UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 40.9 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};const i=Phaser.Game;var r=function(t){return t instanceof i};const n=Phaser.Utils.Objects.GetValue;class h{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(n(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=null==(e=t)||"object"!=typeof e?null:s(e)?e:e.scene&&s(e.scene)?e.scene:e.parent&&e.parent.scene&&s(e.parent.scene)?e.parent.scene:null,this.game=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}(t),this}}function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(h.prototype,t);var o={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}(o);var c=a(o.exports);class l extends c{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var d={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,i){var r=t&&("object"==typeof t||"function"==typeof t),n=i&&("object"==typeof i||"function"==typeof i);if(!r&&!n)return s;var h=String(e);if(r&&h in t)return t[h];if(n&&h in i)return i[h];if(-1===h.indexOf("."))return s;var a=h.split(".");if(r){var o=p(t,a,s);if(o.found)return o.value}if(n){var c=p(i,a,s);if(c.found)return c.value}return s},p=function(t,e,s){for(var i=t,r=s,n=0,h=e.length;n<h;n++){var a=e[n];if(!i||"object"!=typeof i&&"function"!=typeof i||!(a in i))return v.found=!1,v;i=r=i[a]}return v.found=!0,v.value=r,v},v={};const m=["next","exit","enter"];let b=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 r=u(t,"eventEmitter",void 0),n=u(t,"EventEmitterClass",void 0);this.setEventEmitter(r,n),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,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 m}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(b.prototype,d);var f=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 g=["next","exit","enter","update","preupdate","postupdate"];class y extends b{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 g}update(t,e){this.runMethod("update",t,e)}preupdate(t,e){this.runMethod("preupdate",t,e)}postupdate(t,e){this.runMethod("postupdate",t,e)}startUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}stopUpdate(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}startPreUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}stopPreUpdate(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}startPostUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}stopPostUpdate(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}class E extends y{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 w=Phaser.Utils.Objects.GetValue;class T extends h{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(w(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=C[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 C={no:0,lazy:1,always:2},S=Phaser.Utils.Objects.GetValue;class _ extends T{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=S(e,"tickEventName",s),this.isSceneTicker=!A(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 A=function(t){return"step"===t||"poststep"===t};const x=Phaser.Utils.Objects.GetValue,k=Phaser.Math.Clamp;class j{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=x(t,"state",P),this.timeScale=x(t,"timeScale",1),this.delay=x(t,"delay",0),this.repeat=x(t,"repeat",0),this.repeatCounter=x(t,"repeatCounter",0),this.repeatDelay=x(t,"repeatDelay",0),this.duration=x(t,"duration",0),this.nowTime=x(t,"nowTime",0),this.justRestart=x(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?R:M,this.repeatCounter=0,this}stop(){return this.state=P,this}update(t,e){this.state!==P&&this.state!==L&&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=D)):(this.nowTime=this.duration,this.state=L):this.nowTime>=0&&(this.state=R))}get t(){var t;switch(this.state){case P:case M:case D:t=0;break;case R:t=this.nowTime/this.duration;break;case L:t=1}return k(t,0,1)}set t(t){(t=k(t,-1,1))<0?(this.state=M,this.nowTime=-this.delay*t):(this.state=R,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===M}get isCountDown(){return this.state===R}get isRunning(){return this.state===M||this.state===R}get isDone(){return this.state===L}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const P=0,M=1,R=2,D=3,L=-1;class W extends _{constructor(t,e){super(t,e),this.timer=new j}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 X=Phaser.Utils.Objects.GetValue,Y=Phaser.Utils.Objects.GetAdvancedValue,O=Phaser.Tweens.Builders.GetEaseFunction;class N extends W{resetFromJSON(t){return this.timer.resetFromJSON(X(t,"timer")),this.setEnable(X(t,"enable",!0)),this.setTarget(X(t,"target",this.parent)),this.setDelay(Y(t,"delay",0)),this.setDuration(Y(t,"duration",1e3)),this.setEase(X(t,"ease","Linear")),this.setRepeat(X(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=O(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 I=Phaser.Utils.Objects.GetValue,Z=Phaser.Utils.Objects.GetAdvancedValue,G=Phaser.Math.Linear;class B extends N{constructor(t,e){super(t,e),this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(I(t,"mode",0)),this.setAlphaRange(Z(t,"start",this.parent.alpha),Z(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 U=function(t,e,s,i){s instanceof B&&(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 B(t,r):i.resetFromJSON(r),i.restart(),i},V=function(t,e,s){for(var i=0,r=t.length;i<r;i++){var n=U(t[i],500);s.waitEvent(n,"complete")}},H=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 J={right:0,down:1,left:2,up:3},z=[{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 K=function(t,e,s){var{loopType:i,startX:r,endX:n,startY:h,endY:a}=z[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=H(r,n+o,o),d=H(h,a+c,c),u=s.getChessTileZ();"xy"===i?l.forEach((function(i){d.forEach((function(r){$(s,e,i,r,u,t)}))})):d.forEach((function(i){l.forEach((function(r){$(s,e,r,i,u,t)}))}))},$=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")}},q=function(t){return t&&"function"==typeof t.then};const Q=Phaser.Utils.Objects.GetValue,tt=Phaser.Structs.Set;let et=class extends E{constructor(t,e){super(t,e),this.totalMatchedLinesCount=0,this.eliminatedPieceArray=void 0,this.continueFilling=!1,this.eliminatingAction=Q(e,"eliminatingAction",V),this.movingAction=Q(e,"movingAction",K),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 tt,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);q(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);q(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 st=Phaser.Utils.Objects.GetValue,it=Phaser.Utils.Objects.GetAdvancedValue,rt=Phaser.Math.Linear;class nt extends N{constructor(t,e){super(t,e),this.scaleStart={},this.scaleEnd={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(st(t,"mode",0)),this.setScaleRange(it(t,"start",void 0),it(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=ht[t]),this.mode=t,this}setScaleRange(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=it(t,"x",this.parent.scaleX),this.startY=it(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=it(e,"x",void 0),this.endY=it(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=rt(this.startX,this.endX,s)),this.hasScaleY&&(t.scaleY=rt(this.startY,this.endY,s))}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}}const ht={stop:0,destroy:1,yoyo:2};var at=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 nt(t,a):r.resetFromJSON(a),r.restart(),r},ot=function(t,e,s){for(var i=0,r=t.length;i<r;i++){var n=at(t[i],500);s.waitEvent(n,"complete")}},ct=function(t,e,s){},lt=function(t,e,s){},dt=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 ut=Phaser.Utils.Objects.GetValue;class pt extends E{constructor(t,e){super(t,e),this.selectedChess1,this.selectedChess2,this.pickedChess,this.matchState=new et(t,e),this.placeAction=ut(e,"placeAction",ot),this.select1Action=ut(e,"select1Action",ct),this.select2Action=ut(e,"select2Action",this.select1Action),this.pickAction=ut(e,"pickAction",lt),this.swapAction=ut(e,"swapAction",dt),this.undoSwapAction=ut(e,"undoSwapAction",this.swapAction),ut(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);q(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);q(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);q(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);q(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);q(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);q(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 vt={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 mt=Phaser.Utils.Array.GetRandom;var bt=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)&&ft.push(h);h=mt(ft),ft.length=0}else h=mt(a)}else h="function"==typeof obj?r?i.call(r,t,e,s,n):i(t,e,s,n):i;return h},ft=[],gt=function(t){var e=this.board,{loopType:s,startX:i,endX:r,startY:n,endY:h}=z[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++)yt(this,r,l,a,o)&&(c=!0);else for(var d=i;d<=r;d++)yt(this,d,h,a,o)&&(c=!0);return c},yt=function(t,e,s,i,r){return!t.board.contains(e,s,i)&&(t.createChess(e,s,r),!0)},Et=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")}))},wt=function(t,e,s){return this.match.match(t,e,s),this};const Tt=Phaser.Utils.Array.GetRandom;var Ct=function(t){return this.match.anyMatch(t)},St=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)},_t={x:0,y:0};const At=Phaser.Structs.Set;var xt=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},kt={enableBoardLayer(t){return this.layer||(void 0!==t&&!0!==t||(t=this.scene.add.layer()),this.layer=t),this},resetBoardMask(){this.activateAreaMaskGameObject||(this.activateAreaMaskGameObject=this.scene.make.graphics().setVisible(!1),this.activateAreaMask=this.activateAreaMaskGameObject.createGeometryMask(),this.enableBoardLayer(),this.layer.setMask(this.activateAreaMask));var t=this.board,e=t.grid,s=t.tileXYToWorldXY(1,1),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.fillRect(i,r,n,h),this}},jt={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}},Pt={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)?bt(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++)gt.call(this,e)&&(t=!0);return t},breakMatch3:function(){var t=this.chessTileZ,e=this.chessCallbackScope,s=this.candidateSymbols;Et.call(this),wt.call(this,3,(function(i,r){for(var n=Tt(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=bt(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;Et.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)){_t.x=n,_t.y=i;for(var a=0,o=s.length;a<o;a++)if(t=this.board.getNeighborTileXY(_t,a),this.isAtActivateArea(t.x,t.y)&&(St(e,_t,t),this.preTestResult=Ct.call(this,3),St(e,_t,t),this.preTestResult))return!0}return!1},getAllMatch:function(){Et.call(this);for(var t=this,e=[],s=5;s>=3;s--)wt.call(this,s,(function(s,i){for(var r=new At(i.tileXYArrayToChessArray(s.tileXY,t.chessTileZ)),n=0,h=e.length;n<h;n++)if(xt(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(Pt,vt,kt,jt);const Mt=Phaser.Utils.Objects.GetValue;class Rt{constructor(t,e){this.scene=t,this.rexBoard=t[Mt(e,"rexBoard","rexBoard")];var s=Mt(e,"board",{}),i=Mt(s,"x",0),r=Mt(s,"y",0),n=Mt(s,"cellSize",0),h=Mt(s,"cellWidth",n),a=Mt(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(Mt(e,"match")),this.match.setBoard(this.board),this.initSymbols=Mt(e,"initSymbols"),this.chessTileZ=Mt(e,"chess.tileZ",1),this.candidateSymbols=Mt(e,"chess.symbols"),this.chessCallbackScope=Mt(e,"chess.scope"),this.chessCreateCallback=Mt(e,"chess.create"),this.chessMoveTo=Mt(e,"chess.moveTo",{}),this.chessMoveTo.occupiedTest=!0,this.activateAreaMaskGameObject=void 0,this.activateAreaMask=void 0,this.layer=void 0;var o=Mt(e,"layer",!1);o&&this.enableBoardLayer(o),Mt(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&&J.hasOwnProperty(t)&&(t=J[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(Rt.prototype,Pt);const Dt=Phaser.Utils.Objects.GetValue;class Lt{constructor(t,e){this.bejeweled=t,this.scene=t.scene,this.setEnable(Dt(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)}}const Wt=Phaser.Structs.Set;class Xt{constructor(t,e){this.setCompleteCallback(t,e),this.events=new Wt}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.set(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 Yt={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}},Ot={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}},Nt={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 It=Phaser.Data.DataManager;var Zt={destroyDataManager(){this.data&&(this.data.destroy(),this.data=void 0)},setDataEnabled(){return this.data||(this.data=new It(this)),this},setData(t,e){return this.data||(this.data=new It(this)),this.data.set(t,e),this},incData(t,e){return this.data||(this.data=new It(this)),this.data.inc(t,e),this},toggleData(t){return this.data||(this.data=new It(this)),this.data.toggle(t),this},getData(t){return this.data||(this.data=new It(this)),this.data.get(t)}};const Gt=Phaser.Utils.Objects.GetValue;class Bt extends h{constructor(t,e){super(t,e),this.rexBoard=t[Gt(e,"rexBoard","rexBoard")],this.boardWrapper=new Rt(t,e);var s=Gt(e,"input",!0);this.input=s?new Lt(this,e):void 0,this.waitEvents=new Xt,this.mainState=new pt(this,e),this.setMovingDirection(Gt(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(Bt.prototype,Yt,Ot,Nt,Zt),Bt},"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();