UNPKG

@petkoneo/phaser3-rex-plugins

Version:
1 lines 860 kB
var t,e;t=void 0,e=function(){class t{constructor(t){this.scene=t,t.events.once("destroy",this.destroy,this)}destroy(){this.scene=null}static register(e,i){t.prototype[e]=i}}var e=function(t,e,i){return"__BASE"===i?`${t},${e}`:`${i}:${t},${e}`};function i(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>i(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=i(t[s]));return e}const s=Phaser.Utils.Objects.IsPlainObject,r=Phaser.Utils.Objects.GetValue;var n=function(t){return"string"==typeof t&&(t=a[t]),t};const a={scale:0,repeat:1};var o=function(t,e){return 0===t||t===this.columns.count-1||0===e||e===this.rows.count-1},h=function(){},l={_beginDraw:h,_drawImage:h,_drawTileSprite:h,_endDraw:h,setGetFrameNameCallback:function(t){return void 0===t&&(t=e),this.getFrameNameCallback=t,this},setBaseTexture:function(t,e,s,r){Array.isArray(e)&&(r=s,s=e,e=void 0),null==e&&(e="__BASE"),"number"==typeof s&&arguments.length>=6?(s=[arguments[2],void 0,arguments[3]],r=[arguments[4],void 0,arguments[5]]):void 0===s&&void 0===r&&void 0!==this.columns.data&&void 0!==this.rows.data?(s=this.columns.data,r=this.rows.data):(s=i(s),r=i(r)),this.textureKey=t,this.baseFrameName=e,this.columns.data=s,this.columns.count=s?s.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.columns.scale=1,this.rows.data=r,this.rows.count=r?r.length:0,this.rows.stretch=0,this.rows.minHeight=0,this.rows.scale=1;var n=this.scene.sys.textures.get(t);if(!n)return this.clear(),this;if(!s||!r)return this.clear(),this;for(var a=n.get(e),o=a.width,h=0,l=0,d=s.length;l<d;l++)void 0===s[l]?h++:"number"==typeof s[l]?o-=s[l]:o-=s[l].width;var c=h>0?o/h:0,u=a.height,p=0;for(l=0,d=r.length;l<d;l++)void 0===r[l]?p++:"number"==typeof r[l]?u-=r[l]:u-=r[l].width;for(var g,v,f,m,y,b=p?u/p:0,x=0,C=0,k=0,w=r.length;k<w;k++){void 0===r[k]&&(r[k]=b),"number"==typeof r[k]&&(r[k]={height:r[k],stretch:k%2}),f=(g=r[k]).height,this.rows.stretch+=0|g.stretch,this.rows.minHeight+=g.stretch>0?0:f,x=0,l=0;for(var S=s.length;l<S;l++){if(void 0===s[l]&&(s[l]=c),"number"==typeof s[l]&&(s[l]={width:s[l],stretch:l%2}),m=(v=s[l]).width,0===k&&(this.columns.stretch+=0|v.stretch,this.columns.minWidth+=v.stretch>0?0:m),m>=1&&f>=1){var P=typeof(y=this.getFrameNameCallback(l,k,e));"string"!==P&&"number"!==P||n.add(y,0,x+a.cutX,C+a.cutY,m,f)}x+=m}C+=f}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.sys.textures.get(this.textureKey);if(!t)return this;var e,i,s,r,n,a,o,h=this.columns.minWidth*this.maxFixedPartScaleX,l=this.rows.minHeight*this.maxFixedPartScaleY,d=this.width-h,c=this.height-l,u=d>=0?this.maxFixedPartScaleX:this.width/h,p=c>=0?this.maxFixedPartScaleY:this.height/l;if(this.preserveRatio){var g=Math.min(u,p);if(u>g){var v=(u-g)*h;d>=0?d+=v:d=v,u=g}if(p>g){var f=(p-g)*l;c>=0?c+=f:c=f,p=g}}this.columns.scale=u,this.rows.scale=p,e=d>0&&this.columns.stretch>0?d/this.columns.stretch:0,i=c>0&&this.rows.stretch>0?c/this.rows.stretch:0;var m=0,y=0;this._beginDraw();for(var b=0,x=this.rows.count;b<x;b++){o=0===(n=this.rows.data[b]).stretch?n.height*p:i*n.stretch,m=0;for(var C=0,k=this.columns.count;C<k;C++)a=0===(r=this.columns.data[C]).stretch?r.width*u:e*r.stretch,s=this.getFrameNameCallback(C,b,this.baseFrameName),t.has(s)&&a>0&&o>0&&(0==(0===n.stretch&&0===r.stretch||0===this.getStretchMode(C,b)?0:1)?this._drawImage(this.textureKey,s,m,y,a,o):this._drawTileSprite(this.textureKey,s,m,y,a,o)),m+=a;y+=o}this._endDraw()},setStretchMode:function(t){return s(t)?(this.stretchMode.edge=n(r(t,"edge",0)),this.stretchMode.internal=n(r(t,"internal",0))):(t=n(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,e){return o.call(this,t,e)?this.stretchMode.edge:this.stretchMode.internal},setPreserveRatio:function(t){return null==t&&(t=!0),this.preserveRatio=t,this},setMaxFixedPartScale:function(t,e){return void 0===e&&(e=t),this.maxFixedPartScaleX=t,this.maxFixedPartScaleY=e,this}};const d=Phaser.Utils.Objects.IsPlainObject,c=Phaser.Utils.Objects.GetValue;var u=function(t,e){class i extends t{constructor(t,i,s,r,n,a,o,h,l,u){if(d(i)?(i=c(u=i,"x",0),s=c(u,"y",0),r=c(u,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(r)?(r=c(u=r,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(a)?(a=c(u=a,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(o)?(o=c(u=o,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):Array.isArray(o)?(u=l,l=h,h=o,o=c(u,"baseFrame",void 0)):d(h)&&(h=c(u=h,"columns",void 0),l=c(u,"rows",void 0)),void 0===o&&(o=c(u,"frame",void 0)),void 0===h){var p=c(u,"leftWidth",void 0),g=c(u,"rightWidth",void 0);void 0!==p&&void 0!==g&&(h=[p,void 0,g])}if(void 0===l){var v=c(u,"topHeight",void 0),f=c(u,"bottomHeight",void 0);void 0!==v&&void 0!==f&&(l=[v,void 0,f])}super(t),this.type=e,this.setPosition(i,s).setSize(r,n).setOrigin(.5,.5),this.columns={},this.rows={},this.stretchMode={},this._tileSprite=void 0,this._image=void 0,this.setGetFrameNameCallback(c(u,"getFrameNameCallback",void 0)),this.setStretchMode(c(u,"stretchMode",0)),this.setPreserveRatio(c(u,"preserveRatio",!0));var m=c(u,"maxFixedPartScale",1),y=c(u,"maxFixedPartScaleX",m),b=c(u,"maxFixedPartScaleY",void 0);this.setMaxFixedPartScale(y,b),this.setBaseTexture(a,o,h,l)}get minWidth(){return this.columns.minWidth}get minHeight(){return this.rows.minHeight}get fixedPartScaleX(){return this.columns.scale}get fixedPartScaleY(){return this.rows.scale}resize(t,e){return this.width===t&&this.height===e||(super.resize?super.resize(t,e):super.setSize(t,e),this.updateTexture()),this}get leftWidth(){return this.columns.data[0]}get rightWidth(){return this.columns.data[this.columns.count-1]}get topHeight(){return this.rows.data[0]}get bottomHeight(){return this.rows.data[this.rows.count-1]}}return Object.assign(i.prototype,l),i};const p=Phaser.Game;var g=function(t){return t instanceof p};const v=Phaser.Scene;var f=function(t){return t instanceof v},m=function(t){return null==t||"object"!=typeof t?null:g(t)?t:g(t.game)?t.game:f(t)?t.sys.game:f(t.scene)?t.scene.sys.game:void 0};const y=Phaser.GameObjects;var b=void 0,x=function(t,e){if(b||(b={},m(t).events.once("destroy",(function(){for(var t in b)b[t].destroy();b=void 0}))),!b.hasOwnProperty(e)){var i=m(t).scene.systemScene;(t=new y[e](i)).setOrigin(0),b[e]=t}return b[e]};const C=Phaser.GameObjects.RenderTexture;let k=class extends(u(C,"rexNinePatch")){};var w={_drawImage:function(t,e,i,s,r,n){var a=x(this,"Image").setTexture(t,e).setDisplaySize(r,n);this.draw(a,i,s)},_drawTileSprite:function(t,e,i,s,r,n){var a=x(this,"TileSprite").setTexture(t,e).setSize(r,n);this.draw(a,i,s)}};Object.assign(k.prototype,w);var S=function(t){return null==t||""===t||0===t.length},P=function(t,e,i,s){if(void 0===s&&(s="."),"object"==typeof t){if(S(e)){if(null==i)return;"object"==typeof i&&(t=i)}else{"string"==typeof e&&(e=e.split(s));var r=e.pop(),n=function(t,e,i){var s=t;if(S(e));else{var r;"string"==typeof e&&(e=e.split("."));for(var n=0,a=e.length;n<a;n++){var o;null!=s[r=e[n]]&&"object"==typeof s[r]||(o=n===a-1?void 0===i?{}:i:{},s[r]=o),s=s[r]}}return s}(t,e);n[r]=i}return t}};t.register("ninePatch",(function(t,e,i,s,r,n,a,o){var h=new k(this.scene,t,e,i,s,r,n,a,o);return this.scene.add.existing(h),h})),P(window,"RexPlugins.UI.NinePatch",k);const T=Phaser.GameObjects.GetCalcMatrix,O=Phaser.Renderer.Canvas.SetTransform;var M={renderWebGL:function(t,e,i,s){var r=e.getRenderList();if(0!==r.length){i.addToRenderList(e);var n=t.pipelines.set(e.pipeline),a=e.frame.glTexture,o=n.setGameObject(e),h=i.roundPixels,l=T(e,i,s),d=n.calcMatrix.copyFrom(l.calc),c=e._displayOriginX,u=e._displayOriginY,p=i.alpha*e.alpha;t.pipelines.preBatch(e);for(var g=0,v=r.length;g<v;g++)r[g].webglRender(n,d,p,c,u,a,o,h);t.pipelines.postBatch(e)}},renderCanvas:function(t,e,i,s){var r=t.currentContext,n=e.getRenderList();if(0!==n.length&&O(t,r,e,i,s)){i.addToRenderList(e);var a=i.roundPixels,o=-e._displayOriginX,h=-e._displayOriginY;r.translate(o,h);for(var l=0,d=n.length;l<d;l++)n[l].canvasRender(r,o,h,a);r.restore()}}},E=function(t,e){if(this.width===t&&this.height===e)return this;this.width=t,this.height=e,this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this};const _=Phaser.Utils.Array.Remove;var R=function(){return this.poolManager&&this.poolManager.freeMultiple(this.children.list),this.children.list.length=0,this.lastAppendedChildren.length=0,this.dirty=!0,this},L={setTint(t){return this.tint=t,this.tintFill=!1,this},setTintFill(t){return this.tint=t,this.tintFill=!0,this},clearTint(){return this.setTint(16777215),this}},B={setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.frame=this.texture.get(e),this},resize:E,setSize:E,addChild:function(t){return this.lastAppendedChildren.length=0,Array.isArray(t)?(this.children.add(t),this.lastAppendedChildren.push(...t)):(this.children.add(t),this.lastAppendedChildren.push(t)),this},removeChild:function(t){return this.poolManager&&this.poolManager.free(t),_(this.children.list,t),this.lastAppendedChildren.length=0,this.dirty=!0,this},removeChildren:R,clear:R,getLastAppendedChildren:function(){return this.lastAppendedChildren},getChildren:function(){return this.children.list}};Object.assign(B,L);class I{constructor(){this.items=[]}destroy(){this.clear(),this.items=void 0}pop(){return this.items.length>0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const D=Phaser.Utils.Objects.GetValue;var A={};let j=class{constructor(t){this.pools=D(t,"pools",A)}destroy(){this.pools=void 0}free(t){if(!this.pools)return this;var e=t.type;return this.pools.hasOwnProperty(e)||(this.pools[e]=new I),this.pools[e].push(t),t.onFree(),this}freeMultiple(t){if(!this.pools)return this;for(var e=0,i=t.length;e<i;e++)this.free(t[e]);return this}allocate(t){return this.pools&&this.pools.hasOwnProperty(t)?this.pools[t].pop():null}};var z=!1,F=function(t){if(!z){void 0===t&&(t=60);var e=Phaser.VERSION.split("."),i=parseInt(e[0]);if(3===i){var s=parseInt(e[1]);s<t&&console.error(`Minimum supported version : ${i}.${s}`)}else console.error(`Can't supported version : ${i}`);z=!0}};F();const Y=Phaser.GameObjects.GameObject,X=Phaser.Utils.Objects.IsPlainObject,W=Phaser.Utils.Objects.GetValue,V=Phaser.Structs.List,G=Phaser.Utils.Array.StableSort;class H extends Y{constructor(t,e,i,s,r,n){X(e)&&(e=W(n=e,"x",0),i=W(n,"y",0),s=W(n,"texture"),r=W(n,"frame")),void 0===e&&(e=0),void 0===i&&(i=0),super(t,"rexBlitter"),this.children=new V,this.renderList=[],this.displayListDirty=!1,this.lastAppendedChildren=[];var a=W(n,"reuseBob",!0);this.poolManager=a?new j(n):void 0,this.setTexture(s,r),this.setPosition(e,i),this.setOrigin(0,0),this.clearTint(),this.initPipeline(),this.initPostPipeline()}preDestroy(){this.removeChildren(),this.children.destroy(),this.renderList.length=0,this.poolManager&&this.poolManager.destroy()}getRenderList(){if(this.displayListDirty){this.renderList.length=0;for(var t=!1,e=this.children.list,i=0,s=e.length;i<s;i++){var r=e[i];U(r)&&(this.renderList.push(r),t||(t=0!==r.depth))}t&&G(this.renderList,N),this.displayListDirty=!1}return this.renderList}}var U=function(t){return t.active&&t.visible&&t.alpha>0},N=function(t,e){return t._depth-e._depth};const $=Phaser.GameObjects.Components;Phaser.Class.mixin(H,[$.Alpha,$.BlendMode,$.ComputedSize,$.Depth,$.GetBounds,$.Mask,$.Origin,$.Pipeline,$.PostPipeline,$.ScrollFactor,$.Transform,$.Visible,M,B]);const K="image";var J=function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,n=i,a=0;a<s.length;a++){if(e=s[a],!r.hasOwnProperty(e)){n=i;break}r=n=r[e]}return n},q=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},Z={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:J(this.data,t,e)},incData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData(){return this.data&&q(this.data),this}};let Q=class{constructor(t,e){this.type=e,this.data=void 0,this.setParent(t).reset().setActive()}destroy(){this.parent&&this.parent.removeChild(this)}setParent(t){return this.parent=t,this}setDisplayListDirty(t){return t&&this.parent&&(this.parent.displayListDirty=!0),this}get active(){return this._active}set active(t){this.setDisplayListDirty(this._active!=t),this._active=t}setActive(t){return void 0===t&&(t=!0),this.active=t,this}modifyPorperties(t){return this}reset(){this.clearData()}onFree(){this.reset().setActive(!1).setParent()}};Object.assign(Q.prototype,Z);const tt=Phaser.Math.DegToRad,et=Phaser.Math.RadToDeg,it=Phaser.Utils.Objects.GetValue;let st=class extends Q{get visible(){return this._visible}set visible(t){this.setDisplayListDirty(this._visible!=t),this._visible=t}setVisible(t){return void 0===t&&(t=!0),this.visible=t,this}get alpha(){return this._alpha}set alpha(t){this.setDisplayListDirty(!!this._alpha!=!!t),this._alpha=t}setAlpha(t){return this.alpha=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setPosition(t,e){return this.x=t,this.y=e,this}setRotation(t){return this.rotation=t,this}get angle(){return et(this.rotation)}set angle(t){this.rotation=tt(t)}setAngle(t){return this.angle=t,this}setScaleX(t){return this.scaleX=t,this}get width(){return this._width}set width(t){this._width=t}setWidth(t,e){return void 0===e&&(e=!1),this.width=t,e&&(this.scaleY=this.scaleX),this}setScaleY(t){return this.scaleY=t,this}setScale(t,e){return void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this}get height(){return this._height}set height(t){this._height=t}setHeight(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}setScale(t,e){return void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this}get displayWidth(){return this._width*this.scaleX}set displayWidth(t){this.scaleX=t/this._width}setDisplayWidth(t,e){return void 0===e&&(e=!1),this.displayWidth=t,e&&(this.scaleY=this.scaleX),this}get displayHeight(){return this._height*this.scaleY}set displayHeight(t){this.scaleY=t/this._height}setDisplayHeight(t,e){return void 0===e&&(e=!1),this.displayHeight=t,e&&(this.scaleX=this.scaleY),this}setOriginX(t){return this.originX=t,this._displayOriginX=this.width*t,this}setOriginY(t){return this.originY=t,this._displayOriginY=this.height*t,this}setOrigin(t,e){return void 0===e&&(e=t),this.setOriginX(t).setOriginY(e),this}get depth(){return this._depth}set depth(t){this.setDisplayListDirty(this._depth!=t),this._depth=t}setDepth(t){return void 0===t&&(t=0),this.depth=t,this}modifyPorperties(t){if(!t)return this;t.hasOwnProperty("x")&&this.setX(t.x),t.hasOwnProperty("y")&&this.setY(t.y),t.hasOwnProperty("rotation")?this.setRotation(t.rotation):t.hasOwnProperty("angle")&&this.setAngle(t.angle),t.hasOwnProperty("alpha")&&this.setAlpha(t.alpha);var e=it(t,"width",void 0),i=it(t,"height",void 0),s=it(t,"scale",void 0),r=it(t,"scaleX",s),n=it(t,"scaleY",s);void 0!==e?void 0===i&&void 0===n?this.setWidth(e,!0):this.setWidth(e):void 0!==r?this.setScaleX(r):t.hasOwnProperty("displayWidth")&&this.setDisplayWidth(t.displayWidth),void 0!==i?void 0===e&&void 0===r?this.setHeight(i,!0):this.setHeight(i):void 0!==n?this.setScaleY(n):t.hasOwnProperty("displayHeight")&&this.setDisplayHeight(t.displayHeight);var a=it(t,"origin",void 0);return void 0!==a?this.setOrigin(a):(t.hasOwnProperty("originX")&&this.setOriginX(t.originX),t.hasOwnProperty("originY")&&this.setOriginY(t.originY)),t.hasOwnProperty("depth")&&this.setDepth(t.depth),this}reset(){return super.reset(),this.setVisible().setAlpha(1).setPosition(0,0).setRotation(0).setScale(1,1).setOrigin(0).setDepth(0),this}webglRender(t,e,i,s,r,n,a,o){}canvasRender(t,e,i,s){}};const rt=Phaser.GameObjects.Components.TransformMatrix,nt=Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha;var at=new rt;const ot=Phaser.Utils.Objects.IsPlainObject;let ht=class extends st{constructor(t,e){super(t,K),this._crop=lt(),this.setFrame(e)}get width(){return this._width}set width(t){}get height(){return this._height}set height(t){}setFrame(t){return arguments.length>0&&!ot(t)&&(t=this.parent.texture.get(t)),this.frame=t,t?(this._width=t.realWidth,this._height=t.realHeight):(this._width=0,this._height=0),this}setFlipX(t){return void 0===t&&(t=!0),this.flipX=t,this}setFlipY(t){return void 0===t&&(t=!0),this.flipY=t,this}resetFlip(){return this.flipX=!1,this.flipY=!1,this}get tint(){return void 0===this._tint?this.parent.tint:this._tint}set tint(t){this._tint=t}setTint(t){return this.tint=t,this.tintFill=!1,this}setTintFill(t){return this.tint=t,this.tintFill=!0,this}clearTint(){return this.setTint(16777215),this}resetTint(){return this.tint=void 0,this.tintFill=void 0,this}get tintFill(){return void 0===this._tintFill?this.parent.tintFill:this._tintFill}set tintFill(t){this._tintFill=t}setCrop(t,e,i,s){return void 0===t?(this.isCropped=!1,this):this.frame?0===t&&0===e&&i===this._width&&s===this._height?(this.isCropped=!1,this):(this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY),this.isCropped=!0,this):this}reset(){return super.reset(),this.resetFlip().resetTint().setFrame().setCrop(),this}modifyPorperties(t){return t?(t.hasOwnProperty("width")&&(t.displayWidth=t.width,delete t.width),t.hasOwnProperty("height")&&(t.displayHeight=t.height,delete t.height),t.hasOwnProperty("frame")&&this.setFrame(t.frame),super.modifyPorperties(t),t.hasOwnProperty("flipX")&&this.setFlipX(t.flipX),t.hasOwnProperty("flipY")&&this.setFlipY(t.flipY),t.hasOwnProperty("tint")&&this.setTint(t.tint),t.hasOwnProperty("tintFill")&&this.setTintFill(t.tintFill),this):this}};var lt=function(t){return void 0===t&&(t={}),t.u0=0,t.v0=0,t.u1=0,t.v1=0,t.x=0,t.y=0,t.width=0,t.height=0,t.flipX=!1,t.flipY=!1,t.cx=0,t.cy=0,t.cw=0,t.ch=0,t},dt={webglRender:function(t,e,i,s,r,n,a,o){var h=this.frame;if(h){var l,d,c,u,p,g,v,f,m=this._width,y=this._height,b=m*this.originX,x=y*this.originY,C=this.x-s,k=this.y-r;if(this.isCropped){var w=this._crop;w.flipX===this.flipX&&w.flipY===this.flipY||h.updateCropUVs(w,this.flipX,this.flipY),l=w.u0,d=w.v0,c=w.u1,u=w.v1,v=w.width,f=w.height,p=w.x,g=w.y}else l=this.frame.u0,d=this.frame.v0,c=this.frame.u1,u=this.frame.v1,v=m,f=y,p=0,g=0;var S=1,P=1;this.flipX&&(C+=m-2*b,S=-1),this.flipY&&(k+=y-2*x,P=-1),at.applyITRS(C,k,this.rotation,this.scaleX*S,this.scaleY*P),e.multiply(at,at);var T=-b+p,O=-x+g,M=T+v,E=O+f,_=at.setQuad(T,O,M,E,o),R=nt(this.tint,this.alpha*i);t.batchQuad(this.parent,_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],l,d,c,u,R,R,R,R,this.tintFill,n,a)}},canvasRender:function(t,e,i,s){var r=this.frame;if(r){t.save();var n,a,o,h,l=this._width,d=this._height,c=l*this.originX,u=d*this.originY,p=this.x-c,g=this.y-u;if(this.isCropped){var v=this._crop;v.flipX===this.flipX&&v.flipY===this.flipY||r.updateCropUVs(v,this.flipX,this.flipY),o=v.cw,h=v.ch,n=v.cx,a=v.cy}else o=r.cutWidth,h=r.cutHeight,n=r.cutX,a=r.cutY;var f=1,m=1;this.flipX&&(p+=l,f=-1),this.flipY&&(g+=d,m=-1);var y=r.source.resolution,b=o/y,x=h/y;s&&(p=Math.floor(p+.5),g=Math.floor(g+.5),b+=.5,x+=.5),t.translate(p,g),t.rotate(this.rotation),t.scale(this.scaleX*f,this.scaleY*m),t.drawImage(r.source.image,n,a,o,h,0,0,b,x),t.restore()}}};Object.assign(ht.prototype,dt);var ct=function(t,e){"string"==typeof e&&(e={frame:e});var i=t.poolManager?t.poolManager.allocate(K):null;return null===i?i=new ht(t):i.setParent(t).setActive(),i.modifyPorperties(e),t.addChild(i),i},ut={_drawImage:function(t,e,i,s,r,n){ct(this,{frame:e,x:i,y:s,width:r,height:n})},_drawTileSprite:function(t,e,i,s,r,n){var a=this.texture.get(e),o=a.width,h=a.height,l=r%o,d=n%h;0===l&&(l=o),0===d&&(d=h);for(var c=Math.ceil(r/o),u=Math.ceil(n/h),p=c-1,g=u-1,v=0;v<c;v++)for(var f=0;f<u;f++){let t=ct(this,{frame:e,x:i+v*o,y:s+f*h});var m=v===p?l:o,y=f===g?d:h;m===o&&y===h||t.setCrop(0,0,m,y)}}};class pt extends(u(H,"rexNinePatch2")){setBaseTexture(t,e,i,s){return this.setTexture(t,e),super.setBaseTexture(t,e,i,s),this}}Object.assign(pt.prototype,ut),t.register("ninePatch2",(function(t,e,i,s,r,n,a,o){var h=new pt(this.scene,t,e,i,s,r,n,a,o);return this.scene.add.existing(h),h})),P(window,"RexPlugins.UI.NinePatch2",pt);var gt=Phaser.Renderer.WebGL.Utils,vt=function(t,e,i,s,r,n){for(var a=gt.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*s),o=i.pathData,h=i.pathIndexes,l=0;l<h.length;l+=3){var d=2*h[l],c=2*h[l+1],u=2*h[l+2],p=o[d+0]-r,g=o[d+1]-n,v=o[c+0]-r,f=o[c+1]-n,m=o[u+0]-r,y=o[u+1]-n,b=e.getX(p,g),x=e.getY(p,g),C=e.getX(v,f),k=e.getY(v,f),w=e.getX(m,y),S=e.getY(m,y);t.batchTri(i,b,x,C,k,w,S,0,0,1,1,a,a,a,2)}},ft=Phaser.Renderer.WebGL.Utils,mt=function(t,e,i,s,r){var n=t.strokeTint,a=ft.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);n.TL=a,n.TR=a,n.BL=a,n.BR=a;var o=e.pathData,h=o.length-1,l=e.lineWidth,d=l/2,c=o[0]-s,u=o[1]-r;e.closePath||(h-=2);for(var p=2;p<h;p+=2){var g=o[p]-s,v=o[p+1]-r;t.batchLine(c,u,g,v,d,d,l,p-2,!!e.closePath&&p===h-1),c=g,u=v}};const yt=Phaser.GameObjects.GetCalcMatrix;var bt=function(t,e,i,s){var r=i||e.fillColor,n=s||e.fillAlpha,a=(16711680&r)>>>16,o=(65280&r)>>>8,h=255&r;t.fillStyle="rgba("+a+","+o+","+h+","+n+")"},xt=function(t,e,i,s){var r=i||e.strokeColor,n=s||e.strokeAlpha,a=(16711680&r)>>>16,o=(65280&r)>>>8,h=255&r;t.strokeStyle="rgba("+a+","+o+","+h+","+n+")",t.lineWidth=e.lineWidth};const Ct=Phaser.Renderer.Canvas.SetTransform;var kt={renderWebGL:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.pipelines.set(e.pipeline),n=yt(e,i,s),a=r.calcMatrix.copyFrom(n.calc),o=e._displayOriginX,h=e._displayOriginY,l=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&vt(r,a,e,l,o,h),e.isStroked&&mt(r,e,l,o,h),t.pipelines.postBatch(e)},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.currentContext;if(Ct(t,r,e,i,s)){var n=e._displayOriginX,a=e._displayOriginY,o=e.pathData,h=o.length-1,l=o[0]-n,d=o[1]-a;r.beginPath(),r.moveTo(l,d),e.closePath||(h-=2);for(var c=2;c<h;c+=2){var u=o[c]-n,p=o[c+1]-a;r.lineTo(u,p)}r.closePath(),e.isFilled&&(bt(r,e),r.fill()),e.isStroked&&(xt(r,e),r.stroke()),r.restore()}}};const wt=Phaser.GameObjects.Shape;class St extends wt{get fillColor(){return this._fillColor}set fillColor(t){this._fillColor=t,this.isFilled=null!=t&&this._fillAlpha>0}get fillAlpha(){return this._fillAlpha}set fillAlpha(t){this._fillAlpha=t,this.isFilled=t>0&&null!=this._fillColor}setFillStyle(t,e){return void 0===e&&(e=1),this.fillColor=t,this.fillAlpha=e,this}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this.isStroked=null!=t&&this._strokeAlpha>0&&this._lineWidth>0}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(t){this._strokeAlpha=t,this.isStroked=t>0&&null!=this._strokeColor&&this._lineWidth>0}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.isStroked=t>0&&null!=this._strokeColor}setStrokeStyle(t,e,i){return void 0===i&&(i=1),this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this}updateData(){return this}get width(){return this.geom.width}set width(t){this.resize(t,this.height)}get height(){return this.geom.height}set height(t){this.resize(this.width,t)}setSize(t,e){var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this}resize(t,e){return this.setSize(t,e),this}}Object.assign(St.prototype,kt);const Pt=Phaser.Utils.Objects.GetValue;let Tt=class{constructor(t,e,i,s,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,i,s,r)}setTo(t,e,i,s,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setSize(t,e){return this.width=t,this.height=e,this}get minWidth(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}get minHeight(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}get width(){return this._width}set width(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth)}get height(){return this._height}set height(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight)}get radius(){var t=this.cornerRadius;return Math.max(t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y)}set radius(t){var e,i;"number"==typeof t?(e=t,i=t):(e=Pt(t,"x",0),i=Pt(t,"y",0));var s=this.cornerRadius;s.tl=Ot(Pt(t,"tl",void 0),e,i),s.tr=Ot(Pt(t,"tr",void 0),e,i),s.bl=Ot(Pt(t,"bl",void 0),e,i),s.br=Ot(Pt(t,"br",void 0),e,i)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){Mt(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){Mt(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){Mt(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){Mt(this.cornerRadius.br,t)}};var Ot=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),Et(t),t},Mt=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=Pt(e,"x",0),t.y=Pt(e,"y",0)),Et(t)},Et=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)},_t=function(t){return t.x>0&&t.y>0},Rt=function(t,e,i){var s=i.length;if(s>=2){var r=i[s-2],n=i[s-1];if(t===r&&e===n)return i}return i.push(t,e),i};const Lt=Phaser.Math.DegToRad;var Bt=function(t,e,i,s,r,n,a,o,h){a&&n>r?n-=360:!a&&n<r&&(n+=360);var l=Lt(n-r)/o;r=Lt(r);for(var d=0;d<=o;d++){var c=r+l*d,u=t+i*Math.cos(c),p=e+s*Math.sin(c);Rt(u,p,h)}return h};const It=Phaser.Utils.Objects.IsPlainObject,Dt=Phaser.Utils.Objects.GetValue,At=Phaser.Geom.Polygon.Earcut;let jt=class extends St{constructor(t,e,i,s,r,n,a,o){var h,l,d,c;if(It(e)){var u=e;e=u.x,i=u.y,s=u.width,r=u.height,n=u.radius,a=u.color,o=u.alpha,h=u.strokeColor,l=u.strokeAlpha,d=u.strokeWidth,c=u.shape}void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s),void 0===n&&(n=0),void 0===c&&(c=0);var p=new Tt;if(super(t,"rexRoundRectangleShape",p),this.setShapeType(c),0===this.shapeType){var g=Dt(n,"radius",n);p.setTo(0,0,s,r,g)}else g={x:s/2,y:r/2},p.setTo(0,0,s,r,g);this.setIteration(Dt(n,"iteration",void 0)),this.setPosition(e,i),this.setFillStyle(a,o),void 0===d&&(d=2),this.setStrokeStyle(d,h,l),this.updateDisplayOrigin(),this.dirty=!0}updateData(){var t=this.geom,e=this.pathData;e.length=0;var i,s=t.width,r=t.height,n=t.cornerRadius,a=this.iteration+1;if(i=n.tl,_t(i))if(i.convex){var o=i.x,h=i.y;Bt(o,h,i.x,i.y,180,270,!1,a,e)}else Bt(o=0,h=0,i.x,i.y,90,0,!0,a,e);else Rt(0,0,e);return i=n.tr,_t(i)?i.convex?(o=s-i.x,h=i.y,Bt(o,h,i.x,i.y,270,360,!1,a,e)):Bt(o=s,h=0,i.x,i.y,180,90,!0,a,e):Rt(s,0,e),i=n.br,_t(i)?i.convex?(o=s-i.x,h=r-i.y,Bt(o,h,i.x,i.y,0,90,!1,a,e)):Bt(o=s,h=r,i.x,i.y,270,180,!0,a,e):Rt(s,r,e),i=n.bl,_t(i)?i.convex?(o=i.x,h=r-i.y,Bt(o,h,i.x,i.y,90,180,!1,a,e)):Bt(o=0,h=r,i.x,i.y,360,270,!0,a,e):Rt(0,r,e),e.push(e[0],e[1]),this.pathIndexes=At(e),this}setShapeType(t){return"string"==typeof t&&(t=zt[t]),this.shapeType=t,this}setSize(t,e){return void 0===e&&(e=t),this.geom.width===t&&this.geom.height===e||(this.geom.setSize(t,e),1===this.shapeType&&this.setRadius({x:t/2,y:e/2}),this.updateDisplayOrigin(),this.dirty=!0,super.setSize(t,e)),this}get radius(){return this.geom.radius}set radius(t){this.geom.setRadius(t),this.updateDisplayOrigin(),this.dirty=!0}get radiusTL(){return this.geom.radiusTL}set radiusTL(t){this.geom.radiusTL=t,this.dirty=!0}get radiusTR(){return this.geom.radiusTR}set radiusTR(t){this.geom.radiusTR=t,this.dirty=!0}get radiusBL(){return this.geom.radiusBL}set radiusBL(t){this.geom.radiusBL=t,this.dirty=!0}get radiusBR(){return this.geom.radiusBR}set radiusBR(t){this.geom.radiusBR=t,this.dirty=!0}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setRadiusTL(t){return void 0===t&&(t=0),this.radiusTL=t,this}setRadiusTR(t){return void 0===t&&(t=0),this.radiusTR=t,this}setRadiusBL(t){return void 0===t&&(t=0),this.radiusBL=t,this}setRadiusBR(t){return void 0===t&&(t=0),this.radiusBR=t,this}get cornerRadius(){return this.geom.cornerRadius}set cornerRadius(t){this.radius=t}setCornerRadius(t){return this.setRadius(t)}get iteration(){return this._iteration}set iteration(t){void 0!==this._iteration?this._iteration!==t&&(this._iteration=t,this.dirty=!0):this._iteration=t}setIteration(t){return void 0===t&&(t=6),this.iteration=t,this}};const zt={rectangle:0,circle:1};t.register("roundRectangle",(function(t,e,i,s,r,n,a){var o=new jt(this.scene,t,e,i,s,r,n,a);return this.scene.add.existing(o),o})),P(window,"RexPlugins.UI.RoundRectangle",jt);const Ft=Phaser.Renderer.WebGL.Utils;var Yt={renderWebGL:function(t,e,i,s){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,n=r.width,a=r.height,o=Ft.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(r.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,r.glTexture,n,a,e.x,e.y,n/e.resolution,a/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,n,a,o(e.tintTopLeft,i.alpha*e._alphaTL),o(e.tintTopRight,i.alpha*e._alphaTR),o(e.tintBottomLeft,i.alpha*e._alphaBL),o(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,s,!1,l),t.pipelines.postBatch(e)}},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const Xt=Phaser.Display.Color;var Wt={clear(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame(t,e,i,s,r,n,a,o,h,l){var d=this.scene.sys.textures.getFrame(t,e);if(!d)return this;var c=d.cutWidth,u=d.cutHeight;void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=c),void 0===n&&(n=u),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=c),void 0===l&&(l=u);var p=d.cutX+a,g=d.cutY+o;return this.context.drawImage(d.source.image,p,g,h,l,i,s,r,n),this.dirty=!0,this},getDataURL(t,e){return this.canvas.toDataURL(t,e)},getPixel(t,e,i){void 0===i&&(i=new Xt);var s=this.context.getImageData(t,e,1,1);return i.setTo(s.data[0],s.data[1],s.data[2],s.data[3]),i},setPixel(t,e,i,s,r,n){if("number"!=typeof i){var a=i;i=a.red,s=a.green,r=a.blue,n=a.alpha}void 0===n&&(n=0!==i||0!==s||0!==r?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=s,o.data[2]=r,o.data[3]=n,this.context.putImageData(o,t,e),this.dirty=!0,this}},Vt=function(t,e,i,s,r,n,a){var o,h=t.sys.textures,l=t.renderer;void 0===s&&(s=0),void 0===r&&(r=0),void 0===n&&(n=e.width),void 0===a&&(a=e.height);var d=(o=h.exists(i)?h.get(i):h.createCanvas(i,n,a)).getSourceImage();d.width!==n&&(d.width=n),d.height!==a&&(d.height=a);var c=d.getContext("2d",{willReadFrequently:!0});c.clearRect(0,0,n,a),c.drawImage(e,s,r,n,a),l.gl&&o&&l.canvasToTexture(d,o.source[0].glTexture,!0,0)},Gt={updateTexture(t,e){if(t){var i=this.resolution;1!==i&&(this.context.save(),this.context.scale(i,i)),e?t.call(e,this.canvas,this.context):t(this.canvas,this.context),1!==i&&this.context.restore()}this.canvas.width===this.frame.width&&this.canvas.height===this.frame.height||this.frame.setSize(this.canvas.width,this.canvas.height),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(this.canvas,this.frame.source.glTexture,!0),this.frame.glTexture.spectorMetadata={textureKey:"Canvas Game Object"}),this.dirty=!1;var s=this.input;return s&&!s.customHitArea&&(s.hitArea.width=this.width,s.hitArea.height=this.height),this},generateTexture(t,e,i,s,r){var n=this.canvas;return void 0===s?s=n.width:s*=this.resolution,void 0===r?r=n.height:r*=this.resolution,Vt(this.scene,n,t,e,i,s,r),this},loadTexture(t,e){var i=this.scene.sys.textures.getFrame(t,e);return i?(this.width!==i.cutWidth||this.height!==i.cutHeight?this.setSize(i.cutWidth,i.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}};F();const Ht=Phaser.Display.Canvas.CanvasPool,Ut=Phaser.GameObjects.GameObject,Nt=Phaser.Utils.String.UUID;let $t=class extends Ut{constructor(t,e,i,s,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),void 0===n&&(n=1),super(t,"rexCanvas"),this.renderer=t.sys.game.renderer,this._width=s,this._height=r,this.resolution=n,s=Math.max(Math.ceil(s*this.resolution),1),r=Math.max(Math.ceil(r*this.resolution),1),this.canvas=Ht.create(this,s,r),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.dirty=!1,this.setPosition(e,i),this.setOrigin(.5,.5),this.initPipeline(),this.initPostPipeline(!0),this._crop=this.resetCropObject(),this._textureKey=Nt(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.frame=this.texture.get(),this.frame.source.resolution=this.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),this.dirty=!0}preDestroy(){Ht.remove(this.canvas),this.canvas=null,this.context=null;var t=this.texture;t&&t.destroy()}setResolution(t){if(this.resolution===t)return this;this.resolution=t;var e=Math.max(Math.ceil(this.width*t),1),i=Math.max(Math.ceil(this.height*t),1);return this.canvas.width=e,this.canvas.height=i,this.frame.source.resolution=t,this.dirty=!0,this}get width(){return this._width}set width(t){this.setSize(t,this._height)}get height(){return this._height}set height(t){this.setSize(this._width,t)}setCanvasSize(t,e){return this._width===t&&this._height===e||(this._width=t,this._height=e,this.updateDisplayOrigin(),t=Math.max(Math.ceil(t*this.resolution),1),e=Math.max(Math.ceil(e*this.resolution),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.dirty=!0),this}setSize(t,e){return this.setCanvasSize(t,e),this}get displayWidth(){return this.scaleX*this._width}set displayWidth(t){this.scaleX=t/this._width}get displayHeight(){return this.scaleY*this._height}set displayHeight(t){this.scaleY=t/this._height}setDisplaySize(t,e){return this.displayWidth=t,this.displayHeight=e,this}getCanvas(t){return t||(this.dirty=!0),this.canvas}getContext(t){return t||(this.dirty=!0),this.context}needRedraw(){return this.dirty=!0,this}resize(t,e){return this.setSize(t,e),this}};const Kt=Phaser.GameObjects.Components;Phaser.Class.mixin($t,[Kt.Alpha,Kt.BlendMode,Kt.Crop,Kt.Depth,Kt.Flip,Kt.GetBounds,Kt.Mask,Kt.Origin,Kt.Pipeline,Kt.PostPipeline,Kt.ScrollFactor,Kt.Tint,Kt.Transform,Kt.Visible,Yt,Wt,Gt]);const Jt=Phaser.Utils.String.Pad;var qt=function(t,e,i){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${Jt(Math.floor(t).toString(16),6,"0",1)}`;case"function":return t(e,i);case"object":return t.hasOwnProperty("r")?t.hasOwnProperty("a")?`rgba(${t.r},${t.g},${t.b},${t.a})`:`rgb(${t.r},${t.g},${t.b})`:t.hasOwnProperty("h")?t.hasOwnProperty("a")?`hsla(${t.h},${t.s},${t.l},${t.a})`:`hsl(${t.h},${t.s},${t.l})`:t}};const Zt=Phaser.Math.DegToRad;var Qt=function(t,e,i,s,r,n,a){var o,h,l,d,c,u=new Tt(e,i,s,r,n),p=u.minWidth,g=u.minHeight,v=s>=p?1:s/p,f=r>=g?1:r/g,m=u.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=m.tl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,l,h,l,180,270,!1,a):ie(t,0,0,h,l,90,0,!0,a),d=0,c=l):(t.lineTo(0,0),d=0,c=0),o=m.tr,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,l,h,l,270,360,!1,a):ie(t,s,0,h,l,180,90,!0,a)):t.lineTo(s,0),o=m.br,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,r-l,h,l,0,90,!1,a):ie(t,s,r,h,l,270,180,!0,a)):t.lineTo(s,r),o=m.bl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,r-l,h,l,90,180,!1,a):ie(t,0,r,h,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(d,c),t.closePath(),t.restore()},te=function(t){return!t.hasOwnProperty("convex")||t.convex},ee=function(t){return t.x>0&&t.y>0},ie=function(t,e,i,s,r,n,a,o,h){if(o&&a>n?a-=360:!o&&a<n&&(a+=360),n=Zt(n),a=Zt(a),null==h)t.ellipse(e,i,s,r,0,n,a,o);else for(var l,d,c,u=(a-n)/(h+=1),p=0;p<=h;p++)c=n+u*p,l=e+s*Math.cos(c),d=i+r*Math.sin(c),t.lineTo(l,d)},se=function(t,e,i,s,r,n,a,o){if(null!=e||null!=i){var h=t.canvas.width,l=t.canvas.height;null==i&&(s=0);var d=s/2;h=Math.max(1,h-s),l=Math.max(1,l-s),function(t,e,i,s,r,n,a,o,h,l,d,c,u){var p;(Qt(e,i,s,r,n,a,u),null!=o)&&(null!=d&&((p=c?e.createLinearGradient(0,0,r,0):e.createLinearGradient(0,0,0,n)).addColorStop(0,o),p.addColorStop(1,d),o=p),e.fillStyle=o,e.fill());null!=h&&l>0&&(e.strokeStyle=h,e.lineWidth=l,e.stroke())}(t.canvas,t.context,d,d,h,l,r,e,i,s,n,a,o)}},re=function(){se(this,this.fillStyle,this.strokeStyle,this.lineWidth,this.radius,this.fillColor2,this.isHorizontalGradient,this.iteration)};const ne=Phaser.Utils.Objects.GetValue;let ae=class extends $t{constructor(t,e,i,s,r,n,a,o,h,l,d,c){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s),void 0===n&&(n=0),void 0===c&&(c=1),super(t,e,i,s,r,c),this.type="rexRoundRectangleCanvas";var u=ne(n,"radius",n),p=ne(n,"iteration",void 0);this.setRadius(u),this.setIteration(p),this.setFillStyle(a,l,d),this.setStrokeStyle(o,h)}get radius(){return this._radius}set radius(t){this.dirty|=this._radius!=t,this._radius=t}setRadius(t){return this.radius=t,this}get iteration(){return this._iteration}set iteration(t){this.dirty|=this._iteration!=t,this._iteration=t}setIteration(t){return this.iteration=t,this}get fillStyle(){return this._fillStyle}set fillStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillStyle!=t,this._fillStyle=t}get fillColor2(){return this._fillColor2}set fillColor2(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillColor2!=t,this._fillColor2=t}get isHorizontalGradient(){return this._isHorizontalGradient}set isHorizontalGradient(t){this.dirty|=this._isHorizontalGradient!=t,this._isHorizontalGradient=t}setFillStyle(t,e,i){return void 0===i&&(i=!0),this.fillStyle=t,this.fillColor2=e,this.isHorizontalGradient=i,this}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._strokeStyle!=t,this._strokeStyle=t}get lineWidth(){return this._lineWidth}set lineWidth(t){this.dirty|=this._lineWidth!=t,this._lineWidth=t}setStrokeStyle(t,e){return this.strokeStyle=t,this.lineWidth=e,this}updateTexture(){return super.updateTexture((function(){this.clear(),re.call(this)}),this),this}};t.register("roundRectangleCanvas",(function(t,e,i,s,r,n,a,o,h,l){var d=new ae(this.scene,t,e,i,s,r,n,a,o,h,l);return this.scene.add.existing(d),d})),P(window,"RexPlugins.UI.RoundRectangleCanvas",ae);var oe=function(t,e){if(!t)return!1;if(t.hasOwnProperty(e))return!0;for(;t;){if(Object.getOwnPropertyDescriptor(t,e))return!0;t=t.__proto__}return!1},he=function(t,e,i){e&&!oe(t,`${e}X`)&&(Object.defineProperty(t,`${e}X`,{get:function(){return i.x},set:function(e){i.x=e,t.dirty=!0}}),Object.defineProperty(t,`${e}Y`,{get:function(){return i.y},set:function(e){i.y=e,t.dirty=!0}}),Object.defineProperty(t,`${e}T`,{get:function(){return i.t},set:function(e){i.t=e,t.dirty=!0}}))},le={setTLPosition(t,e){return this.geom.setTLPosition(t,e),this.dirty=!0,this},setTRPosition(t,e){return this.geom.setTRPosition(t,e),this.dirty=!0,this},setBLPosition(t,e){return this.geom.setBLPosition(t,e),this.dirty=!0,this},setBRPosition(t,e){return this.geom.setBRPosition(t,e),this.dirty=!0,this},resetCornerPosition(){return this.geom.resetCornerPosition(),this.dirty=!0,this},insertTopSidePoint(t,e,i,s){var r=this.geom.topSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a<o;a++)n=r[a],this.geom.insertTopSidePoint(n.t,n.x,n.y),he(this,n.key,r[r.length-1]);else this.geom.insertTopSidePoint(t,e,i),he(this,s,r[r.length-1]);return this.dirty=!0,this},insertRightSidePoint(t,e,i,s){var r=this.geom.rightSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a<o;a++)n=r[a],this.geom.insertRightSidePoint(n.t,n.x,n.y),he(this,n.key,r[r.length-1]);else this.geom.insertRightSidePoint(t,e,i),he(this,s,r[r.length-1]);return this.dirty=!0,this},insertBottomSidePoint(t,e,i,s){var r=this.geom.bottomSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a<o;a++)n=r[a],this.geom.insertBottomSidePoint(n.t,n.x,n.y),he(this,n.key,r[r.length-1]);else this.geom.insertBottomSidePoint(t,e,i),he(this,s,r[r.length-1]);return this.dirty=!0,this},insertLeftSidePoint(t,e,i,s){var r=this.geom.leftSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a<o;a++)n=r[a],this.geom.insertLeftSidePoint(n.t,n.x,n.y),he(this,n.key,r[r.length-1]);else this.geom.insertLeftSidePoint(t,e,i),he(this,s,r[r.length-1]);return this.dirty=!0,this},clearTopSidePoints(){return this.geom.clearTopSidePoints(),this.dirty=!0,this},clearRightSidePoints(){return this.geom.clearRightSidePoints(),this.dirty=!0,this},clearBottomSidePoints(){return this.geom.clearBottomSidePoints(),this.dirty=!0,this},clearLeftSidePoints(){return this.geom.clearLeftSidePoints(),this.dirty=!0,this},clearAllSidesPoints(){return this.geom.clearAllSidesPoints(),this.dirty=!0,this}};class de{constructor(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),this.setTo(t,e,i,s),this.tlx=0,this.tly=0,this.trx=0,this.try=0,this.blx=0,this.bly=0,this.brx=0,this.bry=0,this.topSidePoints=[],this.rightSidePoints=[],this.bottomSidePoints=[],this.leftSidePoints=[]}setTo(t,e,i,s){return this.setPosition(t,e),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setSize(t,e){return this.width=t,this.height=e,this}setTLPosition(t,e){return this.tlx=t,this.tly=e,this}setTRPosition(t,e){return this.trx=t,this.try=e,this}setBLPosition(t,e){return this.blx=t,this.bly=e,this}setBRPosition(t,e){return this.brx=t,this.bry=e,this}resetCornerPosition(){return this.setTLPosition(0,0).setTRPosition(0,0).setBLPosition(0,0).setBRPosition(0,0),this}insertTopSidePoint(t,e,i){return ce(this.topSidePoints,t,e,i),this}insertRightSidePoint(t,e,i){return ce(this.rightSidePoints,t,e,i),this}insertBottomSidePoint(t,e,i){return ce(this.bottomSidePoints,t,e,i),this}insertLeftSidePoint(t,e,i){return ce(this.leftSidePoints,t,e,i),this}clearTopSidePoints(){return this.topSidePoints.length=0,this}clearRightSidePoints(){return this.rightSidePoints.length=0,this}clearBottomSidePoints(){return this.bottomSidePoints.length=0,this}clearLeftSidePoints(){return this.leftSidePoints.length=0,this}clearAllSidesPoints(){return this.clearTopSidePoints().clearRightSidePoints().clearBottomSidePoints().clearLeftSidePoints(),this}}var ce=function(t,e,i,s){if("number"!=typeof e){var r=e;e=r.t,i=r.x,s=r.y}t.push({t:e,x:i,y:s})};const ue=Phaser.Utils.Objects.IsPlainObject,pe=Phaser.Utils.Objects.GetValue,ge=Phaser.Math.Linear,ve=Phaser.Geom.Polygon.Earcut;class fe extends St{constructor(t,e,i,s,r,n,a){var o,h,l;if(ue(e)){var d=e;e=d.x,i=d.y,s=d.width,r=d.height,n=d.color,a=d.alpha,o=d.strokeColor,h=d.strokeAlpha,l=d.strokeWidth}void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s);var c=new de;super(t,"rexQuadShape",c),c.setTo(0,0,s,r),this.setPosition(e,i),this.setFillStyle(n,a),void 0!==o&&void 0===l&&(l=2),this.setStrokeStyle(l,o,h),this.setTLPosition(pe(d,"tlx",0),pe(d,"tly",0)).setTRPosition(pe(d,"trx",0),pe(d,"try",0)).setBLPosition(pe(d,"blx",0),pe(d,"bly",0)).setBRPosition(pe(d,"brx",0),pe(d,"bry",0));var u=pe(d,"leftSidePoints");u&&this.insertLeftSidePoint(u);var p=pe(d,"topSidePoints");p&&this.insertTopSidePoint(p);var g=pe(d,"rightSidePoints");g&&this.insertRightSidePoint(g);var v=pe(d,"bottomSidePoints");v&&this.insertBottomSidePoint(v),this.updateDisplayOrigin(),this.dirty=!0}updateData(){var t=this.geom,e=this.pathData;e.length=0;var i=t.width,s=t.height,r=0+t.tlx,n=0+t.tly,a=i+t.trx,o=0+t.try,h=i+t.brx,l=s+t.bry,d=0+t.blx,c=s+t.bly,u=t.topSidePoints,p=t.rightSidePoints,g=t.bottomSidePoints,v=t.leftSidePoints;Rt(r,n,e),me(u);for(var f=0,m=u.length;f<m;f++){var y=u[f],b=ge(r,a,y.t)+y.x,x=ge(n,o,y.t)+y.y;Rt(b,x,e)}for(Rt(a,o,e),me(p),f=0,m=p.length;f<m;f++)y=p[f],b=ge(a,h,y.t)+y.x,x=ge(o,l,y.t)+y.y,Rt(b,x,e);for(Rt(h,l,e),me(g),f=g.length-1;f>=0;f--)y=g[f],b=ge(d,h,y.t)+y.x,x=ge(c,l,y.t)+y.y,Rt(b,x,e);for(Rt(d,c,e),me(v),f=v.length-1;f>=0;f--)y=v[f],b=ge(r,d,y.t)+y.x,x=ge(n,c,y.t)+y.y,Rt(b,x,e);return e.push(e[0],e[1]),this.pathIndexes=ve(e),this}get tlx(){return this.geom.tlx}set tlx(t){this.geom.tlx=t,this.dirty=!0}get tly(){return this.geom.tly}set tly(t){this.geom.tly=t,this.dirty=!0}get trx(){return this.geom.trx}set trx(t){this.geom.trx=t,this.dirty=!0}get try(){return this.geom.try}set try(t){this.geom.try=t,this.dirty=!0}get blx(){return this.geom.blx}set blx(t){this.geom.blx=t,this.dirty=!0}get bly(){return this.geom.bly}set bly(t){this.geom.bly=t,this.dirty=!0}get brx(){return this.geom.brx}set brx(t){this.geom.brx=t,this.dirty=!0}get bry(){return this.geom.bry}set bry(t){this.geom.bry=t,this.dirty=!0}get leftSidePoints(){return this.geom.leftSidePoints}get topSidePoints(){return this.geom.topSidePoints}get bottomSidePoints(){return this.geom.bottomSidePoints}get rightSidePoints(){return this.geom.rightSidePoints}}var me=function(t){t.length<=1||t.sort((function(t,e){return t.t-e.t}))};Object.assign(fe.prototype,le),t.register("QuadShape",(function(t,e,i,s,r,n){var a=new fe(this.scene,t,e,i,s,r,n);return this.scene.add.existing(a),a})),P(window,"RexPlugins.UI.QuadShape",fe);var ye=Phaser.Renderer.WebGL.Utils,be={renderWebGL:function(t,e,i,s){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,n=r.width,a=r.height,o=ye.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(r.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,r.glTexture,n,a,e.x,e.y,n/e.style.resolution,a/e.style.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,n,a,o(e.tintTopLeft,i.alpha*e._alphaTL),o(e.tintTopRight,i.alpha*e._alphaTR),o(e.tintBottomLeft,i.alpha*e._alphaBL),o(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,s,!1,l),t.pipelines.postBatch(e)}},renderCanvas:function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const xe=Phaser.Display.Canvas.CanvasPool;F();const Ce=Phaser.GameObjects.GameObject;class ke extends Ce{setStyle(t){return this.style.setStyle(t)}setFont(t){return this.style.setFont(t)}setFontFamily(t){return this.style.setFontFamily(t)}setFontSize(t){return this.style.setFontSize(t)}setFontStyle(t){return this.style.setFontStyle(t)}setTestString(t){return this.style.setTestString(t)}setFixedSize(t,e){return this.style.setFixedSize(t,e)}setBackgroundColor(t,e,i){return this.style.setBackgroundColor(t,e,i)}setBackgroundStrokeColor(t,e){return this.style.setBackgroundStrokeColor(t,e)}setBackgroundCornerRadius(t,e){return this.style.setBackgroundCornerRadius(t,e)}setFill(t){return this.style.setFill(t)}setColor(t){return this.style.setColor(t)}setStroke(t,e){return this.style.setStroke(t,e)}setShadow(t,e,i,s,r,n){return this.style.setShadow(t,e,i,s,r,n)}setShadowOffset(t,e){return this.style.setShadowOffset(t,e)}setShadowColor(t){return this.style.setShadowColor(t)}setShadowBlur(t){return this.style.setShadowBlur(t)}setShadowStroke(t){return this.style.setShadowStroke(t)}setShadowFill(t){return this.style.setShadowFill(t)}setUnderline(t,e,i){return this.style.setUnderline(t,e,i)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,i){return this.style.setStrikethrough(t,e,i)}setStrikethroughColor(t){return this.style.setStrikethroughColor(t)}setStrikethroughThickness(t){return this.style.setStrikethroughThickness(t)}setStrikethroughOffset(t){return this.style.setStrikethroughOffset(t)}setWrapMode(t){return this.style.setWrapMode(t)}setWrapWidth(t){return this.style.setWrapWidth(t)}setWordWrapWidth(t){return this.style.setWrapWidth(t)}setAlign(t){return this.style.setHAlign(t)}setHAlign(t){return this.style.setHAlign(t)}setVAlign(t){return this.style.setVAlign(t)}get lineSpacing(){return this.style.lineSpacing}set lineSpacing(t){this.style.lineSpacing=t}setLineSpacing(t){return this.style.lineSpacing=t,this.updateText(!0),this}setXOffset(t){return this.style.setXOffset(t)}setMaxLines(t){return this.style.setMaxLines(t)}setResolution(t){return this.style.setResolution(t)}getTextMetrics(){return this.style.getTextMetrics()}setTextMetrics(t,e){return this.style.setTextMetrics(t,e)}measureTextMargins(t,e){return function(t,e,i){void 0===i&&(i={});var s=xe.create(this),r=s.getContext("2d",{willReadFrequently:!0});t.syncFont(s,r);var n=r.measureText(e),a=Math.ceil(n.width*t.baselineX),o=a,h=2*o;if(o=o*t.baselineY|0,s.width=a,s.height=h,r.fillStyle="#f00",r.fillRect(0,0,a,h),r.font=t._font,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(t.testString,0,o),i.left=0,0===a||0===h||!r.getImageData(0,0,a,h))return xe.remove(s),i;for(var l=r.getImageData(0,0,a,h).data,d=!1,c=0;c<a;c++){for(var u=0;u<h;u++)if(255!==l[4*(u*a+c)]){i.left=c,d=!0;break}if(d)break}return xe.remove(s),i}(this.style,t,e)}}const we=Phaser.GameObjects.Components;Phaser.Class.mixin(ke,[we.Alpha,we.BlendMode,we.ComputedSize,we.Crop,we.Depth,we.Fli