claude-cup 0.4.0 → 0.4.1
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/web/app.js +1 -1
- package/dist/web/index.html +2 -2
- package/mcp-server/dist/mcp-server.mjs +1 -1
- package/package.json +1 -1
- package/scripts/build-mcp-launcher.mjs +1 -1
- package/src/cli.js +8 -7
- package/src/eco.js +1 -1
- package/src/statusline.js +2 -2
- package/src/usage-api.js +3 -3
package/dist/web/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var rt=Object.create;var be=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var vt=(g,T)=>()=>(T||g((T={exports:{}}).exports,T),T.exports);var ht=(g,T,f,e)=>{if(T&&typeof T=="object"||typeof T=="function")for(let n of ft(T))!ut.call(g,n)&&n!==f&&be(g,n,{get:()=>T[n],enumerable:!(e=lt(T,n))||e.enumerable});return g};var gt=(g,T,f)=>(f=g!=null?rt(ct(g)):{},ht(T||!g||!g.__esModule?be(f,"default",{value:g,enumerable:!0}):f,g));var $e=vt((ae,ye)=>{(function(T,f){typeof ae=="object"&&typeof ye=="object"?ye.exports=f():typeof define=="function"&&define.amd?define("Matter",[],f):typeof ae=="object"?ae.Matter=f():T.Matter=f()})(ae,function(){return(function(g){var T={};function f(e){if(T[e])return T[e].exports;var n=T[e]={i:e,l:!1,exports:{}};return g[e].call(n.exports,n,n.exports,f),n.l=!0,n.exports}return f.m=g,f.c=T,f.d=function(e,n,a){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:a})},f.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(n&1&&(e=f(e)),n&8||n&4&&typeof e=="object"&&e&&e.__esModule)return e;var a=Object.create(null);if(f.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),n&2&&typeof e!="string")for(var s in e)f.d(a,s,function(u){return e[u]}.bind(null,s));return a},f.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f(f.s=20)})([(function(g,T){var f={};g.exports=f,(function(){f._baseDelta=1e3/60,f._nextId=0,f._seed=0,f._nowStartTime=+new Date,f._warnedOnce={},f._decomp=null,f.extend=function(n,a){var s,u,i;typeof a=="boolean"?(s=2,i=a):(s=1,i=!0);for(var v=s;v<arguments.length;v++){var l=arguments[v];if(l)for(var t in l)i&&l[t]&&l[t].constructor===Object&&(!n[t]||n[t].constructor===Object)?(n[t]=n[t]||{},f.extend(n[t],i,l[t])):n[t]=l[t]}return n},f.clone=function(n,a){return f.extend({},a,n)},f.keys=function(n){if(Object.keys)return Object.keys(n);var a=[];for(var s in n)a.push(s);return a},f.values=function(n){var a=[];if(Object.keys){for(var s=Object.keys(n),u=0;u<s.length;u++)a.push(n[s[u]]);return a}for(var i in n)a.push(n[i]);return a},f.get=function(n,a,s,u){a=a.split(".").slice(s,u);for(var i=0;i<a.length;i+=1)n=n[a[i]];return n},f.set=function(n,a,s,u,i){var v=a.split(".").slice(u,i);return f.get(n,a,0,-1)[v[v.length-1]]=s,s},f.shuffle=function(n){for(var a=n.length-1;a>0;a--){var s=Math.floor(f.random()*(a+1)),u=n[a];n[a]=n[s],n[s]=u}return n},f.choose=function(n){return n[Math.floor(f.random()*n.length)]},f.isElement=function(n){return typeof HTMLElement<"u"?n instanceof HTMLElement:!!(n&&n.nodeType&&n.nodeName)},f.isArray=function(n){return Object.prototype.toString.call(n)==="[object Array]"},f.isFunction=function(n){return typeof n=="function"},f.isPlainObject=function(n){return typeof n=="object"&&n.constructor===Object},f.isString=function(n){return toString.call(n)==="[object String]"},f.clamp=function(n,a,s){return n<a?a:n>s?s:n},f.sign=function(n){return n<0?-1:1},f.now=function(){if(typeof window<"u"&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-f._nowStartTime},f.random=function(n,a){return n=typeof n<"u"?n:0,a=typeof a<"u"?a:1,n+e()*(a-n)};var e=function(){return f._seed=(f._seed*9301+49297)%233280,f._seed/233280};f.colorToNumber=function(n){return n=n.replace("#",""),n.length==3&&(n=n.charAt(0)+n.charAt(0)+n.charAt(1)+n.charAt(1)+n.charAt(2)+n.charAt(2)),parseInt(n,16)},f.logLevel=1,f.log=function(){console&&f.logLevel>0&&f.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.info=function(){console&&f.logLevel>0&&f.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.warn=function(){console&&f.logLevel>0&&f.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.warnOnce=function(){var n=Array.prototype.slice.call(arguments).join(" ");f._warnedOnce[n]||(f.warn(n),f._warnedOnce[n]=!0)},f.deprecated=function(n,a,s){n[a]=f.chain(function(){f.warnOnce("\u{1F505} deprecated \u{1F505}",s)},n[a])},f.nextId=function(){return f._nextId++},f.indexOf=function(n,a){if(n.indexOf)return n.indexOf(a);for(var s=0;s<n.length;s++)if(n[s]===a)return s;return-1},f.map=function(n,a){if(n.map)return n.map(a);for(var s=[],u=0;u<n.length;u+=1)s.push(a(n[u]));return s},f.topologicalSort=function(n){var a=[],s=[],u=[];for(var i in n)!s[i]&&!u[i]&&f._topologicalSort(i,s,u,n,a);return a},f._topologicalSort=function(n,a,s,u,i){var v=u[n]||[];s[n]=!0;for(var l=0;l<v.length;l+=1){var t=v[l];s[t]||a[t]||f._topologicalSort(t,a,s,u,i)}s[n]=!1,a[n]=!0,i.push(n)},f.chain=function(){for(var n=[],a=0;a<arguments.length;a+=1){var s=arguments[a];s._chained?n.push.apply(n,s._chained):n.push(s)}var u=function(){for(var i,v=new Array(arguments.length),l=0,t=arguments.length;l<t;l++)v[l]=arguments[l];for(l=0;l<n.length;l+=1){var r=n[l].apply(i,v);typeof r<"u"&&(i=r)}return i};return u._chained=n,u},f.chainPathBefore=function(n,a,s){return f.set(n,a,f.chain(s,f.get(n,a)))},f.chainPathAfter=function(n,a,s){return f.set(n,a,f.chain(f.get(n,a),s))},f.setDecomp=function(n){f._decomp=n},f.getDecomp=function(){var n=f._decomp;try{!n&&typeof window<"u"&&(n=window.decomp),!n&&typeof global<"u"&&(n=global.decomp)}catch{n=null}return n}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e){var n={min:{x:0,y:0},max:{x:0,y:0}};return e&&f.update(n,e),n},f.update=function(e,n,a){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var s=0;s<n.length;s++){var u=n[s];u.x>e.max.x&&(e.max.x=u.x),u.x<e.min.x&&(e.min.x=u.x),u.y>e.max.y&&(e.max.y=u.y),u.y<e.min.y&&(e.min.y=u.y)}a&&(a.x>0?e.max.x+=a.x:e.min.x+=a.x,a.y>0?e.max.y+=a.y:e.min.y+=a.y)},f.contains=function(e,n){return n.x>=e.min.x&&n.x<=e.max.x&&n.y>=e.min.y&&n.y<=e.max.y},f.overlaps=function(e,n){return e.min.x<=n.max.x&&e.max.x>=n.min.x&&e.max.y>=n.min.y&&e.min.y<=n.max.y},f.translate=function(e,n){e.min.x+=n.x,e.max.x+=n.x,e.min.y+=n.y,e.max.y+=n.y},f.shift=function(e,n){var a=e.max.x-e.min.x,s=e.max.y-e.min.y;e.min.x=n.x,e.max.x=n.x+a,e.min.y=n.y,e.max.y=n.y+s}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e,n){return{x:e||0,y:n||0}},f.clone=function(e){return{x:e.x,y:e.y}},f.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},f.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},f.rotate=function(e,n,a){var s=Math.cos(n),u=Math.sin(n);a||(a={});var i=e.x*s-e.y*u;return a.y=e.x*u+e.y*s,a.x=i,a},f.rotateAbout=function(e,n,a,s){var u=Math.cos(n),i=Math.sin(n);s||(s={});var v=a.x+((e.x-a.x)*u-(e.y-a.y)*i);return s.y=a.y+((e.x-a.x)*i+(e.y-a.y)*u),s.x=v,s},f.normalise=function(e){var n=f.magnitude(e);return n===0?{x:0,y:0}:{x:e.x/n,y:e.y/n}},f.dot=function(e,n){return e.x*n.x+e.y*n.y},f.cross=function(e,n){return e.x*n.y-e.y*n.x},f.cross3=function(e,n,a){return(n.x-e.x)*(a.y-e.y)-(n.y-e.y)*(a.x-e.x)},f.add=function(e,n,a){return a||(a={}),a.x=e.x+n.x,a.y=e.y+n.y,a},f.sub=function(e,n,a){return a||(a={}),a.x=e.x-n.x,a.y=e.y-n.y,a},f.mult=function(e,n){return{x:e.x*n,y:e.y*n}},f.div=function(e,n){return{x:e.x/n,y:e.y/n}},f.perp=function(e,n){return n=n===!0?-1:1,{x:n*-e.y,y:n*e.x}},f.neg=function(e){return{x:-e.x,y:-e.y}},f.angle=function(e,n){return Math.atan2(n.y-e.y,n.x-e.x)},f._temp=[f.create(),f.create(),f.create(),f.create(),f.create(),f.create()]})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(0);(function(){e.create=function(s,u){for(var i=[],v=0;v<s.length;v++){var l=s[v],t={x:l.x,y:l.y,index:v,body:u,isInternal:!1};i.push(t)}return i},e.fromPath=function(s,u){var i=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,v=[];return s.replace(i,function(l,t,r){v.push({x:parseFloat(t),y:parseFloat(r)})}),e.create(v,u)},e.centre=function(s){for(var u=e.area(s,!0),i={x:0,y:0},v,l,t,r=0;r<s.length;r++)t=(r+1)%s.length,v=n.cross(s[r],s[t]),l=n.mult(n.add(s[r],s[t]),v),i=n.add(i,l);return n.div(i,6*u)},e.mean=function(s){for(var u={x:0,y:0},i=0;i<s.length;i++)u.x+=s[i].x,u.y+=s[i].y;return n.div(u,s.length)},e.area=function(s,u){for(var i=0,v=s.length-1,l=0;l<s.length;l++)i+=(s[v].x-s[l].x)*(s[v].y+s[l].y),v=l;return u?i/2:Math.abs(i)/2},e.inertia=function(s,u){for(var i=0,v=0,l=s,t,r,o=0;o<l.length;o++)r=(o+1)%l.length,t=Math.abs(n.cross(l[r],l[o])),i+=t*(n.dot(l[r],l[r])+n.dot(l[r],l[o])+n.dot(l[o],l[o])),v+=t;return u/6*(i/v)},e.translate=function(s,u,i){i=typeof i<"u"?i:1;var v=s.length,l=u.x*i,t=u.y*i,r;for(r=0;r<v;r++)s[r].x+=l,s[r].y+=t;return s},e.rotate=function(s,u,i){if(u!==0){var v=Math.cos(u),l=Math.sin(u),t=i.x,r=i.y,o=s.length,c,d,y,P;for(P=0;P<o;P++)c=s[P],d=c.x-t,y=c.y-r,c.x=t+(d*v-y*l),c.y=r+(d*l+y*v);return s}},e.contains=function(s,u){for(var i=u.x,v=u.y,l=s.length,t=s[l-1],r,o=0;o<l;o++){if(r=s[o],(i-t.x)*(r.y-t.y)+(v-t.y)*(t.x-r.x)>0)return!1;t=r}return!0},e.scale=function(s,u,i,v){if(u===1&&i===1)return s;v=v||e.centre(s);for(var l,t,r=0;r<s.length;r++)l=s[r],t=n.sub(l,v),s[r].x=v.x+t.x*u,s[r].y=v.y+t.y*i;return s},e.chamfer=function(s,u,i,v,l){typeof u=="number"?u=[u]:u=u||[8],i=typeof i<"u"?i:-1,v=v||2,l=l||14;for(var t=[],r=0;r<s.length;r++){var o=s[r-1>=0?r-1:s.length-1],c=s[r],d=s[(r+1)%s.length],y=u[r<u.length?r:u.length-1];if(y===0){t.push(c);continue}var P=n.normalise({x:c.y-o.y,y:o.x-c.x}),M=n.normalise({x:d.y-c.y,y:c.x-d.x}),h=Math.sqrt(2*Math.pow(y,2)),m=n.mult(a.clone(P),y),x=n.normalise(n.mult(n.add(P,M),.5)),p=n.sub(c,n.mult(x,h)),C=i;i===-1&&(C=Math.pow(y,.32)*1.75),C=a.clamp(C,v,l),C%2===1&&(C+=1);for(var w=Math.acos(n.dot(P,M)),S=w/C,I=0;I<C;I++)t.push(n.add(n.rotate(m,S*I),p))}return t},e.clockwiseSort=function(s){var u=e.mean(s);return s.sort(function(i,v){return n.angle(u,i)-n.angle(u,v)}),s},e.isConvex=function(s){var u=0,i=s.length,v,l,t,r;if(i<3)return null;for(v=0;v<i;v++)if(l=(v+1)%i,t=(v+2)%i,r=(s[l].x-s[v].x)*(s[t].y-s[l].y),r-=(s[l].y-s[v].y)*(s[t].x-s[l].x),r<0?u|=1:r>0&&(u|=2),u===3)return!1;return u!==0?!0:null},e.hull=function(s){var u=[],i=[],v,l;for(s=s.slice(0),s.sort(function(t,r){var o=t.x-r.x;return o!==0?o:t.y-r.y}),l=0;l<s.length;l+=1){for(v=s[l];i.length>=2&&n.cross3(i[i.length-2],i[i.length-1],v)<=0;)i.pop();i.push(v)}for(l=s.length-1;l>=0;l-=1){for(v=s[l];u.length>=2&&n.cross3(u[u.length-2],u[u.length-1],v)<=0;)u.pop();u.push(v)}return u.pop(),i.pop(),u.concat(i)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(2),s=f(7),u=f(0),i=f(1),v=f(11);(function(){e._timeCorrection=!0,e._inertiaScale=4,e._nextCollidingGroupId=1,e._nextNonCollidingGroupId=-1,e._nextCategory=1,e._baseDelta=1e3/60,e.create=function(t){var r={id:u.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:n.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,isSensor:!1,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,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:16.666666666666668,_original:null},o=u.extend(r,t);return l(o,t),o},e.nextGroup=function(t){return t?e._nextNonCollidingGroupId--:e._nextCollidingGroupId++},e.nextCategory=function(){return e._nextCategory=e._nextCategory<<1,e._nextCategory};var l=function(t,r){r=r||{},e.set(t,{bounds:t.bounds||i.create(t.vertices),positionPrev:t.positionPrev||a.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),n.rotate(t.vertices,t.angle,t.position),v.rotate(t.axes,t.angle),i.update(t.bounds,t.vertices,t.velocity),e.set(t,{axes:r.axes||t.axes,area:r.area||t.area,mass:r.mass||t.mass,inertia:r.inertia||t.inertia});var o=t.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),c=t.isStatic?"#555":"#ccc",d=t.isStatic&&t.render.fillStyle===null?1:0;t.render.fillStyle=t.render.fillStyle||o,t.render.strokeStyle=t.render.strokeStyle||c,t.render.lineWidth=t.render.lineWidth||d,t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};e.set=function(t,r,o){var c;typeof r=="string"&&(c=r,r={},r[c]=o);for(c in r)if(Object.prototype.hasOwnProperty.call(r,c))switch(o=r[c],c){case"isStatic":e.setStatic(t,o);break;case"isSleeping":s.set(t,o);break;case"mass":e.setMass(t,o);break;case"density":e.setDensity(t,o);break;case"inertia":e.setInertia(t,o);break;case"vertices":e.setVertices(t,o);break;case"position":e.setPosition(t,o);break;case"angle":e.setAngle(t,o);break;case"velocity":e.setVelocity(t,o);break;case"angularVelocity":e.setAngularVelocity(t,o);break;case"speed":e.setSpeed(t,o);break;case"angularSpeed":e.setAngularSpeed(t,o);break;case"parts":e.setParts(t,o);break;case"centre":e.setCentre(t,o);break;default:t[c]=o}},e.setStatic=function(t,r){for(var o=0;o<t.parts.length;o++){var c=t.parts[o];r?(c.isStatic||(c._original={restitution:c.restitution,friction:c.friction,mass:c.mass,inertia:c.inertia,density:c.density,inverseMass:c.inverseMass,inverseInertia:c.inverseInertia}),c.restitution=0,c.friction=1,c.mass=c.inertia=c.density=1/0,c.inverseMass=c.inverseInertia=0,c.positionPrev.x=c.position.x,c.positionPrev.y=c.position.y,c.anglePrev=c.angle,c.angularVelocity=0,c.speed=0,c.angularSpeed=0,c.motion=0):c._original&&(c.restitution=c._original.restitution,c.friction=c._original.friction,c.mass=c._original.mass,c.inertia=c._original.inertia,c.density=c._original.density,c.inverseMass=c._original.inverseMass,c.inverseInertia=c._original.inverseInertia,c._original=null),c.isStatic=r}},e.setMass=function(t,r){var o=t.inertia/(t.mass/6);t.inertia=o*(r/6),t.inverseInertia=1/t.inertia,t.mass=r,t.inverseMass=1/t.mass,t.density=t.mass/t.area},e.setDensity=function(t,r){e.setMass(t,r*t.area),t.density=r},e.setInertia=function(t,r){t.inertia=r,t.inverseInertia=1/t.inertia},e.setVertices=function(t,r){r[0].body===t?t.vertices=r:t.vertices=n.create(r,t),t.axes=v.fromVertices(t.vertices),t.area=n.area(t.vertices),e.setMass(t,t.density*t.area);var o=n.centre(t.vertices);n.translate(t.vertices,o,-1),e.setInertia(t,e._inertiaScale*n.inertia(t.vertices,t.mass)),n.translate(t.vertices,t.position),i.update(t.bounds,t.vertices,t.velocity)},e.setParts=function(t,r,o){var c;for(r=r.slice(0),t.parts.length=0,t.parts.push(t),t.parent=t,c=0;c<r.length;c++){var d=r[c];d!==t&&(d.parent=t,t.parts.push(d))}if(t.parts.length!==1){if(o=typeof o<"u"?o:!0,o){var y=[];for(c=0;c<r.length;c++)y=y.concat(r[c].vertices);n.clockwiseSort(y);var P=n.hull(y),M=n.centre(P);e.setVertices(t,P),n.translate(t.vertices,M)}var h=e._totalProperties(t);t.area=h.area,t.parent=t,t.position.x=h.centre.x,t.position.y=h.centre.y,t.positionPrev.x=h.centre.x,t.positionPrev.y=h.centre.y,e.setMass(t,h.mass),e.setInertia(t,h.inertia),e.setPosition(t,h.centre)}},e.setCentre=function(t,r,o){o?(t.positionPrev.x+=r.x,t.positionPrev.y+=r.y,t.position.x+=r.x,t.position.y+=r.y):(t.positionPrev.x=r.x-(t.position.x-t.positionPrev.x),t.positionPrev.y=r.y-(t.position.y-t.positionPrev.y),t.position.x=r.x,t.position.y=r.y)},e.setPosition=function(t,r,o){var c=a.sub(r,t.position);o?(t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.velocity.x=c.x,t.velocity.y=c.y,t.speed=a.magnitude(c)):(t.positionPrev.x+=c.x,t.positionPrev.y+=c.y);for(var d=0;d<t.parts.length;d++){var y=t.parts[d];y.position.x+=c.x,y.position.y+=c.y,n.translate(y.vertices,c),i.update(y.bounds,y.vertices,t.velocity)}},e.setAngle=function(t,r,o){var c=r-t.angle;o?(t.anglePrev=t.angle,t.angularVelocity=c,t.angularSpeed=Math.abs(c)):t.anglePrev+=c;for(var d=0;d<t.parts.length;d++){var y=t.parts[d];y.angle+=c,n.rotate(y.vertices,c,t.position),v.rotate(y.axes,c),i.update(y.bounds,y.vertices,t.velocity),d>0&&a.rotateAbout(y.position,c,t.position,y.position)}},e.setVelocity=function(t,r){var o=t.deltaTime/e._baseDelta;t.positionPrev.x=t.position.x-r.x*o,t.positionPrev.y=t.position.y-r.y*o,t.velocity.x=(t.position.x-t.positionPrev.x)/o,t.velocity.y=(t.position.y-t.positionPrev.y)/o,t.speed=a.magnitude(t.velocity)},e.getVelocity=function(t){var r=e._baseDelta/t.deltaTime;return{x:(t.position.x-t.positionPrev.x)*r,y:(t.position.y-t.positionPrev.y)*r}},e.getSpeed=function(t){return a.magnitude(e.getVelocity(t))},e.setSpeed=function(t,r){e.setVelocity(t,a.mult(a.normalise(e.getVelocity(t)),r))},e.setAngularVelocity=function(t,r){var o=t.deltaTime/e._baseDelta;t.anglePrev=t.angle-r*o,t.angularVelocity=(t.angle-t.anglePrev)/o,t.angularSpeed=Math.abs(t.angularVelocity)},e.getAngularVelocity=function(t){return(t.angle-t.anglePrev)*e._baseDelta/t.deltaTime},e.getAngularSpeed=function(t){return Math.abs(e.getAngularVelocity(t))},e.setAngularSpeed=function(t,r){e.setAngularVelocity(t,u.sign(e.getAngularVelocity(t))*r)},e.translate=function(t,r,o){e.setPosition(t,a.add(t.position,r),o)},e.rotate=function(t,r,o,c){if(!o)e.setAngle(t,t.angle+r,c);else{var d=Math.cos(r),y=Math.sin(r),P=t.position.x-o.x,M=t.position.y-o.y;e.setPosition(t,{x:o.x+(P*d-M*y),y:o.y+(P*y+M*d)},c),e.setAngle(t,t.angle+r,c)}},e.scale=function(t,r,o,c){var d=0,y=0;c=c||t.position;for(var P=0;P<t.parts.length;P++){var M=t.parts[P];n.scale(M.vertices,r,o,c),M.axes=v.fromVertices(M.vertices),M.area=n.area(M.vertices),e.setMass(M,t.density*M.area),n.translate(M.vertices,{x:-M.position.x,y:-M.position.y}),e.setInertia(M,e._inertiaScale*n.inertia(M.vertices,M.mass)),n.translate(M.vertices,{x:M.position.x,y:M.position.y}),P>0&&(d+=M.area,y+=M.inertia),M.position.x=c.x+(M.position.x-c.x)*r,M.position.y=c.y+(M.position.y-c.y)*o,i.update(M.bounds,M.vertices,t.velocity)}t.parts.length>1&&(t.area=d,t.isStatic||(e.setMass(t,t.density*d),e.setInertia(t,y))),t.circleRadius&&(r===o?t.circleRadius*=r:t.circleRadius=null)},e.update=function(t,r){r=(typeof r<"u"?r:1e3/60)*t.timeScale;var o=r*r,c=e._timeCorrection?r/(t.deltaTime||r):1,d=1-t.frictionAir*(r/u._baseDelta),y=(t.position.x-t.positionPrev.x)*c,P=(t.position.y-t.positionPrev.y)*c;t.velocity.x=y*d+t.force.x/t.mass*o,t.velocity.y=P*d+t.force.y/t.mass*o,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.deltaTime=r,t.angularVelocity=(t.angle-t.anglePrev)*d*c+t.torque/t.inertia*o,t.anglePrev=t.angle,t.angle+=t.angularVelocity;for(var M=0;M<t.parts.length;M++){var h=t.parts[M];n.translate(h.vertices,t.velocity),M>0&&(h.position.x+=t.velocity.x,h.position.y+=t.velocity.y),t.angularVelocity!==0&&(n.rotate(h.vertices,t.angularVelocity,t.position),v.rotate(h.axes,t.angularVelocity),M>0&&a.rotateAbout(h.position,t.angularVelocity,t.position,h.position)),i.update(h.bounds,h.vertices,t.velocity)}},e.updateVelocities=function(t){var r=e._baseDelta/t.deltaTime,o=t.velocity;o.x=(t.position.x-t.positionPrev.x)*r,o.y=(t.position.y-t.positionPrev.y)*r,t.speed=Math.sqrt(o.x*o.x+o.y*o.y),t.angularVelocity=(t.angle-t.anglePrev)*r,t.angularSpeed=Math.abs(t.angularVelocity)},e.applyForce=function(t,r,o){var c={x:r.x-t.position.x,y:r.y-t.position.y};t.force.x+=o.x,t.force.y+=o.y,t.torque+=c.x*o.y-c.y*o.x},e._totalProperties=function(t){for(var r={mass:0,area:0,inertia:0,centre:{x:0,y:0}},o=t.parts.length===1?0:1;o<t.parts.length;o++){var c=t.parts[o],d=c.mass!==1/0?c.mass:1;r.mass+=d,r.area+=c.area,r.inertia+=c.inertia,r.centre=a.add(r.centre,a.mult(c.position,d))}return r.centre=a.div(r.centre,r.mass),r}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e.on=function(a,s,u){for(var i=s.split(" "),v,l=0;l<i.length;l++)v=i[l],a.events=a.events||{},a.events[v]=a.events[v]||[],a.events[v].push(u);return u},e.off=function(a,s,u){if(!s){a.events={};return}typeof s=="function"&&(u=s,s=n.keys(a.events).join(" "));for(var i=s.split(" "),v=0;v<i.length;v++){var l=a.events[i[v]],t=[];if(u&&l)for(var r=0;r<l.length;r++)l[r]!==u&&t.push(l[r]);a.events[i[v]]=t}},e.trigger=function(a,s,u){var i,v,l,t,r=a.events;if(r&&n.keys(r).length>0){u||(u={}),i=s.split(" ");for(var o=0;o<i.length;o++)if(v=i[o],l=r[v],l){t=n.clone(u,!1),t.name=v,t.source=a;for(var c=0;c<l.length;c++)l[c].apply(a,[t])}}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(5),a=f(0),s=f(1),u=f(4);(function(){e.create=function(i){return a.extend({id:a.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},i)},e.setModified=function(i,v,l,t){if(i.isModified=v,v&&i.cache&&(i.cache.allBodies=null,i.cache.allConstraints=null,i.cache.allComposites=null),l&&i.parent&&e.setModified(i.parent,v,l,t),t)for(var r=0;r<i.composites.length;r++){var o=i.composites[r];e.setModified(o,v,l,t)}},e.add=function(i,v){var l=[].concat(v);n.trigger(i,"beforeAdd",{object:v});for(var t=0;t<l.length;t++){var r=l[t];switch(r.type){case"body":if(r.parent!==r){a.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}e.addBody(i,r);break;case"constraint":e.addConstraint(i,r);break;case"composite":e.addComposite(i,r);break;case"mouseConstraint":e.addConstraint(i,r.constraint);break}}return n.trigger(i,"afterAdd",{object:v}),i},e.remove=function(i,v,l){var t=[].concat(v);n.trigger(i,"beforeRemove",{object:v});for(var r=0;r<t.length;r++){var o=t[r];switch(o.type){case"body":e.removeBody(i,o,l);break;case"constraint":e.removeConstraint(i,o,l);break;case"composite":e.removeComposite(i,o,l);break;case"mouseConstraint":e.removeConstraint(i,o.constraint);break}}return n.trigger(i,"afterRemove",{object:v}),i},e.addComposite=function(i,v){return i.composites.push(v),v.parent=i,e.setModified(i,!0,!0,!1),i},e.removeComposite=function(i,v,l){var t=a.indexOf(i.composites,v);if(t!==-1){var r=e.allBodies(v);e.removeCompositeAt(i,t);for(var o=0;o<r.length;o++)r[o].sleepCounter=0}if(l)for(var o=0;o<i.composites.length;o++)e.removeComposite(i.composites[o],v,!0);return i},e.removeCompositeAt=function(i,v){return i.composites.splice(v,1),e.setModified(i,!0,!0,!1),i},e.addBody=function(i,v){return i.bodies.push(v),e.setModified(i,!0,!0,!1),i},e.removeBody=function(i,v,l){var t=a.indexOf(i.bodies,v);if(t!==-1&&(e.removeBodyAt(i,t),v.sleepCounter=0),l)for(var r=0;r<i.composites.length;r++)e.removeBody(i.composites[r],v,!0);return i},e.removeBodyAt=function(i,v){return i.bodies.splice(v,1),e.setModified(i,!0,!0,!1),i},e.addConstraint=function(i,v){return i.constraints.push(v),e.setModified(i,!0,!0,!1),i},e.removeConstraint=function(i,v,l){var t=a.indexOf(i.constraints,v);if(t!==-1&&e.removeConstraintAt(i,t),l)for(var r=0;r<i.composites.length;r++)e.removeConstraint(i.composites[r],v,!0);return i},e.removeConstraintAt=function(i,v){return i.constraints.splice(v,1),e.setModified(i,!0,!0,!1),i},e.clear=function(i,v,l){if(l)for(var t=0;t<i.composites.length;t++)e.clear(i.composites[t],v,!0);return v?i.bodies=i.bodies.filter(function(r){return r.isStatic}):i.bodies.length=0,i.constraints.length=0,i.composites.length=0,e.setModified(i,!0,!0,!1),i},e.allBodies=function(i){if(i.cache&&i.cache.allBodies)return i.cache.allBodies;for(var v=[].concat(i.bodies),l=0;l<i.composites.length;l++)v=v.concat(e.allBodies(i.composites[l]));return i.cache&&(i.cache.allBodies=v),v},e.allConstraints=function(i){if(i.cache&&i.cache.allConstraints)return i.cache.allConstraints;for(var v=[].concat(i.constraints),l=0;l<i.composites.length;l++)v=v.concat(e.allConstraints(i.composites[l]));return i.cache&&(i.cache.allConstraints=v),v},e.allComposites=function(i){if(i.cache&&i.cache.allComposites)return i.cache.allComposites;for(var v=[].concat(i.composites),l=0;l<i.composites.length;l++)v=v.concat(e.allComposites(i.composites[l]));return i.cache&&(i.cache.allComposites=v),v},e.get=function(i,v,l){var t,r;switch(l){case"body":t=e.allBodies(i);break;case"constraint":t=e.allConstraints(i);break;case"composite":t=e.allComposites(i).concat(i);break}return t?(r=t.filter(function(o){return o.id.toString()===v.toString()}),r.length===0?null:r[0]):null},e.move=function(i,v,l){return e.remove(i,v),e.add(l,v),i},e.rebase=function(i){for(var v=e.allBodies(i).concat(e.allConstraints(i)).concat(e.allComposites(i)),l=0;l<v.length;l++)v[l].id=a.nextId();return i},e.translate=function(i,v,l){for(var t=l?e.allBodies(i):i.bodies,r=0;r<t.length;r++)u.translate(t[r],v);return i},e.rotate=function(i,v,l,t){for(var r=Math.cos(v),o=Math.sin(v),c=t?e.allBodies(i):i.bodies,d=0;d<c.length;d++){var y=c[d],P=y.position.x-l.x,M=y.position.y-l.y;u.setPosition(y,{x:l.x+(P*r-M*o),y:l.y+(P*o+M*r)}),u.rotate(y,v)}return i},e.scale=function(i,v,l,t,r){for(var o=r?e.allBodies(i):i.bodies,c=0;c<o.length;c++){var d=o[c],y=d.position.x-t.x,P=d.position.y-t.y;u.setPosition(d,{x:t.x+y*v,y:t.y+P*l}),u.scale(d,v,l)}return i},e.bounds=function(i){for(var v=e.allBodies(i),l=[],t=0;t<v.length;t+=1){var r=v[t];l.push(r.bounds.min,r.bounds.max)}return s.create(l)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(4),a=f(5),s=f(0);(function(){e._motionWakeThreshold=.18,e._motionSleepThreshold=.08,e._minBias=.9,e.update=function(u,i){for(var v=i/s._baseDelta,l=e._motionSleepThreshold,t=0;t<u.length;t++){var r=u[t],o=n.getSpeed(r),c=n.getAngularSpeed(r),d=o*o+c*c;if(r.force.x!==0||r.force.y!==0){e.set(r,!1);continue}var y=Math.min(r.motion,d),P=Math.max(r.motion,d);r.motion=e._minBias*y+(1-e._minBias)*P,r.sleepThreshold>0&&r.motion<l?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold/v&&e.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}},e.afterCollisions=function(u){for(var i=e._motionSleepThreshold,v=0;v<u.length;v++){var l=u[v];if(l.isActive){var t=l.collision,r=t.bodyA.parent,o=t.bodyB.parent;if(!(r.isSleeping&&o.isSleeping||r.isStatic||o.isStatic)&&(r.isSleeping||o.isSleeping)){var c=r.isSleeping&&!r.isStatic?r:o,d=c===r?o:r;!c.isStatic&&d.motion>i&&e.set(c,!1)}}}},e.set=function(u,i){var v=u.isSleeping;i?(u.isSleeping=!0,u.sleepCounter=u.sleepThreshold,u.positionImpulse.x=0,u.positionImpulse.y=0,u.positionPrev.x=u.position.x,u.positionPrev.y=u.position.y,u.anglePrev=u.angle,u.speed=0,u.angularSpeed=0,u.motion=0,v||a.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,v&&a.trigger(u,"sleepEnd"))}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(9);(function(){var s=[],u={overlap:0,axis:null},i={overlap:0,axis:null};e.create=function(v,l){return{pair:null,collided:!1,bodyA:v,bodyB:l,parentA:v.parent,parentB:l.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[null,null],supportCount:0}},e.collides=function(v,l,t){if(e._overlapAxes(u,v.vertices,l.vertices,v.axes),u.overlap<=0||(e._overlapAxes(i,l.vertices,v.vertices,l.axes),i.overlap<=0))return null;var r=t&&t.table[a.id(v,l)],o;r?o=r.collision:(o=e.create(v,l),o.collided=!0,o.bodyA=v.id<l.id?v:l,o.bodyB=v.id<l.id?l:v,o.parentA=o.bodyA.parent,o.parentB=o.bodyB.parent),v=o.bodyA,l=o.bodyB;var c;u.overlap<i.overlap?c=u:c=i;var d=o.normal,y=o.tangent,P=o.penetration,M=o.supports,h=c.overlap,m=c.axis,x=m.x,p=m.y,C=l.position.x-v.position.x,w=l.position.y-v.position.y;x*C+p*w>=0&&(x=-x,p=-p),d.x=x,d.y=p,y.x=-p,y.y=x,P.x=x*h,P.y=p*h,o.depth=h;var S=e._findSupports(v,l,d,1),I=0;if(n.contains(v.vertices,S[0])&&(M[I++]=S[0]),n.contains(v.vertices,S[1])&&(M[I++]=S[1]),I<2){var A=e._findSupports(l,v,d,-1);n.contains(l.vertices,A[0])&&(M[I++]=A[0]),I<2&&n.contains(l.vertices,A[1])&&(M[I++]=A[1])}return I===0&&(M[I++]=S[0]),o.supportCount=I,o},e._overlapAxes=function(v,l,t,r){var o=l.length,c=t.length,d=l[0].x,y=l[0].y,P=t[0].x,M=t[0].y,h=r.length,m=Number.MAX_VALUE,x=0,p,C,w,S,I,A;for(I=0;I<h;I++){var k=r[I],B=k.x,E=k.y,L=d*B+y*E,D=P*B+M*E,F=L,V=D;for(A=1;A<o;A+=1)S=l[A].x*B+l[A].y*E,S>F?F=S:S<L&&(L=S);for(A=1;A<c;A+=1)S=t[A].x*B+t[A].y*E,S>V?V=S:S<D&&(D=S);if(C=F-D,w=V-L,p=C<w?C:w,p<m&&(m=p,x=I,p<=0))break}v.axis=r[x],v.overlap=m},e._findSupports=function(v,l,t,r){var o=l.vertices,c=o.length,d=v.position.x,y=v.position.y,P=t.x*r,M=t.y*r,h=o[0],m=h,x=P*(d-m.x)+M*(y-m.y),p,C,w;for(w=1;w<c;w+=1)m=o[w],C=P*(d-m.x)+M*(y-m.y),C<x&&(x=C,h=m);return p=o[(c+h.index-1)%c],x=P*(d-p.x)+M*(y-p.y),m=o[(h.index+1)%c],P*(d-m.x)+M*(y-m.y)<x?(s[0]=h,s[1]=m,s):(s[0]=h,s[1]=p,s)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(16);(function(){e.create=function(a,s){var u=a.bodyA,i=a.bodyB,v={id:e.id(u,i),bodyA:u,bodyB:i,collision:a,contacts:[n.create(),n.create()],contactCount:0,separation:0,isActive:!0,isSensor:u.isSensor||i.isSensor,timeCreated:s,timeUpdated:s,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return e.update(v,a,s),v},e.update=function(a,s,u){var i=s.supports,v=s.supportCount,l=a.contacts,t=s.parentA,r=s.parentB;a.isActive=!0,a.timeUpdated=u,a.collision=s,a.separation=s.depth,a.inverseMass=t.inverseMass+r.inverseMass,a.friction=t.friction<r.friction?t.friction:r.friction,a.frictionStatic=t.frictionStatic>r.frictionStatic?t.frictionStatic:r.frictionStatic,a.restitution=t.restitution>r.restitution?t.restitution:r.restitution,a.slop=t.slop>r.slop?t.slop:r.slop,a.contactCount=v,s.pair=a;var o=i[0],c=l[0],d=i[1],y=l[1];(y.vertex===o||c.vertex===d)&&(l[1]=c,l[0]=c=y,y=l[1]),c.vertex=o,y.vertex=d},e.setActive=function(a,s,u){s?(a.isActive=!0,a.timeUpdated=u):(a.isActive=!1,a.contactCount=0)},e.id=function(a,s){return a.id<s.id?a.id.toString(36)+":"+s.id.toString(36):s.id.toString(36)+":"+a.id.toString(36)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(2),s=f(7),u=f(1),i=f(11),v=f(0);(function(){e._warming=.4,e._torqueDampen=1,e._minLength=1e-6,e.create=function(l){var t=l;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var r=t.bodyA?a.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?a.add(t.bodyB.position,t.pointB):t.pointB,c=a.magnitude(a.sub(r,o));t.length=typeof t.length<"u"?t.length:c,t.id=t.id||v.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var d={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return t.length===0&&t.stiffness>.1?(d.type="pin",d.anchors=!1):t.stiffness<.9&&(d.type="spring"),t.render=v.extend(d,t.render),t},e.preSolveAll=function(l){for(var t=0;t<l.length;t+=1){var r=l[t],o=r.constraintImpulse;r.isStatic||o.x===0&&o.y===0&&o.angle===0||(r.position.x+=o.x,r.position.y+=o.y,r.angle+=o.angle)}},e.solveAll=function(l,t){for(var r=v.clamp(t/v._baseDelta,0,1),o=0;o<l.length;o+=1){var c=l[o],d=!c.bodyA||c.bodyA&&c.bodyA.isStatic,y=!c.bodyB||c.bodyB&&c.bodyB.isStatic;(d||y)&&e.solve(l[o],r)}for(o=0;o<l.length;o+=1)c=l[o],d=!c.bodyA||c.bodyA&&c.bodyA.isStatic,y=!c.bodyB||c.bodyB&&c.bodyB.isStatic,!d&&!y&&e.solve(l[o],r)},e.solve=function(l,t){var r=l.bodyA,o=l.bodyB,c=l.pointA,d=l.pointB;if(!(!r&&!o)){r&&!r.isStatic&&(a.rotate(c,r.angle-l.angleA,c),l.angleA=r.angle),o&&!o.isStatic&&(a.rotate(d,o.angle-l.angleB,d),l.angleB=o.angle);var y=c,P=d;if(r&&(y=a.add(r.position,c)),o&&(P=a.add(o.position,d)),!(!y||!P)){var M=a.sub(y,P),h=a.magnitude(M);h<e._minLength&&(h=e._minLength);var m=(h-l.length)/h,x=l.stiffness>=1||l.length===0,p=x?l.stiffness*t:l.stiffness*t*t,C=l.damping*t,w=a.mult(M,m*p),S=(r?r.inverseMass:0)+(o?o.inverseMass:0),I=(r?r.inverseInertia:0)+(o?o.inverseInertia:0),A=S+I,k,B,E,L,D;if(C>0){var F=a.create();E=a.div(M,h),D=a.sub(o&&a.sub(o.position,o.positionPrev)||F,r&&a.sub(r.position,r.positionPrev)||F),L=a.dot(E,D)}r&&!r.isStatic&&(B=r.inverseMass/S,r.constraintImpulse.x-=w.x*B,r.constraintImpulse.y-=w.y*B,r.position.x-=w.x*B,r.position.y-=w.y*B,C>0&&(r.positionPrev.x-=C*E.x*L*B,r.positionPrev.y-=C*E.y*L*B),k=a.cross(c,w)/A*e._torqueDampen*r.inverseInertia*(1-l.angularStiffness),r.constraintImpulse.angle-=k,r.angle-=k),o&&!o.isStatic&&(B=o.inverseMass/S,o.constraintImpulse.x+=w.x*B,o.constraintImpulse.y+=w.y*B,o.position.x+=w.x*B,o.position.y+=w.y*B,C>0&&(o.positionPrev.x+=C*E.x*L*B,o.positionPrev.y+=C*E.y*L*B),k=a.cross(d,w)/A*e._torqueDampen*o.inverseInertia*(1-l.angularStiffness),o.constraintImpulse.angle+=k,o.angle+=k)}}},e.postSolveAll=function(l){for(var t=0;t<l.length;t++){var r=l[t],o=r.constraintImpulse;if(!(r.isStatic||o.x===0&&o.y===0&&o.angle===0)){s.set(r,!1);for(var c=0;c<r.parts.length;c++){var d=r.parts[c];n.translate(d.vertices,o),c>0&&(d.position.x+=o.x,d.position.y+=o.y),o.angle!==0&&(n.rotate(d.vertices,o.angle,r.position),i.rotate(d.axes,o.angle),c>0&&a.rotateAbout(d.position,o.angle,r.position,d.position)),u.update(d.bounds,d.vertices,r.velocity)}o.angle*=e._warming,o.x*=e._warming,o.y*=e._warming}}},e.pointAWorld=function(l){return{x:(l.bodyA?l.bodyA.position.x:0)+(l.pointA?l.pointA.x:0),y:(l.bodyA?l.bodyA.position.y:0)+(l.pointA?l.pointA.y:0)}},e.pointBWorld=function(l){return{x:(l.bodyB?l.bodyB.position.x:0)+(l.pointB?l.pointB.x:0),y:(l.bodyB?l.bodyB.position.y:0)+(l.pointB?l.pointB.y:0)}},e.currentLength=function(l){var t=(l.bodyA?l.bodyA.position.x:0)+(l.pointA?l.pointA.x:0),r=(l.bodyA?l.bodyA.position.y:0)+(l.pointA?l.pointA.y:0),o=(l.bodyB?l.bodyB.position.x:0)+(l.pointB?l.pointB.x:0),c=(l.bodyB?l.bodyB.position.y:0)+(l.pointB?l.pointB.y:0),d=t-o,y=r-c;return Math.sqrt(d*d+y*y)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(0);(function(){e.fromVertices=function(s){for(var u={},i=0;i<s.length;i++){var v=(i+1)%s.length,l=n.normalise({x:s[v].y-s[i].y,y:s[i].x-s[v].x}),t=l.y===0?1/0:l.x/l.y;t=t.toFixed(3).toString(),u[t]=l}return a.values(u)},e.rotate=function(s,u){if(u!==0)for(var i=Math.cos(u),v=Math.sin(u),l=0;l<s.length;l++){var t=s[l],r;r=t.x*i-t.y*v,t.y=t.x*v+t.y*i,t.x=r}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(0),s=f(4),u=f(1),i=f(2);(function(){e.rectangle=function(v,l,t,r,o){o=o||{};var c={label:"Rectangle Body",position:{x:v,y:l},vertices:n.fromPath("L 0 0 L "+t+" 0 L "+t+" "+r+" L 0 "+r)};if(o.chamfer){var d=o.chamfer;c.vertices=n.chamfer(c.vertices,d.radius,d.quality,d.qualityMin,d.qualityMax),delete o.chamfer}return s.create(a.extend({},c,o))},e.trapezoid=function(v,l,t,r,o,c){c=c||{},o>=1&&a.warn("Bodies.trapezoid: slope parameter must be < 1."),o*=.5;var d=(1-o*2)*t,y=t*o,P=y+d,M=P+y,h;o<.5?h="L 0 0 L "+y+" "+-r+" L "+P+" "+-r+" L "+M+" 0":h="L 0 0 L "+P+" "+-r+" L "+M+" 0";var m={label:"Trapezoid Body",position:{x:v,y:l},vertices:n.fromPath(h)};if(c.chamfer){var x=c.chamfer;m.vertices=n.chamfer(m.vertices,x.radius,x.quality,x.qualityMin,x.qualityMax),delete c.chamfer}return s.create(a.extend({},m,c))},e.circle=function(v,l,t,r,o){r=r||{};var c={label:"Circle Body",circleRadius:t};o=o||25;var d=Math.ceil(Math.max(10,Math.min(o,t)));return d%2===1&&(d+=1),e.polygon(v,l,d,t,a.extend({},c,r))},e.polygon=function(v,l,t,r,o){if(o=o||{},t<3)return e.circle(v,l,r,o);for(var c=2*Math.PI/t,d="",y=c*.5,P=0;P<t;P+=1){var M=y+P*c,h=Math.cos(M)*r,m=Math.sin(M)*r;d+="L "+h.toFixed(3)+" "+m.toFixed(3)+" "}var x={label:"Polygon Body",position:{x:v,y:l},vertices:n.fromPath(d)};if(o.chamfer){var p=o.chamfer;x.vertices=n.chamfer(x.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete o.chamfer}return s.create(a.extend({},x,o))},e.fromVertices=function(v,l,t,r,o,c,d,y){var P=a.getDecomp(),M,h,m,x,p,C,w,S,I,A,k;for(M=!!(P&&P.quickDecomp),r=r||{},m=[],o=typeof o<"u"?o:!1,c=typeof c<"u"?c:.01,d=typeof d<"u"?d:10,y=typeof y<"u"?y:.01,a.isArray(t[0])||(t=[t]),A=0;A<t.length;A+=1)if(C=t[A],x=n.isConvex(C),p=!x,p&&!M&&a.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),x||!M)x?C=n.clockwiseSort(C):C=n.hull(C),m.push({position:{x:v,y:l},vertices:C});else{var B=C.map(function(H){return[H.x,H.y]});P.makeCCW(B),c!==!1&&P.removeCollinearPoints(B,c),y!==!1&&P.removeDuplicatePoints&&P.removeDuplicatePoints(B,y);var E=P.quickDecomp(B);for(w=0;w<E.length;w++){var L=E[w],D=L.map(function(H){return{x:H[0],y:H[1]}});d>0&&n.area(D)<d||m.push({position:n.centre(D),vertices:D})}}for(w=0;w<m.length;w++)m[w]=s.create(a.extend(m[w],r));if(o){var F=5;for(w=0;w<m.length;w++){var V=m[w];for(S=w+1;S<m.length;S++){var b=m[S];if(u.overlaps(V.bounds,b.bounds)){var $=V.vertices,U=b.vertices;for(I=0;I<V.vertices.length;I++)for(k=0;k<b.vertices.length;k++){var j=i.magnitudeSquared(i.sub($[(I+1)%$.length],U[k])),G=i.magnitudeSquared(i.sub($[I],U[(k+1)%U.length]));j<F&&G<F&&($[I].isInternal=!0,U[k].isInternal=!0)}}}}}return m.length>1?(h=s.create(a.extend({parts:m.slice(0)},r)),s.setPosition(h,{x:v,y:l}),h):m[0]}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0),a=f(8);(function(){e.create=function(s){var u={bodies:[],collisions:[],pairs:null};return n.extend(u,s)},e.setBodies=function(s,u){s.bodies=u.slice(0)},e.clear=function(s){s.bodies=[],s.collisions=[]},e.collisions=function(s){var u=s.pairs,i=s.bodies,v=i.length,l=e.canCollide,t=a.collides,r=s.collisions,o=0,c,d;for(i.sort(e._compareBoundsX),c=0;c<v;c++){var y=i[c],P=y.bounds,M=y.bounds.max.x,h=y.bounds.max.y,m=y.bounds.min.y,x=y.isStatic||y.isSleeping,p=y.parts.length,C=p===1;for(d=c+1;d<v;d++){var w=i[d],S=w.bounds;if(S.min.x>M)break;if(!(h<S.min.y||m>S.max.y)&&!(x&&(w.isStatic||w.isSleeping))&&l(y.collisionFilter,w.collisionFilter)){var I=w.parts.length;if(C&&I===1){var A=t(y,w,u);A&&(r[o++]=A)}else for(var k=p>1?1:0,B=I>1?1:0,E=k;E<p;E++)for(var L=y.parts[E],P=L.bounds,D=B;D<I;D++){var F=w.parts[D],S=F.bounds;if(!(P.min.x>S.max.x||P.max.x<S.min.x||P.max.y<S.min.y||P.min.y>S.max.y)){var A=t(L,F,u);A&&(r[o++]=A)}}}}}return r.length!==o&&(r.length=o),r},e.canCollide=function(s,u){return s.group===u.group&&s.group!==0?s.group>0:(s.mask&u.category)!==0&&(u.mask&s.category)!==0},e._compareBoundsX=function(s,u){return s.bounds.min.x-u.bounds.min.x}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e.create=function(a){var s={};return a||n.log("Mouse.create: element was undefined, defaulting to document.body","warn"),s.element=a||document.body,s.absolute={x:0,y:0},s.position={x:0,y:0},s.mousedownPosition={x:0,y:0},s.mouseupPosition={x:0,y:0},s.offset={x:0,y:0},s.scale={x:1,y:1},s.wheelDelta=0,s.button=-1,s.pixelRatio=parseInt(s.element.getAttribute("data-pixel-ratio"),10)||1,s.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},s.mousemove=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v&&(s.button=0,u.preventDefault()),s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.sourceEvents.mousemove=u},s.mousedown=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v?(s.button=0,u.preventDefault()):s.button=u.button,s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.mousedownPosition.x=s.position.x,s.mousedownPosition.y=s.position.y,s.sourceEvents.mousedown=u},s.mouseup=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v&&u.preventDefault(),s.button=-1,s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.mouseupPosition.x=s.position.x,s.mouseupPosition.y=s.position.y,s.sourceEvents.mouseup=u},s.mousewheel=function(u){s.wheelDelta=Math.max(-1,Math.min(1,u.wheelDelta||-u.detail)),u.preventDefault(),s.sourceEvents.mousewheel=u},e.setElement(s,s.element),s},e.setElement=function(a,s){a.element=s,s.addEventListener("mousemove",a.mousemove,{passive:!0}),s.addEventListener("mousedown",a.mousedown,{passive:!0}),s.addEventListener("mouseup",a.mouseup,{passive:!0}),s.addEventListener("wheel",a.mousewheel,{passive:!1}),s.addEventListener("touchmove",a.mousemove,{passive:!1}),s.addEventListener("touchstart",a.mousedown,{passive:!1}),s.addEventListener("touchend",a.mouseup,{passive:!1})},e.clearSourceEvents=function(a){a.sourceEvents.mousemove=null,a.sourceEvents.mousedown=null,a.sourceEvents.mouseup=null,a.sourceEvents.mousewheel=null,a.wheelDelta=0},e.setOffset=function(a,s){a.offset.x=s.x,a.offset.y=s.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},e.setScale=function(a,s){a.scale.x=s.x,a.scale.y=s.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},e._getRelativeMousePosition=function(a,s,u){var i=s.getBoundingClientRect(),v=document.documentElement||document.body.parentNode||document.body,l=window.pageXOffset!==void 0?window.pageXOffset:v.scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:v.scrollTop,r=a.changedTouches,o,c;return r?(o=r[0].pageX-i.left-l,c=r[0].pageY-i.top-t):(o=a.pageX-i.left-l,c=a.pageY-i.top-t),{x:o/(s.clientWidth/(s.width||s.clientWidth)*u),y:c/(s.clientHeight/(s.height||s.clientHeight)*u)}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e._registry={},e.register=function(a){if(e.isPlugin(a)||n.warn("Plugin.register:",e.toString(a),"does not implement all required fields."),a.name in e._registry){var s=e._registry[a.name],u=e.versionParse(a.version).number,i=e.versionParse(s.version).number;u>i?(n.warn("Plugin.register:",e.toString(s),"was upgraded to",e.toString(a)),e._registry[a.name]=a):u<i?n.warn("Plugin.register:",e.toString(s),"can not be downgraded to",e.toString(a)):a!==s&&n.warn("Plugin.register:",e.toString(a),"is already registered to different plugin object")}else e._registry[a.name]=a;return a},e.resolve=function(a){return e._registry[e.dependencyParse(a).name]},e.toString=function(a){return typeof a=="string"?a:(a.name||"anonymous")+"@"+(a.version||a.range||"0.0.0")},e.isPlugin=function(a){return a&&a.name&&a.version&&a.install},e.isUsed=function(a,s){return a.used.indexOf(s)>-1},e.isFor=function(a,s){var u=a.for&&e.dependencyParse(a.for);return!a.for||s.name===u.name&&e.versionSatisfies(s.version,u.range)},e.use=function(a,s){if(a.uses=(a.uses||[]).concat(s||[]),a.uses.length===0){n.warn("Plugin.use:",e.toString(a),"does not specify any dependencies to install.");return}for(var u=e.dependencies(a),i=n.topologicalSort(u),v=[],l=0;l<i.length;l+=1)if(i[l]!==a.name){var t=e.resolve(i[l]);if(!t){v.push("\u274C "+i[l]);continue}e.isUsed(a,t.name)||(e.isFor(t,a)||(n.warn("Plugin.use:",e.toString(t),"is for",t.for,"but installed on",e.toString(a)+"."),t._warned=!0),t.install?t.install(a):(n.warn("Plugin.use:",e.toString(t),"does not specify an install function."),t._warned=!0),t._warned?(v.push("\u{1F536} "+e.toString(t)),delete t._warned):v.push("\u2705 "+e.toString(t)),a.used.push(t.name))}v.length>0&&n.info(v.join(" "))},e.dependencies=function(a,s){var u=e.dependencyParse(a),i=u.name;if(s=s||{},!(i in s)){a=e.resolve(a)||a,s[i]=n.map(a.uses||[],function(l){e.isPlugin(l)&&e.register(l);var t=e.dependencyParse(l),r=e.resolve(l);return r&&!e.versionSatisfies(r.version,t.range)?(n.warn("Plugin.dependencies:",e.toString(r),"does not satisfy",e.toString(t),"used by",e.toString(u)+"."),r._warned=!0,a._warned=!0):r||(n.warn("Plugin.dependencies:",e.toString(l),"used by",e.toString(u),"could not be resolved."),a._warned=!0),t.name});for(var v=0;v<s[i].length;v+=1)e.dependencies(s[i][v],s);return s}},e.dependencyParse=function(a){if(n.isString(a)){var s=/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/;return s.test(a)||n.warn("Plugin.dependencyParse:",a,"is not a valid dependency string."),{name:a.split("@")[0],range:a.split("@")[1]||"*"}}return{name:a.name,range:a.range||a.version}},e.versionParse=function(a){var s=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;s.test(a)||n.warn("Plugin.versionParse:",a,"is not a valid version or range.");var u=s.exec(a),i=Number(u[4]),v=Number(u[5]),l=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:a,operator:u[1]||u[2]||"",major:i,minor:v,patch:l,parts:[i,v,l],prerelease:u[7],number:i*1e8+v*1e4+l}},e.versionSatisfies=function(a,s){s=s||"*";var u=e.versionParse(s),i=e.versionParse(a);if(u.isRange){if(u.operator==="*"||a==="*")return!0;if(u.operator===">")return i.number>u.number;if(u.operator===">=")return i.number>=u.number;if(u.operator==="~")return i.major===u.major&&i.minor===u.minor&&i.patch>=u.patch;if(u.operator==="^")return u.major>0?i.major===u.major&&i.number>=u.number:u.minor>0?i.minor===u.minor&&i.patch>=u.patch:i.patch===u.patch}return a===s||a==="*"}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e){return{vertex:e,normalImpulse:0,tangentImpulse:0}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(7),a=f(18),s=f(13),u=f(19),i=f(5),v=f(6),l=f(10),t=f(0),r=f(4);(function(){e._deltaMax=1e3/60,e.create=function(o){o=o||{};var c={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0,lastUpdatesPerFrame:0}},d=t.extend(c,o);return d.world=o.world||v.create({label:"World"}),d.pairs=o.pairs||u.create(),d.detector=o.detector||s.create(),d.detector.pairs=d.pairs,d.grid={buckets:[]},d.world.gravity=d.gravity,d.broadphase=d.grid,d.metrics={},d},e.update=function(o,c){var d=t.now(),y=o.world,P=o.detector,M=o.pairs,h=o.timing,m=h.timestamp,x;c>e._deltaMax&&t.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to",e._deltaMax.toFixed(3),"ms."),c=typeof c<"u"?c:t._baseDelta,c*=h.timeScale,h.timestamp+=c,h.lastDelta=c;var p={timestamp:h.timestamp,delta:c};i.trigger(o,"beforeUpdate",p);var C=v.allBodies(y),w=v.allConstraints(y);for(y.isModified&&(s.setBodies(P,C),v.setModified(y,!1,!1,!0)),o.enableSleeping&&n.update(C,c),e._bodiesApplyGravity(C,o.gravity),c>0&&e._bodiesUpdate(C,c),i.trigger(o,"beforeSolve",p),l.preSolveAll(C),x=0;x<o.constraintIterations;x++)l.solveAll(w,c);l.postSolveAll(C);var S=s.collisions(P);u.update(M,S,m),o.enableSleeping&&n.afterCollisions(M.list),M.collisionStart.length>0&&i.trigger(o,"collisionStart",{pairs:M.collisionStart,timestamp:h.timestamp,delta:c});var I=t.clamp(20/o.positionIterations,0,1);for(a.preSolvePosition(M.list),x=0;x<o.positionIterations;x++)a.solvePosition(M.list,c,I);for(a.postSolvePosition(C),l.preSolveAll(C),x=0;x<o.constraintIterations;x++)l.solveAll(w,c);for(l.postSolveAll(C),a.preSolveVelocity(M.list),x=0;x<o.velocityIterations;x++)a.solveVelocity(M.list,c);return e._bodiesUpdateVelocities(C),M.collisionActive.length>0&&i.trigger(o,"collisionActive",{pairs:M.collisionActive,timestamp:h.timestamp,delta:c}),M.collisionEnd.length>0&&i.trigger(o,"collisionEnd",{pairs:M.collisionEnd,timestamp:h.timestamp,delta:c}),e._bodiesClearForces(C),i.trigger(o,"afterUpdate",p),o.timing.lastElapsed=t.now()-d,o},e.merge=function(o,c){if(t.extend(o,c),c.world){o.world=c.world,e.clear(o);for(var d=v.allBodies(o.world),y=0;y<d.length;y++){var P=d[y];n.set(P,!1),P.id=t.nextId()}}},e.clear=function(o){u.clear(o.pairs),s.clear(o.detector)},e._bodiesClearForces=function(o){for(var c=o.length,d=0;d<c;d++){var y=o[d];y.force.x=0,y.force.y=0,y.torque=0}},e._bodiesApplyGravity=function(o,c){var d=typeof c.scale<"u"?c.scale:.001,y=o.length;if(!(c.x===0&&c.y===0||d===0))for(var P=0;P<y;P++){var M=o[P];M.isStatic||M.isSleeping||(M.force.y+=M.mass*c.y*d,M.force.x+=M.mass*c.x*d)}},e._bodiesUpdate=function(o,c){for(var d=o.length,y=0;y<d;y++){var P=o[y];P.isStatic||P.isSleeping||r.update(P,c)}},e._bodiesUpdateVelocities=function(o){for(var c=o.length,d=0;d<c;d++)r.updateVelocities(o[d])}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(0),s=f(1);(function(){e._restingThresh=2,e._restingThreshTangent=Math.sqrt(6),e._positionDampen=.9,e._positionWarming=.8,e._frictionNormalMultiplier=5,e._frictionMaxStatic=Number.MAX_VALUE,e.preSolvePosition=function(u){var i,v,l,t=u.length;for(i=0;i<t;i++)v=u[i],v.isActive&&(l=v.contactCount,v.collision.parentA.totalContacts+=l,v.collision.parentB.totalContacts+=l)},e.solvePosition=function(u,i,v){var l,t,r,o,c,d,y,P,M=e._positionDampen*(v||1),h=a.clamp(i/a._baseDelta,0,1),m=u.length;for(l=0;l<m;l++)t=u[l],!(!t.isActive||t.isSensor)&&(r=t.collision,o=r.parentA,c=r.parentB,d=r.normal,t.separation=r.depth+d.x*(c.positionImpulse.x-o.positionImpulse.x)+d.y*(c.positionImpulse.y-o.positionImpulse.y));for(l=0;l<m;l++)t=u[l],!(!t.isActive||t.isSensor)&&(r=t.collision,o=r.parentA,c=r.parentB,d=r.normal,P=t.separation-t.slop*h,(o.isStatic||c.isStatic)&&(P*=2),o.isStatic||o.isSleeping||(y=M/o.totalContacts,o.positionImpulse.x+=d.x*P*y,o.positionImpulse.y+=d.y*P*y),c.isStatic||c.isSleeping||(y=M/c.totalContacts,c.positionImpulse.x-=d.x*P*y,c.positionImpulse.y-=d.y*P*y))},e.postSolvePosition=function(u){for(var i=e._positionWarming,v=u.length,l=n.translate,t=s.update,r=0;r<v;r++){var o=u[r],c=o.positionImpulse,d=c.x,y=c.y,P=o.velocity;if(o.totalContacts=0,d!==0||y!==0){for(var M=0;M<o.parts.length;M++){var h=o.parts[M];l(h.vertices,c),t(h.bounds,h.vertices,P),h.position.x+=d,h.position.y+=y}o.positionPrev.x+=d,o.positionPrev.y+=y,d*P.x+y*P.y<0?(c.x=0,c.y=0):(c.x*=i,c.y*=i)}}},e.preSolveVelocity=function(u){var i=u.length,v,l;for(v=0;v<i;v++){var t=u[v];if(!(!t.isActive||t.isSensor)){var r=t.contacts,o=t.contactCount,c=t.collision,d=c.parentA,y=c.parentB,P=c.normal,M=c.tangent;for(l=0;l<o;l++){var h=r[l],m=h.vertex,x=h.normalImpulse,p=h.tangentImpulse;if(x!==0||p!==0){var C=P.x*x+M.x*p,w=P.y*x+M.y*p;d.isStatic||d.isSleeping||(d.positionPrev.x+=C*d.inverseMass,d.positionPrev.y+=w*d.inverseMass,d.anglePrev+=d.inverseInertia*((m.x-d.position.x)*w-(m.y-d.position.y)*C)),y.isStatic||y.isSleeping||(y.positionPrev.x-=C*y.inverseMass,y.positionPrev.y-=w*y.inverseMass,y.anglePrev-=y.inverseInertia*((m.x-y.position.x)*w-(m.y-y.position.y)*C))}}}}},e.solveVelocity=function(u,i){var v=i/a._baseDelta,l=v*v,t=l*v,r=-e._restingThresh*v,o=e._restingThreshTangent,c=e._frictionNormalMultiplier*v,d=e._frictionMaxStatic,y=u.length,P,M,h,m;for(h=0;h<y;h++){var x=u[h];if(!(!x.isActive||x.isSensor)){var p=x.collision,C=p.parentA,w=p.parentB,S=p.normal.x,I=p.normal.y,A=p.tangent.x,k=p.tangent.y,B=x.inverseMass,E=x.friction*x.frictionStatic*c,L=x.contacts,D=x.contactCount,F=1/D,V=C.position.x-C.positionPrev.x,b=C.position.y-C.positionPrev.y,$=C.angle-C.anglePrev,U=w.position.x-w.positionPrev.x,j=w.position.y-w.positionPrev.y,G=w.angle-w.anglePrev;for(m=0;m<D;m++){var H=L[m],z=H.vertex,W=z.x-C.position.x,ie=z.y-C.position.y,J=z.x-w.position.x,Q=z.y-w.position.y,N=V-ie*$,nt=b+W*$,it=U-Q*G,at=j+J*G,Ee=N-it,De=nt-at,me=S*Ee+I*De,Z=A*Ee+k*De,Re=x.separation+me,xe=Math.min(Re,1);xe=Re<0?0:xe;var Fe=xe*E;Z<-Fe||Z>Fe?(M=Z>0?Z:-Z,P=x.friction*(Z>0?1:-1)*t,P<-M?P=-M:P>M&&(P=M)):(P=Z,M=d);var Oe=W*I-ie*S,He=J*I-Q*S,Ve=F/(B+C.inverseInertia*Oe*Oe+w.inverseInertia*He*He),le=(1+x.restitution)*me*Ve;if(P*=Ve,me<r)H.normalImpulse=0;else{var st=H.normalImpulse;H.normalImpulse+=le,H.normalImpulse>0&&(H.normalImpulse=0),le=H.normalImpulse-st}if(Z<-o||Z>o)H.tangentImpulse=0;else{var ot=H.tangentImpulse;H.tangentImpulse+=P,H.tangentImpulse<-M&&(H.tangentImpulse=-M),H.tangentImpulse>M&&(H.tangentImpulse=M),P=H.tangentImpulse-ot}var fe=S*le+A*P,ce=I*le+k*P;C.isStatic||C.isSleeping||(C.positionPrev.x+=fe*C.inverseMass,C.positionPrev.y+=ce*C.inverseMass,C.anglePrev+=(W*ce-ie*fe)*C.inverseInertia),w.isStatic||w.isSleeping||(w.positionPrev.x-=fe*w.inverseMass,w.positionPrev.y-=ce*w.inverseMass,w.anglePrev-=(J*ce-Q*fe)*w.inverseInertia)}}}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(9),a=f(0);(function(){e.create=function(s){return a.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},s)},e.update=function(s,u,i){var v=n.update,l=n.create,t=n.setActive,r=s.table,o=s.list,c=o.length,d=c,y=s.collisionStart,P=s.collisionEnd,M=s.collisionActive,h=u.length,m=0,x=0,p=0,C,w,S;for(S=0;S<h;S++)C=u[S],w=C.pair,w?(w.isActive&&(M[p++]=w),v(w,C,i)):(w=l(C,i),r[w.id]=w,y[m++]=w,o[d++]=w);for(d=0,c=o.length,S=0;S<c;S++)w=o[S],w.timeUpdated>=i?o[d++]=w:(t(w,!1,i),w.collision.bodyA.sleepCounter>0&&w.collision.bodyB.sleepCounter>0?o[d++]=w:(P[x++]=w,delete r[w.id]));o.length!==d&&(o.length=d),y.length!==m&&(y.length=m),P.length!==x&&(P.length=x),M.length!==p&&(M.length=p)},e.clear=function(s){return s.table={},s.list.length=0,s.collisionStart.length=0,s.collisionActive.length=0,s.collisionEnd.length=0,s}})()}),(function(g,T,f){var e=g.exports=f(21);e.Axes=f(11),e.Bodies=f(12),e.Body=f(4),e.Bounds=f(1),e.Collision=f(8),e.Common=f(0),e.Composite=f(6),e.Composites=f(22),e.Constraint=f(10),e.Contact=f(16),e.Detector=f(13),e.Engine=f(17),e.Events=f(5),e.Grid=f(23),e.Mouse=f(14),e.MouseConstraint=f(24),e.Pair=f(9),e.Pairs=f(19),e.Plugin=f(15),e.Query=f(25),e.Render=f(26),e.Resolver=f(18),e.Runner=f(27),e.SAT=f(28),e.Sleeping=f(7),e.Svg=f(29),e.Vector=f(2),e.Vertices=f(3),e.World=f(30),e.Engine.run=e.Runner.run,e.Common.deprecated(e.Engine,"run","Engine.run \u27A4 use Matter.Runner.run(engine) instead")}),(function(g,T,f){var e={};g.exports=e;var n=f(15),a=f(0);(function(){e.name="matter-js",e.version="0.20.0",e.uses=[],e.used=[],e.use=function(){n.use(e,Array.prototype.slice.call(arguments))},e.before=function(s,u){return s=s.replace(/^Matter./,""),a.chainPathBefore(e,s,u)},e.after=function(s,u){return s=s.replace(/^Matter./,""),a.chainPathAfter(e,s,u)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(6),a=f(10),s=f(0),u=f(4),i=f(12),v=s.deprecated;(function(){e.stack=function(l,t,r,o,c,d,y){for(var P=n.create({label:"Stack"}),M=l,h=t,m,x=0,p=0;p<o;p++){for(var C=0,w=0;w<r;w++){var S=y(M,h,w,p,m,x);if(S){var I=S.bounds.max.y-S.bounds.min.y,A=S.bounds.max.x-S.bounds.min.x;I>C&&(C=I),u.translate(S,{x:A*.5,y:I*.5}),M=S.bounds.max.x+c,n.addBody(P,S),m=S,x+=1}else M+=c}h+=C+d,M=l}return P},e.chain=function(l,t,r,o,c,d){for(var y=l.bodies,P=1;P<y.length;P++){var M=y[P-1],h=y[P],m=M.bounds.max.y-M.bounds.min.y,x=M.bounds.max.x-M.bounds.min.x,p=h.bounds.max.y-h.bounds.min.y,C=h.bounds.max.x-h.bounds.min.x,w={bodyA:M,pointA:{x:x*t,y:m*r},bodyB:h,pointB:{x:C*o,y:p*c}},S=s.extend(w,d);n.addConstraint(l,a.create(S))}return l.label+=" Chain",l},e.mesh=function(l,t,r,o,c){var d=l.bodies,y,P,M,h,m;for(y=0;y<r;y++){for(P=1;P<t;P++)M=d[P-1+y*t],h=d[P+y*t],n.addConstraint(l,a.create(s.extend({bodyA:M,bodyB:h},c)));if(y>0)for(P=0;P<t;P++)M=d[P+(y-1)*t],h=d[P+y*t],n.addConstraint(l,a.create(s.extend({bodyA:M,bodyB:h},c))),o&&P>0&&(m=d[P-1+(y-1)*t],n.addConstraint(l,a.create(s.extend({bodyA:m,bodyB:h},c)))),o&&P<t-1&&(m=d[P+1+(y-1)*t],n.addConstraint(l,a.create(s.extend({bodyA:m,bodyB:h},c))))}return l.label+=" Mesh",l},e.pyramid=function(l,t,r,o,c,d,y){return e.stack(l,t,r,o,c,d,function(P,M,h,m,x,p){var C=Math.min(o,Math.ceil(r/2)),w=x?x.bounds.max.x-x.bounds.min.x:0;if(!(m>C)){m=C-m;var S=m,I=r-1-m;if(!(h<S||h>I)){p===1&&u.translate(x,{x:(h+(r%2===1?1:-1))*w,y:0});var A=x?h*w:0;return y(l+A+h*c,M,h,m,x,p)}}})},e.newtonsCradle=function(l,t,r,o,c){for(var d=n.create({label:"Newtons Cradle"}),y=0;y<r;y++){var P=1.9,M=i.circle(l+y*(o*P),t+c,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),h=a.create({pointA:{x:l+y*(o*P),y:t},bodyB:M});n.addBody(d,M),n.addConstraint(d,h)}return d},v(e,"newtonsCradle","Composites.newtonsCradle \u27A4 moved to newtonsCradle example"),e.car=function(l,t,r,o,c){var d=u.nextGroup(!0),y=20,P=-r*.5+y,M=r*.5-y,h=0,m=n.create({label:"Car"}),x=i.rectangle(l,t,r,o,{collisionFilter:{group:d},chamfer:{radius:o*.5},density:2e-4}),p=i.circle(l+P,t+h,c,{collisionFilter:{group:d},friction:.8}),C=i.circle(l+M,t+h,c,{collisionFilter:{group:d},friction:.8}),w=a.create({bodyB:x,pointB:{x:P,y:h},bodyA:p,stiffness:1,length:0}),S=a.create({bodyB:x,pointB:{x:M,y:h},bodyA:C,stiffness:1,length:0});return n.addBody(m,x),n.addBody(m,p),n.addBody(m,C),n.addConstraint(m,w),n.addConstraint(m,S),m},v(e,"car","Composites.car \u27A4 moved to car example"),e.softBody=function(l,t,r,o,c,d,y,P,M,h){M=s.extend({inertia:1/0},M),h=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},h);var m=e.stack(l,t,r,o,c,d,function(x,p){return i.circle(x,p,P,M)});return e.mesh(m,r,o,y,h),m.label="Soft Body",m},v(e,"softBody","Composites.softBody \u27A4 moved to softBody and cloth examples")})()}),(function(g,T,f){var e={};g.exports=e;var n=f(9),a=f(0),s=a.deprecated;(function(){e.create=function(u){var i={buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return a.extend(i,u)},e.update=function(u,i,v,l){var t,r,o,c=v.world,d=u.buckets,y,P,M=!1;for(t=0;t<i.length;t++){var h=i[t];if(!(h.isSleeping&&!l)&&!(c.bounds&&(h.bounds.max.x<c.bounds.min.x||h.bounds.min.x>c.bounds.max.x||h.bounds.max.y<c.bounds.min.y||h.bounds.min.y>c.bounds.max.y))){var m=e._getRegion(u,h);if(!h.region||m.id!==h.region.id||l){(!h.region||l)&&(h.region=m);var x=e._regionUnion(m,h.region);for(r=x.startCol;r<=x.endCol;r++)for(o=x.startRow;o<=x.endRow;o++){P=e._getBucketId(r,o),y=d[P];var p=r>=m.startCol&&r<=m.endCol&&o>=m.startRow&&o<=m.endRow,C=r>=h.region.startCol&&r<=h.region.endCol&&o>=h.region.startRow&&o<=h.region.endRow;!p&&C&&C&&y&&e._bucketRemoveBody(u,y,h),(h.region===m||p&&!C||l)&&(y||(y=e._createBucket(d,P)),e._bucketAddBody(u,y,h))}h.region=m,M=!0}}}M&&(u.pairsList=e._createActivePairsList(u))},s(e,"update","Grid.update \u27A4 replaced by Matter.Detector"),e.clear=function(u){u.buckets={},u.pairs={},u.pairsList=[]},s(e,"clear","Grid.clear \u27A4 replaced by Matter.Detector"),e._regionUnion=function(u,i){var v=Math.min(u.startCol,i.startCol),l=Math.max(u.endCol,i.endCol),t=Math.min(u.startRow,i.startRow),r=Math.max(u.endRow,i.endRow);return e._createRegion(v,l,t,r)},e._getRegion=function(u,i){var v=i.bounds,l=Math.floor(v.min.x/u.bucketWidth),t=Math.floor(v.max.x/u.bucketWidth),r=Math.floor(v.min.y/u.bucketHeight),o=Math.floor(v.max.y/u.bucketHeight);return e._createRegion(l,t,r,o)},e._createRegion=function(u,i,v,l){return{id:u+","+i+","+v+","+l,startCol:u,endCol:i,startRow:v,endRow:l}},e._getBucketId=function(u,i){return"C"+u+"R"+i},e._createBucket=function(u,i){var v=u[i]=[];return v},e._bucketAddBody=function(u,i,v){var l=u.pairs,t=n.id,r=i.length,o;for(o=0;o<r;o++){var c=i[o];if(!(v.id===c.id||v.isStatic&&c.isStatic)){var d=t(v,c),y=l[d];y?y[2]+=1:l[d]=[v,c,1]}}i.push(v)},e._bucketRemoveBody=function(u,i,v){var l=u.pairs,t=n.id,r;i.splice(a.indexOf(i,v),1);var o=i.length;for(r=0;r<o;r++){var c=l[t(v,i[r])];c&&(c[2]-=1)}},e._createActivePairsList=function(u){var i,v=u.pairs,l=a.keys(v),t=l.length,r=[],o;for(o=0;o<t;o++)i=v[l[o]],i[2]>0?r.push(i):delete v[l[o]];return r}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(7),s=f(14),u=f(5),i=f(13),v=f(10),l=f(6),t=f(0),r=f(1);(function(){e.create=function(o,c){var d=(o?o.mouse:null)||(c?c.mouse:null);d||(o&&o.render&&o.render.canvas?d=s.create(o.render.canvas):c&&c.element?d=s.create(c.element):(d=s.create(),t.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var y=v.create({label:"Mouse Constraint",pointA:d.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),P={type:"mouseConstraint",mouse:d,element:null,body:null,constraint:y,collisionFilter:{category:1,mask:4294967295,group:0}},M=t.extend(P,c);return u.on(o,"beforeUpdate",function(){var h=l.allBodies(o.world);e.update(M,h),e._triggerEvents(M)}),M},e.update=function(o,c){var d=o.mouse,y=o.constraint,P=o.body;if(d.button===0){if(y.bodyB)a.set(y.bodyB,!1),y.pointA=d.position;else for(var M=0;M<c.length;M++)if(P=c[M],r.contains(P.bounds,d.position)&&i.canCollide(P.collisionFilter,o.collisionFilter))for(var h=P.parts.length>1?1:0;h<P.parts.length;h++){var m=P.parts[h];if(n.contains(m.vertices,d.position)){y.pointA=d.position,y.bodyB=o.body=P,y.pointB={x:d.position.x-P.position.x,y:d.position.y-P.position.y},y.angleB=P.angle,a.set(P,!1),u.trigger(o,"startdrag",{mouse:d,body:P});break}}}else y.bodyB=o.body=null,y.pointB=null,P&&u.trigger(o,"enddrag",{mouse:d,body:P})},e._triggerEvents=function(o){var c=o.mouse,d=c.sourceEvents;d.mousemove&&u.trigger(o,"mousemove",{mouse:c}),d.mousedown&&u.trigger(o,"mousedown",{mouse:c}),d.mouseup&&u.trigger(o,"mouseup",{mouse:c}),s.clearSourceEvents(c)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(8),s=f(1),u=f(12),i=f(3);(function(){e.collides=function(v,l){for(var t=[],r=l.length,o=v.bounds,c=a.collides,d=s.overlaps,y=0;y<r;y++){var P=l[y],M=P.parts.length,h=M===1?0:1;if(d(P.bounds,o))for(var m=h;m<M;m++){var x=P.parts[m];if(d(x.bounds,o)){var p=c(x,v);if(p){t.push(p);break}}}}return t},e.ray=function(v,l,t,r){r=r||1e-100;for(var o=n.angle(l,t),c=n.magnitude(n.sub(l,t)),d=(t.x+l.x)*.5,y=(t.y+l.y)*.5,P=u.rectangle(d,y,c,r,{angle:o}),M=e.collides(P,v),h=0;h<M.length;h+=1){var m=M[h];m.body=m.bodyB=m.bodyA}return M},e.region=function(v,l,t){for(var r=[],o=0;o<v.length;o++){var c=v[o],d=s.overlaps(c.bounds,l);(d&&!t||!d&&t)&&r.push(c)}return r},e.point=function(v,l){for(var t=[],r=0;r<v.length;r++){var o=v[r];if(s.contains(o.bounds,l))for(var c=o.parts.length===1?0:1;c<o.parts.length;c++){var d=o.parts[c];if(s.contains(d.bounds,l)&&i.contains(d.vertices,l)){t.push(o);break}}}return t}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(4),a=f(0),s=f(6),u=f(1),i=f(5),v=f(2),l=f(14);(function(){var t,r;typeof window<"u"&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(h){window.setTimeout(function(){h(a.now())},1e3/60)},r=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),e._goodFps=30,e._goodDelta=1e3/60,e.create=function(h){var m={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],engineUpdatesHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",wireframeStrokeStyle:"#bbb",hasBounds:!!h.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},x=a.extend(m,h);return x.canvas&&(x.canvas.width=x.options.width||x.canvas.width,x.canvas.height=x.options.height||x.canvas.height),x.mouse=h.mouse,x.engine=h.engine,x.canvas=x.canvas||d(x.options.width,x.options.height),x.context=x.canvas.getContext("2d"),x.textures={},x.bounds=x.bounds||{min:{x:0,y:0},max:{x:x.canvas.width,y:x.canvas.height}},x.controller=e,x.options.showBroadphase=!1,x.options.pixelRatio!==1&&e.setPixelRatio(x,x.options.pixelRatio),a.isElement(x.element)&&x.element.appendChild(x.canvas),x},e.run=function(h){(function m(x){h.frameRequestId=t(m),o(h,x),e.world(h,x),h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0),(h.options.showStats||h.options.showDebug)&&e.stats(h,h.context,x),(h.options.showPerformance||h.options.showDebug)&&e.performance(h,h.context,x),h.context.setTransform(1,0,0,1,0,0)})()},e.stop=function(h){r(h.frameRequestId)},e.setPixelRatio=function(h,m){var x=h.options,p=h.canvas;m==="auto"&&(m=y(p)),x.pixelRatio=m,p.setAttribute("data-pixel-ratio",m),p.width=x.width*m,p.height=x.height*m,p.style.width=x.width+"px",p.style.height=x.height+"px"},e.setSize=function(h,m,x){h.options.width=m,h.options.height=x,h.bounds.max.x=h.bounds.min.x+m,h.bounds.max.y=h.bounds.min.y+x,h.options.pixelRatio!==1?e.setPixelRatio(h,h.options.pixelRatio):(h.canvas.width=m,h.canvas.height=x)},e.lookAt=function(h,m,x,p){p=typeof p<"u"?p:!0,m=a.isArray(m)?m:[m],x=x||{x:0,y:0};for(var C={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},w=0;w<m.length;w+=1){var S=m[w],I=S.bounds?S.bounds.min:S.min||S.position||S,A=S.bounds?S.bounds.max:S.max||S.position||S;I&&A&&(I.x<C.min.x&&(C.min.x=I.x),A.x>C.max.x&&(C.max.x=A.x),I.y<C.min.y&&(C.min.y=I.y),A.y>C.max.y&&(C.max.y=A.y))}var k=C.max.x-C.min.x+2*x.x,B=C.max.y-C.min.y+2*x.y,E=h.canvas.height,L=h.canvas.width,D=L/E,F=k/B,V=1,b=1;F>D?b=F/D:V=D/F,h.options.hasBounds=!0,h.bounds.min.x=C.min.x,h.bounds.max.x=C.min.x+k*V,h.bounds.min.y=C.min.y,h.bounds.max.y=C.min.y+B*b,p&&(h.bounds.min.x+=k*.5-k*V*.5,h.bounds.max.x+=k*.5-k*V*.5,h.bounds.min.y+=B*.5-B*b*.5,h.bounds.max.y+=B*.5-B*b*.5),h.bounds.min.x-=x.x,h.bounds.max.x-=x.x,h.bounds.min.y-=x.y,h.bounds.max.y-=x.y,h.mouse&&(l.setScale(h.mouse,{x:(h.bounds.max.x-h.bounds.min.x)/h.canvas.width,y:(h.bounds.max.y-h.bounds.min.y)/h.canvas.height}),l.setOffset(h.mouse,h.bounds.min))},e.startViewTransform=function(h){var m=h.bounds.max.x-h.bounds.min.x,x=h.bounds.max.y-h.bounds.min.y,p=m/h.options.width,C=x/h.options.height;h.context.setTransform(h.options.pixelRatio/p,0,0,h.options.pixelRatio/C,0,0),h.context.translate(-h.bounds.min.x,-h.bounds.min.y)},e.endViewTransform=function(h){h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0)},e.world=function(h,m){var x=a.now(),p=h.engine,C=p.world,w=h.canvas,S=h.context,I=h.options,A=h.timing,k=s.allBodies(C),B=s.allConstraints(C),E=I.wireframes?I.wireframeBackground:I.background,L=[],D=[],F,V={timestamp:p.timing.timestamp};if(i.trigger(h,"beforeRender",V),h.currentBackground!==E&&M(h,E),S.globalCompositeOperation="source-in",S.fillStyle="transparent",S.fillRect(0,0,w.width,w.height),S.globalCompositeOperation="source-over",I.hasBounds){for(F=0;F<k.length;F++){var b=k[F];u.overlaps(b.bounds,h.bounds)&&L.push(b)}for(F=0;F<B.length;F++){var $=B[F],U=$.bodyA,j=$.bodyB,G=$.pointA,H=$.pointB;U&&(G=v.add(U.position,$.pointA)),j&&(H=v.add(j.position,$.pointB)),!(!G||!H)&&(u.contains(h.bounds,G)||u.contains(h.bounds,H))&&D.push($)}e.startViewTransform(h),h.mouse&&(l.setScale(h.mouse,{x:(h.bounds.max.x-h.bounds.min.x)/h.options.width,y:(h.bounds.max.y-h.bounds.min.y)/h.options.height}),l.setOffset(h.mouse,h.bounds.min))}else D=B,L=k,h.options.pixelRatio!==1&&h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0);!I.wireframes||p.enableSleeping&&I.showSleeping?e.bodies(h,L,S):(I.showConvexHulls&&e.bodyConvexHulls(h,L,S),e.bodyWireframes(h,L,S)),I.showBounds&&e.bodyBounds(h,L,S),(I.showAxes||I.showAngleIndicator)&&e.bodyAxes(h,L,S),I.showPositions&&e.bodyPositions(h,L,S),I.showVelocity&&e.bodyVelocity(h,L,S),I.showIds&&e.bodyIds(h,L,S),I.showSeparations&&e.separations(h,p.pairs.list,S),I.showCollisions&&e.collisions(h,p.pairs.list,S),I.showVertexNumbers&&e.vertexNumbers(h,L,S),I.showMousePosition&&e.mousePosition(h,h.mouse,S),e.constraints(D,S),I.hasBounds&&e.endViewTransform(h),i.trigger(h,"afterRender",V),A.lastElapsed=a.now()-x},e.stats=function(h,m,x){for(var p=h.engine,C=p.world,w=s.allBodies(C),S=0,I=55,A=44,k=0,B=0,E=0;E<w.length;E+=1)S+=w[E].parts.length;var L={Part:S,Body:w.length,Cons:s.allConstraints(C).length,Comp:s.allComposites(C).length,Pair:p.pairs.list.length};m.fillStyle="#0e0f19",m.fillRect(k,B,I*5.5,A),m.font="12px Arial",m.textBaseline="top",m.textAlign="right";for(var D in L){var F=L[D];m.fillStyle="#aaa",m.fillText(D,k+I,B+8),m.fillStyle="#eee",m.fillText(F,k+I,B+26),k+=I}},e.performance=function(h,m){var x=h.engine,p=h.timing,C=p.deltaHistory,w=p.elapsedHistory,S=p.timestampElapsedHistory,I=p.engineDeltaHistory,A=p.engineUpdatesHistory,k=p.engineElapsedHistory,B=x.timing.lastUpdatesPerFrame,E=x.timing.lastDelta,L=c(C),D=c(w),F=c(I),V=c(A),b=c(k),$=c(S),U=$/L||0,j=Math.round(L/E),G=1e3/L||0,H=4,z=12,W=60,ie=34,J=10,Q=69;m.fillStyle="#0e0f19",m.fillRect(0,50,z*5+W*6+22,ie),e.status(m,J,Q,W,H,C.length,Math.round(G)+" fps",G/e._goodFps,function(N){return C[N]/L-1}),e.status(m,J+z+W,Q,W,H,I.length,E.toFixed(2)+" dt",e._goodDelta/E,function(N){return I[N]/F-1}),e.status(m,J+(z+W)*2,Q,W,H,A.length,B+" upf",Math.pow(a.clamp(V/j||1,0,1),4),function(N){return A[N]/V-1}),e.status(m,J+(z+W)*3,Q,W,H,k.length,b.toFixed(2)+" ut",1-B*b/e._goodFps,function(N){return k[N]/b-1}),e.status(m,J+(z+W)*4,Q,W,H,w.length,D.toFixed(2)+" rt",1-D/e._goodFps,function(N){return w[N]/D-1}),e.status(m,J+(z+W)*5,Q,W,H,S.length,U.toFixed(2)+" x",U*U*U,function(N){return(S[N]/C[N]/U||0)-1})},e.status=function(h,m,x,p,C,w,S,I,A){h.strokeStyle="#888",h.fillStyle="#444",h.lineWidth=1,h.fillRect(m,x+7,p,1),h.beginPath(),h.moveTo(m,x+7-C*a.clamp(.4*A(0),-2,2));for(var k=0;k<p;k+=1)h.lineTo(m+k,x+7-(k<w?C*a.clamp(.4*A(k),-2,2):0));h.stroke(),h.fillStyle="hsl("+a.clamp(25+95*I,0,120)+",100%,60%)",h.fillRect(m,x-7,4,4),h.font="12px Arial",h.textBaseline="middle",h.textAlign="right",h.fillStyle="#eee",h.fillText(S,m+p,x-5)},e.constraints=function(h,m){for(var x=m,p=0;p<h.length;p++){var C=h[p];if(!(!C.render.visible||!C.pointA||!C.pointB)){var w=C.bodyA,S=C.bodyB,I,A;if(w?I=v.add(w.position,C.pointA):I=C.pointA,C.render.type==="pin")x.beginPath(),x.arc(I.x,I.y,3,0,2*Math.PI),x.closePath();else{if(S?A=v.add(S.position,C.pointB):A=C.pointB,x.beginPath(),x.moveTo(I.x,I.y),C.render.type==="spring")for(var k=v.sub(A,I),B=v.perp(v.normalise(k)),E=Math.ceil(a.clamp(C.length/5,12,20)),L,D=1;D<E;D+=1)L=D%2===0?1:-1,x.lineTo(I.x+k.x*(D/E)+B.x*L*4,I.y+k.y*(D/E)+B.y*L*4);x.lineTo(A.x,A.y)}C.render.lineWidth&&(x.lineWidth=C.render.lineWidth,x.strokeStyle=C.render.strokeStyle,x.stroke()),C.render.anchors&&(x.fillStyle=C.render.strokeStyle,x.beginPath(),x.arc(I.x,I.y,3,0,2*Math.PI),x.arc(A.x,A.y,3,0,2*Math.PI),x.closePath(),x.fill())}}},e.bodies=function(h,m,x){var p=x,C=h.engine,w=h.options,S=w.showInternalEdges||!w.wireframes,I,A,k,B;for(k=0;k<m.length;k++)if(I=m[k],!!I.render.visible){for(B=I.parts.length>1?1:0;B<I.parts.length;B++)if(A=I.parts[B],!!A.render.visible){if(w.showSleeping&&I.isSleeping?p.globalAlpha=.5*A.render.opacity:A.render.opacity!==1&&(p.globalAlpha=A.render.opacity),A.render.sprite&&A.render.sprite.texture&&!w.wireframes){var E=A.render.sprite,L=P(h,E.texture);p.translate(A.position.x,A.position.y),p.rotate(A.angle),p.drawImage(L,L.width*-E.xOffset*E.xScale,L.height*-E.yOffset*E.yScale,L.width*E.xScale,L.height*E.yScale),p.rotate(-A.angle),p.translate(-A.position.x,-A.position.y)}else{if(A.circleRadius)p.beginPath(),p.arc(A.position.x,A.position.y,A.circleRadius,0,2*Math.PI);else{p.beginPath(),p.moveTo(A.vertices[0].x,A.vertices[0].y);for(var D=1;D<A.vertices.length;D++)!A.vertices[D-1].isInternal||S?p.lineTo(A.vertices[D].x,A.vertices[D].y):p.moveTo(A.vertices[D].x,A.vertices[D].y),A.vertices[D].isInternal&&!S&&p.moveTo(A.vertices[(D+1)%A.vertices.length].x,A.vertices[(D+1)%A.vertices.length].y);p.lineTo(A.vertices[0].x,A.vertices[0].y),p.closePath()}w.wireframes?(p.lineWidth=1,p.strokeStyle=h.options.wireframeStrokeStyle,p.stroke()):(p.fillStyle=A.render.fillStyle,A.render.lineWidth&&(p.lineWidth=A.render.lineWidth,p.strokeStyle=A.render.strokeStyle,p.stroke()),p.fill())}p.globalAlpha=1}}},e.bodyWireframes=function(h,m,x){var p=x,C=h.options.showInternalEdges,w,S,I,A,k;for(p.beginPath(),I=0;I<m.length;I++)if(w=m[I],!!w.render.visible)for(k=w.parts.length>1?1:0;k<w.parts.length;k++){for(S=w.parts[k],p.moveTo(S.vertices[0].x,S.vertices[0].y),A=1;A<S.vertices.length;A++)!S.vertices[A-1].isInternal||C?p.lineTo(S.vertices[A].x,S.vertices[A].y):p.moveTo(S.vertices[A].x,S.vertices[A].y),S.vertices[A].isInternal&&!C&&p.moveTo(S.vertices[(A+1)%S.vertices.length].x,S.vertices[(A+1)%S.vertices.length].y);p.lineTo(S.vertices[0].x,S.vertices[0].y)}p.lineWidth=1,p.strokeStyle=h.options.wireframeStrokeStyle,p.stroke()},e.bodyConvexHulls=function(h,m,x){var p=x,C,w,S,I,A;for(p.beginPath(),S=0;S<m.length;S++)if(C=m[S],!(!C.render.visible||C.parts.length===1)){for(p.moveTo(C.vertices[0].x,C.vertices[0].y),I=1;I<C.vertices.length;I++)p.lineTo(C.vertices[I].x,C.vertices[I].y);p.lineTo(C.vertices[0].x,C.vertices[0].y)}p.lineWidth=1,p.strokeStyle="rgba(255,255,255,0.2)",p.stroke()},e.vertexNumbers=function(h,m,x){var p=x,C,w,S;for(C=0;C<m.length;C++){var I=m[C].parts;for(S=I.length>1?1:0;S<I.length;S++){var A=I[S];for(w=0;w<A.vertices.length;w++)p.fillStyle="rgba(255,255,255,0.2)",p.fillText(C+"_"+w,A.position.x+(A.vertices[w].x-A.position.x)*.8,A.position.y+(A.vertices[w].y-A.position.y)*.8)}}},e.mousePosition=function(h,m,x){var p=x;p.fillStyle="rgba(255,255,255,0.8)",p.fillText(m.position.x+" "+m.position.y,m.position.x+5,m.position.y-5)},e.bodyBounds=function(h,m,x){var p=x,C=h.engine,w=h.options;p.beginPath();for(var S=0;S<m.length;S++){var I=m[S];if(I.render.visible)for(var A=m[S].parts,k=A.length>1?1:0;k<A.length;k++){var B=A[k];p.rect(B.bounds.min.x,B.bounds.min.y,B.bounds.max.x-B.bounds.min.x,B.bounds.max.y-B.bounds.min.y)}}w.wireframes?p.strokeStyle="rgba(255,255,255,0.08)":p.strokeStyle="rgba(0,0,0,0.1)",p.lineWidth=1,p.stroke()},e.bodyAxes=function(h,m,x){var p=x,C=h.engine,w=h.options,S,I,A,k;for(p.beginPath(),I=0;I<m.length;I++){var B=m[I],E=B.parts;if(B.render.visible)if(w.showAxes)for(A=E.length>1?1:0;A<E.length;A++)for(S=E[A],k=0;k<S.axes.length;k++){var L=S.axes[k];p.moveTo(S.position.x,S.position.y),p.lineTo(S.position.x+L.x*20,S.position.y+L.y*20)}else for(A=E.length>1?1:0;A<E.length;A++)for(S=E[A],k=0;k<S.axes.length;k++)p.moveTo(S.position.x,S.position.y),p.lineTo((S.vertices[0].x+S.vertices[S.vertices.length-1].x)/2,(S.vertices[0].y+S.vertices[S.vertices.length-1].y)/2)}w.wireframes?(p.strokeStyle="indianred",p.lineWidth=1):(p.strokeStyle="rgba(255, 255, 255, 0.4)",p.globalCompositeOperation="overlay",p.lineWidth=2),p.stroke(),p.globalCompositeOperation="source-over"},e.bodyPositions=function(h,m,x){var p=x,C=h.engine,w=h.options,S,I,A,k;for(p.beginPath(),A=0;A<m.length;A++)if(S=m[A],!!S.render.visible)for(k=0;k<S.parts.length;k++)I=S.parts[k],p.arc(I.position.x,I.position.y,3,0,2*Math.PI,!1),p.closePath();for(w.wireframes?p.fillStyle="indianred":p.fillStyle="rgba(0,0,0,0.5)",p.fill(),p.beginPath(),A=0;A<m.length;A++)S=m[A],S.render.visible&&(p.arc(S.positionPrev.x,S.positionPrev.y,2,0,2*Math.PI,!1),p.closePath());p.fillStyle="rgba(255,165,0,0.8)",p.fill()},e.bodyVelocity=function(h,m,x){var p=x;p.beginPath();for(var C=0;C<m.length;C++){var w=m[C];if(w.render.visible){var S=n.getVelocity(w);p.moveTo(w.position.x,w.position.y),p.lineTo(w.position.x+S.x,w.position.y+S.y)}}p.lineWidth=3,p.strokeStyle="cornflowerblue",p.stroke()},e.bodyIds=function(h,m,x){var p=x,C,w;for(C=0;C<m.length;C++)if(m[C].render.visible){var S=m[C].parts;for(w=S.length>1?1:0;w<S.length;w++){var I=S[w];p.font="12px Arial",p.fillStyle="rgba(255,255,255,0.5)",p.fillText(I.id,I.position.x+10,I.position.y-10)}}},e.collisions=function(h,m,x){var p=x,C=h.options,w,S,I,A,k,B,E;for(p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive)for(S=w.collision,E=0;E<w.contactCount;E++){var L=w.contacts[E],D=L.vertex;p.rect(D.x-1.5,D.y-1.5,3.5,3.5)}for(C.wireframes?p.fillStyle="rgba(255,255,255,0.7)":p.fillStyle="orange",p.fill(),p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive&&(S=w.collision,w.contactCount>0)){var F=w.contacts[0].vertex.x,V=w.contacts[0].vertex.y;w.contactCount===2&&(F=(w.contacts[0].vertex.x+w.contacts[1].vertex.x)/2,V=(w.contacts[0].vertex.y+w.contacts[1].vertex.y)/2),S.bodyB===S.supports[0].body||S.bodyA.isStatic===!0?p.moveTo(F-S.normal.x*8,V-S.normal.y*8):p.moveTo(F+S.normal.x*8,V+S.normal.y*8),p.lineTo(F,V)}C.wireframes?p.strokeStyle="rgba(255,165,0,0.7)":p.strokeStyle="orange",p.lineWidth=1,p.stroke()},e.separations=function(h,m,x){var p=x,C=h.options,w,S,I,A,k,B,E;for(p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive){S=w.collision,A=S.bodyA,k=S.bodyB;var L=1;!k.isStatic&&!A.isStatic&&(L=.5),k.isStatic&&(L=0),p.moveTo(k.position.x,k.position.y),p.lineTo(k.position.x-S.penetration.x*L,k.position.y-S.penetration.y*L),L=1,!k.isStatic&&!A.isStatic&&(L=.5),A.isStatic&&(L=0),p.moveTo(A.position.x,A.position.y),p.lineTo(A.position.x+S.penetration.x*L,A.position.y+S.penetration.y*L)}C.wireframes?p.strokeStyle="rgba(255,165,0,0.5)":p.strokeStyle="orange",p.stroke()},e.inspector=function(h,m){var x=h.engine,p=h.selected,C=h.render,w=C.options,S;if(w.hasBounds){var I=C.bounds.max.x-C.bounds.min.x,A=C.bounds.max.y-C.bounds.min.y,k=I/C.options.width,B=A/C.options.height;m.scale(1/k,1/B),m.translate(-C.bounds.min.x,-C.bounds.min.y)}for(var E=0;E<p.length;E++){var L=p[E].data;switch(m.translate(.5,.5),m.lineWidth=1,m.strokeStyle="rgba(255,165,0,0.9)",m.setLineDash([1,2]),L.type){case"body":S=L.bounds,m.beginPath(),m.rect(Math.floor(S.min.x-3),Math.floor(S.min.y-3),Math.floor(S.max.x-S.min.x+6),Math.floor(S.max.y-S.min.y+6)),m.closePath(),m.stroke();break;case"constraint":var D=L.pointA;L.bodyA&&(D=L.pointB),m.beginPath(),m.arc(D.x,D.y,10,0,2*Math.PI),m.closePath(),m.stroke();break}m.setLineDash([]),m.translate(-.5,-.5)}h.selectStart!==null&&(m.translate(.5,.5),m.lineWidth=1,m.strokeStyle="rgba(255,165,0,0.6)",m.fillStyle="rgba(255,165,0,0.1)",S=h.selectBounds,m.beginPath(),m.rect(Math.floor(S.min.x),Math.floor(S.min.y),Math.floor(S.max.x-S.min.x),Math.floor(S.max.y-S.min.y)),m.closePath(),m.stroke(),m.fill(),m.translate(-.5,-.5)),w.hasBounds&&m.setTransform(1,0,0,1,0,0)};var o=function(h,m){var x=h.engine,p=h.timing,C=p.historySize,w=x.timing.timestamp;p.delta=m-p.lastTime||e._goodDelta,p.lastTime=m,p.timestampElapsed=w-p.lastTimestamp||0,p.lastTimestamp=w,p.deltaHistory.unshift(p.delta),p.deltaHistory.length=Math.min(p.deltaHistory.length,C),p.engineDeltaHistory.unshift(x.timing.lastDelta),p.engineDeltaHistory.length=Math.min(p.engineDeltaHistory.length,C),p.timestampElapsedHistory.unshift(p.timestampElapsed),p.timestampElapsedHistory.length=Math.min(p.timestampElapsedHistory.length,C),p.engineUpdatesHistory.unshift(x.timing.lastUpdatesPerFrame),p.engineUpdatesHistory.length=Math.min(p.engineUpdatesHistory.length,C),p.engineElapsedHistory.unshift(x.timing.lastElapsed),p.engineElapsedHistory.length=Math.min(p.engineElapsedHistory.length,C),p.elapsedHistory.unshift(p.lastElapsed),p.elapsedHistory.length=Math.min(p.elapsedHistory.length,C)},c=function(h){for(var m=0,x=0;x<h.length;x+=1)m+=h[x];return m/h.length||0},d=function(h,m){var x=document.createElement("canvas");return x.width=h,x.height=m,x.oncontextmenu=function(){return!1},x.onselectstart=function(){return!1},x},y=function(h){var m=h.getContext("2d"),x=window.devicePixelRatio||1,p=m.webkitBackingStorePixelRatio||m.mozBackingStorePixelRatio||m.msBackingStorePixelRatio||m.oBackingStorePixelRatio||m.backingStorePixelRatio||1;return x/p},P=function(h,m){var x=h.textures[m];return x||(x=h.textures[m]=new Image,x.src=m,x)},M=function(h,m){var x=m;/(jpg|gif|png)$/.test(m)&&(x="url("+m+")"),h.canvas.style.background=x,h.canvas.style.backgroundSize="contain",h.currentBackground=m}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(5),a=f(17),s=f(0);(function(){e._maxFrameDelta=1e3/15,e._frameDeltaFallback=1e3/60,e._timeBufferMargin=1.5,e._elapsedNextEstimate=1,e._smoothingLowerBound=.1,e._smoothingUpperBound=.9,e.create=function(i){var v={delta:16.666666666666668,frameDelta:null,frameDeltaSmoothing:!0,frameDeltaSnapping:!0,frameDeltaHistory:[],frameDeltaHistorySize:100,frameRequestId:null,timeBuffer:0,timeLastTick:null,maxUpdates:null,maxFrameTime:33.333333333333336,lastUpdatesDeferred:0,enabled:!0},l=s.extend(v,i);return l.fps=0,l},e.run=function(i,v){return i.timeBuffer=e._frameDeltaFallback,(function l(t){i.frameRequestId=e._onNextFrame(i,l),t&&i.enabled&&e.tick(i,v,t)})(),i},e.tick=function(i,v,l){var t=s.now(),r=i.delta,o=0,c=l-i.timeLastTick;if((!c||!i.timeLastTick||c>Math.max(e._maxFrameDelta,i.maxFrameTime))&&(c=i.frameDelta||e._frameDeltaFallback),i.frameDeltaSmoothing){i.frameDeltaHistory.push(c),i.frameDeltaHistory=i.frameDeltaHistory.slice(-i.frameDeltaHistorySize);var d=i.frameDeltaHistory.slice(0).sort(),y=i.frameDeltaHistory.slice(d.length*e._smoothingLowerBound,d.length*e._smoothingUpperBound),P=u(y);c=P||c}i.frameDeltaSnapping&&(c=1e3/Math.round(1e3/c)),i.frameDelta=c,i.timeLastTick=l,i.timeBuffer+=i.frameDelta,i.timeBuffer=s.clamp(i.timeBuffer,0,i.frameDelta+r*e._timeBufferMargin),i.lastUpdatesDeferred=0;var M=i.maxUpdates||Math.ceil(i.maxFrameTime/r),h={timestamp:v.timing.timestamp};n.trigger(i,"beforeTick",h),n.trigger(i,"tick",h);for(var m=s.now();r>0&&i.timeBuffer>=r*e._timeBufferMargin;){n.trigger(i,"beforeUpdate",h),a.update(v,r),n.trigger(i,"afterUpdate",h),i.timeBuffer-=r,o+=1;var x=s.now()-t,p=s.now()-m,C=x+e._elapsedNextEstimate*p/o;if(o>=M||C>i.maxFrameTime){i.lastUpdatesDeferred=Math.round(Math.max(0,i.timeBuffer/r-e._timeBufferMargin));break}}v.timing.lastUpdatesPerFrame=o,n.trigger(i,"afterTick",h),i.frameDeltaHistory.length>=100&&(i.lastUpdatesDeferred&&Math.round(i.frameDelta/r)>M?s.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs."):i.lastUpdatesDeferred&&s.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."),typeof i.isFixed<"u"&&s.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."),(i.deltaMin||i.deltaMax)&&s.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."),i.fps!==0&&s.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."))},e.stop=function(i){e._cancelNextFrame(i)},e._onNextFrame=function(i,v){if(typeof window<"u"&&window.requestAnimationFrame)i.frameRequestId=window.requestAnimationFrame(v);else throw new Error("Matter.Runner: missing required global window.requestAnimationFrame.");return i.frameRequestId},e._cancelNextFrame=function(i){if(typeof window<"u"&&window.cancelAnimationFrame)window.cancelAnimationFrame(i.frameRequestId);else throw new Error("Matter.Runner: missing required global window.cancelAnimationFrame.")};var u=function(i){for(var v=0,l=i.length,t=0;t<l;t+=1)v+=i[t];return v/l||0}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(8),a=f(0),s=a.deprecated;(function(){e.collides=function(u,i){return n.collides(u,i)},s(e,"collides","SAT.collides \u27A4 replaced by Collision.collides")})()}),(function(g,T,f){var e={};g.exports=e;var n=f(1),a=f(0);(function(){e.pathToVertices=function(s,u){typeof window<"u"&&!("SVGPathSeg"in window)&&a.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var i,v,l,t,r,o,c,d,y,P,M=[],h,m,x=0,p=0,C=0;u=u||15;var w=function(I,A,k){var B=k%2===1&&k>1;if(!y||I!=y.x||A!=y.y){y&&B?(h=y.x,m=y.y):(h=0,m=0);var E={x:h+I,y:m+A};(B||!y)&&(y=E),M.push(E),p=h+I,C=m+A}},S=function(I){var A=I.pathSegTypeAsLetter.toUpperCase();if(A!=="Z"){switch(A){case"M":case"L":case"T":case"C":case"S":case"Q":p=I.x,C=I.y;break;case"H":p=I.x;break;case"V":C=I.y;break}w(p,C,I.pathSegType)}};for(e._svgPathToAbsolute(s),l=s.getTotalLength(),o=[],i=0;i<s.pathSegList.numberOfItems;i+=1)o.push(s.pathSegList.getItem(i));for(c=o.concat();x<l;){if(P=s.getPathSegAtLength(x),r=o[P],r!=d){for(;c.length&&c[0]!=r;)S(c.shift());d=r}switch(r.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":t=s.getPointAtLength(x),w(t.x,t.y,0);break}x+=u}for(i=0,v=c.length;i<v;++i)S(c[i]);return M},e._svgPathToAbsolute=function(s){for(var u,i,v,l,t,r,o=s.pathSegList,c=0,d=0,y=o.numberOfItems,P=0;P<y;++P){var M=o.getItem(P),h=M.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(h))"x"in M&&(c=M.x),"y"in M&&(d=M.y);else switch("x1"in M&&(v=c+M.x1),"x2"in M&&(t=c+M.x2),"y1"in M&&(l=d+M.y1),"y2"in M&&(r=d+M.y2),"x"in M&&(c+=M.x),"y"in M&&(d+=M.y),h){case"m":o.replaceItem(s.createSVGPathSegMovetoAbs(c,d),P);break;case"l":o.replaceItem(s.createSVGPathSegLinetoAbs(c,d),P);break;case"h":o.replaceItem(s.createSVGPathSegLinetoHorizontalAbs(c),P);break;case"v":o.replaceItem(s.createSVGPathSegLinetoVerticalAbs(d),P);break;case"c":o.replaceItem(s.createSVGPathSegCurvetoCubicAbs(c,d,v,l,t,r),P);break;case"s":o.replaceItem(s.createSVGPathSegCurvetoCubicSmoothAbs(c,d,t,r),P);break;case"q":o.replaceItem(s.createSVGPathSegCurvetoQuadraticAbs(c,d,v,l),P);break;case"t":o.replaceItem(s.createSVGPathSegCurvetoQuadraticSmoothAbs(c,d),P);break;case"a":o.replaceItem(s.createSVGPathSegArcAbs(c,d,M.r1,M.r2,M.angle,M.largeArcFlag,M.sweepFlag),P);break;case"z":case"Z":c=u,d=i;break}(h=="M"||h=="m")&&(u=c,i=d)}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(6),a=f(0);(function(){e.create=n.create,e.add=n.add,e.remove=n.remove,e.clear=n.clear,e.addComposite=n.addComposite,e.addBody=n.addBody,e.addConstraint=n.addConstraint})()})])})});var Ge=gt($e(),1),{Engine:We,Bodies:ze,Composite:Se,Body:Ue}=Ge.default,dt=250,Ne={read:"#6a9bcc",edit:"#788c5d",terminal:"#d4a27f",web:"#c46686",agent:"#cbcadb",ai:"#d97757",other:"#b0aea5"};function Y(g,T,f,e,n=0){return ze.rectangle(g,T,f,e,{isStatic:!0,angle:n,friction:.1})}var ue=class{constructor(){this.engine=We.create({enableSleeping:!0}),this.engine.gravity.y=1.15,this.tokens=[],Se.add(this.engine.world,[Y(190,522,230,24),Y(96,484,14,64),Y(284,484,14,64),Y(134,432,44,12),Y(246,432,44,12),Y(162,320,12,175),Y(218,320,12,175),Y(146,172,100,12,1.05),Y(234,172,100,12,-1.05)])}drop(T,f=0){let e=Ne[T]||Ne.other,n=8+Math.min(5,f),a=190+(Math.random()-.5)*80,s=ze.circle(a,-40-Math.random()*30,n,{restitution:.35,friction:.05,frictionAir:.012,density:.0015});Ue.setVelocity(s,{x:(Math.random()-.5)*1.5,y:1+Math.random()*2}),Ue.setAngularVelocity(s,(Math.random()-.5)*.2),Se.add(this.engine.world,s);let u={body:s,category:T,color:e,r:n,bornAt:performance.now(),dissolveAt:0};if(this.tokens.push(u),this.tokens.length>dt){let i=this.tokens.find(v=>!v.dissolveAt);i&&(i.dissolveAt=performance.now())}return u}step(T,f){We.update(this.engine,Math.min(T,33));let e=performance.now();for(let n of this.tokens){if(n.dissolveAt)continue;let a=n.body.position.y>620||n.body.position.x<-40||n.body.position.x>420,s=e-n.bornAt>30*6e4;(a||s)&&(n.dissolveAt=e)}for(let n=this.tokens.length-1;n>=0;n--){let a=this.tokens[n];a.dissolveAt&&e-a.dissolveAt>700&&(Se.remove(this.engine.world,a.body),this.tokens.splice(n,1))}}};var ve=380,Je=600,ee=510,pt=120,mt='Georgia, "Times New Roman", serif',Qe='"Cascadia Mono", Consolas, "Courier New", monospace';function te(g){g.beginPath(),g.moveTo(146,200),g.bezierCurveTo(116,162,130,102,190,102),g.bezierCurveTo(250,102,264,162,234,200),g.bezierCurveTo(222,252,214,320,212,392),g.bezierCurveTo(213,412,219,424,228,430),g.lineTo(262,430),g.quadraticCurveTo(270,430,270,438),g.lineTo(270,462),g.lineTo(282,462),g.quadraticCurveTo(290,462,290,470),g.lineTo(290,498),g.quadraticCurveTo(290,510,278,510),g.lineTo(102,510),g.quadraticCurveTo(90,510,90,498),g.lineTo(90,470),g.quadraticCurveTo(90,462,98,462),g.lineTo(110,462),g.lineTo(110,438),g.quadraticCurveTo(110,430,118,430),g.lineTo(152,430),g.bezierCurveTo(161,424,167,412,168,392),g.bezierCurveTo(166,320,158,252,146,200),g.closePath()}var _=[{p:0,c:[212,162,127]},{p:55,c:[217,119,87]},{p:85,c:[198,97,63]},{p:100,c:[157,60,40]}];function Ke(g){let T=Math.max(0,Math.min(100,g));for(let f=1;f<_.length;f++)if(T<=_[f].p){let e=_[f-1],n=_[f],a=(T-e.p)/(n.p-e.p||1);return e.c.map((s,u)=>Math.round(s+(n.c[u]-s)*a))}return _[_.length-1].c}var Ce=(g,T)=>`rgba(${g[0]},${g[1]},${g[2]},${T})`;function Me(g){return ee-Math.max(0,Math.min(100,g))/100*(ee-pt)}function Ze(g,T=!1){let f=T?"250,249,245":"20,20,19";te(g),g.fillStyle=T?"rgba(250,249,245,0.05)":"rgba(255,255,255,0.35)",g.fill(),g.save(),te(g),g.clip(),g.strokeStyle=`rgba(${f},0.18)`,g.lineWidth=1.5,g.beginPath(),g.ellipse(190,158,22,55,0,0,Math.PI*2),g.stroke(),g.beginPath(),g.ellipse(190,158,44,55,0,0,Math.PI*2),g.stroke(),g.beginPath(),g.ellipse(190,158,57,18,0,0,Math.PI*2),g.stroke(),g.restore(),te(g),g.strokeStyle=`rgba(${f},${T?.75:.65})`,g.lineWidth=2.5,g.lineJoin="round",g.stroke(),g.beginPath(),g.moveTo(152,130),g.quadraticCurveTo(144,152,150,178),g.strokeStyle=T?"rgba(250,249,245,0.22)":"rgba(255,255,255,0.8)",g.lineWidth=5,g.lineCap="round",g.stroke(),g.font='600 13px ui-monospace, "Cascadia Mono", Consolas, monospace',g.textAlign="center",g.textBaseline="middle",g.fillStyle=`rgba(${f},0.5)`,g.fillText("W O R L D C U P",190,487)}function xt(g){g.font=`10px ${Qe}`,g.fillStyle="rgba(20,20,19,0.4)",g.strokeStyle="rgba(20,20,19,0.3)",g.lineWidth=1.5,g.textAlign="left";for(let T of[25,50,75]){let f=Me(T);g.beginPath(),g.moveTo(316,f),g.lineTo(328,f),g.stroke(),g.fillText(`${T}`,334,f+3)}}function se(g,T,f,e,n,a=0,s=1,u=!1){g.save(),g.translate(T,f),g.scale(e,e);let i=Ke(n),v=Me(n);if(n>.5){g.save(),te(g),g.clip(),g.fillStyle=Ce(i,1),g.fillRect(40,v,300,ee-v+10),g.fillStyle="rgba(250,249,245,0.45)",g.fillRect(40,v,300,3);let l=s,t=()=>(l=l*16807%2147483647)/2147483647,r=Math.min(26,a),o=["#6a9bcc","#788c5d","#d4a27f","#c46686","#cbcadb"];for(let c=0;c<r;c++){let d=75+t()*230,y=ee-14-t()*Math.min(90,ee-v-18);g.beginPath(),g.arc(d,y,7,0,Math.PI*2),g.fillStyle=o[c%o.length],g.globalAlpha=.9,g.fill(),g.globalAlpha=1}g.restore()}Ze(g,u),g.restore()}var he=class{constructor(T){this.canvas=T,this.ctx=T.getContext("2d"),this.physics=new ue,this.fill=0,this.targetFill=0,this.estimated=!1,this.energy=0,this.bubbles=[],this.spills=[],this.sprites=new Map,this.lastT=performance.now(),this.wavePhase=0,this._resize=this._resize.bind(this),new ResizeObserver(this._resize).observe(T.parentElement),this._resize(),requestAnimationFrame(f=>this._frame(f))}setFill(T,f=!1){this.targetFill=Math.max(0,Math.min(100,T)),this.estimated=f}drop(T,f=0){this.physics.drop(T,f),this.energy=Math.min(14,this.energy+2.2)}seed(T,f){let e=Object.entries(T).filter(([,u])=>u>0),n=e.reduce((u,[,i])=>u+i,0)||1,a=Math.min(80,f),s=120;for(let[u,i]of e){let v=Math.max(1,Math.round(i/n*a));for(let l=0;l<v;l++)setTimeout(()=>this.drop(u),s),s+=28+Math.random()*40}}_sprite(T,f){let e=`${T}-${f}`,n=this.sprites.get(e);if(n)return n;let a=f+3,s=document.createElement("canvas");s.width=s.height=Math.ceil(a*2);let u=s.getContext("2d"),i=a;return u.beginPath(),u.arc(i,i,f,0,Math.PI*2),u.fillStyle=T,u.fill(),u.strokeStyle="rgba(20,20,19,0.45)",u.lineWidth=1.4,u.stroke(),u.beginPath(),u.arc(i-f*.3,i-f*.35,f*.28,0,Math.PI*2),u.fillStyle="rgba(250,249,245,0.6)",u.fill(),n={canvas:s,pad:a},this.sprites.set(e,n),n}_resize(){let T=this.canvas.parentElement,f=Math.min(2,window.devicePixelRatio||1),e=T.clientWidth,n=T.clientHeight;!e||!n||(this.canvas.width=Math.round(e*f),this.canvas.height=Math.round(n*f),this.dpr=f,this.scale=Math.min(e*f/ve,n*f/Je)*.92,this.ox=(e*f-ve*this.scale)/2,this.oy=(n*f-Je*this.scale)/2)}_surfaceY(T,f,e){return f+Math.sin(T*.045+this.wavePhase)*e+Math.sin(T*.02-this.wavePhase*.7)*e*.6}_frame(T){let f=T-this.lastT;this.lastT=T,this.wavePhase+=f*.0022,this.energy=Math.max(0,this.energy-f*.004),this.fill+=(this.targetFill-this.fill)*Math.min(1,f*.0015),Math.abs(this.targetFill-this.fill)<.05&&(this.fill=this.targetFill);let e=Me(this.fill);this.physics.step(f,e),this._draw(T,f,e),requestAnimationFrame(n=>this._frame(n))}_draw(T,f,e){let{ctx:n,canvas:a}=this;n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,a.width,a.height),n.setTransform(this.scale,0,0,this.scale,this.ox,this.oy);let s=Ke(this.fill),u=2.2+this.energy,i=this.fill>=95;if(n.beginPath(),n.ellipse(190,522,150,14,0,0,Math.PI*2),n.fillStyle="rgba(20,20,19,0.07)",n.fill(),xt(n),this.fill>.3){n.save(),te(n),n.clip(),n.beginPath(),n.moveTo(40,this._surfaceY(40,e,u));for(let o=50;o<=340;o+=10)n.lineTo(o,this._surfaceY(o,e,u));n.lineTo(340,520),n.lineTo(40,520),n.closePath(),n.fillStyle=Ce(s,1),n.fill(),n.beginPath(),n.moveTo(40,this._surfaceY(40,e,u));for(let o=50;o<=340;o+=10)n.lineTo(o,this._surfaceY(o,e,u));n.strokeStyle="rgba(250,249,245,0.7)",n.lineWidth=2,n.stroke(),this._bubbles(n,f,e),n.restore()}this._tokens(n,e),Ze(n,!1),i&&this._spill(n,f,s);let v=e<205,l=v?"rgba(250,249,245,0.96)":"rgba(20,20,19,0.92)",t=v?"rgba(250,249,245,0.75)":"rgba(94,93,89,0.95)";n.font=`600 44px ${mt}`,n.textAlign="center",n.textBaseline="middle",n.fillStyle=l,n.fillText(`${Math.round(this.fill)}%`,190,162),n.font=`500 10px ${Qe}`,n.fillStyle=t;let r=this.estimated?"EST. ACTIVITY":"OF 5H LIMIT";n.fillText(r.split("").join("\u200A"),190,192)}_tokens(T,f){T.save(),te(T),T.rect(125,-80,130,185),T.clip();let e=performance.now();for(let n of this.physics.tokens){let{body:a,color:s,r:u}=n,i=1;if(n.dissolveAt&&(i=Math.max(0,1-(e-n.dissolveAt)/700),i<=0))continue;let v=a.position.y>f+4,l=this._sprite(s,u);T.globalAlpha=i*(v?.55:1),T.drawImage(l.canvas,a.position.x-l.pad,a.position.y-l.pad),T.globalAlpha=1}T.restore()}_bubbles(T,f,e){this.fill>2&&Math.random()<.02+this.energy*.012&&this.bubbles.push({x:118+Math.random()*144,y:ee-10,r:1.5+Math.random()*3,vy:.02+Math.random()*.03});for(let n=this.bubbles.length-1;n>=0;n--){let a=this.bubbles[n];if(a.y-=a.vy*f,a.x+=Math.sin(a.y*.05)*.3,a.y<e+6){this.bubbles.splice(n,1);continue}T.beginPath(),T.arc(a.x,a.y,a.r,0,Math.PI*2),T.strokeStyle="rgba(250,249,245,0.55)",T.lineWidth=1,T.stroke()}}_spill(T,f,e){if(Math.random()<.12){let n=Math.random()<.5?-1:1;this.spills.push({x:190+n*(52+Math.random()*8),y:112,vx:n*(.02+Math.random()*.05),vy:-.05-Math.random()*.06,r:2.5+Math.random()*2.5,life:1})}for(let n=this.spills.length-1;n>=0;n--){let a=this.spills[n];if(a.vy+=f*6e-4,a.x+=a.vx*f,a.y+=a.vy*f,a.life-=f*.0012,a.life<=0||a.y>590){this.spills.splice(n,1);continue}T.beginPath(),T.arc(a.x,a.y,a.r,0,Math.PI*2),T.fillStyle=Ce(e,.85*a.life),T.fill()}}};var _e=g=>g>=1e6?(g/1e6).toFixed(1)+"M":g>=1e3?(g/1e3).toFixed(1)+"k":String(g),yt="#faf9f5",Ye="#f0eee6",ge="#141413",Xe="#5e5d59",we="#87867f",Pe="#d97757",de='Georgia, "Times New Roman", serif',St='-apple-system, "Segoe UI", Arial, sans-serif',oe='"Cascadia Mono", Consolas, "Courier New", monospace',re=g=>g.toUpperCase().split("").join("\u200A");function pe(g,T="landscape"){let f=T==="landscape"?1200:1080,e=T==="landscape"?630:1350,n=document.createElement("canvas");n.width=f,n.height=e;let a=n.getContext("2d");if(a.fillStyle=yt,a.fillRect(0,0,f,e),a.strokeStyle="rgba(20,20,19,0.18)",a.lineWidth=1.5,a.strokeRect(28,28,f-56,e-56),Ct(a,76,78,17),a.font=`500 17px ${oe}`,a.fillStyle=we,a.textAlign="left",a.fillText(re("claude-jar"),110,84),T==="landscape"){a.fillStyle=Ye,a.fillRect(64,124,420,442),se(a,92,138,.69,g.fill,g.stats.toolCalls,7);let s=560;a.textAlign="left",a.fillStyle=ge,a.font=`600 130px ${de}`,a.fillText(`${Math.round(g.fill)}%`,s,240),je(a,s+4,262,a.measureText(`${Math.round(g.fill)}%`).width-8),a.font=`500 16px ${oe}`,a.fillStyle=Xe,a.fillText(re(g.estimated?"estimated activity today":"of my 5h claude limit used"),s,312),Mt(a,s,376,g),qe(a,f,e,g)}else{a.fillStyle=Ye,a.fillRect(64,130,f-128,700);let s=1.04;se(a,(f-ve*s)/2,156,s,g.fill,g.stats.toolCalls,7),a.textAlign="center",a.fillStyle=ge,a.font=`600 150px ${de}`,a.fillText(`${Math.round(g.fill)}%`,f/2,980),je(a,f/2-130,1004,260),a.font=`500 18px ${oe}`,a.fillStyle=Xe,a.fillText(re(g.estimated?"estimated activity today":"of my 5h claude limit used"),f/2,1052),a.font=`400 30px ${de}`,a.fillStyle=ge,a.fillText(`${_e(g.stats.totalTokens)} tokens \xB7 ${g.stats.efficiency} tok/reply \xB7 ${g.stats.assistantMessages} replies`,f/2,1140),qe(a,f,e,g)}return n}function Ct(g,T,f,e){g.save(),g.strokeStyle=Pe,g.lineWidth=4.5,g.lineCap="round";for(let n=0;n<8;n++){let a=Math.PI/4*n;g.beginPath(),g.moveTo(T+Math.cos(a)*e*.25,f+Math.sin(a)*e*.25),g.lineTo(T+Math.cos(a)*e,f+Math.sin(a)*e),g.stroke()}g.restore()}function je(g,T,f,e){g.fillStyle=Pe,g.fillRect(T,f,e,4),g.fillRect(T,f+8,e,4)}function Mt(g,T,f,e){let n=[[_e(e.stats.totalTokens),"tokens today"],[e.stats.efficiency,"tok / reply"],[String(e.stats.assistantMessages),"claude replies"],[`$${e.stats.cost.toFixed(2)}`,"est. api value"]],a=f;for(let[s,u]of n)g.font=`600 36px ${de}`,g.fillStyle=ge,g.fillText(s,T,a),g.font=`500 13px ${oe}`,g.fillStyle=we,g.fillText(re(u),T+200,a-4),a+=56}function qe(g,T,f,e){g.strokeStyle="rgba(20,20,19,0.12)",g.lineWidth=1,g.beginPath(),g.moveTo(64,f-86),g.lineTo(T-64,f-86),g.stroke(),g.textAlign="left",g.font=`600 22px ${St}`,g.fillStyle=Pe,g.fillText("npx claude-jar",64,f-50),g.textAlign="right",g.font=`500 15px ${oe}`,g.fillStyle=we,g.fillText(re(e.dateLabel),T-64,f-50)}var R=g=>document.getElementById(g),K=g=>g>=1e6?(g/1e6).toFixed(2)+"M":g>=1e3?(g/1e3).toFixed(1)+"k":String(g??0),O={stats:null,usage:null,history:[],seeded:!1,leaderboard:null},q=new he(R("jar-canvas"));function tt(){let g=O.usage;if(g&&g.fiveHour&&(g.status==="ok"||g.status==="stale"))q.setFill(g.fiveHour.pct,!1),R("overflow-badge").classList.toggle("hidden",g.fiveHour.pct<95);else if(O.stats){let T=Math.min(92,Math.max(O.stats.totalTokens>0?4:0,O.stats.totalTokens/15e4*100));q.setFill(T,!0),R("overflow-badge").classList.add("hidden")}}function et(g){O.usage=g;let T=R("banner");g.status==="ok"&&g.fiveHour?(R("pct-5h").textContent=`${Math.round(g.fiveHour.pct)}%`,T.classList.add("hidden")):g.status==="stale"&&g.fiveHour?(R("pct-5h").textContent=`${Math.round(g.fiveHour.pct)}%`,T.textContent=`showing last known limits - ${g.reason}`,T.classList.remove("hidden")):(R("pct-5h").textContent="--%",R("reset-5h").textContent="",T.textContent=`limit data unavailable - ${g.reason}. Showing local activity only.`,T.classList.remove("hidden")),g.sevenDay&&(R("pct-7d").textContent=`${Math.round(g.sevenDay.pct)}%`,R("bar-7d").style.width=`${g.sevenDay.pct}%`,R("bar-7d").style.background=g.sevenDay.pct>85?"#c6613f":""),tt()}function Te(g){O.stats=g,R("stat-tokens").textContent=K(g.totalTokens),R("stat-tokens-sub").textContent=`in ${K(g.tokensIn)} / out ${K(g.tokensOut)}`,R("stat-cost").textContent=`$${(g.cost??0).toFixed(2)}`,R("stat-eff").textContent=String(g.buildRate??0),R("stat-messages").textContent=K(g.assistantMessages),R("stat-sessions").textContent=String(g.sessions??0);let T=O.leaderboard;R("stat-burn").textContent=T&&T.rank>0?`#${T.rank} / ${K(T.total)}`:"--",R("stat-cache").textContent=K(g.cacheRead);let f=g.toolsByCategory||{};for(let e of["read","edit","terminal","web","agent"])R(`cat-${e}`).textContent=String(f[e]||0);R("cat-ai").textContent=K(g.assistantMessages),R("empty-hint").classList.toggle("hidden",g.totalTokens>0||g.toolCalls>0),tt()}function wt(){let g=O.usage?.timeLeft;if(!g)return"";if(g.outlasts)return" \xB7 lasts past reset";let T=Math.floor(g.minutes/60),f=Math.round(g.minutes%60);return` \xB7 ~${T>0?`${T}h ${f}m`:`${f}m`} left at this pace`}function Ie(){let g=O.usage,T=R("reset-5h");if(!g||!g.fiveHour||!g.fiveHour.resetsAt){T.textContent&&(T.textContent="");return}let f=Date.parse(g.fiveHour.resetsAt)-Date.now();if(f<=0){T.textContent="resetting...";return}let e=Math.floor(f/36e5),n=Math.floor(f%36e5/6e4);T.textContent=(e>0?`resets in ${e}h ${n}m`:`resets in ${n}m`)+wt()}setInterval(Ie,1e3);var Pt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ae(){let g=R("shelf-jars");g.innerHTML="";let T=[...O.history];O.stats&&T.push({date:O.stats.date,totalTokens:O.stats.totalTokens,toolCalls:O.stats.toolCalls,fillMax:Math.max(O.stats.fillMax||0,O.usage?.fiveHour?.pct||0),today:!0});for(let e of T){let n=document.createElement("div");n.className="shelf-jar"+(e.today?" today":"");let a=document.createElement("canvas");a.width=88,a.height=124;let s=a.getContext("2d"),u=e.fillMax||Math.min(85,(e.totalTokens||0)/15e4*100);se(s,-2,-6,.225,u,Math.min(10,Math.round((e.toolCalls||0)/10)),3);let i=e.today?"today":Pt[new Date(e.date+"T12:00:00").getDay()];n.appendChild(a),n.insertAdjacentHTML("beforeend",`<span class="day">${i}</span><span class="amt">${e.totalTokens?K(e.totalTokens):"-"}</span>`),n.title=`${e.date}: ${K(e.totalTokens)} tokens, ${e.toolCalls||0} tool calls, peak ${Math.round(e.fillMax||0)}%`,g.appendChild(n)}let f=0;for(let e=T.length-1;e>=0&&(T[e].totalTokens||0)>0;e--)f++;R("streak").textContent=f>1?`${f}-day streak`:""}function Be(){return{fill:O.usage?.fiveHour?O.usage.fiveHour.pct:q.fill,estimated:!(O.usage&&O.usage.fiveHour),stats:{totalTokens:O.stats?.totalTokens||0,toolCalls:O.stats?.toolCalls||0,assistantMessages:O.stats?.assistantMessages||0,efficiency:O.stats?.assistantMessages>0?K(Math.round(O.stats.totalTokens/O.stats.assistantMessages)):"\u2014",cost:O.stats?.cost||0},dateLabel:new Date().toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}}var ne=null;function Tt(){ne=pe(Be(),"landscape");let g=R("share-preview");g.width=ne.width,g.height=ne.height,g.getContext("2d").drawImage(ne,0,0),R("share-modal").classList.remove("hidden")}function Le(g,T){g.toBlob(f=>{let e=document.createElement("a");e.href=URL.createObjectURL(f),e.download=T,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)},"image/png")}R("share-btn").addEventListener("click",Tt);R("share-close").addEventListener("click",()=>R("share-modal").classList.add("hidden"));R("share-modal").addEventListener("click",g=>{g.target===R("share-modal")&&R("share-modal").classList.add("hidden")});R("share-dl-land").addEventListener("click",()=>Le(pe(Be(),"landscape"),"claude-jar.png"));R("share-dl-story").addEventListener("click",()=>Le(pe(Be(),"story"),"claude-jar-story.png"));R("share-copy").addEventListener("click",async()=>{let g=R("share-copy");try{let T=await new Promise(f=>ne.toBlob(f,"image/png"));await navigator.clipboard.write([new ClipboardItem({"image/png":T})]),g.textContent="Copied!"}catch{Le(ne,"claude-jar.png"),g.textContent="Downloaded instead"}setTimeout(()=>g.textContent="Copy image",1800)});var X={on:!1,busy:!1};function ke(g){X.on=!!(g&&g.on),R("eco-toggle").classList.toggle("on",X.on),R("eco-toggle").setAttribute("aria-pressed",String(X.on)),R("eco-state").textContent=X.on?"on":"off",R("stat-eff-sub").textContent=X.on?`eco on \xB7 ${g.summary||"token saver"}`:"eco mode off"}R("eco-toggle").addEventListener("click",async()=>{if(!X.busy){X.busy=!0,R("eco-toggle").style.opacity="0.6";try{let T=await(await fetch("/api/eco",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({on:!X.on})})).json();if(ke(T.status),!T.ok&&T.error){let f=R("banner");f.textContent=T.error,f.classList.remove("hidden")}}catch{}R("eco-toggle").style.opacity="",X.busy=!1}});function At(){let g=new EventSource("/events");g.addEventListener("open",()=>{R("live-dot").classList.add("on"),R("live-dot").title="live"}),g.addEventListener("error",()=>{R("live-dot").classList.remove("on"),R("live-dot").title="reconnecting..."}),g.addEventListener("snapshot",T=>{let f=JSON.parse(T.data);if(O.history=f.history||[],Te(f.stats),et(f.usage),ke(f.eco),Ie(),Ae(),!O.seeded){O.seeded=!0;let e={...f.stats.toolsByCategory};e.ai=Math.min(20,f.stats.assistantMessages),q.seed(e,f.stats.toolCalls+e.ai)}}),g.addEventListener("activity",T=>{let f=JSON.parse(T.data);f.kind==="message"?q.drop("ai",Math.min(5,(f.tokens||0)/600)):q.drop(f.category||"other")}),g.addEventListener("stats",T=>{Te(JSON.parse(T.data)),Ae()}),g.addEventListener("usage",T=>{et(JSON.parse(T.data)),Ie(),Ae()}),g.addEventListener("eco",T=>{ke(JSON.parse(T.data))}),g.addEventListener("leaderboard",T=>{O.leaderboard=JSON.parse(T.data),O.stats&&Te(O.stats)})}At();window.__jar={state:O,scene:q};})();
|
|
1
|
+
(()=>{var rt=Object.create;var be=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var vt=(g,T)=>()=>(T||g((T={exports:{}}).exports,T),T.exports);var ht=(g,T,f,e)=>{if(T&&typeof T=="object"||typeof T=="function")for(let n of ft(T))!ut.call(g,n)&&n!==f&&be(g,n,{get:()=>T[n],enumerable:!(e=lt(T,n))||e.enumerable});return g};var gt=(g,T,f)=>(f=g!=null?rt(ct(g)):{},ht(T||!g||!g.__esModule?be(f,"default",{value:g,enumerable:!0}):f,g));var $e=vt((ae,ye)=>{(function(T,f){typeof ae=="object"&&typeof ye=="object"?ye.exports=f():typeof define=="function"&&define.amd?define("Matter",[],f):typeof ae=="object"?ae.Matter=f():T.Matter=f()})(ae,function(){return(function(g){var T={};function f(e){if(T[e])return T[e].exports;var n=T[e]={i:e,l:!1,exports:{}};return g[e].call(n.exports,n,n.exports,f),n.l=!0,n.exports}return f.m=g,f.c=T,f.d=function(e,n,a){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:a})},f.r=function(e){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(n&1&&(e=f(e)),n&8||n&4&&typeof e=="object"&&e&&e.__esModule)return e;var a=Object.create(null);if(f.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),n&2&&typeof e!="string")for(var s in e)f.d(a,s,function(u){return e[u]}.bind(null,s));return a},f.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f(f.s=20)})([(function(g,T){var f={};g.exports=f,(function(){f._baseDelta=1e3/60,f._nextId=0,f._seed=0,f._nowStartTime=+new Date,f._warnedOnce={},f._decomp=null,f.extend=function(n,a){var s,u,i;typeof a=="boolean"?(s=2,i=a):(s=1,i=!0);for(var v=s;v<arguments.length;v++){var l=arguments[v];if(l)for(var t in l)i&&l[t]&&l[t].constructor===Object&&(!n[t]||n[t].constructor===Object)?(n[t]=n[t]||{},f.extend(n[t],i,l[t])):n[t]=l[t]}return n},f.clone=function(n,a){return f.extend({},a,n)},f.keys=function(n){if(Object.keys)return Object.keys(n);var a=[];for(var s in n)a.push(s);return a},f.values=function(n){var a=[];if(Object.keys){for(var s=Object.keys(n),u=0;u<s.length;u++)a.push(n[s[u]]);return a}for(var i in n)a.push(n[i]);return a},f.get=function(n,a,s,u){a=a.split(".").slice(s,u);for(var i=0;i<a.length;i+=1)n=n[a[i]];return n},f.set=function(n,a,s,u,i){var v=a.split(".").slice(u,i);return f.get(n,a,0,-1)[v[v.length-1]]=s,s},f.shuffle=function(n){for(var a=n.length-1;a>0;a--){var s=Math.floor(f.random()*(a+1)),u=n[a];n[a]=n[s],n[s]=u}return n},f.choose=function(n){return n[Math.floor(f.random()*n.length)]},f.isElement=function(n){return typeof HTMLElement<"u"?n instanceof HTMLElement:!!(n&&n.nodeType&&n.nodeName)},f.isArray=function(n){return Object.prototype.toString.call(n)==="[object Array]"},f.isFunction=function(n){return typeof n=="function"},f.isPlainObject=function(n){return typeof n=="object"&&n.constructor===Object},f.isString=function(n){return toString.call(n)==="[object String]"},f.clamp=function(n,a,s){return n<a?a:n>s?s:n},f.sign=function(n){return n<0?-1:1},f.now=function(){if(typeof window<"u"&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-f._nowStartTime},f.random=function(n,a){return n=typeof n<"u"?n:0,a=typeof a<"u"?a:1,n+e()*(a-n)};var e=function(){return f._seed=(f._seed*9301+49297)%233280,f._seed/233280};f.colorToNumber=function(n){return n=n.replace("#",""),n.length==3&&(n=n.charAt(0)+n.charAt(0)+n.charAt(1)+n.charAt(1)+n.charAt(2)+n.charAt(2)),parseInt(n,16)},f.logLevel=1,f.log=function(){console&&f.logLevel>0&&f.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.info=function(){console&&f.logLevel>0&&f.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.warn=function(){console&&f.logLevel>0&&f.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},f.warnOnce=function(){var n=Array.prototype.slice.call(arguments).join(" ");f._warnedOnce[n]||(f.warn(n),f._warnedOnce[n]=!0)},f.deprecated=function(n,a,s){n[a]=f.chain(function(){f.warnOnce("\u{1F505} deprecated \u{1F505}",s)},n[a])},f.nextId=function(){return f._nextId++},f.indexOf=function(n,a){if(n.indexOf)return n.indexOf(a);for(var s=0;s<n.length;s++)if(n[s]===a)return s;return-1},f.map=function(n,a){if(n.map)return n.map(a);for(var s=[],u=0;u<n.length;u+=1)s.push(a(n[u]));return s},f.topologicalSort=function(n){var a=[],s=[],u=[];for(var i in n)!s[i]&&!u[i]&&f._topologicalSort(i,s,u,n,a);return a},f._topologicalSort=function(n,a,s,u,i){var v=u[n]||[];s[n]=!0;for(var l=0;l<v.length;l+=1){var t=v[l];s[t]||a[t]||f._topologicalSort(t,a,s,u,i)}s[n]=!1,a[n]=!0,i.push(n)},f.chain=function(){for(var n=[],a=0;a<arguments.length;a+=1){var s=arguments[a];s._chained?n.push.apply(n,s._chained):n.push(s)}var u=function(){for(var i,v=new Array(arguments.length),l=0,t=arguments.length;l<t;l++)v[l]=arguments[l];for(l=0;l<n.length;l+=1){var r=n[l].apply(i,v);typeof r<"u"&&(i=r)}return i};return u._chained=n,u},f.chainPathBefore=function(n,a,s){return f.set(n,a,f.chain(s,f.get(n,a)))},f.chainPathAfter=function(n,a,s){return f.set(n,a,f.chain(f.get(n,a),s))},f.setDecomp=function(n){f._decomp=n},f.getDecomp=function(){var n=f._decomp;try{!n&&typeof window<"u"&&(n=window.decomp),!n&&typeof global<"u"&&(n=global.decomp)}catch{n=null}return n}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e){var n={min:{x:0,y:0},max:{x:0,y:0}};return e&&f.update(n,e),n},f.update=function(e,n,a){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var s=0;s<n.length;s++){var u=n[s];u.x>e.max.x&&(e.max.x=u.x),u.x<e.min.x&&(e.min.x=u.x),u.y>e.max.y&&(e.max.y=u.y),u.y<e.min.y&&(e.min.y=u.y)}a&&(a.x>0?e.max.x+=a.x:e.min.x+=a.x,a.y>0?e.max.y+=a.y:e.min.y+=a.y)},f.contains=function(e,n){return n.x>=e.min.x&&n.x<=e.max.x&&n.y>=e.min.y&&n.y<=e.max.y},f.overlaps=function(e,n){return e.min.x<=n.max.x&&e.max.x>=n.min.x&&e.max.y>=n.min.y&&e.min.y<=n.max.y},f.translate=function(e,n){e.min.x+=n.x,e.max.x+=n.x,e.min.y+=n.y,e.max.y+=n.y},f.shift=function(e,n){var a=e.max.x-e.min.x,s=e.max.y-e.min.y;e.min.x=n.x,e.max.x=n.x+a,e.min.y=n.y,e.max.y=n.y+s}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e,n){return{x:e||0,y:n||0}},f.clone=function(e){return{x:e.x,y:e.y}},f.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},f.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},f.rotate=function(e,n,a){var s=Math.cos(n),u=Math.sin(n);a||(a={});var i=e.x*s-e.y*u;return a.y=e.x*u+e.y*s,a.x=i,a},f.rotateAbout=function(e,n,a,s){var u=Math.cos(n),i=Math.sin(n);s||(s={});var v=a.x+((e.x-a.x)*u-(e.y-a.y)*i);return s.y=a.y+((e.x-a.x)*i+(e.y-a.y)*u),s.x=v,s},f.normalise=function(e){var n=f.magnitude(e);return n===0?{x:0,y:0}:{x:e.x/n,y:e.y/n}},f.dot=function(e,n){return e.x*n.x+e.y*n.y},f.cross=function(e,n){return e.x*n.y-e.y*n.x},f.cross3=function(e,n,a){return(n.x-e.x)*(a.y-e.y)-(n.y-e.y)*(a.x-e.x)},f.add=function(e,n,a){return a||(a={}),a.x=e.x+n.x,a.y=e.y+n.y,a},f.sub=function(e,n,a){return a||(a={}),a.x=e.x-n.x,a.y=e.y-n.y,a},f.mult=function(e,n){return{x:e.x*n,y:e.y*n}},f.div=function(e,n){return{x:e.x/n,y:e.y/n}},f.perp=function(e,n){return n=n===!0?-1:1,{x:n*-e.y,y:n*e.x}},f.neg=function(e){return{x:-e.x,y:-e.y}},f.angle=function(e,n){return Math.atan2(n.y-e.y,n.x-e.x)},f._temp=[f.create(),f.create(),f.create(),f.create(),f.create(),f.create()]})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(0);(function(){e.create=function(s,u){for(var i=[],v=0;v<s.length;v++){var l=s[v],t={x:l.x,y:l.y,index:v,body:u,isInternal:!1};i.push(t)}return i},e.fromPath=function(s,u){var i=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,v=[];return s.replace(i,function(l,t,r){v.push({x:parseFloat(t),y:parseFloat(r)})}),e.create(v,u)},e.centre=function(s){for(var u=e.area(s,!0),i={x:0,y:0},v,l,t,r=0;r<s.length;r++)t=(r+1)%s.length,v=n.cross(s[r],s[t]),l=n.mult(n.add(s[r],s[t]),v),i=n.add(i,l);return n.div(i,6*u)},e.mean=function(s){for(var u={x:0,y:0},i=0;i<s.length;i++)u.x+=s[i].x,u.y+=s[i].y;return n.div(u,s.length)},e.area=function(s,u){for(var i=0,v=s.length-1,l=0;l<s.length;l++)i+=(s[v].x-s[l].x)*(s[v].y+s[l].y),v=l;return u?i/2:Math.abs(i)/2},e.inertia=function(s,u){for(var i=0,v=0,l=s,t,r,o=0;o<l.length;o++)r=(o+1)%l.length,t=Math.abs(n.cross(l[r],l[o])),i+=t*(n.dot(l[r],l[r])+n.dot(l[r],l[o])+n.dot(l[o],l[o])),v+=t;return u/6*(i/v)},e.translate=function(s,u,i){i=typeof i<"u"?i:1;var v=s.length,l=u.x*i,t=u.y*i,r;for(r=0;r<v;r++)s[r].x+=l,s[r].y+=t;return s},e.rotate=function(s,u,i){if(u!==0){var v=Math.cos(u),l=Math.sin(u),t=i.x,r=i.y,o=s.length,c,d,y,P;for(P=0;P<o;P++)c=s[P],d=c.x-t,y=c.y-r,c.x=t+(d*v-y*l),c.y=r+(d*l+y*v);return s}},e.contains=function(s,u){for(var i=u.x,v=u.y,l=s.length,t=s[l-1],r,o=0;o<l;o++){if(r=s[o],(i-t.x)*(r.y-t.y)+(v-t.y)*(t.x-r.x)>0)return!1;t=r}return!0},e.scale=function(s,u,i,v){if(u===1&&i===1)return s;v=v||e.centre(s);for(var l,t,r=0;r<s.length;r++)l=s[r],t=n.sub(l,v),s[r].x=v.x+t.x*u,s[r].y=v.y+t.y*i;return s},e.chamfer=function(s,u,i,v,l){typeof u=="number"?u=[u]:u=u||[8],i=typeof i<"u"?i:-1,v=v||2,l=l||14;for(var t=[],r=0;r<s.length;r++){var o=s[r-1>=0?r-1:s.length-1],c=s[r],d=s[(r+1)%s.length],y=u[r<u.length?r:u.length-1];if(y===0){t.push(c);continue}var P=n.normalise({x:c.y-o.y,y:o.x-c.x}),M=n.normalise({x:d.y-c.y,y:c.x-d.x}),h=Math.sqrt(2*Math.pow(y,2)),m=n.mult(a.clone(P),y),x=n.normalise(n.mult(n.add(P,M),.5)),p=n.sub(c,n.mult(x,h)),C=i;i===-1&&(C=Math.pow(y,.32)*1.75),C=a.clamp(C,v,l),C%2===1&&(C+=1);for(var w=Math.acos(n.dot(P,M)),S=w/C,I=0;I<C;I++)t.push(n.add(n.rotate(m,S*I),p))}return t},e.clockwiseSort=function(s){var u=e.mean(s);return s.sort(function(i,v){return n.angle(u,i)-n.angle(u,v)}),s},e.isConvex=function(s){var u=0,i=s.length,v,l,t,r;if(i<3)return null;for(v=0;v<i;v++)if(l=(v+1)%i,t=(v+2)%i,r=(s[l].x-s[v].x)*(s[t].y-s[l].y),r-=(s[l].y-s[v].y)*(s[t].x-s[l].x),r<0?u|=1:r>0&&(u|=2),u===3)return!1;return u!==0?!0:null},e.hull=function(s){var u=[],i=[],v,l;for(s=s.slice(0),s.sort(function(t,r){var o=t.x-r.x;return o!==0?o:t.y-r.y}),l=0;l<s.length;l+=1){for(v=s[l];i.length>=2&&n.cross3(i[i.length-2],i[i.length-1],v)<=0;)i.pop();i.push(v)}for(l=s.length-1;l>=0;l-=1){for(v=s[l];u.length>=2&&n.cross3(u[u.length-2],u[u.length-1],v)<=0;)u.pop();u.push(v)}return u.pop(),i.pop(),u.concat(i)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(2),s=f(7),u=f(0),i=f(1),v=f(11);(function(){e._timeCorrection=!0,e._inertiaScale=4,e._nextCollidingGroupId=1,e._nextNonCollidingGroupId=-1,e._nextCategory=1,e._baseDelta=1e3/60,e.create=function(t){var r={id:u.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:n.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,isSensor:!1,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,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:16.666666666666668,_original:null},o=u.extend(r,t);return l(o,t),o},e.nextGroup=function(t){return t?e._nextNonCollidingGroupId--:e._nextCollidingGroupId++},e.nextCategory=function(){return e._nextCategory=e._nextCategory<<1,e._nextCategory};var l=function(t,r){r=r||{},e.set(t,{bounds:t.bounds||i.create(t.vertices),positionPrev:t.positionPrev||a.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),n.rotate(t.vertices,t.angle,t.position),v.rotate(t.axes,t.angle),i.update(t.bounds,t.vertices,t.velocity),e.set(t,{axes:r.axes||t.axes,area:r.area||t.area,mass:r.mass||t.mass,inertia:r.inertia||t.inertia});var o=t.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),c=t.isStatic?"#555":"#ccc",d=t.isStatic&&t.render.fillStyle===null?1:0;t.render.fillStyle=t.render.fillStyle||o,t.render.strokeStyle=t.render.strokeStyle||c,t.render.lineWidth=t.render.lineWidth||d,t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};e.set=function(t,r,o){var c;typeof r=="string"&&(c=r,r={},r[c]=o);for(c in r)if(Object.prototype.hasOwnProperty.call(r,c))switch(o=r[c],c){case"isStatic":e.setStatic(t,o);break;case"isSleeping":s.set(t,o);break;case"mass":e.setMass(t,o);break;case"density":e.setDensity(t,o);break;case"inertia":e.setInertia(t,o);break;case"vertices":e.setVertices(t,o);break;case"position":e.setPosition(t,o);break;case"angle":e.setAngle(t,o);break;case"velocity":e.setVelocity(t,o);break;case"angularVelocity":e.setAngularVelocity(t,o);break;case"speed":e.setSpeed(t,o);break;case"angularSpeed":e.setAngularSpeed(t,o);break;case"parts":e.setParts(t,o);break;case"centre":e.setCentre(t,o);break;default:t[c]=o}},e.setStatic=function(t,r){for(var o=0;o<t.parts.length;o++){var c=t.parts[o];r?(c.isStatic||(c._original={restitution:c.restitution,friction:c.friction,mass:c.mass,inertia:c.inertia,density:c.density,inverseMass:c.inverseMass,inverseInertia:c.inverseInertia}),c.restitution=0,c.friction=1,c.mass=c.inertia=c.density=1/0,c.inverseMass=c.inverseInertia=0,c.positionPrev.x=c.position.x,c.positionPrev.y=c.position.y,c.anglePrev=c.angle,c.angularVelocity=0,c.speed=0,c.angularSpeed=0,c.motion=0):c._original&&(c.restitution=c._original.restitution,c.friction=c._original.friction,c.mass=c._original.mass,c.inertia=c._original.inertia,c.density=c._original.density,c.inverseMass=c._original.inverseMass,c.inverseInertia=c._original.inverseInertia,c._original=null),c.isStatic=r}},e.setMass=function(t,r){var o=t.inertia/(t.mass/6);t.inertia=o*(r/6),t.inverseInertia=1/t.inertia,t.mass=r,t.inverseMass=1/t.mass,t.density=t.mass/t.area},e.setDensity=function(t,r){e.setMass(t,r*t.area),t.density=r},e.setInertia=function(t,r){t.inertia=r,t.inverseInertia=1/t.inertia},e.setVertices=function(t,r){r[0].body===t?t.vertices=r:t.vertices=n.create(r,t),t.axes=v.fromVertices(t.vertices),t.area=n.area(t.vertices),e.setMass(t,t.density*t.area);var o=n.centre(t.vertices);n.translate(t.vertices,o,-1),e.setInertia(t,e._inertiaScale*n.inertia(t.vertices,t.mass)),n.translate(t.vertices,t.position),i.update(t.bounds,t.vertices,t.velocity)},e.setParts=function(t,r,o){var c;for(r=r.slice(0),t.parts.length=0,t.parts.push(t),t.parent=t,c=0;c<r.length;c++){var d=r[c];d!==t&&(d.parent=t,t.parts.push(d))}if(t.parts.length!==1){if(o=typeof o<"u"?o:!0,o){var y=[];for(c=0;c<r.length;c++)y=y.concat(r[c].vertices);n.clockwiseSort(y);var P=n.hull(y),M=n.centre(P);e.setVertices(t,P),n.translate(t.vertices,M)}var h=e._totalProperties(t);t.area=h.area,t.parent=t,t.position.x=h.centre.x,t.position.y=h.centre.y,t.positionPrev.x=h.centre.x,t.positionPrev.y=h.centre.y,e.setMass(t,h.mass),e.setInertia(t,h.inertia),e.setPosition(t,h.centre)}},e.setCentre=function(t,r,o){o?(t.positionPrev.x+=r.x,t.positionPrev.y+=r.y,t.position.x+=r.x,t.position.y+=r.y):(t.positionPrev.x=r.x-(t.position.x-t.positionPrev.x),t.positionPrev.y=r.y-(t.position.y-t.positionPrev.y),t.position.x=r.x,t.position.y=r.y)},e.setPosition=function(t,r,o){var c=a.sub(r,t.position);o?(t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.velocity.x=c.x,t.velocity.y=c.y,t.speed=a.magnitude(c)):(t.positionPrev.x+=c.x,t.positionPrev.y+=c.y);for(var d=0;d<t.parts.length;d++){var y=t.parts[d];y.position.x+=c.x,y.position.y+=c.y,n.translate(y.vertices,c),i.update(y.bounds,y.vertices,t.velocity)}},e.setAngle=function(t,r,o){var c=r-t.angle;o?(t.anglePrev=t.angle,t.angularVelocity=c,t.angularSpeed=Math.abs(c)):t.anglePrev+=c;for(var d=0;d<t.parts.length;d++){var y=t.parts[d];y.angle+=c,n.rotate(y.vertices,c,t.position),v.rotate(y.axes,c),i.update(y.bounds,y.vertices,t.velocity),d>0&&a.rotateAbout(y.position,c,t.position,y.position)}},e.setVelocity=function(t,r){var o=t.deltaTime/e._baseDelta;t.positionPrev.x=t.position.x-r.x*o,t.positionPrev.y=t.position.y-r.y*o,t.velocity.x=(t.position.x-t.positionPrev.x)/o,t.velocity.y=(t.position.y-t.positionPrev.y)/o,t.speed=a.magnitude(t.velocity)},e.getVelocity=function(t){var r=e._baseDelta/t.deltaTime;return{x:(t.position.x-t.positionPrev.x)*r,y:(t.position.y-t.positionPrev.y)*r}},e.getSpeed=function(t){return a.magnitude(e.getVelocity(t))},e.setSpeed=function(t,r){e.setVelocity(t,a.mult(a.normalise(e.getVelocity(t)),r))},e.setAngularVelocity=function(t,r){var o=t.deltaTime/e._baseDelta;t.anglePrev=t.angle-r*o,t.angularVelocity=(t.angle-t.anglePrev)/o,t.angularSpeed=Math.abs(t.angularVelocity)},e.getAngularVelocity=function(t){return(t.angle-t.anglePrev)*e._baseDelta/t.deltaTime},e.getAngularSpeed=function(t){return Math.abs(e.getAngularVelocity(t))},e.setAngularSpeed=function(t,r){e.setAngularVelocity(t,u.sign(e.getAngularVelocity(t))*r)},e.translate=function(t,r,o){e.setPosition(t,a.add(t.position,r),o)},e.rotate=function(t,r,o,c){if(!o)e.setAngle(t,t.angle+r,c);else{var d=Math.cos(r),y=Math.sin(r),P=t.position.x-o.x,M=t.position.y-o.y;e.setPosition(t,{x:o.x+(P*d-M*y),y:o.y+(P*y+M*d)},c),e.setAngle(t,t.angle+r,c)}},e.scale=function(t,r,o,c){var d=0,y=0;c=c||t.position;for(var P=0;P<t.parts.length;P++){var M=t.parts[P];n.scale(M.vertices,r,o,c),M.axes=v.fromVertices(M.vertices),M.area=n.area(M.vertices),e.setMass(M,t.density*M.area),n.translate(M.vertices,{x:-M.position.x,y:-M.position.y}),e.setInertia(M,e._inertiaScale*n.inertia(M.vertices,M.mass)),n.translate(M.vertices,{x:M.position.x,y:M.position.y}),P>0&&(d+=M.area,y+=M.inertia),M.position.x=c.x+(M.position.x-c.x)*r,M.position.y=c.y+(M.position.y-c.y)*o,i.update(M.bounds,M.vertices,t.velocity)}t.parts.length>1&&(t.area=d,t.isStatic||(e.setMass(t,t.density*d),e.setInertia(t,y))),t.circleRadius&&(r===o?t.circleRadius*=r:t.circleRadius=null)},e.update=function(t,r){r=(typeof r<"u"?r:1e3/60)*t.timeScale;var o=r*r,c=e._timeCorrection?r/(t.deltaTime||r):1,d=1-t.frictionAir*(r/u._baseDelta),y=(t.position.x-t.positionPrev.x)*c,P=(t.position.y-t.positionPrev.y)*c;t.velocity.x=y*d+t.force.x/t.mass*o,t.velocity.y=P*d+t.force.y/t.mass*o,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.deltaTime=r,t.angularVelocity=(t.angle-t.anglePrev)*d*c+t.torque/t.inertia*o,t.anglePrev=t.angle,t.angle+=t.angularVelocity;for(var M=0;M<t.parts.length;M++){var h=t.parts[M];n.translate(h.vertices,t.velocity),M>0&&(h.position.x+=t.velocity.x,h.position.y+=t.velocity.y),t.angularVelocity!==0&&(n.rotate(h.vertices,t.angularVelocity,t.position),v.rotate(h.axes,t.angularVelocity),M>0&&a.rotateAbout(h.position,t.angularVelocity,t.position,h.position)),i.update(h.bounds,h.vertices,t.velocity)}},e.updateVelocities=function(t){var r=e._baseDelta/t.deltaTime,o=t.velocity;o.x=(t.position.x-t.positionPrev.x)*r,o.y=(t.position.y-t.positionPrev.y)*r,t.speed=Math.sqrt(o.x*o.x+o.y*o.y),t.angularVelocity=(t.angle-t.anglePrev)*r,t.angularSpeed=Math.abs(t.angularVelocity)},e.applyForce=function(t,r,o){var c={x:r.x-t.position.x,y:r.y-t.position.y};t.force.x+=o.x,t.force.y+=o.y,t.torque+=c.x*o.y-c.y*o.x},e._totalProperties=function(t){for(var r={mass:0,area:0,inertia:0,centre:{x:0,y:0}},o=t.parts.length===1?0:1;o<t.parts.length;o++){var c=t.parts[o],d=c.mass!==1/0?c.mass:1;r.mass+=d,r.area+=c.area,r.inertia+=c.inertia,r.centre=a.add(r.centre,a.mult(c.position,d))}return r.centre=a.div(r.centre,r.mass),r}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e.on=function(a,s,u){for(var i=s.split(" "),v,l=0;l<i.length;l++)v=i[l],a.events=a.events||{},a.events[v]=a.events[v]||[],a.events[v].push(u);return u},e.off=function(a,s,u){if(!s){a.events={};return}typeof s=="function"&&(u=s,s=n.keys(a.events).join(" "));for(var i=s.split(" "),v=0;v<i.length;v++){var l=a.events[i[v]],t=[];if(u&&l)for(var r=0;r<l.length;r++)l[r]!==u&&t.push(l[r]);a.events[i[v]]=t}},e.trigger=function(a,s,u){var i,v,l,t,r=a.events;if(r&&n.keys(r).length>0){u||(u={}),i=s.split(" ");for(var o=0;o<i.length;o++)if(v=i[o],l=r[v],l){t=n.clone(u,!1),t.name=v,t.source=a;for(var c=0;c<l.length;c++)l[c].apply(a,[t])}}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(5),a=f(0),s=f(1),u=f(4);(function(){e.create=function(i){return a.extend({id:a.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},i)},e.setModified=function(i,v,l,t){if(i.isModified=v,v&&i.cache&&(i.cache.allBodies=null,i.cache.allConstraints=null,i.cache.allComposites=null),l&&i.parent&&e.setModified(i.parent,v,l,t),t)for(var r=0;r<i.composites.length;r++){var o=i.composites[r];e.setModified(o,v,l,t)}},e.add=function(i,v){var l=[].concat(v);n.trigger(i,"beforeAdd",{object:v});for(var t=0;t<l.length;t++){var r=l[t];switch(r.type){case"body":if(r.parent!==r){a.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}e.addBody(i,r);break;case"constraint":e.addConstraint(i,r);break;case"composite":e.addComposite(i,r);break;case"mouseConstraint":e.addConstraint(i,r.constraint);break}}return n.trigger(i,"afterAdd",{object:v}),i},e.remove=function(i,v,l){var t=[].concat(v);n.trigger(i,"beforeRemove",{object:v});for(var r=0;r<t.length;r++){var o=t[r];switch(o.type){case"body":e.removeBody(i,o,l);break;case"constraint":e.removeConstraint(i,o,l);break;case"composite":e.removeComposite(i,o,l);break;case"mouseConstraint":e.removeConstraint(i,o.constraint);break}}return n.trigger(i,"afterRemove",{object:v}),i},e.addComposite=function(i,v){return i.composites.push(v),v.parent=i,e.setModified(i,!0,!0,!1),i},e.removeComposite=function(i,v,l){var t=a.indexOf(i.composites,v);if(t!==-1){var r=e.allBodies(v);e.removeCompositeAt(i,t);for(var o=0;o<r.length;o++)r[o].sleepCounter=0}if(l)for(var o=0;o<i.composites.length;o++)e.removeComposite(i.composites[o],v,!0);return i},e.removeCompositeAt=function(i,v){return i.composites.splice(v,1),e.setModified(i,!0,!0,!1),i},e.addBody=function(i,v){return i.bodies.push(v),e.setModified(i,!0,!0,!1),i},e.removeBody=function(i,v,l){var t=a.indexOf(i.bodies,v);if(t!==-1&&(e.removeBodyAt(i,t),v.sleepCounter=0),l)for(var r=0;r<i.composites.length;r++)e.removeBody(i.composites[r],v,!0);return i},e.removeBodyAt=function(i,v){return i.bodies.splice(v,1),e.setModified(i,!0,!0,!1),i},e.addConstraint=function(i,v){return i.constraints.push(v),e.setModified(i,!0,!0,!1),i},e.removeConstraint=function(i,v,l){var t=a.indexOf(i.constraints,v);if(t!==-1&&e.removeConstraintAt(i,t),l)for(var r=0;r<i.composites.length;r++)e.removeConstraint(i.composites[r],v,!0);return i},e.removeConstraintAt=function(i,v){return i.constraints.splice(v,1),e.setModified(i,!0,!0,!1),i},e.clear=function(i,v,l){if(l)for(var t=0;t<i.composites.length;t++)e.clear(i.composites[t],v,!0);return v?i.bodies=i.bodies.filter(function(r){return r.isStatic}):i.bodies.length=0,i.constraints.length=0,i.composites.length=0,e.setModified(i,!0,!0,!1),i},e.allBodies=function(i){if(i.cache&&i.cache.allBodies)return i.cache.allBodies;for(var v=[].concat(i.bodies),l=0;l<i.composites.length;l++)v=v.concat(e.allBodies(i.composites[l]));return i.cache&&(i.cache.allBodies=v),v},e.allConstraints=function(i){if(i.cache&&i.cache.allConstraints)return i.cache.allConstraints;for(var v=[].concat(i.constraints),l=0;l<i.composites.length;l++)v=v.concat(e.allConstraints(i.composites[l]));return i.cache&&(i.cache.allConstraints=v),v},e.allComposites=function(i){if(i.cache&&i.cache.allComposites)return i.cache.allComposites;for(var v=[].concat(i.composites),l=0;l<i.composites.length;l++)v=v.concat(e.allComposites(i.composites[l]));return i.cache&&(i.cache.allComposites=v),v},e.get=function(i,v,l){var t,r;switch(l){case"body":t=e.allBodies(i);break;case"constraint":t=e.allConstraints(i);break;case"composite":t=e.allComposites(i).concat(i);break}return t?(r=t.filter(function(o){return o.id.toString()===v.toString()}),r.length===0?null:r[0]):null},e.move=function(i,v,l){return e.remove(i,v),e.add(l,v),i},e.rebase=function(i){for(var v=e.allBodies(i).concat(e.allConstraints(i)).concat(e.allComposites(i)),l=0;l<v.length;l++)v[l].id=a.nextId();return i},e.translate=function(i,v,l){for(var t=l?e.allBodies(i):i.bodies,r=0;r<t.length;r++)u.translate(t[r],v);return i},e.rotate=function(i,v,l,t){for(var r=Math.cos(v),o=Math.sin(v),c=t?e.allBodies(i):i.bodies,d=0;d<c.length;d++){var y=c[d],P=y.position.x-l.x,M=y.position.y-l.y;u.setPosition(y,{x:l.x+(P*r-M*o),y:l.y+(P*o+M*r)}),u.rotate(y,v)}return i},e.scale=function(i,v,l,t,r){for(var o=r?e.allBodies(i):i.bodies,c=0;c<o.length;c++){var d=o[c],y=d.position.x-t.x,P=d.position.y-t.y;u.setPosition(d,{x:t.x+y*v,y:t.y+P*l}),u.scale(d,v,l)}return i},e.bounds=function(i){for(var v=e.allBodies(i),l=[],t=0;t<v.length;t+=1){var r=v[t];l.push(r.bounds.min,r.bounds.max)}return s.create(l)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(4),a=f(5),s=f(0);(function(){e._motionWakeThreshold=.18,e._motionSleepThreshold=.08,e._minBias=.9,e.update=function(u,i){for(var v=i/s._baseDelta,l=e._motionSleepThreshold,t=0;t<u.length;t++){var r=u[t],o=n.getSpeed(r),c=n.getAngularSpeed(r),d=o*o+c*c;if(r.force.x!==0||r.force.y!==0){e.set(r,!1);continue}var y=Math.min(r.motion,d),P=Math.max(r.motion,d);r.motion=e._minBias*y+(1-e._minBias)*P,r.sleepThreshold>0&&r.motion<l?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold/v&&e.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}},e.afterCollisions=function(u){for(var i=e._motionSleepThreshold,v=0;v<u.length;v++){var l=u[v];if(l.isActive){var t=l.collision,r=t.bodyA.parent,o=t.bodyB.parent;if(!(r.isSleeping&&o.isSleeping||r.isStatic||o.isStatic)&&(r.isSleeping||o.isSleeping)){var c=r.isSleeping&&!r.isStatic?r:o,d=c===r?o:r;!c.isStatic&&d.motion>i&&e.set(c,!1)}}}},e.set=function(u,i){var v=u.isSleeping;i?(u.isSleeping=!0,u.sleepCounter=u.sleepThreshold,u.positionImpulse.x=0,u.positionImpulse.y=0,u.positionPrev.x=u.position.x,u.positionPrev.y=u.position.y,u.anglePrev=u.angle,u.speed=0,u.angularSpeed=0,u.motion=0,v||a.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,v&&a.trigger(u,"sleepEnd"))}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(9);(function(){var s=[],u={overlap:0,axis:null},i={overlap:0,axis:null};e.create=function(v,l){return{pair:null,collided:!1,bodyA:v,bodyB:l,parentA:v.parent,parentB:l.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[null,null],supportCount:0}},e.collides=function(v,l,t){if(e._overlapAxes(u,v.vertices,l.vertices,v.axes),u.overlap<=0||(e._overlapAxes(i,l.vertices,v.vertices,l.axes),i.overlap<=0))return null;var r=t&&t.table[a.id(v,l)],o;r?o=r.collision:(o=e.create(v,l),o.collided=!0,o.bodyA=v.id<l.id?v:l,o.bodyB=v.id<l.id?l:v,o.parentA=o.bodyA.parent,o.parentB=o.bodyB.parent),v=o.bodyA,l=o.bodyB;var c;u.overlap<i.overlap?c=u:c=i;var d=o.normal,y=o.tangent,P=o.penetration,M=o.supports,h=c.overlap,m=c.axis,x=m.x,p=m.y,C=l.position.x-v.position.x,w=l.position.y-v.position.y;x*C+p*w>=0&&(x=-x,p=-p),d.x=x,d.y=p,y.x=-p,y.y=x,P.x=x*h,P.y=p*h,o.depth=h;var S=e._findSupports(v,l,d,1),I=0;if(n.contains(v.vertices,S[0])&&(M[I++]=S[0]),n.contains(v.vertices,S[1])&&(M[I++]=S[1]),I<2){var A=e._findSupports(l,v,d,-1);n.contains(l.vertices,A[0])&&(M[I++]=A[0]),I<2&&n.contains(l.vertices,A[1])&&(M[I++]=A[1])}return I===0&&(M[I++]=S[0]),o.supportCount=I,o},e._overlapAxes=function(v,l,t,r){var o=l.length,c=t.length,d=l[0].x,y=l[0].y,P=t[0].x,M=t[0].y,h=r.length,m=Number.MAX_VALUE,x=0,p,C,w,S,I,A;for(I=0;I<h;I++){var k=r[I],B=k.x,E=k.y,L=d*B+y*E,D=P*B+M*E,F=L,V=D;for(A=1;A<o;A+=1)S=l[A].x*B+l[A].y*E,S>F?F=S:S<L&&(L=S);for(A=1;A<c;A+=1)S=t[A].x*B+t[A].y*E,S>V?V=S:S<D&&(D=S);if(C=F-D,w=V-L,p=C<w?C:w,p<m&&(m=p,x=I,p<=0))break}v.axis=r[x],v.overlap=m},e._findSupports=function(v,l,t,r){var o=l.vertices,c=o.length,d=v.position.x,y=v.position.y,P=t.x*r,M=t.y*r,h=o[0],m=h,x=P*(d-m.x)+M*(y-m.y),p,C,w;for(w=1;w<c;w+=1)m=o[w],C=P*(d-m.x)+M*(y-m.y),C<x&&(x=C,h=m);return p=o[(c+h.index-1)%c],x=P*(d-p.x)+M*(y-p.y),m=o[(h.index+1)%c],P*(d-m.x)+M*(y-m.y)<x?(s[0]=h,s[1]=m,s):(s[0]=h,s[1]=p,s)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(16);(function(){e.create=function(a,s){var u=a.bodyA,i=a.bodyB,v={id:e.id(u,i),bodyA:u,bodyB:i,collision:a,contacts:[n.create(),n.create()],contactCount:0,separation:0,isActive:!0,isSensor:u.isSensor||i.isSensor,timeCreated:s,timeUpdated:s,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return e.update(v,a,s),v},e.update=function(a,s,u){var i=s.supports,v=s.supportCount,l=a.contacts,t=s.parentA,r=s.parentB;a.isActive=!0,a.timeUpdated=u,a.collision=s,a.separation=s.depth,a.inverseMass=t.inverseMass+r.inverseMass,a.friction=t.friction<r.friction?t.friction:r.friction,a.frictionStatic=t.frictionStatic>r.frictionStatic?t.frictionStatic:r.frictionStatic,a.restitution=t.restitution>r.restitution?t.restitution:r.restitution,a.slop=t.slop>r.slop?t.slop:r.slop,a.contactCount=v,s.pair=a;var o=i[0],c=l[0],d=i[1],y=l[1];(y.vertex===o||c.vertex===d)&&(l[1]=c,l[0]=c=y,y=l[1]),c.vertex=o,y.vertex=d},e.setActive=function(a,s,u){s?(a.isActive=!0,a.timeUpdated=u):(a.isActive=!1,a.contactCount=0)},e.id=function(a,s){return a.id<s.id?a.id.toString(36)+":"+s.id.toString(36):s.id.toString(36)+":"+a.id.toString(36)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(2),s=f(7),u=f(1),i=f(11),v=f(0);(function(){e._warming=.4,e._torqueDampen=1,e._minLength=1e-6,e.create=function(l){var t=l;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var r=t.bodyA?a.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?a.add(t.bodyB.position,t.pointB):t.pointB,c=a.magnitude(a.sub(r,o));t.length=typeof t.length<"u"?t.length:c,t.id=t.id||v.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var d={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return t.length===0&&t.stiffness>.1?(d.type="pin",d.anchors=!1):t.stiffness<.9&&(d.type="spring"),t.render=v.extend(d,t.render),t},e.preSolveAll=function(l){for(var t=0;t<l.length;t+=1){var r=l[t],o=r.constraintImpulse;r.isStatic||o.x===0&&o.y===0&&o.angle===0||(r.position.x+=o.x,r.position.y+=o.y,r.angle+=o.angle)}},e.solveAll=function(l,t){for(var r=v.clamp(t/v._baseDelta,0,1),o=0;o<l.length;o+=1){var c=l[o],d=!c.bodyA||c.bodyA&&c.bodyA.isStatic,y=!c.bodyB||c.bodyB&&c.bodyB.isStatic;(d||y)&&e.solve(l[o],r)}for(o=0;o<l.length;o+=1)c=l[o],d=!c.bodyA||c.bodyA&&c.bodyA.isStatic,y=!c.bodyB||c.bodyB&&c.bodyB.isStatic,!d&&!y&&e.solve(l[o],r)},e.solve=function(l,t){var r=l.bodyA,o=l.bodyB,c=l.pointA,d=l.pointB;if(!(!r&&!o)){r&&!r.isStatic&&(a.rotate(c,r.angle-l.angleA,c),l.angleA=r.angle),o&&!o.isStatic&&(a.rotate(d,o.angle-l.angleB,d),l.angleB=o.angle);var y=c,P=d;if(r&&(y=a.add(r.position,c)),o&&(P=a.add(o.position,d)),!(!y||!P)){var M=a.sub(y,P),h=a.magnitude(M);h<e._minLength&&(h=e._minLength);var m=(h-l.length)/h,x=l.stiffness>=1||l.length===0,p=x?l.stiffness*t:l.stiffness*t*t,C=l.damping*t,w=a.mult(M,m*p),S=(r?r.inverseMass:0)+(o?o.inverseMass:0),I=(r?r.inverseInertia:0)+(o?o.inverseInertia:0),A=S+I,k,B,E,L,D;if(C>0){var F=a.create();E=a.div(M,h),D=a.sub(o&&a.sub(o.position,o.positionPrev)||F,r&&a.sub(r.position,r.positionPrev)||F),L=a.dot(E,D)}r&&!r.isStatic&&(B=r.inverseMass/S,r.constraintImpulse.x-=w.x*B,r.constraintImpulse.y-=w.y*B,r.position.x-=w.x*B,r.position.y-=w.y*B,C>0&&(r.positionPrev.x-=C*E.x*L*B,r.positionPrev.y-=C*E.y*L*B),k=a.cross(c,w)/A*e._torqueDampen*r.inverseInertia*(1-l.angularStiffness),r.constraintImpulse.angle-=k,r.angle-=k),o&&!o.isStatic&&(B=o.inverseMass/S,o.constraintImpulse.x+=w.x*B,o.constraintImpulse.y+=w.y*B,o.position.x+=w.x*B,o.position.y+=w.y*B,C>0&&(o.positionPrev.x+=C*E.x*L*B,o.positionPrev.y+=C*E.y*L*B),k=a.cross(d,w)/A*e._torqueDampen*o.inverseInertia*(1-l.angularStiffness),o.constraintImpulse.angle+=k,o.angle+=k)}}},e.postSolveAll=function(l){for(var t=0;t<l.length;t++){var r=l[t],o=r.constraintImpulse;if(!(r.isStatic||o.x===0&&o.y===0&&o.angle===0)){s.set(r,!1);for(var c=0;c<r.parts.length;c++){var d=r.parts[c];n.translate(d.vertices,o),c>0&&(d.position.x+=o.x,d.position.y+=o.y),o.angle!==0&&(n.rotate(d.vertices,o.angle,r.position),i.rotate(d.axes,o.angle),c>0&&a.rotateAbout(d.position,o.angle,r.position,d.position)),u.update(d.bounds,d.vertices,r.velocity)}o.angle*=e._warming,o.x*=e._warming,o.y*=e._warming}}},e.pointAWorld=function(l){return{x:(l.bodyA?l.bodyA.position.x:0)+(l.pointA?l.pointA.x:0),y:(l.bodyA?l.bodyA.position.y:0)+(l.pointA?l.pointA.y:0)}},e.pointBWorld=function(l){return{x:(l.bodyB?l.bodyB.position.x:0)+(l.pointB?l.pointB.x:0),y:(l.bodyB?l.bodyB.position.y:0)+(l.pointB?l.pointB.y:0)}},e.currentLength=function(l){var t=(l.bodyA?l.bodyA.position.x:0)+(l.pointA?l.pointA.x:0),r=(l.bodyA?l.bodyA.position.y:0)+(l.pointA?l.pointA.y:0),o=(l.bodyB?l.bodyB.position.x:0)+(l.pointB?l.pointB.x:0),c=(l.bodyB?l.bodyB.position.y:0)+(l.pointB?l.pointB.y:0),d=t-o,y=r-c;return Math.sqrt(d*d+y*y)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(0);(function(){e.fromVertices=function(s){for(var u={},i=0;i<s.length;i++){var v=(i+1)%s.length,l=n.normalise({x:s[v].y-s[i].y,y:s[i].x-s[v].x}),t=l.y===0?1/0:l.x/l.y;t=t.toFixed(3).toString(),u[t]=l}return a.values(u)},e.rotate=function(s,u){if(u!==0)for(var i=Math.cos(u),v=Math.sin(u),l=0;l<s.length;l++){var t=s[l],r;r=t.x*i-t.y*v,t.y=t.x*v+t.y*i,t.x=r}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(0),s=f(4),u=f(1),i=f(2);(function(){e.rectangle=function(v,l,t,r,o){o=o||{};var c={label:"Rectangle Body",position:{x:v,y:l},vertices:n.fromPath("L 0 0 L "+t+" 0 L "+t+" "+r+" L 0 "+r)};if(o.chamfer){var d=o.chamfer;c.vertices=n.chamfer(c.vertices,d.radius,d.quality,d.qualityMin,d.qualityMax),delete o.chamfer}return s.create(a.extend({},c,o))},e.trapezoid=function(v,l,t,r,o,c){c=c||{},o>=1&&a.warn("Bodies.trapezoid: slope parameter must be < 1."),o*=.5;var d=(1-o*2)*t,y=t*o,P=y+d,M=P+y,h;o<.5?h="L 0 0 L "+y+" "+-r+" L "+P+" "+-r+" L "+M+" 0":h="L 0 0 L "+P+" "+-r+" L "+M+" 0";var m={label:"Trapezoid Body",position:{x:v,y:l},vertices:n.fromPath(h)};if(c.chamfer){var x=c.chamfer;m.vertices=n.chamfer(m.vertices,x.radius,x.quality,x.qualityMin,x.qualityMax),delete c.chamfer}return s.create(a.extend({},m,c))},e.circle=function(v,l,t,r,o){r=r||{};var c={label:"Circle Body",circleRadius:t};o=o||25;var d=Math.ceil(Math.max(10,Math.min(o,t)));return d%2===1&&(d+=1),e.polygon(v,l,d,t,a.extend({},c,r))},e.polygon=function(v,l,t,r,o){if(o=o||{},t<3)return e.circle(v,l,r,o);for(var c=2*Math.PI/t,d="",y=c*.5,P=0;P<t;P+=1){var M=y+P*c,h=Math.cos(M)*r,m=Math.sin(M)*r;d+="L "+h.toFixed(3)+" "+m.toFixed(3)+" "}var x={label:"Polygon Body",position:{x:v,y:l},vertices:n.fromPath(d)};if(o.chamfer){var p=o.chamfer;x.vertices=n.chamfer(x.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete o.chamfer}return s.create(a.extend({},x,o))},e.fromVertices=function(v,l,t,r,o,c,d,y){var P=a.getDecomp(),M,h,m,x,p,C,w,S,I,A,k;for(M=!!(P&&P.quickDecomp),r=r||{},m=[],o=typeof o<"u"?o:!1,c=typeof c<"u"?c:.01,d=typeof d<"u"?d:10,y=typeof y<"u"?y:.01,a.isArray(t[0])||(t=[t]),A=0;A<t.length;A+=1)if(C=t[A],x=n.isConvex(C),p=!x,p&&!M&&a.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),x||!M)x?C=n.clockwiseSort(C):C=n.hull(C),m.push({position:{x:v,y:l},vertices:C});else{var B=C.map(function(H){return[H.x,H.y]});P.makeCCW(B),c!==!1&&P.removeCollinearPoints(B,c),y!==!1&&P.removeDuplicatePoints&&P.removeDuplicatePoints(B,y);var E=P.quickDecomp(B);for(w=0;w<E.length;w++){var L=E[w],D=L.map(function(H){return{x:H[0],y:H[1]}});d>0&&n.area(D)<d||m.push({position:n.centre(D),vertices:D})}}for(w=0;w<m.length;w++)m[w]=s.create(a.extend(m[w],r));if(o){var F=5;for(w=0;w<m.length;w++){var V=m[w];for(S=w+1;S<m.length;S++){var b=m[S];if(u.overlaps(V.bounds,b.bounds)){var $=V.vertices,U=b.vertices;for(I=0;I<V.vertices.length;I++)for(k=0;k<b.vertices.length;k++){var j=i.magnitudeSquared(i.sub($[(I+1)%$.length],U[k])),G=i.magnitudeSquared(i.sub($[I],U[(k+1)%U.length]));j<F&&G<F&&($[I].isInternal=!0,U[k].isInternal=!0)}}}}}return m.length>1?(h=s.create(a.extend({parts:m.slice(0)},r)),s.setPosition(h,{x:v,y:l}),h):m[0]}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0),a=f(8);(function(){e.create=function(s){var u={bodies:[],collisions:[],pairs:null};return n.extend(u,s)},e.setBodies=function(s,u){s.bodies=u.slice(0)},e.clear=function(s){s.bodies=[],s.collisions=[]},e.collisions=function(s){var u=s.pairs,i=s.bodies,v=i.length,l=e.canCollide,t=a.collides,r=s.collisions,o=0,c,d;for(i.sort(e._compareBoundsX),c=0;c<v;c++){var y=i[c],P=y.bounds,M=y.bounds.max.x,h=y.bounds.max.y,m=y.bounds.min.y,x=y.isStatic||y.isSleeping,p=y.parts.length,C=p===1;for(d=c+1;d<v;d++){var w=i[d],S=w.bounds;if(S.min.x>M)break;if(!(h<S.min.y||m>S.max.y)&&!(x&&(w.isStatic||w.isSleeping))&&l(y.collisionFilter,w.collisionFilter)){var I=w.parts.length;if(C&&I===1){var A=t(y,w,u);A&&(r[o++]=A)}else for(var k=p>1?1:0,B=I>1?1:0,E=k;E<p;E++)for(var L=y.parts[E],P=L.bounds,D=B;D<I;D++){var F=w.parts[D],S=F.bounds;if(!(P.min.x>S.max.x||P.max.x<S.min.x||P.max.y<S.min.y||P.min.y>S.max.y)){var A=t(L,F,u);A&&(r[o++]=A)}}}}}return r.length!==o&&(r.length=o),r},e.canCollide=function(s,u){return s.group===u.group&&s.group!==0?s.group>0:(s.mask&u.category)!==0&&(u.mask&s.category)!==0},e._compareBoundsX=function(s,u){return s.bounds.min.x-u.bounds.min.x}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e.create=function(a){var s={};return a||n.log("Mouse.create: element was undefined, defaulting to document.body","warn"),s.element=a||document.body,s.absolute={x:0,y:0},s.position={x:0,y:0},s.mousedownPosition={x:0,y:0},s.mouseupPosition={x:0,y:0},s.offset={x:0,y:0},s.scale={x:1,y:1},s.wheelDelta=0,s.button=-1,s.pixelRatio=parseInt(s.element.getAttribute("data-pixel-ratio"),10)||1,s.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},s.mousemove=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v&&(s.button=0,u.preventDefault()),s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.sourceEvents.mousemove=u},s.mousedown=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v?(s.button=0,u.preventDefault()):s.button=u.button,s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.mousedownPosition.x=s.position.x,s.mousedownPosition.y=s.position.y,s.sourceEvents.mousedown=u},s.mouseup=function(u){var i=e._getRelativeMousePosition(u,s.element,s.pixelRatio),v=u.changedTouches;v&&u.preventDefault(),s.button=-1,s.absolute.x=i.x,s.absolute.y=i.y,s.position.x=s.absolute.x*s.scale.x+s.offset.x,s.position.y=s.absolute.y*s.scale.y+s.offset.y,s.mouseupPosition.x=s.position.x,s.mouseupPosition.y=s.position.y,s.sourceEvents.mouseup=u},s.mousewheel=function(u){s.wheelDelta=Math.max(-1,Math.min(1,u.wheelDelta||-u.detail)),u.preventDefault(),s.sourceEvents.mousewheel=u},e.setElement(s,s.element),s},e.setElement=function(a,s){a.element=s,s.addEventListener("mousemove",a.mousemove,{passive:!0}),s.addEventListener("mousedown",a.mousedown,{passive:!0}),s.addEventListener("mouseup",a.mouseup,{passive:!0}),s.addEventListener("wheel",a.mousewheel,{passive:!1}),s.addEventListener("touchmove",a.mousemove,{passive:!1}),s.addEventListener("touchstart",a.mousedown,{passive:!1}),s.addEventListener("touchend",a.mouseup,{passive:!1})},e.clearSourceEvents=function(a){a.sourceEvents.mousemove=null,a.sourceEvents.mousedown=null,a.sourceEvents.mouseup=null,a.sourceEvents.mousewheel=null,a.wheelDelta=0},e.setOffset=function(a,s){a.offset.x=s.x,a.offset.y=s.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},e.setScale=function(a,s){a.scale.x=s.x,a.scale.y=s.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},e._getRelativeMousePosition=function(a,s,u){var i=s.getBoundingClientRect(),v=document.documentElement||document.body.parentNode||document.body,l=window.pageXOffset!==void 0?window.pageXOffset:v.scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:v.scrollTop,r=a.changedTouches,o,c;return r?(o=r[0].pageX-i.left-l,c=r[0].pageY-i.top-t):(o=a.pageX-i.left-l,c=a.pageY-i.top-t),{x:o/(s.clientWidth/(s.width||s.clientWidth)*u),y:c/(s.clientHeight/(s.height||s.clientHeight)*u)}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(0);(function(){e._registry={},e.register=function(a){if(e.isPlugin(a)||n.warn("Plugin.register:",e.toString(a),"does not implement all required fields."),a.name in e._registry){var s=e._registry[a.name],u=e.versionParse(a.version).number,i=e.versionParse(s.version).number;u>i?(n.warn("Plugin.register:",e.toString(s),"was upgraded to",e.toString(a)),e._registry[a.name]=a):u<i?n.warn("Plugin.register:",e.toString(s),"can not be downgraded to",e.toString(a)):a!==s&&n.warn("Plugin.register:",e.toString(a),"is already registered to different plugin object")}else e._registry[a.name]=a;return a},e.resolve=function(a){return e._registry[e.dependencyParse(a).name]},e.toString=function(a){return typeof a=="string"?a:(a.name||"anonymous")+"@"+(a.version||a.range||"0.0.0")},e.isPlugin=function(a){return a&&a.name&&a.version&&a.install},e.isUsed=function(a,s){return a.used.indexOf(s)>-1},e.isFor=function(a,s){var u=a.for&&e.dependencyParse(a.for);return!a.for||s.name===u.name&&e.versionSatisfies(s.version,u.range)},e.use=function(a,s){if(a.uses=(a.uses||[]).concat(s||[]),a.uses.length===0){n.warn("Plugin.use:",e.toString(a),"does not specify any dependencies to install.");return}for(var u=e.dependencies(a),i=n.topologicalSort(u),v=[],l=0;l<i.length;l+=1)if(i[l]!==a.name){var t=e.resolve(i[l]);if(!t){v.push("\u274C "+i[l]);continue}e.isUsed(a,t.name)||(e.isFor(t,a)||(n.warn("Plugin.use:",e.toString(t),"is for",t.for,"but installed on",e.toString(a)+"."),t._warned=!0),t.install?t.install(a):(n.warn("Plugin.use:",e.toString(t),"does not specify an install function."),t._warned=!0),t._warned?(v.push("\u{1F536} "+e.toString(t)),delete t._warned):v.push("\u2705 "+e.toString(t)),a.used.push(t.name))}v.length>0&&n.info(v.join(" "))},e.dependencies=function(a,s){var u=e.dependencyParse(a),i=u.name;if(s=s||{},!(i in s)){a=e.resolve(a)||a,s[i]=n.map(a.uses||[],function(l){e.isPlugin(l)&&e.register(l);var t=e.dependencyParse(l),r=e.resolve(l);return r&&!e.versionSatisfies(r.version,t.range)?(n.warn("Plugin.dependencies:",e.toString(r),"does not satisfy",e.toString(t),"used by",e.toString(u)+"."),r._warned=!0,a._warned=!0):r||(n.warn("Plugin.dependencies:",e.toString(l),"used by",e.toString(u),"could not be resolved."),a._warned=!0),t.name});for(var v=0;v<s[i].length;v+=1)e.dependencies(s[i][v],s);return s}},e.dependencyParse=function(a){if(n.isString(a)){var s=/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/;return s.test(a)||n.warn("Plugin.dependencyParse:",a,"is not a valid dependency string."),{name:a.split("@")[0],range:a.split("@")[1]||"*"}}return{name:a.name,range:a.range||a.version}},e.versionParse=function(a){var s=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;s.test(a)||n.warn("Plugin.versionParse:",a,"is not a valid version or range.");var u=s.exec(a),i=Number(u[4]),v=Number(u[5]),l=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:a,operator:u[1]||u[2]||"",major:i,minor:v,patch:l,parts:[i,v,l],prerelease:u[7],number:i*1e8+v*1e4+l}},e.versionSatisfies=function(a,s){s=s||"*";var u=e.versionParse(s),i=e.versionParse(a);if(u.isRange){if(u.operator==="*"||a==="*")return!0;if(u.operator===">")return i.number>u.number;if(u.operator===">=")return i.number>=u.number;if(u.operator==="~")return i.major===u.major&&i.minor===u.minor&&i.patch>=u.patch;if(u.operator==="^")return u.major>0?i.major===u.major&&i.number>=u.number:u.minor>0?i.minor===u.minor&&i.patch>=u.patch:i.patch===u.patch}return a===s||a==="*"}})()}),(function(g,T){var f={};g.exports=f,(function(){f.create=function(e){return{vertex:e,normalImpulse:0,tangentImpulse:0}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(7),a=f(18),s=f(13),u=f(19),i=f(5),v=f(6),l=f(10),t=f(0),r=f(4);(function(){e._deltaMax=1e3/60,e.create=function(o){o=o||{};var c={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0,lastUpdatesPerFrame:0}},d=t.extend(c,o);return d.world=o.world||v.create({label:"World"}),d.pairs=o.pairs||u.create(),d.detector=o.detector||s.create(),d.detector.pairs=d.pairs,d.grid={buckets:[]},d.world.gravity=d.gravity,d.broadphase=d.grid,d.metrics={},d},e.update=function(o,c){var d=t.now(),y=o.world,P=o.detector,M=o.pairs,h=o.timing,m=h.timestamp,x;c>e._deltaMax&&t.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to",e._deltaMax.toFixed(3),"ms."),c=typeof c<"u"?c:t._baseDelta,c*=h.timeScale,h.timestamp+=c,h.lastDelta=c;var p={timestamp:h.timestamp,delta:c};i.trigger(o,"beforeUpdate",p);var C=v.allBodies(y),w=v.allConstraints(y);for(y.isModified&&(s.setBodies(P,C),v.setModified(y,!1,!1,!0)),o.enableSleeping&&n.update(C,c),e._bodiesApplyGravity(C,o.gravity),c>0&&e._bodiesUpdate(C,c),i.trigger(o,"beforeSolve",p),l.preSolveAll(C),x=0;x<o.constraintIterations;x++)l.solveAll(w,c);l.postSolveAll(C);var S=s.collisions(P);u.update(M,S,m),o.enableSleeping&&n.afterCollisions(M.list),M.collisionStart.length>0&&i.trigger(o,"collisionStart",{pairs:M.collisionStart,timestamp:h.timestamp,delta:c});var I=t.clamp(20/o.positionIterations,0,1);for(a.preSolvePosition(M.list),x=0;x<o.positionIterations;x++)a.solvePosition(M.list,c,I);for(a.postSolvePosition(C),l.preSolveAll(C),x=0;x<o.constraintIterations;x++)l.solveAll(w,c);for(l.postSolveAll(C),a.preSolveVelocity(M.list),x=0;x<o.velocityIterations;x++)a.solveVelocity(M.list,c);return e._bodiesUpdateVelocities(C),M.collisionActive.length>0&&i.trigger(o,"collisionActive",{pairs:M.collisionActive,timestamp:h.timestamp,delta:c}),M.collisionEnd.length>0&&i.trigger(o,"collisionEnd",{pairs:M.collisionEnd,timestamp:h.timestamp,delta:c}),e._bodiesClearForces(C),i.trigger(o,"afterUpdate",p),o.timing.lastElapsed=t.now()-d,o},e.merge=function(o,c){if(t.extend(o,c),c.world){o.world=c.world,e.clear(o);for(var d=v.allBodies(o.world),y=0;y<d.length;y++){var P=d[y];n.set(P,!1),P.id=t.nextId()}}},e.clear=function(o){u.clear(o.pairs),s.clear(o.detector)},e._bodiesClearForces=function(o){for(var c=o.length,d=0;d<c;d++){var y=o[d];y.force.x=0,y.force.y=0,y.torque=0}},e._bodiesApplyGravity=function(o,c){var d=typeof c.scale<"u"?c.scale:.001,y=o.length;if(!(c.x===0&&c.y===0||d===0))for(var P=0;P<y;P++){var M=o[P];M.isStatic||M.isSleeping||(M.force.y+=M.mass*c.y*d,M.force.x+=M.mass*c.x*d)}},e._bodiesUpdate=function(o,c){for(var d=o.length,y=0;y<d;y++){var P=o[y];P.isStatic||P.isSleeping||r.update(P,c)}},e._bodiesUpdateVelocities=function(o){for(var c=o.length,d=0;d<c;d++)r.updateVelocities(o[d])}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(0),s=f(1);(function(){e._restingThresh=2,e._restingThreshTangent=Math.sqrt(6),e._positionDampen=.9,e._positionWarming=.8,e._frictionNormalMultiplier=5,e._frictionMaxStatic=Number.MAX_VALUE,e.preSolvePosition=function(u){var i,v,l,t=u.length;for(i=0;i<t;i++)v=u[i],v.isActive&&(l=v.contactCount,v.collision.parentA.totalContacts+=l,v.collision.parentB.totalContacts+=l)},e.solvePosition=function(u,i,v){var l,t,r,o,c,d,y,P,M=e._positionDampen*(v||1),h=a.clamp(i/a._baseDelta,0,1),m=u.length;for(l=0;l<m;l++)t=u[l],!(!t.isActive||t.isSensor)&&(r=t.collision,o=r.parentA,c=r.parentB,d=r.normal,t.separation=r.depth+d.x*(c.positionImpulse.x-o.positionImpulse.x)+d.y*(c.positionImpulse.y-o.positionImpulse.y));for(l=0;l<m;l++)t=u[l],!(!t.isActive||t.isSensor)&&(r=t.collision,o=r.parentA,c=r.parentB,d=r.normal,P=t.separation-t.slop*h,(o.isStatic||c.isStatic)&&(P*=2),o.isStatic||o.isSleeping||(y=M/o.totalContacts,o.positionImpulse.x+=d.x*P*y,o.positionImpulse.y+=d.y*P*y),c.isStatic||c.isSleeping||(y=M/c.totalContacts,c.positionImpulse.x-=d.x*P*y,c.positionImpulse.y-=d.y*P*y))},e.postSolvePosition=function(u){for(var i=e._positionWarming,v=u.length,l=n.translate,t=s.update,r=0;r<v;r++){var o=u[r],c=o.positionImpulse,d=c.x,y=c.y,P=o.velocity;if(o.totalContacts=0,d!==0||y!==0){for(var M=0;M<o.parts.length;M++){var h=o.parts[M];l(h.vertices,c),t(h.bounds,h.vertices,P),h.position.x+=d,h.position.y+=y}o.positionPrev.x+=d,o.positionPrev.y+=y,d*P.x+y*P.y<0?(c.x=0,c.y=0):(c.x*=i,c.y*=i)}}},e.preSolveVelocity=function(u){var i=u.length,v,l;for(v=0;v<i;v++){var t=u[v];if(!(!t.isActive||t.isSensor)){var r=t.contacts,o=t.contactCount,c=t.collision,d=c.parentA,y=c.parentB,P=c.normal,M=c.tangent;for(l=0;l<o;l++){var h=r[l],m=h.vertex,x=h.normalImpulse,p=h.tangentImpulse;if(x!==0||p!==0){var C=P.x*x+M.x*p,w=P.y*x+M.y*p;d.isStatic||d.isSleeping||(d.positionPrev.x+=C*d.inverseMass,d.positionPrev.y+=w*d.inverseMass,d.anglePrev+=d.inverseInertia*((m.x-d.position.x)*w-(m.y-d.position.y)*C)),y.isStatic||y.isSleeping||(y.positionPrev.x-=C*y.inverseMass,y.positionPrev.y-=w*y.inverseMass,y.anglePrev-=y.inverseInertia*((m.x-y.position.x)*w-(m.y-y.position.y)*C))}}}}},e.solveVelocity=function(u,i){var v=i/a._baseDelta,l=v*v,t=l*v,r=-e._restingThresh*v,o=e._restingThreshTangent,c=e._frictionNormalMultiplier*v,d=e._frictionMaxStatic,y=u.length,P,M,h,m;for(h=0;h<y;h++){var x=u[h];if(!(!x.isActive||x.isSensor)){var p=x.collision,C=p.parentA,w=p.parentB,S=p.normal.x,I=p.normal.y,A=p.tangent.x,k=p.tangent.y,B=x.inverseMass,E=x.friction*x.frictionStatic*c,L=x.contacts,D=x.contactCount,F=1/D,V=C.position.x-C.positionPrev.x,b=C.position.y-C.positionPrev.y,$=C.angle-C.anglePrev,U=w.position.x-w.positionPrev.x,j=w.position.y-w.positionPrev.y,G=w.angle-w.anglePrev;for(m=0;m<D;m++){var H=L[m],z=H.vertex,W=z.x-C.position.x,ie=z.y-C.position.y,J=z.x-w.position.x,Q=z.y-w.position.y,N=V-ie*$,nt=b+W*$,it=U-Q*G,at=j+J*G,Ee=N-it,De=nt-at,me=S*Ee+I*De,Z=A*Ee+k*De,Re=x.separation+me,xe=Math.min(Re,1);xe=Re<0?0:xe;var Fe=xe*E;Z<-Fe||Z>Fe?(M=Z>0?Z:-Z,P=x.friction*(Z>0?1:-1)*t,P<-M?P=-M:P>M&&(P=M)):(P=Z,M=d);var Oe=W*I-ie*S,He=J*I-Q*S,Ve=F/(B+C.inverseInertia*Oe*Oe+w.inverseInertia*He*He),le=(1+x.restitution)*me*Ve;if(P*=Ve,me<r)H.normalImpulse=0;else{var st=H.normalImpulse;H.normalImpulse+=le,H.normalImpulse>0&&(H.normalImpulse=0),le=H.normalImpulse-st}if(Z<-o||Z>o)H.tangentImpulse=0;else{var ot=H.tangentImpulse;H.tangentImpulse+=P,H.tangentImpulse<-M&&(H.tangentImpulse=-M),H.tangentImpulse>M&&(H.tangentImpulse=M),P=H.tangentImpulse-ot}var fe=S*le+A*P,ce=I*le+k*P;C.isStatic||C.isSleeping||(C.positionPrev.x+=fe*C.inverseMass,C.positionPrev.y+=ce*C.inverseMass,C.anglePrev+=(W*ce-ie*fe)*C.inverseInertia),w.isStatic||w.isSleeping||(w.positionPrev.x-=fe*w.inverseMass,w.positionPrev.y-=ce*w.inverseMass,w.anglePrev-=(J*ce-Q*fe)*w.inverseInertia)}}}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(9),a=f(0);(function(){e.create=function(s){return a.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},s)},e.update=function(s,u,i){var v=n.update,l=n.create,t=n.setActive,r=s.table,o=s.list,c=o.length,d=c,y=s.collisionStart,P=s.collisionEnd,M=s.collisionActive,h=u.length,m=0,x=0,p=0,C,w,S;for(S=0;S<h;S++)C=u[S],w=C.pair,w?(w.isActive&&(M[p++]=w),v(w,C,i)):(w=l(C,i),r[w.id]=w,y[m++]=w,o[d++]=w);for(d=0,c=o.length,S=0;S<c;S++)w=o[S],w.timeUpdated>=i?o[d++]=w:(t(w,!1,i),w.collision.bodyA.sleepCounter>0&&w.collision.bodyB.sleepCounter>0?o[d++]=w:(P[x++]=w,delete r[w.id]));o.length!==d&&(o.length=d),y.length!==m&&(y.length=m),P.length!==x&&(P.length=x),M.length!==p&&(M.length=p)},e.clear=function(s){return s.table={},s.list.length=0,s.collisionStart.length=0,s.collisionActive.length=0,s.collisionEnd.length=0,s}})()}),(function(g,T,f){var e=g.exports=f(21);e.Axes=f(11),e.Bodies=f(12),e.Body=f(4),e.Bounds=f(1),e.Collision=f(8),e.Common=f(0),e.Composite=f(6),e.Composites=f(22),e.Constraint=f(10),e.Contact=f(16),e.Detector=f(13),e.Engine=f(17),e.Events=f(5),e.Grid=f(23),e.Mouse=f(14),e.MouseConstraint=f(24),e.Pair=f(9),e.Pairs=f(19),e.Plugin=f(15),e.Query=f(25),e.Render=f(26),e.Resolver=f(18),e.Runner=f(27),e.SAT=f(28),e.Sleeping=f(7),e.Svg=f(29),e.Vector=f(2),e.Vertices=f(3),e.World=f(30),e.Engine.run=e.Runner.run,e.Common.deprecated(e.Engine,"run","Engine.run \u27A4 use Matter.Runner.run(engine) instead")}),(function(g,T,f){var e={};g.exports=e;var n=f(15),a=f(0);(function(){e.name="matter-js",e.version="0.20.0",e.uses=[],e.used=[],e.use=function(){n.use(e,Array.prototype.slice.call(arguments))},e.before=function(s,u){return s=s.replace(/^Matter./,""),a.chainPathBefore(e,s,u)},e.after=function(s,u){return s=s.replace(/^Matter./,""),a.chainPathAfter(e,s,u)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(6),a=f(10),s=f(0),u=f(4),i=f(12),v=s.deprecated;(function(){e.stack=function(l,t,r,o,c,d,y){for(var P=n.create({label:"Stack"}),M=l,h=t,m,x=0,p=0;p<o;p++){for(var C=0,w=0;w<r;w++){var S=y(M,h,w,p,m,x);if(S){var I=S.bounds.max.y-S.bounds.min.y,A=S.bounds.max.x-S.bounds.min.x;I>C&&(C=I),u.translate(S,{x:A*.5,y:I*.5}),M=S.bounds.max.x+c,n.addBody(P,S),m=S,x+=1}else M+=c}h+=C+d,M=l}return P},e.chain=function(l,t,r,o,c,d){for(var y=l.bodies,P=1;P<y.length;P++){var M=y[P-1],h=y[P],m=M.bounds.max.y-M.bounds.min.y,x=M.bounds.max.x-M.bounds.min.x,p=h.bounds.max.y-h.bounds.min.y,C=h.bounds.max.x-h.bounds.min.x,w={bodyA:M,pointA:{x:x*t,y:m*r},bodyB:h,pointB:{x:C*o,y:p*c}},S=s.extend(w,d);n.addConstraint(l,a.create(S))}return l.label+=" Chain",l},e.mesh=function(l,t,r,o,c){var d=l.bodies,y,P,M,h,m;for(y=0;y<r;y++){for(P=1;P<t;P++)M=d[P-1+y*t],h=d[P+y*t],n.addConstraint(l,a.create(s.extend({bodyA:M,bodyB:h},c)));if(y>0)for(P=0;P<t;P++)M=d[P+(y-1)*t],h=d[P+y*t],n.addConstraint(l,a.create(s.extend({bodyA:M,bodyB:h},c))),o&&P>0&&(m=d[P-1+(y-1)*t],n.addConstraint(l,a.create(s.extend({bodyA:m,bodyB:h},c)))),o&&P<t-1&&(m=d[P+1+(y-1)*t],n.addConstraint(l,a.create(s.extend({bodyA:m,bodyB:h},c))))}return l.label+=" Mesh",l},e.pyramid=function(l,t,r,o,c,d,y){return e.stack(l,t,r,o,c,d,function(P,M,h,m,x,p){var C=Math.min(o,Math.ceil(r/2)),w=x?x.bounds.max.x-x.bounds.min.x:0;if(!(m>C)){m=C-m;var S=m,I=r-1-m;if(!(h<S||h>I)){p===1&&u.translate(x,{x:(h+(r%2===1?1:-1))*w,y:0});var A=x?h*w:0;return y(l+A+h*c,M,h,m,x,p)}}})},e.newtonsCradle=function(l,t,r,o,c){for(var d=n.create({label:"Newtons Cradle"}),y=0;y<r;y++){var P=1.9,M=i.circle(l+y*(o*P),t+c,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),h=a.create({pointA:{x:l+y*(o*P),y:t},bodyB:M});n.addBody(d,M),n.addConstraint(d,h)}return d},v(e,"newtonsCradle","Composites.newtonsCradle \u27A4 moved to newtonsCradle example"),e.car=function(l,t,r,o,c){var d=u.nextGroup(!0),y=20,P=-r*.5+y,M=r*.5-y,h=0,m=n.create({label:"Car"}),x=i.rectangle(l,t,r,o,{collisionFilter:{group:d},chamfer:{radius:o*.5},density:2e-4}),p=i.circle(l+P,t+h,c,{collisionFilter:{group:d},friction:.8}),C=i.circle(l+M,t+h,c,{collisionFilter:{group:d},friction:.8}),w=a.create({bodyB:x,pointB:{x:P,y:h},bodyA:p,stiffness:1,length:0}),S=a.create({bodyB:x,pointB:{x:M,y:h},bodyA:C,stiffness:1,length:0});return n.addBody(m,x),n.addBody(m,p),n.addBody(m,C),n.addConstraint(m,w),n.addConstraint(m,S),m},v(e,"car","Composites.car \u27A4 moved to car example"),e.softBody=function(l,t,r,o,c,d,y,P,M,h){M=s.extend({inertia:1/0},M),h=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},h);var m=e.stack(l,t,r,o,c,d,function(x,p){return i.circle(x,p,P,M)});return e.mesh(m,r,o,y,h),m.label="Soft Body",m},v(e,"softBody","Composites.softBody \u27A4 moved to softBody and cloth examples")})()}),(function(g,T,f){var e={};g.exports=e;var n=f(9),a=f(0),s=a.deprecated;(function(){e.create=function(u){var i={buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return a.extend(i,u)},e.update=function(u,i,v,l){var t,r,o,c=v.world,d=u.buckets,y,P,M=!1;for(t=0;t<i.length;t++){var h=i[t];if(!(h.isSleeping&&!l)&&!(c.bounds&&(h.bounds.max.x<c.bounds.min.x||h.bounds.min.x>c.bounds.max.x||h.bounds.max.y<c.bounds.min.y||h.bounds.min.y>c.bounds.max.y))){var m=e._getRegion(u,h);if(!h.region||m.id!==h.region.id||l){(!h.region||l)&&(h.region=m);var x=e._regionUnion(m,h.region);for(r=x.startCol;r<=x.endCol;r++)for(o=x.startRow;o<=x.endRow;o++){P=e._getBucketId(r,o),y=d[P];var p=r>=m.startCol&&r<=m.endCol&&o>=m.startRow&&o<=m.endRow,C=r>=h.region.startCol&&r<=h.region.endCol&&o>=h.region.startRow&&o<=h.region.endRow;!p&&C&&C&&y&&e._bucketRemoveBody(u,y,h),(h.region===m||p&&!C||l)&&(y||(y=e._createBucket(d,P)),e._bucketAddBody(u,y,h))}h.region=m,M=!0}}}M&&(u.pairsList=e._createActivePairsList(u))},s(e,"update","Grid.update \u27A4 replaced by Matter.Detector"),e.clear=function(u){u.buckets={},u.pairs={},u.pairsList=[]},s(e,"clear","Grid.clear \u27A4 replaced by Matter.Detector"),e._regionUnion=function(u,i){var v=Math.min(u.startCol,i.startCol),l=Math.max(u.endCol,i.endCol),t=Math.min(u.startRow,i.startRow),r=Math.max(u.endRow,i.endRow);return e._createRegion(v,l,t,r)},e._getRegion=function(u,i){var v=i.bounds,l=Math.floor(v.min.x/u.bucketWidth),t=Math.floor(v.max.x/u.bucketWidth),r=Math.floor(v.min.y/u.bucketHeight),o=Math.floor(v.max.y/u.bucketHeight);return e._createRegion(l,t,r,o)},e._createRegion=function(u,i,v,l){return{id:u+","+i+","+v+","+l,startCol:u,endCol:i,startRow:v,endRow:l}},e._getBucketId=function(u,i){return"C"+u+"R"+i},e._createBucket=function(u,i){var v=u[i]=[];return v},e._bucketAddBody=function(u,i,v){var l=u.pairs,t=n.id,r=i.length,o;for(o=0;o<r;o++){var c=i[o];if(!(v.id===c.id||v.isStatic&&c.isStatic)){var d=t(v,c),y=l[d];y?y[2]+=1:l[d]=[v,c,1]}}i.push(v)},e._bucketRemoveBody=function(u,i,v){var l=u.pairs,t=n.id,r;i.splice(a.indexOf(i,v),1);var o=i.length;for(r=0;r<o;r++){var c=l[t(v,i[r])];c&&(c[2]-=1)}},e._createActivePairsList=function(u){var i,v=u.pairs,l=a.keys(v),t=l.length,r=[],o;for(o=0;o<t;o++)i=v[l[o]],i[2]>0?r.push(i):delete v[l[o]];return r}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(3),a=f(7),s=f(14),u=f(5),i=f(13),v=f(10),l=f(6),t=f(0),r=f(1);(function(){e.create=function(o,c){var d=(o?o.mouse:null)||(c?c.mouse:null);d||(o&&o.render&&o.render.canvas?d=s.create(o.render.canvas):c&&c.element?d=s.create(c.element):(d=s.create(),t.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var y=v.create({label:"Mouse Constraint",pointA:d.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),P={type:"mouseConstraint",mouse:d,element:null,body:null,constraint:y,collisionFilter:{category:1,mask:4294967295,group:0}},M=t.extend(P,c);return u.on(o,"beforeUpdate",function(){var h=l.allBodies(o.world);e.update(M,h),e._triggerEvents(M)}),M},e.update=function(o,c){var d=o.mouse,y=o.constraint,P=o.body;if(d.button===0){if(y.bodyB)a.set(y.bodyB,!1),y.pointA=d.position;else for(var M=0;M<c.length;M++)if(P=c[M],r.contains(P.bounds,d.position)&&i.canCollide(P.collisionFilter,o.collisionFilter))for(var h=P.parts.length>1?1:0;h<P.parts.length;h++){var m=P.parts[h];if(n.contains(m.vertices,d.position)){y.pointA=d.position,y.bodyB=o.body=P,y.pointB={x:d.position.x-P.position.x,y:d.position.y-P.position.y},y.angleB=P.angle,a.set(P,!1),u.trigger(o,"startdrag",{mouse:d,body:P});break}}}else y.bodyB=o.body=null,y.pointB=null,P&&u.trigger(o,"enddrag",{mouse:d,body:P})},e._triggerEvents=function(o){var c=o.mouse,d=c.sourceEvents;d.mousemove&&u.trigger(o,"mousemove",{mouse:c}),d.mousedown&&u.trigger(o,"mousedown",{mouse:c}),d.mouseup&&u.trigger(o,"mouseup",{mouse:c}),s.clearSourceEvents(c)}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(2),a=f(8),s=f(1),u=f(12),i=f(3);(function(){e.collides=function(v,l){for(var t=[],r=l.length,o=v.bounds,c=a.collides,d=s.overlaps,y=0;y<r;y++){var P=l[y],M=P.parts.length,h=M===1?0:1;if(d(P.bounds,o))for(var m=h;m<M;m++){var x=P.parts[m];if(d(x.bounds,o)){var p=c(x,v);if(p){t.push(p);break}}}}return t},e.ray=function(v,l,t,r){r=r||1e-100;for(var o=n.angle(l,t),c=n.magnitude(n.sub(l,t)),d=(t.x+l.x)*.5,y=(t.y+l.y)*.5,P=u.rectangle(d,y,c,r,{angle:o}),M=e.collides(P,v),h=0;h<M.length;h+=1){var m=M[h];m.body=m.bodyB=m.bodyA}return M},e.region=function(v,l,t){for(var r=[],o=0;o<v.length;o++){var c=v[o],d=s.overlaps(c.bounds,l);(d&&!t||!d&&t)&&r.push(c)}return r},e.point=function(v,l){for(var t=[],r=0;r<v.length;r++){var o=v[r];if(s.contains(o.bounds,l))for(var c=o.parts.length===1?0:1;c<o.parts.length;c++){var d=o.parts[c];if(s.contains(d.bounds,l)&&i.contains(d.vertices,l)){t.push(o);break}}}return t}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(4),a=f(0),s=f(6),u=f(1),i=f(5),v=f(2),l=f(14);(function(){var t,r;typeof window<"u"&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(h){window.setTimeout(function(){h(a.now())},1e3/60)},r=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),e._goodFps=30,e._goodDelta=1e3/60,e.create=function(h){var m={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],engineUpdatesHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",wireframeStrokeStyle:"#bbb",hasBounds:!!h.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},x=a.extend(m,h);return x.canvas&&(x.canvas.width=x.options.width||x.canvas.width,x.canvas.height=x.options.height||x.canvas.height),x.mouse=h.mouse,x.engine=h.engine,x.canvas=x.canvas||d(x.options.width,x.options.height),x.context=x.canvas.getContext("2d"),x.textures={},x.bounds=x.bounds||{min:{x:0,y:0},max:{x:x.canvas.width,y:x.canvas.height}},x.controller=e,x.options.showBroadphase=!1,x.options.pixelRatio!==1&&e.setPixelRatio(x,x.options.pixelRatio),a.isElement(x.element)&&x.element.appendChild(x.canvas),x},e.run=function(h){(function m(x){h.frameRequestId=t(m),o(h,x),e.world(h,x),h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0),(h.options.showStats||h.options.showDebug)&&e.stats(h,h.context,x),(h.options.showPerformance||h.options.showDebug)&&e.performance(h,h.context,x),h.context.setTransform(1,0,0,1,0,0)})()},e.stop=function(h){r(h.frameRequestId)},e.setPixelRatio=function(h,m){var x=h.options,p=h.canvas;m==="auto"&&(m=y(p)),x.pixelRatio=m,p.setAttribute("data-pixel-ratio",m),p.width=x.width*m,p.height=x.height*m,p.style.width=x.width+"px",p.style.height=x.height+"px"},e.setSize=function(h,m,x){h.options.width=m,h.options.height=x,h.bounds.max.x=h.bounds.min.x+m,h.bounds.max.y=h.bounds.min.y+x,h.options.pixelRatio!==1?e.setPixelRatio(h,h.options.pixelRatio):(h.canvas.width=m,h.canvas.height=x)},e.lookAt=function(h,m,x,p){p=typeof p<"u"?p:!0,m=a.isArray(m)?m:[m],x=x||{x:0,y:0};for(var C={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},w=0;w<m.length;w+=1){var S=m[w],I=S.bounds?S.bounds.min:S.min||S.position||S,A=S.bounds?S.bounds.max:S.max||S.position||S;I&&A&&(I.x<C.min.x&&(C.min.x=I.x),A.x>C.max.x&&(C.max.x=A.x),I.y<C.min.y&&(C.min.y=I.y),A.y>C.max.y&&(C.max.y=A.y))}var k=C.max.x-C.min.x+2*x.x,B=C.max.y-C.min.y+2*x.y,E=h.canvas.height,L=h.canvas.width,D=L/E,F=k/B,V=1,b=1;F>D?b=F/D:V=D/F,h.options.hasBounds=!0,h.bounds.min.x=C.min.x,h.bounds.max.x=C.min.x+k*V,h.bounds.min.y=C.min.y,h.bounds.max.y=C.min.y+B*b,p&&(h.bounds.min.x+=k*.5-k*V*.5,h.bounds.max.x+=k*.5-k*V*.5,h.bounds.min.y+=B*.5-B*b*.5,h.bounds.max.y+=B*.5-B*b*.5),h.bounds.min.x-=x.x,h.bounds.max.x-=x.x,h.bounds.min.y-=x.y,h.bounds.max.y-=x.y,h.mouse&&(l.setScale(h.mouse,{x:(h.bounds.max.x-h.bounds.min.x)/h.canvas.width,y:(h.bounds.max.y-h.bounds.min.y)/h.canvas.height}),l.setOffset(h.mouse,h.bounds.min))},e.startViewTransform=function(h){var m=h.bounds.max.x-h.bounds.min.x,x=h.bounds.max.y-h.bounds.min.y,p=m/h.options.width,C=x/h.options.height;h.context.setTransform(h.options.pixelRatio/p,0,0,h.options.pixelRatio/C,0,0),h.context.translate(-h.bounds.min.x,-h.bounds.min.y)},e.endViewTransform=function(h){h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0)},e.world=function(h,m){var x=a.now(),p=h.engine,C=p.world,w=h.canvas,S=h.context,I=h.options,A=h.timing,k=s.allBodies(C),B=s.allConstraints(C),E=I.wireframes?I.wireframeBackground:I.background,L=[],D=[],F,V={timestamp:p.timing.timestamp};if(i.trigger(h,"beforeRender",V),h.currentBackground!==E&&M(h,E),S.globalCompositeOperation="source-in",S.fillStyle="transparent",S.fillRect(0,0,w.width,w.height),S.globalCompositeOperation="source-over",I.hasBounds){for(F=0;F<k.length;F++){var b=k[F];u.overlaps(b.bounds,h.bounds)&&L.push(b)}for(F=0;F<B.length;F++){var $=B[F],U=$.bodyA,j=$.bodyB,G=$.pointA,H=$.pointB;U&&(G=v.add(U.position,$.pointA)),j&&(H=v.add(j.position,$.pointB)),!(!G||!H)&&(u.contains(h.bounds,G)||u.contains(h.bounds,H))&&D.push($)}e.startViewTransform(h),h.mouse&&(l.setScale(h.mouse,{x:(h.bounds.max.x-h.bounds.min.x)/h.options.width,y:(h.bounds.max.y-h.bounds.min.y)/h.options.height}),l.setOffset(h.mouse,h.bounds.min))}else D=B,L=k,h.options.pixelRatio!==1&&h.context.setTransform(h.options.pixelRatio,0,0,h.options.pixelRatio,0,0);!I.wireframes||p.enableSleeping&&I.showSleeping?e.bodies(h,L,S):(I.showConvexHulls&&e.bodyConvexHulls(h,L,S),e.bodyWireframes(h,L,S)),I.showBounds&&e.bodyBounds(h,L,S),(I.showAxes||I.showAngleIndicator)&&e.bodyAxes(h,L,S),I.showPositions&&e.bodyPositions(h,L,S),I.showVelocity&&e.bodyVelocity(h,L,S),I.showIds&&e.bodyIds(h,L,S),I.showSeparations&&e.separations(h,p.pairs.list,S),I.showCollisions&&e.collisions(h,p.pairs.list,S),I.showVertexNumbers&&e.vertexNumbers(h,L,S),I.showMousePosition&&e.mousePosition(h,h.mouse,S),e.constraints(D,S),I.hasBounds&&e.endViewTransform(h),i.trigger(h,"afterRender",V),A.lastElapsed=a.now()-x},e.stats=function(h,m,x){for(var p=h.engine,C=p.world,w=s.allBodies(C),S=0,I=55,A=44,k=0,B=0,E=0;E<w.length;E+=1)S+=w[E].parts.length;var L={Part:S,Body:w.length,Cons:s.allConstraints(C).length,Comp:s.allComposites(C).length,Pair:p.pairs.list.length};m.fillStyle="#0e0f19",m.fillRect(k,B,I*5.5,A),m.font="12px Arial",m.textBaseline="top",m.textAlign="right";for(var D in L){var F=L[D];m.fillStyle="#aaa",m.fillText(D,k+I,B+8),m.fillStyle="#eee",m.fillText(F,k+I,B+26),k+=I}},e.performance=function(h,m){var x=h.engine,p=h.timing,C=p.deltaHistory,w=p.elapsedHistory,S=p.timestampElapsedHistory,I=p.engineDeltaHistory,A=p.engineUpdatesHistory,k=p.engineElapsedHistory,B=x.timing.lastUpdatesPerFrame,E=x.timing.lastDelta,L=c(C),D=c(w),F=c(I),V=c(A),b=c(k),$=c(S),U=$/L||0,j=Math.round(L/E),G=1e3/L||0,H=4,z=12,W=60,ie=34,J=10,Q=69;m.fillStyle="#0e0f19",m.fillRect(0,50,z*5+W*6+22,ie),e.status(m,J,Q,W,H,C.length,Math.round(G)+" fps",G/e._goodFps,function(N){return C[N]/L-1}),e.status(m,J+z+W,Q,W,H,I.length,E.toFixed(2)+" dt",e._goodDelta/E,function(N){return I[N]/F-1}),e.status(m,J+(z+W)*2,Q,W,H,A.length,B+" upf",Math.pow(a.clamp(V/j||1,0,1),4),function(N){return A[N]/V-1}),e.status(m,J+(z+W)*3,Q,W,H,k.length,b.toFixed(2)+" ut",1-B*b/e._goodFps,function(N){return k[N]/b-1}),e.status(m,J+(z+W)*4,Q,W,H,w.length,D.toFixed(2)+" rt",1-D/e._goodFps,function(N){return w[N]/D-1}),e.status(m,J+(z+W)*5,Q,W,H,S.length,U.toFixed(2)+" x",U*U*U,function(N){return(S[N]/C[N]/U||0)-1})},e.status=function(h,m,x,p,C,w,S,I,A){h.strokeStyle="#888",h.fillStyle="#444",h.lineWidth=1,h.fillRect(m,x+7,p,1),h.beginPath(),h.moveTo(m,x+7-C*a.clamp(.4*A(0),-2,2));for(var k=0;k<p;k+=1)h.lineTo(m+k,x+7-(k<w?C*a.clamp(.4*A(k),-2,2):0));h.stroke(),h.fillStyle="hsl("+a.clamp(25+95*I,0,120)+",100%,60%)",h.fillRect(m,x-7,4,4),h.font="12px Arial",h.textBaseline="middle",h.textAlign="right",h.fillStyle="#eee",h.fillText(S,m+p,x-5)},e.constraints=function(h,m){for(var x=m,p=0;p<h.length;p++){var C=h[p];if(!(!C.render.visible||!C.pointA||!C.pointB)){var w=C.bodyA,S=C.bodyB,I,A;if(w?I=v.add(w.position,C.pointA):I=C.pointA,C.render.type==="pin")x.beginPath(),x.arc(I.x,I.y,3,0,2*Math.PI),x.closePath();else{if(S?A=v.add(S.position,C.pointB):A=C.pointB,x.beginPath(),x.moveTo(I.x,I.y),C.render.type==="spring")for(var k=v.sub(A,I),B=v.perp(v.normalise(k)),E=Math.ceil(a.clamp(C.length/5,12,20)),L,D=1;D<E;D+=1)L=D%2===0?1:-1,x.lineTo(I.x+k.x*(D/E)+B.x*L*4,I.y+k.y*(D/E)+B.y*L*4);x.lineTo(A.x,A.y)}C.render.lineWidth&&(x.lineWidth=C.render.lineWidth,x.strokeStyle=C.render.strokeStyle,x.stroke()),C.render.anchors&&(x.fillStyle=C.render.strokeStyle,x.beginPath(),x.arc(I.x,I.y,3,0,2*Math.PI),x.arc(A.x,A.y,3,0,2*Math.PI),x.closePath(),x.fill())}}},e.bodies=function(h,m,x){var p=x,C=h.engine,w=h.options,S=w.showInternalEdges||!w.wireframes,I,A,k,B;for(k=0;k<m.length;k++)if(I=m[k],!!I.render.visible){for(B=I.parts.length>1?1:0;B<I.parts.length;B++)if(A=I.parts[B],!!A.render.visible){if(w.showSleeping&&I.isSleeping?p.globalAlpha=.5*A.render.opacity:A.render.opacity!==1&&(p.globalAlpha=A.render.opacity),A.render.sprite&&A.render.sprite.texture&&!w.wireframes){var E=A.render.sprite,L=P(h,E.texture);p.translate(A.position.x,A.position.y),p.rotate(A.angle),p.drawImage(L,L.width*-E.xOffset*E.xScale,L.height*-E.yOffset*E.yScale,L.width*E.xScale,L.height*E.yScale),p.rotate(-A.angle),p.translate(-A.position.x,-A.position.y)}else{if(A.circleRadius)p.beginPath(),p.arc(A.position.x,A.position.y,A.circleRadius,0,2*Math.PI);else{p.beginPath(),p.moveTo(A.vertices[0].x,A.vertices[0].y);for(var D=1;D<A.vertices.length;D++)!A.vertices[D-1].isInternal||S?p.lineTo(A.vertices[D].x,A.vertices[D].y):p.moveTo(A.vertices[D].x,A.vertices[D].y),A.vertices[D].isInternal&&!S&&p.moveTo(A.vertices[(D+1)%A.vertices.length].x,A.vertices[(D+1)%A.vertices.length].y);p.lineTo(A.vertices[0].x,A.vertices[0].y),p.closePath()}w.wireframes?(p.lineWidth=1,p.strokeStyle=h.options.wireframeStrokeStyle,p.stroke()):(p.fillStyle=A.render.fillStyle,A.render.lineWidth&&(p.lineWidth=A.render.lineWidth,p.strokeStyle=A.render.strokeStyle,p.stroke()),p.fill())}p.globalAlpha=1}}},e.bodyWireframes=function(h,m,x){var p=x,C=h.options.showInternalEdges,w,S,I,A,k;for(p.beginPath(),I=0;I<m.length;I++)if(w=m[I],!!w.render.visible)for(k=w.parts.length>1?1:0;k<w.parts.length;k++){for(S=w.parts[k],p.moveTo(S.vertices[0].x,S.vertices[0].y),A=1;A<S.vertices.length;A++)!S.vertices[A-1].isInternal||C?p.lineTo(S.vertices[A].x,S.vertices[A].y):p.moveTo(S.vertices[A].x,S.vertices[A].y),S.vertices[A].isInternal&&!C&&p.moveTo(S.vertices[(A+1)%S.vertices.length].x,S.vertices[(A+1)%S.vertices.length].y);p.lineTo(S.vertices[0].x,S.vertices[0].y)}p.lineWidth=1,p.strokeStyle=h.options.wireframeStrokeStyle,p.stroke()},e.bodyConvexHulls=function(h,m,x){var p=x,C,w,S,I,A;for(p.beginPath(),S=0;S<m.length;S++)if(C=m[S],!(!C.render.visible||C.parts.length===1)){for(p.moveTo(C.vertices[0].x,C.vertices[0].y),I=1;I<C.vertices.length;I++)p.lineTo(C.vertices[I].x,C.vertices[I].y);p.lineTo(C.vertices[0].x,C.vertices[0].y)}p.lineWidth=1,p.strokeStyle="rgba(255,255,255,0.2)",p.stroke()},e.vertexNumbers=function(h,m,x){var p=x,C,w,S;for(C=0;C<m.length;C++){var I=m[C].parts;for(S=I.length>1?1:0;S<I.length;S++){var A=I[S];for(w=0;w<A.vertices.length;w++)p.fillStyle="rgba(255,255,255,0.2)",p.fillText(C+"_"+w,A.position.x+(A.vertices[w].x-A.position.x)*.8,A.position.y+(A.vertices[w].y-A.position.y)*.8)}}},e.mousePosition=function(h,m,x){var p=x;p.fillStyle="rgba(255,255,255,0.8)",p.fillText(m.position.x+" "+m.position.y,m.position.x+5,m.position.y-5)},e.bodyBounds=function(h,m,x){var p=x,C=h.engine,w=h.options;p.beginPath();for(var S=0;S<m.length;S++){var I=m[S];if(I.render.visible)for(var A=m[S].parts,k=A.length>1?1:0;k<A.length;k++){var B=A[k];p.rect(B.bounds.min.x,B.bounds.min.y,B.bounds.max.x-B.bounds.min.x,B.bounds.max.y-B.bounds.min.y)}}w.wireframes?p.strokeStyle="rgba(255,255,255,0.08)":p.strokeStyle="rgba(0,0,0,0.1)",p.lineWidth=1,p.stroke()},e.bodyAxes=function(h,m,x){var p=x,C=h.engine,w=h.options,S,I,A,k;for(p.beginPath(),I=0;I<m.length;I++){var B=m[I],E=B.parts;if(B.render.visible)if(w.showAxes)for(A=E.length>1?1:0;A<E.length;A++)for(S=E[A],k=0;k<S.axes.length;k++){var L=S.axes[k];p.moveTo(S.position.x,S.position.y),p.lineTo(S.position.x+L.x*20,S.position.y+L.y*20)}else for(A=E.length>1?1:0;A<E.length;A++)for(S=E[A],k=0;k<S.axes.length;k++)p.moveTo(S.position.x,S.position.y),p.lineTo((S.vertices[0].x+S.vertices[S.vertices.length-1].x)/2,(S.vertices[0].y+S.vertices[S.vertices.length-1].y)/2)}w.wireframes?(p.strokeStyle="indianred",p.lineWidth=1):(p.strokeStyle="rgba(255, 255, 255, 0.4)",p.globalCompositeOperation="overlay",p.lineWidth=2),p.stroke(),p.globalCompositeOperation="source-over"},e.bodyPositions=function(h,m,x){var p=x,C=h.engine,w=h.options,S,I,A,k;for(p.beginPath(),A=0;A<m.length;A++)if(S=m[A],!!S.render.visible)for(k=0;k<S.parts.length;k++)I=S.parts[k],p.arc(I.position.x,I.position.y,3,0,2*Math.PI,!1),p.closePath();for(w.wireframes?p.fillStyle="indianred":p.fillStyle="rgba(0,0,0,0.5)",p.fill(),p.beginPath(),A=0;A<m.length;A++)S=m[A],S.render.visible&&(p.arc(S.positionPrev.x,S.positionPrev.y,2,0,2*Math.PI,!1),p.closePath());p.fillStyle="rgba(255,165,0,0.8)",p.fill()},e.bodyVelocity=function(h,m,x){var p=x;p.beginPath();for(var C=0;C<m.length;C++){var w=m[C];if(w.render.visible){var S=n.getVelocity(w);p.moveTo(w.position.x,w.position.y),p.lineTo(w.position.x+S.x,w.position.y+S.y)}}p.lineWidth=3,p.strokeStyle="cornflowerblue",p.stroke()},e.bodyIds=function(h,m,x){var p=x,C,w;for(C=0;C<m.length;C++)if(m[C].render.visible){var S=m[C].parts;for(w=S.length>1?1:0;w<S.length;w++){var I=S[w];p.font="12px Arial",p.fillStyle="rgba(255,255,255,0.5)",p.fillText(I.id,I.position.x+10,I.position.y-10)}}},e.collisions=function(h,m,x){var p=x,C=h.options,w,S,I,A,k,B,E;for(p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive)for(S=w.collision,E=0;E<w.contactCount;E++){var L=w.contacts[E],D=L.vertex;p.rect(D.x-1.5,D.y-1.5,3.5,3.5)}for(C.wireframes?p.fillStyle="rgba(255,255,255,0.7)":p.fillStyle="orange",p.fill(),p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive&&(S=w.collision,w.contactCount>0)){var F=w.contacts[0].vertex.x,V=w.contacts[0].vertex.y;w.contactCount===2&&(F=(w.contacts[0].vertex.x+w.contacts[1].vertex.x)/2,V=(w.contacts[0].vertex.y+w.contacts[1].vertex.y)/2),S.bodyB===S.supports[0].body||S.bodyA.isStatic===!0?p.moveTo(F-S.normal.x*8,V-S.normal.y*8):p.moveTo(F+S.normal.x*8,V+S.normal.y*8),p.lineTo(F,V)}C.wireframes?p.strokeStyle="rgba(255,165,0,0.7)":p.strokeStyle="orange",p.lineWidth=1,p.stroke()},e.separations=function(h,m,x){var p=x,C=h.options,w,S,I,A,k,B,E;for(p.beginPath(),B=0;B<m.length;B++)if(w=m[B],!!w.isActive){S=w.collision,A=S.bodyA,k=S.bodyB;var L=1;!k.isStatic&&!A.isStatic&&(L=.5),k.isStatic&&(L=0),p.moveTo(k.position.x,k.position.y),p.lineTo(k.position.x-S.penetration.x*L,k.position.y-S.penetration.y*L),L=1,!k.isStatic&&!A.isStatic&&(L=.5),A.isStatic&&(L=0),p.moveTo(A.position.x,A.position.y),p.lineTo(A.position.x+S.penetration.x*L,A.position.y+S.penetration.y*L)}C.wireframes?p.strokeStyle="rgba(255,165,0,0.5)":p.strokeStyle="orange",p.stroke()},e.inspector=function(h,m){var x=h.engine,p=h.selected,C=h.render,w=C.options,S;if(w.hasBounds){var I=C.bounds.max.x-C.bounds.min.x,A=C.bounds.max.y-C.bounds.min.y,k=I/C.options.width,B=A/C.options.height;m.scale(1/k,1/B),m.translate(-C.bounds.min.x,-C.bounds.min.y)}for(var E=0;E<p.length;E++){var L=p[E].data;switch(m.translate(.5,.5),m.lineWidth=1,m.strokeStyle="rgba(255,165,0,0.9)",m.setLineDash([1,2]),L.type){case"body":S=L.bounds,m.beginPath(),m.rect(Math.floor(S.min.x-3),Math.floor(S.min.y-3),Math.floor(S.max.x-S.min.x+6),Math.floor(S.max.y-S.min.y+6)),m.closePath(),m.stroke();break;case"constraint":var D=L.pointA;L.bodyA&&(D=L.pointB),m.beginPath(),m.arc(D.x,D.y,10,0,2*Math.PI),m.closePath(),m.stroke();break}m.setLineDash([]),m.translate(-.5,-.5)}h.selectStart!==null&&(m.translate(.5,.5),m.lineWidth=1,m.strokeStyle="rgba(255,165,0,0.6)",m.fillStyle="rgba(255,165,0,0.1)",S=h.selectBounds,m.beginPath(),m.rect(Math.floor(S.min.x),Math.floor(S.min.y),Math.floor(S.max.x-S.min.x),Math.floor(S.max.y-S.min.y)),m.closePath(),m.stroke(),m.fill(),m.translate(-.5,-.5)),w.hasBounds&&m.setTransform(1,0,0,1,0,0)};var o=function(h,m){var x=h.engine,p=h.timing,C=p.historySize,w=x.timing.timestamp;p.delta=m-p.lastTime||e._goodDelta,p.lastTime=m,p.timestampElapsed=w-p.lastTimestamp||0,p.lastTimestamp=w,p.deltaHistory.unshift(p.delta),p.deltaHistory.length=Math.min(p.deltaHistory.length,C),p.engineDeltaHistory.unshift(x.timing.lastDelta),p.engineDeltaHistory.length=Math.min(p.engineDeltaHistory.length,C),p.timestampElapsedHistory.unshift(p.timestampElapsed),p.timestampElapsedHistory.length=Math.min(p.timestampElapsedHistory.length,C),p.engineUpdatesHistory.unshift(x.timing.lastUpdatesPerFrame),p.engineUpdatesHistory.length=Math.min(p.engineUpdatesHistory.length,C),p.engineElapsedHistory.unshift(x.timing.lastElapsed),p.engineElapsedHistory.length=Math.min(p.engineElapsedHistory.length,C),p.elapsedHistory.unshift(p.lastElapsed),p.elapsedHistory.length=Math.min(p.elapsedHistory.length,C)},c=function(h){for(var m=0,x=0;x<h.length;x+=1)m+=h[x];return m/h.length||0},d=function(h,m){var x=document.createElement("canvas");return x.width=h,x.height=m,x.oncontextmenu=function(){return!1},x.onselectstart=function(){return!1},x},y=function(h){var m=h.getContext("2d"),x=window.devicePixelRatio||1,p=m.webkitBackingStorePixelRatio||m.mozBackingStorePixelRatio||m.msBackingStorePixelRatio||m.oBackingStorePixelRatio||m.backingStorePixelRatio||1;return x/p},P=function(h,m){var x=h.textures[m];return x||(x=h.textures[m]=new Image,x.src=m,x)},M=function(h,m){var x=m;/(jpg|gif|png)$/.test(m)&&(x="url("+m+")"),h.canvas.style.background=x,h.canvas.style.backgroundSize="contain",h.currentBackground=m}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(5),a=f(17),s=f(0);(function(){e._maxFrameDelta=1e3/15,e._frameDeltaFallback=1e3/60,e._timeBufferMargin=1.5,e._elapsedNextEstimate=1,e._smoothingLowerBound=.1,e._smoothingUpperBound=.9,e.create=function(i){var v={delta:16.666666666666668,frameDelta:null,frameDeltaSmoothing:!0,frameDeltaSnapping:!0,frameDeltaHistory:[],frameDeltaHistorySize:100,frameRequestId:null,timeBuffer:0,timeLastTick:null,maxUpdates:null,maxFrameTime:33.333333333333336,lastUpdatesDeferred:0,enabled:!0},l=s.extend(v,i);return l.fps=0,l},e.run=function(i,v){return i.timeBuffer=e._frameDeltaFallback,(function l(t){i.frameRequestId=e._onNextFrame(i,l),t&&i.enabled&&e.tick(i,v,t)})(),i},e.tick=function(i,v,l){var t=s.now(),r=i.delta,o=0,c=l-i.timeLastTick;if((!c||!i.timeLastTick||c>Math.max(e._maxFrameDelta,i.maxFrameTime))&&(c=i.frameDelta||e._frameDeltaFallback),i.frameDeltaSmoothing){i.frameDeltaHistory.push(c),i.frameDeltaHistory=i.frameDeltaHistory.slice(-i.frameDeltaHistorySize);var d=i.frameDeltaHistory.slice(0).sort(),y=i.frameDeltaHistory.slice(d.length*e._smoothingLowerBound,d.length*e._smoothingUpperBound),P=u(y);c=P||c}i.frameDeltaSnapping&&(c=1e3/Math.round(1e3/c)),i.frameDelta=c,i.timeLastTick=l,i.timeBuffer+=i.frameDelta,i.timeBuffer=s.clamp(i.timeBuffer,0,i.frameDelta+r*e._timeBufferMargin),i.lastUpdatesDeferred=0;var M=i.maxUpdates||Math.ceil(i.maxFrameTime/r),h={timestamp:v.timing.timestamp};n.trigger(i,"beforeTick",h),n.trigger(i,"tick",h);for(var m=s.now();r>0&&i.timeBuffer>=r*e._timeBufferMargin;){n.trigger(i,"beforeUpdate",h),a.update(v,r),n.trigger(i,"afterUpdate",h),i.timeBuffer-=r,o+=1;var x=s.now()-t,p=s.now()-m,C=x+e._elapsedNextEstimate*p/o;if(o>=M||C>i.maxFrameTime){i.lastUpdatesDeferred=Math.round(Math.max(0,i.timeBuffer/r-e._timeBufferMargin));break}}v.timing.lastUpdatesPerFrame=o,n.trigger(i,"afterTick",h),i.frameDeltaHistory.length>=100&&(i.lastUpdatesDeferred&&Math.round(i.frameDelta/r)>M?s.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs."):i.lastUpdatesDeferred&&s.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."),typeof i.isFixed<"u"&&s.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."),(i.deltaMin||i.deltaMax)&&s.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."),i.fps!==0&&s.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."))},e.stop=function(i){e._cancelNextFrame(i)},e._onNextFrame=function(i,v){if(typeof window<"u"&&window.requestAnimationFrame)i.frameRequestId=window.requestAnimationFrame(v);else throw new Error("Matter.Runner: missing required global window.requestAnimationFrame.");return i.frameRequestId},e._cancelNextFrame=function(i){if(typeof window<"u"&&window.cancelAnimationFrame)window.cancelAnimationFrame(i.frameRequestId);else throw new Error("Matter.Runner: missing required global window.cancelAnimationFrame.")};var u=function(i){for(var v=0,l=i.length,t=0;t<l;t+=1)v+=i[t];return v/l||0}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(8),a=f(0),s=a.deprecated;(function(){e.collides=function(u,i){return n.collides(u,i)},s(e,"collides","SAT.collides \u27A4 replaced by Collision.collides")})()}),(function(g,T,f){var e={};g.exports=e;var n=f(1),a=f(0);(function(){e.pathToVertices=function(s,u){typeof window<"u"&&!("SVGPathSeg"in window)&&a.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var i,v,l,t,r,o,c,d,y,P,M=[],h,m,x=0,p=0,C=0;u=u||15;var w=function(I,A,k){var B=k%2===1&&k>1;if(!y||I!=y.x||A!=y.y){y&&B?(h=y.x,m=y.y):(h=0,m=0);var E={x:h+I,y:m+A};(B||!y)&&(y=E),M.push(E),p=h+I,C=m+A}},S=function(I){var A=I.pathSegTypeAsLetter.toUpperCase();if(A!=="Z"){switch(A){case"M":case"L":case"T":case"C":case"S":case"Q":p=I.x,C=I.y;break;case"H":p=I.x;break;case"V":C=I.y;break}w(p,C,I.pathSegType)}};for(e._svgPathToAbsolute(s),l=s.getTotalLength(),o=[],i=0;i<s.pathSegList.numberOfItems;i+=1)o.push(s.pathSegList.getItem(i));for(c=o.concat();x<l;){if(P=s.getPathSegAtLength(x),r=o[P],r!=d){for(;c.length&&c[0]!=r;)S(c.shift());d=r}switch(r.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":t=s.getPointAtLength(x),w(t.x,t.y,0);break}x+=u}for(i=0,v=c.length;i<v;++i)S(c[i]);return M},e._svgPathToAbsolute=function(s){for(var u,i,v,l,t,r,o=s.pathSegList,c=0,d=0,y=o.numberOfItems,P=0;P<y;++P){var M=o.getItem(P),h=M.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(h))"x"in M&&(c=M.x),"y"in M&&(d=M.y);else switch("x1"in M&&(v=c+M.x1),"x2"in M&&(t=c+M.x2),"y1"in M&&(l=d+M.y1),"y2"in M&&(r=d+M.y2),"x"in M&&(c+=M.x),"y"in M&&(d+=M.y),h){case"m":o.replaceItem(s.createSVGPathSegMovetoAbs(c,d),P);break;case"l":o.replaceItem(s.createSVGPathSegLinetoAbs(c,d),P);break;case"h":o.replaceItem(s.createSVGPathSegLinetoHorizontalAbs(c),P);break;case"v":o.replaceItem(s.createSVGPathSegLinetoVerticalAbs(d),P);break;case"c":o.replaceItem(s.createSVGPathSegCurvetoCubicAbs(c,d,v,l,t,r),P);break;case"s":o.replaceItem(s.createSVGPathSegCurvetoCubicSmoothAbs(c,d,t,r),P);break;case"q":o.replaceItem(s.createSVGPathSegCurvetoQuadraticAbs(c,d,v,l),P);break;case"t":o.replaceItem(s.createSVGPathSegCurvetoQuadraticSmoothAbs(c,d),P);break;case"a":o.replaceItem(s.createSVGPathSegArcAbs(c,d,M.r1,M.r2,M.angle,M.largeArcFlag,M.sweepFlag),P);break;case"z":case"Z":c=u,d=i;break}(h=="M"||h=="m")&&(u=c,i=d)}}})()}),(function(g,T,f){var e={};g.exports=e;var n=f(6),a=f(0);(function(){e.create=n.create,e.add=n.add,e.remove=n.remove,e.clear=n.clear,e.addComposite=n.addComposite,e.addBody=n.addBody,e.addConstraint=n.addConstraint})()})])})});var Ge=gt($e(),1),{Engine:We,Bodies:ze,Composite:Se,Body:Ue}=Ge.default,dt=250,Ne={read:"#6a9bcc",edit:"#788c5d",terminal:"#d4a27f",web:"#c46686",agent:"#cbcadb",ai:"#d97757",other:"#b0aea5"};function Y(g,T,f,e,n=0){return ze.rectangle(g,T,f,e,{isStatic:!0,angle:n,friction:.1})}var ue=class{constructor(){this.engine=We.create({enableSleeping:!0}),this.engine.gravity.y=1.15,this.tokens=[],Se.add(this.engine.world,[Y(190,522,230,24),Y(96,484,14,64),Y(284,484,14,64),Y(134,432,44,12),Y(246,432,44,12),Y(162,320,12,175),Y(218,320,12,175),Y(146,172,100,12,1.05),Y(234,172,100,12,-1.05)])}drop(T,f=0){let e=Ne[T]||Ne.other,n=8+Math.min(5,f),a=190+(Math.random()-.5)*80,s=ze.circle(a,-40-Math.random()*30,n,{restitution:.35,friction:.05,frictionAir:.012,density:.0015});Ue.setVelocity(s,{x:(Math.random()-.5)*1.5,y:1+Math.random()*2}),Ue.setAngularVelocity(s,(Math.random()-.5)*.2),Se.add(this.engine.world,s);let u={body:s,category:T,color:e,r:n,bornAt:performance.now(),dissolveAt:0};if(this.tokens.push(u),this.tokens.length>dt){let i=this.tokens.find(v=>!v.dissolveAt);i&&(i.dissolveAt=performance.now())}return u}step(T,f){We.update(this.engine,Math.min(T,33));let e=performance.now();for(let n of this.tokens){if(n.dissolveAt)continue;let a=n.body.position.y>620||n.body.position.x<-40||n.body.position.x>420,s=e-n.bornAt>30*6e4;(a||s)&&(n.dissolveAt=e)}for(let n=this.tokens.length-1;n>=0;n--){let a=this.tokens[n];a.dissolveAt&&e-a.dissolveAt>700&&(Se.remove(this.engine.world,a.body),this.tokens.splice(n,1))}}};var ve=380,Je=600,ee=510,pt=120,mt='Georgia, "Times New Roman", serif',Qe='"Cascadia Mono", Consolas, "Courier New", monospace';function te(g){g.beginPath(),g.moveTo(146,200),g.bezierCurveTo(116,162,130,102,190,102),g.bezierCurveTo(250,102,264,162,234,200),g.bezierCurveTo(222,252,214,320,212,392),g.bezierCurveTo(213,412,219,424,228,430),g.lineTo(262,430),g.quadraticCurveTo(270,430,270,438),g.lineTo(270,462),g.lineTo(282,462),g.quadraticCurveTo(290,462,290,470),g.lineTo(290,498),g.quadraticCurveTo(290,510,278,510),g.lineTo(102,510),g.quadraticCurveTo(90,510,90,498),g.lineTo(90,470),g.quadraticCurveTo(90,462,98,462),g.lineTo(110,462),g.lineTo(110,438),g.quadraticCurveTo(110,430,118,430),g.lineTo(152,430),g.bezierCurveTo(161,424,167,412,168,392),g.bezierCurveTo(166,320,158,252,146,200),g.closePath()}var _=[{p:0,c:[212,162,127]},{p:55,c:[217,119,87]},{p:85,c:[198,97,63]},{p:100,c:[157,60,40]}];function Ke(g){let T=Math.max(0,Math.min(100,g));for(let f=1;f<_.length;f++)if(T<=_[f].p){let e=_[f-1],n=_[f],a=(T-e.p)/(n.p-e.p||1);return e.c.map((s,u)=>Math.round(s+(n.c[u]-s)*a))}return _[_.length-1].c}var Ce=(g,T)=>`rgba(${g[0]},${g[1]},${g[2]},${T})`;function Me(g){return ee-Math.max(0,Math.min(100,g))/100*(ee-pt)}function Ze(g,T=!1){let f=T?"250,249,245":"20,20,19";te(g),g.fillStyle=T?"rgba(250,249,245,0.05)":"rgba(255,255,255,0.35)",g.fill(),g.save(),te(g),g.clip(),g.strokeStyle=`rgba(${f},0.18)`,g.lineWidth=1.5,g.beginPath(),g.ellipse(190,158,22,55,0,0,Math.PI*2),g.stroke(),g.beginPath(),g.ellipse(190,158,44,55,0,0,Math.PI*2),g.stroke(),g.beginPath(),g.ellipse(190,158,57,18,0,0,Math.PI*2),g.stroke(),g.restore(),te(g),g.strokeStyle=`rgba(${f},${T?.75:.65})`,g.lineWidth=2.5,g.lineJoin="round",g.stroke(),g.beginPath(),g.moveTo(152,130),g.quadraticCurveTo(144,152,150,178),g.strokeStyle=T?"rgba(250,249,245,0.22)":"rgba(255,255,255,0.8)",g.lineWidth=5,g.lineCap="round",g.stroke(),g.font='600 13px ui-monospace, "Cascadia Mono", Consolas, monospace',g.textAlign="center",g.textBaseline="middle",g.fillStyle=`rgba(${f},0.5)`,g.fillText("W O R L D C U P",190,487)}function xt(g){g.font=`10px ${Qe}`,g.fillStyle="rgba(20,20,19,0.4)",g.strokeStyle="rgba(20,20,19,0.3)",g.lineWidth=1.5,g.textAlign="left";for(let T of[25,50,75]){let f=Me(T);g.beginPath(),g.moveTo(316,f),g.lineTo(328,f),g.stroke(),g.fillText(`${T}`,334,f+3)}}function se(g,T,f,e,n,a=0,s=1,u=!1){g.save(),g.translate(T,f),g.scale(e,e);let i=Ke(n),v=Me(n);if(n>.5){g.save(),te(g),g.clip(),g.fillStyle=Ce(i,1),g.fillRect(40,v,300,ee-v+10),g.fillStyle="rgba(250,249,245,0.45)",g.fillRect(40,v,300,3);let l=s,t=()=>(l=l*16807%2147483647)/2147483647,r=Math.min(26,a),o=["#6a9bcc","#788c5d","#d4a27f","#c46686","#cbcadb"];for(let c=0;c<r;c++){let d=75+t()*230,y=ee-14-t()*Math.min(90,ee-v-18);g.beginPath(),g.arc(d,y,7,0,Math.PI*2),g.fillStyle=o[c%o.length],g.globalAlpha=.9,g.fill(),g.globalAlpha=1}g.restore()}Ze(g,u),g.restore()}var he=class{constructor(T){this.canvas=T,this.ctx=T.getContext("2d"),this.physics=new ue,this.fill=0,this.targetFill=0,this.estimated=!1,this.energy=0,this.bubbles=[],this.spills=[],this.sprites=new Map,this.lastT=performance.now(),this.wavePhase=0,this._resize=this._resize.bind(this),new ResizeObserver(this._resize).observe(T.parentElement),this._resize(),requestAnimationFrame(f=>this._frame(f))}setFill(T,f=!1){this.targetFill=Math.max(0,Math.min(100,T)),this.estimated=f}drop(T,f=0){this.physics.drop(T,f),this.energy=Math.min(14,this.energy+2.2)}seed(T,f){let e=Object.entries(T).filter(([,u])=>u>0),n=e.reduce((u,[,i])=>u+i,0)||1,a=Math.min(80,f),s=120;for(let[u,i]of e){let v=Math.max(1,Math.round(i/n*a));for(let l=0;l<v;l++)setTimeout(()=>this.drop(u),s),s+=28+Math.random()*40}}_sprite(T,f){let e=`${T}-${f}`,n=this.sprites.get(e);if(n)return n;let a=f+3,s=document.createElement("canvas");s.width=s.height=Math.ceil(a*2);let u=s.getContext("2d"),i=a;return u.beginPath(),u.arc(i,i,f,0,Math.PI*2),u.fillStyle=T,u.fill(),u.strokeStyle="rgba(20,20,19,0.45)",u.lineWidth=1.4,u.stroke(),u.beginPath(),u.arc(i-f*.3,i-f*.35,f*.28,0,Math.PI*2),u.fillStyle="rgba(250,249,245,0.6)",u.fill(),n={canvas:s,pad:a},this.sprites.set(e,n),n}_resize(){let T=this.canvas.parentElement,f=Math.min(2,window.devicePixelRatio||1),e=T.clientWidth,n=T.clientHeight;!e||!n||(this.canvas.width=Math.round(e*f),this.canvas.height=Math.round(n*f),this.dpr=f,this.scale=Math.min(e*f/ve,n*f/Je)*.92,this.ox=(e*f-ve*this.scale)/2,this.oy=(n*f-Je*this.scale)/2)}_surfaceY(T,f,e){return f+Math.sin(T*.045+this.wavePhase)*e+Math.sin(T*.02-this.wavePhase*.7)*e*.6}_frame(T){let f=T-this.lastT;this.lastT=T,this.wavePhase+=f*.0022,this.energy=Math.max(0,this.energy-f*.004),this.fill+=(this.targetFill-this.fill)*Math.min(1,f*.0015),Math.abs(this.targetFill-this.fill)<.05&&(this.fill=this.targetFill);let e=Me(this.fill);this.physics.step(f,e),this._draw(T,f,e),requestAnimationFrame(n=>this._frame(n))}_draw(T,f,e){let{ctx:n,canvas:a}=this;n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,a.width,a.height),n.setTransform(this.scale,0,0,this.scale,this.ox,this.oy);let s=Ke(this.fill),u=2.2+this.energy,i=this.fill>=95;if(n.beginPath(),n.ellipse(190,522,150,14,0,0,Math.PI*2),n.fillStyle="rgba(20,20,19,0.07)",n.fill(),xt(n),this.fill>.3){n.save(),te(n),n.clip(),n.beginPath(),n.moveTo(40,this._surfaceY(40,e,u));for(let o=50;o<=340;o+=10)n.lineTo(o,this._surfaceY(o,e,u));n.lineTo(340,520),n.lineTo(40,520),n.closePath(),n.fillStyle=Ce(s,1),n.fill(),n.beginPath(),n.moveTo(40,this._surfaceY(40,e,u));for(let o=50;o<=340;o+=10)n.lineTo(o,this._surfaceY(o,e,u));n.strokeStyle="rgba(250,249,245,0.7)",n.lineWidth=2,n.stroke(),this._bubbles(n,f,e),n.restore()}this._tokens(n,e),Ze(n,!1),i&&this._spill(n,f,s);let v=e<205,l=v?"rgba(250,249,245,0.96)":"rgba(20,20,19,0.92)",t=v?"rgba(250,249,245,0.75)":"rgba(94,93,89,0.95)";n.font=`600 44px ${mt}`,n.textAlign="center",n.textBaseline="middle",n.fillStyle=l,n.fillText(`${Math.round(this.fill)}%`,190,162),n.font=`500 10px ${Qe}`,n.fillStyle=t;let r=this.estimated?"EST. ACTIVITY":"OF 5H LIMIT";n.fillText(r.split("").join("\u200A"),190,192)}_tokens(T,f){T.save(),te(T),T.rect(125,-80,130,185),T.clip();let e=performance.now();for(let n of this.physics.tokens){let{body:a,color:s,r:u}=n,i=1;if(n.dissolveAt&&(i=Math.max(0,1-(e-n.dissolveAt)/700),i<=0))continue;let v=a.position.y>f+4,l=this._sprite(s,u);T.globalAlpha=i*(v?.55:1),T.drawImage(l.canvas,a.position.x-l.pad,a.position.y-l.pad),T.globalAlpha=1}T.restore()}_bubbles(T,f,e){this.fill>2&&Math.random()<.02+this.energy*.012&&this.bubbles.push({x:118+Math.random()*144,y:ee-10,r:1.5+Math.random()*3,vy:.02+Math.random()*.03});for(let n=this.bubbles.length-1;n>=0;n--){let a=this.bubbles[n];if(a.y-=a.vy*f,a.x+=Math.sin(a.y*.05)*.3,a.y<e+6){this.bubbles.splice(n,1);continue}T.beginPath(),T.arc(a.x,a.y,a.r,0,Math.PI*2),T.strokeStyle="rgba(250,249,245,0.55)",T.lineWidth=1,T.stroke()}}_spill(T,f,e){if(Math.random()<.12){let n=Math.random()<.5?-1:1;this.spills.push({x:190+n*(52+Math.random()*8),y:112,vx:n*(.02+Math.random()*.05),vy:-.05-Math.random()*.06,r:2.5+Math.random()*2.5,life:1})}for(let n=this.spills.length-1;n>=0;n--){let a=this.spills[n];if(a.vy+=f*6e-4,a.x+=a.vx*f,a.y+=a.vy*f,a.life-=f*.0012,a.life<=0||a.y>590){this.spills.splice(n,1);continue}T.beginPath(),T.arc(a.x,a.y,a.r,0,Math.PI*2),T.fillStyle=Ce(e,.85*a.life),T.fill()}}};var _e=g=>g>=1e6?(g/1e6).toFixed(1)+"M":g>=1e3?(g/1e3).toFixed(1)+"k":String(g),yt="#faf9f5",Ye="#f0eee6",ge="#141413",Xe="#5e5d59",we="#87867f",Pe="#d97757",de='Georgia, "Times New Roman", serif',St='-apple-system, "Segoe UI", Arial, sans-serif',oe='"Cascadia Mono", Consolas, "Courier New", monospace',re=g=>g.toUpperCase().split("").join("\u200A");function pe(g,T="landscape"){let f=T==="landscape"?1200:1080,e=T==="landscape"?630:1350,n=document.createElement("canvas");n.width=f,n.height=e;let a=n.getContext("2d");if(a.fillStyle=yt,a.fillRect(0,0,f,e),a.strokeStyle="rgba(20,20,19,0.18)",a.lineWidth=1.5,a.strokeRect(28,28,f-56,e-56),Ct(a,76,78,17),a.font=`500 17px ${oe}`,a.fillStyle=we,a.textAlign="left",a.fillText(re("claude-cup"),110,84),T==="landscape"){a.fillStyle=Ye,a.fillRect(64,124,420,442),se(a,92,138,.69,g.fill,g.stats.toolCalls,7);let s=560;a.textAlign="left",a.fillStyle=ge,a.font=`600 130px ${de}`,a.fillText(`${Math.round(g.fill)}%`,s,240),je(a,s+4,262,a.measureText(`${Math.round(g.fill)}%`).width-8),a.font=`500 16px ${oe}`,a.fillStyle=Xe,a.fillText(re(g.estimated?"estimated activity today":"of my 5h claude limit used"),s,312),Mt(a,s,376,g),qe(a,f,e,g)}else{a.fillStyle=Ye,a.fillRect(64,130,f-128,700);let s=1.04;se(a,(f-ve*s)/2,156,s,g.fill,g.stats.toolCalls,7),a.textAlign="center",a.fillStyle=ge,a.font=`600 150px ${de}`,a.fillText(`${Math.round(g.fill)}%`,f/2,980),je(a,f/2-130,1004,260),a.font=`500 18px ${oe}`,a.fillStyle=Xe,a.fillText(re(g.estimated?"estimated activity today":"of my 5h claude limit used"),f/2,1052),a.font=`400 30px ${de}`,a.fillStyle=ge,a.fillText(`${_e(g.stats.totalTokens)} tokens \xB7 ${g.stats.efficiency} tok/reply \xB7 ${g.stats.assistantMessages} replies`,f/2,1140),qe(a,f,e,g)}return n}function Ct(g,T,f,e){g.save(),g.strokeStyle=Pe,g.lineWidth=4.5,g.lineCap="round";for(let n=0;n<8;n++){let a=Math.PI/4*n;g.beginPath(),g.moveTo(T+Math.cos(a)*e*.25,f+Math.sin(a)*e*.25),g.lineTo(T+Math.cos(a)*e,f+Math.sin(a)*e),g.stroke()}g.restore()}function je(g,T,f,e){g.fillStyle=Pe,g.fillRect(T,f,e,4),g.fillRect(T,f+8,e,4)}function Mt(g,T,f,e){let n=[[_e(e.stats.totalTokens),"tokens today"],[e.stats.efficiency,"tok / reply"],[String(e.stats.assistantMessages),"claude replies"],[`$${e.stats.cost.toFixed(2)}`,"est. api value"]],a=f;for(let[s,u]of n)g.font=`600 36px ${de}`,g.fillStyle=ge,g.fillText(s,T,a),g.font=`500 13px ${oe}`,g.fillStyle=we,g.fillText(re(u),T+200,a-4),a+=56}function qe(g,T,f,e){g.strokeStyle="rgba(20,20,19,0.12)",g.lineWidth=1,g.beginPath(),g.moveTo(64,f-86),g.lineTo(T-64,f-86),g.stroke(),g.textAlign="left",g.font=`600 22px ${St}`,g.fillStyle=Pe,g.fillText("npx claude-cup",64,f-50),g.textAlign="right",g.font=`500 15px ${oe}`,g.fillStyle=we,g.fillText(re(e.dateLabel),T-64,f-50)}var R=g=>document.getElementById(g),K=g=>g>=1e6?(g/1e6).toFixed(2)+"M":g>=1e3?(g/1e3).toFixed(1)+"k":String(g??0),O={stats:null,usage:null,history:[],seeded:!1,leaderboard:null},q=new he(R("jar-canvas"));function tt(){let g=O.usage;if(g&&g.fiveHour&&(g.status==="ok"||g.status==="stale"))q.setFill(g.fiveHour.pct,!1),R("overflow-badge").classList.toggle("hidden",g.fiveHour.pct<95);else if(O.stats){let T=Math.min(92,Math.max(O.stats.totalTokens>0?4:0,O.stats.totalTokens/15e4*100));q.setFill(T,!0),R("overflow-badge").classList.add("hidden")}}function et(g){O.usage=g;let T=R("banner");g.status==="ok"&&g.fiveHour?(R("pct-5h").textContent=`${Math.round(g.fiveHour.pct)}%`,T.classList.add("hidden")):g.status==="stale"&&g.fiveHour?(R("pct-5h").textContent=`${Math.round(g.fiveHour.pct)}%`,T.textContent=`showing last known limits - ${g.reason}`,T.classList.remove("hidden")):(R("pct-5h").textContent="--%",R("reset-5h").textContent="",T.textContent=`limit data unavailable - ${g.reason}. Showing local activity only.`,T.classList.remove("hidden")),g.sevenDay&&(R("pct-7d").textContent=`${Math.round(g.sevenDay.pct)}%`,R("bar-7d").style.width=`${g.sevenDay.pct}%`,R("bar-7d").style.background=g.sevenDay.pct>85?"#c6613f":""),tt()}function Te(g){O.stats=g,R("stat-tokens").textContent=K(g.totalTokens),R("stat-tokens-sub").textContent=`in ${K(g.tokensIn)} / out ${K(g.tokensOut)}`,R("stat-cost").textContent=`$${(g.cost??0).toFixed(2)}`,R("stat-eff").textContent=String(g.buildRate??0),R("stat-messages").textContent=K(g.assistantMessages),R("stat-sessions").textContent=String(g.sessions??0);let T=O.leaderboard;R("stat-burn").textContent=T&&T.rank>0?`#${T.rank} / ${K(T.total)}`:"--",R("stat-cache").textContent=K(g.cacheRead);let f=g.toolsByCategory||{};for(let e of["read","edit","terminal","web","agent"])R(`cat-${e}`).textContent=String(f[e]||0);R("cat-ai").textContent=K(g.assistantMessages),R("empty-hint").classList.toggle("hidden",g.totalTokens>0||g.toolCalls>0),tt()}function wt(){let g=O.usage?.timeLeft;if(!g)return"";if(g.outlasts)return" \xB7 lasts past reset";let T=Math.floor(g.minutes/60),f=Math.round(g.minutes%60);return` \xB7 ~${T>0?`${T}h ${f}m`:`${f}m`} left at this pace`}function Ie(){let g=O.usage,T=R("reset-5h");if(!g||!g.fiveHour||!g.fiveHour.resetsAt){T.textContent&&(T.textContent="");return}let f=Date.parse(g.fiveHour.resetsAt)-Date.now();if(f<=0){T.textContent="resetting...";return}let e=Math.floor(f/36e5),n=Math.floor(f%36e5/6e4);T.textContent=(e>0?`resets in ${e}h ${n}m`:`resets in ${n}m`)+wt()}setInterval(Ie,1e3);var Pt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ae(){let g=R("shelf-jars");g.innerHTML="";let T=[...O.history];O.stats&&T.push({date:O.stats.date,totalTokens:O.stats.totalTokens,toolCalls:O.stats.toolCalls,fillMax:Math.max(O.stats.fillMax||0,O.usage?.fiveHour?.pct||0),today:!0});for(let e of T){let n=document.createElement("div");n.className="shelf-jar"+(e.today?" today":"");let a=document.createElement("canvas");a.width=88,a.height=124;let s=a.getContext("2d"),u=e.fillMax||Math.min(85,(e.totalTokens||0)/15e4*100);se(s,-2,-6,.225,u,Math.min(10,Math.round((e.toolCalls||0)/10)),3);let i=e.today?"today":Pt[new Date(e.date+"T12:00:00").getDay()];n.appendChild(a),n.insertAdjacentHTML("beforeend",`<span class="day">${i}</span><span class="amt">${e.totalTokens?K(e.totalTokens):"-"}</span>`),n.title=`${e.date}: ${K(e.totalTokens)} tokens, ${e.toolCalls||0} tool calls, peak ${Math.round(e.fillMax||0)}%`,g.appendChild(n)}let f=0;for(let e=T.length-1;e>=0&&(T[e].totalTokens||0)>0;e--)f++;R("streak").textContent=f>1?`${f}-day streak`:""}function Be(){return{fill:O.usage?.fiveHour?O.usage.fiveHour.pct:q.fill,estimated:!(O.usage&&O.usage.fiveHour),stats:{totalTokens:O.stats?.totalTokens||0,toolCalls:O.stats?.toolCalls||0,assistantMessages:O.stats?.assistantMessages||0,efficiency:O.stats?.assistantMessages>0?K(Math.round(O.stats.totalTokens/O.stats.assistantMessages)):"\u2014",cost:O.stats?.cost||0},dateLabel:new Date().toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}}var ne=null;function Tt(){ne=pe(Be(),"landscape");let g=R("share-preview");g.width=ne.width,g.height=ne.height,g.getContext("2d").drawImage(ne,0,0),R("share-modal").classList.remove("hidden")}function Le(g,T){g.toBlob(f=>{let e=document.createElement("a");e.href=URL.createObjectURL(f),e.download=T,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)},"image/png")}R("share-btn").addEventListener("click",Tt);R("share-close").addEventListener("click",()=>R("share-modal").classList.add("hidden"));R("share-modal").addEventListener("click",g=>{g.target===R("share-modal")&&R("share-modal").classList.add("hidden")});R("share-dl-land").addEventListener("click",()=>Le(pe(Be(),"landscape"),"claude-cup.png"));R("share-dl-story").addEventListener("click",()=>Le(pe(Be(),"story"),"claude-cup-story.png"));R("share-copy").addEventListener("click",async()=>{let g=R("share-copy");try{let T=await new Promise(f=>ne.toBlob(f,"image/png"));await navigator.clipboard.write([new ClipboardItem({"image/png":T})]),g.textContent="Copied!"}catch{Le(ne,"claude-cup.png"),g.textContent="Downloaded instead"}setTimeout(()=>g.textContent="Copy image",1800)});var X={on:!1,busy:!1};function ke(g){X.on=!!(g&&g.on),R("eco-toggle").classList.toggle("on",X.on),R("eco-toggle").setAttribute("aria-pressed",String(X.on)),R("eco-state").textContent=X.on?"on":"off",R("stat-eff-sub").textContent=X.on?`eco on \xB7 ${g.summary||"token saver"}`:"eco mode off"}R("eco-toggle").addEventListener("click",async()=>{if(!X.busy){X.busy=!0,R("eco-toggle").style.opacity="0.6";try{let T=await(await fetch("/api/eco",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({on:!X.on})})).json();if(ke(T.status),!T.ok&&T.error){let f=R("banner");f.textContent=T.error,f.classList.remove("hidden")}}catch{}R("eco-toggle").style.opacity="",X.busy=!1}});function At(){let g=new EventSource("/events");g.addEventListener("open",()=>{R("live-dot").classList.add("on"),R("live-dot").title="live"}),g.addEventListener("error",()=>{R("live-dot").classList.remove("on"),R("live-dot").title="reconnecting..."}),g.addEventListener("snapshot",T=>{let f=JSON.parse(T.data);if(O.history=f.history||[],Te(f.stats),et(f.usage),ke(f.eco),Ie(),Ae(),!O.seeded){O.seeded=!0;let e={...f.stats.toolsByCategory};e.ai=Math.min(20,f.stats.assistantMessages),q.seed(e,f.stats.toolCalls+e.ai)}}),g.addEventListener("activity",T=>{let f=JSON.parse(T.data);f.kind==="message"?q.drop("ai",Math.min(5,(f.tokens||0)/600)):q.drop(f.category||"other")}),g.addEventListener("stats",T=>{Te(JSON.parse(T.data)),Ae()}),g.addEventListener("usage",T=>{et(JSON.parse(T.data)),Ie(),Ae()}),g.addEventListener("eco",T=>{ke(JSON.parse(T.data))}),g.addEventListener("leaderboard",T=>{O.leaderboard=JSON.parse(T.data),O.stats&&Te(O.stats)})}At();window.__jar={state:O,scene:q};})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
matter-js/build/matter.js:
|
package/dist/web/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>claude-
|
|
6
|
+
<title>claude-cup</title>
|
|
7
7
|
<link rel="stylesheet" href="styles.css" />
|
|
8
8
|
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%23faf9f5'/%3E%3Cg stroke='%23d97757' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M16 5v22M5 16h22M8.2 8.2l15.6 15.6M23.8 8.2L8.2 23.8'/%3E%3C/g%3E%3C/svg%3E" />
|
|
9
9
|
</head>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<path d="M16 3.5v25M3.5 16h25M7.2 7.2l17.6 17.6M24.8 7.2L7.2 24.8"/>
|
|
17
17
|
</g>
|
|
18
18
|
</svg>
|
|
19
|
-
<h1>claude-
|
|
19
|
+
<h1>claude-cup</h1>
|
|
20
20
|
<span id="live-dot" class="live-dot" title="connecting..."></span>
|
|
21
21
|
</div>
|
|
22
22
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// claude-
|
|
2
|
+
// claude-cup MCP launcher (copied to ~/.claude-jar/mcp-server.mjs on registration)
|
|
3
3
|
// This is the entry registered in ~/.claude/settings.json (and Cursor equivalents).
|
|
4
4
|
// It supports both long-lived stdio MCP server mode and short-lived --hook mode.
|
|
5
5
|
// The source path is baked in at build time so the launcher works from any directory.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-cup",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Claude Jar v2 — native desktop visual companion (Tauri + Svelte) with MCP/hook integration for live Claude activity. Beautiful accumulating jar + live intensity meter. The jar is the usage meter.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@ mkdirSync(outDir, { recursive: true });
|
|
|
19
19
|
const srcAbsolute = mcpSrc.replace(/\\/g, '/');
|
|
20
20
|
|
|
21
21
|
const launcher = `#!/usr/bin/env node
|
|
22
|
-
// claude-
|
|
22
|
+
// claude-cup MCP launcher (copied to ~/.claude-jar/mcp-server.mjs on registration)
|
|
23
23
|
// This is the entry registered in ~/.claude/settings.json (and Cursor equivalents).
|
|
24
24
|
// It supports both long-lived stdio MCP server mode and short-lived --hook mode.
|
|
25
25
|
// The source path is baked in at build time so the launcher works from any directory.
|
package/src/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
process.title = 'claude-cup';
|
|
3
|
+
// claude-cup: the Anthropic worldwide building contest.
|
|
3
4
|
// In a terminal (including the Claude Code desktop app's integrated terminal)
|
|
4
5
|
// it renders right there. Otherwise it serves the web UI and opens a browser.
|
|
5
6
|
//
|
|
@@ -142,9 +143,9 @@ async function main() {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
if (args.help) {
|
|
145
|
-
console.log(`claude-
|
|
146
|
+
console.log(`claude-cup - the Anthropic worldwide building contest
|
|
146
147
|
|
|
147
|
-
Usage: npx claude-
|
|
148
|
+
Usage: npx claude-cup [command] [options]
|
|
148
149
|
|
|
149
150
|
Run it inside the Claude Code desktop app's terminal (Ctrl+\`) to see the
|
|
150
151
|
jar right next to your session - no browser needed.
|
|
@@ -152,7 +153,7 @@ jar right next to your session - no browser needed.
|
|
|
152
153
|
Commands:
|
|
153
154
|
statusline format Claude Code statusline JSON from stdin
|
|
154
155
|
(settings.json: {"statusLine":{"type":"command",
|
|
155
|
-
"command":"claude-
|
|
156
|
+
"command":"claude-cup statusline"}})
|
|
156
157
|
|
|
157
158
|
Options:
|
|
158
159
|
-p, --port <n> port for the web ui (default 4690, auto-increments)
|
|
@@ -171,7 +172,7 @@ Options:
|
|
|
171
172
|
const distDir = join(pkgRoot, 'dist', 'web');
|
|
172
173
|
|
|
173
174
|
if (!existsSync(join(distDir, 'index.html'))) {
|
|
174
|
-
console.error('claude-
|
|
175
|
+
console.error('claude-cup: UI bundle missing. If running from source, run: npm run build');
|
|
175
176
|
process.exit(1);
|
|
176
177
|
}
|
|
177
178
|
|
|
@@ -315,7 +316,7 @@ Options:
|
|
|
315
316
|
const s = aggregator.snapshot();
|
|
316
317
|
console.log(`
|
|
317
318
|
.-~~-.
|
|
318
|
-
| | claude-
|
|
319
|
+
| | claude-cup is running
|
|
319
320
|
|~~~~~~| ${url}
|
|
320
321
|
|::::::| today so far: ${s.totalTokens.toLocaleString()} tokens, ${s.toolCalls} tool calls
|
|
321
322
|
\`-..-' (everything stays on your machine)
|
|
@@ -366,6 +367,6 @@ Options:
|
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
main().catch((err) => {
|
|
369
|
-
console.error('claude-
|
|
370
|
+
console.error('claude-cup failed to start:', err.message);
|
|
370
371
|
process.exit(1);
|
|
371
372
|
});
|
package/src/eco.js
CHANGED
|
@@ -23,7 +23,7 @@ export const ECO_ENV = {
|
|
|
23
23
|
const BLOCK_START = '<!-- claude-jar:eco:start -->';
|
|
24
24
|
const BLOCK_END = '<!-- claude-jar:eco:end -->';
|
|
25
25
|
const ECO_BLOCK = `${BLOCK_START}
|
|
26
|
-
# Eco mode (managed by claude-
|
|
26
|
+
# Eco mode (managed by claude-cup - toggling eco off removes this block)
|
|
27
27
|
Be maximally token-efficient: answer concisely with no preamble, recap, or
|
|
28
28
|
celebratory summary. Read only files you truly need and never re-read
|
|
29
29
|
unchanged files. Batch related edits. Prefer targeted diffs over full file
|
package/src/statusline.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// `claude-
|
|
1
|
+
// `claude-cup statusline`: one-line meter for Claude Code's statusline.
|
|
2
2
|
// Claude Code (>= 2.1.80) pipes session JSON to the statusline command on
|
|
3
3
|
// stdin, including rate_limits for Pro/Max accounts. We parse it and print
|
|
4
4
|
// a single line. No network calls - this runs on every statusline refresh.
|
|
@@ -37,7 +37,7 @@ export function formatStatusline(input) {
|
|
|
37
37
|
const seven = pctOf(rl.seven_day);
|
|
38
38
|
|
|
39
39
|
if (five === null && seven === null) {
|
|
40
|
-
return `${CLAY}${SPARK}${RESET} ${DIM}claude-
|
|
40
|
+
return `${CLAY}${SPARK}${RESET} ${DIM}claude-cup${RESET}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const parts = [];
|
package/src/usage-api.js
CHANGED
|
@@ -57,7 +57,7 @@ export class UsagePoller extends EventEmitter {
|
|
|
57
57
|
if (c && c.fiveHour !== undefined) {
|
|
58
58
|
const { samples, ...cachedState } = c;
|
|
59
59
|
this.state = { ...cachedState, status: 'stale', reason: 'cached from previous run' };
|
|
60
|
-
// restore pace history persisted by any previous claude-
|
|
60
|
+
// restore pace history persisted by any previous claude-cup process
|
|
61
61
|
if (Array.isArray(samples)) {
|
|
62
62
|
this.samples = this._normalizeSamples(samples);
|
|
63
63
|
} else if (c.fiveHour && typeof c.fetchedAt === 'number' && this.now() - c.fetchedAt < 45 * 60000) {
|
|
@@ -71,7 +71,7 @@ export class UsagePoller extends EventEmitter {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Instance cooperation: if another claude-
|
|
74
|
+
* Instance cooperation: if another claude-cup process (TUI, web, statusline)
|
|
75
75
|
* fetched fresh data recently, adopt its result and pace samples from the
|
|
76
76
|
* shared cache file instead of hitting the rate-limited endpoint again.
|
|
77
77
|
*/
|
|
@@ -186,7 +186,7 @@ export class UsagePoller extends EventEmitter {
|
|
|
186
186
|
|
|
187
187
|
async pollNow() {
|
|
188
188
|
if (Date.now() < this.backoffUntil) return this.state;
|
|
189
|
-
// another claude-
|
|
189
|
+
// another claude-cup process may have fetched moments ago - reuse its data
|
|
190
190
|
if (this._adoptSharedCache()) return this.state;
|
|
191
191
|
const cred = this.readToken();
|
|
192
192
|
if (cred.error) {
|