text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexgridtableplugin=e()}(this,function(){"use strict";function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(l){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e,i,n=h(l);if(r){var s=h(this).constructor;t=Reflect.construct(n,arguments,s)}else t=n.apply(this,arguments);return e=this,!(i=t)||"object"!=typeof i&&"function"!=typeof i?v(e):i}}function c(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}function y(t,e,i){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=c(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(i):s.value}})(t,e,i||t)}function l(t,e,i,n){return(l="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,n){var s,l,r,o,a=c(t,e);if(a){if((s=Object.getOwnPropertyDescriptor(a,e)).set)return s.set.call(n,i),!0;if(!s.writable)return!1}if(s=Object.getOwnPropertyDescriptor(n,e)){if(!s.writable)return!1;s.value=i,Object.defineProperty(n,e,s)}else o=i,(r=e)in(l=n)?Object.defineProperty(l,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):l[r]=o;return!0})(t,e,i,n)}function s(t,e,i,n,s){if(!l(t,e,i,n||t)&&s)throw new Error("failed to set property");return i}function r(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var d=Phaser.GameObjects.Zone,f=Phaser.Utils.Array.Add,C=Phaser.Utils.Array.Remove,g=function(){t(o,d);var r=u(o);function o(t,e,i,n,s){var l;return p(this,o),void 0===n&&(n=1),void 0===s&&(s=1),(l=r.call(this,t,e,i,n,s)).children=[],l}return e(o,[{key:"destroy",value:function(t){this.scene&&(this.clear(!t),y(h(o.prototype),"destroy",this).call(this,t))}},{key:"contains",value:function(t){return-1!==this.children.indexOf(t)}},{key:"add",value:function(t){return f(this.children,t,0,function(t){t.on("destroy",this.remove,this)},this),this}},{key:"remove",value:function(t,e){return C(this.children,t,function(t){t.off("destroy",this.remove,this),e&&t.destroy()}),this}},{key:"clear",value:function(t){for(var e,i=0,n=this.children.length;i<n;i++)(e=this.children[i]).off("destroy",this.remove,this),t&&e.destroy();return this.children.length=0,this}}]),o}(),b=Phaser.GameObjects.Components;Phaser.Class.mixin(g,[b.Alpha,b.Flip]);function k(t){var e;return t.hasOwnProperty("rexContainer")&&(e=t.rexContainer.parent),e}function m(t){return t.hasOwnProperty("rexContainer")||(t.rexContainer={}),t.rexContainer}function w(t){return this.setParent(t),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),T.call(this,t),this}function x(t){this.setParent(t);var e=m(t);return e.x=t.x,e.y=t.y,e.rotation=t.rotation,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.flipX=t.flipX,e.flipY=t.flipY,e.alpha=t.alpha,e.visible=t.visible,e.active=t.active,this.updateChildPosition(t).updateChildAlpha(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),T.call(this,t),this}function O(t,e){return t===e?1:t/e}var P={setParent:function(t,e){void 0===e&&(e=this);var i=m(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent:function(t){return void 0===t&&(t=this),k(t)},getTopmostParent:function(t){return void 0===t&&(t=this),function(t){for(var e=k(t);e;)e=k(t=e);return t}(t)}},T=g.prototype.add,S={add:function(t){return Array.isArray(t)?this.addMultiple(t):w.call(this,t),this},addMultiple:function(t){for(var e=0,i=t.length;e<i;e++)w.call(this,t[e]);return this},addLocal:function(t){return Array.isArray(t)?this.addMultiple(t):x.call(this,t),this},addLocalMultiple:function(t){for(var e=0,i=t.length;e<i;e++)x.call(this,t[e]);return this}},Y=g.prototype.remove,X=g.prototype.clear,H={remove:function(t,e){return k(t)!==this||(this.setParent(t,null),Y.call(this,t,e)),this},clear:function(t){for(var e=0,i=this.children.length;e<i;e++)this.setParent(this.children[e],null);return X.call(this,t),this}},M={getLocalState:function(t){return m(t)},resetChildState:function(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState:function(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties:function(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},R=Phaser.Math.RotateAround,A={worldToLocal:function(t){return t.x-=this.x,t.y-=this.y,R(t,0,0,-this.rotation),t.x/=this.scaleX,t.y/=this.scaleY,t.x*=this.flipX?-1:1,t.y*=this.flipY?-1:1,t},localToWorld:function(t){return t.x*=this.flipX?-1:1,t.y*=this.flipY?-1:1,t.x*=this.scaleX,t.y*=this.scaleY,R(t,0,0,this.rotation),t.x+=this.x,t.y+=this.y,t}},V={updateChildPosition:function(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=m(t),i=e.parent;return t.x=e.x,t.y=e.y,i.localToWorld(t),t.scaleX=e.scaleX*i.scaleX,t.scaleY=e.scaleY*i.scaleY,void 0!==t.flipX&&(t.flipX=i.flipX?!e.flipX:e.flipX,t.flipY=i.flipY?!e.flipY:e.flipY),t.rotation=e.rotation+i.rotation,t.isRexContainerLite&&(t.syncChildrenEnable=!0,t.syncPosition()),this},syncPosition:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState:function(t){var e=m(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=O(t.scaleX,i.scaleX),e.scaleY=O(t.scaleY,i.scaleY),void 0!==t.flipX&&(e.flipX=t.flipX,e.flipY=t.flipY),e.rotation=t.rotation-i.rotation,this},setChildPosition:function(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition:function(t,e,i){var n=m(t);return n.x=e,n.y=i,this.updateChildPosition(t),this}},_={updateChildRotation:function(t){var e=m(t),i=e.parent;return t.rotation=i.rotation+e.rotation,this},syncRotation:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState:function(t){var e=m(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation:function(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildLocalRotation:function(t,e){return m(t).rotation=e,this.updateChildRotation(t),this}},D={updateChildScale:function(t){var e=m(t),i=e.parent;return t.scaleX=i.scaleX*e.scaleX,t.scaleY=i.scaleY*e.scaleY,this},syncScale:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScale,this),this},resetChildScaleState:function(t){var e=m(t),i=e.parent;return e.scaleX=O(t.scaleX,i.scaleX),e.scaleY=O(t.scaleY,i.scaleY),this},setChildScale:function(t,e,i){return void 0===i&&(i=e),t.scaleX=e,t.scaleY=i,this.resetChildScaleState(t),this},setChildLocalScale:function(t,e,i){void 0===i&&(i=e);var n=m(t);return n.scaleX=e,n.scaleY=i,this.updateChildScale(t),this},setChildDisplaySize:function(t,e,i){return t.setDisplaySize(e,i),this.resetChildScaleState(t),this}},I={updateChildVisible:function(t){var e=m(t),i=e.parent,n=!e.hasOwnProperty("maskVisible")||e.maskVisible;return t.visible=i.visible&&e.visible&&n,this},syncVisible:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState:function(t){var e=m(t);return e.hasOwnProperty("maskVisible")&&delete e.maskVisible,e.visible=t.visible,this},setChildVisible:function(t,e){return this.setChildLocalVisible(t,e),this},setChildLocalVisible:function(t,e){return void 0===e&&(e=!0),m(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible:function(t,e){return void 0===e&&(e=!0),m(t).maskVisible=e,this.updateChildVisible(t),this}},j={updateChildAlpha:function(t){var e=m(t),i=e.parent;return t.alpha=i.alpha*e.alpha,this},syncAlpha:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState:function(t){var e=m(t),i=e.parent;return e.alpha=O(t.alpha,i.alpha),this},setChildAlpha:function(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha:function(t,e){return m(t).alpha=e,this.updateChildAlpha(t),this}},W={updateChildActive:function(t){var e=m(t),i=e.parent;return t.active=i.active&&e.active,this},syncActive:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState:function(t){return m(t).active=t.active,this},setChildActive:function(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive:function(t,e){return void 0===e&&(e=!0),m(t).active=e,this.updateChildActive(t),this}},L={updateChildScrollFactor:function(t){var e=m(t).parent;return t.setScrollFactor(e.scrollFactorX,e.scrollFactorY),this},syncScrollFactor:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},F={updateChildMask:function(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this}},E=Phaser.Utils.Array,G={getChildren:function(){return this.children},getAllChildren:function(t){void 0===t&&(t=[]);for(var e,i=this.children,n=0,s=i.length;n<s;n++){if(e=i[n],t.push(e),e.hasOwnProperty("isRexContainerLite"))t.push.apply(t,r(e.getAllChildren()))}return t},getAllVisibleChildren:function(t){void 0===t&&(t=[]);for(var e,i=this.children,n=0,s=i.length;n<s;n++){if((e=i[n]).visible)if(t.push(e),e.hasOwnProperty("isRexContainerLite"))t.push.apply(t,r(e.getAllVisibleChildren()))}return t},contains:function(t){var e=k(t);return!!e&&(e===this||this.contains(e))},getByName:function(t,e){if(e){for(var i,n,s=[this];s.length;)for(var l=0,r=(i=s.shift()).children.length;l<r;l++){if((n=i.children[l]).name===t)return n;n.isRexContainerLite&&s.push(n)}return null}return E.GetFirst(this.children,"name",t)},getRandom:function(t,e){return E.GetRandom(this.children,t,e)},getFirst:function(t,e,i,n){return E.GetFirstElement(this.children,t,e,i,n)},getAll:function(t,e,i,n){return E.GetAll(this.children,t,e,i,n)},count:function(t,e,i,n){return E.CountAllMatching(this.children,t,e,i,n)},swap:function(t,e){return E.Swap(this.children,t,e),this},moveTo:function(t,e){return E.MoveTo(this.children,t,e),this},setAll:function(t,e,i,n){return E.SetAll(this.children,t,e,i,n),this}},B={tweenChild:function(t){var e,i=t.targets;e=i,"[object Array]"!==Object.prototype.toString.call(e)&&(i=[i]);for(var n,s,l=[],r=0,o=i.length;r<o;r++)(s=i[r]).hasOwnProperty("rexContainer")&&(n=s.scene,l.push(s.rexContainer));if(n){t.targets=l;var a=n.tweens.add(t);return a.on("update",function(t,e,i){var n=i.parent,s=i.self;switch(e){case"x":case"y":n.updateChildPosition(s);break;case"angle":case"rotation":n.updateChildRotation(s);break;case"scaleX":case"scaleY":n.updateChildScale(s);break;case"alpha":n.updateChildAlpha(s)}}),a}},tween:function(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}},z={};Object.assign(z,P,S,H,M,A,V,_,D,I,j,W,L,F,{setDepth:function(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),n=0,s=i.length;n<s;n++)i[n].depth=t;return this},swapDepth:function(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth:function(t){if(this.depth+=t,this.children)for(var e=this.getAllChildren(),i=0,n=e.length;i<n;i++)e[i].depth+=t;return this}},G,B);var U=function(){t(a,g);var o=u(a);function a(t,e,i,n,s,l){var r;return p(this,a),(r=o.call(this,t,e,i,n,s)).type="rexContainerLite",r.isRexContainerLite=!0,r.syncChildrenEnable=!0,r._active=!0,r._mask=null,r._scrollFactorX=1,r._scrollFactorY=1,l&&r.add(l),r}return e(a,[{key:"destroy",value:function(t){this.scene&&(this.syncChildrenEnable=!1,y(h(a.prototype),"destroy",this).call(this,t))}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}},{key:"x",get:function(){return this._x},set:function(t){this._x!==t&&(this._x=t,this.syncPosition())}},{key:"y",get:function(){return this._y},set:function(t){this._y!==t&&(this._y=t,this.syncPosition())}},{key:"rotation",get:function(){return y(h(a.prototype),"rotation",this)},set:function(t){this.rotation!==t&&(s(h(a.prototype),"rotation",t,this,!0),this.syncPosition())}},{key:"scaleX",get:function(){return y(h(a.prototype),"scaleX",this)},set:function(t){this.scaleX!==t&&(s(h(a.prototype),"scaleX",t,this,!0),this.syncPosition())}},{key:"scaleY",get:function(){return y(h(a.prototype),"scaleY",this)},set:function(t){this.scaleY!==t&&(s(h(a.prototype),"scaleY",t,this,!0),this.syncPosition())}},{key:"flipX",get:function(){return y(h(a.prototype),"flipX",this)},set:function(t){y(h(a.prototype),"flipX",this)!==t&&(s(h(a.prototype),"flipX",t,this,!0),this.syncPosition())}},{key:"flipY",get:function(){return y(h(a.prototype),"flipY",this)},set:function(t){y(h(a.prototype),"flipY",this)!==t&&(s(h(a.prototype),"flipY",t,this,!0),this.syncPosition())}},{key:"visible",get:function(){return y(h(a.prototype),"visible",this)},set:function(t){y(h(a.prototype),"visible",this)!==t&&(s(h(a.prototype),"visible",t,this,!0),this.syncVisible())}},{key:"alpha",get:function(){return y(h(a.prototype),"alpha",this)},set:function(t){y(h(a.prototype),"alpha",this)!==t&&(s(h(a.prototype),"alpha",t,this,!0),this.syncAlpha())}},{key:"active",get:function(){return this._active},set:function(t){this._active!==t&&(this._active=t,this.syncActive())}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.syncMask())}},{key:"scrollFactorX",get:function(){return this._scrollFactorX},set:function(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}},{key:"scrollFactorY",get:function(){return this._scrollFactorY},set:function(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}},{key:"list",get:function(){return this.children}}]),a}();Object.assign(U.prototype,z);function Z(t){if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}var N=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;for(var n=e.split("."),s=t,l=i,r=0;r<n.length;r++){if(!s.hasOwnProperty(n[r])){l=i;break}l=s[n[r]],s=s[n[r]]}return l}return i},J={enableData:function(){return void 0===this.data&&(this.data={}),this},getData:function(t,e){return this.enableData(),void 0===t?this.data:N(this.data,t,e)},setData:function(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},incData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData:function(){return this.data&&Z(this.data),this},resetData:function(t){if(this.clearData(),t)for(var e in this.enableData(),t)this.data[e]=t[e];return this},cloneData:function(){return this.data?function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:Z(e),i){e.length=t.length;for(var n=0,s=t.length;n<s;n++)e[n]=t[n]}else for(var l in t)e[l]=t[l];return e}(this.data):{}}},$=function(){function i(t,e){p(this,i),this.container=null,this._deltaHeight=0,this.setParent(t)}return e(i,[{key:"setParent",value:function(t){this.parent=t,this.parentContainer=t.getParentContainer()}},{key:"destroy",value:function(t){void 0===t&&(t=!1),t||this.destroyContainer(),this.deltaHeight=0,this.data=void 0,this.container=null,this.parent=void 0,this.parentContainer=void 0}},{key:"table",get:function(){return this.parent}},{key:"scrollMode",get:function(){return this.parentContainer.scrollMode}},{key:"colIndx",get:function(){return this.parent.cellIndxeToColIndex(this.index)}},{key:"rowIndx",get:function(){return this.parent.cellIndxeToRowIndex(this.index)}},{key:"getContainer",value:function(){return this.container}},{key:"setContainer",value:function(t){return t?(this.container&&this.container.destroy(),this.container=t,this.parentContainer.add(t)):this.destroyContainer(),this}},{key:"destroyContainer",value:function(){return this.container&&(this.container.destroy(),this.container=null),this}},{key:"popContainer",value:function(){if(this.container){var t=this.container;return this.container=null,this.parentContainer.remove(t),t}return null}},{key:"setXY",value:function(t,e){return this.container&&this.parentContainer.setChildLocalPosition(this.container,t,e),this}},{key:"deltaHeight",get:function(){return this._deltaHeight},set:function(t){null==t&&(t=0);var e=this.parent;0===this._deltaHeight&&0!==t?e.nonZeroDeltaHeightCount++:0!==this._deltaHeight&&0===t&&e.nonZeroDeltaHeightCount--;var i=this._deltaHeight!==t;if(this._deltaHeight=t,i){var n=0===this.scrollMode?"cellheightchange":"cellwidthchange";this.parentContainer.emit(n)}}},{key:"deltaWidth",get:function(){return this.deltaHeight},set:function(t){this.deltaHeight=t}},{key:"setDeltaHeight",value:function(t){return this.deltaHeight=t,this}},{key:"setDeltaWidth",value:function(t){return this.deltaHeight=t,this}},{key:"height",get:function(){return 0===this.scrollMode?this.deltaHeight+this.parent.defaultCellHeight:this.parent.defaultCellWidth},set:function(t){1!==this.scrollMode&&this.setDeltaHeight(t-this.parent.defaultCellHeight)}},{key:"setHeight",value:function(t){return this.height=t,this}},{key:"width",get:function(){return 0===this.scrollMode?this.parent.defaultCellWidth:this.deltaHeight+this.parent.defaultCellHeight},set:function(t){0!==this.scrollMode&&this.setDeltaHeight(t-this.parent.defaultCellHeight)}},{key:"setWidth",value:function(t){return this.width=t,this}},{key:"scene",get:function(){return this.parentContainer.scene}}]),i}();Object.assign($.prototype,J);function q(t){return t.hasOwnProperty("geometryMask")?t.geometryMask:t.bitmapMask}function K(t){if(this.emit("cellinvisible",t),this.cellContainersPool){var e=t.popContainer();e&&this.cellContainersPool.killAndHide(e)}t.destroyContainer()}function Q(){var t=this.preVisibleCells,e=this.visibleCells;t.iterate(function(t){e.contains(t)||K.call(this,t)},this)}function tt(t){var e,i=null;(e=t.getContainer())?(i=e,t.popContainer()):this.cellContainersPool&&null!==(i=this.cellContainersPool.getFirstDead())&&i.setActive(!0).setVisible(!0),this.emit("cellvisible",t,i,this),this.cellContainersPool&&((e=t.getContainer())?null===i?this.cellContainersPool.add(e):i!==e&&(this.cellContainersPool.add(e),this.cellContainersPool.killAndHide(i)):null!==i&&this.cellContainersPool.killAndHide(i))}function et(t,e){e-=this.y+this.topLeftY,t-=this.x+this.topLeftX;var i=this.tableOY-(0===this.scrollMode?e:t),n=this.tableOX-(0===this.scrollMode?t:e),s=this.table,l=s.heightToRowIndex(-i),r=s.widthToColIndex(-n),o=s.colRowToCellIndex(r,l);return null!==o&&this.isCellVisible(o)?o:null}var it=function(){function t(){p(this,t),this.items=[]}return e(t,[{key:"destroy",value:function(){this.clear(),this.items=void 0}},{key:"pop",value:function(){return 0<this.items.length?this.items.pop():null}},{key:"push",value:function(t){return this.items.push(t),this}},{key:"pushMultiple",value:function(t){return this.items.push.apply(this.items,t),t.length=0,this}},{key:"clear",value:function(){return this.items.length=0,this}}]),t}(),nt=Phaser.Utils.Objects.GetValue,st=Phaser.Utils.Array.SpliceOne,lt=function(){function i(t,e){p(this,i),this.parent=t,this.cells=[],this.cellPool=new it,this.resetFromJSON(e)}return e(i,[{key:"resetFromJSON",value:function(t){return this.colCount=void 0,this._nonZeroDeltaHeightCount=0,this.resetTotalRowsHeight(),this.setDefaultCellHeight(nt(t,"cellHeight",30)),this.setDefaultCellWidth(nt(t,"cellWidth",30)),this.initCells(nt(t,"cellsCount",0)),this.setColumnCount(nt(t,"columns",1)),this}},{key:"destroy",value:function(t){for(var e=0,i=this.cells.length;e<i;e++)this.freeCell(this.cells[e],t);this.cellPool.destroy(),this.cells=void 0,this.parent=void 0}},{key:"nonZeroDeltaHeightCount",get:function(){return this._nonZeroDeltaHeightCount},set:function(t){this._nonZeroDeltaHeightCount!==t&&(this._nonZeroDeltaHeightCount=t,this.resetTotalRowsHeight())}},{key:"defaultCellHeightMode",get:function(){return 0===this.nonZeroDeltaHeightCount}},{key:"setDefaultCellHeight",value:function(t){return this.defaultCellHeight=t,this}},{key:"setDefaultCellWidth",value:function(t){return this.defaultCellWidth=t,this}},{key:"initCells",value:function(t){var e=this.cells;e.length=t;for(var i=0;i<t;i++)e[i]=null;return this}},{key:"insertNewCells",value:function(t,e){var i=this.cells;if(t===i.length){var n=t+e;i.legth=n;for(var s=t;s<n;s++)i[s]=null}else{var l,r=[];r.length=e;for(s=0;s<e;s++)r[s]=null;(l=this.cells).splice.apply(l,[t,0].concat(r))}return this.resetTotalRowsHeight(),this}},{key:"removeCells",value:function(t,e){for(var i=t+e,n=t;n<i;n++)this.freeCell(n);return i===this.cells.length?this.cells.length=t:(1===e?st(this.cells,t):this.cells.splice(t,e),this.buildCellIndex(t)),this.resetTotalRowsHeight(),this}},{key:"setColumnCount",value:function(t){return this.colCount=t,this.resetTotalRowsHeight(),this}},{key:"rowCount",get:function(){return Math.ceil(this.cells.length/this.colCount)}},{key:"cellsCount",get:function(){return this.cells.length}},{key:"isValidCellIdx",value:function(t){return 0<=t&&t<this.cells.length}},{key:"heightToRowIndex",value:function(t,e){if(this.defaultCellHeightMode){var i=t/this.defaultCellHeight;return i=e?Math.ceil(i):Math.floor(i)}var n,s=this.rowCount,l=t;for(i=0;;){if(n=0<=i&&i<s,!(0<(l-=this.getRowHeight(i))&&n)){if(0===l)return i;if(e){var r=i;(n=0<=(i+=1)&&i<s)||(i=r)}return i}i+=1}}},{key:"widthToColIndex",value:function(t,e){var i=t/this.defaultCellWidth;return i=e?Math.ceil(i):Math.floor(i)}},{key:"colRowToCellIndex",value:function(t,e){return t>=this.colCount?null:e*this.colCount+t}},{key:"rowIndexToHeight",value:function(t,e){if(this.defaultCellHeightMode)return(e-t+1)*this.defaultCellHeight;for(var i=0,n=t;n<=e;n++)i+=this.getRowHeight(n);return i}},{key:"colIndexToWidth",value:function(t,e){return(e-t+1)*this.defaultCellWidth}},{key:"getRowHeight",value:function(t){var e=this.colCount;if(e<=1)return this.getCellHeight(this.colRowToCellIndex(0,t));for(var i,n=0,s=0;s<e;s++)n<(i=this.getCellHeight(this.colRowToCellIndex(s,t)))&&(n=i);return n}},{key:"getColWidth",value:function(){return this.defaultCellWidth}},{key:"getCellHeight",value:function(t){if(!this.isValidCellIdx(t))return 0;var e;if(this.defaultCellHeightMode)e=this.defaultCellHeight;else{var i=this.getCell(t,!1),n=i?i.deltaHeight:0;e=this.defaultCellHeight+n}return e}},{key:"resetTotalRowsHeight",value:function(){this._totalRowsHeight=null}},{key:"totalRowsHeight",get:function(){return null===this._totalRowsHeight&&(this._totalRowsHeight=this.rowIndexToHeight(0,this.rowCount-1)),this._totalRowsHeight}},{key:"totalColumnWidth",get:function(){return this.colCount*this.defaultCellWidth}},{key:"cellIndxeToColIndex",value:function(t){return t%this.colCount}},{key:"cellIndxeToRowIndex",value:function(t){return Math.floor(t/this.colCount)}},{key:"getCell",value:function(t,e){if(!this.isValidCellIdx(t))return null;if(void 0===e&&(e=!0),null===this.cells[t]&&e){var i=this.newCell(t);this.cells[t]=i}return this.cells[t]}},{key:"newCell",value:function(t){var e=this.cellPool.pop();return null===e?e=new $(this):e.setParent(this),e.index=t,e}},{key:"buildCellIndex",value:function(t){void 0===t&&(t=0);for(var e,i=this.cells,n=t,s=i.length;n<s;n++)(e=i[n])&&(e.index=n);return this}},{key:"getParentContainer",value:function(){return this.parent}},{key:"freeCell",value:function(t,e){return"number"==typeof t&&(t=this.cells[t]),t&&(t.destroy(e),e||this.cellPool.push(t)),this}}]),i}(),rt=Phaser.GameObjects.Graphics,ot=function(){t(l,rt);var s=u(l);function l(t,e,i){var n;return p(this,l),void 0===e&&(e=0),"string"==typeof e&&(e=at[e]),void 0===i&&(i=0),(n=s.call(this,t.scene)).parent=t,n.shape=e,n.padding=i,n.setPosition().resize(),n}return e(l,[{key:"destroy",value:function(){return this.parent=void 0,y(h(l.prototype),"destroy",this).call(this),this}},{key:"setPosition",value:function(t,e){var i=this.parent;return void 0===t&&(t=i.x),void 0===e&&(e=i.y),y(h(l.prototype),"setPosition",this).call(this,t,e),this}},{key:"resize",value:function(t,e,i){var n=this.parent;if(void 0===t&&(t=n.width),void 0===e&&(e=n.height),void 0===i&&(i=this.padding),this.widthSave===t&&this.heightSave===e&&this.paddingSave===i)return this;switch(this.clear().fillStyle(16777215),this.shape){case 1:var s=Math.min(t,e)/2;this.fillCircle(0,0,s+i);break;default:this.fillRect(-(t*n.originX)-i,-(e*n.originY)-i,t+2*i,e+2*i)}return this.widthSave=t,this.heightSave=e,this.paddingSave=i,this}}]),l}(),at={rectangle:0,circle:1},ht=Phaser.Geom.Intersects.RectangleToRectangle,ut=Phaser.Geom.Rectangle.Overlaps,ct=function(t){for(;;){var e=t.rexContainer;if(e){if(e.visible){var i=e.parent;if(i){t=i;continue}return!0}return!1}return t.visible}},dt=function(t,e){var i=0,n=e.top,s=e.bottom,l=e.left,r=e.right;return i+=t.contains(l,n)?1:0,i+=t.contains(l,s)?1:0,i+=t.contains(r,n)?1:0,i+=t.contains(r,s)?1:0},ft=function(t,e){t.setChildMaskVisible(e,!0),e.clearMask&&e.clearMask()},pt=function(t,e,i){t.setChildMaskVisible(e,!0),e.setMask&&e.setMask(i)},vt=function(t,e){t.setChildMaskVisible(e,!1),e.clearMask&&e.clearMask()},yt=function(t){var e=0===this.scrollMode?this.topLeftX:this.topLeftY;return this.tableOX+this.table.colIndexToWidth(0,t-1)+e},Ct=function(t){var e=0===this.scrollMode?this.topLeftY:this.topLeftX;return this.tableOY+this.table.rowIndexToHeight(0,t-1)+e},gt=function(){var t=this.preVisibleCells;this.preVisibleCells=this.visibleCells,this.visibleCells=t,this.visibleCells.clear()},bt=Phaser.Math.Clamp,kt={setTableOY:function(t){var e=this.table,i=this.topTableOY,n=this.bottomTableOY,s=t>this.topTableOY,l=t<this.bottomTableOY;this.clampTableOXY&&(e.rowCount<e.heightToRowIndex(this.instHeight,!0)?t=0:s?t=i:l&&(t=n));return this._tableOY!==t&&(this._tableOY=t),s&&(this.execeedTopState||this.emit("execeedtop",this,t,i)),this.execeedTopState=s,l&&(this.execeedBottomState||this.emit("execeedbottom",this,t,n)),this.execeedBottomState=l,this},setTableOX:function(t){var e=this.table,i=this.leftTableOX,n=this.rightTableOX,s=t>this.leftTableOX,l=t<this.rightTableOX;this.clampTableOXY&&(e.colCount<e.widthToColIndex(this.instWidth,!0)?t=0:s?t=i:l&&(t=n));return this._tableOX!==t&&(this._tableOX=t),s&&(this.execeedLeftState||this.emit("execeedleft",this,t,i)),this.execeedLeftState=s,l&&(this.execeedRightState||this.emit("execeedright",this,t,n)),this.execeedRightState=l,this},maskCells:function(){if(!this.cellsMask)return this;if(!this.maskCellsFlag)return this;if(0===this.alpha||!this.visible)return this;for(var t,e=[],i=this.visibleCells.entries,n=0,s=i.length;n<s;n++)(t=i[n].getContainer())&&(t.hasOwnProperty("isRexContainerLite")?t.getAllChildren(e):e.push(t));return function(t,e,i){if(e){void 0===i&&(i=t.getAllChildren());for(var n,s,l=t.getBounds(),r=q(e),o=0,a=i.length;o<a;o++)if(!(n=i[o]).hasOwnProperty("isRexContainerLite")&&n!==r&&ct(n))if(n.getBounds)switch(s=n.getBounds(s),dt(l,s)){case 4:ft(t,n);break;case 0:ht(l,s)||ut(l,s)?pt(t,n,e):vt(t,n);break;default:pt(t,n,e)}else pt(t,n,e)}}(this,this.cellsMask,e),0===this.maskUpdateMode&&(this.maskCellsFlag=!1),this},updateTable:function(t){return void 0===t&&(t=!1),t&&(gt.call(this),Q.call(this)),gt.call(this),function(){if(0!==this.cellsCount){var t=this.table,e=t.heightToRowIndex(-this.tableOY);e<=0&&(e=0);var i=e,n=t.widthToColIndex(-this.tableOX);n<=0&&(n=0);for(var s=n,l=t.colRowToCellIndex(s,i),r=this.bottomBound,o=this.rightBound,a=t.cellsCount-1,h=t.colCount-1,u=yt.call(this,s),c=u,d=Ct.call(this,i);d<r&&l<=a;){if(this.table.isValidCellIdx(l)){var f=t.getCell(l,!0);this.visibleCells.set(f),this.preVisibleCells.contains(f)||tt.call(this,f),0===this.scrollMode?f.setXY(c,d):f.setXY(d,c)}c<o&&s<h?(c+=t.getColWidth(s),s+=1):(c=u,d+=t.getRowHeight(i),s=n,i+=1),l=t.colRowToCellIndex(s,i)}}}.call(this),Q.call(this),this.maskCellsFlag=!0,this},isCellVisible:function(t){var e=this.table.getCell(t,!1);return e&&this.visibleCells.contains(e)},pointToCellIndex:et,pointToCellContainer:function(t,e){var i=et.call(this,t,e);if(null!==i)return this.getCellContainer(i)},eachVisibleCell:function(t,e){return this.visibleCells.each(t,e),this},iterateVisibleCell:function(t,e){return this.visibleCells.iterate(t,e),this},eachCell:function(t,e){return this.table.cells.slice().forEach(t,e),this},iterateCell:function(t,e){return this.table.cells.forEach(t,e),this},setCellsCount:function(t){var e=this.cellsCount;return e===t||(t<e?this.removeCells(t,e-t):this.insertNewCells(e,t-e)),this},insertNewCells:function(t,e){return"object"===a(t)&&(t=t.index),void 0===e&&(e=1),e<=0||(t=bt(t,0,this.cellsCount),this.table.insertNewCells(t,e)),this},removeCells:function(t,e){if("object"===a(t)&&(t=t.index),void 0===e&&(e=1),t<0&&(e+=t,t=0),e<=0)return this;if(t>this.cellsCount)return this;for(var i,n=t,s=t+e;n<s;n++)(i=this.getCell(n,!1))&&(this.visibleCells.contains(i)&&(K.call(this,i),this.visibleCells.delete(i)),this.preVisibleCells.delete(i));return this.table.removeCells(t,e),this},setColumnCount:function(t){return this.table.colCount===t||this.table.setColumnCount(t),this},setGridSize:function(t,e){return this.setCellsCount(t*e),this.table.setColumnCount(t),this},updateVisibleCell:function(t){var e=this.table.getCell(t,!1);return e&&e.container&&tt.call(this,e),this}},mt=Phaser.GameObjects.Group,wt=Phaser.GameObjects.Components,xt=Phaser.Structs.Set,Ot=Phaser.Utils.Objects.GetValue,Pt=function(){t(f,U);var d=u(f);function f(t,e,i,n,s,l){var r;p(this,f),void 0===l&&(l={}),(r=d.call(this,t,e,i,n,s)).type="rexGridTable",r._tableOX=0,r._tableOY=0,r.visibleCells=new xt,r.preVisibleCells=new xt,r.execeedTopState=!1,r.execeedBottomState=!1,r.execeedLeftState=!1,r.execeedRightState=!1,Ot(l,"reuseCellContainer",!1)&&(r.cellContainersPool=new mt(t));var o=Ot(l,"cellVisibleCallback",null);if(null!==o){var a=Ot(l,"cellVisibleCallbackScope",void 0);r.on("cellvisible",o,a)}if(null!==(o=Ot(l,"cellInvisibleCallback",null))){a=Ot(l,"cellInvisibleCallbackScope",void 0);r.on("cellinvisible",o,a)}if(r.setCellsMask(Ot(l,"mask",!0)),r.setScrollMode(Ot(l,"scrollMode",0)),r.setClampMode(Ot(l,"clamplTableOXY",!0)),0===r.scrollMode){var h=Ot(l,"cellWidth",void 0);if(r.expandCellSize=void 0===h,void 0===h){var u=Ot(l,"columns",1);l.cellWidth=r.width/u}}else{h=Ot(l,"cellHeight",void 0);var c=Ot(l,"cellWidth",void 0);r.expandCellSize=void 0===h,l.cellWidth=h,l.cellHeight=c}return r.table=new lt(v(r),l),r.updateTable(),r}return e(f,[{key:"destroy",value:function(t){this.scene&&(this.cellsMask&&this.scene.game.events.off("poststep",this.maskCells,this),this.table.destroy(t),this.table=void 0,this.cellContainersPool&&(this.cellContainersPool.destroy(!0),this.cellContainersPool=void 0),y(h(f.prototype),"destroy",this).call(this,t))}},{key:"setScrollMode",value:function(t){return"string"==typeof t&&(t=Tt[t.toLowerCase()]),this.scrollMode=t,this}},{key:"setClampMode",value:function(t){return void 0===t&&(t=!0),this.clampTableOXY=t,this}},{key:"tableOY",get:function(){return this._tableOY},set:function(t){this.setTableOY(t).updateTable()}},{key:"tableOX",get:function(){return this._tableOX},set:function(t){this.setTableOX(t).updateTable()}},{key:"setTableOXY",value:function(t,e){return this.setTableOY(e).setTableOX(t),this}},{key:"addTableOY",value:function(t){return this.setTableOY(this.tableOY+t),this}},{key:"addTableOX",value:function(t){return this.setTableOX(this.tableOX+t),this}},{key:"addTableOXY",value:function(t,e){return this.addTableOY(e).addTableOX(t),this}},{key:"setTableOYByPercentage",value:function(t){return this.setTableOY(-this.tableVisibleHeight*t),this}},{key:"getTableOYPercentage",value:function(){var t=this.tableVisibleHeight;return 0===t?0:this.tableOY/-t}},{key:"t",get:function(){return this.getTableOYPercentage()},set:function(t){this.setTableOYByPercentage(t).updateTable()}},{key:"getCell",value:function(t){return this.table.getCell(t,!0)}},{key:"getCellContainer",value:function(t){var e,i=this.table.getCell(t,!1);return i&&(e=i.getContainer()),e}},{key:"cellsCount",get:function(){return this.table.cellsCount}},{key:"columnCount",get:function(){return this.table.colCount}},{key:"setCellHeight",value:function(t,e){return("number"==typeof t?this.table.getCell(t,!0):t).height=e,this}},{key:"setCellWidth",value:function(t,e){return("number"==typeof t?this.table.getCell(t,!0):t).width=e,this}},{key:"setCellsMask",value:function(t){var e,i,n;if(!0===t?(e=!0,n=i=0):!1===t?e=!1:(e=Ot(t,"mask",!0),i=Ot(t,"padding",0),n=Ot(t,"updateMode",0)),this.maskCellsFlag=!0,this.maskUpdateMode=n,e){var s=new ot(this,0,i);this.cellsMask=s.createGeometryMask(),this.add(s),"string"==typeof n&&(n=St[n]),this.scene.game.events.on("poststep",this.maskCells,this)}return this}},{key:"instHeight",get:function(){return 0===this.scrollMode?this.height:this.width}},{key:"instWidth",get:function(){return 0===this.scrollMode?this.width:this.height}},{key:"tableHeight",get:function(){return this.table.totalRowsHeight}},{key:"tableWidth",get:function(){return this.table.totalColumnWidth}},{key:"topTableOY",get:function(){return 0}},{key:"bottomTableOY",get:function(){return-this.tableVisibleHeight}},{key:"leftTableOX",get:function(){return 0}},{key:"rightTableOX",get:function(){return-this.tableVisibleWidth}},{key:"tableVisibleHeight",get:function(){var t=this.tableHeight,e=this.instHeight;return e<t?t-e:0}},{key:"tableVisibleWidth",get:function(){var t=this.tableWidth,e=this.instWidth;return e<t?t-e:0}},{key:"bottomLeftY",get:function(){return-(this.displayHeight*this.originY)+this.displayHeight}},{key:"topRightX",get:function(){return-(this.displayWidth*this.originX)+this.displayWidth}},{key:"topLeftX",get:function(){return-(this.displayWidth*this.originX)}},{key:"topLeftY",get:function(){return-(this.displayHeight*this.originY)}},{key:"bottomBound",get:function(){return 0===this.scrollMode?this.bottomLeftY:this.topRightX}},{key:"rightBound",get:function(){return 0===this.scrollMode?this.topRightX:this.bottomLeftY}},{key:"resize",value:function(t,e){return this.width===t&&this.height===e||(y(h(f.prototype),"resize",this).call(this,t,e),this.cellsMask&&(i=q(this.cellsMask),n=t,s=e,!i||void 0===n&&void 0===s||(i.resize?(void 0===n&&(n=i.width),void 0===s&&(s=i.height),i.resize(n,s)):(void 0!==n&&(i.displayWidth=n),void 0!==s&&(i.displayHeight=s)))),this.expandCellSize&&this.table.setDefaultCellWidth(this.instWidth/this.table.colCount),this.updateTable(!0)),this;var i,n,s}}]),f}();Object.assign(Pt.prototype,wt.GetBounds,kt);var Tt={v:0,vertical:0,h:1,horizontal:1},St={update:0,everyTick:1};function Yt(t,e,i,n,s){var l=new Pt(this.scene,t,e,i,n,s);return this.scene.add.existing(l),l}var Xt=Phaser.Utils.Objects.GetValue,Ht=Phaser.GameObjects.BuildGameObject;function Mt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=Xt(t,"width",256),n=Xt(t,"height",256),s=new Pt(this.scene,0,0,i,n,t);return s.syncChildrenEnable=!1,Ht(this.scene,s,t),s.syncChildrenEnable=!0,s.syncPosition().syncVisible().syncAlpha(),s}function Rt(t){return null==t||""===t||0===t.length}var At=function(){t(n,Phaser.Plugins.BasePlugin);var i=u(n);function n(t){var e;return p(this,n),e=i.call(this,t),t.registerGameObject("rexGridTable",Yt,Mt),e}return e(n,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}}]),n}();return function(t,e,i){if("object"===a(t)){if(Rt(e)){if(null==i)return;"object"===a(i)&&(t=i)}else{"string"==typeof e&&(e=e.split("."));var n=e.pop();(function(t,e,i){var n=t;if(!Rt(e)){var s;"string"==typeof e&&(e=e.split("."));for(var l=0,r=e.length;l<r;l++){var o;if(null==n[s=e[l]]||"object"!==a(n[s]))o=l!==r-1||void 0===i?{}:i,n[s]=o;n=n[s]}}return n})(t,e)[n]=i}}}(window,"RexPlugins.GameObjects.GridTable",Pt),At});
  