const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WhatToWatchQuiz-DUst72b4.css"])))=>i.map(i=>d[i]);
import{_ as C}from"./vendor-supabase-yzuDJZPy.js";import{j as e}from"./vendor-ui-CUslpDkL.js";import{r as u,L as O}from"./vendor-react-Dg0Tra3e.js";import{u as k}from"./vendor-query-CN1EccJz.js";import{c as D,z as G,E as L,s as F}from"./index-CJqEbhJN.js";import{m as r,A as P}from"./vendor-motion-CiNtJfg1.js";import{P as H}from"./play-Cs8ErDIS.js";/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const E=D("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),W=()=>C(()=>Promise.resolve({}),__vite__mapDeps([0])),p=[{id:"mood",title:"WHAT MOOD ARE YOU IN?",options:[{id:"escape",label:"I Need to Escape Reality",value:"fantasy"},{id:"feel",label:"I Want to Feel Something",value:"emotional"},{id:"think",label:"I Want to Think",value:"cerebral"},{id:"pump",label:"I Need a Rush",value:"hype"}]},{id:"setting",title:"CHOOSE YOUR WORLD",options:[{id:"fantasy",label:"Magic & Fantasy",value:"fantasy"},{id:"scifi",label:"Sci-Fi & Mecha",value:"scifi"},{id:"modern",label:"Modern Day",value:"modern"},{id:"historical",label:"Historical",value:"historical"}]},{id:"tone",title:"SELECT ATMOSPHERE",options:[{id:"dark",label:"Dark & Gritty",value:"dark"},{id:"balanced",label:"Balanced Mix",value:"balanced"},{id:"light",label:"Light & Fun",value:"light"}]},{id:"protagonist",title:"YOUR IDEAL PROTAGONIST",options:[{id:"underdog",label:"The Underdog",value:"underdog"},{id:"antihero",label:"Morally Gray",value:"antihero"},{id:"hero",label:"Classic Hero",value:"hero"},{id:"ensemble",label:"Ensemble Cast",value:"ensemble"}]},{id:"pacing",title:"PREFERRED PACING",options:[{id:"fast",label:"Non-Stop Action",value:"fast"},{id:"medium",label:"Steady Build",value:"medium"},{id:"slow",label:"Slow Burn",value:"slow"}]},{id:"theme",title:"CORE THEME THAT SPEAKS TO YOU",options:[{id:"revenge",label:"Revenge & Justice",value:"revenge"},{id:"friendship",label:"Bonds & Friendship",value:"friendship"},{id:"growth",label:"Self-Discovery",value:"growth"},{id:"survival",label:"Survival & Stakes",value:"survival"}]},{id:"length",title:"TIME COMMITMENT",options:[{id:"short",label:"Quick Hit (12 eps)",value:"short"},{id:"medium",label:"Full Season (24 eps)",value:"medium"},{id:"long",label:"Epic Journey (50+ eps)",value:"long"}]}];function Z(){const[n,v]=u.useState("hook"),[d,g]=u.useState(0),[l,f]=u.useState({}),[A,q]=u.useState(0);u.useEffect(()=>{W()},[]);const b=(d+1)/p.length*100,{data:s,refetch:T}=k({queryKey:["quiz-recommendation",l],queryFn:async()=>{const a={};({fantasy:["Fantasy","Adventure","Supernatural"],emotional:["Drama","Romance","Slice of Life"],cerebral:["Psychological","Mystery","Thriller"],hype:["Action","Sports","Adventure"]}[l.mood]||[]).forEach(i=>a[i]=(a[i]||0)+3),({fantasy:["Fantasy","Supernatural","Adventure"],scifi:["Sci-Fi","Mecha"],modern:["Slice of Life","Romance","Sports","Drama"],historical:["Historical","Samurai","Military"]}[l.setting]||[]).forEach(i=>a[i]=(a[i]||0)+2),({dark:["Psychological","Horror","Thriller","Drama"],balanced:["Action","Adventure","Mystery"],light:["Comedy","Slice of Life","Romance"]}[l.tone]||[]).forEach(i=>a[i]=(a[i]||0)+2),({revenge:["Action","Thriller","Drama"],friendship:["Adventure","Sports","Slice of Life"],growth:["Drama","Romance","Slice of Life"],survival:["Horror","Thriller","Action","Sci-Fi"]}[l.theme]||[]).forEach(i=>a[i]=(a[i]||0)+2);const I=Object.entries(a).sort((i,t)=>t[1]-i[1]).slice(0,5).map(([i])=>i),{data:N,error:z}=await F.from("shows").select("*").not("poster_url","is",null).not("synopsis","is",null).order("popularity",{ascending:!1}).limit(100);if(z)throw z;const j=(N||[]).map(i=>{let t=0;const y=i.genres||[];I.forEach((c,_)=>{y.includes(c)&&(t+=(5-_)*(a[c]||1))});const h=i.episodes_count||0;return l.pacing==="fast"&&h<=24&&(t+=3),l.pacing==="slow"&&h>=24&&(t+=3),l.pacing==="medium"&&(t+=1),(l.length==="short"&&h<=13||l.length==="medium"&&h>13&&h<=26||l.length==="long"&&h>26)&&(t+=5),l.protagonist==="antihero"&&y.some(c=>["Psychological","Thriller","Horror"].includes(c))&&(t+=3),l.protagonist==="underdog"&&y.some(c=>["Sports","Adventure","Action"].includes(c))&&(t+=3),l.protagonist==="hero"&&y.some(c=>["Action","Adventure","Fantasy"].includes(c))&&(t+=2),l.protagonist==="ensemble"&&y.some(c=>["Slice of Life","Drama","Comedy"].includes(c))&&(t+=2),{show:i,score:t}}).filter(i=>i.score>0).sort((i,t)=>t.score-i.score).slice(0,10);if(j.length===0){const i=Math.floor(Math.random()*Math.min(N?.length||1,20));return N?.[i]||null}const M=Math.floor(Math.random()*j.length);return j[M].show},enabled:n==="loading"});u.useEffect(()=>{if(n==="loading"){const a=setTimeout(()=>{v("result")},2e3);return()=>clearTimeout(a)}},[n]),u.useEffect(()=>{if(n==="questions"){q(0);const a=b,o=setInterval(()=>{q(m=>{const x=m+Math.random()*15;return x>=a?(clearInterval(o),a):x})},50);return()=>clearInterval(o)}},[d,n,b]);const R=()=>{v("questions"),g(0),f({})},w=(a,o)=>{f(m=>({...m,[a]:o})),d<p.length-1?g(m=>m+1):(v("loading"),T())},S=()=>{v("hook"),g(0),f({})};return e.jsxs("div",{className:"quiz-container",children:[n==="questions"&&e.jsxs("div",{className:"quiz-progress-container",children:[e.jsx(r.div,{className:"quiz-progress-bar",style:{width:`${A}%`},animate:{opacity:[1,.7,1],scaleY:[1,1.5,1]},transition:{duration:.1,repeat:2}}),e.jsx("div",{className:"quiz-progress-glitch"})]}),e.jsxs(P,{mode:"wait",children:[n==="hook"&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"quiz-hook",children:[e.jsx("div",{className:"quiz-lens-flare"}),e.jsx(r.h1,{className:"quiz-title",initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.2},children:"INITIATE DISCOVERY"}),e.jsx(r.p,{className:"quiz-subtitle",initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.4},children:"Find your next obsession"}),e.jsxs(r.button,{className:"quiz-start-btn",onClick:R,initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.6},whileHover:{scale:1.02},whileTap:{scale:.98},children:[e.jsx(H,{className:"w-5 h-5"}),e.jsx("span",{children:"BEGIN SCAN"})]})]},"hook"),n==="questions"&&e.jsxs(r.div,{initial:{opacity:0,x:50},animate:{opacity:1,x:0},exit:{opacity:0,x:-50},className:"quiz-question-container",children:[e.jsxs("div",{className:"quiz-question-number",children:[String(d+1).padStart(2,"0")," / ",String(p.length).padStart(2,"0")]}),e.jsx("h2",{className:"quiz-question-title",children:p[d].title}),e.jsx("div",{className:"quiz-options",children:p[d].options.map((a,o)=>e.jsxs(r.button,{className:"quiz-option",onClick:()=>w(p[d].id,a.value),initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:o*.1},whileHover:{scale:1.01},whileTap:{scale:.99},children:[e.jsx("span",{className:"quiz-option-label",children:a.label}),e.jsx(G,{className:"quiz-option-arrow"})]},a.id))})]},`question-${d}`),n==="loading"&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"quiz-loading",children:[e.jsxs("div",{className:"quiz-scanner",children:[e.jsx("div",{className:"quiz-scanner-line"}),e.jsx("div",{className:"quiz-scanner-grid",children:Array.from({length:16}).map((a,o)=>e.jsx(r.div,{className:"quiz-scanner-cell",animate:{opacity:[.1,.5,.1]},transition:{duration:.5,delay:o*.05,repeat:1/0}},o))})]}),e.jsx("p",{className:"quiz-loading-text",children:"SCANNING DATABASE..."})]},"loading"),n==="result"&&s&&e.jsxs(r.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0},className:"quiz-result",children:[e.jsx("div",{className:"quiz-result-label",children:"MATCH FOUND"}),e.jsxs(O,{to:`/shows/${s.slug||s.id}`,className:"quiz-result-card",children:[e.jsxs("div",{className:"quiz-result-image-container",children:[e.jsx("img",{src:s.poster_url||"/placeholder.svg",alt:s.title_english||s.title_romaji||"Anime",className:"quiz-result-image"}),e.jsx("div",{className:"quiz-result-overlay"})]}),e.jsxs("div",{className:"quiz-result-info",children:[e.jsx("h3",{className:"quiz-result-title",children:s.title_english||s.title_romaji}),s.title_romaji&&s.title_english&&e.jsx("p",{className:"quiz-result-alt-title",children:s.title_romaji}),e.jsxs("div",{className:"quiz-result-stats",children:[s.season_year&&e.jsxs("span",{className:"quiz-stat",children:["YEAR: ",s.season_year]}),s.format&&e.jsxs("span",{className:"quiz-stat",children:["FORMAT: ",s.format]}),s.episodes_count&&e.jsxs("span",{className:"quiz-stat",children:["EPISODES: ",s.episodes_count]}),s.average_score&&e.jsxs("span",{className:"quiz-stat",children:["SCORE: ",s.average_score,"%"]})]}),s.genres&&e.jsx("div",{className:"quiz-result-genres",children:s.genres.slice(0,4).map(a=>e.jsx("span",{className:"quiz-genre-tag",children:a},a))}),e.jsxs("div",{className:"quiz-view-details",children:[e.jsx(L,{className:"w-3 h-3"}),e.jsx("span",{children:"VIEW DETAILS"})]})]})]}),e.jsxs("button",{className:"quiz-restart-btn",onClick:S,children:[e.jsx(E,{className:"w-4 h-4"}),e.jsx("span",{children:"RE-SCAN"})]})]},"result"),n==="result"&&!s&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},className:"quiz-no-result",children:[e.jsx("p",{children:"No matches found. Try again."}),e.jsxs("button",{className:"quiz-restart-btn",onClick:S,children:[e.jsx(E,{className:"w-4 h-4"}),e.jsx("span",{children:"RE-SCAN"})]})]},"no-result")]})]})}export{Z as default};