UNPKG

phaser4-rex-plugins

Version:
1 lines 412 kB
var t,e;t=void 0,e=function(){var t=!1,e=function(e){if(!t){void 0===e&&(e=0);var i=Phaser.VERSION.split("."),s=parseInt(i[0]);if(4===s){var r=parseInt(i[1]);r<e&&console.error(`Minimum supported version : ${s}.${r}`)}else console.error(`Can't supported version : ${s}`);t=!0}};e();const i=Phaser.GameObjects.Zone,s=Phaser.Utils.Array.Add,r=Phaser.Utils.Array.Remove;let n=class extends i{constructor(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),super(t,e,i,s,r),this.children=[]}destroy(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),super.destroy(t)}}contains(t){return-1!==this.children.indexOf(t)}add(t){var e=this;return s(this.children,t,0,(function(t){t.once("destroy",e.onChildDestroy,e)}),this),this}remove(t,e){var i=this;return r(this.children,t,(function(t){t.off("destroy",i.onChildDestroy,i),e&&t.destroy()})),this}onChildDestroy(t,e){this.remove(t,!1)}clear(t){for(var e,i=0,s=this.children.length;i<s;i++)(e=this.children[i]).off("destroy",this.onChildDestroy,this),t&&e.destroy();return this.children.length=0,this}};const h=Phaser.GameObjects.Components;Phaser.Class.mixin(n,[h.Alpha,h.Flip]);var a=function(t,e){var i;if(void 0===e)t.hasOwnProperty("rexContainer")&&(i=t.rexContainer.parent);else for(i=a(t);i&&i.name!==e;)i=a(i);return i};const o=Phaser.Math.DegToRad,l=Phaser.Math.RadToDeg;var d=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,syncScrollFactor:!0,syncCameraFilter:!0,syncDisplayList:!0,visible:!0,active:!0};Object.defineProperty(e,"angle",{get:function(){return l(this.rotation)},set:function(t){this.rotation=o(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},c={setParent(t,e){void 0===e&&(e=this);var i=d(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent(t,e){return"string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),a(t,e)},getTopmostParent(t){return void 0===t&&(t=this),function(t){for(var e=a(t);e;)t=e,e=a(e);return t}(t)}};const u=Phaser.Utils.Objects.GetValue,p=n.prototype.add;var v=function(t,e){this.setParent(t);var i=d(t);return f(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t).updateCameraFilter(t),p.call(this,t),m.call(this,t,i),this},g=function(t,e){this.setParent(t);var i=d(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),p.call(this,t),m.call(this,t,i),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.syncCameraFilter=e,t.syncDisplayList=e):(t.syncPosition=u(e,"syncPosition",!0),t.syncRotation=u(e,"syncRotation",!0),t.syncScale=u(e,"syncScale",!0),t.syncAlpha=u(e,"syncAlpha",!0),t.syncScrollFactor=u(e,"syncScrollFactor",!0),t.syncCameraFilter=u(e,"syncCameraFilter",!0),t.syncDisplayList=u(e,"syncDisplayList",!0))},m=function(t,e){this.addToParentContainer(t),e.syncDisplayList&&this.addToPatentLayer(t),this.addToRenderLayer(t)},y={add(t){return Array.isArray(t)?this.addMultiple(t):v.call(this,t),this},pin(t,e){return Array.isArray(t)?this.addMultiple(t,e):v.call(this,t,e),this},addMultiple(t){for(var e=Array.from(arguments),i=0,s=t.length;i<s;i++)e[0]=t[i],this.add.apply(this,e);return this},addLocal(t){return Array.isArray(t)?this.addMultiple(t):g.call(this,t),this},pinLocal(t,e){return Array.isArray(t)?this.addMultiple(t,e):g.call(this,t,e),this},addLocalMultiple(t){for(var e=0,i=t.length;e<i;e++)g.call(this,t[e]);return this}};const b=n.prototype.remove,x=n.prototype.clear;var C={remove(t,e){return a(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),b.call(this,t,e)),this},unpin(t,e){return a(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),b.call(this,t,e)),this},clear(t){for(var e=this.children,i=0,s=e.length;i<s;i++){var r=e[i];this.setParent(r,null),t||this.removeFromRenderLayer(r)}return x.call(this,t),this}},S={getLocalState:t=>d(t),resetChildState(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},w={worldToLocal(t){t.x-=this.x,t.y-=this.y;var e=Math.cos(-this.rotation),i=Math.sin(-this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x/=this.scaleX,t.y/=this.scaleY,t},localToWorld(t){t.x*=this.scaleX,t.y*=this.scaleY;var e=Math.cos(this.rotation),i=Math.sin(this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x+=this.x,t.y+=this.y,t}},O=function(t,e){return t===e?1:t/e},k={updateChildPosition(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=d(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(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState(t){var e=d(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),e.rotation=t.rotation-i.rotation,this},setChildPosition(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition(t,e,i){var s=d(t);return s.x=e,s.y=i,this.updateChildPosition(t),this},resetLocalPositionState(){var t=d(this).parent;return t&&t.resetChildPositionState(this),this},getChildLocalX:t=>d(t).x,getChildLocalY:t=>d(t).y};const P=Phaser.Math.DegToRad;var _={updateChildRotation(t){var e=d(t),i=e.parent;return e.syncRotation&&(t.rotation=i.rotation+e.rotation),this},syncRotation(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState(t){var e=d(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildAngle(t,e){return t.angle=e,this.resetChildRotationState(t),this},setChildLocalRotation(t,e){return d(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle(t,e){return d(t).rotation=P(e),this.updateChildRotation(t),this},resetLocalRotationState(){var t=d(this).parent;return t&&t.resetChildRotationState(this),this},getChildLocalRotation:t=>d(t).rotation},T={updateChildScale(t){var e=d(t),i=e.parent;return e.syncScale&&(t.scaleX=i.scaleX*e.scaleX,t.scaleY=i.scaleY*e.scaleY),this},syncScale(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScale,this),this},resetChildScaleState(t){var e=d(t),i=e.parent;return e.scaleX=O(t.scaleX,i.scaleX),e.scaleY=O(t.scaleY,i.scaleY),this},setChildScale(t,e,i){return void 0===i&&(i=e),t.scaleX=e,t.scaleY=i,this.resetChildScaleState(t),this},setChildLocalScale(t,e,i){void 0===i&&(i=e);var s=d(t);return s.scaleX=e,s.scaleY=i,this.updateChildScale(t),this},setChildDisplaySize(t,e,i){return t.setDisplaySize(e,i),this.resetChildScaleState(t),this},resetLocalScaleState(){var t=d(this).parent;return t&&t.resetChildScaleState(this),this},getChildLocalScaleX:t=>d(t).scaleX,getChildLocalScaleY:t=>d(t).scaleY},E={updateChildVisible(t){var e=d(t),i=e.parent,s=!e.hasOwnProperty("maskVisible")||e.maskVisible,r=!i||i.visible;return t.visible=r&&e.visible&&s,this},syncVisible(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState(t){var e=d(t);return e.hasOwnProperty("maskVisible")&&delete e.maskVisible,e.visible=t.visible,this},setChildVisible(t,e){return this.setChildLocalVisible(t,e),this},setChildLocalVisible(t,e){return void 0===e&&(e=!0),d(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible(t,e){return void 0===e&&(e=!0),d(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState(){var t=d(this).parent;return t&&t.resetChildVisibleState(this),this},getChildLocalVisible:t=>d(t).visible},M={updateChildAlpha(t){var e=d(t),i=e.parent;return e.syncAlpha&&(t.alpha=i.alpha*e.alpha),this},syncAlpha(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState(t){var e=d(t),i=e.parent;return e.alpha=O(t.alpha,i.alpha),this},setChildAlpha(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha(t,e){return d(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState(){var t=d(this).parent;return t&&t.resetChildAlphaState(this),this},getChildLocalAlpha:t=>d(t).alpha},R={updateChildActive(t){var e=d(t),i=e.parent;return t.active=i.active&&e.active,this},syncActive(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState(t){return d(t).active=t.active,this},setChildActive(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive(t,e){return void 0===e&&(e=!0),d(t).active=e,this.updateChildActive(t),this},resetLocalActiveState(){var t=d(this).parent;return t&&t.resetChildActiveState(this),this},getChildLocalActive:t=>d(t).active},L={updateChildScrollFactor(t){var e=d(t),i=e.parent;return e.syncScrollFactor&&(t.scrollFactorX=i.scrollFactorX,t.scrollFactorY=i.scrollFactorY),this},syncScrollFactor(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},D={updateCameraFilter(t){var e=d(t),i=e.parent;return e.syncCameraFilter&&(t.cameraFilter=i.cameraFilter),this},syncCameraFilter(){return this.syncChildrenEnable&&this.children.forEach(this.updateCameraFilter,this),this}},Y={updateChildMask(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask(t){return this.mask=t,this},clearMask(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}},A=function(t,e){if(t.length<=1)return t;var i;void 0===e&&(e=!1);for(var s=0,r=t.length;s<r;s++){var n=t[s];if(n.displayList?i=n.displayList:n.parentContainer&&(i=n.parentContainer.list),i)break}return i||(i=n.scene.sys.displayList),i.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},X=function(t){return t.filter((function(t){return!!t.displayList||!!t.parentContainer||void 0}))},W={setDepth(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)i[s].depth=t;return this},swapDepth(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth(t){if(this.depth+=t,this.children)for(var e=this.getAllChildren(),i=0,s=e.length;i<s;i++)e[i].depth+=t;return this},bringToTop(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);A(e,!1);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.bringToTop(r)}return this},bringMeToTop(){return this.bringToTop()},sendToBack(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);A(e,!0);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.sendToBack(r)}return this},sendMeToBack(){return this.sendToBack()},moveDepthBelow(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);A(i,!1);for(var s=0,r=i.length;s<r;s++){var n=i[s];if(e.exists(n)){e.moveBelow(t,n);break}}return this},moveMyDepthBelow(t){return this.moveDepthBelow(t)},moveDepthAbove(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);A(i,!0);for(var s=0,r=i.length;s<r;s++){var n=i[s];if(e.exists(n)){e.moveAbove(t,n);break}}return this},moveMyDepthAbove(t){return this.moveDepthAbove(t)},bringChildToTop(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=X(e),e=A(e,!1)):e=[t];var i=this.getAllChildren([this]);i=X(i);for(var s=(i=A(i,!1))[i.length-1],r=0,n=e.length;r<n;r++){var h=e[r];s!==h&&(h!==this&&s.displayList!==h.displayList||(s.displayList.moveAbove(h,s),s=h))}return this},sendChildToBack(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=X(e),e=A(e,!1)):e=[t];var i=this.getAllChildren([this]);i=X(i);for(var s=(i=A(i,!1))[0],r=e.length-1;r>=0;r--){var n=e[r];s!==n&&(n!==this&&s.displayList!==n.displayList||(s.displayList.moveBelow(n,s),s=n))}return this}},z=function(t,e){if(!e(t)&&t.isRexContainerLite)for(var i=t.children,s=0,r=i.length;s<r;s++)z(i[s],e)},j=function(t,e){for(var i=[t];i.length>0;){var s=i.shift();!e(s)&&s.isRexContainerLite&&i.push(...s.children)}};const F=Phaser.Utils.Array;var B={getChildren(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(t){void 0===t&&(t=[]);var e=this;return j(e,(function(i){i!==e&&t.push(i)})),t},getAllVisibleChildren(t){void 0===t&&(t=[]);var e=this;return j(e,(function(i){if(i!==e)return!i.visible||void t.push(i)})),t},bfs(t,e){return void 0===e&&(e=this),j(e,t),this},dfs(t,e){return void 0===e&&(e=this),z(e,t),this},contains(t){var e=a(t);return!!e&&(e===this||this.contains(e))},getByName(t,e){if(e){for(var i,s,r=[this];r.length;)for(var n=0,h=(i=r.shift()).children.length;n<h;n++){if((s=i.children[n]).name===t)return s;s.isRexContainerLite&&r.push(s)}return null}return F.GetFirst(this.children,"name",t)},getRandom(t,e){return F.GetRandom(this.children,t,e)},getFirst(t,e,i,s){return F.GetFirstElement(this.children,t,e,i,s)},getAll(t,e,i,s){return F.GetAll(this.children,t,e,i,s)},count(t,e,i,s){return F.CountAllMatching(this.children,t,e,i,s)},swap(t,e){return F.Swap(this.children,t,e),this},setAll(t,e,i,s){return F.SetAll(this.children,t,e,i,s),this}},I=function(t){for(var e=[],i=0,s=t.length;i<s;i++){var r=t[i];r.hasOwnProperty("rexContainer")&&e.push(r.rexContainer)}return e},H=function(t,e,i){if(i.parent){var s=i.parent,r=i.self;switch(e){case"x":case"y":s.updateChildPosition(r);break;case"angle":case"rotation":s.updateChildRotation(r);break;case"scaleX":case"scaleY":case"displayWidth":case"displayHeight":s.updateChildScale(r);break;case"alpha":s.updateChildAlpha(r);break;default:s.updateChildPosition(r),s.updateChildRotation(r),s.updateChildScale(r),s.updateChildAlpha(r)}}else t.remove()},N={tweenChild(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 s=t[e].scene;if(s)return s}return null}(e);if(i){t.targets=I(e);var s=i.tweens.add(t);return s.on("update",H),s}},tweenSelf(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=I(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),H(t,void 0,e)},t},tween(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}};const G=Phaser.GameObjects.Container,V=Phaser.GameObjects.Layer;var U=function(t){return t instanceof V},$=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return!!t.displayList||!!t.parentContainer}))},J=function(t){var e=$(this);-1===e.indexOf(this)&&e.push(this),A(e),t.add(e)},K=function(t,e,i){if(this.scene){var s=$(this);A(s,e),t.remove(s),i&&s.forEach((function(t){t.addToDisplayList()}))}},q={addToContainer(t){return function(t){return t instanceof G}(t)?(this._setParentContainerFlag=!0,J.call(this,t),this._setParentContainerFlag=!1,this):this},addToLayer(t){return U(t)?(J.call(this,t),this):this},removeFromContainer(){return this.parentContainer?(this._setParentContainerFlag=!0,K.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer(t){return void 0===t&&(t=!0),U(this.displayList)?(K.call(this,this.displayList,!1,t),this):this},getParentContainer(){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(t){if(!t.displayList)return this;var e=this.getParentContainer();return e?(t.isRexContainerLite?t.addToContainer(e):e.add(t),this):this},addToPatentLayer(t){if(!t.displayList)return this;var e=this.displayList;return e===t.displayList||U(e)&&(t.isRexContainerLite?t.addToLayer(e):e.add(t)),this}},Z={hasLayer(){return!!this.privateRenderLayer},enableLayer(){if(this.hasLayer())return this;var t=this.scene.add.layer();return this.moveDepthBelow(t),this.addToLayer(t),this.privateRenderLayer=t,this},getLayer(){return this.hasLayer()||this.enableLayer(),this.privateRenderLayer},getRenderLayer(){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(t){if(!t.displayList)return this;var e=this.getRenderLayer();return e?(e===t.displayList||(t.isRexContainerLite?t.addToLayer(e):e.add(t),d(t).layer=e),this):this},removeFromRenderLayer(t){var e=d(t),i=e.layer;return i?(t.isRexContainerLite?t.removeFromLayer(!0):i.remove(t),e.layer=null,this):this}},Q=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},tt=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const et=Phaser.Geom.Rectangle,it=Phaser.Math.Vector2,st=Phaser.Math.RotateAround,rt=Phaser.GameObjects.Container;var nt=function(t,e){if(void 0===e?e=new et:!0===e&&(void 0===ht&&(ht=new et),e=ht),t.getBounds&&!(t instanceof rt))return t.getBounds(e);var i,s,r,n,h,a,o,l;if(t.parentContainer){var d=t.parentContainer.getBoundsTransformMatrix();at(t,e),d.transformPoint(e.x,e.y,e),i=e.x,s=e.y,ot(t,e),d.transformPoint(e.x,e.y,e),r=e.x,n=e.y,lt(t,e),d.transformPoint(e.x,e.y,e),h=e.x,a=e.y,dt(t,e),d.transformPoint(e.x,e.y,e),o=e.x,l=e.y}else at(t,e),i=e.x,s=e.y,ot(t,e),r=e.x,n=e.y,lt(t,e),h=e.x,a=e.y,dt(t,e),o=e.x,l=e.y;return e.x=Math.min(i,r,h,o),e.y=Math.min(s,n,a,l),e.width=Math.max(i,r,h,o)-e.x,e.height=Math.max(s,n,a,l)-e.y,e},ht=void 0,at=function(t,e,i){return void 0===e?e=new it:!0===e&&(void 0===ut&&(ut=new it),e=ut),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-Q(t)*t.originX,e.y=t.y-tt(t)*t.originY,pt(t,e,i))},ot=function(t,e,i){return void 0===e?e=new it:!0===e&&(void 0===ut&&(ut=new it),e=ut),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-Q(t)*t.originX+Q(t),e.y=t.y-tt(t)*t.originY,pt(t,e,i))},lt=function(t,e,i){return void 0===e?e=new it:!0===e&&(void 0===ut&&(ut=new it),e=ut),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-Q(t)*t.originX,e.y=t.y-tt(t)*t.originY+tt(t),pt(t,e,i))},dt=function(t,e,i){return void 0===e?e=new it:!0===e&&(void 0===ut&&(ut=new it),e=ut),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-Q(t)*t.originX+Q(t),e.y=t.y-tt(t)*t.originY+tt(t),pt(t,e,i))},ct=function(t,e,i){void 0===e?e=new it:!0===e&&(void 0===ut&&(ut=new it),e=ut);var s=Q(t),r=tt(t);return e.x=t.x+s*(.5-t.originX),e.y=t.y+r*(.5-t.originY),pt(t,e,i)},ut=void 0,pt=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&st(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e};const vt=Phaser.Geom.Rectangle,gt=Phaser.Geom.Rectangle.Union;var ft,mt=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e];return t},yt=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:mt(e),i){e.length=t.length;for(var s=0,r=t.length;s<r;s++)e[s]=t[s]}else for(var n in t)e[n]=t[n];return e};const bt=Phaser.GameObjects.GameObject,xt=Phaser.GameObjects.Layer;var Ct=function(t){return t instanceof bt||t instanceof xt},St=Phaser.Utils.Objects.GetValue,wt=function(t){if(t){var e=t.gameObjects;Array.isArray(e)||(e=[e]);var i,s,r=t.renderTexture,n=t.saveTexture,h=St(t,"x",void 0),a=St(t,"y",void 0),o=St(t,"width",void 0),l=St(t,"height",void 0),d=St(t,"originX",0),c=St(t,"originY",0),u=St(t,"padding",0);if(void 0===o||void 0===l||void 0===h||void 0===a){var p=function(t,e){var i;void 0===e?e=new vt:!0===e&&(void 0===ft&&(ft=new vt),e=ft),e.setTo(0,0,0,0);for(var s=!0,r=0,n=t.length;r<n;r++)if((i=t[r]).getBounds){var h=nt(i,!0);s?(e.setTo(h.x,h.y,h.width,h.height),s=!1):gt(h,e,e)}return e}(e,!0);void 0!==h&&void 0!==a?(o=2*Math.max(h-p.left,p.right-h),l=2*Math.max(a-p.top,p.bottom-a),d=.5,c=.5):(h=p.x,a=p.y,o=p.width,l=p.height,d=0,c=0),i=p.x,s=p.y}else i=h+(0-d)*o,s=a+(0-c)*l;i-=u,s-=u,o+=2*u,l+=2*u;var v=e[0].scene,g=v.sys.textures;return n&&!r&&(r=g.addDynamicTexture(n,o,l)),r||(r=v.add.renderTexture(0,0,o,l)),r.setPosition&&r.setPosition(h,a),r.width===o&&r.height===l||r.setSize(o,l),r.setOrigin&&r.setOrigin(d,c),r.camera.setScroll(i,s),e=A(yt(e)),r.draw(e).render(),n&&(Ct(r)?r.saveTexture(n):r.key!==n&&g.renameTexture(r.key,key)),r}},Ot={snapshot(t){var e=this.scaleX,i=this.scaleY,s=1===e&&1===i;s||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=wt(t),n=!!r.scene;return s||(this.setScale(e,i),n&&r.setScale(e,i)),n?r:this}};const kt=Phaser.Utils.Objects.GetValue;var Pt=function(t,e,i,s,r,n,h,a){if(t.getBounds||void 0!==t.width&&void 0!==t.height){var o=at(t,_t[0],a);o.x-=h,o.y-=h;var l=ot(t,_t[1],a);l.x+=h,l.y-=h;var d=dt(t,_t[2],a);d.x+=h,d.y+=h;var c=lt(t,_t[3],a);c.x-=h,c.y+=h,null!==r&&e.fillStyle(r,n).fillPoints(_t,!0,!0),null!==i&&e.lineStyle(s,i).strokePoints(_t,!0,!0)}},_t=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const Tt=Phaser.Utils.Objects.GetValue,Et=Phaser.Math.RotateAround;var Mt={changeOrigin:function(t,e){this.syncChildrenEnable=!1,function(t,e,i){void 0===i&&(i=e);var s={x:(e-t.originX)*t.displayWidth,y:(i-t.originY)*t.displayHeight};Et(s,0,0,t.rotation),t.originX=e,t.originY=i,t.x=t.x+s.x,t.y=t.y+s.y}(this,t,e),this.syncChildrenEnable=!0;for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)this.resetChildPositionState(i[s]);return this},drawBounds:function(t,e){var i=Tt(e,"drawContainer",!0),s=Tt(e,"children");return void 0===s&&(s=this.getAllVisibleChildren([this])),i||(s=s.filter((function(t){return!t.isRexContainerLite}))),function(t,e,i){var s,r,n,h,a,o;if("number"==typeof i?s=i:(s=kt(i,"color"),r=kt(i,"lineWidth"),n=kt(i,"fillColor"),h=kt(i,"fillAlpha"),a=kt(i,"padding"),o=kt(i,"includeParent")),void 0===s&&(s=16777215),void 0===r&&(r=1),void 0===n&&(n=null),void 0===h&&(h=1),void 0===a&&(a=0),void 0===o&&(o=!0),Array.isArray(t))for(var l=0,d=t.length;l<d;l++)Pt(t[l],e,s,r,n,h,a,o);else Pt(t,e,s,r,n,h,a,o)}(s,t,e),this}};Object.assign(Mt,c,y,C,S,w,k,_,T,E,M,R,L,D,Y,W,B,N,q,Z,Ot);class Rt extends n{constructor(t,e,i,s,r,n){Array.isArray(s)&&(n=s,s=void 0,r=void 0),super(t,e,i,s,r),this.type="rexContainerLite",this.isRexContainerLite=!0,this.syncChildrenEnable=!0,this._active=!0,this._mask=null,this._scrollFactorX=1,this._scrollFactorY=1,this._cameraFilter=0,this.privateRenderLayer=void 0,n&&this.add(n)}destroy(t){this.scene&&!this.ignoreDestroy&&(this.syncChildrenEnable=!1,super.destroy(t),this.privateRenderLayer&&this.privateRenderLayer.scene&&(this.privateRenderLayer.list.length=0,this.privateRenderLayer.destroy()))}resize(t,e){return this.setSize(t,e),this}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.syncPosition())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.syncPosition())}get rotation(){return super.rotation}set rotation(t){this.rotation!==t&&(super.rotation=t,this.syncPosition())}get scaleX(){return super.scaleX}set scaleX(t){this.scaleX!==t&&(super.scaleX=t,this.syncPosition())}get scaleY(){return super.scaleY}set scaleY(t){this.scaleY!==t&&(super.scaleY=t,this.syncPosition())}get scale(){return super.scale}set scale(t){this.scale!==t&&(super.scale=t,this.syncPosition())}get visible(){return super.visible}set visible(t){super.visible!==t&&(super.visible=t,this.syncVisible())}get alpha(){return super.alpha}set alpha(t){super.alpha!==t&&(super.alpha=t,this.syncAlpha())}get active(){return this._active}set active(t){this._active!==t&&(this._active=t,this.syncActive())}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.syncMask())}get scrollFactorX(){return this._scrollFactorX}set scrollFactorX(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}get scrollFactorY(){return this._scrollFactorY}set scrollFactorY(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}get cameraFilter(){return this._cameraFilter}set cameraFilter(t){this._cameraFilter!==t&&(this._cameraFilter=t,this.syncCameraFilter())}get list(){return this.children}static GetParent(t){return a(t)}get parentContainer(){return this._parentContainer}set parentContainer(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}get setParentContainerFlag(){if(this._setParentContainerFlag)return!0;var t=a(this);return!!t&&t.setParentContainerFlag}}Object.assign(Rt.prototype,Mt);var Lt=function(t){return t.hasOwnProperty("rexSizer")||(t.rexSizer={}),t.rexSizer};const Dt=Phaser.Cameras.Scene2D.BaseCamera,Yt=Phaser.Geom.Rectangle;var At=function(t,e,i){return e instanceof Dt||(i=e,e=void 0),void 0===i?i=new Yt:!0===i&&(i=Xt),e?t.scale.getViewPort(e,i):t.scale.getViewPort(i)},Xt=new Yt;const Wt=Phaser.Display.Align;var zt={center:Wt.CENTER,left:Wt.LEFT_CENTER,right:Wt.RIGHT_CENTER,top:Wt.TOP_CENTER,bottom:Wt.BOTTOM_CENTER,"left-top":Wt.TOP_LEFT,"top-left":Wt.TOP_LEFT,"left-center":Wt.LEFT_CENTER,"center-left":Wt.LEFT_CENTER,"left-bottom":Wt.BOTTOM_LEFT,"bottom-left":Wt.BOTTOM_LEFT,"center-top":Wt.TOP_CENTER,"top-center":Wt.TOP_CENTER,"center-center":Wt.CENTER,"center-bottom":Wt.BOTTOM_CENTER,"bottom-center":Wt.BOTTOM_CENTER,"right-top":Wt.TOP_RIGHT,"top-right":Wt.TOP_RIGHT,"right-center":Wt.RIGHT_CENTER,"center-right":Wt.RIGHT_CENTER,"right-bottom":Wt.BOTTOM_RIGHT,"bottom-right":Wt.BOTTOM_RIGHT},jt=function(){},Ft=new Phaser.GameObjects.Zone({sys:{queueDepthSort:jt,events:{once:jt}}},0,0,1,1);Ft.setOrigin(0);var Bt=0,It=1,Ht=2,Nt=4,Gt=6,Vt=8,Ut=10,$t=12,Jt=function(t){var e=tt(t);return t.y+e-e*t.originY},Kt=function(t){var e=Q(t);return t.x-e*t.originX+.5*e},qt=function(t,e){var i=tt(t);return t.y=e-i+i*t.originY,t},Zt=function(t,e){var i=Q(t),s=i*t.originX;return t.x=e+s-.5*i,t},Qt=function(t){var e=Q(t);return t.x-e*t.originX},te=function(t,e){var i=Q(t);return t.x=e+i*t.originX,t},ee=function(t){var e=Q(t);return t.x+e-e*t.originX},ie=function(t,e){var i=Q(t);return t.x=e-i+i*t.originX,t},se=function(t,e){var i=tt(t),s=i*t.originY;return t.y=e+s-.5*i,t},re=function(t){var e=tt(t);return t.y-e*t.originY+.5*e},ne=function(t){var e=tt(t);return t.y-e*t.originY},he=function(t,e){var i=tt(t);return t.y=e+i*t.originY,t},ae=[];ae[11]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Zt(t,Kt(e)+i),qt(t,Jt(e)+s),t},ae[Ut]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),te(t,Qt(e)-i),qt(t,Jt(e)+s),t},ae[$t]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),ie(t,ee(e)+i),qt(t,Jt(e)+s),t},ae[Gt]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),function(t,e,i){Zt(t,e),se(t,i)}(t,Kt(e)+i,re(e)+s),t},ae[Nt]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),te(t,Qt(e)-i),se(t,re(e)+s),t},ae[Vt]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),ie(t,ee(e)+i),se(t,re(e)+s),t},ae[It]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Zt(t,Kt(e)+i),he(t,ne(e)-s),t},ae[Bt]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),te(t,Qt(e)-i),he(t,ne(e)-s),t},ae[Ht]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),ie(t,ee(e)+i),he(t,ne(e)-s),t};var oe=function(t,e,i,s,r){return ae[i](t,e,s,r)},le=function(t,e,i,s,r,n){Ft.setPosition(e,i).setSize(s,r),oe(t,Ft,n)};const de=Phaser.Utils.Objects.GetValue,ce=Phaser.GameObjects.Group,ue=Phaser.GameObjects.Container;var pe=function(t,e,i){return t.add.text(0,0,"")},ve=function(t,e){Array.isArray(t)||(t=[t]),void 0===e&&(e=[]);for(var i=0,s=t.length;i<s;i++){var r=t[i];r instanceof ue&&(e.push(...r.list),ve(r.list,e))}return e},ge=void 0;const fe=Phaser.Utils.Objects.GetValue;var me=function(t,e){return void 0===t&&(t=0),void 0===e&&(e={}),"number"==typeof t?(e.left=t,e.right=t,e.top=t,e.bottom=t):(e.left=fe(t,"left",0),e.right=fe(t,"right",0),e.top=fe(t,"top",0),e.bottom=fe(t,"bottom",0)),e};const ye=Rt.prototype.add;var be=function(t){return ye.call(this,t),this.sizerEventsEnable&&(t.emit("sizer.add",t,this),this.emit("add",t,this)),this},xe={addBackground(t,e,i){return void 0===this.backgroundChildren&&(this.backgroundChildren=[]),"string"==typeof e&&(i=e,e=void 0),void 0===e&&(e=0),be.call(this,t),this.backgroundChildren.push(t),this.getSizerConfig(t).padding=me(e),void 0!==i&&this.addChildrenMap(i,t),this},isBackground(t){return void 0!==this.backgroundChildren&&-1!==this.backgroundChildren.indexOf(t)}},Ce=function(t,e){var i=null;if(void 0===e)t.hasOwnProperty("rexContainer")&&((i=t.rexContainer.parent)?i.isRexSizer||(i=Ce(i)):i=null);else for(i=Ce(t);i&&i.name!==e;)i=Ce(i);return i},Se={getParentSizer(t,e){return"string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),Ce(t,e)},getTopmostSizer(t){return void 0===t&&(t=this),function(t){for(var e=Ce(t);e;)t=e,e=Ce(e);return t}(t)},hasParentSizer(t,e){void 0===e&&(e=this);for(var i=Ce(e);i;){if(i===t)return!0;i=Ce(i)}return!1},hasChild(t,e){return void 0===e&&(e=this),this.hasParentSizer(e,t)}};const we=Phaser.Utils.Array.Remove,Oe=Rt.prototype.remove,ke=Se.getParentSizer;var Pe=function(t,e){for(var i=ke(t);i;)i.removeChildCallback&&i.removeChildCallback(t,e),i=ke(i);return this.isBackground(t)&&we(this.backgroundChildren,t),Oe.call(this,t,e),!e&&this.sizerEventsEnable&&(t.emit("sizer.remove",t,this),this.emit("remove",t,this)),this};const _e=Phaser.Utils.Array.Remove,Te=Se.getParentSizer;var Ee={removeFromParentSizer(){var t=Te(gameObject);return t&&t.remove(this),this},removeBackground(t,e){return void 0===this.backgroundChildren||this.getParentSizer(t)!==this||(_e(this.backgroundChildren,t),Pe.call(this,t,e)),this},removeAllBackgrounds(t){if(void 0===this.backgroundChildren)return this;for(var e=this.backgroundChildren.length-1;e>=0;e--)this.remove(this.backgroundChildren[e],t);return this}},Me=function(t,e){if("string"==typeof t)this.childrenMap[t]=e;else{var i=t;for(t in i)this.childrenMap[t]=i[t]}return this};const Re=/(\S+)\[(\d+)\]/i,Le=Phaser.Utils.Objects.GetValue;var De=function(t,e){return void 0===e?t:t[e]},Ye=function(t,e,i){void 0===t&&(t={}),void 0===e&&(e=0);var s=typeof e;return"string"===s?t[e]=i:"number"===s?(t.left=e,t.right=e,t.top=e,t.bottom=e):(t.left=Le(e,"left",0),t.right=Le(e,"right",0),t.top=Le(e,"top",0),t.bottom=Le(e,"bottom",0)),t},Ae={getInnerPadding(t){return De(this.space,t)},setInnerPadding(t,e){return Ye(this.space,t,e),this},getOuterPadding(t){return De(this.getSizerConfig(this).padding,t)},setOuterPadding(t,e){return Ye(this.getSizerConfig(this).padding,t,e),this},getChildOuterPadding(t,e){return"string"==typeof t&&(t=this.getElement(t)),De(this.getSizerConfig(t).padding,e)},setChildOuterPadding(t,e,i){return"string"==typeof t&&(t=this.getElement(t)),Ye(this.getSizerConfig(t).padding,e,i),this}},Xe=function(t){var e=this.childrenWidth;if(void 0!==e){var i=void 0!==this.minWidth?this.minWidth*this.scaleX:0;return void 0===t?(t=Math.max(i,e),this.layoutWarnEnable&&i>0&&e>i&&console.warn(`Layout width warn: ${this.constructor.name}'s minWidth (${i}) < childrenWidth (${e})`)):this.layoutWarnEnable&&(i>t||e>t)&&console.warn(`Layout width warn: ${this.constructor.name}'s minWidth (${i}) or childrenWidth (${e} > targetWidth ${t})`),t}},We=function(){var t;for(var e in this.sizerChildren)if(!(!(t=this.sizerChildren[e])||t.isRexSizer&&t.ignoreLayout)&&t.runWidthWrap&&(!t.hasWidthWrap||t.hasWidthWrap()))return!0;return!1},ze=function(t){var e,i,s;for(var r in this.sizerChildren)!(e=this.sizerChildren[r])||e.isRexSizer&&e.ignoreLayout||!e.runWidthWrap||(void 0!==t?(i=this.getExpandedChildWidth(e,t),e.isRexSizer?void 0===(s=e.resolveWidth(i))&&(s=i):s=i,e.runWidthWrap(s)):e.minWidth>0&&e.runWidthWrap(e.minWidth));return this},je=function(t){var e=this.childrenHeight;if(void 0!==e){var i=void 0!==this.minHeight?this.minHeight*this.scaleY:0;return void 0===t?(t=Math.max(i,e),this.layoutWarnEnable&&i>0&&e>i&&console.warn(`Layout height warn: ${this.constructor.name}'s minHeight (${i}) < childrenHeight (${e})`)):this.layoutWarnEnable&&(i>t||e>t)&&console.warn(`Layout height warn: ${this.constructor.name}'s minHeight (${i}) or childrenHeight (${e}) > targetHeight (${t})`),t}},Fe=function(){var t;for(var e in this.sizerChildren)if(!(!(t=this.sizerChildren[e])||t.isRexSizer&&t.ignoreLayout)&&t.runHeightWrap&&(!t.hasHeightWrap||t.hasHeightWrap()))return!0;return!1},Be=function(t){var e,i,s;for(var r in this.sizerChildren)!(e=this.sizerChildren[r])||e.isRexSizer&&e.ignoreLayout||!e.runHeightWrap||(void 0!==t?(i=this.getExpandedChildHeight(e,t),e.isRexSizer?void 0===(s=e.resolveHeight(i))&&(s=i):s=i,e.runHeightWrap(s)):e.minHeight>0&&e.runHeightWrap(e.minHeight));return this},Ie={getShownChildren(t){void 0===t&&(t=[]);for(var e,i=this.children,s=0,r=i.length;s<r;s++)(e=i[s]).rexSizer&&e.rexSizer.hidden||t.push(e);return t},getAllShownChildren(t){void 0===t&&(t=[]);for(var e=[this];e.length>0;){var i=e.shift();i.rexSizer&&i.rexSizer.hidden||(i!==this&&t.push(i),i.isRexContainerLite&&e.push(...i.children))}return t}},He=function(){this._childrenWidth=void 0,this._childrenHeight=void 0;for(var t,e=this.getChildrenSizers(),i=0,s=e.length;i<s;i++)(t=e[i]).ignoreLayout||t.preLayout()},Ne=[Phaser.GameObjects.Image,Phaser.GameObjects.Sprite,Phaser.GameObjects.Mesh,Phaser.GameObjects.Shader,Phaser.GameObjects.Video],Ge=[Phaser.GameObjects.BitmapText],Ve=function(t,e,i){if(t&&(void 0!==e||void 0!==i))if(function(t){if(t.resize)return!0;if(!t.setSize)return!1;for(var e=0,i=Ne.length;e<i;e++){var s=Ne[e];if(s&&t instanceof s)return!1}return!0}(t)){var s,r;s=void 0===e?t.width:e/t.scaleX,r=void 0===i?t.height:i/t.scaleY,t.resize?t.resize(s,r):t.setSize(s,r)}else{var n=function(t){if(void 0===t.displayWidth)return!1;for(var e=0,i=Ge.length;e<i;e++){var s=Ge[e];if(s&&t instanceof s)return!1}return!0}(t);void 0!==e&&(n?t.displayWidth=e:t.scaleX=e/t.width),void 0!==i&&(n?t.displayHeight=i:t.scaleY=i/t.height)}},Ue=function(t,e,i,s,r){var n=$e(t,e,s),h=Je(t,i,r);return void 0===n&&(n=$e(t,e,s)),void 0!==n&&void 0!==h&&{width:n,height:h}},$e=function(t,e,i){return e=t.resolveWidth(e),i&&(t.resolveChildrenWidth(e),t.runWidthWrap(e)),e},Je=function(t,e,i){return e=t.resolveHeight(e),i&&(t.resolveChildrenHeight(e),t.runHeightWrap(e)),e},Ke={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const qe=Phaser.Scene;var Ze=function(t){return t instanceof qe},Qe=function(t){return null==t||"object"!=typeof t?null:Ze(t)?t:t.scene&&Ze(t.scene)?t.scene:t.parent&&t.parent.scene&&Ze(t.parent.scene)?t.parent.scene:null};const ti=Phaser.Game;var ei=function(t){return t instanceof ti},ii=function(t){return null==t||"object"!=typeof t?null:ei(t)?t:ei(t.game)?t.game:Ze(t)?t.sys.game:Ze(t.scene)?t.scene.sys.game:void 0};const si=Phaser.Utils.Objects.GetValue;class ri{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(si(e,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this))}shutdown(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0)}destroy(t){this.shutdown(t)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(t,e){this.destroy(e)}setParent(t){return this.parent=t,this.scene=Qe(t),this.game=ii(t),this}}Object.assign(ri.prototype,Ke);var ni=function(t,e,i,s){Ve(i,t,e)};const hi=Phaser.Utils.Objects.GetValue;class ai extends ri{constructor(t,e){super(t,{eventEmitter:!1}),this.viewport=void 0,this.resetFromJSON(e)}shutdown(t){this.isShutdown||(this.autoAnchor(!1),this.viewport=void 0,this.onUpdateViewportCallback=void 0,this.onUpdateViewportCallbackScope=void 0,this.onResizeCallback=void 0,this.onResizeCallbackScope=void 0,super.shutdown(t))}resetFromJSON(t){void 0===t&&(t={});var e,i,s,r,n,h,a,o,l=this.parent;void 0!==t.x?(e=null,i=t.x):void 0!==t.left?(e=0,i=t.left):void 0!==t.right?(e=1,i=t.right):void 0!==t.centerX&&(e=.5,i=t.centerX),void 0!==t.y?(s=null,r=t.y):void 0!==t.top?(s=0,r=t.top):void 0!==t.bottom?(s=1,r=t.bottom):void 0!==t.centerY&&(s=.5,r=t.centerY),void 0!==i&&(i=i.replace("left","0%").replace("right","100%").replace("center","50%").split("%"),n=parseFloat(i[0])/100,h=""===i[1]?0:parseFloat(i[1])),void 0!==r&&(r=r.replace("top","0%").replace("bottom","100%").replace("center","50%").split("%"),a=parseFloat(r[0])/100,o=""===r[1]?0:parseFloat(r[1]));var d,c,u=t.width;void 0!==u&&(u=u.split("%"),d=parseFloat(u[0])/100,c=""===u[1]?0:parseFloat(u[1]));var p,v,g=t.height;void 0!==g&&(g=g.split("%"),p=parseFloat(g[0])/100,v=""===g[1]?0:parseFloat(g[1]));var f=t.aspectRatio;!0===f&&(f=l.displayWidth/l.displayHeight),this.setAlign(e,s),this.setPercentage(n,a),this.setOffset(h,o),this.setSizePercentage(d,p),this.setSizePadding(c,v),this.setAspectRatio(f);var m=hi(t,"onResizeCallback",ni),y=hi(t,"onResizeCallbackScope");this.setResizeCallback(m,y);var b=hi(t,"onUpdateViewportCallback"),x=hi(t,"onUpdateViewportCallbackScope");return this.setUpdateViewportCallback(b,x),this.autoAnchor(t.enable),this}autoAnchor(t){return void 0===t&&(t=!0),t=!!t,this.autoAnchorEnable===t||(t?(this.scene.sys.scale.on("resize",this.anchor,this),this.anchor()):this.scene.sys.scale.off("resize",this.anchor,this),this.autoAnchorEnable=t),this}setAlign(t,e){return this.alignX=t,this.alignY=e,this}setPercentage(t,e){return this.percentageX=t,this.percentageY=e,this}setOffset(t,e){return this.offsetX=t,this.offsetY=e,this}setSizePercentage(t,e){return this.percentageWidth=t,this.percentageHeight=e,this}setSizePadding(t,e){return this.paddingWidth=t,this.paddingHeight=e,this}setAspectRatio(t){return this.aspectRatio=t,this}setResizeCallback(t,e){return this.onResizeCallback=t,this.onResizeCallbackScope=e,this}setUpdateViewportCallback(t,e){return this.onUpdateViewportCallback=t,this.onUpdateViewportCallbackScope=e,this}anchor(){return this.updateViewport(),this.updateSize(),this.updatePosition(),this}updateSize(){var t=this.onResizeCallback,e=this.onResizeCallbackScope,i=this.anchorWidth,s=this.anchorHeight;if((void 0!==i||void 0!==s)&&t){var r=this.parent;void 0===i&&(i=this.aspectRatio&&s?this.aspectRatio*s:r.width),void 0===s&&(s=this.aspectRatio&&i?i/this.aspectRatio:r.height),e?t.call(e,i,s,r,this):t(i,s,r,this)}}updatePosition(){var t=this.parent;return null===this.alignX?t.x=this.anchorX:void 0!==this.alignX&&(t.x=this.anchorX+t.displayWidth*(t.originX-this.alignX)),null===this.alignY?t.y=this.anchorY:void 0!==this.alignY&&(t.y=this.anchorY+t.displayHeight*(t.originY-this.alignY)),this}get anchorX(){return this.viewport.x+this.viewport.width*this.percentageX+this.offsetX}get anchorY(){return this.viewport.y+this.viewport.height*this.percentageY+this.offsetY}get anchorWidth(){if(void 0!==this.percentageWidth)return this.viewport.width*this.percentageWidth+this.paddingWidth}get anchorHeight(){if(void 0!==this.percentageHeight)return this.viewport.height*this.percentageHeight+this.paddingHeight}updateViewport(){var t=this.parent.scene.cameras.main;this.viewport=At(this.scene,t,this.viewport);var e=this.viewport,i=this.onUpdateViewportCallback,s=this.onUpdateViewportCallbackScope;i&&(s?i.call(s,e,this.parent,this):i(e,this.parent,this))}}const oi=Phaser.Utils.Objects.GetValue;class li extends ri{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(oi(e,"tickingMode",1))}boot(){2!==this.tickingMode||this.tickingState||this.startTicking()}shutdown(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),super.shutdown(t))}setTickingMode(t){"string"==typeof t&&(t=di[t]),this.tickingMode=t}startTicking(){this.tickingState=!0}stopTicking(){this.tickingState=!1}get isRunning(){return this._isRunning}set isRunning(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}start(){return this.isPaused=!1,this.isRunning=!0,this}pause(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}resume(){return this.isPaused&&(this.isPaused=!1,this.isRunning=!0),this}stop(){return this.isPaused=!1,this.isRunning=!1,this}complete(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}const di={no:0,lazy:1,always:2},ci=Phaser.Utils.Objects.GetValue;class ui extends li{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=ci(e,"tickEventName",i),this.isSceneTicker=!pi(this.tickEventName)}startTicking(){super.startTicking(),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this)}stopTicking(){super.stopTicking(),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this)}}var pi=function(t){return"step"===t||"poststep"===t};const vi=Phaser.Utils.Objects.GetValue,gi=Phaser.Math.Clamp;class fi{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=vi(t,"state",mi),this.timeScale=vi(t,"timeScale",1),this.delay=vi(t,"delay",0),this.repeat=vi(t,"repeat",0),this.repeatCounter=vi(t,"repeatCounter",0),this.repeatDelay=vi(t,"repeatDelay",0),this.duration=vi(t,"duration",0),this.nowTime=vi(t,"nowTime",0),this.justRestart=vi(t,"justRestart",!1)}toJSON(){return{state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}destroy(){}setTimeScale(t){return this.timeScale=t,this}setDelay(t){return void 0===t&&(t=0),this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatInfinity(){return this.repeat=-1,this}setRepeatDelay(t){return this.repeatDelay=t,this}start(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?bi:yi,this.repeatCounter=0,this}stop(){return this.state=mi,this}update(t,e){this.state!==mi&&this.state!==Ci&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=xi)):(this.nowTime=this.duration,this.state=Ci):this.nowTime>=0&&(this.state=bi))}get t(){var t;switch(this.state){case mi:case yi:case xi:t=0;break;case bi:t=this.nowTime/this.duration;break;case Ci:t=1}return gi(t,0,1)}set t(t){(t=gi(t,-1,1))<0?(this.state=yi,this.nowTime=-this.delay*t):(this.state=bi,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===mi}get isDelay(){return this.state===yi}get isCountDown(){return this.state===bi}get isRunning(){return this.state===yi||this.state===bi}get isDone(){return this.state===Ci}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const mi=0,yi=1,bi=2,xi=3,Ci=-1;class Si extends ui{constructor(t,e){super(t,e),this.timer=new fi}shutdown(t){this.isShutdown||(super.shutdown(t),this.timer.destroy(),this.timer=void 0)}start(){return this.timer.start(),super.start(),this}stop(){return this.timer.stop(),super.stop(),this}complete(){return this.timer.stop(),super.complete(),this}}const wi=Phaser.Utils.Objects.GetValue,Oi=Phaser.Utils.Objects.GetAdvancedValue,ki=Phaser.Tweens.Builders.GetEaseFunction;class Pi extends Si{resetFromJSON(t){return this.timer.resetFromJSON(wi(t,"timer")),this.setEnable(wi(t,"enable",!0)),this.setTarget(wi(t,"target",this.parent)),this.setDelay(Oi(t,"delay",0)),this.setDuration(Oi(t,"duration",1e3)),this.setEase(wi(t,"ease","Linear")),this.setRepeat(wi(t,"repeat",0)),this}setEnable(t){return null==t&&(t=!0),this.enable=t,this}setTarget(t){return void 0===t&&(t=this.parent),this.target=t,this}setDelay(t){return this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=ki(t),this}start(){return this.timer.isRunning||super.start(),this}restart(){return this.timer.stop(),this.start.apply(this,arguments),this}stop(t){return void 0===t&&(t=!1),super.stop(),t&&(this.timer.setT(1),this.updateTarget(this.target,this.timer),this.complete()),this}update(t,e){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateTarget(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}updateTarget(t,e){}}const _i=Phaser.Utils.Objects.GetValue,Ti=Phaser.Utils.Objects.GetAdvancedValue,Ei=Phaser.Math.Linear;let Mi=class extends Pi{constructor(t,e){super(t,e),this.scaleStart={},this.scaleEnd={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(_i(t,"mode",0)),this.setScaleRange(Ti(t,"start",void 0),Ti(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=Ri[t]),this.mode=t,this}setScaleRange(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=Ti(t,"x",this.parent.scaleX),this.startY=Ti(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=Ti(e,"x",void 0),this.endY=Ti(e,"y",void 0)),this.hasScaleX=void 0!==this.startX&&void 0!==this.endX,this.hasScaleY=void 0!==this.startY&&void 0!==this.endY,this}start(){if(this.timer.isRunning)return this;var t=this.parent;this.hasScaleX&&(t.scaleX=this.startX),this.hasScaleY&&(t.scaleY=this.startY);var e=this.repeat;return 2===this.mode&&-1!==e&&(e=2*(e+1)-1),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(e),super.start(),this}updateTarget(t,e){var i=e.t;e.isOddIteration&&(i=1-i),i=this.easeFn(i),this.hasScaleX&&(t.scaleX=Ei(this.startX,this.endX,i)),this.hasScaleY&&(t.scaleY=Ei(this.startY,this.endY,i))}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}};const Ri={stop:0,destroy:1,yoyo:2};var Li=function(t,e,i,s,r){var n,h;switch(void 0===s&&(s="Cubic"),i){case 0:case"x":n={x:0},h={x:t.scaleX};break;case 1:case"y":n={y:0},h={y:t.scaleY};break;default:n=0,h=t.scale}var a={mode:0,start:n,end:h,duration:e,ease:s};return void 0===r?r=new Mi(t,a):r.resetFromJSON(a),r.restart(),r},Di=function(t,e,i,s,r,n){void 0===s&&(s="Linear"),r instanceof Mi&&(n=r,r=void 0),void 0===r&&(r=!0);var h={};switch(h.mode=r?1:0,i){case 0:case"x":h.end={x:0};break;case 1:case"y":h.end={y:0};break;default:h.end=0}return h.duration=e,h.ease=s,void 0===n?n=new Mi(t,h):n.resetFromJSON(h),n.restart(),n},Yi=function(t,e){return new Promise((function(i,s){t.once(e,(function(){i()}))}))},Ai=function(t){return Yi(t,"complete")};const Xi=Phaser.Utils.Objects.IsPlainObject;var Wi={onInitScale(){var t=this,e=this._scaleBehavior;e.com