import{c as h,r as m,e as p,j as s}from"./index-BaOmyn11.js";let n=null;const x=h((e,t)=>({courses:[],plsatVersions:[],diplomas:[],coursesLoading:!1,selectedCourse:null,fetchCourses:async()=>{n==null||n.abort(),n=new AbortController,e({coursesLoading:!0});try{const a=await fetch("/api/university/courses",{signal:n.signal});if(!a.ok)throw new Error(`HTTP ${a.status}`);const i=await a.json();e({courses:i.courses||[],coursesLoading:!1})}catch(a){a instanceof Error&&a.name==="AbortError"||e({coursesLoading:!1})}},fetchPlsat:async()=>{try{const a=await fetch("/api/university/plsat");if(!a.ok)return;const i=await a.json();e({plsatVersions:i.versions||[]})}catch{}},fetchDiplomas:async()=>{try{const a=await fetch("/api/university/diplomas");if(!a.ok)return;const i=await a.json();e({diplomas:i.diplomas||[]})}catch{}},selectCourse:a=>e({selectedCourse:a})}));function j({course:e,onSelect:t}){return s.jsxs("div",{className:"u-course-card",onClick:t,role:"button",tabIndex:0,onKeyDown:a=>a.key==="Enter"&&t(),children:[s.jsxs("div",{className:"u-course-header",children:[s.jsx("span",{className:"u-course-id",children:e.id}),s.jsxs("span",{className:"u-course-meta",children:[e.lessonCount," lessons",e.quizCount>0?` · ${e.quizCount} quizzes`:""]})]}),s.jsx("h3",{className:"u-course-title",children:e.title}),s.jsx("p",{className:"u-course-desc",children:e.description})]})}function f({version:e}){return s.jsxs("div",{className:"u-plsat-card",children:[s.jsxs("div",{className:"u-plsat-header",children:[s.jsxs("span",{className:"u-plsat-version",children:["PLSAT ",e.version]}),e.passThreshold&&s.jsxs("span",{className:"u-plsat-threshold",children:["Pass: ",e.passThreshold,"%"]})]}),s.jsxs("div",{className:"u-plsat-meta",children:[e.questionCount," questions",e.timeLimit?` · ${e.timeLimit} min`:"",e.frameworkVersion?` · Framework ${e.frameworkVersion}`:""]})]})}function N({diploma:e}){return s.jsxs("div",{className:`u-diploma-card ${e.passed?"u-diploma-passed":"u-diploma-failed"}`,children:[s.jsxs("div",{className:"u-diploma-header",children:[s.jsx("span",{className:"u-diploma-type",children:e.type.toUpperCase()}),s.jsx("span",{className:"u-diploma-date",children:new Date(e.earnedAt).toLocaleDateString()})]}),s.jsxs("div",{className:"u-diploma-score",children:[e.score,"/",e.total," (",e.percentage,"%)",e.passed?" — Passed":" — Not passed"]})]})}function C(){const{courses:e,plsatVersions:t,diplomas:a,coursesLoading:i,selectedCourse:v,fetchCourses:l,fetchPlsat:o,fetchDiplomas:c,selectCourse:d}=x();return m.useEffect(()=>{l(),o(),c();const r=setInterval(()=>{p.getState().activeSection==="university"&&c()},3e4);return()=>clearInterval(r)},[]),s.jsxs("div",{className:"u-section",children:[s.jsxs("div",{className:"u-header",children:[s.jsx("h1",{children:"University"}),s.jsx("span",{className:"u-subtitle",children:"Courses, certifications, and learning paths"})]}),a.length>0&&s.jsxs("div",{className:"u-block",children:[s.jsx("h2",{children:"Earned Diplomas"}),s.jsx("div",{className:"u-grid",children:a.map((r,u)=>s.jsx(N,{diploma:r},r.id||u))})]}),s.jsxs("div",{className:"u-block",children:[s.jsx("h2",{children:"Courses"}),i&&s.jsx("p",{className:"u-loading",children:"Loading courses..."}),!i&&e.length===0&&s.jsxs("p",{className:"u-empty",children:["No courses available. Run ",s.jsx("code",{children:"paradigm university"})," to set up content."]}),s.jsx("div",{className:"u-grid",children:e.map(r=>s.jsx(j,{course:r,onSelect:()=>d(r.id)},r.id))})]}),t.length>0&&s.jsxs("div",{className:"u-block",children:[s.jsx("h2",{children:"PLSAT Certification Exams"}),s.jsx("div",{className:"u-grid",children:t.map(r=>s.jsx(f,{version:r},r.version))})]})]})}export{C as default};
