"use strict";const t=Math.pow,e=Math.sqrt,i=Math.sin,n=Math.cos,s=Math.PI,r=1.70158,o=1.525*r,a=r+1,c=2*s/3,u=2*s/4.5,_bounceOut=function(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},d={linear:t=>t,easeInQuad:function(t){return t*t},easeOutQuad:function(t){return 1-(1-t)*(1-t)},easeInOutQuad:function(e){return e<.5?2*e*e:1-t(-2*e+2,2)/2},easeInCubic:function(t){return t*t*t},easeOutCubic:function(e){return 1-t(1-e,3)},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-t(-2*e+2,3)/2},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(e){return 1-t(1-e,4)},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-t(-2*e+2,4)/2},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(e){return 1-t(1-e,5)},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-t(-2*e+2,5)/2},easeInSine:function(t){return 1-n(t*s/2)},easeOutSine:function(t){return i(t*s/2)},easeInOutSine:function(t){return-(n(s*t)-1)/2},easeInExpo:function(e){return 0===e?0:t(2,10*e-10)},easeOutExpo:function(e){return 1===e?1:1-t(2,-10*e)},easeInOutExpo:function(e){return 0===e?0:1===e?1:e<.5?t(2,20*e-10)/2:(2-t(2,-20*e+10))/2},easeInCirc:function(i){return 1-e(1-t(i,2))},easeOutCirc:function(i){return e(1-t(i-1,2))},easeInOutCirc:function(i){return i<.5?(1-e(1-t(2*i,2)))/2:(e(1-t(-2*i+2,2))+1)/2},easeInBack:function(t){return a*t*t*t-r*t*t},easeOutBack:function(e){return 1+a*t(e-1,3)+r*t(e-1,2)},easeInOutBack:function(e){return e<.5?t(2*e,2)*(7.189819*e-o)/2:(t(2*e-2,2)*((o+1)*(2*e-2)+o)+2)/2},easeInElastic:function(e){return 0===e?0:1===e?1:-t(2,10*e-10)*i((10*e-10.75)*c)},easeOutElastic:function(e){return 0===e?0:1===e?1:t(2,-10*e)*i((10*e-.75)*c)+1},easeInOutElastic:function(e){return 0===e?0:1===e?1:e<.5?-t(2,20*e-10)*i((20*e-11.125)*u)/2:t(2,-20*e+10)*i((20*e-11.125)*u)/2+1},easeInBounce:function(t){return 1-_bounceOut(1-t)},easeOutBounce:_bounceOut,easeInOutBounce:function(t){return t<.5?(1-_bounceOut(1-2*t))/2:(1+_bounceOut(2*t-1))/2}};class Action{constructor(t,e=1,i=d.linear){if(this.duration=t,this.speed=e,this.timingMode=i,this.log=!1,t<0)throw new RangeError("Action duration must be 0 or more.")}get scaledDuration(){return this.duration/this.speed}setSpeed(t){return this.speed=t,this}setTimingMode(t){return this.timingMode=t,this}linear(){return this.setTimingMode(d.linear)}easeIn(){return this.setTimingMode(Action._defaultTimingModeEaseIn)}easeOut(){return this.setTimingMode(Action._defaultTimingModeEaseOut)}easeInOut(){return this.setTimingMode(Action._defaultTimingModeEaseInOut)}onSetupTicker(t,e){}onTickerDidReset(t){}}Action._defaultTimingModeEaseIn=d.easeInSine,Action._defaultTimingModeEaseOut=d.easeOutSine,Action._defaultTimingModeEaseInOut=d.easeInOutSine;const h=1-1e-10;class ActionTicker{static tickAll(t,e){const i=.001*t;for(const[t,n]of this._tickers.entries()){const[s,r]=_getTargetState(t);if(!(s||r<=0))for(const t of n.values())try{t.tick(i*r)}catch(i){void 0===e?console.error("Action failed with error: ",i):e(i),this._removeActionTicker(t)}}}static runAction(t,e,i){this._tickers.has(e)||this._tickers.set(e,new Map);const n=new ActionTicker(t,e,i);this._tickers.get(e).set(null!=t?t:n,n)}static hasTargetActions(t){return this._tickers.has(t)}static getTargetActionForKey(t,e){var i,n;return null===(n=null===(i=this._tickers.get(t))||void 0===i?void 0:i.get(e))||void 0===n?void 0:n.action}static removeTargetActionForKey(t,e){var i;const n=null===(i=this._tickers.get(t))||void 0===i?void 0:i.get(e);n&&this._removeActionTicker(n)}static removeAllTargetActions(t){this._tickers.delete(t)}static _removeActionTicker(t){var e;const i=this._tickers.get(t.target);void 0!==i&&(i.delete(null!==(e=t.key)&&void 0!==e?e:t),0===i.size&&this._tickers.delete(t.target))}constructor(t,e,i){this.key=t,this.target=e,this.action=i,this.isDone=!1,this.autoComplete=!0,this._elapsed=0,this._isSetup=!1,this.speed=i.speed,this.scaledDuration=i.scaledDuration,this.timingMode=i.timingMode}get timeDistance(){return 0===this.scaledDuration?1:Math.min(1,this._elapsed/this.scaledDuration)}get easedTimeDistance(){return this.timingMode(this.timeDistance)}tick(t){this._isSetup||(this.speed=this.action.speed,this.scaledDuration=this.action.duration,this.timingMode=this.action.timingMode,this.data=this.action.onSetupTicker(this.target,this),this._isSetup=!0);const e=this.target,i=this.action;if(null==e||e.destroyed)return void ActionTicker._removeActionTicker(this);const n=t*this.speed;if(0===this.scaledDuration)return i.onTick(this.target,1,1,this,n),this.isDone=!0,ActionTicker._removeActionTicker(this),t;if(0===t&&this.timeDistance=h?(this.isDone=!0,ActionTicker._removeActionTicker(this),this._elapsed>this.scaledDuration?this._elapsed-this.scaledDuration:0):-1}reset(){this._elapsed=0,this.isDone=!1,this._isSetup=!1,this.action.onTickerDidReset(this)}}function _getTargetState(t){let e=t,i=e.isPaused,n=e.speed;for(;!i&&null!=e.parent;)i=e.parent.isPaused,n*=e.parent.speed,e=e.parent;return[i,n]}ActionTicker._tickers=new Map;class GroupAction extends Action{constructor(t){super(Math.max(...t.map((t=>t.scaledDuration)))),this.actions=t}reversed(){return new GroupAction(this.actions.map((t=>t.reversed()))).setTimingMode(this.timingMode).setSpeed(this.speed)}onSetupTicker(t,e){return e.autoComplete=!1,{childTickers:this.actions.map((e=>new ActionTicker(void 0,t,e)))}}onTick(t,e,i,n,s){const r=n.scaledDuration===1/0?s*this.speed:i*n.scaledDuration;let o=!0;for(const t of n.data.childTickers)t.isDone||(o=!1,t.tick(r));o&&(n.isDone=!0)}onTickerDidReset(t){t.data.childTickers.forEach((t=>t.reset()))}}class RepeatAction extends Action{constructor(t,e){if(super(t.scaledDuration*e),this.action=t,this.repeats=e,!Number.isInteger(e)||e<0)throw new RangeError("The number of repeats must be a positive integer.")}reversed(){return new RepeatAction(this.action.reversed(),this.repeats).setTimingMode(this.timingMode).setSpeed(this.speed)}onSetupTicker(t,e){e.autoComplete=!1;const i=new ActionTicker(void 0,t,this.action);return i.timingMode=t=>e.timingMode(i.timingMode(t)),{childTicker:i,n:0}}onTick(t,e,i,n,s){const r=n.data.childTicker;let o=s*this.speed;if(o=r.tick(o),o>0||0===r.scaledDuration){if(++n.data.n>=this.repeats)return void(n.isDone=!0);r.reset(),o=r.tick(o)}}onTickerDidReset(t){t.data.childTicker.reset(),t.data.n=0}}class RepeatForeverAction extends Action{constructor(t){if(super(1/0),this.action=t,t.scaledDuration<=0)throw new TypeError("The action to be repeated must have a non-instantaneous duration.")}reversed(){return new RepeatForeverAction(this.action.reversed()).setTimingMode(this.timingMode).setSpeed(this.speed)}onSetupTicker(t,e){e.autoComplete=!1;const i=new ActionTicker(void 0,t,this.action);return i.timingMode=t=>e.timingMode(i.timingMode(t)),{childTicker:i}}onTick(t,e,i,n,s){const r=n.data.childTicker;let o=s*n.speed;o=r.tick(o),o>0&&(r.reset(),o=r.tick(o))}onTickerDidReset(t){t.data.childTicker.reset()}}class SequenceAction extends Action{constructor(t){super(t.reduce(((t,e)=>t+e.scaledDuration),0)),this.actions=t}reversed(){return new SequenceAction(this.actions.map((t=>t.reversed())).reverse()).setTimingMode(this.timingMode).setSpeed(this.speed)}onSetupTicker(t,e){return e.autoComplete=!1,{childTickers:this._squashedActions().map((e=>new ActionTicker(void 0,t,e)))}}onTick(t,e,i,n,s){let r=n.scaledDuration===1/0?s*this.speed:i*n.scaledDuration;for(const t of n.data.childTickers)if(!t.isDone&&(r=t.tick(r),r<0))return;n.isDone=!0}onTickerDidReset(t){t.data.childTickers.forEach((t=>t.reset()))}_squashedActions(){const t=[];for(const e of this.actions)e instanceof SequenceAction&&1===e.speed&&e.timingMode===d.linear?t.push(...e._squashedActions()):t.push(e);return t}}class CustomAction extends Action{constructor(t,e){super(t),this.stepFn=e}onTick(t,e,i){this.stepFn(t,e,i)}reversed(){return this}}class RunBlockAction extends Action{constructor(t){super(0),this.block=t}reversed(){return this}onTick(){this.block()}}class DelayAction extends Action{onTick(){}reversed(){return this}}class RemoveFromParentAction extends Action{constructor(){super(0)}reversed(){return this}onTick(t){var e;null===(e=t.parent)||void 0===e||e.removeChild(t)}}class RunOnChildAction extends Action{constructor(t,e){super(0),this.action=t,this.nameOrLabel=e}reversed(){return new RunOnChildAction(this.action.reversed(),this.nameOrLabel).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t){if(void 0===t.children||!Array.isArray(t.children))throw new TypeError("The target did not have children.");let e;if(e="getChildByLabel"in t?t.getChildByLabel(this.nameOrLabel):t.children.find((t=>t.label===this.nameOrLabel||t.name===this.nameOrLabel)),!e)throw new ReferenceError(`The target did not have a child matching '${this.nameOrLabel}'.`);e.run(this.action)}}class SetVisibleAction extends Action{constructor(t){super(0),this.visible=t}reversed(){return new SetVisibleAction(!this.visible).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t){t.visible=this.visible}}const l=Math.PI/2;class FollowPathAction extends Action{constructor(t,e,i,n,s){if(super(e),this.asOffset=i,this.orientToPath=n,this.fixedSpeed=s,this.path=t,this.lastIndex=t.length-1,n||s){const[e,i]=FollowPathAction.getLength(t);this.segmentLengths=i,s&&(this.segmentWeights=i.map((t=>t/(e||1))))}}static getPath(t){return Array.isArray(t)?[...t]:[...t.points]}static getLength(t){let e=0;const i=[];for(let n=0;n0){const t=this.path[0],e=this.path[this.path.length-1],i=e.x+t.x,n=e.y+t.y;return this.path.map((({x:t,y:e})=>({x:t-i,y:e-n}))).reverse()}return[...this.path].reverse()}_getDynamicSpeedProgress(t){const e=Math.max(Math.min(Math.floor(t*this.lastIndex),this.lastIndex-1),0),i=this.lastIndex||1;return[e,(t-e/i)*i]}_getFixedSpeedProgress(t){let e=t,i=0,n=0;for(let t=0;te||t===this.lastIndex-1){n=e/s||1;break}e-=s,i++}return[i,n]}}class MoveByAction extends Action{constructor(t,e,i){super(i),this.x=t,this.y=e}reversed(){return new MoveByAction(-this.x,-this.y,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t,e,i){t.position.x+=this.x*i,t.position.y+=this.y*i}}class MoveToAction extends Action{constructor(t,e,i){super(i),this.x=t,this.y=e}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){return{startX:t.x,startY:t.y}}onTick(t,e,i,n){t.position.set(void 0===this.x?t.position.x:n.data.startX+(this.x-n.data.startX)*e,void 0===this.y?t.position.y:n.data.startY+(this.y-n.data.startY)*e)}}class RotateByAction extends Action{constructor(t,e){super(e),this.rotation=t}reversed(){return new RotateByAction(-this.rotation,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t,e,i){t.rotation+=this.rotation*i}}class RotateToAction extends Action{constructor(t,e){super(e),this.rotation=t}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){return{startRotation:t.rotation}}onTick(t,e,i,n){t.rotation=n.data.startRotation+(this.rotation-n.data.startRotation)*e}}class ScaleByAction extends Action{constructor(t,e,i){super(i),this.x=t,this.y=e}reversed(){return new ScaleByAction(-this.x,-this.y,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}onSetupTicker(t){return{dx:t.scale.x*this.x-t.scale.x,dy:t.scale.y*this.y-t.scale.y}}onTick(t,e,i,n){t.scale.set(t.scale.x+n.data.dx*i,t.scale.y+n.data.dy*i)}}class ScaleToAction extends Action{constructor(t,e,i){super(i),this.x=t,this.y=e}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){return{startX:t.scale.x,startY:t.scale.y}}onTick(t,e,i,n){t.scale.set(void 0===this.x?t.scale.x:n.data.startX+(this.x-n.data.startX)*e,void 0===this.y?t.scale.y:n.data.startY+(this.y-n.data.startY)*e)}}class ScaleToSizeAction extends Action{constructor(t,e,i){super(i),this.width=t,this.height=e}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){if("number"!=typeof t.width||"number"!=typeof t.height)throw new TypeError("The target must have numeric 'width' and 'height'.");return{width:t.width,height:t.height}}onTick(t,e,i,n){t.width=n.data.width+(this.width-n.data.width)*e,t.height=n.data.height+(this.height-n.data.height)*e}}class SpeedByAction extends Action{constructor(t,e){super(e),this._speed=t}reversed(){return new SpeedByAction(-this._speed,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t,e,i){t.speed+=this._speed*i}}class SpeedToAction extends Action{constructor(t,e){super(e),this._speed=t}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){return{startSpeed:t.speed}}onTick(t,e,i,n){t.speed=n.data.startSpeed+(this._speed-n.data.startSpeed)*e}}class FadeByAction extends Action{constructor(t,e){super(e),this.alpha=t}reversed(){return new FadeByAction(-this.alpha,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}onTick(t,e,i){t.alpha+=this.alpha*i}}class FadeAlphaToAction extends Action{constructor(t,e){super(e),this.alpha=t}reversed(){return new DelayAction(this.scaledDuration)}onSetupTicker(t){return{startAlpha:t.alpha}}onTick(t,e,i,n){t.alpha=n.data.startAlpha+(this.alpha-n.data.startAlpha)*e}}class FadeInAction extends FadeAlphaToAction{constructor(t){super(1,t)}reversed(){return new FadeAlphaToAction(0,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}}class FadeOutAction extends FadeAlphaToAction{constructor(t){super(0,t)}reversed(){return new FadeAlphaToAction(1,this.duration).setTimingMode(this.timingMode).setSpeed(this.speed)}}const p=Math.PI/180;class _ extends Action{static get DefaultTimingModeEaseIn(){return Action._defaultTimingModeEaseIn}static set DefaultTimingModeEaseIn(t){Action._defaultTimingModeEaseIn=t}static get DefaultTimingModeEaseOut(){return Action._defaultTimingModeEaseOut}static set DefaultTimingModeEaseOut(t){Action._defaultTimingModeEaseOut=t}static get DefaultTimingModeEaseInOut(){return Action._defaultTimingModeEaseInOut}static set DefaultTimingModeEaseInOut(t){Action._defaultTimingModeEaseInOut=t}static tick(t,e){ActionTicker.tickAll(t,e)}static group(t){return new GroupAction(t)}static sequence(t){return new SequenceAction(t)}static repeat(t,e){return new RepeatAction(t,e)}static repeatForever(t){return new RepeatForeverAction(t)}static waitForDuration(t){return new DelayAction(t)}static waitForDurationWithRange(t,e){return new DelayAction(t+(e*Math.random()-.5*e))}static moveBy(t,e,i){return"number"==typeof t?new MoveByAction(t,e,i):new MoveByAction(t.x,t.y,e)}static moveByX(t,e){return this.moveBy(t,0,e)}static moveByY(t,e){return this.moveBy(0,t,e)}static moveTo(t,e,i){return"number"==typeof t?new MoveToAction(t,e,i):new MoveToAction(t.x,t.y,e)}static moveToX(t,e){return new MoveToAction(t,void 0,e)}static moveToY(t,e){return new MoveToAction(void 0,t,e)}static follow(t,e,i=!0,n=!0,s=!0){const r=FollowPathAction.getPath(t);return new FollowPathAction(r,e,i,n,s)}static followAtSpeed(t,e,i=!0,n=!0){const s=FollowPathAction.getPath(t),r=FollowPathAction.getLength(s);return new FollowPathAction(s,r[0]/e,i,n,!0)}static rotateBy(t,e){return new RotateByAction(t,e)}static rotateByDegrees(t,e){return this.rotateBy(t*p,e)}static rotateTo(t,e){return new RotateToAction(t,e)}static rotateToDegrees(t,e){return this.rotateTo(t*p,e)}static speedBy(t,e){return new SpeedByAction(t,e)}static speedTo(t,e){return new SpeedToAction(t,e)}static scaleBy(t,e,i){return"number"==typeof t?void 0===i?new ScaleByAction(t,t,e):new ScaleByAction(t,e,i):new ScaleByAction(t.x,t.y,e)}static scaleByX(t,e){return this.scaleBy(t,0,e)}static scaleByY(t,e){return this.scaleBy(0,t,e)}static scaleTo(t,e,i){return"number"==typeof t?void 0===i?new ScaleToAction(t,t,e):new ScaleToAction(t,e,i):new ScaleToSizeAction(t.width,t.height,e)}static scaleToX(t,e){return new ScaleToAction(t,void 0,e)}static scaleToY(t,e){return new ScaleToAction(void 0,t,e)}static fadeIn(t){return new FadeInAction(t)}static fadeOut(t){return new FadeOutAction(t)}static fadeAlphaTo(t,e){return new FadeAlphaToAction(t,e)}static fadeAlphaBy(t,e){return new FadeByAction(t,e)}static hide(){return new SetVisibleAction(!1)}static unhide(){return new SetVisibleAction(!0)}static removeFromParent(){return new RemoveFromParentAction}static runOnChild(t,e){return new RunOnChildAction(e,t)}static run(t){return new RunBlockAction(t)}static customAction(t,e){return new CustomAction(t,e)}constructor(){super(-1)}}exports.Action=_,exports.TimingMode=d,exports.registerPixiJSActionsMixin=function registerPixiJSActionsMixin(t){const e=t.prototype;e.speed=1,e.isPaused=!1,e.run=function(t,e){return e?ActionTicker.runAction(void 0,this,_.sequence([t,_.run(e)])):ActionTicker.runAction(void 0,this,t)},e.runWithKey=function(t,e){ActionTicker.runAction(e,this,t)},e.runAsPromise=function(t){return new Promise((e=>this.run(t,(()=>e()))))},e.action=function(t){return ActionTicker.getTargetActionForKey(this,t)},e.hasActions=function(){return ActionTicker.hasTargetActions(this)},e.removeAllActions=function(){ActionTicker.removeAllTargetActions(this)},e.removeAction=function(t){ActionTicker.removeTargetActionForKey(this,t)}}; //# sourceMappingURL=index.cjs.map