@vpmedia/phaser 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/phaser.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see phaser.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(self,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AnimationManager:()=>jt,AnimationParser:()=>r,ArraySet:()=>ni,BitmapText:()=>Mh,Button:()=>Oh,CanvasBuffer:()=>Li,CanvasGraphics:()=>m,CanvasMasker:()=>w,CanvasPool:()=>l,CanvasRenderer:()=>vh,CanvasTinter:()=>d,CanvasUtils:()=>y,Circle:()=>hs,CircleUtils:()=>p,Const:()=>i,DOM:()=>xi,Device:()=>hi,DeviceUtils:()=>o,DisplayObject:()=>Hi,EarCut:()=>f,Ellipse:()=>as,EllipseUtils:()=>g,EventManager:()=>yi,Frame:()=>ei,FrameData:()=>ti,Game:()=>Nh,GameLoopRAF:()=>an,GraphicsData:()=>ls,Group:()=>Rh,Image:()=>Yi,InputMSPointer:()=>sn,InputManager:()=>rn,InputMouse:()=>en,InputPointer:()=>nn,InputTouch:()=>hn,Line:()=>sh,LineUtils:()=>v,Loader:()=>on,MathUtils:()=>h,Matrix:()=>Ti,MatrixUtils:()=>a,Point:()=>pe,PointUtils:()=>s,Polygon:()=>$i,PolygonUtils:()=>c,Rectangle:()=>ke,RectangleUtils:()=>n,RoundedRectangle:()=>qi,RoundedRectangleUtils:()=>u,ScaleManager:()=>ln,Scene:()=>dn,SceneManager:()=>un,Signal:()=>Yt,SignalBinding:()=>Xt,Sound:()=>cn,SoundManager:()=>gn,SoundSprite:()=>pn,StringUtils:()=>x,Text:()=>Fh,Time:()=>_n,Timer:()=>fn,TimerEvent:()=>mn,Tween:()=>xn,TweenData:()=>vn,TweenEasing:()=>_,TweenManager:()=>$n});var i={};t.r(i),t.d(i,{BITMAP_TEXT:()=>Et,BLEND_ADD:()=>Z,BLEND_COLOR:()=>ct,BLEND_COLOR_BURN:()=>ht,BLEND_COLOR_DODGE:()=>nt,BLEND_DARKEN:()=>it,BLEND_DIFFERENCE:()=>at,BLEND_EXCLUSION:()=>lt,BLEND_HARD_LIGHT:()=>rt,BLEND_HUE:()=>dt,BLEND_LIGHTEN:()=>st,BLEND_LUMINOSITY:()=>pt,BLEND_MULTIPLY:()=>J,BLEND_NORMAL:()=>$,BLEND_OVERLAY:()=>et,BLEND_SATURATION:()=>ut,BLEND_SCREEN:()=>tt,BLEND_SOFT_LIGHT:()=>ot,BOTTOM_CENTER:()=>R,BOTTOM_LEFT:()=>O,BOTTOM_RIGHT:()=>I,BUTTON:()=>Ct,CENTER:()=>E,FILTER_CANVAS:()=>Lt,FILTER_WEBGL:()=>Ot,GEOM_CIRCLE:()=>Ut,GEOM_ELLIPSE:()=>Bt,GEOM_LINE:()=>Gt,GEOM_MATRIX:()=>Wt,GEOM_POINT:()=>Ht,GEOM_POLYGON:()=>It,GEOM_RECTANGLE:()=>Ft,GEOM_ROUNDED_RECTANGLE:()=>Nt,GRAPHICS:()=>Pt,GROUP:()=>bt,IMAGE:()=>Mt,LEFT_BOTTOM:()=>A,LEFT_CENTER:()=>P,LEFT_TOP:()=>M,MOUSE_OVERRIDES_TOUCH:()=>xt,MOUSE_TOUCH_COMBINE:()=>wt,PENDING_ATLAS:()=>zt,POINTER:()=>Rt,POINTER_CONTACT:()=>vt,POINTER_CURSOR:()=>_t,RENDER_AUTO:()=>gt,RENDER_CANVAS:()=>mt,RENDER_TEXTURE:()=>Dt,RENDER_WEBGL:()=>ft,RIGHT_BOTTOM:()=>L,RIGHT_CENTER:()=>D,RIGHT_TOP:()=>k,SCALE_EXACT_FIT:()=>B,SCALE_LINEAR:()=>F,SCALE_NEAREST:()=>U,SCALE_OFF:()=>N,SCALE_RESIZE:()=>W,SCALE_SHOW_ALL:()=>G,SCALE_USER:()=>H,SPRITE:()=>St,SPRITE_BATCH:()=>Tt,TEXT:()=>At,TILE_SPRITE:()=>kt,TIME_HALF:()=>Y,TIME_MINUTE:()=>z,TIME_QUARTER:()=>j,TIME_SECOND:()=>X,TOP_CENTER:()=>T,TOP_LEFT:()=>S,TOP_RIGHT:()=>C,TOUCH_OVERRIDES_MOUSE:()=>yt,TWEEN_COMPLETE:()=>Q,TWEEN_LOOPED:()=>K,TWEEN_PENDING:()=>V,TWEEN_RUNNING:()=>q});var s={};t.r(s),t.d(s,{add:()=>Vt,angle:()=>Zt,centroid:()=>de,clone:()=>ce,distance:()=>ne,divide:()=>Qt,equals:()=>$t,interpolate:()=>ee,multiply:()=>Kt,multiplyAdd:()=>te,negative:()=>Jt,normalRightHand:()=>oe,normalize:()=>ae,parse:()=>ue,perp:()=>ie,project:()=>he,projectUnit:()=>re,rotate:()=>le,rperp:()=>se,subtract:()=>qt});var n={};t.r(n),t.d(n,{aabb:()=>Ae,clone:()=>_e,contains:()=>ve,containsPoint:()=>ye,containsRaw:()=>xe,containsRect:()=>we,equals:()=>be,getEmptyRectangle:()=>Ee,inflate:()=>ge,inflatePoint:()=>me,intersection:()=>Ce,intersects:()=>Te,intersectsRaw:()=>Me,sameDimensions:()=>Se,size:()=>fe,union:()=>Pe});var h={};t.r(h),t.d(h,{DEG_TO_RAD:()=>De,PI_2:()=>Oe,RAD_TO_DEG:()=>Le,between:()=>Ge,degToRad:()=>Be,difference:()=>Xe,distance:()=>je,getColor:()=>Ke,getColor32:()=>qe,getNextPowerOfTwo:()=>Fe,getRGB:()=>Ze,hex2rgb:()=>Re,hexToColor:()=>Qe,isPowerOfTwo:()=>Ue,linear:()=>ze,linearInterpolation:()=>Ye,radToDeg:()=>Ne,rgb2hex:()=>Ie,snapToCeil:()=>We,valueToColor:()=>Je,webToColor:()=>$e,within:()=>Ve,wrap:()=>He});var r={};t.r(r),t.d(r,{JSONDataHash:()=>si,spriteSheet:()=>ii});var o={};t.r(o),t.d(o,{canPlayAudio:()=>ri,checkAudio:()=>ui,checkBrowser:()=>di,checkDevice:()=>ci,checkFullScreenSupport:()=>li,checkInput:()=>ai,checkOS:()=>oi,initialize:()=>pi});var a={};t.r(a),t.d(a,{clone:()=>wi,getIdentityMatrix:()=>bi,getTempMatrix:()=>Si});var l={};t.r(l),t.d(l,{create:()=>Di,getFirst:()=>Mi,getFree:()=>ki,getPool:()=>Ci,getTotal:()=>Ei,remove:()=>Pi,removeByCanvas:()=>Ai});var d={};t.r(d),t.d(d,{canUseNewCanvasBlendModes:()=>Ui,checkInverseAlpha:()=>Fi,detectCapabilities:()=>Bi,getTintedTexture:()=>Oi,tintWithMultiply:()=>Ri,tintWithPerPixel:()=>Ii});var u={};t.r(u),t.d(u,{clone:()=>Vi,default:()=>ji});var c={};t.r(c),t.d(c,{clone:()=>Qi,default:()=>Ki});var p={};t.r(p),t.d(p,{circumferencePoint:()=>is,clone:()=>Zi,contains:()=>Ji,equals:()=>ts,intersects:()=>es,intersectsPoint:()=>ss,intersectsRectangle:()=>ns});var g={};t.r(g),t.d(g,{contains:()=>os,default:()=>rs});var m={};t.r(m),t.d(m,{renderGraphics:()=>ps,renderGraphicsMask:()=>gs,updateGraphicsTint:()=>cs});var f={};t.r(f),t.d(f,{area:()=>Ss,compareX:()=>vs,cureLocalIntersections:()=>Gs,earcutLinked:()=>Hs,eliminateHole:()=>Bs,eliminateHoles:()=>Ns,equals:()=>Ts,filterPoints:()=>Fs,findHoleBridge:()=>Us,getLeftmost:()=>ws,indexCurve:()=>ys,insertNode:()=>Ds,intersects:()=>Cs,intersectsPolygon:()=>Ms,isEar:()=>Os,isEarHashed:()=>Rs,isValidDiagonal:()=>Es,linkedList:()=>Is,locallyInside:()=>Ps,middleInside:()=>As,pointInTriangle:()=>bs,removeNode:()=>Ls,sortLinked:()=>_s,splitEarcut:()=>Ws,splitPolygon:()=>ks,triangulate:()=>zs,zOrder:()=>xs});var _={};t.r(_),t.d(_,{BackIn:()=>Yn,BackInOut:()=>Vn,BackOut:()=>jn,BounceIn:()=>Kn,BounceInOut:()=>Qn,BounceOut:()=>qn,CircularIn:()=>Nn,CircularInOut:()=>Wn,CircularOut:()=>Gn,CubicIn:()=>Tn,CubicInOut:()=>Mn,CubicOut:()=>Cn,ElasticIn:()=>Hn,ElasticInOut:()=>Xn,ElasticOut:()=>zn,ExponentialIn:()=>Fn,ExponentialInOut:()=>Bn,ExponentialOut:()=>Un,LinearNone:()=>yn,QuadraticIn:()=>wn,QuadraticInOut:()=>Sn,QuadraticOut:()=>bn,QuarticIn:()=>Pn,QuarticInOut:()=>En,QuarticOut:()=>An,QuinticIn:()=>kn,QuinticInOut:()=>Ln,QuinticOut:()=>Dn,SinusoidalIn:()=>On,SinusoidalInOut:()=>In,SinusoidalOut:()=>Rn});var v={};t.r(v),t.d(v,{clone:()=>Zn,intersects:()=>th,intersectsPoints:()=>Jn,intersectsRectangle:()=>eh,reflect:()=>ih});var x={};t.r(x),t.d(x,{generateID:()=>nh,generateShaderID:()=>rh,generateUUID:()=>hh});var y={};t.r(y),t.d(y,{addToDOM:()=>uh,create:()=>oh,getSmoothingPrefix:()=>gh,removeFromDOM:()=>ch,setBackgroundColor:()=>ah,setSmoothingEnabled:()=>mh,setTouchAction:()=>lh,setTransform:()=>ph,setUserSelect:()=>dh});var w={};t.r(w),t.d(w,{popMask:()=>_h,pushMask:()=>fh});var b={};t.r(b),t.d(b,{popMask:()=>Th,pushMask:()=>Sh});const S=0,T=1,C=2,M=3,P=4,A=5,E=6,k=7,D=8,L=9,O=10,R=11,I=12,F=0,U=1,B=0,N=1,G=2,W=3,H=4,z=6e4,X=1e3,Y=500,j=250,V=0,q=1,K=2,Q=3,$=0,Z=1,J=2,tt=3,et=4,it=5,st=6,nt=7,ht=8,rt=9,ot=10,at=11,lt=12,dt=13,ut=14,ct=15,pt=16,gt=0,mt=1,ft=2,_t=1,vt=2,xt=0,yt=1,wt=2,bt=7,St=0,Tt=17,Ct=1,Mt=2,Pt=3,At=4,Et=6,kt=5,Dt=8,Lt=14,Ot=15,Rt=19,It=12,Ft=22,Ut=21,Bt=16,Nt=26,Gt=23,Wt=24,Ht=25,zt=-1,Xt=class{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;this._signal=t,this._listener=e,this._args=h,this._priority=n,this._isOnce=i,this.context=s,this.callCount=0,this.active=!0,this.params=null}execute(t){let e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,this._args&&(i=i.concat(this._args)),e=this._listener.apply(this.context,i),this.callCount+=1,this._isOnce&&this.detach()),e}detach(){return this.isBound()?this._signal.remove(this._listener,this.context):null}isBound(){return!!this._signal&&!!this._listener}isOnce(){return this._isOnce}getListener(){return this._listener}getSignal(){return this._signal}_destroy(){delete this._signal,delete this._listener,delete this.context}toString(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},Yt=class{constructor(){this._bindings=null,this._prevParams=null,this.memorize=!1,this._shouldPropagate=!0,this.active=!0,this._boundDispatch=!1}validateListener(t,e){if("function"!=typeof t)throw new Error("Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}_registerListener(t,e,i,s,n){const h=this._indexOfListener(t,i);let r;if(-1!==h){if(r=this._bindings[h],r.isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else r=new Xt(this,t,e,i,s,n),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r}_addBinding(t){this._bindings||(this._bindings=[]);let e=this._bindings.length;do{e-=1}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)}_indexOfListener(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this._bindings)return-1;let i,s=this._bindings.length;for(;s;)if(s-=1,i=this._bindings[s],i._listener===t&&i.context===e)return s;return-1}has(t,e){return-1!==this._indexOfListener(t,e)}add(t,e,i){this.validateListener(t,"add");for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this._registerListener(t,!1,e,i,n)}addOnce(t,e,i){this.validateListener(t,"addOnce");for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this._registerListener(t,!0,e,i,n)}remove(t,e){this.validateListener(t,"remove");const i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t}removeAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._bindings)return;let e=this._bindings.length;for(;e;)e-=1,t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)}getNumListeners(){return this._bindings?this._bindings.length:0}halt(){this._shouldPropagate=!1}dispatch(){if(!this.active||!this._bindings)return;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=e.slice();let n=this._bindings.length;if(this.memorize&&(this._prevParams=s),!n)return;const h=this._bindings.slice();this._shouldPropagate=!0;do{n-=1}while(h[n]&&this._shouldPropagate&&!1!==h[n].execute(s))}forget(){this._prevParams&&(this._prevParams=null)}dispose(){this.removeAll(),this.forget(),this._bindings=null}toString(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}get boundDispatch(){const t=this;return this._boundDispatch||(this._boundDispatch=function(){return t.dispatch(...arguments)}),this._boundDispatch}},jt=class{constructor(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]}destroy(){const t=Object.keys(this._anims);for(let e=0;e<t.length;e+=1)this._anims[t[e]].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}loadFrameData(t,e){if(!t)return!1;if(this.isLoaded){const e=Object.keys(this._anims);for(let i=0;i<e.length;i+=1){const s=e[i];this._anims[s].updateFrameData(t)}}return this._frameData=t,null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0}copyFrameData(t,e){if(this._frameData=t.clone(),this.isLoaded){const t=Object.keys(this._anims);for(let e=0;e<t.length;e+=1){const i=t[e];this._anims[i].updateFrameData(this._frameData)}}return null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0}add(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;const h=e||[];return void 0===n&&(n=!(!h||"number"!=typeof h[0])),this._outputFrames=[],this._frameData.getFrameIndexes(h,n,this._outputFrames),this._anims[t]=new class{constructor(t,e,i,s,n,h){let r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];this.game=t,this._parent=e,this._frameData=s,this.name=i,this._frames=[],this._frames=this._frames.concat(n),this.delay=1e3/h,this.loop=r,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new Yt,this.onUpdate=null,this.onComplete=new Yt,this.onLoop=new Yt,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)}play(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this}restart(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)}reverse(){return this.reversed=!this.reversed,this}reverseOnce(){return this.onComplete.addOnce(this.reverse,this),this.reverse()}setFrame(t){let e,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("string"==typeof t)for(let i=0;i<this._frames.length;i+=1)this._frameData.getFrame(this._frames[i]).name===t&&(e=i);else if("number"==typeof t)if(i)e=t;else for(let i=0;i<this._frames.length;i+=1)this._frames[i]===t&&(e=i);e&&(this._frameIndex=e-1,this._timeNextFrame=this.game.time.time,this.update())}stop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.isPlaying=!1,this.isFinished=!0,this.paused=!1,t&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this.currentFrame&&this._parent.setFrame(this.currentFrame)),e&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))}onPause(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)}onResume(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)}update(){return!this.isPaused&&!!(this.isPlaying&&this.game.time.time>=this._timeNextFrame)&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount+=1,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))}updateCurrentFrame(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._frameData||!this.currentFrame)return!1;const i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||!e&&i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)}next(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))}previous(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e+=1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))}updateFrameData(t){this._frameData=t,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null}destroy(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())}complete(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}get paused(){return this.isPaused}set paused(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}get reversed(){return this.isReversed}set reversed(t){this.isReversed=t}get frameTotal(){return this._frames.length}get frame(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex}set frame(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}get speed(){return 1e3/this.delay}set speed(t){t>0&&(this.delay=1e3/t)}get enableUpdate(){return null!==this.onUpdate}set enableUpdate(t){t&&null===this.onUpdate?this.onUpdate=new Yt:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}(this.game,this.sprite,t,this._frameData,this._outputFrames,i,s),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]}validateFrames(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(let i=0;i<t.length;i+=1)if(!0===e){if(t[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0}play(t,e,i,s){return this._anims[t]?this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s)):null}stop(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)}update(){return!(this.updateIfVisible&&!this.sprite.visible||!this.currentAnim||!this.currentAnim.update()||(this.currentFrame=this.currentAnim.currentFrame,0))}next(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)}previous(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)}getAnimation(t){return t&&this._anims[t]?this._anims[t]:null}refreshFrame(){console.warn("animation_manager.refreshFrame() is not implemented")}get frameData(){return this._frameData}get frameTotal(){return this._frameData.total}get paused(){return this.currentAnim.isPaused}set paused(t){this.currentAnim.paused=t}get name(){return this.currentAnim?this.currentAnim.name:null}get frame(){return this.currentFrame?this.currentFrame.index:0}set frame(t){"number"==typeof t&&this._frameData&&null!==this._frameData.getFrame(t)?(this.currentFrame=this._frameData.getFrame(t),this.currentFrame&&this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frame: "+t)}get frameName(){return this.currentFrame?this.currentFrame.name:null}set frameName(t){"string"==typeof t&&this._frameData&&null!==this._frameData.getFrameByName(t)?(this.currentFrame=this._frameData.getFrameByName(t),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame))):console.warn("Cannot set frameName: "+t)}};function Vt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe;return s.x=t.x+e.x,s.y=t.y+e.y,s}function qt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe;return s.x=t.x-e.x,s.y=t.y-e.y,s}function Kt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe;return s.x=t.x*e.x,s.y=t.y*e.y,s}function Qt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe;return s.x=t.x/e.x,s.y=t.y/e.y,s}function $t(t,e){return t.x===e.x&&t.y===e.y}function Zt(t,e){return Math.atan2(t.y-e.y,t.x-e.x)}function Jt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(-t.x,-t.y)}function te(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=s||new pe;return n.setTo(t.x+e.x*i,t.y+e.y*i)}function ee(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=s||new pe;return n.setTo(t.x+(e.x-t.x)*i,t.y+(e.y-t.y)*i)}function ie(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(-t.y,t.x)}function se(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(t.y,-t.x)}function ne(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=t.x-e.x,n=t.y-e.y,h=Math.sqrt(s*s+n*n);return i?Math.round(h):h}function he(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe,n=t.dot(e)/e.getMagnitudeSq();return 0!==n&&s.setTo(n*e.x,n*e.y),s}function re(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new pe,n=t.dot(e);return 0!==n&&s.setTo(n*e.x,n*e.y),s}function oe(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(-1*t.y,t.x)}function ae(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe,s=t.getMagnitude();return 0!==s&&i.setTo(t.x/s,t.y/s),i}function le(t,e,i,s,n,h){if(n&&(s*=Math.PI/180),void 0===h){t.subtract(e,i);const n=Math.sin(s),h=Math.cos(s),r=h*t.x-n*t.y,o=n*t.x+h*t.y;t.x=r+e,t.y=o+i}else{const n=s+Math.atan2(t.y-i,t.x-e);t.x=e+h*Math.cos(n),t.y=i+h*Math.sin(n)}return t}function de(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe,s=t.length;if(s<1)throw new Error("Point(points) array must not be empty.");if(1===s)return i.copyFrom(t[0]),i;for(let e=0;e<s;e+=1)Vt(i,t[e],i);return i.divide(s,s),i}function ue(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"y";const s=new pe;return t[e]&&(s.x=parseInt(t[e],10)),t[i]&&(s.y=parseInt(t[i],10)),s}function ce(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(t.x,t.y),i}const pe=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.x=t,this.y=e,this.type=Ht}copyFrom(t){return this.setTo(t.x,t.y)}invert(){return this.setTo(this.y,this.x)}setTo(t,e){return this.x=t||0,this.y=e||(0!==e?this.x:0),this}set(t,e){return this.x=t||0,this.y=e||(0!==e?this.x:0),this}add(t,e){return this.x+=t,this.y+=e,this}subtract(t,e){return this.x-=t,this.y-=e,this}multiply(t,e){return this.x*=t,this.y*=e,this}divide(t,e){return this.x/=t,this.y/=e,this}clampX(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this}clampY(t,e){return this.y=Math.max(t,Math.min(e,this.y)),this}clamp(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clone(){return ce(this)}copyTo(t){return t.x=this.x,t.y=this.y,t}distance(t){return ne(this,t)}equals(t){return t.x===this.x&&t.y===this.y}angle(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?180/Math.PI*Math.atan2(t.y-this.y,t.x-this.x):Math.atan2(t.y-this.y,t.x-this.x)}rotate(t,e,i,s,n){return le(this,t,e,i,s,n)}getMagnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)}getMagnitudeSq(){return this.x*this.x+this.y*this.y}setMagnitude(t){return this.normalize().multiply(t,t)}normalize(){if(!this.isZero()){const t=this.getMagnitude();this.x/=t,this.y/=t}return this}isZero(){return 0===this.x&&0===this.y}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}perp(){return this.setTo(-this.y,this.x)}rperp(){return this.setTo(this.y,-this.x)}normalRightHand(){return this.setTo(-1*this.y,this.x)}floor(){return this.setTo(Math.floor(this.x),Math.floor(this.y))}ceil(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))}toString(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};function ge(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t}function me(t,e){return ge(t,e.x,e.y)}function fe(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pe;return i.setTo(t.width,t.height),i}function _e(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ke;return i.setTo(t.x,t.y,t.width,t.height),i}function ve(t,e,i){return!(t.width<=0||t.height<=0)&&e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom}function xe(t,e,i,s,n,h){return n>=t&&n<t+i&&h>=e&&h<e+s}function ye(t,e){return ve(t,e.x,e.y)}function we(t,e){return!(t.volume>e.volume)&&t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom}function be(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Se(t,e){return t.width===e.width&&t.height===e.height}function Te(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)}function Ce(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new ke;return Te(t,e)&&(s.x=Math.max(t.x,e.x),s.y=Math.max(t.y,e.y),s.width=Math.min(t.right,e.right)-s.x,s.height=Math.min(t.bottom,e.bottom)-s.y),s}function Me(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return!(e>t.right+h||i<t.left-h||s>t.bottom+h||n<t.top-h)}function Pe(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new ke;return s.setTo(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.max(t.right,e.right)-Math.min(t.left,e.left),Math.max(t.bottom,e.bottom)-Math.min(t.top,e.top))}function Ae(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ke;let s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return t.forEach((t=>{t.x>s&&(s=t.x),t.x<n&&(n=t.x),t.y>h&&(h=t.y),t.y<r&&(r=t.y)})),i.setTo(n,r,s-n,h-r),i}function Ee(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.EMPTY_RECTANGLE||(window.PhaserRegistry.EMPTY_RECTANGLE=new ke),window.PhaserRegistry.EMPTY_RECTANGLE}const ke=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.x=t,this.y=e,this.width=i,this.height=s,this.type=Ft}offset(t,e){return this.x+=t,this.y+=e,this}offsetPoint(t){return this.offset(t.x,t.y)}setTo(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}scale(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this}centerOn(t,e){return this.centerX=t,this.centerY=e,this}floor(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)}floorAll(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)}ceil(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)}ceilAll(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)}copyFrom(t){return this.setTo(t.x,t.y,t.width,t.height)}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}inflate(t,e){return ge(this,t,e)}size(t){return fe(this,t)}resize(t,e){return this.width=t,this.height=e,this}clone(t){return _e(this,t)}contains(t,e){return ve(this,t,e)}containsRect(t){return we(t,this)}equals(t){return be(this,t)}intersection(t,e){return Ce(this,t,e)}intersects(t){return Te(this,t)}intersectsRaw(t,e,i,s,n){return Me(this,t,e,i,s,n)}union(t,e){return Pe(this,t,e)}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new pe;return t.x=this.randomX,t.y=this.randomY,t}getPoint(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new pe;switch(t){case S:return e.set(this.x,this.y);case T:return e.set(this.centerX,this.y);case C:return e.set(this.right,this.y);case P:return e.set(this.x,this.centerY);case E:return e.set(this.centerX,this.centerY);case D:return e.set(this.right,this.centerY);case O:return e.set(this.x,this.bottom);case R:return e.set(this.centerX,this.bottom);case I:return e.set(this.right,this.bottom);default:return e.set(this.x,this.y)}}toString(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}get halfWidth(){return Math.round(this.width/2)}get halfHeight(){return Math.round(this.height/2)}get top(){return this.y}set top(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}get topLeft(){return new pe(this.x,this.y)}set topLeft(t){this.x=t.x,this.y=t.y}get topRight(){return new pe(this.x+this.width,this.y)}set topRight(t){this.right=t.x,this.y=t.y}get bottom(){return this.y+this.height}set bottom(t){t<=this.y?this.height=0:this.height=t-this.y}get bottomLeft(){return new pe(this.x,this.bottom)}set bottomLeft(t){this.x=t.x,this.bottom=t.y}get bottomRight(){return new pe(this.right,this.bottom)}set bottomRight(t){this.right=t.x,this.bottom=t.y}get left(){return this.x}set left(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}get right(){return this.x+this.width}set right(t){t<=this.x?this.width=0:this.width=t-this.x}get volume(){return this.width*this.height}get perimeter(){return 2*this.width+2*this.height}get centerX(){return this.x+this.halfWidth}set centerX(t){this.x=t-this.halfWidth}get centerY(){return this.y+this.halfHeight}set centerY(t){this.y=t-this.halfHeight}get randomX(){return this.x+Math.random()*this.width}get randomY(){return this.y+Math.random()*this.height}get empty(){return!this.width||!this.height}set empty(t){!0===t&&this.setTo(0,0,0,0)}},De=Math.PI/180,Le=180/Math.PI,Oe=2*Math.PI;function Re(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]}function Ie(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]}function Fe(t){if(t>0&&0==(t&t-1))return t;let e=1;for(;e<t;)e<<=1;return e}function Ue(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}function Be(t){return t*De}function Ne(t){return t*Le}function Ge(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function We(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return 0===e?t:(t-=i,i+(t=e*Math.ceil(t/e)))}function He(t,e,i){const s=i-e;if(s<=0)return 0;let n=(t-e)%s;return n<0&&(n+=s),n+e}function ze(t,e,i){return(e-t)*i+t}function Xe(t,e){return Math.abs(t-e)}function Ye(t,e){const i=t.length-1,s=i*e,n=Math.floor(s);return e<0?ze(t[0],t[1],s):e>1?ze(t[i],t[i-1],i-s):ze(t[n],t[n+1>i?i:n+1],s-n)}function je(t,e,i,s){const n=t-i,h=e-s;return Math.sqrt(n*n+h*h)}function Ve(t,e,i){return Math.abs(t-e)<=i}function qe(t,e,i,s){return t<<24|e<<16|i<<8|s}function Ke(t,e,i){return t<<16|e<<8|i}function Qe(t,e){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,((t,e,i,s)=>e+e+i+i+s+s));const i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);i&&(e.r=parseInt(i[1],16),e.g=parseInt(i[2],16),e.b=parseInt(i[3],16))}function $e(t,e){const i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);i&&(e.r=parseInt(i[1],10),e.g=parseInt(i[2],10),e.b=parseInt(i[3],10),e.a=void 0!==i[4]?parseFloat(i[4]):1)}function Ze(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}}function Je(t,e){if("string"==typeof t)0===t.indexOf("rgb")?$e(t,e):(e.a=1,Qe(t,e));else if("number"==typeof t){const i=Ze(t);e.r=i.r,e.g=i.g,e.b=i.b,e.a=i.a/255}return e.rgba="rgba("+e.r.toString()+","+e.g.toString()+","+e.b.toString()+","+e.a.toString()+")",e.color=Ke(e.r,e.g,e.b),e.color32=qe(255*e.a,e.r,e.g,e.b),e}const ti=class{constructor(){this._frames=[],this._frameNames=[]}addFrame(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t}getFrame(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return t>=this._frames.length&&(t=0),this._frames[t]}getFrameByName(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null}checkFrameName(t){return null!=this._frameNames[t]}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ti;for(let e=0;e<t.total;e+=1)i.addFrame(t.getFrame(e).clone());return i}(this)}getFrameRange(t,e){const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||[];for(let s=t;s<=e;s+=1)i.push(this._frames[s]);return i}getFrameIndexes(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||[];if(t&&t.length>0)for(let s=0;s<t.length;s+=1)e&&this._frames[t[s]]?i.push(this._frames[t[s]].index):this.getFrameByName(t[s])&&i.push(this.getFrameByName(t[s]).index);else for(let t=0;t<this._frames.length;t+=1)i.push(this._frames[t].index);return i}destroy(){this._frames=null,this._frameNames=null}get total(){return this._frames.length}},ei=class{constructor(t,e,i,s,n,h){this.initialize(t,e,i,s,n,h)}initialize(t,e,i,s,n,h){this.index=t,this.x=e,this.y=i,this.width=s,this.height=n,this.name=h,this.centerX=Math.floor(s/2),this.centerY=Math.floor(n/2),this.distance=je(0,0,s,n),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=s,this.sourceSizeH=n,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height}resize(t,e){this.width=t,this.height=e,this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2),this.distance=je(0,0,t,e),this.sourceSizeW=t,this.sourceSizeH=e,this.right=this.x+t,this.bottom=this.y+e}setTrim(t,e,i,s,n,h,r){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=h,this.spriteSourceSizeH=r)}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ei;return i.initialize(t.index,t.x,t.y,t.width,t.height),i}(this)}getRect(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ke;return t.setTo(this.x,this.y,this.width,this.height),t}};function ii(t,e,i,s,n,h,r){let o=e;if("string"==typeof e&&(o=t.cache.getImage(e)),null===o)return null;const a=o.width,l=o.height;i<=0&&(i=Math.floor(-a/Math.min(-1,i))),s<=0&&(s=Math.floor(-l/Math.min(-1,s)));let d=Math.floor((a-h)/(i+r))*Math.floor((l-h)/(s+r));if(-1!==n&&(d=n),0===a||0===l||a<i||l<s||0===d)return console.warn("AnimationParser.spriteSheet: '"+e+"'s width/height zero or width/height < given frameWidth/frameHeight"),null;const u=new ti;let c=h,p=h;for(let t=0;t<d;t+=1)u.addFrame(new ei(t,c,p,i,s,"")),c+=i+r,c+i>a&&(c=h,p+=s+r);return u}function si(t,e){if(!e.frames)return console.warn("JSONDataHash: Invalid Texture Atlas JSON given, missing frames object",e),null;const i=new ti,s=e.frames;let n,h=0;const r=Object.keys(s);for(let t=0;t<r.length;t+=1){const e=r[t];n=i.addFrame(new ei(h,s[e].frame.x,s[e].frame.y,s[e].frame.w,s[e].frame.h,e)),s[e].trimmed&&n.setTrim(s[e].trimmed,s[e].sourceSize.w,s[e].sourceSize.h,s[e].spriteSourceSize.x,s[e].spriteSourceSize.y,s[e].spriteSourceSize.w,s[e].spriteSourceSize.h),h+=1}return i}const ni=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.position=0,this.list=t}add(t){return this.exists(t)||this.list.push(t),t}getIndex(t){return this.list.indexOf(t)}getByKey(t,e){let i=this.list.length;for(;i;)if(i-=1,this.list[i][t]===e)return this.list[i];return null}exists(t){return this.list.indexOf(t)>-1}reset(){this.list.length=0}remove(t){const e=this.list.indexOf(t);return e>-1?(this.list.splice(e,1),t):null}setAll(t,e){let i=this.list.length;for(;i;)i-=1,this.list[i]&&(this.list[i][t]=e)}callAll(t){let e=this.list.length;for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];for(;e;)e-=1,this.list[e]&&this.list[e][t]&&this.list[e][t].apply(this.list[e],s)}removeAll(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.list.length;for(;e;)if(e-=1,this.list[e]){const i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}get total(){return this.list.length}get first(){return this.position=0,this.list.length>0?this.list[0]:null}get next(){return this.position<this.list.length?(this.position+=1,this.list[this.position]):null}},hi=class{constructor(){this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.chrome=!1,this.firefox=!1,this.edge=!1,this.safari=!1,this.silk=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.iPhone=!1,this.iPad=!1,this.pixelRatio=1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1}};function ri(t,e){return!!("mp3"===e&&t.mp3||"ogg"===e&&(t.ogg||t.opus)||"m4a"===e&&t.m4a||"opus"===e&&t.opus||"wav"===e&&t.wav||"webm"===e&&t.webm||"mp4"===e&&t.dolby)}function oi(t){const e=navigator.userAgent;/Android/.test(e)?t.android=!0:/CrOS/.test(e)?t.chromeOS=!0:/iP[ao]d|iPhone/i.test(e)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1?t.iOS=!0:/Mac OS/.test(e)?t.macOS=!0:/Linux/.test(e)?t.linux=!0:/Windows/.test(e)&&(t.windows=!0),(/Windows Phone/i.test(e)||/IEMobile/i.test(e))&&(t.android=!1,t.iOS=!1,t.macOS=!1,t.windows=!0,t.windowsPhone=!0);const i=/Silk/.test(e);(t.windows||t.macOS||t.linux&&!i||t.chromeOS)&&(t.desktop=!0),(t.android||t.iOS||t.windowsPhone||/Windows NT/i.test(e)&&/Touch/i.test(e))&&(t.desktop=!1)}function ai(t){("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(t.touch=!0),("onwheel"in window||"WheelEvent"in window)&&(t.wheelEvent="wheel")}function li(t){const e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],i=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"],s=document.createElement("div");for(let i=0;i<e.length;i+=1)if(s[e[i]]){t.fullscreen=!0,t.requestFullscreen=e[i];break}if(t.fullscreen){for(let e=0;e<i.length;e+=1)if(document[i[e]]){t.cancelFullscreen=i[e];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(t.fullscreenKeyboard=!0)}}function di(t){const e=navigator.userAgent;/Edge\/\d+/.test(e)?t.edge=!0:/Chrome\/(\d+)/.test(e)&&!t.windowsPhone?t.chrome=!0:/Firefox\D+(\d+)/.test(e)?t.firefox=!0:/Safari\/(\d+)/.test(e)&&!t.windowsPhone&&(t.safari=!0),/Silk/.test(e)&&(t.silk=!0)}function ui(t){const e=document.createElement("audio");try{e.canPlayType&&(e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(t.ogg=!0),(e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||e.canPlayType("audio/opus;").replace(/^no$/,""))&&(t.opus=!0),e.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(t.mp3=!0),e.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(t.wav=!0),(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/aac;").replace(/^no$/,""))&&(t.m4a=!0),e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(t.webm=!0),""!==e.canPlayType('audio/mp4;codecs="ec-3"')&&(t.edge||t.safari)&&(t.dolby=!0))}catch(t){}}function ci(t){t.pixelRatio=window.devicePixelRatio||1,t.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),t.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad")}function pi(t){oi(t),di(t),ui(t),ci(t),li(t),ai(t)}class gi{get x(){return window&&"pageXOffset"in window?window.pageXOffset:document.documentElement.scrollLeft}get y(){return window&&"pageYOffset"in window?window.pageYOffset:document.documentElement.scrollTop}get width(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get height(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}}class mi{get x(){return 0}get y(){return 0}get width(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get height(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}}class fi{get x(){return window&&"pageXOffset"in window?window.pageXOffset:document.documentElement.scrollLeft}get y(){return window&&"pageYOffset"in window?window.pageYOffset:document.documentElement.scrollTop}get width(){return window.innerWidth}get height(){return window.innerHeight}}class _i{get x(){return 0}get y(){return 0}get width(){const t=document.documentElement.clientWidth,e=window.innerWidth;return t<e?e:t}get height(){const t=document.documentElement.clientHeight,e=window.innerHeight;return t<e?e:t}}class vi{get x(){return 0}get y(){return 0}get width(){const t=document.documentElement;return Math.max(t.clientWidth,t.offsetWidth,t.scrollWidth)}get height(){const t=document.documentElement;return Math.max(t.clientHeight,t.offsetHeight,t.scrollHeight)}}const xi=class{constructor(t){this.treatAsDesktop=t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight,this.visualBounds=this.treatAsDesktop?new gi:new fi,this.layoutBounds=this.treatAsDesktop?new mi:new _i,this.documentBounds=new vi,this.scrollXProvider=window&&"pageXOffset"in window?()=>window.pageXOffset:()=>document.documentElement.scrollLeft,this.scrollYProvider=window&&"pageYOffset"in window?()=>window.pageYOffset:()=>document.documentElement.scrollTop}getOffset(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=e||new pe;const i=t.getBoundingClientRect(),s=this.scrollY,n=this.scrollX,h=document.documentElement.clientTop,r=document.documentElement.clientLeft;return e.x=i.left+n-r,e.y=i.top+s-h,e}getBounds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!(t=t&&!t.nodeType?t[0]:t)||1!==t.nodeType)&&this.calibrate(t.getBoundingClientRect(),e)}calibrate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=t.right+e)-(i.left=t.left-e),i.height=(i.bottom=t.bottom+e)-(i.top=t.top-e),i}getScreenOrientation(t){const e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;const s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n}get scrollX(){return this.scrollXProvider()}get scrollY(){return this.scrollYProvider()}get clientWidth(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get clientHeight(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}},yi=class{constructor(t){this.parent=t,this._onAddedToGroup=null,this._onRemovedFromGroup=null,this._onDestroy=null,this._onOutOfBounds=null,this._onEnterBounds=null,this._onInputOver=null,this._onInputOut=null,this._onInputDown=null,this._onInputUp=null,this._onDragStart=null,this._onDragUpdate=null,this._onDragStop=null,this._onAnimationStart=null,this._onAnimationComplete=null,this._onAnimationLoop=null}destroy(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()}get onAddedToGroup(){return this._onAddedToGroup||(this._onAddedToGroup=new Yt),this._onAddedToGroup}onAddedToGroup$dispatch(){this._onAddedToGroup&&this._onAddedToGroup.dispatch(...arguments)}get onRemovedFromGroup(){return this._onRemovedFromGroup||(this._onRemovedFromGroup=new Yt),this._onRemovedFromGroup}onRemovedFromGroup$dispatch(){this._onRemovedFromGroup&&this._onRemovedFromGroup.dispatch(...arguments)}get onDestroy(){return this._onDestroy||(this._onDestroy=new Yt),this._onDestroy}onDestroy$dispatch(){this._onDestroy&&this._onDestroy.dispatch(...arguments)}get onOutOfBounds(){return this._onOutOfBounds||(this._onOutOfBounds=new Yt),this._onOutOfBounds}onOutOfBounds$dispatch(){this._onOutOfBounds&&this._onOutOfBounds.dispatch(...arguments)}get onEnterBounds(){return this._onEnterBounds||(this._onEnterBounds=new Yt),this._onEnterBounds}onEnterBounds$dispatch(){this._onEnterBounds&&this._onEnterBounds.dispatch(...arguments)}get onInputOver(){return this._onInputOver||(this._onInputOver=new Yt),this._onInputOver}onInputOver$dispatch(){this._onInputOver&&this._onInputOver.dispatch(...arguments)}get onInputOut(){return this._onInputOut||(this._onInputOut=new Yt),this._onInputOut}onInputOut$dispatch(){this._onInputOut&&this._onInputOut.dispatch(...arguments)}get onInputDown(){return this._onInputDown||(this._onInputDown=new Yt),this._onInputDown}onInputDown$dispatch(){this._onInputDown&&this._onInputDown.dispatch(...arguments)}get onInputUp(){return this._onInputUp||(this._onInputUp=new Yt),this._onInputUp}onInputUp$dispatch(){this._onInputUp&&this._onInputUp.dispatch(...arguments)}get onDragStart(){return this._onDragStart||(this._onDragStart=new Yt),this._onDragStart}onDragStart$dispatch(){this._onDragStart&&this._onDragStart.dispatch(...arguments)}get onDragUpdate(){return this._onDragUpdate||(this._onDragUpdate=new Yt),this._onDragUpdate}onDragUpdate$dispatch(){this._onDragUpdate&&this._onDragUpdate.dispatch(...arguments)}get onDragStop(){return this._onDragStop||(this._onDragStop=new Yt),this._onDragStop}onDragStop$dispatch(){this._onDragStop&&this._onDragStop.dispatch(...arguments)}get onAnimationStart(){return this._onAnimationStart||(this._onAnimationStart=new Yt),this._onAnimationStart}onAnimationStart$dispatch(){this._onAnimationStart&&this._onAnimationStart.dispatch(...arguments)}get onAnimationComplete(){return this._onAnimationComplete||(this._onAnimationComplete=new Yt),this._onAnimationComplete}onAnimationComplete$dispatch(){this._onAnimationComplete&&this._onAnimationComplete.dispatch(...arguments)}get onAnimationLoop(){return this._onAnimationLoop||(this._onAnimationLoop=new Yt),this._onAnimationLoop}onAnimationLoop$dispatch(){this._onAnimationLoop&&this._onAnimationLoop.dispatch(...arguments)}};function wi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new Ti;return i.a=t.a,i.b=t.b,i.c=t.c,i.d=t.d,i.tx=t.tx,i.ty=t.ty,i}function bi(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.IDENTITY_MATRIX||(window.PhaserRegistry.IDENTITY_MATRIX=new Ti),window.PhaserRegistry.IDENTITY_MATRIX}function Si(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.TEMP_MATRIX||(window.PhaserRegistry.TEMP_MATRIX=new Ti),window.PhaserRegistry.TEMP_MATRIX}const Ti=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=h,this.type=Wt}fromArray(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])}setTo(t,e,i,s,n,h){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=h,this}clone(){return wi(this)}copyTo(t){return t.copyFrom(this),t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}toArray(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new Float32Array(9);return t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e}apply(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new pe;return e.x=this.a*t.x+this.c*t.y+this.tx,e.y=this.b*t.x+this.d*t.y+this.ty,e}applyInverse(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new pe,i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,h=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=h*e-this.ty*i,this.ty=h*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}identity(){return this.setTo(1,0,0,1,0,0)}};function Ci(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.CANVAS_POOL||(window.PhaserRegistry.CANVAS_POOL=[]),window.PhaserRegistry.CANVAS_POOL}function Mi(){const t=Ci();for(let e=0;e<t.length;e+=1)if(!t[e].parent)return e;return-1}function Pi(t){const e=Ci();for(let i=0;i<e.length;i+=1)e[i].parent===t&&(e[i].parent=null,e[i].canvas.width=1,e[i].canvas.height=1)}function Ai(t){const e=Ci();for(let i=0;i<e.length;i+=1)e[i].canvas===t&&(e[i].parent=null,e[i].canvas.width=1,e[i].canvas.height=1)}function Ei(){const t=Ci();let e=0;for(let i=0;i<t.length;i+=1)t[i].parent&&(e+=1);return e}function ki(){const t=Ci();let e=0;for(let i=0;i<t.length;i+=1)t[i].parent||(e+=1);return e}function Di(t,e,i){void 0===t&&console.warn("Created CanvasPool element with undefined parent.");const s=Mi(),n=Ci();let h;if(-1===s){const e={parent:t,canvas:document.createElement("canvas")};n.push(e),h=e.canvas}else n[s].parent=t,h=n[s].canvas;return void 0!==e&&(h.width=e,h.height=i),h}const Li=class{constructor(t,e){this.width=t,this.height=e,this.canvas=Di(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e}clear(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)}resize(t,e){this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e}destroy(){Ai(this.canvas)}};function Oi(t,e){const i=t.tintedTexture||Di("CanvasTinter");return window.PhaserRegistry.CANVAS_TINT_METHOD(t.texture,e,i),i}function Ri(t,e,i){const s=i.getContext("2d"),n=t.crop;i.width===n.width&&i.height===n.height||(i.width=n.width,i.height=n.height),s.clearRect(0,0,n.width,n.height),s.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),s.fillRect(0,0,n.width,n.height),s.globalCompositeOperation="multiply",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.globalCompositeOperation="destination-atop",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)}function Ii(t,e,i){const s=i.getContext("2d"),n=t.crop;i.width=n.width,i.height=n.height,s.globalCompositeOperation="copy",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height);const h=Re(e),r=h[0],o=h[1],a=h[2],l=s.getImageData(0,0,n.width,n.height),d=l.data;for(let t=0;t<d.length;t+=4)if(d[t+0]*=r,d[t+1]*=o,d[t+2]*=a,!window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA){const e=d[t+3];d[t+0]/=255/e,d[t+1]/=255/e,d[t+2]/=255/e}s.putImageData(l,0,0)}function Fi(){const t=new Li(2,1);t.context.fillStyle="rgba(10, 20, 30, 0.5)",t.context.fillRect(0,0,1,1);const e=t.context.getImageData(0,0,1,1);if(null===e)return!1;t.context.putImageData(e,1,0);const i=t.context.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}function Ui(){if(void 0===document)return!1;const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",e="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",i=new Image;i.src=t+"AP804Oa6"+e;const s=new Image;s.src=t+"/wCKxvRF"+e;const n=Di("CanvasTinter",6,1),h=n.getContext("2d");if(h.globalCompositeOperation="multiply",h.drawImage(i,0,0),h.drawImage(s,2,0),!h.getImageData(2,0,1,1))return!1;const r=h.getImageData(2,0,1,1).data;return Ai(n),255===r[0]&&0===r[1]&&0===r[2]}function Bi(){window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA||(window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA=Fi()),window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY||(window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY=Ui()),window.PhaserRegistry.CANVAS_TINT_METHOD||(window.PhaserRegistry.CANVAS_TINT_METHOD=window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY?Ri:Ii)}function Ni(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t.currentBounds)return t.currentBounds;const i=t.texture.frame.width,s=t.texture.frame.height;let n=i*(1-t.anchor.x),h=i*-t.anchor.x,r=s*(1-t.anchor.y),o=s*-t.anchor.y;const a=e||t.worldTransform;let l=a.a;const d=a.b,u=a.c;let c=a.d;const p=a.tx,g=a.ty;let m=-1/0,f=-1/0,_=1/0,v=1/0;if(0===d&&0===u){if(l<0){l*=-1;const t=n;n=-h,h=-t}if(c<0){c*=-1;const t=r;r=-o,o=-t}_=l*h+p,m=l*n+p,v=c*o+g,f=c*r+g}else{const t=l*h+u*o+p,e=c*o+d*h+g,i=l*n+u*o+p,s=c*o+d*n+g,a=l*n+u*r+p,x=c*r+d*n+g,y=l*h+u*r+p,w=c*r+d*h+g;_=t<_?t:_,_=i<_?i:_,_=a<_?a:_,_=y<_?y:_,v=e<v?e:v,v=s<v?s:v,v=x<v?x:v,v=w<v?w:v,m=t>m?t:m,m=i>m?i:m,m=a>m?a:m,m=y>m?y:m,f=e>f?e:f,f=s>f?s:f,f=x>f?x:f,f=w>f?w:f}const x=t.cachedBounds;return x.x=_,x.width=m-_,x.y=v,x.height=f-v,t.currentBounds=x,x}function Gi(t,e,i){if(!t.visible||t.alpha<=0||!t.renderable)return;let s=t.worldTransform;if(i&&(s=i),t._mask||t._filters){const i=e.spriteBatch;t._filters&&(i.flush(),e.filterManager.pushFilter(t._filterBlock)),t._mask&&(i.stop(),e.maskManager.pushMask(t.mask,e),i.start()),i.render(t);for(let i=0;i<t.children.length;i+=1)t.children[i].renderWebGL(e);i.stop(),t._mask&&e.maskManager.popMask(t._mask,e),t._filters&&e.filterManager.popFilter(),i.start()}else{e.spriteBatch.render(t);for(let i=0;i<t.children.length;i+=1)t.children[i].renderWebGL(e,s)}}function Wi(t,e,i){if(!t.visible||0===t.alpha||!t.renderable||t.texture.crop.width<=0||t.texture.crop.height<=0)return;let s=t.worldTransform;if(i&&(s=i),t.blendMode!==e.currentBlendMode&&(e.currentBlendMode=t.blendMode,e.context.globalCompositeOperation=window.PhaserRegistry.blendModesCanvas[e.currentBlendMode]),t._mask&&e.maskManager.pushMask(t._mask,e),t.texture.valid){const i=t.texture.baseTexture.resolution/e.resolution;e.context.globalAlpha=t.worldAlpha,e.smoothProperty&&e.scaleMode!==t.texture.baseTexture.scaleMode&&(e.scaleMode=t.texture.baseTexture.scaleMode,e.context[e.smoothProperty]=e.scaleMode===F);let n=t.texture.trim?t.texture.trim.x-t.anchor.x*t.texture.trim.width:t.anchor.x*-t.texture.frame.width,h=t.texture.trim?t.texture.trim.y-t.anchor.y*t.texture.trim.height:t.anchor.y*-t.texture.frame.height;const r=s.tx*e.resolution+e.shakeX,o=s.ty*e.resolution+e.shakeY;e.roundPixels?(e.context.setTransform(s.a,s.b,s.c,s.d,0|r,0|o),n|=0,h|=0):e.context.setTransform(s.a,s.b,s.c,s.d,r,o);let a=t.texture.crop.width,l=t.texture.crop.height;if(n/=i,h/=i,16777215!==t.tint)(t.texture.requiresReTint||t.cachedTint!==t.tint)&&(t.tintedTexture=Oi(t,t.tint),t.cachedTint=t.tint,t.texture.requiresReTint=!1),e.context.drawImage(t.tintedTexture,0,0,a,l,n,h,a/i,l/i);else{const s=t.texture.crop.x,r=t.texture.crop.y;a=Math.floor(a),l=Math.floor(l),e.context.drawImage(t.texture.baseTexture.source,s,r,a,l,n,h,a/i,l/i)}}for(let i=0;i<t.children.length;i+=1)t.children[i].renderCanvas(e);t._mask&&e.maskManager.popMask(e)}const Hi=class{constructor(){this.exists=!0,this.renderable=!1,this.visible=!0,this.position=new pe(0,0),this.scale=new pe(1,1),this.pivot=new pe(0,0),this.anchor=new pe(0,0),this.rotation=0,this.alpha=1,this.hitArea=null,this.parent=null,this.worldAlpha=1,this.worldTransform=new Ti,this.worldScale=new pe(1,1),this.filterArea=null,this._sr=0,this._cr=1,this.cachedBounds=new ke(0,0,0,0),this.currentBounds=null,this._mask=null,this.children=[],this.ignoreChildInput=!1}destroy(){if(this.children){let t=this.children.length;for(;t;)t-=1,this.children[t].destroy()}this.children=null,this.exists=!1,this.renderable=!1,this.visible=!1,this.hitArea=null,this.parent=null,this.worldTransform=null,this.worldScale=null,this.filterArea=null,this.cachedBounds=null,this.currentBounds=null,this._mask=null,this.destroyCachedSprite()}addChild(t){return this.addChildAt(t,this.children.length)}addChildAt(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);if(i<0||s<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[s]=t}getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");const i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]}removeChild(t){const e=this.children.indexOf(t);return-1===e?null:this.removeChildAt(e)}removeChildAt(t){const e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e}removeChildren(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);const i=e-t;if(i>0&&i<=e){const e=this.children.splice(t,i);for(let t=0;t<e.length;t+=1)e[t].parent=void 0;return e}if(0===i&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")}updateTransform(t){if(!t&&!this.parent)return this;if(!this.game||!this.visible)return this;let e=this.parent;t?e=t:this.parent||(e=this.game.world);const i=e.worldTransform,s=this.worldTransform;let n,h,r,o,a,l;this.rotation%Oe?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),n=this._cr*this.scale.x,h=this._sr*this.scale.x,r=-this._sr*this.scale.y,o=this._cr*this.scale.y,a=this.position.x,l=this.position.y,(this.pivot.x||this.pivot.y)&&(a-=this.pivot.x*n+this.pivot.y*r,l-=this.pivot.x*h+this.pivot.y*o),s.a=n*i.a+h*i.c,s.b=n*i.b+h*i.d,s.c=r*i.a+o*i.c,s.d=r*i.b+o*i.d,s.tx=a*i.a+l*i.c+i.tx,s.ty=a*i.b+l*i.d+i.ty):(n=this.scale.x,o=this.scale.y,a=this.position.x-this.pivot.x*n,l=this.position.y-this.pivot.y*o,s.a=n*i.a,s.b=n*i.b,s.c=o*i.c,s.d=o*i.d,s.tx=a*i.a+l*i.c+i.tx,s.ty=a*i.b+l*i.d+i.ty),this.worldAlpha=this.alpha*e.worldAlpha,this.worldScale.set(this.scale.x*Math.sqrt(s.a*s.a+s.c*s.c),this.scale.y*Math.sqrt(s.b*s.b+s.d*s.d)),this.worldRotation=Math.atan2(-s.c,s.d),this.currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,s,i);for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();return this}getBounds(t){const e=t&&void 0!==t.contains;let i,s,n=!0;if(e?n=void 0!==t.contains&&t.contains(this):t=this,e)for(s=t.worldTransform,t.worldTransform=bi(),i=0;i<t.children.length;i+=1)t.children[i].updateTransform();let h,r,o,a=1/0,l=1/0,d=-1/0,u=-1/0,c=!1;for(i=0;i<this.children.length;i+=1)this.children[i].visible&&(c=!0,h=this.children[i].getBounds(),a=a<h.x?a:h.x,l=l<h.y?l:h.y,r=h.width+h.x,o=h.height+h.y,d=d>r?d:r,u=u>o?u:o);let p=this.cachedBounds;if(!c){p=new ke;const t=p.x,e=p.width+p.x,i=p.y,s=p.height+p.y,n=this.worldTransform,h=n.a,r=n.b,o=n.c,c=n.d,g=n.tx,m=n.ty,f=h*e+o*s+g,_=c*s+r*e+m,v=h*t+o*s+g,x=c*s+r*t+m,y=h*t+o*i+g,w=c*i+r*t+m,b=h*e+o*i+g,S=c*i+r*e+m;d=f,u=_,a=f,l=_,a=v<a?v:a,a=y<a?y:a,a=b<a?b:a,l=x<l?x:l,l=w<l?w:l,l=S<l?S:l,d=v>d?v:d,d=y>d?y:d,d=b>d?b:d,u=x>u?x:u,u=w>u?w:u,u=S>u?S:u}if(p.x=a,p.y=l,p.width=d-a,p.height=u-l,e)for(t.worldTransform=s,i=0;i<t.children.length;i+=1)t.children[i].updateTransform();if(!n){const e=t.getBounds();p.x-=e.x,p.y-=e.y}return p}getLocalBounds(){return this.getBounds(this)}contains(t){return!!t&&(t===this||this.contains(t.parent))}renderWebGL(t){if(!this.visible||this.alpha<=0)return;let e;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t)}renderCanvas(t){if(this.visible&&!(this.alpha<=0)){this._mask&&t.maskManager.pushMask(this._mask,t);for(let e=0;e<this.children.length;e+=1)this.children[e].renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}preUpdate(){}update(){}postUpdate(){}generateTexture(){console.warn("display_object.generateTexture() is not implemented")}toGlobal(t){return this.updateTransform(),this.worldTransform.apply(t)}toLocal(t,e){return e&&(t=e.toGlobal(t)),this.updateTransform(),this.worldTransform.applyInverse(t)}renderCachedSprite(t){this._cachedSprite&&(this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?Gi(this._cachedSprite,t):Wi(this._cachedSprite,t))}generateCachedSprite(){}destroyCachedSprite(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}get width(){return this.getLocalBounds().width*this.scale.x}set width(t){const e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}get height(){return this.getLocalBounds().height*this.scale.y}set height(t){const e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}get x(){return this.position.x}set x(t){this.position.x=t}get y(){return this.position.y}set y(t){this.position.y=t}get worldVisible(){if(!this.visible)return!1;let t=this.parent;if(!t)return this.visible;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){this._mask&&(this._mask.isMask=!1),this._mask=t,t&&(this._mask.isMask=!0)}get offsetX(){return this.anchor.x*this.width}get offsetY(){return this.anchor.y*this.height}get centerX(){return this.x-this.offsetX+.5*this.width}set centerX(t){this.x=t+this.offsetX-.5*this.width}get centerY(){return this.y-this.offsetY+.5*this.height}set centerY(t){this.y=t+this.offsetY-.5*this.height}get left(){return this.x-this.offsetX}set left(t){this.x=t+this.offsetX}get right(){return this.x+this.width-this.offsetX}set right(t){this.x=t-this.width+this.offsetX}get top(){return this.y-this.offsetY}set top(t){this.y=t+this.offsetY}get bottom(){return this.y+this.height-this.offsetY}set bottom(t){this.y=t-this.height+this.offsetY}};class zi{constructor(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0}}const Xi=class{constructor(t,e,i,s){this.noFrame=!1,e||(this.noFrame=!0,e=new ke(0,0,1,1)),t&&t.baseTexture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=s,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new ke(0,0,1,1),t.hasLoaded&&(this.noFrame&&(e=new ke(0,0,t.width,t.height)),this.setFrame(e))}onBaseTextureLoaded(){this.noFrame&&(this.frame=new ke(0,0,this.baseTexture.width,this.baseTexture.height)),this.setFrame(this.frame)}destroy(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.baseTexture.destroy(),this.valid=!1}setFrame(t){this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height)?(this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()):this.valid=!1}_updateUvs(){this._uvs||(this._uvs=new zi);const t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i}},Yi=class extends Hi{constructor(t,e,i,s,n){super(),this.game=t,this.type=Mt,this.renderable=!0,this.key=s,this.texture=window.PhaserRegistry.CACHE_MISSING_IMAGE,this.data={},this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=$,this.shader=null,this._frame=null,this.position.set(e,i),this.events=new yi(this),this.animations=new jt(this),this.loadTexture(s,n)}destroy(){this.game=null,this.key=null,this.data=null,this.texture=null,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.shader=null,this._frame=null,this.events&&this.events.destroy(),this.events=null,this.animations&&this.animations.destroy(),this.animations=null,super.destroy()}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists){this.visible&&(this.game.stage.currentRenderOrderID+=1,this.renderOrderID=this.game.stage.currentRenderOrderID),this.animations&&this.animations.update();for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}else this.renderOrderID=-1}loadTexture(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t===zt?(t=e,e=0):e=e||0,(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&this.animations.stop(),this.key=t,this.customRender=!1;const i=this.game.cache,s=!this.texture.baseTexture.scaleMode;let n=!0;if(t instanceof Xi)this.setTexture(t);else{const s=i.getImage(t,!0);s&&(this.key=s.key,this.setTexture(new Xi(s.base)),this.texture.baseTexture.skipRender="__default"===t,n=!this.animations.loadFrameData(s.frameData,e))}n&&(this._frame=_e(this.texture.frame)),s||(this.texture.baseTexture.scaleMode=1)}setFrame(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)}resizeFrame(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)}resetFrame(){this._frame&&this.setFrame(this._frame)}get frame(){return this.animations.frame}set frame(t){this.animations.frame=t}get frameName(){return this.animations.frameName}set frameName(t){this.animations.frameName=t}crop(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(e&&null!==this.cropRect?this.cropRect.setTo(t.x,t.y,t.width,t.height):e&&null===this.cropRect?this.cropRect=new ke(t.x,t.y,t.width,t.height):this.cropRect=t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())}updateCrop(){if(!this.cropRect)return;const t=this.texture.crop.x,e=this.texture.crop.y,i=this.texture.crop.width,s=this.texture.crop.height;this._crop=_e(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;const n=Math.max(this._frame.x,this._crop.x),h=Math.max(this._frame.y,this._crop.y),r=Math.min(this._frame.right,this._crop.right)-n,o=Math.min(this._frame.bottom,this._crop.bottom)-h;this.texture.crop.x=n,this.texture.crop.y=h,this.texture.crop.width=r,this.texture.crop.height=o,this.texture.frame.width=Math.min(r,this.cropRect.width),this.texture.frame.height=Math.min(o,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||t===n&&e===h&&i===r&&s===o||(this.texture.requiresReTint=!0)}get width(){return this.scale.x*this.texture.frame.width}set width(t){this.scale.x=t/this.texture.frame.width,this._width=t}get height(){return this.scale.y*this.texture.frame.height}set height(t){this.scale.y=t/this.texture.frame.height,this._height=t}onTextureUpdate(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)}setTexture(t){!function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&t.texture.baseTexture.destroy(),t.texture.baseTexture.skipRender=!1,t.texture=e,t.texture.valid=!0,t.cachedTint=-1}(this,t,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}getBounds(){return Ni(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)}getLocalBounds(){return function(t){const e=t.worldTransform;let i;for(t.worldTransform=bi(),i=0;i<t.children.length;i+=1)t.children[i].updateTransform();const s=t.getBounds();for(t.worldTransform=e,i=0;i<t.children.length;i+=1)t.children[i].updateTransform();return s}(this)}renderWebGL(t){Gi(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)}renderCanvas(t){Wi(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)}};function ji(){return!0}function Vi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new qi;return i.x=t.x,i.y=t.y,i.width=t.width,i.height=t.height,i.radius=t.radius,i}const qi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:20;this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Nt}contains(t,e){return!(this.width<=0||this.height<=0)&&t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height}clone(){return Vi(this)}};function Ki(){return!0}function Qi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new $i;return i.setTo(t._points.slice()),i}const $i=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.area=0,this._points=[],this.closed=!0,this.flattened=!1,this.type=It,t&&this.setTo(t)}toNumberArray(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];for(let e=0;e<this._points.length;e+=1)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e+=1):(t.push(this._points[e].x),t.push(this._points[e].y));return t}flatten(){return this._points=this.toNumberArray(),this.flattened=!0,this}clone(){return Qi(this)}contains(t,e){let i=!1;if(this.flattened)for(let s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){const h=this._points[s],r=this._points[s+1],o=this._points[n],a=this._points[n+1];(r<=e&&e<a||a<=e&&e<r)&&t<(o-h)*(e-r)/(a-r)+h&&(i=!i)}else for(let s=-1,n=this._points.length-1;++s<this._points.length;n=s){const h=this._points[s].x,r=this._points[s].y,o=this._points[n].x,a=this._points[n].y;(r<=e&&e<a||a<=e&&e<r)&&t<(o-h)*(e-r)/(a-r)+h&&(i=!i)}return i}setTo(t){if(this.area=0,this._points=[],t){Array.isArray(t)||console.error("[Polygon] setTo() error, input parameter is not an array",t);let e=Number.MAX_VALUE;for(let i=0,s=t.length;i<s;i+=1){let s;"number"==typeof t[i]?(s=new pe(t[i],t[i+1]),i+=1):s=Array.isArray(t[i])?new pe(t[i][0],t[i][1]):new pe(t[i].x,t[i].y),this._points.push(s),s.y<e&&(e=s.y)}this.calculateArea(e)}return this}calculateArea(t){let e,i,s,n;for(let h=0,r=this._points.length;h<r;h+=1)e=this._points[h],i=h===r-1?this._points[0]:this._points[h+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}get points(){return this._points}set points(t){null!==t?this.setTo(t):(this.area=0,this._points=[])}};function Zi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new hs;return i.x=t.x,i.y=t.y,i.diameter=t.diameter,i}function Ji(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}function ts(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter}function es(t,e){return je(t.x,t.y,e.x,e.y)<=t.radius+e.radius}function is(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=s||new pe;return!0===i&&(e=Be(e)),n.x=t.x+t.radius*Math.cos(e),n.y=t.y+t.radius*Math.sin(e),n}function ss(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=s||new pe;return!0===i&&(e=Be(e)),n.x=t.x+t.radius*Math.cos(e),n.y=t.y+t.radius*Math.sin(e),n}function ns(t,e){const i=Math.abs(t.x-e.x-e.halfWidth);if(i>e.halfWidth+t.radius)return!1;const s=Math.abs(t.y-e.y-e.halfHeight);if(s>e.halfHeight+t.radius)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;const n=i-e.halfWidth,h=s-e.halfHeight;return n*n+h*h<=t.radius*t.radius}const hs=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.x=t,this.y=e,this._diameter=i,this._radius=0,i>0&&(this._radius=.5*i),this.type=Ut}circumference(){return Math.PI*this._radius*2}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new pe,e=2*Math.PI*Math.random(),i=Math.random()+Math.random(),s=i>1?2-i:i,n=s*Math.cos(e),h=s*Math.sin(e);return t.x=this.x+n*this.radius,t.y=this.y+h*this.radius,t}getBounds(){return new ke(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)}setTo(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this}copyFrom(t){return this.setTo(t.x,t.y,t.diameter)}copyTo(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t}distance(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=je(this.x,this.y,t.x,t.y);return e?Math.round(i):i}clone(){return Zi(this)}contains(t,e){return Ji(this,t,e)}circumferencePoint(t,e,i){return is(this,t,e,i)}offset(t,e){return this.x+=t,this.y+=e,this}offsetPoint(t){return this.offset(t.x,t.y)}toString(){return"[{Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}get diameter(){return this._diameter}set diameter(t){t>0&&(this._diameter=t,this._radius=.5*t)}get radius(){return this._radius}set radius(t){t>0&&(this._radius=t,this._diameter=2*t)}get left(){return this.x-this._radius}set left(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}get right(){return this.x+this._radius}set right(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}get top(){return this.y-this._radius}set top(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}get bottom(){return this.y+this._radius}set bottom(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}get area(){return this._radius>0?Math.PI*this._radius*this._radius:0}get empty(){return 0===this._diameter}set empty(t){!0===t&&this.setTo(0,0,0)}};function rs(){return!0}function os(t,e,i){if(t.width<=0||t.height<=0)return!1;let s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return s*=s,n*=n,s+n<.25}const as=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.x=t,this.y=e,this.width=i,this.height=s,this.type=Bt}setTo(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}getBounds(){return new ke(this.x-this.width,this.y-this.height,this.width,this.height)}copyFrom(t){return this.setTo(t.x,t.y,t.width,t.height)}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return os(this,t,e)}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new pe,e=Math.random()*Math.PI*2,i=Math.random();return t.x=Math.sqrt(i)*Math.cos(e),t.y=Math.sqrt(i)*Math.sin(e),t.x=this.x+t.x*this.width/2,t.y=this.y+t.y*this.height/2,t}toString(){return"[{Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},ls=class{constructor(t,e,i,s,n,h,r){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=h,this.shape=r,this.type=r.type}clone(){return new ls((t=this).lineWidth,t.lineColor,t.lineAlpha,t.fillColor,t.fillAlpha,t.fill,t.shape);var t}},ds=class{constructor(t,e){this.resolution=1,this.width=100,this.height=100,this.scaleMode=e||window.PhaserRegistry.TEXTURE_SCALE_MODE,this.hasLoaded=!1,this.source=t,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.skipRender=!1,this._powerOf2=!1,this._dirty=[!0,!0,!0,!0],t&&(this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty())}forceLoaded(t,e){this.hasLoaded=!0,this.width=t,this.height=e,this.dirty()}destroy(){this.source&&Ai(this.source),this.source=null,this.unloadFromGPU()}dirty(){for(let t=0;t<this._glTextures.length;t+=1)this._dirty[t]=!0}unloadFromGPU(){this.dirty();for(let t=this._glTextures.length-1;t>=0;t-=1){const e=this._glTextures[t],i=window.PhaserRegistry.GL_CONTEXTS[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()}};function us(t,e){return new Xi(function(t,e){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),new ds(t,e)}(t,e))}function cs(t){if(16777215===t.tint)return;const e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255;for(let n=0;n<t.graphicsData.length;n+=1){const h=t.graphicsData[n],r=0|h.fillColor,o=0|h.lineColor;h._fillTint=((r>>16&255)/255*e*255<<16)+((r>>8&255)/255*i*255<<8)+(255&r)/255*s*255,h._lineTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255}}function ps(t,e){const i=t.worldAlpha;t.dirty&&(cs(t),t.dirty=!1);for(let s=0;s<t.graphicsData.length;s+=1){const n=t.graphicsData[s],h=n.shape,r=n._fillTint,o=n._lineTint;if(e.lineWidth=n.lineWidth,n.type===It){e.beginPath();const t=h.points;e.moveTo(t[0],t[1]);for(let i=1;i<t.length/2;i+=1)e.lineTo(t[2*i],t[2*i+1]);h.closed&&e.lineTo(t[0],t[1]),t[0]===t[t.length-2]&&t[1]===t[t.length-1]&&e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}else if(n.type===Ft)(n.fillColor||0===n.fillColor)&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fillRect(h.x,h.y,h.width,h.height)),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.strokeRect(h.x,h.y,h.width,h.height));else if(n.type===Ut)e.beginPath(),e.arc(h.x,h.y,h.radius,0,2*Math.PI),e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke());else if(n.type===Bt){const t=2*h.width,s=2*h.height,a=h.x-t/2,l=h.y-s/2;e.beginPath();const d=.5522848,u=t/2*d,c=s/2*d,p=a+t,g=l+s,m=a+t/2,f=l+s/2;e.moveTo(a,f),e.bezierCurveTo(a,f-c,m-u,l,m,l),e.bezierCurveTo(m+u,l,p,f-c,p,f),e.bezierCurveTo(p,f+c,m+u,g,m,g),e.bezierCurveTo(m-u,g,a,f+c,a,f),e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}else if(n.type===Nt){const t=h.x,s=h.y,a=h.width,l=h.height;let d=h.radius;const u=Math.min(a,l)/2|0;d=d>u?u:d,e.beginPath(),e.moveTo(t,s+d),e.lineTo(t,s+l-d),e.quadraticCurveTo(t,s+l,t+d,s+l),e.lineTo(t+a-d,s+l),e.quadraticCurveTo(t+a,s+l,t+a,s+l-d),e.lineTo(t+a,s+d),e.quadraticCurveTo(t+a,s,t+a-d,s),e.lineTo(t+d,s),e.quadraticCurveTo(t,s,t,s+d),e.closePath(),(n.fillColor||0===n.fillColor)&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}}}function gs(t,e){const i=t.graphicsData.length;if(0!==i){e.beginPath();for(let s=0;s<i;s+=1){const i=t.graphicsData[s],n=i.shape;if(i.type===It){const t=n.points;e.moveTo(t[0],t[1]);for(let i=1;i<t.length/2;i+=1)e.lineTo(t[2*i],t[2*i+1]);t[0]===t[t.length-2]&&t[1]===t[t.length-1]&&e.closePath()}else if(i.type===Ft)e.rect(n.x,n.y,n.width,n.height),e.closePath();else if(i.type===Ut)e.arc(n.x,n.y,n.radius,0,2*Math.PI),e.closePath();else if(i.type===Bt){const t=2*n.width,i=2*n.height,s=n.x-t/2,h=n.y-i/2,r=.5522848,o=t/2*r,a=i/2*r,l=s+t,d=h+i,u=s+t/2,c=h+i/2;e.moveTo(s,c),e.bezierCurveTo(s,c-a,u-o,h,u,h),e.bezierCurveTo(u+o,h,l,c-a,l,c),e.bezierCurveTo(l,c+a,u+o,d,u,d),e.bezierCurveTo(u-o,d,s,c+a,s,c),e.closePath()}else if(i.type===Nt){const t=n.x,i=n.y,s=n.width,h=n.height;let r=n.radius;const o=Math.min(s,h)/2|0;r=r>o?o:r,e.moveTo(t,i+r),e.lineTo(t,i+h-r),e.quadraticCurveTo(t,i+h,t+r,i+h),e.lineTo(t+s-r,i+h),e.quadraticCurveTo(t+s,i+h,t+s,i+h-r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t+s,i,t+s-r,i),e.lineTo(t+r,i),e.quadraticCurveTo(t,i,t,i+r),e.closePath()}}}}const ms=class{constructor(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0}reset(){this.points=[],this.indices=[],this.glPoints=null,this.glIndicies=null}upload(){const t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1}},fs=class{constructor(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}};function _s(t){let e,i,s,n,h,r,o,a,l=1;do{for(i=t,t=null,h=null,r=0;i;){for(r+=1,s=i,o=0,e=0;e<l&&(o+=1,s=s.nextZ,s);e+=1);for(a=l;o>0||a>0&&s;)0===o?(n=s,s=s.nextZ,a-=1):0!==a&&s?i.z<=s.z?(n=i,i=i.nextZ,o-=1):(n=s,s=s.nextZ,a-=1):(n=i,i=i.nextZ,o-=1),h?h.nextZ=n:t=n,n.prevZ=h,h=n;i=s}h.nextZ=null,l*=2}while(r>1);return t}function vs(t,e){return t.x-e.x}function xs(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-s)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ys(t,e,i,s){let n=t;do{null===n.z&&(n.z=xs(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,_s(n)}function ws(t){let e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function bs(t,e,i,s,n,h,r,o){return(n-r)*(e-o)-(t-r)*(h-o)>=0&&(t-r)*(s-o)-(i-r)*(e-o)>=0&&(i-r)*(h-o)-(n-r)*(s-o)>=0}function Ss(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ts(t,e){return t.x===e.x&&t.y===e.y}function Cs(t,e,i,s){return Ss(t,e,i)>0!=Ss(t,e,s)>0&&Ss(i,s,t)>0!=Ss(i,s,e)>0}function Ms(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Cs(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}function Ps(t,e){return Ss(t.prev,t,t.next)<0?Ss(t,e,t.next)>=0&&Ss(t,t.prev,e)>=0:Ss(t,e,t.prev)<0||Ss(t,t.next,e)<0}function As(t,e){let i=t,s=!1;const n=(t.x+e.x)/2,h=(t.y+e.y)/2;do{i.y>h!=i.next.y>h&&n<(i.next.x-i.x)*(h-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}function Es(t,e){return Ts(t,e)||t.next.i!==e.i&&t.prev.i!==e.i&&!Ms(t,e)&&Ps(t,e)&&Ps(e,t)&&As(t,e)}function ks(t,e){const i=new fs(t.i,t.x,t.y),s=new fs(e.i,e.x,e.y),n=t.next,h=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,h.next=s,s.prev=h,s}function Ds(t,e,i,s){const n=new fs(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ls(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Os(t){const e=t.prev,i=t,s=t.next;if(Ss(e,i,s)>=0)return!1;let n=t.next.next;for(;n!==t.prev;){if(bs(e.x,e.y,i.x,i.y,s.x,s.y,n.x,n.y)&&Ss(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Rs(t,e,i,s){const n=t.prev,h=t,r=t.next;if(Ss(n,h,r)>=0)return!1;const o=n.x<h.x?n.x<r.x?n.x:r.x:h.x<r.x?h.x:r.x,a=n.y<h.y?n.y<r.y?n.y:r.y:h.y<r.y?h.y:r.y,l=n.x>h.x?n.x>r.x?n.x:r.x:h.x>r.x?h.x:r.x,d=n.y>h.y?n.y>r.y?n.y:r.y:h.y>r.y?h.y:r.y,u=xs(o,a,e,i,s),c=xs(l,d,e,i,s);let p=t.nextZ;for(;p&&p.z<=c;){if(p!==t.prev&&p!==t.next&&bs(n.x,n.y,h.x,h.y,r.x,r.y,p.x,p.y)&&Ss(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&bs(n.x,n.y,h.x,h.y,r.x,r.y,p.x,p.y)&&Ss(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Is(t,e,i,s,n){let h,r,o,a=0;for(h=e,r=i-s;h<i;h+=s)a+=(t[r]-t[h])*(t[h+1]+t[r+1]),r=h;if(n===a>0)for(h=e;h<i;h+=s)o=Ds(h,t[h],t[h+1],o);else for(h=i-s;h>=e;h-=s)o=Ds(h,t[h],t[h+1],o);return o}function Fs(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!Ts(s,s.next)&&0!==Ss(s.prev,s,s.next))s=s.next;else{if(Ls(s),s=s.prev,e=s,s===s.next)return null;i=!0}}while(i||s!==e);return e}function Us(t,e){let i=e;const s=t.x,n=t.y;let h,r=-1/0;do{if(n<=i.y&&n>=i.next.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);t<=s&&t>r&&(r=t,h=i.x<i.next.x?i:i.next)}i=i.next}while(i!==e);if(!h)return null;if(t.x===h.x)return h.prev;const o=h;let a,l=1/0;for(i=h.next;i!==o;)s>=i.x&&i.x>=h.x&&bs(n<h.y?s:r,n,h.x,h.y,n<h.y?r:s,n,i.x,i.y)&&(a=Math.abs(n-i.y)/(s-i.x),(a<l||a===l&&i.x>h.x)&&Ps(i,t)&&(h=i,l=a)),i=i.next;return h}function Bs(t,e){if(e=Us(t,e)){const i=ks(e,t);Fs(i,i.next)}}function Ns(t,e,i,s){const n=[];let h,r,o,a,l;for(h=0,r=e.length;h<r;h+=1)o=e[h]*s,a=h<r-1?e[h+1]*s:t.length,l=Is(t,o,a,s,!1),l===l.next&&(l.steiner=!0),n.push(ws(l));for(n.sort(vs),h=0;h<n.length;h+=1)Bs(n[h],i),i=Fs(i,i.next);return i}function Gs(t,e,i){let s=t;do{const n=s.prev,h=s.next.next;Cs(n,s,s.next,h)&&Ps(n,h)&&Ps(h,n)&&(e.push(n.i/i),e.push(s.i/i),e.push(h.i/i),Ls(s),Ls(s.next),s=h,t=s),s=s.next}while(s!==t);return s}function Ws(t,e,i,s,n,h){let r=t;do{let t=r.next.next;for(;t!==r.prev;){if(r.i!==t.i&&Es(r,t)){let o=ks(r,t);return r=Fs(r,r.next),o=Fs(o,o.next),Hs(r,e,i,s,n,h),void Hs(o,e,i,s,n,h)}t=t.next}r=r.next}while(r!==t)}function Hs(t,e,i,s,n,h,r){if(!t)return;!r&&h&&ys(t,s,n,h);let o,a,l=t;for(;t.prev!==t.next;)if(o=t.prev,a=t.next,h?Rs(t,s,n,h):Os(t))e.push(o.i/i),e.push(t.i/i),e.push(a.i/i),Ls(t),t=a.next,l=a.next;else if((t=a)===l){r?1===r?Hs(t=Gs(t,e,i),e,i,s,n,h,2):2===r&&Ws(t,e,i,s,n,h):Hs(Fs(t),e,i,s,n,h,1);break}}function zs(t,e,i){i=i||2;const s=e&&e.length,n=s?e[0]*i:t.length;let h=Is(t,0,n,i,!0);const r=[];if(!h)return r;let o,a,l,d,u,c,p;if(s&&(h=Ns(t,e,h,i)),t.length>80*i){o=t[0],l=t[0],a=t[1],d=t[1];for(let e=i;e<n;e+=i)u=t[e],c=t[e+1],u<o&&(o=u),c<a&&(a=c),u>l&&(l=u),c>d&&(d=c);p=Math.max(l-o,d-a)}return Hs(h,r,i,o,a,p),r}function Xs(){return window.PhaserRegistry.graphicsDataPool||(window.PhaserRegistry.graphicsDataPool=[]),window.PhaserRegistry.graphicsDataPool}function Ys(t,e){let i;return t.data.length?(i=t.data[t.data.length-1],i.mode===e&&1!==e||(i=Xs().pop()||new ms(t.gl),i.mode=e,t.data.push(i))):(i=Xs().pop()||new ms(t.gl),i.mode=e,t.data.push(i)),i.dirty=!0,i}function js(t,e){let i=0,s=t.points;if(0===s.length)return;if(t.lineWidth%2)for(i=0;i<s.length;i+=1)s[i]+=.5;const n=new pe(s[0],s[1]);let h=new pe(s[s.length-2],s[s.length-1]);if(n.x===h.x&&n.y===h.y){s=s.slice(),s.pop(),s.pop(),h=new pe(s[s.length-2],s[s.length-1]);const t=h.x+.5*(n.x-h.x),e=h.y+.5*(n.y-h.y);s.unshift(t,e),s.push(t,e)}const r=e.points,o=e.indices,a=s.length/2;let l=s.length,d=r.length/6;const u=t.lineWidth/2,c=Re(t.lineColor),p=t.lineAlpha,g=c[0]*p,m=c[1]*p,f=c[2]*p;let _,v,x,y,w,b,S,T,C,M,P,A,E,k,D,L,O,R,I,F,U,B,N;for(x=s[0],y=s[1],w=s[2],b=s[3],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,r.push(x-C,y-M,g,m,f,p),r.push(x+C,y+M,g,m,f,p),i=1;i<a-1;i+=1)x=s[2*(i-1)],y=s[2*(i-1)+1],w=s[2*i],b=s[2*i+1],S=s[2*(i+1)],T=s[2*(i+1)+1],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,P=-(b-T),A=w-S,N=Math.sqrt(P*P+A*A),P/=N,A/=N,P*=u,A*=u,D=-M+y-(-M+b),L=-C+w-(-C+x),O=(-C+x)*(-M+b)-(-C+w)*(-M+y),R=-A+T-(-A+b),I=-P+w-(-P+S),F=(-P+S)*(-A+b)-(-P+w)*(-A+T),U=D*I-R*L,Math.abs(U)<.1?(U+=10.1,r.push(w-C,b-M,g,m,f,p),r.push(w+C,b+M,g,m,f,p)):(_=(L*F-I*O)/U,v=(R*O-D*F)/U,B=(_-w)*(_-w)+(v-b)+(v-b),B>19600?(E=C-P,k=M-A,N=Math.sqrt(E*E+k*k),E/=N,k/=N,E*=u,k*=u,r.push(w-E,b-k),r.push(g,m,f,p),r.push(w+E,b+k),r.push(g,m,f,p),r.push(w-E,b-k),r.push(g,m,f,p),l+=1):(r.push(_,v),r.push(g,m,f,p),r.push(w-(_-w),b-(v-b)),r.push(g,m,f,p)));for(x=s[2*(a-2)],y=s[2*(a-2)+1],w=s[2*(a-1)],b=s[2*(a-1)+1],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,r.push(w-C,b-M),r.push(g,m,f,p),r.push(w+C,b+M),r.push(g,m,f,p),o.push(d),i=0;i<l;i+=1)o.push(d),d+=1;o.push(d-1)}function Vs(t,e){const i=t.shape,s=i.x,n=i.y,h=i.width,r=i.height;if(t.fill){const i=Re(t.fillColor),o=t.fillAlpha,a=i[0]*o,l=i[1]*o,d=i[2]*o,u=e.points,c=e.indices,p=u.length/6;u.push(s,n),u.push(a,l,d,o),u.push(s+h,n),u.push(a,l,d,o),u.push(s,n+r),u.push(a,l,d,o),u.push(s+h,n+r),u.push(a,l,d,o),c.push(p,p,p+1,p+2,p+3,p+3)}if(t.lineWidth){const i=t.points;t.points=[s,n,s+h,n,s+h,n+r,s,n+r,s,n],js(t,e),t.points=i}}function qs(t,e,i,s,n,h){let r,o,a,l,d,u;const c=[],p=(t,e,i)=>t+(e-t)*i;let g=0;for(let m=0;m<=20;m+=1)g=m/20,r=p(t,i,g),o=p(e,s,g),a=p(i,n,g),l=p(s,h,g),d=p(r,a,g),u=p(o,l,g),c.push(d,u);return c}function Ks(t,e){const i=t.shape,s=i.x,n=i.y,h=i.width,r=i.height,o=i.radius;let a=[];if(a.push(s,n+o),a=a.concat(qs(s,n+r-o,s,n+r,s+o,n+r)),a=a.concat(qs(s+h-o,n+r,s+h,n+r,s+h,n+r-o)),a=a.concat(qs(s+h,n+o,s+h,n,s+h-o,n)),a=a.concat(qs(s+o,n,s,n,s,n+o)),t.fill){const i=Re(t.fillColor),s=t.fillAlpha,n=i[0]*s,h=i[1]*s,r=i[2]*s,o=e.points,l=e.indices,d=o.length/6,u=zs(a,null,2);for(let t=0;t<u.length;t+=3)l.push(u[t]+d),l.push(u[t]+d),l.push(u[t+1]+d),l.push(u[t+2]+d),l.push(u[t+2]+d);for(let t=0;t<a.length;t+=2)o.push(a[t],a[t+1],n,h,r,s)}if(t.lineWidth){const i=t.points;t.points=a,js(t,e),t.points=i}}function Qs(t,e){const i=t.shape,s=i.x,n=i.y;let h,r;t.type===Ut?(h=i.radius,r=i.radius):(h=i.width,r=i.height);const o=2*Math.PI/40;if(t.fill){const i=Re(t.fillColor),a=t.fillAlpha,l=i[0]*a,d=i[1]*a,u=i[2]*a,c=e.points,p=e.indices;let g=c.length/6;p.push(g);for(let t=0;t<41;t+=1)c.push(s,n,l,d,u,a),c.push(s+Math.sin(o*t)*h,n+Math.cos(o*t)*r,l,d,u,a),p.push(g,g+1),g+=2;p.push(g-1)}if(t.lineWidth){const i=t.points;t.points=[];for(let e=0;e<41;e+=1)t.points.push(s+Math.sin(o*e)*h,n+Math.cos(o*e)*r);js(t,e),t.points=i}}function $s(t,e){const i=t.points.slice();if(i.length<6)return;const s=e.indices;e.points=i,e.alpha=t.fillAlpha,e.color=Re(t.fillColor);let n,h,r=1/0,o=-1/0,a=1/0,l=-1/0;for(let t=0;t<i.length;t+=2)n=i[t],h=i[t+1],r=n<r?n:r,o=n>o?n:o,a=h<a?h:a,l=h>l?h:l;i.push(r,a,o,a,o,l,r,l);const d=i.length/2;for(let t=0;t<d;t+=1)s.push(t)}function Zs(t,e){const i=t.points;if(i.length<6)return!1;const s=e.points,n=e.indices,h=i.length/2,r=Re(t.fillColor),o=t.fillAlpha,a=r[0]*o,l=r[1]*o,d=r[2]*o,u=zs(i,null,2);if(!u)return!1;const c=s.length/6;for(let t=0;t<u.length;t+=3)n.push(u[t]+c),n.push(u[t]+c),n.push(u[t+1]+c),n.push(u[t+2]+c),n.push(u[t+2]+c);for(let t=0;t<h;t+=1)s.push(i[2*t],i[2*t+1],a,l,d,o);return!0}function Js(t,e){const i=(window.PhaserRegistry.stencilBufferLimit||(window.PhaserRegistry.stencilBufferLimit=6),window.PhaserRegistry.stencilBufferLimit);let s,n,h=t._webGL[e.id];if(h||(h={lastIndex:0,data:[],gl:e},t._webGL[e.id]=h),t.dirty=!1,t.clearDirty){for(t.clearDirty=!1,s=0;s<h.data.length;s+=1){const t=h.data[s];t.reset(),Xs().push(t)}h.data=[],h.lastIndex=0}for(s=h.lastIndex;s<t.graphicsData.length;s+=1){const e=t.graphicsData[s];e.type===It?(e.points=e.shape.points.slice(),e.shape.closed&&(e.points[0]===e.points[e.points.length-2]&&e.points[1]===e.points[e.points.length-1]||e.points.push(e.points[0],e.points[1])),e.fill&&e.points.length>=i&&(e.points.length<2*i?(n=Ys(h,0),Zs(e,n)||(n=Ys(h,1),$s(e,n))):(n=Ys(h,1),$s(e,n))),e.lineWidth>0&&(n=Ys(h,0),js(e,n))):(n=Ys(h,0),e.type===Ft?Vs(e,n):e.type===Ut||e.type===Bt?Qs(e,n):e.type===Nt&&Ks(e,n)),h.lastIndex+=1}for(s=0;s<h.data.length;s+=1)n=h.data[s],n.dirty&&n.upload()}const tn=class extends Hi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;super(),this.game=t,this.type=Pt,this.position.set(e,i),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=$,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new ke(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1}destroy(){this.clear(),super.destroy()}lineStyle(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return this.lineWidth=t||0,this.lineColor=e||0,this.lineAlpha=void 0===i?1:i,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new $i(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this}moveTo(t,e){return this.drawShape(new $i([t,e])),this}lineTo(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this._boundsDirty=!0,this}quadraticCurveTo(t,e,i,s){let n,h;this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);const r=this.currentPath.shape.points;0===r.length&&this.moveTo(0,0);const o=r[r.length-2],a=r[r.length-1];let l=0;for(let d=1;d<=20;d+=1)l=d/20,n=o+(t-o)*l,h=a+(e-a)*l,r.push(n+(t+(i-t)*l-n)*l,h+(e+(s-e)*l-h)*l);return this.dirty=!0,this._boundsDirty=!0,this}bezierCurveTo(t,e,i,s,n,h){let r,o,a,l,d;this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);const u=this.currentPath.shape.points,c=u[u.length-2],p=u[u.length-1];let g=0;for(let m=1;m<=20;m+=1)g=m/20,r=1-g,o=r*r,a=o*r,l=g*g,d=l*g,u.push(a*c+3*o*g*t+3*r*l*i+d*n,a*p+3*o*g*e+3*r*l*s+d*h);return this.dirty=!0,this._boundsDirty=!0,this}arcTo(t,e,i,s,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);const h=this.currentPath.shape.points,r=h[h.length-2],o=h[h.length-1]-e,a=r-t,l=s-e,d=i-t,u=Math.abs(o*d-a*l);if(u<1e-8||0===n)h[h.length-2]===t&&h[h.length-1]===e||h.push(t,e);else{const i=o*o+a*a,s=l*l+d*d,h=o*l+a*d,r=n*Math.sqrt(i)/u,c=n*Math.sqrt(s)/u,p=r*h/i,g=c*h/s,m=r*d+c*a,f=r*l+c*o,_=a*(c+p),v=o*(c+p),x=d*(r+g),y=l*(r+g),w=Math.atan2(v-f,_-m),b=Math.atan2(y-f,x-m);this.arc(m+t,f+e,n,w,b,a*l>d*o)}return this.dirty=!0,this._boundsDirty=!0,this}arc(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]&&arguments[5],r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:40;if(s===n)return this;!h&&n<=s?n+=2*Math.PI:h&&s<=n&&(s+=2*Math.PI);const o=h?-1*(s-n):n-s,a=Math.ceil(Math.abs(o)/(2*Math.PI))*r;if(0===o)return this;const l=t+Math.cos(s)*i,d=e+Math.sin(s)*i;h&&this.filling?this.moveTo(t,e):this.moveTo(l,d);const u=this.currentPath.shape.points,c=o/(2*a),p=2*c,g=Math.cos(c),m=Math.sin(c),f=a-1,_=f%1/f;for(let n=0;n<=f;n+=1){const h=c+s+p*(n+_*n),r=Math.cos(h),o=-Math.sin(h);u.push((g*r+m*o)*i+t,(g*-o+m*r)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this}beginFill(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this}endFill(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this}drawRect(t,e,i,s){return this.drawShape(new ke(t,e,i,s)),this}drawRoundedRect(t,e,i,s,n){return this.drawShape(new qi(t,e,i,s,n)),this}drawCircle(t,e,i){return this.drawShape(new hs(t,e,i)),this}drawEllipse(t,e,i,s){return this.drawShape(new as(t,e,i,s)),this}drawPolygon(t){let e;return e=t instanceof $i?t.points:t,this.drawShape(new $i(e)),this}clear(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this}generateTexture(){console.warn("graphics.generateTexture() is not implemented")}renderWebGL(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask)if(this._cacheAsBitmap)(this.dirty||this.cachedSpriteDirty)&&(this.generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,Gi.call(this._cachedSprite,t);else{if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;const e=window.PhaserRegistry.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),function(t,e){const i=e.gl,s=e.projection,n=e.offset;let h,r=e.shaderManager.primitiveShader;t.dirty&&Js(t,i);const o=t._webGL[i.id];if(o)for(let a=0;a<o.data.length;a+=1)1===o.data[a].mode?(h=o.data[a],e.stencilManager.pushStencil(t,h,e),i.drawElements(i.TRIANGLE_FAN,4,i.UNSIGNED_SHORT,2*(h.indices.length-4)),e.stencilManager.popStencil(t,h,e)):(h=o.data[a],e.shaderManager.setShader(r),r=e.shaderManager.primitiveShader,i.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),i.uniform1f(r.flipY,1),i.uniform2f(r.projectionVector,s.x,-s.y),i.uniform2f(r.offsetVector,-n.x,-n.y),i.uniform3fv(r.tintColor,Re(t.tint)),i.uniform1f(r.alpha,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,h.buffer),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,24,0),i.vertexAttribPointer(r.colorAttribute,4,i.FLOAT,!1,24,8),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h.indexBuffer),i.drawElements(i.TRIANGLE_STRIP,h.indices.length,i.UNSIGNED_SHORT,0))}(this,t),this.children.length){t.spriteBatch.start();for(let e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount+=1,t.spriteBatch.start()}}renderCanvas(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask)if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)(this.dirty||this.cachedSpriteDirty)&&(this.generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,Wi(this._cachedSprite,t);else{const e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=window.PhaserRegistry.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);const s=t.resolution,n=i.tx*t.resolution+t.shakeX,h=i.ty*t.resolution+t.shakeY;e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,h),ps(this,e);for(let e=0;e<this.children.length;e+=1)this.children[e].renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}getBounds(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this.renderable)return Ee();if(this.dirty)this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1;else if(this.currentBounds)return this.currentBounds;const e=this._localBounds,i=e.x,s=e.width+e.x,n=e.y,h=e.height+e.y,r=t||this.worldTransform,o=r.a,a=r.b,l=r.c,d=r.d,u=r.tx,c=r.ty,p=o*s+l*h+u,g=d*h+a*s+c,m=o*i+l*h+u,f=d*h+a*i+c,_=o*i+l*n+u,v=d*n+a*i+c,x=o*s+l*n+u,y=d*n+a*s+c;let w=p,b=g,S=p,T=g;return S=m<S?m:S,S=_<S?_:S,S=x<S?x:S,T=f<T?f:T,T=v<T?v:T,T=y<T?y:T,w=m>w?m:w,w=_>w?_:w,w=x>w?x:w,b=f>b?f:b,b=v>b?v:b,b=y>b?y:b,this.cachedBounds.x=S,this.cachedBounds.width=w-S,this.cachedBounds.y=T,this.cachedBounds.height=b-T,this.currentBounds=this.cachedBounds,this.currentBounds}getLocalBounds(){const t=this.worldTransform;this.worldTransform=bi();for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();const e=this.getBounds();this.worldTransform=t;for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();return e}containsPoint(t,e){this.worldTransform.applyInverse(t,e);const i=this.graphicsData;for(let t=0;t<i.length;t+=0){const s=i[t];if(s.fill&&s.shape&&s.shape.contains(e.x,e.y))return!0}return!1}updateLocalBounds(){let t=1/0,e=-1/0,i=1/0,s=-1/0;if(this.graphicsData.length){let n,h,r,o,a,l;for(let d=0;d<this.graphicsData.length;d+=1){const u=this.graphicsData[d],c=u.type,p=u.lineWidth;if(n=u.shape,c===Ft||c===Nt)r=n.x-p/2,o=n.y-p/2,a=n.width+p,l=n.height+p,t=r<t?r:t,e=r+a>e?r+a:e,i=o<i?o:i,s=o+l>s?o+l:s;else if(c===Ut)r=n.x,o=n.y,a=n.radius+p/2,l=n.radius+p/2,t=r-a<t?r-a:t,e=r+a>e?r+a:e,i=o-l<i?o-l:i,s=o+l>s?o+l:s;else if(c===Bt)r=n.x,o=n.y,a=n.width+p/2,l=n.height+p/2,t=r-a<t?r-a:t,e=r+a>e?r+a:e,i=o-l<i?o-l:i,s=o+l>s?o+l:s;else{h=n.points;for(let n=0;n<h.length;n+=1)h[n]instanceof pe?(r=h[n].x,o=h[n].y):(r=h[n],o=h[n+1],n<h.length-1&&(n+=1)),t=r-p<t?r-p:t,e=r+p>e?r+p:e,i=o-p<i?o-p:i,s=o+p>s?o+p:s}}}else t=0,e=0,i=0,s=0;const n=this.boundsPadding;this._localBounds.x=t-n,this._localBounds.width=e-t+2*n,this._localBounds.y=i-n,this._localBounds.height=s-i+2*n}generateCachedSprite(){const t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{const e=new Li(t.width,t.height),i=us(e.canvas);this._cachedSprite=new Yi(this.game,0,0,i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,ps(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha}updateCachedSpriteTexture(){const t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=i.width,e.crop.height=i.height,e.frame.width=i.width,e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()}destroyCachedSprite(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}drawShape(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof $i&&(t=t.clone()).flatten();const e=new ls(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===It&&(e.shape.closed=this.filling,this.currentPath=e),this.dirty=!0,this._boundsDirty=!0,e}postUpdate(){this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate()}drawTriangle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=new $i(t);if(e){const e=new pe(0-t[0].x,0-t[0].y),s=new pe(t[1].x-t[0].x,t[1].y-t[0].y),n=new pe(t[1].x-t[2].x,t[1].y-t[2].y).cross(s);e.dot(n)>0&&this.drawPolygon(i)}else this.drawPolygon(i)}drawTriangles(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=new pe,n=new pe,h=new pe;let r,o=[];if(e)if(t[0]instanceof pe)for(r=0;r<e.length/3;r+=1)o.push(t[e[3*r]]),o.push(t[e[3*r+1]]),o.push(t[e[3*r+2]]),3===o.length&&(this.drawTriangle(o,i),o=[]);else for(r=0;r<e.length;r+=1)s.x=t[2*e[r]],s.y=t[2*e[r]+1],o.push(s.copyTo({})),3===o.length&&(this.drawTriangle(o,i),o=[]);else if(t[0]instanceof pe)for(r=0;r<t.length/3;r+=1)this.drawTriangle([t[3*r],t[3*r+1],t[3*r+2]],i);else for(r=0;r<t.length/6;r+=1)s.x=t[6*r+0],s.y=t[6*r+1],n.x=t[6*r+2],n.y=t[6*r+3],h.x=t[6*r+4],h.y=t[6*r+5],this.drawTriangle([s,n,h],i)}},en=class{constructor(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.mouseWheelCallback=null,this.capture=!1,this.button=-1,this.wheelDelta=0,this.enabled=!0,this.locked=!1,this.stopOnGameOut=!1,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null,this._onMouseWheel=null,this._wheelEvent=null}start(){if(this.game.device.android&&!1===this.game.device.chrome)return;if(null!==this._onMouseDown)return;const t=this;this._onMouseDown=e=>t.onMouseDown(e),this._onMouseMove=e=>t.onMouseMove(e),this._onMouseUp=e=>t.onMouseUp(e),this._onMouseUpGlobal=e=>t.onMouseUpGlobal(e),this._onMouseOutGlobal=e=>t.onMouseOutGlobal(e),this._onMouseOut=e=>t.onMouseOut(e),this._onMouseOver=e=>t.onMouseOver(e),this._onMouseWheel=e=>t.onMouseWheel(e);const e=this.game.canvas;e.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("mousemove",this._onMouseMove,!0),e.addEventListener("mouseup",this._onMouseUp,!0),window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),e.addEventListener("mouseover",this._onMouseOver,!0),e.addEventListener("mouseout",this._onMouseOut,!0);const i=this.game.device.wheelEvent;i&&e.addEventListener(i,this._onMouseWheel,!0)}stop(){const t=this.game.canvas;t.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("mousemove",this._onMouseMove,!0),t.removeEventListener("mouseup",this._onMouseUp,!0),t.removeEventListener("mouseover",this._onMouseOver,!0),t.removeEventListener("mouseout",this._onMouseOut,!0);const e=this.game.device.wheelEvent;e&&t.removeEventListener(e,this._onMouseWheel,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0)}onMouseDown(t){this.event=t,this.eventPreventDefault(t),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.start(t))}onMouseMove(t){this.event=t,this.eventPreventDefault(t),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.move(t))}onMouseUp(t){this.event=t,this.eventPreventDefault(t),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.stop(t))}onMouseUpGlobal(t){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),t.identifier=0,this.input.mousePointer.stop(t))}onMouseOutGlobal(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&this.input.mousePointer.stop(t)}onMouseOut(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(t.identifier=0,this.input.mousePointer.stop(t))}onMouseOver(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,t)}onMouseWheel(t){this._wheelEvent&&(t=this._wheelEvent.bindEvent(t)),this.event=t,this.eventPreventDefault(t),this.wheelDelta=Math.max(-1,Math.min(1,-t.deltaY)),this.mouseWheelCallback&&this.mouseWheelCallback.call(this.callbackContext,t)}eventPreventDefault(t){this.capture&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}},sn=class{constructor(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.capture=!0,this.button=-1,this.event=null,this.enabled=!0,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null}start(){if(!this.game.device.mspointer||null!==this._onMSPointerDown)return;const t=this;this._onMSPointerDown=e=>t.onPointerDown(e),this._onMSPointerMove=e=>t.onPointerMove(e),this._onMSPointerUp=e=>t.onPointerUp(e),this._onMSPointerUpGlobal=e=>t.onPointerUpGlobal(e),this._onMSPointerOut=e=>t.onPointerOut(e),this._onMSPointerOver=e=>t.onPointerOver(e);const e=this.game.canvas;e.addEventListener("MSPointerDown",this._onMSPointerDown,!1),e.addEventListener("MSPointerMove",this._onMSPointerMove,!1),e.addEventListener("MSPointerUp",this._onMSPointerUp,!1),e.addEventListener("pointerdown",this._onMSPointerDown,!1),e.addEventListener("pointermove",this._onMSPointerMove,!1),e.addEventListener("pointerup",this._onMSPointerUp,!1),e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none",window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.addEventListener("MSPointerOver",this._onMSPointerOver,!0),e.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.addEventListener("pointerover",this._onMSPointerOver,!0),e.addEventListener("pointerout",this._onMSPointerOut,!0)}stop(){if(!this.game.device.mspointer)return;const t=this.game.canvas;t.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),t.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),t.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),t.removeEventListener("pointerdown",this._onMSPointerDown,!1),t.removeEventListener("pointermove",this._onMSPointerMove,!1),t.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),t.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.removeEventListener("pointerover",this._onMSPointerOver,!0),t.removeEventListener("pointerout",this._onMSPointerOut,!0)}onPointerDown(t){this.event=t,this.eventPreventDefault(t),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.start(t):this.input.startPointer(t))}onPointerMove(t){this.event=t,this.eventPreventDefault(t),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.move(t):this.input.updatePointer(t))}onPointerUp(t){this.event=t,this.eventPreventDefault(t),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.stop(t):this.input.stopPointer(t))}onPointerUpGlobal(t){if("mouse"!==t.pointerType&&4!==t.pointerType||this.input.mousePointer.withinGame){const e=this.input.getPointerFromIdentifier(t.identifier);e&&e.withinGame&&this.onPointerUp(t)}else this.onPointerUp(t)}onPointerOut(t){let e;this.event=t,this.eventPreventDefault(t),"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.withinGame=!1:(e=this.input.getPointerFromIdentifier(t.identifier),e&&(e.withinGame=!1)),this.input.mouse.mouseOutCallback&&this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext,t),this.input.enabled&&this.enabled&&this.input.mouse.stopOnGameOut&&(t.identifier=0,e?e.stop(t):this.input.mousePointer.stop(t))}onPointerOver(t){if(this.event=t,this.eventPreventDefault(t),"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!0;else{const e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!0)}this.input.mouse.mouseOverCallback&&this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext,t)}eventPreventDefault(t){this.capture&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}},nn=class{constructor(t,e,i){this.game=t,this.id=e,this.type=Rt,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=i||_t|vt,this.target=null,this.button=null,this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===e,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new pe,this.positionDown=new pe,this.positionUp=new pe,this.circle=new hs(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null}resetButtons(){this.isDown=!1,this.isUp=!0}updateButtons(t){"down"===t.type.toLowerCase().substr(-4)?(this.isUp=!1,this.isDown=!0):(this.isUp=!0,this.isDown=!1)}start(t){const e=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(e.multiInputOverride===xt||e.multiInputOverride===wt||e.multiInputOverride===yt&&0===e.totalActivePointers)&&(e.x=this.x,e.y=this.y,e.position.setTo(this.x,this.y),e.onDown.dispatch(this,t),e.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches+=1,null!==this.targetObject&&this.targetObject._touchedHandler(this),this}update(){const t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===xt||t.multiInputOverride===wt||t.multiInputOverride===yt&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))}move(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.game.input;if(i.pollLocked)return null;if(e&&this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&i.mouse.locked&&!e&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*i.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*i.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(i.multiInputOverride===xt||i.multiInputOverride===wt||i.multiInputOverride===yt&&0===i.totalActivePointers)&&(i.activePointer=this,i.x=this.x,i.y=this.y,i.position.setTo(i.x,i.y),i.circle.x=i.x,i.circle.y=i.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY),this.game.paused)return this;let s=i.moveCallbacks.length;for(;s;)s-=1,i.moveCallbacks[s].callback.call(i.moveCallbacks[s].context,this,this.x,this.y,e);return null!==this.targetObject&&!0===this.targetObject.isDragged?!1===this.targetObject.update(this)&&(this.targetObject=null):i.interactiveItems.total>0&&this.processInteractiveObjects(e),this}processInteractiveObjects(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,n.validForInput(i,e,!1)&&(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject}swapTarget(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))}leave(t){this.withinGame=!1,this.move(t,!1)}stop(t){const e=this.game.input;return this._stateReset&&this.withinGame?(t.preventDefault(),null):(this.timeUp=this.game.time.time,(e.multiInputOverride===xt||e.multiInputOverride===wt||e.multiInputOverride===yt&&0===e.totalActivePointers)&&(e.onUp.dispatch(this,t),this.duration>=0&&this.duration<=e.tapRate&&(this.timeUp-this.previousTapTime<e.doubleTapRate?e.onTap.dispatch(this,!0):e.onTap.dispatch(this,!1),this.previousTapTime=this.timeUp)),this.isMouse?this.updateButtons(t):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&(e.currentPointers-=1),e.interactiveItems.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this)}justPressed(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time}justReleased(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time}addClickTrampoline(t,e,i,s){if(!this.isDown)return;this._clickTrampolines=this._clickTrampolines||[];const n=this._clickTrampolines;for(let e=0;e<n.length;e+=1)if(n[e].name===t){n.splice(e,1);break}n.push({name:t,targetObject:this.targetObject,callback:e,callbackContext:i,callbackArgs:s})}processClickTrampolines(){const t=this._clickTrampolines;if(t){for(let e=0;e<t.length;e+=1){const i=t[e];i.targetObject===this._trampolineTargetObject&&i.callback.apply(i.callbackContext,i.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}}reset(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null}resetMovement(){this.movementX=0,this.movementY=0}get duration(){return this.isUp?-1:this.game.time.time-this.timeDown}get worldX(){return this.x}get worldY(){return this.y}},hn=class{constructor(t){this.game=t,this.enabled=!0,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null}start(){if(!this.game.device.touch||null!==this._onTouchStart)return;const t=this;this._onTouchStart=e=>t.onTouchStart(e),this._onTouchMove=e=>t.onTouchMove(e),this._onTouchEnd=e=>t.onTouchEnd(e),this._onTouchEnter=e=>t.onTouchEnter(e),this._onTouchLeave=e=>t.onTouchLeave(e),this._onTouchCancel=e=>t.onTouchCancel(e),this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)}stop(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel))}consumeDocumentTouches(){this._documentTouchMove=t=>{t.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)}onTouchStart(t){if(this.event=t,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.startPointer(t.changedTouches[e])}}onTouchCancel(t){if(this.event=t,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled){this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.stopPointer(t.changedTouches[e])}}onTouchEnter(t){this.event=t,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&this.eventPreventDefault(t)}onTouchLeave(t){this.event=t,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,t),this.eventPreventDefault(t)}onTouchMove(t){this.event=t,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.updatePointer(t.changedTouches[e])}onTouchEnd(t){this.event=t,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.stopPointer(t.changedTouches[e])}eventPreventDefault(t){this.preventDefault&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}},rn=class{constructor(t){this.game=t,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.lockCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=wt,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.touch=null,this.mspointer=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new ni,this._localPoint=new pe,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0}boot(){this.mousePointer=new nn(this.game,0,_t),this.addPointer(),this.addPointer(),this.mouse=new en(this.game),this.touch=new hn(this.game),this.mspointer=new sn(this.game),this.onDown=new Yt,this.onUp=new Yt,this.onTap=new Yt,this.onHold=new Yt,this.scale=new pe(1,1),this.speed=new pe,this.position=new pe,this._oldPosition=new pe,this.circle=new hs(0,0,44),this.activePointer=this.mousePointer,this.hitCanvas=Di(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.game.device.mspointer?this.mspointer.start():this.game.device.touch&&this.touch.start(),this.mousePointer.active=!0;const t=this;this._onClickTrampoline=e=>t.onClickTrampoline(e),this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)}destroy(){this.mouse.stop(),this.game.device.mspointer?this.mspointer.stop():this.game.device.touch&&this.touch.stop(),this.moveCallbacks=[],Pi(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)}setInteractiveCandidateHandler(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e}addMoveCallback(t,e){this.moveCallbacks.push({callback:t,context:e})}deleteMoveCallback(t,e){let i=this.moveCallbacks.length;for(;i;)if(i-=1,this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)}addPointer(){if(this.pointers.length>=10)return console.warn("Input.addPointer: Maximum limit of 10 pointers reached."),null;const t=this.pointers.length+1,e=new nn(this.game,t,vt);return this.pointers.push(e),this["pointer"+t]=e,e}update(){if(this.pollRate>0&&this._pollCounter<this.pollRate)this._pollCounter+=1;else{this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update();for(let t=0;t<this.pointers.length;t+=1)this.pointers[t].update();this._pollCounter=0}}reset(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.game.isBooted&&!this.resetLocked){this.mousePointer.reset();for(let t=0;t<this.pointers.length;t+=1)this.pointers[t].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor="inherit"),t&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new Yt,this.onUp=new Yt,this.onTap=new Yt,this.onHold=new Yt,this.moveCallbacks=[]),this._pollCounter=0}}resetSpeed(t,e){this._oldPosition.setTo(t,e),this.speed.setTo(0,0)}startPointer(t){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(!i.active)return i.start(t)}return null}updatePointer(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.move(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.move(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.move(t)}return null}stopPointer(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.stop(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.stop(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.stop(t)}return null}countActivePointers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pointers.length,e=t;for(let t=0;t<this.pointers.length&&e>0;t+=1)this.pointers[t].active&&(e-=1);return t-e}getPointer(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active===t)return i}return null}getPointerFromIdentifier(t){for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.identifier===t)return i}return null}getPointerFromId(t){for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.pointerId===t)return i}return null}getLocalPosition(t,e){const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||new pe,s=t.worldTransform,n=1/(s.a*s.d+s.c*-s.b);return i.setTo(s.d*n*e.x+-s.c*n*e.y+(s.ty*s.c-s.tx*s.d)*n,s.a*n*e.y+-s.b*n*e.x+(-s.ty*s.a+s.tx*s.b)*n)}hitTest(t,e,i){if(!t.worldVisible)return!1;if(this.getLocalPosition(t,e,this._localPoint),i.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(t instanceof Yi){const e=t.texture.frame.width,i=t.texture.frame.height,s=-e*t.anchor.x;if(this._localPoint.x>=s&&this._localPoint.x<s+e){const e=-i*t.anchor.y;if(this._localPoint.y>=e&&this._localPoint.y<e+i)return!0}}else if(t instanceof tn)for(let e=0;e<t.graphicsData.length;e+=1){const i=t.graphicsData[e];if(i.fill&&i.shape&&i.shape.contains(this._localPoint.x,this._localPoint.y))return!0}for(let s=0;s<t.children.length;s+=1)if(this.hitTest(t.children[s],e,i))return!0;return!1}onClickTrampoline(){this.activePointer.processClickTrampolines()}get x(){return this._x}set x(t){this._x=Math.floor(t)}get y(){return this._y}set y(t){this._y=Math.floor(t)}get pollLocked(){return this.pollRate>0&&this._pollCounter<this.pollRate}get totalInactivePointers(){return this.pointers.length-this.countActivePointers()}get totalActivePointers(){return this.countActivePointers()}get worldX(){return this.x}get worldY(){return this.y}},on=class{constructor(t){this.game=t,this.cache=t.cache,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new Yt,this.onLoadComplete=new Yt,this.onPackComplete=new Yt,this.onFileStart=new Yt,this.onFileComplete=new Yt,this.onFileError=new Yt,this.maxParallelDownloads=this.game.config.maxParallelDownloads||16,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0}setPreloadSprite(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.preloadSprite={sprite:t,direction:e,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===e?new ke(0,0,1,t.height):new ke(0,0,t.width,1),t.crop(this.preloadSprite.rect),t.visible=!0}resize(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)}checkKeyExists(t,e){return this.getAssetIndex(t,e)>-1}getAssetIndex(t,e){let i=-1;for(let s=0;s<this._fileList.length;s+=1){const n=this._fileList[s];if(n.type===t&&n.key===e&&(i=s,!n.loaded&&!n.loading))break}return i}getAsset(t,e){const i=this.getAssetIndex(t,e);return i>-1?{index:i,file:this._fileList[i]}:null}reset(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll())}addToFileList(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;if(void 0===e||""===e)return console.warn("Loader: Invalid or no key given of type "+t),this;if(null==i){if(!h)return console.warn("Loader: No URL given for file type: "+t+" key: "+e),this;i=e+h}const r={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s){const t=Object.keys(s);for(let e=0;e<t.length;e+=1){const i=t[e];r[i]=s[i]}}const o=this.getAssetIndex(t,e);if(n&&o>-1){const t=this._fileList[o];t.loading||t.loaded?(this._fileList.push(r),this._totalFileCount+=1):this._fileList[o]=r}else-1===o&&(this._fileList.push(r),this._totalFileCount+=1);return this}replaceInFileList(t,e,i,s){return this.addToFileList(t,e,i,s,!0)}pack(t,e,i,s){const n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(let t=0;t<this._fileList.length+1;t+=1){const e=this._fileList[t];if(!e||!e.loaded&&!e.loading&&"packfile"!==e.type){this._fileList.splice(t,0,n),this._totalPackCount+=1;break}}return this}image(t,e,i){return this.addToFileList("image",t,e,void 0,i,".png")}images(t,e){if(Array.isArray(e))for(let i=0;i<t.length;i+=1)this.image(t[i],e[i]);else for(let e=0;e<t.length;e+=1)this.image(t[e]);return this}text(t,e,i){return this.addToFileList("text",t,e,void 0,i,".txt")}json(t,e,i){return this.addToFileList("json",t,e,void 0,i,".json")}xml(t,e,i){return this.addToFileList("xml",t,e,void 0,i,".xml")}spritesheet(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;return this.addToFileList("spritesheet",t,e,{frameWidth:i,frameHeight:s,frameMax:n,margin:h,spacing:r},!1,".png")}audio(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.game.sound.noAudio?this:("string"==typeof e&&(e=[e]),this.addToFileList("audio",t,e,{buffer:null,autoDecode:i}))}audioSprite(t,e,i,s){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return this.game.sound.noAudio||(this.audio(t,e,n),i?this.json(t+"-audioatlas",i):s&&("string"==typeof s&&(s=JSON.parse(s)),this.cache.addJSON(t+"-audioatlas","",s))),this}bitmapFont(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(null==e&&(e=t+".png"),null===i&&null===s&&(i=t+".xml"),i)this.addToFileList("bitmapfont",t,e,{atlasURL:i,xSpacing:n,ySpacing:h});else if("string"==typeof s){let i=null,r=null;try{i=JSON.parse(s)}catch(t){r=this.parseXml(s)}if(!r&&!i)throw new Error("Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",t,e,{atlasURL:null,atlasData:i||r,atlasType:i?"json":"xml",xSpacing:n,ySpacing:h})}return this}atlas(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return null==e&&(e=t+".png"),i||s||(i=t+".json"),i?this.addToFileList("textureatlas",t,e,{atlasURL:i,format:n}):this.addToFileList("textureatlas",t,e,{atlasURL:null,atlasData:s,format:n}),this}withSyncPoint(t,e){this._withSyncPointDepth+=1;try{t.call(e||this,this)}finally{this._withSyncPointDepth-=1}return this}addSyncPoint(t,e){const i=this.getAsset(t,e);return i&&(i.file.syncPoint=!0),this}removeFile(t,e){const i=this.getAsset(t,e);i&&(i.loaded||i.loading||this._fileList.splice(i.index,1))}removeAll(){this._fileList.length=0,this._flightQueue.length=0}start(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())}processLoadQueue(){if(!this.isLoading)return console.warn("Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(let t=0;t<this._flightQueue.length;t+=1){const e=this._flightQueue[t];(e.loaded||e.error)&&(this._flightQueue.splice(t,1),t-=1,e.loading=!1,e.requestUrl=null,e.requestObject=null,e.error&&this.onFileError.dispatch(e.key,e),"packfile"!==e.type?(this._loadedFileCount+=1,this.onFileComplete.dispatch(this.progress,e.key,!e.error,this._loadedFileCount,this._totalFileCount)):"packfile"===e.type&&e.error&&(this._loadedPackCount+=1,this.onPackComplete.dispatch(e.key,!e.error,this._loadedPackCount,this._totalPackCount)))}let t=!1;const e=this.maxParallelDownloads;for(let i=this._processingHead;i<this._fileList.length;i+=1){const s=this._fileList[i];if("packfile"===s.type&&!s.error&&s.loaded&&i===this._processingHead&&(this.processPack(s),this._loadedPackCount+=1,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)),s.loaded||s.error?i===this._processingHead&&(this._processingHead=i+1):!s.loading&&this._flightQueue.length<e&&("packfile"!==s.type||s.data?t||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(s),s.loading=!0,this.onFileStart.dispatch(this.progress,s.key,s.url),this.loadFile(s)):(this._flightQueue.push(s),s.loading=!0,this.loadFile(s))),!s.loaded&&s.syncPoint&&(t=!0),this._flightQueue.length>=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Loader - aborting: processing queue empty, loading may have stalled");const t=this;setTimeout((()=>{t.finishedLoading(!0)}),2e3)}}finishedLoading(t){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.reset(),this.onLoadComplete.dispatch(),this.game.state.loadComplete())}asyncComplete(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn(t,e)),this.processLoadQueue()}processPack(t){const e=t.data[t.key];if(!e)return void console.warn("Missing loader pack key",t.key);const i=Array.isArray(e)?e:e.files;for(let t=0;t<i.length;t+=1){const e=i[t];switch(e.type){case"image":this.image(e.key,e.url,e.overwrite);break;case"text":this.text(e.key,e.url,e.overwrite);break;case"json":this.json(e.key,e.url,e.overwrite);break;case"xml":this.xml(e.key,e.url,e.overwrite);break;case"spritesheet":this.spritesheet(e.key,e.url,e.frameWidth,e.frameHeight,e.frameMax,e.margin,e.spacing);break;case"audio":this.audio(e.key,e.urls?e.urls:e.url);break;case"audiosprite":this.audioSprite(e.key,e.urls?e.urls:e.url,e.jsonURL,e.jsonData);break;case"audioSprite":this.audioSprite(e.key,e.audioURL,e.jsonURL,e.jsonData);break;case"bitmapFont":this.bitmapFont(e.key,e.textureURL,e.atlasURL,e.atlasData,e.xSpacing,e.ySpacing);break;case"atlas":this.atlas(e.key,e.textureURL,e.atlasURL,e.atlasData,1)}}}transformUrl(t,e){return!!t&&(t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t:this.baseURL+e.path+t)}loadFile(t){switch(t.type){case"packfile":case"text":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(t);break;case"audio":t.url=this.getAudioURL(t.url),t.url?this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete):this.fileError(t,null,"No supported audio URL specified or device does not have audio playback support");break;case"json":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.xmlLoadComplete)}}loadImageTag(t){const e=this;t.data=new Image,t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=()=>{t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileComplete(t))},t.data.onerror=()=>{t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileError(t))},t.data.src=this.transformUrl(t.url,t)}xhrLoad(t,e,i,s,n){const h=new XMLHttpRequest;h.open("GET",e,!0),h.responseType=i,!1!==this.headers.requestedWith&&h.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&h.setRequestHeader("Accept",this.headers[t.type]),n=n||this.fileError;const r=this;h.onload=()=>{try{return 4===h.readyState&&h.status>=400&&h.status<=599?n.call(r,t,h):s.call(r,t,h)}catch(e){r.hasLoaded?r.game.exceptionHandler(e):r.asyncComplete(t,e.message||"Exception")}return null},h.onerror=()=>{try{return n.call(r,t,h)}catch(e){r.hasLoaded?r.game.exceptionHandler(e):r.asyncComplete(t,e.message||"Exception")}return null},t.requestObject=h,t.requestUrl=e,h.send()}xhrLoadWithXDR(){console.warn("loader.xhrLoadWithXDR() is not implemented")}getAudioURL(t){if(this.game.sound.noAudio)return null;for(let e=0;e<t.length;e+=1){let i=t[e],s=null;if(i.uri){if(s=i.type,i=i.uri,ri(this.game.device,s))return i}else{if(0===i.indexOf("blob:")||0===i.indexOf("data:"))return i;if(i.indexOf("?")>=0&&(i=i.substr(0,i.indexOf("?"))),s=i.substr((Math.max(0,i.lastIndexOf("."))||1/0)+1).toLowerCase(),ri(this.game.device,s))return t[e]}}return null}fileError(t,e,i){let s="Error loading asset";!i&&e&&(i=e.status),(i||0===i)&&(s=s+" ("+i+")"),this.asyncComplete(t,s)}fileComplete(t,e){let i=!0;switch(t.type){case"packfile":t.data=JSON.parse(e.responseText)||{};break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else{if(i=!1,1!==t.format)throw new Error("Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete)}break;case"bitmapfont":t.atlasURL?(i=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",((t,e)=>{let i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))}))):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"audio":t.data=e.response,this.cache.addSound(t.key,t.url,t.data),t.autoDecode&&this.game.sound.decode(t.key);break;case"text":t.data=e.responseText,this.cache.addText(t.key,t.url,t.data)}i&&this.asyncComplete(t)}jsonLoadComplete(t,e){const i=JSON.parse(e.responseText);"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)}csvLoadComplete(){console.warn("loader.csvLoadComplete() is not implemented")}xmlLoadComplete(t,e){const i=e.responseText,s=this.parseXml(i);if(!s){const i=e.responseType||e.contentType;return console.warn("Loader - "+t.key+": invalid XML ("+i+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)}parseXml(t){let e=null;try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new window.ActiveXObject("Microsoft.XMLDOM"),e.async="false",e.loadXML(t))}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}updateProgress(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)}totalLoadedFiles(){return this._loadedFileCount}totalQueuedFiles(){return this._totalFileCount-this._loadedFileCount}totalLoadedPacks(){return this._totalPackCount}totalQueuedPacks(){return this._totalPackCount-this._loadedPackCount}get progressFloat(){const t=this._loadedFileCount/this._totalFileCount*100;return Math.max(0,Math.min(100,t||0))}get progress(){return Math.round(this.progressFloat)}},an=class{constructor(t){this.game=t,this.rafId=0,this.updateBinded=this.update.bind(this)}start(){this.rafId=requestAnimationFrame(this.updateBinded)}stop(){cancelAnimationFrame(this.rafId)}update(t){this.game.update(t),this.rafId=requestAnimationFrame(this.updateBinded)}},ln=class{constructor(t,e,i){this.game=t,this.dom=new xi(t.device),this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new pe,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new Yt,this.enterIncorrectOrientation=new Yt,this.leaveIncorrectOrientation=new Yt,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new Yt,this.onFullScreenChange=new Yt,this.onFullScreenError=new Yt,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new pe(1,1),this.scaleFactorInversed=new pe(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new ke,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=N,this._fullScreenScaleMode=N,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new pe(1,1),this.trackParentInterval=2e3,this.onSizeChange=new Yt,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new ke,this._userScaleFactor=new pe(1,1),this._userScaleTrim=new pe(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new ke,this._tempBounds=new ke,this._lastReportedCanvasSize=new ke,this._lastReportedGameSize=new ke,this._booted=!1,t.config&&this.parseConfig(t.config),this.setupScale(e,i)}boot(){const t=this.compatibility;t.supportsFullScreen=this.game.device.fullscreen,this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");const e=this;this._orientationChange=t=>e.orientationChange(t),this._windowResize=t=>e.windowResize(t),window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=t=>e.fullScreenChange(t),this._fullScreenError=t=>e.fullScreenError(t),document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)}parseConfig(t){void 0!==t.scaleMode&&(this._booted?this.scaleMode=t.scaleMode:this._pendingScaleMode=t.scaleMode),void 0!==t.fullScreenScaleMode&&(this.fullScreenScaleMode=t.fullScreenScaleMode),t.fullScreenTarget?this.fullScreenTarget=t.fullScreenTarget:this.fullScreenTarget=document.documentElement}setupScale(t,e){let i;const s=new ke;""!==this.game.parent&&("string"==typeof this.game.parent?i=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(i=this.game.parent)),i?(this.parentNode=i,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds),s.width=this._parentBounds.width,s.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,s.width=this.dom.visualBounds.width,s.height=this.dom.visualBounds.height,this.offset.set(0,0));let n=0,h=0;"number"==typeof t?n=t:(this.parentScaleFactor.x=parseInt(t,10)/100,n=s.width*this.parentScaleFactor.x),"number"==typeof e?h=e:(this.parentScaleFactor.y=parseInt(e,10)/100,h=s.height*this.parentScaleFactor.y),n=Math.floor(n),h=Math.floor(h),this._gameSize.setTo(0,0,n,h),this.updateDimensions(n,h,!1)}_gameResumed(){this.queueUpdate(!0)}setGameSize(t,e){this._gameSize.setTo(0,0,t,e),this.currentScaleMode!==W&&this.updateDimensions(t,e,!0),this.queueUpdate(!0)}setUserScale(t,e,i,s){this._userScaleFactor.setTo(t,e),this._userScaleTrim.setTo(0|i,0|s),this.queueUpdate(!0)}setResizeCallback(t,e){this.onResize=t,this.onResizeContext=e}signalSizeChange(){if(this.width!==this._lastReportedCanvasSize.width||this.height!==this._lastReportedCanvasSize.height||this.game.width!==this._lastReportedGameSize.width||this.game.height!==this._lastReportedGameSize.height){const t=this.width,e=this.height;this._lastReportedCanvasSize.setTo(0,0,t,e),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.onSizeChange.dispatch(this,t,e),this.currentScaleMode===W&&(this.game.state.resize(t,e),this.game.load.resize(t,e))}}setMinMax(t,e,i,s){this.minWidth=t,this.minHeight=e,void 0!==i&&(this.maxWidth=i),void 0!==s&&(this.maxHeight=s)}preUpdate(){if(this.game.time.time<this._lastUpdate+this._updateThrottle)return;const t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);const e=this._parentBounds.width,i=this._parentBounds.height,s=this.getParentBounds(this._parentBounds),n=s.width!==e||s.height!==i,h=this.updateOrientationState();(n||h)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,s),this.updateLayout(),this.signalSizeChange());let r=2*this._updateThrottle;this._updateThrottle<t&&(r=Math.min(t,this._updateThrottleReset)),this._updateThrottle=Math.max(25,Math.min(this.trackParentInterval,r)),this._lastUpdate=this.game.time.time}pauseUpdate(){this.preUpdate(),this._updateThrottle=this.trackParentInterval}updateDimensions(t,e,i){this.width=t*this.parentScaleFactor.x,this.height=e*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),i&&this.game.renderer.resize(this.width,this.height)}updateScalingAndBounds(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)}forceOrientation(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.forceLandscape=t,this.forcePortrait=e,this.queueUpdate(!0)}classifyOrientation(t){return"portrait-primary"===t||"portrait-secondary"===t?"portrait":"landscape-primary"===t||"landscape-secondary"===t?"landscape":null}updateOrientationState(){const t=this.screenOrientation,e=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;const i=t!==this.screenOrientation,s=e!==this.incorrectOrientation;return s&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(i||s)&&this.onOrientationChange.dispatch(this,t,e),i||s}orientationChange(t){this.event=t,this.queueUpdate(!0)}windowResize(t){this.event=t,this.queueUpdate(!0)}refresh(){this.queueUpdate(!0)}updateLayout(){const t=this.currentScaleMode;if(t!==W){if(this.incorrectOrientation?this.setMaximum():t===B?this.setExactFit():t===G?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===N?(this.width=this.game.width,this.height=this.game.height):t===H&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(t===G||t===H)){const t=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,t.width),this.height=Math.min(this.height,t.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()}else this.reflowGame()}getParentBounds(t){const e=t||new ke,i=this.boundingParent,s=this.dom.visualBounds,n=this.dom.layoutBounds;if(i){const t=i.getBoundingClientRect(),h=i.offsetParent?i.offsetParent.getBoundingClientRect():i.getBoundingClientRect();e.setTo(t.left-h.left,t.top-h.top,t.width,t.height);const r=this.windowConstraints;if(r.right){const t="layout"===r.right?n:s;e.right=Math.min(e.right,t.width)}if(r.bottom){const t="layout"===r.bottom?n:s;e.bottom=Math.min(e.bottom,t.height)}}else e.setTo(0,0,s.width,s.height);return e.setTo(Math.round(e.x),Math.round(e.y),Math.round(e.width),Math.round(e.height)),e}alignCanvas(t,e){const i=this.getParentBounds(this._tempBounds),s=this.game.canvas,n=this.margin;if(t){n.left=0,n.right=0;const t=s.getBoundingClientRect();if(this.width<i.width&&!this.incorrectOrientation){const e=t.left-i.x;let s=i.width/2-this.width/2;s=Math.max(s,0);const h=s-e;n.left=Math.round(h)}s.style.marginLeft=n.left+"px",0!==n.left&&(n.right=-(i.width-t.width-n.left),s.style.marginRight=n.right+"px")}if(e){n.top=0,n.bottom=0;const t=s.getBoundingClientRect();if(this.height<i.height&&!this.incorrectOrientation){const e=t.top-i.y;let s=i.height/2-this.height/2;s=Math.max(s,0);const h=s-e;n.top=Math.round(h)}s.style.marginTop=n.top+"px",0!==n.top&&(n.bottom=-(i.height-t.height-n.top),s.style.marginBottom=n.bottom+"px")}n.x=n.left,n.y=n.top}reflowGame(){this.resetCanvas("","");const t=this.getParentBounds(this._tempBounds);this.updateDimensions(t.width,t.height,!0)}reflowCanvas(){this.incorrectOrientation||(this.width=Math.max(this.minWidth||0,Math.min(this.maxWidth||this.width,this.width)),this.height=Math.max(this.minHeight||0,Math.min(this.maxHeight||this.height,this.height))),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()}resetCanvas(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.width+"px",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.height+"px";const i=this.game.canvas;this.compatibility.noMargins||(i.style.marginLeft="",i.style.marginTop="",i.style.marginRight="",i.style.marginBottom=""),i.style.width=t,i.style.height=e}queueUpdate(t){t&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset}reset(){}setMaximum(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height}setShowAll(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getParentBounds(this._tempBounds),i=e.width,s=e.height;let n;n=t?Math.max(s/this.game.height,i/this.game.width):Math.min(s/this.game.height,i/this.game.width),this.width=Math.round(this.game.width*n),this.height=Math.round(this.game.height*n)}setExactFit(){const t=this.getParentBounds(this._tempBounds);this.width=t.width,this.height=t.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))}createFullScreenTarget(){const t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t.style.background="#000",t}startFullScreen(t,e){if(this.isFullScreen)return!1;if(!this.compatibility.supportsFullScreen){const t=this;return setTimeout((()=>{t.fullScreenError()}),10),!1}if("when-not-mouse"===this.compatibility.clickTrampoline){const i=this.game.input;if(i.activePointer&&i.activePointer!==i.mousePointer&&(e||!1!==e))return i.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1]),!1}void 0!==t&&this.game.renderer.type===mt&&(this.game.stage.smoothed=t);let i=this.fullScreenTarget;if(i||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),i=this._createdFullScreenTarget),this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,{targetElement:i}),this._createdFullScreenTarget){const t=this.game.canvas;t.parentNode.insertBefore(i,t),i.appendChild(t)}return this.game.device.fullscreenKeyboard?i[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):i[this.game.device.requestFullscreen](),!0}stopFullScreen(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen||(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),0))}cleanupCreatedTarget(){const t=this._createdFullScreenTarget;if(t&&t.parentNode){const e=t.parentNode;e.insertBefore(this.game.canvas,t),e.removeChild(t)}this._createdFullScreenTarget=null}prepScreenMode(t){const e=this._createdFullScreenTarget||this.fullScreenTarget;e&&(t?(this._createdFullScreenTarget||this.fullScreenScaleMode===B)&&e!==this.game.canvas&&(this._fullScreenRestore={targetWidth:e.style.width,targetHeight:e.style.height},e.style.width="100%",e.style.height="100%"):(this._fullScreenRestore&&(e.style.width=this._fullScreenRestore.targetWidth,e.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas()))}fullScreenChange(t){this.event=t,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)}fullScreenError(t){this.event=t,this.cleanupCreatedTarget(),this.onFullScreenError.dispatch(this)}destroy(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}get boundingParent(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}get scaleMode(){return this._scaleMode}set scaleMode(t){t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t)}get fullScreenScaleMode(){return this._fullScreenScaleMode}set fullScreenScaleMode(t){t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t)}get currentScaleMode(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}get pageAlignHorizontally(){return this._pageAlignHorizontally}get pageAlignVertically(){return this._pageAlignVertically}get isFullScreen(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}get isPortrait(){return"portrait"===this.classifyOrientation(this.screenOrientation)}get isLandscape(){return"landscape"===this.classifyOrientation(this.screenOrientation)}get isGamePortrait(){return this.height>this.width}get isGameLandscape(){return this.width>this.height}},dn=class{constructor(){this.game=null,this.key=""}init(){}preload(){}create(){}update(){}resize(){}pauseUpdate(){}shutdown(){}},un=class{constructor(t,e){this.game=t,this.states={},this._pendingState=null,null!=e&&(this._pendingState=e),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onResizeCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null}boot(){null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)}add(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=null;return e instanceof dn?s=e:"object"==typeof e?(s=e,s.game=this.game):"function"==typeof e&&(s=new e(this.game)),this.states[t]=s,i&&(this.game.isBooted?this.start(t):this._pendingState=t),s}remove(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onResizeCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]}start(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.checkState(t)){this._pendingState=t,this._clearWorld=e,this._clearCache=i;for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];n&&n.length>0&&(this._args=n.slice())}}restart(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._pendingState=this.current,this._clearWorld=t,this._clearCache=e;for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;n<i;n++)s[n-2]=arguments[n];s&&s.length>0&&(this._args=s.slice())}preUpdate(){if(this._pendingState&&this.game.isBooted){if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.game.world.x=0,this.game.world.y=0,this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}}clearCurrentState(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.input.reset(!0),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this._clearWorld&&(this.game.world.destroy(!0,!0),this._clearCache&&this.game.cache.destroy()))}checkState(t){return!!this.states[t]&&!!(this.states[t].preload||this.states[t].create||this.states[t].update||this.states[t].render)}link(t){this.states[t].game=this.game,this.states[t].key=t}unlink(t){this.states[t]&&(this.states[t].game=null)}setCurrentState(t){this.callbackContext=this.states[t],this.link(t),this.onInitCallback=this.callbackContext.init||this.dummy,this.onPreloadCallback=this.callbackContext.preload||null,this.onCreateCallback=this.callbackContext.create||null,this.onUpdateCallback=this.callbackContext.update||null,this.onResizeCallback=this.callbackContext.resize||null,this.onPauseUpdateCallback=this.callbackContext.pauseUpdate||null,this.onShutDownCallback=this.callbackContext.shutdown||this.dummy,this.current=t,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),t===this._pendingState&&(this._args=[]),this.game.isKickStart=!0}getCurrentState(){return this.states[this.current]}loadComplete(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0}update(){this._created&&this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game)}pauseUpdate(){this._created&&this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game)}resize(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)}destroy(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}dummy(){}get created(){return this._created}},cn=class{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;n||(n=t.sound.connectToMaster),this.game=t,this.name=e,this.key=e,this.loop=s,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._markedToDelete=!1,this._removeFromSoundManager=!1,this.game.sound.noAudio||(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=i*this.game.sound.volume,n&&this.gainNode.connect(this.masterGainNode)),this.onPlay=new Yt,this.onPause=new Yt,this.onResume=new Yt,this.onLoop=new Yt,this.onStop=new Yt,this.onMute=new Yt,this.onMarkerComplete=new Yt,this.onFadeComplete=new Yt,this._volume=i,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1}soundHasUnlocked(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)}addMarker(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}}removeMarker(t){delete this.markers[t]}onEndedHandler(){this._sound.onended=null,this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this._markedToDelete&&(this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))}update(){this.game.cache.checkSoundKey(this.key)?(this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.game.sound.noAudio?this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop()))):this.destroy()}loopFull(t){return this.play(null,0,t,!0)}play(t,e,i,s,n){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.game.sound.noAudio||(void 0===this._sound.stop?this._sound.noteOff(0):this._sound.stop(0),this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Sound.play: audio marker "+t+" does not exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.game.sound.noAudio?this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4===this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0:this.game.cache.isSoundDecoded(this.key)?(this._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===t?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)),this}restart(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.play(t,e,i,s,!0)}pause(){this.isPlaying&&this._sound&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())}resume(){if(this.paused&&this._sound){if(!this.game.sound.noAudio){const t=Math.max(0,this.position+this.pausedPosition/1e3);this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));const e=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,t,e):this.loop&&this.game.device.chrome?this._sound.start(0,t):this._sound.start(0,t,e)}this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}}stop(){if(this.isPlaying&&this._sound&&(this.game.sound.noAudio||(void 0===this._sound.stop?this._sound.noteOff(0):this._sound.stop(0),this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode))),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){const t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}}fadeIn(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.currentMarker;this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))}fadeOut(t){this.fadeTo(t,0)}fadeTo(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.isPlaying&&!this.paused&&e!==this.volume&&(this.fadeTween=this.game.tweens.create(this).to({volume:e},t,"Linear",!0),this.fadeTween.onComplete.add(this.fadeComplete,this))}fadeComplete(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()}destroy(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())}get mute(){return this._muted||this.game.sound.mute}set mute(t){(t=t||!1)!==this._muted&&(t?(this._muted=!0,this._muteVolume=this._tempVolume,this.game.sound.noAudio||(this.gainNode.gain.value=0)):(this._muted=!1,this.game.sound.noAudio||(this.gainNode.gain.value=this._muteVolume)),this.onMute.dispatch(this))}get volume(){return this._volume}set volume(t){this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.game.sound.noAudio||(this.gainNode.gain.value=t))}},pn=class{constructor(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(let t in this.config.spritemap){const e=this.config.spritemap[t],i=this.game.sound.add(this.key);i.addMarker(t,e.start,e.end-e.start,null,e.loop),this.sounds[t]=i}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])}play(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.sounds[t].play(t,null,e)}stop(t){if(t)this.sounds[t].stop();else for(let t in this.sounds)this.sounds[t].stop()}get(t){return this.sounds[t]}},gn=class{constructor(t){this.game=t,this.onChange=new Yt,this.context=null,this.baseLatency=0,this.noAudio=!1,this.connectToMaster=!0,this.isLocked=!1,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new ni,this._watching=!1,this._watchCallback=null,this._watchContext=null}boot(){if(this.game.config.isForceDisabledAudio)this.noAudio=!0;else{if(window.PhaserRegistry&&window.PhaserRegistry.audioContext)this.context=window.PhaserRegistry.audioContext;else if(window.AudioContext)try{this.context=new window.AudioContext}catch(t){this.context=null,this.noAudio=!0,this.isLocked=!1,this.game.exceptionHandler(t)}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(t){this.context=null,this.noAudio=!0,this.isLocked=!1,this.game.exceptionHandler(t)}null===this.context||this.context&&void 0===this.context.createGain&&void 0===this.context.createGainNode?this.noAudio=!0:(this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),this.onUnlockEventBinded=this.onUnlockEvent.bind(this),"suspended"!==this.context.state&&"interrupted"!==this.context.state||this.addUnlockHandlers(),this.context.addEventListener("statechange",(()=>{this.onChange.dispatch("onContextStateChange",{state:this.context.state,isLocked:this.isLocked}),this.isLocked||"suspended"!==this.context.state&&"interrupted"!==this.context.state?this.isLocked&&"running"===this.context.state&&this.removeUnlockHandlers():this.addUnlockHandlers()})))}}addUnlockHandlers(){this.isLocked=!0,this.onChange.dispatch("addUnlockHandlers",{state:this.context.state,isLocked:this.isLocked}),document.body.addEventListener("touchstart",this.onUnlockEventBinded,!1),document.body.addEventListener("touchend",this.onUnlockEventBinded,!1),document.body.addEventListener("click",this.onUnlockEventBinded,!1),document.body.addEventListener("keydown",this.onUnlockEventBinded,!1)}removeUnlockHandlers(){this.isLocked=!1,this.onChange.dispatch("removeUnlockHandlers",{state:this.context.state,isLocked:this.isLocked}),document.body.removeEventListener("touchstart",this.onUnlockEventBinded),document.body.removeEventListener("touchend",this.onUnlockEventBinded),document.body.removeEventListener("click",this.onUnlockEventBinded),document.body.removeEventListener("keydown",this.onUnlockEventBinded)}onUnlockEvent(t){const e=this.context.state;if("suspended"!==e&&"interrupted"!==e)return this.onChange.dispatch("onUnlockResumeDenied",{state:e,isLocked:this.isLocked,event:t}),void this.removeUnlockHandlers();this.onChange.dispatch("onContextResumeStart",{state:e,isLocked:this.isLocked,event:t}),this.context.resume().then((()=>{this.onChange.dispatch("onContextResumeResult",{initialState:e,state:this.context.state,isLocked:this.isLocked}),this.removeUnlockHandlers()})).catch((t=>{this.onChange.dispatch("onContextResumeReject",{initialState:e,state:this.context.state,isLocked:this.isLocked,error:t}),this.removeUnlockHandlers(),this.game.exceptionHandler(t,{initialState:e,state:this.context.state})}))}stopAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].stop()}pauseAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].pause()}resumeAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].resume()}decode(t){const e=this.game.cache.getSoundData(t);e&&!1===this.game.cache.isSoundDecoded(t)&&(this.game.cache.updateSound(t,"isDecoding",!0),this.context.decodeAudioData(e).then((e=>{this.game.cache.decodedSound(t,e)})).catch((e=>{this.game.exceptionHandler(e,{key:t})})))}setDecodedCallback(t,e,i){"string"==typeof t&&(t=[t]),this._watchList.reset();for(let e=0;e<t.length;e+=1)t[e]instanceof cn?this.game.cache.isSoundDecoded(t[e].key)||this._watchList.add(t[e].key):this.game.cache.isSoundDecoded(t[e])||this._watchList.add(t[e]);0===this._watchList.total?(this._watching=!1,e.call(i)):(this._watching=!0,this._watchCallback=e,this._watchContext=i)}update(){if(!this.noAudio){for(let t=0;t<this._sounds.length;t+=1)this._sounds[t].update();if(this._watching){let t=this._watchList.first;for(;t;)this.game.cache.isSoundDecoded(t)&&this._watchList.remove(t),t=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}}add(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.connectToMaster;const n=new cn(this.game,t,e,i,s);return this._sounds.push(n),n}addSprite(t){return new pn(this.game,t)}remove(t){let e=this._sounds.length;for(;e;)if(e-=1,this._sounds[e]===t)return this._sounds[e].destroy(!1),this._sounds.splice(e,1),!0;return!1}removeByKey(t){let e=this._sounds.length,i=0;for(;e;)e-=1,this._sounds[e].key===t&&(this._sounds[e].destroy(!1),this._sounds.splice(e,1),i+=1);return i}play(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.noAudio)return null;const s=this.add(t,e,i);return s.play(),s}setMute(){this._muted||(this._muted=!0,this.noAudio||(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0),this.onChange.dispatch("muted"))}unsetMute(){this._muted&&!this._codeMuted&&(this._muted=!1,this.noAudio||(this.masterGain.gain.value=this._muteVolume),this.onChange.dispatch("unmuted"))}destroy(){this.stopAll();for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].destroy();this._sounds=[],this.onChange.dispose(),this.context&&(window.PhaserRegistry?window.PhaserRegistry.audioContext=this.context:this.context.close&&this.context.close())}get mute(){return this._muted}set mute(t){if(t){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}get volume(){return this._volume}set volume(t){t<0?t=0:t>1&&(t=1),this._volume!==t&&(this._volume=t,this.noAudio||(this.masterGain.gain.value=t))}},mn=class{constructor(t,e,i,s,n,h,r,o){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=h,this.callbackContext=r,this.args=o,this.pendingDelete=!1}},fn=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.game=t,this.running=!1,this.autoDestroy=e,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new Yt,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0}create(t,e,i,s,n,h){const r=Math.round(t);let o=r;0===this._now?o+=this.game.time.time:o+=this._now;const a=new mn(this,r,o,i,e,s,n,h);return this.events.push(a),this.order(),this.expired=!1,a}add(t,e,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this.create(t,!1,0,e,i,n)}repeat(t,e,i,s){for(var n=arguments.length,h=new Array(n>4?n-4:0),r=4;r<n;r++)h[r-4]=arguments[r];return this.create(t,!1,e,i,s,h)}loop(t,e,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this.create(t,!0,0,e,i,n)}start(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(let t=0;t<this.events.length;t+=1)this.events[t].tick=this.events[t].delay+this._started}}stop(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.running=!1,t&&(this.events.length=0)}remove(t){for(let e=0;e<this.events.length;e+=1)if(this.events[e]===t)return this.events[e].pendingDelete=!0,!0;return!1}order(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)}sortHandler(t,e){return t.tick<e.tick?-1:t.tick>e.tick?1:0}clearPendingEvents(){for(this._i=this.events.length;this._i;)this._i-=1,this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0}update(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running&&this._now>=this.events[this._i].tick&&!this.events[this._i].pendingDelete;)this._newTick=this._now+this.events[this._i].delay-(this._now-this.events[this._i].tick),this._newTick<0&&(this._newTick=this._now+this.events[this._i].delay),!0===this.events[this._i].loop?(this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):this.events[this._i].repeatCount>0?(this.events[this._i].repeatCount-=1,this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):(this._marked+=1,this.events[this._i].pendingDelete=!0,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)),this._i+=1;this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy}pause(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))}_pause(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)}adjustEvents(t){for(let e=0;e<this.events.length;e+=1)if(!this.events[e].pendingDelete){let i=this.events[e].tick-t;i<0&&(i=0),this.events[e].tick=this._now+i}const e=this.nextTick-t;this.nextTick=e<0?this._now:this._now+e}resume(){if(!this.paused)return;const t=this.game.time.time;this._pauseTotal+=t-this._now,this._now=t,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}_resume(){this._codePaused||this.resume()}removeAll(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0}destroy(){this.onComplete.removeAll(),this.running=!1,this.events=[],this._len=0,this._i=0}get next(){return this.nextTick}get duration(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}get length(){return this.events.length}get ms(){return this.running?this._now-this._started-this._pauseTotal:0}get seconds(){return this.running?.001*this.ms:0}},_n=class{constructor(t){this.game=t,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.advancedTiming=!1,this.frames=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new fn(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]}boot(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time}add(t){return this._timers.push(t),t}create(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=new fn(this.game,t);return this._timers.push(e),e}removeAll(){for(let t=0;t<this._timers.length;t+=1)this._timers[t].destroy();this._timers=[],this.events.removeAll()}refresh(){const t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t}update(t){const e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e,this.prevTime=this.now,this.now=t,this.elapsed=this.now-this.prevTime,this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())}updateTimers(){let t=0,e=this._timers.length;for(;t<e;)this._timers[t].update(this.time)?t+=1:(this._timers.splice(t,1),e-=1)}updateAdvancedTiming(){this._frameCount+=1,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames+=1,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)}gamePaused(){this._pauseStarted=Date.now(),this.events.pause();let t=this._timers.length;for(;t;)t-=1,this._timers[t]._pause()}gameResumed(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();let t=this._timers.length;for(;t;)t-=1,this._timers[t]._resume()}totalElapsedSeconds(){return.001*(this.time-this._started)}elapsedSince(t){return this.time-t}elapsedSecondsSince(t){return.001*(this.time-t)}reset(){this._started=this.time,this.removeAll()}destroy(){this.reset()}get desiredFps(){return this._desiredFps}set desiredFps(t){this._desiredFps=t,this.desiredFpsMult=1/t}},vn=class{constructor(t){this.parent=t,this.game=t.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction="Linear",this.interpolationFunction=Ye,this.interpolationContext=h,this.isRunning=!1,this.isFrom=!1}to(t,e,i,s,n,h){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=h,this.isFrom=!1,this}from(t,e,i,s,n,h){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=h,this.isFrom=!0,this}start(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vEndCache[i],this.vEnd[i]=this.vStartCache[i],this.parent.target[i]=this.vStart[i]}}return this.value=0,this.yoyoCounter=0,this.repeatCounter=this.repeatTotal,this}loadValues(){const t=Object.keys(this.parent.properties);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.parent.properties[i],Array.isArray(this.vEnd[i])&&(0===this.vEnd[i].length||0===this.percent&&(this.vEnd[i]=[this.vStart[i]].concat(this.vEnd[i]))),void 0!==this.vEnd[i]?("string"==typeof this.vEnd[i]&&(this.vEnd[i]=this.vStart[i]+parseFloat(this.vEnd[i],10)),this.parent.properties[i]=this.vEnd[i]):this.vEnd[i]=this.vStart[i],this.vStartCache[i]=this.vStart[i],this.vEndCache[i]=this.vEnd[i]}return this}update(t){if(this.isRunning){if(t<this.startTime)return q}else{if(!(t>=this.startTime))return V;this.isRunning=!0}const e=this.game.time.elapsedMS;this.parent.reverse?(this.dt-=e*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=e*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);const i=Object.keys(this.vEnd);for(let t=0;t<i.length;t+=1){const e=i[t],s=this.vStart[e],n=this.vEnd[e];Array.isArray(n)?this.parent.target[e]=this.interpolationFunction.call(this.interpolationContext,n,this.value):this.parent.target[e]=s+(n-s)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():q}generateData(t){this.parent.reverse?this.dt=this.duration:this.dt=0;let e=[],i=!1;const s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);const t={},n=Object.keys(this.vEnd);for(let e=0;e<n.length;e+=1){const i=n[e],s=this.vStart[i],h=this.vEnd[i];Array.isArray(h)?t[i]=this.interpolationFunction(h,this.value):t[i]=s+(h-s)*this.value}e.push(t),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){const t=e.slice();t.reverse(),e=e.concat(t)}return e}repeat(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vStartCache[i],this.vEnd[i]=this.vEndCache[i]}return this.inReverse=!1,Q}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return Q;if(this.inReverse){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vEndCache[i],this.vEnd[i]=this.vStartCache[i]}}else{const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vStartCache[i],this.vEnd[i]=this.vEndCache[i]}this.repeatCounter>0&&(this.repeatCounter-=1)}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,K}},xn=class{constructor(t,e,i){this.game=e,this.target=t,this.manager=i,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new Yt,this.onLoop=new Yt,this.onRepeat=new Yt,this.onChildComplete=new Yt,this.onComplete=new Yt,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1}to(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Linear",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return"string"==typeof i&&this.manager.easeMap[i]&&(i=this.manager.easeMap[i]),this.isRunning||(this.timeline.push(new vn(this).to(t,e,i,n,h,r)),s&&this.start()),this}from(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Linear",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return"string"==typeof i&&this.manager.easeMap[i]&&(i=this.manager.easeMap[i]),this.isRunning?(console.warn("Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new vn(this).from(t,e,i,n,h,r)),s&&this.start(),this)}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(let t=0;t<this.timeline.length;t+=1){const e=Object.keys(this.timeline[t].vEnd);for(let t=0;t<e.length;t+=1){const i=e[t];this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1)}}for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].loadValues();return this.manager.add(this),this.isRunning=!0,(t<0||t>this.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this}stop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this}updateTweenData(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0===this.timeline.length)return this;if(-1===i)for(let i=0;i<this.timeline.length;i+=1)this.timeline[i][t]=e;else this.timeline[i][t]=e;return this}delay(t,e){return this.updateTweenData("delay",t,e)}repeat(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("repeatCounter",t,i),this.updateTweenData("repeatDelay",e,i)}repeatDelay(t,e){return this.updateTweenData("repeatDelay",t,e)}yoyo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("yoyo",t,i),this.updateTweenData("yoyoDelay",e,i)}yoyoDelay(t,e){return this.updateTweenData("yoyoDelay",t,e)}easing(t,e){return"string"==typeof t&&this.manager.easeMap[t]&&(t=this.manager.easeMap[t]),this.updateTweenData("easingFunction",t,e)}interpolation(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("interpolationFunction",t,i),this.updateTweenData("interpolationContext",e,i)}repeatAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.repeatCounter=t,this}chain(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];let s=e.length;for(;s;)s-=1,s>0?e[s-1].chainedTween=e[s]:this.chainedTween=e[s];return this}loop(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.repeatCounter=t?-1:0,this}onUpdateCallback(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,this}pause(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time}_pause(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)}resume(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].isRunning||(this.timeline[t].startTime+=this.game.time.time-this._pausedTime)}}_resume(){this._codePaused||this.resume()}update(t){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;const e=this.timeline[this.current].update(t);if(e===V)return!0;if(e===q)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(e===K)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(e===Q){let t=!1;return this.reverse?(this.current-=1,this.current<0&&(this.current=this.timeline.length-1,t=!0)):(this.current+=1,this.current===this.timeline.length&&(this.current=0,t=!0)),t?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter-=1,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}return!1}generateData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:60,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null===this.game||null===this.target)return null;for(let t=0;t<this.timeline.length;t+=1){const e=Object.keys(this.timeline[t].vEnd);for(let t=0;t<e.length;t+=1){const i=e[t];this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1)}}for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].loadValues();for(let i=0;i<this.timeline.length;i+=1)e=e.concat(this.timeline[i].generateData(t));return e}get totalDuration(){let t=0;for(let e=0;e<this.timeline.length;e+=1)t+=this.timeline[e].duration;return t}};function yn(t){return t}function wn(t){return t*t}function bn(t){return t*(2-t)}function Sn(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}function Tn(t){return t*t*t}function Cn(t){return--t*t*t+1}function Mn(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}function Pn(t){return t*t*t*t}function An(t){return 1- --t*t*t*t}function En(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}function kn(t){return t*t*t*t*t}function Dn(t){return--t*t*t*t*t+1}function Ln(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}function On(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}function Rn(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}function In(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}function Fn(t){return 0===t?0:Math.pow(1024,t-1)}function Un(t){return 1===t?1:1-Math.pow(2,-10*t)}function Bn(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}function Nn(t){return 1-Math.sqrt(1-t*t)}function Gn(t){return Math.sqrt(1- --t*t)}function Wn(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}function Hn(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))}function zn(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)}function Xn(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)}function Yn(t){const e=1.70158;return t*t*((e+1)*t-e)}function jn(t){const e=1.70158;return--t*t*((e+1)*t+e)+1}function Vn(t){const e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}function qn(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Kn(t){return 1-qn(1-t)}function Qn(t){return t<.5?.5*Kn(2*t):.5*qn(2*t-1)+.5}const $n=class{constructor(t){this.game=t,this._tweens=[],this._add=[],this.easeMap={Linear:yn,Quad:bn,Cubic:Cn,Quart:An,Quint:Dn,Sine:Rn,Expo:Un,Circ:Gn,Elastic:zn,Back:jn,Bounce:qn,"Quad.easeIn":wn,"Cubic.easeIn":Tn,"Quart.easeIn":Pn,"Quint.easeIn":kn,"Sine.easeIn":On,"Expo.easeIn":Fn,"Circ.easeIn":Nn,"Elastic.easeIn":Hn,"Back.easeIn":Yn,"Bounce.easeIn":Kn,"Quad.easeOut":bn,"Cubic.easeOut":Cn,"Quart.easeOut":An,"Quint.easeOut":Dn,"Sine.easeOut":Rn,"Expo.easeOut":Un,"Circ.easeOut":Gn,"Elastic.easeOut":zn,"Back.easeOut":jn,"Bounce.easeOut":qn,"Quad.easeInOut":Sn,"Cubic.easeInOut":Mn,"Quart.easeInOut":En,"Quint.easeInOut":Ln,"Sine.easeInOut":In,"Expo.easeInOut":Bn,"Circ.easeInOut":Wn,"Elastic.easeInOut":Xn,"Back.easeInOut":Vn,"Bounce.easeInOut":Qn},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)}getAll(){return this._tweens}removeAll(){for(let t=0;t<this._tweens.length;t+=1)this._tweens[t].pendingDelete=!0;this._add=[]}removeFrom(t,e){let i,s;if(Array.isArray(t))for(i=0,s=t.length;i<s;i+=1)this.removeFrom(t[i]);else if(t.type===bt&&e)for(i=0,s=t.children.length;i<s;i+=1)this.removeFrom(t.children[i]);else{for(i=0,s=this._tweens.length;i<s;i+=1)t===this._tweens[i].target&&this.remove(this._tweens[i]);for(i=0,s=this._add.length;i<s;i+=1)t===this._add[i].target&&this.remove(this._add[i])}}add(t){t._manager=this,this._add.push(t)}create(t){return new xn(t,this.game,this)}remove(t){let e=this._tweens.indexOf(t);-1!==e?this._tweens[e].pendingDelete=!0:(e=this._add.indexOf(t),-1!==e&&(this._add[e].pendingDelete=!0))}update(){const t=this._add.length;let e=this._tweens.length;if(0===e&&0===t)return!1;let i=0;for(;i<e;)this._tweens[i].update(this.game.time.time)?i+=1:(this._tweens.splice(i,1),e-=1);return t>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0}isTweening(t){return this._tweens.some((e=>e.target===t))}_pauseAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t]._pause()}_resumeAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t]._resume()}pauseAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t].pause()}resumeAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t].resume(!0)}};function Zn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new sh;return i.start.x=t.start.x,i.start.y=t.start.y,i.end.x=t.end.x,i.end.y=t.end.y,i}function Jn(t,e,i,s){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;const r=h||new pe,o=e.y-t.y,a=s.y-i.y,l=t.x-e.x,d=i.x-s.x,u=e.x*t.y-t.x*e.y,c=s.x*i.y-i.x*s.y,p=o*d-a*l;if(0===p)return null;if(r.x=(l*c-d*u)/p,r.y=(a*u-o*c)/p,n){const n=(s.y-i.y)*(e.x-t.x)-(s.x-i.x)*(e.y-t.y),h=((s.x-i.x)*(t.y-i.y)-(s.y-i.y)*(t.x-i.x))/n,o=((e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x))/n;return h>=0&&h<=1&&o>=0&&o<=1?r:null}return r}function th(t,e,i,s){return Jn(t.start,t.end,e.start,e.end,i,s)}function eh(t,e){if(Te(t,e))return!1;const i=t.start.x,s=t.start.y,n=t.end.x,h=t.end.y,r=e.x,o=e.y,a=e.right,l=e.bottom;let d=0;if(i>=r&&i<=a&&s>=o&&s<=l||n>=r&&n<=a&&h>=o&&h<=l)return!0;if(i<r&&n>=r){if(d=s+(h-s)*(r-i)/(n-i),d>o&&d<=l)return!0}else if(i>a&&n<=a&&(d=s+(h-s)*(a-i)/(n-i),d>=o&&d<=l))return!0;if(s<o&&h>=o){if(d=i+(n-i)*(o-s)/(h-s),d>=r&&d<=a)return!0}else if(s>l&&h<=l&&(d=i+(n-i)*(l-s)/(h-s),d>=r&&d<=a))return!0;return!1}function ih(t,e){return 2*e.normalAngle-3.141592653589793-t.angle}const sh=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.start=new pe(t,e),this.end=new pe(i,s),this.type=Gt}setTo(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this}fromSprite(t,e){return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?this.setTo(t.center.x,t.center.y,e.center.x,e.center.y):this.setTo(t.x,t.y,e.x,e.y)}fromAngle(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this}rotateAround(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this}intersects(t,e,i){return Jn(this.start,this.end,t.start,t.end,e,i)}reflect(t){return ih(this,t)}midPoint(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new pe;return t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t}centerOn(t,e){const i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)}pointOnLine(t,e){return(t-this.start.x)*(this.end.y-this.start.y)==(this.end.x-this.start.x)*(e-this.start.y)}pointOnSegment(t,e){const i=Math.min(this.start.x,this.end.x),s=Math.max(this.start.x,this.end.x),n=Math.min(this.start.y,this.end.y),h=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e)&&t>=i&&t<=s&&e>=n&&e<=h}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new pe,e=Math.random();return t.x=this.start.x+e*(this.end.x-this.start.x),t.y=this.start.y+e*(this.end.y-this.start.y),t}coordinatesOnLine(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=Math.round(this.start.x),s=Math.round(this.start.y);const n=Math.round(this.end.x),h=Math.round(this.end.y),r=Math.abs(n-i),o=Math.abs(h-s),a=i<n?1:-1,l=s<h?1:-1;let d=r-o;e.push([i,s]);let u=1;for(;i!==n||s!==h;){const n=d<<1;n>-o&&(d-=o,i+=a),n<r&&(d+=r,s+=l),u%t==0&&e.push([i,s]),u+=1}return e}clone(){return Zn(this)}get length(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}get angle(){return Math.atan2(this.end.y-this.start.y,this.end.x-this.start.x)}get slope(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}get perpSlope(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}get x(){return Math.min(this.start.x,this.end.x)}get y(){return Math.min(this.start.y,this.end.y)}get left(){return Math.min(this.start.x,this.end.x)}get right(){return Math.max(this.start.x,this.end.x)}get top(){return Math.min(this.start.y,this.end.y)}get bottom(){return Math.max(this.start.y,this.end.y)}get width(){return Math.abs(this.start.x-this.end.x)}get height(){return Math.abs(this.start.y-this.end.y)}get normalX(){return Math.cos(this.angle-1.5707963267948966)}get normalY(){return Math.sin(this.angle-1.5707963267948966)}get normalAngle(){return He(this.angle-1.5707963267948966,-Math.PI,Math.PI)}};function nh(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function hh(){return`${nh()}${nh()}-${nh()}-4${nh().substr(0,3)}-${nh()}-${nh()}${nh()}${nh()}`.toLowerCase()}function rh(){return`${nh()}${nh()}-${nh()}`.toLowerCase()}function oh(t,e,i,s,n){e=e||256,i=i||256;const h=n?document.createElement("canvas"):Di(t,e,i);return"string"==typeof s&&""!==s&&(h.id=s),h.width=e,h.height=i,h.style.display="block",h}function ah(t,e){return e=e||"rgb(0,0,0)",t.style.backgroundColor=e,t}function lh(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}function dh(t,e){return e=e||"none",t.style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}function uh(t,e){let i,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e&&("string"==typeof e?i=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(i=e)),i||(i=document.body),s&&i.style&&(i.style.overflow="hidden"),i.appendChild(t),t}function ch(t){t.parentNode&&t.parentNode.removeChild(t)}function ph(t,e,i,s,n,h,r){return t.setTransform(s,h,r,n,e,i),t}function gh(t){const e=["i","webkitI","msI","mozI","oI"];for(let i=0;i<e.length;i+=1){const s=e[e[i]]+"mageSmoothingEnabled";if(t&&t[s])return s}return null}function mh(t,e){const i=gh(t);return i&&(t[i]=e),t}function fh(t,e){const i=e.context;i.save();const s=t.alpha,n=t.worldTransform,h=e.resolution;i.setTransform(n.a*h,n.b*h,n.c*h,n.d*h,n.tx*h,n.ty*h),gs(t,i),i.clip(),t.worldAlpha=s}function _h(t){t.context.restore()}const vh=class{constructor(t){if(Bi(),this.type=mt,this.resolution=t.config.resolution,this.clearBeforeRender=t.config.clearBeforeRender,this.transparent=t.config.transparent,this.autoResize=!1,this.width=t.width*this.resolution,this.height=t.height*this.resolution,this.view=t.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),!this.context)throw new Error("Error creating Canvas 2D context.");this.refresh=!0,this.count=0,this.renderSession={context:this.context,maskManager:w,scaleMode:null,smoothProperty:gh(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)}render(t){this.context&&(this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=0,this.renderSession.shakeY=0,this.context.globalCompositeOperation="source-over",this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):t._bgColor&&(this.context.fillStyle=t._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t))}destroy(){(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.renderSession=null}resize(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===F)}renderDisplayObject(t,e,i){this.renderSession.context=e||this.context,this.renderSession.resolution=this.resolution,t.renderCanvas(this.renderSession,i)}mapBlendModes(){if(window.PhaserRegistry.blendModesCanvas)return;const t=[],e=window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY;t[$]="source-over",t[Z]="lighter",t[J]=e?"multiply":"source-over",t[tt]=e?"screen":"source-over",t[et]=e?"overlay":"source-over",t[it]=e?"darken":"source-over",t[st]=e?"lighten":"source-over",t[nt]=e?"color-dodge":"source-over",t[ht]=e?"color-burn":"source-over",t[rt]=e?"hard-light":"source-over",t[ot]=e?"soft-light":"source-over",t[at]=e?"difference":"source-over",t[lt]=e?"exclusion":"source-over",t[dt]=e?"hue":"source-over",t[ut]=e?"saturation":"source-over",t[ct]=e?"color":"source-over",t[pt]=e?"luminosity":"source-over",window.PhaserRegistry.blendModesCanvas=t}};function xh(t,e,i){let s=e;Array.isArray(e)&&(s=e.join("\n"));const n=t.createShader(i);return t.shaderSource(n,s),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.PhaserRegistry&&(window.PhaserRegistry.GL_SHADER_INFO_LOG=t.getShaderInfoLog(n)),null)}function yh(t,e,i){const s=function(t,e){return xh(t,e,t.FRAGMENT_SHADER)}(t,i),n=function(t,e){return xh(t,e,t.VERTEX_SHADER)}(t,e),h=t.createProgram();return t.attachShader(h,n),t.attachShader(h,s),t.linkProgram(h),t.getProgramParameter(h,t.LINK_STATUS)||window.PhaserRegistry&&(window.PhaserRegistry.GL_PROGRAM_INFO_LOG=t.getProgramInfoLog(h)),h}const wh=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],bh=class{constructor(t){this.gl=t,this._UID=rh(),this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.uniforms={},this.attributes=[],this.init()}init(){const t=this.gl,e=yh(t,this.vertexSrc||wh,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];const i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1)this.uniforms[i[s]].uniformLocation=t.getUniformLocation(e,i[s]);this.initUniforms(),this.program=e}initUniforms(){this.textureCount=1;const t=this.gl;let e;const i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1){const n=i[s];e=this.uniforms[n];const h=e.type;"sampler2D"===h?(e._init=!1,null!==e.value&&this.initSampler2D(e)):"mat2"===h||"mat3"===h||"mat4"===h?(e.glMatrix=!0,e.glValueLength=1,"mat2"===h?e.glFunc=t.uniformMatrix2fv:"mat3"===h?e.glFunc=t.uniformMatrix3fv:"mat4"===h&&(e.glFunc=t.uniformMatrix4fv)):(e.glFunc=t["uniform"+h],e.glValueLength="2f"===h||"2i"===h?2:"3f"===h||"3i"===h?3:"4f"===h||"4i"===h?4:1)}}initSampler2D(t){if(!t.value||!t.value.baseTexture||!t.value.baseTexture.hasLoaded)return;const e=this.gl;if(e.activeTexture(e["TEXTURE"+this.textureCount]),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){const i=t.textureData,s=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR;let h=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,r=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE;const o=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(h=e.REPEAT,r=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){const t=i.width?i.width:512,s=i.height?i.height:2,n=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,o,t,s,n,o,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,o,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount+=1}syncUniforms(){let t;this.textureCount=1;const e=this.gl,i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1){const n=i[s];t=this.uniforms[n],1===t.glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?window.PhaserRegistry.INSTANCES[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount+=1):this.initSampler2D(t))}}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}};function Sh(t,e){const i=e.gl;t.dirty&&Js(t,i),void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)}function Th(t,e){const i=e.gl;void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)}function Ch(t,e){return Object.keys(e.chars).forEach((i=>{const s=e.chars[i];s.texture=new Xi(t,new ke(s.x,s.y,s.width,s.height))})),e}const Mh=class extends Hi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:32,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"left";super(),this.game=t,this.type=Et,this.position.set(e,i),this.textWidth=0,this.textHeight=0,this._prevAnchor=new pe,this._glyphs=[],this._maxWidth=0,this._text=n.toString()||"",this._data=t.cache.getBitmapFont(s),this._font=s,this._fontSize=h,this._align=r,this._tint=16777215,this.updateText(),this.dirty=!1}destroy(){this._prevAnchor=null,this._glyphs=null,this._text=null,this._data=null,super.destroy()}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists){this.visible&&(this.game.stage.currentRenderOrderID+=1,this.renderOrderID=this.game.stage.currentRenderOrderID);for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}else this.renderOrderID=-1}setText(t){this.text=t}scanLine(t,e,i){let s=0,n=0,h=-1,r=0,o=null;const a=this._maxWidth>0?this._maxWidth:null,l=[];let d=!0;for(let u=0;u<i.length;u+=1){if(d=u===i.length-1,/(?:\r\n|\r|\n)/.test(i.charAt(u)))return{width:n,text:i.substr(0,u),end:d,chars:l};let c=i.charCodeAt(u),p=t.chars[c],g=0;void 0===p&&(c=32,p=t.chars[c]);const m=o&&p.kerning[o]?p.kerning[o]:0;if(/(\s)/.test(i.charAt(u))&&(h=u,r=n),g=(m+p.texture.width+p.xOffset)*e,a&&n+g>=a&&h>-1)return{width:r||n,text:i.substr(0,u-(u-h)),end:d,chars:l};n+=(p.xAdvance+m)*e,l.push(s+(p.xOffset+m)*e),s+=(p.xAdvance+m)*e,o=c}return{width:n,text:i,end:d,chars:l}}cleanText(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const i=this._data.font;if(!i)return"";const s=t.replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n");for(let t=0;t<s.length;t+=1){let n="";const h=s[t];for(let t=0;t<h.length;t+=1)n=i.chars[h.charCodeAt(t)]?n.concat(h[t]):n.concat(e);s[t]=n}return s.join("\n")}updateText(){const t=this._data.font;if(!t)return;let e=this.text;const i=this._fontSize/t.size,s=[];let n=0;this.textWidth=0;let h={end:0===e.length};do{h=this.scanLine(t,i,e),h.y=n,s.push(h),h.width>this.textWidth&&(this.textWidth=h.width),n+=t.lineHeight*i,e=e.substr(h.text.length+1)}while(!1===h.end);this.textHeight=n;let r=0,o=0;const a=this.textWidth*this.anchor.x,l=this.textHeight*this.anchor.y;for(let e=0;e<s.length;e+=1){const n=s[e];"right"===this._align?o=this.textWidth-n.width:"center"===this._align&&(o=(this.textWidth-n.width)/2);for(let e=0;e<n.text.length;e+=1){let s=n.text.charCodeAt(e),h=t.chars[s];void 0===h&&(s=32,h=t.chars[s]);let d=this._glyphs[r];d?d.texture=h.texture:(d=new Yi(this.game,0,0,h.texture),d.name=n.text[e],this._glyphs.push(d)),d.position.x=n.chars[e]+o-a,d.position.y=n.y+h.yOffset*i-l,d.scale.set(i),d.tint=this.tint,d.texture.requiresReTint=!0,d.parent||this.addChild(d),r+=1}}for(let t=r;t<this._glyphs.length;t+=1)this.removeChild(this._glyphs[t])}purgeGlyphs(){const t=this._glyphs.length,e=[];for(let t=0;t<this._glyphs.length;t+=1)this._glyphs[t].parent!==this?this._glyphs[t].destroy():e.push(this._glyphs[t]);return this._glyphs=[],this._glyphs=e,this.updateText(),t-e.length}updateTransform(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),super.updateTransform()}get align(){return this._align}set align(t){t===this._align||"left"!==t&&"center"!==t&&"right"!==t||(this._align=t,this.updateText())}get tint(){return this._tint}set tint(t){t!==this._tint&&(this._tint=t,this.updateText())}get font(){return this._font}set font(t){const e=t.trim();e!==this._font&&(this._font=e,this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}get fontSize(){return this._fontSize}set fontSize(t){(t=parseInt(t,10))!==this._fontSize&&t>0&&(this._fontSize=t,this.updateText())}get text(){return this._text}set text(t){const e=t.toString();e!==this._text&&(this._text=e||"",this.updateText())}get maxWidth(){return this._maxWidth}set maxWidth(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}get smoothed(){return!this._data.base.scaleMode}set smoothed(t){this._data.base.scaleMode=t?0:1}},Ph=class{constructor(t){this.sprite=t,this.game=t.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new pe,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new pe,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new pe,this.snapPoint=new pe,this._dragPoint=new pe,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new pe,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=e,this.priorityID=t;for(let t=0;t<10;t+=1)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new pe,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite}addedToGroup(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()}removedFromGroup(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)}reset(){this.enabled=!1;for(let t=0;t<10;t+=1)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}}stop(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))}destroy(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)}validForInput(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput||!i&&(this.pixelPerfectClick||this.pixelPerfectOver)||!(this.priorityID>t||this.priorityID===t&&this.sprite.renderOrderID>e))}isPixelPerfect(){return this.pixelPerfectClick||this.pixelPerfectOver}pointerX(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].x}pointerY(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].y}pointerDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDown}pointerUp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isUp}pointerTimeDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeDown}pointerTimeUp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeUp}pointerOver(t){if(!this.enabled)return!1;if(void 0===t){for(let t=0;t<10;t+=1)if(this._pointerData[t].isOver)return!0;return!1}return this._pointerData[t].isOver}pointerOut(t){if(!this.enabled)return!1;if(void 0===t)for(let t=0;t<10;t+=1)if(this._pointerData[t].isOut)return!0;return this._pointerData[t].isOut}pointerTimeOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeOver}pointerTimeOut(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeOut}pointerDragged(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDragged}checkPointerDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!!(t.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))}checkPointerOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))}checkPixel(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e&&(this.game.input.getLocalPosition(this.sprite,i,this._tempPoint),t=this._tempPoint.x,e=this._tempPoint.y),0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,t<this.sprite.texture.crop.x||t>this.sprite.texture.crop.right||e<this.sprite.texture.crop.y||e>this.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1}update(t){return null!==this.sprite&&void 0!==this.sprite.parent&&(this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=je(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):!!this._pointerData[t.id].isOver&&(this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1)):(this._pointerOutHandler(t),!1))}_pointerOverHandler(t,e){if(null===this.sprite)return;const i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){const s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.type===bt&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}_pointerOutHandler(t,e){if(null===this.sprite)return;const i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.type===bt&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}_touchedHandler(t){if(null===this.sprite)return;const e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.type===bt&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}dragTimeElapsed(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)}_releasedHandler(t){if(null===this.sprite)return;const e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;let i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.type===bt&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}updateDrag(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t.isUp)return this.stopDrag(t),!1;const i=this.globalToLocalX(t.x)+this._dragPoint.x+this.dragOffset.x,s=this.globalToLocalY(t.y)+this._dragPoint.y+this.dragOffset.y;return this.allowHorizontalDrag&&(this.sprite.x=i+0),this.allowVerticalDrag&&(this.sprite.y=s+0),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y)),this.sprite.events.onDragUpdate.dispatch(this.sprite,t,i,s,this.snapPoint,e),!0}justOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isOver&&this.overDuration(t)<e}justOut(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isOut&&this.game.time.time-this._pointerData[t].timeOut<e}justPressed(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isDown&&this.downDuration(t)<e}justReleased(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isUp&&this.game.time.time-this._pointerData[t].timeUp<e}overDuration(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isOver?this.game.time.time-this._pointerData[t].timeOver:-1}downDuration(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDown?this.game.time.time-this._pointerData[t].timeDown:-1}enableDrag(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:255,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;this._dragPoint=new pe,this.draggable=!0,this.bringToTop=e,this.dragOffset=new pe,this.dragFromCenter=t,this.pixelPerfectClick=i,this.pixelPerfectAlpha=s,n&&(this.boundsRect=n),h&&(this.boundsSprite=h)}disableDrag(){if(this._pointerData)for(let t=0;t<10;t+=1)this._pointerData[t].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1}startDrag(t){const e=this.sprite.x,i=this.sprite.y;if(this.isDragged=!0,this._draggedPointerID=t.id,this._pointerData[t.id].camX=0,this._pointerData[t.id].camY=0,this._pointerData[t.id].isDragged=!0,this.dragFromCenter){const e=this.sprite.getBounds();this.sprite.x=this.globalToLocalX(t.x)+(this.sprite.x-e.centerX),this.sprite.y=this.globalToLocalY(t.y)+(this.sprite.y-e.centerY)}this._dragPoint.setTo(this.sprite.x-this.globalToLocalX(t.x),this.sprite.y-this.globalToLocalY(t.y)),this.updateDrag(t,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.parent.bringToTop(this.sprite)),this.dragStartPoint.set(e,i),this.sprite.events.onDragStart$dispatch(this.sprite,t,e,i),this._pendingDrag=!1}globalToLocalX(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.x,t*=this.game.scale.grid.scaleFluidInversed.x),t}globalToLocalY(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.y,t*=this.game.scale.grid.scaleFluidInversed.y),t}stopDrag(t){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[t.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY),this.sprite.events.onDragStop$dispatch(this.sprite,t),!1===this.checkPointerOver(t)&&this._pointerOutHandler(t)}setDragLock(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.allowHorizontalDrag=t,this.allowVerticalDrag=e}enableSnap(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.snapX=t,this.snapY=e,this.snapOffsetX=n,this.snapOffsetY=h,this.snapOnDrag=i,this.snapOnRelease=s}disableSnap(){this.snapOnDrag=!1,this.snapOnRelease=!1}checkBoundsRect(){this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY))}checkBoundsSprite(){this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY))}},Ah="Over",Eh="Out",kh="Down",Dh="Up",Lh="Disabled",Oh=class extends Yi{constructor(t){let e=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,r=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n),this.type=Ct,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this._onDisabledFrame=null,this.onInputOver=new Yt,this.onInputOut=new Yt,this.onInputDown=new Yt,this.onInputUp=new Yt,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=vt,this.freezeFrames=!1,this.forceOut=!1,this.input=new Ph(this),this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(s,n,h,r),null!==e&&this.onInputUp.add(e,i),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)}destroy(){this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this._onDisabledFrame=null,this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose()),this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.input&&this.input.destroy(),this.input=null,super.destroy()}setEnabled(t,e){this.input.enabled=t,e?this.changeStateFrame(t?Dh:Lh):setTimeout((()=>{this.changeStateFrame(t?Dh:Lh)}),1)}clearFrames(){this.setFrames(null,null,null,null)}removedFromWorld(){this.inputEnabled=!1}setStateFrame(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s="_on"+t+"Frame";e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null}changeStateFrame(t){if(this.freezeFrames)return!1;const e=this["_on"+(this.input.enabled||!this._onDisabledFrame?t:Lh)+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)}setFrames(t,e,i,s){this.setStateFrame(Ah,t,this.input.pointerOver()),this.setStateFrame(Eh,e,!this.input.pointerOver()),this.setStateFrame(kh,i,this.input.pointerDown()),this.setStateFrame(Dh,s,this.input.pointerUp())}onInputOverHandler(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame(Ah),this.onOverMouseOnly&&!e.isMouse||this.onInputOver&&this.onInputOver.dispatch(this,e))}onInputOutHandler(t,e){this.changeStateFrame(Eh),this.onInputOut&&this.onInputOut.dispatch(this,e)}onInputDownHandler(t,e){this.changeStateFrame(kh),this.onInputDown&&this.onInputDown.dispatch(this,e)}onInputUpHandler(t,e,i){this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame(Eh):this.changeStateFrame(Dh)||(i?this.changeStateFrame(Ah):this.changeStateFrame(Eh)))}get inputEnabled(){return this.input&&this.input.enabled}set inputEnabled(t){t?null===this.input?(this.input=new Ph(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}},Rh=class extends Hi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"group",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(),this.game=t,this.type=bt,e||(e=t.world),this.name=i||"group",this.z=0,s?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):e&&(e.addChild(this),this.z=e.children.length),this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=Yi,this.cursor=null,this.inputEnableChildren=!1,this.onChildInputDown=new Yt,this.onChildInputUp=new Yt,this.onChildInputOver=new Yt,this.onChildInputOut=new Yt,this.onDestroy=new Yt,this.cursorIndex=0,this._sortProperty="z"}destroy(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===this.game||this.ignoreDestroy||(this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))}add(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return t.parent===this||(-1===i?(t.z=this.children.length,this.addChild(t)):(this.addChildAt(t,i),this.updateZ()),!this.inputEnableChildren||t.input&&!t.inputEnabled||(t.inputEnabled=!0),!e&&t.events&&t.events.onAddedToGroup$dispatch(t,this),null===this.cursor&&(this.cursor=t)),t}addAt(t,e,i){this.add(t,i,e)}getAt(t){return t<0||t>=this.children.length?-1:this.getChildAt(t)}updateZ(){let t=this.children.length;for(;t;)t-=1,this.children[t].z=t}next(){return this.cursor?(this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex+=1,this.cursor=this.children[this.cursorIndex],this.cursor):null}previous(){return this.cursor?(0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex-=1,this.cursor=this.children[this.cursorIndex],this.cursor):null}swap(t,e){this.swapChildren(t,e),this.updateZ()}bringToTop(t){return t.parent===this&&this.getIndex(t)<this.children.length&&(this.remove(t,!1,!0),this.add(t,!0)),t}sendToBack(t){return t.parent===this&&this.getIndex(t)>0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t}reverse(){this.children.reverse(),this.updateZ()}getIndex(t){return this.children.indexOf(t)}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists)for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate();else this.renderOrderID=-1}update(){let t=this.children.length;for(;t;)t-=1,this.children[t].update()}postUpdate(){for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate()}remove(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0===this.children.length||-1===this.children.indexOf(t))return!1;i||!t.events||t.destroyPhase||t.events.onRemovedFromGroup$dispatch(t,this);const s=this.removeChild(t);return this.updateZ(),this.cursor===t&&this.next(),e&&s&&s.destroy(!0),!0}removeAll(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);const s=this.removeChild(this.children[0]);t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.cursor=null}}},Ih=class extends Hi{constructor(t){super(),this.game=t}},Fh=class extends Yi{constructor(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};super(t,e,i,null),this.game=t,this.type=At,this.canvas=Di(this),this.context=this.canvas.getContext("2d"),this.padding=new pe,this.textBounds=null,this.style=null,this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this._res=t.renderer.resolution,this._text=s.toString(),this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,this.loadTexture(us(this.canvas)),this.setStyle(n),""!==this._text&&this.updateText()}destroy(){this.texture.destroy(!0),Pi(this),this.canvas=null,this.context=null,this.textBounds=null,this.style=null,this.colors=null,this.strokeColors=null,this.fontStyles=null,this.fontWeights=null,this.padding=null,this._text=null,this._fontComponents=null,super.destroy()}setShadow(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgba(0, 0, 0, 1)",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],h=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return this.style.shadowOffsetX=t,this.style.shadowOffsetY=e,this.style.shadowColor=i,this.style.shadowBlur=s,this.style.shadowStroke=n,this.style.shadowFill=h,this.dirty=!0,this}setStyle(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t=JSON.parse(JSON.stringify(t))||{},t.font=t.font||"bold 20pt Arial",t.backgroundColor=t.backgroundColor||null,t.fill=t.fill||"black",t.align=t.align||"left",t.boundsAlignH=t.boundsAlignH||"left",t.boundsAlignV=t.boundsAlignV||"top",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.maxLines=t.maxLines||0,t.shadowOffsetX=t.shadowOffsetX||0,t.shadowOffsetY=t.shadowOffsetY||0,t.shadowColor=t.shadowColor||"rgba(0,0,0,0)",t.shadowBlur=t.shadowBlur||0,t.tabs=t.tabs||0;const i=this.fontToComponents(t.font);return t.fontStyle&&(i.fontStyle=t.fontStyle),t.fontVariant&&(i.fontVariant=t.fontVariant),t.fontWeight&&(i.fontWeight=t.fontWeight),t.fontSize&&("number"==typeof t.fontSize&&(t.fontSize+="px"),i.fontSize=t.fontSize),this._fontComponents=i,t.font=this.componentsToFont(this._fontComponents),this.style=t,this.dirty=!0,e&&this.updateText(),this}updateText(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;let t=this.text;this.style.wordWrap&&(t=this.runWordWrap(this.text));const e=t.split(/(?:\r\n|\r|\n)/),i=this.style.tabs,s=[];let n=0,h=0;const r=this.determineFontProperties(this.style.font);let o=e.length;this.style.maxLines>0&&this.style.maxLines<e.length&&(o=this.style.maxLines),this._charCount=0;for(let t=0;t<o;t+=1){if(0===i)n=this.style.strokeThickness+this.padding.x,this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?n+=this.measureLine(e[t]):n+=this.context.measureText(e[t]).width,this.style.wordWrap&&(n-=this.context.measureText(" ").width);else{const s=e[t].split(/(?:\t)/);if(n=this.padding.x+this.style.strokeThickness,Array.isArray(i)){let t=0;for(let e=0;e<s.length;e+=1){let h=0;h=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(s[e]):Math.ceil(this.context.measureText(s[e]).width),e>0&&(t+=i[e-1]),n=t+h}}else for(let t=0;t<s.length;t+=1)this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?n+=this.measureLine(s[t]):n+=Math.ceil(this.context.measureText(s[t]).width),n+=We(n,i)-n}s[t]=Math.ceil(n),h=Math.max(h,s[t])}this.canvas.width=h*this._res;const a=r.fontSize+this.style.strokeThickness+this.padding.y;let l,d,u=a*o,c=this._lineSpacing;c<0&&Math.abs(c)>a&&(c=-a),0!==c&&(u+=c>0?c*e.length:c*(e.length-1)),this.canvas.height=u*this._res,this.context.scale(this._res,this._res),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round",this._charCount=0;for(let t=0;t<o;t+=1)l=this.style.strokeThickness/2,d=this.style.strokeThickness/2+t*a+r.ascent,t>0&&(d+=c*t),"right"===this.style.align?l+=h-s[t]:"center"===this.style.align&&(l+=(h-s[t])/2),this.autoRound&&(l=Math.round(l),d=Math.round(d)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[t],l,d):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[t],l,d):this.renderTabLine(e[t],l,d,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[t],l,d):this.renderTabLine(e[t],l,d,!0)));this.updateTexture(),this.dirty=!1}renderTabLine(t,e,i,s){const n=t.split(/(?:\t)/),h=this.style.tabs;let r=0;if(Array.isArray(h)){let t=0;for(let o=0;o<n.length;o+=1)o>0&&(t+=h[o-1]),r=e+t,s?this.context.fillText(n[o],r,i):this.context.strokeText(n[o],r,i)}else for(let t=0;t<n.length;t+=1){const o=Math.ceil(this.context.measureText(n[t]).width);r=We(e,h),s?this.context.fillText(n[t],r,i):this.context.strokeText(n[t],r,i),e=r+o}}updateShadow(t){t?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)}measureLine(t){let e=0;for(let i=0;i<t.length;i+=1){const s=t[i];if(this.fontWeights.length>0||this.fontStyles.length>0){const t=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(t.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(t.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(t)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),e+=this.context.measureText(s).width,this._charCount+=1}return Math.ceil(e)}updateLine(t,e,i){for(let s=0;s<t.length;s+=1){const n=t[s];if(this.fontWeights.length>0||this.fontStyles.length>0){const t=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(t.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(t.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(t)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount+=1}}clearColors(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this}clearFontValues(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this}addColor(t,e){return this.colors[e]=t,this.dirty=!0,this}addStrokeColor(t,e){return this.strokeColors[e]=t,this.dirty=!0,this}addFontStyle(t,e){return this.fontStyles[e]=t,this.dirty=!0,this}addFontWeight(t,e){return this.fontWeights[e]=t,this.dirty=!0,this}precalculateWordWrap(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)}runWordWrap(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)}advancedWordWrap(t){const e=this.context,i=this.style.wordWrapWidth;let s="";const n=t.replace(/ +/gi," ").split(/\r?\n/gi);let h=n.length;for(let t=0;t<h;t+=1){let r=n[t],o="";if(r=r.replace(/^ *|\s*$/gi,""),e.measureText(r).width<i)s+=r+"\n";else{let a=i;const l=r.split(" ");for(let i=0;i<l.length;i+=1){const s=l[i],r=s+" ";let d=e.measureText(r).width;if(d>a){if(0===i){let t=r;for(;t.length&&(t=t.slice(0,-1),d=e.measureText(t).width,!(d<=a)););if(!t.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");const n=s.substr(t.length);l[i]=n,o+=t}const u=l[i].length?i:i+1,c=l.slice(u).join(" ").replace(/[ \n]*$/gi,"");n[t+1]=c+" "+(n[t+1]||""),h=n.length;break}o+=r,a-=d}s+=o.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,""),s}basicWordWrap(t){let e="";const i=t.split("\n");for(let t=0;t<i.length;t+=1){let s=this.style.wordWrapWidth;const n=i[t].split(" ");for(let t=0;t<n.length;t+=1){const i=this.context.measureText(n[t]).width,h=i+this.context.measureText(" ").width;h>s?(t>0&&(e+="\n"),e+=n[t]+" ",s=this.style.wordWrapWidth-i):(s-=h,e+=n[t]+" ")}t<i.length-1&&(e+="\n")}return e}updateFont(t){const e=this.componentsToFont(t);this.style.font!==e&&(this.style.font=e,this.dirty=!0,this.parent&&this.updateTransform())}fontToComponents(t){const e=t.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(e){let i=e[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:t,fontStyle:e[1]||"normal",fontVariant:e[2]||"normal",fontWeight:e[3]||"normal",fontSize:e[4]||"medium",fontFamily:i}}return console.warn("[Text] Error parsing CSS font: "+t),{font:t}}componentsToFont(t){const e=[];let i;return i=t.fontStyle,i&&"normal"!==i&&e.push(i),i=t.fontVariant,i&&"normal"!==i&&e.push(i),i=t.fontWeight,i&&"normal"!==i&&e.push(i),i=t.fontSize,i&&"medium"!==i&&e.push(i),i=t.fontFamily,i&&e.push(i),e.length||e.push(t.font),e.join(" ")}setText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.text=t.toString()||"",e?this.updateText():this.dirty=!0,this}parseList(t){if(!Array.isArray(t))return this;let e="";for(let i=0;i<t.length;i+=1)Array.isArray(t[i])?(e+=t[i].join("\t"),i<t.length-1&&(e+="\n")):(e+=t[i],i<t.length-1&&(e+="\t"));return this.text=e,this.dirty=!0,this}setTextBounds(t,e,i,s){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,e,i,s):this.textBounds=new ke(t,e,i,s),this.style.wordWrapWidth>i&&(this.style.wordWrapWidth=i)),this.updateTexture(),this}updateTexture(){const t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){let t=this.textBounds.x,e=this.textBounds.y;"right"===this.style.boundsAlignH?t+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(t+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?e+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(e+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-t,this.pivot.y=-e}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()}renderWebGL(t){this.dirty&&(this.updateText(),this.dirty=!1),Gi(this,t)}renderCanvas(t){this.dirty&&(this.updateText(),this.dirty=!1),Wi(this,t)}getFontPropertiesCache(){return window.PhaserRegistry.fontPropertiesCache||(window.PhaserRegistry.fontPropertiesCache={}),window.PhaserRegistry.fontPropertiesCache}getFontPropertiesCanvas(){return window.PhaserRegistry.fontPropertiesCanvas||(window.PhaserRegistry.fontPropertiesCanvas=document.createElement("canvas")),window.PhaserRegistry.fontPropertiesCanvas}getFontPropertiesContext(){return window.PhaserRegistry.fontPropertiesContext||(window.PhaserRegistry.fontPropertiesContext=this.getFontPropertiesCanvas().getContext("2d")),window.PhaserRegistry.fontPropertiesContext}determineFontProperties(t){const e=this.getFontPropertiesCache();let i=e[t];if(!i){i={};const s=this.getFontPropertiesCanvas(),n=this.getFontPropertiesContext();n.font=t;const h=Math.ceil(n.measureText("|MÉq").width);let r=Math.ceil(n.measureText("|MÉq").width);const o=2*r;if(r=1.4*r|0,s.width=h,s.height=o,n.fillStyle="#f00",n.fillRect(0,0,h,o),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText("|MÉq",0,r),!n.getImageData(0,0,h,o))return i.ascent=r,i.descent=r+6,i.fontSize=i.ascent+i.descent,e[t]=i,i;const a=n.getImageData(0,0,h,o).data,l=a.length,d=4*h;let u,c,p=0,g=!1;for(u=0;u<r;u+=1){for(c=0;c<d;c+=4)if(255!==a[p+c]){g=!0;break}if(g)break;p+=d}for(i.ascent=r-u,p=l-d,g=!1,u=o;u>r;u-=1){for(c=0;c<d;c+=4)if(255!==a[p+c]){g=!0;break}if(g)break;p-=d}i.descent=u-r,i.descent+=6,i.fontSize=i.ascent+i.descent,e[t]=i}return i}getBounds(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.dirty&&(this.updateText(),this.dirty=!1),Ni(this,t)}get text(){return this._text}set text(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}get cssFont(){return this.componentsToFont(this._fontComponents)}set cssFont(t){this._fontComponents=this.fontToComponents(t||"bold 20pt Arial"),this.updateFont(this._fontComponents)}get font(){return this._fontComponents.fontFamily}set font(t){let e=t||"Arial";e=e.trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(e)||/['",]/.exec(e)||(e="'"+e+"'"),this._fontComponents.fontFamily=e,this.updateFont(this._fontComponents)}get fontSize(){const t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t}set fontSize(t){let e=t||"0";"number"==typeof e&&(e+="px"),this._fontComponents.fontSize=e,this.updateFont(this._fontComponents)}get fontWeight(){return this._fontComponents.fontWeight||"normal"}set fontWeight(t){this._fontComponents.fontWeight=t||"normal",this.updateFont(this._fontComponents)}get fontStyle(){return this._fontComponents.fontStyle||"normal"}set fontStyle(t){this._fontComponents.fontStyle=t||"normal",this.updateFont(this._fontComponents)}get fontVariant(){return this._fontComponents.fontVariant||"normal"}set fontVariant(t){this._fontComponents.fontVariant=t||"normal",this.updateFont(this._fontComponents)}get fill(){return this.style.fill}set fill(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}get align(){return this.style.align}set align(t){t!==this.style.align&&(this.style.align=t,this.dirty=!0)}get resolution(){return this._res}set resolution(t){t!==this._res&&(this._res=t,this.dirty=!0)}get tabs(){return this.style.tabs}set tabs(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}get boundsAlignH(){return this.style.boundsAlignH}set boundsAlignH(t){t!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}get boundsAlignV(){return this.style.boundsAlignV}set boundsAlignV(t){t!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}get stroke(){return this.style.stroke}set stroke(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}get strokeThickness(){return this.style.strokeThickness}set strokeThickness(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=t,this.dirty=!0)}get wordWrap(){return this.style.wordWrap}set wordWrap(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}get wordWrapWidth(){return this.style.wordWrapWidth}set wordWrapWidth(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}get lineSpacing(){return this._lineSpacing}set lineSpacing(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}get shadowOffsetX(){return this.style.shadowOffsetX}set shadowOffsetX(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}get shadowOffsetY(){return this.style.shadowOffsetY}set shadowOffsetY(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}get shadowColor(){return this.style.shadowColor}set shadowColor(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}get shadowBlur(){return this.style.shadowBlur}set shadowBlur(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}get shadowStroke(){return this.style.shadowStroke}set shadowStroke(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}get shadowFill(){return this.style.shadowFill}set shadowFill(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}get width(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width}set width(t){this.scale.x=t/this.texture.frame.width,this._width=t}get height(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height}set height(t){this.scale.y=t/this.texture.frame.height,this._height=t}},Uh=class extends Rh{constructor(t){super(t,null,"__world",!1)}boot(){this.game.stage.addChild(this)}},Bh=class extends Hi{constructor(t){super(),this.game=t,this.name="_stage_root",this.worldTransform=new Ti,this.currentRenderOrderID=0,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},t.config.transparent||(this._bgColor.a=1),t.config.backgroundColor&&!this.game.config.transparent&&this.setBackgroundColor(t.config.backgroundColor)}setBackgroundColor(t){this.game.config.transparent||(Je(t,this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)}boot(){dh(this.game.canvas,"none"),lh(this.game.canvas,"none")}preUpdate(){this.currentRenderOrderID=0;for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}update(){let t=this.children.length;for(;t;)t-=1,this.children[t].update()}postUpdate(){for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate();this.updateTransform()}updateTransform(){this.worldAlpha=1;for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform()}destroy(){this.exists=!1,this.game=null,this.worldTransform=null,this._bgColor=null}get backgroundColor(){return this._bgColor.color}set backgroundColor(t){this.setBackgroundColor(t)}get smoothed(){return window.PhaserRegistry.TEXTURE_SCALE_MODE===F}set smoothed(t){window.PhaserRegistry.TEXTURE_SCALE_MODE=t?F:U}},Nh=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};window.PhaserRegistry||(window.PhaserRegistry={}),this.config={},this.id=0,this.parent="",this.width=800,this.height=600,this.renderer=null,this.state=null,this.isBooted=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.device=new hi,this.canvas=null,this.context=null,this.onPause=new Yt,this.onResume=new Yt,this.onBoot=new Yt,this.isPaused=!1,this.parseConfig(t),oi(this.device),"complete"===document.readyState?(pi(this.device),this.boot()):window.addEventListener("load",(()=>{pi(this.device),this.boot()}),!1)}boot(){this.isBooted||(this.isBooted=!0,this.scale=new ln(this,this.config.width,this.config.height),this.stage=new Bh(this),this.initRenderer(),this.world=new Uh(this),this.add=new class{constructor(t){this.game=t}existing(t){return this.game.world.add(t)}image(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return n||(n=this.game.world),n.add(new Yi(this.game,t,e,i,s))}group(t,e,i){return new Rh(this.game,t,e,i)}spriteBatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"group",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return new Ih(this.game,t,e,i)}audio(t,e,i,s){return console.warn("[GameObjectFactory] game.add.audio() is deprecated, use game.sound.add() directly."),this.game.sound.add(t,e,i,s)}sound(t,e,i,s){return console.warn("[GameObjectFactory] game.add.sound() is deprecated, use game.sound.add() directly."),this.game.sound.add(t,e,i,s)}text(t,e,i,s){return((arguments.length>4&&void 0!==arguments[4]?arguments[4]:null)||this.game.world).add(new Fh(this.game,t,e,i,s))}button(t,e,i,s,n,h,r,o,a){return((arguments.length>9&&void 0!==arguments[9]?arguments[9]:null)||this.game.world).add(new Oh(this.game,t,e,i,s,n,h,r,o,a))}graphics(t,e){return((arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||this.game.world).add(new tn(this.game,t,e))}bitmapText(t,e,i,s,n){return((arguments.length>5&&void 0!==arguments[5]?arguments[5]:null)||this.game.world).add(new Mh(this.game,t,e,i,s,n))}tween(t){return console.warn("game.add.tween(target) is deprecated, please use game.tweens.create(target) directly."),this.game.tweens.create(t)}}(this),this.cache=new class{constructor(t){this.game=t,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},text:{},json:{},xml:{},bitmapData:{},bitmapFont:{},renderTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new Yt,this._cacheMap=[],this._cacheMap[0]=this._cache.canvas,this._cacheMap[1]=this._cache.image,this._cacheMap[2]=this._cache.texture,this._cacheMap[3]=this._cache.sound,this._cacheMap[4]=this._cache.text,this._cacheMap[5]=this._cache.bitmapData,this._cacheMap[6]=this._cache.bitmapFont,this._cacheMap[7]=this._cache.json,this._cacheMap[8]=this._cache.xml,this._cacheMap[9]=this._cache.renderTexture,this.addDefaultImage(),this.addMissingImage()}addDefaultImage(){const t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";const e=this.addImage("__default",null,t);e.base.skipRender=!0,window.PhaserRegistry.CACHE_DEFAULT_IMAGE=new Xi(e.base)}addMissingImage(){const t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";const e=this.addImage("__missing",null,t);window.PhaserRegistry.CACHE_MISSING_IMAGE=new Xi(e.base)}addImage(t,e,i){this.checkImageKey(t)&&this.removeImage(t);const s={key:t,url:e,data:i,base:new ds(i),frame:new ei(0,0,0,i.width,i.height,t),frameData:new ti};return s.frameData.addFrame(new ei(0,0,0,i.width,i.height,e)),this._cache.image[t]=s,this._resolveURL(e,s),s}addTextureAtlas(t,e,i,s){const n={key:t,url:e,data:i,base:new ds(i)};n.frameData=si(this.game,s),this._cache.image[t]=n,this._resolveURL(e,n)}addSound(t,e,i){this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:!1,locked:this.game.sound.isLocked},this._resolveURL(e,this._cache.sound[t])}addText(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])}addBitmapFont(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;const o={url:e,data:i,font:null,base:new ds(i)};o.font="json"===n?function(t,e,i,s){const n={font:t.font.info._face,size:parseInt(t.font.info._size,10),lineHeight:parseInt(t.font.common._lineHeight,10)+s,chars:{}};return t.font.chars.char.forEach((t=>{const e=parseInt(t._id,10);n.chars[e]={x:parseInt(t._x,10),y:parseInt(t._y,10),width:parseInt(t._width,10),height:parseInt(t._height,10),xOffset:parseInt(t._xoffset,10),yOffset:parseInt(t._yoffset,10),xAdvance:parseInt(t._xadvance,10)+i,kerning:{}}})),t.font.kernings&&t.font.kernings.kerning&&t.font.kernings.kerning.forEach((t=>{n.chars[t._second].kerning[t._first]=parseInt(t._amount,10)})),Ch(e,n)}(s,o.base,h,r):function(t,e,i,s){const n={},h=t.getElementsByTagName("info")[0],r=t.getElementsByTagName("common")[0];n.font=h.getAttribute("face"),n.size=parseInt(h.getAttribute("size"),10),n.lineHeight=parseInt(r.getAttribute("lineHeight"),10)+s,n.chars={};const o=t.getElementsByTagName("char");for(let t=0;t<o.length;t+=1){const e=parseInt(o[t].getAttribute("id"),10);n.chars[e]={x:parseInt(o[t].getAttribute("x"),10),y:parseInt(o[t].getAttribute("y"),10),width:parseInt(o[t].getAttribute("width"),10),height:parseInt(o[t].getAttribute("height"),10),xOffset:parseInt(o[t].getAttribute("xoffset"),10),yOffset:parseInt(o[t].getAttribute("yoffset"),10),xAdvance:parseInt(o[t].getAttribute("xadvance"),10)+i,kerning:{}}}const a=t.getElementsByTagName("kerning");for(let t=0;t<a.length;t+=1){const e=parseInt(a[t].getAttribute("first"),10),i=parseInt(a[t].getAttribute("second"),10),s=parseInt(a[t].getAttribute("amount"),10);n.chars[i].kerning[e]=s}return Ch(e,n)}(s,o.base,h,r),this._cache.bitmapFont[t]=o,this._resolveURL(e,o)}addJSON(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])}addXML(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])}reloadSound(t){const e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",(()=>e.reloadSoundComplete(t)),!1),i.data.load())}reloadSoundComplete(t){const e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))}updateSound(t,e,i){const s=this.getSound(t);s&&(s[e]=i)}decodedSound(t,e){const i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1}isSoundDecoded(t){const e=this.getItem(t,3,"isSoundDecoded");return e?e.decoded:null}isSoundReady(t){const e=this.getItem(t,3,"isSoundDecoded");return!!e&&e.decoded&&!this.game.sound.isLocked}checkKey(t,e){return!!this._cacheMap[t][e]}checkURL(t){return!!this._urlMap[this._resolveURL(t)]}checkCanvasKey(t){return this.checkKey(0,t)}checkImageKey(t){return this.checkKey(1,t)}checkTextureKey(t){return this.checkKey(2,t)}checkSoundKey(t){return this.checkKey(3,t)}checkTextKey(t){return this.checkKey(4,t)}checkBitmapDataKey(t){return this.checkKey(5,t)}checkBitmapFontKey(t){return this.checkKey(6,t)}checkJSONKey(t){return this.checkKey(7,t)}checkXMLKey(t){return this.checkKey(8,t)}getItem(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return this.checkKey(e,t)?s?this._cacheMap[e][t][s]:this._cacheMap[e][t]:null}getCanvas(t){return this.getItem(t,0,"getCanvas","canvas")}getImage(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__default",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.getItem(t,1,"getImage");return null===i&&(i=this.getItem("__missing",1,"getImage")),e?i:i.data}getTextureFrame(t){return this.getItem(t,2,"getTextureFrame","frame")}getSound(t){return this.getItem(t,3,"getSound")}getSoundData(t){return this.getItem(t,3,"getSoundData","data")}getText(t){return this.getItem(t,4,"getText","data")}getBitmapData(t){return this.getItem(t,5,"getBitmapData","data")}getBitmapFont(t){return this.getItem(t,6,"getBitmapFont")}getJSON(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.getItem(t,7,"getJSON","data");return e?7..parse(7..stringify(i)):i}getXML(t){return this.getItem(t,8,"getXML","data")}getRenderTexture(t){return this.getItem(t,9,"getRenderTexture")}getBaseTexture(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getBaseTexture","base")}getFrame(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getFrame","frame")}getFrameCount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=this.getFrameData(t,e);return i?i.total:0}getFrameData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getFrameData","frameData")}hasFrameData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return null!==this.getItem(t,e,"","frameData")}updateFrameData(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this._cacheMap[i][t]&&(this._cacheMap[i][t].frameData=e)}getFrameByIndex(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const s=this.getFrameData(t,i);return s?s.getFrame(e):null}getFrameByName(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const s=this.getFrameData(t,i);return s?s.getFrameByName(e):null}getURL(t){const e=this._resolveURL(t);return e?this._urlMap[e]:(console.warn("Cache invalid url",e),null)}getKeys(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const e=[];if(this._cacheMap[t]){const i=Object.keys(this._cacheMap[t]);for(let t=0;t<i.length;t+=1){const s=i[t];"__default"!==s&&"__missing"!==s&&e.push(s)}}return e}removeCanvas(t){delete this._cache.canvas[t]}removeImage(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]}removeSound(t){delete this._cache.sound[t]}removeText(t){delete this._cache.text[t]}removeBitmapData(t){delete this._cache.bitmapData[t]}removeBitmapFont(t){delete this._cache.bitmapFont[t]}removeJSON(t){delete this._cache.json[t]}removeXML(t){delete this._cache.xml[t]}removeRenderTexture(t){delete this._cache.renderTexture[t]}removeSpriteSheet(t){delete this._cache.spriteSheet[t]}removeTextureAtlas(t){delete this._cache.atlas[t]}clearGLTextures(){const t=Object.keys(this._cache.image);for(let e=0;e<t.length;e+=1){const i=t[e];this._cache.image[i].base._glTextures=[]}}_resolveURL(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null}destroy(){for(let t=0;t<this._cacheMap.length;t+=1){const e=this._cacheMap[t],i=e?Object.keys(e):[];for(let t=0;t<i.length;t+=1){const s=i[t];"__default"!==s&&"__missing"!==s&&(e[s].destroy&&e[s].destroy(),delete e[s])}}this._urlMap=null,this._urlResolver=null,this._urlTemp=null}}(this),this.load=new on(this),this.time=new _n(this),this.tweens=new $n(this),this.input=new rn(this),this.sound=new gn(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),window.focus&&window.focus(),this.config.isSkipTicker||(this.raf=new an(this),this.raf.start()),this.onBoot.dispatch(this))}initRenderer(){this.config.canvas?this.canvas=this.config.canvas:this.canvas=oh(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%";let t=!1;if(this.config.renderType===gt||this.config.renderType===ft)try{this.renderer=new class{constructor(t){this.type=ft,this.resolution=t.config.resolution,this.autoResize=!1,this.clearBeforeRender=t.config.clearBeforeRender,this.width=t.width,this.height=t.height,this.view=t.canvas,this._contextOptions={alpha:t.config.transparent,depth:!1,antialias:t.config.antialias,premultipliedAlpha:t.config.transparent&&"notMultiplied"!==t.config.transparent,stencil:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:t.config.preserveDrawingBuffer},this.projection=new pe,this.offset=new pe,this.shaderManager=new class{constructor(){this.gl=null,this.primitiveShader=null,this.complexPrimitiveShader=null,this.defaultShader=null,this.fastShader=null,this.stripShader=null,this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(let t=0;t<this.maxAttibs;t+=1)this.attribState[t]=!1;this.stack=[]}setContext(t){this.gl=t,this.primitiveShader=new class{constructor(t){this.gl=t,this._UID=rh(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()}init(){const t=this.gl,e=yh(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}}(t),this.complexPrimitiveShader=new class{constructor(t){this.gl=t,this._UID=rh(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()}init(){const t=this.gl,e=yh(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null}}(t),this.defaultShader=new bh(t),this.fastShader=new class{constructor(t){this.gl=t,this._UID=rh(),this.program=null,this.textureCount=0,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.init()}init(){const t=this.gl,e=yh(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}}(t),this.stripShader=new class{constructor(t){this.gl=t,this._UID=rh(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()}init(){const t=this.gl,e=yh(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null}}(t),this.setShader(this.defaultShader)}setAttribs(t){let e;for(e=0;e<this.tempAttribState.length;e+=1)this.tempAttribState[e]=!1;for(e=0;e<t.length;e+=1){const i=t[e];this.tempAttribState[i]=!0}const i=this.gl;for(e=0;e<this.attribState.length;e+=1)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?i.enableVertexAttribArray(e):i.disableVertexAttribArray(e))}setShader(t){return this._currentId!==t._UID&&(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)}destroy(){this.attribState=null,this.tempAttribState=null,this.currentShader=null,this._currentId=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null}},this.spriteBatch=new class{constructor(){this.vertSize=5,this.size=2e3;const t=4*this.size*4*this.vertSize,e=6*this.size;this.vertices=new ArrayBuffer(t),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(e),this.lastIndexCount=0;for(let t=0,i=0;t<e;t+=6,i+=4)this.indices[t+0]=i+0,this.indices[t+1]=i+1,this.indices[t+2]=i+2,this.indices[t+3]=i+0,this.indices[t+4]=i+2,this.indices[t+5]=i+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new class{constructor(t,e){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=e||{},this.fragmentSrc=t||[]}syncUniforms(){for(let t=0,e=this.shaders.length;t<e;t+=1)this.shaders[t].dirty=!0}}(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])}setContext(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999;const e=new bh(t);e.fragmentSrc=this.defaultShader.fragmentSrc,e.uniforms={},e.init(),this.defaultShader.shaders[t.id]=e}begin(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()}end(){this.flush()}render(t,e){const i=t.texture;let s=t.worldTransform;e&&(s=e),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);const n=i._uvs;if(!n)return;const h=t.anchor.x,r=t.anchor.y;let o,a,l,d;if(i.trim){const t=i.trim;a=t.x-h*t.width,o=a+i.crop.width,d=t.y-r*t.height,l=d+i.crop.height}else o=i.frame.width*(1-h),a=i.frame.width*-h,l=i.frame.height*(1-r),d=i.frame.height*-r;const u=4*this.currentBatchSize*this.vertSize,c=i.baseTexture.resolution,p=s.a/c,g=s.b/c,m=s.c/c,f=s.d/c,_=s.tx,v=s.ty,x=this.colors,y=this.positions;this.renderSession.roundPixels?(y[u]=p*a+m*d+_|0,y[u+1]=f*d+g*a+v|0,y[u+5]=p*o+m*d+_|0,y[u+6]=f*d+g*o+v|0,y[u+10]=p*o+m*l+_|0,y[u+11]=f*l+g*o+v|0,y[u+15]=p*a+m*l+_|0,y[u+16]=f*l+g*a+v|0):(y[u]=p*a+m*d+_,y[u+1]=f*d+g*a+v,y[u+5]=p*o+m*d+_,y[u+6]=f*d+g*o+v,y[u+10]=p*o+m*l+_,y[u+11]=f*l+g*o+v,y[u+15]=p*a+m*l+_,y[u+16]=f*l+g*a+v),y[u+2]=n.x0,y[u+3]=n.y0,y[u+7]=n.x1,y[u+8]=n.y1,y[u+12]=n.x2,y[u+13]=n.y2,y[u+17]=n.x3,y[u+18]=n.y3;const w=t.tint;x[u+4]=(w>>16)+(65280&w)+((255&w)<<16)+(255*t.worldAlpha<<24),x[u+9]=x[u+4],x[u+14]=x[u+4],x[u+19]=x[u+4],this.sprites[this.currentBatchSize]=t,this.currentBatchSize+=1}renderTilingSprite(){}flush(){if(0===this.currentBatchSize)return;const t=this.gl;let e,i,s,n;if(this.dirty){this.dirty=!1,t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e=this.defaultShader.shaders[t.id];const i=4*this.vertSize;t.vertexAttribPointer(e.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(e.aTextureCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(e.colorAttribute,4,t.UNSIGNED_BYTE,!0,i,16)}if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{const e=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}let h,r=0,o=0,a=null,l=this.renderSession.blendModeManager.currentBlendMode,d=null,u=!1,c=!1;for(let p=0,g=this.currentBatchSize;p<g;p+=1){h=this.sprites[p],i=h.tilingTexture?h.tilingTexture.baseTexture:h.texture.baseTexture,s=h.blendMode,n=h.shader||this.defaultShader,u=l!==s,c=!d||!n||d._UID!==n._UID;let g=i.skipRender;if(g&&h.children.length>0&&(g=!1),(a!==i&&!g||u||c)&&(this.renderBatch(a,r,o),o=p,r=0,a=i,u&&(l=s,this.renderSession.blendModeManager.setBlendMode(l)),c)){d=n,e=d.shaders[t.id],e||(e=new bh(t),e.fragmentSrc=d.fragmentSrc,e.uniforms=d.uniforms,e.init(),d.shaders[t.id]=e),this.renderSession.shaderManager.setShader(e),e.dirty&&e.syncUniforms();const i=this.renderSession.projection;t.uniform2f(e.projectionVector,i.x,i.y);const s=this.renderSession.offset;t.uniform2f(e.offsetVector,s.x,s.y)}r+=1}this.renderBatch(a,r,o),this.currentBatchSize=0}renderBatch(t,e,i){if(0===e)return;const s=this.gl;if(t._dirty[s.id]){if(!this.renderSession.renderer.updateTexture(t))return}else s.bindTexture(s.TEXTURE_2D,t._glTextures[s.id]);s.drawElements(s.TRIANGLES,6*e,s.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount+=1}stop(){this.flush(),this.dirty=!0}start(){this.dirty=!0}destroy(){this.vertices=null,this.positions=null,this.colors=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null}},this.filterManager=new class{constructor(){this.filterStack=[],this.offsetX=0,this.offsetY=0}setContext(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()}begin(){}pushFilter(){}popFilter(){}applyFilterPass(){}initShaderBuffers(){}destroy(){}},this.stencilManager=new class{constructor(){this.stencilStack=[],this.reverse=!0,this.count=0}setContext(t){this.gl=t}destroy(){this.stencilStack=null,this.gl=null}pushStencil(t,e,i){const s=i.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);const n=this.count;s.colorMask(!1,!1,!1,!1),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),1===e.mode?(s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?s.stencilFunc(s.EQUAL,255-(n+1),255):s.stencilFunc(s.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n+1,255):s.stencilFunc(s.EQUAL,255-(n+1),255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.count+=1}bindGraphics(t,e,i){const s=i.gl,n=i.projection,h=i.offset;let r;1===e.mode?(r=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(r),s.uniform1f(r.flipY,i.flipY),s.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform2f(r.projectionVector,n.x,-n.y),s.uniform2f(r.offsetVector,-h.x,-h.y),s.uniform3fv(r.tintColor,Re(t.tint)),s.uniform3fv(r.color,e.color),s.uniform1f(r.alpha,t.worldAlpha*e.alpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(r.aVertexPosition,2,s.FLOAT,!1,8,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(r=i.shaderManager.primitiveShader,i.shaderManager.setShader(r),s.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform1f(r.flipY,i.flipY),s.uniform2f(r.projectionVector,n.x,-n.y),s.uniform2f(r.offsetVector,-h.x,-h.y),s.uniform3fv(r.tintColor,Re(t.tint)),s.uniform1f(r.alpha,t.worldAlpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(r.aVertexPosition,2,s.FLOAT,!1,24,0),s.vertexAttribPointer(r.colorAttribute,4,s.FLOAT,!1,24,8),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer))}popStencil(t,e,i){const s=i.gl;if(this.stencilStack.pop(),this.count-=1,0===this.stencilStack.length)s.disable(s.STENCIL_TEST);else{const n=this.count;this.bindGraphics(t,e,i),s.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)):(this.reverse?(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP)}}},this.blendModeManager=new class{constructor(){this.gl=null,this.currentBlendMode=99999}setContext(t){this.gl=t}setBlendMode(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;const e=window.PhaserRegistry.blendModesWebGL[this.currentBlendMode];return e&&this.gl.blendFunc(e[0],e[1]),!0}destroy(){this.gl=null}},this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=b,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()}destroy(){if(window.PhaserRegistry.GL_CONTEXTS[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.filterManager=null,this.gl){this.gl.canvas.width=1,this.gl.canvas.height=1;const t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext()}this.gl=null,this.renderSession=null,Pi(this),window.PhaserRegistry.INSTANCES[this.glContextId]=null,window.PhaserRegistry.GL_CONTEXT_ID-=1}initRegistry(){window.PhaserRegistry.GL_CONTEXT_ID||(window.PhaserRegistry.GL_CONTEXT_ID=0),window.PhaserRegistry.GL_CONTEXTS||(window.PhaserRegistry.GL_CONTEXTS=[]),window.PhaserRegistry.INSTANCES||(window.PhaserRegistry.INSTANCES=[])}initContext(){const t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support WebGL. Try using the Canvas 2D.");this.initRegistry(),this.glContextId=window.PhaserRegistry.GL_CONTEXT_ID,t.id=window.PhaserRegistry.GL_CONTEXT_ID,window.PhaserRegistry.GL_CONTEXTS[this.glContextId]=t,window.PhaserRegistry.INSTANCES[this.glContextId]=this,window.PhaserRegistry.GL_CONTEXT_ID+=1,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.stencilManager.setContext(t),this.filterManager.setContext(t),this.blendModeManager.setContext(t),this.renderSession.gl=this.gl,this.resize(this.width,this.height)}render(t){if(this.contextLost)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),this.clearBeforeRender&&(e.clearColor(t._bgColor.r,t._bgColor.g,t._bgColor.b,t._bgColor.a),e.clear(e.COLOR_BUFFER_BIT)),this.offset.x=0,this.offset.y=0,this.renderDisplayObject(t,this.projection)}renderDisplayObject(t,e,i,s){this.renderSession.blendModeManager.setBlendMode($),this.renderSession.drawCount=0,this.renderSession.flipY=i?-1:1,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t.renderWebGL(this.renderSession,s),this.spriteBatch.end()}resize(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution}updateTexture(t){if(!t.hasLoaded)return!1;const e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===F?e.LINEAR:e.NEAREST),t.mipmap&&Ue(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===F?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===F?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0}mapBlendModes(){if(window.PhaserRegistry.blendModesWebGL)return;const t=this.gl,e=[];e[$]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Z]=[t.SRC_ALPHA,t.DST_ALPHA],e[J]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],e[tt]=[t.SRC_ALPHA,t.ONE],e[et]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[it]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[st]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[nt]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[ht]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[rt]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[ot]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[at]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[lt]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[dt]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[ut]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[ct]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[pt]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],window.PhaserRegistry.blendModesWebGL=e}}(this),this.context=null,this.contextLostBinded=this.contextLost.bind(this),this.contextRestoredBinded=this.contextRestored.bind(this),this.canvas.addEventListener("webglcontextlost",this.contextLostBinded,!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestoredBinded,!1),t=!0}catch(e){t=!1;const i={};window.PhaserRegistry?.GL_PROGRAM_INFO_LOG&&(i.gl_program_log=window.PhaserRegistry.GL_PROGRAM_INFO_LOG),window.PhaserRegistry?.GL_SHADER_INFO_LOG&&(i.gl_shader_log=window.PhaserRegistry.GL_SHADER_INFO_LOG),this.exceptionHandler(e,i)}t||(this.renderer&&(this.contextLostBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextLostBinded,!1),this.contextRestoredBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextRestoredBinded,!1),this.renderer.destroy(),ch(this.canvas),this.canvas=oh(this,this.width,this.height,this.config.canvasID,!0)),this.renderer=new vh(this),this.context=this.renderer.context),this.stage.smoothed=this.config.antialias,uh(this.canvas,this.parent,!1),lh(this.canvas)}parseConfigElement(t,e,i){void 0!==t[e]?this.config[e]=t[e]:this.config[e]=i}parseConfig(t){this.parseConfigElement(t,"width",800),this.parseConfigElement(t,"height",600),this.parseConfigElement(t,"backgroundColor",0),this.parseConfigElement(t,"forceSingleUpdate",!0),this.parseConfigElement(t,"canvasID",""),this.parseConfigElement(t,"canvasStyle",void 0),this.parseConfigElement(t,"resolution",1),this.parseConfigElement(t,"transparent",!1),this.parseConfigElement(t,"antialias",!1),this.parseConfigElement(t,"preserveDrawingBuffer",!1),this.parseConfigElement(t,"clearBeforeRender",!1),this.parseConfigElement(t,"renderType",gt),this.parseConfigElement(t,"isForceDisabledAudio",!1),this.parseConfigElement(t,"maxParallelDownloads",16),t.renderer&&(this.config.renderType=t.renderer),t.exceptionHandler?this.exceptionHandler=t.exceptionHandler:this.exceptionHandler=(t,e)=>{console.error(t,e)},t.parent&&(this.parent=t.parent);let e=null;t.state&&(e=t.state),this.state=new un(this,e)}contextLost(t){t.preventDefault(),this.renderer&&(this.renderer.contextLost=!0)}contextRestored(){this.renderer.initContext(),this.renderer&&(this.renderer.contextLost=!1)}update(t){this.time.update(t),this.isPaused?(this.scale.pauseUpdate(),this.state.pauseUpdate()):(this.scale.preUpdate(),this.state.preUpdate(),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.stage.postUpdate()),this.stage.updateTransform(),this.renderer.render(this.stage)}destroy(){this.isPaused=!0,this.cache&&(this.raf&&this.raf.stop(),this.time.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.canvas&&(this.contextLostBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextLostBinded,!1),this.contextRestoredBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextRestoredBinded,!1)),this.renderer.destroy(!1),ch(this.canvas),this.cache=null,this.load=null,this.time=null,this.world=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.canvas=null,this.renderer=null)}};return e})()));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(self,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{BitmapText:()=>Pi,Button:()=>Ri,Circle:()=>wi,Const:()=>i,DisplayObject:()=>_i,Ellipse:()=>bi,Game:()=>Ms,Group:()=>Fi,Image:()=>vi,Line:()=>Ps,MathUtils:()=>s,Matrix:()=>pi,Point:()=>ce,Polygon:()=>yi,Rectangle:()=>ei,RoundedRectangle:()=>xi,Signal:()=>Ze,Text:()=>Ui});var i={};t.r(i),t.d(i,{BITMAP_TEXT:()=>ct,BLEND_ADD:()=>F,BLEND_COLOR:()=>K,BLEND_COLOR_BURN:()=>H,BLEND_COLOR_DODGE:()=>W,BLEND_DARKEN:()=>N,BLEND_DIFFERENCE:()=>j,BLEND_EXCLUSION:()=>Y,BLEND_HARD_LIGHT:()=>z,BLEND_HUE:()=>V,BLEND_LIGHTEN:()=>G,BLEND_LUMINOSITY:()=>Q,BLEND_MULTIPLY:()=>I,BLEND_NORMAL:()=>R,BLEND_OVERLAY:()=>B,BLEND_SATURATION:()=>q,BLEND_SCREEN:()=>U,BLEND_SOFT_LIGHT:()=>X,BOTTOM_CENTER:()=>_,BOTTOM_LEFT:()=>f,BOTTOM_RIGHT:()=>v,BUTTON:()=>at,CENTER:()=>c,FILTER_CANVAS:()=>mt,FILTER_WEBGL:()=>ft,GEOM_CIRCLE:()=>yt,GEOM_ELLIPSE:()=>wt,GEOM_LINE:()=>St,GEOM_MATRIX:()=>Tt,GEOM_POINT:()=>Ct,GEOM_POLYGON:()=>vt,GEOM_RECTANGLE:()=>xt,GEOM_ROUNDED_RECTANGLE:()=>bt,GRAPHICS:()=>dt,GROUP:()=>ht,IMAGE:()=>lt,LEFT_BOTTOM:()=>u,LEFT_CENTER:()=>d,LEFT_TOP:()=>l,MOUSE_OVERRIDES_TOUCH:()=>it,MOUSE_TOUCH_COMBINE:()=>nt,PENDING_ATLAS:()=>Mt,POINTER:()=>_t,POINTER_CONTACT:()=>et,POINTER_CURSOR:()=>tt,RENDER_AUTO:()=>$,RENDER_CANVAS:()=>Z,RENDER_TEXTURE:()=>gt,RENDER_WEBGL:()=>J,RIGHT_BOTTOM:()=>m,RIGHT_CENTER:()=>g,RIGHT_TOP:()=>p,SCALE_EXACT_FIT:()=>w,SCALE_LINEAR:()=>x,SCALE_NEAREST:()=>y,SCALE_OFF:()=>b,SCALE_RESIZE:()=>T,SCALE_SHOW_ALL:()=>S,SCALE_USER:()=>C,SPRITE:()=>rt,SPRITE_BATCH:()=>ot,TEXT:()=>ut,TILE_SPRITE:()=>pt,TIME_HALF:()=>A,TIME_MINUTE:()=>M,TIME_QUARTER:()=>E,TIME_SECOND:()=>P,TOP_CENTER:()=>o,TOP_LEFT:()=>r,TOP_RIGHT:()=>a,TOUCH_OVERRIDES_MOUSE:()=>st,TWEEN_COMPLETE:()=>O,TWEEN_LOOPED:()=>L,TWEEN_PENDING:()=>k,TWEEN_RUNNING:()=>D});var s={};t.r(s),t.d(s,{DEG_TO_RAD:()=>It,PI_2:()=>Bt,RAD_TO_DEG:()=>Ut,between:()=>jt,degToRad:()=>zt,difference:()=>Kt,distance:()=>$t,generateID:()=>he,generateShaderID:()=>re,getColor:()=>te,getColor32:()=>Jt,getNextPowerOfTwo:()=>Wt,getRGB:()=>se,hex2rgb:()=>Nt,hexToColor:()=>ee,isPowerOfTwo:()=>Ht,linear:()=>qt,linearInterpolation:()=>Qt,radToDeg:()=>Xt,rgb2hex:()=>Gt,snapToCeil:()=>Yt,valueToColor:()=>ne,webToColor:()=>ie,within:()=>Zt,wrap:()=>Vt});var n={};t.r(n),t.d(n,{popMask:()=>ue,pushMask:()=>de});var h={};t.r(h),t.d(h,{popMask:()=>$e,pushMask:()=>Qe});const r=0,o=1,a=2,l=3,d=4,u=5,c=6,p=7,g=8,m=9,f=10,_=11,v=12,x=0,y=1,w=0,b=1,S=2,T=3,C=4,M=6e4,P=1e3,A=500,E=250,k=0,D=1,L=2,O=3,R=0,F=1,I=2,U=3,B=4,N=5,G=6,W=7,H=8,z=9,X=10,j=11,Y=12,V=13,q=14,K=15,Q=16,$=0,Z=1,J=2,tt=1,et=2,it=0,st=1,nt=2,ht=7,rt=0,ot=17,at=1,lt=2,dt=3,ut=4,ct=6,pt=5,gt=8,mt=14,ft=15,_t=19,vt=12,xt=22,yt=21,wt=16,bt=26,St=23,Tt=24,Ct=25,Mt=-1;function Pt(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.CANVAS_POOL||(window.PhaserRegistry.CANVAS_POOL=[]),window.PhaserRegistry.CANVAS_POOL}function At(t){const e=Pt();for(let i=0;i<e.length;i+=1)e[i].parent===t&&(e[i].parent=null,e[i].canvas.width=1,e[i].canvas.height=1)}function Et(t){const e=Pt();for(let i=0;i<e.length;i+=1)e[i].canvas===t&&(e[i].parent=null,e[i].canvas.width=1,e[i].canvas.height=1)}function kt(t,e,i){void 0===t&&console.warn("Created CanvasPool element with undefined parent.");const s=function(){const t=Pt();for(let e=0;e<t.length;e+=1)if(!t[e].parent)return e;return-1}(),n=Pt();let h;if(-1===s){const e={parent:t,canvas:document.createElement("canvas")};n.push(e),h=e.canvas}else n[s].parent=t,h=n[s].canvas;return void 0!==e&&(h.width=e,h.height=i),h}function Dt(t,e,i,s,n){e=e||256,i=i||256;const h=n?document.createElement("canvas"):kt(t,e,i);return"string"==typeof s&&""!==s&&(h.id=s),h.width=e,h.height=i,h.style.display="block",h}function Lt(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}function Ot(t){t.parentNode&&t.parentNode.removeChild(t)}function Rt(t){const e=["i","webkitI","msI","mozI","oI"];for(let i=0;i<e.length;i+=1){const s=e[e[i]]+"mageSmoothingEnabled";if(t&&t[s])return s}return null}const Ft=class{constructor(t,e){this.width=t,this.height=e,this.canvas=kt(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e}clear(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)}resize(t,e){this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e}destroy(){Et(this.canvas)}},It=Math.PI/180,Ut=180/Math.PI,Bt=2*Math.PI;function Nt(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]}function Gt(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]}function Wt(t){if(t>0&&0==(t&t-1))return t;let e=1;for(;e<t;)e<<=1;return e}function Ht(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}function zt(t){return t*It}function Xt(t){return t*Ut}function jt(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function Yt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return 0===e?t:(t-=i,i+(t=e*Math.ceil(t/e)))}function Vt(t,e,i){const s=i-e;if(s<=0)return 0;let n=(t-e)%s;return n<0&&(n+=s),n+e}function qt(t,e,i){return(e-t)*i+t}function Kt(t,e){return Math.abs(t-e)}function Qt(t,e){const i=t.length-1,s=i*e,n=Math.floor(s);return e<0?qt(t[0],t[1],s):e>1?qt(t[i],t[i-1],i-s):qt(t[n],t[n+1>i?i:n+1],s-n)}function $t(t,e,i,s){const n=t-i,h=e-s;return Math.sqrt(n*n+h*h)}function Zt(t,e,i){return Math.abs(t-e)<=i}function Jt(t,e,i,s){return t<<24|e<<16|i<<8|s}function te(t,e,i){return t<<16|e<<8|i}function ee(t,e){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,((t,e,i,s)=>e+e+i+i+s+s));const i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);i&&(e.r=parseInt(i[1],16),e.g=parseInt(i[2],16),e.b=parseInt(i[3],16))}function ie(t,e){const i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);i&&(e.r=parseInt(i[1],10),e.g=parseInt(i[2],10),e.b=parseInt(i[3],10),e.a=void 0!==i[4]?parseFloat(i[4]):1)}function se(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}}function ne(t,e){if("string"==typeof t)0===t.indexOf("rgb")?ie(t,e):(e.a=1,ee(t,e));else if("number"==typeof t){const i=se(t);e.r=i.r,e.g=i.g,e.b=i.b,e.a=i.a/255}return e.rgba="rgba("+e.r.toString()+","+e.g.toString()+","+e.b.toString()+","+e.a.toString()+")",e.color=te(e.r,e.g,e.b),e.color32=Jt(255*e.a,e.r,e.g,e.b),e}function he(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function re(){return`${he()}${he()}-${he()}`.toLowerCase()}function oe(t,e,i){const s=i.getContext("2d"),n=t.crop;i.width===n.width&&i.height===n.height||(i.width=n.width,i.height=n.height),s.clearRect(0,0,n.width,n.height),s.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),s.fillRect(0,0,n.width,n.height),s.globalCompositeOperation="multiply",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.globalCompositeOperation="destination-atop",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)}function ae(t,e,i){const s=i.getContext("2d"),n=t.crop;i.width=n.width,i.height=n.height,s.globalCompositeOperation="copy",s.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height);const h=Nt(e),r=h[0],o=h[1],a=h[2],l=s.getImageData(0,0,n.width,n.height),d=l.data;for(let t=0;t<d.length;t+=4)if(d[t+0]*=r,d[t+1]*=o,d[t+2]*=a,!window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA){const e=d[t+3];d[t+0]/=255/e,d[t+1]/=255/e,d[t+2]/=255/e}s.putImageData(l,0,0)}function le(t,e){const i=t.worldAlpha;t.dirty&&(function(t){if(16777215===t.tint)return;const e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255;for(let n=0;n<t.graphicsData.length;n+=1){const h=t.graphicsData[n],r=0|h.fillColor,o=0|h.lineColor;h._fillTint=((r>>16&255)/255*e*255<<16)+((r>>8&255)/255*i*255<<8)+(255&r)/255*s*255,h._lineTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255}}(t),t.dirty=!1);for(let s=0;s<t.graphicsData.length;s+=1){const n=t.graphicsData[s],h=n.shape,r=n._fillTint,o=n._lineTint;if(e.lineWidth=n.lineWidth,n.type===vt){e.beginPath();const t=h.points;e.moveTo(t[0],t[1]);for(let i=1;i<t.length/2;i+=1)e.lineTo(t[2*i],t[2*i+1]);h.closed&&e.lineTo(t[0],t[1]),t[0]===t[t.length-2]&&t[1]===t[t.length-1]&&e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}else if(n.type===xt)(n.fillColor||0===n.fillColor)&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fillRect(h.x,h.y,h.width,h.height)),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.strokeRect(h.x,h.y,h.width,h.height));else if(n.type===yt)e.beginPath(),e.arc(h.x,h.y,h.radius,0,2*Math.PI),e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke());else if(n.type===wt){const t=2*h.width,s=2*h.height,a=h.x-t/2,l=h.y-s/2;e.beginPath();const d=.5522848,u=t/2*d,c=s/2*d,p=a+t,g=l+s,m=a+t/2,f=l+s/2;e.moveTo(a,f),e.bezierCurveTo(a,f-c,m-u,l,m,l),e.bezierCurveTo(m+u,l,p,f-c,p,f),e.bezierCurveTo(p,f+c,m+u,g,m,g),e.bezierCurveTo(m-u,g,a,f+c,a,f),e.closePath(),n.fill&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}else if(n.type===bt){const t=h.x,s=h.y,a=h.width,l=h.height;let d=h.radius;const u=Math.min(a,l)/2|0;d=d>u?u:d,e.beginPath(),e.moveTo(t,s+d),e.lineTo(t,s+l-d),e.quadraticCurveTo(t,s+l,t+d,s+l),e.lineTo(t+a-d,s+l),e.quadraticCurveTo(t+a,s+l,t+a,s+l-d),e.lineTo(t+a,s+d),e.quadraticCurveTo(t+a,s,t+a-d,s),e.lineTo(t+d,s),e.quadraticCurveTo(t,s,t,s+d),e.closePath(),(n.fillColor||0===n.fillColor)&&(e.globalAlpha=n.fillAlpha*i,e.fillStyle="#"+("00000"+(0|r).toString(16)).substr(-6),e.fill()),n.lineWidth&&(e.globalAlpha=n.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.stroke())}}}function de(t,e){const i=e.context;i.save();const s=t.alpha,n=t.worldTransform,h=e.resolution;i.setTransform(n.a*h,n.b*h,n.c*h,n.d*h,n.tx*h,n.ty*h),function(t,e){const i=t.graphicsData.length;if(0!==i){e.beginPath();for(let s=0;s<i;s+=1){const i=t.graphicsData[s],n=i.shape;if(i.type===vt){const t=n.points;e.moveTo(t[0],t[1]);for(let i=1;i<t.length/2;i+=1)e.lineTo(t[2*i],t[2*i+1]);t[0]===t[t.length-2]&&t[1]===t[t.length-1]&&e.closePath()}else if(i.type===xt)e.rect(n.x,n.y,n.width,n.height),e.closePath();else if(i.type===yt)e.arc(n.x,n.y,n.radius,0,2*Math.PI),e.closePath();else if(i.type===wt){const t=2*n.width,i=2*n.height,s=n.x-t/2,h=n.y-i/2,r=.5522848,o=t/2*r,a=i/2*r,l=s+t,d=h+i,u=s+t/2,c=h+i/2;e.moveTo(s,c),e.bezierCurveTo(s,c-a,u-o,h,u,h),e.bezierCurveTo(u+o,h,l,c-a,l,c),e.bezierCurveTo(l,c+a,u+o,d,u,d),e.bezierCurveTo(u-o,d,s,c+a,s,c),e.closePath()}else if(i.type===bt){const t=n.x,i=n.y,s=n.width,h=n.height;let r=n.radius;const o=Math.min(s,h)/2|0;r=r>o?o:r,e.moveTo(t,i+r),e.lineTo(t,i+h-r),e.quadraticCurveTo(t,i+h,t+r,i+h),e.lineTo(t+s-r,i+h),e.quadraticCurveTo(t+s,i+h,t+s,i+h-r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t+s,i,t+s-r,i),e.lineTo(t+r,i),e.quadraticCurveTo(t,i,t,i+r),e.closePath()}}}}(t,i),i.clip(),t.worldAlpha=s}function ue(t){t.context.restore()}const ce=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.x=t,this.y=e,this.type=Ct}copyFrom(t){return this.setTo(t.x,t.y)}invert(){return this.setTo(this.y,this.x)}setTo(t,e){return this.x=t||0,this.y=e||(0!==e?this.x:0),this}set(t,e){return this.x=t||0,this.y=e||(0!==e?this.x:0),this}add(t,e){return this.x+=t,this.y+=e,this}subtract(t,e){return this.x-=t,this.y-=e,this}multiply(t,e){return this.x*=t,this.y*=e,this}divide(t,e){return this.x/=t,this.y/=e,this}clampX(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this}clampY(t,e){return this.y=Math.max(t,Math.min(e,this.y)),this}clamp(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ce;return i.setTo(t.x,t.y),i}(this)}copyTo(t){return t.x=this.x,t.y=this.y,t}distance(t){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=t.x-e.x,n=t.y-e.y,h=Math.sqrt(s*s+n*n);return i?Math.round(h):h}(this,t)}equals(t){return t.x===this.x&&t.y===this.y}angle(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?180/Math.PI*Math.atan2(t.y-this.y,t.x-this.x):Math.atan2(t.y-this.y,t.x-this.x)}rotate(t,e,i,s,n){return function(t,e,i,s,n,h){if(n&&(s*=Math.PI/180),void 0===h){t.subtract(e,i);const n=Math.sin(s),h=Math.cos(s),r=h*t.x-n*t.y,o=n*t.x+h*t.y;t.x=r+e,t.y=o+i}else{const n=s+Math.atan2(t.y-i,t.x-e);t.x=e+h*Math.cos(n),t.y=i+h*Math.sin(n)}return t}(this,t,e,i,s,n)}getMagnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)}getMagnitudeSq(){return this.x*this.x+this.y*this.y}setMagnitude(t){return this.normalize().multiply(t,t)}normalize(){if(!this.isZero()){const t=this.getMagnitude();this.x/=t,this.y/=t}return this}isZero(){return 0===this.x&&0===this.y}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}perp(){return this.setTo(-this.y,this.x)}rperp(){return this.setTo(this.y,-this.x)}normalRightHand(){return this.setTo(-1*this.y,this.x)}floor(){return this.setTo(Math.floor(this.x),Math.floor(this.y))}ceil(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))}toString(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};function pe(t,e,i){let s=e;Array.isArray(e)&&(s=e.join("\n"));const n=t.createShader(i);return t.shaderSource(n,s),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.PhaserRegistry&&(window.PhaserRegistry.GL_SHADER_INFO_LOG=t.getShaderInfoLog(n)),null)}function ge(t,e,i){const s=function(t,e){return pe(t,e,t.FRAGMENT_SHADER)}(t,i),n=function(t,e){return pe(t,e,t.VERTEX_SHADER)}(t,e),h=t.createProgram();return t.attachShader(h,n),t.attachShader(h,s),t.linkProgram(h),t.getProgramParameter(h,t.LINK_STATUS)||window.PhaserRegistry&&(window.PhaserRegistry.GL_PROGRAM_INFO_LOG=t.getProgramInfoLog(h)),h}const me=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],fe=class{constructor(t){this.gl=t,this._UID=re(),this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.uniforms={},this.attributes=[],this.init()}init(){const t=this.gl,e=ge(t,this.vertexSrc||me,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];const i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1)this.uniforms[i[s]].uniformLocation=t.getUniformLocation(e,i[s]);this.initUniforms(),this.program=e}initUniforms(){this.textureCount=1;const t=this.gl;let e;const i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1){const n=i[s];e=this.uniforms[n];const h=e.type;"sampler2D"===h?(e._init=!1,null!==e.value&&this.initSampler2D(e)):"mat2"===h||"mat3"===h||"mat4"===h?(e.glMatrix=!0,e.glValueLength=1,"mat2"===h?e.glFunc=t.uniformMatrix2fv:"mat3"===h?e.glFunc=t.uniformMatrix3fv:"mat4"===h&&(e.glFunc=t.uniformMatrix4fv)):(e.glFunc=t["uniform"+h],e.glValueLength="2f"===h||"2i"===h?2:"3f"===h||"3i"===h?3:"4f"===h||"4i"===h?4:1)}}initSampler2D(t){if(!t.value||!t.value.baseTexture||!t.value.baseTexture.hasLoaded)return;const e=this.gl;if(e.activeTexture(e["TEXTURE"+this.textureCount]),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){const i=t.textureData,s=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR;let h=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,r=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE;const o=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(h=e.REPEAT,r=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){const t=i.width?i.width:512,s=i.height?i.height:2,n=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,o,t,s,n,o,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,o,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount+=1}syncUniforms(){let t;this.textureCount=1;const e=this.gl,i=Object.keys(this.uniforms);for(let s=0;s<i.length;s+=1){const n=i[s];t=this.uniforms[n],1===t.glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?window.PhaserRegistry.INSTANCES[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount+=1):this.initSampler2D(t))}}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}},_e=class{constructor(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0}reset(){this.points=[],this.indices=[],this.glPoints=null,this.glIndicies=null}upload(){const t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1}},ve=class{constructor(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}};function xe(t,e){return t.x-e.x}function ye(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-s)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function we(t){let e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function be(t,e,i,s,n,h,r,o){return(n-r)*(e-o)-(t-r)*(h-o)>=0&&(t-r)*(s-o)-(i-r)*(e-o)>=0&&(i-r)*(h-o)-(n-r)*(s-o)>=0}function Se(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Te(t,e){return t.x===e.x&&t.y===e.y}function Ce(t,e,i,s){return Se(t,e,i)>0!=Se(t,e,s)>0&&Se(i,s,t)>0!=Se(i,s,e)>0}function Me(t,e){return Se(t.prev,t,t.next)<0?Se(t,e,t.next)>=0&&Se(t,t.prev,e)>=0:Se(t,e,t.prev)<0||Se(t,t.next,e)<0}function Pe(t,e){return Te(t,e)||t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Ce(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&Me(t,e)&&Me(e,t)&&function(t,e){let i=t,s=!1;const n=(t.x+e.x)/2,h=(t.y+e.y)/2;do{i.y>h!=i.next.y>h&&n<(i.next.x-i.x)*(h-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)}function Ae(t,e){const i=new ve(t.i,t.x,t.y),s=new ve(e.i,e.x,e.y),n=t.next,h=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,h.next=s,s.prev=h,s}function Ee(t,e,i,s){const n=new ve(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function ke(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function De(t){const e=t.prev,i=t,s=t.next;if(Se(e,i,s)>=0)return!1;let n=t.next.next;for(;n!==t.prev;){if(be(e.x,e.y,i.x,i.y,s.x,s.y,n.x,n.y)&&Se(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Le(t,e,i,s){const n=t.prev,h=t,r=t.next;if(Se(n,h,r)>=0)return!1;const o=n.x<h.x?n.x<r.x?n.x:r.x:h.x<r.x?h.x:r.x,a=n.y<h.y?n.y<r.y?n.y:r.y:h.y<r.y?h.y:r.y,l=n.x>h.x?n.x>r.x?n.x:r.x:h.x>r.x?h.x:r.x,d=n.y>h.y?n.y>r.y?n.y:r.y:h.y>r.y?h.y:r.y,u=ye(o,a,e,i,s),c=ye(l,d,e,i,s);let p=t.nextZ;for(;p&&p.z<=c;){if(p!==t.prev&&p!==t.next&&be(n.x,n.y,h.x,h.y,r.x,r.y,p.x,p.y)&&Se(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&be(n.x,n.y,h.x,h.y,r.x,r.y,p.x,p.y)&&Se(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Oe(t,e,i,s,n){let h,r,o,a=0;for(h=e,r=i-s;h<i;h+=s)a+=(t[r]-t[h])*(t[h+1]+t[r+1]),r=h;if(n===a>0)for(h=e;h<i;h+=s)o=Ee(h,t[h],t[h+1],o);else for(h=i-s;h>=e;h-=s)o=Ee(h,t[h],t[h+1],o);return o}function Re(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!Te(s,s.next)&&0!==Se(s.prev,s,s.next))s=s.next;else{if(ke(s),s=s.prev,e=s,s===s.next)return null;i=!0}}while(i||s!==e);return e}function Fe(t,e){if(e=function(t,e){let i=e;const s=t.x,n=t.y;let h,r=-1/0;do{if(n<=i.y&&n>=i.next.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);t<=s&&t>r&&(r=t,h=i.x<i.next.x?i:i.next)}i=i.next}while(i!==e);if(!h)return null;if(t.x===h.x)return h.prev;const o=h;let a,l=1/0;for(i=h.next;i!==o;)s>=i.x&&i.x>=h.x&&be(n<h.y?s:r,n,h.x,h.y,n<h.y?r:s,n,i.x,i.y)&&(a=Math.abs(n-i.y)/(s-i.x),(a<l||a===l&&i.x>h.x)&&Me(i,t)&&(h=i,l=a)),i=i.next;return h}(t,e),e){const i=Ae(e,t);Re(i,i.next)}}function Ie(t,e,i){let s=t;do{const n=s.prev,h=s.next.next;Ce(n,s,s.next,h)&&Me(n,h)&&Me(h,n)&&(e.push(n.i/i),e.push(s.i/i),e.push(h.i/i),ke(s),ke(s.next),s=h,t=s),s=s.next}while(s!==t);return s}function Ue(t,e,i,s,n,h){let r=t;do{let t=r.next.next;for(;t!==r.prev;){if(r.i!==t.i&&Pe(r,t)){let o=Ae(r,t);return r=Re(r,r.next),o=Re(o,o.next),Be(r,e,i,s,n,h),void Be(o,e,i,s,n,h)}t=t.next}r=r.next}while(r!==t)}function Be(t,e,i,s,n,h,r){if(!t)return;!r&&h&&function(t,e,i,s){let n=t;do{null===n.z&&(n.z=ye(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let e,i,s,n,h,r,o,a,l=1;do{for(i=t,t=null,h=null,r=0;i;){for(r+=1,s=i,o=0,e=0;e<l&&(o+=1,s=s.nextZ,s);e+=1);for(a=l;o>0||a>0&&s;)0===o?(n=s,s=s.nextZ,a-=1):0!==a&&s?i.z<=s.z?(n=i,i=i.nextZ,o-=1):(n=s,s=s.nextZ,a-=1):(n=i,i=i.nextZ,o-=1),h?h.nextZ=n:t=n,n.prevZ=h,h=n;i=s}h.nextZ=null,l*=2}while(r>1)}(n)}(t,s,n,h);let o,a,l=t;for(;t.prev!==t.next;)if(o=t.prev,a=t.next,h?Le(t,s,n,h):De(t))e.push(o.i/i),e.push(t.i/i),e.push(a.i/i),ke(t),t=a.next,l=a.next;else if((t=a)===l){r?1===r?Be(t=Ie(t,e,i),e,i,s,n,h,2):2===r&&Ue(t,e,i,s,n,h):Be(Re(t),e,i,s,n,h,1);break}}function Ne(t,e,i){i=i||2;const s=e&&e.length,n=s?e[0]*i:t.length;let h=Oe(t,0,n,i,!0);const r=[];if(!h)return r;let o,a,l,d,u,c,p;if(s&&(h=function(t,e,i,s){const n=[];let h,r,o,a,l;for(h=0,r=e.length;h<r;h+=1)o=e[h]*s,a=h<r-1?e[h+1]*s:t.length,l=Oe(t,o,a,s,!1),l===l.next&&(l.steiner=!0),n.push(we(l));for(n.sort(xe),h=0;h<n.length;h+=1)Fe(n[h],i),i=Re(i,i.next);return i}(t,e,h,i)),t.length>80*i){o=t[0],l=t[0],a=t[1],d=t[1];for(let e=i;e<n;e+=i)u=t[e],c=t[e+1],u<o&&(o=u),c<a&&(a=c),u>l&&(l=u),c>d&&(d=c);p=Math.max(l-o,d-a)}return Be(h,r,i,o,a,p),r}function Ge(){return window.PhaserRegistry.graphicsDataPool||(window.PhaserRegistry.graphicsDataPool=[]),window.PhaserRegistry.graphicsDataPool}function We(t,e){let i;return t.data.length?(i=t.data[t.data.length-1],i.mode===e&&1!==e||(i=Ge().pop()||new _e(t.gl),i.mode=e,t.data.push(i))):(i=Ge().pop()||new _e(t.gl),i.mode=e,t.data.push(i)),i.dirty=!0,i}function He(t,e){let i=0,s=t.points;if(0===s.length)return;if(t.lineWidth%2)for(i=0;i<s.length;i+=1)s[i]+=.5;const n=new ce(s[0],s[1]);let h=new ce(s[s.length-2],s[s.length-1]);if(n.x===h.x&&n.y===h.y){s=s.slice(),s.pop(),s.pop(),h=new ce(s[s.length-2],s[s.length-1]);const t=h.x+.5*(n.x-h.x),e=h.y+.5*(n.y-h.y);s.unshift(t,e),s.push(t,e)}const r=e.points,o=e.indices,a=s.length/2;let l=s.length,d=r.length/6;const u=t.lineWidth/2,c=Nt(t.lineColor),p=t.lineAlpha,g=c[0]*p,m=c[1]*p,f=c[2]*p;let _,v,x,y,w,b,S,T,C,M,P,A,E,k,D,L,O,R,F,I,U,B,N;for(x=s[0],y=s[1],w=s[2],b=s[3],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,r.push(x-C,y-M,g,m,f,p),r.push(x+C,y+M,g,m,f,p),i=1;i<a-1;i+=1)x=s[2*(i-1)],y=s[2*(i-1)+1],w=s[2*i],b=s[2*i+1],S=s[2*(i+1)],T=s[2*(i+1)+1],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,P=-(b-T),A=w-S,N=Math.sqrt(P*P+A*A),P/=N,A/=N,P*=u,A*=u,D=-M+y-(-M+b),L=-C+w-(-C+x),O=(-C+x)*(-M+b)-(-C+w)*(-M+y),R=-A+T-(-A+b),F=-P+w-(-P+S),I=(-P+S)*(-A+b)-(-P+w)*(-A+T),U=D*F-R*L,Math.abs(U)<.1?(U+=10.1,r.push(w-C,b-M,g,m,f,p),r.push(w+C,b+M,g,m,f,p)):(_=(L*I-F*O)/U,v=(R*O-D*I)/U,B=(_-w)*(_-w)+(v-b)+(v-b),B>19600?(E=C-P,k=M-A,N=Math.sqrt(E*E+k*k),E/=N,k/=N,E*=u,k*=u,r.push(w-E,b-k),r.push(g,m,f,p),r.push(w+E,b+k),r.push(g,m,f,p),r.push(w-E,b-k),r.push(g,m,f,p),l+=1):(r.push(_,v),r.push(g,m,f,p),r.push(w-(_-w),b-(v-b)),r.push(g,m,f,p)));for(x=s[2*(a-2)],y=s[2*(a-2)+1],w=s[2*(a-1)],b=s[2*(a-1)+1],C=-(y-b),M=x-w,N=Math.sqrt(C*C+M*M),C/=N,M/=N,C*=u,M*=u,r.push(w-C,b-M),r.push(g,m,f,p),r.push(w+C,b+M),r.push(g,m,f,p),o.push(d),i=0;i<l;i+=1)o.push(d),d+=1;o.push(d-1)}function ze(t,e){const i=t.shape,s=i.x,n=i.y,h=i.width,r=i.height;if(t.fill){const i=Nt(t.fillColor),o=t.fillAlpha,a=i[0]*o,l=i[1]*o,d=i[2]*o,u=e.points,c=e.indices,p=u.length/6;u.push(s,n),u.push(a,l,d,o),u.push(s+h,n),u.push(a,l,d,o),u.push(s,n+r),u.push(a,l,d,o),u.push(s+h,n+r),u.push(a,l,d,o),c.push(p,p,p+1,p+2,p+3,p+3)}if(t.lineWidth){const i=t.points;t.points=[s,n,s+h,n,s+h,n+r,s,n+r,s,n],He(t,e),t.points=i}}function Xe(t,e,i,s,n,h){let r,o,a,l,d,u;const c=[],p=(t,e,i)=>t+(e-t)*i;let g=0;for(let m=0;m<=20;m+=1)g=m/20,r=p(t,i,g),o=p(e,s,g),a=p(i,n,g),l=p(s,h,g),d=p(r,a,g),u=p(o,l,g),c.push(d,u);return c}function je(t,e){const i=t.shape,s=i.x,n=i.y,h=i.width,r=i.height,o=i.radius;let a=[];if(a.push(s,n+o),a=a.concat(Xe(s,n+r-o,s,n+r,s+o,n+r)),a=a.concat(Xe(s+h-o,n+r,s+h,n+r,s+h,n+r-o)),a=a.concat(Xe(s+h,n+o,s+h,n,s+h-o,n)),a=a.concat(Xe(s+o,n,s,n,s,n+o)),t.fill){const i=Nt(t.fillColor),s=t.fillAlpha,n=i[0]*s,h=i[1]*s,r=i[2]*s,o=e.points,l=e.indices,d=o.length/6,u=Ne(a,null,2);for(let t=0;t<u.length;t+=3)l.push(u[t]+d),l.push(u[t]+d),l.push(u[t+1]+d),l.push(u[t+2]+d),l.push(u[t+2]+d);for(let t=0;t<a.length;t+=2)o.push(a[t],a[t+1],n,h,r,s)}if(t.lineWidth){const i=t.points;t.points=a,He(t,e),t.points=i}}function Ye(t,e){const i=t.shape,s=i.x,n=i.y;let h,r;t.type===yt?(h=i.radius,r=i.radius):(h=i.width,r=i.height);const o=2*Math.PI/40;if(t.fill){const i=Nt(t.fillColor),a=t.fillAlpha,l=i[0]*a,d=i[1]*a,u=i[2]*a,c=e.points,p=e.indices;let g=c.length/6;p.push(g);for(let t=0;t<41;t+=1)c.push(s,n,l,d,u,a),c.push(s+Math.sin(o*t)*h,n+Math.cos(o*t)*r,l,d,u,a),p.push(g,g+1),g+=2;p.push(g-1)}if(t.lineWidth){const i=t.points;t.points=[];for(let e=0;e<41;e+=1)t.points.push(s+Math.sin(o*e)*h,n+Math.cos(o*e)*r);He(t,e),t.points=i}}function Ve(t,e){const i=t.points.slice();if(i.length<6)return;const s=e.indices;e.points=i,e.alpha=t.fillAlpha,e.color=Nt(t.fillColor);let n,h,r=1/0,o=-1/0,a=1/0,l=-1/0;for(let t=0;t<i.length;t+=2)n=i[t],h=i[t+1],r=n<r?n:r,o=n>o?n:o,a=h<a?h:a,l=h>l?h:l;i.push(r,a,o,a,o,l,r,l);const d=i.length/2;for(let t=0;t<d;t+=1)s.push(t)}function qe(t,e){const i=t.points;if(i.length<6)return!1;const s=e.points,n=e.indices,h=i.length/2,r=Nt(t.fillColor),o=t.fillAlpha,a=r[0]*o,l=r[1]*o,d=r[2]*o,u=Ne(i,null,2);if(!u)return!1;const c=s.length/6;for(let t=0;t<u.length;t+=3)n.push(u[t]+c),n.push(u[t]+c),n.push(u[t+1]+c),n.push(u[t+2]+c),n.push(u[t+2]+c);for(let t=0;t<h;t+=1)s.push(i[2*t],i[2*t+1],a,l,d,o);return!0}function Ke(t,e){const i=(window.PhaserRegistry.stencilBufferLimit||(window.PhaserRegistry.stencilBufferLimit=6),window.PhaserRegistry.stencilBufferLimit);let s,n,h=t._webGL[e.id];if(h||(h={lastIndex:0,data:[],gl:e},t._webGL[e.id]=h),t.dirty=!1,t.clearDirty){for(t.clearDirty=!1,s=0;s<h.data.length;s+=1){const t=h.data[s];t.reset(),Ge().push(t)}h.data=[],h.lastIndex=0}for(s=h.lastIndex;s<t.graphicsData.length;s+=1){const e=t.graphicsData[s];e.type===vt?(e.points=e.shape.points.slice(),e.shape.closed&&(e.points[0]===e.points[e.points.length-2]&&e.points[1]===e.points[e.points.length-1]||e.points.push(e.points[0],e.points[1])),e.fill&&e.points.length>=i&&(e.points.length<2*i?(n=We(h,0),qe(e,n)||(n=We(h,1),Ve(e,n))):(n=We(h,1),Ve(e,n))),e.lineWidth>0&&(n=We(h,0),He(e,n))):(n=We(h,0),e.type===xt?ze(e,n):e.type===yt||e.type===wt?Ye(e,n):e.type===bt&&je(e,n)),h.lastIndex+=1}for(s=0;s<h.data.length;s+=1)n=h.data[s],n.dirty&&n.upload()}function Qe(t,e){const i=e.gl;t.dirty&&Ke(t,i),void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)}function $e(t,e){const i=e.gl;void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)}const Ze=class{constructor(){this._bindings=null,this._prevParams=null,this.memorize=!1,this._shouldPropagate=!0,this.active=!0,this._boundDispatch=!1}validateListener(t,e){if("function"!=typeof t)throw new Error("Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}_registerListener(t,e,i,s,n){const h=this._indexOfListener(t,i);let r;if(-1!==h){if(r=this._bindings[h],r.isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else r=new class{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;this._signal=t,this._listener=e,this._args=h,this._priority=n,this._isOnce=i,this.context=s,this.callCount=0,this.active=!0,this.params=null}execute(t){let e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,this._args&&(i=i.concat(this._args)),e=this._listener.apply(this.context,i),this.callCount+=1,this._isOnce&&this.detach()),e}detach(){return this.isBound()?this._signal.remove(this._listener,this.context):null}isBound(){return!!this._signal&&!!this._listener}isOnce(){return this._isOnce}getListener(){return this._listener}getSignal(){return this._signal}_destroy(){delete this._signal,delete this._listener,delete this.context}toString(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}}(this,t,e,i,s,n),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r}_addBinding(t){this._bindings||(this._bindings=[]);let e=this._bindings.length;do{e-=1}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)}_indexOfListener(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this._bindings)return-1;let i,s=this._bindings.length;for(;s;)if(s-=1,i=this._bindings[s],i._listener===t&&i.context===e)return s;return-1}has(t,e){return-1!==this._indexOfListener(t,e)}add(t,e,i){this.validateListener(t,"add");for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this._registerListener(t,!1,e,i,n)}addOnce(t,e,i){this.validateListener(t,"addOnce");for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this._registerListener(t,!0,e,i,n)}remove(t,e){this.validateListener(t,"remove");const i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t}removeAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._bindings)return;let e=this._bindings.length;for(;e;)e-=1,t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)}getNumListeners(){return this._bindings?this._bindings.length:0}halt(){this._shouldPropagate=!1}dispatch(){if(!this.active||!this._bindings)return;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=e.slice();let n=this._bindings.length;if(this.memorize&&(this._prevParams=s),!n)return;const h=this._bindings.slice();this._shouldPropagate=!0;do{n-=1}while(h[n]&&this._shouldPropagate&&!1!==h[n].execute(s))}forget(){this._prevParams&&(this._prevParams=null)}dispose(){this.removeAll(),this.forget(),this._bindings=null}toString(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}get boundDispatch(){const t=this;return this._boundDispatch||(this._boundDispatch=function(){return t.dispatch(...arguments)}),this._boundDispatch}};function Je(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ei;return i.setTo(t.x,t.y,t.width,t.height),i}function ti(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)}const ei=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.x=t,this.y=e,this.width=i,this.height=s,this.type=xt}offset(t,e){return this.x+=t,this.y+=e,this}offsetPoint(t){return this.offset(t.x,t.y)}setTo(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}scale(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this}centerOn(t,e){return this.centerX=t,this.centerY=e,this}floor(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)}floorAll(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)}ceil(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)}ceilAll(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)}copyFrom(t){return this.setTo(t.x,t.y,t.width,t.height)}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}inflate(t,e){return function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t}(this,t,e)}size(t){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ce;return i.setTo(t.width,t.height),i}(this,t)}resize(t,e){return this.width=t,this.height=e,this}clone(t){return Je(this,t)}contains(t,e){return function(t,e,i){return!(t.width<=0||t.height<=0)&&e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom}(this,t,e)}containsRect(t){return function(t,e){return!(t.volume>e.volume)&&t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom}(t,this)}equals(t){return function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}(this,t)}intersection(t,e){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const s=i||new ei;return ti(t,e)&&(s.x=Math.max(t.x,e.x),s.y=Math.max(t.y,e.y),s.width=Math.min(t.right,e.right)-s.x,s.height=Math.min(t.bottom,e.bottom)-s.y),s}(this,t,e)}intersects(t){return ti(this,t)}intersectsRaw(t,e,i,s,n){return function(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return!(e>t.right+h||i<t.left-h||s>t.bottom+h||n<t.top-h)}(this,t,e,i,s,n)}union(t,e){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(i||new ei).setTo(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.max(t.right,e.right)-Math.min(t.left,e.left),Math.max(t.bottom,e.bottom)-Math.min(t.top,e.top))}(this,t,e)}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ce;return t.x=this.randomX,t.y=this.randomY,t}getPoint(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new ce;switch(t){case r:return e.set(this.x,this.y);case o:return e.set(this.centerX,this.y);case a:return e.set(this.right,this.y);case d:return e.set(this.x,this.centerY);case c:return e.set(this.centerX,this.centerY);case g:return e.set(this.right,this.centerY);case f:return e.set(this.x,this.bottom);case _:return e.set(this.centerX,this.bottom);case v:return e.set(this.right,this.bottom);default:return e.set(this.x,this.y)}}toString(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}get halfWidth(){return Math.round(this.width/2)}get halfHeight(){return Math.round(this.height/2)}get top(){return this.y}set top(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}get topLeft(){return new ce(this.x,this.y)}set topLeft(t){this.x=t.x,this.y=t.y}get topRight(){return new ce(this.x+this.width,this.y)}set topRight(t){this.right=t.x,this.y=t.y}get bottom(){return this.y+this.height}set bottom(t){t<=this.y?this.height=0:this.height=t-this.y}get bottomLeft(){return new ce(this.x,this.bottom)}set bottomLeft(t){this.x=t.x,this.bottom=t.y}get bottomRight(){return new ce(this.right,this.bottom)}set bottomRight(t){this.right=t.x,this.bottom=t.y}get left(){return this.x}set left(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}get right(){return this.x+this.width}set right(t){t<=this.x?this.width=0:this.width=t-this.x}get volume(){return this.width*this.height}get perimeter(){return 2*this.width+2*this.height}get centerX(){return this.x+this.halfWidth}set centerX(t){this.x=t-this.halfWidth}get centerY(){return this.y+this.halfHeight}set centerY(t){this.y=t-this.halfHeight}get randomX(){return this.x+Math.random()*this.width}get randomY(){return this.y+Math.random()*this.height}get empty(){return!this.width||!this.height}set empty(t){!0===t&&this.setTo(0,0,0,0)}};function ii(t,e){return!!("mp3"===e&&t.mp3||"ogg"===e&&(t.ogg||t.opus)||"m4a"===e&&t.m4a||"opus"===e&&t.opus||"wav"===e&&t.wav||"webm"===e&&t.webm||"mp4"===e&&t.dolby)}function si(t){const e=navigator.userAgent;/Android/.test(e)?t.android=!0:/CrOS/.test(e)?t.chromeOS=!0:/iP[ao]d|iPhone/i.test(e)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1?t.iOS=!0:/Mac OS/.test(e)?t.macOS=!0:/Linux/.test(e)?t.linux=!0:/Windows/.test(e)&&(t.windows=!0),(/Windows Phone/i.test(e)||/IEMobile/i.test(e))&&(t.android=!1,t.iOS=!1,t.macOS=!1,t.windows=!0,t.windowsPhone=!0);const i=/Silk/.test(e);(t.windows||t.macOS||t.linux&&!i||t.chromeOS)&&(t.desktop=!0),(t.android||t.iOS||t.windowsPhone||/Windows NT/i.test(e)&&/Touch/i.test(e))&&(t.desktop=!1)}function ni(t){si(t),function(t){const e=navigator.userAgent;/Edge\/\d+/.test(e)?t.edge=!0:/Chrome\/(\d+)/.test(e)&&!t.windowsPhone?t.chrome=!0:/Firefox\D+(\d+)/.test(e)?t.firefox=!0:/Safari\/(\d+)/.test(e)&&!t.windowsPhone&&(t.safari=!0),/Silk/.test(e)&&(t.silk=!0)}(t),function(t){const e=document.createElement("audio");try{e.canPlayType&&(e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(t.ogg=!0),(e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||e.canPlayType("audio/opus;").replace(/^no$/,""))&&(t.opus=!0),e.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(t.mp3=!0),e.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(t.wav=!0),(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/aac;").replace(/^no$/,""))&&(t.m4a=!0),e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(t.webm=!0),""!==e.canPlayType('audio/mp4;codecs="ec-3"')&&(t.edge||t.safari)&&(t.dolby=!0))}catch(t){}}(t),function(t){t.pixelRatio=window.devicePixelRatio||1,t.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),t.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad")}(t),function(t){const e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],i=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"],s=document.createElement("div");for(let i=0;i<e.length;i+=1)if(s[e[i]]){t.fullscreen=!0,t.requestFullscreen=e[i];break}if(t.fullscreen){for(let e=0;e<i.length;e+=1)if(document[i[e]]){t.cancelFullscreen=i[e];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(t.fullscreenKeyboard=!0)}}(t),function(t){("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(t.touch=!0),("onwheel"in window||"WheelEvent"in window)&&(t.wheelEvent="wheel")}(t)}class hi{constructor(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0}}const ri=class{constructor(t,e,i,s){this.noFrame=!1,e||(this.noFrame=!0,e=new ei(0,0,1,1)),t&&t.baseTexture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=s,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new ei(0,0,1,1),t.hasLoaded&&(this.noFrame&&(e=new ei(0,0,t.width,t.height)),this.setFrame(e))}onBaseTextureLoaded(){this.noFrame&&(this.frame=new ei(0,0,this.baseTexture.width,this.baseTexture.height)),this.setFrame(this.frame)}destroy(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.baseTexture.destroy(),this.valid=!1}setFrame(t){this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height)?(this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()):this.valid=!1}_updateUvs(){this._uvs||(this._uvs=new hi);const t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i}},oi=class{constructor(t,e){this.resolution=1,this.width=100,this.height=100,this.scaleMode=e||window.PhaserRegistry.TEXTURE_SCALE_MODE,this.hasLoaded=!1,this.source=t,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.skipRender=!1,this._powerOf2=!1,this._dirty=[!0,!0,!0,!0],t&&(this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty())}forceLoaded(t,e){this.hasLoaded=!0,this.width=t,this.height=e,this.dirty()}destroy(){this.source&&Et(this.source),this.source=null,this.unloadFromGPU()}dirty(){for(let t=0;t<this._glTextures.length;t+=1)this._dirty[t]=!0}unloadFromGPU(){this.dirty();for(let t=this._glTextures.length-1;t>=0;t-=1){const e=this._glTextures[t],i=window.PhaserRegistry.GL_CONTEXTS[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()}},ai=class{constructor(){this._frames=[],this._frameNames=[]}addFrame(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t}getFrame(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return t>=this._frames.length&&(t=0),this._frames[t]}getFrameByName(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null}checkFrameName(t){return null!=this._frameNames[t]}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new ai;for(let e=0;e<t.total;e+=1)i.addFrame(t.getFrame(e).clone());return i}(this)}getFrameRange(t,e){const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||[];for(let s=t;s<=e;s+=1)i.push(this._frames[s]);return i}getFrameIndexes(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||[];if(t&&t.length>0)for(let s=0;s<t.length;s+=1)e&&this._frames[t[s]]?i.push(this._frames[t[s]].index):this.getFrameByName(t[s])&&i.push(this.getFrameByName(t[s]).index);else for(let t=0;t<this._frames.length;t+=1)i.push(this._frames[t].index);return i}destroy(){this._frames=null,this._frameNames=null}get total(){return this._frames.length}},li=class{constructor(t,e,i,s,n,h){this.initialize(t,e,i,s,n,h)}initialize(t,e,i,s,n,h){this.index=t,this.x=e,this.y=i,this.width=s,this.height=n,this.name=h,this.centerX=Math.floor(s/2),this.centerY=Math.floor(n/2),this.distance=$t(0,0,s,n),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=s,this.sourceSizeH=n,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height}resize(t,e){this.width=t,this.height=e,this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2),this.distance=$t(0,0,t,e),this.sourceSizeW=t,this.sourceSizeH=e,this.right=this.x+t,this.bottom=this.y+e}setTrim(t,e,i,s,n,h,r){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=h,this.spriteSourceSizeH=r)}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new li;return i.initialize(t.index,t.x,t.y,t.width,t.height),i}(this)}getRect(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ei;return t.setTo(this.x,this.y,this.width,this.height),t}};function di(t,e){return Object.keys(e.chars).forEach((i=>{const s=e.chars[i];s.texture=new ri(t,new ei(s.x,s.y,s.width,s.height))})),e}const ui=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.position=0,this.list=t}add(t){return this.exists(t)||this.list.push(t),t}getIndex(t){return this.list.indexOf(t)}getByKey(t,e){let i=this.list.length;for(;i;)if(i-=1,this.list[i][t]===e)return this.list[i];return null}exists(t){return this.list.indexOf(t)>-1}reset(){this.list.length=0}remove(t){const e=this.list.indexOf(t);return e>-1?(this.list.splice(e,1),t):null}setAll(t,e){let i=this.list.length;for(;i;)i-=1,this.list[i]&&(this.list[i][t]=e)}callAll(t){let e=this.list.length;for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];for(;e;)e-=1,this.list[e]&&this.list[e][t]&&this.list[e][t].apply(this.list[e],s)}removeAll(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.list.length;for(;e;)if(e-=1,this.list[e]){const i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}get total(){return this.list.length}get first(){return this.position=0,this.list.length>0?this.list[0]:null}get next(){return this.position<this.list.length?(this.position+=1,this.list[this.position]):null}};function ci(){return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.IDENTITY_MATRIX||(window.PhaserRegistry.IDENTITY_MATRIX=new pi),window.PhaserRegistry.IDENTITY_MATRIX}const pi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=h,this.type=Tt}fromArray(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])}setTo(t,e,i,s,n,h){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=h,this}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new pi;return i.a=t.a,i.b=t.b,i.c=t.c,i.d=t.d,i.tx=t.tx,i.ty=t.ty,i}(this)}copyTo(t){return t.copyFrom(this),t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}toArray(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new Float32Array(9);return t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e}apply(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new ce;return e.x=this.a*t.x+this.c*t.y+this.tx,e.y=this.b*t.x+this.d*t.y+this.ty,e}applyInverse(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new ce,i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,h=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=h*e-this.ty*i,this.ty=h*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}identity(){return this.setTo(1,0,0,1,0,0)}};function gi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t.currentBounds)return t.currentBounds;const i=t.texture.frame.width,s=t.texture.frame.height;let n=i*(1-t.anchor.x),h=i*-t.anchor.x,r=s*(1-t.anchor.y),o=s*-t.anchor.y;const a=e||t.worldTransform;let l=a.a;const d=a.b,u=a.c;let c=a.d;const p=a.tx,g=a.ty;let m=-1/0,f=-1/0,_=1/0,v=1/0;if(0===d&&0===u){if(l<0){l*=-1;const t=n;n=-h,h=-t}if(c<0){c*=-1;const t=r;r=-o,o=-t}_=l*h+p,m=l*n+p,v=c*o+g,f=c*r+g}else{const t=l*h+u*o+p,e=c*o+d*h+g,i=l*n+u*o+p,s=c*o+d*n+g,a=l*n+u*r+p,x=c*r+d*n+g,y=l*h+u*r+p,w=c*r+d*h+g;_=t<_?t:_,_=i<_?i:_,_=a<_?a:_,_=y<_?y:_,v=e<v?e:v,v=s<v?s:v,v=x<v?x:v,v=w<v?w:v,m=t>m?t:m,m=i>m?i:m,m=a>m?a:m,m=y>m?y:m,f=e>f?e:f,f=s>f?s:f,f=x>f?x:f,f=w>f?w:f}const x=t.cachedBounds;return x.x=_,x.width=m-_,x.y=v,x.height=f-v,t.currentBounds=x,x}function mi(t,e,i){if(!t.visible||t.alpha<=0||!t.renderable)return;let s=t.worldTransform;if(i&&(s=i),t._mask||t._filters){const i=e.spriteBatch;t._filters&&(i.flush(),e.filterManager.pushFilter(t._filterBlock)),t._mask&&(i.stop(),e.maskManager.pushMask(t.mask,e),i.start()),i.render(t);for(let i=0;i<t.children.length;i+=1)t.children[i].renderWebGL(e);i.stop(),t._mask&&e.maskManager.popMask(t._mask,e),t._filters&&e.filterManager.popFilter(),i.start()}else{e.spriteBatch.render(t);for(let i=0;i<t.children.length;i+=1)t.children[i].renderWebGL(e,s)}}function fi(t,e,i){if(!t.visible||0===t.alpha||!t.renderable||t.texture.crop.width<=0||t.texture.crop.height<=0)return;let s=t.worldTransform;if(i&&(s=i),t.blendMode!==e.currentBlendMode&&(e.currentBlendMode=t.blendMode,e.context.globalCompositeOperation=window.PhaserRegistry.blendModesCanvas[e.currentBlendMode]),t._mask&&e.maskManager.pushMask(t._mask,e),t.texture.valid){const i=t.texture.baseTexture.resolution/e.resolution;e.context.globalAlpha=t.worldAlpha,e.smoothProperty&&e.scaleMode!==t.texture.baseTexture.scaleMode&&(e.scaleMode=t.texture.baseTexture.scaleMode,e.context[e.smoothProperty]=e.scaleMode===x);let n=t.texture.trim?t.texture.trim.x-t.anchor.x*t.texture.trim.width:t.anchor.x*-t.texture.frame.width,h=t.texture.trim?t.texture.trim.y-t.anchor.y*t.texture.trim.height:t.anchor.y*-t.texture.frame.height;const r=s.tx*e.resolution+e.shakeX,o=s.ty*e.resolution+e.shakeY;e.roundPixels?(e.context.setTransform(s.a,s.b,s.c,s.d,0|r,0|o),n|=0,h|=0):e.context.setTransform(s.a,s.b,s.c,s.d,r,o);let a=t.texture.crop.width,l=t.texture.crop.height;if(n/=i,h/=i,16777215!==t.tint)(t.texture.requiresReTint||t.cachedTint!==t.tint)&&(t.tintedTexture=function(t,e){const i=t.tintedTexture||kt("CanvasTinter");return window.PhaserRegistry.CANVAS_TINT_METHOD(t.texture,e,i),i}(t,t.tint),t.cachedTint=t.tint,t.texture.requiresReTint=!1),e.context.drawImage(t.tintedTexture,0,0,a,l,n,h,a/i,l/i);else{const s=t.texture.crop.x,r=t.texture.crop.y;a=Math.floor(a),l=Math.floor(l),e.context.drawImage(t.texture.baseTexture.source,s,r,a,l,n,h,a/i,l/i)}}for(let i=0;i<t.children.length;i+=1)t.children[i].renderCanvas(e);t._mask&&e.maskManager.popMask(e)}const _i=class{constructor(){this.exists=!0,this.renderable=!1,this.visible=!0,this.position=new ce(0,0),this.scale=new ce(1,1),this.pivot=new ce(0,0),this.anchor=new ce(0,0),this.rotation=0,this.alpha=1,this.hitArea=null,this.parent=null,this.worldAlpha=1,this.worldTransform=new pi,this.worldScale=new ce(1,1),this.filterArea=null,this._sr=0,this._cr=1,this.cachedBounds=new ei(0,0,0,0),this.currentBounds=null,this._mask=null,this.children=[],this.ignoreChildInput=!1}destroy(){if(this.children){let t=this.children.length;for(;t;)t-=1,this.children[t].destroy()}this.children=null,this.exists=!1,this.renderable=!1,this.visible=!1,this.hitArea=null,this.parent=null,this.worldTransform=null,this.worldScale=null,this.filterArea=null,this.cachedBounds=null,this.currentBounds=null,this._mask=null,this.destroyCachedSprite()}addChild(t){return this.addChildAt(t,this.children.length)}addChildAt(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);if(i<0||s<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[s]=t}getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");const i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]}removeChild(t){const e=this.children.indexOf(t);return-1===e?null:this.removeChildAt(e)}removeChildAt(t){const e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e}removeChildren(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);const i=e-t;if(i>0&&i<=e){const e=this.children.splice(t,i);for(let t=0;t<e.length;t+=1)e[t].parent=void 0;return e}if(0===i&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")}updateTransform(t){if(!t&&!this.parent)return this;if(!this.game||!this.visible)return this;let e=this.parent;t?e=t:this.parent||(e=this.game.world);const i=e.worldTransform,s=this.worldTransform;let n,h,r,o,a,l;this.rotation%Bt?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),n=this._cr*this.scale.x,h=this._sr*this.scale.x,r=-this._sr*this.scale.y,o=this._cr*this.scale.y,a=this.position.x,l=this.position.y,(this.pivot.x||this.pivot.y)&&(a-=this.pivot.x*n+this.pivot.y*r,l-=this.pivot.x*h+this.pivot.y*o),s.a=n*i.a+h*i.c,s.b=n*i.b+h*i.d,s.c=r*i.a+o*i.c,s.d=r*i.b+o*i.d,s.tx=a*i.a+l*i.c+i.tx,s.ty=a*i.b+l*i.d+i.ty):(n=this.scale.x,o=this.scale.y,a=this.position.x-this.pivot.x*n,l=this.position.y-this.pivot.y*o,s.a=n*i.a,s.b=n*i.b,s.c=o*i.c,s.d=o*i.d,s.tx=a*i.a+l*i.c+i.tx,s.ty=a*i.b+l*i.d+i.ty),this.worldAlpha=this.alpha*e.worldAlpha,this.worldScale.set(this.scale.x*Math.sqrt(s.a*s.a+s.c*s.c),this.scale.y*Math.sqrt(s.b*s.b+s.d*s.d)),this.worldRotation=Math.atan2(-s.c,s.d),this.currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,s,i);for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();return this}getBounds(t){const e=t&&void 0!==t.contains;let i,s,n=!0;if(e?n=void 0!==t.contains&&t.contains(this):t=this,e)for(s=t.worldTransform,t.worldTransform=ci(),i=0;i<t.children.length;i+=1)t.children[i].updateTransform();let h,r,o,a=1/0,l=1/0,d=-1/0,u=-1/0,c=!1;for(i=0;i<this.children.length;i+=1)this.children[i].visible&&(c=!0,h=this.children[i].getBounds(),a=a<h.x?a:h.x,l=l<h.y?l:h.y,r=h.width+h.x,o=h.height+h.y,d=d>r?d:r,u=u>o?u:o);let p=this.cachedBounds;if(!c){p=new ei;const t=p.x,e=p.width+p.x,i=p.y,s=p.height+p.y,n=this.worldTransform,h=n.a,r=n.b,o=n.c,c=n.d,g=n.tx,m=n.ty,f=h*e+o*s+g,_=c*s+r*e+m,v=h*t+o*s+g,x=c*s+r*t+m,y=h*t+o*i+g,w=c*i+r*t+m,b=h*e+o*i+g,S=c*i+r*e+m;d=f,u=_,a=f,l=_,a=v<a?v:a,a=y<a?y:a,a=b<a?b:a,l=x<l?x:l,l=w<l?w:l,l=S<l?S:l,d=v>d?v:d,d=y>d?y:d,d=b>d?b:d,u=x>u?x:u,u=w>u?w:u,u=S>u?S:u}if(p.x=a,p.y=l,p.width=d-a,p.height=u-l,e)for(t.worldTransform=s,i=0;i<t.children.length;i+=1)t.children[i].updateTransform();if(!n){const e=t.getBounds();p.x-=e.x,p.y-=e.y}return p}getLocalBounds(){return this.getBounds(this)}contains(t){return!!t&&(t===this||this.contains(t.parent))}renderWebGL(t){if(!this.visible||this.alpha<=0)return;let e;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t)}renderCanvas(t){if(this.visible&&!(this.alpha<=0)){this._mask&&t.maskManager.pushMask(this._mask,t);for(let e=0;e<this.children.length;e+=1)this.children[e].renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}preUpdate(){}update(){}postUpdate(){}generateTexture(){console.warn("display_object.generateTexture() is not implemented")}toGlobal(t){return this.updateTransform(),this.worldTransform.apply(t)}toLocal(t,e){return e&&(t=e.toGlobal(t)),this.updateTransform(),this.worldTransform.applyInverse(t)}renderCachedSprite(t){this._cachedSprite&&(this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?mi(this._cachedSprite,t):fi(this._cachedSprite,t))}generateCachedSprite(){}destroyCachedSprite(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}get width(){return this.getLocalBounds().width*this.scale.x}set width(t){const e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}get height(){return this.getLocalBounds().height*this.scale.y}set height(t){const e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}get x(){return this.position.x}set x(t){this.position.x=t}get y(){return this.position.y}set y(t){this.position.y=t}get worldVisible(){if(!this.visible)return!1;let t=this.parent;if(!t)return this.visible;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){this._mask&&(this._mask.isMask=!1),this._mask=t,t&&(this._mask.isMask=!0)}get offsetX(){return this.anchor.x*this.width}get offsetY(){return this.anchor.y*this.height}get centerX(){return this.x-this.offsetX+.5*this.width}set centerX(t){this.x=t+this.offsetX-.5*this.width}get centerY(){return this.y-this.offsetY+.5*this.height}set centerY(t){this.y=t+this.offsetY-.5*this.height}get left(){return this.x-this.offsetX}set left(t){this.x=t+this.offsetX}get right(){return this.x+this.width-this.offsetX}set right(t){this.x=t-this.width+this.offsetX}get top(){return this.y-this.offsetY}set top(t){this.y=t+this.offsetY}get bottom(){return this.y+this.height-this.offsetY}set bottom(t){this.y=t-this.height+this.offsetY}},vi=class extends _i{constructor(t,e,i,s,n){super(),this.game=t,this.type=lt,this.renderable=!0,this.key=s,this.texture=window.PhaserRegistry.CACHE_MISSING_IMAGE,this.data={},this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=R,this.shader=null,this._frame=null,this.position.set(e,i),this.events=new class{constructor(t){this.parent=t,this._onAddedToGroup=null,this._onRemovedFromGroup=null,this._onDestroy=null,this._onOutOfBounds=null,this._onEnterBounds=null,this._onInputOver=null,this._onInputOut=null,this._onInputDown=null,this._onInputUp=null,this._onDragStart=null,this._onDragUpdate=null,this._onDragStop=null,this._onAnimationStart=null,this._onAnimationComplete=null,this._onAnimationLoop=null}destroy(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()}get onAddedToGroup(){return this._onAddedToGroup||(this._onAddedToGroup=new Ze),this._onAddedToGroup}onAddedToGroup$dispatch(){this._onAddedToGroup&&this._onAddedToGroup.dispatch(...arguments)}get onRemovedFromGroup(){return this._onRemovedFromGroup||(this._onRemovedFromGroup=new Ze),this._onRemovedFromGroup}onRemovedFromGroup$dispatch(){this._onRemovedFromGroup&&this._onRemovedFromGroup.dispatch(...arguments)}get onDestroy(){return this._onDestroy||(this._onDestroy=new Ze),this._onDestroy}onDestroy$dispatch(){this._onDestroy&&this._onDestroy.dispatch(...arguments)}get onOutOfBounds(){return this._onOutOfBounds||(this._onOutOfBounds=new Ze),this._onOutOfBounds}onOutOfBounds$dispatch(){this._onOutOfBounds&&this._onOutOfBounds.dispatch(...arguments)}get onEnterBounds(){return this._onEnterBounds||(this._onEnterBounds=new Ze),this._onEnterBounds}onEnterBounds$dispatch(){this._onEnterBounds&&this._onEnterBounds.dispatch(...arguments)}get onInputOver(){return this._onInputOver||(this._onInputOver=new Ze),this._onInputOver}onInputOver$dispatch(){this._onInputOver&&this._onInputOver.dispatch(...arguments)}get onInputOut(){return this._onInputOut||(this._onInputOut=new Ze),this._onInputOut}onInputOut$dispatch(){this._onInputOut&&this._onInputOut.dispatch(...arguments)}get onInputDown(){return this._onInputDown||(this._onInputDown=new Ze),this._onInputDown}onInputDown$dispatch(){this._onInputDown&&this._onInputDown.dispatch(...arguments)}get onInputUp(){return this._onInputUp||(this._onInputUp=new Ze),this._onInputUp}onInputUp$dispatch(){this._onInputUp&&this._onInputUp.dispatch(...arguments)}get onDragStart(){return this._onDragStart||(this._onDragStart=new Ze),this._onDragStart}onDragStart$dispatch(){this._onDragStart&&this._onDragStart.dispatch(...arguments)}get onDragUpdate(){return this._onDragUpdate||(this._onDragUpdate=new Ze),this._onDragUpdate}onDragUpdate$dispatch(){this._onDragUpdate&&this._onDragUpdate.dispatch(...arguments)}get onDragStop(){return this._onDragStop||(this._onDragStop=new Ze),this._onDragStop}onDragStop$dispatch(){this._onDragStop&&this._onDragStop.dispatch(...arguments)}get onAnimationStart(){return this._onAnimationStart||(this._onAnimationStart=new Ze),this._onAnimationStart}onAnimationStart$dispatch(){this._onAnimationStart&&this._onAnimationStart.dispatch(...arguments)}get onAnimationComplete(){return this._onAnimationComplete||(this._onAnimationComplete=new Ze),this._onAnimationComplete}onAnimationComplete$dispatch(){this._onAnimationComplete&&this._onAnimationComplete.dispatch(...arguments)}get onAnimationLoop(){return this._onAnimationLoop||(this._onAnimationLoop=new Ze),this._onAnimationLoop}onAnimationLoop$dispatch(){this._onAnimationLoop&&this._onAnimationLoop.dispatch(...arguments)}}(this),this.animations=new class{constructor(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]}destroy(){const t=Object.keys(this._anims);for(let e=0;e<t.length;e+=1)this._anims[t[e]].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}loadFrameData(t,e){if(!t)return!1;if(this.isLoaded){const e=Object.keys(this._anims);for(let i=0;i<e.length;i+=1){const s=e[i];this._anims[s].updateFrameData(t)}}return this._frameData=t,null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0}copyFrameData(t,e){if(this._frameData=t.clone(),this.isLoaded){const t=Object.keys(this._anims);for(let e=0;e<t.length;e+=1){const i=t[e];this._anims[i].updateFrameData(this._frameData)}}return null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0}add(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;const h=e||[];return void 0===n&&(n=!(!h||"number"!=typeof h[0])),this._outputFrames=[],this._frameData.getFrameIndexes(h,n,this._outputFrames),this._anims[t]=new class{constructor(t,e,i,s,n,h){let r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];this.game=t,this._parent=e,this._frameData=s,this.name=i,this._frames=[],this._frames=this._frames.concat(n),this.delay=1e3/h,this.loop=r,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new Ze,this.onUpdate=null,this.onComplete=new Ze,this.onLoop=new Ze,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)}play(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this}restart(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)}reverse(){return this.reversed=!this.reversed,this}reverseOnce(){return this.onComplete.addOnce(this.reverse,this),this.reverse()}setFrame(t){let e,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("string"==typeof t)for(let i=0;i<this._frames.length;i+=1)this._frameData.getFrame(this._frames[i]).name===t&&(e=i);else if("number"==typeof t)if(i)e=t;else for(let i=0;i<this._frames.length;i+=1)this._frames[i]===t&&(e=i);e&&(this._frameIndex=e-1,this._timeNextFrame=this.game.time.time,this.update())}stop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.isPlaying=!1,this.isFinished=!0,this.paused=!1,t&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this.currentFrame&&this._parent.setFrame(this.currentFrame)),e&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))}onPause(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)}onResume(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)}update(){return!this.isPaused&&!!(this.isPlaying&&this.game.time.time>=this._timeNextFrame)&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount+=1,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))}updateCurrentFrame(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._frameData||!this.currentFrame)return!1;const i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||!e&&i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)}next(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))}previous(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e+=1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))}updateFrameData(t){this._frameData=t,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null}destroy(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())}complete(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}get paused(){return this.isPaused}set paused(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}get reversed(){return this.isReversed}set reversed(t){this.isReversed=t}get frameTotal(){return this._frames.length}get frame(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex}set frame(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}get speed(){return 1e3/this.delay}set speed(t){t>0&&(this.delay=1e3/t)}get enableUpdate(){return null!==this.onUpdate}set enableUpdate(t){t&&null===this.onUpdate?this.onUpdate=new Ze:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}(this.game,this.sprite,t,this._frameData,this._outputFrames,i,s),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]}validateFrames(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(let i=0;i<t.length;i+=1)if(!0===e){if(t[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0}play(t,e,i,s){return this._anims[t]?this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s)):null}stop(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)}update(){return!(this.updateIfVisible&&!this.sprite.visible||!this.currentAnim||!this.currentAnim.update()||(this.currentFrame=this.currentAnim.currentFrame,0))}next(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)}previous(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)}getAnimation(t){return t&&this._anims[t]?this._anims[t]:null}refreshFrame(){console.warn("animation_manager.refreshFrame() is not implemented")}get frameData(){return this._frameData}get frameTotal(){return this._frameData.total}get paused(){return this.currentAnim.isPaused}set paused(t){this.currentAnim.paused=t}get name(){return this.currentAnim?this.currentAnim.name:null}get frame(){return this.currentFrame?this.currentFrame.index:0}set frame(t){"number"==typeof t&&this._frameData&&null!==this._frameData.getFrame(t)?(this.currentFrame=this._frameData.getFrame(t),this.currentFrame&&this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frame: "+t)}get frameName(){return this.currentFrame?this.currentFrame.name:null}set frameName(t){"string"==typeof t&&this._frameData&&null!==this._frameData.getFrameByName(t)?(this.currentFrame=this._frameData.getFrameByName(t),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame))):console.warn("Cannot set frameName: "+t)}}(this),this.loadTexture(s,n)}destroy(){this.game=null,this.key=null,this.data=null,this.texture=null,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.shader=null,this._frame=null,this.events&&this.events.destroy(),this.events=null,this.animations&&this.animations.destroy(),this.animations=null,super.destroy()}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists){this.visible&&(this.game.stage.currentRenderOrderID+=1,this.renderOrderID=this.game.stage.currentRenderOrderID),this.animations&&this.animations.update();for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}else this.renderOrderID=-1}loadTexture(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t===Mt?(t=e,e=0):e=e||0,(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&this.animations.stop(),this.key=t,this.customRender=!1;const i=this.game.cache,s=!this.texture.baseTexture.scaleMode;let n=!0;if(t instanceof ri)this.setTexture(t);else{const s=i.getImage(t,!0);s&&(this.key=s.key,this.setTexture(new ri(s.base)),this.texture.baseTexture.skipRender="__default"===t,n=!this.animations.loadFrameData(s.frameData,e))}n&&(this._frame=Je(this.texture.frame)),s||(this.texture.baseTexture.scaleMode=1)}setFrame(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)}resizeFrame(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)}resetFrame(){this._frame&&this.setFrame(this._frame)}get frame(){return this.animations.frame}set frame(t){this.animations.frame=t}get frameName(){return this.animations.frameName}set frameName(t){this.animations.frameName=t}crop(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(e&&null!==this.cropRect?this.cropRect.setTo(t.x,t.y,t.width,t.height):e&&null===this.cropRect?this.cropRect=new ei(t.x,t.y,t.width,t.height):this.cropRect=t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())}updateCrop(){if(!this.cropRect)return;const t=this.texture.crop.x,e=this.texture.crop.y,i=this.texture.crop.width,s=this.texture.crop.height;this._crop=Je(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;const n=Math.max(this._frame.x,this._crop.x),h=Math.max(this._frame.y,this._crop.y),r=Math.min(this._frame.right,this._crop.right)-n,o=Math.min(this._frame.bottom,this._crop.bottom)-h;this.texture.crop.x=n,this.texture.crop.y=h,this.texture.crop.width=r,this.texture.crop.height=o,this.texture.frame.width=Math.min(r,this.cropRect.width),this.texture.frame.height=Math.min(o,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||t===n&&e===h&&i===r&&s===o||(this.texture.requiresReTint=!0)}get width(){return this.scale.x*this.texture.frame.width}set width(t){this.scale.x=t/this.texture.frame.width,this._width=t}get height(){return this.scale.y*this.texture.frame.height}set height(t){this.scale.y=t/this.texture.frame.height,this._height=t}onTextureUpdate(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)}setTexture(t){!function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&t.texture.baseTexture.destroy(),t.texture.baseTexture.skipRender=!1,t.texture=e,t.texture.valid=!0,t.cachedTint=-1}(this,t,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}getBounds(){return gi(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)}getLocalBounds(){return function(t){const e=t.worldTransform;let i;for(t.worldTransform=ci(),i=0;i<t.children.length;i+=1)t.children[i].updateTransform();const s=t.getBounds();for(t.worldTransform=e,i=0;i<t.children.length;i+=1)t.children[i].updateTransform();return s}(this)}renderWebGL(t){mi(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)}renderCanvas(t){fi(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)}},xi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:20;this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=bt}contains(t,e){return!(this.width<=0||this.height<=0)&&t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new xi;return i.x=t.x,i.y=t.y,i.width=t.width,i.height=t.height,i.radius=t.radius,i}(this)}},yi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.area=0,this._points=[],this.closed=!0,this.flattened=!1,this.type=vt,t&&this.setTo(t)}toNumberArray(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];for(let e=0;e<this._points.length;e+=1)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e+=1):(t.push(this._points[e].x),t.push(this._points[e].y));return t}flatten(){return this._points=this.toNumberArray(),this.flattened=!0,this}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new yi;return i.setTo(t._points.slice()),i}(this)}contains(t,e){let i=!1;if(this.flattened)for(let s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){const h=this._points[s],r=this._points[s+1],o=this._points[n],a=this._points[n+1];(r<=e&&e<a||a<=e&&e<r)&&t<(o-h)*(e-r)/(a-r)+h&&(i=!i)}else for(let s=-1,n=this._points.length-1;++s<this._points.length;n=s){const h=this._points[s].x,r=this._points[s].y,o=this._points[n].x,a=this._points[n].y;(r<=e&&e<a||a<=e&&e<r)&&t<(o-h)*(e-r)/(a-r)+h&&(i=!i)}return i}setTo(t){if(this.area=0,this._points=[],t){Array.isArray(t)||console.error("[Polygon] setTo() error, input parameter is not an array",t);let e=Number.MAX_VALUE;for(let i=0,s=t.length;i<s;i+=1){let s;"number"==typeof t[i]?(s=new ce(t[i],t[i+1]),i+=1):s=Array.isArray(t[i])?new ce(t[i][0],t[i][1]):new ce(t[i].x,t[i].y),this._points.push(s),s.y<e&&(e=s.y)}this.calculateArea(e)}return this}calculateArea(t){let e,i,s,n;for(let h=0,r=this._points.length;h<r;h+=1)e=this._points[h],i=h===r-1?this._points[0]:this._points[h+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}get points(){return this._points}set points(t){null!==t?this.setTo(t):(this.area=0,this._points=[])}},wi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.x=t,this.y=e,this._diameter=i,this._radius=0,i>0&&(this._radius=.5*i),this.type=yt}circumference(){return Math.PI*this._radius*2}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ce,e=2*Math.PI*Math.random(),i=Math.random()+Math.random(),s=i>1?2-i:i,n=s*Math.cos(e),h=s*Math.sin(e);return t.x=this.x+n*this.radius,t.y=this.y+h*this.radius,t}getBounds(){return new ei(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)}setTo(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this}copyFrom(t){return this.setTo(t.x,t.y,t.diameter)}copyTo(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t}distance(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=$t(this.x,this.y,t.x,t.y);return e?Math.round(i):i}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new wi;return i.x=t.x,i.y=t.y,i.diameter=t.diameter,i}(this)}contains(t,e){return function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}(this,t,e)}circumferencePoint(t,e,i){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=s||new ce;return!0===i&&(e=zt(e)),n.x=t.x+t.radius*Math.cos(e),n.y=t.y+t.radius*Math.sin(e),n}(this,t,e,i)}offset(t,e){return this.x+=t,this.y+=e,this}offsetPoint(t){return this.offset(t.x,t.y)}toString(){return"[{Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}get diameter(){return this._diameter}set diameter(t){t>0&&(this._diameter=t,this._radius=.5*t)}get radius(){return this._radius}set radius(t){t>0&&(this._radius=t,this._diameter=2*t)}get left(){return this.x-this._radius}set left(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}get right(){return this.x+this._radius}set right(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}get top(){return this.y-this._radius}set top(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}get bottom(){return this.y+this._radius}set bottom(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}get area(){return this._radius>0?Math.PI*this._radius*this._radius:0}get empty(){return 0===this._diameter}set empty(t){!0===t&&this.setTo(0,0,0)}},bi=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.x=t,this.y=e,this.width=i,this.height=s,this.type=wt}setTo(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}getBounds(){return new ei(this.x-this.width,this.y-this.height,this.width,this.height)}copyFrom(t){return this.setTo(t.x,t.y,t.width,t.height)}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return function(t,e,i){if(t.width<=0||t.height<=0)return!1;let s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return s*=s,n*=n,s+n<.25}(this,t,e)}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ce,e=Math.random()*Math.PI*2,i=Math.random();return t.x=Math.sqrt(i)*Math.cos(e),t.y=Math.sqrt(i)*Math.sin(e),t.x=this.x+t.x*this.width/2,t.y=this.y+t.y*this.height/2,t}toString(){return"[{Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},Si=class{constructor(t,e,i,s,n,h,r){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=h,this.shape=r,this.type=r.type}clone(){return new Si((t=this).lineWidth,t.lineColor,t.lineAlpha,t.fillColor,t.fillAlpha,t.fill,t.shape);var t}};function Ti(t,e){return new ri(function(t,e){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),new oi(t,e)}(t,e))}const Ci=class extends _i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;super(),this.game=t,this.type=dt,this.position.set(e,i),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=R,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new ei(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1}destroy(){this.clear(),super.destroy()}lineStyle(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return this.lineWidth=t||0,this.lineColor=e||0,this.lineAlpha=void 0===i?1:i,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new yi(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this}moveTo(t,e){return this.drawShape(new yi([t,e])),this}lineTo(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this._boundsDirty=!0,this}quadraticCurveTo(t,e,i,s){let n,h;this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);const r=this.currentPath.shape.points;0===r.length&&this.moveTo(0,0);const o=r[r.length-2],a=r[r.length-1];let l=0;for(let d=1;d<=20;d+=1)l=d/20,n=o+(t-o)*l,h=a+(e-a)*l,r.push(n+(t+(i-t)*l-n)*l,h+(e+(s-e)*l-h)*l);return this.dirty=!0,this._boundsDirty=!0,this}bezierCurveTo(t,e,i,s,n,h){let r,o,a,l,d;this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);const u=this.currentPath.shape.points,c=u[u.length-2],p=u[u.length-1];let g=0;for(let m=1;m<=20;m+=1)g=m/20,r=1-g,o=r*r,a=o*r,l=g*g,d=l*g,u.push(a*c+3*o*g*t+3*r*l*i+d*n,a*p+3*o*g*e+3*r*l*s+d*h);return this.dirty=!0,this._boundsDirty=!0,this}arcTo(t,e,i,s,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);const h=this.currentPath.shape.points,r=h[h.length-2],o=h[h.length-1]-e,a=r-t,l=s-e,d=i-t,u=Math.abs(o*d-a*l);if(u<1e-8||0===n)h[h.length-2]===t&&h[h.length-1]===e||h.push(t,e);else{const i=o*o+a*a,s=l*l+d*d,h=o*l+a*d,r=n*Math.sqrt(i)/u,c=n*Math.sqrt(s)/u,p=r*h/i,g=c*h/s,m=r*d+c*a,f=r*l+c*o,_=a*(c+p),v=o*(c+p),x=d*(r+g),y=l*(r+g),w=Math.atan2(v-f,_-m),b=Math.atan2(y-f,x-m);this.arc(m+t,f+e,n,w,b,a*l>d*o)}return this.dirty=!0,this._boundsDirty=!0,this}arc(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]&&arguments[5],r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:40;if(s===n)return this;!h&&n<=s?n+=2*Math.PI:h&&s<=n&&(s+=2*Math.PI);const o=h?-1*(s-n):n-s,a=Math.ceil(Math.abs(o)/(2*Math.PI))*r;if(0===o)return this;const l=t+Math.cos(s)*i,d=e+Math.sin(s)*i;h&&this.filling?this.moveTo(t,e):this.moveTo(l,d);const u=this.currentPath.shape.points,c=o/(2*a),p=2*c,g=Math.cos(c),m=Math.sin(c),f=a-1,_=f%1/f;for(let n=0;n<=f;n+=1){const h=c+s+p*(n+_*n),r=Math.cos(h),o=-Math.sin(h);u.push((g*r+m*o)*i+t,(g*-o+m*r)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this}beginFill(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this}endFill(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this}drawRect(t,e,i,s){return this.drawShape(new ei(t,e,i,s)),this}drawRoundedRect(t,e,i,s,n){return this.drawShape(new xi(t,e,i,s,n)),this}drawCircle(t,e,i){return this.drawShape(new wi(t,e,i)),this}drawEllipse(t,e,i,s){return this.drawShape(new bi(t,e,i,s)),this}drawPolygon(t){let e;return e=t instanceof yi?t.points:t,this.drawShape(new yi(e)),this}clear(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this}generateTexture(){console.warn("graphics.generateTexture() is not implemented")}renderWebGL(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask)if(this._cacheAsBitmap)(this.dirty||this.cachedSpriteDirty)&&(this.generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,mi.call(this._cachedSprite,t);else{if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;const e=window.PhaserRegistry.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),function(t,e){const i=e.gl,s=e.projection,n=e.offset;let h,r=e.shaderManager.primitiveShader;t.dirty&&Ke(t,i);const o=t._webGL[i.id];if(o)for(let a=0;a<o.data.length;a+=1)1===o.data[a].mode?(h=o.data[a],e.stencilManager.pushStencil(t,h,e),i.drawElements(i.TRIANGLE_FAN,4,i.UNSIGNED_SHORT,2*(h.indices.length-4)),e.stencilManager.popStencil(t,h,e)):(h=o.data[a],e.shaderManager.setShader(r),r=e.shaderManager.primitiveShader,i.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),i.uniform1f(r.flipY,1),i.uniform2f(r.projectionVector,s.x,-s.y),i.uniform2f(r.offsetVector,-n.x,-n.y),i.uniform3fv(r.tintColor,Nt(t.tint)),i.uniform1f(r.alpha,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,h.buffer),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,24,0),i.vertexAttribPointer(r.colorAttribute,4,i.FLOAT,!1,24,8),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h.indexBuffer),i.drawElements(i.TRIANGLE_STRIP,h.indices.length,i.UNSIGNED_SHORT,0))}(this,t),this.children.length){t.spriteBatch.start();for(let e=0;e<this.children.length;e+=1)this.children[e].renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount+=1,t.spriteBatch.start()}}renderCanvas(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask)if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)(this.dirty||this.cachedSpriteDirty)&&(this.generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,fi(this._cachedSprite,t);else{const e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=window.PhaserRegistry.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);const s=t.resolution,n=i.tx*t.resolution+t.shakeX,h=i.ty*t.resolution+t.shakeY;e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,h),le(this,e);for(let e=0;e<this.children.length;e+=1)this.children[e].renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}getBounds(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this.renderable)return window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.EMPTY_RECTANGLE||(window.PhaserRegistry.EMPTY_RECTANGLE=new ei),window.PhaserRegistry.EMPTY_RECTANGLE;if(this.dirty)this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1;else if(this.currentBounds)return this.currentBounds;const e=this._localBounds,i=e.x,s=e.width+e.x,n=e.y,h=e.height+e.y,r=t||this.worldTransform,o=r.a,a=r.b,l=r.c,d=r.d,u=r.tx,c=r.ty,p=o*s+l*h+u,g=d*h+a*s+c,m=o*i+l*h+u,f=d*h+a*i+c,_=o*i+l*n+u,v=d*n+a*i+c,x=o*s+l*n+u,y=d*n+a*s+c;let w=p,b=g,S=p,T=g;return S=m<S?m:S,S=_<S?_:S,S=x<S?x:S,T=f<T?f:T,T=v<T?v:T,T=y<T?y:T,w=m>w?m:w,w=_>w?_:w,w=x>w?x:w,b=f>b?f:b,b=v>b?v:b,b=y>b?y:b,this.cachedBounds.x=S,this.cachedBounds.width=w-S,this.cachedBounds.y=T,this.cachedBounds.height=b-T,this.currentBounds=this.cachedBounds,this.currentBounds}getLocalBounds(){const t=this.worldTransform;this.worldTransform=ci();for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();const e=this.getBounds();this.worldTransform=t;for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform();return e}containsPoint(t,e){this.worldTransform.applyInverse(t,e);const i=this.graphicsData;for(let t=0;t<i.length;t+=0){const s=i[t];if(s.fill&&s.shape&&s.shape.contains(e.x,e.y))return!0}return!1}updateLocalBounds(){let t=1/0,e=-1/0,i=1/0,s=-1/0;if(this.graphicsData.length){let n,h,r,o,a,l;for(let d=0;d<this.graphicsData.length;d+=1){const u=this.graphicsData[d],c=u.type,p=u.lineWidth;if(n=u.shape,c===xt||c===bt)r=n.x-p/2,o=n.y-p/2,a=n.width+p,l=n.height+p,t=r<t?r:t,e=r+a>e?r+a:e,i=o<i?o:i,s=o+l>s?o+l:s;else if(c===yt)r=n.x,o=n.y,a=n.radius+p/2,l=n.radius+p/2,t=r-a<t?r-a:t,e=r+a>e?r+a:e,i=o-l<i?o-l:i,s=o+l>s?o+l:s;else if(c===wt)r=n.x,o=n.y,a=n.width+p/2,l=n.height+p/2,t=r-a<t?r-a:t,e=r+a>e?r+a:e,i=o-l<i?o-l:i,s=o+l>s?o+l:s;else{h=n.points;for(let n=0;n<h.length;n+=1)h[n]instanceof ce?(r=h[n].x,o=h[n].y):(r=h[n],o=h[n+1],n<h.length-1&&(n+=1)),t=r-p<t?r-p:t,e=r+p>e?r+p:e,i=o-p<i?o-p:i,s=o+p>s?o+p:s}}}else t=0,e=0,i=0,s=0;const n=this.boundsPadding;this._localBounds.x=t-n,this._localBounds.width=e-t+2*n,this._localBounds.y=i-n,this._localBounds.height=s-i+2*n}generateCachedSprite(){const t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{const e=new Ft(t.width,t.height),i=Ti(e.canvas);this._cachedSprite=new vi(this.game,0,0,i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,le(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha}updateCachedSpriteTexture(){const t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=i.width,e.crop.height=i.height,e.frame.width=i.width,e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()}destroyCachedSprite(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}drawShape(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof yi&&(t=t.clone()).flatten();const e=new Si(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===vt&&(e.shape.closed=this.filling,this.currentPath=e),this.dirty=!0,this._boundsDirty=!0,e}postUpdate(){this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate()}drawTriangle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=new yi(t);if(e){const e=new ce(0-t[0].x,0-t[0].y),s=new ce(t[1].x-t[0].x,t[1].y-t[0].y),n=new ce(t[1].x-t[2].x,t[1].y-t[2].y).cross(s);e.dot(n)>0&&this.drawPolygon(i)}else this.drawPolygon(i)}drawTriangles(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=new ce,n=new ce,h=new ce;let r,o=[];if(e)if(t[0]instanceof ce)for(r=0;r<e.length/3;r+=1)o.push(t[e[3*r]]),o.push(t[e[3*r+1]]),o.push(t[e[3*r+2]]),3===o.length&&(this.drawTriangle(o,i),o=[]);else for(r=0;r<e.length;r+=1)s.x=t[2*e[r]],s.y=t[2*e[r]+1],o.push(s.copyTo({})),3===o.length&&(this.drawTriangle(o,i),o=[]);else if(t[0]instanceof ce)for(r=0;r<t.length/3;r+=1)this.drawTriangle([t[3*r],t[3*r+1],t[3*r+2]],i);else for(r=0;r<t.length/6;r+=1)s.x=t[6*r+0],s.y=t[6*r+1],n.x=t[6*r+2],n.y=t[6*r+3],h.x=t[6*r+4],h.y=t[6*r+5],this.drawTriangle([s,n,h],i)}},Mi=class{constructor(t,e,i){this.game=t,this.id=e,this.type=_t,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=i||tt|et,this.target=null,this.button=null,this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===e,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new ce,this.positionDown=new ce,this.positionUp=new ce,this.circle=new wi(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null}resetButtons(){this.isDown=!1,this.isUp=!0}updateButtons(t){"down"===t.type.toLowerCase().substr(-4)?(this.isUp=!1,this.isDown=!0):(this.isUp=!0,this.isDown=!1)}start(t){const e=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(e.multiInputOverride===it||e.multiInputOverride===nt||e.multiInputOverride===st&&0===e.totalActivePointers)&&(e.x=this.x,e.y=this.y,e.position.setTo(this.x,this.y),e.onDown.dispatch(this,t),e.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches+=1,null!==this.targetObject&&this.targetObject._touchedHandler(this),this}update(){const t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===it||t.multiInputOverride===nt||t.multiInputOverride===st&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))}move(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.game.input;if(i.pollLocked)return null;if(e&&this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&i.mouse.locked&&!e&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*i.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*i.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(i.multiInputOverride===it||i.multiInputOverride===nt||i.multiInputOverride===st&&0===i.totalActivePointers)&&(i.activePointer=this,i.x=this.x,i.y=this.y,i.position.setTo(i.x,i.y),i.circle.x=i.x,i.circle.y=i.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY),this.game.paused)return this;let s=i.moveCallbacks.length;for(;s;)s-=1,i.moveCallbacks[s].callback.call(i.moveCallbacks[s].context,this,this.x,this.y,e);return null!==this.targetObject&&!0===this.targetObject.isDragged?!1===this.targetObject.update(this)&&(this.targetObject=null):i.interactiveItems.total>0&&this.processInteractiveObjects(e),this}processInteractiveObjects(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,n.validForInput(i,e,!1)&&(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject}swapTarget(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))}leave(t){this.withinGame=!1,this.move(t,!1)}stop(t){const e=this.game.input;return this._stateReset&&this.withinGame?(t.preventDefault(),null):(this.timeUp=this.game.time.time,(e.multiInputOverride===it||e.multiInputOverride===nt||e.multiInputOverride===st&&0===e.totalActivePointers)&&(e.onUp.dispatch(this,t),this.duration>=0&&this.duration<=e.tapRate&&(this.timeUp-this.previousTapTime<e.doubleTapRate?e.onTap.dispatch(this,!0):e.onTap.dispatch(this,!1),this.previousTapTime=this.timeUp)),this.isMouse?this.updateButtons(t):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&(e.currentPointers-=1),e.interactiveItems.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this)}justPressed(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time}justReleased(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time}addClickTrampoline(t,e,i,s){if(!this.isDown)return;this._clickTrampolines=this._clickTrampolines||[];const n=this._clickTrampolines;for(let e=0;e<n.length;e+=1)if(n[e].name===t){n.splice(e,1);break}n.push({name:t,targetObject:this.targetObject,callback:e,callbackContext:i,callbackArgs:s})}processClickTrampolines(){const t=this._clickTrampolines;if(t){for(let e=0;e<t.length;e+=1){const i=t[e];i.targetObject===this._trampolineTargetObject&&i.callback.apply(i.callbackContext,i.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}}reset(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null}resetMovement(){this.movementX=0,this.movementY=0}get duration(){return this.isUp?-1:this.game.time.time-this.timeDown}get worldX(){return this.x}get worldY(){return this.y}},Pi=class extends _i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:32,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"left";super(),this.game=t,this.type=ct,this.position.set(e,i),this.textWidth=0,this.textHeight=0,this._prevAnchor=new ce,this._glyphs=[],this._maxWidth=0,this._text=n.toString()||"",this._data=t.cache.getBitmapFont(s),this._font=s,this._fontSize=h,this._align=r,this._tint=16777215,this.updateText(),this.dirty=!1}destroy(){this._prevAnchor=null,this._glyphs=null,this._text=null,this._data=null,super.destroy()}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists){this.visible&&(this.game.stage.currentRenderOrderID+=1,this.renderOrderID=this.game.stage.currentRenderOrderID);for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}else this.renderOrderID=-1}setText(t){this.text=t}scanLine(t,e,i){let s=0,n=0,h=-1,r=0,o=null;const a=this._maxWidth>0?this._maxWidth:null,l=[];let d=!0;for(let u=0;u<i.length;u+=1){if(d=u===i.length-1,/(?:\r\n|\r|\n)/.test(i.charAt(u)))return{width:n,text:i.substr(0,u),end:d,chars:l};let c=i.charCodeAt(u),p=t.chars[c],g=0;void 0===p&&(c=32,p=t.chars[c]);const m=o&&p.kerning[o]?p.kerning[o]:0;if(/(\s)/.test(i.charAt(u))&&(h=u,r=n),g=(m+p.texture.width+p.xOffset)*e,a&&n+g>=a&&h>-1)return{width:r||n,text:i.substr(0,u-(u-h)),end:d,chars:l};n+=(p.xAdvance+m)*e,l.push(s+(p.xOffset+m)*e),s+=(p.xAdvance+m)*e,o=c}return{width:n,text:i,end:d,chars:l}}cleanText(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const i=this._data.font;if(!i)return"";const s=t.replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n");for(let t=0;t<s.length;t+=1){let n="";const h=s[t];for(let t=0;t<h.length;t+=1)n=i.chars[h.charCodeAt(t)]?n.concat(h[t]):n.concat(e);s[t]=n}return s.join("\n")}updateText(){const t=this._data.font;if(!t)return;let e=this.text;const i=this._fontSize/t.size,s=[];let n=0;this.textWidth=0;let h={end:0===e.length};do{h=this.scanLine(t,i,e),h.y=n,s.push(h),h.width>this.textWidth&&(this.textWidth=h.width),n+=t.lineHeight*i,e=e.substr(h.text.length+1)}while(!1===h.end);this.textHeight=n;let r=0,o=0;const a=this.textWidth*this.anchor.x,l=this.textHeight*this.anchor.y;for(let e=0;e<s.length;e+=1){const n=s[e];"right"===this._align?o=this.textWidth-n.width:"center"===this._align&&(o=(this.textWidth-n.width)/2);for(let e=0;e<n.text.length;e+=1){let s=n.text.charCodeAt(e),h=t.chars[s];void 0===h&&(s=32,h=t.chars[s]);let d=this._glyphs[r];d?d.texture=h.texture:(d=new vi(this.game,0,0,h.texture),d.name=n.text[e],this._glyphs.push(d)),d.position.x=n.chars[e]+o-a,d.position.y=n.y+h.yOffset*i-l,d.scale.set(i),d.tint=this.tint,d.texture.requiresReTint=!0,d.parent||this.addChild(d),r+=1}}for(let t=r;t<this._glyphs.length;t+=1)this.removeChild(this._glyphs[t])}purgeGlyphs(){const t=this._glyphs.length,e=[];for(let t=0;t<this._glyphs.length;t+=1)this._glyphs[t].parent!==this?this._glyphs[t].destroy():e.push(this._glyphs[t]);return this._glyphs=[],this._glyphs=e,this.updateText(),t-e.length}updateTransform(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),super.updateTransform()}get align(){return this._align}set align(t){t===this._align||"left"!==t&&"center"!==t&&"right"!==t||(this._align=t,this.updateText())}get tint(){return this._tint}set tint(t){t!==this._tint&&(this._tint=t,this.updateText())}get font(){return this._font}set font(t){const e=t.trim();e!==this._font&&(this._font=e,this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}get fontSize(){return this._fontSize}set fontSize(t){(t=parseInt(t,10))!==this._fontSize&&t>0&&(this._fontSize=t,this.updateText())}get text(){return this._text}set text(t){const e=t.toString();e!==this._text&&(this._text=e||"",this.updateText())}get maxWidth(){return this._maxWidth}set maxWidth(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}get smoothed(){return!this._data.base.scaleMode}set smoothed(t){this._data.base.scaleMode=t?0:1}},Ai=class{constructor(t){this.sprite=t,this.game=t.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new ce,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new ce,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new ce,this.snapPoint=new ce,this._dragPoint=new ce,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new ce,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=e,this.priorityID=t;for(let t=0;t<10;t+=1)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new ce,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite}addedToGroup(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()}removedFromGroup(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)}reset(){this.enabled=!1;for(let t=0;t<10;t+=1)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}}stop(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))}destroy(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)}validForInput(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput||!i&&(this.pixelPerfectClick||this.pixelPerfectOver)||!(this.priorityID>t||this.priorityID===t&&this.sprite.renderOrderID>e))}isPixelPerfect(){return this.pixelPerfectClick||this.pixelPerfectOver}pointerX(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].x}pointerY(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].y}pointerDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDown}pointerUp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isUp}pointerTimeDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeDown}pointerTimeUp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeUp}pointerOver(t){if(!this.enabled)return!1;if(void 0===t){for(let t=0;t<10;t+=1)if(this._pointerData[t].isOver)return!0;return!1}return this._pointerData[t].isOver}pointerOut(t){if(!this.enabled)return!1;if(void 0===t)for(let t=0;t<10;t+=1)if(this._pointerData[t].isOut)return!0;return this._pointerData[t].isOut}pointerTimeOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeOver}pointerTimeOut(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].timeOut}pointerDragged(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDragged}checkPointerDown(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!!(t.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))}checkPointerOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))}checkPixel(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e&&(this.game.input.getLocalPosition(this.sprite,i,this._tempPoint),t=this._tempPoint.x,e=this._tempPoint.y),0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,t<this.sprite.texture.crop.x||t>this.sprite.texture.crop.right||e<this.sprite.texture.crop.y||e>this.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1}update(t){return null!==this.sprite&&void 0!==this.sprite.parent&&(this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=$t(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):!!this._pointerData[t.id].isOver&&(this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1)):(this._pointerOutHandler(t),!1))}_pointerOverHandler(t,e){if(null===this.sprite)return;const i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){const s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.type===ht&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}_pointerOutHandler(t,e){if(null===this.sprite)return;const i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.type===ht&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}_touchedHandler(t){if(null===this.sprite)return;const e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.type===ht&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}dragTimeElapsed(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)}_releasedHandler(t){if(null===this.sprite)return;const e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;let i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.type===ht&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}updateDrag(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t.isUp)return this.stopDrag(t),!1;const i=this.globalToLocalX(t.x)+this._dragPoint.x+this.dragOffset.x,s=this.globalToLocalY(t.y)+this._dragPoint.y+this.dragOffset.y;return this.allowHorizontalDrag&&(this.sprite.x=i+0),this.allowVerticalDrag&&(this.sprite.y=s+0),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y)),this.sprite.events.onDragUpdate.dispatch(this.sprite,t,i,s,this.snapPoint,e),!0}justOver(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isOver&&this.overDuration(t)<e}justOut(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isOut&&this.game.time.time-this._pointerData[t].timeOut<e}justPressed(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isDown&&this.downDuration(t)<e}justReleased(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this._pointerData[t].isUp&&this.game.time.time-this._pointerData[t].timeUp<e}overDuration(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isOver?this.game.time.time-this._pointerData[t].timeOver:-1}downDuration(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._pointerData[t].isDown?this.game.time.time-this._pointerData[t].timeDown:-1}enableDrag(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:255,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;this._dragPoint=new ce,this.draggable=!0,this.bringToTop=e,this.dragOffset=new ce,this.dragFromCenter=t,this.pixelPerfectClick=i,this.pixelPerfectAlpha=s,n&&(this.boundsRect=n),h&&(this.boundsSprite=h)}disableDrag(){if(this._pointerData)for(let t=0;t<10;t+=1)this._pointerData[t].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1}startDrag(t){const e=this.sprite.x,i=this.sprite.y;if(this.isDragged=!0,this._draggedPointerID=t.id,this._pointerData[t.id].camX=0,this._pointerData[t.id].camY=0,this._pointerData[t.id].isDragged=!0,this.dragFromCenter){const e=this.sprite.getBounds();this.sprite.x=this.globalToLocalX(t.x)+(this.sprite.x-e.centerX),this.sprite.y=this.globalToLocalY(t.y)+(this.sprite.y-e.centerY)}this._dragPoint.setTo(this.sprite.x-this.globalToLocalX(t.x),this.sprite.y-this.globalToLocalY(t.y)),this.updateDrag(t,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.parent.bringToTop(this.sprite)),this.dragStartPoint.set(e,i),this.sprite.events.onDragStart$dispatch(this.sprite,t,e,i),this._pendingDrag=!1}globalToLocalX(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.x,t*=this.game.scale.grid.scaleFluidInversed.x),t}globalToLocalY(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.y,t*=this.game.scale.grid.scaleFluidInversed.y),t}stopDrag(t){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[t.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY),this.sprite.events.onDragStop$dispatch(this.sprite,t),!1===this.checkPointerOver(t)&&this._pointerOutHandler(t)}setDragLock(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.allowHorizontalDrag=t,this.allowVerticalDrag=e}enableSnap(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.snapX=t,this.snapY=e,this.snapOffsetX=n,this.snapOffsetY=h,this.snapOnDrag=i,this.snapOnRelease=s}disableSnap(){this.snapOnDrag=!1,this.snapOnRelease=!1}checkBoundsRect(){this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY))}checkBoundsSprite(){this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY))}},Ei="Over",ki="Out",Di="Down",Li="Up",Oi="Disabled",Ri=class extends vi{constructor(t){let e=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,r=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n),this.type=at,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this._onDisabledFrame=null,this.onInputOver=new Ze,this.onInputOut=new Ze,this.onInputDown=new Ze,this.onInputUp=new Ze,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=et,this.freezeFrames=!1,this.forceOut=!1,this.input=new Ai(this),this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(s,n,h,r),null!==e&&this.onInputUp.add(e,i),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)}destroy(){this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this._onDisabledFrame=null,this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose()),this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.input&&this.input.destroy(),this.input=null,super.destroy()}setEnabled(t,e){this.input.enabled=t,e?this.changeStateFrame(t?Li:Oi):setTimeout((()=>{this.changeStateFrame(t?Li:Oi)}),1)}clearFrames(){this.setFrames(null,null,null,null)}removedFromWorld(){this.inputEnabled=!1}setStateFrame(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s="_on"+t+"Frame";e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null}changeStateFrame(t){if(this.freezeFrames)return!1;const e=this["_on"+(this.input.enabled||!this._onDisabledFrame?t:Oi)+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)}setFrames(t,e,i,s){this.setStateFrame(Ei,t,this.input.pointerOver()),this.setStateFrame(ki,e,!this.input.pointerOver()),this.setStateFrame(Di,i,this.input.pointerDown()),this.setStateFrame(Li,s,this.input.pointerUp())}onInputOverHandler(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame(Ei),this.onOverMouseOnly&&!e.isMouse||this.onInputOver&&this.onInputOver.dispatch(this,e))}onInputOutHandler(t,e){this.changeStateFrame(ki),this.onInputOut&&this.onInputOut.dispatch(this,e)}onInputDownHandler(t,e){this.changeStateFrame(Di),this.onInputDown&&this.onInputDown.dispatch(this,e)}onInputUpHandler(t,e,i){this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame(ki):this.changeStateFrame(Li)||(i?this.changeStateFrame(Ei):this.changeStateFrame(ki)))}get inputEnabled(){return this.input&&this.input.enabled}set inputEnabled(t){t?null===this.input?(this.input=new Ai(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}},Fi=class extends _i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"group",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(),this.game=t,this.type=ht,e||(e=t.world),this.name=i||"group",this.z=0,s?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):e&&(e.addChild(this),this.z=e.children.length),this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=vi,this.cursor=null,this.inputEnableChildren=!1,this.onChildInputDown=new Ze,this.onChildInputUp=new Ze,this.onChildInputOver=new Ze,this.onChildInputOut=new Ze,this.onDestroy=new Ze,this.cursorIndex=0,this._sortProperty="z"}destroy(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===this.game||this.ignoreDestroy||(this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))}add(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return t.parent===this||(-1===i?(t.z=this.children.length,this.addChild(t)):(this.addChildAt(t,i),this.updateZ()),!this.inputEnableChildren||t.input&&!t.inputEnabled||(t.inputEnabled=!0),!e&&t.events&&t.events.onAddedToGroup$dispatch(t,this),null===this.cursor&&(this.cursor=t)),t}addAt(t,e,i){this.add(t,i,e)}getAt(t){return t<0||t>=this.children.length?-1:this.getChildAt(t)}updateZ(){let t=this.children.length;for(;t;)t-=1,this.children[t].z=t}next(){return this.cursor?(this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex+=1,this.cursor=this.children[this.cursorIndex],this.cursor):null}previous(){return this.cursor?(0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex-=1,this.cursor=this.children[this.cursorIndex],this.cursor):null}swap(t,e){this.swapChildren(t,e),this.updateZ()}bringToTop(t){return t.parent===this&&this.getIndex(t)<this.children.length&&(this.remove(t,!1,!0),this.add(t,!0)),t}sendToBack(t){return t.parent===this&&this.getIndex(t)>0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t}reverse(){this.children.reverse(),this.updateZ()}getIndex(t){return this.children.indexOf(t)}preUpdate(){if(this.pendingDestroy)this.destroy();else if(this.exists&&this.parent.exists)for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate();else this.renderOrderID=-1}update(){let t=this.children.length;for(;t;)t-=1,this.children[t].update()}postUpdate(){for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate()}remove(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0===this.children.length||-1===this.children.indexOf(t))return!1;i||!t.events||t.destroyPhase||t.events.onRemovedFromGroup$dispatch(t,this);const s=this.removeChild(t);return this.updateZ(),this.cursor===t&&this.next(),e&&s&&s.destroy(!0),!0}removeAll(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);const s=this.removeChild(this.children[0]);t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.cursor=null}}},Ii=class extends _i{constructor(t){super(),this.game=t}},Ui=class extends vi{constructor(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};super(t,e,i,null),this.game=t,this.type=ut,this.canvas=kt(this),this.context=this.canvas.getContext("2d"),this.padding=new ce,this.textBounds=null,this.style=null,this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this._res=t.renderer.resolution,this._text=s.toString(),this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,this.loadTexture(Ti(this.canvas)),this.setStyle(n),""!==this._text&&this.updateText()}destroy(){this.texture.destroy(!0),At(this),this.canvas=null,this.context=null,this.textBounds=null,this.style=null,this.colors=null,this.strokeColors=null,this.fontStyles=null,this.fontWeights=null,this.padding=null,this._text=null,this._fontComponents=null,super.destroy()}setShadow(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgba(0, 0, 0, 1)",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],h=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return this.style.shadowOffsetX=t,this.style.shadowOffsetY=e,this.style.shadowColor=i,this.style.shadowBlur=s,this.style.shadowStroke=n,this.style.shadowFill=h,this.dirty=!0,this}setStyle(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t=JSON.parse(JSON.stringify(t))||{},t.font=t.font||"bold 20pt Arial",t.backgroundColor=t.backgroundColor||null,t.fill=t.fill||"black",t.align=t.align||"left",t.boundsAlignH=t.boundsAlignH||"left",t.boundsAlignV=t.boundsAlignV||"top",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.maxLines=t.maxLines||0,t.shadowOffsetX=t.shadowOffsetX||0,t.shadowOffsetY=t.shadowOffsetY||0,t.shadowColor=t.shadowColor||"rgba(0,0,0,0)",t.shadowBlur=t.shadowBlur||0,t.tabs=t.tabs||0;const i=this.fontToComponents(t.font);return t.fontStyle&&(i.fontStyle=t.fontStyle),t.fontVariant&&(i.fontVariant=t.fontVariant),t.fontWeight&&(i.fontWeight=t.fontWeight),t.fontSize&&("number"==typeof t.fontSize&&(t.fontSize+="px"),i.fontSize=t.fontSize),this._fontComponents=i,t.font=this.componentsToFont(this._fontComponents),this.style=t,this.dirty=!0,e&&this.updateText(),this}updateText(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;let t=this.text;this.style.wordWrap&&(t=this.runWordWrap(this.text));const e=t.split(/(?:\r\n|\r|\n)/),i=this.style.tabs,s=[];let n=0,h=0;const r=this.determineFontProperties(this.style.font);let o=e.length;this.style.maxLines>0&&this.style.maxLines<e.length&&(o=this.style.maxLines),this._charCount=0;for(let t=0;t<o;t+=1){if(0===i)n=this.style.strokeThickness+this.padding.x,this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?n+=this.measureLine(e[t]):n+=this.context.measureText(e[t]).width,this.style.wordWrap&&(n-=this.context.measureText(" ").width);else{const s=e[t].split(/(?:\t)/);if(n=this.padding.x+this.style.strokeThickness,Array.isArray(i)){let t=0;for(let e=0;e<s.length;e+=1){let h=0;h=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(s[e]):Math.ceil(this.context.measureText(s[e]).width),e>0&&(t+=i[e-1]),n=t+h}}else for(let t=0;t<s.length;t+=1)this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?n+=this.measureLine(s[t]):n+=Math.ceil(this.context.measureText(s[t]).width),n+=Yt(n,i)-n}s[t]=Math.ceil(n),h=Math.max(h,s[t])}this.canvas.width=h*this._res;const a=r.fontSize+this.style.strokeThickness+this.padding.y;let l,d,u=a*o,c=this._lineSpacing;c<0&&Math.abs(c)>a&&(c=-a),0!==c&&(u+=c>0?c*e.length:c*(e.length-1)),this.canvas.height=u*this._res,this.context.scale(this._res,this._res),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round",this._charCount=0;for(let t=0;t<o;t+=1)l=this.style.strokeThickness/2,d=this.style.strokeThickness/2+t*a+r.ascent,t>0&&(d+=c*t),"right"===this.style.align?l+=h-s[t]:"center"===this.style.align&&(l+=(h-s[t])/2),this.autoRound&&(l=Math.round(l),d=Math.round(d)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[t],l,d):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[t],l,d):this.renderTabLine(e[t],l,d,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[t],l,d):this.renderTabLine(e[t],l,d,!0)));this.updateTexture(),this.dirty=!1}renderTabLine(t,e,i,s){const n=t.split(/(?:\t)/),h=this.style.tabs;let r=0;if(Array.isArray(h)){let t=0;for(let o=0;o<n.length;o+=1)o>0&&(t+=h[o-1]),r=e+t,s?this.context.fillText(n[o],r,i):this.context.strokeText(n[o],r,i)}else for(let t=0;t<n.length;t+=1){const o=Math.ceil(this.context.measureText(n[t]).width);r=Yt(e,h),s?this.context.fillText(n[t],r,i):this.context.strokeText(n[t],r,i),e=r+o}}updateShadow(t){t?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)}measureLine(t){let e=0;for(let i=0;i<t.length;i+=1){const s=t[i];if(this.fontWeights.length>0||this.fontStyles.length>0){const t=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(t.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(t.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(t)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),e+=this.context.measureText(s).width,this._charCount+=1}return Math.ceil(e)}updateLine(t,e,i){for(let s=0;s<t.length;s+=1){const n=t[s];if(this.fontWeights.length>0||this.fontStyles.length>0){const t=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(t.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(t.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(t)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount+=1}}clearColors(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this}clearFontValues(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this}addColor(t,e){return this.colors[e]=t,this.dirty=!0,this}addStrokeColor(t,e){return this.strokeColors[e]=t,this.dirty=!0,this}addFontStyle(t,e){return this.fontStyles[e]=t,this.dirty=!0,this}addFontWeight(t,e){return this.fontWeights[e]=t,this.dirty=!0,this}precalculateWordWrap(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)}runWordWrap(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)}advancedWordWrap(t){const e=this.context,i=this.style.wordWrapWidth;let s="";const n=t.replace(/ +/gi," ").split(/\r?\n/gi);let h=n.length;for(let t=0;t<h;t+=1){let r=n[t],o="";if(r=r.replace(/^ *|\s*$/gi,""),e.measureText(r).width<i)s+=r+"\n";else{let a=i;const l=r.split(" ");for(let i=0;i<l.length;i+=1){const s=l[i],r=s+" ";let d=e.measureText(r).width;if(d>a){if(0===i){let t=r;for(;t.length&&(t=t.slice(0,-1),d=e.measureText(t).width,!(d<=a)););if(!t.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");const n=s.substr(t.length);l[i]=n,o+=t}const u=l[i].length?i:i+1,c=l.slice(u).join(" ").replace(/[ \n]*$/gi,"");n[t+1]=c+" "+(n[t+1]||""),h=n.length;break}o+=r,a-=d}s+=o.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,""),s}basicWordWrap(t){let e="";const i=t.split("\n");for(let t=0;t<i.length;t+=1){let s=this.style.wordWrapWidth;const n=i[t].split(" ");for(let t=0;t<n.length;t+=1){const i=this.context.measureText(n[t]).width,h=i+this.context.measureText(" ").width;h>s?(t>0&&(e+="\n"),e+=n[t]+" ",s=this.style.wordWrapWidth-i):(s-=h,e+=n[t]+" ")}t<i.length-1&&(e+="\n")}return e}updateFont(t){const e=this.componentsToFont(t);this.style.font!==e&&(this.style.font=e,this.dirty=!0,this.parent&&this.updateTransform())}fontToComponents(t){const e=t.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(e){let i=e[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:t,fontStyle:e[1]||"normal",fontVariant:e[2]||"normal",fontWeight:e[3]||"normal",fontSize:e[4]||"medium",fontFamily:i}}return console.warn("[Text] Error parsing CSS font: "+t),{font:t}}componentsToFont(t){const e=[];let i;return i=t.fontStyle,i&&"normal"!==i&&e.push(i),i=t.fontVariant,i&&"normal"!==i&&e.push(i),i=t.fontWeight,i&&"normal"!==i&&e.push(i),i=t.fontSize,i&&"medium"!==i&&e.push(i),i=t.fontFamily,i&&e.push(i),e.length||e.push(t.font),e.join(" ")}setText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.text=t.toString()||"",e?this.updateText():this.dirty=!0,this}parseList(t){if(!Array.isArray(t))return this;let e="";for(let i=0;i<t.length;i+=1)Array.isArray(t[i])?(e+=t[i].join("\t"),i<t.length-1&&(e+="\n")):(e+=t[i],i<t.length-1&&(e+="\t"));return this.text=e,this.dirty=!0,this}setTextBounds(t,e,i,s){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,e,i,s):this.textBounds=new ei(t,e,i,s),this.style.wordWrapWidth>i&&(this.style.wordWrapWidth=i)),this.updateTexture(),this}updateTexture(){const t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){let t=this.textBounds.x,e=this.textBounds.y;"right"===this.style.boundsAlignH?t+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(t+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?e+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(e+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-t,this.pivot.y=-e}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()}renderWebGL(t){this.dirty&&(this.updateText(),this.dirty=!1),mi(this,t)}renderCanvas(t){this.dirty&&(this.updateText(),this.dirty=!1),fi(this,t)}getFontPropertiesCache(){return window.PhaserRegistry.fontPropertiesCache||(window.PhaserRegistry.fontPropertiesCache={}),window.PhaserRegistry.fontPropertiesCache}getFontPropertiesCanvas(){return window.PhaserRegistry.fontPropertiesCanvas||(window.PhaserRegistry.fontPropertiesCanvas=document.createElement("canvas")),window.PhaserRegistry.fontPropertiesCanvas}getFontPropertiesContext(){return window.PhaserRegistry.fontPropertiesContext||(window.PhaserRegistry.fontPropertiesContext=this.getFontPropertiesCanvas().getContext("2d")),window.PhaserRegistry.fontPropertiesContext}determineFontProperties(t){const e=this.getFontPropertiesCache();let i=e[t];if(!i){i={};const s=this.getFontPropertiesCanvas(),n=this.getFontPropertiesContext();n.font=t;const h=Math.ceil(n.measureText("|MÉq").width);let r=Math.ceil(n.measureText("|MÉq").width);const o=2*r;if(r=1.4*r|0,s.width=h,s.height=o,n.fillStyle="#f00",n.fillRect(0,0,h,o),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText("|MÉq",0,r),!n.getImageData(0,0,h,o))return i.ascent=r,i.descent=r+6,i.fontSize=i.ascent+i.descent,e[t]=i,i;const a=n.getImageData(0,0,h,o).data,l=a.length,d=4*h;let u,c,p=0,g=!1;for(u=0;u<r;u+=1){for(c=0;c<d;c+=4)if(255!==a[p+c]){g=!0;break}if(g)break;p+=d}for(i.ascent=r-u,p=l-d,g=!1,u=o;u>r;u-=1){for(c=0;c<d;c+=4)if(255!==a[p+c]){g=!0;break}if(g)break;p-=d}i.descent=u-r,i.descent+=6,i.fontSize=i.ascent+i.descent,e[t]=i}return i}getBounds(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.dirty&&(this.updateText(),this.dirty=!1),gi(this,t)}get text(){return this._text}set text(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}get cssFont(){return this.componentsToFont(this._fontComponents)}set cssFont(t){this._fontComponents=this.fontToComponents(t||"bold 20pt Arial"),this.updateFont(this._fontComponents)}get font(){return this._fontComponents.fontFamily}set font(t){let e=t||"Arial";e=e.trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(e)||/['",]/.exec(e)||(e="'"+e+"'"),this._fontComponents.fontFamily=e,this.updateFont(this._fontComponents)}get fontSize(){const t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t}set fontSize(t){let e=t||"0";"number"==typeof e&&(e+="px"),this._fontComponents.fontSize=e,this.updateFont(this._fontComponents)}get fontWeight(){return this._fontComponents.fontWeight||"normal"}set fontWeight(t){this._fontComponents.fontWeight=t||"normal",this.updateFont(this._fontComponents)}get fontStyle(){return this._fontComponents.fontStyle||"normal"}set fontStyle(t){this._fontComponents.fontStyle=t||"normal",this.updateFont(this._fontComponents)}get fontVariant(){return this._fontComponents.fontVariant||"normal"}set fontVariant(t){this._fontComponents.fontVariant=t||"normal",this.updateFont(this._fontComponents)}get fill(){return this.style.fill}set fill(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}get align(){return this.style.align}set align(t){t!==this.style.align&&(this.style.align=t,this.dirty=!0)}get resolution(){return this._res}set resolution(t){t!==this._res&&(this._res=t,this.dirty=!0)}get tabs(){return this.style.tabs}set tabs(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}get boundsAlignH(){return this.style.boundsAlignH}set boundsAlignH(t){t!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}get boundsAlignV(){return this.style.boundsAlignV}set boundsAlignV(t){t!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}get stroke(){return this.style.stroke}set stroke(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}get strokeThickness(){return this.style.strokeThickness}set strokeThickness(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=t,this.dirty=!0)}get wordWrap(){return this.style.wordWrap}set wordWrap(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}get wordWrapWidth(){return this.style.wordWrapWidth}set wordWrapWidth(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}get lineSpacing(){return this._lineSpacing}set lineSpacing(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}get shadowOffsetX(){return this.style.shadowOffsetX}set shadowOffsetX(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}get shadowOffsetY(){return this.style.shadowOffsetY}set shadowOffsetY(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}get shadowColor(){return this.style.shadowColor}set shadowColor(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}get shadowBlur(){return this.style.shadowBlur}set shadowBlur(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}get shadowStroke(){return this.style.shadowStroke}set shadowStroke(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}get shadowFill(){return this.style.shadowFill}set shadowFill(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}get width(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width}set width(t){this.scale.x=t/this.texture.frame.width,this._width=t}get height(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height}set height(t){this.scale.y=t/this.texture.frame.height,this._height=t}};class Bi{get x(){return window&&"pageXOffset"in window?window.pageXOffset:document.documentElement.scrollLeft}get y(){return window&&"pageYOffset"in window?window.pageYOffset:document.documentElement.scrollTop}get width(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get height(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}}class Ni{get x(){return 0}get y(){return 0}get width(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get height(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}}class Gi{get x(){return window&&"pageXOffset"in window?window.pageXOffset:document.documentElement.scrollLeft}get y(){return window&&"pageYOffset"in window?window.pageYOffset:document.documentElement.scrollTop}get width(){return window.innerWidth}get height(){return window.innerHeight}}class Wi{get x(){return 0}get y(){return 0}get width(){const t=document.documentElement.clientWidth,e=window.innerWidth;return t<e?e:t}get height(){const t=document.documentElement.clientHeight,e=window.innerHeight;return t<e?e:t}}class Hi{get x(){return 0}get y(){return 0}get width(){const t=document.documentElement;return Math.max(t.clientWidth,t.offsetWidth,t.scrollWidth)}get height(){const t=document.documentElement;return Math.max(t.clientHeight,t.offsetHeight,t.scrollHeight)}}const zi=class{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;n||(n=t.sound.connectToMaster),this.game=t,this.name=e,this.key=e,this.loop=s,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._markedToDelete=!1,this._removeFromSoundManager=!1,this.game.sound.noAudio||(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=i*this.game.sound.volume,n&&this.gainNode.connect(this.masterGainNode)),this.onPlay=new Ze,this.onPause=new Ze,this.onResume=new Ze,this.onLoop=new Ze,this.onStop=new Ze,this.onMute=new Ze,this.onMarkerComplete=new Ze,this.onFadeComplete=new Ze,this._volume=i,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1}soundHasUnlocked(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)}addMarker(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}}removeMarker(t){delete this.markers[t]}onEndedHandler(){this._sound.onended=null,this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this._markedToDelete&&(this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))}update(){this.game.cache.checkSoundKey(this.key)?(this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.game.sound.noAudio?this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop()))):this.destroy()}loopFull(t){return this.play(null,0,t,!0)}play(t,e,i,s,n){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.game.sound.noAudio||(void 0===this._sound.stop?this._sound.noteOff(0):this._sound.stop(0),this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Sound.play: audio marker "+t+" does not exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.game.sound.noAudio?this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4===this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0:this.game.cache.isSoundDecoded(this.key)?(this._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===t?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)),this}restart(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.play(t,e,i,s,!0)}pause(){this.isPlaying&&this._sound&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())}resume(){if(this.paused&&this._sound){if(!this.game.sound.noAudio){const t=Math.max(0,this.position+this.pausedPosition/1e3);this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));const e=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,t,e):this.loop&&this.game.device.chrome?this._sound.start(0,t):this._sound.start(0,t,e)}this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}}stop(){if(this.isPlaying&&this._sound&&(this.game.sound.noAudio||(void 0===this._sound.stop?this._sound.noteOff(0):this._sound.stop(0),this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode))),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){const t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}}fadeIn(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.currentMarker;this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))}fadeOut(t){this.fadeTo(t,0)}fadeTo(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.isPlaying&&!this.paused&&e!==this.volume&&(this.fadeTween=this.game.tweens.create(this).to({volume:e},t,"Linear",!0),this.fadeTween.onComplete.add(this.fadeComplete,this))}fadeComplete(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()}destroy(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())}get mute(){return this._muted||this.game.sound.mute}set mute(t){(t=t||!1)!==this._muted&&(t?(this._muted=!0,this._muteVolume=this._tempVolume,this.game.sound.noAudio||(this.gainNode.gain.value=0)):(this._muted=!1,this.game.sound.noAudio||(this.gainNode.gain.value=this._muteVolume)),this.onMute.dispatch(this))}get volume(){return this._volume}set volume(t){this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.game.sound.noAudio||(this.gainNode.gain.value=t))}},Xi=class{constructor(){this.game=null,this.key=""}init(){}preload(){}create(){}update(){}resize(){}pauseUpdate(){}shutdown(){}},ji=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.game=t,this.running=!1,this.autoDestroy=e,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new Ze,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0}create(t,e,i,s,n,h){const r=Math.round(t);let o=r;0===this._now?o+=this.game.time.time:o+=this._now;const a=new class{constructor(t,e,i,s,n,h,r,o){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=h,this.callbackContext=r,this.args=o,this.pendingDelete=!1}}(this,r,o,i,e,s,n,h);return this.events.push(a),this.order(),this.expired=!1,a}add(t,e,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this.create(t,!1,0,e,i,n)}repeat(t,e,i,s){for(var n=arguments.length,h=new Array(n>4?n-4:0),r=4;r<n;r++)h[r-4]=arguments[r];return this.create(t,!1,e,i,s,h)}loop(t,e,i){for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];return this.create(t,!0,0,e,i,n)}start(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(let t=0;t<this.events.length;t+=1)this.events[t].tick=this.events[t].delay+this._started}}stop(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.running=!1,t&&(this.events.length=0)}remove(t){for(let e=0;e<this.events.length;e+=1)if(this.events[e]===t)return this.events[e].pendingDelete=!0,!0;return!1}order(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)}sortHandler(t,e){return t.tick<e.tick?-1:t.tick>e.tick?1:0}clearPendingEvents(){for(this._i=this.events.length;this._i;)this._i-=1,this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0}update(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running&&this._now>=this.events[this._i].tick&&!this.events[this._i].pendingDelete;)this._newTick=this._now+this.events[this._i].delay-(this._now-this.events[this._i].tick),this._newTick<0&&(this._newTick=this._now+this.events[this._i].delay),!0===this.events[this._i].loop?(this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):this.events[this._i].repeatCount>0?(this.events[this._i].repeatCount-=1,this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):(this._marked+=1,this.events[this._i].pendingDelete=!0,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)),this._i+=1;this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy}pause(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))}_pause(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)}adjustEvents(t){for(let e=0;e<this.events.length;e+=1)if(!this.events[e].pendingDelete){let i=this.events[e].tick-t;i<0&&(i=0),this.events[e].tick=this._now+i}const e=this.nextTick-t;this.nextTick=e<0?this._now:this._now+e}resume(){if(!this.paused)return;const t=this.game.time.time;this._pauseTotal+=t-this._now,this._now=t,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}_resume(){this._codePaused||this.resume()}removeAll(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0}destroy(){this.onComplete.removeAll(),this.running=!1,this.events=[],this._len=0,this._i=0}get next(){return this.nextTick}get duration(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}get length(){return this.events.length}get ms(){return this.running?this._now-this._started-this._pauseTotal:0}get seconds(){return this.running?.001*this.ms:0}},Yi=class{constructor(t){this.parent=t,this.game=t.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction="Linear",this.interpolationFunction=Qt,this.interpolationContext=s,this.isRunning=!1,this.isFrom=!1}to(t,e,i,s,n,h){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=h,this.isFrom=!1,this}from(t,e,i,s,n,h){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=h,this.isFrom=!0,this}start(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vEndCache[i],this.vEnd[i]=this.vStartCache[i],this.parent.target[i]=this.vStart[i]}}return this.value=0,this.yoyoCounter=0,this.repeatCounter=this.repeatTotal,this}loadValues(){const t=Object.keys(this.parent.properties);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.parent.properties[i],Array.isArray(this.vEnd[i])&&(0===this.vEnd[i].length||0===this.percent&&(this.vEnd[i]=[this.vStart[i]].concat(this.vEnd[i]))),void 0!==this.vEnd[i]?("string"==typeof this.vEnd[i]&&(this.vEnd[i]=this.vStart[i]+parseFloat(this.vEnd[i],10)),this.parent.properties[i]=this.vEnd[i]):this.vEnd[i]=this.vStart[i],this.vStartCache[i]=this.vStart[i],this.vEndCache[i]=this.vEnd[i]}return this}update(t){if(this.isRunning){if(t<this.startTime)return D}else{if(!(t>=this.startTime))return k;this.isRunning=!0}const e=this.game.time.elapsedMS;this.parent.reverse?(this.dt-=e*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=e*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);const i=Object.keys(this.vEnd);for(let t=0;t<i.length;t+=1){const e=i[t],s=this.vStart[e],n=this.vEnd[e];Array.isArray(n)?this.parent.target[e]=this.interpolationFunction.call(this.interpolationContext,n,this.value):this.parent.target[e]=s+(n-s)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():D}generateData(t){this.parent.reverse?this.dt=this.duration:this.dt=0;let e=[],i=!1;const s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);const t={},n=Object.keys(this.vEnd);for(let e=0;e<n.length;e+=1){const i=n[e],s=this.vStart[i],h=this.vEnd[i];Array.isArray(h)?t[i]=this.interpolationFunction(h,this.value):t[i]=s+(h-s)*this.value}e.push(t),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){const t=e.slice();t.reverse(),e=e.concat(t)}return e}repeat(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vStartCache[i],this.vEnd[i]=this.vEndCache[i]}return this.inReverse=!1,O}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return O;if(this.inReverse){const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vEndCache[i],this.vEnd[i]=this.vStartCache[i]}}else{const t=Object.keys(this.vStartCache);for(let e=0;e<t.length;e+=1){const i=t[e];this.vStart[i]=this.vStartCache[i],this.vEnd[i]=this.vEndCache[i]}this.repeatCounter>0&&(this.repeatCounter-=1)}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,L}};function Vi(t){return t}function qi(t){return t*t}function Ki(t){return t*(2-t)}function Qi(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}function $i(t){return t*t*t}function Zi(t){return--t*t*t+1}function Ji(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}function ts(t){return t*t*t*t}function es(t){return 1- --t*t*t*t}function is(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}function ss(t){return t*t*t*t*t}function ns(t){return--t*t*t*t*t+1}function hs(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}function rs(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}function os(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}function as(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}function ls(t){return 0===t?0:Math.pow(1024,t-1)}function ds(t){return 1===t?1:1-Math.pow(2,-10*t)}function us(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}function cs(t){return 1-Math.sqrt(1-t*t)}function ps(t){return Math.sqrt(1- --t*t)}function gs(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}function ms(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))}function fs(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)}function _s(t){let e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)}function vs(t){const e=1.70158;return t*t*((e+1)*t-e)}function xs(t){const e=1.70158;return--t*t*((e+1)*t+e)+1}function ys(t){const e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}function ws(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function bs(t){return 1-ws(1-t)}function Ss(t){return t<.5?.5*bs(2*t):.5*ws(2*t-1)+.5}const Ts=class extends Fi{constructor(t){super(t,null,"__world",!1)}boot(){this.game.stage.addChild(this)}},Cs=class extends _i{constructor(t){super(),this.game=t,this.name="_stage_root",this.worldTransform=new pi,this.currentRenderOrderID=0,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},t.config.transparent||(this._bgColor.a=1),t.config.backgroundColor&&!this.game.config.transparent&&this.setBackgroundColor(t.config.backgroundColor)}setBackgroundColor(t){this.game.config.transparent||(ne(t,this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)}boot(){var t,e;e=(e="none")||"none",(t=this.game.canvas).style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",Lt(this.game.canvas,"none")}preUpdate(){this.currentRenderOrderID=0;for(let t=0;t<this.children.length;t+=1)this.children[t].preUpdate()}update(){let t=this.children.length;for(;t;)t-=1,this.children[t].update()}postUpdate(){for(let t=0;t<this.children.length;t+=1)this.children[t].postUpdate();this.updateTransform()}updateTransform(){this.worldAlpha=1;for(let t=0;t<this.children.length;t+=1)this.children[t].updateTransform()}destroy(){this.exists=!1,this.game=null,this.worldTransform=null,this._bgColor=null}get backgroundColor(){return this._bgColor.color}set backgroundColor(t){this.setBackgroundColor(t)}get smoothed(){return window.PhaserRegistry.TEXTURE_SCALE_MODE===x}set smoothed(t){window.PhaserRegistry.TEXTURE_SCALE_MODE=t?x:y}},Ms=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};window.PhaserRegistry||(window.PhaserRegistry={}),this.config={},this.id=0,this.parent="",this.width=800,this.height=600,this.renderer=null,this.state=null,this.isBooted=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.device=new class{constructor(){this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.chrome=!1,this.firefox=!1,this.edge=!1,this.safari=!1,this.silk=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.iPhone=!1,this.iPad=!1,this.pixelRatio=1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1}},this.canvas=null,this.context=null,this.onPause=new Ze,this.onResume=new Ze,this.onBoot=new Ze,this.isPaused=!1,this.parseConfig(t),si(this.device),"complete"===document.readyState?(ni(this.device),this.boot()):window.addEventListener("load",(()=>{ni(this.device),this.boot()}),!1)}boot(){this.isBooted||(this.isBooted=!0,this.scale=new class{constructor(t,e,i){this.game=t,this.dom=new class{constructor(t){this.treatAsDesktop=t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight,this.visualBounds=this.treatAsDesktop?new Bi:new Gi,this.layoutBounds=this.treatAsDesktop?new Ni:new Wi,this.documentBounds=new Hi,this.scrollXProvider=window&&"pageXOffset"in window?()=>window.pageXOffset:()=>document.documentElement.scrollLeft,this.scrollYProvider=window&&"pageYOffset"in window?()=>window.pageYOffset:()=>document.documentElement.scrollTop}getOffset(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=e||new ce;const i=t.getBoundingClientRect(),s=this.scrollY,n=this.scrollX,h=document.documentElement.clientTop,r=document.documentElement.clientLeft;return e.x=i.left+n-r,e.y=i.top+s-h,e}getBounds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!(t=t&&!t.nodeType?t[0]:t)||1!==t.nodeType)&&this.calibrate(t.getBoundingClientRect(),e)}calibrate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=t.right+e)-(i.left=t.left-e),i.height=(i.bottom=t.bottom+e)-(i.top=t.top-e),i}getScreenOrientation(t){const e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;const s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n}get scrollX(){return this.scrollXProvider()}get scrollY(){return this.scrollYProvider()}get clientWidth(){return Math.max(window.innerWidth,document.documentElement.clientWidth)}get clientHeight(){return Math.max(window.innerHeight,document.documentElement.clientHeight)}}(t.device),this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new ce,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new Ze,this.enterIncorrectOrientation=new Ze,this.leaveIncorrectOrientation=new Ze,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new Ze,this.onFullScreenChange=new Ze,this.onFullScreenError=new Ze,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new ce(1,1),this.scaleFactorInversed=new ce(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new ei,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=b,this._fullScreenScaleMode=b,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new ce(1,1),this.trackParentInterval=2e3,this.onSizeChange=new Ze,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new ei,this._userScaleFactor=new ce(1,1),this._userScaleTrim=new ce(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new ei,this._tempBounds=new ei,this._lastReportedCanvasSize=new ei,this._lastReportedGameSize=new ei,this._booted=!1,t.config&&this.parseConfig(t.config),this.setupScale(e,i)}boot(){const t=this.compatibility;t.supportsFullScreen=this.game.device.fullscreen,this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");const e=this;this._orientationChange=t=>e.orientationChange(t),this._windowResize=t=>e.windowResize(t),window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=t=>e.fullScreenChange(t),this._fullScreenError=t=>e.fullScreenError(t),document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)}parseConfig(t){void 0!==t.scaleMode&&(this._booted?this.scaleMode=t.scaleMode:this._pendingScaleMode=t.scaleMode),void 0!==t.fullScreenScaleMode&&(this.fullScreenScaleMode=t.fullScreenScaleMode),t.fullScreenTarget?this.fullScreenTarget=t.fullScreenTarget:this.fullScreenTarget=document.documentElement}setupScale(t,e){let i;const s=new ei;""!==this.game.parent&&("string"==typeof this.game.parent?i=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(i=this.game.parent)),i?(this.parentNode=i,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds),s.width=this._parentBounds.width,s.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,s.width=this.dom.visualBounds.width,s.height=this.dom.visualBounds.height,this.offset.set(0,0));let n=0,h=0;"number"==typeof t?n=t:(this.parentScaleFactor.x=parseInt(t,10)/100,n=s.width*this.parentScaleFactor.x),"number"==typeof e?h=e:(this.parentScaleFactor.y=parseInt(e,10)/100,h=s.height*this.parentScaleFactor.y),n=Math.floor(n),h=Math.floor(h),this._gameSize.setTo(0,0,n,h),this.updateDimensions(n,h,!1)}_gameResumed(){this.queueUpdate(!0)}setGameSize(t,e){this._gameSize.setTo(0,0,t,e),this.currentScaleMode!==T&&this.updateDimensions(t,e,!0),this.queueUpdate(!0)}setUserScale(t,e,i,s){this._userScaleFactor.setTo(t,e),this._userScaleTrim.setTo(0|i,0|s),this.queueUpdate(!0)}setResizeCallback(t,e){this.onResize=t,this.onResizeContext=e}signalSizeChange(){if(this.width!==this._lastReportedCanvasSize.width||this.height!==this._lastReportedCanvasSize.height||this.game.width!==this._lastReportedGameSize.width||this.game.height!==this._lastReportedGameSize.height){const t=this.width,e=this.height;this._lastReportedCanvasSize.setTo(0,0,t,e),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.onSizeChange.dispatch(this,t,e),this.currentScaleMode===T&&(this.game.state.resize(t,e),this.game.load.resize(t,e))}}setMinMax(t,e,i,s){this.minWidth=t,this.minHeight=e,void 0!==i&&(this.maxWidth=i),void 0!==s&&(this.maxHeight=s)}preUpdate(){if(this.game.time.time<this._lastUpdate+this._updateThrottle)return;const t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);const e=this._parentBounds.width,i=this._parentBounds.height,s=this.getParentBounds(this._parentBounds),n=s.width!==e||s.height!==i,h=this.updateOrientationState();(n||h)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,s),this.updateLayout(),this.signalSizeChange());let r=2*this._updateThrottle;this._updateThrottle<t&&(r=Math.min(t,this._updateThrottleReset)),this._updateThrottle=Math.max(25,Math.min(this.trackParentInterval,r)),this._lastUpdate=this.game.time.time}pauseUpdate(){this.preUpdate(),this._updateThrottle=this.trackParentInterval}updateDimensions(t,e,i){this.width=t*this.parentScaleFactor.x,this.height=e*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),i&&this.game.renderer.resize(this.width,this.height)}updateScalingAndBounds(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)}forceOrientation(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.forceLandscape=t,this.forcePortrait=e,this.queueUpdate(!0)}classifyOrientation(t){return"portrait-primary"===t||"portrait-secondary"===t?"portrait":"landscape-primary"===t||"landscape-secondary"===t?"landscape":null}updateOrientationState(){const t=this.screenOrientation,e=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;const i=t!==this.screenOrientation,s=e!==this.incorrectOrientation;return s&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(i||s)&&this.onOrientationChange.dispatch(this,t,e),i||s}orientationChange(t){this.event=t,this.queueUpdate(!0)}windowResize(t){this.event=t,this.queueUpdate(!0)}refresh(){this.queueUpdate(!0)}updateLayout(){const t=this.currentScaleMode;if(t!==T){if(this.incorrectOrientation?this.setMaximum():t===w?this.setExactFit():t===S?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===b?(this.width=this.game.width,this.height=this.game.height):t===C&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(t===S||t===C)){const t=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,t.width),this.height=Math.min(this.height,t.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()}else this.reflowGame()}getParentBounds(t){const e=t||new ei,i=this.boundingParent,s=this.dom.visualBounds,n=this.dom.layoutBounds;if(i){const t=i.getBoundingClientRect(),h=i.offsetParent?i.offsetParent.getBoundingClientRect():i.getBoundingClientRect();e.setTo(t.left-h.left,t.top-h.top,t.width,t.height);const r=this.windowConstraints;if(r.right){const t="layout"===r.right?n:s;e.right=Math.min(e.right,t.width)}if(r.bottom){const t="layout"===r.bottom?n:s;e.bottom=Math.min(e.bottom,t.height)}}else e.setTo(0,0,s.width,s.height);return e.setTo(Math.round(e.x),Math.round(e.y),Math.round(e.width),Math.round(e.height)),e}alignCanvas(t,e){const i=this.getParentBounds(this._tempBounds),s=this.game.canvas,n=this.margin;if(t){n.left=0,n.right=0;const t=s.getBoundingClientRect();if(this.width<i.width&&!this.incorrectOrientation){const e=t.left-i.x;let s=i.width/2-this.width/2;s=Math.max(s,0);const h=s-e;n.left=Math.round(h)}s.style.marginLeft=n.left+"px",0!==n.left&&(n.right=-(i.width-t.width-n.left),s.style.marginRight=n.right+"px")}if(e){n.top=0,n.bottom=0;const t=s.getBoundingClientRect();if(this.height<i.height&&!this.incorrectOrientation){const e=t.top-i.y;let s=i.height/2-this.height/2;s=Math.max(s,0);const h=s-e;n.top=Math.round(h)}s.style.marginTop=n.top+"px",0!==n.top&&(n.bottom=-(i.height-t.height-n.top),s.style.marginBottom=n.bottom+"px")}n.x=n.left,n.y=n.top}reflowGame(){this.resetCanvas("","");const t=this.getParentBounds(this._tempBounds);this.updateDimensions(t.width,t.height,!0)}reflowCanvas(){this.incorrectOrientation||(this.width=Math.max(this.minWidth||0,Math.min(this.maxWidth||this.width,this.width)),this.height=Math.max(this.minHeight||0,Math.min(this.maxHeight||this.height,this.height))),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()}resetCanvas(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.width+"px",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.height+"px";const i=this.game.canvas;this.compatibility.noMargins||(i.style.marginLeft="",i.style.marginTop="",i.style.marginRight="",i.style.marginBottom=""),i.style.width=t,i.style.height=e}queueUpdate(t){t&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset}reset(){}setMaximum(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height}setShowAll(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getParentBounds(this._tempBounds),i=e.width,s=e.height;let n;n=t?Math.max(s/this.game.height,i/this.game.width):Math.min(s/this.game.height,i/this.game.width),this.width=Math.round(this.game.width*n),this.height=Math.round(this.game.height*n)}setExactFit(){const t=this.getParentBounds(this._tempBounds);this.width=t.width,this.height=t.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))}createFullScreenTarget(){const t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t.style.background="#000",t}startFullScreen(t,e){if(this.isFullScreen)return!1;if(!this.compatibility.supportsFullScreen){const t=this;return setTimeout((()=>{t.fullScreenError()}),10),!1}if("when-not-mouse"===this.compatibility.clickTrampoline){const i=this.game.input;if(i.activePointer&&i.activePointer!==i.mousePointer&&(e||!1!==e))return i.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1]),!1}void 0!==t&&this.game.renderer.type===Z&&(this.game.stage.smoothed=t);let i=this.fullScreenTarget;if(i||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),i=this._createdFullScreenTarget),this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,{targetElement:i}),this._createdFullScreenTarget){const t=this.game.canvas;t.parentNode.insertBefore(i,t),i.appendChild(t)}return this.game.device.fullscreenKeyboard?i[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):i[this.game.device.requestFullscreen](),!0}stopFullScreen(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen||(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),0))}cleanupCreatedTarget(){const t=this._createdFullScreenTarget;if(t&&t.parentNode){const e=t.parentNode;e.insertBefore(this.game.canvas,t),e.removeChild(t)}this._createdFullScreenTarget=null}prepScreenMode(t){const e=this._createdFullScreenTarget||this.fullScreenTarget;e&&(t?(this._createdFullScreenTarget||this.fullScreenScaleMode===w)&&e!==this.game.canvas&&(this._fullScreenRestore={targetWidth:e.style.width,targetHeight:e.style.height},e.style.width="100%",e.style.height="100%"):(this._fullScreenRestore&&(e.style.width=this._fullScreenRestore.targetWidth,e.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas()))}fullScreenChange(t){this.event=t,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)}fullScreenError(t){this.event=t,this.cleanupCreatedTarget(),this.onFullScreenError.dispatch(this)}destroy(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}get boundingParent(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}get scaleMode(){return this._scaleMode}set scaleMode(t){t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t)}get fullScreenScaleMode(){return this._fullScreenScaleMode}set fullScreenScaleMode(t){t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t)}get currentScaleMode(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}get pageAlignHorizontally(){return this._pageAlignHorizontally}get pageAlignVertically(){return this._pageAlignVertically}get isFullScreen(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}get isPortrait(){return"portrait"===this.classifyOrientation(this.screenOrientation)}get isLandscape(){return"landscape"===this.classifyOrientation(this.screenOrientation)}get isGamePortrait(){return this.height>this.width}get isGameLandscape(){return this.width>this.height}}(this,this.config.width,this.config.height),this.stage=new Cs(this),this.initRenderer(),this.world=new Ts(this),this.add=new class{constructor(t){this.game=t}existing(t){return this.game.world.add(t)}image(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return n||(n=this.game.world),n.add(new vi(this.game,t,e,i,s))}group(t,e,i){return new Fi(this.game,t,e,i)}spriteBatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"group",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return new Ii(this.game,t,e,i)}audio(t,e,i,s){return console.warn("[GameObjectFactory] game.add.audio() is deprecated, use game.sound.add() directly."),this.game.sound.add(t,e,i,s)}sound(t,e,i,s){return console.warn("[GameObjectFactory] game.add.sound() is deprecated, use game.sound.add() directly."),this.game.sound.add(t,e,i,s)}text(t,e,i,s){return((arguments.length>4&&void 0!==arguments[4]?arguments[4]:null)||this.game.world).add(new Ui(this.game,t,e,i,s))}button(t,e,i,s,n,h,r,o,a){return((arguments.length>9&&void 0!==arguments[9]?arguments[9]:null)||this.game.world).add(new Ri(this.game,t,e,i,s,n,h,r,o,a))}graphics(t,e){return((arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||this.game.world).add(new Ci(this.game,t,e))}bitmapText(t,e,i,s,n){return((arguments.length>5&&void 0!==arguments[5]?arguments[5]:null)||this.game.world).add(new Pi(this.game,t,e,i,s,n))}tween(t){return console.warn("game.add.tween(target) is deprecated, please use game.tweens.create(target) directly."),this.game.tweens.create(t)}}(this),this.cache=new class{constructor(t){this.game=t,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},text:{},json:{},xml:{},bitmapData:{},bitmapFont:{},renderTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new Ze,this._cacheMap=[],this._cacheMap[0]=this._cache.canvas,this._cacheMap[1]=this._cache.image,this._cacheMap[2]=this._cache.texture,this._cacheMap[3]=this._cache.sound,this._cacheMap[4]=this._cache.text,this._cacheMap[5]=this._cache.bitmapData,this._cacheMap[6]=this._cache.bitmapFont,this._cacheMap[7]=this._cache.json,this._cacheMap[8]=this._cache.xml,this._cacheMap[9]=this._cache.renderTexture,this.addDefaultImage(),this.addMissingImage()}addDefaultImage(){const t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";const e=this.addImage("__default",null,t);e.base.skipRender=!0,window.PhaserRegistry.CACHE_DEFAULT_IMAGE=new ri(e.base)}addMissingImage(){const t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";const e=this.addImage("__missing",null,t);window.PhaserRegistry.CACHE_MISSING_IMAGE=new ri(e.base)}addImage(t,e,i){this.checkImageKey(t)&&this.removeImage(t);const s={key:t,url:e,data:i,base:new oi(i),frame:new li(0,0,0,i.width,i.height,t),frameData:new ai};return s.frameData.addFrame(new li(0,0,0,i.width,i.height,e)),this._cache.image[t]=s,this._resolveURL(e,s),s}addTextureAtlas(t,e,i,s){const n={key:t,url:e,data:i,base:new oi(i)};n.frameData=function(t,e){if(!e.frames)return console.warn("JSONDataHash: Invalid Texture Atlas JSON given, missing frames object",e),null;const i=new ai,s=e.frames;let n,h=0;const r=Object.keys(s);for(let t=0;t<r.length;t+=1){const e=r[t];n=i.addFrame(new li(h,s[e].frame.x,s[e].frame.y,s[e].frame.w,s[e].frame.h,e)),s[e].trimmed&&n.setTrim(s[e].trimmed,s[e].sourceSize.w,s[e].sourceSize.h,s[e].spriteSourceSize.x,s[e].spriteSourceSize.y,s[e].spriteSourceSize.w,s[e].spriteSourceSize.h),h+=1}return i}(this.game,s),this._cache.image[t]=n,this._resolveURL(e,n)}addSound(t,e,i){this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:!1,locked:this.game.sound.isLocked},this._resolveURL(e,this._cache.sound[t])}addText(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])}addBitmapFont(t,e,i,s,n){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;const o={url:e,data:i,font:null,base:new oi(i)};o.font="json"===n?function(t,e,i,s){const n={font:t.font.info._face,size:parseInt(t.font.info._size,10),lineHeight:parseInt(t.font.common._lineHeight,10)+s,chars:{}};return t.font.chars.char.forEach((t=>{const e=parseInt(t._id,10);n.chars[e]={x:parseInt(t._x,10),y:parseInt(t._y,10),width:parseInt(t._width,10),height:parseInt(t._height,10),xOffset:parseInt(t._xoffset,10),yOffset:parseInt(t._yoffset,10),xAdvance:parseInt(t._xadvance,10)+i,kerning:{}}})),t.font.kernings&&t.font.kernings.kerning&&t.font.kernings.kerning.forEach((t=>{n.chars[t._second].kerning[t._first]=parseInt(t._amount,10)})),di(e,n)}(s,o.base,h,r):function(t,e,i,s){const n={},h=t.getElementsByTagName("info")[0],r=t.getElementsByTagName("common")[0];n.font=h.getAttribute("face"),n.size=parseInt(h.getAttribute("size"),10),n.lineHeight=parseInt(r.getAttribute("lineHeight"),10)+s,n.chars={};const o=t.getElementsByTagName("char");for(let t=0;t<o.length;t+=1){const e=parseInt(o[t].getAttribute("id"),10);n.chars[e]={x:parseInt(o[t].getAttribute("x"),10),y:parseInt(o[t].getAttribute("y"),10),width:parseInt(o[t].getAttribute("width"),10),height:parseInt(o[t].getAttribute("height"),10),xOffset:parseInt(o[t].getAttribute("xoffset"),10),yOffset:parseInt(o[t].getAttribute("yoffset"),10),xAdvance:parseInt(o[t].getAttribute("xadvance"),10)+i,kerning:{}}}const a=t.getElementsByTagName("kerning");for(let t=0;t<a.length;t+=1){const e=parseInt(a[t].getAttribute("first"),10),i=parseInt(a[t].getAttribute("second"),10),s=parseInt(a[t].getAttribute("amount"),10);n.chars[i].kerning[e]=s}return di(e,n)}(s,o.base,h,r),this._cache.bitmapFont[t]=o,this._resolveURL(e,o)}addJSON(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])}addXML(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])}reloadSound(t){const e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",(()=>e.reloadSoundComplete(t)),!1),i.data.load())}reloadSoundComplete(t){const e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))}updateSound(t,e,i){const s=this.getSound(t);s&&(s[e]=i)}decodedSound(t,e){const i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1}isSoundDecoded(t){const e=this.getItem(t,3,"isSoundDecoded");return e?e.decoded:null}isSoundReady(t){const e=this.getItem(t,3,"isSoundDecoded");return!!e&&e.decoded&&!this.game.sound.isLocked}checkKey(t,e){return!!this._cacheMap[t][e]}checkURL(t){return!!this._urlMap[this._resolveURL(t)]}checkCanvasKey(t){return this.checkKey(0,t)}checkImageKey(t){return this.checkKey(1,t)}checkTextureKey(t){return this.checkKey(2,t)}checkSoundKey(t){return this.checkKey(3,t)}checkTextKey(t){return this.checkKey(4,t)}checkBitmapDataKey(t){return this.checkKey(5,t)}checkBitmapFontKey(t){return this.checkKey(6,t)}checkJSONKey(t){return this.checkKey(7,t)}checkXMLKey(t){return this.checkKey(8,t)}getItem(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return this.checkKey(e,t)?s?this._cacheMap[e][t][s]:this._cacheMap[e][t]:null}getCanvas(t){return this.getItem(t,0,"getCanvas","canvas")}getImage(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__default",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.getItem(t,1,"getImage");return null===i&&(i=this.getItem("__missing",1,"getImage")),e?i:i.data}getTextureFrame(t){return this.getItem(t,2,"getTextureFrame","frame")}getSound(t){return this.getItem(t,3,"getSound")}getSoundData(t){return this.getItem(t,3,"getSoundData","data")}getText(t){return this.getItem(t,4,"getText","data")}getBitmapData(t){return this.getItem(t,5,"getBitmapData","data")}getBitmapFont(t){return this.getItem(t,6,"getBitmapFont")}getJSON(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.getItem(t,7,"getJSON","data");return e?7..parse(7..stringify(i)):i}getXML(t){return this.getItem(t,8,"getXML","data")}getRenderTexture(t){return this.getItem(t,9,"getRenderTexture")}getBaseTexture(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getBaseTexture","base")}getFrame(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getFrame","frame")}getFrameCount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=this.getFrameData(t,e);return i?i.total:0}getFrameData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getItem(t,e,"getFrameData","frameData")}hasFrameData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return null!==this.getItem(t,e,"","frameData")}updateFrameData(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this._cacheMap[i][t]&&(this._cacheMap[i][t].frameData=e)}getFrameByIndex(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const s=this.getFrameData(t,i);return s?s.getFrame(e):null}getFrameByName(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const s=this.getFrameData(t,i);return s?s.getFrameByName(e):null}getURL(t){const e=this._resolveURL(t);return e?this._urlMap[e]:(console.warn("Cache invalid url",e),null)}getKeys(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const e=[];if(this._cacheMap[t]){const i=Object.keys(this._cacheMap[t]);for(let t=0;t<i.length;t+=1){const s=i[t];"__default"!==s&&"__missing"!==s&&e.push(s)}}return e}removeCanvas(t){delete this._cache.canvas[t]}removeImage(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]}removeSound(t){delete this._cache.sound[t]}removeText(t){delete this._cache.text[t]}removeBitmapData(t){delete this._cache.bitmapData[t]}removeBitmapFont(t){delete this._cache.bitmapFont[t]}removeJSON(t){delete this._cache.json[t]}removeXML(t){delete this._cache.xml[t]}removeRenderTexture(t){delete this._cache.renderTexture[t]}removeSpriteSheet(t){delete this._cache.spriteSheet[t]}removeTextureAtlas(t){delete this._cache.atlas[t]}clearGLTextures(){const t=Object.keys(this._cache.image);for(let e=0;e<t.length;e+=1){const i=t[e];this._cache.image[i].base._glTextures=[]}}_resolveURL(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null}destroy(){for(let t=0;t<this._cacheMap.length;t+=1){const e=this._cacheMap[t],i=e?Object.keys(e):[];for(let t=0;t<i.length;t+=1){const s=i[t];"__default"!==s&&"__missing"!==s&&(e[s].destroy&&e[s].destroy(),delete e[s])}}this._urlMap=null,this._urlResolver=null,this._urlTemp=null}}(this),this.load=new class{constructor(t){this.game=t,this.cache=t.cache,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new Ze,this.onLoadComplete=new Ze,this.onPackComplete=new Ze,this.onFileStart=new Ze,this.onFileComplete=new Ze,this.onFileError=new Ze,this.maxParallelDownloads=this.game.config.maxParallelDownloads||16,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0}setPreloadSprite(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.preloadSprite={sprite:t,direction:e,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===e?new ei(0,0,1,t.height):new ei(0,0,t.width,1),t.crop(this.preloadSprite.rect),t.visible=!0}resize(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)}checkKeyExists(t,e){return this.getAssetIndex(t,e)>-1}getAssetIndex(t,e){let i=-1;for(let s=0;s<this._fileList.length;s+=1){const n=this._fileList[s];if(n.type===t&&n.key===e&&(i=s,!n.loaded&&!n.loading))break}return i}getAsset(t,e){const i=this.getAssetIndex(t,e);return i>-1?{index:i,file:this._fileList[i]}:null}reset(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll())}addToFileList(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;if(void 0===e||""===e)return console.warn("Loader: Invalid or no key given of type "+t),this;if(null==i){if(!h)return console.warn("Loader: No URL given for file type: "+t+" key: "+e),this;i=e+h}const r={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s){const t=Object.keys(s);for(let e=0;e<t.length;e+=1){const i=t[e];r[i]=s[i]}}const o=this.getAssetIndex(t,e);if(n&&o>-1){const t=this._fileList[o];t.loading||t.loaded?(this._fileList.push(r),this._totalFileCount+=1):this._fileList[o]=r}else-1===o&&(this._fileList.push(r),this._totalFileCount+=1);return this}replaceInFileList(t,e,i,s){return this.addToFileList(t,e,i,s,!0)}pack(t,e,i,s){const n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(let t=0;t<this._fileList.length+1;t+=1){const e=this._fileList[t];if(!e||!e.loaded&&!e.loading&&"packfile"!==e.type){this._fileList.splice(t,0,n),this._totalPackCount+=1;break}}return this}image(t,e,i){return this.addToFileList("image",t,e,void 0,i,".png")}images(t,e){if(Array.isArray(e))for(let i=0;i<t.length;i+=1)this.image(t[i],e[i]);else for(let e=0;e<t.length;e+=1)this.image(t[e]);return this}text(t,e,i){return this.addToFileList("text",t,e,void 0,i,".txt")}json(t,e,i){return this.addToFileList("json",t,e,void 0,i,".json")}xml(t,e,i){return this.addToFileList("xml",t,e,void 0,i,".xml")}spritesheet(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;return this.addToFileList("spritesheet",t,e,{frameWidth:i,frameHeight:s,frameMax:n,margin:h,spacing:r},!1,".png")}audio(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.game.sound.noAudio?this:("string"==typeof e&&(e=[e]),this.addToFileList("audio",t,e,{buffer:null,autoDecode:i}))}audioSprite(t,e,i,s){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return this.game.sound.noAudio||(this.audio(t,e,n),i?this.json(t+"-audioatlas",i):s&&("string"==typeof s&&(s=JSON.parse(s)),this.cache.addJSON(t+"-audioatlas","",s))),this}bitmapFont(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(null==e&&(e=t+".png"),null===i&&null===s&&(i=t+".xml"),i)this.addToFileList("bitmapfont",t,e,{atlasURL:i,xSpacing:n,ySpacing:h});else if("string"==typeof s){let i=null,r=null;try{i=JSON.parse(s)}catch(t){r=this.parseXml(s)}if(!r&&!i)throw new Error("Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",t,e,{atlasURL:null,atlasData:i||r,atlasType:i?"json":"xml",xSpacing:n,ySpacing:h})}return this}atlas(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return null==e&&(e=t+".png"),i||s||(i=t+".json"),i?this.addToFileList("textureatlas",t,e,{atlasURL:i,format:n}):this.addToFileList("textureatlas",t,e,{atlasURL:null,atlasData:s,format:n}),this}withSyncPoint(t,e){this._withSyncPointDepth+=1;try{t.call(e||this,this)}finally{this._withSyncPointDepth-=1}return this}addSyncPoint(t,e){const i=this.getAsset(t,e);return i&&(i.file.syncPoint=!0),this}removeFile(t,e){const i=this.getAsset(t,e);i&&(i.loaded||i.loading||this._fileList.splice(i.index,1))}removeAll(){this._fileList.length=0,this._flightQueue.length=0}start(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())}processLoadQueue(){if(!this.isLoading)return console.warn("Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(let t=0;t<this._flightQueue.length;t+=1){const e=this._flightQueue[t];(e.loaded||e.error)&&(this._flightQueue.splice(t,1),t-=1,e.loading=!1,e.requestUrl=null,e.requestObject=null,e.error&&this.onFileError.dispatch(e.key,e),"packfile"!==e.type?(this._loadedFileCount+=1,this.onFileComplete.dispatch(this.progress,e.key,!e.error,this._loadedFileCount,this._totalFileCount)):"packfile"===e.type&&e.error&&(this._loadedPackCount+=1,this.onPackComplete.dispatch(e.key,!e.error,this._loadedPackCount,this._totalPackCount)))}let t=!1;const e=this.maxParallelDownloads;for(let i=this._processingHead;i<this._fileList.length;i+=1){const s=this._fileList[i];if("packfile"===s.type&&!s.error&&s.loaded&&i===this._processingHead&&(this.processPack(s),this._loadedPackCount+=1,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)),s.loaded||s.error?i===this._processingHead&&(this._processingHead=i+1):!s.loading&&this._flightQueue.length<e&&("packfile"!==s.type||s.data?t||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(s),s.loading=!0,this.onFileStart.dispatch(this.progress,s.key,s.url),this.loadFile(s)):(this._flightQueue.push(s),s.loading=!0,this.loadFile(s))),!s.loaded&&s.syncPoint&&(t=!0),this._flightQueue.length>=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Loader - aborting: processing queue empty, loading may have stalled");const t=this;setTimeout((()=>{t.finishedLoading(!0)}),2e3)}}finishedLoading(t){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.reset(),this.onLoadComplete.dispatch(),this.game.state.loadComplete())}asyncComplete(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn(t,e)),this.processLoadQueue()}processPack(t){const e=t.data[t.key];if(!e)return void console.warn("Missing loader pack key",t.key);const i=Array.isArray(e)?e:e.files;for(let t=0;t<i.length;t+=1){const e=i[t];switch(e.type){case"image":this.image(e.key,e.url,e.overwrite);break;case"text":this.text(e.key,e.url,e.overwrite);break;case"json":this.json(e.key,e.url,e.overwrite);break;case"xml":this.xml(e.key,e.url,e.overwrite);break;case"spritesheet":this.spritesheet(e.key,e.url,e.frameWidth,e.frameHeight,e.frameMax,e.margin,e.spacing);break;case"audio":this.audio(e.key,e.urls?e.urls:e.url);break;case"audiosprite":this.audioSprite(e.key,e.urls?e.urls:e.url,e.jsonURL,e.jsonData);break;case"audioSprite":this.audioSprite(e.key,e.audioURL,e.jsonURL,e.jsonData);break;case"bitmapFont":this.bitmapFont(e.key,e.textureURL,e.atlasURL,e.atlasData,e.xSpacing,e.ySpacing);break;case"atlas":this.atlas(e.key,e.textureURL,e.atlasURL,e.atlasData,1)}}}transformUrl(t,e){return!!t&&(t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t:this.baseURL+e.path+t)}loadFile(t){switch(t.type){case"packfile":case"text":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(t);break;case"audio":t.url=this.getAudioURL(t.url),t.url?this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete):this.fileError(t,null,"No supported audio URL specified or device does not have audio playback support");break;case"json":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.xmlLoadComplete)}}loadImageTag(t){const e=this;t.data=new Image,t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=()=>{t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileComplete(t))},t.data.onerror=()=>{t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileError(t))},t.data.src=this.transformUrl(t.url,t)}xhrLoad(t,e,i,s,n){const h=new XMLHttpRequest;h.open("GET",e,!0),h.responseType=i,!1!==this.headers.requestedWith&&h.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&h.setRequestHeader("Accept",this.headers[t.type]),n=n||this.fileError;const r=this;h.onload=()=>{try{return 4===h.readyState&&h.status>=400&&h.status<=599?n.call(r,t,h):s.call(r,t,h)}catch(e){r.hasLoaded?r.game.exceptionHandler(e):r.asyncComplete(t,e.message||"Exception")}return null},h.onerror=()=>{try{return n.call(r,t,h)}catch(e){r.hasLoaded?r.game.exceptionHandler(e):r.asyncComplete(t,e.message||"Exception")}return null},t.requestObject=h,t.requestUrl=e,h.send()}xhrLoadWithXDR(){console.warn("loader.xhrLoadWithXDR() is not implemented")}getAudioURL(t){if(this.game.sound.noAudio)return null;for(let e=0;e<t.length;e+=1){let i=t[e],s=null;if(i.uri){if(s=i.type,i=i.uri,ii(this.game.device,s))return i}else{if(0===i.indexOf("blob:")||0===i.indexOf("data:"))return i;if(i.indexOf("?")>=0&&(i=i.substr(0,i.indexOf("?"))),s=i.substr((Math.max(0,i.lastIndexOf("."))||1/0)+1).toLowerCase(),ii(this.game.device,s))return t[e]}}return null}fileError(t,e,i){let s="Error loading asset";!i&&e&&(i=e.status),(i||0===i)&&(s=s+" ("+i+")"),this.asyncComplete(t,s)}fileComplete(t,e){let i=!0;switch(t.type){case"packfile":t.data=JSON.parse(e.responseText)||{};break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else{if(i=!1,1!==t.format)throw new Error("Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete)}break;case"bitmapfont":t.atlasURL?(i=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",((t,e)=>{let i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))}))):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"audio":t.data=e.response,this.cache.addSound(t.key,t.url,t.data),t.autoDecode&&this.game.sound.decode(t.key);break;case"text":t.data=e.responseText,this.cache.addText(t.key,t.url,t.data)}i&&this.asyncComplete(t)}jsonLoadComplete(t,e){const i=JSON.parse(e.responseText);"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)}csvLoadComplete(){console.warn("loader.csvLoadComplete() is not implemented")}xmlLoadComplete(t,e){const i=e.responseText,s=this.parseXml(i);if(!s){const i=e.responseType||e.contentType;return console.warn("Loader - "+t.key+": invalid XML ("+i+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)}parseXml(t){let e=null;try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new window.ActiveXObject("Microsoft.XMLDOM"),e.async="false",e.loadXML(t))}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}updateProgress(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)}totalLoadedFiles(){return this._loadedFileCount}totalQueuedFiles(){return this._totalFileCount-this._loadedFileCount}totalLoadedPacks(){return this._totalPackCount}totalQueuedPacks(){return this._totalPackCount-this._loadedPackCount}get progressFloat(){const t=this._loadedFileCount/this._totalFileCount*100;return Math.max(0,Math.min(100,t||0))}get progress(){return Math.round(this.progressFloat)}}(this),this.time=new class{constructor(t){this.game=t,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.advancedTiming=!1,this.frames=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new ji(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]}boot(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time}add(t){return this._timers.push(t),t}create(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=new ji(this.game,t);return this._timers.push(e),e}removeAll(){for(let t=0;t<this._timers.length;t+=1)this._timers[t].destroy();this._timers=[],this.events.removeAll()}refresh(){const t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t}update(t){const e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e,this.prevTime=this.now,this.now=t,this.elapsed=this.now-this.prevTime,this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())}updateTimers(){let t=0,e=this._timers.length;for(;t<e;)this._timers[t].update(this.time)?t+=1:(this._timers.splice(t,1),e-=1)}updateAdvancedTiming(){this._frameCount+=1,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames+=1,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)}gamePaused(){this._pauseStarted=Date.now(),this.events.pause();let t=this._timers.length;for(;t;)t-=1,this._timers[t]._pause()}gameResumed(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();let t=this._timers.length;for(;t;)t-=1,this._timers[t]._resume()}totalElapsedSeconds(){return.001*(this.time-this._started)}elapsedSince(t){return this.time-t}elapsedSecondsSince(t){return.001*(this.time-t)}reset(){this._started=this.time,this.removeAll()}destroy(){this.reset()}get desiredFps(){return this._desiredFps}set desiredFps(t){this._desiredFps=t,this.desiredFpsMult=1/t}}(this),this.tweens=new class{constructor(t){this.game=t,this._tweens=[],this._add=[],this.easeMap={Linear:Vi,Quad:Ki,Cubic:Zi,Quart:es,Quint:ns,Sine:os,Expo:ds,Circ:ps,Elastic:fs,Back:xs,Bounce:ws,"Quad.easeIn":qi,"Cubic.easeIn":$i,"Quart.easeIn":ts,"Quint.easeIn":ss,"Sine.easeIn":rs,"Expo.easeIn":ls,"Circ.easeIn":cs,"Elastic.easeIn":ms,"Back.easeIn":vs,"Bounce.easeIn":bs,"Quad.easeOut":Ki,"Cubic.easeOut":Zi,"Quart.easeOut":es,"Quint.easeOut":ns,"Sine.easeOut":os,"Expo.easeOut":ds,"Circ.easeOut":ps,"Elastic.easeOut":fs,"Back.easeOut":xs,"Bounce.easeOut":ws,"Quad.easeInOut":Qi,"Cubic.easeInOut":Ji,"Quart.easeInOut":is,"Quint.easeInOut":hs,"Sine.easeInOut":as,"Expo.easeInOut":us,"Circ.easeInOut":gs,"Elastic.easeInOut":_s,"Back.easeInOut":ys,"Bounce.easeInOut":Ss},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)}getAll(){return this._tweens}removeAll(){for(let t=0;t<this._tweens.length;t+=1)this._tweens[t].pendingDelete=!0;this._add=[]}removeFrom(t,e){let i,s;if(Array.isArray(t))for(i=0,s=t.length;i<s;i+=1)this.removeFrom(t[i]);else if(t.type===ht&&e)for(i=0,s=t.children.length;i<s;i+=1)this.removeFrom(t.children[i]);else{for(i=0,s=this._tweens.length;i<s;i+=1)t===this._tweens[i].target&&this.remove(this._tweens[i]);for(i=0,s=this._add.length;i<s;i+=1)t===this._add[i].target&&this.remove(this._add[i])}}add(t){t._manager=this,this._add.push(t)}create(t){return new class{constructor(t,e,i){this.game=e,this.target=t,this.manager=i,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new Ze,this.onLoop=new Ze,this.onRepeat=new Ze,this.onChildComplete=new Ze,this.onComplete=new Ze,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1}to(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Linear",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return"string"==typeof i&&this.manager.easeMap[i]&&(i=this.manager.easeMap[i]),this.isRunning||(this.timeline.push(new Yi(this).to(t,e,i,n,h,r)),s&&this.start()),this}from(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Linear",s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return"string"==typeof i&&this.manager.easeMap[i]&&(i=this.manager.easeMap[i]),this.isRunning?(console.warn("Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new Yi(this).from(t,e,i,n,h,r)),s&&this.start(),this)}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(let t=0;t<this.timeline.length;t+=1){const e=Object.keys(this.timeline[t].vEnd);for(let t=0;t<e.length;t+=1){const i=e[t];this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1)}}for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].loadValues();return this.manager.add(this),this.isRunning=!0,(t<0||t>this.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this}stop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this}updateTweenData(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0===this.timeline.length)return this;if(-1===i)for(let i=0;i<this.timeline.length;i+=1)this.timeline[i][t]=e;else this.timeline[i][t]=e;return this}delay(t,e){return this.updateTweenData("delay",t,e)}repeat(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("repeatCounter",t,i),this.updateTweenData("repeatDelay",e,i)}repeatDelay(t,e){return this.updateTweenData("repeatDelay",t,e)}yoyo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("yoyo",t,i),this.updateTweenData("yoyoDelay",e,i)}yoyoDelay(t,e){return this.updateTweenData("yoyoDelay",t,e)}easing(t,e){return"string"==typeof t&&this.manager.easeMap[t]&&(t=this.manager.easeMap[t]),this.updateTweenData("easingFunction",t,e)}interpolation(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.updateTweenData("interpolationFunction",t,i),this.updateTweenData("interpolationContext",e,i)}repeatAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.repeatCounter=t,this}chain(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];let s=e.length;for(;s;)s-=1,s>0?e[s-1].chainedTween=e[s]:this.chainedTween=e[s];return this}loop(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.repeatCounter=t?-1:0,this}onUpdateCallback(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,this}pause(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time}_pause(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)}resume(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].isRunning||(this.timeline[t].startTime+=this.game.time.time-this._pausedTime)}}_resume(){this._codePaused||this.resume()}update(t){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;const e=this.timeline[this.current].update(t);if(e===k)return!0;if(e===D)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(e===L)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(e===O){let t=!1;return this.reverse?(this.current-=1,this.current<0&&(this.current=this.timeline.length-1,t=!0)):(this.current+=1,this.current===this.timeline.length&&(this.current=0,t=!0)),t?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter-=1,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}return!1}generateData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:60,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null===this.game||null===this.target)return null;for(let t=0;t<this.timeline.length;t+=1){const e=Object.keys(this.timeline[t].vEnd);for(let t=0;t<e.length;t+=1){const i=e[t];this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1)}}for(let t=0;t<this.timeline.length;t+=1)this.timeline[t].loadValues();for(let i=0;i<this.timeline.length;i+=1)e=e.concat(this.timeline[i].generateData(t));return e}get totalDuration(){let t=0;for(let e=0;e<this.timeline.length;e+=1)t+=this.timeline[e].duration;return t}}(t,this.game,this)}remove(t){let e=this._tweens.indexOf(t);-1!==e?this._tweens[e].pendingDelete=!0:(e=this._add.indexOf(t),-1!==e&&(this._add[e].pendingDelete=!0))}update(){const t=this._add.length;let e=this._tweens.length;if(0===e&&0===t)return!1;let i=0;for(;i<e;)this._tweens[i].update(this.game.time.time)?i+=1:(this._tweens.splice(i,1),e-=1);return t>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0}isTweening(t){return this._tweens.some((e=>e.target===t))}_pauseAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t]._pause()}_resumeAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t]._resume()}pauseAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t].pause()}resumeAll(){for(let t=this._tweens.length-1;t>=0;t-=1)this._tweens[t].resume(!0)}}(this),this.input=new class{constructor(t){this.game=t,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.lockCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=nt,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.touch=null,this.mspointer=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new ui,this._localPoint=new ce,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0}boot(){this.mousePointer=new Mi(this.game,0,tt),this.addPointer(),this.addPointer(),this.mouse=new class{constructor(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.mouseWheelCallback=null,this.capture=!1,this.button=-1,this.wheelDelta=0,this.enabled=!0,this.locked=!1,this.stopOnGameOut=!1,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null,this._onMouseWheel=null,this._wheelEvent=null}start(){if(this.game.device.android&&!1===this.game.device.chrome)return;if(null!==this._onMouseDown)return;const t=this;this._onMouseDown=e=>t.onMouseDown(e),this._onMouseMove=e=>t.onMouseMove(e),this._onMouseUp=e=>t.onMouseUp(e),this._onMouseUpGlobal=e=>t.onMouseUpGlobal(e),this._onMouseOutGlobal=e=>t.onMouseOutGlobal(e),this._onMouseOut=e=>t.onMouseOut(e),this._onMouseOver=e=>t.onMouseOver(e),this._onMouseWheel=e=>t.onMouseWheel(e);const e=this.game.canvas;e.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("mousemove",this._onMouseMove,!0),e.addEventListener("mouseup",this._onMouseUp,!0),window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),e.addEventListener("mouseover",this._onMouseOver,!0),e.addEventListener("mouseout",this._onMouseOut,!0);const i=this.game.device.wheelEvent;i&&e.addEventListener(i,this._onMouseWheel,!0)}stop(){const t=this.game.canvas;t.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("mousemove",this._onMouseMove,!0),t.removeEventListener("mouseup",this._onMouseUp,!0),t.removeEventListener("mouseover",this._onMouseOver,!0),t.removeEventListener("mouseout",this._onMouseOut,!0);const e=this.game.device.wheelEvent;e&&t.removeEventListener(e,this._onMouseWheel,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0)}onMouseDown(t){this.event=t,this.eventPreventDefault(t),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.start(t))}onMouseMove(t){this.event=t,this.eventPreventDefault(t),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.move(t))}onMouseUp(t){this.event=t,this.eventPreventDefault(t),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.stop(t))}onMouseUpGlobal(t){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),t.identifier=0,this.input.mousePointer.stop(t))}onMouseOutGlobal(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&this.input.mousePointer.stop(t)}onMouseOut(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(t.identifier=0,this.input.mousePointer.stop(t))}onMouseOver(t){this.event=t,this.eventPreventDefault(t),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,t)}onMouseWheel(t){this._wheelEvent&&(t=this._wheelEvent.bindEvent(t)),this.event=t,this.eventPreventDefault(t),this.wheelDelta=Math.max(-1,Math.min(1,-t.deltaY)),this.mouseWheelCallback&&this.mouseWheelCallback.call(this.callbackContext,t)}eventPreventDefault(t){this.capture&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}}(this.game),this.touch=new class{constructor(t){this.game=t,this.enabled=!0,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null}start(){if(!this.game.device.touch||null!==this._onTouchStart)return;const t=this;this._onTouchStart=e=>t.onTouchStart(e),this._onTouchMove=e=>t.onTouchMove(e),this._onTouchEnd=e=>t.onTouchEnd(e),this._onTouchEnter=e=>t.onTouchEnter(e),this._onTouchLeave=e=>t.onTouchLeave(e),this._onTouchCancel=e=>t.onTouchCancel(e),this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)}stop(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel))}consumeDocumentTouches(){this._documentTouchMove=t=>{t.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)}onTouchStart(t){if(this.event=t,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.startPointer(t.changedTouches[e])}}onTouchCancel(t){if(this.event=t,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled){this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.stopPointer(t.changedTouches[e])}}onTouchEnter(t){this.event=t,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&this.eventPreventDefault(t)}onTouchLeave(t){this.event=t,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,t),this.eventPreventDefault(t)}onTouchMove(t){this.event=t,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.updatePointer(t.changedTouches[e])}onTouchEnd(t){this.event=t,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,t),this.eventPreventDefault(t);for(let e=0;e<t.changedTouches.length;e+=1)this.game.input.stopPointer(t.changedTouches[e])}eventPreventDefault(t){this.preventDefault&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}}(this.game),this.mspointer=new class{constructor(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.capture=!0,this.button=-1,this.event=null,this.enabled=!0,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null}start(){if(!this.game.device.mspointer||null!==this._onMSPointerDown)return;const t=this;this._onMSPointerDown=e=>t.onPointerDown(e),this._onMSPointerMove=e=>t.onPointerMove(e),this._onMSPointerUp=e=>t.onPointerUp(e),this._onMSPointerUpGlobal=e=>t.onPointerUpGlobal(e),this._onMSPointerOut=e=>t.onPointerOut(e),this._onMSPointerOver=e=>t.onPointerOver(e);const e=this.game.canvas;e.addEventListener("MSPointerDown",this._onMSPointerDown,!1),e.addEventListener("MSPointerMove",this._onMSPointerMove,!1),e.addEventListener("MSPointerUp",this._onMSPointerUp,!1),e.addEventListener("pointerdown",this._onMSPointerDown,!1),e.addEventListener("pointermove",this._onMSPointerMove,!1),e.addEventListener("pointerup",this._onMSPointerUp,!1),e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none",window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.addEventListener("MSPointerOver",this._onMSPointerOver,!0),e.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.addEventListener("pointerover",this._onMSPointerOver,!0),e.addEventListener("pointerout",this._onMSPointerOut,!0)}stop(){if(!this.game.device.mspointer)return;const t=this.game.canvas;t.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),t.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),t.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),t.removeEventListener("pointerdown",this._onMSPointerDown,!1),t.removeEventListener("pointermove",this._onMSPointerMove,!1),t.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),t.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.removeEventListener("pointerover",this._onMSPointerOver,!0),t.removeEventListener("pointerout",this._onMSPointerOut,!0)}onPointerDown(t){this.event=t,this.eventPreventDefault(t),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.start(t):this.input.startPointer(t))}onPointerMove(t){this.event=t,this.eventPreventDefault(t),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.move(t):this.input.updatePointer(t))}onPointerUp(t){this.event=t,this.eventPreventDefault(t),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.stop(t):this.input.stopPointer(t))}onPointerUpGlobal(t){if("mouse"!==t.pointerType&&4!==t.pointerType||this.input.mousePointer.withinGame){const e=this.input.getPointerFromIdentifier(t.identifier);e&&e.withinGame&&this.onPointerUp(t)}else this.onPointerUp(t)}onPointerOut(t){let e;this.event=t,this.eventPreventDefault(t),"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.withinGame=!1:(e=this.input.getPointerFromIdentifier(t.identifier),e&&(e.withinGame=!1)),this.input.mouse.mouseOutCallback&&this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext,t),this.input.enabled&&this.enabled&&this.input.mouse.stopOnGameOut&&(t.identifier=0,e?e.stop(t):this.input.mousePointer.stop(t))}onPointerOver(t){if(this.event=t,this.eventPreventDefault(t),"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!0;else{const e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!0)}this.input.mouse.mouseOverCallback&&this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext,t)}eventPreventDefault(t){this.capture&&("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault()}}(this.game),this.onDown=new Ze,this.onUp=new Ze,this.onTap=new Ze,this.onHold=new Ze,this.scale=new ce(1,1),this.speed=new ce,this.position=new ce,this._oldPosition=new ce,this.circle=new wi(0,0,44),this.activePointer=this.mousePointer,this.hitCanvas=kt(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.game.device.mspointer?this.mspointer.start():this.game.device.touch&&this.touch.start(),this.mousePointer.active=!0;const t=this;this._onClickTrampoline=e=>t.onClickTrampoline(e),this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)}destroy(){this.mouse.stop(),this.game.device.mspointer?this.mspointer.stop():this.game.device.touch&&this.touch.stop(),this.moveCallbacks=[],At(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)}setInteractiveCandidateHandler(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e}addMoveCallback(t,e){this.moveCallbacks.push({callback:t,context:e})}deleteMoveCallback(t,e){let i=this.moveCallbacks.length;for(;i;)if(i-=1,this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)}addPointer(){if(this.pointers.length>=10)return console.warn("Input.addPointer: Maximum limit of 10 pointers reached."),null;const t=this.pointers.length+1,e=new Mi(this.game,t,et);return this.pointers.push(e),this["pointer"+t]=e,e}update(){if(this.pollRate>0&&this._pollCounter<this.pollRate)this._pollCounter+=1;else{this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update();for(let t=0;t<this.pointers.length;t+=1)this.pointers[t].update();this._pollCounter=0}}reset(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.game.isBooted&&!this.resetLocked){this.mousePointer.reset();for(let t=0;t<this.pointers.length;t+=1)this.pointers[t].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor="inherit"),t&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new Ze,this.onUp=new Ze,this.onTap=new Ze,this.onHold=new Ze,this.moveCallbacks=[]),this._pollCounter=0}}resetSpeed(t,e){this._oldPosition.setTo(t,e),this.speed.setTo(0,0)}startPointer(t){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(!i.active)return i.start(t)}return null}updatePointer(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.move(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.move(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.move(t)}return null}stopPointer(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.stop(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.stop(t);for(let e=2;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.stop(t)}return null}countActivePointers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pointers.length,e=t;for(let t=0;t<this.pointers.length&&e>0;t+=1)this.pointers[t].active&&(e-=1);return t-e}getPointer(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.active===t)return i}return null}getPointerFromIdentifier(t){for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.identifier===t)return i}return null}getPointerFromId(t){for(let e=0;e<this.pointers.length;e+=1){const i=this.pointers[e];if(i.pointerId===t)return i}return null}getLocalPosition(t,e){const i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||new ce,s=t.worldTransform,n=1/(s.a*s.d+s.c*-s.b);return i.setTo(s.d*n*e.x+-s.c*n*e.y+(s.ty*s.c-s.tx*s.d)*n,s.a*n*e.y+-s.b*n*e.x+(-s.ty*s.a+s.tx*s.b)*n)}hitTest(t,e,i){if(!t.worldVisible)return!1;if(this.getLocalPosition(t,e,this._localPoint),i.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(t instanceof vi){const e=t.texture.frame.width,i=t.texture.frame.height,s=-e*t.anchor.x;if(this._localPoint.x>=s&&this._localPoint.x<s+e){const e=-i*t.anchor.y;if(this._localPoint.y>=e&&this._localPoint.y<e+i)return!0}}else if(t instanceof Ci)for(let e=0;e<t.graphicsData.length;e+=1){const i=t.graphicsData[e];if(i.fill&&i.shape&&i.shape.contains(this._localPoint.x,this._localPoint.y))return!0}for(let s=0;s<t.children.length;s+=1)if(this.hitTest(t.children[s],e,i))return!0;return!1}onClickTrampoline(){this.activePointer.processClickTrampolines()}get x(){return this._x}set x(t){this._x=Math.floor(t)}get y(){return this._y}set y(t){this._y=Math.floor(t)}get pollLocked(){return this.pollRate>0&&this._pollCounter<this.pollRate}get totalInactivePointers(){return this.pointers.length-this.countActivePointers()}get totalActivePointers(){return this.countActivePointers()}get worldX(){return this.x}get worldY(){return this.y}}(this),this.sound=new class{constructor(t){this.game=t,this.onChange=new Ze,this.context=null,this.baseLatency=0,this.noAudio=!1,this.connectToMaster=!0,this.isLocked=!1,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new ui,this._watching=!1,this._watchCallback=null,this._watchContext=null}boot(){if(this.game.config.isForceDisabledAudio)this.noAudio=!0;else{if(window.PhaserRegistry&&window.PhaserRegistry.audioContext)this.context=window.PhaserRegistry.audioContext;else if(window.AudioContext)try{this.context=new window.AudioContext}catch(t){this.context=null,this.noAudio=!0,this.isLocked=!1,this.game.exceptionHandler(t)}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(t){this.context=null,this.noAudio=!0,this.isLocked=!1,this.game.exceptionHandler(t)}null===this.context||this.context&&void 0===this.context.createGain&&void 0===this.context.createGainNode?this.noAudio=!0:(this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),this.onUnlockEventBinded=this.onUnlockEvent.bind(this),"suspended"!==this.context.state&&"interrupted"!==this.context.state||this.addUnlockHandlers(),this.context.addEventListener("statechange",(()=>{this.onChange.dispatch("onContextStateChange",{state:this.context.state,isLocked:this.isLocked}),this.isLocked||"suspended"!==this.context.state&&"interrupted"!==this.context.state?this.isLocked&&"running"===this.context.state&&this.removeUnlockHandlers():this.addUnlockHandlers()})))}}addUnlockHandlers(){this.isLocked=!0,this.onChange.dispatch("addUnlockHandlers",{state:this.context.state,isLocked:this.isLocked}),document.body.addEventListener("touchstart",this.onUnlockEventBinded,!1),document.body.addEventListener("touchend",this.onUnlockEventBinded,!1),document.body.addEventListener("click",this.onUnlockEventBinded,!1),document.body.addEventListener("keydown",this.onUnlockEventBinded,!1)}removeUnlockHandlers(){this.isLocked=!1,this.onChange.dispatch("removeUnlockHandlers",{state:this.context.state,isLocked:this.isLocked}),document.body.removeEventListener("touchstart",this.onUnlockEventBinded),document.body.removeEventListener("touchend",this.onUnlockEventBinded),document.body.removeEventListener("click",this.onUnlockEventBinded),document.body.removeEventListener("keydown",this.onUnlockEventBinded)}onUnlockEvent(t){const e=this.context.state;if("suspended"!==e&&"interrupted"!==e)return this.onChange.dispatch("onUnlockResumeDenied",{state:e,isLocked:this.isLocked,event:t}),void this.removeUnlockHandlers();this.onChange.dispatch("onContextResumeStart",{state:e,isLocked:this.isLocked,event:t}),this.context.resume().then((()=>{this.onChange.dispatch("onContextResumeResult",{initialState:e,state:this.context.state,isLocked:this.isLocked}),this.removeUnlockHandlers()})).catch((t=>{this.onChange.dispatch("onContextResumeReject",{initialState:e,state:this.context.state,isLocked:this.isLocked,error:t}),this.removeUnlockHandlers(),this.game.exceptionHandler(t,{initialState:e,state:this.context.state})}))}stopAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].stop()}pauseAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].pause()}resumeAll(){if(!this.noAudio)for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].resume()}decode(t){const e=this.game.cache.getSoundData(t);e&&!1===this.game.cache.isSoundDecoded(t)&&(this.game.cache.updateSound(t,"isDecoding",!0),this.context.decodeAudioData(e).then((e=>{this.game.cache.decodedSound(t,e)})).catch((e=>{this.game.exceptionHandler(e,{key:t})})))}setDecodedCallback(t,e,i){"string"==typeof t&&(t=[t]),this._watchList.reset();for(let e=0;e<t.length;e+=1)t[e]instanceof zi?this.game.cache.isSoundDecoded(t[e].key)||this._watchList.add(t[e].key):this.game.cache.isSoundDecoded(t[e])||this._watchList.add(t[e]);0===this._watchList.total?(this._watching=!1,e.call(i)):(this._watching=!0,this._watchCallback=e,this._watchContext=i)}update(){if(!this.noAudio){for(let t=0;t<this._sounds.length;t+=1)this._sounds[t].update();if(this._watching){let t=this._watchList.first;for(;t;)this.game.cache.isSoundDecoded(t)&&this._watchList.remove(t),t=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}}add(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.connectToMaster;const n=new zi(this.game,t,e,i,s);return this._sounds.push(n),n}addSprite(t){return new class{constructor(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(let t in this.config.spritemap){const e=this.config.spritemap[t],i=this.game.sound.add(this.key);i.addMarker(t,e.start,e.end-e.start,null,e.loop),this.sounds[t]=i}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])}play(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.sounds[t].play(t,null,e)}stop(t){if(t)this.sounds[t].stop();else for(let t in this.sounds)this.sounds[t].stop()}get(t){return this.sounds[t]}}(this.game,t)}remove(t){let e=this._sounds.length;for(;e;)if(e-=1,this._sounds[e]===t)return this._sounds[e].destroy(!1),this._sounds.splice(e,1),!0;return!1}removeByKey(t){let e=this._sounds.length,i=0;for(;e;)e-=1,this._sounds[e].key===t&&(this._sounds[e].destroy(!1),this._sounds.splice(e,1),i+=1);return i}play(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.noAudio)return null;const s=this.add(t,e,i);return s.play(),s}setMute(){this._muted||(this._muted=!0,this.noAudio||(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0),this.onChange.dispatch("muted"))}unsetMute(){this._muted&&!this._codeMuted&&(this._muted=!1,this.noAudio||(this.masterGain.gain.value=this._muteVolume),this.onChange.dispatch("unmuted"))}destroy(){this.stopAll();for(let t=0;t<this._sounds.length;t+=1)this._sounds[t]&&this._sounds[t].destroy();this._sounds=[],this.onChange.dispose(),this.context&&(window.PhaserRegistry?window.PhaserRegistry.audioContext=this.context:this.context.close&&this.context.close())}get mute(){return this._muted}set mute(t){if(t){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}get volume(){return this._volume}set volume(t){t<0?t=0:t>1&&(t=1),this._volume!==t&&(this._volume=t,this.noAudio||(this.masterGain.gain.value=t))}}(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),window.focus&&window.focus(),this.config.isSkipTicker||(this.raf=new class{constructor(t){this.game=t,this.rafId=0,this.updateBinded=this.update.bind(this)}start(){this.rafId=requestAnimationFrame(this.updateBinded)}stop(){cancelAnimationFrame(this.rafId)}update(t){this.game.update(t),this.rafId=requestAnimationFrame(this.updateBinded)}}(this),this.raf.start()),this.onBoot.dispatch(this))}initRenderer(){this.config.canvas?this.canvas=this.config.canvas:this.canvas=Dt(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%";let t=!1;if(this.config.renderType===$||this.config.renderType===J)try{this.renderer=new class{constructor(t){this.type=J,this.resolution=t.config.resolution,this.autoResize=!1,this.clearBeforeRender=t.config.clearBeforeRender,this.width=t.width,this.height=t.height,this.view=t.canvas,this._contextOptions={alpha:t.config.transparent,depth:!1,antialias:t.config.antialias,premultipliedAlpha:t.config.transparent&&"notMultiplied"!==t.config.transparent,stencil:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:t.config.preserveDrawingBuffer},this.projection=new ce,this.offset=new ce,this.shaderManager=new class{constructor(){this.gl=null,this.primitiveShader=null,this.complexPrimitiveShader=null,this.defaultShader=null,this.fastShader=null,this.stripShader=null,this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(let t=0;t<this.maxAttibs;t+=1)this.attribState[t]=!1;this.stack=[]}setContext(t){this.gl=t,this.primitiveShader=new class{constructor(t){this.gl=t,this._UID=re(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()}init(){const t=this.gl,e=ge(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}}(t),this.complexPrimitiveShader=new class{constructor(t){this.gl=t,this._UID=re(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()}init(){const t=this.gl,e=ge(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null}}(t),this.defaultShader=new fe(t),this.fastShader=new class{constructor(t){this.gl=t,this._UID=re(),this.program=null,this.textureCount=0,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.init()}init(){const t=this.gl,e=ge(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null}}(t),this.stripShader=new class{constructor(t){this.gl=t,this._UID=re(),this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()}init(){const t=this.gl,e=ge(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e}destroy(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null}}(t),this.setShader(this.defaultShader)}setAttribs(t){let e;for(e=0;e<this.tempAttribState.length;e+=1)this.tempAttribState[e]=!1;for(e=0;e<t.length;e+=1){const i=t[e];this.tempAttribState[i]=!0}const i=this.gl;for(e=0;e<this.attribState.length;e+=1)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?i.enableVertexAttribArray(e):i.disableVertexAttribArray(e))}setShader(t){return this._currentId!==t._UID&&(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)}destroy(){this.attribState=null,this.tempAttribState=null,this.currentShader=null,this._currentId=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null}},this.spriteBatch=new class{constructor(){this.vertSize=5,this.size=2e3;const t=4*this.size*4*this.vertSize,e=6*this.size;this.vertices=new ArrayBuffer(t),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(e),this.lastIndexCount=0;for(let t=0,i=0;t<e;t+=6,i+=4)this.indices[t+0]=i+0,this.indices[t+1]=i+1,this.indices[t+2]=i+2,this.indices[t+3]=i+0,this.indices[t+4]=i+2,this.indices[t+5]=i+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new class{constructor(t,e){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=e||{},this.fragmentSrc=t||[]}syncUniforms(){for(let t=0,e=this.shaders.length;t<e;t+=1)this.shaders[t].dirty=!0}}(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])}setContext(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999;const e=new fe(t);e.fragmentSrc=this.defaultShader.fragmentSrc,e.uniforms={},e.init(),this.defaultShader.shaders[t.id]=e}begin(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()}end(){this.flush()}render(t,e){const i=t.texture;let s=t.worldTransform;e&&(s=e),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);const n=i._uvs;if(!n)return;const h=t.anchor.x,r=t.anchor.y;let o,a,l,d;if(i.trim){const t=i.trim;a=t.x-h*t.width,o=a+i.crop.width,d=t.y-r*t.height,l=d+i.crop.height}else o=i.frame.width*(1-h),a=i.frame.width*-h,l=i.frame.height*(1-r),d=i.frame.height*-r;const u=4*this.currentBatchSize*this.vertSize,c=i.baseTexture.resolution,p=s.a/c,g=s.b/c,m=s.c/c,f=s.d/c,_=s.tx,v=s.ty,x=this.colors,y=this.positions;this.renderSession.roundPixels?(y[u]=p*a+m*d+_|0,y[u+1]=f*d+g*a+v|0,y[u+5]=p*o+m*d+_|0,y[u+6]=f*d+g*o+v|0,y[u+10]=p*o+m*l+_|0,y[u+11]=f*l+g*o+v|0,y[u+15]=p*a+m*l+_|0,y[u+16]=f*l+g*a+v|0):(y[u]=p*a+m*d+_,y[u+1]=f*d+g*a+v,y[u+5]=p*o+m*d+_,y[u+6]=f*d+g*o+v,y[u+10]=p*o+m*l+_,y[u+11]=f*l+g*o+v,y[u+15]=p*a+m*l+_,y[u+16]=f*l+g*a+v),y[u+2]=n.x0,y[u+3]=n.y0,y[u+7]=n.x1,y[u+8]=n.y1,y[u+12]=n.x2,y[u+13]=n.y2,y[u+17]=n.x3,y[u+18]=n.y3;const w=t.tint;x[u+4]=(w>>16)+(65280&w)+((255&w)<<16)+(255*t.worldAlpha<<24),x[u+9]=x[u+4],x[u+14]=x[u+4],x[u+19]=x[u+4],this.sprites[this.currentBatchSize]=t,this.currentBatchSize+=1}renderTilingSprite(){}flush(){if(0===this.currentBatchSize)return;const t=this.gl;let e,i,s,n;if(this.dirty){this.dirty=!1,t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e=this.defaultShader.shaders[t.id];const i=4*this.vertSize;t.vertexAttribPointer(e.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(e.aTextureCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(e.colorAttribute,4,t.UNSIGNED_BYTE,!0,i,16)}if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{const e=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}let h,r=0,o=0,a=null,l=this.renderSession.blendModeManager.currentBlendMode,d=null,u=!1,c=!1;for(let p=0,g=this.currentBatchSize;p<g;p+=1){h=this.sprites[p],i=h.tilingTexture?h.tilingTexture.baseTexture:h.texture.baseTexture,s=h.blendMode,n=h.shader||this.defaultShader,u=l!==s,c=!d||!n||d._UID!==n._UID;let g=i.skipRender;if(g&&h.children.length>0&&(g=!1),(a!==i&&!g||u||c)&&(this.renderBatch(a,r,o),o=p,r=0,a=i,u&&(l=s,this.renderSession.blendModeManager.setBlendMode(l)),c)){d=n,e=d.shaders[t.id],e||(e=new fe(t),e.fragmentSrc=d.fragmentSrc,e.uniforms=d.uniforms,e.init(),d.shaders[t.id]=e),this.renderSession.shaderManager.setShader(e),e.dirty&&e.syncUniforms();const i=this.renderSession.projection;t.uniform2f(e.projectionVector,i.x,i.y);const s=this.renderSession.offset;t.uniform2f(e.offsetVector,s.x,s.y)}r+=1}this.renderBatch(a,r,o),this.currentBatchSize=0}renderBatch(t,e,i){if(0===e)return;const s=this.gl;if(t._dirty[s.id]){if(!this.renderSession.renderer.updateTexture(t))return}else s.bindTexture(s.TEXTURE_2D,t._glTextures[s.id]);s.drawElements(s.TRIANGLES,6*e,s.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount+=1}stop(){this.flush(),this.dirty=!0}start(){this.dirty=!0}destroy(){this.vertices=null,this.positions=null,this.colors=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null}},this.filterManager=new class{constructor(){this.filterStack=[],this.offsetX=0,this.offsetY=0}setContext(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()}begin(){}pushFilter(){}popFilter(){}applyFilterPass(){}initShaderBuffers(){}destroy(){}},this.stencilManager=new class{constructor(){this.stencilStack=[],this.reverse=!0,this.count=0}setContext(t){this.gl=t}destroy(){this.stencilStack=null,this.gl=null}pushStencil(t,e,i){const s=i.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);const n=this.count;s.colorMask(!1,!1,!1,!1),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),1===e.mode?(s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?s.stencilFunc(s.EQUAL,255-(n+1),255):s.stencilFunc(s.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n+1,255):s.stencilFunc(s.EQUAL,255-(n+1),255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.count+=1}bindGraphics(t,e,i){const s=i.gl,n=i.projection,h=i.offset;let r;1===e.mode?(r=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(r),s.uniform1f(r.flipY,i.flipY),s.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform2f(r.projectionVector,n.x,-n.y),s.uniform2f(r.offsetVector,-h.x,-h.y),s.uniform3fv(r.tintColor,Nt(t.tint)),s.uniform3fv(r.color,e.color),s.uniform1f(r.alpha,t.worldAlpha*e.alpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(r.aVertexPosition,2,s.FLOAT,!1,8,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(r=i.shaderManager.primitiveShader,i.shaderManager.setShader(r),s.uniformMatrix3fv(r.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform1f(r.flipY,i.flipY),s.uniform2f(r.projectionVector,n.x,-n.y),s.uniform2f(r.offsetVector,-h.x,-h.y),s.uniform3fv(r.tintColor,Nt(t.tint)),s.uniform1f(r.alpha,t.worldAlpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(r.aVertexPosition,2,s.FLOAT,!1,24,0),s.vertexAttribPointer(r.colorAttribute,4,s.FLOAT,!1,24,8),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer))}popStencil(t,e,i){const s=i.gl;if(this.stencilStack.pop(),this.count-=1,0===this.stencilStack.length)s.disable(s.STENCIL_TEST);else{const n=this.count;this.bindGraphics(t,e,i),s.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)):(this.reverse?(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP)}}},this.blendModeManager=new class{constructor(){this.gl=null,this.currentBlendMode=99999}setContext(t){this.gl=t}setBlendMode(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;const e=window.PhaserRegistry.blendModesWebGL[this.currentBlendMode];return e&&this.gl.blendFunc(e[0],e[1]),!0}destroy(){this.gl=null}},this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=h,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()}destroy(){if(window.PhaserRegistry.GL_CONTEXTS[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.filterManager=null,this.gl){this.gl.canvas.width=1,this.gl.canvas.height=1;const t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext()}this.gl=null,this.renderSession=null,At(this),window.PhaserRegistry.INSTANCES[this.glContextId]=null,window.PhaserRegistry.GL_CONTEXT_ID-=1}initRegistry(){window.PhaserRegistry.GL_CONTEXT_ID||(window.PhaserRegistry.GL_CONTEXT_ID=0),window.PhaserRegistry.GL_CONTEXTS||(window.PhaserRegistry.GL_CONTEXTS=[]),window.PhaserRegistry.INSTANCES||(window.PhaserRegistry.INSTANCES=[])}initContext(){const t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support WebGL. Try using the Canvas 2D.");this.initRegistry(),this.glContextId=window.PhaserRegistry.GL_CONTEXT_ID,t.id=window.PhaserRegistry.GL_CONTEXT_ID,window.PhaserRegistry.GL_CONTEXTS[this.glContextId]=t,window.PhaserRegistry.INSTANCES[this.glContextId]=this,window.PhaserRegistry.GL_CONTEXT_ID+=1,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.stencilManager.setContext(t),this.filterManager.setContext(t),this.blendModeManager.setContext(t),this.renderSession.gl=this.gl,this.resize(this.width,this.height)}render(t){if(this.contextLost)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),this.clearBeforeRender&&(e.clearColor(t._bgColor.r,t._bgColor.g,t._bgColor.b,t._bgColor.a),e.clear(e.COLOR_BUFFER_BIT)),this.offset.x=0,this.offset.y=0,this.renderDisplayObject(t,this.projection)}renderDisplayObject(t,e,i,s){this.renderSession.blendModeManager.setBlendMode(R),this.renderSession.drawCount=0,this.renderSession.flipY=i?-1:1,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t.renderWebGL(this.renderSession,s),this.spriteBatch.end()}resize(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution}updateTexture(t){if(!t.hasLoaded)return!1;const e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===x?e.LINEAR:e.NEAREST),t.mipmap&&Ht(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===x?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===x?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0}mapBlendModes(){if(window.PhaserRegistry.blendModesWebGL)return;const t=this.gl,e=[];e[R]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[F]=[t.SRC_ALPHA,t.DST_ALPHA],e[I]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],e[U]=[t.SRC_ALPHA,t.ONE],e[B]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[N]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[G]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[W]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[H]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[z]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[X]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[j]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Y]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[V]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[q]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[K]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[Q]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],window.PhaserRegistry.blendModesWebGL=e}}(this),this.context=null,this.contextLostBinded=this.contextLost.bind(this),this.contextRestoredBinded=this.contextRestored.bind(this),this.canvas.addEventListener("webglcontextlost",this.contextLostBinded,!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestoredBinded,!1),t=!0}catch(e){t=!1;const i={};window.PhaserRegistry?.GL_PROGRAM_INFO_LOG&&(i.gl_program_log=window.PhaserRegistry.GL_PROGRAM_INFO_LOG),window.PhaserRegistry?.GL_SHADER_INFO_LOG&&(i.gl_shader_log=window.PhaserRegistry.GL_SHADER_INFO_LOG),this.exceptionHandler(e,i)}t||(this.renderer&&(this.contextLostBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextLostBinded,!1),this.contextRestoredBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextRestoredBinded,!1),this.renderer.destroy(),Ot(this.canvas),this.canvas=Dt(this,this.width,this.height,this.config.canvasID,!0)),this.renderer=new class{constructor(t){if(window.PhaserRegistry||(window.PhaserRegistry={}),window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA||(window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA=function(){const t=new Ft(2,1);t.context.fillStyle="rgba(10, 20, 30, 0.5)",t.context.fillRect(0,0,1,1);const e=t.context.getImageData(0,0,1,1);if(null===e)return!1;t.context.putImageData(e,1,0);const i=t.context.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY||(window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY=function(){if(void 0===document)return!1;const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",e="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",i=new Image;i.src=t+"AP804Oa6"+e;const s=new Image;s.src=t+"/wCKxvRF"+e;const n=kt("CanvasTinter",6,1),h=n.getContext("2d");if(h.globalCompositeOperation="multiply",h.drawImage(i,0,0),h.drawImage(s,2,0),!h.getImageData(2,0,1,1))return!1;const r=h.getImageData(2,0,1,1).data;return Et(n),255===r[0]&&0===r[1]&&0===r[2]}()),window.PhaserRegistry.CANVAS_TINT_METHOD||(window.PhaserRegistry.CANVAS_TINT_METHOD=window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY?oe:ae),this.type=Z,this.resolution=t.config.resolution,this.clearBeforeRender=t.config.clearBeforeRender,this.transparent=t.config.transparent,this.autoResize=!1,this.width=t.width*this.resolution,this.height=t.height*this.resolution,this.view=t.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),!this.context)throw new Error("Error creating Canvas 2D context.");this.refresh=!0,this.count=0,this.renderSession={context:this.context,maskManager:n,scaleMode:null,smoothProperty:Rt(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)}render(t){this.context&&(this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=0,this.renderSession.shakeY=0,this.context.globalCompositeOperation="source-over",this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):t._bgColor&&(this.context.fillStyle=t._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t))}destroy(){(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.renderSession=null}resize(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===x)}renderDisplayObject(t,e,i){this.renderSession.context=e||this.context,this.renderSession.resolution=this.resolution,t.renderCanvas(this.renderSession,i)}mapBlendModes(){if(window.PhaserRegistry.blendModesCanvas)return;const t=[],e=window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY;t[R]="source-over",t[F]="lighter",t[I]=e?"multiply":"source-over",t[U]=e?"screen":"source-over",t[B]=e?"overlay":"source-over",t[N]=e?"darken":"source-over",t[G]=e?"lighten":"source-over",t[W]=e?"color-dodge":"source-over",t[H]=e?"color-burn":"source-over",t[z]=e?"hard-light":"source-over",t[X]=e?"soft-light":"source-over",t[j]=e?"difference":"source-over",t[Y]=e?"exclusion":"source-over",t[V]=e?"hue":"source-over",t[q]=e?"saturation":"source-over",t[K]=e?"color":"source-over",t[Q]=e?"luminosity":"source-over",window.PhaserRegistry.blendModesCanvas=t}}(this),this.context=this.renderer.context),this.stage.smoothed=this.config.antialias,function(t,e){let i,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e&&("string"==typeof e?i=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(i=e)),i||(i=document.body),s&&i.style&&(i.style.overflow="hidden"),i.appendChild(t)}(this.canvas,this.parent,!1),Lt(this.canvas)}parseConfigElement(t,e,i){void 0!==t[e]?this.config[e]=t[e]:this.config[e]=i}parseConfig(t){this.parseConfigElement(t,"width",800),this.parseConfigElement(t,"height",600),this.parseConfigElement(t,"backgroundColor",0),this.parseConfigElement(t,"forceSingleUpdate",!0),this.parseConfigElement(t,"canvasID",""),this.parseConfigElement(t,"canvasStyle",void 0),this.parseConfigElement(t,"resolution",1),this.parseConfigElement(t,"transparent",!1),this.parseConfigElement(t,"antialias",!1),this.parseConfigElement(t,"preserveDrawingBuffer",!1),this.parseConfigElement(t,"clearBeforeRender",!1),this.parseConfigElement(t,"renderType",$),this.parseConfigElement(t,"isForceDisabledAudio",!1),this.parseConfigElement(t,"maxParallelDownloads",16),t.renderer&&(this.config.renderType=t.renderer),t.exceptionHandler?this.exceptionHandler=t.exceptionHandler:this.exceptionHandler=(t,e)=>{console.error(t,e)},t.parent&&(this.parent=t.parent);let e=null;t.state&&(e=t.state),this.state=new class{constructor(t,e){this.game=t,this.states={},this._pendingState=null,null!=e&&(this._pendingState=e),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onResizeCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null}boot(){null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)}add(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=null;return e instanceof Xi?s=e:"object"==typeof e?(s=e,s.game=this.game):"function"==typeof e&&(s=new e(this.game)),this.states[t]=s,i&&(this.game.isBooted?this.start(t):this._pendingState=t),s}remove(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onResizeCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]}start(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.checkState(t)){this._pendingState=t,this._clearWorld=e,this._clearCache=i;for(var s=arguments.length,n=new Array(s>3?s-3:0),h=3;h<s;h++)n[h-3]=arguments[h];n&&n.length>0&&(this._args=n.slice())}}restart(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._pendingState=this.current,this._clearWorld=t,this._clearCache=e;for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;n<i;n++)s[n-2]=arguments[n];s&&s.length>0&&(this._args=s.slice())}preUpdate(){if(this._pendingState&&this.game.isBooted){if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.game.world.x=0,this.game.world.y=0,this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}}clearCurrentState(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.input.reset(!0),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this._clearWorld&&(this.game.world.destroy(!0,!0),this._clearCache&&this.game.cache.destroy()))}checkState(t){return!!this.states[t]&&!!(this.states[t].preload||this.states[t].create||this.states[t].update||this.states[t].render)}link(t){this.states[t].game=this.game,this.states[t].key=t}unlink(t){this.states[t]&&(this.states[t].game=null)}setCurrentState(t){this.callbackContext=this.states[t],this.link(t),this.onInitCallback=this.callbackContext.init||this.dummy,this.onPreloadCallback=this.callbackContext.preload||null,this.onCreateCallback=this.callbackContext.create||null,this.onUpdateCallback=this.callbackContext.update||null,this.onResizeCallback=this.callbackContext.resize||null,this.onPauseUpdateCallback=this.callbackContext.pauseUpdate||null,this.onShutDownCallback=this.callbackContext.shutdown||this.dummy,this.current=t,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),t===this._pendingState&&(this._args=[]),this.game.isKickStart=!0}getCurrentState(){return this.states[this.current]}loadComplete(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0}update(){this._created&&this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game)}pauseUpdate(){this._created&&this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game)}resize(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)}destroy(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}dummy(){}get created(){return this._created}}(this,e)}contextLost(t){t.preventDefault(),this.renderer&&(this.renderer.contextLost=!0)}contextRestored(){this.renderer.initContext(),this.renderer&&(this.renderer.contextLost=!1)}update(t){this.time.update(t),this.isPaused?(this.scale.pauseUpdate(),this.state.pauseUpdate()):(this.scale.preUpdate(),this.state.preUpdate(),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.stage.postUpdate()),this.stage.updateTransform(),this.renderer.render(this.stage)}destroy(){this.isPaused=!0,this.cache&&(this.raf&&this.raf.stop(),this.time.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.canvas&&(this.contextLostBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextLostBinded,!1),this.contextRestoredBinded&&this.canvas.removeEventListener("webglcontextlost",this.contextRestoredBinded,!1)),this.renderer.destroy(!1),Ot(this.canvas),this.cache=null,this.load=null,this.time=null,this.world=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.canvas=null,this.renderer=null)}};const Ps=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.start=new ce(t,e),this.end=new ce(i,s),this.type=St}setTo(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this}fromSprite(t,e){return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?this.setTo(t.center.x,t.center.y,e.center.x,e.center.y):this.setTo(t.x,t.y,e.x,e.y)}fromAngle(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this}rotateAround(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this}intersects(t,e,i){return function(t,e,i,s){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;const r=h||new ce,o=e.y-t.y,a=s.y-i.y,l=t.x-e.x,d=i.x-s.x,u=e.x*t.y-t.x*e.y,c=s.x*i.y-i.x*s.y,p=o*d-a*l;if(0===p)return null;if(r.x=(l*c-d*u)/p,r.y=(a*u-o*c)/p,n){const n=(s.y-i.y)*(e.x-t.x)-(s.x-i.x)*(e.y-t.y),h=((s.x-i.x)*(t.y-i.y)-(s.y-i.y)*(t.x-i.x))/n,o=((e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x))/n;return h>=0&&h<=1&&o>=0&&o<=1?r:null}return r}(this.start,this.end,t.start,t.end,e,i)}reflect(t){return this,2*t.normalAngle-3.141592653589793-this.angle}midPoint(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ce;return t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t}centerOn(t,e){const i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)}pointOnLine(t,e){return(t-this.start.x)*(this.end.y-this.start.y)==(this.end.x-this.start.x)*(e-this.start.y)}pointOnSegment(t,e){const i=Math.min(this.start.x,this.end.x),s=Math.max(this.start.x,this.end.x),n=Math.min(this.start.y,this.end.y),h=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e)&&t>=i&&t<=s&&e>=n&&e<=h}random(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||new ce,e=Math.random();return t.x=this.start.x+e*(this.end.x-this.start.x),t.y=this.start.y+e*(this.end.y-this.start.y),t}coordinatesOnLine(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=Math.round(this.start.x),s=Math.round(this.start.y);const n=Math.round(this.end.x),h=Math.round(this.end.y),r=Math.abs(n-i),o=Math.abs(h-s),a=i<n?1:-1,l=s<h?1:-1;let d=r-o;e.push([i,s]);let u=1;for(;i!==n||s!==h;){const n=d<<1;n>-o&&(d-=o,i+=a),n<r&&(d+=r,s+=l),u%t==0&&e.push([i,s]),u+=1}return e}clone(){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=e||new Ps;return i.start.x=t.start.x,i.start.y=t.start.y,i.end.x=t.end.x,i.end.y=t.end.y,i}(this)}get length(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}get angle(){return Math.atan2(this.end.y-this.start.y,this.end.x-this.start.x)}get slope(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}get perpSlope(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}get x(){return Math.min(this.start.x,this.end.x)}get y(){return Math.min(this.start.y,this.end.y)}get left(){return Math.min(this.start.x,this.end.x)}get right(){return Math.max(this.start.x,this.end.x)}get top(){return Math.min(this.start.y,this.end.y)}get bottom(){return Math.max(this.start.y,this.end.y)}get width(){return Math.abs(this.start.x-this.end.x)}get height(){return Math.abs(this.start.y-this.end.y)}get normalX(){return Math.cos(this.angle-1.5707963267948966)}get normalY(){return Math.sin(this.angle-1.5707963267948966)}get normalAngle(){return Vt(this.angle-1.5707963267948966,-Math.PI,Math.PI)}};return e})()));
3
3
  //# sourceMappingURL=phaser.js.map