1import{j as e}from"./index-ypIK7kjN.js";import{a as r}from"./redux-vendor-BfV9BRyV.js";import{e as te}from"./games-CN0AgIzC.js";import{u as ie}from"./react-vendor-DKynGxiw.js";const re="_mindreaderGameContainer_1qj6f_1",ae="_gameBackBtn_1qj6f_7",oe="_mindreaderHeader_1qj6f_24",ce="_mindreaderStats_1qj6f_42",de="_mindreaderStat_1qj6f_42",le="_statLabel_1qj6f_57",ue="_statValue_1qj6f_62",me="_mindreaderScreen_1qj6f_68",fe="_mindreaderWelcomeContent_1qj6f_79",he="_mindreaderSuccessContent_1qj6f_80",ye="_mindreaderFailureContent_1qj6f_81",ge="_mindreaderIconLarge_1qj6f_86",je="_mindreaderInstructions_1qj6f_111",_e="_mindreaderQuestionArea_1qj6f_138",xe="_mindreaderQuestionText_1qj6f_143",ke="_mindreaderAnswerButtons_1qj6f_155",Ne="_btnYes_1qj6f_161",pe="_btnNo_1qj6f_162",Ae="_mindreaderAiThinking_1qj6f_197",Se="_thinkingAnimation_1qj6f_202",qe="_thinkingDot_1qj6f_209",be="_mindreaderGuessContent_1qj6f_240",Ie="_mindreaderGuessTitle_1qj6f_245",Ce="_mindreaderGuessButtons_1qj6f_256",Te="_successIcon_1qj6f_263",ve="_failureIcon_1qj6f_264",Ge="_mindreaderSuccessTitle_1qj6f_286",t={mindreaderGameContainer:re,gameBackBtn:ae,mindreaderHeader:oe,mindreaderStats:ce,mindreaderStat:de,statLabel:le,statValue:ue,mindreaderScreen:me,mindreaderWelcomeContent:fe,mindreaderSuccessContent:he,mindreaderFailureContent:ye,mindreaderIconLarge:ge,mindreaderInstructions:je,mindreaderQuestionArea:_e,mindreaderQuestionText:xe,mindreaderAnswerButtons:ke,btnYes:Ne,btnNo:pe,mindreaderAiThinking:Ae,thinkingAnimation:Se,thinkingDot:qe,mindreaderGuessContent:be,mindreaderGuessTitle:Ie,mindreaderGuessButtons:Ce,successIcon:Te,failureIcon:ve,mindreaderSuccessTitle:Ge},A=20,Ye={year:"Year Range",category:"Category",region:"Region",year_refine:"Year Refine",ai:"AI Guessing"};function Le(){const Y=ie(),[g,u]=r.useState("welcome"),[L,d]=r.useState("Is the manuscript from after 1750?"),[j,B]=r.useState(0),[m,_]=r.useState("year"),[a,o]=r.useState(null),[f,x]=r.useState(null),[h,S]=r.useState(null),[q,y]=r.useState([]),[k,M]=r.useState([]),[w,R]=r.useState(null),[$,N]=r.useState(!1),[E,Q]=r.useState(""),b=r.useRef(null),U=Ye[m]??"Year",J=`${Math.min(j+1,A)}/${A}`,H=()=>{b.current&&(window.clearTimeout(b.current),b.current=null)},O=()=>{H(),b.current=window.setTimeout(()=>{N(!1),d("Sorry, the AI is taking too long to respond. Click Yes to try again, or No to skip.")},45e3)},l=(n,s)=>{d(`Is the manuscript from ${s} ${n}?`)},I=n=>{d(`Is it in the '${n}' category?`)},D=n=>{d(`Is this manuscript about the ${n}?`)},p=()=>{_("category"),I("Political History")},C=()=>{_("region"),D("Americas")},F=()=>{_("year_refine"),X()},X=()=>{if(!a||a.length<2){v();return}const[n,s]=a,i=s-n;if(i<=25){v();return}const c=n+Math.floor(i/2);d(`Is the manuscript from after ${c}?`)},T=r.useCallback(async n=>{N(!0),O();const s=await te({...n,yearRange:n.yearRange??void 0,category:n.category??void 0,region:n.region??void 0});H(),N(!1),s.isGuess?(Q(s.guessTitle||"Unknown Manuscript"),u("guess")):s.question&&(R(s.question),y(i=>[...i,{role:"assistant",content:s.question??""}]),d(s.question))},[]),v=(n=j)=>{_("ai");const s=[];a?.length===2&&s.push(`The manuscript is from the year range ${a[0]}-${a[1]}.`),f&&s.push(`The manuscript is in the category: ${f}.`),h&&s.push(`The manuscript is from the region: ${h}.`);const i=s.length>0?[{role:"user",content:`Just to confirm what we know so far: ${s.join(" ")}`}]:[],c=[...q,...i];y(c),T({questionCount:n,yearRange:a,category:f,region:h,conversationHistory:c,aiQAPairs:k})},z=(n,s,i)=>{if(s===1){l(n==="yes"?1850:1500,"after");return}if(s===2){i.includes("1850")?l(n==="yes"?1900:1800,"after"):i.includes("1500")&&l(n==="yes"?1650:1200,"after");return}if(s===3){i.includes("1900")?n==="yes"?l(1950,"after"):(o([1850,1900]),p()):i.includes("1800")?(o(n==="yes"?[1800,1850]:[1750,1800]),p()):i.includes("1650")?(o(n==="yes"?[1650,1750]:[1500,1650]),p()):i.includes("1200")&&(o(n==="yes"?[1200,1500]:[0,1200]),p());return}s===4&&i.includes("1950")&&(o(n==="yes"?[1950,2e3]:[1900,1950]),p())},K=(n,s)=>{if(s.includes("Political History")){n==="yes"?(x("Political History"),C()):d("Is it in the Science or Exploration category?");return}
1if(s.includes("Science or Exploration")){I(n==="yes"?"Science":"Music & Art");return}if(s.includes("Science")&&!s.includes("Science or Exploration")){x(n==="yes"?"Science":"Exploration"),C();return}if(s.includes("Music & Art")){n==="yes"?(x("Music & Art"),C()):I("Literature");return}s.includes("Literature")&&(x(n==="yes"?"Literature":"Religion"),C())},Z=(n,s)=>{if(s.includes("Americas")){n==="yes"?(S("Americas"),F()):D("Europe");return}s.includes("Europe")&&(S(n==="yes"?"Europe":"Asia/Africa"),F())},ee=(n,s)=>{if(!a||a.length<2){v(s);return}const[i,c]=a,G=i+Math.floor((c-i)/2);o(n==="yes"?[G,c]:[i,G]),v(s)},ne=async(n,s)=>{if(s>=A){u("failure");return}if(s>=A-1){y(G=>[...G,{role:"user",content:n==="yes"?"Yes":"No"}]),await T({questionCount:s,yearRange:a,category:f,region:h,conversationHistory:[...q,{role:"user",content:n==="yes"?"Yes":"No"}],aiQAPairs:k,forceGuess:!0});return}const i=[...q,{role:"user",content:n==="yes"?"Yes":"No"}],c=w!=null?[...k,{question:w,answer:n}]:k;y(i),M(c),R(null),await T({questionCount:s,yearRange:a,category:f,region:h,conversationHistory:i,aiQAPairs:c})},V=async n=>{const s=L,i=j+1;B(i),m==="year"?z(n,i,s):m==="category"?K(n,s):m==="region"?Z(n,s):m==="year_refine"?ee(n,i):m==="ai"&&await ne(n,i)},P=()=>{B(0),_("year"),o(null),x(null),S(null),y([]),M([]),R(null),Q(""),N(!1),H(),d("Is the manuscript from after 1750?"),u("question")},W=async n=>{if(n){u("success");return}const s=j+1;if(B(s),s>=A){u("failure");return}u("question"),N(!0);const i=[...q,{role:"user",content:"No, that's not correct. Please continue asking questions."}];y(i),await T({questionCount:s,yearRange:a,category:f,region:h,conversationHistory:i,aiQAPairs:k})},se=`I guessed it in ${j+1} questions!`;return e.jsxs("section",{className:t.mindreaderGameContainer,children:[e.jsx("button",{type:"button",className:t.gameBackBtn,onClick:()=>Y("/games"),children:"â Back to Games"}),e.jsxs("div",{className:t.mindreaderHeader,children:[e.jsx("h1",{children:"ð® Manuscript Mindreader"}),e.jsx("p",{children:"Think of a manuscript and I'll try to guess it in 20 questions!"}),e.jsxs("div",{className:t.mindreaderStats,children:[e.jsxs("div",{className:t.mindreaderStat,children:[e.jsx("span",{className:t.statLabel,children:"Questions:"}),e.jsx("span",{className:t.statValue,children:J})]}),e.jsxs("div",{className:t.mindreaderStat,children:[e.jsx("span",{className:t.statLabel,children:"Phase:"}),e.jsx("span",{className:t.statValue,children:U})]})]})]}),g==="welcome"&&e.jsx("div",{className:t.mindreaderScreen,children:e.jsxs("div",{className:t.mindreaderWelcomeContent,children:[e.jsx("div",{className:t.mindreaderIconLarge,children:"ð®"}),e.jsx("h2",{children:"Ready to Play?"}),e.jsx("p",{children:"Think of any manuscript from the collection, and I'll try to guess it!"}),e.jsxs("div",{className:t.mindreaderInstructions,children:[e.jsx("h3",{children:"How it works:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"I'll ask you yes/no questions about the manuscript you're thinking of"}),e.jsx("li",{children:"First, I'll narrow down the time period (1-4 questions)"}),e.jsx("li",{children:"Then I'll ask about the category (1-2 questions)"}),e.jsx("li",{children:"Finally, AI takes over to guess your manuscript!"})]})]}),e.jsx("button",{type:"button",className:"btn-primary btn-large",onClick:P,children:"Start Game"})]})}),g==="question"&&e.jsxs("div",{className:t.mindreaderScreen,children:[e.jsxs("div",{className:t.mindreaderQuestionArea,style:{display:$?"none":"block"},children:[e.jsx("div",{className:t.mindreaderQuestionText,children:L}),e.jsxs("div",{className:t.mindreaderAnswerButtons,children:[e.jsx("button",{type:"button",className:t.btnYes,onClick:()=>V("yes"),children:"â Yes"}),e.jsx("button",{type:"button",className:t.btnNo,onClick:()=>V("no"),children:"â No"})]})]}),e.jsxs("div",{className:t.mindreaderAiThinking,style:{display:$?"block":"none"},children:[e.jsxs("div",{className:t.thinkingAnimation,children:[e.jsx("div",{className:t.thinkingDot}),e.jsx("div",{className:t.thinkingDot}),e.jsx("div",{className:t.thinkingDot})]}),e.jsx("p",{children:"AI is thinking..."})]})]}),g==="guess"&&e.jsx("div",{className:t.mindreaderScreen,children:e.jsxs("div",{className:t.mindreaderGuessContent,children:[e.jsx("h2",{children:"I think I know it!"}),e.jsx("div",{className:t.mindreaderGuessTitle,children:E}),e.jsx("p",{children:"Is this the manuscript you were thinking of?"}),e.jsxs("div",{className:t.mindreaderGuessButtons,children:[e.jsx("button",{type:"button",className:t.btnYes,onClick:()=>W(!0),children:"â Yes, that's it!"}),e.jsx("button",{type:"button",className:t.btnNo,onClick:()=>W(!1),children:"â No, keep trying"})]})]})}),g==="success"&&e.jsx("div",{className:t.mindreaderScreen,children:e.jsxs("div",{className:t.mindreaderSuccessContent,children:[e.jsx("div",{className:t.
1successIcon,children:"ð"}),e.jsx("h2",{children:"I guessed it!"}),e.jsx("div",{className:t.mindreaderSuccessTitle,children:E}),e.jsx("p",{children:se}),e.jsx("button",{type:"button",className:"btn-primary",onClick:P,children:"Play Again"}),e.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>Y("/games"),children:"Back to Games"})]})}),g==="failure"&&e.jsx("div",{className:t.mindreaderScreen,children:e.jsxs("div",{className:t.mindreaderFailureContent,children:[e.jsx("div",{className:t.failureIcon,children:"ð"}),e.jsx("h2",{children:"I couldn't guess it!"}),e.jsx("p",{children:"You stumped me! What manuscript were you thinking of?"}),e.jsx("div",{className:t.mindreaderCorrectAnswer}),e.jsx("button",{type:"button",className:"btn-primary",onClick:P,children:"Play Again"}),e.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>Y("/games"),children:"Back to Games"})]})})]})}export{Le as ManuscriptMindreaderPage};
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.