UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 33.3 kB
!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).reximageboxplugin=e();}(undefined,(function(){function t(e){return t="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(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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,p(n.key),n);}}function n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function r(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e);}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function h(t){var e=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 i,n=s(t);if(e){var r=s(this).constructor;i=Reflect.construct(n,arguments,r);}else i=n.apply(this,arguments);return o(this,i)}}function l(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=l(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},c.apply(this,arguments)}function u(t,e,i,n){return u="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,n){var r,s=l(t,e);if(s){if((r=Object.getOwnPropertyDescriptor(s,e)).set)return r.set.call(n,i),!0;if(!r.writable)return !1}if(r=Object.getOwnPropertyDescriptor(n,e)){if(!r.writable)return !1;r.value=i,Object.defineProperty(n,e,r);}else !function(t,e,i){(e=p(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i;}(n,e,i);return !0},u(t,e,i,n)}function d(t,e,i,n,r){if(!u(t,e,i,n||t)&&r)throw new TypeError("failed to set property");return i}function f(t){return function(t){if(Array.isArray(t))return y(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 y(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 y(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 y(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}function p(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(t,"string");return "symbol"==typeof e?e:String(e)}var v,g=!1;g||(void 0===v&&(v=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<v&&console.error("Minimum supported version : 3.".concat(v)),g=!0);var C=Phaser.GameObjects.Zone,b=Phaser.Utils.Array.Add,m=Phaser.Utils.Array.Remove,P=function(t){r(a,t);var i=h(a);function a(t,n,r,s,o){var h;return e(this,a),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===o&&(o=1),(h=i.call(this,t,n,r,s,o)).children=[],h}return n(a,[{key:"destroy",value:function(t){if(this.scene&&!this.ignoreDestroy){if(t)for(var e,i=this.children.length-1;i>=0;i--)(e=this.children[i]).parentContainer||e.displayList||e.destroy(t);this.clear(!t),c(s(a.prototype),"destroy",this).call(this,t);}}},{key:"contains",value:function(t){return -1!==this.children.indexOf(t)}},{key:"add",value:function(t){var e=this;return b(this.children,t,0,(function(t){t.once("destroy",e.onChildDestroy,e);}),this),this}},{key:"remove",value:function(t,e){var i=this;return m(this.children,t,(function(t){t.off("destroy",i.onChildDestroy,i),e&&t.destroy();})),this}},{key:"onChildDestroy",value:function(t,e){this.remove(t,!1);}},{key:"clear",value:function(t){for(var e,i=0,n=this.children.length;i<n;i++)(e=this.children[i]).off("destroy",this.onChildDestroy,this),t&&e.destroy();return this.children.length=0,this}}]),a}(C),x=Phaser.GameObjects.Components;Phaser.Class.mixin(P,[x.Alpha,x.Flip]);var S,A=function t(e,i){var n;if(void 0===i)e.hasOwnProperty("rexContainer")&&(n=e.rexContainer.parent);else for(n=t(e);n&&n.name!==i;)n=t(n);return n},w=Phaser.Math.DegToRad,k=Phaser.Math.RadToDeg,L=function(t){if(!t.hasOwnProperty("rexContainer")){var e={parent:null,self:null,layer:null,x:0,y:0,syncPosition:!0,rotation:0,syncRotation:!0,scaleX:0,scaleY:0,syncScale:!0,alpha:0,syncAlpha:!0,visible:!0,active:!0};Object.defineProperty(e,"angle",{get:function(){return k(this.rotation)},set:function(t){this.rotation=w(t);}}),Object.defineProperty(e,"displayWidth",{get:function(){return t.width*this.scaleX},set:function(e){this.scaleX=e/t.width;}}),Object.defineProperty(e,"displayHeight",{get:function(){return t.height*this.scaleY},set:function(e){this.scaleY=e/t.height;}}),t.rexContainer=e;}return t.rexContainer},R={setParent:function(t,e){void 0===e&&(e=this);var i=L(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent:function(t,e){return "string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),A(t,e)},getTopmostParent:function(t){return void 0===t&&(t=this),function(t){for(var e=A(t);e;)t=e,e=A(e);return t}(t)}},O=Phaser.Utils.Objects.GetValue,j=P.prototype.add,X=function(t,e){this.setParent(t);var i=L(t);return F(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),j.call(this,t),this.addToParentContainer(t),this.addToRenderLayer(t),this},Y=function(t,e){this.setParent(t);var i=L(t);return F(i,e),i.x=t.x,i.y=t.y,i.rotation=t.rotation,i.scaleX=t.scaleX,i.scaleY=t.scaleY,i.alpha=t.alpha,i.visible=t.visible,i.active=t.active,this.updateChildPosition(t).updateChildAlpha(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),j.call(this,t),this.addToRenderLayer(t),this},F=function(t,e){void 0===e&&(e=!0),"boolean"==typeof e?(t.syncPosition=e,t.syncRotation=e,t.syncScale=e,t.syncAlpha=e,t.syncScrollFactor=e):(t.syncPosition=O(e,"syncPosition",!0),t.syncRotation=O(e,"syncRotation",!0),t.syncScale=O(e,"syncScale",!0),t.syncAlpha=O(e,"syncAlpha",!0),t.syncScrollFactor=O(e,"syncScrollFactor",!0));},T={add:function(t){return Array.isArray(t)?this.addMultiple(t):X.call(this,t),this},pin:function(t,e){return Array.isArray(t)?this.addMultiple(t,e):X.call(this,t,e),this},addMultiple:function(t){for(var e=0,i=t.length;e<i;e++)X.call(this,t[e]);return this},addLocal:function(t){return Array.isArray(t)?this.addMultiple(t):Y.call(this,t),this},pinLocal:function(t,e){return Array.isArray(t)?this.addMultiple(t,e):Y.call(this,t,e),this},addLocalMultiple:function(t){for(var e=0,i=t.length;e<i;e++)Y.call(this,t[e]);return this}},_=P.prototype.remove,M=P.prototype.clear,V={remove:function(t,e){return A(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),_.call(this,t,e)),this},unpin:function(t,e){return A(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),_.call(this,t,e)),this},clear:function(t){for(var e=this.children,i=0,n=e.length;i<n;i++){var r=e[i];this.setParent(r,null),t||this.removeFromRenderLayer(r);}return M.call(this,t),this}},E={getLocalState:function(t){return L(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}},G=Phaser.Math.RotateAround,D={worldToLocal:function(t){return t.x-=this.x,t.y-=this.y,G(t,0,0,-this.rotation),t.x/=this.scaleX,t.y/=this.scaleY,t},localToWorld:function(t){return t.x*=this.scaleX,t.y*=this.scaleY,G(t,0,0,this.rotation),t.x+=this.x,t.y+=this.y,t}},B=function(t,e){return t===e?1:t/e},U={updateChildPosition:function(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=L(t),i=e.parent;return e.syncPosition&&(t.x=e.x,t.y=e.y,i.localToWorld(t)),e.syncRotation&&(t.rotation=e.rotation+i.rotation),e.syncScale&&(t.scaleX=e.scaleX*i.scaleX,t.scaleY=e.scaleY*i.scaleY),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=L(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=B(t.scaleX,i.scaleX),e.scaleY=B(t.scaleY,i.scaleY),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=L(t);return n.x=e,n.y=i,this.updateChildPosition(t),this},resetLocalPositionState:function(){var t=L(this).parent;return t&&t.resetChildPositionState(this),this}},z=Phaser.Math.DegToRad,I={updateChildRotation:function(t){var e=L(t),i=e.parent;return e.syncRotation&&(t.rotation=i.rotation+e.rotation),this},syncRotation:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState:function(t){var e=L(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation:function(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildAngle:function(t,e){return t.angle=e,this.resetChildRotationState(t),this},setChildLocalRotation:function(t,e){return L(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle:function(t,e){return L(t).rotation=z(e),this.updateChildRotation(t),this},resetLocalRotationState:function(){var t=L(this).parent;return t&&t.resetChildRotationState(this),this}},W={updateChildScale:function(t){var e=L(t),i=e.parent;return e.syncScale&&(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=L(t),i=e.parent;return e.scaleX=B(t.scaleX,i.scaleX),e.scaleY=B(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=L(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},resetLocalScaleState:function(){var t=L(this).parent;return t&&t.resetChildScaleState(this),this}},H={updateChildVisible:function(t){var e=L(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=L(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),L(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible:function(t,e){return void 0===e&&(e=!0),L(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState:function(){var t=L(this).parent;return t&&t.resetChildVisibleState(this),this}},N={updateChildAlpha:function(t){var e=L(t),i=e.parent;return e.syncAlpha&&(t.alpha=i.alpha*e.alpha),this},syncAlpha:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState:function(t){var e=L(t),i=e.parent;return e.alpha=B(t.alpha,i.alpha),this},setChildAlpha:function(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha:function(t,e){return L(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState:function(){var t=L(this).parent;return t&&t.resetChildAlphaState(this),this}},Z={updateChildActive:function(t){var e=L(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 L(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),L(t).active=e,this.updateChildActive(t),this},resetLocalActiveState:function(){var t=L(this).parent;return t&&t.resetChildActiveState(this),this}},$={updateChildScrollFactor:function(t){var e=L(t),i=e.parent;return e.syncScrollFactor&&(t.scrollFactorX=i.scrollFactorX,t.scrollFactorY=i.scrollFactorY),this},syncScrollFactor:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},q={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){void 0===t&&(t=!1);var e=this;return this._mask=null,this.setChildMaskVisible(this),this.children.forEach((function(t){t.clearMask&&t.clearMask(!1),t.hasOwnProperty("isRexContainerLite")||e.setChildMaskVisible(t);})),t&&this.mask&&this.mask.destroy(),this}},J=function(t,e){if(t.length<=1)return t;var i;void 0===e&&(e=!1);var n=t[0];return (i=n.displayList?n.displayList:n.parentContainer?n.parentContainer.list:n.scene.sys.displayList).depthSort&&(i.depthSort(),i=i.list),e?t.sort((function(t,e){return i.indexOf(e)-i.indexOf(t)})):t.sort((function(t,e){return i.indexOf(t)-i.indexOf(e)})),t},K={setDepth:function(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),n=0,r=i.length;n<r;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},bringToTop:function(){var t=this.displayList,e=this.getAllChildren([this]);J(e,!1);for(var i=0,n=e.length;i<n;i++){var r=e[i];t.exists(r)&&t.bringToTop(r);}return this},moveDepthBelow:function(t){var e=this.displayList;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);J(i,!1);for(var n=0,r=i.length;n<r;n++){var s=i[n];if(e.exists(s)){e.moveBelow(t,s);break}}return this},moveDepthAbove:function(t){var e=this.displayList;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);J(i,!0);for(var n=0,r=i.length;n<r;n++){var s=i[n];if(e.exists(s)){e.moveAbove(t,s);break}}return this},bringChildToTop:function(t){var e=this.getAllChildren([this]);J(e,!0);var i=e[0];return i===t||i.displayList!==t.displayList||i.displayList.moveAbove(t,i),this},sendChildToBack:function(t){var e=this.getAllChildren([this]);J(e,!1);var i=e[0];return i===t||i.displayList!==t.displayList||i.displayList.moveBelow(t,i),this}},Q=function t(e,i){if(!i(e)&&e.isRexContainerLite)for(var n=e.children,r=0,s=n.length;r<s;r++)t(n[r],i);},tt=function(t,e){for(var i=[t];i.length>0;){var n=i.shift();!e(n)&&n.isRexContainerLite&&i.push.apply(i,f(n.children));}},et=Phaser.Utils.Array,it={getChildren:function(t){if(t)for(var e=0,i=this.children.length;e<i;e++)t.push(this.children[e]);else t=this.children;return t},getAllChildren:function(t){void 0===t&&(t=[]);var e=this;return tt(e,(function(i){i!==e&&t.push(i);})),t},getAllVisibleChildren:function(t){void 0===t&&(t=[]);var e=this;return tt(e,(function(i){if(i!==e)return !i.visible||void t.push(i)})),t},bfs:function(t,e){return void 0===e&&(e=this),tt(e,t),this},dfs:function(t,e){return void 0===e&&(e=this),Q(e,t),this},contains:function(t){var e=A(t);return !!e&&(e===this||this.contains(e))},getByName:function(t,e){if(e){for(var i,n,r=[this];r.length;)for(var s=0,a=(i=r.shift()).children.length;s<a;s++){if((n=i.children[s]).name===t)return n;n.isRexContainerLite&&r.push(n);}return null}return et.GetFirst(this.children,"name",t)},getRandom:function(t,e){return et.GetRandom(this.children,t,e)},getFirst:function(t,e,i,n){return et.GetFirstElement(this.children,t,e,i,n)},getAll:function(t,e,i,n){return et.GetAll(this.children,t,e,i,n)},count:function(t,e,i,n){return et.CountAllMatching(this.children,t,e,i,n)},swap:function(t,e){return et.Swap(this.children,t,e),this},setAll:function(t,e,i,n){return et.SetAll(this.children,t,e,i,n),this}},nt=function(t){for(var e=[],i=0,n=t.length;i<n;i++){var r=t[i];r.hasOwnProperty("rexContainer")&&e.push(r.rexContainer);}return e},rt=function(t,e,i){if(i.parent){var n=i.parent,r=i.self;switch(e){case"x":case"y":n.updateChildPosition(r);break;case"angle":case"rotation":n.updateChildRotation(r);break;case"scaleX":case"scaleY":case"displayWidth":case"displayHeight":n.updateChildScale(r);break;case"alpha":n.updateChildAlpha(r);break;default:n.updateChildPosition(r),n.updateChildRotation(r),n.updateChildScale(r),n.updateChildAlpha(r);}}else t.remove();},st={tweenChild:function(t){var e=t.targets;Array.isArray(e)||(e=[e]);var i=this.scene||function(t){for(var e=0,i=t.length;e<i;e++){var n=t[e].scene;if(n)return n}return null}(e);if(i){t.targets=nt(e);var n=i.tweens.add(t);return n.on("update",rt),n}},tweenSelf:function(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig:function(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=nt(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),rt(t,void 0,e);},t},tween:function(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}},at=Phaser.GameObjects.Container,ot=Phaser.GameObjects.Layer,ht=function(t){return t instanceof ot},lt=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return !!t.displayList||!!t.parentContainer}))},ct=function(t){var e=lt(this);return J(e),t.add(e),this},ut=function(t,e,i){var n=lt(this);return J(n,e),t.remove(n),i&&n.forEach((function(t){t.addToDisplayList();})),this},dt={addToContainer:function(t){return t instanceof at?(this._setParentContainerFlag=!0,ct.call(this,t),this._setParentContainerFlag=!1,this):this},addToLayer:function(t){return ht(t)?(ct.call(this,t),this):this},removeFromContainer:function(){return this.parentContainer?(this._setParentContainerFlag=!0,ut.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer:function(t){return void 0===t&&(t=!0),ht(this.displayList)?(ut.call(this,this.displayList,!1,t),this):this},getParentContainer:function(){if(this.parentContainer)return this.parentContainer;for(var t=this.getParent();t;){var e=t.parentContainer;if(e)return e;t=t.getParent();}return null},addToParentContainer:function(t){if(!t.displayList)return this;var e=this.getParentContainer();return e?(t.isRexContainerLite?t.addToContainer(e):e.add(t),this):this}},ft={hasLayer:function(){return !!this.privateRenderLayer},enableLayer:function(){if(this.hasLayer())return this;var t=this.scene.add.layer();return this.moveDepthBelow(t),this.addToLayer(t),this.privateRenderLayer=t,this},getLayer:function(){return this.hasLayer()||this.enableLayer(),this.privateRenderLayer},getRenderLayer:function(){if(this.hasLayer())return this.privateRenderLayer;for(var t=this.getParent();t;){var e=t.privateRenderLayer;if(e)return e;t=t.getParent();}return null},addToRenderLayer:function(t){if(!t.displayList)return this;var e=this.getRenderLayer();return e?(t.isRexContainerLite?t.addToLayer(e):e.add(t),L(t).layer=e,this):this},removeFromRenderLayer:function(t){var e=L(t),i=e.layer;return i?(t.isRexContainerLite?t.removeFromLayer(!0):i.remove(t),e.layer=null,this):this}},yt=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},pt=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height},vt=Phaser.Geom.Rectangle,gt=Phaser.Math.Vector2,Ct=Phaser.Math.RotateAround,bt=function(t,e){if(void 0===e?e=new vt:!0===e&&(void 0===mt&&(mt=new vt),e=mt),t.getBounds)return t.getBounds(e);var i,n,r,s,a,o,h,l;if(t.parentContainer){var c=t.parentContainer.getBoundsTransformMatrix();Pt(t,e),c.transformPoint(e.x,e.y,e),i=e.x,n=e.y,xt(t,e),c.transformPoint(e.x,e.y,e),r=e.x,s=e.y,St(t,e),c.transformPoint(e.x,e.y,e),a=e.x,o=e.y,At(t,e),c.transformPoint(e.x,e.y,e),h=e.x,l=e.y;}else Pt(t,e),i=e.x,n=e.y,xt(t,e),r=e.x,s=e.y,St(t,e),a=e.x,o=e.y,At(t,e),h=e.x,l=e.y;return e.x=Math.min(i,r,a,h),e.y=Math.min(n,s,o,l),e.width=Math.max(i,r,a,h)-e.x,e.height=Math.max(n,s,o,l)-e.y,e},mt=void 0,Pt=function(t,e,i){return void 0===e?e=new gt:!0===e&&(void 0===wt&&(wt=new gt),e=wt),t.getTopLeft?t.getTopLeft(e):(e.x=t.x-yt(t)*t.originX,e.y=t.y-pt(t)*t.originY,kt(t,e,i))},xt=function(t,e,i){return void 0===e?e=new gt:!0===e&&(void 0===wt&&(wt=new gt),e=wt),t.getTopRight?t.getTopRight(e):(e.x=t.x-yt(t)*t.originX+yt(t),e.y=t.y-pt(t)*t.originY,kt(t,e,i))},St=function(t,e,i){return void 0===e?e=new gt:!0===e&&(void 0===wt&&(wt=new gt),e=wt),t.getBottomLeft?t.getBottomLeft(e):(e.x=t.x-yt(t)*t.originX,e.y=t.y-pt(t)*t.originY+pt(t),kt(t,e,i))},At=function(t,e,i){return void 0===e?e=new gt:!0===e&&(void 0===wt&&(wt=new gt),e=wt),t.getBottomRight?t.getBottomRight(e):(e.x=t.x-yt(t)*t.originX+yt(t),e.y=t.y-pt(t)*t.originY+pt(t),kt(t,e,i))},wt=void 0,kt=function(t,e,i){(void 0===i&&(i=!1),0!==t.rotation&&Ct(e,t.x,t.y,t.rotation),i&&t.parentContainer)&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e);return e},Lt=Phaser.Geom.Rectangle,Rt=Phaser.Geom.Rectangle.Union,Ot=function(e,i){var n=Array.isArray(e);if(void 0===i?i=n?[]:{}:function(e){if("object"!==t(e)||null===e)return e;if(Array.isArray(e))e.length=0;else for(var i in e)delete e[i];}(i),n){i.length=e.length;for(var r=0,s=e.length;r<s;r++)i[r]=e[r];}else for(var a in e)i[a]=e[a];return i},jt=Phaser.GameObjects.GameObject,Xt=Phaser.Utils.Objects.GetValue,Yt=Phaser.Textures.DynamicTexture,Ft=Phaser.Utils.String.UUID,Tt=function(t){if(t){var e,i,n=t.gameObjects,r=t.renderTexture,s=Xt(t,"x",void 0),a=Xt(t,"y",void 0),o=Xt(t,"width",void 0),h=Xt(t,"height",void 0),l=Xt(t,"originX",0),c=Xt(t,"originY",0),u=Xt(t,"padding",0);if(void 0===o||void 0===h||void 0===s||void 0===a){var d=function(t,e){var i;void 0===e?e=new Lt:!0===e&&(void 0===S&&(S=new Lt),e=S),e.setTo(0,0,0,0);for(var n=!0,r=0,s=t.length;r<s;r++)if((i=t[r]).getBounds){var a=bt(i,!0);n?(e.setTo(a.x,a.y,a.width,a.height),n=!1):Rt(a,e,e);}return e}(n,!0);void 0!==s&&void 0!==a?(o=2*Math.max(s-d.left,d.right-s),h=2*Math.max(a-d.top,d.bottom-a),l=.5,c=.5):(s=d.x,a=d.y,o=d.width,h=d.height,l=0,c=0),e=d.x,i=d.y;}else e=s+(0-l)*o,i=a+(0-c)*h;e-=u,i-=u,o+=2*u,h+=2*u;var f=n[0].scene;y&&!r&&(r=new Yt(f.sys.textures,Ft(),o,h)),r||(r=f.add.renderTexture(0,0,o,h)),r.setPosition&&r.setPosition(s,a),r.width===o&&r.height===h||r.setSize(o,h),r.setOrigin&&r.setOrigin(l,c),r.camera.setScroll(e,i),n=J(Ot(n)),r.draw(n);var y=t.saveTexture;if(y)if(r instanceof jt)r.saveTexture(y);else {var p=r,v=p.manager;v.exists(p.key)?v.renameTexture(p.key,key):(p.key=key,v.list[key]=p,v.emit("addtexture",key,p),v.emit("addtexture-".concat(key),p));}return r}},_t={snapshot:function(t){var e=this.scaleX,i=this.scaleY,n=1===e&&1===i;n||this.setScale(1),void 0===t&&(t={}),t.gameObjects=this.getAllVisibleChildren(),t.x=this.x,t.y=this.y,t.originX=this.originX,t.originY=this.originY;var r=Tt(t),s=!!r.scene;return n||(this.setScale(e,i),s&&r.setScale(e,i)),s?r:this}},Mt=Phaser.Utils.Objects.GetValue,Vt=function(t,e,i,n,r,s,a){if(t.getBounds||void 0!==t.width&&void 0!==t.height){void 0===i&&(i=16777215),void 0===n&&(n=1),void 0===r&&(r=null),void 0===s&&(s=1),void 0===a&&(a=0);var o=Pt(t,Et[0]);o.x-=a,o.y-=a;var h=xt(t,Et[1]);h.x+=a,h.y-=a;var l=At(t,Et[2]);l.x+=a,l.y+=a;var c=St(t,Et[3]);c.x-=a,c.y+=a,null!==r&&e.fillStyle(r,s).fillPoints(Et,!0,!0),null!==i&&e.lineStyle(n,i).strokePoints(Et,!0,!0);}},Et=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],Gt=Phaser.Utils.Objects.GetValue,Dt=Phaser.Math.RotateAround,Bt={changeOrigin:function(t,e){this.syncChildrenEnable=!1,function(t,e,i){void 0===i&&(i=e);var n={x:(e-t.originX)*t.displayWidth,y:(i-t.originY)*t.displayHeight};Dt(n,0,0,t.rotation),t.originX=e,t.originY=i,t.x=t.x+n.x,t.y=t.y+n.y;}(this,t,e),this.syncChildrenEnable=!0;for(var i=this.getAllChildren(),n=0,r=i.length;n<r;n++)this.resetChildPositionState(i[n]);return this},drawBounds:function(t,e){var i=Gt(e,"drawContainer",!0),n=Gt(e,"children");return void 0===n&&(n=this.getAllVisibleChildren([this])),i||(n=n.filter((function(t){return !t.isRexContainerLite}))),function(t,e,i){var n,r,s,a,o;if("number"==typeof i?n=i:(n=Mt(i,"color"),r=Mt(i,"lineWidth"),s=Mt(i,"fillColor"),a=Mt(i,"fillAlpha",1),o=Mt(i,"padding",0)),Array.isArray(t))for(var h=0,l=t.length;h<l;h++)Vt(t[h],e,n,r,s,a,o);else Vt(t,e,n,r,s,a,o);}(n,t,e),this}};Object.assign(Bt,R,T,V,E,D,U,I,W,H,N,Z,$,q,K,it,st,dt,ft,_t);var Ut=function(t){r(a,t);var i=h(a);function a(t,n,r,s,o,h){var l;return e(this,a),Array.isArray(s)&&(h=s,s=void 0,o=void 0),(l=i.call(this,t,n,r,s,o)).type="rexContainerLite",l.isRexContainerLite=!0,l.syncChildrenEnable=!0,l._active=!0,l._mask=null,l._scrollFactorX=1,l._scrollFactorY=1,l.privateRenderLayer=void 0,h&&l.add(h),l}return n(a,[{key:"destroy",value:function(t){this.scene&&!this.ignoreDestroy&&(this.syncChildrenEnable=!1,c(s(a.prototype),"destroy",this).call(this,t),this.privateRenderLayer&&(this.privateRenderLayer.list.length=0,this.privateRenderLayer.destroy()));}},{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 c(s(a.prototype),"rotation",this)},set:function(t){this.rotation!==t&&(d(s(a.prototype),"rotation",t,this,!0),this.syncPosition());}},{key:"scaleX",get:function(){return c(s(a.prototype),"scaleX",this)},set:function(t){this.scaleX!==t&&(d(s(a.prototype),"scaleX",t,this,!0),this.syncPosition());}},{key:"scaleY",get:function(){return c(s(a.prototype),"scaleY",this)},set:function(t){this.scaleY!==t&&(d(s(a.prototype),"scaleY",t,this,!0),this.syncPosition());}},{key:"scale",get:function(){return c(s(a.prototype),"scale",this)},set:function(t){this.scale!==t&&(d(s(a.prototype),"scale",t,this,!0),this.syncPosition());}},{key:"visible",get:function(){return c(s(a.prototype),"visible",this)},set:function(t){c(s(a.prototype),"visible",this)!==t&&(d(s(a.prototype),"visible",t,this,!0),this.syncVisible());}},{key:"alpha",get:function(){return c(s(a.prototype),"alpha",this)},set:function(t){c(s(a.prototype),"alpha",this)!==t&&(d(s(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}},{key:"parentContainer",get:function(){return this._parentContainer},set:function(t){this._parentContainer||t?this.setParentContainerFlag?this._parentContainer=t:this._parentContainer&&!t?(this.removeFromContainer(),this._parentContainer=t):t?(this._parentContainer=t,this.addToContainer(t)):this._parentContainer=t:this._parentContainer=t;}},{key:"setParentContainerFlag",get:function(){if(this._setParentContainerFlag)return !0;var t=A(this);return !!t&&t.setParentContainerFlag}}],[{key:"GetParent",value:function(t){return A(t)}}]),a}(P);Object.assign(Ut.prototype,Bt);var zt={},It={scaleImage:function(){var t=this.image,e=function(t,e,i,n){void 0===i&&(i=!0),void 0===n?n={}:!0===n&&(n=zt);var r=t.width,s=t.height,a=e.width,o=e.height;if(r<=a&&s<=o)if(i){var h=a/o;h<(l=r/s)?(n.width=a,n.height=a/l):h>l?(n.width=o*l,n.height=o):(n.width=a,n.height=o);}else n.width=r,n.height=s;else {var l=r/s;n.width=Math.min(r,a),n.height=Math.min(s,o);var c=n.width/n.height;c<l?n.height=n.width/l:c>l&&(n.width=n.height*l);}return n}(t,{width:this.width,height:this.height},this.scaleUp,!0);return t.setDisplaySize(e.width,e.height),this.resetChildScaleState(t),this}};Object.assign(It,{setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}});var Wt=[Phaser.GameObjects.Image,Phaser.GameObjects.Sprite,Phaser.GameObjects.Mesh,Phaser.GameObjects.Shader,Phaser.GameObjects.Video],Ht=function(t){if(t.resize)return !0;if(!t.setSize)return !1;for(var e=0,i=Wt.length;e<i;e++){var n=Wt[e];if(n&&t instanceof n)return !1}return !0},Nt=function(){var t,e,i,n=this.background;return n?(n.setOrigin(this.originX,this.originY),n.setPosition(this.x,this.y),t=n,e=this.displayWidth,i=this.displayHeight,!t||void 0===e&&void 0===i||(Ht(t)?(void 0===e&&(e=t.width),void 0===i&&(i=t.height),t.resize?t.resize(e,i):t.setSize(e,i)):(void 0!==e&&(t.displayWidth=e),void 0!==i&&(t.displayHeight=i))),this.resetChildScaleState(n),this):this},Zt=Phaser.Utils.Objects.IsPlainObject,$t=Phaser.Utils.Objects.GetValue,qt=function(t){r(a,t);var i=h(a);function a(t,n,r,s,o,h){var l;e(this,a),Zt(n)?(n=$t(h=n,"x",0),r=$t(h,"y",0),s=$t(h,"key",void 0),o=$t(h,"frame",void 0)):Zt(o)&&(h=o,o=void 0);var c=$t(h,"image");c?c.setPosition(n,r).setOrigin(.5):(c=t.add.image(n,r,s,o),void 0===s&&c.setVisible(!1)),(l=i.call(this,t,n,r,1,1)).type="rexImageBox";var u=$t(h,"background",!0);u&&l.add(u),l.background=u,l.add(c),l.image=c,l.scaleUp=$t(h,"scaleUp",!1);var d=$t(h,"width",c.width),f=$t(h,"height",c.height);return l.resize(d,f),l}return n(a,[{key:"texture",get:function(){return this.image.texture}},{key:"frame",get:function(){return this.image.frame}},{key:"flipX",get:function(){return this._flipX},set:function(t){this._flipX!==t&&(this._flipX=t,this.image.setFlipX(t));}},{key:"flipY",get:function(){return this._flipY},set:function(t){this._flipY!==t&&(this._flipY=t,this.image.setFlipY(t));}},{key:"resize",value:function(t,e){return c(s(a.prototype),"resize",this).call(this,t,e),Nt.call(this),this.scaleImage(),this}},{key:"setTexture",value:function(t,e){var i=this.image;return i.setTexture(t,e),null!==t?(this.setChildVisible(i,!0),this.scaleImage()):this.setChildVisible(i,!1),this}}]),a}(Ut);function Jt(t,e,i,n,r){var s=new qt(this.scene,t,e,i,n,r);return this.scene.add.existing(s),s}Object.assign(qt.prototype,It);var Kt=Phaser.Utils.Objects.GetAdvancedValue,Qt=Phaser.GameObjects.BuildGameObject;function te(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=Kt(t,"key",null),n=Kt(t,"frame",null),r=new qt(this.scene,0,0,i,n,t);return Qt(this.scene,r,t),r}var ee=function(t){return null==t||""===t||0===t.length},ie=function(t){r(s,Phaser.Plugins.BasePlugin);var i=h(s);function s(t){var n;return e(this,s),n=i.call(this,t),t.registerGameObject("rexImageBox",Jt,te),n}return n(s,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}}]),s}();return function(e,i,n,r){if(void 0===r&&(r="."),"object"===t(e)){if(ee(i)){if(null==n)return;"object"===t(n)&&(e=n);}else {"string"==typeof i&&(i=i.split(r));var s=i.pop(),a=function(e,i,n){var r=e;if(ee(i));else {var s;"string"==typeof i&&(i=i.split("."));for(var a=0,o=i.length;a<o;a++){var h;null!=r[s=i[a]]&&"object"===t(r[s])||(h=a===o-1?void 0===n?{}:n:{},r[s]=h),r=r[s];}}return r}(e,i);a[s]=n;}}}(window,"RexPlugins.GameObjects.ImageBox",qt),ie}));