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;n1){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;ethis._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=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;ryn.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>1;return{width:1<<(1&i?r+1:r),height:1<=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=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;r0&&(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=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=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=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;r0){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;D0){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;a0?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;c0){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=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;ithis._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>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=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=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<>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>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=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=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=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&&ol.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;t0},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>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=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;e0&&(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;ai.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<>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<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)=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;e0){for(var i=0;ii)for(var r=i;r=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"]),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",e),n=-1;if(r>=0&&(n=t.lastIndexOf("<",r))",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-1&&(r=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;nh;){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&&n0&&(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;u1&&u0?(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;r0){var h=this._measureText(r,l);this._updateRichTextWithMaxWidth(l,h,r),a.length>1&&othis._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&o0&&(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;se&&(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"RichText"}}),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;i0)for(s=e;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;e0||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.xs.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.x&&i.x>=u&&Jy(na.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=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;a80*i){o=h=t[0],l=u=t[1];for(var d=i;dh&&(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 ti?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.dataOffset0&&(n=1/e);for(var s=t.paths,a=t.pathOffset,o=t.pathLength;a1e-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;i2&&a.equals(o)&&(n.closed=!0,s.pop(),a=s[s.length-1]);for(var l=0,h=s.length;lm&&(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;v0&&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+1Fv.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,od&&(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;oeb&&!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>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;e0)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;o0){if(c>Gv){var _=c-Gv;Cv.y+=_,Cv.height-=_,c-=_}c-u.h*Uv0&&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;r0&&(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;n1&&Rb,r=this._measureText(cb,db),n=0,s=0;Rb&&this._setupShadow(),Eb&&this._setupOutline();for(var a=0;a>1)<=0){Qs(4003);break}mb=h,db=this._getFontDesc(),cb.font=db;var u=this._getLineHeight();for(r=0,i=0;ia?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;in?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;u1?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=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;i1?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;g0||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;r1?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=n?c-f:w*g-f,WS[w].y=w>=r?_-d:w*S-d;else for(var E=0;E1&&E0?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&&E0?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;PS?i>=(x>0?H:H+1)*S?1:G%1:G;for(var X=0;Xg?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):H0){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;ie)for(;e0&&(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;t0){!function(t,e){for(var i,r,n,s=t.vertexFormat,a=t.chunk.vb,o=0,l=0;l>>0;else if(r.size/r.count==4)for(var c=o+3;c>2}}(n.renderData,a);var l=n.renderData.getMeshBuffer();l&&l.setDirty()}if(i.length>0&&!t._static)for(var h=0;h=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.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;s0&&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;tfr.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;e0&&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;l0;){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=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=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=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=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=0)return"continue";t.push(r),e.push(c.multiply(new c,n.bindposes[i]||c.IDENTITY,eB))},a=0;at[i]?1:t[e]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;n0&&(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._lastIterations0&&(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;ne){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;r1}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;s2?i-2:0),n=2;n>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;i1e-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=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(en)return i;var s=(e=(e-r)/(n-r))/(1/i),a=0|s,o=1e-6;return s-a=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(es)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<=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=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=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;n0?((s&ga.PingPong)===ga.PingPong?e*=-1:l=r,o++):1===e&&l===r-1&&na)break}l+=e,this._doFire(l,!0)}while(l!==n&&l>-1&&l=e.length||this._ignoreIndex===t))for(var i=e[t],r=this._targetNode.components,n=i.events.length,s=0;s5?l-5:0),u=5;u5?l-5:0),u=5;u=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=e[e.length-1])t[t.length-1]=1;else{for(var r=0,n=1;ni){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;_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;C0&&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;ne;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>>0,e}on(e,t);var i=e.prototype;return i.setLayerMask=function(t){this._layerMask&=~(1<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;li||_>=n.requires)continue}for(var d=!0,p=0;p0);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:"";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=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;r0),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=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=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=l.easeDuration){a=o+1,l.easeTime=l.easeDuration;break}}if(a!==i.length){for(var c=a;c=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=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-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.length0?this._oneShotAudioInfoList.forEach((function(e){(!t||e.playTime0){for(var i=0,r=this._objects;i0){for(var n=0;ni&&(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(_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(fv?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&&s=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=0&&t=0&&t=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];en&&(a|=2),es&&(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&&ta&&is&&ra&&n=-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=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)):(Dm&&(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=e||a=e){var l=this.vertices[s],h=this.vertices[r];(e-o)*(l-h)/(a-o)+h0)){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=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=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=0&&n.contains(o)&&this.boneMask.splice(l,1)}else for(var h=0,u=t.getBones();he._zOrder?1:-1},i.prototype._onClear=function(){null!==this._clock&&this._clock.remove(this);for(var t=0,e=this._bones;t=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;r0){this._lockUpdate=!0;for(var s=0,a=this._actions;s0){if(null!==(a=this.getBone(t))&&(a.invalidUpdate(),e))for(var i=0,r=this._slots;i0){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||Sh)&&(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=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=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=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=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=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=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=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=0&&(null!==this._rawDisplayDatas&&(s=this._displayIndex=0&&this._displayIndex=0&&null!==this._rawDisplayDatas){var a=this._displayIndex0)for(var o=0,l=s;o0){this._displayList.length!==e.length&&(this._displayList.length=e.length);for(var i=0,r=e.length;i0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex=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;i0&&(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;nd)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;Ud)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;r0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD));for(var B=this.rotateMix,R=this.translateMix,D=(g=0,3);g0){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;i0&&(this._animatebles[i-r]=s,this._animatebles[i]=null),s.advanceTime(t)):r++}if(r>0){for(n=this._animatebles.length;i=0&&(this._animatebles[e]=null,t.clock=null)},t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&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();n0){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;_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;t1?(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;hthis._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;t0},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;e0;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;n0,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;h0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(var f=0,d=this._poseTimelines;f0&&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;i1e-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=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=0&&r.contains(o)&&this._boneMask.splice(l,1)}else for(var h=0,u=n;h0},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._duration0&&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;i0))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.currentPlayTimes0?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;a0&&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=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=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=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;a255)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=0&&r+61e-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;dr)break;h++}null===u&&((u=new i).frameStart=r,this._actionFrames.splice(h+1,0,u));for(var g=0;g0){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];d0&&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;l0?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);h0?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;bi.width&&(i.width=l),hi.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;a0&&(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;v0)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;o0){for(var a=this._armature.sortedSlots.length,o=new Array(a-s.length/2),l=new Array(a),h=0;h0?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=_=o.length?0:o[_-l],c=_+1=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=o.length?0:o[g-l],f=g+1=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=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];o0&&(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;o0&&_>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;e255)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=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;o0&&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;r0&&(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;_=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;f0&&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;_=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;t0&&(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>8&255)/255,h[_+7]=(l>>16&255)/255,h[_+8]=(l>>24&255)/255,_+=9;var d=i.indices;(!d||d.lengththis.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=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":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[""]=0]=""}($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;ithis.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.vertexCountthis.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;o0&&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;t0&&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;s0&&(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=_&&(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;a0&&(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;b0&&(gU._requestDrawData(zU,UU,VU,h),VU=FU),gU.maxIndexCount=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=0&&Mt.gpuDescriptors[Pt],Ot=Bt.units.length,Ft=0;Ft0){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=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;_e0){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;i0?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;A0?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;o0,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;n0&&(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;ii&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o0){e.glBlocks=new Array(e.blocks.length);for(var v=0;v0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var R=0;Rt.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>1),n=Math.max(1,n>>1)}else for(var u=0;u>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>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>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;s1&&(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>1),n=Math.max(1,n>>1)}else for(var u=0;u>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>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>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;rt.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>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;_>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=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=0&&D.gpuDescriptors[M],I=0;I0){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=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;ot0){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;i0?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;A0?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;o0?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;k0?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;o0,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;n0&&(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;i0?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>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;ni&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var D=0;D1&&(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>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>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=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;nn!=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;as+o&&(h=s+o),na+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;i1){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;s1&&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=i&&tthis.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=i&&tthis.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;ne&&(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;s0){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._curTime0&&(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;s0){this._mesh.copyIndices(0,l);for(var h=1;h=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;e0,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._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=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;st.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)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;u2){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)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;re){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;e1?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.lengtha;)this.emitParticle(g6),this.emitCounter-=a;this.elapsed+=t,-1!==i.duration&&i.durationthis.uvFilled&&this.updateUVs();for(var h=0;h0){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>>0;t=r}for(var n,s=1,a=0,o=t.length,l=0;0>>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>>8&255]<<16|f[t>>>16&255]<<8|f[t>>>24&255])>>32-e:f[t]>>8-e),8>e+a)o=o<>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 0l;++l){for(var u=_=l,c=7,_=_>>>1;_;_>>>=1)u<<=1,u|=1&_,--c;h[l]=(u<>>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_&&(_=t[h]),t[h]>=1;for(u=o;us[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+2s[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>>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;pK)for(;0K?K:138)>K-3&&Q=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(;0K?K:6)>K-3&&QU;U++)j[U]=V[W[U]];for(I=19;4=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=h;)b[h++]=0;for(h=0;29>=h;)A[h++]=0}for(b[256]=1,o=0,l=n.length;o=l){for(d&&a(d,-1),h=0,u=l-o;hB&&o+BE&&(x=C,E=B),258===B)break}f=new S(E,o-x),d?d.length2*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;_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;o1<u&&t("undercommitted"),i=0,r=e.length;i>>=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=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>>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<>>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;an)r>=l&&(this.b=r,i=this.f(),r=this.b),i[r++]=n;else for(o=z[s=n-257],0=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],0l&&(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;tt;++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)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=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=0?rs;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?nh;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?et;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>>8*(4-s)):n.push(r);else for(var a=0;a=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<>>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=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;L0)for(var ot=0;ot>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=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>=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>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;ao)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=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=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=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=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;n1){var h=l[0],u=h.point.x-a,c=h.point.y-o;u*u+c*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;se?t:e}function D(t,e,i){return ti?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=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;ithis.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;ri&&(e=r,i=n)}return e},e.GetSupportVertex=function(t){for(var e=0,i=z.DotVV(this.m_vertices[0],t),r=1;ri&&(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;o1){var c=t.metric,_=this.GetMetric();(_<.5*c||2*c<_||_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;mS+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;fp){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(cb){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.maxFraction0;){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),h1){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=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_+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-_)_?(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_)return;g>c&&(c=g,u=m)}var y=u,v=(y+1)%f,b=d[y],S=d[v];if(c_*_)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;dc&&(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_*_)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;gthis.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;xthis.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||uthis.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;iu||_===u&&n[c].yy.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;S0)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;la&&(a=h,o.Copy(this.m_normals[l]))}if(a>0){for(var u=r.ComputeDistance_s_minDistance.Copy(o),c=a*a,_=0;_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;u0&&c=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;s0&&(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;e0){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.maxFraction0&&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;i0?(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),e0&&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)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,S0&&(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_maxLength0){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;f0: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.length0?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;i0?-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;c0?-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.length4){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.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;X4){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;i0){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;s0&&(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=0&&f>=0&&_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)),pV*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=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;n0;){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=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<>>0)>>>0},r.computeRelativeTag=function(t,e,i){return t+(i<>>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_firstIndex0?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;o0&&(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;n0?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=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;ne?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_internalAllocatedCapacity0;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;_=e&&f=e&&dy||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>0,C=0;CI&&(this.m_depthBuffer[B]=I,x=!0),P>F&&(this.m_depthBuffer[R]=F,x=!0)}if(!x)break}for(var L=0;L0)for(var i=this.GetParticleCount(),n=0;nthis.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_iterationIndexi&&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=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=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=0&&W<=1)){if(!((j=Q)>=0&&j=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;ao){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;yo){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=0?(w=B(w,P),E=R(E,P+1)):D=!0}wn:s})),this.m_expirationTimeBufferRequiresSorting=!1);for(var s=n-1;s>=0;--s){var a=r[s],o=i[a];if(ee.weight:t.index3)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;cthis.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&&t0?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<>>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>>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 t0?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;_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;b8)){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.alpha0this.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;e0?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;s0&&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;ns;)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;i1?e-1:0),r=1;r0&&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>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;nm&&(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;n0}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;e0}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)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<e;)this.physicsWorld.step(e,i,r),this._accumulator-=e;for(var s=this._delayEvents,a=0,o=s.length;a=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;a0){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=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;ar&&(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;s0&&n[0].equals(n[n.length-1])&&(n.length-=1);for(var s=Ttt(n),a=r.offset,o=0;o=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._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<>>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;n0&&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;w0&&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;v0&&(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;al?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;no?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=3){e[0]=t[0],e[1]=t[1],e[2]=t[2];for(var i=t.length,r=3;rztt.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&&(tztt.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&&(tztt.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;nt)){for(var e=this.buffer.byteLength;e=pht){var a=e.readInt();this.layerBuffer=new Array(a);for(var o=0;o=mht){var l=e.readInt();this._layerBinaryInfos=new Array(l);for(var h=0;h=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=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=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=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;h0){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;e0){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;rh&&(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=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._valuethis._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=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;i0&&(e%=this.duration));for(var l=this.timelines,h=0,u=l.length;h>>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=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[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[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[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[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[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[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[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;Si)this.apply(t,e,Number.MAX_VALUE,r,s,a,o),e=-1;else if(e>=l[h-1])return;if(!(i0&&l[u-1]==c;)u--;for(;u=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[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=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[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[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[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[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;i0){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;a0)){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;p1&&(a=1),n!=t.MixBlend.first&&(n=s.mixBlend));var o=a0&&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[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;or||this.queue.event(t,h)}for((t.loop?0==n||s>t.trackTime%n:e>=r&&t.animationLast=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=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;h0){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=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("",[],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=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;i180?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&&yg&&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)=-1&&C<=1&&(C=Math.acos(C),(x=(M=A*Math.cos(C)+F)*M+(P=T*Math.sin(C))*P)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;i0;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;y0?t.MathUtils.degRad:-t.MathUtils.degRad),y=0;for(var D=3;yt.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;yg){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);yC){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;e0},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;i1){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-1||this.updateCacheReset.push(s)}else for(n=0;n0){b=new t.DrawOrderTimeline(L);var k=n.slots.length;for(u=0;u=0;f--)N[f]=-1;var G=t.Utils.newArray(k-V,0),z=0,U=0;for(f=0;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>>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>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=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&&hs&&hn&&un&&ut.minX&&this.minYt.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,r=0,n=i.length;r=i||h=i){var u=r[o];u+(i-l)/(h-l)*(r[s]-u)=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>1,U=this.clipOutput,H=t.Utils.setArraySize(f,O+z*g),X=0;X=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;T0;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>1;o=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;_=r.length&&(r.length=t+1),r[t]||(r[t]={}),r[t][e]=i},i.prototype.addSkin=function(t){for(var e=0;e= 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.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;r0?t.MathUtils.degRad:-t.MathUtils.degRad,c=this.data.offsetRotation*u,_=this.data.offsetShearY*u,f=this.bones,d=0,p=f.length;dt.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;dt.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;a1e-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;a1e-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;s3;){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;u0?(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=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 ti?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=i?e:t.setArraySize(e,i,r)},t.newArray=function(t,e){for(var i=new Array(t),r=0;r0?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;ethis.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.addedValuesthis.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>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;_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>>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;l0&&(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.lengththis.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=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;x0){for(var M=s_t,P=s_t+m_t;M>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;r1)return this._animsEnum;var t=this.getRuntimeData(!0);if(t){for(var e={"":0},i=t.animations,r=0;r"]=0]=""}(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;ithis._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;athis.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||"":e(t[i.parent.data.index])+"/"+i.data.name},i=0,r=t.length;i>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;g0&&(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=_&&(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=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>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;b0)for(var R=t.chunk.vertexOffset,D=Udt,M=Udt+zdt;D0&&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;On.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;h0&&Adt.set(l,Udt),Wdt)for(var h=0,u=o.length,c=Gdt;h0&&Adt.set(A,Udt),Wdt)for(var T=0,C=S.length,x=Gdt;T>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>e,o=0,l=new Uint16Array(2*a+2);l[o++]=0,l[o++]=0;for(var h=1;h>e,o=0,l=new Uint16Array(2*a+2);l[o++]=1056,l[o++]=1056;for(var h=1;h>e,o=0,l=new Uint16Array(2*a+2);l[o++]=0,l[o++]=0;for(var h=1;h>e,o=0,l=new Uint16Array(2*a+2);l[o++]=32,l[o++]=32;for(var h=1;h0&&(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;i0){var e=this.getTerrain().getBlock(this._index[0]-1,this._index[1]);t.west=e._lodLevel,t.west0){var r=this.getTerrain().getBlock(this._index[0],this._index[1]-1);t.north=r._lodLevel,t.north>t,o=s-1>>t,l=0;lthis.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;e0}},{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;n1,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;k0){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;Q0){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;r1)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._topOffsetthis._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=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>>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=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;r0&&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>>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;j0&&(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;e0)for(var T=0,C=v.length;T=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>>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.cola.maxCol?a.maxCol:e.col):(o=E&&e.col>a.maxCol?a.maxCol:e.col,l=E&&t.col=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=r&&i.actionIndex--;break}}},e._removeActionByTag=function(t,e,i){for(var r=0,n=e.actions.length;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=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=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;e1.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;l1?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._total1?1:n;t>=1&&this._total=0&&null==n[s]&&Qs(1015),s>=0){for(var a,o=n[0],l=1;ln?this._two=Tyt._actionOneTwo(e,Dyt(r-n)):r0&&null==e[e.length-1]&&Qs(1015);for(var i=e[0],r=1;r0&&(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=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=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;n0&&(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_&&(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;vu&&(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;r0?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=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)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.xthis._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<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=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.height1)for(var r=i[0],n=0;n0){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=t.length)){for(var i=0;it.length)for(i=0;i0;--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=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=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;r0){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=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(n1e-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;s0)){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;tr?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;n1?i-1:0),n=1;n