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).rexperspectiveimageplugin=e()}(this,function(){"use strict";function h(t){return(h="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 k(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 l(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function f(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 c(t){return(c=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 b(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function P(n){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=c(n);if(r){var i=c(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return function(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 b(t)}(this,t)}}function u(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}function d(t,e,i){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=u(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(i):r.value}})(t,e,i||t)}function s(t,e,i,n){return(s="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,n){var r,s,a,o,h=u(t,e);if(h){if((r=Object.getOwnPropertyDescriptor(h,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 o=i,(a=e)in(s=n)?Object.defineProperty(s,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):s[a]=o;return!0})(t,e,i,n)}function e(t,e,i,n,r){if(!s(t,e,i,n||t)&&r)throw new Error("failed to set property");return i}function a(t){return function(t){if(Array.isArray(t))return r(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 r(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 r(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 r(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 t=Phaser.Math.Vector3,o=Phaser.Math.Matrix4,p=new t,v=new t,y=new o,g=Phaser.GameObjects.Mesh,m=Phaser.Utils.Objects.IsPlainObject,C=Phaser.Utils.Objects.GetValue,x=Phaser.Geom.Mesh.GenerateGridVerts,w=Phaser.Math.RadToDeg,S=Phaser.Math.DegToRad,O=1+1/Math.sin(S(45)),R=function(){f(c,g);var u=P(c);function c(t,e,i,n,r,s){var a;k(this,c),m(e)&&(e=C(s=e,"x",0),i=C(s,"y",0),n=C(s,"key",null),r=C(s,"frame",null)),(a=u.call(this,t,e,i,n,r)).type="rexPerspectiveImage",a.setSizeToFrame(),a.resetPerspective(),a.panZ(O),a.hideCCW=C(s,"hideCCW",!0);var o=C(s,"gridWidth",32),h=C(s,"girdHeight",o);return a.resetVerts(o,h),a}return l(c,[{key:"resetPerspective",value:function(){return this.setPerspective(this.width,this.height,45),this}},{key:"resetVerts",value:function(t,e){if(void 0!==t&&(this.girdWidth=t),void 0!==e&&(this.girdHeight=e),this.clear(),this.dirtyCache[9]=-1,0===this.width||0===this.height)return this;var i=this.frame.cutWidth,n=this.frame.cutHeight;return x({mesh:this,texture:this.texture.key,frame:this.frame.name,width:i/this.height,height:n/this.height,widthSegments:Math.ceil(i/this.girdWidth),heightSegments:Math.ceil(n/this.girdHeight),flipY:this.frame.source.isRenderTexture}),this}},{key:"syncSize",value:function(){return this.setSizeToFrame(),this.resetPerspective(),this.resetVerts(),this}},{key:"rotationX",get:function(){return this.modelRotation.x},set:function(t){this.modelRotation.x=t}},{key:"angleX",get:function(){return w(this.rotationX)},set:function(t){this.rotationX=S(t)}},{key:"rotationY",get:function(){return this.modelRotation.y},set:function(t){this.modelRotation.y=t}},{key:"angleY",get:function(){return w(this.rotationY)},set:function(t){this.rotationY=S(t)}},{key:"rotationZ",get:function(){return this.modelRotation.z},set:function(t){this.modelRotation.z=t}},{key:"angleZ",get:function(){return w(this.rotationZ)},set:function(t){this.rotationZ=S(t)}},{key:"transformVerts",value:function(t,e,i,n,r,s){return function(t,e,i,n,r,s,a){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),p.set(e,i,n),v.set(r,s,a),y.fromRotationXYTranslation(v,p,!0);for(var o=0,h=t.vertices.length;o<h;o++)t.vertices[o].transformMat4(y)}(this,t,e,i,n,r,s),this}},{key:"forceUpdate",value:function(){return this.dirtyCache[10]=1,this}}]),c}();function E(t,e,i,n,r){var s=new R(this.scene,t,e,i,n,r);return this.scene.add.existing(s),s}var A=Phaser.Utils.Objects.GetAdvancedValue,j=Phaser.GameObjects.BuildGameObject;function F(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=A(t,"key",null),n=A(t,"frame",null),r=new R(this.scene,0,0,i,n,t);return j(this.scene,r,t),r}var Y=Phaser.GameObjects.RenderTexture,T=Phaser.Utils.Objects.IsPlainObject,_=Phaser.Utils.Objects.GetValue,X=function(){f(u,R);var h=P(u);function u(t,e,i,n,r,s){var a;k(this,u),T(e)&&(e=_(s=e,"x",0),i=_(s,"y",0),n=_(s,"width",32),r=_(s,"height",32));var o=new Y(t,e,i,n,r).setOrigin(.5);return(a=h.call(this,t,e,i,o.texture.key,null,s)).type="rexPerspectiveRenderTexture",a.rt=o,a}return l(u,[{key:"destroy",value:function(t){d(c(u.prototype),"destroy",this).call(this,t),this.rt.destroy(t),this.rt=null}}]),u}();function M(t,e,i,n,r){var s=new X(this.scene,t,e,i,n,r);return this.scene.add.existing(s),s}var D=Phaser.Utils.Objects.GetAdvancedValue,I=Phaser.GameObjects.BuildGameObject;function V(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=D(t,"x",0),n=D(t,"y",0),r=D(t,"width",32),s=D(t,"height",32),a=new X(this.scene,i,n,r,s,t);return I(this.scene,a,t),a}var G=Phaser.GameObjects.Zone,L=Phaser.Utils.Array.Add,B=Phaser.Utils.Array.Remove,U=function(){f(o,G);var a=P(o);function o(t,e,i,n,r){var s;return k(this,o),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1),(s=a.call(this,t,e,i,n,r)).children=[],s}return l(o,[{key:"destroy",value:function(t){if(this.scene){if(t)for(var e,i=this.children.length-1;0<=i;i--)(e=this.children[i]).parentContainer||e.displayList||e.destroy(t);this.clear(!t),d(c(o.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 L(this.children,t,0,function(t){t.once("destroy",e.onChildDestroy,e)},this),this}},{key:"remove",value:function(t,e){var i=this;return B(this.children,t,function(t){t.off("destroy",i.onChildDestroy,i),e&&t.destroy()}),this}},{key:"onChildDestroy",value:function(t){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}}]),o}(),z=Phaser.GameObjects.Components;Phaser.Class.mixin(U,[z.Alpha,z.Flip]);function W(t){var e;return t.hasOwnProperty("rexContainer")&&(e=t.rexContainer.parent),e}function N(t){return t.hasOwnProperty("rexContainer")||(t.rexContainer={}),t.rexContainer}function Z(t){return this.setParent(t),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),Q.call(this,t),this}function J(t){this.setParent(t);var e=N(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),Q.call(this,t),this}function H(t,e){return t===e?1:t/e}function $(t,e){if(0===t.length)return t;void 0===e&&(e=!1);var i=t[0].scene.sys.displayList;return i.depthSort(),e?t.sort(function(t,e){return i.getIndex(e)-i.getIndex(t)}):t.sort(function(t,e){return i.getIndex(t)-i.getIndex(e)}),t}function q(t){var e=this.getAllChildren([this]);return $(e),t.add(e),this}var K={setParent:function(t,e){void 0===e&&(e=this);var i=N(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),W(t)},getTopmostParent:function(t){return void 0===t&&(t=this),function(t){for(var e=W(t);e;)e=W(t=e);return t}(t)}},Q=U.prototype.add,tt={add:function(t){return Array.isArray(t)?this.addMultiple(t):Z.call(this,t),this},addMultiple:function(t){for(var e=0,i=t.length;e<i;e++)Z.call(this,t[e]);return this},addLocal:function(t){return Array.isArray(t)?this.addMultiple(t):J.call(this,t),this},addLocalMultiple:function(t){for(var e=0,i=t.length;e<i;e++)J.call(this,t[e]);return this}},et=U.prototype.remove,it=U.prototype.clear,nt={remove:function(t,e){return W(t)!==this||(this.setParent(t,null),et.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 it.call(this,t),this}},rt={getLocalState:function(t){return N(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}},st=Phaser.Math.RotateAround,at={worldToLocal:function(t){return t.x-=this.x,t.y-=this.y,st(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,st(t,0,0,this.rotation),t.x+=this.x,t.y+=this.y,t}},ot={updateChildPosition:function(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=N(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=N(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=H(t.scaleX,i.scaleX),e.scaleY=H(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=N(t);return n.x=e,n.y=i,this.updateChildPosition(t),this},resetLocalPositionState:function(){var t=N(this).parent;return t&&t.resetChildPositionState(this),this}},ht={updateChildRotation:function(t){var e=N(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=N(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 N(t).rotation=e,this.updateChildRotation(t),this},resetLocalRotationState:function(){var t=N(this).parent;return t&&t.resetChildRotationState(this),this}},ut={updateChildScale:function(t){var e=N(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=N(t),i=e.parent;return e.scaleX=H(t.scaleX,i.scaleX),e.scaleY=H(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=N(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=N(this).parent;return t&&t.resetChildScaleState(this),this}},ct={updateChildVisible:function(t){var e=N(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=N(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),N(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible:function(t,e){return void 0===e&&(e=!0),N(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState:function(){var t=N(this).parent;return t&&t.resetChildVisibleState(this),this}},lt={updateChildAlpha:function(t){var e=N(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=N(t),i=e.parent;return e.alpha=H(t.alpha,i.alpha),this},setChildAlpha:function(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha:function(t,e){return N(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState:function(){var t=N(this).parent;return t&&t.resetChildAlphaState(this),this}},ft={updateChildActive:function(t){var e=N(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 N(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),N(t).active=e,this.updateChildActive(t),this},resetLocalActiveState:function(){var t=N(this).parent;return t&&t.resetChildActiveState(this),this}},dt={updateChildScrollFactor:function(t){var e=N(t).parent;return t.setScrollFactor(e.scrollFactorX,e.scrollFactorY),this},syncScrollFactor:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},pt={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}},vt=Phaser.Utils.Array,yt={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=[]);for(var e,i=this.children,n=0,r=i.length;n<r;n++){if(e=i[n],t.push(e),e.hasOwnProperty("isRexContainerLite"))t.push.apply(t,a(e.getAllChildren()))}return t},getAllVisibleChildren:function(t){void 0===t&&(t=[]);for(var e,i=this.children,n=0,r=i.length;n<r;n++){if((e=i[n]).visible)if(t.push(e),e.hasOwnProperty("isRexContainerLite"))t.push.apply(t,a(e.getAllVisibleChildren()))}return t},contains:function(t){var e=W(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 vt.GetFirst(this.children,"name",t)},getRandom:function(t,e){return vt.GetRandom(this.children,t,e)},getFirst:function(t,e,i,n){return vt.GetFirstElement(this.children,t,e,i,n)},getAll:function(t,e,i,n){return vt.GetAll(this.children,t,e,i,n)},count:function(t,e,i,n){return vt.CountAllMatching(this.children,t,e,i,n)},swap:function(t,e){return vt.Swap(this.children,t,e),this},setAll:function(t,e,i,n){return vt.SetAll(this.children,t,e,i,n),this}},gt={tweenChild:function(t){var e,i=t.targets;e=i,"[object Array]"!==Object.prototype.toString.call(e)&&(i=[i]);for(var n,r,s=[],a=0,o=i.length;a<o;a++)(r=i[a]).hasOwnProperty("rexContainer")&&(n=r.scene,s.push(r.rexContainer));if(n){t.targets=s;var h=n.tweens.add(t);return h.on("update",function(t,e,i){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":n.updateChildScale(r);break;case"alpha":n.updateChildAlpha(r)}}),h}},tween:function(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}},mt={addToLayer:q,addToContainer:q},kt=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};kt(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}};Object.assign(bt,K,tt,nt,rt,at,ot,ht,ut,ct,lt,ft,dt,pt,{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}},yt,gt,mt);var Pt=function(){f(h,U);var o=P(h);function h(t,e,i,n,r,s){var a;return k(this,h),(a=o.call(this,t,e,i,n,r)).type="rexContainerLite",a.isRexContainerLite=!0,a.syncChildrenEnable=!0,a._active=!0,a._mask=null,a._scrollFactorX=1,a._scrollFactorY=1,s&&a.add(s),a}return l(h,[{key:"destroy",value:function(t){this.scene&&(this.syncChildrenEnable=!1,d(c(h.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 d(c(h.prototype),"rotation",this)},set:function(t){this.rotation!==t&&(e(c(h.prototype),"rotation",t,this,!0),this.syncPosition())}},{key:"scaleX",get:function(){return d(c(h.prototype),"scaleX",this)},set:function(t){this.scaleX!==t&&(e(c(h.prototype),"scaleX",t,this,!0),this.syncPosition())}},{key:"scaleY",get:function(){return d(c(h.prototype),"scaleY",this)},set:function(t){this.scaleY!==t&&(e(c(h.prototype),"scaleY",t,this,!0),this.syncPosition())}},{key:"flipX",get:function(){return d(c(h.prototype),"flipX",this)},set:function(t){d(c(h.prototype),"flipX",this)!==t&&(e(c(h.prototype),"flipX",t,this,!0),this.syncPosition())}},{key:"flipY",get:function(){return d(c(h.prototype),"flipY",this)},set:function(t){d(c(h.prototype),"flipY",this)!==t&&(e(c(h.prototype),"flipY",t,this,!0),this.syncPosition())}},{key:"visible",get:function(){return d(c(h.prototype),"visible",this)},set:function(t){d(c(h.prototype),"visible",this)!==t&&(e(c(h.prototype),"visible",t,this,!0),this.syncVisible())}},{key:"alpha",get:function(){return d(c(h.prototype),"alpha",this)},set:function(t){d(c(h.prototype),"alpha",this)!==t&&(e(c(h.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:"GetParent",value:function(t){return W(t)}}]),h}();Object.assign(Pt.prototype,bt);function Ct(t,e,i,n){if(Array.isArray(t))for(var r=0,s=t.length;r<s;r++){var a=t[r];if((!n||a)&&(i?e.call(i,a,r,t):e(a,r,t)))return}else{for(var o in t){a=t[o];if((!n||a)&&(i?e.call(i,a,o,t):e(a,o,t)))return}}}function xt(t,e){var i;return void 0===e&&(e=jt),At(e)?(e.hasOwnProperty("type")||(e.hasOwnProperty("key")?e.type="image":e.hasOwnProperty("width")&&(e.type="rendertexture")),i=new Ft[e.type](t,e),t.add.existing(i)):i=e,i}function wt(t,e,i){var n;if(void 0===i){var r;n=[];for(var s=0,a=e.length;s<a;s++)o=(r=e[s])?xt(t,r):null,n.push(o)}else{var o,h;n={};for(s=0,a=i.length;s<a;s++)h=i[s],o=e.hasOwnProperty(h)?xt(t,e[h]):null,n[h]=o}return n}function St(t){return t instanceof _t}var Ot=Phaser.Math.RadToDeg,Rt=Phaser.Math.DegToRad,Et=function(){f(h,Pt);var o=P(h);function h(t,e,i,n,r,s){var a;return k(this,h),(a=o.call(this,t,e,i,n,r)).faces=s,Ct(s,function(t){t.setPosition(e,i),this.add(t)},b(a),!0),a}return l(h,[{key:"rotationX",get:function(){return 0},set:function(){}},{key:"angleX",get:function(){return Ot(this.rotationX)},set:function(t){this.rotationX=Rt(t)}},{key:"rotationY",get:function(){return 0},set:function(){}},{key:"angleY",get:function(){return Ot(this.rotationY)},set:function(t){this.rotationY=Rt(t)}},{key:"rotationZ",get:function(){return 0},set:function(){}},{key:"angleZ",get:function(){return Ot(this.rotationZ)},set:function(t){this.rotationZ=Rt(t)}},{key:"setDebug",value:function(e,i){return Ct(this.faces,function(t){t.setDebug(e,i)},null,!0),this}},{key:"panX",value:function(e){return Ct(this.faces,function(t){t.panX(e)},null,!0),this}},{key:"panY",value:function(e){return Ct(this.faces,function(t){t.panY(e)},null,!0),this}},{key:"panZ",value:function(e){return Ct(this.faces,function(t){t.panZ(e)},null,!0),this}},{key:"transformVerts",value:function(e,i,n,r,s,a){return Ct(this.faces,function(t){t.transformVerts(e,i,n,r,s,a)},null,!0),this}},{key:"forEachFace",value:function(t,e,i){return Ct(this.faces,t,e,i),this}}]),h}(),At=Phaser.Utils.Objects.IsPlainObject,jt={key:"__WHITE"},Ft={image:R,rendertexture:X},Yt=(0,Phaser.Math.DegToRad)(180),Tt={setEventEmitter:function(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:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){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):[]}},_t=Phaser.Scene,Xt=Phaser.Utils.Objects.GetValue,Mt=function(){function n(t,e){var i;k(this,n),this.parent=t,this.scene=null==(i=t)||"object"!==h(i)?null:St(i)?i:i.scene&&St(i.scene)?i.scene:i.parent&&i.parent.scene&&St(i.parent.scene)?i.parent.scene:void 0,this.isShutdown=!1,this.setEventEmitter(Xt(e,"eventEmitter",!0)),this.parent&&this.parent===this.scene?this.scene.events.once("shutdown",this.onSceneDestroy,this):this.parent&&this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this)}return l(n,[{key:"shutdown",value:function(){this.isShutdown||(this.parent&&this.parent===this.scene?this.scene.events.off("shutdown",this.onSceneDestroy,this):this.parent&&this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.isShutdown=!0)}},{key:"destroy",value:function(t){this.shutdown(t)}},{key:"onSceneDestroy",value:function(){this.destroy(!0)}},{key:"onParentDestroy",value:function(t,e){this.destroy(e)}}]),n}();Object.assign(Mt.prototype,Tt);var Dt=Phaser.Utils.Objects.GetValue,It=function(){f(r,Mt);var n=P(r);function r(t,e){var i;return k(this,r),(i=n.call(this,t,e))._isRunning=!1,i.isPaused=!1,i.tickingState=!1,i.setTickingMode(Dt(e,"tickingMode",1)),i}return l(r,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking()}},{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),d(c(r.prototype),"shutdown",this).call(this,t))}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=Vt[t]),this.tickingMode=t}},{key:"startTicking",value:function(){this.tickingState=!0}},{key:"stopTicking",value:function(){this.tickingState=!1}},{key:"isRunning",get:function(){return this._isRunning},set:function(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}},{key:"start",value:function(){return this.isPaused=!1,this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}},{key:"resume",value:function(){return this.isPaused&&(this.isRunning=!0),this}},{key:"stop",value:function(){return this.isPaused=!1,this.isRunning=!1,this}},{key:"complete",value:function(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}]),r}(),Vt={no:0,lazy:1,always:2},Gt=function(){f(e,It);var t=P(e);function e(){return k(this,e),t.apply(this,arguments)}return l(e,[{key:"startTicking",value:function(){d(c(e.prototype),"startTicking",this).call(this),this.scene.events.on("update",this.update,this)}},{key:"stopTicking",value:function(){d(c(e.prototype),"stopTicking",this).call(this),this.scene&&this.scene.events.off("update",this.update,this)}}]),e}(),Lt=Phaser.Utils.Objects.GetValue,Bt=Phaser.Math.Clamp,Ut=function(){function e(t){k(this,e),this.resetFromJSON(t)}return l(e,[{key:"resetFromJSON",value:function(t){this.state=Lt(t,"state",zt),this.timeScale=Lt(t,"timeScale",1),this.delay=Lt(t,"delay",0),this.repeat=Lt(t,"repeat",0),this.repeatCounter=Lt(t,"repeatCounter",0),this.duration=Lt(t,"duration",0),this.nowTime=Lt(t,"nowTime",0),this.justRestart=Lt(t,"justRestart",!1)}},{key:"toJSON",value:function(){return{state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}},{key:"destroy",value:function(){}},{key:"setTimeScale",value:function(t){return this.timeScale=t,this}},{key:"setDelay",value:function(t){return void 0===t&&(t=0),this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatInfinity",value:function(){return this.repeat=-1,this}},{key:"start",value:function(){return this.nowTime=0<this.delay?-this.delay:0,this.state=0<=this.nowTime?Nt:Wt,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=zt,this}},{key:"update",value:function(t,e){this.state!==zt&&this.state!==Zt&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.state=0<=this.nowTime?Nt:Wt,this.justRestart=!1,this.nowTime>=this.duration&&(-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration):(this.nowTime=this.duration,this.state=Zt)))}},{key:"t",get:function(){var t;switch(this.state){case zt:case Wt:t=0;break;case Nt:t=this.nowTime/this.duration;break;case Zt:t=1}return Bt(t,0,1)},set:function(t){(t=Bt(t,-1,1))<0?(this.state=Wt,this.nowTime=-this.delay*t):(this.state=Nt,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}},{key:"isIdle",get:function(){return this.state===zt}},{key:"isDelay",get:function(){return this.state===Wt}},{key:"isCountDown",get:function(){return this.state===Nt}},{key:"isRunning",get:function(){return this.state===Wt||this.state===Nt}},{key:"isDone",get:function(){return this.state===Zt}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),e}(),zt=0,Wt=1,Nt=2,Zt=-1,Jt=function(){f(r,Gt);var n=P(r);function r(t,e){var i;return k(this,r),(i=n.call(this,t,e)).timer=new Ut,i}return l(r,[{key:"shutdown",value:function(t){this.isShutdown||(d(c(r.prototype),"shutdown",this).call(this,t),this.timer.destroy(),this.timer=void 0)}},{key:"start",value:function(){return this.timer.start(),d(c(r.prototype),"start",this).call(this),this}},{key:"stop",value:function(){return this.timer.stop(),d(c(r.prototype),"stop",this).call(this),this}},{key:"complete",value:function(){return this.timer.stop(),d(c(r.prototype),"complete",this).call(this),this}}]),r}(),Ht=Phaser.Utils.Objects.GetValue,$t=Phaser.Utils.Objects.GetAdvancedValue,qt=Phaser.Tweens.Builders.GetEaseFunction,Kt=function(){f(e,Jt);var t=P(e);function e(){return k(this,e),t.apply(this,arguments)}return l(e,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(Ht(t,"timer")),this.setEnable(Ht(t,"enable",!0)),this.setDelay($t(t,"delay",0)),this.setDuration($t(t,"duration",1e3)),this.setEase(Ht(t,"ease","Linear")),this.setRepeat(Ht(t,"repeat",0)),this}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=qt(t),this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"start",value:function(){return this.timer.isRunning||d(c(e.prototype),"start",this).call(this),this}},{key:"restart",value:function(){return this.timer.stop(),this.start.apply(this,arguments),this}},{key:"update",value:function(t,e){if(!this.isRunning||!this.enable)return this;var i=this.parent;if(!i.active)return this;var n=this.timer;return n.update(t,e),n.isDelay||this.updateGameObject(i,n),this.emit("update",i,this),n.isDone&&this.complete(),this}},{key:"updateGameObject",value:function(){}}]),e}(),Qt=Phaser.Utils.Objects.GetValue,te=Phaser.Math.Linear,ee=function(){f(r,Kt);var n=P(r);function r(t,e){var i;return k(this,r),(i=n.call(this,t,e)).resetFromJSON(e),i.boot(),i}return l(r,[{key:"resetFromJSON",value:function(t){return d(c(r.prototype),"resetFromJSON",this).call(this,t),this.setEase(Qt(t,"ease","Cubic")),this.setFrontToBackDirection(Qt(t,"frontToBack",0)),this.setBackToFrontDirection(Qt(t,"backToFront",1)),this}},{key:"setFrontToBackDirection",value:function(t){return"string"==typeof t&&(t=ie[t]),this.endAngleFB=0===t?180:-180,this}},{key:"setBackToFrontDirection",value:function(t){return"string"==typeof t&&(t=ie[t]),this.endAngleBF=0===t?-180:180,this}},{key:"start",value:function(){return this.timer.isRunning||(this.timer.setDelay(this.delay).setDuration(this.duration),0===this.parent.face?(this.startAngle=0,this.endAngle=this.endAngleFB):(this.startAngle=this.endAngleBF,this.endAngle=0),d(c(r.prototype),"start",this).call(this)),this}},{key:"flip",value:function(t){if(this.isRunning)return this;void 0!==t&&this.setDuration(t),this.start();var e=this.parent.currentFaceIndex;return this.parent.currentFaceIndex=0===e?1:0,this}},{key:"flipRight",value:function(t){return 0===this.parent.currentFaceIndex?this.setFrontToBackDirection(0):this.setBackToFrontDirection(0),this.flip(t),this}},{key:"flipLeft",value:function(t){return 0===this.parent.currentFaceIndex?this.setFrontToBackDirection(1):this.setBackToFrontDirection(1),this.flip(t),this}},{key:"updateGameObject",value:function(t,e){var i=this.easeFn(e.t),n=te(this.startAngle,this.endAngle,i);0===t.orientation?t.angleY=n:t.angleX=n}}]),r}(),ie={right:0,"left-to-right":0,left:1,"right-to-left":1},ne=Phaser.Utils.Objects.IsPlainObject,re=Phaser.Utils.Objects.GetValue,se=["back","front"],ae=function(){f(m,Et);var g=P(m);function m(t,e,i,n){var r;k(this,m),ne(e)&&(e=re(n=e,"x",0),i=re(n,"y",0));var s=wt(t,n,se),a=s.back,o=s.front,h=re(n,"width"),u=re(n,"height");if(void 0===h||void 0===u){if(void 0===h){var c=o?o.width:0,l=a?a.width:0;h=Math.max(c,l)}if(void 0===u){var f=o?o.height:0,d=a?a.height:0;u=Math.max(f,d)}}(r=g.call(this,t,e,i,h,u,s)).type="rexPerspectiveCard",r.frontFaceRotationX=void 0,r.frontFaceRotationY=void 0,r.frontFaceRotationZ=void 0,Ct(s,function(t,e){this["".concat(e,"Face")]=t},b(r));var p,v,y=re(n,"flip",void 0);return!1!==y&&(r.flip=new ee(b(r),y)),r.setOrientation(re(n,"orientation",0)),p=b(r),(v=s.back)&&(0===p.orientation?v.transformVerts(0,0,0,0,Yt,0):v.transformVerts(0,0,0,Yt,0,0)),r.setFace(re(n,"face",0)),r}return l(m,[{key:"rotationX",get:function(){return this.frontFaceRotationX},set:function(e){this.frontFaceRotationX!==e&&(this.frontFaceRotationX=e,Ct(this.faces,function(t){t.rotationX=e},null,!0))}},{key:"rotationY",get:function(){return this.frontFaceRotationY},set:function(e){this.frontFaceRotationY!==e&&(this.frontFaceRotationY=e,Ct(this.faces,function(t){t.rotationY=e},null,!0))}},{key:"rotationZ",get:function(){return this.frontFaceRotationZ},set:function(e){this.frontFaceRotationZ!==e&&(this.frontFaceRotationZ=e,Ct(this.faces,function(t){t.rotationZ=e},null,!0))}},{key:"setOrientation",value:function(t){return"string"==typeof t&&(t=oe[t]),this.orientation=t,this}},{key:"face",get:function(){return this.currentFaceIndex},set:function(t){"string"==typeof t&&(t=he[t]);var e=1===(this.currentFaceIndex=t)?180:0;0===this.orientation?this.angleY=e:this.angleX=e}},{key:"setFace",value:function(t){return this.face=t,this}},{key:"toggleFace",value:function(){var t=0===this.face?1:0;return this.setFace(t),this}}]),m}(),oe={x:0,horizontal:0,h:0,y:1,vertical:1,v:1},he={front:0,back:1};function ue(t,e,i){var n=new ae(this.scene,t,e,i);return this.scene.add.existing(n),n}var ce=Phaser.GameObjects.BuildGameObject;function le(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new ae(this.scene,0,0,t);return ce(this.scene,i,t),i}function fe(t,e){for(var i=0,n=t.length;i<n;i++)if(face&&face.name===e)return i;return-1}var de=Phaser.Utils.Objects.GetValue,pe=Phaser.Math.RadToDeg,ve=Phaser.Math.DegToRad,ye=Phaser.Math.Angle.WrapDegrees,ge=Phaser.Math.Angle.ShortestBetween,me=Phaser.Math.Wrap,ke=Phaser.Math.Linear,be=function(){f(r,Kt);var n=P(r);function r(t,e){var i;return k(this,r),(i=n.call(this,t,e)).resetFromJSON(e),i.boot(),i}return l(r,[{key:"resetFromJSON",value:function(t){return d(c(r.prototype),"resetFromJSON",this).call(this,t),this.setEase(de(t,"ease","Cubic")),this}},{key:"start",value:function(t){if(this.timer.isRunning)return this;this.timer.setDelay(this.delay).setDuration(this.duration);var e=this.parent;return this.startRotationY=e.rotationY,this.endRotationY=this.startRotationY+t,d(c(r.prototype),"start",this).call(this),this}},{key:"to",value:function(t,e){if(this.isRunning)return this;var i=this.parent;"string"==typeof t&&-1===(t=fe(i.faces,t))&&(t=0),t=me(t,0,i.faces.length),void 0!==e&&this.setDuration(e);var n=ye(pe(i.rotationY)),r=ye(pe((i.rtl?1:-1)*i.faceAngle*t)),s=ge(n,r);return this.start(ve(s)),i.currentFaceIndex=t,this}},{key:"toNext",value:function(t){var e=this.parent.currentFaceIndex+1;return this.to(e,t),this}},{key:"toPrevious",value:function(t){var e=this.parent.currentFaceIndex-1;return this.to(e,t),this}},{key:"toRight",value:function(t){return this.parent.rtl?this.toPrevious(t):this.toNext(t),this}},{key:"toLeft",value:function(t){return this.parent.rtl?this.toNext(t):this.toPrevious(t),this}},{key:"updateGameObject",value:function(t,e){var i=this.easeFn(e.t);t.rotationY=ke(this.startRotationY,this.endRotationY,i)}}]),r}(),Pe=Phaser.Utils.Objects.IsPlainObject,Ce=Phaser.Utils.Objects.GetValue,xe=Phaser.Math.DegToRad,we=Phaser.Math.RadToDeg,Se=Phaser.Math.Angle.WrapDegrees,Oe=Phaser.Math.Linear,Re=Phaser.Math.Wrap,Ee=function(){f(y,Et);var v=P(y);function y(t,e,i,n){var r;k(this,y),Pe(e)&&(e=Ce(n=e,"x",0),i=Ce(n,"y",0));var s=Ce(n,"faces",void 0),a=wt(t,s=s||[]),o=function(t){for(var e,i=0,n=t.length;i<n&&!(e=t[i]);i++);return e}(a),h=Ce(n,"width"),u=Ce(n,"height");void 0===h&&(h=o?o.width:0),void 0===u&&(u=o?o.height:0),(r=v.call(this,t,e,i,h,u,a)).type="rexPerspectiveCarousel",r.face0RotationY=void 0;var c=a.length;r.faceAngle=0<c?xe(360/a.length):0;var l=Ce(n,"faceWidth",void 0);if(void 0===l){var f=Ce(n,"faceSpace",0);l=o?o.width+f:0}r.faceWidth=l,r.faceRadius=2<c?l/2/Math.tan(r.faceAngle/2):l/2,function(t,e){if(0!==t.faceWidth){var i=t.faceRadius;Ct(e,function(t){var e=i/t.height;t.transformVerts(0,0,e).panZ(e)},null,!0)}}(b(r),a);var d=Ce(n,"roll",void 0);if(!1!==d){var p=Ce(n,"rollClass",be);r.roll=new p(b(r),d)}return r.rtl=Ce(n,"rtl",!1),r.zStart=Ce(n,"z",1),r.zEnd=Ce(n,"zEnd",r.zStart-1),r.setFace(Ce(n,"face",0)),r}return l(y,[{key:"rotationY",get:function(){return this.face0RotationY},set:function(s){if(this.face0RotationY!==s){this.face0RotationY=s;var a=this.faceAngle,o=this.zStart,h=this.zEnd,u=this.rtl?-1:1;Ct(this.faces,function(t,e){var i=s+u*a*e;t.rotationY=i;var n=Math.abs(Se(we(i))),r=Oe(o,h,n/180);t.setDepth(r)},null,!0)}}},{key:"face",get:function(){return this.currentFaceIndex},set:function(t){"string"==typeof t&&-1===(t=fe(this.faces,t))&&(t=0),t=Re(t,0,this.faces.length),this.currentFaceIndex=t,this.rotationY=(this.rtl?1:-1)*this.faceAngle*t}},{key:"setFace",value:function(t){return this.face=t,this}}]),y}();function Ae(t,e,i){var n=new Ee(this.scene,t,e,i);return this.scene.add.existing(n),n}var je=Phaser.GameObjects.BuildGameObject;function Fe(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new Ee(this.scene,0,0,t);return je(this.scene,i,t),i}var Ye=function(){f(i,be);var t=P(i);function i(){return k(this,i),t.apply(this,arguments)}return l(i,[{key:"toNext",value:function(t){var e=this.parent;return!e.repeat&&e.isLastImage||this.isRunning||(e.setImageIndex(e.currentImageIndex+1),d(c(i.prototype),"toNext",this).call(this,t).once("complete",e.updateTexture,e)),this}},{key:"toPrevious",value:function(t){var e=this.parent;return!e.repeat&&e.isFirstImage||this.isRunning||(e.setImageIndex(e.currentImageIndex-1),d(c(i.prototype),"toPrevious",this).call(this,t).once("complete",e.updateTexture,e)),this}}]),i}(),Te={},_e=Phaser.Utils.Objects.IsPlainObject,Xe=Phaser.Utils.Objects.GetValue,Me=Phaser.Math.Wrap,De=function(){f(p,Ee);var d=P(p);function p(t,e,i,n){var r,s,a;k(this,p),_e(e)&&(e=Xe(n=e,"x",0),i=Xe(n,"y",0)),void 0===n&&(n={});var o=Xe(n,"images"),h=function(t,e){if(!e)return null;if(Array.isArray(e)){var i=e[0],n=t.textures.getFrame(i.key,i.frame);Te.width=n.cutWidth,Te.height=n.cutHeight}else Te.width=e.width,Te.height=e.height;return Te}(t,o);a=h?(s=h.width,h.height):(s=Xe(n,"width"),Xe(n,"height"));for(var u,c=Xe(n,"faceCount",4),l=[],f=0;f<c;f++)u=new X(t,0,0,s,a,n),t.add.existing(u),l.push(u);return n.faces=l,n.rollClass=Ye,(r=d.call(this,t,e,i,n)).type="rexPerspectiveImageCarousel",r.images=o,r.indexOffsetMap=function(t){for(var e=[0],i=1,n=Math.floor((t-1)/2);i<=n;i++)e.push(i),e.push(-i);return e}(c),r.repeat=Xe(n,"repeat",!0),r.setImageIndex(Xe(n,"index",0)).updateTexture(),r}return l(p,[{key:"setImageIndex",value:function(t){return this.currentImageIndex=Me(t,0,this.images.length),this}},{key:"isFirstImage",get:function(){return 0===this.images.length||0===this.currentImageIndex}},{key:"isLastImage",get:function(){return 0===this.images.length||this.currentImageIndex===this.images.length-1}},{key:"updateTexture",value:function(){var r=this.images.length,s=this.faces.length;return this.indexOffsetMap.forEach(function(t){var e=Me(this.currentImageIndex+t,0,r),i=Me(this.currentFaceIndex+t,0,s),n=this.images[e];this.faces[i].rt.drawFrame(n.key,n.frame)},this),this}}]),p}();function Ie(t,e,i){var n=new De(this.scene,t,e,i);return this.scene.add.existing(n),n}var Ve=Phaser.GameObjects.BuildGameObject;function Ge(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new De(this.scene,t);return Ve(this.scene,i,t),i}function Le(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:function(t){if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(e),i){e.length=t.length;for(var n=0,r=t.length;n<r;n++)e[n]=t[n]}else for(var s in t)e[s]=t[s];return e}function Be(t){var e=t.gameObjects,i=t.renderTexture;if(0===e.length)return i&&i.setSize(1,1).clear(),i;var n,r,s=He(t,"x",void 0),a=He(t,"y",void 0),o=He(t,"width",void 0),h=He(t,"height",void 0),u=He(t,"originX",0),c=He(t,"originY",0);if(void 0===o||void 0===h||void 0===s||void 0===a){var l=function(t,e){var i;void 0===e?e=new Ze:!0===e&&(void 0===Ne&&(Ne=new Ze),e=Ne);for(var n=!0,r=0,s=t.length;r<s;r++)(i=t[r]).getBounds&&(We=i.getBounds(We),n?(e.setTo(We.x,We.y,We.width,We.height),n=!1):Je(We,e,e));return e}(e,!0);c=u=void 0!==s&&void 0!==a?(o=2*Math.max(s-l.left,l.right-s),h=2*Math.max(a-l.top,l.bottom-a),.5):(s=l.x,a=l.y,o=l.width,h=l.height,0),n=l.x,r=l.y}else n=s+(0-u)*o,r=a+(0-c)*h;return i?(i.setPosition(s,a),i.width===o&&i.height===h||i.setSize(o,h)):i=e[0].scene.add.renderTexture(s,a,o,h),i.setOrigin(u,c),i.camera.setScroll(n,r),e=$(Le(e)),i.draw(e),i}function Ue(t){return null==t||""===t||0===t.length}function ze(t,e,i){if("object"===h(t)){if(Ue(e)){if(null==i)return;"object"===h(i)&&(t=i)}else{"string"==typeof e&&(e=e.split("."));var n=e.pop();(function(t,e,i){var n=t;if(!Ue(e)){var r;"string"==typeof e&&(e=e.split("."));for(var s=0,a=e.length;s<a;s++){var o;if(null==n[r=e[s]]||"object"!==h(n[r]))o=s!==a-1||void 0===i?{}:i,n[r]=o;n=n[r]}}return n})(t,e)[n]=i}return t}}var We,Ne,Ze=Phaser.Geom.Rectangle,Je=Phaser.Geom.Rectangle.Union,He=Phaser.Utils.Objects.GetValue,$e=Pt.prototype.add,qe=Phaser.Utils.Objects.GetValue,Ke=function(){f(s,X);var r=P(s);function s(t,e){var i;k(this,s);var n=t.scene;return i=r.call(this,n,t.x,t.y,1,1,e),n.add.existing(b(i)),i.setVisible(!1),$e.call(t,b(i)),i.visibleSibling=[],i.perspectiveState=!1,i.useParentBounds=qe(e,"useParentBounds",!1),i.boot(),i}return l(s,[{key:"boot",value:function(){this.rexContainer.parent.once("destroy",this.onParentDestroy,this)}},{key:"destroy",value:function(t){this.scene&&(this.exit(),this.rexContainer.parent.off("destroy",this.onParentDestroy,this),d(c(s.prototype),"destroy",this).call(this,t))}},{key:"onParentDestroy",value:function(t,e){this.destroy(e)}},{key:"enter",value:function(){this.exit();var e=this.rexContainer.parent;return Be({gameObjects:e.getAllVisibleChildren(),renderTexture:this.rt,x:this.x,y:this.y,width:this.useParentBounds?e.displayWidth:void 0,height:this.useParentBounds?e.displayHeighth:void 0,originX:this.useParentBounds?e.originX:void 0,originY:this.useParentBounds?e.originY:void 0}),this.syncSize(),e.setChildVisible(this,!0),e.children.forEach(function(t){t!==this&&(e.setChildVisible(t,!1),this.visibleSibling.push(t))},this),this.perspectiveState=!0,this}},{key:"exit",value:function(){var e=this.rexContainer.parent;return this.visibleSibling.forEach(function(t){e.setChildVisible(t,!0)},this),this.visibleSibling.length=0,e.setChildVisible(this,!1),this.perspectiveState=!1,this}}]),s}(),Qe=function(){f(n,Phaser.Plugins.BasePlugin);var i=P(n);function n(t){var e;return k(this,n),e=i.call(this,t),t.registerGameObject("rexPerspectiveImage",E,F),t.registerGameObject("rexPerspectiveRenderTexture",M,V),t.registerGameObject("rexPerspectiveCard",ue,le),t.registerGameObject("rexPerspectiveCarousel",Ae,Fe),t.registerGameObject("rexPerspectiveImageCarousel",Ie,Ge),e}return l(n,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}},{key:"addContainerPerspective",value:function(t,e){return new Ke(t,e)}}]),n}();return ze(window,"RexPlugins.GameObjects.PerspectiveImage",R),ze(window,"RexPlugins.GameObjects.PerspectiveRenderTexture",X),ze(window,"RexPlugins.GameObjects.PerspectiveCard",ae),ze(window,"RexPlugins.GameObjects.PerspectiveCarousel",Ee),ze(window,"RexPlugins.GameObjects.PerspectiveImageCarousel",De),ze(window,"RexPlugins.GameObjects.ContainerPerspective",Ke),Qe});
  