1import{j as e,C as gt,u as Qe}from"./vendor-three-Bmn2g83e.js";import{u as T,d as ft,r as d,H as jt,L as B,e as N}from"./vendor-react-kRHgybFd.js";import{u as M,i as j}from"./main-D9e5nRIT.js";import{c as q,Z as te,G as wt,B as he,aa as Re,T as Ye,d as G,bt as Nt,C as Te,aS as Le,a6 as we,bu as Je,U as oe,e as Ve,A as De,az as vt,a1 as yt,bv as Ne,X as H,ac as ce,a9 as ae,a2 as ve,ap as ye,k as kt,g as ke,bf as Ke,ai as St,aR as Ze,a3 as Ct,a5 as et,bw as qe,bx as Pt,f as It,af as $t}from"./vendor-misc-DSUDoLcJ.js";const Xe=["#9333ea","#7c3aed","#4f46e5","#dc2626","#ea580c","#2563eb"];function _t({position:t,color:l,speed:n,size:a}){const r=d.useRef(),c=d.useMemo(()=>Math.random()*Math.PI*2,[]);return Qe(({clock:i})=>{if(!r.current)return;const s=i.getElapsedTime()*n+c;r.current.position.y=t[1]+Math.sin(s*.7)*.6,r.current.position.x=t[0]+Math.sin(s*.5)*.3,r.current.rotation.x=s*.4,r.current.rotation.z=s*.3}),e.jsxs("mesh",{ref:r,position:t,children:[e.jsx("icosahedronGeometry",{args:[a,0]}),e.jsx("meshBasicMaterial",{color:l,wireframe:!0})]})}function Bt(){const t=d.useRef();Qe(({clock:n})=>{t.current&&(t.current.rotation.y=n.getElapsedTime()*.04)});const l=d.useMemo(()=>Array.from({length:22},(n,a)=>({id:a,pos:[(Math.random()-.5)*18,(Math.random()-.5)*8,(Math.random()-.5)*10-3],color:Xe[a%Xe.length],speed:.4+Math.random()*.8,size:.12+Math.random()*.35})),[]);return e.jsx("group",{ref:t,children:l.map(n=>e.jsx(_t,{position:n.pos,color:n.color,speed:n.speed,size:n.size},n.id))})}function Et(){return e.jsx(gt,{gl:{antialias:!0,alpha:!0,powerPreference:"low-power"},dpr:[1,1.5],camera:{fov:60,near:.1,far:100,position:[0,0,10]},style:{position:"absolute",inset:0,pointerEvents:"none"},children:e.jsx(Bt,{})})}const Mt=({d:t})=>{const l={easy:"bg-green-500/20 text-green-400",medium:"bg-yellow-500/20 text-yellow-400",hard:"bg-red-500/20 text-red-400"};return e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${l[t]||"bg-slate-800/80 text-white/50"}`,children:t})},At=({s:t})=>{const l={pending:"bg-blue-500/20 text-blue-400",waiting_for_players:"bg-yellow-500/20 text-yellow-400",in_progress:"bg-green-500/20 text-green-400",completed:"bg-slate-800/80 text-white/40"},n={pending:"Open",waiting_for_players:"Ready",in_progress:"Live",completed:"Done"};return e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${l[t]||"bg-slate-800/80 text-white/50"}`,children:n[t]||t})},Rt=({battle:t,userId:l,onJoin:n})=>{const a=T(),[r,c]=N.useState(!1);t.creatorId;const i=t.participants?.some(P=>P.userId===l),s=t.maxParticipants===1,m=t.participantCount>=t.maxParticipants,x=t.matchType==="school_vs_school",h=t.mode==="free_for_all",o=!!t.metadata?.fogOfWar,b=!!t.metadata?.showdown,u=!!t.metadata?.domination,g=!!t.metadata?.turfWar,p=t.battleType==="territory_control",f=t.battleType==="survival",v=t.status!=="completed",S=()=>a(`/brain-battles/${t.id}`),C=P=>{P.stopPropagation();const y=`${window.location.origin}/brain-battles/${t.id}`;navigator.clipboard.writeText(y).catch(()=>{}),c(!0),setTimeout(()=>c(!1),2e3)};return e.jsxs("div",{onClick:v?S:void 0,className:`bg-slate-700/40 border border-white/25 rounded-2xl p-5 transition-all ${v?"hover:border-purple-500/40 cursor-pointer hover:bg-white/[0.08]":"opacity-60"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"text-white font-bold truncate",children:t.title}),e.jsx(At,{s:t.status}),e.jsx(Mt,{d:t.difficulty}),s&&e.jsxs("span",{className:"text-xs bg-blue-500/20 text-blue-300 px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(Ke,{className:"w-3 h-3"})," Solo"]}),x&&e.jsxs("span",{className:"text-xs bg-purple-500/20 text-purple-300 px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(G,{className:"w-3 h-3"})," School Battle"]}),h&&e.jsx("span",{className:"text-xs bg-orange-500/20 text-orange-300 px-2 py-0.5 rounded-full flex items-center gap-1",children:"âï¸ Royale"}),p&&e.jsx("span",{className:"text-xs bg-green-500/20 text-green-300 px-2 py-0.5 rounded-full",children:"ðºï¸ Territory"}),o&&e.jsx("span",{className:"text-xs bg-slate-500/20 text-slate-300 px-2 py-0.5 rounded-full",children:"ð«ï¸ Fog"}),b&&e.jsx("span",{className:"text-xs bg-yellow-400/20 text-yellow-300 px-2 py-0.5 rounded-full",children:"âï¸ Showdown"}),u&&e.jsx("span",{className:"text-xs bg-amber-500/20 text-amber-300 px-2 py-0.5 rounded-full",children:"ð§© Domination"}),g&&e.jsx("span",{className:"text-xs bg-emerald-500/20 text-emerald-300 px-2 py-0.5 rounded-full",children:"ðï¸ Turf War"}),f&&e.jsx("span",{className:"text-xs bg-red-500/20 text-red-300 px-2 py-0.5 rounded-full",children:"ð Survival"})]}),t.subject&&e.jsx("p",{className:"text-white/60 text-sm",children:t.subject})]}),e.jsxs("div",{className:"flex-shrink-0 text-right",children:[e.jsxs("div",{className:"text-white/50 text-xs flex items-center gap-1 justify-end",children:[e.jsx(St,{className:"w-3 h-3"}),t.duration,"m"]}),e.jsxs("div",{className:"text-white/50 text-xs flex items-center gap-1 justify-end mt-1",children:[e.jsx(oe,{className:"w-3 h-3"}),t.participantCount,"/",t.maxParticipants]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/60",children:[e.jsx(te,{className:"w-3 h-3 text-yellow-400"}),e.jsxs("span",{children:[t.winnerXP," XP to winner"]})]}),e.jsxs("div",{onClick:P=>P.stopPropagation(),className:"flex items-center gap-2",children:[!s&&v&&e.jsx("button",{onClick:C,title:"Copy invite link",className:"p-1.5 bg-slate-700/40 border border-white/25 rounded-lg text-white/60 hover:text-white/70 hover:bg-slate-700/60 transition-all",children:r?e.jsx(ke,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(Ze,{className:"w-3.5 h-3.5"})}),t.status==="completed"?e.jsx("span",{className:"text-white/60 text-xs",children:"Battle over"}
1):i?e.jsxs("button",{onClick:S,className:"text-sm px-4 py-1.5 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-semibold rounded-lg hover:scale-105 transition-all flex items-center gap-1",children:[e.jsx(ye,{className:"w-3.5 h-3.5"})," Enter"]}):t.status==="in_progress"?e.jsxs("button",{onClick:()=>a(`/brain-battles/spectate/${t.id}`),className:"text-sm px-4 py-1.5 bg-red-500/10 border border-red-500/30 text-red-400 font-semibold rounded-lg hover:bg-red-500/20 transition-all flex items-center gap-1",children:[e.jsx(ve,{className:"w-3.5 h-3.5"})," Spectate"]}):m?e.jsx("span",{className:"text-white/60 text-xs",children:"Full"}):e.jsx("button",{onClick:()=>n(t),className:"text-sm px-4 py-1.5 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-semibold rounded-lg hover:scale-105 transition-all",children:"Join"})]})]})]})},ue=[{level:1,title:"Freshman",badge:"ð",xp:0},{level:2,title:"Sophomore",badge:"ð",xp:200},{level:3,title:"Junior",badge:"âï¸",xp:500},{level:4,title:"Senior",badge:"ð«",xp:900},{level:5,title:"Graduate",badge:"ðï¸",xp:1400},{level:6,title:"Scholar",badge:"ð",xp:2e3},{level:7,title:"Honors",badge:"â",xp:2800},{level:8,title:"Distinction",badge:"ð",xp:3700},{level:9,title:"Master",badge:"ð
",xp:4700},{level:10,title:"Grand Master",badge:"ð¥",xp:5900},{level:11,title:"Doctor",badge:"ð¬",xp:7300},{level:12,title:"Professor",badge:"ð©",xp:8900},{level:13,title:"Dean",badge:"ðï¸",xp:10700},{level:14,title:"Provost",badge:"âï¸",xp:12700},{level:15,title:"Chancellor",badge:"ð",xp:15e3},{level:16,title:"Regent",badge:"ð",xp:17500},{level:17,title:"Fellow",badge:"ð®",xp:20300},{level:18,title:"Luminary",badge:"â¨",xp:23500},{level:19,title:"Legend",badge:"ð ",xp:27e3},{level:20,title:"Immortal",badge:"â¡",xp:31e3}];function tt(){try{return parseInt(localStorage.getItem("sq_xp")||"0",10)}catch{return 0}}function Tt(t){let l=ue[0];for(const r of ue)if(t>=r.xp)l=r;else break;const n=ue[l.level]||null,a=n?Math.min((t-l.xp)/(n.xp-l.xp),1):1;return{...l,next:n,pct:a}}function Lt(){try{return parseInt(localStorage.getItem("sq_win_streak")||"0",10)}catch{return 0}}function Dt(){try{return parseInt(localStorage.getItem("sq_best_streak")||"0",10)}catch{return 0}}function qt(){try{return JSON.parse(localStorage.getItem("sq_history")||"[]")}catch{return[]}}const Oe=[{name:"Unranked",badge:"â",min:0,color:"#6b7280"},{name:"Bronze",badge:"ð¥",min:150,color:"#b45309"},{name:"Silver",badge:"ð¥",min:1200,color:"#9ca3af"},{name:"Gold",badge:"ð",min:4500,color:"#eab308"},{name:"Platinum",badge:"ð ",min:12e3,color:"#06b6d4"},{name:"Diamond",badge:"ð",min:25e3,color:"#8b5cf6"},{name:"Master",badge:"ð¥",min:4e4,color:"#ef4444"},{name:"Legend",badge:"â¡",min:6e4,color:"#a855f7"}];function Xt(t){let l=Oe[0];for(const n of Oe)if(t>=n.min)l=n;else break;return l}const O=[{p:0,badge:"",label:"",color:"#6b7280",xpMult:1},{p:1,badge:"â",label:"Prestige I",color:"#eab308",xpMult:1.15},{p:2,badge:"ââ",label:"Prestige II",color:"#f97316",xpMult:1.3},{p:3,badge:"ð«",label:"Prestige III",color:"#a855f7",xpMult:1.45},{p:4,badge:"ð",label:"Prestige IV",color:"#06b6d4",xpMult:1.6},{p:5,badge:"ð",label:"Prestige V",color:"#ec4899",xpMult:1.8}];function Ot(){try{return parseInt(localStorage.getItem("sq_prestige")||"0",10)}catch{return 0}}function zt(t){try{localStorage.setItem("sq_prestige",String(Math.max(0,Math.min(t,5))))}catch{}}function Ft(t){return O[Math.min(Math.max(t,0),5)]}const Wt=20;function Ut({userName:t}){const[l,n]=N.useState(0),[a,r]=N.useState(0),[c,i]=N.useState([]),[s,m]=N.useState(0),[x,h]=N.useState(!1),o=N.useCallback(()=>{n(tt()),r(Lt()),i(qt()),m(Ot())},[]);N.useEffect(()=>{o();const $=()=>{document.hidden||o()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},[o]);const b=()=>{if(s>=5)return;const $=s+1;zt($);try{localStorage.setItem("sq_xp","0")}catch{}h(!1),o()},u=Tt(l),g=Xt(l),p=Ft(s),f=u.level>=Wt&&s<5,v=Dt(),S=c.filter($=>$.result==="W").length,C=c.length>0?Math.round(S/c.length*100):0,P=["#a855f7","#6366f1","#06b6d4","#22c55e","#f59e0b","#ef4444","#ec4899"],y=P[u.level%P.length];return e.jsxs(e.Fragment,{children:[x&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-slate-900 border border-purple-500/30 rounded-2xl p-6 max-w-sm w-full text-center",children:[e.jsx("div",{className:"text-5xl mb-3",children:O[s+1]?.badge||"ð"}),e.jsxs("h3",{className:"text-white font-black text-xl mb-2",children:["Prestige ",s+1,"?"]}),e.jsx("p",{className:"text-white/50 text-sm mb-1",children:"Your level will reset to 1, but you keep your rank and battle history."}),e.jsxs("p",{className:"text-white/50 text-sm mb-4",children:["Unlock ",e.jsx("span",{style:{color:O[s+1]?.color},children:O[s+1]?.label})," badge + ",e.jsxs("strong",{className:"text-yellow-400",children:["+",Math.round((O[s+1]?.xpMult-1)*100),"% permanent XP bonus"]}),"."]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>h(!1),className:"flex-1 px-4 py-2 bg-slate-700/40 border border-white/25 text-white/50 font-semibold rounded-xl hover:bg-slate-700/60 transition-all text-sm",children:"Cancel"}),e.jsx("button",{onClick:b,className:"flex-1 px-4 py-2 font-bold rounded-xl text-white text-sm transition-all hover:scale-105",style:{background:`linear-gradient(135deg,${O[s+1]?.color||"#7c3aed"},#7c3aed)`},children:"PRESTIGE!"})]})]})}),e.jsxs("div",{className:"mt-8 mb-2 bg-white/[0.04] border border-white/25 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsxs("div",{className:"flex-shrink-0 w-14 h-14 roun
1ded-2xl flex items-center justify-center text-3xl relative",style:{background:`${y}18`,border:`2px solid ${s>0?p.color+"60":y+"40"}`},children:[u.badge,s>0&&e.jsx("span",{className:"absolute -top-1.5 -right-1.5 text-sm leading-none",children:p.badge})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-white font-black text-base",children:t}),s>0&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold",style:{background:`${p.color}18`,border:`1px solid ${p.color}50`,color:p.color},children:[p.badge," ",p.label]}),e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold",style:{background:`${y}18`,border:`1px solid ${y}40`,color:y},children:[u.badge," Lv.",u.level," ",u.title]}),g.name!=="Unranked"&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold",style:{background:`${g.color}15`,border:`1px solid ${g.color}40`,color:g.color},children:[g.badge," ",g.name]})]}),e.jsxs("div",{className:"text-white/60 text-xs mt-0.5",children:[l.toLocaleString()," XP total",a>=2&&e.jsxs("span",{className:"ml-2 text-orange-400",children:["ð¥".repeat(Math.min(a,5))," ",a," streak"]}),s>0&&e.jsxs("span",{className:"ml-2",style:{color:p.color},children:["+",Math.round((p.xpMult-1)*100),"% XP"]})]})]}),c.length>0&&e.jsxs("div",{className:"flex-shrink-0 text-right text-xs",children:[e.jsxs("div",{className:"text-white font-bold",children:[S,"W / ",c.length-S,"L"]}),e.jsxs("div",{className:"text-white/60",children:[C,"% win rate"]})]})]}),e.jsx("div",{className:"h-2 bg-slate-700/40 rounded-full overflow-hidden mb-1",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${Math.min(u.pct*100,100)}%`,background:`linear-gradient(90deg,${y},#6366f1)`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-white/50",children:[e.jsxs("span",{children:["Lv.",u.level]}),u.next?e.jsxs("span",{children:[(u.next.xp-l).toLocaleString()," XP to ",u.next.badge," Lv.",u.level+1]}):e.jsx("span",{children:"Max Level!"})]}),(v>0||c.length>0)&&e.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-4 text-center",children:[e.jsxs("div",{className:"bg-white/3 rounded-xl py-2",children:[e.jsx("div",{className:"text-white font-black text-sm",children:c.length}),e.jsx("div",{className:"text-white/60 text-[10px]",children:"battles"})]}),e.jsxs("div",{className:"bg-white/3 rounded-xl py-2",children:[e.jsxs("div",{className:"text-orange-400 font-black text-sm",children:[v,"ð¥"]}),e.jsx("div",{className:"text-white/60 text-[10px]",children:"best streak"})]}),e.jsxs("div",{className:"bg-white/3 rounded-xl py-2",children:[e.jsx("div",{className:"text-emerald-400 font-black text-sm",children:c.reduce(($,A)=>$+(A.xpGained||0),0).toLocaleString()}),e.jsx("div",{className:"text-white/60 text-[10px]",children:"XP earned"})]})]}),c.length>0&&e.jsxs("div",{className:"mt-4 pt-3 border-t border-white/8",children:[e.jsx("div",{className:"text-white/25 text-[10px] uppercase tracking-wider mb-2",children:"Recent Battles"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:c.slice(0,5).map(($,A)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] bg-white/3 rounded-lg px-2 py-1.5",children:[e.jsx("span",{className:`font-black ${$.result==="W"?"text-emerald-400":"text-red-400"}`,children:$.result}),e.jsx("span",{className:"text-white/60",children:$.score?.toLocaleString()||"â"}),$.achievements?.length>0&&e.jsx("span",{className:"text-[11px]",children:$.achievements.join("")}),e.jsxs("span",{className:"text-yellow-400/60 text-[10px]",children:["+",$.xpGained,"xp"]})]},A))})]}),f&&e.jsx("div",{className:"mt-4 pt-3 border-t border-white/8",children:e.jsxs("button",{onClick:()=>h(!0),className:"w-full py-2.5 rounded-xl font-black text-sm tracking-wide transition-all hover:scale-[1.02]",style:{background:`linear-gradient(135deg,${O[s+1]?.color||"#7c3aed"}30,rgba(124,58,237,0.2))`,border:`1.5px solid ${O[s+1]?.color||"#7c3aed"}50`,color:O[s+1]?.color||"#a855f7"},children:["⨠You've reached max level! Prestige ",s+1," is available"]})})]})]})}const V=[{xp:0,reward:"ð® Starter",label:"Starter",color:"#6b7280"},{xp:200,reward:"â¡ Blitz Card",label:"Blitz",color:"#06b6d4"},{xp:600,reward:"ð¥ Hot Streak",label:"Hot Streak",color:"#f97316"}
1,{xp:1500,reward:"ð° +50 BP",label:"BP Bonus",color:"#eab308"},{xp:4e3,reward:"ð Gold Frame",label:"Gold",color:"#eab308"},{xp:8e3,reward:"ð Platinum",label:"Platinum",color:"#06b6d4"},{xp:18e3,reward:"ð Diamond",label:"Diamond",color:"#8b5cf6"},{xp:35e3,reward:"â¡ Legend Badge",label:"Legend",color:"#a855f7"}];function Gt({xp:t}){const l=V.filter(c=>t>=c.xp).length,n=V[l]||null,a=V[l-1]||V[0],r=n?Math.min((t-a.xp)/(n.xp-a.xp),1):1;return e.jsxs("div",{className:"mt-4 bg-white/[0.03] border border-white/8 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-white/50 text-xs font-bold uppercase tracking-wider",children:"Battle Pass"}),n&&e.jsxs("div",{className:"text-white/60 text-[10px]",children:[(n.xp-t).toLocaleString()," XP to ",n.reward]})]}),e.jsx("div",{className:"relative h-2 bg-slate-700/40 rounded-full overflow-hidden mb-4",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${r*100}%`,background:"linear-gradient(90deg,#7c3aed,#06b6d4)"}})}),e.jsx("div",{className:"flex items-start gap-1 overflow-x-auto scrollbar-none pb-1",children:V.map((c,i)=>{const s=t>=c.xp,m=i===l-1||i===0&&l===0;return e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 min-w-[52px]",children:[e.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center text-base transition-all ${s?"scale-105":"opacity-30 grayscale"}`,style:{background:s?`${c.color}20`:"rgba(255,255,255,0.04)",border:`1.5px solid ${s?c.color+"60":"rgba(255,255,255,0.08)"}`},title:c.reward,children:c.reward.split(" ")[0]}),e.jsx("div",{className:"text-[9px] text-center leading-tight text-white/50",children:c.label}),m&&!s&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"})]},i)})})]})}function Ht({onStart:t}){const[l,n]=N.useState("idle"),[a,r]=N.useState(null),[c,i]=N.useState(""),s=()=>`sq_daily_${new Date().toISOString().slice(0,10)}`,m=()=>{try{return!!localStorage.getItem(s())}catch{return!1}},x=()=>{try{return parseInt(localStorage.getItem(s())||"0",10)}catch{return 0}};N.useEffect(()=>{const g=()=>{const f=new Date,v=new Date(f);v.setHours(24,0,0,0);const S=v-f,C=Math.floor(S/36e5).toString().padStart(2,"0"),P=Math.floor(S%36e5/6e4).toString().padStart(2,"0"),y=Math.floor(S%6e4/1e3).toString().padStart(2,"0");i(`${C}:${P}:${y}`)};g();const p=setInterval(g,1e3);return()=>clearInterval(p)},[]);const h=async()=>{n("loading");try{const{data:g}=await j.get("/api/gamification/v2/daily-challenge");r(g),n("ready")}catch{n("error")}};N.useEffect(()=>{m()&&n("done")},[]);const o=()=>{a&&t(a,s)},b=m(),u=b?x():null;return e.jsxs("div",{className:"mt-4 bg-gradient-to-br from-amber-500/10 via-orange-500/8 to-red-500/10 border border-amber-500/25 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-lg",children:"âï¸"}),e.jsx("span",{className:"text-amber-300 font-black text-sm uppercase tracking-wider",children:"Daily Challenge"}),b&&e.jsx("span",{className:"text-[10px] bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 px-2 py-0.5 rounded-full font-bold",children:"â Done"})]}),e.jsx("p",{className:"text-white/60 text-xs",children:"New questions every day · Same for everyone worldwide"})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"text-white/50 text-[9px] uppercase tracking-wider",children:"Resets in"}),e.jsx("div",{className:"text-amber-300/70 font-mono text-xs font-bold",children:c})]})]}),l==="idle"&&!b&&e.jsx("button",{onClick:h,className:"w-full py-2.5 bg-amber-500/20 border border-amber-500/40 text-amber-300 font-bold rounded-xl hover:bg-amber-500/30 transition-all text-sm flex items-center justify-center gap-2",children:"âï¸ Load Today's Challenge"}),l==="loading"&&e.jsxs("div",{className:"text-center py-3",children:[e.jsx(ce,{className:"w-5 h-5 text-amber-400 animate-spin mx-auto mb-1"}),e.jsx("p",{className:"text-white/60 text-xs",children:"Generating today's questionsâ¦"})]}),l==="error"&&e.jsx("p",{className:"text-red-400/60 text-xs text-center py-2",children:"Failed to load. Try again later."}),l==="ready"&&a&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-3 mb-3",children:e.jsxs("div",{className:"flex-1 bg-slate-700/40 rounded-xl p-3",children:[e.jsx("div",{className:"text-white font-bold text-sm",children:a.subject}),e.jsx("div",{className:"text-white/60 text-xs mt-0.5",children:"10 questions · Medium difficulty"})]})}),e.jsx("button",{onClick:o,className:"w-full py-2.5 bg-gradient-to-r from-amber-500 to-orange-500 text-white font-black rounded-xl hover:scale-[1.02] transition-all text-sm flex items-center justify-center gap-2",children:"âï¸ Start Daily Challenge"})]}),b&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-emerald-400 font-black text-lg",children:[u.toLocaleStr
1ing()," pts"]}),e.jsx("div",{className:"text-white/60 text-xs",children:"Today's score"})]}),e.jsxs("div",{className:"text-white/50 text-xs text-right",children:["Come back tomorrow",e.jsx("br",{}),"for a new challenge!"]})]})]})}const Qt=["General Knowledge","Mathematics","Biology","Chemistry","Physics","History","Literature","Psychology","Computer Science","Economics","SAT Prep","AP Biology","AP Chemistry","AP US History","AP Calculus","AP Psychology","AP English","AP Computer Science","AP Economics"],Yt=({onClose:t,onStart:l})=>{const[n,a]=d.useState(""),[r,c]=d.useState("medium"),[i,s]=d.useState(8),[m,x]=d.useState(!1),h=async()=>{x(!0);try{await l({subject:n,difficulty:r,questionCount:i})}finally{x(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-white/25 rounded-2xl w-full max-w-md shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/25",children:[e.jsxs("h2",{className:"text-white font-bold text-lg flex items-center gap-2",children:[e.jsx(Ke,{className:"w-5 h-5 text-blue-400"})," Solo Practice"]}),e.jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-2",children:"Subject"}),e.jsx("input",{value:n,onChange:o=>a(o.target.value),placeholder:"e.g. Cell Biology, World War IIâ¦",className:"w-full px-3 py-2 bg-slate-700/40 border border-white/25 rounded-lg text-white placeholder:text-white/60 outline-none focus:border-blue-500 text-sm mb-2"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Qt.map(o=>e.jsx("button",{onClick:()=>a(o),className:`text-xs px-2.5 py-1 rounded-full border transition-all ${n===o?"border-blue-500 bg-blue-500/20 text-blue-300":"border-white/25 bg-slate-700/40 text-white/40 hover:border-white/20 hover:text-white/70"}`,children:o},o))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Difficulty"}),e.jsxs("select",{value:r,onChange:o=>c(o.target.value),className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-blue-500 text-sm",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Questions"}),e.jsx("select",{value:i,onChange:o=>s(Number(o.target.value)),className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-blue-500 text-sm",children:[5,8,10,15,20].map(o=>e.jsxs("option",{value:o,children:[o," questions"]},o))})]})]}),e.jsx("button",{onClick:h,disabled:m,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-blue-600 to-cyan-600 text-white font-bold rounded-xl hover:scale-105 transition-all disabled:opacity-50 disabled:hover:scale-100",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Generating questionsâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4"})," Start Practice"]})})]})]})})},Jt=({onClose:t,onNavigate:l})=>{const[n,a]=d.useState(""),[r,c]=d.useState("medium"),[i,s]=d.useState("setup"),[m,x]=d.useState(null),[h,o]=d.useState(""),b=d.useRef(null),u=d.useRef(!1);d.useEffect(()=>()=>{u.current=!0,clearInterval(b.current)},[]);const g=async()=>{u.current=!0,clearInterval(b.current);try{await j.delete("/api/gamification/v2/battles/quickmatch")}catch{}t()},p=async()=>{o(""),s("searching"),u.current=!1;try{const f=await j.post("/api/gamification/v2/battles/quickmatch",{subject:n,difficulty:r}),{status:v,battleId:S}=f.data;if(x(S),v==="matched"){clearInterval(b.current),l(S);return}b.current=setInterval(async()=>
1{if(!u.current)try{const C=await j.post("/api/gamification/v2/battles/quickmatch",{subject:n,difficulty:r});(C.data.status==="matched"||u.current)&&(clearInterval(b.current),u.current||l(C.data.battleId||S))}catch{}},2e3),setTimeout(()=>{u.current||(clearInterval(b.current),o("No opponent found. Try creating a public battle instead."),s("setup"),j.delete("/api/gamification/v2/battles/quickmatch").catch(()=>{}))},9e4)}catch(f){s("setup"),o(f.response?.data?.error||"Could not start matchmaking")}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-white/25 rounded-2xl w-full max-w-sm shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/25",children:[e.jsxs("h2",{className:"text-white font-bold text-lg flex items-center gap-2",children:[e.jsx(q,{className:"w-5 h-5 text-red-400"})," Quick Match"]}),e.jsx("button",{onClick:i==="searching"?g:t,className:"text-white/60 hover:text-white transition-colors",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6",children:i==="setup"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-white/50 text-sm",children:"Get auto-paired with a waiting opponent. Battle starts the moment a match is found."}),h&&e.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-xl text-red-300 text-sm flex items-center gap-2",children:[e.jsx(et,{className:"w-4 h-4 flex-shrink-0"}),h]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white/60 text-sm mb-1",children:["Subject ",e.jsx("span",{className:"text-white/60 font-normal",children:"(optional)"})]}),e.jsx("input",{value:n,onChange:f=>a(f.target.value),placeholder:"e.g. Biology, Historyâ¦",className:"w-full px-3 py-2 bg-slate-700/40 border border-white/25 rounded-lg text-white placeholder:text-white/60 outline-none focus:border-red-500 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Difficulty"}),e.jsxs("select",{value:r,onChange:f=>c(f.target.value),className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-red-500 text-sm",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]})]}),e.jsxs("button",{onClick:p,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-red-600 to-orange-600 text-white font-bold rounded-xl hover:scale-105 transition-all",children:[e.jsx(q,{className:"w-4 h-4"})," Find Opponent"]})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"relative w-20 h-20 mx-auto mb-6",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-500/30 animate-ping"}),e.jsx("div",{className:"absolute inset-2 rounded-full border-2 border-red-500/50 animate-ping",style:{animationDelay:"0.3s"}}),e.jsx("div",{className:"absolute inset-4 rounded-full border-2 border-red-500/70 animate-ping",style:{animationDelay:"0.6s"}}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(q,{className:"w-8 h-8 text-red-400"})})]}),e.jsx("h3",{className:"text-white font-bold text-lg mb-2",children:"Searching for opponentâ¦"}),e.jsxs("p",{className:"text-white/60 text-sm mb-1",children:[n?`Subject: ${n}`:"Any subject"," · ",r]}),e.jsx("p",{className:"text-white/25 text-xs mb-6",children:"Up to 90 seconds"}),e.jsx("button",{onClick:g,className:"px-5 py-2.5 bg-slate-800/80 text-white/60 hover:text-white font-semibold rounded-xl hover:bg-slate-700/80 transition-all text-sm",children:"Cancel"})]})})]})})},Vt=({onClose:t,onCreate:l,userSchool:n})=>{const[a,r]=d.useState({title:"",battleType:"quiz_race",subject:"",difficulty:"medium",duration:10,isPublic:!0,winnerXP:100,participantXP:25,questionCount:8,isRoyale:!1,maxParticipants:2,fogOfWar:!1,showdown:!1,domination:!1,turfWar:!1}
1),[c,i]=d.useState(!1),[s,m]=d.useState(""),x=o=>r(b=>({...b,[o.target.name]:o.target.value})),h=async o=>{o.preventDefault(),m(""),i(!0);try{const b=a.battleType==="survival",g={...a,mode:a.isRoyale?"free_for_all":"1v1",maxParticipants:a.isRoyale?a.maxParticipants:b?1:2,minParticipants:b?1:void 0,winnerXP:a.isRoyale?200:a.winnerXP,questionCount:b?8:a.questionCount};await l(g)}catch(b){m(b.response?.data?.error||b.message||"Failed to create battle")}finally{i(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-white/25 rounded-2xl w-full max-w-md shadow-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/25 sticky top-0 bg-slate-900",children:[e.jsxs("h2",{className:"text-white font-bold text-lg flex items-center gap-2",children:[e.jsx(q,{className:"w-5 h-5 text-purple-400"})," Create Battle"]}),e.jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:h,className:"p-6 space-y-4",children:[s&&e.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg flex items-center gap-2",children:[e.jsx(et,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),e.jsx("span",{className:"text-red-200 text-sm",children:s})]}),n&&e.jsxs("div",{className:"p-3 bg-purple-500/10 border border-purple-500/20 rounded-lg text-purple-300 text-sm flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4"}),"Battling for ",e.jsx("strong",{children:n.name})," â points count toward school rankings!"]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white/60 text-sm mb-1",children:["Battle Title ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{name:"title",value:a.title,onChange:x,required:!0,placeholder:"e.g. Chem 101 Showdown",className:"w-full px-3 py-2 bg-slate-700/40 border border-white/25 rounded-lg text-white placeholder:text-white/60 outline-none focus:border-purple-500 text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Type"}),e.jsxs("select",{name:"battleType",value:a.battleType,onChange:x,className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-purple-500 text-sm",children:[e.jsx("option",{value:"quiz_race",children:"Quiz Race"}),e.jsx("option",{value:"speed_blitz",children:"â¡ Speed Blitz (5s/question, 2à pts)"}),e.jsx("option",{value:"territory_control",children:"ðºï¸ Territory Control"}),e.jsx("option",{value:"survival",children:"ð Infinite Survival"}),e.jsx("option",{value:"cooperative",children:"ð¤ Co-op Study (team vs questions)"}),e.jsx("option",{value:"flashcard_duel",children:"Flashcard Duel"}),e.jsx("option",{value:"study_sprint",children:"Study Sprint"}),e.jsx("option",{value:"problem_solve",children:"Problem Solve"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Difficulty"}),e.jsxs("select",{name:"difficulty",value:a.difficulty,onChange:x,className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-purple-500 text-sm",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Subject"}),e.jsx("input",{name:"subject",value:a.subject,onChange:x,placeholder:"e.g. Chemistry",className:"w-full px-3 py-2 bg-slate-700/40 border border-white/25 rounded-lg text-white placeholder:text-white/60 outline-none focus:border-purple-500 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Questions"}),e.jsx("select",{name:"questionCount",value:a.questionCount,onChange:x,className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-purple-500 text-sm",children:[5,8,10,15,20].map(o=>e.jsxs("option",{value:o,children:[o," questions"]},o))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Duration"}),e.jsx("select",{name:"duration",value:a.duration,onChange:x,className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-purple-500 text-sm",children:[5,10,15,20,30].map(o=>e.jsxs("option",{value:o,children:[o," minutes"]},o))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",id:"isPublic",checked:a.isPublic,onChange:o=>r(b=>({...b,isPublic:o.target.checked})),className:"w-4 h-4 accent-purple-600"}),e.jsx("label",{htmlFor:"isPublic",className:"text-white/60 text-sm",children:"Public battle (anyone can join)"})]}),e.jsx("div",{className:`p-3 rounded-xl border cursor-pointer transition-all ${a.isRoyale?"border-orange-500/40 bg-orange-500/10":"border-white/25 bg-white/3 hover:border-white/20"}`,onClick:()=>r(o=>({...o,isRoyale:!o.isRoyale,maxParticipants:o.isRoyale?2:4})),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${a.isRoyale?"bg-
1orange-500":"bg-white/15"}`,children:e.jsx("div",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-all ${a.isRoyale?"left-4":"left-0.5"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/80 text-sm font-bold",children:"âï¸ Battle Royale Mode"}),e.jsx("p",{className:"text-white/60 text-xs",children:"Players have 3 lives â last one standing wins!"})]})]})}),a.isRoyale&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-white/60 text-sm mb-1",children:"Max Players"}),e.jsx("select",{value:a.maxParticipants,onChange:o=>r(b=>({...b,maxParticipants:Number(o.target.value)})),className:"w-full px-3 py-2 bg-slate-800 border border-white/25 rounded-lg text-white outline-none focus:border-orange-500 text-sm",children:[4,5,6,8].map(o=>e.jsxs("option",{value:o,children:[o," players"]},o))})]}),!a.isRoyale&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:`p-3 rounded-xl border cursor-pointer transition-all ${a.fogOfWar?"border-slate-400/40 bg-slate-400/10":"border-white/25 bg-white/3 hover:border-white/20"}`,onClick:()=>r(o=>({...o,fogOfWar:!o.fogOfWar})),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`relative w-8 h-4 rounded-full flex-shrink-0 transition-colors ${a.fogOfWar?"bg-slate-500":"bg-white/15"}`,children:e.jsx("div",{className:`absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-all ${a.fogOfWar?"left-4":"left-0.5"}`})}),e.jsx("span",{className:"text-white/80 text-xs font-bold",children:"ð«ï¸ Fog of War"})]}),e.jsx("p",{className:"text-white/35 text-[10px] leading-tight",children:"Opponent score hidden until reveal"})]}),e.jsxs("div",{className:`p-3 rounded-xl border cursor-pointer transition-all ${a.showdown?"border-yellow-400/40 bg-yellow-400/10":"border-white/25 bg-white/3 hover:border-white/20"}`,onClick:()=>r(o=>({...o,showdown:!o.showdown})),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`relative w-8 h-4 rounded-full flex-shrink-0 transition-colors ${a.showdown?"bg-yellow-500":"bg-white/15"}`,children:e.jsx("div",{className:`absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-all ${a.showdown?"left-4":"left-0.5"}`})}),e.jsx("span",{className:"text-white/80 text-xs font-bold",children:"âï¸ Showdown"})]}),e.jsx("p",{className:"text-white/35 text-[10px] leading-tight",children:"3s dramatic reveal countdown"})]}),e.jsxs("div",{className:`p-3 rounded-xl border cursor-pointer transition-all ${a.domination?"border-amber-400/40 bg-amber-400/10":"border-white/25 bg-white/3 hover:border-white/20"}`,onClick:()=>r(o=>({...o,domination:!o.domination})),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`relative w-8 h-4 rounded-full flex-shrink-0 transition-colors ${a.domination?"bg-amber-500":"bg-white/15"}`,children:e.jsx("div",{className:`absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-all ${a.domination?"left-4":"left-0.5"}`})}),e.jsx("span",{className:"text-white/80 text-xs font-bold",children:"ð§© Domination"})]}),e.jsx("p",{className:"text-white/35 text-[10px] leading-tight",children:"3Ã3 subject grid â 3 in a row = +200 pts"})]}),e.jsxs("div",{className:`p-3 rounded-xl border cursor-pointer transition-all ${a.turfWar?"border-emerald-400/40 bg-emerald-400/10":"border-white/25 bg-white/3 hover:border-white/20"}`,onClick:()=>r(o=>({...o,turfWar:!o.turfWar})),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`relative w-8 h-4 rounded-full flex-shrink-0 transition-colors ${a.turfWar?"bg-emerald-500":"bg-white/15"}`,children:e.jsx("div",{className:`absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-all ${a.turfWar?"left-4":"left-0.5"}`})}),e.jsx("span",{className:"text-white/80 text-xs font-bold",children:"ðï¸ Turf War"})]}),e.jsx("p",{className:"text-white/35 text-[10px] leading-tight",children:"Push the board â breach for +300 pts!"})]})]}
1),e.jsx("button",{type:"submit",disabled:c,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold rounded-xl hover:scale-105 transition-all disabled:opacity-50 disabled:hover:scale-100",children:c?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Creatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4"})," Create Battle"]})})]})]})})},Kt=[{day:0,subject:"History",emoji:"ð",color:"#a855f7",mult:2},{day:1,subject:"Science",emoji:"ð¬",color:"#22c55e",mult:2},{day:2,subject:"Math",emoji:"ð",color:"#ef4444",mult:2},{day:3,subject:"English",emoji:"ð",color:"#3b82f6",mult:2},{day:4,subject:"Tech",emoji:"ð»",color:"#06b6d4",mult:2},{day:5,subject:"Geography",emoji:"ð",color:"#f59e0b",mult:2},{day:6,subject:"Arts",emoji:"ð¨",color:"#ec4899",mult:2}],Q=Kt[new Date().getDay()],Zt=[{id:"win1",emoji:"ð",label:"Win a battle",target:1,type:"wins"},{id:"streak5",emoji:"ð¥",label:"Get a 5-answer streak",target:5,type:"streak"},{id:"correct10",emoji:"â
",label:"Answer 10 correctly",target:10,type:"correct"},{id:"speed3",emoji:"ð",label:"3 correct answers in under 2s",target:3,type:"speed"},{id:"card1",emoji:"ð",label:"Play a power card",target:1,type:"cards"},{id:"boss1",emoji:"âï¸",label:"Beat the Final Boss question",target:1,type:"boss"},{id:"predict3",emoji:"ð¯",label:"Correct subject predictions: 3",target:3,type:"preds"},{id:"battle2",emoji:"â¡",label:"Complete 2 battles",target:2,type:"battles"},{id:"dom1",emoji:"ð§©",label:"Complete a Domination Board",target:1,type:"dom"},{id:"achieve2",emoji:"â",label:"Earn 2 achievements in a battle",target:2,type:"achieve"}];function ze(){const t=new Date().toDateString();try{const r=localStorage.getItem("sq_quests_"+t);if(r)return JSON.parse(r)}catch{}let l=t.split("").reduce((r,c)=>r+c.charCodeAt(0),0);const n=[...Zt],a=[];for(;a.length<3&&n.length>0;){const r=l%n.length;a.push({...n[r],progress:0,completed:!1}),n.splice(r,1),l=(l*31+7)%9973}return a}function es(){const[t,l]=N.useState(()=>ze());N.useEffect(()=>{const a=()=>{document.hidden||l(ze())};return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[]);const n=t.filter(a=>a.completed).length;return e.jsxs("div",{className:"bg-white/4 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-white/70 text-sm font-bold flex items-center gap-1.5",children:"ð Daily Quests"}),e.jsxs("div",{className:"text-xs text-white/60",children:[n,"/3 done · resets midnight"]})]}),e.jsx("div",{className:"space-y-2",children:t.map(a=>e.jsxs("div",{className:`flex items-center gap-2.5 p-2 rounded-xl transition-all ${a.completed?"bg-emerald-500/10 border border-emerald-500/20":"bg-white/3 border border-white/6"}`,children:[e.jsx("span",{className:"text-xl leading-none flex-shrink-0",children:a.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-xs font-semibold truncate ${a.completed?"text-emerald-300":"text-white/70"}`,children:a.label}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("div",{className:"flex-1 h-1 bg-white/8 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(100,a.progress/a.target*100)}%`,background:a.completed?"#22c55e":"#a855f7"}})}),e.jsxs("span",{className:"text-[10px] text-white/60 flex-shrink-0",children:[a.progress,"/",a.target]})]})]}),a.completed&&e.jsx("span",{className:"text-emerald-400 flex-shrink-0 text-sm",children:"â"})]},a.id))})]})}const F=[{id:"science",label:"Science",emoji:"ð¬"},{id:"math",label:"Math",emoji:"ð"},{id:"history",label:"History",emoji:"ð"},{id:"language",label:"Language",emoji:"ð"},{id:"tech",label:"Tech",emoji:"ð»"},{id:"general",label:"General",emoji:"ð"}],Fe=[{name:"Novice",min:0,color:"#6b7280"},{name:"Learner",min:10,color:"#22c55e"},{name:"Adept",min:30,color:"#3b82f6"}
1,{name:"Expert",min:60,color:"#a855f7"},{name:"Master",min:100,color:"#f59e0b"},{name:"Grandmaster",min:200,color:"#ec4899"}];function ts(t){let l=Fe[0];for(const n of Fe)if(t>=n.min)l=n;else break;return l}function ss(){const[t,l]=N.useState({});N.useEffect(()=>{try{l(JSON.parse(localStorage.getItem("sq_mastery")||"{}"))}catch{}},[]);const n=90,a=90,r=62,c=F.length,i=p=>p*2*Math.PI/c-Math.PI/2,s=(p,f)=>({x:n+Math.cos(i(p))*r*f,y:a+Math.sin(i(p))*r*f}),m=200,x=F.map(p=>Math.min((t[p.id]?.correct||0)/m,1)),h=x.map((p,f)=>s(f,Math.max(p,.04))),o=h.map((p,f)=>`${f===0?"M":"L"} ${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join(" ")+" Z",b=[.25,.5,.75,1].map(p=>F.map((f,v)=>s(v,p)).map((f,v)=>`${v===0?"M":"L"} ${f.x.toFixed(1)} ${f.y.toFixed(1)}`).join(" ")+" Z"),u=Object.values(t).some(p=>p.correct>0),g=F.reduce((p,f)=>(t[f.id]?.correct||0)>(t[p.id]?.correct||0)?f:p,F[0]);return e.jsxs("div",{className:"bg-white/4 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-white/70 text-sm font-bold",children:"ð¯ Subject Mastery"}),u&&e.jsxs("div",{className:"text-white/35 text-[10px]",children:["Top: ",g.emoji," ",g.label]})]}),u?e.jsxs("svg",{viewBox:"0 0 180 180",className:"w-full max-w-[180px] mx-auto",children:[b.map((p,f)=>e.jsx("path",{d:p,fill:"none",stroke:"rgba(255,255,255,0.05)",strokeWidth:"1"},f)),F.map((p,f)=>{const v=s(f,1);return e.jsx("line",{x1:n,y1:a,x2:v.x.toFixed(1),y2:v.y.toFixed(1),stroke:"rgba(255,255,255,0.07)",strokeWidth:"1"},f)}),e.jsx("path",{d:o,fill:"rgba(168,85,247,0.18)",stroke:"#a855f7",strokeWidth:"1.5",strokeLinejoin:"round"}),h.map((p,f)=>x[f]>.05&&e.jsx("circle",{cx:p.x.toFixed(1),cy:p.y.toFixed(1),r:"3",fill:"#a855f7"},f)),F.map((p,f)=>{const v=n+Math.cos(i(f))*(r+18),S=a+Math.sin(i(f))*(r+18);return e.jsx("text",{x:v.toFixed(1),y:S.toFixed(1),textAnchor:"middle",dominantBaseline:"middle",fontSize:"10",fill:"rgba(255,255,255,0.4)",children:p.emoji},f)})]}):e.jsxs("div",{className:"text-center py-5 text-white/25 text-xs",children:["Complete battles to",e.jsx("br",{}),"build mastery data"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2",children:F.map(p=>{const f=t[p.id]?.correct||0,v=ts(f);return e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[9px] text-white/60 truncate",children:p.label}),e.jsx("div",{className:"text-[9px] font-bold",style:{color:v.color},children:v.name})]},p.id)})})]})}const pe=[{id:"WILD",emoji:"ð",name:"Wild Card",color:"#a855f7",desc:"Auto-correct question"},{id:"TIME_WARP",emoji:"â±ï¸",name:"Time Warp",color:"#06b6d4",desc:"+12 seconds extra"},{id:"MIND_SHIELD",emoji:"ð",name:"Mind Shield",color:"#22c55e",desc:"Next wrong = 0 penalty"},{id:"PRECISION",emoji:"ð¯",name:"Precision",color:"#f59e0b",desc:"2à pts if under 5s"},{id:"ORACLE",emoji:"ð®",name:"Oracle Peek",color:"#8b5cf6",desc:"Peek correct answer 2.5s"},{id:"POWER_SURGE",emoji:"â¡",name:"Surge",color:"#ef4444",desc:"1.5à on next 2 correct"},{id:"STREAK_SHIELD",emoji:"ð¡ï¸",name:"Streak Shield",color:"#22c55e",desc:"Protects streak for 1 missed day",streakItem:!0}];function as(){const[t,l]=N.useState(null),[n,a]=N.useState(!1);N.useEffect(()=>{try{l(localStorage.getItem("sq_card_reservation")),a(localStorage.getItem("sq_streak_shield")==="1")}catch{}},[]);const r=i=>{if(pe.find(x=>x.id===i)?.streakItem){const x=!n;try{x?localStorage.setItem("sq_streak_shield","1"):localStorage.removeItem("sq_streak_shield")}catch{}a(x);return}const m=i===t?null:i;try{m?localStorage.setItem("sq_card_reservation",m):localStorage.removeItem("sq_card_reservation")}catch{}l(m)},c=pe.find(i=>i.id===t);return e.jsxs("div",{className:"bg-white/4 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("div",{className:"text-white/70 text-sm font-bold",children:"ð Power Card Reserve"}),e.jsx("div",{className:"text-white/25 text-[10px]",children:"Free · 1 slot"})]}),e.jsx("p",{className:"text-white/60 text-[10px] mb-3 leading-relaxed",children:"Pin a card to guarantee it in your next battle hand. Activate the Shield to protect your study streak."}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:pe.map(i=>{const s=!i.streakItem&&t===i.id,m=i.streakItem&&n,x=s||m;return e.jsxs("button",{onClick:()=>r(i.id),title:i.desc,className:`flex flex-col items-center gap-0.5 p-2 rounded-xl border transition-all ${x?i.streakItem?"border-emerald-500/50 bg-emerald-500/15 scale-105":"border-purple-500/50 bg-purple-500/15 scale-105":"border-white/8 bg-white/3 hover:border-white/20 hover:bg-white/6"}`,children:[e.jsx("span",{className:"text-xl leading-none",children:i.emoji}),e.jsx("span",{className:"text-[8px] text-white/50 font-semibold text-center leading-tight",children:i.name}),s&&e.jsx("span",{className:"text-[7px] font-black text-purple-400",children:"RESERVED"}),m&&e.jsx("span",{className:"text-[7px] font-black text-emerald-400",children:"ACTIVE"})]},i.id)})}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 p-2 bg-purple-500/10 border border-purple-500/20 rounded-xl",children:[e.jsx("span",{className:"text-lg leading-none",children:c.emoji}),e.jsxs("span",{className:"text-white/55 text-xs flex-1 leading-tight",children:[c.name," in next battle"]}),e.jsx("button",{onClick:()=>r(null),className:"text-white/25 hover:text-white/60 text-xs transition-all",children:"â"})]})]})}const K=[{id:"SPEED_DEMON",emoji:"ð",name:"Speed Demon",color:"#06b6d4"},{id:"ON_FIRE",emoji:"ð¥",name:"On Fire",color:"#f97316"}
1,{id:"LEGENDARY",emoji:"ð",name:"Legendary",color:"#a855f7",rare:!0},{id:"BOSS_SLAYER",emoji:"âï¸",name:"Boss Slayer",color:"#ef4444",rare:!0},{id:"SURGE_RIDER",emoji:"ðªï¸",name:"Surge Rider",color:"#f59e0b",rare:!0},{id:"CARD_SHARK",emoji:"ð",name:"Card Shark",color:"#8b5cf6"},{id:"DOMINATOR",emoji:"ð§©",name:"Dominator",color:"#fbbf24",rare:!0},{id:"PERFECT",emoji:"ð",name:"Perfect Game",color:"#10b981",rare:!0},{id:"CLUTCH",emoji:"â¡",name:"Clutch",color:"#eab308",rare:!0},{id:"COMEBACK",emoji:"ðª",name:"Comeback Kid",color:"#22c55e",rare:!0},{id:"UNSTOPPABLE",emoji:"ð",name:"Unstoppable",color:"#dc2626",rare:!0},{id:"HIGH_ROLLER",emoji:"ð°",name:"High Roller",color:"#f59e0b"},{id:"TURF_KING",emoji:"ðï¸",name:"Turf King",color:"#22c55e"},{id:"NEMESIS_SLAIN",emoji:"âï¸",name:"Nemesis Slayer",color:"#ef4444",rare:!0},{id:"SURVIVOR_20",emoji:"ð",name:"Survivor",color:"#7c3aed"},{id:"SURVIVOR_50",emoji:"ð±",name:"Apex Survivor",color:"#ec4899",rare:!0}];function ls(){const[t,l]=N.useState([]),[n,a]=N.useState(!1);N.useEffect(()=>{try{l(JSON.parse(localStorage.getItem("sq_unlocked_achievements")||"[]"))}catch{}},[]);const r=K.filter(m=>t.includes(m.id)),c=8,i=[...K].sort((m,x)=>{const h=t.includes(m.id),o=t.includes(x.id);return h===o?0:h?-1:1}),s=n?i:i.slice(0,c);return e.jsxs("div",{className:"bg-white/4 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-white/70 text-sm font-bold",children:"ð
Achievements"}),e.jsxs("div",{className:"text-white/60 text-xs",children:[r.length,"/",K.length]})]}),r.length===0&&e.jsx("p",{className:"text-white/25 text-xs text-center py-2 mb-2",children:"Play battles to earn achievements"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(m=>{const x=t.includes(m.id);return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-bold transition-all ${x?"opacity-100":"opacity-40 grayscale"}`,style:x?{background:`${m.color}18`,border:`1px solid ${m.color}40`,color:m.color}:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.3)"},children:[m.emoji," ",m.name,m.rare&&x&&e.jsx("span",{className:"text-yellow-400 text-[7px] ml-0.5",children:"â¨"})]},m.id)})}),K.length>c&&e.jsx("button",{onClick:()=>a(m=>!m),className:"mt-2 text-white/60 hover:text-white/60 text-xs w-full text-center transition-all",children:n?"Show less â²":`+${K.length-c} more â¼`})]})}function ns({onClose:t,onFound:l}){const[n,a]=N.useState("searching"),[r,c]=N.useState(0),[i,s]=N.useState(1),m=N.useRef(null),x=N.useRef(null),h=()=>{try{return parseInt(localStorage.getItem("sq_rating")||"1200",10)}catch{return 1200}};N.useEffect(()=>{const g=h();return j.post("/api/gamification/v2/matchmaking/queue",{rating:g}).then(p=>{if(p.data.matched){l(p.data.battleId);return}p.data.queueSize&&s(p.data.queueSize)}).catch(()=>a("error")),m.current=setInterval(async()=>{try{const p=await j.get("/api/gamification/v2/matchmaking/status");p.data.matched?(clearInterval(m.current),clearInterval(x.current),a("found"),setTimeout(()=>l(p.data.battleId),800)):p.data.waitSecs!==void 0&&c(p.data.waitSecs)}catch{}},2500),x.current=setInterval(()=>c(p=>p+1),1e3),()=>{clearInterval(m.current),clearInterval(x.current),j.delete("/api/gamification/v2/matchmaking/queue").catch(()=>{})}},[]);const o=()=>{clearInterval(m.current),clearInterval(x.current),j.delete("/api/gamification/v2/matchmaking/queue").catch(()=>{}),t()},b=h(),u=b>=1400?"#a855f7":b>=1200?"#06b6d4":"#9ca3af";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-md",children:[e.jsx("div",{className:"bg-slate-900 border border-white/25 rounded-3xl w-full max-w-sm p-8 text-center shadow-2xl",children:n==="found"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-6xl mb-4 animate-bounce",children:"âï¸"}),e.jsx("h2",{className:"text-white font-black text-2xl mb-2",children:"Opponent Found!"}),e.jsx("p",{className:"text-white/50 text-sm",children:"Loading battle arenaâ¦"})]}):n==="error"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-5xl mb-4",children:"ð"}),e.jsx("h2",{className:"text-white font-black text-xl mb-2",children:"Matchmaking Error"}),e.jsx("p",{className:"text-white/50 text-sm mb-6",children:"Could not reach the server. Try again later."}),e.jsx("button",{onClick:t,className:"px-6 py-2.5 bg-slate-800/80 text-white rounded-xl font-bold hover:bg-slate-700/80 transition-all",children:"Close"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative w-24 h-24 mx-auto mb-6",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-cyan-500/30 animate-ping",style:{animationDuration:"1.5s"}}),e.jsx("div",{className:"absolute inset-2 rounded-full border-2 border-cyan-500/50 animate-ping",style:{animationDuration:"2s"}}),e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-cyan-600/30 to-teal-600/30 border border-cyan-500/40 flex items-center justify-center",children:e.jsx(Ye,{className:"w-10 h-10 text-cyan-400",style:{animation:"spin 3s linear infinite"}})})]}),e.jsx("h2",{className:"text-white font-black text-xl mb-1",children:"Finding Ranked Match"}),e.jsx("p",{className:"text-white/60 text-sm mb-4",children:"Searching for an opponent of similar skillâ¦"}),e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-black text-xl",style:{color:u},children:b}),e.jsx("div",{className:"text-white/60 text-xs",children:"Your Rating"})]}),e.jsx("div",{className:"text-white/50 text-2xl",children:"vs"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-white/60 font-black text-xl",children:"???"}),e.jsx("div",{className:"text-white/60 text-xs",children:"Opponent"})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-6 text-white/60 text-sm",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-cyan-500 rounded-full animate-pulse"}),r,"s · ",i," in queue"]}),e.jsx("button",{onClick:o,className:"px-6 py-2.5 bg-white/8 border border-white/25 text-white/60 rounded-xl font-semibold hover:bg-slate-800/60 transition-all",children:"Cancel"})]})}),e.jsx("style",{children:"@keyframes spin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }"})]})}function rs({onChallenge:t}){const[l,n]=N.useState(null),[a,r]=N.useState(!1),[c,i]=N.useState(!0);return N.useEffect(()=>{j.get("/api/gamification/v2/boss/today").then(({data:s})=>{n(s.boss);const m=`sq_boss_${s.boss?.dateStr||""}`;r(!!localStorage.getItem(m))}).catch(()=>{}).finally(()=>i(!1))},[]),c||!l?null:e.jsxs("div",{className:`mt-4 rounded-2xl p-4 border transition-all ${a?"border-white/8 bg-white/3 opacity-60":"border-red-500/30 bg-red-500/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Je,{size:14,className:a?"text-white/60":"text-red-400"}),e.jsx("span",{className:"text-white/60 text-xs font-semibold uppercase tracking-wide",children:"Daily Boss"}),a&&e.jsx("span",{className:"ml-auto text-emerald-400 text-xs font-bold",children:"â Defeated"}),!a&&e.jsxs("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-red-500/20 border border-red-500/30 text-red-400 font-bold",children:["+",l.xp," XP"]})]}),e.jsxs("div",{className:"flex items-center gap-3 my-2",children:[e.jsx("span",{className:"text-3xl",children:l.emoji}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-black text-sm",children:l.name}),e.jsx("p",{className:"text-white/60 text-xs truncate",children:l.tagline})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/60 mb-3",children:[e.jsx("span",{className:"capitalize",children:l.difficulty}),e.jsx("span",{children:"·"}),e.jsx("span",{children:l.subject}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[l.questionCount," questions"]})]}
1),!a&&e.jsx("button",{onClick:()=>t(l),className:"w-full py-2 bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-500 hover:to-orange-500 text-white text-sm font-black rounded-xl transition-all",children:"âï¸ Challenge Boss"})]})}function is(){const{isAuthenticated:t,user:l}=M(),n=T(),[a,r]=N.useState(null),[c,i]=N.useState([]),[s,m]=N.useState(null),[x,h]=N.useState(!1);return N.useEffect(()=>{j.get("/api/schools/war-room?limit=1").then(o=>{const b=o.data.topSchools||[];if(i(b.slice(0,3)),l?.schoolId){const u=b.find(g=>g.id===l.schoolId);u?(r(u),m(b.indexOf(u)+1||null)):j.get(`/api/schools/${l.schoolId}`).then(g=>g.data.school&&r(g.data.school)).catch(()=>{})}}).catch(()=>{}).finally(()=>h(!0))},[l?.schoolId]),x?t&&a?(a.matchesPlayed>0&&Math.round(a.wins/a.matchesPlayed*100),e.jsxs("div",{className:"rounded-2xl border p-4 mb-4",style:{background:`${a.colorPrimary}10`,borderColor:`${a.colorPrimary}30`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full ring-1 ring-white/20",style:{background:a.colorPrimary}}),e.jsx("span",{className:"text-white/50 text-xs font-semibold uppercase tracking-wider",children:"Your School"})]}),s&&e.jsxs("span",{className:"text-white/60 text-xs font-bold",children:["#",s," nationally"]})]}),e.jsx("div",{className:"font-black text-white text-base mb-3 leading-tight truncate",children:a.name}),e.jsx("div",{className:"grid grid-cols-3 gap-2 mb-3 text-center",children:[{label:"Points",val:(a.totalPoints||0).toLocaleString()},{label:"W/L",val:`${a.wins||0}/${a.losses||0}`},{label:"Members",val:a.memberCount||0}].map(({label:o,val:b})=>e.jsxs("div",{className:"bg-white/6 rounded-lg py-1.5",children:[e.jsx("div",{className:"text-white font-black text-sm",children:b}),e.jsx("div",{className:"text-white/60 text-[10px]",children:o})]},o))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{to:`/schools/${a.slug}`,className:"flex-1 text-center text-xs font-bold py-2 rounded-xl transition-all hover:opacity-80",style:{background:`${a.colorPrimary}20`,color:a.colorPrimary,border:`1px solid ${a.colorPrimary}35`},children:"School Profile"}),e.jsx(B,{to:"/school-war-room",className:"flex-1 text-center text-xs font-bold py-2 rounded-xl bg-white/6 border border-white/25 text-white/60 hover:text-white/90 hover:bg-slate-700/60 transition-all",children:"âï¸ War Room"})]})]})):e.jsxs("div",{className:"bg-white/3 border border-white/8 rounded-2xl p-4 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-white/50 text-xs font-semibold uppercase tracking-wider",children:"ð« School Standings"}),e.jsx(B,{to:"/schools",className:"text-white/60 hover:text-white/60 text-xs transition-colors",children:"All â"})]}),c.length>0?e.jsx("div",{className:"space-y-1.5 mb-3",children:c.map((o,b)=>e.jsxs(B,{to:`/schools/${o.slug}`,className:"flex items-center gap-2.5 px-2 py-1.5 rounded-xl hover:bg-white/6 transition-all group",children:[e.jsx("span",{className:"text-white/60 text-xs w-4 text-right flex-shrink-0",children:["ð¥","ð¥","ð¥"][b]}),e.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.colorPrimary||"#7c3aed"}}),e.jsx("span",{className:"flex-1 text-white/70 text-xs font-semibold truncate group-hover:text-white/90",children:o.name}),e.jsx("span",{className:"text-white/60 text-xs font-bold flex-shrink-0",children:(o.totalPoints||0).toLocaleString()})]},o.id))}):e.jsx("p",{className:"text-white/25 text-xs mb-3",children:"No schools ranked yet â be the first!"}),e.jsx("button",{onClick:()=>n(t?"/scholastic-league":"/signup"),className:"w-full py-2 text-xs font-bold rounded-xl bg-gradient-to-r from-purple-600/80 to-blue-600/80 text-white hover:opacity-90 transition-all",children:t?"Join the Scholastic League â":"Represent your school â"})]}):null}function os(){const[t,l]=N.useState([]),n=T();return N.useEffect(()=>{const a=()=>{j.get("/api/gamification/v2/battles/live").then(({data:c})=>l(c.battles||[])).catch(()=>{})};a();const r=setInterval(a,1e4);return()=>clearInterval(r)},[]),t.length===0?null:e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Live Battles"}),e.jsx("span",{className:"ml-auto text-white/25 text-xs",children:"Auto-updates"})]}),e.jsx("div",{className:"space-y-2",children:t.slice(0,5).map(a=>{const r=(a.participants||[]).map(c=>c.user?.firstName||c.user?.username||"Player").join(" vs ");return e.jsxs("div",{className:"flex items-center gap-2 bg-white/3 rounded-xl px-3 py-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white text-xs font-semibold truncate",children:a.title}),r&&e.jsx("p",{className:"text-white/60 text-xs truncate",children:r})]}),e.jsxs("button",{onClick:()=>n(`/brain-battles/spectate/${a.id}`),className:"flex-shrink-0 flex items-center gap-1 text-xs text-red-400 hover:text-red-300 font-semibold",children:[e.jsx(ve,{size:11})," Watch"]})]},a.id)})})]})}const Z=[{tier:1,xp:500,emoji:"ð",label:"Title"},{tier:2,xp:1500,emoji:"â¡",label:"XP Boost"},{tier:3,xp:3e3,emoji:"âï¸",label:"Title"},{tier:4,xp:5500,emoji:"ð",label:"XP Boost"},{tier:5,xp:9e3,emoji:"ð
",label:"Badge"},{tier:6,xp:14e3,emoji:"ð",label:"Title"},{tier:7,xp:2e4,emoji:"ð",label:"Title"},{tier:8,xp:28e3,emoji:"ð",label:"Boost"},{tier:9,xp:38e3,emoji:"ð",label:"Legend"}];function cs(){const[t,l]=N.useState(0),[n,a]=N.useState(0);N.useEffect(()=>{try{l(parseInt(localStorage.getItem("sq_season_xp")||"0",10)),a(parseInt(localStorage.getItem("sq_season_tier")||"0",10))}catch{}},[]);const r=Z[Z.length-1].xp,c=Math.min(t/r,1),i=Z.find(s=>s.tier>n);return e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-base",children:"ðï¸"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Season 1 Battle Pass"}),e.jsx("span",{className:"ml-auto text-white/25 text-xs",children:"MarâMay 2026"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex justify-between text-xs text-white/60 mb-1",children:[e.jsxs("span",{children:[t.toLocaleStr
1ing()," Season XP"]}),i&&e.jsxs("span",{children:["Next: ",i.xp.toLocaleString()," XP"]})]}),e.jsx("div",{className:"h-2 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${c*100}%`,background:"linear-gradient(90deg, #3b82f6, #8b5cf6)"}})})]}),e.jsx("div",{className:"flex items-center justify-between",children:Z.map(s=>{const m=n>=s.tier;return e.jsxs("div",{className:"flex flex-col items-center gap-0.5",title:s.label,children:[e.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center text-base transition-all ${m?"bg-blue-500/25 border border-blue-400/40":"bg-slate-700/40 border border-white/8 opacity-40"}`,children:s.emoji}),e.jsx("span",{className:"text-white/50 text-[9px]",children:s.tier})]},s.tier)})}),n>=Z.length&&e.jsx("p",{className:"text-center text-amber-400 font-black text-xs mt-2",children:"ð Season Completed!"})]})}function ds(){const[t,l]=N.useState(null),[n,a]=N.useState(!0),r=T();return N.useEffect(()=>{j.get("/api/gamification/v2/guilds/mine").then(({data:c})=>l(c.guild||null)).catch(()=>{}).finally(()=>a(!1))},[]),n?null:t?e.jsx("div",{className:"mt-4 bg-emerald-500/5 border border-emerald-500/20 rounded-2xl p-4 cursor-pointer hover:bg-emerald-500/10 transition-colors",onClick:()=>r("/brain-battles/guilds"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl flex-shrink-0",children:t.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-white font-black text-sm truncate",children:t.name}),e.jsxs("div",{className:"text-emerald-400/60 text-xs",children:[t.guildXP?.toLocaleString()||0," Guild XP · ",t.members?.length,"/",t.maxMembers," members"]})]}),e.jsx(we,{size:14,className:"text-emerald-400 flex-shrink-0"})]})}):e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(we,{size:14,className:"text-emerald-400"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Guild"})]}),e.jsx("p",{className:"text-white/60 text-xs mb-3",children:"Join a study clan to pool XP and climb the guild leaderboard."}),e.jsx("button",{onClick:()=>r("/brain-battles/guilds"),className:"w-full py-2 bg-emerald-600/20 border border-emerald-500/30 hover:bg-emerald-600/30 text-emerald-300 text-xs font-bold rounded-xl transition-colors",children:"Browse Guilds"})]})}function xs(){const[t,l]=N.useState(null),[n,a]=N.useState(!0),r=T();if(N.useEffect(()=>{j.get("/api/gamification/v2/guilds/war").then(({data:x})=>l(x)).catch(()=>{}).finally(()=>a(!1))},[]),n)return null;const c=t?.leaderboard||[],i=t?.weekKey||"",s=i?`Week of ${i}`:"This Week";if(c.length===0)return e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-base",children:"âï¸"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Guild War"})]}),e.jsx("p",{className:"text-white/60 text-xs",children:"No guilds competing yet. Join a guild and win battles to earn war XP!"})]});const m=["ð¥","ð¥","ð¥"];return e.jsxs("div",{className:"mt-4 bg-amber-500/5 border border-amber-500/20 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"âï¸"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Guild War"})]}),e.jsx("span",{className:"text-white/60 text-[10px]",children:s})]}),e.jsx("div",{className:"space-y-2",children:c.slice(0,5).map((x,h)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm w-5 flex-shrink-0 text-center",children:m[h]||`${h+1}.`}),e.jsx("span",{className:"text-base",children:x.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-white/80 text-xs font-bold truncate",children:x.name}),e.jsxs("div",{className:"text-amber-400/60 text-[10px]",children:[x.wins," win",x.wins!==1?"s":""]})]}),e.jsxs("span",{className:"text-amber-300 text-xs font-black",children:[(x.xp??0).toLocaleStr
1ing()," XP"]})]},x.name+h))}),e.jsx("button",{onClick:()=>r("/brain-battles/guilds"),className:"w-full mt-3 py-1.5 text-[10px] font-bold text-amber-400/70 hover:text-amber-300 transition-colors border-t border-white/20 pt-2",children:"View Guilds â"})]})}function ms(){const[t,l]=N.useState(null),[n,a]=N.useState(!0),r=T();if(N.useEffect(()=>{j.get("/api/gamification/v2/guilds/missions").then(({data:i})=>l(i)).catch(()=>{}).finally(()=>a(!1))},[]),n||!t)return null;const c=t.missions||[];return c.length===0?null:e.jsxs("div",{className:"mt-4 bg-violet-500/5 border border-violet-500/20 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð¯"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Guild Missions"})]}),e.jsx("span",{className:"text-white/60 text-[10px]",children:"Weekly collective goals"})]}),e.jsx("div",{className:"space-y-3",children:c.map(i=>{const s=Math.min(100,Math.round(i.progress/i.goal*100)),m=s>=100;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm",children:i.emoji}),e.jsx("span",{className:`text-xs font-bold ${m?"text-violet-300":"text-white/70"}`,children:i.label}),m&&e.jsx("span",{className:"text-[9px] bg-violet-500/30 text-violet-300 px-1.5 py-0.5 rounded-full font-bold",children:"DONE â"})]}),e.jsxs("span",{className:"text-[10px] text-white/60",children:[(i.progress??0).toLocaleString()," / ",(i.goal??0).toLocaleString()]})]}),e.jsx("div",{className:"h-1.5 bg-white/8 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${m?"bg-violet-400":"bg-violet-600"}`,style:{width:`${s}%`}})}),e.jsxs("div",{className:"text-right text-[9px] text-violet-400/50 mt-0.5",children:["+",i.xp," XP reward"]})]},i.id)})}),e.jsx("button",{onClick:()=>r("/brain-battles/guilds"),className:"w-full mt-3 py-1.5 text-[10px] font-bold text-violet-400/70 hover:text-violet-300 transition-colors border-t border-white/20 pt-2",children:"View Guild â"})]})}function hs(){const[t,l]=d.useState(null),[n,a]=d.useState(!1),[r,c]=d.useState([]),[i,s]=d.useState(!1),[m,x]=d.useState(""),{isAuthenticated:h}=M(),o=()=>{if(!h)return;const v=localStorage.getItem("token");v&&(j.get("/api/gamification/v2/streaks/my",{headers:{Authorization:`Bearer ${v}`}}).then(S=>l(S.data.streak)).catch(()=>{}),j.get("/api/gamification/v2/streaks/leaderboard").then(S=>c(S.data.leaderboard||[])).catch(()=>{}))};d.useEffect(()=>{o()},[h]);const b=async()=>{s(!0),x("");try{const v=localStorage.getItem("token"),S=parseInt(localStorage.getItem("sq_xp")||"0",10);if(S<100){x("Need 100 XP to freeze.");return}await j.post("/api/gamification/v2/streaks/checkin",{freeze:!0},{headers:{Authorization:`Bearer ${v}`}}),localStorage.setItem("sq_xp",String(S-100)),x("Streak frozen for today!"),o()}catch(v){x(v.response?.data?.error||"Failed.")}finally{s(!1)}};if(!h)return null;const u=t?.current||0,g=t?.multiplier||1,p=t?.frozenUntil===new Date().toISOString().slice(0,10),f=u>=30?"#ef4444":u>=14?"#f97316":u>=7?"#fb923c":u>=3?"#fbbf24":"#94a3b8";return e.jsxs("div",{className:"rounded-2xl border overflow-hidden",style:{borderColor:f+"35",background:`linear-gradient(135deg, ${f}10, transparent)`},children:[e.jsxs("button",{onClick:()=>a(v=>!v),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2",style:{color:f},children:["ð¥ ",u,"-Day Streak",g>1&&e.jsxs("span",{className:"text-[10px] bg-orange-500/20 text-orange-300 px-1.5 py-0.5 rounded font-bold",children:[g,"x XP"]}),p&&e.jsx("span",{className:"text-[10px] bg-blue-500/20 text-blue-300 px-1.5 py-0.5 rounded",children:"frozen"})]}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"grid grid-cols-3 gap-2 text-center",children:[{label:"Current",value:u},{label:"Longest",value:t?.longest||0},{label:"Multiplier",value:`${g}x`}].map(v=>e.jsxs("div",{className:"bg-slate-700/40 rounded-xl p-2",children:[e.jsx("div",{className:"font-black text-lg",style:{color:f},children:v.value}),e.jsx("div",{className:"text-white/60 text-[10px]",children:v.label})]},v.label))}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-[10px] text-white/60 mb-1",children:[e.jsx("span",{children:"Next milestone"}),e.jsx("span",{children:u<3?`${3-u}d to 1.25x`:u<7?`${7-u}d to 1.5x`:u<14?`${14-u}d to 1.75x`:u<30?`${30-u}d to 2.0x`:"MAX"})]}),e.jsx("div",{className:"h-1 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.min(100,u/30*100)}%`,background:f}})})]}),!p&&u>0&&e.jsx("button",{onClick:b,disabled:i,className:"w-full py-2 bg-blue-600/20 border border-blue-500/25 text-blue-300 text-xs font-bold rounded-xl hover:bg-blue-600/30 transition-all disabled:opacity-50",children:i?"...":"Freeze Streak (â100 XP)"}),m&&e.jsx("p",{className:"text-xs text-center text-white/60",children:m}),r.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-white/60 text-[10px] uppercase tracking-wider mb-1.5",children:"Top Streaks"}),r.slice(0,5).map((v,S)=>e.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-xs",children:[e.jsx("span",{className:"text-white/25 w-4",children:S+1}),e.jsx("span",{className:"flex-1 truncate text-white/70 font-semibold",children:v.username}),e.jsxs("span",{style:{color:f},className:"font-bold",children:[v.current,"ð¥"]})]}
1,v.userId))]})]})]})}function us(){const t=new Date().getDay();if(t!==0&&t!==6)return null;const l=t===6?"Saturday":"Sunday";return e.jsx("div",{className:"flex justify-center mb-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-full text-sm font-bold animate-pulse",style:{background:"rgba(251,191,36,0.15)",border:"1px solid rgba(251,191,36,0.5)",color:"#fbbf24"},children:["ð",e.jsxs("span",{children:[e.jsxs("strong",{children:[l," Double XP Event!"]})," All XP earned today is 2à â fight more battles!"]}),e.jsx("span",{className:"text-amber-400/40 font-normal text-xs",children:"(ends midnight)"})]})})}function ps(){const[t,l]=N.useState(null),[n,a]=N.useState(0),[r,c]=N.useState(!0),i=N.useRef(null);if(N.useEffect(()=>{j.get("/api/gamification/v2/events/live").then(({data:o})=>{o.event&&(l(o.event),a(o.event.secondsLeft||0))}).catch(()=>{}).finally(()=>c(!1))},[]),N.useEffect(()=>{if(t)return i.current=setInterval(()=>{a(o=>Math.max(0,o-1))},1e3),()=>clearInterval(i.current)},[t]),r||!t)return null;const s=Math.floor(n/3600),m=Math.floor(n%3600/60),x=n%60,h=s>0?`${s}h ${m}m left`:m>0?`${m}m ${x}s left`:`${x}s left`;return e.jsxs("div",{className:"mt-4 rounded-2xl p-4 border",style:{background:`${t.color}0d`,borderColor:`${t.color}40`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xl",children:t.emoji}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-black text-sm",style:{color:t.color},children:t.name}),e.jsxs("span",{className:"text-xs font-black px-1.5 py-0.5 rounded-full",style:{background:`${t.color}20`,border:`1px solid ${t.color}40`,color:t.color},children:[t.mult,"à XP"]})]}),e.jsxs("div",{className:"text-white/60 text-xs mt-0.5",children:[t.desc," · ",h]})]})]}),e.jsx("div",{className:"relative h-1 rounded-full bg-slate-700/40 overflow-hidden",children:e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full animate-pulse",style:{width:"60%",background:t.color,opacity:.6}})})]})}const be=[{label:"25 XP",xp:25,color:"#6b7280",emoji:"ð«",weight:30},{label:"50 XP",xp:50,color:"#6366f1",emoji:"â",weight:25},{label:"75 XP",xp:75,color:"#8b5cf6",emoji:"â¨",weight:18},{label:"100 XP",xp:100,color:"#06b6d4",emoji:"ð",weight:12},{label:"150 XP",xp:150,color:"#f59e0b",emoji:"ð¥",weight:8},{label:"300 XP",xp:300,color:"#f97316",emoji:"ð",weight:5},{label:"500 XP",xp:500,color:"#a855f7",emoji:"ð",weight:2}];function bs(){const t=be.reduce((n,a)=>n+a.weight,0);let l=Math.random()*t;for(const n of be)if(l-=n.weight,l<=0)return n;return be[0]}function gs(){const t=new Date().toISOString().slice(0,10),[l,n]=N.useState(!1),[a,r]=N.useState(null),[c,i]=N.useState(!1);N.useEffect(()=>{try{localStorage.getItem("sq_spin_date")===t&&(n(!0),r(JSON.parse(localStorage.getItem("sq_spin_last")||"null")))}catch{}},[t]);const s=()=>{c||l||(i(!0),setTimeout(()=>{const x=bs();try{const h=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(h+x.xp)),localStorage.setItem("sq_spin_date",t),localStorage.setItem("sq_spin_last",JSON.stringify(x))}catch{}r(x),n(!0),i(!1)},2400))},m=["ð«","â","â¨","ð","ð¥","ð","ð"];return e.jsxs("div",{className:"mt-4 bg-gradient-to-b from-purple-500/8 to-pink-500/5 border border-purple-500/20 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-base",children:"ð°"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Daily XP Spin"}),e.jsx("span",{className:"ml-auto text-white/25 text-[10px]",children:"1à per day"})]}),l&&a?e.jsxs("div",{className:"text-center py-1",children:[e.jsx("div",{className:"text-4xl mb-2 animate-bounce",style:{filter:`drop-shadow(0 0 8px ${a.color})`},children:a.emoji}),e.jsxs("div",{className:"font-black text-lg",style:{color:a.color},children:["+",a.label]}),e.jsx("div",{className:"text-white/60 text-xs mt-1",children:"XP awarded! Come back tomorrow."})]}):e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center items-center gap-0.5 mb-3 overflow-hidden h-10",children:m.map((x,h)=>e.jsx("div",{className:"text-xl w-8 text-center flex-shrink-0",style:{animation:c?`spinSlot ${.1+h*.04}s linear infinite`:"none",opacity:c?1:.4+(h===3?.6:0),transition:"opacity 0.3s"},children:x},h))}),e.jsx("button",{onClick:s,disabled:c||l,className:`w-full py-2.5 rounded-xl font-black text-sm transition-all ${c?"bg-purple-600/30 text-purple-300/60 cursor-wait":"bg-gradient-to-r from-purple-600 to-pink-600 text-white hover:scale-[1.02] hover:shadow-lg hover:shadow-
1purple-600/30"}`,children:c?"â³ Spinningâ¦":"ð° Spin for XP!"})]}),e.jsx("style",{children:` 2 @keyframes spinSlot { 3 0% { transform: translateY(0); } 4 50% { transform: translateY(-20px); } 5 100% { transform: translateY(0); } 6 } 7 `})]})}const We=[{id:"wc_win5",label:"Win 5 Battles",icon:"âï¸",goal:5,xp:100,key:"sq_wc_wins"},{id:"wc_survive30",label:"Survive 30 Questions",icon:"ð",goal:30,xp:150,key:"sq_wc_survival"},{id:"wc_ranked3",label:"Play 3 Ranked Matches",icon:"ð ",goal:3,xp:120,key:"sq_wc_ranked"},{id:"wc_correct50",label:"Answer 50 Questions Correct",icon:"â ",goal:50,xp:200,key:"sq_wc_correct"}];function fs(){const[t,l]=N.useState({}),[n,a]=N.useState([]);N.useEffect(()=>{const c={};for(const i of We)c[i.id]=parseInt(localStorage.getItem(i.key)||"0",10);l(c);try{a(JSON.parse(localStorage.getItem("sq_wc_claimed")||"[]"))}catch{}},[]);const r=c=>{if(n.includes(c.id))return;const i=[...n,c.id];a(i),localStorage.setItem("sq_wc_claimed",JSON.stringify(i));try{const s=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(s+c.xp))}catch{}};return e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsx("h3",{className:"text-white font-black text-sm",children:"Weekly Challenges"}),e.jsx("span",{className:"ml-auto text-white/25 text-xs",children:"Resets Monday"})]}),e.jsx("div",{className:"space-y-2.5",children:We.map(c=>{const i=Math.min(t[c.id]||0,c.goal),s=i>=c.goal,m=n.includes(c.id),x=Math.round(i/c.goal*100);return e.jsxs("div",{className:`rounded-xl p-3 border transition-all ${s&&!m?"border-emerald-400/40 bg-emerald-400/5":m?"border-white/20 bg-white/3 opacity-50":"border-white/8 bg-white/3"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-sm",children:c.icon}),e.jsx("span",{className:"text-white/80 text-xs font-semibold flex-1",children:c.label}),e.jsxs("span",{className:"text-amber-400 text-xs font-bold",children:["+",c.xp," XP"]}),s&&!m&&e.jsx("button",{onClick:()=>r(c),className:"px-2 py-0.5 bg-emerald-500 hover:bg-emerald-400 text-black text-xs font-black rounded-lg transition-colors",children:"Claim!"}),m&&e.jsx("span",{className:"text-emerald-400 text-xs",children:"â Done"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-1.5 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${x}%`,background:s?"#10b981":"#8b5cf6"}})}),e.jsxs("span",{className:"text-white/60 text-xs",children:[i,"/",c.goal]})]})]},c.id)})})]})}function js({onClose:t,currentUserId:l,onChallenge:n}){const[a,r]=d.useState("friends"),[c,i]=d.useState([]),[s,m]=d.useState([]),[x,h]=d.useState(""),[o,b]=d.useState([]),[u,g]=d.useState(!1),[p,f]=d.useState(""),[v,S]=d.useState(new Set),[C,P]=d.useState(null),y=k=>{f(k),setTimeout(()=>f(""),3e3)},$=async()=>{try{const k=await j.get("/api/gamification/v2/friends");i(k.data.friends||[]),m(k.data.pending||[])}catch{}};d.useEffect(()=>{$()},[]);const A=async()=>{if(!(x.trim().length<2)){g(!0);try{const k=await j.get(`/api/gamification/v2/friends/search?q=${encodeURIComponent(x.trim())}`);b(k.data.users||[])}catch{b([])}finally{g(!1)}}},I=async(k,z)=>{try{await j.post("/api/gamification/v2/friends/request",{toUserId:k,toName:z}),S(W=>new Set([...W,String(k)])),y(`Request sent to ${z}!`)}catch(W){y(W.response?.data?.error||"Could not send request")}},R=async(k,z)=>{try{await j.put(`/api/gamification/v2/friends/${k}/accept`),y(`You and ${z} are now friends!`),$()}catch{y("Failed to accept")}},L=async k=>{try{await j.put(`/api/gamification/v2/friends/${k}/decline`),$()}catch{}},le=async(k,z)=>{if(C!==k){P(k);return}P(null);try{await j.delete(`/api/gamification/v2/friends/${k}`),i(W=>W.filter(de=>de.userId!==String(k))),y(`Removed ${z}`)}catch{y("Failed to remove")}},ne=async k=>{t(),n(k)};return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",onClick:t,children:[e.jsxs("div",{className:"w-full max-w-sm bg-[#0d0d1a] border-l border-white/25 h-full overflow-y-auto shadow-2xl flex flex-col",onClick:k=>k.stopPropagation(),style:{animation:"slideInRight 0.25s ease-out"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-white/25 sticky top-0 bg-[#0d0d1a] z-10",children:[e.jsx(oe,{className:"w-5 h-5 text-purple-400"}),e.jsx("h2",{className:"text-white font-black text-lg flex-1",children:"Friends"}),e.jsx("button",{onClick:t,className:"p-1.5 text-white/60 hover:text-white transition-colors",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex border-b border-white/25",children:[{key:"friends",label:`Friends (${c.length})`},{key:"requests",label:`Requests${s.length>0?` (${s.length})`:""}`},{key:"search",label:"Add Friends"}].map(k=>e.jsx("button",{onClick:()=>r(k.key),className:`flex-1 py-3 text-xs font-bold transition-all ${a===k.key?"text-purple-400 border-b-2 border-purple-400 bg-purple-500/5":"text-white/40 hover:text-white/70"}`,children:k.label},k.key))}),e.jsxs("div",{className:"flex-1 p-4 space-y-3",children:[a==="friends"&&e.jsx(e.Fragment,{children:c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(oe,{className:"w-12 h-12 text-white/60 mx-auto mb-3"}),e.jsx("p",{className:"text-white/60 text-sm",children:"No friends yet"}),e.jsx("button",{onClick:()=>r("search"),className:"mt-3 text-purple-400 text-xs hover:text-purple-300 underline",children:"Find friends â"})]}):c.map(k=>e.jsxs("div",{className:"flex items-center gap-3 bg-slate-700/40 border border-white/25 rounded-xl px-3 py-3 hover:border-white/20 transition-all",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center font-black text-sm text-white",children:(k.name||"?")[0].toUpperCase()}),k.online&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-400 rounded-full border-2 border-[#0d0d1a]"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-semibold text-sm truncate",children:k.name}),e.jsx("p",{className:`text-xs ${k.online?"text-green-400":"text-white/60"}`,children:k.online?"â Online":"â Offline"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[k.online&&e.jsx("button",{onClick:()=>ne(k),title:"Challenge",className:"p-1.5 bg-purple-600/20 text-purple-400 rounded-lg hover:bg-purple-600/40 transition-all text-xs font-bold px-2.5 py-1.5",children:"âï¸ Challenge"}),C===k.userId?e.jsxs("span",{className:"flex items-center gap-1 text-xs",children:[e.jsx("span",{className:"text-red-400",children:"Remove?"}),e.jsx("button",{onClick:()=>le(k.userId,k.name),className:"px-1.5 py-0.5 bg-red-600/30 text-red-400 rounded hover:bg-red-600/50 transition-all font-bold",children:"Yes"}),e.jsx("button",{onClick:()=>P(null),className:"px-1.5 py-0.5 bg-slate-800/80 text-white/50 rounded hover:bg-slate-700/80 transition-all font-bold",children:"No"})]}):e.jsx("button",{onClick:()=>le(k.userId,k.name),title:"Remove friend",className:"p-1.5 text-white/50 hover:text-red-400 transition-colors",children:e.jsx(qe,{className:"w-4 h-4"})})]})]},k.userId))}),a==="requests"&&e.jsx(e.Fragment,{children:s.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ne,{className:"w-12 h-12 text-white/60 mx-auto mb-3"}),e.jsx("p",{className:"text-white/60 text-sm",children:"No pending requests"})]}):s.map(k=>e.jsxs("div",{className:"flex items-center gap-3 bg-yellow-500/5 border border-yellow-500/20 rounded-xl px-3 py-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-yellow-500/20 flex items-center justify-center font-black text-sm text-yellow-300 flex-shrink-0",children:(k.fromName||"?")[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-semibold text-sm truncate",children:k.fromName}),e.jsx("p",{className:"text-white/60 text-xs",children:"wants to be friends"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("button",{onClick:()=>R(k.fromUserId,k.fromName),className:"p-1.5 bg-green-500/20 text-green-400 rounded-lg hover:bg-green-500/30 transition-all",children:e.jsx(Pt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>L(k.fromUserId),className:"p-1.5 bg-red-500/10 text-red-400 rounded-lg hover:bg-red-500/20 transition-all",children:e.jsx(qe,{className:"w-4 h-4"})})]})]},k.fromUserId))}),a==="search"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(It,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-white/60"}),e.jsx("input",{type:"text",value:x,onChange:k=>h(k.target.value),onKeyDown:k=>k.key==="Enter"&&A(),placeholder:"Search by name...",className:"w-full pl-9 pr-3 py-2.5 bg-slate-700/40 border border-white/25 rounded-xl text-white text-sm placeholder-white/50 focus:outline-none focus:border-purple-500/50"})]}),e.jsx("button",{onClick:A,className:"px-4 py-2.5 bg-purple-600 text-white text-sm font-bold rounded-xl hover:bg-purple-500 transition-all",children:u?"...":"Search"})]}),e.jsx("p",{className:"text-white/50 text-xs text-center",children:"Players who have visited Brain Battles recently will appear here"}),o.length===0&&!u&&x.length>=2&&e.jsxs("p",{className:"text-center text-white/60 text-sm py-4",children:['No users found for "',x,'"']}),o.map(k=>e.jsxs("div",{className:"flex items-center gap-3 bg-slate-700/40 border border-white/25 rounded-xl px-3 py-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-indigo-600/30 flex items-center justify-center font-black text-sm text-indigo-300",children:(k.name||"?")[0].toUpperCase()}),k.online&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-400 rounded-full border-2 border-[#0d0d1a]"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-semibold text-sm truncate",children:k.name}),e.jsx("p",{className:`text-xs ${k.online?"text-green-400":"text-white/60"}`,children:k.online?"â Online now":"â Recently active"})]}),v.has(String(k.userId))?e.jsx("span",{className:"text-xs text-green-400 font-semibold",children:"â Sent"}):e.jsxs("button",{onClick:()=>I(k.userId,k.name),className:"flex items-center gap-1.5 px-3 py-1.5 bg-purple-600/20 text-purple-400 border border-purple-500/30 rounded-lg text-xs font-bold hover:bg-purple-600/40 transition-all",children:[e.jsx($t,{className:"w-3.5 h-3.5"})," Add"]})]},k.userId))]})]}),p&&e.jsx("div",{className:"sticky bottom-4 mx-4 bg-slate-800/80 backdrop-blur border border-white/20 text-white text-sm px-4 py-3 rounded-xl text-center",children:p})]}),e.jsx("style",{children:` 8 @keyframes slideInRight { 9 from { transform: translateX(100%); } 10 to { transform: translateX(0); } 11 } 12 `})]})}function ws({friend:t,onClose:l,onCreate:n}
12){const[a,r]=d.useState("General"),[c,i]=d.useState("1v1"),[s,m]=d.useState(!1),[x,h]=d.useState(!1),[o,b]=d.useState(""),u=["General","Math","Physics","Chemistry","Biology","History","CS","Literature"],g=async()=>{m(!0);try{const p=await j.post("/api/gamification/v2/friends/challenge",{toUserId:t.userId,toName:t.name,subject:a,battleType:c});h(!0),setTimeout(()=>{n(p.data.battleId),l()},1800)}catch(p){console.warn("Challenge send failed:",p.response?.data?.error||p.message),b(p.response?.data?.error||"Failed to send challenge"),m(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm",onClick:l,children:e.jsx("div",{className:"bg-[#0d0d1a] border border-white/25 rounded-2xl p-6 w-full max-w-sm mx-4 shadow-2xl",onClick:p=>p.stopPropagation(),children:x?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"text-4xl mb-3",children:"âï¸"}),e.jsx("h3",{className:"text-white font-black text-xl mb-1",children:"Challenge Sent!"}),e.jsx("p",{className:"text-white/50 text-sm",children:"Navigating to battle lobby..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center font-black text-white",children:(t.name||"?")[0].toUpperCase()}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-white font-black",children:["Challenge ",t.name]}),e.jsx("p",{className:"text-white/60 text-xs",children:"Direct friend battle"})]}),e.jsx("button",{onClick:l,className:"ml-auto text-white/60 hover:text-white",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsx("label",{className:"block text-white/50 text-xs font-semibold mb-1.5",children:"SUBJECT"}),e.jsx("select",{value:a,onChange:p=>r(p.target.value),className:"w-full bg-slate-700/40 border border-white/25 rounded-xl px-3 py-2.5 text-white text-sm mb-4 focus:outline-none focus:border-purple-500/50",children:u.map(p=>e.jsx("option",{value:p,children:p},p))}),e.jsx("label",{className:"block text-white/50 text-xs font-semibold mb-1.5",children:"MODE"}),e.jsx("div",{className:"flex gap-2 mb-5",children:["1v1","speed_blitz","territory_control"].map(p=>e.jsx("button",{onClick:()=>i(p),className:`flex-1 py-2 rounded-xl text-xs font-bold transition-all border ${c===p?"bg-purple-600 border-purple-500 text-white":"border-white/25 text-white/40 hover:border-white/20 hover:text-white/70"}`,children:p==="1v1"?"1v1 Classic":p==="speed_blitz"?"â¡ Speed Blitz":"ðºï¸ Territory"},p))}),o&&e.jsx("p",{className:"text-red-400 text-xs mb-3 text-center",children:o}),e.jsx("button",{onClick:g,disabled:s,className:"w-full py-3 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-black rounded-xl hover:scale-105 transition-all disabled:opacity-50",children:s?"Sending...":"âï¸ Send Challenge"})]})})})}function Ns({player:t,onChallenge:l,isAuthenticated:n}){const[a,r]=d.useState({x:0,y:0}),[c,i]=d.useState(!1),[s,m]=d.useState(!1),x=d.useRef(null),h=u=>{const g=u.currentTarget.getBoundingClientRect();r({x:g.right+8,y:g.top}),clearTimeout(x.current),x.current=setTimeout(()=>i(!0),320)},o=()=>{clearTimeout(x.current),i(!1)},b=async()=>{try{await j.post("/api/gamification/v2/friends/request",{toUserId:t.userId,toName:t.name}),m(!0)}catch{}};return e.jsxs("span",{className:"relative cursor-pointer",onMouseEnter:h,onMouseLeave:o,children:[e.jsx("span",{className:"underline decoration-dotted decoration-white/20",children:t.name}),c&&e.jsxs("div",{className:"fixed z-50 w-52 bg-[#0d0d1a] border border-white/15 rounded-2xl shadow-2xl p-4",style:{left:Math.min(a.x,window.innerWidth-220),top:Math.min(a.y,window.innerHeight-200)},onMouseEnter:()=>i(!0),onMouseLeave:o,children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-purple-600 to-blue-700 flex items-center justify-center font-black text-white text-sm",children:(t.name||"?")[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-black text-sm truncate",children:t.name}),e.jsxs("p",{className:"text-white/60 text-xs",children:["#",t.rank??"?"," ranked"]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-black text-sm",children:t.wins??0}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"wins"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-yellow-400 font-bold text-sm",children:t.bestScore??0}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"best"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-green-400 font-bold text-sm",children:[t.winRate??0,"%"]}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"win rate"})]})]}),e.jsx(B,{to:`/brain-battles/player/${t.userId}`,onClick:o,className:"block text-center text-[10px] text-indigo-400 hover:text-indigo-300 font-semibold mb-2 underline decoration-dotted",children:"View full profile â"}),n&&e.jsxs("div",{className:"flex gap-1.5",children:[l&&e.jsx("button",{onClick:()=>{o(),l(t)},className:"flex-1 py-1.5 bg-purple-600/20 text-purple-400 text-xs font-bold rounded-lg hover:bg-purple-600/40 transition-all",children:"âï¸ Challenge"}),s?e.jsx("span",{className:"flex-1 py-1.5 text-green-400 text-xs font-bold text-center",children:"â Sent"}):e.jsx("button",{onClick:b,className:"flex-1 py-1.5 bg-slate-700/40 text-white/50 text-xs font-bold rounded-lg hover:bg-slate-700/60 transition-all",children:"+ Friend"})]})]})]})}const Ue={default:{ring:"#4b5563",width:2,shadow:"none"},bronze:{ring:"#b45309",width:3,shadow:"0 0 6px #b4530980"},silver:{ring:"#9ca3af",width:3,shadow:"0 0 6px #9ca3af80"},gold:{ring:"#eab308",width:3,shadow:"0 0 10px #eab30870"},platinum:{ring:"#06b6d4",width:3,shadow:"0 0 10px #06b6d480"},diamond:{ring:"#a855f7",width:4,shadow:"0 0 14px #a855f780"},scholar:{ring:"#4ade80",width:3,shadow:"0 0 10px #4ade8060"},legend:{ring:"#f59e0b",width:4,shadow:"0 0 16px #f59e0b90"},founder:{ring:"#ec4899",width:4,shadow:"0 0 14px #ec489990"}};function vs(t){return Ue[t]||Ue.default}function ys(){const[t,l]=d.useState([]),[n,a]=d.useState(!0);if(d.useEffect(()=>{const s=async()=>{try{const x=await j.get("/api/gamification/v2/friends/feed");l(x.data.feed||[])}catch{}};s();const m=setInterval(s,2e4);return()=>clearInterval(m)},[]),t.length===0)return null;function r(s){switch(s.type){case"friend_request":return`${s.fromName} sent a friend request`;case"new_friends":return`${s.name1} and ${s.name2} became friends! ð¤`;case"challenge":return`${s.fromName} challenged ${s.toName} in ${s.subject} âï¸`;case"battle_complete":return`${s.userName} ${s.result==="won"?"won":"finished"} a ${s.subject} battle`;default:return"Something happened"}}function c(s){const m=Math.floor((Date.now()-s)/1e3);return m<60?`${m}s ago`:m<3600?`${Math.floor(m/60)}m ago`:`${Math.floor(m/3600)}h ago`}const i=s=>({friend_request:"text-yellow-400",new_friends:"text-green-400",challenge:"text-purple-400",battle_complete:"text-blue-400"})[s]||"text-white/40";return e.jsxs("div",{className:"mt-4 bg-slate-700/40 border border-white/25 rounded-2xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(s=>!s),className:"w-full flex items-center gap-2 px-5 py-4 hover:bg-slate-700/40 transition-colors",children:[e.jsx(Ct,{className:"w-4 h-4 text-indigo-400 flex-shrink-0"}),e.jsx("span",{className:"text-white font-bold text-sm flex-1 text-left",children:"Social Activity"}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsx("div",{className:"px-4 pb-4 space-y-2",children:t.slice(0,8).map((s,m)=>e.jsxs("div",{className:"flex items-start gap-2.5 py-2 border-t border-white/20 first:border-t-0",children:[e.jsx("span",{className:`text-lg flex-shrink-0 leading-none mt-0.5 ${i(s.type)}`,children:s.type==="friend_request"?"ð":s.type==="new_friends"?"ð¤":s.type==="challenge"?"âï¸":"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white/70 text-xs leading-relaxed",children:r(s)}),e.jsx("p",{className:"text-white/25 text-[10px] mt-0.5",children:c(s.ts)})]})]},m))})]})}function ks({count:t,requests:l,challenges:n,onOpen:a}
12){const[r,c]=d.useState(!1),i=d.useRef(null),s=T();d.useEffect(()=>{const x=h=>{i.current&&!i.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const m=[...l.map(x=>({key:`req-${x.fromUserId}`,icon:"ð",text:`${x.fromName} sent you a friend request`,action:()=>{a(),c(!1)},color:"text-yellow-400"})),...n.map(x=>({key:`ch-${x.battleId}`,icon:"âï¸",text:`${x.fromName} challenged you in ${x.subject}!`,action:()=>{s(`/brain-battles/${x.battleId}`),c(!1)},color:"text-purple-400"}))];return m.length===0&&m.push({key:"empty",icon:"â ",text:"All caught up! No new notifications.",action:()=>{},color:"text-white/60"}),e.jsxs("div",{ref:i,className:"relative",children:[e.jsxs("button",{onClick:()=>c(x=>!x),className:"relative p-2.5 bg-slate-700/40 border border-white/25 rounded-xl text-white/50 hover:text-white hover:bg-slate-700/60 transition-all",children:[e.jsx(Ne,{className:"w-5 h-5"}),t>0&&e.jsx("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] bg-red-500 text-white text-[9px] font-black rounded-full flex items-center justify-center px-1",children:t>9?"9+":t})]}),r&&e.jsxs("div",{className:"absolute right-0 top-12 w-72 bg-[#0d0d1a] border border-white/15 rounded-2xl shadow-2xl overflow-hidden z-50",style:{animation:"fadeSlideDown 0.18s ease-out"},children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/25",children:[e.jsx(Ne,{className:"w-4 h-4 text-white/50"}),e.jsx("span",{className:"text-white font-bold text-sm flex-1",children:"Notifications"}),t>0&&e.jsxs("span",{className:"text-xs text-white/60",children:[t," unread"]})]}),e.jsx("div",{className:"max-h-72 overflow-y-auto",children:m.map(x=>e.jsxs("button",{onClick:x.action,className:"w-full flex items-start gap-3 px-4 py-3 text-left hover:bg-slate-700/40 transition-colors border-b border-white/20 last:border-b-0",children:[e.jsx("span",{className:"text-lg flex-shrink-0 leading-none mt-0.5",children:x.icon}),e.jsx("span",{className:`text-xs leading-relaxed ${x.color}`,children:x.text})]},x.key))})]}),e.jsx("style",{children:` 13 @keyframes fadeSlideDown { 14 from { opacity: 0; transform: translateY(-8px); } 15 to { opacity: 1; transform: translateY(0); } 16 } 17 `})]})}function Ss(){const{isAuthenticated:t,user:l}=M(),[n,a]=d.useState(""),[r,c]=d.useState(""),[i,s]=d.useState(0),[m,x]=d.useState(!1),[h,o]=d.useState(!1);if(d.useEffect(()=>{t&&j.get("/api/gamification/v2/referrals/my-code").then(u=>{a(u.data.code),c(u.data.link),s(u.data.referred||0)}).catch(()=>{})},[t]),d.useEffect(()=>{if(t)try{const u=new URLSearchParams(window.location.search).get("ref"),g=localStorage.getItem("sq_ref_claimed");u&&!g&&j.post("/api/gamification/v2/referrals/claim",{code:u}).then(p=>{if(!p.data.already){const f=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(f+(p.data.xpReward||300))),localStorage.setItem("sq_ref_claimed","1")}}).catch(()=>{})}catch{}},[t]),!t||!n)return null;const b=()=>{navigator.clipboard.writeText(r).catch(()=>{}),x(!0),setTimeout(()=>x(!1),2e3)};return e.jsxs("div",{className:"mt-4 bg-gradient-to-b from-indigo-500/8 to-purple-500/5 border border-indigo-500/20 rounded-2xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>o(u=>!u),className:"w-full flex items-center gap-2 px-5 py-4 hover:bg-slate-700/40 transition-colors",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsx("span",{className:"text-white font-bold text-sm flex-1 text-left",children:"Invite Friends â Earn XP"}),i>0&&e.jsxs("span",{className:"text-indigo-400 text-xs font-bold",children:[i," referred"]}),e.jsx("span",{className:"text-white/60 text-xs",children:h?"â²":"â¼"})]}),h&&e.jsxs("div",{className:"px-5 pb-5",children:[e.jsxs("p",{className:"text-white/60 text-xs mb-3",children:["Share your link. Each friend who joins & plays earns you ",e.jsx("strong",{className:"text-indigo-300",children:"+300 XP"}),"."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 bg-black/50 border border-white/25 rounded-xl px-3 py-2.5 font-mono text-white/80 text-sm truncate",children:r}),e.jsxs("button",{onClick:b,className:"px-4 py-2.5 bg-indigo-600 text-white text-sm font-bold rounded-xl hover:bg-indigo-500 transition-all flex items-center gap-1.5 flex-shrink-0",children:[m?e.jsx(ke,{className:"w-4 h-4"}):e.jsx(Ze,{className:"w-4 h-4"}),m?"Copied!":"Copy"]})]}),i>0&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("div",{className:"bg-indigo-500/10 rounded-xl px-3 py-2 text-center flex-1",children:[e.jsx("p",{className:"text-indigo-300 font-black text-lg",children:i}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"Friends Invited"})]}),e.jsxs("div",{className:"bg-yellow-500/10 rounded-xl px-3 py-2 text-center flex-1",children:[e.jsxs("p",{className:"text-yellow-300 font-black text-lg",children:["+",i*300
17]}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"XP Earned"})]})]})]})]})}const se=[{label:"Bronze",min:0,max:1199,color:"#b45309",icon:"ð¥",reward:"Bronze Scholar frame"},{label:"Silver",min:1200,max:1399,color:"#9ca3af",icon:"ð¥",reward:"Silver Mind frame"},{label:"Gold",min:1400,max:1599,color:"#eab308",icon:"ð",reward:"Gold Intellect frame + 500 Season XP"},{label:"Platinum",min:1600,max:1799,color:"#06b6d4",icon:"ð ",reward:"Platinum Pro frame + 1500 Season XP"},{label:"Diamond",min:1800,max:9999,color:"#a855f7",icon:"ð",reward:"Diamond Legend frame + 3000 Season XP + exclusive title"}];function st(t){return se.slice().reverse().find(l=>t>=l.min)||se[0]}function Cs(t){const l=st(t),n=se[se.indexOf(l)+1];if(!n)return{pct:100,current:t-l.min,needed:0,label:"MAX"};const a=n.min-l.min,r=t-l.min;return{pct:Math.round(r/a*100),current:r,needed:n.min-t,label:n.label}}function Ps(){const[t,l]=d.useState([]),[n,a]=d.useState(0);if(d.useEffect(()=>{j.get("/api/gamification/v2/events/active").then(i=>l(i.data.active||[])).catch(()=>{})},[]),d.useEffect(()=>{if(t.length<=1)return;const i=setInterval(()=>a(s=>(s+1)%t.length),5e3);return()=>clearInterval(i)},[t.length]),t.length===0)return null;const r=t[n],c=Math.max(0,Math.ceil((r.endAt-Date.now())/36e5));return e.jsx("div",{className:"mx-4 mt-3 mb-1 rounded-2xl overflow-hidden",style:{background:"linear-gradient(135deg,rgba(251,146,60,0.15),rgba(239,68,68,0.15))",border:"1px solid rgba(251,146,60,0.3)"},children:e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3",children:[e.jsx("span",{className:"text-2xl",children:r.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-orange-300 font-black text-sm",children:r.name}),e.jsx("p",{className:"text-orange-400/70 text-xs truncate",children:r.description})]}),e.jsxs("div",{className:"flex-shrink-0 text-right",children:[e.jsxs("p",{className:"text-orange-300 font-black text-sm",children:[r.xpMultiplier,"à XP"]}),e.jsxs("p",{className:"text-orange-400/50 text-[10px]",children:[c,"h left"]})]}),t.length>1&&e.jsx("div",{className:"flex gap-1",children:t.map((i,s)=>e.jsx("div",{className:`w-1 h-1 rounded-full transition-all ${s===n?"bg-orange-400":"bg-orange-800"}`},s))})]})})}function Is(){const[t,l]=d.useState([]),n=T();return d.useEffect(()=>{j.get("/api/gamification/v2/challenges/open?limit=3").then(r=>l(r.data.challenges||[])).catch(()=>{});const a=setInterval(()=>{j.get("/api/gamification/v2/challenges/open?limit=3").then(r=>l(r.data.challenges||[])).catch(()=>{})},2e4);return()=>clearInterval(a)},[]),e.jsxs("div",{className:"mt-4 rounded-2xl overflow-hidden border border-red-500/20 bg-gradient-to-b from-red-500/5 to-transparent",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-red-500/10",children:[e.jsx("p",{className:"text-white font-bold text-sm",children:"âï¸ Open Challenges"}),e.jsx("button",{onClick:()=>n("/brain-battles/challenges"),className:"text-red-400 text-xs font-semibold hover:text-red-300 transition-colors",children:"View All â"})]}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.length===0?e.jsx("p",{className:"text-gray-600 text-xs text-center py-2",children:"No open challenges right now"}):t.map(a=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-white/3 rounded-xl hover:bg-white/6 transition-all cursor-pointer",onClick:()=>n("/brain-battles/challenges"),children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-red-600/40 flex items-center justify-center text-white font-bold text-xs flex-shrink-0",children:(a.creatorName||"?")[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-white/80 text-xs font-semibold truncate",children:[a.creatorName," challenges you"]}),e.jsxs("p",{className:"text-gray-500 text-[10px]",children:[a.subject," · ",a.stake]})]}),e.jsx("span",{className:"text-red-400 text-[10px] font-black",children:"FIGHT"})]},a.id)),e.jsx("button",{onClick:()=>n("/brain-battles/challenges"),className:"w-full py-2 text-xs text-red-400/70 hover:text-red-400 font-semibold transition-colors",children:"+ Post your own challenge"})]})]})}const $s={battle_won:{emoji:"ð",color:"text-yellow-400"},achievement_unlocked:{emoji:"ðï¸",color:"text-purple-400"},prestige_up:{emoji:"â",color:"text-orange-400"},survival_record:{emoji:"ð",color:"text-red-400"},rival_beaten:{emoji:"âï¸",color:"text-red-400"},wager_won:{emoji:"ð°",color:"text-yellow-300"},wager_accepted:{emoji:"ð¤",color:"text-blue-400"},bounty_placed:{emoji:"ð¯",color:"text-orange-400"},bounty_claimed:{emoji:"ð¤ ",color:"text-amber-400"},gift_sent:{emoji:"ð",color:"text-pink-400"},league_promotion:{emoji:"ð
",color:"text-indigo-400"},lottery_win:{emoji:"ð°",color:"text-yellow-300"},streak_extended:{emoji:"ð¥",color:"text-orange-400"},tournament_winner:{emoji:"ð",color:"text-yellow-400"}};function _s(t){const l=Math.floor((Date.now()-t)/1e3);return l<60?`${l}s ago`:l<3600?`${Math.floor(l/60)}m ago`:`${Math.floor(l/3600)}h ago`}function Bs(){const[t,l]=d.useState([]),[n,a]=d.useState(!1);return d.useEffect(()=>{const r=()=>{j.get("/api/gamification/v2/activity").then(i=>l(i.data.events||[])).catch(()=>{})};r();const c=setInterval(r,15e3);return()=>clearInterval(c)},[]),t.length===0?null:e.jsxs("div",{className:"bg-gradient-to-br from-slate-800/60 to-slate-900/60 rounded-2xl border border-white/8 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(r=>!r),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-white/70 font-bold text-sm flex items-center gap-2",children:["ð Live Activity ",e.jsx("span",{className:"text-white/25 text-xs font-normal",children:"Global feed"})]}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsx("div",{className:"px-3 pb-3 space-y-1.5 max-h-52 overflow-y-auto",children:t.slice(0,10).map((r,c)=>{const i=$s[r.type]||{emoji:"â¡",color:"text-white/50"},s=r.type==="battle_won"?`won a battle (+${r.xp??"?"} XP)`:r.type==="achievement_unlocked"?`unlocked ${r.emoji||"ðï¸"} ${r.achievement||"achievement"}`:r.type==="rival_beaten"?`crushed their rival! (+${r.xp??"?"} XP)`:r.type==="wager_won"?`won a wager â +${r.payout??"?"} XP`:r.type==="wager_accepted"?`${r.player2} accepted a ${r.amount} XP wager`:r.type==="prestige_up"?"hit a new Prestige level!":r.type==="survival_record"?"set a new Survival record!":r.type==="bounty_placed"?`placed a ${r.amount} XP bounty on ${r.targetName}`:r.type==="bounty_claimed"?`claimed a ${r.payout} XP bounty on ${r.targetName}!`:r.type==="gift_sent"?`sent a ${r.amount} XP gift ð`:r.type==="league_promotion"?`promoted to ${r.division}! ð
`:r.type==="lottery_win"?`won the daily lottery â +${r.prize} XP! ð°`:r.type==="streak_extended"?`is on a ${r.days}-day battle streak! ð¥`:r.type==="tournament_winner"?`won the "${r.name}" tournament! ð`:r.type;return e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-base leading-none flex-shrink-0",children:i.emoji}),e.jsx("span",{className:`font-semibold ${i.color} flex-shrink-0 truncate max-w-[80px]`,children:r.username||"Scholar"}),e.jsx("span",{className:"text-white/60 flex-1 truncate",children:s}),e.jsx("span",{className:"text-white/50 flex-shrink-0",children:_s(r.ts)})]},c)})})]})}function Es(){const{isAuthenticated:t}
17=M(),[l,n]=d.useState(null),[a,r]=d.useState(null),[c,i]=d.useState(!1),[s,m]=d.useState(null),[x,h]=d.useState(!0),o=d.useRef(null);d.useEffect(()=>{const p=localStorage.getItem("token"),f=p?{Authorization:`Bearer ${p}`}:{};j.get("/api/gamification/v2/daily-challenge",{headers:f}).then(v=>{n(v.data),v.data.userResult&&m(v.data.userResult)}).catch(()=>{}),o.current=Date.now()},[]);const b=async()=>{if(!(a===null||!t||c)){i(!0);try{const p=Math.round((Date.now()-o.current)/1e3),f=localStorage.getItem("token"),v=await j.post("/api/gamification/v2/daily-challenge/submit",{answerIdx:a,timeTaken:p},{headers:{Authorization:`Bearer ${f}`}});m(v.data)}catch{}i(!1)}};if(!l||!l.options)return null;const u=!!l.userResult||!!s,g=l.totalSubmissions||0;return e.jsxs("div",{className:"bg-white/[0.04] border border-yellow-500/20 rounded-2xl mb-3 overflow-hidden",children:[e.jsxs("button",{onClick:()=>h(p=>!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-slate-700/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð¯"}),e.jsx("span",{className:"text-yellow-300/80 text-xs font-bold uppercase tracking-wider",children:"Daily Challenge"}),u&&s?.correct&&e.jsxs("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:["+",s.xp," XP"]}),!u&&e.jsx("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full bg-yellow-500/20 text-yellow-400 border border-yellow-500/30 animate-pulse",children:"NEW"})]}),e.jsx(ae,{className:`w-3.5 h-3.5 text-white/60 transition-transform ${x?"rotate-90":""}`})]}),x&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"text-white/60 text-xs leading-relaxed font-medium",children:l.question}),u?e.jsx("div",{className:`px-3 py-2.5 rounded-xl border text-xs font-bold ${s?.correct?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":"bg-red-500/10 border-red-500/20 text-red-300"}`,children:s?.correct?`â
Correct! +${s.xp} XP earned`:`â Incorrect â ${s?.correctLabel||"See answer above"}`}):e.jsxs("div",{className:"space-y-1.5",children:[l.options.map((p,f)=>e.jsxs("button",{onClick:()=>r(f),className:`w-full text-left px-3 py-2 rounded-xl text-xs font-medium transition-all border ${a===f?"bg-yellow-500/20 border-yellow-500/50 text-yellow-300":"bg-white/[0.03] border-white/8 text-white/50 hover:bg-white/6 hover:border-white/15"}`,children:[e.jsxs("span",{className:"text-white/60 mr-2",children:[String.fromCharCode(65+f),"."]}),p]},f)),t?e.jsx("button",{onClick:b,disabled:a===null||c,className:"w-full mt-1 py-2 bg-yellow-500/20 hover:bg-yellow-500/30 border border-yellow-500/40 text-yellow-300 text-xs font-black rounded-xl transition-all disabled:opacity-40",children:c?"Submitting...":"Submit Answer"}):e.jsx("p",{className:"text-white/25 text-[10px] text-center",children:"Sign in to earn XP"})]}),(l.top10||[]).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-white/25 text-[10px] uppercase tracking-wider mb-1.5",children:"Today's Top Scorers"}),e.jsx("div",{className:"space-y-1",children:(l.top10||[]).slice(0,3).map((p,f)=>e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[e.jsx("span",{className:"text-white/60 w-3",children:["ð¥","ð¥","ð¥"][f]}),e.jsxs("span",{className:"flex-1 text-white/60",children:["Player ",f+1]}),e.jsxs("span",{className:"text-yellow-400 font-bold",children:[p.xp," XP"]}),e.jsxs("span",{className:"text-white/50",children:[p.timeTaken,"s"]})]},f))})]}),e.jsxs("div",{className:"text-white/50 text-[10px] text-center",children:[g," players answered today · resets midnight UTC"]})]})]})}const Ge={double_xp:{name:"2à XP",emoji:"â¡",color:"#facc15",durationMin:30},triple_xp:{name:"3à XP",emoji:"ð¥",color:"#f97316",durationMin:10},study_boost:{name:"Study XP +50%",emoji:"ð",color:"#22c55e",durationMin:60},lucky_xp:{name:"Lucky XP +25%",emoji:"ð",color:"#a78bfa",durationMin:45}};function Ms(){const{isAuthenticated:t}
17=M(),[l,n]=d.useState([]),[a,r]=d.useState(!1),[c,i]=d.useState(""),s=async()=>{if(t)try{const h=localStorage.getItem("token"),o=await j.get("/api/gamification/v2/boosters",{headers:{Authorization:`Bearer ${h}`}});n(o.data.active||[])}catch{}};d.useEffect(()=>{s()},[t]);const m=async h=>{if(!(!t||c)){i(h);try{const o=localStorage.getItem("token"),b=await j.post("/api/gamification/v2/boosters/activate",{type:h},{headers:{Authorization:`Bearer ${o}`}});b.data.success&&n(b.data.active||[])}catch{}i("")}},x=l.length>0;return e.jsxs("div",{className:"bg-white/[0.04] border border-white/8 rounded-2xl mb-3 overflow-hidden",children:[e.jsxs("button",{onClick:()=>r(h=>!h),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-slate-700/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"â¡"}),e.jsx("span",{className:"text-white/70 text-xs font-bold uppercase tracking-wider",children:"XP Boosters"}),x&&e.jsx("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full bg-yellow-500/20 text-yellow-400 border border-yellow-500/30 animate-pulse",children:"ACTIVE"})]}),e.jsx(ae,{className:`w-3.5 h-3.5 text-white/60 transition-transform ${a?"rotate-90":""}`})]}),a&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[l.map(h=>{const o=Ge[h.type]||{},b=Math.max(0,h.expiresAt-Date.now()),u=Math.ceil(b/6e4);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl text-xs font-bold",style:{background:`${o.color}12`,border:`1px solid ${o.color}30`,color:o.color},children:[e.jsx("span",{children:o.emoji}),e.jsx("span",{className:"flex-1",children:o.name}),e.jsxs("span",{className:"text-[10px] opacity-70",children:[u,"m left"]})]},h.type)}),t?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-white/50 text-[10px] uppercase tracking-wider",children:"Try a booster (demo â free):"}),Object.entries(Ge).map(([h,o])=>{const b=l.find(u=>u.type===h);return e.jsxs("button",{onClick:()=>m(h),disabled:!!b||c===h,className:"w-full flex items-center gap-2 px-3 py-2 rounded-xl text-xs font-medium transition-all border border-white/8 bg-white/[0.03] hover:bg-white/6 disabled:opacity-40 text-white/60",children:[e.jsx("span",{children:o.emoji}),e.jsx("span",{className:"flex-1 text-left",children:o.name}),e.jsxs("span",{className:"text-white/25 text-[10px]",children:[o.durationMin,"min"]}),b&&e.jsx("span",{className:"text-emerald-400 text-[10px]",children:"â"})]},h)})]}):e.jsx("p",{className:"text-white/25 text-[10px] text-center",children:"Sign in to activate boosters"})]})]})}const As=[{label:"SAT Prep",emoji:"ð",color:"#3b82f6"},{label:"AP Calculus",emoji:"ð",color:"#8b5cf6"},{label:"AP Biology",emoji:"ð¬",color:"#22c55e"},{label:"AP Chemistry",emoji:"âï¸",color:"#f59e0b"},{label:"AP US History",emoji:"ð",color:"#ef4444"},{label:"AP Psychology",emoji:"ð§ ",color:"#ec4899"}];function Rs({onQuickBattle:t}){const l=new Date().getMonth();if(l<2||l>4)return null;const n=Math.max(0,Math.ceil((new Date("2026-05-31")-new Date)/864e5));return e.jsxs("div",{className:"bg-gradient-to-br from-blue-900/30 to-indigo-900/30 border border-blue-500/25 rounded-2xl p-4 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:"ð"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-white font-black text-sm leading-tight",children:"Exam Season"}),e.jsxs("div",{className:"text-white/60 text-xs",children:[n,"d until May finals"]})]})]}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30 font-bold uppercase tracking-wide",children:"Live"})]}),e.jsx("p",{className:"text-white/60 text-xs mb-3",children:"Battle to master AP subjects and SAT skills. Every win builds real exam confidence."}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:As.map(a=>e.jsxs("button",{onClick:()=>t&&t(a.label),className:"flex flex-col items-center gap-1 py-2 rounded-xl bg-slate-700/40 border border-white/8 hover:bg-slate-700/60 hover:border-white/15 transition-all group",children:[e.jsx("span",{className:"text-sm",children:a.emoji}),e.jsx("span",{className:"text-white/55 text-[10px] font-semibold group-hover:text-white/90 transition-colors leading-tight text-center px-0.5",children:a.label.replace("AP ","")})]},a.label))}),e.jsx("div",{className:"mt-2.5 text-center text-white/50 text-[10px]",children:"Tap subject â instant practice battle"})]})}const Ts=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ls(){const[t,l]=d.useState([]),[n,a]=d.useState([]),[r,c]=d.use
17State(!0);d.useEffect(()=>{j.get("/api/gamification/v2/events/week").then(s=>{l(s.data.schedule||[]),a(s.data.active||[])}).catch(()=>{})},[]);const i=new Date().getDay();return t.length===0?null:e.jsxs("div",{className:"bg-white/[0.04] border border-white/8 rounded-2xl mb-3 overflow-hidden",children:[e.jsxs("button",{onClick:()=>c(s=>!s),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-slate-700/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð
"}),e.jsx("span",{className:"text-white/70 text-xs font-bold uppercase tracking-wider",children:"Event Calendar"}),n.length>0&&e.jsx("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full bg-yellow-500/20 text-yellow-400 border border-yellow-500/30 animate-pulse",children:"LIVE"})]}),e.jsx(ae,{className:`w-3.5 h-3.5 text-white/60 transition-transform ${r?"rotate-90":""}`})]}),r&&e.jsxs("div",{className:"px-4 pb-4",children:[n.map(s=>e.jsx("div",{className:"mb-3 px-3 py-2.5 rounded-xl border",style:{background:"rgba(234,179,8,0.08)",borderColor:"rgba(234,179,8,0.25)"},children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:s.emoji}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-yellow-300 text-xs font-black",children:[s.name," â ",s.mult,"à XP"]}),e.jsx("div",{className:"text-white/60 text-[10px]",children:s.desc})]})]})},s.day)),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:t.map(s=>{const m=s.day===i;return e.jsxs("div",{className:`flex flex-col items-center gap-0.5 px-1 py-2 rounded-xl text-center transition-all ${m?"bg-yellow-500/15 border border-yellow-500/30":"bg-white/[0.03]"}`,children:[e.jsx("span",{className:"text-[8px] font-bold",style:{color:m?"#fbbf24":"rgba(255,255,255,0.3)"},children:Ts[s.day]}),e.jsx("span",{className:"text-sm leading-none",children:s.emoji}),e.jsxs("span",{className:"text-[7px] font-black",style:{color:m?"#fbbf24":"rgba(255,255,255,0.4)"},children:[s.mult,"Ã"]})]},s.day)})}),e.jsx("p",{className:"text-white/50 text-[10px] text-center mt-2",children:"XP multipliers refresh daily at midnight UTC"})]})]})}function Ds(){const t=new Date().getMonth();if(t<2||t>4)return null;const[l,n]=N.useState(null),[a,r]=N.useState(!1);N.useEffect(()=>{a&&j.get("/api/gamification/v2/exam-season/leaderboard").then(i=>n(i.data)).catch(()=>{})},[a]);const c=Math.max(0,Math.ceil((new Date("2026-05-31")-new Date)/864e5));return e.jsxs("div",{className:"bg-gradient-to-br from-blue-900/20 to-indigo-900/20 border border-blue-500/20 rounded-2xl mb-4 overflow-hidden",children:[e.jsxs("button",{onClick:()=>r(i=>!i),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-white/4 transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-white font-black text-sm leading-tight",children:"Exam Season Board"}),e.jsxs("div",{className:"text-white/35 text-[10px]",children:[c,"d remaining · SAT & AP"]})]})]}),e.jsx("span",{className:`text-white/60 text-xs transition-transform ${a?"rotate-180":""}`,children:"â¼"})]}),a&&e.jsxs("div",{className:"px-3 pb-3 space-y-1",children:[l?l.entries.length===0?e.jsx("div",{className:"text-center text-white/25 text-xs py-3",children:"No exam battles yet â be first! ð¯"}):l.entries.slice(0,8).map(i=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-white/4 transition-all",children:[e.jsx("span",{className:"text-white/60 text-xs w-4 text-right flex-shrink-0",children:i.rank<=3?["ð¥","ð¥","ð¥"][i.rank-1]:`#${i.rank}`}),e.jsx("span",{className:"flex-1 text-white/70 text-xs font-semibold truncate",children:i.username||"Scholar"}),e.jsxs("span",{className:"text-blue-400 font-black text-xs flex-shrink-0",children:[i.wins,"W"]}),e.jsxs("span",{className:"text-white/25 text-[10px] flex-shrink-0",children:[i.battles,"B"]})]},i.userId)):e.jsx("div",{className:"text-center text-white/25 text-xs py-3",children:"Loadingâ¦"}),e.jsx("div",{className:"text-center mt-1",children:e.jsx("span",{className:"text-white/50 text-[10px]",children:"W=wins · B=battles played"})})]})]})}function qs(){const{isAuthenticated:t}
17=M(),[l,n]=d.useState(null),[a,r]=d.useState(!0);d.useEffect(()=>{if(!t)return;const m=localStorage.getItem("token");j.get("/api/gamification/v2/practice/stats",{headers:{Authorization:`Bearer ${m}`}}).then(x=>n(x.data)).catch(()=>{})},[t]);const c=l?.todayXP||0;l?.totalXP;const i=l?.sessions||0,s=l?.accuracy||0;return e.jsxs("div",{className:"bg-white/[0.04] border border-white/8 rounded-2xl mb-3 overflow-hidden",children:[e.jsxs("button",{onClick:()=>r(m=>!m),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-slate-700/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð§ "}),e.jsx("span",{className:"text-white/70 text-xs font-bold uppercase tracking-wider",children:"Practice Mode"}),c>0&&e.jsxs("span",{className:"text-[9px] font-black px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30",children:["+",c," today"]})]}),e.jsx(ae,{className:`w-3.5 h-3.5 text-white/60 transition-transform ${a?"rotate-90":""}`})]}),a&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[t&&l?e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"bg-black/50 rounded-xl p-2 text-center",children:[e.jsx("div",{className:"text-blue-400 text-sm font-black",children:c}),e.jsx("div",{className:"text-white/60 text-[9px]",children:"Study XP today"})]}),e.jsxs("div",{className:"bg-black/50 rounded-xl p-2 text-center",children:[e.jsx("div",{className:"text-purple-400 text-sm font-black",children:i}),e.jsx("div",{className:"text-white/60 text-[9px]",children:"Sessions"})]}),e.jsxs("div",{className:"bg-black/50 rounded-xl p-2 text-center",children:[e.jsxs("div",{className:"text-emerald-400 text-sm font-black",children:[s,"%"]}),e.jsx("div",{className:"text-white/60 text-[9px]",children:"Accuracy"})]})]}):t?e.jsx("div",{className:"text-white/50 text-xs text-center animate-pulse",children:"Loading..."}):e.jsx("p",{className:"text-white/60 text-xs text-center",children:"Sign in to track study XP"}),e.jsx("div",{className:"text-white/25 text-[10px] px-2 py-2 rounded-xl border border-white/20 bg-black/40",children:"ð¡ Solo drills · full explanations on wrong answers · 5 Study XP per correct answer"}),e.jsx(B,{to:"/brain-battles/practice",className:"block w-full text-center px-4 py-2.5 bg-gradient-to-r from-blue-600/30 to-purple-600/30 border border-blue-500/30 text-blue-300 text-xs font-black rounded-xl hover:from-blue-600/50 hover:to-purple-600/50 transition-all",children:"Start Practice Drill â"})]})]})}const Xs={Bronze:"#cd7f32",Silver:"#94a3b8",Gold:"#fbbf24",Platinum:"#818cf8",Diamond:"#67e8f9"};function ge(t){for(const[l,n]of Object.entries(Xs))if(t.startsWith(l))return n;return"#9ca3af"}function Os(){const[t,l]=d.useState(null),[n,a]=d.useState([]),[r,c]=d.useState(!1),{isAuthenticated:i}=M();if(d.useEffect(()=>{if(!i)return;const x=localStorage.getItem("token");x&&(j.get("/api/gamification/v2/leagues/my",{headers:{Authorization:`Bearer ${x}`}}).then(h=>{h.data.player&&l(h.data.player)}).catch(()=>{}),j.get("/api/gamification/v2/leagues/ladder").then(h=>a(h.data.ladder||[])).catch(()=>{}))},[i]),!i)return null;const s=t?ge(t.division):"#6b7280",m=t?Math.min(100,t.lp):0;return e.jsxs("div",{className:"rounded-2xl border overflow-hidden",style:{borderColor:s+"40",background:`linear-gradient(135deg, ${s}0d, transparent)`},children:[e.jsxs("button",{onClick:()=>c(x=>!x),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2",style:{color:s},children:["ð
",t?t.division:"Unranked",t&&e.jsxs("span",{className:"text-white/60 text-xs font-normal",children:[t.lp," LP"]})]}),e.jsx("span",{className:"text-white/60 text-xs",children:r?"â²":"â¼"})]}),r&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[t&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs text-white/60 mb-1",children:[e.jsxs("span",{children:[t.lp," / 100 LP"]}),e.jsxs("span",{children:[t.wins,"W â ",t.losses,"L this week"]})]}),e.jsx("div",{className:"h-1.5 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${m}%`,background:s}})}),e.jsxs("p",{className:"text-white/50 text-[10px] mt-1",children:[100-t.lp," LP to next division · LP resets weekly"]})]})}),n.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-white/60 text-[10px] uppercase tracking-wider mb-1.5",children:"Top Players"}),n.slice(0,5).map((x,h)=>e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"text-white/60 text-xs w-4",children:h+1}),e.jsx("span",{className:"flex-1 truncate text-xs font-semibold",style:{color:ge(x.division)},children:x.username}),e.jsx("span",{className:"text-xs text-white/25",children:x.division}),e.jsxs("span",{className:"text-xs font-mono",style:{color:ge(x.division)},children:[x.lp," LP"]})]},x.userId))]}),!t&&e.jsx("p",{className:"text-white/60 text-xs text-center",children:"Play ranked battles to earn League Points"})]})]})}function zs(){const[t,l]=d.useState(null),[n,a]=d.useState(!1),[r,c]=d.use
17State(!1),[i,s]=d.useState(!1),[m,x]=d.useState(1),[h,o]=d.useState(""),{isAuthenticated:b}=M(),u=50,g=()=>{if(!b)return;const S=localStorage.getItem("token");S&&j.get("/api/gamification/v2/lottery/today",{headers:{Authorization:`Bearer ${S}`}}).then(C=>l(C.data)).catch(()=>{})};d.useEffect(()=>{g();const S=setInterval(g,3e4);return()=>clearInterval(S)},[b]);const p=async()=>{c(!0),o("");try{const S=localStorage.getItem("token"),C=await j.post("/api/gamification/v2/lottery/buy",{count:m},{headers:{Authorization:`Bearer ${S}`}}),P=C.data.bought*u,y=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(Math.max(0,y-P))),o(`â Got ${C.data.bought} ticket${C.data.bought>1?"s":""}! (${C.data.myTickets} total)`),g()}catch(S){o(S.response?.data?.error||"Failed.")}finally{c(!1)}},f=async()=>{s(!0),o("");try{const S=localStorage.getItem("token"),C=await j.post("/api/gamification/v2/lottery/draw",{},{headers:{Authorization:`Bearer ${S}`}});if(C.data.iWon){const P=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(P+C.data.prize)),o(`ð YOU WON! +${C.data.prize} XP!`)}else o(`Winner: ${C.data.winner?.username||"?"} (+${C.data.prize} XP)`);g()}catch(S){o(S.response?.data?.error||"Draw failed.")}finally{s(!1)}};if(!b)return null;const v=new Date().toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"});return e.jsxs("div",{className:"bg-gradient-to-br from-yellow-900/20 to-amber-900/15 rounded-2xl border border-yellow-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(S=>!S),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-yellow-300 font-bold text-sm flex items-center gap-2",children:["ð° Daily Lottery",t&&!t.drawn&&e.jsxs("span",{className:"text-yellow-500/60 text-xs font-normal",children:[t.prizePool," XP pool"]}),t?.drawn&&e.jsx("span",{className:"bg-green-600/30 text-green-400 text-[10px] px-1.5 rounded font-bold",children:"DRAWN"})]}),e.jsx("span",{className:"text-yellow-600/40 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500/20 rounded-xl p-3 text-center",children:[e.jsxs("p",{className:"text-yellow-400 font-black text-2xl",children:[t?.prizePool?.toLocaleString()||0," XP"]}),e.jsxs("p",{className:"text-white/60 text-xs",children:["Prize pool · ",v]}),t&&e.jsxs("p",{className:"text-white/60 text-xs mt-0.5",children:[t.totalTickets," tickets · ",t.myTickets," yours"]})]}),t?.drawn?e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-green-400 font-bold text-sm",children:["ð ",t.winner?.username," won!"]}),e.jsx("p",{className:"text-white/60 text-xs mt-1",children:"Come back tomorrow for a new draw"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:1,max:10,value:m,onChange:S=>x(Math.min(10,Math.max(1,parseInt(S.target.value)||1))),className:"w-16 px-2 py-1.5 bg-black/30 border border-white/15 rounded-lg text-white text-sm text-center focus:outline-none"}),e.jsx("button",{onClick:p,disabled:r,className:"flex-1 py-2 bg-yellow-600 hover:bg-yellow-500 text-white text-xs font-bold rounded-xl transition-all disabled:opacity-50",children:r?"...":`Buy (â${m*u} XP)`})]}),t&&t.totalTickets>=2&&e.jsx("button",{onClick:f,disabled:i,className:"w-full py-2 bg-gradient-to-r from-orange-600 to-yellow-600 text-white text-xs font-bold rounded-xl hover:opacity-90 transition-all disabled:opacity-50",children:i?"Drawing...":"ð² Draw Now!"})]}),h&&e.jsx("p",{className:`text-xs text-center font-semibold ${h.includes("WON")?"text-yellow-300":"text-white/50"}`,children:h})]})]})}const He=[{tier:1,bpxp:0,label:"+50 XP",emoji:"â¡"},{tier:2,bpxp:200,label:"Power-Up Ã1",emoji:"ð¥"},{tier:3,bpxp:450,label:"+100 XP",emoji:"â¡"},{tier:4,bpxp:750,label:"Warrior Title",emoji:"âï¸"},{tier:5,bpxp:1100,label:"+200 XP",emoji:"â¡"},{tier:6,bpxp:1500,label:"Power-Up Ã3",emoji:"ð¥"},{tier:7,bpxp:2e3,label:"+300 XP",emoji:"â¡"},{tier:8,bpxp:2600,label:"Champion Title",emoji:"ð"},{tier:9,bpxp:3300,label:"+500 XP",emoji:"â¡"},{tier:10,bpxp:4100,label:"Power-Up Ã5",emoji:"ð¥"}
17,{tier:11,bpxp:5e3,label:"+750 XP",emoji:"â¡"},{tier:12,bpxp:6e3,label:"Legend Title",emoji:"ð "},{tier:13,bpxp:7200,label:"+1000 XP",emoji:"â¡"},{tier:14,bpxp:8600,label:"Power-Up Ã10",emoji:"ð¥"},{tier:15,bpxp:1e4,label:"Immortal Title",emoji:"ð"}];function Fs(){const[t,l]=d.useState(null),[n,a]=d.useState(!1),{isAuthenticated:r}=M();if(d.useEffect(()=>{if(!r)return;const o=localStorage.getItem("token");o&&j.get("/api/gamification/v2/battle-pass/my",{headers:{Authorization:`Bearer ${o}`}}).then(b=>l(b.data)).catch(()=>{})},[r]),!r)return null;const c=t?.bp?.tier||1,i=t?.bp?.bpxp||0,s=t?.bp?.progress||0,m=new Set(t?.claimed||[]),x=c>=12?"#fbbf24":c>=8?"#8b5cf6":c>=4?"#0ea5e9":"#22c55e",h=He.find(o=>o.tier===c+1);return e.jsxs("div",{className:"rounded-2xl border overflow-hidden",style:{borderColor:x+"35",background:`linear-gradient(135deg, ${x}0d, transparent)`},children:[e.jsxs("button",{onClick:()=>a(o=>!o),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2",style:{color:x},children:["ð« Battle Pass â Tier ",c,c>=15&&e.jsx("span",{className:"text-[10px] bg-yellow-500/20 text-yellow-300 px-1.5 py-0.5 rounded font-bold",children:"MAX"})]}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-[10px] text-white/60 mb-1",children:[e.jsxs("span",{children:[i.toLocaleString()," BP XP"]}),h&&e.jsxs("span",{children:[h.bpxp.toLocaleString()," for Tier ",h.tier]})]}),e.jsx("div",{className:"h-2 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:`linear-gradient(90deg, ${x}, ${x}cc)`}})}),h&&e.jsxs("p",{className:"text-white/25 text-[10px] mt-1",children:["Next: ",h.emoji," ",h.label]})]}),e.jsx("div",{className:"space-y-1 max-h-52 overflow-y-auto pr-1",children:He.map(o=>{const b=o.tier===c,u=m.has(o.tier),g=o.tier>c;return e.jsxs("div",{className:`flex items-center gap-2 rounded-xl px-3 py-1.5 transition-all ${b?"border":u?"opacity-60":"opacity-40"}`,style:b?{borderColor:x+"50",background:x+"12"}:{},children:[e.jsx("span",{className:"text-base",children:u?"â
":g?"ð":o.emoji}),e.jsx("span",{className:"text-white/50 text-[10px] w-8 text-right font-mono",children:o.tier}),e.jsx("span",{className:`flex-1 text-xs font-semibold ${b?"text-white/90":u?"text-white/50 line-through":"text-white/35"}`,children:o.label}),b&&e.jsx("span",{className:"text-[9px] font-bold px-1.5 py-0.5 rounded",style:{background:x+"25",color:x},children:"NOW"})]},o.tier)})}),e.jsx(B,{to:"/brain-battles/season",className:"block w-full text-center py-2 rounded-xl text-[10px] font-bold bg-slate-700/40 hover:bg-slate-700/60 transition-colors mt-1",style:{color:x},children:"View Full Season Pass â"}),e.jsx("p",{className:"text-white/50 text-[10px] text-center",children:"Earn BPXP every battle · Season 1"})]})]})}function Ws(){const[t,l]=d.useState([]),[n,a]=d.useState([]),[r,c]=d.useState(!1),[i,s]=d.useState("friends"),[m,x]=d.useState(""),[h,o]=d.useState(!1),[b,u]=d.useState(""),{isAuthenticated:g}=M(),p=()=>{if(!g)return;const y=localStorage.getItem("token");if(!y)return;const $={headers:{Authorization:`Bearer ${y}`}};j.get("/api/gamification/v2/friends/list",$).then(A=>l(A.data.friends||[])).catch(()=>{}),j.get("/api/gamification/v2/friends/requests",$).then(A=>a(A.data.requests||[])).catch(()=>{}),j.post("/api/gamification/v2/friends/touch",{},$).catch(()=>{})};d.useEffect(()=>{p();const y=setInterval(p,3e4);return()=>clearInterval(y)},[g]);const f=async()=>{if(m.trim()){o(!0),u("");try{const y=localStorage.getItem("token");await j.post("/api/gamification/v2/friends/request-by-name",{username:m.trim()},{headers:{Authorization:`Bearer ${y}`}}),u(`â Friend request sent to ${m}!`),x("")}catch(y){u(y.response?.data?.error||"User not found.")}finally{o(!1)}}},v=async(y,$)=>{const A=localStorage.getItem("token");await j.post(`/api/gamification/v2/friends/respond/${y}`,{accept:$},{headers:{Authorization:`Bearer ${A}`}}
17).catch(()=>{}),p()},S=async y=>{const $=localStorage.getItem("token");await j.delete(`/api/gamification/v2/friends/${y}`,{headers:{Authorization:`Bearer ${$}`}}).catch(()=>{}),l(A=>A.filter(I=>I.userId!==y))};if(!g)return null;const C=t.filter(y=>y.online).length,P=n.length;return e.jsxs("div",{className:`rounded-2xl border overflow-hidden ${P>0?"border-green-500/25":"border-white/8"} bg-white/[0.03]`,children:[e.jsxs("button",{onClick:()=>c(y=>!y),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2 text-green-300",children:["ð¥ Friends",C>0&&e.jsxs("span",{className:"text-[10px] bg-green-500/20 text-green-400 px-1.5 py-0.5 rounded",children:[C," online"]}),P>0&&e.jsx("span",{className:"bg-green-500 text-white text-[10px] font-black px-1.5 py-0.5 rounded-full animate-pulse",children:P})]}),e.jsx("span",{className:"text-white/25 text-xs",children:r?"â²":"â¼"})]}),r&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"flex gap-1 bg-slate-700/40 rounded-xl p-1",children:[["friends",`Friends (${t.length})`],["requests",`Requests${P?` (${P})`:""}`],["add","Add"]].map(([y,$])=>e.jsx("button",{onClick:()=>s(y),className:`flex-1 py-1 rounded-lg text-[10px] font-bold transition-all ${i===y?"bg-green-600 text-white":"text-white/60 hover:text-white/60"}`,children:$},y))}),i==="friends"&&(t.length===0?e.jsx("p",{className:"text-white/25 text-xs text-center py-1",children:"No friends yet â add some!"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto pr-1",children:t.map(y=>e.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.04] rounded-xl px-3 py-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${y.online?"bg-green-400":"bg-white/15"}`}),e.jsx("span",{className:"flex-1 text-xs font-semibold text-white/75 truncate",children:y.username}),e.jsx("button",{onClick:()=>S(y.userId),className:"text-white/50 hover:text-red-400 text-[10px] transition-colors",children:"Ã"})]},y.userId))})),i==="requests"&&(n.length===0?e.jsx("p",{className:"text-white/25 text-xs text-center py-1",children:"No pending requests"}):n.map(y=>e.jsxs("div",{className:"bg-green-900/15 border border-green-500/20 rounded-xl p-3",children:[e.jsxs("p",{className:"text-white/80 text-xs font-bold mb-2",children:[y.username," wants to be friends"]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>v(y.userId,!0),className:"flex-1 py-1.5 bg-green-600/30 border border-green-500/30 text-green-300 text-xs font-bold rounded-lg",children:"Accept"}),e.jsx("button",{onClick:()=>v(y.userId,!1),className:"flex-1 py-1.5 bg-slate-700/40 border border-white/25 text-white/60 text-xs font-bold rounded-lg",children:"Decline"})]})]},y.userId))),i==="add"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{value:m,onChange:y=>x(y.target.value),onKeyDown:y=>y.key==="Enter"&&f(),placeholder:"Enter exact username...",className:"w-full px-3 py-2 bg-black/30 border border-white/15 rounded-xl text-white text-xs placeholder-white/50 focus:outline-none"}),e.jsx("button",{onClick:f,disabled:h,className:"w-full py-2 bg-green-600 hover:bg-green-500 text-white text-xs font-bold rounded-xl disabled:opacity-50",children:h?"...":"+ Send Friend Request"})]}),b&&e.jsx("p",{className:`text-xs text-center font-semibold ${b.startsWith("â")?"text-green-400":"text-red-400/70"}`,children:b})]})]})}function Us(){const[t,l]=d.useState(null),[n,a]=d.useState(null),[r,c]=d.useState(!1),[i,s]=d.useState(""),{isAuthenticated:m}=M(),x=()=>{if(j.get("/api/gamification/v2/weekly-race/leaderboard").then(p=>l(p.data)).catch(()=>{}),!m)return;const g=localStorage.getItem("token");g&&j.get("/api/gamification/v2/weekly-race/my",{headers:{Authorization:`Bearer ${g}`}}).then(p=>a(p.data)).catch(()=>{})};d.useEffect(()=>{x();const g=setInterval(x,3e4);return()=>clearInterval(g)},[m]),d.useEffect(()=>{if(!t)return;const g=()=>{const v=t.msUntilReset-(Date.now()-p.current);if(v<=0){s("Resetting...");return}const S=Math.floor(v/36e5),C=Math.floor(v%36e5/6e4),P=Math.floor(v/864e5);s(P>0?`${P}d ${S%24}h`:`${S}h ${C}m`)},p={current:Date.now()};g();const f=setInterval(g,6e4);return()=>clearInterval(f)},[t]);const h=t?.leaderboard||[],o=n?.rank,b=n?.entry?.xp||0,u=g=>g===1?"#fbbf24":g===2?"#94a3b8":g===3?"#cd7f32":"#ffffff40";return e.jsxs("div",{className:"bg-gradient-to-br from-cyan-900/18 to-blue-900/12 rounded-2xl border border-cyan-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>c(g=>!g),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-cyan-300 font-bold text-sm flex items-center gap-2",children:["ð Weekly XP Race",o&&o<=3&&e.jsxs("span",{className:"text-[10px] bg-yellow-500/20 text-yellow-300 px-1.5 py-0.5 rounded font-bold",children:["#",o]})]}),e.jsx("span",{className:"text-cyan-600/40 text-xs",children:r?"â²":"â¼"})]}),r&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-[10px] text-white/60",children:[e.jsxs("span",{children:["Resets in ",i||"..."]}),o&&e.jsxs("span",{children:["Your rank: ",e.jsxs("span",{className:"font-bold text-white/60",children:["#",o]}
17)," · ",b.toLocaleString()," XP"]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 text-center",children:[{rank:1,prize:500,label:"ð¥"},{rank:2,prize:250,label:"ð¥"},{rank:3,prize:100,label:"ð¥"}].map(g=>e.jsxs("div",{className:"bg-slate-700/40 rounded-xl p-2",children:[e.jsx("div",{className:"text-lg",children:g.label}),e.jsxs("div",{className:"font-bold text-xs",style:{color:u(g.rank)},children:["+",g.prize," XP"]})]},g.rank))}),h.length>0?e.jsx("div",{className:"space-y-1",children:h.slice(0,10).map((g,p)=>e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx("span",{className:"w-5 text-xs font-bold text-center",style:{color:u(p+1)},children:p===0?"ð¥":p===1?"ð¥":p===2?"ð¥":`${p+1}`}),e.jsx("span",{className:`flex-1 text-xs truncate font-semibold ${g.userId===n?.entry?.userId?"text-cyan-300":"text-white/70"}`,children:g.username}),e.jsx("span",{className:"text-xs font-mono text-white/60",children:(g.xp??0).toLocaleString()})]},g.userId))}):e.jsx("p",{className:"text-white/25 text-xs text-center",children:"Be the first to earn XP this week!"})]})]})}const Gs={challenge_received:"âï¸",challenge_accepted:"â
",challenge_declined:"â",gift_received:"ð",bounty_placed:"ð¯",tournament_ready:"ð",league_promotion:"ð
",streak_at_risk:"â ï¸"};function Hs(){const[t,l]=d.useState([]),[n,a]=d.useState(0),[r,c]=d.useState(!1),{isAuthenticated:i}=M(),s=()=>
17{if(!i)return;const h=localStorage.getItem("token");h&&j.get("/api/gamification/v2/notifications/my",{headers:{Authorization:`Bearer ${h}`}}).then(o=>{l(o.data.notifications||[]),a(o.data.unread||0)}).catch(()=>{})};d.useEffect(()=>{s();const h=setInterval(s,15e3);return()=>clearInterval(h)},[i]);const m=async()=>{const h=localStorage.getItem("token");await j.post("/api/gamification/v2/notifications/read-all",{},{headers:{Authorization:`Bearer ${h}`}}).catch(()=>{}),a(0),l(o=>o.map(b=>({...b,read:!0})))},x=async h=>{const o=localStorage.getItem("token");await j.delete(`/api/gamification/v2/notifications/${h}`,{headers:{Authorization:`Bearer ${o}`}}).catch(()=>{}),l(b=>b.filter(u=>u.id!==h))};return i?e.jsxs("div",{className:`rounded-2xl border overflow-hidden transition-all ${n>0?"border-indigo-400/35 bg-indigo-900/15":"border-white/8 bg-white/[0.03]"}`,children:[e.jsxs("button",{onClick:()=>{c(h=>!h),!r&&n>0&&m()},className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2 text-white/70",children:["ð Notifications",n>0&&e.jsx("span",{className:"bg-red-500 text-white text-[10px] font-black px-1.5 py-0.5 rounded-full min-w-[18px] text-center animate-pulse",children:n})]}),e.jsx("span",{className:"text-white/25 text-xs",children:r?"â²":"â¼"})]}),r&&e.jsxs("div",{className:"px-4 pb-4",children:[t.length===0?e.jsx("p",{className:"text-white/25 text-xs text-center py-2",children:"No notifications yet"}):e.jsx("div",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:t.map(h=>e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2 ${h.read?"bg-white/[0.03]":"bg-indigo-500/10 border border-indigo-500/20"}`,children:[e.jsx("span",{className:"text-base mt-0.5 flex-shrink-0",children:Gs[h.type]||"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white/80 text-xs font-semibold truncate",children:h.title}),e.jsx("p",{className:"text-white/60 text-[10px] truncate",children:h.body}),e.jsx("p",{className:"text-white/50 text-[9px] mt-0.5",children:new Date(h.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("button",{onClick:()=>x(h.id),className:"text-white/50 hover:text-white/50 text-xs flex-shrink-0 mt-0.5",children:"Ã"})]}
17,h.id))}),t.length>0&&n>0&&e.jsx("button",{onClick:m,className:"w-full mt-2 text-[10px] text-white/60 hover:text-white/50 transition-colors",children:"Mark all read"})]})]}):null}function Qs(){const[t,l]=d.useState([]),[n,a]=d.useState([]),[r,c]=d.useState(!1),[i,s]=d.useState("inbox"),[m,x]=d.useState(""),[h,o]=d.useState("General"),[b,u]=d.useState(!1),[g,p]=d.useState(""),{isAuthenticated:f}=M(),v=["General","Science","Math","History","English","Geography","Computer Science","Arts"],S=()=>{if(!f)return;const I=localStorage.getItem("token");if(!I)return;const R={headers:{Authorization:`Bearer ${I}`}};j.get("/api/gamification/v2/direct-challenges/inbox",R).then(L=>l(L.data.challenges||[])).catch(()=>{}),j.get("/api/gamification/v2/direct-challenges/sent",R).then(L=>a(L.data.challenges||[])).catch(()=>{})};d.useEffect(()=>{S();const I=setInterval(S,2e4);return()=>clearInterval(I)},[f]);const C=async()=>{if(!m.trim()){p("Enter a username.");return}u(!0),p("");try{const I=localStorage.getItem("token");await j.post("/api/gamification/v2/direct-challenges/send",{toUsername:m.trim(),subject:h},{headers:{Authorization:`Bearer ${I}`}}),p(`â Challenge sent to ${m}!`),x(""),S()}catch(I){p(I.response?.data?.error||"Failed.")}finally{u(!1)}},P=async(I,R)=>{try{const L=localStorage.getItem("token");await j.post(`/api/gamification/v2/direct-challenges/respond/${I}`,{accept:R},{headers:{Authorization:`Bearer ${L}`}}),S(),R&&p("Challenge accepted! Head to Brain Battles to play.")}catch(L){p(L.response?.data?.error||"Failed.")}};if(!f)return null;const y=t.length,$=I=>{const R=Math.floor((Date.now()-I)/6e4);return R<60?`${R}m ago`:`${Math.floor(R/60)}h ago`},A=I=>I==="accepted"?"text-green-400":I==="declined"?"text-red-400":I==="pending"?"text-white/40":"text-white/50";return e.jsxs("div",{className:`rounded-2xl border overflow-hidden ${y>0?"border-rose-500/30 bg-rose-900/10":"border-white/8 bg-white/[0.03]"}`,children:[e.jsxs("button",{onClick:()=>c(I=>!I),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"font-bold text-sm flex items-center gap-2 text-rose-300",children:["âï¸ Direct Challenges",y>0&&e.jsx("span",{className:"bg-rose-500 text-white text-[10px] font-black px-1.5 py-0.5 rounded-full animate-pulse",children:y})]}),e.jsx("span",{className:"text-rose-600/40 text-xs",children:r?"â²":"â¼"})]}),r&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"flex gap-1 bg-slate-700/40 rounded-xl p-1",children:[["inbox","Inbox"],["send","Send"],["sent","Sent"]].map(([I,R])=>e.jsxs("button",{onClick:()=>s(I),className:`flex-1 py-1 rounded-lg text-xs font-bold transition-all ${i===I?"bg-rose-600 text-white":"text-white/60 hover:text-white/60"}`,children:[R,I==="inbox"&&y>0&&` (${y})`]},I))}),i==="send"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{value:m,onChange:I=>x(I.target.value),placeholder:"Username...",className:"w-full px-3 py-2 bg-black/30 border border-white/15 rounded-xl text-white text-xs placeholder-white/50 focus:outline-none"}),e.jsx("select",{value:h,onChange:I=>o(I.target.value),className:"w-full px-3 py-2 bg-black/30 border border-white/15 rounded-xl text-white text-xs focus:outline-none",children:v.map(I=>e.jsx("option",{value:I,children:I},I))}),e.jsx("button",{onClick:C,disabled:b,className:"w-full py-2 bg-rose-600 hover:bg-rose-500 text-white text-xs font-bold rounded-xl disabled:opacity-50",children:b?"...":"âï¸ Send Challenge"})]}),i==="inbox"&&(t.length===0?e.jsx("p",{className:"text-white/25 text-xs text-center",children:"No pending challenges"}):t.map(I=>e.jsxs("div",{className:"bg-slate-700/40 border border-rose-500/20 rounded-xl p-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-2 mb-2",children:e.jsxs("div",{children:[e.jsxs("p",{className:"text-white/80 text-xs font-bold",children:[I.fromName," challenged you!"]}),e.jsxs("p",{className:"text-white/60 text-[10px]",children:[I.subject," · ",$(I.ts)]})]})}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>P(I.id,!0),className:"flex-1 py-1.5 bg-green-600/30 border border-green-500/30 text-green-300 text-xs font-bold rounded-lg hover:bg-green-600/40",children:"Accept"}),e.jsx("button",{onClick:()=>P(I.id,!1),className:"flex-1 py-1.5 bg-slate-700/40 border border-white/25 text-white/60 text-xs font-bold rounded-lg hover:bg-white/10",children:"Decline"})]})]},I.id))),i==="sent"&&(n.length===0?e.jsx("p",{className:"text-white/25 text-xs text-center",children:"No sent challenges"}):n.slice(0,5).map(I=>e.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.03] rounded-xl px-3 py-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-white/70 text-xs font-semibold truncate",children:["â ",I.toName]}),e.jsxs("p",{className:"text-white/60 text-[10px]",children:[I.subject," · ",$(I.ts)]})]}),e.jsx("span",{className:`text-[10px] font-bold ${A(I.status)}`,children:I.status})]},I.id))),g&&e.jsx("p",{className:`text-xs text-center font-semibold ${g.startsWith("â")?"text-green-400":"text-red-400/70"}`,children:g})]})]})}function Ys(){const[t,l]=d.useState([]),[n,a]=d.useState(!0),{isAuthenticated:r}=M();if(d.useEffect(()=>{if(!r)return;const s=localStorage.getItem("token");s&&j.get("/api/gamification/v2/quests/today",{headers:{Authorization:`Bearer ${s}`}}).then(m=>l(m.data.quests||[])).catch(()=>{})},[r]),!r||t.length===0)return null;const c=t.filter(s=>s.completed).length,i=t.length;return e.jsxs("div",{className:"bg-gradient-to-br from-violet-900/20 to-purple-900/15 rounded-2xl border border-violet-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-violet-300 font-bold text-sm flex items-center gap-2",children:["ð Daily Quests",e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-bold ${c===i?"bg-green-500/25 text-green-300":"bg-violet-500/20 text-violet-300"}`,children:[c,"/",i]})]}),e.jsx("span",{className:"text-violet-600/40 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[t.map(s=>{const m=Math.min(100,Math.round(s.progress/s.target*100));return e.jsxs("div",{className:`rounded-xl p-3 border transition-all ${s.completed?"bg-green-500/10 border-green-500/25":"bg-white/[0.04] border-white/8"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsx("span",{className:`text-xs font-semibold ${s.completed?"text-green-300 line-through opacity-60":"text-white/80"}`,children:s.label}),e.jsxs("span",{className:"text-xs font-bold text-violet-300 whitespace-nowrap",children:["+",s.xp," XP"]})]}),e.jsx("div",{className:"h-1.5 bg-slate-800/80 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${m}
17%`,background:s.completed?"#22c55e":"#8b5cf6"}})}),e.jsxs("div",{className:"text-white/25 text-[10px] mt-1",children:[s.progress,"/",s.target]})]},s.id)}),c===i&&e.jsx("p",{className:"text-green-400 text-xs text-center font-bold pt-1",children:"All quests complete! Resets at midnight UTC."})]})]})}const Js=[{id:"streak_freeze",name:"Streak Freeze",desc:"Protect streak 1 day",price:100,emoji:"âï¸"},{id:"xp_boost",name:"XP Boost Ã3",desc:"1.5à XP, 3 battles",price:250,emoji:"â¡"},{id:"lottery_5",name:"Lottery Pack Ã5",desc:"5 lottery tickets",price:225,emoji:"ð°"},{id:"powerup_bundle",name:"Power-Up Bundle",desc:"3 random power-ups",price:200,emoji:"ð¥"},{id:"xp_boost_big",name:"XP Boost Ã10",desc:"2à XP, 10 battles",price:750,emoji:"ð"},{id:"title_mystery",name:"Mystery Title",desc:"Unlock random title",price:500,emoji:"ð"},{id:"lp_boost",name:"League LP Boost",desc:"+25 LP on next 3 wins",price:400,emoji:"ð
"}];function Vs(){const[t,l]=d.useState(!1),[n,a]=d.useState(null),[r,c]=d.useState(""),{isAuthenticated:i}=M(),s=async x=>{c(""),a(x.id);try{const h=localStorage.getItem("token"),o=parseInt(localStorage.getItem("sq_xp")||"0",10);if(o<x.price){c(`Need ${x.price} XP (have ${o}).`);return}await j.post("/api/gamification/v2/shop/buy",{itemId:x.id},{headers:{Authorization:`Bearer ${h}`}}),localStorage.setItem("sq_xp",String(o-x.price)),c(`â ${x.name} purchased!`)}catch(h){c(h.response?.data?.error||"Failed.")}finally{a(null)}};if(!i)return null;const m=parseInt(localStorage.getItem("sq_xp")||"0",10);return e.jsxs("div",{className:"bg-gradient-to-br from-amber-900/18 to-orange-900/12 rounded-2xl border border-amber-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>l(x=>!x),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-amber-300 font-bold text-sm flex items-center gap-2",children:["ð XP Shop",e.jsxs("span",{className:"text-amber-500/60 text-xs font-normal",children:[m.toLocaleString()," XP"]})]}),e.jsx("span",{className:"text-amber-600/40 text-xs",children:t?"â²":"â¼"})]}),t&&e.jsxs("div",{className:"px-4 pb-4 space-y-1.5",children:[Js.map(x=>e.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.04] border border-white/8 rounded-xl px-3 py-2",children:[e.jsx("span",{className:"text-lg",children:x.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-white/80 text-xs font-bold truncate",children:x.name}),e.jsx("div",{className:"text-white/60 text-[10px]",children:x.desc})]}),e.jsx("button",{onClick:()=>s(x),disabled:n===x.id||m<x.price,className:`text-xs font-bold px-2.5 py-1.5 rounded-lg transition-all whitespace-nowrap ${m>=x.price?"bg-amber-600 hover:bg-amber-500 text-white":"bg-slate-700/40 text-white/50 cursor-not-allowed"} disabled:opacity-50`,children:n===x.id?"...":`${x.price} XP`})]},x.id)),r&&e.jsx("p",{className:`text-xs text-center font-semibold mt-1 ${r.startsWith("â")?"text-green-400":"text-red-400/70"}`,children:r})]})]})}function Ks(){const[t,l]=d.useState(!1),[n,a]=d.useState([]),[r,c]=d.useState(!1),[i,s]=d.useState(null),[m,x]=d.useState(""),[h,o]=d.useState(4),[b,u]=d.useState(""),{isAuthenticated:g}=M(),p=T(),f=()=>{j.get("/api/gamification/v2/brackets/list").then(C=>a(C.data.tournaments||[])).catch(()=>{})};d.useEffect(()=>{f();const C=setInterval(f,15e3);return()=>clearInterval(C)},[]);const v=async()=>{c(!0),u("");try{const C=localStorage.getItem("token"),P=await j.post("/api/gamification/v2/brackets/create",{name:m||void 0,size:h},{headers:{Authorization:`Bearer ${C}`}});u(`â Created! Share ID: ${P.data.tournament.id}`),f()}catch(C){u(C.response?.data?.error||"Failed.")}finally{c(!1)}},S=async C=>{s(C),u("");try{const P=localStorage.getItem("token");await j.post(`/api/gamification/v2/brackets/join/${C}`,{},{headers:{Authorization:`Bearer ${P}`}}),p(`/brain-battles/bracket/${C}`)}catch(P){u(P.response?.data?.error||"Failed."),s(null)}};return e.jsxs("div",{className:"bg-gradient-to-br from-indigo-900/20 to-purple-900/15 rounded-2xl border border-indigo-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>l(C=>!C),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-indigo-300 font-bold text-sm flex items-center gap-2",children:["ð Tournaments",n.length>0&&e.jsxs("span",{className:"bg-indigo-500/20 text-indigo-300 text-[10px] px-1.5 py-0.5 rounded font-bold",children:[n.length," open"]})]}),e.jsx("span",{className:"text-indigo-600/40 text-xs",children:t?"â²":"â¼"})]}),t&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[n.length>0?e.jsx("div",{className:"space-y-1.5",children:n.map(C=>e.jsxs("div",{className:"flex items-center gap-2 bg-slate-700/40 rounded-xl px-3 py-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-white/80 text-xs font-bold truncate",children:C.name}),e.jsxs("div",{className:"text-white/60 text-[10px]",children:[C.joined,"/",C.size," players"]})]}),e.jsx("button",{onClick:()=>S(C.id),disabled:i===C.id||!g,className:"text-xs font-bold px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg transition-all disabled:opacity-50",children:i===C.id?"...":"Join"}),e.jsx("button",{onClick:()=>p(`/brain-battles/bracket/${C.id}`),className:"text-xs text-indigo-400/60 hover:text-indigo-400 px-1",children:"View"})]},C.id))}):e.jsx("p",{className:"text-white/25 text-xs text-center",children:"No open tournaments â create one!"}),g&&e.jsxs("div",{className:"border-t border-white/25 pt-3 space-y-2",children:[e.jsx("p",{className:"text-white/60 text-[10px] uppercase tracking-wider",children:"Create Tournament"}),e.jsx("input",{value:m,onChange:C=>x(C.target.value),placeholder:"Tournament name (optional)",className:"w-full px-3 py-1.5 bg-black/30 border border-white/15 rounded-lg text-white text-xs placeholder-white/50 focus:outline-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{value:h,onChange:C=>o(parseInt(C.target.value)),className:"flex-1 px-2 py-1.5 bg-black/30 border border-white/15 rounded-lg text-white text-xs focus:outline-none",children:[e.jsx("option",{value:4,children:"4 players"}),e.jsx("option",{value:8,children:"8 players"})]}),e.jsx("button",{onClick:v,disabled:r,className:"flex-1 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-bold rounded-lg transition-all disabled:opacity-50",children:r?"...":"+ Create"})]})]}),b&&e.jsx("p",{className:"text-xs text-center text-white/50 font-semibold",children:b})]})]})}function Zs(){const[t,l]=d.useState([]),[n,a]=d.useState(!1),[r,c]=d.use
17State(!1),[i,s]=d.useState(""),[m,x]=d.useState(""),[h,o]=d.useState(200),[b,u]=d.useState(!1),[g,p]=d.useState(""),{isAuthenticated:f,user:v}=M(),S=T();d.useEffect(()=>{const P=()=>{j.get("/api/gamification/v2/bounties").then($=>l($.data.bounties||[])).catch(()=>{})};P();const y=setInterval(P,3e4);return()=>clearInterval(y)},[]);const C=async()=>{if(!m||h<50){p("Enter a valid player ID and min 50 XP.");return}u(!0),p("");try{const P=localStorage.getItem("token");await j.post("/api/gamification/v2/bounties",{targetId:m,targetName:i,amount:h},{headers:{Authorization:`Bearer ${P}`}});const y=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(Math.max(0,y-h))),c(!1),s(""),x(""),o(200),j.get("/api/gamification/v2/bounties").then($=>l($.data.bounties||[])).catch(()=>{})}catch(P){p(P.response?.data?.error||"Failed to place bounty.")}finally{u(!1)}};return e.jsxs("div",{className:"bg-gradient-to-br from-orange-900/30 to-amber-900/20 rounded-2xl border border-orange-500/25 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(P=>!P),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-orange-300 font-bold text-sm flex items-center gap-2",children:["ð¯ Bounties ",e.jsxs("span",{className:"text-orange-500/50 text-xs font-normal",children:[t.length," active"]})]}),e.jsx("span",{className:"text-orange-500/40 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[t.slice(0,4).map(P=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"ð¤ "}),e.jsx("button",{onClick:()=>S(`/brain-battles/player/${P.targetId}`),className:"flex-1 text-left truncate text-xs text-amber-200/80 hover:text-amber-300 font-semibold transition-colors",children:P.targetName}),e.jsxs("span",{className:"text-xs text-orange-400 font-mono font-bold",children:[P.amount.toLocaleString()," XP"]})]},P.bountyId)),t.length===0&&e.jsx("p",{className:"text-orange-600/40 text-xs text-center py-1",children:"No active bounties â be the first!"}),f&&(r?e.jsxs("div",{className:"bg-orange-900/20 border border-orange-500/20 rounded-xl p-3 space-y-2 mt-1",children:[e.jsx("input",{value:m,onChange:P=>x(P.target.value),placeholder:"Target player ID",className:"w-full px-2 py-1.5 bg-black/30 border border-white/25 rounded-lg text-white text-xs focus:outline-none"}),e.jsx("input",{value:i,onChange:P=>s(P.target.value),placeholder:"Their name (optional)",className:"w-full px-2 py-1.5 bg-black/30 border border-white/25 rounded-lg text-white text-xs focus:outline-none"}),e.jsx("input",{type:"number",value:h,min:50,max:1e4,onChange:P=>o(parseInt(P.target.value)||50),className:"w-full px-2 py-1.5 bg-black/30 border border-white/25 rounded-lg text-white text-xs focus:outline-none"}),g&&e.jsx("p",{className:"text-red-400 text-xs",children:g}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,disabled:b,className:"flex-1 py-1.5 bg-orange-600 hover:bg-orange-500 text-white text-xs font-bold rounded-lg transition-all disabled:opacity-50",children:b?"...":`Place (â${h} XP)`}),e.jsx("button",{onClick:()=>c(!1),className:"px-3 py-1.5 bg-slate-800/80 text-white/50 text-xs rounded-lg",children:"â"})]})]}):e.jsx("button",{onClick:()=>c(!0),className:"w-full py-1.5 text-xs text-orange-400/60 hover:text-orange-400 font-semibold transition-colors",children:"+ Place a Bounty"}))]})]})}function ea(){const[t,l]=d.useState([]),[n,a]=d.useState(!1),[r,c]=d.useState(null),{isAuthenticated:i}=M(),s=()=>{const x=localStorage.getItem("token");x&&j.get("/api/gamification/v2/gifts/received",{headers:{Authorization:`Bearer ${x}`}}).then(h=>l(h.data.gifts||[])).catch(()=>{})};d.useEffect(()=>{if(!i)return;s();const x=setInterval(s,3e4);return()=>clearInterval(x)},[i]);const m=async x=>{c(x);try{const h=localStorage.getItem("token"),o=await j.post(`/api/gamification/v2/gifts/${x}/claim`,{},{headers:{Authorization:`Bearer ${h}`}}),b=parseInt(localStorage.getItem("sq_xp")||"0",10);localStorage.setItem("sq_xp",String(b+o.data.xp)),l(u=>u.filter(g=>g.giftId!==x))}catch{}finally{c(null)}};return!i||t.length===0?null:e.jsxs("div",{className:"bg-gradient-to-br from-pink-900/30 to-rose-900/20 rounded-2xl border border-pink-500/25 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(x=>!x),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-pink-300 font-bold text-sm flex items-center gap-2",children:["ð Gift Inbox",e.jsx("span",{className:"bg-pink-500 text-white text-[10px] font-black px-1.5 py-0.5 rounded-full",children:t.length})]}),e.jsx("span",{className:"text-pink-500/40 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsx("div",{className:"px-4 pb-4 space-y-2",children:t.map(x=>e.jsxs("div",{className:"bg-pink-500/10 border border-pink-500/20 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-pink-200 text-xs font-bold",children:["From ",x.senderName]}),e.jsxs("span",{className:"text-yellow-400 text-xs font-mono font-bold",children:["+",x.amount," XP"]})]}),x.message&&e.jsxs("p",{className:"text-white/60 text-xs italic mb-2",children:['"',x.message,'"']}),e.jsx("button",{onClick:()=>m(x.giftId),disabled:r===x.giftId,className:"w-full py-1 bg-pink-600 hover:bg-pink-500 text-white text-xs font-bold rounded-lg transition-all disabled:opacity-50",children:r===x.giftId?"Claiming...":"Claim Gift"})]},x.giftId))})]})}function ta(){const[t,l]=d.useState([]),[n,a]=d.useState(!1),r=T(),{isAuthenticated:c}=M();return d.useEffect(()=>{if(!c)return;const i=localStorage.getItem("token");i&&j.get("/api/gamification/v2/rivals/my",{headers:{Authorization:`Bearer ${i}`}}).then(s=>l(s.data.rivals||[])).catch(()=>{})},[c]),!c||t.length===0?null:e.jsxs("div",{className:"bg-gradient-to-br from-red-900/30 to-rose-900/20 rounded-2xl border border-red-500/20 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(i=>!i),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-red-300 font-bold text-sm flex items-center gap-2",children:["âï¸ Rivals ",e.jsxs("span",{className:"text-red-500/50 text-xs font-normal",children:[t.length," tracked"]})]}),e.jsx("span",{className:"text-red-500/50 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[t.slice(0,3).map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"ð¤"}),e.jsx("button",{onClick:()=>r(`/brain-battles/player/${i.rivalId}`),className:"flex-1 text-left text-xs text-red-200/80 hover:text-red-300 font-semibold truncate transition-colors",children:i.rivalName}),e.jsxs("span",{className:"text-xs text-red-500/60 font-mono",children:[i.wins,"W / ",i.losses,"L"]}),e.jsx("button",{onClick:()=>r("/brain-battles"),className:"text-xs px-2 py-0.5 bg-red-600/30 hover:bg-red-600/50 text-red-300 rounded-lg transition-all font-bold",children:"Rematch"})]},i.rivalId)),e.jsx("p",{className:"text-red-600/40 text-[10px] text-center pt-1",children:"Beat them 2+ times to clear the rivalry"})]})]})}const ee=["Biology","Chemistry","Physics","History","Math"],fe=["text-emerald-400","text-blue-400","text-purple-400","text-amber-400","text-pink-400"];function sa(){const[t,l]=d.useState(null),[n,a]=d.useState(!0),[r,c]=d.use
17State(0);d.useEffect(()=>{j.get("/api/gamification/v2/championships").then(s=>l(s.data)).catch(()=>{})},[]);const i=t?ee.map(s=>{const m=(t.championships?.[s]||[])[0];return{subject:s,leader:m||null}}):[];return e.jsxs("div",{className:"bg-white/4 border border-white/8 rounded-2xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-slate-700/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{size:15,className:"text-amber-400"}),e.jsx("span",{className:"text-white/80 text-sm font-bold",children:"Subject Championships"}),e.jsx("span",{className:"text-xs text-amber-400/70 bg-amber-500/10 px-1.5 py-0.5 rounded-md font-semibold",children:"Weekly"})]}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4",children:[e.jsx("div",{className:"flex gap-1 mb-3 overflow-x-auto pb-1",children:ee.map((s,m)=>e.jsx("button",{onClick:()=>c(m),className:`flex-shrink-0 px-2.5 py-1 rounded-lg text-xs font-semibold transition-all ${r===m?`${fe[m]} bg-white/10`:"text-white/60 hover:text-white/60"}`,children:s.length>4?s.split(" ")[0]:s},s))}),t?e.jsx("div",{className:"space-y-1.5",children:(t.championships?.[ee[r]]||[]).length===0?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-white/25 text-xs",children:"No battles yet this week"}),e.jsx(B,{to:"/brain-battles",className:"text-blue-400/70 text-xs hover:underline",children:"Battle now â"})]}):(t.championships?.[ee[r]]||[]).map((s,m)=>e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-xl ${m===0?"bg-amber-500/10 border border-amber-500/20":"bg-white/4"}`,children:[e.jsx("span",{className:`text-xs font-black w-4 text-center ${m===0?"text-amber-400":m===1?"text-white/50":"text-white/60"}`,children:m===0?"ð":`#${m+1}`}),e.jsx("span",{className:"flex-1 text-white/80 text-xs font-semibold truncate",children:s.name}),e.jsx("span",{className:`text-xs font-bold ${fe[r]}`,children:s.score})]},s.userId))}):e.jsx("div",{className:"space-y-2",children:[1,2,3].map(s=>e.jsx("div",{className:"h-8 bg-slate-700/40 rounded-lg animate-pulse"},s))}),i.some(s=>s.leader)&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/8",children:[e.jsx("p",{className:"text-white/60 text-xs font-semibold mb-2 uppercase tracking-wide",children:"Current Leaders"}),e.jsx("div",{className:"grid grid-cols-1 gap-1",children:i.filter(s=>s.leader).slice(0,3).map((s,m)=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:`font-semibold ${fe[ee.indexOf(s.subject)]}`,children:s.subject.split(" ")[0]}),e.jsx("span",{className:"text-white/50 truncate max-w-[100px]",children:s.leader.name}),e.jsx("span",{className:"text-white/60",children:s.leader.score})]},s.subject))})]})]})]})}function aa(){const[t,l]=d.useState(null),[n,a]=d.useState(!1),r=T();if(d.useEffect(()=>{j.get("/api/gamification/v2/hall-of-fame").then(s=>l(s.data)).catch(()=>{})},[]),!t)return null;const c=t.current?.entries||[];if(c.length===0&&(!t.past||t.past.length===0))return null;const i=["ð¥","ð¥","ð¥"];return e.jsxs("div",{className:"bg-gradient-to-br from-yellow-900/30 to-amber-900/20 rounded-2xl border border-yellow-500/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-3 text-left",children:[e.jsxs("span",{className:"text-yellow-300 font-bold text-sm flex items-center gap-2",children:["ð Hall of Fame ",e.jsx("span",{className:"text-yellow-500/60 text-xs font-normal",children:"Monthly Top"})]}),e.jsx("span",{className:"text-yellow-500/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[c.slice(0,3).map((s,m)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:i[m]||"ðï¸"}),e.jsx("button",{onClick:()=>r(`/brain-battles/player/${s.userId}`),className:"flex-1 text-left truncate text-xs text-amber-200 hover:text-yellow-300 transition-colors",children:s.username}),e.jsxs("span",{className:"text-xs text-yellow-500 font-mono",children:[(s.xp||0).toLocaleStr
17ing()," XP"]})]},s.userId)),c.length===0&&e.jsx("p",{className:"text-yellow-600/60 text-xs text-center py-2",children:"No entries yet this month â battle to claim glory!"}),t.past&&t.past.length>0&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"border-t border-yellow-700/30 pt-2 mt-2",children:[e.jsx("p",{className:"text-yellow-600/50 text-xs mb-1",children:"Last month's champion"}),(()=>{const s=t.past[0].entries?.[0];return s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsx("span",{className:"flex-1 truncate text-xs text-amber-300",children:s.username}),e.jsxs("span",{className:"text-xs text-yellow-600 font-mono",children:[(s.totalXP??0).toLocaleString()," XP"]})]}):null})()]})}),e.jsx("button",{onClick:()=>r("/brain-battles/stats"),className:"w-full py-1.5 text-xs text-yellow-500/60 hover:text-yellow-400 font-semibold transition-colors text-center",children:"View my stats â"})]})]})}function la(){const[t,l]=d.useState(null),[n,a]=d.use
17State(!1),[r,c]=d.useState(!0),i=localStorage.getItem("sq_my_guild_id");if(d.useEffect(()=>{j.get("/api/gamification/v2/clan-wars/current").then(h=>l(h.data.war)).catch(()=>{}).finally(()=>c(!1))},[]),r||!t)return null;const s=t.guilds?.find(h=>h.guildId===i),m=t.guilds?.[0],x=Math.max(0,Math.ceil((t.weekEnd-Date.now())/864e5));return e.jsxs("div",{className:"mt-4 rounded-2xl overflow-hidden border border-orange-500/20 bg-gradient-to-b from-orange-500/5 to-transparent",children:[e.jsxs("button",{onClick:()=>a(h=>!h),className:"w-full flex items-center gap-3 px-5 py-4 hover:bg-slate-700/40 transition-colors",children:[e.jsx("span",{className:"text-xl",children:"âï¸"}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-white font-bold text-sm",children:"Clan Wars"}),e.jsx("p",{className:"text-white/60 text-xs",children:m?`${m.name} leading · ${(m.points??0).toLocaleString()} pts`:"No clans yet â be first!"})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("p",{className:"text-orange-400/60 text-[10px]",children:[x,"d left"]}),s&&e.jsxs("p",{className:"text-orange-300 text-[10px] font-bold",children:["#",(t.guilds?.findIndex(h=>h.guildId===i)??0)+1]})]}),e.jsx("span",{className:"text-white/60 text-xs",children:n?"â²":"â¼"})]}),n&&e.jsxs("div",{className:"px-5 pb-5",children:[t.guilds?.length===0?e.jsx("p",{className:"text-white/60 text-xs text-center py-4",children:"No guilds have contributed yet this week."}):e.jsx("div",{className:"space-y-2 mb-3",children:t.guilds.slice(0,8).map((h,o)=>{const b=t.guilds[0]?.points||1,u=h.guildId===i;return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-xl ${u?"bg-orange-500/10 border border-orange-500/20":"bg-white/3"}`,children:[e.jsxs("span",{className:"text-xs font-black w-5 text-center",style:{color:o<3?["#f59e0b","#9ca3af","#b45309"][o]:"#4b5563"},children:["#",o+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsx("span",{className:"text-white/80 text-xs font-semibold truncate",children:h.name}),e.jsx("span",{className:"text-orange-300 text-xs font-bold ml-2",children:(h.points??0).toLocaleString()})]}),e.jsx("div",{className:"w-full bg-slate-700/40 rounded-full h-1 overflow-hidden",children:e.jsx("div",{className:"h-1 rounded-full transition-all",style:{width:`${h.points/b*100}%`,background:u?"#f97316":"#6b7280"}})})]}),e.jsxs("span",{className:"text-white/50 text-[10px]",children:[h.memberCount,"m"]})]},h.guildId)})}),e.jsx("p",{className:"text-white/50 text-[10px] text-center",children:"Your battle XP automatically contributes to your guild's war score."})]})]})}function na({onPlayRanked:t}){const l=(()=>{try{return parseInt(localStorage.getItem("sq_rating")||"1200",10)}catch{return 1200}})(),n=localStorage.getItem("sq_last_ranked_date")||null,[a,r]=d.useState(!1),[c,i]=d.useState({daysSince:0,decayPoints:0,protected:!0}),m=Math.max(0,Math.ceil((new Date("2026-05-31T23:59:59Z")-Date.now())/864e5));d.useEffect(()=>{if(!n){i({daysSince:0,decayPoints:0,protected:!0});return}const b=Math.floor((Date.now()-new Date(n).getTime())/864e5),g=Math.max(0,Math.floor((b-7)/7))*10,p=b<=7;if(g>0){const f=Math.max(1e3,l-g);f!==l&&localStorage.setItem("sq_rating",String(f))}i({daysSince:b,decayPoints:g,protected:p})},[n,l]);const x=(()=>{try{return parseInt(localStorage.getItem("sq_rating")||"1200",10)}catch{return 1200}})(),h=st(x),o=Cs(x);return e.jsxs("div",{className:"mt-4 rounded-2xl overflow-hidden border",style:{borderColor:`${h.color}30`,background:`linear-gradient(135deg, ${h.color}08 0%, #0a0a1200 100%)`},children:[e.jsxs("button",{onClick:()=>r(b=>!b),className:"w-full flex items-center gap-3 px-5 py-4 hover:bg-slate-700/40 transition-colors",children:[e.jsx("span",{className:"text-xl",children:h.icon}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsxs("p",{className:"text-white font-bold text-sm",children:[h.label," â Elo ",x]}),e.jsx("div",{className:"w-full bg-slate-800/80 rounded-full h-1.5 mt-1 overflow-hidden",children:e.jsx("div",{className:"h-1.5 rounded-full transition-all",style:{width:`${o.pct}%`,background:h.color}})})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("p",{className:"text-white/60 text-[10px]",children:[m,"d left"]}),e.jsx("p",{className:"text-white/50 text-[10px]",children:"Season 1"})]}),e.jsx("span",{className:"text-white/60 text-xs",children:a?"â²":"â¼"})]}),a&&e.jsxs("div",{className:"px-5 pb-5",children:[e.jsxs("div",{className:"flex justify-between text-xs mb-3",children:[e.jsx("span",{style:{color:h.color},className:"font-bold",children:h.label}),o.needed>0?e.jsxs("span",{className:"text-white/60",children:[o.needed," Elo to ",o.label]}):e.jsx("span",{className:"text-yellow-400 font-bold",children:"â Ma
17x Rank!"})]}),e.jsxs("div",{className:"bg-slate-700/40 rounded-xl p-3 mb-3",children:[e.jsx("p",{className:"text-white/60 text-[10px] font-bold uppercase tracking-wider mb-1",children:"Season-End Reward"}),e.jsxs("p",{className:"text-white/70 text-xs",children:[h.icon," ",h.reward]})]}),e.jsx("div",{className:"space-y-1.5 mb-3",children:se.map(b=>e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-xl text-xs transition-all ${b.label===h.label?"bg-slate-800/80 border border-white/15":"opacity-40"}`,children:[e.jsx("span",{children:b.icon}),e.jsx("span",{className:"font-bold",style:{color:b.color},children:b.label}),e.jsxs("span",{className:"text-white/60 text-[10px] flex-1",children:[b.min,"+ Elo"]}),b.label===h.label&&e.jsx("span",{className:"text-white/50 font-bold",children:"â YOU"})]},b.label))}),!c.protected&&c.daysSince>7&&e.jsxs("div",{className:"bg-red-900/30 border border-red-500/30 rounded-xl p-3 mb-3 text-xs",children:[e.jsx("p",{className:"text-red-300 font-bold mb-0.5",children:"â ï¸ Rank Decay Active"}),e.jsxs("p",{className:"text-red-400/70",children:[c.daysSince,"d since last ranked game · â",c.decayPoints," Elo applied. Play now to protect your rank!"]})]}),c.protected&&c.daysSince>0&&e.jsx("div",{className:"bg-green-900/20 border border-green-500/20 rounded-xl p-3 mb-3 text-xs",children:e.jsxs("p",{className:"text-green-400 font-semibold",children:["ð¡ï¸ Rank protected â ",7-c.daysSince,"d remaining"]})}),e.jsx("button",{onClick:t,className:"w-full py-2.5 bg-gradient-to-r from-cyan-600 to-teal-600 text-white text-sm font-black rounded-xl hover:scale-[1.02] transition-all",children:"ð
Play Ranked Match"})]})]})}const ra={common:"#6b7280",uncommon:"#06b6d4",rare:"#a855f7",epic:"#ec4899"};function ia({onClose:t}){const[l,n]=d.useState([]),[a,r]=d.useState(0),[c,i]=d.useState(null),[s,m]=d.useState(""),[x,h]=d.useState(new Set),o=u=>{m(u),setTimeout(()=>m(""),3e3)};d.useEffect(()=>{j.get("/api/gamification/v2/store/catalog").then(u=>n(u.data.catalog||[])).catch(()=>{});try{r(parseInt(localStorage.getItem("sq_xp")||"0",10))}catch{}},[]);const b=async u=>{if(a<u.price){o(`Need ${u.price-a} more XP!`);return}i(u.id);try{await j.post("/api/gamification/v2/store/purchase",{itemId:u.id});try{if(u.grantKey==="sq_streak_shield")localStorage.setItem("sq_streak_shield","1");else if(u.grantKey==="sq_power_pack_charges"){const p=parseInt(localStorage.getItem("sq_power_pack_charges")||"0",10);localStorage.setItem("sq_power_pack_charges",String(p+3))}else if(u.grantKey==="sq_xp_boost_expires"){const p=Date.now()+72e5;localStorage.setItem("sq_xp_boost_expires",String(p)),localStorage.setItem("sq_xp_boost_mult","2")}else if(u.grantKey==="sq_cosmetic_tokens"){const p=parseInt(localStorage.getItem("sq_cosmetic_tokens")||"0",10);localStorage.setItem("sq_cosmetic_tokens",String(p+1))}const g=Math.max(0,a-u.price);localStorage.setItem("sq_xp",String(g)),r(g)}catch{}h(g=>new Set([...g,u.id])),o(`${u.emoji} ${u.name} purchased!`)}catch(g){o(g.response?.data?.error||"Purchase failed")}finally{i(null)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm",onClick:t,children:e.jsxs("div",{className:"bg-[#0d0d1a] border border-white/25 rounded-3xl p-6 w-full max-w-lg mx-4 shadow-2xl",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("span",{className:"text-2xl",children:"ðª"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-white font-black text-xl",children:"Scholar Shop"}),e.jsx("p",{className:"text-white/60 text-xs",children:"Spend XP on powerful consumables"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-yellow-400 font-black text-lg",children:a.toLocaleString()}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"XP balance"})]}),e.jsx("button",{onClick:t,className:"ml-2 p-1.5 text-white/60 hover:text-white",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:l.map(u=>{const g=a>=u.price,p=x.has(u.id)&&!u.stackable,f=c===u.id,v=ra[u.rarity]||"#6b7280";return e.jsxs("div",{className:`rounded-2xl border p-4 transition-all ${p?"border-green-500/30 bg-green-500/5":g?"border-white/15 bg-slate-700/40 hover:border-white/30 hover:bg-white/8 cursor-pointer":"border-white/20 bg-white/[0.02] opacity-50"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:u.emoji}),e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full",style:{background:`${v}20`,color:v},children:u.rarity})]}),e.jsx("p",{className:"text-white font-bold text-sm mb-0.5",children:u.name}),e.jsx("p",{className:"text-white/60 text-xs mb-3 leading-relaxed",children:u.description}),p?e.jsx("div",{className:"text-center text-green-400 text-xs font-bold py-1.5",children:"â Purchased"}):e.jsx("button",{onClick:()=>b(u),disabled:f||!g,className:`w-full py-2 rounded-xl text-sm font-black transition-all ${g?"bg-gradient-to-r from-purple-600 to-blue-600 text-white hover:scale-[1.02]":"bg-slate-700/40 text-white/50 cursor-not-allowed"}
17`,children:f?"â¦":`${u.price.toLocaleString()} XP`})]},u.id)})}),s&&e.jsx("div",{className:"text-center py-2 text-sm font-semibold",style:{color:s.includes("Need")?"#f87171":"#4ade80"},children:s}),e.jsx("p",{className:"text-white/50 text-xs text-center",children:"XP earned from battles · Consumables apply immediately to your account"})]})})}const je=[{emoji:"âï¸",title:"Welcome to Brain Battles",body:"Challenge students worldwide in live quiz duels. Earn XP, climb the ranks, and prove your knowledge.",cta:null},{emoji:"ð¯",title:"How Battles Work",body:"Join or create a battle, then race to answer multiple-choice questions faster and more accurately than your opponent. Correct answers score points â speed gives bonus XP.",cta:null},{emoji:"â",title:"XP & Rank System",body:"Every battle earns XP. Rise through six ranks: Unranked â Bronze ð¥ â Silver ð¥ â Gold ð â Platinum ð â Diamond ð. Higher ranks unlock exclusive titles and cosmetics.",cta:null},{emoji:"â¡",title:"Strategic Power-Ups",body:"Each battle gives you power-ups to deploy mid-game. Freeze your opponent, steal their points, shield against attacks, or double your own score.",cta:null},{emoji:"ð¯",title:"Daily Challenge",body:"One shared question drops every day at midnight UTC. Answer it to earn bonus XP and see how you rank among all players globally.",cta:null},{emoji:"ð§ ",title:"Practice Mode",body:"Solo drills with full AI explanations on every answer. Build knowledge at your own pace and earn Study XP â no opponent, no pressure.",cta:"/brain-battles/practice",ctaLabel:"Try a drill"},{emoji:"ð",title:"You're Ready to Battle!",body:"Find an open battle, create your own, or jump into a ranked match. Good luck â may the best mind win!",cta:null,finish:!0}];function oa({onDone:t}){const[l,n]=d.useState(0),[a,r]=d.useState(!1),[c,i]=d.useState(1),[s,m]=d.useState([]),x=T(),h=je[l],o=je.length,b=(p=1)=>{i(p),r(!0),setTimeout(()=>{n(f=>f+p),r(!1)},180)},u=()=>{const p=Array.from({length:20},(f,v)=>({id:v,x:30+Math.random()*40,y:30+Math.random()*40,color:["#6366f1","#a855f7","#fbbf24","#22c55e","#f97316","#ec4899"][v%6],size:4+Math.random()*6,angle:Math.random()*360}));m(p),setTimeout(()=>{m([]),t()},900)},g=()=>{t()};return e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.75)",backdropFilter:"blur(8px)"},children:[s.map(p=>e.jsx("div",{className:"absolute pointer-events-none rounded-sm",style:{left:`${p.x}%`,top:`${p.y}%`,width:p.size,height:p.size,background:p.color,transform:`rotate(${p.angle}deg)`,animation:"confettiFall 0.9s ease-out forwards",opacity:1}},p.id)),e.jsxs("div",{className:"relative w-full max-w-md",children:[!h.finish&&e.jsx("button",{onClick:g,className:"absolute -top-10 right-0 text-white/60 hover:text-white/60 text-sm transition-colors",children:"Skip tour"}),e.jsxs("div",{className:"bg-gradient-to-br from-slate-800 via-purple-950/60 to-slate-800 border border-purple-500/30 rounded-3xl p-8 shadow-2xl",style:{transition:"opacity 0.18s, transform 0.18s",opacity:a?0:1,transform:a?`translateX(${c*-30}px)`:"translateX(0)"},children:[e.jsx("div",{className:"text-6xl text-center mb-5 leading-none",children:h.emoji}),e.jsx("h2",{className:"text-white font-black text-xl text-center mb-3 leading-tight",children:h.title}),e.jsx("p",{className:"text-white/55 text-sm text-center leading-relaxed mb-7",children:h.body}),e.jsx("div",{className:"flex justify-center gap-1.5 mb-7",children:je.map((p,f)=>e.jsx("button",{onClick:()=>{i(f>l?1:-1),n(f)},className:"rounded-full transition-all",style:{width:f===l?20:6,height:6,background:f===l?"#a855f7":"rgba(255,255,255,0.2)"}},f))}),e.jsxs("div",{className:"flex gap-2",children:[l>0&&e.jsx("button",{onClick:()=>b(-1),className:"px-4 py-2.5 bg-white/6 hover:bg-slate-700/60 border border-white/25 text-white/50 text-sm font-semibold rounded-xl transition-all",children:"â Back"}),h.cta&&e.jsx("button",{onClick:()=>{x(h.cta),t()},className:"flex-1 py-2.5 bg-white/8 hover:bg-white/12 border border-white/15 text-white/70 text-sm font-bold rounded-xl transition-all",children:h.ctaLabel}),h.finish?e.jsx("button",{onClick:u,className:"flex-1 py-2.5 bg-gradient-to-r from-purple-600 via-pink-600 to-orange-500 text-white text-sm font-black rounded-xl hover:scale-[1.02] transition-all animate-pulse",children:"Let's Battle! ð"}):e.jsx("button",{onClick:()=>b(1),className:"flex-1 py-2.5 bg-gradient-to-r from-purple-600 to-blue-600 text-white text-sm font-black rounded-xl hover:scale-[1.02] transition-all",children:"Next â"})]})]}),e.jsxs("p",{className:"text-center text-white/25 text-xs mt-3",children:[l+1," of ",o]})]}),e.jsx("style",{children:` 18 @keyframes confettiFall { 19 0% { transform: rotate(0deg) scale(1); opacity: 1; } 20 100% { transform: rotate(720deg) translateY(80px) scale(0.2); opacity: 0; } 21 } 22 `})]})}function ca({onDismiss:t}){const l=parseInt(localStorage.getItem("sq_streak")||"0");return l<2?null:e.jsxs("div",{className:"mx-4 mb-3 flex items-center gap-3 px-4 py-3 bg-orange-500/10 border border-orange-500/25 rounded-2xl",children:[e.jsx("span",{className:"text-xl",children:"ð¥"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"text-orange-300 text-sm font-bold",children:[l,"-day streak â don't break it!"]}),e.jsx("span",{className:"text-orange-400/50 text-xs ml-2",children:"Play a battle today to keep it alive."})]}),e.jsx("button",{onClick:t,className:"text-white/50 hover:text-white/50 transition-colors flex-shrink-0",children:e.jsx(H,{className:"w-4 h-4"})})]})}const da=["biology","chemistry","physics","history","mathematics","computer science","economics","psychology"];function xa({navigate:t}){const{isAuthenticated:l}=M(),[n,a]=N.useState([]),[r,c]=N.useState({}),[i,s]=N.useState({}),[m,x]=N.useState({});if(N.useEffect(()=>{j.get("/api/schools?limit=200").then(({data:o})=>{const b=(o.schools||[]).filter(g=>g.badges?.includes("demo_school"));a(b);const u={};b.forEach(g=>{u[g.id]="biology"}),c(u)}).catch(()=>{})},[]),n.length===0)return null;const h=async o=>{if(!l){t("/login");return}const b=r[o.id]||"biology";s(u=>({...u,[o.id]:!0})),x(u=>({...u,[o.id]:""}));try{const{data:u}=await j.post(`/api/gamification/v2/schools/${o.slug}/challenge-ai`,{subject:b});t(`/brain-battles/${u.battleId}`)}catch(u){x(g=>({...g,[o.id]:u.response?.data?.error||"Challenge failed. Try again."}))}finally{s(u=>({...u,[o.id]:!1}))}};return e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Ve,{className:"w-5 h-5 text-purple-400"}),e.jsx("h2",{className:"text-white font-black text-lg",children:"Challenge an AI University"}),e.jsx("span",{className:"ml-2 px-2 py-0.5 rounded-full bg-purple-500/20 text-purple-300 text-xs font-bold",children:"AI"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.map(o=>{const b=o.colorPrimary||"#1B2A6B",u=o.colorSecondary||"#D4AF37";return e.jsxs("div",{className:"relative rounded-2xl border overflow-hidden",style:{borderColor:b+"60",background:`linear-gradient(135deg, ${b}22 0%, ${u}11 100%)`},children:[e.jsx("div",{className:"h-1.5 w-full",style:{background:`linear-gradient(90deg, ${b}, ${u})`}}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-2xl flex-shrink-0",style:{background:b+"40"},children:"ð¤"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-white font-black text-base leading-tight truncate",children:o.name}),e.jsx("p",{className:"text-white/60 text-xs mt-0.5",children:o.location}),e.jsxs("span",{className:"inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-full text-xs font-semibold",style:{background:u+"30",color:u},children:[e.jsx(te,{size:10})," AI Opponent"]})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"text-white/60 text-xs font-semibold uppercase tracking-wider mb-1.5 block",children:"Subject"}),e.jsx("select",{value:r[o.id]||"biology",onChange:g=>c(p=>({...p,[o.id]:g.target.value})),className:"w-full bg-slate-800/80 border border-white/15 text-white text-sm rounded-xl px-3 py-2 focus:outline-none focus:border-purple-500/60 capitalize",children:da.map(g=>e.jsx("option",{value:g,className:"bg-gray-900 capitalize",children:g.charAt(0).toUpperCase()+g.slice(1)},g))})]}),m[o.id]&&e.jsx("p",{className:"text-red-400 text-xs mb-3",children:m[o.id]}),e.jsx("button",{onClick:()=>h(o),disabled:i[o.id],className:"w-full flex items-center justify-center gap-2 py-2.5 rounded-xl font-bold text-sm transition-all active:scale-95 disabled:opacity-60",style:{background:`linear-gradient(135deg, ${b}, ${u})`,color:"#fff"},children:i[o.id]?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"})," Startingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:15})," Challenge Now"]})})]})]},o.id)})})]})}function ma({navigate:t,onFilterLive:l}){const[n,a]=N.useState([]),[r,c]=N.useState(!1);return N.useEffect(()=>{const i=()=>{j.get("/api/gamification/v2/battles/live").then(({data:m})=>{a(m.battles||[]),c(!0)}).catch(()=>c(!0))};i();const s=setInterval(i,1e4);return()=>clearInterval(s)},[]),r?e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500 animate-pulse flex-shrink-0"}),e.jsx("h2",{className:"text-white font-black text-lg",children:"Live Battles"}),n.length>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-red-500/20 text-red-400 text-xs font-bold",children:[n.length," live"]}),n.length>0&&e.jsxs("button",{onClick:l,className:"ml-auto text-xs text-white/60 hover:text-white/70 transition-colors flex items-center gap-1",children:["View all ",e.jsx(ae,{size:13})]})]}),n.length===0?e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/3 px-5 py-6 text-center",children:[e.jsx("div",{className:"text-3xl mb-2",children:"âï¸"}),e.jsx("p",{className:"text-white/60 text-sm",children:"No live battles right now"}),e.jsx("p",{className:"text-white/25 text-xs mt-1",children:"Start a battle to be the first one live!"})]}):e.jsx("div",{className:"space-y-2",children:n.slice(0,5).map(i=>{const s=i.participants?.[0],m=i.participants?.[1],x=s?.user?.firstName||s?.user?.username||"Player
221",h=m?.user?.firstName||m?.user?.username||"Player 2",o=s?.metadata?.schoolName||s?.user?.school?.name||"",b=m?.metadata?.schoolName||m?.user?.school?.name||"";return e.jsxs("div",{className:"flex items-center gap-3 bg-slate-700/40 border border-white/8 rounded-2xl px-4 py-3 hover:bg-white/8 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white text-sm font-bold truncate",children:i.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsxs("span",{className:"text-white/50 text-xs truncate",children:[x,o?` · ${o}`:""]}),e.jsx("span",{className:"text-white/25 text-xs",children:"vs"}),e.jsxs("span",{className:"text-white/50 text-xs truncate",children:[h,b?` · ${b}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-500/20 text-red-400 text-xs font-bold",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"})," LIVE"]}),e.jsxs("button",{onClick:()=>t(`/brain-battles/spectate/${i.id}`),className:"flex items-center gap-1.5 px-3 py-1.5 bg-purple-600 hover:bg-purple-500 text-white text-xs font-bold rounded-xl transition-colors",children:[e.jsx(ve,{size:12})," Watch"]})]})]},i.id)})})]}):null}const ga=()=>{const{user:t,isAuthenticated:l}=M(),n=T(),a=ft(),[r,c]=d.useState([]),[i,s]=d.useState(!0),[m,x]=d.useState(!1),[h,o]=d.useState(!1),[b,u]=d.useState(!1),[g,p]=d.useState(!1),[f,v]=d.useState(!1),[S,C]=d.useState(!1),[P,y]=d.use
22State(null),[$,A]=d.useState(""),[I,R]=d.useState("open"),[L,le]=d.useState([]),[ne,k]=d.useState(()=>{try{return!localStorage.getItem("sq_onboarded")&&!!localStorage.getItem("token")}catch{return!1}}),[z,W]=d.useState(()=>{try{const w=parseInt(localStorage.getItem("sq_streak")||"0"),_=localStorage.getItem("sq_streak_banner_date"),E=new Date().toISOString().slice(0,10);return w>=2&&_!==E}catch{return!1}}),de=()=>{try{localStorage.setItem("sq_onboarded","1")}catch{}k(!1)},at=()=>{try{localStorage.setItem("sq_streak_banner_date",new Date().toISOString().slice(0,10))}catch{}W(!1)},[lt,nt]=d.useState({}),[rt,Se]=d.useState(!1),[it,re]=d.useState(!1),[ot,Ce]=d.useState(0),[Y,Pe]=d.useState([]),[Ie,ie]=d.useState(null),$e=d.useRef(null),_e=d.useRef(null),xe=d.useRef(null);d.useEffect(()=>{document.title="Brain Battles â University Quiz League | ScholarNet AI";const w=document.querySelector('meta[name="description"]');w&&(w.content="Challenge students from rival universities in real-time Brain Battles. 1v1, Battle Royale (up to 8 players), Territory Control, Speed Blitz & Cooperative modes. Win points for your school's national ranking.");const _=document.createElement("script");return _.type="application/ld+json",_.id="brain-battles-schema",_.text=JSON.stringify({"@context":"https://schema.org","@type":"VideoGame",name:"Brain Battles â University Quiz League",url:"https://scholar.0xpi.com/brain-battles",description:"Real-time quiz battles between university students. Modes include 1v1, Battle Royale, Territory Control, Speed Blitz, and Cooperative. Win points for your school's national ranking.",genre:"Educational Quiz Game",gamePlatform:"Web Browser",numberOfPlayers:{"@type":"QuantitativeValue",minValue:1,maxValue:8},offers:{"@type":"Offer",price:"0",priceCurrency:"USD"}}),document.getElementById("brain-battles-schema")||document.head.appendChild(_),()=>{const E=document.getElementById("brain-battles-schema");E&&E.remove()}},[]),d.useEffect(()=>{new URLSearchParams(a.search).get("practice")==="1"&&l&&u(!0)},[a.search,l]);const U=w=>{A(w),setTimeout(()=>A(""),3500)},J=async(w=!1)=>{w?x(!0):s(!0);try{let _;if(I==="mine"){if(!l){c([]);return}_=`/api/gamification/v2/battles?userId=${t.id}`}else _=`/api/gamification/v2/battles?status=${{open:"open",live:"in_progress",completed:"completed"}[I]}&isPublic=true`;const E=await j.get(_);c(E.data.battles||[])}catch{c([])}finally{s(!1),x(!1)}};d.useEffect(()=>{J(),l&&t?.schoolId&&j.get(`/api/gamification/v2/schools/${t.schoolId}`).then(w=>y(w.data.school)).catch(()=>{}),j.get("/api/gamification/v2/battles/leaderboard?limit=10").then(w=>
22{const _=w.data.leaderboard||[];le(_);const E=_.map(D=>D.userId).filter(Boolean).join(",");E&&j.get(`/api/gamification/v2/cosmetics/leaderboard-frames?ids=${E}`).then(D=>nt(D.data.cosmetics||{})).catch(()=>{})}).catch(()=>{})},[l,I]),d.useEffect(()=>(clearInterval(xe.current),(I==="open"||I==="live")&&(xe.current=setInterval(()=>J(!0),12e3)),()=>clearInterval(xe.current)),[I,l]),d.useEffect(()=>{if(!l)return;const w=()=>j.post("/api/gamification/v2/friends/heartbeat").catch(()=>{});return w(),$e.current=setInterval(w,3e4),()=>clearInterval($e.current)},[l]);const[ct,Be]=d.useState([]);d.useEffect(()=>{if(!l)return;const w=async()=>{try{const _=await j.get("/api/gamification/v2/friends/notifications");if(Ce(_.data.total||0),Pe(_.data.challenges||[]),_.data.requests>0){const E=await j.get("/api/gamification/v2/friends");Be(E.data.pending||[])}else Be([])}catch{}};return w(),_e.current=setInterval(w,15e3),()=>clearInterval(_e.current)},[l]),d.useEffect(()=>{if(Y.length>0){const w=Y[Y.length-1];w?.battleId&&(U(`âï¸ ${w.fromName} challenged you! Joining...`),j.delete(`/api/gamification/v2/friends/challenges/${w.battleId}`).catch(()=>{}),Pe([]),Ce(0),setTimeout(()=>n(`/brain-battles/${w.battleId}`),1500))}},[Y]);const dt=w=>{ie(w)},xt=async w=>{if(!l){n("/signup?ref=brain-battles");return}try{await j.post(`/api/gamification/v2/battles/${w.id}/join`),U(`Joined "${w.title}"!`),J()}catch(_){U(_.response?.data?.error||"Could not join battle")}},mt=async w=>{const _=await j.post("/api/gamification/v2/battles",w);o(!1);const E=_.data.battle?.id;E?n(`/brain-battles/${E}`):(U("Battle created!"),J())},Ee=async({subject:w,difficulty:_,questionCount:E})=>{try{const D=await j.post("/api/gamification/v2/battles",{title:w?`${w} Practice`:"Solo Practice",battleType:"quiz_race",subject:w,difficulty:_,duration:15,isPublic:!1,minParticipants:1,maxParticipants:1,winnerXP:50,participantXP:50,questionCount:E});u(!1);const X=D.data.battle?.id;X&&n(`/brain-battles/${X}`)}catch(D){U(D.response?.data?.error||"Could not start practice")}},ht=async(w,_)=>{try{const D=(await j.post("/api/gamification/v2/battles",{title:`Daily Challenge: ${w.subject}`,battleType:"quiz_race",subject:w.subject,difficulty:"medium",duration:15,isPublic:!1,minParticipants:1,maxParticipants:1,winnerXP:80,participantXP:80,questionCount:10,metadata:{daily:!0,dailyDate:w.dateStr,preloadedQuestions:w.questions}})).data.battle?.id;D&&n(`/brain-battles/${D}?daily=1&dailyKey=${_()}`)}catch(E){U(E.response?.data?.error||"Could not start daily challenge")}},ut=async w=>{try{const E=(await j.post("/api/gamification/v2/battles",{title:`Boss Battle: ${w.name}`,battleType:"quiz_race",subject:w.subject,difficulty:w.difficulty,duration:20,isPublic:!1,minParticipants:1,maxParticipants:1,winnerXP:w.xp,participantXP:Math.round(w.xp*.3),questionCount:w.questionCount,metadata:{bossMode:!0,bossName:w.name,bossDateStr:w.dateStr}})).data.battle?.id;E&&n(`/brain-battles/${E}?boss=1&bossDateStr=${w.dateStr}&bossKey=sq_boss_${w.dateStr}`)}catch(_){U(_.response?.data?.error||"Could not start boss challenge")}},pt=[{key:"open",label:"Open",icon:e.jsx(te,{className:"w-3.5 h-3.5"})},{key:"live",label:"Live Now",icon:e.jsx(ye,{className:"w-3.5 h-3.5"})},{key:"mine",label:"My Battles",icon:e.jsx(kt,{className:"w-3.5 h-3.5"})},{key:"completed",label:"Completed",icon:e.jsx(ke,{className:"w-3.5 h-3.5"})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-purple-950 to-slate-900",children:[e.jsxs(jt,{children:[e.jsx("title",{children:"Brain Battles â Compete Against Other Universities | ScholarNet AI"}),e.jsx("meta",{name:"description",content:"Challenge students from rival universities in real-time Brain Battles. Battle Royale, Speed Blitz & Territory Control modes. Free to play â earn points for your school's national ranking."}),e.jsx("link",{rel:"canonical",href:"https://scholar.0xpi.com/brain-battles"}),e.jsx("meta",{property:"og:title",content:"Brain Battles â University vs University Academic Competition"}),e.jsx("meta",{property:"og:description",content:"Challenge students from rival universities in real-time Brain Battles. Battle Royale, Speed Blitz & Territory Control modes. Free to play â earn points for your school's national ranking."}),e.jsx("meta",{property:"og:url",content:"https://scholar.0xpi.com/brain-battles"}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:image",content:"https://scholar.0xpi.com/og-image.jpg"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify([{"@context":"https://schema.org","@type":"WebApplication",name:"Brain Battles",applicationCategory:"GameApplication",applicationSubCategory:"EducationalGame",operatingSystem:"Web",url:"https://scholar.0xpi.com/brain-battles",description:"Real-time university Brain Battles â compete against students from rival universities in Battle Royale, Speed Blitz, and Territory Control academic quiz modes.",offers:{"@type":"Offer",price:"0",priceCurrency:"USD",description:"Free to play â no credit card required.",availability:"https://schema.org/InStock"},provider:{"@type":"Organization",name:"ScholarNet AI",url:"https://scholar.0xpi.com"}},{"@context":"https://schema.org","@type":"FAQPage",mainEntity:[{"@type":"Question",name:"What are Brain Battles?",acceptedA
22nswer:{"@type":"Answer",text:"Brain Battles are real-time academic quiz competitions where students compete against peers from rival universities. Modes include Battle Royale, Speed Blitz, and Territory Control. Win points for your school's national ranking."}},{"@type":"Question",name:"Are Brain Battles free to play?",acceptedAnswer:{"@type":"Answer",text:"Yes â Brain Battles are completely free. Create a free ScholarNet AI account, join a battle, and start competing immediately. No credit card required."}},{"@type":"Question",name:"What subjects are covered in Brain Battles?",acceptedAnswer:{"@type":"Answer",text:"Brain Battles cover all major university subjects including mathematics, science, history, literature, computer science, economics, and more. Questions are tailored to university-level difficulty."}},{"@type":"Question",name:"How does the school ranking work?",acceptedAnswer:{"@type":"Answer",text:"Every Brain Battle win earns points for your university. Points accumulate on the national school leaderboard where universities compete for the top ranking. Check the Schools Leaderboard to see how your university ranks."}}]}])})]}),e.jsx(Ps,{}),e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsx(Et,{}),e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-gradient-to-b from-transparent via-purple-950/30 to-slate-900/80"}),e.jsxs("div",{className:"relative max-w-4xl mx-auto px-4 py-14 text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 bg-red-500/10 border border-red-500/30 text-red-400 text-sm px-4 py-2 rounded-full mb-6",children:[e.jsx(q,{className:"w-4 h-4"})," Live Brain Battles"]}),e.jsxs("h1",{className:"text-5xl md:text-6xl font-black text-white mb-4",children:["Prove You're"," ",e.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-purple-400 to-red-400",children:"the Smartest"})]}),e.jsx("p",{className:"text-xl text-white/60 mb-8 max-w-2xl mx-auto",children:"Challenge students from other universities in real-time quiz battles. Every win earns points for your school's national ranking."}),P&&e.jsxs("div",{className:"inline-flex items-center gap-2 bg-slate-700/40 border border-white/25 rounded-full px-4 py-2 mb-6",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:P.colorPrimary}}),e.jsxs("span",{className:"text-white/70 text-sm",children:["Representing ",e.jsx("strong",{className:"text-white",children:P.name})]}),e.jsx(B,{to:"/schools",className:"text-purple-400 text-xs hover:text-purple-300 ml-1",children:"Rankings â"})]}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full text-sm font-bold",style:{background:`${Q.color}18`,border:`1px solid ${Q.color}50`,color:Q.color},children:[Q.emoji,e.jsxs("span",{children:["Today's Boost: ",e.jsx("strong",{children:Q.subject})," questions earn ",Q.mult,"Ã points!"]}),e.jsx("span",{className:"text-white/60 font-normal text-xs",children:"(resets tomorrow)"})]})}),e.jsx(us,{}),!l&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsxs(B,{to:"/signup",className:"flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold rounded-xl hover:scale-105 transition-all",children:[e.jsx(te,{className:"w-5 h-5"})," Join the fight"]}),e.jsx(B,{to:"/login",className:"px-6 py-3 bg-slate-800/80 text-white font-semibold rounded-xl hover:bg-slate-700/80 transition-all",children:"Sign in"})]}),l&&!t?.schoolId&&e.jsx("div",{className:"mb-4",children:e.jsxs(B,{to:"/schools",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/10 border border-yellow-500/30 text-yellow-300 rounded-xl text-sm hover:bg-yellow-500/20 transition-all",children:[e.jsx(wt,{className:"w-4 h-4"})," Pick your school to earn ranking points"]})}),l&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 flex-wrap",children:[e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center justify-center gap-3 px-8 py-4 bg-gradient-to-r from-red-600 to-orange-600 text-white font-extrabold text-lg rounded-2xl hover:scale-105 hover:shadow-lg hover:shadow-red-500/30 transition-all min-w-[180px]",children:[e.jsx(q,{className:"w-6 h-6"})," Quick Match"]}),e.jsxs(B,{to:"/brain-battles/practice",className:"flex items-center justify-center gap-3 px-8 py-4 bg-gradient-to-r from-blue-600 to-purple-600 text-white font-extrabold text-lg rounded-2xl hover:scale-105 hover:shadow-lg hover:shadow-blue-500/30 transition-all min-w-[180px]",children:[e.jsx(he,{className:"w-6 h-6"})," Practice Mode"]}),e.jsxs("button",{onClick:()=>o(!0),className:"flex items-center justify-center gap-3 px-8 py-4 bg-gradient-to-r from-purple-600 to-indigo-600 text-white font-extrabold text-lg rounded-2xl hover:scale-105 hover:shadow-lg hover:shadow-
22purple-500/30 transition-all min-w-[180px]",children:[e.jsx(Re,{className:"w-6 h-6"})," Create Battle"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>v(!0),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-cyan-600 to-teal-600 text-white font-semibold text-sm rounded-xl hover:scale-105 transition-all",children:[e.jsx(Ye,{className:"w-4 h-4"})," Ranked Match"]}),e.jsxs(B,{to:"/brain-battles/tournament",className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-amber-600 to-orange-600 text-white font-semibold text-sm rounded-xl hover:scale-105 transition-all",children:[e.jsx(G,{className:"w-4 h-4"})," Tournament"]}),e.jsxs(B,{to:"/brain-battles/leaderboard",className:"flex items-center gap-2 px-4 py-2 bg-yellow-500/10 border border-yellow-500/30 text-yellow-300 font-semibold text-sm rounded-xl hover:bg-yellow-500/20 hover:scale-105 transition-all",children:[e.jsx(G,{className:"w-4 h-4"})," Leaderboard"]}),e.jsxs(B,{to:"/brain-battles/stats",className:"flex items-center gap-2 px-4 py-2 bg-white/8 border border-white/15 text-white/70 font-semibold text-sm rounded-xl hover:bg-slate-800/60 hover:scale-105 transition-all",children:[e.jsx(Nt,{className:"w-4 h-4 text-indigo-400"})," My Stats"]}),e.jsx(ks,{count:ot,requests:ct,challenges:Y,onOpen:()=>re(!0)})]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("button",{onClick:()=>C(!S),className:"flex items-center gap-2 px-4 py-2 text-white/50 hover:text-white/80 text-sm font-medium transition-all",children:[e.jsx(Te,{className:`w-4 h-4 transition-transform ${S?"rotate-180":""}`}),S?"Less Features":"More Features",e.jsx(Te,{className:`w-4 h-4 transition-transform ${S?"rotate-180":""}`})]})}),S&&e.jsxs("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[e.jsxs(B,{to:"/brain-battles/season",className:"flex items-center gap-1.5 px-3 py-1.5 bg-amber-500/10 border border-amber-500/30 text-amber-300 font-medium text-xs rounded-lg hover:bg-amber-500/20 hover:scale-105 transition-all",children:[e.jsx(Le,{className:"w-3.5 h-3.5"})," Season Pass"]}),e.jsxs(B,{to:"/brain-battles/guilds",className:"flex items-center gap-1.5 px-3 py-1.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 font-medium text-xs rounded-lg hover:bg-emerald-500/20 hover:scale-105 transition-all",children:[e.jsx(we,{className:"w-3.5 h-3.5"})," Guilds"]}),e.jsxs(B,{to:"/brain-battles/gauntlet",className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border border-red-500/30 text-red-300 font-medium text-xs rounded-lg hover:bg-red-500/20 hover:scale-105 transition-all",children:[e.jsx(Je,{className:"w-3.5 h-3.5"})," Gauntlet"]}),e.jsxs("button",{onClick:()=>re(!0),className:"flex items-center gap-1.5 px-3 py-1.5 bg-pink-500/10 border border-pink-500/30 text-pink-300 font-medium text-xs rounded-lg hover:bg-pink-500/20 hover:scale-105 transition-all",children:[e.jsx(oe,{className:"w-3.5 h-3.5"})," Friends"]}),e.jsx(B,{to:"/brain-battles/cosmetics",className:"flex items-center gap-1.5 px-3 py-1.5 bg-yellow-500/10 border border-yellow-500/30 text-yellow-300 font-medium text-xs rounded-lg hover:bg-yellow-500/20 hover:scale-105 transition-all",children:"⨠Cosmetics"}),e.jsx("button",{onClick:()=>Se(!0),className:"flex items-center gap-1.5 px-3 py-1.5 bg-green-500/10 border border-green-500/30 text-green-300 font-medium text-xs rounded-lg hover:bg-green-500/20 hover:scale-105 transition-all",children:"ðª Shop"}),e.jsx(B,{to:"/brain-battles/quiz-builder",className:"flex items-center gap-1.5 px-3 py-1.5 bg-orange-500/10 border border-orange-500/30 text-orange-300 font-medium text-xs rounded-lg hover:bg-orange-500/20 hover:scale-105 transition-all",children:"ð Quiz Builder"}),e.jsx(B,{to:"/brain-battles/challenges",className:"flex items-center gap-1.5 px-3 py-1.5 bg-rose-500/10 border border-rose-500/30 text-rose-300 font-medium text-xs rounded-lg hover:bg-rose-500/20 hover:scale-105 transition-all",children:"âï¸ Challenge Wall"}),e.jsx(B,{to:"/brain-battles/knowledge-tree",className:"flex items-center gap-1.5 px-3 py-1.5 bg-teal-500/10 border border-teal-500/30 text-teal-300 font-medium text-xs rounded-lg hover:bg-teal-500/20 hover:scale-105 transition-all",children:"ð³ Knowledge Tree"}),e.jsxs(B,{to:"/brain-battles/coach",className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-500/10 border border-blue-500/30 text-blue-300 font-medium text-xs rounded-lg hover:bg-blue-500/20 hover:scale-105 transition-all",children:[e.jsx(Ve,{className:"w-3.5 h-3.5"})," AI Coach"]}),e.jsxs(B,{to:"/brain-battles/journal",className:"flex items-center gap-1.5 px-3 py-1.5 bg-indigo-500/10 border border-indigo-500/30 text-indigo-300 font-medium text-xs rounded-lg hover:bg-indigo-500/20 hover:scale-105 transition-all",children:[e.jsx(he,{className:"w-3.5 h-3.5"})," Journal"]}),e.jsxs(B,{to:"/brain-battles/certificates",className:"flex items-center gap-1.5 px-3 py-1.5 bg-amber-500/10 border border-amber-500/30 text-amber-300 font-medium text-xs rounded-lg hover:bg-amber-500/20 hover:scale-105 transition-all",children:[e.jsx(De,{className:"w-3.5 h-3.5"})," Certificates"]})]})]})]})]}),$&&e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 bg-slate-800/80 backdrop-blur border border-white/20 text-white px-6 py-3 rounded-2xl shadow-2xl",children:$}),z&&e.jsx(ca,{onDismiss:at}),e.jsxs("div",{className:"max-w-4xl mx-auto px-4 pb-24",children:[e.jsx(xa,{navigate:n}),e.jsx(ma,{navigate:n,onFilterLive:()=>R("live")}),e.jsxs("div",{className:"flex items-center gap-2 mb-6 flex-wrap",children:[pt.map(w=>e.jsxs("button",{onClick:()=>R(w.key),className:`flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold transition-all ${I===w.key?"bg-purple-600 text-white":"bg-slate-700/40 text-white/50 hover:bg-slate-700/60 hover:text-white"}`,children:[w.icon,w.label]},w.key)),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[(I==="open"||I==="live")&&e.jsx("span",{className:"text-white/50 text-xs",children:"auto-refresh 12s"}),e.jsx("button",{onClick:()=>J(!0),disabled:m,className:"p-2 text-white/60 hover:text-white transition-colors",children:e.jsx(vt,{className:`w-4 h-4 ${m?"animate-spin":""}`})}),e.jsxs("span",{className:"text-white/60 text-sm",children:[r.length," battles"]})]})]}),i?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((w,_)=>e.jsx("div",{className:"bg-white/[0.03] border border-white/6 rounded-2xl p-5 animate-pulse",style:{animationDelay:`${_*80}ms`},children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-10 h-10 bg-white/8 rounded-xl flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2.5",children:[e.jsx("div",{className:"h-4 bg-white/8 rounded-lg w-3/4"}),e.jsx("div",{className:"h-3 bg-slate-700/40 rounded-lg w-1/2"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx("div",{className:"h-5 bg-slate-700/40 rounded-full w-16"}),e.jsx("div",{className:"h-5 bg-slate-700/40 rounded-full w-20"}),e.jsx("div",{className:"h-5 bg-slate-700/40 rounded-full w-14"})]})]}),e.jsx("div",{className:"w-20 h-9 bg-white/6 rounded-xl flex-shrink-0"})]})},_))}):r.length===0?e.jsx("div",{className:"text-center py-16",children:I==="open"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-5 rounded-3xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center",children:e.jsx(q,{className:"w-9 h-9 text-purple-400/60"})}),e.jsx("h3",{className:"text-white/70 text-xl font-black mb-2",children:"No open battles right now"}),e.jsx("p",{className:"text-white/60 text-sm mb-7 max-w-xs mx-auto",children:"Be the first to start one â other players will join you!"}),e.jsxs("div",{className:"flex gap-3 justify-center flex-wrap",children:[e.jsxs("button",{onClick:()=>o(!0),className:"inline-flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold rounded-xl hover:scale-105 transition-all",children:[e.jsx(Re,{className:"w-5 h-5"})," Create a Battle"]}),e.jsxs(B,{to:"/brain-battles/practice",className:"inline-flex items-center gap-2 px-6 py-3 bg-white/8 border border-white/15 text-white/70 font-semibold rounded-xl hover:bg-white/14 transition-all",children:[e.jsx(he,{className:"w-4 h-4 text-blue-400"})," Practice Instead"]})]})]}):I==="mine"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-5 rounded-3xl bg-slate-700/40 border border-white/25 flex items-center justify-center",children:e.jsx(G,{className:"w-9 h-9 text-white/50"})}),e.jsx("h3",{className:"text-white/60 text-xl font-black mb-2",children:"No battles yet"}),e.jsx("p",{className:"text-white/60 text-sm mb-6",children:"Your battles will appear here once you join or create one."}),e.jsxs("button",{onClick:()=>R("open"),className:"inline-flex items-center gap-2 px-5 py-2.5 bg-slate-800/80 text-white/70 rounded-xl hover:bg-slate-700/80 transition-all text-sm font-semibold",children:[e.jsx(q,{className:"w-4 h-4"})," Browse Open Battles"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-5 rounded-3xl bg-slate-700/40 border border-white/25 flex items-center justify-center",children:e.jsx(Le,{className:"w-9 h-9 text-white/50"})}),e.jsx("h3",{className:"text-white/60 text-xl font-black mb-2",children:"Nothing here yet"}),e.jsx("p",{className:"text-white/60 text-sm",children:"Check back soon."})]})}):e.jsx("div",{className:"space-y-3",children:r.map(w=>e.jsx(Rt,{battle:w,userId:t?.id,onJoin:xt},w.id))}),!l&&e.jsx("div",{className:"mt-12 text-center",children:e.jsxs("div",{className:"inline-block bg-slate-700/40 border border-white/25 rounded-2xl px-8 py-6",children:[e.jsx(G,{className:"w-10 h-10 text-yellow-400 mx-auto mb-3"}),e.jsx("h3",{className:"text-white font-bold text-lg mb-2",children:"Ready to battle?"}),e.jsx("p",{className:"text-white/50 text-sm mb-4",children:"Sign up free and represent your university."}),e.jsxs(B,{to:"/signup",className:"inline-flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold rounded-xl hover:scale-105 transition-all",children:[e.jsx(te,{className:"w-4 h-4"})," Get started free"]})]})}),l&&e.jsx(Ut,{userName:t?.firstName||t?.username||"You"}),e.jsx(ps,{}),l&&e.jsx(hs,{}),e.jsx(is,{}),l&&e.jsx(ds,{}),l&&e.jsx(xs,{}),l&&e.jsx(ms,{}),l&&e.jsx(cs,{}),l&&e.jsx(Gt,{xp:tt()}),l&&e.jsx(Ht,{onStart:ht}),l&&e.jsx(rs,{onChallenge:ut}),e.jsx(os,{}),e.jsx(ys,{}),e.jsx(Ss,{}),e.jsx(Is,{}),e.jsx(Es,{}),e.jsx(Ms,{}),e.jsx(Rs,{onQuickBattle:w=>Ee({subject:w,difficulty:"medium",questionCount:10})}),e.jsx(Ds,{}),e.jsx(Ls,{}),e.jsx(qs,{}),e.jsx(Fs,{}),e.jsx(Ws,{}),e.jsx(Hs,{}),e.jsx(Us,{}),e.jsx(Qs,{}),e.jsx(Ys,{}),e.jsx(Vs,{}),e.jsx(Ks,{}),e.jsx(Os,{}),e.jsx(zs,{}),e.jsx(ea,{}),e.jsx(Zs,{}),e.jsx(Bs,{}),e.jsx(ta,{}),e.jsx(sa,{}),e.jsx(B,{to:"/brain-battles/certificates",className:"block p-4 bg-gradient-to-r from-amber-900/30 to-orange-900/30 border border-amber-500/20 rounded-2xl mb-3 hover:border-amber-500/40 transition-all group",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(De,{className:"w-6 h-6 text-amber-400 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-white font-bold text-sm group-hover:text-amber-300 transition-colors",children:"Achievement Certificates"}),e.jsx("div",{className:"text-white/60 text-xs",children:"Download & share your milestones"})]})]})}),e.jsx(aa,{}),e.jsx(la,{}),l&&e.jsx(na,{onPlayRanked:()=>v(!0)}),l&&e.jsx(ss,{}),l&&e.jsx(as,{}),l&&e.jsx(ls,{}),l&&e.jsx(gs,{}),l&&e.jsx(fs,{}),l&&e.jsx("div",{className:"mt-4 mb-4",children:e.jsx(es,{})}),L.length>0&&e.jsxs("div",{className:"mt-12 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(yt,{className:"w-5 h-5 text-yellow-400"}),e.jsx("h2",{className:"text-white font-black text-lg",children:"Top Battlers"}),e.jsx("span",{className:"text-white/60 text-xs ml-auto",children:"PvP wins"})]}),e.jsx("div",{className:"bg-slate-700/40 border border-white/25 rounded-2xl overflow-hidden",children:L.map((w,_)=>{const E=["text-yellow-400","text-slate-300","text-amber-600"],D=["ð¥","ð¥","ð¥"],X=w.userId===t?.id,Me=lt[w.userId],me=vs(Me?.frame||"default"),Ae={none:"",fire:"linear-gradient(90deg,#f97316,#dc2626)",lightning:"linear-gradient(90deg,#38bdf8,#e0f2fe)",rainbow:"linear-gradient(90deg,#ef4444,#f97316,#eab308,#22c55e,#3b82f6,#a855f7)",gold:"linear-gradient(90deg,#f59e0b,#fde68a)",crimson:"linear-gradient(90deg,#dc2626,#7f1d1d)"}[Me?.aura||"none"]||"";return e.jsxs("div",{className:`flex items-center gap-3 px-5 py-3.5 transition-all ${_<L.length-1?"border-b border-white/20":""} ${X?"bg-purple-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsx("div",{className:`w-7 text-center font-black text-sm flex-shrink-0 ${E[_]||"text-white/60"}`,children:_<3?D[_]:`#${w.rank}
22`}),e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-black text-xs flex-shrink-0",style:{background:X?"#9333ea":"#334155",border:`${me.width}px solid ${X?"#c084fc":me.ring}`,boxShadow:X?"0 0 8px #9333ea60":me.shadow},children:(w.name||"?")[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm truncate",style:Ae?{background:Ae,WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"}:{},children:X?e.jsxs("span",{style:{background:"none",WebkitTextFillColor:"#c084fc"},children:[w.name,e.jsx("span",{style:{fontSize:11,opacity:.5},children:" (you)"})]}):e.jsx(Ns,{player:w,isAuthenticated:l,onChallenge:X?null:bt=>ie(bt)})}),e.jsxs("p",{className:"text-white/60 text-xs",children:[w.totalBattles," battle",w.totalBattles!==1?"s":""," · ",w.winRate,"% win rate"]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0 text-right",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-black text-sm",children:w.wins}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"wins"})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsx("p",{className:"text-yellow-400 font-bold text-sm",children:w.bestScore}),e.jsx("p",{className:"text-white/60 text-[10px]",children:"best score"})]})]})]},w.userId)})}),e.jsx("div",{className:"text-center mt-3",children:e.jsx(B,{to:"/schools",className:"text-white/60 text-xs hover:text-white/60 transition-colors",children:"School rankings â"})})]})]}),h&&e.jsx(Vt,{onClose:()=>o(!1),onCreate:mt,userSchool:P}),b&&e.jsx(Yt,{onClose:()=>u(!1),onStart:Ee}),g&&e.jsx(Jt,{onClose:()=>p(!1),onNavigate:w=>{p(!1),n(`/brain-battles/${w}`)}}),f&&e.jsx(ns,{onClose:()=>v(!1),onFound:w=>{v(!1),localStorage.setItem("sq_last_ranked_date",new Date().toISOString()),n(`/brain-battles/${w}`)}}),it&&e.jsx(js,{onClose:()=>re(!1),currentUserId:t?.id,onChallenge:w=>{re(!1),dt(w)}}),Ie&&e.jsx(ws,{friend:Ie,onClose:()=>ie(null),onCreate:w=>{ie(null),n(`/brain-battles/${w}`)}}),rt&&e.jsx(ia,{onClose:()=>Se(!1)}),ne&&e.jsx(oa,{onDone:de}),!ne&&e.jsx("button",{onClick:()=>k(!0),title:"Open feature tour",className:"fixed bottom-6 right-6 z-40 w-10 h-10 rounded-full bg-white/8 border border-white/15 text-white/60 hover:bg-slate-800/60 hover:text-white/70 hover:border-white/30 transition-all flex items-center justify-center text-base font-black shadow-lg",children:"?"}),e.jsxs("div",{className:"border-t border-white/20 mt-8 py-5 text-center",children:[e.jsxs("p",{className:"text-white/25 text-xs",children:[e.jsx(B,{to:"/privacy",className:"hover:text-white/50 transition-colors mx-2",children:"Privacy Policy"}),"·",e.jsx(B,{to:"/terms",className:"hover:text-white/50 transition-colors mx-2",children:"Terms of Service"}),"·",e.jsx("a",{href:"mailto:[email protected]",className:"hover:text-white/50 transition-colors mx-2",children:"Contact Us"})]}),e.jsxs("p",{className:"text-white/15 text-xs mt-1",children:["© ",new Date().getFullYear()," ScholarNet AI. All in-app currency is virtual with no real-money value."]})]})]})};export{ga 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.