PageSourceSearch

https://www.funnudge.com/_next/static/chunks/4929.688407ab0866fbf5.js

js funnudge.com collected 2026-10-02 01:31:14 UTC 8,455 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4929],{3557:(e,t,r)=>{r.d(t,{g:()=>l});var a=r(2115);function l(e){let[t,r]=(0,a.useState)(0);return(0,a.useEffect)(()=>{try{let t=window.localStorage.getItem("funnudge:".concat(e));t&&r(Number(t)||0)}catch(e){}},[e]),{best:t,submit:(0,a.useCallback)(t=>{r(r=>{if(t<=r)return r;try{window.localStorage.setItem("funnudge:".concat(e),String(t))}catch(e){}return t})},[e])}}},4929:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var a=r(5155),l=r(2115),n=r(9636),s=r(8213),i=r(1175),o=r(4107),c=r(3557);let d=1;function u(e){return e.filter(e=>!e.dying)}function x(e){let t=new Set(u(e).map(e=>"".concat(e.r,",").concat(e.c))),r=[];for(let e=0;e<4;e++)for(let a=0;a<4;a++)t.has("".concat(e,",").concat(a))||r.push({r:e,c:a});if(0===r.length)return e;let a=r[Math.floor(Math.random()*r.length)];return[...e,{id:d++,value:.9>Math.random()?2:4,r:a.r,c:a.c,justSpawned:!0}]}let h={2:"bg-zinc-200 text-zinc-800",4:"bg-amber-100 text-amber-900",8:"bg-amber-300 text-amber-950",16:"bg-orange-400 text-white",32:"bg-orange-500 text-white",64:"bg-rose-500 text-white",128:"bg-yellow-400 text-yellow-950 shadow-lg shadow-yellow-400/40",256:"bg-yellow-500 text-white shadow-lg shadow-yellow-500/40",512:"bg-fuchsia-500 text-white shadow-lg shadow-fuchsia-500/40",1024:"bg-violet-500 text-white shadow-lg shadow-violet-500/50",2048:"bg-gradient-to-br from-fuchsia-500 to-violet-600 text-white shadow-xl shadow-fuchsia-500/60"};function m(){let[e,t]=(0,l.useState)([]),[r,d]=(0,l.useState)(0),[m,f]=(0,l.useState)(!1),[g,b]=(0,l.useState)(!1),[w,p]=(0,l.useState)(!1),{best:v,submit:j}=(0,c.g)("2048"),[N,y]=(0,l.useState)(!1),S=(0,l.useRef)(null),k=(0,l.useRef)(null),M=(0,l.useRef)(null),[_,z]=(0,l.useState)([]),[C,E]=(0,l.useState)([]),T=(0,l.useRef)(0),A=(0,l.useRef)(0);(0,l.useEffect)(()=>(t(x(x([]))),()=>{k.current&&clearTimeout(k.current)}),[]);let D=(0,l.useCallback)(a=>{if(m)return;let{next:l,gained:c,moved:h}=function(e,t){let r="left"===t||"right"===t,a="right"===t||"down"===t,l=[],n=0,s=!1;for(let t=0;t<4;t++){let i=u(e).filter(e=>(r?e.r:e.c)===t).sort((e,t)=>r?e.c-t.c:e.r-t.r);a&&i.reverse();let o=0;for(let e=0;e<i.length;e++){let c=i[e],d=i[e+1],u=a?3-o:o,x=r?t:u,h=r?u:t;d&&d.value===c.value?(n+=2*c.value,s=!0,l.push({...c,r:x,c:h,value:2*c.value,justMerged:!0,justSpawned:!1}),l.push({...d,r:x,c:h,dying:!0,justSpawned:!1}),e++):((c.r!==x||c.c!==h)&&(s=!0),l.push({...c,r:x,c:h,justMerged:!1,justSpawned:!1})),o++}}return{next:l,gained:n,moved:s}}(e,a);if(!h)return;M.current={tiles:u(e).map(e=>({...e,justSpawned:!1,justMerged:!1})),score:r},y(!0);let w=x(l);t(w),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{t(e=>e.filter(e=>!e.dying))},170);let p=r+c;if(d(p),j(p),c>0){(0,i._O)("merge");let e=++T.current;z(t=>[...t.slice(-2),{id:e,val:c}]),setTimeout(()=>z(t=>t.filter(t=>t.id!==e)),800)}let v=Math.max(0,...w.filter(e=>!e.dying).map(e=>e.value));if(v>A.current&&(A.current=v,v>=128&&v<2048)){var N="✨ ".concat(v,"!");let e=++T.current;E(t=>[...t.slice(-1),{id:e,text:N,cls:"text-amber-300"}]),setTimeout(()=>E(t=>t.filter(t=>t.id!==e)),1200),(0,i._O)("clear")}!g&&w.some(e=>!e.dying&&e.value>=2048)&&(b(!0),(0,i._O)("win"),(0,s.Q)(),(0,n.Tl)("tile-2048")),!function(e){let t=u(e);if(t.length<16)return!0;let r=Array.from({length:4},()=>[,,,,].fill(0));for(let e of t)r[e.r][e.c]=e.value;for(let e=0;e<4;e++)for(let t=0;t<4;t++)if(t+1<4&&r[e][t]===r[e][t+1]||e+1<4&&r[e][t]===r[e+1][t])return!0;return!1}(w)&&(f(!0),(0,i._O)("lose"),(0,o.q7)("2048",p))},[e,r,m,g,j]);(0,l.useEffect)(()=>{let e=e=>{let t={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",a:"left",d:"right",w:"up",s:"down"}[e.key];t&&(e.preventDefault(),D(t))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D]);let R=()=>{t(x(x([]))),d(0),f(!1),b(!1),p(!1),M.current=null,y(!1),A.current=0,z([]),E([])};return(0,a.jsxs)("div",{className:"select-none",children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"relative rounded-xl bg-white/10 px-4 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Score"}),(0,a.jsx)("div",{className:"text-xl font-bold text-white",children:r}),_.map(e=>(0,a.jsxs)("span",{className:"animate-bounce-in pointer-events-none absolute -top-4 left-1/2 -translate-x-1/2 text-sm font-extrabold text-amber-300 drop-shadow",children:["+",e.val]}
1,e.id))]}),(0,a.jsxs)("div",{className:"rounded-xl bg-white/10 px-4 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Best"}),(0,a.jsx)("div",{className:"text-xl font-bold text-amber-300",children:v})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:()=>{let e=M.current;e&&(t(e.tiles),d(e.score),f(!1),M.current=null,y(!1),(0,i._O)("tap"))},disabled:!N,className:"rounded-xl bg-white/10 px-4 py-2 font-bold text-zinc-200 transition hover:bg-white/20 disabled:cursor-not-allowed disabled:opacity-40",children:"↩ Undo"}),(0,a.jsx)("button",{onClick:R,className:"rounded-xl bg-gradient-to-r from-amber-500 to-orange-500 px-4 py-2 font-bold text-white transition hover:scale-105",children:"New Game"})]})]}),(0,a.jsxs)("div",{className:"relative mx-auto aspect-square w-full max-w-md touch-none rounded-2xl bg-black/40 p-2 sm:p-3",onTouchStart:e=>{S.current={x:e.touches[0].clientX,y:e.touches[0].clientY}},onTouchEnd:e=>{if(!S.current)return;let t=e.changedTouches[0].clientX-S.current.x,r=e.changedTouches[0].clientY-S.current.y;S.current=null,30>Math.max(Math.abs(t),Math.abs(r))||(Math.abs(t)>Math.abs(r)?D(t>0?"right":"left"):D(r>0?"down":"up"))},role:"application","aria-label":"2048 game board. Use arrow keys to move tiles.",children:[(0,a.jsx)("div",{className:"grid h-full grid-cols-4 grid-rows-4 gap-2 sm:gap-3",children:Array.from({length:16}).map((e,t)=>(0,a.jsx)("div",{className:"rounded-lg bg-white/5"},t))}),(0,a.jsx)("div",{className:"absolute inset-2 sm:inset-3",children:e.map(e=>{var t;return(0,a.jsx)("div",{className:"absolute h-1/4 w-1/4 p-1 transition-transform duration-150 ease-out sm:p-1.5",style:{transform:"translate(".concat(100*e.c,"%, ").concat(100*e.r,"%)"),zIndex:e.dying?1:2},children:(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center rounded-lg text-xl font-extrabold sm:text-2xl ".concat(null!=(t=h[e.value])?t:"bg-violet-700 text-white"," ").concat(e.value>=1e3?"text-base sm:text-xl":""," ").concat(e.justSpawned||e.justMerged?"animate-pop":""),children:e.value})},e.id)})}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-[10%] z-10 flex flex-col items-center gap-1",children:C.map(e=>(0,a.jsx)("div",{className:"animate-bounce-in text-2xl font-extrabold drop-shadow-[0_2px_6px_rgba(0,0,0,0.8)] ".concat(e.cls),children:e.text},e.id))}),(m||g&&!w)&&(0,a.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 roun
1ded-2xl bg-black/75 backdrop-blur-sm",children:[(0,a.jsx)("p",{className:"animate-bounce-in text-3xl font-extrabold text-white",children:g&&!m?"\uD83C\uDF89 You made 2048!":"\uD83D\uDC80 Game over"}),(0,a.jsxs)("p",{className:"text-zinc-300",children:["Score: ",(0,a.jsx)("span",{className:"font-bold text-white",children:r}),A.current>=8&&(0,a.jsxs)("span",{className:"ml-2 text-zinc-400",children:["\xb7 Biggest tile"," ",(0,a.jsx)("span",{className:"font-bold text-amber-300",children:A.current})]}),r>0&&r>=v&&(0,a.jsx)("span",{className:"ml-2 font-bold text-amber-300",children:"New best!"})]}),(0,a.jsxs)("div",{className:"flex gap-3",children:[g&&!m&&(0,a.jsx)("button",{onClick:()=>p(!0),className:"rounded-xl border border-white/30 bg-white/10 px-5 py-2.5 font-bold text-white transition hover:bg-white/20",children:"Keep going"}),(0,a.jsx)("button",{onClick:R,className:"rounded-xl bg-gradient-to-r from-amber-500 to-orange-500 px-5 py-2.5 font-bold text-white transition hover:scale-105",children:"Play again"})]})]})]}),(0,a.jsx)("p",{className:"mt-4 text-center text-sm text-zinc-500",children:"⌨️ Arrow keys / WASD \xb7 \uD83D\uDCF1 Swipe to move"})]})}},8213:(e,t,r)=>{r.d(t,{P:()=>a,Q:()=>l});let a="funnudge:celebrate";function l(){try{window.dispatchEvent(new CustomEvent(a))}catch(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.