1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2078],{98:(e,t,n)=>{n.d(t,{EB:()=>c,ER:()=>d,cC:()=>s,sD:()=>h});var o=n(7548),a=n(2006),r=n(3464),l=n(6170),i=n(6451);function s(e,t){var n,s,d,c,h;let u=new o.Z58,m=new o.ubm(null!=(n=null==t?void 0:t.fov)?n:60,4/3,.1,500),w=new o.JeP({antialias:!0});w.setPixelRatio(Math.min(window.devicePixelRatio||1,1.5)),w.setClearColor(null!=(s=null==t?void 0:t.clear)?s:657940),(null==t?void 0:t.shadows)&&(w.shadowMap.enabled=!0,w.shadowMap.type=o.Wk7);let f=w.domElement;f.style.width="100%",f.style.height="100%",f.style.display="block",e.appendChild(f);let p=null;(null==t?void 0:t.bloom)&&((p=new a.s(w)).addPass(new l.A(u,m)),p.addPass(new i.C(new o.I9Y(256,256),null!=(d=t.bloom.strength)?d:.5,null!=(c=t.bloom.radius)?c:.5,null!=(h=t.bloom.threshold)?h:.7)),p.addPass(new r.X));let x=()=>{let t=e.clientWidth||1,n=e.clientHeight||1;w.setSize(t,n,!1),p&&(p.setPixelRatio(w.getPixelRatio()),p.setSize(t,n)),m.aspect=t/n,m.updateProjectionMatrix()};x();let v=new ResizeObserver(x);return v.observe(e),{scene:u,camera:m,renderer:w,render:()=>{p?p.render():w.render(u,m)},dispose:()=>{v.disconnect(),null==p||p.dispose(),u.traverse(e=>{e.geometry&&e.geometry.dispose();let t=e.material;Array.isArray(t)?t.forEach(e=>
1e.dispose()):null==t||t.dispose()}),w.dispose(),f.parentElement===e&&e.removeChild(f)}}}function d(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,l=document.createElement("canvas");l.width=e,l.height=t,n(l.getContext("2d"),e,t);let i=new o.GOR(l);return i.colorSpace=o.er$,i.wrapS=o.GJx,i.wrapT=o.GJx,i.repeat.set(a,r),i.anisotropy=4,i}function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#808080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:26;return d(e,e,o=>{o.fillStyle=t,o.fillRect(0,0,e,e);for(let t=0;t<e*e*.35;t++){let t=128+Math.floor((Math.random()-.5)*2*n);o.fillStyle="rgb(".concat(t,",").concat(t,",").concat(t,")"),o.fillRect(Math.random()*e,Math.random()*e,1.5,1.5)}})}function h(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0xffffff,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.6,r=new Float32Array(3*e);for(let n=0;n<e;n++){let e=t*(.5+.5*Math.random()),o=Math.random()*Math.PI*2,a=(Math.random()-.5)*Math.PI;r[3*n]=Math.cos(o)*Math.cos(a)*e,r[3*n+1]=Math.sin(a)*e,r[3*n+2]=Math.sin(o)*Math.cos(a)*e}let l=new o.LoY;l.setAttribute("position",new o.THS(r,3));let i=new o.BH$({color:n,size:a,sizeAttenuation:!0,transparent:!0,opacity:.8,blending:o.EZo,depthWrite:!1});return new o.ONl(l,i)}},2078:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h});var o=n(5155),a=n(2115),r=n(7548),l=n(1175),i=n(4107),s=n(98),d=n(3557),c=n(2773);function h(){let e=(0,a.useRef)(null),[t,n]=(0,a.useState)("idle");(0,c.GL)("running"===t);let[h,u]=(0,a.useState)(0),[m,w]=(0,a.useState)([]),{best:f,submit:p}=(0,d.g)("snake-3d"),x=(0,a.useRef)(t),v=(0,a.useRef)(0),g=(0,a.useRef)(()=>{}),M=(0,a.useRef)(0);x.current=t;let b=(e,t)=>{let n=++M.current;w(o=>[...o.slice(-2),{id:n,text:e,cls:t}]),window.setTimeout(()=>{w(e=>e.filter(e=>e.id!==n))},1200)},y=(0,a.useRef)(b);return y.current=b,(0,a.useEffect)(()=>{let t=e.current;if(!t)return;let o=(0,s.cC)(t,{fov:50,clear:725536,shadows:!0}),{scene:a,camera:d}=o;a.background=new r.Q1f(725536),a.add(new r.dth(0xbfe6ff,1056792,.85));let c=new r.ZyN(0xffffff,1.2);c.position.set(6,16,8),c.castShadow=!0,c.shadow.mapSize.set(1024,1024),c.shadow.camera.left=-12,c.shadow.camera.right=12,c.shadow.camera.top=12,c.shadow.camera.bottom=-12,c.shadow.camera.far=50,a.add(c);let h=e=>(e-7)*1,m=(0,s.ER)(360,360,(e,t)=>{let n=t/15;for(let t=0;t<15;t++)for(let o=0;o<15;o++){e.fillStyle=(t+o)%2==0?"#2a5c33":"#24512c",e.fillRect(t*n,o*n,n,n);for(let a=0;a<6;a++){e.strokeStyle=.5>Math.random()?"rgba(120,190,110,0.35)":"rgba(30,70,35,0.4)",e.lineWidth=1;let a=t*n+Math.random()*n,r=o*n+Math.random()*n;e.beginPath(),e.moveTo(a,r),e.lineTo(a+(Math.random()-.5)*3,r-3-3*Math.random()),e.stroke()}e.strokeStyle="rgba(0,0,0,0.12)",e.strokeRect(t*n+.5,o*n+.5,n-1,n-1)}}),w=new r.eaF(new r.bdM(15,15),new r._4j({map:m,roughness:1}));w.rotation.x=-Math.PI/2,w.receiveShadow=!0,a.add(w);let f=new r.GOR((()=>{let e=document.createElement("canvas");e.width=8,e.height=256;let t=e.getContext("2d"),n=t.createLinearGradient(0,0,0,256);return n.addColorStop(0,"#214a86"),n.addColorStop(.55,"#6aa6d8"),n.addColorStop(1,"#cfe6f0"),t.fillStyle=n,t.fillRect(0,0,8,256),e})());f.colorSpace=r.er$,a.add(new r.eaF(new r.Gu$(120,24,16),new r.V9B({map:f,side:r.hsX,fog:!1}))),a.fog=new r.jUj(0x9ec4dd,30,75);let M=(0,s.ER)(256,256,(e,t,n)=>{e.fillStyle="#5a9a48",e.fillRect(0,0,t,n);for(let o=0;o<7e3;o++)e.fillStyle=Math.random()>.5?"rgba(100,170,80,0.5)":"rgba(45,105,48,0.5)",e.fillRect(Math.random()*t,Math.random()*n,2,2)},8,8),b=new r.eaF(new r.bdM(120,120),new r._4j({map:M,roughness:1}));b.rotation.x=-Math.PI/2,b.position.y=-.08,b.receiveShadow=!0,a.add(b);let z=new r._4j({color:9080726,roughness:.95}),S=new r.nEu(.4,0),j=8,k=(e,t)=>{let n=new r.eaF(S,z),o=.5+.5*Math.random();n.scale.set(o,.7*o,o),n.position.set(e+(Math.random()-.5)*.25,.16*o,t+(Math.random()-.5)*.25),n.rotation.set(3*Math.random(),3*Math.random(),3*Math.random()),n.castShadow=!0,n.receiveShadow=!0,a.add(n)};for(let e=0;e<=15;e++){let t=-7.5+ +e;k(t,-j),k(t,j),k(-j,t),k(j,t)}let E=new r._4j({color:4160826,roughness:1}),N=new r.qFE(.2,.7,4);for(let e=0;e<44;e++){let e=Math.random()*Math.PI*2,t=9.1+16*Math.random(),n=new r.eaF(N,E);n.position.set(Math.cos(e)*t,.32,Math.sin(e)*t),n.castShadow=!0,a.add(n)}let F=new r._4j({color:7029795}),_=new r._4j({color:3112250,roughness:1});for(let e=0;e<8;e++){let e=Math.random()*Math.PI*2,t=13.5+12*Math.random(),n=new r.YJl,o=new r.eaF(new r.Ho_(.2,.28,1.6,7),F);o.position.y=.8,o.castShadow=!0,n.add(o);let l=new r.eaF(new r.qFE(1.1,2.6,9),_);l.position.y=2.5,l.castShadow=!0,n.add(l),n.position.set(Math.cos(e)*t,0,Math.sin(e)*t),a.add(n)}let R=new r.YJl,D=new r.eaF(new r.Gu$(.34,18,16),new r._4j({color:0xe23b3b,emissive:5902095,emissiveIntensity:.35,roughness:.35}));D.scale.y=.94,D.castShadow=!0;let C=new r.eaF(new r.Ho_(.03,.04,.18,6),new r._4j({color:7029795,roughness:.9}));C.position.y=.38,C.rotation.z=.25;let A=new r.eaF(new r.tcD(.12,8),new r._4j({color:4169018,roughness:.8,side:r.$EB}));A.position.set(.1,.42,0),A.rotation.set(-.9,0,.5),A.scale.set(1.4,.8,1),R.add(D,C,A),a.add(R);let P=1,L=new r.Gu$(.46,16,14),G=new r._4j({color:2278750,roughness:.5}),I=new r._4j({color:1483594,roughness:.55}),Y=new r._4j({color:8843180,roughness:.4,emissive:1332013,emissiveIntensity:.3}),$=new r.V9B({color:0xdc2626}),q=new r.iNn(.035,.02,.3),B=new r.YJl,J=new r.eaF(q,$);J.position.set(-.03,0,.17),J.rotation.y=.18;let O=new r.eaF(q,$);O.position.set(.03,0,.17),O.rotation.y=-.18,B.add(J,O),B.visible=!1,a.add(B);let T=new r.Zpd(.15),W=[],H=0,V=(e,t,n,o,l)=>{for(let i=0;i<l;i++){let l=new r.eaF(T,new r.V9B({color:o,transparent:!0}));l.position.set(e,t,n),l.rotation.set(3*Math.random(),3*Math.random(),3*Math.random()),a.add(l);let i=new r.Pq0(Math.random()-.5,.8*Math.random(),Math.random()-.5).normalize();W.push({mesh:l,vel:i.multiplyScalar(3+4*Math.random()),t:0})}},X=new r.tcD(.16,8),Z=[0xf9a8d4,0xc4b5fd,0xfef08a].map(e=>new r._4j({color:e,roughness:.8,side:r.$EB})),U=[];for(let e=0;e<3;e++){let t=new r.YJl,n=new r.eaF(X,Z[e]);n.position.x=-.09;let o=new r.eaF(X,Z[e]);o.position.x=.09,t.add(n,o),U.push({g:t,wl:n,wr:o,r:10+5*Math.random(),sp:.12+.1*Math.random(),off:6.28*Math.random()}),a.add(t)}let Q=new r._4j({color:0xffffff,roughness:.25}),K=new r._4j({color:657930}),ee=()=>{let e=new r.YJl;e.add(new r.eaF(new r.Gu$(.13,12,12),Q));let t=new r.eaF(new r.Gu$(.07,10,10),K);return t.position.z=.09,e.add(t),e.visible=!1,a.add(e),e},et=ee(),en=ee(),eo=[],ea=[],er=[],el={x:1,z:0},ei={x:1,z:0},es={x:0,z:0},ed=0,ec=.2,eh=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.38;return e.position.set(h(t.x),n,h(t.z))},eu=(e,t)=>
1{let n=-el.z,o=el.x;et.visible=en.visible=!0,et.position.set(e+.26*el.x+.18*n,.62,t+.26*el.z+.18*o),en.position.set(e+.26*el.x-.18*n,.62,t+.26*el.z-.18*o);let a=Math.atan2(el.x,el.z);et.rotation.y=a,en.rotation.y=a},em=()=>{let e,t=new Set(eo.map(e=>"".concat(e.x,",").concat(e.z)));do e={x:Math.floor(15*Math.random()),z:Math.floor(15*Math.random())};while(t.has("".concat(e.x,",").concat(e.z)));es=e,eh(R,e,.4),P=0},ew=()=>{for(let e of er)a.remove(e);er=[];let e=Math.floor(7.5);for(let t of(el={x:1,z:0},ei={x:1,z:0},ec=.2,ed=0,(eo=[{x:e,z:e},{x:e-1,z:e},{x:e-2,z:e}]).forEach((e,t)=>{let n=new r.eaF(L,0===t?Y:G);n.castShadow=!0,n.receiveShadow=!0,eh(n,e),a.add(n),er.push(n)}),ea=eo.slice(),em(),eu(h(eo[0].x),h(eo[0].z)),W))a.remove(t.mesh),t.mesh.material.dispose();W=[],v.current=0,u(0),n("running")};g.current=ew;let ef=()=>{ea=eo.slice(),el=ei;let e=eo[0],t={x:e.x+el.x,z:e.z+el.z};if(t.x<0||t.x>=15||t.z<0||t.z>=15||eo.some(e=>e.x===t.x&&e.z===t.z)){(0,l._O)("explode");let e=er[0];e&&V(e.position.x,.5,e.position.z,2278750,18),H=.45,n("over"),p(v.current),(0,i.q7)("snake-3d",v.current);return}eo.unshift(t);let o=new r.eaF(L,Y);if(o.castShadow=!0,o.receiveShadow=!0,eh(o,t),a.add(o),er.unshift(o),t.x===es.x&&t.z===es.z)v.current+=1,u(v.current),p(v.current),(0,i.q7)("snake-3d",v.current),ec=Math.max(.075,.2-.004*v.current),V(R.position.x,.5,R.position.z,0xef4444,10),v.current%10==0?(y.current("\uD83D\uDC0D ".concat(v.current,"!"),"text-amber-300"),(0,l._O)("clear")):(0,l._O)("eat"),em();else{eo.pop();let e=er.pop();e&&a.remove(e)}},ep=(e,t)=>{"running"===x.current&&(e!==-el.x||t!==-el.z)&&(ei={x:e,z:t})},ex=0,ev=performance.now(),eg=1e3/60,eM=e=>{var t,n,l,i,s,c,u,m,w;ex=requestAnimationFrame(eM);let f=e-ev;if(f<eg-1)return;let p=Math.min(f/1e3,.05);if(ev=e,"running"===x.current){for(ed+=p;ed>=ec&&(ed-=ec,ef(),"running"===x.current););let t=Math.min(1,ed/ec);for(let n=0;n<er.length;n++){let o=eo[n],a=null!=(s=ea[n])?s:o,l=r.cj9.lerp(h(a.x),h(o.x),t),i=r.cj9.lerp(h(a.z),h(o.z),t),d=0===n?1.06:1-Math.min(.4,n/Math.max(6,er.length)*.4);er[n].position.set(l,.36+(n?.025*Math.sin(e/160+.85*n):0),i),er[n].scale.set(d,.88*d,d),er[n].material=0===n?Y:n%2?I:G}let n=null!=(c=null==(l=er[0])?void 0:l.position.x)?c:0,o=null!=(u=null==(i=er[0])?void 0:i.position.z)?u:0;eu(n,o);let a=e/1e3%1.7<.22;B.visible=a,a&&(B.position.set(n+.5*el.x,.42,o+.5*el.z),B.rotation.y=Math.atan2(el.x,el.z))}else B.visible=!1;for(let t of(P=Math.min(1,P+4*p),R.scale.setScalar(.2+.8*P),R.position.y=.4+.08*Math.sin(e/220),R.rotation.y+=2*p,U)){let n=e/1e3*t.sp+t.off,o=t.r+1.2*Math.sin(e/700+t.off);t.g.position.set(Math.cos(n)*o,.9+.4*Math.sin(e/500+t.off),Math.sin(n)*o),t.g.rotation.y=-n;let a=.85*Math.sin(e/55+t.off);t.wl.rotation.y=a,t.wr.rotation.y=-a}W=W.filter(e=>(e.t+=p,e.mesh.position.addScaledVector(e.vel,p),e.vel.y-=8*p,e.mesh.rotation.x+=6*p,e.mesh.material.opacity=Math.max(0,1-e.t/.8),!(e.t>=.8)||(a.remove(e.mesh),e.mesh.material.dispose(),!1)));let v=null!=(m=null==(t=er[0])?void 0:t.position.x)?m:0,g=null!=(w=null==(n=er[0])?void 0:n.position.z)?w:0;d.position.set(.08*v,13.8,15.600000000000001),H>.002&&(d.position.x+=(Math.random()-.5)*H,d.position.y+=(Math.random()-.5)*H,H*=Math.exp(-(5*p))),d.lookAt(.14*v,-.5,.1*g-1),o.render()};ex=requestAnimationFrame(eM);let eb=()=>{cancelAnimationFrame(ex),document.hidden||(ev=performance.now(),ex=requestAnimationFrame(eM))};document.addEventListener("visibilitychange",eb);let ey=e=>{"ArrowUp"===e.key||"w"===e.key?ep(0,-1):"ArrowDown"===e.key||"s"===e.key?ep(0,1):"ArrowLeft"===e.key||"a"===e.key?ep(-1,0):"ArrowRight"===e.key||"d"===e.key?ep(1,0):("Space"===e.code||"Enter"===e.key)&&"running"!==x.current&&(e.preventDefault(),ew()),e.key.startsWith("Arrow")&&e.preventDefault()};window.addEventListener("keydown",ey);let ez=0,eS=0,ej=e=>{ez=e.clientX,eS=e.clientY,"running"!==x.current&&ew()},ek=e=>{let t=e.clientX-ez,n=e.clientY-eS;18>Math.abs(t)&&18>Math.abs(n)||(Math.abs(t)>Math.abs(n)?ep(t>0?1:-1,0):ep(0,n>0?1:-1))};return t.addEventListener("pointerdown",ej),t.addEventListener("pointerup",ek),()=>{cancelAnimationFrame(ex),document.removeEventListener("visibilitychange",eb),window.removeEventListener("keydown",ey),t.removeEventListener("pointerdown",ej),t.removeEventListener("pointerup",ek),m.dispose(),M.dispose(),f.dispose(),L.dispose(),T.dispose(),q.dispose(),X.dispose(),o.dispose()}},[]),(0,o.jsxs)("div",{className:"select-none",children:[(0,o.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[(0,o.jsxs)("div",{className:"flex gap-2",children:[(0,o.jsxs)("div",{className:"rounded-xl bg-white/10 px-4 py-2 text-center",children:[(0,o.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Length"}),(0,o.jsx)("div",{className:"text-xl font-bold text-white",children:h})]}),(0,o.jsxs)("div",{className:"rounded-xl bg-white/10 px-4 py-2 text-center",children:[(0,o.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Best"}),(0,o.jsx)("div",{className:"text-xl font-bold text-amber-300",children:f})]})]}),(0,o.jsx)("button",{onClick:()=>g.current(),className:"rounded-xl bg-gradient-to-r from-green-500 to-emerald-600 px-4 py-2 font-bold text-white transition hover:scale-105",children:"running"===t?"Restart":"Start"})]}),(0,o.jsxs)("div",{"data-board":!0,ref:e,className:"relative mx-auto aspect-square w-full touch-none overflow-hidden rounded-2xl border border-white/10 sm:aspect-[4/3]",style:{maxWidth:"min(100%, calc(82vh * 1.333))"},role:"application","aria-label":"3D Snake. Use arrow keys or swipe to steer; eat the food and avoid the walls and yourself.",children:[(0,o.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-[16%] z-10 flex flex-col items-center gap-1",children:m.map(e=>(0,o.jsx)("div",{className:"animate-bounce-in text-xl font-extrabold drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)] sm:text-2xl ".concat(e.cls),children:e.text},e.id))}),"running"!==t&&(0,o.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 bg-black/55 backdrop-blur-[2px]",children:["over"===t?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"animate-bounce-in text-3xl font-extrabold text-white",children:"\uD83D\uDC0D Game over!"}),(0,o.jsxs)("p",{className:"text-zinc-200",children:["Length: ",(0,o.jsx)("span",{className:"font-bold text-white",children:h}),h>0&&h>=f&&(0,o.jsx)("span",{className:"ml-2 font-bold text-amber-300",children:"New best
1!"})]})]}):(0,o.jsx)("p",{className:"text-5xl","aria-hidden":!0,children:"\uD83D\uDC0D"}),(0,o.jsx)("button",{onClick:e=>{e.stopPropagation(),g.current()},className:"rounded-xl bg-gradient-to-r from-green-500 to-emerald-600 px-6 py-3 font-bold text-white transition hover:scale-105",children:"over"===t?"Slither again":"â¶ Start"})]})]}),(0,o.jsx)("p",{className:"mt-4 text-center text-sm text-zinc-500",children:"â¨ï¸ Arrow keys / \uD83D\uDDB1ï¸ swipe to steer \xb7 Eat the food, grow longer, don't bite yourself"})]})}},2773:(e,t,n)=>{n.d(t,{GL:()=>c,Gp:()=>i,Nc:()=>l,_y:()=>s,mA:()=>d});var o=n(2115);let a=null,r=new Set;function l(e){if(a!==e)for(let t of(a=e,r))t(e)}function i(e){return r.add(e),()=>r.delete(e)}let s={title:"Leave this game?",body:"You're mid-game â your progress in this round will be lost."},d={title:"Leave the match?",body:"The match is still live â leaving counts as a loss and your opponent takes the win."};function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s,{title:n,body:a}=t;(0,o.useEffect)(()=>e?(l({title:n,body:a}),()=>l(null)):void l(null),[e,n,a])}},3557:(e,t,n)=>{n.d(t,{g:()=>a});var o=n(2115);function a(e){let[t,n]=(0,o.useState)(0);return(0,o.useEffect)(()=>{try{let t=window.localStorage.getItem("funnudge:".concat(e));t&&n(Number(t)||0)}catch(e){}},[e]),{best:t,submit:(0,o.useCallback)(t=>{n(n=>{if(t<=n)return n;try{window.localStorage.setItem("funnudge:".concat(e),String(t))}catch(e){}return t})},[e])}}}}]);
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.