!function(){vara={},b={};!function(){b._inertiaScale=4;vara=1,c=-1,d=1;b.create=function(a){varb={id:p.nextId(),type:"body",label:"Body",parts:[],angle:0,vertices:B.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,sprite:{xScale:1,yScale:1},lineWidth:1.5}},c=p.extend(b,a);returne(c,a),c},b.nextGroup=function(b){returnb?c--:a++},b.nextCategory=function(){returnd<<=1};vare=function(a,c){b.set(a,{bounds:a.bounds||y.create(a.vertices),positionPrev:a.positionPrev||A.clone(a.position),anglePrev:a.anglePrev||a.angle,vertices:a.vertices,parts:a.parts||[a],isStatic:a.isStatic,isSleeping:a.isSleeping,parent:a.parent||a}),B.rotate(a.vertices,a.angle,a.position),x.rotate(a.axes,a.angle),y.update(a.bounds,a.vertices,a.velocity),b.set(a,{axes:c.axes||a.axes,area:c.area||a.area,mass:c.mass||a.mass,inertia:c.inertia||a.inertia});vard=a.isStatic?"#eeeeee":p.choose(["#556270","#4ECDC4","#C7F464","#FF6B6B","#C44D58"]),e=p.shadeColor(d,-20);a.render.fillStyle=a.render.fillStyle||d,a.render.strokeStyle=a.render.strokeStyle||e};b.set=function(a,c,d){vare;"string"==typeofc&&(e=c,c={},c[e]=d);for(einc)if(d=c[e],c.hasOwnProperty(e))switch(e){case"isStatic":b.setStatic(a,d);break;case"isSleeping":u.set(a,d);break;case"mass":b.setMass(a,d);break;case"density":b.setDensity(a,d);break;case"inertia":b.setInertia(a,d);break;case"vertices":b.setVertices(a,d);break;case"position":b.setPosition(a,d);break;case"angle":b.setAngle(a,d);break;case"velocity":b.setVelocity(a,d);break;case"angularVelocity":b.setAngularVelocity(a,d);break;case"parts":b.setParts(a,d);break;default:a[e]=d}},b.setStatic=function(a,b){for(varc=0;c<a.parts.length;c++){vard=a.parts[c];d.isStatic=b,b&&(d.restitution=0,d.friction=1,d.mass=d.inertia=d.density=1/0,d.inverseMass=d.inverseInertia=0,d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.anglePrev=d.angle,d.angularVelocity=0,d.speed=0,d.angularSpeed=0,d.motion=0)}},b.setMass=function(a,b){a.mass=b,a.inverseMass=1/a.mass,a.density=a.mass/a.area},b.setDensity=function(a,c){b.setMass(a,c*a.area),a.density=c},b.setInertia=function(a,b){a.inertia=b,a.inverseInertia=1/a.inertia},b.setVertices=function(a,c){a.vertices=c[0].body===a?c:B.create(c,a),a.axes=x.fromVertices(a.vertices),a.area=B.area(a.vertices),b.setMass(a,a.density*a.area);vard=B.centre(a.vertices);B.translate(a.vertices,d,-1),b.setInertia(a,b._inertiaScale*B.inertia(a.vertices,a.mass)),B.translate(a.vertices,a.position),y.update(a.bounds,a.vertices,a.velocity)},b.setParts=function(a,c,d){vare;for(c=c.slice(0),a.parts.length=0,a.parts.push(a),a.parent=a,e=0;e<c.length;e++){varg=c[e];g!==a&&(g.parent=a,a.parts.push(g))}if(1!==a.parts.length){if(d="undefined"!=typeofd?d:!0){varh=[];for(e=0;e<c.length;e++)h=h.concat(c[e].vertices);B.clockwiseSort(h);vari=B.hull(h),j=B.centre(i);b.setVertices(a,i),B.translate(a.vertices,j)}vark=f(a);a.area=k.area,a.parent=a,a.position.x=k.centre.x,a.position.y=k.centre.y,a.positionPrev.x=k.centre.x,a.positionPrev.y=k.centre.y,b.setMass(a,k.mass),b.setInertia(a,k.inertia),b.setPosition(a,k.centre)}},b.setPosition=function(a,b){varc=A.sub(b,a.position);a.positionPrev.x+=c.x,a.positionPrev.y+=c.y;for(vard=0;d<a.parts.length;d++){vare=a.parts[d];e.position.x+=c.x,e.position.y+=c.y,B.translate(e.vertices,c),y.update(e.bounds,e.vertices,a.velocity)}},b.setAngle=function(a,b){varc=b-a.angle;a.anglePrev+=c;for(vard=0;d<a.parts.length;d++){vare=a.parts[d];e.angle+=c,B.rotate(e.vertices,c,a.position),x.rotate(e.axes,c),y.update(e.bounds,e.vertices,a.velocity),d>0&&A.rotateAbout(e.position,c,a.position,e.position)}},b.setVelocity=function(a,b){a.positionPrev.x=a.position.x-b.x,a.positionPrev.y=a.position.y-b.y,a.velocity.x=b.x,a.vel
returnc},r.off=function(a,b,c){if(!b)returnvoid(a.events={});"function"==typeofb&&(c=b,b=p.keys(a.events).join(" "));for(vard=b.split(" "),e=0;e<d.length;e++){varf=a.events[d[e]],g=[];if(c)for(varh=0;h<f.length;h++)f[h]!==c&&g.push(f[h]);a.events[d[e]]=g}},r.trigger=function(a,b,c){vard,e,f,g;if(a.events){c||(c={}),d=b.split(" ");for(varh=0;h<d.length;h++)if(e=d[h],f=a.events[e]){g=p.clone(c,!1),g.name=e,g.source=a;for(vari=0;i<f.length;i++)f[i].apply(a,[g])}}}}();vars={};!function(){s.create=function(b){varc={};returnb||p.log("Mouse.create: element was undefined, defaulting to document.body","warn"),c.element=b||document.body,c.absolute={x:0,y:0},c.position={x:0,y:0},c.mousedownPosition={x:0,y:0},c.mouseupPosition={x:0,y:0},c.offset={x:0,y:0},c.scale={x:1,y:1},c.wheelDelta=0,c.button=-1,c.pixelRatio=c.element.getAttribute("data-pixel-ratio")||1,c.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},c.mousemove=function(b){vard=a(b,c.element,c.pixelRatio),e=b.changedTouches;e&&(c.button=0,b.preventDefault()),c.absolute.x=d.x,c.absolute.y=d.y,c.position.x=c.absolute.x*c.scale.x+c.offset.x,c.position.y=c.absolute.y*c.scale.y+c.offset.y,c.sourceEvents.mousemove=b},c.mousedown=function(b){vard=a(b,c.element,c.pixelRatio),e=b.changedTouches;e?(c.button=0,b.preventDefault()):c.button=b.button,c.absolute.x=d.x,c.absolute.y=d.y,c.position.x=c.absolute.x*c.scale.x+c.offset.x,c.position.y=c.absolute.y*c.scale.y+c.offset.y,c.mousedownPosition.x=c.position.x,c.mousedownPosition.y=c.position.y,c.sourceEvents.mousedown=b},c.mouseup=function(b){vard=a(b,c.element,c.pixelRatio),e=b.changedTouches;e&&b.preventDefault(),c.button=-1,c.absolute.x=d.x,c.absolute.y=d.y,c.position.x=c.absolute.x*c.scale.x+c.offset.x,c.position.y=c.absolute.y*c.scale.y+c.offset.y,c.mouseupPosition.x=c.position.x,c.mouseupPosition.y=c.position.y,c.sourceEvents.mouseup=b},c.mousewheel=function(a){c.wheelDelta=Math.max(-1,Math.min(1,a.wheelDelta||-a.detail)),a.preventDefault()},s.setElement(c,c.element),c},s.setElement=function(a,b){a.element=b,b.addEventListener("mousemove",a.mousemove),b.addEventListener("mousedown",a.mousedown),b.addEventListener("mouseup",a.mouseup),b.addEventListener("mousewheel",a.mousewheel),b.addEventListener("DOMMouseScroll",a.mousewheel),b.addEventListener("touchmove",a.mousemove),b.addEventListener("touchstart",a.mousedown),b.addEventListener("touchend",a.mouseup)},s.clearSourceEvents=function(a){a.sourceEvents.mousemove=null,a.sourceEvents.mousedown=null,a.sourceEvents.mouseup=null,a.sourceEvents.mousewheel=null,a.wheelDelta=0},s.setOffset=function(a,b){a.offset.x=b.x,a.offset.y=b.y,a.position.x=a.absolute.x*a.scale.x+a.offset.x,a.position.y=a.absolute.y*a.scale.y+a.offset.y},s.setScale=function(a,b){a.scale.x=b.x,a.scale.y=b.y,a.position.x=a.absolute.x*a.scale.x+a.offset.x,a.position.y=a.absolute.y*a.scale.y+a.offset.y};vara=function(a,b,c){vard,e,f=b.getBoundingClientRect(),g=document.documentElement||document.body.parentNode||document.body,h=void0!==window.pageXOffset?window.pageXOffset:g.scrollLeft,i=void0!==window.pageYOffset?window.pageYOffset:g.scrollTop,j=a.changedTouches;returnj?(d=j[0].pageX-f.left-h,e=j[0].pageY-f.top-i):(d=a.pageX-f.left-h,e=a.pageY-f.top-i),{x:d/(b.clientWidth/b.width*c),y:e/(b.clientHeight/b.height*c)}}}();vart={};!function(){vara=60,b=a,c=1e3/a,d=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(function(){a(p.now())},c)},e=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame;t.run=function(a){varc,e=0,f=0,g=[],h=1;!functioni(j){vark,l=a.timing,m=1;if(l.frameRequestId=d(i),a.enabled){varn={timestamp:j};r.trigger(a,"beforeTick",n),l.isFixed?k=l.delta:(k=j-c||l.delta,c=j,g.push(k),g=g.slice(-b),k=Math.min.apply(null,g),k=k<l.deltaMin?l.deltaMin:k,k=k>l.deltaMax?l.deltaMax:k,m=k/l.delta,l.delta=k),0!==h&&(m*=l.timeScale/h),0===l.timeScale&&(m=0),h=l.timeScale,f+=1,j-e>=1e3&&(l.fp