PageSourceSearch

https://ordd.io/assets/trivia-browse-63TfCf6U.js

js ordd.io collected 2026-10-10 02:20:25 UTC 9,465 bytes, 1 lines download raw bytes

1import{r,j as e}from"./vendor-query-BRciFQuE.js";import{c1 as P,b8 as k,aE as F}from"./index-DNKTWqBG.js";import{Shell as E,Header as L,CHOICE_LETTERS as B,CountdownBar as R}from"./trivia-display-zpV9S56u.js";import{L as _}from"./log-in-D8SDyuOh.js";import{C as A}from"./chevron-right-DMgvFPqO.js";import{P as q}from"./play-DXht3AAO.js";import{L as H}from"./lightbulb-DQExAEBc.js";import"./vendor-react-Kr73Scym.js";import"./use-guest-account-DQHZgCUB.js";import"./chat-client-DhCI3xB6.js";import"./guest-api-DKjznIit.js";import"./chat-terms-LEZsgxum.js";import"./html-escape-BJTSIi2w.js";import"./guest-upload-path-B-2VxZZ0.js";import"./guest-session-B3mHI9Jf.js";const U=3e4,V=1e4,T={easy:"Easy",medium:"Medium",hard:"Hard"};function z(a){return a.format==="multiple_choice"&&a.choices&&a.correctIndex!=null?a.choices[a.correctIndex]??"":a.answerText??""}function O({deck:a,questions:d,mode:o,auto:g,onExit:w}){const[u,$]=r.useState(()=>({index:1,phase:"question",done:!1,startedAt:Date.now()})),{index:m,phase:x,done:j}=u,i=d[m-1],y=m>=d.length,p=x==="question"?U:V,S=()=>$(n=>{if(n.done)return n;const l={startedAt:Date.now(),done:!1};return n.phase==="question"?{...n,...l,phase:"reveal"}:n.index>=d.length?{...n,done:!0}:{index:n.index+1,phase:"question",...l}});r.useEffect(()=>{if(!g||j)return;const n=Math.max(0,u.startedAt+p-Date.now()),l=setTimeout(S,n);return()=>clearTimeout(l)},[g,j,m,x,u.startedAt]);const N=e.jsx("button",{onClick:w,"aria-label":"Exit game",className:"absolute right-4 top-4 z-20 rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20",children:e.jsx(F,{className:"h-5 w-5"})});if(j)return e.jsxs("div",{className:"relative",children:[N,e.jsx(E,{header:e.jsx(L,{title:a.title,subtitle:"Thanks for playing!"}),children:e.jsxs("div",{className:"space-y-6 text-center",children:[e.jsx("p",{className:"text-6xl",children:"🎉"}),e.jsx("p",{className:"text-4xl font-bold text-white md:text-5xl",children:"That's a wrap!"}),e.jsxs("p",{className:"text-xl text-white/60",children:[d.length," questions · ",a.theme]}),e.jsx("button",{onClick:w,className:"rounded-full bg-white/10 px-6 py-3 text-lg text-white hover:bg-white/20",children:"Back to games"})]})})]});const b=x==="reveal",h=o==="choices"&&i.format==="multiple_choice"&&i.choices;return e.jsxs("div",{className:"relative",children:[N,e.jsx(E,{header:e.jsxs(e.Fragment,{children:[e.jsx(L,{title:a.title,subtitle:`Question ${m} of ${d.length}${T[i.difficulty]?` · ${T[i.difficulty]}`:""}`}),g&&e.jsx(R,{remainingMs:Math.max(0,u.startedAt+p-Date.now()),totalMs:p,phase:x},`${m}-${x}`)]}),children:e.jsxs("div",{className:"flex w-full max-w-5xl flex-col gap-8 pb-24",children:[e.jsx("p",{className:"text-center text-3xl font-semibold leading-snug text-white md:text-5xl",children:i.prompt}),i.imageUrl&&e.jsx("img",{src:i.imageUrl,alt:"",className:"mx-auto max-h-[35vh] rounded-xl object-contain"}),h?e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:i.choices.map((n,l)=>{const f=b&&l===i.correctIndex,C=b&&!f;
1return e.jsxs("div",{className:`flex items-center gap-4 rounded-2xl border-2 p-5 text-xl transition-all duration-500 md:text-2xl ${f?"scale-[1.02] border-emerald-400 bg-emerald-500/20 text-white":C?"border-white/10 bg-white/5 text-white/30":"border-white/20 bg-white/10 text-white"}`,children:[e.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-full text-lg font-bold ${f?"bg-emerald-400 text-emerald-950":"bg-white/15 text-white/80"}`,children:B[l]??l+1}),e.jsx("span",{children:n})]},l)})}):b?e.jsx("p",{className:"text-center text-4xl font-bold text-emerald-300 md:text-5xl",children:z(i)}):e.jsx("p",{className:"text-center text-2xl text-white/50",children:"Shout it out…"}),b&&i.funFact&&e.jsxs("p",{className:"mx-auto flex max-w-3xl items-start gap-2 text-center text-xl text-amber-200/90 md:text-2xl",children:[e.jsx(H,{className:"mt-1 h-6 w-6 shrink-0"}),e.jsx("span",{children:i.funFact})]})]})}),e.jsx("div",{className:"fixed inset-x-0 bottom-6 z-10 flex justify-center px-4",children:e.jsxs("button",{onClick:S,"data-testid":"button-runner-next",className:"flex items-center gap-2 rounded-full bg-amber-400 px-8 py-4 text-lg font-semibold text-amber-950 shadow-lg hover:bg-amber-300",children:[x==="question"?"Reveal answer":y?"Finish":"Next question",e.jsx(A,{className:"h-5 w-5"})]})})]})}function re({deckId:a}={}){const[,d]=P(),[o,g]=r.useState(null),[w,u]=r.useState(""),[$,m]=r.useState(!1),[x,j]=r.useState(""),[i,y]=r.useState(null),[p,S]=r.useState("choices"),[N,b]=r.useState(!1),[h,n]=r.useState(null),[l,f]=r.useState(!1);r.useEffect(()=>{const t=k();if(!t){m(!0);return}fetch(`/api/trivia/venues/${t}/decks`).then(s=>s.ok?s.json():Promise.reject(new Error(String(s.status)))).then(g).catch(()=>m(!0)),fetch(`/api/establishments/subdomain/${t}`).then(s=>s.ok?s.json():null).then(s=>(s==null?void 0:s.name)&&u(s.name)).catch(()=>{})},[]),r.useEffect(()=>{if(!a||!o)return;const t=o.find(s=>s.id===a);t&&y(t)},[a,o]);const C=!!(a&&o&&!o.some(t=>t.id===a)),D=a&&o?o.filter(t=>t.id===a):o,M=async t=>{f(!0);try{const s=k(),c=await fetch(`/api/trivia/venues/${s}/decks/${t.id}/questions`);if(!c.ok)throw new Error(String(c.status));const v=await c.json();n({deck:t,questions:v.questions,mode:p,auto:N})}catch{m(!0)}finally{f(!1)}};return h?e.jsx(O,{deck:h.deck,questions:h.questions,mode:h.mode,auto:h.auto,onExit:()=>n(null)}):e.jsx(E,{header:e.jsx(L,{title:w?e.jsxs(e.Fragment,{children:["Trivia ",e.jsx("span",{className:"text-amber-300",children:"@"})," ",w]}):"Trivia",subtitle:a?"Play it on this screen":"Pick a game and play it on this screen"}),children:e.jsxs("div",{className:"w-full max-w-2xl space-y-4",children:[e.jsxs("form",{className:"flex items-center gap-3 rounded-2xl border-2 border-white/15 bg-white/5 p-4",onSubmit:t=>{t.preventDefault();const s=x.trim().toUpperCase();/^[A-Z0-9]{5}$/.test(s)&&!["DISPL","PLAYS"].includes(s)&&d(`/trivia/${s}`)},children:[e.jsx("label",{htmlFor:"trivia-join-code",className:"shrink-0 text-white/70",children:"Have a game code?"}),e.jsx("input",{id:"trivia-join-code",value:x,onChange:t=>j(t.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,8)),placeholder:"MKVMP",autoComplete:"off",autoCapitalize:"characters",className:"w-32 min-w-0 flex-1 rounded-xl border-2 border-white/20 bg-transparent px-3 py-2 font-mono text-xl uppercase tracking-[0.25em] text-amber-300 placeholder:text-white/60 focus:border-amber-300 focus:outline-none","data-testid":"input-join-code"}),e.jsxs("button",{type:"submit",disabled:x.trim().length!==5,className:"flex items-center gap-2 rounded-xl bg-amber-400 px-5 py-2.5 font-semibold text-amber-950 hover:bg-amber-300 disabled:opacity-40","data-testid":"button-join-code",children:[e.jsx(_,{className:"h-4 w-4"})," Join"]})]}),$?e.jsx("p",{className:"text-center text-xl text-white/60",children:"No trivia games here right now."}):o?C?e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("p",{className:"text-xl text-white/60",children:"That game isn’t available right now."}),e.jsx("button",{onClick:()=>d("/trivia"),className:"rounded-xl bg-amber-400 px-6 py-3 font-semibold text-amber-950 hover:bg-amber-300","data-testid":"button-browse-all",children:"See all games"})]}):o.length===0?e.jsx("p",{className:"text-center text-xl text-white/60",children:"No games are ready yet — check back soon!"}):(D??[]).map(t=>{const s=(i==null?void 0:i.id)===t.id;return e.jsxs("div",{className:`rounded-2xl border-2 p-5 transition-colors ${s?"border-amber-300 bg-white/10":"border-white/15 bg-white/5"}`,children:[e.jsxs("button",{className:"flex w-full items-center justify-between text-left",onClick:()=>y(s?null:t),"data-testid":`deck-${t.id}`,children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-2xl font-semibold text-white",children:t.title}),e.jsxs("span",{className:"text-sm text-white/50",children:[t.theme," · ",t.approvedCount," questions"]})]}),e.jsx(A,{className:`h-6 w-6 text-white/40 transition-transform ${s?"rotate-90":""}`})]}),s&&e.jsxs("div",{className:"mt-5 space-y-4 border-t border-white/10 pt-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[["choices","Show A/B/C/D choices"],["shout","Shout out (hide choices)"]].map(([c,v])=>e.jsx("button",{onClick:()=>S(c),className:`rounded-full px-4 py-2 text-sm ${p===c?"bg-amber-400 font-semibold text-amber-950":"bg-white/10 text-white/70 hover:bg-white/20"}`,children:v},c))}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[[!1,"I press Next"],[!0,"Run automatically (30s / 10s)"]].map(([c,v])=>e.jsx("button",{onClick:()=>b(c),className:`rounded-full px-4 py-2 text-sm ${N===c?"bg-amber-400 font-semibold text-amber-950":"bg-white/10 text-white/70 hover:bg-white/20"}`,children:v},String(c)))}),e.jsxs("button",{onClick:()=>M(t),disabled:l,"data-testid":`play-${t.id}`,className:"flex w-full items-center justify-center gap-2 rounded-xl bg-amber-400 px-6 py-3 text-lg font-semibold text-amber-950 hover:bg-amber-300 disabled:opacity-60",children:[e.jsx(q,{className:"h-5 w-5"})," Play — one time through"]})]})]},t.id)}):e.jsx("p",{className:"animate-pulse text-center text-xl text-white/50",children:"Loading games…"}),a&&!C&&e.jsx("button",{onClick:()=>d("/trivia"),className:"w-full rounded-xl border-2 border-white/15 px-6 py-3 text-white/60 hover:border-white/30 hover:text-white/80","data-testid":"button-browse-all",children:"See all games"})]})})}export{re as default};

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.