(function(at,X){typeof exports=="object"&&typeof module<"u"?X(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],X):(at=typeof globalThis<"u"?globalThis:at||self,X(at.dragonBonesThree={},at.three))})(this,function(at,X){"use strict";var $e=Object.defineProperty;var Je=(at,X,At)=>X in at?$e(at,X,{enumerable:!0,configurable:!0,writable:!0,value:At}):at[X]=At;var ht=(at,X,At)=>(Je(at,typeof X!="symbol"?X+"":X,At),At);var At=Object.defineProperty,Ee=(a,t,i)=>t in a?At(a,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[t]=i,r=(a,t,i)=>(Ee(a,typeof t!="symbol"?t+"":t,i),i);class Se{constructor(t=0){r(this,"time",0),r(this,"timeScale",1),r(this,"_systemTime",0),r(this,"_animatebles",[]),r(this,"_clock",null),this.time=t,this._systemTime=new Date().getTime()*.001}advanceTime(t){t!==t&&(t=0);const i=Date.now()*.001;if(t<0&&(t=i-this._systemTime),this._systemTime=i,this.timeScale!==1&&(t*=this.timeScale),t===0)return;t<0?this.time-=t:this.time+=t;let e=0,s=0,n=this._animatebles.length;for(;e0&&(this._animatebles[e-s]=l,this._animatebles[e]=null),l.advanceTime(t)):s++}if(s>0){for(n=this._animatebles.length;e=0&&(this._animatebles[i]=null,t.clock=null)}clear(){for(const t of this._animatebles)t!==null&&(t.clock=null)}get clock(){return this._clock}set clock(t){this._clock!==t&&(this._clock!==null&&this._clock.remove(this),this._clock=t,this._clock!==null&&this._clock.add(this))}}const Q=class{constructor(){r(this,"hashCode",Q._hashCode++),r(this,"_isInPool",!1)}static _returnObject(a){const t=String(a.constructor),i=t in Q._maxCountMap?Q._maxCountMap[t]:Q._defaultMaxCount,e=Q._poolsMap[t]=Q._poolsMap[t]||[];e.lengtht&&(e.length=t),Q._maxCountMap[i]=t}else{Q._defaultMaxCount=t;for(let i in Q._poolsMap){const e=Q._poolsMap[i];e.length>t&&(e.length=t),i in Q._maxCountMap&&(Q._maxCountMap[i]=t)}}}static clearPool(a=null){if(a!==null){const t=String(a),i=t in Q._poolsMap?Q._poolsMap[t]:null;i!==null&&i.length>0&&(i.length=0)}else for(let t in Q._poolsMap){const i=Q._poolsMap[t];i.length=0}}static borrowObject(a){const t=String(a),i=t in Q._poolsMap?Q._poolsMap[t]:null;if(i!==null&&i.length>0){const s=i.pop();return s._isInPool=!1,s}const e=new a;return e._onClear(),e}returnToPool(){this._onClear(),Q._returnObject(this)}};let b=Q;r(b,"_hashCode",0),r(b,"_defaultMaxCount",3e3),r(b,"_maxCountMap",{}),r(b,"_poolsMap",{});const Rt=class extends b{constructor(){super(...arguments),r(this,"time",0),r(this,"type",""),r(this,"name",""),r(this,"armature",null),r(this,"bone",null),r(this,"slot",null),r(this,"animationState",null),r(this,"actionData",null),r(this,"data",null)}static actionDataToInstance(a,t,i){if(a.name===void 0)throw new Error("data.name is undefined.");if(a.name===void 0)throw new Error("data.name is undefined.");a.type===K.Play?t.type=Rt.FRAME_EVENT:t.type=a.type===K.Frame?Rt.FRAME_EVENT:Rt.SOUND_EVENT,t.name=a.name,t.armature=i,t.actionData=a,t.data=a.data,a.bone!==null&&(t.bone=i.getBone(a.bone.name)),a.slot!==null&&(t.slot=i.getSlot(a.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}};let Y=Rt;r(Y,"START","start"),r(Y,"LOOP_COMPLETE","loopComplete"),r(Y,"COMPLETE","complete"),r(Y,"FADE_IN","fadeIn"),r(Y,"FADE_IN_COMPLETE","fadeInComplete"),r(Y,"FADE_OUT","fadeOut"),r(Y,"FADE_OUT_COMPLETE","fadeOutComplete"),r(Y,"FRAME_EVENT","frameEvent"),r(Y,"SOUND_EVENT","soundEvent");var w=(a=>(a[a.WeigthBoneCount=0]="WeigthBoneCount",a[a.WeigthFloatOffset=1]="WeigthFloatOffset",a[a.WeigthBoneIndices=2]="WeigthBoneIndices",a[a.GeometryVertexCount=0]="GeometryVertexCount",a[a.GeometryTriangleCount=1]="GeometryTriangleCount",a[a.GeometryFloatOffset=2]="GeometryFloatOffset",a[a.GeometryWeightOffset=3]="GeometryWeightOffset",a[a.GeometryVertexIndices=4]="GeometryVertexIndices",a[a.TimelineScale=0]="TimelineScale",a[a.TimelineOffset=1]="TimelineOffset",a[a.TimelineKeyFrameCount=2]="TimelineKeyFrameCount",a[a.TimelineFrameValueCount=3]="TimelineFrameValueCount",a[a.TimelineFrameValueOffset=4]="TimelineFrameValueOffset",a[a.TimelineFrameOffset=5]="TimelineFrameOffset",a[a.FramePosition=0]="FramePosition",a[a.FrameTweenType=1]="FrameTweenType",a[a.FrameTweenEasingOrCurveSampleCount=2]="FrameTweenEasingOrCurveSampleCount",a[a.FrameCurveSamples=3]="FrameCurveSamples",a[a.DeformVertexOffset=0]="DeformVertexOffset",a[a.DeformCount=1]="DeformCount",a[a.DeformValueCount=2]="DeformValueCount",a[a.DeformValueOffset=3]="DeformValueOffset",a[a.DeformFloatOffset=4]="DeformFloatOffset",a))(w||{}),yt=(a=>(a[a.Armature=0]="Armature",a[a.MovieClip=1]="MovieClip",a[a.Stage=2]="Stage",a))(yt||{}),et=(a=>(a[a.Bone=0]="Bone",a[a.Surface=1]="Surface",a))(et||{}),L=(a=>(a[a.Image=0]="Image",a[a.Armature=1]="Armature",a[a.Mesh=2]="Mesh",a[a.BoundingBox=3]="BoundingBox",a[a.Path=4]="Path",a))(L||{}),nt=(a=>(a[a.Rectangle=0]="Rectangle",a[a.Ellipse=1]="Ellipse",a[a.Polygon=2]="Polygon",a))(nt||{}),K=(a=>(a[a.Play=0]="Play",a[a.Frame=10]="Frame",a[a.Sound=11]="Sound",a))(K||{}),$=(a=>(a[a.Normal=0]="Normal",a[a.Add=1]="Add",a[a.Alpha=2]="Alpha",a[a.Darken=3]="Darken",a[a.Difference=4]="Difference",a[a.Erase=5]="Erase",a[a.HardLight=6]="HardLight",a[a.Invert=7]="Invert",a[a.Layer=8]="Layer",a[a.Lighten=9]="Lighten",a[a.Multiply=10]="Multiply",a[a.Overlay=11]="Overlay",a[a.Screen=12]="Screen",a[a.Subtract=13]="Subtract",a))($||{}),q=(a=>(a[a.None=0]="None",a[a.Line=1]="Line",a[a.Curve=2]="Curve",a[a.QuadIn=3]="QuadIn",a[a.QuadOut=4]="QuadOut",a[a.QuadInOut=5]="QuadInOut",a))(q||{}),x=(a=>(a[a.Action=0]="Action",a[a.ZOrder=1]="ZOrder",a[a.BoneAll=10]="BoneAll",a[a.BoneTranslate=11]="BoneTranslate",a[a.BoneRotate=12]="BoneRotate",a[a.BoneScale=13]="BoneScale",a[a.Surface=50]="Surface",a[a.BoneAlpha=60]="BoneAlpha",a[a.SlotDisplay=20]="SlotDisplay",a[a.SlotColor=21]="SlotColor",a[a.SlotDeform=22]="SlotDeform",a[a.SlotZIndex=23]="SlotZIndex",a[a.SlotAlpha=24]="SlotAlpha",a[a.IKConstraint=30]="IKConstraint",a[a.AnimationProgress=40]="AnimationProgress",a[a.AnimationWeight=41]="AnimationWeight",a[a.AnimationParameter=42]="AnimationParameter",a))(x||{}),Mt=(a=>(a[a.None=0]="None",a[a.Additive=1]="Additive",a[a.Override=2]="Override",a))(Mt||{}),mt=(a=>(a[a.SameLayer=1]="SameLayer",a[a.SameGroup=2]="SameGroup",a[a.SameLayerAndGroup=3]="SameLayerAndGroup",a[a.All=4]="All",a[a.Single=5]="Single",a))(mt||{}),_t=(a=>(a[a.None=0]="None",a[a.E1D=1]="E1D",a))(_t||{}),wt=(a=>(a[a.IK=0]="IK",a[a.Path=1]="Path",a))(wt||{}),bt=(a=>(a[a.Fixed=0]="Fixed",a[a.Percent=1]="Percent",a))(bt||{}),pt=(a=>(a[a.Length=0]="Length",a[a.Fixed=1]="Fixed",a[a.Percent=2]="Percent",a))(pt||{}),ft=(a=>(a[a.Tangent=0]="Tangent",a[a.Chain=1]="Chain",a[a.ChainScale=2]="ChainScale",a))(ft||{});const ie=class{constructor(a){r(this,"_clock",new Se),r(this,"_events",[]),r(this,"_objects",[]),r(this,"_eventManager",null),this._eventManager=a,console.info(`DragonBones: ${ie.VERSION} Website: http://dragonbones.com/ Source and Demo: https://github.com/DragonBones/`)}advanceTime(a){if(this._objects.length>0){for(const t of this._objects)t.returnToPool();this._objects.length=0}if(this._clock.advanceTime(a),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){if(this._animationState===null)throw new Error("this._animationState is null.");if(this._animationData===null)throw new Error("this._animationData is null.");const n=this._animationState.playTimes,l=n*this._duration;t*=this._timeScale,this._timeOffset!==0&&(t+=this._timeOffset*this._animationData.duration),n>0&&(t>=l||t<=-l)?(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===e&&this.currentTime===s?!1:((i<0&&this.playState!==i||this.playState<=0&&this.currentPlayTimes!==e)&&(this._frameIndex=-1),!0)}init(t,i,e){if(this._armature=t,this._animationState=i,this._timelineData=e,this._actionTimeline=this._animationState._actionTimeline,this===this._actionTimeline&&(this._actionTimeline=null),this._animationData=this._animationState.animationData,this._animationData.parent===null)throw new Error("this._animationData.parent is null.");if(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;if(s===null)throw new Error("dragonBonesData is null.");if(this._frameArray=s.frameArray,this._timelineArray=s.timelineArray,this._frameIndices=s.frameIndices,this._timelineArray===null)throw new Error("this._timelineArray is null.");this._frameCount=this._timelineArray[this._timelineData.offset+w.TimelineKeyFrameCount],this._frameValueOffset=this._timelineArray[this._timelineData.offset+w.TimelineFrameValueOffset],this._timeScale=100/this._timelineArray[this._timelineData.offset+w.TimelineScale],this._timeOffset=this._timelineArray[this._timelineData.offset+w.TimelineOffset]*.01}}fadeOut(){this.dirty=!1}update(t){if(this._setCurrentTime(t)){if(this._frameCount>1){const i=Math.floor(this.currentTime*this._frameRate);if(this._frameIndices===null)throw new Error("this._frameIndices is null.");const e=this._frameIndices[this._timelineData.frameIndicesOffset+i];if(this._frameIndex!==e){if(this._frameIndex=e,this._animationData===null)throw new Error(" this._animationData is null.");if(this._timelineArray===null)throw new Error(" this._timelineArray is null.");this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+w.TimelineFrameOffset+this._frameIndex],this._onArriveAtFrame()}}else if(this._frameIndex<0){if(this._frameIndex=0,this._timelineData!==null){if(this._animationData===null)throw new Error(" this._animationData is null.");if(this._timelineArray===null)throw new Error(" this._timelineArray is null.");this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+w.TimelineFrameOffset]}this._onArriveAtFrame()}(this._isTween||this.dirty)&&this._onUpdateFrame()}}blend(t){}}class Et extends kt{constructor(){super(...arguments),r(this,"_tweenType",q.None),r(this,"_curveCount",0),r(this,"_framePosition",0),r(this,"_frameDurationR",0),r(this,"_tweenEasing",0),r(this,"_tweenProgress",0),r(this,"_valueScale",1)}static _getEasingValue(t,i,e){let s=i;switch(t){case q.QuadIn:s=Math.pow(i,2);break;case q.QuadOut:s=1-Math.pow(1-i,2);break;case q.QuadInOut:s=.5*(1-Math.cos(i*Math.PI));break}return(s-i)*e+i}static _getEasingCurveValue(t,i,e,s){if(t<=0)return 0;if(t>=1)return 1;const n=e>0,l=e+1,h=Math.floor(t*l);let _=0,m=0;return n?(_=h===0?0:i[s+h-1],m=h===l-1?1e4:i[s+h]):(_=i[s+h-1],m=i[s+h]),(_+(m-_)*(t*l-h))*1e-4}_onClear(){super._onClear(),this._tweenType=q.None,this._curveCount=0,this._framePosition=0,this._frameDurationR=0,this._tweenEasing=0,this._tweenProgress=0,this._valueScale=1}_onArriveAtFrame(){if(this._animationState===null)throw new Error(" this._animationState is null.");if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0?this._frameDurationR=1/i:this._frameDurationR=0}}else this.dirty=!0,this._isTween=!1}_onUpdateFrame(){if(this._isTween)if(this.dirty=!0,this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR,this._tweenType===q.Curve){if(this._frameArray===null)throw new Error(" this._frameArray is null.");this._tweenProgress=Et._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+w.FrameCurveSamples)}else this._tweenType!==q.Line&&(this._tweenProgress=Et._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing))}}class Ct extends Et{constructor(){super(...arguments),r(this,"_currentA",0),r(this,"_currentB",0),r(this,"_differenceA",0),r(this,"_differenceB",0),r(this,"_resultA",0),r(this,"_resultB",0)}_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,i=this._valueArray,e=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(i===null)throw new Error("valueArray is null.");if(this._isTween){const s=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:e+2;t===1?(this._currentA=i[e],this._currentB=i[e+1],this._differenceA=i[s]-this._currentA,this._differenceB=i[s+1]-this._currentB):(this._currentA=i[e]*t,this._currentB=i[e+1]*t,this._differenceA=i[s]*t-this._currentA,this._differenceB=i[s+1]*t-this._currentB)}else this._resultA=i[e]*t,this._resultB=i[e+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 jt extends Et{constructor(){super(...arguments),r(this,"_valueCount",0),r(this,"_rd",[])}_onClear(){super._onClear(),this._valueCount=0,this._rd.length=0}_onArriveAtFrame(){super._onArriveAtFrame();const t=this._valueCount,i=this._rd;if(this._timelineData!==null){const e=this._valueScale,s=this._valueArray;if(s===null)throw new Error("valueArray is null.");const n=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){const l=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:n+t;if(e===1)for(let h=0;h0?-Math.PI:Math.PI,a}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(a){return this.x=a.x,this.y=a.y,this.skew=a.skew,this.rotation=a.rotation,this.scaleX=a.scaleX,this.scaleY=a.scaleY,this}identity(){return this.x=this.y=0,this.skew=this.rotation=0,this.scaleX=this.scaleY=1,this}add(a){return this.x+=a.x,this.y+=a.y,this.skew+=a.skew,this.rotation+=a.rotation,this.scaleX*=a.scaleX,this.scaleY*=a.scaleY,this}minus(a){return this.x-=a.x,this.y-=a.y,this.skew-=a.skew,this.rotation-=a.rotation,this.scaleX/=a.scaleX,this.scaleY/=a.scaleY,this}fromMatrix(a){const t=this.scaleX,i=this.scaleY,e=ae.PI_Q;this.x=a.tx,this.y=a.ty,this.rotation=Math.atan(a.b/a.a);let s=Math.atan(-a.c/a.d);return this.scaleX=this.rotation>-e&&this.rotation-e&&s=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.rotation=this.rotation-Math.PI),i>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,s=s-Math.PI),this.skew=s-this.rotation,this}toMatrix(a){return this.rotation===0?(a.a=1,a.b=0):(a.a=Math.cos(this.rotation),a.b=Math.sin(this.rotation)),this.skew===0?(a.c=-a.b,a.d=a.a):(a.c=-Math.sin(this.skew+this.rotation),a.d=Math.cos(this.skew+this.rotation)),this.scaleX!==1&&(a.a*=this.scaleX,a.b*=this.scaleX),this.scaleY!==1&&(a.c*=this.scaleY,a.d*=this.scaleY),a.tx=this.x,a.ty=this.y,this}};let R=ae;r(R,"PI",Math.PI),r(R,"PI_D",Math.PI*2),r(R,"PI_H",Math.PI/2),r(R,"PI_Q",Math.PI/4),r(R,"RAD_DEG",180/Math.PI),r(R,"DEG_RAD",Math.PI/180);class Oe extends kt{static toString(){return"[class dragonBones.ActionTimelineState]"}_onCrossFrame(t){if(this._armature===null)throw new Error("this._armature is null.");if(this._animationState===null)throw new Error("this._animationState is null.");if(this._animationData===null)throw new Error("this._animationData is null.");if(this._timelineArray===null)throw new Error("this._timelineArray is null.");if(this._frameArray===null)throw new Error("this._frameArray is null.");if(this._animationData.parent===null)throw new Error("this._animationData.parent is null.");if(this._armature._dragonBones===null)throw new Error(" this._armature._dragonBones is null.");const i=this._armature.eventDispatcher;if(this._animationState.actionEnabled){const e=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+w.TimelineFrameOffset+t],s=this._frameArray[e+1],n=this._animationData.parent.actions;for(let l=0;l0&&l.hasDBEventListener(Y.COMPLETE)&&(m=b.borrowObject(Y),m.type=Y.COMPLETE,m.armature=this._armature,m.animationState=this._animationState)),this._frameCount>1){const c=this._timelineData,u=Math.floor(this.currentTime*this._frameRate);if(this._frameIndices===null)throw new Error(" this._frameIndices is null.");const f=this._frameIndices[c.frameIndicesOffset+u];if(this._frameIndex!==f){let T=this._frameIndex;if(this._frameIndex=f,this._timelineArray!==null)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[c.offset+w.TimelineFrameOffset+this._frameIndex],h){if(T<0){const g=Math.floor(s*this._frameRate);T=this._frameIndices[c.frameIndicesOffset+g],this.currentPlayTimes===e&&T===f&&(T=-1)}for(;T>=0;){const g=this._animationData.frameOffset+this._timelineArray[c.offset+w.TimelineFrameOffset+T];if(this._frameArray===null)throw new Error("this._frameArray is null.");const y=this._frameArray[g]/this._frameRate;if(this._position<=y&&y<=this._position+this._duration&&this._onCrossFrame(T),_!==null&&T===0&&(this._armature._dragonBones.bufferEvent(_),_=null),T>0?T--:T=this._frameCount-1,T===f)break}}else{if(T<0){const g=Math.floor(s*this._frameRate);T=this._frameIndices[c.frameIndicesOffset+g];const y=this._animationData.frameOffset+this._timelineArray[c.offset+w.TimelineFrameOffset+T];if(this._frameArray===null)throw new Error("this._frameArray is null.");const d=this._frameArray[y]/this._frameRate;this.currentPlayTimes===e&&(s<=d?T>0?T--:T=this._frameCount-1:T===f&&(T=-1))}for(;T>=0;){T=0&&(this._frameArray[this._frameOffset+1]>0?this._armature._sortZOrder(this._frameArray,this._frameOffset+2):this._armature._sortZOrder(null,0))}_onUpdateFrame(){}}class se extends jt{static toString(){return"[class dragonBones.BoneAllTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._isTween&&this._frameIndex===this._frameCount-1&&(this._rd[2]=R.normalizeRadian(this._rd[2]),this._rd[3]=R.normalizeRadian(this._rd[3])),this._timelineData===null&&(this._rd[4]=1,this._rd[5]=1)}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameFloatOffset,this._valueCount=6,this._valueArray=this._animationData.parent.parent.frameFloatArray}fadeOut(){this.dirty=!1,this._rd[2]=R.normalizeRadian(this._rd[2]),this._rd[3]=R.normalizeRadian(this._rd[3])}blend(t){if(this._armature===null)throw new Error("this._armature is null.");const i=this._armature.armatureData.scale,e=this._rd,s=this.target,n=s.target,l=s.blendWeight,h=n.animationPose;s.dirty>1?(h.x+=e[0]*l*i,h.y+=e[1]*l*i,h.rotation+=e[2]*l,h.skew+=e[3]*l,h.scaleX+=(e[4]-1)*l,h.scaleY+=(e[5]-1)*l):(h.x=e[0]*l*i,h.y=e[1]*l*i,h.rotation=e[2]*l,h.skew=e[3]*l,h.scaleX=(e[4]-1)*l+1,h.scaleY=(e[5]-1)*l+1),(t||this.dirty)&&(this.dirty=!1,n._transformDirty=!0)}}class Fe extends Ct{static toString(){return"[class dragonBones.BoneTranslateTimelineState]"}init(t,i,e){if(super.init(t,i,e),this._armature===null)throw new Error("this._armature is null.");if(this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameFloatOffset,this._valueScale=this._armature.armatureData.scale,this._valueArray=this._animationData.parent.parent.frameFloatArray}blend(t){const i=this.target,e=i.target,s=i.blendWeight,n=e.animationPose;i.dirty>1?(n.x+=this._resultA*s,n.y+=this._resultB*s):s!==1?(n.x=this._resultA*s,n.y=this._resultB*s):(n.x=this._resultA,n.y=this._resultB),(t||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class Me extends Ct{static toString(){return"[class dragonBones.BoneRotateTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._isTween&&this._frameIndex===this._frameCount-1&&(this._differenceA=R.normalizeRadian(this._differenceA),this._differenceB=R.normalizeRadian(this._differenceB))}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameFloatOffset,this._valueArray=this._animationData.parent.parent.frameFloatArray}fadeOut(){this.dirty=!1,this._resultA=R.normalizeRadian(this._resultA),this._resultB=R.normalizeRadian(this._resultB)}blend(t){const i=this.target,e=i.target,s=i.blendWeight,n=e.animationPose;i.dirty>1?(n.rotation+=this._resultA*s,n.skew+=this._resultB*s):s!==1?(n.rotation=this._resultA*s,n.skew=this._resultB*s):(n.rotation=this._resultA,n.skew=this._resultB),(t||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class Ce extends Ct{static toString(){return"[class dragonBones.BoneScaleTimelineState]"}_onArriveAtFrame(){super._onArriveAtFrame(),this._timelineData===null&&(this._resultA=1,this._resultB=1)}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameFloatOffset,this._valueArray=this._animationData.parent.parent.frameFloatArray}blend(t){const i=this.target,e=i.target,s=i.blendWeight,n=e.animationPose;i.dirty>1?(n.scaleX+=(this._resultA-1)*s,n.scaleY+=(this._resultB-1)*s):s!==1?(n.scaleX=(this._resultA-1)*s+1,n.scaleY=(this._resultB-1)*s+1):(n.scaleX=this._resultA,n.scaleY=this._resultB),(t||this.dirty)&&(this.dirty=!1,e._transformDirty=!0)}}class re extends jt{constructor(){super(...arguments),r(this,"_deformCount",0),r(this,"_deformOffset",0),r(this,"_sameValueOffset",0)}static toString(){return"[class dragonBones.SurfaceTimelineState]"}_onClear(){super._onClear(),this._deformCount=0,this._deformOffset=0,this._sameValueOffset=0}init(t,i,e){if(super.init(t,i,e),this._timelineData!==null){if(this._armature===null)throw new Error("this._armature is null.");if(this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");if(this._timelineArray===null)throw new Error("this._timelineArray is null.");const s=this._animationData.parent.parent,n=s.frameIntArray,l=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+w.TimelineFrameValueCount];if(n===null)throw new Error("frameIntArray is null.");this._valueOffset=this._animationData.frameFloatOffset,this._valueCount=n[l+w.DeformValueCount],this._deformCount=n[l+w.DeformCount],this._deformOffset=n[l+w.DeformValueOffset],this._sameValueOffset=n[l+w.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 i=this.target,e=i.target,s=i.blendWeight,n=e._deformVertices,l=this._valueArray;if(l!==null){const h=this._valueCount,_=this._deformOffset,m=this._sameValueOffset,c=this._rd;for(let u=0;u1?n[u]+=f*s:n[u]=f*s}}else if(i.dirty===1)for(let h=0;h1?(e._alpha+=this._result*s,e._alpha>1&&(e._alpha=1)):e._alpha=this._result*s,this._armature===null)throw new Error("this._armature is null.");(t||this.dirty)&&(this.dirty=!1,this._armature._alphaDirty=!0)}}class le extends kt{static toString(){return"[class dragonBones.SlotDisplayTimelineState]"}_onArriveAtFrame(){if(this.playState<0)return;const t=this.target;if(t._slotData===null)throw new Error("slot._slotData is null.");const i=(()=>{if(this._timelineData!==null){if(this._frameArray===null)throw new Error("this._frameArray is null.");return this._frameArray[this._frameOffset+1]}return t._slotData.displayIndex})();t.displayIndex!==i&&t._setDisplayIndex(i,!0)}_onUpdateFrame(){}}class oe extends Et{constructor(){super(...arguments),r(this,"_current",[0,0,0,0,0,0,0,0]),r(this,"_difference",[0,0,0,0,0,0,0,0]),r(this,"_result",[0,0,0,0,0,0,0,0])}static toString(){return"[class dragonBones.SlotColorTimelineState]"}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData!==null){if(this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");const t=this._animationData.parent.parent,i=t.colorArray,e=t.frameIntArray,s=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;if(e===null)throw new Error(" frameIntArray is null.");let n=e[s];if(n<0&&(n+=65536),i===null)throw new Error(" colorArray is null.");this._isTween?(this._current[0]=i[n++],this._current[1]=i[n++],this._current[2]=i[n++],this._current[3]=i[n++],this._current[4]=i[n++],this._current[5]=i[n++],this._current[6]=i[n++],this._current[7]=i[n++],this._frameIndex===this._frameCount-1?n=e[this._animationData.frameIntOffset+this._frameValueOffset]:n=e[s+1],n<0&&(n+=65536),this._difference[0]=i[n++]-this._current[0],this._difference[1]=i[n++]-this._current[1],this._difference[2]=i[n++]-this._current[2],this._difference[3]=i[n++]-this._current[3],this._difference[4]=i[n++]-this._current[4],this._difference[5]=i[n++]-this._current[5],this._difference[6]=i[n++]-this._current[6],this._difference[7]=i[n++]-this._current[7]):(this._result[0]=i[n++]*.01,this._result[1]=i[n++]*.01,this._result[2]=i[n++]*.01,this._result[3]=i[n++]*.01,this._result[4]=i[n++],this._result[5]=i[n++],this._result[6]=i[n++],this._result[7]=i[n++])}else{const t=this.target.slotData.color;if(t===null)throw new Error(" color is null.");this._result[0]=t.alphaMultiplier,this._result[1]=t.redMultiplier,this._result[2]=t.greenMultiplier,this._result[3]=t.blueMultiplier,this._result[4]=t.alphaOffset,this._result[5]=t.redOffset,this._result[6]=t.greenOffset,this._result[7]=t.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 i=this.target,e=i._colorTransform;if(this._animationState===null)throw new Error("this._animationState is null.");if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(e.alphaMultiplier!==this._result[0]||e.redMultiplier!==this._result[1]||e.greenMultiplier!==this._result[2]||e.blueMultiplier!==this._result[3]||e.alphaOffset!==this._result[4]||e.redOffset!==this._result[5]||e.greenOffset!==this._result[6]||e.blueOffset!==this._result[7]){const s=Math.pow(this._animationState._fadeProgress,4);e.alphaMultiplier+=(this._result[0]-e.alphaMultiplier)*s,e.redMultiplier+=(this._result[1]-e.redMultiplier)*s,e.greenMultiplier+=(this._result[2]-e.greenMultiplier)*s,e.blueMultiplier+=(this._result[3]-e.blueMultiplier)*s,e.alphaOffset+=(this._result[4]-e.alphaOffset)*s,e.redOffset+=(this._result[5]-e.redOffset)*s,e.greenOffset+=(this._result[6]-e.greenOffset)*s,e.blueOffset+=(this._result[7]-e.blueOffset)*s,i._colorDirty=!0}}else this.dirty&&(this.dirty=!1,(e.alphaMultiplier!==this._result[0]||e.redMultiplier!==this._result[1]||e.greenMultiplier!==this._result[2]||e.blueMultiplier!==this._result[3]||e.alphaOffset!==this._result[4]||e.redOffset!==this._result[5]||e.greenOffset!==this._result[6]||e.blueOffset!==this._result[7])&&(e.alphaMultiplier=this._result[0],e.redMultiplier=this._result[1],e.greenMultiplier=this._result[2],e.blueMultiplier=this._result[3],e.alphaOffset=this._result[4],e.redOffset=this._result[5],e.greenOffset=this._result[6],e.blueOffset=this._result[7],i._colorDirty=!0))}}}class Be extends Lt{static toString(){return"[class dragonBones.SlotZIndexTimelineState]"}_onArriveAtFrame(){if(super._onArriveAtFrame(),this._timelineData===null){const t=this.target.target;this._result=t.slotData.zIndex}}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameIntOffset,this._valueArray=this._animationData.parent.parent.frameIntArray}blend(t){const i=this.target,e=i.target,s=i.blendWeight;if(i.dirty>1?e._zIndex+=this._result*s:e._zIndex=this._result*s,this._armature===null)throw new Error("this._armature is null.");(t||this.dirty)&&(this.dirty=!1,this._armature._zIndexDirty=!0)}}class he extends jt{constructor(){super(...arguments),r(this,"displayFrame",null),r(this,"_deformCount",0),r(this,"_deformOffset",0),r(this,"_sameValueOffset",0)}static toString(){return"[class dragonBones.DeformTimelineState]"}_onClear(){super._onClear(),this.displayFrame=null,this._deformCount=0,this._deformOffset=0,this._sameValueOffset=0}init(t,i,e){if(super.init(t,i,e),this._timelineData!==null){if(this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");if(this._timelineArray===null)throw new Error("this._timelineArray is null.");const s=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+w.TimelineFrameValueCount],n=this._animationData.parent.parent,l=n.frameIntArray;if(l===null)throw new Error("frameIntArray is null.");if(this._valueOffset=this._animationData.frameFloatOffset,this._valueCount=l[s+w.DeformValueCount],this._deformCount=l[s+w.DeformCount],this._deformOffset=l[s+w.DeformValueOffset],this._sameValueOffset=l[s+w.DeformFloatOffset],this._sameValueOffset<0&&(this._sameValueOffset+=65536),this._sameValueOffset+=this._animationData.frameFloatOffset,this._armature===null)throw new Error("this._armature is null.");this._valueScale=this._armature.armatureData.scale,this._valueArray=n.frameFloatArray,this._rd.length=this._valueCount*2}else{if(this.displayFrame===null)throw new Error("this.displayFrame is null.");this._deformCount=this.displayFrame.deformVertices.length}}blend(t){if(this.displayFrame===null)throw new Error("this.displayFrame is null.");const i=this.target,e=i.target,s=i.blendWeight,n=this.displayFrame.deformVertices,l=this._valueArray;if(l!==null){const h=this._valueCount,_=this._deformOffset,m=this._sameValueOffset,c=this._rd;for(let u=0;u1?n[u]+=f*s:n[u]=f*s}}else if(i.dirty===1)for(let h=0;h0,t._weight=this._currentB;else{const i=t._constraintData;t._bendPositive=i.bendPositive,t._weight=i.weight}t.invalidUpdate(),this.dirty=!1}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameIntOffset,this._valueScale=.01,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Pe extends Lt{static toString(){return"[class dragonBones.AnimationProgressTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const t=this.target;t._parent!==null&&(t.currentTime=this._result*t.totalTime),this.dirty=!1}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class ve extends Lt{static toString(){return"[class dragonBones.AnimationWeightTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const t=this.target;t._parent!==null&&(t.weight=this._result),this.dirty=!1}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Ne extends Ct{static toString(){return"[class dragonBones.AnimationParametersTimelineState]"}_onUpdateFrame(){super._onUpdateFrame();const t=this.target;t._parent!==null&&(t.parameterX=this._resultA,t.parameterY=this._resultB),this.dirty=!1}init(t,i,e){if(super.init(t,i,e),this._animationData===null)throw new Error("this._animationData is null.");if(this._animationData.parent===null)throw new Error(" this._animationData.parent is null.");if(this._animationData.parent.parent===null)throw new Error(" this._animationData.parent.parent is null.");this._valueOffset=this._animationData.frameIntOffset,this._valueScale=1e-4,this._valueArray=this._animationData.parent.parent.frameIntArray}}class Re extends b{constructor(){super(...arguments),r(this,"actionEnabled",!1),r(this,"additive",!1),r(this,"displayControl",!1),r(this,"resetToPose",!1),r(this,"blendType",_t.None),r(this,"playTimes",1),r(this,"layer",0),r(this,"timeScale",1),r(this,"parameterX",0),r(this,"parameterY",0),r(this,"positionX",0),r(this,"positionY",0),r(this,"autoFadeOutTime",0),r(this,"fadeTotalTime",0),r(this,"name",""),r(this,"group",""),r(this,"_timelineDirty",2),r(this,"_playheadState",0),r(this,"_fadeState",-1),r(this,"_subFadeState",1),r(this,"_position",0),r(this,"_duration",0),r(this,"_weight",1),r(this,"_fadeTime",0),r(this,"_time",0),r(this,"_fadeProgress",0),r(this,"_weightResult",0),r(this,"_boneMask",[]),r(this,"_boneTimelines",[]),r(this,"_boneBlendTimelines",[]),r(this,"_slotTimelines",[]),r(this,"_slotBlendTimelines",[]),r(this,"_constraintTimelines",[]),r(this,"_animationTimelines",[]),r(this,"_poseTimelines",[]),r(this,"_animationData",null),r(this,"_armature",null),r(this,"_actionTimeline",null),r(this,"_zOrderTimeline",null),r(this,"_activeChildA",null),r(this,"_activeChildB",null),r(this,"_parent",null)}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 i=t.target;i._parent===this&&(i._fadeState=1,i._subFadeState=1,i._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=_t.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(){{if(this._armature===null)throw new Error("this._armature is null.");if(this._animationData===null)throw new Error("this._animationData is null.");for(const t of this._armature._constraints){const i=this._animationData.getConstraintTimelines(t.name);if(i!==null)for(const e of i)switch(e.type){case x.IKConstraint:{const s=b.borrowObject(_e);s.target=t,s.init(this._armature,this,e),this._constraintTimelines.push(s);break}}else if(this.resetToPose){const e=b.borrowObject(_e);e.target=t,e.init(this._armature,this,null),this._constraintTimelines.push(e),this._poseTimelines.push(e)}}}}_updateBoneAndSlotTimelines(){var t;{const i={};for(const e of this._boneTimelines){const s=e.target.target.name;s in i||(i[s]=[]),i[s].push(e)}for(const e of this._boneBlendTimelines){const s=e.target.target.name;s in i||(i[s]=[]),i[s].push(e)}if(this._armature===null)throw new Error("this._armature is null.");if(this._animationData===null)throw new Error("this._animationData is null.");for(const e of this._armature.getBones()){const s=e.name;if(this.containsBoneMask(s))if(s in i)delete i[s];else{const n=this._animationData.getBoneTimelines(s),l=this._armature.animation.getBlendState(rt.BONE_TRANSFORM,e.name,e);if(n!==null)for(const h of n)switch(h.type){case x.BoneAll:{const _=b.borrowObject(se);_.target=l,_.init(this._armature,this,h),this._boneTimelines.push(_);break}case x.BoneTranslate:{const _=b.borrowObject(Fe);_.target=l,_.init(this._armature,this,h),this._boneTimelines.push(_);break}case x.BoneRotate:{const _=b.borrowObject(Me);_.target=l,_.init(this._armature,this,h),this._boneTimelines.push(_);break}case x.BoneScale:{const _=b.borrowObject(Ce);_.target=l,_.init(this._armature,this,h),this._boneTimelines.push(_);break}case x.BoneAlpha:{const _=b.borrowObject(ne);_.target=this._armature.animation.getBlendState(rt.BONE_ALPHA,e.name,e),_.init(this._armature,this,h),this._boneBlendTimelines.push(_);break}case x.Surface:{const _=b.borrowObject(re);_.target=this._armature.animation.getBlendState(rt.SURFACE,e.name,e),_.init(this._armature,this,h),this._boneBlendTimelines.push(_);break}}else if(this.resetToPose)if(((t=e._boneData)==null?void 0:t.type)===et.Bone){const h=b.borrowObject(se);h.target=l,h.init(this._armature,this,null),this._boneTimelines.push(h),this._poseTimelines.push(h)}else{const h=b.borrowObject(re);h.target=this._armature.animation.getBlendState(rt.SURFACE,e.name,e),h.init(this._armature,this,null),this._boneBlendTimelines.push(h),this._poseTimelines.push(h)}}}for(let e in i)for(const s of i[e]){let n=this._boneTimelines.indexOf(s);n>=0&&(this._boneTimelines.splice(n,1),s.returnToPool()),n=this._boneBlendTimelines.indexOf(s),n>=0&&(this._boneBlendTimelines.splice(n,1),s.returnToPool())}}{const i={},e=[];for(const s of this._slotTimelines){const n=s.target.name;n in i||(i[n]=[]),i[n].push(s)}for(const s of this._slotBlendTimelines){const n=s.target.target.name;n in i||(i[n]=[]),i[n].push(s)}for(const s of this._armature.getSlots()){const n=s.parent.name;if(!this.containsBoneMask(n))continue;const l=s.name;if(l in i)delete i[l];else{let h=!1,_=!1;e.length=0;const m=this._animationData.getSlotTimelines(l);if(m!==null)for(const c of m)switch(c.type){case x.SlotDisplay:{const u=b.borrowObject(le);u.target=s,u.init(this._armature,this,c),this._slotTimelines.push(u),h=!0;break}case x.SlotZIndex:{const u=b.borrowObject(Be);u.target=this._armature.animation.getBlendState(rt.SLOT_Z_INDEX,s.name,s),u.init(this._armature,this,c),this._slotBlendTimelines.push(u);break}case x.SlotColor:{const u=b.borrowObject(oe);u.target=s,u.init(this._armature,this,c),this._slotTimelines.push(u),_=!0;break}case x.SlotDeform:{if(this._animationData.parent===null)throw new Error("this._animationData.parent is null.");const u=this._animationData.parent.parent;if(u===null)throw new Error("dragonBonesData is null.");const f=u.timelineArray;if(f===null)throw new Error("timelineArray is null.");const T=this._animationData.frameIntOffset+f[c.offset+w.TimelineFrameValueCount],g=u.frameIntArray;if(T===null)throw new Error("frameIntOffset is null.");if(g===null)throw new Error("frameIntArray is null.");let y=g[T+w.DeformVertexOffset];y<0&&(y+=65536);for(let d=0,p=s.displayFrameCount;d=0&&(this._slotTimelines.splice(l,1),n.returnToPool()),l=this._slotBlendTimelines.indexOf(n),l>=0&&(this._slotBlendTimelines.splice(l,1),n.returnToPool())}}}_advanceFadeTime(t){const i=this._fadeState>0;if(this._subFadeState<0&&(this._subFadeState=0,this._parent===null&&this.actionEnabled)){const e=i?Y.FADE_OUT:Y.FADE_IN;if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._dragonBones===null)throw new Error("this._armature._dragonBones is null.");if(this._armature.eventDispatcher.hasDBEventListener(e)){const s=b.borrowObject(Y);s.type=e,s.armature=this._armature,s.animationState=this,this._armature._dragonBones.bufferEvent(s)}}if(t<0&&(t=-t),this._fadeTime+=t,this._fadeTime>=this.fadeTotalTime?(this._subFadeState=1,this._fadeProgress=i?0:1):this._fadeTime>0?this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeProgress=i?1:0,this._subFadeState>0&&(i||(this._playheadState|=1,this._fadeState=0),this._parent===null&&this.actionEnabled)){const e=i?Y.FADE_OUT_COMPLETE:Y.FADE_IN_COMPLETE;if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._dragonBones===null)throw new Error("this._armature._dragonBones is null.");if(this._armature.eventDispatcher.hasDBEventListener(e)){const s=b.borrowObject(Y);s.type=e,s.armature=this._armature,s.animationState=this,this._armature._dragonBones.bufferEvent(s)}}}init(t,i,e){if(this._armature===null){if(this._armature=t,this._animationData=i,this.resetToPose=e.resetToPose,this.additive=e.additive,this.displayControl=e.displayControl,this.actionEnabled=e.actionEnabled,this.blendType=i.blendType,this.layer=e.layer,this.playTimes=e.playTimes,this.timeScale=e.timeScale,this.fadeTotalTime=e.fadeInTime,this.autoFadeOutTime=e.autoFadeOutTime,this.name=e.name.length>0?e.name:e.animation,this.group=e.group,this._weight=e.weight,e.pauseFadeIn?this._playheadState=2:this._playheadState=3,e.duration<0?(this._position=0,this._duration=this._animationData.duration,e.position!==0?this.timeScale>=0?this._time=e.position:this._time=e.position-this._duration:this._time=0):(this._position=e.position,this._duration=e.duration,this._time=0),this.timeScale<0&&this._time===0&&(this._time=-1e-6),this.fadeTotalTime<=0&&(this._fadeProgress=.999999),e.boneMask.length>0){this._boneMask.length=e.boneMask.length;for(let s=0,n=this._boneMask.length;s0;let n=!0,l=!0,h=this._time;if(this._weightResult=this._weight*this._fadeProgress,this._parent!==null&&(this._weightResult*=this._parent._weightResult),this._actionTimeline===null)throw new Error("this._actionTimeline is null.");if(this._actionTimeline.playState<=0&&this._actionTimeline.update(h),this._weight!==0){if(s){const _=i*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*_)/_}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0&&this._zOrderTimeline.update(h),this._armature===null)throw new Error("this._armature is null.");if(this._animationData===null)throw new Error("this._animationData is null.");if(s){const _=Math.floor(this._actionTimeline.currentTime*i);this._armature._cacheFrameIndex===_?(n=!1,l=!1):(this._armature._cacheFrameIndex=_,this._animationData.cachedFrames[_]?l=!1:this._animationData.cachedFrames[_]=!0)}if(n){let _=!1,m=null;if(l)for(let c=0,u=this._boneTimelines.length;c0){let c=100,u=100,f=null,T=null;for(let g=0,y=this._animationTimelines.length;g=0?A0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(const _ of this._poseTimelines){let m=this._boneTimelines.indexOf(_);if(m>=0){this._boneTimelines.splice(m,1),_.returnToPool();continue}if(m=this._boneBlendTimelines.indexOf(_),m>=0){this._boneBlendTimelines.splice(m,1),_.returnToPool();continue}if(m=this._slotTimelines.indexOf(_),m>=0){this._slotTimelines.splice(m,1),_.returnToPool();continue}if(m=this._slotBlendTimelines.indexOf(_),m>=0){this._slotBlendTimelines.splice(m,1),_.returnToPool();continue}if(m=this._constraintTimelines.indexOf(_),m>=0){this._constraintTimelines.splice(m,1),_.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,i=!0){if(t<0&&(t=0),i&&(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 e of this._boneTimelines)e.fadeOut();for(const e of this._boneBlendTimelines)e.fadeOut();for(const e of this._slotTimelines)e.fadeOut();for(const e of this._slotBlendTimelines)e.fadeOut();for(const e of this._constraintTimelines)e.fadeOut();for(const e of this._animationTimelines)e.fadeOut(),e.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,i=!0){if(this._armature===null)throw new Error("this._armature is null.");const e=this._armature.getBone(t);if(e!==null){if(this._boneMask.indexOf(t)<0&&this._boneMask.push(t),i)for(const s of this._armature.getBones())this._boneMask.indexOf(s.name)<0&&e.contains(s)&&this._boneMask.push(s.name);this._timelineDirty=1}}removeBoneMask(t,i=!0){const e=this._boneMask.indexOf(t);if(e>=0&&this._boneMask.splice(e,1),this._armature===null)throw new Error("this._armature is null.");if(i){const s=this._armature.getBone(t);if(s!==null){const n=this._armature.getBones();if(this._boneMask.length>0)for(const l of n){const h=this._boneMask.indexOf(l.name);h>=0&&s.contains(l)&&this._boneMask.splice(h,1)}else for(const l of n)l!==s&&(s.contains(l)||this._boneMask.push(l.name))}}this._timelineDirty=1}removeAllBoneMask(){this._boneMask.length=0,this._timelineDirty=1}addState(t,i=null){if(i!==null){if(this._armature===null)throw new Error("this._armature is null.");for(const e of i)switch(e.type){case x.AnimationProgress:{const s=b.borrowObject(Pe);if(s.target=t,s.init(this._armature,this,e),this._animationTimelines.push(s),this.blendType!==_t.None){const n=e;t.positionX=n.x,t.positionY=n.y,t.weight=0}t._parent=this,this.resetToPose=!1;break}case x.AnimationWeight:{const s=b.borrowObject(ve);s.target=t,s.init(this._armature,this,e),this._animationTimelines.push(s);break}case x.AnimationParameter:{const s=b.borrowObject(Ne);s.target=t,s.init(this._armature,this,e),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(){if(this._actionTimeline===null)throw new Error("this._actionTimeline is null.");return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0}get isCompleted(){if(this._actionTimeline===null)throw new Error("this._actionTimeline is null.");return this._actionTimeline.playState>0}get currentPlayTimes(){if(this._actionTimeline===null)throw new Error("this._actionTimeline is null.");return this._actionTimeline.currentPlayTimes}get totalTime(){return this._duration}get currentTime(){if(this._actionTimeline===null)throw new Error("this._actionTimeline is null.");return this._actionTimeline.currentTime}set currentTime(t){if(this._actionTimeline===null)throw new Error("this._actionTimeline is null.");const i=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if((t<0||this._duration0&&i===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 e of this._boneTimelines)e.playState=-1;for(const e of this._slotTimelines)e.playState=-1}}get weight(){return this._weight}set weight(t){if(this._weight!==t){this._weight=t;for(const i of this._boneTimelines)i.dirty=!0;for(const i of this._boneBlendTimelines)i.dirty=!0;for(const i of this._slotBlendTimelines)i.dirty=!0}}get animationData(){if(this._animationData===null)throw new Error("this._animationData is null.");return this._animationData}}class rt extends b{constructor(){super(...arguments),r(this,"dirty",0),r(this,"layer",0),r(this,"leftWeight",0),r(this,"layerWeight",0),r(this,"blendWeight",0),r(this,"target",null)}static toString(){return"[class dragonBones.BlendState]"}_onClear(){this.reset(),this.target=null}update(t){const i=t.layer;let e=t._weightResult;if(this.dirty>0){if(this.leftWeight>0){if(this.layer!==i){if(this.layerWeight>=this.leftWeight)return this.dirty++,this.layer=i,this.leftWeight=0,this.blendWeight=0,!1;this.layer=i,this.leftWeight-=this.layerWeight,this.layerWeight=0}return e*=this.leftWeight,this.dirty++,this.blendWeight=e,this.layerWeight+=this.blendWeight,!0}return!1}return this.dirty++,this.layer=i,this.leftWeight=1,this.blendWeight=e,this.layerWeight=e,!0}reset(){this.dirty=0,this.layer=0,this.leftWeight=0,this.layerWeight=0,this.blendWeight=0}}r(rt,"BONE_TRANSFORM","boneTransform"),r(rt,"BONE_ALPHA","boneAlpha"),r(rt,"SURFACE","surface"),r(rt,"SLOT_DEFORM","slotDeform"),r(rt,"SLOT_ALPHA","slotAlpha"),r(rt,"SLOT_Z_INDEX","slotZIndex");class ke extends b{constructor(){super(...arguments),r(this,"timeScale",1),r(this,"_animationDirty",!1),r(this,"_inheritTimeScale",1),r(this,"_animationNames",[]),r(this,"_animationStates",[]),r(this,"_animations",{}),r(this,"_blendStates",{}),r(this,"_armature",null),r(this,"_animationConfig",null),r(this,"_lastAnimationState",null)}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 i=this._blendStates[t];for(let e in i)i[e].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 i of this._animationStates)i._parent===null&&i.layer===t.layer&&i.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.SameGroup:for(const i of this._animationStates)i._parent===null&&i.group===t.group&&i.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.SameLayerAndGroup:for(const i of this._animationStates)i._parent===null&&i.layer===t.layer&&i.group===t.group&&i.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.All:for(const i of this._animationStates)i._parent===null&&i.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case mt.Single:}}init(t){this._armature===null&&(this._armature=t,this._animationConfig=b.borrowObject(xe))}advanceTime(t){if(t<0&&(t=-t),this._armature===null)throw new Error("this._armature is null.");if(this._armature.inheritAnimation&&this._armature._parent!==null){if(this._armature._parent._armature===null)throw new Error(" this._armature._parent._armature is null.");this._inheritTimeScale=this._armature._parent._armature.animation._inheritTimeScale*this.timeScale}else this._inheritTimeScale=this.timeScale;this._inheritTimeScale!==1&&(t*=this._inheritTimeScale);for(let e in this._blendStates){const s=this._blendStates[e];for(let n in s)s[n].reset()}const i=this._animationStates.length;if(i===1){const e=this._animationStates[0];if(e._fadeState>0&&e._subFadeState>0){if(this._armature._dragonBones===null)throw new Error("this._armature._dragonBones is null.");this._armature._dragonBones.bufferObject(e),this._animationStates.length=0,this._lastAnimationState=null}else{const s=e.animationData,n=s.cacheFrameRate;if(this._animationDirty&&n>0){this._animationDirty=!1;for(const l of this._armature.getBones())l._cachedFrameIndices=s.getBoneCachedFrameIndices(l.name);for(const l of this._armature.getSlots()){if(l.displayFrameCount>0){const h=l.getDisplayFrameAt(0).rawDisplayData;if(h!==null&&h.parent===this._armature.armatureData.defaultSkin){l._cachedFrameIndices=s.getSlotCachedFrameIndices(l.name);continue}}l._cachedFrameIndices=null}}e.advanceTime(t,n)}}else if(i>1){for(let e=0,s=0;e0&&n._subFadeState>0){if(s++,this._armature._dragonBones===null)throw new Error("this._armature._dragonBones is null.");this._armature._dragonBones.bufferObject(n),this._animationDirty=!0,this._lastAnimationState===n&&(this._lastAnimationState=null)}else s>0&&(this._animationStates[e-s]=n),n.advanceTime(t,0);e===i-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(){var t;for(const i of this._animationStates)i.returnToPool();this._animationDirty=!1,(t=this._animationConfig)==null||t.clear(),this._animationStates.length=0,this._lastAnimationState=null}stop(t=null){if(t!==null){const i=this.getState(t);i!==null&&i.stop()}else for(const i of this._animationStates)i.stop()}playConfig(t){const i=t.animation;if(!(i in this._animations))return null;const e=this._animations[i];if(t.fadeOutMode===mt.Single){for(const n of this._animationStates)if(n._fadeState<1&&n.layer===t.layer&&n.animationData===e)return n}this._animationStates.length===0?t.fadeInTime=0:t.fadeInTime<0&&(t.fadeInTime=e.fadeInTime),t.fadeOutTime<0&&(t.fadeOutTime=t.fadeInTime),t.timeScale<=-100&&(t.timeScale=1/e.scale),e.frameCount>0?(t.position<0?(t.position%=e.duration,t.position=e.duration-t.position):t.position===e.duration?t.position-=1e-6:t.position>e.duration&&(t.position%=e.duration),t.duration>0&&t.position+t.duration>e.duration&&(t.duration=e.duration-t.position),t.playTimes<0&&(t.playTimes=e.playTimes)):(t.playTimes=1,t.position=0,t.duration>0&&(t.duration=0)),t.duration===0&&(t.duration=-1),this._fadeOut(t);const s=b.borrowObject(Re);if(this._armature===null)throw new Error("this._armature is null.");if(s.init(this._armature,e,t),this._animationDirty=!0,this._armature._cacheFrameIndex=-1,this._animationStates.length>0){let n=!1;for(let l=0,h=this._animationStates.length;lthis._animationStates[l].layer){n=!0,this._animationStates.splice(l,0,s);break}else if(l!==h-1&&s.layer>this._animationStates[l+1].layer){n=!0,this._animationStates.splice(l+1,0,s);break}n||this._animationStates.push(s)}else this._animationStates.push(s);for(const n of this._armature.getSlots()){const l=n.childArmature;l!==null&&l.inheritAnimation&&l.animation.hasAnimation(i)&&l.animation.getState(i)===null&&l.animation.fadeIn(i)}for(let n in e.animationTimelines){const l=this.fadeIn(n,0,1,s.layer,"",mt.Single);if(l===null)continue;const h=e.animationTimelines[n];l.actionEnabled=!1,l.resetToPose=!1,l.stop(),s.addState(l,h);const _=this._animationStates.indexOf(s),m=this._animationStates.indexOf(l);m<_&&(this._animationStates.splice(_,1),this._animationStates.splice(m,0,s))}return this._lastAnimationState=s,s}play(t=null,i=-1){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");if(this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t!==null?t:"",t!==null&&t.length>0)this.playConfig(this._animationConfig);else if(this._lastAnimationState===null){if(this._armature===null)throw new Error("this._armature is null.");const e=this._armature.armatureData.defaultAnimation;e!==null&&(this._animationConfig.animation=e.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,i=-1,e=-1,s=0,n=null,l=mt.SameLayerAndGroup){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");return this._animationConfig.clear(),this._animationConfig.fadeOutMode=l,this._animationConfig.playTimes=e,this._animationConfig.layer=s,this._animationConfig.fadeInTime=i,this._animationConfig.animation=t,this._animationConfig.group=n!==null?n:"",this.playConfig(this._animationConfig)}gotoAndPlayByTime(t,i=0,e=-1){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");return this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,this._animationConfig.position=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t,this.playConfig(this._animationConfig)}gotoAndPlayByFrame(t,i=0,e=-1){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,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*i/s.frameCount:0),this.playConfig(this._animationConfig)}gotoAndPlayByProgress(t,i=0,e=-1){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,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*(i>0?i:0)),this.playConfig(this._animationConfig)}gotoAndStopByTime(t,i=0){const e=this.gotoAndPlayByTime(t,i,1);return e!==null&&e.stop(),e}gotoAndStopByFrame(t,i=0){const e=this.gotoAndPlayByFrame(t,i,1);return e!==null&&e.stop(),e}gotoAndStopByProgress(t,i=0){const e=this.gotoAndPlayByProgress(t,i,1);return e!==null&&e.stop(),e}getBlendState(t,i,e){t in this._blendStates||(this._blendStates[t]={});const s=this._blendStates[t];if(!(i in s)){const n=s[i]=b.borrowObject(rt);n.target=e}return s[i]}getState(t,i=-1){let e=this._animationStates.length;for(;e--;){const s=this._animationStates[e];if(s.name===t&&(i<0||s.layer===i))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 i in this._animations)delete this._animations[i];for(let i in t)this._animationNames.push(i),this._animations[i]=t[i]}}get animationConfig(){if(this._animationConfig===null)throw new Error("this._animationConfig is null.");return this._animationConfig.clear(),this._animationConfig}get lastAnimationState(){return this._lastAnimationState}}class gt extends b{constructor(){super(...arguments),r(this,"inheritAnimation",!0),r(this,"userData",null),r(this,"_lockUpdate",!1),r(this,"_slotsDirty",!0),r(this,"_zOrderDirty",!1),r(this,"_zIndexDirty",!1),r(this,"_alphaDirty",!0),r(this,"_flipX",!1),r(this,"_flipY",!1),r(this,"_cacheFrameIndex",-1),r(this,"_alpha",1),r(this,"_globalAlpha",1),r(this,"_bones",[]),r(this,"_slots",[]),r(this,"_constraints",[]),r(this,"_actions",[]),r(this,"_armatureData",null),r(this,"_animation",null),r(this,"_proxy",null),r(this,"_display",null),r(this,"_replaceTextureAtlasData",null),r(this,"_replacedTexture",null),r(this,"_dragonBones",null),r(this,"_clock",null),r(this,"_parent",null)}static toString(){return"[class dragonBones.Armature]"}static _onSortSlots(t,i){return t._zIndex*1e3+t._zOrder>i._zIndex*1e3+i._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,i){if(this._armatureData===null)throw new Error("this._armatureData is undefined.");const e=this._armatureData.sortedSlots,s=t===null;if(this._zOrderDirty||!s){for(let n=0,l=e.length;n=l)continue;const _=e[h],m=this.getSlot(_.name);m!==null&&m._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,i){this._actions.indexOf(t)<0&&(i?this._actions.push(t):this._actions.unshift(t))}dispose(){if(this._dragonBones===null)throw new Error(" this._dragonBones is null.");this._armatureData!==null&&(this._lockUpdate=!0,this._dragonBones.bufferObject(this))}init(t,i,e,s){this._armatureData===null&&(this._armatureData=t,this._animation=b.borrowObject(ke),this._proxy=i,this._display=e,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 i=this._cacheFrameIndex;if(this._animation.advanceTime(t),this._slotsDirty||this._zIndexDirty){if(this._slots.sort(gt._onSortSlots),this._zIndexDirty)for(let e=0,s=this._slots.length;e0){for(const e of this._actions){const s=e.actionData;if(s!==null&&s.type===K.Play)if(e.slot!==null){const n=e.slot.childArmature;n!==null&&n.animation.fadeIn(s.name)}else if(e.bone!==null){for(const n of this.getSlots())if(n.parent===e.bone){const l=n.childArmature;l!==null&&l.animation.fadeIn(s.name)}}else this._animation.fadeIn(s.name);e.returnToPool()}this._actions.length=0}if(this._lockUpdate=!1,this._proxy===null)throw new Error("this._proxy is null.");this._proxy.dbUpdate()}invalidUpdate(t=null,i=!1){if(t!==null&&t.length>0){const e=this.getBone(t);if(e!==null&&(e.invalidUpdate(),i))for(const s of this._slots)s.parent===e&&s.invalidUpdate()}else{for(const e of this._bones)e.invalidUpdate();if(i)for(const e of this._slots)e.invalidUpdate()}}containsPoint(t,i){for(const e of this._slots)if(e.containsPoint(t,i))return e;return null}intersectsSegment(t,i,e,s,n=null,l=null,h=null){const _=t===e;let m=0,c=0,u=0,f=0,T=0,g=0,y=0,d=0,p=null,A=null;for(const S of this._slots)if(S.intersectsSegment(t,i,e,s,n,l,h)>0)if(n!==null||l!==null){if(n!==null){let E=_?n.y-i:n.x-t;E<0&&(E=-E),(p===null||Ec)&&(c=E,T=l.x,g=l.y,A=S,h!==null&&(d=h.y))}}else{p=S;break}return p!==null&&n!==null&&(n.x=u,n.y=f,h!==null&&(h.x=y)),A!==null&&l!==null&&(l.x=T,l.y=g,h!==null&&(h.y=d)),p}getBone(t){for(const i of this._bones)if(i.name===t)return i;return null}getBoneByDisplay(t){const i=this.getSlotByDisplay(t);return i!==null?i.parent:null}getSlot(t){for(const i of this._slots)if(i.name===t)return i;return null}getSlotByDisplay(t){if(t!==null){for(const i of this._slots)if(i.display===t)return i}return null}getBones(){return this._bones}getSlots(){return this._slots}get flipX(){if(this._flipX===void 0)throw new Error("this._flipX is undefined.");return this._flipX}set flipX(t){this._flipX!==t&&(this._flipX=t,this.invalidUpdate())}get flipY(){if(this._flipY===void 0)throw new Error("this._flipY is undefined.");return this._flipY}set flipY(t){this._flipY!==t&&(this._flipY=t,this.invalidUpdate())}get cacheFrameRate(){if(this._armatureData===null)throw new Error("this._armatureData is undefined.");if(this._armatureData.cacheFrameRate===void 0)throw new Error("this._armatureData.cacheFrameRate is undefined.");return this._armatureData.cacheFrameRate}set cacheFrameRate(t){if(this._armatureData===null)throw new Error("this._armatureData is undefined.");if(this._armatureData.cacheFrameRate!==t){this._armatureData.cacheFrames(t);for(const i of this._slots){const e=i.childArmature;e!==null&&(e.cacheFrameRate=t)}}}get name(){if(this._armatureData===null)throw new Error("this._armatureData is undefined.");if(this._armatureData.name===void 0)throw new Error("this._armatureData.name is undefined.");return this._armatureData.name}get armatureData(){if(this._armatureData===null)throw new Error("this._armatureData is undefined.");return this._armatureData}get animation(){if(this._animation===null)throw new Error("this._animation is undefined.");return this._animation}get proxy(){if(this._proxy===null)throw new Error("this._proxy is undefined.");return this._proxy}get eventDispatcher(){if(this._proxy===null)throw new Error("this._proxy is undefined.");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 i of this._slots)i.invalidUpdate(),i.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 i of this._slots){const e=i.childArmature;e!==null&&(e.clock=this._clock)}}}get parent(){return this._parent}getDisplay(){return this._display}}class Ot{constructor(t=1,i=0,e=0,s=1,n=0,l=0){r(this,"a"),r(this,"b"),r(this,"c"),r(this,"d"),r(this,"tx"),r(this,"ty"),this.a=t,this.b=i,this.c=e,this.d=s,this.tx=n,this.ty=l}toString(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}copyFromArray(t,i=0){return this.a=t[i],this.b=t[i+1],this.c=t[i+2],this.d=t[i+3],this.tx=t[i+4],this.ty=t[i+5],this}identity(){return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this}concat(t){let i=this.a*t.a,e=0,s=0,n=this.d*t.d,l=this.tx*t.a+t.tx,h=this.ty*t.d+t.ty;return(this.b!==0||this.c!==0)&&(i+=this.b*t.c,e+=this.b*t.d,s+=this.c*t.a,n+=this.c*t.b),(t.b!==0||t.c!==0)&&(e+=this.a*t.b,s+=this.d*t.c,l+=this.ty*t.c,h+=this.tx*t.b),this.a=i,this.b=e,this.c=s,this.d=n,this.tx=l,this.ty=h,this}invert(){let t=this.a,i=this.b,e=this.c,s=this.d;const n=this.tx,l=this.ty;if(i===0&&e===0)return this.b=this.c=0,t===0||s===0?this.a=this.b=this.tx=this.ty=0:(t=this.a=1/t,s=this.d=1/s,this.tx=-t*n,this.ty=-s*l),this;let h=t*s-i*e;if(h===0)return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this;h=1/h;let _=this.a=s*h;return i=this.b=-i*h,e=this.c=-e*h,s=this.d=t*h,this.tx=-(_*n+e*l),this.ty=-(i*n+s*l),this}transformPoint(t,i,e,s=!1){e.x=this.a*t+this.c*i,e.y=this.b*t+this.d*i,s||(e.x+=this.tx,e.y+=this.ty)}transformRectangle(t,i=!1){const e=this.a,s=this.b,n=this.c,l=this.d,h=i?0:this.tx,_=i?0:this.ty,m=t.x,c=t.y,u=m+t.width,f=c+t.height;let T=e*m+n*c+h,g=s*m+l*c+_,y=e*u+n*c+h,d=s*u+l*c+_,p=e*u+n*f+h,A=s*u+l*f+_,S=e*m+n*f+h,E=s*m+l*f+_,I=0;T>y&&(I=T,T=y,y=I),p>S&&(I=p,p=S,S=I),t.x=Math.floor(TS?y:S)-t.x),g>d&&(I=g,g=d,d=I),A>E&&(I=A,A=E,E=I),t.y=Math.floor(gE?d:E)-t.y)}}class Vt{constructor(t=0,i=0){r(this,"x"),r(this,"y"),this.x=t,this.y=i}copyFrom(t){this.x=t.x,this.y=t.y}clear(){this.x=this.y=0}}class Bt extends b{constructor(){super(...arguments),r(this,"globalTransformMatrix",new Ot),r(this,"global",new R),r(this,"offset",new R),r(this,"origin",null),r(this,"userData"),r(this,"_globalDirty",!1),r(this,"_alpha",1),r(this,"_globalAlpha",1),r(this,"_armature",null)}_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(){if(this._armature===null)throw new Error("this._armature is null.");return this._armature}}r(Bt,"_helpMatrix",new Ot),r(Bt,"_helpTransform",new R),r(Bt,"_helpPoint",new Vt);class ue extends Bt{constructor(){super(...arguments),r(this,"offsetMode",Mt.Additive),r(this,"animationPose",new R),r(this,"_transformDirty",!1),r(this,"_childrenTransformDirty",!1),r(this,"_localDirty",!0),r(this,"_hasConstraint",!1),r(this,"_visible",!0),r(this,"_cachedFrameIndex",-1),r(this,"_boneData",null),r(this,"_parent",null),r(this,"_cachedFrameIndices",null)}static toString(){return"[class dragonBones.Bone]"}_onClear(){super._onClear(),this.offsetMode=Mt.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){if(this._armature===null)throw new Error(" this._armature is null.");if(this.origin===void 0)throw new Error(" this.origin is undefined.");const i=this._boneData,e=this.global,s=this.globalTransformMatrix,n=this.origin,l=this.offset,h=this.animationPose,_=this._parent,m=this._armature.flipX,c=this._armature.flipY===ut.yDown;let u=_!==null,f=0;if(this.offsetMode===Mt.Additive?n!==null?(e.x=n.x+l.x+h.x,e.scaleX=n.scaleX*l.scaleX*h.scaleX,e.scaleY=n.scaleY*l.scaleY*h.scaleY,ut.yDown?(e.y=n.y+l.y+h.y,e.skew=n.skew+l.skew+h.skew,e.rotation=n.rotation+l.rotation+h.rotation):(e.y=n.y-l.y+h.y,e.skew=n.skew-l.skew+h.skew,e.rotation=n.rotation-l.rotation+h.rotation)):(e.copyFrom(l),ut.yDown||(e.y=-e.y,e.skew=-e.skew,e.rotation=-e.rotation),e.add(h)):this.offsetMode===Mt.None?n!==null?e.copyFrom(n).add(h):e.copyFrom(h):(u=!1,e.copyFrom(l),ut.yDown||(e.y=-e.y,e.skew=-e.skew,e.rotation=-e.rotation)),u){if(_._boneData===null)throw new Error("parent._boneData is undefined.");if(i===null)throw new Error("boneData is undefined.");const T=_._boneData.type===et.Surface,g=T?_._bone:null,y=T?_._getGlobalTransformMatrix(e.x,e.y):_.globalTransformMatrix;if(i.inheritScale&&(!T||g!==null))T?(i.inheritRotation&&(e.rotation+=_.global.rotation),g.updateGlobalTransform(),e.scaleX*=g.global.scaleX,e.scaleY*=g.global.scaleY,y.transformPoint(e.x,e.y,e),e.toMatrix(s),i.inheritTranslation?(e.x=s.tx,e.y=s.ty):(s.tx=e.x,s.ty=e.y)):(i.inheritRotation||(_.updateGlobalTransform(),m&&c?f=e.rotation-(_.global.rotation+Math.PI):m?f=e.rotation+_.global.rotation+Math.PI:c?f=e.rotation+_.global.rotation:f=e.rotation-_.global.rotation,e.rotation=f),e.toMatrix(s),s.concat(y),i.inheritTranslation?(e.x=s.tx,e.y=s.ty):(s.tx=e.x,s.ty=e.y),t?e.fromMatrix(s):this._globalDirty=!0);else{if(i.inheritTranslation){const d=e.x,p=e.y;e.x=y.a*d+y.c*p+y.tx,e.y=y.b*d+y.d*p+y.ty}else m&&(e.x=-e.x),c&&(e.y=-e.y);i.inheritRotation?(_.updateGlobalTransform(),_.global.scaleX<0?f=e.rotation+_.global.rotation+Math.PI:f=e.rotation+_.global.rotation,y.a*y.d-y.b*y.c<0&&(f-=e.rotation*2,(m!==c||i.inheritReflection)&&(e.skew+=Math.PI),ut.yDown||(e.skew=-e.skew)),e.rotation=f):(m||c)&&(m&&c?f=e.rotation+Math.PI:(m?f=Math.PI-e.rotation:f=-e.rotation,e.skew+=Math.PI),e.rotation=f),e.toMatrix(s)}}else(m||c)&&(m&&(e.x=-e.x),c&&(e.y=-e.y),m&&c?f=e.rotation+Math.PI:(m?f=Math.PI-e.rotation:f=-e.rotation,e.skew+=Math.PI),e.rotation=f),e.toMatrix(s)}_updateAlpha(){if(this._alpha===void 0)throw new Error("this._alpha is undefined.");if(this._parent!==null){if(this._parent._globalAlpha===void 0)throw new Error("this._parent._globalAlpha is undefined.");this._globalAlpha=this._alpha*this._parent._globalAlpha}else{if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._globalAlpha===void 0)throw new Error("this._armature._globalAlpha is undefined.");this._globalAlpha=this._alpha*this._armature._globalAlpha}}init(t,i){this._boneData===null&&(this._boneData=t,this._armature=i,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(this._armature===null)throw new Error("this._armature is null.");if(this._cachedFrameIndex===void 0)throw new Error("this._cachedFrameIndex is undefined.");if(t>=0&&this._cachedFrameIndices!==null){const i=this._cachedFrameIndices[t];if(i>=0&&this._cachedFrameIndex===i)this._transformDirty=!1;else if(i>=0)this._transformDirty=!0,this._cachedFrameIndex=i;else{if(this._hasConstraint)for(const e of this._armature._constraints)e._root===this&&e.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 i of this._armature._constraints)i._root===this&&i.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._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");if(this._cachedFrameIndex<0){const i=t>=0;this._localDirty&&this._updateGlobalTransformMatrix(i),i&&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 i=t;for(;i!==this&&i!==null;)i=i.parent;return i===this}get boneData(){if(this._boneData===null)throw new Error("this._boneData is undefined.");return this._boneData}get visible(){if(this._visible===void 0)throw new Error("this._visible is undefined.");return this._visible}set visible(t){if(this._armature===null)throw new Error(" this._armature is null.");if(this._visible!==t){this._visible=t;for(const i of this._armature.getSlots())i.parent===this&&i._updateVisible()}}get name(){if(this._boneData===null)throw new Error(" this._boneData is undefined.");return this._boneData.name}get parent(){return this._parent}}class Pt extends b{constructor(){super(...arguments),r(this,"_constraintData",null),r(this,"_armature",null),r(this,"_target",null),r(this,"_root",null),r(this,"_bone",null)}_onClear(){this._armature=null,this._target=null,this._root=null,this._bone=null}get name(){var t;if(((t=this._constraintData)==null?void 0:t.name)===void 0)throw new Error("this._constraintData is undefined.");return this._constraintData.name}}r(Pt,"_helpMatrix",new Ot),r(Pt,"_helpTransform",new R),r(Pt,"_helpPoint",new Vt);class me extends Pt{constructor(){super(...arguments),r(this,"_bendPositive",!1),r(this,"_weight",1)}static toString(){return"[class dragonBones.IKConstraint]"}_onClear(){super._onClear(),this._bendPositive=!1,this._weight=1,this._constraintData=null}_computeA(){if(this._target===null)throw new Error("this._target is null.");if(this._root===null)throw new Error("this._root is null.");const t=this._target.global,i=this._root.global,e=this._root.globalTransformMatrix;let s=Math.atan2(t.y-i.y,t.x-i.x);i.scaleX<0&&(s+=Math.PI),i.rotation+=R.normalizeRadian(s-i.rotation)*this._weight,i.toMatrix(e)}_computeB(){if(this._bone===null)throw new Error("this._bone is null.");if(this._bone._boneData===null)throw new Error("this._bone._boneData is null.");if(this._target===null)throw new Error("this._target is null.");const t=this._bone._boneData.length,i=this._root,e=this._target.global,s=i.global,n=this._bone.global,l=this._bone.globalTransformMatrix,h=l.a*t,_=l.b*t,m=h*h+_*_,c=Math.sqrt(m);let u=n.x-s.x,f=n.y-s.y;const T=u*u+f*f,g=Math.sqrt(T),y=n.rotation,d=s.rotation,p=Math.atan2(f,u);u=e.x-s.x,f=e.y-s.y;const A=u*u+f*f,S=Math.sqrt(A);let E=0;if(c+g<=S||S+c<=g||S+g<=c)E=Math.atan2(e.y-s.y,e.x-s.x),c+g<=S||gp)continue;let tt=0;for(;;st++){const Z=J[st];if(!(d>Z)){if(st===0)tt=d/Z;else{const Dt=J[st-1];tt=(d-Dt)/(Z-Dt)}break}}st!==y&&(y=st,u&&st===g?(this._computeVertices(T-4,4,0,f),this._computeVertices(0,4,4,f)):this._computeVertices(st*6+2,8,0,f)),this.addCurvePosition(tt,f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],m,dt,e)}return}u?(T+=2,f.length=_,this._computeVertices(2,T-4,0,f),this._computeVertices(0,2,T-4,f),f[T-2]=f[0],f[T-1]=f[1]):(g--,T-=4,f.length=T,this._computeVertices(2,T,0,f));let A=new Array(g);p=0;let S=f[0],E=f[1],I=0,O=0,C=0,M=0,F=0,N=0,k,V,v,P,U,z,j,B;for(let J=0,it=2;Jp)continue;for(;;dt++){const Z=A[dt];if(!(tt>Z)){if(dt===0)tt/=Z;else{const Dt=A[dt-1];tt=(tt-Dt)/(Z-Dt)}break}}if(dt!==y){y=dt;let Z=dt*6;for(S=f[Z],E=f[Z+1],I=f[Z+2],O=f[Z+3],C=f[Z+4],M=f[Z+5],F=f[Z+6],N=f[Z+7],k=(S-I*2+C)*.03,V=(E-O*2+M)*.03,v=((I-C)*3-S+F)*.006,P=((O-M)*3-E+N)*.006,U=k*2+v,z=V*2+P,j=(I-S)*.3+k+v*.16666667,B=(O-E)*.3+V+P*.16666667,W=Math.sqrt(j*j+B*B),H[0]=W,Z=1;Z<8;Z++)j+=U,B+=z,U+=v,z+=P,W+=Math.sqrt(j*j+B*B),H[Z]=W;j+=U,B+=z,W+=Math.sqrt(j*j+B*B),H[8]=W,j+=U+v,B+=z+P,W+=Math.sqrt(j*j+B*B),H[9]=W,st=0}for(tt*=W;;st++){const Z=H[st];if(!(tt>Z)){if(st===0)tt/=Z;else{const Dt=H[st-1];tt=st+(tt-Dt)/(Z-Dt)}break}}this.addCurvePosition(tt*.1,S,E,I,O,C,M,F,N,m,it,e)}}addCurvePosition(t,i,e,s,n,l,h,_,m,c,u,f){if(t===0){c[u]=i,c[u+1]=e,c[u+2]=0;return}if(t===1){c[u]=_,c[u+1]=m,c[u+2]=0;return}const T=1-t,g=T*T,y=t*t,d=g*T,p=g*t*3,A=T*y*3,S=t*y,E=d*i+p*s+A*l+S*_,I=d*e+p*n+A*h+S*m;c[u]=E,c[u+1]=I,f?c[u+2]=Math.atan2(I-(d*e+p*n+A*h),E-(d*i+p*s+A*l)):c[u+2]=0}init(t,i){this._constraintData=t,this._armature=i;let e=t;if(e.pathDisplayData===null)throw new Error("data.pathDisplayData is null.");if(e.root===null)throw new Error("data.root is null.");if(e.target===null)throw new Error("data.target is null.");if(e.pathSlot===null)throw new Error("data.pathSlot is null.");this.pathOffset=e.pathDisplayData.geometry.offset,this.position=e.position,this.spacing=e.spacing,this.rotateOffset=e.rotateOffset,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this._root=this._armature.getBone(e.root.name),this._target=this._armature.getBone(e.target.name),this._pathSlot=this._armature.getSlot(e.pathSlot.name);for(let s=0,n=e.bones.length;s0?R.DEG_RAD:-R.DEG_RAD}}const E=this.rotateMix,I=this.translateMix;for(let O=0,C=3;O0){let P=F.a,U=F.b,z=F.c,j=F.d,B,H,W;if(c?B=y[C-1]:B=Math.atan2(v,V),B-=Math.atan2(U,P),S){H=Math.cos(B),W=Math.sin(B);const J=M._boneData.length;p+=(J*(H*P-W*U)-V)*E,A+=(J*(W*P+H*U)-v)*E}else B+=d;B>R.PI?B-=R.PI_D:B<-R.PI&&(B+=R.PI_D),B*=E,H=Math.cos(B),W=Math.sin(B),F.a=H*P-W*U,F.b=W*P+H*U,F.c=H*z-W*j,F.d=W*z+H*j}M.global.fromMatrix(F)}this.dirty=!1}invalidUpdate(){}}class Ut{constructor(t=1,i=1,e=1,s=1,n=0,l=0,h=0,_=0){r(this,"alphaMultiplier"),r(this,"redMultiplier"),r(this,"greenMultiplier"),r(this,"blueMultiplier"),r(this,"alphaOffset"),r(this,"redOffset"),r(this,"greenOffset"),r(this,"blueOffset"),this.alphaMultiplier=t,this.redMultiplier=i,this.greenMultiplier=e,this.blueMultiplier=s,this.alphaOffset=n,this.redOffset=l,this.greenOffset=h,this.blueOffset=_}copyFrom(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.greenOffset=t.greenOffset,this.blueOffset=t.blueOffset}identity(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0}}class Ve extends b{constructor(){super(...arguments),r(this,"rawDisplayData",null),r(this,"displayData",null),r(this,"textureData",null),r(this,"display",null),r(this,"deformVertices",[])}static toString(){return"[class dragonBones.DisplayFrame]"}_onClear(){this.rawDisplayData=null,this.displayData=null,this.textureData=null,this.display=null,this.deformVertices.length=0}updateDeformVertices(){if(this.rawDisplayData===null||this.deformVertices.length!==0)return;let t;if(this.rawDisplayData.type===L.Mesh)t=this.rawDisplayData.geometry;else if(this.rawDisplayData.type===L.Path)t=this.rawDisplayData.geometry;else return;let i=0;if(t.weight!==null)i=t.weight.count*2;else{if(t.data===null)throw new Error("rawGeometryData.data is null.");if(t.data.intArray===null)throw new Error("rawGeometryData.data.intArray is null.");i=t.data.intArray[t.offset+w.GeometryVertexCount]*2}this.deformVertices.length=i;for(let e=0,s=this.deformVertices.length;e=0&&this._displayIndex0)for(const n of e){const l=b.borrowObject(Y);Y.actionDataToInstance(n,l,this._armature),l.slot=this,this._armature._bufferAction(l,!1)}else this._childArmature.animation.play()}}}}_updateGlobalTransformMatrix(t){if(this._parent===null)throw new Error("this._parent is null.");if(this._parent._boneData===null)throw new Error("this._parent._boneData is null.");const i=this._parent._boneData.type===et.Bone?this._parent.globalTransformMatrix:this._parent._getGlobalTransformMatrix(this.global.x,this.global.y);this.globalTransformMatrix.copyFrom(this._localMatrix),this.globalTransformMatrix.concat(i),t?this.global.fromMatrix(this.globalTransformMatrix):this._globalDirty=!0}_setDisplayIndex(t,i=!1){if(i){if(this._animationDisplayIndex===t)return;this._animationDisplayIndex=t}this._displayIndex!==t&&(this._displayIndex=t=0&&this._cachedFrameIndices!==null){const i=this._cachedFrameIndices[t];i>=0&&this._cachedFrameIndex===i?this._transformDirty=!1:i>=0?(this._transformDirty=!0,this._cachedFrameIndex=i):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._armature===null)throw new Error(" this._armature is null.");if(this._armature._armatureData===null)throw new Error(" this._armature._armatureData is null.");if(this._transformDirty){if(this._cachedFrameIndex<0){const i=t>=0;this._updateGlobalTransformMatrix(i),i&&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,i=-1){if(i<0)i=this._displayIndex<0?0:this._displayIndex;else if(i>=this._displayFrames.length)return;if(this._armature===null)throw new Error(" this._armature is null.");if(this._armature._armatureData===null)throw new Error(" this._armature._armatureData is null.");if(this._slotData===null)throw new Error(" this._slotData is null.");const e=this._displayFrames[i];if(e.rawDisplayData!==t){if(e.deformVertices.length=0,e.rawDisplayData=t,e.rawDisplayData===null){const s=this._armature._armatureData.defaultSkin;if(s!==null){const n=s.getDisplays(this._slotData.name);n!==null&&i=this._displayFrames.length)return;const e=this._displayFrames[i];e.displayData!==t&&e.rawDisplayData!==t&&(e.displayData=t,i===this._displayIndex&&(this._displayDataDirty=!0))}replaceTextureData(t,i=-1){if(i<0)i=this._displayIndex<0?0:this._displayIndex;else if(i>=this._displayFrames.length)return;const e=this._displayFrames[i];e.textureData!==t&&(e.textureData=t,i===this._displayIndex&&(this._displayDataDirty=!0))}replaceDisplay(t,i=-1){if(i<0)i=this._displayIndex<0?0:this._displayIndex;else if(i>=this._displayFrames.length)return;const e=this._displayFrames[i];if(e.display!==t){const s=e.display;e.display=t,s!==null&&s!==this._rawDisplay&&s!==this._meshDisplay&&!this._hasDisplay(s)&&(s instanceof gt||this._disposeDisplay(s,!0)),t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(s)&&!(t instanceof gt)&&this._initDisplay(t,!0),i===this._displayIndex&&(this._displayDirty=!0)}}containsPoint(t,i){return this._boundingBoxData===null?!1:(this.updateTransformAndMatrix(),G._helpMatrix.copyFrom(this.globalTransformMatrix),G._helpMatrix.invert(),G._helpMatrix.transformPoint(t,i,G._helpPoint),this._boundingBoxData.containsPoint(G._helpPoint.x,G._helpPoint.y))}intersectsSegment(t,i,e,s,n=null,l=null,h=null){if(this._boundingBoxData===null)return 0;this.updateTransformAndMatrix(),G._helpMatrix.copyFrom(this.globalTransformMatrix),G._helpMatrix.invert(),G._helpMatrix.transformPoint(t,i,G._helpPoint),t=G._helpPoint.x,i=G._helpPoint.y,G._helpMatrix.transformPoint(e,s,G._helpPoint),e=G._helpPoint.x,s=G._helpPoint.y;const _=this._boundingBoxData.intersectsSegment(t,i,e,s,n,l,h);return _>0&&(_===1||_===2?n!==null?(this.globalTransformMatrix.transformPoint(n.x,n.y,n),l!==null&&(l.x=n.x,l.y=n.y)):l!==null&&this.globalTransformMatrix.transformPoint(l.x,l.y,l):(n!==null&&this.globalTransformMatrix.transformPoint(n.x,n.y,n),l!==null&&this.globalTransformMatrix.transformPoint(l.x,l.y,l)),h!==null&&(this.globalTransformMatrix.transformPoint(Math.cos(h.x),Math.sin(h.x),G._helpPoint,!0),h.x=Math.atan2(G._helpPoint.y,G._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(h.y),Math.sin(h.y),G._helpPoint,!0),h.y=Math.atan2(G._helpPoint.y,G._helpPoint.x))),_}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 i=this._displayFrames.length;if(it){for(let e=i-1;e=200)return this.globalTransformMatrix;if(e=i>this._kX*(t+200)+g,f=((n*l+n+l+l+u)*2+(e?1:0))*7,y[f]>0)d.copyFromArray(y,f+1);else{const p=u*(h+2),A=this._hullCache[4],S=this._hullCache[5],E=this._hullCache[2]-(l-u)*A,I=this._hullCache[3]-(l-u)*S,O=this._vertices;e?this._getAffineTransform(-200,g+m,1e3-200,m,O[p+h+2],O[p+h+3],E+A,I+S,O[p],O[p+1],lt._helpTransform,d,!0):this._getAffineTransform(-1e3,g,1e3-200,m,E,I,O[p],O[p+1],E+A,I+S,lt._helpTransform,d,!1),y[f]=1,y[f+1]=d.a,y[f+2]=d.b,y[f+3]=d.c,y[f+4]=d.d,y[f+5]=d.tx,y[f+6]=d.ty}}else if(t>=200){if(i<-200||i>=200)return this.globalTransformMatrix;if(e=i>this._kX*(t-1e3)+g,f=((n*l+n+u)*2+(e?1:0))*7,y[f]>0)d.copyFromArray(y,f+1);else{const p=(u+1)*(h+2)-2,A=this._hullCache[4],S=this._hullCache[5],E=this._hullCache[0]+u*A,I=this._hullCache[1]+u*S,O=this._vertices;e?this._getAffineTransform(1e3,g+m,1e3-200,m,E+A,I+S,O[p+h+2],O[p+h+3],E,I,lt._helpTransform,d,!0):this._getAffineTransform(200,g,1e3-200,m,O[p],O[p+1],E,I,O[p+h+2],O[p+h+3],lt._helpTransform,d,!1),y[f]=1,y[f+1]=d.a,y[f+2]=d.b,y[f+3]=d.c,y[f+4]=d.d,y[f+5]=d.tx,y[f+6]=d.ty}}else if(i<-200){if(t<-200||t>=200)return this.globalTransformMatrix;if(e=i>this._kY*(t-T-_)-1e3,f=((n*l+c)*2+(e?1:0))*7,y[f]>0)d.copyFromArray(y,f+1);else{const p=c*2,A=this._hullCache[10],S=this._hullCache[11],E=this._hullCache[8]+c*A,I=this._hullCache[9]+c*S,O=this._vertices;e?this._getAffineTransform(T+_,-200,_,1e3-200,O[p+2],O[p+3],O[p],O[p+1],E+A,I+S,lt._helpTransform,d,!0):this._getAffineTransform(T,-1e3,_,1e3-200,E,I,E+A,I+S,O[p],O[p+1],lt._helpTransform,d,!1),y[f]=1,y[f+1]=d.a,y[f+2]=d.b,y[f+3]=d.c,y[f+4]=d.d,y[f+5]=d.tx,y[f+6]=d.ty}}else if(i>=200){if(t<-200||t>=200)return this.globalTransformMatrix;if(e=i>this._kY*(t-T-_)+200,f=((n*l+n+l+c)*2+(e?1:0))*7,y[f]>0)d.copyFromArray(y,f+1);else{const p=l*(h+2)+c*2,A=this._hullCache[10],S=this._hullCache[11],E=this._hullCache[6]-(n-c)*A,I=this._hullCache[7]-(n-c)*S,O=this._vertices;e?this._getAffineTransform(T+_,1e3,_,1e3-200,E+A,I+S,E,I,O[p+2],O[p+3],lt._helpTransform,d,!0):this._getAffineTransform(T,200,_,1e3-200,O[p],O[p+1],O[p+2],O[p+3],E,I,lt._helpTransform,d,!1),y[f]=1,y[f+1]=d.a,y[f+2]=d.b,y[f+3]=d.c,y[f+4]=d.d,y[f+5]=d.tx,y[f+6]=d.ty}}else if(e=i>this._k*(t-T-_)+g,f=((n*u+c)*2+(e?1:0))*7,y[f]>0)d.copyFromArray(y,f+1);else{const p=c*2+u*(h+2),A=this._vertices;e?this._getAffineTransform(T+_,g+m,_,m,A[p+h+4],A[p+h+5],A[p+h+2],A[p+h+3],A[p+2],A[p+3],lt._helpTransform,d,!0):this._getAffineTransform(T,g,_,m,A[p],A[p+1],A[p+2],A[p+3],A[p+h+2],A[p+h+3],lt._helpTransform,d,!1),y[f]=1,y[f+1]=d.a,y[f+2]=d.b,y[f+3]=d.c,y[f+4]=d.d,y[f+5]=d.tx,y[f+6]=d.ty}return d}init(t,i){if(this._boneData!==null)return;if(super.init(t,i),this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");if(this._armature.armatureData.parent===null)throw new Error("this._armature.armatureData.parent is null.");if(this._armature.armatureData.parent.intArray===null)throw new Error("this._armature.armatureData.parent.intArray is null.");const e=t.segmentX,s=t.segmentY,n=this._armature.armatureData.parent.intArray[t.geometry.offset+w.GeometryVertexCount],l=1e3,h=200;this._dX=h*2/e,this._dY=h*2/s,this._k=-this._dY/this._dX,this._kX=-this._dY/(l-h),this._kY=-(l-h)/this._dX,this._vertices.length=n*2,this._deformVertices.length=n*2,this._matrixCahce.length=(e*s+e*2+s*2)*2*7,this._hullCache.length=10;for(let _=0;_=0&&this._cachedFrameIndices!==null){const i=this._cachedFrameIndices[t];if(i>=0&&this._cachedFrameIndex===i)this._transformDirty=!1;else if(i>=0)this._transformDirty=!0,this._cachedFrameIndex=i;else{if(this._hasConstraint){if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");for(const e of this._armature._constraints)e._root===this&&e.update()}if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");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){if(this._armature===null)throw new Error("this._armature is null.");for(const i of this._armature._constraints)i._root===this&&i.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 h=0,_=this._matrixCahce.length;h<_;h+=7)this._matrixCahce[h]=-1;if(this._updateVertices(),this._cachedFrameIndex<0){const h=t>=0;if(this._localDirty&&this._updateGlobalTransformMatrix(h),h&&this._cachedFrameIndices!==null){if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}const i=1e3,e=200,s=2*this.global.x,n=2*this.global.y,l=lt._helpPoint;this.globalTransformMatrix.transformPoint(i,-e,l),this._hullCache[0]=l.x,this._hullCache[1]=l.y,this._hullCache[2]=s-l.x,this._hullCache[3]=n-l.y,this.globalTransformMatrix.transformPoint(0,this._dY,l,!0),this._hullCache[4]=l.x,this._hullCache[5]=l.y,this.globalTransformMatrix.transformPoint(e,i,l),this._hullCache[6]=l.x,this._hullCache[7]=l.y,this._hullCache[8]=s-l.x,this._hullCache[9]=n-l.y,this.globalTransformMatrix.transformPoint(this._dX,0,l,!0),this._hullCache[10]=l.x,this._hullCache[11]=l.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0}}class fe extends b{constructor(){super(...arguments),r(this,"frameIntOffset",0),r(this,"frameFloatOffset",0),r(this,"frameOffset",0),r(this,"blendType",_t.None),r(this,"frameCount",0),r(this,"playTimes",0),r(this,"duration",0),r(this,"scale",1),r(this,"fadeInTime",0),r(this,"cacheFrameRate",0),r(this,"name",""),r(this,"cachedFrames",[]),r(this,"boneTimelines",{}),r(this,"slotTimelines",{}),r(this,"constraintTimelines",{}),r(this,"animationTimelines",{}),r(this,"boneCachedFrameIndices",{}),r(this,"slotCachedFrameIndices",{}),r(this,"actionTimeline",null),r(this,"zOrderTimeline",null),r(this,"parent",null)}static toString(){return"[class dragonBones.AnimationData]"}_onClear(){for(let t in this.boneTimelines){for(const i of this.boneTimelines[t])i.returnToPool();delete this.boneTimelines[t]}for(let t in this.slotTimelines){for(const i of this.slotTimelines[t])i.returnToPool();delete this.slotTimelines[t]}for(let t in this.constraintTimelines){for(const i of this.constraintTimelines[t])i.returnToPool();delete this.constraintTimelines[t]}for(let t in this.animationTimelines){for(const i of this.animationTimelines[t])i.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=_t.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 i=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=i;for(let e=0,s=this.cacheFrames.length;e=t&&(e=0),this.sortedBones.indexOf(n)>=0)continue;let l=!1;for(let h in this.constraints){const _=this.constraints[h];if(_.root===n&&this.sortedBones.findIndex(m=>m===_.target)<0){l=!0;break}}l||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 i in this.animations)this.animations[i].cacheFrames(this.cacheFrameRate)}}setCacheFrame(t,i){if(this.parent===null)throw new Error("this.parent is null.");const e=this.parent.cachedFrames;let s=e.length;return e.length+=10,e[s]=t.a,e[s+1]=t.b,e[s+2]=t.c,e[s+3]=t.d,e[s+4]=t.tx,e[s+5]=t.ty,e[s+6]=i.rotation,e[s+7]=i.skew,e[s+8]=i.scaleX,e[s+9]=i.scaleY,s}getCacheFrame(t,i,e){if(this.parent===null)throw new Error("this.parent is nul.");const s=this.parent.cachedFrames;t.a=s[e],t.b=s[e+1],t.c=s[e+2],t.d=s[e+3],t.tx=s[e+4],t.ty=s[e+5],i.rotation=s[e+6],i.skew=s[e+7],i.scaleX=s[e+8],i.scaleY=s[e+9],i.x=t.tx,i.y=t.ty}addBone(t){if(t.name===void 0)throw new Error("value.name is undefined.");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===void 0)throw new Error("value.name is undefined.");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===void 0)throw new Error("value.name is undefined.");if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t}addSkin(t){if(t.name===void 0)throw new Error("value.name is undefined.");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===void 0)throw new Error("value.name is undefined.");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,i){i?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,i,e){const s=this.getSkin(t);return s===null?null:s.getDisplay(i,e)}getAnimation(t){return t in this.animations?this.animations[t]:null}}class ye extends b{constructor(){super(...arguments),r(this,"inheritTranslation",!1),r(this,"inheritRotation",!1),r(this,"inheritScale",!1),r(this,"inheritReflection",!1),r(this,"type",et.Bone),r(this,"length",0),r(this,"alpha",1),r(this,"name",""),r(this,"transform",new R),r(this,"userData",null),r(this,"parent",null)}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=et.Bone,this.length=0,this.alpha=1,this.name="",this.transform.identity(),this.userData=null,this.parent=null}}class We extends ye{constructor(){super(...arguments),r(this,"segmentX",0),r(this,"segmentY",0),r(this,"geometry",new zt)}static toString(){return"[class dragonBones.SurfaceData]"}_onClear(){super._onClear(),this.type=et.Surface,this.segmentX=0,this.segmentY=0,this.geometry.clear()}}class Gt extends b{constructor(){super(...arguments),r(this,"blendMode",$.Normal),r(this,"displayIndex",0),r(this,"zOrder",0),r(this,"zIndex",0),r(this,"alpha",1),r(this,"name",""),r(this,"color",null),r(this,"userData",null),r(this,"parent",null)}static createColor(){return new Ut}static toString(){return"[class dragonBones.SlotData]"}_onClear(){this.userData!==null&&this.userData.returnToPool(),this.blendMode=$.Normal,this.displayIndex=0,this.zOrder=0,this.zIndex=0,this.alpha=1,this.name="",this.color=null,this.userData=null,this.parent=null}}r(Gt,"DEFAULT_COLOR",new Ut);class Kt extends b{constructor(){super(...arguments),r(this,"type"),r(this,"color",0),r(this,"width",0),r(this,"height",0)}_onClear(){this.color=0,this.width=0,this.height=0}}class Tt extends Kt{static toString(){return"[class dragonBones.RectangleBoundingBoxData]"}static _computeOutCode(t,i,e,s,n,l){let h=0;return tn&&(h|=2),il&&(h|=8),h}static rectangleIntersectsSegment(t,i,e,s,n,l,h,_,m=null,c=null,u=null){const f=t>n&&tl&&i<_,T=e>n&&el&&s<_;if(f&&T)return-1;let g=0,y=Tt._computeOutCode(t,i,n,l,h,_),d=Tt._computeOutCode(e,s,n,l,h,_);for(;;){if(y|d){if(y&d)break}else{g=2;break}let p=0,A=0,S=0;const E=y!==0?y:d;E&4?(p=t+(e-t)*(l-i)/(s-i),A=l,u!==null&&(S=-Math.PI*.5)):E&8?(p=t+(e-t)*(_-i)/(s-i),A=_,u!==null&&(S=Math.PI*.5)):E&2?(A=i+(s-i)*(h-t)/(e-t),p=h,u!==null&&(S=0)):E&1&&(A=i+(s-i)*(n-t)/(e-t),p=n,u!==null&&(S=Math.PI)),E===y?(t=p,i=A,y=Tt._computeOutCode(t,i,n,l,h,_),u!==null&&(u.x=S)):(e=p,s=A,d=Tt._computeOutCode(e,s,n,l,h,_),u!==null&&(u.y=S))}return g&&(f?(g=2,m!==null&&(m.x=e,m.y=s),c!==null&&(c.x=e,c.y=e),u!==null&&(u.x=u.y+Math.PI)):T?(g=1,m!==null&&(m.x=t,m.y=i),c!==null&&(c.x=t,c.y=i),u!==null&&(u.y=u.x+Math.PI)):(g=3,m!==null&&(m.x=t,m.y=i),c!==null&&(c.x=e,c.y=s))),g}_onClear(){super._onClear(),this.type=nt.Rectangle}containsPoint(t,i){if(this.width===void 0||this.height===void 0)throw new Error;const e=this.width*.5;if(t>=-e&&t<=e){const s=this.height*.5;if(i>=-s&&i<=s)return!0}return!1}intersectsSegment(t,i,e,s,n=null,l=null,h=null){if(this.width===void 0||this.height===void 0)throw new Error;const _=this.width*.5,m=this.height*.5;return Tt.rectangleIntersectsSegment(t,i,e,s,-_,-m,_,m,n,l,h)}}class Zt extends Kt{static toString(){return"[class dragonBones.EllipseData]"}static ellipseIntersectsSegment(t,i,e,s,n,l,h,_,m=null,c=null,u=null){const f=h/_,T=f*f;i*=f,s*=f;const g=e-t,y=s-i,d=Math.sqrt(g*g+y*y),p=g/d,A=y/d,S=(n-t)*p+(l-i)*A,E=S*S,I=t*t+i*i,O=h*h,C=O-I+E;let M=0;if(C>=0){const F=Math.sqrt(C),N=S-F,k=S+F,V=N<0?-1:N<=d?0:1,v=k<0?-1:k<=d?0:1,P=V*v;if(P<0)return-1;P===0&&(V===-1?(M=2,e=t+k*p,s=(i+k*A)/f,m!==null&&(m.x=e,m.y=s),c!==null&&(c.x=e,c.y=s),u!==null&&(u.x=Math.atan2(s/O*T,e/O),u.y=u.x+Math.PI)):v===1?(M=1,t=t+N*p,i=(i+N*A)/f,m!==null&&(m.x=t,m.y=i),c!==null&&(c.x=t,c.y=i),u!==null&&(u.x=Math.atan2(i/O*T,t/O),u.y=u.x+Math.PI)):(M=3,m!==null&&(m.x=t+N*p,m.y=(i+N*A)/f,u!==null&&(u.x=Math.atan2(m.y/O*T,m.x/O))),c!==null&&(c.x=t+k*p,c.y=(i+k*A)/f,u!==null&&(u.y=Math.atan2(c.y/O*T,c.x/O)))))}return M}_onClear(){super._onClear(),this.type=nt.Ellipse}containsPoint(t,i){if(this.width===void 0||this.height===void 0)throw new Error;const e=this.width*.5;if(t>=-e&&t<=e){const s=this.height*.5;if(i>=-s&&i<=s)return i*=e/s,Math.sqrt(t*t+i*i)<=e}return!1}intersectsSegment(t,i,e,s,n=null,l=null,h=null){if(this.width===void 0||this.height===void 0)throw new Error;return Zt.ellipseIntersectsSegment(t,i,e,s,0,0,this.width*.5,this.height*.5,n,l,h)}}class qt extends Kt{constructor(){super(...arguments),r(this,"x",0),r(this,"y",0),r(this,"vertices",[])}static toString(){return"[class dragonBones.PolygonBoundingBoxData]"}static polygonIntersectsSegment(t,i,e,s,n,l=null,h=null,_=null){t===e&&(t=e+1e-6),i===s&&(i=s+1e-6);const m=n.length,c=t-e,u=i-s,f=t*s-i*e;let T=0,g=n[m-2],y=n[m-1],d=0,p=0,A=0,S=0,E=0,I=0;for(let O=0;O=g&&v<=C||v>=C&&v<=g)&&(c===0||v>=t&&v<=e||v>=e&&v<=t)){const P=(f*N-u*k)/V;if((P>=y&&P<=M||P>=M&&P<=y)&&(u===0||P>=i&&P<=s||P>=s&&P<=i))if(h!==null){let U=v-t;U<0&&(U=-U),T===0?(d=U,p=U,A=v,S=P,E=v,I=P,_!==null&&(_.x=Math.atan2(M-y,C-g)-Math.PI*.5,_.y=_.x)):(Up&&(p=U,E=v,I=P,_!==null&&(_.y=Math.atan2(M-y,C-g)-Math.PI*.5))),T++}else{A=v,S=P,E=v,I=P,T++,_!==null&&(_.x=Math.atan2(M-y,C-g)-Math.PI*.5,_.y=_.x);break}}g=C,y=M}return T===1?(l!==null&&(l.x=A,l.y=S),h!==null&&(h.x=A,h.y=S),_!==null&&(_.y=_.x+Math.PI)):T>1&&(T++,l!==null&&(l.x=A,l.y=S),h!==null&&(h.x=E,h.y=I)),T}_onClear(){super._onClear(),this.type=nt.Polygon,this.x=0,this.y=0,this.vertices.length=0}containsPoint(t,i){if(this.x===void 0||this.y===void 0)throw new Error("");if(this.width===void 0||this.height===void 0)throw new Error;let e=!1;if(t>=this.x&&t<=this.width&&i>=this.y&&i<=this.height)for(let s=0,n=this.vertices.length,l=n-2;s=i||h=i){const m=this.vertices[l],c=this.vertices[s];(i-_)*(m-c)/(h-_)+c=0&&t=0&&t=0&&t=0&&e+61e-4;){const A=(p+d)*.5;this._getCurvePoint(_,m,c,u,f,T,g,y,A,this._helpPoint),l-this._helpPoint.x>0?d=A:p=A}t[s]=this._helpPoint.y}return!0}else{let e=0;for(let s=0,n=t.length;s1e-4;){const p=(d+y)*.5;this._getCurvePoint(h,_,m,c,u,f,T,g,p,this._helpPoint),l-this._helpPoint.x>0?y=p:d=p}t[s]=this._helpPoint.y}return!1}}_parseActionDataInFrame(a,t,i,e){o.EVENT in a&&this._mergeActionFrame(a[o.EVENT],t,K.Frame,i,e),o.SOUND in a&&this._mergeActionFrame(a[o.SOUND],t,K.Sound,i,e),o.ACTION in a&&this._mergeActionFrame(a[o.ACTION],t,K.Play,i,e),o.EVENTS in a&&this._mergeActionFrame(a[o.EVENTS],t,K.Frame,i,e),o.ACTIONS in a&&this._mergeActionFrame(a[o.ACTIONS],t,K.Play,i,e)}_mergeActionFrame(a,t,i,e,s){const n=this._armature.actions.length,l=this._parseActionData(a,i,e,s);let h=0,_=null;for(const m of l)this._armature.addAction(m,!1);this._actionFrames.length===0&&(_=new $t,_.frameStart=0,this._actionFrames.push(_),_=null);for(const m of this._actionFrames){if(m.frameStart===t){_=m;break}else if(m.frameStart>t)break;h++}_===null&&(_=new $t,_.frameStart=t,this._actionFrames.splice(h,0,_));for(let m=0;m0){const h=i.getBone(n);h!==null?l.parent=h:(n in this._cacheBones||(this._cacheBones[n]=[]),this._cacheBones[n].push(l))}if(l.name in this._cacheBones){for(const h of this._cacheBones[l.name])h.parent=l;delete this._cacheBones[l.name]}i.addBone(l),this._rawBones.push(l)}}if(o.IK in a){const e=a[o.IK];for(const s of e){const n=this._parseIKConstraint(s);n&&i.addConstraint(n)}}if(i.sortBones(),o.SLOT in a){let e=0;const s=a[o.SLOT];for(const n of s)i.addSlot(this._parseSlot(n,e++))}if(o.SKIN in a){const e=a[o.SKIN];for(const s of e)i.addSkin(this._parseSkin(s))}if(o.PATH_CONSTRAINT in a){const e=a[o.PATH_CONSTRAINT];for(const s of e){const n=this._parsePathConstraint(s);n&&i.addConstraint(n)}}for(let e=0,s=this._cacheRawMeshes.length;e0&&t.parent!==null?(s.root=t.parent,s.bone=t):(s.root=t,s.bone=null),s}_parsePathConstraint(a){const t=this._armature.getSlot(D._getString(a,o.TARGET,""));if(t===null)return null;const i=this._armature.defaultSkin;if(i===null)return null;const e=i.getDisplay(t.name,D._getString(a,o.TARGET_DISPLAY,t.name));if(e===null||!(e instanceof de))return null;const s=a[o.BONES];if(s===null||s.length===0)return null;const n=b.borrowObject(Ke);n.name=D._getString(a,o.NAME,""),n.type=wt.Path,n.pathSlot=t,n.pathDisplayData=e,n.target=t.parent,n.positionMode=o._getPositionMode(D._getString(a,o.POSITION_MODE,"")),n.spacingMode=o._getSpacingMode(D._getString(a,o.SPACING_MODE,"")),n.rotateMode=o._getRotateMode(D._getString(a,o.ROTATE_MODE,"")),n.position=D._getNumber(a,o.POSITION,0),n.spacing=D._getNumber(a,o.SPACING,0),n.rotateOffset=D._getNumber(a,o.ROTATE_OFFSET,0),n.rotateMix=D._getNumber(a,o.ROTATE_MIX,1),n.translateMix=D._getNumber(a,o.TRANSLATE_MIX,1);for(var l of s){const h=this._armature.getBone(l);h!==null&&(n.AddBone(h),n.root===null&&(n.root=h))}return n}_parseSlot(a,t){const i=b.borrowObject(Gt);return i.displayIndex=D._getNumber(a,o.DISPLAY_INDEX,0),i.zOrder=t,i.zIndex=D._getNumber(a,o.Z_INDEX,0),i.alpha=D._getNumber(a,o.ALPHA,1),i.name=D._getString(a,o.NAME,""),i.parent=this._armature.getBone(D._getString(a,o.PARENT,"")),o.BLEND_MODE in a&&typeof a[o.BLEND_MODE]=="string"?i.blendMode=o._getBlendMode(a[o.BLEND_MODE]):i.blendMode=D._getNumber(a,o.BLEND_MODE,$.Normal),o.COLOR in a?(i.color=Gt.createColor(),this._parseColorTransform(a[o.COLOR],i.color)):i.color=Gt.DEFAULT_COLOR,o.ACTIONS in a&&(this._slotChildActions[i.name]=this._parseActionData(a[o.ACTIONS],K.Play,null,null)),i}_parseSkin(a){const t=b.borrowObject(qe);if(t.name=D._getString(a,o.NAME,o.DEFAULT_NAME),t.name.length===0&&(t.name=o.DEFAULT_NAME),o.SLOT in a){const i=a[o.SLOT];this._skin=t;for(const e of i){const s=D._getString(e,o.NAME,""),n=this._armature.getSlot(s);if(n!==null){if(this._slot=n,o.DISPLAY in e){const l=e[o.DISPLAY];for(const h of l)h?t.addDisplay(s,this._parseDisplay(h)):t.addDisplay(s,null)}this._slot=null}}this._skin=null}return t}_parseDisplay(a){const t=D._getString(a,o.NAME,""),i=D._getString(a,o.PATH,"");let e=L.Image,s=null;switch(o.TYPE in a&&typeof a[o.TYPE]=="string"?e=o._getDisplayType(a[o.TYPE]):e=D._getNumber(a,o.TYPE,e),e){case L.Image:{const n=s=b.borrowObject(Ye);n.name=t,n.path=i.length>0?i:t,this._parsePivot(a,n);break}case L.Armature:{const n=s=b.borrowObject(Ue);if(n.name=t,n.path=i.length>0?i:t,n.inheritAnimation=!0,o.ACTIONS in a){const l=this._parseActionData(a[o.ACTIONS],K.Play,null,null);for(const h of l)n.addAction(h)}else if(this._slot.name in this._slotChildActions){const l=this._skin.getDisplays(this._slot.name);if(l===null?this._slot.displayIndex===0:this._slot.displayIndex===l.length){for(const h of this._slotChildActions[this._slot.name])n.addAction(h);delete this._slotChildActions[this._slot.name]}}break}case L.Mesh:{const n=s=b.borrowObject(Xe);n.geometry.inheritDeform=D._getBoolean(a,o.INHERIT_DEFORM,!0),n.name=t,n.path=i.length>0?i:t,o.SHARE in a?(n.geometry.data=this._data,this._cacheRawMeshes.push(a),this._cacheMeshes.push(n)):this._parseMesh(a,n);break}case L.BoundingBox:{const n=this._parseBoundingBox(a);if(n!==null){const l=s=b.borrowObject(Ge);l.name=t,l.path=i.length>0?i:t,l.boundingBox=n}break}case L.Path:{const n=a[o.LENGTHS],l=s=b.borrowObject(de);l.closed=D._getBoolean(a,o.CLOSED,!1),l.constantSpeed=D._getBoolean(a,o.CONSTANT_SPEED,!1),l.name=t,l.path=i.length>0?i:t,l.curveLengths.length=n.length;for(let h=0,_=n.length;h<_;++h)l.curveLengths[h]=n[h];this._parsePath(a,l);break}}return s!==null&&o.TRANSFORM in a&&this._parseTransform(a[o.TRANSFORM],s.transform,this._armature.scale),s}_parsePath(a,t){this._parseGeometry(a,t.geometry)}_parsePivot(a,t){if(o.PIVOT in a){const i=a[o.PIVOT];t.pivot.x=D._getNumber(i,o.X,0),t.pivot.y=D._getNumber(i,o.Y,0)}else t.pivot.x=.5,t.pivot.y=.5}_parseMesh(a,t){if(this._parseGeometry(a,t.geometry),o.WEIGHTS in a){const i=a[o.SLOT_POSE],e=a[o.BONE_POSE],s=this._skin.name+"_"+this._slot.name+"_"+t.name;this._weightSlotPose[s]=i,this._weightBonePoses[s]=e}}_parseBoundingBox(a){let t=null,i=nt.Rectangle;switch(o.SUB_TYPE in a&&typeof a[o.SUB_TYPE]=="string"?i=o._getBoundingBoxType(a[o.SUB_TYPE]):i=D._getNumber(a,o.SUB_TYPE,i),i){case nt.Rectangle:t=b.borrowObject(Tt);break;case nt.Ellipse:t=b.borrowObject(Zt);break;case nt.Polygon:t=this._parsePolygonBoundingBox(a);break}return t!==null&&(t.color=D._getNumber(a,o.COLOR,0),(t.type===nt.Rectangle||t.type===nt.Ellipse)&&(t.width=D._getNumber(a,o.WIDTH,0),t.height=D._getNumber(a,o.HEIGHT,0))),t}_parsePolygonBoundingBox(a){const t=b.borrowObject(qt);if(o.VERTICES in a){const i=this._armature.scale,e=a[o.VERTICES],s=t.vertices;s.length=e.length;for(let n=0,l=e.length;nt.width&&(t.width=h),_t.height&&(t.height=_))}t.width-=t.x,t.height-=t.y}else console.warn(`Data error. Please reexport DragonBones Data to fixed the bug.`);return t}_parseAnimation(a){const t=b.borrowObject(fe);if(t.blendType=o._getAnimationBlendType(D._getString(a,o.BLEND_TYPE,"")),t.frameCount=D._getNumber(a,o.DURATION,0),t.playTimes=D._getNumber(a,o.PLAY_TIMES,1),t.duration=t.frameCount/this._armature.frameRate,t.fadeInTime=D._getNumber(a,o.FADE_IN_TIME,0),t.scale=D._getNumber(a,o.SCALE,1),t.name=D._getString(a,o.NAME,o.DEFAULT_NAME),t.name.length===0&&(t.name=o.DEFAULT_NAME),t.frameIntOffset=this._frameIntArray.length,t.frameFloatOffset=this._frameFloatArray.length,t.frameOffset=this._frameArray.length,this._animation=t,o.FRAME in a){const i=a[o.FRAME],e=i.length;if(e>0)for(let s=0,n=0;s0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",x.Action,0,0,this._parseActionFrame),this._actionFrames.length=0),o.TIMELINE in a){const i=a[o.TIMELINE];for(const e of i){const s=D._getNumber(e,o.TYPE,x.Action),n=D._getString(e,o.NAME,"");let l=null;switch(s){case x.Action:break;case x.SlotDisplay:case x.SlotZIndex:case x.BoneAlpha:case x.SlotAlpha:case x.AnimationProgress:case x.AnimationWeight:if(s===x.SlotDisplay?(this._frameValueType=0,this._frameValueScale=1):(this._frameValueType=1,s===x.SlotZIndex?this._frameValueScale=1:s===x.AnimationProgress||s===x.AnimationWeight?this._frameValueScale=1e4:this._frameValueScale=100),s===x.BoneAlpha||s===x.SlotAlpha||s===x.AnimationWeight?this._frameDefaultValue=1:this._frameDefaultValue=0,s===x.AnimationProgress&&t.blendType!==_t.None){l=b.borrowObject(ce);const h=l;h.x=D._getNumber(e,o.X,0),h.y=D._getNumber(e,o.Y,0)}l=this._parseTimeline(e,null,o.FRAME,s,this._frameValueType,1,this._parseSingleValueFrame,l);break;case x.BoneTranslate:case x.BoneRotate:case x.BoneScale:case x.IKConstraint:case x.AnimationParameter:s===x.IKConstraint||s===x.AnimationParameter?(this._frameValueType=1,s===x.AnimationParameter?this._frameValueScale=1e4:this._frameValueScale=100):(s===x.BoneRotate?this._frameValueScale=R.DEG_RAD:this._frameValueScale=1,this._frameValueType=2),s===x.BoneScale||s===x.IKConstraint?this._frameDefaultValue=1:this._frameDefaultValue=0,l=this._parseTimeline(e,null,o.FRAME,s,this._frameValueType,2,this._parseDoubleValueFrame);break;case x.ZOrder:break;case x.Surface:{const h=this._armature.getBone(n);if(h===null)continue;this._geometry=h.geometry,l=this._parseTimeline(e,null,o.FRAME,s,2,0,this._parseDeformFrame),this._geometry=null;break}case x.SlotDeform:{this._geometry=null;for(const h in this._armature.skins){const _=this._armature.skins[h];for(const m in _.displays){const c=_.displays[m];for(const u of c)if(u!==null&&u.name===n){this._geometry=u.geometry;break}}}if(this._geometry===null)continue;l=this._parseTimeline(e,null,o.FRAME,s,2,0,this._parseDeformFrame),this._geometry=null;break}case x.SlotColor:l=this._parseTimeline(e,null,o.FRAME,s,1,1,this._parseSlotColorFrame);break}if(l!==null)switch(s){case x.Action:break;case x.ZOrder:break;case x.BoneTranslate:case x.BoneRotate:case x.BoneScale:case x.Surface:case x.BoneAlpha:this._animation.addBoneTimeline(n,l);break;case x.SlotDisplay:case x.SlotColor:case x.SlotDeform:case x.SlotZIndex:case x.SlotAlpha:this._animation.addSlotTimeline(n,l);break;case x.IKConstraint:this._animation.addConstraintTimeline(n,l);break;case x.AnimationProgress:case x.AnimationWeight:case x.AnimationParameter:this._animation.addAnimationTimeline(n,l);break}}}return this._animation=null,t}_parseTimeline(a,t,i,e,s,n,l,h=null){if(a!==null&&i.length>0&&i in a&&(t=a[i]),t===null)return null;const _=t.length;if(_===0)return null;const m=this._frameIntArray.length,c=this._frameFloatArray.length,u=this._timelineArray.length;switch(h===null&&(h=b.borrowObject(Wt)),h.type=e,h.offset=u,this._frameValueType=s,this._timeline=h,this._timelineArray.length+=1+1+1+1+1+_,a!==null?(this._timelineArray[u+w.TimelineScale]=Math.round(D._getNumber(a,o.SCALE,1)*100),this._timelineArray[u+w.TimelineOffset]=Math.round(D._getNumber(a,o.OFFSET,0)*100)):(this._timelineArray[u+w.TimelineScale]=100,this._timelineArray[u+w.TimelineOffset]=0),this._timelineArray[u+w.TimelineKeyFrameCount]=_,this._timelineArray[u+w.TimelineFrameValueCount]=n,this._frameValueType){case 0:this._timelineArray[u+w.TimelineFrameValueOffset]=0;break;case 1:this._timelineArray[u+w.TimelineFrameValueOffset]=m-this._animation.frameIntOffset;break;case 2:this._timelineArray[u+w.TimelineFrameValueOffset]=c-this._animation.frameFloatOffset;break}if(_===1)h.frameIndicesOffset=-1,this._timelineArray[u+w.TimelineFrameOffset+0]=l.call(this,t[0],0,0)-this._animation.frameOffset;else{const f=this._animation.frameCount+1,T=this._data.frameIndices,g=T.length;T.length+=f,h.frameIndicesOffset=g;for(let y=0,d=0,p=0,A=0;y0)if(o.CURVE in a){const s=i+1;this._helpArray.length=s;const n=this._samplingEasingCurve(a[o.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length,this._frameArray[e+w.FrameTweenType]=q.Curve,this._frameArray[e+w.FrameTweenEasingOrCurveSampleCount]=n?s:-s;for(let l=0;l0){const n=this._armature.sortedSlots.length,l=new Array(n-s.length/2),h=new Array(n);for(let u=0;u0?e>=this._prevRotation:e<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),e=this._prevRotation+e-this._prevRotation+R.PI_D*this._prevClockwise)),this._prevClockwise=D._getNumber(a,o.TWEEN_ROTATE,0),this._prevRotation=e;const s=this._parseTweenFrame(a,t,i);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[n++]=this._helpTransform.x,this._frameFloatArray[n++]=this._helpTransform.y,this._frameFloatArray[n++]=e,this._frameFloatArray[n++]=this._helpTransform.skew,this._frameFloatArray[n++]=this._helpTransform.scaleX,this._frameFloatArray[n++]=this._helpTransform.scaleY,this._parseActionDataInFrame(a,t,this._bone,this._slot),s}_parseBoneTranslateFrame(a,t,i){const e=this._parseTweenFrame(a,t,i);let s=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[s++]=D._getNumber(a,o.X,0),this._frameFloatArray[s++]=D._getNumber(a,o.Y,0),e}_parseBoneRotateFrame(a,t,i){let e=D._getNumber(a,o.ROTATE,0)*R.DEG_RAD;t!==0&&(this._prevClockwise===0?e=this._prevRotation+R.normalizeRadian(e-this._prevRotation):((this._prevClockwise>0?e>=this._prevRotation:e<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),e=this._prevRotation+e-this._prevRotation+R.PI_D*this._prevClockwise)),this._prevClockwise=D._getNumber(a,o.CLOCK_WISE,0),this._prevRotation=e;const s=this._parseTweenFrame(a,t,i);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[n++]=e,this._frameFloatArray[n++]=D._getNumber(a,o.SKEW,0)*R.DEG_RAD,s}_parseBoneScaleFrame(a,t,i){const e=this._parseTweenFrame(a,t,i);let s=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[s++]=D._getNumber(a,o.X,1),this._frameFloatArray[s++]=D._getNumber(a,o.Y,1),e}_parseSlotDisplayFrame(a,t,i){const e=this._parseFrame(a,t,i);return this._frameArray.length+=1,o.VALUE in a?this._frameArray[e+1]=D._getNumber(a,o.VALUE,0):this._frameArray[e+1]=D._getNumber(a,o.DISPLAY_INDEX,0),this._parseActionDataInFrame(a,t,this._slot.parent,this._slot),e}_parseSlotColorFrame(a,t,i){const e=this._parseTweenFrame(a,t,i);let s=-1;if(o.VALUE in a||o.COLOR in a){const l=o.VALUE in a?a[o.VALUE]:a[o.COLOR];for(let h in l){this._parseColorTransform(l,this._helpColorTransform),s=this._colorArray.length,this._colorArray.length+=8,this._colorArray[s++]=Math.round(this._helpColorTransform.alphaMultiplier*100),this._colorArray[s++]=Math.round(this._helpColorTransform.redMultiplier*100),this._colorArray[s++]=Math.round(this._helpColorTransform.greenMultiplier*100),this._colorArray[s++]=Math.round(this._helpColorTransform.blueMultiplier*100),this._colorArray[s++]=Math.round(this._helpColorTransform.alphaOffset),this._colorArray[s++]=Math.round(this._helpColorTransform.redOffset),this._colorArray[s++]=Math.round(this._helpColorTransform.greenOffset),this._colorArray[s++]=Math.round(this._helpColorTransform.blueOffset),s-=8;break}}s<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=s=this._colorArray.length,this._colorArray.length+=8,this._colorArray[s++]=100,this._colorArray[s++]=100,this._colorArray[s++]=100,this._colorArray[s++]=100,this._colorArray[s++]=0,this._colorArray[s++]=0,this._colorArray[s++]=0,this._colorArray[s++]=0),s=this._defaultColorOffset);const n=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[n]=s,e}_parseSlotDeformFrame(a,t,i){const e=this._frameFloatArray.length,s=this._parseTweenFrame(a,t,i),n=o.VERTICES in a?a[o.VERTICES]:null,l=D._getNumber(a,o.OFFSET,0),h=this._intArray[this._mesh.geometry.offset+w.GeometryVertexCount];if(this._mesh.parent===null)throw new Error("this._mesh.parent is null.");const _=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,m=this._mesh.geometry.weight;let c=0,u=0,f=0,T=0;if(m!==null){const g=this._weightSlotPose[_];this._helpMatrixA.copyFromArray(g,0),this._frameFloatArray.length+=m.count*2,f=m.offset+w.WeigthBoneIndices+m.bones.length}else this._frameFloatArray.length+=h*2;for(let g=0;g=n.length?c=0:c=n[g-l],g+1=n.length?u=0:u=n[g+1-l]),m!==null){const y=this._weightBonePoses[_],d=this._intArray[f++];this._helpMatrixA.transformPoint(c,u,this._helpPoint,!0),c=this._helpPoint.x,u=this._helpPoint.y;for(let p=0;p=n.length?m=0:m=n[u-l],u+1=n.length?c=0:c=n[u+1-l]):(m=0,c=0),this._frameFloatArray[e+u]=m,this._frameFloatArray[e+u+1]=c}if(t===0){const u=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1,this._frameIntArray[u+w.DeformVertexOffset]=this._geometry.offset,this._frameIntArray[u+w.DeformCount]=this._frameFloatArray.length-e,this._frameIntArray[u+w.DeformValueCount]=this._frameFloatArray.length-e,this._frameIntArray[u+w.DeformValueOffset]=0,this._frameIntArray[u+w.DeformFloatOffset]=e-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+w.TimelineFrameValueCount]=u-this._animation.frameIntOffset}return s}_parseTransform(a,t,i){t.x=D._getNumber(a,o.X,0)*i,t.y=D._getNumber(a,o.Y,0)*i,o.ROTATE in a||o.SKEW in a?(t.rotation=R.normalizeRadian(D._getNumber(a,o.ROTATE,0)*R.DEG_RAD),t.skew=R.normalizeRadian(D._getNumber(a,o.SKEW,0)*R.DEG_RAD)):(o.SKEW_X in a||o.SKEW_Y in a)&&(t.rotation=R.normalizeRadian(D._getNumber(a,o.SKEW_Y,0)*R.DEG_RAD),t.skew=R.normalizeRadian(D._getNumber(a,o.SKEW_X,0)*R.DEG_RAD)-t.rotation),t.scaleX=D._getNumber(a,o.SCALE_X,1),t.scaleY=D._getNumber(a,o.SCALE_Y,1)}_parseColorTransform(a,t){t.alphaMultiplier=D._getNumber(a,o.ALPHA_MULTIPLIER,100)*.01,t.redMultiplier=D._getNumber(a,o.RED_MULTIPLIER,100)*.01,t.greenMultiplier=D._getNumber(a,o.GREEN_MULTIPLIER,100)*.01,t.blueMultiplier=D._getNumber(a,o.BLUE_MULTIPLIER,100)*.01,t.alphaOffset=D._getNumber(a,o.ALPHA_OFFSET,0),t.redOffset=D._getNumber(a,o.RED_OFFSET,0),t.greenOffset=D._getNumber(a,o.GREEN_OFFSET,0),t.blueOffset=D._getNumber(a,o.BLUE_OFFSET,0)}_parseGeometry(a,t){const i=a[o.VERTICES],e=Math.floor(i.length/2);let s=0;const n=this._intArray.length,l=this._floatArray.length;t.offset=n,t.data=this._data,this._intArray.length+=1+1+1+1,this._intArray[n+w.GeometryVertexCount]=e,this._intArray[n+w.GeometryFloatOffset]=l,this._intArray[n+w.GeometryWeightOffset]=-1,this._floatArray.length+=e*2;for(let h=0,_=e*2;h<_;++h)this._floatArray[l+h]=i[h];if(o.TRIANGLES in a){const h=a[o.TRIANGLES];s=Math.floor(h.length/3),this._intArray.length+=s*3;for(let _=0,m=s*3;_=0||o.DATA_VERSIONS.indexOf(e)>=0){const s=b.borrowObject(Ze);if(s.version=i,s.name=D._getString(a,o.NAME,""),s.frameRate=D._getNumber(a,o.FRAME_RATE,24),s.frameRate===0&&(s.frameRate=24),o.ARMATURE in a){this._data=s,this._parseArray(a);const n=a[o.ARMATURE];for(const l of n)s.addArmature(this._parseArmature(l,t));this._data.binary||this._modifyArray(),o.STAGE in a?s.stage=s.getArmature(D._getString(a,o.STAGE,"")):s.armatureNames.length>0&&(s.stage=s.getArmature(s.armatureNames[0])),this._data=null}return o.TEXTURE_ATLAS in a&&(this._rawTextureAtlases=a[o.TEXTURE_ATLAS]),s}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(a,t,i=1){if(console.assert(a!==void 0),a===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0)return!1;const e=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(e,t,i),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(t.width=D._getNumber(a,o.WIDTH,0),t.height=D._getNumber(a,o.HEIGHT,0),t.scale=i===1?1/D._getNumber(a,o.SCALE,1):i,t.name=D._getString(a,o.NAME,""),t.imagePath=D._getString(a,o.IMAGE_PATH,""),o.SUB_TEXTURE in a){const e=a[o.SUB_TEXTURE];for(let s=0,n=e.length;s0&&_>0&&(m.frame=Yt.createRectangle(),m.frame.x=D._getNumber(l,o.FRAME_X,0),m.frame.y=D._getNumber(l,o.FRAME_Y,0),m.frame.width=h,m.frame.height=_),t.addTexture(m)}}return!0}static getInstance(){return D._objectDataParserInstance===null&&(D._objectDataParserInstance=new D),D._objectDataParserInstance}};let ot=D;r(ot,"_objectDataParserInstance",null);class $t{constructor(){r(this,"frameStart",0),r(this,"actions",[])}}const Nt=class extends ot{constructor(){super(...arguments),r(this,"_binaryOffset"),r(this,"_binary"),r(this,"_intArrayBuffer"),r(this,"_frameArrayBuffer"),r(this,"_timelineArrayBuffer")}_inRange(a,t,i){return t<=a&&a<=i}_decodeUTF8(a){let t=0,i="",e,s=0,n=0,l=0,h=0;for(;a.length>t;){let _=a[t++];if(_===-1)n!==0?e=65533:e=-1;else if(n===0)this._inRange(_,0,127)?e=_:(this._inRange(_,194,223)?(n=1,h=128,s=_-192):this._inRange(_,224,239)?(n=2,h=2048,s=_-224):this._inRange(_,240,244)&&(n=3,h=65536,s=_-240),s=s*Math.pow(64,n),e=null);else if(!this._inRange(_,128,191))s=0,n=0,l=0,h=0,t--,e=_;else if(l+=1,s=s+(_-128)*Math.pow(64,n-l),l!==n)e=null;else{let m=s,c=h;s=0,n=0,l=0,h=0,this._inRange(m,c,1114111)&&!this._inRange(m,55296,57343)?e=m:e=_}e!==null&&e!==-1&&(e<=65535?e>0&&(i+=String.fromCharCode(e)):(e-=65536,i+=String.fromCharCode(55296+(e>>10&1023)),i+=String.fromCharCode(56320+(e&1023))))}return i}_parseBinaryTimeline(a,t,i=null){const e=i!==null?i:b.borrowObject(Wt);if(e.type=a,e.offset=t,this._timeline=e,this._timelineArrayBuffer===void 0)throw new Error("this._timelineArrayBuffer is undefined.");if(this._frameArrayBuffer===void 0)throw new Error("this._frameArrayBuffer is undefined.");const s=this._timelineArrayBuffer[e.offset+w.TimelineKeyFrameCount];if(s===1)e.frameIndicesOffset=-1;else{let n=0;const l=this._animation.frameCount+1,h=this._data.frameIndices;n=h.length,h.length+=l,e.frameIndicesOffset=n;for(let _=0,m=0,c=0,u=0;_=0){const l=ot._getNumber(s,o.TYPE,x.Action),h=ot._getString(s,o.NAME,"");let _=null;if(l===x.AnimationProgress&&t.blendType!==_t.None){_=b.borrowObject(ce);const m=_;m.x=ot._getNumber(s,o.X,0),m.y=ot._getNumber(s,o.Y,0)}switch(_=this._parseBinaryTimeline(l,n,_),l){case x.Action:break;case x.ZOrder:break;case x.BoneTranslate:case x.BoneRotate:case x.BoneScale:case x.Surface:case x.BoneAlpha:this._animation.addBoneTimeline(h,_);break;case x.SlotDisplay:case x.SlotColor:case x.SlotDeform:case x.SlotZIndex:case x.SlotAlpha:this._animation.addSlotTimeline(h,_);break;case x.IKConstraint:this._animation.addConstraintTimeline(h,_);break;case x.AnimationProgress:case x.AnimationWeight:case x.AnimationParameter:this._animation.addAnimationTimeline(h,_);break}}}}return this._animation=null,t}_parseGeometry(a,t){if(t.offset=a[o.OFFSET],t.data=this._data,this._intArrayBuffer===void 0)throw new Error("this._intArrayBuffer is undefined.");let i=this._intArrayBuffer[t.offset+w.GeometryWeightOffset];if(i<-1&&(i+=65536),i>=0){const e=b.borrowObject(pe),s=this._intArrayBuffer[t.offset+w.GeometryVertexCount],n=this._intArrayBuffer[i+w.WeigthBoneCount];e.offset=i;for(let _=0;_12?t[13]:0,m=new Int16Array(this._binary,this._binaryOffset+t[0],i/Int16Array.BYTES_PER_ELEMENT),c=new Float32Array(this._binary,this._binaryOffset+t[2],e/Float32Array.BYTES_PER_ELEMENT),u=new Int16Array(this._binary,this._binaryOffset+t[4],s/Int16Array.BYTES_PER_ELEMENT),f=new Float32Array(this._binary,this._binaryOffset+t[6],n/Float32Array.BYTES_PER_ELEMENT),T=new Int16Array(this._binary,this._binaryOffset+t[8],l/Int16Array.BYTES_PER_ELEMENT),g=new Uint16Array(this._binary,this._binaryOffset+t[10],h/Uint16Array.BYTES_PER_ELEMENT),y=_>0?new Int16Array(this._binary,this._binaryOffset+t[12],_/Uint16Array.BYTES_PER_ELEMENT):m;this._data.binary=this._binary,this._data.intArray=this._intArrayBuffer=m,this._data.floatArray=c,this._data.frameIntArray=u,this._data.frameFloatArray=f,this._data.frameArray=this._frameArrayBuffer=T,this._data.timelineArray=this._timelineArrayBuffer=g,this._data.colorArray=y}parseDragonBonesData(a,t=1){console.assert(a!=null&&a instanceof ArrayBuffer,"Data error.");const i=new Uint8Array(a,0,8);if(i[0]!=="D".charCodeAt(0)||i[1]!=="B".charCodeAt(0)||i[2]!=="D".charCodeAt(0)||i[3]!=="T".charCodeAt(0))return console.assert(!1,"Nonsupport data."),null;const e=new Uint32Array(a,8,1)[0],s=new Uint8Array(a,8+4,e),n=this._decodeUTF8(s),l=JSON.parse(n);return this._binaryOffset=8+4+e,this._binary=a,super.parseDragonBonesData(l,t)}static getInstance(){return Nt._binaryDataParserInstance===null&&(Nt._binaryDataParserInstance=new Nt),Nt._binaryDataParserInstance}};let De=Nt;r(De,"_binaryDataParserInstance",null);const xt=class{constructor(a=null){r(this,"autoSearch",!1),r(this,"_dragonBonesDataMap",{}),r(this,"_textureAtlasDataMap",{}),r(this,"_dragonBones",null),r(this,"_dataParser",null),xt._objectParser===null&&(xt._objectParser=new ot),xt._binaryParser===null&&(xt._binaryParser=new De),this._dataParser=a!==null?a:xt._objectParser}_isSupportMesh(){return!0}_getTextureData(a,t){if(a in this._textureAtlasDataMap)for(const i of this._textureAtlasDataMap[a]){const e=i.getTexture(t);if(e!==null)return e}if(this.autoSearch){for(let i in this._textureAtlasDataMap)for(const e of this._textureAtlasDataMap[i])if(e.autoSearch){const s=e.getTexture(t);if(s!==null)return s}}return null}_fillBuildArmaturePackage(a,t,i,e,s){let n=null,l=null;if(t.length>0&&t in this._dragonBonesDataMap&&(n=this._dragonBonesDataMap[t],l=n.getArmature(i)),l===null&&(t.length===0||this.autoSearch)){for(let h in this._dragonBonesDataMap)if(n=this._dragonBonesDataMap[h],(t.length===0||n.autoSearch)&&(l=n.getArmature(i),l!==null)){t=h;break}}if(l!==null){if(a.dataName=t,a.textureAtlasName=s,a.data=n,a.armature=l,a.skin=null,e.length>0&&(a.skin=l.getSkin(e),a.skin===null&&this.autoSearch))for(let h in this._dragonBonesDataMap){const _=this._dragonBonesDataMap[h].getArmature(e);if(_!==null){a.skin=_.defaultSkin;break}}return a.skin===null&&(a.skin=l.defaultSkin),!0}return!1}_buildBones(a,t){if(a.armature===null)throw new Error("dataPackage.armature is null.");for(const i of a.armature.sortedBones)b.borrowObject(i.type===et.Bone?ue:lt).init(i,t)}_buildSlots(a,t){if(a.armature===null)throw new Error("dataPackage.armature is null.");const i=a.skin,e=a.armature.defaultSkin;if(i===null||e===null)return;const s={};for(let n in e.displays){const l=e.getDisplays(n);s[n]=l}if(i!==e)for(let n in i.displays){const l=i.getDisplays(n);s[n]=l}for(const n of a.armature.sortedSlots){const l=n.name in s?s[n.name]:null,h=this._buildSlot(a,n,t);if(l!==null){h.displayFrameCount=l.length;for(let _=0,m=h.displayFrameCount;_0){const f=this._getTextureData(a.textureAtlasName,c.path);h.replaceTextureData(f,_)}const u=this._getSlotDisplay(a,c,h);h.replaceDisplay(u,_)}else h.replaceDisplay(null)}}h._setDisplayIndex(n.displayIndex,!0)}}_buildConstraints(a,t){if(a.armature===null)throw new Error("dataPackage.armature is null.");const i=a.armature.constraints;for(let e in i){const s=i[e];switch(s.type){case wt.IK:const n=b.borrowObject(me);n.init(s,t),t._addConstraint(n);break;case wt.Path:const l=b.borrowObject(Le);l.init(s,t),t._addConstraint(l);break;default:const h=b.borrowObject(me);h.init(s,t),t._addConstraint(h);break}}}_buildChildArmature(a,t,i){return this.buildArmature(i.path,a!==null?a.dataName:"","",a!==null?a.textureAtlasName:"")}_getSlotDisplay(a,t,i){if(t.parent===null)throw new Error("displayData.parent is null.");if(t.parent.parent===null)throw new Error("displayData.parent.parent is null.");if(t.parent.parent.parent===null)throw new Error("displayData.parent.parent.parent is null.");const e=a!==null?a.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(e,t.path)),s=i.rawDisplay;break}case L.Mesh:{const n=t;n.texture===null&&(n.texture=this._getTextureData(e,n.path)),this._isSupportMesh()?s=i.meshDisplay:s=i.rawDisplay;break}case L.Armature:{const n=t,l=this._buildChildArmature(a,i,n);if(l!==null){if(l.inheritAnimation=n.inheritAnimation,!l.inheritAnimation){const h=n.actions.length>0?n.actions:l.armatureData.defaultActions;if(h.length>0)for(const _ of h){const m=b.borrowObject(Y);Y.actionDataToInstance(_,m,i.armature),m.slot=i,i.armature._bufferAction(m,!1)}else l.animation.play()}n.armature=l.armatureData}s=l;break}case L.BoundingBox:break}return s}parseDragonBonesData(a,t=null,i=1){const e=a instanceof ArrayBuffer?xt._binaryParser:this._dataParser;if(e===null)throw new Error("dataParser is null.");const s=e.parseDragonBonesData(a,i);for(;;){const n=this._buildTextureAtlasData(null,null);if(e.parseTextureAtlasData(null,n,i))this.addTextureAtlasData(n,t);else{n.returnToPool();break}}return s!==null&&this.addDragonBonesData(s,t),s}parseTextureAtlasData(a,t,i=null,e=1){const s=this._buildTextureAtlasData(null,null);if(this._dataParser===null)throw new Error(" this._dataParser is null.");return this._dataParser.parseTextureAtlasData(a,s,e),this._buildTextureAtlasData(s,t||null),this.addTextureAtlasData(s,i),s}updateTextureAtlases(a,t){const i=this.getTextureAtlasData(t);if(i!==null)for(let e=0,s=i.length;e=0)continue;let h=t.getDisplays(l.name);if(h===null&&(n!==null&&t!==n&&(h=n.getDisplays(l.name)),h===null)){i&&(l.displayFrameCount=0);continue}l.displayFrameCount=h.length;for(let _=0,m=l.displayFrameCount;_0?s.width:n.image.width,h=s.height>0?s.height:n.image.height,_=i.region.x,m=i.region.y,c=i.region.width,u=i.region.height;if(this._geometryData===null){if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");const N=s.scale*this._armature._armatureData.scale,k=Xt.RAW_UVS,V=Xt.RAW_INDICES,v=[],P=[];for(let B=0;B<4;++B){const H=B*2,W=new X.Vector2(k[H],k[H+1]),J=new X.Vector3(W.x*c*N-this._pivotX,W.y*u*N-this._pivotY,0);if(v.push(J),P.push(W),i.rotated){W.set((_+(1-W.y)*c)/l,(m+W.x*u)/h);continue}W.set((_+W.x*c)/l,1-(m+W.y*u)/h)}const U=[];for(let B=0;B<2;++B){const H=B*3;U.push(V[H],V[H+1],V[H+2])}const z=v.map(B=>B.toArray()).flat(),j=P.map(B=>B.toArray()).flat();e.geometry.setAttribute("position",new X.BufferAttribute(new Float32Array(z),3)),e.geometry.setAttribute("uv",new X.BufferAttribute(new Float32Array(j),2)),e.geometry.setIndex(U),e.geometry.attributes.position.needsUpdate=!0,e.geometry.attributes.uv.needsUpdate=!0,e.geometry.computeBoundingBox(),this._material!==null&&this._material.copy(s.material),e.material=s.material,this._visibleDirty=!0;return}const f=this._geometryData.data;if(f===null)throw new Error("data is null.");const T=f.intArray,g=f.floatArray;if(T===null)throw new Error("intArray is null.");if(g===null)throw new Error("floatArray is null.");const y=T[this._geometryData.offset+w.GeometryVertexCount],d=T[this._geometryData.offset+w.GeometryTriangleCount];let p=T[this._geometryData.offset+w.GeometryFloatOffset];p<0&&(p+=65536);const A=p+y*2,S=this._geometryData.offset+w.GeometryVertexIndices;if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");const E=this._armature._armatureData.scale,I=[],O=[];for(let N=0,k=y;NN.toArray()).flat(),F=O.map(N=>N.toArray()).flat();e.geometry.setAttribute("position",new X.BufferAttribute(new Float32Array(M),3)),e.geometry.setAttribute("uv",new X.BufferAttribute(new Float32Array(F),2)),e.geometry.setIndex(C),e.geometry.attributes.position.needsUpdate=!0,e.geometry.attributes.uv.needsUpdate=!0,e.geometry.computeBoundingBox(),this._material!==null&&this._material.copy(s.material),e.material=s.material,this._visibleDirty=!0}_updateMesh(){if(this._armature===null)throw new Error("this._armature is null.");if(this._armature._armatureData===null)throw new Error("this._armature._armatureData is null.");const i=this._armature._armatureData.scale,e=this._displayFrame.deformVertices,s=this._geometryBones,n=this._geometryData,l=n.weight,h=e.length>0&&n.inheritDeform,_=this._renderDisplay;if(l!==null){const d=n.data;if(d===null)throw new Error("data is null.");const p=d.intArray,A=d.floatArray;if(p===null)throw new Error("intArray is null.");if(A===null)throw new Error("floatArray is null.");const S=p[n.offset+w.GeometryVertexCount];let E=p[l.offset+w.WeigthFloatOffset];E<0&&(E+=65536);const I=Array.from(_.geometry.getAttribute("position").array);let O=l.offset+w.WeigthBoneIndices+s.length,C=E,M=0;for(let F=0;F