1import{j as n}from"./index-ypIK7kjN.js";import{a as l}from"./redux-vendor-BfV9BRyV.js";import{g as P}from"./games-CN0AgIzC.js";import{u as U}from"./react-vendor-DKynGxiw.js";const V="_wordleGameContainer_1j6t2_1",Y="_gameBackBtn_1j6t2_7",Z="_wordleHeader_1j6t2_24",z="_wordleStats_1j6t2_42",F="_wordleStat_1j6t2_42",J="_statLabel_1j6t2_57",Q="_statValue_1j6t2_63",X="_btnNewGame_1j6t2_69",q="_wordleBoard_1j6t2_86",I="_wordleRow_1j6t2_94",ee="_wordleTile_1j6t2_100",te="_filled_1j6t2_114",se="_pop_1j6t2_1",re="_correct_1j6t2_119",oe="_flip_1j6t2_1",ae="_present_1j6t2_126",ne="_absent_1j6t2_133",ce="_shake_1j6t2_164",le="_wordleMessage_1j6t2_188",ie="_success_1j6t2_196",de="_error_1j6t2_200",ue="_info_1j6t2_204",we="_wordleKeyboard_1j6t2_208",_e="_keyboardRow_1j6t2_213",me="_key_1j6t2_213",fe="_keyLarge_1j6t2_243",r={wordleGameContainer:V,gameBackBtn:Y,wordleHeader:Z,wordleStats:z,wordleStat:F,statLabel:J,statValue:Q,btnNewGame:X,wordleBoard:q,wordleRow:I,wordleTile:ee,filled:te,pop:se,correct:re,flip:oe,present:ae,absent:ne,shake:ce,wordleMessage:le,success:ie,error:de,info:ue,wordleKeyboard:we,keyboardRow:_e,key:me,keyLarge:fe},f=6,w=5,pe=[["Q","W","E","R","T","Y","U","I","O","P"],["A","S","D","F","G","H","J","K","L"],["ENTER","Z","X","C","V","B","N","M","â«"]],he=()=>Array.from({length:f},()=>Array.from({length:w},()=>""));function be(){const M=U(),[p,K]=l.useState(""),[N,x]=l.useState([]),[O,G]=l.useState([]),[u,h]=l.useState(""),[i,R]=l.useState(0),[j,y]=l.useState(!1),[k,g]=l.useState({text:"",type:""}),[W,E]=l.useState(null),[$,B]=l.useState({}),_=l.useRef(null),A=l.useMemo(()=>{const e=he();return N.forEach((s,t)=>{s.split("").forEach((a,c)=>{e[t][c]=a})}),i<f&&u.split("").forEach((s,t)=>{e[i][t]=s}),e},[N,u,i]),d=l.useCallback((e,s)=>{_.current&&window.clearTimeout(_.current),g({text:e,type:s}),s!=="info"&&(_.current=window.setTimeout(()=>{g({text:"",type:""})},3e3))},[]),D=l.useCallback((e,s)=>{B(t=>{const a={...t};return e.split("").forEach((c,o)=>{const m=s[o],T=a[c];m==="correct"?a[c]="correct":m==="present"?T!=="correct"&&(a[c]="present"):T||(a[c]="absent")}),a})},[]),H=(e,s)=>{const t=Array.from({length:w},()=>"absent"),a=s.split(""),c=e.split("");for(let o=0;o<w;o+=1)c[o]===a[o]&&(t[o]="correct",a[o]="",c[o]="");for(let o=0;o<w;o+=1)if(c[o]){const m=a.indexOf(c[o]);m!==-1&&(t[o]="present",a[m]="")}return t},b=l.useCallback(async()=>{g({text:"",type:""}),y(!1),x([]),G([]),h(""),R(0),B({}),d("Loading word...","info");try{const s=((await P(5)).word??"").toString().toUpperCase();if(!s||s.length!==5){d("Error: Invalid word length","error");return}K(s),g({text:"",type:""})}catch{d("Unable to load word. Please try again.","error")}},[d]);l.useEffect(()=>(b(),()=>{_.current&&window.clearTimeout(_.current)}),[b]);const C=e=>{j||u.length<w&&h(s=>s+e)},L=()=>{j||h(e=>e.slice(0,-1))},v=()=>{if(j)return;if(u.length!==w){d("Word must be 5 letters","error"),E(i),window.setTimeout(()=>E(null),500);return}const e=u.toUpperCase(),s=H(e,p);x(t=>[...t,e]),G(t=>[...t,s]),D(e,s),e===p?(d(["Genius!","Magnificent!","Impressive!","Splendid!","Great!","Phew!"][i]||"You won!","success"),y(!0)):i===f-1?(d(`The word was: ${p}`,"error"),y(!0)):(R(t=>t+1),h(""))},S=l.useCallback(e=>{e.key.length===1&&/[a-zA-Z]/.test(e.key)?(C(e.key.toUpperCase()),e.preventDefault()):e.key==="Enter"?(v(),e.preventDefault()):e.key==="Backspace"&&(L(),e.preventDefault())},[u,j,i,p]);return l.useEffect(()=>(window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)),[S]),n.jsxs("section",{className:r.wordleGameContainer,children:[n.jsx("button",{type:"button",className:r.gameBackBtn,onClick:()=>M("/games"),children:"â Back to Games"}),n.jsxs("div",{className:r.wordleHeader,children:[n.jsx("h1",{children:"ð Manuscriptle"}),n.jsx("p",{children:"Guess the 5-letter word in 6 tries"}),n.jsxs("div",{className:r.wordleStats,children:[n.jsxs("div",{className:r.wordleStat,children:[n.jsx("span",{className:r.statLabel,children:"Guesses:"}),n.jsxs("span",{className:r.statValue,children:[Math.min(i,f),"/",f]})]}),n.jsx("div",{className:r.wordleStat,children:n.jsx("button",{type:"button",className:r.btnNewGame,onClick:b,children:"New Game"})})]})]}),n.jsx("div",{className:r.wordleBoard,children:A.map((e,s)=>n.jsx("div",{className:r.wordleRow,children:e.map((t,a)=>{const c=O[s]?.[a],o=[r.wordleTile,t?r.filled:"",c?r[c]:"",W===s?r.shake:""].filter(
1Boolean).join(" ");return n.jsx("div",{className:o,"data-row":s,"data-col":a,children:t},`tile-${s}-${a}`)})},`row-${s}`))}),n.jsx("div",{className:`${r.wordleMessage} ${k.type?r[k.type]:""}`,id:"wordle-message",children:k.text}),n.jsx("div",{className:r.wordleKeyboard,children:pe.map((e,s)=>n.jsx("div",{className:r.keyboardRow,children:e.map(t=>{const a=t==="ENTER"||t==="â«",c=$[t],o=[r.key,a?r.keyLarge:"",c?r[c]:""].filter(Boolean).join(" ");return n.jsx("button",{type:"button",className:o,"data-key":t,onClick:()=>{t==="ENTER"?v():t==="â«"?L():C(t)},children:t},t)})},`kb-row-${s}`))})]})}export{be as ManuscriptlePage};
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.