!function(a){if("object"==typeofexports)module.exports=a();elseif("function"==typeofdefine,1){varb;"undefined"!=typeofwindow?b=window:"undefined"!=typeofglobal?b=global:"undefined"!=typeofself&&(b=self),b.p2=a()}elsedefine(a)}(function(){returnfunctiona(b,c,d){functione(g,h){if(!c[g]){if(!b[g]){vari="function"==typeofrequire&&require;if(!h&&i)returni(g,!0);if(f)returnf(g,!0);thrownewError("Cannot find module '"+g+"'")}varj=c[g]={exports:{}};b[g][0].call(j.exports,function(a){varc=b[g][1][a];returne(c?c:a)},j,j.exports,a,b,c,d)}returnc[g].exports}for(varf="function"==typeofrequire&&require,g=0;g<d.length;g++)e(d[g]);returne}({1:[function(a,b,c){functiond(){}vare=a("./Scalar");b.exports=d,d.lineInt=function(a,b,c){c=c||0;vard,f,g,h,i,j,k,l=[0,0];returnd=a[1][1]-a[0][1],f=a[0][0]-a[1][0],g=d*a[0][0]+f*a[0][1],h=b[1][1]-b[0][1],i=b[0][0]-b[1][0],j=h*b[0][0]+i*b[0][1],k=d*i-h*f,e.eq(k,0,c)||(l[0]=(i*g-f*j)/k,l[1]=(d*j-h*g)/k),l},d.segmentsIntersect=function(a,b,c,d){vare=b[0]-a[0],f=b[1]-a[1],g=d[0]-c[0],h=d[1]-c[1];if(g*f-h*e==0)return!1;vari=(e*(c[1]-a[1])+f*(a[0]-c[0]))/(g*f-h*e),j=(g*(a[1]-c[1])+h*(c[0]-a[0]))/(h*e-g*f);returni>=0&&1>=i&&j>=0&&1>=j}},{"./Scalar":4}],2:[function(a,b,c){functiond(){}b.exports=d,d.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},d.left=function(a,b,c){returnd.area(a,b,c)>0},d.leftOn=function(a,b,c){returnd.area(a,b,c)>=0},d.right=function(a,b,c){returnd.area(a,b,c)<0},d.rightOn=function(a,b,c){returnd.area(a,b,c)<=0};vare=[],f=[];d.collinear=function(a,b,c,g){if(g){varh=e,i=f;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=c[0]-b[0],i[1]=c[1]-b[1];varj=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.acos(j/(k*l));returng>m}return0==d.area(a,b,c)},d.sqdist=function(a,b){varc=b[0]-a[0],d=b[1]-a[1];returnc*c+d*d}},{}],3:[function(a,b,c){functiond(){this.vertices=[]}functione(a,b,c,d,e){e=e||0;varf=b[1]-a[1],g=a[0]-b[0],i=f*a[0]+g*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*g;returnh.eq(m,0,e)?[0,0]:[(k*i-g*l)/m,(f*l-j*i)/m]}varf=a("./Line"),g=a("./Point"),h=a("./Scalar");b.exports=d,d.prototype.at=function(a){varb=this.vertices,c=b.length;returnb[0>a?a%c+c:a%c]},d.prototype.first=function(){returnthis.vertices[0]},d.prototype.last=function(){returnthis.vertices[this.vertices.length-1]},d.prototype.clear=function(){this.vertices.length=0},d.prototype.append=function(a,b,c){if("undefined"==typeofb)thrownewError("From is not given!");if("undefined"==typeofc)thrownewError("To is not given!");if(b>c-1)thrownewError("lol1");if(c>a.vertices.length)thrownewError("lol2");if(0>b)thrownewError("lol3");for(vard=b;c>d;d++)this.vertices.push(a.vertices[d])},d.prototype.makeCCW=function(){for(vara=0,b=this.vertices,c=1;c<this.vertices.length;++c)(b[c][1]<b[a][1]||b[c][1]==b[a][1]&&b[c][0]>b[a][0])&&(a=c);g.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},d.prototype.reverse=function(){for(vara=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},d.prototype.isReflex=function(a){returng.right(this.at(a-1),this.at(a),this.at(a+1))};vari=[],j=[];d.prototype.canSee=function(a,b){varc,d,e=i,h=j;if(g.leftOn(this.at(a+1),this.at(a),this.at(b))&&g.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=g.sqdist(this.at(a),this.at(b));for(vark=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&g.leftOn(this.at(a),this.at(b),this.at(k+1))&&g.rightOn(this.at(a),this.at(b),this.at(k))&&(e[0]=this.at(a),e[1]=this.at(b),h[0]=this.at(k),h[1]=this.at(k+1),c=f.lineInt(e,h),g.sqdist(this.at(a),c)<d))return!1;return!0},d.prototype.copy=function(a,b,c){vare=c||newd;if(e.clear(),b>a)for(varf=a;b>=f;f++)e.vertices.push(this.vertices[f]);else{for(varf=0;b>=f;f++)e.vertices.push(this.vertices[f]);for(varf=a;f<this.vertices.length;f++)e.vertices.push(this.vertices[f])}returne},d.prototype.getCutEdges=function(){for(vara=[],b=[],c=[],e=newd,f=Number.MAX_VALUE,g=0;g<this.vertices.length;++g)if(this.isReflex(g))for(varh=0;h<thi
this.allowSleep=void0!==a.allowSleep?a.allowSleep:!0,this.wantsToSleep=!1,this.sleepState=d.AWAKE,this.sleepSpeedLimit=void0!==a.sleepSpeedLimit?a.sleepSpeedLimit:.2,this.sleepTimeLimit=void0!==a.sleepTimeLimit?a.sleepTimeLimit:1,this.gravityScale=void0!==a.gravityScale?a.gravityScale:1,this.collisionResponse=void0!==a.collisionResponse?a.collisionResponse:!0,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void0!==a.ccdSpeedThreshold?a.ccdSpeedThreshold:-1,this.ccdIterations=void0!==a.ccdIterations?a.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}vare=a("../math/vec2"),f=a("poly-decomp"),g=a("../shapes/Convex"),h=a("../collision/RaycastResult"),i=a("../collision/Ray"),j=a("../collision/AABB"),k=a("../events/EventEmitter");b.exports=d,d.prototype=newk,d.prototype.constructor=d,d._idCounter=0,d.prototype.updateSolveMassProperties=function(){this.sleepState===d.SLEEPING||this.type===d.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},d.prototype.setDensity=function(a){varb=this.getArea();this.mass=b*a,this.updateMassProperties()},d.prototype.getArea=function(){for(vara=0,b=0;b<this.shapes.length;b++)a+=this.shapes[b].area;returna},d.prototype.getAABB=function(){returnthis.aabbNeedsUpdate&&this.updateAABB(),this.aabb};varl=newj,m=e.create();d.prototype.updateAABB=function(){for(vara=this.shapes,b=a.length,c=m,d=this.angle,f=0;f!==b;f++){varg=a[f],h=g.angle+d;e.rotate(c,g.position,d),e.add(c,c,this.position),g.computeAABB(l,c,h),0===f?this.aabb.copy(l):this.aabb.extend(l)}this.aabbNeedsUpdate=!1},d.prototype.updateBoundingRadius=function(){for(vara=this.shapes,b=a.length,c=0,d=0;d!==b;d++){varf=a[d],g=e.length(f.position),h=f.boundingRadius;g+h>c&&(c=g+h)}this.boundingRadius=c},d.prototype.addShape=function(a,b,c){if(a.body)thrownewError("A shape can only be added to one body.");a.body=this,b?e.copy(a.position,b):e.set(a.position,0,0),a.angle=c||0,this.shapes.push(a),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},d.prototype.removeShape=function(a){varb=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.aabbNeedsUpdate=!0,a.body=null,!0):!1},d.prototype.updateMassProperties=function(){if(this.type===d.STATIC||this.type===d.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{vara=this.shapes,b=a.length,c=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(varg=0;b>g;g++){varh=a[g],i=e.squaredLength(h.position),j=h.computeMomentOfInertia(c);f+=j+c*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass,e.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};e.create();d.prototype.applyForce=function(a,b){if(e.add(this.force,this.force,a),b){varc=e.crossLength(b,a);this.angularForce+=c}};varn=e.create(),o=e.create(),p=e.create();d.prototype.applyForceLocal=function(a,b){b=b||p;varc=n,d=o;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyForce(c,d)};varq=e.create();d.prototype.applyImpulse=function(a,b){if(this.type===d.DYNAMIC){varc=q;if(e.scale(c,a,this.invMass),e.multiply(c,this.massMultiplier,c),e.add(this.velocity,c,this.velocity),b){varf=e.crossLength(b,a);f*=this.invInertia,this.angularVelocity+=f}}};varr=e.create(),s=e.create(),t=e.create();d.prototype.applyImpulseLocal=function(a,b){b=b||t;varc=r,d=s;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyImpulse(c,d)},d.prototype.toLocalFrame=function(a,b){e.toLocalFrame(a,b,this.position,this.angle)},d.prototype.toWorldFrame=function(a,b){e.toGlobalFrame(a,b,this.position,this.angle)},d.prototype.vectorToLocalFrame=function(a,b){e.vectorToLocalFrame(a,b,this.angle)},d.prototype.vectorToWorldFrame=function(a,b){e.vectorToGlobalFrame(a,b,this.angle)},d.prototype.fromPolygon=function(a,b){b=b||{};for(varc=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);vard=newf.Polygon;if(d.vertices=a,d.makeCCW(
}functione(a){for(varb=a.length;b--;)a[b]=0}varf=a("../math/vec2"),g=a("./Solver"),h=a("../utils/Utils"),i=a("../equations/FrictionEquation");b.exports=d,d.prototype=newg,d.prototype.constructor=d,d.prototype.solve=function(a,b){this.sortEquations();varc=0,g=this.iterations,j=this.frictionIterations,k=this.equations,l=k.length,m=Math.pow(this.tolerance*l,2),n=b.bodies,o=b.bodies.length,p=(f.add,f.set,this.useZeroRHS),q=this.lambda;if(this.usedIterations=0,l)for(varr=0;r!==o;r++){vars=n[r];s.updateSolveMassProperties()}q.length<l&&(q=this.lambda=newh.ARRAY_TYPE(l+this.arrayStep),this.Bs=newh.ARRAY_TYPE(l+this.arrayStep),this.invCs=newh.ARRAY_TYPE(l+this.arrayStep)),e(q);for(vart=this.invCs,u=this.Bs,q=this.lambda,r=0;r!==k.length;r++){varv=k[r];(v.timeStep!==a||v.needsUpdate)&&(v.timeStep=a,v.update()),u[r]=v.computeB(v.a,v.b,a),t[r]=v.computeInvC(v.epsilon)}varv,w,r,x;if(0!==l){for(r=0;r!==o;r++){vars=n[r];s.resetConstraintVelocity()}if(j){for(c=0;c!==j;c++){for(w=0,x=0;x!==l;x++){v=k[x];vary=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(d.updateMultipliers(k,q,1/a),x=0;x!==l;x++){varz=k[x];if(zinstanceofi){for(varA=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(c=0;c!==g;c++){for(w=0,x=0;x!==l;x++){v=k[x];vary=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();d.updateMultipliers(k,q,1/a)}},d.updateMultipliers=function(a,b,c){for(vard=a.length;d--;)a[d].multiplier=b[d]*c},d.iterateEquation=function(a,b,c,d,e,f,g,h,i){varj=d[a],k=e[a],l=f[a],m=b.computeGWlambda(),n=b.maxForce,o=b.minForce;g&&(j=0);varp=k*(j-m-c*l),q=l+p;returno*h>q?p=o*h-l:q>n*h&&(p=n*h-l),f[a]+=p,b.addToWlambda(p),p}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(a,b,c){functiond(a,b){a=a||{},e.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}vare=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=d,d.prototype=newe,d.prototype.constructor=d,d.prototype.solve=function(a,b){thrownewError("Solver.solve should be implemented by subclasses!")};varf={bodies:[]};d.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),f.bodies.length=0,b.getBodies(f.bodies),f.bodies.length&&this.solve(a,f))},d.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},d.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},d.prototype.addEquations=function(a){for(varb=0,c=a.length;b!==c;b++){vard=a[b];d.enabled&&this.equations.push(d)}},d.prototype.removeEquation=function(a){varb=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},d.prototype.removeAllEquations=function(){this.equations.length=0},d.GS=1,d.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(a,b,c){functiond(){f.apply(this,arguments)}vare=a("../equations/ContactEquation"),f=a("./Pool");b.exports=d,d.prototype=newf,d.prototype.constructor=d,d.prototype.create=function(){returnnewe},d.prototype.destroy=function(a){returna.bodyA=a.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(a,b,c){functiond(){f.apply(this,arguments)}vare=a("../equations/FrictionEquation"),f=a("./Pool");b.exports=d,d.prototype=newf,d.prototype.constructor=d,d.prototype.create=function(){returnnewe},d.prototype.destroy=function(a){returna.bodyA=a.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(a,b,c){functiond(){f.apply(this,arguments)}vare=a("../world/IslandNode"),f=a("./Pool");b.exports=d,d.prototype=newf,d.prototype.constructor=d,d.prototype.create=function(){returnnewe},d.prototype.destroy=function(a){returna.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(a,b,c){functiond(){f.apply(th
varb=this.children.indexOf(a);if(-1===b)thrownewError("The supplied DisplayObject must be a child of the caller");returnb},b.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(0>b||b>=this.children.length)thrownewError("The supplied index is out of bounds");varc=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},b.DisplayObjectContainer.prototype.getChildAt=function(a){if(0>a||a>=this.children.length)thrownewError("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");returnthis.children[a]},b.DisplayObjectContainer.prototype.removeChild=function(a){varb=this.children.indexOf(a);if(-1!==b)returnthis.removeChildAt(b)},b.DisplayObjectContainer.prototype.removeChildAt=function(a){varb=this.getChildAt(a);returnthis.stage&&b.removeStageReference(),b.parent=void0,this.children.splice(a,1),b},b.DisplayObjectContainer.prototype.removeChildren=function(a,b){varc=a||0,d="number"==typeofb?b:this.children.length,e=d-c;if(e>0&&d>=e){for(varf=this.children.splice(c,e),g=0;g<f.length;g++){varh=f[g];this.stage&&h.removeStageReference(),h.parent=void0}returnf}if(0===e&&0===this.children.length)return[];thrownewError("removeChildren: Range Error, numeric values are outside the acceptable range")},b.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(vara=0;a<this.children.length;a++)this.children[a].updateTransform()},b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=b.DisplayObjectContainer.prototype.updateTransform,b.DisplayObjectContainer.prototype.getBounds=function(){if(0===this.children.length)returnb.EmptyRectangle;for(vara,c,d,e=1/0,f=1/0,g=-(1/0),h=-(1/0),i=!1,j=0;j<this.children.length;j++){vark=this.children[j];k.visible&&(i=!0,a=this.children[j].getBounds(),e=e<a.x?e:a.x,f=f<a.y?f:a.y,c=a.width+a.x,d=a.height+a.y,g=g>c?g:c,h=h>d?h:d)}if(!i)returnb.EmptyRectangle;varl=this._bounds;returnl.x=e,l.y=f,l.width=g-e,l.height=h-f,l},b.DisplayObjectContainer.prototype.getLocalBounds=function(){vara=this.worldTransform;this.worldTransform=b.identityMatrix;for(varc=0;c<this.children.length;c++)this.children[c].updateTransform();vard=this.getBounds();for(this.worldTransform=a,c=0;c<this.children.length;c++)this.children[c].updateTransform();returnd},b.DisplayObjectContainer.prototype.setStageReference=function(a){this.stage=a;for(varb=0;b<this.children.length;b++)this.children[b].setStageReference(a)},b.DisplayObjectContainer.prototype.removeStageReference=function(){for(vara=0;a<this.children.length;a++)this.children[a].removeStageReference();this.stage=null},b.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)returnvoidthis._renderCachedSprite(a);varb;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}elsefor(b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a)}},b.DisplayObjectContainer.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)returnvoidthis._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(varb=0;b<this.children.length;b++)this.children[b]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Sprite=function(a){b.DisplayObjectContainer.call(this),this.anchor=newb.Point,this.texture=a||b.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=b.blendModes.NORMAL,this.shader=null,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},b.Sprite.prototype=Object.create(
this.frame.height=this.trim.height),this.valid&&this._updateUvs()},b.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=newb.TextureUvs);vara=this.crop,c=this.baseTexture.width,d=this.baseTexture.height;this._uvs.x0=a.x/c,this._uvs.y0=a.y/d,this._uvs.x1=(a.x+a.width)/c,this._uvs.y1=a.y/d,this._uvs.x2=(a.x+a.width)/c,this._uvs.y2=(a.y+a.height)/d,this._uvs.x3=a.x/c,this._uvs.y3=(a.y+a.height)/d},b.Texture.fromImage=function(a,c,d){vare=b.TextureCache[a];returne||(e=newb.Texture(b.BaseTexture.fromImage(a,c,d)),b.TextureCache[a]=e),e},b.Texture.fromFrame=function(a){varc=b.TextureCache[a];if(!c)thrownewError('The frameId "'+a+'" does not exist in the texture cache ');returnc},b.Texture.fromCanvas=function(a,c){vard=b.BaseTexture.fromCanvas(a,c);returnnewb.Texture(d)},b.Texture.addTextureToCache=function(a,c){b.TextureCache[c]=a},b.Texture.removeTextureFromCache=function(a){varc=b.TextureCache[a];returndeleteb.TextureCache[a],deleteb.BaseTextureCache[a],c},b.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},b.RenderTexture=function(a,c,d,e,f){if(this.width=a||100,this.height=c||100,this.resolution=f||1,this.frame=newb.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=newb.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=newb.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||b.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,b.Texture.call(this,this.baseTexture,newb.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=d||b.defaultRenderer,this.renderer.type===b.WEBGL_RENDERER){varg=this.renderer.gl;this.baseTexture._dirty[g.id]=!1,this.textureBuffer=newb.FilterTexture(g,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[g.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=newb.Point(.5*this.width,.5*-this.height)}elsethis.render=this.renderCanvas,this.textureBuffer=newb.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=newPhaser.Matrix,this._updateUvs()},b.RenderTexture.prototype=Object.create(b.Texture.prototype),b.RenderTexture.prototype.constructor=b.RenderTexture,b.RenderTexture.prototype.resize=function(a,c,d){(a!==this.width||c!==this.height)&&(this.valid=a>0&&c>0,this.width=a,this.height=c,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=c*this.resolution,d&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===b.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},b.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===b.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},b.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid&&0!==a.alpha){vard=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1);for(vare=0;e<a.children.length;e++)a.children[e].updateTransform();varf=this.renderer.gl;f.viewport(0,0,this.width*this.resolution,this.height*this.resolution),f.bindFramebuffer(f.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer,b),this.renderer.spriteBatch.dirty=!0}},b.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid&&0!==a.alpha){vard=a.worldTransform;d.identity(),b&&d.append(b);for(vare=0;e<a.children.length;e++)a.children[e].updateTransform();c&&this.textureBuffer.clear();varf=this.renderer.resolut
},getSound:function(a){returnthis.getItem(a,c.Cache.SOUND,"getSound")},getSoundData:function(a){returnthis.getItem(a,c.Cache.SOUND,"getSoundData","data")},getText:function(a){returnthis.getItem(a,c.Cache.TEXT,"getText","data")},getPhysicsData:function(a,b,d){vare=this.getItem(a,c.Cache.PHYSICS,"getPhysicsData","data");if(null===e||void0===b||null===b)returne;if(e[b]){varf=e[b];if(!f||!d)returnf;for(varginf)if(g=f[g],g.fixtureKey===d)returng;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+d+" in "+a+'"')}elseconsole.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+a+" / "+b+'"');returnnull},getTilemapData:function(a){returnthis.getItem(a,c.Cache.TILEMAP,"getTilemapData")},getBinary:function(a){returnthis.getItem(a,c.Cache.BINARY,"getBinary")},getBitmapData:function(a){returnthis.getItem(a,c.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(a){returnthis.getItem(a,c.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(a,b){vard=this.getItem(a,c.Cache.JSON,"getJSON","data");returnd?b?c.Utils.extend(!0,{},d):d:null},getXML:function(a){returnthis.getItem(a,c.Cache.XML,"getXML","data")},getVideo:function(a){returnthis.getItem(a,c.Cache.VIDEO,"getVideo")},getShader:function(a){returnthis.getItem(a,c.Cache.SHADER,"getShader","data")},getRenderTexture:function(a){returnthis.getItem(a,c.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(a,b){returnvoid0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getBaseTexture","base")},getFrame:function(a,b){returnvoid0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrame","frame")},getFrameCount:function(a,b){varc=this.getFrameData(a,b);returnc?c.total:0},getFrameData:function(a,b){returnvoid0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrameData","frameData")},hasFrameData:function(a,b){returnvoid0===b&&(b=c.Cache.IMAGE),null!==this.getItem(a,b,"","frameData")},updateFrameData:function(a,b,d){void0===d&&(d=c.Cache.IMAGE),this._cacheMap[d][a]&&(this._cacheMap[d][a].frameData=b)},getFrameByIndex:function(a,b,c){vard=this.getFrameData(a,c);returnd?d.getFrame(b):null},getFrameByName:function(a,b,c){vard=this.getFrameData(a,c);returnd?d.getFrameByName(b):null},getPixiTexture:function(a){if(PIXI.TextureCache[a])returnPIXI.TextureCache[a];varb=this.getPixiBaseTexture(a);returnb?newPIXI.Texture(b):null},getPixiBaseTexture:function(a){if(PIXI.BaseTextureCache[a])returnPIXI.BaseTextureCache[a];varb=this.getItem(a,c.Cache.IMAGE,"getPixiBaseTexture");returnnull!==b?b.base:null},getURL:function(a){vara=this._resolveURL(a);returna?this._urlMap[a]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+a+'" or Cache.autoResolveURL was false'),null)},getKeys:function(a){void0===a&&(a=c.Cache.IMAGE);varb=[];if(this._cacheMap[a])for(vardinthis._cacheMap[a])"__default"!==d&&"__missing"!==d&&b.push(d);returnb},removeCanvas:function(a){deletethis._cache.canvas[a]},removeImage:function(a,b){void0===b&&(b=!0);varc=this.getImage(a,!0);b&&c.base&&c.base.destroy(),deletethis._cache.image[a]},removeSound:function(a){deletethis._cache.sound[a]},removeText:function(a){deletethis._cache.text[a]},removePhysics:function(a){deletethis._cache.physics[a]},removeTilemap:function(a){deletethis._cache.tilemap[a]},removeBinary:function(a){deletethis._cache.binary[a]},removeBitmapData:function(a){deletethis._cache.bitmapData[a]},removeBitmapFont:function(a){deletethis._cache.bitmapFont[a]},removeJSON:function(a){deletethis._cache.json[a]},removeXML:function(a){deletethis._cache.xml[a]},removeVideo:function(a){deletethis._cache.video[a]},removeShader:function(a){deletethis._cache.shader[a]},removeRenderTexture:function(a){deletethis._cache.renderTexture[a]},removeSpriteSheet:function(a){deletethis._cache.spriteSheet[a]},removeTextureAtlas:function(a){deletethis._cache.atlas[a]},clearGLTextures:function(){for(varainthis._cache.image)this._cache.image[a].base._glTextures=[]},_resolveURL:function(a,b){returnthis.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+a,this._urlTemp=this._urlResolv
},startSystem:function(a){a===c.Physics.ARCADE?this.arcade=newc.Physics.Arcade(this.game):a===c.Physics.P2JS?null===this.p2?this.p2=newc.Physics.P2(this.game,this.config):this.p2.reset():a===c.Physics.NINJA?this.ninja=newc.Physics.Ninja(this.game):a===c.Physics.BOX2D?null===this.box2d?this.box2d=newc.Physics.Box2D(this.game,this.config):this.box2d.reset():a===c.Physics.MATTERJS&&(null===this.matter?this.matter=newc.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(a,b,d){void0===b&&(b=c.Physics.ARCADE),void0===d&&(d=!1),b===c.Physics.ARCADE?this.arcade.enable(a):b===c.Physics.P2JS&&this.p2?this.p2.enable(a,d):b===c.Physics.NINJA&&this.ninja?this.ninja.enableAABB(a):b===c.Physics.BOX2D&&this.box2d?this.box2d.enable(a):b===c.Physics.MATTERJS&&this.matter?this.matter.enable(a):console.warn(a.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},c.Physics.prototype.constructor=c.Physics,c.Physics.Arcade=function(a){this.game=a,this.gravity=newc.Point,this.bounds=newc.Rectangle(0,0,a.world.width,a.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=c.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=newc.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},c.Physics.Arcade.prototype.constructor=c.Physics.Arcade,c.Physics.Arcade.SORT_NONE=0,c.Physics.Arcade.LEFT_RIGHT=1,c.Physics.Arcade.RIGHT_LEFT=2,c.Physics.Arcade.TOP_BOTTOM=3,c.Physics.Arcade.BOTTOM_TOP=4,c.Physics.Arcade.prototype={setBounds:function(a,b,c,d){this.bounds.setTo(a,b,c,d)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(a,b){void0===b&&(b=!0);vard=1;if(Array.isArray(a))for(d=a.length;d--;)a[d]instanceofc.Group?this.enable(a[d].children,b):(this.enableBody(a[d]),b&&a[d].hasOwnProperty("children")&&a[d].children.length>0&&this.enable(a[d],!0));elseainstanceofc.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&a.children.length>0&&this.enable(a.children,!0))},enableBody:function(a){a.hasOwnProperty("body")&&null===a.body&&(a.body=newc.Physics.Arcade.Body(a),a.parent&&a.parentinstanceofc.Group&&a.parent.addToHash(a))},updateMotion:function(a){varb=this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity;a.angularVelocity+=b,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.velocity.x=this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x),a.velocity.y=this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)},computeVelocity:function(a,b,c,d,e,f){returnvoid0===f&&(f=1e4),1===a&&b.allowGravity?c+=(this.gravity.x+b.gravity.x)*this.game.time.physicsElapsed:2===a&&b.allowGravity&&(c+=(this.gravity.y+b.gravity.y)*this.game.time.physicsElapsed),d?c+=d*this.game.time.physicsElapsed:e&&(e*=this.game.time.physicsElapsed,c-e>0?c-=e:0>c+e?c+=e:c=0),c>f?c=f:-f>c&&(c=-f),c},overlap:funct
c&&this.walls.right&&(this.walls.right.shapes[0].material=a),d&&this.walls.top&&(this.walls.top.shapes[0].material=a),e&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=a)},updateBoundsCollisionGroup:function(a){void0===a&&(a=!0);varb=a?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=b),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=b),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=b),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=b),this._boundsOwnGroup=a},setBounds:function(a,b,c,d,e,f,g,h,i){void0===e&&(e=this._boundsLeft),void0===f&&(f=this._boundsRight),void0===g&&(g=this._boundsTop),void0===h&&(h=this._boundsBottom),void0===i&&(i=this._boundsOwnGroup),this.setupWall(e,"left",a,b,1.5707963267948966,i),this.setupWall(f,"right",a+c,b,-1.5707963267948966,i),this.setupWall(g,"top",a,b,-3.141592653589793,i),this.setupWall(h,"bottom",a,b+d,0,i),this._boundsLeft=e,this._boundsRight=f,this._boundsTop=g,this._boundsBottom=h,this._boundsOwnGroup=i},setupWall:function(a,b,c,d,e,f){a?this.walls[b]?this.walls[b].position=[this.pxmi(c),this.pxmi(d)]:(this.walls[b]=newp2.Body({mass:0,position:[this.pxmi(c),this.pxmi(d)],angle:e}),this.walls[b].addShape(newp2.Plane),f&&(this.walls[b].shapes[0].collisionGroup=this.boundsCollisionGroup.mask),this.world.addBody(this.walls[b])):this.walls[b]&&(this.world.removeBody(this.walls[b]),this.walls[b]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=newc.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=newc.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=newc.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(vara=this.world.constraints,b=a.length-1;b>=0;b--)this.world.removeConstraint(a[b]);for(varc=this.world.bodies,b=c.length-1;b>=0;b--)this.world.removeBody(c[b]);for(vard=this.world.springs,b=d.length-1;b>=0;b--)this.world.removeSpring(d[b]);for(vare=this.world.contactMaterials,b=e.length-1;b>=0;b--)this.world.removeContactMaterial(e[b]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[]},destroy:function(){this.clear(),this.game=null},addBody:function(a){returna.data.world?!1:(this.world.addBody(a.data),this.onBodyAdded.dispatch(a),!0)},removeBody:function(a){returna.data.world==this.world&&(this.world.removeBody(a.data),this.onBodyRemoved.dispatch(a)),a},addSpring:function(a){returnainstanceofc.Physics.P2.Spring||ainstanceofc.Physics.P2.RotationalSpring?this.world.addSpring(a.data):this.world.addSpring(a),this.onSpringAdded.dispatch(a),a},removeSpring:function(a){returnainstanceofc.Physics.P2.Spring||ainstanceofc.Physics.P2.RotationalSpring?this.world.removeSpring(a.data):this.world.removeSpring(a),this.onSpringRemoved.dispatch(a),a},createDistanceConstraint:function(a,b,d,e,f,g){returna=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(newc.Physics.P2.DistanceConstraint(this,a,b,d,e,f,g)):voidconsole.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(a,b,d,e){returna=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(newc.Physics.P2.GearConstraint(this,a,b,d,e)):voidconsole.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(a,b,d,e,f,g){returna=this.getBody(a),d=this.getBody(d)
for(i.strokeStyle=this.debugSettings.facingEdgeStroke,d=w,f=s-r,b=u;f>=0;d++,f--,b+=o){d>=m&&(d-=m);varx=this.layer.data[d];for(c=v,e=q-p,a=t;e>=0;c++,e--,a+=n){c>=l&&(c-=l);vary=x[c];!y||y.index<0||!y.collides||(this.debugSettings.collidingTileOverfill&&(i.fillStyle=this.debugSettings.collidingTileOverfill,i.fillRect(a,b,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(i.beginPath(),y.faceTop&&(i.moveTo(a,b),i.lineTo(a+this._mc.cw,b)),y.faceBottom&&(i.moveTo(a,b+this._mc.ch),i.lineTo(a+this._mc.cw,b+this._mc.ch)),y.faceLeft&&(i.moveTo(a,b),i.lineTo(a,b+this._mc.ch)),y.faceRight&&(i.moveTo(a+this._mc.cw,b),i.lineTo(a+this._mc.cw,b+this._mc.ch)),i.stroke()))}}},Object.defineProperty(c.TilemapLayer.prototype,"wrap",{get:function(){returnthis._wrap},set:function(a){this._wrap=a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollX",{get:function(){returnthis._scrollX},set:function(a){this._scrollX=a}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollY",{get:function(){returnthis._scrollY},set:function(a){this._scrollY=a}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionWidth",{get:function(){returnthis._mc.cw},set:function(a){this._mc.cw=0|a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionHeight",{get:function(){returnthis._mc.ch},set:function(a){this._mc.ch=0|a,this.dirty=!0}}),c.TilemapParser={INSERT_NULL:!1,parse:function(a,b,d,e,f,g){if(void0===d&&(d=32),void0===e&&(e=32),void0===f&&(f=10),void0===g&&(g=10),void0===b)returnthis.getEmptyData();if(null===b)returnthis.getEmptyData(d,e,f,g);varh=a.cache.getTilemapData(b);if(h){if(h.format===c.Tilemap.CSV)returnthis.parseCSV(b,h.data,d,e);if(!h.format||h.format===c.Tilemap.TILED_JSON)returnthis.parseTiledJSON(h.data)}elseconsole.warn("Phaser.TilemapParser.parse - No map data found for key "+b)},parseCSV:function(a,b,d,e){varf=this.getEmptyData();b=b.trim();for(varg=[],h=b.split("\n"),i=h.length,j=0,k=0;k<h.length;k++){g[k]=[];for(varl=h[k].split(","),m=0;m<l.length;m++)g[k][m]=newc.Tile(f.layers[0],parseInt(l[m],10),m,k,d,e);0===j&&(j=l.length)}returnf.format=c.Tilemap.CSV,f.name=a,f.width=j,f.height=i,f.tileWidth=d,f.tileHeight=e,f.widthInPixels=j*d,f.heightInPixels=i*e,f.layers[0].width=j,f.layers[0].height=i,f.layers[0].widthInPixels=f.widthInPixels,f.layers[0].heightInPixels=f.heightInPixels,f.layers[0].data=g,f},getEmptyData:function(a,b,c,d){vare={};e.width=0,e.height=0,e.tileWidth=0,e.tileHeight=0,"undefined"!=typeofa&&null!==a&&(e.tileWidth=a),"undefined"!=typeofb&&null!==b&&(e.tileHeight=b),"undefined"!=typeofc&&null!==c&&(e.width=c),"undefined"!=typeofd&&null!==d&&(e.height=d),e.orientation="orthogonal",e.version="1",e.properties={},e.widthInPixels=0,e.heightInPixels=0;varf=[],g={name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]};returnf.push(g),e.layers=f,e.images=[],e.objects={},e.collision={},e.tilesets=[],e.tiles=[],e},parseTiledJSON:function(a){functionb(a,b){varc={};for(vardinb){vare=b[d];"undefined"!=typeofa[e]&&(c[e]=a[e])}returnc}if("orthogonal"!==a.orientation)returnconsole.warn("TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser"),null;vard={};d.width=a.width,d.height=a.height,d.tileWidth=a.tilewidth,d.tileHeight=a.tileheight,d.orientation=a.orientation,d.format=c.Tilemap.TILED_JSON,d.version=a.version,d.properties=a.properties,d.widthInPixels=d.width*d.tileWidth,d.heightInPixels=d.height*d.tileHeight;for(vare=[],f=0;f<a.layers.length;f++)if("tilelayer"===a.layers[f].type){varg=a.layers[f];if(!g.compression&&g.encoding&&"base64"===g.encoding){for(varh=window.atob(g.data),i=h.length,j=newArray(i),k=0;i>k;k+=4)j[k/4]=(h.charCodeAt(k)|h.charCodeAt(k+1)<<8|h.charCodeAt(k+2)<<16|h.charCodeAt(k+3)<<24)>>>0;g.data=j,deleteg.encoding}elseif(g.compression){console.warn("TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer '"+g.name+"'");continue}varl={name:g.name,x:g.x,y:g.y,