#!/usr/bin/env node
import'./chunk-XHJ27CER.js';import {Router}from'express';import*as n from'fs';import*as o from'path';function m(p){let i=Router(),u=o.join(__dirname,"..","..","university-content");return i.get("/courses",(a,e)=>{try{let s=o.join(u,"courses");if(!n.existsSync(s))return e.json({courses:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")).map(r=>{let t=JSON.parse(n.readFileSync(o.join(s,r),"utf-8"));return {id:t.id,title:t.title,description:t.description,lessonCount:t.lessons?.length||0,quizCount:t.quizzes?.length||0,lessons:(t.lessons||[]).map(d=>({id:d.id,title:d.title}))}});return l.sort((r,t)=>r.id.localeCompare(t.id)),e.json({courses:l})}catch(s){e.status(500).json({error:"Failed to list courses",detail:String(s)});}}),i.get("/courses/:id",(a,e)=>{try{let s=o.join(u,"courses",`${a.params.id}.json`);if(!n.existsSync(s))return e.status(404).json({error:`Course '${a.params.id}' not found`});let c=JSON.parse(n.readFileSync(s,"utf-8"));return e.json(c)}catch(s){e.status(500).json({error:"Failed to load course",detail:String(s)});}}),i.get("/plsat",(a,e)=>{try{let s=o.join(u,"plsat");if(!n.existsSync(s))return e.json({versions:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")).map(r=>{let t=JSON.parse(n.readFileSync(o.join(s,r),"utf-8"));return {version:t.version||r.replace(".json",""),frameworkVersion:t.frameworkVersion,questionCount:t.questions?.length||0,timeLimit:t.timeLimit,passThreshold:t.passThreshold}});return e.json({versions:l})}catch(s){e.status(500).json({error:"Failed to list PLSAT versions",detail:String(s)});}}),i.get("/diplomas",(a,e)=>{try{let s=o.join(p,".paradigm","university","diplomas");if(!n.existsSync(s))return e.json({diplomas:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")||r.endsWith(".yaml")).map(r=>{let t=n.readFileSync(o.join(s,r),"utf-8");return r.endsWith(".json")?JSON.parse(t):t}).filter(Boolean);return e.json({diplomas:l})}catch(s){e.status(500).json({error:"Failed to load diplomas",detail:String(s)});}}),i.get("/reference",(a,e)=>{try{let s=o.join(u,"reference.json");if(!n.existsSync(s))return e.json({});let c=JSON.parse(n.readFileSync(s,"utf-8"));return e.json(c)}catch(s){e.status(500).json({error:"Failed to load reference",detail:String(s)});}}),i}export{m as createUniversityRouter};