UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 25.8 kB
var t,e;t=void 0,e=function(){var t={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const e=Phaser.Scene;var s=function(t){return t instanceof e},i=function(t){return null==t||"object"!=typeof t?null:s(t)?t:t.scene&&s(t.scene)?t.scene:t.parent&&t.parent.scene&&s(t.parent.scene)?t.parent.scene:null};const n=Phaser.Game;var r=function(t){return t instanceof n};const a=Phaser.Utils.Objects.GetValue;class h{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(a(e,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this))}shutdown(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0)}destroy(t){this.shutdown(t)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(t,e){this.destroy(e)}setParent(t){var e;return this.parent=t,this.scene=i(t),this.game=null==(e=t)||"object"!=typeof e?null:r(e)?e:r(e.game)?e.game:s(e)?e.sys.game:s(e.scene)?e.scene.sys.game:void 0,this}}function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(h.prototype,t);var u={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}function n(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function r(t,e,i,r,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var h=new n(i,r||t,a),o=s?s+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],h]:t._events[o].push(h):(t._events[o]=h,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function h(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),h.prototype.eventNames=function(){var t,i,n=[];if(0===this._eventsCount)return n;for(i in t=this._events)e.call(t,i)&&n.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},h.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,a=new Array(r);n<r;n++)a[n]=i[n].fn;return a},h.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},h.prototype.emit=function(t,e,i,n,r,a){var h=s?s+t:t;if(!this._events[h])return!1;var o,u,c=this._events[h],l=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,n),!0;case 5:return c.fn.call(c.context,e,i,n,r),!0;case 6:return c.fn.call(c.context,e,i,n,r,a),!0}for(u=1,o=new Array(l-1);u<l;u++)o[u-1]=arguments[u];c.fn.apply(c.context,o)}else{var p,d=c.length;for(u=0;u<d;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,e);break;case 3:c[u].fn.call(c[u].context,e,i);break;case 4:c[u].fn.call(c[u].context,e,i,n);break;default:if(!o)for(p=1,o=new Array(l-1);p<l;p++)o[p-1]=arguments[p];c[u].fn.apply(c[u].context,o)}}return!0},h.prototype.on=function(t,e,s){return r(this,t,e,s,!1)},h.prototype.once=function(t,e,s){return r(this,t,e,s,!0)},h.prototype.removeListener=function(t,e,i,n){var r=s?s+t:t;if(!this._events[r])return this;if(!e)return a(this,r),this;var h=this._events[r];if(h.fn)h.fn!==e||n&&!h.once||i&&h.context!==i||a(this,r);else{for(var o=0,u=[],c=h.length;o<c;o++)(h[o].fn!==e||n&&!h[o].once||i&&h[o].context!==i)&&u.push(h[o]);u.length?this._events[r]=1===u.length?u[0]:u:a(this,r)}return this},h.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=s,h.EventEmitter=h,t.exports=h}(u);var c=o(u.exports);class l extends c{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var p={setEventEmitter(t,e){return void 0===e&&(e=l),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},d=function(t,e,s){if(!t||"number"==typeof t)return s;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return s;e=e.split(".")}for(var i=e,n=t,r=s,a=0;a<i.length;a++){if(e=i[a],!n.hasOwnProperty(e)){r=s;break}n=r=n[e]}return r};const v=["next","exit","enter"];let m=class{constructor(t){var e=d(t,"states",void 0);e&&this.addStates(e);var s=d(t,"extend",void 0);if(s)for(var i in s)this.hasOwnProperty(i)&&void 0!==this[i]||(this[i]=s[i]);var n=d(t,"eventEmitter",void 0),r=d(t,"EventEmitterClass",void 0);this.setEventEmitter(n,r),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(d(t,"enable",!0)),this.start(d(t,"start",void 0));var e=d(t,"init",void 0);return e&&e.call(this),this}toJSON(){return{curState:this.state,prevState:this.prevState,enable:this.enable,start:this._start}}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}set state(t){if(this.enable&&!this._stateLock&&this._state!==t){if(this._prevState=this._state,this._state=t,this._stateLock=!0,this.emit("statechange",this),null!=this._prevState){var e="exit_"+this._prevState,s=this[e];s&&s.call(this),this.emit(e,this)}if(this._stateLock=!1,null!=this._state){var i="enter_"+this._state,n=this[i];n&&n.call(this),this.emit(i,this)}}}get state(){return this._state}get prevState(){return this._prevState}start(t){return this._start=t,this._prevState=void 0,this._state=t,this}goto(t){return null!=t&&(this.state=t),this}next(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}get stateProperties(){return v}addState(t,e){"string"!=typeof t&&(t=(e=t).name);for(var s=this.stateProperties,i=0,n=s.length;i<n;i++){var r=s[i],a=e[r];a&&(this[`${r}_${t}`]=a)}return this}addStates(t){if(Array.isArray(t))for(var e=0,s=t.length;e<s;e++)this.addState(t[e]);else for(var i in t)this.addState(i,t[i]);return this}runMethod(t,e,s,i,n,r){var a=this[t+"_"+this.state];if(a){var h=arguments.length;switch(h){case 1:return a.call(this);case 2:return a.call(this,e);case 3:return a.call(this,e,s);case 4:return a.call(this,e,s,i);case 5:return a.call(this,e,s,i,n);case 6:return a.call(this,e,s,i,n,r)}for(var o=new Array(h-1),u=1;u<h;u++)o[u-1]=arguments[u];return a.apply(this,o)}}};Object.assign(m.prototype,p);var f=function(t,e,s,i,n){void 0===n&&(n=!1);var r=t._events[e];if(!r)return!1;for(var a=0,h=r.length;a<h;a++){var o=r[a];if(o.fn===s&&o.context===i&&o.once===n)return!0}return!1};const y=["next","exit","enter","update","preupdate","postupdate"];class _ extends m{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=d(t,"scene",void 0),this}get stateProperties(){return y}update(t,e){this.runMethod("update",t,e)}preupdate(t,e){this.runMethod("preupdate",t,e)}postupdate(t,e){this.runMethod("postupdate",t,e)}startUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}stopUpdate(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}startPreUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}stopPreUpdate(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}startPostUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}stopPostUpdate(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}class g extends _{constructor(t,e){super(e),this.parent=t;var s=e.initState||"IDLE";this.start(s)}init(){this.start("IDLE")}next_IDLE(){return"TRANS_OPNE"}next_TRANS_OPNE(){return"OPEN"}enter_TRANS_OPNE(){var t=this.parent;if(t.transitInTime>0){var e=t.runTransitionInCallback();t.delayCall(e,this.next,this)}else this.next()}exit_TRANS_OPNE(){this.parent.removeDelayCall()}next_OPEN(){return"TRANS_CLOSE"}enter_OPEN(){this.parent.onOpen()}exit_OPEN(){this.parent.removeDelayCall()}next_TRANS_CLOSE(){return"CLOSE"}enter_TRANS_CLOSE(){var t=this.parent;if(t.transitOutTime>0){var e=t.runTransitionOutCallback();t.delayCall(e,this.next,this)}else this.next()}exit_TRANS_CLOSE(){this.parent.removeDelayCall()}next_CLOSE(){return"TRANS_OPNE"}enter_CLOSE(){this.parent.onClose()}exit_CLOSE(){}canOpen(){return"IDLE"===this.state||"CLOSE"===this.state}canClose(){return"IDLE"===this.state||"OPEN"===this.state}}var E={delayCall(t,e,s){return this.delayCallTimer=function(t,e,s,n,r){var a=i(t);return a.time.delayedCall(e,(function(){a.game.events.once("poststep",(function(){s.call(n,r)}))}))}(this,t,e,s),this},removeDelayCall(){return this.delayCallTimer&&(this.delayCallTimer.remove(!1),this.delayCallTimer=void 0),this}},O=function(){},T={setTransitInTime(t){return this.transitInTime=t,this},setTransitOutTime(t){return this.transitOutTime=t,this},setTransitInCallback(t){return t||(t=O),this.transitInCallback=t,this},setTransitOutCallback(t){return t||(t=O),this.transitOutCallback=t,this}},w={runTransitionInCallback(){return this.transitInCallback(this.parent,this.transitInTime),this.transitInTime},onOpen(){},requestOpen(t,e){if(!this._state.canOpen())return this;this.openEventData=arguments.length>0?t:this.parent;var s=this.transitInTime;return void 0!==e&&(this.transitInTime=e),this._state.goto("TRANS_OPNE"),this.transitInTime=s,this}},x={runTransitionOutCallback(){return this.transitOutCallback(this.parent,this.transitOutTime),this.transitOutTime},onClose(){this.oneShotMode&&this.parent.destroy()},requestClose(t,e){if(!this._state.canClose)return this;this.closeEventData=arguments.length>0?t:this.parent;var s=this.transitOutTime;return void 0!==e&&(this.transitOutTime=e),this._state.goto("TRANS_CLOSE"),this.transitOutTime=s,this}},C={};Object.assign(C,E,T,w,x);const S=Phaser.Utils.Objects.GetValue;class b extends h{constructor(t,e){super(t,e),this.setTransitInTime(S(e,"duration.in",200)),this.setTransitOutTime(S(e,"duration.out",200)),this.setTransitInCallback(S(e,"transitIn")),this.setTransitOutCallback(S(e,"transitOut")),this.oneShotMode=S(e,"destroy",!1),this.delayCallTimer=void 0,this._state=new g(this,{eventEmitter:!1,initState:S(e,"initState","IDLE")}),this.openEventData=void 0,this.closeEventData=void 0}get state(){return this._state.state}shutdown(t){this.isShutdown||(this.transitInCallback=void 0,this.transitOutCallback=void 0,this.openEventData=void 0,this.closeEventData=void 0,this.removeDelayCall(),super.shutdown(t))}}Object.assign(b.prototype,C);const P=Phaser.Utils.Objects.GetValue;class k extends h{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(P(e,"tickingMode",1))}boot(){2!==this.tickingMode||this.tickingState||this.startTicking()}shutdown(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),super.shutdown(t))}setTickingMode(t){"string"==typeof t&&(t=L[t]),this.tickingMode=t}startTicking(){this.tickingState=!0}stopTicking(){this.tickingState=!1}get isRunning(){return this._isRunning}set isRunning(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}start(){return this.isPaused=!1,this.isRunning=!0,this}pause(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}resume(){return this.isPaused&&(this.isPaused=!1,this.isRunning=!0),this}stop(){return this.isPaused=!1,this.isRunning=!1,this}complete(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}const L={no:0,lazy:1,always:2},R=Phaser.Utils.Objects.GetValue;class D extends k{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=R(e,"tickEventName",s),this.isSceneTicker=!N(this.tickEventName)}startTicking(){super.startTicking(),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this)}stopTicking(){super.stopTicking(),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this)}}var N=function(t){return"step"===t||"poststep"===t};const j=Phaser.Utils.Objects.GetValue,I=Phaser.Math.Clamp;class A{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=j(t,"state",M),this.timeScale=j(t,"timeScale",1),this.delay=j(t,"delay",0),this.repeat=j(t,"repeat",0),this.repeatCounter=j(t,"repeatCounter",0),this.repeatDelay=j(t,"repeatDelay",0),this.duration=j(t,"duration",0),this.nowTime=j(t,"nowTime",0),this.justRestart=j(t,"justRestart",!1)}toJSON(){return{state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}destroy(){}setTimeScale(t){return this.timeScale=t,this}setDelay(t){return void 0===t&&(t=0),this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatInfinity(){return this.repeat=-1,this}setRepeatDelay(t){return this.repeatDelay=t,this}start(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?Y:X,this.repeatCounter=0,this}stop(){return this.state=M,this}update(t,e){this.state!==M&&this.state!==F&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=U)):(this.nowTime=this.duration,this.state=F):this.nowTime>=0&&(this.state=Y))}get t(){var t;switch(this.state){case M:case X:case U:t=0;break;case Y:t=this.nowTime/this.duration;break;case F:t=1}return I(t,0,1)}set t(t){(t=I(t,-1,1))<0?(this.state=X,this.nowTime=-this.delay*t):(this.state=Y,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===M}get isDelay(){return this.state===X}get isCountDown(){return this.state===Y}get isRunning(){return this.state===X||this.state===Y}get isDone(){return this.state===F}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const M=0,X=1,Y=2,U=3,F=-1;class G extends D{constructor(t,e){super(t,e),this.timer=new A}shutdown(t){this.isShutdown||(super.shutdown(t),this.timer.destroy(),this.timer=void 0)}start(){return this.timer.start(),super.start(),this}stop(){return this.timer.stop(),super.stop(),this}complete(){return this.timer.stop(),super.complete(),this}}const J=Phaser.Utils.Objects.GetValue,V=Phaser.Utils.Objects.GetAdvancedValue,B=Phaser.Tweens.Builders.GetEaseFunction;class q extends G{resetFromJSON(t){return this.timer.resetFromJSON(J(t,"timer")),this.setEnable(J(t,"enable",!0)),this.setTarget(J(t,"target",this.parent)),this.setDelay(V(t,"delay",0)),this.setDuration(V(t,"duration",1e3)),this.setEase(J(t,"ease","Linear")),this.setRepeat(J(t,"repeat",0)),this}setEnable(t){return null==t&&(t=!0),this.enable=t,this}setTarget(t){return void 0===t&&(t=this.parent),this.target=t,this}setDelay(t){return this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=B(t),this}start(){return this.timer.isRunning||super.start(),this}restart(){return this.timer.stop(),this.start.apply(this,arguments),this}stop(t){return void 0===t&&(t=!1),super.stop(),t&&(this.timer.setT(1),this.updateTarget(this.target,this.timer),this.complete()),this}update(t,e){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var s=this.target,i=this.timer;return i.update(t,e),i.isDelay||this.updateTarget(s,i),this.emit("update",s,this),i.isDone&&this.complete(),this}updateTarget(t,e){}}const z=Phaser.Utils.Objects.GetValue,H=Phaser.Utils.Objects.GetAdvancedValue,W=Phaser.Math.Linear;class $ extends q{constructor(t,e){super(t,e),this.scaleStart={},this.scaleEnd={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(z(t,"mode",0)),this.setScaleRange(H(t,"start",void 0),H(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=K[t]),this.mode=t,this}setScaleRange(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=H(t,"x",this.parent.scaleX),this.startY=H(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=H(e,"x",void 0),this.endY=H(e,"y",void 0)),this.hasScaleX=void 0!==this.startX&&void 0!==this.endX,this.hasScaleY=void 0!==this.startY&&void 0!==this.endY,this}start(){if(this.timer.isRunning)return this;var t=this.parent;this.hasScaleX&&(t.scaleX=this.startX),this.hasScaleY&&(t.scaleY=this.startY);var e=this.repeat;return 2===this.mode&&-1!==e&&(e=2*(e+1)-1),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(e),super.start(),this}updateTarget(t,e){var s=e.t;e.isOddIteration&&(s=1-s),s=this.easeFn(s),this.hasScaleX&&(t.scaleX=W(this.startX,this.endX,s)),this.hasScaleY&&(t.scaleY=W(this.startY,this.endY,s))}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}}const K={stop:0,destroy:1,yoyo:2};var Q=function(t,e){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return!0;if(-1!==e.indexOf(".")){for(var s=e.split("."),i=t,n=0;n<s.length;n++){if(!i.hasOwnProperty(s[n]))return!1;i=i[s[n]]}return!0}return!1}return!1};const Z=Phaser.Cameras.Scene2D.BaseCamera,tt=Phaser.Geom.Rectangle;var et=function(t,e,s){return e instanceof Z||(s=e,e=void 0),void 0===s?s=new tt:!0===s&&(s=st),e?t.scale.getViewPort(e,s):t.scale.getViewPort(s)},st=new tt;const it=Phaser.Utils.Objects.GetValue;var nt=function(t,e){var s=it(e,"expandDirection",void 0);"string"==typeof s&&(s=rt[s]);var i,n,r,a,h,o,u,c=(r="alignTargetX",Q(i=e,n="alignTarget")?d(i,n):r&&Q(i,r)?d(i,r):a&&Q(i,a)?d(i,a):h),l=it(e,"alignTargetY",c),p=it(e,"alignOffsetX",0),v=it(e,"alignOffsetY",0),m=it(e,"alignSide","").includes("right"),f=it(e,"bounds"),y=0===s,_=!(y||1===s),g=m?1:0,E=y||_?0:1;t.setOrigin(g,E),o=m?c.getTopRight().x:c.getTopLeft().x,u=l.getBottomLeft().y,t.setPosition(o+p,u+v);var O=f;O||(O=et(t.scene)),_&&t.getBottomLeft().y>O.bottom&&(u=l.getTopLeft().y,t.setOrigin(0,1).setPosition(o+p,u+v))};const rt={down:0,up:1};var at=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},ht=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const ot=Phaser.Geom.Rectangle,ut=Phaser.Math.Vector2,ct=Phaser.Math.RotateAround,lt=Phaser.GameObjects.Container;var pt=void 0,dt=function(t,e,s){return void 0===e?e=new ut:!0===e&&(void 0===yt&&(yt=new ut),e=yt),t.getTopLeft?t.getTopLeft(e,s):(e.x=t.x-at(t)*t.originX,e.y=t.y-ht(t)*t.originY,_t(t,e,s))},vt=function(t,e,s){return void 0===e?e=new ut:!0===e&&(void 0===yt&&(yt=new ut),e=yt),t.getTopRight?t.getTopRight(e,s):(e.x=t.x-at(t)*t.originX+at(t),e.y=t.y-ht(t)*t.originY,_t(t,e,s))},mt=function(t,e,s){return void 0===e?e=new ut:!0===e&&(void 0===yt&&(yt=new ut),e=yt),t.getBottomLeft?t.getBottomLeft(e,s):(e.x=t.x-at(t)*t.originX,e.y=t.y-ht(t)*t.originY+ht(t),_t(t,e,s))},ft=function(t,e,s){return void 0===e?e=new ut:!0===e&&(void 0===yt&&(yt=new ut),e=yt),t.getBottomRight?t.getBottomRight(e,s):(e.x=t.x-at(t)*t.originX+at(t),e.y=t.y-ht(t)*t.originY+ht(t),_t(t,e,s))},yt=void 0,_t=function(t,e,s){return void 0===s&&(s=!1),0!==t.rotation&&ct(e,t.x,t.y,t.rotation),s&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e},gt=function(t,e,s,i,n){if(!t)return!1;if(i&&!i(t,e,s))return!1;var r=function(t,e){if(void 0===e?e=new ot:!0===e&&(void 0===pt&&(pt=new ot),e=pt),t.getBounds&&!(t instanceof lt))return t.getBounds(e);var s,i,n,r,a,h,o,u;if(t.parentContainer){var c=t.parentContainer.getBoundsTransformMatrix();dt(t,e),c.transformPoint(e.x,e.y,e),s=e.x,i=e.y,vt(t,e),c.transformPoint(e.x,e.y,e),n=e.x,r=e.y,mt(t,e),c.transformPoint(e.x,e.y,e),a=e.x,h=e.y,ft(t,e),c.transformPoint(e.x,e.y,e),o=e.x,u=e.y}else dt(t,e),s=e.x,i=e.y,vt(t,e),n=e.x,r=e.y,mt(t,e),a=e.x,h=e.y,ft(t,e),o=e.x,u=e.y;return e.x=Math.min(s,n,a,o),e.y=Math.min(i,r,h,u),e.width=Math.max(s,n,a,o)-e.x,e.height=Math.max(i,r,h,u)-e.y,e}(t,!0);return!(!r.contains(e,s)||n&&!n(t,e,s))};const Et=Phaser.Utils.Objects.GetValue;class Ot extends b{constructor(t,e){void 0===e&&(e={}),null==e.transitIn&&(e.transitIn=function(t,e){!function(t,e,s,i,n){var r,a;switch(void 0===i&&(i="Cubic"),s){case 0:case"x":r={x:0},a={x:t.scaleX};break;case 1:case"y":r={y:0},a={y:t.scaleY};break;default:r=0,a=t.scale}var h={mode:0,start:r,end:a,duration:e,ease:i};void 0===n?n=new $(t,h):n.resetFromJSON(h),n.restart()}(t,e,"y","Cubic")}),null==e.transitOut&&(e.transitOut=function(t,e){!function(t,e,s,i,n){void 0===i&&(i="Linear");var r={mode:0};switch(s){case 0:case"x":r.end={x:0};break;case 1:case"y":r.end={y:0};break;default:r.end=0}r.duration=e,r.ease=i,void 0===n?n=new $(t,r):n.resetFromJSON(r),n.restart()}(t,e,"y","Linear")}),e.manualClose=!0,e.clickOutsideClose=!0,e.destroy=!0,super(t,e),nt(t,e),t.isRexSizer&&t.layout();var s=Et(e,"touchOutsideClose",!1),i=Et(e,"anyTouchClose",!1);i&&(s=!1),i?this.once("open",this.anyTouchClose,this):s&&this.once("open",this.touchOutsideClose,this),this.requestOpen()}shutdown(t){this.isShutdown||(this.scene.input.off("pointerup",this.touchCloseCallback,this),super.shutdown(t))}touchOutsideClose(){return this.scene.input.on("pointerup",this.touchCloseCallback,this),this.clickOutsideTest=!0,this}anyTouchClose(){return this.scene.input.once("pointerup",this.touchCloseCallback,this),this}touchCloseCallback(t){this.clickOutsideTest&&gt(this.parent,t.worldX,t.worldY)||this.requestClose()}onOpen(){this.emit("open",this.parent,this),super.onOpen()}onClose(){this.emit("close",this.parent,this),super.onClose()}}class Tt extends Phaser.Plugins.BasePlugin{constructor(t){super(t)}start(){this.game.events.on("destroy",this.destroy,this)}add(t,e){return new Ot(t,e)}}return Tt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexdropdownplugin=e();