UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 41.2 kB
var t,e;t=void 0,e=function(){var t={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const e=Phaser.Scene;var s=function(t){return t instanceof e},i=function(t){return null==t||"object"!=typeof t?null:s(t)?t:t.scene&&s(t.scene)?t.scene:t.parent&&t.parent.scene&&s(t.parent.scene)?t.parent.scene:null};const r=Phaser.Game;var n=function(t){return t instanceof r};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){var e;return this.parent=t,this.scene=i(t),this.game=null==(e=t)||"object"!=typeof e?null:n(e)?e:n(e.game)?e.game:s(e)?e.sys.game:s(e.scene)?e.scene.sys.game:void 0,this}}function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(a.prototype,t);var c={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}function r(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function n(t,e,i,n,h){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new r(i,n||t,h),o=s?s+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],a]:t._events[o].push(a):(t._events[o]=a,t._eventsCount++),t}function h(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),a.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.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 r=0,n=i.length,h=new Array(n);r<n;r++)h[r]=i[r].fn;return h},a.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},a.prototype.emit=function(t,e,i,r,n,h){var a=s?s+t:t;if(!this._events[a])return!1;var o,c,l=this._events[a],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,i),!0;case 4:return l.fn.call(l.context,e,i,r),!0;case 5:return l.fn.call(l.context,e,i,r,n),!0;case 6:return l.fn.call(l.context,e,i,r,n,h),!0}for(c=1,o=new Array(d-1);c<d;c++)o[c-1]=arguments[c];l.fn.apply(l.context,o)}else{var u,p=l.length;for(c=0;c<p;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,i);break;case 4:l[c].fn.call(l[c].context,e,i,r);break;default:if(!o)for(u=1,o=new Array(d-1);u<d;u++)o[u-1]=arguments[u];l[c].fn.apply(l[c].context,o)}}return!0},a.prototype.on=function(t,e,s){return n(this,t,e,s,!1)},a.prototype.once=function(t,e,s){return n(this,t,e,s,!0)},a.prototype.removeListener=function(t,e,i,r){var n=s?s+t:t;if(!this._events[n])return this;if(!e)return h(this,n),this;var a=this._events[n];if(a.fn)a.fn!==e||r&&!a.once||i&&a.context!==i||h(this,n);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==e||r&&!a[o].once||i&&a[o].context!==i)&&c.push(a[o]);c.length?this._events[n]=1===c.length?c[0]:c:h(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&h(this,e)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=s,a.EventEmitter=a,t.exports=a}(c);var l=o(c.exports);class d extends l{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var u={setEventEmitter(t,e){return void 0===e&&(e=d),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):[]}},p=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,r=t,n=s,h=0;h<i.length;h++){if(e=i[h],!r.hasOwnProperty(e)){n=s;break}r=n=r[e]}return n};const v=["next","exit","enter"];let m=class{constructor(t){var e=p(t,"states",void 0);e&&this.addStates(e);var s=p(t,"extend",void 0);if(s)for(var i in s)this.hasOwnProperty(i)&&void 0!==this[i]||(this[i]=s[i]);var r=p(t,"eventEmitter",void 0),n=p(t,"EventEmitterClass",void 0);this.setEventEmitter(r,n),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(p(t,"enable",!0)),this.start(p(t,"start",void 0));var e=p(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,r=this[i];r&&r.call(this),this.emit(i,this)}}}get state(){return this._state}get prevState(){return this._prevState}start(t){return this._start=t,this._prevState=void 0,this._state=t,this}goto(t){return null!=t&&(this.state=t),this}next(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}get stateProperties(){return v}addState(t,e){"string"!=typeof t&&(t=(e=t).name);for(var s=this.stateProperties,i=0,r=s.length;i<r;i++){var n=s[i],h=e[n];h&&(this[`${n}_${t}`]=h)}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,r,n){var h=this[t+"_"+this.state];if(h){var a=arguments.length;switch(a){case 1:return h.call(this);case 2:return h.call(this,e);case 3:return h.call(this,e,s);case 4:return h.call(this,e,s,i);case 5:return h.call(this,e,s,i,r);case 6:return h.call(this,e,s,i,r,n)}for(var o=new Array(a-1),c=1;c<a;c++)o[c-1]=arguments[c];return h.apply(this,o)}}};Object.assign(m.prototype,u);var b=function(t,e,s,i,r){void 0===r&&(r=!1);var n=t._events[e];if(!n)return!1;for(var h=0,a=n.length;h<a;h++){var o=n[h];if(o.fn===s&&o.context===i&&o.once===r)return!0}return!1};const f=["next","exit","enter","update","preupdate","postupdate"];class g extends m{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=p(t,"scene",void 0),this}get stateProperties(){return f}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 b(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 b(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 b(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}stopPostUpdate(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}class y extends g{constructor(t,e){super(e),this.bejeweled=t,this.boardWrapper=t.boardWrapper,this.waitEvents=t.waitEvents}shutdown(){super.shutdown(),this.bejeweled=void 0,this.boardWrapper=void 0,this.waitEvents=void 0}destroy(){return this.shutdown(),this}next(){this.waitEvents.noWaitEvent?super.next():this.waitEvents.setCompleteCallback(this.next,this)}}const E=Phaser.Utils.Objects.GetValue;class w extends a{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(E(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=T[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 T={no:0,lazy:1,always:2},C=Phaser.Utils.Objects.GetValue;class S extends w{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=C(e,"tickEventName",s),this.isSceneTicker=!_(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 _=function(t){return"step"===t||"poststep"===t};const A=Phaser.Utils.Objects.GetValue,x=Phaser.Math.Clamp;class k{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=A(t,"state",P),this.timeScale=A(t,"timeScale",1),this.delay=A(t,"delay",0),this.repeat=A(t,"repeat",0),this.repeatCounter=A(t,"repeatCounter",0),this.repeatDelay=A(t,"repeatDelay",0),this.duration=A(t,"duration",0),this.nowTime=A(t,"nowTime",0),this.justRestart=A(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?M:j,this.repeatCounter=0,this}stop(){return this.state=P,this}update(t,e){this.state!==P&&this.state!==D&&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=R)):(this.nowTime=this.duration,this.state=D):this.nowTime>=0&&(this.state=M))}get t(){var t;switch(this.state){case P:case j:case R:t=0;break;case M:t=this.nowTime/this.duration;break;case D:t=1}return x(t,0,1)}set t(t){(t=x(t,-1,1))<0?(this.state=j,this.nowTime=-this.delay*t):(this.state=M,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===P}get isDelay(){return this.state===j}get isCountDown(){return this.state===M}get isRunning(){return this.state===j||this.state===M}get isDone(){return this.state===D}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const P=0,j=1,M=2,R=3,D=-1;class L extends S{constructor(t,e){super(t,e),this.timer=new k}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 O=Phaser.Utils.Objects.GetValue,W=Phaser.Utils.Objects.GetAdvancedValue,X=Phaser.Tweens.Builders.GetEaseFunction;class Y extends L{resetFromJSON(t){return this.timer.resetFromJSON(O(t,"timer")),this.setEnable(O(t,"enable",!0)),this.setTarget(O(t,"target",this.parent)),this.setDelay(W(t,"delay",0)),this.setDuration(W(t,"duration",1e3)),this.setEase(O(t,"ease","Linear")),this.setRepeat(O(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=X(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 N=Phaser.Utils.Objects.GetValue,I=Phaser.Utils.Objects.GetAdvancedValue,G=Phaser.Math.Linear;class Z extends Y{constructor(t,e){super(t,e),this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(N(t,"mode",0)),this.setAlphaRange(I(t,"start",this.parent.alpha),I(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=F[t]),this.mode=t,this}setAlphaRange(t,e){return this.alphaStart=t,this.alphaEnd=e,this}start(){return this.timer.isRunning||(this.parent.setAlpha(this.alphaStart),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(2===this.mode?-1:0),super.start()),this}updateTarget(t,e){var s=e.t;e.isOddIteration&&(s=1-s),t.alpha=G(this.alphaStart,this.alphaEnd,s)}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}}const F={stop:0,destroy:1,yoyo:2};var B=function(t,e,s,i){s instanceof Z&&(i=s,s=void 0),void 0===s&&(s=!0);var r={mode:s?1:0,end:0,duration:e};return void 0===i?i=new Z(t,r):i.resetFromJSON(r),i.restart(),i},U=function(t,e,s){for(var i=0,r=t.length;i<r;i++){var n=B(t[i],500);s.waitEvent(n,"complete")}},V=function(t,e,s){void 0===s&&(s=e>=t?1:-1);var i=[];if(s>0)for(var r=t;r<e;r+=s)i.push(r);else if(s<0)for(r=t;r>e;r+=s)i.push(r);return i};const H={right:0,down:1,left:2,up:3},J=[{loopType:"xy",startX:-2,endX:0,startY:1,endY:-2},{loopType:"yx",startX:1,endX:-2,startY:-2,endY:0},{loopType:"xy",startX:1,endX:-1,startY:1,endY:-2},{loopType:"yx",startX:1,endX:-2,startY:1,endY:-1}];var z=function(t,e,s){var{loopType:i,startX:r,endX:n,startY:h,endY:a}=J[t];r<0&&(r=e.width+r),n<0&&(n=e.width+n),h<0&&(h=e.width+h),a<0&&(a=e.width+a);var o=n>=r?1:-1,c=a>=h?1:-1,l=V(r,n+o,o),d=V(h,a+c,c),u=s.getChessTileZ();"xy"===i?l.forEach((function(i){d.forEach((function(r){K(s,e,i,r,u,t)}))})):d.forEach((function(i){l.forEach((function(r){K(s,e,r,i,u,t)}))}))},K=function(t,e,s,i,r,n){var h=e.tileXYZToChess(s,i,r);if(null!==h){var a=t.getChessMoveTo(h);a.moveToward(n),a.isRunning&&t.waitEvent(a,"complete")}},$=function(t){return t&&"function"==typeof t.then};const q=Phaser.Utils.Objects.GetValue,Q=Phaser.Structs.Set;let tt=class extends y{constructor(t,e){super(t,e),this.totalMatchedLinesCount=0,this.eliminatedPieceArray=void 0,this.continueFilling=!1,this.eliminatingAction=q(e,"eliminatingAction",U),this.movingAction=q(e,"movingAction",z),q(e,"debug",!1)&&this.on("statechange",this.printState,this)}shutdown(){return super.shutdown(),this.eliminatedPieceArray=void 0,this.eliminatingAction=void 0,this.movingAction=void 0,this}destroy(){return this.shutdown(),this}setEliminatedPieces(t){return this.eliminatedPieceArray=t,this}getEliminatedPieces(){return this.eliminatedPieceArray}enter_START(){this.totalMatchedLinesCount=0,this.bejeweled.emit("match-start",this.boardWrapper.board,this.bejeweled),this.next()}next_START(){return this.getEliminatedPieces()?"ELIMINATING":"MATCH3"}enter_MATCH3(){var t=this.boardWrapper.getAllMatch();this.bejeweled.emit("match",t,this.boardWrapper.board,this.bejeweled);var e,s=t.length;switch(this.totalMatchedLinesCount+=s,s){case 0:e=[];break;case 1:e=t[0].entries;break;default:for(var i=new Q,r=0;r<s;r++)t[r].entries.forEach((function(t){i.set(t)}));e=i.entries}this.setEliminatedPieces(e),this.next()}next_MATCH3(){var t=this.getEliminatedPieces();return t&&0===t.length?"END":"ELIMINATING"}enter_ELIMINATING(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.getEliminatedPieces();this.bejeweled.emit("eliminate",s,t,e);var i=this.eliminatingAction(s,t,e);$(i)&&(e.waitEvent(e,"eliminate.complete"),i.then((function(){e.emit("eliminate.complete")}))),s.forEach(t.removeChess,t),this.next()}next_ELIMINATING(){return"FILLSTART"}exit_ELIMINATING(){this.setEliminatedPieces()}enter_FILLSTART(){var t=this.boardWrapper.board,e=this.bejeweled;this.bejeweled.emit("fill.start",t,e),this.next()}next_FILLSTART(){return"MOVING"}enter_MOVING(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.boardWrapper.movingDirection;this.bejeweled.emit("move",t,e);var i=this.movingAction(s,t,e);$(i)&&(e.waitEvent(e,"move.complete"),i.then((function(){e.emit("move.complete")}))),this.continueFilling=!this.waitEvents.noWaitEvent,this.next()}next_MOVING(){return this.continueFilling?"PREPARE":"FILLEND"}enter_PREPARE(){this.boardWrapper.board,this.bejeweled,this.boardWrapper.movingDirection,this.continueFilling=this.boardWrapper.fillPrepareRows(),this.bejeweled.emit("prepare",this.boardWrapper.board,this.bejeweled),this.next()}next_PREPARE(){return this.continueFilling?"MOVING":"FILLEND"}enter_FILLEND(){var t=this.boardWrapper.board,e=this.bejeweled;this.bejeweled.emit("fill.end",t,e),this.next()}next_FILLEND(){return"MATCH3"}enter_END(){this.bejeweled.emit("match-end",this.boardWrapper.board,this.bejeweled),this.emit("complete")}printState(){console.log("Match state: "+this.prevState+" -> "+this.state)}};const et=Phaser.Utils.Objects.GetValue,st=Phaser.Utils.Objects.GetAdvancedValue,it=Phaser.Math.Linear;class rt extends Y{constructor(t,e){super(t,e),this.scaleStart={},this.scaleEnd={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(et(t,"mode",0)),this.setScaleRange(st(t,"start",void 0),st(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=nt[t]),this.mode=t,this}setScaleRange(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=st(t,"x",this.parent.scaleX),this.startY=st(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=st(e,"x",void 0),this.endY=st(e,"y",void 0)),this.hasScaleX=void 0!==this.startX&&void 0!==this.endX,this.hasScaleY=void 0!==this.startY&&void 0!==this.endY,this}start(){if(this.timer.isRunning)return this;var t=this.parent;this.hasScaleX&&(t.scaleX=this.startX),this.hasScaleY&&(t.scaleY=this.startY);var e=this.repeat;return 2===this.mode&&-1!==e&&(e=2*(e+1)-1),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(e),super.start(),this}updateTarget(t,e){var s=e.t;e.isOddIteration&&(s=1-s),s=this.easeFn(s),this.hasScaleX&&(t.scaleX=it(this.startX,this.endX,s)),this.hasScaleY&&(t.scaleY=it(this.startY,this.endY,s))}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}}const nt={stop:0,destroy:1,yoyo:2};var ht=function(t,e,s,i,r){var n,h;switch(void 0===i&&(i="Cubic"),s){case 0:case"x":n={x:0},h={x:t.scaleX};break;case 1:case"y":n={y:0},h={y:t.scaleY};break;default:n=0,h=t.scale}var a={mode:0,start:n,end:h,duration:e,ease:i};return void 0===r?r=new rt(t,a):r.resetFromJSON(a),r.restart(),r},at=function(t,e,s){for(var i=0,r=t.length;i<r;i++){var n=ht(t[i],500);s.waitEvent(n,"complete")}},ot=function(t,e,s){},ct=function(t,e,s){},lt=function(t,e,s,i){var r=s.chessToTileXYZ(t),n=s.chessToTileXYZ(e),h=r.x,a=r.y,o=n.x,c=n.y,l=r.z;s.setChessTileZ(e,`#${l}`);var d=i.getChessMoveTo(t),u=i.getChessMoveTo(e);d.moveTo(o,c),u.moveTo(h,a),s.setChessTileZ(e,l),d.isRunning&&i.waitEvent(d,"complete"),u.isRunning&&i.waitEvent(u,"complete")};const dt=Phaser.Utils.Objects.GetValue;class ut extends y{constructor(t,e){super(t,e),this.selectedChess1,this.selectedChess2,this.pickedChess,this.matchState=new tt(t,e),this.placeAction=dt(e,"placeAction",at),this.select1Action=dt(e,"select1Action",ot),this.select2Action=dt(e,"select2Action",this.select1Action),this.pickAction=dt(e,"pickAction",ct),this.swapAction=dt(e,"swapAction",lt),this.undoSwapAction=dt(e,"undoSwapAction",this.swapAction),dt(e,"debug",!1)&&this.on("statechange",this.printState,this)}shutdown(){return super.shutdown(),this.matchState.shutdown(),this.matchState=void 0,this.selectedChess1=void 0,this.selectedChess2=void 0,this.pickedChess=void 0,this}enter_START(){this.boardWrapper.init(),this.next()}next_START(){return"RESET"}enter_RESET(){for(var t=this.boardWrapper,e=!1;!e;)t.reset(),e=t.preTest();t.fillPrepareRows(),this.next()}next_RESET(){return"PLACE"}enter_PLACE(){var t=this.boardWrapper.board,e=this.bejeweled;e.emit("place",t,e);var s=this.boardWrapper.getChessArray(),i=this.placeAction(s,t,e);$(i)&&(e.waitEvent(e,"place.complete"),i.then((function(){e.emit("place.complete")}))),this.next()}next_PLACE(){return"SELECT1START"}enter_SELECT1START(){this.selectedChess1=void 0,this.selectedChess2=void 0,this.pickedChess=void 0,this.bejeweled.emit("select1-start",this.boardWrapper.board,this.bejeweled)}selectChess1(t){return"SELECT1START"===this.state&&(this.selectedChess1=t,this.next()),this}next_SELECT1START(){var t;return this.selectedChess1&&(t="SELECT1"),t}enter_SELECT1(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.selectedChess1;this.bejeweled.emit("select1",s,t,e);var i=this.select1Action(s,t,e);$(i)&&(e.waitEvent(e,"select1.complete"),i.then((function(){e.emit("select1.complete")}))),this.next()}next_SELECT1(){return"SELECT2START"}enter_SELECT2START(){this.bejeweled.emit("select2-start",this.boardWrapper.board,this.bejeweled)}selectChess2(t){return"SELECT2START"===this.state&&(this.selectedChess2=t,this.next()),this}pickChess(t){return"SELECT2START"===this.state&&(this.pickedChess=t,this.next()),this}next_SELECT2START(){return this.pickedChess?"PICK":!!this.selectedChess2&&this.boardWrapper.board.getNeighborChessDirection(this.selectedChess1,this.selectedChess2)<4?"SELECT2":"SELECT1START"}enter_SELECT2(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.selectedChess2;this.bejeweled.emit("select2",s,t,e);var i=this.select2Action(s,t,e);$(i)&&(e.waitEvent(e,"select2.complete"),i.then((function(){e.emit("select2.complete")}))),this.next()}next_SELECT2(){return"SWAP"}enter_SWAP(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.selectedChess1,i=this.selectedChess2;this.bejeweled.emit("swap",s,i,t,e);var r=this.swapAction(s,i,t,e);$(r)&&(e.waitEvent(e,"swap.complete"),r.then((function(){e.emit("swap.complete")}))),this.next()}next_SWAP(){return"MATCH3"}enter_PICK(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.pickedChess;this.bejeweled.emit("pick",s,t,e);var i=this.pickAction(s,t,e);$(i)&&(e.waitEvent(e,"pick.complete"),i.then((function(){e.emit("pick.complete")}))),this.next()}setEliminatingChess(t){this.matchState.setEliminatedPieces(t)}next_PICK(){return"MATCH3"}enter_MATCH3(){this.matchState.once("complete",this.next,this).goto("START")}next_MATCH3(){return 0===this.matchState.totalMatchedLinesCount?"SWAP"===this.prevState?"UNDOSWAP":"SELECT1START":this.boardWrapper.preTest()?"SELECT1START":"RESET"}enter_UNDOSWAP(){var t=this.boardWrapper.board,e=this.bejeweled,s=this.selectedChess1,i=this.selectedChess2;this.bejeweled.emit("undo-swap",s,i,t,e);var r=this.undoSwapAction(s,i,t,e);$(r)&&(e.waitEvent(e,"undo-swap.complete"),r.then((function(){e.emit("undo-swap.complete")}))),this.next()}next_UNDOSWAP(){return"SELECT1START"}printState(){console.log("Main state: "+this.prevState+" -> "+this.state)}}var pt={getChessArray(t){void 0===t&&(t=[]);for(var e=this.board,s=e.width-2,i=e.height-2,r=this.chessTileZ,n=1;n<=i;n++)for(var h=1;h<=s;h++){var a=e.tileXYZToChess(h,n,r);null!==a&&t.push(a)}return t},getChessArrayAtTileX(t,e){void 0===e&&(e=[]);for(var s=this.board,i=s.height-2,r=this.chessTileZ,n=1;n<=i;n++){var h=s.tileXYZToChess(t,n,r);null!==h&&e.push(h)}return e},getChessArrayAtTileY(t,e){void 0===e&&(e=[]);for(var s=this.board,i=s.width-2,r=this.chessTileZ,n=1;n<=i;n++){var h=s.tileXYZToChess(n,t,r);null!==h&&e.push(h)}return e},getChessArrayAtTileXYInRange(t,e,s,i,r){void 0===r&&(r=[]);for(var n=this.board,h=n.width-2,a=n.height-2,o=this.chessTileZ,c=1;c<=a;c++)for(var l=1;l<=h;l++)if(!(Math.abs(l-t)>s||Math.abs(c-e)>i)){var d=n.tileXYZToChess(l,c,o);null!==d&&r.push(d)}return r},getChessArrayWithSymbol(t,e){void 0===e&&(e=[]);for(var s=this.board,i=s.width,r=s.height/2,n=s.height-1,h=this.chessTileZ,a=r;a<=n;a++)for(var o=0;o<=i;o++){var c=s.tileXYZToChess(o,a,h);null!==c&&c.getData("symbol")===t&&e.push(c)}return e},getNeighborChessAtAngle(t,e){var s=this.board.angleSnapToDirection(t,e);return this.getNeighborChessAtDirection(t,s)},getNeighborChessAtDirection(t,e){var s=this.board.getNeighborTileXY(t,e);return s?this.board.tileXYZToChess(s.x,s.y,this.chessTileZ):null}};const vt=Phaser.Utils.Array.GetRandom;var mt=function(t,e,s,i,r,n){var h;if(Array.isArray(i)){var a=i;if(void 0!==n){for(var o=0,c=a.length;o<c;o++)h=a[o],-1===n.indexOf(h)&&bt.push(h);h=vt(bt),bt.length=0}else h=vt(a)}else h="function"==typeof obj?r?i.call(r,t,e,s,n):i(t,e,s,n):i;return h},bt=[],ft=function(t){var e=this.board,{loopType:s,startX:i,endX:r,startY:n,endY:h}=J[t];i<0&&(i=e.width+i),r<0&&(r=e.width+r),n<0&&(n=e.height+n),h<0&&(h=e.height+h);var a=this.chessTileZ,o=this.candidateSymbols,c=!1;if("xy"===s)for(var l=n;l<=h;l++)gt(this,r,l,a,o)&&(c=!0);else for(var d=i;d<=r;d++)gt(this,d,h,a,o)&&(c=!0);return c},gt=function(t,e,s,i,r){return!t.board.contains(e,s,i)&&(t.createChess(e,s,r),!0)},yt=function(){var t=this,e=this.chessTileZ;this.match.refreshSymbols((function(s,i){if(!t.isAtActivateArea(s.x,s.y))return null;var r=i.tileXYZToChess(s.x,s.y,e);return null==r?null:r.getData("symbol")}))},Et=function(t,e,s){return this.match.match(t,e,s),this};const wt=Phaser.Utils.Array.GetRandom;var Tt=function(t){return this.match.anyMatch(t)},Ct=function(t,e,s){var i=t.getSymbol(e.x,e.y),r=t.getSymbol(s.x,s.y);t.setSymbol(e.x,e.y,r),t.setSymbol(s.x,s.y,i)},St={x:0,y:0};const _t=Phaser.Structs.Set;var At=function(t,e){for(var s=t.entries,i=0,r=s.length;i<r;i++)if(!e.contains(s[i]))return!1;return!0},xt=function(t){var e=function(t){return(t=i(t))?t.sys.renderer:null}(t);return!!e&&!!e.gl};const kt=Phaser.Filters.Mask;var Pt=function(t,e,s){var i=function(t,e){var s=t._maskObject;return s?(void 0!==e&&void 0!==s.invert&&(s.invert=e),s):(s=xt(t)?new kt(t.scene.cameras.main,t,e):t.createGeometryMask(),t._maskObject=s,t.once("destroy",(function(){s.destroy(),t._maskObject=void 0})),s)}(e,s);if(t.mask!==i){if(xt(t)){if(!t.filters){if(!t.enableFilters)return;t.enableFilters()}var r=t.filters.external.list;if(t.mask){var n=r.indexOf(t.mask);r[n]=e}else r.push(i)}else if(!t.setMask)return;t.mask=i}};const jt=Phaser.GameObjects.Graphics;var Mt={enableBoardLayer(t){return this.layer||(void 0!==t&&!0!==t||(t=this.scene.add.layer()),this.layer=t),this},resetBoardMask(){this.activateAreaMaskGameObject||(this.activateAreaMaskGameObject=new jt(this.scene),this.enableBoardLayer(),Pt(this.layer,this.activateAreaMaskGameObject));var t=this.board,e=t.grid,s=t.tileXYToWorldXY(0,t.height/2),i=s.x-e.width/2,r=s.y-e.height/2,n=this.activateBoardWidth*e.width,h=this.activateBoardHeight*e.height;return this.activateAreaMaskGameObject.clear().fillStyle(16777215).fillRect(i,r,n,h),this}},Rt={setActivateBoardWidth(t){return this.setBoardWidth(t+2),this},setActivateBoardHeight(t){return this.setBoardHeight(t+2),this},isAtActivateArea(t,e){return t>=1&&t<=this.board.width-2&&e>=1&&e<=this.board.height-2}},Dt={clear:function(){return this.board.removeAllChess(!0),this},init:function(){return this},reset:function(){this.clear();var t=this.initSymbols;this.initSymbols=void 0,this.fillActivateArea(t),this.breakMatch3()},createChess:function(t,e,s){this.scene;var i,r=this.board,n=this.chessCallbackScope,h=Array.isArray(s)?mt(r,t,e,s,n):s;(i=n?this.chessCreateCallback.call(n,r):this.chessCreateCallback(r)).setData("symbol",h),r.addChess(i,t,e,this.chessTileZ,!0),i.rexMoveTo=this.rexBoard.add.moveTo(i,this.chessMoveTo),this.layer&&this.layer.add(i)},fillActivateArea:function(t){for(var e=void 0!==t,s=this.board,i=this.chessTileZ,r=s.width-2,n=s.height-2,h=1;h<=n;h++)for(var a=1;a<=r;a++)if(!s.contains(a,h,i)){var o=this.candidateSymbols;if(e){var c=t[h-1][a-1];"?"!==c&&(o=c)}this.createChess(a,h,o)}},fillPrepareRows:function(){for(var t=!1,e=0;e<4;e++)ft.call(this,e)&&(t=!0);return t},breakMatch3:function(){var t=this.chessTileZ,e=this.chessCallbackScope,s=this.candidateSymbols;yt.call(this),Et.call(this,3,(function(i,r){for(var n=wt(i.tileXY),h=r.tileXYZToChess(n.x,n.y,t),a=r.getNeighborChess(h,null),o=[],c=0,l=a.length;c<l;c++)o.push(a[c].getData("symbol"));var d=mt(r,n.x,n.y,s,e,o);null!=d&&h.setData("symbol",d)}))},preTest:function(){var t,e=this.match,s=this.board.grid.halfDirections;yt.call(this);for(var i=0,r=this.board.height;i<r;i++)for(var n=0,h=this.board.width;n<h;n++)if(this.isAtActivateArea(n,i)){St.x=n,St.y=i;for(var a=0,o=s.length;a<o;a++)if(t=this.board.getNeighborTileXY(St,a),this.isAtActivateArea(t.x,t.y)&&(Ct(e,St,t),this.preTestResult=Tt.call(this,3),Ct(e,St,t),this.preTestResult))return!0}return!1},getAllMatch:function(){yt.call(this);for(var t=this,e=[],s=5;s>=3;s--)Et.call(this,s,(function(s,i){for(var r=new _t(i.tileXYArrayToChessArray(s.tileXY,t.chessTileZ)),n=0,h=e.length;n<h;n++)if(At(e[n],r))return;e.push(r)}));return e},dumpSymbols:function(){for(var t=this.board,e=this.chessTileZ,s=[],i=0,r=t.height;i<r;i++){var n=[];s.push(n);for(var h=0,a=t.width;h<a;h++){var o=t.tileXYZToChess(h,i,e),c=null==o?null:o.getData("symbol");n.push(c)}}return s}};Object.assign(Dt,pt,Mt,Rt);const Lt=Phaser.Utils.Objects.GetValue;class Ot{constructor(t,e){this.scene=t,this.rexBoard=t[Lt(e,"rexBoard","rexBoard")];var s=Lt(e,"board",{}),i=Lt(s,"x",0),r=Lt(s,"y",0),n=Lt(s,"cellSize",0),h=Lt(s,"cellWidth",n),a=Lt(s,"cellHeight",n);this.board=this.rexBoard.add.board({grid:{x:i-h/2,y:r-a/2,cellWidth:h,cellHeight:a}}),this.setActivateBoardWidth(s.width).setActivateBoardHeight(s.height),this.match=this.rexBoard.add.match(Lt(e,"match")),this.match.setBoard(this.board),this.initSymbols=Lt(e,"initSymbols"),this.chessTileZ=Lt(e,"chess.tileZ",1),this.candidateSymbols=Lt(e,"chess.symbols"),this.chessCallbackScope=Lt(e,"chess.scope"),this.chessCreateCallback=Lt(e,"chess.create"),this.chessMoveTo=Lt(e,"chess.moveTo",{}),this.chessMoveTo.occupiedTest=!0,this.activateAreaMaskGameObject=void 0,this.activateAreaMask=void 0,this.layer=void 0;var o=Lt(e,"layer",!1);o&&this.enableBoardLayer(o),Lt(e,"mask",!0)&&this.resetBoardMask()}shutdown(){return this.match.destroy(),this.board.destroy(),this.activateAreaMaskGameObject&&(this.layer.setMask(),this.activateAreaMaskGameObject.destroy(),this.activateAreaMask.destroy()),this.layer&&this.layer.destroy(),this.board=void 0,this.match=void 0,this.initSymbols=void 0,this.candidateSymbols=void 0,this.chessCallbackScope=void 0,this.chessCreateCallback=void 0,this.chessMoveTo=void 0,this}destroy(){return this.shutdown(),this}setBoardWidth(t){return this.board.setBoardWidth(t),this}setBoardHeight(t){return this.board.setBoardHeight(t),this}get activateBoardWidth(){return this.board.width-2}get activateBoardHeight(){return this.board.height-2}setInitSymbols(t){return this.initSymbols=t,this}setMovingDirection(t){return"string"==typeof t&&H.hasOwnProperty(t)&&(t=H[t]),this.movingDirection=t,this}chessToTileXYZ(t){return this.board.chessToTileXYZ(t)}worldXYToChess(t,e){return this.board.worldXYToChess(t,e,this.chessTileZ)}tileXYToChess(t,e){return this.board.tileXYZToChess(t,e,this.chessTileZ)}}Object.assign(Ot.prototype,Dt);const Wt=Phaser.Utils.Objects.GetValue;class Xt{constructor(t,e){this.bejeweled=t,this.scene=t.scene,this.setEnable(Wt(e,"input.enable",!0)),this.boot()}boot(){this.scene.input.on("pointerdown",this.selectChess1,this).on("pointermove",this.selectChess2,this).on("pointerup",this.pickChess,this)}shutdown(){this.scene.input.off("pointerdown",this.selectChess1,this).off("pointermove",this.selectChess2,this).off("pointerup",this.pickChess,this),this.bejeweled=void 0,this.scene=void 0}destroy(){return this.shutdown(),this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}selectChess1(t){if(!this.enable)return this;var e=this.bejeweled.worldXYToChess(t.worldX,t.worldY);e&&this.bejeweled.selectChess1(e)}selectChess2(t){if(!this.enable)return this;if(t.isDown){var e=this.bejeweled.worldXYToChess(t.worldX,t.worldY);e&&e!==this.bejeweled.getSelectedChess1()&&this.bejeweled.selectChess2(e)}}pickChess(t){if(!this.enable)return this;var e=this.bejeweled.worldXYToChess(t.worldX,t.worldY);e&&e===this.bejeweled.getSelectedChess1()&&this.bejeweled.pickChess(e)}}class Yt{constructor(t,e){this.setCompleteCallback(t,e),this.events=new Set}shutdown(){return this.setCompleteCallback(void 0,void 0),this.events.clear(),this.event=void 0,this}destroy(){return this.shutdown(),this}setCompleteCallback(t,e){return this.completeCallback=t,this.scope=e,this}waitCallback(){var t=this,e=function(){t.remove(e)};return this.events.add(e),e}waitEvent(t,e){return t.once(e,this.waitCallback()),this}remove(t){return this.events.delete(t),this.noWaitEvent&&(this.scope?this.completeCallback.call(this.scope):this.completeCallback()),this}clear(){return this.events.clear(),this}get noWaitEvent(){return 0===this.events.size}}var Nt={getSelectedChess1(){return this.mainState.selectedChess1},getSelectedChess2(){return this.mainState.selectedChess2},selectChess1(t){return this.mainState.selectChess1(t),this},selectChess2(t){return this.mainState.selectChess2(t),this},pickChess(t){return this.mainState.pickChess(t),this},setInputEnable(t){return this.input&&this.input.setEnable(t),this}},It={setActivateBoardSize(t,e){return this.boardWrapper.setActivateWidth(t).setActivateHeight(e),this},getChessMoveTo:t=>t?t.rexMoveTo:void 0,getChessTileZ(){return this.boardWrapper.chessTileZ},chessToTileXY(t){return this.boardWrapper.chessToTileXYZ(t)},worldXYToChess(t,e){return this.boardWrapper.worldXYToChess(t,e)},tileXYToChess(t,e){return this.boardWrapper.tileXYToChess(t,e)},getNeighborChessAtAngle(t,e){return this.boardWrapper.getNeighborChessAtAngle(t,e)},getNeighborChessAtDirection(t,e){return this.boardWrapper.getNeighborChessAtDirection(t,e)},getChessArray(t){return this.boardWrapper.getChessArray(t)},getChessArrayAtTileX(t,e){return this.boardWrapper.getChessArrayAtTileX(t,e)},getChessArrayAtTileY(t,e){return this.boardWrapper.getChessArrayAtTileY(t,e)},getChessArrayAtTileXYInRange(t,e,s,i,r){return this.boardWrapper.getChessArrayAtTileXYInRange(t,e,s,i,r)},getNeighborChessAtDirection(t,e){return this.boardWrapper.getNeighborChessAtDirection(t,e)},isAwaitingInput(){return"SELECT1START"===this.mainState.state},dumpSymbols(){return this.boardWrapper.dumpSymbols()},loadSymbols(t){return this.boardWrapper.setInitSymbols(t),this.mainState.goto("RESET"),this},setMovingDirection(t){return this.boardWrapper.setMovingDirection(t),this},getMovingDirection(){return this.boardWrapper.movingDirection},setEliminatingChess(t){return Array.isArray(t)||(t=[t]),this.mainState.setEliminatingChess(t),this},getBoard(){return this.boardWrapper.board},getMatch(){return this.boardWrapper.match}},Gt={waitEvent(t,e){return void 0===e&&(e="complete"),this.waitEvents.waitEvent(t,e),this},waitCallback(){return this.waitEvents.waitCallback()},isWaitingEvent(){return!this.waitEvents.noWaitEvent}};const Zt=Phaser.Data.DataManager;var Ft={destroyDataManager(){this.data&&(this.data.destroy(),this.data=void 0)},setDataEnabled(){return this.data||(this.data=new Zt(this)),this},setData(t,e){return this.data||(this.data=new Zt(this)),this.data.set(t,e),this},incData(t,e){return this.data||(this.data=new Zt(this)),this.data.inc(t,e),this},toggleData(t){return this.data||(this.data=new Zt(this)),this.data.toggle(t),this},getData(t){return this.data||(this.data=new Zt(this)),this.data.get(t)}};const Bt=Phaser.Utils.Objects.GetValue;class Ut extends a{constructor(t,e){super(t,e),this.rexBoard=t[Bt(e,"rexBoard","rexBoard")],this.boardWrapper=new Ot(t,e);var s=Bt(e,"input",!0);this.input=s?new Xt(this,e):void 0,this.waitEvents=new Yt,this.mainState=new ut(this,e),this.setMovingDirection(Bt(e,"movingDirection","down")),this.boot()}boot(){this.scene.events.once("shutdown",this.destroy,this)}shutdown(t){return super.shutdown(t),this.input&&this.input.destroy(),this.boardWrapper.destroy(),this.mainState.destroy(),this.waitEvents.destroy(),this.destroyDataManager(),this.boardWrapper=void 0,this.mainState=void 0,this.input=void 0,this.waitEvents=void 0,this}destroy(t){return this.emit("destroy"),super.destroy(t),this}start(){return this.mainState.goto("START"),this}get movingDirection(){return this.getMovingDirection()}set movingDirection(t){this.setMovingDirection(t)}}return Object.assign(Ut.prototype,Nt,It,Gt,Ft),Ut},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexbejeweled2=e();