(function(I,W){typeof exports=="object"&&typeof module<"u"?W(exports,require("pixi.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js"],W):(I=typeof globalThis<"u"?globalThis:I||self,W(I.DragonBonesPixi={},I.PIXI))})(this,function(I,W){"use strict";var Je=Object.defineProperty;var $e=(I,W,Ft)=>W in I?Je(I,W,{enumerable:!0,configurable:!0,writable:!0,value:Ft}):I[W]=Ft;var a=(I,W,Ft)=>($e(I,typeof W!="symbol"?W+"":W,Ft),Ft);function Ft(u){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(l,t,e.get?e:{enumerable:!0,get:()=>u[t]})}}return l.default=u,Object.freeze(l)}const Gt=Ft(W);class me{constructor(l=0){a(this,"time",0);a(this,"timeScale",1);a(this,"_systemTime",0);a(this,"_animatebles",[]);a(this,"_clock",null);this.time=l,this._systemTime=new Date().getTime()*.001}advanceTime(l){l!==l&&(l=0);const t=Date.now()*.001;if(l<0&&(l=t-this._systemTime),this._systemTime=t,this.timeScale!==1&&(l*=this.timeScale),l===0)return;l<0?this.time-=l:this.time+=l;let e=0,i=0,s=this._animatebles.length;for(;e0&&(this._animatebles[e-i]=n,this._animatebles[e]=null),n.advanceTime(l)):i++}if(i>0){for(s=this._animatebles.length;e=0&&(this._animatebles[t]=null,l.clock=null)}clear(){for(const l of this._animatebles)l!==null&&(l.clock=null)}get clock(){return this._clock}set clock(l){this._clock!==l&&(this._clock!==null&&this._clock.remove(this),this._clock=l,this._clock!==null&&this._clock.add(this))}}const K=class K{constructor(){a(this,"hashCode",K._hashCode++);a(this,"_isInPool",!1)}static _returnObject(l){const t=String(l.constructor),e=t in K._maxCountMap?K._maxCountMap[t]:K._defaultMaxCount,i=K._poolsMap[t]=K._poolsMap[t]||[];i.lengtht&&(i.length=t),K._maxCountMap[e]=t}else{K._defaultMaxCount=t;for(let e in K._poolsMap){const i=K._poolsMap[e];i.length>t&&(i.length=t),e in K._maxCountMap&&(K._maxCountMap[e]=t)}}}static clearPool(l=null){if(l!==null){const t=String(l),e=t in K._poolsMap?K._poolsMap[t]:null;e!==null&&e.length>0&&(e.length=0)}else for(let t in K._poolsMap){const e=K._poolsMap[t];e.length=0}}static borrowObject(l){const t=String(l),e=t in K._poolsMap?K._poolsMap[t]:null;if(e!==null&&e.length>0){const s=e.pop();return s._isInPool=!1,s}const i=new l;return i._onClear(),i}returnToPool(){this._onClear(),K._returnObject(this)}};a(K,"_hashCode",0),a(K,"_defaultMaxCount",3e3),a(K,"_maxCountMap",{}),a(K,"_poolsMap",{});let F=K;const ct=class ct extends F{constructor(){super(...arguments);a(this,"time");a(this,"type");a(this,"name");a(this,"armature");a(this,"bone");a(this,"slot");a(this,"animationState");a(this,"actionData");a(this,"data")}static actionDataToInstance(t,e,i){t.type===q.Play?e.type=ct.FRAME_EVENT:e.type=t.type===q.Frame?ct.FRAME_EVENT:ct.SOUND_EVENT,e.name=t.name,e.armature=i,e.actionData=t,e.data=t.data,t.bone!==null&&(e.bone=i.getBone(t.bone.name)),t.slot!==null&&(e.slot=i.getSlot(t.slot.name))}static toString(){return"[class dragonBones.EventObject]"}_onClear(){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}};a(ct,"START","start"),a(ct,"LOOP_COMPLETE","loopComplete"),a(ct,"COMPLETE","complete"),a(ct,"FADE_IN","fadeIn"),a(ct,"FADE_IN_COMPLETE","fadeInComplete"),a(ct,"FADE_OUT","fadeOut"),a(ct,"FADE_OUT_COMPLETE","fadeOutComplete"),a(ct,"FRAME_EVENT","frameEvent"),a(ct,"SOUND_EVENT","soundEvent");let j=ct;var x=(u=>(u[u.WeigthBoneCount=0]="WeigthBoneCount",u[u.WeigthFloatOffset=1]="WeigthFloatOffset",u[u.WeigthBoneIndices=2]="WeigthBoneIndices",u[u.GeometryVertexCount=0]="GeometryVertexCount",u[u.GeometryTriangleCount=1]="GeometryTriangleCount",u[u.GeometryFloatOffset=2]="GeometryFloatOffset",u[u.GeometryWeightOffset=3]="GeometryWeightOffset",u[u.GeometryVertexIndices=4]="GeometryVertexIndices",u[u.TimelineScale=0]="TimelineScale",u[u.TimelineOffset=1]="TimelineOffset",u[u.TimelineKeyFrameCount=2]="TimelineKeyFrameCount",u[u.TimelineFrameValueCount=3]="TimelineFrameValueCount",u[u.TimelineFrameValueOffset=4]="TimelineFrameValueOffset",u[u.TimelineFrameOffset=5]="TimelineFrameOffset",u[u.FramePosition=0]="FramePosition",u[u.FrameTweenType=1]="FrameTweenType",u[u.FrameTweenEasingOrCurveSampleCount=2]="FrameTweenEasingOrCurveSampleCount",u[u.FrameCurveSamples=3]="FrameCurveSamples",u[u.DeformVertexOffset=0]="DeformVertexOffset",u[u.DeformCount=1]="DeformCount",u[u.DeformValueCount=2]="DeformValueCount",u[u.DeformValueOffset=3]="DeformValueOffset",u[u.DeformFloatOffset=4]="DeformFloatOffset",u))(x||{}),Dt=(u=>(u[u.Armature=0]="Armature",u[u.MovieClip=1]="MovieClip",u[u.Stage=2]="Stage",u))(Dt||{}),$=(u=>(u[u.Bone=0]="Bone",u[u.Surface=1]="Surface",u))($||{}),L=(u=>(u[u.Image=0]="Image",u[u.Armature=1]="Armature",u[u.Mesh=2]="Mesh",u[u.BoundingBox=3]="BoundingBox",u[u.Path=4]="Path",u))(L||{}),it=(u=>(u[u.Rectangle=0]="Rectangle",u[u.Ellipse=1]="Ellipse",u[u.Polygon=2]="Polygon",u))(it||{}),q=(u=>(u[u.Play=0]="Play",u[u.Frame=10]="Frame",u[u.Sound=11]="Sound",u))(q||{}),z=(u=>(u[u.Normal=0]="Normal",u[u.Add=1]="Add",u[u.Alpha=2]="Alpha",u[u.Darken=3]="Darken",u[u.Difference=4]="Difference",u[u.Erase=5]="Erase",u[u.HardLight=6]="HardLight",u[u.Invert=7]="Invert",u[u.Layer=8]="Layer",u[u.Lighten=9]="Lighten",u[u.Multiply=10]="Multiply",u[u.Overlay=11]="Overlay",u[u.Screen=12]="Screen",u[u.Subtract=13]="Subtract",u))(z||{}),J=(u=>(u[u.None=0]="None",u[u.Line=1]="Line",u[u.Curve=2]="Curve",u[u.QuadIn=3]="QuadIn",u[u.QuadOut=4]="QuadOut",u[u.QuadInOut=5]="QuadInOut",u))(J||{}),E=(u=>(u[u.Action=0]="Action",u[u.ZOrder=1]="ZOrder",u[u.BoneAll=10]="BoneAll",u[u.BoneTranslate=11]="BoneTranslate",u[u.BoneRotate=12]="BoneRotate",u[u.BoneScale=13]="BoneScale",u[u.Surface=50]="Surface",u[u.BoneAlpha=60]="BoneAlpha",u[u.SlotDisplay=20]="SlotDisplay",u[u.SlotColor=21]="SlotColor",u[u.SlotDeform=22]="SlotDeform",u[u.SlotZIndex=23]="SlotZIndex",u[u.SlotAlpha=24]="SlotAlpha",u[u.IKConstraint=30]="IKConstraint",u[u.AnimationProgress=40]="AnimationProgress",u[u.AnimationWeight=41]="AnimationWeight",u[u.AnimationParameter=42]="AnimationParameter",u))(E||{}),vt=(u=>(u[u.None=0]="None",u[u.Additive=1]="Additive",u[u.Override=2]="Override",u))(vt||{}),mt=(u=>(u[u.SameLayer=1]="SameLayer",u[u.SameGroup=2]="SameGroup",u[u.SameLayerAndGroup=3]="SameLayerAndGroup",u[u.All=4]="All",u[u.Single=5]="Single",u))(mt||{}),dt=(u=>(u[u.None=0]="None",u[u.E1D=1]="E1D",u))(dt||{}),de=(u=>(u[u.Additive=0]="Additive",u[u.Override=1]="Override",u))(de||{}),It=(u=>(u[u.IK=0]="IK",u[u.Path=1]="Path",u))(It||{}),Et=(u=>(u[u.Fixed=0]="Fixed",u[u.Percent=1]="Percent",u))(Et||{}),Tt=(u=>(u[u.Length=0]="Length",u[u.Fixed=1]="Fixed",u[u.Percent=2]="Percent",u))(Tt||{}),pt=(u=>(u[u.Tangent=0]="Tangent",u[u.Chain=1]="Chain",u[u.ChainScale=2]="ChainScale",u))(pt||{});class ut{constructor(l){a(this,"_clock",new me);a(this,"_events",[]);a(this,"_objects",[]);a(this,"_eventManager",null);this._eventManager=l}advanceTime(l){if(this._objects.length>0){for(const t of this._objects)t.returnToPool();this._objects.length=0}if(this._clock.advanceTime(l),this._events.length>0){for(let t=0;t=0?1:-1,this.currentPlayTimes=1,this.currentTime=this._actionTimeline.currentTime;else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){const n=this._animationState.playTimes,r=n*this._duration;t*=this._timeScale,this._timeOffset!==0&&(t+=this._timeOffset*this._animationData.duration),n>0&&(t>=r||t<=-r)?(this.playState<=0&&this._animationState._playheadState===3&&(this.playState=1),this.currentPlayTimes=n,t<0?this.currentTime=0:this.currentTime=this.playState===1?this._duration+1e-6:this._duration):(this.playState!==0&&this._animationState._playheadState===3&&(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===s?!1:((e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i)&&(this._frameIndex=-1),!0)}init(t,e,i){if(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._timelineData!==null){const s=this._animationData.parent.parent;this._frameArray=s.frameArray,this._timelineArray=s.timelineArray,this._frameIndices=s.frameIndices,this._frameCount=this._timelineArray[this._timelineData.offset+x.TimelineKeyFrameCount],this._frameValueOffset=this._timelineArray[this._timelineData.offset+x.TimelineFrameValueOffset],this._timeScale=100/this._timelineArray[this._timelineData.offset+x.TimelineScale],this._timeOffset=this._timelineArray[this._timelineData.offset+x.TimelineOffset]*.01}}fadeOut(){this.dirty=!1}update(t){if(this._setCurrentTime(t)){if(this._frameCount>1){const 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+x.TimelineFrameOffset+this._frameIndex],this._onArriveAtFrame())}else this._frameIndex<0&&(this._frameIndex=0,this._timelineData!==null&&(this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+x.TimelineFrameOffset]),this._onArriveAtFrame());(this._isTween||this.dirty)&&this._onUpdateFrame()}}blend(t){}}class Ot extends Rt{constructor(){super(...arguments);a(this,"_tweenType");a(this,"_curveCount");a(this,"_framePosition");a(this,"_frameDurationR");a(this,"_tweenEasing");a(this,"_tweenProgress");a(this,"_valueScale")}static _getEasingValue(t,e,i){let s=e;switch(t){case J.QuadIn:s=Math.pow(e,2);break;case J.QuadOut:s=1-Math.pow(1-e,2);break;case J.QuadInOut:s=.5*(1-Math.cos(e*Math.PI));break}return(s-e)*i+e}static _getEasingCurveValue(t,e,i,s){if(t<=0)return 0;if(t>=1)return 1;const n=i>0,r=i+1,o=Math.floor(t*r);let h=0,f=0;return n?(h=o===0?0:e[s+o-1],f=o===r-1?1e4:e[s+o]):(h=e[s+o-1],f=e[s+o]),(h+(f-h)*(t*r-o))*1e-4}_onClear(){super._onClear(),this._tweenType=J.None,this._curveCount=0,this._framePosition=0,this._frameDurationR=0,this._tweenEasing=0,this._tweenProgress=0,this._valueScale=1}_onArriveAtFrame(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0?this._frameDurationR=1/e:this._frameDurationR=0}else this.dirty=!0,this._isTween=!1}_onUpdateFrame(){this._isTween&&(this.dirty=!0,this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR,this._tweenType===J.Curve?this._tweenProgress=Ot._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+x.FrameCurveSamples):this._tweenType!==J.Line&&(this._tweenProgress=Ot._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)))}}class Pt extends Ot{constructor(){super(...arguments);a(this,"_current");a(this,"_difference");a(this,"_result")}_onClear(){super._onClear(),this._current=0,this._difference=0,this._result=0}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData!==null){const t=this._valueScale,e=this._valueArray,i=this._valueOffset+this._frameValueOffset+this._frameIndex;if(this._isTween){const s=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+1;t===1?(this._current=e[i],this._difference=e[s]-this._current):(this._current=e[i]*t,this._difference=e[s]*t-this._current)}else this._result=e[i]*t}else this._result=0}_onUpdateFrame(){super._onUpdateFrame(),this._isTween&&(this._result=this._current+this._difference*this._tweenProgress)}}class Bt extends Ot{constructor(){super(...arguments);a(this,"_currentA");a(this,"_currentB");a(this,"_differenceA");a(this,"_differenceB");a(this,"_resultA");a(this,"_resultB")}_onClear(){super._onClear(),this._currentA=0,this._currentB=0,this._differenceA=0,this._differenceB=0,this._resultA=0,this._resultB=0}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData!==null){const t=this._valueScale,e=this._valueArray,i=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(this._isTween){const s=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+2;t===1?(this._currentA=e[i],this._currentB=e[i+1],this._differenceA=e[s]-this._currentA,this._differenceB=e[s+1]-this._currentB):(this._currentA=e[i]*t,this._currentB=e[i+1]*t,this._differenceA=e[s]*t-this._currentA,this._differenceB=e[s+1]*t-this._currentB)}else this._resultA=e[i]*t,this._resultB=e[i+1]*t}else this._resultA=0,this._resultB=0}_onUpdateFrame(){super._onUpdateFrame(),this._isTween&&(this._resultA=this._currentA+this._differenceA*this._tweenProgress,this._resultB=this._currentB+this._differenceB*this._tweenProgress)}}class Xt extends Ot{constructor(){super(...arguments);a(this,"_valueCount");a(this,"_rd",[])}_onClear(){super._onClear(),this._valueCount=0,this._rd.length=0}_onArriveAtFrame(){super._onArriveAtFrame();const t=this._valueCount,e=this._rd;if(this._timelineData!==null){const i=this._valueScale,s=this._valueArray,n=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){const r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:n+t;if(i===1)for(let o=0;o0?-Math.PI:Math.PI,l}toString(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY}copyFrom(l){return this.x=l.x,this.y=l.y,this.skew=l.skew,this.rotation=l.rotation,this.scaleX=l.scaleX,this.scaleY=l.scaleY,this}identity(){return this.x=this.y=0,this.skew=this.rotation=0,this.scaleX=this.scaleY=1,this}add(l){return this.x+=l.x,this.y+=l.y,this.skew+=l.skew,this.rotation+=l.rotation,this.scaleX*=l.scaleX,this.scaleY*=l.scaleY,this}minus(l){return this.x-=l.x,this.y-=l.y,this.skew-=l.skew,this.rotation-=l.rotation,this.scaleX/=l.scaleX,this.scaleY/=l.scaleY,this}fromMatrix(l){const t=this.scaleX,e=this.scaleY,i=St.PI_Q;this.x=l.tx,this.y=l.ty,this.rotation=Math.atan(l.b/l.a);let s=Math.atan(-l.c/l.d);return this.scaleX=this.rotation>-i&&this.rotation-i&&s=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.rotation=this.rotation-Math.PI),e>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,s=s-Math.PI),this.skew=s-this.rotation,this}toMatrix(l){return this.rotation===0?(l.a=1,l.b=0):(l.a=Math.cos(this.rotation),l.b=Math.sin(this.rotation)),this.skew===0?(l.c=-l.b,l.d=l.a):(l.c=-Math.sin(this.skew+this.rotation),l.d=Math.cos(this.skew+this.rotation)),this.scaleX!==1&&(l.a*=this.scaleX,l.b*=this.scaleX),this.scaleY!==1&&(l.c*=this.scaleY,l.d*=this.scaleY),l.tx=this.x,l.ty=this.y,this}};a(St,"PI",Math.PI),a(St,"PI_D",Math.PI*2),a(St,"PI_H",Math.PI/2),a(St,"PI_Q",Math.PI/4),a(St,"RAD_DEG",180/Math.PI),a(St,"DEG_RAD",Math.PI/180);let v=St;class Xe extends Rt{static toString(){return"[class dragonBones.ActionTimelineState]"}_onCrossFrame(l){const t=this._armature.eventDispatcher;if(this._animationState.actionEnabled){const e=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+x.TimelineFrameOffset+l],i=this._frameArray[e+1],s=this._animationData.parent.actions;for(let n=0;n0&&n.hasDBEventListener(j.COMPLETE)&&(h=F.borrowObject(j),h.type=j.COMPLETE,h.armature=this._armature,h.animationState=this._animationState)),this._frameCount>1){const f=this._timelineData,m=Math.floor(this.currentTime*this._frameRate),d=this._frameIndices[f.frameIndicesOffset+m];if(this._frameIndex!==d){let c=this._frameIndex;if(this._frameIndex=d,this._timelineArray!==null)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[f.offset+x.TimelineFrameOffset+this._frameIndex],r){if(c<0){const A=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+A],this.currentPlayTimes===e&&c===d&&(c=-1)}for(;c>=0;){const A=this._animationData.frameOffset+this._timelineArray[f.offset+x.TimelineFrameOffset+c],p=this._frameArray[A]/this._frameRate;if(this._position<=p&&p<=this._position+this._duration&&this._onCrossFrame(c),o!==null&&c===0&&(this._armature._dragonBones.bufferEvent(o),o=null),c>0?c--:c=this._frameCount-1,c===d)break}}else{if(c<0){const A=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+A];const p=this._animationData.frameOffset+this._timelineArray[f.offset+x.TimelineFrameOffset+c],S=this._frameArray[p]/this._frameRate;this.currentPlayTimes===e&&(i<=S?c>0?c--:c=this._frameCount-1:c===d&&(c=-1))}for(;c>=0;){c=0&&(this._frameArray[this._frameOffset+1]>0?this._armature._sortZOrder(this._frameArray,this._frameOffset+2):this._armature._sortZOrder(null,0))}_onUpdateFrame(){}}class ye extends Xt{static toString(){return"[class dragonBones.BoneAllTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._isTween&&this._frameIndex===this._frameCount-1&&(this._rd[2]=v.normalizeRadian(this._rd[2]),this._rd[3]=v.normalizeRadian(this._rd[3])),this._timelineData===null&&(this._rd[4]=1,this._rd[5]=1)}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameFloatOffset,this._valueCount=6,this._valueArray=this._animationData.parent.parent.frameFloatArray}fadeOut(){this.dirty=!1,this._rd[2]=v.normalizeRadian(this._rd[2]),this._rd[3]=v.normalizeRadian(this._rd[3])}blend(l){const t=this._armature.armatureData.scale,e=this._rd,i=this.target,s=i.target,n=i.blendWeight,r=s.animationPose;i.dirty>1?(r.x+=e[0]*n*t,r.y+=e[1]*n*t,r.rotation+=e[2]*n,r.skew+=e[3]*n,r.scaleX+=(e[4]-1)*n,r.scaleY+=(e[5]-1)*n):(r.x=e[0]*n*t,r.y=e[1]*n*t,r.rotation=e[2]*n,r.skew=e[3]*n,r.scaleX=(e[4]-1)*n+1,r.scaleY=(e[5]-1)*n+1),(l||this.dirty)&&(this.dirty=!1,s._transformDirty=!0)}}class je extends Bt{static toString(){return"[class dragonBones.BoneTranslateTimelineState]"}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameFloatOffset,this._valueScale=this._armature.armatureData.scale,this._valueArray=this._animationData.parent.parent.frameFloatArray}blend(l){const t=this.target,e=t.target,i=t.blendWeight,s=e.animationPose;t.dirty>1?(s.x+=this._resultA*i,s.y+=this._resultB*i):i!==1?(s.x=this._resultA*i,s.y=this._resultB*i):(s.x=this._resultA,s.y=this._resultB),(l||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class ze extends Bt{static toString(){return"[class dragonBones.BoneRotateTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._isTween&&this._frameIndex===this._frameCount-1&&(this._differenceA=v.normalizeRadian(this._differenceA),this._differenceB=v.normalizeRadian(this._differenceB))}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameFloatOffset,this._valueArray=this._animationData.parent.parent.frameFloatArray}fadeOut(){this.dirty=!1,this._resultA=v.normalizeRadian(this._resultA),this._resultB=v.normalizeRadian(this._resultB)}blend(l){const t=this.target,e=t.target,i=t.blendWeight,s=e.animationPose;t.dirty>1?(s.rotation+=this._resultA*i,s.skew+=this._resultB*i):i!==1?(s.rotation=this._resultA*i,s.skew=this._resultB*i):(s.rotation=this._resultA,s.skew=this._resultB),(l||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class He extends Bt{static toString(){return"[class dragonBones.BoneScaleTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._timelineData===null&&(this._resultA=1,this._resultB=1)}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameFloatOffset,this._valueArray=this._animationData.parent.parent.frameFloatArray}blend(l){const t=this.target,e=t.target,i=t.blendWeight,s=e.animationPose;t.dirty>1?(s.scaleX+=(this._resultA-1)*i,s.scaleY+=(this._resultB-1)*i):i!==1?(s.scaleX=(this._resultA-1)*i+1,s.scaleY=(this._resultB-1)*i+1):(s.scaleX=this._resultA,s.scaleY=this._resultB),(l||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class ge extends Xt{constructor(){super(...arguments);a(this,"_deformCount");a(this,"_deformOffset");a(this,"_sameValueOffset")}static toString(){return"[class dragonBones.SurfaceTimelineState]"}_onClear(){super._onClear(),this._deformCount=0,this._deformOffset=0,this._sameValueOffset=0}init(t,e,i){if(super.init(t,e,i),this._timelineData!==null){const s=this._animationData.parent.parent,n=s.frameIntArray,r=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+x.TimelineFrameValueCount];this._valueOffset=this._animationData.frameFloatOffset,this._valueCount=n[r+x.DeformValueCount],this._deformCount=n[r+x.DeformCount],this._deformOffset=n[r+x.DeformValueOffset],this._sameValueOffset=n[r+x.DeformFloatOffset]+this._animationData.frameFloatOffset,this._valueScale=this._armature.armatureData.scale,this._valueArray=s.frameFloatArray,this._rd.length=this._valueCount*2}else this._deformCount=this.target.target._deformVertices.length}blend(t){const e=this.target,i=e.target,s=e.blendWeight,n=i._deformVertices,r=this._valueArray;if(r!==null){const o=this._valueCount,h=this._deformOffset,f=this._sameValueOffset,m=this._rd;for(let d=0;d1?n[d]+=c*s:n[d]=c*s}}else if(e.dirty===1)for(let o=0;o1?(e._alpha+=this._result*i,e._alpha>1&&(e._alpha=1)):e._alpha=this._result*i,(l||this.dirty)&&(this.dirty=!1,this._armature._alphaDirty=!0)}}class Ae extends Rt{static toString(){return"[class dragonBones.SlotDisplayTimelineState]"}_onArriveAtFrame(){if(this.playState>=0){const l=this.target,t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:l._slotData.displayIndex;l.displayIndex!==t&&l._setDisplayIndex(t,!0)}}_onUpdateFrame(){}}class be extends Ot{constructor(){super(...arguments);a(this,"_current",[0,0,0,0,0,0,0,0]);a(this,"_difference",[0,0,0,0,0,0,0,0]);a(this,"_result",[0,0,0,0,0,0,0,0])}static toString(){return"[class dragonBones.SlotColorTimelineState]"}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData!==null){const t=this._animationData.parent.parent,e=t.colorArray,i=t.frameIntArray,s=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;let n=i[s];n<0&&(n+=65536),this._isTween?(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++],this._frameIndex===this._frameCount-1?n=i[this._animationData.frameIntOffset+this._frameValueOffset]:n=i[s+1],n<0&&(n+=65536),this._difference[0]=e[n++]-this._current[0],this._difference[1]=e[n++]-this._current[1],this._difference[2]=e[n++]-this._current[2],this._difference[3]=e[n++]-this._current[3],this._difference[4]=e[n++]-this._current[4],this._difference[5]=e[n++]-this._current[5],this._difference[6]=e[n++]-this._current[6],this._difference[7]=e[n++]-this._current[7]):(this._result[0]=e[n++]*.01,this._result[1]=e[n++]*.01,this._result[2]=e[n++]*.01,this._result[3]=e[n++]*.01,this._result[4]=e[n++],this._result[5]=e[n++],this._result[6]=e[n++],this._result[7]=e[n++])}else{const e=this.target.slotData.color;this._result[0]=e.alphaMultiplier,this._result[1]=e.redMultiplier,this._result[2]=e.greenMultiplier,this._result[3]=e.blueMultiplier,this._result[4]=e.alphaOffset,this._result[5]=e.redOffset,this._result[6]=e.greenOffset,this._result[7]=e.blueOffset}}_onUpdateFrame(){super._onUpdateFrame(),this._isTween&&(this._result[0]=(this._current[0]+this._difference[0]*this._tweenProgress)*.01,this._result[1]=(this._current[1]+this._difference[1]*this._tweenProgress)*.01,this._result[2]=(this._current[2]+this._difference[2]*this._tweenProgress)*.01,this._result[3]=(this._current[3]+this._difference[3]*this._tweenProgress)*.01,this._result[4]=this._current[4]+this._difference[4]*this._tweenProgress,this._result[5]=this._current[5]+this._difference[5]*this._tweenProgress,this._result[6]=this._current[6]+this._difference[6]*this._tweenProgress,this._result[7]=this._current[7]+this._difference[7]*this._tweenProgress)}fadeOut(){this._isTween=!1}update(t){if(super.update(t),this._isTween||this.dirty){const e=this.target,i=e._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){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]){const s=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*s,i.redMultiplier+=(this._result[1]-i.redMultiplier)*s,i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*s,i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*s,i.alphaOffset+=(this._result[4]-i.alphaOffset)*s,i.redOffset+=(this._result[5]-i.redOffset)*s,i.greenOffset+=(this._result[6]-i.greenOffset)*s,i.blueOffset+=(this._result[7]-i.blueOffset)*s,e._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],e._colorDirty=!0))}}}class Ke extends Pt{static toString(){return"[class dragonBones.SlotZIndexTimelineState]"}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData===null){const t=this.target.target;this._result=t.slotData.zIndex}}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameIntOffset,this._valueArray=this._animationData.parent.parent.frameIntArray}blend(l){const t=this.target,e=t.target,i=t.blendWeight;t.dirty>1?e._zIndex+=this._result*i:e._zIndex=this._result*i,(l||this.dirty)&&(this.dirty=!1,this._armature._zIndexDirty=!0)}}class Se extends Xt{constructor(){super(...arguments);a(this,"geometryOffset");a(this,"displayFrame");a(this,"_deformCount");a(this,"_deformOffset");a(this,"_sameValueOffset")}static toString(){return"[class dragonBones.DeformTimelineState]"}_onClear(){super._onClear(),this.geometryOffset=0,this.displayFrame=null,this._deformCount=0,this._deformOffset=0,this._sameValueOffset=0}init(t,e,i){if(super.init(t,e,i),this._timelineData!==null){const s=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+x.TimelineFrameValueCount],n=this._animationData.parent.parent,r=n.frameIntArray,o=this.target.target;this.geometryOffset=r[s+x.DeformVertexOffset],this.geometryOffset<0&&(this.geometryOffset+=65536);for(let h=0,f=o.displayFrameCount;h1?n[d]+=c*s:n[d]=c*s}}else if(e.dirty===1)for(let o=0;o0,l._weight=this._currentB;else{const t=l._constraintData;l._bendPositive=t.bendPositive,l._weight=t.weight}l.invalidUpdate(),this.dirty=!1}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameIntOffset,this._valueScale=.01,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Ze extends Pt{static toString(){return"[class dragonBones.AnimationProgressTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const l=this.target;l._parent!==null&&(l.currentTime=this._result*l.totalTime),this.dirty=!1}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class qe extends Pt{static toString(){return"[class dragonBones.AnimationWeightTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const l=this.target;l._parent!==null&&(l.weight=this._result),this.dirty=!1}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Qe extends Bt{static toString(){return"[class dragonBones.AnimationParametersTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const l=this.target;l._parent!==null&&(l.parameterX=this._resultA,l.parameterY=this._resultB),this.dirty=!1}init(l,t,e){super.init(l,t,e),this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Oe extends F{constructor(){super(...arguments);a(this,"actionEnabled");a(this,"additive");a(this,"displayControl");a(this,"resetToPose");a(this,"blendType");a(this,"playTimes");a(this,"layer");a(this,"timeScale");a(this,"parameterX");a(this,"parameterY");a(this,"positionX");a(this,"positionY");a(this,"autoFadeOutTime");a(this,"fadeTotalTime");a(this,"name");a(this,"group");a(this,"_timelineDirty");a(this,"_playheadState");a(this,"_fadeState");a(this,"_subFadeState");a(this,"_position");a(this,"_duration");a(this,"_weight");a(this,"_fadeTime");a(this,"_time");a(this,"_fadeProgress");a(this,"_weightResult");a(this,"_boneMask",[]);a(this,"_boneTimelines",[]);a(this,"_boneBlendTimelines",[]);a(this,"_slotTimelines",[]);a(this,"_slotBlendTimelines",[]);a(this,"_constraintTimelines",[]);a(this,"_animationTimelines",[]);a(this,"_poseTimelines",[]);a(this,"_animationData");a(this,"_armature");a(this,"_actionTimeline",null);a(this,"_zOrderTimeline",null);a(this,"_activeChildA");a(this,"_activeChildB");a(this,"_parent")}static toString(){return"[class dragonBones.AnimationState]"}_onClear(){for(const t of this._boneTimelines)t.returnToPool();for(const t of this._boneBlendTimelines)t.returnToPool();for(const t of this._slotTimelines)t.returnToPool();for(const t of this._slotBlendTimelines)t.returnToPool();for(const t of this._constraintTimelines)t.returnToPool();for(const t of this._animationTimelines){const e=t.target;e._parent===this&&(e._fadeState=1,e._subFadeState=1,e._parent=null),t.returnToPool()}this._actionTimeline!==null&&this._actionTimeline.returnToPool(),this._zOrderTimeline!==null&&this._zOrderTimeline.returnToPool(),this.actionEnabled=!1,this.additive=!1,this.displayControl=!1,this.resetToPose=!1,this.blendType=dt.None,this.playTimes=1,this.layer=0,this.timeScale=1,this._weight=1,this.parameterX=0,this.parameterY=0,this.positionX=0,this.positionY=0,this.autoFadeOutTime=0,this.fadeTotalTime=0,this.name="",this.group="",this._timelineDirty=2,this._playheadState=0,this._fadeState=-1,this._subFadeState=-1,this._position=0,this._duration=0,this._fadeTime=0,this._time=0,this._fadeProgress=0,this._weightResult=0,this._boneMask.length=0,this._boneTimelines.length=0,this._boneBlendTimelines.length=0,this._slotTimelines.length=0,this._slotBlendTimelines.length=0,this._constraintTimelines.length=0,this._animationTimelines.length=0,this._poseTimelines.length=0,this._animationData=null,this._armature=null,this._actionTimeline=null,this._zOrderTimeline=null,this._activeChildA=null,this._activeChildB=null,this._parent=null}_updateTimelines(){for(const t of this._armature._constraints){const e=this._animationData.getConstraintTimelines(t.name);if(e!==null)for(const i of e)switch(i.type){case E.IKConstraint:{const s=F.borrowObject(De);s.target=t,s.init(this._armature,this,i),this._constraintTimelines.push(s);break}}else if(this.resetToPose){const i=F.borrowObject(De);i.target=t,i.init(this._armature,this,null),this._constraintTimelines.push(i),this._poseTimelines.push(i)}}}_updateBoneAndSlotTimelines(){{const t={};for(const e of this._boneTimelines){const i=e.target.target.name;i in t||(t[i]=[]),t[i].push(e)}for(const e of this._boneBlendTimelines){const i=e.target.target.name;i in t||(t[i]=[]),t[i].push(e)}for(const e of this._armature.getBones()){const i=e.name;if(this.containsBoneMask(i))if(i in t)delete t[i];else{const s=this._animationData.getBoneTimelines(i),n=this._armature.animation.getBlendState(lt.BONE_TRANSFORM,e.name,e);if(s!==null)for(const r of s)switch(r.type){case E.BoneAll:{const o=F.borrowObject(ye);o.target=n,o.init(this._armature,this,r),this._boneTimelines.push(o);break}case E.BoneTranslate:{const o=F.borrowObject(je);o.target=n,o.init(this._armature,this,r),this._boneTimelines.push(o);break}case E.BoneRotate:{const o=F.borrowObject(ze);o.target=n,o.init(this._armature,this,r),this._boneTimelines.push(o);break}case E.BoneScale:{const o=F.borrowObject(He);o.target=n,o.init(this._armature,this,r),this._boneTimelines.push(o);break}case E.BoneAlpha:{const o=F.borrowObject(Te);o.target=this._armature.animation.getBlendState(lt.BONE_ALPHA,e.name,e),o.init(this._armature,this,r),this._boneBlendTimelines.push(o);break}case E.Surface:{const o=F.borrowObject(ge);o.target=this._armature.animation.getBlendState(lt.SURFACE,e.name,e),o.init(this._armature,this,r),this._boneBlendTimelines.push(o);break}}else if(this.resetToPose)if(e._boneData.type===$.Bone){const r=F.borrowObject(ye);r.target=n,r.init(this._armature,this,null),this._boneTimelines.push(r),this._poseTimelines.push(r)}else{const r=F.borrowObject(ge);r.target=this._armature.animation.getBlendState(lt.SURFACE,e.name,e),r.init(this._armature,this,null),this._boneBlendTimelines.push(r),this._poseTimelines.push(r)}}}for(let e in t)for(const i of t[e]){let s=this._boneTimelines.indexOf(i);s>=0&&(this._boneTimelines.splice(s,1),i.returnToPool()),s=this._boneBlendTimelines.indexOf(i),s>=0&&(this._boneBlendTimelines.splice(s,1),i.returnToPool())}}{const t={},e=[];for(const i of this._slotTimelines){const s=i.target.name;s in t||(t[s]=[]),t[s].push(i)}for(const i of this._slotBlendTimelines){const s=i.target.target.name;s in t||(t[s]=[]),t[s].push(i)}for(const i of this._armature.getSlots()){const s=i.parent.name;if(!this.containsBoneMask(s))continue;const n=i.name;if(n in t)delete t[n];else{let r=!1,o=!1;e.length=0;const h=this._animationData.getSlotTimelines(n);if(h!==null)for(const f of h)switch(f.type){case E.SlotDisplay:{const m=F.borrowObject(Ae);m.target=i,m.init(this._armature,this,f),this._slotTimelines.push(m),r=!0;break}case E.SlotZIndex:{const m=F.borrowObject(Ke);m.target=this._armature.animation.getBlendState(lt.SLOT_Z_INDEX,i.name,i),m.init(this._armature,this,f),this._slotBlendTimelines.push(m);break}case E.SlotColor:{const m=F.borrowObject(be);m.target=i,m.init(this._armature,this,f),this._slotTimelines.push(m),o=!0;break}case E.SlotDeform:{const m=F.borrowObject(Se);m.target=this._armature.animation.getBlendState(lt.SLOT_DEFORM,i.name,i),m.init(this._armature,this,f),m.target!==null?(this._slotBlendTimelines.push(m),e.push(m.geometryOffset)):m.returnToPool();break}case E.SlotAlpha:{const m=F.borrowObject(Te);m.target=this._armature.animation.getBlendState(lt.SLOT_ALPHA,i.name,i),m.init(this._armature,this,f),this._slotBlendTimelines.push(m);break}}if(this.resetToPose){if(!r){const f=F.borrowObject(Ae);f.target=i,f.init(this._armature,this,null),this._slotTimelines.push(f),this._poseTimelines.push(f)}if(!o){const f=F.borrowObject(be);f.target=i,f.init(this._armature,this,null),this._slotTimelines.push(f),this._poseTimelines.push(f)}for(let f=0,m=i.displayFrameCount;f=0&&(this._slotTimelines.splice(n,1),s.returnToPool()),n=this._slotBlendTimelines.indexOf(s),n>=0&&(this._slotBlendTimelines.splice(n,1),s.returnToPool())}}}_advanceFadeTime(t){const e=this._fadeState>0;if(this._subFadeState<0&&(this._subFadeState=0,this._parent===null&&this.actionEnabled)){const s=e?j.FADE_OUT:j.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(s)){const n=F.borrowObject(j);n.type=s,n.armature=this._armature,n.animationState=this,this._armature._dragonBones.bufferEvent(n)}}if(t<0&&(t=-t),this._fadeTime+=t,this._fadeTime>=this.fadeTotalTime?(this._subFadeState=1,this._fadeProgress=e?0:1):this._fadeTime>0?this._fadeProgress=e?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeProgress=e?1:0,this._subFadeState>0&&(e||(this._playheadState|=1,this._fadeState=0),this._parent===null&&this.actionEnabled)){const s=e?j.FADE_OUT_COMPLETE:j.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(s)){const n=F.borrowObject(j);n.type=s,n.armature=this._armature,n.animationState=this,this._armature._dragonBones.bufferEvent(n)}}}init(t,e,i){if(this._armature===null){if(this._armature=t,this._animationData=e,this.resetToPose=i.resetToPose,this.additive=i.additive,this.displayControl=i.displayControl,this.actionEnabled=i.actionEnabled,this.blendType=e.blendType,this.layer=i.layer,this.playTimes=i.playTimes,this.timeScale=i.timeScale,this.fadeTotalTime=i.fadeInTime,this.autoFadeOutTime=i.autoFadeOutTime,this.name=i.name.length>0?i.name:i.animation,this.group=i.group,this._weight=i.weight,i.pauseFadeIn?this._playheadState=2:this._playheadState=3,i.duration<0?(this._position=0,this._duration=this._animationData.duration,i.position!==0?this.timeScale>=0?this._time=i.position:this._time=i.position-this._duration:this._time=0):(this._position=i.position,this._duration=i.duration,this._time=0),this.timeScale<0&&this._time===0&&(this._time=-1e-6),this.fadeTotalTime<=0&&(this._fadeProgress=.999999),i.boneMask.length>0){this._boneMask.length=i.boneMask.length;for(let s=0,n=this._boneMask.length;s0;let n=!0,r=!0,o=this._time;if(this._weightResult=this._weight*this._fadeProgress,this._parent!==null&&(this._weightResult*=this._parent._weightResult),this._actionTimeline.playState<=0&&this._actionTimeline.update(o),this._weight!==0){if(s){const h=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*h)/h}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0&&this._zOrderTimeline.update(o),s){const h=Math.floor(this._actionTimeline.currentTime*e);this._armature._cacheFrameIndex===h?(n=!1,r=!1):(this._armature._cacheFrameIndex=h,this._animationData.cachedFrames[h]?r=!1:this._animationData.cachedFrames[h]=!0)}if(n){let h=!1,f=null;if(r)for(let m=0,d=this._boneTimelines.length;m0){let m=100,d=100,c=null,A=null;for(let p=0,S=this._animationTimelines.length;p=0?g0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(const h of this._poseTimelines){let f=this._boneTimelines.indexOf(h);if(f>=0){this._boneTimelines.splice(f,1),h.returnToPool();continue}if(f=this._boneBlendTimelines.indexOf(h),f>=0){this._boneBlendTimelines.splice(f,1),h.returnToPool();continue}if(f=this._slotTimelines.indexOf(h),f>=0){this._slotTimelines.splice(f,1),h.returnToPool();continue}if(f=this._slotBlendTimelines.indexOf(h),f>=0){this._slotBlendTimelines.splice(f,1),h.returnToPool();continue}if(f=this._constraintTimelines.indexOf(h),f>=0){this._constraintTimelines.splice(f,1),h.returnToPool();continue}}this._poseTimelines.length=0}this._actionTimeline.playState>0&&this.autoFadeOutTime>=0&&this.fadeOut(this.autoFadeOutTime)}}}play(){this._playheadState=3}stop(){this._playheadState&=1}fadeOut(t,e=!0){if(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(const i of this._boneTimelines)i.fadeOut();for(const i of this._boneBlendTimelines)i.fadeOut();for(const i of this._slotTimelines)i.fadeOut();for(const i of this._slotBlendTimelines)i.fadeOut();for(const i of this._constraintTimelines)i.fadeOut();for(const i of this._animationTimelines)i.fadeOut(),i.target.fadeOut(999999,!0)}this.displayControl=!1,this.fadeTotalTime=this._fadeProgress>1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)}containsBoneMask(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0}addBoneMask(t,e=!0){const i=this._armature.getBone(t);if(i!==null){if(this._boneMask.indexOf(t)<0&&this._boneMask.push(t),e)for(const s of this._armature.getBones())this._boneMask.indexOf(s.name)<0&&i.contains(s)&&this._boneMask.push(s.name);this._timelineDirty=1}}removeBoneMask(t,e=!0){const i=this._boneMask.indexOf(t);if(i>=0&&this._boneMask.splice(i,1),e){const s=this._armature.getBone(t);if(s!==null){const n=this._armature.getBones();if(this._boneMask.length>0)for(const r of n){const o=this._boneMask.indexOf(r.name);o>=0&&s.contains(r)&&this._boneMask.splice(o,1)}else for(const r of n)r!==s&&(s.contains(r)||this._boneMask.push(r.name))}}this._timelineDirty=1}removeAllBoneMask(){this._boneMask.length=0,this._timelineDirty=1}addState(t,e=null){if(e!==null)for(const i of e)switch(i.type){case E.AnimationProgress:{const s=F.borrowObject(Ze);if(s.target=t,s.init(this._armature,this,i),this._animationTimelines.push(s),this.blendType!==dt.None){const n=i;t.positionX=n.x,t.positionY=n.y,t.weight=0}t._parent=this,this.resetToPose=!1;break}case E.AnimationWeight:{const s=F.borrowObject(qe);s.target=t,s.init(this._armature,this,i),this._animationTimelines.push(s);break}case E.AnimationParameter:{const s=F.borrowObject(Qe);s.target=t,s.init(this._armature,this,i),this._animationTimelines.push(s);break}}t._parent===null&&(t._parent=this)}activeTimeline(){for(const t of this._slotTimelines)t.dirty=!0,t.currentTime=-1}get isFadeIn(){return this._fadeState<0}get isFadeOut(){return this._fadeState>0}get isFadeComplete(){return this._fadeState===0}get isPlaying(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0}get isCompleted(){return this._actionTimeline.playState>0}get currentPlayTimes(){return this._actionTimeline.currentPlayTimes}get totalTime(){return this._duration}get currentTime(){return this._actionTimeline.currentTime}set currentTime(t){const e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if((t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&this._parent===null&&(t=this._duration-1e-6),this._time!==t){this._time=t,this._actionTimeline.setCurrentTime(this._time),this._zOrderTimeline!==null&&(this._zOrderTimeline.playState=-1);for(const i of this._boneTimelines)i.playState=-1;for(const i of this._slotTimelines)i.playState=-1}}get weight(){return this._weight}set weight(t){if(this._weight!==t){this._weight=t;for(const e of this._boneTimelines)e.dirty=!0;for(const e of this._boneBlendTimelines)e.dirty=!0;for(const e of this._slotBlendTimelines)e.dirty=!0}}get animationData(){return this._animationData}}class lt extends F{constructor(){super(...arguments);a(this,"dirty");a(this,"layer");a(this,"leftWeight");a(this,"layerWeight");a(this,"blendWeight");a(this,"target")}static toString(){return"[class dragonBones.BlendState]"}_onClear(){this.reset(),this.target=null}update(t){const e=t.layer;let i=t._weightResult;if(this.dirty>0){if(this.leftWeight>0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight)return this.dirty++,this.layer=e,this.leftWeight=0,this.blendWeight=0,!1;this.layer=e,this.leftWeight-=this.layerWeight,this.layerWeight=0}return i*=this.leftWeight,this.dirty++,this.blendWeight=i,this.layerWeight+=this.blendWeight,!0}return!1}return this.dirty++,this.layer=e,this.leftWeight=1,this.blendWeight=i,this.layerWeight=i,!0}reset(){this.dirty=0,this.layer=0,this.leftWeight=0,this.layerWeight=0,this.blendWeight=0}}a(lt,"BONE_TRANSFORM","boneTransform"),a(lt,"BONE_ALPHA","boneAlpha"),a(lt,"SURFACE","surface"),a(lt,"SLOT_DEFORM","slotDeform"),a(lt,"SLOT_ALPHA","slotAlpha"),a(lt,"SLOT_Z_INDEX","slotZIndex");class xe extends F{constructor(){super(...arguments);a(this,"timeScale");a(this,"_animationDirty");a(this,"_inheritTimeScale");a(this,"_animationNames",[]);a(this,"_animationStates",[]);a(this,"_animations",{});a(this,"_blendStates",{});a(this,"_armature");a(this,"_animationConfig",null);a(this,"_lastAnimationState")}static toString(){return"[class dragonBones.Animation]"}_onClear(){for(const t of this._animationStates)t.returnToPool();for(let t in this._animations)delete this._animations[t];for(let t in this._blendStates){const e=this._blendStates[t];for(let i in e)e[i].returnToPool();delete this._blendStates[t]}this._animationConfig!==null&&this._animationConfig.returnToPool(),this.timeScale=1,this._animationDirty=!1,this._inheritTimeScale=1,this._animationNames.length=0,this._animationStates.length=0,this._armature=null,this._animationConfig=null,this._lastAnimationState=null}_fadeOut(t){switch(t.fadeOutMode){case mt.SameLayer:for(const e of this._animationStates)e._parent===null&&e.layer===t.layer&&e.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.SameGroup:for(const e of this._animationStates)e._parent===null&&e.group===t.group&&e.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.SameLayerAndGroup:for(const e of this._animationStates)e._parent===null&&e.layer===t.layer&&e.group===t.group&&e.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.All:for(const e of this._animationStates)e._parent===null&&e.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.Single:}}init(t){this._armature===null&&(this._armature=t,this._animationConfig=F.borrowObject(pe))}advanceTime(t){t<0&&(t=-t),this._armature.inheritAnimation&&this._armature._parent!==null?this._inheritTimeScale=this._armature._parent._armature.animation._inheritTimeScale*this.timeScale:this._inheritTimeScale=this.timeScale,this._inheritTimeScale!==1&&(t*=this._inheritTimeScale);for(let i in this._blendStates){const s=this._blendStates[i];for(let n in s)s[n].reset()}const e=this._animationStates.length;if(e===1){const i=this._animationStates[0];if(i._fadeState>0&&i._subFadeState>0)this._armature._dragonBones.bufferObject(i),this._animationStates.length=0,this._lastAnimationState=null;else{const s=i.animationData,n=s.cacheFrameRate;if(this._animationDirty&&n>0){this._animationDirty=!1;for(const r of this._armature.getBones())r._cachedFrameIndices=s.getBoneCachedFrameIndices(r.name);for(const r of this._armature.getSlots()){if(r.displayFrameCount>0){const o=r.getDisplayFrameAt(0).rawDisplayData;if(o!==null&&o.parent===this._armature.armatureData.defaultSkin){r._cachedFrameIndices=s.getSlotCachedFrameIndices(r.name);continue}}r._cachedFrameIndices=null}}i.advanceTime(t,n)}}else if(e>1){for(let i=0,s=0;i0&&n._subFadeState>0?(s++,this._armature._dragonBones.bufferObject(n),this._animationDirty=!0,this._lastAnimationState===n&&(this._lastAnimationState=null)):(s>0&&(this._animationStates[i-s]=n),n.advanceTime(t,0)),i===e-1&&s>0&&(this._animationStates.length-=s,this._lastAnimationState===null&&this._animationStates.length>0&&(this._lastAnimationState=this._animationStates[this._animationStates.length-1]))}this._armature._cacheFrameIndex=-1}else this._armature._cacheFrameIndex=-1}reset(){for(const t of this._animationStates)t.returnToPool();this._animationDirty=!1,this._animationConfig.clear(),this._animationStates.length=0,this._lastAnimationState=null}stop(t=null){if(t!==null){const e=this.getState(t);e!==null&&e.stop()}else for(const e of this._animationStates)e.stop()}playConfig(t){const e=t.animation;if(!(e in this._animations))return console.warn(`Non-existent animation. `,"DragonBones name: "+this._armature.armatureData.parent.name,"Armature name: "+this._armature.name,"Animation name: "+e),null;const i=this._animations[e];if(t.fadeOutMode===mt.Single){for(const n of this._animationStates)if(n._fadeState<1&&n.layer===t.layer&&n.animationData===i)return n}this._animationStates.length===0?t.fadeInTime=0:t.fadeInTime<0&&(t.fadeInTime=i.fadeInTime),t.fadeOutTime<0&&(t.fadeOutTime=t.fadeInTime),t.timeScale<=-100&&(t.timeScale=1/i.scale),i.frameCount>0?(t.position<0?(t.position%=i.duration,t.position=i.duration-t.position):t.position===i.duration?t.position-=1e-6:t.position>i.duration&&(t.position%=i.duration),t.duration>0&&t.position+t.duration>i.duration&&(t.duration=i.duration-t.position),t.playTimes<0&&(t.playTimes=i.playTimes)):(t.playTimes=1,t.position=0,t.duration>0&&(t.duration=0)),t.duration===0&&(t.duration=-1),this._fadeOut(t);const s=F.borrowObject(Oe);if(s.init(this._armature,i,t),this._animationDirty=!0,this._armature._cacheFrameIndex=-1,this._animationStates.length>0){let n=!1;for(let r=0,o=this._animationStates.length;rthis._animationStates[r].layer){n=!0,this._animationStates.splice(r,0,s);break}else if(r!==o-1&&s.layer>this._animationStates[r+1].layer){n=!0,this._animationStates.splice(r+1,0,s);break}n||this._animationStates.push(s)}else this._animationStates.push(s);for(const n of this._armature.getSlots()){const r=n.childArmature;r!==null&&r.inheritAnimation&&r.animation.hasAnimation(e)&&r.animation.getState(e)===null&&r.animation.fadeIn(e)}for(let n in i.animationTimelines){const r=this.fadeIn(n,0,1,s.layer,"",mt.Single);if(r===null)continue;const o=i.animationTimelines[n];r.actionEnabled=!1,r.resetToPose=!1,r.stop(),s.addState(r,o);const h=this._animationStates.indexOf(s),f=this._animationStates.indexOf(r);f0)this.playConfig(this._animationConfig);else if(this._lastAnimationState===null){const i=this._armature.armatureData.defaultAnimation;i!==null&&(this._animationConfig.animation=i.name,this.playConfig(this._animationConfig))}else!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted?this._lastAnimationState.play():(this._animationConfig.animation=this._lastAnimationState.name,this.playConfig(this._animationConfig));return this._lastAnimationState}fadeIn(t,e=-1,i=-1,s=0,n=null,r=mt.SameLayerAndGroup){return this._animationConfig.clear(),this._animationConfig.fadeOutMode=r,this._animationConfig.playTimes=i,this._animationConfig.layer=s,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=n!==null?n:"",this.playConfig(this._animationConfig)}gotoAndPlayByTime(t,e=0,i=-1){return 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)}gotoAndPlayByFrame(t,e=0,i=-1){this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;const s=t in this._animations?this._animations[t]:null;return s!==null&&(this._animationConfig.position=s.frameCount>0?s.duration*e/s.frameCount:0),this.playConfig(this._animationConfig)}gotoAndPlayByProgress(t,e=0,i=-1){this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;const s=t in this._animations?this._animations[t]:null;return s!==null&&(this._animationConfig.position=s.duration*(e>0?e:0)),this.playConfig(this._animationConfig)}gotoAndStopByTime(t,e=0){const i=this.gotoAndPlayByTime(t,e,1);return i!==null&&i.stop(),i}gotoAndStopByFrame(t,e=0){const i=this.gotoAndPlayByFrame(t,e,1);return i!==null&&i.stop(),i}gotoAndStopByProgress(t,e=0){const i=this.gotoAndPlayByProgress(t,e,1);return i!==null&&i.stop(),i}getBlendState(t,e,i){t in this._blendStates||(this._blendStates[t]={});const s=this._blendStates[t];if(!(e in s)){const n=s[e]=F.borrowObject(lt);n.target=i}return s[e]}getState(t,e=-1){let i=this._animationStates.length;for(;i--;){const s=this._animationStates[i];if(s.name===t&&(e<0||s.layer===e))return s}return null}hasAnimation(t){return t in this._animations}getStates(){return this._animationStates}get isPlaying(){for(const t of this._animationStates)if(t.isPlaying)return!0;return!1}get isCompleted(){for(const t of this._animationStates)if(!t.isCompleted)return!1;return this._animationStates.length>0}get lastAnimationName(){return this._lastAnimationState!==null?this._lastAnimationState.name:""}get animationNames(){return this._animationNames}get animations(){return this._animations}set animations(t){if(this._animations!==t){this._animationNames.length=0;for(let e in this._animations)delete this._animations[e];for(let e in t)this._animationNames.push(e),this._animations[e]=t[e]}}get animationConfig(){return this._animationConfig.clear(),this._animationConfig}get lastAnimationState(){return this._lastAnimationState}}class te extends F{constructor(){super(...arguments);a(this,"frameIntOffset");a(this,"frameFloatOffset");a(this,"frameOffset");a(this,"blendType");a(this,"frameCount");a(this,"playTimes");a(this,"duration");a(this,"scale");a(this,"fadeInTime");a(this,"cacheFrameRate");a(this,"name");a(this,"cachedFrames",[]);a(this,"boneTimelines",{});a(this,"slotTimelines",{});a(this,"constraintTimelines",{});a(this,"animationTimelines",{});a(this,"boneCachedFrameIndices",{});a(this,"slotCachedFrameIndices",{});a(this,"actionTimeline",null);a(this,"zOrderTimeline",null);a(this,"parent")}static toString(){return"[class dragonBones.AnimationData]"}_onClear(){for(let t in this.boneTimelines){for(const e of this.boneTimelines[t])e.returnToPool();delete this.boneTimelines[t]}for(let t in this.slotTimelines){for(const e of this.slotTimelines[t])e.returnToPool();delete this.slotTimelines[t]}for(let t in this.constraintTimelines){for(const e of this.constraintTimelines[t])e.returnToPool();delete this.constraintTimelines[t]}for(let t in this.animationTimelines){for(const e of this.animationTimelines[t])e.returnToPool();delete this.animationTimelines[t]}for(let t in this.boneCachedFrameIndices)delete this.boneCachedFrameIndices[t];for(let t in this.slotCachedFrameIndices)delete this.slotCachedFrameIndices[t];this.actionTimeline!==null&&this.actionTimeline.returnToPool(),this.zOrderTimeline!==null&&this.zOrderTimeline.returnToPool(),this.frameIntOffset=0,this.frameFloatOffset=0,this.frameOffset=0,this.blendType=dt.None,this.frameCount=0,this.playTimes=0,this.duration=0,this.scale=1,this.fadeInTime=0,this.cacheFrameRate=0,this.name="",this.cachedFrames.length=0,this.actionTimeline=null,this.zOrderTimeline=null,this.parent=null}cacheFrames(t){if(this.cacheFrameRate>0)return;this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);const e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(let i=0,s=this.cacheFrames.length;i=t&&(i=0),this.sortedBones.indexOf(n)>=0)continue;let r=!1;for(let o in this.constraints){const h=this.constraints[o];if(h.root===n&&this.sortedBones.indexOf(h.target)<0){r=!0;break}}r||n.parent!==null&&this.sortedBones.indexOf(n.parent)<0||(this.sortedBones.push(n),s++)}}cacheFrames(t){if(!(this.cacheFrameRate>0)){this.cacheFrameRate=t;for(let e in this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)}}setCacheFrame(t,e){const i=this.parent.cachedFrames;let s=i.length;return i.length+=10,i[s]=t.a,i[s+1]=t.b,i[s+2]=t.c,i[s+3]=t.d,i[s+4]=t.tx,i[s+5]=t.ty,i[s+6]=e.rotation,i[s+7]=e.skew,i[s+8]=e.scaleX,i[s+9]=e.scaleY,s}getCacheFrame(t,e,i){const s=this.parent.cachedFrames;t.a=s[i],t.b=s[i+1],t.c=s[i+2],t.d=s[i+3],t.tx=s[i+4],t.ty=s[i+5],e.rotation=s[i+6],e.skew=s[i+7],e.scaleX=s[i+8],e.scaleY=s[i+9],e.x=t.tx,e.y=t.ty}addBone(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t,this.sortedBones.push(t)}addSlot(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t,this.sortedSlots.push(t)}addConstraint(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t}addSkin(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this,this.skins[t.name]=t,this.defaultSkin===null&&(this.defaultSkin=t),t.name==="default"&&(this.defaultSkin=t)}addAnimation(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this,this.animations[t.name]=t,this.animationNames.push(t.name),this.defaultAnimation===null&&(this.defaultAnimation=t)}addAction(t,e){e?this.defaultActions.push(t):this.actions.push(t)}getBone(t){return t in this.bones?this.bones[t]:null}getSlot(t){return t in this.slots?this.slots[t]:null}getConstraint(t){return t in this.constraints?this.constraints[t]:null}getSkin(t){return t in this.skins?this.skins[t]:null}getMesh(t,e,i){const s=this.getSkin(t);return s===null?null:s.getDisplay(e,i)}getAnimation(t){return t in this.animations?this.animations[t]:null}}class ae extends F{constructor(){super(...arguments);a(this,"inheritTranslation");a(this,"inheritRotation");a(this,"inheritScale");a(this,"inheritReflection");a(this,"type");a(this,"length");a(this,"alpha");a(this,"name");a(this,"transform",new v);a(this,"userData",null);a(this,"parent")}static toString(){return"[class dragonBones.BoneData]"}_onClear(){this.userData!==null&&this.userData.returnToPool(),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.inheritReflection=!1,this.type=$.Bone,this.length=0,this.alpha=1,this.name="",this.transform.identity(),this.userData=null,this.parent=null}}class Be extends ae{constructor(){super(...arguments);a(this,"segmentX");a(this,"segmentY");a(this,"geometry",new zt)}static toString(){return"[class dragonBones.SurfaceData]"}_onClear(){super._onClear(),this.type=$.Surface,this.segmentX=0,this.segmentY=0,this.geometry.clear()}}class Yt extends F{constructor(){super(...arguments);a(this,"blendMode");a(this,"displayIndex");a(this,"zOrder");a(this,"zIndex");a(this,"alpha");a(this,"name");a(this,"color",null);a(this,"userData",null);a(this,"parent")}static createColor(){return new Lt}static toString(){return"[class dragonBones.SlotData]"}_onClear(){this.userData!==null&&this.userData.returnToPool(),this.blendMode=z.Normal,this.displayIndex=0,this.zOrder=0,this.zIndex=0,this.alpha=1,this.name="",this.color=null,this.userData=null,this.parent=null}}a(Yt,"DEFAULT_COLOR",new Lt);class Ht extends F{constructor(){super(...arguments);a(this,"type");a(this,"color");a(this,"width");a(this,"height")}_onClear(){this.color=0,this.width=0,this.height=0}}class At extends Ht{static toString(){return"[class dragonBones.RectangleBoundingBoxData]"}static _computeOutCode(l,t,e,i,s,n){let r=0;return ls&&(r|=2),tn&&(r|=8),r}static rectangleIntersectsSegment(l,t,e,i,s,n,r,o,h=null,f=null,m=null){const d=l>s&&ln&&ts&&en&&i=-e&&l<=e){const i=this.height*.5;if(t>=-i&&t<=i)return!0}return!1}intersectsSegment(l,t,e,i,s=null,n=null,r=null){const o=this.width*.5,h=this.height*.5;return At.rectangleIntersectsSegment(l,t,e,i,-o,-h,o,h,s,n,r)}}class Kt extends Ht{static toString(){return"[class dragonBones.EllipseData]"}static ellipseIntersectsSegment(l,t,e,i,s,n,r,o,h=null,f=null,m=null){const d=r/o,c=d*d;t*=d,i*=d;const A=e-l,p=i-t,S=Math.sqrt(A*A+p*p),O=A/S,y=p/S,g=(s-l)*O+(n-t)*y,D=g*g,C=l*l+t*t,M=r*r,w=M-C+D;let N=0;if(w>=0){const B=Math.sqrt(w),k=g-B,P=g+B,X=k<0?-1:k<=S?0:1,H=P<0?-1:P<=S?0:1,R=X*H;if(R<0)return-1;R===0&&(X===-1?(N=2,e=l+P*O,i=(t+P*y)/d,h!==null&&(h.x=e,h.y=i),f!==null&&(f.x=e,f.y=i),m!==null&&(m.x=Math.atan2(i/M*c,e/M),m.y=m.x+Math.PI)):H===1?(N=1,l=l+k*O,t=(t+k*y)/d,h!==null&&(h.x=l,h.y=t),f!==null&&(f.x=l,f.y=t),m!==null&&(m.x=Math.atan2(t/M*c,l/M),m.y=m.x+Math.PI)):(N=3,h!==null&&(h.x=l+k*O,h.y=(t+k*y)/d,m!==null&&(m.x=Math.atan2(h.y/M*c,h.x/M))),f!==null&&(f.x=l+P*O,f.y=(t+P*y)/d,m!==null&&(m.y=Math.atan2(f.y/M*c,f.x/M)))))}return N}_onClear(){super._onClear(),this.type=it.Ellipse}containsPoint(l,t){const e=this.width*.5;if(l>=-e&&l<=e){const i=this.height*.5;if(t>=-i&&t<=i)return t*=e/i,Math.sqrt(l*l+t*t)<=e}return!1}intersectsSegment(l,t,e,i,s=null,n=null,r=null){return Kt.ellipseIntersectsSegment(l,t,e,i,0,0,this.width*.5,this.height*.5,s,n,r)}}class Zt extends Ht{constructor(){super(...arguments);a(this,"x");a(this,"y");a(this,"vertices",[])}static toString(){return"[class dragonBones.PolygonBoundingBoxData]"}static polygonIntersectsSegment(t,e,i,s,n,r=null,o=null,h=null){t===i&&(t=i+1e-6),e===s&&(e=s+1e-6);const f=n.length,m=t-i,d=e-s,c=t*s-e*i;let A=0,p=n[f-2],S=n[f-1],O=0,y=0,g=0,D=0,C=0,M=0;for(let w=0;w=p&&R<=N||R>=N&&R<=p)&&(m===0||R>=t&&R<=i||R>=i&&R<=t)){const U=(c*P-d*X)/H;if((U>=S&&U<=B||U>=B&&U<=S)&&(d===0||U>=e&&U<=s||U>=s&&U<=e))if(o!==null){let G=R-t;G<0&&(G=-G),A===0?(O=G,y=G,g=R,D=U,C=R,M=U,h!==null&&(h.x=Math.atan2(B-S,N-p)-Math.PI*.5,h.y=h.x)):(Gy&&(y=G,C=R,M=U,h!==null&&(h.y=Math.atan2(B-S,N-p)-Math.PI*.5))),A++}else{g=R,D=U,C=R,M=U,A++,h!==null&&(h.x=Math.atan2(B-S,N-p)-Math.PI*.5,h.y=h.x);break}}p=N,S=B}return A===1?(r!==null&&(r.x=g,r.y=D),o!==null&&(o.x=g,o.y=D),h!==null&&(h.y=h.x+Math.PI)):A>1&&(A++,r!==null&&(r.x=g,r.y=D),o!==null&&(o.x=C,o.y=M)),A}_onClear(){super._onClear(),this.type=it.Polygon,this.x=0,this.y=0,this.vertices.length=0}containsPoint(t,e){let i=!1;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(let s=0,n=this.vertices.length,r=n-2;s=e||o=e){const f=this.vertices[r],m=this.vertices[s];(e-h)*(f-m)/(o-h)+m=0&&t=0&&t=0&&te._zIndex*1e3+e._zOrder?1:-1}_onClear(){this._clock!==null&&this._clock.remove(this);for(const t of this._bones)t.returnToPool();for(const t of this._slots)t.returnToPool();for(const t of this._constraints)t.returnToPool();for(const t of this._actions)t.returnToPool();this._animation!==null&&this._animation.returnToPool(),this._proxy!==null&&this._proxy.dbClear(),this._replaceTextureAtlasData!==null&&this._replaceTextureAtlasData.returnToPool(),this.inheritAnimation=!0,this.userData=null,this._lockUpdate=!1,this._slotsDirty=!0,this._zOrderDirty=!1,this._zIndexDirty=!1,this._alphaDirty=!0,this._flipX=!1,this._flipY=!1,this._cacheFrameIndex=-1,this._alpha=1,this._globalAlpha=1,this._bones.length=0,this._slots.length=0,this._constraints.length=0,this._actions.length=0,this._armatureData=null,this._animation=null,this._proxy=null,this._display=null,this._replaceTextureAtlasData=null,this._replacedTexture=null,this._dragonBones=null,this._clock=null,this._parent=null}_sortZOrder(t,e){const i=this._armatureData.sortedSlots,s=t===null;if(this._zOrderDirty||!s){for(let n=0,r=i.length;n=r)continue;const h=i[o],f=this.getSlot(h.name);f!==null&&f._setZOrder(n)}this._slotsDirty=!0,this._zOrderDirty=!s}}_addBone(t){this._bones.indexOf(t)<0&&this._bones.push(t)}_addSlot(t){this._slots.indexOf(t)<0&&this._slots.push(t)}_addConstraint(t){this._constraints.indexOf(t)<0&&this._constraints.push(t)}_bufferAction(t,e){this._actions.indexOf(t)<0&&(e?this._actions.push(t):this._actions.unshift(t))}dispose(){this._armatureData!==null&&(this._lockUpdate=!0,this._dragonBones.bufferObject(this))}init(t,e,i,s){this._armatureData===null&&(this._armatureData=t,this._animation=F.borrowObject(xe),this._proxy=e,this._display=i,this._dragonBones=s,this._proxy.dbInit(this),this._animation.init(this),this._animation.animations=this._armatureData.animations)}advanceTime(t){if(this._lockUpdate)return;if(this._lockUpdate=!0,this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn(`The armature data has been disposed. Please make sure dispose armature before call factory.clear().`);return}const e=this._cacheFrameIndex;if(this._animation.advanceTime(t),this._slotsDirty||this._zIndexDirty){if(this._slots.sort(bt._onSortSlots),this._zIndexDirty)for(let i=0,s=this._slots.length;i0){for(const i of this._actions){const s=i.actionData;if(s!==null&&s.type===q.Play)if(i.slot!==null){const n=i.slot.childArmature;n!==null&&n.animation.fadeIn(s.name)}else if(i.bone!==null){for(const n of this.getSlots())if(n.parent===i.bone){const r=n.childArmature;r!==null&&r.animation.fadeIn(s.name)}}else this._animation.fadeIn(s.name);i.returnToPool()}this._actions.length=0}this._lockUpdate=!1,this._proxy.dbUpdate()}invalidUpdate(t=null,e=!1){if(t!==null&&t.length>0){const i=this.getBone(t);if(i!==null&&(i.invalidUpdate(),e))for(const s of this._slots)s.parent===i&&s.invalidUpdate()}else{for(const i of this._bones)i.invalidUpdate();if(e)for(const i of this._slots)i.invalidUpdate()}}containsPoint(t,e){for(const i of this._slots)if(i.containsPoint(t,e))return i;return null}intersectsSegment(t,e,i,s,n=null,r=null,o=null){const h=t===i;let f=0,m=0,d=0,c=0,A=0,p=0,S=0,O=0,y=null,g=null;for(const D of this._slots)if(D.intersectsSegment(t,e,i,s,n,r,o)>0)if(n!==null||r!==null){if(n!==null){let M=h?n.y-e:n.x-t;M<0&&(M=-M),(y===null||Mm)&&(m=M,A=r.x,p=r.y,g=D,o!==null&&(O=o.y))}}else{y=D;break}return y!==null&&n!==null&&(n.x=d,n.y=c,o!==null&&(o.x=S)),g!==null&&r!==null&&(r.x=A,r.y=p,o!==null&&(o.y=O)),y}getBone(t){for(const e of this._bones)if(e.name===t)return e;return null}getBoneByDisplay(t){const e=this.getSlotByDisplay(t);return e!==null?e.parent:null}getSlot(t){for(const e of this._slots)if(e.name===t)return e;return null}getSlotByDisplay(t){if(t!==null){for(const e of this._slots)if(e.display===t)return e}return null}getBones(){return this._bones}getSlots(){return this._slots}get flipX(){return this._flipX}set flipX(t){this._flipX!==t&&(this._flipX=t,this.invalidUpdate())}get flipY(){return this._flipY}set flipY(t){this._flipY!==t&&(this._flipY=t,this.invalidUpdate())}get cacheFrameRate(){return this._armatureData.cacheFrameRate}set cacheFrameRate(t){if(this._armatureData.cacheFrameRate!==t){this._armatureData.cacheFrames(t);for(const e of this._slots){const i=e.childArmature;i!==null&&(i.cacheFrameRate=t)}}}get name(){return this._armatureData.name}get armatureData(){return this._armatureData}get animation(){return this._animation}get proxy(){return this._proxy}get eventDispatcher(){return this._proxy}get display(){return this._display}get replacedTexture(){return this._replacedTexture}set replacedTexture(t){if(this._replacedTexture!==t){this._replaceTextureAtlasData!==null&&(this._replaceTextureAtlasData.returnToPool(),this._replaceTextureAtlasData=null),this._replacedTexture=t;for(const e of this._slots)e.invalidUpdate(),e.update(-1)}}get clock(){return this._clock}set clock(t){if(this._clock!==t){this._clock!==null&&this._clock.remove(this),this._clock=t,this._clock&&this._clock.add(this);for(const e of this._slots){const i=e.childArmature;i!==null&&(i.clock=this._clock)}}}get parent(){return this._parent}getDisplay(){return this._display}}class Ct{constructor(l=1,t=0,e=0,i=1,s=0,n=0){a(this,"a");a(this,"b");a(this,"c");a(this,"d");a(this,"tx");a(this,"ty");this.a=l,this.b=t,this.c=e,this.d=i,this.tx=s,this.ty=n}toString(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty}copyFrom(l){return this.a=l.a,this.b=l.b,this.c=l.c,this.d=l.d,this.tx=l.tx,this.ty=l.ty,this}copyFromArray(l,t=0){return this.a=l[t],this.b=l[t+1],this.c=l[t+2],this.d=l[t+3],this.tx=l[t+4],this.ty=l[t+5],this}identity(){return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this}concat(l){let t=this.a*l.a,e=0,i=0,s=this.d*l.d,n=this.tx*l.a+l.tx,r=this.ty*l.d+l.ty;return(this.b!==0||this.c!==0)&&(t+=this.b*l.c,e+=this.b*l.d,i+=this.c*l.a,s+=this.c*l.b),(l.b!==0||l.c!==0)&&(e+=this.a*l.b,i+=this.d*l.c,n+=this.ty*l.c,r+=this.tx*l.b),this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this}invert(){let l=this.a,t=this.b,e=this.c,i=this.d;const s=this.tx,n=this.ty;if(t===0&&e===0)return this.b=this.c=0,l===0||i===0?this.a=this.b=this.tx=this.ty=0:(l=this.a=1/l,i=this.d=1/i,this.tx=-l*s,this.ty=-i*n),this;let r=l*i-t*e;if(r===0)return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this;r=1/r;let o=this.a=i*r;return t=this.b=-t*r,e=this.c=-e*r,i=this.d=l*r,this.tx=-(o*s+e*n),this.ty=-(t*s+i*n),this}transformPoint(l,t,e,i=!1){e.x=this.a*l+this.c*t,e.y=this.b*l+this.d*t,i||(e.x+=this.tx,e.y+=this.ty)}transformRectangle(l,t=!1){const e=this.a,i=this.b,s=this.c,n=this.d,r=t?0:this.tx,o=t?0:this.ty,h=l.x,f=l.y,m=h+l.width,d=f+l.height;let c=e*h+s*f+r,A=i*h+n*f+o,p=e*m+s*f+r,S=i*m+n*f+o,O=e*m+s*d+r,y=i*m+n*d+o,g=e*h+s*d+r,D=i*h+n*d+o,C=0;c>p&&(C=c,c=p,p=C),O>g&&(C=O,O=g,g=C),l.x=Math.floor(cg?p:g)-l.x),A>S&&(C=A,A=S,S=C),y>D&&(C=y,y=D,D=C),l.y=Math.floor(AD?S:D)-l.y)}}class Nt extends F{constructor(){super(...arguments);a(this,"globalTransformMatrix",new Ct);a(this,"global",new v);a(this,"offset",new v);a(this,"origin");a(this,"userData");a(this,"_globalDirty");a(this,"_alpha");a(this,"_globalAlpha");a(this,"_armature")}_onClear(){this.globalTransformMatrix.identity(),this.global.identity(),this.offset.identity(),this.origin=null,this.userData=null,this._globalDirty=!1,this._alpha=1,this._globalAlpha=1,this._armature=null}updateGlobalTransform(){this._globalDirty&&(this._globalDirty=!1,this.global.fromMatrix(this.globalTransformMatrix))}get armature(){return this._armature}}a(Nt,"_helpMatrix",new Ct),a(Nt,"_helpTransform",new v),a(Nt,"_helpPoint",new Vt);class le extends Nt{constructor(){super(...arguments);a(this,"offsetMode");a(this,"animationPose",new v);a(this,"_transformDirty");a(this,"_childrenTransformDirty");a(this,"_localDirty");a(this,"_hasConstraint");a(this,"_visible");a(this,"_cachedFrameIndex");a(this,"_boneData");a(this,"_parent");a(this,"_cachedFrameIndices")}static toString(){return"[class dragonBones.Bone]"}_onClear(){super._onClear(),this.offsetMode=vt.Additive,this.animationPose.identity(),this._transformDirty=!1,this._childrenTransformDirty=!1,this._localDirty=!0,this._hasConstraint=!1,this._visible=!0,this._cachedFrameIndex=-1,this._boneData=null,this._parent=null,this._cachedFrameIndices=null}_updateGlobalTransformMatrix(t){const e=this._boneData,i=this.global,s=this.globalTransformMatrix,n=this.origin,r=this.offset,o=this.animationPose,h=this._parent,f=this._armature.flipX,m=this._armature.flipY===ut.yDown;let d=h!==null,c=0;if(this.offsetMode===vt.Additive?n!==null?(i.x=n.x+r.x+o.x,i.scaleX=n.scaleX*r.scaleX*o.scaleX,i.scaleY=n.scaleY*r.scaleY*o.scaleY,ut.yDown?(i.y=n.y+r.y+o.y,i.skew=n.skew+r.skew+o.skew,i.rotation=n.rotation+r.rotation+o.rotation):(i.y=n.y-r.y+o.y,i.skew=n.skew-r.skew+o.skew,i.rotation=n.rotation-r.rotation+o.rotation)):(i.copyFrom(r),ut.yDown||(i.y=-i.y,i.skew=-i.skew,i.rotation=-i.rotation),i.add(o)):this.offsetMode===vt.None?n!==null?i.copyFrom(n).add(o):i.copyFrom(o):(d=!1,i.copyFrom(r),ut.yDown||(i.y=-i.y,i.skew=-i.skew,i.rotation=-i.rotation)),d){const A=h._boneData.type===$.Surface,p=A?h._bone:null,S=A?h._getGlobalTransformMatrix(i.x,i.y):h.globalTransformMatrix;if(e.inheritScale&&(!A||p!==null))A?(e.inheritRotation&&(i.rotation+=h.global.rotation),p.updateGlobalTransform(),i.scaleX*=p.global.scaleX,i.scaleY*=p.global.scaleY,S.transformPoint(i.x,i.y,i),i.toMatrix(s),e.inheritTranslation?(i.x=s.tx,i.y=s.ty):(s.tx=i.x,s.ty=i.y)):(e.inheritRotation||(h.updateGlobalTransform(),f&&m?c=i.rotation-(h.global.rotation+Math.PI):f?c=i.rotation+h.global.rotation+Math.PI:m?c=i.rotation+h.global.rotation:c=i.rotation-h.global.rotation,i.rotation=c),i.toMatrix(s),s.concat(S),e.inheritTranslation?(i.x=s.tx,i.y=s.ty):(s.tx=i.x,s.ty=i.y),t?i.fromMatrix(s):this._globalDirty=!0);else{if(e.inheritTranslation){const O=i.x,y=i.y;i.x=S.a*O+S.c*y+S.tx,i.y=S.b*O+S.d*y+S.ty}else f&&(i.x=-i.x),m&&(i.y=-i.y);e.inheritRotation?(h.updateGlobalTransform(),h.global.scaleX<0?c=i.rotation+h.global.rotation+Math.PI:c=i.rotation+h.global.rotation,S.a*S.d-S.b*S.c<0&&(c-=i.rotation*2,(f!==m||e.inheritReflection)&&(i.skew+=Math.PI),ut.yDown||(i.skew=-i.skew)),i.rotation=c):(f||m)&&(f&&m?c=i.rotation+Math.PI:(f?c=Math.PI-i.rotation:c=-i.rotation,i.skew+=Math.PI),i.rotation=c),i.toMatrix(s)}}else(f||m)&&(f&&(i.x=-i.x),m&&(i.y=-i.y),f&&m?c=i.rotation+Math.PI:(f?c=Math.PI-i.rotation:c=-i.rotation,i.skew+=Math.PI),i.rotation=c),i.toMatrix(s)}_updateAlpha(){this._parent!==null?this._globalAlpha=this._alpha*this._parent._globalAlpha:this._globalAlpha=this._alpha*this._armature._globalAlpha}init(t,e){this._boneData===null&&(this._boneData=t,this._armature=e,this._alpha=this._boneData.alpha,this._boneData.parent!==null&&(this._parent=this._armature.getBone(this._boneData.parent.name)),this._armature._addBone(this),this.origin=this._boneData.transform)}update(t){if(t>=0&&this._cachedFrameIndices!==null){const 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(const i of this._armature._constraints)i._root===this&&i.update();this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(const e of this._armature._constraints)e._root===this&&e.update();(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1)}if(this._transformDirty)if(this._transformDirty=!1,this._childrenTransformDirty=!0,this._cachedFrameIndex<0){const e=t>=0;this._localDirty&&this._updateGlobalTransformMatrix(e),e&&this._cachedFrameIndices!==null&&(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}updateByConstraint(){this._localDirty&&(this._localDirty=!1,(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty)&&this._updateGlobalTransformMatrix(!0),this._transformDirty=!0)}invalidUpdate(){this._transformDirty=!0}contains(t){if(t===this)return!1;let e=t;for(;e!==this&&e!==null;)e=e.parent;return e===this}get boneData(){return this._boneData}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const e of this._armature.getSlots())e.parent===this&&e._updateVisible()}}get name(){return this._boneData.name}get parent(){return this._parent}}class kt extends F{constructor(){super(...arguments);a(this,"_constraintData");a(this,"_armature");a(this,"_target");a(this,"_root");a(this,"_bone")}_onClear(){this._armature=null,this._target=null,this._root=null,this._bone=null}get name(){return this._constraintData.name}}a(kt,"_helpMatrix",new Ct),a(kt,"_helpTransform",new v),a(kt,"_helpPoint",new Vt);class oe extends kt{constructor(){super(...arguments);a(this,"_scaleEnabled");a(this,"_bendPositive");a(this,"_weight")}static toString(){return"[class dragonBones.IKConstraint]"}_onClear(){super._onClear(),this._scaleEnabled=!1,this._bendPositive=!1,this._weight=1,this._constraintData=null}_computeA(){const t=this._target.global,e=this._root.global,i=this._root.globalTransformMatrix;let s=Math.atan2(t.y-e.y,t.x-e.x);e.scaleX<0&&(s+=Math.PI),e.rotation+=v.normalizeRadian(s-e.rotation)*this._weight,e.toMatrix(i)}_computeB(){const t=this._bone._boneData.length,e=this._root,i=this._target.global,s=e.global,n=this._bone.global,r=this._bone.globalTransformMatrix,o=r.a*t,h=r.b*t,f=o*o+h*h,m=Math.sqrt(f);let d=n.x-s.x,c=n.y-s.y;const A=d*d+c*c,p=Math.sqrt(A),S=n.rotation,O=s.rotation,y=Math.atan2(c,d);d=i.x-s.x,c=i.y-s.y;const g=d*d+c*c,D=Math.sqrt(g);let C=0;if(m+p<=D||D+m<=p||D+p<=m)C=Math.atan2(i.y-s.y,i.x-s.x),m+p<=D||py)continue}let et=0;for(;;ht++){const Q=nt[ht];if(!(O>Q)){if(ht===0)et=O/Q;else{const xt=nt[ht-1];et=(O-xt)/(Q-xt)}break}}ht!==S&&(S=ht,d&&ht===p?(this._computeVertices(A-4,4,0,c),this._computeVertices(0,4,4,c)):this._computeVertices(ht*6+2,8,0,c)),this.addCurvePosition(et,c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],f,yt,i)}return}d?(A+=2,c.length=h,this._computeVertices(2,A-4,0,c),this._computeVertices(0,2,A-4,c),c[A-2]=c[0],c[A-1]=c[1]):(p--,A-=4,c.length=A,this._computeVertices(2,A,0,c));let g=new Array(p);y=0;let D=c[0],C=c[1],M=0,w=0,N=0,B=0,k=0,P=0,X,H,R,U,G,st,Z,V;for(let nt=0,rt=2;nty)continue}for(;;yt++){const Q=g[yt];if(!(et>Q)){if(yt===0)et/=Q;else{const xt=g[yt-1];et=(et-xt)/(Q-xt)}break}}if(yt!==S){S=yt;let Q=yt*6;for(D=c[Q],C=c[Q+1],M=c[Q+2],w=c[Q+3],N=c[Q+4],B=c[Q+5],k=c[Q+6],P=c[Q+7],X=(D-M*2+N)*.03,H=(C-w*2+B)*.03,R=((M-N)*3-D+k)*.006,U=((w-B)*3-C+P)*.006,G=X*2+R,st=H*2+U,Z=(M-D)*.3+X+R*.16666667,V=(w-C)*.3+H+U*.16666667,at=Math.sqrt(Z*Z+V*V),_t[0]=at,Q=1;Q<8;Q++)Z+=G,V+=st,G+=R,st+=U,at+=Math.sqrt(Z*Z+V*V),_t[Q]=at;Z+=G,V+=st,at+=Math.sqrt(Z*Z+V*V),_t[8]=at,Z+=G+R,V+=st+U,at+=Math.sqrt(Z*Z+V*V),_t[9]=at,ht=0}for(et*=at;;ht++){const Q=_t[ht];if(!(et>Q)){if(ht===0)et/=Q;else{const xt=_t[ht-1];et=ht+(et-xt)/(Q-xt)}break}}this.addCurvePosition(et*.1,D,C,M,w,N,B,k,P,f,rt,i)}}addCurvePosition(t,e,i,s,n,r,o,h,f,m,d,c){if(t===0){m[d]=e,m[d+1]=i,m[d+2]=0;return}if(t===1){m[d]=h,m[d+1]=f,m[d+2]=0;return}const A=1-t,p=A*A,S=t*t,O=p*A,y=p*t*3,g=A*S*3,D=t*S,C=O*e+y*s+g*r+D*h,M=O*i+y*n+g*o+D*f;m[d]=C,m[d+1]=M,c?m[d+2]=Math.atan2(M-(O*i+y*n+g*o),C-(O*e+y*s+g*r)):m[d+2]=0}init(t,e){this._constraintData=t,this._armature=e;let i=t;this.pathOffset=i.pathDisplayData.geometry.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(let s=0,n=i.bones.length;s0?v.DEG_RAD:-v.DEG_RAD}}const C=this.rotateMix,M=this.translateMix;for(let w=0,N=3;w0){let U=k.a,G=k.b,st=k.c,Z=k.d,V,_t,at;if(m?V=S[N-1]:V=Math.atan2(R,H),V-=Math.atan2(G,U),D){_t=Math.cos(V),at=Math.sin(V);const nt=B._boneData.length;y+=(nt*(_t*U-at*G)-H)*C,g+=(nt*(at*U+_t*G)-R)*C}else V+=O;V>v.PI?V-=v.PI_D:V<-v.PI&&(V+=v.PI_D),V*=C,_t=Math.cos(V),at=Math.sin(V),k.a=_t*U-at*G,k.b=at*U+_t*G,k.c=_t*st-at*Z,k.d=at*st+_t*Z}B.global.fromMatrix(k)}this.dirty=!1}invalidUpdate(){}}class ft extends le{constructor(){super(...arguments);a(this,"_dX");a(this,"_dY");a(this,"_k");a(this,"_kX");a(this,"_kY");a(this,"_vertices",[]);a(this,"_deformVertices",[]);a(this,"_hullCache",[]);a(this,"_matrixCahce",[]);a(this,"_bone")}static toString(){return"[class dragonBones.Surface]"}_onClear(){super._onClear(),this._dX=0,this._dY=0,this._k=0,this._kX=0,this._kY=0,this._vertices.length=0,this._deformVertices.length=0,this._matrixCahce.length=0,this._hullCache.length=0,this._bone=null}_getAffineTransform(t,e,i,s,n,r,o,h,f,m,d,c,A){const p=o-n,S=h-r,O=f-n,y=m-r;d.rotation=Math.atan2(S,p),d.skew=Math.atan2(y,O)-Math.PI*.5-d.rotation,A&&(d.rotation+=Math.PI),d.scaleX=Math.sqrt(p*p+S*S)/i,d.scaleY=Math.sqrt(O*O+y*y)/s,d.toMatrix(c),d.x=c.tx=n-(c.a*t+c.c*e),d.y=c.ty=r-(c.b*t+c.d*e)}_updateVertices(){const t=this._armature.armatureData.parent,e=this._boneData.geometry,i=t.intArray,s=t.floatArray,n=i[e.offset+x.GeometryVertexCount],r=i[e.offset+x.GeometryFloatOffset],o=this._vertices,h=this._deformVertices;if(this._parent!==null)if(this._parent._boneData.type===$.Surface)for(let f=0,m=n;f=200)return this.globalTransformMatrix;if(n=e>this._kX*(t+200)+O,p=((o*h+o+h+h+A)*2+(n?1:0))*7,y[p]>0)g.copyFromArray(y,p+1);else{const D=A*(f+2),C=this._hullCache[4],M=this._hullCache[5],w=this._hullCache[2]-(h-A)*C,N=this._hullCache[3]-(h-A)*M,B=this._vertices;n?this._getAffineTransform(-200,O+d,800,d,B[D+f+2],B[D+f+3],w+C,N+M,B[D],B[D+1],ft._helpTransform,g,!0):this._getAffineTransform(-1e3,O,800,d,w,N,B[D],B[D+1],w+C,N+M,ft._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}}else if(t>=200){if(e<-200||e>=200)return this.globalTransformMatrix;if(n=e>this._kX*(t-1e3)+O,p=((o*h+o+A)*2+(n?1:0))*7,y[p]>0)g.copyFromArray(y,p+1);else{const D=(A+1)*(f+2)-2,C=this._hullCache[4],M=this._hullCache[5],w=this._hullCache[0]+A*C,N=this._hullCache[1]+A*M,B=this._vertices;n?this._getAffineTransform(1e3,O+d,800,d,w+C,N+M,B[D+f+2],B[D+f+3],w,N,ft._helpTransform,g,!0):this._getAffineTransform(200,O,800,d,B[D],B[D+1],w,N,B[D+f+2],B[D+f+3],ft._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}}else if(e<-200){if(t<-200||t>=200)return this.globalTransformMatrix;if(n=e>this._kY*(t-S-m)-1e3,p=((o*h+c)*2+(n?1:0))*7,y[p]>0)g.copyFromArray(y,p+1);else{const D=c*2,C=this._hullCache[10],M=this._hullCache[11],w=this._hullCache[8]+c*C,N=this._hullCache[9]+c*M,B=this._vertices;n?this._getAffineTransform(S+m,-200,m,800,B[D+2],B[D+3],B[D],B[D+1],w+C,N+M,ft._helpTransform,g,!0):this._getAffineTransform(S,-1e3,m,800,w,N,w+C,N+M,B[D],B[D+1],ft._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}}else if(e>=200){if(t<-200||t>=200)return this.globalTransformMatrix;if(n=e>this._kY*(t-S-m)+200,p=((o*h+o+h+c)*2+(n?1:0))*7,y[p]>0)g.copyFromArray(y,p+1);else{const D=h*(f+2)+c*2,C=this._hullCache[10],M=this._hullCache[11],w=this._hullCache[6]-(o-c)*C,N=this._hullCache[7]-(o-c)*M,B=this._vertices;n?this._getAffineTransform(S+m,1e3,m,800,w+C,N+M,w,N,B[D+2],B[D+3],ft._helpTransform,g,!0):this._getAffineTransform(S,200,m,800,B[D],B[D+1],B[D+2],B[D+3],w,N,ft._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}}else if(n=e>this._k*(t-S-m)+O,p=((o*A+c)*2+(n?1:0))*7,y[p]>0)g.copyFromArray(y,p+1);else{const D=c*2+A*(f+2),C=this._vertices;n?this._getAffineTransform(S+m,O+d,m,d,C[D+f+4],C[D+f+5],C[D+f+2],C[D+f+3],C[D+2],C[D+3],ft._helpTransform,g,!0):this._getAffineTransform(S,O,m,d,C[D],C[D+1],C[D+2],C[D+3],C[D+f+2],C[D+f+3],ft._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}return g}init(t,e){if(this._boneData!==null)return;super.init(t,e);const i=t.segmentX,s=t.segmentY,n=this._armature.armatureData.parent.intArray[t.geometry.offset+x.GeometryVertexCount],r=1e3,o=200;this._dX=o*2/i,this._dY=o*2/s,this._k=-this._dY/this._dX,this._kX=-this._dY/(r-o),this._kY=-(r-o)/this._dX,this._vertices.length=n*2,this._deformVertices.length=n*2,this._matrixCahce.length=(i*s+i*2+s*2)*2*7,this._hullCache.length=10;for(let h=0;h=0&&this._cachedFrameIndices!==null){const 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(const i of this._armature._constraints)i._root===this&&i.update();this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(const e of this._armature._constraints)e._root===this&&e.update();(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1)}if(this._transformDirty){this._transformDirty=!1,this._childrenTransformDirty=!0;for(let o=0,h=this._matrixCahce.length;o=0;this._localDirty&&this._updateGlobalTransformMatrix(o),o&&this._cachedFrameIndices!==null&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);const e=1e3,i=200,s=2*this.global.x,n=2*this.global.y,r=ft._helpPoint;this.globalTransformMatrix.transformPoint(e,-i,r),this._hullCache[0]=r.x,this._hullCache[1]=r.y,this._hullCache[2]=s-r.x,this._hullCache[3]=n-r.y,this.globalTransformMatrix.transformPoint(0,this._dY,r,!0),this._hullCache[4]=r.x,this._hullCache[5]=r.y,this.globalTransformMatrix.transformPoint(i,e,r),this._hullCache[6]=r.x,this._hullCache[7]=r.y,this._hullCache[8]=s-r.x,this._hullCache[9]=n-r.y,this.globalTransformMatrix.transformPoint(this._dX,0,r,!0),this._hullCache[10]=r.x,this._hullCache[11]=r.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0}}const b=class b{static _getArmatureType(l){switch(l.toLowerCase()){case"stage":return Dt.Stage;case"armature":return Dt.Armature;case"movieclip":return Dt.MovieClip;default:return Dt.Armature}}static _getBoneType(l){switch(l.toLowerCase()){case"bone":return $.Bone;case"surface":return $.Surface;default:return $.Bone}}static _getPositionMode(l){switch(l.toLocaleLowerCase()){case"percent":return Et.Percent;case"fixed":return Et.Fixed;default:return Et.Percent}}static _getSpacingMode(l){switch(l.toLocaleLowerCase()){case"length":return Tt.Length;case"percent":return Tt.Percent;case"fixed":return Tt.Fixed;default:return Tt.Length}}static _getRotateMode(l){switch(l.toLocaleLowerCase()){case"tangent":return pt.Tangent;case"chain":return pt.Chain;case"chainscale":return pt.ChainScale;default:return pt.Tangent}}static _getDisplayType(l){switch(l.toLowerCase()){case"image":return L.Image;case"mesh":return L.Mesh;case"armature":return L.Armature;case"boundingbox":return L.BoundingBox;case"path":return L.Path;default:return L.Image}}static _getBoundingBoxType(l){switch(l.toLowerCase()){case"rectangle":return it.Rectangle;case"ellipse":return it.Ellipse;case"polygon":return it.Polygon;default:return it.Rectangle}}static _getBlendMode(l){switch(l.toLowerCase()){case"normal":return z.Normal;case"add":return z.Add;case"alpha":return z.Alpha;case"darken":return z.Darken;case"difference":return z.Difference;case"erase":return z.Erase;case"hardlight":return z.HardLight;case"invert":return z.Invert;case"layer":return z.Layer;case"lighten":return z.Lighten;case"multiply":return z.Multiply;case"overlay":return z.Overlay;case"screen":return z.Screen;case"subtract":return z.Subtract;default:return z.Normal}}static _getAnimationBlendType(l){switch(l.toLowerCase()){case"none":return dt.None;case"1d":return dt.E1D;default:return dt.None}}static _getActionType(l){switch(l.toLowerCase()){case"play":return q.Play;case"frame":return q.Frame;case"sound":return q.Sound;default:return q.Play}}};a(b,"DATA_VERSION_2_3","2.3"),a(b,"DATA_VERSION_3_0","3.0"),a(b,"DATA_VERSION_4_0","4.0"),a(b,"DATA_VERSION_4_5","4.5"),a(b,"DATA_VERSION_5_0","5.0"),a(b,"DATA_VERSION_5_5","5.5"),a(b,"DATA_VERSION_5_6","5.6"),a(b,"DATA_VERSION",b.DATA_VERSION_5_6),a(b,"DATA_VERSIONS",[b.DATA_VERSION_4_0,b.DATA_VERSION_4_5,b.DATA_VERSION_5_0,b.DATA_VERSION_5_5,b.DATA_VERSION_5_6]),a(b,"TEXTURE_ATLAS","textureAtlas"),a(b,"SUB_TEXTURE","SubTexture"),a(b,"FORMAT","format"),a(b,"IMAGE_PATH","imagePath"),a(b,"WIDTH","width"),a(b,"HEIGHT","height"),a(b,"ROTATED","rotated"),a(b,"FRAME_X","frameX"),a(b,"FRAME_Y","frameY"),a(b,"FRAME_WIDTH","frameWidth"),a(b,"FRAME_HEIGHT","frameHeight"),a(b,"DRADON_BONES","dragonBones"),a(b,"USER_DATA","userData"),a(b,"ARMATURE","armature"),a(b,"CANVAS","canvas"),a(b,"BONE","bone"),a(b,"SURFACE","surface"),a(b,"SLOT","slot"),a(b,"CONSTRAINT","constraint"),a(b,"SKIN","skin"),a(b,"DISPLAY","display"),a(b,"FRAME","frame"),a(b,"IK","ik"),a(b,"PATH_CONSTRAINT","path"),a(b,"ANIMATION","animation"),a(b,"TIMELINE","timeline"),a(b,"FFD","ffd"),a(b,"TRANSLATE_FRAME","translateFrame"),a(b,"ROTATE_FRAME","rotateFrame"),a(b,"SCALE_FRAME","scaleFrame"),a(b,"DISPLAY_FRAME","displayFrame"),a(b,"COLOR_FRAME","colorFrame"),a(b,"DEFAULT_ACTIONS","defaultActions"),a(b,"ACTIONS","actions"),a(b,"EVENTS","events"),a(b,"INTS","ints"),a(b,"FLOATS","floats"),a(b,"STRINGS","strings"),a(b,"TRANSFORM","transform"),a(b,"PIVOT","pivot"),a(b,"AABB","aabb"),a(b,"COLOR","color"),a(b,"VERSION","version"),a(b,"COMPATIBLE_VERSION","compatibleVersion"),a(b,"FRAME_RATE","frameRate"),a(b,"TYPE","type"),a(b,"SUB_TYPE","subType"),a(b,"NAME","name"),a(b,"PARENT","parent"),a(b,"TARGET","target"),a(b,"STAGE","stage"),a(b,"SHARE","share"),a(b,"PATH","path"),a(b,"LENGTH","length"),a(b,"DISPLAY_INDEX","displayIndex"),a(b,"Z_ORDER","zOrder"),a(b,"Z_INDEX","zIndex"),a(b,"BLEND_MODE","blendMode"),a(b,"INHERIT_TRANSLATION","inheritTranslation"),a(b,"INHERIT_ROTATION","inheritRotation"),a(b,"INHERIT_SCALE","inheritScale"),a(b,"INHERIT_REFLECTION","inheritReflection"),a(b,"INHERIT_ANIMATION","inheritAnimation"),a(b,"INHERIT_DEFORM","inheritDeform"),a(b,"SEGMENT_X","segmentX"),a(b,"SEGMENT_Y","segmentY"),a(b,"BEND_POSITIVE","bendPositive"),a(b,"CHAIN","chain"),a(b,"WEIGHT","weight"),a(b,"BLEND_TYPE","blendType"),a(b,"FADE_IN_TIME","fadeInTime"),a(b,"PLAY_TIMES","playTimes"),a(b,"SCALE","scale"),a(b,"OFFSET","offset"),a(b,"POSITION","position"),a(b,"DURATION","duration"),a(b,"TWEEN_EASING","tweenEasing"),a(b,"TWEEN_ROTATE","tweenRotate"),a(b,"TWEEN_SCALE","tweenScale"),a(b,"CLOCK_WISE","clockwise"),a(b,"CURVE","curve"),a(b,"SOUND","sound"),a(b,"EVENT","event"),a(b,"ACTION","action"),a(b,"X","x"),a(b,"Y","y"),a(b,"SKEW_X","skX"),a(b,"SKEW_Y","skY"),a(b,"SCALE_X","scX"),a(b,"SCALE_Y","scY"),a(b,"VALUE","value"),a(b,"ROTATE","rotate"),a(b,"SKEW","skew"),a(b,"ALPHA","alpha"),a(b,"ALPHA_OFFSET","aO"),a(b,"RED_OFFSET","rO"),a(b,"GREEN_OFFSET","gO"),a(b,"BLUE_OFFSET","bO"),a(b,"ALPHA_MULTIPLIER","aM"),a(b,"RED_MULTIPLIER","rM"),a(b,"GREEN_MULTIPLIER","gM"),a(b,"BLUE_MULTIPLIER","bM"),a(b,"UVS","uvs"),a(b,"VERTICES","vertices"),a(b,"TRIANGLES","triangles"),a(b,"WEIGHTS","weights"),a(b,"SLOT_POSE","slotPose"),a(b,"BONE_POSE","bonePose"),a(b,"BONES","bones"),a(b,"POSITION_MODE","positionMode"),a(b,"SPACING_MODE","spacingMode"),a(b,"ROTATE_MODE","rotateMode"),a(b,"SPACING","spacing"),a(b,"ROTATE_OFFSET","rotateOffset"),a(b,"ROTATE_MIX","rotateMix"),a(b,"TRANSLATE_MIX","translateMix"),a(b,"TARGET_DISPLAY","targetDisplay"),a(b,"CLOSED","closed"),a(b,"CONSTANT_SPEED","constantSpeed"),a(b,"VERTEX_COUNT","vertexCount"),a(b,"LENGTHS","lengths"),a(b,"GOTO_AND_PLAY","gotoAndPlay"),a(b,"DEFAULT_NAME","default");let _=b;var Ve=(u=>(u[u.Step=0]="Step",u[u.Int=1]="Int",u[u.Float=2]="Float",u))(Ve||{});const T=class T extends _{constructor(){super(...arguments);a(this,"_rawTextureAtlasIndex",0);a(this,"_rawBones",[]);a(this,"_data",null);a(this,"_armature",null);a(this,"_bone",null);a(this,"_geometry",null);a(this,"_slot",null);a(this,"_skin",null);a(this,"_mesh",null);a(this,"_animation",null);a(this,"_timeline",null);a(this,"_rawTextureAtlases",null);a(this,"_frameValueType",0);a(this,"_defaultColorOffset",-1);a(this,"_prevClockwise",0);a(this,"_prevRotation",0);a(this,"_frameDefaultValue",0);a(this,"_frameValueScale",1);a(this,"_helpMatrixA",new Ct);a(this,"_helpMatrixB",new Ct);a(this,"_helpTransform",new v);a(this,"_helpColorTransform",new Lt);a(this,"_helpPoint",new Vt);a(this,"_helpArray",[]);a(this,"_intArray",[]);a(this,"_floatArray",[]);a(this,"_frameIntArray",[]);a(this,"_frameFloatArray",[]);a(this,"_frameArray",[]);a(this,"_timelineArray",[]);a(this,"_colorArray",[]);a(this,"_cacheRawMeshes",[]);a(this,"_cacheMeshes",[]);a(this,"_actionFrames",[]);a(this,"_weightSlotPose",{});a(this,"_weightBonePoses",{});a(this,"_cacheBones",{});a(this,"_slotChildActions",{})}static _getBoolean(t,e,i){if(e in t){const s=t[e],n=typeof s;if(n==="boolean")return s;if(n==="string")switch(s){case"0":case"NaN":case"":case"false":case"null":case"undefined":return!1;default:return!0}else return!!s}return i}static _getNumber(t,e,i){if(e in t){const s=t[e];return s===null||s==="NaN"?i:+s||0}return i}static _getString(t,e,i){if(e in t){const s=t[e];return typeof s==="string"?s:String(s)}return i}_getCurvePoint(t,e,i,s,n,r,o,h,f,m){const d=1-f,c=d*d,A=f*f,p=d*c,S=3*f*c,O=3*d*A,y=f*A;m.x=p*t+S*i+O*n+y*o,m.y=p*e+S*s+O*r+y*h}_samplingEasingCurve(t,e){const i=t.length;if(i%3===1){let s=-2;for(let n=0,r=e.length;n=0&&s+61e-4;){const D=(g+y)*.5;this._getCurvePoint(f,m,d,c,A,p,S,O,D,this._helpPoint),o-this._helpPoint.x>0?y=D:g=D}e[n]=this._helpPoint.y}return!0}else{let s=0;for(let n=0,r=e.length;n1e-4;){const g=(y+O)*.5;this._getCurvePoint(h,f,m,d,c,A,p,S,g,this._helpPoint),o-this._helpPoint.x>0?O=g:y=g}e[n]=this._helpPoint.y}return!1}}_parseActionDataInFrame(t,e,i,s){_.EVENT in t&&this._mergeActionFrame(t[_.EVENT],e,q.Frame,i,s),_.SOUND in t&&this._mergeActionFrame(t[_.SOUND],e,q.Sound,i,s),_.ACTION in t&&this._mergeActionFrame(t[_.ACTION],e,q.Play,i,s),_.EVENTS in t&&this._mergeActionFrame(t[_.EVENTS],e,q.Frame,i,s),_.ACTIONS in t&&this._mergeActionFrame(t[_.ACTIONS],e,q.Play,i,s)}_mergeActionFrame(t,e,i,s,n){const r=this._armature.actions.length,o=this._parseActionData(t,i,s,n);let h=0,f=null;for(const m of o)this._armature.addAction(m,!1);this._actionFrames.length===0&&(f=new Qt,f.frameStart=0,this._actionFrames.push(f),f=null);for(const m of this._actionFrames){if(m.frameStart===e){f=m;break}else if(m.frameStart>e)break;h++}f===null&&(f=new Qt,f.frameStart=e,this._actionFrames.splice(h,0,f));for(let m=0;m0){const h=i.getBone(r);h!==null?o.parent=h:(r in this._cacheBones||(this._cacheBones[r]=[]),this._cacheBones[r].push(o))}if(o.name in this._cacheBones){for(const h of this._cacheBones[o.name])h.parent=o;delete this._cacheBones[o.name]}i.addBone(o),this._rawBones.push(o)}}if(_.IK in t){const s=t[_.IK];for(const n of s){const r=this._parseIKConstraint(n);r&&i.addConstraint(r)}}if(i.sortBones(),_.SLOT in t){let s=0;const n=t[_.SLOT];for(const r of n)i.addSlot(this._parseSlot(r,s++))}if(_.SKIN in t){const s=t[_.SKIN];for(const n of s)i.addSkin(this._parseSkin(n))}if(_.PATH_CONSTRAINT in t){const s=t[_.PATH_CONSTRAINT];for(const n of s){const r=this._parsePathConstraint(n);r&&i.addConstraint(r)}}for(let s=0,n=this._cacheRawMeshes.length;s0&&e.parent!==null?(n.root=e.parent,n.bone=e):(n.root=e,n.bone=null),n}_parsePathConstraint(t){const e=this._armature.getSlot(T._getString(t,_.TARGET,""));if(e===null)return null;const i=this._armature.defaultSkin;if(i===null)return null;const s=i.getDisplay(e.name,T._getString(t,_.TARGET_DISPLAY,e.name));if(s===null||!(s instanceof ie))return null;const n=t[_.BONES];if(n===null||n.length===0)return null;const r=F.borrowObject(ke);r.name=T._getString(t,_.NAME,""),r.type=It.Path,r.pathSlot=e,r.pathDisplayData=s,r.target=e.parent,r.positionMode=_._getPositionMode(T._getString(t,_.POSITION_MODE,"")),r.spacingMode=_._getSpacingMode(T._getString(t,_.SPACING_MODE,"")),r.rotateMode=_._getRotateMode(T._getString(t,_.ROTATE_MODE,"")),r.position=T._getNumber(t,_.POSITION,0),r.spacing=T._getNumber(t,_.SPACING,0),r.rotateOffset=T._getNumber(t,_.ROTATE_OFFSET,0),r.rotateMix=T._getNumber(t,_.ROTATE_MIX,1),r.translateMix=T._getNumber(t,_.TRANSLATE_MIX,1);for(var o of n){const h=this._armature.getBone(o);h!==null&&(r.AddBone(h),r.root===null&&(r.root=h))}return r}_parseSlot(t,e){const i=F.borrowObject(Yt);return i.displayIndex=T._getNumber(t,_.DISPLAY_INDEX,0),i.zOrder=e,i.zIndex=T._getNumber(t,_.Z_INDEX,0),i.alpha=T._getNumber(t,_.ALPHA,1),i.name=T._getString(t,_.NAME,""),i.parent=this._armature.getBone(T._getString(t,_.PARENT,"")),_.BLEND_MODE in t&&typeof t[_.BLEND_MODE]=="string"?i.blendMode=_._getBlendMode(t[_.BLEND_MODE]):i.blendMode=T._getNumber(t,_.BLEND_MODE,z.Normal),_.COLOR in t?(i.color=Yt.createColor(),this._parseColorTransform(t[_.COLOR],i.color)):i.color=Yt.DEFAULT_COLOR,_.ACTIONS in t&&(this._slotChildActions[i.name]=this._parseActionData(t[_.ACTIONS],q.Play,null,null)),i}_parseSkin(t){const e=F.borrowObject(Re);if(e.name=T._getString(t,_.NAME,_.DEFAULT_NAME),e.name.length===0&&(e.name=_.DEFAULT_NAME),_.SLOT in t){const i=t[_.SLOT];this._skin=e;for(const s of i){const n=T._getString(s,_.NAME,""),r=this._armature.getSlot(n);if(r!==null){if(this._slot=r,_.DISPLAY in s){const o=s[_.DISPLAY];for(const h of o)h?e.addDisplay(n,this._parseDisplay(h)):e.addDisplay(n,null)}this._slot=null}}this._skin=null}return e}_parseDisplay(t){const e=T._getString(t,_.NAME,""),i=T._getString(t,_.PATH,"");let s=L.Image,n=null;switch(_.TYPE in t&&typeof t[_.TYPE]=="string"?s=_._getDisplayType(t[_.TYPE]):s=T._getNumber(t,_.TYPE,s),s){case L.Image:{const r=n=F.borrowObject(Fe);r.name=e,r.path=i.length>0?i:e,this._parsePivot(t,r);break}case L.Armature:{const r=n=F.borrowObject(Ie);if(r.name=e,r.path=i.length>0?i:e,r.inheritAnimation=!0,_.ACTIONS in t){const o=this._parseActionData(t[_.ACTIONS],q.Play,null,null);for(const h of o)r.addAction(h)}else if(this._slot.name in this._slotChildActions){const o=this._skin.getDisplays(this._slot.name);if(o===null?this._slot.displayIndex===0:this._slot.displayIndex===o.length){for(const h of this._slotChildActions[this._slot.name])r.addAction(h);delete this._slotChildActions[this._slot.name]}}break}case L.Mesh:{const r=n=F.borrowObject(Ee);r.geometry.inheritDeform=T._getBoolean(t,_.INHERIT_DEFORM,!0),r.name=e,r.path=i.length>0?i:e,_.SHARE in t?(r.geometry.data=this._data,this._cacheRawMeshes.push(t),this._cacheMeshes.push(r)):this._parseMesh(t,r);break}case L.BoundingBox:{const r=this._parseBoundingBox(t);if(r!==null){const o=n=F.borrowObject(Ce);o.name=e,o.path=i.length>0?i:e,o.boundingBox=r}break}case L.Path:{const r=t[_.LENGTHS],o=n=F.borrowObject(ie);o.closed=T._getBoolean(t,_.CLOSED,!1),o.constantSpeed=T._getBoolean(t,_.CONSTANT_SPEED,!1),o.name=e,o.path=i.length>0?i:e,o.curveLengths.length=r.length;for(let h=0,f=r.length;he.width&&(e.width=h),fe.height&&(e.height=f))}e.width-=e.x,e.height-=e.y}else console.warn(`Data error. Please reexport DragonBones Data to fixed the bug.`);return e}_parseAnimation(t){const e=F.borrowObject(te);if(e.blendType=_._getAnimationBlendType(T._getString(t,_.BLEND_TYPE,"")),e.frameCount=T._getNumber(t,_.DURATION,0),e.playTimes=T._getNumber(t,_.PLAY_TIMES,1),e.duration=e.frameCount/this._armature.frameRate,e.fadeInTime=T._getNumber(t,_.FADE_IN_TIME,0),e.scale=T._getNumber(t,_.SCALE,1),e.name=T._getString(t,_.NAME,_.DEFAULT_NAME),e.name.length===0&&(e.name=_.DEFAULT_NAME),e.frameIntOffset=this._frameIntArray.length,e.frameFloatOffset=this._frameFloatArray.length,e.frameOffset=this._frameArray.length,this._animation=e,_.FRAME in t){const i=t[_.FRAME],s=i.length;if(s>0)for(let n=0,r=0;n0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",E.Action,0,0,this._parseActionFrame),this._actionFrames.length=0),_.TIMELINE in t){const i=t[_.TIMELINE];for(const s of i){const n=T._getNumber(s,_.TYPE,E.Action),r=T._getString(s,_.NAME,"");let o=null;switch(n){case E.Action:break;case E.SlotDisplay:case E.SlotZIndex:case E.BoneAlpha:case E.SlotAlpha:case E.AnimationProgress:case E.AnimationWeight:if(n===E.SlotDisplay?(this._frameValueType=0,this._frameValueScale=1):(this._frameValueType=1,n===E.SlotZIndex?this._frameValueScale=1:n===E.AnimationProgress||n===E.AnimationWeight?this._frameValueScale=1e4:this._frameValueScale=100),n===E.BoneAlpha||n===E.SlotAlpha||n===E.AnimationWeight?this._frameDefaultValue=1:this._frameDefaultValue=0,n===E.AnimationProgress&&e.blendType!==dt.None){o=F.borrowObject(ee);const h=o;h.x=T._getNumber(s,_.X,0),h.y=T._getNumber(s,_.Y,0)}o=this._parseTimeline(s,null,_.FRAME,n,this._frameValueType,1,this._parseSingleValueFrame,o);break;case E.BoneTranslate:case E.BoneRotate:case E.BoneScale:case E.IKConstraint:case E.AnimationParameter:n===E.IKConstraint||n===E.AnimationParameter?(this._frameValueType=1,n===E.AnimationParameter?this._frameValueScale=1e4:this._frameValueScale=100):(n===E.BoneRotate?this._frameValueScale=v.DEG_RAD:this._frameValueScale=1,this._frameValueType=2),n===E.BoneScale||n===E.IKConstraint?this._frameDefaultValue=1:this._frameDefaultValue=0,o=this._parseTimeline(s,null,_.FRAME,n,this._frameValueType,2,this._parseDoubleValueFrame);break;case E.ZOrder:break;case E.Surface:{const h=this._armature.getBone(r);if(h===null)continue;this._geometry=h.geometry,o=this._parseTimeline(s,null,_.FRAME,n,2,0,this._parseDeformFrame),this._geometry=null;break}case E.SlotDeform:{this._geometry=null;for(const h in this._armature.skins){const f=this._armature.skins[h];for(const m in f.displays){const d=f.displays[m];for(const c of d)if(c!==null&&c.name===r){this._geometry=c.geometry;break}}}if(this._geometry===null)continue;o=this._parseTimeline(s,null,_.FRAME,n,2,0,this._parseDeformFrame),this._geometry=null;break}case E.SlotColor:o=this._parseTimeline(s,null,_.FRAME,n,1,1,this._parseSlotColorFrame);break}if(o!==null)switch(n){case E.Action:break;case E.ZOrder:break;case E.BoneTranslate:case E.BoneRotate:case E.BoneScale:case E.Surface:case E.BoneAlpha:this._animation.addBoneTimeline(r,o);break;case E.SlotDisplay:case E.SlotColor:case E.SlotDeform:case E.SlotZIndex:case E.SlotAlpha:this._animation.addSlotTimeline(r,o);break;case E.IKConstraint:this._animation.addConstraintTimeline(r,o);break;case E.AnimationProgress:case E.AnimationWeight:case E.AnimationParameter:this._animation.addAnimationTimeline(r,o);break}}}return this._animation=null,e}_parseTimeline(t,e,i,s,n,r,o,h=null){if(t!==null&&i.length>0&&i in t&&(e=t[i]),e===null)return null;const f=e.length;if(f===0)return null;const m=this._frameIntArray.length,d=this._frameFloatArray.length,c=this._timelineArray.length;switch(h===null&&(h=F.borrowObject(Wt)),h.type=s,h.offset=c,this._frameValueType=n,this._timeline=h,this._timelineArray.length+=5+f,t!==null?(this._timelineArray[c+x.TimelineScale]=Math.round(T._getNumber(t,_.SCALE,1)*100),this._timelineArray[c+x.TimelineOffset]=Math.round(T._getNumber(t,_.OFFSET,0)*100)):(this._timelineArray[c+x.TimelineScale]=100,this._timelineArray[c+x.TimelineOffset]=0),this._timelineArray[c+x.TimelineKeyFrameCount]=f,this._timelineArray[c+x.TimelineFrameValueCount]=r,this._frameValueType){case 0:this._timelineArray[c+x.TimelineFrameValueOffset]=0;break;case 1:this._timelineArray[c+x.TimelineFrameValueOffset]=m-this._animation.frameIntOffset;break;case 2:this._timelineArray[c+x.TimelineFrameValueOffset]=d-this._animation.frameFloatOffset;break}if(f===1)h.frameIndicesOffset=-1,this._timelineArray[c+x.TimelineFrameOffset+0]=o.call(this,e[0],0,0)-this._animation.frameOffset;else{const A=this._animation.frameCount+1,p=this._data.frameIndices,S=p.length;p.length+=A,h.frameIndicesOffset=S;for(let O=0,y=0,g=0,D=0;O0)if(_.CURVE in t){const n=i+1;this._helpArray.length=n;const r=this._samplingEasingCurve(t[_.CURVE],this._helpArray);this._frameArray.length+=2+this._helpArray.length,this._frameArray[s+x.FrameTweenType]=J.Curve,this._frameArray[s+x.FrameTweenEasingOrCurveSampleCount]=r?n:-n;for(let o=0;o0){const r=this._armature.sortedSlots.length,o=new Array(r-n.length/2),h=new Array(r);for(let c=0;c0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+v.PI_D*this._prevClockwise)),this._prevClockwise=T._getNumber(t,_.TWEEN_ROTATE,0),this._prevRotation=s;const n=this._parseTweenFrame(t,e,i);let r=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[r++]=this._helpTransform.x,this._frameFloatArray[r++]=this._helpTransform.y,this._frameFloatArray[r++]=s,this._frameFloatArray[r++]=this._helpTransform.skew,this._frameFloatArray[r++]=this._helpTransform.scaleX,this._frameFloatArray[r++]=this._helpTransform.scaleY,this._parseActionDataInFrame(t,e,this._bone,this._slot),n}_parseBoneTranslateFrame(t,e,i){const s=this._parseTweenFrame(t,e,i);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[n++]=T._getNumber(t,_.X,0),this._frameFloatArray[n++]=T._getNumber(t,_.Y,0),s}_parseBoneRotateFrame(t,e,i){let s=T._getNumber(t,_.ROTATE,0)*v.DEG_RAD;e!==0&&(this._prevClockwise===0?s=this._prevRotation+v.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+v.PI_D*this._prevClockwise)),this._prevClockwise=T._getNumber(t,_.CLOCK_WISE,0),this._prevRotation=s;const n=this._parseTweenFrame(t,e,i);let r=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[r++]=s,this._frameFloatArray[r++]=T._getNumber(t,_.SKEW,0)*v.DEG_RAD,n}_parseBoneScaleFrame(t,e,i){const s=this._parseTweenFrame(t,e,i);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[n++]=T._getNumber(t,_.X,1),this._frameFloatArray[n++]=T._getNumber(t,_.Y,1),s}_parseSlotDisplayFrame(t,e,i){const s=this._parseFrame(t,e,i);return this._frameArray.length+=1,_.VALUE in t?this._frameArray[s+1]=T._getNumber(t,_.VALUE,0):this._frameArray[s+1]=T._getNumber(t,_.DISPLAY_INDEX,0),this._parseActionDataInFrame(t,e,this._slot.parent,this._slot),s}_parseSlotColorFrame(t,e,i){const s=this._parseTweenFrame(t,e,i);let n=-1;if(_.VALUE in t||_.COLOR in t){const o=_.VALUE in t?t[_.VALUE]:t[_.COLOR];for(let h in o){this._parseColorTransform(o,this._helpColorTransform),n=this._colorArray.length,this._colorArray.length+=8,this._colorArray[n++]=Math.round(this._helpColorTransform.alphaMultiplier*100),this._colorArray[n++]=Math.round(this._helpColorTransform.redMultiplier*100),this._colorArray[n++]=Math.round(this._helpColorTransform.greenMultiplier*100),this._colorArray[n++]=Math.round(this._helpColorTransform.blueMultiplier*100),this._colorArray[n++]=Math.round(this._helpColorTransform.alphaOffset),this._colorArray[n++]=Math.round(this._helpColorTransform.redOffset),this._colorArray[n++]=Math.round(this._helpColorTransform.greenOffset),this._colorArray[n++]=Math.round(this._helpColorTransform.blueOffset),n-=8;break}}n<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=n=this._colorArray.length,this._colorArray.length+=8,this._colorArray[n++]=100,this._colorArray[n++]=100,this._colorArray[n++]=100,this._colorArray[n++]=100,this._colorArray[n++]=0,this._colorArray[n++]=0,this._colorArray[n++]=0,this._colorArray[n++]=0),n=this._defaultColorOffset);const r=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[r]=n,s}_parseSlotDeformFrame(t,e,i){const s=this._frameFloatArray.length,n=this._parseTweenFrame(t,e,i),r=_.VERTICES in t?t[_.VERTICES]:null,o=T._getNumber(t,_.OFFSET,0),h=this._intArray[this._mesh.geometry.offset+x.GeometryVertexCount],f=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,m=this._mesh.geometry.weight;let d=0,c=0,A=0,p=0;if(m!==null){const S=this._weightSlotPose[f];this._helpMatrixA.copyFromArray(S,0),this._frameFloatArray.length+=m.count*2,A=m.offset+x.WeigthBoneIndices+m.bones.length}else this._frameFloatArray.length+=h*2;for(let S=0;S=r.length?d=0:d=r[S-o],S+1=r.length?c=0:c=r[S+1-o]),m!==null){const O=this._weightBonePoses[f],y=this._intArray[A++];this._helpMatrixA.transformPoint(d,c,this._helpPoint,!0),d=this._helpPoint.x,c=this._helpPoint.y;for(let g=0;g=r.length?m=0:m=r[c-o],c+1=r.length?d=0:d=r[c+1-o]):(m=0,d=0),this._frameFloatArray[s+c]=m,this._frameFloatArray[s+c+1]=d}if(e===0){const c=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[c+x.DeformVertexOffset]=this._geometry.offset,this._frameIntArray[c+x.DeformCount]=this._frameFloatArray.length-s,this._frameIntArray[c+x.DeformValueCount]=this._frameFloatArray.length-s,this._frameIntArray[c+x.DeformValueOffset]=0,this._frameIntArray[c+x.DeformFloatOffset]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+x.TimelineFrameValueCount]=c-this._animation.frameIntOffset}return n}_parseTransform(t,e,i){e.x=T._getNumber(t,_.X,0)*i,e.y=T._getNumber(t,_.Y,0)*i,_.ROTATE in t||_.SKEW in t?(e.rotation=v.normalizeRadian(T._getNumber(t,_.ROTATE,0)*v.DEG_RAD),e.skew=v.normalizeRadian(T._getNumber(t,_.SKEW,0)*v.DEG_RAD)):(_.SKEW_X in t||_.SKEW_Y in t)&&(e.rotation=v.normalizeRadian(T._getNumber(t,_.SKEW_Y,0)*v.DEG_RAD),e.skew=v.normalizeRadian(T._getNumber(t,_.SKEW_X,0)*v.DEG_RAD)-e.rotation),e.scaleX=T._getNumber(t,_.SCALE_X,1),e.scaleY=T._getNumber(t,_.SCALE_Y,1)}_parseColorTransform(t,e){e.alphaMultiplier=T._getNumber(t,_.ALPHA_MULTIPLIER,100)*.01,e.redMultiplier=T._getNumber(t,_.RED_MULTIPLIER,100)*.01,e.greenMultiplier=T._getNumber(t,_.GREEN_MULTIPLIER,100)*.01,e.blueMultiplier=T._getNumber(t,_.BLUE_MULTIPLIER,100)*.01,e.alphaOffset=T._getNumber(t,_.ALPHA_OFFSET,0),e.redOffset=T._getNumber(t,_.RED_OFFSET,0),e.greenOffset=T._getNumber(t,_.GREEN_OFFSET,0),e.blueOffset=T._getNumber(t,_.BLUE_OFFSET,0)}_parseGeometry(t,e){const i=t[_.VERTICES],s=Math.floor(i.length/2);let n=0;const r=this._intArray.length,o=this._floatArray.length;e.offset=r,e.data=this._data,this._intArray.length+=4,this._intArray[r+x.GeometryVertexCount]=s,this._intArray[r+x.GeometryFloatOffset]=o,this._intArray[r+x.GeometryWeightOffset]=-1,this._floatArray.length+=s*2;for(let h=0,f=s*2;h=0||_.DATA_VERSIONS.indexOf(s)>=0){const n=F.borrowObject(ve);if(n.version=i,n.name=T._getString(t,_.NAME,""),n.frameRate=T._getNumber(t,_.FRAME_RATE,24),n.frameRate===0&&(n.frameRate=24),_.ARMATURE in t){this._data=n,this._parseArray(t);const r=t[_.ARMATURE];for(const o of r)n.addArmature(this._parseArmature(o,e));this._data.binary||this._modifyArray(),_.STAGE in t?n.stage=n.getArmature(T._getString(t,_.STAGE,"")):n.armatureNames.length>0&&(n.stage=n.getArmature(n.armatureNames[0])),this._data=null}return _.TEXTURE_ATLAS in t&&(this._rawTextureAtlases=t[_.TEXTURE_ATLAS]),n}else console.assert(!1,"Nonsupport data version: "+i+` Please convert DragonBones data to support version. Read more: https://github.com/DragonBones/Tools/`);return null}parseTextureAtlasData(t,e,i=1){if(console.assert(t!==void 0),t===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0)return!1;const s=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(s,e,i),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(e.width=T._getNumber(t,_.WIDTH,0),e.height=T._getNumber(t,_.HEIGHT,0),e.scale=i===1?1/T._getNumber(t,_.SCALE,1):i,e.name=T._getString(t,_.NAME,""),e.imagePath=T._getString(t,_.IMAGE_PATH,""),_.SUB_TEXTURE in t){const s=t[_.SUB_TEXTURE];for(let n=0,r=s.length;n0&&f>0&&(m.frame=Ut.createRectangle(),m.frame.x=T._getNumber(o,_.FRAME_X,0),m.frame.y=T._getNumber(o,_.FRAME_Y,0),m.frame.width=h,m.frame.height=f),e.addTexture(m)}}return!0}static getInstance(){return T._objectDataParserInstance===null&&(T._objectDataParserInstance=new T),T._objectDataParserInstance}};a(T,"_objectDataParserInstance",null);let ot=T;class Qt{constructor(){a(this,"frameStart",0);a(this,"actions",[])}}const Mt=class Mt extends ot{constructor(){super(...arguments);a(this,"_binaryOffset");a(this,"_binary");a(this,"_intArrayBuffer");a(this,"_frameArrayBuffer");a(this,"_timelineArrayBuffer")}_inRange(t,e,i){return e<=t&&t<=i}_decodeUTF8(t){let n=0,r="",o,h=0,f=0,m=0,d=0;for(;t.length>n;){let c=t[n++];if(c===-1)f!==0?o=65533:o=-1;else if(f===0)this._inRange(c,0,127)?o=c:(this._inRange(c,194,223)?(f=1,d=128,h=c-192):this._inRange(c,224,239)?(f=2,d=2048,h=c-224):this._inRange(c,240,244)&&(f=3,d=65536,h=c-240),h=h*Math.pow(64,f),o=null);else if(!this._inRange(c,128,191))h=0,f=0,m=0,d=0,n--,o=c;else if(m+=1,h=h+(c-128)*Math.pow(64,f-m),m!==f)o=null;else{let A=h,p=d;h=0,f=0,m=0,d=0,this._inRange(A,p,1114111)&&!this._inRange(A,55296,57343)?o=A:o=c}o!==null&&o!==-1&&(o<=65535?o>0&&(r+=String.fromCharCode(o)):(o-=65536,r+=String.fromCharCode(55296+(o>>10&1023)),r+=String.fromCharCode(56320+(o&1023))))}return r}_parseBinaryTimeline(t,e,i=null){const s=i!==null?i:F.borrowObject(Wt);s.type=t,s.offset=e,this._timeline=s;const n=this._timelineArrayBuffer[s.offset+x.TimelineKeyFrameCount];if(n===1)s.frameIndicesOffset=-1;else{let r=0;const o=this._animation.frameCount+1,h=this._data.frameIndices;r=h.length,h.length+=o,s.frameIndicesOffset=r;for(let f=0,m=0,d=0,c=0;f=0){const o=ot._getNumber(n,_.TYPE,E.Action),h=ot._getString(n,_.NAME,"");let f=null;if(o===E.AnimationProgress&&e.blendType!==dt.None){f=F.borrowObject(ee);const m=f;m.x=ot._getNumber(n,_.X,0),m.y=ot._getNumber(n,_.Y,0)}switch(f=this._parseBinaryTimeline(o,r,f),o){case E.Action:break;case E.ZOrder:break;case E.BoneTranslate:case E.BoneRotate:case E.BoneScale:case E.Surface:case E.BoneAlpha:this._animation.addBoneTimeline(h,f);break;case E.SlotDisplay:case E.SlotColor:case E.SlotDeform:case E.SlotZIndex:case E.SlotAlpha:this._animation.addSlotTimeline(h,f);break;case E.IKConstraint:this._animation.addConstraintTimeline(h,f);break;case E.AnimationProgress:case E.AnimationWeight:case E.AnimationParameter:this._animation.addAnimationTimeline(h,f);break}}}}return this._animation=null,e}_parseGeometry(t,e){e.offset=t[_.OFFSET],e.data=this._data;const i=this._intArrayBuffer[e.offset+x.GeometryWeightOffset];if(i>=0){const s=F.borrowObject(se),n=this._intArrayBuffer[e.offset+x.GeometryVertexCount],r=this._intArrayBuffer[i+x.WeigthBoneCount];s.offset=i;for(let f=0;f12?e[13]:0,m=new Uint16Array(this._binary,this._binaryOffset+e[0],i/Uint16Array.BYTES_PER_ELEMENT),d=new Float32Array(this._binary,this._binaryOffset+e[2],s/Float32Array.BYTES_PER_ELEMENT),c=new Int16Array(this._binary,this._binaryOffset+e[4],n/Int16Array.BYTES_PER_ELEMENT),A=new Float32Array(this._binary,this._binaryOffset+e[6],r/Float32Array.BYTES_PER_ELEMENT),p=new Int16Array(this._binary,this._binaryOffset+e[8],o/Int16Array.BYTES_PER_ELEMENT),S=new Uint16Array(this._binary,this._binaryOffset+e[10],h/Uint16Array.BYTES_PER_ELEMENT),O=f>0?new Uint16Array(this._binary,this._binaryOffset+e[12],f/Uint16Array.BYTES_PER_ELEMENT):m;this._data.binary=this._binary,this._data.intArray=this._intArrayBuffer=m,this._data.floatArray=d,this._data.frameIntArray=c,this._data.frameFloatArray=A,this._data.frameArray=this._frameArrayBuffer=p,this._data.timelineArray=this._timelineArrayBuffer=S,this._data.colorArray=O}parseDragonBonesData(t,e=1){console.assert(t!=null&&t instanceof ArrayBuffer,"Data error.");const i=new Uint8Array(t,0,8);if(i[0]!==68||i[1]!==66||i[2]!==68||i[3]!==84)return console.assert(!1,"Nonsupport data."),null;const s=new Uint32Array(t,8,1)[0],n=new Uint8Array(t,12,s),r=this._decodeUTF8(n),o=JSON.parse(r);return this._binaryOffset=12+s,this._binary=t,super.parseDragonBonesData(o,e)}static getInstance(){return Mt._binaryDataParserInstance===null&&(Mt._binaryDataParserInstance=new Mt),Mt._binaryDataParserInstance}};a(Mt,"_binaryDataParserInstance",null);let Jt=Mt;const gt=class gt{constructor(l=null){a(this,"autoSearch",!1);a(this,"_dragonBonesDataMap",{});a(this,"_textureAtlasDataMap",{});a(this,"_dragonBones",null);a(this,"_dataParser",null);gt._objectParser===null&&(gt._objectParser=new ot),gt._binaryParser===null&&(gt._binaryParser=new Jt),this._dataParser=l!==null?l:gt._objectParser}_isSupportMesh(){return!0}_getTextureData(l,t){if(l in this._textureAtlasDataMap)for(const e of this._textureAtlasDataMap[l]){const i=e.getTexture(t);if(i!==null)return i}if(this.autoSearch){for(let e in this._textureAtlasDataMap)for(const i of this._textureAtlasDataMap[e])if(i.autoSearch){const s=i.getTexture(t);if(s!==null)return s}}return null}_fillBuildArmaturePackage(l,t,e,i,s){let n=null,r=null;if(t.length>0&&t in this._dragonBonesDataMap&&(n=this._dragonBonesDataMap[t],r=n.getArmature(e)),r===null&&(t.length===0||this.autoSearch)){for(let o in this._dragonBonesDataMap)if(n=this._dragonBonesDataMap[o],(t.length===0||n.autoSearch)&&(r=n.getArmature(e),r!==null)){t=o;break}}if(r!==null){if(l.dataName=t,l.textureAtlasName=s,l.data=n,l.armature=r,l.skin=null,i.length>0&&(l.skin=r.getSkin(i),l.skin===null&&this.autoSearch))for(let o in this._dragonBonesDataMap){const f=this._dragonBonesDataMap[o].getArmature(i);if(f!==null){l.skin=f.defaultSkin;break}}return l.skin===null&&(l.skin=r.defaultSkin),!0}return!1}_buildBones(l,t){for(const e of l.armature.sortedBones)F.borrowObject(e.type===$.Bone?le:ft).init(e,t)}_buildSlots(l,t){const e=l.skin,i=l.armature.defaultSkin;if(e===null||i===null)return;const s={};for(let n in i.displays){const r=i.getDisplays(n);s[n]=r}if(e!==i)for(let n in e.displays){const r=e.getDisplays(n);s[n]=r}for(const n of l.armature.sortedSlots){const r=n.name in s?s[n.name]:null,o=this._buildSlot(l,n,t);if(r!==null){o.displayFrameCount=r.length;for(let h=0,f=o.displayFrameCount;h0){const c=this._getTextureData(l.textureAtlasName,m.path);o.replaceTextureData(c,h)}const d=this._getSlotDisplay(l,m,o);o.replaceDisplay(d,h)}else o.replaceDisplay(null)}}o._setDisplayIndex(n.displayIndex,!0)}}_buildConstraints(l,t){const e=l.armature.constraints;for(let i in e){const s=e[i];switch(s.type){case It.IK:const n=F.borrowObject(oe);n.init(s,t),t._addConstraint(n);break;case It.Path:const r=F.borrowObject(Le);r.init(s,t),t._addConstraint(r);break;default:const o=F.borrowObject(oe);o.init(s,t),t._addConstraint(o);break}}}_buildChildArmature(l,t,e){return this.buildArmature(e.path,l!==null?l.dataName:"","",l!==null?l.textureAtlasName:"")}_getSlotDisplay(l,t,e){const i=l!==null?l.dataName:t.parent.parent.parent.name;let s=null;switch(t.type){case L.Image:{const n=t;n.texture===null&&(n.texture=this._getTextureData(i,t.path)),s=e.rawDisplay;break}case L.Mesh:{const n=t;n.texture===null&&(n.texture=this._getTextureData(i,n.path)),this._isSupportMesh()?s=e.meshDisplay:s=e.rawDisplay;break}case L.Armature:{const n=t,r=this._buildChildArmature(l,e,n);if(r!==null){if(r.inheritAnimation=n.inheritAnimation,!r.inheritAnimation){const o=n.actions.length>0?n.actions:r.armatureData.defaultActions;if(o.length>0)for(const h of o){const f=F.borrowObject(j);j.actionDataToInstance(h,f,e.armature),f.slot=e,e.armature._bufferAction(f,!1)}else r.animation.play()}n.armature=r.armatureData}s=r;break}case L.BoundingBox:break}return s}parseDragonBonesData(l,t=null,e=1){const i=l instanceof ArrayBuffer?gt._binaryParser:this._dataParser,s=i.parseDragonBonesData(l,e);for(;;){const n=this._buildTextureAtlasData(null,null);if(i.parseTextureAtlasData(null,n,e))this.addTextureAtlasData(n,t);else{n.returnToPool();break}}return s!==null&&this.addDragonBonesData(s,t),s}parseTextureAtlasData(l,t,e=null,i=1){const s=this._buildTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(l,s,i),this._buildTextureAtlasData(s,t||null),this.addTextureAtlasData(s,e),s}updateTextureAtlases(l,t){const e=this.getTextureAtlasData(t);if(e!==null)for(let i=0,s=e.length;i=0)continue;let o=t.getDisplays(r.name);if(o===null&&(n!==null&&t!==n&&(o=n.getDisplays(r.name)),o===null)){e&&(r.displayFrameCount=0);continue}r.displayFrameCount=o.length;for(let h=0,f=r.displayFrameCount;h=0&&this._displayIndex0)for(const r of s){const o=F.borrowObject(j);j.actionDataToInstance(r,o,this._armature),o.slot=this,this._armature._bufferAction(o,!1)}else this._childArmature.animation.play()}}}_updateGlobalTransformMatrix(t){const e=this._parent._boneData.type===$.Bone?this._parent.globalTransformMatrix:this._parent._getGlobalTransformMatrix(this.global.x,this.global.y);this.globalTransformMatrix.copyFrom(this._localMatrix),this.globalTransformMatrix.concat(e),t?this.global.fromMatrix(this.globalTransformMatrix):this._globalDirty=!0}_setDisplayIndex(t,e=!1){if(e){if(this._animationDisplayIndex===t)return;this._animationDisplayIndex=t}this._displayIndex!==t&&(this._displayIndex=t=0&&this._cachedFrameIndices!==null){const 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(this._transformDirty){if(this._cachedFrameIndex<0){const e=t>=0;this._updateGlobalTransformMatrix(e),e&&this._cachedFrameIndices!==null&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);this._updateTransform(),this._transformDirty=!1}}}invalidUpdate(){this._displayDataDirty=!0,this._displayDirty=!0,this._transformDirty=!0}updateTransformAndMatrix(){this._transformDirty&&(this._updateGlobalTransformMatrix(!1),this._transformDirty=!1)}replaceRawDisplayData(t,e=-1){if(e<0)e=this._displayIndex<0?0:this._displayIndex;else if(e>=this._displayFrames.length)return;const i=this._displayFrames[e];if(i.rawDisplayData!==t){if(i.deformVertices.length=0,i.rawDisplayData=t,i.rawDisplayData===null){const s=this._armature._armatureData.defaultSkin;if(s!==null){const n=s.getDisplays(this._slotData.name);n!==null&&e=this._displayFrames.length)return;const i=this._displayFrames[e];i.displayData!==t&&i.rawDisplayData!==t&&(i.displayData=t,e===this._displayIndex&&(this._displayDataDirty=!0))}replaceTextureData(t,e=-1){if(e<0)e=this._displayIndex<0?0:this._displayIndex;else if(e>=this._displayFrames.length)return;const i=this._displayFrames[e];i.textureData!==t&&(i.textureData=t,e===this._displayIndex&&(this._displayDataDirty=!0))}replaceDisplay(t,e=-1){if(e<0)e=this._displayIndex<0?0:this._displayIndex;else if(e>=this._displayFrames.length)return;const i=this._displayFrames[e];if(i.display!==t){const s=i.display;i.display=t,s!==null&&s!==this._rawDisplay&&s!==this._meshDisplay&&!this._hasDisplay(s)&&(s instanceof bt||this._disposeDisplay(s,!0)),t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(s)&&!(t instanceof bt)&&this._initDisplay(t,!0),e===this._displayIndex&&(this._displayDirty=!0)}}containsPoint(t,e){return this._boundingBoxData===null?!1:(this.updateTransformAndMatrix(),Y._helpMatrix.copyFrom(this.globalTransformMatrix),Y._helpMatrix.invert(),Y._helpMatrix.transformPoint(t,e,Y._helpPoint),this._boundingBoxData.containsPoint(Y._helpPoint.x,Y._helpPoint.y))}intersectsSegment(t,e,i,s,n=null,r=null,o=null){if(this._boundingBoxData===null)return 0;this.updateTransformAndMatrix(),Y._helpMatrix.copyFrom(this.globalTransformMatrix),Y._helpMatrix.invert(),Y._helpMatrix.transformPoint(t,e,Y._helpPoint),t=Y._helpPoint.x,e=Y._helpPoint.y,Y._helpMatrix.transformPoint(i,s,Y._helpPoint),i=Y._helpPoint.x,s=Y._helpPoint.y;const h=this._boundingBoxData.intersectsSegment(t,e,i,s,n,r,o);return h>0&&(h===1||h===2?n!==null?(this.globalTransformMatrix.transformPoint(n.x,n.y,n),r!==null&&(r.x=n.x,r.y=n.y)):r!==null&&this.globalTransformMatrix.transformPoint(r.x,r.y,r):(n!==null&&this.globalTransformMatrix.transformPoint(n.x,n.y,n),r!==null&&this.globalTransformMatrix.transformPoint(r.x,r.y,r)),o!==null&&(this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),Y._helpPoint,!0),o.x=Math.atan2(Y._helpPoint.y,Y._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),Y._helpPoint,!0),o.y=Math.atan2(Y._helpPoint.y,Y._helpPoint.x))),h}getDisplayFrameAt(t){return this._displayFrames[t]}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._updateVisible())}get displayFrameCount(){return this._displayFrames.length}set displayFrameCount(t){const e=this._displayFrames.length;if(et){for(let i=e-1;i0}addDBEventListener(t,e,i){this.addListener(t,e,i)}removeDBEventListener(t,e,i){this.removeListener(t,e,i)}get armature(){return this._armature}get animation(){return this._armature.animation}}class _e extends Pe{constructor(){super(...arguments);a(this,"_renderTexture",null)}static toString(){return"[class dragonBones.PixiTextureAtlasData]"}_onClear(){super._onClear(),this._renderTexture,this._renderTexture=null}createTexture(){return F.borrowObject(Ue)}get renderTexture(){return this._renderTexture}set renderTexture(t){if(this._renderTexture!==t)if(this._renderTexture=t,this._renderTexture!==null)for(let e in this.textures){const i=this.textures[e];i.renderTexture=new W.Texture({source:this._renderTexture.source,frame:new W.Rectangle(i.region.x,i.region.y,i.region.width,i.region.height),orig:new W.Rectangle(i.region.x,i.region.y,i.region.width,i.region.height),trim:new W.Rectangle(0,0,i.region.width,i.region.height),rotate:i.rotated?2:0})}else for(let e in this.textures){const i=this.textures[e];i.renderTexture=null}}}class Ue extends Ut{constructor(){super(...arguments);a(this,"renderTexture",null)}static toString(){return"[class dragonBones.PixiTextureData]"}_onClear(){super._onClear(),this.renderTexture!==null&&this.renderTexture.destroy(!1),this.renderTexture=null}}class Ge extends Y{constructor(){super(...arguments);a(this,"_textureScale");a(this,"_renderDisplay")}static toString(){return"[class dragonBones.PixiSlot]"}_onClear(){super._onClear(),this._textureScale=1,this._renderDisplay=null,this._updateTransform=this._updateTransformV4}_initDisplay(t,e){}_disposeDisplay(t,e){e||t.destroy()}_onUpdateDisplay(){this._renderDisplay=this._display?this._display:this._rawDisplay}_addDisplay(){this._armature.display.addChild(this._renderDisplay)}_replaceDisplay(t){const e=this._armature.display,i=t;e.addChild(this._renderDisplay),e.swapChildren(this._renderDisplay,i),e.removeChild(i),this._textureScale=1}_removeDisplay(){this._renderDisplay.parent.removeChild(this._renderDisplay)}_updateZOrder(){const t=this._armature.display;t.getChildIndex(this._renderDisplay)!==this._zOrder&&t.addChildAt(this._renderDisplay,this._zOrder)}_updateVisible(){this._renderDisplay.visible=this._parent.visible&&this._visible}_updateBlendMode(){if(this._renderDisplay instanceof Gt.Sprite)switch(this._blendMode){case z.Normal:this._renderDisplay.blendMode="normal";break;case z.Add:this._renderDisplay.blendMode="add";break;case z.Darken:this._renderDisplay.blendMode="darken";break;case z.Difference:this._renderDisplay.blendMode="difference";break;case z.HardLight:this._renderDisplay.blendMode="hard-light";break;case z.Lighten:this._renderDisplay.blendMode="lighten";break;case z.Multiply:this._renderDisplay.blendMode="multiply";break;case z.Overlay:this._renderDisplay.blendMode="overlay";break;case z.Screen:this._renderDisplay.blendMode="screen";break}}_updateColor(){const t=this._colorTransform.alphaMultiplier*this._globalAlpha;if(this._renderDisplay.alpha=t,this._renderDisplay instanceof W.Sprite||this._renderDisplay instanceof W.MeshSimple){const e=(Math.round(this._colorTransform.redMultiplier*255)<<16)+(Math.round(this._colorTransform.greenMultiplier*255)<<8)+Math.round(this._colorTransform.blueMultiplier*255);this._renderDisplay.tint=e}}_updateFrame(){let t=this._textureData;if(this._displayIndex>=0&&this._display!==null&&t!==null){let e=t.parent;this._armature.replacedTexture!==null&&(this._armature._replaceTextureAtlasData===null?(e=F.borrowObject(_e),e.copyFrom(t.parent),e.renderTexture=this._armature.replacedTexture,this._armature._replaceTextureAtlasData=e):e=this._armature._replaceTextureAtlasData,t=e.getTexture(t.name));const i=t.renderTexture;if(i!==null){if(this._geometryData!==null){const s=this._geometryData.data,n=s.intArray,r=s.floatArray,o=n[this._geometryData.offset+x.GeometryVertexCount],h=n[this._geometryData.offset+x.GeometryTriangleCount];let f=n[this._geometryData.offset+x.GeometryFloatOffset];f<0&&(f+=65536);const m=f+o*2,d=this._armature._armatureData.scale,c=this._renderDisplay,A=new Float32Array(o*2),p=new Float32Array(o*2),S=new Uint16Array(h*3);for(let g=0,D=o*2;g0&&s.inheritDeform,o=this._renderDisplay;if(n!==null){const h=s.data,f=h.intArray,m=h.floatArray,d=f[s.offset+x.GeometryVertexCount];let c=f[n.offset+x.WeigthFloatOffset];c<0&&(c+=65536);for(let A=0,p=0,S=n.offset+x.WeigthBoneIndices+i.length,O=c,y=0;A