1import{a as I,b as B,s as A,ay as H,L as Z,j as e,g as f,q as p,ah as W,K as q,aF as O,h as Q}from"./index.BdetuOfV.js";import{r as v,L as j,a as T,i as F,bh as X,cb as J,cc as V,cd as ee,bo as y,D as P,aj as R,l as G,M as $,p as se,aa as ae,X as te,B as re,_ as le}from"./vendor-lucide.D5HzgynF.js";import{P as N,a as L,h as ne,i as ie,S as ce}from"./useStudentPassport.C5psR8Rl.js";import{R as oe}from"./generateCategoricalChart.BHCuEJ0n.js";import{R as de,P as xe,a as me}from"./RadarChart.BPw_xkvD.js";import{P as he,a as pe}from"./PolarAngleAxis.DFplqZXJ.js";function z(a){const{user:s}=I();return B({queryKey:["olympiad","published-result",s==null?void 0:s.id,a??"self"],queryFn:async()=>{if(!(s!=null&&s.id))return{ok:!1,reason:"not_authenticated"};const{data:r,error:c}=await A.rpc("oly_get_published_result",a?{p_student_id:a}:{});if(c)throw c;return r},enabled:!!(s!=null&&s.id),staleTime:6e4})}const ue="olympiad-receipts";function Y(){return H({mutationFn:async({resultId:a,kind:s})=>{const{data:r,error:c}=await A.rpc("oly_get_published_signed_url_path",{p_result_id:a,p_kind:s});if(c)throw c;if(!r)throw new Error("PDF not generated yet");const{data:i,error:n}=await A.storage.from(ue).createSignedUrl(r,300);if(n)throw n;return i.signedUrl},onError:a=>Z(a,{fallback:"Couldn't open PDF.",context:"useOlympiadPublishedResultUrl"})})}function be(a,s){const{user:r}=I();return B({queryKey:["olympiad","student-analysis",r==null?void 0:r.id,s??"self"],enabled:!!(r!=null&&r.id),queryFn:async()=>{const{data:c,error:i}=await A.rpc("oly_student_performance_analysis",s?{p_student_id:s}:{});if(i)throw i;return c},staleTime:6e4})}const D=a=>a>=80?"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300":a>=60?"bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300":"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",g=a=>a==null?"N/A":a<60?`${Math.round(a)}s`:`${Math.floor(a/60)}m ${Math.round(a%60)}s`;function k({eyebrow:a,title:s,subtitle:r,children:c}){return e.jsxs("section",{className:"surface-card frosted-shadow rounded-card p-4 sm:p-5 space-y-3",children:[e.jsxs("header",{children:[e.jsx("p",{className:"eyebrow",children:a}),e.jsx("h3",{className:"text-base font-semibold text-ink-900",children:s}),r&&e.jsx("p",{className:"text-xs text-ink-600 mt-0.5",children:r})]}),c]})}function fe({t:a}){return e.jsxs("li",{className:"flex items-center justify-between gap-3 py-1.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-ink-900",children:a.topic_name}),e.jsxs("p",{className:"text-[11px] text-ink-500",children:[a.subject_name," · ",a.correct,"/",a.questions," correct"]})]}),e.jsxs("span",{className:p("shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold tabular-nums",D(a.pct_correct)),children:[a.pct_correct,"%"]})]})}function K({studentId:a}){const{data:s,isLoading:r,isError:c,refetch:i}=be(!0,a),n=v.useMemo(()=>{if(!s||!s.ok)return null;const t=s.topics,b=[...t].sort((d,h)=>h.pct_correct-d.pct_correct),u=b.slice(0,3),x=b.slice(u.length).sort((d,h)=>d.pct_correct-h.pct_correct).slice(0,3),w=[...t].sort((d,h)=>h.questions-d.questions).slice(0,6).map(d=>({topic:d.topic_name.length>16?`${d.topic_name.slice(0,15)}â¦`:d.topic_name,value:d.pct_correct})),_=t.filter(d=>d.attempted>0),C=[..._].sort((d,h)=>h.avg_time_seconds-d.avg_time_seconds)[0]??null,S=[..._].sort((d,h)=>d.avg_time_seconds-h.avg_time_seconds)[0]??null;return{strengths:u,focusAreas:x,radarTopics:w,slowest:C,fastest:S}},[s]);if(r)return e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(j,{className:"h-5 w-5 animate-spin text-ink-500"})});if(c)return e.jsxs("div",{className:"surface-card frosted-shadow rounded-card space-y-3 p-6 text-center",children:[e.jsx("p",{className:"text-sm text-ink-600",children:"Couldn't load your performance analysis."}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>i(),children:"Retry"})]});if(!s||!s.ok||!n)return null;const{time:l,benchmark:o}=s,m=[{label:"You",value:Number(o.student_pct),cls:"bg-brand-primary"},{label:"Class average",value:o.class_avg_pct!=null?Number(o.class_avg_pct):null,cls:"bg-brand-secondary"},{label:"School average",value:o.school_avg_pct!=null?Number(o.school_avg_pct):null,cls:"bg-ink-400/50"}];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx(k,{eyebrow:"Skill intelligence",title:"Topic radar",subt
1itle:"Your accuracy by topic",children:n.radarTopics.length>=3?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",height:260},children:e.jsx(oe,{children:e.jsxs(de,{data:n.radarTopics,outerRadius:"70%",children:[e.jsx(xe,{stroke:"hsl(var(--surface-stroke))"}),e.jsx(he,{dataKey:"topic",tick:{fill:"hsl(var(--ink-500))",fontSize:10}}),e.jsx(pe,{domain:[0,100],tick:!1,axisLine:!1}),e.jsx(me,{dataKey:"value",stroke:"hsl(var(--brand-primary))",fill:"hsl(var(--brand-primary))",fillOpacity:.25})]})})}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-x-4 gap-y-1 text-[11px] text-ink-600",children:[e.jsxs("span",{children:[e.jsx("span",{className:"mr-1 inline-block h-2 w-2 rounded-full bg-emerald-500"}),"80â100 Strong"]}),e.jsxs("span",{children:[e.jsx("span",{className:"mr-1 inline-block h-2 w-2 rounded-full bg-amber-500"}),"60â79 Developing"]}),e.jsxs("span",{children:[e.jsx("span",{className:"mr-1 inline-block h-2 w-2 rounded-full bg-rose-500"}),"0â59 Needs attention"]})]})]}):e.jsx("ul",{className:"divide-y divide-surface-stroke",children:s.topics.map(t=>e.jsx(fe,{t},`${t.subject_name}-${t.topic_name}`))})}),e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsx(k,{eyebrow:"Where you shine",title:"Strengths",children:e.jsx("ul",{className:"divide-y divide-surface-stroke",children:n.strengths.map(t=>e.jsxs("li",{className:"flex items-center gap-2.5 py-1.5",children:[e.jsx(T,{className:"h-4 w-4 shrink-0 text-emerald-500"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-ink-900",children:t.topic_name}),e.jsx("p",{className:"text-[11px] text-ink-500",children:t.subject_name})]}),e.jsxs("span",{className:p("shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold tabular-nums",D(t.pct_correct)),children:[t.pct_correct,"%"]})]},`${t.subject_name}-${t.topic_name}`))})}),n.focusAreas.length>0&&e.jsx(k,{eyebrow:"Where to improve",title:"Focus areas",children:e.jsx("ul",{className:"divide-y divide-surface-stroke",children:n.focusAreas.map(t=>e.jsxs("li",{className:"flex items-center gap-2.5 py-1.5",children:[e.jsx(F,{className:"h-4 w-4 shrink-0 text-brand-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-ink-900",children:t.topic_name}),e.jsx("p",{className:"text-[11px] text-ink-500",children:t.subject_name})]}),e.jsxs("span",{className:p("shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold tabular-nums",D(t.pct_correct)),children:[t.pct_correct,"%"]})]},`${t.subject_name}-${t.topic_name}`))})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx(k,{eyebrow:"Benchmark",title:"How you compare",subtitle:"Overall score vs your class and school",children:e.jsx("ul",{className:"space-y-3",children:m.map(t=>e.jsxs("li",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:t.label==="You"?"font-semibold text-ink-900":"text-ink-600",children:t.label}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:t.value!=null?`${Math.round(t.value*10)/10}%`:"N/A"})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-ink-400/10",children:e.jsx("div",{className:p("h-full rounded-full",t.cls),style:{width:`${Math.min(100,Math.max(0,t.value??0))}%`}})})]},t.label))})}),e.jsx(k,{eyebrow:"Time intelligence",title:"How you spent your time",subtitle:`Total exam time: ${g(l.total_seconds)}`,children:e.jsxs("ul",{className:"space-y-2.5",children:[e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(X,{className:"h-4 w-4 shrink-0 text-brand-primary"}),e.jsx("span",{className:"flex-1 text-ink-600",children:"Average per question"}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:g(l.avg_seconds_per_question)})]}),n.fastest&&e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(J,{className:"h-4 w-4 shrink-0 text-emerald-500"}),e.jsxs("span",{className:"flex-1 truncate text-ink-600",children:["Fastest topic · ",n.fastest.topic_name]}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:g(n.fastest.avg_time_seconds)})]}),n.slowest&&e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(V,{className:"h-4 w-4 shrink-0 text-brand-secondary"}),e.jsxs("span",{className:"flex-1 truncate text-ink-600",children:["Slowest topic · ",n.slowest.topic_name]}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:g(n.slowest.avg_time_seconds)})]}),e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(T,{className:"h-4 w-4 shrink-0 text-emerald-500"}),e.jsx("span",{className:"flex-1 text-ink-600",children:"Avg time when correct"}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:g(l.avg_seconds_correct)})]}),e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(F,{className:"h-4 w-4 shrink-0 text-rose-500"}),e.jsx("span",{className:"flex-1 text-ink-600",children:"Avg time when incorrect"}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:g(l.avg_seconds_incorrect)})]}),e.jsxs("li",{className:"flex items-center gap-2.5 text-sm",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0 text-ink-500"}),e.jsx("span",{className:"flex-1 text-ink-600",children:"Unanswered questions"}),e.jsx("span",{className:"font-semibold tabular-nums text-ink-900",children:l.unanswered})]})]})})]})]})}const je={gold:{label:"Gold",icon:R,cls:"bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300"},silver:{label:"Silver",icon:G,cls:"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300"},bronze:{label:"Bronze",icon:$,cls:"bg-orange-100 text-orange-800 dark:bg-orange-500/15 dark:text-orange-300"},participation:{label:"Participation",icon:y,cls:"bg-sky-100 text-sky-800 dark:bg-sky-500/15 dark:text-sky-300"}};function ge(){const{studentId:a}=W(),{data:s,isLoading:r}=z(a),c=Y(),[i,n]=v.useState(null),l=async(u,x)=>{n(x);try{const w=await c.mutateAsync({resultId:u,kind:x});q(w)}finally{n(null)}};if(r)return e.jsx(N,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(j,{className:"h-5 w-5 animate-spin text-ink-500"})})});const o=e.jsxs(O,{to:"/school/olympiad/students",className:"inline-flex items-center gap-1 text-sm text-ink-600 hover:text-ink-900 mb-2",children:[e.jsx(se,{className:"h-4 w-4"})," Students"]});if(!(s!=null&&s.ok))return e.jsxs(N,{children:[o,e.jsx(L,{title:"Student dashboard"}),e.jsx("div",{className:"surface-card frosted-shadow rounded-card p-6 text-center text-sm text-ink-600",children:"This student's result hasn't been published yet."})]});const m=s.certificate_tier==="absent",t=je[s.certificate_tier],b=(t==null?void 0:t.icon)??y;return e.jsxs(N,{children:[o,e.jsx(L,{title:s.full_name,subtitle:`${s.roll_number} · ${s.class_label}${s.section_label?` · Section ${s.section_label}`:""}`}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("section",{className:"surface-card frosted-shadow rounded-card p-5 sm:p-6",children:m?e.jsx("p",{className:"text-center text-sm text-ink-600",children:"This student did not appear for the exam."}):e.jsxs("div",{className:"flex flex-col items-center gap-5 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"inline-flex h-14 w-14 items-center justify-center rounded-2xl bg-brand-primary/10 text-brand-primary",children:e.jsx(b,{className:"h-7 w-7"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-3xl font-bold tabular-nums text-ink-900",children:[Number(s.percentage).toFixed(1),"%"]}),e.jsxs("p",{className:"text-sm text-ink-600",children:[Number(s.total_marks_obtained).toFixed(0),"/",Number(s.total_max_marks).toFixed(0)," marks"]})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Class rank"}),e.jsx("p",{className:"mt-0.5 text-lg font-bold tabular-nums text-ink-900",children:s.class_rank!=null?e.jsxs(e.Fragment,{children:[s.class_rank,s.class_total!=null&&e.jsxs("span",{className:"text-sm font-normal text-ink-500",children:[" / ",s.class_total]})]}):"N/A"})]}),e.jsx("span",{className:"hidden h-8 w-px bg-surface-stroke sm:block","aria-hidden":!0}),e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Award"}),t?e.jsxs("span",{className:p("mt-1 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-semibold",t.cls),children:[e.jsx(b,{className:"h-3.5 w-3.5"}),t.label]}):e.jsx("p",{className:"mt-0.5 text-lg font-bold text-ink-900",children:"N/A"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",disabled:i!==null||!s.result_pdf_path,onClick:()=>l(s.result_id,"result"),children:[i==="result"?e.jsx(j,{className:"mr-1.5 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-1.5 h-4 w-4"}),"Report"]}),e.jsxs(f,{variant:"outline",size:"sm",disabled:i!==null||!s.certificate_pdf_path,onClick:()=>l(s.result_id,"certificate"),children:[i==="certificate"?e.jsx(j,{className:"mr-1.5 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-1.5 h-4 w-4"}),"Certificate"]})]})]})}),!m&&e.jsx(K,{studentId:a})]})]})}const Me=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"}));function Ne({scheduledAt:a}){const[s,r]=v.useState(()=>Date.now());v.useEffect(()=>{const t=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(t)},[]);const i=new Date(a).getTime()-s;
1if(i<=0)return e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:"Exam is live now"});const n=Math.floor(i/(24*60*60*1e3)),l=Math.floor(i%(24*60*60*1e3)/(60*60*1e3)),o=Math.floor(i%(60*60*1e3)/(60*1e3)),m=Math.floor(i%(60*1e3)/1e3);return n>0?e.jsxs("p",{className:"text-xl font-bold text-ink-900",children:[n,"d ",l,"h ",o,"m"]}):l>0?e.jsxs("p",{className:"text-xl font-bold text-amber-600",children:[l,"h ",o,"m ",m,"s"]}):e.jsxs("p",{className:"text-xl font-bold text-red-600",children:[o,"m ",m,"s"]})}const E={gold:{label:"Gold",icon:R,ring:["#ffe9a8","#f3c357","#d99a2b"],iconClass:"text-[#f5cd63]",labelGrad:"from-[#ffe9a8] to-[#f1c052]",starClass:"text-[#f3c357]",glowClass:"bg-[#ffce73]/30"},silver:{label:"Silver",icon:G,ring:["#f4f7fa","#cdd6df","#9fabb8"],iconClass:"text-[#dbe3ea]",labelGrad:"from-[#eef2f6] to-[#c2ccd6]",starClass:"text-[#cdd6df]",glowClass:"bg-[#cfdae6]/25"},bronze:{label:"Bronze",icon:$,ring:["#f1cea3","#d99a5e","#b06f31"],iconClass:"text-[#e7b07a]",labelGrad:"from-[#f0c79a] to-[#cc8a4e]",starClass:"text-[#d99a5e]",glowClass:"bg-[#e0a36a]/30"},participation:{label:"Participation",icon:y,ring:["#a7e3e0","#3aa9a4","#1f8e92"],iconClass:"text-[#cdeeec]",labelGrad:"from-[#cdeeec] to-[#5bbdb9]",starClass:"text-[#7fd3d0]",glowClass:"bg-white/20"},absent:{label:"Absent",icon:y,ring:["#cdd6df","#aab4bf","#8794a1"],iconClass:"text-[#dbe3ea]",labelGrad:"from-[#e2e8f0] to-[#aab4bf]",starClass:"text-[#aab4bf]",glowClass:"bg-white/12"}};function ye({cfg:a,className:s}){const r=a.icon;return e.jsxs("div",{className:p("relative mb-1 h-[104px] w-[92px]",s),children:[e.jsxs("svg",{viewBox:"0 0 92 104",className:"absolute inset-0 h-full w-full drop-shadow-[0_10px_16px_rgba(0,0,0,0.3)]","aria-hidden":!0,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tier-ring",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0",stopColor:a.ring[0]}),e.jsx("stop",{offset:"0.5",stopColor:a.ring[1]}),e.jsx("stop",{offset:"1",stopColor:a.ring[2]})]})}),e.jsx("path",{d:"M34 56 L26 100 L40 90 L46 99 L52 90 L66 100 L58 56 Z",fill:"#0f6066"}),e.jsx("path",{d:"M37 58 L31 92 L40 86 L46 94 L52 86 L61 92 L55 58 Z",fill:"#0c4d52"}),e.jsx("circle",{cx:"46",cy:"40",r:"35",fill:"url(#tier-ring)"}),e.jsx("circle",{cx:"46",cy:"40",r:"35",fill:"none",stroke:"#ffffff",strokeOpacity:"0.35",strokeWidth:"1.5"}),e.jsx("circle",{cx:"46",cy:"40",r:"27",fill:"#0e5a61"})]}),e.jsx(r,{className:p("absolute left-[46px] top-[40px] h-[26px] w-[26px] -translate-x-1/2 -translate-y-1/2",a.iconClass)})]})}function we({correct:a,incorrect:s,total:r,accuracyPct:c}){const n=2*Math.PI*46,l=n*(1-Math.min(100,Math.max(0,c))/100);return e.jsxs("div",{className:"w-full rounded-2xl border border-white/20 bg-white/10 p-5 md:w-[330px] md:shrink-0",children:[e.jsx("p",{className:"mb-3.5 text-center text-[10.5px] font-bold uppercase tracking-[0.14em] text-white/75",children:"How you answered"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative h-[112px] w-[112px] shrink-0",children:[e.jsxs("svg",{width:"112",height:"112",viewBox:"0 0 112 112",className:"-rotate-90","aria-hidden":!0,children:[e.jsx("circle",{cx:"56",cy:"56",r:46,fill:"none",stroke:"rgba(255,255,255,0.18)",strokeWidth:"12"}),e.jsx("circle",{cx:"56",cy:"56",r:46,fill:"none",stroke:"#34d399",strokeWidth:"12",strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:l})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsxs("span",{className:"text-[24px] font-extrabold leading-none text-white",children:[c,"%"]}),e.jsx("span",{className:"mt-0.5 text-[9px] font-bold uppercase tracking-[0.08em] text-white/70",children:"Accuracy"})]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(M,{color:"bg-emerald-400",label:"Correct",value:a}),e.jsx(M,{color:"bg-rose-400",label:"Incorrect",value:s}),e.jsx(M,{color:"bg-white/50",label:"Total",value:r})]})]})]})}function M({color:a,label:s,value:r}){return e.jsxs("div",{className:"flex items-center gap-2.5 py-[5px]",children:[e.jsx("span",{className:p("h-2.5 w-2.5 shrink-0 rounded-sm",a)}),e.jsx("span",{className:"flex-1 text-xs font-semibold text-white/85",children:s}),e.jsx("span",{className:"text-sm font-extrabold tabular-nums text-white",children:r})]})}function ke({result:a}){const s=Y(),[r,c]=v.useState(null),i=E[a.certificate_tier]??E.participation,n=async h=>{c(h);try{const U=await s.mutateAsync({resultId:a.result_id,kind:h});q(U)}catch{}finally{c(null)}},l=a.certificate_tier==="absent",o=a.class_rank===1,m=a.school_rank===1,t=!l&&(o||m),b=o&&m?"1st in your class & school":o?"1st in your class":"1st in your school",u=Math.round(Number(a.total_marks_obtained)),x=Math.round(Number(a.total_max_marks)),w=Math.max(0,x-u),_=
1Math.round(Number(a.percentage)),C=a.school_rank??a.class_rank,S=a.school_rank?a.school_total:a.class_total,d=C&&S?Math.max(1,Math.round(C/S*100)):null;return e.jsxs("div",{className:"surface-card frosted-shadow rounded-card overflow-hidden",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-brand-primary via-[#15828a] to-[#0e5a61] p-6 sm:p-7",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-[22%] -top-10 h-44 w-72 -translate-x-1/2 rounded-full bg-white/16 blur-3xl"}),e.jsx("div",{"aria-hidden":!0,className:p("pointer-events-none absolute left-[74%] top-1/3 h-44 w-72 -translate-x-1/2 rounded-full blur-3xl",i.glowClass)}),e.jsxs("div",{className:"relative flex flex-col items-center gap-6 text-center md:flex-row md:items-center md:justify-between md:gap-8 md:text-left",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 md:flex-row md:items-center md:gap-5",children:[e.jsx(ye,{cfg:i,className:"md:mb-0"}),e.jsxs("div",{className:"flex flex-col items-center md:items-start",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-white/80",children:"Your result"}),e.jsxs("div",{className:"mt-2 inline-flex items-center gap-2.5",children:[e.jsx(y,{className:p("h-3 w-3 fill-current",i.starClass)}),e.jsx("span",{className:p("bg-gradient-to-b bg-clip-text text-sm font-extrabold uppercase tracking-[0.24em] text-transparent",i.labelGrad),children:i.label}),e.jsx(y,{className:p("h-3 w-3 fill-current",i.starClass)})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mt-2 text-[44px] font-extrabold leading-none text-white",children:[u," ",e.jsxs("span",{className:"text-3xl font-bold text-white/55",children:["/ ",x]})]}),e.jsxs("p",{className:"mt-1.5 text-lg font-bold text-white/90",children:[Number(a.percentage).toFixed(2),"%"]}),t&&e.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 rounded-full border border-white/40 bg-white/12 px-4 py-1.5 text-xs font-bold text-white",children:[e.jsx(R,{className:"h-3.5 w-3.5"}),b]})]})]})]}),!l&&e.jsx(we,{correct:u,incorrect:w,total:x,accuracyPct:_})]})]}),l?e.jsx("p",{className:"p-6 text-center text-sm text-ink-700",children:"You did not attempt the exam. Contact your school if this is an error."}):e.jsxs("div",{className:"space-y-4 p-5 sm:p-6",children:[a.class_rank!=null&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-brand-primary/20 bg-brand-primary/10 p-3.5",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-brand-primary/15 text-brand-primary",children:e.jsx($,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-[0.1em] text-brand-primary",children:"Class rank"}),e.jsxs("p",{className:"text-xl font-extrabold leading-tight text-ink-900",children:[a.class_rank," ",e.jsxs("span",{className:"text-sm font-medium text-ink-500",children:["of ",a.class_total]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-brand-secondary/20 bg-brand-secondary/10 p-3.5",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-brand-secondary/15 text-brand-secondary",children:e.jsx(ae,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-[0.1em] text-brand-secondary",children:"Percentile"}),e.jsx("p",{className:"text-xl font-extrabold leading-tight text-ink-900",children:d!=null?e.jsxs(e.Fragment,{children:["Top ",d,e.jsx("span",{className:"text-sm font-medium text-ink-500",children:"%"})]}):"N/A"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 sm:flex-row",children:[e.jsxs(f,{variant:"secondary",className:"h-12 flex-1 border-0 bg-brand-primary bg-none text-white shadow-sm hover:bg-brand-primary/90",disabled:r!==null||!a.result_pdf_path,onClick:()=>n("result"),children:[r==="result"?e.jsx(j,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-2 h-4 w-4"}),"Download report"]}),e.jsxs(f,{variant:"secondary",className:"h-12 flex-1 border-0 bg-brand-accent bg-none text-white shadow-sm hover:bg-brand-accent/90",disabled:r!==null||!a.certificate_pdf_path,onClick:()=>n("certificate"),children:[r==="certificate"?e.jsx(j,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-2 h-4 w-4"}),"Download certificate"]})]}),e.jsx(O,{to:"/student/olympiad/review",children:e.jsxs(f,{variant:"ghost",className:"h-11 w-full text-brand-primary hover:bg-brand-primary/10 hover:text-brand-primary",children:["Review your answers",e.jsx(te,{className:"ml-2 h-4 w-4"})]})})]})]})}function ve(){const a=Q(),{data:s,isLoading:r}=ne(),c=s!=null&&s.ok?s.student.subject_ids:void 0,i=s!=null&&s.ok?s.student.grade_level_id:void 0,{data:n}=ie(c,i),{data:l}=z();if(r)return e.jsx(N,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(j,{className:"h-5 w-5 animate-spin text-ink-500"})})});if(!(s!=null&&s.ok))return e.jsxs(N,{children:[e.jsx(L,{title:"SALCI Olympiad"}),e.jsx("p",{className:"py-6 text-sm text-ink-600",children:"No active Olympiad enrollment for your account."})]});const o=x=>x.toLocaleDateString("en-IN",{timeZone:"Asia/Kolkata"}),m=s.batch!==null&&o(new Date(s.batch.scheduled_at))===o(new Date),t=!!s.attempt&&s.attempt.status!=="in_progress",b=((l==null?void 0:l.ok)??!1)||t,u=e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow",children:"Your subjects"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:s.subjects.map(x=>e.jsxs(O,{to:`/student/olympiad/study/${x.id}`,className:"group flex items-center justify-between gap-2 rounded-xl border border-surface-stroke bg-surface-card px-3.5 py-3 transition-colors hover:border-brand-primary/40 hover:bg-brand-primary/[0.05]",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4 shrink-0 text-brand-primary"}),e.jsx("span",{className:"truncate text-sm font-semibold text-ink-900",children:x.name})]}),e.jsx(le,{className:"h-4 w-4 shrink-0 text-ink-400 transition-colors group-hover:text-brand-primary"})]},x.id))})]}),(n??[]).length>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow",children:"Study material"}),e.jsx("div",{className:"space-y-2",children:(n??[]).map(x=>e.jsx(ce,{material:x},x.id))})]})]});return e.jsxs(N,{children:[e.jsx(L,{title:"SALCI Olympiad",subtitle:`${s.school_name} · Roll ${s.student.roll_number}`}),e.jsxs("div",{className:"space-y-4 py-4",children:[l!=null&&l.ok?e.jsx(ke,{result:l}):e.jsxs("div",{className:"surface-card frosted-shadow rounded-card p-6 text-center",children:[e.jsx("p",{className:"eyebrow",children:"Your exam"}),s.attempt&&s.attempt.status!=="in_progress"?e.jsxs("div",{className:"space-y-2 mt-3",children:[e.jsx(T,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"text-base font-semibold text-ink-900",children:"Exam submitted"}),s.attempt.submitted_at&&e.jsxs("p",{className:"text-xs text-ink-500",children:["Submitted on ",new Date(s.attempt.submitted_at).toLocaleStr
1ing("en-IN",{timeZone:"Asia/Kolkata"})]}),e.jsx("p",{className:"text-sm text-ink-700 mt-2",children:"Your results will be published by your school soon."})]}):s.attempt&&s.attempt.status==="in_progress"?e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsx("p",{className:"text-sm text-ink-700",children:"You have an exam in progress."}),e.jsx(f,{className:"w-full",onClick:()=>a("/student/olympiad/exam"),children:"Resume exam"})]}):s.batch?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-ink-700 mt-1",children:new Date(s.batch.scheduled_at).toLocaleString("en-IN",{timeZone:"Asia/Kolkata",dateStyle:"full",timeStyle:"short"})}),e.jsx("div",{className:"mt-4",children:e.jsx(Ne,{scheduledAt:s.batch.scheduled_at})}),e.jsx(f,{className:"w-full mt-4",onClick:()=>a("/student/olympiad/pin-entry"),disabled:!m,title:m?void 0:"Available on exam day",children:m?"Start exam":"Available on exam day"})]}):e.jsx("p",{className:"text-sm text-ink-600 mt-2",children:"Your batch will be announced by your school."})]}),!b&&u,(l==null?void 0:l.ok)&&l.certificate_tier!=="absent"&&e.jsx(K,{}),b&&u]})]})}const Te=Object.freeze(Object.defineProperty({__proto__:null,default:ve},Symbol.toStringTag,{value:"Module"}));export{Me as O,K as S,Y as a,Te as b,z as u};
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.