4 lines
2.2 MiB
4 lines
2.2 MiB
System.register(["./instantiated-628c9a6a.js","./_commonjsHelpers-364bf34e.js"],(function(t){"use strict";var e,i,r,n,s,a,o,l,h,u,c,_,f,d,p,m,g,y,v,b,S,A,T,C,x,w,E,B,R,D,M,P,I,O,F,L,k,V,N,G,z,U,H,X,W,j,Y,q,K,J,Z,Q,$,tt,et,it,rt,nt,st,at,ot,lt,ht,ut,ct,_t,ft,dt,pt,mt,gt,yt,vt,bt,St,At,Tt,Ct,xt,wt,Et,Bt,Rt,Dt,Mt,Pt,It,Ot,Ft,Lt,kt,Vt,Nt,Gt,zt,Ut,Ht,Xt,Wt,jt,Yt,qt,Kt,Jt,Zt,Qt,$t,te,ee,ie,re,ne,se,ae,oe,le,he,ue,ce,_e,fe,de,pe,me,ge,ye,ve,be,Se,Ae,Te,Ce,xe,we,Ee,Be,Re,De,Me,Pe,Ie,Oe,Fe,Le,ke,Ve,Ne,Ge,ze,Ue,He,Xe,We,je,Ye,qe,Ke,Je,Ze,Qe,$e,ti,ei,ii,ri,ni,si,ai,oi,li,hi,ui,ci,_i,fi,di,pi,mi,gi,yi,vi,bi,Si,Ai,Ti,Ci,xi,wi,Ei,Bi,Ri,Di,Mi,Pi,Ii,Oi,Fi,Li,ki,Vi,Ni,Gi,zi,Ui,Hi,Xi,Wi,ji,Yi,qi,Ki,Ji,Zi,Qi,$i,tr,er,ir,rr,nr,sr,ar,or,lr,hr,ur,cr,_r,fr,dr,pr,mr,gr,yr,vr,br,Sr,Ar,Tr,Cr,xr,wr,Er,Br,Rr,Dr,Mr,Pr,Ir,Or,Fr,Lr,kr,Vr,Nr,Gr,zr,Ur,Hr,Xr,Wr,jr,Yr,qr,Kr,Jr,Zr,Qr,$r,tn,en,rn,nn,sn,an,on,ln,hn,un,cn,_n,fn,dn,pn,mn,gn,yn,vn,bn,Sn,An,Tn,Cn,xn,wn,En,Bn,Rn,Dn,Mn,Pn,In,On,Fn,Ln,kn,Vn,Nn,Gn,zn,Un,Hn,Xn,Wn,jn,Yn,qn,Kn,Jn,Zn,Qn,$n,ts,es,is,rs,ns,ss,as,os,ls,hs,us,cs,_s,fs,ds,ps,ms,gs,ys,vs,bs,Ss,As,Ts,Cs,xs,ws,Es,Bs,Rs,Ds,Ms,Ps,Is,Os,Fs,Ls,ks,Vs,Ns,Gs,zs,Us,Hs,Xs,Ws,js,Ys,qs,Ks,Js,Zs,Qs,$s,ta,ea,ia,ra,na,sa,aa,oa,la,ha,ua,ca,_a,fa,da,pa,ma,ga,ya,va,ba,Sa,Aa,Ta,Ca,xa,wa,Ea,Ba,Ra,Da,Ma,Pa,Ia,Oa,Fa,La,ka,Va,Na,Ga,za,Ua,Ha,Xa,Wa,ja,Ya,qa,Ka,Ja,Za,Qa,$a,to,eo,io,ro,no,so,ao,oo,lo,ho,uo,co,_o,fo,po,mo,go,yo,vo,bo,So,Ao,To,Co,xo,wo,Eo,Bo,Ro,Do,Mo,Po,Io,Oo,Fo,Lo,ko,Vo,No,Go,zo,Uo,Ho,Xo,Wo,jo,Yo,qo,Ko,Jo,Zo,Qo;return{setters:[function(Zo){e=Zo.b,i=Zo.V,r=Zo.v,n=Zo.a,s=Zo.c,a=Zo.d,o=Zo.e,l=Zo.Q,h=Zo.q,u=Zo.M,c=Zo.f,_=Zo.m,f=Zo.A,d=Zo.S,p=Zo.s,m=Zo.R,g=Zo.r,y=Zo.C,v=Zo.g,b=Zo.E,S=Zo.h,A=Zo.i,T=Zo.j,C=Zo.k,x=Zo.l,w=Zo.t,E=Zo.n,B=Zo.o,R=Zo.p,D=Zo.u,M=Zo.w,P=Zo.x,I=Zo.y,O=Zo.z,F=Zo.B,L=Zo.D,k=Zo.F,V=Zo.G,N=Zo.H,G=Zo.I,z=Zo.J,U=Zo.K,H=Zo.P,X=Zo.L,W=Zo.N,j=Zo.O,Y=Zo.T,q=Zo.U,K=Zo.W,J=Zo.X,Z=Zo.Y,Q=Zo.Z,$=Zo._,tt=Zo.$,et=Zo.a0,it=Zo.a1,rt=Zo.a2,nt=Zo.a3,st=Zo.a4,at=Zo.a5,ot=Zo.a6,lt=Zo.a7,ht=Zo.a8,ut=Zo.a9,ct=Zo.aa,_t=Zo.ab,ft=Zo.ac,dt=Zo.ad,pt=Zo.ae,mt=Zo.af,gt=Zo.ag,yt=Zo.ah,vt=Zo.ai,bt=Zo.aj,St=Zo.ak,At=Zo.al,Tt=Zo.am,Ct=Zo.an,xt=Zo.ao,wt=Zo.ap,Et=Zo.aq,Bt=Zo.ar,Rt=Zo.as,Dt=Zo.at,Mt=Zo.au,Pt=Zo.av,It=Zo.aw,Ot=Zo.ax,Ft=Zo.ay,Lt=Zo.az,kt=Zo.aA,Vt=Zo.aB,Nt=Zo.aC,Gt=Zo.aD,zt=Zo.aE,Ut=Zo.aF,Ht=Zo.aG,Xt=Zo.aH,Wt=Zo.aI,jt=Zo.aJ,Yt=Zo.aK,qt=Zo.aL,Kt=Zo.aM,Jt=Zo.aN,Zt=Zo.aO,Qt=Zo.aP,$t=Zo.aQ,te=Zo.aR,ee=Zo.aS,ie=Zo.aT,re=Zo.aU,ne=Zo.aV,se=Zo.aW,ae=Zo.aX,oe=Zo.aY,le=Zo.aZ,he=Zo.a_,ue=Zo.a$,ce=Zo.b0,_e=Zo.b1,fe=Zo.b2,de=Zo.b3,pe=Zo.b4,me=Zo.b5,ge=Zo.b6,ye=Zo.b7,ve=Zo.b8,be=Zo.b9,Se=Zo.ba,Ae=Zo.bb,Te=Zo.bc,Ce=Zo.bd,xe=Zo.be,we=Zo.bf,Ee=Zo.bg,Be=Zo.bh,Re=Zo.bi,De=Zo.bj,Me=Zo.bk,Pe=Zo.bl,Ie=Zo.bm,Oe=Zo.bn,Fe=Zo.bo,Le=Zo.bp,ke=Zo.bq,Ve=Zo.br,Ne=Zo.bs,Ge=Zo.bt,ze=Zo.bu,Ue=Zo.bv,He=Zo.bw,Xe=Zo.bx,We=Zo.by,je=Zo.bz,Ye=Zo.bA,qe=Zo.bB,Ke=Zo.bC,Je=Zo.bD,Ze=Zo.bE,Qe=Zo.bF,$e=Zo.bG,ti=Zo.bH,ei=Zo.bI,ii=Zo.bJ,ri=Zo.bK,ni=Zo.bL,si=Zo.bM,ai=Zo.bN,oi=Zo.bO,li=Zo.bP,hi=Zo.bQ,ui=Zo.bR,ci=Zo.bS,_i=Zo.bT,fi=Zo.bU,di=Zo.bV,pi=Zo.bW,mi=Zo.bX,gi=Zo.bY,yi=Zo.bZ,vi=Zo.b_,bi=Zo.b$,Si=Zo.c0,Ai=Zo.c1,Ti=Zo.c2,Ci=Zo.c3,xi=Zo.c4,wi=Zo.c5,Ei=Zo.c6,Bi=Zo.c7,Ri=Zo.c8,Di=Zo.c9,Mi=Zo.ca,Pi=Zo.cb,Ii=Zo.cc,Oi=Zo.cd,Fi=Zo.ce,Li=Zo.cf,ki=Zo.cg,Vi=Zo.ch,Ni=Zo.ci,Gi=Zo.cj,zi=Zo.ck,Ui=Zo.cl,Hi=Zo.cm,Xi=Zo.cn,Wi=Zo.co,ji=Zo.cp,Yi=Zo.cq,qi=Zo.cr,Ki=Zo.cs,Ji=Zo.ct,Zi=Zo.cu,Qi=Zo.cv,$i=Zo.cw,tr=Zo.cx,er=Zo.cy,ir=Zo.cz,rr=Zo.cA,nr=Zo.cB,sr=Zo.cC,ar=Zo.cD,or=Zo.cE,lr=Zo.cF,hr=Zo.cG,ur=Zo.cH,cr=Zo.cI,_r=Zo.cJ,fr=Zo.cK,dr=Zo.cL,pr=Zo.cM,mr=Zo.cN,gr=Zo.cO,yr=Zo.cP,vr=Zo.cQ,br=Zo.cR,Sr=Zo.cS,Ar=Zo.cT,Tr=Zo.cU,Cr=Zo.cV,xr=Zo.cW,wr=Zo.cX,Er=Zo.cY,Br=Zo.cZ,Rr=Zo.c_,Dr=Zo.c$,Mr=Zo.d0,Pr=Zo.d1,Ir=Zo.d2,Or=Zo.d3,Fr=Zo.d4,Lr=Zo.d5,kr=Zo.d6,Vr=Zo.d7,Nr=Zo.d8,Gr=Zo.d9,zr=Zo.da,Ur=Zo.db,Hr=Zo.dc,Xr=Zo.dd,Wr=Zo.de,jr=Zo.df,Yr=Zo.dg,qr=Zo.dh,Kr=Zo.di,Jr=Zo.dj,Zr=Zo.dk,Qr=Zo.dl,$r=Zo.dm,tn=Zo.dn,en=Zo.dp,rn=Zo.dq,nn=Zo.dr,sn=Zo.ds,an=Zo.dt,on=Zo.du,ln=Zo.dv,hn=Zo.dw,un=Zo.dx,cn=Zo.dy,_n=Zo.dz,fn=Zo.dA,dn=Zo.dB,pn=Zo.dC,mn=Zo.dD,gn=Zo.dE,yn=Zo.dF,vn=Zo.dG,bn=Zo.dH,Sn=Zo.dI,An=Zo.dJ,Tn=Zo.dK,Cn=Zo.dL,xn=Zo.dM,wn=Zo.dN,En=Zo.dO,Bn=Zo.dP,Rn=Zo.dQ,Dn=Zo.dR,Mn=Zo.dS,Pn=Zo.dT,In=Zo.dU,On=Zo.dV,Fn=Zo.dW,Ln=Zo.dX,kn=Zo.dY,Vn=Zo.dZ,Nn=Zo.d_,Gn=Zo.d$,zn=Zo.e0,Un=Zo.e1,Hn=Zo.e2,Xn=Zo.e3,Wn=Zo.e4,jn=Zo.e5,Yn=Zo.e6,qn=Zo.e7,Kn=Zo.e8,Jn=Zo.e9,Zn=Zo.ea,Qn=Zo.eb,$n=Zo.ec,ts=Zo.ed,es=Zo.ee,is=Zo.ef,rs=Zo.eg,ns=Zo.eh,ss=Zo.ei,as=Zo.ej,os=Zo.ek,ls=Zo.el,hs=Zo.em,us=Zo.en,cs=Zo.eo,_s=Zo.ep,fs=Zo.eq,ds=Zo.er,ps=Zo.es,ms=Zo.et,gs=Zo.eu,ys=Zo.ev,vs=Zo.ew,bs=Zo.ex,Ss=Zo.ey,As=Zo.ez,Ts=Zo.eA,Cs=Zo.eB,xs=Zo.eC,ws=Zo.eD,Es=Zo.eE,Bs=Zo.eF,Rs=Zo.eG,Ds=Zo.eH,Ms=Zo.eI,Ps=Zo.eJ,Is=Zo.eK,Os=Zo.eL,Fs=Zo.eM,Ls=Zo.eN,ks=Zo.eO,Vs=Zo.eP,Ns=Zo.eQ,Gs=Zo.eR,zs=Zo.eS,Us=Zo.eT,Hs=Zo.eU,Xs=Zo.eV,Ws=Zo.eW,js=Zo.eX,Ys=Zo.eY,qs=Zo.eZ,Ks=Zo.e_,Js=Zo.e$,Zs=Zo.f0,Qs=Zo.f1,$s=Zo.f2,ta=Zo.f3,ea=Zo.f4,ia=Zo.f5,ra=Zo.f6,na=Zo.f7,sa=Zo.f8,aa=Zo.f9,oa=Zo.fa,la=Zo.fb,ha=Zo.fc,ua=Zo.fd,ca=Zo.fe,_a=Zo.ff,fa=Zo.fg,da=Zo.fh,pa=Zo.fi,ma=Zo.fj,ga=Zo.fk,ya=Zo.fl,va=Zo.fm,ba=Zo.fn,Sa=Zo.fo,Aa=Zo.fp,Ta=Zo.fq,Ca=Zo.fr,xa=Zo.fs,wa=Zo.ft,Ea=Zo.fu,Ba=Zo.fv,Ra=Zo.fw,Da=Zo.fx,Ma=Zo.fy,Pa=Zo.fz,Ia=Zo.fA,Oa=Zo.fB,Fa=Zo.fC,La=Zo.fD,ka=Zo.fE,Va=Zo.fF,Na=Zo.fG,Ga=Zo.fH,za=Zo.fI,Ua=Zo.fJ,Ha=Zo.fK,Xa=Zo.fL,Wa=Zo.fM,ja=Zo.fN,Ya=Zo.fO,qa=Zo.fP,Ka=Zo.fQ,Ja=Zo.fR,Za=Zo.fS,Qa=Zo.fT,$a=Zo.fU,to=Zo.fV,eo=Zo.fW,io=Zo.fX,ro=Zo.fY,no=Zo.fZ,so=Zo.f_,ao=Zo.f$,oo=Zo.g0,lo=Zo.g1,ho=Zo.g2,uo=Zo.g3,co=Zo.g4,_o=Zo.g5,fo=Zo.g6,po=Zo.g7,mo=Zo.g8,go=Zo.g9,yo=Zo.ga,vo=Zo.gb,bo=Zo.gc,So=Zo.gd,Ao=Zo.ge,To=Zo.gf,Co=Zo.gg,xo=Zo.gh,wo=Zo.gi,Eo=Zo.gj,Bo=Zo.gk,Ro=Zo.gl,Do=Zo.gm,Mo=Zo.gn,Po=Zo.go,Io=Zo.gp,Oo=Zo.gq,Fo=Zo.gr,Lo=Zo.gs,ko=Zo.gt,Vo=Zo.gu,No=Zo.gv,Go=Zo.gw,zo=Zo.gx,Uo=Zo.gy,Ho=Zo.gz,Xo=Zo.gA,Wo=Zo.gB,jo=Zo.gC,Yo=Zo.gD,qo=Zo.gE,Ko=Zo.gF,Jo=Zo.gG;var Qo={};Qo.Acceleration=Zo.hQ,Qo.AffineTransform=Zo.A,Qo.AmbientInfo=Zo.hB,Qo.Asset=Zo.dl,Qo.AssetManager=Zo.df,Qo.AsyncDelegate=Zo.g$,Qo.BaseNode=Zo.hy,Qo.BitMask=Zo.gI,Qo.BloomStage=Zo.hp,Qo.BufferAsset=Zo.h0,Qo.CCBoolean=Zo.fc,Qo.CCClass=Zo.g1,Qo.CCFloat=Zo.f8,Qo.CCInteger=Zo.g9,Qo.CCObject=Zo.eP,Qo.CCString=Zo.fb,Qo.CachedArray=Zo.N,Qo.Camera=Zo.eT,Qo.CameraComponent=Zo.eT,Qo.Color=Zo.C,Qo.CompactValueTypeArray=Zo.gX,Qo.Component=Zo.eh,Qo.DEFAULT_OCTREE_DEPTH=Zo.hH,Qo.DEFAULT_WORLD_MAX_POS=Zo.hG,Qo.DEFAULT_WORLD_MIN_POS=Zo.hF,Qo.DebugMode=Zo.ha,Qo.DebugView=Zo.hw,Qo.DeferredPipeline=Zo.hl,Qo.Details=Zo.gV,Qo.Director=Zo.d3,Qo.EPSILON=Zo.E,Qo.EffectAsset=Zo.gk,Qo.Enum=Zo.eS,Qo.Event=Zo.gC,Qo.EventAcceleration=Zo.hN,Qo.EventHandler=Zo.gr,Qo.EventKeyboard=Zo.hO,Qo.EventMouse=Zo.hP,Qo.EventTarget=Zo.fM,Qo.EventTouch=Zo.gA,Qo.Eventify=Zo.fK,Qo.ExtrapolationMode=Zo.hM,Qo.FogInfo=Zo.hD,Qo.ForwardFlow=Zo.hj,Qo.ForwardPipeline=Zo.hi,Qo.ForwardStage=Zo.hk,Qo.Game=Zo.f$,Qo.GbufferStage=Zo.hn,Qo.ImageAsset=Zo.dG,Qo.Input=Zo.f2,Qo.InstancedBuffer=Zo.ht,Qo.JavaScript=Zo.h6,Qo.JsonAsset=Zo.h3,Qo.KeyCode=Zo.gw,Qo.Layers=Zo.eu,Qo.LightingStage=Zo.ho,Qo.MATH_FLOAT_ARRAY=Zo.J,Qo.MainFlow=Zo.hm,Qo.Mat3=Zo.M,Qo.Mat4=Zo.f,Qo.Material=Zo.dy,Qo.MathBase=Zo.K,Qo.MissingScript=Zo.hL,Qo.ModelRenderer=Zo.eY,Qo.Node=Zo.eO,Qo.NodeActivator=Zo.hz,Qo.NodeEventType=Zo.ea,Qo.NodeSpace=Zo.hA,Qo.ObjectCurve=Zo.fs,Qo.OctreeInfo=Zo.hI,Qo.PipelineEventProcessor=Zo.hv,Qo.PipelineEventType=Zo.gm,Qo.PipelineSceneData=Zo.hh,Qo.PipelineStateManager=Zo.hu,Qo.Pool=Zo.P,Qo.PostProcessStage=Zo.hq,Qo.Prefab=Zo.h1,Qo.PrefabLink=Zo.gM,Qo.PrivateNode=Zo.hK,Qo.Quat=Zo.Q,Qo.QuatCurve=Zo.fr,Qo.QuatInterpolationMode=Zo.fH,Qo.RealCurve=Zo.fp,Qo.RealInterpolationMode=Zo.fF,Qo.Rect=Zo.R,Qo.RecyclePool=Zo.L,Qo.RenderFlow=Zo.hf,Qo.RenderPipeline=Zo.he,Qo.RenderStage=Zo.hg,Qo.RenderTexture=Zo.eL,Qo.RenderableComponent=Zo.eY,Qo.Renderer=Zo.el,Qo.RenderingSubMesh=Zo.dP,Qo.ResolutionPolicy=Zo.hb,Qo.Root=Zo.d0,Qo.Scene=Zo.gD,Qo.SceneAsset=Zo.h2,Qo.SceneGlobals=Zo.hJ,Qo.Scheduler=Zo.cZ,Qo.Script=Zo.h5,Qo.Settings=Zo.gg,Qo.ShadowFlow=Zo.hr,Qo.ShadowStage=Zo.hs,Qo.ShadowsInfo=Zo.hE,Qo.Size=Zo.S,Qo.SkyboxInfo=Zo.hC,Qo.System=Zo.c_,Qo.SystemEvent=Zo.hT,Qo.SystemEventType=Zo.gB,Qo.TangentWeightMode=Zo.fG,Qo.TextAsset=Zo.go,Qo.Texture2D=Zo.dA,Qo.TextureCube=Zo.h4,Qo.Touch=Zo.hR,Qo.TransformBit=Zo.eW,Qo.TypeScript=Zo.h7,Qo.VERSION=Zo.gq,Qo.ValueType=Zo.fC,Qo.Vec2=Zo.V,Qo.Vec3=Zo.a,Qo.Vec4=Zo.d,Qo.View=Zo.gF,Qo.WorldNode3DToLocalNodeUI=Zo.gQ,Qo.WorldNode3DToWorldNodeUI=Zo.gR,Qo.__checkObsoleteInNamespace__=Zo.gP,Qo.__checkObsolete__=Zo.gO,Qo._decorator=Zo.gT,Qo.absMax=Zo.H,Qo.absMaxComponent=Zo.G,Qo.approx=Zo.i,Qo.assert=Zo.fS,Qo.assertID=Zo.e7,Qo.assetManager=Zo.d4,Qo.bezier=Zo.gH,Qo.bezierByTime=Zo.fA,Qo.bits=Zo.b,Qo.builtinResMgr=Zo.ek,Qo.ccenum=Zo.ei,Qo.cclegacy=Zo.cY,Qo.clamp=Zo.j,Qo.clamp01=Zo.k,Qo.color=Zo.g,Qo.convertUtils=Zo.gS,Qo.createDefaultPipeline=Zo.hd,Qo.debug=Zo.es,Qo.deprecateModuleExportedName=Zo.gG,Qo.deserialize=Zo.gU,Qo.deserializeTag=Zo.gZ,Qo.director=Zo.di,Qo.easing=Zo.fz,Qo.editorExtrasTag=Zo.gY,Qo.enumerableProps=Zo.I,Qo.equals=Zo.h,Qo.error=Zo.fR,Qo.errorID=Zo.d_,Qo.find=Zo.dY,Qo.game=Zo.d2,Qo.getError=Zo.dg,Qo.getPhaseID=Zo.hx,Qo.getSerializationMetadata=Zo.gW,Qo.input=Zo.f4,Qo.instantiate=Zo.fv,Qo.inverseLerp=Zo.F,Qo.isDisplayStats=Zo.h8,Qo.isValid=Zo.gl,Qo.js=Zo.gJ,Qo.lerp=Zo.l,Qo.log=Zo.fQ,Qo.logID=Zo.f1,Qo.macro=Zo.dh,Qo.markAsWarning=Zo.d1,Qo.mat4=Zo.m,Qo.misc=Zo.gK,Qo.murmurhash2_32_gc=Zo.dU,Qo.nextPow2=Zo.z,Qo.path=Zo.gL,Qo.pingPong=Zo.D,Qo.pipeline=Zo.hc,Qo.pseudoRandom=Zo.w,Qo.pseudoRandomRange=Zo.x,Qo.pseudoRandomRangeInt=Zo.y,Qo.quat=Zo.q,Qo.random=Zo.o,Qo.randomRange=Zo.p,Qo.randomRangeInt=Zo.u,Qo.rect=Zo.r,Qo.removeProperty=Zo.c$,Qo.repeat=Zo.B,Qo.replaceProperty=Zo.cX,Qo.resources=Zo.d6,Qo.screen=Zo.eV,Qo.serializeTag=Zo.g_,Qo.setDefaultLogTimes=Zo.gN,Qo.setDisplayStats=Zo.h9,Qo.settings=Zo.gf,Qo.size=Zo.s,Qo.sys=Zo.dW,Qo.systemEvent=Zo.hS,Qo.toDegree=Zo.n,Qo.toRadian=Zo.t,Qo.v2=Zo.v,Qo.v3=Zo.c,Qo.v4=Zo.e,Qo.view=Zo.eU,Qo.warn=Zo.dH,Qo.warnID=Zo.dQ,t(Qo)},function(t){Zo=t.c,Qo=t.u,t.a}],execute:function(){t({AntiAliasing:void 0,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,PhysicsGroup:void 0,VerticalTextAlignment:void 0,buildShadowPass:Tl,buildShadowPasses:xl,computeRatioByType:AP,earcut:sv,fragmentText:fu,getBaselineOffset:function(){return 0},getCameraUniqueID:Bl,getEnglishWordPartAtFirst:cu,getEnglishWordPartAtLast:_u,getLoadOpOfClearFlag:Rl,getPathFromRoot:function(t,e){for(var i=t,r="";null!==i&&i!==e;)r=i.name+"/"+r,i=i.parent;return r.slice(0,-1)},getRenderArea:Al,getWorldTransformUntilRoot:Ew,isEnglishWordPartAtFirst:function(t){return au.test(t)},isEnglishWordPartAtLast:function(t){return su.test(t)},isUnicodeCJK:ou,isUnicodeSpace:lu,safeMeasureText:hu,sampleAnimationCurve:SP,tween:zvt,tweenUtil:Uvt,validPunctualLightsCulling:Ml});var $o=Object.freeze({__proto__:null,bits:e,Vec2:i,v2:r,Vec3:n,v3:s,Vec4:a,v4:o,Quat:l,quat:h,Mat3:u,Mat4:c,mat4:_,AffineTransform:f,Size:d,size:p,Rect:m,rect:g,Color:y,color:v,EPSILON:b,equals:S,approx:A,clamp:T,clamp01:C,lerp:x,toRadian:w,toDegree:E,random:B,randomRange:R,randomRangeInt:D,pseudoRandom:M,pseudoRandomRange:P,pseudoRandomRangeInt:I,nextPow2:O,repeat:F,pingPong:L,inverseLerp:k,absMaxComponent:V,absMax:N,enumerableProps:G,MATH_FLOAT_ARRAY:z,MathBase:U});t("math",$o),t("memop",Object.freeze({__proto__:null,Pool:H,RecyclePool:X,CachedArray:W})),t("gfx",Object.freeze({__proto__:null,DescriptorSet:j,Buffer:Y,CommandBuffer:q,get ObjectType(){return K},get Status(){return J},get API(){return Z},get SurfaceTransform(){return Q},get Feature(){return $},get Format(){return tt},get FormatType(){return et},get Type(){return it},get BufferUsageBit(){return rt},get BufferFlagBit(){return nt},get MemoryAccessBit(){return st},get MemoryUsageBit(){return at},get TextureType(){return ot},get TextureUsageBit(){return lt},get TextureFlagBit(){return ht},get FormatFeatureBit(){return ut},get SampleCount(){return ct},get VsyncMode(){return _t},get Filter(){return ft},get Address(){return dt},get ComparisonFunc(){return pt},get StencilOp(){return mt},get BlendFactor(){return gt},get BlendOp(){return yt},get ColorMask(){return vt},get ShaderStageFlagBit(){return bt},get LoadOp(){return St},get StoreOp(){return At},get AccessFlagBit(){return Tt},get ResolveMode(){return Ct},get PipelineBindPoint(){return xt},get PrimitiveMode(){return wt},get PolygonMode(){return Et},get ShadeModel(){return Bt},get CullMode(){return Rt},get DynamicStateFlagBit(){return Dt},get StencilFace(){return Mt},get DescriptorType(){return Pt},get QueueType(){return It},get QueryType(){return Ot},get CommandBufferType(){return Ft},get ClearFlagBit(){return Lt},get BarrierType(){return kt},get PassType(){return Vt},Size:Nt,DeviceCaps:Gt,DeviceOptions:zt,Offset:Ut,Rect:Ht,Extent:Xt,TextureSubresLayers:Wt,TextureSubresRange:jt,TextureCopy:Yt,TextureBlit:qt,BufferTextureCopy:Kt,Viewport:Jt,Color:Zt,BindingMappingInfo:Qt,SwapchainInfo:$t,DeviceInfo:te,BufferInfo:ee,BufferViewInfo:ie,DrawInfo:re,DispatchInfo:ne,IndirectBuffer:se,TextureInfo:ae,TextureViewInfo:oe,SamplerInfo:le,Uniform:he,UniformBlock:ue,UniformSamplerTexture:ce,UniformSampler:_e,UniformTexture:fe,UniformStorageImage:de,UniformStorageBuffer:pe,UniformInputAttachment:me,ShaderStage:ge,Attribute:ye,ShaderInfo:ve,InputAssemblerInfo:be,ColorAttachment:Se,DepthStencilAttachment:Ae,SubpassInfo:Te,SubpassDependency:Ce,RenderPassInfo:xe,GeneralBarrierInfo:we,TextureBarrierInfo:Ee,BufferBarrierInfo:Be,FramebufferInfo:Re,DescriptorSetLayoutBinding:De,DescriptorSetLayoutInfo:Me,DescriptorSetInfo:Pe,PipelineLayoutInfo:Ie,InputState:Oe,CommandBufferInfo:Fe,QueueInfo:Le,QueryPoolInfo:ke,FormatInfo:Ve,MemoryStatus:Ne,DynamicStencilStates:Ge,DynamicStates:ze,GFXObject:Ue,get AttributeName(){return He},FormatInfos:Xe,DESCRIPTOR_BUFFER_TYPE:We,DESCRIPTOR_SAMPLER_TYPE:je,DESCRIPTOR_DYNAMIC_TYPE:Ye,DRAW_INFO_SIZE:qe,IsPowerOf2:Ke,FormatSize:Je,FormatSurfaceSize:Ze,GetTypeSize:Qe,getTypedArrayConstructor:$e,formatAlignment:ti,alignTo:ei,Device:ii,Swapchain:ri,Framebuffer:ni,InputAssembler:si,DescriptorSetLayout:ai,PipelineLayout:oi,RasterizerState:li,DepthStencilState:hi,BlendTarget:ui,BlendState:ci,PipelineStateInfo:_i,PipelineState:fi,Queue:di,RenderPass:pi,Sampler:mi,Shader:gi,Texture:yi,GeneralBarrier:vi,TextureBarrier:bi,get LegacyRenderMode(){return Si},get RenderType(){return Ai},DeviceManager:Ti,deviceManager:Ci}));var tl=Object.freeze({__proto__:null,distance:xi,enums:wi,intersect:Ei,Line:Bi,Plane:Ri,Ray:Di,Triangle:Mi,Sphere:Pi,AABB:Ii,OBB:Oi,Capsule:Fi,Frustum:Li,Keyframe:ki,AnimationCurve:Vi,get SplineMode(){return Ni},Spline:Gi,get ERaycastMode(){return zi},line:Ui,plane:Hi,ray:Xi,triangle:Wi,sphere:ji,aabb:Yi,obb:qi,capsule:Ki,frustum:Ji});t("geometry",tl);var el=Object.freeze({__proto__:null,get CameraFOVAxis(){return Zi},get CameraProjection(){return Qi},get CameraAperture(){return $i},get CameraISO(){return tr},get CameraShutter(){return er},SKYBOX_FLAG:ir,Camera:rr,get ModelType(){return nr},Model:sr,SubModel:ar,Ambient:or,EnvironmentLightingType:lr,Skybox:hr,ShadowSize:ur,ShadowType:cr,PCFType:_r,CSMLevel:fr,CSMOptimizationMode:dr,Shadows:pr,FogType:mr,Fog:gr,Octree:yr,ColorTemperatureToRGB:vr,get LightType(){return br},nt2lm:Sr,Light:Ar,DirectionalLight:Tr,SphereLight:Cr,SpotLight:xr}),il={};wr(il,"vmath",[{name:"vec2",newName:"Vec2",target:$o,targetName:"math"},{name:"vec3",newName:"Vec3",target:$o,targetName:"math"},{name:"vec4",newName:"Vec4",target:$o,targetName:"math"},{name:"quat",newName:"Quat",target:$o,targetName:"math"},{name:"mat3",newName:"Mat3",target:$o,targetName:"math"},{name:"mat4",newName:"Mat4",target:$o,targetName:"math"},{name:"color4",newName:"Color",target:$o,targetName:"math"},{name:"rect",newName:"Rect",target:$o,targetName:"math"},{name:"approx",newName:"approx",target:$o,targetName:"math"},{name:"EPSILON",newName:"EPSILON",target:$o,targetName:"math"},{name:"equals",newName:"equals",target:$o,targetName:"math"},{name:"clamp",newName:"clamp",target:$o,targetName:"math"},{name:"clamp01",newName:"clamp01",target:$o,targetName:"math"},{name:"lerp",newName:"lerp",target:$o,targetName:"math"},{name:"toRadian",newName:"toRadian",target:$o,targetName:"math"},{name:"toDegree",newName:"toDegree",target:$o,targetName:"math"},{name:"random",newName:"random",target:$o,targetName:"math"},{name:"randomRange",newName:"randomRange",target:$o,targetName:"math"},{name:"randomRangeInt",newName:"randomRangeInt",target:$o,targetName:"math"},{name:"pseudoRandom",newName:"pseudoRandom",target:$o,targetName:"math"},{name:"pseudoRandomRangeInt",newName:"pseudoRandomRangeInt",target:$o,targetName:"math"},{name:"nextPow2",newName:"nextPow2",target:$o,targetName:"math"},{name:"repeat",newName:"repeat",target:$o,targetName:"math"},{name:"pingPong",newName:"pingPong",target:$o,targetName:"math"},{name:"inverseLerp",newName:"inverseLerp",target:$o,targetName:"math"}]),Er.vmath=il,wr(Br.prototype,"Scheduler.prototype",[{name:"enableForTarget",newName:"enableForTarget",target:Br,targetName:"Scheduler"}]),wr(Br,"Scheduler",[{name:"PRIORITY_SYSTEM",newName:"System.Priority.SCHEDULER",customGetter:function(){return Rr.Priority.SCHEDULER}}]),Dr(Br,"Scheduler",[{name:"PRIORITY_NON_SYSTEM",suggest:"Use enum` System.Priority` instead"}]),wr(ar.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),Dr(ar.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]),wr(Mr.prototype,"Root.prototype",[{name:"ui",newName:"batcher2D"}]),Pr(Ir,"game",[{name:"collisionMatrix"},{name:"groupList"}]),Pr(Or.prototype,"director",[{name:"calculateDeltaTime"},{name:"getDeltaTime",suggest:"Use game.deltaTime instead"},{name:"getTotalTime",suggest:"Use game.totalTime instead"},{name:"getCurrentTime",suggest:"Use game.frameStartTime instead"}]),Dr(Or.prototype,"director",[{name:"setAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getRunningScene",suggest:"please use getScene instead"},{name:"setDepthTest",suggest:"please use camera API instead"},{name:"setClearColor",suggest:"please use camera API instead"},{name:"getWinSize",suggest:"please use view.getVisibleSize instead"},{name:"getWinSizeInPixels"},{name:"purgeCachedData",suggest:"please use assetManager.releaseAll instead"},{name:"convertToGL"},{name:"convertToUI"}]);var rl=[".png",".jpg",".bmp",".jpeg",".gif",".ico",".tiff",".webp",".image",".pvr",".pkm",".astc"],nl=[".mp3",".ogg",".wav",".m4a"];function sl(){return!0}var al={transformURL:function(t){var e=rn(t);if(!e)return t;var i=nn.find((function(t){return!!t.getAssetInfo(e)}));if(!i)return t;var r,n=i.getAssetInfo(e);if(!(r=t.startsWith(i.base+i.config.nativeBase)?n.nativeVer||"":n.ver||"")||-1!==t.indexOf(r))return t;var s=!1;if(".ttf"===Lr(t)&&(s=!0),s){var a=sn(t),o=an(t);t=a+"."+r+"/"+o}else t=t.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,})/,(function(t){return t+"."+r}));return t}},ol=t("CCLoader",function(){function t(){this._autoReleaseSetting=Object.create(null),this._parseLoadResArgs=Zr}var e=t.prototype;return e.load=function(t,e,i){void 0===i&&void 0!==e&&(i=e,e=null);for(var r=Array.isArray(t)?t:[t],n=0;n<r.length;n++){var s=r[n];"string"==typeof s?r[n]={url:s,__isNative__:!0}:(s.type&&(s.ext="."+s.type,s.type=void 0),s.url&&(s.__isNative__=!0))}var a=[],o=[];Fr.loadAny(r,null,(function(t,i,r){r.content&&(rl.includes(r.ext)?a.push(r.content):nl.includes(r.ext)&&o.push(r.content)),e&&e(t,i,r)}),(function(t,e){var n=null;if(!t){e=Array.isArray(e)?e:[e];for(var s=function(t){var i=e[t];if(!(i instanceof Qr)){var n=i,s=r[t].url;a.includes(n)?$r.create(s,i,".png",{},(function(i,r){n=e[t]=r})):o.includes(n)&&$r.create(s,i,".mp3",{},(function(i,r){n=e[t]=r})),Vr.add(s,n)}},l=0;l<e.length;l++)s(l);if(e.length>1){var h=Object.create(null);e.forEach((function(t){h[t._uuid]=t})),n={isCompleted:sl,_map:h}}else n=e[0]}i&&i(t,n)}))},e.getXMLHttpRequest=function(){return new XMLHttpRequest},e.getItem=function(t){return Fr.assets.has(t)?{content:Fr.assets.get(t)}:null},e.loadRes=function(t,e,i,r){var n=this._parseLoadResArgs(e,i,r),s=n.type,a=n.onProgress,o=n.onComplete,l=Lr(t);l&&!kr.getInfoWithPath(t,s)&&(t=t.slice(0,-l.length)),kr.load(t,s,a,o)},e.loadResArray=function(t,e,i,r){var n=this._parseLoadResArgs(e,i,r),s=n.type,a=n.onProgress,o=n.onComplete;t.forEach((function(e,i){var r=Lr(e);r&&!kr.getInfoWithPath(e,s)&&(t[i]=e.slice(0,-r.length))})),kr.load(t,s,a,o)},e.loadResDir=function(t,e,i,r){var n=this._parseLoadResArgs(e,i,r),s=n.type,a=n.onProgress,o=n.onComplete;kr.loadDir(t,s,a,(function(e,i){var r=[];e||(r=kr.getDirWithPath(t,s).map((function(t){return t.path}))),o&&o(e,i,r)}))},e.getRes=function(t,e){return Vr.has(t)?Vr.get(t):kr.get(t,e)},e.getResCount=function(){return Vr.count},e.getDependsRecursively=function(t){if(!t)return[];var e="string"==typeof t?t:t._uuid;return Nr.getDepsRecursively(e).concat([e])},e.addDownloadHandlers=function(t){var e=Object.create(null),i=function(i){var r=t[i];e["."+i]=function(t,e,i){r({url:t},i)}};for(var r in t)i(r);Gr.register(e)},e.addLoadHandlers=function(t){var e=Object.create(null),i=function(i){var r=t[i];e["."+i]=function(t,e,i){r({content:t},i)}};for(var r in t)i(r);zr.register(e)},e.release=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++){var i=t[e];"string"==typeof i&&(i=Vr.get(i)),Fr.releaseAsset(i)}else t&&("string"==typeof t&&(t=Vr.get(t)),Fr.releaseAsset(t))},e.releaseAsset=function(t){Fr.releaseAsset(t)},e.releaseRes=function(t,e){kr.release(t,e)},e.releaseAll=function(){Fr.releaseAll(),Vr.clear()},e.removeItem=function(t){return!!Vr.remove(t)},e.setAutoRelease=function(t,e){"object"==typeof t&&(t=t._uuid),this._autoReleaseSetting[t]=!!e},e.setAutoReleaseRecursively=function(t,e){"object"==typeof t&&(t=t._uuid),e=!!e,this._autoReleaseSetting[t]=e;for(var i=Nr.getDepsRecursively(t),r=0;r<i.length;r++)this._autoReleaseSetting[i[r]]=e},e.isAutoRelease=function(t){return"object"==typeof t&&(t=t._uuid),!!this._autoReleaseSetting[t]},Ur(t,[{key:"onProgress",set:function(t){tn(t)}},{key:"_cache",get:function(){if(Vr instanceof en)return Vr._map;var t={};return Vr.forEach((function(e,i){t[i]=e})),t}},{key:"md5Pipe",get:function(){return al}},{key:"downloader",get:function(){return Gr}},{key:"loader",get:function(){return Fr.parser}}]),t}()),ll=t("loader",new ol),hl=t("AssetLibrary",{init:function(t){t.importBase=t.libraryPath,t.nativeBase=t.rawAssetsBase,Fr.init(t),t.rawAssets&&kr.init({base:"",deps:[],scenes:{},redirect:[],debug:!0,packs:{},types:[],versions:{import:[],native:[]},name:Hr.RESOURCES,importBase:t.importBase,nativeBase:t.nativeBase,paths:t.rawAssets.assets,uuids:Object.keys(t.rawAssets.assets),extensionMap:{}})},loadAsset:function(t,e){Fr.loadAny(t,e)}}),ul=t("url",{});wr(ul,"url",[{name:"normalize",target:Fr.utils,targetName:"assetManager.utils",newName:"normalize"},{name:"raw",targetName:"Asset.prototype",newName:"nativeUrl",customFunction:function(t){return t.startsWith("resources/")?Xr({path:Wr(t.substr(10)),bundle:Hr.RESOURCES,__isNative__:!0,ext:Lr(t)}):""}}]),Dr(hl,"AssetLibrary",[{name:"getLibUrlNoExt",suggest:"AssetLibrary.getLibUrlNoExt was removed, if you want to transform url, please use assetManager.utils.getUrlWithUuid instead"},{name:"queryAssetInfo",suggest:"AssetLibrary.queryAssetInfo was removed"}]),Dr(ll,"loader",[{name:"releaseResDir",suggest:"loader.releaseResDir was removed, please use assetManager.releaseAsset instead"},{name:"flowInDeps",suggest:"loader.flowInDeps was removed"},{name:"assetLoader",suggest:"loader.assetLoader was removed, assetLoader and md5Pipe were merged into assetManager.transformPipeline"}]),wr(Er,"cc",[{name:"loader",newName:"assetManager",logTimes:1,customGetter:function(){return ll}},{name:"AssetLibrary",newName:"assetManager",logTimes:1,customGetter:function(){return hl}},{name:"Pipeline",target:jr,targetName:"AssetManager",newName:"Pipeline",logTimes:1},{name:"url",targetName:"assetManager",newName:"utils",logTimes:1,customGetter:function(){return ul}}]),Dr(Er,"cc",[{name:"LoadingItems",suggest:Yr(1400,"LoadingItems","AssetManager.Task")}]),wr(qr,"macro",[{name:"DOWNLOAD_MAX_CONCURRENT",target:Gr,targetName:"assetManager.downloader",newName:"maxConcurrency"}]),wr(Kr,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(t){var e;return Fr.main?null===(e=Fr.main.getSceneInfo(t))||void 0===e?void 0:e.uuid:""}}]),wr(Ir,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var t=[];return Fr.main&&Fr.main.config.scenes.forEach((function(e){t.push(e)})),t}}]);var cl=Jr._autoRelease;Jr._autoRelease=function(t,e,i){cl.call(Jr,t,e,i);for(var r=ll._autoReleaseSetting,n=Object.keys(r),s=0;s<n.length;s++){var a=n[s];if(!0===r[a]){var o=Vr.get(a);o&&Jr.tryRelease(o)}}};var _l,fl,dl,pl,ml,gl=function(t,e,i,r,n,s,a){void 0===t&&(t=""),void 0===e&&(e=2),void 0===i&&(i=0),void 0===r&&(r=St.LOAD),void 0===n&&(n=At.STORE),void 0===s&&(s=Lt.ALL),void 0===a&&(a=new Zt),this.slotName=void 0,this.accessType=void 0,this.attachmentType=void 0,this.loadOp=void 0,this.storeOp=void 0,this.clearFlags=void 0,this.clearColor=void 0,this.slotName=t,this.accessType=e,this.attachmentType=i,this.loadOp=r,this.storeOp=n,this.clearFlags=s,this.clearColor=a},yl=function(){this.name="",this.accessType=0,this.clearFlags=Lt.NONE,this.clearColor=new Zt,this.clearValueType=0},vl=function(t,e){void 0===t&&(t=null),void 0===e&&(e=0),this.light=void 0,this.level=void 0,this.light=t,this.level=e},bl=function(){},Sl=(on((function(){return ml.apply(this,arguments)||this}),ml=bl),on((function(){return pl.apply(this,arguments)||this}),pl=bl),on((function(){return dl.apply(this,arguments)||this}),dl=bl),on((function(){return fl.apply(this,arguments)||this}),fl=bl),on((function(){return _l.apply(this,arguments)||this}),_l=function(){}),function(){});function Al(t,e,i,r,n){void 0===r&&(r=null),void 0===n&&(n=0);var s=new Ht,a=t.viewport,o=e,l=i;if(s.x=a.x*o,s.y=a.y*l,s.width=a.width*o,s.height=a.height*l,r)switch(r.type){case br.DIRECTIONAL:var h=r;h.shadowFixedArea||h.csmLevel===fr.LEVEL_1?(s.x=0,s.y=0,s.width=o,s.height=l):(s.x=n%2*.5*o,s.y=.5*(1-Math.floor(n/2))*l,s.width=.5*o,s.height=.5*l);break;case br.SPOT:s.x=0,s.y=0,s.width=o,s.height=l}return s}function Tl(t,e,i,r,n,s,a){var o=e.device,l=t;if(!e.containsResource(l)){var h=ln(o)?tt.R32F:tt.RGBA8;e.addRenderTarget(l,h,s,a,0),e.addDepthStencil(l+"Depth",tt.DEPTH_STENCIL,s,a,0)}var u=e.addRasterPass(s,a,"default",t);u.addRasterView(l,new gl("_",2,0,St.CLEAR,At.STORE,Lt.COLOR,new Zt(1,1,1,i.clearColor.w))),u.addRasterView(l+"Depth",new gl("_",2,1,St.CLEAR,At.DISCARD,Lt.DEPTH_STENCIL,new Zt(i.clearDepth,i.clearStencil,0,0)));var c=Al(i,s,a,r,n);u.setViewport(new Jt(c.x,c.y,c.width,c.height)),u.addQueue(1).addSceneOfCamera(i,new vl(r,n),8)}var Cl=function(){this.shadowEnabled=!1,this.mainLightShadowNames=new Array,this.spotLightShadowNames=new Array};function xl(t,e,i){var r=i,n=r.pipelineSceneData.shadows,s=i.pipelineSceneData.validPunctualLights,a=new Cl,o=i.pipelineSceneData.shadows;if(!n.enabled||n.type!==cr.ShadowMap)return a;a.shadowEnabled=!0;for(var l=[],h=0,u=0;h<n.maxReceived&&u<s.length;){var c=s[u];c.type===br.SPOT&&c.shadowEnabled&&(l.push(c),h++),u++}var _=e.scene.mainLight,f=o.size.x,d=o.size.y;if(_&&_.shadowEnabled)if(a.mainLightShadowNames[0]="MainLightShadow"+t,_.shadowFixedArea)Tl(a.mainLightShadowNames[0],i,e,_,0,f,d);else for(var p=r.pipelineSceneData.csmSupported?_.csmLevel:1,m=0;m<p;m++)a.mainLightShadowNames[m]="MainLightShadow"+t,Tl(a.mainLightShadowNames[m],i,e,_,m,f,d);for(var g=0;g<l.length;g++){var y=l[g],v="SpotLightShadow"+g.toString()+t;a.spotLightShadowNames[g]=v,Tl(v,i,e,y,0,f,d)}return a}var wl,El=[];function Bl(t){return El.includes(t)||El.push(t),El.indexOf(t)}function Rl(t,e){var i=St.CLEAR;return t&Lt.COLOR||0!==e||(i=t&ir?St.DISCARD:St.LOAD),(t&Lt.DEPTH_STENCIL)!==Lt.DEPTH_STENCIL&&1===e&&(t&Lt.DEPTH||(i=St.LOAD),t&Lt.STENCIL||(i=St.LOAD)),i}t("ForwardPipelineBuilder",function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.prototype.setup=function(t,e){for(var i=0;i<t.length;i++){var r=t[i];if(null!==r.scene){Ml(e,r);var n=Bl(r),s="Camera"+n,a=xl(s,r,e),o=r.window.width,l=r.window.height,h="dsForwardPassColor"+s,u="dsForwardPassDS"+s;e.containsResource(h)||(e.addRenderTexture(h,tt.RGBA8,o,l,r.window),e.addDepthStencil(u,tt.DEPTH_STENCIL,o,l,0));for(var c,_=e.addRasterPass(o,l,"default","CameraForwardPass"+n),f=hn(a.mainLightShadowNames);!(c=f()).done;){var d=c.value;if(e.containsResource(d)){var p=new yl;_.addComputeView(d,p)}}for(var m,g=hn(a.spotLightShadowNames);!(m=g()).done;){var y=m.value;if(e.containsResource(y)){var v=new yl;_.addComputeView(y,v)}}var b=new gl("_",2,0,Rl(r.clearFlag,0),At.STORE,r.clearFlag,new Zt(r.clearColor.x,r.clearColor.y,r.clearColor.z,r.clearColor.w)),S=new gl("_",2,1,Rl(r.clearFlag,1),At.STORE,r.clearFlag,new Zt(r.clearDepth,r.clearStencil,0,0));_.addRasterView(h,b),_.addRasterView(u,S),_.addQueue(1).addSceneOfCamera(r,new vl,291),_.addQueue(3).addSceneOfCamera(r,new vl,1556)}}},e}(Sl)),function(t){t[t.NONE=0]="NONE",t[t.FXAA=1]="FXAA"}(wl||(wl=t("AntiAliasing",{})));var Dl=function(){this._deferredLightingMaterial=void 0,this._deferredPostMaterial=void 0,this._antiAliasing=wl.NONE,this._deferredLightingMaterial=new cn,this._deferredLightingMaterial.name="builtin-deferred-material",this._deferredLightingMaterial.initialize({effectName:"pipeline/deferred-lighting",defines:{CC_RECEIVE_SHADOW:1}});for(var t=0;t<this._deferredLightingMaterial.passes.length;++t)this._deferredLightingMaterial.passes[t].tryCompile();this._deferredPostMaterial=new cn,this._deferredPostMaterial.name="builtin-post-process-material",qr.ENABLE_ANTIALIAS_FXAA&&(this._antiAliasing=wl.FXAA),this._deferredPostMaterial.initialize({effectName:"pipeline/post-process",defines:{ANTIALIAS_TYPE:this._antiAliasing}});for(var e=0;e<this._deferredPostMaterial.passes.length;++e)this._deferredPostMaterial.passes[e].tryCompile()};function Ml(t,e){var i=t.pipelineSceneData.validPunctualLights;i.length=0;for(var r=Pi.create(0,0,0,1),n=e.scene.spotLights,s=0;s<n.length;s++){var a=n[s];a.baked||(Pi.set(r,a.position.x,a.position.y,a.position.z,a.range),Ei.sphereFrustum(r,e.frustum)&&i.push(a))}for(var o=e.scene.sphereLights,l=0;l<o.length;l++){var h=o[l];h.baked||(Pi.set(r,h.position.x,h.position.y,h.position.z,h.range),Ei.sphereFrustum(r,e.frustum)&&i.push(h))}}t("DeferredPipelineBuilder",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)._deferredData=new Dl,e}return on(e,t),e.prototype.setup=function(t,e){for(var i=0;i<t.length;++i){var r=t[i];if(r.scene){Ml(e,r);var n=Bl(r),s=xl("Camera"+n,r,e),a=r.window.width,o=r.window.height,l="dsDeferredPassColorCamera",h="deferredGbufferPassNormal",u="deferredGbufferPassEmissive",c="dsDeferredPassDSCamera";if(!e.containsResource(l)){var _=tt.RGBA16F;e.addRenderTarget(l,_,a,o,0),e.addRenderTarget(h,_,a,o,0),e.addRenderTarget(u,_,a,o,0),e.addDepthStencil(c,tt.DEPTH_STENCIL,a,o,0)}var f=e.addRasterPass(a,o,"Geometry","CameraGbufferPass"+n),d=new Zt(0,0,0,0);r.clearFlag&Lt.COLOR&&(e.pipelineSceneData.isHDR?un(d,r.clearColor):(d.x=r.clearColor.x,d.y=r.clearColor.y,d.z=r.clearColor.z));var p=new gl("_",2,0,St.CLEAR,At.STORE,r.clearFlag,d),m=new gl("_",2,0,St.CLEAR,At.STORE,r.clearFlag,new Zt(0,0,0,0)),g=new gl("_",2,0,St.CLEAR,At.STORE,r.clearFlag,new Zt(0,0,0,0)),y=new gl("_",2,1,St.CLEAR,At.STORE,r.clearFlag,new Zt(r.clearDepth,r.clearStencil,0,0));f.addRasterView(l,p),f.addRasterView(h,m),f.addRasterView(u,g),f.addRasterView(c,y),f.addQueue(1).addSceneOfCamera(r,new vl,3);var v="deferredLightingPassRTName";e.containsResource(v)||(e.addRenderTarget(v,tt.RGBA8,a,o,0),e.addDepthStencil("deferredLightingPassDS",tt.DEPTH_STENCIL,a,o,0));for(var b,S=e.addRasterPass(a,o,"Lighting","CameraLightingPass"+n),A=hn(s.mainLightShadowNames);!(b=A()).done;){var T=b.value;if(e.containsResource(T)){var C=new yl;S.addComputeView(T,C)}}for(var x,w=hn(s.spotLightShadowNames);!(x=w()).done;){var E=x.value;if(e.containsResource(E)){var B=new yl;S.addComputeView(E,B)}}if(e.containsResource(l)){var R=new yl;R.name="gbuffer_albedoMap",S.addComputeView(l,R);var D=new yl;D.name="gbuffer_normalMap",S.addComputeView(h,D);var M=new yl;M.name="gbuffer_emissiveMap",S.addComputeView(u,M);var P=new yl;P.name="depth_stencil",S.addComputeView(c,P)}var I=new Zt(0,0,0,0);r.clearFlag&Lt.COLOR&&(I.x=r.clearColor.x,I.y=r.clearColor.y,I.z=r.clearColor.z),I.w=0;var O=new gl("_",2,0,St.CLEAR,At.STORE,r.clearFlag,I);S.addRasterView(v,O),S.addQueue(3).addCameraQuad(r,this._deferredData._deferredLightingMaterial,64),S.addQueue(3).addSceneOfCamera(r,new vl,772);var F="postprocessPassRTName"+n,L="postprocessPassDS"+n;e.containsResource(F)||(e.addRenderTexture(F,tt.RGBA8,a,o,r.window),e.addDepthStencil(L,tt.DEPTH_STENCIL,a,o,0));var k=e.addRasterPass(a,o,"Postprocess","CameraPostprocessPass"+n);if(e.containsResource(v)){var V=new yl;V.name="outputResultMap",k.addComputeView(v,V)}var N=new Zt(0,0,0,r.clearColor.w);r.clearFlag&Lt.COLOR&&(N.x=r.clearColor.x,N.y=r.clearColor.y,N.z=r.clearColor.z);var G=new gl("_",2,0,Rl(r.clearFlag,0),At.STORE,r.clearFlag,N),z=new gl("_",2,1,Rl(r.clearFlag,1),At.STORE,r.clearFlag,new Zt(r.clearDepth,r.clearStencil,0,0));k.addRasterView(F,G),k.addRasterView(L,z),k.addQueue(0).addFullscreenQuad(this._deferredData._deferredPostMaterial,0),k.addQueue(3).addSceneOfCamera(r,new vl,1040)}}},e}(Sl)),Er.math=$o,Er.geometry=tl;var Pl=new n,Il=new c;function Ol(t,e,i,r){var s=i.chunk,a=i.data,o=s.vb,l=i.vertexCount;t.getWorldMatrix(Il);for(var h=0,u=0;u<l;u++){var c=a[u];n.set(Pl,c.x,c.y,0),n.transformMat4(Pl,Pl,Il),o[h++]=Pl.x,o[h++]=Pl.y,o[h++]=Pl.z,y.toArray(o,r,h+2),h+=6}s.bufferId;for(var _=s.vertexOffset,f=s.meshBuffer,d=s.meshBuffer.iData,p=f.indexOffset,m=0,g=l/4;m<g;m++){var v=_+4*m;d[p++]=v,d[p++]=v+1,d[p++]=v+2,d[p++]=v+1,d[p++]=v+3,d[p++]=v+2}f.indexOffset+=i.indexCount,f.setDirty()}var Fl={},Ll=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 kl;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;Er.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}(),kl=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=_n.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var r=this.getGFXTexture();if(t&&r){var n=this._getGFXDevice();if(n){var s=new Kt;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}(fn),Vl=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)._atlases=[],e._atlasIndex=-1,e._maxAtlasCount=5,e._textureSize=2048,e._maxFrameSize=512,e._textureBleeding=!0,e._enabled=!1,e}on(e,t);var i=e.prototype;return i.newAtlas=function(){var t=this._atlases[++this._atlasIndex];return t||(t=new Ll(this._textureSize,this._textureSize),this._atlases.push(t)),t},i.beforeSceneLoad=function(){this.reset()},i.init=function(){this.enabled=!qr.CLEANUP_IMAGE_CACHE},i.insertSpriteFrame=function(t){if(!this._enabled||this._atlasIndex===this._maxAtlasCount||!t||t._original)return null;if(!t.packable)return null;var e=t.texture.getSamplerInfo();if(e.minFilter!==dn.LINEAR||e.magFilter!==dn.LINEAR||e.mipFilter!==dn.NONE)return null;var i=this._atlases[this._atlasIndex];i||(i=this.newAtlas());var r=i.insertSpriteFrame(t);return r||this._atlasIndex===this._maxAtlasCount?r:(i=this.newAtlas()).insertSpriteFrame(t)},i.reset=function(){for(var t=0,e=this._atlases.length;t<e;t++)this._atlases[t].destroy();this._atlases.length=0,this._atlasIndex=-1},i.deleteAtlasSpriteFrame=function(t){if(t._original){for(var e,i=this._atlases.length-1;i>=0;i--)e=this._atlases[i],pn.array.fastRemove(e._innerSpriteFrames,t);var r=t._original._texture;this.deleteAtlasTexture(r)}},i.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--)},i.packToDynamicAtlas=function(t,e){if(this._enabled&&e&&!e._original&&e.packable&&e.texture&&e.texture.width>0&&e.texture.height>0){var i=this.insertSpriteFrame(e);i&&e._setDynamicAtlasFrame(i)}},Ur(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(t?(this.reset(),Er.director.on(Er.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),Er.director.off(Er.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}}]),e}(Rr);Vl.instance=void 0;var Nl,Gl=t("dynamicAtlasManager",Vl.instance=new Vl);Kr.registerSystem("dynamicAtlasManager",Gl,0),Er.internal.dynamicAtlasManager=Gl,function(t){t[t.positions=He.ATTR_POSITION]="positions",t[t.normals=He.ATTR_NORMAL]="normals",t[t.uvs=He.ATTR_TEX_COORD]="uvs",t[t.colors=He.ATTR_COLOR]="colors"}(Nl||(Nl={}));var zl,Ul,Hl,Xl,Wl,jl,Yl=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}(),ql=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>yn.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[r]=new Jl(this._mesh,r,this._mesh.struct.morph,e):this._subMeshRenderings[r]=new Kl(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){Tn(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(He.ATTR_POSITION)&&s.push({name:"CC_MORPH_TARGET_HAS_POSITION",value:!0}),r.attributes.includes(He.ATTR_NORMAL)&&s.push({name:"CC_MORPH_TARGET_HAS_NORMAL",value:!0}),r.attributes.includes(He.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=hn(i);!(t=e()).done;){var r=t.value;null==r||r.destroy()}}}},t}(),Kl=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,th(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=$l(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=hn(this._attributes);!(t=e()).done;)t.value.morphTexture.destroy()},e.createInstance=function(){var t=this,e=new Ql(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=hn(t._attributes);!(r=n()).done;){var s=r.value,a=void 0;switch(s.name){case He.ATTR_POSITION:a=wn;break;case He.ATTR_NORMAL:a=xn;break;case He.ATTR_TANGENT:a=Cn;break;default:bn("Unexpected attribute!")}void 0!==a&&(i.bindSampler(a,s.morphTexture.sampler),i.bindTexture(a,s.morphTexture.texture))}i.bindBuffer(yn.BINDING,e.buffer),i.update()},destroy:function(){}}},t}(),Jl=function(){function t(t,e,i,r){this._gfxDevice=void 0,this._attributes=[],this._gfxDevice=r;var n=i.subMeshMorphs[e];th(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 Zl(this,this._attributes[0].targets[0].displacements.length/3,this._gfxDevice)},Ur(t,[{key:"data",get:function(){return this._attributes}}]),t}(),Zl=function(){function t(t,e,i){this._attributes=void 0,this._owner=void 0,this._morphUniforms=void 0,this._owner=t,this._morphUniforms=new Ql(i,0);var r=$l(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];gn(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=hn(this._attributes);!(e=i()).done;){var r=e.value,n=void 0;switch(r.attributeName){case He.ATTR_POSITION:n=wn;break;case He.ATTR_NORMAL:n=xn;break;case He.ATTR_TANGENT:n=Cn;break;default:bn("Unexpected attribute!")}void 0!==n&&(t.bindSampler(n,r.morphTexture.sampler),t.bindTexture(n,r.morphTexture.texture))}t.bindBuffer(yn.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}(),Ql=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(yn.SIZE)),this._remoteBuffer=t.createBuffer(new ee(rt.UNIFORM|rt.TRANSFER_DST,at.HOST|at.DEVICE,yn.SIZE,yn.SIZE))}var e=t.prototype;return e.destroy=function(){this._remoteBuffer.destroy()},e.setWeights=function(t){gn(t.length===this._targetCount);for(var e=0;e<t.length;++e)this._localBuffer.setFloat32(yn.OFFSET_OF_WEIGHTS+4*e,t[e],Er.sys.isLittleEndian)},e.setMorphTextureInfo=function(t,e){this._localBuffer.setFloat32(yn.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH,t,Er.sys.isLittleEndian),this._localBuffer.setFloat32(yn.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT,e,Er.sys.isLittleEndian)},e.setVerticesCount=function(t){this._localBuffer.setFloat32(yn.OFFSET_OF_VERTICES_COUNT,t,Er.sys.isLittleEndian)},e.commit=function(){this._remoteBuffer.update(this._localBuffer.buffer)},Ur(t,[{key:"buffer",get:function(){return this._remoteBuffer}}]),t}();function $l(t,e){var i,r,n,s;t.getFormatFeatures(tt.RGBA32F)&ut.SAMPLED_TEXTURE?(i=e,n=16,r=fn.PixelFormat.RGBA32F,s=Float32Array):(i=4*e,n=4,r=fn.PixelFormat.RGBA8888,s=Uint8Array);var a=function(t){t<5&&(t=5);var e=Sn(t),i=An(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 vn({width:o,height:l,_data:a,_compressed:!1,format:r}),u=new fn;u.setFilters(fn.Filter.NEAREST,fn.Filter.NEAREST),u.setMipFilter(fn.Filter.NONE),u.setWrapMode(fn.WrapMode.CLAMP_TO_EDGE,fn.WrapMode.CLAMP_TO_EDGE,fn.WrapMode.CLAMP_TO_EDGE),u.image=h,u.getGFXTexture()||bn("Unexpected: failed to create morph texture?");var c=t.getSampler(u.getSamplerInfo());return{get texture(){return u.getGFXTexture()},get sampler(){return c},get valueView(){return i},destroy:function(){u.destroy()},updatePixels:function(){u.uploadData(a)}}}}}function th(t,e,i){t.renderingSubMeshes[e].enableVertexIdChannel(i)}function eh(t){switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}}var ih=new n,rh=new n,nh=new Uint8Array,sh=t("Mesh",En("cc.Mesh")((jl=function(t){function e(){var e;return(e=t.call(this)||this).morphRendering=null,Mn(e,"_struct",Hl,Pn(e)),Mn(e,"_hash",Xl,Pn(e)),e._data=nh,e._initialized=!1,Mn(e,"_allowDataAccess",Wl,Pn(e)),e._isMeshDataUploaded=!1,e._renderingSubMeshes=null,e._boneSpaceBounds=new Map,e._jointBufferIndices=null,e}on(e,t);var i=e.prototype;return i.onLoaded=function(){this.initialize()},i.initialize=function(){var t=this;if(!this._initialized)if(this._initialized=!0,this._struct.dynamic){for(var e=Ci.gfxDevice,i=[],r=[],n=0;n<this._struct.vertexBundles.length;n++){var s=this._struct.vertexBundles[n],a=e.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.DEVICE,s.view.length,s.view.stride));i.push(a)}for(var o=0;o<this._struct.primitives.length;o++){var l=this._struct.primitives[o],h=l.indexView,u=null;h&&(u=e.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,h.length,h.stride)));for(var c=[],_=0;_<l.vertexBundelIndices.length;_++){var f=l.vertexBundelIndices[_];c.push(i[f])}for(var d=[],p=0;p<l.vertexBundelIndices.length;p++)for(var m,g=l.vertexBundelIndices[p],y=this._struct.vertexBundles[g],v=hn(y.attributes);!(m=v()).done;){var b=m.value,S=new ye;S.copy(b),d.push(S)}var A=new Bn(c,d,l.primitiveMode,u);A.drawInfo=new re,A.mesh=this,A.subMeshIdx=o,r.push(A)}this._renderingSubMeshes=r}else!function(){for(var e=t._data.buffer,i=Ci.gfxDevice,r=t._createVertexBuffers(i,e),n=[],s=0;s<t._struct.primitives.length;s++){var a=t._struct.primitives[s];if(0!==a.vertexBundelIndices.length){var o=null,l=null;if(a.indexView){var h=a.indexView,u=h.stride,c=h.length;if(4===u&&!i.hasFeature($.ELEMENT_INDEX_UINT)){var _=t._struct.vertexBundles[a.vertexBundelIndices[0]].view.count;if(_>=65536){Rn(10001,_,65536);continue}u>>=1,c>>=1}o=i.createBuffer(new ee(rt.INDEX,at.DEVICE,c,u)),l=new(eh(h.stride))(e,h.offset,h.count),h.stride!==u&&(l=eh(u).from(l)),o.update(l)}var f=a.vertexBundelIndices.map((function(t){return r[t]})),d=[];if(a.vertexBundelIndices.length>0)for(var p=a.vertexBundelIndices[0],m=t._struct.vertexBundles[p].attributes,g=0;g<m.length;++g){var y=m[g];d[g]=new ye(y.name,y.format,y.isNormalized,y.stream,y.isInstanced,y.location)}var v=new Bn(f,d,a.primitiveMode,o);v.mesh=t,v.subMeshIdx=s,n.push(v)}}t._renderingSubMeshes=n,t._struct.morph&&(t.morphRendering=function(t,e){return new ql(t,e)}(t,i)),t._isMeshDataUploaded=!0,t._allowDataAccess||t.releaseData()}()},i.updateSubMesh=function(t,e){if(this._struct.dynamic)if(t>=this._struct.primitives.length)Rn(14201);else{var i=[];if(e.positions.length>0&&i.push(e.positions),e.normals&&e.normals.length>0&&i.push(e.normals),e.uvs&&e.uvs.length>0&&i.push(e.uvs),e.tangents&&e.tangents.length>0&&i.push(e.tangents),e.colors&&e.colors.length>0&&i.push(e.colors),e.customAttributes)for(var r=0;r<e.customAttributes.length;r++)i.push(e.customAttributes[r].values);for(var s=this._struct.dynamic,a=s.info,o=this._struct.primitives[t],l=this._renderingSubMeshes[t],h=l.drawInfo,u=0;u<i.length;u++){var c=i[u],_=this._struct.vertexBundles[o.vertexBundelIndices[u]],f=_.view.stride,d=c.byteLength/f,p=c.byteLength,m=new Uint8Array(this._data.buffer,_.view.offset,p),g=new Uint8Array(c.buffer,c.byteOffset,p),y=l.vertexBuffers[u];gn(d<=a.maxSubMeshVertices),p>0&&(m.set(g),y.update(g,p)),_.view.count=d,h.vertexCount=d}if(o.indexView){var v=o.indexView,b=v.stride,S=2===b?e.indices16.length:e.indices32.length,A=S*b,T=new Uint8Array(this._data.buffer,v.offset,A),C=2===b?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,A):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,A),x=l.indexBuffer;gn(S<=a.maxSubMeshIndices),A>0&&(T.set(C),x.update(C,A)),v.count=S,h.indexCount=S}if(e.minPos&&e.maxPos){var w=new n(e.minPos.x,e.minPos.y,e.minPos.z),E=new n(e.maxPos.x,e.maxPos.y,e.maxPos.z);s.bounds[t]||(s.bounds[t]=new Ii),Ii.fromPoints(s.bounds[t],w,E);for(var B,R=new n,D=new n,M=hn(s.bounds);!(B=M()).done;){var P=B.value;P&&(P.getBoundary(R,D),n.min(w,R,w),n.max(E,D,E))}this._struct.minPosition=new n(w.x,w.y,w.z),this._struct.maxPosition=new n(E.x,E.y,E.z)}l.invalidateGeometricInfo()}else Rn(14200)},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,this._isMeshDataUploaded=!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._hash=0},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,s=0;s<r.length;s++)e.push(new Ii(1/0,1/0,1/0,-1/0,-1/0,-1/0)),i.push(!1);for(var a=this._struct.primitives,o=0;o<a.length;o++){var l=this.readAttribute(o,He.ATTR_JOINTS),h=this.readAttribute(o,He.ATTR_WEIGHTS),u=this.readAttribute(o,He.ATTR_POSITION);if(l&&h&&u)for(var c=Math.min(l.length/4,h.length/4,u.length/3),_=0;_<c;_++){n.set(ih,u[3*_+0],u[3*_+1],u[3*_+2]);for(var f=0;f<4;++f){var d=4*_+f,p=l[d];if(!(0===h[d]||p>=r.length)){n.transformMat4(rh,ih,r[p]),i[p]=!0;var m=e[p];n.min(m.center,m.center,rh),n.max(m.halfExtents,m.halfExtents,rh)}}}}for(var g=0;g<r.length;g++){var y=e[g];i[g]?Ii.fromPoints(y,y.center,y.halfExtents):e[g]=null}return e},i.merge=function(t,e,i){if(i&&!this.validateMergingMesh(t))return!1;var r=new n,s=e&&new l,a=e&&new Ii;if(s&&e.getRotation(s),!this._initialized){var o=JSON.parse(JSON.stringify(t._struct)),h=t._data.slice();if(e){o.maxPosition&&o.minPosition&&(n.add(a.center,o.maxPosition,o.minPosition),n.multiplyScalar(a.center,a.center,.5),n.subtract(a.halfExtents,o.maxPosition,o.minPosition),n.multiplyScalar(a.halfExtents,a.halfExtents,.5),Ii.transform(a,a,e),n.add(o.maxPosition,a.center,a.halfExtents),n.subtract(o.minPosition,a.center,a.halfExtents));for(var u=0;u<o.vertexBundles.length;u++)for(var c=o.vertexBundles[u],_=0;_<c.attributes.length;_++)if(c.attributes[_].name===He.ATTR_POSITION||c.attributes[_].name===He.ATTR_NORMAL){var f=c.attributes[_].format,d=new DataView(h.buffer,c.view.offset+ah(c.attributes,_)),p=hh(d,f),m=uh(d,f);if(!p||!m)continue;for(var g=c.view.count,y=c.view.stride,v=lh(f),b=0;b<g;b++){var S=b*y,A=S+v,T=A+v;switch(r.set(p(S),p(A),p(T)),c.attributes[_].name){case He.ATTR_POSITION:r.transformMat4(e);break;case He.ATTR_NORMAL:n.transformQuat(r,r,s)}m(S,r.x),m(A,r.y),m(T,r.z)}}}return this.reset({struct:o,data:h}),this.initialize(),!0}for(var C,x,w,E,B,R=new Yl,D=0,M=0,P=0,I=0,O=0,F=0,L=0,k=0,V=!1,N=new Array(this._struct.vertexBundles.length),G=0;G<this._struct.vertexBundles.length;++G){var z=this._struct.vertexBundles[G],U=t._struct.vertexBundles[G];P=z.view.offset,I=U.view.offset,M=z.view.stride,D=z.view.count+U.view.count,C=new ArrayBuffer(D*M),x=new Uint8Array(C),P+=(w=this._data.subarray(P,P+z.view.length)).length,I+=(E=t._data.subarray(I,I+U.view.length)).length,x.set(w),O=0;for(var H,X=hn(z.attributes);!(H=X()).done;){var W=H.value;L=0,V=!1;for(var j,Y=hn(U.attributes);!(j=Y()).done;){var q=j.value;if(W.name===q.name&&W.format===q.format){V=!0;break}L+=Xe[q.format].size}if(V){k=Xe[W.format].size,F=z.view.length+O;for(var K=0;K<U.view.count;++K){if(B=E.subarray(L,L+k),x.set(B,F),(W.name===He.ATTR_POSITION||W.name===He.ATTR_NORMAL)&&e){var J=new Float32Array(x.buffer,F,3);switch(r.set(J[0],J[1],J[2]),W.name){case He.ATTR_POSITION:r.transformMat4(e);break;case He.ATTR_NORMAL:n.transformQuat(r,r,s)}J[0]=r.x,J[1]=r.y,J[2]=r.z}F+=z.view.stride,L+=U.view.stride}}O+=Xe[W.format].size}N[G]={attributes:z.attributes,view:{offset:R.getLength(),length:C.byteLength,count:D,stride:M}},R.addBuffer(C)}for(var Z,Q,$,tt=0,et=2,it=0,rt=new Array(this._struct.primitives.length),nt=0;nt<this._struct.primitives.length;++nt){var st=this._struct.primitives[nt],at=t._struct.primitives[nt];rt[nt]={primitiveMode:st.primitiveMode,vertexBundelIndices:st.vertexBundelIndices};for(var ot,lt=hn(st.vertexBundelIndices);!(ot=lt()).done;){var ht=ot.value;it=Math.max(it,this._struct.vertexBundles[ht].view.count)}if(st.indexView&&at.indexView){tt=st.indexView.count,tt+=at.indexView.count,P=st.indexView.offset,I=at.indexView.offset,et=tt<256?1:tt<65536?2:4;var ut=new ArrayBuffer(tt*et);if(Z=2===et?new Uint16Array(ut):1===et?new Uint8Array(ut):new Uint32Array(ut),Q=2===st.indexView.stride?new Uint16Array(this._data.buffer,P,st.indexView.count):1===st.indexView.stride?new Uint8Array(this._data.buffer,P,st.indexView.count):new Uint32Array(this._data.buffer,P,st.indexView.count),et===st.indexView.stride)Z.set(Q);else for(var ct=0;ct<st.indexView.count;++ct)Z[ct]=Q[ct];P+=st.indexView.length,$=2===at.indexView.stride?new Uint16Array(t._data.buffer,I,at.indexView.count):1===at.indexView.stride?new Uint8Array(t._data.buffer,I,at.indexView.count):new Uint32Array(t._data.buffer,I,at.indexView.count);for(var _t=0;_t<at.indexView.count;++_t)Z[st.indexView.count+_t]=it+$[_t];I+=at.indexView.length,rt[nt].indexView={offset:R.getLength(),length:ut.byteLength,count:tt,stride:et},R.setNextAlignment(et),R.addBuffer(ut)}}var ft={vertexBundles:N,primitives:rt,minPosition:this._struct.minPosition,maxPosition:this._struct.maxPosition};return ft.minPosition&&t._struct.minPosition&&ft.maxPosition&&t._struct.maxPosition&&(e?(n.add(a.center,t._struct.maxPosition,t._struct.minPosition),n.multiplyScalar(a.center,a.center,.5),n.subtract(a.halfExtents,t._struct.maxPosition,t._struct.minPosition),n.multiplyScalar(a.halfExtents,a.halfExtents,.5),Ii.transform(a,a,e),n.add(r,a.center,a.halfExtents),n.max(ft.maxPosition,ft.maxPosition,r),n.subtract(r,a.center,a.halfExtents),n.min(ft.minPosition,ft.minPosition,r)):(n.min(ft.minPosition,ft.minPosition,t._struct.minPosition),n.max(ft.maxPosition,ft.maxPosition,t._struct.maxPosition))),this.reset({struct:ft,data:new Uint8Array(R.getCombined())}),this.initialize(),!0},i.validateMergingMesh=function(t){if(this._struct.dynamic||t._struct.dynamic)return!1;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=$e(Xe[s]);if(0!==n){var o=new DataView(i._data.buffer,t.view.offset+ah(t.attributes,e)),l=Xe[s],h=hh(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 d=0;d<u;++d)c[u*f+d]=h(_*f+c.BYTES_PER_ELEMENT*d);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+ah(t.attributes,e)),u=new DataView(i,n),c=Xe[l],_=hh(h,l),f=uh(u,l);if(_&&f){for(var d=c.count,p=t.view.stride,m=lh(l),g=r,y=m,v=0;v<o;++v)for(var b=0;b<d;++b)f(g*v+y*b,_(p*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?tt.R8UI:2===i.indexView.stride?tt.R16UI:tt.R32UI,s=hh(new DataView(this._data.buffer),n),a=0;a<r;++a)e[a]=s(i.indexView.offset+Xe[n].size*a);return!0},i.readAttributeFormat=function(t,e){var i=null;return this._accessAttribute(t,e,(function(t,e){var r=t.attributes[e].format;i=Xe[r]})),i},i._accessAttribute=function(t,e,i){if(!(t>=this._struct.primitives.length))for(var r,n=this._struct.primitives[t],s=hn(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){return this._struct.vertexBundles.map((function(i){var r=t.createBuffer(new ee(rt.VERTEX,at.DEVICE,i.view.length,i.view.stride)),n=new Uint8Array(e,i.view.offset,i.view.length);return r.update(n),r}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.reset({struct:{vertexBundles:[],primitives:[]},data:nh})},i.releaseData=function(){this._data=nh},Ur(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data=new Uint8Array(t)}},{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=In(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}},{key:"allowDataAccess",get:function(){return this._allowDataAccess},set:function(t){this._allowDataAccess=t,this._isMeshDataUploaded&&!this._allowDataAccess&&this.releaseData()}}]),e}(Qr),Hl=Dn((Ul=jl).prototype,"_struct",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{vertexBundles:[],primitives:[]}}}),Xl=Dn(Ul.prototype,"_hash",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Wl=Dn(Ul.prototype,"_allowDataAccess",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),zl=Ul))||zl);function ah(t,e){for(var i=0,r=0;r<e;++r){var n=t[r];i+=Xe[n.format].size}return i}Er.Mesh=sh;var oh=Fn.isLittleEndian;function lh(t){var e=Xe[t];return e.size/e.count}function hh(t,e){var i=Xe[e],r=i.size/i.count;switch(i.type){case et.UNORM:switch(r){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,oh)};case 4:return function(e){return t.getUint32(e,oh)}}break;case et.SNORM:case et.INT:switch(r){case 1:return function(e){return t.getInt8(e)};case 2:return function(e){return t.getInt16(e,oh)};case 4:return function(e){return t.getInt32(e,oh)}}break;case et.UINT:switch(r){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,oh)};case 4:return function(e){return t.getUint32(e,oh)}}break;case et.FLOAT:return function(e){return t.getFloat32(e,oh)}}return null}function uh(t,e){var i=Xe[e],r=i.size/i.count;switch(i.type){case et.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,oh)};case 4:return function(e,i){return t.setUint32(e,i,oh)}}break;case et.SNORM:case et.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,oh)};case 4:return function(e,i){return t.setInt32(e,i,oh)}}break;case et.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,oh)};case 4:return function(e,i){return t.setUint32(e,i,oh)}}break;case et.FLOAT:return function(e,i){return t.setFloat32(e,i,oh)}}return null}var ch=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_NORMAL,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F),new ye(He.ATTR_TANGENT,tt.RGBA32F),new ye(He.ATTR_COLOR,tt.RGBA32F)],_h=new n;function fh(t,e,i){i=i||{};var r,s=[],a=0,o=[],l=0,h=t.positions.slice();if(h.length>0){if(r=null,t.attributes)for(var u,c=hn(t.attributes);!(u=c()).done;){var _=u.value;if(_.name===He.ATTR_POSITION){r=_;break}}r||(r=ch[0]),s.push(r);var f=Xe[r.format];l=Math.max(l,Math.floor(h.length/f.count)),o.push({offset:a,data:h,attribute:r}),a+=f.size}if(t.normals&&t.normals.length>0){if(r=null,t.attributes)for(var d,p=hn(t.attributes);!(d=p()).done;){var m=d.value;if(m.name===He.ATTR_NORMAL){r=m;break}}r||(r=ch[1]);var g=Xe[r.format];s.push(r),l=Math.max(l,Math.floor(t.normals.length/g.count)),o.push({offset:a,data:t.normals,attribute:r}),a+=g.size}if(t.uvs&&t.uvs.length>0){if(r=null,t.attributes)for(var y,v=hn(t.attributes);!(y=v()).done;){var b=y.value;if(b.name===He.ATTR_TEX_COORD){r=b;break}}r||(r=ch[2]);var S=Xe[r.format];s.push(r),l=Math.max(l,Math.floor(t.uvs.length/S.count)),o.push({offset:a,data:t.uvs,attribute:r}),a+=S.size}if(t.tangents&&t.tangents.length>0){if(r=null,t.attributes)for(var A,T=hn(t.attributes);!(A=T()).done;){var C=A.value;if(C.name===He.ATTR_TANGENT){r=C;break}}r||(r=ch[3]);var x=Xe[r.format];s.push(r),l=Math.max(l,Math.floor(t.tangents.length/x.count)),o.push({offset:a,data:t.tangents,attribute:r}),a+=x.size}if(t.colors&&t.colors.length>0){if(r=null,t.attributes)for(var w,E=hn(t.attributes);!(w=E()).done;){var B=w.value;if(B.name===He.ATTR_COLOR){r=B;break}}r||(r=ch[4]);var R=Xe[r.format];s.push(r),l=Math.max(l,Math.floor(t.colors.length/R.count)),o.push({offset:a,data:t.colors,attribute:r}),a+=R.size}if(t.customAttributes)for(var D=0;D<t.customAttributes.length;D++){var M=t.customAttributes[D],P=Xe[M.attr.format];s.push(M.attr),l=Math.max(l,Math.floor(M.values.length/P.count)),o.push({offset:a,data:M.values,attribute:M.attr}),a+=P.size}for(var I=new Yl,O=new ArrayBuffer(l*a),F=new DataView(O),L=0,k=o;L<k.length;L++){var V=k[L];Ln(F,V.data,V.attribute.format,V.offset,a)}I.setNextAlignment(0);var N={attributes:s,view:{offset:I.getLength(),length:O.byteLength,count:l,stride:a}};I.addBuffer(O);var G=null,z=0;if(t.indices){var U=t.indices;z=U.length,G=new ArrayBuffer(2*z);var H=new DataView(G);Ln(H,U,tt.R16UI)}var X={primitiveMode:t.primitiveMode||wt.TRIANGLE_LIST,vertexBundelIndices:[0]};G&&(I.setNextAlignment(2),X.indexView={offset:I.getLength(),length:G.byteLength,count:z,stride:2},I.addBuffer(G));var W=t.minPos;if(!W&&i.calculateBounds){W=n.set(new n,1/0,1/0,1/0);for(var j=0;j<l;++j)n.set(_h,h[3*j+0],h[3*j+1],h[3*j+2]),n.min(W,W,_h)}var Y=t.maxPos;if(!Y&&i.calculateBounds){Y=n.set(new n,-1/0,-1/0,-1/0);for(var q=0;q<l;++q)n.set(_h,h[3*q+0],h[3*q+1],h[3*q+2]),n.max(Y,Y,_h)}var K={vertexBundles:[N],primitives:[X]};return W&&(K.minPosition=new n(W.x,W.y,W.z)),Y&&(K.maxPosition=new n(Y.x,Y.y,Y.z)),e||(e=new sh),e.reset({struct:K,data:new Uint8Array(I.getCombined())}),e}function dh(t,e){if(e>0){var i=t%e;if(0!==i)return e-i}return 0}var ph,mh,gh,yh=function(){function t(){}return t.createMesh=function(t,e,i){return fh(t,e,i)},t.createDynamicMesh=function(t,e,i,r){return function(t,e,i,r){r=r||{maxSubMeshes:1,maxSubMeshVertices:1024,maxSubMeshIndices:1024};var n=[],s=0;if(e.positions.length>0&&n.push(new ye(He.ATTR_POSITION,tt.RGB32F,!1,s++,!1,0)),e.normals&&e.normals.length>0&&n.push(new ye(He.ATTR_NORMAL,tt.RGB32F,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&n.push(new ye(He.ATTR_TEX_COORD,tt.RG32F,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&n.push(new ye(He.ATTR_TANGENT,tt.RGBA32F,!1,s++,!1,0)),e.colors&&e.colors.length>0&&n.push(new ye(He.ATTR_COLOR,tt.RGBA32F,!1,s++,!1,0)),e.customAttributes)for(var a=0;a<e.customAttributes.length;a++){var o=e.customAttributes[a],l=new ye;l.copy(o.attr),l.stream=s++,n.push(l)}for(var h=[],u=[],c=0,_=0;_<r.maxSubMeshes;_++){for(var f,d={vertexBundelIndices:[],primitiveMode:e.primitiveMode||wt.TRIANGLE_LIST},p=hn(n);!(f=p()).done;){var m=f.value,g=Xe[m.format],y=r.maxSubMeshVertices*g.size,v={view:{offset:c,length:y,count:0,stride:g.size},attributes:[m]},b=h.length;d.vertexBundelIndices.push(b),h.push(v),c+=y}var S=0;if(e.indices16&&e.indices16.length>0?S=2:e.indices32&&e.indices32.length>0&&(S=4),S>0){c+=dh(c,S);var A=r.maxSubMeshIndices*S,T={offset:c,length:A,count:0,stride:S};d.indexView=T,c+=A}u.push(d)}var C={info:{maxSubMeshes:r.maxSubMeshes,maxSubMeshVertices:r.maxSubMeshVertices,maxSubMeshIndices:r.maxSubMeshIndices},bounds:[]};C.bounds.length=r.maxSubMeshes;var x={struct:{vertexBundles:h,primitives:u,dynamic:C},data:new Uint8Array(c)};return i||(i=new sh),i.reset(x),i.initialize(),i.updateSubMesh(t,e),i}(t,e,i,r)},t}(),vh=Object.freeze({__proto__:null,find:kn,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=hn(a.vertexBundelIndices);!(i=o()).done;)for(var l,h=i.value,u=s.vertexBundles[h],c=u.view.offset,_=u.view,f=_.length,d=_.stride,p=hn(u.attributes);!(l=p()).done;){var m=l.value,g=Nl[m.name];g&&(r[g]=(r[g]||[]).concat(mn(n,m.format,c,f,d))),c+=Xe[m.format].size}var y=a.indexView;return r.indices=mn(n,tt["R"+8*y.stride+"UI"],y.offset,y.length),r},createMesh:fh,MeshUtils:yh,readBuffer:mn,writeBuffer:Ln,mapBuffer:Vn});t("utils",vh);var bh,Sh=new n,Ah=new c;!function(t){t[t.RECT=0]="RECT",t[t.POLYGON=1]="POLYGON"}(bh||(bh={}));var Th,Ch,xh,wh,Eh=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],Bh=t("SpriteFrame",En("cc.SpriteFrame")((gh=mh=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.unbiasUV=[],e.uvSliced=[],e._rect=new m,e._trimmedBorder=new a,e._offset=new i,e._originalSize=new d,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._pixelsToUnit=100,e._pivot=new i(.5,.5),e._meshType=bh.RECT,e._extrude=0,e._customOutLine=[],e._minPos=new n,e._maxPos=new n,e}on(e,t),e.createWithImage=function(t){var i=t instanceof vn?t:new vn(t),r=new fn;r.image=i;var n=new e;return n.texture=r,n};var r=e.prototype;return r.textureLoaded=function(){return!!this.texture},r.isRotated=function(){return this._rotated},r.setRotated=function(t){this.rotated=t},r.getRect=function(t){return t?(t.set(this._rect),t):this._rect.clone()},r.setRect=function(t){this.rect=t},r.getOriginalSize=function(t){return t?(t.set(this._originalSize),t):this._originalSize.clone()},r.setOriginalSize=function(t){this.originalSize=t},r.getOffset=function(t){return t?(t.set(this._offset),t):this._offset.clone()},r.setOffset=function(t){this.offset=t},r.getGFXTexture=function(){return this._texture.getGFXTexture()},r.getGFXSampler=function(){return this._texture.getGFXSampler()},r.getHash=function(){return this._texture.getHash()},r.getSamplerInfo=function(){return this._texture.getSamplerInfo()},r.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._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(),this._calcTrimmedBorder()},r.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?(Nn(3300,this.name+"/"+t.name,i,t.width),!1):!(r>t.height&&(Nn(3301,this.name+"/"+t.name,r,t.height),1))},r._calcTrimmedBorder=function(){var t=this._originalSize.width,e=this._originalSize.height,i=.5*(t-this._rect.width),r=.5*(e-this._rect.height);this._trimmedBorder.x=this._offset.x+i,this._trimmedBorder.y=this._offset.x-i,this._trimmedBorder.z=this._offset.y+r,this._trimmedBorder.w=this._offset.y-r},r.ensureMeshData=function(){this._mesh||(this._initVertices(),this._createMesh())},r.destroy=function(){return this._packable&&Gl&&Gl.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},r._calculateSlicedUV=function(){var t=this._rect,i=this.texture,r=i.width,n=i.height,s=this._capInsets[0],a=this._capInsets[2],o=t.width-s-a,l=this._capInsets[1],h=this._capInsets[3],u=t.height-l-h,c=this.uvSliced;if(c.length=0,this._rotated){Eh[0].u=t.x/r,Eh[1].u=(t.x+h)/r,Eh[2].u=(t.x+h+u)/r,Eh[3].u=(t.x+t.height)/r,Eh[3].v=t.y/n,Eh[2].v=(t.y+s)/n,Eh[1].v=(t.y+s+o)/n,Eh[0].v=(t.y+t.width)/n;for(var _=0;_<4;++_)for(var f=Eh[_],d=0;d<4;++d){var p=Eh[3-d];c.push({u:f.u,v:p.v})}}else{Eh[0].u=t.x/r,Eh[1].u=(t.x+s)/r,Eh[2].u=(t.x+s+o)/r,Eh[3].u=(t.x+t.width)/r,Eh[3].v=t.y/n,Eh[2].v=(t.y+l)/n,Eh[1].v=(t.y+l+u)/n,Eh[0].v=(t.y+t.height)/n;for(var m=0;m<4;++m)for(var g=Eh[m],y=0;y<4;++y){var v=Eh[y];c.push({u:v.u,v:g.v})}}this.emit(e.EVENT_UV_UPDATED,this)},r._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 d=0===n?0:t.x/n,p=0===n?1:(t.x+t.width)/n,m=0===s?1:(t.y+t.height)/s,g=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=p,e[1]=g,e[2]=d,e[3]=g,e[4]=p,e[5]=m,e[6]=d,e[7]=m):this._isFlipUVX?(e[0]=p,e[1]=m,e[2]=d,e[3]=m,e[4]=p,e[5]=g,e[6]=d,e[7]=g):this._isFlipUVY?(e[0]=d,e[1]=g,e[2]=p,e[3]=g,e[4]=d,e[5]=m,e[6]=p,e[7]=m):(e[0]=d,e[1]=m,e[2]=p,e[3]=m,e[4]=d,e[5]=g,e[6]=p,e[7]=g);var y=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]=y,i[3]=S,i[4]=v,i[5]=b,i[6]=y,i[7]=b):this._isFlipUVX?(i[0]=v,i[1]=b,i[2]=y,i[3]=b,i[4]=v,i[5]=S,i[6]=y,i[7]=S):this._isFlipUVY?(i[0]=y,i[1]=S,i[2]=v,i[3]=S,i[4]=y,i[5]=b,i[6]=v,i[7]=b):(i[0]=y,i[1]=b,i[2]=v,i[3]=b,i[4]=y,i[5]=S,i[6]=v,i[7]=S)}this._calculateSlicedUV()},r._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())},r._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())},r._checkPackable=function(){var t=Gl;if(t){var e=this._texture;if(e instanceof fn&&!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}},r._serialize=function(){return null},r._deserialize=function(t){var e=t,r=e.rect;r&&(this._rect=new m(r.x,r.y,r.width,r.height));var s=e.offset;e.offset&&(this._offset=new i(s.x,s.y));var a=e.originalSize;e.originalSize&&(this._originalSize=new d(a.width,a.height)),this._rotated=!!e.rotated,this._name=e.name,this._packable=!!e.packable,this._pixelsToUnit=e.pixelsToUnit;var o=e.pivot;o&&(this._pivot=new i(o.x,o.y)),this._meshType=e.meshType;var l=e.capInsets;l&&(this._capInsets[0]=l[0],this._capInsets[1]=l[1],this._capInsets[2]=l[2],this._capInsets[3]=l[3]);var h=e.vertices;if(h){this.vertices||(this.vertices={rawPosition:[],positions:[],indexes:h.indexes,uv:h.uv,nuv:h.nuv,minPos:new n(h.minPos.x,h.minPos.y,h.minPos.z),maxPos:new n(h.maxPos.x,h.maxPos.y,h.maxPos.z)}),this.vertices.rawPosition.length=0;for(var u=h.rawPosition,c=0;c<u.length;c+=3)this.vertices.rawPosition.push(new n(u[c],u[c+1],u[c+2]));this._updateMeshVertices()}},r.clone=function(){var t,i,r,n,s=new e,a=this.vertices;return s.vertices=a?{rawPosition:a.rawPosition.slice(0),positions:a.positions.slice(0),indexes:a.indexes.slice(0),uv:a.uv.slice(0),nuv:a.nuv.slice(0),minPos:a.minPos.clone(),maxPos:a.minPos.clone()}:null,(t=s.uv).splice.apply(t,[0,s.uv.length].concat(this.uv)),(i=s.unbiasUV).splice.apply(i,[0,s.unbiasUV.length].concat(this.unbiasUV)),(r=s.uvSliced).splice.apply(r,[0,s.uvSliced.length].concat(this.uvSliced)),s._rect.set(this._rect),s._offset.set(this._offset),s._originalSize.set(this._originalSize),s._rotated=this._rotated,(n=s._capInsets).splice.apply(n,[0,s._capInsets.length].concat(this._capInsets)),s._atlasUuid=this._atlasUuid,s._texture=this._texture,s._isFlipUVX=this._isFlipUVX,s._isFlipUVY=this._isFlipUVY,s._pixelsToUnit=this._pixelsToUnit,s._pivot.set(this._pivot),s._meshType=this._meshType,s},r._refreshTexture=function(t){this._texture=t;var e=this._texture,i={},r=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(e)||(i.rect=new m(0,0,e.width,e.height),r=!0),(0===this._originalSize.width||0===this._originalSize.height||r)&&(i.originalSize=new d(e.width,e.height),r=!0),r&&this.reset(i),this._checkPackable(),this._mesh&&this._updateMesh()},r.onLoaded=function(){this._calcTrimmedBorder()},r.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new fn;i.initDefault(),this._refreshTexture(i),this._calculateUV()},r.validate=function(){return this._texture&&this._rect&&0!==this._rect.width&&0!==this._rect.height},r._initVertices=function(){if(this.vertices?(this.vertices.rawPosition.length=0,this.vertices.positions.length=0,this.vertices.indexes.length=0,this.vertices.uv.length=0,this.vertices.nuv.length=0,this.vertices.minPos.set(0,0,0),this.vertices.maxPos.set(0,0,0)):this.vertices={rawPosition:[],positions:[],indexes:[],uv:[],nuv:[],minPos:new n,maxPos:new n},this._meshType===bh.POLYGON);else{var t=this.texture,e=t.width,i=t.height,r=this.rect,s=r.width,a=r.height,o=r.x,l=i-r.y-a,h=s/2,u=a/2,c=0===e?0:o/e,_=0===e?1:(o+s)/e,f=0===i?1:(l+a)/i,d=0===i?0:r.y/i;Sh.set(-h,-u,0),this.vertices.rawPosition.push(Sh.clone()),this.vertices.uv.push(o),this.vertices.uv.push(l+a),this.vertices.nuv.push(c),this.vertices.nuv.push(d),this.vertices.minPos.set(Sh),Sh.set(h,-u,0),this.vertices.rawPosition.push(Sh.clone()),this.vertices.uv.push(o+s),this.vertices.uv.push(l+a),this.vertices.nuv.push(_),this.vertices.nuv.push(d),Sh.set(-h,u,0),this.vertices.rawPosition.push(Sh.clone()),this.vertices.uv.push(o),this.vertices.uv.push(l),this.vertices.nuv.push(c),this.vertices.nuv.push(f),Sh.set(h,u,0),this.vertices.rawPosition.push(Sh.clone()),this.vertices.uv.push(o+s),this.vertices.uv.push(l),this.vertices.nuv.push(_),this.vertices.nuv.push(f),this.vertices.maxPos.set(Sh),this.vertices.indexes.push(0),this.vertices.indexes.push(1),this.vertices.indexes.push(2),this.vertices.indexes.push(2),this.vertices.indexes.push(1),this.vertices.indexes.push(3)}this._updateMeshVertices()},r._updateMeshVertices=function(){Ah.identity();var t=1/this._pixelsToUnit,e=new n(t,t,1);Ah.scale(e);var i=-(this._pivot.x-.5)*this.rect.width*t,r=-(this._pivot.y-.5)*this.rect.height*t;e.set(i,r,0),Ah.translate(e);for(var s=this.vertices,a=0;a<s.rawPosition.length;a++){var o=s.rawPosition[a];n.transformMat4(e,o,Ah),n.toArray(s.positions,e,3*a)}n.transformMat4(this._minPos,s.minPos,Ah),n.transformMat4(this._maxPos,s.maxPos,Ah)},r._createMesh=function(){this._mesh=fh({primitiveMode:wt.TRIANGLE_LIST,positions:this.vertices.positions,uvs:this.vertices.nuv,indices:this.vertices.indexes,minPos:this._minPos,maxPos:this._maxPos,attributes:[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F)]})},r._updateMesh=function(){this._mesh&&this._mesh.destroy(),this._initVertices(),this._createMesh()},Ur(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(),this._calcTrimmedBorder())}},{key:"originalSize",get:function(){return this._originalSize},set:function(t){this._originalSize.equals(t)||(this._originalSize.set(t),this._texture&&this._calculateUV(),this._calcTrimmedBorder())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this._calcTrimmedBorder()}},{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?t!==this._texture&&this.reset({texture:t},!0):Rn(3122,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}},{key:"pixelsToUnit",get:function(){return this._pixelsToUnit}},{key:"pivot",get:function(){return this._pivot}},{key:"mesh",get:function(){return this._mesh}},{key:"trimmedBorder",get:function(){return this._trimmedBorder}}]),e}(Qr),mh.EVENT_UV_UPDATED="uv_updated",mh.MeshType=bh,ph=gh))||ph);Er.SpriteFrame=Bh;var Rh,Dh=t("SpriteAtlas",En("cc.SpriteAtlas")((wh=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,Mn(e,"spriteFrames",xh,Pn(e)),e}on(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=Gn();for(var n=0;n<r.length;n+=2)e.result.push(this.spriteFrames,r[n],r[n+1],zn(Bh))},e}(Qr),xh=Dn((Ch=wh).prototype,"spriteFrames",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Gn()}}),Th=Ch))||Th);Er.SpriteAtlas=Dh;var Mh,Ph,Ih,Oh,Fh=t("Font",En("cc.Font")(Rh=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e}(Qr))||Rh);Er.Font=Fh;var Lh,kh,Vh,Nh,Gh,zh,Uh,Hh,Xh,Wh=t("TTFFont",En("cc.TTFFont")((Oh=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,Mn(e,"_fontFamily",Ih,Pn(e)),e}return on(e,t),e.prototype.initDefault=function(e){this._fontFamily="Arial",t.prototype.initDefault.call(this,e)},Ur(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:Lr(this._native),__isNative__:!0}}}]),e}(Fh),Ih=Dn((Ph=Oh).prototype,"_fontFamily",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(Ph.prototype,"_nativeAsset",[Hn,Xn],Object.getOwnPropertyDescriptor(Ph.prototype,"_nativeAsset"),Ph.prototype),Dn(Ph.prototype,"_nativeDep",[Hn],Object.getOwnPropertyDescriptor(Ph.prototype,"_nativeDep"),Ph.prototype),Mh=Ph))||Mh);Er.TTFFont=Wh;var jh,Yh=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},qh=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 Yh;jn(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}(),Kh=t("BitmapFont",(Lh=En("cc.BitmapFont"),kh=Wn(Bh),Lh((Xh=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,Mn(e,"fntDataStr",Gh,Pn(e)),Mn(e,"spriteFrame",zh,Pn(e)),Mn(e,"fontSize",Uh,Pn(e)),Mn(e,"fntConfig",Hh,Pn(e)),e}return on(e,t),e.prototype.onLoaded=function(){var t=this.spriteFrame;!this.fontDefDictionary&&t&&(this.fontDefDictionary=new qh(t.texture));var e=this.fntConfig;if(e){var i=e.fontDefDictionary;for(var r in i){var n=new Yh,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 bn("The fnt config is not exists!")},e}(Fh),Gh=Dn((Nh=Xh).prototype,"fntDataStr",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),zh=Dn(Nh.prototype,"spriteFrame",[kh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Uh=Dn(Nh.prototype,"fontSize",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Hh=Dn(Nh.prototype,"fntConfig",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vh=Nh))||Vh));Er.BitmapFont=Kh;var Jh=t("LabelAtlas",En("cc.LabelAtlas")(jh=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e}(Kh))||jh);Er.LabelAtlas=Jh;var Zh=t("BASELINE_RATIO",.26),Qh=t("MIDDLE_RATIO",(Zh+1)/2-Zh);var $h=new Yn(2);$h.get=function(){return this._get()||{key:"",value:0,prev:null,next:null}};var tu,eu=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=$h.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,$h.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),iu=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,ru=/^[!,.:;'}\]%\?>、‘“》?。,!]/,nu=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/,su=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/,au=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;function ou(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 lu(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 hu(t,e,i){var r=(i||t.font)+"🎮"+e,n=eu.get(r);if(null!==n)return n;var s=t.measureText(e),a=s&&s.width||0;return eu.put(r,a),a}function uu(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 cu(t){return au.exec(t)}function _u(t){return su.exec(t)}function fu(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=uu(s,a),l=e-r(o),h=o,u=0,c=0;l>i&&c++<100;)a*=i/l,l=e-r(o=uu(s,a|=0));for(c=0;o&&l<=i&&c++<100;){var _=iu.exec(o);h=o,l=e-r(o=uu(s,a+=u=_?_[0].length:1))}0==(a-=u)?(a=1,h=uu(s,1)):1===a&&s[0]>="\ud800"&&s[0]<="\udbff"&&(a=2,h=uu(s,2));var f=uu(s,0,a),d=void 0;ru.test(h||o)&&(0==(a-=(d=nu.exec(f))?d[0].length:0)&&(a=1),h=uu(s,a),f=uu(s,0,a)),au.test(h)&&(d=su.exec(f))&&f!==d[0]&&(h=uu(s,a-=d[0].length),f=uu(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 du,pu=t("CanvasPool",function(){function t(){this.pool=[]}t.getInstance=function(){return tu||(tu=new t),tu};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>=qr.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}()),mu=y.WHITE.clone(),gu=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},yu="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",vu=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,pu.getInstance().put(this.data)},e._updateProperties=function(){if(this.data=pu.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var t=hu(this.context,this.char,this.labelInfo.fontDesc),e=2*this.labelInfo.margin+2;this.width=parseFloat(t.toFixed(2))+e,this.height=(1+Zh)*this.labelInfo.fontSize+e,this.offsetY=-this.labelInfo.fontSize*Zh/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 vn),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=yu,t.fillRect(0,0,i,r),t.font=e.fontDesc;var n=e.fontSize,s=i/2,a=r/2+n*Qh+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||mu;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}(),bu=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=_n.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var r=this.getGFXTexture();if(t&&r){var n=this._getGFXDevice();if(n){var s=new Kt;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}(fn),Su=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 bu;i.initWithSize(t,e),this.fontDefDictionary=new qh(i),this._halfBleed=1,this._width=t,this._height=e,Kr.on(Or.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=Kr.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 Rn(12100),null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new gu;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 bu;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 vu(t,e);n.updateRenderData(),r=this.insertLetterTexture(n),n.destroy()}return r},Ur(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(),Au={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:y.WHITE.clone(),isOutlined:!1,out:y.WHITE.clone(),margin:0},Tu=[new ye(He.ATTR_POSITION,tt.RGB32F)],Cu=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA32F)],xu=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F),new ye(He.ATTR_COLOR,tt.RGBA32F)],wu=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F),new ye(He.ATTR_COLOR,tt.RGBA32F),new ye(He.ATTR_COLOR2,tt.RGBA32F)];function Eu(t){for(var e=0,i=0;i<t.length;i++){var r=t[i];e+=Xe[r.format].count}return e}function Bu(t){for(var e=0,i=0;i<t.length;i++){var r=t[i];e+=Xe[r.format].size}return e}Er.internal.vfmtPosUvColor=xu,Er.internal.vfmtPosUvTwoColor=wu,t("UIVertexFormat",Object.freeze({__proto__:null,vfmt:Tu,vfmtPosColor:Cu,vfmtPosUvColor:xu,vfmtPosUvTwoColor:wu,getComponentPerVertex:Eu,getAttributeStride:Bu})),function(t){t[t.byteOffset=0]="byteOffset",t[t.vertexOffset=1]="vertexOffset",t[t.indexOffset=2]="indexOffset",t[t.dirty=3]="dirty",t[t.floatsPerVertex=4]="floatsPerVertex",t[t.count=5]="count"}(du||(du={}));var Ru,Du,Mu,Pu,Iu=t("MeshBuffer",function(){var t=e.prototype;function e(){this._byteOffset=0,this._vertexOffset=0,this._indexOffset=0,this._dirty=!1,this._floatsPerVertex=0,this._vData=null,this._iData=null,this._useLinkedData=!1,this._vertexFormatBytes=0,this._initVDataCount=0,this._initIDataCount=0,this._attributes=null,this._iaPool=[],this._iaInfo=null,this._nextFreeIAHandle=0,this.initSharedBuffer(),this.syncSharedBufferToNative()}return t.initSharedBuffer=function(){},t.syncSharedBufferToNative=function(){},t.initialize=function(t,e,i,r){this._initVDataCount=i,this._initIDataCount=r,this._attributes=e,this.floatsPerVertex=Eu(e),gn(this._initVDataCount/this._floatsPerVertex<65536,Yr(9005)),this.vData&&this.iData||(this.vData=new Float32Array(this._initVDataCount),this.iData=new Uint16Array(this._initIDataCount)),this._iaPool.push(this.createNewIA(t))},t.reset=function(){this._nextFreeIAHandle=0,this.dirty=!1},t.destroy=function(){this.reset(),this._attributes=null,this._iaInfo=null,this.vData=null,this.iData=null;for(var t=0;t<this._iaPool.length;++t){var e=this._iaPool[t];e.vertexBuffers[0]&&e.vertexBuffers[0].destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.ia.destroy()}this._iaPool.length=0},t.setDirty=function(){this.dirty=!0},t.request=function(){return Rn(9002),!1},t.requireFreeIA=function(t){return this._iaPool.length<=this._nextFreeIAHandle&&this._iaPool.push(this.createNewIA(t)),this._iaPool[this._nextFreeIAHandle++].ia},t.recycleIA=function(t){for(var e=this._iaPool,i=0;i<this._nextFreeIAHandle;++i)if(t===e[i].ia){var r=e[i];return e[i]=e[--this._nextFreeIAHandle],void(e[this._nextFreeIAHandle]=r)}},t.checkCapacity=function(t,e){var i=(this.vertexOffset+t)*this._floatsPerVertex,r=this.indexOffset+e;return!(i>this._initVDataCount||r>this._initIDataCount)},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){for(var t=Fn.__isWebIOS14OrIPadOS14Env?this._nextFreeIAHandle:1,e=this.byteOffset,i=this.indexOffset,r=0;r<t;++r){var n=this._iaPool[r],s=new Float32Array(this.vData.buffer,0,e>>2),a=new Uint16Array(this.iData.buffer,0,i),o=n.vertexBuffers[0];e>o.size&&o.resize(e),o.update(s),2*i>n.indexBuffer.size&&n.indexBuffer.resize(2*i),n.indexBuffer.update(a)}this.dirty=!1}},t.createNewIA=function(t){var e,i,r;if(Fn.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var n=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,a=t.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,n,n));r=t.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,s,s)),i=[a],this._iaInfo=new be(this._attributes,i,r),e=t.createInputAssembler(this._iaInfo)}else e=t.createInputAssembler(this._iaInfo),i=this._iaInfo.vertexBuffers,r=this._iaInfo.indexBuffer;return{ia:e,vertexBuffers:i,indexBuffer:r}},Ur(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"byteOffset",get:function(){return this._byteOffset},set:function(t){this._byteOffset=t}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(t){this._vertexOffset=t}},{key:"indexOffset",get:function(){return this._indexOffset},set:function(t){this._indexOffset=t}},{key:"dirty",get:function(){return this._dirty},set:function(t){this._dirty=t}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex},set:function(t){this._floatsPerVertex=t}},{key:"vData",get:function(){return this._vData},set:function(t){this._vData=t}},{key:"iData",get:function(){return this._iData},set:function(t){this._iData=t}},{key:"useLinkedData",get:function(){return this._useLinkedData},set:function(t){this._useLinkedData=t}},{key:"nativeObj",get:function(){return this._nativeObj}},{key:"sharedBuffer",get:function(){return this._sharedBuffer}}]),e}()),Ou=function(){function t(t,e){this._device=null,this._attributes=null,this._vertexFormatBytes=void 0,this._floatsPerVertex=void 0,this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=Eu(e),this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT}var e=t.prototype;return e.initialize=function(){},e.reset=function(){},e.request=function(){},e.appendBuffers=function(){},e.uploadBuffers=function(){},e.destroy=function(){this._attributes.length=0},Ur(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex}}]),t}(),Fu=new H((function(){return{offset:0,length:0}}),32),Lu=function(){function t(t,e,i,r,n,s){this._ib=void 0,this.vertexAccessor=t,this.bufferId=e,this.meshBuffer=i,this.vertexOffset=r,this.vb=n,this.indexCount=s,this._ib=new Uint16Array(s),gn(i===t.getMeshBuffer(e))}return t.prototype.setIndexBuffer=function(){},Ur(t,[{key:"ib",get:function(){return this._ib}}]),t}(),ku=function(t){function e(i,r,n,s){var a;return(a=t.call(this,i,r)||this)._freeLists=[],a._vCount=0,a._iCount=0,a._id=0,a._vCount=n||Math.floor(1024*qr.BATCHER2D_MEM_INCREMENT/a._vertexFormatBytes),a._iCount=s||a._vCount*e.IB_SCALE,a._id=e.generateID(),a._allocateBuffer(),a}on(e,t);var i=e.prototype;return i.destroy=function(){for(var e=0;e<this._buffers.length;++e){this._buffers[e].destroy();for(var i=this._freeLists[e],r=0;r<i.length;++r)Fu.free(i[r])}this._buffers.length=0,this._freeLists.length=0,t.prototype.destroy.call(this)},i.reset=function(){for(var t=0;t<this._buffers.length;++t){var e=this._buffers[t];e.indexOffset=0,e.reset()}},i.getVertexBuffer=function(t){return this._buffers[t].vData},i.getIndexBuffer=function(t){return this._buffers[t].iData},i.getMeshBuffer=function(t){return this._buffers[t]},i.uploadBuffers=function(){for(var t=0;t<this._buffers.length;++t){var e=this._freeLists[t][0],i=this._buffers[t];(!e||e.length<i.vData.byteLength)&&i.uploadBuffers()}},i.appendIndices=function(t,e){var i=this._buffers[t];e.length&&(i.iData.set(e,i.indexOffset),i.indexOffset+=e.length)},i.allocateChunk=function(t,e){for(var i,r=t*this.vertexFormatBytes,n=null,s=0,a=-1,o=null,l=0;l<this._buffers.length;++l){n=this._buffers[l],i=this._freeLists[l];for(var h=0;h<i.length;++h)if(i[h].length>=r){o=i[h],s=l,a=h;break}if(o)break}if(o||(s=this._allocateBuffer(),(n=this._buffers[s])&&n.checkCapacity(t,e)&&(a=0,o=this._freeLists[s][a])),o){var u=o.offset/this.vertexFormatBytes,c=new Float32Array(n.vData.buffer,o.offset,r>>2).fill(0);return this._allocateChunkFromEntry(s,a,o,r),new Lu(this,s,n,u,c,e)}return Nn(9004,r),null},i.recycleChunk=function(t){var e=this._freeLists[t.bufferId],i=this._buffers[t.bufferId],r=t.vertexOffset*this.vertexFormatBytes,n=t.vb.byteLength;if(0!==n){for(var s=!1,a=0,o=null,l=e[a];l&&l.offset<r;)o=l,l=e[++a];if(o&&0==r-(o.offset+o.length)&&(o.length+=n,r=o.offset,n=o.length,l&&l.offset-(r+n)==0&&(o.length+=l.length,e.splice(a,1),Fu.free(l),l=null),s=!0),!s&&l){if(0==l.offset-(r+n))l.offset=r,l.length+=n;else{var h=Fu.alloc();h.offset=r,h.length=n,e.splice(a,0,h)}s=!0}if(s)r+n===i.byteOffset&&(i.byteOffset=r);else{var u=Fu.alloc();u.offset=r,u.length=n,e.push(u)}}},i._allocateChunkFromEntry=function(t,e,i,r){var n=i.length-r,s=i.offset+r,a=this._buffers[t];a.byteOffset<s&&(a.byteOffset=s),qn(n>=0,9004,t,i.offset,i.length),0===n?(this._freeLists[t].splice(e,1),Fu.free(i)):(i.offset+=r,i.length=n)},i._allocateBuffer=function(){qn(this._buffers.length===this._freeLists.length,9003);var t=new Iu,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=Fu.alloc();i.offset=0,i.length=t.vData.byteLength;var r=[i];return this._freeLists.push(r),Kr.root.batcher2D.syncMeshBuffersToNative(this.id,this._buffers),this._buffers.length-1},e.generateID=function(){return e.ID_COUNT++},Ur(e,[{key:"id",get:function(){return this._id}}]),e}(Ou);ku.IB_SCALE=4,ku.ID_COUNT=0,function(t){t[t.DrawInfoType=0]="DrawInfoType",t[t.VertDirty=1]="VertDirty",t[t.IsMeshBuffer=2]="IsMeshBuffer",t[t.Stride=3]="Stride",t[t.Count=4]="Count"}(Ru||(Ru={})),function(t){t[t.BufferID=0]="BufferID",t[t.AccessorID=1]="AccessorID",t[t.Count=2]="Count"}(Du||(Du={})),function(t){t[t.VertexOffset=0]="VertexOffset",t[t.IndexOffset=1]="IndexOffset",t[t.VBCount=2]="VBCount",t[t.IBCount=3]="IBCount",t[t.DataHash=4]="DataHash",t[t.Count=5]="Count"}(Mu||(Mu={})),function(t){t[t.COMP=0]="COMP",t[t.MODEL=1]="MODEL",t[t.IA=2]="IA",t[t.SUB_NODE=3]="SUB_NODE"}(Pu||(Pu={}));var Vu,Nu,Gu=function(){function t(t){this._accId=-1,this._bufferId=-1,this._vertexOffset=0,this._indexOffset=0,this._vb=null,this._ib=null,this._vData=null,this._iData=null,this._vertDirty=!1,this._vbCount=0,this._ibCount=0,this._dataHash=0,this._isMeshBuffer=!1,this._material=null,this._texture=null,this._sampler=null,this._stride=0,this._useLocal=!1,this._model=null,this._drawInfoType=Pu.COMP,this._subNode=null,this._uint8SharedBuffer=void 0,this._uint16SharedBuffer=void 0,this._uint32SharedBuffer=void 0,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,Ru.Count),i+=Ru.Count*Uint8Array.BYTES_PER_ELEMENT,this._uint16SharedBuffer=new Uint16Array(e,i,Du.Count),i+=Du.Count*Uint16Array.BYTES_PER_ELEMENT,this._uint32SharedBuffer=new Uint32Array(e,i,Mu.Count)}var e=t.prototype;return e.init=function(){},e.clear=function(){this._bufferId=0,this._vertexOffset=0,this._indexOffset=0,this._vertDirty=!1},e.setAccId=function(t){this._accId=t},e.setBufferId=function(t){this._bufferId=t},e.setAccAndBuffer=function(t,e){this._bufferId=e,this._accId=t},e.setVertexOffset=function(t){this._vertexOffset=t},e.setIndexOffset=function(t){this._indexOffset=t},e.setVB=function(){},e.setIB=function(){},e.setVData=function(){},e.setIData=function(){},e.setVBCount=function(t){this._vbCount=t},e.setIBCount=function(){},e.setVertDirty=function(t){this._vertDirty=t},e.setDataHash=function(t){this._dataHash=t},e.setIsMeshBuffer=function(t){this._isMeshBuffer=t},e.setMaterial=function(t){this._material=t},e.setTexture=function(t){this._texture=t},e.setSampler=function(t){this._sampler=t},e.setModel=function(){},e.setDrawInfoType=function(t){this._drawInfoType=t},e.setSubNode=function(t){this._subNode=t},e.setStride=function(t){this._stride=t},e.initRender2dBuffer=function(){},e.fillRender2dBuffer=function(){},Ur(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"render2dBuffer",get:function(){return this._render2dBuffer}}]),t}();!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"}(Vu||(Vu={})),function(t){t[t.stencilTest=0]="stencilTest",t[t.func=1]="func",t[t.stencilMask=2]="stencilMask",t[t.writeMask=3]="writeMask",t[t.failOp=4]="failOp",t[t.zFailOp=5]="zFailOp",t[t.passOp=6]="passOp",t[t.ref=7]="ref",t[t.count=8]="count"}(Nu||(Nu={}));var zu,Uu,Hu,Xu,Wu,ju=t("StencilManager",function(){function t(){this._maskStack=[],this._stencilPattern={stencilTest:!0,func:pt.ALWAYS,stencilMask:65535,writeMask:65535,failOp:mt.KEEP,zFailOp:mt.KEEP,passOp:mt.KEEP,ref:1},this._stage=Vu.DISABLED,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?Vu.CLEAR_INVERTED:Vu.CLEAR},e.enterLevel=function(t){t.subComp.stencilStage=t.inverted?Vu.ENTER_LEVEL_INVERTED:Vu.ENTER_LEVEL},e.enableMask=function(){this.stage=Vu.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=Vu.DISABLED:this.stage=Vu.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=Vu.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=pt.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 hi(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===Vu.DISABLED?(e.stencilTest=!1,e.func=pt.ALWAYS,e.failOp=mt.KEEP,e.stencilMask=e.writeMask=65535,e.ref=1):(e.stencilTest=!0,t===Vu.ENABLED?(e.func=pt.EQUAL,e.failOp=mt.KEEP,e.stencilMask=e.ref=this.getStencilRef(),e.writeMask=this.getWriteMask()):t===Vu.CLEAR?(e.func=pt.NEVER,e.failOp=mt.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===Vu.CLEAR_INVERTED||t===Vu.ENTER_LEVEL?(e.func=pt.NEVER,e.failOp=mt.REPLACE,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===Vu.ENTER_LEVEL_INVERTED&&(e.func=pt.NEVER,e.failOp=mt.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()))},Ur(t,[{key:"stage",get:function(){return this._stage},set:function(t){this._stage=t}},{key:"pattern",get:function(){return this._stencilPattern}}]),t}());ju.sharedManager=null,ju.sharedManager=new ju,function(t){t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC",t[t.CROSSED=2]="CROSSED"}(zu||(zu={})),function(t){t[t.localOpacity=0]="localOpacity",t[t.count=1]="count"}(Uu||(Uu={})),function(t){t[t.colorR=0]="colorR",t[t.colorG=1]="colorG",t[t.colorB=2]="colorB",t[t.colorA=3]="colorA",t[t.maskMode=4]="maskMode",t[t.count=5]="count"}(Hu||(Hu={})),function(t){t[t.colorDirty=0]="colorDirty",t[t.enabled=1]="enabled",t[t.useLocal=2]="useLocal",t[t.count=3]="count"}(Xu||(Xu={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.MASK_INVERTED=2]="MASK_INVERTED",t[t.MASK_NODE=3]="MASK_NODE",t[t.MASK_NODE_INVERTED=4]="MASK_NODE_INVERTED"}(Wu||(Wu={}));var Yu,qu,Ku,Ju,Zu,Qu,$u,tc,ec,ic,rc,nc,sc,ac,oc,lc,hc,uc,cc,_c,fc,dc,pc,mc,gc,yc,vc,bc,Sc,Ac,Tc,Cc,xc,wc,Ec,Bc=function(){function t(){this._renderEntityType=zu.STATIC,this._dynamicDrawInfoArr=[],this._node=null,this._stencilStage=Vu.DISABLED,this._useLocal=!1,this._maskMode=Wu.NONE,this._color=y.WHITE,this._localOpacity=255,this._colorDirty=!0,this._enabled=!0}var e=t.prototype;return e.addDynamicRenderDrawInfo=function(){},e.removeDynamicRenderDrawInfo=function(){},e.clearDynamicRenderDrawInfos=function(){},e.clearStaticRenderDrawInfos=function(){},e.setDynamicRenderDrawInfo=function(){},e.setMaskMode=function(t){this._maskMode=t},e.getStaticRenderDrawInfo=function(){return null},e.setNode=function(t){this._node=t},e.setStencilStage=function(t){this._stencilStage=t},e.setUseLocal=function(t){this._useLocal=t},e.initSharedBuffer=function(){},Ur(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"renderDrawInfoArr",get:function(){return this._dynamicDrawInfoArr}},{key:"renderEntityType",get:function(){return this._renderEntityType}},{key:"color",get:function(){return this._color},set:function(t){this._color=t}},{key:"localOpacity",get:function(){return this._localOpacity},set:function(t){this._localOpacity=t}},{key:"colorDirty",get:function(){return this._colorDirty},set:function(t){this._colorDirty=t}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}}]),t}(),Rc=Bu(xu)>>2,Dc=new H((function(){return{x:0,y:0,z:0,u:0,v:0,color:y.WHITE.clone()}}),128),Mc=t("BaseRenderData",function(){function t(t){void 0===t&&(t=xu),this.chunk=null,this._renderDrawInfo=null,this._material=null,this._dataHash=0,this._isMeshBuffer=!1,this._vc=0,this._ic=0,this._floatStride=0,this._vertexFormat=xu,this._drawInfoType=Pu.COMP,this._multiOwner=!1,this._batcher=null,this._floatStride=t===xu?Rc:Bu(t)>>2,this._vertexFormat=t}var e=t.prototype;return e.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},e.initRenderDrawInfo=function(t,e){void 0===e&&(e=Pu.COMP)},e.removeRenderDrawInfo=function(){},e.setRenderDrawInfoAttributes=function(){},Ur(t,[{key:"vertexCount",get:function(){return this._vc}},{key:"indexCount",get:function(){return this._ic}},{key:"stride",get:function(){return this._floatStride<<2}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vertexFormat",get:function(){return this._vertexFormat}},{key:"drawInfoType",get:function(){return this._drawInfoType},set:function(t){this._drawInfoType=t,this._renderDrawInfo&&this._renderDrawInfo.setDrawInfoType(t)}},{key:"renderDrawInfo",get:function(){return this._renderDrawInfo}},{key:"material",get:function(){return this._material},set:function(t){this._material=t,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(t)}},{key:"dataHash",get:function(){return this._dataHash},set:function(t){this._dataHash=t,this._renderDrawInfo&&this._renderDrawInfo.setDataHash(t)}},{key:"multiOwner",get:function(){return this._multiOwner},set:function(t){this._multiOwner=t}},{key:"batcher",get:function(){return this._batcher||(this._batcher=Kr.root.batcher2D),this._batcher}}]),t}()),Pc=t("RenderData",function(t){function e(e,i){var r;return void 0===e&&(e=xu),(r=t.call(this,e)||this)._vertDirty=!0,r._textureHash=0,r.indices=null,r.layer=0,r.nodeDirty=!0,r.passDirty=!0,r.textureDirty=!0,r.hashDirty=!0,r._data=[],r._pivotX=0,r._pivotY=0,r._width=0,r._height=0,r._frame=null,r._accessor=null,r.vertexRow=1,r.vertexCol=1,i||(i=r.batcher.switchBufferAccessor(r._vertexFormat)),r._accessor=i,r}on(e,t),e.add=function(t,i){void 0===t&&(t=xu);var r=new e(t);return r._floatStride=t===xu?Rc:Bu(t)>>2,r._vertexFormat=t,i||(i=Kr.root.batcher2D.switchBufferAccessor(r._vertexFormat)),r._accessor=i,r},e.remove=function(t){t.clear(),t._accessor=null};var i=e.prototype;return i.resize=function(t,e){t===this._vc&&e===this._ic&&this.chunk||(this._vc=t,this._ic=e,this.chunk&&(this._accessor.recycleChunk(this.chunk),this.chunk=null),this.chunk=this._accessor.allocateChunk(t,e),this.updateHash())},i.setRenderDrawInfoAttributes=function(){},i.fillDrawInfoAttributes=function(){},i.syncRender2dBuffer=function(){},i.resizeAndCopy=function(t,e){if(t!==this._vc||e!==this._ic||!this.chunk){this._vc=t,this._ic=e;var i=this.chunk;this.chunk=this._accessor.allocateChunk(t,e),i&&(this.chunk.vb.set(i.vb),this._accessor.recycleChunk(i)),this.updateHash()}},i.getMeshBuffer=function(){return this.chunk&&this._accessor?this._accessor.getMeshBuffer(this.chunk.bufferId):null},i.updateNode=function(t){this.layer=t.node.layer,this.nodeDirty=!1,this.hashDirty=!0},i.updatePass=function(t){this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0},i.updateTexture=function(t){this.frame=t,this.textureHash=t.getHash(),this.textureDirty=!1,this.hashDirty=!0},i.updateHash=function(){var t=""+(this.chunk?this.chunk.bufferId:-1)+this.layer+" "+this.textureHash;this.dataHash=In(t,666),this.hashDirty=!1},i.updateRenderData=function(t,e){if(this.passDirty&&(this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(this.material)),this.nodeDirty){var i=t.node.scene?t._getRenderScene():null;this.layer=t.node.layer,null!==i&&(this.nodeDirty=!1),this.hashDirty=!0}this.textureDirty&&(this.frame=e,this.textureHash=e.getHash(),this.textureDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&(this._renderDrawInfo.setTexture(this.frame?this.frame.getGFXTexture():null),this._renderDrawInfo.setSampler(this.frame?this.frame.getGFXSampler():null))),this.hashDirty&&(this.updateHash(),this._renderDrawInfo&&this._renderDrawInfo.setDataHash(this.dataHash))},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.resize(0,0),this._data.length=0,this._pivotX=0,this._pivotY=0,this._width=0,this._height=0,this.indices=null,this.vertDirty=!0,this.material=null,this.nodeDirty=!0,this.passDirty=!0,this.textureDirty=!0,this.hashDirty=!0,this.layer=0,this.frame=null,this.textureHash=0,this.dataHash=0},e.createStaticVBAccessor=function(t,e,i){var r=Kr.root.device;return new ku(r,t,e,i)},Ur(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++)Dc.free(e[r]);for(r=i;r<t;r++)e[r]=Dc.alloc();e.length=t}this.syncRender2dBuffer()}},{key:"data",get:function(){return this._data}},{key:"vertDirty",get:function(){return this._vertDirty},set:function(t){this._vertDirty=t,this._renderDrawInfo&&t&&this._renderDrawInfo.setVertDirty(t)}},{key:"textureHash",get:function(){return this._textureHash},set:function(t){this._textureHash=t}},{key:"frame",get:function(){return this._frame},set:function(t){this._frame=t,this._renderDrawInfo&&(this._frame?(this._renderDrawInfo.setTexture(this._frame.getGFXTexture()),this._renderDrawInfo.setSampler(this._frame.getGFXSampler())):(this._renderDrawInfo.setTexture(null),this._renderDrawInfo.setSampler(null)))}},{key:"accessor",get:function(){return this._accessor}}]),e}(Mc)),Ic=t("MeshRenderData",function(t){function e(e){var i;return void 0===e&&(e=xu),(i=t.call(this,e)||this)._isMeshBuffer=!0,i.vData=void 0,i.iData=void 0,i.vertexStart=0,i.vertexRange=0,i.indexStart=0,i.indexRange=0,i.lastFilledIndex=0,i.lastFilledVertex=0,i.frame=void 0,i._byteLength=0,i._vertexBuffers=[],i._indexBuffer=null,i._iaPool=null,i._iaInfo=null,i.vData=new Float32Array(256*i.stride),i.iData=new Uint16Array(1536),i}on(e,t),e.add=function(t){void 0===t&&(t=xu);var i=new e;return i._floatStride=t===xu?Rc:Bu(t)>>2,i._vertexFormat=t,i},e.remove=function(t){t.clear()};var i=e.prototype;return i.request=function(t,e){var i=this._byteLength+t*this.stride;return!!this.reserve(t,e)&&(this._vc+=t,this._ic+=e,this._byteLength=i,this.vertexRange=this._vc,this.indexRange=this._ic,!0)},i.reserve=function(t,e){var i=this._byteLength+t*this.stride,r=this.indexCount+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.resize=function(t,e){var i=t*this.stride;gn(t>=0&&e>=0&&i<=this.vData.byteLength&&e<=this.iData.length),this._vc=t,this._ic=e,this._byteLength=i,this.updateRange(0,t,0,e)},i.updateRange=function(t,e,i,r){gn(e>=0&&r>=0&&e<=this._vc&&r<=this._ic),this.vertexStart=t,this.indexStart=i,this.vertexRange=e,this.indexRange=r},i.requestIA=function(t){this._initIAInfo(t);var e=this._iaPool.add();return e.firstIndex=this.indexStart,e.indexCount=this.indexRange,e},i.uploadBuffers=function(){if(0!==this._byteLength&&this._vertexBuffers[0]&&this._indexBuffer){var t=this._ic,e=new Float32Array(this.vData.buffer,0,this._byteLength>>2),i=new Uint16Array(this.iData.buffer,0,t),r=this._vertexBuffers[0];this._byteLength>r.size&&r.resize(this._byteLength),r.update(e);var n=t<<1;n>this._indexBuffer.size&&this._indexBuffer.resize(n),this._indexBuffer.update(i)}},i.freeIAPool=function(){this._iaPool&&this._iaPool.reset()},i.reset=function(){this._vc=0,this._ic=0,this._byteLength=0,this.vertexStart=0,this.vertexRange=0,this.indexStart=0,this.indexRange=0,this.lastFilledIndex=0,this.lastFilledVertex=0,this.material=null,this.freeIAPool()},i.clear=function(){this.reset(),this._iaPool&&this._iaPool.destroy(),this._vertexBuffers[0]&&(this._vertexBuffers[0].destroy(),this._vertexBuffers=[]),this._iaInfo=null,this.vData=new Float32Array(256*this.stride),this.iData=new Uint16Array(1536)},i._initIAInfo=function(t){var e=this;if(!this._iaInfo){var i=this.stride,r=this._vertexBuffers;r.length||r.push(t.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.DEVICE,i,i)));var n=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=t.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,n,n))),this._iaInfo=new be(this._vertexFormat,r,this._indexBuffer),this._iaPool=new X((function(){return t.createInputAssembler(e._iaInfo)}),1,(function(t){t.destroy()}))}},i._reallocBuffer=function(t,e){var i=this.vData;this.vData=new Float32Array(t),i&&this.vData.set(i,0);var r=this.iData;this.iData=new Uint16Array(e),r&&this.iData.set(r,0)},i.setRenderDrawInfoAttributes=function(){},i.particleInitRenderDrawInfo=function(){},Ur(e,[{key:"formatByte",get:function(){return this.stride},set:function(){}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vDataOffset",get:function(){return this._byteLength>>>2}}]),e}(Mc)),Oc=(new X((function(){return new Ic}),32),new i),Fc=new i,Lc=new n,kc=new c,Vc=new c,Nc=new c,Gc=new c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),zc=new m,Uc=(Yu=En("cc.UITransform"),qu=Qn(),Ku=$n(110),Ju=ts(),Zu=es(),Qu=is(),$u=es(),tc=is(),oc=Yu(ec=qu(ec=Ku(ec=Ju(ec=Kn(ec=Jn((ac=sc=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,Mn(e,"_contentSize",rc,Pn(e)),Mn(e,"_anchorPoint",nc,Pn(e)),e}on(e,t);var r=e.prototype;return r.__preload=function(){this.node._uiProps.uiTransformComp=this},r.onLoad=function(){this.node.parent&&e.insertChangeMap(this.node.parent)},r.onEnable=function(){this.node.on(Zn.PARENT_CHANGED,this._parentChanged,this),this._markRenderDataDirty()},r.onDisable=function(){this.node.off(Zn.PARENT_CHANGED,this._parentChanged,this)},r.onDestroy=function(){this.node._uiProps.uiTransformComp=null},r.setContentSize=function(t,e){var i=this._contentSize;if(void 0===e){if(A((t=t).width,i.width,b)&&A(t.height,i.height,b))return;i.width=t.width,i.height=t.height}else{if(A(t=t,i.width,b)&&A(e,i.height,b))return;i.width=t,i.height=e}this.node.emit(Zn.SIZE_CHANGED),this._markRenderDataDirty()},r.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(Zn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty()},r.isHit=function(t){for(var e=this._contentSize.width,r=this._contentSize.height,n=Oc,s=Fc,a=this._getRenderScene().cameras,o=0;o<a.length;o++){var l=a[o];if(l.visibility&this.node.layer){l.node.getWorldRT(kc);var h=kc.m12,u=kc.m13,_=rs.center;if(kc.m12=_.x-(kc.m00*h+kc.m04*u),kc.m13=_.y-(kc.m01*h+kc.m05*u),c.invert(kc,kc),i.transformMat4(n,t,kc),this.node.getWorldMatrix(Nc),c.invert(kc,Nc),!c.strictEquals(kc,Gc)){i.transformMat4(s,n,kc),s.x+=this._anchorPoint.x*e,s.y+=this._anchorPoint.y*r;var f=!1;if(s.x>=0&&s.y>=0&&s.x<=e&&s.y<=r&&(f=this._maskTest(n)),f)return!0}}}return!1},r.hitTest=function(t){for(var e=this._contentSize.width,r=this._contentSize.height,s=Lc,a=Oc,o=Fc,l=this._getRenderScene().cameras,h=0;h<l.length;h++){var u=l[h];if(u.visibility&this.node.layer&&(!u.window||u.window.swapchain)&&(n.set(s,t.x,t.y,0),u.screenToWorld(s,s),i.set(a,s.x,s.y),this.node.getWorldMatrix(Nc),c.invert(kc,Nc),!c.strictEquals(kc,Gc))){i.transformMat4(o,a,kc),o.x+=this._anchorPoint.x*e,o.y+=this._anchorPoint.y*r;var _=!1;if(o.x>=0&&o.y>=0&&o.x<=e&&o.y<=r&&(_=this._maskTest(a)),_)return!0}}return!1},r._maskTest=function(t){var e,i,r=null===(e=this.node)||void 0===e||null===(i=e.eventProcessor)||void 0===i?void 0:i.maskList;if(r)for(var n=this.node,s=r.length,a=0,o=0;n&&o<s;++a,n=n.parent){var l=r[o];if(a===l.index){if(n!==l.comp.node){r.length=o;break}var h=l.comp;if(h&&h._enabled&&!h.isHit(t))return!1;o++}else if(a>l.index){r.length=o;break}}return!0},r.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(Nc),c.invert(kc,Nc),e||(e=new n),n.transformMat4(e,t,kc)},r.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(Nc),e||(e=new n),n.transformMat4(e,t,Nc)},r.getBoundingBox=function(){c.fromRTS(Vc,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var t=this._contentSize.width,e=this._contentSize.height,i=new m(-this._anchorPoint.x*t,-this._anchorPoint.y*e,t,e);return i.transformMat4(Vc),i},r.getBoundingBoxToWorld=function(){return this.node.parent?(this.node.parent.getWorldMatrix(Nc),this.getBoundingBoxTo(Nc)):this.getBoundingBox()},r.getBoundingBoxTo=function(t){c.fromRTS(Vc,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var i=this._contentSize.width,r=this._contentSize.height,n=new m(-this._anchorPoint.x*i,-this._anchorPoint.y*r,i,r);if(c.multiply(Nc,t,Vc),n.transformMat4(Nc),!this.node.children)return n;for(var s,a=this.node.children,o=hn(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&&m.union(n,n,u)}}}return n},r.getComputeAABB=function(t){var e=this._contentSize.width,i=this._contentSize.height;zc.set(-this._anchorPoint.x*e,-this._anchorPoint.y*i,e,i),zc.transformMat4(this.node.worldMatrix);var r=zc.x+.5*zc.width,n=zc.y+.5*zc.height,s=this.node.worldPosition.z,a=zc.width/2,o=zc.height/2;return null!=t?(Ii.set(t,r,n,s,a,o,.001),t):new Ii(r,n,s,a,o,.001)},r._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this.node.parent&&e.insertChangeMap(this.node.parent)},r._markRenderDataDirty=function(){var t=this.node._uiProps.uiComp;t&&t.markForUpdateRenderData()},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()},Ur(e,[{key:"contentSize",get:function(){return this._contentSize},set:function(t){this._contentSize.equals(t)||(this._contentSize.set(t),this.node.emit(Zn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"width",get:function(){return this._contentSize.width},set:function(t){this._contentSize.width!==t&&(this._contentSize.width=t,this.node.emit(Zn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"height",get:function(){return this._contentSize.height},set:function(t){this.contentSize.height!==t&&(this._contentSize.height=t,this.node.emit(Zn.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(t){this._anchorPoint.equals(t)||(this._anchorPoint.set(t),this.node.emit(Zn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this.node.emit(Zn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this.node.emit(Zn.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority!==t&&(this.node.getComponent("cc.RenderRoot2D")?Rn(6706):(this._priority=t,this.node.parent&&e.insertChangeMap(this.node.parent)))}},{key:"visibility",get:function(){var t=Kr.root.batcher2D.getFirstRenderCamera(this.node);return t?t.visibility:0}},{key:"cameraPriority",get:function(){var t=Kr.root.batcher2D.getFirstRenderCamera(this.node);return t?t.priority:0}}]),e}(ns),sc.EventType=Zn,sc.priorityChangeNodeMap=new Map,Dn((ic=ac).prototype,"contentSize",[Zu,Qu],Object.getOwnPropertyDescriptor(ic.prototype,"contentSize"),ic.prototype),Dn(ic.prototype,"anchorPoint",[$u,tc],Object.getOwnPropertyDescriptor(ic.prototype,"anchorPoint"),ic.prototype),rc=Dn(ic.prototype,"_contentSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new d(100,100)}}),nc=Dn(ic.prototype,"_anchorPoint",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(.5,.5)}}),ec=ic))||ec)||ec)||ec)||ec)||ec)||ec,t({UITransform:oc,UITransformComponent:oc}),oc);Kr.on(Or.EVENT_AFTER_UPDATE,Uc._sortSiblings),Kr.on(Or.EVENT_BEFORE_SCENE_LAUNCH,Uc._cleanChangeMap),ss(gt),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"}(Ec||(Ec=t("InstanceMaterialType",{})));var Hc,Xc,Wc,jc,Yc,qc,Kc,Jc,Zc,Qc,$c,t_,e_,i_,r_,n_,s_,a_,o_,l_,h_,u_,c_,__,f_,d_,p_,m_,g_,y_,v_,b_,S_,A_,T_,C_,x_,w_,E_,B_,R_,D_,M_,P_,I_,O_,F_,L_,k_,V_,N_,G_,z_,U_,H_,X_,W_,j_,Y_,q_,K_,J_,Z_,Q_,$_,tf,ef,rf,nf,sf,af=function(e){return t({UIRenderer:e,RenderComponent:e,UIRenderable:e,Renderable2D:e}),e}((lc=En("cc.UIRenderer"),hc=us(Uc),uc=cs(),cc=Wn(cn),_c=es(),fc=is(),dc=_s(),pc=es(),mc=is(),gc=Wn(cn),lc(yc=hc(yc=Jn((wc=xc=function(t){function e(){var e;return(e=t.call(this)||this)._renderData=null,Mn(e,"_materials",bc,Pn(e)),Mn(e,"_customMaterial",Sc,Pn(e)),Mn(e,"_srcBlendFactor",Ac,Pn(e)),Mn(e,"_dstBlendFactor",Tc,Pn(e)),Mn(e,"_color",Cc,Pn(e)),e._stencilStage=Vu.DISABLED,e._assembler=null,e._postAssembler=null,e._renderDataFlag=!0,e._renderFlag=!0,e._renderEntity=void 0,e._instanceMaterialType=-1,e._srcBlendFactorCache=gt.SRC_ALPHA,e._dstBlendFactorCache=gt.ONE_MINUS_SRC_ALPHA,e._dirtyVersion=-1,e._internalId=-1,e._useVertexOpacity=!1,e._lastParent=null,e._renderEntity=e.createRenderEntity(),e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._renderEntity.setNode(this.node)},i.__preload=function(){this.node._uiProps.uiComp=this,this._flushAssembler&&this._flushAssembler()},i.onEnable=function(){this.node.on(Zn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(Zn.SIZE_CHANGED,this._nodeStateChange,this),this.node.on(Zn.PARENT_CHANGED,this._colorDirty,this),this.updateMaterial(),this._colorDirty(),as.addRenderer(this),this.markForUpdateRenderData()},i.onRestore=function(){this.updateMaterial(),this.markForUpdateRenderData()},i.onDisable=function(){this.node.off(Zn.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(Zn.SIZE_CHANGED,this._nodeStateChange,this),this.node.off(Zn.PARENT_CHANGED,this._colorDirty,this),as.removeRenderer(this),this._renderFlag=!1,this._renderEntity.enabled=!1},i.onDestroy=function(){if(this._renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this.destroyRenderData(),this._materialInstances)for(var t=0;t<this._materialInstances.length;t++){var e=this._materialInstances[t];e&&e.destroy()}},i.markForUpdateRenderData=function(t){if(void 0===t&&(t=!0),t){var e=this.renderData;e&&(e.vertDirty=!0),as.markDirtyRenderer(this)}},i.requestRenderData=function(t){void 0===t&&(t=Pu.COMP);var e=Pc.add();return e.initRenderDrawInfo(this,t),this._renderData=e,e},i.destroyRenderData=function(){this.renderData&&(this.renderData.removeRenderDrawInfo(this),Pc.remove(this.renderData),this._renderData=null)},i.updateRenderer=function(){this._assembler&&this._assembler.updateRenderData(this),this._renderFlag=this._canRender(),this._renderEntity.enabled=this._renderFlag},i.fillBuffers=function(t){this._renderFlag&&this._render(t)},i.postUpdateAssembler=function(t){this._postAssembler&&this._renderFlag&&this._postRender(t)},i._render=function(){},i._postRender=function(){},i._canRender=function(){return null!==this.getMaterial(0)&&this._enabled&&this._color.a>0},i._postCanRender=function(){},i.updateMaterial=function(){if(this._customMaterial)this.setMaterial(this._customMaterial,0);else{var t=this._updateBuiltinMaterial();this.setMaterial(t,0),this._updateBlendFunc()}},i._updateColor=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0),this.setEntityColor(this._color),this.setEntityOpacity(this.node._uiProps.localOpacity),this._assembler&&(this._assembler.updateColor(this),this._renderFlag=this._canRender(),this.setEntityEnabled(this._renderFlag))},e.setEntityColorDirtyRecursively=function(t,i){var r=t._uiProps.uiComp;r&&r.color&&(r._renderEntity.colorDirty=i);for(var n=0;n<t.children.length;n++)e.setEntityColorDirtyRecursively(t.children[n],i)},i.setEntityColorDirty=function(){},i.setEntityColor=function(){},i.setEntityOpacity=function(){},i.setEntityEnabled=function(){},i._updateBlendFunc=function(){var t=this.getRenderMaterial(0).passes[0].blendState.targets[0];if(this._dstBlendFactorCache=t.blendDst,this._srcBlendFactorCache=t.blendSrc,this._dstBlendFactorCache!==this._dstBlendFactor||this._srcBlendFactorCache!==this._srcBlendFactor){(t=this.getMaterialInstance(0).passes[0].blendState.targets[0]).blend=!0,t.blendDstAlpha=gt.ONE_MINUS_SRC_ALPHA,t.blendDst=this._dstBlendFactor,t.blendSrc=this._srcBlendFactor;var e=this.getMaterialInstance(0).passes[0];e.blendState.setTarget(0,t),e._updatePassHash(),this._dstBlendFactorCache=this._dstBlendFactor,this._srcBlendFactorCache=this._srcBlendFactor}},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._colorDirty=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0)},i._onMaterialModified=function(e,i){this.renderData&&(this.markForUpdateRenderData(),this.renderData.passDirty=!0),t.prototype._onMaterialModified.call(this,e,i)},i._updateBuiltinMaterial=function(){var t;switch(this._instanceMaterialType){case Ec.ADD_COLOR:t=os.get("ui-base-material");break;case Ec.GRAYSCALE:t=os.get("ui-sprite-gray-material");break;case Ec.USE_ALPHA_SEPARATED:t=os.get("ui-sprite-alpha-sep-material");break;case Ec.USE_ALPHA_SEPARATED_AND_GRAY:t=os.get("ui-sprite-gray-alpha-sep-material");break;default:t=os.get("ui-sprite-material")}return t},i.setNodeDirty=function(){this.renderData&&(this.renderData.nodeDirty=!0)},i.setTextureDirty=function(){this.renderData&&(this.renderData.textureDirty=!0)},i.createRenderEntity=function(){return new Bc(zu.STATIC)},Ur(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:"color",get:function(){return this._color},set:function(t){this._color.equals(t)||(this._color.set(t),this._updateColor())}},{key:"renderData",get:function(){return this._renderData}},{key:"useVertexOpacity",get:function(){return this._useVertexOpacity}},{key:"stencilStage",get:function(){return this._stencilStage},set:function(t){this._stencilStage=t,this._renderEntity.setStencilStage(t)}},{key:"batcher",get:function(){return Kr.root.batcher2D}},{key:"renderEntity",get:function(){return this._renderEntity}}]),e}(ls),xc.BlendState=gt,xc.Assembler=null,xc.PostAssembler=null,Dn((vc=wc).prototype,"sharedMaterials",[Hn,uc],Object.getOwnPropertyDescriptor(vc.prototype,"sharedMaterials"),vc.prototype),Dn(vc.prototype,"customMaterial",[cc,_c,fc,dc,hs],Object.getOwnPropertyDescriptor(vc.prototype,"customMaterial"),vc.prototype),Dn(vc.prototype,"color",[pc,mc],Object.getOwnPropertyDescriptor(vc.prototype,"color"),vc.prototype),bc=Dn(vc.prototype,"_materials",[Hn],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Sc=Dn(vc.prototype,"_customMaterial",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ac=Dn(vc.prototype,"_srcBlendFactor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gt.SRC_ALPHA}}),Tc=Dn(vc.prototype,"_dstBlendFactor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gt.ONE_MINUS_SRC_ALPHA}}),Cc=Dn(vc.prototype,"_color",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),yc=vc))||yc)||yc)||yc));Er.internal.UIRenderer=af,y.WHITE.clone(),function(t){t[t.LEFT=0]="LEFT",t[t.CENTER=1]="CENTER",t[t.RIGHT=2]="RIGHT"}(ef||(ef=t("HorizontalTextAlignment",{}))),ss(ef),function(t){t[t.TOP=0]="TOP",t[t.CENTER=1]="CENTER",t[t.BOTTOM=2]="BOTTOM"}(rf||(rf=t("VerticalTextAlignment",{}))),ss(rf),function(t){t[t.NONE=0]="NONE",t[t.CLAMP=1]="CLAMP",t[t.SHRINK=2]="SHRINK",t[t.RESIZE_HEIGHT=3]="RESIZE_HEIGHT"}(nf||(nf=t("Overflow",{}))),ss(nf),function(t){t[t.NONE=0]="NONE",t[t.BITMAP=1]="BITMAP",t[t.CHAR=2]="CHAR"}(sf||(sf=t("CacheMode",{}))),ss(sf);var of=function(e){return t({Label:e,LabelComponent:e}),e}((Hc=En("cc.Label"),Xc=Qn(),Wc=$n(110),jc=ts(),Yc=es(),qc=is(),Kc=Wn(ef),Jc=es(),Zc=is(),Qc=Wn(rf),$c=es(),t_=is(),e_=es(),i_=is(),r_=es(),n_=cs(),s_=is(),a_=es(),o_=is(),l_=cs(),h_=es(),u_=is(),c_=Wn(nf),__=es(),f_=is(),d_=es(),p_=is(),m_=Wn(Fh),g_=es(),y_=cs(),v_=is(),b_=es(),S_=is(),A_=Wn(sf),T_=es(),C_=is(),x_=es(),w_=is(),E_=es(),B_=is(),R_=es(),D_=is(),M_=cs(),P_=es(),I_=is(),Hc(O_=Xc(O_=Wc(O_=jc((tf=$_=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_string",L_,Pn(e)),Mn(e,"_horizontalAlign",k_,Pn(e)),Mn(e,"_verticalAlign",V_,Pn(e)),Mn(e,"_actualFontSize",N_,Pn(e)),Mn(e,"_fontSize",G_,Pn(e)),Mn(e,"_fontFamily",z_,Pn(e)),Mn(e,"_lineHeight",U_,Pn(e)),Mn(e,"_overflow",H_,Pn(e)),Mn(e,"_enableWrapText",X_,Pn(e)),Mn(e,"_font",W_,Pn(e)),Mn(e,"_isSystemFontUsed",j_,Pn(e)),Mn(e,"_spacingX",Y_,Pn(e)),Mn(e,"_isItalic",q_,Pn(e)),Mn(e,"_isBold",K_,Pn(e)),Mn(e,"_isUnderline",J_,Pn(e)),Mn(e,"_underlineHeight",Z_,Pn(e)),Mn(e,"_cacheMode",Q_,Pn(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}on(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._applyFontTexture()},i.onDestroy=function(){if(this._assembler&&this._assembler.resetAssemblerData&&this._assembler.resetAssemblerData(this._assemblerData),this._assemblerData=null,this._ttfSpriteFrame){this._ttfSpriteFrame._resetDynamicAtlasFrame();var e=this._ttfSpriteFrame.texture;if(this._ttfSpriteFrame.destroy(),e){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),t&&(this._flushAssembler(),this.renderData&&(this.renderData.vertDirty=!0),this._applyFontTexture()),this._assembler&&this._assembler.updateRenderData(this)},i._render=function(t){t.commitComp(this,this.renderData,this._texture,this._assembler,null)},i._updateColor=function(){t.prototype._updateColor.call(this),this.markForUpdateRenderData()},i.setEntityColor=function(){},i._canRender=function(){if(!t.prototype._canRender.call(this)||!this._string)return!1;var e=this._font;if(e&&e instanceof Kh){var i=e.spriteFrame;if(!i||!i.texture)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,this._updateColor())},i._applyFontTexture=function(){this.markForUpdateRenderData();var t=this._font;if(t instanceof Kh){var e=t.spriteFrame;e&&e.texture&&(this._texture=e,this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine(),this._assembler&&this._assembler.updateRenderData(this))}else{if(this.cacheMode===sf.CHAR)this._letterTexture=this._assembler.getAssemblerData(),this._texture=this._letterTexture;else if(!this._ttfSpriteFrame){this._ttfSpriteFrame=new Bh,this._assemblerData=this._assembler.getAssemblerData();var i=new vn(this._assemblerData.canvas),r=new fn;r.image=i,this._ttfSpriteFrame.texture=r}this.cacheMode!==sf.CHAR&&(this._texture=this._ttfSpriteFrame),this.changeMaterialForDefine()}},i.changeMaterialForDefine=function(){if(this._texture){var t=!1;if(this.cacheMode!==sf.CHAR){var e=this._texture.texture;if(e instanceof fs){var i=e.getPixelFormat();t=i===_n.RGBA_ETC1||i===_n.RGB_A_PVRTC_4BPPV1||i===_n.RGB_A_PVRTC_2BPPV1}}this._instanceMaterialType=t?Ec.USE_ALPHA_SEPARATED:Ec.ADD_COLOR_AND_TEXTURE,this.updateMaterial()}},i._updateBlendFunc=function(){t.prototype._updateBlendFunc.call(this)},Ur(e,[{key:"string",get:function(){return this._string},set:function(t){t=null==t?"":t.toString(),this._string!==t&&(this._string=t,this.markForUpdateRenderData())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this._horizontalAlign!==t&&(this._horizontalAlign=t,this.markForUpdateRenderData())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this.markForUpdateRenderData())}},{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.markForUpdateRenderData())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.markForUpdateRenderData())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this.markForUpdateRenderData())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this.markForUpdateRenderData())}},{key:"overflow",get:function(){return this._overflow},set:function(t){this._overflow!==t&&(this._overflow=t,this.markForUpdateRenderData())}},{key:"enableWrapText",get:function(){return this._enableWrapText},set:function(t){this._enableWrapText!==t&&(this._enableWrapText=t,this.markForUpdateRenderData())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._isSystemFontUsed=!t,this._font=t,this.destroyRenderData(),this._fontAtlas=null,this.updateRenderData(!0))}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this.destroyRenderData(),this._isSystemFontUsed=!!t,t&&(this.font=null),this._flushAssembler(),this.markForUpdateRenderData())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode!==sf.BITMAP||this._font instanceof Kh||!this._ttfSpriteFrame||this._ttfSpriteFrame._resetDynamicAtlasFrame(),this._cacheMode===sf.CHAR&&(this._ttfSpriteFrame=null),this._cacheMode=t,this.updateRenderData(!0))}},{key:"isBold",get:function(){return this._isBold},set:function(t){this._isBold!==t&&(this._isBold=t,this.markForUpdateRenderData())}},{key:"isItalic",get:function(){return this._isItalic},set:function(t){this._isItalic!==t&&(this._isItalic=t,this.markForUpdateRenderData())}},{key:"isUnderline",get:function(){return this._isUnderline},set:function(t){this._isUnderline!==t&&(this._isUnderline=t,this.markForUpdateRenderData())}},{key:"underlineHeight",get:function(){return this._underlineHeight},set:function(t){this._underlineHeight!==t&&(this._underlineHeight=t,this.markForUpdateRenderData())}},{key:"spriteFrame",get:function(){return this._texture}},{key:"ttfSpriteFrame",get:function(){return this._ttfSpriteFrame}},{key:"assemblerData",get:function(){return this._assemblerData}},{key:"fontAtlas",get:function(){return this._fontAtlas},set:function(t){this._fontAtlas=t}},{key:"_bmFontOriginalSize",get:function(){return this._font instanceof Kh?this._font.fontSize:-1}}]),e}(af),$_.HorizontalAlign=ef,$_.VerticalAlign=rf,$_.Overflow=nf,$_.CacheMode=sf,$_._canvasPool=pu.getInstance(),Dn((F_=tf).prototype,"string",[Yc,qc,ds],Object.getOwnPropertyDescriptor(F_.prototype,"string"),F_.prototype),Dn(F_.prototype,"horizontalAlign",[Kc,Jc,Zc],Object.getOwnPropertyDescriptor(F_.prototype,"horizontalAlign"),F_.prototype),Dn(F_.prototype,"verticalAlign",[Qc,$c,t_],Object.getOwnPropertyDescriptor(F_.prototype,"verticalAlign"),F_.prototype),Dn(F_.prototype,"fontSize",[e_,i_],Object.getOwnPropertyDescriptor(F_.prototype,"fontSize"),F_.prototype),Dn(F_.prototype,"fontFamily",[r_,n_,s_],Object.getOwnPropertyDescriptor(F_.prototype,"fontFamily"),F_.prototype),Dn(F_.prototype,"lineHeight",[a_,o_],Object.getOwnPropertyDescriptor(F_.prototype,"lineHeight"),F_.prototype),Dn(F_.prototype,"spacingX",[l_,h_,u_],Object.getOwnPropertyDescriptor(F_.prototype,"spacingX"),F_.prototype),Dn(F_.prototype,"overflow",[c_,__,f_],Object.getOwnPropertyDescriptor(F_.prototype,"overflow"),F_.prototype),Dn(F_.prototype,"enableWrapText",[d_,p_],Object.getOwnPropertyDescriptor(F_.prototype,"enableWrapText"),F_.prototype),Dn(F_.prototype,"font",[m_,g_,y_,v_],Object.getOwnPropertyDescriptor(F_.prototype,"font"),F_.prototype),Dn(F_.prototype,"useSystemFont",[b_,S_],Object.getOwnPropertyDescriptor(F_.prototype,"useSystemFont"),F_.prototype),Dn(F_.prototype,"cacheMode",[A_,T_,C_],Object.getOwnPropertyDescriptor(F_.prototype,"cacheMode"),F_.prototype),Dn(F_.prototype,"isBold",[x_,w_],Object.getOwnPropertyDescriptor(F_.prototype,"isBold"),F_.prototype),Dn(F_.prototype,"isItalic",[E_,B_],Object.getOwnPropertyDescriptor(F_.prototype,"isItalic"),F_.prototype),Dn(F_.prototype,"isUnderline",[R_,D_],Object.getOwnPropertyDescriptor(F_.prototype,"isUnderline"),F_.prototype),Dn(F_.prototype,"underlineHeight",[M_,Un,P_,I_],Object.getOwnPropertyDescriptor(F_.prototype,"underlineHeight"),F_.prototype),L_=Dn(F_.prototype,"_string",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"label"}}),k_=Dn(F_.prototype,"_horizontalAlign",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ef.CENTER}}),V_=Dn(F_.prototype,"_verticalAlign",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return rf.CENTER}}),N_=Dn(F_.prototype,"_actualFontSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),G_=Dn(F_.prototype,"_fontSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),z_=Dn(F_.prototype,"_fontFamily",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),U_=Dn(F_.prototype,"_lineHeight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),H_=Dn(F_.prototype,"_overflow",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return nf.NONE}}),X_=Dn(F_.prototype,"_enableWrapText",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),W_=Dn(F_.prototype,"_font",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),j_=Dn(F_.prototype,"_isSystemFontUsed",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Y_=Dn(F_.prototype,"_spacingX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),q_=Dn(F_.prototype,"_isItalic",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),K_=Dn(F_.prototype,"_isBold",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),J_=Dn(F_.prototype,"_isUnderline",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Z_=Dn(F_.prototype,"_underlineHeight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),Q_=Dn(F_.prototype,"_cacheMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sf.NONE}}),O_=F_))||O_)||O_)||O_)||O_));Er.Label=of;var lf,hf,uf=0,cf={};function _f(t){return--t,t|=t>>16,t|=t>>8,t|=t>>4,t|=t>>2,t|=t>>1,++t}function ff(t,e){return Math.ceil(t/e)*e}!function(t){t[t.OPAQUE=0]="OPAQUE",t[t.TRANSPARENT=1]="TRANSPARENT",t[t.OVERLAY=2]="OVERLAY"}(lf||(lf={})),function(t){t[t.DEFAULT=1]="DEFAULT",t[t.FORWARD=2]="FORWARD",t[t.SHADOWCAST=4]="SHADOWCAST"}(hf||(hf={}));var df,pf,mf,gf,yf,vf,bf,Sf,Af,Tf=function(){function t(t){this._device=void 0,this._format=tt.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new Kt,this._region1=new Kt,this._region2=new Kt,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=t}var e=t.prototype;return e.initialize=function(t){var e=Xe[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=$e(e),this._roundUpFn=t.roundUpFn||null,this._alignment=t.alignment||1,t.inOrderFree&&(this.alloc=this._McDonaldAlloc)},e.destroy=function(){for(var t=0;t<this._chunkCount;++t)this._chunks[t].texture.destroy();this._chunks.length=0,this._handles.length=0},e.alloc=function(t,e){t=ff(t,this._alignment);var i=-1,r=-1;if(void 0!==e&&(i=e,r=this._findAvailableSpace(t,i)),r<0)for(var n=0;n<this._chunkCount&&(i=n,!((r=this._findAvailableSpace(t,i))>=0));++n);if(r>=0){var s=this._chunks[i];s.start+=t;var a={chunkIdx:i,start:r,end:r+t,texture:s.texture};return this._handles.push(a),a}var o=Math.sqrt(t/this._formatSize),l=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,_f(o)),h=this._chunks[this.createChunk(l)];h.start+=t;var u={chunkIdx:this._chunkCount-1,start:0,end:t,texture:h.texture};return this._handles.push(u),u},e.free=function(t){for(var e=0;e<this._handles.length;++e)if(this._handles[e]===t)return this._chunks[t.chunkIdx].end=t.end,void this._handles.splice(e,1)},e.createChunk=function(t){var e=t*t*this._formatSize;ps("TextureBufferPool: Allocate chunk "+this._chunkCount+", size: "+e+", format: "+this._format);var i={texture:this._device.createTexture(new ae(ot.TEX2D,lt.SAMPLED|lt.TRANSFER_DST,this._format,t,t)),size:e,start:0,end:e};return this._chunks[this._chunkCount]=i,this._chunkCount++},e.update=function(t,e){var i=[],r=[],n=t.start/this._formatSize,s=e.byteLength/this._formatSize,a=n%t.texture.width,o=Math.floor(n/t.texture.width),l=Math.min(t.texture.width-a,s),h=0;a>0&&(this._region0.texOffset.x=a,this._region0.texOffset.y=o,this._region0.texExtent.width=l,this._region0.texExtent.height=1,i.push(new this._bufferViewCtor(e,h*this._formatSize,l*this._channels)),r.push(this._region0),a=0,o+=1,s-=l,h+=l),s>0&&(this._region1.texOffset.x=a,this._region1.texOffset.y=o,s>t.texture.width?(this._region1.texExtent.width=t.texture.width,this._region1.texExtent.height=Math.floor(s/t.texture.width),l=this._region1.texExtent.width*this._region1.texExtent.height):(l=s,this._region1.texExtent.width=l,this._region1.texExtent.height=1),i.push(new this._bufferViewCtor(e,h*this._formatSize,l*this._channels)),r.push(this._region1),a=0,o+=this._region1.texExtent.height,s-=l,h+=l),s>0&&(this._region2.texOffset.x=a,this._region2.texOffset.y=o,this._region2.texExtent.width=s,this._region2.texExtent.height=1,i.push(new this._bufferViewCtor(e,h*this._formatSize,s*this._channels)),r.push(this._region2)),this._device.copyBuffersToTexture(i,t.texture,r)},e._findAvailableSpace=function(t,e){var i=this._chunks[e],r=!1,n=i.start;if(n+t<=i.size)r=!0;else{n=0;for(var s=this._handles.filter((function(t){return t.chunkIdx===e})).sort((function(t,e){return t.start-e.start})),a=0;a<s.length;a++){var o=s[a];if(n+t<=o.start){r=!0;break}n=o.end}!r&&n+t<=i.size&&(r=!0)}return r?n:-1},e._McDonaldAlloc=function(t){t=ff(t,this._alignment);for(var e=0;e<this._chunkCount;++e){var i=this._chunks[e],r=!1,n=i.start;if(n+t<=i.end?r=!0:n>i.end?n+t<=i.size?r=!0:t<=i.end&&(i.start=n=0,r=!0):n===i.end&&(i.start=n=0,i.end=i.size,t<=i.end&&(r=!0)),r){i.start+=t;var s={chunkIdx:e,start:n,end:n+t,texture:i.texture};return this._handles.push(s),s}}var a=Math.sqrt(t/this._formatSize),o=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,_f(a)),l=this._chunks[this.createChunk(o)];l.start+=t;var h={chunkIdx:this._chunkCount,start:0,end:t,texture:l.texture};return this._handles.push(h),h},t}(),Cf=function(){function t(t,e,i){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=i*(1<<e)}return t.prototype.allocateNewChunk=function(){return new ArrayBuffer(this._chunkSize)},t}();!function(t){t[t.UINT32=0]="UINT32",t[t.FLOAT32=1]="FLOAT32",t[t.NEVER=2]="NEVER"}(Af||(Af={}));var xf,wf,Ef=function(){function t(t,e,i,r,n){void 0===n&&(n=8),this._dataType=void 0,this._dataMembers=void 0,this._elementCount=void 0,this._entryBits=void 0,this._stride=void 0,this._entriesPerChunk=void 0,this._entryMask=void 0,this._chunkMask=void 0,this._poolFlag=void 0,this._arrayBuffers=[],this._freeLists=[],this._uint32BufferViews=[],this._float32BufferViews=[],this._hasUint32=!1,this._hasFloat32=!1,this._nativePool=void 0,this._elementCount=r.COUNT,this._entryBits=n,this._dataType=e,this._dataMembers=i,this._stride=4*this._elementCount,this._entriesPerChunk=1<<n,this._entryMask=this._entriesPerChunk-1,this._poolFlag=1<<30,this._chunkMask=~(this._entryMask|this._poolFlag),this._nativePool=new Cf(t,n,this._stride);var s=Af.NEVER,a=!1,o=!1;for(var l in e){if(a=this._hasFloat32,(o=this._hasUint32)&&a)break;s=e[l],a||s!==Af.FLOAT32?o||s!==Af.UINT32||(this._hasUint32=!0):this._hasFloat32=!0}}var e=t.prototype;return e.alloc=function(){for(var t=0;t<this._freeLists.length;t++){var e=this._freeLists[t];if(e.length){var i=e[e.length-1];return e.length--,(t<<this._entryBits)+i+this._poolFlag}}for(var r=this._nativePool.allocateNewChunk(),n=[],s=[],a=[],o=this._hasFloat32,l=this._hasUint32,h=0;h<this._entriesPerChunk;h++)o&&n.push(new Float32Array(r,this._stride*h,this._elementCount)),l&&s.push(new Uint32Array(r,this._stride*h,this._elementCount)),h&&a.push(h);return l&&this._uint32BufferViews.push(s),o&&this._float32BufferViews.push(n),this._freeLists.push(a),this._arrayBuffers.push(r),(t<<this._entryBits)+this._poolFlag},e.getBuffer=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;return(this._hasFloat32?this._float32BufferViews:this._uint32BufferViews)[e][i]},e.getTypedArray=function(t,e){var i=(this._chunkMask&t)>>this._entryBits,r=this._entryMask&t,n=e,s=(this._dataType[e]===Af.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][r],a=this._dataMembers[e];return s.subarray(n,n+a)},e.free=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[e][i].fill(0),this._freeLists[e].push(i)},t}();!function(t){t[t.NODE=0]="NODE",t[t.PASS=1]="PASS",t[t.AABB=2]="AABB",t[t.RENDER2D=3]="RENDER2D"}(xf||(xf={})),function(t){t[t.POSITION=0]="POSITION",t[t.UV=3]="UV",t[t.COLOR=5]="COLOR",t[t.COUNT=9]="COUNT"}(wf||(wf={}));var Bf,Rf=((df={})[wf.POSITION]=Af.FLOAT32,df[wf.UV]=Af.FLOAT32,df[wf.COLOR]=Af.UINT32,df[wf.COUNT]=Af.NEVER,df),Df=((pf={})[wf.POSITION]=wf.UV-wf.POSITION,pf[wf.UV]=wf.COLOR-wf.UV,pf[wf.COLOR]=wf.COUNT-wf.COLOR,pf[wf.COUNT]=1,pf),Mf=new Ef(xf.RENDER2D,Rf,Df,wf);!function(t){t[t.DIRTY_FLAG=0]="DIRTY_FLAG",t[t.LAYER=1]="LAYER",t[t.WORLD_SCALE=2]="WORLD_SCALE",t[t.WORLD_POSITION=5]="WORLD_POSITION",t[t.WORLD_ROTATION=8]="WORLD_ROTATION",t[t.WORLD_MATRIX=12]="WORLD_MATRIX",t[t.LOCAL_SCALE=28]="LOCAL_SCALE",t[t.LOCAL_POSITION=31]="LOCAL_POSITION",t[t.LOCAL_ROTATION=34]="LOCAL_ROTATION",t[t.COUNT=38]="COUNT"}(Bf||(Bf={}));var Pf,If=((mf={})[Bf.DIRTY_FLAG]=Af.UINT32,mf[Bf.LAYER]=Af.UINT32,mf[Bf.WORLD_SCALE]=Af.FLOAT32,mf[Bf.WORLD_POSITION]=Af.FLOAT32,mf[Bf.WORLD_ROTATION]=Af.FLOAT32,mf[Bf.WORLD_MATRIX]=Af.FLOAT32,mf[Bf.LOCAL_SCALE]=Af.FLOAT32,mf[Bf.LOCAL_POSITION]=Af.FLOAT32,mf[Bf.LOCAL_ROTATION]=Af.FLOAT32,mf[Bf.COUNT]=Af.NEVER,mf),Of=((gf={})[Bf.DIRTY_FLAG]=Bf.LAYER-Bf.DIRTY_FLAG,gf[Bf.LAYER]=Bf.WORLD_SCALE-Bf.LAYER,gf[Bf.WORLD_SCALE]=Bf.WORLD_POSITION-Bf.WORLD_SCALE,gf[Bf.WORLD_POSITION]=Bf.WORLD_ROTATION-Bf.WORLD_POSITION,gf[Bf.WORLD_ROTATION]=Bf.WORLD_MATRIX-Bf.WORLD_ROTATION,gf[Bf.WORLD_MATRIX]=Bf.LOCAL_SCALE-Bf.WORLD_MATRIX,gf[Bf.LOCAL_SCALE]=Bf.LOCAL_POSITION-Bf.LOCAL_SCALE,gf[Bf.LOCAL_POSITION]=Bf.LOCAL_ROTATION-Bf.LOCAL_POSITION,gf[Bf.LOCAL_ROTATION]=Bf.COUNT-Bf.LOCAL_ROTATION,gf[Bf.COUNT]=1,gf),Ff=new Ef(xf.NODE,If,Of,Bf);!function(t){t[t.PRIORITY=0]="PRIORITY",t[t.STAGE=1]="STAGE",t[t.PHASE=2]="PHASE",t[t.PRIMITIVE=3]="PRIMITIVE",t[t.BATCHING_SCHEME=4]="BATCHING_SCHEME",t[t.DYNAMIC_STATE=5]="DYNAMIC_STATE",t[t.HASH=6]="HASH",t[t.COUNT=7]="COUNT"}(Pf||(Pf={}));var Lf,kf=((yf={})[Pf.PRIORITY]=Af.UINT32,yf[Pf.STAGE]=Af.UINT32,yf[Pf.PHASE]=Af.UINT32,yf[Pf.PRIMITIVE]=Af.UINT32,yf[Pf.BATCHING_SCHEME]=Af.UINT32,yf[Pf.DYNAMIC_STATE]=Af.UINT32,yf[Pf.HASH]=Af.UINT32,yf[Pf.COUNT]=Af.NEVER,yf),Vf=((vf={})[Pf.PRIORITY]=Pf.STAGE-Pf.PRIORITY,vf[Pf.STAGE]=Pf.PHASE-Pf.STAGE,vf[Pf.PHASE]=Pf.PRIMITIVE-Pf.PHASE,vf[Pf.PRIMITIVE]=Pf.BATCHING_SCHEME-Pf.PRIMITIVE,vf[Pf.BATCHING_SCHEME]=Pf.DYNAMIC_STATE-Pf.BATCHING_SCHEME,vf[Pf.DYNAMIC_STATE]=Pf.HASH-Pf.DYNAMIC_STATE,vf[Pf.HASH]=Pf.COUNT-Pf.HASH,vf[Pf.COUNT]=1,vf),Nf=new Ef(xf.PASS,kf,Vf,Pf);!function(t){t[t.CENTER=0]="CENTER",t[t.HALFEXTENTS=3]="HALFEXTENTS",t[t.COUNT=6]="COUNT"}(Lf||(Lf={}));var Gf=((bf={})[Lf.CENTER]=Af.FLOAT32,bf[Lf.HALFEXTENTS]=Af.FLOAT32,bf[Lf.COUNT]=Af.NEVER,bf),zf=((Sf={})[Lf.CENTER]=Lf.HALFEXTENTS-Lf.CENTER,Sf[Lf.HALFEXTENTS]=Lf.COUNT-Lf.HALFEXTENTS,Sf[Lf.COUNT]=1,Sf),Uf=new Ef(xf.AABB,Gf,zf,Lf);Dr(ms.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),Dr(ms.prototype,"RenderScene.prototype",[{name:"raycastAll",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllModels",suggest:"using intersect.rayModel in geometry"},{name:"raycastSingleModel",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllCanvas",suggest:"using intersect.rayAABB in geometry"},{name:"rayResultCanvas"},{name:"rayResultModels"},{name:"rayResultAll"},{name:"rayResultSingleModel"}]);var Hf={};Dr(Hf,"CameraVisFlags",[{name:"GENERAL"}]),wr(Hf,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:gs.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:gs.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:gs.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:gs.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:gs.BitMask,targetName:"UI_2D"}]),Er.CameraVisFlags=Hf;var Xf={};Dr(Xf,"VisibilityFlags",[{name:"GENERAL"}]),wr(Xf,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:gs.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:gs.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:gs.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:gs.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:gs.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:gs.Enum,targetName:"UI_2D"}]),Er.VisibilityFlags=Xf,wr(ys.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),Dr(rr.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),Dr(pr.prototype,"Shadows.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),Dr(xr.prototype,"SpotLight.prototype",[{name:"aspect"}]);var Wf,jf,Yf,qf=function(t){if(void 0===cf[t]){var e=1<<uf;cf[t]=e,uf+=1}},Kf=Object.freeze({__proto__:null,addStage:qf,scene:el,createIA:function(t,e){if(!e.positions)return console.error("The data must have positions field"),null;for(var i=[],r=e.positions.length/3,n=0;n<r;++n)i.push(e.positions[3*n],e.positions[3*n+1],e.positions[3*n+2]),e.normals&&i.push(e.normals[3*n],e.normals[3*n+1],e.normals[3*n+2]),e.uvs&&i.push(e.uvs[2*n],e.uvs[2*n+1]),e.colors&&i.push(e.colors[3*n],e.colors[3*n+1],e.colors[3*n+2]);var s=[];s.push(new ye(He.ATTR_POSITION,tt.RGB32F)),e.normals&&s.push(new ye(He.ATTR_NORMAL,tt.RGB32F)),e.uvs&&s.push(new ye(He.ATTR_TEX_COORD,tt.RG32F)),e.colors&&s.push(new ye(He.ATTR_COLOR,tt.RGB32F));var a=t.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.DEVICE,4*i.length,4*i.length/r));a.update(new Float32Array(i));var o=null;return e.indices&&(o=t.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,2*e.indices.length,2))).update(new Uint16Array(e.indices)),t.createInputAssembler(new be(s,[a],o))},get RenderQueue(){return lf},get PassStage(){return hf},genHandle:vs,getTypeFromHandle:bs,getBindingFromHandle:Ss,getCountFromHandle:As,getOffsetFromHandle:Ts,customizeType:Cs,type2reader:xs,type2writer:ws,getDefaultFromType:Es,overrideMacros:Bs,get BatchingSchemes(){return Rs},Pass:ys,getDeviceShaderVersion:Ds,programLib:Ms,nearestPOT:_f,TextureBufferPool:Tf,MaterialInstance:Ps,PassInstance:Is,get PoolType(){return xf},NULL_HANDLE:0,get Render2dView(){return wf},Render2dPool:Mf,get NodeView(){return Bf},NodePool:Ff,get PassView(){return Pf},PassPool:Nf,get AABBView(){return Lf},AABBPool:Uf,RenderScene:ms,CameraVisFlags:Hf,VisibilityFlags:Xf});t("renderer",Kf),function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE"}(Wf||(Wf={})),ss(Wf),function(t){t[t.BEVEL=0]="BEVEL",t[t.ROUND=1]="ROUND",t[t.MITER=2]="MITER"}(jf||(jf={})),ss(jf),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"}(Yf||(Yf={})),ss(Yf);var Jf=Math.PI,Zf=Math.min,Qf=Math.max,$f=Math.cos,td=Math.sin,ed=Math.abs,id=Math.sign,rd=.5522847493;function nd(t,e,i,r,n){t.moveTo(e-r,i),t.bezierCurveTo(e-r,i+n*rd,e-r*rd,i+n,e,i+n),t.bezierCurveTo(e+r*rd,i+n,e+r,i+n*rd,e+r,i),t.bezierCurveTo(e+r,i-n*rd,e+r*rd,i-n,e,i-n),t.bezierCurveTo(e-r*rd,i-n,e-r,i-n*rd,e-r,i),t.close()}function sd(t,e,i,r,n,s,a,o,l,h,u){var c,_,f,d,p,m,g,y,v,b,S,A,T,C,x,w;h>10||(p=.5*(s+o),m=.5*(a+l),g=.5*((c=.5*(e+r))+(f=.5*(r+s))),y=.5*((_=.5*(i+n))+(d=.5*(n+a))),((x=ed((r-o)*(C=l-i)-(n-l)*(T=o-e)))+(w=ed((s-o)*C-(a-l)*T)))*(x+w)<t.tessTol*(T*T+C*C)?t.addPoint(o,l,0===u?u|Yf.PT_BEVEL:u):(sd(t,e,i,c,_,g,y,S=.5*(g+(v=.5*(f+p))),A=.5*(y+(b=.5*(d+m))),h+1,0),sd(t,S,A,v,b,p,m,o,l,h+1,u)))}var ad,od,ld,hd,ud,cd,_d,fd,dd,pd,md,gd,yd,vd,bd,Sd,Ad,Td,Cd,xd,wd,Ed,Bd,Rd,Dd,Md,Pd,Id,Od,Fd,Ld,kd,Vd,Nd,Gd,zd,Ud,Hd,Xd,Wd,jd,Yd,qd,Kd,Jd,Zd,Qd,$d,tp,ep,ip,rp,np,sp,ap,op,lp,hp,up,cp,_p,fp,dp,pp,mp,gp,yp,vp,bp,Sp,Ap,Tp,Cp,xp=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 on(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}(i),wp=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}(),Ep=function(){function t(t){this.dataOffset=0,this.updatePathOffset=!1,this.pathLength=0,this.pathOffset=0,this.paths=[],this.tessTol=.25,this.distTol=.01,this.fillColor=y.WHITE.clone(),this.lineCap=Wf.BUTT,this.strokeColor=y.BLACK.clone(),this.lineJoin=jf.MITER,this.lineWidth=0,this.pointsOffset=0,this._commandX=0,this._commandY=0,this._points=[],this._renderDataList=[],this._curPath=null,this._comp=void 0,this._comp=t}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,Yf.PT_CORNER),this._commandX=t,this._commandY=e},e.lineTo=function(t,e){this.addPoint(t,e,Yf.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?(sd(this,o.x,o.y,t,e,i,r,n,s,0,Yf.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,d=0,p=0,m=0,g=0,y=0,v=0,b=0,S=0,A=0;if(u=s-n,a=a||!1)if(ed(u)>=2*Jf)u=2*Jf;else for(;u<0;)u+=2*Jf;else if(ed(u)>=2*Jf)u=2*-Jf;else for(;u>0;)u-=2*Jf;for(l=0|Qf(1,Zf(ed(u)/(.5*Jf)+.5,5)),c=ed(4/3*(1-$f(o=u/l/2))/td(o)),a||(c=-c),A=0;A<=l;A++)d=e+(_=$f(h=n+u*(A/l)))*r,p=i+(f=td(h))*r,m=-f*r*c,g=_*r*c,0===A?t.moveTo(d,p):t.bezierCurveTo(y+b,v+S,d-m,p-g,d,p),y=d,v=p,b=m,S=g}(this,t,e,i,r,n,s)},e.ellipse=function(t,e,i,r){nd(this,t,e,i,r),this._curPath.complex=!1},e.circle=function(t,e,i){nd(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=Zf(s,.5*ed(r))*id(r),o=Zf(s,.5*ed(n))*id(n);t.moveTo(e,i+o),t.lineTo(e,i+n-o),t.bezierCurveTo(e,i+n-o*(1-rd),e+a*(1-rd),i+n,e+a,i+n),t.lineTo(e+r-a,i+n),t.bezierCurveTo(e+r-a*(1-rd),i+n,e+r,i+n-o*(1-rd),e+r,i+n-o),t.lineTo(e+r,i+o),t.bezierCurveTo(e+r,i+o*(1-rd),e+r-a*(1-rd),i,e+r-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-rd),i,e,i+o*(1-rd),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&&(Ic.remove(r),r.removeRenderDrawInfo(this._comp))}this._renderDataList.length=0},e.close=function(){this._curPath.closed=!0},e.requestRenderData=function(){var t=Ic.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 xp(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 wp,this.paths.push(e)),this.pathLength++,this._curPath=e,e},t}(),Bp=Cu.concat([new ye("a_dist",tt.R32F)]),Rp=Eu(Bp),Dp=Bu(Bp),Mp=function(e){return t({Graphics:e,GraphicsComponent:e}),e}((ad=En("cc.Graphics"),od=Qn(),ld=$n(110),hd=ts(),ud=is(),cd=Wn(jf),_d=is(),fd=Wn(Wf),dd=is(),pd=is(),md=is(),gd=is(),yd=cs(),ad(vd=od(vd=ld(vd=hd((Bd=Ed=function(t){function e(){var e;return(e=t.call(this)||this).impl=null,e.model=null,Mn(e,"_lineWidth",Sd,Pn(e)),Mn(e,"_strokeColor",Ad,Pn(e)),Mn(e,"_lineJoin",Td,Pn(e)),Mn(e,"_lineCap",Cd,Pn(e)),Mn(e,"_fillColor",xd,Pn(e)),Mn(e,"_miterLimit",wd,Pn(e)),e._isDrawing=!1,e._isNeedUploadData=!0,e._graphicsUseSubMeshes=[],e._instanceMaterialType=Ec.ADD_COLOR,e.impl=new Ep(Pn(e)),e}on(e,t);var i=e.prototype;return i.onRestore=function(){this.impl||this._flushAssembler()},i.onLoad=function(){t.prototype.onLoad.call(this),this.model=Kr.root.createModel(sr),this.model.node=this.model.transform=this.node,this._flushAssembler()},i._postRender=function(t){this._postAssembler&&t.commitComp(this,null,null,this._postAssembler,null)},i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMtlForGraphics()},i.onDestroy=function(){this._sceneGetter=null,this.model&&(Kr.root.destroyModel(this.model),this.model=null);var e=this._graphicsUseSubMeshes.length;if(e>0){for(var i=0;i<e;++i)this._graphicsUseSubMeshes[i].destroy();this._graphicsUseSubMeshes.length=0}this.impl&&(this._isDrawing=!1,this.impl.clear(),this.impl=null),t.prototype.onDestroy.call(this)},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=os.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=Ci.gfxDevice,i=e.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.DEVICE,65535*Dp,Dp)),r=e.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,131070*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),n=new Bn([i],Bp,wt.TRIANGLE_LIST,r);n.subMeshIdx=0,this.model.initSubModel(t,n,this.getMaterialInstance(0)),this._graphicsUseSubMeshes.push(n)}}else Rn(4500,this.node.name)},i._uploadData=function(){var t=this.impl;if(t){var e=t&&t.getRenderDataList();if(!(e.length<=0)&&this.model){for(var i=this.model.subModels,r=0;r<e.length;r++){var n=e[r],s=i[r].inputAssembler;if(n.lastFilledVertex!==n.vertexStart){var a=new Float32Array(n.vData.buffer,0,n.vertexStart*Rp);s.vertexBuffers[0].update(a),s.vertexCount=n.vertexStart;var o=new Uint16Array(n.iData.buffer,0,n.indexStart);s.indexBuffer.update(o),s.indexCount=n.indexStart,n.lastFilledVertex=n.vertexStart,n.lastFilledIndex=n.indexStart}}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)}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},i.updateRenderer=function(){t.prototype.updateRenderer.call(this)},i.createRenderEntity=function(){return new Bc(zu.DYNAMIC)},Ur(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(){}},{key:"graphicsNativeProxy",get:function(){return this._graphicsNativeProxy}}]),e}(af),Ed.LineJoin=jf,Ed.LineCap=Wf,Dn((bd=Bd).prototype,"lineWidth",[Un,ud],Object.getOwnPropertyDescriptor(bd.prototype,"lineWidth"),bd.prototype),Dn(bd.prototype,"lineJoin",[cd,_d],Object.getOwnPropertyDescriptor(bd.prototype,"lineJoin"),bd.prototype),Dn(bd.prototype,"lineCap",[fd,dd],Object.getOwnPropertyDescriptor(bd.prototype,"lineCap"),bd.prototype),Dn(bd.prototype,"strokeColor",[pd],Object.getOwnPropertyDescriptor(bd.prototype,"strokeColor"),bd.prototype),Dn(bd.prototype,"fillColor",[md],Object.getOwnPropertyDescriptor(bd.prototype,"fillColor"),bd.prototype),Dn(bd.prototype,"miterLimit",[gd],Object.getOwnPropertyDescriptor(bd.prototype,"miterLimit"),bd.prototype),Dn(bd.prototype,"color",[Hn,yd],Object.getOwnPropertyDescriptor(bd.prototype,"color"),bd.prototype),Sd=Dn(bd.prototype,"_lineWidth",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Ad=Dn(bd.prototype,"_strokeColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.BLACK.clone()}}),Td=Dn(bd.prototype,"_lineJoin",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jf.MITER}}),Cd=Dn(bd.prototype,"_lineCap",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wf.BUTT}}),xd=Dn(bd.prototype,"_fillColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),wd=Dn(bd.prototype,"_miterLimit",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),vd=bd))||vd)||vd)||vd)||vd));Er.Graphics=Mp,function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED",t[t.FILLED=3]="FILLED"}(Sp||(Sp={})),ss(Sp),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.RADIAL=2]="RADIAL"}(Ap||(Ap={})),ss(Ap),function(t){t[t.CUSTOM=0]="CUSTOM",t[t.TRIMMED=1]="TRIMMED",t[t.RAW=2]="RAW"}(Tp||(Tp={})),ss(Tp),function(t){t.SPRITE_FRAME_CHANGED="spriteframe-changed"}(Cp||(Cp={}));var Pp,Ip,Op,Fp,Lp,kp,Vp,Np,Gp,zp,Up,Hp,Xp,Wp,jp,Yp,qp,Kp,Jp,Zp,Qp,$p,tm,em,im=function(e){return t({Sprite:e,SpriteComponent:e}),e}((Rd=En("cc.Sprite"),Dd=Qn(),Md=$n(110),Pd=ts(),Id=Wn(Dh),Od=es(),Fd=is(),Ld=Wn(Bh),kd=es(),Vd=is(),Nd=Wn(Sp),Gd=es(),zd=is(),Ud=Wn(Ap),Hd=es(),Xd=is(),Wd=es(),jd=is(),Yd=Ls(),qd=es(),Kd=is(),Jd=Ls(),Zd=es(),Qd=is(),$d=cs(),tp=es(),ep=is(),ip=es(),rp=is(),np=Wn(Tp),sp=es(),ap=is(),Rd(op=Dd(op=Md(op=Pd((bp=vp=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,Mn(e,"_spriteFrame",hp,Pn(e)),Mn(e,"_type",up,Pn(e)),Mn(e,"_fillType",cp,Pn(e)),Mn(e,"_sizeMode",_p,Pn(e)),Mn(e,"_fillCenter",fp,Pn(e)),Mn(e,"_fillStart",dp,Pn(e)),Mn(e,"_fillRange",pp,Pn(e)),Mn(e,"_isTrimmedMode",mp,Pn(e)),Mn(e,"_useGrayscale",gp,Pn(e)),Mn(e,"_atlas",yp,Pn(e)),e}on(e,t);var i=e.prototype;return i.__preload=function(){this.changeMaterialForDefine(),t.prototype.__preload.call(this)},i.onEnable=function(){t.prototype.onEnable.call(this),this._activateMaterial();var e=this._spriteFrame;e&&(this._updateUVs(),this._type===Sp.SLICED&&e.on(Bh.EVENT_UV_UPDATED,this._updateUVs,this))},i.onDisable=function(){t.prototype.onDisable.call(this),this._spriteFrame&&this._type===Sp.SLICED&&this._spriteFrame.off(Bh.EVENT_UV_UPDATED,this._updateUVs,this)},i.onDestroy=function(){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 fs){var r=t.getPixelFormat();i=r===_n.RGBA_ETC1||r===_n.RGB_A_PVRTC_4BPPV1||r===_n.RGB_A_PVRTC_2BPPV1}i&&this.grayscale?this._instanceMaterialType=Ec.USE_ALPHA_SEPARATED_AND_GRAY:i?this._instanceMaterialType=Ec.USE_ALPHA_SEPARATED:this.grayscale?this._instanceMaterialType=Ec.GRAYSCALE:this._instanceMaterialType=Ec.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 Os){var i=Fs({SAMPLE_FROM_RT:!0},e.passes[0].defines),r=new cn;r.initialize({effectAsset:e.effectAsset,defines:i}),e=r}return e},i._render=function(t){t.commitComp(this,this.renderData,this._spriteFrame,this._assembler,null)},i._canRender=function(){if(!t.prototype._canRender.call(this))return!1;var e=this._spriteFrame;return!(!e||!e.texture)},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.spriteFrame&&this._assembler.updateUVs(this),this._updateColor()),this._spriteFrame&&(this._type===Sp.SLICED?this._spriteFrame.on(Bh.EVENT_UV_UPDATED,this._updateUVs,this):this._spriteFrame.off(Bh.EVENT_UV_UPDATED,this._updateUVs,this))},i._postRender=function(t){this._postAssembler&&t.commitComp(this,null,null,this._postAssembler,null)},i._applySpriteSize=function(){if(this._spriteFrame)if(Tp.RAW===this._sizeMode){var t=this._spriteFrame.originalSize;this.node._uiProps.uiTransformComp.setContentSize(t)}else if(Tp.TRIMMED===this._sizeMode){var e=this._spriteFrame.rect;this.node._uiProps.uiTransformComp.setContentSize(e.width,e.height)}},i._resized=function(){},i._activateMaterial=function(){var t=this._spriteFrame,e=this.getRenderMaterial(0);t&&e&&this.markForUpdateRenderData(),this.renderData&&(this.renderData.material=e)},i._updateUVs=function(){this._assembler&&this._assembler.updateUVs(this)},i._applySpriteFrame=function(t){var e=this._spriteFrame;t&&this._type===Sp.SLICED&&t.off(Bh.EVENT_UV_UPDATED,this._updateUVs,this);var i=!1;e&&(t&&t.texture===e.texture||(i=!0),i&&(this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine()),this._applySpriteSize(),this._type===Sp.SLICED&&e.on(Bh.EVENT_UV_UPDATED,this._updateUVs,this))},Ur(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(),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===Ap.RADIAL||this._fillType===Ap.RADIAL?this.destroyRenderData():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===Sp.FILLED&&this.renderData&&this.markForUpdateRenderData()}},{key:"fillStart",get:function(){return this._fillStart},set:function(t){this._fillStart=T(t,0,1),this._type===Sp.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"fillRange",get:function(){return this._fillRange},set:function(t){this._fillRange=T(t,-1,1),this._type===Sp.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"trim",get:function(){return this._isTrimmedMode},set:function(t){this._isTrimmedMode!==t&&(this._isTrimmedMode=t,this._type===Sp.SIMPLE&&this.renderData&&this.markForUpdateRenderData(!0))}},{key:"grayscale",get:function(){return this._useGrayscale},set:function(t){this._useGrayscale!==t&&(this._useGrayscale=t,this.changeMaterialForDefine(),this.updateMaterial())}},{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,t!==Tp.CUSTOM&&this._applySpriteSize())}}]),e}(af),vp.FillType=Ap,vp.Type=Sp,vp.SizeMode=Tp,vp.EventType=Cp,Dn((lp=bp).prototype,"spriteAtlas",[Id,Od,Fd],Object.getOwnPropertyDescriptor(lp.prototype,"spriteAtlas"),lp.prototype),Dn(lp.prototype,"spriteFrame",[Ld,kd,Vd],Object.getOwnPropertyDescriptor(lp.prototype,"spriteFrame"),lp.prototype),Dn(lp.prototype,"type",[Nd,Gd,zd],Object.getOwnPropertyDescriptor(lp.prototype,"type"),lp.prototype),Dn(lp.prototype,"fillType",[Ud,Hd,Xd],Object.getOwnPropertyDescriptor(lp.prototype,"fillType"),lp.prototype),Dn(lp.prototype,"fillCenter",[Wd,jd],Object.getOwnPropertyDescriptor(lp.prototype,"fillCenter"),lp.prototype),Dn(lp.prototype,"fillStart",[Yd,qd,Kd],Object.getOwnPropertyDescriptor(lp.prototype,"fillStart"),lp.prototype),Dn(lp.prototype,"fillRange",[Jd,Zd,Qd],Object.getOwnPropertyDescriptor(lp.prototype,"fillRange"),lp.prototype),Dn(lp.prototype,"trim",[$d,tp,ep],Object.getOwnPropertyDescriptor(lp.prototype,"trim"),lp.prototype),Dn(lp.prototype,"grayscale",[Un,ip,rp],Object.getOwnPropertyDescriptor(lp.prototype,"grayscale"),lp.prototype),Dn(lp.prototype,"sizeMode",[np,sp,ap],Object.getOwnPropertyDescriptor(lp.prototype,"sizeMode"),lp.prototype),hp=Dn(lp.prototype,"_spriteFrame",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),up=Dn(lp.prototype,"_type",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Sp.SIMPLE}}),cp=Dn(lp.prototype,"_fillType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ap.HORIZONTAL}}),_p=Dn(lp.prototype,"_sizeMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Tp.TRIMMED}}),fp=Dn(lp.prototype,"_fillCenter",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(0,0)}}),dp=Dn(lp.prototype,"_fillStart",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pp=Dn(lp.prototype,"_fillRange",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),mp=Dn(lp.prototype,"_isTrimmedMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),gp=Dn(lp.prototype,"_useGrayscale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),yp=Dn(lp.prototype,"_atlas",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),op=lp))||op)||op)||op)||op));Er.Sprite=im;var rm,nm=new c,sm=new i,am=new c,om=[];!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"}(rm||(rm={})),ss(rm);var lm=function(e){return t({Mask:e,MaskComponent:e}),e}((Pp=En("cc.Mask"),Ip=Qn(),Op=$n(110),Fp=ts(),Lp=Wn(rm),kp=is(),Vp=es(),Np=is(),Gp=cs(),zp=Wn(Bh),Up=cs(),Hp=cs(),Xp=Ls(),Wp=cs(),jp=cs(),Pp(Yp=Ip(Yp=Op(Yp=Fp((em=tm=function(t){function e(){var e;return(e=t.call(this)||this)._clearStencilMtl=null,e._clearModel=null,Mn(e,"_type",Kp,Pn(e)),Mn(e,"_inverted",Jp,Pn(e)),Mn(e,"_segments",Zp,Pn(e)),Mn(e,"_spriteFrame",Qp,Pn(e)),Mn(e,"_alphaThreshold",$p,Pn(e)),e._sprite=null,e._graphics=null,e._maskNode=null,e._clearModelMesh=null,e._instanceMaterialType=Ec.ADD_COLOR,e}on(e,t);var r=e.prototype;return r.onLoad=function(){t.prototype.onLoad.call(this),this._createClearModel(),this._changeRenderType()},r.onEnable=function(){t.prototype.onEnable.call(this),this._updateGraphics(),this._enableGraphics(),this._changeRenderType(),this.node.on(Zn.SIZE_CHANGED,this._sizeChange,this),this.node.on(Zn.ANCHOR_CHANGED,this._anchorChange,this),this.node.on(Zn.SIBLING_ORDER_CHANGED,this._siblingChange,this),this.node.on(Zn.LAYER_CHANGED,this._layerChange,this),this._sizeChange(),this._siblingChange(),this._layerChange()},r.onRestore=function(){this._changeRenderType(),t.prototype.updateMaterial.call(this),this._updateGraphics(),this.markForUpdateRenderData()},r.onDisable=function(){t.prototype.onDisable.call(this),this._disableGraphics(),this.node.off(Zn.SIZE_CHANGED,this._sizeChange,this),this.node.off(Zn.ANCHOR_CHANGED,this._anchorChange,this),this.node.off(Zn.SIBLING_ORDER_CHANGED,this._siblingChange,this),this.node.off(Zn.LAYER_CHANGED,this._layerChange,this)},r.onDestroy=function(){this._clearModel&&this._clearModelMesh&&(Kr.root.destroyModel(this._clearModel),this._clearModelMesh.destroy()),this._clearStencilMtl&&this._clearStencilMtl.destroy(),this._removeMaskNode(),t.prototype.onDestroy.call(this)},r.isHit=function(t){var e=this.node._uiProps.uiTransformComp,r=e.contentSize,n=r.width,s=r.height,a=sm;this.node.getWorldMatrix(nm),c.invert(am,nm),i.transformMat4(a,t,am);var o=e.anchorPoint;a.x+=o.x*n,a.y+=o.y*s;var l=!1;if(this.type===rm.RECT||this.type===rm.GRAPHICS_STENCIL||this.type===rm.IMAGE_STENCIL)l=a.x>=0&&a.y>=0&&a.x<=n&&a.y<=s;else if(this.type===rm.ELLIPSE){var h=n/2,u=s/2,_=a.x-.5*n,f=a.y-.5*s;l=_*_/(h*h)+f*f/(u*u)<1}return this._inverted&&(l=!l),l},r._render=function(t){t.commitComp(this,this.renderData,null,this._assembler,null)},r._postRender=function(t){this._postAssembler&&t.commitComp(this,null,null,this._postAssembler,null)},r._nodeStateChange=function(e){t.prototype._nodeStateChange.call(this,e),this._updateGraphics()},r._canRender=function(){return!!t.prototype._canRender.call(this)&&(this._type!==rm.IMAGE_STENCIL?null!==this._graphics:null!==this._sprite&&null!==this._spriteFrame)},r._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()},r._changeRenderType=function(){this._type!==rm.IMAGE_STENCIL?this._createGraphics():this._createSprite()},r._initSpriteNode=function(){var t=new ks("MASK_CHILD");t.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy,t.addComponent(im),t.setPosition(0,0,0),t.layer=this.node.layer,this._maskNode=t,this.node.insertChild(t,0)},r._sizeChange=function(){this._sprite&&this._maskNode._uiProps.uiTransformComp.setContentSize(this.node._uiProps.uiTransformComp.contentSize)},r._anchorChange=function(){this._sprite&&this._maskNode._uiProps.uiTransformComp.setAnchorPoint(this.node._uiProps.uiTransformComp.anchorPoint)},r._siblingChange=function(){this._maskNode&&0!==this._maskNode.getSiblingIndex()&&this._maskNode.setSiblingIndex(0)},r._layerChange=function(){this._maskNode&&(this._maskNode.layer=this.node.layer)},r._createSprite=function(){if(!this._sprite){this._initSpriteNode();var t=this._sprite=this._maskNode.getComponent(im);t.color=y.WHITE.clone(),t._postAssembler=e.ChildPostAssembler.getAssembler(this),t.sizeMode=0,this._sizeChange(),this._anchorChange()}this._sprite.spriteFrame=this._spriteFrame,this._updateMaterial()},r._initGraphicsNode=function(){var t=new ks("MASK_CHILD");t.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy,t.addComponent(Mp),t.setPosition(0,0,0),t.layer=this.node.layer,this._maskNode=t,this.node.insertChild(t,0)},r._createGraphics=function(){if(!this._graphics){this._initGraphicsNode();var t=this._graphics=this._maskNode.getComponent(Mp);t._objFlags|=Vs.Flags.IsOnLoadCalled,t.node.getWorldMatrix(),t.lineWidth=0;var i=y.WHITE.clone();i.a=0,t.fillColor=i,t._postAssembler=e.ChildPostAssembler.getAssembler(this)}this.node.insertChild(this._maskNode,0),this._updateMaterial()},r._updateGraphics=function(){if(this._graphics&&(this._type===rm.RECT||this._type===rm.ELLIPSE)){var t=this.node._uiProps.uiTransformComp,e=this._graphics;e.clear();var i=t.contentSize,r=i.width,s=i.height,a=t.anchorPoint,o=-r*a.x,l=-s*a.y;if(this._type===rm.RECT)e.rect(o,l,r,s);else if(this._type===rm.ELLIPSE){for(var h=function(t,e,i){om.length=0;for(var r=2*Math.PI/i,s=0;s<i;++s)om.push(new n(e.x*Math.cos(r*s)+t.x,e.y*Math.sin(r*s)+t.y,0));return om}(new n(o+r/2,l+s/2,0),new n(r/2,s/2,0),this._segments),u=0;u<h.length;++u){var c=h[u];0===u?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y)}e.close()}e.fill()}},r._createClearModel=function(){if(!this._clearModel){var t=os.get("default-clear-stencil");this._clearStencilMtl=new Ps({parent:t,owner:this,subModelIdx:0}),this._clearModel=Kr.root.createModel(sr),this._clearModel.node=this._clearModel.transform=this.node;var e=Bu(Tu),i=Ci.gfxDevice,r=i.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.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 ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),a=new Uint16Array([0,1,2,2,1,3]);s.update(a),this._clearModelMesh=new Bn([r],Tu,wt.TRIANGLE_LIST,s),this._clearModelMesh.subMeshIdx=0,this._clearModel.initSubModel(0,this._clearModelMesh,this._clearStencilMtl)}},r._updateBuiltinMaterial=function(){return os.get("default-clear-stencil")},r._updateMaterial=function(){if(this._graphics){var t=this._graphics;t.stencilStage=Vu.DISABLED;var e=os.get("ui-graphics-material");t.setMaterial(e,0),t.getMaterialInstance(0)}else if(this._sprite){var i=this._sprite;i.stencilStage=Vu.DISABLED;var r=os.get("ui-alpha-test-material");i.setMaterial(r,0),(r=i.getMaterialInstance(0)).setProperty("alphaThreshold",this._alphaThreshold)}},r._enableGraphics=function(){this.subComp&&(this.subComp.enabled=!0)},r._disableGraphics=function(){this.subComp&&(this.subComp.enabled=!1)},r._removeMaskNode=function(){this._maskNode&&this._maskNode.isValid&&(this._maskNode.destroy(),this._sprite=null,this._graphics=null)},r._useRenderData=function(){this.renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData())},r.createRenderEntity=function(){return new Bc(zu.DYNAMIC)},Ur(e,[{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this.markForUpdateRenderData(!1),this._updateMaterial(),this._type!==rm.IMAGE_STENCIL?(this._sprite&&(this._sprite=null),this._spriteFrame=null,this._maskNode.parent=null,this._changeRenderType(),this._updateGraphics()):(this._graphics&&(this._graphics.clear(),this._graphics=null),this._maskNode.parent=null,this._changeRenderType()))}},{key:"inverted",get:function(){return this._inverted},set:function(t){this._inverted=t,this.stencilStage=Vu.DISABLED,this._graphics?this._graphics.stencilStage=Vu.DISABLED:this._sprite&&(this._sprite.stencilStage=Vu.DISABLED)}},{key:"segments",get:function(){return this._segments},set:function(t){this._segments!==t&&(this._segments=T(t,3,1e4),this._updateGraphics())}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame=t,this._sprite&&(this._sprite.spriteFrame=t),this._updateMaterial())}},{key:"alphaThreshold",get:function(){return this._alphaThreshold},set:function(t){this._alphaThreshold!==t&&(this._alphaThreshold=t,this.type===rm.IMAGE_STENCIL&&this._sprite&&this._sprite.getMaterialInstance(0).setProperty("alphaThreshold",this._alphaThreshold))}},{key:"subComp",get:function(){return this._graphics||this._sprite}},{key:"color",get:function(){return this._color},set:function(t){this.color=t}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(){}}]),e}(af),tm.ChildPostAssembler=null,tm.Type=rm,Dn((qp=em).prototype,"type",[Lp,kp],Object.getOwnPropertyDescriptor(qp.prototype,"type"),qp.prototype),Dn(qp.prototype,"inverted",[Vp,Np],Object.getOwnPropertyDescriptor(qp.prototype,"inverted"),qp.prototype),Dn(qp.prototype,"segments",[Gp],Object.getOwnPropertyDescriptor(qp.prototype,"segments"),qp.prototype),Dn(qp.prototype,"spriteFrame",[zp,Up],Object.getOwnPropertyDescriptor(qp.prototype,"spriteFrame"),qp.prototype),Dn(qp.prototype,"alphaThreshold",[Hp,Xp,Ns],Object.getOwnPropertyDescriptor(qp.prototype,"alphaThreshold"),qp.prototype),Dn(qp.prototype,"color",[Hn,Wp],Object.getOwnPropertyDescriptor(qp.prototype,"color"),qp.prototype),Dn(qp.prototype,"customMaterial",[Hn,jp],Object.getOwnPropertyDescriptor(qp.prototype,"customMaterial"),qp.prototype),Kp=Dn(qp.prototype,"_type",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return rm.RECT}}),Jp=Dn(qp.prototype,"_inverted",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Zp=Dn(qp.prototype,"_segments",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),Qp=Dn(qp.prototype,"_spriteFrame",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),$p=Dn(qp.prototype,"_alphaThreshold",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),Yp=qp))||Yp)||Yp)||Yp)||Yp));Gs._maskComp=lm,Er.Mask=lm;var hm,um,cm,_m,fm,dm,pm,mm,gm,ym,vm,bm,Sm,Am=/^(click)(\s)*=|(param)(\s)*=/,Tm=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,Cm=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="",o=-1;if((i=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(t))&&i[0].length>0&&(r=i[0].trim()).startsWith("img")&&"/"===r[r.length-1]){var l;i=Tm.exec(t);for(var h=!1;i;){var u=(r=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length)).length;if(r=(r=r.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),a=t.substring(u).trim(),o="src"===r?this.getRightQuotationIndex(a):-1,l=(n=a.indexOf(" ",o+1>=a.length?-1:o+1))>-1?a.substr(0,n):a,t=a.substring(n).trim(),l.endsWith("/")&&(l=l.slice(0,-1)),"src"===r){switch(l.charCodeAt(0)){case 34:case 39:h=!0,l=l.slice(1,-1)}e.isImage=!0,e.src=l}else if("height"===r)e.imageHeight=parseInt(l);else if("width"===r)e.imageWidth=parseInt(l);else if("align"===r){switch(l.charCodeAt(0)){case 34:case 39:l=l.slice(1,-1)}e.imageAlign=l.toLowerCase()}else"offset"===r?e.imageOffset=l:"click"===r&&(e.event=this._processEventHandler(r+"="+l));e.event&&"param"===r&&(e.event[r]=l.replace(/^"|"$/g,"")),i=Tm.exec(t)}return h&&e.isImage&&this._resultObjectArray.push({text:"",style:e}),{}}if(i=/^(outline(\s)*[^>]*)/.exec(t)){var c={color:"#ffffff",width:1};if(t=i[0].substring("outline".length).trim()){var _,f=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=f.exec(t);i;)r=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),_=(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+"="+_):"color"===r?c.color=_:"width"===r&&(c.width=parseInt(_)),e.event&&"param"===r&&(e.event[r]=_.replace(/^"|"$/g,"")),i=f.exec(t)}e.outline=c}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.getRightQuotationIndex=function(t){var e=-1,i=-1,r=t.indexOf("'"),n=t.indexOf('"'),s=n>-1&&(n<r||-1===r);return r>-1&&(r<n||-1===n)?(e=r,i=t.indexOf("'",e+1>=t.length?-1:e+1)):s&&(e=n,i=t.indexOf('"',e+1>=t.length?-1:e+1)),i},e._processEventHandler=function(t){for(var e={},i=0,r=!1,n=Am.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=Am.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=hn(this._specialSymbolArray);!(e=i()).done;){var r=e.value,n=r[0],s=r[1];t=t.replace(n,s)}return t},t}()),xm=function(e){return t({LabelOutline:e,LabelOutlineComponent:e}),e}((hm=En("cc.LabelOutline"),um=Qn(),cm=$n(110),_m=ts(),fm=us(of),dm=is(),pm=is(),hm(mm=um(mm=cm(mm=_m(mm=fm(mm=Jn((bm=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,Mn(e,"_color",ym,Pn(e)),Mn(e,"_width",vm,Pn(e)),e}on(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(of);t&&t.updateRenderData(!0)},Ur(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}(ns),ym=Dn((gm=bm).prototype,"_color",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(0,0,0,255)}}),vm=Dn(gm.prototype,"_width",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),Dn(gm.prototype,"color",[dm],Object.getOwnPropertyDescriptor(gm.prototype,"color"),gm.prototype),Dn(gm.prototype,"width",[pm],Object.getOwnPropertyDescriptor(gm.prototype,"width"),gm.prototype),mm=gm))||mm)||mm)||mm)||mm)||mm)||mm));Er.LabelOutline=xm;var wm,Em,Bm,Rm,Dm,Mm,Pm,Im,Om,Fm,Lm,km,Vm,Nm,Gm=t("RenderRoot2D",En("cc.RenderRoot2D")(Sm=$n(100)(Sm=ts()(Sm=us(Uc)(Sm=Kn(Sm=Jn(Sm=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.onEnable=function(){Er.director.root.batcher2D.addScreen(this)},i.onDisable=function(){Er.director.root.batcher2D.removeScreen(this)},i.onDestroy=function(){Er.director.root.batcher2D.removeScreen(this)},e}(ns))||Sm)||Sm)||Sm)||Sm)||Sm)||Sm),zm=new n,Um=zs({OVERLAY:0,INTERSPERSE:1}),Hm=function(e){return t({Canvas:e,CanvasComponent:e}),e}((wm=En("cc.Canvas"),Em=Qn(),Bm=$n(100),Rm=ts(),Dm=Wn(Us),Mm=is(),Pm=is(),Im=Wn(Us),wm(Om=Em(Om=Bm(Om=Rm(Om=Jn(Om=Kn((Vm=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_cameraComponent",Lm,Pn(e)),Mn(e,"_alignCanvasWithScreen",km,Pn(e)),e._thisOnCameraResized=void 0,e._fitDesignResolution=void 0,e._pos=new n,e._renderMode=Um.OVERLAY,e._thisOnCameraResized=e._onResizeCamera.bind(Pn(e)),e}on(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._cameraComponent.node.on(Us.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)),this._onResizeCamera(),this.node.on(Zn.TRANSFORM_CHANGED,this._thisOnCameraResized)},i.onEnable=function(){t.prototype.onEnable.call(this),this._cameraComponent&&this._cameraComponent.node.on(Us.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDisable=function(){t.prototype.onDisable.call(this),this._cameraComponent&&this._cameraComponent.node.off(Us.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.node.off(Zn.TRANSFORM_CHANGED,this._thisOnCameraResized)},i._onResizeCamera=function(){if(this._cameraComponent&&this._alignCanvasWithScreen){if(this._cameraComponent.targetTexture)this._cameraComponent.orthoHeight=rs.height/2;else{var t=Xs.windowSize;this._cameraComponent.orthoHeight=t.height/Hs.getScaleY()/2}this.node.getWorldPosition(zm),this._cameraComponent.node.setWorldPosition(zm.x,zm.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===Um.OVERLAY?e|1<<30:e&~(1<<30)}return 0},Ur(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}(Gm),Dn((Fm=Vm).prototype,"cameraComponent",[Dm,Mm],Object.getOwnPropertyDescriptor(Fm.prototype,"cameraComponent"),Fm.prototype),Dn(Fm.prototype,"alignCanvasWithScreen",[Pm],Object.getOwnPropertyDescriptor(Fm.prototype,"alignCanvasWithScreen"),Fm.prototype),Lm=Dn(Fm.prototype,"_cameraComponent",[Im],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),km=Dn(Fm.prototype,"_alignCanvasWithScreen",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Om=Fm))||Om)||Om)||Om)||Om)||Om)||Om));Er.Canvas=Hm;var Xm,Wm,jm,Ym,qm,Km,Jm,Zm,Qm,$m,tg,eg,ig,rg,ng,sg,ag=t("UIComponent",En("cc.UIComponent")(Nm=us(Uc)(Nm=$n(110)(Nm=Kn(Nm=Jn(Nm=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=Vu.DISABLED,e}on(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.postUpdateAssembler=function(){},i.markForUpdateRenderData=function(){},i.setNodeDirty=function(){},i.setTextureDirty=function(){},e}(ns))||Nm)||Nm)||Nm)||Nm)||Nm);Dr(ag.prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),Dr(af.prototype,"Renderable2D.prototype",[{name:"srcBlendFactor"},{name:"dstBlendFactor"}]),wr(Hm.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:y.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}}]),Pr(Uc.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),Er.UITransformComponent=Uc,pn.setClassAlias(Uc,"cc.UITransformComponent"),pn.setClassAlias(af,"cc.RenderComponent"),Er.CanvasComponent=Hm,pn.setClassAlias(Hm,"cc.CanvasComponent"),Er.internal.Renderable2D=af,pn.setClassAlias(af,"cc.Renderable2D"),function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED"}(sg||(sg={})),t("SpriteRenderer",(Xm=En("cc.SpriteRenderer"),Wm=Qn(),jm=$n(100),Ym=ts(),qm=Wn(Bh),Km=cs(),Xm(Jm=Wm(Jm=jm(Jm=Ym(Jm=Jn((ng=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,Mn(e,"_spriteFrame",Qm,Pn(e)),Mn(e,"_mode",$m,Pn(e)),Mn(e,"_color",tg,Pn(e)),Mn(e,"_flipX",eg,Pn(e)),Mn(e,"_flipY",ig,Pn(e)),Mn(e,"_size",rg,Pn(e)),e._model=null,e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._spriteFrame&&(this._spriteFrame.mesh||this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels()},i.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene()},i.onEnable=function(){this._model||this._updateModels(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene()},i.onDestroy=function(){this._model&&(Er.director.root.destroyModel(this._model),this._model=null,this._models.length=0)},i._updateModels=function(){if(this._spriteFrame){var t=this._model;if(t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model){var e=this._spriteFrame.mesh;this._model.createBoundingShape(e.struct.minPosition,e.struct.maxPosition),this._updateModelParams(),this._onUpdateLocalDescriptorSet()}}},i._createModel=function(){var t=this._model=Er.director.root.createModel(sr);t.visFlags=this.visibility,t.node=t.transform=this.node,this._models.length=0,this._models.push(this._model)},i._updateModelParams=function(){if(this._spriteFrame&&this._model){this._spriteFrame.ensureMeshData();var t=this._spriteFrame.mesh;this.node.hasChangedFlags|=Ws.POSITION,this._model.transform.hasChangedFlags|=Ws.POSITION;var e=t?t.renderingSubMeshes.length:0,i=t.renderingSubMeshes;if(i)for(var r=0;r<e;++r){var n=this.getRenderMaterial(r);n&&!n.isValid&&(n=null);var s=i[r];s&&this._model.initSubModel(r,s,n||this._getBuiltinMaterial())}this._model.enabled=!0}},i._getBuiltinMaterial=function(){return os.get("missing-material")},i._onMaterialModified=function(e,i){t.prototype._onMaterialModified.call(this,e,i),this._spriteFrame&&this._model&&this._model.inited&&this._onRebuildPSO(e,i||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.setSubModelMaterial(t,e),this._onUpdateLocalDescriptorSet())},i._onUpdateLocalDescriptorSet=function(){if(this._spriteFrame&&this._model&&this._model.inited)for(var t=this._spriteFrame.getGFXTexture(),e=this._spriteFrame.getGFXSampler(),i=this._model.subModels,r=js.SAMPLER_SPRITE,n=0;n<i.length;n++){var s=i[n].descriptorSet;s.bindTexture(r,t),s.bindSampler(r,e),s.update()}},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)},Ur(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame,this._spriteFrame=t,this._spriteFrame&&(this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels(),this.enabledInHierarchy&&this._attachToScene())}},{key:"model",get:function(){return this._model}}]),e}(Ys),Dn((Zm=ng).prototype,"spriteFrame",[qm],Object.getOwnPropertyDescriptor(Zm.prototype,"spriteFrame"),Zm.prototype),Qm=Dn(Zm.prototype,"_spriteFrame",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),$m=Dn(Zm.prototype,"_mode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sg.SIMPLE}}),tg=Dn(Zm.prototype,"_color",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),eg=Dn(Zm.prototype,"_flipX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),ig=Dn(Zm.prototype,"_flipY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),rg=Dn(Zm.prototype,"_size",[Km,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),Jm=Zm))||Jm)||Jm)||Jm)||Jm)||Jm));var og,lg,hg,ug,cg,_g,fg,dg,pg,mg,gg,yg,vg,bg,Sg,Ag,Tg,Cg,xg,wg,Eg,Bg,Rg,Dg,Mg,Pg,Ig,Og,Fg,Lg,kg,Vg,Ng,Gg,zg,Ug,Hg,Xg,Wg,jg=new Cm,Yg="RICHTEXT_CHILD",qg="RICHTEXT_Image_CHILD",Kg=new Yn((function(t){if(!Er.isValid(t.node))return!1;var e=t.node.getComponent(xm);return e&&(e.width=0),!0}),20),Jg=new Yn((function(t){return Er.isValid(t.node)}),10);function Zg(t){return{node:new ks(t),comp:null,lineCount:0,styleIndex:0,imageOffset:"",clickParam:"",clickHandler:"",type:t}}function Qg(t,e){var i;t===Yg?i=Kg._get():t===qg&&(i=Jg._get());var r=(i=i||Zg(t)).node;return r||(r=new ks(t)),r.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy,t===qg?(i.comp=r.getComponent(im)||r.addComponent(im),i.comp.spriteFrame=e,i.comp.type=im.Type.SLICED,i.comp.sizeMode=im.SizeMode.CUSTOM):(i.comp=r.getComponent(of)||r.addComponent(of),i.comp.string=e,i.comp.horizontalAlign=ef.LEFT,i.comp.verticalAlign=rf.TOP,i.comp.underlineHeight=2),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 $g,ty=function(e){return t({RichText:e,RichTextComponent:e}),e}((og=En("cc.RichText"),lg=Qn(),hg=$n(110),ug=ts(),cg=is(),_g=Wn(ef),fg=is(),dg=Wn(rf),pg=is(),mg=is(),gg=is(),yg=Wn(Fh),vg=is(),bg=is(),Sg=es(),Ag=Wn(sf),Tg=is(),Cg=is(),xg=is(),wg=Wn(Dh),Eg=is(),Bg=is(),og(Rg=lg(Rg=hg(Rg=ug(Rg=Jn((Wg=Xg=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_lineHeight",Mg,Pn(e)),Mn(e,"_string",Pg,Pn(e)),Mn(e,"_horizontalAlign",Ig,Pn(e)),Mn(e,"_verticalAlign",Og,Pn(e)),Mn(e,"_fontSize",Fg,Pn(e)),Mn(e,"_maxWidth",Lg,Pn(e)),Mn(e,"_fontFamily",kg,Pn(e)),Mn(e,"_font",Vg,Pn(e)),Mn(e,"_isSystemFontUsed",Ng,Pn(e)),Mn(e,"_userDefinedFont",Gg,Pn(e)),Mn(e,"_cacheMode",zg,Pn(e)),Mn(e,"_imageAtlas",Ug,Pn(e)),Mn(e,"_handleTouchEvent",Hg,Pn(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._labelChildrenNum=0,e._updateRichTextStatus=e._updateRichText,e}on(e,t);var i=e.prototype;return i.onLoad=function(){this.node.on(Zn.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(Zn.ANCHOR_CHANGED,this._updateRichTextPosition,this)},i.onRestore=function(){},i.onDestroy=function(){for(var t,e=hn(this._segments);!(t=e()).done;){var i=t.value;i.node.removeFromParent(),i.type===Yg?Kg.put(i):i.type===qg&&Jg.put(i)}this.node.off(Zn.ANCHOR_CHANGED,this._updateRichTextPosition,this),this.node.off(Zn.LAYER_CHANGED,this._applyLayer,this)},i._addEventListeners=function(){this.node.on(Zn.TOUCH_END,this._onTouchEnded,this)},i._removeEventListeners=function(){this.node.off(Zn.TOUCH_END,this._onTouchEnded,this)},i._updateLabelSegmentTextAttributes=function(){var t=this;this._segments.forEach((function(e){t._applyTextAttribute(e)}))},i._createFontLabel=function(t){return Qg(Yg,t)},i._createImage=function(t){return Qg(qg,t)},i._onTTFLoaded=function(){this._font,this._layoutDirty=!0,this._updateRichText()},i.SplitLongStringApproximatelyIn2048=function(t,e){var i=[];if(this._calculateSize(e,t).x<2048)i.push(t);else for(var r=t.split("\n"),n=0;n<r.length;n++)if(this._calculateSize(e,r[n]).x<2048)i.push(r[n]);else{var s=this.splitLongStringOver2048(r[n],e);i.push.apply(i,s)}return i},i.splitLongStringOver2048=function(t,e){for(var i=[],r=t,n=0,s=r.length/2,a=r.substring(n,s),o=r.substring(s),l=this._calculateSize(e,a),h=(this._calculateSize(e,o),1*this.maxWidth);l.x>h;){if((s/=2)<1){s*=2;break}a=a.substring(n,s),o=r.substring(s),l=this._calculateSize(e,a)}for(var u=1e3,c=1;u&&n<t.length;){for(;u&&l.x<h;){var _=cu(o);_&&_.length>0&&(c=_[0].length),s+=c,a=r.substring(n,s),o=r.substring(s),l=this._calculateSize(e,a),u--}for(;u&&a.length>=2&&l.x>h;)s-=c,a=r.substring(n,s),l=this._calculateSize(e,a),c=1,u--;if(a.length>=2){var f=_u(a);f&&f.length>0&&a!==f[0]&&(s-=f[0].length,a=r.substring(n,s))}if(i.push(a),n=s,s+=a.length,a=r.substring(n,s),o=r.substring(s),u--,this._calculateSize(e,o).x<2048){n=t.length,s=t.length,a=o,i.push(a);break}l=this._calculateSize(e,a)}return i},i._measureText=function(t,e){var i=this,r=function(e){return i._calculateSize(t,e).width};return e?r(e):r},i._calculateSize=function(t,e){var i;return 0===this._labelSegmentsCache.length?(i=this._createFontLabel(e),this._labelSegmentsCache.push(i)):(i=this._labelSegmentsCache[0]).node.getComponent(of).string=e,i.styleIndex=t,this._applyTextAttribute(i),i.node._uiProps.uiTransformComp.contentSize},i._onTouchEnded=function(t){for(var e,i=this,r=this.node.getComponents(ns),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=hn(this._segments);!(e=s()).done;)n()},i._containsTouchLocation=function(t,e){var i=t.node.getComponent(Uc);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===Yg||i.name===qg){i.parent===this.node?i.parent=null:t.splice(e,1);var r=Zg(i.name);r.node=i,i.name===Yg?(r.comp=i.getComponent(of),Kg.put(r)):(r.comp=i.getComponent(im),Jg.put(r)),this._labelChildrenNum--}}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!==Yg&&i.name!==qg||(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(of);r&&(r.string=t)}var n=i.comp;return n.verticalAlign!==this._verticalAlign&&(n.verticalAlign=this._verticalAlign),i.styleIndex=e,i.lineCount=this._lineCount,i.node._uiProps.uiTransformComp.setAnchorPoint(0,0),i.node.layer=this.node.layer,this.node.insertChild(i.node,this._labelChildrenNum++),this._applyTextAttribute(i),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=fu(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)}e.imageOffset&&(n.imageOffset=e.imageOffset),n.node.layer=this.node.layer,this.node.insertChild(n.node,this._labelChildrenNum++),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 Rn(4400)}},i._updateRichText=function(){if(this.enabledInHierarchy){var t=jg.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=this.SplitLongStringApproximatelyIn2048(s,r).join("\n")).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+Zh)*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(ou(r)||lu(r))return 1;for(var n=1,s=e+1;s<i&&!lu(r=t.charAt(s))&&!ou(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 ef.LEFT:break;case ef.CENTER:h-=this._linesWidth[l-1]/2;break;case ef.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(im)){var c=o.node.position.clone(),_=this._lineHeight,f=this._lineHeight*(1+Zh);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 d=o.imageOffset.split(",");if(1===d.length&&d[0]){var p=parseFloat(d[0]);Number.isInteger(p)&&(c.y+=p)}else if(2===d.length){var m=parseFloat(d[0]),g=parseFloat(d[1]);Number.isInteger(m)&&(c.x+=m),Number.isInteger(g)&&(c.y+=g)}}o.node.position=c}var y=o.node.getComponent(xm);if(y){var v=o.node.position.clone();v.y-=y.width,o.node.position=v}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return y[e]?y[e]:(new y).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(of);if(e){this._resetLabelState(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(xm);n||(n=t.node.addComponent(xm)),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||"")}e.cacheMode=this._cacheMode,this._font instanceof Fh&&!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=hn(this._segments);!(t=e()).done;)t.value.node.layer=this.node.layer},i._resetLabelState=function(t){t.fontSize=this._fontSize,t.color=y.WHITE,t.isBold=!1,t.isItalic=!1,t.isUnderline=!1},Ur(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:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=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}(ns),Xg.HorizontalAlign=ef,Xg.VerticalAlign=rf,Dn((Dg=Wg).prototype,"string",[ds,cg],Object.getOwnPropertyDescriptor(Dg.prototype,"string"),Dg.prototype),Dn(Dg.prototype,"horizontalAlign",[_g,fg],Object.getOwnPropertyDescriptor(Dg.prototype,"horizontalAlign"),Dg.prototype),Dn(Dg.prototype,"verticalAlign",[dg,pg],Object.getOwnPropertyDescriptor(Dg.prototype,"verticalAlign"),Dg.prototype),Dn(Dg.prototype,"fontSize",[mg],Object.getOwnPropertyDescriptor(Dg.prototype,"fontSize"),Dg.prototype),Dn(Dg.prototype,"fontFamily",[gg],Object.getOwnPropertyDescriptor(Dg.prototype,"fontFamily"),Dg.prototype),Dn(Dg.prototype,"font",[yg,vg],Object.getOwnPropertyDescriptor(Dg.prototype,"font"),Dg.prototype),Dn(Dg.prototype,"useSystemFont",[bg,Sg],Object.getOwnPropertyDescriptor(Dg.prototype,"useSystemFont"),Dg.prototype),Dn(Dg.prototype,"cacheMode",[Ag,Tg],Object.getOwnPropertyDescriptor(Dg.prototype,"cacheMode"),Dg.prototype),Dn(Dg.prototype,"maxWidth",[Cg],Object.getOwnPropertyDescriptor(Dg.prototype,"maxWidth"),Dg.prototype),Dn(Dg.prototype,"lineHeight",[xg],Object.getOwnPropertyDescriptor(Dg.prototype,"lineHeight"),Dg.prototype),Dn(Dg.prototype,"imageAtlas",[wg,Eg],Object.getOwnPropertyDescriptor(Dg.prototype,"imageAtlas"),Dg.prototype),Dn(Dg.prototype,"handleTouchEvent",[Bg],Object.getOwnPropertyDescriptor(Dg.prototype,"handleTouchEvent"),Dg.prototype),Mg=Dn(Dg.prototype,"_lineHeight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),Pg=Dn(Dg.prototype,"_string",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"<color=#00ff00>Rich</color><color=#0fffff>Text</color>"}}),Ig=Dn(Dg.prototype,"_horizontalAlign",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ef.LEFT}}),Og=Dn(Dg.prototype,"_verticalAlign",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return rf.TOP}}),Fg=Dn(Dg.prototype,"_fontSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),Lg=Dn(Dg.prototype,"_maxWidth",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),kg=Dn(Dg.prototype,"_fontFamily",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),Vg=Dn(Dg.prototype,"_font",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ng=Dn(Dg.prototype,"_isSystemFontUsed",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Gg=Dn(Dg.prototype,"_userDefinedFont",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zg=Dn(Dg.prototype,"_cacheMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sf.NONE}}),Ug=Dn(Dg.prototype,"_imageAtlas",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Hg=Dn(Dg.prototype,"_handleTouchEvent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Rg=Dg))||Rg)||Rg)||Rg)||Rg)||Rg));Er.RichText=ty;var ey=function(e){return t({UIMeshRenderer:e,UIModelComponent:e}),e}(En("cc.UIMeshRenderer")($g=Qn()($g=$n(110)($g=ts()($g=Jn($g=function(t){function e(){var e;return(e=t.call(this)||this)._modelComponent=null,e.modelCount=0,e._dirtyVersion=-1,e._internalId=-1,e.stencilStage=Vu.DISABLED,e._renderData=null,e._renderEntity=new Bc(zu.DYNAMIC),e}on(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){as.addRenderer(this),this.markForUpdateRenderData()},i.onDisable=function(){as.removeRenderer(this),this.renderEntity.enabled=this._canRender()},i.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent?this.renderEntity.setNode(this.node):console.warn("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},i.onDestroy=function(){this.renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent&&(this._modelComponent._sceneGetter=null)},i._render=function(t){if(this._modelComponent){var e=this._modelComponent._collectModels();this._modelComponent._detachFromScene();for(var i=0;i<e.length;i++)e[i].enabled&&t.commitModel(this,e[i],this._modelComponent.material);return!0}return!1},i.fillBuffers=function(t){this.enabled&&this._render(t)},i.updateRenderer=function(){},i._uploadRenderData=function(){},i.postUpdateAssembler=function(){},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++)r[s]._priority=qs.MAX-11,i.recompileShaders({CC_FORCE_FORWARD_SHADING:!0},s)}},i.markForUpdateRenderData=function(){as.markDirtyRenderer(this)},i.setNodeDirty=function(){},i.setTextureDirty=function(){},i._canRender=function(){return this.enabled&&null!==this._modelComponent},Ur(e,[{key:"modelComponent",get:function(){return this._modelComponent}},{key:"renderEntity",get:function(){return this._renderEntity}},{key:"renderData",get:function(){return this._renderData}}]),e}(ns))||$g)||$g)||$g)||$g)||$g);Er.UIMeshRenderer=ey;var iy,ry,ny,sy,ay,oy,ly,hy,uy,cy,_y,fy,dy,py,my,gy,yy,vy,by,Sy,Ay,Ty,Cy,xy,wy,Ey,By,Ry,Dy,My,Py,Iy=gs.Enum.NONE|gs.Enum.UI_3D,Oy=function(){function t(){this.model=null,this.texture=null,this.sampler=null,this.useLocalData=null,this.isStatic=!1,this.textureHash=0,this.samplerHash=0,this._passes=[],this._shaders=[],this._visFlags=Iy,this._inputAssembler=null,this._descriptorSet=null}var e=t.prototype;return e.destroy=function(){this._passes=[]},e.clear=function(){this._inputAssembler=null,this._descriptorSet=null,this.texture=null,this.sampler=null,this.textureHash=0,this.samplerHash=0,this.model=null,this.isStatic=!1,this.useLocalData=null,this.visFlags=Iy},e.fillPasses=function(t,e,i,r){if(t){var n=t.passes;if(!n)return;this._shaders.length=n.length;for(var s=0;s<n.length;s++){this._passes[s]||(this._passes[s]=new ys(Er.director.root));var a=n[s],o=this._passes[s];a.update(),e||(e=a.depthStencilState,i=0),o._initPassFromTarget(a,e,i),this._shaders[s]=o.getShaderVariant(r)}}},Ur(t,[{key:"inputAssembler",get:function(){return this._inputAssembler},set:function(t){this._inputAssembler=t}},{key:"descriptorSet",get:function(){return this._descriptorSet},set:function(t){this._descriptorSet=t}},{key:"visFlags",get:function(){return this._visFlags},set:function(t){this._visFlags=t}},{key:"passes",get:function(){return this._passes}},{key:"shaders",get:function(){return this._shaders}}]),t}(),Fy=function(e){return t({UIStaticBatch:e,UIStaticBatchComponent:e}),e}((iy=En("cc.UIStaticBatch"),ry=Qn(),ny=ts(),sy=$n(110),ay=cs(),iy(oy=ry(oy=ny(oy=sy((hy=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._bufferAccessor=null,e._dirty=!0,e._uiDrawBatchList=[],e}on(e,t);var i=e.prototype;return i.postUpdateAssembler=function(){},i.markAsDirty=function(){},i._requireDrawBatch=function(){var t=new Oy;return t.isStatic=!0,this._uiDrawBatchList.push(t),t},i._clearData=function(){if(this._bufferAccessor){this._bufferAccessor.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 Kr.root&&Kr.root.batcher2D?Kr.root.batcher2D:(Rn(9301),null)},Ur(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}(af),Dn((ly=hy).prototype,"color",[Hn,ay],Object.getOwnPropertyDescriptor(ly.prototype,"color"),ly.prototype),oy=ly))||oy)||oy)||oy)||oy)),Ly=t("LabelShadow",(uy=En("cc.LabelShadow"),cy=Qn(),_y=$n(110),fy=ts(),dy=us(of),py=is(),my=is(),gy=is(),uy(yy=cy(yy=_y(yy=fy(yy=dy(yy=Jn((Ty=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,Mn(e,"_color",by,Pn(e)),Mn(e,"_offset",Sy,Pn(e)),Mn(e,"_blur",Ay,Pn(e)),e}on(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(of);t&&t.updateRenderData(!0)},Ur(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}(ns),by=Dn((vy=Ty).prototype,"_color",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(0,0,0,255)}}),Sy=Dn(vy.prototype,"_offset",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(2,2)}}),Ay=Dn(vy.prototype,"_blur",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),Dn(vy.prototype,"color",[py],Object.getOwnPropertyDescriptor(vy.prototype,"color"),vy.prototype),Dn(vy.prototype,"offset",[my],Object.getOwnPropertyDescriptor(vy.prototype,"offset"),vy.prototype),Dn(vy.prototype,"blur",[gy],Object.getOwnPropertyDescriptor(vy.prototype,"blur"),vy.prototype),yy=vy))||yy)||yy)||yy)||yy)||yy)||yy)),ky=function(e){return t({UIOpacity:e,UIOpacityComponent:e}),e}((Cy=En("cc.UIOpacity"),xy=Qn(),wy=$n(110),Ey=ts(),By=is(),Cy(Ry=xy(Ry=wy(Ry=Ey(Ry=Jn(Ry=Kn((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,Mn(e,"_opacity",My,Pn(e)),e}on(e,t);var i=e.prototype;return i.setEntityLocalOpacityDirtyRecursively=function(){},e.setEntityLocalOpacityDirtyRecursively=function(t,i,r){var n=t._uiProps.uiComp,s=t.getComponent(e),a=r;n&&n.color?(n.renderEntity.colorDirty=i,n.renderEntity.color=n.color,n.renderEntity.localOpacity=s?a*s.opacity/255:a,a=1):s&&(a=s.opacity/255);for(var o=0;o<t.children.length;o++)e.setEntityLocalOpacityDirtyRecursively(t.children[o],i||a<1,a)},i.onEnable=function(){this.node._uiProps.localOpacity=this._opacity/255,this.setEntityLocalOpacityDirtyRecursively(!0)},i.onDisable=function(){this.node._uiProps.localOpacity=1,this.setEntityLocalOpacityDirtyRecursively(!0)},Ur(e,[{key:"opacity",get:function(){return this._opacity},set:function(t){this._opacity!==t&&(t=Ks(t,0,255),this._opacity=t,this.node._uiProps.localOpacity=t/255,this.setEntityLocalOpacityDirtyRecursively(!0))}}]),e}(ns),Dn((Dy=Py).prototype,"opacity",[Un,By],Object.getOwnPropertyDescriptor(Dy.prototype,"opacity"),Dy.prototype),My=Dn(Dy.prototype,"_opacity",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 255}}),Ry=Dy))||Ry)||Ry)||Ry)||Ry)||Ry)||Ry));Er.MaskComponent=lm,pn.setClassAlias(lm,"cc.MaskComponent"),Er.LabelComponent=of,pn.setClassAlias(of,"cc.LabelComponent"),Er.LabelOutlineComponent=xm,pn.setClassAlias(xm,"cc.LabelOutlineComponent"),Er.RichTextComponent=ty,pn.setClassAlias(ty,"cc.RichTextComponent"),Er.SpriteComponent=im,pn.setClassAlias(im,"cc.SpriteComponent"),Er.UIModelComponent=ey,pn.setClassAlias(ey,"cc.UIModelComponent"),Er.GraphicsComponent=Mp,pn.setClassAlias(Mp,"cc.GraphicsComponent"),pn.setClassAlias(Fy,"cc.UIStaticBatchComponent"),pn.setClassAlias(ky,"cc.UIOpacityComponent"),wr(lm.prototype,"Mask",[{name:"graphics",newName:"subComp",target:lm.prototype,targetName:"Mask"}]);var Vy=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 Ny(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=rv(s,t[s],t[s+1],a);else for(s=i-r;s>=e;s-=r)a=rv(s,t[s],t[s+1],a);return a&&$y(a,a.next)&&(nv(a),a=a.next),a}function Gy(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||!$y(i,i.next)&&0!==Qy(i.prev,i,i.next))i=i.next;else{if(nv(i),(i=e=i.prev)===i.next)return null;r=!0}}while(r||i!==e);return e}function zy(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=qy(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?Hy(t,r,n,s):Uy(t))e.push(l.i/i),e.push(t.i/i),e.push(h.i/i),nv(t),t=h.next,o=h.next;else if((t=h)===o){a?1===a?zy(t=Xy(t,e,i),e,i,r,n,s,2):2===a&&Wy(t,e,i,r,n,s):zy(Gy(t),e,i,r,n,s,1);break}}}function Uy(t){var e=t.prev,i=t,r=t.next;if(Qy(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(Jy(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Qy(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Hy(t,e,i,r){var n=t.prev,s=t,a=t.next;if(Qy(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=qy(o,l,e,i,r),_=qy(h,u,e,i,r),f=t.nextZ;f&&f.z<=_;){if(f!==t.prev&&f!==t.next&&Jy(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&Qy(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&&Jy(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&Qy(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function Xy(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!$y(n,s)&&tv(n,r,r.next,s)&&ev(n,s)&&ev(s,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(s.i/i),nv(r),nv(r.next),r=t=s),r=r.next}while(r!==t);return r}function Wy(t,e,i,r,n,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Zy(a,o)){var l=iv(a,o);return a=Gy(a,a.next),l=Gy(l,l.next),zy(a,e,i,r,n,s),void zy(l,e,i,r,n,s)}o=o.next}a=a.next}while(a!==t)}function jy(t,e){return t.x-e.x}function Yy(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&&Jy(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)&&ev(i,t)&&(a=i,_=l),i=i.next;return a}(t,e)){var i=iv(e,t);Gy(i,i.next)}}function qy(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 Ky(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function Jy(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 Zy(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&&tv(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&ev(t,e)&&ev(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 Qy(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function $y(t,e){return t.x===e.x&&t.y===e.y}function tv(t,e,i,r){return!!($y(t,e)&&$y(i,r)||$y(t,r)&&$y(i,e))||Qy(t,e,i)>0!=Qy(t,e,r)>0&&Qy(i,r,t)>0!=Qy(i,r,e)>0}function ev(t,e){return Qy(t.prev,t,t.next)<0?Qy(t,e,t.next)>=0&&Qy(t,t.prev,e)>=0:Qy(t,e,t.prev)<0||Qy(t,t.next,e)<0}function iv(t,e){var i=new Vy(t.i,t.x,t.y),r=new Vy(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 rv(t,e,i,r){var n=new Vy(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 nv(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 sv(t,e,i){i=i||3;var r=e?e.length:0,n=r?e[0]*i:t.length,s=Ny(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=Ny(t,e[a]*r,a<n-1?e[a+1]*r:t.length,r,!1))&&(o===o.next&&(o.steiner=!0),s.push(Ky(o)));if(s.sort(jy),!i)return i;for(a=0;a<s.length;a++)Yy(s[a],i),i=Gy(i,i.next);return i}(t,e,s,i)),t.length>80*i){o=h=t[0],l=u=t[1];for(var d=i;d<n;d+=i)(c=t[d])<o&&(o=c),(_=t[d+1])<l&&(l=_),c>h&&(h=c),_>u&&(u=_);f=Math.max(h-o,u-l)}return zy(s,a,i,o,l,f),a}for(var av=Math.PI,ov=Math.min,lv=Math.max,hv=Math.ceil,uv=Math.acos,cv=Math.cos,_v=Math.sin,fv=Math.atan2,dv=null,pv=null,mv=new y,gv=[],yv=0;yv<4;yv++)gv.push(new n);function vv(t,e,i){return t<e?e:t>i?i:t}var bv={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!pv)return null;var i=pv.getRenderDataList(),r=i[pv.dataOffset];if(!r)return null;var n=r,s=n?n.vertexStart+e:0;return(s>65535||3*s>131070)&&(++pv.dataOffset,pv.dataOffset<i.length?r=i[pv.dataOffset]:(r=pv.requestRenderData(),i[pv.dataOffset]=r),n=r),n&&n.vertexCount<s&&n.request(e,3*e),r},stroke:function(t){y.copy(mv,t.strokeColor),t.impl&&(this._flattenPaths(t.impl),this._expandStroke(t),t.impl.updatePathOffset=!0,this.end(t))},fill:function(t){y.copy(mv,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(pv=t.impl){var s=function(t,e,i){var r=2*uv(t/(t+i));return lv(2,hv(e/r))}(e,av,pv.tessTol);this._calculateJoins(pv,e,r,n);for(var a=pv.paths,o=0,l=pv.pathOffset,h=pv.pathLength;l<h;l++){var u=a[l],c=u.points.length;r===jf.ROUND?o+=2*(c+u.bevel*(s+2)+1):o+=2*(c+5*u.bevel+1),u.closed||(i===Wf.ROUND?o+=2*(2*s+2):o+=12)}var _=dv=this.getRenderData(t,o);if(_){for(var f=_.vData,d=_.iData,p=pv.pathOffset,m=pv.pathLength;p<m;p++){var g=a[p],y=g.points,v=y.length,b=_.vertexStart,S=void 0,A=void 0,T=0,C=0,x=g.closed;if(x?(S=y[v-1],A=y[0],T=0,C=v):(S=y[0],A=y[1],T=1,C=v-1),A=A||S,!x){var w=new xp(A.x,A.y);w.subtract(S),w.normalize();var E=w.x,B=w.y;i===Wf.BUTT?this._buttCapStart(S,E,B,e,0):i===Wf.SQUARE?this._buttCapStart(S,E,B,e,e):i===Wf.ROUND&&this._roundCapStart(S,E,B,e,s)}for(var R=T;R<C;++R)r===jf.ROUND?this._roundJoin(S,A,e,e,s):0!=(A.flags&(Yf.PT_BEVEL|Yf.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=y[R+1];if(x){var D=8*b;this._vSet(f[D],f[D+1],1),this._vSet(f[D+8],f[D+8+1],-1)}else{var M=new xp(A.x,A.y);M.subtract(S),M.normalize();var P=M.x,I=M.y;i===Wf.BUTT?this._buttCapEnd(A,P,I,e,0):i===Wf.SQUARE?this._buttCapEnd(A,P,I,e,e):i===Wf.ROUND&&this._roundCapEnd(A,P,I,e,s)}for(var O=_.indexStart,F=b+2,L=_.vertexStart;F<L;F++)d[O++]=F-2,d[O++]=F-1,d[O++]=F;_.indexStart=O}dv=null,pv=null}}},_expandFill:function(t){if(pv=t.impl){for(var e=pv.paths,i=0,r=pv.pathOffset,n=pv.pathLength;r<n;r++)i+=e[r].points.length;var s=dv=this.getRenderData(t,i);if(s){for(var a=s,o=a.vData,l=a.iData,h=pv.pathOffset,u=pv.pathLength;h<u;h++){var c=e[h],_=c.points,f=_.length;if(0!==f){for(var d=s.vertexStart,p=0;p<f;++p)this._vSet(_[p].x,_[p].y);var m=s.indexStart;if(c.complex){for(var g=[],y=d,v=s.vertexStart;y<v;y++){var b=8*y;g.push(o[b++]),g.push(o[b++]),g.push(o[b++])}var S=sv(g,null,3);if(!S||0===S.length)continue;for(var A=0,T=S.length;A<T;A++)l[m++]=S[A]+d}else for(var C=d,x=d+2,w=a.vertexStart;x<w;x++)l[m++]=C,l[m++]=x-1,l[m++]=x;a.indexStart=m}}dv=null,pv=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 d,p,m=c.dy,g=-c.dx,y=_.dy,v=-_.dx;if(_.dmx=.5*(m+y),_.dmy=.5*(g+v),(d=_.dmx*_.dmx+_.dmy*_.dmy)>1e-6){var b=1/d;b>600&&(b=600),_.dmx*=b,_.dmy*=b}_.dx*c.dy-c.dx*_.dy>0&&(_.flags|=Yf.PT_LEFT),d*(p=lv(11,ov(c.len,_.len)*n))*p<1&&(_.flags|=Yf.PT_INNERBEVEL),_.flags&Yf.PT_CORNER&&(d*r*r<1||i===jf.BEVEL||i===jf.ROUND)&&(_.flags|=Yf.PT_BEVEL),0!=(_.flags&(Yf.PT_BEVEL|Yf.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 xp(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)*av,c=cv(u)*r,_=_v(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)*av,c=cv(u)*r,_=_v(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&Yf.PT_LEFT)){var c=this._chooseBevel(e.flags&Yf.PT_INNERBEVEL,t,e,i),_=c[0],f=c[1],d=c[2],p=c[3],m=fv(-a,-s),g=fv(-l,-o);g>m&&(g-=2*av),this._vSet(_,f,1),this._vSet(h-s*r,e.y-a*r,-1);for(var y=vv(hv((m-g)/av)*n,2,n),v=0;v<y;v++){var b=m+v/(y-1)*(g-m),S=h+cv(b)*r,A=u+_v(b)*r;this._vSet(h,u,0),this._vSet(S,A,-1)}this._vSet(d,p,1),this._vSet(h-o*r,u-l*r,-1)}else{var T=this._chooseBevel(e.flags&Yf.PT_INNERBEVEL,t,e,-r),C=T[0],x=T[1],w=T[2],E=T[3],B=fv(a,s),R=fv(l,o);R<B&&(R+=2*av),this._vSet(h+s*r,u+a*r,1),this._vSet(C,x,-1);for(var D=vv(hv((R-B)/av)*n,2,n),M=0;M<D;M++){var P=B+M/(D-1)*(R-B),I=h+cv(P)*i,O=u+_v(P)*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,d=e.dy,p=-e.dx;if(e.flags&Yf.PT_LEFT){var m=this._chooseBevel(e.flags&Yf.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-d*r,e.y-p*r,-1)}else{var g=this._chooseBevel(e.flags&Yf.PT_INNERBEVEL,t,e,-r);n=g[0],s=g[1],a=g[2],o=g[3],this._vSet(e.x+_*i,e.y+f*i,1),this._vSet(n,s,-1),this._vSet(e.x+d*i,e.y+p*i,1),this._vSet(a,o,-1)}},_vSet:function(t,e,i){if(void 0===i&&(i=0),dv){var r=dv,n=8*r.vertexStart,s=r.vData;s[n++]=t,s[n++]=e,s[n++]=0,y.toArray(s,mv,n),n+=4,s[n++]=i,r.vertexStart++}}},Sv=t("graphicsAssembler",{getAssembler:function(){return bv}});Mp.Assembler=Sv;var Av,Tv=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},Cv=new m,xv=new Su(64,64),wv=new qh(null),Ev=null,Bv=null,Rv=[],Dv=[],Mv=[],Pv=[],Iv=new d,Ov=new d,Fv=new i,Lv=null,kv=0,Vv=0,Nv=0,Gv=0,zv=0,Uv=1,Hv=null,Xv="",Wv=0,jv=0,Yv=0,qv=0,Kv=0,Jv=0,Zv=0,Qv=!1,$v=0,tb=0,eb=0,ib={updateRenderData:function(t){t.renderData&&Ev!==t&&(t.renderData.vertDirty&&(Bv=(Ev=t).node._uiProps.uiTransformComp,this._updateFontFamily(t),this._updateProperties(t),this._updateLabelInfo(t),this._updateContent(),Ev.actualFontSize=Wv,Bv.setContentSize(Ov),this.updateUVs(t),this.updateColor(t),Ev.renderData.vertDirty=!1,Ev=null,this._resetProperties()),t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame))},updateUVs:function(t){for(var e=t.renderData,i=e.chunk.vb,r=e.vertexCount,n=e.data,s=3,a=0;a<r;a++){var o=n[a];i[s]=o.u,i[s+1]=o.v,s+=9}},updateColor:function(){},_updateFontScale:function(){Uv=Wv/jv},_updateFontFamily:function(t){var e=t.font;Hv=e.spriteFrame,Lv=e.fntConfig,Au.fontAtlas=e.fontDefDictionary,Au.fontAtlas||(t.cacheMode===sf.CHAR?Au.fontAtlas=xv:Au.fontAtlas=wv),Gl.packToDynamicAtlas(t,Hv)},_updateLabelInfo:function(){Au.hash="",Au.margin=0},_updateProperties:function(t){Xv=t.string.toString(),Wv=t.fontSize,jv=Lv?Lv.fontSize:t.fontSize,Yv=t.horizontalAlign,qv=t.verticalAlign,Kv=t.spacingX,Zv=t.overflow,Jv=t._lineHeight;var e=Bv.contentSize;Ov.width=e.width,Ov.height=e.height,Zv===nf.NONE?(Qv=!1,Ov.width+=2*Au.margin,Ov.height+=2*Au.margin):Zv===nf.RESIZE_HEIGHT?(Qv=!0,Ov.height+=2*Au.margin):Qv=t.enableWrapText,Au.lineHeight=Jv,Au.fontSize=Wv,this._setupBMFontOverflowMetrics()},_resetProperties:function(){Lv=null,Hv=null,Au.hash="",Au.margin=0},_updateContent:function(){this._updateFontScale(),this._computeHorizontalKerningForText(),this._alignText()},_computeHorizontalKerningForText:function(){var t=Xv,e=t.length,i=Lv.kerningDict,r=Rv;if(i)for(var 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=Xv.length,i=0,r=0,n=0,s=0,a=0,o=0,l=0,h=null,u=0;u<e;){var c=Xv.charAt(u);if("\n"!==c){for(var _=t(Xv,u,e),f=o,d=l,p=a,m=r,g=!1,y=0;y<_;++y){var v=u+y;if("\r"!==(c=Xv.charAt(v)))if(h=Au.fontAtlas.getLetterDefinitionForChar(c,Au)){var b=m+h.offsetX*Uv-Au.margin;if(Qv&&eb>0&&r>0&&b+h.w*Uv>eb&&!lu(c)){Mv.push(a),a=0,i++,r=0,n-=Jv*this._getFontScale()+0,g=!0;break}Fv.x=b,Fv.y=n-h.offsetY*Uv,this._recordLetterInfo(Fv,c,v,i),v+1<Rv.length&&v<e-1&&(m+=Rv[v+1]),m+=h.xAdvance*Uv+Kv,p=Fv.x+h.w*Uv,f<Fv.y&&(f=Fv.y),d>Fv.y-h.h*Uv&&(d=Fv.y-h.h*Uv)}else this._recordPlaceholderInfo(v,c),console.log("Can't find letter definition in texture atlas "+Lv.atlasName+" for letter:"+c);else this._recordPlaceholderInfo(v,c)}g||(r=m,o<f&&(o=f),l>d&&(l=d),s<(a=p)&&(s=a),u+=_)}else Mv.push(a),a=0,i++,r=0,n-=Jv*this._getFontScale()+0,this._recordPlaceholderInfo(u,c),u++}return Mv.push(a),Vv=(kv=i+1)*Jv*this._getFontScale(),kv>1&&(Vv+=0*(kv-1)),Ov.width=$v,Ov.height=tb,$v<=0&&(Ov.width=parseFloat(s.toFixed(2))+2*Au.margin),tb<=0&&(Ov.height=parseFloat(Vv.toFixed(2))+2*Au.margin),Gv=Ov.height,zv=0,o>0&&(Gv=Ov.height+o),l<-Vv&&(zv=Vv+l),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return Zv===nf.SHRINK?Uv:1},_getFirstWordLen:function(t,e,i){var r=t.charAt(e);if(ou(r)||"\n"===r||lu(r))return 1;var n=1,s=Au.fontAtlas.getLetterDefinitionForChar(r,Au);if(!s)return n;for(var a=s.xAdvance*Uv+Kv,o=e+1;o<i&&(r=t.charAt(o),s=Au.fontAtlas.getLetterDefinitionForChar(r,Au));++o){if(a+s.offsetX*Uv+s.w*Uv>eb&&!lu(r)&&eb>0)return n;if(a+=s.xAdvance*Uv+Kv,"\n"===r||lu(r)||ou(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>=Dv.length){var i=new Tv;Dv.push(i)}Dv[t].char=e,Dv[t].hash=""+e.charCodeAt(0)+Au.hash,Dv[t].valid=!1},_recordLetterInfo:function(t,e,i,r){if(i>=Dv.length){var n=new Tv;Dv.push(n)}var s=""+e.charCodeAt(0)+Au.hash;Dv[i].line=r,Dv[i].char=e,Dv[i].hash=s,Dv[i].valid=Au.fontAtlas.getLetter(s).valid,Dv[i].x=t.x,Dv[i].y=t.y},_alignText:function(){Vv=0,Mv.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),Zv===nf.SHRINK&&Wv>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||Zv===nf.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(t){var e=!0;t||(t=.1,e=!1),Wv=t,e&&this._updateContent()},_shrinkLabelToContentSize:function(t){for(var e=0,i=0|Wv,r=0;e<i;){var n=r=e+i+1>>1;if(n<=0)break;Uv=n/jv,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),t()?i=r-1:e=r}e>=0&&this._scaleFontSizeDown(e)},_isVerticalClamp:function(){return Vv>Ov.height},_isHorizontalClamp:function(){for(var t=!1,e=0,i=Xv.length;e<i;++e){var r=Dv[e];if(r.valid){var n=Au.fontAtlas.getLetterDefinitionForChar(r.char,Au);if(!n)continue;var s=r.x+n.w*Uv,a=r.line;if($v>0)if(Qv){if(Mv[a]>Ov.width&&(s>Ov.width||s<0)){t=!0;break}}else if(s>Ov.width){t=!0;break}}}return t},_isHorizontalClamped:function(t,e){var i=Mv[e],r=t>Ov.width||t<0;return Qv?i>Ov.width&&r:r},_updateQuads:function(){if(!Ev)return!1;var t=Hv?Hv.texture:Au.fontAtlas.getTexture(),e=Ev.renderData;e.dataLength=0,e.resize(0,0);for(var i=Bv.anchorPoint,r=Ov,n=i.x*r.width,s=i.y*r.height,a=!0,o=0,l=Xv.length;o<l;++o){var h=Dv[o];if(h.valid){var u=Au.fontAtlas.getLetter(h.hash);if(u){Cv.height=u.h,Cv.width=u.w,Cv.x=u.u,Cv.y=u.v;var c=h.y+Nv;if(tb>0){if(c>Gv){var _=c-Gv;Cv.y+=_,Cv.height-=_,c-=_}c-u.h*Uv<zv&&Zv===nf.CLAMP&&(Cv.height=c<zv?0:(c-zv)/Uv)}var f=h.line,d=h.x+u.w/2*Uv+Pv[f];if($v>0&&this._isHorizontalClamped(d,f))if(Zv===nf.CLAMP)Cv.width=0;else if(Zv===nf.SHRINK){if(Ov.width>u.w){a=!1;break}Cv.width=0}if(Cv.height>0&&Cv.width>0){var p=this._determineRect(),m=h.x+Pv[h.line];this.appendQuad(Ev,t,Cv,p,m-n,c-s,Uv)}}else console.warn("Can't find letter in this bitmap-font")}}var g=e.indexCount;return this.createQuadIndices(g),e.chunk.setIndexBuffer(Av),a},createQuadIndices:function(t){if(t%6==0){var e=t/6;Av=null,Av=new Uint16Array(t);for(var i=0,r=0;r<e;r++)Av[i++]=0+4*r,Av[i++]=1+4*r,Av[i++]=2+4*r,Av[i++]=1+4*r,Av[i++]=3+4*r,Av[i++]=2+4*r}else console.error("illegal index count!")},appendQuad:function(){},_determineRect:function(){var t=Hv.isRotated(),e=Hv.getOriginalSize(),i=Hv.getRect(),r=Hv.getOffset(),n=r.x+(e.width-i.width)/2,s=r.y-(e.height-i.height)/2;if(t){var a=Cv.x;Cv.x=i.x+i.height-Cv.y-Cv.height-s,Cv.y=a+i.y-n,Cv.y<0&&(Cv.height+=s)}else Cv.x+=i.x-n,Cv.y+=i.y+s;return t},_computeAlignmentOffset:function(){switch(Pv.length=0,Yv){case ef.LEFT:for(var t=0;t<kv;++t)Pv.push(0);break;case ef.CENTER:for(var e=0,i=Mv.length;e<i;e++)Pv.push((Ov.width-Mv[e])/2);break;case ef.RIGHT:for(var r=0,n=Mv.length;r<n;r++)Pv.push(Ov.width-Mv[r])}if(Nv=Ov.height,qv!==rf.TOP){var s=Ov.height-Vv+Jv*this._getFontScale()-jv*Uv;qv===rf.BOTTOM?Nv-=s:Nv-=s/2}},_setupBMFontOverflowMetrics:function(){var t=Ov.width,e=Ov.height;Zv===nf.RESIZE_HEIGHT&&(e=0),Zv===nf.NONE&&(t=0,e=0),$v=t,tb=e,Iv.width=t,Iv.height=e,eb=t}},rb=new y(255,255,255,255),nb={createData:function(t){return t.requestRenderData()},fillBuffers:function(t){var e=t.node;rb.set(t.color),rb.a=255*e._uiProps.opacity,Ol(e,0,t.renderData,rb)},appendQuad:function(t,e,i,r,n,s,a){var o=t.renderData;if(o){var l=o.dataLength;o.dataLength+=4,o.resize(o.dataLength,o.dataLength/2*3);var h=o.data,u=e.width,c=e.height,_=i.width,f=i.height,d=0,p=0,m=0,g=0;r?(d=i.x/u,g=(i.x+f)/u,p=(i.y+_)/c,m=i.y/c,h[l].u=d,h[l].v=m,h[l+1].u=d,h[l+1].v=p,h[l+2].u=g,h[l+2].v=m,h[l+3].u=g,h[l+3].v=p):(d=i.x/u,g=(i.x+_)/u,p=(i.y+f)/c,m=i.y/c,h[l].u=d,h[l].v=p,h[l+1].u=g,h[l+1].v=p,h[l+2].u=d,h[l+2].v=m,h[l+3].u=g,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}}};Js(nb,ib);var sb=null,ab=jn(ib,{getAssemblerData:function(){return sb||(sb=new Su(1024,1024)),sb.getTexture()},_updateFontFamily:function(t){Au.fontAtlas=sb,Au.fontFamily=this._getFontFamily(t);var e=t.getComponent(xm);e&&e.enabled?(Au.isOutlined=!0,Au.margin=e.width,Au.out=e.color.clone(),Au.out.a=e.color.a*t.color.a/255):(Au.isOutlined=!1,Au.margin=0)},_getFontFamily:function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(e=t.font._nativeAsset||"Arial"),e},_updateLabelInfo:function(t){Au.fontDesc=this._getFontDesc(),Au.color=t.color,Au.hash=function(t){var e=t.color.toHEX(),i="";return t.isOutlined&&t.margin>0&&(i=i+t.margin+t.out.toHEX()),""+t.fontSize+t.fontFamily+e+i}(Au)},_getFontDesc:function(){return Au.fontSize.toString()+"px "+Au.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),ob=new y(255,255,255,255),lb={createData:function(t){return t.requestRenderData()},fillBuffers:function(t){if(t.renderData){var e=t.node;ob.a=255*e._uiProps.opacity,Ol(e,0,t.renderData,ob)}},appendQuad:nb.appendQuad};Js(lb,ab);var hb=of.Overflow,ub=(1/255).toFixed(3),cb=null,_b=null,fb=null,db="",pb="",mb=0,gb=0,yb=[],vb=new d,bb=0,Sb=0,Ab=0,Tb=new y,Cb="",xb=hb.NONE,wb=!1,Eb=null,Bb=y.BLACK.clone(),Rb=null,Db=y.BLACK.clone(),Mb=new m,Pb=d.ZERO.clone(),Ib=d.ZERO.clone(),Ob=i.ZERO.clone(),Fb=i.ZERO.clone(),Lb=0,kb=0,Vb=!1,Nb=!1,Gb=!1,zb=["left","center","right"],Ub={getAssemblerData:function(){return of._canvasPool.get()},resetAssemblerData:function(t){t&&of._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp;this._updateFontFamily(t),this._updateProperties(t,e),this._calculateLabelFont(),this._updateLabelDimensions(),this._updateTexture(t),this._calDynamicAtlas(t),t.actualFontSize=mb,e.setContentSize(vb),this.updateVertexData(t),this.updateUVs(t),t.renderData.vertDirty=!1,cb=null,_b=null,fb=null}t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame)}},updateVertexData:function(){},updateUVs:function(){},_updateFontFamily:function(t){Cb=t.useSystemFont?t.fontFamily||"Arial":t.font&&t.font._nativeAsset||"Arial"},_updateProperties:function(t,e){var i=t.assemblerData;i&&(cb=i.context,_b=i.canvas,fb=t.spriteFrame,pb=t.string.toString(),mb=t.fontSize,gb=mb,xb=t.overflow,Ib.width=vb.width=e.width,Ib.height=vb.height=e.height,kb=t.underlineHeight,bb=t.lineHeight,Sb=t.horizontalAlign,Ab=t.verticalAlign,Tb=t.color,t.node._uiProps.opacity,Vb=t.isBold,Nb=t.isItalic,Gb=t.isUnderline,wb=xb!==hb.NONE&&(xb===hb.RESIZE_HEIGHT||t.enableWrapText),(Eb=(Eb=xm&&t.getComponent(xm))&&Eb.enabled&&Eb.width>0?Eb:null)&&Bb.set(Eb.color),(Rb=(Rb=Ly&&t.getComponent(Ly))&&Rb.enabled?Rb:null)&&Db.set(Rb.color),this._updatePaddingRect())},_updatePaddingRect:function(){var t=0,e=0,i=0,r=0,n=0;if(Pb.width=Pb.height=0,Eb&&(t=e=i=r=n=Eb.width,Pb.width=Pb.height=2*n),Rb){var s=Rb.blur+n,a=Rb.offset.x,o=Rb.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(Nb){var l=gb*Math.tan(.20943951);r+=l,Pb.width+=l}Mb.x=i,Mb.y=t,Mb.width=i+r,Mb.height=t+e},_calculateFillTextStartPosition:function(){var t=0;Sb===ef.RIGHT?t=vb.width-Mb.width:Sb===ef.CENTER&&(t=(vb.width-Mb.width)/2);var e=this._getLineHeight()*(yb.length-1),i=mb*(1-Zh/2);if(Ab!==rf.TOP){var r=e+Mb.height+mb-vb.height;Ab===rf.BOTTOM?i-=r+=Zh/2*mb:i-=r/2}i+=0*mb,Ob.set(t+Mb.x,i+Mb.y)},_updateTexture:function(t){if(cb&&_b){cb.clearRect(0,0,_b.width,_b.height),cb.font=db,this._calculateFillTextStartPosition();var e=this._getLineHeight();cb.lineJoin="round",Eb?(cb.fillStyle="rgba("+Bb.r+", "+Bb.g+", "+Bb.b+", "+ub+")",cb.fillRect(0,0,_b.width,_b.height)):t._srcBlendFactor===gt.SRC_ALPHA&&(cb.fillStyle="rgba("+Tb.r+", "+Tb.g+", "+Tb.b+", "+ub+")",cb.fillRect(0,0,_b.width,_b.height)),cb.fillStyle="rgb("+Tb.r+", "+Tb.g+", "+Tb.b+")";var i=Ob.x,r=0;this._drawTextEffect(Ob,e);for(var n=0;n<yb.length;++n)r=Ob.y+n*e,Eb&&cb.strokeText(yb[n],i,r),cb.fillText(yb[n],i,r);Rb&&(cb.shadowColor="transparent"),this._uploadTexture(t)}},_uploadTexture:function(t){if(t.cacheMode===of.CacheMode.BITMAP){var e=t.ttfSpriteFrame;Gl.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}var i;fb&&_b&&(i=fb instanceof Bh?fb.texture:fb,0!==_b.width&&0!==_b.height&&(i.reset({width:_b.width,height:_b.height,mipmapLevel:1}),i.uploadData(_b),i.setWrapMode(Zs.CLAMP_TO_EDGE,Zs.CLAMP_TO_EDGE),fb instanceof Bh&&(fb.rect=new m(0,0,_b.width,_b.height),fb._calculateUV()),t.renderData&&(t.renderData.textureDirty=!0),Er.director.root&&Er.director.root.batcher2D&&Er.director.root.batcher2D._releaseDescriptorSetCache(i.getHash())))},_calDynamicAtlas:function(t){if(!(t.cacheMode!==of.CacheMode.BITMAP||!_b||_b.width<=0||_b.height<=0)){var e=t.ttfSpriteFrame;Gl.packToDynamicAtlas(t,e)}},_setupOutline:function(){cb.strokeStyle="rgba("+Bb.r+", "+Bb.g+", "+Bb.b+", "+Bb.a/255+")",cb.lineWidth=2*Eb.width},_setupShadow:function(){cb.shadowColor="rgba("+Db.r+", "+Db.g+", "+Db.b+", "+Db.a/255+")",cb.shadowBlur=Rb.blur,cb.shadowOffsetX=Rb.offset.x,cb.shadowOffsetY=-Rb.offset.y},_drawTextEffect:function(t,e){if(Rb||Eb||Gb){var i=yb.length>1&&Rb,r=this._measureText(cb,db),n=0,s=0;Rb&&this._setupShadow(),Eb&&this._setupOutline();for(var a=0;a<yb.length;++a)n=t.x,s=t.y+a*e,i&&(Eb&&cb.strokeText(yb[a],n,s),cb.fillText(yb[a],n,s)),Gb&&(Lb=r(yb[a]),Sb===ef.RIGHT?Fb.x=t.x-Lb:Sb===ef.CENTER?Fb.x=t.x-Lb/2:Fb.x=t.x,Fb.y=s+gb/8,cb.fillRect(Fb.x,Fb.y,Lb,kb));i&&(cb.shadowColor="transparent")}},_updateLabelDimensions:function(){vb.width=Math.min(vb.width,2048),vb.height=Math.min(vb.height,2048);var t=!1;_b.width!==vb.width&&(_b.width=vb.width,t=!0),_b.height!==vb.height&&(_b.height=vb.height,t=!0),t&&(cb.font=db),cb.textAlign=zb[Sb],cb.textBaseline="alphabetic"},_getFontDesc:function(){var t=mb.toString()+"px ";return t+=Cb,Vb&&(t="bold "+t),Nb&&(t="italic "+t),t},_getLineHeight:function(){return 0|(0===bb?mb:bb*mb/gb)},_calculateParagraphLength:function(t,e){for(var i,r=[],n=hn(t);!(i=n()).done;){var s=hu(e,i.value,db);r.push(s)}return r},_measureText:function(t,e){return function(i){return hu(t,i,e)}},_calculateShrinkFont:function(t){if(cb){var e=this._calculateParagraphLength(t,cb),i=0,r=0,n=0;if(wb){var s=Ib.width,a=Ib.height;if(s<0||a<0)return;r=a+1;for(var o=0,l=0|mb+1,h=0;o<l;){if((h=o+l+1>>1)<=0){Qs(4003);break}mb=h,db=this._getFontDesc(),cb.font=db;var u=this._getLineHeight();for(r=0,i=0;i<t.length;++i){var c=hu(cb,t[i],db);r+=fu(t[i],c,s,this._measureText(cb,db)).length*u}r>a?l=h-1:o=h}0===o?Qs(4003):(mb=o,db=this._getFontDesc(),cb.font=db)}else{for(r=t.length*this._getLineHeight(),i=0;i<t.length;++i)n<e[i]&&(n=e[i]);var _=(vb.width-Mb.width)/n,f=vb.height/r;mb=gb*Math.min(1,_,f)|0,db=this._getFontDesc(),cb.font=db}}},_calculateWrapText:function(t){if(wb&&cb){yb=[];for(var e=Ib.width,i=0;i<t.length;++i){var r=hu(cb,t[i],db),n=fu(t[i],r,e,this._measureText(cb,db));yb=yb.concat(n)}}},_calculateLabelFont:function(){if(cb){var t=pb.split("\n");switch(yb=t,db=this._getFontDesc(),cb.font=db,xb){case hb.NONE:for(var e=0,i=0,r=0;r<t.length;++r){var n=hu(cb,t[r],db);e=e>n?e:n}i=(yb.length+Zh)*this._getLineHeight();var s=parseFloat(e.toFixed(2)),a=parseFloat(i.toFixed(2));vb.width=s+Mb.width,vb.height=a+Mb.height,Ib.width=s+Pb.width,Ib.height=a+Pb.height;break;case hb.SHRINK:this._calculateShrinkFont(t),this._calculateWrapText(t);break;case hb.CLAMP:this._calculateWrapText(t);break;case hb.RESIZE_HEIGHT:this._calculateWrapText(t);var o=(yb.length+Zh)*this._getLineHeight();vb.height=o+Mb.height,Ib.height=o+Pb.height}}}},Hb=y.WHITE.clone(),Xb=new n,Wb=Uint16Array.from([0,1,2,1,3,2]),jb={createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6);var i=e.chunk.vb;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++)y.toArray(i,Hb,r),r+=9;return e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(Wb),e},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,r=e.data,s=t.node,a=i.vb,o=s.worldMatrix,l=e.floatStride,h=0,u=0;u<r.length;u++){var c=r[u];n.set(Xb,c.x,c.y,0),n.transformMat4(Xb,Xb,o),h=u*l,a[h++]=Xb.x,a[h++]=Xb.y,a[h++]=Xb.z}var _=i.vertexOffset,f=i.meshBuffer,d=i.meshBuffer.iData,p=f.indexOffset;d[p++]=_,d[p++]=_+1,d[p++]=_+2,d[p++]=_+2,d[p++]=_+1,d[p++]=_+3,f.indexOffset+=6},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[1].x=r-s,o[1].y=-a,o[2].x=-s,o[2].y=n-a,o[3].x=r-s,o[3].y=n-a}},updateUVs:function(t){var e=t.renderData;if(e&&t.ttfSpriteFrame){var i=e.chunk.vb,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]}},updateColor:function(){}};Js(jb,Ub);var Yb=t("labelAssembler",{getAssembler:function(t){var e=jb;return t.font instanceof Kh?e=nb:t.cacheMode===of.CacheMode.CHAR&&(e=lb),e}});of.Assembler=Yb;var qb=ju.sharedManager,Kb={createData:function(t){return t.requestRenderData(Pu.MODEL)},updateRenderData:function(){},fillBuffers:function(t,e){(t.type!==rm.IMAGE_STENCIL||t.spriteFrame)&&(qb.pushMask(t),e.finishMergeBatches(),function(t,e){qb.clear(t),e.commitModel(t,t._clearModel,t._clearStencilMtl)}(t,e),function(t){qb.enterLevel(t),t.type===rm.IMAGE_STENCIL&&(qb.stage=t.subComp.stencilStage)}(t))}},Jb={fillBuffers:function(){qb.exitMask()}},Zb={getAssembler:function(){return Kb}},Qb={getAssembler:function(){return Jb}},$b={getAssembler:function(){return tS}},tS={fillBuffers:function(){qb.enableMask()}};lm.Assembler=Zb,lm.PostAssembler=Qb,lm.ChildPostAssembler=$b;var eS,iS=im.FillType,rS=new c,nS=new n,sS=Uint16Array.from([0,1,2,1,3,2]),aS={updateRenderData:function(t){var e=t.spriteFrame;Gl.packToDynamicAtlas(t,e);var i=t.renderData;if(i&&e){if(!i.vertDirty)return;var r=t.fillStart,n=t.fillRange;n<0&&(r+=n,n=-n),n=(n=(n=r+n)>1?1:n)<0?0:n;var s=(r=(r=r>1?1:r)<0?0:r)+(n=(n-=r)<0?0:n);s=s>1?1:s,this.updateColor(t),this.updateUVs(t,r,s),this.updateVertexData(t,r,s),i.updateRenderData(t,e)}},updateUVs:function(t,e,i){var r=t.spriteFrame,n=t.renderData.chunk.vb,s=r.width,a=r.height,o=r.rect,l=0,h=0,u=0,c=0,_=0,f=0,d=0,p=0,m=0,g=0;switch(r.isRotated()?(l=o.x/s,h=(o.y+o.width)/a,u=_=l,d=m=(o.x+o.height)/s,f=g=h,c=p=o.y/a):(l=o.x/s,h=(o.y+o.height)/a,u=d=l,_=m=(o.x+o.width)/s,c=f=h,p=g=o.y/a),t.fillType){case iS.HORIZONTAL:n[3]=u+(_-u)*e,n[4]=c+(f-c)*e,n[12]=u+(_-u)*i,n[13]=c+(f-c)*i,n[21]=d+(m-d)*e,n[22]=p+(g-p)*e,n[30]=d+(m-d)*i,n[31]=p+(g-p)*i;break;case iS.VERTICAL:n[3]=u+(d-u)*e,n[4]=c+(p-c)*e,n[12]=_+(m-_)*e,n[13]=f+(g-f)*e,n[21]=u+(d-u)*i,n[22]=c+(p-c)*i,n[30]=_+(m-_)*i,n[31]=f+(g-f)*i;break;default:Nn(2626)}},updateVertexData:function(t,e,i){var r=t.renderData.data,n=t.node._uiProps.uiTransformComp,s=n.width,a=n.height,o=n.anchorX*s,l=n.anchorY*a,h=-o,u=-l,c=s-o,_=a-l,f=0;switch(t.fillType){case iS.HORIZONTAL:f=h+(c-h)*i,h+=(c-h)*e,c=f;break;case iS.VERTICAL:f=u+(_-u)*i,u+=(_-u)*e,_=f;break;default:Nn(2626)}r[0].x=h,r[0].y=u,r[1].x=c,r[1].y=u,r[2].x=h,r[2].y=_,r[3].x=c,r[3].y=_},createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(sS);for(var i,r=e.data,n=hn(r);!(i=n()).done;)i.value.z=0;return e},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(rS);for(var i=t.renderData.floatStride,r=t.renderData.data,s=e.vb,a=0,o=0;o<4;o++){var l=r[o];n.set(nS,l.x,l.y,0),n.transformMat4(nS,nS,rS),s[a=o*i]=nS.x,s[a+1]=nS.y,s[a+2]=nS.z}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1),i.bufferId;var r=i.vertexOffset,n=i.meshBuffer,s=i.meshBuffer.iData,a=n.indexOffset;s[a++]=r,s[a++]=r+1,s[a++]=r+2,s[a++]=r+2,s[a++]=r+1,s[a++]=r+3,n.indexOffset+=6},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,r=e.floatStride,n=5,s=t.color,a=s.r/255,o=s.g/255,l=s.b/255,h=t.node._uiProps.opacity,u=0;u<4;u++)i[n]=a,i[n+1]=o,i[n+2]=l,i[n+3]=h,n+=r}},oS=2*Math.PI,lS=1e-6,hS=new c,uS=new n,cS=[new i,new i,new i,new i],_S=new Array(4),fS=new Array(8),dS=[new i,new i,new i,new i],pS=[new i,new i,new i,new i],mS=new i,gS=[new i,new i,new i,new i];function yS(t,e,i,r,n,s,a){var o=Math.sin(s);o=Math.abs(o)>lS?o:0;var l=Math.cos(s),h=0,u=0;if(0!==(l=Math.abs(l)>lS?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 d=n.x+u*(i-n.y);a[1].x=d,a[1].y=i}}}function vS(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 bS(t,e,i,r,n){var s=_S,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,SS((i.x-a)/(l-a),(i.y-o)/(h-o),t,e),SS((r.x-a)/(l-a),(r.y-o)/(h-o),t,e+1),SS((n.x-a)/(l-a),(n.y-o)/(h-o),t,e+2)}function SS(t,e,i,r){var n=fS,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 AS={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;Gl.packToDynamicAtlas(t,e),this.updateUVs(t);var r,n,s,a,o,l,h,u,c,_=t.renderData;if(_&&e){if(!_.vertDirty)return;var f=_.data,d=t.fillStart,p=t.fillRange;for(p<0&&(d+=p,p=-p);d>=1;)d-=1;for(;d<0;)d+=1;var m=(d*=oS)+(p*=oS);!function(t){var e=t.node._uiProps.uiTransformComp,r=e.width,n=e.height,s=e.anchorX*r,a=e.anchorY*n,o=-s,l=-a,h=r-s,u=n-a,c=_S;c[0]=o,c[1]=l,c[2]=h,c[3]=u;var _=t.fillCenter,f=mS.x=Math.min(Math.max(0,_.x),1)*(h-o)+o,d=mS.y=Math.min(Math.max(0,_.y),1)*(u-l)+l;cS[0].x=cS[3].x=o,cS[1].x=cS[2].x=h,cS[0].y=cS[1].y=l,cS[2].y=cS[3].y=u;for(var p,m=hn(gS);!(p=m()).done;){var g=p.value;i.set(g,0,0)}f!==c[0]&&i.set(gS[0],3,0),f!==c[2]&&i.set(gS[2],1,2),d!==c[1]&&i.set(gS[1],0,1),d!==c[3]&&i.set(gS[3],2,3)}(t),n=(r=e).width,s=r.height,a=r.getRect(),o=0,l=0,h=0,u=0,c=fS,r.isRotated()?(o=a.x/n,l=(a.x+a.height)/n,h=a.y/s,u=(a.y+a.width)/s,c[0]=c[2]=o,c[4]=c[6]=l,c[3]=c[7]=u,c[1]=c[5]=h):(o=a.x/n,l=(a.x+a.width)/n,h=a.y/s,u=(a.y+a.height)/s,c[0]=c[4]=o,c[2]=c[6]=l,c[1]=c[3]=u,c[5]=c[7]=h),yS(_S[0],_S[2],_S[1],_S[3],mS,d,dS),yS(_S[0],_S[2],_S[1],_S[3],mS,d+p,pS);for(var g=0,y=0;y<4;++y){var v=gS[y];if(v)if(p>=oS)_.dataLength=g+3,bS(f,g,mS,cS[v.x],cS[v.y]),g+=3;else{var b=vS(mS,cS[v.x]),S=vS(mS,cS[v.y]);S<b&&(S+=oS),b-=oS,S-=oS;for(var A=0;A<3;++A)b>=m||(b>=d?(_.dataLength=g+3,bS(f,g,mS,cS[v.x],S>=m?pS[y]:cS[v.y]),g+=3):S>d&&(S<=m?(_.dataLength=g+3,bS(f,g,mS,dS[y],cS[v.y]),g+=3):(_.dataLength=g+3,bS(f,g,mS,dS[y],pS[y]),g+=3))),b+=oS,S+=oS}}0===g&&(_.dataLength=0),_.resize(g,g),_.updateRenderData(t,e)}},createQuadIndices:function(t){eS=null,eS=new Uint16Array(t);for(var e=0,i=0;i<t;i++)eS[e++]=i},fillBuffers:function(t){var e=t.node,i=t.renderData,r=i.chunk;(e.hasChangedFlags||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,r),i.vertDirty=!1),this.updateColorLate(t),r.bufferId;for(var n=r.vertexOffset,s=r.meshBuffer,a=r.meshBuffer.iData,o=s.indexOffset,l=0;l<i.indexCount;l++)a[o+l]=n+l;s.indexOffset+=i.indexCount,s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,r=e.data,n=e.chunk.vb,s=0;s<r.length;s++){var a=s*i;n[a+3]=r[s].u,n[a+4]=r[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(hS);for(var i=t.renderData,r=i.floatStride,s=t.renderData.data,a=e.vb,o=i.vertexCount,l=0,h=0;h<o;h++){var u=s[h];n.set(uS,u.x,u.y,0),n.transformMat4(uS,uS,hS),a[l+0]=uS.x,a[l+1]=uS.y,a[l+2]=uS.z,a[l+3]=u.u,a[l+4]=u.v,l+=r}},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,r=e.floatStride,n=e.vertexCount,s=5,a=t.color,o=a.r/255,l=a.g/255,h=a.b/255,u=t.node._uiProps.opacity,c=0;c<n;c++)i[s]=o,i[s+1]=l,i[s+2]=h,i[s+3]=u,s+=r},updateColor:function(){}},TS=[],CS=0;CS<4;CS++)TS.push(new n);for(var xS=Uint16Array.from([0,1,2,1,3,2]),wS={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(4,6),e.vertexRow=2,e.vertexCol=2,e.chunk.setIndexBuffer(xS),e},updateRenderData:function(t){var e=t.spriteFrame;Gl.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},updateWorldVerts:function(t,e){for(var i=t.renderData,r=e.vb,s=i.data,a=t.node.worldMatrix,o=i.floatStride,l=TS[0],h=0,u=0;u<s.length;u++){var c=s[u];n.set(l,c.x,c.y,0),n.transformMat4(l,l,a),h=u*o,r[h++]=l.x,r[h++]=l.y,r[h++]=l.z}},fillBuffers:function(t){if(null!==t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVerts(t,i),e.vertDirty=!1),i.bufferId;for(var r=i.vertexOffset,n=i.meshBuffer,s=i.meshBuffer.iData,a=n.indexOffset,o=0;o<e.vertexRow-1;o++)for(var l=0;l<e.vertexCol-1;l++){var h=r+o*e.vertexCol+l;s[a++]=h,s[a++]=h+1,s[a++]=h+e.vertexCol,s[a++]=h+1,s[a++]=h+1+e.vertexCol,s[a++]=h+e.vertexCol,n.indexOffset+=6}}},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=_.originalSize,d=n/f.width,p=s/f.height,m=_.trimmedBorder;l=m.x*d-a,h=m.z*p-o,u=n+m.y*d-a,c=s+m.w*p-o}r[0].x=l,r[0].y=h,r[1].x=u,r[1].y=h,r[2].x=l,r[2].y=c,r[3].x=u,r[3].y=c,e.vertDirty=!0}},updateUVs:function(t){if(t.spriteFrame){var e=t.renderData.chunk.vb,i=t.spriteFrame.uv;e[3]=i[0],e[4]=i[1],e[12]=i[2],e[13]=i[3],e[21]=i[4],e[22]=i[5],e[30]=i[6],e[31]=i[7]}},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,r=5,n=t.color,s=n.r/255,a=n.g/255,o=n.b/255,l=n.a/255,h=0;h<4;h++,r+=e.floatStride)i[r]=s,i[r+1]=a,i[r+2]=o,i[r+3]=l}},ES=new n,BS=new c,RS=[],DS=0;DS<4;DS++)RS.push({x:0,y:0,z:0,u:0,v:0,color:new y});for(var MS={createData:function(t){var e=t.requestRenderData();return e.dataLength=16,e.resize(16,54),e.vertexRow=4,e.vertexCol=4,this.QUAD_INDICES=new Uint16Array(54),this.createQuadIndices(4,4),e.chunk.setIndexBuffer(this.QUAD_INDICES),e},createQuadIndices:function(t,e){for(var i=0,r=0;r<t-1;r++)for(var n=0;n<e-1;n++){var s=r*e+n;this.QUAD_INDICES[i++]=s,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+e,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+1+e,this.QUAD_INDICES[i++]=s+e}},updateRenderData:function(t){var e=t.spriteFrame;Gl.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},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,d=s-c-_,p=n/(h+u),m=s/(c+_);p=Number.isNaN(p)||p>1?1:p,m=Number.isNaN(m)||m>1?1:m,f=f<0?0:f,d=d<0?0:d,RS[0].x=-a,RS[0].y=-o,RS[1].x=h*p-a,RS[1].y=_*m-o,RS[2].x=RS[1].x+f,RS[2].y=RS[1].y+d,RS[3].x=n-a,RS[3].y=s-o;for(var g=0;g<e.vertexRow;g++)for(var y=0;y<e.vertexCol;y++){var v=g*e.vertexCol+y;v<e.dataLength&&g<RS.length&&y<RS.length&&(i[v].x=RS[y].x,i[v].y=RS[g].y)}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t.node.hasChangedFlags||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1),i.bufferId;for(var r=i.vertexOffset,n=i.meshBuffer,s=i.meshBuffer.iData,a=n.indexOffset,o=0;o<3;++o)for(var l=0;l<3;++l){var h=r+4*o+l;s[a++]=h,s[a++]=h+1,s[a++]=h+4,s[a++]=h+1,s[a++]=h+5,s[a++]=h+4}n.indexOffset=a},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(BS);for(var i=t.renderData,r=i.floatStride,s=i.data,a=e.vb,o=0,l=0;l<4;++l)for(var h=s[4*l],u=0;u<4;++u){var c=s[u];n.set(ES,c.x,h.y,0),n.transformMat4(ES,ES,BS),o=(4*l+u)*r,a[o++]=ES.x,a[o++]=ES.y,a[o++]=ES.z}},updateUVs:function(t){if(t.spriteFrame)for(var e=t.renderData,i=e.chunk.vb,r=e.floatStride,n=t.spriteFrame.uvSliced,s=3,a=0;a<16;a++)i[s]=n[a].u,i[s+1]=n[a].v,s+=r},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,r=e.floatStride,n=5,s=t.color,a=s.r/255,o=s.g/255,l=s.b/255,h=t.node._uiProps.opacity,u=0;u<16;u++)i[n]=a,i[n+1]=o,i[n+2]=l,i[n+3]=h,n+=r}},PS=[],IS=0;IS<4;IS++)PS.push(new n);var OS,FS,LS,kS,VS,NS,GS,zS,US=new c,HS=new n,XS=0,WS=[];function jS(t){return t&&(t.insetTop>0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var YS={createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.renderData,i=t.spriteFrame;if(i&&e&&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,d=s-u-c;f=f>0?f:0,d=d>0?d:0;var p=0===h?f:f/h,m=0===_?d:d/_,g=jS(i),y=Math.ceil(m+g),v=Math.ceil(p+g);e.dataLength=4*y*v,this.updateVerts(t,f,d,y,v),e.vertexCount!==y*v*4&&t.renderEntity&&(t.renderEntity.colorDirty=!0),e.resize(y*v*4,y*v*6),e.updateRenderData(t,i)}},createQuadIndices:function(t){if(t%6==0){var e=t/6;zS=null,zS=new Uint16Array(t);for(var i=0,r=0;r<e;r++)zS[i++]=0+4*r,zS[i++]=1+4*r,zS[i++]=2+4*r,zS[i++]=1+4*r,zS[i++]=3+4*r,zS[i++]=2+4*r}else console.error("illegal index count!")},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},fillBuffers:function(t){var e=t.node,i=t.renderData,r=i.chunk;(e.hasChangedFlags||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,r),i.vertDirty=!1),this.updateColorLate(t),r.bufferId;for(var n=r.vertexOffset,s=r.meshBuffer,a=r.meshBuffer.iData,o=s.indexOffset,l=0;l<i.indexCount;l+=6)a[o++]=n,a[o++]=n+1,a[o++]=n+2,a[o++]=n+1,a[o++]=n+3,a[o++]=n+2,n+=4,s.indexOffset+=6;s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,r=e.data,n=e.chunk.vb,s=0;s<r.length;s++){var a=s*i;n[a+3]=r[s].u,n[a+4]=r[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(US);for(var i=t.renderData,r=i.floatStride,s=i.data,a=e.vb,o=0;o<s.length;o++){n.set(HS,s[o].x,s[o].y,s[o].z),n.transformMat4(HS,HS,US);var l=o*r;a[l]=HS.x,a[l+1]=HS.y,a[l+2]=HS.z}this.updateWorldUVData(t)},updateVerts:function(t,e,i,r,n){var s,a,o=t.node._uiProps.uiTransformComp,l=t.renderData.data,h=t.spriteFrame,u=h.rect,c=Math.abs(o.width),_=Math.abs(o.height),f=o.anchorX*c,d=o.anchorY*_,p=h.insetLeft,m=h.insetRight,g=u.width-p-m,v=h.insetTop,b=h.insetBottom,S=u.height-v-b,A=o.width/(p+m)>1?1:o.width/(p+m),T=o.height/(v+b)>1?1:o.height/(v+b);s=g>0?Math.floor(1e3*e)/1e3%g==0?g:e%g:e,a=S>0?Math.floor(1e3*i)/1e3%S==0?S:i%S:i,XS=Math.max(r+1,n+1);for(var C=0;C<XS;C++)WS.push({x:0,y:0,z:0,u:0,v:0,color:new y});var x=jS(h);if(0===x)for(var w=0;w<XS;w++)WS[w].x=w>=n?c-f:w*g-f,WS[w].y=w>=r?_-d:w*S-d;else for(var E=0;E<XS;E++)0===E?WS[E].x=-f:1===E?WS[E].x=p*A-f:E>1&&E<n-1?WS[E].x=g>0?p*A-f+g*(E-1):p+e-f:E===n-1?WS[E].x=p*A-f+s+g*(E-2):E>=n&&(WS[E].x=Math.min(p+e+m,c)-f),0===E?WS[E].y=-d:1===E?WS[E].y=b*T-d:E>1&&E<r-1?WS[E].y=S>0?b*T-d+S*(E-1):b+i-d:E===r-1?WS[E].y=b*T-d+a+S*(E-2):E>=r&&(WS[E].y=Math.min(b+i+v,_)-d);for(var B=0,R=0,D=0,M=0,P=0;P<r;++P){D=WS[P].y,M=WS[P+1].y;for(var I=0;I<n;++I){B=WS[I].x,R=WS[I+1].x;var O=4*(P*n+I);l[O].x=B,l[O].y=D,l[O+1].x=R,l[O+1].y=D,l[O+2].x=B,l[O+2].y=M,l[O+3].x=R,l[O+3].y=M}}var F=h.rotated,L=(h.uv,h.uvSliced);OS=L[0],FS=L[1],LS=L[2],kS=L[3],VS=L[4],NS=L[8],GS=L[12];for(var k=0,V=0,N=0===g?e:e/g,G=0===S?i:i/S,z=[],U=[],H=0;H<r;++H){V=i>S?i>=(x>0?H:H+1)*S?1:G%1:G;for(var X=0;X<n;++X){k=e>g?e>=(x>0?X:X+1)*g?1:N%1:N,F?(0===x?(z[0]=VS.u,z[1]=VS.u,z[2]=VS.u+(NS.u-VS.u)*V,U[0]=FS.v,U[1]=FS.v+(LS.v-FS.v)*k,U[2]=FS.v):(0===H?(z[0]=OS.u,z[1]=OS.u,z[2]=VS.u):H<r-1?(z[0]=VS.u,z[1]=VS.u,z[2]=VS.u+(NS.u-VS.u)*V):H===r-1&&(z[0]=NS.u,z[1]=NS.u,z[2]=GS.u),0===X?(U[0]=OS.v,U[1]=FS.v,U[2]=OS.v):X<n-1?(U[0]=FS.v,U[1]=FS.v+(LS.v-FS.v)*k,U[2]=FS.v):X===n-1&&(U[0]=LS.v,U[1]=kS.v,U[2]=LS.v)),z[3]=z[2],U[3]=U[1]):(0===x?(z[0]=FS.u,z[1]=FS.u+(LS.u-FS.u)*k,z[2]=FS.u,U[0]=VS.v,U[1]=VS.v,U[2]=VS.v+(NS.v-VS.v)*V):(0===X?(z[0]=OS.u,z[1]=FS.u,z[2]=OS.u):X<n-1?(z[0]=FS.u,z[1]=FS.u+(LS.u-FS.u)*k,z[2]=FS.u):X===n-1&&(z[0]=LS.u,z[1]=kS.u,z[2]=LS.u),0===H?(U[0]=OS.v,U[1]=OS.v,U[2]=VS.v):H<r-1?(U[0]=VS.v,U[1]=VS.v,U[2]=VS.v+(NS.v-VS.v)*V):H===r-1&&(U[0]=NS.v,U[1]=NS.v,U[2]=GS.v)),z[3]=z[1],U[3]=U[2]);var W=4*(H*n+X);l[W].u=z[0],l[W].v=U[0],l[W+1].u=z[1],l[W+1].v=U[1],l[W+2].u=z[2],l[W+2].v=U[2],l[W+3].u=z[3],l[W+3].v=U[3]}}},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,r=e.floatStride,n=e.vertexCount,s=5,a=t.color,o=a.r/255,l=a.g/255,h=a.b/255,u=t.node._uiProps.opacity,c=0;c<n;c++)i[s]=o,i[s+1]=l,i[s+2]=h,i[s+3]=u,s+=r},updateColor:function(){}},qS=im.Type,KS=im.FillType,JS=t("spriteAssembler",{getAssembler:function(t){var e=wS,i=t;switch(i.type){case qS.SLICED:e=MS;break;case qS.TILED:e=YS;break;case qS.FILLED:e=i.fillType===KS.RADIAL?AS:aS}return e}});im.Assembler=JS;var ZS=[$s.EventType.MOUSE_DOWN,$s.EventType.MOUSE_MOVE,$s.EventType.MOUSE_UP,$s.EventType.MOUSE_WHEEL],QS=[$s.EventType.TOUCH_START,$s.EventType.TOUCH_MOVE,$s.EventType.TOUCH_END,$s.EventType.TOUCH_CANCEL],$S=(new(function(){function t(){this.priority=ta.UI,this._isListDirty=!1,this._inDispatchCount=0,this._pointerEventProcessorList=[],this._processorListToAdd=[],this._processorListToRemove=[],ea._registerEventDispatcher(this),Gs.callbacksInvoker.on(ia.ADD_POINTER_EVENT_PROCESSOR,this.addPointerEventProcessor,this),Gs.callbacksInvoker.on(ia.REMOVE_POINTER_EVENT_PROCESSOR,this.removePointerEventProcessor,this),Gs.callbacksInvoker.on(ia.MARK_LIST_DIRTY,this._markListDirty,this)}var e=t.prototype;return e.dispatchEvent=function(t){var e=t.type;return QS.includes(e)?this.dispatchEventTouch(t):!ZS.includes(e)||this.dispatchEventMouse(t)},e.addPointerEventProcessor=function(t){0===this._inDispatchCount?this._pointerEventProcessorList.includes(t)||(this._pointerEventProcessorList.push(t),this._isListDirty=!0):this._processorListToAdd.includes(t)||this._processorListToAdd.push(t),pn.array.remove(this._processorListToRemove,t)},e.removePointerEventProcessor=function(t){0===this._inDispatchCount?(pn.array.remove(this._pointerEventProcessorList,t),this._isListDirty=!0):this._processorListToRemove.includes(t)||this._processorListToRemove.push(t),pn.array.remove(this._processorListToAdd,t)},e.dispatchEventMouse=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,r=!0,n=0;n<i;++n){var s=e[n];if(s.isEnabled&&s.shouldHandleEventMouse&&s._handleEventMouse(t)){if(r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},e.dispatchEventTouch=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,r=t.touch,n=!0,s=0;s<i;++s){var a=e[s];if(a.isEnabled&&a.shouldHandleEventTouch)if(t.type===ra.TOUCH_START){if(a._handleEventTouch(t)){if(a.claimedTouchIdList.push(r.getID()),n=!1,!t.preventSwallow)break;t.preventSwallow=!1}}else if(a.claimedTouchIdList.length>0){var o=a.claimedTouchIdList.indexOf(r.getID());if(-1!==o){if(a._handleEventTouch(t),t.type!==ra.TOUCH_END&&t.type!==ra.TOUCH_CANCEL||pn.array.removeAt(a.claimedTouchIdList,o),n=!1,!t.preventSwallow)break;t.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),n},e._updatePointerEventProcessorList=function(){for(var t=this._processorListToAdd,e=t.length,i=0;i<e;++i)this.addPointerEventProcessor(t[i]);t.length=0;for(var r=this._processorListToRemove,n=r.length,s=0;s<n;++s)this.removePointerEventProcessor(r[s]);r.length=0},e._sortPointerEventProcessorList=function(){if(this._isListDirty){for(var t=this._pointerEventProcessorList,e=t.length,i=0;i<e;++i){var r=t[i],n=r.node;if(n._uiProps){var s=n._uiProps.uiTransformComp;r.cachedCameraPriority=s.cameraPriority}}t.sort(this._sortByPriority),this._isListDirty=!1}},e._sortByPriority=function(t,e){var i=t.node,r=e.node;if(!(e&&r&&r.activeInHierarchy&&r._uiProps.uiTransformComp))return-1;if(!(t&&i&&i.activeInHierarchy&&i._uiProps.uiTransformComp))return 1;if(t.cachedCameraPriority!==e.cachedCameraPriority)return e.cachedCameraPriority-t.cachedCameraPriority;for(var n=i,s=r,a=!1;(null===(o=n.parent)||void 0===o?void 0:o._id)!==(null===(l=s.parent)||void 0===l?void 0:l._id);){var o,l,h,u,c,_;n=null===(null===(h=n)||void 0===h||null===(u=h.parent)||void 0===u?void 0:u.parent)?(a=!0)&&r:n&&n.parent,s=null===(null===(c=s)||void 0===c||null===(_=c.parent)||void 0===_?void 0:_.parent)?(a=!0)&&i:s&&s.parent}if(n._id===s._id){if(n._id===r._id)return-1;if(n._id===i._id)return 1}var f=n?n.getSiblingIndex():0,d=s?s.getSiblingIndex():0;return a?f-d:d-f},e._markListDirty=function(){this._isListDirty=!0},t}()),new Pe(null)),tA=new c,eA=t("UI",function(){function t(t){var e=this;this.device=void 0,this._screens=[],this._staticVBBuffer=null,this._bufferAccessors=new Map,this._drawBatchPool=void 0,this._batches=void 0,this._currBID=-1,this._indexStart=0,this._emptyMaterial=new cn,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._currIsStatic=!1,this._currHash=0,this._pOpacity=1,this._opacityDirty=0,this._descriptorSetCache=new rA,this._meshDataArray=[],this._root=t,this.device=t.device,this._batches=new W(64),this._drawBatchPool=new H((function(){return new Oy}),128,(function(t){return t.destroy(e)}))}var e=t.prototype;return e.initialize=function(){return!0},e.destroy=function(){for(var t=0;t<this._batches.length;t++)this._batches.array[t]&&this._batches.array[t].destroy(this);this._batches.destroy(),this._bufferAccessors.forEach((function(t){t.destroy()})),this._bufferAccessors.clear(),this._drawBatchPool&&this._drawBatchPool.destroy(),this._descriptorSetCache.destroy(),ju.sharedManager.destroy()},e.syncRootNodesToNative=function(){},e.addScreen=function(t){this._screens.push(t),this._screens.sort(this._screenSort)},e.removeScreen=function(t){var e=this._screens.indexOf(t);-1!==e&&this._screens.splice(e,1)},e.sortScreens=function(){this._screens.sort(this._screenSort)},e.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},e.update=function(){for(var t=this._screens,e=0,i=0;i<t.length;++i){var r=t[i],n=r._getRenderScene();if(r.enabledInHierarchy&&n){this._opacityDirty=0,this._pOpacity=1,this.walk(r.node),this.autoMergeBatches(this._currComponent),this.resetRenderStates();var s=0;if(this._batches.length>e)for(;e<this._batches.length;++e){var a=this._batches.array[e];if(a.model)for(var o=a.model.subModels,l=0;l<o.length;l++)o[l].priority=s++;else a.descriptorSet=this._descriptorSetCache.getDescriptorSet(a);n.addBatch(a)}}}},e.uploadBuffers=function(){this._batches.length>0&&(this._meshDataArray.forEach((function(t){t.uploadBuffers()})),this._bufferAccessors.forEach((function(t){t.uploadBuffers(),t.reset()})),this._descriptorSetCache.update())},e.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._bufferAccessors.forEach((function(t){t.reset()})),this._meshDataArray.forEach((function(t){t.freeIAPool()})),this._meshDataArray.length=0,this._staticVBBuffer=null,this._currBID=-1,this._indexStart=0,this._currHash=0,this._currLayer=0,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currComponent=null,this._currTransform=null,this._batches.clear(),ju.sharedManager.reset()},e.switchBufferAccessor=function(t){void 0===t&&(t=xu);var e=t===xu?36:Bu(t);if(!this._staticVBBuffer||this._staticVBBuffer.vertexFormatBytes!==e){var i=this._bufferAccessors.get(e);i||(i=new ku(this.device,t),this._bufferAccessors.set(e,i)),this._staticVBBuffer=i,this._currBID=-1}return this._staticVBBuffer},e.registerBufferAccessor=function(t,e){this._bufferAccessors.set(t,e)},e.updateBuffer=function(t,e){var i=this.switchBufferAccessor(t);this._currBID!==e&&(this._currBID=e,this._indexStart=i.getMeshBuffer(e).indexOffset)},e.commitComp=function(t,e,i,r,n){var s,a=0,o=-1;if(e&&e.chunk){if(!e.isValid())return;a=e.dataHash,s=e.material,o=e.chunk.bufferId}t.stencilStage=ju.sharedManager.stage;var l=t.stencilStage;this._currHash===a&&0!==a&&this._currMaterial===s&&this._currDepthStencilStateStage===l||(this.autoMergeBatches(this._currComponent),e&&!e._isMeshBuffer&&this.updateBuffer(e.vertexFormat,o),this._currRenderData=e,this._currHash=e?e.dataHash:0,this._currComponent=t,this._currTransform=n,this._currMaterial=t.getRenderMaterial(0),this._currDepthStencilStateStage=l,this._currLayer=t.node.layer,i?(this._currTexture=i.getGFXTexture(),this._currSampler=i.getGFXSampler(),this._currTextureHash=i.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=null,this._currSampler=null,this._currTextureHash=0,this._currSamplerHash=0)),r.fillBuffers(t,this)},e.commitIA=function(t,e,i,r,n){var s;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var a=0;t&&(t.stencilStage=ju.sharedManager.stage,s=null!==t.customMaterial?ju.sharedManager.getStencilStage(t.stencilStage,r):ju.sharedManager.getStencilStage(t.stencilStage),a=ju.sharedManager.getStencilHash(t.stencilStage));var o=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();o.visFlags=t.node.layer,o.inputAssembler=e,o.useLocalData=n||null,i&&(o.texture=i.getGFXTexture(),o.sampler=i.getGFXSampler(),o.textureHash=i.getHash(),o.samplerHash=o.sampler.hash),o.fillPasses(r||null,s,a,null),this._batches.push(o)},e.commitModel=function(t,e,i){var r;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var n=0;i&&(t.stencilStage!==Vu.ENABLED&&t.stencilStage!==Vu.DISABLED||(t.stencilStage=ju.sharedManager.stage),r=ju.sharedManager.getStencilStage(t.stencilStage,i),n=ju.sharedManager.getStencilHash(t.stencilStage));var s=Er.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.visFlags=t.node.layer,o.model=e,o.texture=null,o.sampler=null,o.useLocalData=null,r||(r=null),o.fillPasses(i,r,n,l.patches),o.inputAssembler=l.inputAssembler,o.model.visFlags=o.visFlags,o.descriptorSet=l.descriptorSet,this._batches.push(o)}},e.setupStaticBatch=function(t,e){this.finishMergeBatches(),this._staticVBBuffer=e,this.currStaticRoot=t},e.endStaticBatch=function(){this.finishMergeBatches(),this.currStaticRoot=null,this._staticVBBuffer=null,this.switchBufferAccessor()},e.commitStaticBatch=function(t){this._batches.concat(t.drawBatchList),this.finishMergeBatches()},e.autoMergeBatches=function(t){var e=this._currMaterial;if(e){var i,r=this._currRenderData,n=this._staticVBBuffer;if(r&&r._isMeshBuffer)i=r.requestIA(this.device),-1===this._meshDataArray.indexOf(r)&&this._meshDataArray.push(r);else if(n){var s=this._currBID,a=n.getMeshBuffer(s);if(!a)return;var o=a.indexOffset-this._indexStart;if(o<=0)return;gn(this._indexStart<a.indexOffset),a.setDirty(),(i=a.requireFreeIA(this.device)).firstIndex=this._indexStart,i.indexCount=o,this._indexStart=a.indexOffset}if(this._currBID=-1,i){var l,h=0;t&&(l=null!==t.customMaterial?ju.sharedManager.getStencilStage(t.stencilStage,e):ju.sharedManager.getStencilStage(t.stencilStage),h=ju.sharedManager.getStencilHash(t.stencilStage));var u=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();u.visFlags=this._currLayer,u.texture=this._currTexture,u.sampler=this._currSampler,u.inputAssembler=i,u.useLocalData=this._currTransform,u.textureHash=this._currTextureHash,u.samplerHash=this._currSamplerHash,u.fillPasses(e,l,h,null),this._batches.push(u)}}},e.forceMergeBatches=function(t,e,i){this._currMaterial=t,e?(this._currTexture=e.getGFXTexture(),this._currSampler=e.getGFXSampler(),this._currTextureHash=e.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=this._currSampler=null,this._currTextureHash=this._currSamplerHash=0),this._currLayer=i.node.layer,this.autoMergeBatches(i)},e.resetRenderStates=function(){this._currMaterial=this._emptyMaterial,this._currRenderData=null,this._currTexture=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},e.finishMergeBatches=function(){this.autoMergeBatches(),this.resetRenderStates()},e.flushMaterial=function(t){this._currMaterial=t},e.walk=function(t,e){if(void 0===e&&(e=0),t.activeInHierarchy){var i=t.children,r=t._uiProps,n=r.uiComp,s=this._pOpacity,a=s,o=n&&n.color?n.color.a/255:1;if(this._pOpacity=a*=o*r.localOpacity,r._opacity=a,r.colorDirty&&this._opacityDirty++,n&&n.enabledInHierarchy&&n.fillBuffers(this),this._opacityDirty&&n&&!n.useVertexOpacity&&n.renderData&&n.renderData.vertexCount>0){!function(t,e){for(var i,r,n,s=t.vertexFormat,a=t.chunk.vb,o=0,l=0;l<s.length;++l){if(i=s[l],(r=Xe[i.format]).hasAlpha)if(n=t.floatStride,r.size/r.count==1)for(var h=~~T(Math.round(255*e),0,255),u=o;u<a.length;u+=n)a[u]=(4294967040&a[u]|h)>>>0;else if(r.size/r.count==4)for(var c=o+3;c<a.length;c+=n)a[c]=e;o+=r.size>>2}}(n.renderData,a);var l=n.renderData.getMeshBuffer();l&&l.setDirty()}if(i.length>0&&!t._static)for(var h=0;h<i.length;++h){var u=i[h];this.walk(u,e)}r.colorDirty&&(this._opacityDirty--,r.colorDirty=!1),this._pOpacity=s,n&&n.enabledInHierarchy&&n.postUpdateAssembler(this),e+=1}},e._screenSort=function(t,e){return t.node.getSiblingIndex()-e.node.getSiblingIndex()},e._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},e.syncMeshBuffersToNative=function(){},Ur(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"currBufferAccessor",get:function(){return this._staticVBBuffer||(this._staticVBBuffer=this.switchBufferAccessor()),this._staticVBBuffer}},{key:"batches",get:function(){return this._batches}},{key:"currStaticRoot",set:function(t){this._currStaticRoot=t}},{key:"currIsStatic",set:function(t){this._currIsStatic=t}}]),t}()),iA=function(){function t(){this._descriptorSet=null,this._transform=null,this._textureHash=0,this._samplerHash=0,this._localBuffer=null,this._transformUpdate=!0;var t=Ci.gfxDevice;this._localData=new Float32Array(na.COUNT),this._localBuffer=t.createBuffer(new ee(rt.UNIFORM|rt.TRANSFER_DST,at.HOST|at.DEVICE,na.SIZE,na.SIZE))}var e=t.prototype;return e.initialize=function(t){var e=Ci.gfxDevice;this._transform=t.useLocalData,this._textureHash=t.textureHash,this._samplerHash=t.samplerHash,$S.layout=t.passes[0].localSetLayout,this._descriptorSet=e.createDescriptorSet($S),this._descriptorSet.bindBuffer(na.BINDING,this._localBuffer);var i=js.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.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._descriptorSet&&(this._descriptorSet.destroy(),this._descriptorSet=null),this._localData=null},e.isValid=function(){return this._transform&&this._transform.isValid},e.uploadLocalData=function(){var t=this._transform;if((t.hasChangedFlags||t._dirtyFlags)&&(t.updateWorldTransform(),this._transformUpdate=!0),this._transformUpdate){var e=t.worldMatrix;c.toArray(this._localData,e,na.MAT_WORLD_OFFSET),c.inverseTranspose(tA,e);var i=c.determinant(tA),r=1/Math.sqrt(i);c.multiplyScalar(tA,tA,r),c.toArray(this._localData,tA,na.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._transformUpdate=!1}},Ur(t,[{key:"descriptorSet",get:function(){return this._descriptorSet}}]),t}(),rA=function(){function t(){this._descriptorSetCache=new Map,this._dsCacheHashByTexture=new Map,this._localDescriptorSetCache=[],this._localCachePool=void 0,this._localCachePool=new H((function(){return new iA}),16,(function(t){return t.destroy()}))}var e=t.prototype;return e.getDescriptorSet=function(t){var e;if(Er.director.root,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.descriptorSet}var a=this._localCachePool.alloc();return a.initialize(t),this._localDescriptorSetCache.push(a),a.descriptorSet}if(e=t.textureHash^t.samplerHash,this._descriptorSetCache.has(e))return this._descriptorSetCache.get(e);$S.layout=t.passes[0].localSetLayout;var o=Ci.gfxDevice.createDescriptorSet($S),l=js.SAMPLER_SPRITE;return o.bindTexture(l,t.texture),o.bindSampler(l,t.sampler),o.update(),this._descriptorSetCache.set(e,o),this._dsCacheHashByTexture.set(t.textureHash,e),o},e.update=function(){var t=this._localDescriptorSetCache,e=[];t.forEach((function(i){if(i.isValid())i.uploadLocalData();else{i.reset();var r=t.indexOf(i);e.push(r)}}));for(var i=e.length-1;i>=0;i--)t.splice(e[i],1)},e.reset=function(){var t=this;this._localDescriptorSetCache.forEach((function(e){t._localCachePool.free(e)})),this._localDescriptorSetCache.length=0},e.releaseDescriptorSetCache=function(t){var e=this._dsCacheHashByTexture.get(t);e&&this._descriptorSetCache.has(e)&&(this._descriptorSetCache.get(e).destroy(),this._descriptorSetCache.delete(e),this._dsCacheHashByTexture.delete(t))},e.destroy=function(){this._descriptorSetCache.forEach((function(t){t.destroy()})),this._descriptorSetCache.clear(),this._dsCacheHashByTexture.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy()},t}();Er.internal.Batcher2D=eA,t("UIDrawBatch",function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e}(Oy)),Pr(Iu.prototype,"MeshBuffer",["byteStart","vertexStart","indicesStart","request"].map((function(t){return{name:t,suggest:"please use meshBuffer.accessor."+t+" instead"}}))),wr(Iu.prototype,"MeshBuffer",[{name:"indicesOffset",newName:"indexOffset"}]),Dr(Iu.prototype,"MeshBuffer",[{name:"vertexBuffers"},{name:"indexBuffer"}]),wr(eA.prototype,"Batcher2D",[{name:"currBufferBatch",newName:"currBufferAccessor"},{name:"acquireBufferBatch",newName:"switchBufferAccessor"}]),Dr(Ic.prototype,"MeshRenderData",[{name:"formatByte"},{name:"byteStart"},{name:"byteCount"}]),wr(Ic.prototype,"MeshRenderData",[{name:"indicesStart",newName:"indexStart"}]),t("QuadRenderData",function(t){function e(e){var i;return i=t.call(this,e)||this,Rn(9006),i}return on(e,t),e}(Ic));var nA,sA=null,aA=-1,oA="BES bswy:->@123丁ぁᄁ",lA=Object.create(null),hA=[],uA=3e3;function cA(){for(var t=!0,e=Date.now(),i=hA.length-1;i>=0;i--){var r=hA[i],n=r.fontFamilyName;if(e-r.startTime>uA)Rn(4933,n),r.onComplete(null,n),hA.splice(i,1);else{var s=r.refWidth,a="40px "+n;sA.font=a,s!==hu(sA,oA,a)?(hA.splice(i,1),r.onComplete(null,n)):t=!1}}t&&(clearInterval(aA),aA=-1)}function _A(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(lA[r])i(null,r);else{if(!sA){var n=document.createElement("canvas");n.width=100,n.height=100,sA=n.getContext("2d")}var s=hu(sA,oA,"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=document.createElement("div"),h=l.style;if(h.fontFamily=r,l.innerHTML=".",h.position="absolute",h.left="-100px",h.top="-100px",document.body.appendChild(l),function(){if(void 0===nA)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);nA=t?parseInt(t[1],10)>42:!e}else nA=!1;return nA}())!function(t,e,i){var r=new Promise((function(i,r){!function n(){Date.now()-t>=uA?r():document.fonts.load("40px "+e).then((function(t){t.length>=1?i():setTimeout(n,100)}),(function(){r()}))}()})),n=null,s=new Promise((function(t,e){n=setTimeout(e,uA)}));Promise.race([s,r]).then((function(){n&&(clearTimeout(n),n=null),i(null,e)}),(function(){Rn(4933,e),i(null,e)}))}(Date.now(),r,i);else{var u={fontFamilyName:r,refWidth:s,onComplete:i,startTime:Date.now()};hA.push(u),-1===aA&&(aA=setInterval(cA,100))}lA[r]=a}}function fA(t,e,i,r){var n=new Wh;n._nativeUrl=t,n._nativeAsset=e,r(null,n)}Gr.register({".font":_A,".eot":_A,".ttf":_A,".woff":_A,".svg":_A,".ttc":_A}),$r.register({".font":fA,".eot":fA,".ttf":fA,".woff":fA,".svg":fA,".ttc":fA}),Er.UI={MeshBuffer:Iu,spriteAssembler:JS,graphicsAssembler:Sv,labelAssembler:Yb,RenderData:Pc,MeshRenderData:Ic};var dA,pA,mA,gA,yA,vA,bA,SA,AA,TA,CA,xA,wA,EA,BA,RA,DA,MA,PA,IA,OA,FA,LA,kA,VA,NA,GA,zA,UA,HA,XA,WA,jA,YA,qA,KA,JA,ZA,QA,$A,tT,eT,iT,rT,nT,sT,aT,oT,lT,hT,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)._morphRenderingInstance=null,e._usedMaterials=new Set,e}on(e,t);var i=e.prototype;return i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);if(this._morphRenderingInstance){var r=this._morphRenderingInstance.requiredPatches(e);if(r)return r.concat(null!=i?i:[])}return i},i.initSubModel=function(e,i,r){return t.prototype.initSubModel.call(this,e,i,this._launderMaterial(r))},i.destroy=function(){t.prototype.destroy.call(this),this._morphRenderingInstance=null},i.setSubModelMaterial=function(e,i){return t.prototype.setSubModelMaterial.call(this,e,this._launderMaterial(i))},i.setMorphRendering=function(t){this._morphRenderingInstance=t},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},e}(sr),cT=zs({OFF:0,ON:1}),_T=zs({OFF:0,ON:1}),fT=(dA=En("cc.ModelLightmapSettings"),pA=oa("_recieveShadow"),dA((CA=function(){function t(){Mn(this,"texture",yA,this),Mn(this,"uvParam",vA,this),Mn(this,"_bakeable",bA,this),Mn(this,"_castShadow",SA,this),Mn(this,"_receiveShadow",AA,this),Mn(this,"_lightmapSize",TA,this)}return Ur(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}(),yA=Dn((gA=CA).prototype,"texture",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),vA=Dn(gA.prototype,"uvParam",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new a}}),bA=Dn(gA.prototype,"_bakeable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),SA=Dn(gA.prototype,"_castShadow",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),AA=Dn(gA.prototype,"_receiveShadow",[pA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),TA=Dn(gA.prototype,"_lightmapSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),Dn(gA.prototype,"bakeable",[Un],Object.getOwnPropertyDescriptor(gA.prototype,"bakeable"),gA.prototype),Dn(gA.prototype,"castShadow",[Un],Object.getOwnPropertyDescriptor(gA.prototype,"castShadow"),gA.prototype),Dn(gA.prototype,"receiveShadow",[Un],Object.getOwnPropertyDescriptor(gA.prototype,"receiveShadow"),gA.prototype),Dn(gA.prototype,"lightmapSize",[Un],Object.getOwnPropertyDescriptor(gA.prototype,"lightmapSize"),gA.prototype),mA=gA))||mA),dT=function(e){return t({MeshRenderer:e,ModelComponent:e}),e}((xA=En("cc.MeshRenderer"),wA=Qn(),EA=$n(100),BA=ts(),RA=Wn(sa),DA=is(),MA=aa({group:{name:"DynamicShadowSettings",displayOrder:0}}),PA=Wn(sa),IA=is(),OA=aa({group:{name:"DynamicShadowSettings",displayOrder:1}}),FA=Wn(cT),LA=is(),kA=aa({group:{name:"DynamicShadowSettings",displayOrder:2}}),VA=Wn(_T),NA=is(),GA=aa({group:{name:"DynamicShadowSettings",displayOrder:3}}),zA=Wn(sh),UA=is(),HA=cs(),xA(XA=wA(XA=EA(XA=BA(XA=Jn((tT=$A=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"lightmapSettings",jA,Pn(e)),Mn(e,"_mesh",YA,Pn(e)),Mn(e,"_shadowCastingMode",qA,Pn(e)),Mn(e,"_shadowReceivingMode",KA,Pn(e)),Mn(e,"_shadowBias",JA,Pn(e)),Mn(e,"_shadowNormalBias",ZA,Pn(e)),e._subMeshShapesWeights=[],e._modelType=void 0,e._model=null,e._morphInstance=null,Mn(e,"_enableMorph",QA,Pn(e)),e._modelType=sr,e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._mesh&&this._mesh.initialize(),this._validateShapeWeights()||this._initSubMeshShapesWeights(),this._watchMorphInMesh(),this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias()},i.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias()},i.onEnable=function(){t.prototype.onEnable.call(this),this._model||this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._onUpdateLocalShadowBias(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene()},i.onDestroy=function(){this._model&&(Er.director.root.destroyModel(this._model),this._model=null,this._models.length=0),this._morphInstance&&this._morphInstance.destroy()},i.onGeometryChanged=function(){this._model&&this._mesh&&(this._model.createBoundingShape(this._mesh.struct.minPosition,this._mesh.struct.maxPosition),this._model.updateWorldBound(),this._model.onGeometryChanged())},i.getWeight=function(t,e){var i=this._subMeshShapesWeights;gn(t<i.length);var r=this._subMeshShapesWeights[t];return gn(e<r.length),r[e]},i.setWeights=function(t,e){var i=this._subMeshShapesWeights;e>=i.length||i[e].length===t.length&&(i[e]=t.slice(0),this._uploadSubMeshShapesWeights(e))},i.setWeight=function(t,e,i){var r=this._subMeshShapesWeights;if(!(e>=r.length)){var n=r[e];i>=n.length||(n[i]=t,this._uploadSubMeshShapesWeights(e))}},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){var t=this._model;t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model&&(this._mesh&&this._model.createBoundingShape(this._mesh.struct.minPosition,this._mesh.struct.maxPosition),this._model.initLightingmap(this.lightmapSettings.texture,this.lightmapSettings.uvParam),this._updateModelParams(),this._onUpdateLightingmap(),this._onUpdateLocalShadowBias())}},i._createModel=function(){var t=this._morphInstance&&this._modelType===sr?uT:this._modelType,e=this._model=Er.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 uT&&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|=Ws.POSITION,this._model.transform.hasChangedFlags|=Ws.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._onUpdateLocalShadowBias=function(){null!==this.model&&this.model.updateLocalShadowBias(),this.setInstancedAttribute("a_localShadowBias",[this._shadowBias,this._shadowNormalBias])},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(),this._onUpdateLocalShadowBias())},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 os.get("missing-material")},i._onVisibilityChange=function(t){this._model&&(this._model.visFlags=t)},i._updateShadowBias=function(){this._model&&(this._model.shadowBias=this._shadowBias)},i._updateShadowNormalBias=function(){this._model&&(this._model.shadowNormalBias=this._shadowNormalBias)},i._updateCastShadow=function(){this._model&&(this._shadowCastingMode===cT.OFF?this._model.castShadow=!1:(gn(this._shadowCastingMode===cT.ON,"ShadowCastingMode "+this._shadowCastingMode+" is not supported."),this._model.castShadow=!0))},i._updateReceiveShadow=function(){this._model&&(this._shadowReceivingMode===_T.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){this._morphInstance=this._mesh.morphRendering.createInstance();for(var t=this._mesh.struct.primitives.length,e=0;e<t;++e)this._uploadSubMeshShapesWeights(e);this._model&&this._model instanceof uT&&this._model.setMorphRendering(this._morphInstance)}},i._initSubMeshShapesWeights=function(){var t=this._mesh;if(this._subMeshShapesWeights.length=0,t){var e=t.struct.morph;if(e){var i=e.weights;this._subMeshShapesWeights=e.subMeshMorphs.map((function(t){return t?t.weights?t.weights.slice(0):i?(gn(i.length===t.targets.length),i.slice(0)):new Array(t.targets.length).fill(0):[]}))}}},i._validateShapeWeights=function(){var t=this._mesh,e=this._subMeshShapesWeights;if(!t||!t.struct.morph)return 0===e.length;var i=t.struct.morph;return i.subMeshMorphs.length===e.length&&e.every((function(t,e){var r,n,s=t.length;return(null!==(r=null===(n=i.subMeshMorphs[e])||void 0===n?void 0:n.targets.length)&&void 0!==r?r:0)===s}))},i._uploadSubMeshShapesWeights=function(t){var e;null===(e=this._morphInstance)||void 0===e||e.setWeights(t,this._subMeshShapesWeights[t])},Ur(e,[{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._updateShadowBias(),this._onUpdateLocalShadowBias()}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._updateShadowNormalBias(),this._onUpdateLocalShadowBias()}},{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,i=this._mesh=t;null==i||i.initialize(),this._initSubMeshShapesWeights(),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}(Ys),$A.ShadowCastingMode=cT,$A.ShadowReceivingMode=_T,jA=Dn((WA=tT).prototype,"lightmapSettings",[On,Un,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new fT}}),YA=Dn(WA.prototype,"_mesh",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qA=Dn(WA.prototype,"_shadowCastingMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cT.OFF}}),KA=Dn(WA.prototype,"_shadowReceivingMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return _T.ON}}),JA=Dn(WA.prototype,"_shadowBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZA=Dn(WA.prototype,"_shadowNormalBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(WA.prototype,"shadowBias",[RA,DA,MA,hs],Object.getOwnPropertyDescriptor(WA.prototype,"shadowBias"),WA.prototype),Dn(WA.prototype,"shadowNormalBias",[PA,IA,OA,hs],Object.getOwnPropertyDescriptor(WA.prototype,"shadowNormalBias"),WA.prototype),Dn(WA.prototype,"shadowCastingMode",[FA,LA,kA,hs],Object.getOwnPropertyDescriptor(WA.prototype,"shadowCastingMode"),WA.prototype),Dn(WA.prototype,"receiveShadow",[VA,NA,GA,hs],Object.getOwnPropertyDescriptor(WA.prototype,"receiveShadow"),WA.prototype),Dn(WA.prototype,"mesh",[zA,UA],Object.getOwnPropertyDescriptor(WA.prototype,"mesh"),WA.prototype),Dn(WA.prototype,"enableMorph",[HA,hs],Object.getOwnPropertyDescriptor(WA.prototype,"enableMorph"),WA.prototype),QA=Dn(WA.prototype,"_enableMorph",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),XA=WA))||XA)||XA)||XA)||XA)||XA));function pT(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(dT);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(!pT(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 sh,s=new c,a=new c;t.getWorldMatrix(a),c.invert(a,a);for(var o=0;o<i.length;o++){var l=i[o];l.node.getWorldMatrix(s),c.multiply(s,a,s),n.merge(i[o].mesh,s),l.enabled=!1}var h=e.addComponent(dT);return h.mesh=n,h.sharedMaterials=i[0].sharedMaterials,!0},t.unbatchStaticModel=function(t,e){for(var i=t.getComponentsInChildren(dT),r=0;r<i.length;r++)i[r].enabled=!0;var n=e.getComponent(dT);return n&&(n.mesh&&n.mesh.destroyRenderingMesh(),n.destroy()),!0},t}()),wr(sh.prototype,"Mesh.prototype",[{name:"renderingMesh",newName:"renderingSubMeshes"}]),Dr(sh.prototype,"Mesh.prototype",[{name:"hasFlatBuffers"},{name:"destroyFlatBuffers"}]);var mT,gT,yT,vT,bT,ST,AT,TT,CT,xT,wT,ET,BT,RT,DT,MT,PT,IT,OT,FT,LT,kT,VT=t("Skeleton",(eT=En("cc.Skeleton"),iT=Wn([la]),rT=Wn([c]),eT((hT=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,Mn(e,"_joints",aT,Pn(e)),Mn(e,"_bindposes",oT,Pn(e)),Mn(e,"_hash",lT,Pn(e)),e._invBindposes=null,e}on(e,t);var i=e.prototype;return i.destroy=function(){var e,i;return null===(e=null===(i=Er.director.root)||void 0===i?void 0:i.dataPoolManager)||void 0===e||e.releaseSkeleton(this),t.prototype.destroy.call(this)},i.validate=function(){return this.joints.length>0&&this.bindposes.length>0},Ur(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 c;c.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=In(t,666)}return this._hash}}]),e}(Qr),aT=Dn((sT=hT).prototype,"_joints",[iT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),oT=Dn(sT.prototype,"_bindposes",[rT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),lT=Dn(sT.prototype,"_hash",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),nT=sT))||nT));Er.Skeleton=VT,Dr(dT.prototype,"MeshRenderer.prototype",[{name:"enableDynamicBatching"},{name:"recieveShadows"}]),Er.ModelComponent=dT,pn.setClassAlias(dT,"cc.ModelComponent");var NT,GT,zT,UT,HT,XT,WT,jT,YT,qT,KT,JT,ZT,QT,$T,tC,eC,iC,rC,nC,sC,aC,oC,lC,hC,uC,cC,_C,fC,dC,pC,mC,gC,yC,vC,bC,SC,AC,TC,CC,xC,wC,EC,BC,RC,DC,MC,PC,IC,OC,FC,LC,kC,VC,NC,GC,zC,UC,HC,XC,WC,jC,YC,qC,KC,JC,ZC,QC,$C,tx,ex,ix,rx,nx,sx,ax,ox,lx,hx,ux,cx,_x,fx,dx,px,mx,gx,yx,vx,bx,Sx,Ax,Tx,Cx,xx,wx,Ex,Bx,Rx,Dx,Mx,Px,Ix,Ox,Fx,Lx,kx,Vx,Nx,Gx,zx,Ux,Hx,Xx,Wx,jx,Yx,qx,Kx,Jx,Zx,Qx,$x,tw,ew,iw,rw,nw,sw,aw,ow,lw,hw,uw,cw,_w,fw,dw,pw,mw,gw=new n,yw=zs({LUMINOUS_FLUX:0,LUMINANCE:1}),vw=En("cc.StaticLightSettings")((AT=function(){function t(){Mn(this,"_baked",yT,this),Mn(this,"_editorOnly",vT,this),Mn(this,"_bakeable",bT,this),Mn(this,"_castShadow",ST,this)}return Ur(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}(),yT=Dn((gT=AT).prototype,"_baked",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),vT=Dn(gT.prototype,"_editorOnly",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),bT=Dn(gT.prototype,"_bakeable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),ST=Dn(gT.prototype,"_castShadow",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(gT.prototype,"editorOnly",[Un],Object.getOwnPropertyDescriptor(gT.prototype,"editorOnly"),gT.prototype),Dn(gT.prototype,"bakeable",[Un],Object.getOwnPropertyDescriptor(gT.prototype,"bakeable"),gT.prototype),Dn(gT.prototype,"castShadow",[Un],Object.getOwnPropertyDescriptor(gT.prototype,"castShadow"),gT.prototype),mT=gT))||mT,bw=function(e){return t({Light:e,LightComponent:e}),e}((TT=En("cc.Light"),CT=is(),xT=is(),wT=Ls(),ET=is(),BT=Wn(vw),RT=es(),TT((kT=LT=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_color",PT,Pn(e)),Mn(e,"_useColorTemperature",IT,Pn(e)),Mn(e,"_colorTemperature",OT,Pn(e)),Mn(e,"_staticSettings",FT,Pn(e)),e._type=br.UNKNOWN,e._lightType=void 0,e._light=null,e._lightType=Ar,e}on(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=Er.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&&(Er.director.root.recycleLight(this._light),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 br.DIRECTIONAL:t.addDirectionalLight(this._light),t.setMainLight(this._light);break;case br.SPHERE:t.addSphereLight(this._light);break;case br.SPOT:t.addSpotLight(this._light)}}},i._detachFromScene=function(){if(this._light&&this._light.scene){var t=this._light.scene;switch(this._type){case br.DIRECTIONAL:t.removeDirectionalLight(this._light),t.unsetMainLight(this._light);break;case br.SPHERE:t.removeSphereLight(this._light);break;case br.SPOT:t.removeSpotLight(this._light)}}},Ur(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._light&&(gw.x=t.r/255,gw.y=t.g/255,gw.z=t.b/255,this._light.color=gw)}},{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}(ns),LT.Type=br,LT.PhotometricTerm=yw,PT=Dn((MT=kT).prototype,"_color",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),IT=Dn(MT.prototype,"_useColorTemperature",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),OT=Dn(MT.prototype,"_colorTemperature",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 6550}}),FT=Dn(MT.prototype,"_staticSettings",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vw}}),Dn(MT.prototype,"color",[CT],Object.getOwnPropertyDescriptor(MT.prototype,"color"),MT.prototype),Dn(MT.prototype,"useColorTemperature",[xT],Object.getOwnPropertyDescriptor(MT.prototype,"useColorTemperature"),MT.prototype),Dn(MT.prototype,"colorTemperature",[Ns,wT,ET],Object.getOwnPropertyDescriptor(MT.prototype,"colorTemperature"),MT.prototype),Dn(MT.prototype,"staticSettings",[BT,RT],Object.getOwnPropertyDescriptor(MT.prototype,"staticSettings"),MT.prototype),DT=MT))||DT)),Sw=function(e){return t({DirectionalLight:e,DirectionalLightComponent:e}),e}((NT=En("cc.DirectionalLight"),GT=Qn(),zT=ts(),UT=oa("_illuminance"),HT=is(),XT=cs(),WT=aa({group:{name:"DynamicShadowSettings",displayOrder:1}}),jT=Wn(ha),YT=cs(),qT=aa({group:{name:"DynamicShadowSettings",displayOrder:5}}),KT=Wn(_r),JT=cs(),ZT=aa({group:{name:"DynamicShadowSettings",displayOrder:6}}),QT=Wn(sa),$T=cs(),tC=aa({group:{name:"DynamicShadowSettings",displayOrder:7}}),eC=Wn(sa),iC=cs(),rC=aa({group:{name:"DynamicShadowSettings",displayOrder:8}}),nC=Ls(),sC=Wn(sa),aC=cs(),oC=aa({group:{name:"DynamicShadowSettings",displayOrder:9}}),lC=is(),hC=Ls(),uC=Wn(sa),cC=cs(),_C=aa({group:{name:"DynamicShadowSettings",displayOrder:10}}),fC=is(),dC=Ls(),pC=Wn(sa),mC=cs(),gC=aa({group:{name:"DynamicShadowSettings",displayOrder:11}}),yC=is(),vC=Wn(fr),bC=cs(),SC=aa({group:{name:"DynamicShadowSettings",displayOrder:12}}),AC=is(),TC=Wn(ha),CC=cs(),xC=aa({group:{name:"DynamicShadowSettings",displayOrder:13}}),wC=is(),EC=Ls(),BC=Wn(sa),RC=cs(),DC=aa({group:{name:"DynamicShadowSettings",displayOrder:14}}),MC=is(),PC=Wn(dr),IC=cs(),OC=aa({group:{name:"DynamicShadowSettings",displayOrder:15}}),FC=Wn(ha),LC=cs(),kC=aa({group:{name:"DynamicShadowSettings",displayOrder:16}}),VC=Wn(sa),NC=cs(),GC=aa({group:{name:"DynamicShadowSettings",displayOrder:17}}),zC=Wn(sa),UC=cs(),HC=aa({group:{name:"DynamicShadowSettings",displayOrder:18}}),XC=Wn(sa),NT(WC=GT(WC=zT(WC=Jn((hx=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_illuminanceHDR",YC,Pn(e)),Mn(e,"_illuminanceLDR",qC,Pn(e)),Mn(e,"_shadowEnabled",KC,Pn(e)),Mn(e,"_shadowPcf",JC,Pn(e)),Mn(e,"_shadowBias",ZC,Pn(e)),Mn(e,"_shadowNormalBias",QC,Pn(e)),Mn(e,"_shadowSaturation",$C,Pn(e)),Mn(e,"_shadowDistance",tx,Pn(e)),Mn(e,"_shadowInvisibleOcclusionRange",ex,Pn(e)),Mn(e,"_csmLevel",ix,Pn(e)),Mn(e,"_csmLayerLambda",rx,Pn(e)),Mn(e,"_csmOptimizationMode",nx,Pn(e)),Mn(e,"_shadowFixedArea",sx,Pn(e)),Mn(e,"_shadowNear",ax,Pn(e)),Mn(e,"_shadowFar",ox,Pn(e)),Mn(e,"_shadowOrthoSize",lx,Pn(e)),e._type=br.DIRECTIONAL,e._light=null,e._lightType=Tr,e}return on(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR,this._light.shadowEnabled=this._shadowEnabled,this._light.shadowPcf=this._shadowPcf,this._light.shadowBias=this._shadowBias,this._light.shadowNormalBias=this._shadowNormalBias,this._light.shadowSaturation=this._shadowSaturation,this._light.shadowDistance=this._shadowDistance,this._light.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange,this._light.shadowFixedArea=this._shadowFixedArea,this._light.shadowNear=this._shadowNear,this._light.shadowFar=this._shadowFar,this._light.shadowOrthoSize=this._shadowOrthoSize,this._light.csmLevel=this._csmLevel,this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmOptimizationMode=this._csmOptimizationMode)},Ur(e,[{key:"illuminance",get:function(){return Er.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){Er.director.root.pipeline.pipelineSceneData.isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=this._shadowEnabled)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=this._shadowPcf)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=this._shadowBias)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=this._shadowNormalBias)}},{key:"shadowSaturation",get:function(){return this._shadowSaturation},set:function(t){this._shadowSaturation=T(t,0,1),this._light&&(this._light.shadowSaturation=this._shadowSaturation)}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(t){this._shadowDistance=Math.min(t,pr.MAX_FAR),this._shadowDistance/.1<10&&Rn(15003,this._shadowDistance),this._light&&(this._light.shadowDistance=this._shadowDistance,this._light.csmNeedUpdate=!0)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,pr.MAX_FAR),this._light&&(this._light.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange)}},{key:"csmLevel",get:function(){return this._csmLevel},set:function(t){this._csmLevel=t,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"enableCSM",get:function(){return this._csmLevel>fr.LEVEL_1},set:function(t){this._csmLevel=t?fr.LEVEL_4:fr.LEVEL_1,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t,this._light&&(this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmNeedUpdate=!0)}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t,this._light&&(this._light.csmOptimizationMode=this._csmOptimizationMode)}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this._light&&(this._light.shadowFixedArea=this._shadowFixedArea)}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t,this._light&&(this._light.shadowNear=this._shadowNear)}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,pr.MAX_FAR),this._light&&(this._light.shadowFar=this._shadowFar)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t,this._light&&(this._light.shadowOrthoSize=this._shadowOrthoSize)}}]),e}(bw),YC=Dn((jC=hx).prototype,"_illuminanceHDR",[aa,UT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 65e3}}),qC=Dn(jC.prototype,"_illuminanceLDR",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 65e3*rr.standardExposureValue}}),KC=Dn(jC.prototype,"_shadowEnabled",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),JC=Dn(jC.prototype,"_shadowPcf",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return _r.HARD}}),ZC=Dn(jC.prototype,"_shadowBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e-5}}),QC=Dn(jC.prototype,"_shadowNormalBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$C=Dn(jC.prototype,"_shadowSaturation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),tx=Dn(jC.prototype,"_shadowDistance",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),ex=Dn(jC.prototype,"_shadowInvisibleOcclusionRange",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 200}}),ix=Dn(jC.prototype,"_csmLevel",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return fr.LEVEL_4}}),rx=Dn(jC.prototype,"_csmLayerLambda",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.75}}),nx=Dn(jC.prototype,"_csmOptimizationMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dr.RemoveDuplicates}}),sx=Dn(jC.prototype,"_shadowFixedArea",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),ax=Dn(jC.prototype,"_shadowNear",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),ox=Dn(jC.prototype,"_shadowFar",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),lx=Dn(jC.prototype,"_shadowOrthoSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),Dn(jC.prototype,"illuminance",[HT],Object.getOwnPropertyDescriptor(jC.prototype,"illuminance"),jC.prototype),Dn(jC.prototype,"shadowEnabled",[XT,WT,Un,jT],Object.getOwnPropertyDescriptor(jC.prototype,"shadowEnabled"),jC.prototype),Dn(jC.prototype,"shadowPcf",[YT,qT,Un,KT],Object.getOwnPropertyDescriptor(jC.prototype,"shadowPcf"),jC.prototype),Dn(jC.prototype,"shadowBias",[JT,ZT,Un,QT],Object.getOwnPropertyDescriptor(jC.prototype,"shadowBias"),jC.prototype),Dn(jC.prototype,"shadowNormalBias",[$T,tC,Un,eC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowNormalBias"),jC.prototype),Dn(jC.prototype,"shadowSaturation",[iC,rC,Un,nC,Ns,sC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowSaturation"),jC.prototype),Dn(jC.prototype,"shadowDistance",[aC,oC,Un,lC,hC,Ns,uC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowDistance"),jC.prototype),Dn(jC.prototype,"shadowInvisibleOcclusionRange",[cC,_C,Un,fC,dC,Ns,pC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowInvisibleOcclusionRange"),jC.prototype),Dn(jC.prototype,"csmLevel",[mC,gC,Un,yC,Ns,vC],Object.getOwnPropertyDescriptor(jC.prototype,"csmLevel"),jC.prototype),Dn(jC.prototype,"enableCSM",[bC,SC,Un,AC,Ns,TC],Object.getOwnPropertyDescriptor(jC.prototype,"enableCSM"),jC.prototype),Dn(jC.prototype,"csmLayerLambda",[CC,xC,Un,wC,EC,Ns,BC],Object.getOwnPropertyDescriptor(jC.prototype,"csmLayerLambda"),jC.prototype),Dn(jC.prototype,"csmOptimizationMode",[RC,DC,Un,MC,Ns,PC],Object.getOwnPropertyDescriptor(jC.prototype,"csmOptimizationMode"),jC.prototype),Dn(jC.prototype,"shadowFixedArea",[IC,OC,Un,FC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowFixedArea"),jC.prototype),Dn(jC.prototype,"shadowNear",[LC,kC,Un,VC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowNear"),jC.prototype),Dn(jC.prototype,"shadowFar",[NC,GC,Un,zC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowFar"),jC.prototype),Dn(jC.prototype,"shadowOrthoSize",[UC,HC,XC],Object.getOwnPropertyDescriptor(jC.prototype,"shadowOrthoSize"),jC.prototype),WC=jC))||WC)||WC)||WC)||WC)),Aw=function(e){return t({SphereLight:e,SphereLightComponent:e}),e}((ux=En("cc.SphereLight"),cx=Qn(),_x=ts(),fx=oa("_luminance"),dx=es(),px=is(),mx=es(),gx=is(),yx=Wn(yw),vx=es(),bx=is(),Sx=is(),Ax=is(),ux(Tx=cx(Tx=_x(Tx=Jn((Dx=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_size",xx,Pn(e)),Mn(e,"_luminanceHDR",wx,Pn(e)),Mn(e,"_luminanceLDR",Ex,Pn(e)),Mn(e,"_term",Bx,Pn(e)),Mn(e,"_range",Rx,Pn(e)),e._type=br.SPHERE,e._light=null,e._lightType=Cr,e}return on(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this.size=this._size,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},Ur(e,[{key:"luminousFlux",get:function(){return Er.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*Sr(this._size):this._luminanceLDR},set:function(t){var e=0;Er.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/Sr(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return Er.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){Er.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{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}(bw),xx=Dn((Cx=Dx).prototype,"_size",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),wx=Dn(Cx.prototype,"_luminanceHDR",[On,fx],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Sr(.15)}}),Ex=Dn(Cx.prototype,"_luminanceLDR",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Sr(.15)*rr.standardExposureValue*rr.standardLightMeterScale}}),Bx=Dn(Cx.prototype,"_term",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return yw.LUMINOUS_FLUX}}),Rx=Dn(Cx.prototype,"_range",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(Cx.prototype,"luminousFlux",[dx,px],Object.getOwnPropertyDescriptor(Cx.prototype,"luminousFlux"),Cx.prototype),Dn(Cx.prototype,"luminance",[mx,gx],Object.getOwnPropertyDescriptor(Cx.prototype,"luminance"),Cx.prototype),Dn(Cx.prototype,"term",[yx,vx,bx],Object.getOwnPropertyDescriptor(Cx.prototype,"term"),Cx.prototype),Dn(Cx.prototype,"size",[Sx],Object.getOwnPropertyDescriptor(Cx.prototype,"size"),Cx.prototype),Dn(Cx.prototype,"range",[Ax],Object.getOwnPropertyDescriptor(Cx.prototype,"range"),Cx.prototype),Tx=Cx))||Tx)||Tx)||Tx)||Tx)),Tw=function(e){return t({SpotLight:e,SpotLightComponent:e}),e}((Mx=En("cc.SpotLight"),Px=Qn(),Ix=ts(),Ox=oa("_luminance"),Fx=is(),Lx=es(),kx=is(),Vx=es(),Nx=Wn(yw),Gx=es(),zx=is(),Ux=is(),Hx=is(),Xx=Ls(),Wx=is(),jx=cs(),Yx=aa({group:{name:"DynamicShadowSettings",displayOrder:1}}),qx=Wn(ha),Kx=cs(),Jx=aa({group:{name:"DynamicShadowSettings",displayOrder:2}}),Zx=Wn(_r),Qx=cs(),$x=aa({group:{name:"DynamicShadowSettings",displayOrder:3}}),tw=Wn(sa),ew=cs(),iw=aa({group:{name:"DynamicShadowSettings",displayOrder:4}}),rw=Wn(sa),Mx(nw=Px(nw=Ix(nw=Jn((mw=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_size",aw,Pn(e)),Mn(e,"_luminanceHDR",ow,Pn(e)),Mn(e,"_luminanceLDR",lw,Pn(e)),Mn(e,"_term",hw,Pn(e)),Mn(e,"_range",uw,Pn(e)),Mn(e,"_spotAngle",cw,Pn(e)),Mn(e,"_shadowEnabled",_w,Pn(e)),Mn(e,"_shadowPcf",fw,Pn(e)),Mn(e,"_shadowBias",dw,Pn(e)),Mn(e,"_shadowNormalBias",pw,Pn(e)),e._type=br.SPOT,e._light=null,e._lightType=xr,e}return on(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR,this._light.shadowEnabled=this._shadowEnabled,this._light.shadowPcf=this._shadowPcf,this._light.shadowBias=this._shadowBias,this._light.shadowNormalBias=this._shadowNormalBias)},Ur(e,[{key:"luminousFlux",get:function(){return Er.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*Sr(this._size):this._luminanceLDR},set:function(t){var e=0;Er.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/Sr(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return Er.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){Er.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{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=w(t))}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=t)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=t)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=t)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=t)}}]),e}(bw),aw=Dn((sw=mw).prototype,"_size",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),ow=Dn(sw.prototype,"_luminanceHDR",[On,Ox],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Sr(.15)}}),lw=Dn(sw.prototype,"_luminanceLDR",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Sr(.15)*rr.standardExposureValue*rr.standardLightMeterScale}}),hw=Dn(sw.prototype,"_term",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return yw.LUMINOUS_FLUX}}),uw=Dn(sw.prototype,"_range",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),cw=Dn(sw.prototype,"_spotAngle",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),_w=Dn(sw.prototype,"_shadowEnabled",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),fw=Dn(sw.prototype,"_shadowPcf",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return _r.HARD}}),dw=Dn(sw.prototype,"_shadowBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e-5}}),pw=Dn(sw.prototype,"_shadowNormalBias",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(sw.prototype,"luminousFlux",[Fx,Lx],Object.getOwnPropertyDescriptor(sw.prototype,"luminousFlux"),sw.prototype),Dn(sw.prototype,"luminance",[kx,Vx],Object.getOwnPropertyDescriptor(sw.prototype,"luminance"),sw.prototype),Dn(sw.prototype,"term",[Nx,Gx,zx],Object.getOwnPropertyDescriptor(sw.prototype,"term"),sw.prototype),Dn(sw.prototype,"size",[Ux],Object.getOwnPropertyDescriptor(sw.prototype,"size"),sw.prototype),Dn(sw.prototype,"range",[Hx],Object.getOwnPropertyDescriptor(sw.prototype,"range"),sw.prototype),Dn(sw.prototype,"spotAngle",[Ns,Xx,Wx],Object.getOwnPropertyDescriptor(sw.prototype,"spotAngle"),sw.prototype),Dn(sw.prototype,"shadowEnabled",[jx,Yx,Un,qx],Object.getOwnPropertyDescriptor(sw.prototype,"shadowEnabled"),sw.prototype),Dn(sw.prototype,"shadowPcf",[Kx,Jx,Un,Zx],Object.getOwnPropertyDescriptor(sw.prototype,"shadowPcf"),sw.prototype),Dn(sw.prototype,"shadowBias",[Qx,$x,Un,tw],Object.getOwnPropertyDescriptor(sw.prototype,"shadowBias"),sw.prototype),Dn(sw.prototype,"shadowNormalBias",[ew,iw,Un,rw],Object.getOwnPropertyDescriptor(sw.prototype,"shadowNormalBias"),sw.prototype),nw=sw))||nw)||nw)||nw)||nw));Er.LightComponent=bw,pn.setClassAlias(bw,"cc.LightComponent"),Er.DirectionalLightComponent=Sw,pn.setClassAlias(Sw,"cc.DirectionalLightComponent"),Er.SphereLightComponent=Aw,pn.setClassAlias(Aw,"cc.SphereLightComponent"),Er.SpotLightComponent=Tw,pn.setClassAlias(Tw,"cc.SpotLightComponent"),wr(Tw.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),wr(Aw.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),wr(bw.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var Cw=Symbol("BakeNodeCurves"),xw=t("SkelAnimDataHub",function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&Er.director.root.dataPoolManager.releaseAnimationClip(e);var r=Math.ceil(e.sample*e.duration)+1,n=e.sample;i=e[Cw](0,n,r),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}());xw.pool=new Map;var ww=new c;function Ew(t,e,i){for(c.identity(i);t!==e;)c.fromRTS(ww,t.rotation,t.position,t.scale),c.multiply(i,ww,i),t=t.parent;return i}var Bw=new le(ft.POINT,ft.POINT,ft.NONE,dt.CLAMP,dt.CLAMP,dt.CLAMP),Rw=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 Dw(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new l,new l,new n,new l,new n;var Mw=new n,Pw=new n,Iw=new n,Ow=new n,Fw=new c,Lw=new c,kw=new Ii,Vw=Number.MAX_SAFE_INTEGER,Nw=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.getFormatFeatures(tt.RGBA32F)&ut.SAMPLED_TEXTURE?tt.RGBA32F:tt.RGBA8}(this._device);this._formatSize=Xe[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new Tf(t),this._pool.initialize({format:e,roundUpFn:Dw}),this._customPool=new Tf(t),this._customPool.initialize({format:e,roundUpFn:Dw})}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,s=this._textureBuffers.get(r)||null;if(s&&s.bounds.has(e.hash))return s.refCount++,s;var a=t.joints,o=t.bindposes,l=null,h=!1,u=a.length;if(s)s.refCount++;else{var _=12*u,f=this._chunkIdxMap.get(r),d=void 0!==f?this._customPool.alloc(_*Float32Array.BYTES_PER_ELEMENT,f):this._pool.alloc(_*Float32Array.BYTES_PER_ELEMENT);if(!d)return s;s={pixelOffset:d.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:0,readyToBeDeleted:!1,handle:d},l=new Float32Array(_),h=!0}n.set(Iw,Vw,Vw,Vw),n.set(Ow,-Vw,-Vw,-Vw);for(var p=e.getBoneSpaceBounds(t),m=0,g=0;m<u;m++,g+=12){var y=i.getChildByPath(a[m]),v=y?Ew(y,i,Fw):t.inverseBindposes[m],b=p[m];b&&(Ii.transform(kw,b,v),kw.getBoundary(Mw,Pw),n.min(Iw,Iw,Mw),n.max(Ow,Ow,Pw)),h&&(y&&c.multiply(v,v,o[m]),Rw(l,g,y?v:c.IDENTITY))}var S=[new Ii];return s.bounds.set(e.hash,S),Ii.fromPoints(S[0],Iw,Ow),h&&(this._pool.update(s.handle,l.buffer),this._textureBuffers.set(r,s)),s},e.getSequencePoseTexture=function(t,e,i,r){var s=t.hash^e.hash,a=this._textureBuffers.get(s)||null;if(a&&a.bounds.has(i.hash))return a.refCount++,a;var o=t.joints,l=t.bindposes,h=xw.getOrExtract(e).frames,u=null,_=!1,f=o.length;if(a)a.refCount++;else{var d=12*f*h,p=this._chunkIdxMap.get(s),m=void 0!==p?this._customPool.alloc(d*Float32Array.BYTES_PER_ELEMENT,p):this._pool.alloc(d*Float32Array.BYTES_PER_ELEMENT);if(!m)return null;var g=this._createAnimInfos(t,e,r);a={pixelOffset:m.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:e.hash,readyToBeDeleted:!1,handle:m,animInfos:g},u=new Float32Array(d),_=!0}var y=i.getBoneSpaceBounds(t),v=[];a.bounds.set(i.hash,v);for(var b=0;b<h;b++)v.push(new Ii(Vw,Vw,Vw,-Vw,-Vw,-Vw));for(var S=0,A=0;S<h;S++){for(var T=v[S],C=0;C<f;C++,A+=12){var x=a.animInfos[C],w=x.curveData,E=x.downstream,B=x.bindposeIdx,R=x.bindposeCorrection,D=void 0,M=!0;w&&E?D=c.multiply(Fw,w[S],E):w?D=w[S]:E?D=E:(D=t.inverseBindposes[B],M=!1);var P=y[C];if(P){var I=R?c.multiply(Lw,D,R):D;Ii.transform(kw,P,I),kw.getBoundary(Mw,Pw),n.min(T.center,T.center,Mw),n.max(T.halfExtents,T.halfExtents,Pw)}_&&(M&&c.multiply(Fw,D,l[B]),Rw(u,A,M?Fw:c.IDENTITY))}Ii.fromPoints(T,T.center,T.halfExtents)}return _&&(this._pool.update(a.handle,u.buffer),this._textureBuffers.set(s,a)),a},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=xw.getOrExtract(e),l=0;l<a;l++){for(var h=n[l],u=o.joints[h],_=i.getChildByPath(h),f=void 0,d=void 0;!u;){var p=h.lastIndexOf("/");if(h=h.substring(0,p),u=o.joints[h],_?(f||(f=new c),c.fromRTS(Fw,_.rotation,_.position,_.scale),c.multiply(f,Fw,f),_=_.parent):d=h,p<0)break}var m=l,g=void 0;if(void 0!==d&&u){m=l-1;for(var y=0;y<a;y++)if(n[y]===d){m=y,g=new c,c.multiply(g,s[y],t.inverseBindposes[l]);break}}r.push({curveData:u&&u.transforms,downstream:f,bindposeIdx:m,bindposeCorrection:g})}return r},Ur(t,[{key:"pixelsPerJoint",get:function(){return this._pixelsPerJoint}}]),t}(),Gw=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 ee(rt.UNIFORM|rt.TRANSFER_DST,at.HOST|at.DEVICE,ua.SIZE,ua.SIZE)),r=new Float32Array([0,0,0,0]);i.update(r);var n={buffer:i,data:r,dirty:!1,dirtyForJSB:new Uint8Array([0]),currentClip:null};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,e){return t.currentClip=e,t.data[0]=-1,t.buffer.update(t.data),t.dirty=!1,t},e.clear=function(){for(var t,e=hn(this._pool.values());!(t=e()).done;)t.value.buffer.destroy();this._pool.clear()},t}(),zw=[],Uw=new Map;function Hw(t,e){for(var i=0,r=c.IDENTITY;t;){if(t.stamp===e||t.stamp+1===e&&!t.node.hasChangedFlags){r=t.world,t.stamp=e;break}t.stamp=e,zw[i++]=t,t=t.parent}for(;i>0;){t=zw[--i],zw[i]=null;var n=t.node;c.fromRTS(t.local,n.rotation,n.position,n.scale),r=c.multiply(t.world,r,t.local)}return r}function Xw(t,e){for(var i,r=null,n=0;t!==e;){var s=t.uuid;if(Uw.has(s)){r=Uw.get(s);break}r={node:t,local:new c,world:new c,stamp:-1,parent:null},Uw.set(s,r),zw[n++]=r,t=t.parent,r=null}for(;n>0;)i=zw[--n],zw[n]=null,i.parent=r,r=i;return r}function Ww(t){for(var e=Uw.get(t.uuid)||null;e;)Uw.delete(e.node.uuid),e=e.parent}var jw=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],Yw=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function qw(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 Kw=new n,Jw=new n,Zw=new n,Qw=new n,$w=new c,tE=new Ii,eE=function(){this._format=_n.RGBA32F,this._textures=[],this._buffers=[]};eE.WIDTH=256,eE.HEIGHT=3;var iE,rE,nE,sE,aE,oE,lE,hE,uE,cE,_E,fE,dE,pE,mE,gE,yE,vE,bE,SE,AE,TE,CE,xE,wE,EE,BE,RE,DE,ME,PE,IE,OE,FE,LE,kE,VE,NE,GE,zE,UE,HE,XE,WE,jE,YE=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new eE,e._realTimeTextureMode=!1,e.type=nr.SKINNING,e}on(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}this._dataArray.length=0,this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0,this._realTimeJointTexture._buffers.length=0,t.prototype.destroy.call(this)},i.uploadAnimation=function(){},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++)Ww(this._joints[r].target);if(this._bufferIndices=null,this._joints.length=0,t&&e&&i){this._realTimeTextureMode=!1,ca.JOINT_UNIFORM_CAPACITY<t.joints.length&&(this._realTimeTextureMode=!0),this.transform=e;var n=i.getBoneSpaceBounds(t),s=i.struct.jointMaps;this._ensureEnoughBuffers(s&&s.length||1),this._bufferIndices=i.jointBufferIndices,this._initRealTimeJointTexture();for(var a=0;a<t.joints.length;a++){var o=n[a],l=e.getChildByPath(t.joints[a]);if(o&&l){var h=Xw(l,e),u=t.bindposes[a],c=[],_=[];s?qw(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._localDataUpdated=!0),n.set(Kw,1/0,1/0,1/0),n.set(Jw,-1/0,-1/0,-1/0);for(var i=0;i<this._joints.length;i++){var r=this._joints[i],s=r.bound,a=Hw(r.transform,t);Ii.transform(tE,s,a),tE.getBoundary(Zw,Qw),n.min(Kw,Kw,Zw),n.max(Jw,Jw,Qw)}var o=this._worldBounds;this._modelBounds&&o&&(Ii.fromPoints(this._modelBounds,Kw,Jw),this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,this._worldBounds))},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;c.multiply($w,a.world,o);for(var l=0;l<s.length;l++)Rw(this._dataArray[s[l]],12*n[l],$w)}if(this._realTimeTextureMode)this._updateRealTimeJointTextureBuffer();else 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),r=jw;return this._realTimeTextureMode&&(r=Yw),i?r.concat(i):r},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var r=this._bufferIndices[e];if(this._realTimeTextureMode)this._bindRealTimeJointTexture(r,i);else{var n=this._buffers[r];n&&i.bindBuffer(ca.BINDING,n)}},i._updateInstancedAttributes=function(e,i){i.batchingScheme!==Rs.NONE&&Rn(3936,this.node.getPathInHierarchy()),t.prototype._updateInstancedAttributes.call(this,e,i)},i._ensureEnoughBuffers=function(t){if(this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}if(this._dataArray.length&&(this._dataArray.length=0),this._realTimeTextureMode)for(var i=0;i<t;i++){var r=eE.WIDTH;this._dataArray[i]=new Float32Array(12*r)}else for(var n=0;n<t;n++){this._buffers[n]=this._device.createBuffer(new ee(rt.UNIFORM|rt.TRANSFER_DST,at.HOST|at.DEVICE,ca.SIZE,ca.SIZE));var s=ca.JOINT_UNIFORM_CAPACITY;this._dataArray[n]=new Float32Array(12*s)}},i._initRealTimeJointTexture=function(){if(this._realTimeJointTexture._textures.length&&(this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0),this._realTimeJointTexture._buffers.length=0,this._realTimeTextureMode){var t=Kr.root.device,e=eE.WIDTH,i=eE.HEIGHT;0==(t.getFormatFeatures(tt.RGBA32F)&ut.SAMPLED_TEXTURE)&&(this._realTimeJointTexture._format=_n.RGBA8888,e=4*eE.WIDTH);for(var r=this._realTimeJointTexture._textures,n=this._realTimeJointTexture._buffers,s=this._realTimeJointTexture._format,a=0;a<this._dataArray.length;a++){n[a]=new Float32Array(4*eE.HEIGHT*eE.WIDTH);var o=n[a],l=s===_n.RGBA32F?o:new Uint8Array(o.buffer),h=new vn({width:e,height:i,_data:l,_compressed:!1,format:s}),u=new fn;u.setFilters(fn.Filter.NEAREST,fn.Filter.NEAREST),u.setMipFilter(fn.Filter.NONE),u.setWrapMode(fn.WrapMode.CLAMP_TO_EDGE,fn.WrapMode.CLAMP_TO_EDGE,fn.WrapMode.CLAMP_TO_EDGE),u.image=h,r[a]=u}}},i._bindRealTimeJointTexture=function(t,e){if(this._realTimeTextureMode){var i=this._realTimeJointTexture._textures[t];if(i){var r=i.getGFXTexture(),n=i.getGFXSampler();e.bindTexture(_a,r),e.bindSampler(_a,n)}}},i._updateRealTimeJointTextureBuffer=function(){if(this._realTimeTextureMode)for(var t=this._realTimeJointTexture._textures,e=this._realTimeJointTexture._buffers,i=0;i<t.length;i++){for(var r=e[i],n=this._dataArray[i],s=n.length/12,a=0,o=0,l=0;l<s;l++)o=4*l,r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++],o=4*(l+eE.WIDTH),r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++],o=4*(l+2*eE.WIDTH),r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++],r[o++]=n[a++];var h=this._realTimeJointTexture._format===_n.RGBA32F?r:new Uint8Array(r.buffer);t[i].uploadData(h)}},e}(uT),qE=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_BAKED_ANIMATION",value:!0}],KE=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=nr.BAKED_SKINNING,e._dataPoolManager=Er.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}on(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 ee(rt.UNIFORM|rt.TRANSFER_DST,at.DEVICE,fa.SIZE,fa.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)}}},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.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?i.concat(qE):qE},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(da,s)}},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(fa.BINDING,n),i.bindBuffer(ua.BINDING,a.buffer),s){var o=this._device.getSampler(Bw);i.bindTexture(da,s.handle.texture),i.bindSampler(da,o)}},i._updateInstancedAttributes=function(e,i){t.prototype._updateInstancedAttributes.call(this,e,i),this._instAnimInfoIdx=this._getInstancedAttributeIndex(pa),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}(uT),JE=function(e){return t({SkinnedMeshRenderer:e,SkinningModelComponent:e}),e}((iE=En("cc.SkinnedMeshRenderer"),rE=Qn(),nE=$n(100),sE=ts(),aE=Wn(VT),oE=Wn(ks),lE=Wn(VT),hE=Wn(ks),uE=is(),iE(cE=rE(cE=nE(cE=Jn(cE=sE((pE=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_skeleton",fE,Pn(e)),Mn(e,"_skinningRoot",dE,Pn(e)),e._clip=null,e.associatedAnimation=null,e._modelType=KE,e}on(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this._tryBindAnimation()},i.onDestroy=function(){this.associatedAnimation&&(this.associatedAnimation.notifySkinnedMeshRemoved(this),gn(null===this.associatedAnimation)),t.prototype.onDestroy.call(this)},i.uploadAnimation=function(t){this._clip=t,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(t)},i.setUseBakedAnimation=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var i=t?KE:YE;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(Er.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this.enabledInHierarchy&&this._attachToScene()))},i.setMaterial=function(e,i){t.prototype.setMaterial.call(this,e,i),this._modelType===YE&&this.getMaterialInstance(i)},i._updateModelParams=function(){this._update(),t.prototype._updateModelParams.call(this)},i._tryBindAnimation=function(){var t=this._skinningRoot;if(t){for(var e=!1,i=this.node;i;i=i.parent)if(i===t){e=!0;break}if(e){var r=t.getComponent("cc.SkeletalAnimation");r?r.notifySkinnedMeshAdded(this):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))},Ur(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){this._skinningRoot=t,this._tryBindAnimation(),t!==this._skinningRoot&&this._update()}},{key:"model",get:function(){return this._model}}]),e}(dT),fE=Dn((_E=pE).prototype,"_skeleton",[aE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),dE=Dn(_E.prototype,"_skinningRoot",[oE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(_E.prototype,"skeleton",[lE],Object.getOwnPropertyDescriptor(_E.prototype,"skeleton"),_E.prototype),Dn(_E.prototype,"skinningRoot",[hE,uE],Object.getOwnPropertyDescriptor(_E.prototype,"skinningRoot"),_E.prototype),cE=_E))||cE)||cE)||cE)||cE)||cE)),ZE=new ye(He.ATTR_BATCH_ID,tt.R32F),QE=new ye(He.ATTR_BATCH_UV,tt.RG32F),$E=Xe[ZE.format].size+Xe[QE.format].size,tB=function(e){return t({SkinnedMeshUnit:e,SkinningModelUnit:e}),e}((mE=En("cc.SkinnedMeshUnit"),gE=Wn(sh),yE=Wn(VT),vE=Wn(cn),bE=Wn(JE),mE((RE=function(){function t(){Mn(this,"mesh",TE,this),Mn(this,"skeleton",CE,this),Mn(this,"material",xE,this),Mn(this,"_localTransform",wE,this),Mn(this,"_offset",EE,this),Mn(this,"_size",BE,this)}return Ur(t,[{key:"offset",get:function(){return this._offset},set:function(t){i.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){i.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&&Ew(t.node,t.skinningRoot,this._localTransform))}}]),t}(),TE=Dn((AE=RE).prototype,"mesh",[gE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),CE=Dn(AE.prototype,"skeleton",[yE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),xE=Dn(AE.prototype,"material",[vE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),wE=Dn(AE.prototype,"_localTransform",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new c}}),EE=Dn(AE.prototype,"_offset",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(0,0)}}),BE=Dn(AE.prototype,"_size",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(1,1)}}),Dn(AE.prototype,"offset",[Un],Object.getOwnPropertyDescriptor(AE.prototype,"offset"),AE.prototype),Dn(AE.prototype,"size",[Un],Object.getOwnPropertyDescriptor(AE.prototype,"size"),AE.prototype),Dn(AE.prototype,"copyFrom",[bE],Object.getOwnPropertyDescriptor(AE.prototype,"copyFrom"),AE.prototype),SE=AE))||SE)),eB=new c,iB=(new c,new n),rB=function(e){return t({SkinnedMeshBatchRenderer:e,BatchedSkinningModelComponent:e}),e}((DE=En("cc.SkinnedMeshBatchRenderer"),ME=Qn(),PE=$n(100),IE=ts(),OE=is(),FE=Wn([la]),LE=is(),kE=Wn([tB]),VE=is(),NE=cs(),GE=cs(),DE(zE=ME(zE=PE(zE=Jn(zE=IE((jE=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,Mn(e,"atlasSize",HE,Pn(e)),Mn(e,"batchableTextureNames",XE,Pn(e)),Mn(e,"units",WE,Pn(e)),e._textures={},e._batchMaterial=null,e}on(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>=it.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;c.invert(eB,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(c.multiply(new c,n.bindposes[i]||c.IDENTITY,eB))},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 VT;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 sh;for(var r=0,s=tt.UNKNOWN,a=0,o=tt.UNKNOWN,l=0,h=tt.UNKNOWN,u=0,_=tt.UNKNOWN,f=0,d=tt.UNKNOWN,p=new Array(this.units.length),m=this.units.length,g=0;g<m;g++){var y=this.units[g];y&&y.skeleton&&(p[g]=y.skeleton.joints.map((function(e){return t._skeleton.joints.findIndex((function(t){return e===t}))})))}for(var v=function(e){var i=t.units[e];if(!i||!i.mesh||!i.mesh.data)return"continue";var m=t._createUnitMesh(e,i.mesh),g=new DataView(m.data.buffer);c.inverseTranspose(eB,i._localTransform);for(var y=i.offset,v=i.size,b=function(t){var c=m.struct.vertexBundles[t];r=c.view.offset,s=tt.UNKNOWN;for(var b=0;b<c.attributes.length;b++){var S=c.attributes[b];if(S.name===He.ATTR_POSITION){s=S.format;break}r+=Xe[S.format].size}if(s){for(var A=mn(g,s,r,c.view.length,c.view.stride),T=0;T<A.length;T+=3)n.fromArray(iB,A,T),n.transformMat4(iB,iB,i._localTransform),n.toArray(A,iB,T);Ln(g,A,s,r,c.view.stride)}a=c.view.offset,o=tt.UNKNOWN;for(var C=0;C<c.attributes.length;C++){var x=c.attributes[C];if(x.name===He.ATTR_NORMAL){o=x.format;break}a+=Xe[x.format].size}if(o){for(var w=mn(g,o,a,c.view.length,c.view.stride),E=0;E<w.length;E+=3)n.fromArray(iB,w,E),n.transformMat4Normal(iB,iB,eB),n.toArray(w,iB,E);Ln(g,w,o,a,c.view.stride)}l=c.view.offset,h=tt.UNKNOWN;for(var B=0;B<c.attributes.length;B++){var R=c.attributes[B];if(R.name===He.ATTR_TANGENT){h=R.format;break}l+=Xe[R.format].size}if(h){for(var D=mn(g,h,l,c.view.length,c.view.stride),M=0;M<D.length;M+=3)n.fromArray(iB,D,M),n.transformMat4Normal(iB,iB,eB),n.toArray(D,iB,M);Ln(g,D,h,l,c.view.stride)}u=c.view.offset,_=tt.UNKNOWN;for(var P=0;P<c.attributes.length;P++){var I=c.attributes[P];if(I.name===He.ATTR_BATCH_UV){_=I.format;break}u+=Xe[I.format].size}_&&Vn(g,(function(t,e){var i,r=0===e?"x":"y";return(t=(i=t)-Math.floor(i))*v[r]+y[r]}),_,u,c.view.length,c.view.stride,g);var O=p[e];if(!O)return"continue";f=c.view.offset,d=tt.UNKNOWN;for(var F=0;F<c.attributes.length;F++){var L=c.attributes[F];if(L.name===He.ATTR_JOINTS){d=L.format;break}f+=Xe[L.format].size}d&&Vn(g,(function(t){return O[t]}),d,f,c.view.length,c.view.stride,g)},S=0;S<m.struct.vertexBundles.length;S++)b(S);t._mesh.merge(m)},b=0;b<m;b++)v(b);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 Kt;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=Er.director.root.device;s.length>0&&f.copyBuffersToTexture(s,_,a),r.length>0&&f.copyTexImagesToTexture(r,_,n)},i.createTexture=function(t){var e=new fn;return e.setFilters(dn.LINEAR,dn.LINEAR),e.setMipFilter(dn.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:_n.RGBA8888}),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:_n.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=tt.UNKNOWN,l=0;l<s.vertexBundelIndices.length;l++){var h=e.struct.vertexBundles[s.vertexBundelIndices[l]];a=h.view.offset,o=tt.UNKNOWN;for(var u=0;u<h.attributes.length;u++){var c=h.attributes[u];if(c.name===He.ATTR_TEX_COORD){o=c.format;break}a+=Xe[c.format].size}if(o)break}if(void 0===r[l]){r[l]=[o,a];var _=i.vertexBundles[l];_.attributes.push(ZE),_.attributes.push(QE),_.view.offset=0,_.view.length+=_.view.count*$E,_.view.stride+=$E}}for(var f=0,d=0;d<i.vertexBundles.length;d++)f+=i.vertexBundles[d].view.length;for(var p=0;p<i.primitives.length;p++){var m=i.primitives[p];m.indexView&&(m.indexView.offset=f,f+=m.indexView.length)}var g=new Uint8Array(f),y=e.data,v=new DataView(g.buffer),b=new DataView(y.buffer),S=Er.sys.isLittleEndian;for(var A in r)for(var T=i.vertexBundles[A],C=e.struct.vertexBundles[A],x=r[A],w=x[0],E=x[1],B=mn(b,w,E,C.view.length,C.view.stride),R=C.view,D=T.view,M=R.stride,P=D.stride,I=R.offset,O=D.offset,F=0;F<D.count;F++){var L=y.subarray(I,I+M);g.set(L,O),v.setFloat32(O+M,t),v.setFloat32(O+M+4,B[2*F],S),v.setFloat32(O+M+8,B[2*F+1],S),O+=P,I+=M}for(var k=0;k<i.primitives.length;k++){var V=e.struct.primitives[k],N=i.primitives[k];if(V.indexView&&N.indexView)for(var G=V.indexView.stride,z=N.indexView.stride,U=V.indexView.offset,H=N.indexView.offset,X=0;X<N.indexView.count;X++){var W=y.subarray(U,U+G);g.set(W,H),H+=z,U+=G}}var j=new sh;return j.reset({struct:i,data:g}),j},Ur(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}(JE),HE=Dn((UE=jE).prototype,"atlasSize",[On,OE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1024}}),XE=Dn(UE.prototype,"batchableTextureNames",[FE,On,LE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),WE=Dn(UE.prototype,"units",[kE,On,VE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dn(UE.prototype,"mesh",[Hn,NE],Object.getOwnPropertyDescriptor(UE.prototype,"mesh"),UE.prototype),Dn(UE.prototype,"skeleton",[Hn,GE],Object.getOwnPropertyDescriptor(UE.prototype,"skeleton"),UE.prototype),zE=UE))||zE)||zE)||zE)||zE)||zE));Er.SkinningModelComponent=JE,pn.setClassAlias(JE,"cc.SkinningModelComponent"),Er.SkinningModelUnit=tB,pn.setClassAlias(tB,"cc.SkinningModelUnit"),Er.BatchedSkinningModelComponent=rB,pn.setClassAlias(rB,"cc.BatchedSkinningModelComponent"),Er.utils=vh;var nB,sB,aB,oB,lB,hB,uB,cB=Symbol("CreateEval"),_B=(En("cc.animation.EmbeddedPlayer")((hB=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,Mn(e,"begin",sB,Pn(e)),Mn(e,"end",aB,Pn(e)),Mn(e,"reconciledSpeed",oB,Pn(e)),Mn(e,"playable",lB,Pn(e)),e}return on(e,t),e}(ma),sB=Dn((nB=hB).prototype,"begin",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),aB=Dn(nB.prototype,"end",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oB=Dn(nB.prototype,"reconciledSpeed",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),lB=Dn(nB.prototype,"playable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nB)),function(){}),fB=function(){function t(t){this._randomAccess=t}return t.prototype.setTime=function(){},Ur(t,[{key:"randomAccess",get:function(){return this._randomAccess}}]),t}(),dB=function(){function t(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var e=t.prototype;return e.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(Yr(3912)):(this._isPlaying=!0,this.onPlay())},e.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},e.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},e.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},e.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.update=function(){},e.onPlay=function(){},e.onPause=function(){},e.onResume=function(){},e.onStop=function(){},e.onError=function(){},Ur(t,[{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isMotionless",get:function(){return!this.isPlaying||this.isPaused}}]),t}(),pB=function(){function t(t){this.weight=0,this._pose=void 0,this._blendStateWriters=[],this._pose=t}var e=t.prototype;return e.destroy=function(){for(var t=0;t<this._blendStateWriters.length;++t)this._pose.destroyWriter(this._blendStateWriters[t]);this._blendStateWriters.length=0},e.createPoseWriter=function(t,e,i){var r=this._pose.createWriter(t,e,this,i);return this._blendStateWriters.push(r),r},t}();function mB(){return Er.director.getAnimationManager()}!function(t){t.PLAY="play",t.STOP="stop",t.PAUSE="pause",t.RESUME="resume",t.LASTFRAME="lastframe",t.FINISHED="finished"}(uB||(uB={})),ss(uB);var gB,yB,vB,bB,SB=t("AnimationState",function(t){function e(e,i){var r;return void 0===i&&(i=""),(r=t.call(this)||this).duration=1,r.time=0,r.frameRate=0,r._targetNode=null,r._curveLoaded=!1,r._clip=void 0,r._speed=1,r._useSimpleProcess=!1,r._target=null,r._wrapMode=va.Normal,r._repeatCount=1,r._delay=0,r._delayTime=0,r._currentFramePlayed=!1,r._name=void 0,r._lastIterations=NaN,r._lastWrapInfo=null,r._wrappedInfo=new ya,r._allowLastFrame=!1,r._blendStateWriterHost={weight:0},r._playbackDuration=0,r._invDuration=1,r._poseOutput=null,r._weight=1,r._clipEval=void 0,r._clipEventEval=void 0,r._clipEmbeddedPlayerEval=void 0,r._doNotCreateEval=!1,r._clip=e,r._name=i||e&&e.name,r._playbackRange={min:0,max:e.duration},r._playbackDuration=e.duration,e.duration||ps("Clip "+e.name+" has zero duration."),r}on(e,t);var i=e.prototype;return i.initialize=function(t,e,i){if(!this._curveLoaded){this._curveLoaded=!0,this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval&&(this._clipEval=void 0),this._clipEventEval&&(this._clipEventEval=void 0),this._clipEmbeddedPlayerEval&&(this._clipEmbeddedPlayerEval.destroy(),this._clipEmbeddedPlayerEval=void 0),this._targetNode=t;var r=this._clip;if(this.duration=r.duration,this._invDuration=1/this.duration,this._speed=r.speed,this.wrapMode=r.wrapMode,this.frameRate=r.sample,this._playbackRange.min=0,this._playbackRange.max=r.duration,this._playbackDuration=r.duration,(this.wrapMode&ga.Loop)===ga.Loop?this.repeatCount=1/0:this.repeatCount=1,!this._doNotCreateEval){var n,s,a,o=null!==(n=null!=e?e:null===(s=mB())||void 0===s?void 0:s.blendState)&&void 0!==n?n:null;o&&(this._poseOutput=new pB(o)),this._clipEval=r.createEvaluator({target:t,pose:null!==(a=this._poseOutput)&&void 0!==a?a:void 0,mask:i})}r.containsAnyEvent()&&(this._clipEventEval=r.createEventEvaluator(this._targetNode)),r.containsAnyEmbeddedPlayer()&&(this._clipEmbeddedPlayerEval=r.createEmbeddedPlayerEvaluator(this._targetNode),this._clipEmbeddedPlayerEval.notifyHostSpeedChanged(this._speed))}},i.destroy=function(){this.isMotionless||mB().removeAnimation(this),this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval=void 0},i.emit=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];mB().pushDelayEvent(this._emit,this,e)},i.on=function(t,e,i){return this._target&&this._target.isValid?this._target.on(t,e,i):null},i.once=function(t,e,i){return this._target&&this._target.isValid?this._target.once(t,e,i):null},i.off=function(t,e,i){this._target&&this._target.isValid&&this._target.off(t,e,i)},i.allowLastFrameEvent=function(t){this._allowLastFrame=t},i._setEventTarget=function(t){this._target=t},i.setTime=function(t){this._currentFramePlayed=!1,this.time=t||0;var e,i=this.getWrappedInfo(t,this._wrappedInfo);null===(e=this._clipEventEval)||void 0===e||e.ignore(i.ratio,i.direction)},i.update=function(t){this._delayTime>0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this._speed:this._currentFramePlayed=!0,this._process())},i.sample=function(){var t=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(t.time),this._sampleEvents(t),this._sampleEmbeddedPlayers(t),t},i.onPlay=function(){var t;this.setTime(this._getPlaybackStart()),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(uB.PLAY,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit(uB.STOP,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit(uB.RESUME,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit(uB.PAUSE,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPause(this.current)},i._sampleCurves=function(t){var e=this._poseOutput,i=this._clipEval;e&&(e.weight=this.weight),i&&i.evaluate(t)},i._process=function(){this._useSimpleProcess?this.simpleProcess():this.process()},i.process=function(){var t,e=this.sample();this._allowLastFrame&&(t=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new ya(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit(uB.LASTFRAME,this),t.set(e)),e.stopped&&(this.stop(),this.emit(uB.FINISHED,this))},i.simpleProcess=function(){var t=this._playbackRange.min,e=this._playbackDuration,i=0,r=0;if(0!==e&&((i=this.time%e)<0&&(i+=e),r=(t+i)*this._invDuration),this._sampleCurves(t+i),this._clipEventEval||this._clipEmbeddedPlayerEval){var n=this.getWrappedInfo(this.time,this._wrappedInfo);this._sampleEvents(n),this._sampleEmbeddedPlayers(n)}this._allowLastFrame&&(Number.isNaN(this._lastIterations)&&(this._lastIterations=r),(this.time>0&&this._lastIterations>r||this.time<0&&this._lastIterations<r)&&this.emit(uB.LASTFRAME,this),this._lastIterations=r)},i._needReverse=function(t){var e=this.wrapMode,i=!1;return(e&ga.PingPong)===ga.PingPong&&(t-(0|t)==0&&t>0&&(t-=1),1&t&&(i=!i)),(e&ga.Reverse)===ga.Reverse&&(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new ya;var i=this._playbackRange.min,r=this._playbackDuration,n=this.repeatCount;if(0===r)return e.time=0,e.ratio=0,e.direction=1,e.stopped=!!Number.isFinite(n),e.iterations=0,e;var s=!1,a=(t-=i)>0?t/r:-t/r;if(a>=n){a=n,s=!0;var o=n-(0|n);0===o&&(o=1),t=o*r*(t>0?1:-1)}if(t>r){var l=t%r;t=0===l?r:l}else t<0&&0!=(t%=r)&&(t+=r);var h=!1,u=this._wrapMode&ga.ShouldWrap;u&&(h=this._needReverse(a));var c=h?-1:1;return this.speed<0&&(c*=-1),u&&h&&(t=r-t),e.time=i+t,e.ratio=e.time/this.duration,e.direction=c,e.stopped=s,e.iterations=a,e},i._getPlaybackStart=function(){return this._playbackRange.min},i._sampleEvents=function(t){var e;null===(e=this._clipEventEval)||void 0===e||e.sample(t.ratio,t.direction,t.iterations)},i._sampleEmbeddedPlayers=function(t){var e;null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.evaluate(t.time,Math.trunc(t.iterations))},i._emit=function(t,e){this._target&&this._target.isValid&&this._target.emit(t,t,e)},i._onReplayOrResume=function(){mB().addAnimation(this)},i._onPauseOrStop=function(){mB().removeAnimation(this)},Ur(e,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(t){var e;this._wrapMode=t,this.time=0,t&ga.Loop?this.repeatCount=1/0:this.repeatCount=1,null===(e=this._clipEventEval)||void 0===e||e.setWrapMode(t)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t;var e=this._wrapMode&ga.ShouldWrap,i=(this.wrapMode&ga.Reverse)===ga.Reverse;this._useSimpleProcess=t===1/0&&!e&&!i}},{key:"delay",get:function(){return this._delay},set:function(t){this._delayTime=this._delay=t}},{key:"playbackRange",get:function(){return this._playbackRange},set:function(t){gn(t.max>t.min),this._playbackRange.min=Math.max(t.min,0),this._playbackRange.max=Math.min(t.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"speed",get:function(){return this._speed},set:function(t){var e;this._speed=t,null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.notifyHostSpeedChanged(t)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return 0===this.duration?0:this.current/this.duration}},{key:"weight",get:function(){return this._weight},set:function(t){this._weight=t,this._poseOutput&&(this._poseOutput.weight=t)}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),e}(dB));Er.AnimationState=SB,En("cc.animation.EmbeddedAnimationClipPlayable")((bB=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,Mn(e,"path",yB,Pn(e)),Mn(e,"clip",vB,Pn(e)),e}return on(e,t),e.prototype.instantiate=function(t){var e=this.clip,i=this.path;if(!e)return null;var r=t.getChildByPath(i);if(!r)return Nn(3938,i,t.getPathInHierarchy(),e.name),null;var n=new SB(e);return n.initialize(r),new IB(n)},e}(_B),yB=Dn((gB=bB).prototype,"path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),vB=Dn(gB.prototype,"clip",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gB));var AB,TB,CB,xB,wB,EB,BB,RB,DB,MB,PB,IB=function(t){function e(e){var i;return(i=t.call(this,!0)||this)._animationState=void 0,i._animationState=e,i}on(e,t);var i=e.prototype;return i.destroy=function(){this._animationState.destroy()},i.play=function(){this._animationState.play()},i.pause=function(){this._animationState.pause()},i.stop=function(){this._animationState.stop()},i.setSpeed=function(t){this._animationState.speed=t},i.setTime=function(t){this._animationState.time=t},e}(fB),OB=(En("cc.animation.EmbeddedParticleSystemPlayable")((CB=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,Mn(e,"path",TB,Pn(e)),e}return on(e,t),e.prototype.instantiate=function(t){var e=t.getChildByPath(this.path);if(!e)return bn("Hierarchy path "+this.path+" does not exists."),null;var i=ba("cc.ParticleSystem");if(!i)return bn("Particle system is required for embedded particle system player."),null;var r=e.getComponent(i);return r?new OB(r):(bn(this.path+" does not includes a particle system component."),null)},e}(_B),TB=Dn((AB=CB).prototype,"path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),AB)),function(t){function e(e){var i;return(i=t.call(this,!1)||this)._particleSystem=void 0,i._particleSystem=e,i}on(e,t);var i=e.prototype;return i.destroy=function(){},i.play=function(){this._particleSystem.play()},i.pause=function(){this._particleSystem.stopEmitting()},i.stop=function(){this._particleSystem.stopEmitting()},i.setSpeed=function(t){this._particleSystem.simulationSpeed=t},e}(fB));function FB(t){return"string"==typeof t||"number"==typeof t}var LB,kB,VB,NB,GB,zB,UB,HB,XB,WB,jB,YB,qB,KB,JB,ZB,QB,$B,tR,eR,iR,rR,nR,sR,aR,oR,lR,hR,uR,cR,_R,fR,dR,pR,mR,gR,yR,vR,bR,SR,AR,TR,CR,xR,wR,ER,BR=En("cc.animation.HierarchyPath")((BB=function(){function t(t){Mn(this,"path",EB,this),this.path=t||""}return t.prototype.get=function(t){return t instanceof ks?t.getChildByPath(this.path)||(Rn(3926,t.name,this.path),null):(Rn(3925),null)},t}(),EB=Dn((wB=BB).prototype,"path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),xB=wB))||xB,RR=En("cc.animation.ComponentPath")((PB=function(){function t(t){Mn(this,"component",MB,this),this.component=t||""}return t.prototype.get=function(t){return t instanceof ks?t.getComponent(this.component)||(Rn(3928,t.name,this.component),null):(Rn(3927),null)},t}(),MB=Dn((DB=PB).prototype,"component",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),RB=DB))||RB,DR=Symbol("NormalizedFollow"),MR=Symbol("ConvertAsTrsPath"),PR=Symbol("TrackBinding"),IR=En("cc.animation.TrackPath")((NB=function(){function t(){Mn(this,"_paths",VB,this)}var e=t.prototype;return e.toProperty=function(t){return this._paths.push(t),this},e.toElement=function(t){return this._paths.push(t),this},e.toHierarchy=function(t){return this._paths.push(new BR(t)),this},e.toComponent=function(t){var e=new RR("string"==typeof t?t:pn.getClassName(t));return this._paths.push(e),this},e.toCustomized=function(t){return this._paths.push(t),this},e.append=function(){for(var t,e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];var n=(t=this._paths).concat.apply(t,i.map((function(t){return t._paths})));return this._paths=n,this},e.isPropertyAt=function(t){return"string"==typeof this._paths[t]},e.parsePropertyAt=function(t){return this._paths[t]},e.isElementAt=function(t){return"number"==typeof this._paths[t]},e.parseElementAt=function(t){return this._paths[t]},e.isHierarchyAt=function(t){return this._paths[t]instanceof BR},e.parseHierarchyAt=function(t){return gn(this.isHierarchyAt(t)),this._paths[t].path},e.isComponentAt=function(t){return this._paths[t]instanceof RR},e.parseComponentAt=function(t){return gn(this.isComponentAt(t)),this._paths[t].component},e.slice=function(e,i){var r=new t;return r._paths=this._paths.slice(e,i),r},e.trace=function(t,e,i){var r,n;return null!==(r=e)&&void 0!==r||(e=0),null!==(n=i)&&void 0!==n||(i=this._paths.length),this[DR](t,e,i)},e[MR]=function(){for(var t,e=this._paths,i=e.length,r=0,n="";r<i;++r){var s=e[r];if(!(s instanceof BR))break;s.path&&(n?n+="/"+s.path:n=s.path)}if(r===i)return null;if(r!==i-1)return null;switch(e[r]){case"position":case"scale":case"rotation":case"eulerAngles":t=e[r];break;default:return null}return{node:n,property:t}},e[DR]=function(t,e,i){for(var r=this._paths,n=t,s=e;s<i;++s){var a=r[s];if(FB(a)){if(!(a in n))return Rn(3929,a),null;n=n[a]}else n=a.get(n);if(null===n)break}return n},Ur(t,[{key:"length",get:function(){return this._paths.length}}]),t}(),VB=Dn((kB=NB).prototype,"_paths",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LB=kB))||LB,OR=En("cc.animation.TrackBinding")(GB=Sa((XB=function(){function t(){Mn(this,"path",UB,this),Mn(this,"proxy",HB,this)}var e=t.prototype;return e.parseTrsPath=function(){return this.proxy?null:this.path[MR]()},e.createRuntimeBinding=function(t,e,i){var r=this.path,n=this.proxy,s=r.length,a=s-1;if(0===s||!r.isPropertyAt(a)&&!r.isElementAt(a)||n){if(n){var o=r[DR](t,0,s);if(null===o)return null;var l=n.forTarget(o),h={setValue:function(t){l.set(t)}},u=l.get;return u&&(h.getValue=function(){return u.call(l)}),h}return Nn(3921),null}var c,_=r.isPropertyAt(a)?r.parsePropertyAt(a):r.parseElementAt(a),f=r[DR](t,0,s-1);return null===f?null:e&&f instanceof ks&&("position"===(c=_)||"rotation"===c||"scale"===c||"eulerAngles"===c)?e.createPoseWriter(f,_,i):{setValue:function(t){f[_]=t},getValue:function(){return f[_]}}},e.isMaskedOff=function(t){var e=this.parseTrsPath();if(!e)return!1;for(var i=t.joints[Symbol.iterator](),r=i.next();!r.done;r=i.next()){var n=r.value;if(n.path===e.node)return!n.enabled}return!1},t}(),UB=Dn((zB=XB).prototype,"path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new IR}}),HB=Dn(zB.prototype,"proxy",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),GB=zB))||GB)||GB,FR=En("cc.animation.Track")((qB=function(){function t(){Mn(this,"_binding",YB,this)}var e=t.prototype;return e.channels=function(){return[]},e.range=function(){for(var t,e={min:1/0,max:-1/0},i=hn(this.channels());!(t=i()).done;){var r=t.value;e.min=Math.min(e.min,r.curve.rangeMin),e.max=Math.max(e.max,r.curve.rangeMax)}return e},Ur(t,[{key:"path",get:function(){return this._binding.path},set:function(t){this._binding.path=t}},{key:"proxy",get:function(){return this._binding.proxy},set:function(t){this._binding.proxy=t}},{key:PR,get:function(){return this._binding}}]),t}(),YB=Dn((jB=qB).prototype,"_binding",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new OR}}),WB=jB))||WB,LR=En("cc.animation.Channel")((QB=function(){function t(t){this.name="",Mn(this,"_curve",ZB,this),this._curve=t}return Ur(t,[{key:"curve",get:function(){return this._curve}}]),t}(),ZB=Dn((JB=QB).prototype,"_curve",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),KB=JB))||KB,kR=En("cc.animation.SingleChannelTrack")((iR=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_channel",eR,Pn(e)),e._channel=new LR(e.createCurve()),e}on(e,t);var i=e.prototype;return i.channels=function(){return[this._channel]},i.createCurve=function(){throw new Error("Not impl")},i[cB]=function(){var t=this._channel.curve;return new VR(t)},Ur(e,[{key:"channel",get:function(){return this._channel}}]),e}(FR),eR=Dn((tR=iR).prototype,"_channel",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),$B=tR))||$B,VR=function(){function t(t){this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t)},t}(),NR=(En("cc.animation.RealArrayTrack")((sR=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,Mn(e,"_channels",nR,Pn(e)),e}on(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[cB]=function(){return new NR(this._channels.map((function(t){return t.curve})))},Ur(e,[{key:"elementCount",get:function(){return this._channels.length},set:function(t){var e=this._channels.length;if(t<e)this._channels.splice(t);else if(t>e){var i;(i=this._channels).push.apply(i,Array.from({length:t-e},(function(){return new LR(new Aa)})))}}}]),e}(FR),nR=Dn((rR=sR).prototype,"_channels",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),rR)),function(){function t(t){this._curves=t,this._result=new Array(t.length).fill(0)}return t.prototype.evaluate=function(t){for(var e=this._result,i=e.length,r=0;r<i;++r)e[r]=this._curves[r].evaluate(t);return this._result},t}()),GR=En("cc.animation.UniformProxyFactory")((cR=function(){function t(t,e){Mn(this,"passIndex",lR,this),Mn(this,"uniformName",hR,this),Mn(this,"channelIndex",uR,this),this.passIndex=e||0,this.uniformName=t||""}return t.prototype.forTarget=function(t){var e=t.passes[this.passIndex],i=e.getHandle(this.uniformName);if(!i)throw new Error('Material "'+t.name+'" has no uniform "'+this.uniformName+'"');if(ys.getTypeFromHandle(i)<it.SAMPLER1D){var r=void 0===this.channelIndex?i:e.getHandle(this.uniformName,this.channelIndex,it.FLOAT);if(!r)throw new Error('Uniform "'+this.uniformName+" (in material "+t.name+") has no channel "+this.channelIndex+'"');return function(t,e){for(var i,r=hn(t.shaderInfo.blocks);!(i=r()).done;)for(var n,s=i.value,a=hn(s.members);!(n=a()).done;){var o=n.value;if(o.name===e)return o.count>1}return!1}(e,this.uniformName)?{set:function(t){e.setUniformArray(r,t)}}:{set:function(t){e.setUniform(r,t)}}}var n=ys.getBindingFromHandle(i),s=e.properties[this.uniformName],a=s&&s.value?s.value+"-texture":Es(s.type),o=os.get(a);return o||(bn("Illegal texture default value: "+a+"."),o=os.get("default-texture")),{set:function(t){t||(t=o);var i=t.getGFXTexture();i&&i.width&&i.height&&(e.bindTexture(n,i),t instanceof fs&&e.bindSampler(n,Ci.gfxDevice.getSampler(t.getSamplerInfo())))}}},t}(),lR=Dn((oR=cR).prototype,"passIndex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),hR=Dn(oR.prototype,"uniformName",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),uR=Dn(oR.prototype,"channelIndex",[Ta],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),aR=oR))||aR,zR=En("cc.animation.MorphWeightValueProxy")((mR=function(){function t(){Mn(this,"subMeshIndex",dR,this),Mn(this,"shapeIndex",pR,this)}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),dR=Dn((fR=mR).prototype,"subMeshIndex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pR=Dn(fR.prototype,"shapeIndex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_R=fR))||_R,UR=En("cc.animation.MorphWeightsValueProxy")((bR=function(){function t(){Mn(this,"subMeshIndex",vR,this)}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),vR=Dn((yR=bR).prototype,"subMeshIndex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),gR=yR))||gR,HR=En("cc.animation.MorphWeightsAllValueProxy")(SR=function(){function t(){}return t.prototype.forTarget=function(t){return{set:function(e){for(var i,r,n=null!==(i=null===(r=t.mesh)||void 0===r?void 0:r.struct.primitives.length)&&void 0!==i?i:0,s=0;s<n;++s)t.setWeights(e,s)}}},t}())||SR;function XR(t,e,i,r){var n,s,a,o,h,u,c=new e,_=new e,f=new e,d=En(t)((u=function(){function t(t,i,r){Mn(this,"dataPoint",a,this),Mn(this,"inTangent",o,this),Mn(this,"outTangent",h,this),this.dataPoint=t||new e,this.inTangent=i||new e,this.outTangent=r||new e}var n=t.prototype;return n.lerp=function(t,e,n){var s=this.dataPoint,a=t.dataPoint;_=i(_,this.inTangent,n),f=i(f,t.outTangent,n);var o=e*e*e,l=e*e,h=o-2*l+e,u=-2*o+3*l,d=o-l;return c=i(c,s,2*o-3*l+1),c=r(c,c,_,h),c=r(c,c,a,u),c=r(c,c,f,d)},n.getNoLerp=function(){return this.dataPoint},t}(),a=Dn((s=u).prototype,"dataPoint",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new e}}),o=Dn(s.prototype,"inTangent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new e}}),h=Dn(s.prototype,"outTangent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new e}}),n=s))||n;if(e===l){var p=d.prototype.lerp;d.prototype.lerp=function(t,e,i){var r=p.call(this,t,e,i);return l.normalize(r,r),r}}return d}var WR,jR,YR,qR,KR,JR,ZR=XR("cc.CubicSplineVec2Value",i,i.multiplyScalar,i.scaleAndAdd),QR=XR("cc.CubicSplineVec3Value",n,n.multiplyScalar,n.scaleAndAdd),$R=XR("cc.CubicSplineVec4Value",a,a.multiplyScalar,a.scaleAndAdd),tD=XR("cc.CubicSplineQuatValue",l,l.multiplyScalar,l.scaleAndAdd),eD=En("cc.CubicSplineNumberValue")((ER=function(){function t(t,e,i){Mn(this,"dataPoint",CR,this),Mn(this,"inTangent",xR,this),Mn(this,"outTangent",wR,this),this.dataPoint=t,this.inTangent=e,this.outTangent=i}var e=t.prototype;return e.lerp=function(t,e,i){var r=this.dataPoint,n=t.dataPoint,s=e*e*e,a=e*e;return r*(2*s-3*a+1)+this.outTangent*i*(s-2*a+e)+n*(-2*s+3*a)+t.inTangent*i*(s-a)},e.getNoLerp=function(){return this.dataPoint},t}(),CR=Dn((TR=ER).prototype,"dataPoint",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),xR=Dn(TR.prototype,"inTangent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),wR=Dn(TR.prototype,"outTangent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),AR=TR))||AR,iD=En("cc.animation.RealTrack")(WR=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.prototype.createCurve=function(){return new Aa},e}(kR))||WR;function rD(t){return 0===t.keyFramesCount?void 0:t}var nD,sD,aD,oD,lD,hD,uD,cD,_D,fD,dD,pD,mD=["X","Y","Z","W"],gD=En("cc.animation.VectorTrack")((JR=function(t){function e(){var e;e=t.call(this)||this,Mn(e,"_channels",qR,Pn(e)),Mn(e,"_nComponents",KR,Pn(e)),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var r=new LR(new Aa);r.name=mD[i],e._channels[i]=r}return e}on(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[cB]=function(){switch(this._nComponents){default:case 2:return new yD(rD(this._channels[0].curve),rD(this._channels[1].curve));case 3:return new vD(rD(this._channels[0].curve),rD(this._channels[1].curve),rD(this._channels[2].curve));case 4:return new bD(rD(this._channels[0].curve),rD(this._channels[1].curve),rD(this._channels[2].curve),rD(this._channels[3].curve))}},Ur(e,[{key:"componentsCount",get:function(){return this._nComponents},set:function(t){this._nComponents=t}}]),e}(FR),qR=Dn((YR=JR).prototype,"_channels",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),KR=Dn(YR.prototype,"_nComponents",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 4}}),jR=YR))||jR,yD=function(){function t(t,e){this._result=new i,this._x=t,this._y=e}return t.prototype.evaluate=function(t,e){return this._x&&this._y||!e.getValue||i.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._result},t}(),vD=function(){function t(t,e,i){this._result=new n,this._x=t,this._y=e,this._z=i}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z||!e.getValue||n.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._z&&(this._result.z=this._z.evaluate(t)),this._result},t}(),bD=function(){function t(t,e,i,r){this._result=new a,this._x=t,this._y=e,this._z=i,this._w=r}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z&&this._w||!e.getValue||a.copy(this._result,e.getValue()),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._z&&(this._result.z=this._z.evaluate(t)),this._w&&(this._result.w=this._w.evaluate(t)),this._result},t}(),SD=En("cc.animation.QuatTrack")(nD=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.createCurve=function(){return new Ca},i[cB]=function(){return new AD(this.channels()[0].curve)},e}(kR))||nD,AD=function(){function t(t){this._result=new l,this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t,this._result),this._result},t}(),TD=["Red","Green","Blue","Alpha"],CD=En("cc.animation.ColorTrack")((lD=function(t){function e(){var e;e=t.call(this)||this,Mn(e,"_channels",oD,Pn(e)),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var r=new LR(new Aa);r.name=TD[i],e._channels[i]=r}return e}on(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[cB]=function(){return new xD(rD(this._channels[0].curve),rD(this._channels[1].curve),rD(this._channels[2].curve),rD(this._channels[3].curve))},e}(FR),oD=Dn((aD=lD).prototype,"_channels",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),sD=aD))||sD,xD=function(){function t(t,e,i,r){this._result=new y,this._x=t,this._y=e,this._z=i,this._w=r}return t.prototype.evaluate=function(t,e){return this._x&&this._y&&this._z&&this._w||!e.getValue||y.copy(this._result,e.getValue()),this._x&&(this._result.r=this._x.evaluate(t)),this._y&&(this._result.g=this._y.evaluate(t)),this._z&&(this._result.b=this._z.evaluate(t)),this._w&&(this._result.a=this._w.evaluate(t)),this._result},t}(),wD=["Width","Height"],ED=En("cc.animation.SizeTrack")((_D=function(t){function e(){var e;e=t.call(this)||this,Mn(e,"_channels",cD,Pn(e)),e._channels=new Array(2);for(var i=0;i<e._channels.length;++i){var r=new LR(new Aa);r.name=wD[i],e._channels[i]=r}return e}on(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[cB]=function(){return new BD(rD(this._channels[0].curve),rD(this._channels[1].curve))},e}(FR),cD=Dn((uD=_D).prototype,"_channels",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),hD=uD))||hD,BD=function(){function t(t,e){this._result=new d,this._width=t,this._height=e}return t.prototype.evaluate=function(t,e){if((!this._width||!this._height)&&e.getValue){var i=e.getValue();this._result.x=i.x,this._result.y=i.y}return this._width&&(this._result.width=this._width.evaluate(t)),this._height&&(this._result.height=this._height.evaluate(t)),this._result},t}(),RD=En("cc.animation.ObjectTrack")(fD=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.prototype.createCurve=function(){return new xa},e}(kR))||fD,DD=Symbol("[[Owner]]");function MD(t,e){gn(t[DD]===e)}!function(t){t[t.FLOAT=0]="FLOAT",t[t.BOOLEAN=1]="BOOLEAN",t[t.TRIGGER=2]="TRIGGER",t[t.INTEGER=3]="INTEGER"}(dD||(dD={})),function(t){t[t.AFTER_CONSUMED=0]="AFTER_CONSUMED",t[t.NEXT_FRAME_OR_AFTER_CONSUMED=1]="NEXT_FRAME_OR_AFTER_CONSUMED"}(pD||(pD={}));var PD,ID,OD,FD,LD,kD,VD,ND,GD,zD,UD,HD,XD,WD,jD,YD=function(){function t(t,e){this.type=void 0,this.resetMode=pD.AFTER_CONSUMED,this._value=void 0,this._refs=[],this.type=t,this._value=e}return t.prototype.bind=function(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return this._refs.push({fn:t,thisArg:e,args:r}),this._value},Ur(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t;for(var e,i=hn(this._refs);!(e=i()).done;){var r=e.value,n=r.fn,s=r.thisArg,a=r.args;n.call.apply(n,[s,t].concat(a))}}}]),t}(),qD=function(t){function e(e){var i;return(i=t.call(this,e+" transition is invalid")||this).name="TransitionRejectError",i}return on(e,t),e}(wa(Error)),KD=function(t){function e(e){return t.call(this,"Graph variable "+e+" is not defined")||this}return on(e,t),e}(wa(Error)),JD=function(t){function e(e,i,r){return t.call(this,"Expect graph variable "+e+" to have type '"+i+"' instead of received '"+(null!=r?r:typeof r)+"'")||this}return on(e,t),e}(wa(Error)),ZD=Symbol("[[createEval]]"),QD=Symbol("[[Outgoing transitions]]"),$D=Symbol("[[Incoming transitions]]"),tM=En("cc.animation.State")((FD=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"name",OD,Pn(e)),e[QD]=[],e[$D]=[],e}return on(e,t),e}(ma),OD=Dn((ID=FD).prototype,"name",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),PD=ID))||PD,eM=En("cc.animation.InteractiveState")((ND=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,Mn(e,"_components",VD,Pn(e)),e}on(e,t);var i=e.prototype;return i.addComponent=function(t){var e=new t;return this._components.push(e),e},i.removeComponent=function(t){Ea(this._components,t)},i.instantiateComponents=function(){return this._components.map((function(t){return Ba(t)}))},Ur(e,[{key:"components",get:function(){return this._components}}]),e}(tM),VD=Dn((kD=ND).prototype,"_components",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LD=kD))||LD,iM=En("cc.animation.Motion")((jD=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,Mn(e,"motion",UD,Pn(e)),Mn(e,"speed",HD,Pn(e)),Mn(e,"speedMultiplier",XD,Pn(e)),Mn(e,"speedMultiplierEnabled",WD,Pn(e)),e}return on(e,t),e.prototype.clone=function(){var t,i,r=new e;return r.motion=null!==(t=null===(i=this.motion)||void 0===i?void 0:i.clone())&&void 0!==t?t:null,r.speed=this.speed,r.speedMultiplier=this.speedMultiplier,r.speedMultiplierEnabled=this.speedMultiplierEnabled,r},e}(eM),UD=Dn((zD=jD).prototype,"motion",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),HD=Dn(zD.prototype,"speed",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),XD=Dn(zD.prototype,"speedMultiplier",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),WD=Dn(zD.prototype,"speedMultiplierEnabled",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),GD=zD))||GD;function rM(t,e,i){if(Ra(t,e),Ra(t,i),e===i)return t;var r=t[e];if(e<i)for(var n=e+1;n<=i;++n)t[n-1]=t[n];else for(var s=e;s!==i;--s)t[s]=t[s-1];return t[i]=r,t}var nM,sM,aM,oM,lM,hM,uM,cM,_M,fM,dM,pM,mM,gM,yM,vM,bM,SM,AM,TM,CM,xM,wM,EM,BM,RM,DM,MM,PM,IM,OM,FM,LM,kM,VM,NM,GM,zM,UM,HM,XM,WM,jM,YM,qM,KM,JM,ZM,QM,$M,tP,eP,iP,rP,nP,sP,aP,oP=Symbol("[[OnAfterDeserialized]]"),lP=En("cc.animation.Transition")((hM=function(t){function e(e,i,r){var n;return n=t.call(this)||this,Mn(n,"from",aM,Pn(n)),Mn(n,"to",oM,Pn(n)),Mn(n,"conditions",lM,Pn(n)),n[DD]=void 0,n.from=e,n.to=i,r&&(n.conditions=r),n}return on(e,t),e}(ma),aM=Dn((sM=hM).prototype,"from",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),oM=Dn(sM.prototype,"to",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),lM=Dn(sM.prototype,"conditions",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),nM=sM))||nM;!function(t){t[t.NONE=0]="NONE",t[t.CURRENT_STATE=1]="CURRENT_STATE",t[t.NEXT_STATE=2]="NEXT_STATE",t[t.CURRENT_STATE_THEN_NEXT_STATE=3]="CURRENT_STATE_THEN_NEXT_STATE",t[t.NEXT_STATE_THEN_CURRENT_STATE=4]="NEXT_STATE_THEN_CURRENT_STATE"}(aP||(aP={}));var hP,uP=En("cc.animation.AnimationTransition")((vM=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,Mn(e,"duration",_M,Pn(e)),Mn(e,"relativeDuration",fM,Pn(e)),Mn(e,"exitConditionEnabled",dM,Pn(e)),Mn(e,"destinationStart",pM,Pn(e)),Mn(e,"relativeDestinationStart",mM,Pn(e)),Mn(e,"interruptionSource",gM,Pn(e)),Mn(e,"_exitCondition",yM,Pn(e)),e}return on(e,t),Ur(e,[{key:"exitCondition",get:function(){return this._exitCondition},set:function(t){this._exitCondition=t}},{key:"interruptible",get:function(){return this.interruptionSource!==aP.NONE},set:function(t){this.interruptionSource=t?aP.CURRENT_STATE_THEN_NEXT_STATE:aP.NONE}}]),e}(lP),_M=Dn((cM=vM).prototype,"duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),fM=Dn(cM.prototype,"relativeDuration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),dM=Dn(cM.prototype,"exitConditionEnabled",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),pM=Dn(cM.prototype,"destinationStart",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),mM=Dn(cM.prototype,"relativeDestinationStart",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),gM=Dn(cM.prototype,"interruptionSource",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return aP.NONE}}),yM=Dn(cM.prototype,"_exitCondition",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),uM=cM))||uM,cP=En("cc.animation.EmptyState")(bM=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e}(tM))||bM,_P=En("cc.animation.EmptyStateTransition")((wM=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,Mn(e,"duration",TM,Pn(e)),Mn(e,"destinationStart",CM,Pn(e)),Mn(e,"relativeDestinationStart",xM,Pn(e)),e}return on(e,t),e}(lP),TM=Dn((AM=wM).prototype,"duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),CM=Dn(AM.prototype,"destinationStart",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),xM=Dn(AM.prototype,"relativeDestinationStart",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),SM=AM))||SM,fP=En("cc.animation.StateMachine")((OM=function(t){on(i,t);var e=i.prototype;function i(){var e;return e=t.call(this)||this,Mn(e,"_states",RM,Pn(e)),Mn(e,"_transitions",DM,Pn(e)),Mn(e,"_entryState",MM,Pn(e)),Mn(e,"_exitState",PM,Pn(e)),Mn(e,"_anyState",IM,Pn(e)),e._entryState=e._addState(new tM),e._entryState.name="Entry",e._exitState=e._addState(new tM),e._exitState.name="Exit",e._anyState=e._addState(new tM),e._anyState.name="Any",e}return e.__callOnAfterDeserializeRecursive=function(){this[oP]();for(var t=this._states.length,e=0;e<t;++e){var i=this._states[e];i instanceof dP&&i.stateMachine.__callOnAfterDeserializeRecursive()}},e[oP]=function(){this._states.forEach((function(){})),this._transitions.forEach((function(t){t.from[QD].push(t),t.to[$D].push(t)}))},e[ZD]=function(){throw new Error("Method not implemented.")},e.states=function(){return this._states},e.transitions=function(){return this._transitions},e.getTransitionsBetween=function(t,e){return MD(t,this),MD(e,this),t[QD].filter((function(t){return t.to===e}))},e.getOutgoings=function(t){return MD(t,this),t[QD]},e.getIncomings=function(t){return MD(t,this),t[$D]},e.addMotion=function(){return this._addState(new iM)},e.addSubStateMachine=function(){return this._addState(new dP)},e.addEmpty=function(){return this._addState(new cP)},e.remove=function(t){MD(t,this),t!==this.entryState&&t!==this.exitState&&t!==this.anyState&&(this.eraseTransitionsIncludes(t),Ea(this._states,t))},e.connect=function(t,e,i){if(MD(t,this),MD(e,this),e===this.entryState)throw new qD("to-entry");if(e===this.anyState)throw new qD("to-any");if(t===this.exitState)throw new qD("from-exit");var r=t instanceof iM||t===this._anyState?new uP(t,e,i):t instanceof cP?new _P(t,e,i):new lP(t,e,i);return this._transitions.push(r),t[QD].push(r),e[$D].push(r),r},e.disconnect=function(t,e){MD(t,this),MD(e,this);for(var i=t[QD],r=e[$D],n=this._transitions,s=i.filter((function(t){return t.to===e})),a=s.length,o=function(t){var e=s[t];Ea(i,e),gn(Ea(n,e)),Tn(Da(r,(function(t){return t===e})))},l=0;l<a;++l)o(l)},e.removeTransition=function(t){gn(Ea(this._transitions,t)),Tn(Da(t.from[QD],(function(e){return e===t}))),Tn(Da(t.to[$D],(function(e){return e===t})))},e.eraseOutgoings=function(t){var e=this;MD(t,this);for(var i=t[QD],r=function(t){var r=i[t],n=r.to;gn(Ea(e._transitions,r)),Tn(Da(n[$D],(function(t){return t===r})))},n=0;n<i.length;++n)r(n);i.length=0},e.eraseIncomings=function(t){var e=this;MD(t,this);for(var i=t[$D],r=function(t){var r=i[t],n=r.from;gn(Ea(e._transitions,r)),Tn(Da(n[QD],(function(t){return t===r})))},n=0;n<i.length;++n)r(n);i.length=0},e.eraseTransitionsIncludes=function(t){this.eraseIncomings(t),this.eraseOutgoings(t)},e.adjustTransitionPriority=function(t,e){var i=t.from;if(0!==e){var r=i[QD],n=r.indexOf(t);rM(r,n,T(n+e,0,r.length-1))}},e.clone=function(){for(var t,e=new i,r=new Map,n=hn(this._states);!(t=n()).done;){var s=t.value;switch(s){case this._entryState:r.set(s,e._entryState);break;case this._exitState:r.set(s,e._exitState);break;case this._anyState:r.set(s,e._anyState);break;default:if(s instanceof iM||s instanceof dP){var a=s.clone();e._addState(a),r.set(s,a)}}}for(var o,l=hn(this._transitions);!(o=l()).done;){var h=o.value,u=r.get(h.from),c=r.get(h.to),_=e.connect(u,c);_.conditions=h.conditions.map((function(t){return t.clone()})),_ instanceof uP&&(_.duration=h.duration,_.exitConditionEnabled=h.exitConditionEnabled,_.exitCondition=h.exitCondition)}return e},e._addState=function(t){return this._states.push(t),t},Ur(i,[{key:"entryState",get:function(){return this._entryState}},{key:"exitState",get:function(){return this._exitState}},{key:"anyState",get:function(){return this._anyState}}]),i}(ma),RM=Dn((BM=OM).prototype,"_states",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),DM=Dn(BM.prototype,"_transitions",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),MM=Dn(BM.prototype,"_entryState",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),PM=Dn(BM.prototype,"_exitState",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),IM=Dn(BM.prototype,"_anyState",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),EM=BM))||EM,dP=En("cc.animation.SubStateMachine")((VM=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,Mn(e,"_stateMachine",kM,Pn(e)),e}return on(e,t),e.prototype.clone=function(){var t=new e;return t._stateMachine=this._stateMachine.clone(),t},Ur(e,[{key:"stateMachine",get:function(){return this._stateMachine}}]),e}(eM),kM=Dn((LM=VM).prototype,"_stateMachine",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new fP}}),FM=LM))||FM,pP=En("cc.animation.Layer")((WM=function(){function t(){this[DD]=void 0,Mn(this,"_stateMachine",zM,this),Mn(this,"name",UM,this),Mn(this,"weight",HM,this),Mn(this,"mask",XM,this),this._stateMachine=new fP}return Ur(t,[{key:"stateMachine",get:function(){return this._stateMachine}}]),t}(),zM=Dn((GM=WM).prototype,"_stateMachine",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),UM=Dn(GM.prototype,"name",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),HM=Dn(GM.prototype,"weight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),XM=Dn(GM.prototype,"mask",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),NM=GM))||NM;!function(t){t[t.override=0]="override",t[t.additive=1]="additive"}(hP||(hP={})),gn(0==(0|pD.AFTER_CONSUMED<<1));var mP=En("cc.animation.PlainVariable")((JM=function(){function t(t){if(Mn(this,"_type",qM,this),Mn(this,"_value",KM,this),void 0!==t)switch(this._type=t,t){default:break;case dD.FLOAT:case dD.INTEGER:this._value=0;break;case dD.BOOLEAN:this._value=!1}}return Ur(t,[{key:"type",get:function(){return this._type}},{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),qM=Dn((YM=JM).prototype,"_type",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dD.FLOAT}}),KM=Dn(YM.prototype,"_value",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),jM=YM))||jM,gP=En("cc.animation.TriggerVariable")((tP=function(){function t(){Mn(this,"_flags",$M,this)}return Ur(t,[{key:"type",get:function(){return dD.TRIGGER}},{key:"value",get:function(){return!!((1&this._flags)>>0)},set:function(t){t?this._flags|=1:this._flags&=-2}},{key:"resetMode",get:function(){return(6&this._flags)>>1},set:function(t){this._flags&=-7,this._flags|=t<<1}}]),t}(),$M=Dn((QM=tP).prototype,"_flags",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZM=QM))||ZM,yP=En("cc.animation.AnimationGraph")((sP=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_layers",rP,Pn(e)),Mn(e,"_variables",nP,Pn(e)),e}on(e,t);var i=e.prototype;return i.onLoaded=function(){for(var t=this._layers,e=t.length,i=0;i<e;++i)t[i].stateMachine.__callOnAfterDeserializeRecursive()},i.addLayer=function(){var t=new pP;return this._layers.push(t),t},i.removeLayer=function(t){Ma.removeAt(this._layers,t)},i.moveLayer=function(t,e){rM(this._layers,t,e)},i.addBoolean=function(t,e){void 0===e&&(e=!1);var i=new mP(dD.BOOLEAN);i.value=e,this._variables[t]=i},i.addFloat=function(t,e){void 0===e&&(e=0);var i=new mP(dD.FLOAT);i.value=e,this._variables[t]=i},i.addInteger=function(t,e){void 0===e&&(e=0);var i=new mP(dD.INTEGER);i.value=e,this._variables[t]=i},i.addTrigger=function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=pD.AFTER_CONSUMED);var r=new gP;r.resetMode=i,r.value=e,this._variables[t]=r},i.removeVariable=function(t){delete this._variables[t]},i.getVariable=function(t){return this._variables[t]},i.renameVariable=function(t,e){var i=this._variables;t in i&&(e in i||(this._variables=Object.entries(i).reduce((function(i,r){var n=r[0],s=r[1];return i[n===t?e:n]=s,i}),{})))},Ur(e,[{key:"layers",get:function(){return this._layers}},{key:"variables",get:function(){return Object.entries(this._variables)}}]),e}(Qr),rP=Dn((iP=sP).prototype,"_layers",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),nP=Dn(iP.prototype,"_variables",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),eP=iP))||eP,vP=t("RatioSampler",function(){function t(t){var e,i;this.ratios=void 0,this._findRatio=void 0,this.ratios=t;for(var r=!0,n=1,s=t.length;n<s;n++)if(e=t[n]-t[n-1],1===n)i=e;else if(Math.abs(e-i)>1e-6){r=!1;break}this._findRatio=r?TP:Oa}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());Er.RatioSampler=vP;var bP=t("AnimCurve",function(){function t(e,i){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=i,this._values=e.values;var r=function(e){return"string"==typeof e?e:Array.isArray(e)?e[0]===e[1]&&e[2]===e[3]?t.Linear:t.Bezier(e):t.Linear};if(void 0!==e.easingMethod)this.type=r(e.easingMethod);else if(Array.isArray(e.easingMethods))this.types=e.easingMethods.map(r);else if(void 0!==e.easingMethods){this.types=new Array(this._values.length).fill(null);for(var n=0,s=Object.keys(e.easingMethods);n<s.length;n++){var a=s[n];this.types[a]=r(e.easingMethods[a])}}else this.type=null;var o=e.values[0];(void 0===e.interpolate||e.interpolate)&&(this._lerp=PP(o)),void 0!==e._arrayLength&&(this._array=new Array(e._arrayLength))}t.Bezier=function(t){return t};var e=t.prototype;return e.hasLerp=function(){return!!this._lerp},e.valueAt=function(t){if(void 0===this._array){var e=this._values[t];return e&&e.getNoLerp?e.getNoLerp():e}for(var i=0;i<this._array.length;++i)this._array[i]=this._values[this._array.length*t+i];return this._array},e.valueBetween=function(t,e,i,r,n){if(this._lerp){var s=this.types?this.types[e]:this.type,a=n-i,o=(t-i)/a;if(s&&(o=AP(o,s)),void 0===this._array){var l=this._values[e],h=this._values[r];return this._lerp(l,h,o,a*this._duration)}for(var u=0;u<this._array.length;++u){var c=this._values[this._array.length*e+u],_=this._values[this._array.length*r+u];this._array[u]=this._lerp(c,_,o,a*this._duration)}return this._array}if(void 0===this._array)return this.valueAt(e);for(var f=0;f<this._array.length;++f)this._array[f]=this._values[this._array.length*e+f];return this._array},e.empty=function(){return 0===this._values.length},e.constant=function(){return 1===this._values.length},t}());function SP(t,e,i){var r=e.sample(i);if(r<0)if((r=~r)<=0)r=0;else{if(!(r>=e.ratios.length))return t.valueBetween(i,r-1,e.ratios[r-1],r,e.ratios[r]);r=e.ratios.length-1}return t.valueAt(r)}function AP(t,e){if("string"==typeof e){var i=Pa[e];i?t=i(t):Nn(3906,e)}else Array.isArray(e)&&(t=Ia(e,t));return t}function TP(t,e){var i=t.length-1;if(0===i)return 0;var r=t[0];if(e<r)return 0;var n=t[i];if(e>n)return i;var s=(e=(e-r)/(n-r))/(1/i),a=0|s,o=1e-6;return s-a<o?a:a+1-s<o?a+1:~(a+1)}bP.Linear=null,Er.AnimCurve=bP,t("EventInfo",function(){function t(){this.events=[]}return t.prototype.add=function(t,e){this.events.push({func:t||"",params:e||[]})},t}()),Er.sampleAnimationCurve=SP;var CP,xP,wP,EP,BP,RP,DP,MP,PP=function(){function t(t,e,i,r){return t.lerp(e,i,r)}return function(e){if(null!==e){if("number"==typeof e)return x;if("object"==typeof e&&e.constructor){if(e instanceof l)return i=new l,function(t,e,r){return l.slerp(i,t,e,r)};if(e instanceof Fa)return function(t){var e=new t;return function(i,r,n){return t.lerp(e,i,r,n),e}}(e.constructor);if(e.constructor===Number)return x;if(La(e))return t}var i}}}(),IP=En("cc.animation.UntypedTrackChannel")((EP=function(t){function e(){var e;return e=t.call(this,new Aa)||this,Mn(e,"property",wP,Pn(e)),e}return on(e,t),e}(LR),wP=Dn((xP=EP).prototype,"property",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),CP=xP))||CP,OP=En("cc.animation.UntypedTrack")((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,Mn(e,"_channels",DP,Pn(e)),e}on(e,t);var r=e.prototype;return r.channels=function(){return this._channels},r[cB]=function(t){var e=this;if(!t.getValue)throw new Error(Yr(3930));var r=function(t){var i;return null===(i=e._channels.find((function(e){return e.property===t})))||void 0===i?void 0:i.curve},s=t.getValue();switch(!0){default:throw new Error(Yr(3931));case s instanceof i:return new yD(r("x"),r("y"));case s instanceof n:return new vD(r("x"),r("y"),r("z"));case s instanceof a:return new bD(r("x"),r("y"),r("z"),r("w"));case s instanceof y:return new xD(r("r"),r("g"),r("b"),r("a"));case s instanceof d:return new BD(r("width"),r("height"))}},r.addChannel=function(t){var e=new IP;return e.property=t,this._channels.push(e),e},r.upgrade=function(t){var e=this,i=function(t,i){var r=e.channels().find((function(e){return e.property===t}));r&&(i.name=r.name,i.curve.assignSorted(Array.from(r.curve.times()),Array.from(r.curve.values())))},r=t(this.path,this.proxy);switch(r){default:break;case"vec2":case"vec3":case"vec4":var n=new gD;n.path=this.path,n.proxy=this.proxy,n.componentsCount="vec2"===r?2:"vec3"===r?3:4;var s=n.channels(),a=s[0],o=s[1],l=s[2],h=s[3];switch(r){case"vec4":i("w",h);case"vec3":i("z",l);default:case"vec2":i("x",a),i("y",o)}return n;case"color":var u=new CD,c=u.channels(),_=c[0],f=c[1],d=c[2],p=c[3];return i("r",_),i("g",f),i("b",d),i("a",p),i("x",_),i("y",f),i("z",d),i("w",p),u;case"size":}return null},e}(FR),DP=Dn((RP=MP).prototype,"_channels",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),BP=RP))||BP,FP=function(){function t(t){this._keys=[],this._curves=[],this._commonTargets=[],this._ratioSamplers=[],this._runtimeCurves=void 0,this._data=null,this._duration=void 0,this._duration=t}var e=t.prototype;return e.getPropertyCurves=function(){return this._runtimeCurves||this._createPropertyCurves(),this._runtimeCurves},e.toTracks=function(){for(var t,e=[],r=this.keys,s=this.curves,o=this.commonTargets,h=function(t,e,i){for(var r,n=new IR,s=hn(e);!(r=s()).done;){var a=r.value;"string"==typeof a?n.toProperty(a):"number"==typeof a?n.toElement(a):a instanceof BR?n.toHierarchy(a.path):a instanceof RR?n.toComponent(a.component):n.toCustomized(a)}t.path=n,t.proxy=i},u=o.map((function(t){var i=new OP;return h(i,t.modifiers,t.valueAdapter),e.push(i),i})),c=function(){var s,o=t.value,c=o.data,_=c.values;if(0===_.length)return"continue";var f=c.keys<0?[0]:r[c.keys],p=_[0],m=null===(s=c.interpolate)||void 0===s||s;gn("number"!=typeof c._arrayLength||"number"==typeof p);var g=new kP(c,f.length),v=function(t){h(t,o.modifiers,o.valueAdapter)},b=void 0;if("number"==typeof o.commonTarget){if(!_.every((function(t){return"number"==typeof t})))return Rn(3932),"continue";if(o.valueAdapter||1!==o.modifiers.length||"string"!=typeof o.modifiers[0])return Rn(3933),"continue";var S=o.modifiers[0],A=u[o.commonTarget].addChannel(S).curve;b=A}!function(){if("number"==typeof p){if(!_.every((function(t){return"number"==typeof t})))return void Rn(3934);var t;if(b)t=b;else{var r=new iD;v(r),e.push(r),t=r.channel.curve}var s=m?Va.LINEAR:Va.CONSTANT;return t.assignSorted(f,_.map((function(t){return{value:t,interpolationMode:s}}))),void g.convert(t)}if("object"==typeof p)switch(!0){default:break;case LP(_,i):case LP(_,n):case LP(_,a):var o=p instanceof i?2:p instanceof n?3:4,h=new gD;v(h),h.componentsCount=o;var u=h.channels(),c=u[0].curve,S=u[1].curve,A=u[2].curve,T=u[3].curve,C=m?Va.LINEAR:Va.CONSTANT,x=function(t){return{value:t,interpolationMode:C}};switch(o){case 4:T.assignSorted(f,_.map((function(t){return x(t.w)}))),g.convert(T);case 3:A.assignSorted(f,_.map((function(t){return x(t.z)}))),g.convert(A);default:c.assignSorted(f,_.map((function(t){return x(t.x)}))),g.convert(c),S.assignSorted(f,_.map((function(t){return x(t.y)}))),g.convert(S)}return void e.push(h);case LP(_,l):var w=new SD;v(w);var E=m?Ga.SLERP:Ga.CONSTANT;return w.channel.curve.assignSorted(f,_.map((function(t){return{value:l.clone(t),interpolationMode:E}}))),g.convertQuatCurve(w.channel.curve),void e.push(w);case LP(_,y):var B=new CD;v(B);var R=B.channels(),D=R[0].curve,M=R[1].curve,P=R[2].curve,I=R[3].curve,O=m?Va.LINEAR:Va.CONSTANT,F=function(t){return{value:t,interpolationMode:O}};return D.assignSorted(f,_.map((function(t){return F(t.r)}))),g.convert(D),M.assignSorted(f,_.map((function(t){return F(t.g)}))),g.convert(M),P.assignSorted(f,_.map((function(t){return F(t.b)}))),g.convert(P),I.assignSorted(f,_.map((function(t){return F(t.a)}))),g.convert(I),void e.push(B);case LP(_,d):var L=new ED;v(L);var k=L.channels(),V=k[0].curve,N=k[1].curve,G=m?Va.LINEAR:Va.CONSTANT,z=function(t){return{value:t,interpolationMode:G}};return V.assignSorted(f,_.map((function(t){return z(t.width)}))),g.convert(V),N.assignSorted(f,_.map((function(t){return z(t.height)}))),g.convert(N),void e.push(L);case LP(_,eD):var U=new iD;v(U);var H=m?Va.CUBIC:Va.CONSTANT;return U.channel.curve.assignSorted(f,_.map((function(t){return{value:t.dataPoint,leftTangent:t.inTangent,rightTangent:t.outTangent,interpolationMode:H}}))),void e.push(U);case LP(_,ZR):case LP(_,QR):case LP(_,$R):var X=p instanceof ZR?2:p instanceof QR?3:4,W=new gD;v(W),W.componentsCount=X;var j=W.channels(),Y=j[0],q=j[1],K=j[2],J=j[3],Z=m?Va.LINEAR:Va.CONSTANT,Q=function(t,e,i){return{value:t,leftTangent:e,rightTangent:i,interpolationMode:Z}};switch(X){case 4:J.curve.assignSorted(f,_.map((function(t){return Q(t.dataPoint.w,t.inTangent.w,t.outTangent.w)})));case 3:K.curve.assignSorted(f,_.map((function(t){return Q(t.dataPoint.z,t.inTangent.z,t.outTangent.z)})));default:Y.curve.assignSorted(f,_.map((function(t){return Q(t.dataPoint.y,t.inTangent.y,t.outTangent.y)}))),q.curve.assignSorted(f,_.map((function(t){return Q(t.dataPoint.x,t.inTangent.x,t.outTangent.x)})))}return void e.push(W);case _.every((function(t){return t instanceof tD})):Rn(3935)}var $=new RD;v($),$.channel.curve.assignSorted(f,_),e.push($)}()},_=hn(s);!(t=_()).done;)c();return e},e._createPropertyCurves=function(){var t=this;this._ratioSamplers=this._keys.map((function(e){return new vP(e.map((function(e){return e/t._duration})))})),this._runtimeCurves=this._curves.map((function(e){return{curve:new bP(e.data,t._duration),modifiers:e.modifiers,valueAdapter:e.valueAdapter,sampler:t._ratioSamplers[e.data.keys],commonTarget:e.commonTarget}}))},Ur(t,[{key:"keys",get:function(){return this._keys},set:function(t){this._keys=t}},{key:"curves",get:function(){return this._curves},set:function(t){this._curves=t,delete this._runtimeCurves}},{key:"commonTargets",get:function(){return this._commonTargets},set:function(t){this._commonTargets=t}},{key:"data",get:function(){return this._data}}]),t}();function LP(t,e){return t.every((function(t){return t instanceof e}))}var kP=function(){function t(t,e){this._easingMethods=void 0;var i=t.easingMethods;Array.isArray(i)?0===i.length&&0!==e?this._easingMethods=new Array(e).fill(null):this._easingMethods=i:this._easingMethods=void 0===i?new Array(e).fill(t.easingMethod):Array.from({length:e},(function(t,e){var r;return null!==(r=i[e])&&void 0!==r?r:null}))}var e=t.prototype;return e.convert=function(t){var e,i,r,n,s,a,o,l,h,u,c,_,f,d,p,m,g,y,v,b,S,A,T=this._easingMethods;if(T){var C=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(T)&&gn(C===T.length);for(var x=C-1,w=0;w<x;++w){var E=T[w];E&&(Array.isArray(E)?(e=E,i=t.getKeyframeTime(w),r=t.getKeyframeValue(w),n=t.getKeyframeTime(w+1),s=t.getKeyframeValue(w+1),a=void 0,o=void 0,l=void 0,h=void 0,u=void 0,c=void 0,_=void 0,f=void 0,d=void 0,p=void 0,m=void 0,g=void 0,y=void 0,v=void 0,b=void 0,S=void 0,A=void 0,o=e[0],l=e[1],h=e[2],u=e[3],c=r.value,_=3*(n-i),f=3*(s.value-c),m=(1-h)*_,g=(1-u)*f,y=1/3,v=(p=l*f)/(d=o*_),b=Math.sqrt(d*d+p*p)*y,S=g/m,A=Math.sqrt(m*m+g*g)*y,r.interpolationMode=Va.CUBIC,r.tangentWeightMode=(a=r.tangentWeightMode)===Na.NONE?Na.RIGHT:a===Na.LEFT?Na.BOTH:a,r.rightTangent=v,r.rightTangentWeight=b,s.tangentWeightMode=function(t){return t===Na.NONE?Na.LEFT:t===Na.RIGHT?Na.BOTH:t}(s.tangentWeightMode),s.leftTangent=S,s.leftTangentWeight=A):VP(E,t,w))}}}},e.convertQuatCurve=function(t){var e=this._easingMethods;if(e){var i=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(e)&&gn(i===e.length);for(var r=i-1,n=0;n<r;++n){var s=e[n];s&&(Array.isArray(s)?t.getKeyframeValue(n).easingMethod=s.slice():NP(s,t,n))}}}},Ur(t,[{key:"nil",get:function(){return!this._easingMethods||this._easingMethods.every((function(t){return null==t}))}}]),t}();function VP(t,e,i){gn(i!==e.keyFramesCount-1);var r=e.getKeyframeValue(i),n=pI[t];n===ka.CONSTANT?r.interpolationMode=Va.CONSTANT:(r.interpolationMode=Va.LINEAR,r.easingMethod=n)}function NP(t,e,i){gn(i!==e.keyFramesCount-1);var r=e.getKeyframeValue(i),n=pI[t];r.easingMethod=n}var GP,zP,UP,HP,XP,WP,jP,YP,qP,KP,JP,ZP,QP,$P,tI,eI,iI,rI,nI,sI,aI,oI,lI,hI,uI,cI,_I,fI,dI,pI={constant:ka.CONSTANT,linear:ka.LINEAR,quadIn:ka.QUAD_IN,quadOut:ka.QUAD_OUT,quadInOut:ka.QUAD_IN_OUT,quadOutIn:ka.QUAD_OUT_IN,cubicIn:ka.CUBIC_IN,cubicOut:ka.CUBIC_OUT,cubicInOut:ka.CUBIC_IN_OUT,cubicOutIn:ka.CUBIC_OUT_IN,quartIn:ka.QUART_IN,quartOut:ka.QUART_OUT,quartInOut:ka.QUART_IN_OUT,quartOutIn:ka.QUART_OUT_IN,quintIn:ka.QUINT_IN,quintOut:ka.QUINT_OUT,quintInOut:ka.QUINT_IN_OUT,quintOutIn:ka.QUINT_OUT_IN,sineIn:ka.SINE_IN,sineOut:ka.SINE_OUT,sineInOut:ka.SINE_IN_OUT,sineOutIn:ka.SINE_OUT_IN,expoIn:ka.EXPO_IN,expoOut:ka.EXPO_OUT,expoInOut:ka.EXPO_IN_OUT,expoOutIn:ka.EXPO_OUT_IN,circIn:ka.CIRC_IN,circOut:ka.CIRC_OUT,circInOut:ka.CIRC_IN_OUT,circOutIn:ka.CIRC_OUT_IN,elasticIn:ka.ELASTIC_IN,elasticOut:ka.ELASTIC_OUT,elasticInOut:ka.ELASTIC_IN_OUT,elasticOutIn:ka.ELASTIC_OUT_IN,backIn:ka.BACK_IN,backOut:ka.BACK_OUT,backInOut:ka.BACK_IN_OUT,backOutIn:ka.BACK_OUT_IN,bounceIn:ka.BOUNCE_IN,bounceOut:ka.BOUNCE_OUT,bounceInOut:ka.BOUNCE_IN_OUT,bounceOutIn:ka.BOUNCE_OUT_IN,smooth:ka.SMOOTH,fade:ka.FADE};function mI(){throw new Error("split() only valid in Editor.")}En("cc.animation.ExoticAnimation")((UP=function(){function t(){Mn(this,"_nodeAnimations",zP,this)}var e=t.prototype;return e.createEvaluator=function(t){return new wI(this._nodeAnimations,t)},e.addNodeAnimation=function(t){var e=new gI(t);return this._nodeAnimations.push(e),e},e.collectAnimatedJoints=function(){return Array.from(new Set(this._nodeAnimations.map((function(t){return t.path}))))},e.split=function(){return mI()},e.toHashString=function(){return this._nodeAnimations.map((function(t){return t.toHashString()})).join("\n")},t}(),zP=Dn((GP=UP).prototype,"_nodeAnimations",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),GP));var gI=En("cc.animation.ExoticNodeAnimation")((KP=function(){function t(t){Mn(this,"_path",WP,this),Mn(this,"_position",jP,this),Mn(this,"_rotation",YP,this),Mn(this,"_scale",qP,this),this._path=t}var e=t.prototype;return e.createPosition=function(t,e){this._position=new TI(t,new SI(e))},e.createRotation=function(t,e){this._rotation=new TI(t,new AI(e))},e.createScale=function(t,e){this._scale=new TI(t,new SI(e))},e.createEvaluator=function(t){return new EI(this._path,this._position,this._rotation,this._scale,t)},e.split=function(){return mI()},e.toHashString=function(){var t,e,i,r,n,s;return this._path+"\n"+(null!==(t=null===(e=this._position)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"")+(null!==(i=null===(r=this._scale)||void 0===r?void 0:r.toHashString())&&void 0!==i?i:"")+(null!==(n=null===(s=this._rotation)||void 0===s?void 0:s.toHashString())&&void 0!==n?n:"")},Ur(t,[{key:"path",get:function(){return this._path}}]),t}(),WP=Dn((XP=KP).prototype,"_path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),jP=Dn(XP.prototype,"_position",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),YP=Dn(XP.prototype,"_rotation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qP=Dn(XP.prototype,"_scale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),HP=XP))||HP;function yI(t){return t.toPrecision(2)}function vI(t){return t.map(yI).join(" ")}var bI=En("cc.animation.ExoticVectorLikeTrackValues")((tI=function(){function t(t){Mn(this,"_values",QP,this),Mn(this,"_isQuantized",$P,this),this._values=t,this._isQuantized=!1}var e=t.prototype;return e.quantize=function(t){gn(!this._isQuantized),this._values=function(t,e){var i=RI[e],r=1<<i.BYTES_PER_ELEMENT,n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;t.forEach((function(t){n=Math.min(t,n),s=Math.max(t,s)}));var a=s-n,o=i.from(t,(function(t){return(t-n)/a*r}));return new WI(DI(t),o,a,n)}(this._values,t),this._isQuantized=!0},e.toHashString=function(){var t=this._isQuantized,e=this._values;return t+" "+(t?e.toHashString():vI(e))},Ur(t,[{key:"precision",get:function(){return this._isQuantized?this._values.originalPrecision:DI(this._values)}}]),t}(),QP=Dn((ZP=tI).prototype,"_values",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),$P=Dn(ZP.prototype,"_isQuantized",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),JP=ZP))||JP,SI=En("cc.animation.ExoticVec3TrackValues")(eI=function(t){function e(){return t.apply(this,arguments)||this}on(e,t),e.imitate=function(t,i){var r=new e(t);return i._isQuantized&&r.quantize(i._values.quantizationType),r};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?qI(i,t,e):n.fromArray(e,i,3*t)},i.lerp=function(t,e,i,r,s,a){var o=this._values;this._isQuantized?(qI(o,t,r),qI(o,e,s)):(n.fromArray(r,o,3*t),n.fromArray(s,o,3*e)),n.lerp(a,r,s,i)},e}(bI))||eI,AI=En("cc.animation.ExoticQuatTrackValues")(iI=function(t){function e(){return t.apply(this,arguments)||this}on(e,t),e.imitate=function(t,i){var r=new e(t);return i._isQuantized&&r.quantize(i._values.quantizationType),r};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?KI(i,t,e):l.fromArray(e,i,4*t)},i.lerp=function(t,e,i,r,n,s){var a=this._values;this._isQuantized?(KI(a,t,r),KI(a,e,n)):(l.fromArray(r,a,4*t),l.fromArray(n,a,4*e)),l.slerp(s,r,n,i)},e}(bI))||iI,TI=En("cc.animation.ExoticTrack")((oI=function(){function t(t,e){Mn(this,"times",sI,this),Mn(this,"values",aI,this),this.times=t,this.values=e}return t.prototype.toHashString=function(){var t=this.times,e=this.values;return"times: "+vI(t)+"; values: "+e.toHashString()},t}(),sI=Dn((nI=oI).prototype,"times",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),aI=Dn(nI.prototype,"values",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),rI=nI))||rI;function CI(t,e){t.length,gn(0!==t.length);var i=0,r=0,n=Oa(t,e);if(n>=0)i=n;else{var s=~n,a=s-1;i=a;var o=t[s],l=t[a];r=(e-l)/(o-l)}return{index:i,ratio:r}}!function(){function t(){this._reset()}var e=t.prototype;e.transformTime=function(t){return t-this._timeOffset},e.calculate=function(t,e,i){this._reset();var r=t.length;if(r){var n=t[0],s=t[r-1],a=T(e,n,s),o=T(i,n,s);this._timeOffset=a;var l=function(t,e,i){var r=t.length;gn(i>=e&&e>=t[0]&&i<=t[r-1]);var n=CI(t,e),s=n.index,a=n.ratio,o=CI(t,i);return{fromIndex:s,fromRatio:a,toIndex:o.index,toRatio:o.ratio}}(t,a,o),h=l.fromIndex,u=l.fromRatio,c=l.toIndex,_=l.toRatio,f=!u,d=!_;h!==c||u!==_?(f||(this.preLerpIndex=h,this.preLerpRatio=u),this.directKeyframesBegin=f?h:h+1,this.directKeyframesEnd=c+1,d||(this.postLerpIndex=c,this.postLerpRatio=_)):f?(this.directKeyframesBegin=h,this.directKeyframesEnd=h+1):(this.preLerpIndex=h,this.preLerpRatio=u)}},e._reset=function(){this.preLerpIndex=-1,this.preLerpRatio=0,this.directKeyframesBegin=0,this.directKeyframesEnd=0,this.postLerpIndex=-1,this.postLerpRatio=0,this._timeOffset=0},Ur(t,[{key:"keyframesCount",get:function(){var t=this.preLerpIndex,e=this.directKeyframesBegin;return 0+(t<0?0:1)+(this.directKeyframesEnd-e)+(this.postLerpIndex<0?0:1)}}])}();var xI,wI=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluator(e)}))}return t.prototype.evaluate=function(t){this._nodeEvaluations.forEach((function(e){e.evaluate(t)}))},t}(),EI=function(){function t(t,e,i,r,s){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=YI(e.times,e.values,n,t,"position",s)),i&&(this._rotation=YI(i.times,i.values,l,t,"rotation",s)),r&&(this._scale=YI(r.times,r.values,n,t,"scale",s))}return t.prototype.evaluate=function(t){if(this._position){var e=this._position.evaluator.evaluate(t);this._position.runtimeBinding.setValue(e)}if(this._rotation){var i=this._rotation.evaluator.evaluate(t);this._rotation.runtimeBinding.setValue(i)}if(this._scale){var r=this._scale.evaluator.evaluate(t);this._scale.runtimeBinding.setValue(r)}},t}(),BI=function(){function t(t,e,i){this._times=void 0,this._inputSampleResultCache={just:!1,index:-1,nextIndex:-1,ratio:0},this._values=void 0,this._prevValue=void 0,this._nextValue=void 0,this._resultValue=void 0,this._times=t,this._values=e,this._prevValue=new i,this._nextValue=new i,this._resultValue=new i}return t.prototype.evaluate=function(t){var e=this._times,i=this._values,r=this._resultValue;if(0===e.length)return r;var n=function(t,e,i){var r=t.length,n=t[0],s=t[r-1];if(e<n)i.just=!0,i.index=0;else if(e>s)i.just=!0,i.index=r-1;else{var a=Oa(t,e);if(a>=0)i.just=!0,i.index=a;else{var o=~a,l=o-1,h=t[l],u=t[o],c=(e-t[l])/(u-h);i.just=!1,i.index=l,i.nextIndex=o,i.ratio=c}}return i}(e,t,this._inputSampleResultCache);return n.just?i.get(n.index,r):i.lerp(n.index,n.nextIndex,n.ratio,this._prevValue,this._nextValue,r),r},t}(),RI={uint8:Uint8Array,uint16:Uint16Array};function DI(t){switch(t.BYTES_PER_ELEMENT){default:case 4:return xI.FLOAT_32;case 8:return xI.FLOAT_64}}!function(t){t[t.FLOAT_32=0]="FLOAT_32",t[t.FLOAT_64=1]="FLOAT_64"}(xI||(xI={}));var MI,PI,II,OI,FI,LI,kI,VI,NI,GI,zI,UI,HI,XI,WI=En("cc.animation.QuantizedFloatArray")((dI=function(){function t(t,e,i,r){void 0===r&&(r=0),Mn(this,"originalPrecision",uI,this),Mn(this,"min",cI,this),Mn(this,"extent",_I,this),Mn(this,"values",fI,this),this.originalPrecision=t,this.values=e,this.extent=i,this.min=r}return t.prototype.toHashString=function(){var t=this.originalPrecision,e=this.min,i=this.extent,r=this.values;return t+" "+yI(e)+" "+yI(i)+" "+r.join(" ")},Ur(t,[{key:"quantizationType",get:function(){switch(this.values.BYTES_PER_ELEMENT){default:case 1:return"uint8";case 2:return"uint16"}}}]),t}(),uI=Dn((hI=dI).prototype,"originalPrecision",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),cI=Dn(hI.prototype,"min",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_I=Dn(hI.prototype,"extent",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),fI=Dn(hI.prototype,"values",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),lI=hI))||lI;function jI(t,e){return t.values[e]/(1<<t.values.BYTES_PER_ELEMENT)*t.extent+t.min}function YI(t,e,i,r,n,s){var a=new OR;a.path=(new IR).toHierarchy(r).toProperty(n);var o=s(a);return o?{runtimeBinding:o,evaluator:new BI(t,e,i)}:null}function qI(t,e,i){n.set(i,jI(t,3*e+0),jI(t,3*e+1),jI(t,3*e+2))}function KI(t,e,i){l.set(i,jI(t,4*e+0),jI(t,4*e+1),jI(t,4*e+2),jI(t,4*e+3))}var JI=Symbol("SearchForRootBonePath"),ZI=Symbol("ExoticAnimation"),QI=Symbol("[[EmbeddedPlayerCount]]"),$I=Symbol("[[GetEmbeddedPlayers]]"),tO=Symbol("[[AddEmbeddedPlayer]]"),eO=Symbol("[[RemoveEmbeddedPlayer]]"),iO=Symbol("[[ClearEmbeddedPlayers]]"),rO=t("AnimationClip",En("cc.AnimationClip")((XI=HI=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,Mn(e,"sample",II,Pn(e)),Mn(e,"speed",OI,Pn(e)),Mn(e,"wrapMode",FI,Pn(e)),Mn(e,"enableTrsBlending",LI,Pn(e)),Mn(e,"_duration",kI,Pn(e)),Mn(e,"_hash",VI,Pn(e)),e.frameRate=0,Mn(e,"_tracks",NI,Pn(e)),Mn(e,"_exoticAnimation",GI,Pn(e)),e._legacyData=void 0,e._legacyDataDirty=!1,Mn(e,"_events",zI,Pn(e)),Mn(e,"_embeddedPlayers",UI,Pn(e)),e._runtimeEvents={ratios:[],eventGroups:[]},e}on(e,t),e.createWithSpriteFrames=function(t,i){var r=new e;r.sample=i||r.sample,r.duration=t.length/r.sample;var n=1/r.sample,s=new RD;return s.path=(new IR).toComponent("cc.Sprite").toProperty("spriteFrame"),s.channels()[0].curve.assignSorted(t.map((function(t,e){return[n*e,t]}))),r.addTrack(s),r};var i=e.prototype;return i.onLoaded=function(){this.frameRate=this.sample,this.events=this._events},i.range=function(){for(var t={min:1/0,max:-1/0},e=this._tracks,i=e.length,r=0;r<i;++r){var n=e[r].range();t.min=Math.min(t.min,n.min),t.max=Math.max(t.max,n.max)}return t},i.getTrack=function(t){return this._tracks[t]},i.addTrack=function(t){var e=this._tracks.length;return this._tracks.push(t),e},i.removeTrack=function(t){this._tracks.splice(t,1)},i.clearTracks=function(){this._tracks.length=0},i.containsAnyEvent=function(){return 0!==this._events.length},i.createEventEvaluator=function(t){return new _O(t,this._runtimeEvents.ratios,this._runtimeEvents.eventGroups,this.wrapMode)},i.containsAnyEmbeddedPlayer=function(){return 0!==this._embeddedPlayers.length},i.createEmbeddedPlayerEvaluator=function(t){return new nO(this._embeddedPlayers,t)},i.createEvaluator=function(t){var e=this,i=t.target;return this._createEvalWithBinder(i,(function(r){if(!t.mask||!r.isMaskedOff(t.mask)){var n=r.createRuntimeBinding(i,e.enableTrsBlending?t.pose:void 0,!1);return null!=n?n:void 0}}),t.rootMotion)},i.destroy=function(){var e;return(null===(e=Er.director.root)||void 0===e?void 0:e.dataPoolManager)&&Er.director.root.dataPoolManager.releaseAnimationClip(this),xw.destroy(this),t.prototype.destroy.call(this)},i[Cw]=function(t,e,i){for(var r=1/e,n=this._collectAnimatedJoints(),s=n.length,a={},o=0;o<s;++o)a[n[o]]={transforms:Array.from({length:i},(function(){return new c}))};var l=n.reduce((function(t,e){return t[e]=new oO,t}),{});for(var h in l){var u=l[h],_=h.lastIndexOf("/");if(_>=0){var f=h.substring(0,_),d=l[f];d&&(u.parent=d)}}for(var p=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=l[e.node];if(i)return cO(i,e.property)}}),void 0),m=0;m<i;++m){var g=t+r*m;p.evaluate(g);for(var y=0;y<s;++y){var v=n[y];c.copy(a[v].transforms[m],l[v].globalTransform)}for(var b=0;b<s;++b){var S=n[b];l[S].invalidate()}}return{samples:e,frames:i,joints:a}},i.upgradeUntypedTracks=function(t){for(var e=[],i=[],r=this._tracks,n=r.length,s=0;s<n;++s){var a=r[s];if(a instanceof OP){var o=a.upgrade(t);o&&(e.push(o),i.push(a))}}for(var l=i.length,h=0;h<l;++h)Ma.remove(r,i[h]);r.push.apply(r,e)},i[JI]=function(){return this._searchForRootBonePath()},i.getPropertyCurves=function(){return this._getLegacyData().getPropertyCurves()},i.updateEventDatas=function(){this.events=this._events},i.hasEvents=function(){return 0!==this.events.length},i.syncLegacyData=function(){this._legacyData&&(this._fromLegacy(this._legacyData),this._legacyData=void 0)},i[$I]=function(){return this._embeddedPlayers},i[tO]=function(t){this._embeddedPlayers.push(t)},i[eO]=function(t){var e=this._embeddedPlayers.indexOf(t);e>=0&&this._embeddedPlayers.splice(e,1)},i[iO]=function(){this._embeddedPlayers.length=0},i._createEvalWithBinder=function(t,e,i){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData());var r,n=[];i&&(r=this._createRootMotionEvaluation(t,i,n));for(var s,a=[],o=this._tracks,l=o.length,h=0;h<l;++h){var u=o[h];if(!n.includes(u)&&!Array.from(u.channels()).every((function(t){return 0===t.curve.keyFramesCount}))){var c=e(u[PR]);if(c){var _=u[cB](c);a.push({binding:c,trackEval:_})}}}return this._exoticAnimation&&(s=this._exoticAnimation.createEvaluator(e)),new sO(a,s,r)},i._createRootMotionEvaluation=function(t,e,i){if(t instanceof ks){var r=this._searchForRootBonePath();if(r){var n=t.getChildByPath(r);if(n){for(var s=new aO,a=[],o=this._tracks,l=o.length,h=0;h<l;++h){var u=o[h],c=u[PR].parseTrsPath();if(c&&c.node===r){i.push(u);var _=cO(s,c.property);if(_){var f=u[cB](_);a.push({binding:_,trackEval:f})}}}return new hO(n,this._duration,s,a)}Rn(3924)}else Rn(3923)}else Nn(3920)},i._searchForRootBonePath=function(){var t=this._tracks.map((function(t){var e=t[PR].parseTrsPath();if(e){var i=e.node;return{path:i,rank:i.split("/").length}}return{path:"",rank:0}}));t.sort((function(t,e){return t.rank-e.rank}));var e=t.findIndex((function(t){return 0!==t.rank}));if(e<0)return"";for(var i=t.length,r=t[e],n=!0,s=e+1;s<i;++s){var a=t[s];if(a.rank!==r.rank)break;if(a.path!==r.path){n=!1;break}}return n?r.path:""},i._getLegacyData=function(){return this._legacyData||(this._legacyData=this._toLegacy()),this._legacyData},i._toLegacy=function(){var t=new FP(this._duration);return t.keys=[],t.curves=[],t.commonTargets=[],t},i._fromLegacy=function(t){for(var e=t.toTracks(),i=e.length,r=0;r<i;++r)this.addTrack(e[r])},i._collectAnimatedJoints=function(){for(var t=new Set,e=this._tracks,i=e.length,r=0;r<i;++r){var n=e[r][PR].parseTrsPath();n&&t.add(n.node)}if(this._exoticAnimation)for(var s=this._exoticAnimation.collectAnimatedJoints(),a=s.length,o=0;o<a;++o)t.add(s[o]);return Array.from(t)},Ur(e,[{key:"duration",get:function(){return this._duration},set:function(t){this._duration=t}},{key:"tracksCount",get:function(){return this._tracks.length}},{key:"tracks",get:function(){return this._tracks}},{key:"hash",get:function(){var t,e;if(this._hash)return this._hash;var i="Exotic:"+(null!==(t=null===(e=this._exoticAnimation)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"");return this._hash=In(i,666)}},{key:"events",get:function(){return this._events},set:function(t){var e=this;this._events=t;for(var i=[],r=[],n=this.events.sort((function(t,e){return t.frame-e.frame})),s=n.length,a=function(t){var s=n[t],a=s.frame/e._duration,o=i.findIndex((function(t){return t===a}));o<0&&(o=i.length,i.push(a),r.push({events:[]})),r[o].events.push({functionName:s.func,parameters:s.params})},o=0;o<s;++o)a(o);this._runtimeEvents={ratios:i,eventGroups:r}}},{key:ZI,get:function(){return this._exoticAnimation}},{key:ZI,set:function(t){this._exoticAnimation=t}},{key:"keys",get:function(){return this._getLegacyData().keys}},{key:"keys",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().keys=t}},{key:"curves",get:function(){return this._legacyDataDirty=!0,this._getLegacyData().curves}},{key:"curves",set:function(t){this._getLegacyData().curves=t}},{key:"commonTargets",get:function(){return this._getLegacyData().commonTargets}},{key:"commonTargets",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().commonTargets=t}},{key:"data",get:function(){return this._getLegacyData().data}},{key:"eventGroups",get:function(){return this._runtimeEvents.eventGroups}},{key:QI,get:function(){return this._embeddedPlayers.length}}]),e}(Qr),HI.WrapMode=va,II=Dn((PI=XI).prototype,"sample",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),OI=Dn(PI.prototype,"speed",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),FI=Dn(PI.prototype,"wrapMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return va.Normal}}),LI=Dn(PI.prototype,"enableTrsBlending",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),kI=Dn(PI.prototype,"_duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),VI=Dn(PI.prototype,"_hash",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),NI=Dn(PI.prototype,"_tracks",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),GI=Dn(PI.prototype,"_exoticAnimation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zI=Dn(PI.prototype,"_events",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),UI=Dn(PI.prototype,"_embeddedPlayers",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),MI=PI))||MI);Er.AnimationClip=rO;var nO=function(){function t(t,e){this._embeddedPlayers=t,this._embeddedPlayerEvaluationInfos=t.map((function(t){var i=t.playable;if(!i)return null;var r=i.instantiate(e);return r?{instantiatedPlayer:r,entered:!1,hostPauseTime:0,lastIterations:0}:null}))}var e=t.prototype;return e.destroy=function(){for(var t=this._embeddedPlayerEvaluationInfos,e=t.length,i=0;i<e;++i){var r;null===(r=t[i])||void 0===r||r.instantiatedPlayer.destroy()}this._embeddedPlayerEvaluationInfos.length=0},e.evaluate=function(t,e){for(var i=this._embeddedPlayers,r=this._embeddedPlayerEvaluationInfos,n=i.length,s=0;s<n;++s){var a=r[s];if(a){var o=a.entered,l=a.instantiatedPlayer,h=a.lastIterations,u=i[s],c=u.begin,_=u.end;if(t>=c&&t<=_?o?e!==h&&(l.stop(),l.play(),a.entered=!0):(l.play(),a.entered=!0):o&&(l.stop(),a.entered=!1),a.lastIterations=e,a.entered){var f=t-c;a.instantiatedPlayer.setTime(f)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,r=e.length,n=0;n<r;++n){var s=i[n];if(s){var a=s.instantiatedPlayer;e[n].reconciledSpeed&&a.setSpeed(t)}}},e.notifyHostPlay=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,r=e.length,n=0;n<r;++n){var s=i[n];if(s){var a=e[n],o=a.begin,l=a.end,h=s.instantiatedPlayer;if(s.entered){var u=s.hostPauseTime;if(h.randomAccess||A(u,t,1e-5)){var c=T(t,o,l);h.play(),h.setTime(c-o)}else h.stop()}}}},e.notifyHostPause=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,r=e.length,n=0;n<r;++n){var s=i[n];if(s){var a=s.instantiatedPlayer;s.entered&&(a.pause(),s.hostPauseTime=t)}}},e.notifyHostStop=function(){for(var t=this._embeddedPlayers,e=this._embeddedPlayerEvaluationInfos,i=t.length,r=0;r<i;++r){var n=e[r];if(n){var s=n.instantiatedPlayer;n.entered&&(n.entered=!1,s.stop())}}},t}(),sO=function(){function t(t,e,i){this._exoticAnimationEvaluator=void 0,this._trackEvalStatues=[],this._rootMotionEvaluation=void 0,this._trackEvalStatues=t,this._exoticAnimationEvaluator=e,this._rootMotionEvaluation=i}var e=t.prototype;return e.evaluate=function(t){for(var e=this._trackEvalStatues,i=this._exoticAnimationEvaluator,r=e.length,n=0;n<r;++n){var s=e[n],a=s.trackEval,o=s.binding,l=a.evaluate(t,o);o.setValue(l)}i&&i.evaluate(t)},e.evaluateRootMotion=function(t,e){var i=this._rootMotionEvaluation;i&&i.evaluate(t,e)},t}(),aO=function(){function t(){this.position=new n,this.scale=new n(1,1,1),this.rotation=new l,this.eulerAngles=new n}return t.prototype.getTransform=function(t){c.fromRTS(t,this.rotation,this.position,this.scale)},t}(),oO=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).parent=null,e._dirty=!0,e._transform=new c,e}return on(e,t),e.prototype.invalidate=function(){this._dirty=!0},Ur(e,[{key:"globalTransform",get:function(){var t=this._transform;return this._dirty&&(this._dirty=!1,c.fromRTS(t,this.rotation,this.position,this.scale),this.parent&&c.multiply(t,this.parent.globalTransform,t)),this._transform}}]),e}(aO),lO=new c,hO=function(){function t(t,e,i,r){this._initialTransformCache=new c,this._clipEndTransformCache=new c,this._startTransformCache=new c,this._endTransformCache=new c,this._motionTransformCache=new c,this._translationMotionCache=new n,this._rotationMotionCache=new l,this._scaleMotionCache=new n,this._rootBone=t,this._duration=e,this._boneTransform=i,this._trackEvalStatuses=r}var e=t.prototype;return e.evaluate=function(t,e){var i=this._calcMotionTransform(t,e,this._motionTransformCache),r=this._translationMotionCache,s=this._rotationMotionCache,a=this._scaleMotionCache,o=this._rootBone;c.toRTS(i,s,r,a),n.add(r,r,o.position),o.setPosition(r),l.multiply(s,s,o.rotation),o.setRotation(s),n.multiply(a,a,o.scale),o.setScale(a)},e._calcMotionTransform=function(t,e,i){var r=this._duration,n=r-t,s=this._evaluateAt(t,this._startTransformCache);if(e<n){var a=this._evaluateAt(t+e,this._endTransformCache);uO(i,s,a)}else{c.identity(i);var o=function(t,e){uO(lO,t,e),c.multiply(i,i,lO)},l=e-n,h=Math.floor(l/r),u=l-h*r,_=this._evaluateAt(0,this._initialTransformCache),f=this._evaluateAt(r,this._clipEndTransformCache),d=this._evaluateAt(u,this._endTransformCache);o(s,f),uO(lO,_,f);for(var p=0;p<h;++p)c.multiply(i,i,lO);o(_,d)}return i},e._evaluateAt=function(t,e){for(var i=this._trackEvalStatuses,r=i.length,n=0;n<r;++n){var s=i[n],a=s.trackEval,o=s.binding,l=a.evaluate(t,o);o.setValue(l)}return this._boneTransform.getTransform(e),e},t}();function uO(t,e,i){c.invert(t,e),c.multiply(t,i,t)}function cO(t,e){switch(e){default:return;case"position":return{setValue:function(e){n.copy(t.position,e)}};case"rotation":return{setValue:function(e){l.copy(t.rotation,e)}};case"scale":return{setValue:function(e){n.copy(t.scale,e)}};case"eulerAngles":return{setValue:function(e){n.copy(t.eulerAngles,e)}}}}var _O=function(){function t(t,e,i,r){this._lastFrameIndex=-1,this._lastIterations=0,this._lastDirection=0,this._ignoreIndex=-1,this._sampled=!1,this._targetNode=t,this._ratios=e,this._eventGroups=i,this._wrapMode=r}var e=t.prototype;return e.setWrapMode=function(t){this._wrapMode=t},e.ignore=function(t,e){this._ignoreIndex=-1,this._sampled=!1;var i=dO(t,this._ratios);i<0&&(i=~i-1,e<0&&(i+=1),this._ignoreIndex=i)},e.sample=function(t,e,i){var r=this._eventGroups.length,n=dO(t,this._ratios);if(n<0&&(n=~n-1,e<0&&(n+=1)),this._ignoreIndex!==n&&(this._ignoreIndex=-1),!this._sampled)return this._sampled=!0,this._doFire(n,!1),this._lastFrameIndex=n,this._lastIterations=i,void(this._lastDirection=e);var s=this._wrapMode,a=fO(i),o=fO(this._lastIterations),l=this._lastFrameIndex,h=this._lastDirection,u=-1!==o&&a!==o;if(l===n&&u&&1===r)this._doFire(0,!1);else if(l!==n||u){e=h;do{if(l!==n){if(-1===e&&0===l&&n>0?((s&ga.PingPong)===ga.PingPong?e*=-1:l=r,o++):1===e&&l===r-1&&n<r-1&&((s&ga.PingPong)===ga.PingPong?e*=-1:l=-1,o++),l===n)break;if(o>a)break}l+=e,this._doFire(l,!0)}while(l!==n&&l>-1&&l<r)}this._lastFrameIndex=n,this._lastIterations=i,this._lastDirection=e},e._doFire=function(t,e){e?mB().pushDelayEvent(this._checkAndFire,this,[t]):this._checkAndFire(t)},e._checkAndFire=function(t){if(this._targetNode&&this._targetNode.isValid){var e=this._eventGroups;if(!(t<0||t>=e.length||this._ignoreIndex===t))for(var i=e[t],r=this._targetNode.components,n=i.events.length,s=0;s<n;++s)for(var a=i.events[s],o=a.functionName,l=r.length,h=0;h<l;++h){var u=r[h],c=u[o];"function"==typeof c&&c.apply(u,a.parameters)}}},t}();function fO(t){return t-(0|t)==0&&(t-=1),0|t}function dO(t,e){return Oa(e,t)}var pO,mO,gO,yO,vO,bO=AO,SO=AO;function AO(){}pO=En("cc.animation.ClipMotion"),mO=Wn(rO),pO((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,Mn(e,"clip",yO,Pn(e)),e}on(e,t);var i=e.prototype;return i[ZD]=function(t){return this.clip?new zO(t,this.clip):null},i.clone=function(){var t=new e;return t.clip=this.clip,t},e}(ma),yO=Dn((gO=vO).prototype,"clip",[mO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gO));var TO,CO,xO,wO,EO,BO,RO,DO,MO,PO,IO,OO,FO,LO,kO,VO,NO,GO,zO=function(){function t(t,e){this.duration=e.duration/e.speed,this._state=new SB(e),this._state.initialize(t.node,t.blendBuffer,t.mask)}var e=t.prototype;return e.getClipStatuses=function(t){var e=this,i=!1;return{next:function(){return i?{done:!0,value:void 0}:(i=!0,{done:!1,value:{__DEBUG_ID__:e.__DEBUG__ID__,clip:e._state.clip,weight:t}})}}},e.sample=function(t,e){if(0!==e){var i=this._state.duration*t;this._state.time=i,this._state.weight=e,this._state.sample(),this._state.weight=0}},Ur(t,[{key:"progress",get:function(){return this._state.time/this.duration}}]),t}(),UO=En("cc.animation.BindableNumber")((EO=function(){function t(t){void 0===t&&(t=0),Mn(this,"variable",xO,this),Mn(this,"value",wO,this),this.value=t}return t.prototype.clone=function(){var e=new t;return e.value=this.value,e.variable=this.variable,e},t}(),xO=Dn((CO=EO).prototype,"variable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),wO=Dn(CO.prototype,"value",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),TO=CO))||TO,HO=En("cc.animation.BindableBoolean")((PO=function(){function t(t){void 0===t&&(t=!1),Mn(this,"variable",DO,this),Mn(this,"value",MO,this),this.value=t}return t.prototype.clone=function(){var e=new t;return e.value=this.value,e.variable=this.variable,e},t}(),DO=Dn((RO=PO).prototype,"variable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),MO=Dn(RO.prototype,"value",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),BO=RO))||BO;function XO(t,e,i,r,n){var s=e.variable,a=e.value;if(!s)return a;var o=t.getVar(s);if(!jO(o,s))return a;if(o.type!==i)throw new JD(s,"number");for(var l=arguments.length,h=new Array(l>5?l-5:0),u=5;u<l;u++)h[u-5]=arguments[u];var c=o.bind.apply(o,[r,n].concat(h));return c}function WO(t,e,i,r,n){var s=e.variable,a=e.value;if(!s)return a;var o=t.getVar(s);if(!jO(o,s))return a;if(i!==dD.FLOAT&&i!==dD.INTEGER)throw new JD(s,"number or integer");for(var l=arguments.length,h=new Array(l>5?l-5:0),u=5;u<l;u++)h[u-5]=arguments[u];var c=o.bind.apply(o,[r,n].concat(h));return c}function jO(t,e){if(t)return!0;throw new KD(e)}var YO,qO,KO,JO,ZO,QO,$O,tF,eF,iF,rF,nF=En("cc.animation.AnimationBlendItem")((LO=function(){function t(){Mn(this,"motion",FO,this)}var e=t.prototype;return e.clone=function(){var e=new t;return this._assign(e),e},e._assign=function(t){var e,i;return t.motion=null!==(e=null===(i=this.motion)||void 0===i?void 0:i.clone())&&void 0!==e?e:null,t},t}(),FO=Dn((OO=LO).prototype,"motion",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),IO=OO))||IO,sF=En("cc.animation.AnimationBlend")((GO=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,Mn(e,"name",NO,Pn(e)),e}return on(e,t),e}(ma),NO=Dn((VO=GO).prototype,"name",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),kO=VO))||kO,aF=function(){function t(t,e,i,r){this._childEvaluators=i.map((function(e){var i,r;return null!==(i=null===(r=e.motion)||void 0===r?void 0:r[ZD](t))&&void 0!==i?i:null})),this._weights=new Array(this._childEvaluators.length).fill(0),this._inputs=[].concat(r)}var e=t.prototype;return e.getChildWeight=function(t){return this._weights[t]},e.getChildMotionEval=function(t){return this._childEvaluators[t]},e.getClipStatuses=function(t){var e,i=this._childEvaluators,r=this._weights,n=i.length,s=0;return{next:function(){for(;;){if(e){var a=e.next();if(!a.done)return a}if(s>=n)return{done:!0,value:void 0};var o=i[s];e=null==o?void 0:o.getClipStatuses(t*r[s]),++s}}}},e.sample=function(t,e){for(var i=0;i<this._childEvaluators.length;++i){var r;null===(r=this._childEvaluators[i])||void 0===r||r.sample(t,e*this._weights[i])}},e.setInput=function(t,e){this._inputs[e]=t,this.doEval()},e.doEval=function(){this.eval(this._weights,this._inputs)},e.eval=function(){},Ur(t,[{key:"childCount",get:function(){return this._weights.length}},{key:"duration",get:function(){for(var t=0,e=0;e<this._childEvaluators.length;++e){var i,r;t+=(null!==(i=null===(r=this._childEvaluators[e])||void 0===r?void 0:r.duration)&&void 0!==i?i:0)*this._weights[e]}return t}}]),t}(),oF=En("cc.animation.AnimationBlend1DItem")((JO=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,Mn(e,"threshold",KO,Pn(e)),e}on(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return this._assign(t),t},i._assign=function(e){return t.prototype._assign.call(this,e),e.threshold=this.threshold,e},e}(nF),KO=Dn((qO=JO).prototype,"threshold",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),YO=qO))||YO,lF=(En("cc.animation.AnimationBlend1D")((eF=tF=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,Mn(e,"_items",QO,Pn(e)),Mn(e,"param",$O,Pn(e)),e}on(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._items=this._items.map((function(t){return t.clone()})),t.param=this.param.clone(),t},i[ZD]=function(t){var e=new lF(t,this,this._items,this._items.map((function(t){return t.threshold})),0),i=XO(t,this.param,dD.FLOAT,e.setInput,e,0);return e.setInput(i,0),e},Ur(e,[{key:"items",get:function(){return this._items},set:function(t){this._items=Array.from(t).sort((function(t,e){return t.threshold-e.threshold}))}}]),e}(sF),tF.Item=oF,QO=Dn((ZO=eF).prototype,"_items",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),$O=Dn(ZO.prototype,"param",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UO}}),ZO)),function(t){function e(e,i,r,n,s){var a;return(a=t.call(this,e,i,r,[s])||this)._thresholds=n,a.doEval(),a}return on(e,t),e.prototype.eval=function(t,e){var i=e[0];!function(t,e,i){if(t.fill(0),0===e.length);else if(i<=e[0])t[0]=1;else if(i>=e[e.length-1])t[t.length-1]=1;else{for(var r=0,n=1;n<e.length;++n)if(e[n]>i){r=n;break}var s=e[r-1],a=e[r],o=a-s;t[r-1]=(a-i)/o,t[r]=(i-s)/o}}(t,this._thresholds,i)},e}(aF)),hF=(iF=new i,rF={wA:0,wB:0},function(t,e,r){if(gn(t.length===e.length),0!==e.length)if(1!==e.length)if(i.strictEquals(r,i.ZERO)){var n=e.findIndex((function(t){return i.strictEquals(t,i.ZERO)}));n>=0?t[n]=1:t.fill(1/e.length)}else{for(var s=-1,a=-1,o=-1,l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,u=r.x,c=r.y,_=0;_<e.length;++_){var f=e[_];if(i.equals(f,i.ZERO))o=_;else{var d=i.normalize(iF,f),p=i.dot(d,r);d.x*c-d.y*u>0?p>=h&&(h=p,s=_):p>=l&&(l=p,a=_)}}var m=0;if(s<0||a<0)m=1;else{var g=(x=e[s],w=e[a],E=r,B=rF,(R=i.cross(x,w))?(B.wA=i.cross(E,w)/R,B.wB=i.cross(E,x)/-R):(B.wA=0,B.wB=0),B),y=g.wA,v=g.wB,b=0,S=0,A=y+v;A>1?(b=y/A,S=v/A):A<0?(b=0,S=0,m=1):(b=y,S=v,m=1-A),t[s]=b,t[a]=S}if(m>0)if(o>=0)t[o]=m;else for(var T=m/t.length,C=0;C<t.length;++C)t[C]+=T}else t[0]=1;var x,w,E,B,R});function uF(t,e,r,n){t.fill(0);for(var s=new i(0,0),a=new i(0,0),o=0,l=e.length,h=0;h<l;++h){for(var u=Number.MAX_VALUE,c=!1,_=0;_<l;++_)if(h!==_){n(e[h],e[_],r,s,a);var f=1-i.dot(s,a)/i.lengthSqr(a);if(f<0){c=!0;break}u=Math.min(u,f)}c||(t[h]=u,o+=u)}o>0&&t.forEach((function(e,i){return t[i]=e/o}))}var cF,_F,fF,dF,pF,mF,gF,yF,vF,bF,SF,AF,TF,CF,xF,wF,EF,BF,RF=function(t,e,r,n,s){i.subtract(n,r,t),i.subtract(s,e,t)},DF=(cF=new n(0,0,0),_F=new n(0,0,0),fF=new n(0,0,0),dF=new n(0,0,0),pF=new n(0,0,0),mF=new n(0,0,0),function(t,e,r,s,a){var o=0,l=0,h=2;n.set(fF,r.x,r.y,0),i.equals(t,i.ZERO)?(o=i.angle(r,e),l=0,h=1):i.equals(e,i.ZERO)?(l=o=i.angle(r,t),h=1):(o=i.angle(t,e))<=0?l=0:i.equals(r,i.ZERO)?l=o:(n.set(dF,t.x,t.y,0),n.set(pF,e.x,e.y,0),n.set(mF,r.x,r.y,0),n.cross(cF,dF,pF),n.projectOnPlane(fF,mF,cF),l=n.angle(dF,fF),o<.99*Math.PI&&n.dot(n.cross(_F,dF,fF),cF)<0&&(l=-l));var u=i.len(t),c=i.len(e),_=(c+u)/2;i.set(a,(c-u)/_,o*h),i.set(s,(n.len(fF)-u)/_,l*h)});!function(t){t[t.SIMPLE_DIRECTIONAL=0]="SIMPLE_DIRECTIONAL",t[t.FREEFORM_CARTESIAN=1]="FREEFORM_CARTESIAN",t[t.FREEFORM_DIRECTIONAL=2]="FREEFORM_DIRECTIONAL"}(BF||(BF={})),ss(BF);var MF,PF,IF,OF,FF,LF,kF,VF,NF,GF,zF,UF,HF,XF,WF,jF,YF,qF,KF,JF,ZF,QF,$F,tL,eL,iL,rL,nL,sL,aL,oL,lL=En("cc.animation.AnimationBlend2DItem")((bF=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,Mn(e,"threshold",vF,Pn(e)),e}on(e,t);var r=e.prototype;return r.clone=function(){var t=new e;return this._assign(t),t},r._assign=function(e){return t.prototype._assign.call(this,e),i.copy(e.threshold,this.threshold),e},e}(nF),vF=Dn((yF=bF).prototype,"threshold",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),gF=yF))||gF,hL=(En("cc.animation.AnimationBlend2D")((EF=wF=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,Mn(e,"algorithm",AF,Pn(e)),Mn(e,"_items",TF,Pn(e)),Mn(e,"paramX",CF,Pn(e)),Mn(e,"paramY",xF,Pn(e)),e}on(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._items=this._items.map((function(t){var e;return null!==(e=null==t?void 0:t.clone())&&void 0!==e?e:null})),t.paramX=this.paramX.clone(),t.paramY=this.paramY.clone(),t},i[ZD]=function(t){var e=new hL(t,this,this._items,this._items.map((function(t){return t.threshold})),this.algorithm,[0,0]),i=XO(t,this.paramX,dD.FLOAT,e.setInput,e,0),r=XO(t,this.paramY,dD.FLOAT,e.setInput,e,1);return e.setInput(i,0),e.setInput(r,1),e},Ur(e,[{key:"items",get:function(){return this._items},set:function(t){this._items=Array.from(t)}}]),e}(sF),wF.Algorithm=BF,wF.Item=lL,AF=Dn((SF=EF).prototype,"algorithm",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return BF.SIMPLE_DIRECTIONAL}}),TF=Dn(SF.prototype,"_items",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),CF=Dn(SF.prototype,"paramX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UO}}),xF=Dn(SF.prototype,"paramY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UO}}),SF)),function(t){function e(e,r,n,s,a,o){var l;return(l=t.call(this,e,r,n,o)||this)._thresholds=void 0,l._algorithm=void 0,l._value=new i,l._thresholds=s,l._algorithm=a,l.doEval(),l}return on(e,t),e.prototype.eval=function(t,e){var r=e[0],n=e[1];switch(i.set(this._value,r,n),t.fill(0),this._algorithm){case BF.SIMPLE_DIRECTIONAL:hF(t,this._thresholds,this._value);break;case BF.FREEFORM_CARTESIAN:!function(t,e,i){uF(t,e,i,RF)}(t,this._thresholds,this._value);break;case BF.FREEFORM_DIRECTIONAL:!function(t,e,i){uF(t,e,i,DF)}(t,this._thresholds,this._value)}},e}(aF)),uL=En("cc.animation.AnimationBlendDirectItem")((OF=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,Mn(e,"weight",IF,Pn(e)),e}on(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return this._assign(t),t},i._assign=function(e){return t.prototype._assign.call(this,e),e.weight=this.weight,e},e}(nF),IF=Dn((PF=OF).prototype,"weight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),MF=PF))||MF,cL=(En("cc.animation.AnimationBlendDirect")((VF=kF=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,Mn(e,"_items",LF,Pn(e)),e}on(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._items=this._items.map((function(t){var e;return null!==(e=null==t?void 0:t.clone())&&void 0!==e?e:null})),t},i[ZD]=function(t){return new cL(t,this,this._items,this._items.map((function(t){return t.weight})))},Ur(e,[{key:"items",get:function(){return this._items},set:function(t){this._items=Array.from(t)}}]),e}(sF),kF.Item=uL,LF=Dn((FF=VF).prototype,"_items",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),FF)),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).doEval(),e}return on(e,t),e.prototype.eval=function(t,e){for(var i=t.length,r=0;r<i;++r)t[r]=e[r]},e}(aF)),_L=(En("cc.animation.AnimationMask")((zF=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,Mn(e,"_jointMasks",GF,Pn(e)),e}on(e,t);var i=e.prototype;return i.addJoint=function(t,e){var i=new _L;i.path=t,i.enabled=e,this._jointMasks.push(i)},i.removeJoint=function(t){Da(this._jointMasks,(function(e){return e.path===t}))},i.clear=function(){this._jointMasks.length=0},i.filterDisabledNodes=function(t){for(var e=this._jointMasks,i=e.length,r=new Set,n=0;n<i;++n){var s=e[n],a=s.path;if(!s.enabled){var o=t.getChildByPath(a);o&&r.add(o)}}return r},Ur(e,[{key:"joints",get:function(){return this._jointMasks},set:function(t){this.clear();for(var e,i=hn(t);!(e=i()).done;){var r=e.value;this.addJoint(r.path,r.enabled)}}}]),e}(Qr),GF=Dn((NF=zF).prototype,"_jointMasks",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dn(NF.prototype,"joints",[Un],Object.getOwnPropertyDescriptor(NF.prototype,"joints"),NF.prototype),NF)),En("cc.JointMask")((XF=Dn((HF=function(){Mn(this,"path",XF,this),Mn(this,"enabled",WF,this)}).prototype,"path",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),WF=Dn(HF.prototype,"enabled",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),UF=HF))||UF);!function(t){t[t.EQUAL_TO=0]="EQUAL_TO",t[t.NOT_EQUAL_TO=1]="NOT_EQUAL_TO",t[t.LESS_THAN=2]="LESS_THAN",t[t.LESS_THAN_OR_EQUAL_TO=3]="LESS_THAN_OR_EQUAL_TO",t[t.GREATER_THAN=4]="GREATER_THAN",t[t.GREATER_THAN_OR_EQUAL_TO=5]="GREATER_THAN_OR_EQUAL_TO"}(oL||(oL={})),En("cc.animation.BinaryCondition")((ZF=JF=function(){function t(){Mn(this,"operator",YF,this),Mn(this,"lhs",qF,this),Mn(this,"rhs",KF,this)}var e=t.prototype;return e.clone=function(){var e=new t;return e.operator=this.operator,e.lhs=this.lhs.clone(),e.rhs=this.rhs.clone(),e},e[ZD]=function(t){var e=this.operator,i=this.lhs,r=this.rhs,n=new dL(e,0,0),s=WO(t,i,dD.FLOAT,n.setLhs,n),a=WO(t,r,dD.FLOAT,n.setRhs,n);return n.reset(s,a),n},t}(),JF.Operator=oL,YF=Dn((jF=ZF).prototype,"operator",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return oL.EQUAL_TO}}),qF=Dn(jF.prototype,"lhs",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UO}}),KF=Dn(jF.prototype,"rhs",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UO}}),jF));var fL,dL=function(){function t(t,e,i){this._operator=t,this._lhs=e,this._rhs=i,this._eval()}var e=t.prototype;return e.reset=function(t,e){this._lhs=t,this._rhs=e,this._eval()},e.setLhs=function(t){this._lhs=t,this._eval()},e.setRhs=function(t){this._rhs=t,this._eval()},e.eval=function(){return this._result},e._eval=function(){var t=this._lhs,e=this._rhs;switch(this._operator){default:case oL.EQUAL_TO:this._result=t===e;break;case oL.NOT_EQUAL_TO:this._result=t!==e;break;case oL.LESS_THAN:this._result=t<e;break;case oL.LESS_THAN_OR_EQUAL_TO:this._result=t<=e;break;case oL.GREATER_THAN:this._result=t>e;break;case oL.GREATER_THAN_OR_EQUAL_TO:this._result=t>=e}},t}();!function(t){t[t.TRUTHY=0]="TRUTHY",t[t.FALSY=1]="FALSY"}(fL||(fL={})),En("cc.animation.UnaryCondition")((iL=eL=function(){function t(){Mn(this,"operator",$F,this),Mn(this,"operand",tL,this)}var e=t.prototype;return e.clone=function(){var e=new t;return e.operator=this.operator,e.operand=this.operand.clone(),e},e[ZD]=function(t){var e=this.operator,i=this.operand,r=new mL(e,!1),n=XO(t,i,dD.BOOLEAN,r.setOperand,r);return r.reset(n),r},t}(),eL.Operator=fL,$F=Dn((QF=iL).prototype,"operator",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return fL.TRUTHY}}),tL=Dn(QF.prototype,"operand",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new HO}}),QF));var pL,mL=function(){function t(t,e){this._operator=t,this._operand=e,this._eval()}var e=t.prototype;return e.reset=function(t){this.setOperand(t)},e.setOperand=function(t){this._operand=t,this._eval()},e.eval=function(){return this._result},e._eval=function(){var t=this._operand;switch(this._operator){default:case fL.TRUTHY:this._result=!!t;break;case fL.FALSY:this._result=!t}},t}(),gL=En("cc.animation.TriggerCondition")((aL=function(){function t(){Mn(this,"trigger",sL,this)}var e=t.prototype;return e.clone=function(){var e=new t;return e.trigger=this.trigger,e},e[ZD]=function(t){var e=new yL(!1),i=t.getVar(this.trigger);return jO(i,this.trigger)&&(function(t,e){if(t!==dD.TRIGGER)throw new JD(e,"trigger")}(i.type,this.trigger),e.setTrigger(i.bind(e.setTrigger,e))),e},t}(),sL=Dn((nL=aL).prototype,"trigger",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),rL=nL))||rL,yL=function(){function t(t){this._triggered=!1,this._triggered=t}var e=t.prototype;return e.setTrigger=function(t){this._triggered=t},e.eval=function(){return this._triggered},t}(),vL=function(){function t(){this._nodeBlendStates=new Map}var e=t.prototype;return e.createWriter=function(t,e,i,r){var n=this.ref(t,e);return new bL(t,e,n,i,r)},e.destroyWriter=function(t){var e=t;this.deRef(e.node,e.property)},e.ref=function(t,e){var i=this._nodeBlendStates.get(t);return i||(i=this.createNodeBlendState(),this._nodeBlendStates.set(t,i)),i.refProperty(t,e)},e.deRef=function(t,e){var i=this._nodeBlendStates.get(t);i&&(i.deRefProperty(e),i.empty&&this._nodeBlendStates.delete(t))},e.apply=function(){this._nodeBlendStates.forEach((function(t,e){t.apply(e)}))},t}(),bL=function(){function t(t,e,i,r,n){this._node=t,this._property=e,this._propertyBlendState=i,this._host=r,this._constants=n}var e=t.prototype;return e.getValue=function(){return this._node[this._property]},e.setValue=function(t){var e=this._propertyBlendState,i=this._host.weight;e.blend(t,i)},Ur(t,[{key:"node",get:function(){return this._node}},{key:"property",get:function(){return this._property}}]),t}();!function(t){t[t.POSITION=1]="POSITION",t[t.ROTATION=2]="ROTATION",t[t.SCALE=4]="SCALE",t[t.EULER_ANGLES=8]="EULER_ANGLES"}(pL||(pL={}));var SL,AL=pL.POSITION|pL.ROTATION|pL.SCALE|pL.EULER_ANGLES,TL=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new n}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=PL(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,n.zero(this.result)},t}(),CL=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new l}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=IL(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,l.identity(this.result)},t}(),xL=function(){function t(){this._transformApplyFlags=0,this._properties={}}var e=t.prototype;return e.refProperty=function(t,e){var i,r,n,s=this._properties;switch(e){default:case"position":case"scale":case"eulerAngles":n=null!==(i=s[e])&&void 0!==i?i:s[e]=this._createVec3BlendState(t[e]);break;case"rotation":n=null!==(r=s[e])&&void 0!==r?r:s[e]=this._createQuatBlendState(t.rotation)}return++n.refCount,n},e.deRefProperty=function(t){var e=this._properties,i=e[t];i&&(--i.refCount,i.refCount>0||delete e[t])},e.apply=function(t){var e,i,r,n=this._transformApplyFlags,s=this._properties,a=s.position,o=s.scale,l=s.rotation,h=s.eulerAngles;n&&(a&&n&pL.POSITION&&(e=a.result),o&&n&pL.SCALE&&(i=o.result),h&&n&pL.EULER_ANGLES&&(r=h.result),l&&n&pL.ROTATION&&(r=l.result),(r||e||i)&&t.setRTS(r,e,i),this._transformApplyFlags=0)},Ur(t,[{key:"empty",get:function(){var t=this._properties;return!(t.position||t.rotation||t.eulerAngles||t.scale)}}]),t}(),wL=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.apply=function(e){var i=this._properties,r=i.position,n=i.scale,s=i.rotation,a=i.eulerAngles;r&&r.accumulatedWeight&&(this._transformApplyFlags|=pL.POSITION,r.accumulatedWeight<1&&r.blend(e.position,1-r.accumulatedWeight)),n&&n.accumulatedWeight&&(this._transformApplyFlags|=pL.SCALE,n.accumulatedWeight<1&&n.blend(e.scale,1-n.accumulatedWeight)),a&&a.accumulatedWeight&&(this._transformApplyFlags|=pL.EULER_ANGLES,a.accumulatedWeight<1&&a.blend(e.eulerAngles,1-a.accumulatedWeight)),s&&s.accumulatedWeight&&(this._transformApplyFlags|=pL.ROTATION,s.accumulatedWeight<1&&s.blend(e.rotation,1-s.accumulatedWeight)),t.prototype.apply.call(this,e),null==r||r.reset(),null==n||n.reset(),null==s||s.reset(),null==a||a.reset()},i._createVec3BlendState=function(){return new TL},i._createQuatBlendState=function(){return new CL},e}(xL),EL=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.prototype.createNodeBlendState=function(){return new wL},e}(vL),BL=function(){function t(t){this.refCount=0,this.result=new n,this._defaultValue=new n,this._clipBlendResult=new n,this._accumulatedWeight=0,n.copy(this._defaultValue,t),n.copy(this.result,t)}var e=t.prototype;return e.blend=function(t,e){this._accumulatedWeight=PL(this._clipBlendResult,this._clipBlendResult,this._accumulatedWeight,t,e)},e.commitLayerChange=function(t){var e=this.result,i=this._clipBlendResult,r=this._accumulatedWeight;r<1&&this.blend(this._defaultValue,1-r),n.lerp(e,e,i,t),n.zero(this._clipBlendResult),this._accumulatedWeight=0},e.reset=function(){n.copy(this.result,this._defaultValue)},t}(),RL=function(){function t(t){this.refCount=0,this.result=new l,this._defaultValue=new l,this._clipBlendResult=new l,this._accumulatedWeight=0,l.copy(this._defaultValue,t),l.copy(this.result,t)}var e=t.prototype;return e.blend=function(t,e){this._accumulatedWeight=IL(this._clipBlendResult,this._clipBlendResult,this._accumulatedWeight,t,e)},e.commitLayerChange=function(t){var e=this.result,i=this._clipBlendResult,r=this._accumulatedWeight;r<1&&this.blend(this._defaultValue,1-r),l.slerp(e,e,i,t),l.identity(this._clipBlendResult),this._accumulatedWeight=0},e.reset=function(){l.copy(this.result,this._defaultValue)},t}(),DL=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)._layerMask=-1>>>0,e}on(e,t);var i=e.prototype;return i.setLayerMask=function(t){this._layerMask&=~(1<<t)},i.commitLayerChanges=function(t,e){if(this._layerMask&1<<t){var i=this._properties,r=i.position,n=i.scale,s=i.rotation,a=i.eulerAngles;r&&r.commitLayerChange(e),n&&n.commitLayerChange(e),s&&s.commitLayerChange(e),a&&a.commitLayerChange(e)}},i.apply=function(e){this._transformApplyFlags=AL,t.prototype.apply.call(this,e);var i=this._properties,r=i.position,n=i.scale,s=i.rotation,a=i.eulerAngles;null==r||r.reset(),null==n||n.reset(),null==s||s.reset(),null==a||a.reset()},i._createVec3BlendState=function(t){return new BL(t)},i._createQuatBlendState=function(t){return new RL(t)},e}(xL),ML=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setMask=function(t,e){this._nodeBlendStates.forEach((function(i,r){e.has(r)&&i.setLayerMask(t)}))},i.commitLayerChanges=function(t,e){this._nodeBlendStates.forEach((function(i){i.commitLayerChanges(t,e)}))},i.createNodeBlendState=function(){return new DL},e}(vL);function PL(t,e,i,r,s){var a=i+s;if(1!==s||i){if(a){var o=s/a;n.lerp(t,t,r,o)}}else n.copy(t,r);return a}function IL(t,e,i,r,n){var s=i+n;if(1!==n||i){if(s){var a=n/s;l.slerp(t,e,r,a)}}else l.copy(t,r);return s}var OL,FL=En("cc.animation.StateMachineComponent")(SL=function(){function t(){}var e=t.prototype;return e.onMotionStateEnter=function(){},e.onMotionStateExit=function(){},e.onMotionStateUpdate=function(){},e.onStateMachineEnter=function(){},e.onStateMachineExit=function(){},t}())||SL,LL=function(){function t(t,e,i){var r=this;this._blendBuffer=new ML,this._currentTransitionCache={duration:0,time:0},this._varInstances={},this._hasAutoTrigger=!1;for(var n,s=hn(t.variables);!(n=s()).done;){var a=n.value,o=a[0],l=a[1],h=this._varInstances[o]=new YD(l.type,l.value);if(l.type===dD.TRIGGER){var u=l.resetMode;h.resetMode=u,u===pD.NEXT_FRAME_OR_AFTER_CONSUMED&&(this._hasAutoTrigger=!0)}}for(var c={controller:i,blendBuffer:this._blendBuffer,node:e,getVar:function(t){return r._varInstances[t]},triggerResetFn:function(t){r.setValue(t,!1)}},_=(this._layerEvaluations=t.layers.map((function(t){var e;return new kL(t,Fs({},c,{mask:null!==(e=t.mask)&&void 0!==e?e:void 0}))}))).length,f=0;f<_;++f){var d=t.layers[f].mask;if(d){var p=d.filterDisabledNodes(c.node);this._blendBuffer.setMask(f,p)}}}var e=t.prototype;return e.update=function(t){for(var e=this._blendBuffer,i=this._layerEvaluations,r=i.length,n=0;n<r;++n){var s=i[n];s.update(t),e.commitLayerChanges(n,s.weight*s.passthroughWeight)}if(this._hasAutoTrigger){var a=this._varInstances;for(var o in a){var l=a[o];l.type===dD.TRIGGER&&l.resetMode===pD.NEXT_FRAME_OR_AFTER_CONSUMED&&(l.value=!1)}}this._blendBuffer.apply()},e.getVariables=function(){return Object.entries(this._varInstances)},e.getCurrentStateStatus=function(t){return this._layerEvaluations[t].getCurrentStateStatus()},e.getCurrentClipStatuses=function(t){return this._layerEvaluations[t].getCurrentClipStatuses()},e.getCurrentTransition=function(t){var e=this._layerEvaluations,i=this._currentTransitionCache;return e[t].getCurrentTransition(i)?i:null},e.getNextStateStatus=function(t){return this._layerEvaluations[t].getNextStateStatus()},e.getNextClipStatuses=function(t){return Tn(this.getCurrentTransition(t)),this._layerEvaluations[t].getNextClipStatuses()},e.getValue=function(t){var e=this._varInstances[t];return e?e.value:void 0},e.setValue=function(t,e){var i=this._varInstances[t];i&&(i.value=e)},e.getLayerWeight=function(t){return this._layerEvaluations[t].weight},e.setLayerWeight=function(t,e){this._layerEvaluations[t].weight=e},t}(),kL=function(){function t(t,e){this.passthroughWeight=1,this._nodes=[],this._topLevelEntry=void 0,this._topLevelExit=void 0,this._currentNode=void 0,this._currentTransitionToNode=null,this._currentTransitionPath=[],this._transitionProgress=0,this._fromWeight=0,this._toWeight=0,this._fromUpdated=!1,this._toUpdated=!1,this._transitionSnapshot=new lk,this.name=t.name,this._controller=e.controller,this.weight=t.weight;var i=this._addStateMachine(t.stateMachine,null,Fs({},e),t.name),r=i.entry,n=i.exit;this._topLevelEntry=r,this._topLevelExit=n,this._currentNode=r,this._resetTrigger=e.triggerResetFn}var e=t.prototype;return e.update=function(t){this.exited||(this._fromWeight=1,this._toWeight=0,this._eval(t),this._sample())},e.getCurrentStateStatus=function(){var t=this._currentNode;return t.kind===NL.animation?t.getFromPortStatus():t.kind===NL.transitionSnapshot?t.first.getFromPortStatus():null},e.getCurrentClipStatuses=function(){var t=this._currentNode;return t.kind===NL.animation?t.getClipStatuses(this._fromWeight):t.kind===NL.transitionSnapshot?t.first.getClipStatuses(this._fromWeight):zL},e.getCurrentTransition=function(t){var e=this._currentTransitionPath;if(0!==e.length){if(e[e.length-1].to.kind!==NL.animation)return!1;var i=e[0],r=i.duration,n=i.normalizedDuration,s=t.duration=n?r*(this._currentNode.kind===NL.animation?this._currentNode.duration:this._currentNode.kind===NL.transitionSnapshot?this._currentNode.first.duration:0):r;return t.time=this._transitionProgress*s,!0}return!1},e.getNextStateStatus=function(){return gn(this._currentTransitionToNode&&this._currentTransitionToNode.kind!==NL.empty),this._currentTransitionToNode.getToPortStatus()},e.getNextClipStatuses=function(){var t,e=this._currentTransitionPath,i=e[e.length-1].to;return gn(i.kind===NL.animation),null!==(t=i.getClipStatuses(this._toWeight))&&void 0!==t?t:zL},e._addStateMachine=function(t,e,i,r){for(var n,s,a,o=this,l=Array.from(t.states()),h=l.map((function(e){return e instanceof iM?new jL(e,i):e===t.entryState?n=new sk(e,NL.entry,e.name):e===t.exitState?a=new sk(e,NL.exit,e.name):e===t.anyState?s=new sk(e,NL.any,e.name):e instanceof cP?new ak(e):null})),u={components:null,parent:e,entry:n,exit:a,any:s},c=0;c<l.length;++c){var _=h[c];_&&(_.stateMachine=u)}for(var f=l.map((function(t){if(t instanceof dP){var e=o._addStateMachine(t.stateMachine,u,i,r+"/"+t.name);return e.components=new WL(t),e}return null})),d=0;d<l.length;++d){var p=l[d],m=t.getOutgoings(p),g=[],y=void 0;y=p instanceof dP?f[d].exit:h[d];for(var v,b=function(){var t=v.value,e=t.to,r=l.findIndex((function(e){return e===t.to})),n=void 0;n=e instanceof dP?f[r].entry:h[r];var s={conditions:t.conditions.map((function(t){return t[ZD](i)})),to:n,triggers:void 0,duration:0,normalizedDuration:!1,destinationStart:0,relativeDestinationStart:!1,exitCondition:0,exitConditionEnabled:!1,interruption:aP.NONE};t instanceof uP?(s.duration=t.duration,s.normalizedDuration=t.relativeDuration,s.exitConditionEnabled=t.exitConditionEnabled,s.exitCondition=t.exitCondition,s.destinationStart=t.destinationStart,s.relativeDestinationStart=t.relativeDestinationStart,s.interruption=t.interruptionSource):t instanceof _P&&(s.duration=t.duration,s.destinationStart=t.destinationStart,s.relativeDestinationStart=t.relativeDestinationStart),s.conditions.forEach((function(e,i){var r,n=t.conditions[i];n instanceof gL&&n.trigger&&(null!==(r=s.triggers)&&void 0!==r?r:s.triggers=[]).push(n.trigger)})),g.push(s)},S=hn(m);!(v=S()).done;)b();y.outgoingTransitions=g}return u},e._eval=function(t){if(gn(!this.exited),SO("[Layer "+this.name+"]: UpdateStart "+t+"s"),this._continueDanglingTransition())return 0;for(var e=t,i=!0,r=0;i||e>0;){if(i=!1,100===r){Rn(14e3,100);break}if(++r,this._currentTransitionPath.length>0){var n=this._detectInterruption(e,HL);if(n){if(e-=n.requires,this._interrupt(n))break;i=!0;continue}if(e-=this._updateCurrentTransition(e),this._currentNode.kind===NL.exit)break;0===this._currentTransitionPath.length&&(i=!0)}else{var s=this._currentNode,a=this._matchCurrentNodeTransition(e);if(a){var o=a.transition,l=a.requires;if(bO("[SubStateMachine "+this.name+"]: CurrentNodeUpdate: "+s.name),e-=l,s.kind===NL.animation&&(s.updateFromPort(l),this._fromUpdated=!0),this._switchTo(o))break;i=!0}else bO("[SubStateMachine "+this.name+"]: CurrentNodeUpdate: "+s.name),s.kind===NL.animation?(s.updateFromPort(e),this._fromUpdated=!0,e=0):e=0}}return bO("[SubStateMachine "+this.name+"]: UpdateEnd"),this._fromUpdated&&this._currentNode.kind===NL.animation&&(this._fromUpdated=!1,this._currentNode.triggerFromPortUpdate(this._controller)),this._currentTransitionToNode&&this._toUpdated&&this._currentTransitionToNode.kind===NL.animation&&(this._toUpdated=!1,this._currentTransitionToNode.triggerToPortUpdate(this._controller)),e},e._sample=function(){var t=this._currentNode,e=this._currentTransitionToNode,i=this._fromWeight,r=this._toWeight;t.kind===NL.empty?(this.passthroughWeight=r,e&&e.kind===NL.animation&&e.sampleToPort(1)):e&&e.kind===NL.empty?(this.passthroughWeight=i,this._sampleSource(1)):(this.passthroughWeight=1,this._sampleSource(i),e&&e.kind===NL.animation&&e.sampleToPort(r))},e._sampleSource=function(t){var e=this._currentNode;e.kind===NL.animation?e.sampleFromPort(t):e.kind===NL.transitionSnapshot&&e.sample(t)},e._matchCurrentNodeTransition=function(t){var e=this._currentNode,i=UL.reset();return this._matchTransition(e,e,t,null,i),i.hasZeroCost()||e.kind===NL.animation&&(this._matchAnyScoped(e,t,i),i.hasZeroCost())||i.isValid()?i:null},e._matchAnyScoped=function(t,e,i){for(var r=!1,n=t.stateMachine;null!==n&&(this._matchTransition(n.any,t,e,null,i)&&(r=!0),!i.hasZeroCost());n=n.parent);return r},e._matchTransition=function(t,e,i,r,n){gn(t===e||t.kind===NL.any);for(var s=t.outgoingTransitions,a=s.length,o=!1,l=0;l<a;++l){var h=s[l];if(h!==r){var u=h.conditions,c=u.length;if(0===c){if(t.kind===NL.entry||t.kind===NL.exit){n.set(h,0),o=!0;break}if(!h.exitConditionEnabled)continue}var _=0;if(e.kind===NL.animation&&h.exitConditionEnabled){var f=e.duration*h.exitCondition;if((_=Math.max(f-e.fromPortTime,0))>i||_>=n.requires)continue}for(var d=!0,p=0;p<c;++p)if(!u[p].eval()){d=!1;break}if(d){if(0===_){n.set(h,0),o=!0;break}gn(_<=n.requires),n.set(h,_),o=!0}}}return o},e._switchTo=function(t){var e=this._currentTransitionPath;this._consumeTransition(t),e.push(t);var i=this._matchTransitionPathUntilMotion();return!i||(this._doTransitionToMotion(i),!1)},e._continueDanglingTransition=function(){var t=this._currentTransitionPath,e=t.length;if(0===e)return!1;var i=t[e-1].to;if(i.kind!==NL.animation&&i.kind!==NL.empty){var r=this._matchTransitionPathUntilMotion();return!r||(this._doTransitionToMotion(r),!1)}return!1},e._matchTransitionPathUntilMotion=function(){for(var t=this._currentTransitionPath,e=t[t.length-1].to;e.kind!==NL.animation&&e.kind!==NL.empty;){var i=UL.reset();if(this._matchTransition(e,e,0,null,i),!i.transition)break;var r=i.transition;this._consumeTransition(r),t.push(r),e=r.to}return e.kind===NL.animation||e.kind===NL.empty?e:null},e._consumeTransition=function(t){var e=t.to;e.kind===NL.entry&&this._callEnterMethods(e)},e._resetTriggersAlongThePath=function(){for(var t=this._currentTransitionPath,e=t.length,i=0;i<e;++i){var r=t[i];this._resetTriggersOnTransition(r)}},e._doTransitionToMotion=function(t){var e=this._currentTransitionPath;if(gn(0!==e.length),this._resetTriggersAlongThePath(),this._transitionProgress=0,this._currentTransitionToNode=t,this._toUpdated=!1,t.kind===NL.animation){var i=e[0],r=i.destinationStart,n=i.relativeDestinationStart?r:0===t.duration?0:r/t.duration;t.resetToPort(n)}this._callEnterMethods(t)},e._updateCurrentTransition=function(t){var e,i=this._currentTransitionPath,r=this._currentTransitionToNode;Tn(i.length>0);var n=i[0],s=n.duration,a=n.normalizedDuration,o=this._currentNode,l=r,h=0,u=0;if(s<=0)h=0,u=1;else{gn(o.kind===NL.animation||o.kind===NL.empty||o.kind===NL.transitionSnapshot);var c=this._transitionProgress,_=o.kind===NL.empty?s:a?s*(o.kind===NL.animation?o.duration:o.first.duration):s,f=c*_,d=_-f;h=Math.min(d,t),u=this._transitionProgress=(f+h)/_}var p=null!==(e=null==l?void 0:l.name)&&void 0!==e?e:"<Empty>";this._fromWeight=1-u,this._toWeight=u;var m=0!==h,g=1===u;return o.kind===NL.animation&&m&&(SO("Update "+o.name),o.updateFromPort(h),this._fromUpdated=!0),l.kind===NL.animation&&m&&(SO("Update "+l.name),l.updateToPort(h),this._toUpdated=!0),g&&(bO("[SubStateMachine "+this.name+"]: Transition finished: "+o.name+" -> "+p+"."),this._finishCurrentTransition()),h},e._finishCurrentTransition=function(){var t=this._currentTransitionPath,e=this._currentTransitionToNode;Tn(t.length>0);var i=this._currentNode,r=e;this._callExitMethods(i);for(var n=this._currentTransitionPath,s=n.length,a=0;a<s;++a){var o=n[a].to;o.kind===NL.exit&&this._callExitMethods(o)}this._fromUpdated=this._toUpdated,this._toUpdated=!1,this._dropCurrentTransition(),this._currentNode=r,i.kind===NL.transitionSnapshot&&i.clear()},e._dropCurrentTransition=function(){var t=this._currentTransitionToNode;t.kind===NL.animation&&t.finishTransition(),this._currentTransitionToNode=null,this._currentTransitionPath.length=0,this._fromWeight=1,this._toWeight=0},e._detectInterruption=function(t,e){var i=this._currentTransitionPath,r=this._currentNode,n=this._currentTransitionToNode;if(r.kind!==NL.animation&&r.kind!==NL.transitionSnapshot)return null;if(!n||n.kind!==NL.animation)return null;gn(0!==i.length);var s=i[0],a=s.interruption;if(a===aP.NONE)return null;var o=UL.reset(),l=null,h=r.kind===NL.animation?r:r.first,u=this._matchAnyScoped(h,t,o);u&&(l=h),o.hasZeroCost();var c=a===aP.CURRENT_STATE||a===aP.CURRENT_STATE_THEN_NEXT_STATE?VL(r):n;(u=this._matchTransition(c,c,t,s,o))&&(l=c),o.hasZeroCost();var _=a===aP.NEXT_STATE_THEN_CURRENT_STATE?VL(r):a===aP.CURRENT_STATE_THEN_NEXT_STATE?n:null;return _&&((u=this._matchTransition(_,_,t,s,o))&&(l=_),o.hasZeroCost()),UL.transition?e.set(l,UL.transition,UL.requires):null},e._interrupt=function(t){var e=t.from,i=t.transition,r=t.requires,n=this._currentNode;if(gn(n.kind===NL.animation||n.kind===NL.transitionSnapshot),n.kind===NL.animation){n.updateFromPort(r),this._fromUpdated=!0;var s=this._transitionSnapshot;gn(s.empty),s.enqueue(n,1)}return this._takeCurrentTransitionSnapshot(e),this._dropCurrentTransition(),this._currentNode=this._transitionSnapshot,this._switchTo(i)},e._takeCurrentTransitionSnapshot=function(t){var e=this._currentTransitionPath,i=this._currentTransitionToNode,r=this._transitionSnapshot;gn(0!==e.length),gn(i&&i.kind===NL.animation);var n=e[0],s=n.duration,a=n.normalizedDuration,o=t,l=0;if(s<=0)l=1;else{var h=this._transitionProgress,u=a?s*o.duration:s;l=h*u/u}r.enqueue(i,l)},e._resetTriggersOnTransition=function(t){var e=t.triggers;if(e)for(var i=e.length,r=0;r<i;++r){var n=e[r];this._resetTrigger(n)}},e._resetTrigger=function(t){(0,this._triggerReset)(t)},e._callEnterMethods=function(t){var e,i=this._controller;switch(t.kind){default:break;case NL.animation:t.components.callMotionStateEnterMethods(i,t.getToPortStatus());break;case NL.entry:null===(e=t.stateMachine.components)||void 0===e||e.callStateMachineEnterMethods(i)}},e._callExitMethods=function(t){var e,i=this._controller;switch(t.kind){default:break;case NL.animation:t.components.callMotionStateExitMethods(i,t.getFromPortStatus());break;case NL.exit:null===(e=t.stateMachine.components)||void 0===e||e.callStateMachineExitMethods(i)}},Ur(t,[{key:"exited",get:function(){return this._currentNode===this._topLevelExit}}]),t}();function VL(t){return t.kind===NL.animation?t:t.first}var NL,GL=Object.freeze({next:function(){return{done:!0,value:void 0}}}),zL=Object.freeze(((OL={})[Symbol.iterator]=function(){return GL},OL)),UL=new(function(){function t(){this.transition=null,this.requires=1/0}var e=t.prototype;return e.hasZeroCost=function(){return 0===this.requires},e.isValid=function(){return null!==this.transition},e.set=function(t,e){return this.transition=t,this.requires=e,this},e.reset=function(){return this.requires=1/0,this.transition=null,this},t}()),HL=new(function(){function t(){this.transition=null,this.requires=0,this.from=null}return t.prototype.set=function(t,e,i){return this.from=t,this.transition=e,this.requires=i,this},t}());!function(t){t[t.entry=0]="entry",t[t.exit=1]="exit",t[t.any=2]="any",t[t.animation=3]="animation",t[t.empty=4]="empty",t[t.transitionSnapshot=5]="transitionSnapshot"}(NL||(NL={}));var XL=function(t){this.name=void 0,this.outgoingTransitions=[],this.name=t.name},WL=function(){function t(t){this._components=t.instantiateComponents()}var e=t.prototype;return e.callMotionStateEnterMethods=function(t,e){this._callMotionStateCallbackIfNonDefault("onMotionStateEnter",t,e)},e.callMotionStateUpdateMethods=function(t,e){this._callMotionStateCallbackIfNonDefault("onMotionStateUpdate",t,e)},e.callMotionStateExitMethods=function(t,e){this._callMotionStateCallbackIfNonDefault("onMotionStateExit",t,e)},e.callStateMachineEnterMethods=function(t){this._callStateMachineCallbackIfNonDefault("onStateMachineEnter",t)},e.callStateMachineExitMethods=function(t){this._callStateMachineCallbackIfNonDefault("onStateMachineExit",t)},e._callMotionStateCallbackIfNonDefault=function(t,e,i){for(var r=this._components,n=r.length,s=0;s<n;++s){var a=r[s];a[t]!==FL.prototype[t]&&a[t](e,i)}},e._callStateMachineCallbackIfNonDefault=function(t,e){for(var i=this._components,r=i.length,n=0;n<r;++n){var s=i[n];s[t]!==FL.prototype[t]&&s[t](e)}},t}(),jL=function(t){function e(e,i){var r,n,s;if((s=t.call(this,e)||this).kind=NL.animation,s._source=null,s._baseSpeed=1,s._speed=1,s._fromPort={progress:0,statusCache:{progress:0}},s._toPort={progress:0,statusCache:{progress:0}},s._baseSpeed=e.speed,s._setSpeedMultiplier(1),e.speedMultiplierEnabled&&e.speedMultiplier){var a=e.speedMultiplier,o=i.getVar(a);if(jO(o,a)){!function(t,e,i){if(t!==e)throw new JD(i,"number")}(o.type,dD.FLOAT,a),o.bind(s._setSpeedMultiplier,Pn(s));var l=o.value;s._setSpeedMultiplier(l)}}var h=Fs({},i),u=null!==(r=null===(n=e.motion)||void 0===n?void 0:n[ZD](h))&&void 0!==r?r:null;return u&&Object.defineProperty(u,"__DEBUG_ID__",{value:s.name}),s._source=u,s.components=new WL(e),s}on(e,t);var i=e.prototype;return i.updateFromPort=function(t){this._fromPort.progress=YL(this._fromPort.progress,this.duration,t*this._speed)},i.updateToPort=function(t){this._toPort.progress=YL(this._toPort.progress,this.duration,t*this._speed)},i.triggerFromPortUpdate=function(t){this.components.callMotionStateUpdateMethods(t,this.getFromPortStatus())},i.triggerToPortUpdate=function(t){this.components.callMotionStateUpdateMethods(t,this.getToPortStatus())},i.getFromPortStatus=function(){var t=this._fromPort.statusCache;return t.progress=qL(this._fromPort.progress),t},i.getToPortStatus=function(){var t=this._toPort.statusCache;return t.progress=qL(this._toPort.progress),t},i.resetToPort=function(t){this._toPort.progress=t},i.finishTransition=function(){this._fromPort.progress=this._toPort.progress},i.sampleFromPort=function(t){var e;null===(e=this._source)||void 0===e||e.sample(this._fromPort.progress,t)},i.sampleToPort=function(t){var e;null===(e=this._source)||void 0===e||e.sample(this._toPort.progress,t)},i.getClipStatuses=function(t){var e,i=this._source;return i?((e={})[Symbol.iterator]=function(){return i.getClipStatuses(t)},e):zL},i._setSpeedMultiplier=function(t){this._speed=this._baseSpeed*t},Ur(e,[{key:"duration",get:function(){var t,e;return null!==(t=null===(e=this._source)||void 0===e?void 0:e.duration)&&void 0!==t?t:0}},{key:"fromPortTime",get:function(){return this._fromPort.progress*this.duration}}]),e}(XL);function YL(t,e,i){return 0===e?0:t+i/e}function qL(t){var e=t-Math.trunc(t);return e>=0?e:1+e}var KL,JL,ZL,QL,$L,tk,ek,ik,rk,nk,sk=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).kind=void 0,r.kind=i,r}return on(e,t),e}(XL),ak=function(t){function e(e){var i;return(i=t.call(this,e)||this).kind=NL.empty,i}return on(e,t),e}(XL),ok=function(t,e){this.motion=t,this.weight=e},lk=function(t){function e(){var e;return(e=t.call(this,{name:"[[TransitionSnapshotEval]]"})||this).kind=NL.transitionSnapshot,e._queue=[],e}on(e,t);var i=e.prototype;return i.sample=function(t){for(var e=this._queue,i=e.length,r=0;r<i;++r){var n=e[r],s=n.motion,a=n.weight;s.sampleFromPort(a*t)}},i.clear=function(){this._queue.length=0},i.enqueue=function(t,e){for(var i=this._queue,r=i.length,n=1-e,s=0;s<r;++s)i[s].weight*=n;i.push(new ok(t,e))},Ur(e,[{key:"empty",get:function(){return 0===this._queue.length}},{key:"first",get:function(){var t=this._queue;return gn(t.length>0),t[0].motion}}]),e}(XL),hk=(KL=En("cc.animation.AnimationController"),JL=ts(),ZL=aa(yP),KL(QL=JL((ek=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,Mn(e,"graph",tk,Pn(e)),e._graphEval=null,e}on(e,t);var i=e.prototype;return i.__preload=function(){this.graph&&(this._graphEval=new LL(this.graph,this.node,this))},i.update=function(t){var e;null===(e=this._graphEval)||void 0===e||e.update(t)},i.getVariables=function(){return this._graphEval.getVariables()},i.setValue=function(t,e){this._graphEval.setValue(t,e)},i.getValue=function(t){return this._graphEval.getValue(t)},i.getCurrentStateStatus=function(t){return this._graphEval.getCurrentStateStatus(t)},i.getCurrentClipStatuses=function(t){return this._graphEval.getCurrentClipStatuses(t)},i.getCurrentTransition=function(t){return this._graphEval.getCurrentTransition(t)},i.getNextStateStatus=function(t){return this._graphEval.getNextStateStatus(t)},i.getNextClipStatuses=function(t){return this._graphEval.getNextClipStatuses(t)},i.getLayerWeight=function(t){return this._graphEval.getLayerWeight(t)},i.setLayerWeight=function(t,e){return this._graphEval.setLayerWeight(t,e)},e}(ns),tk=Dn(($L=ek).prototype,"graph",[ZL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),QL=$L))||QL)||QL);t("animation",Object.freeze({__proto__:null,UniformProxyFactory:GR,MorphWeightValueProxy:zR,MorphWeightsValueProxy:UR,MorphWeightsAllValueProxy:HR,Track:FR,TrackPath:IR,RealTrack:iD,VectorTrack:gD,QuatTrack:SD,ColorTrack:CD,SizeTrack:ED,ObjectTrack:RD,isPropertyPath:FB,isCustomPath:function(t,e){return t instanceof e},HierarchyPath:BR,ComponentPath:RR,CubicSplineVec2Value:ZR,CubicSplineVec3Value:QR,CubicSplineVec4Value:$R,CubicSplineQuatValue:tD,CubicSplineNumberValue:eD,AnimationController:hk,get VariableType(){return dD},StateMachineComponent:FL}));var uk=t("AnimationManager",En((nk=rk=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)._anims=new za([]),e._crossFades=new za([]),e._delayEvents=[],e._blendStateBuffer=new EL,e._sockets=[],e}on(e,t);var i=e.prototype;return i.addCrossFade=function(t){-1===this._crossFades.array.indexOf(t)&&this._crossFades.push(t)},i.removeCrossFade=function(t){var e=this._crossFades.array.indexOf(t);e>=0?this._crossFades.fastRemoveAt(e):Nn(3907)},i.update=function(t){var e=this._delayEvents,i=this._crossFades,r=this._sockets,n=i.array;for(i.i=0;i.i<n.length;++i.i)n[i.i].update(t);var s=this._anims,a=s.array;for(s.i=0;s.i<a.length;++s.i){var o=a[s.i];o.isMotionless||o.update(t)}this._blendStateBuffer.apply();for(var l=Er.director.getTotalFrames(),h=0,u=r.length;h<u;h++){var c=r[h],_=c.target,f=c.transform;_.matrix=Hw(f,l)}for(var d=0,p=e.length;d<p;d++){var m=e[d];m.fn.apply(m.thisArg,m.args)}e.length=0},i.destruct=function(){},i.addAnimation=function(t){-1===this._anims.array.indexOf(t)&&this._anims.push(t)},i.removeAnimation=function(t){var e=this._anims.array.indexOf(t);e>=0?this._anims.fastRemoveAt(e):Nn(3907)},i.pushDelayEvent=function(t,e,i){this._delayEvents.push({fn:t,thisArg:e,args:i})},i.addSockets=function(t,e){for(var i=this,r=function(r){var n=e[r];if(i._sockets.find((function(t){return t.target===n.target})))return"continue";var s=t.getChildByPath(n.path),a=n.target&&s&&Xw(s,t);a&&i._sockets.push({target:n.target,transform:a})},n=0;n<e.length;++n)r(n)},i.removeSockets=function(t,e){for(var i=0;i<e.length;++i)for(var r=e[i],n=0;n<this._sockets.length;++n){var s=this._sockets[n];if(s.target===r.target){Ww(s.transform.node),this._sockets[n]=this._sockets[this._sockets.length-1],this._sockets.length--;break}}},Ur(e,[{key:"blendState",get:function(){return this._blendStateBuffer}}]),e}(Rr),rk.ID="animation",ik=nk))||ik);Kr.on(Or.EVENT_INIT,(function(){var t=new uk;Kr.registerSystem(uk.ID,t,Rr.Priority.HIGH)})),Er.AnimationManager=uk;var ck,_k,fk,dk,pk,mk,gk,yk,vk,bk,Sk,Ak,Tk,Ck,xk,wk,Ek,Bk,Rk,Dk,Mk=function(t){function e(e){var i;return(i=t.call(this)||this)._managedStates=[],i._fadings=[],i._scheduled=!1,i._scheduler=null!=e?e:mB(),i}on(e,t);var i=e.prototype;return i.update=function(t){if(!this.isMotionless){var e=this._managedStates,i=this._fadings;if(1===e.length&&1===i.length){var r=e[0].state;r&&(r.weight=1)}else this._calculateWeights(t);1===e.length&&1===i.length&&this._unscheduleThis()}},i.crossFade=function(t,e){var i;0===this._managedStates.length&&(e=0),0===e&&this.clear();var r=this._managedStates.find((function(e){return e.state===t}));r?(null===(i=r.state)||void 0===i?void 0:i.isMotionless)&&r.state.play():(r={state:t,reference:0},t&&t.play(),this._managedStates.push(r)),++r.reference,this._fadings.unshift({easeDuration:e,easeTime:0,target:r}),this.isMotionless||this._scheduleThis()},i.clear=function(){for(var t=0;t<this._managedStates.length;++t){var e=this._managedStates[t].state;e&&e.stop()}this._managedStates.length=0,this._fadings.length=0},i.onPlay=function(){t.prototype.onPlay.call(this),this._scheduleThis()},i.onPause=function(){t.prototype.onPause.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.pause()}this._unscheduleThis()},i.onResume=function(){t.prototype.onResume.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.resume()}this._scheduleThis()},i.onStop=function(){t.prototype.onStop.call(this),this.clear()},i._calculateWeights=function(t){for(var e=this._managedStates,i=this._fadings,r=0;r<e.length;++r){var n=e[r].state;n&&(n.weight=0)}for(var s=1,a=i.length,o=0;o<i.length;++o){var l=i[o];l.easeTime+=t;var h=0===l.easeDuration?1:C(l.easeTime/l.easeDuration),u=h*s;if(s*=1-h,l.target.state&&(l.target.state.weight+=u),l.easeTime>=l.easeDuration){a=o+1,l.easeTime=l.easeDuration;break}}if(a!==i.length){for(var c=a;c<i.length;++c){var _=i[c];--_.target.reference,_.target.reference<=0&&(_.target.state&&_.target.state.stop(),Ea(this._managedStates,_.target))}i.splice(a)}},i._scheduleThis=function(){this._scheduled||(this._scheduler.addCrossFade(this),this._scheduled=!0)},i._unscheduleThis=function(){this._scheduled&&(this._scheduler.removeCrossFade(this),this._scheduled=!1)},e}(dB),Pk=function(e){return t({Animation:e,AnimationComponent:e}),e}((ck=En("cc.Animation"),_k=Qn(),fk=$n(99),dk=ts(),pk=Wn([rO]),mk=is(),gk=Wn(rO),yk=is(),vk=is(),bk=Wn([rO]),ck(Sk=_k(Sk=fk(Sk=Jn(Sk=dk((Ek=wk=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,Mn(e,"playOnLoad",Tk,Pn(e)),e._crossFade=new Mk,e._nameToState=Gn(!0),Mn(e,"_clips",Ck,Pn(e)),Mn(e,"_defaultClip",xk,Pn(e)),e._hasBeenPlayed=!1,e}on(e,t);var i=e.prototype;return i.onLoad=function(){for(var t in this.clips=this._clips,this._nameToState)this._nameToState[t].initialize(this.node)},i.start=function(){this.playOnLoad&&!this._hasBeenPlayed&&this._defaultClip&&this.crossFade(this._defaultClip.name,0)},i.onEnable=function(){this._crossFade.resume()},i.onDisable=function(){this._crossFade.pause()},i.onDestroy=function(){for(var t in this._crossFade.stop(),this._nameToState)this._nameToState[t].destroy();this._nameToState=Gn(!0)},i.play=function(t){if(this._hasBeenPlayed=!0,!t){if(!this._defaultClip)return;t=this._defaultClip.name}this.crossFade(t,0)},i.crossFade=function(t,e){void 0===e&&(e=.3),this._hasBeenPlayed=!0;var i=this._nameToState[t];i&&this.doPlayOrCrossFade(i,e)},i.pause=function(){this._crossFade.pause()},i.resume=function(){this._crossFade.resume()},i.stop=function(){this._crossFade.stop()},i.getState=function(t){var e=this._nameToState[t];return e&&!e.curveLoaded&&e.initialize(this.node),e||null},i.createState=function(t,e){return e=e||t.name,this.removeState(e),this._doCreateState(t,e)},i.removeState=function(t){var e=this._nameToState[t];e&&(e.allowLastFrameEvent(!1),e.stop(),delete this._nameToState[t])},i.addClip=function(t,e){return Ua(this._clips,t)||this._clips.push(t),this.createState(t,e)},i.removeClip=function(t,e){var i;for(var r in this._nameToState){var n=this._nameToState[r];if(n.clip===t){i=n;break}}if(t===this._defaultClip){if(!e)return void Rn(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void Rn(3903);i.stop()}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]},i.on=function(e,i,r,n){var s=t.prototype.on.call(this,e,i,r,n);return e===uB.LASTFRAME&&this._syncAllowLastFrameEvent(),s},i.once=function(e,i,r){var n=t.prototype.once.call(this,e,i,r);return e===uB.LASTFRAME&&this._syncAllowLastFrameEvent(),n},i.off=function(e,i,r){t.prototype.off.call(this,e,i,r),e===uB.LASTFRAME&&this._syncDisallowLastFrameEvent()},i._createState=function(t,e){return new SB(t,e)},i._doCreateState=function(t,e){var i=this._createState(t,e);return i._setEventTarget(this),i.allowLastFrameEvent(this.hasEventListener(uB.LASTFRAME)),this.node&&i.initialize(this.node),this._nameToState[i.name]=i,i},i.doPlayOrCrossFade=function(t,e){this._crossFade.play(),this._crossFade.crossFade(t,e)},i._removeStateOfAutomaticClip=function(t){for(var e in this._nameToState){var i=this._nameToState[e];Ik(t,i.clip)&&(i.stop(),delete this._nameToState[e])}},i._syncAllowLastFrameEvent=function(){if(this.hasEventListener(uB.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!0)},i._syncDisallowLastFrameEvent=function(){if(!this.hasEventListener(uB.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!1)},Ur(e,[{key:"clips",get:function(){return this._clips},set:function(t){var e=this;this._crossFade&&this._crossFade.clear();for(var i,r=hn(this._clips);!(i=r()).done;){var n=i.value;n&&this._removeStateOfAutomaticClip(n)}for(var s,a=hn(t);!(s=a()).done;){var o=s.value;o&&this.createState(o)}var l=t.find((function(t){return Ik(t,e._defaultClip)}));this._defaultClip=l||null,this._clips=t}},{key:"defaultClip",get:function(){return this._defaultClip},set:function(t){this._defaultClip=t,t&&(this._clips.findIndex((function(e){return Ik(e,t)}))>=0||(this._clips.push(t),this.createState(t)))}}]),e}(Ha(ns)),wk.EventType=uB,Dn((Ak=Ek).prototype,"clips",[pk,mk],Object.getOwnPropertyDescriptor(Ak.prototype,"clips"),Ak.prototype),Dn(Ak.prototype,"defaultClip",[gk,yk],Object.getOwnPropertyDescriptor(Ak.prototype,"defaultClip"),Ak.prototype),Tk=Dn(Ak.prototype,"playOnLoad",[On,vk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Ck=Dn(Ak.prototype,"_clips",[bk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),xk=Dn(Ak.prototype,"_defaultClip",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Sk=Ak))||Sk)||Sk)||Sk)||Sk)||Sk));function Ik(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}Er.Animation=Pk,Er.AnimationComponent=Pk,pn.setClassAlias(Pk,"cc.AnimationComponent"),Er.easing=Pa,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"}(Bk||(Bk={})),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"}(Rk||(Rk={})),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"}(Dk||(Dk={}));var Ok,Fk,Lk=t("AudioPCMDataView",function(){function t(){if(this._bufferView=void 0,this._normalizeFactor=1,2===arguments.length)this._bufferView=arguments.length<=0?void 0:arguments[0],this._normalizeFactor=arguments.length<=1?void 0:arguments[1];else{var t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],i=arguments.length<=2?void 0:arguments[2];this._bufferView=new e(t),this._normalizeFactor=i}}return t.prototype.getData=function(t){return this._bufferView[t]*this._normalizeFactor},Ur(t,[{key:"length",get:function(){return this._bufferView.length}}]),t}()),kk=0;function Vk(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&&Vk(t,i)})).catch((function(){})))}function Nk(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=kk++,s=t;s._operationQueue.push({id:n,func:r,args:i,invoking:!1}),s._eventTarget.once(n.toString(),e),Vk(s,s._operationQueue[0])}))}}function Gk(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 zk,Uk,Hk,Xk=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;Gk(this._domAudio).then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t)})).catch((function(){}))},e.stop=function(){this._domAudio.pause()},Ur(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}(),Wk=(Fk=function(){function t(t){var e=this;this._domAudio=void 0,this._state=Dk.INIT,this._onEnded=void 0,this._eventTarget=new Wa,this._operationQueue=[],this._domAudio=t,Xa.on("hide",this._onHide,this),Xa.on("show",this._onShow,this),this._onEnded=function(){e.seek(0).catch((function(){})),e._state=Dk.INIT,e._eventTarget.emit(Bk.ENDED)},this._domAudio.addEventListener("ended",this._onEnded)}var e=t.prototype;return e.destroy=function(){Xa.off("hide",this._onHide,this),Xa.off("show",this._onShow,this),this._domAudio.removeEventListener("ended",this._onEnded),this._domAudio=null},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";Xa.os===ja.IOS?n="loadedmetadata":Xa.browserType===Ya.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 Xk(t,i);r(e)})).catch(n)}))},e._onHide=function(){var t=this;this._state===Dk.PLAYING&&this.pause().then((function(){t._state=Dk.INTERRUPTED,t._eventTarget.emit(Bk.INTERRUPTION_BEGIN)})).catch((function(){}))},e._onShow=function(){var t=this;this._state===Dk.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(Bk.INTERRUPTION_END)})).catch((function(){}))},e.getPCMData=function(){},e.seek=function(t){return t=T(t,0,this.duration),this._domAudio.currentTime=t,Promise.resolve()},e.play=function(){var t=this;return new Promise((function(e){Gk(t._domAudio).then((function(){t._state=Dk.PLAYING,e()})).catch((function(){}))}))},e.pause=function(){return this._domAudio.pause(),this._state=Dk.PAUSED,Promise.resolve()},e.stop=function(){var t=this;return new Promise((function(e){t._domAudio.pause(),t._domAudio.currentTime=0,t._state=Dk.STOPPED,e()}))},e.onInterruptionBegin=function(t){this._eventTarget.on(Bk.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(Bk.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(Bk.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(Bk.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(Bk.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(Bk.ENDED,t)},Ur(t,[{key:"src",get:function(){return this._domAudio?this._domAudio.src:""}},{key:"type",get:function(){return Rk.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=C(t),this._domAudio.volume=t}},{key:"duration",get:function(){return this._domAudio.duration}},{key:"currentTime",get:function(){return this._domAudio.currentTime}},{key:"sampleRate",get:function(){return 0}}]),t}(),Dn((Ok=Fk).prototype,"seek",[Nk],Object.getOwnPropertyDescriptor(Ok.prototype,"seek"),Ok.prototype),Dn(Ok.prototype,"play",[Nk],Object.getOwnPropertyDescriptor(Ok.prototype,"play"),Ok.prototype),Dn(Ok.prototype,"pause",[Nk],Object.getOwnPropertyDescriptor(Ok.prototype,"pause"),Ok.prototype),Dn(Ok.prototype,"stop",[Nk],Object.getOwnPropertyDescriptor(Ok.prototype,"stop"),Ok.prototype),Ok),jk=function(){function t(t){this._nativeAudio=void 0,this._startTime=0,this._startOffset=0,this._isPaused=!0,this._nativeAudio=t}var e=t.prototype;return e.destroy=function(){this._nativeAudio=void 0},e._now=function(){return performance.now()/1e3},e._calculateCurrentTime=function(){var t=this._now()-this._startTime,e=this._startOffset+t;return e>=this.duration&&(this._startTime=this._now(),this._startOffset=0),e%this.duration},e.start=function(){this._isPaused=!1,this._startTime=this._now()},e.pause=function(){this._isPaused||(this._isPaused=!0,this._startOffset=this._calculateCurrentTime())},e.stop=function(){this._isPaused=!0,this._startOffset=0},e.seek=function(t){this._startTime=this._now(),this._startOffset=T(t,0,this.duration)},Ur(t,[{key:"duration",get:function(){return this._nativeAudio.duration}},{key:"currentTime",get:function(){return this._isPaused?this._startOffset:this._calculateCurrentTime()}}]),t}(),Yk=new(function(){function t(){this._audioBufferDataMap={}}var e=t.prototype;return e.addCache=function(t,e){this._audioBufferDataMap[t]?console.warn("Audio buffer "+t+" has been cached"):this._audioBufferDataMap[t]={usedCount:1,audioBuffer:e}},e.retainCache=function(t){var e=this._audioBufferDataMap[t];e?e.usedCount++:console.warn("Audio buffer cache "+t+" has not been added.")},e.getCache=function(t){var e=this._audioBufferDataMap[t];return null==e?void 0:e.audioBuffer},e.tryReleasingCache=function(t){var e=this._audioBufferDataMap[t];e?--e.usedCount<=0&&delete this._audioBufferDataMap[t]:console.warn("Audio buffer cache "+t+" has not been added.")},t}()),qk=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,Kk="on-context-running",Jk=function(){function t(){var t=this;this._eventTarget=void 0,this._context=void 0,this._isRunning=!1,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),this._eventTarget=new Wa,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(Kk)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(Kk,t,e)},e.offRunning=function(t,e){this._eventTarget.off(Kk,t,e)},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){if(t.isRunning)e();else{var i=t._context;if(i.resume)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,capture:!0}),null==r||r.addEventListener("mouseup",n,{once:!0,capture:!0})}else e();else e()}}))},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){void 0===t&&(t=1);var e=this._context.createGain();return 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)},Ur(t,[{key:"isRunning",get:function(){return this._isRunning}},{key:"currentTime",get:function(){return this._context.currentTime}}]),t}();Jk.support=!!qk,Jk.support&&(Hk=new Jk);var Zk,Qk,$k,tV,eV,iV=function(){function t(t,e,i){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._currentTimer=0,this._url=void 0,this._onEndCb=void 0,this._duration=t.duration,this._url=i,this._bufferSourceNode=Hk.createBufferSource(t,!1);var r=Hk.createGain(e);this._bufferSourceNode.connect(r),Hk.connectContext(r)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),Hk.runContext().then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t),t._currentTimer=window.setTimeout((function(){var e;Yk.tryReleasingCache(t._url),null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(){}))},e.stop=function(){clearTimeout(this._currentTimer),Yk.tryReleasingCache(this._url),this._bufferSourceNode.stop(),this._bufferSourceNode.buffer=null},Ur(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}(),rV=(Uk=function(){function t(t,e){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._state=Dk.INIT,this._audioTimer=void 0,this._eventTarget=new Wa,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new jk(t),this._gainNode=Hk.createGain(),Hk.connectContext(this._gainNode),this._src=e,Xa.on("hide",this._onHide,this),Xa.on("show",this._onShow,this)}var e=t.prototype;return e.destroy=function(){this._audioTimer.destroy(),this._audioBuffer&&(this._audioBuffer=null),Yk.tryReleasingCache(this._src),Xa.off("hide",this._onHide,this),Xa.off("show",this._onShow,this)},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=Yk.getCache(t);if(r)return Yk.retainCache(t),void e(r);var n=new XMLHttpRequest,s="load audio failed: "+t+", status: ";n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=function(){200===n.status||0===n.status?Hk.decodeAudioData(n.response).then((function(i){Yk.addCache(t,i),e(i)})).catch((function(){})):i(new Error(""+s+n.status+"(no response)"))},n.onerror=function(){i(new Error(""+s+n.status+"(error)"))},n.ontimeout=function(){i(new Error(""+s+n.status+"(time out)"))},n.onabort=function(){i(new Error(""+s+n.status+"(abort)"))},n.send(null)}))},t.loadOneShotAudio=function(e,i){return new Promise((function(r,n){t.loadNative(e).then((function(t){var n=new iV(t,i,e);r(n)})).catch(n)}))},e.getPCMData=function(t){return new Lk(this._audioBuffer.getChannelData(t),1)},e._onHide=function(){var t=this;this._state===Dk.PLAYING&&this.pause().then((function(){t._state=Dk.INTERRUPTED,t._eventTarget.emit(Bk.INTERRUPTION_BEGIN)})).catch((function(){}))},e._onShow=function(){var t=this;this._state===Dk.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(Bk.INTERRUPTION_END)})).catch((function(){}))},e.seek=function(t){var e=this;return new Promise((function(i){Hk.offRunning(),e._audioTimer.seek(t),e._state===Dk.PLAYING?e._doPlay().then(i).catch((function(){})):i()}))},e.play=function(){return Hk.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){Hk.isRunning?(t._startSourceNode(),e()):(Hk.onceRunning((function(){t._startSourceNode(),e()})),Hk.runContext().catch((function(){})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=Hk.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.start(0,this._audioTimer.currentTime),this._state=Dk.PLAYING,this._audioTimer.start(),window.clearTimeout(this._currentTimer),this._currentTimer=window.setTimeout((function e(){t.loop?t._currentTimer=window.setTimeout(e,1e3*t._audioBuffer.duration):(t._audioTimer.stop(),t._eventTarget.emit(Bk.ENDED),t._state=Dk.INIT)}),1e3*(this._audioBuffer.duration-this._audioTimer.currentTime))},e._stopSourceNode=function(){try{this._sourceNode&&(this._sourceNode.stop(),this._sourceNode.buffer=null)}catch(t){}},e.pause=function(){return Hk.offRunning(),this._state===Dk.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=Dk.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return Hk.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=Dk.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.onInterruptionBegin=function(t){this._eventTarget.on(Bk.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(Bk.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(Bk.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(Bk.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(Bk.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(Bk.ENDED,t)},Ur(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return Rk.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=C(t),this._volume=t,Hk.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}(),Dn((zk=Uk).prototype,"seek",[Nk],Object.getOwnPropertyDescriptor(zk.prototype,"seek"),zk.prototype),Dn(zk.prototype,"play",[Nk],Object.getOwnPropertyDescriptor(zk.prototype,"play"),zk.prototype),Dn(zk.prototype,"pause",[Nk],Object.getOwnPropertyDescriptor(zk.prototype,"pause"),zk.prototype),Dn(zk.prototype,"stop",[Nk],Object.getOwnPropertyDescriptor(zk.prototype,"stop"),zk.prototype),zk),nV=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()},Ur(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}(),sV=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)!==Rk.DOM_AUDIO&&Jk.support?rV.load(e).then((function(e){r(new t(e))})).catch((function(){})):(Jk.support||Rn(5201),Wk.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)!==Rk.DOM_AUDIO&&Jk.support?rV.loadNative(t):(Jk.support||Rn(5201),Wk.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(r,n){(null==i?void 0:i.audioLoadMode)!==Rk.DOM_AUDIO&&Jk.support?rV.loadOneShotAudio(t,e).then((function(t){r(new nV(t))})).catch(n):(Jk.support||Rn(5201),Wk.loadOneShotAudio(t,e).then((function(t){r(new nV(t))})).catch(n))}))},e.getPCMData=function(t){return this._player.getPCMData(t)},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)},Ur(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}},{key:"sampleRate",get:function(){return this._player.sampleRate}}]),t}();sV.maxAudioChannel=24;var aV=t("AudioClip",En("cc.AudioClip")((eV=tV=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,Mn(e,"_duration",$k,Pn(e)),e._loadMode=Rk.UNKNOWN_AUDIO,e._meta=null,e._player=null,e}on(e,t);var i=e.prototype;return i.destroy=function(){var e,i=t.prototype.destroy.call(this);return null===(e=this._player)||void 0===e||e.destroy(),this._player=null,this._meta&&(this._meta.player=null),i},i.validate=function(){return!!this._meta},i.getDuration=function(){return this._duration?this._duration:this._meta?this._meta.duration:0},i.getCurrentTime=function(){return this._player?this._player.currentTime:0},i.getVolume=function(){return this._player?this._player.volume:0},i.getLoop=function(){return!!this._player&&this._player.loop},i.setCurrentTime=function(t){var e;null===(e=this._player)||void 0===e||e.seek(t).catch((function(){}))},i.setVolume=function(t){this._player&&(this._player.volume=t)},i.setLoop=function(t){this._player&&(this._player.loop=t)},i.play=function(){var t;null===(t=this._player)||void 0===t||t.play().catch((function(){}))},i.pause=function(){var t;null===(t=this._player)||void 0===t||t.pause().catch((function(){}))},i.stop=function(){var t;null===(t=this._player)||void 0===t||t.stop().catch((function(){}))},i.playOneShot=function(t){void 0===t&&(t=1),this._nativeAsset&&sV.loadOneShotAudio(this._nativeAsset.url,t).then((function(t){t.play()})).catch((function(){}))},Ur(e,[{key:"_nativeAsset",get:function(){return this._meta},set:function(t){this._meta=t,t?(this._loadMode=t.type,this._player=t.player):(this._meta=null,this._loadMode=Rk.UNKNOWN_AUDIO,this._duration=0)}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:this._native,__isNative__:!0}}},{key:"loadMode",get:function(){return this._loadMode}},{key:"state",get:function(){return this._player?this._player.state:Dk.INIT}}]),e}(Qr),tV.AudioType=Rk,$k=Dn((Qk=eV).prototype,"_duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Qk.prototype,"_nativeDep",[Hn],Object.getOwnPropertyDescriptor(Qk.prototype,"_nativeDep"),Qk.prototype),Zk=Qk))||Zk);function oV(t,e,i){sV.load(t,{audioLoadMode:e.audioLoadMode}).then((function(e){var r={player:e,url:t,duration:e.duration,type:e.type};i(null,r)})).catch((function(t){i(t)}))}function lV(t,e,i,r){var n=new aV;n._nativeUrl=t,n._nativeAsset=e,n._duration=e.duration,r(null,n)}Er.AudioClip=aV,Gr.register({".mp3":oV,".ogg":oV,".wav":oV,".m4a":oV}),$r.register({".mp3":lV,".ogg":lV,".wav":lV,".m4a":lV});var hV,uV,cV,_V,fV,dV,pV,mV,gV,yV,vV,bV,SV,AV,TV,CV,xV,wV,EV,BV=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 sV){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&&(qa(t,i),!0)},e.removePlaying=function(t){if(t instanceof sV){if(this._tryRemovePlaying(this._audioPlayerInfoList,t))return}else this._tryRemovePlaying(this._oneShotAudioInfoList,t)},e.discardOnePlayingIfNeeded=function(){var t;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length<sV.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}()),RV="audiosource-loaded";!function(t){t.STARTED="started",t.ENDED="ended"}(EV||(EV={}));var DV=function(e){return t({AudioSource:e,AudioSourceComponent:e}),e}((hV=En("cc.AudioSource"),uV=Qn(),cV=ts(),_V=Wn(aV),fV=Wn(aV),dV=is(),pV=is(),mV=is(),gV=Ls(),yV=is(),hV(vV=uV(vV=cV((wV=xV=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,Mn(e,"_clip",SV,Pn(e)),e._player=null,Mn(e,"_loop",AV,Pn(e)),Mn(e,"_playOnAwake",TV,Pn(e)),Mn(e,"_volume",CV,Pn(e)),e._cachedCurrentTime=0,e._operationsBeforeLoading=[],e._isLoaded=!1,e._lastSetClip=null,e}on(e,t);var i=e.prototype;return i._syncPlayer=function(){var t=this,e=this._clip;this._isLoaded=!1,this._lastSetClip!==e&&(e?e._nativeAsset?(this._lastSetClip=e,this._operationsBeforeLoading.length=0,sV.load(e._nativeAsset.url,{audioLoadMode:e.loadMode}).then((function(i){var r;t._lastSetClip===e?(t._isLoaded=!0,t._player&&(BV.removePlaying(t._player),t._player.offEnded(),t._player.offInterruptionBegin(),t._player.offInterruptionEnd(),t._player.destroy()),t._player=i,i.onEnded((function(){var e;BV.removePlaying(i),null===(e=t.node)||void 0===e||e.emit(EV.ENDED,t)})),i.onInterruptionBegin((function(){BV.removePlaying(i)})),i.onInterruptionEnd((function(){BV.addPlaying(i)})),t._syncStates(),null===(r=t.node)||void 0===r||r.emit(RV)):i.destroy()})).catch((function(){}))):console.error("Invalid audio clip"):this._lastSetClip=null)},i.onLoad=function(){this._syncPlayer()},i.onEnable=function(){this._playOnAwake&&!this.playing&&this.play()},i.onDisable=function(){var t=this._getRootNode();(null==t?void 0:t._persistNode)||this.pause()},i.onDestroy=function(){var t;this.stop(),null===(t=this._player)||void 0===t||t.destroy(),this._player=null},i.getPCMData=function(t){var e=this;return new Promise((function(i){if(0!==t&&1!==t)return console.warn("Only support channel index 0 or 1 to get buffer"),void i(void 0);var r;e._player?i(e._player.getPCMData(t)):null===(r=e.node)||void 0===r||r.once(RV,(function(){var r;i(null===(r=e._player)||void 0===r?void 0:r.getPCMData(t))}))}))},i.getSampleRate=function(){var t=this;return new Promise((function(e){var i;t._player?e(t._player.sampleRate):null===(i=t.node)||void 0===i||i.once(RV,(function(){e(t._player.sampleRate)}))}))},i._getRootNode=function(){for(var t,e,i=this.node,r=null===(t=i)||void 0===t||null===(e=t.parent)||void 0===e?void 0:e.parent;r;){var n,s,a;r=null===(s=i=null===(n=i)||void 0===n?void 0:n.parent)||void 0===s||null===(a=s.parent)||void 0===a?void 0:a.parent}return i},i.play=function(){var t,e,i=this;this._isLoaded||!this.clip?(BV.discardOnePlayingIfNeeded(),this.state===Dk.PLAYING&&(null===(e=this._player)||void 0===e||e.stop().catch((function(){}))),null===(t=this._player)||void 0===t||t.play().then((function(){var t;BV.addPlaying(i._player),null===(t=i.node)||void 0===t||t.emit(EV.STARTED,i)})).catch((function(){}))):this._operationsBeforeLoading.push("play")},i.pause=function(){var t,e=this;this._isLoaded||!this.clip?null===(t=this._player)||void 0===t||t.pause().then((function(){BV.removePlaying(e._player)})).catch((function(){})):this._operationsBeforeLoading.push("pause")},i.stop=function(){var t,e=this;this._isLoaded||!this.clip?null===(t=this._player)||void 0===t||t.stop().then((function(){BV.removePlaying(e._player)})).catch((function(){})):this._operationsBeforeLoading.push("stop")},i.playOneShot=function(t,e){void 0===e&&(e=1),t._nativeAsset?sV.loadOneShotAudio(t._nativeAsset.url,this._volume*e,{audioLoadMode:t.loadMode}).then((function(t){BV.discardOnePlayingIfNeeded(),t.onPlay=function(){BV.addPlaying(t)},t.onEnd=function(){BV.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(){}))},Ur(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=T(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=T(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.duration:0}},{key:"state",get:function(){return this._player?this._player.state:Dk.INIT}},{key:"playing",get:function(){return this.state===e.AudioState.PLAYING}}],[{key:"maxAudioChannel",get:function(){return sV.maxAudioChannel}}]),e}(ns),xV.AudioState=Dk,xV.EventType=EV,SV=Dn((bV=wV).prototype,"_clip",[_V],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),AV=Dn(bV.prototype,"_loop",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),TV=Dn(bV.prototype,"_playOnAwake",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),CV=Dn(bV.prototype,"_volume",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(bV.prototype,"clip",[fV,dV],Object.getOwnPropertyDescriptor(bV.prototype,"clip"),bV.prototype),Dn(bV.prototype,"loop",[pV],Object.getOwnPropertyDescriptor(bV.prototype,"loop"),bV.prototype),Dn(bV.prototype,"playOnAwake",[mV],Object.getOwnPropertyDescriptor(bV.prototype,"playOnAwake"),bV.prototype),Dn(bV.prototype,"volume",[gV,yV],Object.getOwnPropertyDescriptor(bV.prototype,"volume"),bV.prototype),vV=bV))||vV)||vV)||vV));wr(aV,"AudioClip",[{name:"PlayingState",newName:"AudioState",target:DV,targetName:"AudioSource"}]),Pr(aV.prototype,"AudioClip.prototype",["state","play","pause","stop","playOneShot","setCurrentTime","setVolume","setLoop","getCurrentTime","getVolume","getLoop"].map((function(t){return{name:t,suggest:"please use AudioSource.prototype."+t+" instead"}}))),Er.AudioSourceComponent=DV,pn.setClassAlias(DV,"cc.AudioSourceComponent"),Er.log=Ka,Er.warn=bn,Er.error=Ja,Er.assert=Za,Er._throw=Qa,Er.logID=Qs,Er.warnID=Rn,Er.errorID=Nn,Er.assertID=qn,Er.debug=$a,Er.path={join:to,extname:Lr,mainFileName:eo,basename:an,dirname:sn,changeExtname:Wr,changeBasename:io,_normalize:ro,stripSep:no,get sep(){return so()}};var MV,PV,IV=t("NodePool",function(){function t(t){this.poolHandlerComp=void 0,this._pool=void 0,this.poolHandlerComp=t,this._pool=[]}var e=t.prototype;return e.size=function(){return this._pool.length},e.clear=function(){for(var t=this._pool.length,e=0;e<t;++e)this._pool[e].destroy();this._pool.length=0},e.put=function(t){if(t&&-1===this._pool.indexOf(t)){t.removeFromParent();var e=this.poolHandlerComp?t.getComponent(this.poolHandlerComp):null;e&&e.unuse&&e.unuse(),this._pool.push(t)}},e.get=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var r=this._pool.length-1;if(r<0)return null;var n=this._pool[r];this._pool.length=r;var s=this.poolHandlerComp?n.getComponent(this.poolHandlerComp):null;return s&&s.reuse&&s.reuse(arguments),n},t}());Er.NodePool=IV;var OV=null!==(MV=globalThis.jsb)&&void 0!==MV?MV:{};t("native",{DownloaderHints:OV.DownloaderHints,Downloader:OV.Downloader,zipUtils:OV.zipUtils,fileUtils:OV.fileUtils,DebugRenderer:OV.DebugRenderer,copyTextToClipboard:null===(PV=OV.copyTextToClipboard)||void 0===PV?void 0:PV.bind(OV),garbageCollect:OV.garbageCollect,reflection:OV.reflection,bridge:OV.bridge,jsbBridgeWrapper:OV.jsbBridgeWrapper,AssetsManager:OV.AssetsManager,EventAssetsManager:OV.EventAssetsManager,Manifest:OV.Manifest}),Er.renderer=Kf;var FV=Object.setPrototypeOf,LV={};LV||(LV={}),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}(LV||(LV={})),console.warn||(console.warn=function(){}),console.assert||(console.assert=function(){}),Date.now||(Date.now=function(){return(new Date).getTime()}),FV=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}(LV||(LV={})),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,d=i*u+n*h+a,p=r*u+s*h+o,m=i*u+n*c+a,g=r*u+s*c+o,y=i*l+n*c+a,v=r*l+s*c+o,b=0;_>d&&(b=_,_=d,d=b),m>y&&(b=m,m=y,y=b),t.x=Math.floor(_<m?_:m),t.width=Math.ceil((d>y?d:y)-t.x),f>p&&(b=f,f=p,p=b),g>v&&(b=g,g=v,v=b),t.y=Math.floor(f<g?f:g),t.height=Math.ceil((p>v?p:v)-t.y)},t}();t.Matrix=e}(LV||(LV={})),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}(LV||(LV={})),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}(LV||(LV={})),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}(LV||(LV={})),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}(LV||(LV={})),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 FV(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 FV(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}(LV||(LV={})),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 FV(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}(LV||(LV={})),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 FV(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 FV(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 FV(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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return FV(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 FV(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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.displays={},e}return FV(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}(LV||(LV={})),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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return FV(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 FV(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 d=0,p=e._computeOutCode(t,i,s,a,o,l),m=e._computeOutCode(r,n,s,a,o,l);;){if(0==(p|m)){d=2;break}if(0!=(p&m))break;var g=0,y=0,v=0,b=0!==p?p:m;0!=(4&b)?(g=t+(r-t)*(a-i)/(n-i),y=a,null!==c&&(v=.5*-Math.PI)):0!=(8&b)?(g=t+(r-t)*(l-i)/(n-i),y=l,null!==c&&(v=.5*Math.PI)):0!=(2&b)?(y=i+(n-i)*(o-t)/(r-t),g=o,null!==c&&(v=0)):0!=(1&b)&&(y=i+(n-i)*(s-t)/(r-t),g=s,null!==c&&(v=Math.PI)),b===p?(t=g,i=y,p=e._computeOutCode(t,i,s,a,o,l),null!==c&&(c.x=v)):(r=g,n=y,m=e._computeOutCode(r,n,s,a,o,l),null!==c&&(c.y=v))}return d&&(_?(d=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?(d=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)):(d=3,null!==h&&(h.x=t,h.y=i),null!==u&&(u.x=r,u.y=n))),d},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 FV(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,d=(r*=c)-(e*=c),p=Math.sqrt(f*f+d*d),m=f/p,g=d/p,y=(n-t)*m+(s-e)*g,v=a*a,b=v-(t*t+e*e)+y*y,S=0;if(b>=0){var A=Math.sqrt(b),T=y-A,C=y+A,x=T<0?-1:T<=p?0:1,w=C<0?-1:C<=p?0:1,E=x*w;if(E<0)return-1;0===E&&(-1===x?(S=2,i=t+C*m,r=(e+C*g)/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+=T*m,e=(e+T*g)/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+T*m,l.y=(e+T*g)/c,null!==u&&(u.x=Math.atan2(l.y/v*_,l.x/v))),null!==h&&(h.x=t+C*m,h.y=(e+C*g)/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 FV(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],d=n[l-1],p=0,m=0,g=0,y=0,v=0,b=0,S=0;S<l;S+=2){var A=n[S],T=n[S+1];f===A&&(f=A+1e-4),d===T&&(d=T+1e-4);var C=f-A,x=d-T,w=f*T-d*A,E=h*x-u*C,B=(c*C-h*w)/E;if((B>=f&&B<=A||B>=A&&B<=f)&&(0===h||B>=t&&B<=i||B>=i&&B<=t)){var R=(c*x-u*w)/E;if((R>=d&&R<=T||R>=T&&R<=d)&&(0===u||R>=e&&R<=r||R>=r&&R<=e)){if(null===a){g=B,y=R,v=B,b=R,_++,null!==o&&(o.x=Math.atan2(T-d,A-f)-.5*Math.PI,o.y=o.x);break}var D=B-t;D<0&&(D=-D),0===_?(p=D,m=D,g=B,y=R,v=B,b=R,null!==o&&(o.x=Math.atan2(T-d,A-f)-.5*Math.PI,o.y=o.x)):(D<p&&(p=D,g=B,y=R,null!==o&&(o.x=Math.atan2(T-d,A-f)-.5*Math.PI)),D>m&&(m=D,v=B,b=R,null!==o&&(o.y=Math.atan2(T-d,A-f)-.5*Math.PI))),_++}}f=A,d=T}return 1===_?(null!==s&&(s.x=g,s.y=y),null!==a&&(a.x=g,a.y=y),null!==o&&(o.y=o.x+Math.PI)):_>1&&(_++,null!==s&&(s.x=g,s.y=y),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}(LV||(LV={})),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 FV(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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.boneMask=[],e}return FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.textures={},e}return FV(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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e.bones=[],e}return FV(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}(LV||(LV={})),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 FV(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,d=0,p=0,m=null,g=null,y=0,v=this._slots;y<v.length;y++){var b=v[y];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&&(d=a.x))),null!==s&&((S=s.x-t)<0&&(S=-S),(null===g||S>h)&&(h=S,_=s.x,f=s.y,g=b,null!==a&&(p=a.y)))}}return null!==m&&null!==n&&(n.x=u,n.y=c,null!==a&&(a.x=d)),null!==g&&null!==s&&(s.x=_,s.y=f,null!==a&&(a.y=p)),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}(LV||(LV={})),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 FV(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}(LV||(LV={})),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 FV(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 d=r.x,p=r.y;r.x=f.a*d+f.c*p+f.tx,r.y=f.b*d+f.d*p+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}(LV||(LV={})),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 FV(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,d=o-s,p=l-n,m=h-s;u.rotation=Math.atan2(d,f),u.skew=Math.atan2(m,p)-.5*Math.PI-u.rotation,_&&(u.rotation+=Math.PI),u.scaleX=Math.sqrt(f*f+d*d)/i,u.scaleY=Math.sqrt(p*p+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),d=n+.5*(a-n),p=s+.5*(o-s),m=l+.5*(a-l),g=h+.5*(o-h);this._globalDirty=!1,this._getAffineTransform(0,0,200,200,_,f,d,p,m,g,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),d=0,p=_*u-s,m=f*c-s,g=this._matrixCahce,y=e._helpMatrix;if(t<-s){if(i<-s||i>=s)return this.globalTransformMatrix;if(d=7*(2*(o*(l+1)+2*o+l+f)+((n=i>this._kX*(t+s)+m)?1:0)),this._matrixCahce[d]>0)y.copyFromArray(g,d+1);else{var v=f*(h+2),b=this._hullCache[4],S=this._hullCache[5],A=this._hullCache[2]-(l-f)*b,T=this._hullCache[3]-(l-f)*S,C=this._vertices;n?this._getAffineTransform(-s,m+c,800,c,C[v+h+2],C[v+h+3],A+b,T+S,C[v],C[v+1],e._helpTransform,y,!0):this._getAffineTransform(-r,m,800,c,A,T,C[v],C[v+1],A+b,T+S,e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty}}else if(t>=s){if(i<-s||i>=s)return this.globalTransformMatrix;d=7*(2*(o*(l+1)+o+f)+((n=i>this._kX*(t-r)+m)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=(f+1)*(h+2)-2,b=this._hullCache[4],S=this._hullCache[5],A=this._hullCache[0]+f*b,T=this._hullCache[1]+f*S,C=this._vertices,n?this._getAffineTransform(r,m+c,800,c,A+b,T+S,C[v+h+2],C[v+h+3],A,T,e._helpTransform,y,!0):this._getAffineTransform(s,m,800,c,C[v],C[v+1],A,T,C[v+h+2],C[v+h+3],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else if(i<-s){if(t<-s||t>=s)return this.globalTransformMatrix;d=7*(o*(l+1)+2*_+((n=i>this._kY*(t-p-u)-r)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=2*_,b=this._hullCache[10],S=this._hullCache[11],A=this._hullCache[8]+_*b,T=this._hullCache[9]+_*S,C=this._vertices,n?this._getAffineTransform(p+u,-s,u,800,C[v+2],C[v+3],C[v],C[v+1],A+b,T+S,e._helpTransform,y,!0):this._getAffineTransform(p,-r,u,800,A,T,A+b,T+S,C[v],C[v+1],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else if(i>=s){if(t<-s||t>=s)return this.globalTransformMatrix;d=7*(2*(o*(l+1)+o+l+f)+((n=i>this._kY*(t-p-u)+s)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=l*(h+2)+2*_,b=this._hullCache[10],S=this._hullCache[11],A=this._hullCache[6]-(o-_)*b,T=this._hullCache[7]-(o-_)*S,C=this._vertices,n?this._getAffineTransform(p+u,r,u,800,A+b,T+S,A,T,C[v+2],C[v+3],e._helpTransform,y,!0):this._getAffineTransform(p,s,u,800,C[v],C[v+1],C[v+2],C[v+3],A,T,e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else d=7*(2*(o*f+_)+((n=i>this._k*(t-p-u)+m)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=2*_+f*(h+2),C=this._vertices,n?this._getAffineTransform(p+u,m+c,u,c,C[v+h+4],C[v+h+5],C[v+h+2],C[v+h+3],C[v+2],C[v+3],e._helpTransform,y,!0):this._getAffineTransform(p,m,u,c,C[v],C[v+1],C[v+2],C[v+3],C[v+h+2],C[v+h+3],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty);return y},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}(LV||(LV={})),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 FV(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}(LV||(LV={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return FV(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 FV(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+_*_,d=Math.sqrt(f),p=s.rotation,m=n.rotation,g=Math.atan2(_,c),y=(c=r.x-n.x)*c+(_=r.y-n.y)*_,v=Math.sqrt(y),b=0;if(u+d<=v||v+u<=d||v+d<=u)b=Math.atan2(r.y-n.y,r.x-n.x),u+d<=v||d<u&&(b+=Math.PI);else{var S=(f-h+y)/(2*y),A=Math.sqrt(f-S*S*y)/v,T=n.x+c*S,C=n.y+_*S,x=-_*A,w=c*A,E=!1,B=i.parent;if(null!==B){var R=B.globalTransformMatrix;E=R.a*R.d-R.b*R.c<0}E!==this._bendPositive?(s.x=T-x,s.y=C-w):(s.x=T+x,s.y=C+w),b=Math.atan2(s.y-n.y,s.x-n.x)}var D=t.Transform.normalizeRadian(b-g);n.rotation=m+D*this._weight,n.toMatrix(i.globalTransformMatrix);var M=g+D*this._weight;s.x=n.x+Math.cos(M)*d,s.y=n.y+Math.sin(M)*d;var P=Math.atan2(r.y-s.y,r.x-s.x);s.scaleX<0&&(P+=Math.PI),s.rotation=n.rotation+p-m+t.Transform.normalizeRadian(P-D-p)*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 FV(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],d=_+2+c,p=(C=0,0);C<o;C++){for(var m=0,g=0,y=0,v=n[d++];y<v;y++){var b=u[n[d++]];if(null!==b){b.updateByConstraint(),T=b.globalTransformMatrix;var S=s[f++];w=s[f++]*r,E=s[f++]*r,m+=(T.a*w+T.c*E+T.tx)*S,g+=(T.b*w+T.d*E+T.ty)*S}}this._pathGlobalVertices[p++]=m,this._pathGlobalVertices[p++]=g}else{var A=this._pathSlot.parent;A.updateByConstraint();for(var T=A.globalTransformMatrix,C=0,x=l;C<o;C+=2){var w=s[x++]*r,E=s[x++]*r,B=T.a*w+T.c*E+T.tx,R=T.b*w+T.d*E+T.ty;this._pathGlobalVertices[C]=B,this._pathGlobalVertices[C+1]=R}}},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 d=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 p=new Array(c);d=0;for(var m,g,y,v,b,S,A,T,C=h[0],x=h[1],w=0,E=0,B=0,R=0,D=0,M=0,P=(U=0,2);U<c;U++,P+=6)w=h[P],E=h[P+1],B=h[P+2],R=h[P+3],b=2*(m=.1875*(C-2*w+B))+(y=.09375*(3*(w-B)-C+(D=h[P+4]))),S=2*(g=.1875*(x-2*E+R))+(v=.09375*(3*(E-R)-x+(M=h[P+5]))),A=.75*(w-C)+m+.16666667*y,T=.75*(E-x)+g+.16666667*v,d+=Math.sqrt(A*A+T*T),A+=b,T+=S,b+=y,S+=v,d+=Math.sqrt(A*A+T*T),A+=b,T+=S,d+=Math.sqrt(A*A+T*T),A+=b+y,T+=S+v,d+=Math.sqrt(A*A+T*T),p[U]=d,C=D,x=M;if(r&&(f*=d),n)for(U=0;U<e;U++)o[U]*=d;for(var I=this._segments,O=0,F=(U=0,H=0,X=0,0);U<e;U++,H+=3){var L=f+=o[U];if(l)(L%=d)<0&&(L+=d),X=0;else{if(L<0)continue;if(L>d)continue}for(;;X++){var k=p[X];if(!(L>k)){0===X?L/=k:L=(L-(G=p[X-1]))/(k-G);break}}if(X!==_){_=X;var V=6*X;for(C=h[V],x=h[V+1],w=h[V+2],E=h[V+3],B=h[V+4],R=h[V+5],b=2*(m=.03*(C-2*w+B))+(y=.006*(3*(w-B)-C+(D=h[V+6]))),S=2*(g=.03*(x-2*E+R))+(v=.006*(3*(E-R)-x+(M=h[V+7]))),A=.3*(w-C)+m+.16666667*y,T=.3*(E-x)+g+.16666667*v,O=Math.sqrt(A*A+T*T),I[0]=O,V=1;V<8;V++)A+=b,T+=S,b+=y,S+=v,O+=Math.sqrt(A*A+T*T),I[V]=O;A+=b,T+=S,O+=Math.sqrt(A*A+T*T),I[8]=O,A+=b+y,T+=S+v,O+=Math.sqrt(A*A+T*T),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,C,x,w,E,B,R,D,M,a,H,i)}}else{var z=t.curveLengths;if(d=z[c-=l?1:2],r&&(f*=d),n)for(var U=0;U<e;U++)o[U]*=d;h.length=8;U=0;for(var H=0,X=0;U<e;U++,H+=3){if(f+=o[U],l)(f%=d)<0&&(f+=d),X=0;else{if(f<0)continue;if(f>d)continue}for(var W=0;;X++){var j=z[X];if(!(f>j)){if(0===X)W=f/j;else{var Y=z[X-1];W=(f-Y)/(j-Y)}break}}X!==_&&(_=X,l&&X===c?(this._computeVertices(u-4,4,0,h),this._computeVertices(0,4,4,h)):this._computeVertices(6*X+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=_*_,d=t*t,p=f*_,m=f*t*3,g=_*d*3,y=t*d,v=p*e+m*r+g*s+y*o,b=p*i+m*n+g*a+y*l;h[u]=v,h[u+1]=b,h[u+2]=c?Math.atan2(b-(p*i+m*n+g*a),v-(p*e+m*r+g*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,d=_?f:f+1,p=this.spacing,m=this._spaces;if(m.length=d,c||u){m[0]=0;for(var g=0,y=d-1;g<y;g++){(M=h[g]).updateByConstraint();var v=M._boneData.length,b=v*(P=M.globalTransformMatrix).a,S=v*P.b,A=Math.sqrt(b*b+S*S);c&&(this._boneLengths[g]=A),m[g+1]=(v+p)*A/v}}else for(g=0;g<d;g++)m[g]=p;this._computeBezierCurve(r,d,_,1===a,2===o);var T,C=this._positions,x=this.rotateOffset,w=C[0],E=C[1];0===x?T=1===l:(T=!1,null!==(M=e.parent)&&(x*=(P=M.globalTransformMatrix).a*P.d-P.b*P.c>0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD));for(var B=this.rotateMix,R=this.translateMix,D=(g=0,3);g<f;g++,D+=3){var M,P;(M=h[g]).updateByConstraint(),(P=M.globalTransformMatrix).tx+=(w-P.tx)*R,P.ty+=(E-P.ty)*R;var I=(b=C[D])-w,O=(S=C[D+1])-E;if(c){var F=this._boneLengths[g],L=(Math.sqrt(I*I+O*O)/F-1)*B+1;P.a*=L,P.b*=L}if(w=b,E=S,B>0){var k=P.a,V=P.b,N=P.c,G=P.d,z=void 0,U=void 0,H=void 0;if(z=_?C[D-1]:Math.atan2(O,I),z-=Math.atan2(V,k),T){U=Math.cos(z),H=Math.sin(z);var X=M._boneData.length;w+=(X*(U*k-H*V)-I)*B,E+=(X*(H*k+U*V)-O)*B}else z+=x;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),P.a=U*k-H*V,P.b=H*k+U*V,P.c=U*N-H*G,P.d=H*N+U*G}M.global.fromMatrix(P)}this.dirty=!1}}},i.prototype.invalidUpdate=function(){},i}(e);t.PathConstraint=r}(LV||(LV={})),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}(LV||(LV={})),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 FV(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((d=this._animationStates[0])._fadeState>0&&d._subFadeState>0)this._armature._dragonBones.bufferObject(d),this._animationStates.length=0,this._lastAnimationState=null;else{var i=d._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}}d.advanceTime(t,r)}else if(e>1){for(var _=0,f=0;_<e;++_){var d;(d=this._animationStates[_])._fadeState>0&&d._subFadeState>0?(f++,this._armature._dragonBones.bufferObject(d),this._animationDirty=!0,this._lastAnimationState===d&&(this._lastAnimationState=null)):(f>0&&(this._animationStates[_-f]=d),d.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 d=!1;for(var p in r.animationTimelines){this._lockUpdate||(d=!0,this._lockUpdate=!0);var m=this.fadeIn(p,e.fadeInTime,1,o.layer,null,0);null!==m&&(m.resetToPose=!1,m._parent=o,m.stop())}return d&&(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}(LV||(LV={})),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 FV(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=(y=n[r]).bone.name)in e||(e[l]=[]),e[l].push(y);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((M=_[c]).type){case 10:(y=t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone=o,y.bonePose=u,y.init(this._armature,this,M),this._boneTimelines.push(y);break;case 11:(y=t.BaseObject.borrowObject(t.BoneTranslateTimelineState)).bone=o,y.bonePose=u,y.init(this._armature,this,M),this._boneTimelines.push(y);break;case 12:(y=t.BaseObject.borrowObject(t.BoneRotateTimelineState)).bone=o,y.bonePose=u,y.init(this._armature,this,M),this._boneTimelines.push(y);break;case 13:(y=t.BaseObject.borrowObject(t.BoneScaleTimelineState)).bone=o,y.bonePose=u,y.init(this._armature,this,M),this._boneTimelines.push(y)}else this.resetToPose&&((y=t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone=o,y.bonePose=u,y.init(this._armature,this,null),this._boneTimelines.push(y),this._poseTimelines.push(y))}else if(1===o._boneData.type)if(null!==(h=this._animationData.getSurfaceTimelines(l)))for(var f=0,d=h;f<d.length;f++)switch((M=d[f]).type){case 50:(y=t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface=o,y.init(this._armature,this,M),this._surfaceTimelines.push(y)}else this.resetToPose&&((y=t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface=o,y.init(this._armature,this,null),this._surfaceTimelines.push(y),this._poseTimelines.push(y))}for(var p in e)for(var m=0,g=e[p];m<g.length;m++){var y=g[m];this._boneTimelines.splice(this._boneTimelines.indexOf(y),1),y.returnToPool()}for(var v={},b=[],S=0,A=this._slotTimelines;S<A.length;S++)(l=(y=A[S]).slot.name)in v||(v[l]=[]),v[l].push(y);for(var T=0,C=this._armature.getSlots();T<C.length;T++){var x=C[T],w=x.parent.name;if(this.containsBoneMask(w))if(l=x.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 R=0,D=h;R<D.length;R++){var M;switch((M=D[R]).type){case 20:(y=t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot=x,y.init(this._armature,this,M),this._slotTimelines.push(y),E=!0;break;case 21:(y=t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot=x,y.init(this._armature,this,M),this._slotTimelines.push(y),B=!0;break;case 22:(y=t.BaseObject.borrowObject(t.DeformTimelineState)).slot=x,y.init(this._armature,this,M),this._slotTimelines.push(y),b.push(y.vertexOffset)}}if(this.resetToPose&&(E||((y=t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot=x,y.init(this._armature,this,null),this._slotTimelines.push(y),this._poseTimelines.push(y)),B||((y=t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot=x,y.init(this._armature,this,null),this._slotTimelines.push(y),this._poseTimelines.push(y)),null!==x.rawDisplayDatas))for(var P=0,I=x.rawDisplayDatas;P<I.length;P++){var O=I[P];if(null!==O&&2===O.type){var F=O.vertices.offset;b.indexOf(F)<0&&((y=t.BaseObject.borrowObject(t.DeformTimelineState)).vertexOffset=F,y.slot=x,y.init(this._armature,this,null),this._slotTimelines.push(y),this._poseTimelines.push(y))}}}}for(var p in v)for(var L=0,k=v[p];L<k.length;L++)y=k[L],this._slotTimelines.splice(this._slotTimelines.indexOf(y),1),y.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)(p=this._boneTimelines[h]).playState<=0&&p.update(a),(h===u-1||p.bone!==this._boneTimelines[h+1].bone)&&0!==(c=p.bone._blendState.update(this._weightResult,this.layer))&&p.blend(c);for(h=0,u=this._surfaceTimelines.length;h<u;++h){var c=(p=this._surfaceTimelines[h]).surface._blendState.update(this._weightResult,this.layer);p.playState<=0&&p.update(a),0!==c&&p.blend(c)}if(this.displayControl)for(h=0,u=this._slotTimelines.length;h<u;++h){var _=(p=this._slotTimelines[h]).slot.displayController;null!==_&&_!==this.name&&_!==this.group||p.playState<=0&&p.update(a)}for(h=0,u=this._constraintTimelines.length;h<u;++h)(p=this._constraintTimelines[h]).playState<=0&&p.update(a);for(h=0,u=this._animationTimelines.length;h<u;++h)c=(p=this._animationTimelines[h]).animationState._blendState.update(this._weightResult,this.layer),p.playState<=0&&p.update(a),0!==c&&p.blend(c)}if(0===this._fadeState){if(this._subFadeState>0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(var f=0,d=this._poseTimelines;f<d.length;f++){var p;(p=d[f])instanceof t.BoneTimelineState?this._boneTimelines.splice(this._boneTimelines.indexOf(p),1):p instanceof t.SurfaceTimelineState?this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(p),1):p instanceof t.SlotTimelineState?this._slotTimelines.splice(this._slotTimelines.indexOf(p),1):p instanceof t.ConstraintTimelineState&&this._constraintTimelines.splice(this._constraintTimelines.indexOf(p),1),p.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 FV(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}(LV||(LV={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return FV(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 FV(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 FV(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 FV(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 FV(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.constraint=null},e}(i);t.ConstraintTimelineState=s}(LV||(LV={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return FV(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 d=Math.floor(n*this._frameRate);f=this._frameIndices[u.frameIndicesOffset+d],this.currentPlayTimes===r&&f===_&&(f=-1)}for(;f>=0;){var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[p]/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&&(d=Math.floor(n*this._frameRate),f=this._frameIndices[u.frameIndicesOffset+d],p=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[p]/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,p=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[p]/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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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 FV(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=_}(LV||(LV={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return FV(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}(LV||(LV={})),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}(LV||(LV={})),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 FV(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,d=3*l*c,p=3*u*_,m=l*_;h.x=f*t+d*i+p*n+m*a,h.y=f*e+d*r+p*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],d=o?t[r+6]:1,p=o?t[r+7]:1,m=0,g=1;g-m>1e-4;){var y=.5*(g+m);this._getCurvePoint(l,h,u,c,_,f,d,p,y,this._helpPoint),a-this._helpPoint.x>0?m=y:g=y}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 d=0,p=this._actionFrames;d<p.length;d++){var m=p[d];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 g=0;g<l.length;++g)u.actions.push(o+g)},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 d=0,p=this._cacheBones[_.name];d<p.length;d++)p[d].parent=_;delete this._cacheBones[_.name]}n.addBone(_),this._rawBones.push(_)}if(t.DataParser.IK in e)for(var m=0,g=e[t.DataParser.IK];m<g.length;m++){var y=g[m];(B=this._parseIKConstraint(y))&&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 T=0,C=e[t.DataParser.SKIN];T<C.length;T++){var x=C[T];n.addSkin(this._parseSkin(x))}if(t.DataParser.PATH_CONSTRAINT in e)for(var w=0,E=e[t.DataParser.PATH_CONSTRAINT];w<E.length;w++){var B,R=E[w];(B=this._parsePathConstraint(R))&&n.addConstraint(B)}for(var D=0,M=this._cacheRawMeshes.length;D<M;++D){var P=this._cacheRawMeshes[D];t.DataParser.GLUE_WEIGHTS in P&&t.DataParser.GLUE_MESHES in P&&this._parseMeshGlue(P,this._cacheMeshes[D])}for(D=0,M=this._cacheRawMeshes.length;D<M;++D){var I=this._cacheRawMeshes[D],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[D].vertices.shareFrom(L.vertices)}}if(t.DataParser.ANIMATION in e)for(var k=0,V=e[t.DataParser.ANIMATION];k<V.length;k++){var N=V[k],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 X=0,W=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);X<W.length;X++)H=W[X],n.addAction(H,!1);for(var j in this._rawBones.length=0,this._cacheRawMeshes.length=0,this._cacheMeshes.length=0,this._armature=null,this._weightSlotPose)delete this._weightSlotPose[j];for(var j in this._weightBonePoses)delete this._weightBonePoses[j];for(var j in this._cacheBones)delete this._cacheBones[j];for(var j in this._slotChildActions)delete this._slotChildActions[j];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,d=this._slotChildActions[this._slot.name];f<d.length;f++)c=d[f],l.addAction(c);delete this._slotChildActions[this._slot.name]}}break;case 2:var p=a=t.BaseObject.borrowObject(t.MeshDisplayData);p.vertices.inheritDeform=r._getBoolean(e,t.DataParser.INHERIT_DEFORM,!0),p.name=i,p.path=n.length>0?n:i,p.vertices.data=this._data,t.DataParser.SHARE in e?(this._cacheRawMeshes.push(e),this._cacheMeshes.push(p)):this._parseMesh(e,p),t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e&&(this._cacheRawMeshes.push(e),this._cacheMeshes.push(p));break;case 3:var m=this._parseBoundingBox(e);if(null!==m){var g=a=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);g.name=i,g.path=n.length>0?n:i,g.boundingBox=m}break;case 4:var y=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=y.length;for(var b=0,S=y.length;b<S;++b)v.curveLengths[b]=y[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,d=this._armature.sortedBones,p=t.BaseObject.borrowObject(t.WeightData);for(p.count=c,p.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],g=this._rawBones[m];p.addBone(g),this._intArray[_+2+B]=d.indexOf(g)}this._floatArray.length+=3*c,B=0;for(var y=0,v=0,b=_+2+u,S=f;B<c;B++){var A=l[y++];this._intArray[b++]=A;for(var T=0;T<A;T++){var C=l[y++],x=l[y++],w=n[v++],E=n[v++];this._intArray[b++]=h.indexOf(C),this._floatArray[S++]=x,this._floatArray[S++]=w,this._floatArray[S++]=E}}i.vertices.weight=p}else{this._floatArray.length+=n.length;for(var B=0,R=n.length;B<R;++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 d=e[t.DataParser.WEIGHTS],p=e[t.DataParser.SLOT_POSE],m=e[t.DataParser.BONE_POSE],g=this._armature.sortedBones,y=new Array,v=Math.floor(m.length/7),b=this._floatArray.length,S=Math.floor(d.length-a)/2,A=this._intArray.length,T=t.BaseObject.borrowObject(t.WeightData);for(T.count=S,T.offset=A,y.length=v,this._intArray.length+=2+v+a+S,this._intArray[A+1]=b,_=0;_<v;++_){var C=m[7*_],x=this._rawBones[C];T.addBone(x),y[_]=C,this._intArray[A+2+_]=g.indexOf(x)}this._floatArray.length+=3*S,this._helpMatrixA.copyFromArray(p,0),_=0;for(var w=0,E=A+2+v,B=b;_<a;++_){var R=2*_,D=this._intArray[E++]=d[w++],M=this._floatArray[l+R],P=this._floatArray[l+R+1];this._helpMatrixA.transformPoint(M,P,this._helpPoint),M=this._helpPoint.x,P=this._helpPoint.y;for(var I=0;I<D;++I){C=d[w++];var O=y.indexOf(C);this._helpMatrixB.copyFromArray(m,7*O+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(M,P,this._helpPoint),this._intArray[E++]=O,this._floatArray[B++]=d[w++],this._floatArray[B++]=this._helpPoint.x,this._floatArray[B++]=this._helpPoint.y}}i.vertices.weight=T,this._weightSlotPose[c]=p,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 d=r._getString(c,t.DataParser.NAME,"");this._surface=this._armature.getBone(d),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 p=0,m=e[t.DataParser.SLOT];p<m.length;p++)c=m[p],this._parseSlotTimeline(c);if(t.DataParser.FFD in e)for(var g=0,y=e[t.DataParser.FFD];g<y.length;g++){c=y[g];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,T=e[t.DataParser.IK];A<T.length;A++){c=T[A];var C=r._getString(c,t.DataParser.NAME,""),x=this._armature.getConstraint(C);null!==x&&null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,30,!0,!1,2,this._parseIKConstraintFrame))&&this._animation.addConstraintTimeline(x,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,R=r._getString(c,t.DataParser.NAME,"");null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,40,!0,!1,2,this._parseAnimationFrame))&&this._animation.addAnimationTimeline(R,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,d=t.BaseObject.borrowObject(t.TimelineData),p=this._timelineArray.length;if(this._timelineArray.length+=5+c,null!==e?(this._timelineArray[p+0]=Math.round(100*r._getNumber(e,t.DataParser.SCALE,1)),this._timelineArray[p+1]=Math.round(100*r._getNumber(e,t.DataParser.OFFSET,0))):(this._timelineArray[p+0]=100,this._timelineArray[p+1]=0),this._timelineArray[p+2]=c,this._timelineArray[p+3]=h,this._timelineArray[p+4]=o?_-this._animation.frameIntOffset:l?f-this._animation.frameFloatOffset:0,this._timeline=d,d.type=a,d.offset=p,1===c)d.frameIndicesOffset=-1,this._timelineArray[p+5+0]=u.call(this,n[0],0,0)-this._animation.frameOffset;else{var m=this._animation.frameCount+1,g=this._data.frameIndices,y=0;t.DragonBones.webAssembly?(y=g.size(),g.resize(y+m,0)):(y=g.length,g.length+=m),d.frameIndicesOffset=y;for(var v=0,b=0,S=0,A=0;v<m;++v){if(S+A<=v&&b<c){var T=n[b];S=v,A=b===c-1?this._animation.frameCount-S:T instanceof i?this._actionFrames[b+1].frameStart-S:r._getNumber(T,t.DataParser.DURATION,1),this._timelineArray[p+5+b]=u.call(this,T,S,A)-this._animation.frameOffset,b++}t.DragonBones.webAssembly?g.set(y+v,b-1):g[y+v]=b-1}}return this._timeline=null,d},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,d=s.length;f<d;f+=2){for(var p=s[f],m=s[f+1];c!==p;)o[_++]=c++;l[c+m]=c++}for(;c<a;)o[_++]=c++;this._frameArray.length+=1+a,this._frameArray[n+1]=a;for(var g=a;g--;)-1===l[g]?this._frameArray[n+2+g]=o[--_]||0:this._frameArray[n+2+g]=l[g]||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,d=0,p=0;if(null!==c){var m=this._weightSlotPose[u];this._helpMatrixA.copyFromArray(m,0),this._frameFloatArray.length+=2*c.count,d=c.offset+2+c.bones.length}else this._frameFloatArray.length+=2*h;for(var g=0;g<2*h;g+=2)if(null===o?(_=0,f=0):(_=g<l||g-l>=o.length?0:o[g-l],f=g+1<l||g+1-l>=o.length?0:o[g+1-l]),null!==c){var y=this._weightBonePoses[u],v=this._intArray[d++];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[d++];this._helpMatrixB.copyFromArray(y,7*S+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(_,f,this._helpPoint,!0),this._frameFloatArray[s+p++]=this._helpPoint.x,this._frameFloatArray[s+p++]=this._helpPoint.y}}else this._frameFloatArray[s+g]=_,this._frameFloatArray[s+g+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 d=0,p=h[t.DataParser.INTS];d<p.length;d++){var m=p[d];f.addInt(m)}}if(t.DataParser.FLOATS in h){null===f&&(f=t.BaseObject.borrowObject(t.UserData));for(var g=0,y=h[t.DataParser.FLOATS];g<y.length;g++)m=y[g],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),d=new Int16Array(l,h+e+i+r+n,this._frameArray.length),p=new Uint16Array(l,h+e+i+r+n+s,this._timelineArray.length),m=0,g=this._intArray.length;m<g;++m)u[m]=this._intArray[m];for(m=0,g=this._floatArray.length;m<g;++m)c[m]=this._floatArray[m];for(m=0,g=this._frameIntArray.length;m<g;++m)_[m]=this._frameIntArray[m];for(m=0,g=this._frameFloatArray.length;m<g;++m)f[m]=this._frameFloatArray[m];for(m=0,g=this._frameArray.length;m<g;++m)d[m]=this._frameArray[m];for(m=0,g=this._timelineArray.length;m<g;++m)p[m]=this._timelineArray[m];t.webAssemblyModule.setDataBinary(this._data,h,e,i,r,n,s,a)}else{var y=new ArrayBuffer(o);for(u=new Int16Array(y,0,this._intArray.length),c=new Float32Array(y,e,this._floatArray.length),_=new Int16Array(y,e+i,this._frameIntArray.length),f=new Float32Array(y,e+i+r,this._frameFloatArray.length),d=new Int16Array(y,e+i+r+n,this._frameArray.length),p=new Uint16Array(y,e+i+r+n+s,this._timelineArray.length),m=0,g=this._intArray.length;m<g;++m)u[m]=this._intArray[m];for(m=0,g=this._floatArray.length;m<g;++m)c[m]=this._floatArray[m];for(m=0,g=this._frameIntArray.length;m<g;++m)_[m]=this._frameIntArray[m];for(m=0,g=this._frameFloatArray.length;m<g;++m)f[m]=this._frameFloatArray[m];for(m=0,g=this._frameArray.length;m<g;++m)d[m]=this._frameArray[m];for(m=0,g=this._timelineArray.length;m<g;++m)p[m]=this._timelineArray[m];this._data.binary=y,this._data.intArray=u,this._data.floatArray=c,this._data.frameIntArray=_,this._data.frameFloatArray=f,this._data.frameArray=d,this._data.timelineArray=p}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}(LV||(LV={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return FV(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 d=this._armature.getSlot(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.addSlotTimeline(d,_)}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 p=this._armature.getConstraint(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.addConstraintTimeline(p,_)}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),d=new Uint16Array(this._binary,this._binaryOffset+i[10],l/Uint16Array.BYTES_PER_ELEMENT);if(t.DragonBones.webAssembly){for(var p=r+n+s+a+o+l,m=t.webAssemblyModule._malloc(p),g=new Uint8Array(this._binary,this._binaryOffset,p/Uint8Array.BYTES_PER_ELEMENT),y=new Uint8Array(t.webAssemblyModule.HEAP16.buffer,m,g.length),v=0,b=g.length;v<b;++v)y[v]=g[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=d}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=d},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}(LV||(LV={})),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,d=0,p=t.DragonBones.webAssembly?c.size():c.length;d<p;++d){var m=t.DragonBones.webAssembly?c.get(d):c[d];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 d=f[_],p=t.BaseObject.borrowObject(t.EventObject);t.EventObject.actionDataToInstance(d,p,n.armature),p.slot=n,n.armature._bufferAction(p,!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,d=c;f<d;++f){var p=t.DragonBones.webAssembly?u.get(f):u[f];_[f]=null!==p?this._getSlotDisplay(null,p,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 d=f[_];if(d instanceof t.Armature){var p=n.getDisplays(u.name);if(null!==p&&c<(t.DragonBones.webAssembly?p.size():p.length)){var m=t.DragonBones.webAssembly?p.get(c):p[c];if(null!==m&&1===m.type){var g=this.getArmatureData(m.path,m.parent.parent.parent.name);g&&this.replaceAnimation(d,g,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}(LV||(LV={})),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}}(LV||(LV={}));var kV,VV,NV,GV,zV,UV,HV,XV,WV,jV,YV,qV,KV,JV=LV.DragonBones,ZV=LV.BaseObject,QV=LV.Matrix,$V=LV.Transform,tN=LV.ColorTransform,eN=LV.Point,iN=LV.Rectangle,rN=LV.UserData,nN=LV.ActionData,sN=LV.DragonBonesData,aN=LV.ArmatureData,oN=LV.BoneData,lN=LV.SurfaceData,hN=LV.SlotData,uN=LV.ConstraintData,cN=LV.IKConstraintData,_N=LV.PathConstraintData,fN=LV.CanvasData,dN=LV.SkinData,pN=LV.VerticesData,mN=LV.DisplayData,gN=LV.ImageDisplayData,yN=LV.ArmatureDisplayData,vN=LV.MeshDisplayData,bN=LV.BoundingBoxDisplayData,SN=LV.PathDisplayData,AN=LV.WeightData,TN=LV.BoundingBoxData,CN=LV.RectangleBoundingBoxData,xN=LV.EllipseBoundingBoxData,wN=LV.PolygonBoundingBoxData,EN=LV.AnimationData,BN=LV.TimelineData,RN=LV.AnimationConfig,DN=LV.TextureAtlasData,MN=LV.TextureData,PN=LV.DeformVertices,IN=LV.Armature,ON=LV.TransformObject,FN=LV.Bone,LN=LV.Surface,kN=LV.Slot,VN=LV.Constraint,NN=LV.IKConstraint,GN=LV.PathConstraint,zN=LV.WorldClock,UN=LV.Animation,HN=LV.AnimationState,XN=LV.BonePose,WN=LV.BlendState,jN=LV.TimelineState,YN=LV.TweenTimelineState,qN=LV.BoneTimelineState,KN=LV.SlotTimelineState,JN=LV.ConstraintTimelineState,ZN=LV.ActionTimelineState,QN=LV.ZOrderTimelineState,$N=LV.BoneAllTimelineState,tG=LV.BoneTranslateTimelineState,eG=LV.BoneRotateTimelineState,iG=LV.BoneScaleTimelineState,rG=LV.SurfaceTimelineState,nG=LV.SlotDislayTimelineState,sG=LV.SlotColorTimelineState,aG=LV.DeformTimelineState,oG=LV.IKConstraintTimelineState,lG=LV.AnimationTimelineState,hG=LV.EventObject,uG=LV.DataParser,cG=LV.ObjectDataParser,_G=LV.ActionFrame,fG=LV.BinaryDataParser,dG=LV.BaseFactory,pG=LV.BuildArmaturePackage,mG=LV.BinaryOffset,gG=LV.ArmatureType,yG=LV.BoneType,vG=LV.DisplayType,bG=LV.BoundingBoxType,SG=LV.ActionType,AG=LV.BlendMode,TG=LV.TweenType,CG=LV.TimelineType,xG=En("dragonBones.CCTextureAtlasData")(kV=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}on(e,t),e.toString=function(){return"[class dragonBones.CCTextureAtlasData]"};var i=e.prototype;return i.createTexture=function(){return ZV.borrowObject(wG)},i._onClear=function(){t.prototype._onClear.call(this),this.renderTexture=null},Ur(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 m(i.region.x,i.region.y,i.region.height,i.region.width):(r=new m(i.region.x,i.region.y,i.region.width,i.region.height),i.spriteFrame=new Bh,i.spriteFrame.texture=t,i.spriteFrame.rect=r)}}else for(var n in this.textures)this.textures[n].spriteFrame=null}}]),e}(DN))||kV,wG=En("dragonBones.CCTextureData")(VV=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 on(e,t),e.toString=function(){return"[class dragonBones.CCTextureData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.spriteFrame=null},e}(MN))||VV,EG=En("dragonBones.CCSlot")(NV=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 c,e._worldMatrix=new c,e._worldMatrixDirty=!0,e._visible=!1,e._color=new y,e}on(e,t),e.toString=function(){return"[class dragonBones.CCSlot]"};var i=e.prototype;return i.getTexture=function(){return this._textureData?this._textureData.spriteFrame.texture:null},i.calculWorldMatrix=function(){var t=this._armature._parent;t?this._mulMat(this._worldMatrix,t._worldMatrix,this._matrix):c.copy(this._worldMatrix,this._matrix),this._worldMatrixDirty=!1},i._onClear=function(){t.prototype._onClear.call(this),this._localVertices.length=0,this._indices.length=0,c.identity(this._matrix),c.identity(this._worldMatrix),this._worldMatrixDirty=!0,this._color=new y,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+mG.MeshVertexCount],d=c[h.offset+mG.MeshTriangleCount],p=c[h.offset+mG.MeshFloatOffset];p<0&&(p+=65536);for(var m=p+2*f,g=this._armature._armatureData.scale,y=0,v=2*f;y<v;y+=2)e[r++]=_[p+y]*g,e[r++]=-_[p+y+1]*g,h.rotated?(e[r++]=(l.x+(1-_[m+y])*l.width)/a,e[r++]=(l.y+_[m+y+1]*l.height)/o):(e[r++]=(l.x+_[m+y]*l.width)/a,e[r++]=(l.y+_[m+y+1]*l.height)/o);for(var b=0;b<3*d;++b)t[i++]=c[h.offset+mG.MeshVertexIndices+b];e.length=r,t.length=i,h.weight&&this._identityTransform()}else{var S=l.x/a,A=(l.y+l.height)/o,T=(l.x+l.width)/a,C=l.y/o;e[r++]=0,e[r++]=0,e[r++]=S,e[r++]=A,e[r++]=l.width,e[r++]=0,e[r++]=T,e[r++]=A,e[r++]=0,e[r++]=l.height,e[r++]=S,e[r++]=C,e[r++]=l.width,e[r++]=l.height,e[r++]=T,e[r++]=C,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+mG.MeshVertexCount],c=l[n.offset+mG.WeigthFloatOffset];c<0&&(c+=65536);for(var _=0,f=n.offset+mG.WeigthBoneIndices+i.length,d=c,p=0,m=0;_<u;_++,m+=4){for(var g=l[f++],y=0,v=0,b=0;b<g;++b){var S=i[l[f++]];if(null!==S){var A=S.globalTransformMatrix,T=h[d++],C=h[d++]*t,x=h[d++]*t;s&&(C+=e[p++],x+=e[p++]),y+=(A.a*C+A.c*x+A.tx)*T,v+=(A.b*C+A.d*x+A.ty)*T}}a[m]=y,a[m+1]=-v}}else if(s){var w=this._parent._boneData.type!==yG.Bone,E=r.data,B=E.intArray,R=E.floatArray,D=B[r.offset+mG.MeshVertexCount],M=B[r.offset+mG.MeshFloatOffset];M<0&&(M+=65536);for(var P=0,I=D,O=0;P<I;P++,O+=4){var F=R[M+2*P]*t+e[2*P],L=R[M+2*P+1]*t+e[2*P+1];if(w){var k=this._parent._getGlobalTransformMatrix(F,L);a[O]=k.a*F+k.c*L+k.tx,a[O+1]=-k.b*F+k.d*L+k.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,d=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*d+o,t.m13=n*f+a*d+l):(t.m00=h*r,t.m01=u*a,t.m04=c*r,t.m05=_*a,t.m12=r*f+o,t.m13=a*d+l)},e}(kN))||NV,BG=En("dragonBones.CCArmatureDisplay")(GV=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 Wa,e}on(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 n(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)},Ur(e,[{key:"node",get:function(){return this}}]),e}(mN))||GV,RG=En("CCFactory")((HV=UV=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 BG;return e._dragonBones=new JV(i),Kr.getScheduler()&&(Ir.on(ao.EVENT_RESTART,e.onRestart,Pn(e)),e.initUpdate()),e.id=e.uuid="CCFactory",e}on(e,t),e.getInstance=function(){return e._factory||(e._factory=new e),e._factory};var i=e.prototype;return i.onRestart=function(){e._factory=null},i.initUpdate=function(){Br.enableForTarget(this),Kr.getScheduler().scheduleUpdate(this,Rr.Priority.HIGH,!1)},i.update=function(t){this._dragonBones.advanceTime(t)},i.getDragonBonesDataByRawData=function(t){return(t instanceof ArrayBuffer?dG._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 ks).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=ZV.borrowObject(xG),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.unshift(n)}this._slots=e},i._buildArmature=function(t){var e=ZV.borrowObject(IN);e._skinData=t.skin,e._animation=ZV.borrowObject(UN),e._animation._armature=e,e._animation.animations=t.armature.animations,e._isChildArmature=!1;var i=new BG;return e.init(t.armature,i,i,this._dragonBones),e},i._buildSlot=function(t,e,i){var r=ZV.borrowObject(EG),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}(dG),UV._factory=null,zV=HV))||zV,DG=1/60,MG=[],PG=[],IG=0,OG=0,FG=0,LG=null,kG=null,VG=0,NG=0,GG=0,zG=0,UG=0,HG=function(){function t(){this.maxVertexCount=0,this.maxIndexCount=0,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(DG),this._frameIdx++,this.updateFrame(e,this._frameIdx),this.totalTime+=DG}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){FG=0,IG=0,OG=0,LG=null,kG=null,VG=0,NG=0,GG=0,zG=0,UG=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),zG>0&&(n[zG-1].vfOffset=FG),n.length=zG,s.length=IG;var a=GG-1;if(a>=0)if(NG>0){var o=r[a];o.indexCount=NG,o.vfCount=9*VG,o.vertexCount=VG,r.length=GG}else r.length=GG-1;if(0!==r.length){var l,h=i.vertices,u=FG/5,c=9*u;(!h||h.length<FG)&&(h=i.vertices=new Float32Array(c));for(var _=0,f=0;_<c;)h[_]=MG[f++],h[_+1]=MG[f++],h[_+3]=MG[f++],h[_+4]=MG[f++],l=MG[f++],h[_+5]=(255&l)/255,h[_+6]=(l>>8&255)/255,h[_+7]=(l>>16&255)/255,h[_+8]=(l>>24&255)/255,_+=9;var d=i.indices;(!d||d.length<OG)&&(d=i.indices=new Uint16Array(OG));for(var p=0;p<OG;p++)d[p]=PG[p];i.vertices=h,i.indices=d,this.maxVertexCount=u>this.maxVertexCount?u:this.maxVertexCount,this.maxIndexCount=d.length>this.maxIndexCount?d.length:this.maxIndexCount}},e._traverseArmature=function(t,e){var i,r,n,s,a,o,l,h,u,c=this._tempColors,_=this._tempSegments,f=this._tempBoneInfos,d=t._slots,p=t._bones;if(this._enableCacheAttachedInfo)for(var m=0,g=p.length;m<g;m++,IG++){var y=p[m],v=f[IG];v||(v=f[IG]={globalTransformMatrix:new QV});var b=y.globalTransformMatrix;v.globalTransformMatrix.copyFrom(b)}for(var S=0,A=d.length;S<A;S++)if((n=d[S])._visible&&n._displayData)if(n.updateWorldMatrix(),a=n._color,n.childArmature)this._traverseArmature(n.childArmature,e*a.a/255);else if(l=n.getTexture()){LG===l.nativeUrl&&kG===n._blendMode||(LG=l.nativeUrl,kG=n._blendMode,(h=GG-1)>=0&&(NG>0?((u=_[h]).indexCount=NG,u.vertexCount=VG,u.vfCount=9*VG):GG--),_[GG]={tex:l,blendMode:n._blendMode,indexCount:0,vertexCount:0,vfCount:0},GG++,NG=0,VG=0),o=(a.a*e<<24>>>0)+(a.b<<16)+(a.g<<8)+a.r,UG!==o&&(UG=o,zG>0&&(c[zG-1].vfOffset=FG),c[zG++]={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,C=i.length;T<C;)XV=i[T++],WV=i[T++],MG[FG++]=XV*s.m00+WV*s.m04+s.m12,MG[FG++]=XV*s.m01+WV*s.m05+s.m13,MG[FG++]=i[T++],MG[FG++]=i[T++],MG[FG++]=o;for(var x=0,w=r.length;x<w;x++)PG[OG++]=VG+r[x];NG+=r.length,VG+=i.length/4}},t}(),XG=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=RG.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 HG)._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}();XG.FrameTime=DG,XG.sharedCache=new XG;var WG,jG,YG,qG,KG,JG,ZG,QG,$G,tz=En("dragonBones.DragonBonesAsset")((KV=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,Mn(e,"_dragonBonesJson",qV,Pn(e)),e._factory=null,e._dragonBonesJsonData=void 0,e._armaturesEnum=null,e}on(e,t);var i=e.prototype;return i.constructctor=function(){this.reset()},i.createNode=function(t){var e=new ks(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||RG.getInstance(),!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=zs(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 zs(r)}return null},i.destroy=function(){return this._clear(),t.prototype.destroy.call(this)},i._clear=function(){this._factory&&(XG.sharedCache.resetArmature(this._uuid),this._factory.removeDragonBonesDataByUUID(this._uuid,!0))},Ur(e,[{key:"dragonBonesJson",get:function(){return this._dragonBonesJson},set:function(t){this._dragonBonesJson=t,this._dragonBonesJsonData=JSON.parse(t),this.reset()}}]),e}(Qr),qV=Dn((YV=KV).prototype,"_dragonBonesJson",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),jV=YV))||jV;Er.internal.DragonBonesAsset=tz;var ez,iz=(WG=En("dragonBones.DragonBonesAtlasAsset"),jG=Wn(fn),WG(($G=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_atlasJson",KG,Pn(e)),Mn(e,"_texture",JG,Pn(e)),Mn(e,"_atlasJsonData",ZG,Pn(e)),e._factory=null,Mn(e,"_textureAtlasData",QG,Pn(e)),e._clear(),e}on(e,t);var i=e.prototype;return i.createNode=function(t){var e=new ks(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&&(XG.sharedCache.resetArmature(this._uuid),this._factory.removeTextureAtlasData(this._uuid,!0),this._factory.removeDragonBonesDataByUUID(this._uuid,!0)),this._textureAtlasData=null},Ur(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}(Qr),KG=Dn((qG=$G).prototype,"_atlasJson",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),JG=Dn(qG.prototype,"_texture",[On,jG],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ZG=Dn(qG.prototype,"_atlasJsonData",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),QG=Dn(qG.prototype,"_textureAtlasData",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),YG=qG))||YG);Er.internal.DragonBonesAtlasAsset=iz;var rz,nz,sz,az,oz,lz,hz,uz,cz,_z,fz,dz,pz,mz,gz,yz,vz,bz,Sz,Az,Tz,Cz,xz,wz,Ez,Bz,Rz,Dz,Mz,Pz,Iz,Oz,Fz,Lz,kz,Vz,Nz,Gz,zz,Uz,Hz,Xz,Wz,jz,Yz,qz,Kz,Jz,Zz,Qz,$z,tU,eU,iU=new c,rU=En("dragonBones.AttachUtil")(ez=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=this._armature.getBones(),l=s.length-1;l>=0;l--){var h=s[l],u=h.target;if(u)if(u.isValid){var c=e?t[h.boneIndex]:o[h.boneIndex];c&&(i=u,r=c.globalTransformMatrix,n=void 0,(n=iU).m00=r.a,n.m01=r.b,n.m04=-r.c,n.m05=-r.d,n.m12=r.tx,n.m13=r.ty,i.matrix=iU)}else a.delete(h.path),s.splice(l,1)}}},t}())||ez,nU=function(t){function e(){var e;return(e=t.call(this)||this)._armatures=new Set,e}on(e,t),e.getInstance=function(){return e._instance||(e._instance=new e,Kr.registerSystem(e.ID,e._instance,Rr.Priority.HIGH)),e._instance};var i=e.prototype;return i.add=function(t){t&&(this._armatures.has(t)||this._armatures.add(t))},i.remove=function(t){t&&this._armatures.has(t)&&this._armatures.delete(t)},i.postUpdate=function(t){this._armatures&&this._armatures.forEach((function(e){e.updateAnimation(t)}))},i.prepareRenderData=function(){this._armatures&&this._armatures.forEach((function(t){t.markForUpdateRenderData()}))},e}(Rr);function sU(t,e,i){lo.Attr.setClassAttr(t,e,"type","Enum"),lo.Attr.setClassAttr(t,e,"enumList",zs.getList(i))}nU.ID="ARMATURE",nU._instance=void 0,Er.internal.ArmatureSystem=nU,function(t){t[t.default=-1]="default"}(Qz||(Qz={})),ss(Qz),function(t){t[t["<None>"]=0]="<None>"}($z||($z={})),ss($z),function(t){t[t.REALTIME=0]="REALTIME"}(tU||(tU={})),ss($z),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(eU||(eU={})),ss(eU);var aU=(rz=En("dragonBones.ArmatureDisplay.DragonBoneSocket"),nz=Wn(ks),rz((oz=Dn((az=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),Mn(this,"path",oz,this),Mn(this,"target",lz,this),this.boneIndex=null,this.path=t,this.target=e}).prototype,"path",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),lz=Dn(az.prototype,"target",[nz,Un,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),sz=az))||sz);oo(aU,"dragonBones.ArmatureDisplay.DragonBoneSocket");var oU=(hz=En("dragonBones.ArmatureDisplay"),uz=Qn(),cz=ts(),_z=Wn(tz),fz=is(),dz=Wn(iz),pz=is(),mz=cs(),gz=cs(),yz=_s(),vz=Wn(Qz),bz=is(),Sz=Wn($z),Az=_s(),Tz=is(),Cz=_s(),xz=is(),wz=is(),Ez=is(),Bz=is(),Rz=is(),Dz=Wn([aU]),Mz=is(),Pz=Wn(cn),Iz=es(),Oz=_s(),hz(Fz=uz(Fz=cz(Fz=Jn((Zz=Jz=function(t){on(i,t);var e=i.prototype;function i(){var e;return e=t.call(this)||this,Mn(e,"playTimes",kz,Pn(e)),Mn(e,"premultipliedAlpha",Vz,Pn(e)),e._armature=null,e.attachUtil=void 0,Mn(e,"_defaultArmatureIndexValue",Nz,Pn(e)),Mn(e,"_dragonAsset",Gz,Pn(e)),Mn(e,"_dragonAtlasAsset",zz,Pn(e)),Mn(e,"_armatureName",Uz,Pn(e)),Mn(e,"_animationName",Hz,Pn(e)),Mn(e,"_animationIndexValue",Xz,Pn(e)),e._preCacheMode=-1,e._cacheMode=eU.REALTIME,Mn(e,"_defaultCacheModeValue",Wz,Pn(e)),Mn(e,"_timeScale",jz,Pn(e)),Mn(e,"_playTimes",Yz,Pn(e)),Mn(e,"_debugBones",qz,Pn(e)),e._debugDraw=null,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._drawIdx=0,e._drawList=new X((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),e.maxVertexCount=0,e.maxIndexCount=0,e._materialCache={},e._enumArmatures=zs({}),e._enumAnimations=zs({}),e._socketNodes=new Map,e._cachedSockets=new Map,Mn(e,"_sockets",Kz,Pn(e)),e._inited=void 0,e._drawInfoList=[],e._cacheModeEnum=void 0,e._eventTarget=new Wa,e._inited=!1,e.attachUtil=new rU,e.initFactory(),sU(Pn(e),"_animationIndex",e._enumAnimations),sU(Pn(e),"_defaultArmatureIndex",e._enumArmatures),e._useVertexOpacity=!0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new Gu),this._drawInfoList[t]},e.initFactory=function(){this._factory=RG.getInstance()},e.onLoad=function(){t.prototype.onLoad.call(this);for(var e=this.node.children,i=0,r=e.length;i<r;i++){var n=e[i];0===(n.name&&n.name.search("CHILD_ARMATURE-"))&&n.destroy()}},e._requestDrawData=function(t,e,i,r){var n=this._drawList.add();return n.material=t,n.texture=e,n.indexOffset=i,n.indexCount=r,n},e.destroyRenderData=function(){this._drawList.reset(),t.prototype.destroyRenderData.call(this)},e.getMaterialForBlend=function(t,e){var i=t+"/"+e,r=this._materialCache[i];if(r)return r;var n=this.getMaterial(0);return(r=new Ps({parent:n,subModelIdx:0,owner:this})).recompileShaders({USE_LOCAL:!0},0),this._materialCache[i]=r,r.overridePipelineStates({blendState:{targets:[{blendSrc:t,blendDst:e}]}}),r},e._render=function(t){if(this.renderData&&this._drawList){var e=this.renderData,i=e.chunk,r=i.vertexAccessor,n=e.getMeshBuffer(),s=n.indexOffset;r.appendIndices(i.bufferId,e.indices);for(var a=0;a<this._drawList.length;a++){this._drawIdx=a;var o=this._drawList.data[a];if(o.texture){var l=n.requireFreeIA(t.device);l.firstIndex=s+o.indexOffset,l.indexCount=o.indexCount,t.commitIA(this,l,o.texture,o.material,this.node)}}}},e.__preload=function(){t.prototype.__preload.call(this),this._init()},e._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()}},e.getArmatureKey=function(){return this._armatureKey},e.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())},e.isAnimationCached=function(){return this._cacheMode!==eU.REALTIME},e.onEnable=function(){t.prototype.onEnable.call(this),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.add(this._armature),this._flushAssembler(),nU.getInstance().add(this)},e.onDisable=function(){t.prototype.onDisable.call(this),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.remove(this._armature),nU.getInstance().remove(this)},e._emitCacheCompleteEvent=function(){this._eventTarget.emit(hG.LOOP_COMPLETE),this._eventTarget.emit(hG.COMPLETE)},e.updateAnimation=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=XG.FrameTime;0===this._accTime&&0===this._playCount&&this._eventTarget.emit(hG.START),this._accTime+=t*this.timeScale*1;var n=Math.floor(this._accTime/r);if(e.isCompleted||(e.updateToFrame(n),this.renderData&&(this.renderData.vertexCount<e.maxVertexCount||this.renderData.indexCount<e.maxIndexCount)&&(this.maxVertexCount=e.maxVertexCount>this.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount)))),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],this.renderData&&(this.renderData.vertexCount<e.maxVertexCount||this.renderData.indexCount<e.maxIndexCount)&&(this.maxVertexCount=e.maxVertexCount>this.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount))))}}},e.onDestroy=function(){this._materialInstances=this._materialInstances.filter((function(t){return!!t})),this._inited=!1,this._cacheMode===eU.PRIVATE_CACHE?(this._armatureCache.dispose(),this._armatureCache=null,this._armature=null):this._cacheMode===eU.SHARED_CACHE?(this._armatureCache=null,this._armature=null):this._armature&&(this._armature.dispose(),this._armature=null),this._drawList.destroy(),t.prototype.onDestroy.call(this)},e._updateDebugDraw=function(){if(this.debugBones){if(!this._debugDraw){var t=new ks("DEBUG_DRAW_NODE");t.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy;var e=t.addComponent(Mp);e.lineWidth=1,e.strokeColor=new y(255,0,0,255),this._debugDraw=e}this._debugDraw.node.parent=this.node}else this._debugDraw&&(this._debugDraw.node.parent=null);this.markForUpdateRenderData()},e._buildArmature=function(){if(this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName){this._armature&&(this._preCacheMode===eU.PRIVATE_CACHE?this._armatureCache.dispose():this._preCacheMode===eU.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===eU.SHARED_CACHE?this._armatureCache=XG.sharedCache:this._cacheMode===eU.PRIVATE_CACHE&&(this._armatureCache=new XG,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=eU.REALTIME)),this._preCacheMode=this._cacheMode,this._cacheMode===eU.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!==eU.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.attachUtil.init(this),this.animationName&&this.playAnimation(this.animationName,this.playTimes),this._flushAssembler()}},e.querySockets=function(){return this._armature?(0===this._cachedSockets.size&&this._indexBoneSockets(),Array.from(this._cachedSockets.keys()).sort()):[]},e.querySocketPathByName=function(t){for(var e,i=[],r=hn(this._cachedSockets.keys());!(e=r()).done;){var n=e.value;n.endsWith(t)&&i.push(n)}return i},e._parseDragonAtlasAsset=function(){this.dragonAtlasAsset&&this.dragonAtlasAsset.init(this._factory)},e._refresh=function(){this._buildArmature(),this._indexBoneSockets(),this.markForUpdateRenderData()},e._updateCacheModeEnum=function(){this._cacheModeEnum=zs({}),this._armature?Object.assign(this._cacheModeEnum,eU):Object.assign(this._cacheModeEnum,tU),sU(this,"_defaultCacheMode",this._cacheModeEnum)},e._updateAnimEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getAnimsEnum(this.armatureName):$z,this._enumAnimations=zs({}),Object.assign(this._enumAnimations,t||$z),zs.update(this._enumAnimations),sU(this,"_animationIndex",this._enumAnimations)},e._updateArmatureEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getArmatureEnum():Qz,this._enumArmatures=zs({}),Object.assign(this._enumArmatures,t||Qz),zs.update(this._enumArmatures),sU(this,"_defaultArmatureIndex",this._enumArmatures)},e._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=hn(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)}},e.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},e.updateAnimationCache=function(t){this.isAnimationCached()&&this._armatureCache.updateAnimationCache(this._armatureKey,t)},e.invalidAnimationCache=function(){this.isAnimationCached()&&this._armatureCache.invalidAnimationCache(this._armatureKey)},e.getArmatureNames=function(){var t=this._factory.getDragonBonesData(this._armatureKey);return t&&t.armatureNames||[]},e.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},e.on=function(t,e,i){this.addEventListener(t,e,i)},e.off=function(t,e,i){this.removeEventListener(t,e,i)},e.once=function(t,e,i){this._eventTarget.once(t,e,i)},e.addEventListener=function(t,e,i){this._eventTarget.on(t,e,i)},e.removeEventListener=function(t,e,i){this._eventTarget.off(t,e,i)},e.buildArmature=function(t,e){return this._factory.createArmatureNode(this,t,e)},e.armature=function(){return this._armature},e._flushAssembler=function(){var t=i.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._armature&&this._assembler&&(this._renderData=this._assembler.createData(this),this.renderData&&(this.maxVertexCount=this.renderData.vertexCount,this.maxIndexCount=this.renderData.indexCount),this.markForUpdateRenderData(),this._updateColor())},e._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)}}}},e._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)}},e._cleanMaterialCache=function(){for(var t in this._materialCache)this._materialCache[t].destroy();this._materialCache={}},e.createRenderEntity=function(){var t=new Bc(zu.DYNAMIC);return t.setUseLocal(!0),t},e.markForUpdateRenderData=function(e){void 0===e&&(e=!0),t.prototype.markForUpdateRenderData.call(this,e),this._debugDraw&&this._debugDraw.markForUpdateRenderData(e)},Ur(i,[{key:"dragonAsset",get:function(){return this._dragonAsset},set:function(t){this._dragonAsset=t,this.destroyRenderData(),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 Nn(7400,this.name);e=i[this._defaultArmatureIndex]}void 0!==e?this.armatureName=e:Nn(7401,this.name),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):Nn(7402,this.name)}}else this.animationName=""}},{key:"_defaultCacheMode",get:function(){return this._defaultCacheModeValue},set:function(t){if(this._defaultCacheModeValue=t,this._defaultCacheMode!==eU.REALTIME&&this._armature&&!XG.canCache(this._armature))return this._defaultCacheMode=eU.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:"drawList",get:function(){return this._drawList}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this._cleanMaterialCache(),this.setMaterial(this._customMaterial,0),this.markForUpdateRenderData()}}]),i}(af),Jz.AnimationCacheMode=eU,Dn((Lz=Zz).prototype,"dragonAsset",[Un,_z,fz],Object.getOwnPropertyDescriptor(Lz.prototype,"dragonAsset"),Lz.prototype),Dn(Lz.prototype,"dragonAtlasAsset",[Un,dz,pz],Object.getOwnPropertyDescriptor(Lz.prototype,"dragonAtlasAsset"),Lz.prototype),Dn(Lz.prototype,"armatureName",[mz],Object.getOwnPropertyDescriptor(Lz.prototype,"armatureName"),Lz.prototype),Dn(Lz.prototype,"animationName",[gz],Object.getOwnPropertyDescriptor(Lz.prototype,"animationName"),Lz.prototype),Dn(Lz.prototype,"_defaultArmatureIndex",[yz,Un,vz,bz],Object.getOwnPropertyDescriptor(Lz.prototype,"_defaultArmatureIndex"),Lz.prototype),Dn(Lz.prototype,"_animationIndex",[Un,Sz,Az,Tz],Object.getOwnPropertyDescriptor(Lz.prototype,"_animationIndex"),Lz.prototype),Dn(Lz.prototype,"_defaultCacheMode",[Un,Cz,xz],Object.getOwnPropertyDescriptor(Lz.prototype,"_defaultCacheMode"),Lz.prototype),Dn(Lz.prototype,"timeScale",[Un,wz,On],Object.getOwnPropertyDescriptor(Lz.prototype,"timeScale"),Lz.prototype),kz=Dn(Lz.prototype,"playTimes",[Ez,Un,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Vz=Dn(Lz.prototype,"premultipliedAlpha",[On,Un,Bz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(Lz.prototype,"debugBones",[Rz,Un],Object.getOwnPropertyDescriptor(Lz.prototype,"debugBones"),Lz.prototype),Dn(Lz.prototype,"sockets",[Dz,Mz],Object.getOwnPropertyDescriptor(Lz.prototype,"sockets"),Lz.prototype),Nz=Dn(Lz.prototype,"_defaultArmatureIndexValue",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Qz.default}}),Gz=Dn(Lz.prototype,"_dragonAsset",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zz=Dn(Lz.prototype,"_dragonAtlasAsset",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Uz=Dn(Lz.prototype,"_armatureName",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Hz=Dn(Lz.prototype,"_animationName",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Xz=Dn(Lz.prototype,"_animationIndexValue",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Wz=Dn(Lz.prototype,"_defaultCacheModeValue",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return eU.REALTIME}}),jz=Dn(Lz.prototype,"_timeScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Yz=Dn(Lz.prototype,"_playTimes",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),qz=Dn(Lz.prototype,"_debugBones",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Kz=Dn(Lz.prototype,"_sockets",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dn(Lz.prototype,"customMaterial",[Hn,Pz,Iz,Oz],Object.getOwnPropertyDescriptor(Lz.prototype,"customMaterial"),Lz.prototype),Fz=Lz))||Fz)||Fz)||Fz)||Fz);Er.internal.ArmatureDisplay=oU;var lU,hU,uU,cU,_U,fU,dU,pU,mU,gU,yU,vU,bU,SU,AU,TU,CU,xU,wU,EU=new y(255,0,0,255),BU=new y(0,0,255,255),RU=new y(0,255,0,255),DU=0,MU=0,PU=0,IU=0,OU=0,FU=0,LU=0,kU=0,VU=0,NU=new Float32Array(4),GU=new c,zU=null,UU=null;function HU(t,e){if(!t)return null;var i,r;switch(e){case 1:i=_U?gt.ONE:gt.SRC_ALPHA,r=gt.ONE;break;case 10:i=gt.DST_COLOR,r=gt.ONE_MINUS_SRC_ALPHA;break;case 12:i=gt.ONE,r=gt.ONE_MINUS_SRC_COLOR;break;case 0:default:i=_U?gt.ONE:gt.SRC_ALPHA,r=gt.ONE_MINUS_SRC_ALPHA}return gU.getMaterialForBlend(i,r)}function XU(t,e){var i=t.a*e*cU,r=_U?i/255:1,n=t.r*lU*r/255,s=t.g*hU*r/255,a=t.b*uU*r/255;NU[0]=n,NU[1]=s,NU[2]=a,NU[3]=_U?1:i/255}var WU=null,jU={accessor:WU,vCount:32767,ensureAccessor:function(){if(!WU){var t=Kr.root.device,e=Kr.root.batcher2D,i=xu;this.accessor=WU=new ku(t,i,this.vCount),e.registerBufferAccessor(Number.parseInt("DRAGONBONES",36),WU)}return this.accessor},createData:function(t){var e=t.renderData;if(!e){this.ensureAccessor();for(var i=t._armature._slots,r=0,n=0,s=0;s<i.length;++s){var a=i[s];r+=a._localVertices.length/4,n+=a._indices.length}(e=Pc.add(xu,this.accessor)).resize(r,n),e.indices&&n===e.indices.length||(e.indices=new Uint16Array(n))}return e},updateRenderData:function(t){gU=t,t._armature&&function(t){var e=t._armature;if(e){fU=!0,_U=t.premultipliedAlpha,t.drawList.reset(),gU=t,t.node,dU=t.renderData,gU=t,bU=0,zU=null;var i,r=t.color;if(lU=r.r/255,hU=r.g/255,uU=r.b/255,cU=t.node._uiProps.opacity,4294967295!==r._val&&(bU|=1),DU=0,PU=0,IU=0,OU=0,FU=0,VU=0,LU=gU.maxVertexCount,kU=gU.maxIndexCount,t.isAnimationCached())!function(t){if(t){var e=t.segments;if(0!==e.length){var i=null,r=t.vertices,n=t.indices,s=0,a=0,o=0,l=0,h=0,u=t.colors,c=u[h++],_=c.vfOffset;XU(c,1);for(var f=dU,d=f.chunk.vb,p=f.indices,m=0,g=e.length;m<g;m++){var y=e[m];if(i=HU(y.tex,y.blendMode)){if(zU||(zU=i),fU||i.hash!==zU.hash||y.tex&&y.tex!==UU){fU=!1;var v=FU-VU;v>0&&(gU._requestDrawData(zU,UU,VU,v),VU=FU),zU=i,UU=y.tex}MU=y.vertexCount,OU=y.indexCount,s=f.chunk.vertexOffset;for(var b=FU,S=FU+OU;b<S;b++)p[b]=s+PU+n[o++];l=y.vfCount;var A=r.subarray(a,l);d.set(A,a);if(1&bU)for(var T=a/9*5,C=a,x=a+l;C<x;C+=9,T+=5)T>=_&&(XU(c=u[h++],1),_=c.vfOffset),d.set(NU,C+5);a+=l,PU+=MU,FU+=OU,MU=0,OU=0}}var w=FU-VU;UU&&w>0&&gU._requestDrawData(zU,UU,VU,w)}}}(t._curFrame);else{YU(e,1,i);var n=t._debugDraw;if(t.debugBones&&n){n.clear(),n.lineWidth=5,n.strokeColor=EU,n.fillColor=BU;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=RU)}}}WU.getMeshBuffer(dU.chunk.bufferId).setDirty(),t.attachUtil._syncAttachedNode(),gU=void 0}}(t)},updateColor:function(t){t&&(gU=t).markForUpdateRenderData()}};function YU(t,e,i){var r=dU;mU=r.chunk.vb,pU=r.indices;for(var n,s,a,o,l,h,u=t._slots,_=0,f=u.length;_<f;_++)if(o=(l=u[_])._color,l._visible&&l._displayData)if(i?l._mulMat(l._worldMatrix,i,l._matrix):c.copy(l._worldMatrix,l._matrix),l.childArmature)YU(l.childArmature,o.a/255,l._worldMatrix);else if(n=HU(l.getTexture(),l._blendMode)){zU||(zU=n);var d=l.getTexture();if(fU||n.hash!==zU.hash||d&&UU!==d){fU=!1;var p=FU-VU;p>0&&(gU._requestDrawData(zU,UU,VU,p),VU=FU),UU=d,zU=n}XU(o,e),GU.set(l._worldMatrix),s=l._localVertices,MU=s.length/4,DU=9*MU,a=l._indices,OU=a.length;var m=!1;if(PU+MU>LU&&(LU=PU+MU,m=!0),FU+OU>kU&&(kU=FU+OU,m=!0),m){var g=pU,y=r.chunk.vertexOffset;r.resizeAndCopy(LU,kU>r.indexCount?kU:r.indexCount),mU=r.chunk.vb,kU>pU.length&&(pU=r.indices=new Uint16Array(kU));for(var v=r.chunk.vertexOffset-y,b=0;b<FU;++b)pU[b]=g[b]+v}SU=GU.m00,AU=GU.m04,TU=GU.m12,CU=GU.m01,xU=GU.m05,wU=GU.m13;for(var S=0,A=s.length,T=IU;S<A;T+=9)yU=s[S++],vU=s[S++],mU[T]=yU*SU+vU*AU+TU,mU[T+1]=yU*CU+vU*xU+wU,mU[T+3]=s[S++],mU[T+4]=s[S++],mU.set(NU,T+5);for(var C=r.chunk.vertexOffset,x=0,w=a.length,E=FU;x<w;x++,E++)pU[E]=PU+a[x]+C;IU+=DU,PU+=MU,FU+=OU,MU=0,OU=0}h=FU-VU,UU&&h>0&&(gU._requestDrawData(zU,UU,VU,h),VU=FU),gU.maxIndexCount<kU&&(gU.maxIndexCount=kU),gU.maxVertexCount<LU&&(gU.maxVertexCount=LU)}Er.internal.DragonBonesAssembler=jU;var qU,KU,JU,ZU={getAssembler:function(){return jU}};oU.Assembler=ZU,Dr(oU.prototype,"ArmatureDisplay",[{name:"_enableBatch",suggest:"Not support batch render mode"}]),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"}(qU||(qU={})),function(t){t[t.Frame=0]="Frame",t[t.Sound=1]="Sound"}(KU||(KU={})),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"}(JU||(JU={})),t("dragonBones",Object.freeze({__proto__:null,get ExtensionType(){return qU},get EventType(){return KU},get AnimationFadeOutMode(){return JU},CCFactory:RG,CCSlot:EG,CCTextureAtlasData:xG,CCTextureData:wG,CCArmatureDisplay:BG,AnimationCache:HG,ArmatureCache:XG,DragonBonesAsset:tz,DragonBonesAtlasAsset:iz,timeScale:1,get AnimationCacheMode(){return eU},DragonBoneSocket:aU,ArmatureDisplay:oU,AttachUtil:rU,simpleDragonBoneAssembler:ZU,DragonBones:JV,BaseObject:ZV,Matrix:QV,Transform:$V,ColorTransform:tN,Point:eN,Rectangle:iN,UserData:rN,ActionData:nN,DragonBonesData:sN,ArmatureData:aN,BoneData:oN,SurfaceData:lN,SlotData:hN,ConstraintData:uN,IKConstraintData:cN,PathConstraintData:_N,CanvasData:fN,SkinData:dN,VerticesData:pN,DisplayData:mN,ImageDisplayData:gN,ArmatureDisplayData:yN,MeshDisplayData:vN,BoundingBoxDisplayData:bN,PathDisplayData:SN,WeightData:AN,BoundingBoxData:TN,RectangleBoundingBoxData:CN,EllipseBoundingBoxData:xN,PolygonBoundingBoxData:wN,AnimationData:EN,TimelineData:BN,AnimationConfig:RN,TextureAtlasData:DN,TextureData:MN,DeformVertices:PN,Armature:IN,TransformObject:ON,Bone:FN,Surface:LN,Slot:kN,Constraint:VN,IKConstraint:NN,PathConstraint:GN,WorldClock:zN,Animation:UN,AnimationState:HN,BonePose:XN,BlendState:WN,TimelineState:jN,TweenTimelineState:YN,BoneTimelineState:qN,SlotTimelineState:KN,ConstraintTimelineState:JN,ActionTimelineState:ZN,ZOrderTimelineState:QN,BoneAllTimelineState:$N,BoneTranslateTimelineState:tG,BoneRotateTimelineState:eG,BoneScaleTimelineState:iG,SurfaceTimelineState:rG,SlotDislayTimelineState:nG,SlotColorTimelineState:sG,DeformTimelineState:aG,IKConstraintTimelineState:oG,AnimationTimelineState:lG,EventObject:hG,DataParser:uG,ObjectDataParser:cG,ActionFrame:_G,BinaryDataParser:fG,BaseFactory:dG,BuildArmaturePackage:pG,BinaryOffset:mG,ArmatureType:gG,BoneType:yG,DisplayType:vG,BoundingBoxType:bG,ActionType:SG,BlendMode:AG,TweenType:TG,TimelineType:CG}));var QU,$U=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}on(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})},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&We){var i=this._buffers[e];i&&(t[e].gpuBuffer=i.gpuBuffer||i.gpuBufferView)}else t[e].type&je&&(this._textures[e]&&(t[e].gpuTexture=this._textures[e].gpuTexture),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},Ur(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(j);!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.SRGB_EXT=35904]="SRGB_EXT",t[t.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",t[t.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",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"}(QU||(QU={}));var tH=function(){function t(){}return t.setInstance=function(e){t._instance=e},Ur(t,null,[{key:"instance",get:function(){return t._instance}}]),t}();function eH(t,e){switch(t){case tt.R8:return e.UNSIGNED_BYTE;case tt.R8SN:return e.BYTE;case tt.R8UI:return e.UNSIGNED_BYTE;case tt.R8I:return e.BYTE;case tt.R16F:return QU.HALF_FLOAT_OES;case tt.R16UI:return e.UNSIGNED_SHORT;case tt.R16I:return e.SHORT;case tt.R32F:return e.FLOAT;case tt.R32UI:return e.UNSIGNED_INT;case tt.R32I:return e.INT;case tt.RG8:return e.UNSIGNED_BYTE;case tt.RG8SN:return e.BYTE;case tt.RG8UI:return e.UNSIGNED_BYTE;case tt.RG8I:return e.BYTE;case tt.RG16F:return QU.HALF_FLOAT_OES;case tt.RG16UI:return e.UNSIGNED_SHORT;case tt.RG16I:return e.SHORT;case tt.RG32F:return e.FLOAT;case tt.RG32UI:return e.UNSIGNED_INT;case tt.RG32I:return e.INT;case tt.RGB8:case tt.SRGB8:return e.UNSIGNED_BYTE;case tt.RGB8SN:return e.BYTE;case tt.RGB8UI:return e.UNSIGNED_BYTE;case tt.RGB8I:return e.BYTE;case tt.RGB16F:return QU.HALF_FLOAT_OES;case tt.RGB16UI:return e.UNSIGNED_SHORT;case tt.RGB16I:return e.SHORT;case tt.RGB32F:return e.FLOAT;case tt.RGB32UI:return e.UNSIGNED_INT;case tt.RGB32I:return e.INT;case tt.BGRA8:case tt.RGBA8:case tt.SRGB8_A8:return e.UNSIGNED_BYTE;case tt.RGBA8SN:return e.BYTE;case tt.RGBA8UI:return e.UNSIGNED_BYTE;case tt.RGBA8I:return e.BYTE;case tt.RGBA16F:return QU.HALF_FLOAT_OES;case tt.RGBA16UI:return e.UNSIGNED_SHORT;case tt.RGBA16I:return e.SHORT;case tt.RGBA32F:return e.FLOAT;case tt.RGBA32UI:return e.UNSIGNED_INT;case tt.RGBA32I:return e.INT;case tt.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case tt.R11G11B10F:return e.FLOAT;case tt.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case tt.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case tt.RGB10A2:return e.UNSIGNED_BYTE;case tt.RGB10A2UI:return e.UNSIGNED_INT;case tt.RGB9E5:return e.UNSIGNED_BYTE;case tt.DEPTH:return e.UNSIGNED_INT;case tt.DEPTH_STENCIL:return QU.UNSIGNED_INT_24_8_WEBGL;case tt.BC1:case tt.BC1_SRGB:case tt.BC2:case tt.BC2_SRGB:case tt.BC3:case tt.BC3_SRGB:case tt.BC4:return e.UNSIGNED_BYTE;case tt.BC4_SNORM:return e.BYTE;case tt.BC5:return e.UNSIGNED_BYTE;case tt.BC5_SNORM:return e.BYTE;case tt.BC6H_SF16:case tt.BC6H_UF16:return e.FLOAT;case tt.BC7:case tt.BC7_SRGB:case tt.ETC_RGB8:case tt.ETC2_RGB8:case tt.ETC2_SRGB8:case tt.ETC2_RGB8_A1:case tt.ETC2_SRGB8_A1:case tt.EAC_R11:return e.UNSIGNED_BYTE;case tt.EAC_R11SN:return e.BYTE;case tt.EAC_RG11:return e.UNSIGNED_BYTE;case tt.EAC_RG11SN:return e.BYTE;case tt.PVRTC_RGB2:case tt.PVRTC_RGBA2:case tt.PVRTC_RGB4:case tt.PVRTC_RGBA4:case tt.PVRTC2_2BPP:case tt.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case tt.ASTC_RGBA_4X4:case tt.ASTC_RGBA_5X4:case tt.ASTC_RGBA_5X5:case tt.ASTC_RGBA_6X5:case tt.ASTC_RGBA_6X6:case tt.ASTC_RGBA_8X5:case tt.ASTC_RGBA_8X6:case tt.ASTC_RGBA_8X8:case tt.ASTC_RGBA_10X5:case tt.ASTC_RGBA_10X6:case tt.ASTC_RGBA_10X8:case tt.ASTC_RGBA_10X10:case tt.ASTC_RGBA_12X10:case tt.ASTC_RGBA_12X12:case tt.ASTC_SRGBA_4X4:case tt.ASTC_SRGBA_5X4:case tt.ASTC_SRGBA_5X5:case tt.ASTC_SRGBA_6X5:case tt.ASTC_SRGBA_6X6:case tt.ASTC_SRGBA_8X5:case tt.ASTC_SRGBA_8X6:case tt.ASTC_SRGBA_8X8:case tt.ASTC_SRGBA_10X5:case tt.ASTC_SRGBA_10X6:case tt.ASTC_SRGBA_10X8:case tt.ASTC_SRGBA_10X10:case tt.ASTC_SRGBA_12X10:case tt.ASTC_SRGBA_12X12:default:return e.UNSIGNED_BYTE}}function iH(t,e){switch(t){case it.BOOL:return e.BOOL;case it.BOOL2:return e.BOOL_VEC2;case it.BOOL3:return e.BOOL_VEC3;case it.BOOL4:return e.BOOL_VEC4;case it.INT:return e.INT;case it.INT2:return e.INT_VEC2;case it.INT3:return e.INT_VEC3;case it.INT4:return e.INT_VEC4;case it.UINT:return e.UNSIGNED_INT;case it.FLOAT:return e.FLOAT;case it.FLOAT2:return e.FLOAT_VEC2;case it.FLOAT3:return e.FLOAT_VEC3;case it.FLOAT4:return e.FLOAT_VEC4;case it.MAT2:return e.FLOAT_MAT2;case it.MAT3:return e.FLOAT_MAT3;case it.MAT4:return e.FLOAT_MAT4;case it.SAMPLER2D:return e.SAMPLER_2D;case it.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),it.UNKNOWN}}function rH(t){switch(t){case it.BOOL:case it.BOOL2:case it.BOOL3:case it.BOOL4:case it.INT:case it.INT2:case it.INT3:case it.INT4:case it.UINT:return Int32Array;case it.FLOAT:case it.FLOAT2:case it.FLOAT3:case it.FLOAT4:case it.MAT2:case it.MAT3:case it.MAT4:return Float32Array;default:return console.error("Unsupported GLType, convert to TypedArrayConstructor failed."),Float32Array}}function nH(t,e){switch(t){case e.BOOL:return it.BOOL;case e.BOOL_VEC2:return it.BOOL2;case e.BOOL_VEC3:return it.BOOL3;case e.BOOL_VEC4:return it.BOOL4;case e.INT:return it.INT;case e.INT_VEC2:return it.INT2;case e.INT_VEC3:return it.INT3;case e.INT_VEC4:return it.INT4;case e.UNSIGNED_INT:return it.UINT;case e.FLOAT:return it.FLOAT;case e.FLOAT_VEC2:return it.FLOAT2;case e.FLOAT_VEC3:return it.FLOAT3;case e.FLOAT_VEC4:return it.FLOAT4;case e.FLOAT_MAT2:return it.MAT2;case e.FLOAT_MAT3:return it.MAT3;case e.FLOAT_MAT4:return it.MAT4;case e.SAMPLER_2D:return it.SAMPLER2D;case e.SAMPLER_CUBE:return it.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),it.UNKNOWN}}function sH(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 aH(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}}tH._instance=null;var oH,lH=[512,513,514,515,516,517,518,519],hH=[0,7680,7681,7682,7683,5386,34055,34056],uH=[32774,32778,32779,32775,32776],cH=[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"}(oH||(oH={}));var _H=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},fH=function(t){function e(){var e;return(e=t.call(this,oH.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new Ht,e.clearFlag=Lt.NONE,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return on(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(_H),dH=function(t){function e(){var e;return(e=t.call(this,oH.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.dynamicStates=new ze,e}return on(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuDescriptorSets.length=0,this.gpuInputAssembler=null,this.dynamicOffsets.length=0},e}(_H),pH=function(t){function e(){var e;return(e=t.call(this,oH.DRAW)||this).drawInfo=new re,e}return on(e,t),e.prototype.clear=function(){},e}(_H),mH=function(t){function e(){var e;return(e=t.call(this,oH.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return on(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(_H),gH=function(t){function e(){var e;return(e=t.call(this,oH.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return on(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(_H),yH=function(){function t(){this.cmds=new W(1),this.beginRenderPassCmds=new W(1),this.bindStatesCmds=new W(1),this.drawCmds=new W(1),this.updateBufferCmds=new W(1),this.copyBufferToTextureCmds=new W(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 vH(t,e,i,r,n){if(e.usage&rt.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&rt.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;a<s.length;++a)e.indirects.setDrawInfo(r+a,s[a])}else{var o=i,l=t.gl,h=t.stateCache;switch(e.glTarget){case l.ARRAY_BUFFER:t.extensions.useVAO&&h.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),h.glVAO=null),bH.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer);break;case l.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&h.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),h.glVAO=null),bH.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer);break;default:return void console.error("Unsupported BufferType, update buffer failed.")}n===o.byteLength?l.bufferSubData(e.glTarget,r,o):l.bufferSubData(e.glTarget,r,o.slice(0,n))}}var bH={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0},SH=new Ht;function AH(t,e,i,r,n,s,a){var o=t.gl,l=t.stateCache,h=0;if(i&&(SH.x=r.x<<i.lodLevel,SH.y=r.y<<i.lodLevel,SH.width=r.width<<i.lodLevel,SH.height=r.height<<i.lodLevel),i&&e){l.glFramebuffer!==i.glFramebuffer&&(o.bindFramebuffer(o.FRAMEBUFFER,i.glFramebuffer),l.glFramebuffer=i.glFramebuffer),l.viewport.left===SH.x&&l.viewport.top===SH.y&&l.viewport.width===SH.width&&l.viewport.height===SH.height||(o.viewport(SH.x,SH.y,SH.width,SH.height),l.viewport.left=SH.x,l.viewport.top=SH.y,l.viewport.width=SH.width,l.viewport.height=SH.height),l.scissorRect.x===SH.x&&l.scissorRect.y===SH.y&&l.scissorRect.width===SH.width&&l.scissorRect.height===SH.height||(o.scissor(SH.x,SH.y,SH.width,SH.height),l.scissorRect.x=SH.x,l.scissorRect.y=SH.y,l.scissorRect.width=SH.width,l.scissorRect.height=SH.height);var u=n.length;t.extensions.WEBGL_draw_buffers||(u=1);for(var c=0;c<u;++c){var _=e.colorAttachments[c];if(_.format!==tt.UNKNOWN)switch(_.loadOp){case St.LOAD:break;case St.CLEAR:l.bs.targets[0].blendColorMask!==vt.ALL&&o.colorMask(!0,!0,!0,!0);var f=n[0];o.clearColor(f.x,f.y,f.z,f.w),h|=o.COLOR_BUFFER_BIT;break;case St.DISCARD:}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==tt.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case St.LOAD:break;case St.CLEAR:l.dss.depthWrite||o.depthMask(!0),o.clearDepth(s),h|=o.DEPTH_BUFFER_BIT;break;case St.DISCARD:}if(Xe[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case St.LOAD:break;case St.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 St.DISCARD:}}if(h&&o.clear(h),h&o.COLOR_BUFFER_BIT){var d=l.bs.targets[0].blendColorMask;if(d!==vt.ALL){var p=(d&vt.R)!==vt.NONE,m=(d&vt.G)!==vt.NONE,g=(d&vt.B)!==vt.NONE,y=(d&vt.A)!==vt.NONE;o.colorMask(p,m,g,y)}}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 TH(t,e,i,r,n,s){var a,o,l,h=t.gl,u=t.stateCache,c=e&&e.gpuShader,_=!1;if(e&&bH.gpuPipelineState!==e){if(bH.gpuPipelineState=e,bH.glPrimitive=e.glPrimitive,e.gpuShader){var f=e.gpuShader.glProgram;u.glProgram!==f&&(h.useProgram(f),u.glProgram=f,_=!0)}var d=e.rs;if(d){if(u.rs.cullMode!==d.cullMode){switch(d.cullMode){case Rt.NONE:h.disable(h.CULL_FACE);break;case Rt.FRONT:h.enable(h.CULL_FACE),h.cullFace(h.FRONT);break;case Rt.BACK:h.enable(h.CULL_FACE),h.cullFace(h.BACK)}u.rs.cullMode=d.cullMode}var p=d.isFrontFaceCCW;u.rs.isFrontFaceCCW!==p&&(h.frontFace(p?h.CCW:h.CW),u.rs.isFrontFaceCCW=p),u.rs.depthBias===d.depthBias&&u.rs.depthBiasSlop===d.depthBiasSlop||(h.polygonOffset(d.depthBias,d.depthBiasSlop),u.rs.depthBias=d.depthBias,u.rs.depthBiasSlop=d.depthBiasSlop),u.rs.lineWidth!==d.lineWidth&&(h.lineWidth(d.lineWidth),u.rs.lineWidth=d.lineWidth)}var m=e.dss;m&&(u.dss.depthTest!==m.depthTest&&(m.depthTest?h.enable(h.DEPTH_TEST):h.disable(h.DEPTH_TEST),u.dss.depthTest=m.depthTest),u.dss.depthWrite!==m.depthWrite&&(h.depthMask(m.depthWrite),u.dss.depthWrite=m.depthWrite),u.dss.depthFunc!==m.depthFunc&&(h.depthFunc(lH[m.depthFunc]),u.dss.depthFunc=m.depthFunc),u.dss.stencilTestFront===m.stencilTestFront&&u.dss.stencilTestBack===m.stencilTestBack||(m.stencilTestFront||m.stencilTestBack?h.enable(h.STENCIL_TEST):h.disable(h.STENCIL_TEST),u.dss.stencilTestFront=m.stencilTestFront,u.dss.stencilTestBack=m.stencilTestBack),u.dss.stencilFuncFront===m.stencilFuncFront&&u.dss.stencilRefFront===m.stencilRefFront&&u.dss.stencilReadMaskFront===m.stencilReadMaskFront||(h.stencilFuncSeparate(h.FRONT,lH[m.stencilFuncFront],m.stencilRefFront,m.stencilReadMaskFront),u.dss.stencilFuncFront=m.stencilFuncFront,u.dss.stencilRefFront=m.stencilRefFront,u.dss.stencilReadMaskFront=m.stencilReadMaskFront),u.dss.stencilFailOpFront===m.stencilFailOpFront&&u.dss.stencilZFailOpFront===m.stencilZFailOpFront&&u.dss.stencilPassOpFront===m.stencilPassOpFront||(h.stencilOpSeparate(h.FRONT,hH[m.stencilFailOpFront],hH[m.stencilZFailOpFront],hH[m.stencilPassOpFront]),u.dss.stencilFailOpFront=m.stencilFailOpFront,u.dss.stencilZFailOpFront=m.stencilZFailOpFront,u.dss.stencilPassOpFront=m.stencilPassOpFront),u.dss.stencilWriteMaskFront!==m.stencilWriteMaskFront&&(h.stencilMaskSeparate(h.FRONT,m.stencilWriteMaskFront),u.dss.stencilWriteMaskFront=m.stencilWriteMaskFront),u.dss.stencilFuncBack===m.stencilFuncBack&&u.dss.stencilRefBack===m.stencilRefBack&&u.dss.stencilReadMaskBack===m.stencilReadMaskBack||(h.stencilFuncSeparate(h.BACK,lH[m.stencilFuncBack],m.stencilRefBack,m.stencilReadMaskBack),u.dss.stencilFuncBack=m.stencilFuncBack,u.dss.stencilRefBack=m.stencilRefBack,u.dss.stencilReadMaskBack=m.stencilReadMaskBack),u.dss.stencilFailOpBack===m.stencilFailOpBack&&u.dss.stencilZFailOpBack===m.stencilZFailOpBack&&u.dss.stencilPassOpBack===m.stencilPassOpBack||(h.stencilOpSeparate(h.BACK,hH[m.stencilFailOpBack],hH[m.stencilZFailOpBack],hH[m.stencilPassOpBack]),u.dss.stencilFailOpBack=m.stencilFailOpBack,u.dss.stencilZFailOpBack=m.stencilZFailOpBack,u.dss.stencilPassOpBack=m.stencilPassOpBack),u.dss.stencilWriteMaskBack!==m.stencilWriteMaskBack&&(h.stencilMaskSeparate(h.BACK,m.stencilWriteMaskBack),u.dss.stencilWriteMaskBack=m.stencilWriteMaskBack));var g=e.bs;if(g){u.bs.isA2C!==g.isA2C&&(g.isA2C?h.enable(h.SAMPLE_ALPHA_TO_COVERAGE):h.disable(h.SAMPLE_ALPHA_TO_COVERAGE),u.bs.isA2C=g.isA2C),u.bs.blendColor.x===g.blendColor.x&&u.bs.blendColor.y===g.blendColor.y&&u.bs.blendColor.z===g.blendColor.z&&u.bs.blendColor.w===g.blendColor.w||(h.blendColor(g.blendColor.x,g.blendColor.y,g.blendColor.z,g.blendColor.w),u.bs.blendColor.x=g.blendColor.x,u.bs.blendColor.y=g.blendColor.y,u.bs.blendColor.z=g.blendColor.z,u.bs.blendColor.w=g.blendColor.w);var y=g.targets[0],v=u.bs.targets[0];v.blend!==y.blend&&(y.blend?h.enable(h.BLEND):h.disable(h.BLEND),v.blend=y.blend),v.blendEq===y.blendEq&&v.blendAlphaEq===y.blendAlphaEq||(h.blendEquationSeparate(uH[y.blendEq],uH[y.blendAlphaEq]),v.blendEq=y.blendEq,v.blendAlphaEq=y.blendAlphaEq),v.blendSrc===y.blendSrc&&v.blendDst===y.blendDst&&v.blendSrcAlpha===y.blendSrcAlpha&&v.blendDstAlpha===y.blendDstAlpha||(h.blendFuncSeparate(cH[y.blendSrc],cH[y.blendDst],cH[y.blendSrcAlpha],cH[y.blendDstAlpha]),v.blendSrc=y.blendSrc,v.blendDst=y.blendDst,v.blendSrcAlpha=y.blendSrcAlpha,v.blendDstAlpha=y.blendDstAlpha),v.blendColorMask!==y.blendColorMask&&(h.colorMask((y.blendColorMask&vt.R)!==vt.NONE,(y.blendColorMask&vt.G)!==vt.NONE,(y.blendColorMask&vt.B)!==vt.NONE,(y.blendColorMask&vt.A)!==vt.NONE),v.blendColorMask=y.blendColorMask)}}if(e&&e.gpuPipelineLayout&&c){for(var b=c.glBlocks.length,S=e.gpuPipelineLayout.dynamicOffsetIndices,A=0;A<b;A++){var T=c.glBlocks[A],C=r[T.set],x=C&&C.descriptorIndices[T.binding],w=x>=0&&C.gpuDescriptors[x],E=null,B=0;if(w&&w.gpuBuffer){var R=w.gpuBuffer,D=S[T.set],M=D&&D[T.binding];M>=0&&(B=n[M]),"vf32"in R?E=R.vf32:(B+=R.offset,E=R.gpuBuffer.vf32),B>>=2}if(E)for(var P=T.glActiveUniforms.length,I=0;I<P;I++){var O=T.glActiveUniforms[I];switch(O.glType){case h.BOOL:case h.INT:for(var F=0;F<O.array.length;++F){var L=O.offset+B+F;if(E[L]!==O.array[F]){for(var k=F,V=L;k<O.array.length;++k,++V)O.array[k]=E[V];h.uniform1iv(O.glLoc,O.array);break}}break;case h.BOOL_VEC2:case h.INT_VEC2:for(var N=0;N<O.array.length;++N){var G=O.offset+B+N;if(E[G]!==O.array[N]){for(var z=N,U=G;z<O.array.length;++z,++U)O.array[z]=E[U];h.uniform2iv(O.glLoc,O.array);break}}break;case h.BOOL_VEC3:case h.INT_VEC3:for(var H=0;H<O.array.length;++H){var X=O.offset+B+H;if(E[X]!==O.array[H]){for(var W=H,j=X;W<O.array.length;++W,++j)O.array[W]=E[j];h.uniform3iv(O.glLoc,O.array);break}}break;case h.BOOL_VEC4:case h.INT_VEC4:for(var Y=0;Y<O.array.length;++Y){var q=O.offset+B+Y;if(E[q]!==O.array[Y]){for(var K=Y,J=q;K<O.array.length;++K,++J)O.array[K]=E[J];h.uniform4iv(O.glLoc,O.array);break}}break;case h.FLOAT:for(var Z=0;Z<O.array.length;++Z){var Q=O.offset+B+Z;if(E[Q]!==O.array[Z]){for(var $=Z,tt=Q;$<O.array.length;++$,++tt)O.array[$]=E[tt];h.uniform1fv(O.glLoc,O.array);break}}break;case h.FLOAT_VEC2:for(var et=0;et<O.array.length;++et){var it=O.offset+B+et;if(E[it]!==O.array[et]){for(var rt=et,nt=it;rt<O.array.length;++rt,++nt)O.array[rt]=E[nt];h.uniform2fv(O.glLoc,O.array);break}}break;case h.FLOAT_VEC3:for(var st=0;st<O.array.length;++st){var at=O.offset+B+st;if(E[at]!==O.array[st]){for(var ot=st,lt=at;ot<O.array.length;++ot,++lt)O.array[ot]=E[lt];h.uniform3fv(O.glLoc,O.array);break}}break;case h.FLOAT_VEC4:for(var ht=0;ht<O.array.length;++ht){var ut=O.offset+B+ht;if(E[ut]!==O.array[ht]){for(var ct=ht,_t=ut;ct<O.array.length;++ct,++_t)O.array[ct]=E[_t];h.uniform4fv(O.glLoc,O.array);break}}break;case h.FLOAT_MAT2:for(var ft=0;ft<O.array.length;++ft){var dt=O.offset+B+ft;if(E[dt]!==O.array[ft]){for(var pt=ft,mt=dt;pt<O.array.length;++pt,++mt)O.array[pt]=E[mt];h.uniformMatrix2fv(O.glLoc,!1,O.array);break}}break;case h.FLOAT_MAT3:for(var gt=0;gt<O.array.length;++gt){var yt=O.offset+B+gt;if(E[yt]!==O.array[gt]){for(var bt=gt,St=yt;bt<O.array.length;++bt,++St)O.array[bt]=E[St];h.uniformMatrix3fv(O.glLoc,!1,O.array);break}}break;case h.FLOAT_MAT4:for(var At=0;At<O.array.length;++At){var Tt=O.offset+B+At;if(E[Tt]!==O.array[At]){for(var Ct=At,xt=Tt;Ct<O.array.length;++Ct,++xt)O.array[Ct]=E[xt];h.uniformMatrix4fv(O.glLoc,!1,O.array);break}}}}else Ja("Buffer binding '"+T.name+"' at set "+T.set+" binding "+T.binding+" is not bounded")}for(var wt=c.glSamplerTextures.length,Et=0;Et<wt;Et++)for(var Bt=c.glSamplerTextures[Et],Mt=r[Bt.set],Pt=Mt&&Mt.descriptorIndices[Bt.binding],It=Pt>=0&&Mt.gpuDescriptors[Pt],Ot=Bt.units.length,Ft=0;Ft<Ot;Ft++){var Lt=Bt.units[Ft];if(It&&It.gpuSampler){if(It.gpuTexture&&It.gpuTexture.size>0){var kt=It.gpuTexture,Vt=u.glTexUnits[Lt];Vt.glTexture!==kt.glTexture&&(u.texUnit!==Lt&&(h.activeTexture(h.TEXTURE0+Lt),u.texUnit=Lt),kt.glTexture?h.bindTexture(kt.glTarget,kt.glTexture):h.bindTexture(kt.glTarget,t.nullTex2D.gpuTexture.glTexture),Vt.glTexture=kt.glTexture);var Nt=It.gpuSampler;kt.isPowerOf2?(a=Nt.glWrapS,o=Nt.glWrapT):(a=h.CLAMP_TO_EDGE,o=h.CLAMP_TO_EDGE),l=kt.isPowerOf2?kt.mipLevel<=1&&(Nt.glMinFilter===h.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===h.LINEAR_MIPMAP_LINEAR)?h.LINEAR:Nt.glMinFilter:Nt.glMinFilter===h.LINEAR||Nt.glMinFilter===h.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===h.LINEAR_MIPMAP_LINEAR?h.LINEAR:h.NEAREST,kt.glWrapS!==a&&(u.texUnit!==Lt&&(h.activeTexture(h.TEXTURE0+Lt),u.texUnit=Lt),h.texParameteri(kt.glTarget,h.TEXTURE_WRAP_S,a),kt.glWrapS=a),kt.glWrapT!==o&&(u.texUnit!==Lt&&(h.activeTexture(h.TEXTURE0+Lt),u.texUnit=Lt),h.texParameteri(kt.glTarget,h.TEXTURE_WRAP_T,o),kt.glWrapT=o),kt.glMinFilter!==l&&(u.texUnit!==Lt&&(h.activeTexture(h.TEXTURE0+Lt),u.texUnit=Lt),h.texParameteri(kt.glTarget,h.TEXTURE_MIN_FILTER,l),kt.glMinFilter=l),kt.glMagFilter!==Nt.glMagFilter&&(u.texUnit!==Lt&&(h.activeTexture(h.TEXTURE0+Lt),u.texUnit=Lt),h.texParameteri(kt.glTarget,h.TEXTURE_MAG_FILTER,Nt.glMagFilter),kt.glMagFilter=Nt.glMagFilter)}It=Mt.gpuDescriptors[++Pt]}else Ja("Sampler binding '"+Bt.name+"' at set "+Bt.set+" binding "+Bt.binding+" index "+Ft+" is not bounded")}}if(i&&c&&(_||bH.gpuInputAssembler!==i)){bH.gpuInputAssembler=i;var Gt=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var zt=t.extensions.OES_vertex_array_object,Ut=i.glVAOs.get(c.glProgram);if(!Ut){var Ht;Ut=zt.createVertexArrayOES(),i.glVAOs.set(c.glProgram,Ut),zt.bindVertexArrayOES(Ut),h.bindBuffer(h.ARRAY_BUFFER,null),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),u.glArrayBuffer=null,u.glElementArrayBuffer=null;for(var Xt=c.glInputs.length,Wt=0;Wt<Xt;Wt++){var jt=c.glInputs[Wt];Ht=null;for(var Yt=i.glAttribs.length,qt=0;qt<Yt;qt++){var Kt=i.glAttribs[qt];if(Kt.name===jt.name){Ht=Kt;break}}if(Ht){u.glArrayBuffer!==Ht.glBuffer&&(h.bindBuffer(h.ARRAY_BUFFER,Ht.glBuffer),u.glArrayBuffer=Ht.glBuffer);for(var Jt=0;Jt<Ht.componentCount;++Jt){var Zt=jt.glLoc+Jt,Qt=Ht.offset+Ht.size*Jt;h.enableVertexAttribArray(Zt),u.glCurrentAttribLocs[Zt]=!0,h.vertexAttribPointer(Zt,Ht.count,Ht.glType,Ht.isNormalized,Ht.stride,Qt),Gt&&Gt.vertexAttribDivisorANGLE(Zt,Ht.isInstanced?1:0)}}}var $t=i.gpuIndexBuffer;$t&&h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,$t.glBuffer),zt.bindVertexArrayOES(null),h.bindBuffer(h.ARRAY_BUFFER,null),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),u.glArrayBuffer=null,u.glElementArrayBuffer=null}u.glVAO!==Ut&&(zt.bindVertexArrayOES(Ut),u.glVAO=Ut)}else{for(var te=0;te<t.capabilities.maxVertexAttributes;++te)u.glCurrentAttribLocs[te]=!1;for(var ee=c.glInputs.length,ie=0;ie<ee;ie++){for(var re=c.glInputs[ie],ne=null,se=i.glAttribs.length,ae=0;ae<se;ae++){var oe=i.glAttribs[ae];if(oe.name===re.name){ne=oe;break}}if(ne){u.glArrayBuffer!==ne.glBuffer&&(h.bindBuffer(h.ARRAY_BUFFER,ne.glBuffer),u.glArrayBuffer=ne.glBuffer);for(var le=0;le<ne.componentCount;++le){var he=re.glLoc+le,ue=ne.offset+ne.size*le;!u.glEnabledAttribLocs[he]&&he>=0&&(h.enableVertexAttribArray(he),u.glEnabledAttribLocs[he]=!0),u.glCurrentAttribLocs[he]=!0,h.vertexAttribPointer(he,ne.count,ne.glType,ne.isNormalized,ne.stride,ue),Gt&&Gt.vertexAttribDivisorANGLE(he,ne.isInstanced?1:0)}}}var ce=i.gpuIndexBuffer;ce&&u.glElementArrayBuffer!==ce.glBuffer&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,ce.glBuffer),u.glElementArrayBuffer=ce.glBuffer);for(var _e=0;_e<t.capabilities.maxVertexAttributes;++_e)u.glEnabledAttribLocs[_e]!==u.glCurrentAttribLocs[_e]&&(h.disableVertexAttribArray(_e),u.glEnabledAttribLocs[_e]=!1)}}if(e&&e.dynamicStates.length)for(var fe=e.dynamicStates.length,de=0;de<fe;de++)switch(e.dynamicStates[de]){case Dt.LINE_WIDTH:u.rs.lineWidth!==s.lineWidth&&(h.lineWidth(s.lineWidth),u.rs.lineWidth=s.lineWidth);break;case Dt.DEPTH_BIAS:u.rs.depthBias===s.depthBiasConstant&&u.rs.depthBiasSlop===s.depthBiasSlope||(h.polygonOffset(s.depthBiasConstant,s.depthBiasSlope),u.rs.depthBias=s.depthBiasConstant,u.rs.depthBiasSlop=s.depthBiasSlope);break;case Dt.BLEND_CONSTANTS:var pe=s.blendConstant;u.bs.blendColor.x===pe.x&&u.bs.blendColor.y===pe.y&&u.bs.blendColor.z===pe.z&&u.bs.blendColor.w===pe.w||(h.blendColor(pe.x,pe.y,pe.z,pe.w),u.bs.blendColor.copy(pe));break;case Dt.STENCIL_WRITE_MASK:var me=s.stencilStatesFront,ge=s.stencilStatesBack;u.dss.stencilWriteMaskFront!==me.writeMask&&(h.stencilMaskSeparate(h.FRONT,me.writeMask),u.dss.stencilWriteMaskFront=me.writeMask),u.dss.stencilWriteMaskBack!==ge.writeMask&&(h.stencilMaskSeparate(h.BACK,ge.writeMask),u.dss.stencilWriteMaskBack=ge.writeMask);break;case Dt.STENCIL_COMPARE_MASK:var ye=s.stencilStatesFront,ve=s.stencilStatesBack;u.dss.stencilRefFront===ye.reference&&u.dss.stencilReadMaskFront===ye.compareMask||(h.stencilFuncSeparate(h.FRONT,lH[u.dss.stencilFuncFront],ye.reference,ye.compareMask),u.dss.stencilRefFront=ye.reference,u.dss.stencilReadMaskFront=ye.compareMask),u.dss.stencilRefBack===ve.reference&&u.dss.stencilReadMaskBack===ve.compareMask||(h.stencilFuncSeparate(h.BACK,lH[u.dss.stencilFuncBack],ve.reference,ve.compareMask),u.dss.stencilRefBack=ve.reference,u.dss.stencilReadMaskBack=ve.compareMask)}}function CH(t,e){var i=t.gl,r=t.extensions,n=r.ANGLE_instanced_arrays,s=r.WEBGL_multi_draw,a=bH.gpuInputAssembler,o=bH.glPrimitive;if(a){var l=a.gpuIndexBuffer;if(a.gpuIndirectBuffer){var h=a.gpuIndirectBuffer.indirects;if(h.drawByIndex){for(var u=0;u<h.drawCount;u++)h.byteOffsets[u]=h.offsets[u]*l.stride;if(s)h.instancedDraw?s.multiDrawElementsInstancedWEBGL(o,h.counts,0,a.glIndexType,h.byteOffsets,0,h.instances,0,h.drawCount):s.multiDrawElementsWEBGL(o,h.counts,0,a.glIndexType,h.byteOffsets,0,h.drawCount);else for(var c=0;c<h.drawCount;c++)h.instances[c]&&n?n.drawElementsInstancedANGLE(o,h.counts[c],a.glIndexType,h.byteOffsets[c],h.instances[c]):i.drawElements(o,h.counts[c],a.glIndexType,h.byteOffsets[c])}else if(s)h.instancedDraw?s.multiDrawArraysInstancedWEBGL(o,h.offsets,0,h.counts,0,h.instances,0,h.drawCount):s.multiDrawArraysWEBGL(o,h.offsets,0,h.counts,0,h.drawCount);else for(var _=0;_<h.drawCount;_++)h.instances[_]&&n?n.drawArraysInstancedANGLE(o,h.offsets[_],h.counts[_],h.instances[_]):i.drawArrays(o,h.offsets[_],h.counts[_])}else if(e.instanceCount&&n)if(l){if(e.indexCount>0){var f=e.firstIndex*l.stride;n.drawElementsInstancedANGLE(o,e.indexCount,a.glIndexType,f,e.instanceCount)}}else e.vertexCount>0&&n.drawArraysInstancedANGLE(o,e.firstVertex,e.vertexCount,e.instanceCount);else if(l){if(e.indexCount>0){var d=e.firstIndex*l.stride;i.drawElements(o,e.indexCount,a.glIndexType,d)}}else e.vertexCount>0&&i.drawArrays(o,e.firstVertex,e.vertexCount)}}var xH=new Array(oH.COUNT);function wH(t,e){xH.fill(0);for(var i=0;i<e.cmds.length;++i){var r=e.cmds.array[i],n=xH[r]++;switch(r){case oH.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[n];AH(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case oH.BIND_STATES:var a=e.bindStatesCmds.array[n];TH(t,a.gpuPipelineState,a.gpuInputAssembler,a.gpuDescriptorSets,a.dynamicOffsets,a.dynamicStates);break;case oH.DRAW:CH(t,e.drawCmds.array[n].drawInfo);break;case oH.UPDATE_BUFFER:var o=e.updateBufferCmds.array[n];vH(t,o.gpuBuffer,o.buffer,o.offset,o.size);break;case oH.COPY_BUFFER_TO_TEXTURE:var l=e.copyBufferToTextureCmds.array[n];RH(t,l.buffers,l.gpuTexture,l.regions)}}}var EH=new Uint8Array(1);function BH(t,e,i,r,n){var s=ti(e).height,a=Je(e,n.width,n.height,n.depth),o=Je(e,r.width,1,1),l=Je(e,r.width,r.height,1),h=Je(e,n.width,1,1),u=$e(Xe[e]);EH.byteLength<a&&(EH=new Uint8Array(a));for(var c=0,_=i,f=0;f<n.depth;f++){_=i+l*f;for(var d=0;d<n.height;d+=s)EH.subarray(c,c+h).set(new Uint8Array(t.buffer,t.byteOffset+_,h)),c+=h,_+=o}return new u(EH.buffer)}function RH(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,l=Xe[i.format],h=$e(l),u=l.isCompressed,c=ti(i.format),_=new Xt,f=new Ut,d=new Xt;switch(i.glTarget){case n.TEXTURE_2D:for(var p=0;p<r.length;p++){var m=r[p],g=m.texSubres.mipLevel;f.x=0===m.texOffset.x?0:ei(m.texOffset.x,c.width),f.y=0===m.texOffset.y?0:ei(m.texOffset.y,c.height),_.width=m.texExtent.width<c.width?m.texExtent.width:ei(m.texExtent.width,c.width),_.height=m.texExtent.height<c.height?m.texExtent.width:ei(m.texExtent.height,c.height),d.width=m.buffStride>0?m.buffStride:_.width,d.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var y,v=m.texExtent.width+f.x===i.width>>g?m.texExtent.width:_.width,b=m.texExtent.height+f.y===i.height>>g?m.texExtent.height:_.height,S=e[a++];y=d.width===_.width&&d.height===_.height?new h(S.buffer,S.byteOffset+m.buffOffset):BH(S,i.format,m.buffOffset,d,_),u?i.glInternalFmt===QU.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?n.compressedTexImage2D(n.TEXTURE_2D,g,i.glInternalFmt,v,b,0,y):n.compressedTexSubImage2D(n.TEXTURE_2D,g,f.x,f.y,v,b,i.glFormat,y):n.texSubImage2D(n.TEXTURE_2D,g,f.x,f.y,v,b,i.glFormat,i.glType,y)}break;case n.TEXTURE_CUBE_MAP:for(var A=0;A<r.length;A++){var T=r[A],C=T.texSubres.mipLevel;f.x=0===T.texOffset.x?0:ei(T.texOffset.x,c.width),f.y=0===T.texOffset.y?0:ei(T.texOffset.y,c.height),_.width=T.texExtent.width<c.width?T.texExtent.width:ei(T.texExtent.width,c.width),_.height=T.texExtent.height<c.height?T.texExtent.width:ei(T.texExtent.height,c.height),d.width=T.buffStride>0?T.buffStride:_.width,d.height=T.buffTexHeight>0?T.buffTexHeight:_.height;var x=T.texExtent.width+f.x===i.width>>C?T.texExtent.width:_.width,w=T.texExtent.height+f.y===i.height>>C?T.texExtent.height:_.height,E=T.texSubres.baseArrayLayer+T.texSubres.layerCount;for(o=T.texSubres.baseArrayLayer;o<E;++o){var B,R=e[a++];B=d.width===_.width&&d.height===_.height?new h(R.buffer,R.byteOffset+T.buffOffset):BH(R,i.format,T.buffOffset,d,_),u?i.glInternalFmt===QU.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,C,i.glInternalFmt,x,w,0,B):n.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,C,f.x,f.y,x,w,i.glFormat,B):n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,C,f.x,f.y,x,w,i.glFormat,i.glType,B)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&ht.GEN_MIPMAP&&n.generateMipmap(i.glTarget)}var DH=function(){function t(){this.counts=void 0,this.offsets=void 0,this.instances=void 0,this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1,this.byteOffsets=void 0,this._capacity=4,this.counts=new Int32Array(this._capacity),this.offsets=new Int32Array(this._capacity),this.instances=new Int32Array(this._capacity),this.byteOffsets=new Int32Array(this._capacity)}var e=t.prototype;return e.clearDraws=function(){this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1},e.setDrawInfo=function(t,e){this._ensureCapacity(t),this.drawByIndex=e.indexCount>0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=Sn(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),r=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),r.set(this.instances),this.counts=e,this.offsets=i,this.instances=r}},t}(),MH=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}on(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&rt.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:new DH,glTarget:0,glBuffer:null},this._usage&rt.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),function(t,e){var i=t.gl,r=t.stateCache,n=e.memUsage&at.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&rt.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.extensions.useVAO&&r.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),bH.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&rt.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&r.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),bH.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&rt.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&rt.INDIRECT||e.usage&rt.TRANSFER_DST||e.usage&rt.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}(tH.instance,this._gpuBuffer),tH.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(function(t,e){var i=t.gl,r=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&r.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),bH.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&r.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),bH.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}(tH.instance,this._gpuBuffer),tH.instance.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=tH.instance,i=this._gpuBuffer,r=e.gl,n=e.stateCache,s=i.memUsage&at.HOST?r.DYNAMIC_DRAW:r.STATIC_DRAW,i.usage&rt.VERTEX?(e.extensions.useVAO&&n.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),bH.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&rt.INDEX?(e.extensions.useVAO&&n.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),bH.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&rt.UNIFORM?i.buffer&&(i.vf32=new Float32Array(i.buffer.buffer)):(i.usage&rt.INDIRECT||i.usage&rt.TRANSFER_DST||i.usage&rt.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),i.glTarget=r.NONE),tH.instance.memoryStatus.bufferSize-=a,tH.instance.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&rt.INDIRECT?0:t.byteLength,vH(tH.instance,this._gpuBuffer,t,0,i))},Ur(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(Y),PH=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new W(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}(),IH=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 PH(fH,1),this.bindStatesCmdPool=new PH(dH,1),this.drawCmdPool=new PH(pH,1),this.updateBufferCmdPool=new PH(mH,1),this.copyBufferToTextureCmdPool=new PH(gH,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}(),OH=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 yH,e._cmdAllocator=new IH,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUInputAssembler=null,e._curGPUDescriptorSets=[],e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new ze,e._isStateInvalied=!1,e}on(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=tH.instance.bindingMappings.blockOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null)},i.destroy=function(){this._cmdAllocator.clearCmds(this.cmdPackage)},i.begin=function(){this._cmdAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0,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._cmdAllocator.beginRenderPassCmdPool.alloc(fH);a.gpuRenderPass=t.gpuRenderPass,a.gpuFramebuffer=e.gpuFramebuffer,a.renderArea.copy(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(oH.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){var n,s=null===(n=this._curGPUPipelineState)||void 0===n?void 0:n.gpuPipelineLayout;if(s){for(var a=this._curDynamicOffsets,o=s.dynamicOffsetOffsets[t],l=0;l<i.length;l++)a[o+l]=i[l];this._isStateInvalied=!0}}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){var e=this._curDynamicStates.viewport;e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height&&e.minDepth===t.minDepth&&e.maxDepth===t.maxDepth||(e.left=t.left,e.top=t.top,e.width=t.width,e.height=t.height,e.minDepth=t.minDepth,e.maxDepth=t.maxDepth,this._isStateInvalied=!0)},i.setScissor=function(t){var e=this._curDynamicStates.scissor;e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,this._isStateInvalied=!0)},i.setLineWidth=function(t){this._curDynamicStates.lineWidth!==t&&(this._curDynamicStates.lineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){var r=this._curDynamicStates;r.depthBiasConstant===t&&r.depthBiasClamp===e&&r.depthBiasSlope===i||(r.depthBiasConstant=t,r.depthBiasClamp=e,r.depthBiasSlope=i,this._isStateInvalied=!0)},i.setBlendConstants=function(t){var e=this._curDynamicStates.blendConstant;e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w||(e.copy(t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){var i=this._curDynamicStates;i.depthMinBounds===t&&i.depthMaxBounds===e||(i.depthMinBounds=t,i.depthMaxBounds=e,this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){var i=this._curDynamicStates.stencilStatesFront,r=this._curDynamicStates.stencilStatesBack;t&Mt.FRONT&&i.writeMask!==e&&(i.writeMask=e,this._isStateInvalied=!0),t&Mt.BACK&&r.writeMask!==e&&(r.writeMask=e,this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){var r=this._curDynamicStates.stencilStatesFront,n=this._curDynamicStates.stencilStatesBack;t&Mt.FRONT&&(r.compareMask===i&&r.reference===e||(r.reference=e,r.compareMask=i,this._isStateInvalied=!0)),t&Mt.BACK&&(n.compareMask===i&&n.reference===e||(n.reference=e,n.compareMask=i,this._isStateInvalied=!0))},i.draw=function(t){if(this._type===Ft.PRIMARY&&this._isInRenderPass||this._type===Ft.SECONDARY){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t,i=this._cmdAllocator.drawCmdPool.alloc(pH);i.drawInfo.copy(e),this.cmdPackage.drawCmds.push(i),this.cmdPackage.cmds.push(oH.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var r=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=r/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(r-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===Ft.PRIMARY&&!this._isInRenderPass||this._type===Ft.SECONDARY){var r=t.gpuBuffer;if(r){var n,s=this._cmdAllocator.updateBufferCmdPool.alloc(mH),a=0;t.usage&rt.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(oH.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===Ft.PRIMARY&&!this._isInRenderPass||this._type===Ft.SECONDARY){var r=e.gpuTexture;if(r){var n=this._cmdAllocator.copyBufferToTextureCmdPool.alloc(gH);n&&(n.gpuTexture=r,n.regions=i,n.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(n),this.cmdPackage.cmds.push(oH.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._cmdAllocator.bindStatesCmdPool.alloc(dH);t&&(t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets),Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets),t.gpuInputAssembler=this._curGPUInputAssembler,t.dynamicStates.copy(this._curDynamicStates),this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(oH.BIND_STATES),this._isStateInvalied=!1)},e}(q),FH=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null;for(var e=0,i=[],r=0;r<t.colorTextures.length;++r){var n=t.colorTextures[r];n&&(i.push(n.gpuTexture),e=n.lodLevel)}var s=null;t.depthStencilTexture&&(s=t.depthStencilTexture.gpuTexture,e=t.depthStencilTexture.lodLevel);var a=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorTextures:i,gpuDepthStencilTexture:s,glFramebuffer:null,isOffscreen:!0,get width(){return this.isOffscreen?a:this.gpuColorTextures[0].width},set width(t){a=t},get height(){return this.isOffscreen?o:this.gpuColorTextures[0].height},set height(t){o=t},lodLevel:e},function(t,e){for(var i=0;i<e.gpuColorTextures.length;++i)if(e.gpuColorTextures[i].isSwapchainTexture)return void(e.isOffscreen=!1);var r=t.gl,n=[],s=r.createFramebuffer();if(s){e.glFramebuffer=s,t.stateCache.glFramebuffer!==e.glFramebuffer&&r.bindFramebuffer(r.FRAMEBUFFER,e.glFramebuffer);for(var a=0;a<e.gpuColorTextures.length;++a){var o=e.gpuColorTextures[a];o&&(o.glTexture?r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,o.glTarget,o.glTexture,0):r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,r.RENDERBUFFER,o.glRenderbuffer),n.push(r.COLOR_ATTACHMENT0+a),e.width=Math.min(e.width,o.width),e.height=Math.min(e.height,o.height))}var l=e.gpuDepthStencilTexture;if(l){var h=Xe[l.format].hasStencil?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;l.glTexture?r.framebufferTexture2D(r.FRAMEBUFFER,h,l.glTarget,l.glTexture,0):r.framebufferRenderbuffer(r.FRAMEBUFFER,h,r.RENDERBUFFER,l.glRenderbuffer),e.width=Math.min(e.width,l.width),e.height=Math.min(e.height,l.height)}t.extensions.WEBGL_draw_buffers&&t.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(n);var u=r.checkFramebufferStatus(r.FRAMEBUFFER);if(u!==r.FRAMEBUFFER_COMPLETE)switch(u){case r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case r.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&r.bindFramebuffer(r.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(tH.instance,this._gpuFramebuffer)},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=tH.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null)},Ur(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(ni),LH=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}on(e,t);var i=e.prototype;return i.initialize=function(t){if(0!==t.vertexBuffers.length){if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._drawInfo.indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._drawInfo.firstIndex=0;else{var e=this._vertexBuffers[0];this._drawInfo.vertexCount=e.size/e.stride,this._drawInfo.firstVertex=0,this._drawInfo.vertexOffset=0}this._drawInfo.instanceCount=0,this._drawInfo.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;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=eH(s.format,i),h=Xe[s.format].size;e.glAttribs[n]={name:s.name,glBuffer:o.glBuffer,glType:l,size:h,count:Xe[s.format].count,stride:o.stride,componentCount:aH(l,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:r[a]},r[a]+=h}}(tH.instance,this._gpuInputAssembler)}else console.error("InputAssemblerInfo.vertexBuffers is null.")},i.destroy=function(){var t=tH.instance;this._gpuInputAssembler&&t.extensions.useVAO&&function(t,e){for(var i=e.glVAOs.values(),r=i.next(),n=t.extensions.OES_vertex_array_object,s=t.stateCache.glVAO;!r.done;)n.deleteVertexArrayOES(r.value),s===r.value&&(n.bindVertexArrayOES(null),s=null),r=i.next();t.stateCache.glVAO=s,e.glVAOs.clear()}(t,this._gpuInputAssembler),this._gpuInputAssembler=null},Ur(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}(si),kH=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}on(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&Ye)for(var _=0;_<c.count;_++)h.push(c.binding)}this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:h,descriptorIndices:a,descriptorCount:e}},i.destroy=function(){this._bindings.length=0},Ur(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(ai),VH=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}on(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=[],s=0;s<this._setLayouts.length;s++){for(var a=this._setLayouts[s],o=a.gpuDescriptorSetLayout.dynamicBindings,l=Array(a.bindingIndices.length).fill(-1),h=0;h<o.length;h++){var u=o[h];l[u]<0&&(l[u]=r+h)}i.push(a.gpuDescriptorSetLayout),e.push(l),n.push(r),r+=o.length}this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:r,dynamicOffsetOffsets:n}},i.destroy=function(){this._setLayouts.length=0},Ur(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(oi),NH=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],GH=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}on(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);this._gpuPipelineState={glPrimitive:NH[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}},i.destroy=function(){this._gpuPipelineState=null},Ur(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(fi),zH=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,r,n,s){AH(tH.instance,t.gpuRenderPass,e.gpuFramebuffer,i,r,n,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t;CH(tH.instance,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var i=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.setViewport=function(t){var e=tH.instance,i=e.stateCache,r=e.gl;i.viewport.left===t.left&&i.viewport.top===t.top&&i.viewport.width===t.width&&i.viewport.height===t.height||(r.viewport(t.left,t.top,t.width,t.height),i.viewport.left=t.left,i.viewport.top=t.top,i.viewport.width=t.width,i.viewport.height=t.height)},i.setScissor=function(t){var e=tH.instance,i=e.stateCache,r=e.gl;i.scissorRect.x===t.x&&i.scissorRect.y===t.y&&i.scissorRect.width===t.width&&i.scissorRect.height===t.height||(r.scissor(t.x,t.y,t.width,t.height),i.scissorRect.x=t.x,i.scissorRect.y=t.y,i.scissorRect.width=t.width,i.scissorRect.height=t.height)},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&rt.INDIRECT?0:e.byteLength,vH(tH.instance,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&&RH(tH.instance,t,r,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var r=t[i];wH(tH.instance,r.cmdPackage),this._numDrawCalls+=r._numDrawCalls,this._numInstances+=r._numInstances,this._numTris+=r._numTris}},i.bindStates=function(){TH(tH.instance,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,this._curDynamicOffsets,this._curDynamicStates),this._isStateInvalied=!1},e}(OH),UH=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type},i.destroy=function(){},i.submit=function(t){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}(di),HH=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,this._subpasses=t.subpasses,this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash()},i.destroy=function(){this._gpuRenderPass=null},Ur(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(pi),XH=[10497,33648,33071,33071],WH=function(t){function e(e,i){var r;(r=t.call(this,e,i)||this)._gpuSampler=null;var n,s,a=r._info.minFilter,o=r._info.magFilter,l=r._info.mipFilter;n=a===ft.LINEAR||a===ft.ANISOTROPIC?l===ft.LINEAR||l===ft.ANISOTROPIC?9987:l===ft.POINT?9985:9729:l===ft.LINEAR||l===ft.ANISOTROPIC?9986:l===ft.POINT?9984:9728,s=o===ft.LINEAR||o===ft.ANISOTROPIC?9729:9728;var h=XH[r._info.addressU],u=XH[r._info.addressV],c=XH[r._info.addressW];return r._gpuSampler={glMinFilter:n,glMagFilter:s,glWrapS:h,glWrapT:u,glWrapR:c},r}return on(e,t),Ur(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(mi),jH=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}on(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.slice(),samplerTextures:t.samplerTextures.slice(),subpassInputs:t.subpassInputs.slice(),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}}!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 bt.VERTEX:s="VertexShader",n=i.VERTEX_SHADER;break;case bt.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.extensions.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));ps("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 d,p=f.name.indexOf("[");d=-1!==p?f.name.substr(0,p):f.name;var m=i.getAttribLocation(e.glProgram,d),g=nH(f.type,i),y=sH(f.type,i);e.glInputs[_]={binding:m,name:d,type:g,stride:y,count:f.size,size:y*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 T=b.members[A],C=iH(T.type,i),x=sH(C,i),w=x*T.count;S.glUniforms[A]={binding:-1,name:T.name,type:T.type,stride:x,count:T.count,size:w,offset:0,glType:C,glLoc:null,array:null}}}}for(var E=0;E<e.subpassInputs.length;++E){var B=e.subpassInputs[E];e.samplerTextures.push(new ce(B.set,B.binding,B.name,it.SAMPLER2D,B.count))}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var R=0;R<e.samplerTextures.length;++R){var D=e.samplerTextures[R];e.glSamplerTextures[R]={set:D.set,binding:D.binding,name:D.name,type:D.type,count:D.count,units:[],glUnits:null,glType:iH(D.type,i),glLoc:null}}}for(var M=i.getProgramParameter(e.glProgram,i.ACTIVE_UNIFORMS),P=0;P<M;++P){var I=i.getActiveUniform(e.glProgram,P);if(I&&I.type!==i.SAMPLER_2D&&I.type!==i.SAMPLER_CUBE){var O=i.getUniformLocation(e.glProgram,I.name);if(t.extensions.isLocationActive(O)){var F,L=I.name.indexOf("[");F=-1!==L?I.name.substr(0,L):I.name;for(var k=0;k<e.glBlocks.length;k++)for(var V=e.glBlocks[k],N=0;N<V.glUniforms.length;N++){var G=V.glUniforms[N];if(G.name===F){G.glLoc=O,G.count=I.size,G.size=G.stride*G.count,G.array=new(rH(G.type))(G.size/4),V.glActiveUniforms.push(G);break}}}}}for(var z=0;z<e.glBlocks.length;z++)for(var U=e.glBlocks[z],H=0;H<U.glUniforms.length;H++){var X=U.glUniforms[H];X.offset=U.size/4,U.size+=X.size}for(var W=[],j=[],Y=t.bindingMappings,q=t.stateCache.texUnitCacheMap,K=0,J=0;J<e.blocks.length;++J)e.blocks[J].set===Y.flexibleSet&&K++;for(var Z=0,Q=0;Q<e.samplerTextures.length;++Q){var $=e.samplerTextures[Q],tt=i.getUniformLocation(e.glProgram,$.name);if(t.extensions.isLocationActive(tt)&&(W.push(e.glSamplerTextures[Q]),j.push(tt)),void 0===q[$.name]){var et=$.binding+Y.samplerTextureOffsets[$.set]+Z;$.set===Y.flexibleSet&&(et-=K),q[$.name]=et%t.capabilities.maxTextureUnits,Z+=$.count-1}}if(W.length){for(var rt=[],nt=0;nt<W.length;++nt){var st=W[nt],at=q[st.name];if(void 0!==at){st.glLoc=j[nt];for(var ot=0;ot<st.count;++ot){for(;rt[at];)at=(at+1)%t.capabilities.maxTextureUnits;st.units.push(at),rt[at]=!0}}}for(var lt=0,ht=0;ht<W.length;++ht){var ut=W[ht];if(!t.extensions.isLocationActive(ut.glLoc)){ut.glLoc=j[ht];for(var ct=0;ct<ut.count;++ct){for(;rt[lt];)lt=(lt+1)%t.capabilities.maxTextureUnits;void 0===q[ut.name]&&(q[ut.name]=lt),ut.units.push(lt),rt[lt]=!0}}}t.stateCache.glProgram!==e.glProgram&&i.useProgram(e.glProgram);for(var _t=0;_t<W.length;_t++){var ft=W[_t];ft.glUnits=new Int32Array(ft.units),i.uniform1iv(ft.glLoc,ft.glUnits)}t.stateCache.glProgram!==e.glProgram&&i.useProgram(t.stateCache.glProgram)}for(var dt=0;dt<e.glBlocks.length;)e.glBlocks[dt].glActiveUniforms.length?dt++:(e.glBlocks[dt]=e.glBlocks[e.glBlocks.length-1],e.glBlocks.length--);e.glSamplerTextures=W}}(tH.instance,this._gpuShader)},i.destroy=function(){this._gpuShader&&(function(t,e){if(e.glProgram){var i=t.gl;if(!t.extensions.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),t.stateCache.glProgram===e.glProgram&&(t.gl.useProgram(null),t.stateCache.glProgram=null),e.glProgram=null}}(tH.instance,this._gpuShader),this._gpuShader=null)},Ur(e,[{key:"gpuShader",get:function(){return this._gpuShader}}]),e}(gi),YH=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 Jt,this.scissorRect=new Ht(0,0,0,0),this.rs=new li,this.dss=new hi,this.bs=new ci,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}(),qH=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._lodLevel=0,e}on(e,t);var i=e.prototype;return i.initialize=function(t,e){var i=t,r=t;"texture"in t&&(i=r.texture.info,this._isTextureView=!0),this._info.copy(i),this._isPowerOf2=Ke(this._info.width)&&Ke(this._info.height),this._size=Ze(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,this._isTextureView?(this._viewInfo.copy(r),this._lodLevel=r.baseLevel,this._gpuTexture=r.texture._gpuTexture):(this._gpuTexture={type:i.type,format:i.format,usage:i.usage,width:i.width,height:i.height,depth:i.depth,size:this._size,arrayLayer:i.layerCount,mipLevel:i.levelCount,samples:i.samples,flags:i.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,isSwapchainTexture:e||!1},function(t,e){var i=t.gl;e.glFormat=e.glInternalFmt=function(t,e){switch(t){case tt.A8:return e.ALPHA;case tt.L8:return e.LUMINANCE;case tt.LA8:return e.LUMINANCE_ALPHA;case tt.RGB8:case tt.RGB16F:case tt.RGB32F:return e.RGB;case tt.BGRA8:case tt.RGBA8:case tt.SRGB8_A8:case tt.RGBA16F:case tt.RGBA32F:return e.RGBA;case tt.R5G6B5:return e.RGB;case tt.RGB5A1:case tt.RGBA4:return e.RGBA;case tt.DEPTH:return e.DEPTH_COMPONENT;case tt.DEPTH_STENCIL:return e.DEPTH_STENCIL;case tt.BC1:return QU.COMPRESSED_RGB_S3TC_DXT1_EXT;case tt.BC1_ALPHA:return QU.COMPRESSED_RGBA_S3TC_DXT1_EXT;case tt.BC1_SRGB:return QU.COMPRESSED_SRGB_S3TC_DXT1_EXT;case tt.BC1_SRGB_ALPHA:return QU.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case tt.BC2:return QU.COMPRESSED_RGBA_S3TC_DXT3_EXT;case tt.BC2_SRGB:return QU.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case tt.BC3:return QU.COMPRESSED_RGBA_S3TC_DXT5_EXT;case tt.BC3_SRGB:return QU.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case tt.ETC_RGB8:return QU.COMPRESSED_RGB_ETC1_WEBGL;case tt.ETC2_RGB8:return QU.COMPRESSED_RGB8_ETC2;case tt.ETC2_SRGB8:return QU.COMPRESSED_SRGB8_ETC2;case tt.ETC2_RGB8_A1:return QU.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_SRGB8_A1:return QU.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_RGBA8:return QU.COMPRESSED_RGBA8_ETC2_EAC;case tt.ETC2_SRGB8_A8:return QU.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case tt.EAC_R11:return QU.COMPRESSED_R11_EAC;case tt.EAC_R11SN:return QU.COMPRESSED_SIGNED_R11_EAC;case tt.EAC_RG11:return QU.COMPRESSED_RG11_EAC;case tt.EAC_RG11SN:return QU.COMPRESSED_SIGNED_RG11_EAC;case tt.PVRTC_RGB2:return QU.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGBA2:return QU.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGB4:return QU.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case tt.PVRTC_RGBA4:return QU.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case tt.ASTC_RGBA_4X4:return QU.COMPRESSED_RGBA_ASTC_4x4_KHR;case tt.ASTC_RGBA_5X4:return QU.COMPRESSED_RGBA_ASTC_5x4_KHR;case tt.ASTC_RGBA_5X5:return QU.COMPRESSED_RGBA_ASTC_5x5_KHR;case tt.ASTC_RGBA_6X5:return QU.COMPRESSED_RGBA_ASTC_6x5_KHR;case tt.ASTC_RGBA_6X6:return QU.COMPRESSED_RGBA_ASTC_6x6_KHR;case tt.ASTC_RGBA_8X5:return QU.COMPRESSED_RGBA_ASTC_8x5_KHR;case tt.ASTC_RGBA_8X6:return QU.COMPRESSED_RGBA_ASTC_8x6_KHR;case tt.ASTC_RGBA_8X8:return QU.COMPRESSED_RGBA_ASTC_8x8_KHR;case tt.ASTC_RGBA_10X5:return QU.COMPRESSED_RGBA_ASTC_10x5_KHR;case tt.ASTC_RGBA_10X6:return QU.COMPRESSED_RGBA_ASTC_10x6_KHR;case tt.ASTC_RGBA_10X8:return QU.COMPRESSED_RGBA_ASTC_10x8_KHR;case tt.ASTC_RGBA_10X10:return QU.COMPRESSED_RGBA_ASTC_10x10_KHR;case tt.ASTC_RGBA_12X10:return QU.COMPRESSED_RGBA_ASTC_12x10_KHR;case tt.ASTC_RGBA_12X12:return QU.COMPRESSED_RGBA_ASTC_12x12_KHR;case tt.ASTC_SRGBA_4X4:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case tt.ASTC_SRGBA_5X4:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case tt.ASTC_SRGBA_5X5:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case tt.ASTC_SRGBA_6X5:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case tt.ASTC_SRGBA_6X6:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case tt.ASTC_SRGBA_8X5:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case tt.ASTC_SRGBA_8X6:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case tt.ASTC_SRGBA_8X8:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case tt.ASTC_SRGBA_10X5:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case tt.ASTC_SRGBA_10X6:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case tt.ASTC_SRGBA_10X8:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case tt.ASTC_SRGBA_10X10:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case tt.ASTC_SRGBA_12X10:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case tt.ASTC_SRGBA_12X12:return QU.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),e.RGBA}}(e.format,i),e.glType=eH(e.format,i);var r=e.width,n=e.height;switch(e.type){case ot.TEX2D:if(e.glTarget=i.TEXTURE_2D,e.isSwapchainTexture)break;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Nn(9100,s,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!Xe[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var l=Je(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);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 e.glInternalFmt=function(t,e){switch(t){case tt.R5G6B5:return e.RGB565;case tt.RGB5A1:return e.RGB5_A1;case tt.RGBA4:return e.RGBA4;case tt.RGBA16F:return QU.RGBA16F_EXT;case tt.RGBA32F:return QU.RGBA32F_EXT;case tt.SRGB8_A8:return QU.SRGB8_ALPHA8_EXT;case tt.DEPTH:return e.DEPTH_COMPONENT16;case tt.DEPTH_STENCIL:return e.DEPTH_STENCIL;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}(e.format,i),e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,r,n));break;case ot.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(r,n);if(c>t.capabilities.maxCubeMapTextureSize&&Nn(9100,c,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var f=0;f<6;++f){r=e.width,n=e.height;for(var d=0;d<e.mipLevel;++d){var p=Je(e.format,r,n,1),m=new Uint8Array(p);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+f,d,e.glInternalFmt,r,n,0,m),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}else for(var g=0;g<6;++g){r=e.width,n=e.height;for(var y=0;y<e.mipLevel;++y)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+g,y,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=ot.TEX2D,e.glTarget=i.TEXTURE_2D}}(tH.instance,this._gpuTexture),tH.instance.memoryStatus.textureSize+=this._size,this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount)},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(function(t,e){var i=t.gl;if(e.glTexture){var r=t.stateCache.glTexUnits,n=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s<r.length;s++)r[s].glTexture===e.glTexture&&(i.activeTexture(i.TEXTURE0+s),n=s,i.bindTexture(e.glTarget,null),r[s].glTexture=null);t.stateCache.texUnit=n,e.glTexture=null}if(e.glRenderbuffer){var a=t.stateCache.glRenderbuffer;i.deleteRenderbuffer(e.glRenderbuffer),a===e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,null),a=null),e.glRenderbuffer=null}}(tH.instance,this._gpuTexture),tH.instance.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.resize=function(t,i){if(this._info.width!==t||this._info.height!==i){this._info.levelCount===e.getLevelCount(this._info.width,this._info.height)?this._info.levelCount=e.getLevelCount(t,i):this._info.levelCount>1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var r=this._size;this._info.width=t,this._info.height=i,this._size=Ze(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,function(t,e){if(e.size){var i=t.gl,r=e.width,n=e.height;switch(e.type){case ot.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Nn(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),Xe[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var l=Je(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 ot.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(r,n);c>t.capabilities.maxCubeMapTextureSize&&Nn(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),Xe[e.format].isCompressed)for(var f=0;f<6;++f){r=e.width,n=e.height;for(var d=0;d<e.mipLevel;++d){var p=Je(e.format,r,n,1),m=new Uint8Array(p);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+f,d,e.glInternalFmt,r,n,0,m),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}else for(var g=0;g<6;++g){r=e.width,n=e.height;for(var y=0;y<e.mipLevel;++y)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+g,y,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=ot.TEX2D,e.glTarget=i.TEXTURE_2D}}}(tH.instance,this._gpuTexture),tH.instance.memoryStatus.textureSize-=r,tH.instance.memoryStatus.textureSize+=this._size)}},i.initAsSwapchainTexture=function(t){var e=new ae;e.format=t.format,e.usage=Xe[t.format].hasDepth?lt.DEPTH_STENCIL_ATTACHMENT:lt.COLOR_ATTACHMENT,e.width=t.width,e.height=t.height,this.initialize(e,!0)},Ur(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"lodLevel",get:function(){return this._lodLevel}}]),e}(yi),KH="webglcontextlost";function JH(t,e){for(var i=["","WEBKIT_","MOZ_"],r=0;r<i.length;++r){var n=t.getExtension(i[r]+e);if(n)return n}return null}function ZH(t){var e={EXT_texture_filter_anisotropic:JH(t,"EXT_texture_filter_anisotropic"),EXT_blend_minmax:JH(t,"EXT_blend_minmax"),EXT_frag_depth:JH(t,"EXT_frag_depth"),EXT_shader_texture_lod:JH(t,"EXT_shader_texture_lod"),EXT_sRGB:JH(t,"EXT_sRGB"),OES_vertex_array_object:JH(t,"OES_vertex_array_object"),EXT_color_buffer_half_float:JH(t,"EXT_color_buffer_half_float"),WEBGL_color_buffer_float:JH(t,"WEBGL_color_buffer_float"),WEBGL_compressed_texture_etc1:JH(t,"WEBGL_compressed_texture_etc1"),WEBGL_compressed_texture_etc:JH(t,"WEBGL_compressed_texture_etc"),WEBGL_compressed_texture_pvrtc:JH(t,"WEBGL_compressed_texture_pvrtc"),WEBGL_compressed_texture_s3tc:JH(t,"WEBGL_compressed_texture_s3tc"),WEBGL_compressed_texture_s3tc_srgb:JH(t,"WEBGL_compressed_texture_s3tc_srgb"),WEBGL_debug_shaders:JH(t,"WEBGL_debug_shaders"),WEBGL_draw_buffers:JH(t,"WEBGL_draw_buffers"),WEBGL_lose_context:JH(t,"WEBGL_lose_context"),WEBGL_depth_texture:JH(t,"WEBGL_depth_texture"),OES_texture_half_float:JH(t,"OES_texture_half_float"),OES_texture_half_float_linear:JH(t,"OES_texture_half_float_linear"),OES_texture_float:JH(t,"OES_texture_float"),OES_texture_float_linear:JH(t,"OES_texture_float_linear"),OES_standard_derivatives:JH(t,"OES_standard_derivatives"),OES_element_index_uint:JH(t,"OES_element_index_uint"),ANGLE_instanced_arrays:JH(t,"ANGLE_instanced_arrays"),WEBGL_debug_renderer_info:JH(t,"WEBGL_debug_renderer_info"),WEBGL_multi_draw:null,WEBGL_compressed_texture_astc:null,destroyShadersImmediately:!0,noCompressedTexSubImage2D:!1,isLocationActive:function(t){return!!t},useVAO:!1};return Xa.os===ja.IOS&&14===Xa.osMainVersion&&Xa.isBrowser||(e.WEBGL_compressed_texture_astc=JH(t,"WEBGL_compressed_texture_astc")),Xa.os!==ja.ANDROID&&Xa.os!==ja.IOS&&(e.WEBGL_multi_draw=JH(t,"WEBGL_multi_draw")),Xa.browserType===Ya.UC&&(e.ANGLE_instanced_arrays=null),(Xa.os===ja.IOS&&Xa.osMainVersion<=10||ho)&&(e.destroyShadersImmediately=!1),e.OES_vertex_array_object&&(e.useVAO=!0),e}var QH=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 YH,e.cmdAllocator=new IH,e.nullTex2D=null,e.nullTexCube=null,e._canvas=null,e._webGLContextLostHandler=null,e._extensions=null,e}on(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.windowHandle,this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(KH,this._onWebGLContextLost);var e=tH.instance.gl;this.stateCache.initialize(tH.instance.capabilities.maxTextureUnits,tH.instance.capabilities.maxVertexAttributes),this._extensions=ZH(e),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)}(e);var i=tt.RGBA8,r=tt.DEPTH_STENCIL,n=e.getParameter(e.DEPTH_BITS),s=e.getParameter(e.STENCIL_BITS);n&&s?r=tt.DEPTH_STENCIL:n&&(r=tt.DEPTH),this._colorTexture=new qH,this._colorTexture.initAsSwapchainTexture({swapchain:this,format:i,width:t.width,height:t.height}),this._depthStencilTexture=new qH,this._depthStencilTexture.initAsSwapchainTexture({swapchain:this,format:r,width:t.width,height:t.height}),this.nullTex2D=tH.instance.createTexture(new ae(ot.TEX2D,lt.SAMPLED,tt.RGBA8,2,2,ht.GEN_MIPMAP)),this.nullTexCube=tH.instance.createTexture(new ae(ot.CUBE,lt.SAMPLED,tt.RGBA8,2,2,ht.GEN_MIPMAP,6));var a=new Kt;a.texExtent.width=2,a.texExtent.height=2;var o=new Uint8Array(this.nullTex2D.size);o.fill(0),tH.instance.copyBuffersToTexture([o],this.nullTex2D,[a]),a.texSubres.layerCount=6,tH.instance.copyBuffersToTexture([o,o,o,o,o,o],this.nullTexCube,[a])},i.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener(KH,this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._extensions=null,this._canvas=null},i.resize=function(t,e){this._colorTexture.width===t&&this._colorTexture.height===e||(ps("Resizing swapchain: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._colorTexture.resize(t,e),this._depthStencilTexture.resize(t,e))},i._onWebGLContextLost=function(t){Rn(11e3),bn(t)},Ur(e,[{key:"extensions",get:function(){return this._extensions}}]),e}(ri),$H=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)._swapchain=null,e._context=null,e._bindingMappings=null,e._textureExclusive=new Array(tt.COUNT),e}on(e,t);var i=e.prototype;return i.initialize=function(t){tH.setInstance(this),this._gfxAPI=Z.WEBGL;var e=this._bindingMappingInfo=t.bindingMappingInfo,i=[],r=[],n=e.setIndices[0];i[n]=0,r[n]=0;for(var s=1;s<e.setIndices.length;++s){var a=e.setIndices[s],o=e.setIndices[s-1];i[a]=e.maxBlockCounts[o]+i[o],r[a]=e.maxSamplerTextureCounts[o]+r[o]}for(var l=0;l<e.setIndices.length;++l){var h=e.setIndices[l];r[h]-=e.maxBlockCounts[h]}this._bindingMappings={blockOffsets:i,samplerTextureOffsets:r,flexibleSet:e.setIndices[e.setIndices.length-1]};var u=this._context=function(t){var e=null;try{var i={alpha:qr.ENABLE_TRANSPARENT_CANVAS,antialias:uo||qr.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};e=t.getContext("webgl",i)}catch(t){return null}return e}(ii.canvas);if(!u)return console.error("This device does not support WebGL."),!1;this._queue=this.createQueue(new Le(It.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Fe(this._queue)),this._caps.maxVertexAttributes=u.getParameter(u.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=u.getParameter(u.MAX_VERTEX_UNIFORM_VECTORS),this._caps.maxFragmentUniformVectors=u.getParameter(u.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=u.getParameter(u.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=u.getParameter(u.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=u.getParameter(u.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=u.getParameter(u.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxUniformBufferBindings=16;var c=u.getSupportedExtensions(),_="";if(c)for(var f,d=hn(c);!(f=d()).done;)_+=f.value+" ";var p=ZH(u);p.WEBGL_debug_renderer_info?(this._renderer=u.getParameter(p.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=u.getParameter(p.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=u.getParameter(u.RENDERER),this._vendor=u.getParameter(u.VENDOR));var m=u.getParameter(u.VERSION);this._features.fill(!1),this.initFormatFeatures(p),p.EXT_blend_minmax&&(this._features[$.BLEND_MINMAX]=!0),p.OES_element_index_uint&&(this._features[$.ELEMENT_INDEX_UINT]=!0),p.ANGLE_instanced_arrays&&(this._features[$.INSTANCED_ARRAYS]=!0),p.WEBGL_draw_buffers&&(this._features[$.MULTIPLE_RENDER_TARGETS]=!0);var g="";return this.getFormatFeatures(tt.ETC_RGB8)&&(g+="etc1 "),this.getFormatFeatures(tt.ETC2_RGB8)&&(g+="etc2 "),this.getFormatFeatures(tt.BC1)&&(g+="dxt "),this.getFormatFeatures(tt.PVRTC_RGB2)&&(g+="pvrtc "),this.getFormatFeatures(tt.ASTC_RGBA_4X4)&&(g+="astc "),ps("WebGL device initialized."),ps("RENDERER: "+this._renderer),ps("VENDOR: "+this._vendor),ps("VERSION: "+m),ps("COMPRESSED_FORMAT: "+g),ps("EXTENSIONS: "+_),!0},i.destroy=function(){this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null)},i.flushCommands=function(){},i.acquire=function(){},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.initFormatFeatures=function(t){this._formatFeatures.fill(ut.NONE),this._textureExclusive.fill(!0);var e=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER;this._formatFeatures[tt.RGB8]=e,this._formatFeatures[tt.R5G6B5]=e,this._textureExclusive[tt.R5G6B5]=!1,this._formatFeatures[tt.RGBA8]=e,this._formatFeatures[tt.RGBA4]=e,this._textureExclusive[tt.RGBA4]=!1,this._formatFeatures[tt.RGB5A1]=e,this._textureExclusive[tt.RGB5A1]=!1,this._formatFeatures[tt.DEPTH]=ut.RENDER_TARGET,this._textureExclusive[tt.DEPTH]=!1,this._formatFeatures[tt.DEPTH_STENCIL]=ut.RENDER_TARGET,this._textureExclusive[tt.DEPTH_STENCIL]=!1,this._formatFeatures[tt.R8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RG8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGB8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGBA8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RG8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGB8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGBA8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RG8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGB8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGBA8I]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RG8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGB8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGBA8UI]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R32F]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RG32F]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGB32F]|=ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.RGBA32F]|=ut.VERTEX_ATTRIBUTE,t.EXT_sRGB&&(this._formatFeatures[tt.SRGB8]=e,this._formatFeatures[tt.SRGB8_A8]=e,this._textureExclusive[tt.SRGB8_A8]=!1),t.WEBGL_depth_texture&&(this._formatFeatures[tt.DEPTH]|=e,this._formatFeatures[tt.DEPTH_STENCIL]|=e),t.WEBGL_color_buffer_float&&(this._formatFeatures[tt.RGB32F]|=ut.RENDER_TARGET,this._formatFeatures[tt.RGBA32F]|=ut.RENDER_TARGET,this._textureExclusive[tt.RGB32F]=!1,this._textureExclusive[tt.RGBA32F]=!1),t.EXT_color_buffer_half_float&&(this._formatFeatures[tt.RGB16F]|=ut.RENDER_TARGET,this._formatFeatures[tt.RGBA16F]|=ut.RENDER_TARGET,this._textureExclusive[tt.RGB16F]=!1,this._textureExclusive[tt.RGBA16F]=!1),t.OES_texture_float&&(this._formatFeatures[tt.RGB32F]|=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE,this._formatFeatures[tt.RGBA32F]|=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE),t.OES_texture_half_float&&(this._formatFeatures[tt.RGB16F]|=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE,this._formatFeatures[tt.RGBA16F]|=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE),t.OES_texture_float_linear&&(this._formatFeatures[tt.RGB32F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RGBA32F]|=ut.LINEAR_FILTER),t.OES_texture_half_float_linear&&(this._formatFeatures[tt.RGB16F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RGBA16F]|=ut.LINEAR_FILTER);var i=ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER;t.WEBGL_compressed_texture_etc1&&(this._formatFeatures[tt.ETC_RGB8]=i),t.WEBGL_compressed_texture_etc&&(this._formatFeatures[tt.ETC2_RGB8]=i,this._formatFeatures[tt.ETC2_RGBA8]=i,this._formatFeatures[tt.ETC2_SRGB8]=i,this._formatFeatures[tt.ETC2_SRGB8_A8]=i,this._formatFeatures[tt.ETC2_RGB8_A1]=i,this._formatFeatures[tt.ETC2_SRGB8_A1]=i),t.WEBGL_compressed_texture_s3tc&&(this._formatFeatures[tt.BC1]=i,this._formatFeatures[tt.BC1_ALPHA]=i,this._formatFeatures[tt.BC1_SRGB]=i,this._formatFeatures[tt.BC1_SRGB_ALPHA]=i,this._formatFeatures[tt.BC2]=i,this._formatFeatures[tt.BC2_SRGB]=i,this._formatFeatures[tt.BC3]=i,this._formatFeatures[tt.BC3_SRGB]=i),t.WEBGL_compressed_texture_pvrtc&&(this._formatFeatures[tt.PVRTC_RGB2]|=i,this._formatFeatures[tt.PVRTC_RGBA2]|=i,this._formatFeatures[tt.PVRTC_RGB4]|=i,this._formatFeatures[tt.PVRTC_RGBA4]|=i),t.WEBGL_compressed_texture_astc&&(this._formatFeatures[tt.ASTC_RGBA_4X4]|=i,this._formatFeatures[tt.ASTC_RGBA_5X4]|=i,this._formatFeatures[tt.ASTC_RGBA_5X5]|=i,this._formatFeatures[tt.ASTC_RGBA_6X5]|=i,this._formatFeatures[tt.ASTC_RGBA_6X6]|=i,this._formatFeatures[tt.ASTC_RGBA_8X5]|=i,this._formatFeatures[tt.ASTC_RGBA_8X6]|=i,this._formatFeatures[tt.ASTC_RGBA_8X8]|=i,this._formatFeatures[tt.ASTC_RGBA_10X5]|=i,this._formatFeatures[tt.ASTC_RGBA_10X6]|=i,this._formatFeatures[tt.ASTC_RGBA_10X8]|=i,this._formatFeatures[tt.ASTC_RGBA_10X10]|=i,this._formatFeatures[tt.ASTC_RGBA_12X10]|=i,this._formatFeatures[tt.ASTC_RGBA_12X12]|=i,this._formatFeatures[tt.ASTC_SRGBA_4X4]|=i,this._formatFeatures[tt.ASTC_SRGBA_5X4]|=i,this._formatFeatures[tt.ASTC_SRGBA_5X5]|=i,this._formatFeatures[tt.ASTC_SRGBA_6X5]|=i,this._formatFeatures[tt.ASTC_SRGBA_6X6]|=i,this._formatFeatures[tt.ASTC_SRGBA_8X5]|=i,this._formatFeatures[tt.ASTC_SRGBA_8X6]|=i,this._formatFeatures[tt.ASTC_SRGBA_8X8]|=i,this._formatFeatures[tt.ASTC_SRGBA_10X5]|=i,this._formatFeatures[tt.ASTC_SRGBA_10X6]|=i,this._formatFeatures[tt.ASTC_SRGBA_10X8]|=i,this._formatFeatures[tt.ASTC_SRGBA_10X10]|=i,this._formatFeatures[tt.ASTC_SRGBA_12X10]|=i,this._formatFeatures[tt.ASTC_SRGBA_12X12]|=i)},i.createCommandBuffer=function(t){var e=new(t.type===Ft.PRIMARY?zH:OH);return e.initialize(t),e},i.createSwapchain=function(t){var e=new QH;return this._swapchain=e,e.initialize(t),e},i.createBuffer=function(t){var e=new MH;return e.initialize(t),e},i.createTexture=function(t){var e=new qH;return e.initialize(t),e},i.createDescriptorSet=function(t){var e=new $U;return e.initialize(t),e},i.createShader=function(t){var e=new jH;return e.initialize(t),e},i.createInputAssembler=function(t){var e=new LH;return e.initialize(t),e},i.createRenderPass=function(t){var e=new HH;return e.initialize(t),e},i.createFramebuffer=function(t){var e=new FH;return e.initialize(t),e},i.createDescriptorSetLayout=function(t){var e=new kH;return e.initialize(t),e},i.createPipelineLayout=function(t){var e=new VH;return e.initialize(t),e},i.createPipelineState=function(t){var e=new GH;return e.initialize(t),e},i.createQueue=function(t){var e=new UH;return e.initialize(t),e},i.getSampler=function(t){var e=mi.computeHash(t);return this._samplers.has(e)||this._samplers.set(e,new WH(t,e)),this._samplers.get(e)},i.getGeneralBarrier=function(t){var e=vi.computeHash(t);return this._generalBarrierss.has(e)||this._generalBarrierss.set(e,new vi(t,e)),this._generalBarrierss.get(e)},i.getTextureBarrier=function(t){var e=bi.computeHash(t);return this._textureBarriers.has(e)||this._textureBarriers.set(e,new bi(t,e)),this._textureBarriers.get(e)},i.getBufferBarrier=function(t){var e=co.computeHash(t);return this._bufferBarriers.has(e)||this._bufferBarriers.set(e,new co(t,e)),this._bufferBarriers.get(e)},i.copyBuffersToTexture=function(t,e,i){RH(this,t,e.gpuTexture,i)},i.copyTextureToBuffers=function(t,e,i){!function(t,e,i,r){var n=t.gl,s=t.stateCache,a=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,a);var o=0,l=0,h=1,u=1;switch(e.glTarget){case n.TEXTURE_2D:for(var c=0;c<r.length;c++){var _=r[c];n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,e.glTarget,e.glTexture,_.texSubres.mipLevel),o=_.texOffset.x,l=_.texOffset.y,h=_.texExtent.width,u=_.texExtent.height,n.readPixels(o,l,h,u,e.glFormat,e.glType,i[c])}break;default:console.error("Unsupported GL texture type, copy texture to buffers failed.")}n.bindFramebuffer(n.FRAMEBUFFER,null),s.glFramebuffer=null,n.deleteFramebuffer(a)}(this,t.gpuTexture,e,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&ht.GEN_MIPMAP&&i.isPowerOf2&&n.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},Ur(e,[{key:"gl",get:function(){return this._context}},{key:"extensions",get:function(){return this._swapchain.extensions}},{key:"stateCache",get:function(){return this._swapchain.stateCache}},{key:"nullTex2D",get:function(){return this._swapchain.nullTex2D}},{key:"nullTexCube",get:function(){return this._swapchain.nullTexCube}},{key:"textureExclusive",get:function(){return this._textureExclusive}},{key:"bindingMappings",get:function(){return this._bindingMappings}}]),e}(ii));Er.WebGLDevice=$H;var tX,eX=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}on(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,gpuTextureView:null,gpuSampler:null})},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)t[e].type&We?this._buffers[e]&&(t[e].gpuBuffer=this._buffers[e].gpuBuffer):t[e].type&je&&(this._textures[e]&&(t[e].gpuTextureView=this._textures[e].gpuTextureView),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},Ur(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(j);!function(t){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"}(tX||(tX={}));var iX=function(){function t(){}return t.setInstance=function(e){t._instance=e},Ur(t,null,[{key:"instance",get:function(){return t._instance}}]),t}();iX._instance=null;var rX=[10497,33648,33071,33071],nX=new Float32Array(4);function sX(t,e){switch(t){case tt.R8:return e.UNSIGNED_BYTE;case tt.R8SN:return e.BYTE;case tt.R8UI:return e.UNSIGNED_BYTE;case tt.R8I:return e.BYTE;case tt.R16F:return e.HALF_FLOAT;case tt.R16UI:return e.UNSIGNED_SHORT;case tt.R16I:return e.SHORT;case tt.R32F:return e.FLOAT;case tt.R32UI:return e.UNSIGNED_INT;case tt.R32I:return e.INT;case tt.RG8:return e.UNSIGNED_BYTE;case tt.RG8SN:return e.BYTE;case tt.RG8UI:return e.UNSIGNED_BYTE;case tt.RG8I:return e.BYTE;case tt.RG16F:return e.HALF_FLOAT;case tt.RG16UI:return e.UNSIGNED_SHORT;case tt.RG16I:return e.SHORT;case tt.RG32F:return e.FLOAT;case tt.RG32UI:return e.UNSIGNED_INT;case tt.RG32I:return e.INT;case tt.RGB8:case tt.SRGB8:return e.UNSIGNED_BYTE;case tt.RGB8SN:return e.BYTE;case tt.RGB8UI:return e.UNSIGNED_BYTE;case tt.RGB8I:return e.BYTE;case tt.RGB16F:return e.HALF_FLOAT;case tt.RGB16UI:return e.UNSIGNED_SHORT;case tt.RGB16I:return e.SHORT;case tt.RGB32F:return e.FLOAT;case tt.RGB32UI:return e.UNSIGNED_INT;case tt.RGB32I:return e.INT;case tt.BGRA8:case tt.RGBA8:case tt.SRGB8_A8:return e.UNSIGNED_BYTE;case tt.RGBA8SN:return e.BYTE;case tt.RGBA8UI:return e.UNSIGNED_BYTE;case tt.RGBA8I:return e.BYTE;case tt.RGBA16F:return e.HALF_FLOAT;case tt.RGBA16UI:return e.UNSIGNED_SHORT;case tt.RGBA16I:return e.SHORT;case tt.RGBA32F:return e.FLOAT;case tt.RGBA32UI:return e.UNSIGNED_INT;case tt.RGBA32I:return e.INT;case tt.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case tt.R11G11B10F:return e.UNSIGNED_INT_10F_11F_11F_REV;case tt.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case tt.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case tt.RGB10A2:case tt.RGB10A2UI:return e.UNSIGNED_INT_2_10_10_10_REV;case tt.RGB9E5:case tt.DEPTH:return e.FLOAT;case tt.DEPTH_STENCIL:return e.UNSIGNED_INT_24_8;case tt.BC1:case tt.BC1_SRGB:case tt.BC2:case tt.BC2_SRGB:case tt.BC3:case tt.BC3_SRGB:case tt.BC4:return e.UNSIGNED_BYTE;case tt.BC4_SNORM:return e.BYTE;case tt.BC5:return e.UNSIGNED_BYTE;case tt.BC5_SNORM:return e.BYTE;case tt.BC6H_SF16:case tt.BC6H_UF16:return e.FLOAT;case tt.BC7:case tt.BC7_SRGB:case tt.ETC_RGB8:case tt.ETC2_RGB8:case tt.ETC2_SRGB8:case tt.ETC2_RGB8_A1:case tt.ETC2_SRGB8_A1:case tt.EAC_R11:return e.UNSIGNED_BYTE;case tt.EAC_R11SN:return e.BYTE;case tt.EAC_RG11:return e.UNSIGNED_BYTE;case tt.EAC_RG11SN:return e.BYTE;case tt.PVRTC_RGB2:case tt.PVRTC_RGBA2:case tt.PVRTC_RGB4:case tt.PVRTC_RGBA4:case tt.PVRTC2_2BPP:case tt.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case tt.ASTC_RGBA_4X4:case tt.ASTC_RGBA_5X4:case tt.ASTC_RGBA_5X5:case tt.ASTC_RGBA_6X5:case tt.ASTC_RGBA_6X6:case tt.ASTC_RGBA_8X5:case tt.ASTC_RGBA_8X6:case tt.ASTC_RGBA_8X8:case tt.ASTC_RGBA_10X5:case tt.ASTC_RGBA_10X6:case tt.ASTC_RGBA_10X8:case tt.ASTC_RGBA_10X10:case tt.ASTC_RGBA_12X10:case tt.ASTC_RGBA_12X12:case tt.ASTC_SRGBA_4X4:case tt.ASTC_SRGBA_5X4:case tt.ASTC_SRGBA_5X5:case tt.ASTC_SRGBA_6X5:case tt.ASTC_SRGBA_6X6:case tt.ASTC_SRGBA_8X5:case tt.ASTC_SRGBA_8X6:case tt.ASTC_SRGBA_8X8:case tt.ASTC_SRGBA_10X5:case tt.ASTC_SRGBA_10X6:case tt.ASTC_SRGBA_10X8:case tt.ASTC_SRGBA_10X10:case tt.ASTC_SRGBA_12X10:case tt.ASTC_SRGBA_12X12:default:return e.UNSIGNED_BYTE}}function aX(t,e){switch(t){case it.BOOL:return e.BOOL;case it.BOOL2:return e.BOOL_VEC2;case it.BOOL3:return e.BOOL_VEC3;case it.BOOL4:return e.BOOL_VEC4;case it.INT:return e.INT;case it.INT2:return e.INT_VEC2;case it.INT3:return e.INT_VEC3;case it.INT4:return e.INT_VEC4;case it.UINT:return e.UNSIGNED_INT;case it.FLOAT:return e.FLOAT;case it.FLOAT2:return e.FLOAT_VEC2;case it.FLOAT3:return e.FLOAT_VEC3;case it.FLOAT4:return e.FLOAT_VEC4;case it.MAT2:return e.FLOAT_MAT2;case it.MAT2X3:return e.FLOAT_MAT2x3;case it.MAT2X4:return e.FLOAT_MAT2x4;case it.MAT3X2:return e.FLOAT_MAT3x2;case it.MAT3:return e.FLOAT_MAT3;case it.MAT3X4:return e.FLOAT_MAT3x4;case it.MAT4X2:return e.FLOAT_MAT4x2;case it.MAT4X3:return e.FLOAT_MAT4x3;case it.MAT4:return e.FLOAT_MAT4;case it.SAMPLER2D:return e.SAMPLER_2D;case it.SAMPLER2D_ARRAY:return e.SAMPLER_2D_ARRAY;case it.SAMPLER3D:return e.SAMPLER_3D;case it.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),it.UNKNOWN}}function oX(t,e){switch(t){case e.BOOL:return it.BOOL;case e.BOOL_VEC2:return it.BOOL2;case e.BOOL_VEC3:return it.BOOL3;case e.BOOL_VEC4:return it.BOOL4;case e.INT:return it.INT;case e.INT_VEC2:return it.INT2;case e.INT_VEC3:return it.INT3;case e.INT_VEC4:return it.INT4;case e.UNSIGNED_INT:return it.UINT;case e.UNSIGNED_INT_VEC2:return it.UINT2;case e.UNSIGNED_INT_VEC3:return it.UINT3;case e.UNSIGNED_INT_VEC4:return it.UINT4;case e.FLOAT:return it.FLOAT;case e.FLOAT_VEC2:return it.FLOAT2;case e.FLOAT_VEC3:return it.FLOAT3;case e.FLOAT_VEC4:return it.FLOAT4;case e.FLOAT_MAT2:return it.MAT2;case e.FLOAT_MAT2x3:return it.MAT2X3;case e.FLOAT_MAT2x4:return it.MAT2X4;case e.FLOAT_MAT3x2:return it.MAT3X2;case e.FLOAT_MAT3:return it.MAT3;case e.FLOAT_MAT3x4:return it.MAT3X4;case e.FLOAT_MAT4x2:return it.MAT4X2;case e.FLOAT_MAT4x3:return it.MAT4X3;case e.FLOAT_MAT4:return it.MAT4;case e.SAMPLER_2D:return it.SAMPLER2D;case e.SAMPLER_2D_ARRAY:return it.SAMPLER2D_ARRAY;case e.SAMPLER_3D:return it.SAMPLER3D;case e.SAMPLER_CUBE:return it.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),it.UNKNOWN}}function lX(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:return 4;case e.UNSIGNED_INT_VEC2:return 8;case e.UNSIGNED_INT_VEC3:return 12;case e.UNSIGNED_INT_VEC4:return 16;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_MAT2x3:return 24;case e.FLOAT_MAT2x4:return 32;case e.FLOAT_MAT3x2:return 24;case e.FLOAT_MAT3:return 36;case e.FLOAT_MAT3x4:return 48;case e.FLOAT_MAT4x2:return 32;case e.FLOAT_MAT4x3:return 48;case e.FLOAT_MAT4:return 64;case e.SAMPLER_2D:case e.SAMPLER_2D_ARRAY:case e.SAMPLER_2D_ARRAY_SHADOW:case e.SAMPLER_3D:case e.SAMPLER_CUBE:case e.INT_SAMPLER_2D:case e.INT_SAMPLER_2D_ARRAY:case e.INT_SAMPLER_3D:case e.INT_SAMPLER_CUBE:case e.UNSIGNED_INT_SAMPLER_2D:case e.UNSIGNED_INT_SAMPLER_2D_ARRAY:case e.UNSIGNED_INT_SAMPLER_3D:case e.UNSIGNED_INT_SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function hX(t,e){switch(t){case e.FLOAT_MAT2:case e.FLOAT_MAT2x3:case e.FLOAT_MAT2x4:return 2;case e.FLOAT_MAT3x2:case e.FLOAT_MAT3:case e.FLOAT_MAT3x4:return 3;case e.FLOAT_MAT4x2:case e.FLOAT_MAT4x3:case e.FLOAT_MAT4:return 4;default:return 1}}var uX,cX=[512,513,514,515,516,517,518,519],_X=[0,7680,7681,7682,7683,5386,34055,34056],fX=[32774,32778,32779,32775,32776],dX=[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"}(uX||(uX={}));var pX=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},mX=function(t){function e(){var e;return(e=t.call(this,uX.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new Ht,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return on(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(pX),gX=function(t){function e(){var e;return(e=t.call(this,uX.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.dynamicStates=new ze,e}return on(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuInputAssembler=null,this.gpuDescriptorSets.length=0,this.dynamicOffsets.length=0},e}(pX),yX=function(t){function e(){var e;return(e=t.call(this,uX.DRAW)||this).drawInfo=new re,e}return on(e,t),e.prototype.clear=function(){},e}(pX),vX=function(t){function e(){var e;return(e=t.call(this,uX.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return on(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(pX),bX=function(t){function e(){var e;return(e=t.call(this,uX.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return on(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(pX),SX=function(){function t(){this.cmds=new W(1),this.beginRenderPassCmds=new W(1),this.bindStatesCmds=new W(1),this.drawCmds=new W(1),this.updateBufferCmds=new W(1),this.copyBufferToTextureCmds=new W(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 AX(t,e,i,r,n){if(e.usage&rt.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;a<s.length;++a)e.indirects.setDrawInfo(r+a,s[a])}else{var o=i,l=t.gl,h=t.stateCache;switch(e.glTarget){case l.ARRAY_BUFFER:t.extensions.useVAO&&h.glVAO&&(l.bindVertexArray(null),h.glVAO=null),xX.gpuInputAssembler=null,h.glArrayBuffer!==e.glBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.glBuffer),h.glArrayBuffer=e.glBuffer),n===o.byteLength?l.bufferSubData(e.glTarget,r,o):l.bufferSubData(e.glTarget,r,o.slice(0,n));break;case l.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&h.glVAO&&(l.bindVertexArray(null),h.glVAO=null),xX.gpuInputAssembler=null,h.glElementArrayBuffer!==e.glBuffer&&(l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.glBuffer),h.glElementArrayBuffer=e.glBuffer),n===o.byteLength?l.bufferSubData(e.glTarget,r,o):l.bufferSubData(e.glTarget,r,o.slice(0,n));break;case l.UNIFORM_BUFFER:h.glUniformBuffer!==e.glBuffer&&(l.bindBuffer(l.UNIFORM_BUFFER,e.glBuffer),h.glUniformBuffer=e.glBuffer),n===o.byteLength?l.bufferSubData(e.glTarget,r,o):l.bufferSubData(e.glTarget,r,new Float32Array(o,0,n/4));break;default:console.error("Unsupported BufferType, update buffer failed.")}}}function TX(t,e){var i=t.gl;e.glInternalFmt=function(t,e){switch(t){case tt.A8:return e.ALPHA;case tt.L8:return e.LUMINANCE;case tt.LA8:return e.LUMINANCE_ALPHA;case tt.R8:return e.R8;case tt.R8SN:return e.R8_SNORM;case tt.R8UI:return e.R8UI;case tt.R8I:return e.R8I;case tt.RG8:return e.RG8;case tt.RG8SN:return e.RG8_SNORM;case tt.RG8UI:return e.RG8UI;case tt.RG8I:return e.RG8I;case tt.RGB8:return e.RGB8;case tt.RGB8SN:return e.RGB8_SNORM;case tt.RGB8UI:return e.RGB8UI;case tt.RGB8I:return e.RGB8I;case tt.BGRA8:case tt.RGBA8:return e.RGBA8;case tt.RGBA8SN:return e.RGBA8_SNORM;case tt.RGBA8UI:return e.RGBA8UI;case tt.RGBA8I:return e.RGBA8I;case tt.R16I:return e.R16I;case tt.R16UI:return e.R16UI;case tt.R16F:return e.R16F;case tt.RG16I:return e.RG16I;case tt.RG16UI:return e.RG16UI;case tt.RG16F:return e.RG16F;case tt.RGB16I:return e.RGB16I;case tt.RGB16UI:return e.RGB16UI;case tt.RGB16F:return e.RGB16F;case tt.RGBA16I:return e.RGBA16I;case tt.RGBA16UI:return e.RGBA16UI;case tt.RGBA16F:return e.RGBA16F;case tt.R32I:return e.R32I;case tt.R32UI:return e.R32UI;case tt.R32F:return e.R32F;case tt.RG32I:return e.RG32I;case tt.RG32UI:return e.RG32UI;case tt.RG32F:return e.RG32F;case tt.RGB32I:return e.RGB32I;case tt.RGB32UI:return e.RGB32UI;case tt.RGB32F:return e.RGB32F;case tt.RGBA32I:return e.RGBA32I;case tt.RGBA32UI:return e.RGBA32UI;case tt.RGBA32F:return e.RGBA32F;case tt.R5G6B5:return e.RGB565;case tt.RGB5A1:return e.RGB5_A1;case tt.RGBA4:return e.RGBA4;case tt.SRGB8:return e.SRGB8;case tt.SRGB8_A8:return e.SRGB8_ALPHA8;case tt.RGB10A2:return e.RGB10_A2;case tt.RGB10A2UI:return e.RGB10_A2UI;case tt.R11G11B10F:return e.R11F_G11F_B10F;case tt.DEPTH:return e.DEPTH_COMPONENT32F;case tt.DEPTH_STENCIL:return e.DEPTH24_STENCIL8;case tt.BC1:return tX.COMPRESSED_RGB_S3TC_DXT1_EXT;case tt.BC1_ALPHA:return tX.COMPRESSED_RGBA_S3TC_DXT1_EXT;case tt.BC1_SRGB:return tX.COMPRESSED_SRGB_S3TC_DXT1_EXT;case tt.BC1_SRGB_ALPHA:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case tt.BC2:return tX.COMPRESSED_RGBA_S3TC_DXT3_EXT;case tt.BC2_SRGB:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case tt.BC3:return tX.COMPRESSED_RGBA_S3TC_DXT5_EXT;case tt.BC3_SRGB:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case tt.ETC_RGB8:return tX.COMPRESSED_RGB_ETC1_WEBGL;case tt.ETC2_RGB8:return tX.COMPRESSED_RGB8_ETC2;case tt.ETC2_SRGB8:return tX.COMPRESSED_SRGB8_ETC2;case tt.ETC2_RGB8_A1:return tX.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_SRGB8_A1:return tX.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_RGBA8:return tX.COMPRESSED_RGBA8_ETC2_EAC;case tt.ETC2_SRGB8_A8:return tX.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case tt.EAC_R11:return tX.COMPRESSED_R11_EAC;case tt.EAC_R11SN:return tX.COMPRESSED_SIGNED_R11_EAC;case tt.EAC_RG11:return tX.COMPRESSED_RG11_EAC;case tt.EAC_RG11SN:return tX.COMPRESSED_SIGNED_RG11_EAC;case tt.PVRTC_RGB2:return tX.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGBA2:return tX.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGB4:return tX.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case tt.PVRTC_RGBA4:return tX.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case tt.ASTC_RGBA_4X4:return tX.COMPRESSED_RGBA_ASTC_4x4_KHR;case tt.ASTC_RGBA_5X4:return tX.COMPRESSED_RGBA_ASTC_5x4_KHR;case tt.ASTC_RGBA_5X5:return tX.COMPRESSED_RGBA_ASTC_5x5_KHR;case tt.ASTC_RGBA_6X5:return tX.COMPRESSED_RGBA_ASTC_6x5_KHR;case tt.ASTC_RGBA_6X6:return tX.COMPRESSED_RGBA_ASTC_6x6_KHR;case tt.ASTC_RGBA_8X5:return tX.COMPRESSED_RGBA_ASTC_8x5_KHR;case tt.ASTC_RGBA_8X6:return tX.COMPRESSED_RGBA_ASTC_8x6_KHR;case tt.ASTC_RGBA_8X8:return tX.COMPRESSED_RGBA_ASTC_8x8_KHR;case tt.ASTC_RGBA_10X5:return tX.COMPRESSED_RGBA_ASTC_10x5_KHR;case tt.ASTC_RGBA_10X6:return tX.COMPRESSED_RGBA_ASTC_10x6_KHR;case tt.ASTC_RGBA_10X8:return tX.COMPRESSED_RGBA_ASTC_10x8_KHR;case tt.ASTC_RGBA_10X10:return tX.COMPRESSED_RGBA_ASTC_10x10_KHR;case tt.ASTC_RGBA_12X10:return tX.COMPRESSED_RGBA_ASTC_12x10_KHR;case tt.ASTC_RGBA_12X12:return tX.COMPRESSED_RGBA_ASTC_12x12_KHR;case tt.ASTC_SRGBA_4X4:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case tt.ASTC_SRGBA_5X4:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case tt.ASTC_SRGBA_5X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case tt.ASTC_SRGBA_6X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case tt.ASTC_SRGBA_6X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case tt.ASTC_SRGBA_8X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case tt.ASTC_SRGBA_8X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case tt.ASTC_SRGBA_8X8:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case tt.ASTC_SRGBA_10X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case tt.ASTC_SRGBA_10X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case tt.ASTC_SRGBA_10X8:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case tt.ASTC_SRGBA_10X10:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case tt.ASTC_SRGBA_12X10:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case tt.ASTC_SRGBA_12X12:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}(e.format,i),e.glFormat=function(t,e){switch(t){case tt.A8:return e.ALPHA;case tt.L8:return e.LUMINANCE;case tt.LA8:return e.LUMINANCE_ALPHA;case tt.R8:case tt.R8SN:return e.RED;case tt.R8UI:case tt.R8I:return e.RED;case tt.RG8:case tt.RG8SN:case tt.RG8UI:case tt.RG8I:return e.RG;case tt.RGB8:case tt.RGB8SN:case tt.RGB8UI:case tt.RGB8I:return e.RGB;case tt.BGRA8:case tt.RGBA8:case tt.RGBA8SN:case tt.RGBA8UI:case tt.RGBA8I:return e.RGBA;case tt.R16UI:case tt.R16I:case tt.R16F:return e.RED;case tt.RG16UI:case tt.RG16I:case tt.RG16F:return e.RG;case tt.RGB16UI:case tt.RGB16I:case tt.RGB16F:return e.RGB;case tt.RGBA16UI:case tt.RGBA16I:case tt.RGBA16F:return e.RGBA;case tt.R32UI:case tt.R32I:case tt.R32F:return e.RED;case tt.RG32UI:case tt.RG32I:case tt.RG32F:return e.RG;case tt.RGB32UI:case tt.RGB32I:case tt.RGB32F:return e.RGB;case tt.RGBA32UI:case tt.RGBA32I:case tt.RGBA32F:case tt.RGB10A2:return e.RGBA;case tt.R11G11B10F:case tt.R5G6B5:return e.RGB;case tt.RGB5A1:case tt.RGBA4:return e.RGBA;case tt.SRGB8:return e.RGB;case tt.SRGB8_A8:return e.RGBA;case tt.DEPTH:return e.DEPTH_COMPONENT;case tt.DEPTH_STENCIL:return e.DEPTH_STENCIL;case tt.BC1:return tX.COMPRESSED_RGB_S3TC_DXT1_EXT;case tt.BC1_ALPHA:return tX.COMPRESSED_RGBA_S3TC_DXT1_EXT;case tt.BC1_SRGB:return tX.COMPRESSED_SRGB_S3TC_DXT1_EXT;case tt.BC1_SRGB_ALPHA:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case tt.BC2:return tX.COMPRESSED_RGBA_S3TC_DXT3_EXT;case tt.BC2_SRGB:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case tt.BC3:return tX.COMPRESSED_RGBA_S3TC_DXT5_EXT;case tt.BC3_SRGB:return tX.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case tt.ETC_RGB8:return tX.COMPRESSED_RGB_ETC1_WEBGL;case tt.ETC2_RGB8:return tX.COMPRESSED_RGB8_ETC2;case tt.ETC2_SRGB8:return tX.COMPRESSED_SRGB8_ETC2;case tt.ETC2_RGB8_A1:return tX.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_SRGB8_A1:return tX.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case tt.ETC2_RGBA8:return tX.COMPRESSED_RGBA8_ETC2_EAC;case tt.ETC2_SRGB8_A8:return tX.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case tt.EAC_R11:return tX.COMPRESSED_R11_EAC;case tt.EAC_R11SN:return tX.COMPRESSED_SIGNED_R11_EAC;case tt.EAC_RG11:return tX.COMPRESSED_RG11_EAC;case tt.EAC_RG11SN:return tX.COMPRESSED_SIGNED_RG11_EAC;case tt.PVRTC_RGB2:return tX.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGBA2:return tX.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case tt.PVRTC_RGB4:return tX.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case tt.PVRTC_RGBA4:return tX.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case tt.ASTC_RGBA_4X4:return tX.COMPRESSED_RGBA_ASTC_4x4_KHR;case tt.ASTC_RGBA_5X4:return tX.COMPRESSED_RGBA_ASTC_5x4_KHR;case tt.ASTC_RGBA_5X5:return tX.COMPRESSED_RGBA_ASTC_5x5_KHR;case tt.ASTC_RGBA_6X5:return tX.COMPRESSED_RGBA_ASTC_6x5_KHR;case tt.ASTC_RGBA_6X6:return tX.COMPRESSED_RGBA_ASTC_6x6_KHR;case tt.ASTC_RGBA_8X5:return tX.COMPRESSED_RGBA_ASTC_8x5_KHR;case tt.ASTC_RGBA_8X6:return tX.COMPRESSED_RGBA_ASTC_8x6_KHR;case tt.ASTC_RGBA_8X8:return tX.COMPRESSED_RGBA_ASTC_8x8_KHR;case tt.ASTC_RGBA_10X5:return tX.COMPRESSED_RGBA_ASTC_10x5_KHR;case tt.ASTC_RGBA_10X6:return tX.COMPRESSED_RGBA_ASTC_10x6_KHR;case tt.ASTC_RGBA_10X8:return tX.COMPRESSED_RGBA_ASTC_10x8_KHR;case tt.ASTC_RGBA_10X10:return tX.COMPRESSED_RGBA_ASTC_10x10_KHR;case tt.ASTC_RGBA_12X10:return tX.COMPRESSED_RGBA_ASTC_12x10_KHR;case tt.ASTC_RGBA_12X12:return tX.COMPRESSED_RGBA_ASTC_12x12_KHR;case tt.ASTC_SRGBA_4X4:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case tt.ASTC_SRGBA_5X4:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case tt.ASTC_SRGBA_5X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case tt.ASTC_SRGBA_6X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case tt.ASTC_SRGBA_6X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case tt.ASTC_SRGBA_8X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case tt.ASTC_SRGBA_8X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case tt.ASTC_SRGBA_8X8:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case tt.ASTC_SRGBA_10X5:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case tt.ASTC_SRGBA_10X6:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case tt.ASTC_SRGBA_10X8:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case tt.ASTC_SRGBA_10X10:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case tt.ASTC_SRGBA_12X10:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case tt.ASTC_SRGBA_12X12:return tX.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),e.RGBA}}(e.format,i),e.glType=sX(e.format,i);var r=e.width,n=e.height;switch(e.type){case ot.TEX2D:if(e.glTarget=i.TEXTURE_2D,e.isSwapchainTexture)break;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Nn(9100,s,t.capabilities.maxTextureSize),e.samples===ct.ONE){if(e.glTexture=i.createTexture(),e.size>0){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var l=Je(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 i.texStorage2D(i.TEXTURE_2D,e.mipLevel,e.glInternalFmt,r,n)}}else e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case ot.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var u=Math.max(r,n);if(u>t.capabilities.maxCubeMapTextureSize&&Nn(9100,u,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var c=t.stateCache.glTexUnits[t.stateCache.texUnit];if(c.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),c.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var _=0;_<e.mipLevel;++_){for(var f=Je(e.format,r,n,1),d=new Uint8Array(f),p=0;p<6;++p)i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,e.glInternalFmt,r,n,0,d);r=Math.max(1,r>>1),n=Math.max(1,n>>1)}else i.texStorage2D(i.TEXTURE_CUBE_MAP,e.mipLevel,e.glInternalFmt,r,n)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=ot.TEX2D,e.glTarget=i.TEXTURE_2D}}function CX(t,e){var i=t.gl;if(e.glTexture){var r=t.stateCache.glTexUnits,n=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s<r.length;++s)r[s].glTexture===e.glTexture&&(i.activeTexture(i.TEXTURE0+s),n=s,i.bindTexture(e.glTarget,null),r[s].glTexture=null);t.stateCache.texUnit=n,e.glTexture=null}if(e.glRenderbuffer){var a=t.stateCache.glRenderbuffer;i.deleteRenderbuffer(e.glRenderbuffer),a===e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,null),a=null),e.glRenderbuffer=null}}var xX={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0,invalidateAttachments:[]};function wX(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),xX.invalidateAttachments.length=0;for(var u=0;u<n.length;++u){var c=e.colorAttachments[u];if(c.format!==tt.UNKNOWN)switch(c.loadOp){case St.LOAD:break;case St.CLEAR:if(l.bs.targets[0].blendColorMask!==vt.ALL&&o.colorMask(!0,!0,!0,!0),i.isOffscreen)nX[0]=n[u].x,nX[1]=n[u].y,nX[2]=n[u].z,nX[3]=n[u].w,o.clearBufferfv(o.COLOR,u,nX);else{var _=n[0];o.clearColor(_.x,_.y,_.z,_.w),h|=o.COLOR_BUFFER_BIT}break;case St.DISCARD:xX.invalidateAttachments.push(o.COLOR_ATTACHMENT0+u)}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==tt.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case St.LOAD:break;case St.CLEAR:l.dss.depthWrite||o.depthMask(!0),o.clearDepth(s),h|=o.DEPTH_BUFFER_BIT;break;case St.DISCARD:xX.invalidateAttachments.push(o.DEPTH_ATTACHMENT)}if(Xe[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case St.LOAD:break;case St.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 St.DISCARD:xX.invalidateAttachments.push(o.STENCIL_ATTACHMENT)}}if(i.glFramebuffer&&xX.invalidateAttachments.length&&o.invalidateFramebuffer(o.FRAMEBUFFER,xX.invalidateAttachments),h&&o.clear(h),h&o.COLOR_BUFFER_BIT){var f=l.bs.targets[0].blendColorMask;if(f!==vt.ALL){var d=(f&vt.R)!==vt.NONE,p=(f&vt.G)!==vt.NONE,m=(f&vt.B)!==vt.NONE,g=(f&vt.A)!==vt.NONE;o.colorMask(d,p,m,g)}}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 EX(t,e,i,r,n,s){var a=t.gl,o=t.stateCache,l=e&&e.gpuShader,h=!1;if(e&&xX.gpuPipelineState!==e){if(xX.gpuPipelineState=e,xX.glPrimitive=e.glPrimitive,l){var u=l.glProgram;o.glProgram!==u&&(a.useProgram(u),o.glProgram=u,h=!0)}var c=e.rs;if(c){if(o.rs.cullMode!==c.cullMode){switch(c.cullMode){case Rt.NONE:a.disable(a.CULL_FACE);break;case Rt.FRONT:a.enable(a.CULL_FACE),a.cullFace(a.FRONT);break;case Rt.BACK:a.enable(a.CULL_FACE),a.cullFace(a.BACK)}t.stateCache.rs.cullMode=c.cullMode}var _=c.isFrontFaceCCW;t.stateCache.rs.isFrontFaceCCW!==_&&(a.frontFace(_?a.CCW:a.CW),t.stateCache.rs.isFrontFaceCCW=_),t.stateCache.rs.depthBias===c.depthBias&&t.stateCache.rs.depthBiasSlop===c.depthBiasSlop||(a.polygonOffset(c.depthBias,c.depthBiasSlop),t.stateCache.rs.depthBias=c.depthBias,t.stateCache.rs.depthBiasSlop=c.depthBiasSlop),t.stateCache.rs.lineWidth!==c.lineWidth&&(a.lineWidth(c.lineWidth),t.stateCache.rs.lineWidth=c.lineWidth)}var f=e.dss;f&&(o.dss.depthTest!==f.depthTest&&(f.depthTest?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),o.dss.depthTest=f.depthTest),o.dss.depthWrite!==f.depthWrite&&(a.depthMask(f.depthWrite),o.dss.depthWrite=f.depthWrite),o.dss.depthFunc!==f.depthFunc&&(a.depthFunc(cX[f.depthFunc]),o.dss.depthFunc=f.depthFunc),o.dss.stencilTestFront===f.stencilTestFront&&o.dss.stencilTestBack===f.stencilTestBack||(f.stencilTestFront||f.stencilTestBack?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),o.dss.stencilTestFront=f.stencilTestFront,o.dss.stencilTestBack=f.stencilTestBack),o.dss.stencilFuncFront===f.stencilFuncFront&&o.dss.stencilRefFront===f.stencilRefFront&&o.dss.stencilReadMaskFront===f.stencilReadMaskFront||(a.stencilFuncSeparate(a.FRONT,cX[f.stencilFuncFront],f.stencilRefFront,f.stencilReadMaskFront),o.dss.stencilFuncFront=f.stencilFuncFront,o.dss.stencilRefFront=f.stencilRefFront,o.dss.stencilReadMaskFront=f.stencilReadMaskFront),o.dss.stencilFailOpFront===f.stencilFailOpFront&&o.dss.stencilZFailOpFront===f.stencilZFailOpFront&&o.dss.stencilPassOpFront===f.stencilPassOpFront||(a.stencilOpSeparate(a.FRONT,_X[f.stencilFailOpFront],_X[f.stencilZFailOpFront],_X[f.stencilPassOpFront]),o.dss.stencilFailOpFront=f.stencilFailOpFront,o.dss.stencilZFailOpFront=f.stencilZFailOpFront,o.dss.stencilPassOpFront=f.stencilPassOpFront),o.dss.stencilWriteMaskFront!==f.stencilWriteMaskFront&&(a.stencilMaskSeparate(a.FRONT,f.stencilWriteMaskFront),o.dss.stencilWriteMaskFront=f.stencilWriteMaskFront),o.dss.stencilFuncBack===f.stencilFuncBack&&o.dss.stencilRefBack===f.stencilRefBack&&o.dss.stencilReadMaskBack===f.stencilReadMaskBack||(a.stencilFuncSeparate(a.BACK,cX[f.stencilFuncBack],f.stencilRefBack,f.stencilReadMaskBack),o.dss.stencilFuncBack=f.stencilFuncBack,o.dss.stencilRefBack=f.stencilRefBack,o.dss.stencilReadMaskBack=f.stencilReadMaskBack),o.dss.stencilFailOpBack===f.stencilFailOpBack&&o.dss.stencilZFailOpBack===f.stencilZFailOpBack&&o.dss.stencilPassOpBack===f.stencilPassOpBack||(a.stencilOpSeparate(a.BACK,_X[f.stencilFailOpBack],_X[f.stencilZFailOpBack],_X[f.stencilPassOpBack]),o.dss.stencilFailOpBack=f.stencilFailOpBack,o.dss.stencilZFailOpBack=f.stencilZFailOpBack,o.dss.stencilPassOpBack=f.stencilPassOpBack),o.dss.stencilWriteMaskBack!==f.stencilWriteMaskBack&&(a.stencilMaskSeparate(a.BACK,f.stencilWriteMaskBack),o.dss.stencilWriteMaskBack=f.stencilWriteMaskBack));var d=e.bs;if(d){o.bs.isA2C!==d.isA2C&&(d.isA2C?a.enable(a.SAMPLE_ALPHA_TO_COVERAGE):a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),o.bs.isA2C=d.isA2C),o.bs.blendColor.x===d.blendColor.x&&o.bs.blendColor.y===d.blendColor.y&&o.bs.blendColor.z===d.blendColor.z&&o.bs.blendColor.w===d.blendColor.w||(a.blendColor(d.blendColor.x,d.blendColor.y,d.blendColor.z,d.blendColor.w),o.bs.blendColor.x=d.blendColor.x,o.bs.blendColor.y=d.blendColor.y,o.bs.blendColor.z=d.blendColor.z,o.bs.blendColor.w=d.blendColor.w);var p=d.targets[0],m=o.bs.targets[0];m.blend!==p.blend&&(p.blend?a.enable(a.BLEND):a.disable(a.BLEND),m.blend=p.blend),m.blendEq===p.blendEq&&m.blendAlphaEq===p.blendAlphaEq||(a.blendEquationSeparate(fX[p.blendEq],fX[p.blendAlphaEq]),m.blendEq=p.blendEq,m.blendAlphaEq=p.blendAlphaEq),m.blendSrc===p.blendSrc&&m.blendDst===p.blendDst&&m.blendSrcAlpha===p.blendSrcAlpha&&m.blendDstAlpha===p.blendDstAlpha||(a.blendFuncSeparate(dX[p.blendSrc],dX[p.blendDst],dX[p.blendSrcAlpha],dX[p.blendDstAlpha]),m.blendSrc=p.blendSrc,m.blendDst=p.blendDst,m.blendSrcAlpha=p.blendSrcAlpha,m.blendDstAlpha=p.blendDstAlpha),m.blendColorMask!==p.blendColorMask&&(a.colorMask((p.blendColorMask&vt.R)!==vt.NONE,(p.blendColorMask&vt.G)!==vt.NONE,(p.blendColorMask&vt.B)!==vt.NONE,(p.blendColorMask&vt.A)!==vt.NONE),m.blendColorMask=p.blendColorMask)}}if(e&&e.gpuPipelineLayout&&l){for(var g=l.glBlocks.length,y=e.gpuPipelineLayout.dynamicOffsetIndices,v=0;v<g;v++){var b=l.glBlocks[v],S=r[b.set],A=S&&S.descriptorIndices[b.binding],T=A>=0&&S.gpuDescriptors[A];if(T&&T.gpuBuffer){var C=y[b.set],x=C&&C[b.binding],w=T.gpuBuffer.glOffset;x>=0&&(w+=n[x]),o.glBindUBOs[b.glBinding]===T.gpuBuffer.glBuffer&&o.glBindUBOOffsets[b.glBinding]===w||(w?a.bindBufferRange(a.UNIFORM_BUFFER,b.glBinding,T.gpuBuffer.glBuffer,w,T.gpuBuffer.size):a.bindBufferBase(a.UNIFORM_BUFFER,b.glBinding,T.gpuBuffer.glBuffer),o.glUniformBuffer=o.glBindUBOs[b.glBinding]=T.gpuBuffer.glBuffer,o.glBindUBOOffsets[b.glBinding]=w)}else Ja("Buffer binding '"+b.name+"' at set "+b.set+" binding "+b.binding+" is not bounded")}for(var E=l.glSamplerTextures.length,B=0;B<E;B++)for(var R=l.glSamplerTextures[B],D=r[R.set],M=D&&D.descriptorIndices[R.binding],P=M>=0&&D.gpuDescriptors[M],I=0;I<R.units.length;I++){var O=R.units[I],F=o.glTexUnits[O];if(P&&P.gpuTextureView&&P.gpuTextureView.gpuTexture&&P.gpuSampler){var L=P.gpuTextureView,k=L.gpuTexture,V=L.baseLevel,N=V+L.levelCount;if(k.size>0){F.glTexture!==k.glTexture&&(o.texUnit!==O&&(a.activeTexture(a.TEXTURE0+O),o.texUnit=O),k.glTexture?a.bindTexture(k.glTarget,k.glTexture):a.bindTexture(k.glTarget,t.nullTex2D.gpuTexture.glTexture),F.glTexture=k.glTexture);var G=P.gpuSampler.getGLSampler(t,V,N);o.glSamplerUnits[O]!==G&&(a.bindSampler(O,G),o.glSamplerUnits[O]=G)}P=D.gpuDescriptors[++M]}else Ja("Sampler binding '"+R.name+"' at set "+R.set+" binding "+R.binding+" index "+I+" is not bounded")}}if(i&&l&&(h||xX.gpuInputAssembler!==i))if(xX.gpuInputAssembler=i,t.extensions.useVAO){var z=i.glVAOs.get(l.glProgram);if(!z){var U;z=a.createVertexArray(),i.glVAOs.set(l.glProgram,z),a.bindVertexArray(z),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),o.glArrayBuffer=null,o.glElementArrayBuffer=null;for(var H=0;H<l.glInputs.length;H++){var X=l.glInputs[H];U=null;for(var W=0;W<i.glAttribs.length;W++){var j=i.glAttribs[W];if(j.name===X.name){U=j;break}}if(U){o.glArrayBuffer!==U.glBuffer&&(a.bindBuffer(a.ARRAY_BUFFER,U.glBuffer),o.glArrayBuffer=U.glBuffer);for(var Y=0;Y<U.componentCount;++Y){var q=X.glLoc+Y,K=U.offset+U.size*Y;a.enableVertexAttribArray(q),o.glCurrentAttribLocs[q]=!0,a.vertexAttribPointer(q,U.count,U.glType,U.isNormalized,U.stride,K),a.vertexAttribDivisor(q,U.isInstanced?1:0)}}}var J=i.gpuIndexBuffer;J&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,J.glBuffer),a.bindVertexArray(null),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),o.glArrayBuffer=null,o.glElementArrayBuffer=null}o.glVAO!==z&&(a.bindVertexArray(z),o.glVAO=z)}else{for(var Z=0;Z<t.capabilities.maxVertexAttributes;++Z)o.glCurrentAttribLocs[Z]=!1;for(var Q=0;Q<l.glInputs.length;Q++){for(var $=l.glInputs[Q],tt=null,et=0;et<i.glAttribs.length;et++){var it=i.glAttribs[et];if(it.name===$.name){tt=it;break}}if(tt){o.glArrayBuffer!==tt.glBuffer&&(a.bindBuffer(a.ARRAY_BUFFER,tt.glBuffer),o.glArrayBuffer=tt.glBuffer);for(var rt=0;rt<tt.componentCount;++rt){var nt=$.glLoc+rt,st=tt.offset+tt.size*rt;!o.glEnabledAttribLocs[nt]&&nt>=0&&(a.enableVertexAttribArray(nt),o.glEnabledAttribLocs[nt]=!0),o.glCurrentAttribLocs[nt]=!0,a.vertexAttribPointer(nt,tt.count,tt.glType,tt.isNormalized,tt.stride,st),a.vertexAttribDivisor(nt,tt.isInstanced?1:0)}}}var at=i.gpuIndexBuffer;at&&o.glElementArrayBuffer!==at.glBuffer&&(a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,at.glBuffer),o.glElementArrayBuffer=at.glBuffer);for(var ot=0;ot<t.capabilities.maxVertexAttributes;++ot)o.glEnabledAttribLocs[ot]!==o.glCurrentAttribLocs[ot]&&(a.disableVertexAttribArray(ot),o.glEnabledAttribLocs[ot]=!1)}if(e&&e.dynamicStates.length)for(var lt=e.dynamicStates.length,ht=0;ht<lt;ht++)switch(e.dynamicStates[ht]){case Dt.LINE_WIDTH:o.rs.lineWidth!==s.lineWidth&&(a.lineWidth(s.lineWidth),o.rs.lineWidth=s.lineWidth);break;case Dt.DEPTH_BIAS:o.rs.depthBias===s.depthBiasConstant&&o.rs.depthBiasSlop===s.depthBiasSlope||(a.polygonOffset(s.depthBiasConstant,s.depthBiasSlope),o.rs.depthBias=s.depthBiasConstant,o.rs.depthBiasSlop=s.depthBiasSlope);break;case Dt.BLEND_CONSTANTS:var ut=s.blendConstant;o.bs.blendColor.x===ut.x&&o.bs.blendColor.y===ut.y&&o.bs.blendColor.z===ut.z&&o.bs.blendColor.w===ut.w||(a.blendColor(ut.x,ut.y,ut.z,ut.w),o.bs.blendColor.copy(ut));break;case Dt.STENCIL_WRITE_MASK:var ct=s.stencilStatesFront,_t=s.stencilStatesBack;o.dss.stencilWriteMaskFront!==ct.writeMask&&(a.stencilMaskSeparate(a.FRONT,ct.writeMask),o.dss.stencilWriteMaskFront=ct.writeMask),o.dss.stencilWriteMaskBack!==_t.writeMask&&(a.stencilMaskSeparate(a.BACK,_t.writeMask),o.dss.stencilWriteMaskBack=_t.writeMask);break;case Dt.STENCIL_COMPARE_MASK:var ft=s.stencilStatesFront,dt=s.stencilStatesBack;o.dss.stencilRefFront===ft.reference&&o.dss.stencilReadMaskFront===ft.compareMask||(a.stencilFuncSeparate(a.FRONT,cX[o.dss.stencilFuncFront],ft.reference,ft.compareMask),o.dss.stencilRefFront=ft.reference,o.dss.stencilReadMaskFront=ft.compareMask),o.dss.stencilRefBack===dt.reference&&o.dss.stencilReadMaskBack===dt.compareMask||(a.stencilFuncSeparate(a.BACK,cX[o.dss.stencilFuncBack],dt.reference,dt.compareMask),o.dss.stencilRefBack=dt.reference,o.dss.stencilReadMaskBack=dt.compareMask)}}function BX(t,e){var i=t.gl,r=xX.gpuInputAssembler,n=xX.glPrimitive,s=t.extensions.WEBGL_multi_draw;if(r){var a=r.gpuIndexBuffer;if(r.gpuIndirectBuffer){var o=r.gpuIndirectBuffer.indirects;if(o.drawByIndex){for(var l=0;l<o.drawCount;l++)o.byteOffsets[l]=o.offsets[l]*a.stride;if(s)o.instancedDraw?s.multiDrawElementsInstancedWEBGL(n,o.counts,0,r.glIndexType,o.byteOffsets,0,o.instances,0,o.drawCount):s.multiDrawElementsWEBGL(n,o.counts,0,r.glIndexType,o.byteOffsets,0,o.drawCount);else for(var h=0;h<o.drawCount;h++)o.instances[h]?i.drawElementsInstanced(n,o.counts[h],r.glIndexType,o.byteOffsets[h],o.instances[h]):i.drawElements(n,o.counts[h],r.glIndexType,o.byteOffsets[h])}else if(s)o.instancedDraw?s.multiDrawArraysInstancedWEBGL(n,o.offsets,0,o.counts,0,o.instances,0,o.drawCount):s.multiDrawArraysWEBGL(n,o.offsets,0,o.counts,0,o.drawCount);else for(var u=0;u<o.drawCount;u++)o.instances[u]?i.drawArraysInstanced(n,o.offsets[u],o.counts[u],o.instances[u]):i.drawArrays(n,o.offsets[u],o.counts[u])}else if(e.instanceCount)if(a){if(e.indexCount>0){var c=e.firstIndex*a.stride;i.drawElementsInstanced(n,e.indexCount,r.glIndexType,c,e.instanceCount)}}else e.vertexCount>0&&i.drawArraysInstanced(n,e.firstVertex,e.vertexCount,e.instanceCount);else if(a){if(e.indexCount>0){var _=e.firstIndex*a.stride;i.drawElements(n,e.indexCount,r.glIndexType,_)}}else e.vertexCount>0&&i.drawArrays(n,e.firstVertex,e.vertexCount)}}var RX=new Array(uX.COUNT);function DX(t,e){RX.fill(0);for(var i=0;i<e.cmds.length;++i){var r=e.cmds.array[i],n=RX[r]++;switch(r){case uX.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[n];wX(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case uX.BIND_STATES:var a=e.bindStatesCmds.array[n];EX(t,a.gpuPipelineState,a.gpuInputAssembler,a.gpuDescriptorSets,a.dynamicOffsets,a.dynamicStates);break;case uX.DRAW:BX(t,e.drawCmds.array[n].drawInfo);break;case uX.UPDATE_BUFFER:var o=e.updateBufferCmds.array[n];AX(t,o.gpuBuffer,o.buffer,o.offset,o.size);break;case uX.COPY_BUFFER_TO_TEXTURE:var l=e.copyBufferToTextureCmds.array[n];IX(t,l.buffers,l.gpuTexture,l.regions)}}}var MX=new Uint8Array(1);function PX(t,e,i,r,n){var s=ti(e).height,a=Je(e,n.width,n.height,n.depth),o=Je(e,r.width,1,1),l=Je(e,r.width,r.height,1),h=Je(e,n.width,1,1),u=$e(Xe[e]);MX.byteLength<a&&(MX=new Uint8Array(a));for(var c=0,_=i,f=0;f<n.depth;f++){_=i+l*f;for(var d=0;d<n.height;d+=s)MX.subarray(c,c+h).set(new Uint8Array(t.buffer,t.byteOffset+_,h)),c+=h,_+=o}return new u(MX.buffer)}function IX(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,l=Xe[i.format],h=$e(l),u=l.isCompressed,c=ti(i.format),_=new Xt,f=new Ut,d=new Xt;switch(i.glTarget){case n.TEXTURE_2D:for(var p=0;p<r.length;p++){var m=r[p],g=m.texSubres.mipLevel;f.x=0===m.texOffset.x?0:ei(m.texOffset.x,c.width),f.y=0===m.texOffset.y?0:ei(m.texOffset.y,c.height),_.width=m.texExtent.width<c.width?m.texExtent.width:ei(m.texExtent.width,c.width),_.height=m.texExtent.height<c.height?m.texExtent.width:ei(m.texExtent.height,c.height),d.width=m.buffStride>0?m.buffStride:_.width,d.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var y,v=m.texExtent.width+f.x===i.width>>g?m.texExtent.width:_.width,b=m.texExtent.height+f.y===i.height>>g?m.texExtent.height:_.height,S=e[a++];y=d.width===_.width&&d.height===_.height?new h(S.buffer,S.byteOffset+m.buffOffset):PX(S,i.format,m.buffOffset,d,_),u?i.glInternalFmt!==tX.COMPRESSED_RGB_ETC1_WEBGL?n.compressedTexSubImage2D(n.TEXTURE_2D,g,f.x,f.y,v,b,i.glFormat,y):n.compressedTexImage2D(n.TEXTURE_2D,g,i.glInternalFmt,v,b,0,y):n.texSubImage2D(n.TEXTURE_2D,g,f.x,f.y,v,b,i.glFormat,i.glType,y)}break;case n.TEXTURE_2D_ARRAY:for(var A=0;A<r.length;A++){var T=r[A],C=T.texSubres.mipLevel;f.x=0===T.texOffset.x?0:ei(T.texOffset.x,c.width),f.y=0===T.texOffset.y?0:ei(T.texOffset.y,c.height),_.width=T.texExtent.width<c.width?T.texExtent.width:ei(T.texExtent.width,c.width),_.height=T.texExtent.height<c.height?T.texExtent.width:ei(T.texExtent.height,c.height),_.depth=1,d.width=T.buffStride>0?T.buffStride:_.width,d.height=T.buffTexHeight>0?T.buffTexHeight:_.height;var x=T.texExtent.width+f.x===i.width>>C?T.texExtent.width:_.width,w=T.texExtent.height+f.y===i.height>>C?T.texExtent.height:_.height,E=T.texSubres.baseArrayLayer+T.texSubres.layerCount;for(o=T.texSubres.baseArrayLayer;o<E;++o){f.z=o;var B,R=e[a++];B=d.width===_.width&&d.height===_.height?new h(R.buffer,R.byteOffset+T.buffOffset):PX(R,i.format,T.buffOffset,d,_),u?i.glInternalFmt!==tX.COMPRESSED_RGB_ETC1_WEBGL?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,C,f.x,f.y,f.z,x,w,_.depth,i.glFormat,B):n.compressedTexImage3D(n.TEXTURE_2D_ARRAY,C,i.glInternalFmt,x,w,_.depth,0,B):n.texSubImage3D(n.TEXTURE_2D_ARRAY,C,f.x,f.y,f.z,x,w,_.depth,i.glFormat,i.glType,B)}}break;case n.TEXTURE_3D:for(var D=0;D<r.length;D++){var M=r[D],P=M.texSubres.mipLevel;f.x=0===M.texOffset.x?0:ei(M.texOffset.x,c.width),f.y=0===M.texOffset.y?0:ei(M.texOffset.y,c.height),f.z=M.texOffset.z,_.width=M.texExtent.width<c.width?M.texExtent.width:ei(M.texExtent.width,c.width),_.height=M.texExtent.height<c.height?M.texExtent.width:ei(M.texExtent.height,c.height),_.depth=M.texExtent.depth,d.width=M.buffStride>0?M.buffStride:_.width,d.height=M.buffTexHeight>0?M.buffTexHeight:_.height;var I,O=M.texExtent.width+f.x===i.width>>P?M.texExtent.width:_.width,F=M.texExtent.height+f.y===i.height>>P?M.texExtent.height:_.height,L=e[a++];I=d.width===_.width&&d.height===_.height?new h(L.buffer,L.byteOffset+M.buffOffset):PX(L,i.format,M.buffOffset,d,_),u?i.glInternalFmt!==tX.COMPRESSED_RGB_ETC1_WEBGL?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,P,f.x,f.y,f.z,O,F,_.depth,i.glFormat,I):n.compressedTexImage3D(n.TEXTURE_2D_ARRAY,P,i.glInternalFmt,O,F,_.depth,0,I):n.texSubImage3D(n.TEXTURE_2D_ARRAY,P,f.x,f.y,f.z,O,F,_.depth,i.glFormat,i.glType,I)}break;case n.TEXTURE_CUBE_MAP:for(var k=0;k<r.length;k++){var V=r[k],N=V.texSubres.mipLevel;f.x=0===V.texOffset.x?0:ei(V.texOffset.x,c.width),f.y=0===V.texOffset.y?0:ei(V.texOffset.y,c.height),_.width=V.texExtent.width<c.width?V.texExtent.width:ei(V.texExtent.width,c.width),_.height=V.texExtent.height<c.height?V.texExtent.width:ei(V.texExtent.height,c.height),d.width=V.buffStride>0?V.buffStride:_.width,d.height=V.buffTexHeight>0?V.buffTexHeight:_.height;var G=V.texExtent.width+f.x===i.width>>N?V.texExtent.width:_.width,z=V.texExtent.height+f.y===i.height>>N?V.texExtent.height:_.height,U=V.texSubres.baseArrayLayer+V.texSubres.layerCount;for(o=V.texSubres.baseArrayLayer;o<U;++o){var H,X=e[a++];H=d.width===_.width&&d.height===_.height?new h(X.buffer,X.byteOffset+V.buffOffset):PX(X,i.format,V.buffOffset,d,_),u?i.glInternalFmt!==tX.COMPRESSED_RGB_ETC1_WEBGL?n.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,N,f.x,f.y,G,z,i.glFormat,H):n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,N,i.glInternalFmt,G,z,0,H):n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,N,f.x,f.y,G,z,i.glFormat,i.glType,H)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&ht.GEN_MIPMAP&&n.generateMipmap(i.glTarget)}var OX=function(){function t(){this.counts=void 0,this.offsets=void 0,this.instances=void 0,this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1,this.byteOffsets=void 0,this._capacity=4,this.counts=new Int32Array(this._capacity),this.offsets=new Int32Array(this._capacity),this.instances=new Int32Array(this._capacity),this.byteOffsets=new Int32Array(this._capacity)}var e=t.prototype;return e.clearDraws=function(){this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1},e.setDrawInfo=function(t,e){this._ensureCapacity(t),this.drawByIndex=e.indexCount>0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=Sn(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),r=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),r.set(this.instances),this.counts=e,this.offsets=i,this.instances=r}},t}(),FX=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}on(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._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:e.gpuBuffer.indirects,glTarget:e.gpuBuffer.glTarget,glBuffer:e.gpuBuffer.glBuffer,glOffset:t.offset}}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._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:new OX,glTarget:0,glBuffer:null,glOffset:0},function(t,e){var i=t.gl,r=t.stateCache,n=e.memUsage&at.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&rt.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.extensions.useVAO&&r.glVAO&&(i.bindVertexArray(null),r.glVAO=null),xX.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&rt.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&r.glVAO&&(i.bindVertexArray(null),r.glVAO=null),xX.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 if(e.usage&rt.UNIFORM){e.glTarget=i.UNIFORM_BUFFER;var o=i.createBuffer();o&&e.size>0&&(e.glBuffer=o,t.stateCache.glUniformBuffer!==e.glBuffer&&(i.bindBuffer(i.UNIFORM_BUFFER,e.glBuffer),t.stateCache.glUniformBuffer=e.glBuffer),i.bufferData(i.UNIFORM_BUFFER,e.size,n),i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null)}else e.usage&rt.INDIRECT||e.usage&rt.TRANSFER_DST||e.usage&rt.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE}(iX.instance,this._gpuBuffer),iX.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(t,e){var i=t.gl,r=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&r.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),xX.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&r.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),xX.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null;break;case i.UNIFORM_BUFFER:i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}(iX.instance,this._gpuBuffer),iX.instance.memoryStatus.bufferSize-=this._size),this._gpuBuffer=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._gpuBuffer&&(this._gpuBuffer.size=t,t>0&&(e=iX.instance,i=this._gpuBuffer,r=e.gl,n=e.stateCache,s=i.memUsage&at.HOST?r.DYNAMIC_DRAW:r.STATIC_DRAW,i.usage&rt.VERTEX?(e.extensions.useVAO&&n.glVAO&&(r.bindVertexArray(null),n.glVAO=null),xX.gpuInputAssembler=null,n.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),n.glArrayBuffer=null):i.usage&rt.INDEX?(e.extensions.useVAO&&n.glVAO&&(r.bindVertexArray(null),n.glVAO=null),xX.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&rt.UNIFORM?(e.stateCache.glUniformBuffer!==i.glBuffer&&r.bindBuffer(r.UNIFORM_BUFFER,i.glBuffer),r.bufferData(r.UNIFORM_BUFFER,i.size,s),r.bindBuffer(r.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null):(i.usage&rt.INDIRECT||i.usage&rt.TRANSFER_DST||i.usage&rt.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),i.glTarget=r.NONE),iX.instance.memoryStatus.bufferSize-=a,iX.instance.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&rt.INDIRECT?0:t.byteLength,AX(iX.instance,this._gpuBuffer,t,0,i))},Ur(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),e}(Y),LX=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new W(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}(),kX=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 LX(mX,1),this.bindStatesCmdPool=new LX(gX,1),this.drawCmdPool=new LX(yX,1),this.updateBufferCmdPool=new LX(vX,1),this.copyBufferToTextureCmdPool=new LX(bX,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}(),VX=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 SX,e._cmdAllocator=new kX,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUDescriptorSets=[],e._curGPUInputAssembler=null,e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new ze,e._isStateInvalied=!1,e}on(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=iX.instance.bindingMappings.blockOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null)},i.destroy=function(){this._cmdAllocator.clearCmds(this.cmdPackage)},i.begin=function(){this._cmdAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0,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._cmdAllocator.beginRenderPassCmdPool.alloc(mX);a.gpuRenderPass=t.gpuRenderPass,a.gpuFramebuffer=e.gpuFramebuffer,a.renderArea.copy(i);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(uX.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){var n,s=null===(n=this._curGPUPipelineState)||void 0===n?void 0:n.gpuPipelineLayout;if(s){for(var a=this._curDynamicOffsets,o=s.dynamicOffsetOffsets[t],l=0;l<i.length;l++)a[o+l]=i[l];this._isStateInvalied=!0}}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){var e=this._curDynamicStates.viewport;e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height&&e.minDepth===t.minDepth&&e.maxDepth===t.maxDepth||(e.left=t.left,e.top=t.top,e.width=t.width,e.height=t.height,e.minDepth=t.minDepth,e.maxDepth=t.maxDepth,this._isStateInvalied=!0)},i.setScissor=function(t){var e=this._curDynamicStates.scissor;e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,this._isStateInvalied=!0)},i.setLineWidth=function(t){this._curDynamicStates.lineWidth!==t&&(this._curDynamicStates.lineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){var r=this._curDynamicStates;r.depthBiasConstant===t&&r.depthBiasClamp===e&&r.depthBiasSlope===i||(r.depthBiasConstant=t,r.depthBiasClamp=e,r.depthBiasSlope=i,this._isStateInvalied=!0)},i.setBlendConstants=function(t){var e=this._curDynamicStates.blendConstant;e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w||(e.copy(t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){var i=this._curDynamicStates;i.depthMinBounds===t&&i.depthMaxBounds===e||(i.depthMinBounds=t,i.depthMaxBounds=e,this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){var i=this._curDynamicStates.stencilStatesFront,r=this._curDynamicStates.stencilStatesBack;t&Mt.FRONT&&i.writeMask!==e&&(i.writeMask=e,this._isStateInvalied=!0),t&Mt.BACK&&r.writeMask!==e&&(r.writeMask=e,this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){var r=this._curDynamicStates.stencilStatesFront,n=this._curDynamicStates.stencilStatesBack;t&Mt.FRONT&&(r.compareMask===i&&r.reference===e||(r.reference=e,r.compareMask=i,this._isStateInvalied=!0)),t&Mt.BACK&&(n.compareMask===i&&n.reference===e||(n.reference=e,n.compareMask=i,this._isStateInvalied=!0))},i.draw=function(t){if(this._type===Ft.PRIMARY&&this._isInRenderPass||this._type===Ft.SECONDARY){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t,i=this._cmdAllocator.drawCmdPool.alloc(yX);i.drawInfo.copy(e),this.cmdPackage.drawCmds.push(i),this.cmdPackage.cmds.push(uX.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var r=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=r/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(r-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===Ft.PRIMARY&&!this._isInRenderPass||this._type===Ft.SECONDARY){var r=t.gpuBuffer;if(r){var n,s=this._cmdAllocator.updateBufferCmdPool.alloc(vX),a=0;t.usage&rt.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(uX.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===Ft.PRIMARY&&!this._isInRenderPass||this._type===Ft.SECONDARY){var r=e.gpuTexture;if(r){var n=this._cmdAllocator.copyBufferToTextureCmdPool.alloc(bX);n.gpuTexture=r,n.regions=i,n.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(n),this.cmdPackage.cmds.push(uX.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._cmdAllocator.bindStatesCmdPool.alloc(gX);t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets),Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets),t.gpuInputAssembler=this._curGPUInputAssembler,t.dynamicStates=this._curDynamicStates,this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(uX.BIND_STATES),this._isStateInvalied=!1},e}(q),NX=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null;for(var e=[],i=0;i<t.colorTextures.length;i++){var r=t.colorTextures[i];r&&e.push(r.gpuTextureView)}var n=null;t.depthStencilTexture&&(n=t.depthStencilTexture.gpuTextureView);var s=Number.MAX_SAFE_INTEGER;this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorViews:e,gpuDepthStencilView:n,glFramebuffer:null,isOffscreen:!0,get width(){return this.isOffscreen?s:this.gpuColorViews.length>0?this.gpuColorViews[0].gpuTexture.width:this.gpuDepthStencilView.gpuTexture.width},set width(t){s=t},get height(){return this.isOffscreen?s:this.gpuColorViews.length>0?this.gpuColorViews[0].gpuTexture.height:this.gpuDepthStencilView.gpuTexture.height},set height(t){}},function(t,e){for(var i=0;i<e.gpuColorViews.length;++i)if(e.gpuColorViews[i].gpuTexture.isSwapchainTexture)return void(e.isOffscreen=!1);var r=t.gl,n=[],s=r.createFramebuffer();if(s){e.glFramebuffer=s,t.stateCache.glFramebuffer!==e.glFramebuffer&&r.bindFramebuffer(r.FRAMEBUFFER,e.glFramebuffer);for(var a=0;a<e.gpuColorViews.length;++a){var o=e.gpuColorViews[a],l=o.gpuTexture;l&&(l.glTexture?r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,l.glTarget,l.glTexture,o.baseLevel):r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,r.RENDERBUFFER,l.glRenderbuffer),n.push(r.COLOR_ATTACHMENT0+a),e.width=Math.min(e.width,l.width>>o.baseLevel),e.height=Math.min(e.height,l.height>>o.baseLevel))}var h=e.gpuDepthStencilView;if(h){var u=h.gpuTexture,c=Xe[u.format].hasStencil?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;u.glTexture?r.framebufferTexture2D(r.FRAMEBUFFER,c,u.glTarget,u.glTexture,e.gpuDepthStencilView.baseLevel):r.framebufferRenderbuffer(r.FRAMEBUFFER,c,r.RENDERBUFFER,u.glRenderbuffer),e.width=Math.min(e.width,u.width>>h.baseLevel),e.height=Math.min(e.height,u.height>>h.baseLevel)}r.drawBuffers(n);var _=r.checkFramebufferStatus(r.FRAMEBUFFER);if(_!==r.FRAMEBUFFER_COMPLETE)switch(_){case r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case r.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&r.bindFramebuffer(r.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(iX.instance,this._gpuFramebuffer)},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=iX.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null)},Ur(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(ni),GX=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}on(e,t);var i=e.prototype;return i.initialize=function(t){if(0!==t.vertexBuffers.length){if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._drawInfo.indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._drawInfo.firstIndex=0;else{var e=this._vertexBuffers[0];this._drawInfo.vertexCount=e.size/e.stride,this._drawInfo.firstVertex=0,this._drawInfo.vertexOffset=0}this._drawInfo.instanceCount=0,this._drawInfo.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("Illegal index buffer stride.")}var o=null;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=sX(s.format,i),h=Xe[s.format].size;e.glAttribs[n]={name:s.name,glBuffer:o.glBuffer,glType:l,size:h,count:Xe[s.format].count,stride:o.stride,componentCount:hX(l,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:r[a]},r[a]+=h}}(iX.instance,this._gpuInputAssembler)}else console.error("InputAssemblerInfo.vertexBuffers is null.")},i.destroy=function(){var t=iX.instance;this._gpuInputAssembler&&t.extensions.useVAO&&function(t,e){for(var i=e.glVAOs.values(),r=i.next(),n=t.gl,s=t.stateCache.glVAO;!r.done;)n.deleteVertexArray(r.value),s===r.value&&(n.bindVertexArray(null),s=null),r=i.next();t.stateCache.glVAO=s,e.glVAOs.clear()}(t,this._gpuInputAssembler),this._gpuInputAssembler=null},Ur(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}(si),zX=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}on(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&Ye)for(var _=0;_<c.count;_++)h.push(c.binding)}this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:h,descriptorIndices:a,descriptorCount:e}},i.destroy=function(){this._bindings.length=0},Ur(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(ai),UX=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}on(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=[],s=0;s<this._setLayouts.length;s++){for(var a=this._setLayouts[s],o=a.gpuDescriptorSetLayout.dynamicBindings,l=Array(a.bindingIndices.length).fill(-1),h=0;h<o.length;h++){var u=o[h];l[u]<0&&(l[u]=r+h)}i.push(a.gpuDescriptorSetLayout),e.push(l),n.push(r),r+=o.length}this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:r,dynamicOffsetOffsets:n}},i.destroy=function(){this._setLayouts.length=0},Ur(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(oi),HX=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],XX=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}on(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);this._gpuPipelineState={glPrimitive:HX[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}},i.destroy=function(){this._gpuPipelineState=null},Ur(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(fi),WX=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,r,n,s){wX(iX.instance,t.gpuRenderPass,e.gpuFramebuffer,i,r,n,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t;BX(iX.instance,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var i=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.setViewport=function(t){var e=iX.instance,i=e.stateCache,r=e.gl;i.viewport.left===t.left&&i.viewport.top===t.top&&i.viewport.width===t.width&&i.viewport.height===t.height||(r.viewport(t.left,t.top,t.width,t.height),i.viewport.left=t.left,i.viewport.top=t.top,i.viewport.width=t.width,i.viewport.height=t.height)},i.setScissor=function(t){var e=iX.instance,i=e.stateCache,r=e.gl;i.scissorRect.x===t.x&&i.scissorRect.y===t.y&&i.scissorRect.width===t.width&&i.scissorRect.height===t.height||(r.scissor(t.x,t.y,t.width,t.height),i.scissorRect.x=t.x,i.scissorRect.y=t.y,i.scissorRect.width=t.width,i.scissorRect.height=t.height)},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&rt.INDIRECT?0:e.byteLength,AX(iX.instance,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&&IX(iX.instance,t,r,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var r=t[i];DX(iX.instance,r.cmdPackage),this._numDrawCalls+=r._numDrawCalls,this._numInstances+=r._numInstances,this._numTris+=r._numTris}},i.bindStates=function(){EX(iX.instance,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,this._curDynamicOffsets,this._curDynamicStates),this._isStateInvalied=!1},e}(VX),jX=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type},i.destroy=function(){},i.submit=function(t){for(var e=0;e<t.length;e++){var i=t[e];this.numDrawCalls+=i.numDrawCalls,this.numInstances+=i.numInstances,this.numTris+=i.numTris}},i.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},e}(di),YX=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}on(e,t);var i=e.prototype;return i.initialize=function(t){this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,this._subpasses=t.subpasses,this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash()},i.destroy=function(){this._gpuRenderPass=null},Ur(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(pi),qX=function(t){function e(e,i){var r,n,s,a;return(r=t.call(this,e,i)||this)._gpuSampler=null,r._gpuSampler={glSamplers:new Map,minFilter:r._info.minFilter,magFilter:r._info.magFilter,mipFilter:r._info.mipFilter,addressU:r._info.addressU,addressV:r._info.addressV,addressW:r._info.addressW,glMinFilter:0,glMagFilter:0,glWrapS:0,glWrapT:0,glWrapR:0,getGLSampler:function(t,e,i){var r=t.gl,n=e<<16|i;if(!this.glSamplers.has(n)){var s=r.createSampler();s&&(this.glSamplers.set(n,s),r.samplerParameteri(s,r.TEXTURE_MIN_FILTER,this.glMinFilter),r.samplerParameteri(s,r.TEXTURE_MAG_FILTER,this.glMagFilter),r.samplerParameteri(s,r.TEXTURE_WRAP_S,this.glWrapS),r.samplerParameteri(s,r.TEXTURE_WRAP_T,this.glWrapT),r.samplerParameteri(s,r.TEXTURE_WRAP_R,this.glWrapR),r.samplerParameterf(s,r.TEXTURE_MIN_LOD,e),r.samplerParameterf(s,r.TEXTURE_MAX_LOD,i))}return this.glSamplers.get(n)}},n=iX.instance,s=r._gpuSampler,a=n.gl,s.minFilter===ft.LINEAR||s.minFilter===ft.ANISOTROPIC?s.mipFilter===ft.LINEAR||s.mipFilter===ft.ANISOTROPIC?s.glMinFilter=a.LINEAR_MIPMAP_LINEAR:s.mipFilter===ft.POINT?s.glMinFilter=a.LINEAR_MIPMAP_NEAREST:s.glMinFilter=a.LINEAR:s.mipFilter===ft.LINEAR||s.mipFilter===ft.ANISOTROPIC?s.glMinFilter=a.NEAREST_MIPMAP_LINEAR:s.mipFilter===ft.POINT?s.glMinFilter=a.NEAREST_MIPMAP_NEAREST:s.glMinFilter=a.NEAREST,s.magFilter===ft.LINEAR||s.magFilter===ft.ANISOTROPIC?s.glMagFilter=a.LINEAR:s.glMagFilter=a.NEAREST,s.glWrapS=rX[s.addressU],s.glWrapT=rX[s.addressV],s.glWrapR=rX[s.addressW],r}return on(e,t),e.prototype.destroy=function(){this._gpuSampler&&(function(t,e){for(var i=t.gl,r=e.glSamplers.values().next();!r.done;){i.deleteSampler(r.value);for(var n=t.stateCache.glSamplerUnits,s=0;s<n.length;++s)n[s]===r.value&&(i.bindSampler(s,null),n[s]=null)}e.glSamplers.clear()}(iX.instance,this._gpuSampler),this._gpuSampler=null)},Ur(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(mi),KX=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}on(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.slice(),samplerTextures:t.samplerTextures.slice(),subpassInputs:t.subpassInputs.slice(),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}}!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 bt.VERTEX:s="VertexShader",n=i.VERTEX_SHADER;break;case bt.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,"#version 300 es\n"+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)}i.linkProgram(e.glProgram);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));ps("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 d,p=f.name.indexOf("[");d=-1!==p?f.name.substr(0,p):f.name;var m=i.getAttribLocation(e.glProgram,d),g=oX(f.type,i),y=lX(f.type,i);e.glInputs[_]={name:d,type:g,stride:y,count:f.size,size:y*f.size,glType:f.type,glLoc:m}}}var v,b,S,A,T=i.getProgramParameter(e.glProgram,i.ACTIVE_UNIFORM_BLOCKS);if(T){e.glBlocks=new Array(T);for(var C=0;C<T;++C){var x=(v=i.getActiveUniformBlockName(e.glProgram,C)).indexOf("[");-1!==x&&(v=v.substr(0,x)),A=null;for(var w=0;w<e.blocks.length;w++)if(e.blocks[w].name===v){A=e.blocks[w];break}if(A){b=C,S=i.getActiveUniformBlockParameter(e.glProgram,b,i.UNIFORM_BLOCK_DATA_SIZE);var E=A.binding+(t.bindingMappings.blockOffsets[A.set]||0);i.uniformBlockBinding(e.glProgram,b,E),e.glBlocks[C]={set:A.set,binding:A.binding,idx:b,name:v,size:S,glBinding:E}}else Ja("Block '"+v+"' does not bound")}}for(var B=0;B<e.subpassInputs.length;++B){var R=e.subpassInputs[B];e.samplerTextures.push(new ce(R.set,R.binding,R.name,it.SAMPLER2D,R.count))}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var D=0;D<e.samplerTextures.length;++D){var M=e.samplerTextures[D];e.glSamplerTextures[D]={set:M.set,binding:M.binding,name:M.name,type:M.type,count:M.count,units:[],glUnits:null,glType:aX(M.type,i),glLoc:null}}}for(var P=[],I=[],O=t.stateCache.texUnitCacheMap,F=0,L=0;L<e.blocks.length;++L)e.blocks[L].set===t.bindingMappings.flexibleSet&&F++;for(var k=0,V=0;V<e.samplerTextures.length;++V){var N=e.samplerTextures[V],G=i.getUniformLocation(e.glProgram,N.name);if(G&&-1!==G.id&&(P.push(e.glSamplerTextures[V]),I.push(G)),void 0===O[N.name]){var z=N.binding+t.bindingMappings.samplerTextureOffsets[N.set]+k;N.set===t.bindingMappings.flexibleSet&&(z-=F),O[N.name]=z%t.capabilities.maxTextureUnits,k+=N.count-1}}if(P.length){for(var U=[],H=0;H<P.length;++H){var X=P[H],W=O[X.name];if(void 0!==W){X.glLoc=I[H];for(var j=0;j<X.count;++j){for(;U[W];)W=(W+1)%t.capabilities.maxTextureUnits;X.units.push(W),U[W]=!0}}}for(var Y=0,q=0;q<P.length;++q){var K=P[q];if(!K.glLoc){for(K.glLoc=I[q];U[Y];)Y++;for(var J=0;J<K.count;++J){for(;U[Y];)Y=(Y+1)%t.capabilities.maxTextureUnits;void 0===O[K.name]&&(O[K.name]=Y),K.units.push(Y),U[Y]=!0}}}t.stateCache.glProgram!==e.glProgram&&i.useProgram(e.glProgram);for(var Z=0;Z<P.length;Z++){var Q=P[Z];Q.glUnits=new Int32Array(Q.units),i.uniform1iv(Q.glLoc,Q.glUnits)}t.stateCache.glProgram!==e.glProgram&&i.useProgram(t.stateCache.glProgram)}e.glSamplerTextures=P}}(iX.instance,this._gpuShader)},i.destroy=function(){var t,e;this._gpuShader&&(t=iX.instance,(e=this._gpuShader).glProgram&&(t.gl.deleteProgram(e.glProgram),t.stateCache.glProgram===e.glProgram&&(t.gl.useProgram(null),t.stateCache.glProgram=null),e.glProgram=null),this._gpuShader=null)},Ur(e,[{key:"gpuShader",get:function(){return this._gpuShader}}]),e}(gi),JX=function(){function t(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glUniformBuffer=null,this.glBindUBOs=[],this.glBindUBOOffsets=[],this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glSamplerUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.glReadFramebuffer=null,this.viewport=new Jt,this.scissorRect=new Ht(0,0,0,0),this.rs=new li,this.dss=new hi,this.bs=new ci,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return t.prototype.initialize=function(t,e,i){for(var r=0;r<t;++r)this.glTexUnits.push({glTexture:null});this.glSamplerUnits.length=t,this.glSamplerUnits.fill(null),this.glBindUBOs.length=e,this.glBindUBOs.fill(null),this.glBindUBOOffsets.length=e,this.glBindUBOOffsets.fill(0),this.glEnabledAttribLocs.length=i,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=i,this.glCurrentAttribLocs.fill(!1)},t}(),ZX=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._gpuTextureView=null,e}on(e,t);var i=e.prototype;return i.initialize=function(t,e){var i=t,r=t;if("texture"in t&&(i=r.texture.info,this._isTextureView=!0),this._info.copy(i),this._isPowerOf2=Ke(this._info.width)&&Ke(this._info.height),this._size=Ze(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,this._isTextureView){var n;if(this._viewInfo.copy(r),this._gpuTexture=r.texture._gpuTexture,(null===(n=this._gpuTexture)||void 0===n?void 0:n.format)!==i.format)return void console.log("GPU memory alias is not supported");this._gpuTextureView={gpuTexture:this._gpuTexture,type:r.type,format:r.format,baseLevel:r.baseLevel,levelCount:r.levelCount}}else this._gpuTexture={type:i.type,format:i.format,usage:i.usage,width:i.width,height:i.height,depth:i.depth,size:this._size,arrayLayer:i.layerCount,mipLevel:i.levelCount,samples:i.samples,flags:i.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,isSwapchainTexture:e||!1},TX(iX.instance,this._gpuTexture),iX.instance.memoryStatus.textureSize+=this._size,this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount,this._gpuTextureView={gpuTexture:this._gpuTexture,type:this._viewInfo.type,format:this._viewInfo.format,baseLevel:this._viewInfo.baseLevel,levelCount:this._viewInfo.levelCount}},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(CX(iX.instance,this._gpuTexture),iX.instance.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.resize=function(t,i){if(this._info.width!==t||this._info.height!==i){this._info.levelCount===e.getLevelCount(this._info.width,this._info.height)?this._info.levelCount=e.getLevelCount(t,i):this._info.levelCount>1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var r=this._size;this._info.width=t,this._info.height=i,this._size=Ze(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,function(t,e){if(e.size){var i=t.gl,r=e.width,n=e.height;switch(e.type){case ot.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Nn(9100,s,t.capabilities.maxTextureSize),e.samples===ct.ONE){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var o=0;o<e.mipLevel;++o){var l=Je(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 CX(t,e),TX(t,e)}else e.glRenderbuffer&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case ot.CUBE:e.type=ot.CUBE,e.glTarget=i.TEXTURE_CUBE_MAP;var u=Math.max(r,n);u>t.capabilities.maxCubeMapTextureSize&&Nn(9100,u,t.capabilities.maxTextureSize);var c=t.stateCache.glTexUnits[t.stateCache.texUnit];if(c.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),c.glTexture=e.glTexture),Xe[e.format].isCompressed)for(var _=0;_<6;++_){r=e.width,n=e.height;for(var f=0;f<e.mipLevel;++f){var d=Je(e.format,r,n,1),p=new Uint8Array(d);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+_,f,e.glInternalFmt,r,n,0,p),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}else CX(t,e),TX(t,e);break;default:console.error("Unsupported TextureType, create texture failed."),e.type=ot.TEX2D,e.glTarget=i.TEXTURE_2D}}}(iX.instance,this._gpuTexture),iX.instance.memoryStatus.textureSize-=r,iX.instance.memoryStatus.textureSize+=this._size)}},i.initAsSwapchainTexture=function(t){var e=new ae;e.format=t.format,e.usage=Xe[t.format].hasDepth?lt.DEPTH_STENCIL_ATTACHMENT:lt.COLOR_ATTACHMENT,e.width=t.width,e.height=t.height,this.initialize(e,!0)},Ur(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"gpuTextureView",get:function(){return this._gpuTextureView}}]),e}(yi),QX="webglcontextlost";function $X(t,e){for(var i=["","WEBKIT_","MOZ_"],r=0;r<i.length;++r){var n=t.getExtension(i[r]+e);if(n)return n}return null}function tW(t){var e={EXT_texture_filter_anisotropic:$X(t,"EXT_texture_filter_anisotropic"),EXT_color_buffer_half_float:$X(t,"EXT_color_buffer_half_float"),EXT_color_buffer_float:$X(t,"EXT_color_buffer_float"),WEBGL_compressed_texture_etc1:$X(t,"WEBGL_compressed_texture_etc1"),WEBGL_compressed_texture_etc:$X(t,"WEBGL_compressed_texture_etc"),WEBGL_compressed_texture_pvrtc:$X(t,"WEBGL_compressed_texture_pvrtc"),WEBGL_compressed_texture_astc:$X(t,"WEBGL_compressed_texture_astc"),WEBGL_compressed_texture_s3tc:$X(t,"WEBGL_compressed_texture_s3tc"),WEBGL_compressed_texture_s3tc_srgb:$X(t,"WEBGL_compressed_texture_s3tc_srgb"),WEBGL_debug_shaders:$X(t,"WEBGL_debug_shaders"),WEBGL_lose_context:$X(t,"WEBGL_lose_context"),WEBGL_debug_renderer_info:$X(t,"WEBGL_debug_renderer_info"),OES_texture_half_float_linear:$X(t,"OES_texture_half_float_linear"),OES_texture_float_linear:$X(t,"OES_texture_float_linear"),WEBGL_multi_draw:null,useVAO:!0};return Xa.os!==ja.ANDROID&&Xa.os!==ja.IOS&&(e.WEBGL_multi_draw=$X(t,"WEBGL_multi_draw")),e}var eW=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 JX,e.nullTex2D=null,e.nullTexCube=null,e._canvas=null,e._webGL2ContextLostHandler=null,e._extensions=null,e}on(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.windowHandle,this._webGL2ContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(QX,this._onWebGLContextLost);var e=iX.instance.gl;this.stateCache.initialize(iX.instance.capabilities.maxTextureUnits,iX.instance.capabilities.maxUniformBufferBindings,iX.instance.capabilities.maxVertexAttributes),this._extensions=tW(e),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.polygonOffset(0,0),t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LESS),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)}(e);var i=tt.RGBA8,r=tt.DEPTH_STENCIL,n=e.getParameter(e.DEPTH_BITS),s=e.getParameter(e.STENCIL_BITS);n&&s?r=tt.DEPTH_STENCIL:n&&(r=tt.DEPTH),this._colorTexture=new ZX,this._colorTexture.initAsSwapchainTexture({swapchain:this,format:i,width:t.width,height:t.height}),this._depthStencilTexture=new ZX,this._depthStencilTexture.initAsSwapchainTexture({swapchain:this,format:r,width:t.width,height:t.height}),this.nullTex2D=iX.instance.createTexture(new ae(ot.TEX2D,lt.SAMPLED,tt.RGBA8,2,2,ht.NONE)),this.nullTexCube=iX.instance.createTexture(new ae(ot.CUBE,lt.SAMPLED,tt.RGBA8,2,2,ht.NONE,6));var a=new Kt;a.texExtent.width=2,a.texExtent.height=2;var o=new Uint8Array(this.nullTex2D.size);o.fill(0),iX.instance.copyBuffersToTexture([o],this.nullTex2D,[a]),a.texSubres.layerCount=6,iX.instance.copyBuffersToTexture([o,o,o,o,o,o],this.nullTexCube,[a])},i.destroy=function(){this._canvas&&this._webGL2ContextLostHandler&&(this._canvas.removeEventListener(QX,this._webGL2ContextLostHandler),this._webGL2ContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._extensions=null,this._canvas=null},i.resize=function(t,e){this._colorTexture.width===t&&this._colorTexture.height===e||(ps("Resizing swapchain: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._colorTexture.resize(t,e),this._depthStencilTexture.resize(t,e))},i._onWebGLContextLost=function(t){Rn(11e3),bn(t)},Ur(e,[{key:"extensions",get:function(){return this._extensions}}]),e}(ri),iW=t("WebGL2Device",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)._swapchain=null,e._context=null,e._bindingMappings=null,e._textureExclusive=new Array(tt.COUNT),e}on(e,t);var i=e.prototype;return i.initialize=function(t){iX.setInstance(this),this._gfxAPI=Z.WEBGL2;var e=this._bindingMappingInfo=t.bindingMappingInfo,i=[],r=[],n=e.setIndices[0];i[n]=0,r[n]=0;for(var s=1;s<e.setIndices.length;++s){var a=e.setIndices[s],o=e.setIndices[s-1];i[a]=e.maxBlockCounts[o]+i[o],r[a]=e.maxSamplerTextureCounts[o]+r[o]}for(var l=0;l<e.setIndices.length;++l){var h=e.setIndices[l];r[h]-=e.maxBlockCounts[h]}this._bindingMappings={blockOffsets:i,samplerTextureOffsets:r,flexibleSet:e.setIndices[e.setIndices.length-1]};var u=this._context=function(t){var e=null;try{var i={alpha:qr.ENABLE_TRANSPARENT_CANVAS,antialias:uo||qr.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};e=t.getContext("webgl2",i)}catch(t){return null}return e}(ii.canvas);if(!u)return console.error("This device does not support WebGL."),!1;this._queue=this.createQueue(new Le(It.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Fe(this._queue)),this._caps.maxVertexAttributes=u.getParameter(u.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=u.getParameter(u.MAX_VERTEX_UNIFORM_VECTORS),this._caps.maxFragmentUniformVectors=u.getParameter(u.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=u.getParameter(u.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=u.getParameter(u.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxUniformBufferBindings=u.getParameter(u.MAX_UNIFORM_BUFFER_BINDINGS),this._caps.maxUniformBlockSize=u.getParameter(u.MAX_UNIFORM_BLOCK_SIZE),this._caps.maxTextureSize=u.getParameter(u.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=u.getParameter(u.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.uboOffsetAlignment=u.getParameter(u.UNIFORM_BUFFER_OFFSET_ALIGNMENT);var c=u.getSupportedExtensions(),_="";if(c)for(var f,d=hn(c);!(f=d()).done;)_+=f.value+" ";var p=tW(u);p.WEBGL_debug_renderer_info?(this._renderer=u.getParameter(p.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=u.getParameter(p.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=u.getParameter(u.RENDERER),this._vendor=u.getParameter(u.VENDOR));var m=u.getParameter(u.VERSION);this._features.fill(!1),this.initFormatFeatures(p),this._features[$.ELEMENT_INDEX_UINT]=!0,this._features[$.INSTANCED_ARRAYS]=!0,this._features[$.MULTIPLE_RENDER_TARGETS]=!0,this._features[$.BLEND_MINMAX]=!0;var g="";return this.getFormatFeatures(tt.ETC_RGB8)&&(g+="etc1 "),this.getFormatFeatures(tt.ETC2_RGB8)&&(g+="etc2 "),this.getFormatFeatures(tt.BC1)&&(g+="dxt "),this.getFormatFeatures(tt.PVRTC_RGB2)&&(g+="pvrtc "),this.getFormatFeatures(tt.ASTC_RGBA_4X4)&&(g+="astc "),ps("WebGL2 device initialized."),ps("RENDERER: "+this._renderer),ps("VENDOR: "+this._vendor),ps("VERSION: "+m),ps("COMPRESSED_FORMAT: "+g),ps("EXTENSIONS: "+_),!0},i.destroy=function(){this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null);for(var t=this._samplers.values(),e=t.next();!e.done;)e.value.destroy(),e=t.next();this._swapchain=null},i.flushCommands=function(){},i.acquire=function(){},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.initFormatFeatures=function(t){this._formatFeatures.fill(ut.NONE),this._textureExclusive.fill(!0);var e=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE|ut.STORAGE_TEXTURE|ut.LINEAR_FILTER|ut.VERTEX_ATTRIBUTE;this._formatFeatures[tt.R8]=e,this._formatFeatures[tt.RG8]=e,this._formatFeatures[tt.RGB8]=e,this._formatFeatures[tt.RGBA8]=e,e=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE|ut.STORAGE_TEXTURE|ut.LINEAR_FILTER,this._formatFeatures[tt.R8SN]=e,this._formatFeatures[tt.RG8SN]=e,this._formatFeatures[tt.RGB8SN]=e,this._formatFeatures[tt.RGBA8SN]=e,this._formatFeatures[tt.R5G6B5]=e,this._formatFeatures[tt.RGBA4]=e,this._formatFeatures[tt.RGB5A1]=e,this._formatFeatures[tt.RGB10A2]=e,this._formatFeatures[tt.SRGB8]=e,this._formatFeatures[tt.SRGB8_A8]=e,this._formatFeatures[tt.R11G11B10F]=e,this._formatFeatures[tt.RGB9E5]=e,this._formatFeatures[tt.DEPTH]=e,this._formatFeatures[tt.DEPTH_STENCIL]=e,this._formatFeatures[tt.RGB10A2UI]=ut.RENDER_TARGET|ut.STORAGE_TEXTURE|ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER,e=ut.RENDER_TARGET|ut.SAMPLED_TEXTURE|ut.STORAGE_TEXTURE|ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R16F]=e,this._formatFeatures[tt.RG16F]=e,this._formatFeatures[tt.RGB16F]=e,this._formatFeatures[tt.RGBA16F]=e,e=ut.STORAGE_TEXTURE|ut.SAMPLED_TEXTURE|ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R32F]=e,this._formatFeatures[tt.RG32F]=e,this._formatFeatures[tt.RGB32F]=e,this._formatFeatures[tt.RGBA32F]=e,this._formatFeatures[tt.RGB10A2UI]=ut.RENDER_TARGET|ut.STORAGE_TEXTURE|ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER,e=ut.RENDER_TARGET|ut.STORAGE_TEXTURE|ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER|ut.VERTEX_ATTRIBUTE,this._formatFeatures[tt.R8I]=e,this._formatFeatures[tt.R8UI]=e,this._formatFeatures[tt.R16I]=e,this._formatFeatures[tt.R16UI]=e,this._formatFeatures[tt.R32I]=e,this._formatFeatures[tt.R32UI]=e,this._formatFeatures[tt.RG8I]=e,this._formatFeatures[tt.RG8UI]=e,this._formatFeatures[tt.RG16I]=e,this._formatFeatures[tt.RG16UI]=e,this._formatFeatures[tt.RG32I]=e,this._formatFeatures[tt.RG32UI]=e,this._formatFeatures[tt.RGB8I]=e,this._formatFeatures[tt.RGB8UI]=e,this._formatFeatures[tt.RGB16I]=e,this._formatFeatures[tt.RGB16UI]=e,this._formatFeatures[tt.RGB32I]=e,this._formatFeatures[tt.RGB32UI]=e,this._formatFeatures[tt.RGBA8I]=e,this._formatFeatures[tt.RGBA8UI]=e,this._formatFeatures[tt.RGBA16I]=e,this._formatFeatures[tt.RGBA16UI]=e,this._formatFeatures[tt.RGBA32I]=e,this._formatFeatures[tt.RGBA32UI]=e,this._textureExclusive[tt.R8]=!1,this._textureExclusive[tt.RG8]=!1,this._textureExclusive[tt.RGB8]=!1,this._textureExclusive[tt.R5G6B5]=!1,this._textureExclusive[tt.RGBA4]=!1,this._textureExclusive[tt.RGB5A1]=!1,this._textureExclusive[tt.RGBA8]=!1,this._textureExclusive[tt.RGB10A2]=!1,this._textureExclusive[tt.RGB10A2UI]=!1,this._textureExclusive[tt.SRGB8_A8]=!1,this._textureExclusive[tt.R8I]=!1,this._textureExclusive[tt.R8UI]=!1,this._textureExclusive[tt.R16I]=!1,this._textureExclusive[tt.R16UI]=!1,this._textureExclusive[tt.R32I]=!1,this._textureExclusive[tt.R32UI]=!1,this._textureExclusive[tt.RG8I]=!1,this._textureExclusive[tt.RG8UI]=!1,this._textureExclusive[tt.RG16I]=!1,this._textureExclusive[tt.RG16UI]=!1,this._textureExclusive[tt.RG32I]=!1,this._textureExclusive[tt.RG32UI]=!1,this._textureExclusive[tt.RGBA8I]=!1,this._textureExclusive[tt.RGBA8UI]=!1,this._textureExclusive[tt.RGBA16I]=!1,this._textureExclusive[tt.RGBA16UI]=!1,this._textureExclusive[tt.RGBA32I]=!1,this._textureExclusive[tt.RGBA32UI]=!1,this._textureExclusive[tt.DEPTH]=!1,this._textureExclusive[tt.DEPTH_STENCIL]=!1,t.EXT_color_buffer_float&&(this._formatFeatures[tt.R32F]|=ut.RENDER_TARGET,this._formatFeatures[tt.RG32F]|=ut.RENDER_TARGET,this._formatFeatures[tt.RGBA32F]|=ut.RENDER_TARGET,this._textureExclusive[tt.R32F]=!1,this._textureExclusive[tt.RG32F]=!1,this._textureExclusive[tt.RGBA32F]=!1),t.EXT_color_buffer_half_float&&(this._textureExclusive[tt.R16F]=!1,this._textureExclusive[tt.RG16F]=!1,this._textureExclusive[tt.RGBA16F]=!1),t.OES_texture_float_linear&&(this._formatFeatures[tt.RGB32F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RGBA32F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.R32F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RG32F]|=ut.LINEAR_FILTER),t.OES_texture_half_float_linear&&(this._formatFeatures[tt.RGB16F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RGBA16F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.R16F]|=ut.LINEAR_FILTER,this._formatFeatures[tt.RG16F]|=ut.LINEAR_FILTER);var i=ut.SAMPLED_TEXTURE|ut.LINEAR_FILTER;t.WEBGL_compressed_texture_etc1&&(this._formatFeatures[tt.ETC_RGB8]=i),t.WEBGL_compressed_texture_etc&&(this._formatFeatures[tt.ETC2_RGB8]=i,this._formatFeatures[tt.ETC2_RGBA8]=i,this._formatFeatures[tt.ETC2_SRGB8]=i,this._formatFeatures[tt.ETC2_SRGB8_A8]=i,this._formatFeatures[tt.ETC2_RGB8_A1]=i,this._formatFeatures[tt.ETC2_SRGB8_A1]=i),t.WEBGL_compressed_texture_s3tc&&(this._formatFeatures[tt.BC1]=i,this._formatFeatures[tt.BC1_ALPHA]=i,this._formatFeatures[tt.BC1_SRGB]=i,this._formatFeatures[tt.BC1_SRGB_ALPHA]=i,this._formatFeatures[tt.BC2]=i,this._formatFeatures[tt.BC2_SRGB]=i,this._formatFeatures[tt.BC3]=i,this._formatFeatures[tt.BC3_SRGB]=i),t.WEBGL_compressed_texture_pvrtc&&(this._formatFeatures[tt.PVRTC_RGB2]=i,this._formatFeatures[tt.PVRTC_RGBA2]=i,this._formatFeatures[tt.PVRTC_RGB4]=i,this._formatFeatures[tt.PVRTC_RGBA4]=i),t.WEBGL_compressed_texture_astc&&(this._formatFeatures[tt.ASTC_RGBA_4X4]=i,this._formatFeatures[tt.ASTC_RGBA_5X4]=i,this._formatFeatures[tt.ASTC_RGBA_5X5]=i,this._formatFeatures[tt.ASTC_RGBA_6X5]=i,this._formatFeatures[tt.ASTC_RGBA_6X6]=i,this._formatFeatures[tt.ASTC_RGBA_8X5]=i,this._formatFeatures[tt.ASTC_RGBA_8X6]=i,this._formatFeatures[tt.ASTC_RGBA_8X8]=i,this._formatFeatures[tt.ASTC_RGBA_10X5]=i,this._formatFeatures[tt.ASTC_RGBA_10X6]=i,this._formatFeatures[tt.ASTC_RGBA_10X8]=i,this._formatFeatures[tt.ASTC_RGBA_10X10]=i,this._formatFeatures[tt.ASTC_RGBA_12X10]=i,this._formatFeatures[tt.ASTC_RGBA_12X12]=i,this._formatFeatures[tt.ASTC_SRGBA_4X4]=i,this._formatFeatures[tt.ASTC_SRGBA_5X4]=i,this._formatFeatures[tt.ASTC_SRGBA_5X5]=i,this._formatFeatures[tt.ASTC_SRGBA_6X5]=i,this._formatFeatures[tt.ASTC_SRGBA_6X6]=i,this._formatFeatures[tt.ASTC_SRGBA_8X5]=i,this._formatFeatures[tt.ASTC_SRGBA_8X6]=i,this._formatFeatures[tt.ASTC_SRGBA_8X8]=i,this._formatFeatures[tt.ASTC_SRGBA_10X5]=i,this._formatFeatures[tt.ASTC_SRGBA_10X6]=i,this._formatFeatures[tt.ASTC_SRGBA_10X8]=i,this._formatFeatures[tt.ASTC_SRGBA_10X10]=i,this._formatFeatures[tt.ASTC_SRGBA_12X10]=i,this._formatFeatures[tt.ASTC_SRGBA_12X12]=i)},i.createCommandBuffer=function(t){var e=new(t.type===Ft.PRIMARY?WX:VX);return e.initialize(t),e},i.createSwapchain=function(t){var e=new eW;return this._swapchain=e,e.initialize(t),e},i.createBuffer=function(t){var e=new FX;return e.initialize(t),e},i.createTexture=function(t){var e=new ZX;return e.initialize(t),e},i.createDescriptorSet=function(t){var e=new eX;return e.initialize(t),e},i.createShader=function(t){var e=new KX;return e.initialize(t),e},i.createInputAssembler=function(t){var e=new GX;return e.initialize(t),e},i.createRenderPass=function(t){var e=new YX;return e.initialize(t),e},i.createFramebuffer=function(t){var e=new NX;return e.initialize(t),e},i.createDescriptorSetLayout=function(t){var e=new zX;return e.initialize(t),e},i.createPipelineLayout=function(t){var e=new UX;return e.initialize(t),e},i.createPipelineState=function(t){var e=new XX;return e.initialize(t),e},i.createQueue=function(t){var e=new jX;return e.initialize(t),e},i.getSampler=function(t){var e=mi.computeHash(t);return this._samplers.has(e)||this._samplers.set(e,new qX(t,e)),this._samplers.get(e)},i.getGeneralBarrier=function(t){var e=vi.computeHash(t);return this._generalBarrierss.has(e)||this._generalBarrierss.set(e,new vi(t,e)),this._generalBarrierss.get(e)},i.getTextureBarrier=function(t){var e=bi.computeHash(t);return this._textureBarriers.has(e)||this._textureBarriers.set(e,new bi(t,e)),this._textureBarriers.get(e)},i.getBufferBarrier=function(t){var e=co.computeHash(t);return this._bufferBarriers.has(e)||this._bufferBarriers.set(e,new co(t,e)),this._bufferBarriers.get(e)},i.copyBuffersToTexture=function(t,e,i){IX(this,t,e.gpuTexture,i)},i.copyTextureToBuffers=function(t,e,i){!function(t,e,i,r){var n=t.gl,s=t.stateCache,a=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,a);var o=0,l=0,h=1,u=1;switch(e.glTarget){case n.TEXTURE_2D:for(var c=0;c<r.length;c++){var _=r[c];n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,e.glTarget,e.glTexture,_.texSubres.mipLevel),o=_.texOffset.x,l=_.texOffset.y,h=_.texExtent.width,u=_.texExtent.height,n.readPixels(o,l,h,u,e.glFormat,e.glType,i[c])}break;default:console.error("Unsupported GL texture type, copy texture to buffers failed.")}n.bindFramebuffer(n.FRAMEBUFFER,null),s.glFramebuffer=null,n.deleteFramebuffer(a)}(this,t.gpuTexture,e,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&ht.GEN_MIPMAP&&n.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},Ur(e,[{key:"gl",get:function(){return this._context}},{key:"extensions",get:function(){return this._swapchain.extensions}},{key:"stateCache",get:function(){return this._swapchain.stateCache}},{key:"nullTex2D",get:function(){return this._swapchain.nullTex2D}},{key:"nullTexCube",get:function(){return this._swapchain.nullTexCube}},{key:"textureExclusive",get:function(){return this._textureExclusive}},{key:"bindingMappings",get:function(){return this._bindingMappings}}]),e}(ii));function rW(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}Er.WebGL2Device=iW;var nW=new i,sW=new i,aW=new i,oW=new i;function lW(t,e,i){for(var r=i.length,n=0;n<r;++n)if(rW(t,e,i[n],i[(n+1)%r]))return!0;return!1}function hW(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 uW(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:nW.set(e.x+l*s,e.y+l*a):e:nW.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 cW,_W,fW,dW,pW,mW,gW,yW,vW,bW,SW,AW,TW,CW,xW,wW,EW=t("Intersection2D",(function(){}));EW.lineLine=rW,EW.lineRect=function(t,e,i){var r=nW.set(i.x,i.y),n=sW.set(i.x,i.yMax),s=aW.set(i.xMax,i.yMax),a=oW.set(i.xMax,i.y);return!!(rW(t,e,r,n)||rW(t,e,n,s)||rW(t,e,s,a)||rW(t,e,a,r))},EW.linePolygon=lW,EW.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},EW.rectPolygon=function(t,e){var i=nW.set(t.x,t.y),r=sW.set(t.x,t.yMax),n=aW.set(t.xMax,t.yMax),s=oW.set(t.xMax,t.y);if(lW(i,r,e))return!0;if(lW(r,n,e))return!0;if(lW(n,s,e))return!0;if(lW(s,i,e))return!0;for(var a=0,o=e.length;a<o;++a)if(t.contains(e[a]))return!0;return!!(hW(i,e)||hW(r,e)||hW(n,e)||hW(s,e))},EW.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},EW.polygonPolygon=function(t,e){var i,r;for(i=0,r=t.length;i<r;++i)if(lW(t[i],t[(i+1)%r],e))return!0;for(i=0,r=e.length;i<r;++i)if(hW(e[i],t))return!0;for(i=0,r=t.length;i<r;++i)if(hW(t[i],e))return!0;return!1},EW.circleCircle=function(t,e,r,n){return i.distance(t,r)<e+n},EW.polygonCircle=function(t,e,i){var r=e;if(hW(r,t))return!0;for(var n=0,s=t.length;n<s;n++)if(uW(r,0===n?t[t.length-1]:t[n-1],t[n],!0)<i)return!0;return!1},EW.pointInPolygon=hW,EW.pointLineDistance=uW;var BW,RW,DW,MW=function(e){return t({Billboard:e,BillboardComponent:e}),e}((cW=En("cc.Billboard"),_W=Qn(),fW=ts(),dW=Wn(fn),pW=Wn(fn),mW=is(),gW=is(),yW=is(),vW=is(),cW(bW=_W(bW=fW(bW=Jn((wW=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_texture",AW,Pn(e)),Mn(e,"_height",TW,Pn(e)),Mn(e,"_width",CW,Pn(e)),Mn(e,"_rotation",xW,Pn(e)),e._model=null,e._mesh=null,e._material=null,e._uniform=new a(1,1,0,0),e}on(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=fh({primitiveMode:wt.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:[y.WHITE.r,y.WHITE.g,y.WHITE.b,y.WHITE.a,y.WHITE.r,y.WHITE.g,y.WHITE.b,y.WHITE.a,y.WHITE.r,y.WHITE.g,y.WHITE.b,y.WHITE.a,y.WHITE.r,y.WHITE.g,y.WHITE.b,y.WHITE.a],attributes:[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F),new ye(He.ATTR_COLOR,tt.RGBA8UI,!0)],indices:[0,1,2,1,2,3]},void 0,{calculateBounds:!1});var t=this._model=Er.director.root.createModel(sr,this.node);t.node=t.transform=this.node,null==this._material&&(this._material=new cn,this._material.copy(os.get("default-billboard-material"))),t.initSubModel(0,this._mesh.renderingSubMeshes[0],this._material)},Ur(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*E(this._rotation))/100},set:function(t){this._rotation=w(t),this._material&&(this._uniform.z=this._rotation,this._material.setProperty("cc_size_rotation",this._uniform))}}]),e}(ns),AW=Dn((SW=wW).prototype,"_texture",[dW],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(SW.prototype,"texture",[pW,mW],Object.getOwnPropertyDescriptor(SW.prototype,"texture"),SW.prototype),TW=Dn(SW.prototype,"_height",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(SW.prototype,"height",[gW],Object.getOwnPropertyDescriptor(SW.prototype,"height"),SW.prototype),CW=Dn(SW.prototype,"_width",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(SW.prototype,"width",[yW],Object.getOwnPropertyDescriptor(SW.prototype,"width"),SW.prototype),xW=Dn(SW.prototype,"_rotation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(SW.prototype,"rotation",[vW],Object.getOwnPropertyDescriptor(SW.prototype,"rotation"),SW.prototype),bW=SW))||bW)||bW)||bW)||bW)),PW=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RGBA32F),new ye(He.ATTR_TEX_COORD1,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA8,!0)],IW=new n,OW=new n,FW=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=nr.LINE,e._capacity=100,e._iaInfo=new se([new re]),e._iaInfoBuffer=e._device.createBuffer(new ee(rt.INDIRECT,at.DEVICE,qe,qe)),e}on(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=hn(PW);!(t=e()).done;){var i=t.value;i.offset=this._vertSize,this._vertSize+=Xe[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 ee(rt.VERTEX|rt.TRANSFER_DST,at.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 ee(rt.INDEX|rt.TRANSFER_DST,at.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 Bn([t],PW,wt.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;n.subtract(IW,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++]=IW.x,this._vdataF32[r++]=IW.y,this._vdataF32[r++]=IW.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++]=IW.x,this._vdataF32[r++]=IW.y,this._vdataF32[r++]=IW.z,this._vdataUint32[r++]=i.evaluate(0,1)._val;for(var s=1;s<t.length-1;s++){n.subtract(IW,t[s-1],t[s]),n.subtract(OW,t[s+1],t[s]),n.subtract(OW,OW,IW);var a=s/t.length;this._vdataF32[r++]=t[s].x,this._vdataF32[r++]=t[s].y,this._vdataF32[r++]=t[s].z,this._vdataF32[r++]=0,this._vdataF32[r++]=e.evaluate(a,1),this._vdataF32[r++]=a,this._vdataF32[r++]=0,this._vdataF32[r++]=OW.x,this._vdataF32[r++]=OW.y,this._vdataF32[r++]=OW.z,this._vdataUint32[r++]=i.evaluate(a,1)._val,this._vdataF32[r++]=t[s].x,this._vdataF32[r++]=t[s].y,this._vdataF32[r++]=t[s].z,this._vdataF32[r++]=1,this._vdataF32[r++]=e.evaluate(a,1),this._vdataF32[r++]=a,this._vdataF32[r++]=1,this._vdataF32[r++]=OW.x,this._vdataF32[r++]=OW.y,this._vdataF32[r++]=OW.z,this._vdataUint32[r++]=i.evaluate(a,1)._val}n.subtract(IW,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++]=IW.x,this._vdataF32[r++]=IW.y,this._vdataF32[r++]=IW.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++]=IW.x,this._vdataF32[r++]=IW.y,this._vdataF32[r++]=IW.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}(sr),LW=lo.Attr.setClassAttr,kW=[["mode","constant","multiplier"],["mode","spline","multiplier"],["mode","splineMin","splineMax","multiplier"],["mode","constantMin","constantMax","multiplier"]],VW=zs({Constant:0,Curve:1,TwoCurves:2,TwoConstants:3}),NW=t("CurveRange",En("cc.CurveRange")((DW=RW=function(){function t(){this.mode=VW.Constant,this.spline=_o(),this.splineMin=_o(),this.splineMax=_o(),this.constant=0,this.constantMin=0,this.constantMax=0,this.multiplier=1}var e=t.prototype;return e.evaluate=function(t,e){switch(this.mode){default:case VW.Constant:return this.constant;case VW.Curve:return this.spline.evaluate(t)*this.multiplier;case VW.TwoCurves:return x(this.splineMin.evaluate(t),this.splineMax.evaluate(t),e)*this.multiplier;case VW.TwoConstants:return x(this.constantMin,this.constantMax,e)}},e.getMax=function(){switch(this.mode){default:case VW.Constant:return this.constant;case VW.Curve:return this.multiplier;case VW.TwoConstants:return this.constantMax;case VW.TwoCurves:return this.multiplier}},e._onBeforeSerialize=function(){return kW[this.mode]},Ur(t,[{key:"curve",get:function(){var t;return null!==(t=this._curve)&&void 0!==t?t:this._curve=new Vi(this.spline)},set:function(t){this._curve=t,this.spline=t._internalCurve}},{key:"curveMin",get:function(){var t;return null!==(t=this._curveMin)&&void 0!==t?t:this._curveMin=new Vi(this.splineMin)},set:function(t){this._curveMin=t,this.splineMin=t._internalCurve}},{key:"curveMax",get:function(){var t;return null!==(t=this._curveMax)&&void 0!==t?t:this._curveMax=new Vi(this.splineMax)},set:function(t){this._curveMax=t,this.splineMax=t._internalCurve}}]),t}(),RW.Mode=VW,BW=DW))||BW);function GW(t,e,i){switch(t.mode){case VW.Constant:return t.constant;case VW.Curve:return t.spline.evaluate(e)*t.multiplier;case VW.TwoCurves:return 0===i?t.splineMin.evaluate(e)*t.multiplier:t.splineMax.evaluate(e)*t.multiplier;case VW.TwoConstants:return 0===i?t.constantMin:t.constantMax;default:return 0}}function zW(t){switch(t.mode){case VW.TwoConstants:case VW.TwoCurves:return 2;default:return 1}}function UW(t,e,i){var r=new vn({width:e,height:i,_data:t,_compressed:!1,format:_n.RGBA32F}),n=new fn;return n.setFilters(dn.NEAREST,dn.NEAREST),n.setMipFilter(dn.NONE),n.setWrapMode(Zs.CLAMP_TO_EDGE,Zs.CLAMP_TO_EDGE,Zs.CLAMP_TO_EDGE),n.image=r,n}function HW(t,e,i,r,n){for(var s=Math.max(zW(e),zW(i),zW(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,d=0;d<t;d++){var p=GW(c,l*d,h);f=n?p:(_+=p)/(d+1),a[4*(h*t+d)+u]=f}return UW(a,t,s)}lo.fastDefine("cc.CurveRange",NW,{multiplier:1,constantMax:0,constantMin:0,constant:0,mode:VW.Constant,splineMax:Object.freeze(_o()),splineMin:Object.freeze(_o()),spline:Object.freeze(_o())}),LW(NW,"multiplier","visible",!0),LW(NW,"constantMax","visible",!0),LW(NW,"constantMin","visible",!0),LW(NW,"constant","visible",!0),LW(NW,"mode","type","Enum"),LW(NW,"mode","enumList",zs.getList(VW)),LW(NW,"mode","visible",!0),LW(NW,"splineMax","type","Object"),LW(NW,"splineMax","ctor",Aa),LW(NW,"splineMax","visible",!0),LW(NW,"splineMin","type","Object"),LW(NW,"splineMin","ctor",Aa),LW(NW,"splineMin","visible",!0),LW(NW,"spline","type","Object"),LW(NW,"spline","ctor",Aa),LW(NW,"spline","visible",!0);var XW=zs({Blend:0,Fixed:1}),WW=t("ColorKey",(function(){this.color=y.WHITE.clone(),this.time=0}));lo.fastDefine("cc.ColorKey",WW,{color:y.WHITE.clone(),time:0}),lo.Attr.setClassAttr(WW,"color","visible",!0),lo.Attr.setClassAttr(WW,"time","visible",!0);var jW=t("AlphaKey",(function(){this.alpha=1,this.time=0}));lo.fastDefine("cc.AlphaKey",jW,{alpha:1,time:0}),lo.Attr.setClassAttr(jW,"alpha","visible",!0),lo.Attr.setClassAttr(jW,"time","visible",!0);var YW,qW,KW,JW,ZW,QW,$W,tj,ej,ij,rj,nj,sj,aj,oj,lj,hj,uj=t("Gradient",function(){function t(){this.colorKeys=new Array,this.alphaKeys=new Array,this.mode=XW.Blend,this._color=void 0,this._color=y.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){t=F(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===XW.Fixed)return this.colorKeys[e].color;var n=(t-i)/(r-i);return y.lerp(this._color,this.colorKeys[e-1].color,this.colorKeys[e].color,n),this._color}}var s=this.colorKeys.length-1;return t<this.colorKeys[0].time?y.lerp(this._color,y.BLACK,this.colorKeys[0].color,t/this.colorKeys[0].time):t>this.colorKeys[s].time&&y.lerp(this._color,this.colorKeys[s].color,y.BLACK,(t-this.colorKeys[s].time)/(1-this.colorKeys[s].time)),this._color}return 1===this.colorKeys.length?(this._color.set(this.colorKeys[0].color),this._color):(this._color.set(y.WHITE),this._color)},e.getAlpha=function(t){if(this.alphaKeys.length>1){t=F(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===XW.Fixed)return this.alphaKeys[e].alpha;var n=(t-i)/(r-i);return x(this.alphaKeys[e-1].alpha,this.alphaKeys[e].alpha,n)}}var s=this.alphaKeys.length-1;return t<this.alphaKeys[0].time?x(0,this.alphaKeys[0].alpha,t/this.alphaKeys[0].time):t>this.alphaKeys[s].time?x(this.alphaKeys[s].alpha,0,(t-this.alphaKeys[s].time)/(1-this.alphaKeys[s].time)):255}return 1===this.alphaKeys.length?this.alphaKeys[0].alpha:255},t}());uj.Mode=XW,lo.fastDefine("cc.Gradient",uj,{colorKeys:[],alphaKeys:[],mode:XW.Blend}),lo.Attr.setClassAttr(uj,"colorKeys","visible",!0),lo.Attr.setClassAttr(uj,"alphaKeys","visible",!0),lo.Attr.setClassAttr(uj,"mode","visible",!0);var cj,_j,fj,dj,pj,mj,gj,yj,vj,bj,Sj,Aj,Tj,Cj,xj,wj,Ej,Bj,Rj,Dj,Mj,Pj,Ij,Oj,Fj,Lj,kj,Vj,Nj,Gj,zj,Uj,Hj,Xj,Wj,jj,Yj,qj,Kj=uo,Jj=zs({Color:0,Gradient:1,TwoColors:2,TwoGradients:3,RandomColor:4}),Zj=t("GradientRange",(YW=En("cc.GradientRange"),qW=Wn(Jj),KW=Wn(uj),JW=Wn(uj),ZW=Wn(uj),QW=Wn(Jj),YW((hj=lj=function(){function t(){Mn(this,"color",ej,this),Mn(this,"colorMin",ij,this),Mn(this,"colorMax",rj,this),Mn(this,"gradient",nj,this),Mn(this,"gradientMin",sj,this),Mn(this,"gradientMax",aj,this),Mn(this,"_mode",oj,this),this._color=y.WHITE.clone()}var e=t.prototype;return e.evaluate=function(t,e){switch(this._mode){case Jj.Color:return this.color;case Jj.TwoColors:return y.lerp(this._color,this.colorMin,this.colorMax,e),this._color;case Jj.RandomColor:return this.gradient.randomColor();case Jj.Gradient:return this.gradient.evaluate(t);case Jj.TwoGradients:return y.lerp(this._color,this.gradientMin.evaluate(t),this.gradientMax.evaluate(t),e),this._color;default:return this.color}},e._onBeforeSerialize=function(){return Kj[this._mode]},Ur(t,[{key:"mode",get:function(){return this._mode},set:function(t){this._mode=t}}]),t}(),lj.Mode=Jj,Dn((tj=hj).prototype,"mode",[qW],Object.getOwnPropertyDescriptor(tj.prototype,"mode"),tj.prototype),ej=Dn(tj.prototype,"color",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),ij=Dn(tj.prototype,"colorMin",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),rj=Dn(tj.prototype,"colorMax",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),nj=Dn(tj.prototype,"gradient",[KW],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new uj}}),sj=Dn(tj.prototype,"gradientMin",[JW],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new uj}}),aj=Dn(tj.prototype,"gradientMax",[ZW],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new uj}}),oj=Dn(tj.prototype,"_mode",[QW],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Jj.Color}}),$W=tj))||$W));function Qj(t,e,i){switch(t.mode){case Jj.Color:return t.color;case Jj.TwoColors:return 0===i?t.colorMin:t.colorMax;case Jj.RandomColor:return t.gradient.randomColor();case Jj.Gradient:return t.gradient.evaluate(e);case Jj.TwoGradients:return 0===i?t.gradientMin.evaluate(e):t.gradientMax.evaluate(e);default:return t.color}}var $j={parent:null,owner:null,subModelIdx:0},tY={CC_USE_WORLD_SPACE:!1},eY=function(e){return t({Line:e,LineComponent:e}),e}((cj=En("cc.Line"),_j=Qn(),fj=ts(),dj=Wn(fn),pj=Wn(fn),mj=es(),gj=is(),yj=es(),vj=is(),bj=Wn([n]),Sj=Wn([n]),Aj=es(),Tj=is(),Cj=Wn(NW),xj=Wn(NW),wj=Ls(),Ej=es(),Bj=is(),Rj=Wn(i),Dj=es(),Mj=is(),Pj=Wn(i),Ij=es(),Oj=is(),Fj=Wn(Zj),Lj=Wn(Zj),kj=es(),Vj=is(),cj(Nj=_j(Nj=fj(Nj=Jn((qj=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_texture",zj,Pn(e)),e._material=null,e._materialInstance=null,Mn(e,"_worldSpace",Uj,Pn(e)),Mn(e,"_positions",Hj,Pn(e)),Mn(e,"_width",Xj,Pn(e)),Mn(e,"_tile",Wj,Pn(e)),Mn(e,"_offset",jj,Pn(e)),Mn(e,"_color",Yj,Pn(e)),e._model=null,e._tile_offset=new a,e}on(e,t);var i=e.prototype;return i.onLoad=function(){var t=this._model=Er.director.root.createModel(FW);t.node=t.transform=this.node,null===this._material&&(this._material=new cn,this._material.copy(os.get("default-trail-material")),tY.CC_USE_WORLD_SPACE=this.worldSpace,$j.parent=this._material,$j.subModelIdx=0,this._materialInstance=new Ps($j),$j.parent=null,$j.subModelIdx=0,this._materialInstance.recompileShaders(tY)),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)},Ur(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&&(tY.CC_USE_WORLD_SPACE=this.worldSpace,this._materialInstance.recompileShaders(tY),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}(ns),zj=Dn((Gj=qj).prototype,"_texture",[dj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(Gj.prototype,"texture",[pj,mj,gj],Object.getOwnPropertyDescriptor(Gj.prototype,"texture"),Gj.prototype),Uj=Dn(Gj.prototype,"_worldSpace",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(Gj.prototype,"worldSpace",[yj,vj],Object.getOwnPropertyDescriptor(Gj.prototype,"worldSpace"),Gj.prototype),Hj=Dn(Gj.prototype,"_positions",[bj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dn(Gj.prototype,"positions",[Sj,Aj,Tj],Object.getOwnPropertyDescriptor(Gj.prototype,"positions"),Gj.prototype),Xj=Dn(Gj.prototype,"_width",[Cj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),Dn(Gj.prototype,"width",[xj,wj,Ej,Bj],Object.getOwnPropertyDescriptor(Gj.prototype,"width"),Gj.prototype),Wj=Dn(Gj.prototype,"_tile",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(1,1)}}),Dn(Gj.prototype,"tile",[Rj,Dj,Mj],Object.getOwnPropertyDescriptor(Gj.prototype,"tile"),Gj.prototype),jj=Dn(Gj.prototype,"_offset",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i(0,0)}}),Dn(Gj.prototype,"offset",[Pj,Ij,Oj],Object.getOwnPropertyDescriptor(Gj.prototype,"offset"),Gj.prototype),Yj=Dn(Gj.prototype,"_color",[Fj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zj}}),Dn(Gj.prototype,"color",[Lj,kj,Vj],Object.getOwnPropertyDescriptor(Gj.prototype,"color"),Gj.prototype),Nj=Gj))||Nj)||Nj)||Nj)||Nj)),iY=function(){function t(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.startEuler=void 0,this.startRotation=void 0,this.startRotated=void 0,this.deltaQuat=void 0,this.deltaMat=void 0,this.localMat=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.loopCount=void 0,this.lastLoop=void 0,this.trailDelay=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 n(0,0,0),this.velocity=new n(0,0,0),this.animatedVelocity=new n(0,0,0),this.ultimateVelocity=new n(0,0,0),this.angularVelocity=new n(0,0,0),this.axisOfRotation=new n(0,0,0),this.rotation=new n(0,0,0),this.startEuler=new n(0,0,0),this.startRotation=new l,this.startRotated=!1,this.deltaQuat=new l,this.deltaMat=new c,this.localMat=new c,this.startSize=new n(0,0,0),this.size=new n(0,0,0),this.startColor=y.WHITE.clone(),this.color=y.WHITE.clone(),this.randomSeed=0,this.remainingLifetime=0,this.loopCount=0,this.lastLoop=0,this.trailDelay=0,this.startLifetime=0,this.emitAccumulator0=0,this.emitAccumulator1=0,this.frameIndex=0,this.startRow=0}return t.prototype.reset=function(){this.rotation.set(0,0,0),this.startEuler.set(0,0,0),this.startRotation.set(0,0,0,1),this.startRotated=!1,this.deltaQuat.set(0,0,0,1),this.deltaMat.identity(),this.localMat.identity()},t}();iY.INDENTIFY_NEG_QUAT=10,iY.R2D=180/Math.PI;var rY,nY,sY,aY,oY,lY,hY,uY,cY,_Y,fY,dY,pY,mY,gY,yY,vY,bY,SY,AY,TY,CY,xY,wY,EY,BY,RY,DY,MY,PY,IY,OY,FY,LY,kY="colorModule",VY="rotationModule",NY="sizeModule",GY="textureModule",zY="noiseModule",UY=["sizeModule","colorModule","forceModule","velocityModule","limitModule","rotationModule","textureModule","noiseModule"],HY=["_colorOverLifetimeModule","_shapeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule","_trailModule"],XY=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}(),WY=zs({World:0,Local:1,Custom:2}),jY=zs({Pause:0,PauseAndCatchup:1,AlwaysSimulate:2}),YY=zs({World:0,Local:1,View:2}),qY=zs({Billboard:0,StrecthedBillboard:1,HorizontalBillboard:2,VerticalBillboard:3,Mesh:4}),KY=zs({Box:0,Circle:1,Cone:2,Sphere:3,Hemisphere:4}),JY=zs({Base:0,Edge:1,Shell:2,Volume:3}),ZY=zs({Random:0,Loop:1,PingPong:2}),QY=zs({Particles:0}),$Y=zs({Stretch:0}),tq=(rY=En("cc.ColorOvertimeModule"),nY=es(),sY=Wn(Zj),aY=es(),rY((cY=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,Mn(e,"_enable",hY,Pn(e)),Mn(e,"color",uY,Pn(e)),e.name=kY,e}return on(e,t),e.prototype.animate=function(t){t.color.set(t.startColor),t.color.multiply(this.color.evaluate(1-t.remainingLifetime/t.startLifetime,M(t.randomSeed+91041)))},Ur(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}(XY),hY=Dn((lY=cY).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(lY.prototype,"enable",[nY],Object.getOwnPropertyDescriptor(lY.prototype,"enable"),lY.prototype),uY=Dn(lY.prototype,"color",[sY,On,aY],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zj}}),oY=lY))||oY),eq=new n(0,0,-1);function iq(t,e,i,r){return e!==t?(t===WY.World||c.invert(i,i),c.getRotation(r,i),!0):(l.set(r,0,0,0,1),!1)}function rq(t,e){i.set(t,Math.cos(e),Math.sin(e))}function nq(t){var e=R(-1,1),i=R(0,2*Math.PI),r=Math.sqrt(1-e*e),s=r*Math.cos(i),a=r*Math.sin(i);n.set(t,s,a,e)}function sq(t,e,i){nq(t),n.multiplyScalar(t,t,e+(i-e)*B())}function aq(t,e,i,r){rq(t,r),t.z=0,n.multiplyScalar(t,t,e+(i-e)*B())}function oq(t){for(var e=0;e<t.length;e++){var i=e+D(0,t.length-e),r=t[i];t[i]=t[e],t[e]=r}}function lq(){var t=R(-1,1);return 0===t&&t++,fo(t)}var hq,uq,cq,_q,fq,dq,pq,mq,gq,yq,vq,bq,Sq,Aq,Tq,Cq,xq,wq,Eq,Bq,Rq,Dq,Mq,Pq,Iq,Oq,Fq,Lq,kq,Vq,Nq,Gq,zq,Uq,Hq,Xq,Wq,jq,Yq,qq,Kq,Jq,Zq,Qq,$q,tK,eK,iK,rK,nK,sK,aK,oK,lK,hK,uK,cK,_K,fK,dK,pK,mK,gK,yK,vK,bK,SK=212165,AK=new n,TK=(_Y=En("cc.ForceOvertimeModule"),fY=es(),dY=Wn(NW),pY=Ls(),mY=es(),gY=is(),yY=Wn(NW),vY=Ls(),bY=es(),SY=is(),AY=Wn(NW),TY=Ls(),CY=es(),xY=is(),wY=Wn(WY),EY=es(),BY=is(),_Y((LY=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_enable",MY,Pn(e)),Mn(e,"x",PY,Pn(e)),Mn(e,"y",IY,Pn(e)),Mn(e,"z",OY,Pn(e)),Mn(e,"space",FY,Pn(e)),e.randomized=!1,e.rotation=void 0,e.needTransform=void 0,e.name="forceModule",e.rotation=new l,e.needTransform=!1,e.needUpdate=!0,e}on(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=iq(t,this.space,e,this.rotation)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,r=n.set(AK,this.x.evaluate(i,M(t.randomSeed+SK)),this.y.evaluate(i,M(t.randomSeed+SK)),this.z.evaluate(i,M(t.randomSeed+SK)));this.needTransform&&n.transformQuat(r,r,this.rotation),n.scaleAndAdd(t.velocity,t.velocity,r,e),n.copy(t.ultimateVelocity,t.velocity)},Ur(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}(XY),MY=Dn((DY=LY).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(DY.prototype,"enable",[fY],Object.getOwnPropertyDescriptor(DY.prototype,"enable"),DY.prototype),PY=Dn(DY.prototype,"x",[dY,On,pY,mY,gY],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),IY=Dn(DY.prototype,"y",[yY,On,vY,bY,SY],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),OY=Dn(DY.prototype,"z",[AY,On,TY,CY,xY],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),FY=Dn(DY.prototype,"space",[wY,On,EY,BY],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.Local}}),RY=DY))||RY),CK=23541,xK=new n,wK=new n,EK=(hq=En("cc.LimitVelocityOvertimeModule"),uq=es(),cq=Wn(NW),_q=Ls(),fq=es(),dq=is(),pq=cs(),mq=Wn(NW),gq=Ls(),yq=es(),vq=is(),bq=cs(),Sq=Wn(NW),Aq=Ls(),Tq=es(),Cq=is(),xq=cs(),wq=Wn(NW),Eq=Ls(),Bq=es(),Rq=is(),Dq=cs(),Mq=es(),Pq=is(),Iq=es(),Oq=is(),Fq=Wn(WY),Lq=es(),kq=is(),hq((qq=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_enable",Gq,Pn(e)),Mn(e,"limitX",zq,Pn(e)),Mn(e,"limitY",Uq,Pn(e)),Mn(e,"limitZ",Hq,Pn(e)),Mn(e,"limit",Xq,Pn(e)),Mn(e,"dampen",Wq,Pn(e)),Mn(e,"separateAxes",jq,Pn(e)),Mn(e,"space",Yq,Pn(e)),e.drag=null,e.multiplyDragByParticleSize=!1,e.multiplyDragByParticleVelocity=!1,e.name="limitModule",e.rotation=void 0,e.needTransform=void 0,e.rotation=new l,e.needTransform=!1,e.needUpdate=!0,e}on(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=iq(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=xK;this.separateAxes?(n.set(wK,this.limitX.evaluate(e,M(t.randomSeed+CK)),this.limitY.evaluate(e,M(t.randomSeed+CK)),this.limitZ.evaluate(e,M(t.randomSeed+CK))),this.needTransform&&n.transformQuat(wK,wK,this.rotation),n.set(i,BK(t.ultimateVelocity.x,wK.x,this.dampen),BK(t.ultimateVelocity.y,wK.y,this.dampen),BK(t.ultimateVelocity.z,wK.z,this.dampen))):(n.normalize(i,t.ultimateVelocity),n.multiplyScalar(i,i,BK(t.ultimateVelocity.length(),this.limit.evaluate(e,M(t.randomSeed+CK)),this.dampen))),n.copy(t.ultimateVelocity,i)},Ur(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}(XY),Gq=Dn((Nq=qq).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(Nq.prototype,"enable",[uq],Object.getOwnPropertyDescriptor(Nq.prototype,"enable"),Nq.prototype),zq=Dn(Nq.prototype,"limitX",[cq,On,_q,fq,dq,pq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),Uq=Dn(Nq.prototype,"limitY",[mq,On,gq,yq,vq,bq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),Hq=Dn(Nq.prototype,"limitZ",[Sq,On,Aq,Tq,Cq,xq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),Xq=Dn(Nq.prototype,"limit",[wq,On,Eq,Bq,Rq,Dq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),Wq=Dn(Nq.prototype,"dampen",[On,Mq,Pq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 3}}),jq=Dn(Nq.prototype,"separateAxes",[On,Iq,Oq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Yq=Dn(Nq.prototype,"space",[Fq,On,Lq,kq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.Local}}),Vq=Nq))||Vq);function BK(t,e,i){var r=Math.sign(t),n=Math.abs(t);return n>e&&(n=x(n,e,i)),n*r}var RK,DK,MK,PK,IK,OK,FK,LK,kK,VK,NK,GK,zK,UK,HK,XK,WK,jK,YK,qK,KK,JK,ZK,QK,$K,tJ,eJ,iJ,rJ,nJ,sJ,aJ,oJ,lJ,hJ,uJ,cJ,_J,fJ,dJ,pJ,mJ,gJ,yJ,vJ,bJ,SJ,AJ,TJ,CJ,xJ,wJ,EJ,BJ,RJ,DJ,MJ,PJ,IJ,OJ,FJ,LJ,kJ,VJ,NJ,GJ,zJ,UJ,HJ,XJ,WJ,jJ,YJ,qJ,KJ,JJ,ZJ,QJ,$J,tZ,eZ,iZ,rZ,nZ,sZ,aZ,oZ,lZ,hZ,uZ,cZ,_Z,fZ,dZ,pZ,mZ,gZ,yZ,vZ,bZ,SZ,AZ,TZ,CZ,xZ,wZ,EZ,BZ,RZ,DZ,MZ,PZ,IZ,OZ,FZ,LZ,kZ,VZ,NZ,GZ,zZ,UZ,HZ,XZ,WZ,jZ,YZ,qZ,KZ,JZ,ZZ,QZ,$Z,tQ,eQ,iQ,rQ,nQ,sQ,aQ,oQ,lQ,hQ,uQ,cQ,_Q,fQ,dQ,pQ,mQ,gQ,yQ,vQ,bQ,SQ,AQ,TQ,CQ,xQ,wQ,EQ,BQ,RQ,DQ,MQ,PQ,IQ,OQ,FQ,LQ,kQ,VQ,NQ,GQ,zQ,UQ,HQ,XQ,WQ,jQ,YQ,qQ,KQ,JQ,ZQ,QQ,$Q,t$,e$,i$,r$,n$,s$,a$,o$,l$,h$,u$=(Kq=En("cc.RotationOvertimeModule"),Jq=es(),Zq=es(),Qq=is(),$q=Wn(NW),tK=Ls(),eK=es(),iK=is(),rK=cs(),nK=Wn(NW),sK=Ls(),aK=es(),oK=is(),lK=cs(),hK=Wn(NW),uK=Ls(),cK=es(),_K=is(),Kq((bK=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e=t.call.apply(t,[this].concat(r))||this,Mn(e,"_enable",pK,Pn(e)),Mn(e,"_separateAxes",mK,Pn(e)),Mn(e,"x",gK,Pn(e)),Mn(e,"y",yK,Pn(e)),Mn(e,"z",vK,Pn(e)),e.name=VY,e._startMat=new c,e._matRot=new c,e._quatRot=new l,e._otherEuler=new n,e}on(e,t);var i=e.prototype;return i._processRotation=function(t){var e=t.particleSystem.processor.getInfo().renderMode;e!==qY.Mesh&&e===qY.StrecthedBillboard&&this._quatRot.set(0,0,0,1),l.normalize(this._quatRot,this._quatRot),this._quatRot.w<0&&(this._quatRot.x+=iY.INDENTIFY_NEG_QUAT)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,r=M(t.randomSeed+125292),n=t.particleSystem.processor.getInfo().renderMode;this._separateAxes&&n!==qY.VerticalBillboard&&n!==qY.HorizontalBillboard?l.fromEuler(t.deltaQuat,this.x.evaluate(i,r)*e*iY.R2D,this.y.evaluate(i,r)*e*iY.R2D,this.z.evaluate(i,r)*e*iY.R2D):l.fromEuler(t.deltaQuat,0,0,this.z.evaluate(i,r)*e*iY.R2D),t.deltaMat=c.fromQuat(t.deltaMat,t.deltaQuat),t.localMat=t.localMat.multiply(t.deltaMat),t.startRotated||(n!==qY.Mesh&&(n===qY.StrecthedBillboard?t.startEuler.set(0,0,0):n!==qY.Billboard&&t.startEuler.set(0,0,t.startEuler.z)),l.fromEuler(t.startRotation,t.startEuler.x*iY.R2D,t.startEuler.y*iY.R2D,t.startEuler.z*iY.R2D),t.startRotated=!0),this._startMat=c.fromQuat(this._startMat,t.startRotation),this._matRot=this._startMat.multiply(t.localMat),c.getRotation(this._quatRot,this._matRot),this._processRotation(t,iY.R2D),t.rotation.set(this._quatRot.x,this._quatRot.y,this._quatRot.z)},Ur(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}(XY),pK=Dn((dK=bK).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(dK.prototype,"enable",[Jq],Object.getOwnPropertyDescriptor(dK.prototype,"enable"),dK.prototype),mK=Dn(dK.prototype,"_separateAxes",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(dK.prototype,"separateAxes",[Zq,Qq],Object.getOwnPropertyDescriptor(dK.prototype,"separateAxes"),dK.prototype),gK=Dn(dK.prototype,"x",[$q,On,tK,po,eK,iK,rK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),yK=Dn(dK.prototype,"y",[nK,On,sK,po,aK,oK,lK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),vK=Dn(dK.prototype,"z",[hK,On,uK,po,cK,_K],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),fK=dK))||fK),c$=(RK=En("cc.SizeOvertimeModule"),DK=es(),MK=es(),PK=is(),IK=Wn(NW),OK=Ls(),FK=es(),LK=is(),kK=cs(),VK=Wn(NW),NK=Ls(),GK=es(),zK=is(),UK=cs(),HK=Wn(NW),XK=Ls(),WK=es(),jK=is(),YK=cs(),qK=Wn(NW),KK=Ls(),JK=es(),ZK=is(),QK=cs(),RK((oJ=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,Mn(e,"_enable",eJ,Pn(e)),Mn(e,"separateAxes",iJ,Pn(e)),Mn(e,"size",rJ,Pn(e)),Mn(e,"x",nJ,Pn(e)),Mn(e,"y",sJ,Pn(e)),Mn(e,"z",aJ,Pn(e)),e.name=NY,e}return on(e,t),e.prototype.animate=function(t){if(this.separateAxes){var e=1-t.remainingLifetime/t.startLifetime,i=M(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 n.multiplyScalar(t.size,t.startSize,this.size.evaluate(1-t.remainingLifetime/t.startLifetime,M(t.randomSeed+39825)))},Ur(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}(XY),eJ=Dn((tJ=oJ).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(tJ.prototype,"enable",[DK],Object.getOwnPropertyDescriptor(tJ.prototype,"enable"),tJ.prototype),iJ=Dn(tJ.prototype,"separateAxes",[On,MK,PK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),rJ=Dn(tJ.prototype,"size",[IK,On,OK,FK,LK,kK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),nJ=Dn(tJ.prototype,"x",[VK,On,NK,GK,zK,UK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),sJ=Dn(tJ.prototype,"y",[HK,On,XK,WK,jK,YK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),aJ=Dn(tJ.prototype,"z",[qK,On,KK,JK,ZK,QK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),$K=tJ))||$K),_$=90794,f$=zs({Grid:0}),d$=zs({WholeSheet:0,SingleRow:1}),p$=(lJ=En("cc.TextureAnimationModule"),hJ=oa("numTilesX"),uJ=oa("numTilesY"),cJ=es(),_J=Wn(f$),fJ=Wn(f$),dJ=es(),pJ=is(),mJ=es(),gJ=is(),yJ=es(),vJ=is(),bJ=Wn(d$),SJ=es(),AJ=is(),TJ=Wn(NW),CJ=Ls(),xJ=es(),wJ=is(),EJ=Wn(NW),BJ=Ls(),RJ=es(),DJ=is(),MJ=es(),PJ=is(),IJ=es(),OJ=is(),FJ=es(),LJ=is(),lJ((QJ=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,Mn(e,"_enable",NJ,Pn(e)),Mn(e,"_numTilesX",GJ,Pn(e)),Mn(e,"_numTilesY",zJ,Pn(e)),Mn(e,"_mode",UJ,Pn(e)),Mn(e,"animation",HJ,Pn(e)),Mn(e,"frameOverTime",XJ,Pn(e)),Mn(e,"startFrame",WJ,Pn(e)),Mn(e,"cycleCount",jJ,Pn(e)),Mn(e,"_flipU",YJ,Pn(e)),Mn(e,"_flipV",qJ,Pn(e)),Mn(e,"_uvChannelMask",KJ,Pn(e)),Mn(e,"randomRow",JJ,Pn(e)),Mn(e,"rowIndex",ZJ,Pn(e)),e.name=GY,e}on(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,M(t.randomSeed+_$))/(this.numTilesX*this.numTilesY);if(this.animation===d$.WholeSheet)t.frameIndex=F(this.cycleCount*(this.frameOverTime.evaluate(e,M(t.randomSeed+_$))+i),1);else if(this.animation===d$.SingleRow){var r=1/this.numTilesY;if(this.randomRow){var n=F(this.cycleCount*(this.frameOverTime.evaluate(e,M(t.randomSeed+_$))+i),1),s=t.startRow*r,a=s+r;t.frameIndex=x(s,a,n)}else{var o=this.rowIndex*r,l=o+r;t.frameIndex=x(o,l,F(this.cycleCount*(this.frameOverTime.evaluate(e,M(t.randomSeed+_$))+i),1))}}},Ur(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!==f$.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}(XY),NJ=Dn((VJ=QJ).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),GJ=Dn(VJ.prototype,"_numTilesX",[hJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),zJ=Dn(VJ.prototype,"_numTilesY",[uJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(VJ.prototype,"enable",[cJ],Object.getOwnPropertyDescriptor(VJ.prototype,"enable"),VJ.prototype),UJ=Dn(VJ.prototype,"_mode",[_J],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return f$.Grid}}),Dn(VJ.prototype,"mode",[fJ,dJ,pJ],Object.getOwnPropertyDescriptor(VJ.prototype,"mode"),VJ.prototype),Dn(VJ.prototype,"numTilesX",[mJ,gJ],Object.getOwnPropertyDescriptor(VJ.prototype,"numTilesX"),VJ.prototype),Dn(VJ.prototype,"numTilesY",[yJ,vJ],Object.getOwnPropertyDescriptor(VJ.prototype,"numTilesY"),VJ.prototype),HJ=Dn(VJ.prototype,"animation",[bJ,On,SJ,AJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return d$.WholeSheet}}),XJ=Dn(VJ.prototype,"frameOverTime",[TJ,On,CJ,xJ,wJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),WJ=Dn(VJ.prototype,"startFrame",[EJ,On,BJ,RJ,DJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),jJ=Dn(VJ.prototype,"cycleCount",[On,MJ,PJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),YJ=Dn(VJ.prototype,"_flipU",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qJ=Dn(VJ.prototype,"_flipV",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),KJ=Dn(VJ.prototype,"_uvChannelMask",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),JJ=Dn(VJ.prototype,"randomRow",[On,IJ,OJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),ZJ=Dn(VJ.prototype,"rowIndex",[On,FJ,LJ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),kJ=VJ))||kJ),m$=197866,g$=new n,y$=($J=En("cc.VelocityOvertimeModule"),tZ=es(),eZ=Wn(NW),iZ=Ls(),rZ=es(),nZ=is(),sZ=Wn(NW),aZ=Ls(),oZ=es(),lZ=is(),hZ=Wn(NW),uZ=Ls(),cZ=es(),_Z=is(),fZ=Wn(NW),dZ=Ls(),pZ=es(),mZ=is(),gZ=Wn(WY),yZ=es(),vZ=is(),$J((BZ=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_enable",AZ,Pn(e)),Mn(e,"x",TZ,Pn(e)),Mn(e,"y",CZ,Pn(e)),Mn(e,"z",xZ,Pn(e)),Mn(e,"speedModifier",wZ,Pn(e)),Mn(e,"space",EZ,Pn(e)),e.rotation=void 0,e.needTransform=void 0,e.name="velocityModule",e.rotation=new l,e.speedModifier.constant=1,e.needTransform=!1,e.needUpdate=!0,e}on(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=iq(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=n.set(g$,this.x.evaluate(e,M(t.randomSeed^m$)),this.y.evaluate(e,M(156497^t.randomSeed)),this.z.evaluate(e,M(984136^t.randomSeed)));this.needTransform&&n.transformQuat(i,i,this.rotation),n.add(t.animatedVelocity,t.animatedVelocity,i),n.add(t.ultimateVelocity,t.velocity,t.animatedVelocity),n.multiplyScalar(t.ultimateVelocity,t.ultimateVelocity,this.speedModifier.evaluate(1-t.remainingLifetime/t.startLifetime,M(t.randomSeed+m$)))},Ur(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}(XY),AZ=Dn((SZ=BZ).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(SZ.prototype,"enable",[tZ],Object.getOwnPropertyDescriptor(SZ.prototype,"enable"),SZ.prototype),TZ=Dn(SZ.prototype,"x",[eZ,On,iZ,rZ,nZ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),CZ=Dn(SZ.prototype,"y",[sZ,On,aZ,oZ,lZ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),xZ=Dn(SZ.prototype,"z",[hZ,On,uZ,cZ,_Z],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),wZ=Dn(SZ.prototype,"speedModifier",[fZ,On,dZ,pZ,mZ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),EZ=Dn(SZ.prototype,"space",[gZ,On,yZ,vZ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.Local}}),bZ=SZ))||bZ),v$=t("Burst",(RZ=En("cc.Burst"),DZ=Wn(NW),MZ=Ls(),RZ((VZ=function(){function t(){Mn(this,"_time",OZ,this),Mn(this,"_repeatCount",FZ,this),Mn(this,"repeatInterval",LZ,this),Mn(this,"count",kZ,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=F(t._time-t.startDelay.evaluate(0,1),t.duration)-e;i=i>0?i:0;var r=F(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.reset=function(){this._remainingCount=0,this._curTime=0},e.getMaxCount=function(t){return this.count.getMax()*Math.min(Math.ceil(t.duration/this.repeatInterval),this.repeatCount)},Ur(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}(),OZ=Dn((IZ=VZ).prototype,"_time",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(IZ.prototype,"time",[Un],Object.getOwnPropertyDescriptor(IZ.prototype,"time"),IZ.prototype),FZ=Dn(IZ.prototype,"_repeatCount",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(IZ.prototype,"repeatCount",[Un],Object.getOwnPropertyDescriptor(IZ.prototype,"repeatCount"),IZ.prototype),LZ=Dn(IZ.prototype,"repeatInterval",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),kZ=Dn(IZ.prototype,"count",[DZ,On,MZ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),PZ=IZ))||PZ)),b$=new n(0,0,0),S$=[],A$=new n(.5,.5,.5),T$=(NZ=En("cc.ShapeModule"),GZ=es(),zZ=is(),UZ=es(),HZ=is(),XZ=es(),WZ=is(),jZ=es(),YZ=is(),qZ=cs(),KZ=es(),JZ=is(),ZZ=cs(),QZ=es(),$Z=Wn(KY),tQ=oa("shapeType"),eQ=es(),iQ=Wn(KY),rQ=is(),nQ=Wn(JY),sQ=es(),aQ=is(),oQ=cs(),lQ=es(),hQ=is(),uQ=es(),cQ=is(),_Q=es(),fQ=is(),dQ=es(),pQ=is(),mQ=es(),gQ=is(),yQ=cs(),vQ=es(),bQ=is(),SQ=cs(),AQ=Wn(ZY),TQ=es(),CQ=is(),xQ=cs(),wQ=cs(),EQ=es(),BQ=is(),RQ=cs(),DQ=Wn(NW),MQ=cs(),PQ=Ls(),IQ=es(),OQ=is(),FQ=cs(),LQ=es(),kQ=is(),VQ=cs(),NQ=es(),GQ=is(),zQ=cs(),NZ((h$=function(){function t(){Mn(this,"_enable",XQ,this),Mn(this,"_shapeType",WQ,this),Mn(this,"emitFrom",jQ,this),Mn(this,"alignToDirection",YQ,this),Mn(this,"randomDirectionAmount",qQ,this),Mn(this,"sphericalDirectionAmount",KQ,this),Mn(this,"randomPositionAmount",JQ,this),Mn(this,"radius",ZQ,this),Mn(this,"radiusThickness",QQ,this),Mn(this,"arcMode",$Q,this),Mn(this,"arcSpread",t$,this),Mn(this,"arcSpeed",e$,this),Mn(this,"length",i$,this),Mn(this,"boxThickness",r$,this),Mn(this,"_position",n$,this),Mn(this,"_rotation",s$,this),Mn(this,"_scale",a$,this),Mn(this,"_arc",o$,this),Mn(this,"_angle",l$,this),this.mat=void 0,this.quat=void 0,this.particleSystem=void 0,this.lastTime=void 0,this.totalAngle=void 0,this.mat=new c,this.quat=new l,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 KY.Box:!function(t,e,i,r){switch(t){case JY.Volume:s=i,a=A$,n.set(s,R(-a.x,a.x),R(-a.y,a.y),R(-a.z,a.z));break;case JY.Shell:S$.splice(0,S$.length),S$.push(R(-.5,.5)),S$.push(R(-.5,.5)),S$.push(.5*lq()),oq(S$),C$(S$,e),n.set(i,S$[0],S$[1],S$[2]);break;case JY.Edge:S$.splice(0,S$.length),S$.push(R(-.5,.5)),S$.push(.5*lq()),S$.push(.5*lq()),oq(S$),C$(S$,e),n.set(i,S$[0],S$[1],S$[2]);break;default:console.warn(t+" is not supported for box emitter.")}var s,a;n.copy(r,eq)}(this.emitFrom,this.boxThickness,t.position,t.velocity);break;case KY.Circle:e=this.radius,r=this.radiusThickness,s=this.generateArcAngle(),a=t.position,o=t.velocity,aq(a,e*(1-r),e,s),n.normalize(o,a);break;case KY.Cone:!function(t,e,r,s,a,o,l,h){switch(t){case JY.Base:aq(l,e*(1-r),e,s),i.multiplyScalar(h,l,Math.sin(a)),h.z=-Math.cos(a)*e,n.normalize(h,h),l.z=0;break;case JY.Shell:rq(l,s),i.multiplyScalar(h,l,Math.sin(a)),h.z=-Math.cos(a),n.normalize(h,h),i.multiplyScalar(l,l,e),l.z=0;break;case JY.Volume:aq(l,e*(1-r),e,s),i.multiplyScalar(h,l,Math.sin(a)),h.z=-Math.cos(a)*e,n.normalize(h,h),l.z=0,n.add(l,l,n.multiplyScalar(b$,h,o*B()/-h.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 KY.Sphere:!function(t,e,i,r,s){switch(t){case JY.Volume:sq(r,e*(1-i),e),n.normalize(s,r);break;case JY.Shell:nq(r),n.multiplyScalar(r,r,e),n.normalize(s,r);break;default:console.warn(t+" is not supported for sphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;case KY.Hemisphere:!function(t,e,i,r,s){switch(t){case JY.Volume:sq(r,e*(1-i),e),r.z>0&&(r.z*=-1),n.normalize(s,r);break;case JY.Shell:nq(r),n.multiplyScalar(r,r,e),r.z>0&&(r.z*=-1),n.normalize(s,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,r,s,a,o;if(this.randomPositionAmount>0&&(t.position.x+=R(-this.randomPositionAmount,this.randomPositionAmount),t.position.y+=R(-this.randomPositionAmount,this.randomPositionAmount),t.position.z+=R(-this.randomPositionAmount,this.randomPositionAmount)),n.transformQuat(t.velocity,t.velocity,this.quat),n.transformMat4(t.position,t.position,this.mat),this.sphericalDirectionAmount>0){var l=n.normalize(b$,t.position);n.lerp(t.velocity,t.velocity,l,this.sphericalDirectionAmount)}this.lastTime=this.particleSystem._time},e.constructMat=function(){l.fromEuler(this.quat,this._rotation.x,this._rotation.y,this._rotation.z),c.fromRTS(this.mat,this.quat,this._position,this._scale)},e.generateArcAngle=function(){if(this.arcMode===ZY.Random)return R(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 ZY.Loop:return F(t,this._arc);case ZY.PingPong:return L(t,this._arc);default:return F(t,this._arc)}},Ur(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 E(this._arc)},set:function(t){this._arc=w(t)}},{key:"angle",get:function(){return Math.round(100*E(this._angle))/100},set:function(t){this._angle=w(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 KY.Box:this.emitFrom===JY.Base&&(this.emitFrom=JY.Volume);break;case KY.Cone:this.emitFrom===JY.Edge&&(this.emitFrom=JY.Base);break;case KY.Sphere:case KY.Hemisphere:this.emitFrom!==JY.Base&&this.emitFrom!==JY.Edge||(this.emitFrom=JY.Volume)}}}]),t}(),Dn((HQ=h$).prototype,"position",[GZ,zZ],Object.getOwnPropertyDescriptor(HQ.prototype,"position"),HQ.prototype),Dn(HQ.prototype,"rotation",[UZ,HZ],Object.getOwnPropertyDescriptor(HQ.prototype,"rotation"),HQ.prototype),Dn(HQ.prototype,"scale",[XZ,WZ],Object.getOwnPropertyDescriptor(HQ.prototype,"scale"),HQ.prototype),Dn(HQ.prototype,"arc",[jZ,YZ,qZ],Object.getOwnPropertyDescriptor(HQ.prototype,"arc"),HQ.prototype),Dn(HQ.prototype,"angle",[KZ,JZ,ZZ],Object.getOwnPropertyDescriptor(HQ.prototype,"angle"),HQ.prototype),XQ=Dn(HQ.prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(HQ.prototype,"enable",[QZ],Object.getOwnPropertyDescriptor(HQ.prototype,"enable"),HQ.prototype),WQ=Dn(HQ.prototype,"_shapeType",[$Z,tQ,eQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return KY.Cone}}),Dn(HQ.prototype,"shapeType",[iQ,rQ],Object.getOwnPropertyDescriptor(HQ.prototype,"shapeType"),HQ.prototype),jQ=Dn(HQ.prototype,"emitFrom",[nQ,On,sQ,aQ,oQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return JY.Volume}}),YQ=Dn(HQ.prototype,"alignToDirection",[On,lQ,hQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),qQ=Dn(HQ.prototype,"randomDirectionAmount",[On,uQ,cQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),KQ=Dn(HQ.prototype,"sphericalDirectionAmount",[On,_Q,fQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),JQ=Dn(HQ.prototype,"randomPositionAmount",[On,dQ,pQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZQ=Dn(HQ.prototype,"radius",[On,mQ,gQ,yQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),QQ=Dn(HQ.prototype,"radiusThickness",[On,vQ,bQ,SQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),$Q=Dn(HQ.prototype,"arcMode",[AQ,On,TQ,CQ,xQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ZY.Random}}),t$=Dn(HQ.prototype,"arcSpread",[wQ,On,EQ,BQ,RQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),e$=Dn(HQ.prototype,"arcSpeed",[DQ,MQ,PQ,On,IQ,OQ,FQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),i$=Dn(HQ.prototype,"length",[On,LQ,kQ,VQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),r$=Dn(HQ.prototype,"boxThickness",[On,NQ,GQ,zQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(0,0,0)}}),n$=Dn(HQ.prototype,"_position",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(0,0,0)}}),s$=Dn(HQ.prototype,"_rotation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(0,0,0)}}),a$=Dn(HQ.prototype,"_scale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(1,1,1)}}),o$=Dn(HQ.prototype,"_arc",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return w(360)}}),l$=Dn(HQ.prototype,"_angle",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return w(25)}}),UQ=HQ))||UQ);function C$(t,e){e.x>0&&(t[0]+=.5*R(-e.x,e.x),t[0]=T(t[0],-.5,.5)),e.y>0&&(t[1]+=.5*R(-e.y,e.y),t[1]=T(t[1],-.5,.5)),e.z>0&&(t[2]+=.5*R(-e.z,e.z),t[2]=T(t[2],-.5,.5))}var x$,w$,E$,B$,R$,D$,M$,P$,I$,O$,F$,L$,k$,V$,N$,G$,z$,U$,H$,X$,W$,j$,Y$,q$,K$,J$,Z$,Q$,$$,t0,e0,i0,r0,n0,s0,a0,o0,l0,h0,u0,c0,_0,f0,d0,p0=[0,0,1,0,0,1,1,1],m0=[0,0,0,1,0,0,0,1,0,1,1,0],g0=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertAttrs=void 0,e._vertAttribSize=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._vertAttribSizeStatic=void 0,e._vertStaticAttrsFloatCount=void 0,e._insBuffers=void 0,e._insIndices=void 0,e._useInstance=void 0,e.type=nr.PARTICLE_BATCH,e._capacity=0,e._vertAttrs=null,e._vertAttribSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._vertAttribSizeStatic=0,e._vertStaticAttrsFloatCount=0,e._insBuffers=[],e._insIndices=null,Ci.gfxDevice.hasFeature($.INSTANCED_ARRAYS)?e._useInstance=!0:e._useInstance=!1,e._iaInfo=new se([new re]),e._iaInfoBuffer=e._device.createBuffer(new ee(rt.INDIRECT,at.HOST|at.DEVICE,qe,qe)),e._subMeshData=null,e._mesh=null,e}on(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._useInstance)this.setVertexAttributesIns(t,e);else{if(this._mesh===t&&this._vertAttrs===e)return;this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0;for(var i,r=hn(this._vertAttrs);!(i=r()).done;){var n=i.value;n.offset=this._vertAttribSize,this._vertAttribSize+=Xe[n.format].size}this._vertAttrsFloatCount=this._vertAttribSize/4,this.rebuild()}},i.setVertexAttributesIns=function(t,e){if(this._mesh!==t||this._vertAttrs!==e){this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0,this._vertAttribSizeStatic=0;for(var i,r=hn(this._vertAttrs);!(i=r()).done;){var n=i.value;0===n.stream?(n.offset=this._vertAttribSize,this._vertAttribSize+=Xe[n.format].size):1===n.stream&&(n.offset=this._vertAttribSizeStatic,this._vertAttribSizeStatic+=Xe[n.format].size)}this._vertAttrsFloatCount=this._vertAttribSize/4,this._vertStaticAttrsFloatCount=this._vertAttribSizeStatic/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 ee(rt.VERTEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,this._vertAttribSize*this._capacity*this._vertCount,this._vertAttribSize)),e=new ArrayBuffer(this._vertAttribSize*this._capacity*this._vertCount);if(this._mesh&&this._capacity>0){var i=this._vertAttrs[this._vertAttrs.findIndex((function(t){return t.name===He.ATTR_TEX_COORD}))].offset;this._mesh.copyAttribute(0,He.ATTR_TEX_COORD,e,this._vertAttribSize,i);var r=this._vertAttrs.findIndex((function(t){return t.name===He.ATTR_TEX_COORD3}));if(i=this._vertAttrs[r++].offset,this._mesh.copyAttribute(0,He.ATTR_POSITION,e,this._vertAttribSize,i),i=this._vertAttrs[r++].offset,this._mesh.copyAttribute(0,He.ATTR_NORMAL,e,this._vertAttribSize,i),i=this._vertAttrs[r++].offset,!this._mesh.copyAttribute(0,He.ATTR_COLOR,e,this._vertAttribSize,i))for(var n=new Uint32Array(e),s=0;s<this._vertCount;++s)n[s*this._vertAttrsFloatCount+i/4]=y.WHITE._val;for(var a=new Float32Array(e),o=1;o<this._capacity;o++)a.copyWithin(o*this._vertAttribSize*this._vertCount/4,0,this._vertAttribSize*this._vertCount/4)}t.update(e);var l=new Uint16Array(this._capacity*this._indexCount);if(this._mesh&&this._capacity>0){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 d=this._device.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,this._capacity*this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));return d.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 ee(rt.INDIRECT,at.HOST|at.DEVICE,qe,qe))),this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new Bn([t],this._vertAttrs,wt.TRIANGLE_LIST,d,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material),e},i.createSubMeshDataInsDynamic=function(){this.destroySubMeshData();var t=this._device.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,this._vertAttribSize*this._capacity,this._vertAttribSize)),e=new ArrayBuffer(this._vertAttribSize*this._capacity);return t.update(e),this._insBuffers.push(t),e},i.createSubMeshDataInsStatic=function(){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 ee(rt.VERTEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,this._vertAttribSizeStatic*this._vertCount,this._vertAttribSizeStatic)),e=new ArrayBuffer(this._vertAttribSizeStatic*this._vertCount);if(this._mesh){var i=this._vertAttrs.findIndex((function(t){return t.name===He.ATTR_TEX_COORD})),r=this._vertAttrs[i].offset;if(this._mesh.copyAttribute(0,He.ATTR_TEX_COORD,e,this._vertAttribSizeStatic,r),i=this._vertAttrs.findIndex((function(t){return t.name===He.ATTR_TEX_COORD3})),r=this._vertAttrs[i++].offset,this._mesh.copyAttribute(0,He.ATTR_POSITION,e,this._vertAttribSizeStatic,r),r=this._vertAttrs[i++].offset,this._mesh.copyAttribute(0,He.ATTR_NORMAL,e,this._vertAttribSizeStatic,r),r=this._vertAttrs[i++].offset,!this._mesh.copyAttribute(0,He.ATTR_COLOR,e,this._vertAttribSizeStatic,r))for(var n=new Uint32Array(e),s=0;s<this._vertCount;++s)n[s*this._vertStaticAttrsFloatCount+r/4]=y.WHITE._val}else for(var a=new Float32Array(e),o=0;o<m0.length;++o)a[o]=m0[o];t.update(e);var l=new Uint16Array(this._indexCount);this._mesh?this._mesh.copyIndices(0,l):(l[0]=0,l[1]=1,l[2]=2,l[3]=3,l[4]=2,l[5]=1);var h=this._device.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));h.update(l),this._insIndices=h,this._iaInfo.drawInfos[0].vertexCount=this._vertCount,this._iaInfo.drawInfos[0].indexCount=this._indexCount,this._iaInfoBuffer||(this._iaInfoBuffer=this._device.createBuffer(new ee(rt.INDIRECT,at.HOST|at.DEVICE,qe,qe))),this._iaInfoBuffer.update(this._iaInfo),this._insBuffers.push(t)},i.createInsSubmesh=function(){this._subMeshData=new Bn(this._insBuffers,this._vertAttrs,wt.TRIANGLE_LIST,this._insIndices,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material)},i.updateMaterial=function(t){this._material=t,this.setSubModelMaterial(0,t)},i.addParticleVertexData=function(t,e){if(this._useInstance)this.addParticleVertexDataIns(t,e);else 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.addParticleVertexDataIns=function(t,e){var i=t*this._vertAttrsFloatCount;this._mesh?(this._vdataF32[i++]=e[0].x,this._vdataF32[i++]=e[0].y,this._vdataF32[i++]=e[0].z,this._vdataF32[i++]=e[1].z,this._vdataF32[i++]=e[2].x,this._vdataF32[i++]=e[2].y,this._vdataF32[i++]=e[2].z,this._vdataF32[i++]=e[3].x,this._vdataF32[i++]=e[3].y,this._vdataF32[i++]=e[3].z,this._vdataUint32[i++]=e[4]):(this._vdataF32[i++]=e[0].x,this._vdataF32[i++]=e[0].y,this._vdataF32[i++]=e[0].z,this._vdataF32[i++]=e[1].z,this._vdataF32[i++]=e[2].x,this._vdataF32[i++]=e[2].y,this._vdataF32[i++]=e[2].z,this._vdataF32[i++]=e[3].x,this._vdataF32[i++]=e[3].y,this._vdataF32[i++]=e[3].z,this._vdataUint32[i++]=e[4],e[5]&&(this._vdataF32[i++]=e[5].x,this._vdataF32[i++]=e[5].y,this._vdataF32[i++]=e[5].z))},i.addGPUParticleVertexData=function(t,e,i){if(this._useInstance)this.addGPUParticleVertexDataIns(t,e,i);else 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++]=p0[2*n],this._vdataF32[s++]=t.rotation.x,this._vdataF32[s++]=t.rotation.y,this._vdataF32[s++]=t.rotation.z,this._vdataF32[s++]=p0[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.addGPUParticleVertexDataIns=function(t,e,i){var r=e*this._vertAttrsFloatCount,n=r;this._vdataF32[n++]=t.position.x,this._vdataF32[n++]=t.position.y,this._vdataF32[n++]=t.position.z,this._vdataF32[n++]=i,this._vdataF32[n++]=t.startSize.x,this._vdataF32[n++]=t.startSize.y,this._vdataF32[n++]=t.startSize.z,this._vdataF32[n++]=t.frameIndex,this._vdataF32[n++]=t.rotation.x,this._vdataF32[n++]=t.rotation.y,this._vdataF32[n++]=t.rotation.z,this._vdataF32[n++]=t.startColor.r/255,this._vdataF32[n++]=t.startColor.g/255,this._vdataF32[n++]=t.startColor.b/255,this._vdataF32[n++]=t.startColor.a/255,this._vdataF32[n++]=t.velocity.x,this._vdataF32[n++]=t.velocity.y,this._vdataF32[n++]=t.velocity.z,this._vdataF32[n++]=t.startLifetime,this._vdataF32[n++]=t.randomSeed,r+=this._vertAttrsFloatCount},i.updateGPUParticles=function(t,e,i){if(this._useInstance)return this.updateGPUParticlesIns(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.updateGPUParticlesIns=function(t,e,i){for(var r=this._vertAttrsFloatCount,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){if(this._useInstance)this.updateIAIns(t);else{if(t<=0)return;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.updateIAIns=function(t){if(!(t<=0)){var e=this._subModels[0].inputAssembler;e.vertexBuffers[0].update(this._vdataF32),e.instanceCount=t,this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount,this._iaInfo.drawInfos[0].instanceCount=t,this._iaInfoBuffer.update(this._iaInfo)}},i.clear=function(){this._useInstance?this.clearIns():this._subModels[0].inputAssembler.indexCount=0},i.clearIns=function(){this._subModels[0].inputAssembler.instanceCount=0},i.destroy=function(){t.prototype.destroy.call(this),this.doDestroy()},i.doDestroy=function(){this._vBuffer=null,this._vdataF32=null,this._vdataUint32=null,this._insBuffers=[],this._insIndices=null,this._vertAttrs=null,this._material=null,this._mesh=null,this.destroySubMeshData()},i.rebuild=function(){this._useInstance?this.rebuildIns():(this._vBuffer=this.createSubMeshData(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer))},i.rebuildIns=function(){this._vBuffer=this.createSubMeshDataInsDynamic(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer),this.createSubMeshDataInsStatic(),this.createInsSubmesh()},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null),this._iaInfoBuffer&&(this._iaInfoBuffer=null)},Ur(e,[{key:"useInstance",get:function(){return this._useInstance},set:function(t){this._useInstance!==t&&(this._useInstance=t)}}]),e}(sr),y0=function(){function t(t){this._particleSystem=null,this._model=null,this._renderInfo=null,this._vertAttrs=[],this._useInstance=void 0,this._renderInfo=t,Ci.gfxDevice.hasFeature($.INSTANCED_ARRAYS)?this._useInstance=!0:this._useInstance=!1}var e=t.prototype;return e.getUseInstance=function(){return this._useInstance},e.getInfo=function(){return this._renderInfo},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)}},e.onDisable=function(){this.detachFromScene()},e.onDestroy=function(){this._model&&(Er.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===qY.Mesh?this._renderInfo.mesh:null,this._vertAttrs)},e.clear=function(){this._model&&(this._model.enabled=!1)},e.getModel=function(){return this._model},e._initModel=function(){this._model||(this._model=Er.director.root.createModel(g0),this._model.setCapacity(this._particleSystem.capacity),this._model.visFlags=this._particleSystem.visibility)},e.updateTrailMaterial=function(){},e.getDefaultTrailMaterial=function(){return null},t}(),v0=function(){function t(t){this.permutation=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],this.accSpeed=new n,this.noiseSpeed=new n,this.noiseFrequency=0,this.noiseAbs=new n,this.noiseAmplitude=new n,this.octaves=new n,this.dt=0,this.point=new n,this.result=new n,this.mixOut=new i,t&&(this.permutation=t)}var e=t.prototype;return e.noise=function(t,e,i,r,n){void 0===r&&(r=0),void 0===n&&(n=1);for(var s=new Array(512),a=0;a<256;a++)s[256+a]=s[a]=this.permutation[a];var o=255&Math.floor(t),l=255&Math.floor(e),h=255&Math.floor(i);t-=Math.floor(t),e-=Math.floor(e),i-=Math.floor(i);var u=this.fade(t),c=this.fade(e),_=this.fade(i),f=s[o]+l,d=s[f]+h,p=s[f+1]+h,m=s[o+1]+l,g=s[m]+h,y=s[m+1]+h;return r+this.scale(this.lerp(_,this.lerp(c,this.lerp(u,this.grad(s[d],t,e,i),this.grad(s[g],t-1,e,i)),this.lerp(u,this.grad(s[p],t,e-1,i),this.grad(s[y],t-1,e-1,i))),this.lerp(c,this.lerp(u,this.grad(s[d+1],t,e,i-1),this.grad(s[g+1],t-1,e,i-1)),this.lerp(u,this.grad(s[p+1],t,e-1,i-1),this.grad(s[y+1],t-1,e-1,i-1)))))*(n-r)},e.fade=function(t){return t*t*t*(t*(6*t-15)+10)},e.lerp=function(t,e,i){return e+t*(i-e)},e.grad=function(t,e,i,r){var n=15&t,s=n<8?e:i,a=n<4?i:12===n||14===n?e:r;return(0==(1&n)?s:-s)+(0==(2&n)?a:-a)},e.scale=function(t){return(1+t)/2},e.setSpeed=function(t,e,i){this.noiseSpeed.set(t,e,i)},e.setFrequency=function(t){this.noiseFrequency=t},e.setAbs=function(t,e,i){this.noiseAbs.set(t,e,i)},e.setAmplititude=function(t,e,i){this.noiseAmplitude.set(t,e,i)},e.setOctaves=function(t,e,i){this.octaves.set(t,e,i)},e.setTime=function(t){this.dt=t},e.setSamplePoint=function(t){this.point.set(t)},e.getResult=function(){return this.result},e.getNoise=function(t,e,i,r,n,s,a){var o=s,l=0;if(l+=this.noise(t*o,e*o,i*o,-1,1),1===a.x)return l;for(var h=1,u=1,c=1;c<a.x;++c)h*=a.y,o*=a.z,u+=h,l+=this.noise(t*o,e*o,i*o,-1,1)*h;return l/u},e.getNoiseMix=function(t,e,i,r,n,s){t.x=this.getNoise(e.x,e.y,e.z,i,r,n,s),t.y=this.getNoise(e.y,e.z,e.x,i,r,n,s)},e.getNoiseParticle=function(){this.accSpeed.set(this.noiseSpeed.x*this.dt,this.noiseSpeed.y*this.dt,this.noiseSpeed.z*this.dt);var t=this.getNoise(this.point.z+this.accSpeed.x,this.point.y,this.point.x,this.dt,this.accSpeed,this.noiseFrequency,this.octaves),e=this.getNoise(this.point.x+1e3,this.point.z+this.accSpeed.y,this.point.y,this.dt,this.accSpeed,this.noiseFrequency,this.octaves),i=this.getNoise(this.point.y,this.point.x+1e3,this.point.z+this.accSpeed.z,this.dt,this.accSpeed,this.noiseFrequency,this.octaves);this.result.set(t*this.noiseAmplitude.x,e*this.noiseAmplitude.y,i*this.noiseAmplitude.z)},e.getPreview=function(t,e,i){for(var r=0;r<i;++r)for(var n=0;n<e;++n){var s=(n-.5*e)/e+this.noiseSpeed.x*this.dt,a=(r-.5*i)/i+this.noiseSpeed.y*this.dt,o=this.getNoise(s,a,0,this.dt,this.accSpeed,this.noiseFrequency,this.octaves);t[r*e+n]=.5*(o+1)}},t}(),b0=new n,S0=new c,A0=new l,T0=(new n,["_colorOverLifetimeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule"]),C0=[0,0,1,0,0,1,1,1],x0=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RGB32F),new ye(He.ATTR_TEX_COORD1,tt.RGB32F),new ye(He.ATTR_TEX_COORD2,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA8,!0)],w0=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RGB32F),new ye(He.ATTR_TEX_COORD1,tt.RGB32F),new ye(He.ATTR_TEX_COORD2,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA8,!0),new ye(He.ATTR_COLOR1,tt.RGB32F)],E0=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RGB32F),new ye(He.ATTR_TEX_COORD1,tt.RGB32F),new ye(He.ATTR_TEX_COORD2,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA8,!0),new ye(He.ATTR_TEX_COORD3,tt.RGB32F),new ye(He.ATTR_NORMAL,tt.RGB32F),new ye(He.ATTR_COLOR1,tt.RGBA8,!0)],B0=[new ye(He.ATTR_TEX_COORD4,tt.RGBA32F,!1,0,!0),new ye(He.ATTR_TEX_COORD1,tt.RGB32F,!1,0,!0),new ye(He.ATTR_TEX_COORD2,tt.RGB32F,!1,0,!0),new ye(He.ATTR_COLOR,tt.RGBA8,!0,0,!0),new ye(He.ATTR_TEX_COORD,tt.RGB32F,!1,1)],R0=[new ye(He.ATTR_TEX_COORD4,tt.RGBA32F,!1,0,!0),new ye(He.ATTR_TEX_COORD1,tt.RGB32F,!1,0,!0),new ye(He.ATTR_TEX_COORD2,tt.RGB32F,!1,0,!0),new ye(He.ATTR_COLOR,tt.RGBA8,!0,0,!0),new ye(He.ATTR_COLOR1,tt.RGB32F,!1,0,!0),new ye(He.ATTR_TEX_COORD,tt.RGB32F,!1,1)],D0=[new ye(He.ATTR_TEX_COORD4,tt.RGBA32F,!1,0,!0),new ye(He.ATTR_TEX_COORD1,tt.RGB32F,!1,0,!0),new ye(He.ATTR_TEX_COORD2,tt.RGB32F,!1,0,!0),new ye(He.ATTR_COLOR,tt.RGBA8,!0,0,!0),new ye(He.ATTR_TEX_COORD,tt.RGB32F,!1,1),new ye(He.ATTR_TEX_COORD3,tt.RGB32F,!1,1),new ye(He.ATTR_NORMAL,tt.RGB32F,!1,1),new ye(He.ATTR_COLOR1,tt.RGBA8,!0,1)],M0={parent:null,owner:null,subModelIdx:0},P0=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._tmp_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._uNodeRotHandle=0,i._alignSpace=YY.View,i._inited=!1,i._localMat=new c,i._gravity=new a,i.noise=new v0,i._model=null,i._frameTile_velLenScale=new a(1,1,0,0),i._tmp_velLenScale=i._frameTile_velLenScale.clone(),i._node_scale=new a,i._attrs=new Array(7),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}on(e,t);var r=e.prototype;return r.onInit=function(e){var i=this;t.prototype.onInit.call(this,e),this._particles=new X((function(){return new iY(i)}),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.onDestroy=function(){var e;null===(e=this._particles)||void 0===e||e.destroy(),t.prototype.onDestroy.call(this)},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;T0.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=UY.length;e<i;e++){var r=this._animateList[UY[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=UY.length;r<n;r++){var s=this._animateList[UY[r]];s&&this._runAnimateList.push(s)}this.updateMaterialParams()},r.updateAlignSpace=function(t){this._alignSpace=t},r.getDefaultMaterial=function(){return this._defaultMat},r.updateRotation=function(t){t&&this.doUpdateRotation(t)},r.doUpdateRotation=function(t){if(this._renderInfo.renderMode===qY.Mesh||this._alignSpace!==YY.View){if(this._alignSpace===YY.Local)this._particleSystem.node.getRotation(A0);else if(this._alignSpace===YY.World)this._particleSystem.node.getWorldRotation(A0);else if(this._alignSpace===YY.View){var e;A0.set(0,0,0,1);var i=null===(e=this._particleSystem.node.scene.renderScene)||void 0===e?void 0:e.cameras;if(void 0!==i)for(var r=0;r<(null==i?void 0:i.length);++r){var n=i[r];if((n.visibility&this._particleSystem.node.layer)===this._particleSystem.node.layer){l.fromViewUp(A0,n.forward);break}}}else A0.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,A0)}},r.updateScale=function(t){t&&this.doUpdateScale(t)},r.doUpdateScale=function(t){switch(this._particleSystem.scaleSpace){case WY.Local:this._particleSystem.node.getScale(this._node_scale);break;case WY.World:this._particleSystem.node.getWorldScale(this._node_scale)}t.setUniform(this._uScaleHandle,this._node_scale)},r.updateParticles=function(t){var e=this,i=this._particleSystem;if(!i)return this._particles.length;i.node.getWorldMatrix(S0);var r=(i.getMaterialInstance(0)||this._defaultMat).passes[0];this.doUpdateScale(r),this.doUpdateRotation(r),this._updateList.forEach((function(t){t.update(i._simulationSpace,S0)}));var s=i._trailModule,a=s&&s.enable;if(a&&s.update(),i.simulationSpace===WY.Local){var o=i.node.getRotation();c.fromQuat(this._localMat,o),this._localMat.transpose()}for(var l=function(r){var o=e._particles.data[r];if(o.remainingLifetime-=t,n.set(o.animatedVelocity,0,0,0),o.remainingLifetime<0)return a&&s.removeParticle(o),e._particles.removeAt(r),--r,h=r,"continue";if(i.simulationSpace===WY.Local){var l=9.8*-i.gravityModifier.evaluate(1-o.remainingLifetime/o.startLifetime,M(o.randomSeed))*t;e._gravity.x=0,e._gravity.y=l,e._gravity.z=0,e._gravity.w=1,e._gravity=e._gravity.transformMat4(e._localMat),o.velocity.x+=e._gravity.x,o.velocity.y+=e._gravity.y,o.velocity.z+=e._gravity.z}else o.velocity.y-=9.8*i.gravityModifier.evaluate(1-o.remainingLifetime/o.startLifetime,M(o.randomSeed))*t;n.copy(o.ultimateVelocity,o.velocity),e._runAnimateList.forEach((function(e){e.animate(o,t)})),n.scaleAndAdd(o.position,o.position,o.ultimateVelocity,t),a&&s.animate(o,t),h=r},h=0;h<this._particles.length;++h)l(h);return this._model.enabled=this._particles.length>0,this._particles.length},r.getNoisePreview=function(t,e,i){var r=this;this._runAnimateList.forEach((function(n){n.name===zY&&n.getNoisePreview(t,r._particleSystem,e,i)}))},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===qY.Mesh?this._fillDataFunc=this._fillMeshData:this._renderInfo.renderMode===qY.StrecthedBillboard?this._fillDataFunc=this._fillStrecthedData:this._fillDataFunc=this._fillNormalData},r._fillMeshData=function(t,e,i){var r=e/4;this._attrs[0]=t.position,b0.z=i,this._attrs[1]=b0,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._model.addParticleVertexData(r,this._attrs)},r._fillStrecthedData=function(t,e,i){if(this._useInstance)this._fillStrecthedDataIns(t,e,i);else for(var r=0;r<4;++r)this._attrs[0]=t.position,b0.x=C0[2*r],b0.y=C0[2*r+1],b0.z=i,this._attrs[1]=b0,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=t.ultimateVelocity,this._attrs[6]=null,this._model.addParticleVertexData(e++,this._attrs)},r._fillStrecthedDataIns=function(t,e,i){var r=e/4;this._attrs[0]=t.position,b0.z=i,this._attrs[1]=b0,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=t.ultimateVelocity,this._model.addParticleVertexData(r,this._attrs)},r._fillNormalData=function(t,e,i){if(this._useInstance)this._fillNormalDataIns(t,e,i);else for(var r=0;r<4;++r)this._attrs[0]=t.position,b0.x=C0[2*r],b0.y=C0[2*r+1],b0.z=i,this._attrs[1]=b0,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=null,this._model.addParticleVertexData(e++,this._attrs)},r._fillNormalDataIns=function(t,e,i){var r=e/4;this._attrs[0]=t.position,b0.z=i,this._attrs[1]=b0,this._attrs[2]=t.size,this._attrs[3]=t.rotation,this._attrs[4]=t.color._val,this._attrs[5]=null,this._model.addParticleVertexData(r,this._attrs)},r._setVertexAttrib=function(){if(this._useInstance)this._setVertexAttribIns();else switch(this._renderInfo.renderMode){case qY.StrecthedBillboard:this._vertAttrs=w0.slice();break;case qY.Mesh:this._vertAttrs=E0.slice();break;default:this._vertAttrs=x0.slice()}},r._setVertexAttribIns=function(){switch(this._renderInfo.renderMode){case qY.StrecthedBillboard:this._vertAttrs=R0.slice();break;case qY.Mesh:this._vertAttrs=D0.slice();break;default:this._vertAttrs=B0.slice()}},r.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;if(null!=e){var r=e._effectAsset._name;this._renderInfo.mainTexture=e.getProperty("mainTexture",0),-1!==r.indexOf("builtin-particle")&&-1===r.indexOf("builtin-particle-gpu")||t.setMaterial(null,0)}null==t.sharedMaterial&&null==this._defaultMat&&(M0.parent=os.get("default-particle-material"),M0.owner=this._particleSystem,M0.subModelIdx=0,this._defaultMat=new Ps(M0),M0.parent=null,M0.owner=null,M0.subModelIdx=0,null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var n=t.getMaterialInstance(0)||this._defaultMat;t._simulationSpace===WY.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var s=n.passes[0];this._uScaleHandle=s.getHandle("scale"),this._uLenHandle=s.getHandle("frameTile_velLenScale"),this._uNodeRotHandle=s.getHandle("nodeRotation");var o=this._renderInfo.renderMode,l=this._frameTile_velLenScale;o===qY.Billboard?this._defines.CC_RENDER_MODE=0:o===qY.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,l.z=this._renderInfo.velocityScale,l.w=this._renderInfo.lengthScale):o===qY.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:o===qY.VerticalBillboard?this._defines.CC_RENDER_MODE=3:o===qY.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+o+" not support.");var h=t._textureAnimationModule;h&&h.enable?(a.copy(this._tmp_velLenScale,l),i.set(this._tmp_velLenScale,h.numTilesX,h.numTilesY),s.setUniform(this._uLenHandle,this._tmp_velLenScale)):s.setUniform(this._uLenHandle,l);var u,c=this._particleSystem._rotationOvertimeModule;u=c&&c.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=u,this._defines.CC_INSTANCE_PARTICLE=this._useInstance,n.recompileShaders(this._defines),this._model&&this._model.updateMaterial(n)}},r.updateTrailMaterial=function(){if(this._particleSystem){var t=this._particleSystem,e=t._trailModule;if(e&&e.enable){t.simulationSpace===WY.World||e.space===WY.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&&(M0.parent=os.get("default-trail-material"),M0.owner=this._particleSystem,M0.subModelIdx=1,this._defaultTrailMat=new Ps(M0),M0.parent=null,M0.owner=null,M0.subModelIdx=0),(i=i||this._defaultTrailMat).recompileShaders(this._trailDefines),e.updateMaterial()}}},r.setUseInstance=function(t){this._useInstance!==t&&(this._useInstance=t,this._model&&(this._model.useInstance=t,this._model.doDestroy()),this.updateRenderMode())},e}(y0),I0=new c,O0=new a,F0=new l,L0=new l,k0=(new n,32),V0="a_position_starttime",N0="a_size_uv",G0="a_rotation_uv",z0="a_color",U0="a_dir_life",H0="a_rndSeed",X0="a_size_fid",W0="a_rotation",j0=[new ye(V0,tt.RGBA32F),new ye(N0,tt.RGBA32F),new ye(G0,tt.RGBA32F),new ye(z0,tt.RGBA32F),new ye(U0,tt.RGBA32F),new ye(H0,tt.R32F)],Y0=[new ye(V0,tt.RGBA32F),new ye(N0,tt.RGBA32F),new ye(G0,tt.RGBA32F),new ye(z0,tt.RGBA32F),new ye(U0,tt.RGBA32F),new ye(H0,tt.R32F),new ye(He.ATTR_TEX_COORD,tt.RGB32F),new ye(He.ATTR_TEX_COORD3,tt.RGB32F),new ye(He.ATTR_NORMAL,tt.RGB32F),new ye(He.ATTR_COLOR1,tt.RGBA8,!0)],q0=[new ye(V0,tt.RGBA32F,!1,0,!0),new ye(X0,tt.RGBA32F,!1,0,!0),new ye(W0,tt.RGB32F,!1,0,!0),new ye(z0,tt.RGBA32F,!1,0,!0),new ye(U0,tt.RGBA32F,!1,0,!0),new ye(H0,tt.R32F,!1,0,!0),new ye("a_uv",tt.RGB32F,!1,1)],K0=[new ye(V0,tt.RGBA32F,!1,0,!0),new ye(X0,tt.RGBA32F,!1,0,!0),new ye(W0,tt.RGB32F,!1,0,!0),new ye(z0,tt.RGBA32F,!1,0,!0),new ye(U0,tt.RGBA32F,!1,0,!0),new ye(H0,tt.R32F,!1,0,!0),new ye(He.ATTR_TEX_COORD,tt.RGB32F,!1,1),new ye(He.ATTR_TEX_COORD3,tt.RGB32F,!1,1),new ye(He.ATTR_NORMAL,tt.RGB32F,!1,1),new ye(He.ATTR_COLOR1,tt.RGBA8,!0,1)],J0={parent:null,owner:null,subModelIdx:0},Z0=function(t){function e(e){var i;return(i=t.call(this,e)||this)._defines=void 0,i._frameTile_velLenScale=void 0,i._unifrom_velLenScale=void 0,i._tmp_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._uNodeRotHandle=0,i._alignSpace=YY.View,i._inited=!1,i._frameTile_velLenScale=new a(1,1,0,0),i._unifrom_velLenScale=i._frameTile_velLenScale.clone(),i._tmp_velLenScale=i._frameTile_velLenScale.clone(),i._node_scale=new a,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 iY(null),i._particleNum=0,i}on(e,t);var r=e.prototype;return r.onInit=function(e){t.prototype.onInit.call(this,e),this._setVertexAttrib(),this._initModel(),this.updateMaterialParams(),this.setVertexAttributes(),this._inited=!0},r.updateRenderMode=function(){this._setVertexAttrib(),this.updateMaterialParams(),this.setVertexAttributes()},r.setVertexAttributes=function(){t.prototype.setVertexAttributes.call(this),this._model.constructAttributeIndex()},r.clear=function(){t.prototype.clear.call(this),this._particleNum=0,this.updateRenderData()},r.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()},r.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))},r.getFreeParticle=function(){return this._particleNum>=this._particleSystem._capacity?null:this._tempParticle},r.setNewParticle=function(t){this._model.addGPUParticleVertexData(t,this._particleNum,this._particleSystem._time),this._particleNum++},r.getDefaultMaterial=function(){return this._defaultMat},r.updateRotation=function(t){t&&this.doUpdateRotation(t)},r.doUpdateRotation=function(t){if(this._renderInfo.renderMode===qY.Mesh||this._alignSpace!==YY.View){if(this._alignSpace===YY.Local)this._particleSystem.node.getRotation(L0);else if(this._alignSpace===YY.World)this._particleSystem.node.getWorldRotation(L0);else if(this._alignSpace===YY.View){var e;L0.set(0,0,0,1);var i=null===(e=this._particleSystem.node.scene.renderScene)||void 0===e?void 0:e.cameras;if(void 0!==i)for(var r=0;r<(null==i?void 0:i.length);++r){var n=i[r];if((n.visibility&this._particleSystem.node.layer)===this._particleSystem.node.layer){l.fromViewUp(L0,n.forward);break}}}else L0.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,L0)}},r.updateScale=function(t){t&&this.doUpdateScale(t)},r.doUpdateScale=function(t){switch(this._particleSystem.scaleSpace){case WY.Local:this._particleSystem.node.getScale(this._node_scale);break;case WY.World:this._particleSystem.node.getWorldScale(this._node_scale)}t.setUniform(t.getHandle("scale"),this._node_scale)},r.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},r.updateRenderData=function(){},r.beforeRender=function(){this._model.updateIA(this._particleNum)},r.updateAlignSpace=function(t){this._alignSpace=t},r.updateShaderUniform=function(t){var e=this._particleSystem.getMaterialInstance(0)||this._defaultMat;if(e){var i=e.passes[0];O0.x=this._particleSystem._time,O0.y=t,i.setUniform(this._uTimeHandle,O0),this._particleSystem.node.getWorldRotation(F0),i.setUniform(this._uRotHandle,F0),this.doUpdateRotation(i)}},r.initShaderUniform=function(t){var e=t.passes[0];this._uTimeHandle=e.getHandle("u_timeDelta"),this._uRotHandle=e.getHandle("u_worldRot"),this._uNodeRotHandle=e.getHandle("nodeRotation"),this.doUpdateScale(e),e.setUniform(e.getHandle("frameTile_velLenScale"),this._unifrom_velLenScale),O0.x=k0,O0.y=.03125,e.setUniform(e.getHandle("u_sampleInfo"),O0);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=HW(k0,r.x,r.y,r.z);var n=e.getHandle("force_over_time_tex0"),s=ys.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(zW(e),zW(i),zW(r),zW(n)),a=new Float32Array(t*s*4),o=[e,i,r,n],l=1/(t-1),h=0;h<s;h++)for(var u=0;u<4;u++)for(var c=o[u],_=0,f=0,d=0;d<t;d++){var p=GW(c,l*d,h);f=(_+=p)/(d+1),a[4*(h*t+d)+u]=f}return UW(a,t,s)}(k0,l.x,l.y,l.z,l.speedModifier);var h=e.getHandle("velocity_over_time_tex0"),u=ys.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 Jj.TwoColors:case Jj.TwoGradients:return 2;default:return 1}}(e),r=new Uint8Array(t*i*4),n=1/t,s=0,a=0;a<i;a++)for(var o=0;o<t;o++){var l=Qj(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 fn;return h.create(t,i,_n.RGBA8888),h.setFilters(dn.LINEAR,dn.LINEAR),h.setWrapMode(Zs.CLAMP_TO_EDGE,Zs.CLAMP_TO_EDGE),h.uploadData(r),h}(k0,f.color);var d=e.getHandle("color_over_time_tex0"),p=ys.getBindingFromHandle(d);e.bindSampler(p,this._colorTexture.getGFXSampler()),e.bindTexture(p,this._colorTexture.getGFXTexture());var m=e.getHandle("u_color_mode");e.setUniform(m,this._colorTexture.height)}var g=this._particleSystem._rotationOvertimeModule;if(i=g&&g.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=i,i){this._rotationTexture&&this._rotationTexture.destroy(),g.separateAxes?this._rotationTexture=HW(k0,g.x,g.y,g.z):this._rotationTexture=function(t,e){for(var i=zW(e),r=new Float32Array(t*i*4),n=1/(t-1),s=0,a=0;a<i;a++)for(var o=0;o<t;o++){var l=GW(e,n*o,a);r[s+2]=l,s+=4}return UW(r,t,i)}(k0,g.z);var y=e.getHandle("rotation_over_time_tex0"),v=ys.getBindingFromHandle(y);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=HW(k0,S.x,S.y,S.z,!0):this._sizeTexture=function(t,e){for(var i=zW(e),r=new Float32Array(t*i*4),n=1/(t-1),s=0,a=0,o=0;o<i;o++){0;for(var l=0;l<t;l++){var h=GW(e,n*l,o);s=h,r[a]=s,r[a+1]=s,r[a+2]=s,a+=4}}return UW(r,t,i)}(k0,S.size);var A=e.getHandle("size_over_time_tex0"),T=ys.getBindingFromHandle(A);e.bindSampler(T,this._sizeTexture.getGFXSampler()),e.bindTexture(T,this._sizeTexture.getGFXTexture());var C=e.getHandle("u_size_mode");e.setUniform(C,this._sizeTexture.height)}var x=this._particleSystem._textureAnimationModule;if(i=x&&x.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(zW(e),zW(i)),n=new Float32Array(t*r*4),s=[e,i],a=1/(t-1),o=0;o<r;o++)for(var l=0;l<2;l++)for(var h=s[l],u=0,c=0;c<t;c++){var _=GW(h,a*c,o);u=_,n[4*(o*t+c)+l]=u}return UW(n,t,r)}(k0,x.startFrame,x.frameOverTime);var w=e.getHandle("texture_animation_tex0"),E=ys.getBindingFromHandle(w);e.bindSampler(E,this._animTexture.getGFXSampler()),e.bindTexture(E,this._animTexture.getGFXTexture());var B=e.getHandle("u_anim_info");O0.x=this._animTexture.height,O0.y=x.numTilesX*x.numTilesY,O0.z=x.cycleCount,e.setUniform(B,O0)}this._defines.USE_VK_SHADER=Ci.gfxDevice.gfxAPI===Z.VULKAN,this._defines.CC_INSTANCE_PARTICLE=this._useInstance},r.getParticleCount=function(){return this._particleNum},r.onMaterialModified=function(){this._inited&&this.updateMaterialParams()},r.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e)},r._setVertexAttrib=function(){if(this._useInstance)this._setVertexAttribIns();else switch(this._renderInfo.renderMode){case qY.StrecthedBillboard:this._vertAttrs=j0.slice();break;case qY.Mesh:this._vertAttrs=Y0.slice();break;default:this._vertAttrs=j0.slice()}},r._setVertexAttribIns=function(){switch(this._renderInfo.renderMode){case qY.StrecthedBillboard:this._vertAttrs=q0.slice();break;case qY.Mesh:this._vertAttrs=K0.slice();break;default:this._vertAttrs=q0.slice()}},r.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;if(null!==e){var r=e._effectAsset._name;this._renderInfo.mainTexture=e.getProperty("mainTexture",0),-1===r.indexOf("builtin-particle-gpu")&&(this._renderInfo.mainTexture=e.getProperty("mainTexture",0),this._particleSystem.setMaterial(null,0))}null==t.sharedMaterial&&null==this._defaultMat&&(J0.parent=os.get("default-particle-gpu-material"),J0.owner=t,J0.subModelIdx=0,this._defaultMat=new Ps(J0),J0.parent=null,J0.owner=null,J0.subModelIdx=0,null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var n=t.getMaterialInstance(0)||this._defaultMat;t.node.getWorldMatrix(I0),t._simulationSpace===WY.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var s=this._renderInfo.renderMode;s===qY.Billboard?this._defines.CC_RENDER_MODE=0:s===qY.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,this._frameTile_velLenScale.z=this._renderInfo.velocityScale,this._frameTile_velLenScale.w=this._renderInfo.lengthScale):s===qY.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:s===qY.VerticalBillboard?this._defines.CC_RENDER_MODE=3:s===qY.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+s+" not support.");var o=t._textureAnimationModule;o&&o.enable?(i.set(this._frameTile_velLenScale,o.numTilesX,o.numTilesY),a.copy(this._unifrom_velLenScale,this._frameTile_velLenScale)):(this._tmp_velLenScale.z=this._frameTile_velLenScale.z,this._tmp_velLenScale.w=this._frameTile_velLenScale.w,a.copy(this._unifrom_velLenScale,this._tmp_velLenScale)),this.initShaderUniform(n),n.recompileShaders(this._defines),this._model&&this._model.updateMaterial(n)}},r.setUseInstance=function(t){this._useInstance!==t&&(this._useInstance=t,this._model&&(this._model.useInstance=t,this._model.doDestroy()),this.updateRenderMode())},r.getNoisePreview=function(){},e}(y0);function Q0(){var t=Kr.root.device;return!!(t.capabilities.maxVertexTextureUnits>=8&&t.getFormatFeatures(tt.RGBA32F)&(ut.RENDER_TARGET|ut.SAMPLED_TEXTURE))||(Er.warn("Maybe the device has restrictions on vertex textures or does not support float textures."),!1)}var $0,t1,e1,i1,r1,n1,s1,a1,o1,l1,h1,u1,c1,_1,f1,d1,p1,m1,g1,y1,v1,b1,S1,A1,T1,C1,x1,w1,E1,B1,R1,D1,M1,P1,I1,O1,F1,L1,k1,V1,N1,G1,z1,U1,H1,X1,W1,j1,Y1,q1,K1,J1,Z1,Q1,$1,t2,e2,i2,r2,n2,s2,a2,o2,l2,h2,u2,c2,_2,f2,d2,p2,m2,g2,y2,v2,b2,S2,A2,T2,C2,x2,w2,E2,B2,R2,D2,M2,P2,I2,O2,F2,L2,k2,V2,N2,G2,z2,U2,H2,X2,W2,j2,Y2,q2,K2,J2,Z2,Q2,$2,t3,e3,i3,r3,n3,s3,a3,o3,l3,h3,u3,c3,_3,f3,d3,p3,m3,g3,y3,v3,b3,S3,A3,T3,C3,x3,w3,E3,B3,R3,D3,M3,P3,I3,O3,F3,L3,k3,V3,N3,G3,z3,U3,H3,X3,W3,j3,Y3,q3,K3,J3,Z3,Q3,$3,t5,e5,i5,r5,n5,s5,a5,o5,l5,h5,u5,c5,_5,f5,d5,p5,m5,g5,y5,v5,b5,S5,A5,T5,C5,x5,w5,E5,B5,R5,D5,M5,P5,I5,O5,F5,L5,k5,V5,N5,G5,z5,U5,H5,X5,W5,j5,Y5,q5,K5,J5,Z5,Q5,$5,t8,e8,i8,r8,n8,s8,a8,o8,l8,h8,u8,c8,_8,f8,d8,p8,m8,g8,y8,v8,b8,S8,A8,T8,C8,x8,w8,E8,B8,R8,D8,M8,P8,I8,O8,F8,L8,k8,V8,N8,G8,z8,U8,H8,X8,W8,j8,Y8,q8,K8,J8,Z8,Q8,$8,t4,e4,i4,r4,n4,s4,a4,o4,l4,h4,u4,c4,_4,f4,d4,p4,m4,g4,y4,v4,b4,S4,A4,T4,C4,x4,w4,E4,B4,R4,D4,M4,P4,I4,O4,F4,L4,k4,V4,N4,G4,z4,U4,H4=(x$=En("cc.ParticleSystemRenderer"),w$=Wn(qY),E$=es(),B$=is(),R$=es(),D$=is(),M$=es(),P$=is(),I$=Wn(qY),O$=Wn(sh),F$=es(),L$=is(),k$=Wn(cn),V$=es(),N$=cs(),G$=is(),z$=Wn(cn),U$=es(),H$=cs(),X$=Wn(cn),W$=es(),j$=cs(),Y$=Wn(cn),q$=es(),K$=cs(),J$=is(),Z$=es(),Q$=is(),$$=Wn(YY),t0=es(),e0=is(),x$((d0=f0=function(){function t(){Mn(this,"_renderMode",n0,this),Mn(this,"_velocityScale",s0,this),Mn(this,"_lengthScale",a0,this),Mn(this,"_mesh",o0,this),Mn(this,"_cpuMaterial",l0,this),Mn(this,"_gpuMaterial",h0,this),Mn(this,"_mainTexture",u0,this),Mn(this,"_useGPU",c0,this),Mn(this,"_alignSpace",_0,this),this._particleSystem=null}var e=t.prototype;return e.create=function(t){null===this._particleSystem?this._particleSystem=t:this._particleSystem!==t&&Nn(6033)},e.onInit=function(t){if(this.create(t),this._particleSystem.processor)Nn(6034);else{var e=this._useGPU&&Q0();this._particleSystem.processor=e?new Z0(this):new P0(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(t)}this._useGPU?this.gpuMaterial=this.particleMaterial:this.cpuMaterial=this.particleMaterial},e._switchProcessor=function(){this._particleSystem&&(this._particleSystem.processor&&(this._particleSystem.processor.detachFromScene(),this._particleSystem.processor.clear(),this._particleSystem.processor=null),!this._useGPU&&this.cpuMaterial&&(this.particleMaterial=this.cpuMaterial),this._useGPU&&this.gpuMaterial&&(this.particleMaterial=this.gpuMaterial),this._particleSystem.processor=this._useGPU?new Z0(this):new P0(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(this._particleSystem),this._particleSystem.processor.onEnable(),this._particleSystem.bindModule())},Ur(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:"cpuMaterial",get:function(){return this._cpuMaterial},set:function(t){if(null!==t){var e=t.effectName;-1!==e.indexOf("particle")&&-1===e.indexOf("particle-gpu")?(this._cpuMaterial=t,this.particleMaterial=this._cpuMaterial):Rn(6035)}}},{key:"gpuMaterial",get:function(){return this._gpuMaterial},set:function(t){null!==t&&(-1!==t.effectName.indexOf("particle-gpu")?(this._gpuMaterial=t,this.particleMaterial=this._gpuMaterial):Rn(6035))}},{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&&(Q0()?this._useGPU=t:this._useGPU=!1,this._switchProcessor())}},{key:"alignSpace",get:function(){return this._alignSpace},set:function(t){this._alignSpace=t,this._particleSystem.processor.updateAlignSpace(this._alignSpace)}}]),t}(),f0.AlignmentSpace=YY,Dn((r0=d0).prototype,"renderMode",[w$,E$,B$],Object.getOwnPropertyDescriptor(r0.prototype,"renderMode"),r0.prototype),Dn(r0.prototype,"velocityScale",[R$,D$],Object.getOwnPropertyDescriptor(r0.prototype,"velocityScale"),r0.prototype),Dn(r0.prototype,"lengthScale",[M$,P$],Object.getOwnPropertyDescriptor(r0.prototype,"lengthScale"),r0.prototype),n0=Dn(r0.prototype,"_renderMode",[I$,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qY.Billboard}}),s0=Dn(r0.prototype,"_velocityScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),a0=Dn(r0.prototype,"_lengthScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),o0=Dn(r0.prototype,"_mesh",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(r0.prototype,"mesh",[O$,F$,L$],Object.getOwnPropertyDescriptor(r0.prototype,"mesh"),r0.prototype),Dn(r0.prototype,"particleMaterial",[k$,V$,hs,N$,G$],Object.getOwnPropertyDescriptor(r0.prototype,"particleMaterial"),r0.prototype),Dn(r0.prototype,"cpuMaterial",[z$,U$,hs,H$],Object.getOwnPropertyDescriptor(r0.prototype,"cpuMaterial"),r0.prototype),l0=Dn(r0.prototype,"_cpuMaterial",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(r0.prototype,"gpuMaterial",[X$,W$,hs,j$],Object.getOwnPropertyDescriptor(r0.prototype,"gpuMaterial"),r0.prototype),h0=Dn(r0.prototype,"_gpuMaterial",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(r0.prototype,"trailMaterial",[Y$,q$,hs,K$,J$],Object.getOwnPropertyDescriptor(r0.prototype,"trailMaterial"),r0.prototype),u0=Dn(r0.prototype,"_mainTexture",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),c0=Dn(r0.prototype,"_useGPU",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(r0.prototype,"useGPU",[Z$,Q$],Object.getOwnPropertyDescriptor(r0.prototype,"useGPU"),r0.prototype),Dn(r0.prototype,"alignSpace",[$$,t0,e0],Object.getOwnPropertyDescriptor(r0.prototype,"alignSpace"),r0.prototype),_0=Dn(r0.prototype,"_alignSpace",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return YY.View}}),i0=r0))||i0),X4=Math.cos(w(100)),W4={position:new n,velocity:new n},j4=new l,Y4=new c,q4=new n,K4=new n,J4=new y,Z4=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 n,lifetime:0,width:0,velocity:new n,direction:0,color:new y})}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 n,lifetime:0,width:0,velocity:new n,direction:0,color:new y}),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}(),Q4=($0=En("cc.TrailModule"),t1=es(),e1=Wn(QY),i1=es(),r1=is(),n1=Wn(NW),s1=Ls(),a1=es(),o1=is(),l1=es(),h1=is(),u1=Wn(WY),c1=es(),_1=is(),f1=Wn($Y),d1=es(),p1=is(),m1=es(),g1=is(),y1=Wn(NW),v1=Ls(),b1=es(),S1=is(),A1=es(),T1=is(),C1=Wn(Zj),x1=es(),w1=is(),E1=Wn(Zj),B1=es(),R1=is(),D1=Wn(WY),$0((j1=function(){var t=e.prototype;function e(){Mn(this,"_enable",I1,this),Mn(this,"mode",O1,this),Mn(this,"lifeTime",F1,this),Mn(this,"_minParticleDistance",L1,this),Mn(this,"existWithParticles",k1,this),Mn(this,"textureMode",V1,this),Mn(this,"widthFromParticle",N1,this),Mn(this,"widthRatio",G1,this),Mn(this,"colorFromParticle",z1,this),Mn(this,"colorOverTrail",U1,this),Mn(this,"colorOvertime",H1,this),Mn(this,"_space",X1,this),Mn(this,"_particleSystem",W1,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 se([new re]),this._vertAttrs=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RGBA32F),new ye(He.ATTR_TEX_COORD1,tt.RGB32F),new ye(He.ATTR_COLOR,tt.RGBA8,!0)],this._vertSize=0;for(var t,e=hn(this._vertAttrs);!(t=e()).done;){var i=t.value;this._vertSize+=Xe[i.format].size}this._particleTrail=new Map}return t.getModel=function(){return this._trailModel},t.onInit=function(t){this._particleSystem=t,this.minParticleDistance=this._minParticleDistance;for(var e=0,i=t.startLifetime.getMax(),r=t.rateOverTime.getMax(),n=t.duration,s=0,a=t.bursts.length;s<a;s++)e+=t.bursts[s].getMaxCount(t)*Math.ceil(i/n);this._trailNum=Math.ceil(i*this.lifeTime.getMax()*60*(r*n+e)),this._trailSegments=new H((function(){return new Z4(10)}),Math.ceil(r*n),(function(t){return t.trailElements.length=0})),this._enable&&(this.enable=this._enable)},t.onEnable=function(){this._attachToScene()},t.onDisable=function(){this._particleTrail.clear(),this._detachFromScene()},t._attachToScene=function(){this._trailModel&&(this._trailModel.scene&&this._detachFromScene(),this._particleSystem._getRenderScene().addModel(this._trailModel))},t._detachFromScene=function(){this._trailModel&&this._trailModel.scene&&this._trailModel.scene.removeModel(this._trailModel)},t.destroy=function(){this.destroySubMeshData(),this._trailModel&&(Kr.root.destroyModel(this._trailModel),this._trailModel=null),this._trailSegments&&(this._trailSegments.destroy(),this._trailSegments=null)},t.play=function(){this._trailModel&&this._enable&&(this._trailModel.enabled=!0)},t.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)}},t.updateMaterial=function(){this._particleSystem&&(this._material=this._particleSystem.getMaterialInstance(1)||this._particleSystem.processor._defaultTrailMat,this._trailModel&&this._trailModel.setSubModelMaterial(0,this._material))},t.update=function(){this._trailLifetime=this.lifeTime.evaluate(this._particleSystem._time,1),this.space===WY.World&&this._particleSystem._simulationSpace===WY.Local?(this._needTransform=!0,this._particleSystem.node.getWorldMatrix(Y4),this._particleSystem.node.getWorldRotation(j4)):this._needTransform=!1},t.animate=function(t,e){if(this._trailSegments)if(t.loopCount>t.lastLoop)t.trailDelay>1?(t.lastLoop=t.loopCount,t.trailDelay=0):t.trailDelay++;else{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?n.transformMat4(q4,t.position,Y4):n.copy(q4,t.position),!(r&&(i.iterateElement(this,this._updateTrailElement,t,e),n.squaredDistance(r.position,q4)<this._minSquaredDistance))&&(r=i.addElement())){n.copy(r.position,q4),r.lifetime=0,this.widthFromParticle?r.width=t.size.x*this.widthRatio.evaluate(0,1):r.width=this.widthRatio.evaluate(0,1);var s=i.count();if(2===s){var a=i.getElement(i.end-2);n.subtract(a.velocity,r.position,a.position)}else if(s>2){var o=i.getElement(i.end-2),l=i.getElement(i.end-3);n.subtract(q4,l.position,o.position),n.subtract(K4,r.position,o.position),n.subtract(o.velocity,K4,q4),n.equals(n.ZERO,o.velocity)&&n.copy(o.velocity,q4),n.normalize(o.velocity,o.velocity),this._checkDirectionReverse(o,l)}this.colorFromParticle?r.color.set(t.color):r.color.set(this.colorOvertime.evaluate(0,1))}}},t.removeParticle=function(t){var e=this._particleTrail.get(t);e&&this._trailSegments&&(e.clear(),this._trailSegments.free(e),this._particleTrail.delete(t))},t.updateRenderData=function(){this.vbOffset=0,this.ibOffset=0;for(var t,e=hn(this._particleTrail.keys());!(t=e()).done;){var i=t.value,r=this._particleTrail.get(i);if(-1!==r.start){var s=4*this.vbOffset/this._vertSize,a=r.start>=r.end?r.end+r.trailElements.length:r.end,o=a-r.start,l=1/o,h=r.trailElements[r.start];this._fillVertexBuffer(h,this.colorOverTrail.evaluate(1,1),s,1,0,4);for(var u=r.start+1;u<a;u++){var c=r.trailElements[u%r.trailElements.length],_=u-r.start;this._fillVertexBuffer(c,this.colorOverTrail.evaluate(1-_/o,1),s,1-_*l,_,5)}this._needTransform?n.transformMat4(W4.position,i.position,Y4):n.copy(W4.position,i.position);var f=this._trailModel;if(f&&f.node.invalidateChildren(Ws.POSITION),1===o||2===o){var d=r.getElement(r.end-1);n.subtract(d.velocity,W4.position,d.position),this._vbF32[this.vbOffset-this._vertSize/4-4]=d.velocity.x,this._vbF32[this.vbOffset-this._vertSize/4-3]=d.velocity.y,this._vbF32[this.vbOffset-this._vertSize/4-2]=d.velocity.z,this._vbF32[this.vbOffset-4]=d.velocity.x,this._vbF32[this.vbOffset-3]=d.velocity.y,this._vbF32[this.vbOffset-2]=d.velocity.z,n.subtract(W4.velocity,W4.position,d.position),this._checkDirectionReverse(W4,d)}else if(o>2){var p=r.getElement(r.end-1),m=r.getElement(r.end-2);n.subtract(q4,m.position,p.position),n.subtract(K4,W4.position,p.position),n.normalize(q4,q4),n.normalize(K4,K4),n.subtract(p.velocity,K4,q4),n.normalize(p.velocity,p.velocity),this._checkDirectionReverse(p,m),this.vbOffset-=this._vertSize/4*2,this.ibOffset-=6,this._fillVertexBuffer(p,this.colorOverTrail.evaluate(l,1),s,l,o-1,5),n.subtract(W4.velocity,W4.position,p.position),n.normalize(W4.velocity,W4.velocity),this._checkDirectionReverse(W4,p)}this.widthFromParticle?W4.width=i.size.x*this.widthRatio.evaluate(0,1):W4.width=this.widthRatio.evaluate(0,1),W4.color=i.color,n.equals(W4.velocity,n.ZERO)?this.ibOffset-=3:this._fillVertexBuffer(W4,this.colorOverTrail.evaluate(0,1),s,0,o,1)}}this._trailModel.enabled=this.ibOffset>0},t.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)}},t.beforeRender=function(){this.updateIA(this.ibOffset)},t._createModel=function(){this._trailModel||(this._trailModel=Er.director.root.createModel(sr))},t.rebuild=function(){var t=Kr.root.device,e=t.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.HOST|at.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 ee(rt.INDEX|rt.TRANSFER_DST,at.HOST|at.DEVICE,6*Math.max(1,this._trailNum)*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));this._iBuffer=new Uint16Array(6*Math.max(1,this._trailNum)),r.update(this._iBuffer),this._iaInfoBuffer=t.createBuffer(new ee(rt.INDIRECT,at.HOST|at.DEVICE,qe,qe)),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 Bn([e],this._vertAttrs,wt.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)},t._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},t._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,J4.set(t.color),J4.multiply(e),this._vbUint32[this.vbOffset++]=J4._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++]=J4._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)},t._checkDirectionReverse=function(t,e){n.dot(t.velocity,e.velocity)<X4?t.direction=1-e.direction:t.direction=e.direction},t.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null)},Ur(e,[{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()}}]),e}(),Dn((P1=j1).prototype,"enable",[t1],Object.getOwnPropertyDescriptor(P1.prototype,"enable"),P1.prototype),I1=Dn(P1.prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),O1=Dn(P1.prototype,"mode",[e1,On,i1,r1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return QY.Particles}}),F1=Dn(P1.prototype,"lifeTime",[n1,On,s1,a1,o1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),L1=Dn(P1.prototype,"_minParticleDistance",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),Dn(P1.prototype,"minParticleDistance",[l1,h1],Object.getOwnPropertyDescriptor(P1.prototype,"minParticleDistance"),P1.prototype),Dn(P1.prototype,"space",[u1,c1,_1],Object.getOwnPropertyDescriptor(P1.prototype,"space"),P1.prototype),k1=Dn(P1.prototype,"existWithParticles",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),V1=Dn(P1.prototype,"textureMode",[f1,On,d1,p1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return $Y.Stretch}}),N1=Dn(P1.prototype,"widthFromParticle",[On,m1,g1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),G1=Dn(P1.prototype,"widthRatio",[y1,On,v1,b1,S1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),z1=Dn(P1.prototype,"colorFromParticle",[On,A1,T1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),U1=Dn(P1.prototype,"colorOverTrail",[C1,On,x1,w1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zj}}),H1=Dn(P1.prototype,"colorOvertime",[E1,On,B1,R1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zj}}),X1=Dn(P1.prototype,"_space",[D1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.World}}),W1=Dn(P1.prototype,"_particleSystem",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),M1=P1))||M1),$4=new c,t6=new l,e6=new n,i6=["_colorOverLifetimeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule"],r6=function(){function t(t){this._particleSystem=void 0,this._processor=void 0,this._node=void 0,this._particlesAll=void 0,this._updateList=new Map,this._animateList=new Map,this._runAnimateList=new Array,this._localMat=new c,this._gravity=new a,this.minPos=new n,this.maxPos=new n,this._nodePos=new n,this._nodeSize=new n,this._particleSystem=t,this._processor=this._particleSystem.processor,this._node=t.node,this._particlesAll=[],this._initModuleList()}var e=t.prototype;return e._updateBoundingNode=function(){this._nodeSize.set(this.maxPos.x-this.minPos.x,this.maxPos.y-this.minPos.y,this.maxPos.z-this.minPos.z),this._nodePos.set(this.minPos.x+.5*this._nodeSize.x,this.minPos.y+.5*this._nodeSize.y,this.minPos.z+.5*this._nodeSize.z)},e.setBoundingBoxSize=function(t){this.maxPos.x=this._nodePos.x+t.x,this.maxPos.y=this._nodePos.y+t.y,this.maxPos.z=this._nodePos.z+t.z,this.minPos.x=this._nodePos.x-t.x,this.minPos.y=this._nodePos.y-t.y,this.minPos.z=this._nodePos.z-t.z,this._updateBoundingNode()},e.setBoundingBoxCenter=function(t,e,i){this.maxPos.x=t+.5*this._nodeSize.x,this.maxPos.y=e+.5*this._nodeSize.y,this.maxPos.z=i+.5*this._nodeSize.z,this.minPos.x=t-.5*this._nodeSize.x,this.minPos.y=e-.5*this._nodeSize.y,this.minPos.z=i-.5*this._nodeSize.z,this._updateBoundingNode()},e._initModuleList=function(){var t=this;i6.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=UY.length;e<i;e++){var r=this._animateList[UY[e]];r&&this._runAnimateList.push(r)}},e._emit=function(t,e,i){var r=this._particleSystem,s=this._node,a=r.time%r.duration/r.duration;s.invalidateChildren(Ws.POSITION),r.simulationSpace===WY.World&&(s.getWorldMatrix($4),s.getWorldRotation(t6));for(var o=0;o<t;++o){var l=new iY(r);l.particleSystem=r,l.reset();var h=M(D(0,mo));r._shapeModule&&r._shapeModule.enable?r._shapeModule.emit(l):(n.set(l.position,0,0,0),n.copy(l.velocity,eq)),r._textureAnimationModule&&r._textureAnimationModule.enable&&r._textureAnimationModule.init(l);var u=r.startSpeed.evaluate(a,h);n.multiplyScalar(l.velocity,l.velocity,u),r.simulationSpace===WY.World&&(n.transformMat4(l.position,l.position,$4),n.transformQuat(l.velocity,l.velocity,t6)),n.copy(l.ultimateVelocity,l.velocity),n.set(l.rotation,0,0,0),r.startSize3D?n.set(l.startSize,r.startSizeX.evaluate(a,h),r.startSizeY.evaluate(a,h),r.startSizeZ.evaluate(a,h)):(n.set(l.startSize,r.startSizeX.evaluate(a,h),1,1),l.startSize.y=l.startSize.x),n.copy(l.size,l.startSize),l.startLifetime=r.startLifetime.evaluate(a,h)+e,l.remainingLifetime=l.startLifetime,i.push(l)}},e._updateParticles=function(t,e){var i=this,r=this._particleSystem;switch(r.node.getWorldMatrix($4),r.scaleSpace){case WY.Local:r.node.getScale(e6);break;case WY.World:r.node.getWorldScale(e6)}if(this._updateList.forEach((function(t){t.update(r.simulationSpace,$4)})),r.simulationSpace===WY.Local){var s=r.node.getRotation();c.fromQuat(this._localMat,s),this._localMat.transpose()}for(var a=function(s){var a=e[s];if(a.remainingLifetime-=t,n.set(a.animatedVelocity,0,0,0),r.simulationSpace===WY.Local){var o=9.8*-r.gravityModifier.evaluate(1-a.remainingLifetime/a.startLifetime,M(a.randomSeed))*t;i._gravity.x=0,i._gravity.y=o,i._gravity.z=0,i._gravity.w=1,i._gravity=i._gravity.transformMat4(i._localMat),a.velocity.x+=i._gravity.x,a.velocity.y+=i._gravity.y,a.velocity.z+=i._gravity.z}else a.velocity.y-=9.8*r.gravityModifier.evaluate(1-a.remainingLifetime/a.startLifetime,M(a.randomSeed))*t;n.copy(a.ultimateVelocity,a.velocity),i._runAnimateList.forEach((function(e){e.animate(a,t)})),n.scaleAndAdd(a.position,a.position,a.ultimateVelocity,t)},o=0;o<e.length;++o)a(o)},e._calculateBounding=function(t){var e=new n,i=new n,r=new n,s=new n,a=new n(1,1,1);if(this._processor.getInfo().renderMode===qY.Mesh){var o=this._processor.getInfo().mesh;if(o&&o.struct.minPosition&&o.struct.maxPosition){var l=new Ii;Ii.fromPoints(l,o.struct.minPosition,o.struct.maxPosition);var h=Math.max(l.halfExtents.x,l.halfExtents.y,l.halfExtents.z);a.set(h,h,h)}}for(var u=this._particleSystem.node.worldMatrix,c=0;c<this._particlesAll.length;++c){var _=this._particlesAll[c];n.multiply(e,e6,_.size),n.multiply(e,e,a),i.set(_.position),this._particleSystem.simulationSpace!==WY.World&&n.transformMat4(i,i,u),t&&0===c?(n.subtract(this.minPos,i,e),n.add(this.maxPos,i,e)):(n.subtract(r,i,e),n.add(s,i,e),n.min(this.minPos,this.minPos,r),n.max(this.maxPos,this.maxPos,s))}},e.calculatePositions=function(){this._emit(this._particleSystem.capacity,0,this._particlesAll);var t=M(D(0,mo));this._updateParticles(0,this._particlesAll),this._calculateBounding(!0),this._updateParticles(this._particleSystem.startLifetime.evaluate(0,t),this._particlesAll),this._calculateBounding(!1),this._updateBoundingNode()},e.clear=function(){this._particlesAll.length=0},e.destroy=function(){},t}(),n6=(Y1=En("cc.NoiseModule"),q1=es(),K1=Wn(sa),J1=Ls(),Z1=es(),Q1=Wn(sa),$1=Ls(),t2=es(),e2=Wn(sa),i2=Ls(),r2=es(),n2=Wn(sa),s2=Ls(),a2=es(),o2=Wn(sa),l2=Ls(),h2=es(),u2=Wn(sa),c2=Ls(),_2=es(),f2=Wn(sa),d2=Ls(),p2=yo(),m2=es(),g2=cs(),y2=Wn(sa),v2=Ls(),b2=yo(),S2=es(),A2=cs(),T2=Wn(sa),C2=Ls(),x2=yo(),w2=es(),E2=cs(),B2=Wn(sa),R2=Ls(),D2=yo(),M2=es(),P2=Wn(go),I2=Ls(),O2=yo(),F2=es(),L2=cs(),k2=Wn(sa),V2=Ls(),N2=yo(),G2=es(),z2=cs(),U2=Wn(sa),H2=Ls(),X2=yo(),W2=es(),Y1((l3=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,Mn(e,"_enable",q2,Pn(e)),Mn(e,"_strengthX",K2,Pn(e)),Mn(e,"_strengthY",J2,Pn(e)),Mn(e,"_strengthZ",Z2,Pn(e)),Mn(e,"_noiseSpeedX",Q2,Pn(e)),Mn(e,"_noiseSpeedY",$2,Pn(e)),Mn(e,"_noiseSpeedZ",t3,Pn(e)),Mn(e,"_noiseFrequency",e3,Pn(e)),Mn(e,"_remapX",i3,Pn(e)),Mn(e,"_remapY",r3,Pn(e)),Mn(e,"_remapZ",n3,Pn(e)),Mn(e,"_octaves",s3,Pn(e)),Mn(e,"_octaveMultiplier",a3,Pn(e)),Mn(e,"_octaveScale",o3,Pn(e)),e.name=zY,e.noise=new v0,e}on(e,t);var i=e.prototype;return i.animate=function(t,e){this.noise.setTime(t.particleSystem.time),this.noise.setSpeed(this.noiseSpeedX,this.noiseSpeedY,this.noiseSpeedZ),this.noise.setFrequency(this.noiseFrequency),this.noise.setAbs(this.remapX,this.remapY,this.remapZ),this.noise.setAmplititude(this.strengthX,this.strengthY,this.strengthZ),this.noise.setOctaves(this.octaves,this.octaveMultiplier,this.octaveScale),this.noise.setSamplePoint(t.position),this.noise.getNoiseParticle();var i=this.noise.getResult();i.multiply3f(Math.random(),Math.random(),Math.random()),n.add(t.position,t.position,i.multiplyScalar(e))},i.getNoisePreview=function(t,e,i,r){this.noise.setTime(e.time),this.noise.setSpeed(this.noiseSpeedX,this.noiseSpeedY,this.noiseSpeedZ),this.noise.setFrequency(this.noiseFrequency),this.noise.setAbs(this.remapX,this.remapY,this.remapZ),this.noise.setAmplititude(this.strengthX,this.strengthY,this.strengthZ),this.noise.setOctaves(this.octaves,this.octaveMultiplier,this.octaveScale),this.noise.getNoiseParticle(),this.noise.getPreview(t,i,r)},Ur(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:"strengthX",get:function(){return this._strengthX},set:function(t){this._strengthX=t}},{key:"strengthY",get:function(){return this._strengthY},set:function(t){this._strengthY=t}},{key:"strengthZ",get:function(){return this._strengthZ},set:function(t){this._strengthZ=t}},{key:"noiseSpeedX",get:function(){return this._noiseSpeedX},set:function(t){this._noiseSpeedX=t}},{key:"noiseSpeedY",get:function(){return this._noiseSpeedY},set:function(t){this._noiseSpeedY=t}},{key:"noiseSpeedZ",get:function(){return this._noiseSpeedZ},set:function(t){this._noiseSpeedZ=t}},{key:"noiseFrequency",get:function(){return this._noiseFrequency},set:function(t){this._noiseFrequency=t}},{key:"remapX",get:function(){return this._remapX},set:function(t){this._remapX=t}},{key:"remapY",get:function(){return this._remapY},set:function(t){this._remapY=t}},{key:"remapZ",get:function(){return this._remapZ},set:function(t){this._remapZ=t}},{key:"octaves",get:function(){return this._octaves},set:function(t){this._octaves=t}},{key:"octaveMultiplier",get:function(){return this._octaveMultiplier},set:function(t){this._octaveMultiplier=t}},{key:"octaveScale",get:function(){return this._octaveScale},set:function(t){this._octaveScale=t}}]),e}(XY),q2=Dn((Y2=l3).prototype,"_enable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(Y2.prototype,"enable",[q1],Object.getOwnPropertyDescriptor(Y2.prototype,"enable"),Y2.prototype),Dn(Y2.prototype,"strengthX",[K1,J1,Z1,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"strengthX"),Y2.prototype),K2=Dn(Y2.prototype,"_strengthX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),Dn(Y2.prototype,"strengthY",[Q1,$1,t2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"strengthY"),Y2.prototype),J2=Dn(Y2.prototype,"_strengthY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),Dn(Y2.prototype,"strengthZ",[e2,i2,r2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"strengthZ"),Y2.prototype),Z2=Dn(Y2.prototype,"_strengthZ",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),Dn(Y2.prototype,"noiseSpeedX",[n2,s2,Ns,a2],Object.getOwnPropertyDescriptor(Y2.prototype,"noiseSpeedX"),Y2.prototype),Q2=Dn(Y2.prototype,"_noiseSpeedX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"noiseSpeedY",[o2,l2,h2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"noiseSpeedY"),Y2.prototype),$2=Dn(Y2.prototype,"_noiseSpeedY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"noiseSpeedZ",[u2,c2,_2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"noiseSpeedZ"),Y2.prototype),t3=Dn(Y2.prototype,"_noiseSpeedZ",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"noiseFrequency",[f2,d2,p2,m2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"noiseFrequency"),Y2.prototype),e3=Dn(Y2.prototype,"_noiseFrequency",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(Y2.prototype,"remapX",[g2,y2,v2,b2,S2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"remapX"),Y2.prototype),i3=Dn(Y2.prototype,"_remapX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"remapY",[A2,T2,C2,x2,w2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"remapY"),Y2.prototype),r3=Dn(Y2.prototype,"_remapY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"remapZ",[E2,B2,R2,D2,M2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"remapZ"),Y2.prototype),n3=Dn(Y2.prototype,"_remapZ",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Y2.prototype,"octaves",[P2,I2,O2,F2,Ns],Object.getOwnPropertyDescriptor(Y2.prototype,"octaves"),Y2.prototype),s3=Dn(Y2.prototype,"_octaves",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(Y2.prototype,"octaveMultiplier",[L2,k2,V2,N2,G2],Object.getOwnPropertyDescriptor(Y2.prototype,"octaveMultiplier"),Y2.prototype),a3=Dn(Y2.prototype,"_octaveMultiplier",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),Dn(Y2.prototype,"octaveScale",[z2,U2,H2,X2,W2],Object.getOwnPropertyDescriptor(Y2.prototype,"octaveScale"),Y2.prototype),o3=Dn(Y2.prototype,"_octaveScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),j2=Y2))||j2),s6=new c,a6=new l,o6=Object.getOwnPropertyDescriptor(ls.prototype,"sharedMaterials"),l6=function(e){return t({ParticleSystem:e,ParticleSystemComponent:e}),e}((h3=En("cc.ParticleSystem"),u3=Qn(),c3=ts(),_3=$n(99),f3=Ls(),d3=es(),p3=is(),m3=Wn(Zj),g3=es(),y3=is(),v3=Wn(WY),b3=es(),S3=is(),A3=es(),T3=is(),C3=oa("startSize"),x3=Ls(),w3=Wn(NW),E3=es(),B3=is(),R3=Wn(NW),D3=Ls(),M3=es(),P3=is(),I3=cs(),O3=Wn(NW),F3=Ls(),L3=es(),k3=is(),V3=cs(),N3=Wn(NW),G3=Ls(),z3=es(),U3=is(),H3=es(),X3=is(),W3=Wn(NW),j3=Ls(),Y3=es(),q3=is(),K3=cs(),J3=Wn(NW),Z3=Ls(),Q3=es(),$3=is(),t5=cs(),e5=Wn(NW),i5=oa("startRotation"),r5=Ls(),n5=es(),s5=is(),a5=cs(),o5=Wn(NW),l5=Ls(),h5=es(),u5=is(),c5=Wn(NW),_5=Ls(),f5=es(),d5=is(),p5=es(),m5=is(),g5=es(),y5=is(),v5=es(),b5=is(),S5=Wn(WY),A5=es(),T5=is(),C5=es(),x5=is(),w5=es(),E5=is(),B5=Wn(NW),R5=Ls(),D5=es(),M5=is(),P5=Wn(NW),I5=Ls(),O5=es(),F5=is(),L5=Wn(NW),k5=Ls(),V5=es(),N5=is(),G5=Wn([v$]),z5=es(),U5=is(),H5=Wn(ha),X5=es(),W5=is(),j5=Wn(jY),Y5=es(),q5=is(),K5=Wn(sa),J5=es(),Z5=is(),Q5=Wn(sa),$5=es(),t8=is(),e8=Wn(sa),i8=es(),r8=is(),n8=es(),s8=is(),a8=oa("enableCulling"),o8=cs(),l8=Wn(cn),h8=_s(),u8=Wn(tq),c8=Wn(tq),_8=es(),f8=is(),d8=Wn(T$),p8=Wn(T$),m8=es(),g8=is(),y8=Wn(c$),v8=Wn(c$),b8=es(),S8=is(),A8=Wn(y$),T8=Wn(y$),C8=es(),x8=is(),w8=Wn(TK),E8=Wn(TK),B8=es(),R8=is(),D8=Wn(EK),M8=Wn(EK),P8=es(),I8=is(),O8=Wn(u$),F8=Wn(u$),L8=es(),k8=is(),V8=Wn(p$),N8=Wn(p$),G8=es(),z8=is(),U8=Wn(n6),H8=Wn(n6),X8=es(),W8=Wn(Q4),j8=Wn(Q4),Y8=es(),q8=is(),K8=Wn(H4),J8=es(),Z8=is(),h3(Q8=u3(Q8=c3(Q8=_3(Q8=Jn((U4=z4=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"startColor",t4,Pn(e)),Mn(e,"scaleSpace",e4,Pn(e)),Mn(e,"startSize3D",i4,Pn(e)),Mn(e,"startSizeX",r4,Pn(e)),Mn(e,"startSizeY",n4,Pn(e)),Mn(e,"startSizeZ",s4,Pn(e)),Mn(e,"startSpeed",a4,Pn(e)),Mn(e,"startRotation3D",o4,Pn(e)),Mn(e,"startRotationX",l4,Pn(e)),Mn(e,"startRotationY",h4,Pn(e)),Mn(e,"startRotationZ",u4,Pn(e)),Mn(e,"startDelay",c4,Pn(e)),Mn(e,"startLifetime",_4,Pn(e)),Mn(e,"duration",f4,Pn(e)),Mn(e,"loop",d4,Pn(e)),Mn(e,"simulationSpeed",p4,Pn(e)),Mn(e,"playOnAwake",m4,Pn(e)),Mn(e,"gravityModifier",g4,Pn(e)),Mn(e,"rateOverTime",y4,Pn(e)),Mn(e,"rateOverDistance",v4,Pn(e)),Mn(e,"bursts",b4,Pn(e)),Mn(e,"_renderCulling",S4,Pn(e)),Mn(e,"_cullingMode",A4,Pn(e)),Mn(e,"_aabbHalfX",T4,Pn(e)),Mn(e,"_aabbHalfY",C4,Pn(e)),Mn(e,"_aabbHalfZ",x4,Pn(e)),Mn(e,"_dataCulling",w4,Pn(e)),Mn(e,"_colorOverLifetimeModule",E4,Pn(e)),Mn(e,"_shapeModule",B4,Pn(e)),Mn(e,"_sizeOvertimeModule",R4,Pn(e)),Mn(e,"_velocityOvertimeModule",D4,Pn(e)),Mn(e,"_forceOvertimeModule",M4,Pn(e)),Mn(e,"_limitVelocityOvertimeModule",P4,Pn(e)),Mn(e,"_rotationOvertimeModule",I4,Pn(e)),Mn(e,"_textureAnimationModule",O4,Pn(e)),Mn(e,"_noiseModule",F4,Pn(e)),Mn(e,"_trailModule",L4,Pn(e)),Mn(e,"renderer",k4,Pn(e)),e._isPlaying=void 0,e._isPaused=void 0,e._isStopped=void 0,e._isEmitting=void 0,e._needRefresh=void 0,e._time=void 0,e._emitRateTimeCounter=void 0,e._emitRateDistanceCounter=void 0,e._oldWPos=void 0,e._curWPos=void 0,e._boundingBox=void 0,e._culler=void 0,e._oldPos=void 0,e._curPos=void 0,e._isCulled=void 0,e._isSimulating=void 0,e._customData1=void 0,e._customData2=void 0,e._subEmitters=void 0,e._needAttach=void 0,Mn(e,"_prewarm",V4,Pn(e)),Mn(e,"_capacity",N4,Pn(e)),Mn(e,"_simulationSpace",G4,Pn(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._needRefresh=!0,e._needAttach=!1,e._time=0,e._emitRateTimeCounter=0,e._emitRateDistanceCounter=0,e._oldWPos=new n,e._curWPos=new n,e._boundingBox=null,e._culler=null,e._oldPos=null,e._curPos=null,e._isCulled=!1,e._isSimulating=!0,e._customData1=new i,e._customData2=new i,e._subEmitters=[],e}on(e,t);var r=e.prototype;return r.onFocusInEditor=function(){this.renderer.create(this)},r.onLoad=function(){this.renderer.onInit(this),this._shapeModule&&this._shapeModule.onInit(this),this._trailModule&&this._trailModule.onInit(this),this.bindModule(),this._resetPosition()},r._onMaterialModified=function(t,e){null!==this.processor&&this.processor.onMaterialModified(t,e)},r._onRebuildPSO=function(t,e){this.processor.onRebuildPSO(t,e)},r._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},r._attachToScene=function(){this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._attachToScene()},r._detachFromScene=function(){this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},r.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),this._noiseModule&&this._noiseModule.bindTarget(this.processor)},r.play=function(){if(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(),this.processor){var t=this.processor.getModel();t&&(t.enabled=this.enabledInHierarchy)}},r.pause=function(){this._isStopped?console.warn("pause(): particle system is already stopped."):(this._isPlaying&&(this._isPlaying=!1),this._isPaused=!0)},r.stopEmitting=function(){this._isEmitting=!1},r.stop=function(){(this._isPlaying||this._isPaused)&&this.clear(),this._isPlaying&&(this._isPlaying=!1),this._isPaused&&(this._isPaused=!1),this._isEmitting&&(this._isEmitting=!1),this._time=0,this._emitRateTimeCounter=0,this._emitRateDistanceCounter=0,this._isStopped=!0,this._needRefresh=!0;for(var t,e=hn(this.bursts);!(t=e()).done;)t.value.reset()},r.clear=function(){this.enabledInHierarchy&&(this.processor.clear(),this._trailModule&&this._trailModule.clear()),this._calculateBounding(!1)},r.getParticleCount=function(){return this.processor.getParticleCount()},r.setCustomData1=function(t,e){i.set(this._customData1,t,e)},r.setCustomData2=function(t,e){i.set(this._customData2,t,e)},r.onDestroy=function(){var t;this.stop(),(null===(t=this.processor.getModel())||void 0===t?void 0:t.scene)&&(this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene()),Er.director.off(Er.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDestroy(),this._trailModule&&this._trailModule.destroy(),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},r.onEnable=function(){t.prototype.onEnable.call(this),Er.director.on(Er.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.playOnAwake&&!uo&&this.play(),this.processor.onEnable(),this._trailModule&&this._trailModule.onEnable()},r.onDisable=function(){Er.director.off(Er.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDisable(),this._trailModule&&this._trailModule.onDisable(),this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null)},r._calculateBounding=function(t){this._boundingBox&&(this._culler||(this._culler=new r6(this)),this._culler.calculatePositions(),Ii.fromPoints(this._boundingBox,this._culler.minPos,this._culler.maxPos),t?(this.aabbHalfX=this._boundingBox.halfExtents.x,this.aabbHalfY=this._boundingBox.halfExtents.y,this.aabbHalfZ=this._boundingBox.halfExtents.z):(this.aabbHalfX?this.setBoundingX(this.aabbHalfX):this.aabbHalfX=this._boundingBox.halfExtents.x,this.aabbHalfY?this.setBoundingY(this.aabbHalfY):this.aabbHalfY=this._boundingBox.halfExtents.y,this.aabbHalfZ?this.setBoundingZ(this.aabbHalfZ):this.aabbHalfZ=this._boundingBox.halfExtents.z),this._culler.clear())},r.update=function(t){var e,i,r=t*this.simulationSpeed;if(this.renderCulling){var s;if(this._boundingBox||(this._boundingBox=new Ii,this._calculateBounding(!1)),this._curPos||(this._curPos=new n),this.node.getWorldPosition(this._curPos),this._oldPos||(this._oldPos=new n,this._oldPos.set(this._curPos)),!this._curPos.equals(this._oldPos)&&this._boundingBox&&this._culler){var a=this._curPos.x-this._oldPos.x,o=this._curPos.y-this._oldPos.y,l=this._curPos.z-this._oldPos.z,h=this._boundingBox.center;h.x+=a,h.y+=o,h.z+=l,this._culler.setBoundingBoxCenter(h.x,h.y,h.z),this._oldPos.set(this._curPos)}var u=null===(s=this.node.scene.renderScene)||void 0===s?void 0:s.cameras,c=!0;if(void 0!==u&&this._boundingBox)for(var _=0;_<u.length;++_){var f=u[_];if((f.visibility&this.node.layer)===this.node.layer&&Ei.aabbFrustum(this._boundingBox,f.frustum)){c=!1;break}}if(c){if(this._cullingMode!==jY.AlwaysSimulate&&(this._isSimulating=!1),this._isCulled||(this.processor.detachFromScene(),this._isCulled=!0),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._cullingMode===jY.PauseAndCatchup&&(this._time+=r),this._cullingMode!==jY.AlwaysSimulate)return}else this._isCulled&&(this._attachToScene(),this._isCulled=!1),this._isSimulating||(this._isSimulating=!0);if(!this._isSimulating)return}else this._boundingBox&&(this._boundingBox=null),this._culler&&(this._culler.clear(),this._culler.destroy(),this._culler=null),this._isSimulating=!0;if(this._isPlaying)this._time+=r,this._emit(r),0!==this.processor.updateParticles(r)||this._isEmitting||this.stop();else{var d=(this.getMaterialInstance(0)||this.processor.getDefaultMaterial()).passes[0];this.processor.updateRotation(d),this.processor.updateScale(d)}(this.processor.updateRenderData(),this._trailModule&&this._trailModule.enable&&this._trailModule.updateRenderData(),this._needAttach&&this.getParticleCount()>0&&!this._isCulled)&&((null===(e=this.processor.getModel())||void 0===e?void 0:e.scene)||this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&((null===(i=this._trailModule.getModel())||void 0===i?void 0:i.scene)||this._trailModule._attachToScene()),this._needAttach=!1)},r.beforeRender=function(){var t,e;this._isPlaying&&(this.processor.beforeRender(),this._trailModule&&this._trailModule.enable&&this._trailModule.beforeRender(),this.getParticleCount()<=0?(null===(e=this.processor.getModel())||void 0===e?void 0:e.scene)&&(this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._needAttach=!1):(null===(t=this.processor.getModel())||void 0===t?void 0:t.scene)||(this._needAttach=!0))},r._onVisibilityChange=function(t){this.processor._model&&(this.processor._model.visFlags=t)},r.emit=function(t,e){var i=this._time%this.duration/this.duration;this._needRefresh&&(this.node.invalidateChildren(Ws.POSITION),this._needRefresh=!1),this._simulationSpace===WY.World&&(this.node.getWorldMatrix(s6),this.node.getWorldRotation(a6));for(var r=0;r<t;++r){var s=this.processor.getFreeParticle();if(null===s)return;s.particleSystem=this,s.reset();var a=M(D(0,mo));this._shapeModule&&this._shapeModule.enable?this._shapeModule.emit(s):(n.set(s.position,0,0,0),n.copy(s.velocity,eq)),this._textureAnimationModule&&this._textureAnimationModule.enable&&this._textureAnimationModule.init(s);var o=this.startSpeed.evaluate(i,a);n.multiplyScalar(s.velocity,s.velocity,o),this._simulationSpace===WY.World&&(n.transformMat4(s.position,s.position,s6),n.transformQuat(s.velocity,s.velocity,a6)),n.copy(s.ultimateVelocity,s.velocity),this.startRotation3D?s.startEuler.set(this.startRotationX.evaluate(i,a),this.startRotationY.evaluate(i,a),this.startRotationZ.evaluate(i,a)):s.startEuler.set(0,0,this.startRotationZ.evaluate(i,a)),s.rotation.set(s.startEuler),this.startSize3D?n.set(s.startSize,this.startSizeX.evaluate(i,a),this.startSizeY.evaluate(i,a),this.startSizeZ.evaluate(i,a)):(n.set(s.startSize,this.startSizeX.evaluate(i,a),1,1),s.startSize.y=s.startSize.x),n.copy(s.size,s.startSize),s.startColor.set(this.startColor.evaluate(i,a)),s.color.set(s.startColor),s.startLifetime=this.startLifetime.evaluate(i,a)+e,s.remainingLifetime=s.startLifetime,s.randomSeed=D(0,233280),s.loopCount++,this.processor.setNewParticle(s)}},r._prewarmSystem=function(){this.startDelay.mode=VW.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)},r._emit=function(t){var e=this.startDelay.evaluate(0,1);if(this._time>e){if(this._time>this.duration+e&&(this.loop||(this._isEmitting=!1)),!this._isEmitting)return;if(this._emitRateTimeCounter+=this.rateOverTime.evaluate(this._time/this.duration,1)*t,this._emitRateTimeCounter>1){var i=Math.floor(this._emitRateTimeCounter);this._emitRateTimeCounter-=i,this.emit(i,t)}this.node.getWorldPosition(this._curWPos);var r=n.distance(this._curWPos,this._oldWPos);if(n.copy(this._oldWPos,this._curWPos),this._emitRateDistanceCounter+=r*this.rateOverDistance.evaluate(this._time/this.duration,1),this._emitRateDistanceCounter>1){var s=Math.floor(this._emitRateDistanceCounter);this._emitRateDistanceCounter-=s,this.emit(s,t)}for(var a,o=hn(this.bursts);!(a=o()).done;)a.value.update(this,t)}},r._resetPosition=function(){this.node.getWorldPosition(this._oldWPos),n.copy(this._curWPos,this._oldWPos)},r.addSubEmitter=function(t){this._subEmitters.push(t)},r.removeSubEmitter=function(t){this._subEmitters.splice(this._subEmitters.indexOf(t),1)},r.addBurst=function(t){this.bursts.push(t)},r.removeBurst=function(t){this.bursts.splice(this.bursts.indexOf(t),1)},r.getBoundingX=function(){return this._aabbHalfX},r.getBoundingY=function(){return this._aabbHalfY},r.getBoundingZ=function(){return this._aabbHalfZ},r.setBoundingX=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.x=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfX=t)},r.setBoundingY=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.y=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfY=t)},r.setBoundingZ=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.z=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfZ=t)},r._onBeforeSerialize=function(t){var e=this;return this.dataCulling?t.filter((function(t){return!HY.includes(t)||e[t]&&e[t].enable})):t},r.getNoisePreview=function(t,e){var i=[];return this.processor&&this.processor.getNoisePreview(i,t,e),i},Ur(e,[{key:"capacity",get:function(){return this._capacity},set:function(t){this._capacity=Math.floor(t>0?t:0),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:"renderCulling",get:function(){return this._renderCulling},set:function(t){this._renderCulling=t,t&&(this._boundingBox||(this._boundingBox=new Ii,this._calculateBounding(!1)))}},{key:"cullingMode",get:function(){return this._cullingMode},set:function(t){this._cullingMode=t}},{key:"aabbHalfX",get:function(){return this.getBoundingX()||0},set:function(t){this.setBoundingX(t)}},{key:"aabbHalfY",get:function(){return this.getBoundingY()||0},set:function(t){this.setBoundingY(t)}},{key:"aabbHalfZ",get:function(){return this.getBoundingZ()||0},set:function(t){this.setBoundingZ(t)}},{key:"dataCulling",get:function(){return this._dataCulling},set:function(t){this._dataCulling=t}},{key:"sharedMaterials",get:function(){return o6.get.call(this)},set:function(t){o6.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:"noiseModule",get:function(){return this._noiseModule},set:function(t){t&&(this._noiseModule=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}(Ys),z4.CullingMode=jY,Dn(($8=U4).prototype,"capacity",[f3,d3,p3],Object.getOwnPropertyDescriptor($8.prototype,"capacity"),$8.prototype),t4=Dn($8.prototype,"startColor",[m3,On,g3,y3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zj}}),e4=Dn($8.prototype,"scaleSpace",[v3,On,b3,S3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.Local}}),i4=Dn($8.prototype,"startSize3D",[On,A3,T3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),r4=Dn($8.prototype,"startSizeX",[C3,x3,w3,E3,B3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),n4=Dn($8.prototype,"startSizeY",[R3,On,D3,M3,P3,I3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),s4=Dn($8.prototype,"startSizeZ",[O3,On,F3,L3,k3,V3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),a4=Dn($8.prototype,"startSpeed",[N3,On,G3,z3,U3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),o4=Dn($8.prototype,"startRotation3D",[On,H3,X3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),l4=Dn($8.prototype,"startRotationX",[W3,On,j3,po,Y3,q3,K3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),h4=Dn($8.prototype,"startRotationY",[J3,On,Z3,po,Q3,$3,t5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),u4=Dn($8.prototype,"startRotationZ",[e5,i5,r5,po,n5,s5,a5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),c4=Dn($8.prototype,"startDelay",[o5,On,l5,h5,u5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),_4=Dn($8.prototype,"startLifetime",[c5,On,_5,f5,d5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),f4=Dn($8.prototype,"duration",[On,p5,m5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),d4=Dn($8.prototype,"loop",[On,g5,y5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn($8.prototype,"prewarm",[v5,b5],Object.getOwnPropertyDescriptor($8.prototype,"prewarm"),$8.prototype),Dn($8.prototype,"simulationSpace",[S5,On,A5,T5],Object.getOwnPropertyDescriptor($8.prototype,"simulationSpace"),$8.prototype),p4=Dn($8.prototype,"simulationSpeed",[On,C5,x5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),m4=Dn($8.prototype,"playOnAwake",[On,w5,E5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),g4=Dn($8.prototype,"gravityModifier",[B5,On,R5,D5,M5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),y4=Dn($8.prototype,"rateOverTime",[P5,On,I5,O5,F5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),v4=Dn($8.prototype,"rateOverDistance",[L5,On,k5,V5,N5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new NW}}),b4=Dn($8.prototype,"bursts",[G5,On,z5,U5],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dn($8.prototype,"renderCulling",[H5,X5,W5],Object.getOwnPropertyDescriptor($8.prototype,"renderCulling"),$8.prototype),S4=Dn($8.prototype,"_renderCulling",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn($8.prototype,"cullingMode",[j5,Y5,q5],Object.getOwnPropertyDescriptor($8.prototype,"cullingMode"),$8.prototype),A4=Dn($8.prototype,"_cullingMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jY.Pause}}),Dn($8.prototype,"aabbHalfX",[K5,J5,Z5],Object.getOwnPropertyDescriptor($8.prototype,"aabbHalfX"),$8.prototype),T4=Dn($8.prototype,"_aabbHalfX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn($8.prototype,"aabbHalfY",[Q5,$5,t8],Object.getOwnPropertyDescriptor($8.prototype,"aabbHalfY"),$8.prototype),C4=Dn($8.prototype,"_aabbHalfY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn($8.prototype,"aabbHalfZ",[e8,i8,r8],Object.getOwnPropertyDescriptor($8.prototype,"aabbHalfZ"),$8.prototype),x4=Dn($8.prototype,"_aabbHalfZ",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn($8.prototype,"dataCulling",[n8,s8],Object.getOwnPropertyDescriptor($8.prototype,"dataCulling"),$8.prototype),w4=Dn($8.prototype,"_dataCulling",[On,a8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn($8.prototype,"sharedMaterials",[Hn,o8,l8,On,h8],Object.getOwnPropertyDescriptor($8.prototype,"sharedMaterials"),$8.prototype),E4=Dn($8.prototype,"_colorOverLifetimeModule",[u8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"colorOverLifetimeModule",[c8,_8,f8],Object.getOwnPropertyDescriptor($8.prototype,"colorOverLifetimeModule"),$8.prototype),B4=Dn($8.prototype,"_shapeModule",[d8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"shapeModule",[p8,m8,g8],Object.getOwnPropertyDescriptor($8.prototype,"shapeModule"),$8.prototype),R4=Dn($8.prototype,"_sizeOvertimeModule",[y8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"sizeOvertimeModule",[v8,b8,S8],Object.getOwnPropertyDescriptor($8.prototype,"sizeOvertimeModule"),$8.prototype),D4=Dn($8.prototype,"_velocityOvertimeModule",[A8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"velocityOvertimeModule",[T8,C8,x8],Object.getOwnPropertyDescriptor($8.prototype,"velocityOvertimeModule"),$8.prototype),M4=Dn($8.prototype,"_forceOvertimeModule",[w8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"forceOvertimeModule",[E8,B8,R8],Object.getOwnPropertyDescriptor($8.prototype,"forceOvertimeModule"),$8.prototype),P4=Dn($8.prototype,"_limitVelocityOvertimeModule",[D8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"limitVelocityOvertimeModule",[M8,P8,I8],Object.getOwnPropertyDescriptor($8.prototype,"limitVelocityOvertimeModule"),$8.prototype),I4=Dn($8.prototype,"_rotationOvertimeModule",[O8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"rotationOvertimeModule",[F8,L8,k8],Object.getOwnPropertyDescriptor($8.prototype,"rotationOvertimeModule"),$8.prototype),O4=Dn($8.prototype,"_textureAnimationModule",[V8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"textureAnimationModule",[N8,G8,z8],Object.getOwnPropertyDescriptor($8.prototype,"textureAnimationModule"),$8.prototype),F4=Dn($8.prototype,"_noiseModule",[U8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"noiseModule",[H8,X8],Object.getOwnPropertyDescriptor($8.prototype,"noiseModule"),$8.prototype),L4=Dn($8.prototype,"_trailModule",[W8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn($8.prototype,"trailModule",[j8,Y8,q8],Object.getOwnPropertyDescriptor($8.prototype,"trailModule"),$8.prototype),k4=Dn($8.prototype,"renderer",[K8,On,J8,Z8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new H4}}),V4=Dn($8.prototype,"_prewarm",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),N4=Dn($8.prototype,"_capacity",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 100}}),G4=Dn($8.prototype,"_simulationSpace",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WY.Local}}),Q8=$8))||Q8)||Q8)||Q8)||Q8)||Q8)),h6=t("ParticleUtils",function(){function t(){}return t.instantiate=function(t){return this.registeredSceneEvent||(Kr.on(Or.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneUnload,this),this.registeredSceneEvent=!0),this.particleSystemPool.has(t._uuid)||this.particleSystemPool.set(t._uuid,new H((function(){return Ba(t)||new ks}),1,(function(t){return t.destroy()}))),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=hn(t.getComponentsInChildren(l6));!(e=i()).done;)e.value.play()},t.stop=function(t){for(var e,i=hn(t.getComponentsInChildren(l6));!(e=i()).done;)e.value.stop()},t.onSceneUnload=function(){this.particleSystemPool.forEach((function(t){return t.destroy()})),this.particleSystemPool.clear()},t}());h6.particleSystemPool=new Map,h6.registeredSceneEvent=!1,Dr(v$.prototype,"Burst.prototype",[{name:"minCount"},{name:"maxCount"}]),wr(l6.prototype,"ParticleSystem.prototype",[{name:"enableCulling",newName:"dataCulling"}]),Er.ParticleSystemComponent=l6,pn.setClassAlias(l6,"cc.ParticleSystemComponent"),Er.BillboardComponent=MW,pn.setClassAlias(MW,"cc.BillboardComponent"),Er.LineComponent=eY,pn.setClassAlias(eY,"cc.LineComponent"),Er.ParticleUtils=h6;var u6,c6,_6,f6,d6=zs({GRAVITY:0,RADIUS:1}),p6=zs({FREE:0,RELATIVE:1,GROUPED:2}),m6=new i(0,0),g6=new i,y6=new i,v6=new i,b6=new i,S6=Eu(xu),A6=function(){this.pos=new i(0,0),this.startPos=new i(0,0),this.color=new y(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 i(0,0),this.aspectRatio=1,this.dir=new i(0,0),this.radialAccel=0,this.tangentialAccel=0,this.angle=0,this.degreesPerSecond=0,this.radius=0,this.deltaRadius=0},T6=new(function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.prototype.get=function(){return this._get()||new A6},e}(Yn))((function(t){t.pos.set(m6),t.startPos.set(m6),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(m6),t.aspectRatio=1,t.dir.set(m6),t.radialAccel=0,t.tangentialAccel=0,t.angle=0,t.degreesPerSecond=0,t.radius=0,t.deltaRadius=0}),1024),C6=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)T6.put(t[e]);t.length=0},e.emitParticle=function(t){var e=this.sys,i=T6.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=Ks(l.r+h.r*(Math.random()-.5)*2,0,255),i.color.g=s=Ks(l.g+h.g*(Math.random()-.5)*2,0,255),i.color.b=a=Ks(l.b+h.b*(Math.random()-.5)*2,0,255),i.color.a=o=Ks(l.a+h.a*(Math.random()-.5)*2,0,255),i.deltaColor.r=(Ks(u.r+c.r*(Math.random()-.5)*2,0,255)-n)/r,i.deltaColor.g=(Ks(u.g+c.g*(Math.random()-.5)*2,0,255)-s)/r,i.deltaColor.b=(Ks(u.b+c.b*(Math.random()-.5)*2,0,255)-a)/r,i.deltaColor.a=(Ks(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 d=e.startSpin+e.startSpinVar*(Math.random()-.5)*2,p=e.endSpin+e.endSpinVar*(Math.random()-.5)*2;i.rotation=d,i.deltaRotation=(p-d)/r,i.startPos.x=t.x,i.startPos.y=t.y,i.aspectRatio=e.aspectRatio||1;var m=vo(e.angle+this._worldRotation+e.angleVar*(Math.random()-.5)*2);if(e.emitterMode===d6.GRAVITY){var g=e.speed+e.speedVar*(Math.random()-.5)*2;i.dir.x=Math.cos(m),i.dir.y=Math.sin(m),i.dir.multiplyScalar(g),i.radialAccel=e.radialAccel+e.radialAccelVar*(Math.random()-.5)*2,i.tangentialAccel=e.tangentialAccel+e.tangentialAccelVar*(Math.random()-.5)*2,e.rotationIsDir&&(i.rotation=-bo(Math.atan2(i.dir.y,i.dir.x)))}else{var y=e.startRadius+e.startRadiusVar*(Math.random()-.5)*2,v=e.endRadius+e.endRadiusVar*(Math.random()-.5)*2;i.radius=y,i.deltaRadius=-1===e.endRadius?0:(v-y)/r,i.angle=m,i.degreesPerSecond=vo(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*S6*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,d=u,p=c,m=-vo(t.rotation),g=Math.cos(m),v=Math.sin(m);n[r]=_*g-f*v+s,n[r+1]=_*v+f*g+a,n[r+2]=0,n[r+9]=d*g-f*v+s,n[r+10]=d*v+f*g+a,n[r+11]=0,n[r+18]=_*g-p*v+s,n[r+19]=_*v+p*g+a,n[r+20]=0,n[r+27]=d*g-p*v+s,n[r+28]=d*v+p*g+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;y.toArray(n,t.color,r+5),y.toArray(n,t.color,r+14),y.toArray(n,t.color,r+23),y.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===p6.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;g6.x=s.m12,g6.y=s.m13}else i.positionType===p6.RELATIVE?(this._worldRotation=r.eulerAngles.z,g6.x=r.position.x,g6.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(g6),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;){y6.x=y6.y=v6.x=v6.y=b6.x=b6.y=0;var u=n[h];if(u.timeToLive-=t,u.timeToLive>0){if(i.emitterMode===d6.GRAVITY){var c=b6,_=y6,f=v6;(u.pos.x||u.pos.y)&&(_.set(u.pos),_.normalize()),f.set(_),_.multiplyScalar(u.radialAccel);var d=f.x;f.x=-f.y,f.y=d,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 p=y6;p.set(u.pos),i.positionType!==p6.GROUPED&&p.add(u.startPos);var m=S6*h*4;this.updateParticleBuffer(u,p,o,m),++h}else{var g=n[h];h!==n.length-1&&(n[h]=n[n.length-1]),T6.put(g),n.length--,o.resize(o.vertexCount-4,o.indexCount-6)}}this.renderData.material=this.sys.getRenderMaterial(0),this.renderData.frame=this.sys._renderSpriteFrame,o.setRenderDrawInfoAttributes(),0!==n.length||this.active||this.readyToPlay||(this.finished=!0,i._finishedSimulation())},e.requestData=function(t,e){var i=this.renderData.indexCount;this.renderData.request(t,e);for(var r=this.renderData.indexCount/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}},e.initDrawInfo=function(){this.renderData.setRenderDrawInfoAttributes()},t}(),x6=t("ParticleAsset",En("cc.ParticleAsset")((f6=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,Mn(e,"spriteFrame",_6,Pn(e)),e}return on(e,t),e}(Qr),_6=Dn((c6=f6).prototype,"spriteFrame",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),u6=c6))||u6);Er.ParticleAsset=x6;
|
||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
|
||
var w6={};(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 d(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function p(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=y,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))}d.prototype.getParent=function(t){return 2*((t-2)/4|0)},d.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},d.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 g,y=2,v={NONE:0,r:1,j:y,N:3},b=[];for(g=0;288>g;g++)switch(i){case 143>=g:b.push([g+48,8]);break;case 255>=g:b.push([g-144+400,9]);break;case 279>=g:b.push([g-256+0,7]);break;case 287>=g:b.push([g-280+192,8]);break;default:t("invalid literal: "+g)}function S(t,e){this.length=t,this.G=e}function A(){var e=T;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),d=(a+=n.length)===l,p=e,m=e,g=this.a,v=this.b;if(s){for(g=new Uint8Array(this.a.buffer);g.length<=v+f.length+5;)g=new Uint8Array(g.length<<1);g.set(this.a)}if(u=d?1:0,g[v++]=0|u,_=65536+~(c=f.length)&65535,g[v++]=255&c,g[v++]=c>>>8&255,g[v++]=255&_,g[v++]=_>>>8&255,s)g.set(f,v),v+=f.length,g=g.subarray(0,v);else{for(p=0,m=f.length;p<m;++p)g[v++]=f[p];g.length=v}this.b=v,this.a=g}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,T,C,x=E(this,h);for(A=0,T=x.length;A<T;A++)if(C=x[A],o.prototype.d.apply(S,b[C]),256<C)S.d(x[++A],x[++A],i),S.d(x[++A],5),S.d(x[++A],x[++A],i);else if(256===C)break;this.a=S.finish(),this.b=this.a.length;break;case y:var w,D,M,P,I,O,F,L,k,V,N,G,z,U,H,X=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],j=Array(19);for(w=y,X.d(1,1,i),X.d(w,2,i),D=E(this,h),F=R(O=B(this.L,15)),k=R(L=B(this.K,7)),M=286;257<M&&0===O[M-1];M--);for(P=30;1<P&&0===L[P-1];P--);var Y,q,K,J,Z,Q,$=M,tt=P,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,J=rt.length;Y<J;++Y)rt[Y]=0;for(Y=Z=0,J=et.length;Y<J;Y+=q){for(q=1;Y+q<J&&et[Y+q]===et[Y];++q);if(K=q,0===et[Y])if(3>K)for(;0<K--;)it[Z++]=0,rt[0]++;else for(;0<K;)(Q=138>K?K:138)>K-3&&Q<K&&(Q=K-3),10>=Q?(it[Z++]=17,it[Z++]=Q-3,rt[17]++):(it[Z++]=18,it[Z++]=Q-11,rt[18]++),K-=Q;else if(it[Z++]=et[Y],rt[et[Y]]++,3>--K)for(;0<K--;)it[Z++]=et[Y],rt[et[Y]]++;else for(;0<K;)(Q=6>K?K:6)>K-3&&Q<K&&(Q=K-3),it[Z++]=16,it[Z++]=Q-3,rt[16]++,K-=Q}for(r=s?it.subarray(0,Z):it.slice(0,Z),V=B(rt,7),U=0;19>U;U++)j[U]=V[W[U]];for(I=19;4<I&&0===j[I-1];I--);for(N=R(V),X.d(M-257,5,i),X.d(P-1,5,i),X.d(I-4,4,i),U=0;U<I;U++)X.d(j[U],3,i);for(U=0,H=r.length;U<H;U++)if(G=r[U],X.d(N[G],V[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)}X.d(r[U],z,i)}var nt,st,at,ot,lt,ht,ut,ct,_t=[F,O],ft=[k,L];for(lt=_t[0],ht=_t[1],ut=ft[0],ct=ft[1],nt=0,st=D.length;nt<st;++nt)if(at=D[nt],X.d(lt[at],ht[at],i),256<at)X.d(D[++nt],D[++nt],i),ot=D[++nt],X.d(ut[ot],ct[ot],i),X.d(D[++nt],D[++nt],i);else if(256===at)break;this.a=X.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var T,C,x=[];for(T=3;258>=T;T++)C=A(),x[T]=C[2]<<24|C[1]<<16|C[0];var w=s?new Uint32Array(x):x;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)g[y++]=h[a];b[h[0]]++,A[h[3]]++,v=e.length+r-1,d=null}var o,l,h,u,c,_,f,d,p,m={},g=s?new Uint16Array(2*n.length):[],y=0,v=0,b=new(s?Uint32Array:Array)(286),A=new(s?Uint32Array:Array)(30),T=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(d&&a(d,-1),h=0,u=l-o;h<u;++h)p=n[o+h],g[y++]=p,++b[p];break}if(0<_.length){var C=e,x=e,E=0,B=e,R=e,D=e,M=n.length,P=(R=0,_.length);t:for(;R<P;R++){if(C=_[P-R-1],B=3,3<E){for(D=E;3<D;D--)if(n[C+D-1]!==n[o+D-1])continue t;B=E}for(;258>B&&o+B<M&&n[C+B]===n[o+B];)++B;if(B>E&&(x=C,E=B),258===B)break}f=new S(E,o-x),d?d.length<f.length?(p=n[o-1],g[y++]=p,++b[p],a(f,0)):a(d,-1):f.length<T?d=f:a(f,0)}else d?a(d,-1):(p=n[o],g[y++]=p,++b[p])}_.push(o)}return g[y++]=256,b[256]++,r.L=b,r.K=A,s?g.subarray(0,y):g}function B(t,e){function i(t){var e=T[t][C[t]];e===y?(i(t+1),i(t+1)):--S[e],++C[t]}var r,n,a,o,l,h=t.length,u=new d(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,p,m,g,y=n.length,v=new(s?Uint16Array:Array)(e),b=new(s?Uint8Array:Array)(e),S=new(s?Uint8Array:Array)(y),A=Array(e),T=Array(e),C=Array(e),x=(1<<e)-y,w=1<<e-1;for(v[e-1]=y,f=0;f<e;++f)x<w?b[f]=0:(b[f]=1,x-=w),x<<=1,v[e-2-f]=(v[e-1-f]/2|0)+y;for(v[0]=b[0],A[0]=Array(v[0]),T[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]),T[f]=Array(v[f]);for(_=0;_<y;++_)S[_]=e;for(p=0;p<v[e-1];++p)A[e-1][p]=n[p],T[e-1][p]=p;for(_=0;_<e;++_)C[_]=0;for(1===b[e-1]&&(--S[0],++C[e-1]),f=e-2;0<=f;--f){for(m=_=0,g=C[f+1],p=0;p<v[f];p++)(m=A[f+1][g]+A[f+1][g+1])>n[_]?(A[f][p]=m,T[f][p]=y,g+=2):(A[f][p]=n[_],T[f][p]=_,++_);C[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 R(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 D(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=M.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 M=v;function P(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"))}}D.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 M.NONE:o=0;break;case M.r:o=1;break;case M.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",D),n("Zlib.Deflate.compress",(function(t,e){return new D(t,e).n()})),n("Zlib.Deflate.CompressionType",M),n("Zlib.Deflate.CompressionType.NONE",M.NONE),n("Zlib.Deflate.CompressionType.FIXED",M.r),n("Zlib.Deflate.CompressionType.DYNAMIC",M.j);var I=0,O=1,F={D:I,C:O};P.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,k,V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=s?new Uint16Array(V):V,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,X=[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(X):X,j=[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(j):j,q=new(s?Uint8Array:Array)(288);for(L=0,k=q.length;L<k;++L)q[L]=143>=L?8:255>=L?9:279>=L?7:8;var K,J,Z=p(q),Q=new(s?Uint8Array:Array)(30);for(K=0,J=Q.length;K<J;++K)Q[K]=5;var $=p(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=p(u),r=new(s?Uint8Array:Array)(o),n=new(s?Uint8Array:Array)(l),t.o(p(e.call(t,o,i,r)),p(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 P(e,{index:this.c,bufferSize:i.bufferSize,bufferType:i.bufferType,resize:i.resize})}P.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},P.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},P.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},P.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},P.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},P.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;p(at);var ot,lt,ht=new(s?Uint8Array:Array)(30);for(ot=0,lt=ht.length;ot<lt;++ot)ht[ot]=5;p(ht);var ut=8}).call(w6);var E6=w6.Zlib;E6.Deflate=E6.Deflate,E6.Deflate.compress=E6.Deflate.compress,E6.Inflate=E6.Inflate,E6.Inflate.BufferType=E6.Inflate.BufferType,E6.Inflate.prototype.decompress=E6.Inflate.prototype.decompress;for(var B6=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 d=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*d,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(Yr(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 E6.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,d=0,p=0,m=0,g=0,y=0,v=0,b=0,S=0,A=0,T=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=d=0;d<i;u=d+=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=p=0;p<i;u=p+=1)l=t[a++],h=(u-u%e)/e,m=u<e?0:r[o-e],0===s?A=T=0:(A=r[(s-1)*i+h*e+u%e],T=h&&r[(s-1)*i+(h-1)*e+u%e]),g=m+A-T,y=Math.abs(g-m),b=Math.abs(g-A),S=Math.abs(g-T),v=y<=b&&y<=S?m:b<=S?A:T,r[o++]=(l+v)%256;break;default:throw new Error(Yr(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}(),R6=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(Yr(6019));this._littleEndian=!1}return this._littleEndian},e.hasTowel=function(){if(42!==this.getUint16(2))throw RangeError(Yr(6020));return!0},e.getFieldTypeName=function(t){return t in M6?M6[t]:null},e.getFieldTagName=function(t){return t in D6?D6[t]:(Qs(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))):Qs(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)Qs(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);Qs(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?Qs(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)):Qs(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 d,p=n.StripOffsets.values,m=p.length;if(n.StripByteCounts)d=n.StripByteCounts.values;else{if(Qs(8003),1!==m)throw Error(Yr(6024));d=[Math.ceil(s*a*c/8)]}for(var g=1,y=1,v=0;v<m;v++){var b=p[v];o[v]=[];for(var S=d[v],A=0,T=0,C=1,x=!0,w=[],E=0,B=0,R=0;A<S;A+=C)switch(l){case 1:w=[];for(var D=0;D<h;D++){var M=u[D];if(!M.hasBytesPerSample){var P=this.getBits(M.bitsPerSample,b+A,T);throw w.push(P.bits),A=P.byteOffset-b,T=P.bitOffset,RangeError(Yr(6025))}var I=M.bytesPerSample*D;w.push(this.getBytes(M.bytesPerSample,b+A+I))}if(o[v].push(w),!_)throw C=0,RangeError(Yr(6026));C=f;break;case 2:case 3:case 4:case 5:case 6:case 7:break;case 32773:if(x){x=!1;var O=this.getUint8(b+A);O>=0&&O<=127?g=O+1:O>=-127&&O<=-1?y=1-O:x=!0}else{for(var F=this.getUint8(b+A),L=0;L<y;L++){var k=u[B];if(!k.hasBytesPerSample)throw RangeError(Yr(6025));R=R<<8*E|F,++E===k.bytesPerSample&&(w.push(R),R=E=0,B++),B===h&&(o[v].push(w),w=[],B=0)}0==--g&&(x=!0)}C=1}}if(e.getContext){var V=this._canvas.getContext("2d");V.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,X=0,W=n.PhotometricInterpretation.values[0],j=[],Y=0;n.ExtraSamples&&(Y=(j=n.ExtraSamples.values).length);var q=[],K=0;n.ColorMap&&(q=n.ColorMap.values,K=Math.pow(2,u[0].bitsPerSample));for(var J=0;J<G;J++){J+1===G&&(H=U);for(var Z=o[J].length,Q=X*J,$=0,tt=0;$<H&&tt<Z;$++)for(var et=0;et<s;et++,tt++){var it=o[J][tt],rt=0,nt=0,st=0,at=1;if(Y>0)for(var ot=0;ot<Y;ot++)if(1===j[ot]||2===j[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(Yr(6027));var e=it[0];rt=i.clampColorSample(q[e],16),nt=i.clampColorSample(q[K+e],16),st=i.clampColorSample(q[2*K+e],16);break;default:throw RangeError(Yr(6028,W))}}(),V.fillStyle="rgba("+rt+", "+nt+", "+st+", "+at+")",V.fillRect(et,Q+$,1,1)}X=H}}return this._canvas}},t}(),D6={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"},M6={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"},P6=new Array(123),I6=0;I6<123;++I6)P6[I6]=64;for(var O6=0;O6<64;++O6)P6["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(O6)]=O6;var F6={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=P6[t.charCodeAt(l++)]<<2|(n=P6[t.charCodeAt(l++)])>>4,i=(15&n)<<4|(s=P6[t.charCodeAt(l++)])>>2,r=(3&s)<<6|(a=P6[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}},L6=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(L6.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};L6.gunzip=function(t){return t.constructor===Array||t.constructor,new L6(t).gunzip()[0][0]},L6.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},L6.LITERALS=288,L6.NAMEMAX=256,L6.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],L6.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],L6.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],L6.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],L6.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],L6.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L6.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},L6.prototype.readByte=function(){return this.bits+=8,this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1},L6.prototype.byteAlign=function(){this.bb=1},L6.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},L6.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=L6.bitReverse[e]>>8-t),e},L6.prototype.flushBuffer=function(){this.bIdx=0},L6.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},L6.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]++}},L6.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},L6.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},L6.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},L6.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=L6.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,d=this.readBits(L6.cplext[a])+L6.cplens[a],a=L6.bitReverse[this.readBits(5)]>>3,L6.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(L6.cpdext[a]-8)<<8):p=this.readBits(L6.cpdext[a]),p+=L6.cpdist[a],a=0;a<d;a++){var s=this.buf32k[this.bIdx-p&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[L6.border[a]]=this.readBits(3);for(d=this.distanceTree.length,i=0;i<d;i++)this.distanceTree[i]=new L6.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(d=this.literalTree.length,i=0;i<d;i++)this.literalTree[i]=new L6.HufNode;if(this.CreateTree(this.literalTree,l,c,0))return this.flushBuffer(),1;for(d=this.literalTree.length,i=0;i<d;i++)this.distanceTree[i]=new L6.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 d,p;if(0==(a-=256))break;for(a--,d=this.readBits(L6.cplext[a])+L6.cplens[a],a=this.DecodeValue(this.distanceTree),L6.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(L6.cpdext[a]-8)<<8):p=this.readBits(L6.cpdext[a]),p+=L6.cpdist[a];d--;)s=this.buf32k[this.bIdx-p&32767],this.addBuffer(s)}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},L6.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]},L6.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<L6.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()}},L6.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<L6.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 k6,V6,N6,G6,z6,U6,H6,X6,W6,j6,Y6,q6,K6,J6,Z6,Q6,$6,t7,e7,i7,r7,n7,s7,a7,o7,l7,h7,u7,c7,_7,f7,d7,p7,m7,g7,y7,v7,b7,S7,A7,T7,C7,x7,w7,E7,B7,R7,D7,M7,P7,I7,O7,F7,L7,k7,V7,N7,G7,z7,U7,H7,X7,W7,j7,Y7,q7,K7,J7,Z7,Q7,$7,t9,e9,i9,r9,n9,s9,a9,o9,l9,h9,u9,c9,_9,f9,d9,p9,m9,g9,y9,v9,b9,S9,A9,T9,C9,x9,w9,E9,B9,R9,D9,M9,P9={name:"Jacob__Codec"};function I9(t){var e=t.parent,i=t.getComponent(K9);return e&&i?I9(e):t.getComponentsInChildren(K9)}P9.Base64=F6,P9.GZip=L6,P9.unzip=function(){return P9.GZip.gunzip.apply(P9.GZip,arguments)},P9.unzipBase64=function(){var t=P9.Base64.decode.apply(P9.Base64,arguments);try{return P9.GZip.gunzip.call(P9.GZip,t)}catch(e){return t.slice(7)}},P9.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},P9.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"}(M9||(M9={}));var O9,F9,L9,k9,V9,N9,G9,z9,U9,H9,X9,W9,j9,Y9,q9,K9=t("ParticleSystem2D",(k6=En("cc.ParticleSystem2D"),V6=ts(),N6=es(),G6=is(),z6=Wn(x6),U6=es(),H6=is(),X6=Wn(Bh),W6=is(),j6=is(),Y6=is(),q6=is(),K6=is(),J6=is(),Z6=is(),Q6=is(),$6=cs(),t7=is(),e7=is(),i7=is(),r7=is(),n7=is(),s7=is(),a7=is(),o7=is(),l7=is(),h7=is(),u7=is(),c7=is(),_7=is(),f7=Wn(p6),d7=is(),p7=es(),m7=is(),g7=Wn(d6),y7=is(),v7=is(),b7=is(),S7=is(),A7=is(),T7=is(),C7=is(),x7=is(),w7=is(),E7=is(),B7=is(),R7=is(),D7=is(),M7=is(),P7=is(),I7=es(),O7=is(),F7=es(),L7=is(),k7=oa("preview"),k6(V7=V6(V7=So(V7=Jn((D9=R9=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"duration",G7,Pn(e)),Mn(e,"emissionRate",z7,Pn(e)),Mn(e,"life",U7,Pn(e)),Mn(e,"lifeVar",H7,Pn(e)),Mn(e,"angle",X7,Pn(e)),Mn(e,"angleVar",W7,Pn(e)),Mn(e,"startSize",j7,Pn(e)),Mn(e,"startSizeVar",Y7,Pn(e)),Mn(e,"endSize",q7,Pn(e)),Mn(e,"endSizeVar",K7,Pn(e)),Mn(e,"startSpin",J7,Pn(e)),Mn(e,"startSpinVar",Z7,Pn(e)),Mn(e,"endSpin",Q7,Pn(e)),Mn(e,"endSpinVar",$7,Pn(e)),Mn(e,"sourcePos",t9,Pn(e)),Mn(e,"posVar",e9,Pn(e)),Mn(e,"emitterMode",i9,Pn(e)),Mn(e,"gravity",r9,Pn(e)),Mn(e,"speed",n9,Pn(e)),Mn(e,"speedVar",s9,Pn(e)),Mn(e,"tangentialAccel",a9,Pn(e)),Mn(e,"tangentialAccelVar",o9,Pn(e)),Mn(e,"radialAccel",l9,Pn(e)),Mn(e,"radialAccelVar",h9,Pn(e)),Mn(e,"rotationIsDir",u9,Pn(e)),Mn(e,"startRadius",c9,Pn(e)),Mn(e,"startRadiusVar",_9,Pn(e)),Mn(e,"endRadius",f9,Pn(e)),Mn(e,"endRadiusVar",d9,Pn(e)),Mn(e,"rotatePerS",p9,Pn(e)),Mn(e,"rotatePerSVar",m9,Pn(e)),e.aspectRatio=1,Mn(e,"playOnLoad",g9,Pn(e)),Mn(e,"autoRemoveOnFinish",y9,Pn(e)),Mn(e,"_preview",v9,Pn(e)),Mn(e,"_custom",b9,Pn(e)),Mn(e,"_file",S9,Pn(e)),Mn(e,"_spriteFrame",A9,Pn(e)),Mn(e,"_totalParticles",T9,Pn(e)),Mn(e,"_startColor",C9,Pn(e)),Mn(e,"_startColorVar",x9,Pn(e)),Mn(e,"_endColor",w9,Pn(e)),Mn(e,"_endColorVar",E9,Pn(e)),Mn(e,"_positionType",B9,Pn(e)),e._stopped=!0,e.initProperties(),e}on(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,this._simulator.renderData&&this._assembler&&this._assembler.removeData(this._simulator.renderData)},i.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new C6(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=I9(this.node),e=0;e<t.length;++e)t[e]._startPreview()},i.onLostFocusInEditor=function(){this._focused=!1;for(var t=I9(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),this._simulator.renderData.particleInitRenderDrawInfo(this.renderEntity),this._simulator.initDrawInfo())},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.markForUpdateRenderData()},i.isFull=function(){return this.particleCount>=this.totalParticles},i._applyFile=function(){var t=this._file;if(t){if(!t)return void Nn(6029);if(!this.isValid)return;this._plistFile=t.nativeUrl,this._custom||(this._spriteFrame!==t.spriteFrame&&(this.spriteFrame=t.spriteFrame),this._initWithDictionary(t._nativeAsset)),this._spriteFrame?!this._renderSpriteFrame&&this._spriteFrame&&this._applySpriteFrame():t.spriteFrame?this.spriteFrame=t.spriteFrame:this._custom&&this._initTextureWithDictionary(t._nativeAsset)}},i._initTextureWithDictionary=function(t){var e,i=this;if(t.spriteFrameUuid){var r=t.spriteFrameUuid;Fr.loadAny(r,(function(e,r){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),Ja(e)):i.spriteFrame=r}))}else{var n=io(this._plistFile,t.textureFileName||"");if(t.textureFileName)Fr.loadRemote(n,(function(e,r){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),Ja(e)):i.spriteFrame=r?Bh.createWithImage(r):Bh.createWithImage(os.get("white-texture"))}));else if(t.textureImageData){var s=t.textureImageData;if(!(s&&s.length>0))return!1;var a=Fr.assets.get(n);if(!a){var o=P9.unzipBase64AsArray(s,1);if(!o)return Rn(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]?M9.PNG:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?M9.TIFF:M9.UNKNOWN;if(l!==M9.TIFF&&l!==M9.PNG)return Rn(6031,this._file.name),!1;var h=document.createElement("canvas");l===M9.PNG?new B6(o).render(h):(this._tiffReader||(this._tiffReader=new R6),this._tiffReader.parseTIFF(o,h)),a=new vn(h),Fr.assets.add(n,a)}a||Rn(6032,this._file.name),this.spriteFrame=a?Bh.createWithImage(a):Bh.createWithImage(os.get("white-texture"))}}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||gt.SRC_ALPHA),this._dstBlendFactor=parseInt(t.blendFuncDestination||gt.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:p6.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||d6.GRAVITY),this.emitterMode===d6.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!==d6.RADIUS)return Rn(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._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.texture&&(this._simulator.updateUVs(!0),this._syncAspect(),this._updateMaterial(),this._stopped=!1,this.markForUpdateRenderData()):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!==p6.FREE})},i._finishedSimulation=function(){this.resetSystem(),this.stopSystem(),this.markForUpdateRenderData(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()},i._canRender=function(){return t.prototype._canRender.call(this)&&!this._stopped&&null!==this._renderSpriteFrame},i._render=function(t){this._positionType===p6.RELATIVE?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===p6.GROUPED?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node):t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,null)},Ur(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:"color",get:function(){return this._color},set:function(){}},{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:"preview",get:function(){return this._preview},set:function(t){t?this._startPreview():this._stopPreview(),this._preview=t}},{key:"stopped",get:function(){return this._stopped}},{key:"active",get:function(){return this._simulator.active}},{key:"assembler",get:function(){return this._assembler}}]),e}(af),R9.EmitterMode=d6,R9.PositionType=p6,R9.DURATION_INFINITY=-1,R9.START_SIZE_EQUAL_TO_END_SIZE=-1,R9.START_RADIUS_EQUAL_TO_END_RADIUS=-1,Dn((N7=D9).prototype,"custom",[Un,N6,G6],Object.getOwnPropertyDescriptor(N7.prototype,"custom"),N7.prototype),Dn(N7.prototype,"file",[z6,U6,H6],Object.getOwnPropertyDescriptor(N7.prototype,"file"),N7.prototype),Dn(N7.prototype,"spriteFrame",[X6,W6],Object.getOwnPropertyDescriptor(N7.prototype,"spriteFrame"),N7.prototype),Dn(N7.prototype,"totalParticles",[Un,j6],Object.getOwnPropertyDescriptor(N7.prototype,"totalParticles"),N7.prototype),G7=Dn(N7.prototype,"duration",[On,Un,Y6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),z7=Dn(N7.prototype,"emissionRate",[On,Un,q6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),U7=Dn(N7.prototype,"life",[On,Un,K6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),H7=Dn(N7.prototype,"lifeVar",[On,Un,J6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(N7.prototype,"startColor",[Un,Z6],Object.getOwnPropertyDescriptor(N7.prototype,"startColor"),N7.prototype),Dn(N7.prototype,"startColorVar",[Un,Q6],Object.getOwnPropertyDescriptor(N7.prototype,"startColorVar"),N7.prototype),Dn(N7.prototype,"color",[$6],Object.getOwnPropertyDescriptor(N7.prototype,"color"),N7.prototype),Dn(N7.prototype,"endColor",[Un,t7],Object.getOwnPropertyDescriptor(N7.prototype,"endColor"),N7.prototype),Dn(N7.prototype,"endColorVar",[Un,e7],Object.getOwnPropertyDescriptor(N7.prototype,"endColorVar"),N7.prototype),X7=Dn(N7.prototype,"angle",[On,Un,i7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 90}}),W7=Dn(N7.prototype,"angleVar",[On,Un,r7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),j7=Dn(N7.prototype,"startSize",[On,Un,n7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),Y7=Dn(N7.prototype,"startSizeVar",[On,Un,s7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),q7=Dn(N7.prototype,"endSize",[On,Un,a7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),K7=Dn(N7.prototype,"endSizeVar",[On,Un,o7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),J7=Dn(N7.prototype,"startSpin",[On,Un,l7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Z7=Dn(N7.prototype,"startSpinVar",[On,Un,h7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Q7=Dn(N7.prototype,"endSpin",[On,Un,u7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$7=Dn(N7.prototype,"endSpinVar",[On,Un,c7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),t9=Dn(N7.prototype,"sourcePos",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return i.ZERO.clone()}}),e9=Dn(N7.prototype,"posVar",[On,Un,_7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return i.ZERO.clone()}}),Dn(N7.prototype,"positionType",[f7,d7],Object.getOwnPropertyDescriptor(N7.prototype,"positionType"),N7.prototype),Dn(N7.prototype,"preview",[Un,p7,m7],Object.getOwnPropertyDescriptor(N7.prototype,"preview"),N7.prototype),i9=Dn(N7.prototype,"emitterMode",[On,Un,g7,y7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return d6.GRAVITY}}),r9=Dn(N7.prototype,"gravity",[On,Un,v7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return i.ZERO.clone()}}),n9=Dn(N7.prototype,"speed",[On,Un,b7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 180}}),s9=Dn(N7.prototype,"speedVar",[On,Un,S7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),a9=Dn(N7.prototype,"tangentialAccel",[On,Un,A7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 80}}),o9=Dn(N7.prototype,"tangentialAccelVar",[On,Un,T7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),l9=Dn(N7.prototype,"radialAccel",[On,Un,C7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),h9=Dn(N7.prototype,"radialAccelVar",[On,Un,x7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),u9=Dn(N7.prototype,"rotationIsDir",[On,Un,w7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),c9=Dn(N7.prototype,"startRadius",[On,Un,E7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_9=Dn(N7.prototype,"startRadiusVar",[On,Un,B7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),f9=Dn(N7.prototype,"endRadius",[On,Un,R7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),d9=Dn(N7.prototype,"endRadiusVar",[On,Un,D7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),p9=Dn(N7.prototype,"rotatePerS",[On,Un,M7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),m9=Dn(N7.prototype,"rotatePerSVar",[On,Un,P7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),g9=Dn(N7.prototype,"playOnLoad",[On,Un,I7,O7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),y9=Dn(N7.prototype,"autoRemoveOnFinish",[On,Un,F7,L7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),v9=Dn(N7.prototype,"_preview",[k7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),b9=Dn(N7.prototype,"_custom",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),S9=Dn(N7.prototype,"_file",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),A9=Dn(N7.prototype,"_spriteFrame",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),T9=Dn(N7.prototype,"_totalParticles",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 150}}),C9=Dn(N7.prototype,"_startColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(255,255,255,255)}}),x9=Dn(N7.prototype,"_startColorVar",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(0,0,0,0)}}),w9=Dn(N7.prototype,"_endColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(255,255,255,0)}}),E9=Dn(N7.prototype,"_endColorVar",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(0,0,0,0)}}),B9=Dn(N7.prototype,"_positionType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return p6.FREE}}),V7=N7))||V7)||V7)||V7)||V7)),J9=function(){function t(t,e){this.point=new i,this.dir=new i,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}(),Z9=t("MotionStreak",(O9=En("cc.MotionStreak"),F9=ts(),L9=Qn(),k9=Wn(fn),O9(V9=Jn(V9=So(V9=F9(V9=L9((Y9=j9=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,Mn(e,"_preview",G9,Pn(e)),Mn(e,"_fadeTime",z9,Pn(e)),Mn(e,"_minSeg",U9,Pn(e)),Mn(e,"_stroke",H9,Pn(e)),Mn(e,"_texture",X9,Pn(e)),Mn(e,"_fastMode",W9,Pn(e)),e._points=[],e}on(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,this._updateColor())},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.renderData,this._texture,this._assembler,null)},Ur(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}(af),j9.Point=J9,Dn((N9=Y9).prototype,"preview",[Un],Object.getOwnPropertyDescriptor(N9.prototype,"preview"),N9.prototype),Dn(N9.prototype,"fadeTime",[Un],Object.getOwnPropertyDescriptor(N9.prototype,"fadeTime"),N9.prototype),Dn(N9.prototype,"minSeg",[Un],Object.getOwnPropertyDescriptor(N9.prototype,"minSeg"),N9.prototype),Dn(N9.prototype,"stroke",[Un],Object.getOwnPropertyDescriptor(N9.prototype,"stroke"),N9.prototype),Dn(N9.prototype,"texture",[k9],Object.getOwnPropertyDescriptor(N9.prototype,"texture"),N9.prototype),Dn(N9.prototype,"fastMode",[Un],Object.getOwnPropertyDescriptor(N9.prototype,"fastMode"),N9.prototype),G9=Dn(N9.prototype,"_preview",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),z9=Dn(N9.prototype,"_fadeTime",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),U9=Dn(N9.prototype,"_minSeg",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),H9=Dn(N9.prototype,"_stroke",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),X9=Dn(N9.prototype,"_texture",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),W9=Dn(N9.prototype,"_fastMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),V9=N9))||V9)||V9)||V9)||V9)||V9)),Q9=(new i,new i),$9=new i;function ttt(t,e){return t.x=-e.y,t.y=e.x,t}var ett={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(16,42),e},update:function(t,e){var r,n=t.stroke/2,s=t.node.worldMatrix,a=s.m12,o=s.m13,l=t.points;if(l.length>1){var h=l[0],u=h.point.x-a,c=h.point.y-o;u*u+c*c<t.minSeg&&(r=h)}r||(r=new Z9.Point,l.unshift(r)),r.setPoint(a,o),r.time=t.fadeTime+e;var _,f=0;if(!(l.length<2)){var d=t.renderData;this.updateRenderDataCache(t,d);var p=t.color,m=p.r,g=p.g,y=p.b,v=p.a,b=l[1];b.distance=i.subtract($9,r.point,b.point).length(),$9.normalize(),b.setDir($9.x,$9.y),r.setDir($9.x,$9.y),d.dataLength=2*l.length;for(var S=d.data,A=t.fadeTime,T=!1,C=l.length-1;C>=0;C--){var x=l[C],w=x.point,E=x.dir;if(x.time-=e,x.time<0)l.splice(C,1);else{var B=x.time/A,R=l[C-1];if(!T){if(!R){l.splice(C,1);continue}w.x=R.point.x-E.x*B,w.y=R.point.y-E.y*B}T=!0,ttt(Q9,E);var D=(B*v<<24>>>0)+(y<<16)+(g<<8)+m,M=f;S[M].x=w.x+Q9.x*n,S[M].y=w.y+Q9.y*n,S[M].u=1,S[M].v=B,S[M].color._val=D,S[M+=1].x=w.x-Q9.x*n,S[M].y=w.y-Q9.y*n,S[M].u=0,S[M].v=B,S[M].color._val=D,f+=2}}_=f<=2?0:3*(f-2),d.resize(f,_)}},updateWorldVertexAllData:function(t){for(var e=t.renderData,i=e.floatStride,r=e.data,n=e.chunk.vb,s=0;s<r.length;s++){var a=s*i;n[a+0]=r[s].x,n[a+1]=r[s].y,n[a+2]=r[s].z,n[a+3]=r[s].u,n[a+4]=r[s].v,y.toArray(n,r[s].color,a+5)}},createQuadIndices:function(t,e){var i=t.renderData.chunk.meshBuffer.indexOffset;q9=null,q9=new Uint16Array(e);for(var r=0,n=e;r<n;r+=2){var s=0+r;q9[i++]=s,q9[i++]=s+2,q9[i++]=s+1,q9[i++]=s+1,q9[i++]=s+2,q9[i++]=s+3}},updateRenderDataCache:function(t,e){e.passDirty&&e.updatePass(t),e.nodeDirty&&e.updateNode(t),e.textureDirty&&t.texture&&(e.updateTexture(t.texture),e.material=t.getRenderMaterial(0)),e.hashDirty&&e.updateHash()},updateRenderData:function(){},updateColor:function(){},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,r=e.data,n=e.vertexCount,s=e.indexCount,a=i.vb,o=0,l=0;l<n;l++){var h=r[l];a[o++]=h.x,a[o++]=h.y,a[o++]=h.z,a[o++]=h.u,a[o++]=h.v,y.toArray(a,h.color,o),o+=4}i.bufferId;for(var u=i.vertexOffset,c=i.meshBuffer,_=i.meshBuffer.iData,f=c.indexOffset,d=0,p=s;d<p;d+=2){var m=u+d;_[f++]=m,_[f++]=m+2,_[f++]=m+1,_[f++]=m+1,_[f++]=m+2,_[f++]=m+3}c.indexOffset+=e.indexCount,c.setDirty()}},itt=t("MotionStreakAssemblerManager",{getAssembler:function(){return ett}});Z9.Assembler=itt;var rtt,ntt,stt={maxParticleDeltaTime:0,createData:function(){return Ic.add()},removeData:function(t){Ic.remove(t)},updateRenderData:function(){},fillBuffers:function(){}},att=t("ParticleSystem2DAssembler",{getAssembler:function(){return stt.maxParticleDeltaTime||(stt.maxParticleDeltaTime=Er.game.frameTime/1e3*2),stt}});K9.Assembler=att;var ott=Zo((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,d=-1,p=.75,m=.25,g=256,y=.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 T(t,e){void 0===e&&(e=0);for(var i=new Array(t),r=0;r<t;++r)i[r]=e;return i}var C=s/180,x=180/s,w=2*s,E=Math.abs;function B(t,e){return t<e?t:e}function R(t,e){return t>e?t:e}function D(t,e,i){return t<e?e:t>i?i:t}var M=isFinite;function P(t){return t*t}function I(t){return 1/Math.sqrt(t)}var O=Math.sqrt,F=Math.pow;var L=Math.cos,k=Math.sin,V=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=R(this.x,t.x),this.y=R(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=R(t.x,e.x),i.y=R(t.y,e.y),i},t.ClampV=function(t,e,i,r){return r.x=D(t.x,e.x,i.x),r.y=D(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},Ur(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},Ur(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 X=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}();X.IDENTITY=new X;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 j=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}();j.IDENTITY=new j;var Y=function(){function t(){this.p=new z,this.q=new j}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 j.MulRR(t.q,e.q,i.q),z.AddVV(j.MulRV(t.q,e.p,i.p),t.p,i.p),i},t.MulTXX=function(t,e,i){return j.MulTRR(t.q,e.q,i.q),j.MulTRV(t.q,z.SubVV(e.p,t.p,i.p),i.p),i},t}();Y.IDENTITY=new Y;var q,K=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(j.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}(),J=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+")"},Ur(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}();J.ZERO=new J(0,0,0,0),J.RED=new J(1,0,0),J.GREEN=new J(0,1,0),J.BLUE=new J(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 d=e.GetVertex(0),p=n.GetVertex(0);Y.MulXV(i,d,f.wA),Y.MulXV(s,p,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,_),d=z.DotVV(r,_),p=-f,m=z.CrossVV(n,l),g=m*z.CrossVV(i,r),y=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&&y<=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&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(u<=0&&d<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(d>0&&p>0&&g<=0){var A=1/(d+p);return this.m_v2.a=d*A,this.m_v3.a=p*A,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var T=1/(g+y+v);this.m_v1.a=g*T,this.m_v2.a=y*T,this.m_v3.a=v*T,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,dt=new z;function pt(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,d=0,p=0;p<20;){d=u.m_count;for(var m=0;m<d;++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 g=u.GetSearchDirection(ct);if(g.LengthSquared()<n)break;var y=c[u.m_count];y.indexA=a.GetSupport(j.MulTRV(l.q,z.NegV(g,z.s_t0),ft)),Y.MulXV(l,a.GetVertex(y.indexA),y.wA),y.indexB=o.GetSupport(j.MulTRV(h.q,g,dt)),Y.MulXV(h,o.GetVertex(y.indexB),y.wB),z.SubVV(y.wB,y.wA,y.w),++p,++t.b2_gjkIters;for(var v=!1,b=0;b<d;++b)if(y.indexA===_[b]&&y.indexB===f[b]){v=!0;break}if(v)break;++u.m_count}if(t.b2_gjkMaxIters=R(t.b2_gjkMaxIters,p),u.GetWitnessPoints(e.pointA,e.pointB),e.distance=z.DistanceVV(e.pointA,e.pointB),e.iterations=p,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 T=z.SubVV(e.pointB,e.pointA,_t);T.Normalize(),e.pointA.SelfMulAdd(S,T),e.pointB.SelfMulSub(A,T)}else{var C=z.MidVV(e.pointA,e.pointB,ut);e.pointA.Copy(C),e.pointB.Copy(C),e.distance=0}}}var mt,gt=new z,yt=new at,vt=new z,bt=new z,St=new z,At=new z,Tt=new z,Ct=new z;(mt=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[mt.e_vertex=0]="e_vertex",mt[mt.e_face=1]="e_face";var xt,wt=function(){function t(){this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return Ur(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)},Ur(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}();(xt=t.b2ManifoldType||(t.b2ManifoldType={}))[xt.e_unknown=-1]="e_unknown",xt[xt.e_circles=0]="e_circles",xt[xt.e_faceA=1]="e_faceA",xt[xt.e_faceB=2]="e_faceB";var Rt,Dt=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}(),Mt=function(){function e(){this.normal=new z,this.points=z.MakeArray(2),this.separations=T(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:j.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 d=Y.MulXV(a,i.points[f].localPoint,e.Initialize_s_clipPoint),p=s-z.DotVV(z.SubVV(d,_,z.s_t0),this.normal),m=z.AddVMulSV(d,p,this.normal,e.Initialize_s_cA),g=z.SubVMulSV(d,o,this.normal,e.Initialize_s_cB);z.MidVV(m,g,this.points[f]),this.separations[f]=z.DotVV(z.SubVV(g,m,z.s_t0),this.normal)}break;case t.b2ManifoldType.e_faceB:j.MulRV(a.q,i.localNormal,this.normal);for(var y=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,y,z.s_t0),this.normal),A=z.AddVMulSV(b,S,this.normal,e.Initialize_s_cB),T=z.SubVMulSV(b,s,this.normal,e.Initialize_s_cA);z.MidVV(T,A,this.points[v]),this.separations[v]=z.DotVV(z.SubVV(T,A,z.s_t0),this.normal)}this.normal.SelfNeg()}},e}();Mt.Initialize_s_pointA=new z,Mt.Initialize_s_pointB=new z,Mt.Initialize_s_cA=new z,Mt.Initialize_s_cB=new z,Mt.Initialize_s_planePoint=new z,Mt.Initialize_s_clipPoint=new z,(Rt=t.b2PointState||(t.b2PointState={}))[Rt.b2_nullState=0]="b2_nullState",Rt[Rt.b2_addState=1]="b2_addState",Rt[Rt.b2_persistState=2]="b2_persistState",Rt[Rt.b2_removeState=3]="b2_removeState";var Pt=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=R(this.upperBound.x,t.upperBound.x),this.upperBound.y=R(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=R(t.upperBound.x,e.upperBound.x),this.upperBound.y=R(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,d=(this.lowerBound.x-a)*f,p=(this.upperBound.x-a)*f,m=-1;if(d>p){var g=d;d=p,p=g,m=1}if(d>n&&(_.x=m,_.y=0,n=d),n>(s=B(s,p)))return!1}if(c<r){if(o<this.lowerBound.y||this.upperBound.y<o)return!1}else{var y=1/h,v=(this.lowerBound.y-o)*y,b=(this.upperBound.y-o)*y,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 kt(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 Vt=new rt,Nt=new it,Gt=new nt;function zt(t,e,i,r,n,s){var a=Vt.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 pt(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},Ur(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}(),Xt=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=R(r.x,u),h.upperBound.y=R(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 d=f.aabb.GetCenter(),p=f.aabb.GetExtents();if(!(E(z.DotVV(a,z.SubVV(r,d,z.s_t0)))-z.DotVV(o,p)>0))if(f.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=l;var g=i(m,f);if(0===g)return;g>0&&(l=g,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=R(r.x,u),h.upperBound.y=R(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 d=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),d=_.GetPerimeter()+u):(_.Combine2(i,s.aabb),f=s.aabb.GetPerimeter(),d=_.GetPerimeter()-f+u),h<c&&h<d)break;r=c<d?n:s}var p=r.parent,m=this.AllocateNode();m.parent=p,m.aabb.Combine2(i,r.aabb),m.height=r.height+1,null!==p?(p.child1===r?p.child1=m:p.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 g=e.parent;null!==g;){var y=Ut((g=this.Balance(g)).child1),v=Ut(g.child2);g.height=1+R(y.height,v.height),g.aabb.Combine2(y.aabb,v.aabb),g=g.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+R(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+R(e.height,s.height),i.height=1+R(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+R(e.height,n.height),i.height=1+R(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+R(i.height,o.height),e.height=1+R(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+R(i.height,a.height),e.height=1+R(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+R(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 R(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 jt(t,e){return t<e}Xt.s_r=new z,Xt.s_v=new z,Xt.s_abs_v=new z,Xt.s_segmentAABB=new Ft,Xt.s_subInput=new It,Xt.s_combinedAABB=new Ft,Xt.s_aabb=new Ft,Xt.s_node_id=0;var Yt=function(t,e){this.proxyA=t,this.proxyB=e},qt=function(){function t(){this.m_tree=new Xt,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=jt);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,Kt);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 Kt(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 Jt,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 K,this.sweepB=new K,this.tMax=0};(Jt=t.b2TOIOutputState||(t.b2TOIOutputState={}))[Jt.e_unknown=0]="e_unknown",Jt[Jt.e_failed=1]="e_failed",Jt[Jt.e_overlapped=2]="e_overlapped",Jt[Jt.e_touching=3]="e_touching",Jt[Jt.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 K,this.m_sweepB=new K,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 d=this.m_axis.Normalize();return this.m_localPoint.SetZero(),d}if(e.indexA[0]===e.indexA[1]){this.m_type=t.b2SeparationFunctionType.e_faceB;var p=this.m_proxyB.GetVertex(e.indexB[0]),m=this.m_proxyB.GetVertex(e.indexB[1]);z.CrossVOne(z.SubVV(m,p,z.s_t0),this.m_axis).SelfNormalize();var g=j.MulRV(h.q,this.m_axis,ee);z.MidVV(p,m,this.m_localPoint);var y=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,y,z.s_t0),g);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]),T=this.m_proxyA.GetVertex(e.indexA[1]);z.CrossVOne(z.SubVV(T,A,z.s_t0),this.m_axis).SelfNormalize();var C=j.MulRV(l.q,this.m_axis,ee);z.MidVV(A,T,this.m_localPoint);var x=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,x,z.s_t0),C);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=j.MulTRV(n.q,this.m_axis,ie),o=j.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 _=j.MulRV(n.q,this.m_axis,ee),f=Y.MulXV(n,this.m_localPoint,$t),d=j.MulTRV(s.q,z.NegV(_,z.s_t0),re);e[0]=-1,i[0]=this.m_proxyB.GetSupport(d);var p=this.m_proxyB.GetVertex(i[0]),m=Y.MulXV(s,p,te);return z.DotVV(z.SubVV(m,f,z.s_t0),_);case t.b2SeparationFunctionType.e_faceB:var g=j.MulRV(s.q,this.m_axis,ee),y=Y.MulXV(s,this.m_localPoint,te),v=j.MulTRV(n.q,z.NegV(g,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,y,z.s_t0),g);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=j.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 d=j.MulRV(s.q,this.m_axis,ee),p=Y.MulXV(s,this.m_localPoint,te),m=this.m_proxyA.GetVertex(e),g=Y.MulXV(n,m,$t);return z.DotVV(z.SubVV(g,p,z.s_t0),d);default:return 0}},e}(),le=new Q,he=new it,ue=new rt,ce=new nt,_e=new oe,fe=[0],de=[0],pe=new K,me=new K;function ge(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=R(8,R(n.m_count,s.m_count)),l=pe.Copy(i.sweepA),h=me.Copy(i.sweepB);l.Normalize(),h.Normalize();var u=i.tMax,c=n.m_radius+s.m_radius,_=R(o,c-.024),f=.002,d=0,p=0,m=he;m.count=0;var g=ue;for(g.proxyA.Copy(i.proxyA),g.proxyB.Copy(i.proxyB),g.useRadii=!1;;){var y=Zt,v=Qt;l.GetTransform(y,d),h.GetTransform(v,d),g.transformA.Copy(y),g.transformB.Copy(v);var b=ce;if(pt(b,m,g),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=d;break}var S=_e;S.Initialize(m,n,l,s,h,d);for(var A=!1,T=u,C=0;;){var x=fe,w=de,B=S.FindMinSeparation(x,w,T);if(B>_+f){e.state=t.b2TOIOutputState.e_separated,e.t=u,A=!0;break}if(B>_-f){d=T;break}var D=S.Evaluate(x[0],w[0],d);if(D<_-f){e.state=t.b2TOIOutputState.e_failed,e.t=d,A=!0;break}if(D<=_+f){e.state=t.b2TOIOutputState.e_touching,e.t=d,A=!0;break}for(var M=0,P=d,I=T;;){var O;O=1&M?P+(_-D)*(I-P)/(B-D):.5*(P+I),++M,++t.b2_toiRootIters;var F=S.Evaluate(x[0],w[0],O);if(E(F-_)<f){T=O;break}if(F>_?(P=O,D=F):(I=O,B=F),50===M)break}if(t.b2_toiMaxRootIters=R(t.b2_toiMaxRootIters,M),++C===a)break}if(++p,++t.b2_toiIters,A)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=d;break}}t.b2_toiMaxIters=R(t.b2_toiMaxIters,p);var L=r.GetMilliseconds();t.b2_toiMaxTime=R(t.b2_toiMaxTime,L),t.b2_toiTime+=L}var ye=new z,ve=new z;function be(e,i,r,n,s){e.pointCount=0;var a=Y.MulXV(r,i.m_p,ye),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,Te=new z;function Ce(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,d=n.m_vertices,p=n.m_normals,m=0;m<f;++m){var g=z.DotVV(p[m],z.SubVV(h,d[m],z.s_t0));if(g>_)return;g>c&&(c=g,u=m)}var y=u,v=(y+1)%f,b=d[y],S=d[v];if(c<r)return e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[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)),T=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(T<=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 C=z.MidVV(b,S,Te);if(z.DotVV(z.SubVV(h,C,z.s_t1),p[y])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[y]).SelfNormalize(),e.localPoint.Copy(C),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}}var xe=new z,we=new z,Ee=new z,Be=new z;function Re(t,e,r,n,s){for(var a=t.m_vertices,o=t.m_normals,l=n.m_count,h=n.m_vertices,u=j.MulRV(e.q,o[r],xe),c=j.MulTRV(s.q,u,we),_=0,f=i,d=0;d<l;++d){var p=z.DotVV(h[d],c);p<f&&(f=p,_=d)}var m=Y.MulXV(e,a[r],Ee),g=Y.MulXV(s,h[_],Be);return z.DotVV(z.SubVV(g,m,z.s_t0),u)}var De=new z,Me=new z;function Pe(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),De),h=j.MulTRV(r.q,l,Me),u=0,c=-i,_=0;_<a;++_){var f=z.DotVV(o[_],h);f>c&&(c=f,u=_)}var d=Re(e,r,u,n,s),p=(u+a-1)%a,m=Re(e,r,p,n,s),g=(u+1)%a,y=Re(e,r,g,n,s),v=0,b=0,S=0;if(m>d&&m>y)S=-1,v=p,b=m;else{if(!(y>d))return t[0]=u,d;S=1,v=g,b=y}for(;(d=Re(e,r,u=-1===S?(v+a-1)%a:(v+1)%a,n,s))>b;)v=u,b=d;return t[0]=v,b}var Ie=new z;var Oe=Pt.MakeArray(2),Fe=Pt.MakeArray(2),Le=Pt.MakeArray(2),ke=[0],Ve=[0],Ne=new z,Ge=new z,ze=new z,Ue=new z,He=new z,Xe=new z,We=new z,je=new z;function Ye(e,r,n,s,a){e.pointCount=0;var o=r.m_radius+s.m_radius,l=ke;l[0]=0;var h=Pe(l,r,n,s,a);if(!(h>o)){var u=Ve;u[0]=0;var c=Pe(u,s,a,r,n);if(!(c>o)){var _,f,d,p,m=0,g=0;c>.98*h+.001?(_=s,f=r,d=a,p=n,m=u[0],e.type=t.b2ManifoldType.e_faceB,g=1):(_=r,f=s,d=n,p=a,m=l[0],e.type=t.b2ManifoldType.e_faceA,g=0);var y=Oe;!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,_=j.MulTRV(o.q,j.MulRV(n.q,l[s],z.s_t0),Ie),f=0,d=i,p=0;p<h;++p){var m=z.DotVV(_,c[p]);m<d&&(d=m,f=p)}var g=f,y=(g+1)%h,v=e[0];Y.MulXV(o,u[g],v.v);var b=v.id.cf;b.indexA=s,b.indexB=g,b.typeA=t.b2ContactFeatureType.e_face,b.typeB=t.b2ContactFeatureType.e_vertex;var S=e[1];Y.MulXV(o,u[y],S.v);var A=S.id.cf;A.indexA=s,A.indexB=y,A.typeA=t.b2ContactFeatureType.e_face,A.typeB=t.b2ContactFeatureType.e_vertex}(y,_,d,m,f,p);var v=_.m_count,b=_.m_vertices,S=m,A=(m+1)%v,T=b[S],C=b[A],x=z.SubVV(C,T,Ne);x.Normalize();var w=z.CrossVOne(x,Ge),E=z.MidVV(T,C,ze),B=j.MulRV(d.q,x,He),R=z.CrossVOne(B,Ue),D=Y.MulXV(d,T,We),M=Y.MulXV(d,C,je),P=z.DotVV(R,D),I=-z.DotVV(B,D)+o,O=z.DotVV(B,M)+o,F=Fe,L=Le;if(!(kt(F,y,z.NegV(B,Xe),I,S)<2||kt(L,F,B,O,A)<2)){e.localNormal.Copy(w),e.localPoint.Copy(E);for(var k=0,V=0;V<2;++V){var N=L[V];if(z.DotVV(R,N.v)-P<=o){var G=e.points[k];if(Y.MulTXV(p,N.v,G.localPoint),G.id.Copy(N.id),g){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}++k}}e.pointCount=k}}}}var qe,Ke=new z,Je=new z,Ze=new z,Qe=new z,$e=new z,ti=new z,ei=new z,ii=new Et;function ri(e,i,r,n,s){e.pointCount=0;var a=Y.MulTXV(r,Y.MulXV(s,n.m_p,z.s_t0),Ke),o=i.m_vertex1,l=i.m_vertex2,h=z.SubVV(l,o,Je),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=ii;if(f.cf.indexB=0,f.cf.typeB=t.b2ContactFeatureType.e_vertex,c<=0){var d=o,p=z.SubVV(a,d,Ze);if(z.DotVV(p,p)>_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=o,y=z.SubVV(g,m,Qe);if(z.DotVV(y,z.SubVV(g,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(d),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,Ze);if(z.DotVV(b,b)>_*_)return;if(i.m_hasVertex3){var S=i.m_vertex3,A=l,T=z.SubVV(S,A,$e);if(z.DotVV(T,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 C=z.DotVV(h,h),x=ti;x.x=1/C*(u*o.x+c*l.x),x.y=1/C*(u*o.y+c*l.y);var w=z.SubVV(a,x,Ze);if(!(z.DotVV(w,w)>_*_)){var E=ei.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"}(qe||(qe={}));var ni,si=function(){this.type=qe.e_unknown,this.index=0,this.separation=0},ai=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"}(ni||(ni={}));var oi=function(){function e(){this.m_polygonB=new ai,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=ni.e_isolated,this.m_type2=ni.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,d=!1;if(o){var p=z.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),f=z.CrossVV(p,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),d=z.CrossVV(h,m)>0,_=z.DotVV(this.m_normal2,z.SubVV(this.m_centroidB,this.m_v2,z.s_t0))}o&&l?f&&d?(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())):d?(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?d?(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 g=0;g<s.m_count;++g)this.m_polygonB.vertices.length<=g&&this.m_polygonB.vertices.push(new z),this.m_polygonB.normals.length<=g&&this.m_polygonB.normals.push(new z),Y.MulXV(this.m_xf,s.m_vertices[g],this.m_polygonB.vertices[g]),j.MulRV(this.m_xf.q,s.m_normals[g],this.m_polygonB.normals[g]);this.m_radius=s.m_radius+r.m_radius,i.pointCount=0;var y=this.ComputeEdgeSeparation(e.s_edgeAxis);if(y.type!==qe.e_unknown&&!(y.separation>this.m_radius)){var v=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(v.type!==qe.e_unknown&&v.separation>this.m_radius)){var b;b=v.type===qe.e_unknown?y:v.separation>.98*y.separation+.001?v:y;var S=e.s_ie,A=e.s_rf;if(b.type===qe.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var T=0,C=z.DotVV(this.m_normal,this.m_polygonB.normals[0]),x=1;x<this.m_polygonB.count;++x){var w=z.DotVV(this.m_normal,this.m_polygonB.normals[x]);w<C&&(C=w,T=x)}var E=T,B=(E+1)%this.m_polygonB.count,R=S[0];R.v.Copy(this.m_polygonB.vertices[E]),R.id.cf.indexA=0,R.id.cf.indexB=E,R.id.cf.typeA=t.b2ContactFeatureType.e_face,R.id.cf.typeB=t.b2ContactFeatureType.e_vertex;var D=S[1];D.v.Copy(this.m_polygonB.vertices[B]),D.id.cf.indexA=0,D.id.cf.indexB=B,D.id.cf.typeA=t.b2ContactFeatureType.e_face,D.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 M=S[0];M.v.Copy(this.m_v1),M.id.cf.indexA=0,M.id.cf.indexB=b.index,M.id.cf.typeA=t.b2ContactFeatureType.e_vertex,M.id.cf.typeB=t.b2ContactFeatureType.e_face;var P=S[1];P.v.Copy(this.m_v2),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,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(!(kt(I,S,A.sideNormal1,A.sideOffset1,A.i1)<2||kt(O,I,A.sideNormal2,A.sideOffset2,A.i2)<2)){b.type===qe.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 k=i.points[F];b.type===qe.e_edgeA?(Y.MulTXV(this.m_xf,O[L].v,k.localPoint),k.id.Copy(O[L].id)):(k.localPoint.Copy(O[L].v),k.id.cf.typeA=O[L].id.cf.typeB,k.id.cf.typeB=O[L].id.cf.typeA,k.id.cf.indexA=O[L].id.cf.indexB,k.id.cf.indexB=O[L].id.cf.indexA),++F}i.pointCount=F}}}},r.ComputeEdgeSeparation=function(t){var e=t;e.type=qe.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=qe.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=qe.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=qe.e_edgeB,r.index=s,r.separation=o)}return r},e}();oi.s_edge1=new z,oi.s_edge0=new z,oi.s_edge2=new z,oi.s_ie=Pt.MakeArray(2),oi.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},oi.s_clipPoints1=Pt.MakeArray(2),oi.s_clipPoints2=Pt.MakeArray(2),oi.s_edgeAxis=new si,oi.s_polygonAxis=new si,oi.s_n=new z,oi.s_perp=new z;var li=new oi;function hi(t,e,i,r,n){li.Collide(t,e,i,r,n)}var ui,ci=function(){this.mass=0,this.center=new z(0,0),this.I=0};(ui=t.b2ShapeType||(t.b2ShapeType={}))[ui.e_unknown=-1]="e_unknown",ui[ui.e_circleShape=0]="e_circleShape",ui[ui.e_edgeShape=1]="e_edgeShape",ui[ui.e_polygonShape=2]="e_polygonShape",ui[ui.e_chainShape=3]="e_chainShape",ui[ui.e_shapeTypeCount=4]="e_shapeTypeCount";var _i=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}(),fi=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}on(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)<=P(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)-P(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=P(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}(_i);fi.TestPoint_s_center=new z,fi.TestPoint_s_d=new z,fi.ComputeDistance_s_center=new z,fi.RayCast_s_position=new z,fi.RayCast_s_s=new z,fi.RayCast_s_r=new z,fi.ComputeAABB_s_p=new z;var di=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}on(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=[],d=0,p=h;;){f[d]=p;for(var m=0,g=1;g<i;++g)if(m!==p){var y=z.SubVV(n[m],n[f[d]],r.Set_s_r),v=z.SubVV(n[g],n[f[d]],r.Set_s_v),b=z.CrossVV(y,v);b<0&&(m=g),0===b&&v.LengthSquared()>y.LengthSquared()&&(m=g)}else m=g;if(++d,p=m,m===h)break}this.m_count=d,this.m_vertices=z.MakeArray(this.m_count),this.m_normals=z.MakeArray(this.m_count);for(var S=0;S<d;++S)this.m_vertices[S].Copy(n[f[S]]);for(var A=0;A<d;++A){var T=this.m_vertices[A],C=this.m_vertices[(A+1)%d],x=z.SubVV(C,T,z.s_t0);z.CrossVOne(x,this.m_normals[A]).SelfNormalize()}return r.ComputeCentroid(this.m_vertices,d,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]),j.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),d=f.LengthSquared();c>d&&(u.Copy(f),c=d)}return j.MulRV(t.q,u,n),n.Normalize(),Math.sqrt(c)}return j.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,j.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 d=u.x,p=u.y,m=c.x,g=c.y;s+=.25*l*_*(d*d+m*d+m*m+p*p+g*p+g*g)}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=j.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 d=r.ComputeSubmergedArea_s_md;return this.ComputeMass(d,1),Y.MulXV(i,d.center,n),d.mass}return 0;case 1:-1===h?h=this.m_count-1:u=this.m_count-1}for(var p,m=(h+1)%this.m_count,g=(u+1)%this.m_count,y=(0-o[h])/(o[m]-o[h]),v=(0-o[u])/(o[g]-o[u]),b=r.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[h].x*(1-y)+this.m_vertices[m].x*y,this.m_vertices[h].y*(1-y)+this.m_vertices[m].y*y),S=r.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[u].x*(1-v)+this.m_vertices[g].x*v,this.m_vertices[u].y*(1-v)+this.m_vertices[g].y*v),A=0,T=r.ComputeSubmergedArea_s_center.SetZero(),C=this.m_vertices[m],x=m;x!==g;){p=(x=(x+1)%this.m_count)===g?S:this.m_vertices[x];var w=.5*((C.x-b.x)*(p.y-b.y)-(C.y-b.y)*(p.x-b.x));A+=w,T.x+=w*(b.x+C.x+p.x)/3,T.y+=w*(b.y+C.y+p.y)/3,C=p}return T.SelfMul(1/A),Y.MulXV(i,T,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),d=.5*z.CrossVV(_,f);s+=d,n.x+=d*o*(h.x+u.x+c.x),n.y+=d*o*(h.y+u.y+c.y)}return n.SelfMul(1/s),n},r}(_i);di.Set_s_r=new z,di.Set_s_v=new z,di.TestPoint_s_pLocal=new z,di.ComputeDistance_s_pLocal=new z,di.ComputeDistance_s_normalForMaxDistance=new z,di.ComputeDistance_s_minDistance=new z,di.ComputeDistance_s_distance=new z,di.RayCast_s_p1=new z,di.RayCast_s_p2=new z,di.RayCast_s_d=new z,di.ComputeAABB_s_v=new z,di.ComputeMass_s_center=new z,di.ComputeMass_s_s=new z,di.ComputeMass_s_e1=new z,di.ComputeMass_s_e2=new z,di.Validate_s_e=new z,di.Validate_s_v=new z,di.ComputeSubmergedArea_s_normalL=new z,di.ComputeSubmergedArea_s_md=new ci,di.ComputeSubmergedArea_s_intoVec=new z,di.ComputeSubmergedArea_s_outoVec=new z,di.ComputeSubmergedArea_s_center=new z,di.ComputeCentroid_s_pRef=new z,di.ComputeCentroid_s_e1=new z,di.ComputeCentroid_s_e2=new z;var pi=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}on(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 d=z.AddVMulSV(n,f,a,i.RayCast_s_q),p=z.SubVV(l,o,i.RayCast_s_r),m=z.DotVV(p,p);if(0===m)return!1;var g=z.DotVV(z.SubVV(d,o,z.s_t0),p)/m;return!(g<0||1<g||(t.fraction=f,j.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}(_i);pi.ComputeDistance_s_v1=new z,pi.ComputeDistance_s_v2=new z,pi.ComputeDistance_s_d=new z,pi.ComputeDistance_s_s=new z,pi.RayCast_s_p1=new z,pi.RayCast_s_p2=new z,pi.RayCast_s_d=new z,pi.RayCast_s_e=new z,pi.RayCast_s_q=new z,pi.RayCast_s_r=new z,pi.ComputeAABB_s_v1=new z,pi.ComputeAABB_s_v2=new z;var mi=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}on(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}(_i);mi.ComputeDistance_s_edgeShape=new pi,mi.RayCast_s_edgeShape=new pi,mi.ComputeAABB_s_v1=new z,mi.ComputeAABB_s_v2=new z;var gi=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}();gi.DEFAULT=new gi;var yi=function(){this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.isSensor=!1,this.filter=new gi},vi=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}();vi.Synchronize_s_aabb1=new Ft,vi.Synchronize_s_aabb2=new Ft;var bi,Si=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 gi,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,gi.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 ci),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 vi(this,t)},i.DestroyProxies=function(){for(var t,e=hn(this.m_proxies);!(t=e()).done;)t.value.Reset();this.m_proxies.length=0},i.TouchProxies=function(){for(var t,e=hn(this.m_proxies);!(t=e()).done;)t.value.Touch()},i.SynchronizeProxies=function(t,e,i){for(var r,n=hn(this.m_proxies);!(r=n()).done;)r.value.Synchronize(t,e,i)},Ur(t,[{key:"m_proxyCount",get:function(){return this.m_proxies.length}}]),t}();(bi=t.b2BodyType||(t.b2BodyType={}))[bi.b2_unknown=-1]="b2_unknown",bi[bi.b2_staticBody=0]="b2_staticBody",bi[bi.b2_kinematicBody=1]="b2_kinematicBody",bi[bi.b2_dynamicBody=2]="b2_dynamicBody";var Ai,Ti,Ci=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 K,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 _i?this.CreateFixtureShapeDensity(t,e):this.CreateFixtureDef(t)},r.CreateFixtureDef=function(t){if(this.m_world.IsLocked())throw new Error;var e=new Si(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 j.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 j.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),j.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),j.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),j.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}();Ci.CreateFixtureShapeDensity_s_def=new yi,Ci.SetMassData_s_oldCenter=new z,Ci.ResetMassData_s_localCenter=new z,Ci.ResetMassData_s_oldCenter=new z,Ci.ResetMassData_s_massData=new ci,Ci.SynchronizeFixtures_s_xf1=new Y,Ci.SynchronizeFixtures_s_displacement=new z,(Ti=t.b2JointType||(t.b2JointType={}))[Ti.e_unknownJoint=0]="e_unknownJoint",Ti[Ti.e_revoluteJoint=1]="e_revoluteJoint",Ti[Ti.e_prismaticJoint=2]="e_prismaticJoint",Ti[Ti.e_distanceJoint=3]="e_distanceJoint",Ti[Ti.e_pulleyJoint=4]="e_pulleyJoint",Ti[Ti.e_mouseJoint=5]="e_mouseJoint",Ti[Ti.e_gearJoint=6]="e_gearJoint",Ti[Ti.e_wheelJoint=7]="e_wheelJoint",Ti[Ti.e_weldJoint=8]="e_weldJoint",Ti[Ti.e_frictionJoint=9]="e_frictionJoint",Ti[Ti.e_ropeJoint=10]="e_ropeJoint",Ti[Ti.e_motorJoint=11]="e_motorJoint",Ti[Ti.e_areaJoint=12]="e_areaJoint",(Ai=t.b2LimitState||(t.b2LimitState={}))[Ai.e_inactiveLimit=0]="e_inactiveLimit",Ai[Ai.e_atLowerLimit=1]="e_atLowerLimit",Ai[Ai.e_atUpperLimit=2]="e_atUpperLimit",Ai[Ai.e_equalLimits=3]="e_equalLimits";var xi=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}(),wi=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},Ur(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}(),Ei=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},Bi=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new wi(this),this.m_edgeB=new wi(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 on(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}(Ei),Di=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 j,r.m_qB=new j,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}on(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),j.MulRV(_,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),j.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 d=this.m_u.Length();d>o?this.m_u.SelfMul(1/d):this.m_u.SetZero();var p=z.CrossVV(this.m_rA,this.m_u),m=z.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,this.m_frequencyHz>0){var y=d-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=y*A*S*this.m_gamma,g+=this.m_gamma,this.m_mass=0!==g?1/g:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var T=z.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);n.SelfMulSub(this.m_invMassA,T),a-=this.m_invIA*z.CrossVV(this.m_rA,T),u.SelfMulAdd(this.m_invMassB,T),c+=this.m_invIB*z.CrossVV(this.m_rB,T)}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=j.MulRV(a,this.m_lalcA,this.m_rA),c=j.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=D(f,-.2,u);var d=-this.m_mass*f,p=z.MulSV(d,_,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),r-=this.m_invIA*z.CrossVV(h,p),n.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*z.CrossVV(c,p),t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,E(f)<o},i}(Bi);Di.InitVelocityConstraints_s_P=new z,Di.SolveVelocityConstraints_s_vpA=new z,Di.SolveVelocityConstraints_s_vpB=new z,Di.SolveVelocityConstraints_s_P=new z,Di.SolvePositionConstraints_s_P=new z;var Mi=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 on(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}(Ei),Pi=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=T(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}on(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,d=!0,p=0;p<this.m_bodies.length;++p){var m=this.m_bodies[p],g=t.positions[m.m_islandIndex].c,y=(p+1)%this.m_bodies.length,v=z.AddVV(this.m_normals[p],this.m_normals[y],this.m_delta);v.SelfMul(f);var b=v.LengthSquared();b>P(u)&&v.SelfMul(u/O(b)),b>P(o)&&(d=!1),g.x+=v.x,g.y+=v.y}return d},i}(Bi),Ii=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 on(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}(Ei),Oi=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 X,r.m_angularMass=0,r.m_qA=new j,r.m_qB=new j,r.m_lalcA=new z,r.m_lalcB=new z,r.m_K=new X,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}on(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=j.MulRV(o,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=j.MulRV(l,this.m_lalcB,this.m_rB),c=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=c+_+f*h.y*h.y+d*u.y*u.y,p.ex.y=-f*h.x*h.y-d*u.x*u.y,p.ey.x=p.ex.y,p.ey.y=c+_+f*h.x*h.x+d*u.x*u.x,p.GetInverse(this.m_linearMass),this.m_angularMass=f+d,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+=d*(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,d=u*this.m_maxTorque;this.m_angularImpulse=D(this.m_angularImpulse+_,-d,d),r-=l*(_=this.m_angularImpulse-f),s+=h*_;var p=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=X.MulMV(this.m_linearMass,p,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),g=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m);var y=u*this.m_maxForce;this.m_linearImpulse.LengthSquared()>y*y&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(y)),z.SubVV(this.m_linearImpulse,g,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}(Bi);Oi.SolveVelocityConstraints_s_Cdot_v2=new z,Oi.SolveVelocityConstraints_s_impulseV=new z,Oi.SolveVelocityConstraints_s_oldImpulseV=new z;var Fi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return on(i,e),i}(Ei),Li=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 j,n.m_qB=new j,n.m_qC=new j,n.m_qD=new j,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,d=j.MulTRV(h.q,z.AddVV(j.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(d,f,z.s_t0),n.m_localAxisC)}n.m_bodyD=n.m_joint2.GetBodyA(),n.m_bodyB=n.m_joint2.GetBodyB();var p=n.m_bodyB.m_xf,m=n.m_bodyB.m_sweep.a,g=n.m_bodyD.m_xf,y=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-y-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=j.MulTRV(g.q,z.AddVV(j.MulRV(p.q,n.m_localAnchorB,z.s_t0),z.SubVV(p.p,g.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}on(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,d=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(a),g=this.m_qC.SetAngle(h),y=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=j.MulRV(g,this.m_localAxisC,r.InitVelocityConstraints_s_u);z.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var b=j.MulRV(g,this.m_lalcC,r.InitVelocityConstraints_s_rC);z.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var S=j.MulRV(p,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=j.MulRV(y,this.m_localAxisD,r.InitVelocityConstraints_s_u);z.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var T=j.MulRV(y,this.m_lalcD,r.InitVelocityConstraints_s_rD);z.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var C=j.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(T,A),this.m_JwB=this.m_ratio*z.CrossVV(C,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),d-=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=d},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,d=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,m=e.positions[this.m_indexD].a,g=this.m_qA.SetAngle(u),y=this.m_qB.SetAngle(_),v=this.m_qC.SetAngle(d),b=this.m_qD.SetAngle(m),S=this.m_JvAC,A=this.m_JvBD,T=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)S.SetZero(),s=1,o=1,T+=this.m_iA+this.m_iC,i=u-d-this.m_referenceAngleA;else{var C=j.MulRV(v,this.m_localAxisC,r.SolvePositionConstraints_s_u),x=j.MulRV(v,this.m_lalcC,r.SolvePositionConstraints_s_rC),w=j.MulRV(g,this.m_lalcA,r.SolvePositionConstraints_s_rA);S.Copy(C),o=z.CrossVV(x,C),s=z.CrossVV(w,C),T+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*s*s;var E=this.m_lalcC,B=j.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,T+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),n=_-m-this.m_referenceAngleB;else{var R=j.MulRV(b,this.m_localAxisD,r.SolvePositionConstraints_s_u),D=j.MulRV(b,this.m_lalcD,r.SolvePositionConstraints_s_rD),M=j.MulRV(y,this.m_lalcB,r.SolvePositionConstraints_s_rB);z.MulSV(this.m_ratio,R,A),l=this.m_ratio*z.CrossVV(D,R),a=this.m_ratio*z.CrossVV(M,R),T+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*l*l+this.m_iB*a*a;var P=this.m_lalcD,I=j.MulTRV(b,z.AddVV(M,z.SubVV(c,p,z.s_t0),z.s_t0),z.s_t0);n=z.DotVV(z.SubVV(I,P,z.s_t0),this.m_localAxisD)}var O=i+this.m_ratio*n-this.m_constant,F=0;return T>0&&(F=-O/T),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),d-=this.m_iC*F*o,p.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=d,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}(Bi);Li.InitVelocityConstraints_s_u=new z,Li.InitVelocityConstraints_s_rA=new z,Li.InitVelocityConstraints_s_rB=new z,Li.InitVelocityConstraints_s_rC=new z,Li.InitVelocityConstraints_s_rD=new z,Li.SolvePositionConstraints_s_u=new z,Li.SolvePositionConstraints_s_rA=new z,Li.SolvePositionConstraints_s_rB=new z,Li.SolvePositionConstraints_s_rC=new z,Li.SolvePositionConstraints_s_rD=new z;var ki=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 on(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}(Ei),Vi=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 X,r.m_angularMass=0,r.m_qA=new j,r.m_qB=new j,r.m_K=new X,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}on(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=j.MulRV(h,z.SubVV(this.m_linearOffset,this.m_localCenterA,z.s_t0),this.m_rA),_=j.MulRV(u,z.NegV(this.m_localCenterB,z.s_t0),this.m_rB),f=this.m_invMassA,d=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=this.m_K;if(g.ex.x=f+d+p*c.y*c.y+m*_.y*_.y,g.ex.y=-p*c.x*c.y-m*_.x*_.y,g.ey.x=g.ex.y,g.ey.y=f+d+p*c.x*c.x+m*_.x*_.x,g.GetInverse(this.m_linearMass),this.m_angularMass=p+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 y=this.m_linearImpulse;r.SelfMulSub(f,y),n-=p*(z.CrossVV(c,y)+this.m_angularImpulse),o.SelfMulAdd(d,y),l+=m*(z.CrossVV(_,y)+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*_,d=this.m_angularImpulse,p=u*this.m_maxTorque;this.m_angularImpulse=D(this.m_angularImpulse+f,-p,p),r-=l*(f=this.m_angularImpulse-d),s+=h*f;var m=this.m_rA,g=this.m_rB,y=z.AddVV(z.SubVV(z.AddVV(n,z.CrossSV(s,g,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=X.MulMV(this.m_linearMass,y,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(g,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}(Bi);Vi.SolveVelocityConstraints_s_Cdot_v2=new z,Vi.SolveVelocityConstraints_s_impulse_v2=new z,Vi.SolveVelocityConstraints_s_oldImpulse_v2=new z;var Ni=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 on(i,e),i}(Ei),Gi=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 X,r.m_C=new z,r.m_qB=new j,r.m_lalcB=new z,r.m_K=new X,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}on(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),j.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=X.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}(Bi);Gi.SolveVelocityConstraints_s_Cdot=new z,Gi.SolveVelocityConstraints_s_impulse=new z,Gi.SolveVelocityConstraints_s_oldImpulse=new z;var zi=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 on(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}(Ei),Ui=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 X,n.m_motorMass=0,n.m_qA=new j,n.m_qB=new j,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}on(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=j.MulRV(c,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d=j.MulRV(_,this.m_lalcB,this.m_rB),p=z.AddVV(z.SubVV(o,i,z.s_t0),z.SubVV(d,f,z.s_t1),r.InitVelocityConstraints_s_d),m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,v=this.m_invIB;if(j.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=z.CrossVV(z.AddVV(p,f,z.s_t0),this.m_axis),this.m_a2=z.CrossVV(d,this.m_axis),this.m_motorMass=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),j.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=z.CrossVV(z.AddVV(p,f,z.s_t0),this.m_perp),this.m_s2=z.CrossVV(d,this.m_perp),this.m_K.ex.x=m+g+y*this.m_s1*this.m_s1+v*this.m_s2*this.m_s2,this.m_K.ex.y=y*this.m_s1+v*this.m_s2,this.m_K.ex.z=y*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=y+v,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=y*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+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_enableLimit){var b=z.DotVV(this.m_axis,p);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,T=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-=y*A,h.SelfMulAdd(g,S),u+=v*T}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,d=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=D(this.m_motorImpulse+_,-d,d),_=this.m_motorImpulse-f;var p=z.MulSV(_,this.m_axis,r.SolveVelocityConstraints_s_P),m=_*this.m_a1,g=_*this.m_a2;i.SelfMulSub(o,p),n-=h*m,s.SelfMulAdd(l,p),a+=u*g}var y=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(-y,-v,-b,r.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=R(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=B(this.m_impulse.z,0));var T=-y-(this.m_impulse.z-S.z)*this.m_K.ez.x,C=-v-(this.m_impulse.z-S.z)*this.m_K.ez.y,x=this.m_K.Solve22(T,C,r.SolveVelocityConstraints_s_f2r);x.x+=S.x,x.y+=S.y,this.m_impulse.x=x.x,this.m_impulse.y=x.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,M=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*M}else{var P=this.m_K.Solve22(-y,-v,r.SolveVelocityConstraints_s_df2);this.m_impulse.x+=P.x,this.m_impulse.y+=P.y;var I=z.MulSV(P.x,this.m_perp,r.SolveVelocityConstraints_s_P),O=P.x*this.m_s1+P.y,F=P.x*this.m_s2+P.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,d=this.m_invIB,p=j.MulRV(a,this.m_lalcA,this.m_rA),m=j.MulRV(h,this.m_lalcB,this.m_rB),g=z.SubVV(z.AddVV(n,m,z.s_t0),z.AddVV(e,p,z.s_t1),r.SolvePositionConstraints_s_d),y=j.MulRV(a,this.m_localXAxisA,this.m_axis),v=z.CrossVV(z.AddVV(g,p,z.s_t0),y),b=z.CrossVV(m,y),S=j.MulRV(a,this.m_localYAxisA,this.m_perp),A=z.CrossVV(z.AddVV(g,p,z.s_t0),S),T=z.CrossVV(m,S),C=r.SolvePositionConstraints_s_impulse,x=z.DotVV(S,g),w=s-i-this.m_referenceAngle,B=E(x),M=E(w),P=!1,I=0;if(this.m_enableLimit){var O=z.DotVV(y,g);E(this.m_upperTranslation-this.m_lowerTranslation)<.016?(I=D(O,-.2,u),B=R(B,E(O)),P=!0):O<=this.m_lowerTranslation?(I=D(O-this.m_lowerTranslation+o,-.2,0),B=R(B,this.m_lowerTranslation-O),P=!0):O>=this.m_upperTranslation&&(I=D(O-this.m_upperTranslation-o,0,u),B=R(B,O-this.m_upperTranslation),P=!0)}if(P){var F=c+_+f*A*A+d*T*T,L=f*A+d*T,k=f*A*v+d*T*b,V=f+d;0===V&&(V=1);var N=f*v+d*b,G=c+_+f*v*v+d*b*b,U=this.m_K3;U.ex.SetXYZ(F,L,k),U.ey.SetXYZ(L,V,N),U.ez.SetXYZ(k,N,G),C=U.Solve33(-x,-w,-I,C)}else{var H=c+_+f*A*A+d*T*T,X=f*A+d*T,W=f+d;0===W&&(W=1);var Y=this.m_K2;Y.ex.Set(H,X),Y.ey.Set(X,W);var q=Y.Solve(-x,-w,r.SolvePositionConstraints_s_impulse1);C.x=q.x,C.y=q.y,C.z=0}var K=z.AddVV(z.MulSV(C.x,S,z.s_t0),z.MulSV(C.z,y,z.s_t1),r.SolvePositionConstraints_s_P),J=C.x*A+C.y+C.z*v,Z=C.x*T+C.y+C.z*b;return e.SelfMulSub(c,K),i-=f*J,n.SelfMulAdd(_,K),s+=d*Z,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,B<=o&&M<=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=j.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=j.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}(Bi);Ui.InitVelocityConstraints_s_d=new z,Ui.InitVelocityConstraints_s_P=new z,Ui.SolveVelocityConstraints_s_P=new z,Ui.SolveVelocityConstraints_s_f2r=new z,Ui.SolveVelocityConstraints_s_f1=new H,Ui.SolveVelocityConstraints_s_df3=new H,Ui.SolveVelocityConstraints_s_df2=new z,Ui.SolvePositionConstraints_s_d=new z,Ui.SolvePositionConstraints_s_impulse=new H,Ui.SolvePositionConstraints_s_impulse1=new z,Ui.SolvePositionConstraints_s_P=new z,Ui.GetJointTranslation_s_pA=new z,Ui.GetJointTranslation_s_pB=new z,Ui.GetJointTranslation_s_d=new z,Ui.GetJointTranslation_s_axis=new z;var Hi=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 on(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}(Ei),Xi=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 j,r.m_qB=new j,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}on(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),j.MulRV(u,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),j.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 d=z.CrossVV(this.m_rA,this.m_uA),p=z.CrossVV(this.m_rB,this.m_uB),m=this.m_invMassA+this.m_invIA*d*d,g=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=m+this.m_ratio*this.m_ratio*g,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=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,y),s+=this.m_invIA*z.CrossVV(this.m_rA,y),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=j.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=j.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(),d=_.Length();f>.08?c.SelfMul(1/f):c.SetZero(),d>.08?_.SelfMul(1/d):_.SetZero();var p=z.CrossVV(h,c),m=z.CrossVV(u,_),g=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*m*m,v=g+this.m_ratio*this.m_ratio*y;v>0&&(v=1/v);var b=this.m_constant-f-this.m_ratio*d,S=E(b),A=-v*b,T=z.MulSV(-A,c,i.SolvePositionConstraints_s_PA),C=z.MulSV(-this.m_ratio*A,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,T),r+=this.m_invIA*z.CrossVV(h,T),n.SelfMulAdd(this.m_invMassB,C),s+=this.m_invIB*z.CrossVV(u,C),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}(Bi);Xi.InitVelocityConstraints_s_PA=new z,Xi.InitVelocityConstraints_s_PB=new z,Xi.SolveVelocityConstraints_s_vpA=new z,Xi.SolveVelocityConstraints_s_vpB=new z,Xi.SolveVelocityConstraints_s_PA=new z,Xi.SolveVelocityConstraints_s_PB=new z,Xi.SolvePositionConstraints_s_PA=new z,Xi.SolvePositionConstraints_s_PB=new z,Xi.GetCurrentLengthA_s_p=new z,Xi.GetCurrentLengthB_s_p=new z;var Wi=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 on(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}(Ei),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 j,n.m_qB=new j,n.m_lalcA=new z,n.m_lalcB=new z,n.m_K=new X,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}on(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),j.MulRV(u,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),j.MulRV(c,this.m_lalcB,this.m_rB);var _=this.m_invMassA,f=this.m_invMassB,d=this.m_invIA,p=this.m_invIB,m=d+p===0;if(this.m_mass.ex.x=_+f+this.m_rA.y*this.m_rA.y*d+this.m_rB.y*this.m_rB.y*p,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*d-this.m_rB.y*this.m_rB.x*p,this.m_mass.ez.x=-this.m_rA.y*d-this.m_rB.y*p,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=_+f+this.m_rA.x*this.m_rA.x*d+this.m_rB.x*this.m_rB.x*p,this.m_mass.ez.y=this.m_rA.x*d+this.m_rB.x*p,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=d+p,this.m_motorMass=d+p,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!m||(this.m_motorImpulse=0),this.m_enableLimit&&!m){var g=a-i-this.m_referenceAngle;E(this.m_upperAngle-this.m_lowerAngle)<2*l?this.m_limitState=t.b2LimitState.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):g>=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 y=r.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(_,y),s-=d*(z.CrossVV(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),o.SelfMulAdd(f,y),h+=p*(z.CrossVV(this.m_rB,y)+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*_,d=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=D(this.m_motorImpulse+f,-p,p),n-=h*(f=this.m_motorImpulse-d),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),g=a-n,y=this.m_mass.Solve33(m.x,m.y,g,r.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+y.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);y.x=S.x,y.y=S.y,y.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(y);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+y.z>0){var A=-m.x+this.m_impulse.z*this.m_mass.ez.x,T=-m.y+this.m_impulse.z*this.m_mass.ez.y,C=this.m_mass.Solve22(A,T,r.SolveVelocityConstraints_s_reduced_v2);y.x=C.x,y.y=C.y,y.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);var x=r.SolveVelocityConstraints_s_P.Set(y.x,y.y);i.SelfMulSub(o,x),n-=h*(z.CrossVV(this.m_rA,x)+y.z),s.SelfMulAdd(l,x),a+=u*(z.CrossVV(this.m_rB,x)+y.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,d=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!d){var p=h-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var g=D(p-this.m_lowerAngle,-.13962634015955555,c);m=-this.m_motorMass*g,f=E(g)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var y=p-this.m_lowerAngle;f=-y,y=D(y+l,-.13962634015955555,0),m=-this.m_motorMass*y}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=p-this.m_upperAngle;f=v,v=D(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=j.MulRV(u,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var S=j.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 T=this.m_invMassA,C=this.m_invMassB,x=this.m_invIA,w=this.m_invIB,B=this.m_K;B.ex.x=T+C+x*b.y*b.y+w*S.y*S.y,B.ex.y=-x*b.x*b.y-w*S.x*S.y,B.ey.x=B.ex.y,B.ey.y=T+C+x*b.x*b.x+w*S.x*S.x;var R=B.Solve(A.x,A.y,r.SolvePositionConstraints_s_impulse).SelfNeg();return n.SelfMulSub(T,R),s-=x*z.CrossVV(b,R),a.SelfMulAdd(C,R),h+=w*z.CrossVV(S,R),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}(Bi);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 Yi=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 on(i,e),i}(Ei),qi=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 j,n.m_qB=new j,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}on(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),j.MulRV(_,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),j.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 d=this.m_length-this.m_maxLength;if(this.m_state=d>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 p=z.CrossVV(this.m_rA,this.m_u),m=z.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=z.MulSV(this.m_impulse,this.m_u,r.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,y),a-=this.m_invIA*z.CrossVV(this.m_rA,y),u.SelfMulAdd(this.m_invMassB,y),c+=this.m_invIB*z.CrossVV(this.m_rB,y)}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=j.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=j.MulRV(l,this.m_lalcB,this.m_rB),_=this.m_u.Copy(n).SelfAdd(c).SelfSub(e).SelfSub(h),f=_.Normalize(),d=f-this.m_maxLength;d=D(d,0,u);var p=-this.m_mass*d,m=z.MulSV(p,_,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}(Bi);qi.InitVelocityConstraints_s_P=new z,qi.SolveVelocityConstraints_s_vpA=new z,qi.SolveVelocityConstraints_s_vpB=new z,qi.SolveVelocityConstraints_s_P=new z,qi.SolvePositionConstraints_s_P=new z;var Ki=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 on(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}(Ei),Ji=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 j,r.m_qB=new j,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}on(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),j.MulRV(h,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),j.MulRV(u,this.m_lalcB,this.m_rB);var c=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=c+_+this.m_rA.y*this.m_rA.y*f+this.m_rB.y*this.m_rB.y*d,p.ey.x=-this.m_rA.y*this.m_rA.x*f-this.m_rB.y*this.m_rB.x*d,p.ez.x=-this.m_rA.y*f-this.m_rB.y*d,p.ex.y=p.ey.x,p.ey.y=c+_+this.m_rA.x*this.m_rA.x*f+this.m_rB.x*this.m_rB.x*d,p.ez.y=this.m_rA.x*f+this.m_rB.x*d,p.ex.z=p.ez.x,p.ey.z=p.ez.y,p.ez.z=f+d,this.m_frequencyHz>0){p.GetInverse22(this.m_mass);var m=f+d,g=m>0?1/m:0,y=a-e-this.m_referenceAngle,v=2*s*this.m_frequencyHz,b=2*g*this.m_dampingRatio*v,S=g*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=y*A*S*this.m_gamma,m+=this.m_gamma,this.m_mass.ez.z=0!==m?1/m:0}else p.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var T=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(c,T),n-=f*(z.CrossVV(this.m_rA,T)+this.m_impulse.z),o.SelfMulAdd(_,T),l+=d*(z.CrossVV(this.m_rB,T)+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 d=f;e.SelfMulSub(a,d),r-=l*z.CrossVV(this.m_rA,d),n.SelfMulAdd(o,d),s+=h*z.CrossVV(this.m_rB,d)}else{var p=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,g=W.MulM33XYZ(this.m_mass,p.x,p.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(g);var y=i.SolveVelocityConstraints_s_P.Set(g.x,g.y);e.SelfMulSub(a,y),r-=l*(z.CrossVV(this.m_rA,y)+g.z),n.SelfMulAdd(o,y),s+=h*(z.CrossVV(this.m_rB,y)+g.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 d=j.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,m,g=j.MulRV(h,this.m_lalcB,this.m_rB),y=this.m_K;if(y.ex.x=u+c+d.y*d.y*_+g.y*g.y*f,y.ey.x=-d.y*d.x*_-g.y*g.x*f,y.ez.x=-d.y*_-g.y*f,y.ex.y=y.ey.x,y.ey.y=u+c+d.x*d.x*_+g.x*g.x*f,y.ez.y=d.x*_+g.x*f,y.ex.z=y.ez.x,y.ey.z=y.ez.y,y.ez.z=_+f,this.m_frequencyHz>0){var v=z.SubVV(z.AddVV(n,g,z.s_t0),z.AddVV(e,d,z.s_t1),i.SolvePositionConstraints_s_C1);p=v.Length(),m=0;var b=y.Solve22(v.x,v.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(u,b),r-=_*z.CrossVV(d,b),n.SelfMulAdd(c,b),s+=f*z.CrossVV(g,b)}else{var S=z.SubVV(z.AddVV(n,g,z.s_t0),z.AddVV(e,d,z.s_t1),i.SolvePositionConstraints_s_C1),A=s-r-this.m_referenceAngle;p=S.Length(),m=E(A);var T=y.Solve33(S.x,S.y,A,i.SolvePositionConstraints_s_impulse).SelfNeg(),C=i.SolvePositionConstraints_s_P.Set(T.x,T.y);e.SelfMulSub(u,C),r-=_*(z.CrossVV(this.m_rA,C)+T.z),n.SelfMulAdd(c,C),s+=f*(z.CrossVV(this.m_rB,C)+T.z)}return t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,p<=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}(Bi);Ji.InitVelocityConstraints_s_P=new z,Ji.SolveVelocityConstraints_s_Cdot1=new z,Ji.SolveVelocityConstraints_s_impulse1=new z,Ji.SolveVelocityConstraints_s_impulse=new H,Ji.SolveVelocityConstraints_s_P=new z,Ji.SolvePositionConstraints_s_C1=new z,Ji.SolvePositionConstraints_s_P=new z,Ji.SolvePositionConstraints_s_impulse=new H;var Zi=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 on(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}(Ei),Qi=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 j,r.m_qB=new j,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}on(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,d=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(l),m=this.m_qB.SetAngle(_);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var g=j.MulRV(p,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var y=j.MulRV(m,this.m_lalcB,this.m_rB),v=z.SubVV(z.AddVV(c,y,z.s_t0),z.AddVV(o,g,z.s_t1),i.InitVelocityConstraints_s_d);if(j.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=z.CrossVV(z.AddVV(v,g,z.s_t0),this.m_ay),this.m_sBy=z.CrossVV(y,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){j.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=z.CrossVV(z.AddVV(v,g,z.s_t0),this.m_ax),this.m_sBx=z.CrossVV(y,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,T=2*this.m_springMass*this.m_dampingRatio*A,C=this.m_springMass*A*A,x=t.step.dt;this.m_gamma=x*(T+x*C),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=S*x*C*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),d+=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=d},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,d=c*this.m_sBx;a.SelfMulSub(e,_),o-=n*f,l.SelfMulAdd(r,_);var p=(h+=s*d)-o-this.m_motorSpeed,m=-this.m_motorMass*p,g=this.m_motorImpulse,y=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=D(this.m_motorImpulse+m,-y,y),o-=n*(m=this.m_motorImpulse-g),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,T=b*this.m_sBy;a.SelfMulSub(e,S),o-=n*A,l.SelfMulAdd(r,S),h+=s*T,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=j.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=j.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=j.MulRV(a,this.m_localYAxisA,this.m_ay),d=z.CrossVV(z.AddVV(_,h,z.s_t0),f),p=z.CrossVV(c,f),m=z.DotVV(_,this.m_ay),g=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!==g?-m/g:0;var y=z.MulSV(u,f,i.SolvePositionConstraints_s_P),v=u*d,b=u*p;return e.SelfMulSub(this.m_invMassA,y),r-=this.m_invIA*v,n.SelfMulAdd(this.m_invMassB,y),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=j.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=j.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}(Bi);function $i(t,e){return O(t*e)}function tr(t,e){return t>e?t:e}Qi.InitVelocityConstraints_s_d=new z,Qi.InitVelocityConstraints_s_P=new z,Qi.SolveVelocityConstraints_s_P=new z,Qi.SolvePositionConstraints_s_d=new z,Qi.SolvePositionConstraints_s_P=new z;var er=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},Ur(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}(),ir=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 er(this),this.m_nodeB=new er(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new Dt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new Dt}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=$i(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=tr(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=$i(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=tr(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 d=this.m_manifold.points[f];d.normalImpulse=0,d.tangentImpulse=0;for(var p=d.id,m=0;m<this.m_oldManifold.pointCount;++m){var g=this.m_oldManifold.points[m];if(g.id.key===p.key){d.normalImpulse=g.normalImpulse,d.tangentImpulse=g.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 ge(n,r),n.t},t}();ir.ComputeTOI_s_input=new ne,ir.ComputeTOI_s_output=new ae;var rr=function(t){function e(){return t.apply(this,arguments)||this}return on(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}(ir),nr=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Ye(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(ir),sr=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Ce(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(ir),ar=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){ri(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(ir),or=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){hi(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(ir),lr=function(t){function e(){return t.apply(this,arguments)||this}return on(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),ri(t,n,i,this.GetShapeB(),r)},e}(ir);lr.Evaluate_s_edge=new pi;var hr=function(t){function e(){return t.apply(this,arguments)||this}return on(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),hi(t,n,i,this.GetShapeB(),r)},e}(ir);hr.Evaluate_s_edge=new pi;var ur=function(){this.pool=[],this.createFcn=null,this.destroyFcn=null,this.primary=!1},cr=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 ur}this.AddType(rr.Create,rr.Destroy,t.b2ShapeType.e_circleShape,t.b2ShapeType.e_circleShape),this.AddType(sr.Create,sr.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_circleShape),this.AddType(nr.Create,nr.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_polygonShape),this.AddType(ar.Create,ar.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_circleShape),this.AddType(or.Create,or.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_polygonShape),this.AddType(lr.Create,lr.Destroy,t.b2ShapeType.e_chainShape,t.b2ShapeType.e_circleShape),this.AddType(hr.Create,hr.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}(),_r=function(){function t(){}var e=t.prototype;return e.SayGoodbyeJoint=function(){},e.SayGoodbyeFixture=function(){},e.SayGoodbyeParticleGroup=function(){},e.SayGoodbyeParticle=function(){},t}(),fr=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}();fr.b2_defaultFilter=new fr;var dr=function(){this.normalImpulses=T(2),this.tangentImpulses=T(2),this.count=0},pr=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}();pr.b2_defaultListener=new pr;var mr=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(){return!0},e.ReportParticle=function(){return!1},e.ShouldQueryParticleSystem=function(){return!0},t}(),gr=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}(),yr=function(){function e(){this.m_broadPhase=new qt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=fr.b2_defaultFilter,this.m_contactListener=pr.b2_defaultListener,this.m_contactFactory=new cr}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}(),vr=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}(),br=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}(),Sr=function(){function t(){this.c=new z,this.a=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),Ar=function(){function t(){this.v=new z,this.w=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),Tr=function(){this.step=new br},Cr=!1,xr=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}(),wr=function(){function t(){this.points=xr.MakeArray(2),this.normal=new z,this.tangent=new z,this.normalMass=new X,this.K=new X,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}(),Er=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}(),Br=function(){this.step=new br,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:j.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:j.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 Dr=function(){function t(){this.m_step=new br,this.m_positionConstraints=Er.MakeArray(1024),this.m_velocityConstraints=wr.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=R(2*this.m_positionConstraints.length,this.m_count);this.m_positionConstraints.length<e;)this.m_positionConstraints[this.m_positionConstraints.length]=new Er;if(this.m_velocityConstraints.length<this.m_count)for(var i=R(2*this.m_velocityConstraints.length,this.m_count);this.m_velocityConstraints.length<i;)this.m_velocityConstraints[this.m_velocityConstraints.length]=new wr;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(),d=f.pointCount,p=this.m_velocityConstraints[r];p.friction=n.m_friction,p.restitution=n.m_restitution,p.tangentSpeed=n.m_tangentSpeed,p.indexA=c.m_islandIndex,p.indexB=_.m_islandIndex,p.invMassA=c.m_invMass,p.invMassB=_.m_invMass,p.invIA=c.m_invI,p.invIB=_.m_invI,p.contactIndex=r,p.pointCount=d,p.K.SetZero(),p.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=d,m.radiusA=h,m.radiusB=u,m.type=f.type;for(var g=0;g<d;++g){var y=f.points[g],v=p.points[g];this.m_step.warmStarting?(v.normalImpulse=this.m_step.dtRatio*y.normalImpulse,v.tangentImpulse=this.m_step.dtRatio*y.tangentImpulse):(v.normalImpulse=0,v.tangentImpulse=0),v.rA.SetZero(),v.rB.SetZero(),v.normalMass=0,v.tangentMass=0,v.velocityBias=0,m.localPoints[g].Copy(y.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,d=s.invIA,p=s.invIB,m=a.localCenterA,g=a.localCenterB,y=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,T=this.m_positions[c].a,C=this.m_velocities[c].v,x=this.m_velocities[c].w;e.q.SetAngle(v),i.q.SetAngle(T),z.SubVV(y,j.MulRV(e.q,m,z.s_t0),e.p),z.SubVV(A,j.MulRV(i.q,g,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],y,B.rA),z.SubVV(r.points[E],A,B.rB);var R=z.CrossVV(B.rA,s.normal),D=z.CrossVV(B.rB,s.normal),M=_+f+d*R*R+p*D*D;B.normalMass=M>0?1/M:0;var P=s.tangent,I=z.CrossVV(B.rA,P),O=z.CrossVV(B.rB,P),F=_+f+d*I*I+p*O*O;B.tangentMass=F>0?1/F:0,B.velocityBias=0;var L=z.DotVV(s.normal,z.SubVV(z.AddVCrossSV(C,x,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,d=this.m_velocities[s].w,p=r.normal,m=r.tangent,g=0;g<u;++g){var y=r.points[g];z.AddVV(z.MulSV(y.normalImpulse,p,z.s_t0),z.MulSV(y.tangentImpulse,m,z.s_t1),e),_-=o*z.CrossVV(y.rA,e),c.SelfMulSub(a,e),d+=h*z.CrossVV(y.rB,e),f.SelfMulAdd(l,e)}this.m_velocities[n].w=_,this.m_velocities[s].w=d}},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,d=this.m_velocities[a].v,p=this.m_velocities[a].w,m=n.normal,g=n.tangent,y=n.friction,v=0;v<c;++v){var b=n.points[v];z.SubVV(z.AddVCrossSV(d,p,b.rB,z.s_t0),z.AddVCrossSV(_,f,b.rA,z.s_t1),e);var S=z.DotVV(e,g)-n.tangentSpeed,A=b.tangentMass*-S,T=y*b.normalImpulse,C=D(b.tangentImpulse+A,-T,T);A=C-b.tangentImpulse,b.tangentImpulse=C,z.MulSV(A,g,i),_.SelfMulSub(o,i),f-=l*z.CrossVV(b.rA,i),d.SelfMulAdd(h,i),p+=u*z.CrossVV(b.rB,i)}n.pointCount;for(var x=0;x<c;++x){var w=n.points[x];z.SubVV(z.AddVCrossSV(d,p,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),M=R(w.normalImpulse+B,0);B=M-w.normalImpulse,w.normalImpulse=M,z.MulSV(B,m,i),_.SelfMulSub(o,i),f-=l*z.CrossVV(w.rA,i),d.SelfMulAdd(h,i),p+=u*z.CrossVV(w.rB,i)}this.m_velocities[s].w=f,this.m_velocities[a].w=p}},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,d=u.invMassA,p=u.invIA,m=u.localCenterB,g=u.invMassB,y=u.invIB,v=u.pointCount,b=this.m_positions[c].c,S=this.m_positions[c].a,A=this.m_positions[_].c,T=this.m_positions[_].a,C=0;C<v;++C){e.q.SetAngle(S),i.q.SetAngle(T),z.SubVV(b,j.MulRV(e.q,f,z.s_t0),e.p),z.SubVV(A,j.MulRV(i.q,m,z.s_t0),i.p),r.Initialize(u,e,i,C);var x=r.normal,w=r.point,E=r.separation;z.SubVV(w,b,n),z.SubVV(w,A,s),l=B(l,E);var R=D(.2*(E+o),-.2,0),M=z.CrossVV(n,x),P=z.CrossVV(s,x),I=d+g+p*M*M+y*P*P,O=I>0?-R/I:0;z.MulSV(O,x,a),b.SelfMulSub(d,a),S-=p*z.CrossVV(n,a),A.SelfMulAdd(g,a),T+=y*z.CrossVV(s,a)}this.m_positions[c].a=S,this.m_positions[_].a=T}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,d=_.indexB,p=_.localCenterA,m=_.localCenterB,g=_.pointCount,y=0,v=0;f!==e&&f!==i||(y=_.invMassA,v=_.invIA);var b=0,S=0;d!==e&&d!==i||(b=_.invMassB,S=_.invIB);for(var A=this.m_positions[f].c,T=this.m_positions[f].a,C=this.m_positions[d].c,x=this.m_positions[d].a,w=0;w<g;++w){r.q.SetAngle(T),n.q.SetAngle(x),z.SubVV(A,j.MulRV(r.q,p,z.s_t0),r.p),z.SubVV(C,j.MulRV(n.q,m,z.s_t0),n.p),s.Initialize(_,r,n,w);var E=s.normal,R=s.point,M=s.separation;z.SubVV(R,A,a),z.SubVV(R,C,l),u=B(u,M);var P=D(.75*(M+o),-.2,0),I=z.CrossVV(a,E),O=z.CrossVV(l,E),F=y+b+v*I*I+S*O*O,L=F>0?-P/F:0;z.MulSV(L,E,h),A.SelfMulSub(y,h),T-=v*z.CrossVV(a,h),C.SelfMulAdd(b,h),x+=S*z.CrossVV(l,h)}this.m_positions[f].a=T,this.m_positions[d].a=x}return u>=-.012},t}();Dr.InitializeVelocityConstraints_s_xfA=new Y,Dr.InitializeVelocityConstraints_s_xfB=new Y,Dr.InitializeVelocityConstraints_s_worldManifold=new Mt,Dr.WarmStart_s_P=new z,Dr.SolveVelocityConstraints_s_dv=new z,Dr.SolveVelocityConstraints_s_dv1=new z,Dr.SolveVelocityConstraints_s_dv2=new z,Dr.SolveVelocityConstraints_s_P=new z,Dr.SolveVelocityConstraints_s_a=new z,Dr.SolveVelocityConstraints_s_b=new z,Dr.SolveVelocityConstraints_s_x=new z,Dr.SolveVelocityConstraints_s_d=new z,Dr.SolveVelocityConstraints_s_P1=new z,Dr.SolveVelocityConstraints_s_P2=new z,Dr.SolveVelocityConstraints_s_P1P2=new z,Dr.SolvePositionConstraints_s_xfA=new Y,Dr.SolvePositionConstraints_s_xfB=new Y,Dr.SolvePositionConstraints_s_psm=new Rr,Dr.SolvePositionConstraints_s_rA=new z,Dr.SolvePositionConstraints_s_rB=new z,Dr.SolvePositionConstraints_s_P=new z,Dr.SolveTOIPositionConstraints_s_xfA=new Y,Dr.SolveTOIPositionConstraints_s_xfB=new Y,Dr.SolveTOIPositionConstraints_s_psm=new Rr,Dr.SolveTOIPositionConstraints_s_rA=new z,Dr.SolveTOIPositionConstraints_s_rB=new z,Dr.SolveTOIPositionConstraints_s_P=new z;var Mr,Pr=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=Sr.MakeArray(1024),this.m_velocities=Ar.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=R(2*this.m_positions.length,t);this.m_positions.length<n;)this.m_positions[this.m_positions.length]=new Sr;if(this.m_velocities.length<t)for(var s=R(2*this.m_velocities.length,t);this.m_velocities.length<s;)this.m_velocities[this.m_velocities.length]=new Ar},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,d=this.m_velocities[h].v.Copy(u.m_linearVelocity),p=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&&(d.x+=l*(u.m_gravityScale*s.x+u.m_invMass*u.m_force.x),d.y+=l*(u.m_gravityScale*s.y+u.m_invMass*u.m_force.y),p+=l*u.m_invI*u.m_torque,d.SelfMul(1/(1+l*u.m_linearDamping)),p*=1/(1+l*u.m_angularDamping)),this.m_positions[h].a=c,this.m_velocities[h].w=p}o.Reset();var m=e.s_solverData;m.step.Copy(n),m.positions=this.m_positions,m.velocities=this.m_velocities;var g=e.s_contactSolverDef;g.step.Copy(n),g.contacts=this.m_contacts,g.count=this.m_contactCount,g.positions=this.m_positions,g.velocities=this.m_velocities;var y=e.s_contactSolver.Initialize(g);y.InitializeVelocityConstraints(),n.warmStarting&&y.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);y.SolveVelocityConstraints()}y.StoreImpulses(),r.solveVelocity=o.GetMilliseconds();for(var A=0;A<this.m_bodyCount;++A){var T=this.m_positions[A].c,C=this.m_positions[A].a,x=this.m_velocities[A].v,w=this.m_velocities[A].w,R=z.MulSV(l,x,e.s_translation);if(z.DotVV(R,R)>4){var D=2/R.Length();x.SelfMul(D)}var M=l*w;M*M>f&&(w*=_/E(M)),T.x+=l*x.x,T.y+=l*x.y,C+=l*w,this.m_positions[A].a=C,this.m_velocities[A].w=w}o.Reset();for(var P=!1,I=0;I<n.positionIterations;++I){for(var O=y.SolvePositionConstraints(),F=!0,L=0;L<this.m_jointCount;++L){var k=this.m_joints[L].SolvePositionConstraints(m);F=F&&k}if(O&&F){P=!0;break}}for(var V=0;V<this.m_bodyCount;++V){var N=this.m_bodies[V];N.m_sweep.c.Copy(this.m_positions[V].c),N.m_sweep.a=this.m_positions[V].a,N.m_linearVelocity.Copy(this.m_velocities[V].v),N.m_angularVelocity=this.m_velocities[V].w,N.SynchronizeTransform()}if(r.solvePosition=o.GetMilliseconds(),this.Report(y.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&&P)for(var X=0;X<this.m_bodyCount;++X)this.m_bodies[X].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 d=this.m_positions[c].c,p=this.m_positions[c].a,m=this.m_velocities[c].v,g=this.m_velocities[c].w,y=z.MulSV(u,m,e.s_translation);if(z.DotVV(y,y)>4){var v=2/y.Length();m.SelfMul(v)}var b=u*g;b*b>f&&(g*=_/E(b)),d.SelfMulAdd(u,m),p+=u*g,this.m_positions[c].a=p,this.m_velocities[c].w=g;var S=this.m_bodies[c];S.m_sweep.c.Copy(d),S.m_sweep.a=p,S.m_linearVelocity.Copy(m),S.m_angularVelocity=g,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}();Pr.s_timer=new Q,Pr.s_solverData=new Tr,Pr.s_contactSolverDef=new Br,Pr.s_contactSolver=new Dr,Pr.s_translation=new z,Pr.s_impulse=new dr,(Mr=t.b2ParticleFlag||(t.b2ParticleFlag={}))[Mr.b2_waterParticle=0]="b2_waterParticle",Mr[Mr.b2_zombieParticle=2]="b2_zombieParticle",Mr[Mr.b2_wallParticle=4]="b2_wallParticle",Mr[Mr.b2_springParticle=8]="b2_springParticle",Mr[Mr.b2_elasticParticle=16]="b2_elasticParticle",Mr[Mr.b2_viscousParticle=32]="b2_viscousParticle",Mr[Mr.b2_powderParticle=64]="b2_powderParticle",Mr[Mr.b2_tensileParticle=128]="b2_tensileParticle",Mr[Mr.b2_colorMixingParticle=256]="b2_colorMixingParticle",Mr[Mr.b2_destructionListenerParticle=512]="b2_destructionListenerParticle",Mr[Mr.b2_barrierParticle=1024]="b2_barrierParticle",Mr[Mr.b2_staticPressureParticle=2048]="b2_staticPressureParticle",Mr[Mr.b2_reactiveParticle=4096]="b2_reactiveParticle",Mr[Mr.b2_repulsiveParticle=8192]="b2_repulsiveParticle",Mr[Mr.b2_fixtureContactListenerParticle=16384]="b2_fixtureContactListenerParticle",Mr[Mr.b2_particleContactListenerParticle=32768]="b2_particleContactListenerParticle",Mr[Mr.b2_fixtureContactFilterParticle=65536]="b2_fixtureContactFilterParticle",Mr[Mr.b2_particleContactFilterParticle=131072]="b2_particleContactFilterParticle";var Ir=function(){this.flags=0,this.position=new z,this.velocity=new z,this.color=new J(0,0,0,0),this.lifetime=0,this.userData=null,this.group=null};function Or(t,e,i){return D(Math.ceil(Math.sqrt(t/(.01*e))*i),1,8)}var Fr,Lr=function(){function t(){this.m_index=d}var e=t.prototype;return e.GetIndex=function(){return this.m_index},e.SetIndex=function(t){this.m_index=t},t}();(Fr=t.b2ParticleGroupFlag||(t.b2ParticleGroupFlag={}))[Fr.b2_solidParticleGroup=1]="b2_solidParticleGroup",Fr[Fr.b2_rigidParticleGroup=2]="b2_rigidParticleGroup",Fr[Fr.b2_particleGroupCanBeEmpty=4]="b2_particleGroupCanBeEmpty",Fr[Fr.b2_particleGroupWillBeDestroyed=8]="b2_particleGroupWillBeDestroyed",Fr[Fr.b2_particleGroupNeedsUpdateDepth=16]="b2_particleGroupNeedsUpdateDepth",Fr[Fr.b2_particleGroupInternalMask=24]="b2_particleGroupInternalMask";var kr=function(){this.flags=0,this.groupFlags=0,this.position=new z,this.angle=0,this.linearVelocity=new z,this.angularVelocity=0,this.color=new J,this.strength=1,this.shapeCount=0,this.stride=0,this.particleCount=0,this.lifetime=0,this.userData=null,this.group=null},Vr=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}();Vr.GetLinearVelocityFromWorldPoint_s_t0=new z;var Nr=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},Ur(t,[{key:"m_capacity",get:function(){return this.m_buffer.length}}]),t}(),Gr=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 zr})),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 Nr(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 Hr(_,f,_+f*this.m_countX,c))}for(;!h.Empty();){var d=h.Front(),p=d.m_x,m=d.m_y,g=d.m_i,y=d.m_generator;h.Pop(),this.m_diagram[g]||(this.m_diagram[g]=y,p>0&&h.Push(new Hr(p-1,m,g-1,y)),m>0&&h.Push(new Hr(p,m-1,g-this.m_countX,y)),p<this.m_countX-1&&h.Push(new Hr(p+1,m,g+1,y)),m<this.m_countY-1&&h.Push(new Hr(p,m+1,g+this.m_countX,y)))}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],T=this.m_diagram[S+1];A!==T&&(h.Push(new Hr(b,v,S,T)),h.Push(new Hr(b+1,v,S+1,A)))}for(var C=0;C<this.m_countY-1;C++)for(var x=0;x<this.m_countX;x++){var w=x+C*this.m_countX,E=this.m_diagram[w],B=this.m_diagram[w+this.m_countX];E!==B&&(h.Push(new Hr(x,C,w,B)),h.Push(new Hr(x,C+1,w+this.m_countX,E)))}for(;!h.Empty();){var R=h.Front(),D=R.m_x,M=R.m_y,P=R.m_i,I=R.m_generator;h.Pop();var O=this.m_diagram[P],F=I;if(O!==F){var L=O.center.x-D,k=O.center.y-M,V=F.center.x-D,N=F.center.y-M;L*L+k*k>V*V+N*N&&(this.m_diagram[P]=F,D>0&&h.Push(new Hr(D-1,M,P-1,F)),M>0&&h.Push(new Hr(D,M-1,P-this.m_countX,F)),D<this.m_countX-1&&h.Push(new Hr(D+1,M,P+1,F)),M<this.m_countY-1&&h.Push(new Hr(D,M+1,P+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}(),zr=function(){this.center=new z,this.tag=0,this.necessary=!1},Hr=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 Wr(t,e){return t<e}function jr(t,e,i,r){void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===r&&(r=Wr);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 Yr(t,e,i,r){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===r&&(r=Wr),jr(t,e,i,r)}function qr(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 Kr(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 Jr(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 Zr(t,e,i,r){for(var n=i;e!==n;)Xr(t,e++,n++),n===r?n=i:e===i&&(i=n)}var Qr=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:g;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=qr(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}(),$r=function(t){function e(e){var i;return(i=t.call(this)||this).m_system=e,i}on(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}(mr),tn=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}(),en=function(){this.index=0,this.weight=0,this.normal=new z,this.mass=0},rn=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},nn=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},sn=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}(),an=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 ln,this.m_flagsBuffer=new ln,this.m_positionBuffer=new ln,this.m_velocityBuffer=new ln,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new ln,this.m_groupBuffer=[],this.m_userDataBuffer=new ln,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new ln,this.m_bodyContactCountBuffer=new ln,this.m_consecutiveContactStepsBuffer=new ln,this.m_stuckParticleBuffer=new Qr((function(){return 0})),this.m_proxyBuffer=new Qr((function(){return new un})),this.m_contactBuffer=new Qr((function(){return new tn})),this.m_bodyContactBuffer=new Qr((function(){return new en})),this.m_pairBuffer=new Qr((function(){return new rn})),this.m_triadBuffer=new Qr((function(){return new nn})),this.m_expirationTimeBuffer=new ln,this.m_indexByExpirationTimeBuffer=new ln,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new sn,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:g;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return d;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 J).Copy(e(t.color,J.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 J).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 Lr).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 gn(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 Vr(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 yn(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 J(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=Kr(this.m_proxyBuffer.data,0,i,r.computeTag(this.m_inverseDiameter*e.lowerBound.x,this.m_inverseDiameter*e.lowerBound.y),un.CompareProxyTag),s=Jr(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),d=z.DotVV(f,f),p=this.GetInsideBoundsEnumerator(u);(c=p.GetNext())>=0;){var m=z.SubVV(e,h[c],s),g=z.DotVV(m,f),y=g*g-d*(z.DotVV(m,m)-this.m_squaredDiameter);if(y>=0){var v=O(y),b=(-g-v)/d;if(b>_)continue;if(b<0&&((b=(-g+v)/d)<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(g),(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 Ir;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,J.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 d=z.SubVV(f.m_vertex2,f.m_vertex1,o),p=d.Length();u<p;){var m=z.AddVMulSV(f.m_vertex1,u/p,d,l);this.CreateParticleForGroup(n,s,m),u+=h}u-=p}},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 Ir;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,d=_.indexB,p=this.m_flagsBuffer.data[f],m=this.m_flagsBuffer.data[d],g=this.m_groupBuffer[f],y=this.m_groupBuffer[d];if(f>=e&&f<i&&d>=e&&d<i&&!((p|m)&t.b2ParticleFlag.b2_zombieParticle)&&(p|m)&r.k_pairFlags&&(n.IsNecessary(f)||n.IsNecessary(d))&&r.ParticleCanBeConnected(p,g)&&r.ParticleCanBeConnected(m,y)&&n.ShouldCreatePair(f,d)){var v=this.m_pairBuffer.data[this.m_pairBuffer.Append()];v.indexA=f,v.indexB=d,v.flags=_.flags,v.strength=B(g?g.m_strength:1,y?y.m_strength:1),v.distance=z.DistanceVV(l[f],l[d])}Yr(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 Gr(i-e),S=e;S<i;S++){var A=this.m_flagsBuffer.data[S],T=this.m_groupBuffer[S];A&t.b2ParticleFlag.b2_zombieParticle||!r.ParticleCanBeConnected(A,T)||b.AddGenerator(l[S],S,n.IsNecessary(S))}var C=this.GetParticleStride();b.Generate(C/2,2*C);var x=this;b.GetNodes((function(t,e,i){var h=x.m_flagsBuffer.data[t],u=x.m_flagsBuffer.data[e],c=x.m_flagsBuffer.data[i];if((h|u|c)&r.k_triadFlags&&n.ShouldCreateTriad(t,e,i)){var _=l[t],f=l[e],d=l[i],p=z.SubVV(_,f,s),m=z.SubVV(f,d,a),g=z.SubVV(d,_,o),y=4*x.m_squaredDiameter;if(z.DotVV(p,p)>y||z.DotVV(m,m)>y||z.DotVV(g,g)>y)return;var v=x.m_groupBuffer[t],b=x.m_groupBuffer[e],S=x.m_groupBuffer[i],A=x.m_triadBuffer.data[x.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 T=(_.x+f.x+d.x)/3,C=(_.y+f.y+d.y)/3;A.pa.x=_.x-T,A.pa.y=_.y-C,A.pb.x=f.x-T,A.pb.y=f.y-C,A.pc.x=d.x-T,A.pc.y=d.y-C,A.ka=-z.DotVV(g,p),A.kb=-z.DotVV(p,m),A.kc=-z.DotVV(m,g),A.s=z.CrossVV(_,f)+z.CrossVV(f,d)+z.CrossVV(d,_)}})),Yr(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 kr;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 d=0;d<r;d++){var p=e[d],m=p.indexA,g=p.indexB,y=p.weight;this.m_accumulationBuffer[m]+=y,this.m_accumulationBuffer[g]+=y}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 T=O(this.m_count)>>0,C=0;C<T;C++){for(var x=!1,w=0;w<r;w++){var E=e[w],B=E.indexA,R=E.indexB,D=1-E.weight,M=this.m_depthBuffer[B],P=this.m_depthBuffer[R],I=P+D,F=M+D;M>I&&(this.m_depthBuffer[B]=I,x=!0),P>F&&(this.m_depthBuffer[R]=F,x=!0)}if(!x)break}for(var L=0;L<c;L++)for(var k=u[L],V=k.m_firstIndex;V<k.m_lastIndex;V++)this.m_depthBuffer[V]<i?this.m_depthBuffer[V]*=this.m_particleDiameter:this.m_depthBuffer[V]=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=Kr(this.m_proxyBuffer.data,0,n,e,un.CompareProxyTag),a=Jr(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(){jr(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 pn;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 dn;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=R(a.upperBound.x,R(h.x,u)),a.upperBound.y=R(a.upperBound.y,R(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,d=r.SolveBarrier_s_f,p=this.m_positionBuffer.data,m=this.m_velocityBuffer.data,g=0;g<this.m_count;g++)0!=(this.m_flagsBuffer.data[g]&r.k_barrierWallFlags)&&m[g].SetZero();for(var y=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,T=S.indexB,C=p[A],x=p[T],w=i;z.MinV(C,x,w.lowerBound),z.MaxV(C,x,w.upperBound);for(var E=this.m_groupBuffer[A],B=this.m_groupBuffer[T],R=this.GetLinearVelocity(E,A,C,n),D=this.GetLinearVelocity(B,T,x,s),M=z.SubVV(x,C,a),P=z.SubVV(D,R,o),I=this.GetInsideBoundsEnumerator(w),F=void 0;(F=I.GetNext())>=0;){var L=p[F],k=this.m_groupBuffer[F];if(E!==k&&B!==k){var V=this.GetLinearVelocity(k,F,L,l),N=z.SubVV(L,C,h),G=z.SubVV(V,R,u),U=z.CrossVV(P,G),H=z.CrossVV(M,G)-z.CrossVV(N,P),X=z.CrossVV(M,N),W=void 0,j=void 0,Y=c,q=_;if(0===U){if(0===H)continue;if(!((j=-X/H)>=0&&j<y))continue;if(z.AddVMulSV(M,j,P,Y),z.AddVMulSV(N,j,G,q),!((W=z.DotVV(Y,q)/z.DotVV(Y,Y))>=0&&W<=1))continue}else{var K=H*H-4*X*U;if(K<0)continue;var J=O(K),Z=(-H-J)/(2*U),Q=(-H+J)/(2*U);if(Z>Q){var $=Z;Z=Q,Q=$}if(j=Z,z.AddVMulSV(M,j,P,Y),z.AddVMulSV(N,j,G,q),W=z.DotVV(Y,q)/z.DotVV(Y,Y),!(j>=0&&j<y&&W>=0&&W<=1)){if(!((j=Q)>=0&&j<y))continue;if(z.AddVMulSV(M,j,P,Y),z.AddVMulSV(N,j,G,q),!((W=z.DotVV(Y,q)/z.DotVV(Y,Y))>=0&&W<=1))continue}}var tt=f;tt.x=R.x+W*P.x-V.x,tt.y=R.y+W*P.y-V.y;var et=z.MulSV(v,tt,d);if(k&&this.IsRigidGroup(k)){var it=k.GetMass(),rt=k.GetInertia();it>0&&k.m_linearVelocity.SelfMulAdd(1/it,et),rt>0&&(k.m_angularVelocity+=z.CrossVV(z.SubVV(L,k.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 d=this.m_weightBuffer[f];if(this.m_flagsBuffer.data[f]&t.b2ParticleFlag.b2_staticPressureParticle){var p=(this.m_accumulationBuffer[f]+r*(d-1))/(d+s);this.m_staticPressureBuffer[f]=D(p,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*R(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),d=this.GetParticleInvMass(),p=0;p<this.m_bodyContactBuffer.count;p++){var g=this.m_bodyContactBuffer.data[p],y=g.index,v=g.body,b=g.weight,S=g.mass,A=g.normal,T=n[y],C=this.m_accumulationBuffer[y]+o*b,x=z.MulSV(f*b*S*C,A,i);s[y].SelfMulSub(d,x),v.ApplyLinearImpulse(x,T,!0)}for(var w=0;w<this.m_contactBuffer.count;w++){var E=this.m_contactBuffer.data[w],D=E.indexA,M=E.indexB,P=E.weight,I=E.normal,O=this.m_accumulationBuffer[D]+this.m_accumulationBuffer[M],F=z.MulSV(f*P*O,I,i);s[D].SelfSub(F),s[M].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,d=u.mass,p=u.normal,m=n[c],g=z.SubVV(_.GetLinearVelocityFromWorldPoint(m,z.s_t0),s[c],e),y=z.DotVV(g,p);if(y<0){var v=R(a*f,B(-o*y,.5)),b=z.MulSV(v*d*y,p,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],T=A.indexA,C=A.indexB,x=A.weight,w=A.normal,E=z.SubVV(s[C],s[T],e),D=z.DotVV(E,w);if(D<0){var M=R(a*x,B(-o*D,.5)),P=z.MulSV(M*D,w,i);s[T].SelfAdd(P),s[C].SelfSub(P)}}},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 d=this.m_bodyContactBuffer.data[f],p=d.index,m=this.m_groupBuffer[p];if(m&&this.IsRigidGroup(m)){var g=d.body,y=d.normal,v=d.weight,b=c[p],S=z.SubVV(g.GetLinearVelocityFromWorldPoint(b,t),m.GetLinearVelocityFromWorldPoint(b,e),n),A=z.DotVV(S,y);if(A<0){this.InitDampingParameterWithRigidGroupOrParticle(s,a,o,!0,m,p,b,y),this.InitDampingParameter(l,h,u,g.GetMass(),g.GetInertia()-g.GetMass()*g.GetLocalCenter().LengthSquared(),g.GetWorldCenter(),b,y);var T=_*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,p,T,y),g.ApplyLinearImpulse(z.MulSV(-T,y,z.s_t0),b,!0)}}}for(var C=0;C<this.m_contactBuffer.count;C++){var x=this.m_contactBuffer.data[C],w=x.indexA,E=x.indexB,R=x.normal,D=x.weight,M=this.m_groupBuffer[w],P=this.m_groupBuffer[E],I=this.IsRigidGroup(M),O=this.IsRigidGroup(P);if(M!==P&&(I||O)){var F=z.MidVV(c[w],c[E],i),L=z.SubVV(this.GetLinearVelocity(P,E,F,t),this.GetLinearVelocity(M,w,F,e),n),k=z.DotVV(L,R);if(k<0){this.InitDampingParameterWithRigidGroupOrParticle(s,a,o,I,M,w,F,R),this.InitDampingParameterWithRigidGroupOrParticle(l,h,u,O,P,E,F,R);var V=_*D*this.ComputeDampingImpulse(s[0],a[0],o[0],l[0],h[0],u[0],k);this.ApplyDamping(s[0],a[0],o[0],I,M,w,V,R),this.ApplyDamping(l[0],h[0],u[0],O,P,E,-V,R)}}}},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),d=z.DotVV(f,c);if(d<0){var p=z.MulSV(.5*u*d,c,e);i[l].SelfMulAdd(s,p),h.ApplyLinearImpulse(p.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),j.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 d=h.m_firstIndex;d<h.m_lastIndex;d++)Y.MulXV(f,o[d],l[d])}},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,d=_.indexB,p=_.indexC,m=_.pa,g=_.pb,y=_.pc,v=i.Copy(l[f]),b=n.Copy(l[d]),S=s.Copy(l[p]),A=h[f],T=h[d],C=h[p];v.SelfMulAdd(e.dt,A),b.SelfMulAdd(e.dt,T),S.SelfMulAdd(e.dt,C);var x=(v.x+b.x+S.x)/3,w=(v.y+b.y+S.y)/3;v.x-=x,v.y-=w,b.x-=x,b.y-=w,S.x-=x,S.y-=w;var E=a;E.s=z.CrossVV(m,v)+z.CrossVV(g,b)+z.CrossVV(y,S),E.c=z.DotVV(m,v)+z.DotVV(g,b)+z.DotVV(y,S);var B=I(E.s*E.s+E.c*E.c);isFinite(B)||(B=198177537e11),E.s*=B,E.c*=B;var R=u*_.strength;j.MulRV(E,m,o),z.SubVV(o,v,o),z.MulSV(R,o,o),A.SelfAdd(o),j.MulRV(E,g,o),z.SubVV(o,b,o),z.MulSV(R,o,o),T.SelfAdd(o),j.MulRV(E,y,o),z.SubVV(o,S,o),z.MulSV(R,o,o),C.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,d=i.Copy(o[_]),p=n.Copy(o[f]),m=l[_],g=l[f];d.SelfMulAdd(e.dt,m),p.SelfMulAdd(e.dt,g);var y=z.SubVV(p,d,s),v=c.distance,b=y.Length(),S=h*c.strength,A=z.MulSV(S*(v-b)/b,y,a);m.SelfSub(A),g.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,d=z.MulSV((1-_)*_,f,i);this.m_accumulation2Buffer[u].SelfSub(d),this.m_accumulation2Buffer[c].SelfAdd(d)}}for(var p=this.GetCriticalVelocity(e),m=this.m_def.surfaceTensionPressureStrength*p,g=this.m_def.surfaceTensionNormalStrength*p,y=.5*p,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,T=b.weight,C=b.normal,x=this.m_weightBuffer[S]+this.m_weightBuffer[A],w=z.SubVV(this.m_accumulation2Buffer[A],this.m_accumulation2Buffer[S],n),E=B(m*(x-2)+g*z.DotVV(w,C),y)*T,R=z.MulSV(E,C,s);a[S].SelfSub(R),a[A].SelfAdd(R)}}},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,d=n[u],p=z.SubVV(c.GetLinearVelocityFromWorldPoint(d,z.s_t0),s[u],e),m=z.MulSV(a*f*_,p,i);s[u].SelfMulAdd(o,m),c.ApplyLinearImpulse(m.SelfNeg(),d,!0)}}for(var g=0;g<this.m_contactBuffer.count;g++){var y=this.m_contactBuffer.data[g];if(y.flags&t.b2ParticleFlag.b2_viscousParticle){var v=y.indexA,b=y.indexB,S=y.weight,A=z.SubVV(s[b],s[v],e),T=z.MulSV(a*S,A,i);s[v].SelfAdd(T),s[b].SelfSub(T)}}},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,d=u.mass,p=n[c],m=u.normal,g=z.MulSV(a*d*(_-o),m,i);s[c].SelfMulSub(l,g),f.ApplyLinearImpulse(g,p,!0)}}}for(var y=0;y<this.m_contactBuffer.count;y++){var v=this.m_contactBuffer.data[y];if(v.flags&t.b2ParticleFlag.b2_powderParticle){var b=v.weight;if(b>o){var S=v.indexA,A=v.indexB,T=v.normal,C=z.MulSV(a*(b-o),T,i);s[S].SelfSub(C),s[A].SelfAdd(C)}}}},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];J.MixColors(a,o,e)}}},n.SolveZombie=function(){for(var e=0,i=[],r=0;r<this.m_count;r++)i[r]=d;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(d),this.m_handleIndexBuffer.data[s]=null)}i[s]=d}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 p=this.m_contactBuffer.data[f];p.indexA=i[p.indexA],p.indexB=i[p.indexB]}this.m_contactBuffer.RemoveIf(u.IsContactInvalid);for(var m=0;m<this.m_bodyContactBuffer.count;m++){var g=this.m_bodyContactBuffer.data[m];g.index=i[g.index]}this.m_bodyContactBuffer.RemoveIf(u.IsBodyContactInvalid);for(var y=0;y<this.m_pairBuffer.count;y++){var v=this.m_pairBuffer.data[y];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,T=0;T<this.m_count;T++){var C=i[this.m_indexByExpirationTimeBuffer.data[T]];C!==d&&(this.m_indexByExpirationTimeBuffer.data[A++]=C)}for(var x=this.m_groupList;x;x=x.GetNext()){for(var w=e,E=0,D=!1,M=x.m_firstIndex;M<x.m_lastIndex;M++){var P=i[M];P>=0?(w=B(w,P),E=R(E,P+1)):D=!0}w<E?(x.m_firstIndex=w,x.m_lastIndex=E,D&&x.m_groupFlags&t.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SetGroupFlags(x,x.m_groupFlags|t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth)):(x.m_firstIndex=0,x.m_lastIndex=0,x.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty||this.SetGroupFlags(x,x.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&&(jr(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(Zr(this.m_flagsBuffer.data,t,e,i),this.m_lastBodyContactStepBuffer.data&&Zr(this.m_lastBodyContactStepBuffer.data,t,e,i),this.m_bodyContactCountBuffer.data&&Zr(this.m_bodyContactCountBuffer.data,t,e,i),this.m_consecutiveContactStepsBuffer.data&&Zr(this.m_consecutiveContactStepsBuffer.data,t,e,i),Zr(this.m_positionBuffer.data,t,e,i),Zr(this.m_velocityBuffer.data,t,e,i),Zr(this.m_groupBuffer,t,e,i),this.m_hasForce&&Zr(this.m_forceBuffer,t,e,i),this.m_staticPressureBuffer&&Zr(this.m_staticPressureBuffer,t,e,i),this.m_depthBuffer&&Zr(this.m_depthBuffer,t,e,i),this.m_colorBuffer.data&&Zr(this.m_colorBuffer.data,t,e,i),this.m_userDataBuffer.data&&Zr(this.m_userDataBuffer.data,t,e,i),this.m_handleIndexBuffer.data){Zr(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){Zr(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 d=0;d<this.m_pairBuffer.count;d++){var p=this.m_pairBuffer.data[d];p.indexA=v(p.indexA),p.indexB=v(p.indexB)}for(var m=0;m<this.m_triadBuffer.count;m++){var g=this.m_triadBuffer.data[m];g.indexA=v(g.indexA),g.indexB=v(g.indexB),g.indexC=v(g.indexC)}for(var y=this.m_groupList;y;y=y.GetNext())y.m_firstIndex=v(y.m_firstIndex),y.m_lastIndex=v(y.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 p*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(){jr(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=qr(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!==d},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}();an.xTruncBits=12,an.yTruncBits=12,an.tagBits=32,an.yOffset=1<<an.yTruncBits-1,an.yShift=an.tagBits-an.yTruncBits,an.xShift=an.tagBits-an.yTruncBits-an.xTruncBits,an.xScale=1<<an.xShift,an.xOffset=an.xScale*(1<<an.xTruncBits-1),an.yMask=(1<<an.yTruncBits)-1<<an.yShift,an.xMask=~an.yMask,an.DestroyParticlesInShape_s_aabb=new Ft,an.CreateParticleGroup_s_transform=new Y,an.ComputeCollisionEnergy_s_v=new z,an.QueryShapeAABB_s_aabb=new Ft,an.QueryPointAABB_s_aabb=new Ft,an.RayCast_s_aabb=new Ft,an.RayCast_s_p=new z,an.RayCast_s_v=new z,an.RayCast_s_n=new z,an.RayCast_s_point=new z,an.k_pairFlags=t.b2ParticleFlag.b2_springParticle,an.k_triadFlags=t.b2ParticleFlag.b2_elasticParticle,an.k_noPressureFlags=t.b2ParticleFlag.b2_powderParticle|t.b2ParticleFlag.b2_tensileParticle,an.k_extraDampingFlags=t.b2ParticleFlag.b2_staticPressureParticle,an.k_barrierWallFlags=t.b2ParticleFlag.b2_barrierParticle|t.b2ParticleFlag.b2_wallParticle,an.CreateParticlesStrokeShapeForGroup_s_edge=new pi,an.CreateParticlesStrokeShapeForGroup_s_d=new z,an.CreateParticlesStrokeShapeForGroup_s_p=new z,an.CreateParticlesFillShapeForGroup_s_aabb=new Ft,an.CreateParticlesFillShapeForGroup_s_p=new z,an.UpdatePairsAndTriads_s_dab=new z,an.UpdatePairsAndTriads_s_dbc=new z,an.UpdatePairsAndTriads_s_dca=new z,an.AddContact_s_d=new z,an.UpdateBodyContacts_s_aabb=new Ft,an.Solve_s_subStep=new br,an.SolveCollision_s_aabb=new Ft,an.SolveGravity_s_gravity=new z,an.SolveBarrier_s_aabb=new Ft,an.SolveBarrier_s_va=new z,an.SolveBarrier_s_vb=new z,an.SolveBarrier_s_pba=new z,an.SolveBarrier_s_vba=new z,an.SolveBarrier_s_vc=new z,an.SolveBarrier_s_pca=new z,an.SolveBarrier_s_vca=new z,an.SolveBarrier_s_qba=new z,an.SolveBarrier_s_qca=new z,an.SolveBarrier_s_dv=new z,an.SolveBarrier_s_f=new z,an.SolvePressure_s_f=new z,an.SolveDamping_s_v=new z,an.SolveDamping_s_f=new z,an.SolveRigidDamping_s_t0=new z,an.SolveRigidDamping_s_t1=new z,an.SolveRigidDamping_s_p=new z,an.SolveRigidDamping_s_v=new z,an.SolveExtraDamping_s_v=new z,an.SolveExtraDamping_s_f=new z,an.SolveRigid_s_position=new z,an.SolveRigid_s_rotation=new j,an.SolveRigid_s_transform=new Y,an.SolveRigid_s_velocityTransform=new Y,an.SolveElastic_s_pa=new z,an.SolveElastic_s_pb=new z,an.SolveElastic_s_pc=new z,an.SolveElastic_s_r=new j,an.SolveElastic_s_t0=new z,an.SolveSpring_s_pa=new z,an.SolveSpring_s_pb=new z,an.SolveSpring_s_d=new z,an.SolveSpring_s_f=new z,an.SolveTensile_s_weightedNormal=new z,an.SolveTensile_s_s=new z,an.SolveTensile_s_f=new z,an.SolveViscous_s_v=new z,an.SolveViscous_s_f=new z,an.SolveRepulsive_s_f=new z,an.SolvePowder_s_f=new z,an.SolveSolid_s_f=new z,an.RemoveSpuriousBodyContacts_s_n=new z,an.RemoveSpuriousBodyContacts_s_pos=new z,an.RemoveSpuriousBodyContacts_s_normal=new z;var ln=function(){function t(){this._data=null,this.userSuppliedCapacity=0}return Ur(t,[{key:"data",get:function(){return this._data},set:function(t){this._data=t}}]),t}(),un=function(){function t(){this.index=d,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&an.xMask)>>>0,this.m_xUpper=(i&an.xMask)>>>0,this.m_yLower=(e&an.yMask)>>>0,this.m_yUpper=(i&an.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&an.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 d},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}(),dn=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return d},e}(fn),pn=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return d},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}(),gn=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}on(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}(mr),yn=function(t){function e(e){var i;return(i=t.call(this)||this).m_threshold=0,i.m_threshold=e,i}on(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}on(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}(_i),bn=function(e){function i(t){var i;return(i=e.call(this)||this).m_flagsBuffer=t,i}return on(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}on(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(),d=_>0?1/_:0,p=f>0?1/f:0,m=this.m_system.m_flagsBuffer.data[n]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),g=z.SubVV(o,c,a),y=z.CrossVV(g,l),v=m+d+p*y*y,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}($r);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}on(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],d=this.m_system.m_velocityBuffer.data[n],p=a,m=l;if(0===this.m_system.m_iterationIndex){var g=Y.MulTXV(_.m_xf0,f,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(g.SelfSub(_.GetLocalCenter()),j.MulRV(_.m_xf0.q,g,g),j.MulTRV(_.m_xf.q,g,g),g.SelfAdd(_.GetLocalCenter())),Y.MulXV(_.m_xf,g,m.p1)}else m.p1.Copy(f);if(z.AddVMulSV(f,this.m_step.dt,d,m.p2),m.maxFraction=1,e.RayCast(p,m,r)){var y=p.normal,v=h;v.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+o*y.x,v.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+o*y.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()*(d.x-b.x),S.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.y-b.y),this.m_system.ParticleApplyForce(n,S)}},r.ReportParticle=function(){return!1},i}($r);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 Tn=function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new yr,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 vr,this.m_island=new Pr,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 Ci(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 Di(e);case t.b2JointType.e_mouseJoint:return new Gi(e);case t.b2JointType.e_prismaticJoint:return new Ui(e);case t.b2JointType.e_revoluteJoint:return new ji(e);case t.b2JointType.e_pulleyJoint:return new Xi(e);case t.b2JointType.e_gearJoint:return new Li(e);case t.b2JointType.e_wheelJoint:return new Qi(e);case t.b2JointType.e_weldJoint:return new Ji(e);case t.b2JointType.e_frictionJoint:return new Oi(e);case t.b2JointType.e_ropeJoint:return new qi(e);case t.b2JointType.e_motorJoint:return new Vi(e);case t.b2JointType.e_areaJoint:return new Pi(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 an(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 Or(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 d=this.m_bodyList;d;d=d.m_next){var p=e.DrawDebugData_s_xf;p.q.Copy(d.m_xf.q),p.p.Copy(d.GetWorldCenter()),this.m_debugDraw.DrawTransform(p)}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 mr?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 mr)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 mr?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 mr)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 mr?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 mr)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 mr?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 gr?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(),d=_.GetGroundAnchorB();this.m_debugDraw.DrawSegment(f,h,c),this.m_debugDraw.DrawSegment(d,u,c),this.m_debugDraw.DrawSegment(f,d,c);break;case t.b2JointType.e_mouseJoint:var p=e.DrawJoint_s_c;p.Set(0,1,0),this.m_debugDraw.DrawPoint(h,4,p),this.m_debugDraw.DrawPoint(u,4,p),p.Set(.8,.8,.8),this.m_debugDraw.DrawSegment(h,u,p);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,d=_.m_vertices,p=e.DrawShape_s_ghostColor.SetRGBA(.75*r.r,.75*r.g,.75*r.b,r.a),m=d[0];if(this.m_debugDraw.DrawPoint(m,4,r),_.m_hasPrevVertex){var g=_.m_prevVertex;this.m_debugDraw.DrawSegment(g,m,p),this.m_debugDraw.DrawCircle(g,.1,p)}for(var y=1;y<f;++y){var v=d[y];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,p),this.m_debugDraw.DrawCircle(b,.1,p)}break;case t.b2ShapeType.e_polygonShape:var S=n,A=S.m_count,T=S.m_vertices;this.m_debugDraw.DrawSolidPolygon(T,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 d=f.m_fixtureA.m_isSensor,p=f.m_fixtureB.m_isSensor;if(!d&&!p){n.AddContact(f),f.m_islandFlag=!0;var m=_.other;m.m_islandFlag||(l[u++]=m,m.m_islandFlag=!0)}}}for(var g=c.m_jointList;g;g=g.next)if(!g.joint.m_islandFlag){var y=g.other;y.IsActive()&&(n.AddJoint(g.joint),g.joint.m_islandFlag=!0,y.m_islandFlag||(l[u++]=y,y.m_islandFlag=!0))}}}var v=new vr;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 T=new Q,C=this.m_bodyList;C;C=C.m_next)C.m_islandFlag&&C.GetType()!==t.b2BodyType.b2_staticBody&&C.SynchronizeFixtures();this.m_contactManager.FindNewContacts(),this.m_profile.broadphase=T.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(),d=_.m_type,p=f.m_type,m=_.IsAwake()&&d!==t.b2BodyType.b2_staticBody,g=f.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!g)continue;var y=_.IsBullet()||d!==t.b2BodyType.b2_dynamicBody,v=f.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!y&&!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(),T=e.SolveTOI_s_toi_input;T.proxyA.SetShape(u.GetShape(),S),T.proxyB.SetShape(c.GetShape(),A),T.sweepA.Copy(_.m_sweep),T.sweepB.Copy(f.m_sweep),T.tMax=1;var C=e.SolveTOI_s_toi_output;ge(C,T);var x=C.t;h=C.state===t.b2TOIOutputState.e_touching?B(b+(1-b)*x,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(),R=w.GetBody(),D=E.GetBody(),M=e.SolveTOI_s_backup1.Copy(R.m_sweep),P=e.SolveTOI_s_backup2.Copy(D.m_sweep);if(R.Advance(o),D.Advance(o),a.Update(this.m_contactManager.m_contactListener),a.m_toiFlag=!1,++a.m_toiCount,a.IsEnabled()&&a.IsTouching()){R.SetAwake(!0),D.SetAwake(!0),r.Clear(),r.AddBody(R),r.AddBody(D),r.AddContact(a),R.m_islandFlag=!0,D.m_islandFlag=!0,a.m_islandFlag=!0;for(var I=0;I<2;++I){var O=0===I?R:D;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 k=F.other;if(k.m_type!==t.b2BodyType.b2_dynamicBody||O.IsBullet()||k.IsBullet()){var V=L.m_fixtureA.m_isSensor,N=L.m_fixtureB.m_isSensor;if(!V&&!N){var G=e.SolveTOI_s_backup.Copy(k.m_sweep);k.m_islandFlag||k.Advance(o),L.Update(this.m_contactManager.m_contactListener),L.IsEnabled()&&L.IsTouching()?(L.m_islandFlag=!0,r.AddContact(L),k.m_islandFlag||(k.m_islandFlag=!0,k.m_type!==t.b2BodyType.b2_staticBody&&k.SetAwake(!0),r.AddBody(k))):(k.m_sweep.Copy(G),k.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,R.m_islandIndex,D.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 X=H.m_contactList;X;X=X.next)X.contact.m_toiFlag=!1,X.contact.m_islandFlag=!1}}if(this.m_contactManager.FindNewContacts(),this.m_subStepping){this.m_stepComplete=!1;break}}else a.SetEnabled(!1),R.m_sweep.Copy(M),D.m_sweep.Copy(P),R.SynchronizeTransform(),D.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}();Tn.Step_s_step=new br,Tn.Step_s_stepTimer=new Q,Tn.Step_s_timer=new Q,Tn.DrawDebugData_s_color=new J(0,0,0),Tn.DrawDebugData_s_vs=z.MakeArray(4),Tn.DrawDebugData_s_xf=new Y,Tn.QueryFixtureShape_s_aabb=new Ft,Tn.RayCast_s_input=new It,Tn.RayCast_s_output=new Ot,Tn.RayCast_s_point=new z,Tn.DrawJoint_s_p1=new z,Tn.DrawJoint_s_p2=new z,Tn.DrawJoint_s_color=new J(.5,.8,.8),Tn.DrawJoint_s_c=new J,Tn.DrawShape_s_ghostColor=new J,Tn.SolveTOI_s_subStep=new br,Tn.SolveTOI_s_backup=new K,Tn.SolveTOI_s_backup1=new K,Tn.SolveTOI_s_backup2=new K,Tn.SolveTOI_s_toi_input=new ne,Tn.SolveTOI_s_toi_output=new ae;var Cn=function(t,e){this.prevBody=null,this.nextBody=null,this.prevController=null,this.nextController=null,this.controller=t,this.body=e},xn=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 Cn(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}on(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 J(0,0,.8);t.DrawSegment(i,r,n)},e}(xn),En=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).A=new z(0,0),e}on(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}(xn);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}on(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}(xn),Rn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).G=1,e.invSqr=!0,e}on(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 d=this.m_bodyList;d;d=d.nextBody)for(var p=d.body,m=p.GetWorldCenter(),g=p.GetMass(),y=this.m_bodyList;y&&y!==d;y=y.nextBody){var v=y.body,b=v.GetWorldCenter(),S=v.GetMass(),A=b.x-m.x,T=b.y-m.y,C=A*A+T*T;if(!(C<r)){var x=e.Step_s_f.Set(A,T);x.SelfMul(this.G/C*g*S),p.IsAwake()&&p.ApplyForce(x,m),v.IsAwake()&&v.ApplyForce(x.SelfMul(-1),b)}}},i.Draw=function(){},e}(xn);Rn.Step_s_f=new z;var Dn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).T=new X,e.maxTimestep=0,e}on(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(X.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/R(t,e):0},e}(xn);Dn.Step_s_damping=new z;var Mn=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=T(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=T(r),this.m_as=T(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),d=z.CrossVV(_,f),p=z.DotVV(_,f);this.m_as[l]=G(d,p)}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 d=z.CrossVV(u,c),p=z.DotVV(u,c),m=G(d,p),g=z.MulSV(-1/_,u.SelfSkew(),t.s_Jd1),y=z.MulSV(1/f,c.SelfSkew(),t.s_Jd2),v=z.NegV(g,t.s_J1),b=z.SubVV(g,y,t.s_J2),S=y,A=o*z.DotVV(v,v)+l*z.DotVV(b,b)+h*z.DotVV(S,S);if(0!==A){A=1/A;for(var T=m-this.m_as[i];T>s;)T=(m-=2*s)-this.m_as[i];for(;T<-s;)T=(m+=2*s)-this.m_as[i];var C=-this.m_k3*A*T;r.SelfMulAdd(o*C,v),n.SelfMulAdd(l*C,b),a.SelfMulAdd(h*C,S)}}}},e.Draw=function(t){for(var e=new J(.4,.5,.7),i=0;i<this.m_count-1;++i)t.DrawSegment(this.m_ps[i],this.m_ps[i+1],e)},t}();Mn.s_d=new z,Mn.s_d1=new z,Mn.s_d2=new z,Mn.s_Jd1=new z,Mn.s_Jd2=new z,Mn.s_J1=new z,Mn.s_J2=new z,t.b2AABB=Ft,t.b2Abs=E,t.b2Acos=V,t.b2Alloc=function(){return null},t.b2AreaJoint=Pi,t.b2AreaJointDef=Mi,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 Ao(Error,i)}},t.b2Atan2=G,t.b2BlockAllocator=function(){},t.b2Body=Ci,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=Or,t.b2ChainAndCircleContact=lr,t.b2ChainAndPolygonContact=hr,t.b2ChainShape=mi,t.b2CircleContact=rr,t.b2CircleShape=fi,t.b2Clamp=D,t.b2ClipSegmentToLine=kt,t.b2ClipVertex=Pt,t.b2CollideCircles=be,t.b2CollideEdgeAndCircle=ri,t.b2CollideEdgeAndPolygon=hi,t.b2CollidePolygonAndCircle=Ce,t.b2CollidePolygons=Ye,t.b2Color=J,t.b2ConstantAccelController=En,t.b2ConstantForceController=Bn,t.b2Contact=ir,t.b2ContactEdge=er,t.b2ContactFactory=cr,t.b2ContactFeature=wt,t.b2ContactFilter=fr,t.b2ContactID=Et,t.b2ContactImpulse=dr,t.b2ContactListener=pr,t.b2ContactManager=yr,t.b2ContactPositionConstraint=Er,t.b2ContactRegister=ur,t.b2ContactSolver=Dr,t.b2ContactSolverDef=Br,t.b2ContactVelocityConstraint=wr,t.b2Controller=xn,t.b2ControllerEdge=Cn,t.b2Cos=L,t.b2Counter=$,t.b2DegToRad=function(t){return t*C},t.b2DestructionListener=_r,t.b2Distance=pt,t.b2DistanceInput=rt,t.b2DistanceJoint=Di,t.b2DistanceJointDef=Ri,t.b2DistanceOutput=nt,t.b2DistanceProxy=et,t.b2Draw=Z,t.b2DynamicTree=Xt,t.b2EdgeAndCircleContact=ar,t.b2EdgeAndPolygonContact=or,t.b2EdgeShape=pi,t.b2Filter=gi,t.b2Fixture=Si,t.b2FixtureDef=yi,t.b2FixtureParticleQueryCallback=$r,t.b2FixtureProxy=vi,t.b2Free=function(){},t.b2FrictionJoint=Oi,t.b2FrictionJointDef=Ii,t.b2GearJoint=Li,t.b2GearJointDef=Fi,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=Rn,t.b2GrowableBuffer=Qr,t.b2GrowableStack=tt,t.b2InvSqrt=I,t.b2IsPowerOfTwo=function(t){return t>0&&0==(t&t-1)},t.b2IsValid=M,t.b2Island=Pr,t.b2Jacobian=xi,t.b2Joint=Bi,t.b2JointDef=Ei,t.b2JointEdge=wi,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=T,t.b2Manifold=Dt,t.b2ManifoldPoint=Bt,t.b2MassData=ci,t.b2Mat22=X,t.b2Mat33=W,t.b2Max=R,t.b2Maybe=e,t.b2Min=B,t.b2MixFriction=$i,t.b2MixRestitution=tr,t.b2MotorJoint=Vi,t.b2MotorJointDef=ki,t.b2MouseJoint=Gi,t.b2MouseJointDef=Ni,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=Kt,t.b2ParseInt=function(t){return parseInt(t,10)},t.b2ParseUInt=function(t){return Math.abs(parseInt(t,10))},t.b2ParticleBodyContact=en,t.b2ParticleContact=tn,t.b2ParticleDef=Ir,t.b2ParticleGroup=Vr,t.b2ParticleGroupDef=kr,t.b2ParticleHandle=Lr,t.b2ParticlePair=rn,t.b2ParticlePairSet=pn,t.b2ParticleSystem=an,t.b2ParticleSystemDef=sn,t.b2ParticleSystem_CompositeShape=vn,t.b2ParticleSystem_ConnectionFilter=mn,t.b2ParticleSystem_DestroyParticlesInShapeCallback=gn,t.b2ParticleSystem_FixedSetAllocator=fn,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=d,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=dn,t.b2ParticleSystem_InsideBoundsEnumerator=cn,t.b2ParticleSystem_JoinParticleGroupsFilter=yn,t.b2ParticleSystem_ParticleListNode=_n,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=d,this.second=d,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=ln,t.b2ParticleTriad=nn,t.b2PolygonAndCircleContact=sr,t.b2PolygonContact=nr,t.b2PolygonShape=di,t.b2Position=Sr,t.b2PositionSolverManifold=Rr,t.b2Pow=F,t.b2PrismaticJoint=Ui,t.b2PrismaticJointDef=zi,t.b2Profile=vr,t.b2PulleyJoint=Xi,t.b2PulleyJointDef=Hi,t.b2QueryCallback=mr,t.b2RadToDeg=function(t){return t*x},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2RayCastCallback=gr,t.b2RayCastInput=It,t.b2RayCastOutput=Ot,t.b2RevoluteJoint=ji,t.b2RevoluteJointDef=Wi,t.b2Rope=Mn,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=qi,t.b2RopeJointDef=Yi,t.b2Rot=j,t.b2SeparationFunction=oe,t.b2Shape=_i,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=R(i.m_radius,h)+R(r.m_radius,h),s=e.transformA,a=e.transformB,o=e.translationB,l=gt.Set(0,0),u=0,c=yt;c.m_count=0;for(var _=c.m_vertices,f=i.GetSupport(j.MulTRV(s.q,z.NegV(o,z.s_t1),z.s_t0)),d=Y.MulXV(s,i.GetVertex(f),vt),p=r.GetSupport(j.MulTRV(a.q,o,z.s_t0)),m=Y.MulXV(a,r.GetVertex(p),bt),g=z.SubVV(d,m,St),y=R(h,n-h),v=0;v<20&&E(g.Length()-y)>.004;){t.iterations+=1,f=i.GetSupport(j.MulTRV(s.q,z.NegV(g,z.s_t1),z.s_t0)),d=Y.MulXV(s,i.GetVertex(f),vt),p=r.GetSupport(j.MulTRV(a.q,g,z.s_t0)),m=Y.MulXV(a,r.GetVertex(p),bt);var b=z.SubVV(d,m,At);g.Normalize();var S=z.DotVV(g,b),A=z.DotVV(g,o);if(S-y>u*A){if(A<=0)return!1;if((u=(S-y)/A)>1)return!1;l.Copy(g).SelfNeg(),c.m_count=0}var T=_[c.m_count];switch(T.indexA=p,T.wA.Copy(m).SelfMulAdd(u,o),T.indexB=f,T.wB.Copy(d),T.w.Copy(T.wB).SelfSub(T.wA),T.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(g),++v}var C=Tt,x=Ct;return c.GetWitnessPoints(C,x),g.LengthSquared()>0&&(l.Copy(g).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=k,t.b2SolverData=Tr,t.b2Sq=P,t.b2Sqrt=O,t.b2StackAllocator=function(){},t.b2Swap=function(t,e){var i=t[0];t[0]=e[0],e[0]=i},t.b2Sweep=K,t.b2TOIInput=ne,t.b2TOIOutput=ae,t.b2TensorDampingController=Dn,t.b2TestOverlapAABB=Lt,t.b2TestOverlapShape=zt,t.b2TimeOfImpact=ge,t.b2TimeStep=br,t.b2Timer=Q,t.b2Transform=Y,t.b2TreeNode=Ht,t.b2Vec2=z,t.b2Vec2_zero=U,t.b2Vec3=H,t.b2Velocity=Ar,t.b2VelocityConstraintPoint=xr,t.b2Version=b,t.b2WeldJoint=Ji,t.b2WeldJointDef=Ki,t.b2WheelJoint=Qi,t.b2WheelJointDef=Zi,t.b2World=Tn,t.b2WorldManifold=Mt,t.b2_180_over_pi=x,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=d,t.b2_linearSleepTolerance=y,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=g,t.b2_minParticleWeight=1,t.b2_minPulleyLength=2,t.b2_particleStride=p,t.b2_pi=s,t.b2_pi_over_180=C,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=Cr,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));Qo(ott);var ltt={};for(var htt in ott)-1===htt.indexOf("b2_")&&(ltt[htt.replace("b2","")]=ott[htt]);var utt,ctt,_tt,ftt,dtt,ptt=ltt;!function(t){t[t.Static=0]="Static",t[t.Kinematic=1]="Kinematic",t[t.Dynamic=2]="Dynamic",t[t.Animated=3]="Animated"}(utt||(utt=t("ERigidBody2DType",{}))),zs(utt),function(t){t[t.None=0]="None",t[t.BOX=1]="BOX",t[t.CIRCLE=2]="CIRCLE",t[t.POLYGON=3]="POLYGON"}(ctt||(ctt=t("ECollider2DType",{}))),zs(ctt),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"}(_tt||(_tt=t("EJoint2DType",{}))),zs(_tt),function(t){t[t.DEFAULT=1]="DEFAULT"}(ftt||(ftt=t("PhysicsGroup",{}))),zs(ftt),function(t){t[t.Closest=0]="Closest",t[t.Any=1]="Any",t[t.AllClosest=2]="AllClosest",t[t.All=3]="All"}(dtt||(dtt=t("ERaycast2DType",{})));var mtt,gtt=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"}(mtt||(mtt=t("EPhysics2DDrawFlags",{})));var ytt=t("PHYSICS_2D_PTM_RATIO",32),vtt=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}on(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){Ea(this._contactFixtures,t)},e}(ptt.ContactListener),btt=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 ptt.Vec2,e._isPoint=!1,e._fixtures=[],e}on(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}(ptt.QueryCallback);function Stt(t,e){var i=e.length;return e[t<0?i- -t%i:t%i]}function Att(t,e,i){for(var r=[];e<t;)e+=i.length;for(;t<=e;++t)r.push(Stt(t,i));return r}function Ttt(t){Mtt(t);for(var e,r,n,s,a,o,l=[],h=new i,u=new i,c=0,_=0,f=0;f<t.length;++f)if(xtt(f,t)){r=n=1e8;for(var d=0;d<t.length;++d)Ett(Stt(f-1,t),Stt(f,t),Stt(d,t))&&Rtt(Stt(f-1,t),Stt(f,t),Stt(d-1,t))&&(s=Itt(Stt(f-1,t),Stt(f,t),Stt(d,t),Stt(d-1,t)),wtt(Stt(f+1,t),Stt(f,t),s)&&(e=Dtt(Stt(f,t),s))<r&&(r=e,h=s,c=d)),Ett(Stt(f+1,t),Stt(f,t),Stt(d+1,t))&&Rtt(Stt(f+1,t),Stt(f,t),Stt(d,t))&&(s=Itt(Stt(f+1,t),Stt(f,t),Stt(d,t),Stt(d+1,t)),Ett(Stt(f-1,t),Stt(f,t),s)&&(e=Dtt(Stt(f,t),s))<n&&(n=e,_=d,u=s));if(c==(_+1)%t.length){var p=h.add(u).multiplyScalar(.5);(a=Att(f,_,t)).push(p),(o=Att(c,f,t)).push(p)}else{for(var m=0,g=c;_<c;)_+=t.length;for(var y=c;y<=_;++y)if(Ctt(f,y,t)){var v=1/(Dtt(Stt(f,t),Stt(y,t))+1);xtt(y,t)?Rtt(Stt(y-1,t),Stt(y,t),Stt(f,t))&&Btt(Stt(y+1,t),Stt(y,t),Stt(f,t))?v+=3:v+=2:v+=1,v>m&&(g=y,m=v)}a=Att(f,g,t),o=Att(g,f,t)}return(l=l.concat(Ttt(a))).concat(Ttt(o))}l.push(t);for(var b=l.length-1;b>=0;b--)0==l[b].length&&l.splice(b,0);return l}function Ctt(t,e,r){if(xtt(t,r)){if(Btt(Stt(t,r),Stt(t-1,r),Stt(e,r))&&Rtt(Stt(t,r),Stt(t+1,r),Stt(e,r)))return!1}else if(Rtt(Stt(t,r),Stt(t+1,r),Stt(e,r))||Btt(Stt(t,r),Stt(t-1,r),Stt(e,r)))return!1;if(xtt(e,r)){if(Btt(Stt(e,r),Stt(e-1,r),Stt(t,r))&&Rtt(Stt(e,r),Stt(e+1,r),Stt(t,r)))return!1}else if(Rtt(Stt(e,r),Stt(e+1,r),Stt(t,r))||Btt(Stt(e,r),Stt(e-1,r),Stt(t,r)))return!1;for(var n=0;n<r.length;++n)if((n+1)%r.length!=t&&n!=t&&(n+1)%r.length!=e&&n!=e){var s=new i;if(Ott(Stt(t,r),Stt(e,r),Stt(n,r),Stt(n+1,r),s))return!1}return!0}function xtt(t,e){return wtt(t,e)}function wtt(t,e,i){if(void 0===i){var r=t,n=e;t=Stt(r-1,n),e=Stt(r,n),void 0===t&&(t=e),void 0===(i=Stt(r+1,n))&&(i=e)}return Ftt(t,e,i)<0}function Ett(t,e,i){return Ftt(t,e,i)>0}function Btt(t,e,i){return Ftt(t,e,i)>=0}function Rtt(t,e,i){return Ftt(t,e,i)<=0}function Dtt(t,e){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r}function Mtt(t){Ptt(t)||t.reverse()}function Ptt(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 Itt(t,e,r,n){var s,a=new i,o=e.y-t.y,l=t.x-e.x,h=o*t.x+l*t.y,u=n.y-r.y,c=r.x-n.x,_=u*r.x+c*r.y,f=o*c-u*l;return s=f,0,Math.abs(s-0)<=1e-6||(a.x=(c*h-l*_)/f,a.y=(o*_-u*h)/f),a}function Ott(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),d=(o-s)*(a-u)-(l-a)*(s-h),p=(_-u)*(o-s)-(c-h)*(l-a);return!(Math.abs(p)<1e-6)&&(d/=p,(f/=p)>0&&f<1&&d>0&&d<1&&(n.x=s+f*(o-s),n.y=a+f*(l-a),!0))}function Ftt(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var Ltt=Object.freeze({__proto__:null,ConvexPartition:Ttt,ForceCounterClockWise:Mtt,IsCounterClockWise:Ptt}),ktt=function(){return 0},Vtt={impl:null,rigidBody:null,isAwake:!1,isSleeping:!1,initialize:ktt,setType:ktt,setLinearDamping:ktt,setAngularDamping:ktt,setGravityScale:ktt,setFixedRotation:ktt,setAllowSleep:ktt,isActive:ktt,setActive:ktt,wakeUp:ktt,sleep:ktt,getMass:ktt,getInertia:ktt,getLinearVelocity:ktt,setLinearVelocity:ktt,getLinearVelocityFromWorldPoint:ktt,getAngularVelocity:ktt,setAngularVelocity:ktt,getLocalVector:ktt,getWorldVector:ktt,getLocalPoint:ktt,getWorldPoint:ktt,getLocalCenter:ktt,getWorldCenter:ktt,applyForce:ktt,applyForceToCenter:ktt,applyTorque:ktt,applyLinearImpulse:ktt,applyLinearImpulseToCenter:ktt,applyAngularImpulse:ktt,onEnable:ktt,onDisable:ktt,onDestroy:ktt},Ntt={INITED:!1};var Gtt,ztt,Utt,Htt,Xtt,Wtt,jtt={INITED:!1},Ytt={impl:null,initialize:ktt,setDampingRatio:ktt,setFrequency:ktt,setMaxForce:ktt,setTarget:ktt,setDistance:ktt,setAngularOffset:ktt,setCorrectionFactor:ktt,setLinearOffset:ktt,setMaxLength:ktt,setMaxTorque:ktt,setLowerLimit:ktt,setUpperLimit:ktt,setMaxMotorForce:ktt,setMaxMotorTorque:ktt,setMotorSpeed:ktt,enableLimit:ktt,enableMotor:ktt,setLowerAngle:ktt,setUpperAngle:ktt};!function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(Gtt||(Gtt=t("ERigidBodyType",{}))),zs(Gtt),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(ztt||(ztt=t("EAxisDirection",{}))),zs(ztt),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(Utt||(Utt={})),zs(Utt),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"}(Htt||(Htt={})),zs(Htt),function(t){t[t.POINT_TO_POINT=0]="POINT_TO_POINT",t[t.HINGE=1]="HINGE",t[t.CONE_TWIST=2]="CONE_TWIST"}(Xtt||(Xtt={})),zs(Xtt),function(t){t[t.DEFAULT=1]="DEFAULT"}(Wtt||(Wtt={})),zs(Wtt);var qtt=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=Wtt.DEFAULT}else{for(var n=0;n<32;n++)this[""+(1<<n)]=0;this[1]=Wtt.DEFAULT}},Ktt=null;Er.internal.PhysicsGroup2D=ftt;var Jtt,Ztt,Qtt,$tt,tet,eet,iet,ret,net,set,aet,oet,het,uet,cet,_et,fet,det,pet,met,get=t("PhysicsSystem2D",function(t){function e(){var e,r,n,s,a;(a=t.call(this)||this).velocityIterations=10,a.positionIterations=10,a.physicsWorld=void 0,a.collisionMatrix=new qtt,a._enable=!0,a._allowSleep=!0,a._maxSubSteps=1,a._fixedTimeStep=1/60,a._autoSimulation=!0,a._accumulator=0,a._steping=!1,a._gravity=new i(0,-10*ytt),a._delayEvents=[];var o=To.querySettings(Co.Category.PHYSICS,"gravity");o&&(i.copy(a._gravity,o),a._gravity.multiplyScalar(ytt)),a._allowSleep=null!==(e=To.querySettings(Co.Category.PHYSICS,"allowSleep"))&&void 0!==e?e:a._allowSleep,a._fixedTimeStep=null!==(r=To.querySettings(Co.Category.PHYSICS,"fixedTimeStep"))&&void 0!==r?r:a._fixedTimeStep,a._maxSubSteps=null!==(n=To.querySettings(Co.Category.PHYSICS,"maxSubSteps"))&&void 0!==n?n:a._maxSubSteps,a._autoSimulation=null!==(s=To.querySettings(Co.Category.PHYSICS,"autoSimulation"))&&void 0!==s?s:a._autoSimulation;var l=To.querySettings(Co.Category.PHYSICS,"collisionMatrix");if(l)for(var h in l){var u=parseInt(h),c=1<<parseInt(h);a.collisionMatrix[""+c]=l[u]}var _=To.querySettings(Co.Category.PHYSICS,"collisionGroups");return _&&_ instanceof Array&&(_.forEach((function(t){ftt[t.name]=1<<t.index})),zs.update(ftt)),a.physicsWorld=new rtt.PhysicsWorld,a.gravity=a._gravity,a.allowSleep=a._allowSleep,a}on(e,t);var r=e.prototype;return r.postUpdate=function(t){if(this._enable&&this._autoSimulation){Kr.emit(Or.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,Kr.emit(Or.EVENT_AFTER_PHYSICS)}},r._callAfterStep=function(t,e){this._steping?this._delayEvents.push({target:t,func:e}):e.call(t)},r.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},r.step=function(t){this.physicsWorld.step(t,this.velocityIterations,this.positionIterations)},r.raycast=function(t,e,i,r){return void 0===i&&(i=dtt.Closest),void 0===r&&(r=4294967295),this.physicsWorld.raycast(t,e,i,r)},r.testPoint=function(t){return this.physicsWorld.testPoint(t)},r.testAABB=function(t){return this.physicsWorld.testAABB(t)},Ur(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 i(t.x/ytt,t.y/ytt))}},{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!ntt}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===ntt}},{key:"PHYSICS_BOX2D",get:function(){return"box2d"===ntt}},{key:"PhysicsGroup",get:function(){return ftt}},{key:"instance",get:function(){return Ktt||(Ktt=new e),Ktt}}]),e}(Ha(Rr)));get.ID="PHYSICS_2D",Kr.once(Or.EVENT_INIT,(function(){get.PHYSICS_NONE||uo||Kr.registerSystem(get.ID,get.instance,Rr.Priority.LOW)})),function(t){t[t.Circles=0]="Circles",t[t.FaceA=1]="FaceA",t[t.FaceB=2]="FaceB"}(Jtt||(Jtt=t("Physics2DManifoldType",{})));var yet,vet,bet,Aet,Tet,Cet,xet,wet,Eet,Bet,Ret,Det,Met,Pet,Iet,Oet,Fet,Let,ket,Vet,Net,Get,zet,Uet,Het,Xet,Wet,jet,Yet,qet,Ket,Jet,Zet,Qet,$et,tit,eit,iit,rit,nit,sit,ait,oit,lit,hit,uit,cit,_it,fit,dit,pit,mit,git,yit,vit,bit,Sit,Ait,Tit,Cit,xit,wit,Eit,Bit,Rit,Dit,Mit,Pit,Iit,Oit,Fit,Lit,kit,Vit,Nit,Git,zit,Uit,Hit,Xit,Wit,jit,Yit,qit,Kit,Jit,Zit,Qit,$it,trt,ert,irt,rrt,nrt,srt,art,ort,lrt,hrt,urt,crt=aa,_rt=Wn,frt=ts,drt=t("RigidBody2D",(Ztt=En("cc.RigidBody2D"),Qtt=frt(),$tt=_rt(Wtt),tet=_rt(utt),Ztt(eet=Qtt((met=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,Mn(e,"enabledContactListener",ret,Pn(e)),Mn(e,"bullet",net,Pn(e)),Mn(e,"awakeOnLoad",set,Pn(e)),e._body=null,Mn(e,"_group",aet,Pn(e)),Mn(e,"_type",oet,Pn(e)),Mn(e,"_allowSleep",het,Pn(e)),Mn(e,"_gravityScale",uet,Pn(e)),Mn(e,"_linearDamping",cet,Pn(e)),Mn(e,"_angularDamping",_et,Pn(e)),Mn(e,"_linearVelocity",fet,Pn(e)),Mn(e,"_angularVelocity",det,Pn(e)),Mn(e,"_fixedRotation",pet,Pn(e)),e}on(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=Er._global.CC_PHYSICS_2D_BUILTIN?Vtt:new rtt.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()},Ur(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===utt.Animated?this._body.setType(utt.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}(ns),Dn((iet=met).prototype,"group",[$tt],Object.getOwnPropertyDescriptor(iet.prototype,"group"),iet.prototype),ret=Dn(iet.prototype,"enabledContactListener",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),net=Dn(iet.prototype,"bullet",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(iet.prototype,"type",[tet],Object.getOwnPropertyDescriptor(iet.prototype,"type"),iet.prototype),Dn(iet.prototype,"allowSleep",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"allowSleep"),iet.prototype),Dn(iet.prototype,"gravityScale",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"gravityScale"),iet.prototype),Dn(iet.prototype,"linearDamping",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"linearDamping"),iet.prototype),Dn(iet.prototype,"angularDamping",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"angularDamping"),iet.prototype),Dn(iet.prototype,"linearVelocity",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"linearVelocity"),iet.prototype),Dn(iet.prototype,"angularVelocity",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"angularVelocity"),iet.prototype),Dn(iet.prototype,"fixedRotation",[crt],Object.getOwnPropertyDescriptor(iet.prototype,"fixedRotation"),iet.prototype),set=Dn(iet.prototype,"awakeOnLoad",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),aet=Dn(iet.prototype,"_group",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wtt.DEFAULT}}),oet=Dn(iet.prototype,"_type",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return utt.Dynamic}}),het=Dn(iet.prototype,"_allowSleep",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),uet=Dn(iet.prototype,"_gravityScale",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),cet=Dn(iet.prototype,"_linearDamping",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_et=Dn(iet.prototype,"_angularDamping",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),fet=Dn(iet.prototype,"_linearVelocity",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),det=Dn(iet.prototype,"_angularVelocity",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pet=Dn(iet.prototype,"_fixedRotation",[crt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),eet=iet))||eet)||eet)),prt=t("Collider2D",(yet=En("cc.Collider2D"),vet=Wn(Wtt),yet((Met=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,Mn(e,"editing",Tet,Pn(e)),Mn(e,"tag",Cet,Pn(e)),e.TYPE=ctt.None,e._shape=null,e._body=null,Mn(e,"_group",xet,Pn(e)),Mn(e,"_density",wet,Pn(e)),Mn(e,"_sensor",Eet,Pn(e)),Mn(e,"_friction",Bet,Pn(e)),Mn(e,"_restitution",Ret,Pn(e)),Mn(e,"_offset",Det,Pn(e)),e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._shape=function(t){return Ntt.INITED||(Ntt.INITED=!0,Ntt[ctt.BOX]=function(){return new rtt.BoxShape},Ntt[ctt.CIRCLE]=function(){return new rtt.CircleShape},Ntt[ctt.POLYGON]=function(){return new rtt.PolygonShape}),Ntt[t]()}(this.TYPE),this._shape.initialize(this),this._shape.onLoad&&this._shape.onLoad(),this._body=this.getComponent(drt)},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()},Ur(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 m}}]),e}(Ha(ns)),Tet=Dn((Aet=Met).prototype,"editing",[Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Cet=Dn(Aet.prototype,"tag",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Aet.prototype,"group",[vet],Object.getOwnPropertyDescriptor(Aet.prototype,"group"),Aet.prototype),Dn(Aet.prototype,"density",[aa],Object.getOwnPropertyDescriptor(Aet.prototype,"density"),Aet.prototype),Dn(Aet.prototype,"sensor",[aa],Object.getOwnPropertyDescriptor(Aet.prototype,"sensor"),Aet.prototype),Dn(Aet.prototype,"friction",[aa],Object.getOwnPropertyDescriptor(Aet.prototype,"friction"),Aet.prototype),Dn(Aet.prototype,"restitution",[aa],Object.getOwnPropertyDescriptor(Aet.prototype,"restitution"),Aet.prototype),Dn(Aet.prototype,"offset",[aa],Object.getOwnPropertyDescriptor(Aet.prototype,"offset"),Aet.prototype),xet=Dn(Aet.prototype,"_group",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wtt.DEFAULT}}),wet=Dn(Aet.prototype,"_density",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Eet=Dn(Aet.prototype,"_sensor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Bet=Dn(Aet.prototype,"_friction",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.2}}),Ret=Dn(Aet.prototype,"_restitution",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Det=Dn(Aet.prototype,"_offset",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),bet=Aet))||bet)),mrt=(t("BoxCollider2D",En("cc.BoxCollider2D")(Pet=ts()((Fet=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,Mn(e,"_size",Oet,Pn(e)),e.TYPE=ctt.BOX,e}return on(e,t),Ur(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}(prt),Oet=Dn((Iet=Fet).prototype,"_size",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new d(1,1)}}),Dn(Iet.prototype,"size",[aa],Object.getOwnPropertyDescriptor(Iet.prototype,"size"),Iet.prototype),Pet=Iet))||Pet)||Pet),t("CircleCollider2D",En("cc.CircleCollider2D")(Let=ts()((Net=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,Mn(e,"_radius",Vet,Pn(e)),e.TYPE=ctt.CIRCLE,e}return on(e,t),Ur(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 i}},{key:"worldRadius",get:function(){return this._shape?this._shape.worldRadius:0}}]),e}(prt),Vet=Dn((ket=Net).prototype,"_radius",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dn(ket.prototype,"radius",[aa],Object.getOwnPropertyDescriptor(ket.prototype,"radius"),ket.prototype),Let=ket))||Let)||Let),t("PolygonCollider2D",(Get=En("cc.PolygonCollider2D"),zet=ts(),Uet=aa({serializable:!1,displayOrder:0}),Het=aa({type:i}),Get(Xet=zet((qet=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,Mn(e,"threshold",jet,Pn(e)),Mn(e,"_points",Yet,Pn(e)),e.TYPE=ctt.POLYGON,e}return on(e,t),Ur(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}(prt),jet=Dn((Wet=qet).prototype,"threshold",[Uet],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Yet=Dn(Wet.prototype,"_points",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[new i(-1,-1),new i(1,-1),new i(1,1),new i(-1,1)]}}),Dn(Wet.prototype,"points",[Het],Object.getOwnPropertyDescriptor(Wet.prototype,"points"),Wet.prototype),Xet=Wet))||Xet)||Xet)),t("Joint2D",(Ket=En("cc.Joint2D"),Jet=Wn(drt),Ket((rit=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,Mn(e,"anchor",$et,Pn(e)),Mn(e,"connectedAnchor",tit,Pn(e)),Mn(e,"collideConnected",eit,Pn(e)),Mn(e,"connectedBody",iit,Pn(e)),e._body=null,e._joint=null,e.TYPE=_tt.None,e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._joint=function(t){return function(){if(!jtt.INITED){jtt.INITED=!0;var t=Er._global.CC_PHYSICS_2D_BUILTIN;jtt[_tt.SPRING]=function(){return t?Ytt:new rtt.SpringJoint},jtt[_tt.DISTANCE]=function(){return t?Ytt:new rtt.DistanceJoint},jtt[_tt.FIXED]=function(){return t?Ytt:new rtt.FixedJoint},jtt[_tt.MOUSE]=function(){return t?Ytt:new rtt.MouseJoint},jtt[_tt.RELATIVE]=function(){return t?Ytt:new rtt.RelativeJoint},jtt[_tt.SLIDER]=function(){return t?Ytt:new rtt.SliderJoint},jtt[_tt.WHEEL]=function(){return t?Ytt:new rtt.WheelJoint},jtt[_tt.HINGE]=function(){return t?Ytt:new rtt.HingeJoint}}}(),jtt[t]()}(this.TYPE),this._joint.initialize(this),this._body=this.getComponent(drt)},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()},Ur(e,[{key:"body",get:function(){return this._body}},{key:"impl",get:function(){return this._joint}}]),e}(ns),$et=Dn((Qet=rit).prototype,"anchor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),tit=Dn(Qet.prototype,"connectedAnchor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),eit=Dn(Qet.prototype,"collideConnected",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),iit=Dn(Qet.prototype,"connectedBody",[Jet],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Zet=Qet))||Zet))),grt=(t("DistanceJoint2D",En("cc.DistanceJoint2D")(nit=ts()((lit=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=_tt.DISTANCE,Mn(e,"_maxLength",ait,Pn(e)),Mn(e,"_autoCalcDistance",oit,Pn(e)),e}return on(e,t),Ur(e,[{key:"maxLength",get:function(){return this._autoCalcDistance&&this.connectedBody?n.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}(mrt),Dn((sit=lit).prototype,"maxLength",[aa],Object.getOwnPropertyDescriptor(sit.prototype,"maxLength"),sit.prototype),Dn(sit.prototype,"autoCalcDistance",[aa],Object.getOwnPropertyDescriptor(sit.prototype,"autoCalcDistance"),sit.prototype),ait=Dn(sit.prototype,"_maxLength",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),oit=Dn(sit.prototype,"_autoCalcDistance",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),nit=sit))||nit)||nit),t("SpringJoint2D",En("cc.SpringJoint2D")(hit=ts()((pit=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=_tt.SPRING,Mn(e,"_frequency",cit,Pn(e)),Mn(e,"_dampingRatio",_it,Pn(e)),Mn(e,"_distance",fit,Pn(e)),Mn(e,"_autoCalcDistance",dit,Pn(e)),e}return on(e,t),Ur(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?n.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}(mrt),Dn((uit=pit).prototype,"frequency",[aa],Object.getOwnPropertyDescriptor(uit.prototype,"frequency"),uit.prototype),Dn(uit.prototype,"dampingRatio",[aa],Object.getOwnPropertyDescriptor(uit.prototype,"dampingRatio"),uit.prototype),Dn(uit.prototype,"distance",[aa],Object.getOwnPropertyDescriptor(uit.prototype,"distance"),uit.prototype),Dn(uit.prototype,"autoCalcDistance",[aa],Object.getOwnPropertyDescriptor(uit.prototype,"autoCalcDistance"),uit.prototype),cit=Dn(uit.prototype,"_frequency",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),_it=Dn(uit.prototype,"_dampingRatio",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),fit=Dn(uit.prototype,"_distance",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),dit=Dn(uit.prototype,"_autoCalcDistance",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),hit=uit))||hit)||hit),t("MouseJoint2D",En("cc.MouseJoint2D")(mit=ts()((Sit=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=_tt.MOUSE,Mn(e,"_maxForce",yit,Pn(e)),Mn(e,"_dampingRatio",vit,Pn(e)),Mn(e,"_frequency",bit,Pn(e)),e._target=new i,e}return on(e,t),e.prototype.update=function(t){this._joint.update(t)},Ur(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}(mrt),Dn((git=Sit).prototype,"frequency",[aa],Object.getOwnPropertyDescriptor(git.prototype,"frequency"),git.prototype),Dn(git.prototype,"dampingRatio",[aa],Object.getOwnPropertyDescriptor(git.prototype,"dampingRatio"),git.prototype),Dn(git.prototype,"maxForce",[aa],Object.getOwnPropertyDescriptor(git.prototype,"maxForce"),git.prototype),yit=Dn(git.prototype,"_maxForce",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),vit=Dn(git.prototype,"_dampingRatio",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),bit=Dn(git.prototype,"_frequency",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),mit=git))||mit)||mit),new n),yrt=new n,vrt=(t("RelativeJoint2D",En("cc.RelativeJoint2D")(Ait=ts()((Dit=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=_tt.RELATIVE,Mn(e,"_maxForce",Cit,Pn(e)),Mn(e,"_maxTorque",xit,Pn(e)),Mn(e,"_correctionFactor",wit,Pn(e)),Mn(e,"_angularOffset",Eit,Pn(e)),Mn(e,"_linearOffset",Bit,Pn(e)),Mn(e,"_autoCalcOffset",Rit,Pn(e)),e}return on(e,t),Ur(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?i.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&&(l.toEuler(grt,this.node.worldRotation),l.toEuler(yrt,this.connectedBody.node.worldRotation),this._angularOffset=yrt.z-grt.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}(mrt),Dn((Tit=Dit).prototype,"maxForce",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"maxForce"),Tit.prototype),Dn(Tit.prototype,"maxTorque",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"maxTorque"),Tit.prototype),Dn(Tit.prototype,"correctionFactor",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"correctionFactor"),Tit.prototype),Dn(Tit.prototype,"linearOffset",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"linearOffset"),Tit.prototype),Dn(Tit.prototype,"angularOffset",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"angularOffset"),Tit.prototype),Dn(Tit.prototype,"autoCalcOffset",[aa],Object.getOwnPropertyDescriptor(Tit.prototype,"autoCalcOffset"),Tit.prototype),Cit=Dn(Tit.prototype,"_maxForce",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),xit=Dn(Tit.prototype,"_maxTorque",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),wit=Dn(Tit.prototype,"_correctionFactor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),Eit=Dn(Tit.prototype,"_angularOffset",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Bit=Dn(Tit.prototype,"_linearOffset",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new i}}),Rit=Dn(Tit.prototype,"_autoCalcOffset",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Ait=Tit))||Ait)||Ait),new i),brt=(t("SliderJoint2D",En("cc.SliderJoint2D")(Mit=ts()((zit=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=_tt.SLIDER,Mn(e,"_angle",Iit,Pn(e)),Mn(e,"_autoCalcAngle",Oit,Pn(e)),Mn(e,"_enableMotor",Fit,Pn(e)),Mn(e,"_maxMotorForce",Lit,Pn(e)),Mn(e,"_motorSpeed",kit,Pn(e)),Mn(e,"_enableLimit",Vit,Pn(e)),Mn(e,"_lowerLimit",Nit,Pn(e)),Mn(e,"_upperLimit",Git,Pn(e)),e}return on(e,t),Ur(e,[{key:"angle",get:function(){return this._autoCalcAngle&&this.connectedBody&&(i.subtract(vrt,this.connectedBody.node.worldPosition,this.node.worldPosition),this._angle=E(Math.atan2(vrt.y,vrt.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}(mrt),Dn((Pit=zit).prototype,"angle",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"angle"),Pit.prototype),Dn(Pit.prototype,"autoCalcAngle",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"autoCalcAngle"),Pit.prototype),Dn(Pit.prototype,"enableMotor",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"enableMotor"),Pit.prototype),Dn(Pit.prototype,"maxMotorForce",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"maxMotorForce"),Pit.prototype),Dn(Pit.prototype,"motorSpeed",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"motorSpeed"),Pit.prototype),Dn(Pit.prototype,"enableLimit",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"enableLimit"),Pit.prototype),Dn(Pit.prototype,"lowerLimit",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"lowerLimit"),Pit.prototype),Dn(Pit.prototype,"upperLimit",[aa],Object.getOwnPropertyDescriptor(Pit.prototype,"upperLimit"),Pit.prototype),Iit=Dn(Pit.prototype,"_angle",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Oit=Dn(Pit.prototype,"_autoCalcAngle",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Fit=Dn(Pit.prototype,"_enableMotor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Lit=Dn(Pit.prototype,"_maxMotorForce",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),kit=Dn(Pit.prototype,"_motorSpeed",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),Vit=Dn(Pit.prototype,"_enableLimit",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Nit=Dn(Pit.prototype,"_lowerLimit",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Git=Dn(Pit.prototype,"_upperLimit",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Mit=Pit))||Mit)||Mit),t("FixedJoint2D",En("cc.FixedJoint2D")(Uit=ts()((jit=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=_tt.FIXED,Mn(e,"_frequency",Xit,Pn(e)),Mn(e,"_dampingRatio",Wit,Pn(e)),e}return on(e,t),Ur(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}(mrt),Dn((Hit=jit).prototype,"frequency",[aa],Object.getOwnPropertyDescriptor(Hit.prototype,"frequency"),Hit.prototype),Dn(Hit.prototype,"dampingRatio",[aa],Object.getOwnPropertyDescriptor(Hit.prototype,"dampingRatio"),Hit.prototype),Xit=Dn(Hit.prototype,"_frequency",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),Wit=Dn(Hit.prototype,"_dampingRatio",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),Uit=Hit))||Uit)||Uit),t("WheelJoint2D",En("cc.WheelJoint2D")(Yit=ts()((ert=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=_tt.WHEEL,Mn(e,"_angle",Kit,Pn(e)),Mn(e,"_enableMotor",Jit,Pn(e)),Mn(e,"_maxMotorTorque",Zit,Pn(e)),Mn(e,"_motorSpeed",Qit,Pn(e)),Mn(e,"_frequency",$it,Pn(e)),Mn(e,"_dampingRatio",trt,Pn(e)),e}return on(e,t),Ur(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}(mrt),Dn((qit=ert).prototype,"angle",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"angle"),qit.prototype),Dn(qit.prototype,"enableMotor",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"enableMotor"),qit.prototype),Dn(qit.prototype,"maxMotorTorque",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"maxMotorTorque"),qit.prototype),Dn(qit.prototype,"motorSpeed",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"motorSpeed"),qit.prototype),Dn(qit.prototype,"frequency",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"frequency"),qit.prototype),Dn(qit.prototype,"dampingRatio",[aa],Object.getOwnPropertyDescriptor(qit.prototype,"dampingRatio"),qit.prototype),Kit=Dn(qit.prototype,"_angle",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 90}}),Jit=Dn(qit.prototype,"_enableMotor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Zit=Dn(qit.prototype,"_maxMotorTorque",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),Qit=Dn(qit.prototype,"_motorSpeed",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$it=Dn(qit.prototype,"_frequency",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),trt=Dn(qit.prototype,"_dampingRatio",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),Yit=qit))||Yit)||Yit),t("HingeJoint2D",En("cc.HingeJoint2D")(irt=ts()((urt=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=_tt.HINGE,Mn(e,"_enableLimit",nrt,Pn(e)),Mn(e,"_lowerAngle",srt,Pn(e)),Mn(e,"_upperAngle",art,Pn(e)),Mn(e,"_enableMotor",ort,Pn(e)),Mn(e,"_maxMotorTorque",lrt,Pn(e)),Mn(e,"_motorSpeed",hrt,Pn(e)),e}return on(e,t),Ur(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}(mrt),Dn((rrt=urt).prototype,"enableLimit",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"enableLimit"),rrt.prototype),Dn(rrt.prototype,"lowerAngle",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"lowerAngle"),rrt.prototype),Dn(rrt.prototype,"upperAngle",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"upperAngle"),rrt.prototype),Dn(rrt.prototype,"enableMotor",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"enableMotor"),rrt.prototype),Dn(rrt.prototype,"maxMotorTorque",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"maxMotorTorque"),rrt.prototype),Dn(rrt.prototype,"motorSpeed",[aa],Object.getOwnPropertyDescriptor(rrt.prototype,"motorSpeed"),rrt.prototype),nrt=Dn(rrt.prototype,"_enableLimit",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),srt=Dn(rrt.prototype,"_lowerAngle",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),art=Dn(rrt.prototype,"_upperAngle",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ort=Dn(rrt.prototype,"_enableMotor",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),lrt=Dn(rrt.prototype,"_maxMotorTorque",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),hrt=Dn(rrt.prototype,"_motorSpeed",[aa],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),irt=rrt))||irt)||irt),t("Physics2DUtils",{PolygonSeparator:Ltt}),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=dtt.Closest,e._fixtures=[],e._points=[],e._normals=[],e._fractions=[],e._mask=4294967295,e}on(e,t);var r=e.prototype;return r.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},r.ReportFixture=function(t,e,r,n){return 0==(t.GetFilterData().categoryBits&this._mask)?0:this._type===dtt.Closest?(this._fixtures[0]=t,this._points[0]=e,this._normals[0]=r,this._fractions[0]=n,n):(this._fixtures.push(t),this._points.push(new i(e.x,e.y)),this._normals.push(new i(r.x,r.y)),this._fractions.push(n),this._type===dtt.Any?0:this._type>=dtt.All?1:n)},r.getFixtures=function(){return this._fixtures},r.getPoints=function(){return this._points},r.getNormals=function(){return this._normals},r.getFractions=function(){return this._fractions},e}(ptt.RayCastCallback)),Srt=[],Art=[new i,new i],Trt=new ptt.WorldManifold,Crt={points:[],separations:[],normal:new i},xrt=function(){this.localPoint=new i,this.normalImpulse=0,this.tangentImpulse=0},wrt=[new xrt,new xrt],Ert={type:0,localPoint:new i,localNormal:new i,points:[]},Brt={normalImpulses:[],tangentImpulses:[]},Rrt=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=Srt.pop();return i||(i=new t),i.init(e),i},t.put=function(t){var e=t.m_userData;e&&(Srt.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=Crt.points,e=Crt.separations,i=Crt.normal;this._b2contact.GetWorldManifold(Trt);var r=Trt.points,n=Trt.separations,s=this._b2contact.GetManifold().pointCount;t.length=e.length=s;for(var a=0;a<s;a++){var o=Art[a];o.x=r[a].x*ytt,o.y=r[a].y*ytt,t[a]=o,e[a]=n[a]*ytt}return i.x=Trt.normal.x,i.y=Trt.normal.y,this._inverted&&(i.x*=-1,i.y*=-1),Crt},e.getManifold=function(){for(var t=Ert.points,e=Ert.localNormal,i=Ert.localPoint,r=this._b2contact.GetManifold(),n=r.points,s=t.length=r.pointCount,a=0;a<s;a++){var o=wrt[a],l=n[a];o.localPoint.x=l.localPoint.x*ytt,o.localPoint.y=l.localPoint.y*ytt,o.normalImpulse=l.normalImpulse*ytt,o.tangentImpulse=l.tangentImpulse,t[a]=o}return i.x=r.localPoint.x*ytt,i.y=r.localPoint.y*ytt,e.x=r.localNormal.x,e.y=r.localNormal.y,Ert.type=r.type,this._inverted&&(e.x*=-1,e.y*=-1),Ert},e.getImpulse=function(){var t=this._impulse;if(!t)return null;for(var e=Brt.normalImpulses,i=Brt.tangentImpulses,r=t.count,n=0;n<r;n++)e[n]=t.normalImpulses[n]*ytt,i[n]=t.tangentImpulses[n];return i.length=e.length=r,Brt},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)&&get.instance.emit(t,e,i,this),(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}(),Drt=new ptt.Vec2,Mrt=new y,Prt=y.GREEN,Irt=y.RED,Ort=function(t){function e(e){var i;return(i=t.call(this)||this)._drawer=null,i._xf=new ptt.Transform,i._dxf=new ptt.Transform,i._drawer=e,i}on(e,t);var i=e.prototype;return i._DrawPolygon=function(t,e){for(var i=this._drawer,r=0;r<e;r++){ptt.Transform.MulXV(this._xf,t[r],Drt);var n=Drt.x*ytt,s=Drt.y*ytt;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)*ytt,(t.y+i.y)*ytt,e*ytt)},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/ytt),void r.fill();this._applyStrokeColor(i),ptt.Transform.MulXV(this._xf,t,Drt),r.moveTo(Drt.x*ytt,Drt.y*ytt),ptt.Transform.MulXV(this._xf,e,Drt),r.lineTo(Drt.x*ytt,Drt.y*ytt),r.stroke()},i.DrawTransform=function(t){var e=this._drawer;e.strokeColor=Irt,Drt.x=Drt.y=0,ptt.Transform.MulXV(t,Drt,Drt),e.moveTo(Drt.x*ytt,Drt.y*ytt),Drt.x=1,Drt.y=0,ptt.Transform.MulXV(t,Drt,Drt),e.lineTo(Drt.x*ytt,Drt.y*ytt),e.stroke(),e.strokeColor=Prt,Drt.x=Drt.y=0,ptt.Transform.MulXV(t,Drt,Drt),e.moveTo(Drt.x*ytt,Drt.y*ytt),Drt.x=0,Drt.y=1,ptt.Transform.MulXV(t,Drt,Drt),e.lineTo(Drt.x*ytt,Drt.y*ytt),e.stroke()},i.DrawPoint=function(){},i.DrawParticles=function(){},i._applyStrokeColor=function(t){this._drawer.strokeColor=Mrt.set(255*t.r,255*t.g,255*t.b,150)},i._applyFillColor=function(t){this._drawer.fillColor=Mrt.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}(ptt.Draw),Frt=new n,Lrt=new i,krt=new i,Vrt=new ptt.BodyDef,Nrt=new ptt.AABB,Grt=[],zrt=function(){function t(){this._world=void 0,this._bodies=[],this._animatedBodies=[],this._rotationAxis=new n,this._contactListener=void 0,this._aabbQueryCallback=void 0,this._raycastQueryCallback=void 0,this._debugGraphics=null,this._b2DebugDrawer=null,this._debugDrawFlags=0,this._world=new ptt.World(new ptt.Vec2(0,-10));var t=new vtt;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 btt,this._raycastQueryCallback=new brt}var e=t.prototype;return e._checkDebugDrawValid=function(){if(!this._debugGraphics||!this._debugGraphics.isValid){var t=kn("Canvas");if(!t){var e=Kr.getScene();if(!e)return;(t=new ks("Canvas")).addComponent(Hm),t.parent=e}var i=new ks("PHYSICS_2D_DEBUG_DRAW");i.hideFlags|=Vs.Flags.DontSave,i.parent=t,i.worldPosition=n.ZERO,i.layer=gs.Enum.UI_2D,this._debugGraphics=i.addComponent(Mp),this._debugGraphics.lineWidth=2;var r=new Ort(this._debugGraphics);this._b2DebugDrawer=r,this._world.SetDebugDraw(r)}var s=this._debugGraphics.node.parent;this._debugGraphics.node.setSiblingIndex(s.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,r,n){if(t.equals(e))return[];r=r||dtt.Closest,Lrt.x=t.x/ytt,Lrt.y=t.y/ytt,krt.x=e.x/ytt,krt.y=e.y/ytt;var s=this._raycastQueryCallback;s.init(r,n),this._world.RayCast(s,Lrt,krt);var a=s.getFixtures();if(a.length>0){for(var o=s.getPoints(),l=s.getNormals(),h=s.getFractions(),u=[],c=0,_=a.length;c<_;c++){var f=a[c],d=f.m_userData,p=d.collider;if(r===dtt.AllClosest){for(var m=void 0,g=0;g<u.length;g++)u[g].collider===p&&(m=u[g]);if(m){h[c]<m.fraction&&(m.fixtureIndex=d.getFixtureIndex(f),m.point.x=o[c].x*ytt,m.point.y=o[c].y*ytt,m.normal.x=l[c].x,m.normal.y=l[c].y,m.fraction=h[c]);continue}}u.push({collider:p,fixtureIndex:d.getFixtureIndex(f),point:new i(o[c].x*ytt,o[c].y*ytt),normal:new i(l[c].x,l[c].y),fraction:h[c]})}return u}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!==utt.Animated){var s=n.node,a=r.impl,o=a.GetPosition();Frt.x=o.x*ytt,Frt.y=o.y*ytt,Frt.z=0,s.worldPosition=Frt;var l=E(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=Vrt,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/ytt,n.y/ytt),Frt.z=l.getAxisAngle(this._rotationAxis,r.worldRotation),this._rotationAxis.z<0&&(Frt.z=2*Math.PI-Frt.z),e.angle=Frt.z,e.awake=i.awakeOnLoad,i.type===utt.Animated?(e.type=utt.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=w(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),Ma.remove(this._bodies,t),t.rigidBody.type===utt.Animated&&Ma.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=Lrt.x=t.x/ytt,i=Lrt.y=t.y/ytt,r=.2/ytt;Nrt.lowerBound.x=e-r,Nrt.lowerBound.y=i-r,Nrt.upperBound.x=e+r,Nrt.upperBound.y=i+r;var n=this._aabbQueryCallback;n.init(Lrt),this._world.QueryAABB(n,Nrt);var s=n.getFixtures();Grt.length=0;for(var a=0;a<s.length;a++){var o=s[a].m_userData.collider;Grt.includes(o)||Grt.push(o)}return Grt},e.testAABB=function(t){Nrt.lowerBound.x=t.xMin/ytt,Nrt.lowerBound.y=t.yMin/ytt,Nrt.upperBound.x=t.xMax/ytt,Nrt.upperBound.y=t.yMax/ytt;var e=this._aabbQueryCallback;e.init(),this._world.QueryAABB(e,Nrt);var i=e.getFixtures();Grt.length=0;for(var r=0;r<i.length;r++){var n=i[r].m_userData.collider;Grt.includes(n)||Grt.push(n)}return Grt},e.drawDebug=function(){this._checkDebugDrawValid(),this._debugGraphics&&(this._debugGraphics.clear(),this._world.DrawDebugData())},e._onBeginContact=function(t){Rrt.get(t).emit(gtt.BEGIN_CONTACT)},e._onEndContact=function(t){var e=t.m_userData;e&&(e.emit(gtt.END_CONTACT),Rrt.put(t))},e._onPreSolve=function(t){var e=t.m_userData;e&&e.emit(gtt.PRE_SOLVE)},e._onPostSolve=function(t,e){var i=t.m_userData;i&&(i._setImpulse(e),i.emit(gtt.POST_SOLVE),i._setImpulse(null))},Ur(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}(),Urt=(new n,new ptt.Vec2),Hrt=function(){function t(){this._animatedPos=new i,this._animatedAngle=0,this._body=null,this._inited=!1}var e=t.prototype;return e.initialize=function(t){this._rigidBody=t,get.instance._callAfterStep(this,this._init)},e.onDestroy=function(){get.instance._callAfterStep(this,this._destroy)},e.onEnable=function(){this.setActive(!0)},e.onDisable=function(){this.setActive(!1)},e._registerNodeEvents=function(){this.rigidBody.node.on(Zn.TRANSFORM_CHANGED,this._onNodeTransformChanged,this)},e._unregisterNodeEvents=function(){this.rigidBody.node.off(Zn.TRANSFORM_CHANGED,this._onNodeTransformChanged,this)},e._onNodeTransformChanged=function(t){if(!get.instance.stepping){if(t&ks.TransformBit.SCALE)for(var e=this.rigidBody.getComponents(prt),i=0;i<e.length;i++)e[i].apply();t&ks.TransformBit.POSITION&&this.syncPositionToPhysics(!0),t&ks.TransformBit.ROTATION&&this.syncRotationToPhysics(!0)}},e._init=function(){this._inited||(this._registerNodeEvents(),get.instance.physicsWorld.addBody(this),this._inited=!0)},e._destroy=function(){this._inited&&(get.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;Urt.x=(this._animatedPos.x-i.x)*r,Urt.y=(this._animatedPos.y-i.y)*r,e.SetLinearVelocity(Urt);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===utt.Animated?e.GetLinearVelocity():e.GetPosition()).x=r.x/ytt,i.y=r.y/ytt,n===utt.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=w(this._rigidBody.node.eulerAngles.z);this._rigidBody.type===utt.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 Urt.Set(t.x/ytt,t.y/ytt),this._body.GetLinearVelocityFromWorldPoint(Urt,e),e.x*=ytt,e.y*=ytt,e},e.setAngularVelocity=function(t){this._body.SetAngularVelocity(t)},e.getAngularVelocity=function(){return E(this._body.GetAngularVelocity())},e.getLocalVector=function(t,e){return e=e||new i,Urt.Set(t.x/ytt,t.y/ytt),this._body.GetLocalVector(Urt,e),e.x*=ytt,e.y*=ytt,e},e.getWorldVector=function(t,e){return Urt.Set(t.x/ytt,t.y/ytt),this._body.GetWorldVector(Urt,e),e.x*=ytt,e.y*=ytt,e},e.getLocalPoint=function(t,e){return e=e||new i,Urt.Set(t.x/ytt,t.y/ytt),this._body.GetLocalPoint(Urt,e),e.x*=ytt,e.y*=ytt,e},e.getWorldPoint=function(t,e){return e=e||new i,Urt.Set(t.x/ytt,t.y/ytt),this._body.GetWorldPoint(Urt,e),e.x*=ytt,e.y*=ytt,e},e.getLocalCenter=function(t){t=t||new i;var e=this._body.GetLocalCenter();return t.x=e.x*ytt,t.y=e.y*ytt,t},e.getWorldCenter=function(t){t=t||new i;var e=this._body.GetWorldCenter();return t.x=e.x*ytt,t.y=e.y*ytt,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(Urt.Set(e.x/ytt,e.y/ytt),this._body.ApplyForce(t,Urt,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&&(Urt.Set(e.x/ytt,e.y/ytt),this._body.ApplyLinearImpulse(t,Urt,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)},Ur(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}(),Xrt=new ptt.Filter;function Wrt(t){var e=t.collider;return Xrt.categoryBits=e.group===Wtt.DEFAULT?e.body.group:e.group,Xrt.maskBits=get.instance.collisionMatrix[Xrt.categoryBits],Xrt}var jrt,Yrt,qrt=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new m}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){get.instance._callAfterStep(this,this._init)},e.onDisable=function(){get.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=Wrt(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(drt);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=Wrt(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&&get.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,get.instance.physicsWorld.unregisterContactFixture(r),e&&e.DestroyFixture(r)}this._body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},Ur(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*=ytt,i*=ytt,r*=ytt,n*=ytt;var c=this._rect;return c.x=e,c.y=i,c.width=r-e,c.height=n-i,c}}]),t}(),Krt=new m,Jrt=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(e=t.call.apply(t,[this].concat(n))||this)._worldPoints=[new i,new i,new i,new i],e}return on(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/ytt*t,n=i.size.height/2/ytt*e,s=i.offset.x/ytt*t,a=i.offset.y/ytt*e,o=new ptt.PolygonShape;return o.SetAsBox(r,n,new ptt.Vec2(s,a),0),[o]},Ur(e,[{key:"worldPoints",get:function(){var t=Krt,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}(qrt),Zrt=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(e=t.call.apply(t,[this].concat(n))||this)._worldPosition=new i,e}return on(e,t),e.prototype._createShapes=function(t,e){t=Math.abs(t),e=Math.abs(e);var i=this.collider,r=i.offset.x/ytt*t,n=i.offset.y/ytt*e,s=new ptt.CircleShape;return s.m_radius=i.radius/ytt*t,s.m_p.Set(r,n),[s]},Ur(e,[{key:"worldRadius",get:function(){return this._shapes[0].m_radius*ytt}},{key:"worldPosition",get:function(){var t=this._shapes[0].m_p;return this._worldPosition.set(t.x*ytt,t.y*ytt)}}]),e}(qrt),Qrt=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 on(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=Ttt(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 ptt.PolygonShape);var d=l[_],p=(d.x+a.x)/ytt*t,m=(d.y+a.y)/ytt*e,g=new ptt.Vec2(p,m);u.push(g),c||(c=g),u.length===ptt.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},Ur(e,[{key:"worldPoints",get:function(){for(var t=this.collider,e=t.points,r=this._worldPoints,n=t.node.worldMatrix,s=0;s<e.length;s++)r[s]||(r[s]=new i),i.transformMat4(r[s],e[s],n);return r.length=e.length,this._worldPoints}}]),e}(qrt),$rt=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(){get.instance._callAfterStep(this,this._init)},e.onDisable=function(){get.instance._callAfterStep(this,this._destroy)},e.start=function(){get.instance._callAfterStep(this,this._init)},e._init=function(){if(!this._inited){var t=this._jointComp;if(t.isValid){this._body=t.getComponent(drt);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=get.instance.physicsWorld.impl.CreateJoint(e),this._inited=!0)}}}},e._destroy=function(){this._inited&&(get.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},Ur(t,[{key:"impl",get:function(){return this._b2joint}},{key:"comp",get:function(){return this._jointComp}},{key:"body",get:function(){return this._body}}]),t}(),tnt=new ptt.Vec2;function ent(t){Er._global.CC_PHYSICS_BUILTIN="builtin"===t,Er._global.CC_PHYSICS_CANNON="cannon.js"===t,Er._global.CC_PHYSICS_AMMO="ammo.js"===t}jrt={PhysicsWorld:zrt,RigidBody:Hrt,BoxShape:Jrt,CircleShape:Zrt,PolygonShape:Qrt,MouseJoint:function(t){function e(){for(var e,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(e=t.call.apply(t,[this].concat(n))||this)._touchPoint=new i,e._isTouched=!1,e}on(e,t);var r=e.prototype;return r.setTarget=function(t){this._b2joint&&(tnt.x=t.x/ytt,tnt.y=t.y/ytt,this._b2joint.SetTarget(tnt))},r.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},r.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},r.setMaxForce=function(t){this._b2joint&&this._b2joint.SetMaxForce(t)},r._createJointDef=function(){var t=new ptt.MouseJointDef,e=this._jointComp;return t.target.Set(this._touchPoint.x/ytt,this._touchPoint.y/ytt),t.maxForce=e.maxForce,t.dampingRatio=e.dampingRatio,t.frequencyHz=e.frequency,t},r.initialize=function(e){t.prototype.initialize.call(this,e);var i=kn("Canvas");i&&(i.on(Zn.TOUCH_START,this.onTouchBegan,this),i.on(Zn.TOUCH_MOVE,this.onTouchMove,this),i.on(Zn.TOUCH_END,this.onTouchEnd,this),i.on(Zn.TOUCH_CANCEL,this.onTouchEnd,this))},r.onEnable=function(){},r.start=function(){},r.onTouchBegan=function(t){this._isTouched=!0;var e=this._touchPoint.set(t.getUILocation()),i=get.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)}},r.onTouchMove=function(t){this._touchPoint=t.getUILocation()},r.onTouchEnd=function(){this._destroy(),this._isTouched=!1},r.update=function(){this._isTouched&&this.isValid()&&this.setTarget(this._touchPoint)},e}($rt),DistanceJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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 ptt.RopeJointDef;return e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt),e.maxLength=t.maxLength/ytt,e},e}($rt),SpringJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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 ptt.DistanceJointDef;return e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt),e.length=t.distance/ytt,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}($rt),RelativeJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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(w(t))},i.setLinearOffset=function(t){this._b2joint&&this._b2joint.SetLinearOffset(new ptt.Vec2(t.x/ytt,t.y/ytt))},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 ptt.MotorJointDef;return e.linearOffset.Set(t.linearOffset.x/ytt,t.linearOffset.y/ytt),e.angularOffset=w(t.angularOffset),e.maxForce=t.maxForce,e.maxTorque=t.maxTorque,e.correctionFactor=t.correctionFactor,e},e}($rt),SliderJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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/ytt,t.upperLimit/ytt)}},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 ptt.PrismaticJointDef;e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt);var i=w(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.referenceAngle=0,e.enableLimit=t.enableLimit,e.lowerTranslation=t.lowerLimit/ytt,e.upperTranslation=t.upperLimit/ytt,e.enableMotor=t.enableMotor,e.maxMotorForce=t.maxMotorForce,e.motorSpeed=t.motorSpeed,e},e}($rt),FixedJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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 ptt.WeldJointDef;return e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt),e.referenceAngle=0,e.frequencyHz=t.frequency,e.dampingRatio=t.dampingRatio,e},e}($rt),WheelJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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 ptt.WheelJointDef;e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt);var i=w(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=w(t.motorSpeed),e.enableMotor=t.enableMotor,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}($rt),HingeJoint:function(t){function e(){return t.apply(this,arguments)||this}on(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(w(t.lowerAngle),w(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 ptt.RevoluteJointDef;return e.localAnchorA.Set(t.anchor.x/ytt,t.anchor.y/ytt),e.localAnchorB.Set(t.connectedAnchor.x/ytt,t.connectedAnchor.y/ytt),e.enableMotor=t.enableMotor,e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=w(t.motorSpeed),e.enableLimit=t.enableLimit,e.lowerAngle=t.lowerAngle,e.upperAngle=t.upperAngle,e},e}($rt)},ntt="box2d",Er._global.CC_PHYSICS_2D_BUILTIN=!1,Er._global.CC_PHYSICS_2D_BOX2D=!0,rtt=jrt;var int,rnt={id:"",switchTo:function(t){if(rnt.runInEditor){var e=rnt;if(rnt.physicsWorld&&t!==rnt.id&&null!=rnt.backend[t]?(rnt.physicsWorld.destroy(),console.info("[PHYSICS]: switch from "+rnt.id+" to "+t+"."),ent(t),e.id=t,e.wrapper=rnt.backend[t],e.physicsWorld=ont()):(console.info("[PHYSICS]: using "+t+"."),e.physicsWorld=ont()),Yrt){var i=e.physicsWorld;i.setGravity(Yrt.gravity),i.setAllowSleep(Yrt.allowSleep)}}},register:function(t,e){if(console.info("[PHYSICS]: register "+t+"."),rnt.backend[t]=e,!rnt.physicsWorld||rnt.id===t){ent(t);var i=rnt;i.id=t,i.wrapper=e}},wrapper:{},backend:{},physicsWorld:null,runInEditor:!uo},nnt=function(){return 0},snt={impl:null,setGravity:nnt,setAllowSleep:nnt,setDefaultMaterial:nnt,step:nnt,syncAfterEvents:nnt,syncSceneToPhysics:nnt,raycast:nnt,raycastClosest:nnt,emitEvents:nnt,destroy:nnt};function ant(t,e){return null==t&&(rnt.id?bn(rnt.id+" physics does not support "+int[e]):Nn(9600),!0)}function ont(){return ant(rnt.wrapper.PhysicsWorld,int.World)?snt:new rnt.wrapper.PhysicsWorld}!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"}(int||(int={}));var lnt={impl:null,rigidBody:null,isAwake:!1,isSleepy:!1,isSleeping:!1,initialize:nnt,onEnable:nnt,onDisable:nnt,onDestroy:nnt,setType:nnt,setMass:nnt,setLinearDamping:nnt,setAngularDamping:nnt,useGravity:nnt,setLinearFactor:nnt,setAngularFactor:nnt,setAllowSleep:nnt,wakeUp:nnt,sleep:nnt,clearState:nnt,clearForces:nnt,clearVelocity:nnt,setSleepThreshold:nnt,getSleepThreshold:nnt,getLinearVelocity:nnt,setLinearVelocity:nnt,getAngularVelocity:nnt,setAngularVelocity:nnt,applyForce:nnt,applyLocalForce:nnt,applyImpulse:nnt,applyLocalImpulse:nnt,applyTorque:nnt,applyLocalTorque:nnt,setGroup:nnt,getGroup:nnt,addGroup:nnt,removeGroup:nnt,setMask:nnt,getMask:nnt,addMask:nnt,removeMask:nnt,isUsingCCD:nnt,useCCD:nnt},hnt={INITED:!1},unt={impl:null,collider:null,attachedRigidBody:null,initialize:nnt,onLoad:nnt,onEnable:nnt,onDisable:nnt,onDestroy:nnt,setGroup:nnt,getGroup:nnt,addGroup:nnt,removeGroup:nnt,setMask:nnt,getMask:nnt,addMask:nnt,removeMask:nnt,setMaterial:nnt,setAsTrigger:nnt,setCenter:nnt,getAABB:nnt,getBoundingSphere:nnt,updateSize:nnt,updateRadius:nnt,setRadius:nnt,setCylinderHeight:nnt,setDirection:nnt,setHeight:nnt,setShapeType:nnt,setVertices:nnt,setMesh:nnt,setTerrain:nnt,setNormal:nnt,setConstant:nnt,updateEventListener:nnt};var cnt={INITED:!1},_nt={impl:null,initialize:nnt,onLoad:nnt,onEnable:nnt,onDisable:nnt,onDestroy:nnt,setEnableCollision:nnt,setConnectedBody:nnt,setPivotA:nnt,setPivotB:nnt,setAxis:nnt};var fnt={type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},dnt={type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},pnt=function(){function t(){this.BT_TRANSFORM_0=xo.Transform_new(),this.BT_TRANSFORM_1=xo.Transform_new(),this.BT_V3_0=xo.Vec3_new(0,0,0),this.BT_V3_1=xo.Vec3_new(0,0,0),this.BT_V3_2=xo.Vec3_new(0,0,0),this.BT_QUAT_0=xo.Quat_new(0,0,0,1)}return t.setWrapper=function(t,e,i){this.ROOT[e]||(this.ROOT[e]={}),this.ROOT[e][t]=i},t.delWrapper=function(t,e){delete this.ROOT[e][t]},t.getWrapper=function(t,e){return this.ROOT[e][t]},t.isNotEmptyShape=function(t){return t!==xo.EmptyShape_static()},Ur(t,null,[{key:"instance",get:function(){return null==t._instance&&(t._instance=new t),t._instance}}]),t}();pnt._instance=void 0,pnt.ROOT={};var mnt,gnt,ynt,vnt,bnt,Snt,Ant,Tnt,Cnt=new n,xnt=new n,wnt=new l;function Ent(t,e){return xo.Vec3_set(t,e.x,e.y,e.z),t}function Bnt(t,e){return t.x=xo.Vec3_x(e),t.y=xo.Vec3_y(e),t.z=xo.Vec3_z(e),t}function Rnt(t,e){return xo.Quat_set(t,e.x,e.y,e.z,e.w),t}function Dnt(t,e){return t.x=xo.Quat_x(e),t.y=xo.Quat_y(e),t.z=xo.Quat_z(e),t.w=xo.Quat_w(e),t}xo.CACHE=pnt;var Mnt=function(e){return t({PhysicsMaterial:e,PhysicMaterial:e}),e}(En("cc.PhysicsMaterial")((Tnt=Ant=function(t){function e(){var i;return(i=t.call(this)||this).id=void 0,Mn(i,"_friction",ynt,Pn(i)),Mn(i,"_rollingFriction",vnt,Pn(i)),Mn(i,"_spinningFriction",bnt,Pn(i)),Mn(i,"_restitution",Snt,Pn(i)),e.allMaterials.push(Pn(i)),i.id=e._idCounter++,i._uuid||(i._uuid="pm_"+i.id),i}on(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},i.setValues=function(t,i,r,n){var s=this._friction!==t||this._rollingFriction!==i||this._spinningFriction!==r||this._restitution!==n;this._friction=t,this._rollingFriction=i,this._spinningFriction=r,this._restitution=n,s&&this.emit(e.EVENT_UPDATE)},Ur(e,[{key:"friction",get:function(){return this._friction},set:function(t){S(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){S(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){S(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){S(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}(Qr),Ant.allMaterials=[],Ant.EVENT_UPDATE="event_update",Ant._idCounter=0,Dn((gnt=Tnt).prototype,"friction",[Un],Object.getOwnPropertyDescriptor(gnt.prototype,"friction"),gnt.prototype),Dn(gnt.prototype,"rollingFriction",[Un],Object.getOwnPropertyDescriptor(gnt.prototype,"rollingFriction"),gnt.prototype),Dn(gnt.prototype,"spinningFriction",[Un],Object.getOwnPropertyDescriptor(gnt.prototype,"spinningFriction"),gnt.prototype),Dn(gnt.prototype,"restitution",[Un],Object.getOwnPropertyDescriptor(gnt.prototype,"restitution"),gnt.prototype),ynt=Dn(gnt.prototype,"_friction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.6}}),vnt=Dn(gnt.prototype,"_rollingFriction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),bnt=Dn(gnt.prototype,"_spinningFriction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Snt=Dn(gnt.prototype,"_restitution",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),mnt=gnt))||mnt),Pnt=t("PhysicsRayResult",function(){function t(){this._hitPoint=new n,this._hitNormal=new n,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,r){n.copy(this._hitPoint,t),n.copy(this._hitNormal,r),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return n.copy(e._hitPoint,this._hitPoint),n.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,e},Ur(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}());Er.internal.PhysicsGroup=Wtt;var Int,Ont,Fnt,Lnt,knt,Vnt,Nnt,Gnt,znt,Unt,Hnt,Xnt,Wnt,jnt,Ynt,qnt,Knt,Jnt,Znt,Qnt,$nt,tst,est,ist,rst,nst,sst,ast,ost,lst,hst,ust,cst,_st,fst,dst,pst,mst,gst,yst,vst,bst,Sst,Ast,Tst=t("PhysicsSystem",function(t){on(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this).raycastClosestResult=new Pnt,e.raycastResults=[],e.collisionMatrix=new qtt(1),e.minVolumeSize=1e-5,e.useNodeChains=!1,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 n(0,-10,0),e._materialConfig=new Mnt,e.raycastOptions={group:-1,mask:-1,queryTrigger:!0,maxDistance:1e7},e.raycastResultPool=new X((function(){return new Pnt}),1),e}return e.initDefaultMaterial=function(){null==this._material&&(this._material=os.get("default-physics-material"),null!=this._material?(this.physicsWorld.setDefaultMaterial(this._material),this._material.on(Mnt.EVENT_UPDATE,this._updateMaterial,this),this.setDefaultMaterial(this._materialConfig)):console.error("PhysicsSystem initDefaultMaterial failed"))},e.postUpdate=function(t){if(this.physicsWorld)if(this._enable){if(this._autoSimulation){for(this._subStepCount=0,this._accumulator+=t,Kr.emit(Or.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.physicsWorld.emitEvents(),this.physicsWorld.syncAfterEvents(),this._accumulator-=this._fixedTimeStep,this._subStepCount++}Kr.emit(Or.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:To.querySettings(Co.Category.PHYSICS,"allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:To.querySettings(Co.Category.PHYSICS,"fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var r=t?t.maxSubSteps:To.querySettings(Co.Category.PHYSICS,"maxSubSteps");"number"==typeof r&&(this._maxSubSteps=r);var s=t?t.sleepThreshold:To.querySettings(Co.Category.PHYSICS,"sleepThreshold");"number"==typeof s&&(this._sleepThreshold=s);var a=t?t.autoSimulation:To.querySettings(Co.Category.PHYSICS,"autoSimulation");"boolean"==typeof a&&(this.autoSimulation=a);var o=t?t.gravity:To.querySettings(Co.Category.PHYSICS,"gravity");o&&n.copy(this._gravity,o);var l=t?t.defaultMaterial:To.querySettings(Co.Category.PHYSICS,"defaultMaterial");this._materialConfig=l;var h=t?t.collisionMatrix:To.querySettings(Co.Category.PHYSICS,"collisionMatrix");if(h)for(var u in h)this.collisionMatrix[""+(1<<parseInt(u))]=h[u];var c=t?t.collisionGroups:To.querySettings(Co.Category.PHYSICS,"collisionGroups");c&&c instanceof Array&&(c.forEach((function(t){Wtt[t.name]=1<<t.index})),zs.update(Wtt)),this.physicsWorld&&(this.physicsWorld.setGravity(this._gravity),this.physicsWorld.setAllowSleep(this._allowSleep))},e.setDefaultMaterial=function(t){this._material&&t&&this._material.setValues(t.friction,t.rollingFriction,t.spinningFriction,t.restitution)},e.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},e.step=function(t,e,i){this.physicsWorld&&this.physicsWorld.step(t,e,i)},e.syncSceneToPhysics=function(){this.physicsWorld&&this.physicsWorld.syncSceneToPhysics()},e.emitEvents=function(){this.physicsWorld&&this.physicsWorld.emitEvents()},e.raycast=function(t,e,i,r){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(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))},e.raycastClosest=function(t,e,i,r){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=r,this.physicsWorld.raycastClosest(t,this.raycastOptions,this.raycastClosestResult))},e._updateMaterial=function(){this.physicsWorld&&this.physicsWorld.setDefaultMaterial(this._material)},i.constructAndRegister=function(){if(!i._instance){var t=new i;t.resetConfiguration(),function(t){if(Yrt||(Yrt=t),rnt.runInEditor&&!rnt.physicsWorld){console.info("[PHYSICS]: using "+rnt.id+".");var e=rnt.physicsWorld=ont();e.setGravity(Yrt.gravity),e.setAllowSleep(Yrt.allowSleep)}}(t),i._instance=t,Kr.registerSystem(i.ID,t,t.priority),os.get("default-physics-material")?t.initDefaultMaterial():Ir.onPostProjectInitDelegate.add(t.initDefaultMaterial.bind(t))}},Ur(i,[{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&&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&&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:"physicsWorld",get:function(){return rnt.physicsWorld}}],[{key:"PHYSICS_NONE",get:function(){return!rnt.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===rnt.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===rnt.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===rnt.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===rnt.id}},{key:"PhysicsGroup",get:function(){return Wtt}},{key:"instance",get:function(){return i._instance}}]),i}(Rr));Tst.ID="PHYSICS",Tst._instance=null,Kr.once(Or.EVENT_INIT,(function(){Tst.constructAndRegister()}));var Cst,xst,wst,Est,Bst,Rst,Dst,Mst,Pst,Ist,Ost,Fst,Lst,kst,Vst,Nst,Gst,zst,Ust,Hst,Xst,Wst,jst=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}((Int=En("cc.RigidBody"),Ont=Qn(),Fnt=ts(),Lnt=$n(-1),knt=Wn(Tst.PhysicsGroup),Vnt=es(),Nnt=is(),Gnt=Wn(Gtt),znt=es(),Unt=is(),Hnt=cs(),Xnt=es(),Wnt=is(),jnt=cs(),Ynt=es(),qnt=is(),Knt=cs(),Jnt=es(),Znt=is(),Qnt=cs(),$nt=es(),tst=is(),est=cs(),ist=es(),rst=is(),nst=cs(),sst=es(),ast=is(),ost=cs(),lst=es(),hst=is(),Int(ust=Ont(ust=Fnt(ust=Jn(ust=Kn(ust=Lnt((Ast=Sst=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,Mn(e,"_group",_st,Pn(e)),Mn(e,"_type",fst,Pn(e)),Mn(e,"_mass",dst,Pn(e)),Mn(e,"_allowSleep",pst,Pn(e)),Mn(e,"_linearDamping",mst,Pn(e)),Mn(e,"_angularDamping",gst,Pn(e)),Mn(e,"_useGravity",yst,Pn(e)),Mn(e,"_linearFactor",vst,Pn(e)),Mn(e,"_angularFactor",bst,Pn(e)),e}on(e,t);var i=e.prototype;return i.onLoad=function(){rnt.runInEditor&&(this._body=ant(rnt.wrapper.RigidBody,int.RigidBody)?lnt:new rnt.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._isInitialized&&this._body.applyForce(t,e)},i.applyLocalForce=function(t,e){this._isInitialized&&this._body.applyLocalForce(t,e)},i.applyImpulse=function(t,e){this._isInitialized&&this._body.applyImpulse(t,e)},i.applyLocalImpulse=function(t,e){this._isInitialized&&this._body.applyLocalImpulse(t,e)},i.applyTorque=function(t){this._isInitialized&&this._body.applyTorque(t)},i.applyLocalTorque=function(t){this._isInitialized&&this._body.applyLocalTorque(t)},i.wakeUp=function(){this._isInitialized&&this._body.wakeUp()},i.sleep=function(){this._isInitialized&&this._body.sleep()},i.clearState=function(){this._isInitialized&&this._body.clearState()},i.clearForces=function(){this._isInitialized&&this._body.clearForces()},i.clearVelocity=function(){this._isInitialized&&this._body.clearVelocity()},i.getLinearVelocity=function(t){this._isInitialized&&this._body.getLinearVelocity(t)},i.setLinearVelocity=function(t){this._isInitialized&&this._body.setLinearVelocity(t)},i.getAngularVelocity=function(t){this._isInitialized&&this._body.getAngularVelocity(t)},i.setAngularVelocity=function(t){this._isInitialized&&this._body.setAngularVelocity(t)},i.getGroup=function(){return this._isInitialized?this._body.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._body.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._body.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._body.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._body.getMask():0},i.setMask=function(t){this._isInitialized&&this._body.setMask(t)},i.addMask=function(t){this._isInitialized&&this._body.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._body.removeMask(t)},Ur(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._body&&this._body.getGroup()!==t&&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){n.copy(this._linearFactor,t),this._body&&this._body.setLinearFactor(this._linearFactor)}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){n.copy(this._angularFactor,t),this._body&&this._body.setAngularFactor(this._angularFactor)}},{key:"sleepThreshold",get:function(){return this._isInitialized?this._body.getSleepThreshold():.1},set:function(t){this._isInitialized&&this._body.setSleepThreshold(t)}},{key:"useCCD",get:function(){return!!this._isInitialized&&this._body.isUsingCCD()},set:function(t){this._isInitialized&&this._body.useCCD(t)}},{key:"isAwake",get:function(){return!!this._isInitialized&&this._body.isAwake}},{key:"isSleepy",get:function(){return!!this._isInitialized&&this._body.isSleepy}},{key:"isSleeping",get:function(){return!!this._isInitialized&&this._body.isSleeping}},{key:"isStatic",get:function(){return this._type===Gtt.STATIC},set:function(t){t&&this.isStatic||!t&&!this.isStatic||(this.type=t?Gtt.STATIC:Gtt.DYNAMIC)}},{key:"isDynamic",get:function(){return this._type===Gtt.DYNAMIC},set:function(t){t&&this.isDynamic||!t&&!this.isDynamic||(this.type=t?Gtt.DYNAMIC:Gtt.KINEMATIC)}},{key:"isKinematic",get:function(){return this._type===Gtt.KINEMATIC},set:function(t){t&&this.isKinematic||!t&&!this.isKinematic||(this.type=t?Gtt.KINEMATIC:Gtt.DYNAMIC)}},{key:"body",get:function(){return this._body}},{key:"_isInitialized",get:function(){var t=null===this._body;return t&&Ja("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(ns),Sst.Type=Gtt,Dn((cst=Ast).prototype,"group",[knt,Vnt,Nnt],Object.getOwnPropertyDescriptor(cst.prototype,"group"),cst.prototype),Dn(cst.prototype,"type",[Gnt,znt,Unt],Object.getOwnPropertyDescriptor(cst.prototype,"type"),cst.prototype),Dn(cst.prototype,"mass",[Hnt,Xnt,Wnt],Object.getOwnPropertyDescriptor(cst.prototype,"mass"),cst.prototype),Dn(cst.prototype,"allowSleep",[jnt,Ynt,qnt],Object.getOwnPropertyDescriptor(cst.prototype,"allowSleep"),cst.prototype),Dn(cst.prototype,"linearDamping",[Knt,Jnt,Znt],Object.getOwnPropertyDescriptor(cst.prototype,"linearDamping"),cst.prototype),Dn(cst.prototype,"angularDamping",[Qnt,$nt,tst],Object.getOwnPropertyDescriptor(cst.prototype,"angularDamping"),cst.prototype),Dn(cst.prototype,"useGravity",[est,ist,rst],Object.getOwnPropertyDescriptor(cst.prototype,"useGravity"),cst.prototype),Dn(cst.prototype,"linearFactor",[nst,sst,ast],Object.getOwnPropertyDescriptor(cst.prototype,"linearFactor"),cst.prototype),Dn(cst.prototype,"angularFactor",[ost,lst,hst],Object.getOwnPropertyDescriptor(cst.prototype,"angularFactor"),cst.prototype),_st=Dn(cst.prototype,"_group",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Tst.PhysicsGroup.DEFAULT}}),fst=Dn(cst.prototype,"_type",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Gtt.DYNAMIC}}),dst=Dn(cst.prototype,"_mass",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),pst=Dn(cst.prototype,"_allowSleep",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),mst=Dn(cst.prototype,"_linearDamping",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),gst=Dn(cst.prototype,"_angularDamping",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),yst=Dn(cst.prototype,"_useGravity",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),vst=Dn(cst.prototype,"_linearFactor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(1,1,1)}}),bst=Dn(cst.prototype,"_angularFactor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(1,1,1)}}),ust=cst))||ust)||ust)||ust)||ust)||ust)||ust));jst||(jst=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}({}));var Yst=function(e){return t({Collider:e,ColliderComponent:e}),e}((Cst=En("cc.Collider"),xst=Wn(jst),wst=_s(),Est=es(),Bst=is(),Rst=Wn(Mnt),Dst=_s(),Mst=es(),Pst=is(),Ist=es(),Ost=is(),Fst=Wn(n),Lst=es(),kst=is(),Vst=Wn(Mnt),Cst((Wst=Xst=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,Mn(i,"_material",zst,Pn(i)),Mn(i,"_isTrigger",Ust,Pn(i)),Mn(i,"_center",Hst,Pn(i)),i.type=e,i}on(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._isInitialized?this._shape.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._shape.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._shape.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._shape.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._shape.getMask():0},i.setMask=function(t){this._isInitialized&&this._shape.setMask(t)},i.addMask=function(t){this._isInitialized&&this._shape.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._shape.removeMask(t)},i.onLoad=function(){rnt.runInEditor&&(this.sharedMaterial=null==this._material?Tst.instance.defaultMaterial:this._material,this._shape=function(t){return hnt.INITED||(hnt.INITED=!0,hnt[Htt.BOX]=function(){return ant(rnt.wrapper.BoxShape,int.BoxCollider)?unt:new rnt.wrapper.BoxShape},hnt[Htt.SPHERE]=function(){return ant(rnt.wrapper.SphereShape,int.SphereCollider)?unt:new rnt.wrapper.SphereShape},hnt[Htt.CAPSULE]=function(){return ant(rnt.wrapper.CapsuleShape,int.CapsuleCollider)?unt:new rnt.wrapper.CapsuleShape},hnt[Htt.CYLINDER]=function(){return ant(rnt.wrapper.CylinderShape,int.CylinderCollider)?unt:new rnt.wrapper.CylinderShape},hnt[Htt.CONE]=function(){return ant(rnt.wrapper.ConeShape,int.ConeCollider)?unt:new rnt.wrapper.ConeShape},hnt[Htt.MESH]=function(){return ant(rnt.wrapper.TrimeshShape,int.MeshCollider)?unt:new rnt.wrapper.TrimeshShape},hnt[Htt.TERRAIN]=function(){return ant(rnt.wrapper.TerrainShape,int.TerrainCollider)?unt:new rnt.wrapper.TerrainShape},hnt[Htt.SIMPLEX]=function(){return ant(rnt.wrapper.SimplexShape,int.SimplexCollider)?unt:new rnt.wrapper.SimplexShape},hnt[Htt.PLANE]=function(){return ant(rnt.wrapper.PlaneShape,int.PlaneCollider)?unt:new rnt.wrapper.PlaneShape}),hnt[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._needTriggerEvent=!1,this._needCollisionEvent=!1,this._shape.updateEventListener(),this._material&&this._material.off(Mnt.EVENT_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())},Ur(e,[{key:"attachedRigidBody",get:function(){return t=this.node,(e=t.getComponent(jst))&&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&&this._material&&(this._material.off(Mnt.EVENT_UPDATE,this._updateMaterial,this),this._material=this._material.clone(),this._material.on(Mnt.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1),this._material},set:function(t){this._shape?(t&&this._material?this._material.id!==t.id&&(this._material.off(Mnt.EVENT_UPDATE,this._updateMaterial,this),t.on(Mnt.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1,this._material=t):t&&!this._material?(t.on(Mnt.EVENT_UPDATE,this._updateMaterial,this),this._material=t):!t&&this._material&&(this._material.off(Mnt.EVENT_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){n.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 Ii),this._shape&&this._shape.getAABB(this._aabb),this._aabb}},{key:"boundingSphere",get:function(){return null==this._boundingSphere&&(this._boundingSphere=new Pi),this._shape&&this._shape.getBoundingSphere(this._boundingSphere),this._boundingSphere}},{key:"needTriggerEvent",get:function(){return this._needTriggerEvent}},{key:"needCollisionEvent",get:function(){return this._needCollisionEvent}},{key:"_isInitialized",get:function(){var t=null===this._shape;return t&&Ja("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(Ha(ns)),Xst.Type=Htt,Xst.Axis=ztt,Dn((Gst=Wst).prototype,"attachedRigidBody",[xst,wo,wst,Est,Bst],Object.getOwnPropertyDescriptor(Gst.prototype,"attachedRigidBody"),Gst.prototype),Dn(Gst.prototype,"sharedMaterial",[Rst,Dst,Mst,Pst],Object.getOwnPropertyDescriptor(Gst.prototype,"sharedMaterial"),Gst.prototype),Dn(Gst.prototype,"isTrigger",[Ist,Ost],Object.getOwnPropertyDescriptor(Gst.prototype,"isTrigger"),Gst.prototype),Dn(Gst.prototype,"center",[Fst,Lst,kst],Object.getOwnPropertyDescriptor(Gst.prototype,"center"),Gst.prototype),zst=Dn(Gst.prototype,"_material",[Vst],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ust=Dn(Gst.prototype,"_isTrigger",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Hst=Dn(Gst.prototype,"_center",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Nst=Gst))||Nst));function qst(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}Yst||(Yst=function(e){return t({Collider:e,ColliderComponent:e}),e}({}));var Kst=new n,Jst=new n,Zst=new n,Qst=new n,$st=new n,tat=new n,eat=new n,iat=new n,rat=new n,nat=new n,sat=new n,aat=new n,oat=new n(0,0,0),lat=new n(0,0,0);function hat(t,e,i,r){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===r&&(r={});var s=.5*i,a=r.radialSegments||32,o=r.heightSegments||1,l=void 0===r.capped||r.capped,h=r.arc||2*Math.PI,u=0;l||(t>0&&u++,e>0&&u++);var c=(a+1)*(o+1);l&&(c+=(a+1)*u+a*u);var _=a*o*6;l&&(_+=a*u*3);var f=new Array(_),d=new Array(3*c),p=new Array(3*c),m=new Array(2*c),g=Math.max(t,e),y=new n(-g,-s,-g),v=new n(g,s,g),b=Math.sqrt(g*g+s*s),S=0,A=0;return function(){for(var r=[],l=t-e,u=l*l/i*Math.sign(l),c=0;c<=o;c++){for(var _=[],g=c/o,y=g*l+e,v=0;v<=a;++v){var b=v/a,T=b*h,C=Math.sin(T),x=Math.cos(T);d[3*S]=y*C,d[3*S+1]=g*i-s,d[3*S+2]=y*x,n.normalize(oat,n.set(lat,C,-u,x)),p[3*S]=oat.x,p[3*S+1]=oat.y,p[3*S+2]=oat.z,m[2*S]=2*(1-b)%1,m[2*S+1]=g,_.push(S),++S}r.push(_)}for(var w=0;w<o;++w)for(var E=0;E<a;++E){var B=r[w][E],R=r[w+1][E],D=r[w+1][E+1],M=r[w][E+1];f[A]=B,++A,f[A]=M,++A,f[A]=R,++A,f[A]=M,++A,f[A]=D,++A,f[A]=R,++A}}(),l&&(e>0&&T(!1),t>0&&T(!0)),{positions:d,normals:p,uvs:m,indices:f,minPos:y,maxPos:v,boundingRadius:b};function T(i){for(var r=i?t:e,n=i?1:-1,o=S,l=1;l<=a;++l)d[3*S]=0,d[3*S+1]=s*n,d[3*S+2]=0,p[3*S]=0,p[3*S+1]=n,p[3*S+2]=0,m[2*S]=.5,m[2*S+1]=.5,++S;for(var u=S,c=0;c<=a;++c){var _=c/a*h,g=Math.cos(_),y=Math.sin(_);d[3*S]=r*y,d[3*S+1]=s*n,d[3*S+2]=r*g,p[3*S]=0,p[3*S+1]=n,p[3*S+2]=0,m[2*S]=.5-.5*y*n,m[2*S+1]=.5+.5*g,++S}for(var v=0;v<a;++v){var b=o+v,T=u+v;i?(f[A]=T+1,++A,f[A]=b,++A,f[A]=T,++A):(f[A]=b,++A,f[A]=T+1,++A,f[A]=T,++A)}}}var uat=new n(0,0,0),cat=new n(0,0,0),_at=new n(0,0,0),fat=new n(0,0,0),dat=new n(0,0,0),pat=new n(0,0,0),mat=new n(0,0,0),gat=new n(0,0,0),yat=new n(0,0,0),vat=Object.freeze({__proto__:null,box:function(t){var e=(t=t||{}).widthSegments||1,i=t.heightSegments||1,r=t.lengthSegments||1,s=(t.width||1)/2,a=(t.height||1)/2,o=(t.length||1)/2,l=[n.set($st,-s,-a,o),n.set(tat,s,-a,o),n.set(eat,s,a,o),n.set(iat,-s,a,o),n.set(rat,s,-a,-o),n.set(nat,-s,-a,-o),n.set(sat,-s,a,-o),n.set(aat,s,a,-o)],h=[[2,3,1],[4,5,7],[7,6,2],[1,0,4],[1,4,2],[5,0,6]],u=[[0,0,1],[0,0,-1],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0]],c=[[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[0,0,-1,1],[0,0,1,1]],_=[],f=[],d=[],p=[],m=[],g=new n(-s,-a,-o),y=new n(s,a,o),v=Math.sqrt(s*s+a*a+o*o);function b(t,e,i){var r,s,a,o,g=_.length/3,y=h[t],v=u[t],b=c[t];for(o=0;o<=i;o++)for(a=0;a<=e;a++)if(r=a/e,s=o/i,n.lerp(Kst,l[y[0]],l[y[1]],r),n.lerp(Jst,l[y[0]],l[y[2]],s),n.subtract(Zst,Jst,l[y[0]]),n.add(Qst,Kst,Zst),_.push(Qst.x,Qst.y,Qst.z),f.push(v[0],v[1],v[2]),d.push(r,s),p.push(b[0],b[1],b[2],b[3]),a<e&&o<i){var S=e+1,A=a+o*S,T=a+(o+1)*S,C=a+1+(o+1)*S,x=a+1+o*S;m.push(g+A,g+x,g+T),m.push(g+T,g+x,g+C)}}return b(0,e,i),b(4,r,i),b(1,e,i),b(5,r,i),b(3,e,r),b(2,e,r),{positions:_,normals:f,uvs:d,tangents:p,indices:m,minPos:g,maxPos:y,boundingRadius:v}},cone:function(t,e,i){return void 0===t&&(t=.5),void 0===e&&(e=1),void 0===i&&(i={}),hat(0,t,e,i)},cylinder:hat,plane:function(t){var e=function(t){return(t=qst(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,s=e.widthSegments,a=e.lengthSegments,o=.5*i,l=.5*r,h=[],u=[],c=[],_=new n(-o,0,-l),f=new n(o,0,l),d=Math.sqrt(i*i+r*r);n.set(dat,-o,0,l),n.set(pat,o,0,l),n.set(mat,-o,0,-l);for(var p=0;p<=a;p++)for(var m=0;m<=s;m++){var g=m/s,y=p/a;if(n.lerp(uat,dat,pat,g),n.lerp(cat,dat,mat,y),n.subtract(_at,cat,dat),n.add(fat,uat,_at),h.push(fat.x,fat.y,fat.z),e.includeUV&&u.push(g,y),m<s&&p<a){var v=s+1,b=m+p*v,S=m+(p+1)*v,A=m+1+(p+1)*v,T=m+1+p*v;c.push(b,T,S),c.push(T,A,S)}}var C={positions:h,indices:c,minPos:_,maxPos:f,boundingRadius:d};if(e.includeNormal){var x=(a+1)*(s+1),w=new Array(3*x);C.normals=w;for(var E=0;E<x;++E)w[3*E+0]=0,w[3*E+1]=1,w[3*E+2]=0}return e.includeUV&&(C.uvs=u),C},quad:function(t){var e=qst(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=[],s=[],a=[],o=[],l=new n(-t,-t,-t),h=new n(t,t,t),u=t,c=0;c<=i;++c)for(var _=c*Math.PI/i,f=Math.sin(_),d=-Math.cos(_),p=0;p<=i;++p){var m=2*p*Math.PI/i-Math.PI/2,g=Math.sin(m)*f,y=d,v=Math.cos(m)*f,b=p/i,S=c/i;if(r.push(g*t,y*t,v*t),s.push(g,y,v),a.push(b,S),c<i&&p<i){var A=i+1,T=A*c+p,C=A*(c+1)+p,x=A*(c+1)+p+1,w=A*c+p+1;o.push(T,w,C),o.push(w,x,C)}}return{positions:r,indices:o,normals:s,uvs:a,minPos:l,maxPos:h,boundingRadius:u}},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,s=i.tubularSegments||32,a=i.arc||2*Math.PI,o=[],l=[],h=[],u=[],c=new n(-t-e,-e,-t-e),_=new n(t+e,e,t+e),f=t+e,d=0;d<=r;d++)for(var p=0;p<=s;p++){var m=p/s,g=d/r,y=m*a,v=g*Math.PI*2,b=(t+e*Math.cos(v))*Math.sin(y),S=e*Math.sin(v),A=(t+e*Math.cos(v))*Math.cos(y),T=Math.sin(y)*Math.cos(v),C=Math.sin(v),x=Math.cos(y)*Math.cos(v);if(o.push(b,S,A),l.push(T,C,x),h.push(m,g),p<s&&d<r){var w=s+1,E=w*d+p,B=w*(d+1)+p,R=w*(d+1)+p+1,D=w*d+p+1;u.push(E,D,B),u.push(D,R,B)}}return{positions:o,normals:l,uvs:h,indices:u,minPos:c,maxPos:_,boundingRadius:f}},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 s=i-t-e,a=r.sides||32,o=r.heightSegments||32,l=e/i,h=s/i,u=t/i,c=Math.floor(o*l),_=Math.floor(o*u),f=Math.floor(o*h),d=s+e-i/2,p=e-i/2,m=e-i/2,g=r.arc||2*Math.PI,y=[],v=[],b=[],S=[],A=Math.max(t,e),T=new n(-A,-i/2,-A),C=new n(A,i/2,A),x=i/2,w=0,E=[];return function(){for(var t=0;t<=c;++t)for(var i=t*Math.PI/c/2,r=Math.sin(i),n=-Math.cos(i),s=0;s<=a;++s){var l=2*s*Math.PI/a-Math.PI/2,h=Math.sin(l)*r,u=n,_=Math.cos(l)*r,f=s/a,d=t/o;if(y.push(h*e,u*e+m,_*e),v.push(h,u,_),b.push(f,d),t<c&&s<a){var p=a+1,g=p*t+s,A=p*(t+1)+s,T=p*(t+1)+s+1,C=p*t+s+1;S.push(g,C,A),S.push(C,T,A)}++w}}(),function(){for(var i=(t-e)/s,r=0;r<=f;r++){for(var o=[],u=r/f,c=u*(t-e)+e,_=0;_<=a;++_){var d=_/a,m=u*h+l,A=d*g-g/4,T=Math.sin(A),C=Math.cos(A);y.push(c*T),y.push(u*s+p),y.push(c*C),n.normalize(gat,n.set(yat,T,-i,C)),v.push(gat.x),v.push(gat.y),v.push(gat.z),b.push(d,m),o.push(w),++w}E.push(o)}for(var x=0;x<f;++x)for(var B=0;B<a;++B){var R=E[x][B],D=E[x+1][B],M=E[x+1][B+1],P=E[x][B+1];S.push(R),S.push(P),S.push(D),S.push(P),S.push(M),S.push(D)}}(),function(){for(var e=0;e<=_;++e)for(var i=e*Math.PI/_/2+Math.PI/2,r=Math.sin(i),n=-Math.cos(i),s=0;s<=a;++s){var l=2*s*Math.PI/a-Math.PI/2,h=Math.sin(l)*r,c=n,p=Math.cos(l)*r,m=s/a,g=e/o+(1-u);if(y.push(h*t,c*t+d,p*t),v.push(h,c,p),b.push(m,g),e<_&&s<a){var A=a+1,T=A*e+s+E[f][a]+1,C=A*(e+1)+s+E[f][a]+1,x=A*(e+1)+s+1+E[f][a]+1,w=A*e+s+1+E[f][a]+1;S.push(T,w,C),S.push(w,x,C)}}}(),{positions:y,normals:v,uvs:b,indices:S,minPos:T,maxPos:C,boundingRadius:x}},circle:function(t){var e=function(t){return(t=qst(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:wt.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!==wt.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=wt.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!==wt.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:qst});t("primitives",vat);var bat=new n;function Sat(t){return t.x=Math.abs(t.x),t.y=Math.abs(t.y),t.z=Math.abs(t.z),t}var Aat,Tat,Cat,xat,wat,Eat,Bat,Rat,Dat,Mat,Pat,Iat,Oat,Fat,Lat,kat,Vat,Nat,Gat,zat,Uat,Hat,Xat,Wat,jat,Yat,qat,Kat,Jat,Zat,Qat,$at,tot,eot,iot,rot,not,sot,aot,oot,lot,hot,uot,cot,_ot,fot,dot,pot,mot,got,yot,vot,bot,Sot,Aot,Tot,Cot,xot,wot,Eot,Bot,Rot,Dot,Mot,Pot,Iot,Oot,Fot,Lot,kot,Vot,Not,Got,zot,Uot,Hot,Xot,Wot,jot,Yot,qot,Kot,Jot,Zot,Qot,$ot,tlt,elt,ilt,rlt,nlt,slt,alt,olt,llt,hlt,ult,clt,_lt,flt,dlt,plt,mlt,glt,ylt,vlt,blt,Slt,Alt,Tlt,Clt,xlt,wlt,Elt,Blt,Rlt,Dlt,Mlt,Plt,Ilt,Olt,Flt,Llt,klt,Vlt,Nlt,Glt,zlt,Ult,Hlt,Xlt,Wlt,jlt,Ylt,qlt,Klt,Jlt,Zlt=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:bat,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(S(n,e[h])&&S(s,e[h+1])&&S(a,e[h+2])){l=!1;break}l&&(e.push(n),e.push(s),e.push(a))}}return e},absolute:Sat,cylinder:hat}),Qlt=function(e){return t({BoxCollider:e,BoxColliderComponent:e}),e}((Aat=En("cc.BoxCollider"),Tat=Qn(),Cat=ts(),xat=Wn(n),wat=is(),Aat(Eat=Tat(Eat=Cat(Eat=Jn((Dat=function(t){function e(){var e;return e=t.call(this,Htt.BOX)||this,Mn(e,"_size",Rat,Pn(e)),e}return on(e,t),Ur(e,[{key:"size",get:function(){return this._size},set:function(t){n.strictEquals(this._size,t)||(n.copy(this._size,t),Sat(this._size),this._shape&&this.shape.updateSize())}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((Bat=Dat).prototype,"size",[xat,wat],Object.getOwnPropertyDescriptor(Bat.prototype,"size"),Bat.prototype),Rat=Dn(Bat.prototype,"_size",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(1,1,1)}}),Eat=Bat))||Eat)||Eat)||Eat)||Eat)),$lt=function(e){return t({SphereCollider:e,SphereColliderComponent:e}),e}((Mat=En("cc.SphereCollider"),Pat=Qn(),Iat=ts(),Oat=is(),Mat(Fat=Pat(Fat=Iat(Fat=Jn((Vat=function(t){function e(){var e;return e=t.call(this,Htt.SPHERE)||this,Mn(e,"_radius",kat,Pn(e)),e}return on(e,t),Ur(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.updateRadius())}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((Lat=Vat).prototype,"radius",[Oat],Object.getOwnPropertyDescriptor(Lat.prototype,"radius"),Lat.prototype),kat=Dn(Lat.prototype,"_radius",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),Fat=Lat))||Fat)||Fat)||Fat)||Fat)),tht=function(e){return t({CapsuleCollider:e,CapsuleColliderComponent:e}),e}((Nat=En("cc.CapsuleCollider"),Gat=Qn(),zat=ts(),Uat=is(),Hat=is(),Xat=Wn(ztt),Wat=is(),Nat(jat=Gat(jat=zat(jat=Jn((Zat=function(t){function e(){var e;return e=t.call(this,Htt.CAPSULE)||this,Mn(e,"_radius",qat,Pn(e)),Mn(e,"_cylinderHeight",Kat,Pn(e)),Mn(e,"_direction",Jat,Pn(e)),e}on(e,t);var i=e.prototype;return i._getRadiusScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===ztt.Y_AXIS?Math.abs(N(t.x,t.z)):this._direction===ztt.X_AXIS?Math.abs(N(t.y,t.z)):Math.abs(N(t.x,t.y))},i._getHeightScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===ztt.Y_AXIS?Math.abs(t.y):this._direction===ztt.X_AXIS?Math.abs(t.x):Math.abs(t.z)},Ur(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"cylinderHeight",get:function(){return this._cylinderHeight},set:function(t){this._cylinderHeight!==t&&(this._cylinderHeight=Math.abs(t),this._shape&&this.shape.setCylinderHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){(t=Math.floor(t))<ztt.X_AXIS||t>ztt.Z_AXIS||this._direction!==t&&(this._direction=t,this._shape&&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}(Yst),Dn((Yat=Zat).prototype,"radius",[Uat],Object.getOwnPropertyDescriptor(Yat.prototype,"radius"),Yat.prototype),Dn(Yat.prototype,"cylinderHeight",[Hat],Object.getOwnPropertyDescriptor(Yat.prototype,"cylinderHeight"),Yat.prototype),Dn(Yat.prototype,"direction",[Xat,Wat],Object.getOwnPropertyDescriptor(Yat.prototype,"direction"),Yat.prototype),qat=Dn(Yat.prototype,"_radius",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),Kat=Dn(Yat.prototype,"_cylinderHeight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Jat=Dn(Yat.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ztt.Y_AXIS}}),jat=Yat))||jat)||jat)||jat)||jat)),eht=function(e){return t({CylinderCollider:e,CylinderColliderComponent:e}),e}((Qat=En("cc.CylinderCollider"),$at=Qn(),tot=ts(),eot=is(),iot=is(),rot=Wn(ztt),not=is(),Qat(sot=$at(sot=tot(sot=Jn((uot=function(t){function e(){var e;return e=t.call(this,Htt.CYLINDER)||this,Mn(e,"_radius",oot,Pn(e)),Mn(e,"_height",lot,Pn(e)),Mn(e,"_direction",hot,Pn(e)),e}return on(e,t),Ur(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(this._height=Math.abs(t),this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<ztt.X_AXIS||t>ztt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((aot=uot).prototype,"radius",[eot],Object.getOwnPropertyDescriptor(aot.prototype,"radius"),aot.prototype),Dn(aot.prototype,"height",[iot],Object.getOwnPropertyDescriptor(aot.prototype,"height"),aot.prototype),Dn(aot.prototype,"direction",[rot,not],Object.getOwnPropertyDescriptor(aot.prototype,"direction"),aot.prototype),oot=Dn(aot.prototype,"_radius",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),lot=Dn(aot.prototype,"_height",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),hot=Dn(aot.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ztt.Y_AXIS}}),sot=aot))||sot)||sot)||sot)||sot)),iht=t("ConeCollider",(cot=En("cc.ConeCollider"),_ot=Qn(),fot=ts(),dot=is(),pot=is(),mot=Wn(ztt),got=is(),cot(yot=_ot(yot=fot(yot=Jn((Tot=function(t){function e(){var e;return e=t.call(this,Htt.CONE)||this,Mn(e,"_radius",bot,Pn(e)),Mn(e,"_height",Sot,Pn(e)),Mn(e,"_direction",Aot,Pn(e)),e}return on(e,t),Ur(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&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&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<ztt.X_AXIS||t>ztt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((vot=Tot).prototype,"radius",[dot],Object.getOwnPropertyDescriptor(vot.prototype,"radius"),vot.prototype),Dn(vot.prototype,"height",[pot],Object.getOwnPropertyDescriptor(vot.prototype,"height"),vot.prototype),Dn(vot.prototype,"direction",[mot,got],Object.getOwnPropertyDescriptor(vot.prototype,"direction"),vot.prototype),bot=Dn(vot.prototype,"_radius",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),Sot=Dn(vot.prototype,"_height",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Aot=Dn(vot.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ztt.Y_AXIS}}),yot=vot))||yot)||yot)||yot)||yot)),rht=function(e){return t({MeshCollider:e,MeshColliderComponent:e}),e}((Cot=En("cc.MeshCollider"),xot=Qn(),wot=ts(),Eot=Wn(sh),Bot=is(),Rot=is(),Cot(Dot=xot(Dot=wot(Dot=Jn((Oot=function(t){function e(){var e;return e=t.call(this,Htt.MESH)||this,Mn(e,"_mesh",Pot,Pn(e)),Mn(e,"_convex",Iot,Pn(e)),e}return on(e,t),Ur(e,[{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,this._shape&&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}(Yst),Dn((Mot=Oot).prototype,"mesh",[Eot,Bot],Object.getOwnPropertyDescriptor(Mot.prototype,"mesh"),Mot.prototype),Dn(Mot.prototype,"convex",[Un,Rot],Object.getOwnPropertyDescriptor(Mot.prototype,"convex"),Mot.prototype),Pot=Dn(Mot.prototype,"_mesh",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Iot=Dn(Mot.prototype,"_convex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dot=Mot))||Dot)||Dot)||Dot)||Dot)),nht=t("ConstantForce",(Fot=En("cc.ConstantForce"),Lot=Qn(),kot=us(jst),Vot=ts(),Not=es(),Got=is(),zot=es(),Uot=is(),Hot=es(),Xot=is(),Wot=es(),jot=is(),Fot(Yot=Lot(Yot=kot(Yot=Vot(Yot=Kn(Yot=Jn(($ot=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,Mn(e,"_force",Kot,Pn(e)),Mn(e,"_localForce",Jot,Pn(e)),Mn(e,"_torque",Zot,Pn(e)),Mn(e,"_localTorque",Qot,Pn(e)),e._mask=0,e}on(e,t);var i=e.prototype;return i.onLoad=function(){this._rigidBody=this.node.getComponent(jst),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(n.ZERO)?this._mask&=~e:this._mask|=e},Ur(e,[{key:"force",get:function(){return this._force},set:function(t){n.copy(this._force,t),this._maskUpdate(this._force,1)}},{key:"localForce",get:function(){return this._localForce},set:function(t){n.copy(this._localForce,t),this._maskUpdate(this.localForce,2)}},{key:"torque",get:function(){return this._torque},set:function(t){n.copy(this._torque,t),this._maskUpdate(this._torque,4)}},{key:"localTorque",get:function(){return this._localTorque},set:function(t){n.copy(this._localTorque,t),this._maskUpdate(this._localTorque,8)}}]),e}(ns),Kot=Dn((qot=$ot).prototype,"_force",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Jot=Dn(qot.prototype,"_localForce",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Zot=Dn(qot.prototype,"_torque",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Qot=Dn(qot.prototype,"_localTorque",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Dn(qot.prototype,"force",[Not,Got],Object.getOwnPropertyDescriptor(qot.prototype,"force"),qot.prototype),Dn(qot.prototype,"localForce",[zot,Uot],Object.getOwnPropertyDescriptor(qot.prototype,"localForce"),qot.prototype),Dn(qot.prototype,"torque",[Hot,Xot],Object.getOwnPropertyDescriptor(qot.prototype,"torque"),qot.prototype),Dn(qot.prototype,"localTorque",[Wot,jot],Object.getOwnPropertyDescriptor(qot.prototype,"localTorque"),qot.prototype),Yot=qot))||Yot)||Yot)||Yot)||Yot)||Yot)||Yot)),sht=(t("TERRAIN_MAX_LEVELS",4),t("TERRAIN_MAX_BLEND_LAYERS",4)),aht=t("TERRAIN_MAX_LAYER_COUNT",256),oht=t("TERRAIN_BLOCK_TILE_COMPLEXITY",32),lht=t("TERRAIN_BLOCK_VERTEX_COMPLEXITY",33),hht=t("TERRAIN_BLOCK_VERTEX_SIZE",8),uht=t("TERRAIN_HEIGHT_BASE",32768),cht=t("TERRAIN_HEIGHT_FACTORY",1/512),_ht=t("TERRAIN_HEIGHT_FMIN",-uht*cht),fht=t("TERRAIN_HEIGHT_FMAX",(65535-uht)*cht),dht=(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)),pht=t("TERRAIN_DATA_VERSION2",16842754),mht=t("TERRAIN_DATA_VERSION3",16842755),ght=t("TERRAIN_DATA_VERSION4",16842756),yht=t("TERRAIN_DATA_VERSION5",16842757),vht=t("TERRAIN_DATA_VERSION_DEFAULT",16843025),bht=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}(),Sht=t("TerrainLayerInfo",En("cc.TerrainLayerInfo")((ilt=Dn((elt=function(){Mn(this,"slot",ilt,this),Mn(this,"tileSize",rlt,this),Mn(this,"detailMap",nlt,this),Mn(this,"normalMap",slt,this),Mn(this,"roughness",alt,this),Mn(this,"metallic",olt,this)}).prototype,"slot",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),rlt=Dn(elt.prototype,"tileSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),nlt=Dn(elt.prototype,"detailMap",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),slt=Dn(elt.prototype,"normalMap",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),alt=Dn(elt.prototype,"roughness",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),olt=Dn(elt.prototype,"metallic",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),tlt=elt))||tlt),Aht=t("TerrainLayerBinaryInfo",En("cc.TerrainLayerBinaryInfo")(llt=function(){this.slot=0,this.tileSize=1,this.roughness=1,this.metallic=0,this.detailMapId="",this.normalMapId=""})||llt),Tht=t("TerrainAsset",En("cc.TerrainAsset")((_lt=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=[],Mn(e,"_layerInfos",clt,Pn(e)),e}on(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]*oht+1;return(this._heights[e*i+t]-uht)*cht},i.getVertexCountI=function(){return this._blockCount.length<1?0:this._blockCount[0]*oht+1},i.getVertexCountJ=function(){return this._blockCount.length<2?0:this._blockCount[1]*oht+1},i._setNativeData=function(t){this._data=t},i._loadNativeData=function(t){if(!t||0===t.length)return!1;var e=new bht;if(e.assign(t),this._version=e.readInt(),this._version===vht)return!0;if(this._version!==dht&&this._version!==pht&&this._version!==mht&&this._version!==ght&&this._version!==yht)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>=pht){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>=mht){var l=e.readInt();this._layerBinaryInfos=new Array(l);for(var h=0;h<this._layerBinaryInfos.length;++h)this._layerBinaryInfos[h]=new Aht,this._layerBinaryInfos[h].slot=e.readInt(),this._layerBinaryInfos[h].tileSize=e.readFloat(),this._layerBinaryInfos[h].detailMapId=e.readString(),this._version>=ght&&(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 bht;t.writeInt32(yht),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 Aht;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 bht;return t.writeInt32(vht),t.buffer},Ur(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)}},{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}(Qr),clt=Dn((ult=_lt).prototype,"_layerInfos",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),hlt=ult))||hlt),Cht=t("TerrainCollider",(flt=En("cc.TerrainCollider"),dlt=Qn(),plt=ts(),mlt=Wn(Tht),glt=is(),flt(ylt=dlt(ylt=plt(ylt=Jn((Slt=function(t){function e(){var e;return e=t.call(this,Htt.TERRAIN)||this,Mn(e,"_terrain",blt,Pn(e)),e}return on(e,t),Ur(e,[{key:"terrain",get:function(){return this._terrain},set:function(t){this._terrain=t,this._shape&&this.shape.setTerrain(this._terrain)}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((vlt=Slt).prototype,"terrain",[mlt,glt],Object.getOwnPropertyDescriptor(vlt.prototype,"terrain"),vlt.prototype),blt=Dn(vlt.prototype,"_terrain",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ylt=vlt))||ylt)||ylt)||ylt)||ylt)),xht=t("SimplexCollider",(Alt=En("cc.SimplexCollider"),Tlt=Qn(),Clt=ts(),xlt=Wn(Utt),wlt=is(),Elt=is(),Blt=cs(),Rlt=is(),Dlt=cs(),Mlt=is(),Plt=cs(),Ilt=is(),Alt(Olt=Tlt(Olt=Clt(Olt=Jn((Nlt=Vlt=function(t){function e(){var e;return e=t.call(this,Htt.SIMPLEX)||this,Mn(e,"_shapeType",Llt,Pn(e)),Mn(e,"_vertices",klt,Pn(e)),e}return on(e,t),e.prototype.updateVertices=function(){this._shape&&this.shape.setVertices(this._vertices)},Ur(e,[{key:"shapeType",get:function(){return this._shapeType},set:function(t){this._shapeType=t,this._shape&&this.shape.setShapeType(t)}},{key:"vertex0",get:function(){return this._vertices[0]},set:function(t){n.copy(this._vertices[0],t),this.updateVertices()}},{key:"vertex1",get:function(){return this._vertices[1]},set:function(t){n.copy(this._vertices[1],t),this.updateVertices()}},{key:"vertex2",get:function(){return this._vertices[2]},set:function(t){n.copy(this._vertices[2],t),this.updateVertices()}},{key:"vertex3",get:function(){return this._vertices[3]},set:function(t){n.copy(this._vertices[3],t),this.updateVertices()}},{key:"shape",get:function(){return this._shape}},{key:"vertices",get:function(){return this._vertices}}]),e}(Yst),Vlt.ESimplexType=Utt,Dn((Flt=Nlt).prototype,"shapeType",[xlt,wlt],Object.getOwnPropertyDescriptor(Flt.prototype,"shapeType"),Flt.prototype),Dn(Flt.prototype,"vertex0",[Un,Elt],Object.getOwnPropertyDescriptor(Flt.prototype,"vertex0"),Flt.prototype),Dn(Flt.prototype,"vertex1",[Blt,Rlt],Object.getOwnPropertyDescriptor(Flt.prototype,"vertex1"),Flt.prototype),Dn(Flt.prototype,"vertex2",[Dlt,Mlt],Object.getOwnPropertyDescriptor(Flt.prototype,"vertex2"),Flt.prototype),Dn(Flt.prototype,"vertex3",[Plt,Ilt],Object.getOwnPropertyDescriptor(Flt.prototype,"vertex3"),Flt.prototype),Llt=Dn(Flt.prototype,"_shapeType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Utt.TETRAHEDRON}}),klt=Dn(Flt.prototype,"_vertices",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[new n(0,0,0),new n(0,0,1),new n(1,0,0),new n(0,1,0)]}}),Olt=Flt))||Olt)||Olt)||Olt)||Olt));xht||(xht=t("SimplexCollider",{}));var wht,Eht,Bht,Rht,Dht,Mht,Pht,Iht,Oht,Fht,Lht,kht,Vht,Nht,Ght,zht,Uht,Hht,Xht,Wht,jht,Yht,qht,Kht,Jht,Zht,Qht,$ht,tut,eut=t("PlaneCollider",(Glt=En("cc.PlaneCollider"),zlt=Qn(),Ult=ts(),Hlt=Wn(n),Xlt=is(),Wlt=is(),Glt(jlt=zlt(jlt=Ult(jlt=Jn((Jlt=function(t){function e(){var e;return e=t.call(this,Htt.PLANE)||this,Mn(e,"_normal",qlt,Pn(e)),Mn(e,"_constant",Klt,Pn(e)),e}return on(e,t),Ur(e,[{key:"normal",get:function(){return this._normal},set:function(t){n.strictEquals(this._normal,t)||(n.copy(this._normal,t),this._shape&&this.shape.setNormal(this._normal))}},{key:"constant",get:function(){return this._constant},set:function(t){this._constant!==t&&(this._constant=t,this._shape&&this.shape.setConstant(this._constant))}},{key:"shape",get:function(){return this._shape}}]),e}(Yst),Dn((Ylt=Jlt).prototype,"normal",[Hlt,Xlt],Object.getOwnPropertyDescriptor(Ylt.prototype,"normal"),Ylt.prototype),Dn(Ylt.prototype,"constant",[Un,Wlt],Object.getOwnPropertyDescriptor(Ylt.prototype,"constant"),Ylt.prototype),qlt=Dn(Ylt.prototype,"_normal",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n(0,1,0)}}),Klt=Dn(Ylt.prototype,"_constant",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),jlt=Ylt))||jlt)||jlt)||jlt)||jlt)),iut=t("Constraint",(wht=En("cc.Constraint"),Eht=us(jst),Bht=Wn(jst),Rht=es(),Dht=Wn(jst),Mht=es(),Pht=es(),Iht=Wn(jst),wht(Oht=Eht((Nht=Vht=function(t){function e(e){var i;return(i=t.call(this)||this).TYPE=void 0,Mn(i,"_enableCollision",Lht,Pn(i)),Mn(i,"_connectedBody",kht,Pn(i)),i._constraint=null,i.TYPE=e,i}on(e,t);var i=e.prototype;return i.onLoad=function(){rnt.runInEditor&&(this._constraint=function(t){return cnt.INITED||(cnt.INITED=!0,cnt[Xtt.POINT_TO_POINT]=function(){return ant(rnt.wrapper.PointToPointConstraint,int.PointToPointConstraint)?_nt:new rnt.wrapper.PointToPointConstraint},cnt[Xtt.HINGE]=function(){return ant(rnt.wrapper.HingeConstraint,int.HingeConstraint)?_nt:new rnt.wrapper.HingeConstraint},cnt[Xtt.CONE_TWIST]=function(){return ant(rnt.wrapper.ConeTwistConstraint,int.ConeTwistConstraint)?_nt:new rnt.wrapper.ConeTwistConstraint}),cnt[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()},Ur(e,[{key:"attachedBody",get:function(){return this.getComponent(jst)}},{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}(Ha(ns)),Vht.Type=Xtt,Dn((Fht=Nht).prototype,"attachedBody",[Bht,wo,Rht],Object.getOwnPropertyDescriptor(Fht.prototype,"attachedBody"),Fht.prototype),Dn(Fht.prototype,"connectedBody",[Dht,Mht],Object.getOwnPropertyDescriptor(Fht.prototype,"connectedBody"),Fht.prototype),Dn(Fht.prototype,"enableCollision",[Pht],Object.getOwnPropertyDescriptor(Fht.prototype,"enableCollision"),Fht.prototype),Lht=Dn(Fht.prototype,"_enableCollision",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),kht=Dn(Fht.prototype,"_connectedBody",[Iht],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Oht=Fht))||Oht)||Oht));iut||(iut=t("Constraint",{}));var rut,nut,sut,aut,out,lut,hut,uut,cut,_ut,fut=t("HingeConstraint",(Ght=En("cc.HingeConstraint"),zht=Qn(),Uht=ts(),Hht=Wn(n),Xht=Wn(n),Wht=Wn(n),jht=oa("axisA"),Yht=oa("pivotA"),qht=oa("pivotB"),Ght(Kht=zht(Kht=Uht((tut=function(t){function e(){var e;return e=t.call(this,Xtt.HINGE)||this,Mn(e,"_axis",Zht,Pn(e)),Mn(e,"_pivotA",Qht,Pn(e)),Mn(e,"_pivotB",$ht,Pn(e)),e}return on(e,t),Ur(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){n.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){n.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"axis",get:function(){return this._axis},set:function(t){n.copy(this._axis,t),this.constraint.setAxis(this._axis)}},{key:"constraint",get:function(){return this._constraint}}]),e}(iut),Dn((Jht=tut).prototype,"pivotA",[Hht],Object.getOwnPropertyDescriptor(Jht.prototype,"pivotA"),Jht.prototype),Dn(Jht.prototype,"pivotB",[Xht],Object.getOwnPropertyDescriptor(Jht.prototype,"pivotB"),Jht.prototype),Dn(Jht.prototype,"axis",[Wht],Object.getOwnPropertyDescriptor(Jht.prototype,"axis"),Jht.prototype),Zht=Dn(Jht.prototype,"_axis",[On,jht],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Qht=Dn(Jht.prototype,"_pivotA",[On,Yht],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),$ht=Dn(Jht.prototype,"_pivotB",[On,qht],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),Kht=Jht))||Kht)||Kht)||Kht)),dut=t("PointToPointConstraint",(rut=En("cc.PointToPointConstraint"),nut=Qn(),sut=ts(),aut=Wn(n),out=Wn(n),rut(lut=nut(lut=sut((_ut=function(t){function e(){var e;return e=t.call(this,Xtt.POINT_TO_POINT)||this,Mn(e,"_pivotA",uut,Pn(e)),Mn(e,"_pivotB",cut,Pn(e)),e}return on(e,t),Ur(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){n.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){n.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"constraint",get:function(){return this._constraint}}]),e}(iut),Dn((hut=_ut).prototype,"pivotA",[aut],Object.getOwnPropertyDescriptor(hut.prototype,"pivotA"),hut.prototype),Dn(hut.prototype,"pivotB",[out],Object.getOwnPropertyDescriptor(hut.prototype,"pivotB"),hut.prototype),uut=Dn(hut.prototype,"_pivotA",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),cut=Dn(hut.prototype,"_pivotB",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new n}}),lut=hut))||lut)||lut)||lut));Er.PhysicsSystem=Tst,Er.PhysicsMaterial=Mnt,Er.PhysicsRayResult=Pnt,Er.ConstantForce=nht;var put,mut,gut,yut,vut,but=Object.freeze({__proto__:null,PhysicsSystem:Tst,PhysicsRayResult:Pnt,get Collider(){return Yst},BoxCollider:Qlt,SphereCollider:$lt,CapsuleCollider:tht,MeshCollider:rht,CylinderCollider:eht,ConeCollider:iht,TerrainCollider:Cht,get SimplexCollider(){return xht},PlaneCollider:eut,get Constraint(){return iut},HingeConstraint:fut,PointToPointConstraint:dut,get RigidBody(){return jst},PhysicsMaterial:Mnt,ConstantForce:nht,selector:rnt,utils:Zlt,get ERigidBodyType(){return Gtt},get EAxisDirection(){return ztt},get ESimplexType(){return Utt},get EColliderType(){return Htt},get EConstraintType(){return Xtt},get PhysicsGroup(){return Wtt}});t("physics",but),wr(Tst,"PhysicsSystem",[{name:"ins",newName:"instance"},{name:"PHYSICS_AMMO",newName:"PHYSICS_BULLET"}]),wr(Tst.prototype,"PhysicsSystem.prototype",[{name:"deltaTime",newName:"fixedTimeStep"},{name:"maxSubStep",newName:"maxSubSteps"}]),Dr(Tst.prototype,"PhysicsSystem.prototype",[{name:"useFixedTime"},{name:"useCollisionMatrix"},{name:"updateCollisionMatrix"},{name:"resetCollisionMatrix"},{name:"isCollisionGroup"},{name:"setCollisionGroup"}]),wr(Yst.prototype,"Collider.prototype",[{name:"attachedRigidbody",newName:"attachedRigidBody"},{name:"TYPE",newName:"type"}]),wr(Yst,"Collider",[{name:"EColliderType",newName:"Type"},{name:"EAxisDirection",newName:"Axis"}]),wr(iut,"Constraint",[{name:"EConstraintType",newName:"Type"}]),wr(Qlt.prototype,"BoxCollider.prototype",[{name:"boxShape",newName:"shape"}]),wr($lt.prototype,"SphereCollider.prototype",[{name:"sphereShape",newName:"shape"}]),wr(tht.prototype,"CapsuleCollider.prototype",[{name:"capsuleShape",newName:"shape"}]),wr(jst.prototype,"RigidBody.prototype",[{name:"rigidBody",newName:"body"}]),wr(jst,"RigidBody",[{name:"ERigidBodyType",newName:"Type"}]),Dr(jst.prototype,"RigidBody.prototype",[{name:"fixedRotation"}]),Er.RigidBodyComponent=jst,pn.setClassAlias(jst,"cc.RigidBodyComponent"),Er.ColliderComponent=Yst,pn.setClassAlias(Yst,"cc.ColliderComponent"),Er.BoxColliderComponent=Qlt,pn.setClassAlias(Qlt,"cc.BoxColliderComponent"),Er.SphereColliderComponent=$lt,pn.setClassAlias($lt,"cc.SphereColliderComponent"),pn.setClassAlias(tht,"cc.CapsuleColliderComponent"),pn.setClassAlias(rht,"cc.MeshColliderComponent"),pn.setClassAlias(eht,"cc.CylinderColliderComponent"),Er.PhysicMaterial=Mnt,pn.setClassAlias(Mnt,"cc.PhysicMaterial"),Er.physics=but,function(t){t[t.BODY_RE_ADD=1]="BODY_RE_ADD",t[t.GHOST_RE_ADD=2]="GHOST_RE_ADD"}(put||(put={})),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"}(mut||(mut={})),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"}(gut||(gut={})),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"}(yut||(yut={})),function(t){t[t.BT_DISABLE_WORLD_GRAVITY=1]="BT_DISABLE_WORLD_GRAVITY",t[t.BT_ENABLE_GYROPSCOPIC_FORCE=2]="BT_ENABLE_GYROPSCOPIC_FORCE"}(vut||(vut={}));var Sut=Cnt,Aut=xnt,Tut=function(){var t=e.prototype;function e(){this.id=void 0,this._isEnabled=!1,this._isUsingCCD=!1,this.id=e.idCounter++}return t.setMass=function(t){this._rigidBody.isDynamic&&(xo.RigidBody_setMass(this.impl,t),this._wakeUpIfSleep(),this._sharedBody.dirty|=put.BODY_RE_ADD)},t.setType=function(t){this._sharedBody.setType(t)},t.setLinearDamping=function(){xo.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.setAngularDamping=function(){xo.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.useGravity=function(t){if(this._rigidBody.isDynamic){var e=xo.RigidBody_getFlags(this.impl);t?e&=~vut.BT_DISABLE_WORLD_GRAVITY:(xo.RigidBody_setGravity(this.impl,Ent(pnt.instance.BT_V3_0,n.ZERO)),e|=vut.BT_DISABLE_WORLD_GRAVITY),xo.RigidBody_setFlags(this.impl,e),this._wakeUpIfSleep(),this._sharedBody.dirty|=put.BODY_RE_ADD}},t.useCCD=function(t){xo.CollisionObject_setCcdMotionThreshold(this.impl,t?.01:0),xo.CollisionObject_setCcdSweptSphereRadius(this.impl,t?.1:0),this._isUsingCCD=t},t.isUsingCCD=function(){return this._isUsingCCD},t.setLinearFactor=function(t){xo.RigidBody_setLinearFactor(this.impl,Ent(pnt.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAngularFactor=function(t){xo.RigidBody_setAngularFactor(this.impl,Ent(pnt.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAllowSleep=function(t){this._rigidBody.isDynamic&&(t?xo.CollisionObject_forceActivationState(this.impl,yut.ACTIVE_TAG):xo.CollisionObject_forceActivationState(this.impl,yut.DISABLE_DEACTIVATION),this._wakeUpIfSleep())},t.clearState=function(){xo.RigidBody_clearState(this.impl)},t.clearVelocity=function(){this.setLinearVelocity(n.ZERO),this.setAngularVelocity(n.ZERO)},t.clearForces=function(){xo.RigidBody_clearForces(this.impl)},t.initialize=function(t){this._rigidBody=t,this._sharedBody=Tst.instance.physicsWorld.getSharedBody(this._rigidBody.node,this),this._sharedBody.reference=!0},t.onEnable=function(){this._isEnabled=!0,this.setMass(this._rigidBody.mass),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),xo.CollisionObject_activate(this.impl,t)},t.sleep=function(){return xo.RigidBody_wantsSleeping(this.impl)},t.setSleepThreshold=function(t){this._wakeUpIfSleep(),xo.RigidBody_setSleepingThresholds(this.impl,t,t)},t.getSleepThreshold=function(){return xo.RigidBody_getLinearSleepingThreshold(this.impl)},t.getLinearVelocity=function(t){return Bnt(t,xo.RigidBody_getLinearVelocity(this.impl))},t.setLinearVelocity=function(t){this._wakeUpIfSleep(),Ent(xo.RigidBody_getLinearVelocity(this.impl),t)},t.getAngularVelocity=function(t){return Bnt(t,xo.RigidBody_getAngularVelocity(this.impl))},t.setAngularVelocity=function(t){this._wakeUpIfSleep(),Ent(xo.RigidBody_getAngularVelocity(this.impl),t)},t.applyLocalForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,r=n.transformQuat(Sut,t,i),s=e?n.transformQuat(Aut,e,i):n.ZERO;xo.RigidBody_applyForce(this.impl,Ent(pnt.instance.BT_V3_0,r),Ent(pnt.instance.BT_V3_1,s))},t.applyLocalTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),n.transformQuat(Sut,t,this._sharedBody.node.worldRotation),xo.RigidBody_applyTorque(this.impl,Ent(pnt.instance.BT_V3_0,Sut))},t.applyLocalImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,r=n.transformQuat(Sut,t,i),s=e?n.transformQuat(Aut,e,i):n.ZERO;xo.RigidBody_applyImpulse(this.impl,Ent(pnt.instance.BT_V3_0,r),Ent(pnt.instance.BT_V3_1,s))},t.applyForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||n.ZERO;xo.RigidBody_applyForce(this.impl,Ent(pnt.instance.BT_V3_0,t),Ent(pnt.instance.BT_V3_1,i))},t.applyTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),xo.RigidBody_applyTorque(this.impl,Ent(pnt.instance.BT_V3_0,t))},t.applyImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||n.ZERO;xo.RigidBody_applyImpulse(this.impl,Ent(pnt.instance.BT_V3_0,t),Ent(pnt.instance.BT_V3_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||xo.CollisionObject_activate(this.impl,!0)},Ur(e,[{key:"isAwake",get:function(){var t=xo.CollisionObject_getActivationState(this.impl);return t===yut.ACTIVE_TAG||t===yut.DISABLE_DEACTIVATION}},{key:"isSleepy",get:function(){return xo.CollisionObject_getActivationState(this.impl)===yut.WANTS_DEACTIVATION}},{key:"isSleeping",get:function(){return xo.CollisionObject_getActivationState(this.impl)===yut.ISLAND_SLEEPING}},{key:"impl",get:function(){return this._sharedBody.body}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"sharedBody",get:function(){return this._sharedBody}},{key:"isEnabled",get:function(){return this._isEnabled}}]),e}();Tut.idCounter=0;var Cut=Cnt,xut=wnt,wut=0,Eut=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=Tst.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=Wtt.DEFAULT,o=Tst.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=Tst.instance.collisionMatrix[l];n._collisionFilterGroup=l,n._collisionFilterMask=h}return n};var e=t.prototype;return e._instantiateBodyStruct=function(){if(!this._bodyStruct){var t=0;this._wrappedBody&&this._wrappedBody.rigidBody.enabled&&this._wrappedBody.rigidBody.isDynamic&&(t=this._wrappedBody.rigidBody.mass);var e=pnt.instance.BT_TRANSFORM_0,i=pnt.instance.BT_QUAT_0;Ent(xo.Transform_getOrigin(e),this.node.worldPosition),Rnt(i,this.node.worldRotation),xo.Transform_setRotation(e,i);var r=xo.ccMotionState_new(this.id,e),n=xo.RigidBody_new(t,r),s=Tst.instance.sleepThreshold;xo.RigidBody_setSleepingThresholds(n,s,s),this._bodyStruct={id:wut++,body:n,motionState:r,compound:xo.ccCompoundShape_new(),wrappedShapes:[],useCompound:!1},pnt.setWrapper(this.id,xo.BODY_CACHE_NAME,this),this._ghostStruct&&xo.CollisionObject_setIgnoreCollisionCheck(this.ghost,this.body,!0),this._wrappedBody&&this.setBodyType(this._wrappedBody.rigidBody.type)}},e._instantiateGhostStruct=function(){if(!this._ghostStruct){var t=xo.CollisionObject_new(),e=xo.ccCompoundShape_new();xo.CollisionObject_setCollisionShape(t,e),xo.CollisionObject_setCollisionFlags(t,mut.CF_STATIC_OBJECT|mut.CF_NO_CONTACT_RESPONSE),this._ghostStruct={id:wut++,ghost:t,compound:e,wrappedShapes:[]},this._bodyStruct&&xo.CollisionObject_setIgnoreCollisionCheck(this.body,this.ghost,!0),this._wrappedBody&&this.setGhostType(this._wrappedBody.rigidBody.type)}},e.setType=function(t){this.setBodyType(t),this.setGhostType(t)},e.setBodyType=function(t){if(this._bodyStruct&&this._wrappedBody){var e=this._bodyStruct.body,i=this._wrappedBody,r=i.rigidBody,n=xo.CollisionObject_getCollisionFlags(e),s=pnt.instance.BT_V3_0;switch(t){case Gtt.DYNAMIC:n&=~mut.CF_KINEMATIC_OBJECT,n&=~mut.CF_STATIC_OBJECT,xo.CollisionObject_setCollisionFlags(e,n),i.setMass(r.mass),i.useGravity(r.useGravity),i.setAllowSleep(r.allowSleep);break;case Gtt.KINEMATIC:xo.Vec3_set(s,0,0,0),xo.RigidBody_setMassProps(e,0,s),n|=mut.CF_KINEMATIC_OBJECT,n&=~mut.CF_STATIC_OBJECT,xo.CollisionObject_setCollisionFlags(e,n),xo.CollisionObject_forceActivationState(e,yut.DISABLE_DEACTIVATION);break;case Gtt.STATIC:default:xo.Vec3_set(s,0,0,0),xo.RigidBody_setMassProps(e,0,s),n|=mut.CF_STATIC_OBJECT,n&=~mut.CF_KINEMATIC_OBJECT,xo.CollisionObject_setCollisionFlags(e,n),xo.CollisionObject_forceActivationState(e,yut.ISLAND_SLEEPING)}this.dirty|=put.BODY_RE_ADD}},e.setGhostType=function(t){if(this._ghostStruct){var e=this._ghostStruct.ghost,i=xo.CollisionObject_getCollisionFlags(e);switch(t){case Gtt.DYNAMIC:case Gtt.KINEMATIC:i&=~mut.CF_STATIC_OBJECT,i|=mut.CF_KINEMATIC_OBJECT,xo.CollisionObject_setCollisionFlags(e,i),xo.CollisionObject_forceActivationState(e,yut.DISABLE_DEACTIVATION);break;case Gtt.STATIC:default:i&=~mut.CF_KINEMATIC_OBJECT,i|=mut.CF_STATIC_OBJECT,xo.CollisionObject_setCollisionFlags(e,i),xo.CollisionObject_forceActivationState(e,yut.ISLAND_SLEEPING)}this.dirty|=put.GHOST_RE_ADD}},e.addShape=function(t,e){function i(t,e){xo.CollisionObject_setCollisionShape(t.body,e),t.dirty|=put.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.compound)}else i(this,t.impl)}this.bodyEnabled=!0}},e.removeShape=function(t,e){if(e){var i=this.ghostStruct.wrappedShapes.indexOf(t);i>=0&&(qa(this.ghostStruct.wrappedShapes,i),t.setCompound(0),this.ghostEnabled=!1)}else{var r=this.bodyStruct.wrappedShapes.indexOf(t);r>=0&&(this.bodyStruct.useCompound?t.setCompound(0):xo.CollisionObject_setCollisionShape(this.body,xo.EmptyShape_static()),xo.CollisionObject_activate(this.body,!0),this.dirty|=put.BODY_RE_ADD,qa(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&&qa(this.wrappedJoints1,i)}else{var r=this.wrappedJoints0.indexOf(t);r>=0&&qa(this.wrappedJoints0,r)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&put.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&put.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=pnt.instance.BT_QUAT_0,e=xo.CollisionObject_getWorldTransform(this.body);if(Rnt(t,this.node.worldRotation),Ent(xo.Transform_getOrigin(e),this.node.worldPosition),xo.Transform_setRotation(e,t),this.node.hasChangedFlags&Ws.SCALE&&this.syncBodyScale(),xo.CollisionObject_isKinematicObject(this.body)){var i=xo.RigidBody_getMotionState(this.body);i&&xo.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&xo.CollisionObject_activate(this.body)}},e.syncPhysicsToScene=function(){xo.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=pnt.instance.BT_QUAT_0,e=pnt.instance.BT_TRANSFORM_0;if(xo.MotionState_getWorldTransform(xo.RigidBody_getMotionState(this.body),e),xo.Transform_getRotation(e,t),this.node.worldRotation=Dnt(xut,t),this.node.worldPosition=Bnt(Cut,xo.Transform_getOrigin(e)),this._ghostStruct){var i=xo.CollisionObject_getWorldTransform(this.ghost);Ent(xo.Transform_getOrigin(i),this.node.worldPosition),Rnt(t,this.node.worldRotation),xo.Transform_setRotation(i,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=pnt.instance.BT_QUAT_0,e=xo.CollisionObject_getWorldTransform(this.ghost);Ent(xo.Transform_getOrigin(e),this.node.worldPosition),Rnt(t,this.node.worldRotation),xo.Transform_setRotation(e,t),this.node.hasChangedFlags&Ws.SCALE&&this.syncGhostScale(),xo.CollisionObject_activate(this.ghost)}},e.syncInitialBody=function(){var t=pnt.instance.BT_QUAT_0,e=xo.CollisionObject_getWorldTransform(this.body);Ent(xo.Transform_getOrigin(e),this.node.worldPosition),Rnt(t,this.node.worldRotation),xo.Transform_setRotation(e,t),this.syncBodyScale(),xo.CollisionObject_activate(this.body)},e.syncInitialGhost=function(){var t=pnt.instance.BT_QUAT_0,e=xo.CollisionObject_getWorldTransform(this.ghost);Ent(xo.Transform_getOrigin(e),this.node.worldPosition),Rnt(t,this.node.worldRotation),xo.Transform_setRotation(e,t),this.syncGhostScale(),xo.CollisionObject_activate(this.body)},e.syncBodyScale=function(){for(var t=0;t<this.bodyStruct.wrappedShapes.length;t++)this.bodyStruct.wrappedShapes[t].updateScale();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].updateScale()},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;pnt.delWrapper(e.body,xo.BODY_CACHE_NAME),xo.MotionState_del(e.motionState),xo.CollisionShape_del(e.compound),xo.CollisionObject_del(e.body),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;xo.CollisionShape_del(i.compound),xo.CollisionObject_del(i.ghost),this._ghostStruct=null}},e.isBodySleeping=function(){return xo.CollisionObject_getActivationState(this.body)===yut.ISLAND_SLEEPING},Ur(t,[{key:"wrappedBody",get:function(){return this._wrappedBody}},{key:"bodyCompoundShape",get:function(){return this.bodyStruct.compound}},{key:"ghostCompoundShape",get:function(){return this.ghostStruct.compound}},{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|=put.BODY_RE_ADD,this.dirty|=put.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=put.BODY_RE_ADD,this.dirty|=put.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){if(t){if(this.bodyIndex<0){if(0===this.bodyStruct.wrappedShapes.length){if(!this.wrappedBody)return;if(!this.wrappedBody.rigidBody.isDynamic)return}this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this),this.syncInitialBody()}}else 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)&&(xo.RigidBody_clearState(this.body),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}();Eut.idCounter=0,Eut.sharedBodesMap=new Map;var But=Cnt,Rut={},Dut=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=xo.Quat_new(0,0,0,1),this.transform=xo.Transform_new()}var e=t.prototype;return e.updateEventListener=function(){this._sharedBody.wrappedWorld.updateNeedEmitEvents(this.collider.needCollisionEvent||this.collider.needTriggerEvent)},e.setMaterial=function(t){if(!this._isTrigger&&this._isEnabled&&t)if(this._compound){Rut[t._uuid]||(Rut[t._uuid]=xo.ccMaterial_new());var e=Rut[t._uuid];xo.ccMaterial_set(e,t.restitution,t.friction,t.rollingFriction,t.spinningFriction),xo.CollisionShape_setMaterial(this._impl,e)}else xo.CollisionObject_setMaterial(this._sharedBody.body,t.restitution,t.friction,t.rollingFriction,t.spinningFriction)},e.setCenter=function(t){n.copy(But,t),But.multiply(this._collider.node.worldScale),Ent(xo.Transform_getOrigin(this.transform),But),this.updateCompoundTransform()},e.setAsTrigger=function(t){this._isTrigger!==t&&(this._isEnabled&&(this._sharedBody.removeShape(this,!t),this._sharedBody.addShape(this,t)),this._isTrigger=t)},e.getAABB=function(t){var e=pnt.instance.BT_TRANSFORM_0;xo.Transform_setIdentity(e),xo.Transform_setRotation(e,Rnt(pnt.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=pnt.instance.BT_V3_0,r=pnt.instance.BT_V3_1;xo.CollisionShape_getAabb(this._impl,e,i,r),t.halfExtents.x=(xo.Vec3_x(r)-xo.Vec3_x(i))/2,t.halfExtents.y=(xo.Vec3_y(r)-xo.Vec3_y(i))/2,t.halfExtents.z=(xo.Vec3_z(r)-xo.Vec3_z(i))/2,n.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=xo.CollisionShape_getLocalBoundingSphere(this._impl),n.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=Tst.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){pnt.isNotEmptyShape(this._impl)&&(xo.CollisionShape_setUserPointer(this._impl,this._impl),pnt.setWrapper(this._impl,t.TYPE,this))},e.onLoad=function(){this.setCenter(this._collider.center),this.setAsTrigger(this._collider.isTrigger)},e.onEnable=function(){this._isEnabled=!0,this._sharedBody.addShape(this,this._isTrigger),this.setMaterial(this.collider.sharedMaterial)},e.onDisable=function(){this._isEnabled=!1,this._sharedBody.removeShape(this,this._isTrigger)},e.onDestroy=function(){this._sharedBody.reference=!1,this._collider=null,xo.Quat_del(this.quat),xo.Transform_del(this.transform),this._compound&&xo.CollisionShape_del(this._compound),pnt.isNotEmptyShape(this._impl)&&(xo.CollisionShape_del(this._impl),pnt.delWrapper(this._impl,t.TYPE))},e.updateByReAdd=function(){this._isEnabled&&(this._sharedBody.removeShape(this,this._isTrigger),this._sharedBody.addShape(this,this._isTrigger))},e.getGroup=function(){return this._sharedBody.collisionFilterGroup},e.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},e.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},e.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},e.getMask=function(){return this._sharedBody.collisionFilterMask},e.setMask=function(t){this._sharedBody.collisionFilterMask=t},e.addMask=function(t){this._sharedBody.collisionFilterMask|=t},e.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},e.setCompound=function(t){this._compound&&xo.CompoundShape_removeChildShape(this._compound,this._impl),t&&xo.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?xo.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=put.BODY_RE_ADD)},e.needCompound=function(){return this._collider.type===Htt.TERRAIN||!this._collider.center.equals(n.ZERO)},Ur(t,[{key:"attachedRigidBody",get:function(){return this._sharedBody.wrappedBody?this._sharedBody.wrappedBody.rigidBody:null}},{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}},{key:"sharedBody",get:function(){return this._sharedBody}}]),t}();Dut.TYPE="shape",Dut.idCounter=0;var Mut,Put,Iut,Out,Fut,Lut,kut,Vut,Nut,Gut=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}(),zut=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}(),Uut=function(){function t(t){this.impl=0,this.event=void 0,this.event=t}var e=t.prototype;return e.getLocalPointOnA=function(t){this.impl&&Bnt(t,xo.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&Bnt(t,xo.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&Bnt(t,xo.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&Bnt(t,xo.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=pnt.instance.BT_QUAT_0,i=xo.PersistentManifold_getBody0(this.event.impl),r=xo.CollisionObject_getWorldTransform(i);xo.Transform_getRotation(r,e);var s=wnt;Dnt(s,e),l.conjugate(s,s),Bnt(t,xo.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||n.negate(t,t),n.transformQuat(t,t,s)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=pnt.instance.BT_QUAT_0,i=xo.PersistentManifold_getBody1(this.event.impl),r=xo.CollisionObject_getWorldTransform(i);xo.Transform_getRotation(r,e);var s=wnt;Dnt(s,e),l.conjugate(s,s),Bnt(t,xo.ManifoldPoint_get_m_normalWorldOnB(this.impl)),n.transformQuat(t,t,s)}},e.getWorldNormalOnA=function(t){this.impl&&(Bnt(t,xo.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||n.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&Bnt(t,xo.ManifoldPoint_get_m_normalWorldOnB(this.impl))},Ur(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===xo.PersistentManifold_getBody0(this.event.impl)}}]),t}(),Hut=[],Xut=Cnt,Wut=xnt,jut=function(){var t=e.prototype;function e(){this._world=void 0,this._broadphase=void 0,this._solver=void 0,this._dispatcher=void 0,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this.bodies=[],this.ghosts=[],this.constraints=[],this.triggerArrayMat=new Gut,this.collisionArrayMat=new Gut,this.contactsDic=new zut,this.oldContactsDic=new zut,this._broadphase=xo.DbvtBroadphase_new(),this._dispatcher=xo.CollisionDispatcher_new(),this._solver=xo.SequentialImpulseConstraintSolver_new(),this._world=xo.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){xo.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){xo.DynamicsWorld_setGravity(this._world,Ent(pnt.instance.BT_V3_0,t))},t.updateNeedEmitEvents=function(t){if(this.ghosts)if(t)this._needEmitEvents=!0;else{this._needEmitEvents=!1;for(var e=0;e<this.ghosts.length;e++)for(var i=this.ghosts[e].ghostStruct.wrappedShapes,r=0;r<i.length;r++){var n=i[r].collider;if(n.needCollisionEvent||n.needTriggerEvent)return void(this._needEmitEvents=!0)}for(var s=0;s<this.bodies.length;s++)for(var a=this.bodies[s].bodyStruct.wrappedShapes,o=0;o<a.length;o++){var l=a[o].collider;if(l.needCollisionEvent||l.needTriggerEvent)return void(this._needEmitEvents=!0)}}},t.destroy=function(){(this.constraints.length||this.bodies.length)&&Ja("You should destroy all physics component first."),xo.CollisionWorld_del(this._world),xo.DbvtBroadphase_del(this._broadphase),xo.CollisionDispatcher_del(this._dispatcher),xo.SequentialImpulseConstraintSolver_del(this._solver),this.bodies=null,this.ghosts=null,this.constraints=null,this.triggerArrayMat=null,this.collisionArrayMat=null,this.contactsDic=null,this.oldContactsDic=null,Hut.length=0},t.step=function(t,e,i){void 0===i&&(i=0),(this.bodies.length||this.ghosts.length)&&(void 0===e&&(e=t),xo.DynamicsWorld_stepSimulation(this._world,e,i,t))},t.syncSceneToPhysics=function(){for(var t=this.ghosts.length-1;t>=0;t--){var e=this.ghosts[t];e.updateDirty(),e.syncSceneToGhost()}for(var i=this.bodies.length-1;i>=0;i--){var r=this.bodies[i];r.updateDirty(),r.syncSceneToPhysics()}},t.syncAfterEvents=function(){this._needSyncAfterEvents&&this.syncSceneToPhysics()},t.raycast=function(t,e,i,r){t.computeHit(Xut,e.maxDistance);var s=Ent(pnt.instance.BT_V3_0,Xut),a=Ent(pnt.instance.BT_V3_1,t.o),o=xo.ccAllRayCallback_static();if(xo.ccAllRayCallback_reset(o,a,s,e.mask,e.queryTrigger),xo.CollisionWorld_rayTest(this._world,a,s,o),xo.RayCallback_hasHit(o)){for(var l=xo.ccAllRayCallback_getHitPointWorld(o),h=xo.ccAllRayCallback_getHitNormalWorld(o),u=xo.ccAllRayCallback_getCollisionShapePtrs(o),c=0,_=xo.int_array_size(u);c<_;c++){Bnt(Xut,xo.Vec3_array_at(l,c)),Bnt(Wut,xo.Vec3_array_at(h,c));var f=pnt.getWrapper(xo.int_array_at(u,c),Dut.TYPE),d=i.add();r.push(d),d._assign(Xut,n.distance(t.o,Xut),f.collider,Wut)}return!0}return!1},t.raycastClosest=function(t,e,i){t.computeHit(Xut,e.maxDistance);var r=Ent(pnt.instance.BT_V3_0,Xut),s=Ent(pnt.instance.BT_V3_1,t.o),a=xo.ccClosestRayCallback_static();if(xo.ccClosestRayCallback_reset(a,s,r,e.mask,e.queryTrigger),xo.CollisionWorld_rayTest(this._world,s,r,a),xo.RayCallback_hasHit(a)){Bnt(Xut,xo.ccClosestRayCallback_getHitPointWorld(a)),Bnt(Wut,xo.ccClosestRayCallback_getHitNormalWorld(a));var o=pnt.getWrapper(xo.ccClosestRayCallback_getCollisionShapePtr(a),Dut.TYPE);return i._assign(Xut,n.distance(t.o,Xut),o.collider,Wut),!0}return!1},t.getSharedBody=function(t,e){return Eut.getSharedBody(t,this,e)},t.addSharedBody=function(t){this.bodies.indexOf(t)<0&&(this.bodies.push(t),xo.DynamicsWorld_addRigidBody(this._world,t.body,t.collisionFilterGroup,t.collisionFilterMask))},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(qa(this.bodies,e),xo.DynamicsWorld_removeRigidBody(this._world,t.body))},t.addGhostObject=function(t){this.ghosts.indexOf(t)<0&&(this.ghosts.push(t),xo.CollisionWorld_addCollisionObject(this._world,t.ghost,t.collisionFilterGroup,t.collisionFilterMask))},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(qa(this.ghosts,e),xo.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),xo.DynamicsWorld_addConstraint(this.impl,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),xo.DynamicsWorld_removeConstraint(this.impl,t.impl),t.index=-1)},t.emitEvents=function(){if(this._needSyncAfterEvents=!1,this._needEmitEvents){this.gatherConatactData();for(var t=this.contactsDic.getLength();t--;){Hut.push.apply(Hut,dnt.contacts),dnt.contacts.length=0;var e=this.contactsDic.getKeyByIndex(t),i=this.contactsDic.getDataByKey(e),r=i.shape0,n=i.shape1;this.oldContactsDic.set(r.id,n.id,i);var s=r.collider,a=n.collider;if(s&&a){if(s.isTrigger||a.isTrigger)this.triggerArrayMat.get(r.id,n.id)?fnt.type="onTriggerStay":(fnt.type="onTriggerEnter",this.triggerArrayMat.set(r.id,n.id,!0)),fnt.impl=i.impl,fnt.selfCollider=s,fnt.otherCollider=a,s.emit(fnt.type,fnt),fnt.selfCollider=a,fnt.otherCollider=s,a.emit(fnt.type,fnt),this._needSyncAfterEvents=!0;else{var o=s.attachedRigidBody,l=a.attachedRigidBody;if(o&&l){if(o.isSleeping&&l.isSleeping)continue}else if(!o&&l){if(l.isSleeping)continue}else if(!l&&o&&o.isSleeping)continue;this.collisionArrayMat.get(r.id,n.id)?dnt.type="onCollisionStay":(dnt.type="onCollisionEnter",this.collisionArrayMat.set(r.id,n.id,!0));for(var h=0;h<i.contacts.length;h++){var u=i.contacts[h];if(Hut.length>0){var c=Hut.pop();c.impl=u,dnt.contacts.push(c)}else{var _=new Uut(dnt);_.impl=u,dnt.contacts.push(_)}}dnt.impl=i.impl,dnt.selfCollider=s,dnt.otherCollider=a,s.emit(dnt.type,dnt),dnt.selfCollider=a,dnt.otherCollider=s,a.emit(dnt.type,dnt),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(r.id,n.id)&&this.oldContactsDic.set(r.id,n.id,i)}}for(var f=this.oldContactsDic.getLength();f--;){var d=this.oldContactsDic.getKeyByIndex(f),p=this.oldContactsDic.getDataByKey(d),m=p.shape0,g=p.shape1,y=m.collider,v=g.collider;if(y&&v){var b=y.isTrigger||v.isTrigger;null==this.contactsDic.getDataByKey(d)&&(b?this.triggerArrayMat.get(m.id,g.id)&&(fnt.type="onTriggerExit",fnt.selfCollider=y,fnt.otherCollider=v,y.emit(fnt.type,fnt),fnt.selfCollider=v,fnt.otherCollider=y,v.emit(fnt.type,fnt),this.triggerArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0):this.collisionArrayMat.get(m.id,g.id)&&(Hut.push.apply(Hut,dnt.contacts),dnt.contacts.length=0,dnt.type="onCollisionExit",dnt.selfCollider=y,dnt.otherCollider=v,y.emit(dnt.type,dnt),dnt.selfCollider=v,dnt.otherCollider=y,v.emit(dnt.type,dnt),this.collisionArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0))}}this.contactsDic.reset()}},t.gatherConatactData=function(){for(var t=xo.Dispatcher_getNumManifolds(this._dispatcher),e=0;e<t;e++)for(var i=xo.Dispatcher_getManifoldByIndexInternal(this._dispatcher,e),r=xo.PersistentManifold_getNumContacts(i),n=0;n<r;n++){var s=xo.PersistentManifold_getContactPoint(i,n),a=xo.ManifoldPoint_getShape0(s),o=xo.ManifoldPoint_getShape1(s),l=pnt.getWrapper(a,Dut.TYPE),h=pnt.getWrapper(o,Dut.TYPE);if(l.collider.needTriggerEvent||h.collider.needTriggerEvent||l.collider.needCollisionEvent||h.collider.needCollisionEvent){var u=this.contactsDic.get(l.id,h.id);u||(u=this.contactsDic.set(l.id,h.id,{shape0:l,shape1:h,contacts:[],impl:i})),u.contacts.push(s)}}},Ur(e,[{key:"impl",get:function(){return this._world}}]),e}(),Yut=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.updateSize=function(){var t=pnt.instance.BT_V3_0;Ent(t,this.getMinUnscaledHalfExtents(bat)),xo.BoxShape_setUnscaledHalfExtents(this.impl,t),this.updateCompoundTransform()},i.onComponentSet=function(){var t=pnt.instance.BT_V3_0;Ent(t,this.getMinUnscaledHalfExtents(bat)),this._impl=xo.BoxShape_new(t),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=pnt.instance.BT_V3_0;xo.CollisionShape_setLocalScaling(this._impl,Ent(e,this.getMinScale(bat))),this.updateCompoundTransform()},i.getMinUnscaledHalfExtents=function(t){var e=this.collider.size,i=Sat(bat.set(this._collider.node.worldScale)),r=Tst.instance.minVolumeSize,n=e.x/2,s=e.y/2,a=e.z/2,o=n*i.x<r?r/i.x:n,l=s*i.y<r?r/i.y:s,h=a*i.z<r?r/i.z:a;return t.set(o,l,h),t},i.getMinScale=function(t){var e=this.collider.size,i=Sat(bat.set(this._collider.node.worldScale)),r=Tst.instance.minVolumeSize,n=e.x/2,s=e.y/2,a=e.z/2,o=n*i.x<r?r/n:i.x,l=s*i.y<r?r/s:i.y,h=a*i.z<r?r/a:i.z;return t.set(o,l,h),t},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),qut=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.updateRadius=function(){xo.SphereShape_setUnscaledRadius(this.impl,this.getMinUnscaledRadius()),this.updateCompoundTransform()},i.onComponentSet=function(){this._impl=xo.SphereShape_new(this.getMinUnscaledRadius()),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=this.getMinScale();Cnt.set(e,e,e);var i=pnt.instance.BT_V3_0;xo.CollisionShape_setLocalScaling(this._impl,Ent(i,Cnt)),this.updateCompoundTransform()},i.getMinUnscaledRadius=function(){var t=this.collider.radius,e=Math.abs(V(this._collider.node.worldScale)),i=Tst.instance.minVolumeSize;return e*t<i?i/e:t},i.getMinScale=function(){var t=this.collider.radius,e=Math.abs(V(this._collider.node.worldScale)),i=Tst.instance.minVolumeSize;return e*t<i?i/t:e},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),Kut=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setCylinderHeight=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=xo.CapsuleShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,r){var n,s,a=r,o=i;1===o?(n=t*Math.abs(N(a.x,a.z)),s=e/2*Math.abs(a.y)):0===o?(n=t*Math.abs(N(a.y,a.z)),s=e/2*Math.abs(a.x)):(n=t*Math.abs(N(a.x,a.y)),s=e/2*Math.abs(a.z)),xo.CapsuleShape_updateProp(this._impl,n,s,o),this.updateCompoundTransform()},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),Jut=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).refBtTriangleMesh=0,e}on(e,t);var i=e.prototype;return i.setMesh=function(t){if(this._isInitialized)if(this._impl&&pnt.isNotEmptyShape(this._impl))Rn(9620);else{var e=t;if(e&&e.renderingSubMeshes.length>0){var i=this._getBtTriangleMesh(e);this.collider.convex?this._impl=xo.ConvexTriangleMeshShape_new(i):this._impl=xo.BvhTriangleMeshShape_new(i,!0,!0);var r=pnt.instance.BT_V3_0;Ent(r,this._collider.node.worldScale),xo.CollisionShape_setMargin(this._impl,.01),xo.CollisionShape_setLocalScaling(this._impl,r),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=xo.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.refBtTriangleMesh&&xo.TriangleMesh_del(this.refBtTriangleMesh),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=pnt.instance.BT_V3_0;Ent(e,this._collider.node.worldScale),xo.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=xo.TriangleMesh_new(),function(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=pnt.instance.BT_V3_0,u=pnt.instance.BT_V3_1,c=pnt.instance.BT_V3_2;if(a===wt.TRIANGLE_LIST)for(var _=l.length,f=0;f<_;f+=3){var d=3*l[f],p=3*l[f+1],m=3*l[f+2];xo.Vec3_set(h,o[d],o[d+1],o[d+2]),xo.Vec3_set(u,o[p],o[p+1],o[p+2]),xo.Vec3_set(c,o[m],o[m+1],o[m+2]),xo.TriangleMesh_addTriangle(t,h,u,c)}else if(a===wt.TRIANGLE_STRIP)for(var g=l.length-2,y=0,v=0;v<g;v+=1){var b=3*l[v-y],S=3*l[v+y+1],A=3*l[v+2];y=~y,xo.Vec3_set(h,o[b],o[b+1],o[b+2]),xo.Vec3_set(u,o[S],o[S+1],o[S+2]),xo.Vec3_set(c,o[A],o[A+1],o[A+2]),xo.TriangleMesh_addTriangle(t,h,u,c)}else if(a===wt.TRIANGLE_FAN){var T=l.length-1,C=3*l[0];xo.Vec3_set(h,o[C],o[C+1],o[C+2]);for(var x=1;x<T;x+=1){var w=3*l[x],E=3*l[x+1];xo.Vec3_set(u,o[w],o[w+1],o[w+2]),xo.Vec3_set(c,o[E],o[E+1],o[E+2]),xo.TriangleMesh_addTriangle(t,h,u,c)}}}}}(this.refBtTriangleMesh,t),this.refBtTriangleMesh},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),Zut=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){var t=pnt.instance.BT_V3_0;xo.Vec3_set(t,.5,1,.5),this._impl=xo.CylinderShape_new(t),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,r){var n,s,a=r,o=i;1===o?(s=e*Math.abs(a.y),n=t*Math.abs(N(a.x,a.z))):0===o?(s=e*Math.abs(a.x),n=t*Math.abs(N(a.y,a.z))):(s=e*Math.abs(a.z),n=t*Math.abs(N(a.x,a.y))),xo.CylinderShape_updateProp(this._impl,n,s/2,o),this.updateCompoundTransform()},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),Qut=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=xo.ConeShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,r){var n,s,a=r,o=i;1===o?(s=e*Math.abs(a.y),n=t*Math.abs(N(a.x,a.z))):0===o?(s=e*Math.abs(a.x),n=t*Math.abs(N(a.y,a.z))):(s=e*Math.abs(a.z),n=t*Math.abs(N(a.x,a.y))),xo.ConeShape_setRadius(this._impl,n),xo.ConeShape_setHeight(this._impl,s),xo.ConeShape_setConeUpIndex(this._impl,o);var l=pnt.instance.BT_V3_0;xo.Vec3_set(l,1,1,1),xo.CollisionShape_setLocalScaling(this._impl,l),this.updateCompoundTransform()},Ur(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(Dut),$ut=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return(e=t.call.apply(t,[this].concat(r))||this)._bufPtr=0,e._tileSize=0,e._localOffset=new n,e}on(e,t);var i=e.prototype;return i.setTerrain=function(t){if(this._isInitialized)if(this._impl&&pnt.isNotEmptyShape(this._impl))bn("[Physics][Bullet]: change the terrain asset after initialization is not support.");else{var e=t;if(e){this._tileSize=e.tileSize;var i=e.getVertexCountI(),r=e.getVertexCountJ();this._bufPtr=xo._malloc(4*i*r);for(var n=0,s=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER,o=0;o<r;o++)for(var l=0;l<i;l++){var h=e.getHeight(l,o);xo._write_f32(this._bufPtr+n,h),s>h&&(s=h),h>a&&(a=h),n+=4}a+=.01,s-=.01,this._localOffset.set((i-1)/2*this._tileSize,(a+s)/2,(r-1)/2*this._tileSize),this._impl=xo.TerrainShape_new(i,r,this._bufPtr,1,s,a);var u=pnt.instance.BT_V3_0;xo.Vec3_set(u,this._tileSize,1,this._tileSize),xo.CollisionShape_setLocalScaling(this._impl,u),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=xo.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&xo._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){n.copy(Cnt,t),Cnt.add(this._localOffset),Ent(xo.Transform_getOrigin(this.transform),Cnt),this.updateCompoundTransform()},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),tct=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setShapeType=function(){},i.setVertices=function(){},i.onComponentSet=function(){this._impl=xo.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=pnt.instance.BT_V3_0,r=0;r<t;r++)xo.SimplexShape_addVertex(this._impl,Ent(i,e[r]));xo.CollisionShape_setLocalScaling(this._impl,Ent(i,this._collider.node.worldScale))},i.onLoad=function(){t.prototype.onLoad.call(this),this.collider.updateVertices()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=pnt.instance.BT_V3_0;xo.CollisionShape_setLocalScaling(this._impl,Ent(e,this._collider.node.worldScale))},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),ect=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setNormal=function(t){Ent(xo.StaticPlaneShape_getPlaneNormal(this.impl),t),this.updateCompoundTransform()},i.setConstant=function(t){xo.StaticPlaneShape_setPlaneConstant(this.impl,t),this.updateCompoundTransform()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=pnt.instance.BT_V3_0;Ent(e,this._collider.node.worldScale),xo.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i.onComponentSet=function(){var t=pnt.instance.BT_V3_0;Ent(t,this.collider.normal),this._impl=xo.StaticPlaneShape_new(t,this.collider.constant),this.updateScale()},Ur(e,[{key:"collider",get:function(){return this._collider}}]),e}(Dut),ict=function(){function t(){this.dirty=0,this.index=-1,this._impl=0,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.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(){xo.TypedConstraint_del(this._impl),this._com=null,this._rigidBody=null},Ur(t,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),t}(),rct=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.setPivotA=function(){var t=this.constraint,e=pnt.instance.BT_V3_0;n.multiply(Cnt,t.node.worldScale,t.pivotA),Ent(e,Cnt),xo.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=pnt.instance.BT_V3_0,r=t.connectedBody;r?(n.multiply(Cnt,r.node.worldScale,t.pivotB),Ent(i,Cnt)):(n.multiply(Cnt,e.worldScale,t.pivotA),n.add(Cnt,Cnt,e.worldPosition),n.add(Cnt,Cnt,t.pivotB),Ent(i,Cnt)),xo.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:xo.TypedConstraint_getFixedBody(),r=pnt.instance.BT_V3_0,n=pnt.instance.BT_V3_1;this._impl=xo.P2PConstraint_new(e,i,r,n),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)},Ur(e,[{key:"constraint",get:function(){return this._com}}]),e}(ict),nct=function(t){function e(){return t.apply(this,arguments)||this}on(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.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:xo.TypedConstraint_getFixedBody(),r=pnt.instance.BT_TRANSFORM_0,n=pnt.instance.BT_TRANSFORM_1;this._impl=xo.HingeConstraint_new(e,i,r,n),this.updateFrames()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=Cnt,r=wnt,s=pnt.instance.BT_TRANSFORM_0;n.multiply(i,e.worldScale,t.pivotA),Ent(xo.Transform_getOrigin(s),i);var a=pnt.instance.BT_QUAT_0;l.rotationTo(r,n.UNIT_Z,t.axis),Rnt(a,r),xo.Transform_setRotation(s,a);var o=pnt.instance.BT_TRANSFORM_1,h=this.constraint.connectedBody;h?n.multiply(i,h.node.worldScale,t.pivotB):(n.multiply(i,e.worldScale,t.pivotA),n.add(i,i,e.worldPosition),n.add(i,i,t.pivotB),l.multiply(r,r,e.worldRotation)),Ent(xo.Transform_getOrigin(o),i),Rnt(a,r),xo.Transform_setRotation(o,a),xo.HingeConstraint_setFrames(this._impl,s,o)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},Ur(e,[{key:"constraint",get:function(){return this._com}}]),e}(ict);Ir.once(ao.EVENT_PRE_SUBSYSTEM_INIT,(function(){rnt.register("bullet",{PhysicsWorld:jut,RigidBody:Tut,BoxShape:Yut,SphereShape:qut,CapsuleShape:Kut,TrimeshShape:Jut,CylinderShape:Zut,ConeShape:Qut,TerrainShape:$ut,SimplexShape:tct,PlaneShape:ect,PointToPointConstraint:rct,HingeConstraint:nct})})),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"}(Nut||(Nut={})),ss(Nut);var sct=t("Primitive",(Mut=En("cc.Primitive"),Put=Wn(Nut),Mut((Vut=kut=function(t){function e(e){var i;return void 0===e&&(e=Nut.BOX),i=t.call(this)||this,Mn(i,"type",Fut,Pn(i)),Mn(i,"info",Lut,Pn(i)),i.type=e,i}return on(e,t),e.prototype.onLoaded=function(){fh(vat[Nut[this.type].toLowerCase()](this.info),this)},e}(sh),kut.PrimitiveType=Nut,Fut=Dn((Out=Vut).prototype,"type",[Put],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Nut.BOX}}),Lut=Dn(Out.prototype,"info",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),Iut=Out))||Iut));Er.Primitive=sct,Er.primitives=vat;var act,oct=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)}},Ur(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),lct=En("cc.PerfCounter")(act=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}on(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}(oct))||act,hct="0123456789. ",uct=500,cct={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},_ct={fps:{desc:"Framerate (FPS)",below:30,average:uct,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:uct},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:uct,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:uct},render:{desc:"Renderer (ms)",min:0,max:50,average:uct,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},fct=t("Profiler",function(t){function e(){var e;return(e=t.call(this)||this)._stats=null,e._showFPS=!1,e._rootNode=null,e._device=null,e._swapchain=null,e._pipeline=null,e._meshRenderer=null,e._canvas=null,e._ctx=null,e._texture=null,e._region=new Kt,e._canvasArr=[],e._regionArr=[e._region],e.digitsData=null,e.offsetData=null,e.pass=null,e._canvasDone=!1,e._statsDone=!1,e._inited=!1,e._lineHeight=256/(Object.keys(_ct).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=document.createElement("canvas"),e._ctx=e._canvas.getContext("2d"),e._canvasArr.push(e._canvas),e}on(e,t);var i=e.prototype;return i.init=function(){To.querySettings(Co.Category.PROFILING,"showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),Er.director.off(Er.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),Er.director.off(Er.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),Er.director.off(Er.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),Er.director.off(Er.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),Er.director.off(Er.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),Er.director.off(Er.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!1,Kr.root.pipeline.profiler=null,Er.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=Er.director.root;this._device=Ci.gfxDevice,this._swapchain=t.mainWindow.swapchain,this._pipeline=t.pipeline}this.generateCanvas(),this.generateStats(),Er.game.once(Er.Game.EVENT_ENGINE_INITED,this.generateNode,this),Er.game.on(Er.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),Er.director.on(Er.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),Er.director.on(Er.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),Er.director.on(Er.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),Er.director.on(Er.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),Er.director.on(Er.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),Er.director.on(Er.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,Er.game.config.showFPS=!0}},i.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 ae(ot.TEX2D,lt.SAMPLED|lt.TRANSFER_DST,tt.RGBA8,256,256)),this._region.texExtent.width=256,this._region.texExtent.height=256)}},i.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 _ct){var r=_ct[i];this._ctx.fillText(r.desc,0,e*this._lineHeight),r.counter=new lct(i,r,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var n=0;n<hct.length;++n){var s=this._ctx.measureText(hct[n]).width;this._eachNumWidth=Math.max(this._eachNumWidth,s)}for(var a=0;a<hct.length;++a)this._ctx.fillText(hct[a],a*this._eachNumWidth,this._totalLines*this._lineHeight);this._eachNumWidth/=this._canvas.width,this._stats=_ct,this._canvasArr[0]=this._canvas,this._device.copyTexImagesToTexture(this._canvasArr,this._texture,this._regionArr)}},i.generateNode=function(){if(!this._rootNode||!this._rootNode.isValid){this._rootNode=new ks("PROFILER_NODE"),this._rootNode._objFlags=Er.Object.Flags.DontSave|Er.Object.Flags.HideInHierarchy,Er.game.addPersistRootNode(this._rootNode);var t=new ks("Profiler_Root");t.parent=this._rootNode;for(var e=.4,i=e/this._totalLines,r=e/this._wordHeight,n=i/23,s=this._eachNumWidth*this._canvas.width*n,a=[0,e,0,r,e,0,r,0,0,0,0,0],o=[0,2,1,0,3,2],l=[0,0,-1,0,1,0,-1,0,1,this._wordHeight,-1,0,0,this._wordHeight,-1,0],h=0,u=0;u<this._totalLines;u++)for(var c=0;c<8;c++){a.push(r+c*s,e-u*i,0),a.push(r+(c+1)*s,e-u*i,0),a.push(r+(c+1)*s,e-(u+1)*i,0),a.push(r+c*s,e-(u+1)*i,0),h=4*(8*u+c+1),o.push(0+h,2+h,1+h,0+h,3+h,2+h);var _=8*u+c,f=Math.floor(_/4),d=_-4*f;l.push(0,this._wordHeight,f,d),l.push(this._eachNumWidth,this._wordHeight,f,d),l.push(this._eachNumWidth,1,f,d),l.push(0,1,f,d)}this._meshRenderer=t.addComponent(dT),this._meshRenderer.mesh=fh({positions:a,indices:o,colors:l});var p=new cn;p.initialize({effectName:"util/profiler"});var m=this.pass=p.passes[0],g=m.getBinding("mainTexture"),y=m.getBinding("digits"),v=m.getBinding("offset");m.bindTexture(g,this._texture),this.digitsData=m.blocks[y],this.offsetData=m.blocks[v],this.offsetData[3]=-1,this._meshRenderer.material=p,this._meshRenderer.node.layer=gs.Enum.PROFILER,this._inited=!0}},i.beforeUpdate=function(){if(this._stats){var t=performance.now();this._stats.frame.counter.start(t),this._stats.logic.counter.start(t)}},i.afterUpdate=function(){if(this._stats){var t=performance.now();Er.director.isPaused()?this._stats.frame.counter.start(t):this._stats.logic.counter.end(t)}},i.beforePhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.start(t)}},i.afterPhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.end(t)}},i.beforeDraw=function(){if(this._stats&&this._inited){var t=this._swapchain.surfaceTransform,e=this._device.capabilities.clipSpaceSignY;if(t!==this.offsetData[3]){var i=Eo[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,this._meshRenderer.model?Kr.root.pipeline.profiler=this._meshRenderer.model:Kr.root.pipeline.profiler=null;var n=performance.now();this._stats.render.counter.start(n)}},i.afterDraw=function(){if(this._stats&&this._inited){var t=performance.now();if(this._stats.frame.counter.end(t),this._stats.fps.counter.frame(t),this._stats.render.counter.end(t),!(t-this.lastTime<uct)){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=cct[h];void 0===u&&(u=11),r[l]=u}i++}}}},e}(Rr)),dct=t("profiler",new fct);Kr.registerSystem("profiler",dct,0),Er.profiler=dct;var pct=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new Nw(t),this.jointAnimationInfo=new Gw(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}();Er.internal.DataPoolManager=pct;var mct,gct,yct,vct,bct,Sct,Act,Tct,Cct,xct,wct,Ect,Bct,Rct,Dct,Mct,Pct,Ict,Oct,Fct,Lct=new c,kct=new c,Vct=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._parent=null,r._curvesInited=!1,r._animInfoMgr=Er.director.root.dataPoolManager.jointAnimationInfo,r}on(e,t);var i=e.prototype;return i.initialize=function(e){if(!this._curveLoaded){this._parent=e.getComponent("cc.SkeletalAnimation");var i=this._parent.useBakedAnimation;this._doNotCreateEval=i,t.prototype.initialize.call(this,e),this._curvesInited=!i;var r=xw.getOrExtract(this.clip),n=r.frames,s=r.samples;this._frames=n-1,this._animInfo=this._animInfoMgr.getData(e.uuid),this._bakedDuration=this._frames/s,this.setUseBaked(i)}},i.setUseBaked=function(e){e?(this._sampleCurves=this._sampleCurvesBaked,this.duration=this._bakedDuration):(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],s=e.getChildByPath(r.path);if(r.target){for(var a=xw.getOrExtract(this.clip),o=r.path,h=a.joints[o],u=s,_=void 0;!h;){var f=o.lastIndexOf("/");if(o=o.substring(0,f),h=a.joints[o],u&&(_||(_=c.identity(kct)),c.fromRTS(Lct,u.rotation,u.position,u.scale),c.multiply(_,Lct,_),u=u.parent),f<0)break}for(var d=h&&h.transforms,p=a.frames,m=[],g=0;g<p;g++){var y;y=d&&_?c.multiply(Lct,d[g],_):d?d[g]:_||new c;var v={pos:new n,rot:new l,scale:new n};c.toRTS(y,v.rot,v.pos,v.scale),m.push(v)}this._sockets.push({target:r.target,frames:m})}}},i._sampleCurvesBaked=function(t){var e=t/this.duration,i=this._animInfo,r=this.clip;i.currentClip!==r&&(this._animInfoMgr.switchClip(this._animInfo,r),this._parent.getUsers().forEach((function(t){t.uploadAnimation(r)})));var n=e*this._frames+.5|0;if(n!==i.data[0]){i.data[0]=n,i.dirty=!0;for(var s=0;s<this._sockets.length;++s){var a=this._sockets[s],o=a.target,l=a.frames[n],h=l.pos,u=l.rot,c=l.scale;o.setRTS(u,h,c)}}},e}(SB)),Nct=t("Socket",(mct=En("cc.SkeletalAnimation.Socket"),gct=Wn(ks),mct((bct=Dn((vct=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),Mn(this,"path",bct,this),Mn(this,"target",Sct,this),this.path=t,this.target=e}).prototype,"path",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Sct=Dn(vct.prototype,"target",[gct],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),yct=vct))||yct));pn.setClassAlias(Nct,"cc.SkeletalAnimationComponent.Socket");var Gct=new c,zct=new c;function Uct(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),Uct(n,s,i)}}return i}var Hct=function(e){return t({SkeletalAnimation:e,SkeletalAnimationComponent:e}),e}((Act=En("cc.SkeletalAnimation"),Tct=Qn(),Cct=$n(99),xct=ts(),wct=Wn([Nct]),Ect=is(),Bct=is(),Rct=Wn([Nct]),Act(Dct=Tct(Dct=Cct(Dct=Jn(Dct=xct((Fct=Oct=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,Mn(e,"_useBakedAnimation",Pct,Pn(e)),Mn(e,"_sockets",Ict,Pn(e)),e._users=new Set,e._currentBakedState=null,e}on(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this);for(var e=this.node.getComponentsInChildren(JE),i=0;i<e.length;++i){var r=e[i];r.skinningRoot===this.node&&this.notifySkinnedMeshAdded(r)}},i.onDestroy=function(){t.prototype.onDestroy.call(this),Er.director.root.dataPoolManager.jointAnimationInfo.destroy(this.node.uuid),mB().removeSockets(this.node,this._sockets),this._removeAllUsers()},i.onEnable=function(){var e;t.prototype.onEnable.call(this),null===(e=this._currentBakedState)||void 0===e||e.resume()},i.onDisable=function(){var e;t.prototype.onDisable.call(this),null===(e=this._currentBakedState)||void 0===e||e.pause()},i.start=function(){this.sockets=this._sockets,this.useBakedAnimation=this._useBakedAnimation,t.prototype.start.call(this)},i.pause=function(){var e;this._useBakedAnimation?null===(e=this._currentBakedState)||void 0===e||e.pause():t.prototype.pause.call(this)},i.resume=function(){var e;this._useBakedAnimation?null===(e=this._currentBakedState)||void 0===e||e.resume():t.prototype.resume.call(this)},i.stop=function(){this._useBakedAnimation?this._currentBakedState&&(this._currentBakedState.stop(),this._currentBakedState=null):t.prototype.stop.call(this)},i.querySockets=function(){var t=this._defaultClip&&Object.keys(xw.getOrExtract(this._defaultClip).joints).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),Uct(n,r,e))}return e},i.rebuildSocketAnimations=function(){for(var t,e=hn(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,Ew(r,this.node,Gct),c.fromRTS(zct,n.rotation,n.position,n.scale),c.equals(zct,Gct)||(n.matrix=Gct))}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 ks;return i.parent=this.node,this._sockets.push(new Nct(t,i)),this.rebuildSocketAnimations(),i},i.notifySkinnedMeshAdded=function(t){var e=this._useBakedAnimation,i=t.associatedAnimation;if(i&&i._users.delete(t),t.associatedAnimation=this,t.setUseBakedAnimation(e,!0),e){var r=this._currentBakedState;r&&t.uploadAnimation(r.clip)}this._users.add(t)},i.notifySkinnedMeshRemoved=function(t){gn(t.associatedAnimation===this||null===t.associatedAnimation),t.setUseBakedAnimation(!1),t.associatedAnimation=null,this._users.delete(t)},i.getUsers=function(){return this._users},i._createState=function(t,e){return new Vct(t,e)},i._doCreateState=function(e,i){var r=t.prototype._doCreateState.call(this,e,i);return r.rebuildSocketCurves(this._sockets),r},i.doPlayOrCrossFade=function(e,i){if(this._useBakedAnimation){this._currentBakedState&&this._currentBakedState.stop();var r=e;this._currentBakedState=r,r.play()}else t.prototype.doPlayOrCrossFade.call(this,e,i)},i._removeAllUsers=function(){var t=this;Array.from(this._users).forEach((function(e){t.notifySkinnedMeshRemoved(e)}))},Ur(e,[{key:"sockets",get:function(){return this._sockets},set:function(t){if(!this._useBakedAnimation){var e=mB();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){for(var e in this._useBakedAnimation=t,this._nameToState)this._nameToState[e].setUseBaked(t);this._users.forEach((function(e){e.setUseBakedAnimation(t)})),this._useBakedAnimation?mB().removeSockets(this.node,this._sockets):(mB().addSockets(this.node,this._sockets),this._currentBakedState=null)}}]),e}(Pk),Oct.Socket=Nct,Dn((Mct=Fct).prototype,"sockets",[wct,Ect],Object.getOwnPropertyDescriptor(Mct.prototype,"sockets"),Mct.prototype),Dn(Mct.prototype,"useBakedAnimation",[Bct],Object.getOwnPropertyDescriptor(Mct.prototype,"useBakedAnimation"),Mct.prototype),Pct=Dn(Mct.prototype,"_useBakedAnimation",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Ict=Dn(Mct.prototype,"_sockets",[Rct],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Dct=Mct))||Dct)||Dct)||Dct)||Dct)||Dct));Er.SkeletalAnimationComponent=Hct,pn.setClassAlias(Hct,"cc.SkeletalAnimationComponent");var Xct,Wct,jct=(Xct=function(t,e){return(Xct=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}Xct(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,d=t*e.BEZIER_SIZE,p=this.curves;p[d++]=e.BEZIER;for(var m=_,g=f,y=d+e.BEZIER_SIZE-1;d<y;d+=2)p[d]=m,p[d+1]=g,_+=u,f+=c,u+=l,c+=h,m+=_,g+=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 jct(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),d=h[f+s.PREV_ROTATION],p=h[f],m=this.getCurvePercent((f>>1)-1,1-(r-p)/(h[f+s.PREV_TIME]-p)),g=h[f+s.ROTATION]-d;switch(g=d+(g-360*(16384-(16384.499999999996-g/360|0)))*m,l){case e.setup:u.rotation=u.data.rotation+(g-360*(16384-(16384.499999999996-g/360|0)))*o;break;case e.first:case e.replace:g+=u.data.rotation-u.rotation;case e.add:u.rotation+=(g-360*(16384-(16384.499999999996-g/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 jct(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 d=h[f],p=this.getCurvePercent(f/s.ENTRIES-1,1-(r-d)/(h[f+s.PREV_TIME]-d));c+=(h[f+s.X]-c)*p,_+=(h[f+s.Y]-_)*p}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 jct(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 d=0,p=0;if(o>=_[_.length-a.ENTRIES])d=_[_.length+a.PREV_X]*f.data.scaleX,p=_[_.length+a.PREV_Y]*f.data.scaleY;else{var m=n.binarySearch(_,o,a.ENTRIES);d=_[m+a.PREV_X],p=_[m+a.PREV_Y];var g=_[m],y=this.getCurvePercent(m/a.ENTRIES-1,1-(o-g)/(_[m+a.PREV_TIME]-g));d=(d+(_[m+a.X]-d)*y)*f.data.scaleX,p=(p+(_[m+a.Y]-p)*y)*f.data.scaleY}if(1==h)u==e.add?(f.scaleX+=d-f.data.scaleX,f.scaleY+=p-f.data.scaleY):(f.scaleX=d,f.scaleY=p);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(d)*t.MathUtils.signum(v)-v)*h,f.scaleY=b+(Math.abs(p)*t.MathUtils.signum(b)-b)*h;break;case e.first:case e.replace:v=f.scaleX,b=f.scaleY,f.scaleX=v+(Math.abs(d)*t.MathUtils.signum(v)-v)*h,f.scaleY=b+(Math.abs(p)*t.MathUtils.signum(b)-b)*h;break;case e.add:v=f.scaleX,b=f.scaleY,f.scaleX=v+(Math.abs(d)*t.MathUtils.signum(v)-f.data.scaleX)*h,f.scaleY=b+(Math.abs(p)*t.MathUtils.signum(b)-f.data.scaleY)*h}else switch(u){case e.setup:v=Math.abs(f.data.scaleX)*t.MathUtils.signum(d),b=Math.abs(f.data.scaleY)*t.MathUtils.signum(p),f.scaleX=v+(d-v)*h,f.scaleY=b+(p-b)*h;break;case e.first:case e.replace:v=Math.abs(f.scaleX)*t.MathUtils.signum(d),b=Math.abs(f.scaleY)*t.MathUtils.signum(p),f.scaleX=v+(d-v)*h,f.scaleY=b+(p-b)*h;break;case e.add:v=t.MathUtils.signum(d),b=t.MathUtils.signum(p),f.scaleX=Math.abs(f.scaleX)*v+(d-Math.abs(f.data.scaleX)*v)*h,f.scaleY=Math.abs(f.scaleY)*b+(p-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 jct(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 d=h[f],p=this.getCurvePercent(f/i.ENTRIES-1,1-(s-d)/(h[f+i.PREV_TIME]-d));c+=(h[f+i.X]-c)*p,_+=(h[f+i.Y]-_)*p}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 jct(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,d=0,p=0,m=0;if(r>=u[u.length-s.ENTRIES]){var g=u.length;f=u[g+s.PREV_R],d=u[g+s.PREV_G],p=u[g+s.PREV_B],m=u[g+s.PREV_A]}else{var y=n.binarySearch(u,r,s.ENTRIES);f=u[y+s.PREV_R],d=u[y+s.PREV_G],p=u[y+s.PREV_B],m=u[y+s.PREV_A];var v=u[y],b=this.getCurvePercent(y/s.ENTRIES-1,1-(r-v)/(u[y+s.PREV_TIME]-v));f+=(u[y+s.R]-f)*b,d+=(u[y+s.G]-d)*b,p+=(u[y+s.B]-p)*b,m+=(u[y+s.A]-m)*b}1==o?h.color.set(f,d,p,m):(c=h.color,l==e.setup&&c.setFromColor(h.data.color),c.add((f-c.r)*o,(d-c.g)*o,(p-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 jct(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,d=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((d.r-_.r)*o,(d.g-_.g)*o,(d.b-_.b)*o,0)}else{var p=0,m=0,g=0,y=0,v=0,b=0,S=0;if(r>=u[u.length-s.ENTRIES]){var A=u.length;p=u[A+s.PREV_R],m=u[A+s.PREV_G],g=u[A+s.PREV_B],y=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 T=n.binarySearch(u,r,s.ENTRIES);p=u[T+s.PREV_R],m=u[T+s.PREV_G],g=u[T+s.PREV_B],y=u[T+s.PREV_A],v=u[T+s.PREV_R2],b=u[T+s.PREV_G2],S=u[T+s.PREV_B2];var C=u[T],x=this.getCurvePercent(T/s.ENTRIES-1,1-(r-C)/(u[T+s.PREV_TIME]-C));p+=(u[T+s.R]-p)*x,m+=(u[T+s.G]-m)*x,g+=(u[T+s.B]-g)*x,y+=(u[T+s.A]-y)*x,v+=(u[T+s.R2]-v)*x,b+=(u[T+s.G2]-b)*x,S+=(u[T+s.B2]-S)*x}1==o?(h.color.set(p,m,g,y),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((p-c.r)*o,(m-c.g)*o,(g-c.b)*o,(y-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 d=this.attachmentNames[f];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}else{var p=u.data.attachmentName;u.setAttachment(null==p?null:t.getAttachment(this.slotIndex,p))}},s}();t.AttachmentTimeline=_;var f=null,d=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 jct(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,d=this.frames;if(s<d[0]){var p=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==p.bones)for(var g=p.vertices,y=0;y<f;y++)m[y]+=(g[y]-m[y])*o;else for(o=1-o,y=0;y<f;y++)m[y]*=o}}else{var v=t.Utils.setArraySize(c,f);if(s>=d[d.length-1]){var b=_[d.length-1];if(1==o)if(l==e.add)if(null==(p=u).bones){g=p.vertices;for(var S=0;S<f;S++)v[S]+=b[S]-g[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 T=u;if(null==T.bones){g=T.vertices;for(var C=0;C<f;C++){var x=g[C];v[C]=x+(b[C]-x)*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==(p=u).bones){g=p.vertices;for(var B=0;B<f;B++)v[B]+=(b[B]-g[B])*o}else for(var R=0;R<f;R++)v[R]+=b[R]*o}}else{var D=n.binarySearch(d,s),M=_[D-1],P=_[D],I=d[D],O=this.getCurvePercent(D-1,1-(s-I)/(d[D-1]-I));if(1==o)if(l==e.add)if(null==(p=u).bones){g=p.vertices;for(var F=0;F<f;F++){var L=M[F];v[F]+=L+(P[F]-L)*O-g[F]}}else for(var k=0;k<f;k++)L=M[k],v[k]+=L+(P[k]-L)*O;else for(var V=0;V<f;V++)L=M[V],v[V]=L+(P[V]-L)*O;else switch(l){case e.setup:var N=u;if(null==N.bones){g=N.vertices;for(var G=0;G<f;G++)L=M[G],x=g[G],v[G]=x+(L+(P[G]-L)*O-x)*o}else for(var z=0;z<f;z++)L=M[z],v[z]=(L+(P[z]-L)*O)*o;break;case e.first:case e.replace:for(var U=0;U<f;U++)L=M[U],v[U]+=(L+(P[U]-L)*O-v[U])*o;break;case e.add:if(null==(p=u).bones){g=p.vertices;for(var H=0;H<f;H++)L=M[H],v[H]+=(L+(P[H]-L)*O-g[H])*o}else for(var X=0;X<f;X++)L=M[X],v[X]+=(L+(P[X]-L)*O)*o}}}}}},s}(s);t.DeformTimeline=d;var p=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=p;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 d;d=a>=f[f.length-1]?f.length-1:n.binarySearch(f,a)-1;var p=this.drawOrders[d];if(null==p)t.Utils.arrayCopy(_,0,c,0,_.length);else for(var m=0,g=p.length;m<g;m++)c[m]=_[p[m]]}}else t.Utils.arrayCopy(r.slots,0,r.drawOrder,0,r.slots.length)},s}();t.DrawOrderTimeline=m;var g=function(s){function a(e){var i=s.call(this,e)||this;return i.frames=t.Utils.newFloatArray(e*a.ENTRIES),i}return jct(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),d=c[f+a.PREV_MIX],p=c[f+a.PREV_SOFTNESS],m=c[f],g=this.getCurvePercent(f/a.ENTRIES-1,1-(s-m)/(c[f+a.PREV_TIME]-m));h==e.setup?(_.mix=_.data.mix+(d+(c[f+a.MIX]-d)*g-_.data.mix)*l,_.softness=_.data.softness+(p+(c[f+a.SOFTNESS]-p)*g-_.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+=(d+(c[f+a.MIX]-d)*g-_.mix)*l,_.softness+=(p+(c[f+a.SOFTNESS]-p)*g-_.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=g;var y=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return jct(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,d=0,p=0;if(r>=h[h.length-s.ENTRIES]){var m=h.length;_=h[m+s.PREV_ROTATE],f=h[m+s.PREV_TRANSLATE],d=h[m+s.PREV_SCALE],p=h[m+s.PREV_SHEAR]}else{var g=n.binarySearch(h,r,s.ENTRIES);_=h[g+s.PREV_ROTATE],f=h[g+s.PREV_TRANSLATE],d=h[g+s.PREV_SCALE],p=h[g+s.PREV_SHEAR];var y=h[g],v=this.getCurvePercent(g/s.ENTRIES-1,1-(r-y)/(h[g+s.PREV_TIME]-y));_+=(h[g+s.ROTATE]-_)*v,f+=(h[g+s.TRANSLATE]-f)*v,d+=(h[g+s.SCALE]-d)*v,p+=(h[g+s.SHEAR]-p)*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+(d-c.scaleMix)*o,u.shearMix=c.shearMix+(p-c.shearMix)*o):(u.rotateMix+=(_-u.rotateMix)*o,u.translateMix+=(f-u.translateMix)*o,u.scaleMix+=(d-u.scaleMix)*o,u.shearMix+=(p-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=y;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 jct(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[_],d=this.getCurvePercent(_/s.ENTRIES-1,1-(r-f)/(h[_+s.PREV_TIME]-f));c+=(h[_+s.VALUE]-c)*d}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 jct(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[_],d=this.getCurvePercent(_/i.ENTRIES-1,1-(s-f)/(h[_+i.PREV_TIME]-f));c+=(h[_+i.VALUE]-c)*d}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 jct(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 d=h[f],p=this.getCurvePercent(f/s.ENTRIES-1,1-(r-d)/(h[f+s.PREV_TIME]-d));c+=(h[f+s.ROTATE]-c)*p,_+=(h[f+s.TRANSLATE]-_)*p}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}(Wct||(Wct={})),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,d=l.animation.timelines;if(0==a&&1==u||h==t.MixBlend.add)for(var p=0;p<f;p++)t.Utils.webkit602BugfixHelper(u,h),d[p].apply(i,c,_,r,u,h,t.MixDirection.mixIn);else{var m=l.timelineMode,g=0==l.timelinesRotation.length;g&&t.Utils.setArraySize(l.timelinesRotation,f<<1,null);var y=l.timelinesRotation;for(p=0;p<f;p++){var v=d[p],b=(m[p]&e.NOT_LAST-1)==e.SUBSEQUENT?h:t.MixBlend.setup;v instanceof t.RotateTimeline?this.applyRotateTimeline(v,i,_,u,b,y,p<<1,g):(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,d=s.alpha*i.interruptAlpha,p=d*(1-a);if(n==t.MixBlend.add)for(var m=0;m<_;m++)f[m].apply(r,u,c,o,p,n,t.MixDirection.mixOut);else{var g=s.timelineMode,y=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,T=void 0,C=0;switch(g[m]&e.NOT_LAST-1){case e.SUBSEQUENT:if(T=n,!l&&S instanceof t.AttachmentTimeline){if((g[m]&e.NOT_LAST)==e.NOT_LAST)continue;T=t.MixBlend.setup}if(!h&&S instanceof t.DrawOrderTimeline)continue;C=p;break;case e.FIRST:T=t.MixBlend.setup,C=p;break;case e.HOLD:T=t.MixBlend.setup,C=d;break;default:T=t.MixBlend.setup;var x=y[m];C=d*Math.max(0,1-x.mixTime/x.mixDuration)}s.totalAlpha+=C,S instanceof t.RotateTimeline?this.applyRotateTimeline(S,r,c,C,T,b,m<<1,v):(t.Utils.webkit602BugfixHelper(C,n),T==t.MixBlend.setup&&(S instanceof t.AttachmentTimeline?(l||(g[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,C,T,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 d=t.Animation.binarySearch(u,r,t.RotateTimeline.ENTRIES),p=u[d+t.RotateTimeline.PREV_ROTATION],m=u[d],g=h.getCurvePercent((d>>1)-1,1-(r-m)/(u[d+t.RotateTimeline.PREV_TIME]-m));f=u[d+t.RotateTimeline.ROTATION]-p,f=p+(f-=360*(16384-(16384.499999999996-f/360|0)))*g+c.data.rotation,f-=360*(16384-(16384.499999999996-f/360|0))}var y=0,v=f-_;if(0==(v-=360*(16384-(16384.499999999996-v/360|0))))y=a[o];else{var b=0,S=0;l?(b=0,S=v):(b=a[o],S=a[o+1]);var A=v>0,T=b>=0;t.MathUtils.signum(S)!=t.MathUtils.signum(v)&&Math.abs(S)<=90&&(Math.abs(b)>180&&(b+=360*t.MathUtils.signum(b)),T=A),y=v+b-b%360,T!=A&&(y+=360*t.MathUtils.signum(b)),a[o]=y}a[o+1]=v,_+=y*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}(Wct||(Wct={})),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}(Wct||(Wct={})),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}(Wct||(Wct={})),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}(Wct||(Wct={})),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={}))}(Wct||(Wct={})),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,d=l.b,p=l.c,m=l.d;switch(this.worldX=f*e+d*i+l.worldX,this.worldY=p*e+m*i+l.worldY,this.data.transformMode){case t.TransformMode.Normal:u=r+90+o;var g=t.MathUtils.cosDeg(r+a)*n,y=t.MathUtils.cosDeg(u)*s,v=t.MathUtils.sinDeg(r+a)*n,b=t.MathUtils.sinDeg(u)*s;return this.a=f*g+d*v,this.b=f*y+d*b,this.c=p*g+m*v,void(this.d=p*y+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;(C=f*f+p*p)>1e-4?(d=p*(C=Math.abs(f*m-d*p)/C),m=f*C,S=Math.atan2(p,f)*t.MathUtils.radDeg):(f=0,p=0,S=90-Math.atan2(m,d)*t.MathUtils.radDeg);var A=r+a-S,T=r+o-S+90;g=t.MathUtils.cosDeg(A)*n,y=t.MathUtils.cosDeg(T)*s,v=t.MathUtils.sinDeg(A)*n,b=t.MathUtils.sinDeg(T)*s,this.a=f*g-d*v,this.b=f*y-d*b,this.c=p*g+m*v,this.d=p*y+m*b;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var C,x=t.MathUtils.cosDeg(r),w=t.MathUtils.sinDeg(r),E=(f*x+d*w)/this.skeleton.scaleX,B=(p*x+m*w)/this.skeleton.scaleY;(C=Math.sqrt(E*E+B*B))>1e-5&&(C=1/C),E*=C,B*=C,C=Math.sqrt(E*E+B*B),this.data.transformMode==t.TransformMode.NoScale&&f*m-d*p<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(C=-C);var R=Math.PI/2+Math.atan2(B,E),D=Math.cos(R)*C,M=Math.sin(R)*C;g=t.MathUtils.cosDeg(a)*n,y=t.MathUtils.cosDeg(90+o)*s,v=t.MathUtils.sinDeg(a)*n,b=t.MathUtils.sinDeg(90+o)*s,this.a=E*g+D*v,this.b=E*y+D*b,this.c=B*g+M*v,this.d=B*y+M*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,d=h*this.b-c*this.d,p=u*this.c-_*this.a,m=u*this.d-_*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(f*f+p*p),this.ascaleX>1e-4){var g=f*m-d*p;this.ascaleY=g/this.ascaleX,this.ashearY=Math.atan2(f*d+p*m,g)*t.MathUtils.radDeg,this.arotation=Math.atan2(p,f)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(d*d+m*m),this.ashearY=0,this.arotation=90-Math.atan2(m,d)*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}(Wct||(Wct={})),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={}))}(Wct||(Wct={})),function(t){t.ConstraintData=function(t,e,i){this.name=t,this.order=e,this.skinRequired=i}}(Wct||(Wct={})),function(t){t.Event=function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}(Wct||(Wct={})),function(t){t.EventData=function(t){this.name=t}}(Wct||(Wct={})),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,d=Math.atan2(f,_)*t.MathUtils.radDeg-e.ashearX-e.arotation;e.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360);var p=e.ascaleX,m=e.ascaleY;if(n||s){var g=e.data.length*p,y=Math.sqrt(_*_+f*f);if(n&&y<g||s&&y>g&&g>1e-4){var v=(y/g-1)*o+1;p*=v,a&&(m*=v)}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+d*o,p,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,d=i.ascaleX,p=0,m=0,g=0;c<0?(c=-c,p=180,g=-1):(p=0,g=1),f<0&&(f=-f,g=-g),d<0?(d=-d,m=180):m=0;var y=i.ax,v=0,b=0,S=0,A=e.a,T=e.b,C=e.c,x=e.d,w=Math.abs(c-f)<=1e-4;w?(b=A*y+T*(v=i.ay)+e.worldX,S=C*y+x*v+e.worldY):(v=0,b=A*y+e.worldX,S=C*y+e.worldY);var E=e.parent;A=E.a,T=E.b,C=E.c;var B,R,D=1/(A*(x=E.d)-T*C),M=b-E.worldX,P=S-E.worldY,I=(M*x-P*T)*D-h,O=(P*A-M*C)*D-u,F=Math.sqrt(I*I+O*O),L=i.data.length*d;if(F<1e-4)return this.apply1(e,r,n,!1,a,!1,l),void i.updateWorldTransformWith(y,v,0,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY);var k=((M=r-E.worldX)*x-(P=n-E.worldY)*T)*D-h,V=(P*A-M*C)*D-u,N=k*k+V*V;if(0!=o){o*=c*(d+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=(k-=(U=(z-o*(1-U*U))/G)*k)*k+(V-=U*V)*V}}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)),R=Math.acos(H)*s,A=F+L*H,T=L*Math.sin(R),B=Math.atan2(V*A-k*T,k*A+V*T)}else{var X=(A=c*L)*A,W=(T=f*L)*T,j=Math.atan2(V,k),Y=-2*W*F,q=W-X;if((x=Y*Y-4*q*(C=W*F*F+X*N-X*W))>=0){var K=Math.sqrt(x);Y<0&&(K=-K);var J=(K=-(Y+K)/2)/q,Z=C/K,Q=Math.abs(J)<Math.abs(Z)?J:Z;if(Q*Q<=N){P=Math.sqrt(N-Q*Q)*s,B=j-Math.atan2(P,Q),R=Math.atan2(P/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;(C=-A*F/(X-W))>=-1&&C<=1&&(C=Math.acos(C),(x=(M=A*Math.cos(C)+F)*M+(P=T*Math.sin(C))*P)<et&&($=C,et=x,tt=M,it=P),x>st&&(rt=C,st=x,nt=M,at=P)),N<=(et+st)/2?(B=j-Math.atan2(it*s,tt),R=$*s):(B=j-Math.atan2(at*s,nt),R=rt*s)}var ot=Math.atan2(v,y)*g,lt=e.arotation;(B=(B-ot)*t.MathUtils.radDeg+p-lt)>180?B-=360:B<-180&&(B+=360),e.updateWorldTransformWith(h,u,lt+B*l,_,e.ascaleY,0,0),lt=i.arotation,(R=((R+ot)*t.MathUtils.radDeg-i.ashearX)*g+m-lt)>180?R-=360:R<-180&&(R+=360),i.updateWorldTransformWith(y,v,lt+R*l,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e}();t.IkConstraint=e}(Wct||(Wct={})),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 jct(e,t),e}(t.ConstraintData);t.IkConstraintData=e}(Wct||(Wct={})),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,d=t.Utils.setArraySize(this.spaces,_),p=null,m=this.spacing;if(u||!o){u&&(p=t.Utils.setArraySize(this.lengths,c));for(var g=a.spacingMode==t.SpacingMode.Length,y=0,v=_-1;y<v;){var b=(M=f[y]).data.length;if(b<e.epsilon)u&&(p[y]=0),d[++y]=0;else if(o){if(u){var S=b*M.a,A=b*M.c,T=Math.sqrt(S*S+A*A);p[y]=T}d[++y]=m}else{S=b*M.a,A=b*M.c;var C=Math.sqrt(S*S+A*A);u&&(p[y]=C),d[++y]=(g?b+m:m)*C/b}}}else for(y=1;y<_;y++)d[y]=m;var x=this.computeWorldPositions(i,_,h,a.positionMode==t.PositionMode.Percent,o),w=x[0],E=x[1],B=a.offsetRotation,R=!1;0==B?R=l==t.RotateMode.Chain:(R=!1,B*=(D=this.target.bone).a*D.d-D.b*D.c>0?t.MathUtils.degRad:-t.MathUtils.degRad),y=0;for(var D=3;y<c;y++,D+=3){var M;(M=f[y]).worldX+=(w-M.worldX)*n,M.worldY+=(E-M.worldY)*n;var P=(S=x[D])-w,I=(A=x[D+1])-E;if(u){var O=p[y];if(0!=O){var F=(Math.sqrt(P*P+I*I)/O-1)*r+1;M.a*=F,M.c*=F}}if(w=S,E=A,s){var L=M.a,k=M.b,V=M.c,N=M.d,G=0,z=0,U=0;if(G=h?x[D-1]:0==d[y+1]?x[D+2]:Math.atan2(I,P),G-=Math.atan2(V,L),R){z=Math.cos(G),U=Math.sin(G);var H=M.data.length;w+=(H*(z*L-U*V)-P)*r,E+=(H*(U*L+z*V)-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),M.a=z*L-U*V,M.b=z*k-U*N,M.c=U*L+z*V,M.d=U*k+z*N}M.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,d=f/6,p=e.NONE;if(!i.constantSpeed){var m=i.lengths,g=m[d-=_?1:2];if(s&&(l*=g),a)for(var y=1;y<r;y++)h[y]*=g;c=t.Utils.setArraySize(this.world,8),y=0;for(var v=0,b=0;y<r;y++,v+=3){var S=l+=W=h[y];if(_)(S%=g)<0&&(S+=g),b=0;else{if(S<0){p!=e.BEFORE&&(p=e.BEFORE,i.computeWorldVertices(o,2,4,c,0,2)),this.addBeforePosition(S,c,0,u,v);continue}if(S>g){p!=e.AFTER&&(p=e.AFTER,i.computeWorldVertices(o,f-6,4,c,0,2)),this.addAfterPosition(S-g,c,0,u,v);continue}}for(;;b++){var A=m[b];if(!(S>A)){0==b?S/=A:S=(S-(K=m[b-1]))/(A-K);break}}b!=p&&(p=b,_&&b==d?(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||y>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]):(d--,f-=4,c=t.Utils.setArraySize(this.world,f),i.computeWorldVertices(o,2,f,c,0,2));for(var T=t.Utils.setArraySize(this.curves,d),C=0,x=c[0],w=c[1],E=0,B=0,R=0,D=0,M=0,P=0,I=0,O=0,F=0,L=0,k=0,V=0,N=0,G=0,z=(y=0,2);y<d;y++,z+=6)E=c[z],B=c[z+1],R=c[z+2],D=c[z+3],k=2*(I=.1875*(x-2*E+R))+(F=.09375*(3*(E-R)-x+(M=c[z+4]))),V=2*(O=.1875*(w-2*B+D))+(L=.09375*(3*(B-D)-w+(P=c[z+5]))),N=.75*(E-x)+I+.16666667*F,G=.75*(B-w)+O+.16666667*L,C+=Math.sqrt(N*N+G*G),N+=k,G+=V,k+=F,V+=L,C+=Math.sqrt(N*N+G*G),N+=k,G+=V,C+=Math.sqrt(N*N+G*G),N+=k+F,G+=V+L,C+=Math.sqrt(N*N+G*G),T[y]=C,x=M,w=P;if(l*=s?C:C/i.lengths[d-1],a)for(y=1;y<r;y++)h[y]*=C;for(var U=this.segments,H=0,X=(y=0,v=0,b=0,0);y<r;y++,v+=3){var W;if(S=l+=W=h[y],_)(S%=C)<0&&(S+=C),b=0;else{if(S<0){this.addBeforePosition(S,c,0,u,v);continue}if(S>C){this.addAfterPosition(S-C,c,f-4,u,v);continue}}for(;;b++){var j=T[b];if(!(S>j)){0==b?S/=j:S=(S-(K=T[b-1]))/(j-K);break}}if(b!=p){p=b;var Y=6*b;for(x=c[Y],w=c[Y+1],E=c[Y+2],B=c[Y+3],R=c[Y+4],D=c[Y+5],k=2*(I=.03*(x-2*E+R))+(F=.006*(3*(E-R)-x+(M=c[Y+6]))),V=2*(O=.03*(w-2*B+D))+(L=.006*(3*(B-D)-w+(P=c[Y+7]))),N=.3*(E-x)+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+=k,G+=V,k+=F,V+=L,H+=Math.sqrt(N*N+G*G),U[Y]=H;N+=k,G+=V,H+=Math.sqrt(N*N+G*G),U[8]=H,N+=k+F,G+=V+L,H+=Math.sqrt(N*N+G*G),U[9]=H,X=0}for(S*=H;;X++){var q=U[X];if(!(S>q)){var K;0==X?S/=q:S=X+(S-(K=U[X-1]))/(q-K);break}}this.addCurvePosition(.1*S,x,w,E,B,R,D,M,P,u,v,n||y>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,d=1-t,p=d*d,m=p*d,g=d*t,y=3*g,v=d*y,b=y*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*p+n*g*2+a*_),S-(e*p+r*g*2+s*_)))},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e.epsilon=1e-5,e}();t.PathConstraint=e}(Wct||(Wct={})),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 jct(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"}(Wct||(Wct={})),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}(Wct||(Wct={})),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,d=c.getAttachment();if(d instanceof t.RegionAttachment)_=8,f=t.Utils.setArraySize(r,_,0),d.computeWorldVertices(c.bone,f,0,2);else if(d instanceof t.MeshAttachment){var p=d;_=p.worldVerticesLength,f=t.Utils.setArraySize(r,_,0),p.computeWorldVertices(c,0,_,f,0,2)}if(null!=f)for(var m=0,g=f.length;m<g;m+=2){var y=f[m],v=f[m+1];s=Math.min(s,y),a=Math.min(a,v),o=Math.max(o,y),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}(Wct||(Wct={})),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)];(d=new t.BoneData(h,u,c)).rotation=a.readFloat(),d.x=a.readFloat()*n,d.y=a.readFloat()*n,d.scaleX=a.readFloat(),d.scaleY=a.readFloat(),d.shearX=a.readFloat(),d.shearY=a.readFloat(),d.length=a.readFloat()*n,d.transformMode=e.TransformModeValues[a.readInt(!0)],d.skinRequired=a.readBoolean(),o&&t.Color.rgba8888ToColor(d.color,a.readInt32()),s.bones.push(d)}for(l=a.readInt(!0),h=0;h<l;h++){var _=a.readString(),f=s.bones[a.readInt(!0)],d=new t.SlotData(h,_,f);t.Color.rgba8888ToColor(d.color,a.readInt32());var p=a.readInt32();-1!=p&&t.Color.rgb888ToColor(d.darkColor=new t.Color,p),d.attachmentName=a.readStringRef(),d.blendMode=e.BlendModeValues[a.readInt(!0)],s.slots.push(d)}l=a.readInt(!0),h=0;for(var m=void 0;h<l;h++){(d=new t.IkConstraintData(a.readString())).order=a.readInt(!0),d.skinRequired=a.readBoolean(),m=a.readInt(!0);for(var g=0;g<m;g++)d.bones.push(s.bones[a.readInt(!0)]);d.target=s.bones[a.readInt(!0)],d.mix=a.readFloat(),d.softness=a.readFloat()*n,d.bendDirection=a.readByte(),d.compress=a.readBoolean(),d.stretch=a.readBoolean(),d.uniform=a.readBoolean(),s.ikConstraints.push(d)}for(l=a.readInt(!0),h=0,m=void 0;h<l;h++){for((d=new t.TransformConstraintData(a.readString())).order=a.readInt(!0),d.skinRequired=a.readBoolean(),m=a.readInt(!0),g=0;g<m;g++)d.bones.push(s.bones[a.readInt(!0)]);d.target=s.bones[a.readInt(!0)],d.local=a.readBoolean(),d.relative=a.readBoolean(),d.offsetRotation=a.readFloat(),d.offsetX=a.readFloat()*n,d.offsetY=a.readFloat()*n,d.offsetScaleX=a.readFloat(),d.offsetScaleY=a.readFloat(),d.offsetShearY=a.readFloat(),d.rotateMix=a.readFloat(),d.translateMix=a.readFloat(),d.scaleMix=a.readFloat(),d.shearMix=a.readFloat(),s.transformConstraints.push(d)}for(l=a.readInt(!0),h=0,m=void 0;h<l;h++){for((d=new t.PathConstraintData(a.readString())).order=a.readInt(!0),d.skinRequired=a.readBoolean(),m=a.readInt(!0),g=0;g<m;g++)d.bones.push(s.bones[a.readInt(!0)]);d.target=s.slots[a.readInt(!0)],d.positionMode=e.PositionModeValues[a.readInt(!0)],d.spacingMode=e.SpacingModeValues[a.readInt(!0)],d.rotateMode=e.RotateModeValues[a.readInt(!0)],d.offsetRotation=a.readFloat(),d.position=a.readFloat(),d.positionMode==t.PositionMode.Fixed&&(d.position*=n),d.spacing=a.readFloat(),d.spacingMode!=t.SpacingMode.Length&&d.spacingMode!=t.SpacingMode.Fixed||(d.spacing*=n),d.rotateMix=a.readFloat(),d.translateMix=a.readFloat(),s.pathConstraints.push(d)}var y=this.readSkin(a,s,!0,o);for(null!=y&&(s.defaultSkin=y,s.skins.push(y)),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++)(d=new t.EventData(a.readStringRef())).intValue=a.readInt(!1),d.floatValue=a.readFloat(),d.stringValue=a.readString(),d.audioPath=a.readString(),null!=d.audioPath&&(d.volume=a.readFloat(),d.balance=a.readFloat()),s.events.push(d);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(),d=i.readFloat(),p=i.readFloat(),m=i.readFloat(),g=i.readFloat(),y=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=d*h,S.y=p*h,S.scaleX=m,S.scaleY=g,S.rotation=f,S.width=y*h,S.height=v*h,t.Color.rgba8888ToColor(S.color,b),S.updateOffset(),S);case t.AttachmentType.BoundingBox:var A=i.readInt(!0),T=this.readVertices(i,A),C=(b=l?i.readInt32():0,this.attachmentLoader.newBoundingBoxAttachment(s,u));return null==C?null:(C.worldVerticesLength=A<<1,C.vertices=T.vertices,C.bones=T.bones,l&&t.Color.rgba8888ToColor(C.color,b),C);case t.AttachmentType.Mesh:_=i.readStringRef(),b=i.readInt32(),A=i.readInt(!0);var x=this.readFloatArray(i,A<<1,1),w=this.readShortArray(i),E=(T=this.readVertices(i,A),i.readInt(!0)),B=null;return y=0,v=0,l&&(B=this.readShortArray(i),y=i.readFloat(),v=i.readFloat()),null==_&&(_=u),null==(R=this.attachmentLoader.newMeshAttachment(s,u,_))?null:(R.path=_,t.Color.rgba8888ToColor(R.color,b),R.bones=T.bones,R.vertices=T.vertices,R.worldVerticesLength=A<<1,R.triangles=w,R.regionUVs=x,R.updateUVs(),R.hullLength=E<<1,l&&(R.edges=B,R.width=y*h,R.height=v*h),R);case t.AttachmentType.LinkedMesh:_=i.readStringRef(),b=i.readInt32();var R,D=i.readStringRef(),M=i.readStringRef(),P=i.readBoolean();return y=0,v=0,l&&(y=i.readFloat(),v=i.readFloat()),null==_&&(_=u),null==(R=this.attachmentLoader.newMeshAttachment(s,u,_))?null:(R.path=_,t.Color.rgba8888ToColor(R.color,b),l&&(R.width=y*h,R.height=v*h),this.linkedMeshes.push(new r(R,D,a,M,P)),R);case t.AttachmentType.Path:for(var I=i.readBoolean(),O=i.readBoolean(),F=(A=i.readInt(!0),T=this.readVertices(i,A),t.Utils.newArray(A/3,0)),L=0,k=F.length;L<k;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=T.vertices,_.bones=T.bones,_.lengths=F,l&&t.Color.rgba8888ToColor(_.color,b),_);case t.AttachmentType.Point:f=i.readFloat(),d=i.readFloat(),p=i.readFloat(),b=l?i.readInt32():0;var V=this.attachmentLoader.newPointAttachment(s,u);return null==V?null:(V.x=d*h,V.y=p*h,V.rotation=f,l&&t.Color.rgba8888ToColor(V.color,b),V);case t.AttachmentType.Clipping:var N=i.readInt(!0),G=(A=i.readInt(!0),T=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=T.vertices,G.bones=T.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,d=i.readInt(!0);f<d;f++){var p=i.readByte(),m=i.readInt(!0);switch(p){case e.SLOT_ATTACHMENT:(b=new t.AttachmentTimeline(m)).slotIndex=_;for(var g=0;g<m;g++)b.setFrame(g,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=_,g=0;g<m;g++){var y=i.readFloat();t.Color.rgba8888ToColor(l,i.readInt32()),b.setFrame(g,y,l.r,l.g,l.b,l.a),g<m-1&&this.readCurve(i,g,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=_,g=0;g<m;g++)y=i.readFloat(),t.Color.rgba8888ToColor(l,i.readInt32()),t.Color.rgb888ToColor(h,i.readInt32()),b.setFrame(g,y,l.r,l.g,l.b,l.a,h.r,h.g,h.b),g<m-1&&this.readCurve(i,g,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,d=i.readInt(!0);f<d;f++)switch(p=i.readByte(),m=i.readInt(!0),p){case e.BONE_ROTATE:for((b=new t.RotateTimeline(m)).boneIndex=v,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat()),g<m-1&&this.readCurve(i,g,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(p==e.BONE_SCALE?b=new t.ScaleTimeline(m):p==e.BONE_SHEAR?b=new t.ShearTimeline(m):(b=new t.TranslateTimeline(m),S=a),b.boneIndex=v,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat()*S,i.readFloat()*S),g<m-1&&this.readCurve(i,g,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,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat(),i.readFloat()*a,i.readByte(),i.readBoolean(),i.readBoolean()),g<m-1&&this.readCurve(i,g,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,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat()),g<m-1&&this.readCurve(i,g,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 T=n.pathConstraints[A];for(f=0,d=i.readInt(!0);f<d;f++)switch(p=i.readByte(),m=i.readInt(!0),p){case e.PATH_POSITION:case e.PATH_SPACING:for(b=void 0,S=1,p==e.PATH_SPACING?(b=new t.PathConstraintSpacingTimeline(m),T.spacingMode!=t.SpacingMode.Length&&T.spacingMode!=t.SpacingMode.Fixed||(S=a)):(b=new t.PathConstraintPositionTimeline(m),T.positionMode==t.PositionMode.Fixed&&(S=a)),b.pathConstraintIndex=A,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat()*S),g<m-1&&this.readCurve(i,g,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,g=0;g<m;g++)b.setFrame(g,i.readFloat(),i.readFloat(),i.readFloat()),g<m-1&&this.readCurve(i,g,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 C=n.skins[i.readInt(!0)];for(f=0,d=i.readInt(!0);f<d;f++){_=i.readInt(!0);for(var x=0,w=i.readInt(!0);x<w;x++){var E=C.getAttachment(_,i.readStringRef()),B=null!=E.bones,R=E.vertices,D=B?R.length/3*2:R.length;for(m=i.readInt(!0),(b=new t.DeformTimeline(m)).slotIndex=_,b.attachment=E,g=0;g<m;g++){y=i.readFloat();var M=void 0,P=i.readInt(!0);if(0==P)M=B?t.Utils.newFloatArray(D):R;else{M=t.Utils.newFloatArray(D);var I=i.readInt(!0);if(P+=I,1==a)for(var O=I;O<P;O++)M[O]=i.readFloat();else for(O=I;O<P;O++)M[O]=i.readFloat()*a;if(!B){O=0;for(var F=M.length;O<F;O++)M[O]+=R[O]}}b.setFrame(g,y,M),g<m-1&&this.readCurve(i,g,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 k=n.slots.length;for(u=0;u<L;u++){y=i.readFloat();var V=i.readInt(!0),N=t.Utils.newArray(k,0);for(f=k-1;f>=0;f--)N[f]=-1;var G=t.Utils.newArray(k-V,0),z=0,U=0;for(f=0;f<V;f++){for(_=i.readInt(!0);z!=_;)G[U++]=z++;N[z+i.readInt(!0)]=z++}for(;z<k;)G[U++]=z++;for(f=k-1;f>=0;f--)-1==N[f]&&(N[f]=G[--U]);b.setFrame(u,y,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++){y=i.readFloat();var X=n.events[i.readInt(!0)],W=new t.Event(y,X);W.intValue=i.readInt(!1),W.floatValue=i.readFloat(),W.stringValue=i.readBoolean()?i.readString():X.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}}(Wct||(Wct={})),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[_],d=s[_+1],p=u*d-c*f,m=u-f,g=c-d,y=o*g-l*m,v=(h*m-o*p)/y;if((v>=u&&v<=f||v>=f&&v<=u)&&(v>=e&&v<=r||v>=r&&v<=e)){var b=(h*g-l*p)/y;if((b>=c&&b<=d||b>=d&&b<=c)&&(b>=i&&b<=n||b>=n&&b<=i))return!0}u=f,c=d}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}(Wct||(Wct={})),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,d=this.clippedTriangles,p=this.clippingPolygons,m=this.clippingPolygons.length,g=l?12:8,y=0;f.length=0,d.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],T=s[b+c],C=s[b+c+1],x=e[(b=r[v+1]*h)+u],w=e[b+u+1],E=s[b+c],B=s[b+c+1],R=e[(b=r[v+2]*h)+u],D=e[b+u+1],M=s[b+c],P=s[b+c+1],I=0;I<m;I++){var O=f.length;if(!this.clip(S,A,x,w,R,D,p[I],_)){(H=t.Utils.setArraySize(f,O+3*g))[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]=T,H[O+7]=C,H[O+8]=o.r,H[O+9]=o.g,H[O+10]=o.b,H[O+11]=o.a,H[O+12]=x,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]=R,H[O+25]=D,H[O+26]=a.r,H[O+27]=a.g,H[O+28]=a.b,H[O+29]=a.a,H[O+30]=M,H[O+31]=P,H[O+32]=o.r,H[O+33]=o.g,H[O+34]=o.b,H[O+35]=o.a):(H[O+6]=T,H[O+7]=C,H[O+8]=x,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]=R,H[O+17]=D,H[O+18]=a.r,H[O+19]=a.g,H[O+20]=a.b,H[O+21]=a.a,H[O+22]=M,H[O+23]=P),O=d.length,(Q=t.Utils.setArraySize(d,O+3))[O]=y,Q[O+1]=y+1,Q[O+2]=y+2,y+=3;continue t}var F=_.length;if(0!=F){for(var L=w-D,k=R-x,V=S-R,N=D-A,G=1/(L*V+k*(A-D)),z=F>>1,U=this.clipOutput,H=t.Utils.setArraySize(f,O+z*g),X=0;X<F;X+=2){var W=U[X],j=U[X+1];H[O]=W,H[O+1]=j,H[O+2]=a.r,H[O+3]=a.g,H[O+4]=a.b,H[O+5]=a.a;var Y=W-R,q=j-D,K=(L*Y+k*q)*G,J=(N*Y+V*q)*G,Z=1-K-J;H[O+6]=T*K+E*J+M*Z,H[O+7]=C*K+B*J+P*Z,l&&(H[O+8]=o.r,H[O+9]=o.g,H[O+10]=o.b,H[O+11]=o.a),O+=g}O=d.length;var Q=t.Utils.setArraySize(d,O+3*(z-2));for(z--,X=1;X<z;X++)Q[O]=y,Q[O+1]=y+X,Q[O+2]=y+X+1,O+=3;y+=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 d=c[f],p=c[f+1],m=c[f+2],g=c[f+3],y=d-m,v=p-g,b=u,S=u.length-2,A=o.length,T=0;T<S;T+=2){var C=b[T],x=b[T+1],w=b[T+2],E=b[T+3],B=y*(E-g)-v*(w-m)>0;if(y*(x-g)-v*(C-m)>0){if(B){o.push(w),o.push(E);continue}var R=(M=E-x)*(m-d)-(P=w-C)*(g-p);if(Math.abs(R)>1e-6){var D=(P*(p-x)-M*(d-C))/R;o.push(d+(m-d)*D),o.push(p+(g-p)*D)}else o.push(d),o.push(p)}else if(B){var M,P;R=(M=E-x)*(m-d)-(P=w-C)*(g-p),Math.abs(R)>1e-6?(D=(P*(p-x)-M*(d-C))/R,o.push(d+(m-d)*D),o.push(p+(g-p)*D)):(o.push(d),o.push(p)),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}(Wct||(Wct={})),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}(Wct||(Wct={})),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);(d=new t.BoneData(n.bones.length,l.name,h)).length=this.getValue(l,"length",0)*r,d.x=this.getValue(l,"x",0)*r,d.y=this.getValue(l,"y",0)*r,d.rotation=this.getValue(l,"rotation",0),d.scaleX=this.getValue(l,"scaleX",1),d.scaleY=this.getValue(l,"scaleY",1),d.shearX=this.getValue(l,"shearX",0),d.shearY=this.getValue(l,"shearY",0),d.transformMode=e.transformModeFromString(this.getValue(l,"transform","normal")),d.skinRequired=this.getValue(l,"skin",!1),n.bones.push(d)}if(s.slots)for(o=0;o<s.slots.length;o++){var c=(R=s.slots[o]).name,_=R.bone,f=n.findBone(_);if(null==f)throw new Error("Slot bone not found: "+_);var d=new t.SlotData(n.slots.length,c,f),p=this.getValue(R,"color",null);null!=p&&d.color.setFromString(p);var m=this.getValue(R,"dark",null);null!=m&&(d.darkColor=new t.Color(1,1,1,1),d.darkColor.setFromString(m)),d.attachmentName=this.getValue(R,"attachment",null),d.blendMode=e.blendModeFromString(this.getValue(R,"blend","normal")),n.slots.push(d)}if(s.ik)for(o=0;o<s.ik.length;o++){var g=s.ik[o];(d=new t.IkConstraintData(g.name)).order=this.getValue(g,"order",0),d.skinRequired=this.getValue(g,"skin",!1);for(var y=0;y<g.bones.length;y++){if(_=g.bones[y],null==(w=n.findBone(_)))throw new Error("IK bone not found: "+_);d.bones.push(w)}var v=g.target;if(d.target=n.findBone(v),null==d.target)throw new Error("IK target bone not found: "+v);d.mix=this.getValue(g,"mix",1),d.softness=this.getValue(g,"softness",0)*r,d.bendDirection=this.getValue(g,"bendPositive",!0)?1:-1,d.compress=this.getValue(g,"compress",!1),d.stretch=this.getValue(g,"stretch",!1),d.uniform=this.getValue(g,"uniform",!1),n.ikConstraints.push(d)}if(s.transform)for(o=0;o<s.transform.length;o++){for(g=s.transform[o],(d=new t.TransformConstraintData(g.name)).order=this.getValue(g,"order",0),d.skinRequired=this.getValue(g,"skin",!1),y=0;y<g.bones.length;y++){if(_=g.bones[y],null==(w=n.findBone(_)))throw new Error("Transform constraint bone not found: "+_);d.bones.push(w)}if(v=g.target,d.target=n.findBone(v),null==d.target)throw new Error("Transform constraint target bone not found: "+v);d.local=this.getValue(g,"local",!1),d.relative=this.getValue(g,"relative",!1),d.offsetRotation=this.getValue(g,"rotation",0),d.offsetX=this.getValue(g,"x",0)*r,d.offsetY=this.getValue(g,"y",0)*r,d.offsetScaleX=this.getValue(g,"scaleX",0),d.offsetScaleY=this.getValue(g,"scaleY",0),d.offsetShearY=this.getValue(g,"shearY",0),d.rotateMix=this.getValue(g,"rotateMix",1),d.translateMix=this.getValue(g,"translateMix",1),d.scaleMix=this.getValue(g,"scaleMix",1),d.shearMix=this.getValue(g,"shearMix",1),n.transformConstraints.push(d)}if(s.path)for(o=0;o<s.path.length;o++){for(g=s.path[o],(d=new t.PathConstraintData(g.name)).order=this.getValue(g,"order",0),d.skinRequired=this.getValue(g,"skin",!1),y=0;y<g.bones.length;y++){if(_=g.bones[y],null==(w=n.findBone(_)))throw new Error("Transform constraint bone not found: "+_);d.bones.push(w)}if(v=g.target,d.target=n.findSlot(v),null==d.target)throw new Error("Path target slot not found: "+v);d.positionMode=e.positionModeFromString(this.getValue(g,"positionMode","percent")),d.spacingMode=e.spacingModeFromString(this.getValue(g,"spacingMode","length")),d.rotateMode=e.rotateModeFromString(this.getValue(g,"rotateMode","tangent")),d.offsetRotation=this.getValue(g,"rotation",0),d.position=this.getValue(g,"position",0),d.positionMode==t.PositionMode.Fixed&&(d.position*=r),d.spacing=this.getValue(g,"spacing",0),d.spacingMode!=t.SpacingMode.Length&&d.spacingMode!=t.SpacingMode.Fixed||(d.spacing*=r),d.rotateMix=this.getValue(g,"rotateMix",1),d.translateMix=this.getValue(g,"translateMix",1),n.pathConstraints.push(d)}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 T=b[o],C=new t.Skin(T.name);if(T.bones)for(var x=0;x<T.bones.length;x++){var w;if(null==(w=n.findBone(T.bones[x])))throw new Error("Skin bone not found: "+T.bones[o]);C.bones.push(w)}if(T.ik)for(x=0;x<T.ik.length;x++){if(null==(E=n.findIkConstraint(T.ik[x])))throw new Error("Skin IK constraint not found: "+T.ik[o]);C.constraints.push(E)}if(T.transform)for(x=0;x<T.transform.length;x++){if(null==(E=n.findTransformConstraint(T.transform[x])))throw new Error("Skin transform constraint not found: "+T.transform[o]);C.constraints.push(E)}if(T.path)for(x=0;x<T.path.length;x++){var E;if(null==(E=n.findPathConstraint(T.path[x])))throw new Error("Skin path constraint not found: "+T.path[o]);C.constraints.push(E)}for(var c in T.attachments){var B=n.findSlot(c);if(null==B)throw new Error("Slot not found: "+c);var R=T.attachments[c];for(var D in R){var M=this.readAttachment(R[D],C,B.index,D,n);null!=M&&C.setAttachment(B.index,D,M)}}n.skins.push(C),"default"==C.name&&(n.defaultSkin=C)}}o=0;for(var P=this.linkedMeshes.length;o<P;o++){var I=this.linkedMeshes[o];if(null==(C=null==I.skin?n.defaultSkin:n.findSkin(I.skin)))throw new Error("Skin not found: "+I.skin);var O=C.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];(d=new t.EventData(F)).intValue=this.getValue(L,"int",0),d.floatValue=this.getValue(L,"float",0),d.stringValue=this.getValue(L,"string",""),d.audioPath=this.getValue(L,"audio",null),null!=d.audioPath&&(d.volume=this.getValue(L,"volume",1),d.balance=this.getValue(L,"balance",0)),n.events.push(d)}if(s.animations)for(var k in s.animations){var V=s.animations[k];this.readAnimation(V,k,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 d=e.vertexCount;this.readVertices(e,l,d<<1);for(var p=t.Utils.newArray(d/3,0),m=0;m<e.lengths.length;m++)p[m]=e.lengths[m]*o;return l.lengths=p,null!=(v=this.getValue(e,"color",null))&&l.color.setFromString(v),l;case"point":var g=this.attachmentLoader.newPointAttachment(r,s);return null==g?null:(g.x=this.getValue(e,"x",0)*o,g.y=this.getValue(e,"y",0)*o,g.rotation=this.getValue(e,"rotation",0),null!=(v=this.getValue(e,"color",null))&&g.color.setFromString(v),g);case"clipping":var y=this.attachmentLoader.newClippingAttachment(r,s);if(null==y)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);y.endSlot=S}return d=e.vertexCount,this.readVertices(e,y,d<<1),null!=(v=this.getValue(e,"color",null))&&y.color.setFromString(v),y}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 d=new t.Color;d.setFromString(f.color),b.setFrame(c,this.getValue(f,"time",0),d.r,d.g,d.b,d.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 p=new t.Color,m=new t.Color;p.setFromString(f.light),m.setFromString(f.dark),b.setFrame(c,this.getValue(f,"time",0),p.r,p.g,p.b,p.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 g in e.bones){var y=e.bones[g],v=r.findBoneIndex(g);if(-1==v)throw new Error("Bone not found: "+g);for(var h in y)if(u=y[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+" ("+g+")");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 T=this.getValue(f,"x",A),C=this.getValue(f,"y",A);b.setFrame(c,this.getValue(f,"time",0),T*S,C*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 x in e.ik){var w=e.ik[x],E=r.findIkConstraint(x);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 x in e.transform){for(w=e.transform[x],E=r.findTransformConstraint(x),(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 x in B){w=B[x];var R=r.findPathConstraintIndex(x);if(-1==R)throw new Error("Path constraint not found: "+x);var D=r.pathConstraints[R];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),D.spacingMode!=t.SpacingMode.Length&&D.spacingMode!=t.SpacingMode.Fixed||(S=n)):(b=new t.PathConstraintPositionTimeline(u.length),D.positionMode==t.PositionMode.Fixed&&(S=n)),b.pathConstraintIndex=R,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=R,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 M in e.deform){var P=e.deform[M],I=r.findSkin(M);if(null==I)throw new Error("Skin not found: "+M);for(var o in P){if(l=P[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,k=F?L.length/3*2:L.length;(b=new t.DeformTimeline(u.length)).slotIndex=Z,b.attachment=O,c=0;for(var V=0;V<u.length;V++){f=u[V];var N=void 0,G=this.getValue(f,"vertices",null);if(null==G)N=F?t.Utils.newFloatArray(k):L;else{N=t.Utils.newFloatArray(k);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;_<k;_++)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 X=r.slots.length;for(c=0,V=0;V<H.length;V++){var W=H[V],j=null,Y=this.getValue(W,"offsets",null);if(null!=Y){j=t.Utils.newArray(X,-1);var q=t.Utils.newArray(X-Y.length,0),K=0,J=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(;K!=Z;)q[J++]=K++;j[K+Q.offset]=K++}for(;K<X;)q[J++]=K++;for(_=X-1;_>=0;_--)-1==j[_]&&(j[_]=q[--J])}b.setFrame(c++,this.getValue(W,"time",0),j)}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}}(Wct||(Wct={})),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}(Wct||(Wct={})),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}(Wct||(Wct={})),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}}(Wct||(Wct={})),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 jct(e,t),e.prototype.setFilters=function(){},e.prototype.setWraps=function(){},e.prototype.dispose=function(){},e}(r);t.FakeTexture=n}(Wct||(Wct={})),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 d=parseInt(o[0]),p=parseInt(o[1]);u.u=_/l.width,u.v=f/l.height,u.rotate?(u.u2=(_+p)/l.width,u.v2=(f+d)/l.height):(u.u2=(_+d)/l.width,u.v2=(f+p)/l.height),u.x=_,u.y=f,u.width=Math.abs(d),u.height=Math.abs(p),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 jct(e,t),e}(t.TextureRegion);t.TextureAtlasRegion=n}(Wct||(Wct={})),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,d=0,p=f.length;d<p;d++){var m=f[d],g=!1;if(0!=e){var y=m.a,v=m.b,b=m.c,S=m.d;(E=Math.atan2(l,a)-Math.atan2(b,y)+c)>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E*=e;var A=Math.cos(E),T=Math.sin(E);m.a=A*y-T*b,m.b=A*v-T*S,m.c=T*y+A*b,m.d=T*v+A*S,g=!0}if(0!=i){var C=this.temp;s.localToWorld(C.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(C.x-m.worldX)*i,m.worldY+=(C.y-m.worldY)*i,g=!0}if(r>0){var x=Math.sqrt(m.a*m.a+m.c*m.c),w=Math.sqrt(a*a+l*l);x>1e-5&&(x=(x+(w-x+this.data.offsetScaleX)*r)/x),m.a*=x,m.c*=x,x=Math.sqrt(m.b*m.b+m.d*m.d),w=Math.sqrt(o*o+h*h),x>1e-5&&(x=(x+(w-x+this.data.offsetScaleY)*r)/x),m.b*=x,m.d*=x,g=!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,x=Math.sqrt(v*v+S*S),m.b=Math.cos(E)*x,m.d=Math.sin(E)*x,g=!0}g&&(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,d=0,p=f.length;d<p;d++){var m,g=f[d],y=!1;if(0!=e){var v=g.a,b=g.b,S=g.c,A=g.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 T=Math.cos(m),C=Math.sin(m);g.a=T*v-C*S,g.b=T*b-C*A,g.c=C*v+T*S,g.d=C*b+T*A,y=!0}if(0!=i){var x=this.temp;s.localToWorld(x.set(this.data.offsetX,this.data.offsetY)),g.worldX+=x.x*i,g.worldY+=x.y*i,y=!0}if(r>0){var w=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleX)*r+1;g.a*=w,g.c*=w,w=(Math.sqrt(o*o+h*h)-1+this.data.offsetScaleY)*r+1,g.b*=w,g.d*=w,y=!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=g.b,A=g.d,m=Math.atan2(A,b)+(m-t.MathUtils.PI/2+_)*n,w=Math.sqrt(b*b+A*A),g.b=Math.cos(m)*w,g.d=Math.sin(m)*w,y=!0;y&&(g.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,d=l.ascaleY;0!=i&&(f>1e-5&&(f=(f+(n.ascaleX-f+this.data.offsetScaleX)*i)/f),d>1e-5&&(d=(d+(n.ascaleY-d+this.data.offsetScaleY)*i)/d));var p=l.ashearY;0!=r&&(u=n.ashearY-p+this.data.offsetShearY,u-=360*(16384-(16384.499999999996-u/360|0)),l.shearY+=u*r),l.updateWorldTransformWith(c,_,h,f,d,l.ashearX,p)}},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 d=l.ashearY;0!=r&&(d+=(n.ashearY+this.data.offsetShearY)*r),l.updateWorldTransformWith(u,c,h,_,f,l.ashearX,d)}},e}();t.TransformConstraint=e}(Wct||(Wct={})),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 jct(e,t),e}(t.ConstraintData);t.TransformConstraintData=e}(Wct||(Wct={})),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,d=i[c],p=i[c+1],m=i[_],g=i[_+1],y=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],T=i[S+1];if(e.positiveArea(y,v,d,p,A,T)&&e.positiveArea(d,p,m,g,A,T)&&e.positiveArea(m,g,y,v,A,T))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 C=(--r+s-1)%r,x=s==r?0:s;a[C]=e.isConcave(C,r,i,n),a[x]=e.isConcave(x,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,d=i[u+2]<<1,p=r[_],m=r[_+1],g=r[f],y=r[f+1],v=r[d],b=r[d+1],S=!1;if(l==_){var A=o.length-4,T=e.winding(o[A],o[A+1],o[A+2],o[A+3],v,b),C=e.winding(v,b,o[0],o[1],o[2],o[3]);T==h&&C==h&&(o.push(v),o.push(b),a.push(d),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(p),o.push(m),o.push(g),o.push(y),o.push(v),o.push(b),(a=this.polygonIndicesPool.obtain()).length=0,a.push(_),a.push(f),a.push(d),h=e.winding(p,m,g,y,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 x=a[0],w=a[a.length-1],E=(o=n[u])[A=o.length-4],B=o[A+1],R=o[A+2],D=o[A+3],M=o[0],P=o[1],I=o[2],O=o[3],F=e.winding(E,B,R,D,M,P),L=0;L<c;L++)if(L!=u){var k=s[L];if(3==k.length){var V=k[0],N=k[1],G=k[2],z=n[L];v=z[z.length-2],b=z[z.length-1],V==x&&N==w&&(T=e.winding(E,B,R,D,v,b),C=e.winding(v,b,M,P,I,O),T==F&&C==F&&(z.length=0,k.length=0,o.push(v),o.push(b),a.push(G),E=R,B=D,R=v,D=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}(Wct||(Wct={})),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 jct(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 jct(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=_}(Wct||(Wct={})),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 jct(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,C=3*c;B<i;B+=s){var d=0,p=0,m=h[u++];for(m+=u;u<m;u++,C+=3){b=f[h[u]],R=l[C],D=l[C+1];var g=l[C+2];d+=(R*b.a+D*b.b+b.worldX)*g,p+=(R*b.c+D*b.d+b.worldY)*g}r[B]=d,r[B+1]=p}else for(var y=o,v=(B=n,C=3*c,c<<1);B<i;B+=s){for(d=0,p=0,m=h[u++],m+=u;u<m;u++,C+=3,v+=2)b=f[h[u]],R=l[C]+y[v],D=l[C+1]+y[v+1],g=l[C+2],d+=(R*b.a+D*b.b+b.worldX)*g,p+=(R*b.c+D*b.d+b.worldY)*g;r[B]=d,r[B+1]=p}}else{o.length>0&&(l=o);for(var b,S=(b=t.bone).worldX,A=b.worldY,T=b.a,C=b.b,x=b.c,w=b.d,E=e,B=n;B<i;E+=2,B+=s){var R=l[E],D=l[E+1];r[B]=R*T+D*C+S,r[B+1]=R*x+D*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}(Wct||(Wct={})),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"}(Wct||(Wct={})),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 jct(i,e),i.prototype.copy=function(){var t=new i(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.BoundingBoxAttachment=e}(Wct||(Wct={})),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 jct(i,e),i.prototype.copy=function(){var t=new i(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.ClippingAttachment=e}(Wct||(Wct={})),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 jct(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}(Wct||(Wct={})),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 jct(i,e),i.prototype.copy=function(){var e=new i(this.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}(Wct||(Wct={})),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 jct(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(this.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}(Wct||(Wct={})),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 jct(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,d=s*l+this.x,p=s*h,m=a*l+this.y,g=a*h,y=this.offset;y[i.OX1]=u-f,y[i.OY1]=_+c,y[i.OX2]=u-g,y[i.OY2]=m+c,y[i.OX3]=d-g,y[i.OY3]=m+p,y[i.OX4]=d-f,y[i.OY4]=_+p},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(this.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}(Wct||(Wct={})),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}(Wct||(Wct={})),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}(Wct||(Wct={}));var Yct,qct,Kct,Jct,Zct,Qct,$ct=Wct,t_t=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}(),e_t=1/60,i_t=[],r_t=[],n_t=0,s_t=0,a_t=0,o_t=null,l_t=null,h_t=0,u_t=0,c_t=0,__t=0,f_t=null,d_t=null,p_t=0,m_t=0,g_t=new $ct.Color(1,1,1,1),y_t=new $ct.Color(1,1,1,1),v_t=[0,1,2,2,3,0],b_t=function(){function t(){this.frames=[],this.totalTime=0,this.isCompleted=!1,this.maxVertexCount=0,this.maxIndexCount=0,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(e_t),null==n||n.update(e_t),null==n||n.apply(i),null==i||i.updateWorldTransform(),this._frameIdx++,this.updateFrame(i,r,this._frameIdx),this.totalTime+=e_t}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(Jct=i.a*e.a*t.a*255,Yct=e.r*t.r*255,qct=e.g*t.g*255,Kct=e.b*t.b*255,g_t.r=Yct*i.r,g_t.g=qct*i.g,g_t.b=Kct*i.b,g_t.a=Jct,null==n.darkColor?y_t.set(0,0,0,1):(y_t.r=n.darkColor.r*Yct,y_t.g=n.darkColor.g*qct,y_t.b=n.darkColor.b*Kct),y_t.a=0,Zct=(g_t.a<<24>>>0)+(g_t.b<<16)+(g_t.g<<8)+g_t.r,Qct=(y_t.a<<24>>>0)+(y_t.b<<16)+(y_t.g<<8)+y_t.r,f_t!==Zct||d_t!==Qct){var s=this._tempColors;f_t=Zct,d_t=Qct,__t>0&&(s[__t-1].vfOffset=a_t),s[__t++]={fr:g_t.r,fg:g_t.g,fb:g_t.b,fa:g_t.a,dr:y_t.r,dg:y_t.g,db:y_t.b,da:y_t.a,vfOffset:0}}if(r.isClipping()){r.clipTriangles(i_t,p_t,r_t,m_t,i_t,g_t,y_t,!0,6,a_t,a_t+2);var a=r.clippedVertices,o=r.clippedTriangles;m_t=o.length,p_t=a.length/12*6;for(var l=0,h=s_t,u=o.length;l<u;)r_t[h++]=o[l++];for(var c=0,_=a.length,f=a_t;c<_;c+=12,f+=6)i_t[f]=a[c],i_t[f+1]=a[c+1],i_t[f+2]=a[c+6],i_t[f+3]=a[c+7],i_t[f+4]=Zct,i_t[f+5]=Qct}else for(var d=a_t,p=a_t+p_t;d<p;d+=6)i_t[d+4]=Zct,i_t[d+5]=Qct},e.updateFrame=function(t,e,i){a_t=0,n_t=0,s_t=0,o_t=null,l_t=null,h_t=0,u_t=0,c_t=0,__t=0,f_t=null,d_t=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),__t>0&&(s[__t-1].vfOffset=a_t),s.length=__t,a.length=n_t;var o=c_t-1;if(o>=0)if(u_t>0){var l=n[o];l.indexCount=u_t,l.vfCount=13*h_t,l.vertexCount=h_t,n.length=c_t}else n.length=c_t-1;if(0!==n.length){var h=r.vertices,u=a_t/6,c=13*u;(!h||h.length<c)&&(h=r.vertices=new Float32Array(c));for(var _=0,f=0;_<c;)h[_]=i_t[f++],h[_+1]=i_t[f++],h[_+3]=i_t[f++],h[_+4]=i_t[f++],this._setVerticeColor(i_t[f++],h,_+5),this._setVerticeColor(i_t[f++],h,_+9),_+=13;var d=r.indices;(!d||d.length<s_t)&&(d=r.indices=new Uint16Array(s_t));for(var p=0;p<s_t;p++)d[p]=r_t[p];r.vertices=h,r.indices=d,this.maxVertexCount=u>this.maxVertexCount?u:this.maxVertexCount,this.maxIndexCount=d.length>this.maxIndexCount?d.length:this.maxIndexCount}},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,d=this._tempSegments,p=this._tempBoneInfos,m=t.color,g=t.bones;if(this._enableCacheAttachedInfo)for(var y=0,v=g.length;y<v;y++,n_t++){var b=g[y],S=p[n_t];S||(S=p[n_t]={}),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,T=t.drawOrder.length;A<T;A++)if((f=t.drawOrder[A]).bone.active)if(p_t=0,m_t=0,i=f.getAttachment())if(o=i instanceof $ct.RegionAttachment,l=i instanceof $ct.MeshAttachment,i instanceof $ct.ClippingAttachment)e.clipStart(f,i);else if(o||l)if(h=i.region.texture.getRealTexture()){if(_=f.data.blendMode,o_t===h.getId()&&l_t===_||(o_t=h.getId(),l_t=_,(u=c_t-1)>=0&&(u_t>0?((c=d[u]).indexCount=u_t,c.vertexCount=h_t,c.vfCount=13*h_t):c_t--),d[c_t]={tex:h,blendMode:_,indexCount:0,vertexCount:0,vfCount:0},c_t++,u_t=0,h_t=0),o)a=v_t,p_t=24,m_t=6,i.computeWorldVertices(f.bone,i_t,a_t,6);else if(l){var C=i;a=C.triangles,p_t=6*(C.worldVerticesLength>>1),m_t=a.length,C.computeWorldVertices(f,0,C.worldVerticesLength,i_t,a_t,6)}if(0!==p_t&&0!==m_t){for(var x=0,w=s_t,E=a.length;x<E;)r_t[w++]=a[x++];s=i.uvs;for(var B=a_t,R=a_t+p_t,D=0;B<R;B+=6,D+=2)i_t[B+2]=s[D],i_t[B+3]=s[D+1];if(r=i.color,n=f.color,this.fillVertices(m,r,n,e,f),m_t>0){for(var M=s_t,P=s_t+m_t;M<P;M++)r_t[M]+=h_t;s_t+=m_t,a_t+=p_t,u_t+=m_t,h_t+=p_t/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}(),S_t=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 $ct.Skeleton(e),n=new $ct.SkeletonClipping,s=new $ct.AnimationStateData(r.data),a=new $ct.AnimationState(s),o=new t_t;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 b_t)._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;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}();S_t.FrameTime=e_t,S_t.sharedCache=new S_t;var A_t,T_t,C_t,x_t,w_t,E_t,B_t,R_t,D_t,M_t,P_t,I_t=new c,O_t=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(){if(this._inited){var t=this._skeletonComp.socketNodes;if(0!==t.size){var e;if(e=this._skeletonComp.isAnimationCached()?this._skeletonComp._curFrame&&this._skeletonComp._curFrame.boneInfos:this._skeleton.bones)for(var i,r=function(t,e){var i=I_t;i.m00=e.a,i.m01=e.c,i.m04=e.b,i.m05=e.d,i.m12=e.worldX,i.m13=e.worldY,t.matrix=I_t},n=hn(t.keys());!(i=n()).done;){var s=i.value,a=t.get(s);if(a&&a.isValid){var o=e[s];o?r(a,o):(a.removeFromParent(),a.destroy(),t.delete(s))}else t.delete(s)}}}},t}(),F_t=function(t){function e(e){var i;return(i=t.call(this,e)||this).name="sp.SkeletonTexture",i._texture=null,i._material=null,i}on(e,t);var i=e.prototype;return i.setRealTexture=function(t){this._texture=t},i.getRealTexture=function(){return this._texture},i.setFilters=function(t,e){this._texture&&this.getRealTexture().setFilters(L_t(t),L_t(e))},i.setWraps=function(t,e){this._texture&&this.getRealTexture().setWrapMode(k_t(t),k_t(e))},i.dispose=function(){},e}($ct.Texture);function L_t(t){switch(t){case $ct.TextureFilter.Nearest:case $ct.TextureFilter.MipMapNearestNearest:case $ct.TextureFilter.MipMapLinearNearest:return dn.NEAREST;case $ct.TextureFilter.MipMap:case $ct.TextureFilter.MipMapNearestLinear:case $ct.TextureFilter.MipMapLinearLinear:case $ct.TextureFilter.Linear:default:return dn.LINEAR}}function k_t(t){switch(t){case $ct.TextureWrap.MirroredRepeat:return Zs.MIRRORED_REPEAT;case $ct.TextureWrap.ClampToEdge:return Zs.CLAMP_TO_EDGE;case $ct.TextureWrap.Repeat:default:return Zs.REPEAT}}var V_t=(A_t=En("sp.SkeletonData"),T_t=Wn([fn]),C_t=Wn([la]),A_t((P_t=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_skeletonJson",E_t,Pn(e)),Mn(e,"textures",B_t,Pn(e)),Mn(e,"textureNames",R_t,Pn(e)),Mn(e,"scale",D_t,Pn(e)),Mn(e,"_atlasText",M_t,Pn(e)),e._buffer=void 0,e._skeletonCache=null,e._atlasCache=null,e._skinsEnum=null,e._animsEnum=null,e.reset(),e}on(e,t);var i=e.prototype;return i.createNode=function(t){var e=new ks(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.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 $ct.AtlasAttachmentLoader(e),r=null,n=null;return this.skeletonJson?(n=new $ct.SkeletonJson(i),r=this.skeletonJson):(n=new $ct.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=zs(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=zs(e)}return null},i.destroy=function(){return S_t.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 F_t({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 $ct.TextureAtlas(this.atlasText,this._getTexture.bind(this)):(t||console.error(this.name+" no atlas found!"),null)},Ur(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}(Qr),E_t=Dn((w_t=P_t).prototype,"_skeletonJson",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),B_t=Dn(w_t.prototype,"textures",[On,T_t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),R_t=Dn(w_t.prototype,"textureNames",[On,C_t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),D_t=Dn(w_t.prototype,"scale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),M_t=Dn(w_t.prototype,"_atlasText",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),x_t=w_t))||x_t);Er.internal.SpineSkeletonData=V_t;var N_t,G_t,z_t,U_t,H_t,X_t,W_t,j_t,Y_t,q_t,K_t,J_t,Z_t,Q_t,$_t,tft,eft,ift,rft,nft,sft,aft,oft,lft,hft,uft,cft,_ft,fft,dft,pft,mft,gft,yft,vft,bft,Sft,Aft,Tft,Cft,xft,wft,Eft,Bft,Rft,Dft,Mft,Pft,Ift,Oft,Fft,Lft,kft,Vft,Nft,Gft=function(t){function e(){var e;return(e=t.call(this)||this)._skeletons=new Set,e}on(e,t),e.getInstance=function(){return e._instance||(e._instance=new e,Kr.registerSystem(e.ID,e._instance,Rr.Priority.HIGH)),e._instance};var i=e.prototype;return i.add=function(t){t&&(this._skeletons.has(t)||this._skeletons.add(t))},i.remove=function(t){t&&this._skeletons.has(t)&&this._skeletons.delete(t)},i.postUpdate=function(t){this._skeletons&&this._skeletons.forEach((function(e){e.updateAnimation(t)}))},i.prepareRenderData=function(){this._skeletons&&this._skeletons.forEach((function(t){t.markForUpdateRenderData()}))},e}(Rr);function zft(t,e,i){lo.Attr.setClassAttr(t,e,"type","Enum"),lo.Attr.setClassAttr(t,e,"enumList",zs.getList(i))}Gft.ID="SKELETON",Gft._instance=void 0,Er.internal.SpineSkeletonSystem=Gft,function(t){t[t.default=0]="default"}(Lft||(Lft={})),ss(Lft),function(t){t[t["<None>"]=0]="<None>"}(kft||(kft={})),ss(kft),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(Vft||(Vft={})),ss(Vft),function(t){t[t.COLORED_TEXTURED=0]="COLORED_TEXTURED",t[t.TWO_COLORED=1]="TWO_COLORED"}(Nft||(Nft={}));var Uft=(N_t=En("sp.Skeleton.SpineSocket"),G_t=Wn(ks),N_t((H_t=Dn((U_t=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),Mn(this,"path",H_t,this),Mn(this,"target",X_t,this),this.path=t,this.target=e}).prototype,"path",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),X_t=Dn(U_t.prototype,"target",[G_t,Un,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),z_t=U_t))||z_t);pn.setClassAlias(Uft,"sp.Skeleton.SpineSocket");var Hft=(W_t=En("sp.Skeleton"),j_t=Qn(),Y_t=ts(),q_t=Wn(cn),K_t=es(),J_t=_s(),Z_t=Wn(V_t),Q_t=_s(),$_t=Wn(Lft),tft=is(),eft=_s(),ift=Wn(kft),rft=is(),nft=_s(),sft=is(),aft=Wn(Vft),oft=is(),lft=is(),hft=is(),uft=is(),cft=is(),_ft=is(),fft=is(),dft=Wn([Uft]),pft=is(),mft=cs(),gft=cs(),W_t(yft=j_t(yft=Y_t(yft=Jn((Fft=Oft=function(t){on(i,t);var e=i.prototype;function i(){var e;return e=t.call(this)||this,Mn(e,"loop",bft,Pn(e)),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.maxVertexCount=0,e.maxIndexCount=0,e._materialCache={},e._enumSkins=zs({}),e._enumAnimations=zs({}),e._playTimes=0,Mn(e,"_timeScale",Sft,Pn(e)),e._paused=!1,e._accTime=0,e._playCount=0,e._skeletonCache=null,e._animationName="",e._animationQueue=[],e._headAniInfo=null,e._isAniComplete=!0,e._needUpdateSkeltonData=!0,Mn(e,"_useTint",Aft,Pn(e)),Mn(e,"_preCacheMode",Tft,Pn(e)),Mn(e,"_cacheMode",Cft,Pn(e)),Mn(e,"_defaultCacheMode",xft,Pn(e)),Mn(e,"_debugBones",wft,Pn(e)),Mn(e,"_debugSlots",Eft,Pn(e)),Mn(e,"_skeletonData",Bft,Pn(e)),Mn(e,"_premultipliedAlpha",Rft,Pn(e)),Mn(e,"defaultSkin",Dft,Pn(e)),Mn(e,"defaultAnimation",Mft,Pn(e)),Mn(e,"_sockets",Pft,Pn(e)),e._drawIdx=0,e._drawList=new X((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),Mn(e,"_debugMesh",Ift,Pn(e)),e._rootBone=void 0,e._state=void 0,e._listener=void 0,e._socketNodes=new Map,e._cachedSockets=new Map,e._drawInfoList=[],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 O_t,zft(Pn(e),"_defaultSkinIndex",e._enumSkins),zft(Pn(e),"_animationIndex",e._enumAnimations),e._useVertexOpacity=!0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new Gu),this._drawInfoList[t]},e.setSkeletonData=function(t){var e=this.node._uiProps.uiTransformComp;if(null!=t.width&&null!=t.height&&e.setContentSize(t.width,t.height),this._cacheMode===Vft.SHARED_CACHE?this._skeletonCache=S_t.sharedCache:this._cacheMode===Vft.PRIVATE_CACHE&&(this._skeletonCache=new S_t,this._skeletonCache.enablePrivateMode()),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&bn("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 $ct.Skeleton(t),this._clipper=new $ct.SkeletonClipping,this._rootBone=this._skeleton.getRootBone();this._flushAssembler()},e.setSlotsRange=function(t,e){this.isAnimationCached()?bn("Slots visible range can not be modified in cached mode."):(this._startSlotIndex=t,this._endSlotIndex=e)},e.setAnimationStateData=function(t){if(this.isAnimationCached())bn("'setAnimationStateData' interface can not be invoked in cached mode.");else{var e=new $ct.AnimationState(t);this._listener&&(this._state&&this._state.removeListener(this._listener),e.addListener(this._listener)),this._state=e}},e.__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()},e.setAnimationCacheMode=function(t){this._preCacheMode!==t&&(this._cacheMode=t,this._needUpdateSkeltonData=!0,this._updateSkeletonData(),this._updateUseTint(),this._updateSocketBindings(),this.markForUpdateRenderData())},e.isAnimationCached=function(){return this._cacheMode!==Vft.REALTIME},e.updateAnimation=function(t){if(this.markForUpdateRenderData(),!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)},e.setVertexEffectDelegate=function(t){this._effectDelegate=t},e.setToSetupPose=function(){this._skeleton&&this._skeleton.setToSetupPose()},e.setBonesToSetupPose=function(){this._skeleton&&this._skeleton.setBonesToSetupPose()},e.setSlotsToSetupPose=function(){this._skeleton&&this._skeleton.setSlotsToSetupPose()},e.updateAnimationCache=function(t){if(this.isAnimationCached()){var e=this._skeletonData._uuid;this._skeletonCache&&this._skeletonCache.updateAnimationCache(e,t)}},e.invalidAnimationCache=function(){this.isAnimationCached()&&this._skeletonCache&&this._skeletonCache.invalidAnimationCache(this._skeletonData._uuid)},e.findBone=function(t){return this._skeleton?this._skeleton.findBone(t):null},e.findSlot=function(t){return this._skeleton?this._skeleton.findSlot(t):null},e.setSkin=function(t){this._skeleton&&(this._skeleton.setSkinByName(t),this._skeleton.setSlotsToSetupPose()),this.invalidAnimationCache()},e.getAttachment=function(t,e){return this._skeleton?this._skeleton.getAttachmentByName(t,e):null},e.setAttachment=function(t,e){this._skeleton&&this._skeleton.setAttachment(t,e),this.invalidAnimationCache()},e.getTextureAtlas=function(t){return t.region},e.setMix=function(t,e,i){this._state&&this._state.data.setMix(t,e,i)},e.setAnimation=function(t,e,i){if(this._playTimes=i?0:1,this._animationName=e,this.isAnimationCached()){if(0!==t&&bn("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 Qs(7509,e),null;var s=this._state.setAnimationWith(t,n,i);return this._state.apply(this._skeleton),s}return null},e.addAnimation=function(t,e,i,r){if(r=r||0,this.isAnimationCached())0!==t&&bn("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):(Qs(7510,e),null)}return null},e.findAnimation=function(t){return this._skeleton?this._skeleton.data.findAnimation(t):null},e.getCurrent=function(t){if(this.isAnimationCached())bn("'getCurrent' interface can not be invoked in cached mode.");else if(this._state)return this._state.getCurrent(t);return null},e.clearTracks=function(){this.isAnimationCached()?bn("'clearTracks' interface can not be invoked in cached mode."):this._state&&(this._state.clearTracks(),this.setToSetupPose())},e.clearTrack=function(t){this.isAnimationCached()?bn("'clearTrack' interface can not be invoked in cached mode."):this._state&&this._state.clearTrack(t)},e.setStartListener=function(t){this._ensureListener(),this._listener.start=t},e.setInterruptListener=function(t){this._ensureListener(),this._listener.interrupt=t},e.setEndListener=function(t){this._ensureListener(),this._listener.end=t},e.setDisposeListener=function(t){this._ensureListener(),this._listener.dispose=t},e.setCompleteListener=function(t){this._ensureListener(),this._listener.complete=t},e.setEventListener=function(t){this._ensureListener(),this._listener.event=t},e.setTrackStartListener=function(t,e){t_t.getListeners(t).start=e},e.setTrackInterruptListener=function(t,e){t_t.getListeners(t).interrupt=e},e.setTrackEndListener=function(t,e){t_t.getListeners(t).end=e},e.setTrackDisposeListener=function(t,e){t_t.getListeners(t).dispose=e},e.setTrackCompleteListener=function(t,e){t_t.getListeners(t).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},e.setTrackEventListener=function(t,e){t_t.getListeners(t).event=e},e.getState=function(){return this._state},e.onEnable=function(){t.prototype.onEnable.call(this),this._flushAssembler(),Gft.getInstance().add(this)},e.onDisable=function(){t.prototype.onDisable.call(this),Gft.getInstance().remove(this)},e.onDestroy=function(){this._cleanMaterialCache(),this._drawList.destroy(),t.prototype.onDestroy.call(this)},e.destroyRenderData=function(){this._drawList.reset(),t.prototype.destroyRenderData.call(this)},e.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=os.get("default-spine-material"));var a=!1;switch(i){case Nft.TWO_COLORED:a=!0;break;case Nft.COLORED_TEXTURED:}return n=new Ps({parent:s,subModelIdx:0,owner:this}),this._materialCache[r]=n,n.overridePipelineStates({blendState:{blendColor:y.WHITE,targets:[{blendEq:yt.ADD,blendAlphaEq:yt.ADD,blendSrc:t,blendDst:e,blendSrcAlpha:t,blendDstAlpha:e}]}}),n.recompileShaders({TWO_COLORED:a,USE_LOCAL:!0}),n},e.onRestore=function(){this.updateMaterial(),this.markForUpdateRenderData()},e.querySockets=function(){return this._skeleton?(0===this._cachedSockets.size&&this._indexBoneSockets(),this._cachedSockets.size>0?Array.from(this._cachedSockets.keys()).sort():[]):[]},e._requestDrawData=function(t,e,i,r){var n=this._drawList.add();return n.material=t,n.texture=e,n.indexOffset=i,n.indexCount=r,n},e._render=function(t){if(this.renderData&&this._drawList){var e=this.renderData,i=e.chunk,r=i.vertexAccessor,n=e.getMeshBuffer(),s=n.indexOffset;r.appendIndices(i.bufferId,e.indices);for(var a=0;a<this._drawList.length;a++){this._drawIdx=a;var o=this._drawList.data[a];if(o.texture){var l=n.requireFreeIA(t.device);l.firstIndex=s+o.indexOffset,l.indexCount=o.indexCount,t.commitIA(this,l,o.texture,o.material,this.node)}}}},e.updateWorldTransform=function(){this.isAnimationCached()&&this._skeleton&&this._skeleton.updateWorldTransform()},e._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))},e._updateCache=function(t){var e=this._frameCache;if(e.isInited()){var i=e.frames,r=S_t.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),this.renderData&&(this.renderData.vertexCount<e.maxVertexCount||this.renderData.indexCount<e.maxIndexCount)&&(this.maxVertexCount=e.maxVertexCount>this.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount)))),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,void this._emitCacheCompleteEvent();this._accTime=0,n=0,this._emitCacheCompleteEvent()}this._curFrame=i[n]}},e._updateRealtime=function(t){var e=this._skeleton,i=this._state;e&&(e.update(t),i&&(i.update(t),i.apply(e)))},e._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)}}},e._updateUseTint=function(){this._cleanMaterialCache(),this.destroyRenderData(),this._assembler&&this._skeleton&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData())},e._updateBatch=function(){this.markForUpdateRenderData()},e._updateAnimEnum=function(){var t;t=this.skeletonData?this.skeletonData.getAnimsEnum():kft,this._enumAnimations=zs({}),Object.assign(this._enumAnimations,t),zs.update(this._enumAnimations),zft(this,"_animationIndex",this._enumAnimations)},e._updateSkinEnum=function(){var t;t=this.skeletonData?this.skeletonData.getSkinsEnum():Lft,this._enumSkins=zs({}),Object.assign(this._enumSkins,t),zs.update(this._enumSkins),zft(this,"_defaultSkinIndex",this._enumSkins)},e._ensureListener=function(){this._listener||(this._listener=new t_t,this._state&&this._state.addListener(this._listener))},e._updateSkeletonData=function(){if(this.skeletonData&&!1!==this._needUpdateSkeltonData){this._needUpdateSkeltonData=!1;var t=this.skeletonData.getRuntimeData();if(t){try{this.setSkeletonData(t),this.isAnimationCached()||this.setAnimationStateData(new $ct.AnimationStateData(this._skeleton.data)),this.defaultSkin&&this.setSkin(this.defaultSkin)}catch(t){bn(t)}this._indexBoneSockets(),this.attachUtil.init(this),this._preCacheMode=this._cacheMode,this.animation=this.defaultAnimation}}},e._refreshInspector=function(){this._updateAnimEnum(),this._updateSkinEnum()},e._updateDebugDraw=function(){if(this.debugBones||this.debugSlots||this.debugMesh){if(!this._debugRenderer){var t=new ks("DEBUG_DRAW_NODE");t.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy;var e=t.addComponent(Mp);e.lineWidth=1,e.strokeColor=new y(255,0,0,255),this._debugRenderer=e,t.parent=this.node}this.isAnimationCached()&&bn("Debug bones or slots is invalid in cached mode")}else this._debugRenderer&&(this._debugRenderer.node.destroy(),this._debugRenderer=null)},e._flushAssembler=function(){var t=i.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._skeleton&&this._assembler&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},e._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)}}}},e._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))}))},e._cleanMaterialCache=function(){for(var t in this._materialCache)this._materialCache[t].destroy();this._materialCache={}},e.createRenderEntity=function(){var t=new Bc(zu.DYNAMIC);return t.setUseLocal(!0),t},e.markForUpdateRenderData=function(e){void 0===e&&(e=!0),t.prototype.markForUpdateRenderData.call(this,e),this._debugRenderer&&this._debugRenderer.markForUpdateRenderData(e)},Ur(i,[{key:"drawList",get:function(){return this._drawList}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this._cleanMaterialCache(),this.setMaterial(this._customMaterial,0),this.markForUpdateRenderData()}},{key:"paused",get:function(){return this._paused},set:function(t){this._paused=t}},{key:"skeletonData",get:function(){return this._skeletonData},set:function(t){t&&t.resetEnums(),this._skeletonData!==t&&(this.destroyRenderData(),this._skeletonData=t,this._needUpdateSkeltonData=!0,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.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())}},{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}}]),i}(af),Oft.SpineSocket=Uft,Oft.AnimationCacheMode=Vft,Dn((vft=Fft).prototype,"customMaterial",[Hn,q_t,K_t,J_t],Object.getOwnPropertyDescriptor(vft.prototype,"customMaterial"),vft.prototype),Dn(vft.prototype,"skeletonData",[Un,Z_t],Object.getOwnPropertyDescriptor(vft.prototype,"skeletonData"),vft.prototype),Dn(vft.prototype,"_defaultSkinIndex",[Q_t,$_t,tft],Object.getOwnPropertyDescriptor(vft.prototype,"_defaultSkinIndex"),vft.prototype),Dn(vft.prototype,"_animationIndex",[eft,ift,rft],Object.getOwnPropertyDescriptor(vft.prototype,"_animationIndex"),vft.prototype),Dn(vft.prototype,"defaultCacheMode",[nft,sft,Un,aft],Object.getOwnPropertyDescriptor(vft.prototype,"defaultCacheMode"),vft.prototype),bft=Dn(vft.prototype,"loop",[On,oft],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(vft.prototype,"premultipliedAlpha",[Un,lft],Object.getOwnPropertyDescriptor(vft.prototype,"premultipliedAlpha"),vft.prototype),Dn(vft.prototype,"timeScale",[hft,Un],Object.getOwnPropertyDescriptor(vft.prototype,"timeScale"),vft.prototype),Dn(vft.prototype,"debugSlots",[Un,uft],Object.getOwnPropertyDescriptor(vft.prototype,"debugSlots"),vft.prototype),Dn(vft.prototype,"debugBones",[Un,cft],Object.getOwnPropertyDescriptor(vft.prototype,"debugBones"),vft.prototype),Dn(vft.prototype,"debugMesh",[Un,_ft],Object.getOwnPropertyDescriptor(vft.prototype,"debugMesh"),vft.prototype),Dn(vft.prototype,"useTint",[Un,fft],Object.getOwnPropertyDescriptor(vft.prototype,"useTint"),vft.prototype),Dn(vft.prototype,"sockets",[dft,pft],Object.getOwnPropertyDescriptor(vft.prototype,"sockets"),vft.prototype),Sft=Dn(vft.prototype,"_timeScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Aft=Dn(vft.prototype,"_useTint",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Tft=Dn(vft.prototype,"_preCacheMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Cft=Dn(vft.prototype,"_cacheMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Vft.REALTIME}}),xft=Dn(vft.prototype,"_defaultCacheMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Vft.REALTIME}}),wft=Dn(vft.prototype,"_debugBones",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Eft=Dn(vft.prototype,"_debugSlots",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Bft=Dn(vft.prototype,"_skeletonData",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Rft=Dn(vft.prototype,"_premultipliedAlpha",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dft=Dn(vft.prototype,"defaultSkin",[On,mft],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Mft=Dn(vft.prototype,"defaultAnimation",[gft,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Pft=Dn(vft.prototype,"_sockets",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ift=Dn(vft.prototype,"_debugMesh",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),yft=vft))||yft)||yft)||yft)||yft);Er.internal.SpineSkeleton=Hft;var Xft,Wft,jft,Yft,qft,Kft,Jft,Zft,Qft,$ft,tdt,edt,idt,rdt,ndt,sdt,adt,odt,ldt,hdt,udt,cdt,_dt,fdt,ddt,pdt,mdt,gdt,ydt,vdt,bdt,Sdt,Adt,Tdt,Cdt,xdt=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 $ct.JitterEffect(t,e),this._vertexEffect},e.initSwirlWithPow=function(t,e){return this._interpolation=new $ct.Pow(e),this._vertexEffect=new $ct.SwirlEffect(t,this._interpolation),this._vertexEffect},e.initSwirlWithPowOut=function(t,e){return this._interpolation=new $ct.PowOut(e),this._vertexEffect=new $ct.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}(),wdt=[0,1,2,2,3,0],Edt=new y(0,0,255,255),Bdt=new y(255,0,0,255),Rdt=new y(0,255,0,255),Ddt=new y(255,255,0,255),Mdt=new $ct.Color(1,1,1,1),Pdt=new $ct.Color(1,1,1,1),Idt=new $ct.Vector2,Odt=new $ct.Vector2,Fdt=new Float32Array(4),Ldt=new Float32Array(4),kdt=0,Vdt=0,Ndt=0,Gdt=0,zdt=0,Udt=0,Hdt=0,Xdt=0,Wdt=null,jdt=null,Ydt=null,qdt=1/255;function Kdt(t){var e,i;switch(t){case $ct.BlendMode.Additive:e=Xft?gt.ONE:gt.SRC_ALPHA,i=gt.ONE;break;case $ct.BlendMode.Multiply:e=gt.DST_COLOR,i=gt.ONE_MINUS_SRC_ALPHA;break;case $ct.BlendMode.Screen:e=gt.ONE,i=gt.ONE_MINUS_SRC_COLOR;break;case $ct.BlendMode.Normal:default:e=Xft?gt.ONE:gt.SRC_ALPHA,i=gt.ONE_MINUS_SRC_ALPHA}return bdt.getMaterialForBlendAndTint(e,i,qft?Nft.TWO_COLORED:Nft.COLORED_TEXTURED)}function Jdt(t){pdt=t.fa*edt,hdt=Qft*(Wft=Xft?pdt*qdt:1),udt=$ft*Wft,cdt=tdt*Wft,_dt=t.fr*hdt,fdt=t.fg*udt,ddt=t.fb*cdt,Fdt[0]=_dt*qdt,Fdt[1]=fdt*qdt,Fdt[2]=ddt*qdt,Fdt[3]=pdt*qdt,mdt=t.dr*hdt,gdt=t.dg*udt,ydt=t.db*cdt,vdt=Xft?255:0,Ldt[0]=mdt*qdt,Ldt[1]=gdt*qdt,Ldt[2]=ydt*qdt,Ldt[3]=vdt*qdt}var Zdt=new Float32Array(4);function Qdt(t){return Zdt[0]=t.r*qdt,Zdt[1]=t.g*qdt,Zdt[2]=t.b*qdt,Zdt[3]=t.a*qdt,Zdt}var $dt=null,tpt=null,ept={vCount:32767,ensureAccessor:function(t){var e=t?tpt:$dt;if(!e){var i=Kr.root.device,r=Kr.root.batcher2D,n=t?wu:xu;t?(e=tpt=new ku(i,n,this.vCount),r.registerBufferAccessor(Number.parseInt("SPINETINT",36),tpt)):(e=$dt=new ku(i,n,this.vCount),r.registerBufferAccessor(Number.parseInt("SPINE",36),$dt))}return e},createData:function(t){var e=t.renderData;if(!e){for(var i=t.useTint||t.isAnimationCached(),r=this.ensureAccessor(i),n=t._skeleton.data.skins,s=0,a=0,o=0;o<n.length;++o)for(var l=n[o].attachments,h=0;h<l.length;h++){var u=l[h];for(var c in u){var _=u[c];_ instanceof $ct.RegionAttachment?(s+=4,a+=6):_ instanceof $ct.MeshAttachment&&(s+=_.worldVerticesLength>>1,a+=_.triangles.length)}}(e=Pc.add(i?wu:xu,r)).resize(s,a),e.indices&&a===e.indices.length||(e.indices=new Uint16Array(a)),t.maxVertexCount=s,t.maxIndexCount=a}return e},updateRenderData:function(t){bdt=t;var e=t._skeleton;!t.isAnimationCached()&&e&&e.updateWorldTransform(),e&&function(t){if(t._skeleton){var e=t.color;Qft=e.r*qdt,$ft=e.g*qdt,tdt=e.b*qdt,edt=t.node._uiProps.opacity,qft=t.useTint||t.isAnimationCached(),idt=qft?13:9,t.drawList.reset(),bdt=t,t.node,Sdt=t.renderData,jdt=null,ldt=!0,Xft=t.premultipliedAlpha,Wft=1,Cdt=!1,Wdt=t._effectDelegate&&t._effectDelegate._vertexEffect,(4294967295!==e._val||Xft)&&(Cdt=!0),t.isAnimationCached()?function(){var t=bdt._curFrame;if(t){var e=t.segments;if(0!==e.length){rdt=12,Gdt=0,zdt=0,Ndt=0,Udt=0;var i=null,r=t.vertices,n=t.indices,s=0,a=0,o=0,l=0,h=t.colors,u=0,c=h[u++],_=c.vfOffset;Jdt(c);for(var f=0,d=Sdt,p=d.chunk.vb,m=d.indices,g=0,y=e.length;g<y;g++){var v=e[g];if(i=Kdt(v.blendMode)){if(jdt||(jdt=i),ldt||i.hash!==jdt.hash||v.tex&&v.tex!==Ydt){ldt=!1;var b=Udt-f;b>0&&(bdt._requestDrawData(jdt,Ydt,f,b),f=Udt),jdt=i,Ydt=v.tex}Vdt=v.vertexCount,zdt=v.indexCount,s=d.chunk.vertexOffset;for(var S=Udt,A=Udt+zdt;S<A;S++)m[S]=s+Ndt+n[o++];if(l=v.vfCount,p.set(r.subarray(a,a+l),a),Cdt)for(var T=a/13*6,C=a,x=a+l;C<x;C+=idt,T+=6)T>=_&&(Jdt(c=h[u++]),_=c.vfOffset),p.set(Fdt,C+5),p.set(Ldt,C+9);a+=l,Ndt+=Vdt,Udt+=zdt,Vdt=0,zdt=0}}var w=Udt-f;Ydt&&w>0&&bdt._requestDrawData(jdt,Ydt,f,w)}}}():(Wdt&&Wdt.begin(t._skeleton),function(){var t=Sdt;Tdt=t.chunk.vb,Adt=t.indices,Hdt=bdt.maxVertexCount,Xdt=bdt.maxIndexCount;var e,i,r,n,s,a,o=bdt._skeleton,l=o.color,h=bdt._debugRenderer,u=bdt._clipper,c=null;jft=bdt._startSlotIndex,Yft=bdt._endSlotIndex,odt=!1,-1===jft&&(odt=!0),Kft=bdt.debugSlots,Jft=bdt.debugBones,Zft=bdt.debugMesh,h&&(Jft||Kft||Zft)&&(h.clear(),h.lineWidth=5),rdt=12,kdt=0,Ndt=0,Gdt=0,zdt=0,Udt=0;for(var _=0,f=0,d=o.drawOrder.length;f<d;f++)if(void 0!==(a=o.drawOrder[f])&&a.bone.active)if(jft>=0&&jft===a.data.index&&(odt=!0),odt)if(Yft>=0&&Yft===a.data.index&&(odt=!1),kdt=0,zdt=0,e=a.getAttachment())if(n=e instanceof $ct.RegionAttachment,s=e instanceof $ct.MeshAttachment,e instanceof $ct.ClippingAttachment)u.clipStart(a,e);else if(n||s){var p=e.region.texture.getRealTexture();if(c=Kdt(a.data.blendMode)){if(jdt||(jdt=c),ldt||c.hash!==jdt.hash||p&&Ydt!==p){ldt=!1;var m=Udt-_;m>0&&(bdt._requestDrawData(jdt,Ydt,_,m),_=Udt),Ydt=p,jdt=c}if(n){if(r=wdt,kdt=(Vdt=4)*idt,zdt=6,e.computeWorldVertices(a.bone,Tdt,Gdt,idt),h&&Kft){h.strokeColor=Edt,h.moveTo(Tdt[Gdt],Tdt[Gdt+1]);for(var g=Gdt+idt,y=Gdt+kdt;g<y;g+=idt)h.lineTo(Tdt[g],Tdt[g+1]);h.close(),h.stroke()}}else if(s){var v=e;if(r=v.triangles,Vdt=v.worldVerticesLength>>1,kdt=Vdt*idt,zdt=r.length,v.computeWorldVertices(a,0,v.worldVerticesLength,Tdt,Gdt,idt),h&&Zft){h.strokeColor=Ddt;for(var b=0,S=r.length;b<S;b+=3){var A=r[b]*idt+Gdt,T=r[b+1]*idt+Gdt,C=r[b+2]*idt+Gdt;h.moveTo(Tdt[A],Tdt[A+1]),h.lineTo(Tdt[T],Tdt[T+1]),h.lineTo(Tdt[C],Tdt[C+1]),h.close(),h.stroke()}}}if(0!==kdt&&0!==zdt){var x=e;(Adt=t.indices).set(r,Udt),i=x.uvs;for(var w=Gdt,E=Gdt+kdt,B=0;w<E;w+=idt,B+=2)Tdt[w+3]=i[B],Tdt[w+4]=i[B+1];if(rpt(l,x.color,a.color,u,a),zdt>0)for(var R=t.chunk.vertexOffset,D=Udt,M=Udt+zdt;D<M;D++)Adt[D]+=Ndt+R;Gdt+=kdt,Ndt+=Vdt,Udt+=zdt,Vdt=0,zdt=0,u.clipEndWithSlot(a)}else u.clipEndWithSlot(a)}else u.clipEndWithSlot(a)}else u.clipEndWithSlot(a);else u.clipEndWithSlot(a);else u.clipEndWithSlot(a);var P=Udt-_;if(Ydt&&P>0&&bdt._requestDrawData(jdt,Ydt,_,P),u.clipEnd(),h&&Jft){var I;h.strokeColor=Bdt,h.fillColor=Edt;for(var O=0,F=o.bones.length;O<F;O++){var L=(I=o.bones[O]).data.length*I.a+I.worldX,k=I.data.length*I.c+I.worldY;h.moveTo(I.worldX,I.worldY),h.lineTo(L,k),h.stroke(),h.circle(I.worldX,I.worldY,1.5*Math.PI),h.fill(),0===O&&(h.fillColor=Rdt)}}}(),Wdt&&Wdt.end()),(qft?tpt:$dt).getMeshBuffer(Sdt.chunk.bufferId).setDirty(),t.attachUtil._syncAttachedNode(),bdt=void 0,Wdt=null}}(t)},updateColor:function(t){t&&(bdt=t).markForUpdateRenderData()},fillBuffers:function(){}};function ipt(t,e){var i=Vdt,r=zdt,n=Sdt;zdt=e.length,Vdt=t.length/rdt,kdt=Vdt*idt,Hdt+=Vdt-i,Xdt+=zdt-r;var s=Adt,a=n.chunk.vertexOffset,o=!1;if(Hdt>n.vertexCount&&(n.resizeAndCopy(Hdt,Xdt>n.indexCount?Xdt:n.indexCount),Tdt=n.chunk.vb,o=!0),Xdt>Adt.length&&(Adt=n.indices=new Uint16Array(Xdt),o=!0),o)for(var l=n.chunk.vertexOffset-a,h=0;h<Udt;++h)Adt[h]=s[h]+l}function rpt(t,e,i,r,n){if(Mdt.a=i.a*e.a*t.a*edt*255,Wft=Xft?Mdt.a:255,ndt=Qft*e.r*t.r*Wft,sdt=$ft*e.g*t.g*Wft,adt=tdt*e.b*t.b*Wft,Mdt.r=ndt*i.r,Mdt.g=sdt*i.g,Mdt.b=adt*i.b,null==n.darkColor?Pdt.set(0,0,0,1):(Pdt.r=n.darkColor.r*ndt,Pdt.g=n.darkColor.g*sdt,Pdt.b=n.darkColor.b*adt),Pdt.a=Xft?255:0,qft)if(r.isClipping()){rdt=qft?12:8;var s=Tdt.subarray(Gdt),a=Tdt.subarray(Gdt+3);r.clipTriangles(s,kdt,Adt.subarray(Udt),zdt,a,Mdt,Pdt,qft,idt);var o=r.clippedVertices,l=r.clippedTriangles;if(ipt(o,l),l.length>0&&Adt.set(l,Udt),Wdt)for(var h=0,u=o.length,c=Gdt;h<u;h+=rdt,c+=idt)Idt.x=o[h],Idt.y=o[h+1],Mdt.set(o[h+2],o[h+3],o[h+4],o[h+5]),Odt.x=o[h+6],Odt.y=o[h+7],Pdt.set(o[h+8],o[h+9],o[h+10],o[h+11]),Wdt.transform(Idt,Odt,Mdt,Pdt),Tdt[c]=Idt.x,Tdt[c+1]=Idt.y,Tdt[c+3]=Odt.x,Tdt[c+4]=Odt.y,Tdt.set(Qdt(Mdt),c+5),Tdt.set(Qdt(Pdt),c+9);else for(var _=0,f=o.length,d=Gdt;_<f;_+=rdt,d+=idt)Tdt[d]=o[_],Tdt[d+1]=o[_+1],Tdt[d+3]=o[_+6],Tdt[d+4]=o[_+7],Tdt[d+5]=o[_+2]*qdt,Tdt[d+6]=o[_+3]*qdt,Tdt[d+7]=o[_+4]*qdt,Tdt[d+8]=o[_+5]*qdt,Tdt[d+9]=o[_+8]*qdt,Tdt[d+10]=o[_+9]*qdt,Tdt[d+11]=o[_+10]*qdt,Tdt[d+12]=o[_+11]*qdt}else if(Wdt)for(var p=Gdt,m=Gdt+kdt;p<m;p+=idt)Idt.x=Tdt[p],Idt.y=Tdt[p+1],Odt.x=Tdt[p+3],Odt.y=Tdt[p+4],Wdt.transform(Idt,Odt,Mdt,Pdt),Tdt[p]=Idt.x,Tdt[p+1]=Idt.y,Tdt[p+3]=Odt.x,Tdt[p+4]=Odt.y,Tdt.set(Qdt(Mdt),p+5),Tdt.set(Qdt(Pdt),p+9);else{Fdt.set(Qdt(Mdt)),Ldt.set(Qdt(Pdt));for(var g=Gdt,y=Gdt+kdt;g<y;g+=idt)Tdt.set(Fdt,g+5),Tdt.set(Ldt,g+9)}else if(r.isClipping()){rdt=qft?12:8;var v=Tdt.subarray(Gdt),b=Tdt.subarray(Gdt+3);r.clipTriangles(v,kdt,Adt.subarray(Udt),zdt,b,Mdt,Pdt,qft,idt);var S=r.clippedVertices,A=r.clippedTriangles;if(ipt(S,A),A.length>0&&Adt.set(A,Udt),Wdt)for(var T=0,C=S.length,x=Gdt;T<C;T+=rdt,x+=idt)Idt.x=S[T],Idt.y=S[T+1],Mdt.set(S[T+2],S[T+3],S[T+4],S[T+5]),Odt.x=S[T+6],Odt.y=S[T+7],Pdt.set(0,0,0,0),Wdt.transform(Idt,Odt,Mdt,Pdt),Tdt[x]=Idt.x,Tdt[x+1]=Idt.y,Tdt[x+3]=Odt.x,Tdt[x+4]=Odt.y,Tdt.set(Qdt(Mdt),x+5);else for(var w=0,E=S.length,B=Gdt;w<E;w+=rdt,B+=idt)Tdt[B]=S[w],Tdt[B+1]=S[w+1],Tdt[B+3]=S[w+6],Tdt[B+4]=S[w+7],Tdt[B+5]=S[w+2]*qdt,Tdt[B+6]=S[w+3]*qdt,Tdt[B+7]=S[w+4]*qdt,Tdt[B+8]=S[w+5]*qdt}else if(Wdt)for(var R=Gdt,D=Gdt+kdt;R<D;R+=idt)Idt.x=Tdt[R],Idt.y=Tdt[R+1],Odt.x=Tdt[R+3],Odt.y=Tdt[R+4],Wdt.transform(Idt,Odt,Mdt,Pdt),Tdt[R]=Idt.x,Tdt[R+1]=Idt.y,Tdt[R+3]=Odt.x,Tdt[R+4]=Odt.y,Tdt.set(Qdt(Mdt),R+5);else{Fdt.set(Qdt(Mdt)),Ldt.set(Qdt(Pdt));for(var M=Gdt,P=Gdt+kdt;M<P;M+=idt)Tdt.set(Fdt,M+5)}}Er.internal.SpineAssembler=ept;var npt,spt,apt={getAssembler:function(){return ept}};Hft.Assembler=apt,Dr(Hft.prototype,"Skeleton",[{name:"enableBatch",suggest:"Not support batch render mode"}]),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"}(npt||(npt={})),ss(npt),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"}(spt||(spt={})),ss(spt),t("sp",Object.freeze({__proto__:null,spine:$ct,get ATTACHMENT_TYPE(){return npt},get AnimationEventType(){return spt},timeScale:1,get DefaultSkinsEnum(){return Lft},get DefaultAnimsEnum(){return kft},get AnimationCacheMode(){return Vft},get SpineMaterialType(){return Nft},SpineSocket:Uft,Skeleton:Hft,SkeletonData:V_t,SkeletonTexture:F_t,convertFilter:L_t,convertWraps:k_t,VertexEffectDelegate:xdt,simpleSpineAssembler:apt})),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=T(t,0,this.w-1),e=T(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=T(n,0,this.w-1),s=T(s,0,this.h-1),a=T(a,0,this.w-1),o=T(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),d=.5*(c+_);return l+h<=1?f=d+(d-u):u=d+(d-f),(u*(1-l)+c*l)*(1-h)+(_*(1-l)+f*l)*h},t}());var opt,lpt,hpt,upt,cpt,_pt,fpt,dpt,ppt,mpt,gpt,ypt,vpt,bpt,Spt,Apt,Tpt,Cpt,xpt,wpt,Ept,Bpt,Rpt,Dpt,Mpt,Ppt,Ipt,Opt,Fpt,Lpt,kpt,Vpt,Npt,Gpt,zpt,Upt,Hpt,Xpt,Wpt,jpt,Ypt,qpt,Kpt,Jpt,Zpt,Qpt,$pt,tmt,emt,imt,rmt,nmt,smt,amt,omt,lmt=33,hmt=1e14,umt=function(){function t(){this.level=0,this.north=0,this.south=0,this.west=0,this.east=0}return t.prototype.equals=function(t){return this.level===t.level&&this.north===t.north&&this.south===t.south&&this.west===t.west&&this.east===t.east},t}(),cmt=function(){this.size=0,this.indices=null},_mt=function(){this.key=new umt,this.start=0,this.size=0,this.buffer=null,this.primCount=0},fmt=function(){function t(){this._bodyIndexPool=void 0,this._connecterIndexPool=void 0,this._indexMap=[],this._indexBuffer=new Uint16Array,this._bodyIndexPool=new Array(4);for(var e=0;e<4;++e)this._bodyIndexPool[e]=new cmt;this._connecterIndexPool=new Array(64);for(var i=0;i<4;++i)for(var r=0;r<4;++r)for(var n=0;n<4;++n)this._connecterIndexPool[t.mapIndex(i,r,n)]=new cmt;for(var s=0;s<4;++s)this._genBodyIndex(s);for(var a=0;a<4;++a)for(var o=0;o<4;++o)this._genConnecterIndexNorth(a,o),this._genConnecterIndexSouth(a,o),this._genConnecterIndexWest(a,o),this._genConnecterIndexEast(a,o);for(var l=0;l<4;++l)for(var h=0;h<4;++h)if(!(h<l))for(var u=0;u<4;++u)if(!(u<l))for(var c=0;c<4;++c)if(!(c<l))for(var _=0;_<4;++_)if(!(_<l)){var f=new umt;f.level=l,f.north=h,f.south=u,f.west=c,f.east=_,this._genIndexData(f)}}t.mapIndex=function(t,e,i){return 16*t+4*e+i};var e=t.prototype;return e.getIndexData=function(t){for(var e=0;e<this._indexMap.length;++e)if(this._indexMap[e].key.equals(t))return this._indexMap[e];return null},e._genBodyIndex=function(t){var e=1<<t,i=32>>t,r=0;if(t<3&&(i-=2,r=e*lmt+e),0!==i&&0!==i){var n=i*i*6;this._bodyIndexPool[t].indices=new Uint16Array(n);for(var s=0,a=new Uint16Array(n),o=r,l=o+lmt*e,h=0;h<i;++h){for(var u=0;u<i;++u)a[s++]=l+u*e,a[s++]=l+(u+1)*e,a[s++]=o+u*e,a[s++]=l+(u+1)*e,a[s++]=o+(u+1)*e,a[s++]=o+u*e;o+=lmt*e,l+=lmt*e}this._bodyIndexPool[t].size=s,this._bodyIndexPool[t].indices=a}},e._genConnecterIndexNorth=function(e,i){var r=t.mapIndex(e,i,0);if(i<e||3===e)return this._connecterIndexPool[r].size=0,void(this._connecterIndexPool[r].indices=null);var n=1<<e,s=1<<i,a=32>>e,o=0,l=new Uint16Array(2*a+2);l[o++]=0,l[o++]=0;for(var h=1;h<a;++h){var u=h*n,c=n*lmt+u,_=(n-n)*lmt+u/s*s;l[o++]=c,l[o++]=_}l[o++]=32,l[o++]=32,this._connecterIndexPool[r].size=o,this._connecterIndexPool[r].indices=l},e._genConnecterIndexSouth=function(e,i){var r=t.mapIndex(e,i,1);if(i<e||3===e)return this._connecterIndexPool[r].size=0,void(this._connecterIndexPool[r].indices=null);var n=1<<e,s=1<<i,a=32>>e,o=0,l=new Uint16Array(2*a+2);l[o++]=1056,l[o++]=1056;for(var h=1;h<a;++h){var u=h*n,c=32-n,_=(c+n)*lmt+u/s*s,f=c*lmt+u;l[o++]=_,l[o++]=f}l[o++]=1088,l[o++]=1088,this._connecterIndexPool[r].size=o,this._connecterIndexPool[r].indices=l},e._genConnecterIndexWest=function(e,i){var r=t.mapIndex(e,i,2);if(i<e||3===e)return this._connecterIndexPool[r].size=0,void(this._connecterIndexPool[r].indices=null);var n=1<<e,s=1<<i,a=32>>e,o=0,l=new Uint16Array(2*a+2);l[o++]=0,l[o++]=0;for(var h=1;h<a;++h){var u=h*n/s*s*lmt+0,c=h*n*lmt+n;l[o++]=u,l[o++]=c}l[o++]=1056,l[o++]=1056,this._connecterIndexPool[r].size=o,this._connecterIndexPool[r].indices=l},e._genConnecterIndexEast=function(e,i){var r=t.mapIndex(e,i,3);if(i<e||3===e)return this._connecterIndexPool[r].size=0,void(this._connecterIndexPool[r].indices=null);var n=1<<e,s=1<<i,a=32>>e,o=0,l=new Uint16Array(2*a+2);l[o++]=32,l[o++]=32;for(var h=1;h<a;++h){var u=h*n*lmt+(32-n),c=h*n/s*s*lmt+32;l[o++]=u,l[o++]=c}l[o++]=1088,l[o++]=1088,this._connecterIndexPool[r].size=o,this._connecterIndexPool[r].indices=l},e._getConnenterIndex=function(e,i,r){return this._connecterIndexPool[t.mapIndex(e,i,r)]},e._genIndexData=function(t){var e=this.getIndexData(t);if(null!=e)return e;var i=this._bodyIndexPool[t.level],r=this._getConnenterIndex(t.level,t.north,0),n=this._getConnenterIndex(t.level,t.south,1),s=this._getConnenterIndex(t.level,t.west,2),a=this._getConnenterIndex(t.level,t.east,3);if((e=new _mt).size=0,e.primCount=0,null!=i.indices&&(e.size+=i.size),r.indices&&(e.size+=3*(r.size-2)),n.indices&&(e.size+=3*(n.size-2)),s.indices&&(e.size+=3*(s.size-2)),a.indices&&(e.size+=3*(a.size-2)),0===e.size)return null;var o=0;if(e.buffer=new Uint16Array(e.size),e.key.level=t.level,e.key.east=t.east,e.key.west=t.west,e.key.north=t.north,e.key.south=t.south,i.indices)for(var l=0;l<i.size;++l)e.buffer[o++]=i.indices[l];if(r.indices)for(var h=0;h<r.size-2;h+=2){var u=r.indices[h+0],c=r.indices[h+1],_=r.indices[h+2],f=r.indices[h+3];e.buffer[o++]=u,e.buffer[o++]=_,e.buffer[o++]=c,e.buffer[o++]=_,e.buffer[o++]=f,e.buffer[o++]=c}if(n.indices)for(var d=0;d<n.size-2;d+=2){var p=n.indices[d+0],m=n.indices[d+1],g=n.indices[d+2],y=n.indices[d+3];e.buffer[o++]=p,e.buffer[o++]=g,e.buffer[o++]=m,e.buffer[o++]=g,e.buffer[o++]=y,e.buffer[o++]=m}if(s.indices)for(var v=0;v<s.size-2;v+=2){var b=s.indices[v+0],S=s.indices[v+1],A=s.indices[v+2],T=s.indices[v+3];e.buffer[o++]=b,e.buffer[o++]=A,e.buffer[o++]=S,e.buffer[o++]=A,e.buffer[o++]=T,e.buffer[o++]=S}if(a.indices)for(var C=0;C<a.size-2;C+=2){var x=a.indices[C+0],w=a.indices[C+1],E=a.indices[C+2],B=a.indices[C+3];e.buffer[o++]=x,e.buffer[o++]=E,e.buffer[o++]=w,e.buffer[o++]=E,e.buffer[o++]=B,e.buffer[o++]=w}e.primCount=o/3,e.start=this._indexBuffer.length,this._indexMap.push(e);var R=new Uint16Array(e.start+e.size);return R.set(this._indexBuffer,0),R.set(e.buffer,e.start),this._indexBuffer=R,e},t}(),dmt=t("TerrainInfo",En("cc.TerrainInfo")((fpt=function(){function t(){Mn(this,"tileSize",hpt,this),Mn(this,"blockCount",upt,this),Mn(this,"weightMapSize",cpt,this),Mn(this,"lightMapSize",_pt,this)}return Ur(t,[{key:"size",get:function(){var t=new d(0,0);return t.width=this.blockCount[0]*oht*this.tileSize,t.height=this.blockCount[1]*oht*this.tileSize,t}},{key:"tileCount",get:function(){var t=[0,0];return t[0]=this.blockCount[0]*oht,t[1]=this.blockCount[1]*oht,t}},{key:"vertexCount",get:function(){var t=this.tileCount;return t[0]+=1,t[1]+=1,t}}]),t}(),hpt=Dn((lpt=fpt).prototype,"tileSize",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),upt=Dn(lpt.prototype,"blockCount",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[1,1]}}),cpt=Dn(lpt.prototype,"weightMapSize",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 128}}),_pt=Dn(lpt.prototype,"lightMapSize",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 128}}),opt=lpt))||opt),pmt=t("TerrainLayer",En("cc.TerrainLayer")((mpt=Dn((ppt=function(){Mn(this,"detailMap",mpt,this),Mn(this,"normalMap",gpt,this),Mn(this,"tileSize",ypt,this),Mn(this,"metallic",vpt,this),Mn(this,"roughness",bpt,this)}).prototype,"detailMap",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gpt=Dn(ppt.prototype,"normalMap",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ypt=Dn(ppt.prototype,"tileSize",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),vpt=Dn(ppt.prototype,"metallic",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),bpt=Dn(ppt.prototype,"roughness",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),dpt=ppt))||dpt),mmt=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._brushPass=null,e._brushMaterial=null,e._currentMaterial=null,e._currentMaterialLayers=0,e}on(e,t);var i=e.prototype;return i.destroy=function(){return null!=this._model&&(Er.director.root.destroyModel(this._model),this._model=null),t.prototype.destroy.call(this)},i._destroyModel=function(){null!=this._model&&(Er.director.root.destroyModel(this._model),this._model=null)},i._invalidMaterial=function(){null!=this._currentMaterial&&(this._clearMaterials(),this._brushPass=null,this._currentMaterial=null,null!=this._model&&(this._model.enabled=!1))},i._updateMaterial=function(t,e){if(null==this._meshData||null==this._model)return!1;var i=t.getMaxLayer();if(null==this._currentMaterial||i!==this._currentMaterialLayers){if(this._currentMaterial=new cn,this._currentMaterial.initialize({effectAsset:t.getTerrain().getEffectAsset(),defines:t._getMaterialDefines(i)}),null!==this._brushMaterial){var r=new cn;r.copy(this._brushMaterial),this._brushPass=null,null!==r.passes&&r.passes.length>0&&(this._brushPass=r.passes[0],this._currentMaterial.passes.push(this._brushPass),r.passes.pop())}return 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,!0}return!1},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 os.get("missing-material")},e}(Ys),gmt=t("TerrainBlockLightmapInfo",En("cc.TerrainBlockLightmapInfo")((Tpt=Dn((Apt=function(){Mn(this,"texture",Tpt,this),Mn(this,"UOff",Cpt,this),Mn(this,"VOff",xpt,this),Mn(this,"UScale",wpt,this),Mn(this,"VScale",Ept,this)}).prototype,"texture",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Cpt=Dn(Apt.prototype,"UOff",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),xpt=Dn(Apt.prototype,"VOff",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),wpt=Dn(Apt.prototype,"UScale",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Ept=Dn(Apt.prototype,"VScale",[On,Un],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Spt=Apt))||Spt),ymt=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._lodLevel=0,this._lodKey=new umt,this._errorMetrics=[0,0,0,0],this._LevelDistances=[hmt,hmt,hmt,hmt],this._bbMin=new n,this._bbMax=new n,this._terrain=t,this._index[0]=e,this._index[1]=i,this._lightmapInfo=t._getLightmapInfo(e,i),this._node=new ks("TerrainBlock"),this._node.setParent(this._terrain.node),this._node.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy,this._node.layer=this._terrain.node.layer,this._renderable=this._node.addComponent(mmt)}var e=t.prototype;return e.build=function(){var t=Kr.root.device,e=new Float32Array(hht*lht*lht);this._buildVertexData(e);var i=t.createBuffer(new ee(rt.VERTEX|rt.TRANSFER_DST,at.DEVICE,hht*Float32Array.BYTES_PER_ELEMENT*lht*lht,hht*Float32Array.BYTES_PER_ELEMENT));i.update(e),this._buildBoundingBox();var r=[new ye(He.ATTR_POSITION,tt.RGB32F),new ye(He.ATTR_NORMAL,tt.RGB32F),new ye(He.ATTR_TEX_COORD,tt.RG32F)];this._renderable._meshData=new Bn([i],r,wt.TRIANGLE_LIST,this._terrain._getSharedIndexBuffer(),null,!1),this._renderable._model=Er.director.root.createModel(sr),this._renderable._model.createBoundingShape(this._bbMin,this._bbMax),this._renderable._model.node=this._renderable._model.transform=this._node,null!=this._renderable.node.scene&&(this.visible=!0),this._updateWeightMap(),this._updateMaterial(!0),this._updateLodBuffer(e),this._updateIndexBuffer()},e.rebuild=function(){this._updateHeight(),this._updateWeightMap(),this._renderable._invalidMaterial(),this._updateMaterial(!1)},e.destroy=function(){this.visible=!1,this._renderable._destroyModel(),null!=this._node&&this._node.isValid&&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=Er.builtinResMgr.get("normal-texture")),e},n=this._renderable._currentMaterial;if(null!==n){var s=this.getMaxLayer(),o=new a(1,1,1,1),l=new a(1,1,1,1),h=new a(0,0,0,0);if(0===s)if(-1!==this.layers[0]){var u=this._terrain.getLayer(this.layers[0]);null!==u&&(o.x=1/u.tileSize,l.x=u.roughness,h.x=u.metallic),n.setProperty("detailMap0",i(u)),t&&n.setProperty("normalMap0",r(u))}else n.setProperty("detailMap0",Er.builtinResMgr.get("default-texture")),t&&n.setProperty("normalMap0",Er.builtinResMgr.get("normal-texture"));else if(1===s){var c=this._terrain.getLayer(this.layers[0]),_=this._terrain.getLayer(this.layers[1]);null!==c&&(o.x=1/c.tileSize,l.x=c.roughness,h.x=c.metallic),null!==_&&(o.y=1/_.tileSize,l.y=_.roughness,h.y=_.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(c)),n.setProperty("detailMap1",i(_)),t&&(n.setProperty("normalMap0",r(c)),n.setProperty("normalMap1",r(_)))}else if(2===s){var f=this._terrain.getLayer(this.layers[0]),d=this._terrain.getLayer(this.layers[1]),p=this._terrain.getLayer(this.layers[2]);null!==f&&(o.x=1/f.tileSize,l.x=f.roughness,h.x=f.metallic),null!==d&&(o.y=1/d.tileSize,l.y=d.roughness,h.y=d.metallic),null!==p&&(o.z=1/p.tileSize,l.z=p.roughness,h.z=p.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(f)),n.setProperty("detailMap1",i(d)),n.setProperty("detailMap2",i(p)),t&&(n.setProperty("normalMap0",r(f)),n.setProperty("normalMap1",r(d)),n.setProperty("normalMap2",r(p)))}else if(3===s){var m=this._terrain.getLayer(this.layers[0]),g=this._terrain.getLayer(this.layers[1]),y=this._terrain.getLayer(this.layers[2]),v=this._terrain.getLayer(this.layers[3]);null!==m&&(o.x=1/m.tileSize,l.x=m.roughness,h.x=m.metallic),null!==g&&(o.y=1/g.tileSize,l.y=g.roughness,h.y=g.metallic),null!==y&&(o.z=1/y.tileSize,l.z=y.roughness,h.z=y.metallic),null!==v&&(o.w=1/v.tileSize,l.w=v.roughness,h.w=v.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(m)),n.setProperty("detailMap1",i(g)),n.setProperty("detailMap2",i(y)),n.setProperty("detailMap3",i(v)),t&&(n.setProperty("normalMap0",r(m)),n.setProperty("normalMap1",r(g)),n.setProperty("normalMap2",r(y)),n.setProperty("normalMap3",r(v)))}n.setProperty("UVScale",o),e&&(n.setProperty("roughness",l),n.setProperty("metallic",h)),null!==this.lightmap&&(n.setProperty("lightMap",this.lightmap),n.setProperty("lightMapUVParam",this.lightmapUVParam))}},e._updateLevel=function(t){var e=new n,i=new n;n.add(e,this._bbMin,this._terrain.node.getWorldPosition()),n.add(i,this._bbMax,this._terrain.node.getWorldPosition());var r=n.distance(e,t),s=n.distance(i,t),a=Math.min(r,s);for(a-=this._terrain.LodBias,this._lodLevel=0;this._lodLevel<3&&!(a<=this._LevelDistances[this._lodLevel+1]);)++this._lodLevel},e.setBrushMaterial=function(t){this._renderable._brushMaterial!==t&&(this._renderable._invalidMaterial(),this._renderable._brushMaterial=t)},e._getBrushMaterial=function(){return this._renderable?this._renderable._brushMaterial:null},e._getBrushPass=function(){return this._renderable?this._renderable._brushPass:null},e.getTerrain=function(){return this._terrain},e.getIndex=function(){return this._index},e.getRect=function(){var t=new m;return t.x=this._index[0]*oht,t.y=this._index[1]*oht,t.width=oht,t.height=oht,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,CC_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)&&null!==this.lightmap&&this.lightmap.setWrapMode(Zs.CLAMP_TO_BORDER,Zs.CLAMP_TO_BORDER)},e._updateHeight=function(){if(null!=this._renderable._meshData){var t=new Float32Array(hht*lht*lht);this._buildVertexData(t),this._renderable._meshData.vertexBuffers[0].update(t),this._buildBoundingBox(),this._renderable._model.createBoundingShape(this._bbMin,this._bbMax),this._renderable._model.updateWorldBound(),this._updateLodBuffer(t),this._updateIndexBuffer()}},e._updateWeightMap=function(){if(0!==this.getMaxLayer()){null==this._weightMap&&(this._weightMap=new fn,this._weightMap.create(this._terrain.weightMapSize,this._terrain.weightMapSize,_n.RGBA8888),this._weightMap.setFilters(dn.LINEAR,dn.LINEAR),this._weightMap.setWrapMode(Zs.CLAMP_TO_EDGE,Zs.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()},e._updateLod=function(){var t=new umt;if(t.level=this._lodLevel,t.north=this._lodLevel,t.south=this._lodLevel,t.west=this._lodLevel,t.east=this._lodLevel,this._index[0]>0){var e=this.getTerrain().getBlock(this._index[0]-1,this._index[1]);t.west=e._lodLevel,t.west<this._lodLevel&&(t.west=this._lodLevel)}if(this._index[0]<this._terrain.info.blockCount[0]-1){var i=this.getTerrain().getBlock(this._index[0]+1,this._index[1]);t.east=i._lodLevel,t.east<this._lodLevel&&(t.east=this._lodLevel)}if(this._index[1]>0){var r=this.getTerrain().getBlock(this._index[0],this._index[1]-1);t.north=r._lodLevel,t.north<this._lodLevel&&(t.north=this._lodLevel)}if(this._index[1]<this._terrain.info.blockCount[1]-1){var n=this.getTerrain().getBlock(this._index[0],this._index[1]+1);t.south=n._lodLevel,t.south<this._lodLevel&&(t.south=this._lodLevel)}this._lodKey.equals(t)||(this._lodKey=t,this._updateIndexBuffer())},e._resetLod=function(){var t=new umt;t.level=0,t.north=0,t.south=0,t.west=0,t.east=0,this._lodKey.equals(t)||(this._lodKey=t,this._updateIndexBuffer())},e._updateIndexBuffer=function(){if(null!==this._renderable._meshData&&null!==this._renderable._model&&0!==this._renderable._model.subModels.length){var t=this._terrain._getIndexData(this._lodKey);if(null!==t){var e=this._renderable._model.subModels[0];e.inputAssembler.firstIndex=t.start,e.inputAssembler.indexCount=t.size}}},e._getHeight=function(t,e,i){return i[(lht*e+t)*hht+1]},e._updateLodBuffer=function(t){this._lodLevel=0,this._lodKey=new umt,this._calcErrorMetrics(t),this._calcLevelDistances(t)},e._calcErrorMetrics=function(t){this._errorMetrics[0]=0;for(var e=1;e<4;++e)this._errorMetrics[e]=this._calcErrorMetric(e,t);for(var i=2;i<4;++i)this._errorMetrics[i]=Math.max(this._errorMetrics[i],this._errorMetrics[i-1])},e._calcErrorMetric=function(t,e){for(var i=0,r=1<<t,n=lht,s=lht,a=n-1>>t,o=s-1>>t,l=0;l<s;l+=r)for(var h=0;h<a;++h){var u=h*r,c=u+r,_=(c+u)/2,f=this._getHeight(u,l,e),d=this._getHeight(c,l,e),p=this._getHeight(_,l,e),m=(f+d)/2,g=Math.abs(p-m);i=Math.max(i,g)}for(var y=0;y<n;y+=r)for(var v=0;v<o;++v){var b=v*r,S=b+r,A=(b+S)/2,T=this._getHeight(y,b,e),C=this._getHeight(y,S,e),x=this._getHeight(y,A,e),w=(T+C)/2,E=Math.abs(x-w);i=Math.max(i,E)}for(var B=0;B<o;++B)for(var R=B*r,D=R+r,M=(R+D)/2,P=0;P<a;++P){var I=P*r,O=I+r,F=(I+O)/2,L=this._getHeight(I,R,e),k=this._getHeight(O,D,e),V=this._getHeight(F,M,e),N=(L+k)/2,G=Math.abs(V-N);i=Math.max(i,G)}return i},e._calcLevelDistances=function(){for(var t=1;t<4;++t){var e=96*this._errorMetrics[t];this._LevelDistances[t]=e}},e._buildVertexData=function(t){for(var e=0,r=0;r<lht;++r)for(var n=0;n<lht;++n){var s=this._index[0]*oht+n,a=this._index[1]*oht+r,o=this._terrain.getPosition(s,a),l=this._terrain.getNormal(s,a),h=new i(n/oht,r/oht);t[e++]=o.x,t[e++]=o.y,t[e++]=o.z,t[e++]=l.x,t[e++]=l.y,t[e++]=l.z,t[e++]=h.x,t[e++]=h.y}},e._buildBoundingBox=function(){this._bbMin.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._bbMax.set(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(var t=0;t<lht;++t)for(var e=0;e<lht;++e){var i=this._index[0]*oht+e,r=this._index[1]*oht+t,s=this._terrain.getPosition(i,r);n.min(this._bbMin,this._bbMin,s),n.max(this._bbMax,this._bbMax,s)}},Ur(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:"material",get:function(){return this._renderable?this._renderable._currentMaterial:null}},{key:"layers",get:function(){return this._terrain.getBlockLayers(this._index[0],this._index[1])}},{key:"weightmap",get:function(){return this._weightMap}},{key:"lightmap",get:function(){return this._lightmapInfo?this._lightmapInfo.texture:null}},{key:"lightmapUVParam",get:function(){return null!=this._lightmapInfo?new a(this._lightmapInfo.UOff,this._lightmapInfo.VOff,this._lightmapInfo.UScale,this._lightmapInfo.VScale):new a(0,0,0,0)}},{key:"visible",get:function(){return null!==this._renderable._model&&null!==this._renderable._model.scene},set:function(t){null!==this._renderable._model&&(t?null!=this._terrain.node&&null!=this._terrain.node.scene&&null!=this._terrain.node.scene.renderScene&&null==this._renderable._model.scene&&this._terrain.node.scene.renderScene.addModel(this._renderable._model):null!==this._renderable._model.scene&&this._renderable._model.scene.removeModel(this._renderable._model))}}]),t}());t("Terrain",(Bpt=En("cc.Terrain"),Rpt=Qn(),Dpt=Wn(Tht),Mpt=Wn(Bo),Ppt=cs(),Ipt=Wn(gmt),Opt=Wn(ha),Fpt=Wn(ha),Lpt=Wn(ha),kpt=Wn(ha),Vpt=Wn(sa),Npt=Wn(Tht),Gpt=cs(),zpt=Wn(Bo),Upt=cs(),Hpt=Wn(dmt),Bpt(Xpt=Rpt(Xpt=Jn(Xpt=Kn((tmt=function(t){function e(){var e;e=t.call(this)||this,Mn(e,"__asset",jpt,Pn(e)),Mn(e,"_effectAsset",Ypt,Pn(e)),Mn(e,"_lightmapInfos",qpt,Pn(e)),Mn(e,"_receiveShadow",Kpt,Pn(e)),Mn(e,"_useNormalmap",Jpt,Pn(e)),Mn(e,"_usePBR",Zpt,Pn(e)),Mn(e,"_lodEnable",Qpt,Pn(e)),Mn(e,"_lodBias",$pt,Pn(e)),e._buitinAsset=null,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._lod=new fmt,e._sharedIndexBuffer=null;for(var i=0;i<aht;++i)e._layerList.push(null);return e}on(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._resetLightmap(!1),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 ymt(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 Tht;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&&Ro(r.detailMap)){var n=new Sht;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?Er.EffectAsset.get("builtin-terrain"):this._effectAsset},i.onEnable=function(){0===this._blocks.length&&this._buildImp();for(var t=0;t<this._blocks.length;++t)this._blocks[t].visible=!0;Er.director.root.pipelineEvent.on(Do.RENDER_CAMERA_BEGIN,this.onUpdateFromCamera,this)},i.onDisable=function(){Er.director.root.pipelineEvent.off(Do.RENDER_CAMERA_BEGIN,this.onUpdateFromCamera,this);for(var t=0;t<this._blocks.length;++t)this._blocks[t].visible=!1},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.onEnable(),this._buildImp(!0)},i.update=function(){for(var t=0;t<this._blocks.length;++t)this._blocks[t].update()},i.onUpdateFromCamera=function(t){if(this.lodEnable&&t.scene===this._getRenderScene()){for(var e=0;e<this._blocks.length;++e)this._blocks[e]._updateLevel(t.position);for(var i=0;i<this._blocks.length;++i)this._blocks[i]._updateLod()}},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,s=this.getHeight(t,e);return new n(i,s,r)},i.getHeightField=function(){return this._heights},i.setHeight=function(t,e,i){i=T(i,_ht,fht),this._heights[e*this.vertexCount[0]+t]=uht+i/cht},i.getHeight=function(t,e){return(this._heights[e*this.vertexCount[0]+t]-uht)*cht},i.getHeightClamp=function(t,e){return t=T(t,0,this.vertexCount[0]-1),e=T(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=T(n,0,this.vertexCount[0]-1),s=T(s,0,this.vertexCount[1]-1),a=T(a,0,this.vertexCount[0]-1),o=T(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),d=.5*(c+_);return l+h<=1?f=d+(d-u):u=d+(d-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 n;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,s=Math.floor(i),a=Math.floor(r),o=s+1,l=a+1,h=i-s,u=r-a;if(s<0||s>this.vertexCount[0]-1||a<0||a>this.vertexCount[1]-1)return null;s=T(s,0,this.vertexCount[0]-1),a=T(a,0,this.vertexCount[1]-1),o=T(o,0,this.vertexCount[0]-1),l=T(l,0,this.vertexCount[1]-1);var c=this.getNormal(s,a),_=this.getNormal(o,a),f=this.getNormal(s,l),d=this.getNormal(o,l),p=new n;n.add(p,_,f).multiplyScalar(.5),h+u<=1?(d.set(p),d.subtract(c),d.add(p)):(c.set(p),c.subtract(d),c.add(p));var m=new n,g=new n,y=new n;return n.lerp(m,c,_,h),n.lerp(g,f,d,h),n.lerp(y,m,g,u),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 a;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,o=Math.floor(n),l=Math.floor(s),h=o+1,u=l+1,c=n-o,_=s-l;if(o<0||o>i-1||l<0||l>r-1)return null;o=T(o,0,i-1),l=T(l,0,r-1),h=T(h,0,i-1),u=T(u,0,r-1);var f=this.getWeight(o,l),d=this.getWeight(h,l),p=this.getWeight(o,u),m=this.getWeight(h,u),g=new a;a.add(g,d,p).multiplyScalar(.5),c+_<=1?(m=new a,a.subtract(m,g,f).add(g)):(f=new a,a.subtract(f,g,m).add(g));var y=new a,v=new a,b=new a;return a.lerp(y,f,d,c),a.lerp(v,p,m,c),a.lerp(b,y,v,_),b},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)*sht;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)*sht;return this._layerBuffer[r+i]},i.setBlockLayer=function(t,e,i,r){var n=(e*this._blockCount[0]+t)*sht;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 s=t;r&&n.subtract(s,t,this.node.getWorldPosition());var a=new n;a.set(e),a.multiplyScalar(i);var o=null;if(e.equals(new n(0,1,0))){var l=this.getHeightAt(s.x,s.z);null!=l&&s.y<=l&&(o=new n(s.x,l,s.z))}else if(e.equals(new n(0,-1,0))){var h=this.getHeightAt(s.x,s.z);null!=h&&s.y>=h&&(o=new n(s.x,h,s.z))}else{for(var u=0;u++<2e3;){var c=this.getHeightAt(s.x,s.z);if(null!=c&&s.y<=c)break;s.add(e)}for(;u++<2e3;){var _=this.getHeightAt(s.x,s.z);if(null!=_&&s.y<=_){o=new n(s.x,_,s.z);break}s.add(a)}}return o},i._createSharedIndexBuffer=function(){var t=Ci.gfxDevice.createBuffer(new ee(rt.INDEX|rt.TRANSFER_DST,at.DEVICE,Uint16Array.BYTES_PER_ELEMENT*this._lod._indexBuffer.length,Uint16Array.BYTES_PER_ELEMENT));return t.update(this._lod._indexBuffer),t},i._getSharedIndexBuffer=function(){return null==this._sharedIndexBuffer&&(this._sharedIndexBuffer=this._createSharedIndexBuffer()),this._sharedIndexBuffer},i._getIndexData=function(t){return this._lod.getIndexData(t)},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 gmt)},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,s=1,a=this.getPosition(t,e);t<this.vertexCount[0]-1?i=this.getPosition(t+1,e):(s*=-1,i=this.getPosition(t-1,e)),e<this.vertexCount[1]-1?r=this.getPosition(t,e+1):(s*=-1,r=this.getPosition(t,e-1)),i.subtract(a),r.subtract(a);var o=new n;return o.set(r),o.cross(i),o.multiplyScalar(s),o.normalize(),o},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(this._buitinAsset!==i&&(this._buitinAsset=i),!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<yht)for(var n=function(t){var r=new pmt,n=i.layerBinaryInfos[t];r.tileSize=n.tileSize,Er.assetManager.loadAny(n.detailMapId,(function(t,e){r.detailMap=e})),""!==n.normalMapId&&Er.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 pmt,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]=uht,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]*sht;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],d=this._weightMapSize*this._blockCount[1];if(this._weights.length!==f*d*4){this._weights=new Uint8Array(f*d*4);for(var p=0;p<f*d;++p)this._weights[4*p+0]=255,this._weights[4*p+1]=0,this._weights[4*p+2]=0,this._weights[4*p+3]=0}for(var m=0;m<this._blockCount[1];++m)for(var g=0;g<this._blockCount[0];++g)this._blocks.push(new ymt(this,g,m));for(var y=0;y<this._blocks.length;++y)this._blocks[y].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]=uht;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]*sht;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<sht;++h)e[o*sht+h]=this._layerBuffer[l*sht+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],o=t.weightMapSize*t.blockCount[1];if(s===r&&o===n)return!1;for(var l=new Uint8Array(s*o*4),h=0;h<s*o;++h)l[4*h+0]=255,l[4*h+1]=0,l[4*h+2]=0,l[4*h+3]=0;for(var u=Math.min(t.blockCount[0],this._blockCount[0]),c=Math.min(t.blockCount[1],this._blockCount[1]),_=function(t,e,i){var n=e*r+t,s=new a;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},f=function(t,r,n,s){var o=Math.floor(t),l=Math.floor(r),h=Math.min(o+1,i-1),u=Math.min(l+1,i-1),c=t-o,f=r-l,d=_(o+n,l+s,e._weights),p=_(h+n,l+s,e._weights),m=_(o+n,u+s,e._weights),g=_(h+n,u+s,e._weights),y=new a;a.add(y,p,m).multiplyScalar(.5),c+f<=1?(g.set(y),g.subtract(d),g.add(y)):(d.set(y),d.subtract(g),d.add(y));var v=new a,b=new a,S=new a;return a.lerp(v,d,p,c),a.lerp(b,m,g,c),a.lerp(S,v,b,f),S},d=0;d<c;++d)for(var p=0;p<u;++p)for(var m=p*i,g=d*i,y=0;y<t.weightMapSize;++y)for(var v=0;v<t.weightMapSize;++v){var b=void 0;b=t.weightMapSize===i?_(v+m,y+g,this._weights):f(v/(t.weightMapSize-1)*(i-1),y/(t.weightMapSize-1)*(i-1),m,g,this._weights);var S=p*t.weightMapSize+v,A=(d*t.weightMapSize+y)*s+S;l[4*A+0]=255*b.x,l[4*A+1]=255*b.y,l[4*A+2]=255*b.z,l[4*A+3]=255*b.w}return this._weights=l,!0},Ur(e,[{key:"_asset",get:function(){return this.__asset},set:function(t){if(this.__asset=t,this._buitinAsset!==this.__asset){this._buitinAsset=this.__asset;for(var e=0;e<this._blocks.length;++e)this._blocks[e].destroy();if(this._blocks=[],null===this.__asset){this._effectAsset=null,this._lightmapInfos=[],this._receiveShadow=!1,this._useNormalmap=!1,this._usePBR=!1,this._tileSize=1,this._blockCount=[1,1],this._weightMapSize=128,this._lightMapSize=128,this._heights=new Uint16Array,this._weights=new Uint8Array,this._normals=[],this._layerBuffer=[],this._blocks=[],this._layerList=[];for(var i=0;i<aht;++i)this._layerList.push(null)}Ci.gfxDevice&&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:"lodEnable",get:function(){return this._lodEnable},set:function(t){if(this._lodEnable=t,!this._lodEnable)for(var e=0;e<this._blocks.length;e++)this._blocks[e]._resetLod()}},{key:"LodBias",get:function(){return this._lodBias},set:function(t){this._lodBias=t}},{key:"size",get:function(){var t=new d(0,0);return t.width=this.blockCount[0]*oht*this.tileSize,t.height=this.blockCount[1]*oht*this.tileSize,t}},{key:"tileSize",get:function(){return this._tileSize}},{key:"tileCount",get:function(){return[this.blockCount[0]*oht,this.blockCount[1]*oht]}},{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 dmt;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}(ns),jpt=Dn((Wpt=tmt).prototype,"__asset",[Dpt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ypt=Dn(Wpt.prototype,"_effectAsset",[Mpt,On,hs,Ppt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qpt=Dn(Wpt.prototype,"_lightmapInfos",[Ipt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Kpt=Dn(Wpt.prototype,"_receiveShadow",[Opt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Jpt=Dn(Wpt.prototype,"_useNormalmap",[Fpt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Zpt=Dn(Wpt.prototype,"_usePBR",[Lpt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Qpt=Dn(Wpt.prototype,"_lodEnable",[kpt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),$pt=Dn(Wpt.prototype,"_lodBias",[Vpt,On,hs],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(Wpt.prototype,"_asset",[Npt,Gpt],Object.getOwnPropertyDescriptor(Wpt.prototype,"_asset"),Wpt.prototype),Dn(Wpt.prototype,"effectAsset",[zpt,Upt],Object.getOwnPropertyDescriptor(Wpt.prototype,"effectAsset"),Wpt.prototype),Dn(Wpt.prototype,"receiveShadow",[Un],Object.getOwnPropertyDescriptor(Wpt.prototype,"receiveShadow"),Wpt.prototype),Dn(Wpt.prototype,"useNormalMap",[Un],Object.getOwnPropertyDescriptor(Wpt.prototype,"useNormalMap"),Wpt.prototype),Dn(Wpt.prototype,"usePBR",[Un],Object.getOwnPropertyDescriptor(Wpt.prototype,"usePBR"),Wpt.prototype),Dn(Wpt.prototype,"lodEnable",[Un],Object.getOwnPropertyDescriptor(Wpt.prototype,"lodEnable"),Wpt.prototype),Dn(Wpt.prototype,"LodBias",[Un],Object.getOwnPropertyDescriptor(Wpt.prototype,"LodBias"),Wpt.prototype),Dn(Wpt.prototype,"info",[Hpt],Object.getOwnPropertyDescriptor(Wpt.prototype,"info"),Wpt.prototype),Xpt=Wpt))||Xpt)||Xpt)||Xpt)||Xpt)),function(t){t[t.ORTHO=0]="ORTHO",t[t.HEX=1]="HEX",t[t.ISO=2]="ISO"}(emt||(emt={})),ss(emt),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"}(imt||(imt={})),ss(imt),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"}(rmt||(rmt={})),ss(rmt),function(t){t[t.STAGGERAXIS_X=0]="STAGGERAXIS_X",t[t.STAGGERAXIS_Y=1]="STAGGERAXIS_Y"}(nmt||(nmt={})),ss(nmt),function(t){t[t.STAGGERINDEX_ODD=0]="STAGGERINDEX_ODD",t[t.STAGGERINDEX_EVEN=1]="STAGGERINDEX_EVEN"}(smt||(smt={})),ss(smt),function(t){t[t.RightDown=0]="RightDown",t[t.RightUp=1]="RightUp",t[t.LeftDown=2]="LeftDown",t[t.LeftUp=3]="LeftUp"}(amt||(amt={})),ss(amt),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"}(omt||(omt={})),ss(omt);var vmt=function(){function t(){this.name="",this.firstGid=0,this.spacing=0,this.margin=0,this.sourceImage=void 0,this.imageName=null,this.imageSize=new d(0,0),this.tileOffset=new i(0,0),this._tileSize=new d(0,0),this.collection=!1}return t.prototype.rectForGID=function(t,e){var i=e||new m(0,0,0,0);i.width=this._tileSize.width,i.height=this._tileSize.height;var r=t;r&=rmt.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}(),bmt=function(){function t(){this.properties={},this.name="",this.objects=[],this.visible=!0,this.opacity=0,this.color=new y(255,255,255,255),this.offset=new i(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}(),Smt=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 i(0,0),this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}();Smt.ATTRIB_NONE=1,Smt.ATTRIB_BASE64=2,Smt.ATTRIB_GZIP=4,Smt.ATTRIB_ZLIB=8;var Amt=function(){this.name="",this.visible=!0,this.width=0,this.height=0,this.offset=new i(0,0),this.opacity=0,this.trans=new y(255,255,255,255),this.sourceImage=void 0,this.tintColor=null};function Tmt(t){var e=of.HorizontalAlign;switch(t){case"center":return e.CENTER;case"right":return e.RIGHT;default:return e.LEFT}}function Cmt(t){var e=of.VerticalAlign;switch(t){case"center":return e.CENTER;case"bottom":return e.BOTTOM;default:return e.TOP}}function xmt(t){if(!t)return new y(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 y(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 y(s,a,o,255)}function wmt(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=xmt(c)),e[h]=c}return e}var Emt,Bmt,Rmt,Dmt,Mmt,Pmt,Imt,Omt,Fmt,Lmt,kmt,Vmt,Nmt,Gmt,zmt,Umt,Hmt=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=amt.RightDown,this._supportVersion=[1,4,0],this._objectGroups=[],this._allChildren=[],this._mapSize=new d(0,0),this._tileSize=new d(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 d(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 d(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=Smt.ATTRIB_NONE,this.parentElement=null,this.parseXMLString(t)},e.parseXMLString=function(e,i){var r,n=(new Mo).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){Qs(7216,u);break}}"orthogonal"===s?this.orientation=emt.ORTHO:"isometric"===s?this.orientation=emt.ISO:"hexagonal"===s?this.orientation=emt.HEX:null!==s&&Qs(7217,s),this.renderOrder="right-up"===h?amt.RightUp:"left-up"===h?amt.LeftUp:"left-down"===h?amt.LeftDown:amt.RightDown,"x"===a?this.setStaggerAxis(nmt.STAGGERAXIS_X):"y"===a&&this.setStaggerAxis(nmt.STAGGERAXIS_Y),"odd"===o?this.setStaggerIndex(smt.STAGGERINDEX_ODD):"even"===o&&this.setStaggerIndex(smt.STAGGERINDEX_EVEN),l&&this.setHexSideLength(parseFloat(l));var p=new d(0,0);p.width=parseFloat(n.getAttribute("width")),p.height=parseFloat(n.getAttribute("height")),this.setMapSize(p),(p=new d(0,0)).width=parseFloat(n.getAttribute("tilewidth")),p.height=parseFloat(n.getAttribute("tileheight")),this.setTileSize(p),this.properties=wmt(n)}var m=n.getElementsByTagName("tileset");for("map"!==n.nodeName&&(m=[]).push(n),r=0;r<m.length;r++){var g=m[r],y=g.getAttribute("source");if(y){var v=parseInt(g.getAttribute("firstgid")),b=this._tsxContentMap[y];b&&this.parseXMLString(b,v)}else{var S=g.getElementsByTagName("image"),A=S.length>1,T=S[0],C=T.getAttribute("source");C=C.replace(/\\/g,"/");var x=g.getElementsByTagName("tile"),w=x&&x.length||1,E=null,B=g.getAttribute("name")||"",R=parseInt(g.getAttribute("spacing"))||0,D=parseInt(g.getAttribute("margin"))||0,M=i||parseInt(g.getAttribute("firstgid"))||0,P=new d(0,0);P.width=parseFloat(g.getAttribute("tilewidth")),P.height=parseFloat(g.getAttribute("tileheight"));var I=g.getElementsByTagName("tileoffset")[0],O=0,F=0;I&&(O=parseFloat(I.getAttribute("x"))||0,F=parseFloat(I.getAttribute("y"))||0);for(var L=null,k=0;k<w;k++){var V=S[k]?S[k]:T;if(V){var N=V.getAttribute("source");if(N=N.replace(/\\/g,"/"),!L||A){if((L=new vmt).name=B,L.firstGid=M&rmt.FLIPPED_MASK,L.tileOffset.x=O,L.tileOffset.y=F,L.collection=A,!A&&(L.imageName=N,L.imageSize.width=parseFloat(V.getAttribute("width"))||0,L.imageSize.height=parseFloat(V.getAttribute("height"))||0,L.sourceImage=this._spriteFrameMap[N],!L.sourceImage)){var G=t.getNameWithPostfix(N);if(L.imageName=G,L.sourceImage=this._spriteFrameMap[G],!L.sourceImage){var z=t.getShortName(N);L.imageName=z,L.sourceImage=this._spriteFrameMap[z],L.sourceImage||(console.error("[error]: "+z+" not find in ["+Object.keys(this._spriteFrameMap).join(", ")+"]"),Nn(7221,N),console.warn("Please try asset type of "+N+" to 'sprite-frame'"))}}L.spacing=R,L.margin=D,L._tileSize.width=P.width,L._tileSize.height=P.height,this.setTilesets(L)}if(E=x&&x[k]){this.parentGID=M+(parseInt(E.getAttribute("id"))||0);var U=E.getElementsByTagName("image");if(U&&U.length>0){var H=U[0],X=H.getAttribute("source");if(X=X.replace(/\\/g,"/"),L.imageName=X,L.imageSize.width=parseFloat(H.getAttribute("width"))||0,L.imageSize.height=parseFloat(H.getAttribute("height"))||0,L._tileSize.width=L.imageSize.width,L._tileSize.height=L.imageSize.height,L.sourceImage=this._spriteFrameMap[X],!L.sourceImage){var W=t.getNameWithPostfix(X);if(L.imageName=W,L.sourceImage=this._spriteFrameMap[W],!L.sourceImage){var j=t.getShortName(X);L.imageName=j,L.sourceImage=this._spriteFrameMap[j],L.sourceImage||(Nn(7221,X),console.warn("Please try asset type of "+X+" to 'sprite-frame'"))}}L.firstGid=this.parentGID&rmt.FLIPPED_MASK}var Y=(rmt.FLIPPED_MASK&this.parentGID)>>>0;this._tileProperties.set(Y,wmt(E));var q=E.getElementsByTagName("animation");if(q&&q.length>0){var K=q[0].getElementsByTagName("frame"),J={frames:[],dt:0,frameIdx:0};this._tileAnimations.set(Y,J);for(var Z=J.frames,Q=0;Q<K.length;Q++){var $=K[Q],tt=M+(parseInt($.getAttribute("tileid"))||0),et=parseFloat($.getAttribute("duration"))||0;Z.push({tileid:tt,duration:et/1e3,grid:null})}}}}}}}var it=n.childNodes;for(r=0;r<it.length;r++){var rt=it[r];if(!this._shouldIgnoreNode(rt)){if("imagelayer"===rt.nodeName){var nt=this._parseImageLayer(rt);nt&&this.setImageLayers(nt)}if("layer"===rt.nodeName){var st=this._parseLayer(rt);this.setLayers(st)}if("objectgroup"===rt.nodeName){var at=this._parseObjectGroup(rt);this.setObjectGroups(at)}}}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 Amt;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?xmt(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=xmt(a.getAttribute("trans")),i.sourceImage?i:(Nn(7221,o),console.warn("Please try asset type of "+o+" to 'sprite-frame'"),null)},e._parseLayer=function(t){var e=t.getElementsByTagName("data")[0],r=new Smt;r.name=t.getAttribute("name");var n=new d(0,0);n.width=parseFloat(t.getAttribute("width")),n.height=parseFloat(t.getAttribute("height")),r.layerSize=n;var s=t.getAttribute("visible");r.visible=!("0"===s);var a=t.getAttribute("opacity");r.opacity=a?Math.round(255*parseFloat(a)):255,r.offset=new i(parseFloat(t.getAttribute("offsetx"))||0,parseFloat(t.getAttribute("offsety"))||0);var o=t.getAttribute("tintcolor");r.tintColor=o?xmt(o):null;for(var l="",h=0;h<e.childNodes.length;h++)l+=e.childNodes[h].nodeValue;l=l.trim();var u,c=e.getAttribute("compression"),_=e.getAttribute("encoding");if(c&&"gzip"!==c&&"zlib"!==c)return Qs(7218),null;switch(c){case"gzip":u=P9.unzipBase64AsArray(l,4);break;case"zlib":u=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 E6.Inflate(P9.Base64.decodeAsArray(l,1)).decompress());break;case null:case"":if("base64"===_)u=P9.Base64.decodeAsArray(l,4);else if("csv"===_){u=[];for(var f=l.split(","),p=0;p<f.length;p++)u.push(parseInt(f[p]))}else{var m=e.getElementsByTagName("tile");u=[];for(var g=0;g<m.length;g++)u.push(parseInt(m[g].getAttribute("gid")))}break;default:this.layerAttrs===Smt.ATTRIB_NONE&&Qs(7219)}return u&&(r.tiles=new Uint32Array(u)),r.properties=wmt(t),r},e._parseObjectGroup=function(t){var e=new bmt;e.name=t.getAttribute("name")||"",e.offset=new i(parseFloat(t.getAttribute("offsetx")),parseFloat(t.getAttribute("offsety")));var r=t.getAttribute("opacity");e.opacity=r?Math.round(255*parseFloat(r)):255;var n=t.getAttribute("tintcolor");e.tintColor=n?xmt(n):null;var s=t.getAttribute("visible");s&&0===parseInt(s)&&(e.visible=!1);var a=t.getAttribute("color");a&&e.color.fromHEX(a);var o=t.getAttribute("draworder");o&&(e.draworder=o),e.setProperties(wmt(t));var l=t.getElementsByTagName("object");if(l){for(var h=0;h<l.length;h++){var u=l[h],c={};c.id=u.getAttribute("id")||h,c.name=u.getAttribute("name")||"",c.width=parseFloat(u.getAttribute("width"))||0,c.height=parseFloat(u.getAttribute("height"))||0,c.x=parseFloat(u.getAttribute("x"))||0,c.y=parseFloat(u.getAttribute("y"))||0,c.rotation=parseFloat(u.getAttribute("rotation"))||0,wmt(u,c);var _=u.getAttribute("visible");c.visible=!(_&&0===parseInt(_));var f=u.getElementsByTagName("text");if(f&&f.length>0){var d=f[0];c.type=omt.TEXT,c.wrap="1"===d.getAttribute("wrap"),c.color=xmt(d.getAttribute("color")),c.halign=Tmt(d.getAttribute("halign")),c.valign=Cmt(d.getAttribute("valign")),c.pixelsize=parseInt(d.getAttribute("pixelsize"))||16,c.text=d.childNodes[0].nodeValue}var p=u.getAttribute("gid");p&&(c.gid=parseInt(p),c.type=omt.IMAGE);var m=u.getElementsByTagName("ellipse");m&&m.length>0&&(c.type=omt.ELLIPSE);var g=u.getElementsByTagName("polygon");if(g&&g.length>0){c.type=omt.POLYGON;var y=g[0].getAttribute("points");y&&(c.points=this._parsePointsString(y))}var v=u.getElementsByTagName("polyline");if(v&&v.length>0){c.type=omt.POLYLINE;var b=v[0].getAttribute("points");b&&(c.polylinePoints=this._parsePointsString(b))}c.type||(c.type=omt.RECT),e.objects.push(c)}"index"!==o&&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)},Ur(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}(),Xmt=t("TiledTile",(Emt=En("cc.TiledTile"),Bmt=Qn(),Rmt=ts(),Dmt=us(Uc),Mmt=Wn(go),Pmt=Wn(go),Imt=Wn(go),Omt=Wn(go),Fmt=Wn(go),Emt(Lmt=Bmt(Lmt=Rmt(Lmt=Dmt(Lmt=Jn((Gmt=function(t){function e(){var e;return(e=t.call(this)||this)._layer=null,Mn(e,"_x",Vmt,Pn(e)),Mn(e,"_y",Nmt,Pn(e)),e}on(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))bn("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)}}},Ur(e,[{key:"x",get:function(){return this._x},set:function(t){t!==this._x&&(this._layer&&this._layer.isInvalidPosition(t,this._y)?bn("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)?bn("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}(ns),Vmt=Dn((kmt=Gmt).prototype,"_x",[Mmt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Nmt=Dn(kmt.prototype,"_y",[Pmt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dn(kmt.prototype,"x",[Imt],Object.getOwnPropertyDescriptor(kmt.prototype,"x"),kmt.prototype),Dn(kmt.prototype,"y",[Omt],Object.getOwnPropertyDescriptor(kmt.prototype,"y"),kmt.prototype),Dn(kmt.prototype,"grid",[Fmt],Object.getOwnPropertyDescriptor(kmt.prototype,"grid"),kmt.prototype),Lmt=kmt))||Lmt)||Lmt)||Lmt)||Lmt)||Lmt));function Wmt(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,d=t.margin,p=1;if(!s){var g=Math.floor((o-2*d+f)/(h+f)),y=Math.floor((l-2*d+f)/(u+f));p=Math.max(1,y*g)}for(var v=t.firstGid,b=null,S=!!e.get(v),A=t.firstGid+p,T=v;T<A&&(S&&!e.get(T)&&(S=!1),S||!e.get(T));++T){if(b={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:T,spriteFrame:r,texture:n},t.rectForGID(T,b),!i||p>1)if(i){b._name=i.name;var C=i.unbiasUV[0],x=i.rotated?i.unbiasUV[1]:i.unbiasUV[5];b.l=C+(b.x+.5)/c,b.t=x+(b.y+.5)/_,b.r=C+(b.x+b.width-.5)/c,b.b=x+(b.y+b.height-.5)/_,b._rect=new m(b.x,b.y,b.width,b.height)}else b.l=b.x/c,b.t=b.y/_,b.r=(b.x+b.width)/c,b.b=(b.y+b.height)/_,b._rect=new m(b.x,b.y,b.width,b.height);else i.rotated?(b._rotated=!0,b._name=i.name,b._rect=i.getRect(),b.l=i.unbiasUV[0],b.t=i.unbiasUV[1],b.r=i.unbiasUV[4],b.b=i.unbiasUV[3]):(b._name=i.name,b._rect=i.getRect(),b.l=i.unbiasUV[0],b.t=i.unbiasUV[5],b.r=i.unbiasUV[2],b.b=i.unbiasUV[1]);b.cx=(b.l+b.r)/2,b.cy=(b.t+b.b)/2,e.set(T,b)}}for(var jmt,Ymt,qmt,Kmt,Jmt,Zmt,Qmt,$mt,tgt,egt,igt,rgt,ngt,sgt,agt,ogt,lgt,hgt,ugt,cgt,_gt,fgt,dgt,pgt,mgt,ggt,ygt,vgt,bgt,Sgt,Agt,Tgt,Cgt,xgt,wgt,Egt,Bgt,Rgt,Dgt,Mgt=new c,Pgt=new i,Igt=new n,Ogt=new n,Fgt={row:0,col:0},Lgt=t("TiledUserNodeData",En("cc.TiledUserNodeData")(zmt=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 on(e,t),e}(ns))||zmt),kgt=t("TiledLayer",En("cc.TiledLayer")(Umt=function(t){on(r,t);var e=r.prototype;function r(){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._tiledDataArray=[],e._drawInfoList=[],e._tiledDataArrayIdx=0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new Gu,this._drawInfoList[t].setDrawInfoType(Pu.IA)),this._drawInfoList[t]},e.hasTiledNode=function(){return this._hasTiledNodeGrid},e.hasAnimation=function(){return this._hasAniGrid},e.addUserNode=function(t){var e=t.getComponent(Lgt);return e?(bn("CCTiledLayer:addUserNode node has been added"),!1):(e=t.addComponent(Lgt),t.parent=this.node,this._userNodeMap[t.uuid]=e,e._row=-1,e._col=-1,e._tiledLayer=this,this._nodeLocalPosToLayerPos(t.getPosition(),Pgt),this._positionToRowCol(Pgt.x,Pgt.y,Fgt),this._addUserNodeToGrid(e,Fgt),this._updateCullingOffsetByUserNode(t),t.on(Zn.TRANSFORM_CHANGED,this._userNodePosChange,e),t.on(Zn.SIZE_CHANGED,this._userNodeSizeChange,e),!0)},e.removeUserNode=function(t){var e=t.getComponent(Lgt);return e?(t.off(Zn.TRANSFORM_CHANGED,this._userNodePosChange,e),t.off(Zn.SIZE_CHANGED,this._userNodeSizeChange,e),this._removeUserNodeFromGrid(e),delete this._userNodeMap[t.uuid],t._removeComponent(e),e.destroy(),t.removeFromParent(),!0):(bn("CCTiledLayer:removeUserNode node is not exist"),!1)},e.destroyUserNode=function(t){this.removeUserNode(t),t.destroy()},e._nodeLocalPosToLayerPos=function(t,e){e.x=t.x+this._leftDownToCenterX,e.y=t.y+this._leftDownToCenterY},e.getNodesByRowCol=function(t,e){var i=this._userNodeGrid[t];return i?i[e]:null},e.getNodesCountByRow=function(t){var e=this._userNodeGrid[t];return e?e.count:0},e._updateAllUserNode=function(){for(var t in this._userNodeGrid={},this._userNodeMap){var e=this._userNodeMap[t];this._nodeLocalPosToLayerPos(e.node.getPosition(),Pgt),this._positionToRowCol(Pgt.x,Pgt.y,Fgt),this._addUserNodeToGrid(e,Fgt),this._updateCullingOffsetByUserNode(e.node)}},e._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)},e._userNodeSizeChange=function(){var t=this.node,e=this._tiledLayer;e._updateCullingOffsetByUserNode(t),e._userNodeDirty=!0,e.markForUpdateRenderData()},e._userNodePosChange=function(){var t=this,e=t.node,i=t._tiledLayer;i._nodeLocalPosToLayerPos(e.getPosition(),Pgt),i._positionToRowCol(Pgt.x,Pgt.y,Fgt),i._limitInLayer(Fgt),Fgt.row===t._row&&Fgt.col===t._col||(i._removeUserNodeFromGrid(t),i._addUserNodeToGrid(t,Fgt))},e._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()},e._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)},e._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},e.isUserNodeDirty=function(){return this._userNodeDirty},e.setUserNodeDirty=function(t){this._userNodeDirty=t},e.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(Zn.ANCHOR_CHANGED,this._syncAnchorPoint,this),this.node.on(Zn.TRANSFORM_CHANGED,this.updateCulling,this),this.node.on(Zn.SIZE_CHANGED,this.updateCulling,this),this.node.parent.on(Zn.TRANSFORM_CHANGED,this.updateCulling,this),this.node.parent.on(Zn.SIZE_CHANGED,this.updateCulling,this),this.markForUpdateRenderData(),this.scheduleOnce(this.updateCulling.bind(this))},e.onDisable=function(){var e,i;t.prototype.onDisable.call(this),null===(e=this.node.parent)||void 0===e||e.off(Zn.SIZE_CHANGED,this.updateCulling,this),null===(i=this.node.parent)||void 0===i||i.off(Zn.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(Zn.SIZE_CHANGED,this.updateCulling,this),this.node.off(Zn.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(Zn.ANCHOR_CHANGED,this._syncAnchorPoint,this)},e._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()},e.getLayerName=function(){return this._layerName},e.setLayerName=function(t){this._layerName=t},e.getProperty=function(t){return this._properties[t]},e.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 emt.ORTHO:return this._positionForOrthoAt(i,e);case emt.ISO:return this._positionForIsoAt(i,e);case emt.HEX:return this._positionForHexAt(i,e)}return null},e.isInvalidPosition=function(t,e){return t>=this._layerSize.width||e>=this._layerSize.height||t<0||e<0},e._positionForIsoAt=function(t,e){var r=0,n=0,s=Math.floor(t)+Math.floor(e)*this._layerSize.width,a=this.tiles[s];if(a){var o=(a&rmt.FLIPPED_MASK)>>>0,l=this.texGrids.get(o).tileset.tileOffset;r=l.x,n=l.y}return new i(.5*this._mapTileSize.width*(this._layerSize.height+t-e-1)+r,.5*this._mapTileSize.height*(this._layerSize.width-t+this._layerSize.height-e-2)-n)},e._positionForOrthoAt=function(t,e){var r=0,n=0,s=Math.floor(t)+Math.floor(e)*this._layerSize.width,a=this.tiles[s];if(a){var o=(a&rmt.FLIPPED_MASK)>>>0,l=this.texGrids.get(o).tileset.tileOffset;r=l.x,n=l.y}return new i(t*this._mapTileSize.width+r,(this._layerSize.height-e-1)*this._mapTileSize.height-n)},e._positionForHexAt=function(t,e){var r,n=this._mapTileSize.width,s=this._mapTileSize.height,a=this._layerSize.height,o=Math.floor(t)+Math.floor(e)*this._layerSize.width,l=(this.tiles[o]&rmt.FLIPPED_MASK)>>>0;r=this.texGrids.get(l)?this.texGrids.get(l).tileset.tileOffset:{x:0,y:0};var h=this._staggerIndex===smt.STAGGERINDEX_ODD?1:-1,u=0,c=0,_=0,f=0;switch(this._staggerAxis){case nmt.STAGGERAXIS_Y:_=0,e%2==1&&(_=n/2*h),u=t*n+_+r.x,c=(a-e-1)*(s-(s-this._hexSideLength)/2)-r.y;break;case nmt.STAGGERAXIS_X:f=0,t%2==1&&(f=s/2*-h),u=t*(n-(n-this._hexSideLength)/2)+r.x,c=(a-e-1)*s+f-r.y}return new i(u,c)},e.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++}}},e.setTileGIDAt=function(t,e,i,r){var n=(t&rmt.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?Qs(7239,t):(r=r||0,this._updateTileForGID((n|r)>>>0,e,i)):Qs(7238)},e._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&rmt.FLIPPED_MASK)>>>0;this.texGrids.get(n)?(this.tiles[r]=t,this._updateVertex(e,i)):this.tiles[r]=0,this._cullingDirty=!0}},e.getTileGIDAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position");if(!this.tiles)return Qs(7237),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&rmt.FLIPPED_MASK)>>>0},e.getTileFlagsAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this.tiles)return Qs(7240),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&rmt.FLIPPED_ALL)>>>0},e.setCullingDirty=function(t){this._cullingDirty=t},e.isCullingDirty=function(){return this._cullingDirty},e.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===emt.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,Fgt),Fgt.row-=n,Fgt.col-=n,Fgt.row=Fgt.row>0?Fgt.row:0,Fgt.col=Fgt.col>0?Fgt.col:0,Fgt.row===c.row&&Fgt.col===c.col||(c.row=Fgt.row,c.col=Fgt.col,this._cullingDirty=!0),h<0||u<0?(Fgt.row=-1,Fgt.col=-1):(this._positionToRowCol(h,u,Fgt),Fgt.row++,Fgt.col++),Fgt.row>this._rightTop.row&&(Fgt.row=this._rightTop.row),Fgt.col>this._rightTop.col&&(Fgt.col=this._rightTop.col),Fgt.row===_.row&&Fgt.col===_.col||(_.row=Fgt.row,_.col=Fgt.col,this._cullingDirty=!0,this.markForUpdateRenderData())}},e._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 emt.ORTHO:l=Math.floor(t/r),o=Math.floor(e/n);break;case emt.ISO:l=Math.floor(t/s),o=Math.floor(e/a);break;case emt.HEX:c===nmt.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},e.updateCulling=function(){if(this._enableCulling){this.node.updateWorldTransform(),c.invert(Mgt,this.node.getWorldMatrix());var t=Kr.root.batcher2D.getFirstRenderCamera(this.node);t&&(Igt.x=0,Igt.y=0,Igt.z=0,Ogt.x=t.width,Ogt.y=t.height,Ogt.z=0,t.screenToWorld(Igt,Igt),t.screenToWorld(Ogt,Ogt),n.transformMat4(Igt,Igt,Mgt),n.transformMat4(Ogt,Ogt,Mgt),this.updateViewPort(Igt.x,Igt.y,Ogt.x-Igt.x,Ogt.y-Igt.y))}},e.getLayerOrientation=function(){return this._layerOrientation},e.getProperties=function(){return this._properties},e._updateVertex=function(t,e){var i=rmt.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,d=.5*_,p=this._layerSize.height,m=this._layerSize.width,g=this.texGrids,y=0,v=0;n===emt.HEX&&(a=this._staggerAxis,o=this._diffX1,l=this._diffY1,h=this._odd_even);var b,S,A,T=0,C=0,x=0,w=0,E=e*m+t;b=(s[E]&i)>>>0;var B=g.get(b);if(B){switch(this._animations.get(b)&&(this._hasAniGrid=this._hasAniGrid||!0),n){case emt.ORTHO:y=(T=t)*c,v=(C=p-e-1)*_;break;case emt.ISO:y=f*(T=p+t-e-1),v=d*(C=p+m-t-e-2);break;case emt.HEX:y=t*(c-o)+(a===nmt.STAGGERAXIS_Y&&e%2==1?f*h:0),v=(p-e-1)*(_-l)+(a===nmt.STAGGERAXIS_X&&t%2==1?d*-h:0),T=t,C=p-e-1}var R=r[C]=r[C]||{minCol:0,maxCol:0},D=R[T]=R[T]||{};R.minCol>T&&(R.minCol=T),R.maxCol<T&&(R.maxCol=T),u.row<C&&(u.row=C,n===emt.ISO&&(u.row+=1)),u.col<T&&(u.col=T,n===emt.ISO&&(u.col+=1));var M=B.tileset.tileOffset;y+=this._offset.x+M.x+B.offsetX,v+=this._offset.y-M.y-B.offsetY,x=(x=-M.y+B.tileset._tileSize.height-_)<0?0:x,S=M.y<0?0:M.y,A=-M.x<0?0:-M.x,w=(w=M.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<x&&(this._downOffset=x),D.left=y,D.bottom=v,D.index=E,this._cullingDirty=!0}}},e._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}},e.getTiledTileAt=function(t,e,i){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTiledTileAt: invalid position");if(!this.tiles)return Qs(7236),null;var r=Math.floor(t)+Math.floor(e)*this._layerSize.width,n=this.tiledTiles[r];if(!n&&i){var s=new ks;return(n=s.addComponent(Xmt))._x=t,n._y=e,n._layer=this,n.updateInfo(),s.parent=this.node,n}return n},e.setTiledTileAt=function(t,e,i){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.setTiledTileAt: invalid position");if(!this.tiles)return Qs(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},e.getTexture=function(t){return t=t||0,this._textures&&t>=0&&this._textures.length>t?this._textures[t]:null},e.getTextures=function(){return this._textures},e.setTexture=function(t){this.setTextures([t])},e.setTextures=function(t){this._textures=t,this.markForUpdateRenderData()},e.getLayerSize=function(){return this._layerSize},e.getMapTileSize=function(){return this._mapTileSize},e.getTileSet=function(t){return t=t||0,this._tilesets&&t>=0&&this._tilesets.length>t?this._tilesets[t]:null},e.getTileSets=function(){return this._tilesets},e.setTileSet=function(t){this.setTileSets([t])},e.setTileSets=function(t){this._tilesets=t;var e=this._textures=[],i=this.texGrids;i.clear();for(var r=0;r<t.length;r++){var n=t[r];n&&(e[r]=n.sourceImage)}for(var s=0,a=t.length;s<a;++s){var o=t[s];o&&Wmt(o,i,o.sourceImage)}this._prepareToRender()},e.init=function(t,e,r,n,s){this._cullingDirty=!0,this._layerInfo=t,this._mapInfo=e;var a=t.layerSize;this._layerName=t.name,this.tiles=t.tiles,this._properties=t.properties,this._layerSize=a,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=r,this._textures=n,this.texGrids=s,this._layerOrientation=e.orientation,this._mapTileSize=e.getTileSize();var o=this._mapTileSize.width,l=this._mapTileSize.height,h=this._layerSize.width,u=this._layerSize.height;if(this._layerOrientation===emt.HEX){var c=0,_=0;this._odd_even=this._staggerIndex===smt.STAGGERINDEX_ODD?1:-1,this._staggerAxis===nmt.STAGGERAXIS_X?(this._diffX1=(o-this._hexSideLength)/2,this._diffY1=0,_=l*(u+.5),c=(o+this._hexSideLength)*Math.floor(h/2)+o*(h%2)):(this._diffX1=0,this._diffY1=(l-this._hexSideLength)/2,c=o*(h+.5),_=(l+this._hexSideLength)*Math.floor(u/2)+l*(u%2)),this.node._uiProps.uiTransformComp.setContentSize(c,_)}else if(this._layerOrientation===emt.ISO){var f=h+u;this.node._uiProps.uiTransformComp.setContentSize(.5*o*f,.5*l*f)}else this.node._uiProps.uiTransformComp.setContentSize(h*o,u*l);this._offset=new i(t.offset.x,-t.offset.y),this._useAutomaticVertexZ=!1,this._vertexZvalue=0,this._syncAnchorPoint(),this._prepareToRender()},e._prepareToRender=function(){this._updateVertices(),this._updateAllUserNode()},e.requestTiledRenderData=function(){for(var t=this._tiledDataArray;t.length>0&&t[t.length-1].subNodes&&0===t[t.length-1].subNodes.length;)t.pop();if(t.length>0){var e=t[t.length-1];if(e.renderData&&0===e.renderData.vertexCount)return e}var i={renderData:null,texture:null};return this._tiledDataArray.push(i),i},e.requestSubNodesData=function(){var t=this._tiledDataArray;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._tiledDataArray.push(e),e},e.destroyRenderData=function(){this._tiledDataArray.forEach((function(t){var e=t.renderData;e&&Pc.remove(e)})),this._tiledDataArray.length=0,t.prototype.destroyRenderData.call(this)},e._flushAssembler=function(){var t=r.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t,this._assembler.createData(this)),0===this._tiledDataArray.length&&(this.markForUpdateRenderData(),this._updateColor())},e._render=function(t){for(var e=0;e<this._tiledDataArray.length;e++){this._tiledDataArrayIdx=e;var i=this._tiledDataArray[e];if(i.subNodes)i.subNodes.forEach((function(e){e&&t.walk(e.node)}));else{var r=i;r.texture&&t.commitComp(this,r.renderData,r.texture,this._assembler,null)}}this.node._static=!0},e.createRenderEntity=function(){return new Bc(zu.CROSSED)},e.fillIndicesBuffer=function(t,e){var i=t.chunk.meshBuffer.iData,r=t.chunk.meshBuffer.indexOffset;e.setIndexOffset(r);for(var n=t.chunk.vertexOffset,s=t.vertexCount/4,a=0;a<s;a+=1)i[r]=n,i[r+1]=n+1,i[r+2]=n+2,i[r+3]=n+2,i[r+4]=n+1,i[r+5]=n+3,r+=6,n+=4;t.chunk.meshBuffer.indexOffset=r,e.setIBCount(6*s)},e.prepareDrawData=function(){var t=this;this._drawInfoList.length=0;var e=this.renderEntity;e.clearDynamicRenderDrawInfos();var i=this._tiledDataArray,r=0;i.forEach((function(i){if(i.subNodes)i.subNodes.forEach((function(i){if(i){t._drawInfoList[r]||(t._drawInfoList[r]=new Gu);var n=t._drawInfoList[r];n.setDrawInfoType(Pu.SUB_NODE),n.setSubNode(i.node),e.setDynamicRenderDrawInfo(n,r),r++}}));else{var n=i;if(n.texture){t._drawInfoList[r]||(t._drawInfoList[r]=new Gu);var s=t._drawInfoList[r];n.renderData.fillDrawInfoAttributes(s),s.setTexture(n.texture.getGFXTexture()),s.setSampler(n.texture.getGFXSampler()),s.setMaterial(t.getRenderMaterial(0)),t.fillIndicesBuffer(n.renderData,s),e.setDynamicRenderDrawInfo(s,r),r++}}}))},Ur(r,[{key:"cullingRect",get:function(){return this._cullingRect}},{key:"rightTop",get:function(){return this._rightTop}},{key:"layerSize",get:function(){return this._layerSize}},{key:"tiledDataArray",get:function(){return this._tiledDataArray}},{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())}}]),r}(af))||Umt),Vgt=t("TiledObjectGroup",(jmt=En("cc.TiledObjectGroup"),Ymt=Qn(),qmt=us(Uc),Kmt=Wn(ha),jmt(Jmt=Ymt(Jmt=qmt((Qmt=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}on(e,t);var r=e.prototype;return r.getPositionOffset=function(){return this._positionOffset},r.getProperties=function(){return this._properties},r.getGroupName=function(){return this._groupName},r.getProperty=function(t){return this._properties[t.toString()]},r.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},r.getObjects=function(){return this._objects},r._init=function(t,e,r){var n=rmt.FLIPPED_MASK,s=rmt.HORIZONTAL,a=rmt.VERTICAL;this._groupName=t.name,this._positionOffset=t.offset,this._mapInfo=e,this._properties=t.getProperties(),this._offset=new i(t.offset.x,-t.offset.y),this._opacity=t.opacity,t.tintColor&&(this._tintColor=t.tintColor),this._texGrids=r,this._animations=e.getTileAnimations(),this.aniObjects=[],this._hasAniObj=!1;var o=e.mapSize,l=e.tileSize,h=0,u=0,c=new y,_=emt.ISO===e.orientation;if(e.orientation===emt.HEX)e.getStaggerAxis()===nmt.STAGGERAXIS_X?(u=l.height*(o.height+.5),h=(l.width+e.getHexSideLength())*Math.floor(o.width/2)+l.width*(o.width%2)):(h=l.width*(o.width+.5),u=(l.height+e.getHexSideLength())*Math.floor(o.height/2)+l.height*(o.height%2));else if(_){var f=o.width+o.height;h=.5*l.width*f,u=.5*l.height*f}else h=o.width*l.width,u=o.height*l.height;var d=this.node._uiProps.uiTransformComp;d.setContentSize(h,u);for(var p=h*d.anchorX,m=u*(1-d.anchorY),g=t.objects,v={},b=0,S=g.length;b<S;b++){var A=g[b],T=A.type;A.offset=new i(A.x,A.y);var C=A.points||A.polylinePoints;if(C)for(var x=0;x<C.length;x++)C[x].y*=-1;if(_){var w=A.x/l.height,E=A.y/l.height;A.x=.5*l.width*(o.height+w-E),A.y=.5*l.height*(o.width+o.height-w-E)}else A.y=u-A.y;if(T===omt.TEXT){var B="text"+A.id;v[B]=!0;var R=this.node.getChildByName(B);R||(R=new ks),R.setRotationFromEuler(0,0,-A.rotation),R.setPosition(A.x-p,A.y-m),R.name=B,R.parent=this.node,R.setSiblingIndex(b);var D=R.getComponent(of);D||(D=R.addComponent(of));var M=R._uiProps.uiTransformComp;R.active=A.visible,M.anchorX=0,M.anchorY=1,this._tintColor?(c.set(this._tintColor),c.a*=this._opacity/255,D.color.set(c)):D.color.a*=this._opacity/255,D.overflow=of.Overflow.SHRINK,D.lineHeight=A.height,D.string=A.text,D.horizontalAlign=A.halign,D.verticalAlign=A.valign,D.fontSize=A.pixelsize,M.setContentSize(A.width,A.height)}else if(T===omt.IMAGE){var P=A.gid,I=(P&n)>>>0,O=r.get(I);if(!O)continue;var F=O.tileset,L="img"+A.id;v[L]=!0;var k=this.node.getChildByName(L);A.width=A.width||O.width,A.height=A.height||O.height,k&&k._objFlags&Vs.Flags.HideInHierarchy&&(k.removeFromParent(),k.hideFlags|=Vs.Flags.DontSave,k.destroy(),k=null),k||(k=new ks),this._animations.get(I)&&(this.aniObjects.push({object:A,imgNode:k,gridGID:I}),this._hasAniObj=!0);var V=F.tileOffset.x,N=F.tileOffset.y;k.active=A.visible,k.setRotationFromEuler(0,0,-A.rotation),k.setPosition(A.x-p,A.y-m),k.name=L,k.parent=this.node,k.setSiblingIndex(b);var G=k.getComponent(im);G||(G=k.addComponent(im));var z=k._uiProps.uiTransformComp;_?(z.anchorX=.5+V/A.width,z.anchorY=N/A.height):(z.anchorX=V/A.width,z.anchorY=N/A.height),this._tintColor?(c.set(this._tintColor),c.a*=this._opacity/255,G.color.set(c)):G.color.a*=this._opacity/255,G.sizeMode=im.SizeMode.CUSTOM;var U=this._premultiplyAlpha?gt.ONE:gt.SRC_ALPHA;G._srcBlendFactor!==U&&(G._srcBlendFactor=U,G.material&&G._updateBlendFunc());var H=O.spriteFrame;H=H?H.clone():new Bh,(P&s)>>>0&&(H.flipUVX=!H.flipUVX),(P&a)>>>0&&(H.flipUVY=!H.flipUVY),H.rotated=O._rotated,H.rect=O._rect,G.spriteFrame=H,z.setContentSize(A.width,A.height),G.markForUpdateRenderData()}}this._objects=g;for(var X=this.node.children,W=/^(?:img|text)\d+$/,j=0,Y=X.length;j<Y;j++){var q=X[j],K=q.name;W.test(K)&&!v[K]&&q.destroy()}},r.update=function(){if(this._hasAniObj)for(var t=this.aniObjects,e=this._texGrids,i=emt.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 d=u.getComponent(im),p=d.spriteFrame;p.rotated=o._rotated,p.rect=o._rect,d.spriteFrame=p,d.markForUpdateRenderData()}}},Ur(e,[{key:"premultiplyAlpha",get:function(){return this._premultiplyAlpha},set:function(t){this._premultiplyAlpha=t}},{key:"offset",get:function(){return this._offset}}]),e}(ns),Dn((Zmt=Qmt).prototype,"premultiplyAlpha",[Kmt],Object.getOwnPropertyDescriptor(Zmt.prototype,"premultiplyAlpha"),Zmt.prototype),Jmt=Zmt))||Jmt)||Jmt)||Jmt)),Ngt=t("TiledMapAsset",($mt=En("cc.TiledMapAsset"),tgt=Wn([Po]),egt=Wn([la]),igt=Wn([Bh]),rgt=Wn([Bh]),ngt=Wn([la]),sgt=Wn([la]),agt=Wn([d]),$mt((ggt=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,Mn(e,"tmxXmlStr",hgt,Pn(e)),Mn(e,"tsxFiles",ugt,Pn(e)),Mn(e,"tsxFileNames",cgt,Pn(e)),Mn(e,"spriteFrames",_gt,Pn(e)),Mn(e,"imageLayerSpriteFrame",fgt,Pn(e)),Mn(e,"imageLayerSpriteFrameNames",dgt,Pn(e)),Mn(e,"spriteFrameNames",pgt,Pn(e)),Mn(e,"spriteFrameSizes",mgt,Pn(e)),e}return on(e,t),e}(Qr),hgt=Dn((lgt=ggt).prototype,"tmxXmlStr",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),ugt=Dn(lgt.prototype,"tsxFiles",[On,tgt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),cgt=Dn(lgt.prototype,"tsxFileNames",[On,egt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),_gt=Dn(lgt.prototype,"spriteFrames",[On,igt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),fgt=Dn(lgt.prototype,"imageLayerSpriteFrame",[On,rgt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),dgt=Dn(lgt.prototype,"imageLayerSpriteFrameNames",[On,ngt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),pgt=Dn(lgt.prototype,"spriteFrameNames",[On,sgt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),mgt=Dn(lgt.prototype,"spriteFrameSizes",[On,agt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ogt=lgt))||ogt)),Ggt=(t("TiledMap",(ygt=En("cc.TiledMap"),vgt=Qn(),bgt=ts(),Sgt=us(Uc),Agt=Wn(Ngt),Tgt=es(),ygt(Cgt=vgt(Cgt=bgt(Cgt=Sgt(Cgt=Jn((Dgt=Rgt=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 d(0,0),e._tileSize=new d(0,0),e._mapOrientation=emt.ORTHO,e._isApplied=!1,Mn(e,"_tmxFile",wgt,Pn(e)),Mn(e,"_enableCulling",Egt,Pn(e)),Mn(e,"cleanupImageCache",Bgt,Pn(e)),e}on(e,t);var r=e.prototype;return r.getMapSize=function(){return this._mapSize},r.getTileSize=function(){return this._tileSize},r.getMapOrientation=function(){return this._mapOrientation},r.getObjectGroups=function(){return this._groups},r.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},r.getProperties=function(){return this._properties},r.getLayers=function(){return this._layers},r.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},r._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)}},r.getProperty=function(t){return this._properties[t.toString()]},r.getPropertiesForGID=function(t){return this._tileProperties.get(t)},r.__preload=function(){this._tmxFile&&!1===this._isApplied&&(this._applyFile(),this._isApplied=!0)},r.onEnable=function(){this.node.on(Zn.ANCHOR_CHANGED,this._syncAnchorPoint,this)},r.onDisable=function(){this.node.off(Zn.ANCHOR_CHANGED,this._syncAnchorPoint,this)},r._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 d=i.tsxFileNames,p=i.tsxFiles,m={},g=0;g<d.length;++g)d[g].length>0&&(m[d[g]]=p[g].text);var y=new Hmt(i.tmxXmlStr,m,a,o,c),v=y.getTilesets();v&&0!==v.length||Qs(7241),this._buildWithMapInfo(y)}else this._releaseMapInfo()},r._releaseMapInfo=function(){for(var t=this._layers,e=0,i=t.length;e<i;e++){var r,n;null===(r=t[e].node.parent)||void 0===r||r.off(Zn.SIZE_CHANGED,t[e].updateCulling,t[e]),null===(n=t[e].node.parent)||void 0===n||n.off(Zn.TRANSFORM_CHANGED,t[e].updateCulling,t[e]),t[e].node.removeFromParent(),t[e].node.destroy()}t.length=0;for(var s=this._groups,a=0,o=s.length;a<o;a++)s[a].node.removeFromParent(),s[a].node.destroy();s.length=0;for(var l=this._images,h=0,u=l.length;h<u;h++)l[h].removeFromParent(),l[h].destroy();l.length=0},r._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)}},r._fillAniGrids=function(t,e){for(var i,r=hn(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)}}},r._buildLayerAndGroup=function(){var t=this._tilesets,e=this._texGrids,r=this._animations;e.clear();for(var n=0,s=t.length;n<s;++n){var a=t[n];a&&(a.sourceImage?Wmt(a,e,a.sourceImage):console.warn("Can't find the spriteFrame of tilesets "+n))}this._fillAniGrids(e,r);for(var o=this._layers,l=this._groups,h=this._images,u={},c=0,_=o.length;c<_;c++)u[o[c].node.name]=!0;for(var f=0,d=l.length;f<d;f++)u[l[f].node.name]=!0;for(var p=0,m=h.length;p<m;p++)u[h[p].name]=!0;o=this._layers=[],l=this._groups=[],h=this._images=[];var g=this._mapInfo,y=this.node,v=g.getAllChildren(),b=this._textures,S=0,A=0;if(v&&v.length>0)for(var T=0,C=v.length;T<C;T++){var x=v[T],w=x.name,E=this.node.getChildByName(w);if(u[w]=!1,E||((E=new ks).name=w,E.layer=y.layer,y.addChild(E)),E.setSiblingIndex(T),E.active=x.visible,x instanceof Smt){var B=E.getComponent(kgt);B||(B=E.addComponent(kgt)),B.init(x,g,t,b,e),B.enableCulling=this._enableCulling,x.ownTiles=!1,o.push(B)}else if(x instanceof bmt){var R=E.getComponent(Vgt);R||(R=E.addComponent(Vgt)),R._init(x,g,e),l.push(R)}else if(x instanceof Amt){var D=x.sourceImage;E.layerInfo=x,E._offset=new i(x.offset.x,-x.offset.y);var M=E.getComponent(im);M||(M=E.addComponent(im)),M.color.a*=x.opacity,M.spriteFrame=D;var P=D.width,I=D.height;D.original&&(P=D.originalSize.width,I=D.originalSize.height),E._uiProps.uiTransformComp.setContentSize(P,I),h.push(E)}S=Math.max(S,E._uiProps.uiTransformComp.width),A=Math.max(A,E._uiProps.uiTransformComp.height)}for(var O=y.children,F=0,L=O.length;F<L;F++){var k=O[F];u[k.name]&&k.destroy()}this.node._uiProps.uiTransformComp.setContentSize(S,A),this._syncAnchorPoint()},r._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)}this._buildLayerAndGroup(),this.cleanupImageCache&&this._textures.forEach((function(t){e.doCleanupImageCache(t)}))},r.doCleanupImageCache=function(t){t._image instanceof HTMLImageElement?t._image.src="":Fn.hasFeature(Fn.Feature.IMAGE_BITMAP)&&t._image instanceof ImageBitmap&&t._image.close&&t._image.close(),t._image=null},r.lateUpdate=function(t){for(var e,i=this._animations,r=this._texGrids,n=hn(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=this.getLayers(),u=0,c=h.length;u<c;u++){var _=h[u];(_.hasAnimation()||_.node.hasChangedFlags)&&_.markForUpdateRenderData()}},Ur(e,[{key:"tmxAsset",get:function(){return this._tmxFile},set:function(t){(this._tmxFile!==t||uo)&&(this._tmxFile=t,this._applyFile(),this._isApplied=!0)}},{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}(ns),Rgt.Orientation=emt,Rgt.Property=imt,Rgt.TileFlag=rmt,Rgt.StaggerAxis=nmt,Rgt.StaggerIndex=smt,Rgt.TMXObjectType=omt,Rgt.RenderOrder=amt,wgt=Dn((xgt=Dgt).prototype,"_tmxFile",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dn(xgt.prototype,"tmxAsset",[Agt,Tgt],Object.getOwnPropertyDescriptor(xgt.prototype,"tmxAsset"),xgt.prototype),Egt=Dn(xgt.prototype,"_enableCulling",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(xgt.prototype,"enableCulling",[Un],Object.getOwnPropertyDescriptor(xgt.prototype,"enableCulling"),xgt.prototype),Bgt=Dn(xgt.prototype,"cleanupImageCache",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Cgt=xgt))||Cgt)||Cgt)||Cgt)||Cgt)||Cgt)),Math.ceil(10922.5)),zgt=[],Ugt=0;Ugt<4;Ugt++)zgt.push(new n);var Hgt,Xgt,Wgt,jgt=new c,Ygt=new n,qgt={row:0,col:0},Kgt={x:0,y:0},Jgt={x:0,y:0},Zgt={x:0,y:0},Qgt={x:0,y:0},$gt=0,tyt=0,eyt=0,iyt=0,ryt=null,nyt=null,syt={ensureAccessor:function(){if(!nyt){var t=Kr.root.device;Kr.root.batcher2D,nyt=new ku(t,xu,this.vCount),Kr.on(Or.EVENT_BEFORE_DRAW,(function(){nyt.reset()}))}},createData:function(){},fillBuffers:function(t){if(t&&0!==t.tiledDataArray.length){for(var e=t.tiledDataArray[t._tiledDataArrayIdx].renderData,i=e.chunk.meshBuffer.iData,r=e.chunk.meshBuffer.indexOffset,n=e.chunk.vertexOffset,s=e.vertexCount/4,a=0;a<s;a+=1)i[r]=n,i[r+1]=n+1,i[r+2]=n+2,i[r+3]=n+2,i[r+4]=n+1,i[r+5]=n+3,r+=6,n+=4;e.chunk.meshBuffer.indexOffset=r}},updateRenderData:function(t){if(t.updateCulling(),tyt=t.leftDownToCenterX,eyt=t.leftDownToCenterY,t.colorChanged||t.isCullingDirty()||t.isUserNodeDirty()||t.hasAnimation()||t.hasTiledNode()||t.node.hasChangedFlags){var e,i;if(t.colorChanged=!1,t.destroyRenderData(),t.enableCulling){var r=t.cullingRect;e=r.leftDown,i=r.rightTop}else e=qgt,i=t.rightTop;switch(t.renderOrder){case amt.RightDown:lyt(e,i,-1,1,t);break;case amt.LeftDown:lyt(e,i,-1,-1,t);break;case amt.RightUp:lyt(e,i,1,1,t);break;case amt.LeftUp:default:lyt(e,i,1,-1,t)}t.setCullingDirty(!1),t.setUserNodeDirty(!1)}},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[3]=e.a/255;for(var r,n=t.tiledDataArray,s=hn(n);!(r=s()).done;){var a=r.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)}}};function ayt(t,e){var i;t._rotated?(Kgt.x=t.r,Kgt.y=t.t,Jgt.x=t.l,Jgt.y=t.t,Zgt.x=t.r,Zgt.y=t.b,Qgt.x=t.l,Qgt.y=t.b):(Kgt.x=t.l,Kgt.y=t.t,Jgt.x=t.l,Jgt.y=t.b,Zgt.x=t.r,Zgt.y=t.t,Qgt.x=t.r,Qgt.y=t.b),(e&rmt.DIAGONAL)>>>0&&(i=Jgt,Jgt=Zgt,Zgt=i),(e&rmt.HORIZONTAL)>>>0&&(i=Kgt,Kgt=Zgt,Zgt=i,i=Jgt,Jgt=Qgt,Qgt=i),(e&rmt.VERTICAL)>>>0&&(i=Kgt,Kgt=Jgt,Jgt=i,i=Zgt,Zgt=Qgt,Qgt=i)}function oyt(){if(!(iyt<1)&&ryt){var t=4*iyt,e=6*iyt,i=Xgt.requestTiledRenderData();i.renderData=Pc.add(xu),i.texture=ryt;var r=i.renderData;r.resize(t,e),r.chunk.vb.set(Hgt.subarray(0,9*t),0),iyt=0,ryt=null}}function lyt(t,e,i,r,n){if(!(e.row<0||e.col<0)){Xgt=n;var s=n.node.worldMatrix;$gt=0;var a,o,l,h,u,c,_,f,d,p=n.tiledTiles,m=n.texGrids,g=n.tiles,y=18,v=27,b=n.vertices,S=0,A=0,T=0,C=0,x=0,w=0,E=!0;Wgt=ayt;var B=new Float32Array(4);B[0]=n.color.r/255,B[1]=n.color.g/255,B[2]=n.color.b/255,B[3]=n.color.a/255,-1===i?(h=e.row,u=t.row):(h=t.row,u=e.row);var R=Math.abs(t.row-e.row)+1,D=Math.abs(e.col-t.col)+1;Hgt=new Float32Array(R*D*36),iyt=0;for(var M=Hgt;(u-h)*i>=0;h+=i)for(a=b[h],w=n.getNodesCountByRow(h),E=a&&0===w,1===r?(o=E&&t.col<a.minCol?a.minCol:t.col,l=E&&e.col>a.maxCol?a.maxCol:e.col):(o=E&&e.col>a.maxCol?a.maxCol:e.col,l=E&&t.col<a.minCol?a.minCol:t.col);(l-o)*r>=0;o+=r){if(c=a&&a[o],w>0){oyt();var P=n.requestSubNodesData(),I=n.getNodesByRowCol(h,o);I&&I.count>0&&(P.subNodes=I.list)}c&&(S=g[c.index],(f=m.get((S&rmt.FLIPPED_MASK)>>>0))&&(ryt!==f.texture&&(oyt(),ryt=f.texture),_=f.tileset._tileSize,A=c.left-tyt,T=c.bottom-eyt,C=A+_.width,x=T+_.height,d=p[c.index],$gt=36*iyt,d?d.node.active&&hyt(d.node,B,M,A,C,x,T,!1):(zgt[0].x=A,zgt[0].y=x,zgt[1].x=A,zgt[1].y=T,zgt[2].x=C,zgt[2].y=x,zgt[3].x=C,zgt[3].y=T,zgt[0].transformMat4(s),M[$gt]=zgt[0].x,M[$gt+1]=zgt[0].y,M[$gt+2]=zgt[0].z,zgt[1].transformMat4(s),M[$gt+9]=zgt[1].x,M[$gt+9+1]=zgt[1].y,M[$gt+9+2]=zgt[1].z,zgt[2].transformMat4(s),M[$gt+y]=zgt[2].x,M[$gt+y+1]=zgt[2].y,M[$gt+y+2]=zgt[2].z,zgt[3].transformMat4(s),M[$gt+v]=zgt[3].x,M[$gt+v+1]=zgt[3].y,M[$gt+v+2]=zgt[3].z,M.set(B,$gt+5),M.set(B,$gt+9+5),M.set(B,$gt+y+5),M.set(B,$gt+v+5)),Wgt(f,S),M[$gt+3]=Kgt.x,M[$gt+4]=Kgt.y,M[$gt+9+3]=Jgt.x,M[$gt+9+4]=Jgt.y,M[$gt+y+3]=Zgt.x,M[$gt+y+4]=Zgt.y,M[$gt+v+3]=Qgt.x,M[$gt+v+4]=Qgt.y,++iyt>=Ggt&&oyt()))}oyt()}}function hyt(t,e,i,r,s,a,o,l){var h=18,u=27;t.updateWorldTransform(),c.fromRTS(jgt,t.rotation,t.position,t.scale),n.set(Ygt,-(r+tyt),-(o+eyt),0),c.transform(jgt,jgt,Ygt),c.multiply(jgt,t.parent.worldMatrix,jgt);var _=jgt,f=_.m12,d=_.m13,p=_.m00,m=_.m01,g=_.m04,y=_.m05,v=1===p&&0===m&&0===g&&1===y;if(l){var b=(r+s)/2,S=(a+o)/2;v?(i[$gt]=b+f,i[$gt+1]=a+d,i[$gt+9]=r+f,i[$gt+9+1]=S+d,i[$gt+h]=s+f,i[$gt+h+1]=S+d,i[$gt+u]=b+f,i[$gt+u+1]=o+d):(i[$gt]=b*p+a*g+f,i[$gt+1]=b*m+a*y+d,i[$gt+9]=r*p+S*g+f,i[$gt+9+1]=r*m+S*y+d,i[$gt+h]=s*p+S*g+f,i[$gt+h+1]=s*m+S*y+d,i[$gt+u]=b*p+o*g+f,i[$gt+u+1]=b*m+o*y+d)}else v?(i[$gt]=r+f,i[$gt+1]=a+d,i[$gt+9]=r+f,i[$gt+9+1]=o+d,i[$gt+h]=s+f,i[$gt+h+1]=a+d,i[$gt+u]=s+f,i[$gt+u+1]=o+d):(i[$gt]=r*p+a*g+f,i[$gt+1]=r*m+a*y+d,i[$gt+9]=r*p+o*g+f,i[$gt+9+1]=r*m+o*y+d,i[$gt+h]=s*p+a*g+f,i[$gt+h+1]=s*m+a*y+d,i[$gt+u]=s*p+o*g+f,i[$gt+u+1]=s*m+o*y+d);i.set(e,$gt+5),i.set(e,$gt+9+5),i.set(e,$gt+h+5),i.set(e,$gt+u+5)}var uyt=t("tiledLayerAssembler",{getAssembler:function(){return syt}});kgt.Assembler=uyt;var cyt=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(){Qs(1006)},e.update=function(){Qs(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 Qs(1008),null},e.retain=function(){},e.release=function(){},t}();cyt.TAG_INVALID=-1;var _yt=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}on(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}(cyt),fyt=(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}on(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):(Nn(1021),!1)},i.clone=function(){var t=new e;return t.initWithAction(this._innerAction.clone(),this._speed),t},i.startWithTarget=function(t){cyt.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),cyt.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}}(cyt),0),dyt=function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1},pyt=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 dyt),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_"+fyt++);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 Nn(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._removeAllActionsByTag=function(t,e,i){for(var r=e.actions.length-1;r>=0;--r){var n=e.actions[r];if(n&&n.getTag()===t){if(i&&n.getOriginalTarget()!==i)continue;this._removeActionAtIndex(r,e)}}},e.removeActionByTag=function(t,e){var i=this;t===cyt.TAG_INVALID&&Qs(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.removeAllActionsByTag=function(t,e){var i=this;t===cyt.TAG_INVALID&&Qs(1002);var r=this._hashTargets;if(e){var n=r.get(e);n&&this._removeAllActionsByTag(t,n,e)}else r.forEach((function(e){i._removeAllActionsByTag(t,e)}))},e.getActionByTag=function(t,e){t===cyt.TAG_INVALID&&Qs(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}Qs(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(){Er.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(!Io(n)||n.isValid){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--}else this.removeAllActionsFromTarget(n),r--}},t}(),myt=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 pyt,e}return on(e,t),e.prototype.update=function(t){this.actionMgr.update(t)},Ur(e,[{key:"ActionManager",get:function(){return this.actionMgr}}]),e}(Rr));myt.ID="TWEEN",myt.instance=void 0,Kr.on(Or.EVENT_INIT,(function(){var t=new myt;myt.instance=t,Kr.registerSystem(myt.ID,t,Rr.Priority.MEDIUM)}));var gyt=function(t){function e(){return t.apply(this,arguments)||this}on(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}(_yt),yyt=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(Ys),e=0;e<t.length;++e)t[e].enabled=!0},i.reverse=function(){return new vyt},i.clone=function(){return new e},e}(gyt),vyt=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(Ys),e=0;e<t.length;++e)t[e].enabled=!1},i.reverse=function(){return new yyt},i.clone=function(){return new e},e}(gyt);!function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;i.update=function(){for(var t=this.target.getComponentsInChildren(Ys),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}}(gyt);var byt=function(t){function e(e){var i;return(i=t.call(this)||this)._isNeedCleanUp=!0,void 0!==e&&i.init(e),i}on(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}(gyt),Syt=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}on(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}(gyt),Ayt=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}on(e,t);var i=e.prototype;return i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?qr.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){cyt.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},i.reverse=function(){return Qs(1010),this},i.setAmplitudeRate=function(){Qs(1011)},i.getAmplitudeRate=function(){return Qs(1012),0},i.speed=function(t){return t<=0?(Qs(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?(Qs(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}(_yt),Tyt=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 Nn(1019),Pn(r);var s=n.length-1;if(s>=0&&null==n[s]&&Qs(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}on(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return Nn(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){Ayt.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(),cyt.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}(Ayt);function Cyt(t){var e=t instanceof Array?t:arguments;if(1===e.length)return Nn(1019),null;var i=e.length-1;i>=0&&null==e[i]&&Qs(1015);var r=null;if(i>=0){r=e[0];for(var n=1;n<=i;n++)e[n]&&(r=Tyt._actionOneTwo(r,e[n]))}return r}Tyt._actionOneTwo=function(t,e){var i=new Tyt;return i.initWithTwoActions(t,e),i};var xyt=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}on(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 gyt&&(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,Ayt.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),cyt.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}(Ayt),wyt=function(t){function e(e){var i;return(i=t.call(this)||this)._innerAction=null,e&&i.initWithAction(e),i}on(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?(this._innerAction=t,!0):(Nn(1026),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone()),t},i.startWithTarget=function(t){Ayt.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}(Ayt),Eyt=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 Nn(1020),Pn(r);var s=n.length-1;if(s>=0&&null==n[s]&&Qs(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}on(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return Nn(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=Tyt._actionOneTwo(e,Dyt(r-n)):r<n&&(this._one=Tyt._actionOneTwo(t,Dyt(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){Ayt.prototype.startWithTarget.call(this,t),this._one.startWithTarget(t),this._two.startWithTarget(t)},i.stop=function(){this._one.stop(),this._two.stop(),cyt.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}(Ayt);function Byt(t){var e=t instanceof Array?t:arguments;if(1===e.length)return Nn(1020),null;e.length>0&&null==e[e.length-1]&&Qs(1015);for(var i=e[0],r=1;r<e.length;r++)null!=e[r]&&(i=Eyt._actionOneTwo(i,e[r]));return i}Eyt._actionOneTwo=function(t,e){var i=new Eyt;return i.initWithTwoActions(t,e),i};var Ryt=function(t){function e(){return t.apply(this,arguments)||this}on(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}(Ayt);function Dyt(t){return new Ryt(t)}var Myt,Pyt,Iyt,Oyt,Fyt,Lyt,kyt,Vyt,Nyt,Gyt,zyt,Uyt,Hyt,Xyt,Wyt,jyt,Yyt,qyt,Kyt,Jyt,Zyt,Qyt,$yt,tvt,evt,ivt,rvt,nvt,svt,avt,ovt,lvt,hvt,uvt,cvt,_vt,fvt,dvt,pvt,mvt,gvt,yvt,vvt,bvt,Svt,Avt,Tvt,Cvt,xvt,wvt,Evt,Bvt,Rvt,Dvt,Mvt,Pvt,Ivt,Ovt,Fvt,Lvt,kvt=function(t){function e(e){var i;return(i=t.call(this)||this)._other=null,e&&i.initWithAction(e),i}on(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?t===this._other?(Nn(1029),!1):!!Ayt.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0):(Nn(1028),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},i.startWithTarget=function(t){Ayt.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(),cyt.prototype.stop.call(this)},e}(Ayt),Vvt=t("TweenAction",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 + "+Oo,r=t;r.delay&&bn(e+"delay"+i),r.repeat&&bn(e+"repeat"+i),r.repeatDelay&&bn(e+"repeatDelay"+i),r.interpolation&&bn(e+"interpolation"+i),r.onStop&&bn(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=Pa[s],r.easing||Rn(1031,s)}for(var a in n._opts=r,n._props=Object.create(null),i)if(i.hasOwnProperty(a)){var o=i[a];if("function"==typeof o&&(o=o()),null!=o&&"string"!=typeof o){var l=void 0,h=void 0;void 0!==o.value&&(o.easing||o.progress)&&("string"==typeof o.easing?(l=Pa[o.easing])||Rn(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}on(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){Ayt.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}(Ayt)),Nvt=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}on(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}(gyt),Gvt=t("Tween",function(){function t(t){this._actions=[],this._finalAction=null,this._target=null,this._tag=cyt.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 cyt?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&&myt.instance.ActionManager.removeAction(this._finalAction),this._finalAction=this._union(),this._finalAction.setTag(this._tag),myt.instance.ActionManager.addAction(this._finalAction,this._target,!1),this):(bn("Please set target to tween first"),this)},e.stop=function(){return this._finalAction&&myt.instance.ActionManager.removeAction(this._finalAction),this},e.clone=function(t){var e=this._union();return zvt(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 Vvt(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 Vvt(t,e,i);return this._actions.push(r),this},e.set=function(t){var e=new Nvt(t);return this._actions.push(e),this},e.delay=function(t){var e=Dyt(t);return this._actions.push(e),this},e.call=function(t){var e=function(t){return new Syt(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 xyt(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 wyt(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 kvt(t)}(i)),this},e.hide=function(){var t=new vyt;return this._actions.push(t),this},e.show=function(){var t=new yyt;return this._actions.push(t),this},e.removeSelf=function(){var t=new byt(!1);return this._actions.push(t),this},t.stopAll=function(){myt.instance.ActionManager.removeAllActions()},t.stopAllByTag=function(t,e){myt.instance.ActionManager.removeAllActionsByTag(t,e)},t.stopAllByTarget=function(t){myt.instance.ActionManager.removeAllActionsFromTarget(t)},e._union=function(){var t=this._actions;return 1===t.length?t[0]:Cyt(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 Cyt.apply(Cyt,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 Byt.apply(Byt,e)},t}());function zvt(t){return new Gvt(t)}function Uvt(t){return bn("tweenUtil' is deprecated, please use 'tween' instead "),new Gvt(t)}Gvt._tmp_args=[],Er.Tween=Gvt,Er.tween=zvt,Er.tweenUtil=Uvt;var Hvt,Xvt,Wvt,jvt=new y;!function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.SPRITE=2]="SPRITE",t[t.SCALE=3]="SCALE"}(Hvt||(Hvt={})),ss(Hvt),function(t){t.NORMAL="normal",t.HOVER="hover",t.PRESSED="pressed",t.DISABLED="disabled"}(Xvt||(Xvt={})),function(t){t.CLICK="click"}(Wvt||(Wvt={}));var Yvt=function(e){return t({Button:e,ButtonComponent:e}),e}((Myt=En("cc.Button"),Pyt=Qn(),Iyt=$n(110),Oyt=ts(),Fyt=us(Uc),Lyt=Wn(ks),kyt=es(),Vyt=is(),Nyt=es(),Gyt=is(),zyt=Wn(Hvt),Uyt=es(),Hyt=is(),Xyt=es(),Wyt=is(),jyt=es(),Yyt=is(),qyt=es(),Kyt=is(),Jyt=es(),Zyt=is(),Qyt=Lo(),$yt=ko(),tvt=es(),evt=is(),ivt=es(),rvt=is(),nvt=Wn(Bh),svt=es(),avt=is(),ovt=Wn(Bh),lvt=es(),hvt=is(),uvt=Wn(Bh),cvt=es(),_vt=is(),fvt=Wn(Bh),dvt=es(),pvt=is(),mvt=Wn([Fo]),gvt=es(),yvt=is(),Myt(vvt=Pyt(vvt=Iyt(vvt=Oyt(vvt=Fyt(vvt=Jn((Lvt=Fvt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e=t.call.apply(t,[this].concat(r))||this,Mn(e,"clickEvents",Svt,Pn(e)),Mn(e,"_interactable",Avt,Pn(e)),Mn(e,"_transition",Tvt,Pn(e)),Mn(e,"_normalColor",Cvt,Pn(e)),Mn(e,"_hoverColor",xvt,Pn(e)),Mn(e,"_pressedColor",wvt,Pn(e)),Mn(e,"_disabledColor",Evt,Pn(e)),Mn(e,"_normalSprite",Bvt,Pn(e)),Mn(e,"_hoverSprite",Rvt,Pn(e)),Mn(e,"_pressedSprite",Dvt,Pn(e)),Mn(e,"_disabledSprite",Mvt,Pn(e)),Mn(e,"_duration",Pvt,Pn(e)),Mn(e,"_zoomScale",Ivt,Pn(e)),Mn(e,"_target",Ovt,Pn(e)),e._pressed=!1,e._hovered=!1,e._fromColor=new y,e._toColor=new y,e._time=0,e._transitionFinished=!0,e._fromScale=new n,e._toScale=new n,e._originalScale=null,e._sprite=null,e._targetScale=new n,e}on(e,t);var i=e.prototype;return i.__preload=function(){this.target||(this.target=this.node);var t=this.node.getComponent(im);t&&(this._normalSprite=t.spriteFrame),this._applyTarget(),this._resetState()},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._resetState(),this._unregisterNodeEvent()},i.onDestroy=function(){this.target.isValid&&this._unregisterTargetEvent(this.target)},i.update=function(t){var e=this.target;if(!this._transitionFinished&&e&&(this._transition===Hvt.COLOR||this._transition===Hvt.SCALE)){this._time+=t;var i=1;if(this._duration>0&&(i=this._time/this._duration),i>=1&&(i=1),this._transition===Hvt.COLOR){var r=e._uiProps.uiComp;y.lerp(jvt,this._fromColor,this._toColor,i),r&&(r.color=jvt)}else this.transition===Hvt.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=x(this._fromScale.x,this._toScale.x,i),this._targetScale.y=x(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=this._transition;if(e===Hvt.COLOR&&this._interactable){var i=t.getComponent(af);i&&(i.color=this._normalColor)}else e===Hvt.SCALE&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){this.node.on(Zn.TOUCH_START,this._onTouchBegan,this),this.node.on(Zn.TOUCH_MOVE,this._onTouchMove,this),this.node.on(Zn.TOUCH_END,this._onTouchEnded,this),this.node.on(Zn.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(Zn.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(Zn.MOUSE_LEAVE,this._onMouseMoveOut,this)},i._registerTargetEvent=function(t){t.on(Zn.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(Zn.TOUCH_START,this._onTouchBegan,this),this.node.off(Zn.TOUCH_MOVE,this._onTouchMove,this),this.node.off(Zn.TOUCH_END,this._onTouchEnded,this),this.node.off(Zn.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(Zn.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(Zn.MOUSE_LEAVE,this._onMouseMoveOut,this)},i._unregisterTargetEvent=function(t){t.off(Zn.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(im)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new n),n.copy(this._originalScale,this.target.getScale()),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){this._transition===Hvt.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case Xvt.NORMAL:this._normalSprite=t;break;case Xvt.HOVER:this._hoverSprite=t;break;case Xvt.PRESSED:this._pressedSprite=t;break;case Xvt.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===Hvt.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case Xvt.NORMAL:this._normalColor=t;break;case Xvt.HOVER:this._hoverColor=t;break;case Xvt.PRESSED:this._pressedColor=t;break;case Xvt.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t&Ws.SCALE&&this._originalScale&&this._transition===Hvt.SCALE&&this._transitionFinished&&n.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.hitTest(e.getLocation());this._transition===Hvt.SCALE&&this.target&&this._originalScale?r?(n.copy(this._fromScale,this._originalScale),n.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=r?Xvt.PRESSED:Xvt.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(Fo.emitEvents(this.clickEvents,t),this.node.emit(Wvt.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!==Hvt.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=Xvt.NORMAL;return this._interactable?this._pressed?t=Xvt.PRESSED:this._hovered&&(t=Xvt.HOVER):t=Xvt.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(af);r&&(t===Xvt.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===Xvt.PRESSED?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(n.copy(this._fromScale,this._originalScale),n.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(n.copy(this._fromScale,this.target.getScale()),n.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===Hvt.COLOR?this._updateColorTransition(t):e===Hvt.SPRITE?this._updateSpriteTransition(t):e===Hvt.SCALE&&this._updateScaleTransition(t)},Ur(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._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===Hvt.COLOR?this._updateColorTransition(Xvt.NORMAL):this._transition===Hvt.SPRITE&&this._updateSpriteTransition(Xvt.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(im);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}(ns),Fvt.Transition=Hvt,Fvt.EventType=Wvt,Dn((bvt=Lvt).prototype,"target",[Lyt,kyt,Vyt],Object.getOwnPropertyDescriptor(bvt.prototype,"target"),bvt.prototype),Dn(bvt.prototype,"interactable",[Nyt,Gyt],Object.getOwnPropertyDescriptor(bvt.prototype,"interactable"),bvt.prototype),Dn(bvt.prototype,"transition",[zyt,Uyt,Hyt],Object.getOwnPropertyDescriptor(bvt.prototype,"transition"),bvt.prototype),Dn(bvt.prototype,"normalColor",[Xyt,Wyt],Object.getOwnPropertyDescriptor(bvt.prototype,"normalColor"),bvt.prototype),Dn(bvt.prototype,"pressedColor",[jyt,Yyt],Object.getOwnPropertyDescriptor(bvt.prototype,"pressedColor"),bvt.prototype),Dn(bvt.prototype,"hoverColor",[qyt,Kyt],Object.getOwnPropertyDescriptor(bvt.prototype,"hoverColor"),bvt.prototype),Dn(bvt.prototype,"disabledColor",[Jyt,Zyt],Object.getOwnPropertyDescriptor(bvt.prototype,"disabledColor"),bvt.prototype),Dn(bvt.prototype,"duration",[Qyt,$yt,tvt,evt],Object.getOwnPropertyDescriptor(bvt.prototype,"duration"),bvt.prototype),Dn(bvt.prototype,"zoomScale",[ivt,rvt],Object.getOwnPropertyDescriptor(bvt.prototype,"zoomScale"),bvt.prototype),Dn(bvt.prototype,"normalSprite",[nvt,svt,avt],Object.getOwnPropertyDescriptor(bvt.prototype,"normalSprite"),bvt.prototype),Dn(bvt.prototype,"pressedSprite",[ovt,lvt,hvt],Object.getOwnPropertyDescriptor(bvt.prototype,"pressedSprite"),bvt.prototype),Dn(bvt.prototype,"hoverSprite",[uvt,cvt,_vt],Object.getOwnPropertyDescriptor(bvt.prototype,"hoverSprite"),bvt.prototype),Dn(bvt.prototype,"disabledSprite",[fvt,dvt,pvt],Object.getOwnPropertyDescriptor(bvt.prototype,"disabledSprite"),bvt.prototype),Svt=Dn(bvt.prototype,"clickEvents",[mvt,On,gvt,yvt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Avt=Dn(bvt.prototype,"_interactable",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Tvt=Dn(bvt.prototype,"_transition",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Hvt.NONE}}),Cvt=Dn(bvt.prototype,"_normalColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),xvt=Dn(bvt.prototype,"_hoverColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(211,211,211,255)}}),wvt=Dn(bvt.prototype,"_pressedColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return y.WHITE.clone()}}),Evt=Dn(bvt.prototype,"_disabledColor",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new y(124,124,124,255)}}),Bvt=Dn(bvt.prototype,"_normalSprite",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Rvt=Dn(bvt.prototype,"_hoverSprite",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Dvt=Dn(bvt.prototype,"_pressedSprite",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Mvt=Dn(bvt.prototype,"_disabledSprite",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Pvt=Dn(bvt.prototype,"_duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),Ivt=Dn(bvt.prototype,"_zoomScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.2}}),Ovt=Dn(bvt.prototype,"_target",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),vvt=bvt))||vvt)||vvt)||vvt)||vvt)||vvt)||vvt));Er.Button=Yvt;var qvt,Kvt,Jvt,Zvt=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}();Zvt._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"}(qvt||(qvt={})),zs(qvt),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"}(Kvt||(Kvt={})),zs(Kvt),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"}(Jvt||(Jvt={})),zs(Jvt);var Qvt,$vt,tbt,ebt,ibt,rbt,nbt,sbt,abt,obt,lbt,hbt,ubt,cbt,_bt,fbt,dbt,pbt,mbt,gbt,ybt,vbt,bbt,Sbt,Abt,Tbt,Cbt,xbt,wbt,Ebt,Bbt,Rbt,Dbt,Mbt,Pbt,Ibt,Obt,Fbt,Lbt,kbt,Vbt,Nbt,Gbt,zbt,Ubt,Hbt,Xbt,Wbt,jbt,Ybt,qbt,Kbt,Jbt,Zbt,Qbt,$bt,tSt,eSt,iSt,rSt,nSt,sSt=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}(),aSt=new c,oSt=new c,lSt=new n,hSt=null,uSt=0,cSt=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.__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_"+ ++uSt,e}on(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,t.inputMode===Kvt.ANY?this._createTextArea():this._createInput(),Zvt.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer())},i.clear=function(){this._removeEventListeners(),this._removeDomFromGameContainer(),Zvt.remove(this),hSt===this&&(hSt=null),this._delegate=null},i.update=function(){this._updateMatrix()},i.setTabIndex=function(t){this._edTxt.tabIndex=t,Zvt.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){hSt&&hSt!==this&&hSt.setFocus(!1),this._editing=!0,hSt=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(){Ir.container&&this._edTxt&&(Ir.container.appendChild(this._edTxt),document.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){Vo(Ir.container,this._edTxt)&&this._edTxt&&Ir.container.removeChild(this._edTxt),Vo(document.head,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()),Fn.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),Fn.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){Fn.os!==ja.ANDROID&&Fn.os!==ja.OHOS||(No.handleResizeEvent=!1,this._adjustWindowScroll())},i._hideDomOnMobile=function(){Fn.os!==ja.ANDROID&&Fn.os!==ja.OHOS||(No.handleResizeEvent=!0),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(){Fn.browserType!==Ya.WECHAT||Fn.os!==ja.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=Hs.getScaleX(),i=Hs.getScaleY(),r=Hs.getViewportRect(),s=No.devicePixelRatio;t.getWorldMatrix(aSt);var a=t._uiProps.uiTransformComp;if(a&&n.set(lSt,-a.anchorX*a.width,-a.anchorY*a.height,lSt.z),c.transform(aSt,aSt,lSt),t._uiProps.uiTransformComp){var o=Kr.root.batcher2D.getFirstRenderCamera(t);if(o){o.node.getWorldRT(oSt);var l=oSt.m12,h=oSt.m13,u=rs.center;oSt.m12=u.x-(oSt.m00*l+oSt.m04*h),oSt.m13=u.y-(oSt.m01*l+oSt.m05*h),c.multiply(oSt,oSt,aSt),e/=s,i/=s;var _=Ir.container,f=oSt.m00*e,d=aSt.m01,p=aSt.m04,m=oSt.m05*i,g=parseInt(_&&_.style.paddingLeft||"0");g+=r.x/s;var y=parseInt(_&&_.style.paddingBottom||"0");y+=r.y/s;var v="matrix("+f+","+-d+","+-p+","+m+","+(oSt.m12*e+g)+","+-(oSt.m13*i+y)+")";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===Jvt.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===Jvt.INITIAL_CAPS_WORD&&(s="capitalize"),void(n.style.textTransform=s)}if(n=n,i===Jvt.PASSWORD)return n.type="password",void(n.style.textTransform="none");var a=n.type;e===Kvt.EMAIL_ADDR?a="email":e===Kvt.NUMERIC||e===Kvt.DECIMAL?a="number":e===Kvt.PHONE_NUMBER?(a="number",n.pattern="[0-9]*",n.addEventListener("wheel",(function(){return!1}))):e===Kvt.URL?a="url":(a="text",r===qvt.SEARCH&&(a="search")),n.type=a;var o="none";i===Jvt.INITIAL_CAPS_ALL_CHARACTERS?o="uppercase":i===Jvt.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,this._updateTextLabel(t.textLabel))},i._updateTextLabel=function(t){if(t){var e=t.font;e=!e||e instanceof Kh?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 of.HorizontalAlign.LEFT:r.style.textAlign="left";break;case of.HorizontalAlign.CENTER:r.style.textAlign="center";break;case of.HorizontalAlign.RIGHT:r.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof Kh?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 of.HorizontalAlign.LEFT:a="left";break;case of.HorizontalAlign.CENTER:a="center";break;case of.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+";}",Fn.browserType===Ya.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&&Fn.isMobile&&t._adjustWindowScroll()},r.onKeydown=function(i){i.keyCode===Go.ENTER?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Go.TAB&&(i.propagationStopped=!0,i.preventDefault(),Zvt.next(t))},r.onBlur=function(){Fn.isMobile&&i&&r.compositionEnd(),t._editing=!1,hSt=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}(sSt);!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"}(nSt||(nSt={}));var _St,fSt,dSt,pSt,mSt,gSt,ySt,vSt,bSt,SSt,ASt,TSt,CSt,xSt,wSt,ESt,BSt,RSt,DSt,MSt,PSt,ISt,OSt,FSt,LSt,kSt,VSt,NSt,GSt,zSt,USt,HSt,XSt,WSt,jSt,YSt,qSt,KSt,JSt,ZSt,QSt,$St,tAt,eAt,iAt,rAt,nAt,sAt,aAt,oAt,lAt,hAt,uAt,cAt,_At,fAt,dAt,pAt,mAt,gAt,yAt,vAt=function(e){return t({EditBox:e,EditBoxComponent:e}),e}((Qvt=En("cc.EditBox"),$vt=Qn(),tbt=$n(110),ebt=ts(),ibt=us(Uc),rbt=es(),nbt=is(),sbt=es(),abt=is(),obt=Wn(of),lbt=es(),hbt=is(),ubt=Wn(of),cbt=es(),_bt=is(),fbt=Wn(Bh),dbt=es(),pbt=is(),mbt=Wn(Jvt),gbt=es(),ybt=is(),vbt=Wn(Kvt),bbt=es(),Sbt=is(),Abt=Wn(qvt),Tbt=es(),Cbt=is(),xbt=es(),wbt=is(),Ebt=es(),Bbt=is(),Rbt=Wn([Fo]),Dbt=es(),Mbt=is(),Pbt=Wn([Fo]),Ibt=es(),Obt=is(),Fbt=Wn([Fo]),Lbt=es(),kbt=is(),Vbt=Wn([Fo]),Nbt=es(),Gbt=is(),Qvt(zbt=$vt(zbt=tbt(zbt=ebt(zbt=ibt(zbt=Jn((rSt=iSt=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,Mn(e,"editingDidBegan",Hbt,Pn(e)),Mn(e,"textChanged",Xbt,Pn(e)),Mn(e,"editingDidEnded",Wbt,Pn(e)),Mn(e,"editingReturn",jbt,Pn(e)),e._impl=null,e._background=null,Mn(e,"_textLabel",Ybt,Pn(e)),Mn(e,"_placeholderLabel",qbt,Pn(e)),Mn(e,"_returnType",Kbt,Pn(e)),Mn(e,"_string",Jbt,Pn(e)),Mn(e,"_tabIndex",Zbt,Pn(e)),Mn(e,"_backgroundImage",Qbt,Pn(e)),Mn(e,"_inputFlag",$bt,Pn(e)),Mn(e,"_inputMode",tSt,Pn(e)),Mn(e,"_maxLength",eSt,Pn(e)),e._isLabelVisible=!1,e}on(e,t);var i=e.prototype;return i.__preload=function(){this._init()},i.onEnable=function(){this._registerEvent(),this._ensureBackgroundSprite(),this._impl&&this._impl.onEnable()},i.update=function(){this._impl&&this._impl.update()},i.onDisable=function(){this._unregisterEvent(),this._unregisterBackgroundEvent(),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(){Fo.emitEvents(this.editingDidBegan,this),this.node.emit(nSt.EDITING_DID_BEGAN,this)},i._editBoxEditingDidEnded=function(){Fo.emitEvents(this.editingDidEnded,this),this.node.emit(nSt.EDITING_DID_ENDED,this)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,Fo.emitEvents(this.textChanged,t,this),this.node.emit(nSt.TEXT_CHANGED,this)},i._editBoxEditingReturn=function(){Fo.emitEvents(this.editingReturn,this),this.node.emit(nSt.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._updatePlaceholderLabel(),this._updateTextLabel(),this._isLabelVisible=!0,this.node.on(Zn.SIZE_CHANGED,this._resizeChildNodes,this),(this._impl=new e._EditBoxImpl).init(this),this._updateString(this._string),this._syncSize()},i._ensureBackgroundSprite=function(){if(!this._background){var t=this.node.getComponent(im);t||(t=this.node.addComponent(im)),t!==this._background&&(t.type=im.Type.SLICED,t.spriteFrame=this._backgroundImage,this._background=t,this._registerBackgroundEvent())}},i._updateTextLabel=function(){var t=this._textLabel;if(!t){var e=this.node.getChildByName("TEXT_LABEL");e||((e=new ks("TEXT_LABEL")).layer=this.node.layer),(t=e.getComponent(of))||(t=e.addComponent(of)),e.parent=this.node,this._textLabel=t}this._textLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),t.overflow=of.Overflow.CLAMP,this._inputMode===Kvt.ANY?(t.verticalAlign=rf.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 ks("PLACEHOLDER_LABEL")).layer=this.node.layer),(t=e.getComponent(of))||(t=e.addComponent(of)),e.parent=this.node,this._placeholderLabel=t}this._placeholderLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),this._inputMode===Kvt.ANY?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!==Jvt.PASSWORD)r===Jvt.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():r===Jvt.INITIAL_CAPS_WORD?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):r===Jvt.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(Zn.TOUCH_START,this._onTouchBegan,this),this.node.on(Zn.TOUCH_END,this._onTouchEnded,this)},i._unregisterEvent=function(){this.node.off(Zn.TOUCH_START,this._onTouchBegan,this),this.node.off(Zn.TOUCH_END,this._onTouchEnded,this)},i._onBackgroundSpriteFrameChanged=function(){this._background&&(this.backgroundImage=this._background.spriteFrame)},i._registerBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.on(im.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,this)},i._unregisterBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.off(im.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,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===Kvt.ANY&&(s.verticalAlign=rf.TOP),s.enableWrapText=this._inputMode===Kvt.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),n.enableWrapText=this._inputMode===Kvt.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),this._syncSize()},Ur(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._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._ensureBackgroundSprite(),this._background.spriteFrame=t)}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(t){this._inputFlag!==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}(ns),iSt._EditBoxImpl=sSt,iSt.KeyboardReturnType=qvt,iSt.InputFlag=Jvt,iSt.InputMode=Kvt,iSt.EventType=nSt,Dn((Ubt=rSt).prototype,"string",[rbt,nbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"string"),Ubt.prototype),Dn(Ubt.prototype,"placeholder",[sbt,abt],Object.getOwnPropertyDescriptor(Ubt.prototype,"placeholder"),Ubt.prototype),Dn(Ubt.prototype,"textLabel",[obt,lbt,hbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"textLabel"),Ubt.prototype),Dn(Ubt.prototype,"placeholderLabel",[ubt,cbt,_bt],Object.getOwnPropertyDescriptor(Ubt.prototype,"placeholderLabel"),Ubt.prototype),Dn(Ubt.prototype,"backgroundImage",[fbt,dbt,pbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"backgroundImage"),Ubt.prototype),Dn(Ubt.prototype,"inputFlag",[mbt,gbt,ybt],Object.getOwnPropertyDescriptor(Ubt.prototype,"inputFlag"),Ubt.prototype),Dn(Ubt.prototype,"inputMode",[vbt,bbt,Sbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"inputMode"),Ubt.prototype),Dn(Ubt.prototype,"returnType",[Abt,Tbt,Cbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"returnType"),Ubt.prototype),Dn(Ubt.prototype,"maxLength",[xbt,wbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"maxLength"),Ubt.prototype),Dn(Ubt.prototype,"tabIndex",[Ebt,Bbt],Object.getOwnPropertyDescriptor(Ubt.prototype,"tabIndex"),Ubt.prototype),Hbt=Dn(Ubt.prototype,"editingDidBegan",[Rbt,On,Dbt,Mbt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Xbt=Dn(Ubt.prototype,"textChanged",[Pbt,On,Ibt,Obt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Wbt=Dn(Ubt.prototype,"editingDidEnded",[Fbt,On,Lbt,kbt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),jbt=Dn(Ubt.prototype,"editingReturn",[Vbt,On,Nbt,Gbt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ybt=Dn(Ubt.prototype,"_textLabel",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qbt=Dn(Ubt.prototype,"_placeholderLabel",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Kbt=Dn(Ubt.prototype,"_returnType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qvt.DEFAULT}}),Jbt=Dn(Ubt.prototype,"_string",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Zbt=Dn(Ubt.prototype,"_tabIndex",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Qbt=Dn(Ubt.prototype,"_backgroundImage",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),$bt=Dn(Ubt.prototype,"_inputFlag",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Jvt.DEFAULT}}),tSt=Dn(Ubt.prototype,"_inputMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Kvt.ANY}}),eSt=Dn(Ubt.prototype,"_maxLength",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),zbt=Ubt))||zbt)||zbt)||zbt)||zbt)||zbt)||zbt));"object"!=typeof window||"object"!=typeof document||zo||Uo||Ho||(vAt._EditBoxImpl=cSt),Er.internal.EditBox=vAt,function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(fAt||(fAt={})),ss(fAt),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(dAt||(dAt={})),ss(dAt),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(pAt||(pAt={})),ss(pAt),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(mAt||(mAt={})),ss(mAt),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(gAt||(gAt={})),ss(gAt),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(yAt||(yAt={})),ss(yAt);var bAt,SAt,AAt,TAt,CAt,xAt,wAt,EAt,BAt,RAt,DAt,MAt,PAt,IAt,OAt,FAt,LAt,kAt,VAt,NAt,GAt,zAt,UAt,HAt=new n,XAt=function(e){return t({Layout:e,LayoutComponent:e}),e}((_St=En("cc.Layout"),fSt=Qn(),dSt=$n(110),pSt=ts(),mSt=us(Uc),gSt=cs(),ySt=is(),vSt=cs(),bSt=is(),SSt=Wn(fAt),ASt=es(),TSt=is(),CSt=Wn(dAt),xSt=cs(),wSt=is(),ESt=cs(),BSt=is(),RSt=Wn(pAt),DSt=is(),MSt=is(),PSt=is(),ISt=is(),OSt=is(),FSt=is(),LSt=is(),kSt=Wn(mAt),VSt=is(),NSt=Wn(gAt),GSt=is(),zSt=Wn(yAt),USt=cs(),HSt=is(),XSt=cs(),WSt=is(),jSt=is(),_St(YSt=fSt(YSt=dSt(YSt=pSt(YSt=mSt(YSt=Jn((_At=cAt=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,Mn(e,"_resizeMode",KSt,Pn(e)),Mn(e,"_layoutType",JSt,Pn(e)),Mn(e,"_cellSize",ZSt,Pn(e)),Mn(e,"_startAxis",QSt,Pn(e)),Mn(e,"_paddingLeft",$St,Pn(e)),Mn(e,"_paddingRight",tAt,Pn(e)),Mn(e,"_paddingTop",eAt,Pn(e)),Mn(e,"_paddingBottom",iAt,Pn(e)),Mn(e,"_spacingX",rAt,Pn(e)),Mn(e,"_spacingY",nAt,Pn(e)),Mn(e,"_verticalDirection",sAt,Pn(e)),Mn(e,"_horizontalDirection",aAt,Pn(e)),Mn(e,"_constraint",oAt,Pn(e)),Mn(e,"_constraintNum",lAt,Pn(e)),Mn(e,"_affectedByScale",hAt,Pn(e)),Mn(e,"_isAlign",uAt,Pn(e)),e._layoutSize=new d(300,200),e._layoutDirty=!0,e._childrenDirty=!1,e._usefulLayoutObj=[],e._init=!1,e}on(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(d.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(){Kr.on(Or.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.on(Zn.SIZE_CHANGED,this._resized,this),this.node.on(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.on(Zn.CHILD_ADDED,this._childAdded,this),this.node.on(Zn.CHILD_REMOVED,this._childRemoved,this),this.node.on(Zn.SIBLING_ORDER_CHANGED,this._childrenChanged,this),this.node.on("childrenSiblingOrderChanged",this.updateLayout,this),this._addChildrenEventListeners()},i._removeEventListeners=function(){Kr.off(Or.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.off(Zn.SIZE_CHANGED,this._resized,this),this.node.off(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.off(Zn.CHILD_ADDED,this._childAdded,this),this.node.off(Zn.CHILD_REMOVED,this._childRemoved,this),this.node.off(Zn.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(Zn.SIZE_CHANGED,this._doLayoutDirty,this),i.on(Zn.TRANSFORM_CHANGED,this._transformDirty,this),i.on(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),i.on(Zn.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(Zn.SIZE_CHANGED,this._doLayoutDirty,this),i.off(Zn.TRANSFORM_CHANGED,this._transformDirty,this),i.off(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),i.off(Zn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this)}},i._childAdded=function(t){t.on(Zn.SIZE_CHANGED,this._doLayoutDirty,this),t.on(Zn.TRANSFORM_CHANGED,this._transformDirty,this),t.on(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),t.on(Zn.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this),this._childrenChanged()},i._childRemoved=function(t){t.off(Zn.SIZE_CHANGED,this._doLayoutDirty,this),t.off(Zn.TRANSFORM_CHANGED,this._transformDirty,this),t.off(Zn.ANCHOR_CHANGED,this._doLayoutDirty,this),t.off(Zn.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===gAt.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,d=!1,p=this._usefulLayoutObj.length,m=this._cellSize.width,g=this._getPaddingH();this._layoutType!==fAt.GRID&&this._resizeMode===dAt.CHILDREN&&(m=(t-g-(p-1)*this._spacingX)/p);for(var y=this._usefulLayoutObj,v=0;v<y.length;++v){var b=y[v],S=b.node,A=S.scale,T=this._getUsedScaleValue(A.x),C=this._getUsedScaleValue(A.y);this._resizeMode===dAt.CHILDREN&&(b.width=m/T,this._layoutType===fAt.GRID&&(b.height=this._cellSize.height/C));var x=Math.abs(this._horizontalDirection-b.anchorX),w=b.width*T,E=b.height*C;E>_&&(f=Math.max(_,f),c=_||E,_=E),h+=a*(x*w+this._spacingX);var B=a*(1-x)*w;if(e){if(s>0)(d=v/s>0&&v%s==0)&&(c=_>E?_:c);else if(w>t-g)h>l+a*x*w&&(d=!0);else{var R=(1-this._horizontalDirection-n.x)*t,D=h+B+a*(a>0?this._paddingRight:this._paddingLeft);d=Math.abs(D)>Math.abs(R)}d&&(h=l+a*x*w,E!==_&&(c=_),u+=c+this._spacingY,c=_=E)}var M=i(S,b,u);r&&S.setPosition(h,M),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===mAt.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,d=!1,p=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();this._layoutType!==fAt.GRID&&this._resizeMode===dAt.CHILDREN&&(m=(t-g-(p-1)*this._spacingY)/p);for(var y=this._usefulLayoutObj,v=0;v<y.length;++v){var b=y[v],S=b.node,A=S.scale,T=this._getUsedScaleValue(A.x),C=this._getUsedScaleValue(A.y);this._resizeMode===dAt.CHILDREN&&(b.height=m/C,this._layoutType===fAt.GRID&&(b.width=this._cellSize.width/T));var x=Math.abs(this._verticalDirection-b.anchorY),w=b.width*T,E=b.height*C;w>u&&(c=Math.max(u,c),_=u||w,u=w),h+=a*(x*E+this._spacingY);var B=a*(1-x)*E;if(e){if(s>0)(d=v/s>0&&v%s==0)&&(_=u>E?u:_);else if(E>t-g)h>l+a*x*E&&(d=!0);else{var R=(1-this._verticalDirection-n.y)*t,D=h+B+a*(a>0?this._paddingTop:this._paddingBottom);d=Math.abs(D)>Math.abs(R)}d&&(h=l+a*x*E,w!==u&&(_=u),f+=_+this._spacingX,_=u=w)}var M=i(S,b,f);r&&(S.getPosition(HAt),S.setPosition(M,h,HAt.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===mAt.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===dAt.CONTAINER&&(l=this._doLayoutHorizontally(r,!0,o,!1),s=-t.y*l,this._verticalDirection===mAt.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*l)),this._doLayoutHorizontally(r,!0,o,!0),this._resizeMode===dAt.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===gAt.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===dAt.CONTAINER&&(l=this._doLayoutVertically(r,!0,o,!1),s=-t.x*l,this._horizontalDirection===gAt.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*l)),this._doLayoutVertically(r,!0,o,!0),this._resizeMode===dAt.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===pAt.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===pAt.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===dAt.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===dAt.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===fAt.HORIZONTAL){var e=this._getHorizontalBaseWidth();this._doLayoutHorizontally(e,!1,(function(e){return(t._isAlign?n.ZERO:e.position).y}),!0),this.node._uiProps.uiTransformComp.width=e}else if(this._layoutType===fAt.VERTICAL){var i=this._getVerticalBaseHeight();this._doLayoutVertically(i,!1,(function(e){return(t._isAlign?n.ZERO:e.position).x}),!0),this.node._uiProps.uiTransformComp.height=i}else this._layoutType===fAt.GRID&&this._doLayoutGrid()},i._getUsedScaleValue=function(t){return this._affectedByScale?Math.abs(t):1},i._transformDirty=function(t){t&Ws.SCALE&&t&Ws.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!==fAt.GRID||this._constraint===yAt.NONE||this._constraintNum<=0)return 0;var t=this._constraint===yAt.FIXED_ROW?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum;return this._startAxis===pAt.VERTICAL&&(t=this._constraint===yAt.FIXED_COL?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum),t},Ur(e,[{key:"alignHorizontal",get:function(){return this._isAlign},set:function(t){this._layoutType===fAt.HORIZONTAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"alignVertical",get:function(){return this._isAlign},set:function(t){this._layoutType===fAt.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!==fAt.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!==fAt.NONE&&this._constraint!==t&&(this._constraint=t,this._doLayoutDirty())}},{key:"constraintNum",get:function(){return this._constraintNum},set:function(t){this._constraint!==yAt.NONE&&this._constraintNum!==t&&(t<=0&&bn("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}(ns),cAt.Type=fAt,cAt.VerticalDirection=mAt,cAt.HorizontalDirection=gAt,cAt.ResizeMode=dAt,cAt.AxisDirection=pAt,cAt.Constraint=yAt,Dn((qSt=_At).prototype,"alignHorizontal",[gSt,ySt],Object.getOwnPropertyDescriptor(qSt.prototype,"alignHorizontal"),qSt.prototype),Dn(qSt.prototype,"alignVertical",[vSt,bSt],Object.getOwnPropertyDescriptor(qSt.prototype,"alignVertical"),qSt.prototype),Dn(qSt.prototype,"type",[SSt,ASt,TSt],Object.getOwnPropertyDescriptor(qSt.prototype,"type"),qSt.prototype),Dn(qSt.prototype,"resizeMode",[CSt,xSt,wSt],Object.getOwnPropertyDescriptor(qSt.prototype,"resizeMode"),qSt.prototype),Dn(qSt.prototype,"cellSize",[ESt,BSt],Object.getOwnPropertyDescriptor(qSt.prototype,"cellSize"),qSt.prototype),Dn(qSt.prototype,"startAxis",[RSt,DSt],Object.getOwnPropertyDescriptor(qSt.prototype,"startAxis"),qSt.prototype),Dn(qSt.prototype,"paddingLeft",[MSt],Object.getOwnPropertyDescriptor(qSt.prototype,"paddingLeft"),qSt.prototype),Dn(qSt.prototype,"paddingRight",[PSt],Object.getOwnPropertyDescriptor(qSt.prototype,"paddingRight"),qSt.prototype),Dn(qSt.prototype,"paddingTop",[ISt],Object.getOwnPropertyDescriptor(qSt.prototype,"paddingTop"),qSt.prototype),Dn(qSt.prototype,"paddingBottom",[OSt],Object.getOwnPropertyDescriptor(qSt.prototype,"paddingBottom"),qSt.prototype),Dn(qSt.prototype,"spacingX",[FSt],Object.getOwnPropertyDescriptor(qSt.prototype,"spacingX"),qSt.prototype),Dn(qSt.prototype,"spacingY",[LSt],Object.getOwnPropertyDescriptor(qSt.prototype,"spacingY"),qSt.prototype),Dn(qSt.prototype,"verticalDirection",[kSt,VSt],Object.getOwnPropertyDescriptor(qSt.prototype,"verticalDirection"),qSt.prototype),Dn(qSt.prototype,"horizontalDirection",[NSt,GSt],Object.getOwnPropertyDescriptor(qSt.prototype,"horizontalDirection"),qSt.prototype),Dn(qSt.prototype,"constraint",[zSt,USt,HSt],Object.getOwnPropertyDescriptor(qSt.prototype,"constraint"),qSt.prototype),Dn(qSt.prototype,"constraintNum",[XSt,WSt],Object.getOwnPropertyDescriptor(qSt.prototype,"constraintNum"),qSt.prototype),Dn(qSt.prototype,"affectedByScale",[jSt],Object.getOwnPropertyDescriptor(qSt.prototype,"affectedByScale"),qSt.prototype),KSt=Dn(qSt.prototype,"_resizeMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dAt.NONE}}),JSt=Dn(qSt.prototype,"_layoutType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return fAt.NONE}}),ZSt=Dn(qSt.prototype,"_cellSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new d(40,40)}}),QSt=Dn(qSt.prototype,"_startAxis",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pAt.HORIZONTAL}}),$St=Dn(qSt.prototype,"_paddingLeft",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),tAt=Dn(qSt.prototype,"_paddingRight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),eAt=Dn(qSt.prototype,"_paddingTop",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),iAt=Dn(qSt.prototype,"_paddingBottom",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),rAt=Dn(qSt.prototype,"_spacingX",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),nAt=Dn(qSt.prototype,"_spacingY",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),sAt=Dn(qSt.prototype,"_verticalDirection",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return mAt.TOP_TO_BOTTOM}}),aAt=Dn(qSt.prototype,"_horizontalDirection",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gAt.LEFT_TO_RIGHT}}),oAt=Dn(qSt.prototype,"_constraint",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return yAt.NONE}}),lAt=Dn(qSt.prototype,"_constraintNum",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),hAt=Dn(qSt.prototype,"_affectedByScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),uAt=Dn(qSt.prototype,"_isAlign",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),YSt=qSt))||YSt)||YSt)||YSt)||YSt)||YSt)||YSt));Er.Layout=XAt,function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.FILLED=2]="FILLED"}(UAt||(UAt={})),zs(UAt);var WAt,jAt,YAt,qAt,KAt,JAt,ZAt,QAt,$At,tTt,eTt,iTt,rTt,nTt,sTt,aTt,oTt,lTt,hTt,uTt,cTt,_Tt,fTt,dTt,pTt=function(e){return t({ProgressBar:e,ProgressBarComponent:e}),e}((bAt=En("cc.ProgressBar"),SAt=Qn(),AAt=$n(110),TAt=ts(),CAt=us(Uc),xAt=Wn(im),wAt=is(),EAt=Wn(UAt),BAt=is(),RAt=is(),DAt=Ls(),MAt=is(),PAt=is(),bAt(IAt=SAt(IAt=AAt(IAt=TAt(IAt=CAt((zAt=GAt=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,Mn(e,"_barSprite",FAt,Pn(e)),Mn(e,"_mode",LAt,Pn(e)),Mn(e,"_totalLength",kAt,Pn(e)),Mn(e,"_progress",VAt,Pn(e)),Mn(e,"_reverse",NAt,Pn(e)),e}on(e,t);var r=e.prototype;return r._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===im.FillType.RADIAL&&(this._mode=UAt.FILLED),this._mode===UAt.HORIZONTAL?this.totalLength=n.width:this._mode===UAt.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)}}},r._updateBarStatus=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=t._uiProps.uiTransformComp,r=e.anchorPoint,s=e.contentSize,a=t.getPosition(),o=new i(0,.5),l=C(this._progress),h=this._totalLength*l,u=s,c=0,_=0;switch(this._mode){case UAt.HORIZONTAL:this._reverse&&(o=new i(1,.5)),u=new d(h,s.height),c=this._totalLength,_=s.height;break;case UAt.VERTICAL:o=this._reverse?new i(.5,1):new i(.5,0),u=new d(s.width,h),c=s.width,_=this._totalLength}if(this._mode===UAt.FILLED)this._barSprite.type!==im.Type.FILLED?bn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this._reverse&&(h*=-1),this._barSprite.fillRange=h);else if(this._barSprite.type!==im.Type.FILLED){var f=o.x-r.x,p=o.y-r.y,m=new n(c*f,_*p,0);t.setPosition(a.x+m.x,a.y+m.y,a.z),e.setAnchorPoint(o),e.setContentSize(u)}else bn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},Ur(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===UAt.HORIZONTAL?this.totalLength=i.width:this._mode===UAt.VERTICAL?this.totalLength=i.height:this._mode===UAt.FILLED&&(this.totalLength=this._barSprite.fillRange)}}},{key:"totalLength",get:function(){return this._totalLength},set:function(t){this._mode===UAt.FILLED&&(t=C(t)),this._totalLength!==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}(ns),GAt.Mode=UAt,Dn((OAt=zAt).prototype,"barSprite",[xAt,wAt],Object.getOwnPropertyDescriptor(OAt.prototype,"barSprite"),OAt.prototype),Dn(OAt.prototype,"mode",[EAt,BAt],Object.getOwnPropertyDescriptor(OAt.prototype,"mode"),OAt.prototype),Dn(OAt.prototype,"totalLength",[RAt],Object.getOwnPropertyDescriptor(OAt.prototype,"totalLength"),OAt.prototype),Dn(OAt.prototype,"progress",[DAt,Ns,MAt],Object.getOwnPropertyDescriptor(OAt.prototype,"progress"),OAt.prototype),Dn(OAt.prototype,"reverse",[PAt],Object.getOwnPropertyDescriptor(OAt.prototype,"reverse"),OAt.prototype),FAt=Dn(OAt.prototype,"_barSprite",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),LAt=Dn(OAt.prototype,"_mode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return UAt.HORIZONTAL}}),kAt=Dn(OAt.prototype,"_totalLength",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),VAt=Dn(OAt.prototype,"_progress",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),NAt=Dn(OAt.prototype,"_reverse",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),IAt=OAt))||IAt)||IAt)||IAt)||IAt)||IAt));Er.ProgressBar=pTt;var mTt,gTt=new n,yTt=new n,vTt=new n,bTt=new i,STt=new y,ATt=new i;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(mTt||(mTt={})),ss(mTt);var TTt,CTt=function(e){return t({ScrollBar:e,ScrollBarComponent:e}),e}((WAt=En("cc.ScrollBar"),jAt=Qn(),YAt=$n(110),qAt=ts(),KAt=us(Uc),JAt=Wn(im),ZAt=es(),QAt=is(),$At=Wn(mTt),tTt=es(),eTt=is(),iTt=es(),rTt=is(),nTt=es(),sTt=is(),WAt(aTt=jAt(aTt=YAt(aTt=qAt(aTt=KAt((dTt=fTt=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,Mn(e,"_scrollView",lTt,Pn(e)),Mn(e,"_handle",hTt,Pn(e)),Mn(e,"_direction",uTt,Pn(e)),Mn(e,"_enableAutoHide",cTt,Pn(e)),Mn(e,"_autoHideTime",_Tt,Pn(e)),e._touching=!1,e._opacity=255,e._autoHideRemainingTime=0,e}on(e,t);var r=e.prototype;return r.hide=function(){this._autoHideRemainingTime=0,this._setOpacity(0)},r.show=function(){this._autoHideRemainingTime=this._autoHideTime,this._setOpacity(this._opacity)},r.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=ATt;u.set(0,0),this._direction===mTt.HORIZONTAL?(s=i.width,a=r.width,h=n.width,o=t.x,this._convertToScrollViewSpace(u,e),l=-u.x):this._direction===mTt.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),_=ATt;this._calculatePosition(_,s,a,h,l,o,c),this._updateLength(c),this._updateHandlerPosition(_)}}}},r.setScrollView=function(t){this._scrollView=t},r.onTouchBegan=function(){this._enableAutoHide&&(this._touching=!0)},r.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}},r.onEnable=function(){var t=this.node.getComponent(im);t&&(this._opacity=t.color.a)},r.start=function(){this._enableAutoHide&&this._setOpacity(0)},r.update=function(t){this._processAutoHide(t)},r._convertToScrollViewSpace=function(t,e){var r=this._scrollView&&this._scrollView.node._uiProps.uiTransformComp,n=e._uiProps.uiTransformComp;if(r&&n){gTt.set(-n.anchorX*n.width,-n.anchorY*n.height,0),n.convertToWorldSpaceAR(gTt,yTt);var s=r.convertToNodeSpaceAR(yTt);s.x+=r.anchorX*r.width,s.y+=r.anchorY*r.height,t.set(s.x,s.y)}else t.set(i.ZERO)},r._setOpacity=function(t){if(this._handle){var e=this.node.getComponent(im);e&&(STt.set(e.color),STt.a=t,e.color=STt),(e=this._handle.getComponent(im))&&(STt.set(e.color),STt.a=t,e.color=STt)}},r._updateHandlerPosition=function(t){if(this._handle){var e=vTt;this._fixupHandlerPosition(e),this._handle.node.setPosition(t.x+e.x,t.y+e.y,e.z)}},r._fixupHandlerPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,r=e.anchorPoint,s=this.handle.node._uiProps.uiTransformComp.contentSize,a=this.handle.node.parent;n.set(gTt,-i.width*r.x,-i.height*r.y,0);var o=this.node._uiProps.uiTransformComp.convertToWorldSpaceAR(gTt,yTt),l=t;l.set(0,0,0),a._uiProps.uiTransformComp.convertToNodeSpaceAR(o,l),this.direction===mTt.HORIZONTAL?l.set(l.x,l.y+(i.height-s.height)/2,l.z):this.direction===mTt.VERTICAL&&l.set(l.x+(i.width-s.width)/2,l.y,l.z),this.handle.node.setPosition(l)},r._conditionalDisableScrollBar=function(t,e){return t.width<=e.width&&this._direction===mTt.HORIZONTAL||t.height<=e.height&&this._direction===mTt.VERTICAL},r._calculateLength=function(t,e,i,r){var n=t;return r&&(n+=20*(r>0?r:-r)),i*(e/n)},r._calculatePosition=function(t,e,i,r,n,s,a){var o=e-i;s&&(o+=Math.abs(s));var l=0;o&&(l=C(l=n/o));var h=(r-a)*l;this._direction===mTt.VERTICAL?t.set(0,h):t.set(h,0)},r._updateLength=function(t){if(this._handle){var e=this._handle.node._uiProps.uiTransformComp,i=e.contentSize,r=e.anchorPoint;r.x===bTt.x&&r.y===bTt.y||e.setAnchorPoint(bTt),this._direction===mTt.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},r._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)}},Ur(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t,this.onScroll(i.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(i.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}(ns),fTt.Direction=mTt,Dn((oTt=dTt).prototype,"handle",[JAt,ZAt,QAt],Object.getOwnPropertyDescriptor(oTt.prototype,"handle"),oTt.prototype),Dn(oTt.prototype,"direction",[$At,tTt,eTt],Object.getOwnPropertyDescriptor(oTt.prototype,"direction"),oTt.prototype),Dn(oTt.prototype,"enableAutoHide",[iTt,rTt],Object.getOwnPropertyDescriptor(oTt.prototype,"enableAutoHide"),oTt.prototype),Dn(oTt.prototype,"autoHideTime",[nTt,sTt],Object.getOwnPropertyDescriptor(oTt.prototype,"autoHideTime"),oTt.prototype),lTt=Dn(oTt.prototype,"_scrollView",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),hTt=Dn(oTt.prototype,"_handle",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),uTt=Dn(oTt.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return mTt.HORIZONTAL}}),cTt=Dn(oTt.prototype,"_enableAutoHide",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),_Tt=Dn(oTt.prototype,"_autoHideTime",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),aTt=oTt))||aTt)||aTt)||aTt)||aTt)||aTt));Er.ScrollBar=CTt;var xTt,wTt,ETt,BTt,RTt,DTt,MTt,PTt,ITt,OTt,FTt,LTt,kTt,VTt,NTt,GTt,zTt,UTt,HTt,XTt,WTt,jTt,YTt,qTt,KTt,JTt,ZTt,QTt,$Tt,tCt,eCt,iCt,rCt,nCt,sCt,aCt,oCt,lCt,hCt,uCt,cCt,_Ct,fCt,dCt,pCt,mCt,gCt,yCt,vCt=t("ViewGroup",En("cc.ViewGroup")(TTt=$n(110)(TTt=function(t){function e(){return t.apply(this,arguments)||this}return on(e,t),e}(ns))||TTt)||TTt);Er.ViewGroup=vCt;var bCt,SCt=1e-4,ACt=new n,TCt=new n,CCt=new i,xCt=new i,wCt=function(){return(new Date).getMilliseconds()},ECt={"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"}(bCt||(bCt={}));var BCt,RCt,DCt,MCt,PCt,ICt,OCt,FCt,LCt,kCt,VCt,NCt,GCt,zCt,UCt,HCt,XCt,WCt,jCt,YCt,qCt,KCt=function(e){return t({ScrollView:e,ScrollViewComponent:e}),e}((xTt=En("cc.ScrollView"),wTt=Qn(),ETt=$n(110),BTt=ts(),RTt=us(Uc),DTt=Ls(),MTt=es(),PTt=is(),ITt=Ls(),OTt=es(),FTt=is(),LTt=es(),kTt=is(),VTt=es(),NTt=is(),GTt=Wn(ks),zTt=es(),UTt=is(),HTt=es(),XTt=is(),WTt=Wn(CTt),jTt=es(),YTt=is(),qTt=es(),KTt=is(),JTt=Wn(CTt),ZTt=es(),QTt=is(),$Tt=es(),tCt=is(),eCt=Wn([Fo]),iCt=es(),rCt=is(),xTt(nCt=wTt(nCt=ETt(nCt=BTt(nCt=RTt((yCt=gCt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e=t.call.apply(t,[this].concat(r))||this,Mn(e,"bounceDuration",aCt,Pn(e)),Mn(e,"brake",oCt,Pn(e)),Mn(e,"elastic",lCt,Pn(e)),Mn(e,"inertia",hCt,Pn(e)),Mn(e,"horizontal",uCt,Pn(e)),Mn(e,"vertical",cCt,Pn(e)),Mn(e,"cancelInnerEvents",_Ct,Pn(e)),Mn(e,"scrollEvents",fCt,Pn(e)),e._autoScrolling=!1,e._scrolling=!1,Mn(e,"_content",dCt,Pn(e)),Mn(e,"_horizontalScrollBar",pCt,Pn(e)),Mn(e,"_verticalScrollBar",mCt,Pn(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 n,e._autoScrollTargetDelta=new n,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new n,e._outOfBoundaryAmount=new n,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new n,e._deltaPos=new n,e}on(e,t);var r=e.prototype;return r.scrollToBottom=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r,!0)},r.scrollToTop=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToLeft=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToRight=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToTopLeft=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToTopRight=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToBottomRight=function(t,e){void 0===e&&(e=!0);var r=this._calculateMovePercentDelta({anchor:new i(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(r,t,!1!==e):this._moveContent(r)},r.scrollToOffset=function(t,e,r){void 0===r&&(r=!0);var n=this.getMaxScrollOffset(),s=new i(0,0);0===n.x?s.x=0:s.x=t.x/n.x,0===n.y?s.y=1:s.y=(n.y-t.y)/n.y,this.scrollTo(s,e,r)},r.getScrollOffset=function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return new i(e,t)},r.getMaxScrollOffset=function(){if(!this._content||!this.view)return i.ZERO;var t=this._content._uiProps.uiTransformComp.contentSize,e=t.width-this.view.width,r=t.height-this.view.height;return new i(e=e>=0?e:0,r=r>=0?r:0)},r.scrollToPercentHorizontal=function(t,e,r){var n=this._calculateMovePercentDelta({anchor:new i(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==r):this._moveContent(n)},r.scrollTo=function(t,e,r){var n=this._calculateMovePercentDelta({anchor:new i(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,r):this._moveContent(n)},r.scrollToPercentVertical=function(t,e,r){var n=this._calculateMovePercentDelta({anchor:new i(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,r):this._moveContent(n)},r.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},r.setContentPosition=function(t){this._setContentPosition(t)},r._setContentPosition=function(t){if(this._content){var e=this._getContentPosition();Math.abs(t.x-e.x)<SCt&&Math.abs(t.y-e.y)<SCt||(this._content.setPosition(t),this._outOfBoundaryAmountDirty=!0)}},r.getContentPosition=function(){return this._getContentPosition()},r._getContentPosition=function(){return this._content?(this._contentPos.set(this._content.position),this._contentPos):n.ZERO.clone()},r.isScrolling=function(){return this._scrolling},r.isAutoScrolling=function(){return this._autoScrolling},r.getScrollEndedEventTiming=function(){return SCt},r.start=function(){this._calculateBoundary(),this._content&&Kr.once(Or.EVENT_BEFORE_DRAW,this._adjustContentOutOfBoundary,this)},r.onEnable=function(){this._registerEvent(),this._content&&(this._content.on(Zn.SIZE_CHANGED,this._calculateBoundary,this),this._content.on(Zn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.on(Zn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.on(Zn.SIZE_CHANGED,this._calculateBoundary,this))),this._calculateBoundary(),this._updateScrollBarState()},r.update=function(t){this._autoScrolling&&this._processAutoScrolling(t)},r.onDisable=function(){this._unregisterEvent(),this._content&&(this._content.off(Zn.SIZE_CHANGED,this._calculateBoundary,this),this._content.off(Zn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.off(Zn.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.off(Zn.SIZE_CHANGED,this._calculateBoundary,this))),this._hideScrollBar(),this.stopAutoScroll()},r._registerEvent=function(){this.node.on(Zn.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(Zn.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(Zn.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(Zn.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(Zn.MOUSE_WHEEL,this._onMouseWheel,this,!0)},r._unregisterEvent=function(){this.node.off(Zn.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(Zn.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(Zn.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(Zn.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(Zn.MOUSE_WHEEL,this._onMouseWheel,this,!0)},r._onMouseWheel=function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=new n,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)}},r._onTouchBegan=function(t,e){this.enabledInHierarchy&&this._content&&(this._hasNestedViewGroup(t,e)||(this._handlePressLogic(),this._touchMoved=!1,this._stopPropagationIfTargetIsMe(t)))},r._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(CCt);if(r.subtract(i.getUIStartLocation(xCt)),r.length()>7&&!this._touchMoved&&t.target!==this.node){var n=new Xo(t.getTouches(),t.bubbles,Wo.TOUCH_CANCEL);n.touch=t.touch,n.simulate=!0,t.target.dispatchEvent(n),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},r._onTouchEnded=function(t,e){if(this.enabledInHierarchy&&this._content&&t&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent(bCt.TOUCH_UP);var i=t.touch;this._handleReleaseLogic(i),this._touchMoved?t.propagationStopped=!0:this._stopPropagationIfTargetIsMe(t)}},r._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)}},r._calculateBoundary=function(){if(this._content&&this.view){var t=this._content.getComponent(XAt);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)}},r._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==jo.CAPTURING_PHASE)return!1;if(e)for(var i,r=hn(e);!(i=r()).done;){var n=i.value;if(this.node===n)return!(!t.target||!t.target.getComponent(vCt));if(n.getComponent(vCt))return!0}return!1},r._startInertiaScroll=function(t){var e=new n(t);e.multiplyScalar(.7),this._startAttenuatingAutoScroll(e,t)},r._calculateAttenuatedFactor=function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},r._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)},r._calculateAutoScrollTimeByInitialSpeed=function(t){return Math.sqrt(Math.sqrt(t/5))},r._startAutoScroll=function(t,e,i){void 0===i&&(i=!1);var r=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=r,this._autoScrollAttenuate=i,n.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(n.ZERO,SCt)||(this._autoScrollCurrentlyOutOfBoundary=!0)},r._calculateTouchMoveVelocity=function(){var t=new n,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(n.ZERO);else{var i=new n;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},r._flattenVectorByDirection=function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},r._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);ACt.set(this._getContentPosition()),ACt.add(i),ACt.set(Math.round(1e4*ACt.x)*SCt,Math.round(1e4*ACt.y)*SCt,ACt.z),this._setContentPosition(ACt);var r=this._getHowMuchOutOfBoundary();CCt.set(r.x,r.y),this._updateScrollBar(CCt),this.elastic&&e&&this._startBounceBackIfNeeded()},r._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.x-e.anchorX*e.width},r._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+t.width},r._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+t.height},r._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.y-e.anchorY*e.height},r._getHowMuchOutOfBoundary=function(t){if((t=t||new n).equals(n.ZERO,SCt)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new n,i=this._getContentLeftBoundary(),r=this._getContentRightBoundary();i+t.x>this._leftBoundary?e.x=this._leftBoundary-(i+t.x):r+t.x<this._rightBoundary&&(e.x=this._rightBoundary-(r+t.x));var s=this._getContentTopBoundary(),a=this._getContentBottomBoundary();return s+t.y<this._topBoundary?e.y=this._topBoundary-(s+t.y):a+t.y>this._bottomBoundary&&(e.y=this._bottomBoundary-(a+t.y)),t.equals(n.ZERO,SCt)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),this._clampDelta(e),e},r._updateScrollBar=function(t){this._horizontalScrollBar&&this._horizontalScrollBar.onScroll(t),this.verticalScrollBar&&this.verticalScrollBar.onScroll(t)},r._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar.onTouchBegan()},r._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar.onTouchEnded()},r._dispatchEvent=function(t){if(t===bCt.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===bCt.SCROLL_TO_TOP||t===bCt.SCROLL_TO_BOTTOM||t===bCt.SCROLL_TO_LEFT||t===bCt.SCROLL_TO_RIGHT){var e=1<<ECt[t];if(this._scrollEventEmitMask&e)return;this._scrollEventEmitMask|=e}Fo.emitEvents(this.scrollEvents,this,ECt[t]),this.node.emit(t,this)},r._adjustContentOutOfBoundary=function(){if(this._content&&(this._outOfBoundaryAmountDirty=!0,this._isOutOfBoundary())){var t=this._getHowMuchOutOfBoundary();ACt.set(this._getContentPosition()),ACt.add(t),this._content.setPosition(ACt),this._updateScrollBar(i.ZERO)}},r._hideScrollBar=function(){this._horizontalScrollBar&&this._horizontalScrollBar.hide(),this._verticalScrollBar&&this._verticalScrollBar.hide()},r._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())}},r._stopPropagationIfTargetIsMe=function(t){t.eventPhase===jo.AT_TARGET&&t.target===this.node&&(t.propagationStopped=!0)},r._processDeltaMove=function(t){this._scrollChildren(t),this._gatherTouchMove(t)},r._handleMoveLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._processDeltaMove(this._deltaPos)},r._handleReleaseLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._gatherTouchMove(this._deltaPos),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(bCt.SCROLL_ENDED))},r._getLocalAxisAlignDelta=function(t,e){var i=this.node._uiProps.uiTransformComp,r=new n;i&&(e.getUILocation(CCt),e.getUIPreviousLocation(xCt),ACt.set(CCt.x,CCt.y,0),TCt.set(xCt.x,xCt.y,0),i.convertToNodeSpaceAR(ACt,ACt),i.convertToNodeSpaceAR(TCt,TCt),n.subtract(r,ACt,TCt)),t.set(r)},r._scrollChildren=function(t){this._clampDelta(t);var e,i=t;this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i.add(e));var r="",s="";if(this._content){var a=this._content._uiProps.uiTransformComp,o=a.anchorX,l=a.anchorY,h=a.width,u=a.height,c=this._content.position||n.ZERO;this.vertical&&(i.y>0?c.y-l*u+i.y>=this._bottomBoundary&&(r=bCt.SCROLL_TO_BOTTOM):i.y<0&&c.y-l*u+u+i.y<=this._topBoundary&&(r=bCt.SCROLL_TO_TOP)),this.horizontal&&(i.x<0?c.x-o*h+h+i.x<=this._rightBoundary&&(s=bCt.SCROLL_TO_RIGHT):i.x>0&&c.x-o*h+i.x>=this._leftBoundary&&(s=bCt.SCROLL_TO_LEFT))}this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(bCt.SCROLL_BEGAN)),this._dispatchEvent(bCt.SCROLLING)),""!==r&&this._dispatchEvent(r),""!==s&&this._dispatchEvent(s)},r._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(bCt.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=wCt(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},r._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)}},r._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=wCt();this._touchMoveTimeDeltas.push((i-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=i},r._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(this._clampDelta(t),t.equals(n.ZERO,SCt))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(bCt.BOUNCE_TOP),t.y<0&&this._dispatchEvent(bCt.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(bCt.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(bCt.BOUNCE_LEFT),this._isBouncing=!0),!0},r._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(ACt,SCt)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},r._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(n.ZERO,SCt)},r._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,n.copy(this._autoScrollBrakingStartPosition,this._getContentPosition()),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},r._processAutoScrolling=function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var r,s=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(r=s,s=(r-=1)*r*r*r*r+1);var a=this._autoScrollTargetDelta.clone();a.multiplyScalar(s);var o=this._autoScrollStartPosition.clone();o.add(a);var l=Math.abs(s-1)<=SCt;if(Math.abs(s-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(bCt.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var h=o.clone();h.subtract(this._autoScrollBrakingStartPosition),e&&h.multiplyScalar(i),o.set(this._autoScrollBrakingStartPosition),o.add(h)}else{var u=o.clone();u.subtract(this.getContentPosition());var c=this._getHowMuchOutOfBoundary(u);c.equals(n.ZERO,SCt)||(o.add(c),l=!0)}l&&(this._autoScrolling=!1);var _=o.clone();_.subtract(this._getContentPosition()),this._clampDelta(_),this._moveContent(_,l),this._dispatchEvent(bCt.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(bCt.SCROLL_ENDED))},r._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(n.ZERO,SCt))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(bCt.SCROLL_ENDED),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(bCt.SCROLL_ENDED),this._stopMouseWheel=!1)},r._calculateMovePercentDelta=function(t){var e=t.anchor,r=t.applyToHorizontal,s=t.applyToVertical;this._calculateBoundary(),e.clampf(i.ZERO,i.ONE);var a=this._getContentBottomBoundary()-this._bottomBoundary;a=-a;var o=this._getContentLeftBoundary()-this._leftBoundary;o=-o;var l=new n;if(this._content&&this.view){var h=0,u=this._content._uiProps.uiTransformComp.contentSize,c=this.view.contentSize;r&&(h=u.width-c.width,l.x=o-h*e.x),s&&(h=u.height-c.height,l.y=a-h*e.y)}return l},r._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new n,r=0,s=this._getContentLeftBoundary()-this._leftBoundary;if(s=-s,this._content){var a=this._content._uiProps.uiTransformComp.contentSize;a.height<t.height&&(r=a.height-t.height,i.y=e-r),a.width<t.width&&(r=a.width-t.width,i.x=s)}this._updateScrollBarState(),this._moveContent(i),this._adjustContentOutOfBoundary()},r._scaleChanged=function(t){t===Ws.SCALE&&this._calculateBoundary()},Ur(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()):Qs(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(i.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(i.ZERO)))}},{key:"view",get:function(){var t=this._content&&this._content.parent;return t?t._uiProps.uiTransformComp:null}}]),e}(vCt),gCt.EventType=bCt,aCt=Dn((sCt=yCt).prototype,"bounceDuration",[On,DTt,MTt,PTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oCt=Dn(sCt.prototype,"brake",[On,ITt,OTt,FTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),lCt=Dn(sCt.prototype,"elastic",[On,LTt,kTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),hCt=Dn(sCt.prototype,"inertia",[On,VTt,NTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(sCt.prototype,"content",[GTt,zTt,UTt],Object.getOwnPropertyDescriptor(sCt.prototype,"content"),sCt.prototype),uCt=Dn(sCt.prototype,"horizontal",[On,HTt,XTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(sCt.prototype,"horizontalScrollBar",[WTt,jTt,YTt],Object.getOwnPropertyDescriptor(sCt.prototype,"horizontalScrollBar"),sCt.prototype),cCt=Dn(sCt.prototype,"vertical",[On,qTt,KTt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(sCt.prototype,"verticalScrollBar",[JTt,ZTt,QTt],Object.getOwnPropertyDescriptor(sCt.prototype,"verticalScrollBar"),sCt.prototype),_Ct=Dn(sCt.prototype,"cancelInnerEvents",[On,$Tt,tCt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),fCt=Dn(sCt.prototype,"scrollEvents",[eCt,On,iCt,rCt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),dCt=Dn(sCt.prototype,"_content",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pCt=Dn(sCt.prototype,"_horizontalScrollBar",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),mCt=Dn(sCt.prototype,"_verticalScrollBar",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nCt=sCt))||nCt)||nCt)||nCt)||nCt)||nCt));Er.ScrollView=KCt;var JCt,ZCt=new n;!function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(JCt||(JCt={})),ss(JCt);var QCt,$Ct,txt,ext,ixt,rxt,nxt,sxt,axt,oxt,lxt,hxt,uxt,cxt,_xt,fxt,dxt,pxt,mxt,gxt,yxt=function(e){return t({Slider:e,SliderComponent:e}),e}((BCt=En("cc.Slider"),RCt=Qn(),DCt=$n(110),MCt=ts(),PCt=us(Uc),ICt=Wn(im),OCt=is(),FCt=Wn(JCt),LCt=is(),kCt=Ls(),VCt=is(),NCt=Wn([Fo]),GCt=is(),BCt(zCt=RCt(zCt=DCt(zCt=MCt(zCt=PCt((qCt=YCt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e=t.call.apply(t,[this].concat(r))||this,Mn(e,"slideEvents",HCt,Pn(e)),Mn(e,"_handle",XCt,Pn(e)),Mn(e,"_direction",WCt,Pn(e)),Mn(e,"_progress",jCt,Pn(e)),e._offset=new n,e._dragging=!1,e._touchHandle=!1,e._handleLocalPos=new n,e._touchPos=new n,e}on(e,t);var i=e.prototype;return i.__preload=function(){this._updateHandlePosition()},i.onEnable=function(){this._updateHandlePosition(),this.node.on(Zn.TOUCH_START,this._onTouchBegan,this),this.node.on(Zn.TOUCH_MOVE,this._onTouchMoved,this),this.node.on(Zn.TOUCH_END,this._onTouchEnded,this),this.node.on(Zn.TOUCH_CANCEL,this._onTouchCancelled,this),this._handle&&this._handle.isValid&&(this._handle.node.on(Zn.TOUCH_START,this._onHandleDragStart,this),this._handle.node.on(Zn.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.on(Zn.TOUCH_END,this._onTouchEnded,this))},i.onDisable=function(){this.node.off(Zn.TOUCH_START,this._onTouchBegan,this),this.node.off(Zn.TOUCH_MOVE,this._onTouchMoved,this),this.node.off(Zn.TOUCH_END,this._onTouchEnded,this),this.node.off(Zn.TOUCH_CANCEL,this._onTouchCancelled,this),this._handle&&this._handle.isValid&&(this._handle.node.off(Zn.TOUCH_START,this._onHandleDragStart,this),this._handle.node.off(Zn.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.off(Zn.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();n.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 n,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(){Fo.emitEvents(this.slideEvents,this),this.node.emit("slide",this)},i._updateProgress=function(t){if(this._handle&&t){var e=t.getUILocation();n.set(this._touchPos,e.x,e.y,0);var i=this.node._uiProps.uiTransformComp,r=i.convertToNodeSpaceAR(this._touchPos,ZCt);this.direction===JCt.Horizontal?this.progress=C(.5+(r.x-this._offset.x)/i.width):this.progress=C(.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===JCt.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===JCt.Horizontal?this._handle.node.setPosition(i.x,0,i.z):this._handle.node.setPosition(0,i.y,i.z),this._updateHandlePosition()}},Ur(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}(ns),YCt.Direction=JCt,Dn((UCt=qCt).prototype,"handle",[ICt,OCt],Object.getOwnPropertyDescriptor(UCt.prototype,"handle"),UCt.prototype),Dn(UCt.prototype,"direction",[FCt,LCt],Object.getOwnPropertyDescriptor(UCt.prototype,"direction"),UCt.prototype),Dn(UCt.prototype,"progress",[Ns,kCt,VCt],Object.getOwnPropertyDescriptor(UCt.prototype,"progress"),UCt.prototype),HCt=Dn(UCt.prototype,"slideEvents",[NCt,On,GCt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),XCt=Dn(UCt.prototype,"_handle",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),WCt=Dn(UCt.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return JCt.Horizontal}}),jCt=Dn(UCt.prototype,"_progress",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),zCt=UCt))||zCt)||zCt)||zCt)||zCt)||zCt));function vxt(){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))}Er.Slider=yxt,function(t){t.TOGGLE="toggle"}(gxt||(gxt={}));var bxt,Sxt,Axt,Txt,Cxt,xxt,wxt,Ext,Bxt,Rxt,Dxt,Mxt,Pxt=function(e){return t({Toggle:e,ToggleComponent:e}),e}((QCt=En("cc.Toggle"),$Ct=Qn(),txt=$n(110),ext=ts(),ixt=us(Uc),rxt=es(),nxt=is(),sxt=Wn(im),axt=es(),oxt=is(),lxt=Wn([Fo]),hxt=is(),QCt(uxt=$Ct(uxt=txt(uxt=ext(uxt=ixt((mxt=pxt=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,Mn(e,"checkEvents",_xt,Pn(e)),Mn(e,"_isChecked",fxt,Pn(e)),Mn(e,"_checkMark",dxt,Pn(e)),e}on(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&&Fo.emitEvents(this.checkEvents,this)},Ur(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 Er.Node.isNode(t)?t.getComponent("cc.ToggleContainer"):null}}]),e}(Yvt),pxt.EventType=vxt(gxt,Wvt),Dn((cxt=mxt).prototype,"isChecked",[rxt,nxt],Object.getOwnPropertyDescriptor(cxt.prototype,"isChecked"),cxt.prototype),Dn(cxt.prototype,"checkMark",[sxt,axt,oxt],Object.getOwnPropertyDescriptor(cxt.prototype,"checkMark"),cxt.prototype),_xt=Dn(cxt.prototype,"checkEvents",[lxt,On,hxt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),fxt=Dn(cxt.prototype,"_isChecked",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),dxt=Dn(cxt.prototype,"_checkMark",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),uxt=cxt))||uxt)||uxt)||uxt)||uxt)||uxt));Er.Toggle=Pxt;var Ixt,Oxt,Fxt,Lxt,kxt,Vxt,Nxt,Gxt,zxt,Uxt,Hxt,Xxt,Wxt,jxt,Yxt,qxt,Kxt,Jxt,Zxt,Qxt,$xt,twt,ewt,iwt,rwt,nwt,swt,awt,owt,lwt,hwt,uwt,cwt,_wt,fwt,dwt,pwt,mwt,gwt,ywt,vwt,bwt,Swt,Awt,Twt,Cwt=function(e){return t({ToggleContainer:e,ToggleContainerComponent:e}),e}((bxt=En("cc.ToggleContainer"),Sxt=Qn(),Axt=$n(110),Txt=ts(),Cxt=is(),xxt=Wn([Fo]),wxt=is(),bxt(Ext=Sxt(Ext=Axt(Ext=Txt(Ext=Jn((Mxt=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,Mn(e,"_allowSwitchOff",Rxt,Pn(e)),Mn(e,"checkEvents",Dxt,Pn(e)),e}on(e,t);var i=e.prototype;return i.onEnable=function(){this.ensureValidState(),this.node.on(Zn.CHILD_ADDED,this.ensureValidState,this),this.node.on(Zn.CHILD_REMOVED,this.ensureValidState,this)},i.onDisable=function(){this.node.off(Zn.CHILD_ADDED,this.ensureValidState,this),this.node.off(Zn.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&&Er.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)}},Ur(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}(ns),Rxt=Dn((Bxt=Mxt).prototype,"_allowSwitchOff",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dn(Bxt.prototype,"allowSwitchOff",[Cxt],Object.getOwnPropertyDescriptor(Bxt.prototype,"allowSwitchOff"),Bxt.prototype),Dxt=Dn(Bxt.prototype,"checkEvents",[xxt,On,wxt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ext=Bxt))||Ext)||Ext)||Ext)||Ext)||Ext));Er.ToggleContainer=Cwt;var xwt,wwt,Ewt=new i;function Bwt(t){return t instanceof Yo?rs:t._uiProps.uiTransformComp?t._uiProps.uiTransformComp.contentSize:d.ZERO}function Rwt(t,e,i,r){t.parent?Ewt.set(t.parent.getScale().x,t.parent.getScale().y):Ewt.set(0,0);for(var n=Ewt.x,s=Ewt.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?Ewt.set(l.getScale().x,l.getScale().y):Ewt.set(0,0);var u=Ewt.x,c=Ewt.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"}(xwt||(xwt={})),ss(xwt),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"}(wwt||(wwt={}));var Dwt,Mwt,Pwt,Iwt,Owt,Fwt,Lwt,kwt,Vwt,Nwt,Gwt,zwt,Uwt,Hwt,Xwt,Wwt,jwt,Ywt,qwt,Kwt=wwt.TOP|wwt.BOT,Jwt=wwt.LEFT|wwt.RIGHT,Zwt=function(e){return t({Widget:e,WidgetComponent:e}),e}((Ixt=En("cc.Widget"),Oxt=Qn(),Fxt=$n(110),Lxt=ts(),kxt=us(Uc),Vxt=Wn(ks),Nxt=is(),Gxt=is(),zxt=is(),Uxt=is(),Hxt=is(),Xxt=is(),Wxt=is(),jxt=cs(),Yxt=cs(),qxt=is(),Kxt=is(),Jxt=is(),Zxt=is(),Qxt=is(),$xt=is(),twt=Wn(xwt),ewt=is(),Ixt(iwt=Oxt(iwt=Fxt(iwt=Lxt(iwt=kxt(iwt=Jn((Twt=Awt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return(e=t.call.apply(t,[this].concat(r))||this)._lastPos=new n,e._lastSize=new d,e._dirty=!0,e._hadAlignOnce=!1,Mn(e,"_alignFlags",nwt,Pn(e)),Mn(e,"_target",swt,Pn(e)),Mn(e,"_left",awt,Pn(e)),Mn(e,"_right",owt,Pn(e)),Mn(e,"_top",lwt,Pn(e)),Mn(e,"_bottom",hwt,Pn(e)),Mn(e,"_horizontalCenter",uwt,Pn(e)),Mn(e,"_verticalCenter",cwt,Pn(e)),Mn(e,"_isAbsLeft",_wt,Pn(e)),Mn(e,"_isAbsRight",fwt,Pn(e)),Mn(e,"_isAbsTop",dwt,Pn(e)),Mn(e,"_isAbsBottom",pwt,Pn(e)),Mn(e,"_isAbsHorizontalCenter",mwt,Pn(e)),Mn(e,"_isAbsVerticalCenter",gwt,Pn(e)),Mn(e,"_originalWidth",ywt,Pn(e)),Mn(e,"_originalHeight",vwt,Pn(e)),Mn(e,"_alignMode",bwt,Pn(e)),Mn(e,"_lockFlags",Swt,Pn(e)),e}on(e,t);var i=e.prototype;return i.updateAlignment=function(){Er._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),Er._widgetManager.add(this),this._hadAlignOnce=!1,this._registerEvent(),this._registerTargetEvents()},i.onDisable=function(){Er._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(Zn.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.on(Zn.SIZE_CHANGED,this._setDirtyByMode,this),this.node.on(Zn.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this),this.node.on(Zn.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._unregisterEvent=function(){this.node.off(Zn.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.off(Zn.SIZE_CHANGED,this._setDirtyByMode,this),this.node.off(Zn.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this)},i._removeParentEvent=function(){this.node.off(Zn.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:rs;this.isAlignLeft&&t===wwt.LEFT?this._left=e?this._left*n.width:this._left/n.width:this.isAlignRight&&t===wwt.RIGHT?this._right=e?this._right*n.width:this._right/n.width:this.isAlignHorizontalCenter&&t===wwt.CENTER?this._horizontalCenter=e?this._horizontalCenter*n.width:this._horizontalCenter/n.width:this.isAlignTop&&t===wwt.TOP?this._top=e?this._top*n.height:this._top/n.height:this.isAlignBottom&&t===wwt.BOT?this._bottom=e?this._bottom*n.height:this._bottom/n.height:this.isAbsoluteVerticalCenter&&t===wwt.MID&&(this._verticalCenter=this._verticalCenter/n.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(Uc)&&(t.on(Zn.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(Zn.SIZE_CHANGED,this._setDirtyByMode,this),t.on(Zn.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(Zn.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(Zn.SIZE_CHANGED,this._setDirtyByMode,this),t.off(Zn.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(Zn.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(Zn.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){(this.alignMode===xwt.ALWAYS||uo)&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&Jwt)>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)},Ur(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&wwt.TOP)>0},set:function(t){this._setAlign(wwt.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&wwt.BOT)>0},set:function(t){this._setAlign(wwt.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&wwt.LEFT)>0},set:function(t){this._setAlign(wwt.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&wwt.RIGHT)>0},set:function(t){this._setAlign(wwt.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&wwt.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=wwt.MID):this._alignFlags&=~wwt.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&wwt.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=wwt.CENTER):this._alignFlags&=~wwt.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&Jwt)===Jwt}},{key:"isStretchHeight",get:function(){return(this._alignFlags&Kwt)===Kwt}},{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(wwt.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(wwt.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(wwt.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(wwt.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(wwt.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(wwt.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}(ns),Awt.AlignMode=xwt,Dn((rwt=Twt).prototype,"target",[Vxt,Nxt],Object.getOwnPropertyDescriptor(rwt.prototype,"target"),rwt.prototype),Dn(rwt.prototype,"isAlignTop",[Gxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignTop"),rwt.prototype),Dn(rwt.prototype,"isAlignBottom",[zxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignBottom"),rwt.prototype),Dn(rwt.prototype,"isAlignLeft",[Uxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignLeft"),rwt.prototype),Dn(rwt.prototype,"isAlignRight",[Hxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignRight"),rwt.prototype),Dn(rwt.prototype,"isAlignVerticalCenter",[Xxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignVerticalCenter"),rwt.prototype),Dn(rwt.prototype,"isAlignHorizontalCenter",[Wxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isAlignHorizontalCenter"),rwt.prototype),Dn(rwt.prototype,"isStretchWidth",[jxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isStretchWidth"),rwt.prototype),Dn(rwt.prototype,"isStretchHeight",[Yxt],Object.getOwnPropertyDescriptor(rwt.prototype,"isStretchHeight"),rwt.prototype),Dn(rwt.prototype,"top",[qxt],Object.getOwnPropertyDescriptor(rwt.prototype,"top"),rwt.prototype),Dn(rwt.prototype,"editorTop",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorTop"),rwt.prototype),Dn(rwt.prototype,"bottom",[Kxt],Object.getOwnPropertyDescriptor(rwt.prototype,"bottom"),rwt.prototype),Dn(rwt.prototype,"editorBottom",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorBottom"),rwt.prototype),Dn(rwt.prototype,"left",[Jxt],Object.getOwnPropertyDescriptor(rwt.prototype,"left"),rwt.prototype),Dn(rwt.prototype,"editorLeft",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorLeft"),rwt.prototype),Dn(rwt.prototype,"right",[Zxt],Object.getOwnPropertyDescriptor(rwt.prototype,"right"),rwt.prototype),Dn(rwt.prototype,"editorRight",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorRight"),rwt.prototype),Dn(rwt.prototype,"horizontalCenter",[Qxt],Object.getOwnPropertyDescriptor(rwt.prototype,"horizontalCenter"),rwt.prototype),Dn(rwt.prototype,"editorHorizontalCenter",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorHorizontalCenter"),rwt.prototype),Dn(rwt.prototype,"verticalCenter",[$xt],Object.getOwnPropertyDescriptor(rwt.prototype,"verticalCenter"),rwt.prototype),Dn(rwt.prototype,"editorVerticalCenter",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"editorVerticalCenter"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteTop",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteTop"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteBottom",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteBottom"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteLeft",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteLeft"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteRight",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteRight"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteHorizontalCenter",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteHorizontalCenter"),rwt.prototype),Dn(rwt.prototype,"isAbsoluteVerticalCenter",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"isAbsoluteVerticalCenter"),rwt.prototype),Dn(rwt.prototype,"alignMode",[twt,ewt],Object.getOwnPropertyDescriptor(rwt.prototype,"alignMode"),rwt.prototype),Dn(rwt.prototype,"alignFlags",[Un],Object.getOwnPropertyDescriptor(rwt.prototype,"alignFlags"),rwt.prototype),nwt=Dn(rwt.prototype,"_alignFlags",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),swt=Dn(rwt.prototype,"_target",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),awt=Dn(rwt.prototype,"_left",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),owt=Dn(rwt.prototype,"_right",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),lwt=Dn(rwt.prototype,"_top",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),hwt=Dn(rwt.prototype,"_bottom",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),uwt=Dn(rwt.prototype,"_horizontalCenter",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),cwt=Dn(rwt.prototype,"_verticalCenter",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_wt=Dn(rwt.prototype,"_isAbsLeft",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),fwt=Dn(rwt.prototype,"_isAbsRight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),dwt=Dn(rwt.prototype,"_isAbsTop",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),pwt=Dn(rwt.prototype,"_isAbsBottom",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),mwt=Dn(rwt.prototype,"_isAbsHorizontalCenter",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),gwt=Dn(rwt.prototype,"_isAbsVerticalCenter",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),ywt=Dn(rwt.prototype,"_originalWidth",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),vwt=Dn(rwt.prototype,"_originalHeight",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),bwt=Dn(rwt.prototype,"_alignMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return xwt.ON_WINDOW_RESIZE}}),Swt=Dn(rwt.prototype,"_lockFlags",[On,qo],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),iwt=rwt))||iwt)||iwt)||iwt)||iwt)||iwt)||iwt));Er.internal.computeInverseTransForTarget=Rwt,Er.internal.getReadonlyNodeSize=Bwt,Er.Widget=Zwt;var Qwt,$wt=new y;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(Qwt||(Qwt={})),ss(Qwt);var tEt,eEt,iEt,rEt,nEt,sEt,aEt,oEt,lEt,hEt,uEt,cEt,_Et,fEt,dEt,pEt,mEt,gEt,yEt,vEt,bEt,SEt,AEt,TEt,CEt,xEt,wEt,EEt,BEt,REt,DEt,MEt,PEt,IEt,OEt,FEt,LEt,kEt,VEt,NEt,GEt,zEt,UEt,HEt=function(e){return t({PageViewIndicator:e,PageViewIndicatorComponent:e}),e}((Dwt=En("cc.PageViewIndicator"),Mwt=Qn(),Pwt=$n(110),Iwt=ts(),Owt=Wn(Bh),Fwt=is(),Lwt=Wn(Qwt),kwt=is(),Vwt=Wn(d),Nwt=is(),Gwt=is(),Dwt(zwt=Mwt(zwt=Pwt(zwt=Iwt((qwt=Ywt=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,Mn(e,"spacing",Hwt,Pn(e)),Mn(e,"_spriteFrame",Xwt,Pn(e)),Mn(e,"_direction",Wwt,Pn(e)),Mn(e,"_cellSize",jwt,Pn(e)),e._layout=null,e._pageView=null,e._indicators=[],e}on(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(XAt),this._layout||(this._layout=this.addComponent(XAt));var t=this._layout;this.direction===Qwt.HORIZONTAL?(t.type=XAt.Type.HORIZONTAL,t.spacingX=this.spacing):this.direction===Qwt.VERTICAL&&(t.type=XAt.Type.VERTICAL,t.spacingY=this.spacing),t.resizeMode=XAt.ResizeMode.CONTAINER},i._createIndicator=function(){var t=new ks;t.layer=this.node.layer;var e=t.addComponent(im);return e.spriteFrame=this.spriteFrame,e.sizeMode=im.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;$wt.set(n.color),$wt.a=127.5,n.color=$wt}}if(t[e]._uiProps.uiComp){var s=t[e]._uiProps.uiComp;$wt.set(s.color),$wt.a=255,s.color=$wt}}}},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()}}},Ur(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}(ns),Ywt.Direction=Qwt,Dn((Uwt=qwt).prototype,"spriteFrame",[Owt,Fwt],Object.getOwnPropertyDescriptor(Uwt.prototype,"spriteFrame"),Uwt.prototype),Dn(Uwt.prototype,"direction",[Lwt,kwt],Object.getOwnPropertyDescriptor(Uwt.prototype,"direction"),Uwt.prototype),Dn(Uwt.prototype,"cellSize",[Vwt,Nwt],Object.getOwnPropertyDescriptor(Uwt.prototype,"cellSize"),Uwt.prototype),Hwt=Dn(Uwt.prototype,"spacing",[On,Gwt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Xwt=Dn(Uwt.prototype,"_spriteFrame",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Wwt=Dn(Uwt.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Qwt.HORIZONTAL}}),jwt=Dn(Uwt.prototype,"_cellSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new d(20,20)}}),zwt=Uwt))||zwt)||zwt)||zwt)||zwt));Er.PageViewIndicator=HEt;var XEt,WEt,jEt,YEt=new i;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(XEt||(XEt={})),ss(XEt),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(WEt||(WEt={})),ss(WEt),function(t){t.PAGE_TURNING="page-turning"}(jEt||(jEt={}));var qEt=function(e){return t({PageView:e,PageViewComponent:e}),e}((tEt=En("cc.PageView"),eEt=Qn(),iEt=$n(110),rEt=ts(),nEt=Wn(XEt),sEt=is(),aEt=Wn(WEt),oEt=is(),lEt=Ls(),hEt=is(),uEt=Ls(),cEt=is(),_Et=Wn(HEt),fEt=is(),dEt=is(),pEt=Wn(CTt),mEt=cs(),gEt=Wn(CTt),yEt=cs(),vEt=cs(),bEt=cs(),SEt=cs(),AEt=Wn([Fo]),TEt=cs(),CEt=is(),xEt=Wn([Fo]),wEt=is(),tEt(EEt=eEt(EEt=iEt(EEt=rEt((UEt=zEt=function(t){function e(){for(var e,r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return e=t.call.apply(t,[this].concat(s))||this,Mn(e,"autoPageTurningThreshold",REt,Pn(e)),Mn(e,"horizontal",DEt,Pn(e)),Mn(e,"vertical",MEt,Pn(e)),Mn(e,"cancelInnerEvents",PEt,Pn(e)),Mn(e,"scrollEvents",IEt,Pn(e)),Mn(e,"pageTurningSpeed",OEt,Pn(e)),Mn(e,"pageEvents",FEt,Pn(e)),Mn(e,"_sizeMode",LEt,Pn(e)),Mn(e,"_direction",kEt,Pn(e)),Mn(e,"_scrollThreshold",VEt,Pn(e)),Mn(e,"_pageTurningEventTiming",NEt,Pn(e)),Mn(e,"_indicator",GEt,Pn(e)),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=new n,e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=new i,e._touchEndPosition=new i,e}on(e,t);var r=e.prototype;return r.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(Zn.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.on(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},r.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(Zn.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.off(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},r.onLoad=function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},r.getCurrentPageIndex=function(){return this._curPageIdx},r.setCurrentPageIndex=function(t){this.scrollToPage(t,1)},r.getPages=function(){return this._pages},r.addPage=function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(t._uiProps.uiTransformComp?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):Qs(4301))},r.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 Qs(4301);this._pages.splice(e,0,t),this.content.insertChild(t,e),this._updatePageView()}},r.removePage=function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):Rn(4300,t.name)}},r.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())}},r.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()}},r.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())},r.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},r._updatePageView=function(){if(this.content){var t=this.content.getComponent(XAt);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===WEt.Horizontal?this._scrollCenterOffsetX[r]=Math.abs(i.x+n.x):this._scrollCenterOffsetY[r]=Math.abs(i.y+n.y)}this.indicator&&this.indicator._refresh()}},r._updateAllPagesSize=function(){var t=this.view;if(this.content&&t&&this._sizeMode===XEt.Unified)for(var e=this._pages,i=t.contentSize,r=0,n=e.length;r<n;r++)e[r]._uiProps.uiTransformComp.setContentSize(i)},r._handleReleaseLogic=function(){this._autoScrollToPage(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(e.EventType.SCROLL_ENDED))},r._onTouchBegan=function(e,r){e.touch.getUILocation(YEt),i.set(this._touchBeganPosition,YEt.x,YEt.y),t.prototype._onTouchBegan.call(this,e,r)},r._onTouchMoved=function(e,i){t.prototype._onTouchMoved.call(this,e,i)},r._onTouchEnded=function(e,r){e.touch.getUILocation(YEt),i.set(this._touchEndPosition,YEt.x,YEt.y),t.prototype._onTouchEnded.call(this,e,r)},r._onTouchCancelled=function(e,r){e.touch.getUILocation(YEt),i.set(this._touchEndPosition,YEt.x,YEt.y),t.prototype._onTouchCancelled.call(this,e,r)},r._onMouseWheel=function(){},r._syncScrollDirection=function(){this.horizontal=this.direction===WEt.Horizontal,this.vertical=this.direction===WEt.Vertical},r._syncSizeMode=function(){var t=this.view;if(this.content&&t){var e=this.content.getComponent(XAt);if(e){if(this._sizeMode===XEt.Free&&this._pages.length>0){var i=this._pages[0]._uiProps.uiTransformComp,r=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===WEt.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-r.width)/2):this.direction===WEt.Vertical&&(e.paddingTop=(t.height-i.height)/2,e.paddingBottom=(t.height-r.height)/2)}e.updateLayout()}}},r._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()}},r._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,Fo.emitEvents(this.pageEvents,this,jEt.PAGE_TURNING),this.node.emit(jEt.PAGE_TURNING,this))},r._isQuicklyScrollable=function(t){if(this.direction===WEt.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===WEt.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},r._moveOffsetValue=function(t){var e=new i;if(this._sizeMode===XEt.Free)this.direction===WEt.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===WEt.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var r=this.view;if(!r)return e;this.direction===WEt.Horizontal?e.x=t*r.width:this.direction===WEt.Vertical&&(e.y=t*r.height)}return e},r._getDragDirection=function(t){return this._direction===WEt.Horizontal?0===t.x?0:t.x>0?1:-1:0===t.y?0:t.y<0?1:-1},r._isScrollable=function(t,e,i){if(this._sizeMode===XEt.Free){var r=0,n=0;if(this.direction===WEt.Horizontal)return r=this._scrollCenterOffsetX[e],n=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(r-n)*this.scrollThreshold;if(this.direction===WEt.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===WEt.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===WEt.Vertical)return Math.abs(t.y)>=s.height*this.scrollThreshold}return!1},r._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 i;i.subtract(e,this._touchBeganPosition,this._touchEndPosition);var r=this._curPageIdx,n=r+this._getDragDirection(e),s=this.pageTurningSpeed*Math.abs(r-n);if(n<this._pages.length){if(this._isScrollable(e,r,n))return void this.scrollToPage(n,s);var a=this._calculateTouchMoveVelocity();if(this._isQuicklyScrollable(a))return void this.scrollToPage(n,s)}this.scrollToPage(r,s)}},Ur(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}(KCt),zEt.SizeMode=XEt,zEt.Direction=WEt,zEt.EventType=vxt(jEt,bCt),Dn((BEt=UEt).prototype,"sizeMode",[nEt,sEt],Object.getOwnPropertyDescriptor(BEt.prototype,"sizeMode"),BEt.prototype),Dn(BEt.prototype,"direction",[aEt,oEt],Object.getOwnPropertyDescriptor(BEt.prototype,"direction"),BEt.prototype),Dn(BEt.prototype,"scrollThreshold",[Ns,lEt,hEt],Object.getOwnPropertyDescriptor(BEt.prototype,"scrollThreshold"),BEt.prototype),Dn(BEt.prototype,"pageTurningEventTiming",[Ns,uEt,cEt],Object.getOwnPropertyDescriptor(BEt.prototype,"pageTurningEventTiming"),BEt.prototype),Dn(BEt.prototype,"indicator",[_Et,fEt],Object.getOwnPropertyDescriptor(BEt.prototype,"indicator"),BEt.prototype),REt=Dn(BEt.prototype,"autoPageTurningThreshold",[On,dEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 100}}),Dn(BEt.prototype,"verticalScrollBar",[pEt,Hn,mEt],Object.getOwnPropertyDescriptor(BEt.prototype,"verticalScrollBar"),BEt.prototype),Dn(BEt.prototype,"horizontalScrollBar",[gEt,Hn,yEt],Object.getOwnPropertyDescriptor(BEt.prototype,"horizontalScrollBar"),BEt.prototype),DEt=Dn(BEt.prototype,"horizontal",[Hn,On,vEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),MEt=Dn(BEt.prototype,"vertical",[Hn,On,bEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),PEt=Dn(BEt.prototype,"cancelInnerEvents",[Hn,On,SEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),IEt=Dn(BEt.prototype,"scrollEvents",[AEt,On,Hn,TEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),OEt=Dn(BEt.prototype,"pageTurningSpeed",[On,Un,CEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),FEt=Dn(BEt.prototype,"pageEvents",[xEt,On,wEt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LEt=Dn(BEt.prototype,"_sizeMode",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return XEt.Unified}}),kEt=Dn(BEt.prototype,"_direction",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return WEt.Horizontal}}),VEt=Dn(BEt.prototype,"_scrollThreshold",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),NEt=Dn(BEt.prototype,"_pageTurningEventTiming",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),GEt=Dn(BEt.prototype,"_indicator",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),EEt=BEt))||EEt)||EEt)||EEt)||EEt));Er.PageView=qEt;var KEt=new n,JEt=new i,ZEt=new i,QEt=new i(1,1),$Et=new i,tBt=new i;function eBt(t,e){if(!e._hadAlignOnce){e.alignMode===xwt.ONCE&&(e._hadAlignOnce=!0);var i,r=e.target,s=ZEt,a=QEt;r?Rwt(t,i=r,s,a):i=t.parent;var o=Bwt(i),l=i instanceof Yo||!i.getComponent(Uc),h=l?JEt:i.getComponent(Uc).anchorPoint,u=l;t.getPosition(KEt);var c=t._uiProps.uiTransformComp,_=KEt.x,f=KEt.y,d=c.anchorPoint,p=t.getScale();if(e.alignFlags&wwt.HORIZONTAL){var m=0,g=0,y=o.width;u?(m=rs.left.x,g=rs.right.x):g=(m=-h.x*y)+y,m+=e.isAbsoluteLeft?e.left:e.left*y,g-=e.isAbsoluteRight?e.right:e.right*y,r&&(m+=s.x,m*=a.x,g+=s.x,g*=a.x);var v=0,b=d.x,S=p.x;if(S<0&&(b=1-b,S=-S),e.isStretchWidth)v=g-m,0!==S&&(c.width=v/S),_=m+b*v;else if(v=c.width*S,e.isAlignHorizontalCenter){var A=e.isAbsoluteHorizontalCenter?e.horizontalCenter:e.horizontalCenter*y,T=(.5-h.x)*o.width;r&&(A*=a.x,T+=s.x,T*=a.x),_=T+(b-.5)*v+A}else _=e.isAlignLeft?m+b*v:g+(b-1)*v;e._lastSize.width=v}if(e.alignFlags&wwt.VERTICAL){var C=0,x=0,w=o.height;u?(x=rs.bottom.y,C=rs.top.y):C=(x=-h.y*w)+w,x+=e.isAbsoluteBottom?e.bottom:e.bottom*w,C-=e.isAbsoluteTop?e.top:e.top*w,r&&(x+=s.y,x*=a.y,C+=s.y,C*=a.y);var E=0,B=d.y,R=p.y;if(R<0&&(B=1-B,R=-R),e.isStretchHeight)E=C-x,0!==R&&(c.height=E/R),f=x+B*E;else if(E=c.height*R,e.isAlignVerticalCenter){var D=e.isAbsoluteVerticalCenter?e.verticalCenter:e.verticalCenter*w,M=(.5-h.y)*o.height;r&&(D*=a.y,M+=s.y,M*=a.y),f=M+(B-.5)*E+D}else f=e.isAlignBottom?x+B*E:C+(B-1)*E;e._lastSize.height=E}t.setPosition(_,f,KEt.z),n.set(e._lastPos,_,f,KEt.z)}}function iBt(t){var e=t.getComponent(Zwt);if(e&&e.enabled){if(!Er.isValid(t,!0))return;uBt.push(e)}for(var i,r=t.children,n=hn(r);!(i=n()).done;){var s=i.value;s.active&&iBt(s)}}function rBt(){var t=Kr.getScene();if(t){cBt.isAligning=!0,cBt._nodesOrderDirty&&(uBt.length=0,iBt(t),cBt._nodesOrderDirty=!1);var e=null,i=cBt._activeWidgetsIterator;for(i.i=0;i.i<uBt.length;++i.i)(e=uBt[i.i])._dirty&&(eBt(e.node,e),e._dirty=!1);cBt.isAligning=!1}}var nBt,sBt,aBt,oBt,lBt,hBt,uBt=[],cBt=t("widgetManager",Er._widgetManager={isAligning:!1,_nodesOrderDirty:!1,_activeWidgetsIterator:new Ma.MutableForwardIterator(uBt),animationState:null,init:function(){Kr.on(Or.EVENT_AFTER_SCENE_LAUNCH,rBt),Kr.on(Or.EVENT_AFTER_UPDATE,rBt),Ko.instance.on("design-resolution-changed",this.onResized,this);var t=this.onResized.bind(this);Ko.instance.on("canvas-resize",t),No.on("orientation-change",t)},add:function(){this._nodesOrderDirty=!0},remove:function(t){this._activeWidgetsIterator.remove(t)},onResized:function(){var t=Kr.getScene();t&&this.refreshWidgetOnResized(t)},refreshWidgetOnResized:function(t){var e=ks.isNode(t)&&t.getComponent(Zwt);e&&e.enabled&&(e.alignMode===xwt.ON_WINDOW_RESIZE||e.alignMode===xwt.ALWAYS)&&e.setDirty();for(var i,r=t.children,n=hn(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=$Et;s.set(0,0);var a=tBt;if(a.set(1,1),t.target&&Rwt(r,n=t.target,s,a),!e)return;var o=n._uiProps&&n._uiProps.uiTransformComp,l=o?o.anchorPoint:JEt,h=r._uiProps.uiTransformComp,u=Bwt(n),c=h.anchorPoint,_=r.getPosition(),f=wwt,d=r.getScale(),p=0;if(e&f.LEFT){var m=-l.x*u.width;m+=s.x,m*=a.x,p=_.x-c.x*h.width*Math.abs(d.x)-m,t.isAbsoluteLeft||(p/=u.width),p/=a.x,t.left=i(t.left,p)}if(e&f.RIGHT){var g=(1-l.x)*u.width;g+=s.x,p=(g*=a.x)-(_.x+(1-c.x)*h.width*Math.abs(d.x)),t.isAbsoluteRight||(p/=u.width),p/=a.x,t.right=i(t.right,p)}if(e&f.TOP){var y=(1-l.y)*u.height;y+=s.y,p=(y*=a.y)-(_.y+(1-c.y)*h.height*Math.abs(d.y)),t.isAbsoluteTop||(p/=u.height),p/=a.y,t.top=i(t.top,p)}if(e&f.BOT){var v=-l.y*u.height;v+=s.y,v*=a.y,p=_.y-c.y*h.height*Math.abs(d.y)-v,t.isAbsoluteBottom||(p/=u.height),p/=a.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&ks.isNode(i)&&t(i);var r=e.getComponent(Zwt);r&&i&&eBt(e,r)},AlignMode:xwt,AlignFlags:wwt});Kr.on(Or.EVENT_INIT,(function(){cBt.init()}));var _Bt,fBt,dBt,pBt,mBt,gBt,yBt,vBt,bBt,SBt,ABt,TBt,CBt,xBt,wBt,EBt,BBt,RBt,DBt,MBt,PBt=function(e){return t({SafeArea:e,SafeAreaComponent:e}),e}((nBt=En("cc.SafeArea"),sBt=Qn(),aBt=$n(110),oBt=ts(),lBt=us(Zwt),nBt(hBt=sBt(hBt=aBt(hBt=Jn(hBt=oBt(hBt=lBt(hBt=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),No.on("window-resize",this.updateArea,this),No.on("orientation-change",this.updateArea,this)},i.onDisable=function(){No.off("window-resize",this.updateArea,this),No.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(Zwt),e=this.node.getComponent(Uc);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=Hs.getVisibleSize(),s=n.width,a=n.height,o=Fn.getSafeAreaRect();t.top=a-o.y-o.height,t.bottom=o.y,t.left=o.x,t.right=s-o.x-o.width,t.updateAlignment();var l=this.node.position.clone(),h=r.x-(l.x-i.x)/e.width,u=r.y-(l.y-i.y)/e.height;e.setAnchorPoint(h,u),cBt.add(t)}},e}(ns))||hBt)||hBt)||hBt)||hBt)||hBt)||hBt));Er.SafeArea=PBt;var IBt,OBt=function(e){return t({UICoordinateTracker:e,UICoordinateTrackerComponent:e}),e}((_Bt=En("cc.UICoordinateTracker"),fBt=Qn(),dBt=ts(),pBt=$n(110),mBt=Wn(ks),gBt=is(),yBt=Wn(Us),vBt=is(),bBt=is(),SBt=is(),ABt=Wn([Fo]),TBt=is(),_Bt(CBt=fBt(CBt=dBt(CBt=pBt((MBt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e=t.call.apply(t,[this].concat(r))||this,Mn(e,"syncEvents",wBt,Pn(e)),Mn(e,"_target",EBt,Pn(e)),Mn(e,"_camera",BBt,Pn(e)),Mn(e,"_useScale",RBt,Pn(e)),Mn(e,"_distance",DBt,Pn(e)),e._transformPos=new n,e._viewPos=new n,e._canMove=!0,e._lastWPos=new n,e._lastCameraPos=new n,e}on(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&&n.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);Fo.emitEvents(this.syncEvents,this._transformPos,i)}},i._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},Ur(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}(ns),Dn((xBt=MBt).prototype,"target",[mBt,gBt],Object.getOwnPropertyDescriptor(xBt.prototype,"target"),xBt.prototype),Dn(xBt.prototype,"camera",[yBt,vBt],Object.getOwnPropertyDescriptor(xBt.prototype,"camera"),xBt.prototype),Dn(xBt.prototype,"useScale",[bBt],Object.getOwnPropertyDescriptor(xBt.prototype,"useScale"),xBt.prototype),Dn(xBt.prototype,"distance",[SBt],Object.getOwnPropertyDescriptor(xBt.prototype,"distance"),xBt.prototype),wBt=Dn(xBt.prototype,"syncEvents",[ABt,On,TBt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),EBt=Dn(xBt.prototype,"_target",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),BBt=Dn(xBt.prototype,"_camera",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),RBt=Dn(xBt.prototype,"_useScale",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),DBt=Dn(xBt.prototype,"_distance",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),CBt=xBt))||CBt)||CBt)||CBt)||CBt)),FBt=[Zn.TOUCH_START,Zn.TOUCH_END,Zn.TOUCH_MOVE,Zn.MOUSE_DOWN,Zn.MOUSE_MOVE,Zn.MOUSE_UP,Zn.MOUSE_ENTER,Zn.MOUSE_LEAVE,Zn.MOUSE_WHEEL];function LBt(t){t.propagationStopped=!0}var kBt,VBt,NBt,GBt,zBt,UBt,HBt,XBt,WBt,jBt,YBt,qBt,KBt,JBt=function(e){return t({BlockInputEvents:e,BlockInputEventsComponent:e}),e}(En("cc.BlockInputEvents")(IBt=Qn()(IBt=ts()(IBt=function(t){function e(){return t.apply(this,arguments)||this}on(e,t);var i=e.prototype;return i.onEnable=function(){for(var t=0;t<FBt.length;t++)this.node.on(FBt[t],LBt,this)},i.onDisable=function(){for(var t=0;t<FBt.length;t++)this.node.off(FBt[t],LBt,this)},e}(ns))||IBt)||IBt)||IBt),ZBt=t("SubContextView",(kBt=En("cc.SubContextView"),VBt=Qn(),NBt=$n(110),GBt=us(Uc),zBt=ts(),UBt=is(),HBt=is(),kBt(XBt=VBt(XBt=NBt(XBt=GBt(XBt=zBt((qBt=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_fps",jBt,Pn(e)),e._sprite=void 0,e._imageAsset=void 0,e._texture=void 0,e._updatedTime=0,e._updateInterval=0,e._openDataContext=void 0,e._content=void 0,Mn(e,"_designResolutionSize",YBt,Pn(e)),e._content=new ks("content"),e._content.hideFlags|=Vs.Flags.DontSave|Vs.Flags.HideInHierarchy,e._sprite=null,e._imageAsset=new vn,e._openDataContext=null,e._updatedTime=performance.now(),e._texture=new fn,e}on(e,t);var i=e.prototype;return i.onLoad=function(){Fl.getOpenDataContext?(this._updateInterval=1e3/this._fps,this._openDataContext=Fl.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,e=this._designResolutionSize.width,i=this._designResolutionSize.height;t.width=e,t.height=i}},i._initContentNode=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._imageAsset;if(e.reset(t),this._texture.image=e,this._texture.create(t.width,t.height),this._sprite=this._content.getComponent(im),this._sprite||(this._sprite=this._content.addComponent(im)),this._sprite.spriteFrame)this._sprite.spriteFrame.texture=this._texture;else{var i=new Bh;i.texture=this._texture,this._sprite.spriteFrame=i}this._content.parent=this.node}},i._updateSubContextView=function(){if(this._openDataContext){var t=this.node.getComponent(Uc),e=this._content.getComponent(Uc),i=t.width/e.width,r=t.height/e.height,n=i>r?r:i;e.width*=n,e.height*=n;var s=Hs.getViewportRect(),a=e.getBoundingBoxToWorld(),o=Hs.getVisibleSize(),l=No.devicePixelRatio,h=(s.width*(a.x/o.width)+s.x)/l,u=(s.height*(a.y/o.height)+s.y)/l,c=s.width*(a.width/o.width)/l,_=s.height*(a.height/o.height)/l;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:h,y:u,width:c,height:_})}},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._texture.create(e.width,e.height),this._texture.uploadData(e)}},i._registerNodeEvent=function(){this.node.on(Zn.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(Zn.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(Zn.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(Zn.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(Zn.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(Zn.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())},i.onDestroy=function(){this._content.destroy(),this._texture.destroy(),this._sprite&&this._sprite.destroy(),this._imageAsset.destroy(),this._openDataContext=null},Ur(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}(ns),Dn((WBt=qBt).prototype,"designResolutionSize",[UBt],Object.getOwnPropertyDescriptor(WBt.prototype,"designResolutionSize"),WBt.prototype),Dn(WBt.prototype,"fps",[HBt],Object.getOwnPropertyDescriptor(WBt.prototype,"fps"),WBt.prototype),jBt=Dn(WBt.prototype,"_fps",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),YBt=Dn(WBt.prototype,"_designResolutionSize",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new d(640,960)}}),XBt=WBt))||XBt)||XBt)||XBt)||XBt)||XBt));Er.SubContextView=ZBt,Jo({ButtonComponent:{newName:"Button",since:"1.2.0",removed:!1},EditBoxComponent:{newName:"EditBox",since:"1.2.0",removed:!1},LayoutComponent:{newName:"Layout",since:"1.2.0",removed:!1},ProgressBarComponent:{newName:"ProgressBar",since:"1.2.0",removed:!1},ScrollViewComponent:{newName:"ScrollView",since:"1.2.0",removed:!1},ScrollBarComponent:{newName:"ScrollBar",since:"1.2.0",removed:!1},SliderComponent:{newName:"Slider",since:"1.2.0",removed:!1},ToggleComponent:{newName:"Toggle",since:"1.2.0",removed:!1},ToggleContainerComponent:{newName:"ToggleContainer",since:"1.2.0",removed:!1},WidgetComponent:{newName:"Widget",since:"1.2.0",removed:!1},PageViewComponent:{newName:"PageView",since:"1.2.0",removed:!1},PageViewIndicatorComponent:{newName:"PageViewIndicator",since:"1.2.0",removed:!1},SafeAreaComponent:{newName:"SafeArea",since:"1.2.0",removed:!1},UICoordinateTrackerComponent:{newName:"UICoordinateTracker",since:"1.2.0",removed:!1},BlockInputEventsComponent:{newName:"BlockInputEvents",since:"1.2.0",removed:!1}});var QBt,$Bt,tRt,eRt,iRt=t("UIReorderComponent",En("cc.UIReorderComponent")(KBt=function(){Rn(1408,"UIReorderComponent")})||KBt);Er.UIReorderComponent=iRt,Er.ButtonComponent=Yvt,pn.setClassAlias(Yvt,"cc.ButtonComponent"),Er.EditBoxComponent=vAt,pn.setClassAlias(vAt,"cc.EditBoxComponent"),Er.LayoutComponent=XAt,pn.setClassAlias(XAt,"cc.LayoutComponent"),Er.ProgressBarComponent=pTt,pn.setClassAlias(pTt,"cc.ProgressBarComponent"),Er.ScrollViewComponent=KCt,pn.setClassAlias(KCt,"cc.ScrollViewComponent"),Er.ScrollBarComponent=CTt,pn.setClassAlias(CTt,"cc.ScrollBarComponent"),Er.SliderComponent=yxt,pn.setClassAlias(yxt,"cc.SliderComponent"),Er.ToggleComponent=Pxt,pn.setClassAlias(Pxt,"cc.ToggleComponent"),Er.ToggleContainerComponent=Cwt,pn.setClassAlias(Cwt,"cc.ToggleContainerComponent"),Er.WidgetComponent=Zwt,pn.setClassAlias(Zwt,"cc.WidgetComponent"),Er.PageViewComponent=qEt,pn.setClassAlias(qEt,"cc.PageViewComponent"),Er.PageViewIndicatorComponent=HEt,pn.setClassAlias(HEt,"cc.PageViewIndicatorComponent"),Er.SafeAreaComponent=PBt,pn.setClassAlias(PBt,"cc.SafeAreaComponent"),pn.setClassAlias(OBt,"cc.UICoordinateTrackerComponent"),Er.BlockInputEventsComponent=JBt,pn.setClassAlias(JBt,"cc.BlockInputEventsComponent");var rRt=t("VideoClip",En("cc.VideoClip")((eRt=function(t){function e(){var e;return e=t.call(this)||this,Mn(e,"_duration",tRt,Pn(e)),e._video=null,e}return on(e,t),Ur(e,[{key:"_nativeAsset",get:function(){return this._video},set:function(t){this._video=t,this._duration=t?t.duration:0}}]),e}(Qr),tRt=Dn(($Bt=eRt).prototype,"_duration",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),QBt=$Bt))||QBt);function nRt(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;Ka(e),i(new Error(e))},s.send()}function sRt(t,e,i,r){var n=new rRt;n._nativeUrl=t,n._nativeAsset=e,r(null,n)}Gr.register({".mp4":nRt,".avi":nRt,".mov":nRt,".mpg":nRt,".mpeg":nRt,".rm":nRt,".rmvb":nRt}),$r.register({".mp4":sRt,".avi":sRt,".mov":sRt,".mpg":sRt,".mpeg":sRt,".rm":sRt,".rmvb":sRt});var aRt,oRt,lRt=zs({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"}(aRt||(aRt={})),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"}(oRt||(oRt={}));var hRt=function(){function t(t){var e=this;this._componentEventList=new Map,this._state=aRt.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(Uc),this._onHide=function(){e.video&&e._state===aRt.PLAYING&&(e.video.pause(),e._interrupted=!0)},this._onShow=function(){e._interrupted&&e.video&&(e.video.play(),e._interrupted=!1)},Er.game.on(Er.Game.EVENT_HIDE,this._onHide),Er.game.on(Er.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(aRt.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(aRt.READY_TO_PLAY)},e.onPlay=function(){this._playing=!0,this.dispatchEvent(aRt.PLAYING)},e.onPlaying=function(){this.dispatchEvent(aRt.PLAYING)},e.onPause=function(){this._ignorePause?this._ignorePause=!1:(this._playing=!1,this.dispatchEvent(aRt.PAUSED))},e.onStoped=function(){this._playing=!1,this._ignorePause=!1,this.dispatchEvent(aRt.STOPPED)},e.onEnded=function(){this.dispatchEvent(aRt.COMPLETED)},e.onClick=function(){this.dispatchEvent(aRt.CLICKED)},e.onError=function(t){this.dispatchEvent(aRt.ERROR);var e=t.target;e&&e.error&&Ja("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(),Er.game.off(Er.Game.EVENT_HIDE,this._onHide),Er.game.off(Er.Game.EVENT_SHOW,this._onShow)},Ur(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 Kr.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();Er.internal.VideoPlayerImpl=hRt;var uRt,cRt,_Rt,fRt,dRt,pRt,mRt,gRt,yRt,vRt,bRt,SRt,ARt,TRt,CRt,xRt,wRt,ERt,BRt,RRt,DRt,MRt,PRt,IRt,ORt,FRt,LRt,kRt,VRt,NRt,GRt,zRt,URt,HRt,XRt,WRt,jRt,YRt,qRt,KRt=-Math.pow(2,15),JRt=_(),ZRt=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}on(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(aRt.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){Fn.browserType!==Ya.UC?this.video&&(this.video.playbackRate=t):bn("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===oRt.HAVE_ENOUGH_DATA)return Fn.os===ja.IOS&&Fn.isBrowser?(t?i.webkitEnterFullscreen&&i.webkitEnterFullscreen():i.webkitExitFullscreen&&i.webkitExitFullscreen(),void(this._fullScreenOnAwake=i.webkitDisplayingFullscreen)):Xs.supportsFullScreen?void(t?(Fn.browserType===Ya.IE&&(i.style.transform=""),i.setAttribute("x5-video-player-fullscreen","true"),Xs.requestFullScreen(i,(function(t){var r=Fn.browserType===Ya.IE?t.msFullscreenElement:t.fullscreenElement;e._fullScreenOnAwake=r===i}),(function(){e._fullScreenOnAwake=!1}))):(i.removeAttribute("x5-video-player-fullscreen"),Xs.exitFullScreen())):(this._fullScreenOnAwake=t,this._forceUpdate=!0,void this.syncMatrix())},i.syncStayOnBottom=function(t){this._video&&(this._video.style["z-index"]=t?KRt: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&&Vo(Ir.container,t)&&(Ir.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(),Ir.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 oRt.HAVE_METADATA:case oRt.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&&!Xs.fullScreen()){this._dirty&&(this._dirty=!1,this._stayOnBottom?(this._clearColorA=t.clearColor.w,this._clearFlag=t.clearFlag,t.clearColor.w=0,t.clearFlag=Lt.ALL):this._clearFlag&&(t.clearColor.w=this._clearColorA,t.clearFlag=this._clearFlag,this._clearColorA=-1,this._clearFlag=null)),this._component.node.getWorldMatrix(JRt),t.update(!0),t.worldMatrixToScreen(JRt,JRt,Ir.canvas.width,Ir.canvas.height);var e=0,i=0;if(this._fullScreenOnAwake?(e=rs.width,i=rs.height):(e=this._uiTrans.contentSize.width,i=this._uiTrans.contentSize.height),this._forceUpdate||this._m00!==JRt.m00||this._m01!==JRt.m01||this._m04!==JRt.m04||this._m05!==JRt.m05||this._m12!==JRt.m12||this._m13!==JRt.m13||this._w!==e||this._h!==i){this._m00=JRt.m00,this._m01=JRt.m01,this._m04=JRt.m04,this._m05=JRt.m05,this._m12=JRt.m12,this._m13=JRt.m13,this._w=e,this._h=i;var r=No.devicePixelRatio,n=1/r,s=1/r,a=Ir.container,o=JRt.m00*n,l=JRt.m01,h=JRt.m04,u=JRt.m05*s;this._video.style.width=this._w+"px",this._video.style.height=this._h+"px",Fn.browserType!==Ya.MOBILE_QQ?this._video.style.objectFit=this._keepAspectRatio?"none":"fill":bn("keepAspectRatio is not supported by the qq mobile browser.");var c=this._w*n,_=this._h*s,f=this._uiTrans.anchorPoint,d=f.x,p=f.y,m=c*JRt.m00*d,g=_*JRt.m05*p,y=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+","+(JRt.m12*n-m+y)+","+-(JRt.m13*s-g+v)+")";this._video.style.transform=b,this._video.style["-webkit-transform"]=b,Fn.browserType!==Ya.IE&&(this._forceUpdate=!1)}}}},e}(hRt),QRt=function(){function t(){}return t.getImpl=function(t){return new ZRt(t)},t}();Er.internal.VideoPlayerImplManager=QRt;var $Rt,tDt=t("VideoPlayer",(uRt=En("cc.VideoPlayer"),cRt=Qn(),_Rt=ts(),fRt=us(Uc),dRt=Wn(rRt),pRt=Wn(lRt),mRt=is(),gRt=is(),yRt=Wn(rRt),vRt=is(),bRt=is(),SRt=Ls(),ARt=is(),TRt=Ls(),CRt=is(),xRt=is(),wRt=is(),ERt=is(),BRt=is(),RRt=is(),DRt=Wn([Fo]),MRt=es(),PRt=is(),uRt(IRt=cRt(IRt=_Rt(IRt=fRt(IRt=Jn((qRt=YRt=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,Mn(e,"_resourceType",FRt,Pn(e)),Mn(e,"_remoteURL",LRt,Pn(e)),Mn(e,"_clip",kRt,Pn(e)),Mn(e,"_playOnAwake",VRt,Pn(e)),Mn(e,"_volume",NRt,Pn(e)),Mn(e,"_mute",GRt,Pn(e)),Mn(e,"_playbackRate",zRt,Pn(e)),Mn(e,"_loop",URt,Pn(e)),Mn(e,"_fullScreenOnAwake",HRt,Pn(e)),Mn(e,"_stayOnBottom",XRt,Pn(e)),Mn(e,"_keepAspectRatio",WRt,Pn(e)),e._impl=null,e._cachedCurrentTime=0,Mn(e,"videoPlayerEvent",jRt,Pn(e)),e}on(e,t);var i=e.prototype;return i.syncSource=function(){this._impl&&(this._resourceType===lRt.REMOTE?this._impl.syncURL(this._remoteURL):this._impl.syncClip(this._clip))},i.__preload=function(){this._impl=QRt.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(aRt.META_LOADED,this.onMetaLoaded.bind(this)),this._impl.componentEventList.set(aRt.READY_TO_PLAY,this.onReadyToPlay.bind(this)),this._impl.componentEventList.set(aRt.PLAYING,this.onPlaying.bind(this)),this._impl.componentEventList.set(aRt.PAUSED,this.onPaused.bind(this)),this._impl.componentEventList.set(aRt.STOPPED,this.onStopped.bind(this)),this._impl.componentEventList.set(aRt.COMPLETED,this.onCompleted.bind(this)),this._impl.componentEventList.set(aRt.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(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.META_LOADED),this.node.emit("meta-loaded",this)},i.onReadyToPlay=function(){this._playOnAwake&&!this.isPlaying&&this.play(),Fo.emitEvents(this.videoPlayerEvent,this,aRt.READY_TO_PLAY),this.node.emit(aRt.READY_TO_PLAY,this)},i.onPlaying=function(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.PLAYING),this.node.emit(aRt.PLAYING,this)},i.onPaused=function(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.PAUSED),this.node.emit(aRt.PAUSED,this)},i.onStopped=function(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.STOPPED),this.node.emit(aRt.STOPPED,this)},i.onCompleted=function(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.COMPLETED),this.node.emit(aRt.COMPLETED,this)},i.onError=function(){Fo.emitEvents(this.videoPlayerEvent,this,aRt.ERROR),this.node.emit(aRt.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()},Ur(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)?bn("illegal video time! value:"+t):(t=T(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:aRt.NONE}},{key:"isPlaying",get:function(){return!!this._impl&&this._impl.isPlaying}}]),e}(ns),YRt.EventType=aRt,YRt.ResourceType=lRt,FRt=Dn((ORt=qRt).prototype,"_resourceType",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return lRt.LOCAL}}),LRt=Dn(ORt.prototype,"_remoteURL",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),kRt=Dn(ORt.prototype,"_clip",[dRt,On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),VRt=Dn(ORt.prototype,"_playOnAwake",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),NRt=Dn(ORt.prototype,"_volume",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),GRt=Dn(ORt.prototype,"_mute",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),zRt=Dn(ORt.prototype,"_playbackRate",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),URt=Dn(ORt.prototype,"_loop",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),HRt=Dn(ORt.prototype,"_fullScreenOnAwake",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),XRt=Dn(ORt.prototype,"_stayOnBottom",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),WRt=Dn(ORt.prototype,"_keepAspectRatio",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dn(ORt.prototype,"resourceType",[pRt,mRt],Object.getOwnPropertyDescriptor(ORt.prototype,"resourceType"),ORt.prototype),Dn(ORt.prototype,"remoteURL",[gRt],Object.getOwnPropertyDescriptor(ORt.prototype,"remoteURL"),ORt.prototype),Dn(ORt.prototype,"clip",[yRt,vRt],Object.getOwnPropertyDescriptor(ORt.prototype,"clip"),ORt.prototype),Dn(ORt.prototype,"playOnAwake",[bRt],Object.getOwnPropertyDescriptor(ORt.prototype,"playOnAwake"),ORt.prototype),Dn(ORt.prototype,"playbackRate",[Ns,SRt,ARt],Object.getOwnPropertyDescriptor(ORt.prototype,"playbackRate"),ORt.prototype),Dn(ORt.prototype,"volume",[Ns,TRt,CRt],Object.getOwnPropertyDescriptor(ORt.prototype,"volume"),ORt.prototype),Dn(ORt.prototype,"mute",[xRt],Object.getOwnPropertyDescriptor(ORt.prototype,"mute"),ORt.prototype),Dn(ORt.prototype,"loop",[wRt],Object.getOwnPropertyDescriptor(ORt.prototype,"loop"),ORt.prototype),Dn(ORt.prototype,"keepAspectRatio",[ERt],Object.getOwnPropertyDescriptor(ORt.prototype,"keepAspectRatio"),ORt.prototype),Dn(ORt.prototype,"fullScreenOnAwake",[BRt],Object.getOwnPropertyDescriptor(ORt.prototype,"fullScreenOnAwake"),ORt.prototype),Dn(ORt.prototype,"stayOnBottom",[RRt],Object.getOwnPropertyDescriptor(ORt.prototype,"stayOnBottom"),ORt.prototype),jRt=Dn(ORt.prototype,"videoPlayerEvent",[On,DRt,MRt,PRt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),IRt=ORt))||IRt)||IRt)||IRt)||IRt)||IRt));Er.internal.VideoPlayer=tDt,wr(tDt.prototype,"VideoPlayer.prototype",[{name:"onPasued",newName:"onPaused"}]),function(t){t.NONE="none",t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}($Rt||($Rt={}));var eDt=function(){function t(t){this._componentEventList=new Map,this._state=$Rt.NONE,this._wrapper=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(Uc),this.reset(),this.createWebView()}var e=t.prototype;return e.reset=function(){this._wrapper=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=$Rt.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._wrapper=null,this._webview=null,this._loaded=!1,this._component=null,this._uiTrans=null,this._forceUpdate=!1,this._componentEventList.clear()},Ur(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 Kr.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();Er.internal.WebViewImpl=eDt;var iDt,rDt,nDt,sDt,aDt,oDt,lDt,hDt,uDt,cDt,_Dt,fDt,dDt,pDt,mDt=_(),gDt=function(t){function e(e){return t.call(this,e)||this}on(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($Rt.LOADED);var i=e.target,r=i.contentDocument&&i.contentDocument.body;r&&r.innerHTML.includes("404")&&t.dispatchEvent($Rt.ERROR,r.innerHTML)}))},i.loadURL=function(t){this.webview&&(this.webview.src=t,this.dispatchEvent($Rt.LOADING))},i.createWebView=function(){var t=document.createElement("div");this._wrapper=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",Ir.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._wrapper;Vo(Ir.container,t)&&Ir.container.removeChild(t),this.reset()},i.enable=function(){this._wrapper&&(this._wrapper.style.visibility="visible")},i.disable=function(){this._wrapper&&(this._wrapper.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($Rt.ERROR,t),Ja(t)}}},i.setOnJSCallback=function(){bn("The platform does not support")},i.setJavascriptInterfaceScheme=function(){bn("The platform does not support")},i.syncMatrix=function(){if(this._wrapper&&this._uiTrans&&this._component&&"hidden"!==this._wrapper.style.visibility){var t=this.UICamera;if(t){this._component.node.getWorldMatrix(mDt),t.update(!0),t.worldMatrixToScreen(mDt,mDt,Ir.canvas.width,Ir.canvas.height);var e=this._uiTrans.contentSize,i=e.width,r=e.height;if(this._forceUpdate||this._m00!==mDt.m00||this._m01!==mDt.m01||this._m04!==mDt.m04||this._m05!==mDt.m05||this._m12!==mDt.m12||this._m13!==mDt.m13||this._w!==i||this._h!==r){this._m00=mDt.m00,this._m01=mDt.m01,this._m04=mDt.m04,this._m05=mDt.m05,this._m12=mDt.m12,this._m13=mDt.m13,this._w=i,this._h=r;var n=No.devicePixelRatio,s=1/n,a=1/n,o=Ir.container,l=mDt.m00*s,h=mDt.m01,u=mDt.m04,c=mDt.m05*a;this._wrapper.style.width=i+"px",this._wrapper.style.height=r+"px";var _=this._w*s,f=this._h*a,d=_*mDt.m00*this._uiTrans.anchorX,p=f*mDt.m05*this._uiTrans.anchorY,m=o&&o.style.paddingLeft?parseInt(o.style.paddingLeft):0,g=o&&o.style.paddingBottom?parseInt(o.style.paddingBottom):0,y="matrix("+l+","+-h+","+-u+","+c+","+(mDt.m12*s-d+m)+","+-(mDt.m13*a-p+g)+")";this._wrapper.style.transform=y,this._wrapper.style["-webkit-transform"]=y,this._forceUpdate=!1}}}},e}(eDt),yDt=function(){function t(){}return t.getImpl=function(t){return new gDt(t)},t}();Er.internal.WebViewImplManager=yDt;var vDt=t("WebView",(iDt=En("cc.WebView"),rDt=Qn(),nDt=ts(),sDt=us(Uc),aDt=is(),oDt=Wn([Fo]),lDt=es(),hDt=is(),iDt(uDt=rDt(uDt=nDt(uDt=sDt(uDt=Jn((pDt=dDt=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,Mn(e,"_url",_Dt,Pn(e)),e._impl=null,Mn(e,"webviewEvents",fDt,Pn(e)),e}on(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=yDt.getImpl(this),this._impl.componentEventList.set($Rt.LOADING,this.onLoading.bind(this)),this._impl.componentEventList.set($Rt.LOADED,this.onLoaded.bind(this)),this._impl.componentEventList.set($Rt.ERROR,this.onError.bind(this)),this._impl.loadURL(this._url)},i.onLoading=function(){Fo.emitEvents(this.webviewEvents,this,$Rt.LOADING),this.node.emit($Rt.LOADING,this)},i.onLoaded=function(){Fo.emitEvents(this.webviewEvents,this,$Rt.LOADED),this.node.emit($Rt.LOADED,this)},i.onError=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];Fo.emitEvents(this.webviewEvents,this,$Rt.ERROR,e),this.node.emit($Rt.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()},Ur(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:$Rt.NONE}}]),e}(ns),dDt.EventType=$Rt,_Dt=Dn((cDt=pDt).prototype,"_url",[On],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"https://cocos.com"}}),Dn(cDt.prototype,"url",[aDt],Object.getOwnPropertyDescriptor(cDt.prototype,"url"),cDt.prototype),fDt=Dn(cDt.prototype,"webviewEvents",[On,oDt,lDt,hDt],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),uDt=cDt))||uDt)||uDt)||uDt)||uDt)||uDt));Er.internal.WebView=vDt}}}));
|