phaser3-rex-plugins
Version:
7 lines • 54.2 kB
JavaScript
var t,e;t=void 0,e=function(){var t=Phaser.Renderer.WebGL.Utils,e={renderWebGL:function(e,s,r,i){if(0!==s.width&&0!==s.height){r.addToRenderList(s);var n=s.frame,a=n.width,h=n.height,o=t.getTintAppendFloatAlpha,l=e.pipelines.set(s.pipeline,s),u=l.setTexture2D(n.glTexture,s);e.pipelines.preBatch(s),l.batchTexture(s,n.glTexture,a,h,s.x,s.y,a/s.style.resolution,h/s.style.resolution,s.scaleX,s.scaleY,s.rotation,s.flipX,s.flipY,s.scrollFactorX,s.scrollFactorY,s.displayOriginX,s.displayOriginY,0,0,a,h,o(s.tintTopLeft,r.alpha*s._alphaTL),o(s.tintTopRight,r.alpha*s._alphaTR),o(s.tintBottomLeft,r.alpha*s._alphaBL),o(s.tintBottomRight,r.alpha*s._alphaBR),s.tintFill,0,0,r,i,!1,u),e.pipelines.postBatch(s)}},renderCanvas:function(t,e,s,r){0!==e.width&&0!==e.height&&(s.addToRenderList(e),t.batchSprite(e,e.frame,s,r))}};const s=Phaser.Display.Canvas.CanvasPool;var r=!1;!function(t){if(!r){void 0===t&&(t=60);var e=Phaser.VERSION.split("."),s=parseInt(e[0]);if(3===s){var i=parseInt(e[1]);i<t&&console.error(`Minimum supported version : ${s}.${i}`)}else console.error(`Can't supported version : ${s}`);r=!0}}();const i=Phaser.GameObjects.GameObject;class n extends i{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,s){return this.style.setBackgroundColor(t,e,s)}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,s,r,i,n){return this.style.setShadow(t,e,s,r,i,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,s){return this.style.setUnderline(t,e,s)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,s){return this.style.setStrikethrough(t,e,s)}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}get letterSpacing(){return this.style.letterSpacing}set letterSpacing(t){this.style.letterSpacing=t}setLetterSpacing(t){return this.style.letterSpacing=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,r){void 0===r&&(r={});var i=s.create(this),n=i.getContext("2d",{willReadFrequently:!0});t.syncFont(i,n);var a=n.measureText(e),h=Math.ceil(a.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,i.width=h,i.height=l,n.fillStyle="#f00",n.fillRect(0,0,h,l),n.font=t._font,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(t.testString,0,o),r.left=0,0===h||0===l||!n.getImageData(0,0,h,l))return s.remove(i),r;for(var u=n.getImageData(0,0,h,l).data,d=!1,c=0;c<h;c++){for(var g=0;g<l;g++)if(255!==u[4*(g*h+c)]){r.left=c,d=!0;break}if(d)break}return s.remove(i),r}(this.style,t,e)}}const a=Phaser.GameObjects.Components;Phaser.Class.mixin(n,[a.Alpha,a.BlendMode,a.ComputedSize,a.Crop,a.Depth,a.Flip,a.GetBounds,a.Mask,a.Origin,a.Pipeline,a.PostPipeline,a.ScrollFactor,a.Tint,a.Transform,a.Visible,e]);const h=Phaser.Utils.String.Pad;var o=function(t,e,s){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${h(Math.floor(t).toString(16),6,"0",1)}`;case"function":return t(e,s);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}},l={backgroundColor:["backgroundColor",null,o],backgroundColor2:["backgroundColor2",null,o],backgroundHorizontalGradient:["backgroundHorizontalGradient",!0,null],backgroundStrokeColor:["backgroundStrokeColor",null,o],backgroundStrokeLineWidth:["backgroundStrokeLineWidth",2,null],backgroundCornerRadius:["backgroundCornerRadius",0,null],backgroundCornerIteration:["backgroundCornerIteration",null,null],fontFamily:["fontFamily","Courier",null],fontSize:["fontSize","16px",null],fontStyle:["fontStyle","",null],color:["color","#fff",o],stroke:["stroke","#fff",o],strokeThickness:["strokeThickness",0,null],shadowOffsetX:["shadow.offsetX",0,null],shadowOffsetY:["shadow.offsetY",0,null],shadowColor:["shadow.color","#000",o],shadowBlur:["shadow.blur",0,null],shadowStroke:["shadow.stroke",!1,null],shadowFill:["shadow.fill",!1,null],underlineColor:["underline.color","#000",o],underlineThickness:["underline.thickness",0,null],underlineOffset:["underline.offset",0,null],strikethroughColor:["strikethrough.color","#000",o],strikethroughThickness:["strikethrough.thickness",0,null],strikethroughOffset:["strikethrough.offset",0,null],halign:["halign","left",null],valign:["valign","top",null],maxLines:["maxLines",0,null],fixedWidth:["fixedWidth",0,null],fixedHeight:["fixedHeight",0,null],resolution:["resolution",0,null],lineSpacing:["lineSpacing",0,null],letterSpacing:["letterSpacing",0,null],xOffset:["xOffset",0,null],fixedLineHeightMode:["fixedLineHeightMode",!0,null],rtl:["rtl",!1,null],testString:["testString","|MÉqgy",null],baselineX:["baselineX",1.2,null],baselineY:["baselineY",1.4,null],wrapMode:["wrap.mode",0,null],wrapWidth:["wrap.width",0,null],wrapCallback:["wrap.callback",null],wrapCallbackScope:["wrap.callbackScope",null]};
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
const u=Phaser.Display.Canvas.CanvasPool;var d=function(t){var e=u.create(this),s=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,s);var r=s.measureText(t.testString);if("actualBoundingBoxAscent"in r){var i=r.actualBoundingBoxAscent,n=r.actualBoundingBoxDescent,a={ascent:i,descent:n,fontSize:i+n};return u.remove(e),a}var h=Math.ceil(r.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,e.width=h,e.height=l,s.fillStyle="#f00",s.fillRect(0,0,h,l),s.font=t._font,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(t.testString,0,o),a={ascent:0,descent:0,fontSize:0},!s.getImageData(0,0,h,l))return a.ascent=o,a.descent=o+6,a.fontSize=a.ascent+a.descent,u.remove(e),a;var d,c,g=s.getImageData(0,0,h,l).data,p=g.length,f=4*h,v=0,y=!1;for(d=0;d<o;d++){for(c=0;c<f;c+=4)if(255!==g[v+c]){y=!0;break}if(y)break;v+=f}for(a.ascent=o-d,v=p-f,y=!1,d=l;d>o;d--){for(c=0;c<f;c+=4)if(255!==g[v+c]){y=!0;break}if(y)break;v-=f}return a.descent=d-o,a.fontSize=a.ascent+a.descent,u.remove(e),a},c=0,g=1,p=2,f=0,v=1,y=2,x=/(?:\r\n|\r|\n)/;const w={none:f,word:v,char:y,character:y,mix:3},m=Phaser.Utils.Objects.GetAdvancedValue,S=Phaser.Utils.Objects.GetValue;class T{constructor(t,e,s){this.parent=t,void 0===s&&(s=l),this.propertyMap=s,this.backgroundColor,this.backgroundColor2,this.backgroundHorizontalGradient,this.backgroundStrokeColor,this.backgroundStrokeLineWidth,this.backgroundCornerRadius,this.backgroundCornerIteration,this.fontFamily,this.fontSize,this.fontStyle,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.underlineColor,this.underlineThickness,this.underlineOffset,this.strikethroughColor,this.strikethroughThickness,this.strikethroughOffset,this.halign,this.valign,this.maxLines,this.fixedWidth,this.fixedHeight,this.resolution,this.xOffset,this.rtl,this.testString,this.baselineX,this.baselineY,this.wrapMode,this.wrapWidth,this.wrapCallback,this.wrapCallbackScope,this._font,this.setStyle(e,!1,!0)}get isWrapFitMode(){return this.fixedWidth>0&&this.wrapMode!==f&&0===this.wrapWidth}setStyle(t,e,s){if(void 0===e&&(e=!0),void 0===s&&(s=!1),t&&t.hasOwnProperty("wordWrap")){var r=t.wordWrap;r.hasOwnProperty("width")&&(t.wrap={mode:"word",width:r.width})}if(t&&t.hasOwnProperty("wrap")){var i=t.wrap;if(i.hasOwnProperty("mode")){var n=i.mode;"string"==typeof n&&(i.mode=w[n])}else i.hasOwnProperty("width")&&(i.mode=1)}t&&t.rtl&&s&&!t.hasOwnProperty("halign")&&(t.halign="right"),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px");var a=this.propertyMap;for(var h in a){var l=a[h],u=l[0],c=s?l[1]:this[h],g=l[2];if("wrapCallback"===h||"wrapCallbackScope"===h)this[h]=S(t,u,c);else{var p=m(t,u,c);g&&(p=g(p)),this[h]=p}}var f=S(t,"font",null);this._font=null===f?this.fontStyle+" "+this.fontSize+" "+this.fontFamily:f;var v=S(t,"fill",null);null!==v&&(this.color=o(v));var y=S(t,"metrics",!1);return y?this.metrics={ascent:S(y,"ascent",0),descent:S(y,"descent",0),fontSize:S(y,"fontSize",0)}:!e&&this.metrics||(this.metrics=d(this)),e?this.parent.updateText():this.parent}syncFont(t,e){e.font=this._font}syncStyle(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"}syncShadow(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)}update(t){return t&&(this._font=`${this.fontStyle} ${this.fontSize} ${this.fontFamily}`.trim(),this.metrics=d(this)),this.parent.updateText(t)}buildFont(){var t=`${this.fontStyle} ${this.fontSize} ${this.fontFamily}`.trim();return t!==this._font&&(this._font=t),this}setFont(t){return"string"==typeof t?(this.fontFamily=t,this.fontSize="",this.fontStyle=""):(this.fontFamily=S(t,"fontFamily","Courier"),this.fontSize=S(t,"fontSize","16px"),this.fontStyle=S(t,"fontStyle","")),this.update(!0)}setFontFamily(t){return this.fontFamily=t,this.update(!0)}setFontStyle(t){return this.fontStyle=t,this.update(!0)}setFontSize(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize=t,this.update(!0)}setTestString(t){return this.testString=t,this.update(!0)}setFixedSize(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(this.isWrapFitMode)}setResolution(t){return this.resolution=t,this.update(!1)}setXOffset(t){return this.xOffset=t,this.update(!1)}setBackgroundColor(t,e,s){return void 0===s&&(s=!0),this.backgroundColor=o(t,this.parent.canvas,this.parent.context),this.backgroundColor2=o(e,this.parent.canvas,this.parent.context),this.backgroundHorizontalGradient=s,this.update(!1)}setBackgroundStrokeColor(t,e){return this.backgroundStrokeColor=o(t,this.parent.canvas,this.parent.context),this.backgroundStrokeLineWidth=e,this.update(!1)}setBackgroundCornerRadius(t,e){return this.backgroundCornerRadius=t,this.backgroundCornerIteration=e,this.update(!1)}setFill(t){return this.color=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setColor(t){return this.color=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setStroke(t,e){return void 0===t?this.strokeThickness=0:(void 0===e&&(e=this.strokeThickness),this.stroke=o(t,this.parent.canvas,this.parent.context),this.strokeThickness=e),this.update(!0)}setShadow(t,e,s,r,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===s&&(s="#000"),void 0===r&&(r=0),void 0===i&&(i=!1),void 0===n&&(n=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=o(s,this.parent.canvas,this.parent.context),this.shadowBlur=r,this.shadowStroke=i,this.shadowFill=n,this.update(!1)}setShadowOffset(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)}setShadowColor(t){return void 0===t&&(t="#000"),this.shadowColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setShadowBlur(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)}setShadowStroke(t){return this.shadowStroke=t,this.update(!1)}setShadowFill(t){return this.shadowFill=t,this.update(!1)}setUnderline(t,e,s){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===s&&(s=0),this.underlineColor=o(t,this.parent.canvas,this.parent.context),this.underlineThickness=e,this.underlineOffset=s,this.update(!1)}setUnderlineColor(t){return void 0===t&&(t="#000"),this.underlineColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setUnderlineThickness(t){return void 0===t&&(t=0),this.underlineThickness=t,this.update(!1)}setUnderlineOffset(t){return void 0===t&&(t=0),this.underlineOffset=t,this.update(!1)}setStrikethrough(t,e,s){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===s&&(s=0),this.strikethroughColor=o(t,this.parent.canvas,this.parent.context),this.strikethroughThickness=e,this.strikethroughOffset=s,this.update(!1)}setStrikethroughColor(t){return void 0===t&&(t="#000"),this.strikethroughColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setStrikethroughThickness(t){return void 0===t&&(t=0),this.strikethroughThickness=t,this.update(!1)}setStrikethroughOffset(t){return void 0===t&&(t=0),this.strikethroughOffset=t,this.update(!1)}setWrapMode(t){return"string"==typeof t&&(t=w[t.toLowerCase()]||0),this.wrapMode=t,this.update(!0)}setWrapWidth(t){return this.wrapWidth=t,this.update(!1)}setAlign(t,e){return void 0===t&&(t="left"),void 0===e&&(e="top"),this.halign=t,this.valign=e,this.update(!1)}setHAlign(t){return void 0===t&&(t="left"),this.halign=t,this.update(!1)}setVAlign(t){return void 0===t&&(t="top"),this.valign=t,this.update(!1)}setMaxLines(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)}getTextMetrics(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}}setTextMetrics(t,e){return this.metrics.ascent=t.ascent,this.metrics.descent=t.descent,this.metrics.fontSize=t.fontSize,e&&("string"==typeof e?(this.fontFamily=e,this.fontSize="",this.fontStyle=""):(this.fontFamily=S(e,"fontFamily",this.fontFamily),this.fontSize=S(e,"fontSize",this.fontSize),this.fontStyle=S(e,"fontStyle",this.fontStyle))),this.parent.updateText(!0)}get lineHeight(){return this.metrics.fontSize+this.parent.lineSpacing}toJSON(){var t={},e=this.propertyMap;for(var s in e)t[s]=this[s];return t.metrics=this.getTextMetrics(),t}destroy(){this.parent=void 0}}const k=Phaser.Utils.Objects.GetValue;class P{constructor(t,e,s,r,i){void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=0),void 0===r&&(r=0),void 0===i&&(i=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,s,r,i)}setTo(t,e,s,r,i){return this.setPosition(t,e),this.setRadius(i),this.setSize(s,r),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,s;"number"==typeof t?(e=t,s=t):(e=k(t,"x",0),s=k(t,"y",0));var r=this.cornerRadius;r.tl=O(k(t,"tl",void 0),e,s),r.tr=O(k(t,"tr",void 0),e,s),r.bl=O(k(t,"bl",void 0),e,s),r.br=O(k(t,"br",void 0),e,s)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){b(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){b(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){b(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){b(this.cornerRadius.br,t)}}var O=function(t,e,s){return void 0===t?t={x:e,y:s}:"number"==typeof t&&(t={x:t,y:t}),M(t),t},b=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=k(e,"x",0),t.y=k(e,"y",0)),M(t)},M=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)};const C=Phaser.Math.DegToRad;var L=function(t){return!t.hasOwnProperty("convex")||t.convex},F=function(t){return t.x>0&&t.y>0},A=function(t,e,s,r,i,n,a,h,o){if(h&&a>n?a-=360:!h&&a<n&&(a+=360),n=C(n),a=C(a),null==o)t.ellipse(e,s,r,i,0,n,a,h);else for(var l,u,d,c=(a-n)/(o+=1),g=0;g<=o;g++)d=n+c*g,l=e+r*Math.cos(d),u=s+i*Math.sin(d),t.lineTo(l,u)},R=function(t,e,s,r,i,n,a,h,o,l,u,d,c){var g;(function(t,e,s,r,i,n,a){var h,o,l,u,d,c=new P(e,s,r,i,n),g=c.minWidth,p=c.minHeight,f=r>=g?1:r/g,v=i>=p?1:i/p,y=c.cornerRadius;t.save(),t.beginPath(),t.translate(e,s),h=y.tl,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,o,l,o,l,180,270,!1,a):A(t,0,0,o,l,90,0,!0,a),u=0,d=l):(t.lineTo(0,0),u=0,d=0),h=y.tr,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,r-o,l,o,l,270,360,!1,a):A(t,r,0,o,l,180,90,!0,a)):t.lineTo(r,0),h=y.br,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,r-o,i-l,o,l,0,90,!1,a):A(t,r,i,o,l,270,180,!0,a)):t.lineTo(r,i),h=y.bl,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,o,i-l,o,l,90,180,!1,a):A(t,0,i,o,l,360,270,!0,a)):t.lineTo(0,i),t.lineTo(u,d),t.closePath(),t.restore()}(e,s,r,i,n,a,c),null!=h)&&(null!=u&&((g=d?e.createLinearGradient(0,0,i,0):e.createLinearGradient(0,0,0,n)).addColorStop(0,h),g.addColorStop(1,u),h=g),e.fillStyle=h,e.fill());null!=o&&l>0&&(e.strokeStyle=o,e.lineWidth=l,e.stroke())},W={draw(t,e,s,r){var i=this.penManager;this.hitAreaManager.clear();var n=this.context;n.save();var a=this.defaultStyle;this.clear(),function(t,e,s,r,i,n,a,h){if(null!=e||null!=s){var o=t.canvas.width,l=t.canvas.height;null==s&&(r=0);var u=r/2;o=Math.max(1,o-r),l=Math.max(1,l-r),R(t.canvas,t.context,u,u,o,l,i,e,s,r,n,a,h)}}(this,a.backgroundColor,a.backgroundStrokeColor,a.backgroundStrokeLineWidth,a.backgroundCornerRadius,a.backgroundColor2,a.backgroundHorizontalGradient,a.backgroundCornerIteration);var h=this.parent,o=h.padding,l=h.width-o.left-o.right,u=h.height-o.top-o.bottom,d=this.linesHeight,c=l>0&&u>0,g=h.style.fixedHeight>0,p=d>u,f=a.maxLines,v=f<=0&&"top"===a.valign&&c&&g&&p,y=v;y&&(n.save(),n.beginPath(),n.rect(o.left,o.top,l,u),n.clip()),t+=this.startXOffset,e+=this.startYOffset;var x,w,m,S,T,k,P=a.halign,O=a.valign,b=i.lines,M=b.length;if(v&&M>0){var C=-h.scrollY,L=C+u;m=function(t,e){for(var s=0,r=t.length-1,i=t.length;s<=r;){var n=s+r>>1;t[n].endOffset>e?(i=n,r=n-1):s=n+1}return i}(b,C),S=function(t,e){for(var s=0,r=t.length-1,i=t.length;s<=r;){var n=s+r>>1;t[n].startOffset>=e?(i=n,r=n-1):s=n+1}return i}(b,L),m<0&&(m=0),S>M&&(S=M),S<m&&(S=m)}else f>0&&M>f?(w=f,S=(m="center"===O?Math.floor((M-w)/2):"bottom"===O?M-w:0)+w):(m=0,S=M);var F=this.rtl,A=F?this.parent.width:void 0;if(v)k=e;else{var W=this.getLinesHeight(m,S);k="center"===O?Math.max((r-W)/2,0):"bottom"===O?Math.max(r-W-2,0):0,k+=e}for(var H=m;H<S;H++)if(0!==(x=i.getLineWidth(H))){var Y=b[H];if(Y){for(var z=Y.pens,I=z.length,_=P,B=0;B<I;B++){var X=z[B].prop.align;if(void 0!==X){_=X;break}}T="center"===_?(s-x)/2:"right"===_?F?0:s-x:F?s-x:0,T+=t;var $=this.getLineHeight(Y)+a.lineSpacing;for(B=0;B<I;B++)this.drawPen(z[B],T,k,A,$)}}y&&n.restore(),n.restore()},drawPen(t,e,s,r,i){e+=t.x,s+=t.y+(t.prop.y||0),void 0!==r&&(e=r-e);var n=this.canvas,a=this.context;a.save();var h=this.parser.propToContextStyle(this.defaultStyle,t.prop);if(null!==h.bgcolor&&t.width>0){var o=this.defaultStyle.metrics,l=s-o.ascent,u=o.fontSize;this.drawRectangle(e,l,t.width,u,h.bgcolor,h)}if(h.underlineThickness>0&&t.width>0){var d=s+h.underlineOffset-h.underlineThickness/2;this.drawLine(e,d,t.width,h.underlineThickness,h.underlineColor,h)}if(t.isTextPen&&(h.buildFont(),h.syncFont(n,a),h.syncStyle(n,a),this.drawText(e,s,t.text,h)),t.isImagePen&&this.drawImage(e,s,t.prop.img,t.prop.color,h),h.strikethroughThickness>0&&t.width>0&&(d=s+h.strikethroughOffset-h.strikethroughThickness/2,this.drawLine(e,d,t.width,h.strikethroughThickness,h.strikethroughColor,h)),a.restore(),t.hasAreaMarker&&t.width>0){var c,g=t.prop.area;if(g)c={key:g};else{var p=t.prop.url;c={key:`url:${p}`,url:p}}this.hitAreaManager.add(e,s-this.startYOffset,t.width,i||this.defaultStyle.lineHeight,c)}},clear(){var t=this.canvas;this.context.clearRect(0,0,t.width,t.height)},drawRectangle(t,e,s,r,i,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;a.fillStyle=i,a.fillRect(t,e,s,r)},drawLine(t,e,s,r,i,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;n.syncShadow(a,n.shadowStroke);var h=a.lineCap;a.lineCap="butt",a.strokeStyle=i,a.lineWidth=r,a.beginPath(),a.moveTo(t,e),a.lineTo(t+s,e),a.stroke(),a.lineCap=h},drawText(t,e,s,r){this.autoRound&&(t=Math.round(t),e=Math.round(e));var i=this.context,n=r.letterSpacing;if(0===n)r.stroke&&"none"!==r.stroke&&r.strokeThickness>0&&(r.syncShadow(i,r.shadowStroke),i.strokeText(s,t,e)),r.color&&"none"!==r.color&&(r.syncShadow(i,r.shadowFill),i.fillText(s,t,e));else for(var a=s.split(""),h=0,o=a.length;h<o;h++){var l=a[h];r.stroke&&"none"!==r.stroke&&r.strokeThickness>0&&(r.syncShadow(i,r.shadowStroke),i.strokeText(l,t,e)),r.color&&"none"!==r.color&&(r.syncShadow(i,r.shadowFill),i.fillText(l,t,e)),t+=i.measureText(l).width+n}},drawImage(t,e,s,r,i){e-=this.startYOffset,this.parent.imageManager.draw(s,this.context,t,e,r,this.autoRound)}};const H=Phaser.Utils.Objects.GetValue,Y=c,z=g;class I{constructor(t){this.prop={},this.resetFromJSON(t)}resetFromJSON(t){this.text=H(t,"text",""),this.x=H(t,"x",0),this.y=H(t,"y",0),this.width=H(t,"width",0),this.ascent=H(t,"ascent",0),this.descent=H(t,"descent",0);var e=H(t,"height",null);null==e&&(e=this.ascent+this.descent),this.height=e;var s=H(t,"prop",null);null===s&&(s={}),this.prop=s,this.newLineMode=H(t,"newLineMode",0),this.startIndex=H(t,"startIndex",0)}get plainText(){var t=this.text;return this.newLineMode===z&&(t+="\n"),t}get wrapText(){var t=this.text;return this.newLineMode!==Y&&(t+="\n"),t}get rawTextLength(){var t=this.text.length;return this.newLineMode===z&&(t+=1),t}get endIndex(){return this.startIndex+this.rawTextLength}get lastX(){return this.x+this.width}get isTextPen(){return""!==this.text}get isImagePen(){return!!this.prop.img}get hasAreaMarker(){return!!this.prop.area||!!this.prop.url}}class _{constructor(t){this.pens=t||[],this.maxAscent=0,this.maxDescent=0,this.lineHeight=0,this.startOffset=0,this.endOffset=0}reset(){return this.pens.length=0,this.maxAscent=0,this.maxDescent=0,this.lineHeight=0,this.startOffset=0,this.endOffset=0,this}addPen(t){return this.pens.push(t),t.ascent>this.maxAscent&&(this.maxAscent=t.ascent),t.descent>this.maxDescent&&(this.maxDescent=t.descent),this}get length(){return this.pens.length}get lastPen(){return this.pens[this.pens.length-1]}}var B=function(t,e){var s=Array.isArray(t);if(void 0===e?e=s?[]:{}: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]}(e),s){e.length=t.length;for(var r=0,i=t.length;r<i;r++)e[r]=t[r]}else for(var n in t)e[n]=t[n];return e},X=function(){};const $=Phaser.Utils.Objects.GetFastValue,j=c,D=p;class G{constructor(t){this.pens=[],this.lines=[],this.maxLinesWidth=void 0,this.pensPool=t.pensPool,this.linesPool=t.linesPool,this.tagToText=$(t,"tagToText",X),this.tagToTextScope=$(t,"tagToTextScope",void 0)}destroy(){this.clear(),this.tagToText=void 0,this.tagToTextScope=void 0}clear(){for(var t=0,e=this.lines.length;t<e;t++){var s=this.lines[t];s&&s.reset?s.reset():s&&(s.length=0)}this.pensPool.pushMultiple(this.pens),this.linesPool.pushMultiple(this.lines),this.maxLinesWidth=void 0}addTextPen(t,e,s,r,i,n,a){var h=this.pensPool.pop();if(null==h&&(h=new I),U.text=t,U.x=e,U.y=s,U.width=r,a){var o=null!=a.ascent?a.ascent:0,l=null!=a.descent?a.descent:0,u=null!=a.height?a.height:o+l;U.ascent=o,U.descent=l,U.height=u}else U.ascent=0,U.descent=0,U.height=0;return U.prop=i,U.newLineMode=n,h.resetFromJSON(U),this.addPen(h),this}addImagePen(t,e,s,r,i){return this.addTextPen("",t,e,s,r,j,i),this}addNewLinePen(){var t=this.lastPen,e=t?t.lastX:0,s=t?t.y:0,r=t?B(t.prop):null;return this.addTextPen("",e,s,0,r,D),this}addPen(t){var e=this.lastPen;t.startIndex=null==e?0:e.endIndex,this.pens.push(t);var s=this.lastLine;null==s?(s=this.newLine(),this.lines.push(s)):s.pens||(s=this.convertLine(s),this.lines[this.lines.length-1]=s),s.addPen?s.addPen(t):s.push(t),t.newLineMode!==j&&(s=this.newLine(),this.lines.push(s)),this.maxLinesWidth=void 0}clone(t){null==t&&(t=new G),t.clear();for(var e=0,s=this.lines.length;e<s;e++)for(var r=this.lines[e],i=r&&r.pens?r.pens:r,n=0,a=i.length;n<a;n++){var h=i[n];t.addPen(h.text,h.x,h.y,h.width,B(h.prop),h.newLineMode)}return t}get lastPen(){return this.pens[this.pens.length-1]}get lastLine(){return this.lines[this.lines.length-1]}getLineStartIndex(t){if(t>=this.lines.length)return this.getLineEndIndex(t);var e=this.lines[t],s=e&&e.pens?e.pens:e;return s&&s[0]?s[0].startIndex:0}getLineEndIndex(t){t>=this.lines.length&&(t=this.lines.length-1);var e,s,r=!1;for(e=t;e>=0;e--){var i;if(r=null!=(i=(s=this.lines[e])&&s.pens?s.pens:s)&&i.length>0)break}return r?(i=s&&s.pens?s.pens:s)[i.length-1].endIndex:0}getLineWidth(t){var e=this.lines[t];if(!e)return 0;var s=e&&e.pens?e.pens:e,r=s[s.length-1];return null==r?0:r.lastX}getMaxLineWidth(){if(void 0!==this.maxLinesWidth)return this.maxLinesWidth;for(var t,e=0,s=0,r=this.lines.length;s<r;s++)(t=this.getLineWidth(s))>e&&(e=t);return this.maxLinesWidth=e,e}getLineWidths(){for(var t=[],e=0,s=this.lines.length;e<s;e++)t.push(this.getLineWidth(e));return t}get linesCount(){return this.lines.length}newLine(){return this.convertLine(this.linesPool.pop())}convertLine(t){return t?t.pens?t.reset():Array.isArray(t)?new _(t).reset():new _:new _}get plainText(){for(var t="",e=this.pens,s=0,r=e.length;s<r;s++)t+=e[s].plainText;return t}get rawTextLength(){for(var t=0,e=this.pens,s=0,r=this.pens.length;s<r;s++)t+=e[s].rawTextLength;return t}getSliceTagText(t,e,s){var r=this.lastPen;if(null==r)return"";var i=r.endIndex;void 0!==t&&0!==t||(t=-1),void 0!==e&&e!==i||(e=i+1),void 0===s&&(s=!1);for(var n,a,h,o,l,u,d="",c=0,g=this.pens.length;c<g&&((o=(n=this.pens[c]).endIndex)<=t||(n=this.pens[c],a=s?n.wrapText:n.plainText,l=n.prop,(h=n.startIndex)>=t&&o<=e||(a=a.substring(t-h,e-h)),this.tagToTextScope?d+=this.tagToText.call(this.tagToTextScope,a,l,u):d+=this.tagToText(a,l,u),u=l,!(o>=e)));c++);return d}get length(){return this.lines.length}set length(t){this.clear()}}var U={};class K{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 V=Phaser.Geom.Rectangle;var N=new K;class J{constructor(){this.hitAreas=[]}destroy(){this.clear()}clear(){for(var t=0,e=this.hitAreas.length;t<e;t++)this.hitAreas[t].data=null;return N.pushMultiple(this.hitAreas),this}add(t,e,s,r,i){void 0===i&&(i={});var n=N.pop();return null===n?n=new V(t,e,s,r):n.setTo(t,e,s,r),n.data=i,this.hitAreas.push(n),this}getFirst(t,e){for(var s=0,r=this.hitAreas.length;s<r;s++){var i=this.hitAreas[s];if(i.contains(t,e))return i}return null}getByKey(t){for(var e=0,s=this.hitAreas.length;e<s;e++){var r=this.hitAreas[e];if(r.data.key===t)return r}return null}drawBounds(t,e,s){void 0===e&&(e=16777215),s&&t.save().translateCanvas(s.x,s.y).rotateCanvas(s.rotation).scaleCanvas(s.scaleX,s.scaleY);for(var r=0,i=this.hitAreas.length;r<i;r++){var n=this.hitAreas[r];t.lineStyle(1,e).strokeRect(n.x,n.y,n.width,n.height)}return s&&t.restore(),this}}var q=function(t,e,s,r){var i=this.hitAreaManager.getFirst(e,s);if(null!==i){var n=i.data.key;Z.call(this,"areadown",n,t,e,s,r),i.data&&(i.data.isDown=!0)}},E=function(t,e,s,r){var i=this.hitAreaManager.getFirst(e,s);if(null!==i){var n=i.data.key;if(Z.call(this,"areaup",n,t,e,s,r),i.data){if(i.data.isDown){if(Z.call(this,"areaclick",n,t,e,s,r),!i.data)return;var a=i.data.url;a&&window.open(a,"_blank")}i.data.isDown=!1}}},Q=function(t,e,s,r){if(null!==e){var i=(a=this.hitAreaManager.getFirst(e,s))?a.data.key:null;if(this.lastHitAreaKey!==i){if(null!==this.lastHitAreaKey){Z.call(this,"areaout",this.lastHitAreaKey,t,e,s,r);var n=this.hitAreaManager.getByKey(this.lastHitAreaKey);n&&(this.urlTagCursorStyle&&tt(this.scene,n,""),n.data.isDown=!1)}null!==i&&(Z.call(this,"areaover",i,t,e,s,r),a.data&&this.urlTagCursorStyle&&tt(this.scene,a,this.urlTagCursorStyle)),this.lastHitAreaKey=i}}else{var a;null!==this.lastHitAreaKey&&(Z.call(this,"areaout",this.lastHitAreaKey,t,e,s,r),(a=this.hitAreaManager.getByKey(this.lastHitAreaKey))&&a.data&&(a.data.isDown=!1),this.lastHitAreaKey=null)}},Z=function(t,e,s,r,i,n){this.parent.emit(`${t}-${e}`,s,r,i,n),this.parent.emit(t,e,s,r,i,n)},tt=function(t,e,s){e&&e.data&&e.data.url&&(t.input.manager.canvas.style.cursor=s)};const et=Phaser.GameObjects.Components.TransformMatrix,st=Phaser.Math.TransformXY;var rt,it,nt={},at=/^[\x00-\x7F]+$/,ht=function(t){return at.test(t)};const ot=c,lt=g,ut=p,dt=f,ct=v,gt=y,pt=x;var ft=function(t,e,s,r,i,n,a){r<=0&&(s=dt);var h=[];if(!t||!t.length)return h;for(var o,l,u,d=s===dt,c=t.split(pt),g=0,p=c.length;g<p;g++)if(o=c[g],u=g===p-1?ot:lt,d){var f=e.measureText(o).width+i*o.length;h.push(a.getLine(o,f,u))}else{if(l=0===g?r-n:r,o.length<=100&&(f=e.measureText(o).width+i*o.length)<=l){h.push(a.getLine(o,f,u));continue}for(var v,y,x,w=vt(o,s),m="",S=0,T=0,k=w.length;T<k;T++){if(v=w[T],(y=e.measureText(v).width+i*v.length)>r&&yt(v)){""!==m?h.push(a.getLine(m,S,ut)):0===T&&n>0&&h.push(a.getLine("",0,ut)),h.push(...ft(v,e,gt,r,i,0,a));var P=h.pop();m=P.text,S=P.width,a.freeLine(P)," "===m&&(m="",S=0)}else(x=S+y)>l?(h.push(a.getLine(m,S,ut)),m=v,S=y,l=r):(m+=v,S=x);T===k-1&&h.push(a.getLine(m,S,u))}}return h},vt=function(t,e){var s;switch(e){case ct:s=[];for(var r=0,i=(t=t.split(" ")).length;r<i;r++){var n=t[r];r<i-1?s.push(n+" "):""!==n&&s.push(n)}break;case gt:s=t.split("");break;default:for(s=[],r=0,i=(t=t.split(" ")).length;r<i;r++)n=t[r],r<i-1?ht(n)?s.push(n+" "):(s.push(...n.split("")),s.push(" ")):""!==n&&(ht(n)?s.push(n):s.push(...n.split("")))}return s},yt=function(t){switch(t.length){case 1:return!1;case 2:return" "!==t.charAt(1);default:return!0}};const xt=Phaser.Utils.Objects.GetValue,wt=f,mt=c,St=p;class Tt{constructor(t){this.parent=t.parent,this.scene=this.parent.scene,this.context=xt(t,"context",null),this.canvas=this.context.canvas,this.parser=xt(t,"parser",null),this.defaultStyle=xt(t,"style",null),this.autoRound=!0,this.pensPool=t.pensPool,this.linesPool=t.linesPool,this.wrapTextLinesPool=t.wrapTextLinesPool,this.penManager=this.newPenManager(),this._tmpPenManager=null,this.hitAreaManager=new J,this.lastHitAreaKey=null,this.urlTagCursorStyle=null}destroy(){this.parent=void 0,this.scene=void 0,this.context=void 0,this.canvas=void 0,this.parser=void 0,this.defaultStyle=void 0,this.penManager&&(this.penManager.destroy(),this.penManager=void 0),this._tmpPenManager&&(this._tmpPenManager.destroy(),this._tmpPenManager=void 0),this.hitAreaManager&&(this.hitAreaManager.destroy(),this.hitAreaManager=void 0),this.pensPool=void 0,this.linesPool=void 0,this.wrapTextLinesPool=void 0}updatePenManager(t,e,s,r,i){if(void 0===i&&(i=this.penManager),i.clear(),""===t)return i;var n=this.parent.style;if(n.isWrapFitMode){var a=this.parent.padding;s=n.fixedWidth-a.left-a.right}for(var h,o,l,u,c,g=this.canvas,p=this.context,f=0,v=0,y=n.wrapCallback,x=n.wrapCallbackScope,w=!y,m=!0,S=this.parser.splitText(t),T=this.wrapTextLinesPool,k=0,P=S.length;k<P;k++)if(h=(u=this.parser.tagTextToProp(S[k],o)).plainText,(o=u.prop).img){var O=this.addImagePen(o,f,v,s,e,r,i);f=O.x,v=O.y}else if(""!==h){p.save(),(l=this.parser.propToContextStyle(this.defaultStyle,o)).buildFont(),l.syncFont(g,p),l.syncStyle(g,p);var b=d(l);if(w)c=ft(h,p,e,s,l.letterSpacing,f,T);else{var M;"string"==typeof(c=y.call(x,h,p,s,l.letterSpacing,f))&&(c=c.split("\n"));for(var C=0,L=c.length;C<L;C++)"string"==typeof(M=c[C])?c[C]=T.getLine(M,p.measureText(M).width,C<L-1?St:mt):m=!1}for(C=0,L=c.length;C<L;C++)M=c[C],i.addTextPen(M.text,f,v,M.width,B(o),M.newLineMode,b),M.newLineMode!==mt?(f=0,v+=r):f+=M.width;m&&T.freeLines(c),c=null,p.restore()}var F=i.lines;for(k=0,P=F.length;k<P;k++){var A=F[k].pens,R=A[A.length-1];R&&(R.width+=this.parser.getStrokeThinkness(this.defaultStyle,R.prop),R.width-=this.parser.getLetterSpacing(this.defaultStyle,R.prop))}return this.updateLineOffsets(F,n),i}addImagePen(t,e,s,r,i,n,a){var h,o=this.imageManager.getOuterWidth(t.img),l=this.imageManager.getOuterHeight(t.img);if(l>0){var u=this.defaultStyle.metrics.ascent,d=l-u;d<0&&(d=0),h={ascent:u,descent:d,height:u+d}}return r>0&&i!==wt&&r<e+o&&(a.addNewLinePen(),s+=n,e=0),a.addImagePen(e,s,o,B(t),h),{x:e+=o,y:s}}updateLineOffsets(t,e){for(var s=e.lineSpacing,r=this.defaultStyle.metrics,i=r.ascent,n=r.descent,a=0,h=e.fixedLineHeightMode,o=0,l=t.length;o<l;o++){var u=t[o],d=u.maxAscent,c=u.maxDescent;(h||0===d&&0===c)&&(d=i,c=n),u.maxAscent=d,u.maxDescent=c,u.lineHeight=d+c,u.startOffset=a,u.endOffset=a+u.lineHeight;for(var g=a+d-i,p=u.pens,f=0,v=p.length;f<v;f++)p[f].y=g;a=u.endOffset+s}}get startXOffset(){return this.defaultStyle.xOffset}get startYOffset(){return this.defaultStyle.metrics.ascent}get lines(){return this.penManager.lines}get displayLinesCount(){var t=this.penManager.linesCount,e=this.defaultStyle.maxLines;return e>0&&t>e&&(t=e),t}get linesWidth(){return Math.ceil(this.penManager.getMaxLineWidth())}get linesHeight(){var t=this.displayLinesCount;return this.getLinesHeight(0,t)}getLineHeight(t){var e=t?t.lineHeight:0;if(e>0)return e;var s=this.defaultStyle.metrics;return s.ascent+s.descent}getLinesHeight(t,e){var s=this.penManager.lines,r=s.length;if(void 0===t&&(t=0),(void 0===e||e>r)&&(e=r),e<=t)return 0;for(var i=0,n=t;n<e;n++)i+=this.getLineHeight(s[n]);var a=e-t;return a>1&&(i+=this.defaultStyle.lineSpacing*(a-1)),i}get imageManager(){return this.parent.imageManager}get rtl(){return this.parent.style.rtl}newPenManager(){return new G({pensPool:this.pensPool,linesPool:this.linesPool,tagToText:this.parser.propToTagText,tagToTextScope:this.parser})}get tmpPenManager(){return null===this._tmpPenManager&&(this._tmpPenManager=this.newPenManager()),this._tmpPenManager}getPlainText(t,e,s){var r;if(null==t)r=this.penManager.plainText;else{var i=this.parser.splitText(t,1);r="";for(var n=0,a=i.length;n<a;n++)r+=i[n]}return null==e&&null==s||(null==e&&(e=0),null==s&&(s=r.length),r=r.substring(e,s)),r}getPenManager(t,e){if(void 0===t)return this.copyPenManager(e,this.penManager);void 0===e&&(e=this.newPenManager());var s=this.defaultStyle;return this.updatePenManager(t,s.wrapMode,s.wrapWidth,s.lineHeight,e),e}getText(t,e,s,r){if(null==t)return this.penManager.getSliceTagText(e,s,r);var i=this.tmpPenManager,n=this.defaultStyle;return this.updatePenManager(t,n.wrapMode,n.wrapWidth,n.lineHeight,i),i.getSliceTagText(e,s,r)}copyPenManager(t,e){return void 0===e&&(e=this.penManager),e.copy(t)}getTextWidth(t){return void 0===t&&(t=this.penManager),t.getMaxLineWidth()}getLastPen(t){return void 0===t&&(t=this.penManager),t.lastPen}}var kt={setInteractive:function(){this.parent.on("pointerdown",q,this).on("pointerup",E,this).on("pointermove",Q,this).on("pointerover",Q,this).on("pointerout",(function(t,e){Q.call(this,t,null,null,e)}),this)},getHitArea:function(t,e,s){var r=function(t,e,s,r,i){void 0===r&&(r=t.scene.cameras.main),void 0===i?i={}:!0===i&&(i=nt);var n=r.scrollX,a=r.scrollY,h=e+n*t.scrollFactorX-n,o=s+a*t.scrollFactorY-a;return t.parentContainer?(void 0===rt&&(rt=new et,it=new et),t.getWorldTransformMatrix(rt,it),rt.applyInverse(h,o,i)):st(h,o,t.x,t.y,t.rotation,t.scaleX,t.scaleY,i),i.x+=t.displayOriginX,i.y+=t.displayOriginY,i}(this.parent,t,e,s,!0),i=this.hitAreaManager.getFirst(r.x,r.y);if(null!==i)return i.data.key}};Object.assign(Tt.prototype,W,kt);class Pt extends K{freeLine(t){if(t)return this.push(t),this}freeLines(t){if(t)return this.pushMultiple(t),this}getLine(t,e,s){var r=this.pop();return null===r&&(r={}),r.text=t,r.width=e,r.newLineMode=s,r}}const Ot=Phaser.Utils.Objects.IsPlainObject,bt=Phaser.Utils.Objects.GetValue;var Mt=function(t,e){Ot(t)?t=(e=t).key:void 0===e&&(e={key:t}),e.hasOwnProperty("key")||(e.key=t);var s=e.key,r=e.frame,i=e.width,n=e.height;if(void 0===i||void 0===n){var a=this.textureManager.getFrame(s,r),h=a?a.cutWidth:0,o=a?a.cutHeight:0;void 0===i&&void 0===n?(i=h,n=o):void 0===i?i=h*(n/o):void 0===n&&(n=o*(i/h))}this.images[t]={key:s,frame:r,width:i,height:n,y:bt(e,"y",0),left:bt(e,"left",0),right:bt(e,"right",0),originX:bt(e,"originX",0),originY:bt(e,"originY",0),tintFill:bt(e,"tintFill",!1)}};const Ct=Phaser.Display.Canvas.CanvasPool;class Lt{constructor(t){this.textureManager=t.sys.textures,this.images={}}destroy(){this.textureManager=void 0,this.images=void 0}add(t,e){if("string"==typeof t)Mt.call(this,t,e);else if(Array.isArray(t))for(var s=0,r=(i=t).length;s<r;s++)Mt.call(this,i[s]);else{var i=t;for(var t in i)Mt.call(this,t,i[t])}return this}has(t){return this.images.hasOwnProperty(t)}remove(t){return this.has(t)&&delete this.images[t],this}get(t){return this.has(t)||this.textureManager.exists(t)&&this.add(t),this.images[t]}getOuterWidth(t){var e=this.get(t);return e?e.width+e.left+e.right:0}getOuterHeight(t){var e=this.get(t);return e?e.height:0}getFrame(t){var e=this.get(t);return e?this.textureManager.getFrame(e.key,e.frame):void 0}hasTexture(t){return!!this.getFrame(t)}}var Ft={draw:function(t,e,s,r,i,n){var a=this.get(t);if(a){var h=this.textureManager.getFrame(a.key,a.frame),o=a.width,l=a.height;s+=a.left-a.originX*o,r+=a.y-a.originY*l,a.tintFill||(i=void 0),function(t,e,s,r,i,n,a,h){void 0===s&&(s=0),void 0===r&&(r=0),void 0===i&&(i=t.cutWidth),void 0===n&&(n=t.cutHeight),void 0===h&&(h=!1),h&&(s=Math.round(s),r=Math.round(r));var o=e.getContext("2d",{willReadFrequently:!0});if(a){var l=Ct.create(null,i,n,Phaser.CANVAS,!0),u=l.getContext("2d",{willReadFrequently:!0});u.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,0,0,i,n),u.globalCompositeOperation="source-in",u.fillStyle=a,u.fillRect(0,0,i,n),o.drawImage(l,0,0,i,n,s,r,i,n),Ct.remove(l)}else o.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,s,r,i,n)}(h,e.canvas,s,r,o,l,i,n)}}};Object.assign(Lt.prototype,Ft);const At=Phaser.Utils.Objects.IsPlainObject,Rt=Phaser.DOM.AddToDOM,Wt=Phaser.Display.Canvas.CanvasPool,Ht=Phaser.GameObjects.GameObject,Yt=Phaser.Utils.Objects.GetValue,zt=Phaser.DOM.RemoveFromDOM,It=x,_t=Phaser.Utils.String.UUID,Bt=Phaser.Math.Clamp;var Xt=null,$t=null,jt=null;class Dt extends n{constructor(t,e,s,r,i,n,a){if(At(e)){var h=e;e=Yt(h,"x",0),s=Yt(h,"y",0),r=Yt(h,"text",""),i=Yt(h,"style")}if(void 0===e&&(e=0),void 0===s&&(s=0),super(t,n),this.renderer=t.sys.game.renderer,this.setPosition(e,s),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(!0),this.canvas=Wt.create(this),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this._imageManager=void 0,i){if(i.hasOwnProperty("align")){var o=i.align;delete i.align,i.halign=o}i.hasOwnProperty("stroke")&&!i.hasOwnProperty("strokeThickness")&&(i.strokeThickness=1)}this.style=new T(this,i);var l,u,d,c=Yt(i,"images",void 0);c&&this.addImage(c),this.autoRound=!0,this._text=void 0,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.dirty=!1,this._scrollY=0,0===this.style.resolution&&(this.style.resolution=1),this._crop=this.resetCropObject(),this._textureKey=_t(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.frame=this.texture.get(),this.frame.source.resolution=this.style.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),Yt(i,"sharedPool",!0)?(Xt||(Xt={},$t=new K,jt=new Pt,this.scene.game.events.once("destroy",(function(){Xt=null,$t=null,jt=null}))),Xt.hasOwnProperty(n)||(Xt[n]=new K),l=Xt[n],u=$t,d=jt):(l=new K,u=new K,d=new Pt),this.canvasText=new Tt({parent:this,context:this.context,parser:a,style:this.style,pensPool:l,linesPool:u,wrapTextLinesPool:d}),this.parser=a,this.initRTL(),i&&i.padding&&this.setPadding(i.padding),this.setText(r),this.setUrlTagCursorStyle(Yt(i,"urlTagCursorStyle","pointer")),Yt(i,"interactive",!1)&&this.setInteractive()}preDestroy(){zt(this.canvas),this.canvasText.destroy(),this.canvasText=void 0,this._imageManager&&(this._imageManager.destroy(),this._imageManager=void 0),Wt.remove(this.canvas);var t=this.texture;t&&t.destroy()}set text(t){this.setText(t)}get text(){return this._text}get topScrollY(){return 0}get bottomScrollY(){var t=this.contentHeight-this.viewportHeight;return t>0?-t:0}get scrollY(){return this._scrollY}set scrollY(t){this._scrollY!==t&&(this._scrollY=t,this.updateText(!1))}setScrollY(t,e){return void 0===e&&(e=!1),e&&(t=Bt(t,this.bottomScrollY,this.topScrollY)),this.scrollY=t,this}addScrollY(t,e){return this.setScrollY(this.scrollY+t,e)}get t(){var t=this.bottomScrollY;return 0===t?0:this._scrollY/t}set t(t){this.setT(t)}setT(t,e){void 0===e&&(e=!1),e&&(t=Bt(t,0,1));var s=this.bottomScrollY*t;return this.setScrollY(s,!1)}addT(t,e){return this.setT(this.t+t,e)}scrollToTop(){return this.setScrollY(this.topScrollY)}scrollToBottom(){return this.setScrollY(this.bottomScrollY)}initRTL(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",Rt(this.canvas,this.scene.sys.canvas),this.originX=1)}setRTL(t){void 0===t&&(t=!0);var e=this.style;if(e.rtl===t)return this;if(e.rtl=t,t?(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",Rt(this.canvas,this.scene.sys.canvas)):(this.canvas.dir="ltr",this.context.direction="ltr"),"left"===e.halign?e.halign="right":"right"===e.halign&&(e.halign="left"),this._imageManager){var s=this._imageManager.images;for(var r in s)s[r].originX=1-s[r].originX}return this}setText(t){return(t=function(t){return null==t?t="":Array.isArray(t)?t=t.join("\n"):"number"==typeof t&&(t=t.toString()),t}(t))===this._text||(this._text=t,this.updateText()),this}setPadding(t,e,s,r){if("object"==typeof t){var i=t,n=Yt(i,"x",null);null!==n?(t=n,s=n):(t=Yt(i,"left",0),s=Yt(i,"right",t));var a=Yt(i,"y",null);null!==a?(e=a,r=a):(e=Yt(i,"top",0),r=Yt(i,"bottom",e))}else void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=t),void 0===r&&(r=e);return this.padding.left=t,this.padding.top=e,this.padding.right=s,this.padding.bottom=r,this.updateText(!1)}updateText(t){void 0===t&&(t=!0);var e=this.canvasText,s=this.style;t&&e.updatePenManager(this._text,s.wrapMode,s.wrapWidth,s.lineHeight);var r,i,n=this.padding,a=Math.ceil(e.linesWidth);0===s.fixedWidth?(this.width=a+n.left+n.right,r=a):(this.width=s.fixedWidth,(r=this.width-n.left-n.right)<a&&(r=a)),0===s.fixedHeight?(this.height=e.linesHeight+n.top+n.bottom,i=e.linesHeight):(this.height=s.fixedHeight,(i=this.height-n.top-n.bottom)<e.linesHeight&&(i=e.linesHeight));var h=this.width,o=this.height;this.updateDisplayOrigin();var l=s.resolution;h*=l,o*=l,h=Math.max(Math.ceil(h),1),o=Math.max(Math.ceil(o),1);var u=this.canvas,d=this.context;u.width!==h||u.height!==o?(u.width=h,u.height=o,this.frame.setSize(h,o)):d.clearRect(0,0,h,o),d.save(),d.scale(l,l);var c=this.style.rtl?n.right:n.left,g=n.top+this._scrollY;e.draw(c,g,r,i),d.restore(),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(u,this.frame.source.glTexture,!0),this.frame.glTexture.spectorMetadata={textureKey:"BBCodeText Game Object"}),this.dirty=!0;var p=this.input;return p&&!p.customHitArea&&(p.hitArea.width=this.width,p.hitArea.height=this.height),this}toJSON(){var t=Components.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t}setInteractive(t,e,s){var r=!!this.input;return Ht.prototype.setInteractive.call(this,t,e,s),r||this.canvasText.setInteractive(),this}setUrlTagCursorStyle(t){return this.urlTagCursorStyle=t,this}get urlTagCursorStyle(){return this.canvasText.urlTagCursorStyle}set urlTagCursorStyle(t){this.canvasText.urlTagCursorStyle=t}getWrappedText(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),(t=this.canvasText.getText(t,e,s,!0)).split(It)}getPlainText(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),this.canvasText.getPlainText(t,e,s)}getText(t,e,s,r){return"number"==typeof t&&(r=s,s=e,e=t,t=void 0),void 0===r&&(r=!1),this.canvasText.getText(t,e,s,r)}getSubString(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),this.getText(t,e,s)}copyPenManager(t){return this.canvasText.copyPenManager(t)}getPenManager(t,e){return this.canvasText.getPenManager(t,e)}setSize(t,e){return this.setFixedSize(t,e)}resize(t,e){return this.setFixedSize(t,e)}get imageManager(){return this._imageManager||(this._imageManager=new Lt(this.scene)),this._imageManager}addImage(t,e){return this.imageManager.add(t,e),this}drawAreaBounds(t,e){return this.canvasText.hitAreaManager.drawBounds(t,e,this),this}generateTexture(t,e,s,r,i){var n=this.canvas;return void 0===r?r=n.width:r*=this.resolution,void 0===i?i=n.height:i*=this.resolution,function(t,e,s,r,i,n,a){var h,o=t.sys.textures,l=t.renderer;void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=e.width),void 0===a&&(a=e.height);var u=(h=o.exists(s)?o.get(s):o.createCanvas(s,n,a)).getSourceImage();u.width!==n&&(u.width=n),u.height!==a&&(u.height=a);var d=u.getContext("2d",{willReadFrequently:!0});d.clearRect(0,0,n,a),d.drawImage(e,r,i,n,a),l.gl&&h&&l.canvasToTexture(u,h.source[0].glTexture,!0,0)}(this.scene,n,t,e,s,r,i),this}getHitArea(t,e,s){return this.canvasText.getHitArea(t,e,s)}get viewportHeight(){var t=this.padding,e=this.height-t.top-t.bottom;return Math.max(e,0)}get contentHeight(){return this.canvasText.linesHeight}}var Gt={appendText:function(t,e){var s;return t||0===t||(t=""),void 0===e&&(e=!0),Array.isArray(t)&&(t=t.join("\n")),(s=e?`${this.text}\n${t}`:`${this.text}${t}`)!=this.text&&this.setText(s),this}};Object.assign(Dt.prototype,Gt);var Ut={plainText:null,prevProp:null},Kt=new T;class Vt{constructor(t){void 0===t&&(t={}),this.tags=t}addTag(t,e){this.tags[t]=e}getTag(t){return this.tags[t]}splitText(t,e){for(var s=[],r=0;;){var i=qt.exec(t);if(!i)break;var n=i[0],a=qt.lastIndex-n.length;if(r<a&&s.push(t.substring(r,a)),void 0===e)s.push(n);else if(1===e)if(Et.test(n)){var h=n.match(Qt);s.push(h[2])}else Zt.test(n)&&(h=n.match(te),s.push(h[2]));r=qt.lastIndex}var o=t.length;return r<o&&s.push(t.substring(r,o)),s}tagTextToProp(t,e){var s,r;if(Et.test(t)){if(null!=(a=t.match(Qt))){var i=a[1],n=this.tags;(r=n.hasOwnProperty(i)?n[i]:{})._class=i,s=a[2]}}else if(Zt.test(t)){var a;if(null!=(a=t.match(te))){var h=a[1];(r=Nt(h))._style=h,s=a[2]}}null==s&&(s=t),null==r&&(r={});var o=Ut;return o.plainText=s,o.prop=r,o}propToContextStyle(t,e){var s=Kt;if(e.hasOwnProperty("img"))s.image=e.img;else{if(s.image=null,e.hasOwnProperty("family")||e.hasOwnProperty("fontFamily")||e.hasOwnProperty("font-family")){var r=e.hasOwnProperty("family")?e.family:e.hasOwnProperty("fontFamily")?e.fontFamily:e["font-family"];s.fontFamily=r}else s.fontFamily=t.fontFamily;if(e.hasOwnProperty("size")||e.hasOwnProperty("fontSize")||e.hasOwnProperty("font-size")){var i=e.hasOwnProperty("size")?e.size:e.hasOwnProperty("fontSize")?e.fontSize:e["font-size"];"number"==typeof i&&(i=`${i}px`),s.fontSize=i}else s.fontSize=t.fontSize;if(e.hasOwnProperty("style")||e.hasOwnProperty("fontStyle")||e.hasOwnProperty("font-style")){var n=e.hasOwnProperty("style")?e.style:e.hasOwnProperty("fontStyle")?e.fontStyle:e["font-style"];s.fontStyle=n}else s.fontStyle=t.fontStyle;if(e.hasOwnProperty("color")||e.hasOwnProperty("font-color")){var a=e.hasOwnProperty("color")?e.color:e["font-color"];s.color=a}else s.color=t.color;if(e.hasOwnProperty("stroke")){var h=e.stroke;s.stroke=h.hasOwnProperty("color")?h.color:t.stroke,s.strokeThickness=h.hasOwnProperty("thickness")?h.thickness:t.strokeThickness}else s.stroke=t.stroke,s.strokeThickness=t.strokeThickness}if(e.hasOwnProperty("shadow")){var o=e.shadow;s.shadowColor=o.hasOwnProperty("color")?o.color:t.shadowColor,s.shadowOffsetX=o.hasOwnProperty("offsetX")?o.offsetX:t.shadowOffsetX,s.shadowOffsetY=o.hasOwnProperty("offsetY")?o.offsetY:t.shadowOffsetY,s.shadowBlur=o.hasOwnProperty("blur")?o.blur:t.shadowBlur,s.shadowStroke=!0,s.shadowFill=!0}else s.shadowColor=t.shadowColor,s.shadowOffsetX=t.shadowOffsetX,s.shadowOffsetY=t.shadowOffsetY,s.shadowBlur=t.shadowBlur,s.shadowStroke=t.shadowStroke,s.shadowFill=t.shadowFill;if(e.hasOwnProperty("u")||e.hasOwnProperty("underline")){var l=e.hasOwnProperty("u")?e.u:e.underline;s.underlineColor=l.hasOwnProperty("color")?l.color:t.underlineColor,s.underlineThickness=l.hasOwnProperty("thickness")?l.thickness:t.underlineThickness,s.underlineOffset=l.hasOwnProperty("offset")?l.offset:t.un