#!/usr/bin/env node
import {a,c,d}from'./chunk-D34YFK4M.js';import'./chunk-5TAVYPOV.js';import s from'chalk';import*as g from'fs';import*as u from'path';async function x(i){let l=process.cwd(),c$1=a(l);if(!c$1||c$1.totalContent===0){console.log(s.yellow(`
  No university content to validate.
`));return}let n=[],r=c$1.entries;i.id&&(r=r.filter(e=>e.id===i.id),r.length===0&&(console.error(s.red(`
  Content "${i.id}" not found
`)),process.exit(1)));let a$1=null;if(i.deep){a$1=new Set;let e=u.join(l,".paradigm","scan-index.json");if(g.existsSync(e))try{let o=JSON.parse(g.readFileSync(e,"utf8"));if(o.symbols&&Array.isArray(o.symbols))for(let t of o.symbols)t.symbol&&a$1.add(t.symbol);}catch{}}let p=new Set(c$1.entries.map(e=>e.id));for(let e of r){if(e.title||n.push({contentId:e.id,severity:"error",check:"missing-title",message:"Content is missing a title"}),e.type==="quiz"){let o=c(l,e.id);if(!o)n.push({contentId:e.id,severity:"error",check:"unreadable-quiz",message:"Quiz file could not be parsed"});else for(let t of o.questions)(!t.choices||!(t.correct in t.choices))&&n.push({contentId:e.id,severity:"error",check:"invalid-quiz-answer",message:`Question ${t.id}: correct "${t.correct}" not in choices [${Object.keys(t.choices||{}).join(", ")}]`,fix:`Set correct to one of: ${Object.keys(t.choices||{}).join(", ")}`});}if(e.type==="path"){let o=d(l,e.id);if(!o)n.push({contentId:e.id,severity:"error",check:"unreadable-path",message:"Learning path file could not be parsed"});else for(let t of o.steps)!t.content.startsWith("plsat:")&&!p.has(t.content)&&n.push({contentId:e.id,severity:"error",check:"broken-path-step",message:`Step references "${t.content}" which doesn't exist`,fix:`Create content with id "${t.content}"`});}if(a$1&&e.symbols.length>0)for(let o of e.symbols)a$1.has(o)||n.push({contentId:e.id,severity:"warning",check:"broken-symbol-ref",message:`Symbol "${o}" not found in scan-index`});}if(i.json){console.log(JSON.stringify({status:n.some(e=>e.severity==="error")?"errors":n.length>0?"warnings":"healthy",totalContent:c$1.totalContent,checked:r.length,issues:n},null,2));return}if(console.log(s.blue(`
  University Validation (${r.length} items${i.deep?", deep mode":""})
`)),n.length===0){console.log(s.green(`  All checks passed.
`));return}let d$1=n.filter(e=>e.severity==="error"),f=n.filter(e=>e.severity==="warning");for(let e of d$1)console.log(s.red(`  x ${e.contentId}: ${e.message}`)),e.fix&&console.log(s.gray(`    Fix: ${e.fix}`));for(let e of f)console.log(s.yellow(`  ! ${e.contentId}: ${e.message}`)),e.fix&&console.log(s.gray(`    Fix: ${e.fix}`));console.log(),d$1.length>0&&console.log(s.red(`  ${d$1.length} error${d$1.length>1?"s":""}`)),f.length>0&&console.log(s.yellow(`  ${f.length} warning${f.length>1?"s":""}`)),console.log();}export{x as universityValidateCommand};