PageSourceSearch

https://www.funnudge.com/_next/static/chunks/2257.8065e5851072b24a.js

js funnudge.com collected 2026-10-02 01:30:54 UTC 9,663 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2257],{2257:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var n=r(5155),l=r(2115),a=r(2932),o=r(1175),c=r(4107);let i=()=>Array.from({length:6},()=>Array(7).fill(0)),s=e=>{let t=[];for(let r=0;r<7;r++)0===e[0][r]&&t.push(r);return t},u=(e,t)=>{for(let r=5;r>=0;r--)if(0===e[r][t])return r;return -1},d=(e,t)=>{let r=[[0,1],[1,0],[1,1],[1,-1]];for(let n=0;n<6;n++)for(let l=0;l<7;l++)if(e[n][l]===t)for(let[a,o]of r){let r=[[n,l]];for(let c=1;c<4;c++){let i=n+a*c,s=l+o*c;if(i<0||i>=6||s<0||s>=7||e[i][s]!==t)break;r.push([i,s])}if(4===r.length)return r}return null},f=(e,t)=>{let r=2===t?1:2,n=e.filter(e=>e===t).length,l=e.filter(e=>e===r).length,a=e.filter(e=>0===e).length;return 4===n?1e3:3===n&&1===a?12:2===n&&2===a?3:3===l&&1===a?-16:0},h=(e,t,r,n,l)=>{let a=s(e);if(d(e,2))return{col:-1,score:1e5+t};if(d(e,1))return{col:-1,score:-1e5-t};if(0===a.length||0===t)return{col:-1,score:((e,t)=>{let r=0;for(let n=0;n<6;n++)e[n][3]===t&&(r+=4);let n=[];for(let t=0;t<6;t++)for(let r=0;r<7;r++)r+3<7&&n.push([e[t][r],e[t][r+1],e[t][r+2],e[t][r+3]]),t+3<6&&n.push([e[t][r],e[t+1][r],e[t+2][r],e[t+3][r]]),t+3<6&&r+3<7&&n.push([e[t][r],e[t+1][r+1],e[t+2][r+2],e[t+3][r+3]]),t+3<6&&r-3>=0&&n.push([e[t][r],e[t+1][r-1],e[t+2][r-2],e[t+3][r-3]]);for(let e of n)r+=f(e,t);return r})(e,2)};a.sort((e,t)=>Math.abs(3-e)-Math.abs(3-t));let o=l?{col:a[0],score:-1/0}:{col:a[0],score:1/0};for(let c of a){let a=u(e,c);e[a][c]=l?2:1;let i=h(e,t-1,r,n,!l).score;if(e[a][c]=0,l?(i>o.score&&(o={col:c,score:i}),r=Math.max(r,i)):(i<o.score&&(o={col:c,score:i}),n=Math.min(n,i)),n<=r)break}return o};function m(){let e=(0,l.useRef)(null),[t,r]=(0,l.useState)(""),[f,m]=(0,l.useState)(!1),[b,p]=(0,l.useState)("medium"),[g,x]=(0,l.useState)(!1),[w,y]=(0,l.useState)({w:0,l:0,d:0}),S=(0,l.useRef)(i()),k=(0,l.useRef)(1),C=(0,l.useRef)(-1),v=(0,l.useRef)(new Set),M=(0,l.useRef)(null),P=(0,l.useRef)(!1),j=(0,l.useRef)("medium"),N=(0,l.useRef)(!1),R=(0,l.useRef)(0);j.current=b,N.current=f;let A=(0,l.useCallback)(()=>{let t=e.current;if(!t)return;let r=(0,a.c)(t,392,392);if(!r)return;let n=r.createLinearGradient(0,0,0,392);n.addColorStop(0,"#0c1229"),n.addColorStop(1,"#070b1c"),r.fillStyle=n,r.fillRect(0,0,392,392);let l=r.createRadialGradient(196,0,39.2,196,0,352.8);l.addColorStop(0,"rgba(70,110,230,0.22)"),l.addColorStop(1,"rgba(70,110,230,0)"),r.fillStyle=l,r.fillRect(0,0,392,392);let o=function(e,t,n){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:22.400000000000002,a=r.createRadialGradient(e-.35*l,t-.4*l,.1*l,e,t,l);a.addColorStop(0,1===n?"#fca5a5":"#fde68a"),a.addColorStop(.45,1===n?"#ef4444":"#eab308"),a.addColorStop(1,1===n?"#991b1b":"#92400e"),r.fillStyle=a,r.beginPath(),r.arc(e,t,l,0,2*Math.PI),r.fill(),r.strokeStyle="rgba(0,0,0,0.28)",r.lineWidth=2,r.beginPath(),r.arc(e,t,.78*l,0,2*Math.PI),r.stroke(),r.strokeStyle="rgba(0,0,0,0.18)",r.beginPath(),r.arc(e,t,.55*l,0,2*Math.PI),r.stroke(),r.fillStyle="rgba(255,255,255,0.55)",r.beginPath(),r.ellipse(e-.38*l,t-.45*l,.2*l,.12*l,-.6,0,2*Math.PI),r.fill()};!(C.current>=0)||P.current||N.current||(r.globalAlpha=.85,o(56*C.current+28,28,1,17.92),r.globalAlpha=1);let c=M.current;c&&o(56*c.c+28,c.y,c.color);let i=r.createLinearGradient(0,56,0,392);i.addColorStop(0,"#2f66e8"),i.addColorStop(.45,"#2149c4"),i.addColorStop(1,"#142e8f"),r.fillStyle=i,r.beginPath(),r.roundRect(0,56,392,336,12),r.fill(),r.strokeStyle="rgba(150,180,255,0.4)",r.lineWidth=1.5,r.beginPath(),r.roundRect(1,57,390,334,11),r.stroke();let s=r.createLinearGradient(0,56,0,112);s.addColorStop(0,"rgba(200,225,255,0.28)"),s.addColorStop(1,"rgba(200,225,255,0)"),r.fillStyle=s,r.beginPath(),r.roundRect(0,56,392,56,12),r.fill();let u=performance.now()/1e3;for(let e=0;e<6;e++)for(let t=0;t<7;t++){let n=56*t+28,l=56+56*e+28,a=S.current[e][t];if(0===a){let e=t===C.current&&!P.current&&!N.current,a=r.createRadialGradient(n,l-2.8000000000000003,5.6000000000000005,n,l,23.52);a.addColorStop(0,e?"#101c40":"#080e24"),a.addColorStop(.75,e?"#1b2c60":"#131f48"),a.addColorStop(1,"#2c4aa0"),r.fillStyle=a,r.beginPath(),r.arc(n,l,22.400000000000002,0,2*Math.PI),r.fill(),r.strokeStyle="rgba(0,0,0,0.55)",r.lineWidth=2.5,r.beginPath(),r.arc(n,l,22.400000000000002-1,1.1*Math.PI,1.9*Math.PI),r.stroke(),r.strokeStyle="rgba(140,175,255,0.35)",r.lineWidth=1.5,r.beginPath(),r.arc(n,l,22.400000000000002-1,.15*Math.PI,.85*Math.PI),r.stroke()}else o(n,l,a);if(v.current.has("".concat(e,",").concat(t))){let e=.6+.4*Math.sin(5*u);r.strokeStyle="rgba(253,224,71,".concat(e,")"),r.shadowColor="#fde047",r.shadowBlur=14*e,r.lineWidth=4,r.beginPath(),r.arc(n,l,23.52,0,2*Math.PI),r.stroke(),r.shadowBlur=0}}},[]),I=(e,t,r,n)=>{P.current=!0,M.current={c:e,r:t,y:28,vy:6,bounced:!1,color:r};let l=56+56*t+28,a=()=>{let c=M.current;if(c)if(c.vy+=2.4,c.y+=c.vy,c.y>=l){if(!c.bounced&&c.vy>9){c.y=l,c.vy=-(.28*c.vy),c.bounced=!0,(0,o._O)("tap"),requestAnimationFrame(a);return}S.current[t][e]=r,M.current=null,P.current=!1,n()}else requestAnimationFrame(a)};requestAnimationFrame(a)},z=e=>{m(!0),1===e?(r("\uD83C\uDFC6 You win!"),y(e=>({...e,w:e.w+1})),(0,o._O)("win"),(0,c.q7)("connect-four",1)):(2===e?(r("\uD83D\uDC80 The AI wins"),y(e=>({...e,l:e.l+1})),(0,o._O)("lose")):(r("\uD83E\uDD1D Draw!"),y(e=>({...e,d:e.d+1})),(0,o._O)("clear")),(0,c.q7)("connect-four",0))},G=(0,l.useCallback)(()=>
1{S.current=i(),k.current=1,v.current=new Set,M.current=null,P.current=!1,m(!1),r(""),x(!1)},[]);(0,l.useEffect)(()=>{G()},[G]),(0,l.useEffect)(()=>{let e=()=>{A(),R.current=requestAnimationFrame(e)};return R.current=requestAnimationFrame(e),()=>cancelAnimationFrame(R.current)},[A]);let _=t=>{let r=e.current.getBoundingClientRect();return Math.max(0,Math.min(6,Math.floor((t.clientX-r.left)/r.width*392/56)))};return(0,n.jsxs)("div",{className:"select-none",children:[(0,n.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("div",{className:"flex rounded-xl bg-white/10 p-1 text-sm",children:["easy","medium","hard"].map(e=>(0,n.jsx)("button",{onClick:()=>{p(e),G()},className:"rounded-lg px-3 py-1.5 font-semibold capitalize transition ".concat(b===e?"bg-red-500 text-white":"text-zinc-300"),children:e},e))})}),(0,n.jsx)("button",{onClick:G,className:"rounded-xl bg-gradient-to-r from-red-500 to-rose-600 px-4 py-2 font-bold text-white transition hover:scale-105",children:"New Game"})]}),(0,n.jsxs)("div",{className:"mb-3 flex items-center justify-center gap-3 text-sm font-semibold text-zinc-300",children:[(0,n.jsx)("span",{children:f?t:g?"\uD83E\uDD14 AI is thinking…":"\uD83D\uDD34 Your turn — drop a disc"}),(w.w>0||w.l>0||w.d>0)&&(0,n.jsxs)("span",{className:"rounded-full bg-white/10 px-3 py-1 text-xs text-zinc-400",children:[(0,n.jsxs)("span",{className:"text-emerald-300",children:[w.w,"W"]})," \xb7"," ",(0,n.jsxs)("span",{className:"text-rose-300",children:[w.l,"L"]})," \xb7"," ",(0,n.jsxs)("span",{className:"text-zinc-300",children:[w.d,"D"]})]})]}),(0,n.jsxs)("div",{"data-board":!0,className:"relative mx-auto w-full max-w-md overflow-hidden rounded-2xl border border-white/10",children:[(0,n.jsx)("canvas",{ref:e,width:392,height:392,onPointerMove:e=>C.current=_(e),onPointerLeave:()=>C.current=-1,onPointerDown:e=>(e=>{if(P.current||N.current||1!==k.current||0!==S.current[0][e])return;let t=u(S.current,e);k.current=2,I(e,t,1,()=>{let e=d(S.current,1);e?(v.current=new Set(e.map(e=>{let[t,r]=e;return"".concat(t,",").concat(r)})),z(1)):0===s(S.current).length?z(0):(x(!0),setTimeout(()=>{let e,t="easy"===j.current?1:"medium"===j.current?4:6;if("easy"===j.current&&.5>Math.random()){let t=s(S.current);e=t[Math.random()*t.length|0]}else(e=h(S.current,t,-1/0,1/0,!0).col)<0&&(e=s(S.current)[0]);let r=u(S.current,e);I(e,r,2,()=>{x(!1);let e=d(S.current,2);e?(v.current=new Set(e.map(e=>{let[t,r]=e;return"".concat(t,",").concat(r)})),z(2)):0===s(S.current).length?z(0):k.current=1})},380))})})(_(e)),className:"block w-full touch-none",role:"application","aria-label":"Connect Four. Click a column to drop your disc. Get four in a row to win."}),f&&(0,n.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 overflow-hidden bg-black/55 backdrop-blur-[2px]",children:[t.includes("win!")&&Array.from({length:30}).map((e,t)=>(0,n.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute top-0 rounded-sm",style:{left:"".concat(89*t%100,"%"),width:6+t%3*2,height:10+t%4*2,background:["#ef4444","#fbbf24","#34d399","#38bdf8","#fb7185"][t%5],animation:"confetti-fall ".concat(1.5+t%5*.3,"s ease-in ").concat(t%7*.13,"s forwards")}},t)),(0,n.jsx)("p",{className:"animate-bounce-in text-3xl font-extrabold text-white",children:t}),(0,n.jsx)("button",{onClick:G,className:"rounded-xl bg-gradient-to-r from-red-500 to-rose-600 px-6 py-3 font-bold text-white transition hover:scale-105",children:"▶ Play again"})]})]}),(0,n.jsx)("p",{className:"mt-4 text-center text-sm text-zinc-500",children:"\uD83D\uDDB1️ Click a column to drop \xb7 Connect four of your discs in a row — horizontal, vertical, or diagonal — before the AI does"})]})}},2932:(e,t,r)=>{function n(e,t,r){let n=window.devicePixelRatio||1,l=Math.max(1,Math.min((e.clientWidth||t)*n/t,4)),a=Math.round(t*l),o=Math.round(r*l);(e.width!==a||e.height!==o)&&(e.width=a,e.height=o);let c=e.getContext("2d");return c&&c.setTransform(l,0,0,l,0,0),c}function l(e,t,r,n,l){let a=r.getBoundingClientRect(),o=Math.min(a.width/n,a.height/l)||1,c=a.left+(a.width-n*o)/2,i=a.top+(a.height-l*o)/2;return{x:(e-c)/o,y:(t-i)/o}}r.d(t,{c:()=>n,f:()=>l})}}]);

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.