1import{r as a,j as l,v as I}from"./vendor-core-BfsIZGLM.js";import{p as S}from"./main-Cznl0eY3.js";import"./vendor-animation-C5u8yPkK.js";import"./vendor-three-DWQGnPeS.js";var W=(s=>(s.START="START",s.PLAYING="PLAYING",s.PAUSED="PAUSED",s.WON="WON",s.GAMEOVER="GAMEOVER",s.LOADING_LEVEL="LOADING_LEVEL",s))(W||{});const X=120,N=4,o=6,A=250,g=4.5,k=15e-5,P=14,_=({className:s})=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"12 6 12 12 16 14"})]}),y=({className:s})=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[l.jsx("path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6"}),l.jsx("path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18"}),l.jsx("path",{d:"M4 22h16"}),l.jsx("path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"}),l.jsx("path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"}),l.jsx("path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z"})]}),V=()=>{const s=a.useRef(null),L=a.useRef(null),[u,p]=a.useState("START"),[b,m]=a.useState(0),[R,x]=a.useState(0),[j,T]=a.useState({width:0,height:0}),t=a.useRef({paddleX:0,paddleWidth:X,ballX:0,ballY:0,ballDX:g,ballDY:-g,score:0,survivalStart:0,width:0,height:0,status:"START"});a.useEffect(()=>{t.current.status=u},[u]);const v=a.useCallback(()=>{if(!s.current)return;const{clientWidth:r,clientHeight:n}=s.current;T({width:r,height:n}),t.current.width=r,t.current.height=n,t.current.ballX===0&&t.current.ballY===0&&r>0&&n>0&&(t.current.paddleX=r/2-X/2,t.current.ballX=r/2,t.current.ballY=n/2),t.current.paddleX+t.current.paddleWidth>r&&(t.current.paddleX=Math.max(0,r-t.current.paddleWidth))},[]);a.useEffect(()=>{if(!s.current)return;const r=new ResizeObserver(()=>{v()});return r.observe(s.current),v(),()=>r.disconnect()},[v]);const Y=()=>{const{width:r,height:n}=t.current;t.current.ballX=r/2,t.current.ballY=n/2;const d=g;t.current.ballDX=d*(Math.random()>.5?1:-1),t.current.ballDY=-d,t.current.paddleX=r/2-t.current.paddleWidth/2,t.current.paddleWidth=X};a.useEffect(()=>{const r=setTimeout(()=>{t.current.width>0&&t.current.height>0&&(Y(),t.current.score=0,t.current.survivalStart=Date.now(),m(0),x(0),p("PLAYING"),S("Brackets"))},100);return()=>clearTimeout(r)},[]),a.useEffect(()=>{if(u==="GAMEOVER"){const r=setTimeout(()=>{Y(),t.current.score=0,t.current.survivalStart=Date.now(),m(0),x(0),p("PLAYING")},2e3);return()=>clearTimeout(r)}},[u]);const E=a.useCallback(r=>{const n=t.current.paddleWidth,d=t.current.width;let i=r.clientX-n/2;i<0&&(i=0),i+n>d&&(i=d-n),t.current.paddleX=i},[]),w=a.useCallback(r=>{if(r.touches.length===0)return;const n=t.current.paddleWidth,d=t.current.width;let i=r.touches[0].clientX-n/2;i<0&&(i=0),i+n>d&&(i=d-n),t.current.paddleX=i},[]);a.useEffect(()=>(window.addEventListener("mousemove",E),window.addEventListener("touchmove",w,{passive:!0}),()=>{window.removeEventListener("mousemove",E),window.removeEventListener("touchmove",w)}),[E,w]),a.useEffect(()=>{let r;const n=()=>{const e=t.current;if(e.status!=="PLAYING")return;const c=Math.floor((Date.now()-e.survivalStart)/1e3);if(x(c),Math.floor(e.score)!==b&&m(Math.floor(e.score)),Math.sqrt(e.ballDX**2+e.ballDY**2)<P){const f=1+k;e.ballDX*=f,e.ballDY*=f}e.ballX+=e.ballDX,e.ballY+=e.ballDY,(e.ballX+o>e.width||e.ballX-o<0)&&(e.ballDX=-e.ballDX,e.ballX=e.ballX<o?o:e.width-o),e.ballY-o<0&&(e.ballDY=-e.ballDY,e.ballY=o);const D=e.height-A;if(e.ballY+o>D&&e.ballY-o<D+N&&e.ballX>e.paddleX&&e.ballX<e.paddleX+e.paddleWidth&&e.ballDY>0){e.ballDY=-e.ballDY,e.ballY=D-o;const f=e.ballX-(e.paddleX+e.paddleWidth/2);e.ballDX+=f*.12,e.paddleWidth=Math.max(40,e.paddleWidth-.5),e.score+=50}e.ballY-o>e.height-A+20&&p("GAMEOVER")},d=()=>{const e=L.current?.getContext("2d");if(!e)return;const c=t.current,h=c.height-A;e.fillStyle="rgba(0, 0, 0, 0.0)",e.fillRect(0,0,c.width,c.height),e.clearRect(0,0,c.width,c.height),e.beginPath(),e.moveTo(0,h+40),e.lineTo(c.width,h+40),e.stroke(),e.fillStyle="#fff",e.fillRect(c.paddleX,h,c.paddleWidth,N),e.beginPath(),e.arc(c.ballX,c.ballY,o,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.closePath()},i=()=>{n(),d(),r=requestAnimationFrame(i)};return i(),()=>cancelAnimationFrame(r)},[b]);const M=u==="GAMEOVER";return l.jsxs("div",{ref:s,className:"w-full h-full bg-transparent overflow-hidden select-none cursor-crosshair",children:[l.jsx("canvas",{ref:L,width:j.width,height:j.height,className:"flex"}
1),l.jsxs("div",{className:"absolute bottom-[136px] left-0 right-0 flex flex-col items-center pointer-events-none",children:[l.jsxs("div",{className:"flex justify-center items-center space-x-6 mb-4 tabular-nums",children:[l.jsxs("div",{className:"flex justify-center items-center space-x-1.5",children:[l.jsx(_,{className:"w-5 h-5 text-[#4275F4]"}),l.jsxs("span",{className:"text-[18px] font-medium text-white tracking-[-0.36px]",children:[R,"s"]})]}),l.jsxs("div",{className:"flex justify-center items-center space-x-1.5",children:[l.jsx(y,{className:"w-5 h-5 text-[#34A853]"}),l.jsx("span",{className:"text-[18px] font-medium text-white tracking-[-0.36px]",children:String(Math.floor(b)).padStart(6,"0")})]})]}),l.jsx("div",{className:"text-[#9BA0A6] font-medium",children:M?"Restarting...":I.isMobile?"Drag to steer":"Move mouse to steer"})]}),M&&l.jsx("div",{className:"absolute inset-0 pointer-events-none bg-gradient-to-t from-black via-black/20 to-transparent transition-opacity duration-700"})]})};export{W as GameStatus,V as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.