phaser4-rex-plugins
Version:
1 lines • 561 kB
JavaScript
var t,e;t=void 0,e=function(){class t{constructor(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,t.events.once("destroy",this.destroy,this)}destroy(){this.scene=null,this.displayList=null,this.updateList=null}static register(e,i){t.prototype[e]=i}}var e={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 i=Phaser.Scene;var s=function(t){return t instanceof i},r=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 a=function(t){return t instanceof n},o=function(t){return null==t||"object"!=typeof t?null:a(t)?t:a(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 l{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=r(t),this.game=o(t),this}}Object.assign(l.prototype,e);const d=Phaser.Utils.Objects.GetValue;class c extends l{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(d(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=u[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 u={no:0,lazy:1,always:2};var p=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},g=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const v=Phaser.Geom.Rectangle,f=Phaser.Math.Vector2,m=Phaser.Math.RotateAround,y=Phaser.GameObjects.Container;var b=function(t,e){if(void 0===e?e=new v:!0===e&&(void 0===x&&(x=new v),e=x),t.getBounds&&!(t instanceof y))return t.getBounds(e);var i,s,r,n,a,o,h,l;if(t.parentContainer){var d=t.parentContainer.getBoundsTransformMatrix();C(t,e),d.transformPoint(e.x,e.y,e),i=e.x,s=e.y,w(t,e),d.transformPoint(e.x,e.y,e),r=e.x,n=e.y,S(t,e),d.transformPoint(e.x,e.y,e),a=e.x,o=e.y,O(t,e),d.transformPoint(e.x,e.y,e),h=e.x,l=e.y}else C(t,e),i=e.x,s=e.y,w(t,e),r=e.x,n=e.y,S(t,e),a=e.x,o=e.y,O(t,e),h=e.x,l=e.y;return e.x=Math.min(i,r,a,h),e.y=Math.min(s,n,o,l),e.width=Math.max(i,r,a,h)-e.x,e.height=Math.max(s,n,o,l)-e.y,e},x=void 0,C=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===P&&(P=new f),e=P),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-p(t)*t.originX,e.y=t.y-g(t)*t.originY,T(t,e,i))},w=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===P&&(P=new f),e=P),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-p(t)*t.originX+p(t),e.y=t.y-g(t)*t.originY,T(t,e,i))},S=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===P&&(P=new f),e=P),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-p(t)*t.originX,e.y=t.y-g(t)*t.originY+g(t),T(t,e,i))},O=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===P&&(P=new f),e=P),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-p(t)*t.originX+p(t),e.y=t.y-g(t)*t.originY+g(t),T(t,e,i))},k=function(t,e,i){void 0===e?e=new f:!0===e&&(void 0===P&&(P=new f),e=P);var s=p(t),r=g(t);return e.x=t.x+s*(.5-t.originX),e.y=t.y+r*(.5-t.originY),T(t,e,i)},P=void 0,T=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&m(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e},_=function(t,e,i,s,r){return!(!t||s&&!s(t,e,i)||!b(t,!0).contains(e,i)||r&&!r(t,e,i))},E=function(t,e,i){var s=t.camera;return s?(void 0===i?i={}:!0===i&&(i=M),s===e?(i.x=t.worldX,i.y=t.worldY):s.getWorldPoint(t.x,t.y,i),i):null},M={},R=function(t,e,i,s){return function(t,e,i,s,r){var n,a=t.scene.sys.cameras.main,o=0===t.scrollFactorX&&0===t.scrollFactorY;if(e)return o?i(t,e.x,e.y,s,r):!!(n=E(e,a,!0))&&i(t,n.x,n.y,s,r);for(var h=t.scene.input.manager,l=h.pointersTotal,d=h.pointers,c=0;c<l;c++)if(e=d[c],o){if(i(t,e.x,e.y,s,r))return!0}else{if(!(n=E(e,a,!0)))continue;if(i(t,n.x,n.y,s,r))return!0}return!1}(t,e,_,i,s)};const L=Phaser.Utils.Objects.GetValue;class D extends c{constructor(t,e){var i=r(t);i===t&&(t=void 0),super(i,e),this.gameObject=t,t&&t.setInteractive(L(e,"inputConfig",void 0)),this._enable=void 0,this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(L(t,"enable",!0)),this.setDetectBounds(),void 0===this.gameObject?this.setDetectBounds(L(t,"bounds",void 0)):this.setDetectBounds(),this.tracerState=A,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=W,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=A,this.onDragEnd())}onPointerMove(t){if(this.enable&&t.isDown){var e=!this.bounds||this.bounds.contains(t.x,t.y),i=this.pointer===t;!i&&e||(i&&!e?this.onPointerUp(t):(this.movedState||(this.movedState=t.x!==t.downX||t.y!==t.downY),this.movedState&&this.onDrag()))}}dragCancel(){return this.tracerState===W&&this.onDragEnd(),this.pointer=void 0,this.tracerState=A,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=j,this}isPointerInGameObject(t,e,i){var s=this.lastPointer;return!!s&&R(t,s,e,i)}}const A=0,W=1,j="IDLE";function B(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var z={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function s(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,s,n,a){if("function"!=typeof s)throw new TypeError("The listener must be a function");var o=new r(s,n||t,a),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function o(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,s,r=[];if(0===this._eventsCount)return r;for(s in t=this._events)e.call(t,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=i?i+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,n=s.length,a=new Array(n);r<n;r++)a[r]=s[r].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,s=this._events[e];return s?s.fn?1:s.length:0},o.prototype.emit=function(t,e,s,r,n,a){var o=i?i+t:t;if(!this._events[o])return!1;var h,l,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,s),!0;case 4:return d.fn.call(d.context,e,s,r),!0;case 5:return d.fn.call(d.context,e,s,r,n),!0;case 6:return d.fn.call(d.context,e,s,r,n,a),!0}for(l=1,h=new Array(c-1);l<c;l++)h[l-1]=arguments[l];d.fn.apply(d.context,h)}else{var u,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(t,d[l].fn,void 0,!0),c){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,e);break;case 3:d[l].fn.call(d[l].context,e,s);break;case 4:d[l].fn.call(d[l].context,e,s,r);break;default:if(!h)for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];d[l].fn.apply(d[l].context,h)}}return!0},o.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,s,r){var n=i?i+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||r&&!o.once||s&&o.context!==s||a(this,n);else{for(var h=0,l=[],d=o.length;h<d;h++)(o[h].fn!==e||r&&!o[h].once||s&&o[h].context!==s)&&l.push(o[h]);l.length?this._events[n]=1===l.length?l[0]:l:a(this,n)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(z);var Y=B(z.exports);let F=class extends Y{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}};var I={setEventEmitter(t,e){return void 0===e&&(e=F),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):[]}},X=function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,n=i,a=0;a<s.length;a++){if(e=s[a],!r.hasOwnProperty(e)){n=i;break}r=n=r[e]}return n};const G=["next","exit","enter"];let V=class{constructor(t){var e=X(t,"states",void 0);e&&this.addStates(e);var i=X(t,"extend",void 0);if(i)for(var s in i)this.hasOwnProperty(s)&&void 0!==this[s]||(this[s]=i[s]);var r=X(t,"eventEmitter",void 0),n=X(t,"EventEmitterClass",void 0);this.setEventEmitter(r,n),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(X(t,"enable",!0)),this.start(X(t,"start",void 0));var e=X(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,i=this[e];i&&i.call(this),this.emit(e,this)}if(this._stateLock=!1,null!=this._state){var s="enter_"+this._state,r=this[s];r&&r.call(this),this.emit(s,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 i=this.stateProperties,s=0,r=i.length;s<r;s++){var n=i[s],a=e[n];a&&(this[`${n}_${t}`]=a)}return this}addStates(t){if(Array.isArray(t))for(var e=0,i=t.length;e<i;e++)this.addState(t[e]);else for(var s in t)this.addState(s,t[s]);return this}runMethod(t,e,i,s,r,n){var a=this[t+"_"+this.state];if(a){var o=arguments.length;switch(o){case 1:return a.call(this);case 2:return a.call(this,e);case 3:return a.call(this,e,i);case 4:return a.call(this,e,i,s);case 5:return a.call(this,e,i,s,r);case 6:return a.call(this,e,i,s,r,n)}for(var h=new Array(o-1),l=1;l<o;l++)h[l-1]=arguments[l];return a.apply(this,h)}}};Object.assign(V.prototype,I);var H=function(t,e,i,s,r){void 0===r&&(r=!1);var n=t._events[e];if(!n)return!1;for(var a=0,o=n.length;a<o;a++){var h=n[a];if(h.fn===i&&h.context===s&&h.once===r)return!0}return!1};const N=["next","exit","enter","update","preupdate","postupdate"];class U extends V{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=X(t,"scene",void 0),this}get stateProperties(){return N}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 H(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 H(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 H(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}}const $=Phaser.Utils.Objects.GetValue,K=Phaser.Math.Distance.Between;class Z extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.stop(),i.tapsCount=0,i.x=0,i.y=0,i.worldX=0,i.worldY=0,i.lastPointer=void 0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.start(),i.tapsCount=0,i.emit("tappingstart",i,i.gameObject,i.lastPointer)}},RECOGNIZED:{enter:function(){i.start(),i.emit("tap",i,i.gameObject,i.lastPointer),i.emit(`${i.tapsCount}tap`,i,i.gameObject,i.lastPointer)}}},init:function(){this.state=J},eventEmitter:!1};this.setRecongizedStateObject(new U(s))}resetFromJSON(t){super.resetFromJSON(t),this.setHoldTime($(t,"time",250)),this.setTapInterval($(t,"tapInterval",200)),this.setDragThreshold($(t,"threshold",9)),this.setTapOffset($(t,"tapOffset",10));var e=$(t,"taps",void 0);return void 0!==e?this.setTaps(e):(this.setMaxTaps($(t,"maxTaps",void 0)),this.setMinTaps($(t,"minTaps",void 0))),this}onDragStart(){switch(this.state){case J:this.state=q;break;case q:var t=this.lastPointer;K(t.upX,t.upY,t.x,t.y)>this.tapOffset&&(this.state=Q,this.state=q);break;case Q:this.state=q}}onDragEnd(){this.state===q&&(this.tapsCount++,this.emit("tapping",this,this.gameObject,this.lastPointer),void 0!==this.maxTaps&&this.tapsCount===this.maxTaps&&(this.state=Q))}onDrag(){this.state!==J&&this.pointer.getDistance()>this.dragThreshold&&(this.state=J)}preUpdate(t,e){if(this.isRunning&&this.enable&&this.state===q){var i=this.lastPointer;i.isDown?t-i.downTime>this.holdTime&&(this.state=J):t-i.upTime>this.tapInterval&&(void 0===this.minTaps||this.tapsCount>=this.minTaps?this.state=Q:this.state=J)}}postUpdate(t,e){this.isRunning&&this.enable&&this.state===Q&&(this.state=J)}get isTapping(){return this.state===Q}get isTapped(){return this.isTapping}setHoldTime(t){return this.holdTime=t,this}setTapInterval(t){return this.tapInterval=t,this}setDragThreshold(t){return this.dragThreshold=t,this}setTapOffset(t){return this.tapOffset=t,this}setMaxTaps(t){return this.maxTaps=t,this}setMinTaps(t){return this.minTaps=t,this}setTaps(t,e){return void 0===e&&(e=t),this.setMinTaps(t).setMaxTaps(e),this}}const J="IDLE",q="BEGIN",Q="RECOGNIZED",tt=Phaser.Utils.Objects.GetValue;class et extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.x=0,i.y=0,i.worldX=0,i.worldY=0,i.lastPointer=void 0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.start()},exit:function(){i.stop()}},RECOGNIZED:{enter:function(){i.emit("pressstart",i,i.gameObject,i.lastPointer)},exit:function(){i.emit("pressend",i,i.gameObject,i.lastPointer)}}},init:function(){this.state=it},eventEmitter:!1};this.setRecongizedStateObject(new U(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(tt(t,"threshold",9)),this.setHoldTime(tt(t,"time",251)),this}onDragStart(){this.state=st,0===this.holdTime&&(this.state=rt)}onDragEnd(){this.state=it}onDrag(){this.state!==it&&this.pointer.getDistance()>this.dragThreshold&&(this.state=it)}preUpdate(t,e){this.isRunning&&this.enable&&this.state===st&&t-this.pointer.downTime>=this.holdTime&&(this.state=rt)}get isPressing(){return this.state===rt}get isPressed(){return this.isPressing}setHoldTime(t){return this.holdTime=t,this}setDragThreshold(t){return this.dragThreshold=t,this}}const it="IDLE",st="BEGIN",rt="RECOGNIZED",nt=Phaser.Utils.Objects.GetValue;class at extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{},BEGIN:{enter:function(){var t=i.pointer;i.startX=t.x,i.startY=t.y,i.startWorldX=t.worldX,i.startWorldY=t.worldY}},RECOGNIZED:{enter:function(){i.emit("panstart",i,i.gameObject,i.lastPointer)},exit:function(){var t=i.lastPointer;i.endX=t.x,i.endY=t.y;var e=E(t,i.pointerCamera,!0);i.endWorldX=e.x,i.endWorldY=e.y,i.emit("panend",i,i.gameObject,i.lastPointer)}}},init:function(){this.state=ot},eventEmitter:!1};this.setRecongizedStateObject(new U(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(nt(t,"threshold",10)),this}onDragStart(){this.state=ht,0===this.dragThreshold&&(this.state=lt)}onDragEnd(){this.state=ot}onDrag(){switch(this.state){case ht:if(this.pointer.getDistance()>=this.dragThreshold){this.state=lt,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 lt:var e=this.pointerCamera,i=this.pointer.position,s=this.pointer.prevPosition;this.dx=i.x-s.x,this.dy=i.y-s.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 r=E(t,e,!0);this.worldX=r.x,this.worldY=r.y,this.emit("pan",this,this.gameObject,this.lastPointer)}}get isPanning(){return this.state===lt}get isPanned(){return this.isPanning}setDragThreshold(t){return this.dragThreshold=t,this}}const ot="IDLE",ht="BEGIN",lt="RECOGNIZED";var dt=function(t){return o(t).loop.delta};const ct=Phaser.Math.Distance.Between,ut=Phaser.Math.Angle.Between;var pt={getDt:function(){return dt(this.scene)},getVelocity:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return ct(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 ut(e.x,e.y,t.x,t.y)}},gt={"up&down":0,"left&right":1,"4dir":2,"8dir":3},vt={};const ft=Phaser.Utils.Objects.GetValue,mt=Phaser.Math.RadToDeg;class yt extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.x=0,i.y=0,i.worldX=0,i.worldY=0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.validDrag=!1}},RECOGNIZED:{enter:function(){i.start(),i.updateDirectionStates(),i.emit("swipe",i,i.gameObject,i.lastPointer)},exit:function(){i.stop(),i.clearDirectionStates()}}},init:function(){this.state=bt},eventEmitter:!1};this.setRecongizedStateObject(new U(s)),this.clearDirectionStates()}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(ft(t,"threshold",10)),this.setVelocityThreshold(ft(t,"velocityThreshold",1e3)),this.setDirectionMode(ft(t,"dir","8dir")),this}onDragStart(){this.state=xt}onDragEnd(){this.state=bt}onDrag(){this.state===xt&&(this.validDrag||(this.validDrag=0===this.dragThreshold||this.pointer.getDistance()>=this.dragThreshold),this.validDrag&&this.dragVelocity>this.velocityThreshold&&(this.state=Ct))}postUpdate(t,e){this.isRunning&&this.enable&&this.state===Ct&&(this.state=bt)}get isSwiping(){return this.state===Ct}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=gt[t]),this.dirMode=t,this}updateDirectionStates(){return function(t,e,i){switch(void 0===i?i={}:!0===i&&(i=vt),i.left=!1,i.right=!1,i.up=!1,i.down=!1,t=(t+360)%360,e){case 0:t<180?i.down=!0:i.up=!0;break;case 1:t>90&&t<=270?i.left=!0:i.right=!0;break;case 2:t>45&&t<=135?i.down=!0:t>135&&t<=225?i.left=!0:t>225&&t<=315?i.up=!0:i.right=!0;break;case 3:t>22.5&&t<=67.5?(i.down=!0,i.right=!0):t>67.5&&t<=112.5?i.down=!0:t>112.5&&t<=157.5?(i.down=!0,i.left=!0):t>157.5&&t<=202.5?i.left=!0:t>202.5&&t<=247.5?(i.left=!0,i.up=!0):t>247.5&&t<=292.5?i.up=!0:t>292.5&&t<=337.5?(i.up=!0,i.right=!0):i.right=!0}}(mt(this.getVelocityAngle()),this.dirMode,this),this}clearDirectionStates(){return this.left=!1,this.right=!1,this.up=!1,this.down=!1,this}}Object.assign(yt.prototype,pt);const bt="IDLE",xt="BEGIN",Ct="RECOGNIZED";var wt=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 St=Phaser.Utils.Objects.GetValue,Ot=Phaser.Utils.Array.SpliceOne,kt=Phaser.Math.Distance.Between,Pt=Phaser.Math.Angle.Between;class Tt{constructor(t,e){var i=r(t);i===t&&(t=void 0);var s=i.input.manager.pointersTotal-1;s<2&&i.input.addPointer(2-s),this.scene=i,this.gameObject=t,t&&t.setInteractive(St(e,"inputConfig",void 0)),this.setEventEmitter(St(e,"eventEmitter",void 0)),this._enable=void 0,this.pointers=[],this.movedState={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(St(t,"enable",!0)),this.bounds=St(t,"bounds",void 0),this.tracerState=Et,this.pointers.length=0,wt(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,wt(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 Et:this.tracerState=Mt,this.onDrag1Start();break;case Mt:this.tracerState=Rt,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],Ot(this.pointers,e),this.tracerState){case Mt:this.tracerState=Et,this.onDrag1End();break;case Rt: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),i=-1!==this.pointers.indexOf(t);if(!i&&e);else if(i&&!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 Rt:this.onDrag2()}}}dragCancel(){return this.tracerState===Rt&&this.onDrag2End(),this.pointers.length=0,wt(this.movedState),this.tracerState=Et,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!==Rt)return 0;var t=this.pointers[0],e=this.pointers[1];return kt(t.x,t.y,e.x,e.y)}get angleBetween(){if(this.tracerState!==Rt)return 0;var t=this.pointers[0],e=this.pointers[1];return Pt(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,i=t.prevPosition;_t.x=e.x-i.x,_t.y=e.y-i.y}else _t.x=0,_t.y=0;return _t}get centerX(){if(this.tracerState!==Rt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.x+e.x)/2}get centerY(){if(this.tracerState!==Rt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.y+e.y)/2}get prevCenterX(){if(this.tracerState!==Rt)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!==Rt)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=Lt,this}isPointer0InGameObject(t,e,i){var s=this.pointers[0];return!!s&&R(t,s,e,i)}isPointer1InGameObject(t,e,i){var s=this.pointers[1];return!!s&&R(t,s,e,i)}}Object.assign(Tt.prototype,e);var _t={};const Et=0,Mt=1,Rt=2,Lt="IDLE",Dt=Phaser.Utils.Objects.GetValue;class At extends Tt{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.prevDistance=void 0,i.scaleFactor=1}},BEGIN:{},RECOGNIZED:{enter:function(){i.emit("pinchstart",i)},exit:function(){i.emit("pinchend",i)}}},init:function(){this.state=Wt},eventEmitter:!1};this.setRecongizedStateObject(new U(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(Dt(t,"threshold",0)),this}onDrag2Start(){this.scaleFactor=1,this.prevDistance=this.distanceBetween,this.state=jt,0===this.dragThreshold&&(this.state=Bt)}onDrag2End(){this.state=Wt}onDrag2(){switch(this.state){case jt: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=Bt}break;case Bt:t=this.distanceBetween,this.scaleFactor=t/this.prevDistance,this.emit("pinch",this),this.prevDistance=t}}get isPinching(){return this.state===Bt}get isPinched(){return this.isPinching}setDragThreshold(t){return this.dragThreshold=t,this}}const Wt="IDLE",jt="BEGIN",Bt="RECOGNIZED",zt=Phaser.Math.RotateAround;var Yt=function(t,e,i,s){return zt(t,e,i,s),t.rotation+=s,t},Ft={};const It=Phaser.Utils.Objects.GetValue,Xt=Phaser.Math.Angle.WrapDegrees,Gt=Phaser.Math.Angle.ShortestBetween,Vt=Phaser.Math.RadToDeg,Ht=Phaser.Math.DegToRad;var Nt={spinObject:function(t,e){if(!this.isRotation)return this;void 0===e&&(e=this.pointers[0].camera);var i=this.movementCenterX,s=this.movementCenterY,r=function(t,e,i,s){return void 0===s?s={}:!0===s&&(s=Ft),i.getWorldPoint(t,e,s),s}(this.centerX,this.centerY,e,!0),n=r.x,a=r.y,o=this.rotation;if(Array.isArray(t))for(var h=t,l=0,d=h.length;l<d;l++)(t=h[l]).x+=i,t.y+=s,Yt(t,n,a,o);else t.x+=i,t.y+=s,Yt(t,n,a,o);return this}};Object.assign(class extends Tt{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.prevAngle=void 0,i.angle=0}},BEGIN:{},RECOGNIZED:{enter:function(){i.emit("rotatestart",i)},exit:function(){i.emit("rotateend",i)}}},init:function(){this.state=Ut},eventEmitter:!1};this.setRecongizedStateObject(new U(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(It(t,"threshold",0)),this}onDrag2Start(){this.prevAngle=Xt(Vt(this.angleBetween)),this.state=$t,0===this.dragThreshold&&(this.state=Kt)}onDrag2End(){this.state=Ut}onDrag2(){switch(this.state){case $t:if(this.pointers[0].getDistance()>=this.dragThreshold&&this.pointers[1].getDistance()>=this.dragThreshold){var t=Xt(Vt(this.angleBetween));this.angle=Gt(this.prevAngle,t),this.prevAngle=t,this.state=Kt}break;case Kt:t=Xt(Vt(this.angleBetween)),this.angle=Gt(this.prevAngle,t),this.prevAngle=t,this.emit("rotate",this)}}get isRotating(){return this.state===Kt}get isRotated(){return this.isRotating}get rotation(){return Ht(this.angle)}setDragThreshold(t){return this.dragThreshold=t,this}}.prototype,Nt);const Ut="IDLE",$t="BEGIN",Kt="RECOGNIZED";var Zt=function(t,e){var i,s=t.cameras;if(void 0===e)i=s.main;else switch(typeof e){case"string":i=s.getCamera(e);break;case"number":i=s.cameras[e];break;default:i=e}return i};const Jt=Phaser.Utils.Objects.GetValue;class qt extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=Jt(e,"inputTarget",t),this.pan=new at(this.inputTarget);var i=Zt(t,Jt(e,"camera"));this.setCamera(i).setEnable(Jt(e,"enable",!0)),this.boot()}boot(){this.pan.on("pan",(function(t){var e=this.camera;if(e){var i=e.zoom;e.scrollX-=t.dx/i,e.scrollY-=t.dy/i}}),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 Qt=Phaser.Utils.Objects.GetValue;class te extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=Qt(e,"inputTarget",t),this.pinch=new At(this.inputTarget);var i=Zt(t,Qt(e,"camera"));this.setCamera(i).setEnable(Qt(e,"enable",!0)).setMinZoom(Qt(e,"minZoom",void 0)).setMaxZoom(Qt(e,"maxZoom",void 0)).setFocusEnable(Qt(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],i=t.pointers[1];this.focusEnable&&void 0===this.focusWorldX&&(this.focusWorldX=.5*(e.worldX+i.worldX),this.focusWorldY=.5*(e.worldY+i.worldY)),this.emit("pinchstart")}),this).on("pinch",(function(t){var e=this.camera;if(e){var i=e.zoom*t.scaleFactor;if(void 0!==this.minZoom&&i<this.minZoom&&(i=this.minZoom),void 0!==this.maxZoom&&i>this.maxZoom&&(i=this.maxZoom),e.zoom=i,e.preRender(),this.focusEnable){var s=t.pointers[0],r=t.pointers[1],n=.5*(s.x+r.x),a=.5*(s.y+r.y),o=e.getWorldPoint(n,a);e.scrollX-=o.x-this.focusWorldX,e.scrollY-=o.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 ee=Phaser.Input.Keyboard.Key,ie=Phaser.Input.Keyboard.KeyCodes,se=["up","down","left","right"];class re{constructor(t){this.scene=t,this.keys={},this.cursorKeys={},this.noKeyDown=!0;for(var e=0,i=se.length;e<i;e++){var s=se[e];this.addKey(s),this.cursorKeys[s]=this.keys[s]}}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 i=this.keys[t];return i.enabled?(e&&(this.noKeyDown=!1),i.isDown!==e&&(ne.timeStamp=Date.now(),ne.keyCode=i.keyCode,e?i.onDown(ne):i.onUp(ne)),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(),ie.hasOwnProperty(e)&&(e=ie[e])),this.keys[t]=new ee(this.scene,e),this}addKeys(t){for(var e=0,i=t.length;e<i;e++)this.addKey(t[e]);return this}}var ne={timeStamp:0,keyCode:0,altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,location:0};const ae=Phaser.Cameras.Scene2D.BaseCamera,oe=Phaser.Geom.Rectangle;var he=function(t,e,i){return e instanceof ae||(i=e,e=void 0),void 0===i?i=new oe:!0===i&&(i=le),e?t.scale.getViewPort(e,i):t.scale.getViewPort(i)},le=new oe;const de=Phaser.Utils.Objects.GetValue;class ce extends re{constructor(t,e){super(t),this.scene=t,this._enable=void 0,this.setEnable(de(e,"enable",!0)),this.setSensitiveDistance(de(e,"sensitiveDistance",20));var i=de(e,"bounds",void 0);void 0===i?(i=he(t),this.autoUpdateViewportBounds=!0):this.autoUpdateViewportBounds=!1,this.setBounds(i),this.pointerOutGameReleaseEnable=de(e,"pointerOutGameRelease",!0),this.pointerOutBoundsReleaseEnable=de(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(){he(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,i=t.y,s=this.bounds.left,r=this.bounds.right,n=this.bounds.top,a=this.bounds.bottom,o=this.sensitiveDistance,h=e>=s&&e<=s+o,l=e<=r&&e>=r-o,d=i>=n&&i<=n+o,c=i<=a&&i>=a-o;this.pointerOutBoundsReleaseEnable||(h|=e<s,l|=e>r,d|=i<n,c|=i>a),this.setKeyState("left",h),this.setKeyState("right",l),this.setKeyState("up",d),this.setKeyState("down",c)}}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 ue=Phaser.Utils.Objects.GetValue;class pe extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.cursorAtBounds=new ce(t);var i=this.cursorAtBounds.createCursorKeys();this.cameraController=new Phaser.Cameras.Controls.SmoothedKeyControl({left:i.left,right:i.right,up:i.up,down:i.down,acceleration:.06,drag:.003,maxSpeed:.3});var s=Zt(t,ue(e,"camera"));this.setCamera(s).setEnable(ue(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 ge=Phaser.Utils.Objects.GetValue;class ve extends c{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=ge(e,"tickEventName",i),this.isSceneTicker=!fe(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 fe=function(t){return"step"===t||"poststep"===t};const me=Phaser.Utils.Objects.GetValue,ye=Phaser.Math.Clamp;class be{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=me(t,"state",xe),this.timeScale=me(t,"timeScale",1),this.delay=me(t,"delay",0),this.repeat=me(t,"repeat",0),this.repeatCounter=me(t,"repeatCounter",0),this.repeatDelay=me(t,"repeatDelay",0),this.duration=me(t,"duration",0),this.nowTime=me(t,"nowTime",0),this.justRestart=me(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?we:Ce,this.repeatCounter=0,this}stop(){return this.state=xe,this}update(t,e){this.state!==xe&&this.state!==Oe&&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=Se)):(this.nowTime=this.duration,this.state=Oe):this.nowTime>=0&&(this.state=we))}get t(){var t;switch(this.state){case xe:case Ce:case Se:t=0;break;case we:t=this.nowTime/this.duration;break;case Oe:t=1}return ye(t,0,1)}set t(t){(t=ye(t,-1,1))<0?(this.state=Ce,this.nowTime=-this.delay*t):(this.state=we,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===xe}get isDelay(){return this.state===Ce}get isCountDown(){return this.state===we}get isRunning(){return this.state===Ce||this.state===we}get isDone(){return this.state===Oe}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const xe=0,Ce=1,we=2,Se=3,Oe=-1;class ke extends ve{constructor(t,e){super(t,e),this.timer=new be}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 Pe=Phaser.Utils.Objects.GetValue,Te=Phaser.Utils.Objects.GetAdvancedValue,_e=Phaser.Tweens.Builders.GetEaseFunction;class Ee extends ke{resetFromJSON(t){return this.timer.resetFromJSON(Pe(t,"timer")),this.setEnable(Pe(t,"enable",!0)),this.setTarget(Pe(t,"target",this.parent)),this.setDelay(Te(t,"delay",0)),this.setDuration(Te(t,"duration",1e3)),this.setEase(Pe(t,"ease","Linear")),this.setRepeat(Pe(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=_e(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 i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateTarget(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}updateTarget(t,e){}}const Me=Phaser.Math.Linear;class Re extends Ee{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 i=this.parent;!function(t,e,i,s){if(void 0!==i){var r=t.getWorldPoint(i,s);t.zoom=e,t.preRender();var n=t.getWorldPoint(i,s);t.scrollX-=n.x-r.x,t.scrollY-=n.y-r.y}else t.zoom=e}(t,Me(this.startZoomValue,this.endZoomValue,e.t),i.focusLocalX,i.focusLocalY)}}const Le=Phaser.Utils.Objects.GetValue;Phaser.Math.Clamp;class De extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.easeZoom=new Re(this);var i=Zt(t,Le(e,"camera"));this.setEnable(Le(e,"enable",!0)).setMinZoom(Le(e,"minZoom")).setMaxZoom(Le(e,"maxZoom")).setZoomStep(Le(e,"zoomStep",.1)).setEaseDuration(Le(e,"easeDuration",200)).setCamera(i),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(Ae(t.zoom,this.zoomStep)),this.zoom=t.zoom,this):(this.zoomLevel=void 0,this)}onWheel(t,e,i,s,r,n){var a=this.camera;if(this.enable&&a){var o=void 0!==this.minZoom,h=void 0!==this.maxZoom;o&&this.zoom<=this.minZoom&&s>0||h&&this.zoom>=this.maxZoom&&s<0||(this.zoomLevel+=s<0?1:-1,this.zoom=We(this.zoomLevel,this.zoomStep),o&&this.zoom<this.minZoom&&(this.zoom=this.minZoom),h&&this.zoom>this.maxZoom&&(this.zoom=this.maxZoom),this.focusLocalX=t.x,this.focusLocalY=t.y,this.easeZoom.start(this.zoom))}}}var Ae=function(t,e){return t>=1?Math.log(t)/Math.log(1+e):-Math.log(t)/Math.log(1-e)},We=function(t,e){return t>=0?Math.pow(1+e,t):Math.pow(1-e,-t)};function je(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>je(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 i in t)t.hasOwnProperty(i)&&(e[i]=je(t[i]));return e}const Be=Phaser.Utils.Objects.GetValue;class ze extends l{constructor(t,e){super(t,e=void 0===e?{}:je(e)),this._enable=!0,this._camera=void 0;var i,s=Be(e,"minZoom"),r=Be(e,"maxZoom");Be(e,"boundsScroll",!0)&&(this.boundsScroll=new pe(t,{camera:Be(e,"camera"),enable:Be(e,"boundsScrollEnable",!0)})),Be(e,"mouseWheelZoom",!0)&&(this.mouseWheelZoom=new De(t,{camera:Be(e,"camera"),enable:Be(e,"mouseWheelZoomEnable",!0),zoomStep:Be(e,"mouseWheelZoomStep",.1),minZoom:Be(e,"mouseWheelZoomMin",s),maxZoom:Be(e,"mouseWheelZoomMax",r)})),Be(e,"pinchZoom",!0)&&(this.pinchZoom=new te(t,{camera:Be(e,"camera"),inputTarget:Be(e,"inputTarget",t),enable:Be(e,"pinchZoomEnable",!0),minZoom:Be(e,"pinchZoomMin",s),maxZoom:Be(e,"pinchZoomMax",r),focusEnable:Be(e,"pinchZoomFocusEnable",!0)})),Be(e,"panScroll",!0)&&(this.panScroll=new qt(t,{camera:Be(e,"camera"),inputTarget:Be(e,"inputTarget",t),enable:Be(e,"panScrollEnable",!0)})),this.setEnable(Be(e,"enable",!0)),this.pinchZoom&&this.panScroll&&this.pinchZoom.on("pinchstart",(function(){i=this.panScroll.enable,this.panScroll.setEnable(!1)}),this).on("pinchend",(function(){this.panScroll.setEnable(i)}),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