`,actions:e,allowClose:!0});r&&(!H||await el({title:"Restart run to try this item?",text:"You're about to start a new run with the selected unlocked item, is that really what you wanted ? ",actions:[{value:!0,text:"Restart game to test item"},{value:!1,text:"Cancel"}]}))&&(_A=r,_q())}function eh(_,e){return Math.sqrt(Math.pow(_.x-e.x,2)+Math.pow(_.y-e.y,2))}function eb(){return`hsl(${2*Math.round(e_/4)%360},100%,70%)`}function ey(_,e,t,r){let o=eh(_,e),l=__/2;if(o>l)return;let s=(_.x-e.x)/o,a=(_.y-e.y)/o,i=-t*(l-o)/(1.2*l)/3*Math.min(500,e_)/500;r&&void 0!==e.vx&&void 0!==e.vy&&(e.vx+=s*i,e.vy+=a*i),_.vx-=s*i,_.vy-=a*i,_x.push({type:"particle",duration:100,time:e_,size:E/2,color:eb(),ethereal:!0,x:_.x,y:_.y,vx:-(10*s)+_.vx+(Math.random()-.5)*2,vy:-(10*a)+_.vy+(Math.random()-.5)*2}),r&&void 0!==e.vx&&void 0!==e.vy&&_x.push({type:"particle",duration:100,time:e_,size:E/2,color:eb(),ethereal:!0,x:e.x,y:e.y,vx:10*s+e.vx+(Math.random()-.5)*2,vy:10*a+e.vy+(Math.random()-.5)*2})}function eu(){ea("record")&&r?.state==="recording"&&r?.pause()}function em(){ea("record")&&r&&(r?.stop(),r=null)}function eg(){try{if(null!==document.fullscreenElement)document.exitFullscreen?document.exitFullscreen().then():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();else{let _=document.documentElement;_.requestFullscreen?_.requestFullscreen().then():_.webkitRequestFullscreen&&_.webkitRequestFullscreen()}}catch(_){console.warn(_)}}et.addEventListener("click",_=>{_.preventDefault(),ei().then()}),document.getElementById("menu")?.addEventListener("click",_=>{_.preventDefault(),en().then()});const ed={ArrowLeft:0,ArrowRight:0,Shift:0};function ep(_,e){ed[_]=e,_V=(ed.ArrowRight-ed.ArrowLeft)*(1+2*ed.Shift)*__/50}document.addEventListener("keydown",_=>{"f"!==_.key.toLowerCase()||_.ctrlKey||_.metaKey?_.key in ed&&ep(_.key,1):eg()," "===_.key&&!er&&(j?J(!0):U(),_.preventDefault())}),document.addEventListener("keyup",_=>{let e=document.querySelector("button:focus");if(_.key in ed)ep(_.key,0);else if("ArrowDown"===_.key&&e?.nextElementSibling?.tagName==="BUTTON")e?.nextElementSibling?.focus();else if("ArrowUp"===_.key&&e?.previousElementSibling?.tagName==="BUTTON")e?.previousElementSibling?.focus();else if("Escape"===_.key&&eo)eo();else if("Escape"===_.key&&j)J(!0);else if("m"!==_.key.toLowerCase()||er){if("s"!==_.key.toLowerCase()||er)return;ei().then()}else en().then();_.preventDefault()}),_n(),_q(),function _(){_c();let e=performance.now();if(q=__/12*(3-V.smaller_puck+V.bigger_puck),_V&&_I(Z+_V),j){e_+=e-_F,_J.runTime+=e-_F,_J.max_combo=Math.max(_J.max_combo,F);let _=Math.min(4,(e-_F)/(1e3/60));_*=+!!j,_M=_M.filter(_=>!_.destroyed),_W=_W.filter(_=>!_.destroyed);let t=_w.filter(_=>_&&"black"!==_).length;if(e_>_Z+1e3&&V.hot_start&&(_Z=e_,function(_,e,t){let r=Math.max(0,F-(F=Math.max(D(),F-_)));r&&(x.comboDecrease(),void 0!==e&&void 0!==t&&_x.push({type:"text",text:"-"+r,time:e_,color:"red",x:e,y:t,duration:300,size:20}))}(V.hot_start,Z,_t-40)),t<=V.skip_last&&!ee&&(_w.forEach((_,e)=>{_&&_0(e,_W[0],!0)}),ee++),t||_M.length){if(j||e_){let e=!1,t=Math.round(E/2);if(_M.forEach(r=>{if(r.destroyed)return;if(V.coin_magnet){let e=_*(Z-r.x)/(100+Math.pow(r.y-_t,2)+Math.pow(r.x-Z,2))*V.coin_magnet*100;r.vx+=e,r.sa-=e/10}let o=1-(.03*V.viscosity+.005)*_;r.vy*=o,r.vx*=o,r.vx>7*I&&(r.vx=7*I),r.vx<-7*I&&(r.vx=-7*I),r.vy>7*I&&(r.vy=7*I),r.vy<-7*I&&(r.vy=-7*I),r.a+=r.sa,r.vy+=_*r.weight*.8;let l=Math.abs(r.sx)+Math.abs(r.sx),s=_j(r,t,_);if(r.y>_t-t-20&&r.y<_t+20+r.vy&&Math.abs(r.x-Z)_d&&!_H&&(_d=_m,localStorage.setItem("breakout-3-hs",_m.toString())),ea("basic")||_x.push({type:"particle",duration:100+50*Math.random(),time:e_,size:E/2,color:r.color,x:r.previousX,y:r.previousY,vx:(_a-r.x)/100,vy:-r.y/100,ethereal:!0}),Date.now()-_p>16&&(_p=Date.now(),x.coinCatch(r.x)),_J.score+=r.points;else r.y>_i+t&&(r.destroyed=!0,V.compound_interest&&N(r.x,r.y));let a=function(_){let e=E/2,{x:t,y:r,previousX:o,previousY:l}=_,s=_Y(o,r,e),a=_Y(t,l,e),i=void 0===s&&void 0===a&&_Y(t,r,e)||void 0;if(void 0!==s||void 0!==i){_.y=_.previousY,_.vy*=-1;let o=_w[_D(t-e,r+e)],l=_w[_D(t+e,r+e)];o&&!l&&(_.vx+=1,_.sa-=1),!o&&l&&(_.vx-=1,_.sa+=1)}return(void 0!==a||void 0!==i)&&(_.x=_.previousX,_.vx*=-1),s??a??i}(r);V.metamorphosis&&void 0!==a&&_w[a]&&r.color!==_w[a]&&"black"!==_w[a]&&!r.coloredABrick&&(_w[a]=r.color,r.coloredABrick=!0),(void 0!==a||s)&&(r.vx*=.8,r.vy*=.8,r.sa*=.9,l>20&&!e&&(e=!0,x.coinBounce(r.x,.2)),3>Math.abs(r.vy)&&(r.vy=0))}),_W.forEach(e=>(function(_,e){_.previousVX=_.vx,_.previousVY=_.vy;let t=1+V.telekinesis+V.ball_repulse_ball+V.puck_repulse_ball+V.ball_attract_ball;if(_X(_)&&(t+=3,_.vx+=(Z-_.x)/1e3*e*V.telekinesis),_.vx*_.vx+_.vy*_.vy0?1:-1)*.02/t),V.ball_repulse_ball)for(let e of _W)e.x>=_.x||ey(_,e,V.ball_repulse_ball,!0);if(V.ball_attract_ball)for(let e of _W)e.x>=_.x||function(_,e,t){let r=eh(_,e),o=.5*__;if(r1&&!ea("basic"))for(let e=0;e<_.hitItem?.length-1&&e.5,l=Math.random()>.5?1:-1,s=Math.random()>.5?1:-1;_x.push({type:"particle",duration:250,ethereal:!0,time:e_,size:E/2,color:r,x:_h(t)+l*_r/2,y:_b(t)+s*_r/2,vx:o?0:-l*I,vy:o?-s*I:0})}let r=_j(_,10,e);r&&(V.left_is_lava&&r%2&&_.xK+__/2&&N(_.x,_.y),V.top_is_lava&&r>=2&&N(_.x,_.y+20),x.wallBeep(_.x),_.bouncesList?.push({x:_.previousX,y:_.previousY}));let o=_t-20-10,l=Math.abs(_.x-Z)<10+q/2;if(_.y>o&&_.vy>0&&(l||V.extra_life&&_.y>o+10)){if(l){let e=Math.sqrt(_.vx*_.vx+_.vy*_.vy),t=Math.atan2(-q/2,_.x-Z);_.vx=e*Math.cos(t),_.vy=e*Math.sin(t),x.wallBeep(_.x)}else if(_.vy*=-1,V.extra_life=Math.max(0,V.extra_life-1),x.lifeLost(_.x),!ea("basic"))for(let e=0;e<10;e++)_x.push({type:"particle",ethereal:!1,color:"red",destroyed:!1,duration:150,size:E/2,time:e_,x:_.x,y:_.y,vx:Math.random()*I*3,vy:3*I});V.streak_shots&&N(_.x,_.y),V.respawn&&_.hitItem.slice(0,-1).slice(0,V.respawn).forEach(({index:_,color:e})=>{_w[_]||"black"===e||(_w[_]=e)}),_.hitItem=[],_.hitSinceBounce||(_J.misses++,_B++,N(_.x,_.y),_x.push({type:"text",text:"miss",duration:500,time:e_,size:30,color:"red",x:Z,y:_t-40})),_J.puck_bounces++,_.hitSinceBounce=0,_.sapperUses=0,_.piercedSinceBounce=0,_.bouncesList=[{x:_.previousX,y:_.previousY}]}_.y>_t+10&&j&&(_.destroyed=!0,_J.balls_lost++,_W.find(_=>!_.destroyed)||_Q("Game Over","You dropped the ball after catching "+_m+" coins. "));let{x:s,y:a,previousX:i,previousY:n}=_,c=_Y(i,a,10),h=_Y(s,n,10),b=void 0===c&&void 0===h&&_Y(s,a,10)||void 0,y=c??h??b,u=y&&"black"!==_w[y]&&V.sturdy_bricks&&V.sturdy_bricks>5*Math.random(),m=!1;if(u||void 0===y);else(V.pierce_color&&(void 0===c||_w[c]===_v)&&(void 0===h||_w[h]===_v)&&(void 0===b||_w[b]===_v)?0:1)?_.piercedSinceBounce<3*V.pierce&&(m=!0,_.piercedSinceBounce++):m=!0;if(void 0===c&&void 0===b||m||(_.y=_.previousY,_.vy*=-1),void 0===h&&void 0===b||m||(_.x=_.previousX,_.vx*=-1),u){x.wallBeep(s);return}if(void 0!==y){let e=_w[y];_0(y,_,!1),_.sapperUses1&&(_x.push({type:"particle",duration:100*_.sparks,time:e_,size:E/2,color:_v,x:_.x,y:_.y,vx:(Math.random()-.5)*I,vy:(Math.random()-.5)*I,ethereal:!1}),_.sparks=0))})(e,_)),V.wind){let _=(Z-(K+__/2))/__*2*V.wind;for(let e=0;e.5&&_x.push({type:"particle",duration:150,ethereal:!0,time:e_,size:E/2,color:eb(),x:Q+Math.random()*_e,y:Math.random()*_t,vx:8*_,vy:0})}_x.forEach(e=>{"particle"===e.type&&(e.x+=e.vx*_,e.y+=e.vy*_,!e.ethereal&&(e.vy+=.5,_N(_D(e.x,e.y))&&(e.destroyed=!0)))})}}else H+1<_1()?_L(H+1):_Q("Run finished with "+_m+" points","You cleared all levels for this run.");if(F>D()){let _=!ea("basic")&&(F-D())*Math.random()>5&&j&&{type:"particle",duration:100*(Math.random()+1),time:e_,size:E/2,color:"red",ethereal:!0};if(V.top_is_lava&&_&&_x.push({..._,x:Q+Math.random()*_e,y:0,vx:(Math.random()-.5)*10,vy:5}),V.left_is_lava&&_&&_x.push({..._,x:Q,y:Math.random()*_t,vx:5,vy:(Math.random()-.5)*10}),V.right_is_lava&&_&&_x.push({..._,x:Q+_e,y:Math.random()*_t,vx:-5,vy:(Math.random()-.5)*10}),V.compound_interest){let e=Z,t=0;do e=Q+_e*Math.random(),t++;while(Math.abs(e-Z){let{x:e,y:t,time:r,color:o,size:l,type:s,duration:a}=_;P.globalAlpha=Math.min(1,2-(e_-r)/a*2),"particle"===s&&_3(P,o,l,e,t)});else if(P.globalCompositeOperation="source-over",P.globalAlpha=1,P.fillStyle="#000",P.fillRect(0,0,e,t),P.globalCompositeOperation="screen",P.globalAlpha=.6,_M.forEach(_=>{_.destroyed||_8(P,_.color,2*E,_.x,_.y)}),_W.forEach(_=>{_8(P,_v,40,_.x,_.y)}),P.globalAlpha=.5,_w.forEach((_,e)=>{if(!_)return;let t=_h(e),r=_b(e);_8(P,"black"==_?"#666":_,_r,t,r)}),P.globalAlpha=1,_x.forEach(_=>{let{x:e,y:t,time:r,color:o,size:l,type:s,duration:a}=_;P.globalAlpha=Math.min(1,2-(e_-r)/a*2),"ball"===s&&_8(P,o,l,e,t),"particle"===s&&_8(P,o,3*l,e,t)}),P.globalAlpha=.2,P.globalCompositeOperation="multiply",P.fillStyle="black",P.fillRect(0,0,e,t),P.globalAlpha=.8,P.globalCompositeOperation="multiply",_.svg&&_l.width&&_l.complete){if(_s.title!==_.name){_s.title=_.name,_s.width=_a,_s.height=_i;let r=_s.getContext("2d");r.fillStyle=_.color||"#000",r.fillRect(0,0,_a,_i);let o=P.createPattern(_l,"repeat");o&&(r.fillStyle=o,r.fillRect(0,0,e,t))}P.drawImage(_s,0,0)}else P.fillStyle="#000",P.fillRect(0,0,e,t);P.globalAlpha=1,P.globalCompositeOperation="source-over";let r=Date.now()-_g+5,i=r<200;if(i){let _=(V.bigger_explosions+1)*50/r;P.translate(Math.sin(Date.now())*_,Math.sin(Date.now()+36)*_)}if(P.globalAlpha=1,_M.forEach(e=>{e.destroyed||(P.globalCompositeOperation="gold"===e.color||_.color?"source-over":"screen",_7(P,e.color,E,e.x,e.y,_.color||"black",e.a))}),ea("basic")||(P.globalCompositeOperation="source-over",P.globalAlpha=Math.min(.8,_M.length/20),_W.forEach(e=>{_3(P,_.color||"#000",120,e.x,e.y)})),P.globalCompositeOperation="source-over",function(){P.globalAlpha=1;let _=F>D()&&V.picky_eater,e=__+"_"+_w.join("_")+$.complete+"_"+_+"_"+_v+"_"+V.pierce_color;if(e!==_4){_4=e,_2.width=__,_2.height=__+1;let t=_2.getContext("2d");t.clearRect(0,0,__,__),t.resetTransform(),t.translate(-K,0),_w.forEach((e,r)=>{let o=_h(r),l=_b(r);if(!e)return;let s=_v!==e&&"black"!==e&&_&&"red"||e;(function(_,e,t,r,o){let l=Math.ceil(r-_r/2),s=Math.ceil(o-_r/2),a=Math.ceil(r+_r/2)-1-l,i=Math.ceil(o+_r/2)-1-s,n="brick"+e+"_"+t+"_"+a+"_"+i;if(!_5[n]){var c,h,b,y,u,m;let _=document.createElement("canvas");_.width=a,_.height=i;let r=_.getContext("2d");r.fillStyle=e,r.strokeStyle=t,r.lineJoin="round",r.lineWidth=2,c=r,h=1,b=1,y=a-2,u=i-2,m=2,c.beginPath(),c.moveTo(3,1),c.lineTo(h+y-m,b),c.quadraticCurveTo(h+y,b,h+y,b+m),c.lineTo(h+y,b+u-m),c.quadraticCurveTo(h+y,b+u,h+y-m,b+u),c.lineTo(h+m,b+u),c.quadraticCurveTo(h,b+u,h,b+u-m),c.lineTo(h,b+m),c.quadraticCurveTo(h,b,h+m,b),c.closePath(),r.fill(),r.stroke(),_5[n]=_}_.drawImage(_5[n],l,s,a,i)})(t,e,s,o,l),"black"===e&&(t.globalCompositeOperation="source-over",function(_,e,t,r,o){let l="svg"+e+"_"+t+"_"+e.complete;if(!_5[l]){let _=document.createElement("canvas");_.width=t,_.height=t;let r=_.getContext("2d"),o=t/Math.max(e.width,e.height),s=e.width*o,a=e.height*o;r.drawImage(e,(t-s)/2,(t-a)/2,s,a),_5[l]=_}_.drawImage(_5[l],Math.round(r-t/2),Math.round(o-t/2))}(t,$,_r,o,l))})}P.drawImage(_2,K,0)}(),P.globalCompositeOperation="screen",(_x=_x.filter(_=>e_-_.time<_.duration&&!_.destroyed)).forEach(_=>{let{x:e,y:t,time:r,color:o,size:l,type:s,duration:a}=_,i=e_-r;P.globalAlpha=Math.max(0,Math.min(1,2-i/a*2)),"text"===s?(P.globalCompositeOperation="source-over",_9(P,_.text,o,l,e,t-i/10)):"particle"===s&&(P.globalCompositeOperation="screen",_3(P,o,l,e,t),_8(P,o,l,e,t))}),V.extra_life){P.globalAlpha=1,P.globalCompositeOperation="source-over",P.fillStyle=T;for(let _=0;_{_3(P,_v,20,_.x,_.y,T),_X(_)&&(P.strokeStyle=T,P.beginPath(),P.bezierCurveTo(Z,_t,Z,_.y,_.x,_.y),P.stroke())}),P.globalAlpha=1,P.globalCompositeOperation="source-over",V.streak_shots&&F>D()&&_6(P,"red",q,20,-2),_6(P,T,q,20),F>1){P.globalCompositeOperation="source-over";let _="x "+F,e=20*_.length/1.8+2*E,t=Z-e/2;eD();P.globalCompositeOperation="source-over",Q?(P.fillStyle=n&&V.left_is_lava?"red":T,P.fillRect(K-1,0,1,t),P.fillStyle=n&&V.right_is_lava?"red":T,P.fillRect(e-K+1,0,1,t)):(P.fillStyle="red",n&&V.left_is_lava&&P.fillRect(0,0,1,t),n&&V.right_is_lava&&P.fillRect(e-1,0,1,t)),V.top_is_lava&&F>D()&&(P.fillStyle="red",P.fillRect(Q,0,_e,1));let c=V.compound_interest&&F>D();P.fillStyle=c?"red":T,ea("mobile-mode")?(P.fillRect(Q,_t,_e,1),j||_9(P,"Press and hold here to play",T,20,_a/2,_t+(_i-_t)/2)):c&&P.fillRect(Q,_t-1,_e,1),i&&P.resetTransform(),ea("record")&&j&&o&&(a&&(a.drawImage(C,Q,0,_e,_t,0,0,s.width,s.height),a.fillStyle="#FFF",a.textBaseline="top",a.font="12px monospace",a.textAlign="right",a.fillText(_m.toString(),s.width-12,12),a.textAlign="left",a.fillText("Level "+(H+1)+"/"+_1(),12,12)),l?.requestFrame?l?.requestFrame():o?.requestFrame&&o.requestFrame())})(),requestAnimationFrame(_),_F=e}();