UNPKG

phaser3-rex-plugins

Version:
1 lines 61.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexdynamictextplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r);}}function r(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e);}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var i,r=s(t);if(e){var n=s(this).constructor;i=Reflect.construct(r,arguments,n);}else i=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)}(this,i)}}function l(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var r=l(t,e);if(r){var n=Object.getOwnPropertyDescriptor(r,e);return n.get?n.get.call(arguments.length<3?t:i):n.value}},u.apply(this,arguments)}function c(t,e,i,r){return c="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,r){var n,s=l(t,e);if(s){if((n=Object.getOwnPropertyDescriptor(s,e)).set)return n.set.call(r,i),!0;if(!n.writable)return !1}if(n=Object.getOwnPropertyDescriptor(r,e)){if(!n.writable)return !1;n.value=i,Object.defineProperty(r,e,n);}else !function(t,e,i){(e=g(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i;}(r,e,i);return !0},c(t,e,i,r)}function d(t,e,i,r,n){if(!c(t,e,i,r||t)&&n)throw new TypeError("failed to set property");return i}function f(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return y(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return y(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function g(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(t,"string");return "symbol"==typeof e?e:String(e)}var v,p=Phaser.Renderer.WebGL.Utils,k={renderWebGL:function(t,e,i,r){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.addToRenderList(e);var n=e.frame,s=n.width,h=n.height,o=p.getTintAppendFloatAlpha,a=t.pipelines.set(e.pipeline,e),l=a.setTexture2D(n.glTexture,e);t.pipelines.preBatch(e),a.batchTexture(e,n.glTexture,s,h,e.x,e.y,s/e.resolution,h/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,s,h,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,r,!1,l),t.pipelines.postBatch(e);}},renderCanvas:function(t,e,i,r){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,r));}},w=Phaser.Display.Color,x={clear:function(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill:function(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame:function(t,e,i,r,n,s,h,o,a,l){var u=this.scene.sys.textures.getFrame(t,e);if(!u)return this;var c=u.cutWidth,d=u.cutHeight;void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=c),void 0===s&&(s=d),void 0===h&&(h=0),void 0===o&&(o=0),void 0===a&&(a=c),void 0===l&&(l=d);var f=u.cutX+h,y=u.cutY+o;return this.context.drawImage(u.source.image,f,y,a,l,i,r,n,s),this.dirty=!0,this},getDataURL:function(t,e){return this.canvas.toDataURL(t,e)},getPixel:function(t,e,i){void 0===i&&(i=new w);var r=this.context.getImageData(t,e,1,1);return i.setTo(r.data[0],r.data[1],r.data[2],r.data[3]),i},setPixel:function(t,e,i,r,n,s){if("number"!=typeof i){var h=i;i=h.red,r=h.green,n=h.blue,s=h.alpha;}void 0===s&&(s=0!==i||0!==r||0!==n?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=r,o.data[2]=n,o.data[3]=s,this.context.putImageData(o,t,e),this.dirty=!0,this}},b={updateTexture:function(t,e){t&&(e?t.call(e,this.canvas,this.context):t(this.canvas,this.context)),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=this.frame.source.glTexture),this.dirty=!1;var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=this.width,i.hitArea.height=this.height),this},generateTexture:function(t,e,i,r,n){var s=this.canvas;return void 0===r?r=s.width:r*=this.resolution,void 0===n?n=s.height:n*=this.resolution,function(t,e,i,r,n,s,h){var o,a=t.sys.textures,l=t.renderer;void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=e.width),void 0===h&&(h=e.height);var u=(o=a.exists(i)?a.get(i):a.createCanvas(i,s,h)).getSourceImage();u.width!==s&&(u.width=s),u.height!==h&&(u.height=h);var c=u.getContext("2d",{willReadFrequently:!0});c.clearRect(0,0,s,h),c.drawImage(e,r,n,s,h),l.gl&&o&&l.canvasToTexture(u,o.source[0].glTexture,!0,0);}(this.scene,s,t,e,i,r,n),this},loadTexture:function(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}},m=!1;m||(void 0===v&&(v=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<v&&console.error("Minimum supported version : 3.".concat(v)),m=!0);var S=Phaser.Display.Canvas.CanvasPool,C=function(t){n(s,t);var i=a(s);function s(t,r,n,h,a){var l;return e(this,s),void 0===r&&(r=0),void 0===n&&(n=0),void 0===h&&(h=1),void 0===a&&(a=1),(l=i.call(this,t,"rexCanvas")).renderer=t.sys.game.renderer,l.resolution=1,l._width=h,l._height=a,h=Math.max(Math.ceil(h*l.resolution),1),a=Math.max(Math.ceil(a*l.resolution),1),l.canvas=S.create(o(l),h,a),l.context=l.canvas.getContext("2d",{willReadFrequently:!0}),l.dirty=!1,l.setPosition(r,n),l.setOrigin(.5,.5),l.initPipeline(),l.initPostPipeline(!0),l._crop=l.resetCropObject(),l.texture=t.sys.textures.addCanvas(null,l.canvas,!0),l.frame=l.texture.get(),l.frame.source.resolution=l.resolution,l.renderer&&l.renderer.gl&&(l.renderer.deleteTexture(l.frame.source.glTexture),l.frame.source.glTexture=null),l.dirty=!0,l}return r(s,[{key:"preDestroy",value:function(){S.remove(this.canvas),this.texture.destroy(),this.canvas=null,this.context=null;}},{key:"width",get:function(){return this._width},set:function(t){this.setSize(t,this._height);}},{key:"height",get:function(){return this._height},set:function(t){this.setSize(this._width,t);}},{key:"setCanvasSize",value:function(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}},{key:"setSize",value:function(t,e){return this.setCanvasSize(t,e),this}},{key:"displayWidth",get:function(){return this.scaleX*this._width},set:function(t){this.scaleX=t/this._width;}},{key:"displayHeight",get:function(){return this.scaleY*this._height},set:function(t){this.scaleY=t/this._height;}},{key:"setDisplaySize",value:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}},{key:"getCanvas",value:function(t){return t||(this.dirty=!0),this.canvas}},{key:"getContext",value:function(t){return t||(this.dirty=!0),this.context}},{key:"needRedraw",value:function(){return this.dirty=!0,this}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}}]),s}(Phaser.GameObjects.GameObject),O=Phaser.GameObjects.Components;Phaser.Class.mixin(C,[O.Alpha,O.BlendMode,O.Crop,O.Depth,O.Flip,O.GetBounds,O.Mask,O.Origin,O.Pipeline,O.PostPipeline,O.ScrollFactor,O.Tint,O.Transform,O.Visible,k,x,b]);var P=Phaser.Utils.Objects.GetValue,T=function(e,i,r){void 0===e&&(e={}),void 0===i&&(i=0);var n=t(i);return "string"===n?e[i]=r:"number"===n?(e.left=i,e.right=i,e.top=i,e.bottom=i):(e.left=P(i,"left",0),e.right=P(i,"right",0),e.top=P(i,"top",0),e.bottom=P(i,"bottom",0)),e},_={enableData:function(){return void 0===this.data&&(this.data={}),this},setData:function(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:function(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var r=e.split("."),n=t,s=i,h=0;h<r.length;h++){if(!n.hasOwnProperty(r[h])){s=i;break}s=n[r[h]],n=n[r[h]];}return s}return i}return i}(this.data,t,e)},incData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData:function(){return this.data&&function(e){if("object"!==t(e)||null===e)return e;if(Array.isArray(e))e.length=0;else for(var i in e)delete e[i];}(this.data),this}},Y=function(){function t(i,r){e(this,t),this.setParent(i),this.type=r,this.renderable=!1,this.reset().setActive();}return r(t,[{key:"destroy",value:function(){this.parent.removeChild(this);}},{key:"setParent",value:function(t){return this.parent=t,this}},{key:"scene",get:function(){return this.parent.scene}},{key:"canvas",get:function(){return this.parent?this.parent.canvas:null}},{key:"context",get:function(){return this.parent?this.parent.context:null}},{key:"setDirty",value:function(t){return t&&this.parent&&(this.parent.dirty=!0),this}},{key:"active",get:function(){return this._active},set:function(t){this.setDirty(this._active!=t),this._active=t;}},{key:"setActive",value:function(t){return void 0===t&&(t=!0),this.active=t,this}},{key:"modifyPorperties",value:function(t){return this}},{key:"onFree",value:function(){this.reset().setParent();}},{key:"reset",value:function(){return this}},{key:"render",value:function(){}},{key:"contains",value:function(t,e){return !1}}]),t}();Object.assign(Y.prototype,_);var X,R,B,A,W,D={renderContent:function(){},render:function(){if(!this.willRender)return this;var t=this.context;if(t.save(),t.globalAlpha=this.alpha,this.toLocalPosition){var e=this.drawX,i=this.drawY;this.autoRound&&(e=Math.round(e),i=Math.round(i)),t.translate(e,i),t.scale(this.scaleX,this.scaleY),t.rotate(this.rotation);}return this.drawBelowCallback&&this.drawBelowCallback(this),this.renderContent(),this.drawAboveCallback&&this.drawAboveCallback(this),t.restore(),this}},H=Phaser.Math.RotateAround,L=Phaser.Geom.Rectangle,M=function(t){void 0===R&&(R=new L);var e=t.drawTLX,i=t.drawTLY;return R.setTo(e,i,t.drawTRX-e,t.drawBLY-i),R},j=Phaser.Math.RotateAround,F=function(t,e,i,r){return void 0===r?r={}:!0===r&&(void 0===B&&(B={}),r=B),r.x=e,r.y=i,0!==t.rotation&&j(r,0,0,t.rotation),r.x=r.x*t.scaleX+t.drawX,r.y=r.y*t.scaleY+t.drawY,r},z=Phaser.GameObjects.Components.TransformMatrix,G={},I=function(t,e,i,r,n){var s=F(e,i,r,!0),h=function(t,e,i,r){void 0===r?r={}:!0===r&&(r=G);var n=e-t.width*t.originX,s=i-t.height*t.originY;return void 0===A&&(A=new z,W=new z),t.parentContainer?t.getWorldTransformMatrix(A,W):A.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),A.transformPoint(n,s,r),r}(t,s.x,s.y,n);return h},U=function(t,e,i,r,n){"number"!=typeof i&&(n=i,i=0,r=0);var s=e.drawCenterX+i,h=e.drawCenterY+r;return I(t,e,s,h,n)},E={contains:function(t,e){if(0===this.width||0===this.height)return !1;var i=function(t,e,i,r){return void 0===r?r={}:!0===r&&(void 0===X&&(X={}),r=X),r.x=(t-i.drawX)/i.scaleX,r.y=(e-i.drawY)/i.scaleY,0!==i.rotation&&H(r,0,0,-i.rotation),r}(t,e,this,!0);return M(this).contains(i.x,i.y)},getWorldPosition:function(t,e,i){return U(this.parent,this,t,e,i)}};Object.assign(E,D);var V=Phaser.Math.DegToRad,N=Phaser.Math.RadToDeg,J=Phaser.Utils.Objects.GetValue,q=function(t){n(s,t);var i=a(s);function s(t,r){var n;return e(this,s),(n=i.call(this,t,r)).renderable=!0,n.scrollFactorX=1,n.scrollFactorY=1,n.toLocalPosition=!0,n.originX=0,n.offsetX=0,n.offsetY=0,n}return r(s,[{key:"visible",get:function(){return this._visible},set:function(t){this.setDirty(this._visible!=t),this._visible=t;}},{key:"setVisible",value:function(t){return void 0===t&&(t=!0),this.visible=t,this}},{key:"alpha",get:function(){return this._alpha},set:function(t){this.setDirty(this._alpha!=t),this._alpha=t;}},{key:"setAlpha",value:function(t){return this.alpha=t,this}},{key:"x",get:function(){return this._x},set:function(t){this.setDirty(this._x!=t),this._x=t;}},{key:"setX",value:function(t){return this.x=t,this}},{key:"y",get:function(){return this._y},set:function(t){this.setDirty(this._y!=t),this._y=t;}},{key:"setY",value:function(t){return this.y=t,this}},{key:"setPosition",value:function(t,e){return this.x=t,this.y=e,this}},{key:"setInitialPosition",value:function(t,e){return this.x0=t,this.y0=e,this}},{key:"setScrollFactorX",value:function(t){return this.scrollFactorX=t,this}},{key:"setScrollFactorY",value:function(t){return this.scrollFactorY=t,this}},{key:"setScrollFactor",value:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}},{key:"rotation",get:function(){return this._rotation},set:function(t){this.setDirty(this._rotation!=t),this._rotation=t;}},{key:"setRotation",value:function(t){return this.rotation=t,this}},{key:"angle",get:function(){return N(this._rotation)},set:function(t){this.rotation=V(t);}},{key:"setAngle",value:function(t){return this.angle=t,this}},{key:"scaleX",get:function(){return this._scaleX},set:function(t){this.setDirty(this._scaleX!==t),this._scaleX=t;}},{key:"setScaleX",value:function(t){return this.scaleX=t,this}},{key:"width",get:function(){return 0},set:function(t){}},{key:"setWidth",value:function(t,e){return void 0===e&&(e=!1),this.width=t,e&&(this.scaleY=this.scaleX),this}},{key:"leftSpace",get:function(){return this._leftSpace},set:function(t){this.setDirty(this._leftSpace!==t),this._leftSpace=t;}},{key:"setLeftSpace",value:function(t){return this.leftSpace=t,this}},{key:"rightSpace",get:function(){return this._rightSpace},set:function(t){this.setDirty(this._rightSpace!==t),this._rightSpace=t;}},{key:"setRightSpace",value:function(t){return this.rightSpace=t,this}},{key:"outerWidth",get:function(){return this.width+this.leftSpace+this.rightSpace}},{key:"scaleY",get:function(){return this._scaleY},set:function(t){this.setDirty(this._scaleY!==t),this._scaleY=t;}},{key:"setScaleY",value:function(t){return this.scaleY=t,this}},{key:"height",get:function(){return 0},set:function(t){}},{key:"setHeight",value:function(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}},{key:"setScale",value:function(t,e){return void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this}},{key:"setOrigin",value:function(t){return this.originX=t,this}},{key:"setAlign",value:function(t){return this.align=t,this}},{key:"modifyPorperties",value:function(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=J(t,"width",void 0),i=J(t,"height",void 0),r=J(t,"scaleX",void 0),n=J(t,"scaleY",void 0);return void 0!==e?void 0===i&&void 0===n?this.setWidth(e,!0):this.setWidth(e):void 0!==r&&this.setScaleX(r),void 0!==i?void 0===e&&void 0===r?this.setHeight(i,!0):this.setHeight(i):void 0!==n&&this.setScaleY(n),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),this}},{key:"setDrawBelowCallback",value:function(t){return this.drawBelowCallback=t,this}},{key:"setDrawAboveCallback",value:function(t){return this.drawAboveCallback=t,this}},{key:"reset",value:function(){return this.setVisible().setAlpha(1).setPosition(0,0).setRotation(0).setScale(1,1).setLeftSpace(0).setRightSpace(0).setOrigin(0).setAlign().setDrawBelowCallback().setDrawAboveCallback(),this}},{key:"willRender",get:function(){return this.visible&&this.alpha>0}},{key:"drawX",get:function(){var t=this.x+this.leftSpace+this.offsetX-this.originX*this.width;return this.parent._textOX*this.scrollFactorX+t}},{key:"drawY",get:function(){var t=this.y+this.offsetY;return this.parent._textOY*this.scrollFactorY+t}},{key:"drawTLX",get:function(){return 0}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return 0}},{key:"drawBLY",get:function(){return 0}},{key:"drawTRX",get:function(){return 0}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return 0}},{key:"drawBRY",get:function(){return 0}},{key:"drawCenterX",get:function(){return (this.drawTRX+this.drawTLX)/2}},{key:"drawCenterY",get:function(){return (this.drawBLY+this.drawTLY)/2}}]),s}(Y);Object.assign(q.prototype,E);var $=Phaser.Utils.String.Pad,K=function(e,i,r){if(null==e)return e;switch(t(e)){case"string":default:return e;case"number":return "#".concat($(Math.floor(e).toString(16),6,"0",1));case"function":return e(i,r);case"object":return e.hasOwnProperty("r")?e.hasOwnProperty("a")?"rgba(".concat(e.r,",").concat(e.g,",").concat(e.b,",").concat(e.a,")"):"rgb(".concat(e.r,",").concat(e.g,",").concat(e.b,")"):e.hasOwnProperty("h")?e.hasOwnProperty("a")?"hsla(".concat(e.h,",").concat(e.s,",").concat(e.l,",").concat(e.a,")"):"hsl(".concat(e.h,",").concat(e.s,",").concat(e.l,")"):e}},Q=function(t,e,i){return e.hasOwnProperty(t)?e[t]:i[t]},Z=Phaser.Utils.Objects.GetValue,tt=function(){function t(i,r,n,s,h){e(this,t),void 0===i&&(i=0),void 0===r&&(r=i),void 0===n&&(n=0),void 0===s&&(s=0),void 0===h&&(h=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(i,r,n,s,h);}return r(t,[{key:"setTo",value:function(t,e,i,r,n){return this.setPosition(t,e),this.setRadius(n),this.setSize(i,r),this}},{key:"setPosition",value:function(t,e){return this.x=t,this.y=e,this}},{key:"setRadius",value:function(t){return void 0===t&&(t=0),this.radius=t,this}},{key:"setSize",value:function(t,e){return this.width=t,this.height=e,this}},{key:"minWidth",get:function(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}},{key:"minHeight",get:function(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}},{key:"width",get:function(){return this._width},set:function(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth);}},{key:"height",get:function(){return this._height},set:function(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight);}},{key:"radius",get:function(){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:function(t){var e,i;"number"==typeof t?(e=t,i=t):(e=Z(t,"x",0),i=Z(t,"y",0));var r=this.cornerRadius;r.tl=et(Z(t,"tl",void 0),e,i),r.tr=et(Z(t,"tr",void 0),e,i),r.bl=et(Z(t,"bl",void 0),e,i),r.br=et(Z(t,"br",void 0),e,i);}},{key:"radiusTL",get:function(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.tl,t);}},{key:"radiusTR",get:function(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.tr,t);}},{key:"radiusBL",get:function(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.bl,t);}},{key:"radiusBR",get:function(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.br,t);}}]),t}(),et=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),rt(t),t},it=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=Z(e,"x",0),t.y=Z(e,"y",0)),rt(t);},rt=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y);},nt=Phaser.Math.DegToRad,st=function(t){return !t.hasOwnProperty("convex")||t.convex},ht=function(t){return t.x>0&&t.y>0},ot=function(t,e,i,r,n,s,h,o,a){if(o&&h>s?h-=360:!o&&h<s&&(h+=360),s=nt(s),h=nt(h),null==a)t.ellipse(e,i,r,n,0,s,h,o);else for(var l,u,c,d=(h-s)/(a+=1),f=0;f<=a;f++)c=s+d*f,l=e+r*Math.cos(c),u=i+n*Math.sin(c),t.lineTo(l,u);},at=function(t,e,i,r,n,s,h,o,a,l,u,c,d){if(function(t,e,i,r,n,s,h){var o,a,l,u,c,d=new tt(e,i,r,n,s),f=d.minWidth,y=d.minHeight,g=r>=f?1:r/f,v=n>=y?1:n/y,p=d.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=p.tl,ht(o)?(a=o.x*g,l=o.y*v,st(o)?ot(t,a,l,a,l,180,270,!1,h):ot(t,0,0,a,l,90,0,!0,h),u=0,c=l):(t.lineTo(0,0),u=0,c=0),o=p.tr,ht(o)?(a=o.x*g,l=o.y*v,st(o)?ot(t,r-a,l,a,l,270,360,!1,h):ot(t,r,0,a,l,180,90,!0,h)):t.lineTo(r,0),o=p.br,ht(o)?(a=o.x*g,l=o.y*v,st(o)?ot(t,r-a,n-l,a,l,0,90,!1,h):ot(t,r,n,a,l,270,180,!0,h)):t.lineTo(r,n),o=p.bl,ht(o)?(a=o.x*g,l=o.y*v,st(o)?ot(t,a,n-l,a,l,90,180,!1,h):ot(t,0,n,a,l,360,270,!0,h)):t.lineTo(0,n),t.lineTo(u,c),t.closePath(),t.restore();}(e,i,r,n,s,h,d),null!=o){var f;if(null!=u)(f=c?e.createLinearGradient(0,0,n,0):e.createLinearGradient(0,0,0,s)).addColorStop(0,o),f.addColorStop(1,u),o=f;e.fillStyle=o,e.fill();}null!=a&&l>0&&(e.strokeStyle=a,e.lineWidth=l,e.stroke());},lt=Phaser.Utils.Objects.GetValue,ut=function(t){n(h,t);var i=a(h);function h(t,r){var n;return e(this,h),(n=i.call(this,t,"background")).setScrollFactor(0),n.setColor(lt(r,"color",null),lt(r,"color2",null),lt(r,"horizontalGradient",!0)),n.setStroke(lt(r,"stroke",null),lt(r,"strokeThickness",2)),n.setCornerRadius(lt(r,"cornerRadius",0),lt(r,"cornerIteration",null)),n}return r(h,[{key:"color",get:function(){return this._color},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t;}},{key:"color2",get:function(){return this._color2},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t;}},{key:"horizontalGradient",get:function(){return this._horizontalGradient},set:function(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t;}},{key:"setColor",value:function(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}},{key:"stroke",get:function(){return this._stroke},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t;}},{key:"strokeThickness",get:function(){return this._strokeThickness},set:function(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t;}},{key:"setStroke",value:function(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}},{key:"cornerRadius",get:function(){return this._cornerRadius},set:function(t){this.setDirty(this._cornerRadius!=t),this._cornerRadius=t;}},{key:"cornerIteration",get:function(){return this._cornerIteration},set:function(t){this.setDirty(this._cornerIteration!=t),this._cornerIteration=t;}},{key:"modifyStyle",value:function(t){return t.hasOwnProperty("color")&&this.setColor(t.color,Q("color2",t,this),Q("horizontalGradient",t,this)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,Q("strokeThickness",t,this)),t.hasOwnProperty("cornerRadius")&&this.setCornerRadius(t.cornerRadius,Q("cornerIteration",t,this)),this}},{key:"modifyPorperties",value:function(t){return u(s(h.prototype),"modifyPorperties",this).call(this,t),this.modifyStyle(t),this}},{key:"setCornerRadius",value:function(t,e){return this.cornerRadius=t,this.cornerIteration=e,this}},{key:"renderContent",value:function(){!function(t,e,i,r,n,s,h,o){if(null!=e||null!=i){var a=t.canvas.width,l=t.canvas.height;null==i&&(r=0);var u=r/2;a=Math.max(1,a-r),l=Math.max(1,l-r),at(t.canvas,t.context,u,u,a,l,n,e,i,r,s,h,o);}}(this.parent,this.color,this.stroke,this.strokeThickness,this.cornerRadius,this.color2,this.horizontalGradient,this.cornerIteration);}}]),h}(q),ct=Phaser.Utils.Objects.GetValue,dt=function(t){n(h,t);var i=a(h);function h(t,r){var n;return e(this,h),(n=i.call(this,t,"innerbounds")).setScrollFactor(0),n.setColor(ct(r,"color",null),ct(r,"color2",null),ct(r,"horizontalGradient",!0)),n.setStroke(ct(r,"stroke",null),ct(r,"strokeThickness",2)),n}return r(h,[{key:"color",get:function(){return this._color},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t;}},{key:"color2",get:function(){return this._color2},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t;}},{key:"horizontalGradient",get:function(){return this._horizontalGradient},set:function(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t;}},{key:"setColor",value:function(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}},{key:"stroke",get:function(){return this._stroke},set:function(t){t=K(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t;}},{key:"strokeThickness",get:function(){return this._strokeThickness},set:function(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t;}},{key:"setStroke",value:function(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}},{key:"modifyPorperties",value:function(t){u(s(h.prototype),"modifyPorperties",this).call(this,t),t.hasOwnProperty("color")&&this.setColor(t.color,ct(t,"color2",null),ct(t,"horizontalGradient",!0)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,ct(t,"strokeThickness",2));}},{key:"renderContent",value:function(){var t=this.parent.padding,e=t.left,i=t.top,r=this.parent.width-t.left-t.right,n=this.parent.height-t.top-t.bottom,s=this.context;if(null!=this.color){var h,o;if(null!=this.color2)(o=this.horizontalGradient?s.createLinearGradient(0,0,r,0):s.createLinearGradient(0,0,0,n)).addColorStop(0,this.color),o.addColorStop(1,this.color2),h=o;else h=this.color;s.fillStyle=h,s.fillRect(e,i,r,n);}null!=this.stroke&&this.strokeThickness>0&&(s.strokeStyle=this.stroke,s.lineWidth=this.strokeThickness,s.strokeRect(e,i,r,n));}}]),h}(q),ft=Phaser.Utils.Objects.GetValue,yt=function(){function t(i,r){e(this,t),this.parent=i,this.set(r);}return r(t,[{key:"toJSON",value:function(){return {bold:this.bold,italic:this.italic,fontSize:this.fontSize,fontFamily:this.fontFamily,color:this.color,stroke:this.stroke,strokeThickness:this.strokeThickness,shaodwColor:this.shadowColor,shadowBlur:this.shadowBlur,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,offsetX:this.offsetX,offsetY:this.offsetY,leftSpace:this.leftSpace,rightSpace:this.rightSpace,backgroundHeight:this.backgroundHeight,backgroundBottomY:this.backgroundBottomY,align:this.align}}},{key:"set",value:function(t){return this.setBold(ft(t,"bold",!1)),this.setItalic(ft(t,"italic",!1)),this.setFontSize(ft(t,"fontSize","16px")),this.setFontFamily(ft(t,"fontFamily","Courier")),this.setColor(ft(t,"color","#fff")),this.setStrokeStyle(ft(t,"stroke",null),ft(t,"strokeThickness",0)),this.setShadow(ft(t,"shadowColor",null),ft(t,"shadowOffsetX",0),ft(t,"shadowOffsetY",0),ft(t,"shadowBlur",0)),this.setOffset(ft(t,"offsetX",0),ft(t,"offsetY",0)),this.setSpace(ft(t,"leftSpace",0),ft(t,"rightSpace",0)),this.setAlign(ft(t,"align",void 0)),this.setBackgroundColor(ft(t,"backgroundColor",null)),this.setBackgroundHeight(ft(t,"backgroundHeight",void 0)),this.setBackgroundBottomY(ft(t,"backgroundBottomY",void 0)),this}},{key:"modify",value:function(t){return t.hasOwnProperty("bold")&&this.setBold(t.bold),t.hasOwnProperty("italic")&&this.setItalic(t.italic),t.hasOwnProperty("fontSize")&&this.setFontSize(t.fontSize),t.hasOwnProperty("fontFamily")&&this.setFontFamily(t.fontFamily),t.hasOwnProperty("color")&&this.setColor(t.color),(t.hasOwnProperty("stroke")||t.hasOwnProperty("strokeThickness"))&&this.setStrokeStyle(Q("stroke",t,this),Q("strokeThickness",t,this)),t.hasOwnProperty("shadowColor")&&this.setShadowColor(t.shadowColor),(t.hasOwnProperty("shadowOffsetX")||t.hasOwnProperty("shadowOffsetY"))&&this.setShadowOffset(Q("shadowOffsetX",t,this),Q("shadowOffsetY",t,this)),t.hasOwnProperty("shadowBlur")&&this.setShadowBlur(t.shaodwBlur),t.hasOwnProperty("offsetX")&&this.setOffsetX(t.offsetX),t.hasOwnProperty("offsetY")&&this.setOffsetY(t.offsetY),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),t.hasOwnProperty("backgroundColor")&&this.setBackgroundColor(t.backgroundColor),t.hasOwnProperty("backgroundHeight")&&this.setBackgroundHeight(t.backgroundHeight),t.hasOwnProperty("backgroundBottomY")&&this.setBackgroundBottomY(t.backgroundBottomY),this}},{key:"setUpdateTextFlag",value:function(){return this.parent&&(this.parent.updateTextFlag=!0),this}},{key:"clone",value:function(){return new t(null,this.toJSON())}},{key:"copyFrom",value:function(t){return this.set(t.toJSON()),this}},{key:"copyTo",value:function(t){return t.set(this.toJSON()),this}},{key:"setBold",value:function(t){return void 0===t&&(t=!0),this.bold=t,this.setUpdateTextFlag(),this}},{key:"setItalic",value:function(t){return void 0===t&&(t=!0),this.italic=t,this.setUpdateTextFlag(),this}},{key:"fontStyle",get:function(){return this.bold&&this.italic?"bold italic":this.bold?"bold":this.italic?"italic":""}},{key:"setFontSize",value:function(t){return "number"==typeof t&&(t="".concat(t,"px")),this.fontSize=t,this.setUpdateTextFlag(),this}},{key:"setFontFamily",value:function(t){return this.fontFamily=t,this.setUpdateTextFlag(),this}},{key:"font",get:function(){return "".concat(this.fontStyle," ").concat(this.fontSize," ").concat(this.fontFamily)}},{key:"setColor",value:function(t){return this.color=K(t),this}},{key:"hasFill",get:function(){return null!=this.color}},{key:"setStrokeStyle",value:function(t,e){return this.stroke=K(t),void 0!==e&&(this.strokeThickness=e),this}},{key:"setStrokeThickness",value:function(t){return this.strokeThickness=t,this}},{key:"hasStroke",get:function(){return null!=this.stroke&&this.strokeThickness>0}},{key:"setShadowColor",value:function(t){return this.shadowColor=K(t),this}},{key:"setShadowOffset",value:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.shadowOffsetX=t,this.shadowOffsetY=e,this}},{key:"setShadowBlur",value:function(t){return void 0===t&&(t=0),this.shaodwBlur=t,this}},{key:"setShadow",value:function(t,e,i,r){return this.setShadowColor(t).setShadowOffset(e,i).setShadowBlur(r),this}},{key:"setBackgroundColor",value:function(t){return this.backgroundColor=K(t),this}},{key:"hasBackgroundColor",get:function(){return null!=this.backgroundColor}},{key:"setBackgroundHeight",value:function(t){return this.backgroundHeight=t,this}},{key:"setBackgroundBottomY",value:function(t){return this.backgroundBottomY=t,this}},{key:"setOffsetX",value:function(t){return void 0===t&&(t=0),this.offsetX=t,this}},{key:"setOffsetY",value:function(t){return void 0===t&&(t=0),this.offsetY=t,this}},{key:"setOffset",value:function(t,e){return this.setOffsetX(t).setOffsetY(e),this}},{key:"setLeftSpace",value:function(t){return void 0===t&&(t=0),this.leftSpace=t,this}},{key:"setRightSpace",value:function(t){return void 0===t&&(t=0),this.rightSpace=t,this}},{key:"setSpace",value:function(t,e){return this.setLeftSpace(t).setRightSpace(e),this}},{key:"setAlign",value:function(t){return this.align=t,this}},{key:"syncFont",value:function(t){return t.font=this.font,this}},{key:"syncStyle",value:function(t){t.textBaseline="alphabetic";var e=this.hasFill,i=this.hasStroke;return t.fillStyle=e?this.color:"#000",t.strokeStyle=i?this.stroke:"#000",t.lineWidth=i?this.strokeThickness:0,t.lineCap="round",t.lineJoin="round",this}},{key:"syncShadow",value:function(t){null!=t.shadowColor?(t.shadowColor=this.shadowColor,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowBlur=this.shadowBlur):(t.shadowColor=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0);}},{key:"getTextMetrics",value:function(t,e){return this.syncFont(t).syncStyle(t),t.measureText(e)}}]),t}(),gt=Phaser.Utils.Array.Remove,vt=Phaser.Utils.Array.Remove,pt="text",kt="image",wt="drawer",xt="space",bt="command",mt=function(t){return t.type===pt&&"\n"===t.text},St=function(t){return t.type===pt&&"\f"===t.text},Ct=function(t){return t.type===pt},Ot=function(t){n(h,t);var i=a(h);function h(t,r,n){var s;return e(this,h),(s=i.call(this,t,pt)).updateTextFlag=!1,s.style=new yt(o(s),n),s.setText(r),s}return r(h,[{key:"autoRound",get:function(){return this.parent.autoRound}},{key:"offsetX",get:function(){return this.style.offsetX},set:function(t){this.style&&(this.style.offsetX=t);}},{key:"offsetY",get:function(){return this.style.offsetY},set:function(t){this.style&&(this.style.offsetY=t);}},{key:"leftSpace",get:function(){return this.style.leftSpace*this.scaleX},set:function(t){this.style&&(this.style.leftSpace=t),d(s(h.prototype),"leftSpace",t,this,!0);}},{key:"rightSpace",get:function(){return this.style.rightSpace*this.scaleX},set:function(t){this.style&&(this.style.rightSpace=t),d(s(h.prototype),"rightSpace",t,this,!0);}},{key:"align",get:function(){return this.style.align},set:function(t){this.style&&(this.style.align=t);}},{key:"modifyStyle",value:function(t){return this.setDirty(!0),this.style.modify(t),this.updateTextFlag&&this.updateTextSize(),this}},{key:"modifyPorperties",value:function(t){return t?(this.modifyStyle(t),u(s(h.prototype),"modifyPorperties",this).call(this,t),this):this}},{key:"setText",value:function(t){return this.setDirty(this.text!=t),this.text=t,this.updateTextSize(),this}},{key:"updateTextSize",value:function(){var t=this.text;if("\n"===t||"\f"===t||""===t)this.clearTextSize();else {var e,i,r=this.style.getTextMetrics(this.context,this.text);this.textWidth=r.width,"actualBoundingBoxAscent"in r?(e=r.actualBoundingBoxAscent,i=r.actualBoundingBoxDescent):(e=0,i=0),this.textHeight=e+i,this.ascent=e,this.descent=i;}return this.updateTextFlag=!1,this}},{key:"clearTextSize",value:function(){return this.textWidth=0,this.textHeight=0,this.ascent=0,this.descent=0,this}},{key:"copyTextSize",value:function(t){return this.textWidth=t.textWidth,this.textHeight=t.textHeight,this.ascent=t.ascent,this.descent=t.descent,this}},{key:"width",get:function(){return this.textWidth*this.scaleX},set:function(t){this.textWidth>0?this.scaleX=t/this.textWidth:this.scaleX=1;}},{key:"height",get:function(){return this.textHeight*this.scaleY},set:function(t){this.textHeight>0?this.scaleY=t/this.textHeight:this.scaleY=1;}},{key:"willRender",get:function(){return 0!==this.textWidth&&u(s(h.prototype),"willRender",this)}},{key:"renderContent",value:function(){var t=this.context,e=this.style;if(e.hasBackgroundColor){t.fillStyle=e.backgroundColor;var i=this.drawTLX,r=this.drawTRX-i,n=e.backgroundBottomY;null==n&&(n=this.drawBLY);var s=e.backgroundHeight;null==s&&(s=n-this.drawTLY);var h=n-s;t.fillRect(i,h,r,s);}var o=e.hasFill,a=e.hasStroke;(o||a)&&(e.syncFont(t).syncStyle(t),a&&(e.syncShadow(t),t.strokeText(this.text,0,0)),o&&(e.syncShadow(t),t.fillText(this.text,0,0)));}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return -this.ascent}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.descent}},{key:"drawTRX",get:function(){return this.textWidth+this.rightSpace}},{key:"drawTRY",get:function(){return -this.ascent}},{key:"drawBRX",get:function(){return this.textWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.descent}}]),h}(q),Pt=function(t,e){var i=this.createCharChildren(t,e);return this.addChild(i),this},Tt=function(t){n(s,t);var i=a(s);function s(t,r,n){var h;return e(this,s),(h=i.call(this,t,kt)).setTexture(r,n),h}return r(s,[{key:"frameWidth",get:function(){return this.frameObj?this.frameObj.cutWidth:0}},{key:"frameHeight",get:function(){return this.frameObj?this.frameObj.cutHeight:0}},{key:"offsetY",get:function(){return -this.height},set:function(t){}},{key:"key",get:function(){return this._key},set:function(t){this.setDirty(this._key!=t),this._key=t;}},{key:"frame",get:function(){return this._frame},set:function(t){this.setDirty(this._frame!=t),this._frame=t;}},{key:"setTexture",value:function(t,e){return this.key=t,this.frame=e,this.frameObj=this.scene.sys.textures.getFrame(t,e),this}},{key:"width",get:function(){return this.frameWidth*this.scaleX},set:function(t){this.setDirty(this.width!==t),this.scaleX=t/this.frameWidth;}},{key:"height",get:function(){return this.frameHeight*this.scaleY},set:function(t){this.setDirty(this.height!==t),this.scaleY=t/this.frameHeight;}},{key:"setHeight",value:function(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}},{key:"renderContent",value:function(){var t=this.context,e=this.frameObj,i=this.frameWidth,r=this.frameHeight;t.drawImage(e.source.image,e.cutX,e.cutY,i,r,0,0,i,r);}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.frameHeight}},{key:"drawTRX",get:function(){return this.frameWidth+this.rightSpace}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return this.frameWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.frameHeight}}]),s}(q),_t=function(t){n(h,t);var i=a(h);function h(t,r,n,s){var o;return e(this,h),(o=i.call(this,t,wt)).setRenderCallback(r),o.setDrawerSize(n,s),o}return r(h,[{key:"setRenderCallback",value:function(t){return t?this.renderContent=t.bind(this):delete this.renderContent,this}},{key:"setDrawerSize",value:function(t,e){return !0===t?(this.toLocalPosition=!1,t=void 0,e=void 0):this.toLocalPosition=!0,void 0===t&&(t=0),void 0===e&&(e=t),this.drawerWidth=t,this.drawerHeight=e,this}},{key:"onFree",value:function(){u(s(h.prototype),"onFree",this).call(this),this.setRenderCallback();}},{key:"width",get:function(){return this.drawerWidth*this.scaleX},set:function(t){this.setDirty(this.width!==t),this.scaleX=this.drawerWidth>0?t/this.drawerWidth:1;}},{key:"height",get:function(){return this.drawerHeight*this.scaleY},set:function(t){this.setDirty(this.height!==t),this.scaleY=this.drawerHeight>0?t/this.drawerHeight:1;}},{key:"offsetY",get:function(){return -this.height},set:function(t){}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.drawerHeight}},{key:"drawTRX",get:function(){return this.drawerWidth+this.rightSpace}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return this.drawerWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.drawerHeight}}]),h}(q),Yt=function(t){n(s,t);var i=a(s);function s(t,r){var n;return e(this,s),(n=i.call(this,t,xt)).setSpaceWidth(r),n}return r(s,[{key:"width",get:function(){return this.spaceWidth*this.scaleX},set:function(t){this.spaceWidth>0?this.scaleX=t/this.spaceWidth:this.scaleX=1;}},{key:"setSpaceWidth",value:function(t){return this.spaceWidth=t,this}}]),s}(q),Xt=function(t){n(h,t);var i=a(h);function h(t,r,n,s,o){var a;return e(this,h),(a=i.call(this,t,bt)).setName(r).setParameter(s).setCallback(n,o),a}return r(h,[{key:"setName",value:function(t){return this.name=t,this}},{key:"setParameter",value:function(t){return this.param=t,this}},{key:"setCallback",value:function(t,e){return this.callback=t,this.scope=e,this}},{key:"exec",value:function(){return this.scope?this.callback.call(this.scope,this.param,this.name):this.callback(this.param,this.name)}},{key:"onFree",value:function(){u(s(h.prototype),"onFree",this).call(this),this.setName().setCallback().setParameter();}}]),h}(Y),Rt=function e(i){var r,n,s;if(null==i||"object"!==t(i))return i;if(r=Array.isArray(i)?[]:{},function(e){if("object"!==t(e)||e.nodeType||e===e.window)return !1;try{if(e.constructor&&!{}.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return !1}catch(t){return !1}return !0}(i))for(s in i)n=i[s],r[s]=e(n);else r=i;return r},Bt=function(t){var e={callback:void 0,start:0,isLastPage:!1,maxLines:void 0,padding:void 0,letterSpacing:void 0,hAlign:void 0,vAlign:void 0,children:[],lines:[],maxLineWidth:0,linesHeight:0,lineHeight:void 0,maxLineHeight:0,linesWidth:0,lineWidth:void 0};return Object.assign(e,t)},At=function(t,e,i,r){void 0===r&&(r={word:[],width:0}),r.word.length=0;for(var n=t.length,s=e,h=r.word,o=0;s<n;){var a=t[s];if(a.renderable){var l=a.type===pt?a.text:null;if(null===l||" "===l||"\n"===l||"\f"===l){s===e&&(h.push(a),o+=a.outerWidth);break}if(h.push(a),o+=a.outerWidth,s++,i)break}else h.push(a),s++;}return r.width=o,r},Wt=function(t){for(var e=0,i=t.length;e<i;e++){var r=t[e];if(void 0!==r.align)return r.align}},Dt=function(t,e,i){if(0!==e||0!==i)for(var r=0,n=t.length;r<n;r++){var s=t[r];s.renderable&&(s.x+=e,s.y+=i);}},Ht=function(){var t,e,i=this.defaultTextStyle.getTextMetrics(this.context,this.testString);return "actualBoundingBoxAscent"in i?(t=i.actualBoundingBoxAscent,e=i.actualBoundingBoxDescent):(t=0,e=0),Lt.ascent=t,Lt.descent=e,Lt.height=t+e,Lt},Lt={},Mt=Phaser.Utils.Objects.GetValue,jt=function(t){var e=Mt(t,"start",0);T(this.wrapPadding,Mt(t,"padding",0));var i,r=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,n=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,s=Mt(t,"lineHeight"),h=Mt(t,"ascent",s);if(void 0===s){var o=Mt(t,"useDefaultTextHeight",!1);if(i=Mt(t,"maxLines",0),this.fixedHeight>0&&!o){var a=this.fixedHeight-r;if(i>0)s=a/i;else s=(l=Ht.call(this)).height,h=l.ascent,i=Math.floor((a-h)/s);}else {var l;s=(l=Ht.call(this)).height,h=l.ascent;}}else if(this.fixedHeight>0){if(void 0===(i=Mt(t,"maxLines"))){a=this.fixedHeight-r;i=Math.floor(a/s);}}else i=Mt(t,"maxLines",0);void 0===h&&(h=s);var u=0===i,c=Mt(t,"wrapWidth",void 0);void 0===c&&(c=this.fixedWidth>0?this.fixedWidth-n:1/0);for(var d=Mt(t,"letterSpacing",0),f=Mt(t,"hAlign",0),y=Mt(t,"vAlign",0),g=Mt(t,"charWrap",!1),v=Bt({callback:"runWordWrap",start:e,padding:this.wrapPadding,letterSpacing:d,maxLines:i,hAlign:f,vAlign:y,ascent:h,lineHeight:s,wrapWidth:c,charWrap:g}),p=this.children,k=0,w=p.length;k<w;k++)p[k].setActive(!1);c+=d;for(var x,b=this.padding.left+this.wrapPadding.left,m=b,S=this.padding.top+this.wrapPadding.top+h,C=c,O=e,P=p.length,_=v.children,Y=v.lines,X=[],R=0,B=0,A=!1;O<P;){var W=(x=At(p,O,g,x)).word,D=W.length,H=x.width+D*d;O+=D;var L=mt(W[0]);A=St(W[0]);var M=L||A;if(C<H||M){if(M){var j=W[0];j.setActive().setPosition(m,S),_.push(j),X.push(j);}if(m=b,S+=s,C=c,Y.push({children:X,width:R}),B=Math.max(B,R),R=0,X=[],A||!u&&Y.length===i)break;if(M)continue}C-=H,R+=H;for(k=0,w=W.length;k<w;k++){(G=W[k]).setActive(),_.push(G),X.push(G),G.renderable&&(G.setPosition(m,S),m+=G.outerWidth+d);}}X.length>0&&(Y.push({children:X,width:R}),B=Math.max(B,R)),v.start+=_.length,v.isLastPage=!A&&v.start===P,v.maxLineWidth=B,v.linesHeight=Y.length*s;var F=this.fixedWidth>0?this.fixedWidth:v.maxLineWidth+n,z=this.fixedHeight>0?this.fixedHeight:v.linesHeight+r;!function(t,e,i){var r,n,s=t.hAlign,h=t.vAlign,o=t.linesHeight;switch(h){case 1:case"center":n=(i-o)/2;break;case 2:case"bottom":n=i-o;break;default:n=0;}for(var a=t.lines,l=0,u=a.length;l<u;l++){var c=a[l],d=c.width,f=c.children,y=Wt(f);switch(void 0===y&&(y=s),y){case 1:case"center":r=(e-d)/2;break;case 2:case"right":r=e-d;break;default:r=0;}Dt(f,r,n);}}(v,F-n,a=z-r),this.setCanvasSize(F,z);for(k=0,w=_.length;k<w;k++){var G;(G=_[k]).renderable&&(G.x0=G.x,G.y0=G.y);}return v},Ft=Phaser.Utils.Objects.Merge,zt=Phaser.Utils.Objects.GetValue,Gt=function(t){var e=zt(t,"start",0);T(this.wrapPadding,zt(t,"padding",0));var i,r=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,n=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,s=zt(t,"lineWidth",void 0);if(void 0===s)i=zt(t,"maxLines",0),s=this.fixedWidth>0?(h=this.fixedWidth-n)/i:0;else if(this.fixedWidth>0){if(void 0===(i=zt(t,"maxLines",void 0))){var h=this.fixedWidth-n;i=Math.floor(h/s)+1;}}else i=zt(t,"maxLines",0);var o=0===i,a=zt(t,"fixedCharacterHeight",void 0);if(void 0===a){var l=zt(t,"charPerLine",void 0);if(void 0!==l){var u=this.fixedHeight-r;a=Math.floor(u/l);}}var c=zt(t,"wrapHeight",void 0);void 0===c&&(c=this.fixedHeight>0?this.fixedHeight-r:1/0);for(var d=zt(t,"letterSpacing",0),f=zt(t,"rtl",!0),y=zt(t,"hAlign",f?2:0),g=zt(t,"vAlign",0),v=Bt({callback:"runVerticalWrap",start:e,padding:this.wrapPadding,letterSpacing:d,maxLines:i,hAlign:y,vAlign:g,lineWidth:s,fixedCharacterHeight:a,wrapHeight:c,rtl:f}),p=this.children,k=0,w=p.length;k<w;k++)p[k].setActive(!1);c+=d;for(var x=this.padding.left+this.wrapPadding.left,b=this.padding.top+this.wrapPadding.top,m=x,S=b,C=c,O=e,P=p.length,_=v.children,Y=v.lines,X=[],R=0,B=0;O<P;){var A=p[O];if(O++,A.renderable){var W=(void 0!==a?a:A.height)+d,D=mt(A),H=St(A),L=D||H;if(C<W||L){if(D&&(A.setActive().setPosition(m,S).setOrigin(.5),_.push(A),X.push(A)),m=x,S=b,C=c,Y.push({children:X,height:R}),B=Math.max(B,R),R=0,X=[],H||!o&&Y.length===i)break;if(L)continue}C-=W,R+=W,A.setActive().setPosition(m,S).setOrigin(.5),_.push(A),X.push(A),S+=W;}else A.setActive(),_.push(A),X.push(A);}X.length>0&&(Y.push({children:X,height:R}),B=Math.max(B,R)),v.start+=_.length,v.isLastPage=v.start===P,v.maxLineHeight=B,v.linesWidth=Y.length*s;var M=this.fixedWidth>0?this.fixedWidth:v.linesWidth+n,j=this.fixedHeight>0?this.fixedHeight:v.maxLineHeight+r;!function(t,e,i){var r,n,s=t.hAlign,h=t.vAlign,o=t.rtl,a=t.lines,l=t.lineWidth,u=t.linesWidth;switch(s){case 1:case"center":r=(e-u)/2;break;case 2:case"right":r=e-u;break;default:r=0;}o&&(r+=l);for(var c=0,d=a.length;c<d;c++){var f=a[o?d-c-1:c],y=f.children,g=f.height,v=Wt(y);switch(void 0===v&&(v=h),v){case 1:case"center":n=(i-g)/2;break;case 2:case"bottom":n=i-g;break;default:n=0;}Dt(y,r,n),r+=l;}}(v,h=M-n,u=j-r),this.setCanvasSize(M,j);for(k=0,w=_.length;k<w;k++){(A=_[k]).renderable&&(A.x0=A.x,A.y0=A.y);}return v},It=Phaser.Utils.Objects.Merge,Ut=Phaser.Utils.Objects.GetValue,Et=Phaser.Utils.Array.GetAll,Vt=Phaser.Math.Distance.BetweenPointsSquared,Nt=function(t,e,i){for(var r=0,n=(t=t).length;r<n;r++){var s=t[r];if(s.active&&s.renderable&&s.contains(e,i))return s}return null},Jt=function(){return this.on("pointerdown",qt,this).on("pointerdown",$t,this).on("pointermove",Kt,this).on("pointerover",Kt,this).on("pointerout",(function(t,e){Kt.call(this,t,null,null,e);}),this),this},qt=function(t,e,i,r){if(this.childrenInteractiveEnable){var n=Nt(this.children,e,i);n&&this.emit("child.pointerdown",n,t,e,i,r);}},$t=function(t,e,i,r){if(this.childrenInteractiveEnable){var n=Nt(this.children,e,i);n&&this.emit("child.pointerup",n,t,e,i,r);}},Kt=function(t,e,i,r){if(this.childrenInteractiveEnable)if(null!==e){var n=Nt(this.children,e,i);n!==this.lastOverChild&&(null!==this.lastOverChild&&this.emit("child.pointerout",this.lastOverChild,t,e,i,r),null!==n&&this.emit("child.pointerover",n,t,e,i,r),this.lastOverChild=n);}else null!==this.lastOverChild&&(this.emit("child.pointerout",this.lastOverChild,t,e,i,r),this.lastOverChild=null);},Qt=Phaser.GameObjects.GameObject,Zt=Phaser.Utils.Array.BringToTop,te=Phaser.Utils.Array.SendToBack,ee=Phaser.Utils.Array.MoveUp,ie=Phaser.Utils.Array.MoveDown,re=Phaser.Utils.Array.MoveAbove,ne=Phaser.Utils.Array.MoveBelow,se={moveChildToFist:function(t){return te(this.children,t),this},moveChildToLast:function(t){return Zt(this.children,t),this},movechildUp:function(t){return ee(this.children,t),this},movechildDown:function(t){return ie(this.children,t),this},movechildAbove:function(t,e){return re(this.children,t,e),this},movechildBelow:function(t,e){return ne(this.children,t,e),this}},he={setFixedSize:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fixedWidth===t&&this.fixedHeight===e||(this.fixedWidth=t,this.fixedHeight=e,this.dirty=!0,this.setCanvasSize(t>0?t:this.width,e>0?e:this.height)),this},setPadding:function(t,e){var i=this.padding,r=i.left,n=i.right,s=i.top,h=i.bottom;return T(i,t,e),this.dirty=th