phaser4-rex-plugins
Version:
2 lines (1 loc) • 48.7 kB
JavaScript
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},o=function(t){return null==t||"object"!=typeof t?null:r(t)?t:r(t.game)?t.game:s(t)?t.sys.game:s(t.scene)?t.scene.sys.game:void 0};const h=Phaser.Utils.Objects.GetValue;class a{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(h(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){return this.parent=t,this.scene=i(t),this.game=o(t),this}}Object.assign(a.prototype,t);const u=Phaser.Utils.Objects.GetValue;class c extends a{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(u(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};var d=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},p=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const m=Phaser.Geom.Rectangle,v=Phaser.Math.Vector2,g=Phaser.Math.RotateAround,f=Phaser.GameObjects.Container;var y=void 0,b=function(t,e,s){return void 0===e?e=new v:!0===e&&(void 0===D&&(D=new v),e=D),t.getTopLeft?t.getTopLeft(e,s):(e.x=t.x-d(t)*t.originX,e.y=t.y-p(t)*t.originY,x(t,e,s))},E=function(t,e,s){return void 0===e?e=new v:!0===e&&(void 0===D&&(D=new v),e=D),t.getTopRight?t.getTopRight(e,s):(e.x=t.x-d(t)*t.originX+d(t),e.y=t.y-p(t)*t.originY,x(t,e,s))},w=function(t,e,s){return void 0===e?e=new v:!0===e&&(void 0===D&&(D=new v),e=D),t.getBottomLeft?t.getBottomLeft(e,s):(e.x=t.x-d(t)*t.originX,e.y=t.y-p(t)*t.originY+p(t),x(t,e,s))},S=function(t,e,s){return void 0===e?e=new v:!0===e&&(void 0===D&&(D=new v),e=D),t.getBottomRight?t.getBottomRight(e,s):(e.x=t.x-d(t)*t.originX+d(t),e.y=t.y-p(t)*t.originY+p(t),x(t,e,s))},D=void 0,x=function(t,e,s){return void 0===s&&(s=!1),0!==t.rotation&&g(e,t.x,t.y,t.rotation),s&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e},_=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 m:!0===e&&(void 0===y&&(y=new m),e=y),t.getBounds&&!(t instanceof f))return t.getBounds(e);var s,i,n,r,o,h,a,u;if(t.parentContainer){var c=t.parentContainer.getBoundsTransformMatrix();b(t,e),c.transformPoint(e.x,e.y,e),s=e.x,i=e.y,E(t,e),c.transformPoint(e.x,e.y,e),n=e.x,r=e.y,w(t,e),c.transformPoint(e.x,e.y,e),o=e.x,h=e.y,S(t,e),c.transformPoint(e.x,e.y,e),a=e.x,u=e.y}else b(t,e),s=e.x,i=e.y,E(t,e),n=e.x,r=e.y,w(t,e),o=e.x,h=e.y,S(t,e),a=e.x,u=e.y;return e.x=Math.min(s,n,o,a),e.y=Math.min(i,r,h,u),e.width=Math.max(s,n,o,a)-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))},P=function(t,e,s){var i=t.camera;return i?(void 0===s?s={}:!0===s&&(s=O),i===e?(s.x=t.worldX,s.y=t.worldY):i.getWorldPoint(t.x,t.y,s),s):null},O={},Z=function(t,e,s,i){return function(t,e,s,i,n){var r,o=t.scene.sys.cameras.main,h=0===t.scrollFactorX&&0===t.scrollFactorY;if(e)return h?s(t,e.x,e.y,i,n):!!(r=P(e,o,!0))&&s(t,r.x,r.y,i,n);for(var a=t.scene.input.manager,u=a.pointersTotal,c=a.pointers,l=0;l<u;l++)if(e=c[l],h){if(s(t,e.x,e.y,i,n))return!0}else{if(!(r=P(e,o,!0)))continue;if(s(t,r.x,r.y,i,n))return!0}return!1}(t,e,_,s,i)};const T=Phaser.Utils.Objects.GetValue;class C extends c{constructor(t,e){var s=i(t);s===t&&(t=void 0),super(s,e),this.gameObject=t,t&&t.setInteractive(T(e,"inputConfig",void 0)),this._enable=void 0,this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(T(t,"enable",!0)),this.setDetectBounds(),void 0===this.gameObject?this.setDetectBounds(T(t,"bounds",void 0)):this.setDetectBounds(),this.tracerState=k,this.pointer=void 0,this.lastPointer=void 0,this.movedState=!1,this.isTouchingAnyObject=!1,this}boot(){super.boot(),this.gameObject?this.gameObject.on("pointerdown",this.onPointerDown,this):this.scene.input.on("pointerdown",this.onPointerDown,this),this.scene.input.on("pointerup",this.onPointerUp,this),this.scene.input.on("gameout",this.dragCancel,this),this.scene.input.on("pointermove",this.onPointerMove,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(t){this.scene&&(this.gameObject||this.scene.input.off("pointerdown",this.onPointerDown,this),this.scene.input.off("pointerup",this.onPointerUp,this),this.scene.input.off("gameout",this.dragCancel,this),this.scene.input.off("pointermove",this.onPointerMove,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.gameObject=void 0,this.bounds=void 0,this.pointer=void 0,this.lastPointer=void 0,this.movedState=!1,super.shutdown(t))}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.dragCancel(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}setDetectBounds(t){return this.bounds=t,this}toggleEnable(){return this.setEnable(!this.enable),this}onPointerDown(t,e){this.enable&&void 0===this.pointer&&(!this.bounds||this.bounds.contains(t.x,t.y))&&this.pointer!==t&&(this.pointer=t,this.pointerCamera=t.camera,this.lastPointer=t,this.movedState=!1,this.tracerState=j,void 0===this.gameObject&&(this.isTouchingAnyObject=e.length>0),this.onDragStart())}onPointerUp(t){this.enable&&(!this.bounds||this.bounds.contains(t.x,t.y))&&this.pointer===t&&(this.pointer=void 0,this.pointerCamera=void 0,this.movedState=!1,this.tracerState=k,this.onDragEnd())}onPointerMove(t){if(this.enable&&t.isDown){var e=!this.bounds||this.bounds.contains(t.x,t.y),s=this.pointer===t;!s&&e||(s&&!e?this.onPointerUp(t):(this.movedState||(this.movedState=t.x!==t.downX||t.y!==t.downY),this.movedState&&this.onDrag()))}}dragCancel(){return this.tracerState===j&&this.onDragEnd(),this.pointer=void 0,this.tracerState=k,this}onDragStart(){this.emit("dragstart",this)}onDragEnd(){this.emit("dragend",this)}onDrag(){this.emit("drag",this)}preUpdate(t,e){}postUpdate(t,e){}startTicking(){super.startTicking(),this.scene.sys.events.on("preupdate",this.preUpdate,this),this.scene.sys.events.on("postupdate",this.postUpdate,this)}stopTicking(){super.stopTicking(),this.scene&&(this.scene.sys.events.off("preupdate",this.preUpdate,this),this.scene.sys.events.off("postupdate",this.postUpdate,this))}setRecongizedStateObject(t){return this.recongizedState=t,this}get state(){return this.recongizedState.state}set state(t){this.recongizedState.state=t}cancel(){return this.state=M,this}isPointerInGameObject(t,e,s){var i=this.lastPointer;return!!i&&Z(t,i,e,s)}}const k=0,j=1,M="IDLE";function R(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var B={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,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var h=new n(i,r||t,o),a=s?s+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],h]:t._events[a].push(h):(t._events[a]=h,t._eventsCount++),t}function o(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,o=new Array(r);n<r;n++)o[n]=i[n].fn;return o},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,o){var h=s?s+t:t;if(!this._events[h])return!1;var a,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,o),!0}for(u=1,a=new Array(l-1);u<l;u++)a[u-1]=arguments[u];c.fn.apply(c.context,a)}else{var d,p=c.length;for(u=0;u<p;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(!a)for(d=1,a=new Array(l-1);d<l;d++)a[d-1]=arguments[d];c[u].fn.apply(c[u].context,a)}}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 o(this,r),this;var h=this._events[r];if(h.fn)h.fn!==e||n&&!h.once||i&&h.context!==i||o(this,r);else{for(var a=0,u=[],c=h.length;a<c;a++)(h[a].fn!==e||n&&!h[a].once||i&&h[a].context!==i)&&u.push(h[a]);u.length?this._events[r]=1===u.length?u[0]:u:o(this,r)}return this},h.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&o(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}(B);var W=R(B.exports);class L extends W{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var N={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):[]}},U=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,o=0;o<i.length;o++){if(e=i[o],!n.hasOwnProperty(e)){r=s;break}n=r=n[e]}return r};const G=["next","exit","enter"];let V=class{constructor(t){var e=U(t,"states",void 0);e&&this.addStates(e);var s=U(t,"extend",void 0);if(s)for(var i in s)this.hasOwnProperty(i)&&void 0!==this[i]||(this[i]=s[i]);var n=U(t,"eventEmitter",void 0),r=U(t,"EventEmitterClass",void 0);this.setEventEmitter(n,r),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(U(t,"enable",!0)),this.start(U(t,"start",void 0));var e=U(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 G}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],o=e[r];o&&(this[`${r}_${t}`]=o)}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 o=this[t+"_"+this.state];if(o){var h=arguments.length;switch(h){case 1:return o.call(this);case 2:return o.call(this,e);case 3:return o.call(this,e,s);case 4:return o.call(this,e,s,i);case 5:return o.call(this,e,s,i,n);case 6:return o.call(this,e,s,i,n,r)}for(var a=new Array(h-1),u=1;u<h;u++)a[u-1]=arguments[u];return o.apply(this,a)}}};Object.assign(V.prototype,N);var A=function(t,e,s,i,n){void 0===n&&(n=!1);var r=t._events[e];if(!r)return!1;for(var o=0,h=r.length;o<h;o++){var a=r[o];if(a.fn===s&&a.context===i&&a.once===n)return!0}return!1};const K=["next","exit","enter","update","preupdate","postupdate"];class z extends V{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=U(t,"scene",void 0),this}get stateProperties(){return K}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 A(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 A(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 A(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}}Phaser.Utils.Objects.GetValue,Phaser.Math.Distance.Between,Phaser.Utils.Objects.GetValue;const X=Phaser.Utils.Objects.GetValue;class Y extends C{constructor(t,e){super(t,e);var s=this,i={states:{IDLE:{},BEGIN:{enter:function(){var t=s.pointer;s.startX=t.x,s.startY=t.y,s.startWorldX=t.worldX,s.startWorldY=t.worldY}},RECOGNIZED:{enter:function(){s.emit("panstart",s,s.gameObject,s.lastPointer)},exit:function(){var t=s.lastPointer;s.endX=t.x,s.endY=t.y;var e=P(t,s.pointerCamera,!0);s.endWorldX=e.x,s.endWorldY=e.y,s.emit("panend",s,s.gameObject,s.lastPointer)}}},init:function(){this.state=I},eventEmitter:!1};this.setRecongizedStateObject(new z(i))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(X(t,"threshold",10)),this}onDragStart(){this.state=F,0===this.dragThreshold&&(this.state=J)}onDragEnd(){this.state=I}onDrag(){switch(this.state){case F:if(this.pointer.getDistance()>=this.dragThreshold){this.state=J,this.dx=0,this.dy=0,this.dWorldX=0,this.dWorldY=0;var t=this.pointer;this.x=t.x,this.y=t.y,this.worldX=t.worldX,this.worldY=t.worldY}break;case J:var e=this.pointerCamera,s=this.pointer.position,i=this.pointer.prevPosition;this.dx=s.x-i.x,this.dy=s.y-i.y,this.dWorldX=this.dx/e.zoom,this.dWorldY=this.dy/e.zoom,t=this.pointer,this.x=t.x,this.y=t.y;var n=P(t,e,!0);this.worldX=n.x,this.worldY=n.y,this.emit("pan",this,this.gameObject,this.lastPointer)}}get isPanning(){return this.state===J}get isPanned(){return this.isPanning}setDragThreshold(t){return this.dragThreshold=t,this}}const I="IDLE",F="BEGIN",J="RECOGNIZED",H=Phaser.Math.Distance.Between,$=Phaser.Math.Angle.Between;var q={getDt:function(){var t;return t=this.scene,o(t).loop.delta},getVelocity:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return H(e.x,e.y,t.x,t.y)/(.001*this.getDt())},getVelocityX:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return Math.abs(t.x-e.x)/(.001*this.getDt())},getVelocityY:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return Math.abs(t.y-e.y)/(.001*this.getDt())},getVelocityAngle:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return $(e.x,e.y,t.x,t.y)}},Q={"up&down":0,"left&right":1,"4dir":2,"8dir":3},tt={};const et=Phaser.Utils.Objects.GetValue,st=Phaser.Math.RadToDeg;Object.assign(class extends C{constructor(t,e){super(t,e);var s=this,i={states:{IDLE:{enter:function(){s.x=0,s.y=0,s.worldX=0,s.worldY=0},exit:function(){var t=s.lastPointer;s.x=t.x,s.y=t.y,s.worldX=t.worldX,s.worldY=t.worldY}},BEGIN:{enter:function(){s.validDrag=!1}},RECOGNIZED:{enter:function(){s.start(),s.updateDirectionStates(),s.emit("swipe",s,s.gameObject,s.lastPointer)},exit:function(){s.stop(),s.clearDirectionStates()}}},init:function(){this.state=it},eventEmitter:!1};this.setRecongizedStateObject(new z(i)),this.clearDirectionStates()}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(et(t,"threshold",10)),this.setVelocityThreshold(et(t,"velocityThreshold",1e3)),this.setDirectionMode(et(t,"dir","8dir")),this}onDragStart(){this.state=nt}onDragEnd(){this.state=it}onDrag(){this.state===nt&&(this.validDrag||(this.validDrag=0===this.dragThreshold||this.pointer.getDistance()>=this.dragThreshold),this.validDrag&&this.dragVelocity>this.velocityThreshold&&(this.state=rt))}postUpdate(t,e){this.isRunning&&this.enable&&this.state===rt&&(this.state=it)}get isSwiping(){return this.state===rt}get isSwiped(){return this.isSwiping}get dragVelocity(){var t;switch(this.dirMode){case 0:t=this.getVelocityY();break;case 1:t=this.getVelocityX();break;default:t=this.getVelocity()}return t}setDragThreshold(t){return this.dragThreshold=t,this}setVelocityThreshold(t){return this.velocityThreshold=t,this}setDirectionMode(t){return"string"==typeof t&&(t=Q[t]),this.dirMode=t,this}updateDirectionStates(){return function(t,e,s){switch(void 0===s?s={}:!0===s&&(s=tt),s.left=!1,s.right=!1,s.up=!1,s.down=!1,t=(t+360)%360,e){case 0:t<180?s.down=!0:s.up=!0;break;case 1:t>90&&t<=270?s.left=!0:s.right=!0;break;case 2:t>45&&t<=135?s.down=!0:t>135&&t<=225?s.left=!0:t>225&&t<=315?s.up=!0:s.right=!0;break;case 3:t>22.5&&t<=67.5?(s.down=!0,s.right=!0):t>67.5&&t<=112.5?s.down=!0:t>112.5&&t<=157.5?(s.down=!0,s.left=!0):t>157.5&&t<=202.5?s.left=!0:t>202.5&&t<=247.5?(s.left=!0,s.up=!0):t>247.5&&t<=292.5?s.up=!0:t>292.5&&t<=337.5?(s.up=!0,s.right=!0):s.right=!0}}(st(this.getVelocityAngle()),this.dirMode,this),this}clearDirectionStates(){return this.left=!1,this.right=!1,this.up=!1,this.down=!1,this}}.prototype,q);const it="IDLE",nt="BEGIN",rt="RECOGNIZED";var ot=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e];return t};const ht=Phaser.Utils.Objects.GetValue,at=Phaser.Utils.Array.SpliceOne,ut=Phaser.Math.Distance.Between,ct=Phaser.Math.Angle.Between;class lt{constructor(t,e){var s=i(t);s===t&&(t=void 0);var n=s.input.manager.pointersTotal-1;n<2&&s.input.addPointer(2-n),this.scene=s,this.gameObject=t,t&&t.setInteractive(ht(e,"inputConfig",void 0)),this.setEventEmitter(ht(e,"eventEmitter",void 0)),this._enable=void 0,this.pointers=[],this.movedState={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(ht(t,"enable",!0)),this.bounds=ht(t,"bounds",void 0),this.tracerState=pt,this.pointers.length=0,ot(this.movedState),this}boot(){this.gameObject?this.gameObject.on("pointerdown",this.onPointerDown,this):this.scene.input.on("pointerdown",this.onPointerDown,this),this.scene.input.on("pointerup",this.onPointerUp,this),this.scene.input.on("gameout",this.dragCancel,this),this.scene.input.on("pointermove",this.onPointerMove,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(){this.scene&&(this.destroyEventEmitter(),this.pointers.length=0,ot(this.movedState),this.gameObject||this.scene.input.off("pointerdown",this.onPointerDown,this),this.scene.input.off("pointerup",this.onPointerUp,this),this.scene.input.off("gameout",this.dragCancel,this),this.scene.input.off("pointermove",this.onPointerMove,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.scene=void 0,this.gameObject=void 0)}destroy(){this.shutdown()}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.dragCancel(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}onPointerDown(t){if(this.enable&&2!==this.pointers.length&&(!this.bounds||this.bounds.contains(t.x,t.y))&&-1===this.pointers.indexOf(t))switch(this.movedState[t.id]=!1,this.pointers.push(t),this.pointerCamera=t.camera,this.tracerState){case pt:this.tracerState=mt,this.onDrag1Start();break;case mt:this.tracerState=vt,this.onDrag2Start()}}onPointerUp(t){if(this.enable&&(!this.bounds||this.bounds.contains(t.x,t.y))){var e=this.pointers.indexOf(t);if(-1!==e)switch(delete this.movedState[t.id],at(this.pointers,e),this.tracerState){case mt:this.tracerState=pt,this.onDrag1End();break;case vt:this.tracerState=mt,this.onDrag2End(),this.onDrag1Start()}}}onPointerMove(t){if(this.enable&&t.isDown){var e=!this.bounds||this.bounds.contains(t.x,t.y),s=-1!==this.pointers.indexOf(t);if(!s&&e);else if(s&&!e)this.onPointerUp(t);else if(this.movedState[t.id]||(this.movedState[t.id]=t.x!==t.downX||t.y!==t.downY),this.movedState[t.id])switch(this.tracerState){case mt:this.onDrag1();break;case vt:this.onDrag2()}}}dragCancel(){return this.tracerState===vt&&this.onDrag2End(),this.pointers.length=0,ot(this.movedState),this.tracerState=pt,this}onDrag1Start(){this.emit("drag1start",this)}onDrag1End(){this.emit("drag1end",this)}onDrag1(){this.emit("drag1",this)}onDrag2Start(){this.emit("drag2start",this)}onDrag2End(){this.emit("drag2end",this)}onDrag2(){this.emit("drag2",this)}get distanceBetween(){if(this.tracerState!==vt)return 0;var t=this.pointers[0],e=this.pointers[1];return ut(t.x,t.y,e.x,e.y)}get angleBetween(){if(this.tracerState!==vt)return 0;var t=this.pointers[0],e=this.pointers[1];return ct(t.x,t.y,e.x,e.y)}get drag1Vector(){var t=this.pointers[0];if(t&&this.movedState[t.id]){var e=t.position,s=t.prevPosition;dt.x=e.x-s.x,dt.y=e.y-s.y}else dt.x=0,dt.y=0;return dt}get centerX(){if(this.tracerState!==vt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.x+e.x)/2}get centerY(){if(this.tracerState!==vt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.y+e.y)/2}get prevCenterX(){if(this.tracerState!==vt)return 0;var t=this.movedState[this.pointers[0].id]?this.pointers[0].prevPosition:this.pointers[0].position,e=this.movedState[this.pointers[1].id]?this.pointers[1].prevPosition:this.pointers[1].position;return(t.x+e.x)/2}get prevCenterY(){if(this.tracerState!==vt)return 0;var t=this.movedState[this.pointers[0].id]?this.pointers[0].prevPosition:this.pointers[0].position,e=this.movedState[this.pointers[1].id]?this.pointers[1].prevPosition:this.pointers[1].position;return(t.y+e.y)/2}get movementCenterX(){return this.centerX-this.prevCenterX}get movementCenterY(){return this.centerY-this.prevCenterY}setRecongizedStateObject(t){return this.recongizedState=t,this}get state(){return this.recongizedState.state}set state(t){this.recongizedState.state=t}cancel(){return this.state=gt,this}isPointer0InGameObject(t,e,s){var i=this.pointers[0];return!!i&&Z(t,i,e,s)}isPointer1InGameObject(t,e,s){var i=this.pointers[1];return!!i&&Z(t,i,e,s)}}Object.assign(lt.prototype,t);var dt={};const pt=0,mt=1,vt=2,gt="IDLE",ft=Phaser.Utils.Objects.GetValue;class yt extends lt{constructor(t,e){super(t,e);var s=this,i={states:{IDLE:{enter:function(){s.prevDistance=void 0,s.scaleFactor=1}},BEGIN:{},RECOGNIZED:{enter:function(){s.emit("pinchstart",s)},exit:function(){s.emit("pinchend",s)}}},init:function(){this.state=bt},eventEmitter:!1};this.setRecongizedStateObject(new z(i))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(ft(t,"threshold",0)),this}onDrag2Start(){this.scaleFactor=1,this.prevDistance=this.distanceBetween,this.state=Et,0===this.dragThreshold&&(this.state=wt)}onDrag2End(){this.state=bt}onDrag2(){switch(this.state){case Et:if(this.pointers[0].getDistance()>=this.dragThreshold&&this.pointers[1].getDistance()>=this.dragThreshold){var t=this.distanceBetween;this.scaleFactor=t/this.prevDistance,this.prevDistance=t,this.state=wt}break;case wt:t=this.distanceBetween,this.scaleFactor=t/this.prevDistance,this.emit("pinch",this),this.prevDistance=t}}get isPinching(){return this.state===wt}get isPinched(){return this.isPinching}setDragThreshold(t){return this.dragThreshold=t,this}}const bt="IDLE",Et="BEGIN",wt="RECOGNIZED",St=Phaser.Math.RotateAround;var Dt=function(t,e,s,i){return St(t,e,s,i),t.rotation+=i,t},xt={};const _t=Phaser.Utils.Objects.GetValue,Pt=Phaser.Math.Angle.WrapDegrees,Ot=Phaser.Math.Angle.ShortestBetween,Zt=Phaser.Math.RadToDeg,Tt=Phaser.Math.DegToRad;var Ct={spinObject:function(t,e){if(!this.isRotation)return this;void 0===e&&(e=this.pointers[0].camera);var s=this.movementCenterX,i=this.movementCenterY,n=function(t,e,s,i){return void 0===i?i={}:!0===i&&(i=xt),s.getWorldPoint(t,e,i),i}(this.centerX,this.centerY,e,!0),r=n.x,o=n.y,h=this.rotation;if(Array.isArray(t))for(var a=t,u=0,c=a.length;u<c;u++)(t=a[u]).x+=s,t.y+=i,Dt(t,r,o,h);else t.x+=s,t.y+=i,Dt(t,r,o,h);return this}};Object.assign(class extends lt{constructor(t,e){super(t,e);var s=this,i={states:{IDLE:{enter:function(){s.prevAngle=void 0,s.angle=0}},BEGIN:{},RECOGNIZED:{enter:function(){s.emit("rotatestart",s)},exit:function(){s.emit("rotateend",s)}}},init:function(){this.state=kt},eventEmitter:!1};this.setRecongizedStateObject(new z(i))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(_t(t,"threshold",0)),this}onDrag2Start(){this.prevAngle=Pt(Zt(this.angleBetween)),this.state=jt,0===this.dragThreshold&&(this.state=Mt)}onDrag2End(){this.state=kt}onDrag2(){switch(this.state){case jt:if(this.pointers[0].getDistance()>=this.dragThreshold&&this.pointers[1].getDistance()>=this.dragThreshold){var t=Pt(Zt(this.angleBetween));this.angle=Ot(this.prevAngle,t),this.prevAngle=t,this.state=Mt}break;case Mt:t=Pt(Zt(this.angleBetween)),this.angle=Ot(this.prevAngle,t),this.prevAngle=t,this.emit("rotate",this)}}get isRotating(){return this.state===Mt}get isRotated(){return this.isRotating}get rotation(){return Tt(this.angle)}setDragThreshold(t){return this.dragThreshold=t,this}}.prototype,Ct);const kt="IDLE",jt="BEGIN",Mt="RECOGNIZED";var Rt=function(t,e){var s,i=t.cameras;if(void 0===e)s=i.main;else switch(typeof e){case"string":s=i.getCamera(e);break;case"number":s=i.cameras[e];break;default:s=e}return s};const Bt=Phaser.Utils.Objects.GetValue;class Wt extends a{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=Bt(e,"inputTarget",t),this.pan=new Y(this.inputTarget);var s=Rt(t,Bt(e,"camera"));this.setCamera(s).setEnable(Bt(e,"enable",!0)),this.boot()}boot(){this.pan.on("pan",(function(t){var e=this.camera;if(e){var s=e.zoom;e.scrollX-=t.dx/s,e.scrollY-=t.dy/s}}),this).on("panstart",(function(){this.emit("panstart")}),this).on("panend",(function(){this.emit("panend")}),this)}shutdown(t){this.isShutdown||(this.inputTarget=void 0,this.pan.destroy(),this.pan=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this}get enable(){return this.pan.enable}set enable(t){this.pan.enable=t}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};get isPanning(){return this.pan.isPanning}}const Lt=Phaser.Utils.Objects.GetValue;class Nt extends a{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=Lt(e,"inputTarget",t),this.pinch=new yt(this.inputTarget);var s=Rt(t,Lt(e,"camera"));this.setCamera(s).setEnable(Lt(e,"enable",!0)).setMinZoom(Lt(e,"minZoom",void 0)).setMaxZoom(Lt(e,"maxZoom",void 0)).setFocusEnable(Lt(e,"focusEnable",!0)),this.boot()}boot(){this.focusWorldX=void 0,this.focusWorldY=void 0,this.pinch.on("pinchstart",(function(t){var e=t.pointers[0],s=t.pointers[1];this.focusEnable&&void 0===this.focusWorldX&&(this.focusWorldX=.5*(e.worldX+s.worldX),this.focusWorldY=.5*(e.worldY+s.worldY)),this.emit("pinchstart")}),this).on("pinch",(function(t){var e=this.camera;if(e){var s=e.zoom*t.scaleFactor;if(void 0!==this.minZoom&&s<this.minZoom&&(s=this.minZoom),void 0!==this.maxZoom&&s>this.maxZoom&&(s=this.maxZoom),e.zoom=s,e.preRender(),this.focusEnable){var i=t.pointers[0],n=t.pointers[1],r=.5*(i.x+n.x),o=.5*(i.y+n.y),h=e.getWorldPoint(r,o);e.scrollX-=h.x-this.focusWorldX,e.scrollY-=h.y-this.focusWorldY}}}),this).on("pinchend",(function(){this.focusWorldX=void 0,this.focusWorldY=void 0,this.emit("pinchend")}),this)}shutdown(t){this.isShutdown||(this.inputTarget=void 0,this.pinch.destroy(),this.pinch=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this}get enable(){return this.pinch.enable}set enable(t){this.pinch.enable=t}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};setMinZoom(t){return this.minZoom=t,this}setMaxZoom(t){return this.maxZoom=t,this}setFocusEnable(t){return this.focusEnable=t,this}get isPinching(){return this.pinch.isPinching}}const Ut=Phaser.Input.Keyboard.Key,Gt=Phaser.Input.Keyboard.KeyCodes,Vt=["up","down","left","right"];class At{constructor(t){this.scene=t,this.keys={},this.cursorKeys={},this.noKeyDown=!0;for(var e=0,s=Vt.length;e<s;e++){var i=Vt[e];this.addKey(i),this.cursorKeys[i]=this.keys[i]}}shutdown(t){for(var e in this.scene=void 0,this.keys)this.keys[e].destroy();this.keys=void 0,this.cursorKeys=void 0}destroy(t){shutdown(t)}createCursorKeys(){return this.cursorKeys}setKeyState(t,e){var s=this.keys[t];return s.enabled?(e&&(this.noKeyDown=!1),s.isDown!==e&&(Kt.timeStamp=Date.now(),Kt.keyCode=s.keyCode,e?s.onDown(Kt):s.onUp(Kt)),this):this}clearAllKeysState(){for(var t in this.noKeyDown=!0,this.keys)this.setKeyState(t,!1);return this}getKeyState(t){return this.keys[t]}get upKeyDown(){return this.keys.up.isDown}get downKeyDown(){return this.keys.down.isDown}get leftKeyDown(){return this.keys.left.isDown}get rightKeyDown(){return this.keys.right.isDown}get anyKeyDown(){return!this.noKeyDown}addKey(t,e){return void 0===e&&(e=t),"string"==typeof e&&(e=e.toUpperCase(),Gt.hasOwnProperty(e)&&(e=Gt[e])),this.keys[t]=new Ut(this.scene,e),this}addKeys(t){for(var e=0,s=t.length;e<s;e++)this.addKey(t[e]);return this}}var Kt={timeStamp:0,keyCode:0,altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,location:0};const zt=Phaser.Cameras.Scene2D.BaseCamera,Xt=Phaser.Geom.Rectangle;var Yt=function(t,e,s){return e instanceof zt||(s=e,e=void 0),void 0===s?s=new Xt:!0===s&&(s=It),e?t.scale.getViewPort(e,s):t.scale.getViewPort(s)},It=new Xt;const Ft=Phaser.Utils.Objects.GetValue;class Jt extends At{constructor(t,e){super(t),this.scene=t,this._enable=void 0,this.setEnable(Ft(e,"enable",!0)),this.setSensitiveDistance(Ft(e,"sensitiveDistance",20));var s=Ft(e,"bounds",void 0);void 0===s?(s=Yt(t),this.autoUpdateViewportBounds=!0):this.autoUpdateViewportBounds=!1,this.setBounds(s),this.pointerOutGameReleaseEnable=Ft(e,"pointerOutGameRelease",!0),this.pointerOutBoundsReleaseEnable=Ft(e,"pointerOutBoundsRelease",!1),this.boot()}boot(){this.scene.input.on("pointermove",this.onPointerMove,this),this.pointerOutGameReleaseEnable&&this.scene.input.on("gameout",this.clearAllKeysState,this),this.autoUpdateViewportBounds&&this.scene.scale.on("resize",this.updateBoundsByViewport,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(){this.scene&&(this.scene.input.off("pointermove",this.onPointerMove,this),this.pointerOutGameReleaseEnable&&this.scene.input.off("gameout",this.clearAllKeysState,this),this.autoUpdateViewportBounds&&this.scene.scale.off("resize",this.updateBoundsByViewport,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.scene=void 0,super.shutdown())}destroy(){this.shutdown()}updateBoundsByViewport(){Yt(this.scene,this.bounds)}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.clearAllKeysState(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}setBounds(t){return this.bounds=t,this}getBounds(){return this.bounds}setSensitiveDistance(t){return this.sensitiveDistance=t,this}onPointerMove(t){if(this.enable){var e=t.x,s=t.y,i=this.bounds.left,n=this.bounds.right,r=this.bounds.top,o=this.bounds.bottom,h=this.sensitiveDistance,a=e>=i&&e<=i+h,u=e<=n&&e>=n-h,c=s>=r&&s<=r+h,l=s<=o&&s>=o-h;this.pointerOutBoundsReleaseEnable||(a|=e<i,u|=e>n,c|=s<r,l|=s>o),this.setKeyState("left",a),this.setKeyState("right",u),this.setKeyState("up",c),this.setKeyState("down",l)}}get up(){return this.upKeyDown}get down(){return this.downKeyDown}get left(){return this.leftKeyDown}get right(){return this.rightKeyDown}get noKey(){return this.noKeyDown}}const Ht=Phaser.Utils.Objects.GetValue;class $t extends a{constructor(t,e){void 0===e&&(e={}),super(t,e),this.cursorAtBounds=new Jt(t);var s=this.cursorAtBounds.createCursorKeys();this.cameraController=new Phaser.Cameras.Controls.SmoothedKeyControl({left:s.left,right:s.right,up:s.up,down:s.down,acceleration:.06,drag:.003,maxSpeed:.3});var i=Rt(t,Ht(e,"camera"));this.setCamera(i).setEnable(Ht(e,"enable",!0)),this.boot()}boot(){this.scene.events.on("preupdate",this.updateCameraController,this)}shutdown(t){this.isShutdown||(this.scene.events.off("preupdate",this.updateCameraController,this),this.cursorAtBounds.destroy(),this.cameraController.destroy(),super.shutdown(t))}get camera(){return this.cameraController.camera}set camera(t){this.cameraController.setCamera(t),t?this.cameraController.start():this.cameraController.stop()}setCamera(t){return this.camera=t,this}get enable(){return this.cursorAtBounds.enable}set enable(t){this.cursorAtBounds.enable=t}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}updateCameraController(t,e){this.cameraController.update(e)}}const qt=Phaser.Utils.Objects.GetValue;class Qt extends c{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=qt(e,"tickEventName",s),this.isSceneTicker=!te(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 te=function(t){return"step"===t||"poststep"===t};const ee=Phaser.Utils.Objects.GetValue,se=Phaser.Math.Clamp;class ie{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=ee(t,"state",ne),this.timeScale=ee(t,"timeScale",1),this.delay=ee(t,"delay",0),this.repeat=ee(t,"repeat",0),this.repeatCounter=ee(t,"repeatCounter",0),this.repeatDelay=ee(t,"repeatDelay",0),this.duration=ee(t,"duration",0),this.nowTime=ee(t,"nowTime",0),this.justRestart=ee(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?oe:re,this.repeatCounter=0,this}stop(){return this.state=ne,this}update(t,e){this.state!==ne&&this.state!==ae&&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=he)):(this.nowTime=this.duration,this.state=ae):this.nowTime>=0&&(this.state=oe))}get t(){var t;switch(this.state){case ne:case re:case he:t=0;break;case oe:t=this.nowTime/this.duration;break;case ae:t=1}return se(t,0,1)}set t(t){(t=se(t,-1,1))<0?(this.state=re,this.nowTime=-this.delay*t):(this.state=oe,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===ne}get isDelay(){return this.state===re}get isCountDown(){return this.state===oe}get isRunning(){return this.state===re||this.state===oe}get isDone(){return this.state===ae}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const ne=0,re=1,oe=2,he=3,ae=-1;class ue extends Qt{constructor(t,e){super(t,e),this.timer=new ie}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 ce=Phaser.Utils.Objects.GetValue,le=Phaser.Utils.Objects.GetAdvancedValue,de=Phaser.Tweens.Builders.GetEaseFunction;class pe extends ue{resetFromJSON(t){return this.timer.resetFromJSON(ce(t,"timer")),this.setEnable(ce(t,"enable",!0)),this.setTarget(ce(t,"target",this.parent)),this.setDelay(le(t,"delay",0)),this.setDuration(le(t,"duration",1e3)),this.setEase(ce(t,"ease","Linear")),this.setRepeat(ce(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=de(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 me=Phaser.Math.Linear;class ve extends pe{constructor(t,e){super(t,e),this.resetFromJSON(e)}start(t){return this.stop(),this.startZoomValue=this.target.zoom,this.endZoomValue=t,this.timer.setDuration(this.duration),super.start(),this}updateTarget(t,e){var s=this.parent;!function(t,e,s,i){if(void 0!==s){var n=t.getWorldPoint(s,i);t.zoom=e,t.preRender();var r=t.getWorldPoint(s,i);t.scrollX-=r.x-n.x,t.scrollY-=r.y-n.y}else t.zoom=e}(t,me(this.startZoomValue,this.endZoomValue,e.t),s.focusLocalX,s.focusLocalY)}}const ge=Phaser.Utils.Objects.GetValue;Phaser.Math.Clamp;class fe extends a{constructor(t,e){void 0===e&&(e={}),super(t,e),this.easeZoom=new ve(this);var s=Rt(t,ge(e,"camera"));this.setEnable(ge(e,"enable",!0)).setMinZoom(ge(e,"minZoom")).setMaxZoom(ge(e,"maxZoom")).setZoomStep(ge(e,"zoomStep",.1)).setEaseDuration(ge(e,"easeDuration",200)).setCamera(s),this.boot()}boot(){this.scene.input.on("wheel",this.onWheel,this)}shutdown(t){this.isShutdown||(this.scene.input.off("wheel",this.onWheel,this),this.easeZoom.destroy(),this.easeZoom=void 0,this.inputTarget=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this.resetZoomLevel(),this.easeZoom.stop().setTarget(t||null),this}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};setMinZoom(t){return this.minZoom=t,this}setMaxZoom(t){return this.maxZoom=t,this}setZoomStep(t){return this.zoomStep=t,this}setEaseDuration(t){return this.easeDuration=t,this.easeZoom.setDuration(t),this}resetZoomLevel(){var t=this.camera;return t?(this.zoomLevel=Math.round(ye(t.zoom,this.zoomStep)),this.zoom=t.zoom,this):(this.zoomLevel=void 0,this)}onWheel(t,e,s,i,n,r){var o=this.camera;if(this.enable&&o){var h=void 0!==this.minZoom,a=void 0!==this.maxZoom;h&&this.zoom<=this.minZoom&&i>0||a&&this.zoom>=this.maxZoom&&i<0||(this.zoomLevel+=i<0?1:-1,this.zoom=be(this.zoomLevel,this.zoomStep),h&&this.zoom<this.minZoom&&(this.zoom=this.minZoom),a&&this.zoom>this.maxZoom&&(this.zoom=this.maxZoom),this.focusLocalX=t.x,this.focusLocalY=t.y,this.easeZoom.start(this.zoom))}}}var ye=function(t,e){return t>=1?Math.log(t)/Math.log(1+e):-Math.log(t)/Math.log(1-e)},be=function(t,e){return t>=0?Math.pow(1+e,t):Math.pow(1-e,-t)};function Ee(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>Ee(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=Ee(t[s]));return e}const we=Phaser.Utils.Objects.GetValue;class Se extends a{constructor(t,e){super(t,e=void 0===e?{}:Ee(e)),this._enable=!0,this._camera=void 0;var s,i=we(e,"minZoom"),n=we(e,"maxZoom");we(e,"boundsScroll",!0)&&(this.boundsScroll=new $t(t,{camera:we(e,"camera"),enable:we(e,"boundsScrollEnable",!0)})),we(e,"mouseWheelZoom",!0)&&(this.mouseWheelZoom=new fe(t,{camera:we(e,"camera"),enable:we(e,"mouseWheelZoomEnable",!0),zoomStep:we(e,"mouseWheelZoomStep",.1),minZoom:we(e,"mouseWheelZoomMin",i),maxZoom:we(e,"mouseWheelZoomMax",n)})),we(e,"pinchZoom",!0)&&(this.pinchZoom=new Nt(t,{camera:we(e,"camera"),inputTarget:we(e,"inputTarget",t),enable:we(e,"pinchZoomEnable",!0),minZoom:we(e,"pinchZoomMin",i),maxZoom:we(e,"pinchZoomMax",n),focusEnable:we(e,"pinchZoomFocusEnable",!0)})),we(e,"panScroll",!0)&&(this.panScroll=new Wt(t,{camera:we(e,"camera"),inputTarget:we(e,"inputTarget",t),enable:we(e,"panScrollEnable",!0)})),this.setEnable(we(e,"enable",!0)),this.pinchZoom&&this.panScroll&&this.pinchZoom.on("pinchstart",(function(){s=this.panScroll.enable,this.panScroll.setEnable(!1)}),this).on("pinchend",(function(){this.panScroll.setEnable(s)}),this)}destroy(t){this.panScroll&&this.panScroll.destroy(t),this.pinchZoom&&this.pinchZoom.destroy(t),this.boundsScroll&&this.boundsScroll.destroy(t),this.mouseWheelZoom&&this.mouseWheelZoom.destroy(t),super.destroy(t)}set camera(t){this.panScroll&&this.panScroll.setCamera(t),this.pinchZoom&&this.pinchZoom.setCamera(t),this.boundsScroll&&this.boundsScroll.setCamera(t),this.mouseWheelZoom&&this.mouseWheelZoom.setCamera(t)}get camera(){return this.panScroll?this.panScroll.camera:this.pinchZoom?this.pinchZoom.camera:this.boundsScroll?this.boundsScroll.camera:this.mouseWheelZoom?this.mouseWheelZoom.camera:void 0}setCamera(t){return this.camera=t,this}set boundsScrollEnable(t){this.boundsScroll&&(this.boundsScroll.enable=t)}get boundsScrollEnable(){return!!this.boundsScroll&&this.boundsScroll.enable}setBoundsScrollEnable=function(t){return void 0===t&&(t=!0),this.boundsScrollEnable=t,this};set mouseWheelZoomEnable(t){this.mouseWheelZoom&&(this.mouseWheelZoom.enable=t)}get mouseWheelZoomEnable(){if(this.mouseWheelZoom)return this.mouseWheelZoom.enable}setMouseWheelZoomEnable(t){return void 0===t&&(t=!0),this.mouseWheelZoom=t,this}set pinchZoomEnable(t){this.pinchZoom&&(this.pinchZoom.enable=t)}get pinchZoomEnable(){return!!this.pinchZoom&&this.pinchZoom.enable}setPinchZoomEnable=function(t){return void 0===t&&(t=!0),this.pinchZoomEnable=t,this};get isPinching(){return!!this.pinchZoom&&this.pinchZoom.isPinching}set panScrollEnable(t){this.panScroll&&(this.panScroll.enable=t)}get panScrollEnable(){return!!this.panScroll&&this.panScroll.enable}setPanScrollEnable=function(t){return void 0===t&&(t=!0),this.panScrollEnable=t,this};get isPanning(){return!!this.panScroll&&this.panScroll.isPanning}set enable(t){t=!!t,this._enable!==t&&(t?(this.panScrollEnable=this.panScrollEnableSave,this.pinchZoomEnable=this.pinchZoomEnableSave,this.boundsScrollEnable=this.boundsScrollEnableSave,this.mouseWheelZoomEnable=this.mouseWheelZoomEnableSave):(this.panScrollEnableSave=this.panScrollEnable,this.pinchZoomEnableSave=this.pinchZoomEnable,this.boundsScrollEnableSave=this.boundsScrollEnable,this.mouseWheelZoomEnableSave=this.mouseWheelZoomEnable,this.panScrollEnable=!1,this.pinchZoomEnable=!1,this.boundsScrollEnable=!1,this.mouseWheelZoomEnable=!1),this._enable=t)}get enable(){return this._enable}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.enable=!this.enable,this}}class De extends Phaser.Plugins.BasePlugin{constructor(t){super(t)}start(){this.game.events.on("destroy",this.destroy,this)}add(t,e){return new Se(t,e)}addPanScroll(t,e){return new Wt(t,e)}addPinchZoom(t,e){return new Nt(t,e)}addBoundsScroll(t,e){return new $t(t,e)}addMouseWheelZoom(t,e){return new fe(t,e)}}return De},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexcameracontrollerplugin=e();