function r(r,n){return l.sqrt((r.x-n.x)*(r.x-n.x)+(r.y-n.y)*(r.y-n.y))}function n(n,t){var a;do a={x:x()*o,y:x()*v,r:t,t:n||0,vx:0,vy:0,a:0};while(i.filter((n)=>{return r(n,a)<n.r+a.r&&n!=a}).length);return i.push(a),a}function t(r,n){r.vx=5*l.cos(n),r.vy=5*l.sin(n)}function e(){y++,u.r=30*x()+8;for(var r=9;r--;)n(0,u.r*r/9+8)}var i=[],o=a.width,v=a.height,l=Math,x=l.random,f=.95,y=0,u=n(2);setInterval(()=>{c.fillStyle=0,c.fillRect(0,0,o,v),1==i.length&&e();for(var n=i.length;n-- >0;){var a=i[n];!a.t&&x()>.99&&t(a,7*x()),a.vx*=f,a.vy*=f,a.x+=a.vx,a.y+=a.vy,a.x=l.max(0,l.min(o,a.x)),a.y=l.max(0,l.min(v,a.y)),a.a+=.1*(a.r-a.a),c.beginPath(),c.strokeStyle=a.t?"#fff":"rgb("+(a.a/u.a*255|0)+", "+(u.a/a.a*255|0)+",0)",c.lineWidth=l.abs(a.vx)+l.abs(a.vx)+1,c.arc(a.x,a.y,a.a,0,7),c.stroke();for(var h=0;h<i.length;h++){var s=i[h];n!=h&&r(a,s)<a.r+s.r&&a.r<s.r&&(s.r+=a.r,a.d=1)}a.d&&i.splice(n,1)}u.d&&confirm("Wave: "+y+"\nAgain?")&&top.reload()},15),b.onmouseup=(r)=>{t(u,l.atan2(r.clientY-u.y,r.clientX-u.x))};
ZnVuY3Rpb24gcihyLG4pe3JldHVybiBsLnNxcnQoKHIueC1uLngpKihyLngtbi54KSsoci55LW4ueSkqKHIueS1uLnkpKX1mdW5jdGlvbiBuKG4sdCl7dmFyIGE7ZG8gYT17eDp4KCkqbyx5OngoKSp2LHI6dCx0Om58fDAsdng6MCx2eTowLGE6MH07d2hpbGUoaS5maWx0ZXIoKG4pPT57cmV0dXJuIHIobixhKTxuLnIrYS5yJiZuIT1hfSkubGVuZ3RoKTtyZXR1cm4gaS5wdXNoKGEpLGF9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