1import{f as nt,j as e}from"./query-vendor-hhwDzQ2O.js";import{h as ct,u as dt,r as u}from"./react-vendor-CeHpY9tY.js";import{D as js}from"./DashboardLayout-DvVs0FN8.js";import{a as ot,az as ut,j as xt,$ as mt,k as ht,aA as pt,aB as gt,aC as jt,aD as ft,aE as bt,aF as vt,ad as Nt,aG as yt,aH as wt,aI as kt,ah as Ct,aJ as St,aK as Dt,aL as At,aM as Lt,B as n,C as Q,c as w,f as Ye,p as fe,d as Ut,e as Ft,L as c,I as h,S as B,w as $,x as _,y as R,z as v,K as ee,N as se,O as te,P as ae,aa as ie,al as fs,aN as Tt,aO as Qt,aP as zt,aQ as qt,aR as Pt,aS as Mt,aT as Ot,aU as Vt,o as bs,aV as vs,aW as z,aX as be}from"./index-DCdJkPd2.js";import{T as S}from"./textarea-CHE9QOqw.js";import{T as It,a as Et,b as ve,c as Ne}from"./tabs-BLnMsruH.js";import{T as ye,a as we,b as F,c as x,d as ke,e as m}from"./table-DkWCtlvc.js";import{h as T,a4 as Kt,bk as Ce,aO as D,bv as Ns,a9 as He,c as Se,bm as Bt,bw as $t,bx as De,b as Y,ap as ys,Y as Ae,aq as ws,by as ks,a1 as q,$ as _t,a0 as Rt,bt as Yt,z as Ht,r as Wt,br as Gt,X as Cs,ar as Xt,V as Jt}from"./icons-vendor-B7tMGsnB.js";import"./index-Bznwf2v8.js";const As=5*1024*1024,Ss=Math.floor(As/1024/1024),Ds=(H,Le)=>H?.response?.data?.error||H?.response?.data?.message||H?.message||Le;function ca(){const{id:H}=ct(),[,Le]=dt(),d=Number(H),{toast:r}=ot(),p=nt(),re=ut(),{data:f,isLoading:Ls}=xt(d),{data:le,isLoading:Us}=mt({courseId:d}),{data:Ue,isLoading:Fs}=ht({courseId:d}),Ts=pt(),Qs=gt(),zs=jt(),Fe=ft(),ne=bt(),We=vt(),[Te,Ge]=u.useState(""),[Qe,Xe]=u.useState(""),[ze,Je]=u.useState("MS Office"),[qe,Pe]=u.useState("3 Months"),[Ze,Me]=u.useState("5000"),[ce,es]=u.useState(!1),[de,ss]=u.useState(""),[ts,as]=u.useState(""),[is,rs]=u.useState("75");u.useEffect(()=>{f&&(Ge(f.title||""),Xe(f.description||""),Je(f.category||"MS Office"),Pe(f.duration||"3 Months"),Me((f.fee??0).toString()),es(!!f.isFree),ss(f.thumbnail||""),as(f.syllabus||""),rs((f.minAttendancePercentage??75).toString()))},[f]);const qs=async s=>{if(s.preventDefault(),!Te.trim()||!Qe.trim()||!ze.trim()||!qe.trim()){r({title:"Please fill in all required fields",variant:"destructive"});return}try{await ps.mutateAsync({id:d,data:{title:Te,description:Qe,category:ze,duration:qe,fee:ce?0:Number(Ze),isFree:ce,thumbnail:de||null,syllabus:ts||null,minAttendancePercentage:Number(is)}}),r({title:"Course details updated successfully!"}),p.invalidateQueries({queryKey:bs(d)})}catch{r({title:"Error updating course details",variant:"destructive"})}},[Oe,Ve]=u.useState(null),[oe,ue]=u.useState(""),[Ps,P]=u.useState(!1),[Ms,xe]=u.useState(!1),[Os,me]=u.useState(!1),[Vs,he]=u.useState(!1),[M,O]=u.useState(null),[Ie,Is]=u.useState(null),[V,ls]=u.useState(!1),[i,g]=u.useState({title:"",description:"",videoUrl:"",pdfUrl:"",duration:"",completionThreshold:"80",notes:"",resources:"",isVisible:!0}),W=()=>g({title:"",description:"",videoUrl:"",pdfUrl:"",duration:"",completionThreshold:"80",notes:"",resources:"",isVisible:!0}),ns=async s=>{const a=s.target.files?.[0];if(!a)return;if(a.type!=="application/pdf"){r({title:"Only PDF files are allowed",variant:"destructive"});return}const t=new FormData;t.append("pdf",a),ls(!0);try{const l=localStorage.getItem("token")||sessionStorage.getItem("token"),o=await fetch("/api/lessons/upload-pdf",{method:"POST",body:t,headers:{Authorization:`Bearer ${l}`}}),N=await o.json();if(!o.ok)throw new Error(N.error||"Upload failed");g(C=>({...C,pdfUrl:N.url})),r({title:"PDF uploaded successfully!"})}catch(l){r({title:l.message||"Failed to upload",variant:"destructive"})}finally{ls(!1)}},[pe,cs]=u.useState(!1),Es=async s=>{const a=s.target.files?.[0];if(!a)return;if(a.type!=="application/pdf"&&!a.name.toLowerCase().endsWith(".pdf")){r({title:"Only PDF files are allowed",variant:"destructive"});return}if(a.size>As){r({title:`PDF must be ${Ss}MB or smaller. Please compress it first.`,variant:"destructive"});return}const t=new FormData;t.append("pdf",a),cs(!0);try{const l=localStorage.getItem("token")||sessionStorage.getItem("token"),o=await fetch("/api/upload-pdf",{method:"POST",body:t,headers:{Authorization:`Bearer ${l}`}}),N=await o.json();if(!o.ok)throw new Error(N.error||"Upload failed");A(C=>({...C,fileUrl:N.url})),r({title:"Assignment PDF uploaded successfully!"})}catch(l){r({title:l.message||"Failed to upload",variant:"destructive"})}finally{cs(!1)}},ds=s=>{Is(s),W(),xe(!0)},os=s=>{O(s),g({title:s.title||"",description:s.description||"",videoUrl:s.videoUrl||"",pdfUrl:s.pdfUrl||"",duration:s.duration?.toString()||"",completionThreshold:(s.completionThreshold??80).toString(),notes:s.notes||"",resources:s.resources||"",isVisible:s.isVisible!==!1}),me(!0)},{data:us,isLoading:Ks}=Nt({courseId:d}),Bs=yt(),$s=wt(),_s=kt(),[Rs,I]=u.useState(!1),[Ee,Ke]=u.useState(null),[b,A]=u.useState({title:"",description:"",dueDate:"",totalMarks:100,fileUrl:""}),{data:xs,isLoading:Ys}=Ct({courseId:d}
1),Be=St(),$e=Dt(),ms=At(),[Hs,E]=u.useState(!1),[G,hs]=u.useState(null),[j,y]=u.useState({title:"",timeLimit:30,timerMode:"overall",questions:[{question:"",options:["","","",""],correctOption:0,marks:1}]}),_e=()=>{hs(null),y({title:"",timeLimit:30,timerMode:"overall",questions:[{question:"",options:["","","",""],correctOption:0,marks:1}]})},Ws=async()=>{if(oe.trim())try{Oe?(await Qs.mutateAsync({id:Oe,data:{courseId:d,title:oe,order:0}}),r({title:"Section updated"})):(await Ts.mutateAsync({data:{courseId:d,title:oe,order:le?.length??0}}),r({title:"Section created"})),p.invalidateQueries({queryKey:vs({courseId:d})}),ue(""),Ve(null),P(!1)}catch{r({title:"Error saving section",variant:"destructive"})}},Gs=async s=>{if(s.preventDefault(),!i.title||!Ie){r({title:"Title is required",variant:"destructive"});return}if(!i.videoUrl.trim()){r({title:"YouTube lecture link is required",variant:"destructive"});return}try{await Fe.mutateAsync({data:{courseId:d,sectionId:Ie,title:i.title,description:i.description||void 0,videoUrl:i.videoUrl.trim(),pdfUrl:i.pdfUrl||void 0,duration:i.duration?Number(i.duration):void 0,orderIndex:Ue?.filter(a=>a.sectionId===Ie).length??0,completionThreshold:Number(i.completionThreshold)||80,notes:i.notes||void 0,resources:i.resources||void 0,isVisible:i.isVisible}}),r({title:"Lecture added successfully!"}),p.invalidateQueries({queryKey:fe({courseId:d})}),xe(!1),W()}catch(a){r({title:a?.response?.data?.error||a?.response?.data?.message||a?.message||"Failed to add lecture",variant:"destructive"})}},Xs=async s=>{if(s.preventDefault(),!M||!i.title){r({title:"Title is required",variant:"destructive"});return}if(!i.videoUrl.trim()){r({title:"YouTube lecture link is required",variant:"destructive"});return}try{await ne.mutateAsync({id:M.id,data:{courseId:d,title:i.title,description:i.description||void 0,videoUrl:i.videoUrl.trim(),pdfUrl:i.pdfUrl||void 0,duration:i.duration?Number(i.duration):void 0,orderIndex:M.orderIndex||0,completionThreshold:Number(i.completionThreshold)||80,notes:i.notes||void 0,resources:i.resources||void 0,isVisible:i.isVisible}}),r({title:"Lecture updated successfully!"}),p.invalidateQueries({queryKey:fe({courseId:d})}),me(!1),O(null),W()}catch(a){r({title:a?.response?.data?.error||a?.response?.data?.message||a?.message||"Failed to update lecture",variant:"destructive"})}},Js=async s=>{if(await re("Are you sure? This will delete all lessons in this section."))try{await zs.mutateAsync({id:s}),p.invalidateQueries({queryKey:vs({courseId:d})}),r({title:"Section deleted"})}catch{r({title:"Error deleting section",variant:"destructive"})}},Zs=async()=>{if(M)try{await We.mutateAsync({id:M.id}),p.invalidateQueries({queryKey:fe({courseId:d})}),r({title:"Lecture deleted successfully!"}),he(!1),O(null)}catch(s){r({title:Ds(s,"Error deleting lesson"),variant:"destructive"})}},et=async()=>{if(b.title.trim()){if(!b.fileUrl){r({title:"Upload the assignment PDF before saving",variant:"destructive"});return}try{Ee?(await $s.mutateAsync({id:Ee,data:{...b,courseId:d}}),r({title:"Assignment updated"})):(await Bs.mutateAsync({data:{...b,courseId:d}}),r({title:"Assignment created"})),p.invalidateQueries({queryKey:z({courseId:d})}),I(!1),Ke(null),A({title:"",description:"",dueDate:"",totalMarks:100,fileUrl:""})}catch{r({title:"Error saving assignment",variant:"destructive"})}}},st=async s=>{if(await re("Are you sure you want to delete this assignment?"))try{p.setQueryData(z({courseId:d}),a=>Array.isArray(a)?a.filter(t=>t.id!==s):a),p.setQueryData(z({}),a=>Array.isArray(a)?a.filter(t=>t.id!==s):a),await _s.mutateAsync({id:s}),p.invalidateQueries({queryKey:z({courseId:d})}),p.invalidateQueries({queryKey:z({})}),r({title:"Assignment deleted"})}catch{p.invalidateQueries({queryKey:z({courseId:d})}),p.invalidateQueries({queryKey:z({})}),r({title:"Error deleting assignment",variant:"destructive"})}},tt=async()=>{if(!j.title.trim()){r({title:"Quiz title required",description:"Please enter a title for this quiz.",variant:"destructive"});return}if(j.questions.length===0){r({title:"Questions required",description:"Please add at least one question to the quiz.",variant:"destructive"});return}for(let s=0;s<j.questions.length;s++)if(!j.questions[s].question.trim()){r({title:`Question ${s+1} empty`,description:"Please enter text for all questions.",variant:"destructive"});return}try{const s=j.questions.reduce((a,t)=>a+(Number(t.marks)||1),0);G?(await $e.mutateAsync({id:G,data:{...j,courseId:d,totalMarks:s}}),r({title:"Quiz updated successfully!"})):(await Be.mutateAsync({data:{...j,courseId:d,totalMarks:s}}),r({title:"Quiz created successfully!"})),p.invalidateQueries({queryKey:["/api/quizzes"]}),p.invalidateQueries({queryKey:be({courseId:d})}),E(!1),_e()}catch(s){const a=s?.response?.data?.error||s?.message||"Failed to save quiz";r({title:G?"Error updating quiz":"Error creating quiz",description:a,variant:"destructive"})}},at=async s=>{if(await re("Are you sure you want to delete this quiz? This action cannot be undone."))try{p.setQueryData(be({courseId:d}),a=>Array.isArray(a)?a.filter(t=>t.id!==s):a),p.setQueryData(["/api/quizzes"],a=>Array.isArray(a)?a.filter(t=>t.id!==s):a),await ms.mutateAsync({id:s}),p.invalidateQueries({queryKey:["/api/quizzes"]}),p.invalidateQueries({queryKey:be({courseId:d})}),r({title:"Quiz deleted successfully!"})}catch{p.invalidateQueries({queryKey:["/api/quizzes"]}),p.invalidateQueries({queryKey:be({courseId:d})}),r({title:"Error deleting quiz",variant:"destructive"})}},ps=Lt(),it=async()=>
1{if(await re("Are you sure you want to submit this course for review? You won't be able to edit it until it's reviewed."))try{await ps.mutateAsync({id:d,data:{...f,status:"pending"}}),r({title:"Course submitted for review"}),p.invalidateQueries({queryKey:bs(d)})}catch{r({title:"Error submitting course",variant:"destructive"})}};if(Ls||Us||Fs||Ks||Ys)return e.jsx(js,{children:e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx(T,{className:"h-8 w-8 animate-spin text-primary"})})});const rt=s=>{switch(s){case"live":return e.jsx(w,{className:"bg-green-500 hover:bg-green-600",children:"Live"});case"pending":return e.jsx(w,{className:"bg-yellow-500 hover:bg-yellow-600 text-black",children:"Pending Review"});case"rejected":return e.jsx(w,{className:"bg-red-500 hover:bg-red-600",children:"Rejected"});default:return e.jsx(w,{variant:"outline",children:"Draft"})}};return e.jsxs(js,{children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:f?.title}),rt(f?.status)]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Course Builder & Curriculum Management"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>Le("/teacher/courses"),children:[e.jsx(Kt,{className:"h-4 w-4 mr-2"}),"Back to Courses"]}),(f?.status==="draft"||f?.status==="rejected")&&e.jsxs(n,{variant:"default",className:"bg-indigo-600 hover:bg-indigo-700",onClick:it,children:[e.jsx(Ce,{className:"h-4 w-4 mr-2"}),"Submit for Review"]}),e.jsxs(n,{variant:"outline",onClick:()=>{ue(""),Ve(null),P(!0)},children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Add Section"]}),e.jsxs(n,{variant:"outline",onClick:()=>{Ke(null),A({title:"",description:"",dueDate:"",totalMarks:100,fileUrl:""}),I(!0)},children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Add Assignment"]}),e.jsxs(n,{variant:"outline",onClick:()=>{_e(),E(!0)},children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Create Quiz"]})]})]}),e.jsxs(It,{defaultValue:"curriculum",className:"w-full",children:[e.jsxs(Et,{className:"mb-8",children:[e.jsxs(ve,{value:"curriculum",className:"flex items-center gap-2 px-6",children:[e.jsx(Ns,{className:"h-4 w-4"})," Curriculum"]}),e.jsxs(ve,{value:"assignments",className:"flex items-center gap-2 px-6",children:[e.jsx(He,{className:"h-4 w-4"})," Assignments"]}),e.jsxs(ve,{value:"quizzes",className:"flex items-center gap-2 px-6",children:[e.jsx(Se,{className:"h-4 w-4"})," Quizzes"]}),e.jsxs(ve,{value:"details",className:"flex items-center gap-2 px-6",children:[e.jsx(Bt,{className:"h-4 w-4"})," Course Settings"]})]}),e.jsx(Ne,{value:"curriculum",children:le?.length===0?e.jsxs(Q,{className:"border-dashed py-12 flex flex-col items-center justify-center text-center",children:[e.jsx(Ns,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-20"}),e.jsx("h3",{className:"text-lg font-medium",children:"No sections yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mb-6",children:"Start by adding your first section to organize your course content."}),e.jsxs(n,{onClick:()=>P(!0),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Add First Section"]})]}):e.jsxs("div",{className:"space-y-5",children:[le?.map(s=>{const a=Ue?.filter(t=>t.sectionId===s.id)||[];return e.jsxs(Q,{className:"overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-slate-200 bg-slate-50/80 px-5 py-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-slate-200 bg-white text-slate-400",children:e.jsx($t,{className:"h-4 w-4 cursor-grab"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-black text-slate-900",children:s.title}),e.jsxs(w,{variant:"outline",className:"h-6 rounded-md bg-white text-[10px] font-bold text-slate-500",children:[a.length," lectures"]})]}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"Add YouTube lecture links, notes, and resources for this section."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",className:"h-9 gap-2 rounded-md text-xs font-bold",onClick:()=>ds(s.id),children:[e.jsx(D,{className:"h-3.5 w-3.5"})," Add Lecture"]}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{ue(s.title),Ve(s.id),P(!0)},children:e.jsx(De,{className:"h-4 w-4"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>Js(s.id),children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),e.jsx(Ye,{className:"p-0",children:a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-12 text-center",children:[e.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-slate-100 text-slate-400",children:e.jsx(ys,{className:"h-6 w-6"})}),e.jsx("h4",{className:"text-sm font-black text-slate-900",children:"No lecture links yet"}),e.jsx("p",{className:"mt-1 max-w-sm text-xs font-medium text-slate-500",children:"Create a lecture row with a title, YouTube URL, duration, and optional PDF notes."}),e.jsxs(n,{className:"mt-5 gap-2 rounded-md text-xs font-bold",size:"sm",onClick:()=>ds(s.id),children:[e.jsx(D,{className:"h-4 w-4"})," Add First Lecture"]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ye,{className:"min-w-[920px]",children:[e.jsx(we,{className:"bg-white",children:e.jsxs(F,{className:"hover:bg-white",children:[e.jsx(x,{className:"w-12 text-center text-[10px] font-black uppercase text-slate-400",children:"#"}),e.jsx(x,{className:"min-w-[240px] text-[10px] font-black uppercase text-slate-400",children:"Lecture"}),e.jsx(x,{className:"min-w-[280px] text-[10px] font-black uppercase text-slate-400",children:"Video Link"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"PDF"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Duration"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Status"}),e.jsx(x,{className:"w-28 text-right text-[10px] font-black uppercase text-slate-400",children:"Actions"})]})}),e.jsx(ke,{children:a.map((t,l)=>e.jsxs(F,{className:`h-14 hover:bg-slate-50/80 ${t.isVisible===!1?"bg-amber-50/30":""}`,children:[e.jsx(m,{className:"text-center",children:e.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-blue-50 text-xs font-black text-blue-600",children:l+1})}),e.jsx(m,{className:"max-w-[280px]",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-900",children:t.title}),t.description&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] font-medium text-slate-500",children:t.description})]})}),e.jsx(m,{className:"max-w-[320px]",children:t.videoUrl?e.jsxs("a",{href:t.videoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-2 rounded-md border border-red-100 bg-red-50 px-2.5 py-1.5 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.videoUrl}),e.jsx(ws,{className:"h-3 w-3 shrink-0"})]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold text-slate-400",children:[e.jsx(ks,{className:"h-3.5 w-3.5"})," No video link"]})}),e.jsx(m,{children:t.pdfUrl?e.jsxs("a",{href:t.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 text-xs font-bold text-slate-700 hover:bg-slate-50",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," PDF"]}):e.jsx("span",{className:"text-xs font-medium text-slate-400",children:"None"})}),e.jsx(m,{className:"text-xs font-semibold text-slate-600",children:t.duration?`${t.duration} min`:"Not set"}),e.jsx(m,{children:e.jsx(w,{variant:"outline",className:`h-6 rounded-md text-[10px] font-black ${t.isVisible===!1?"border-amber-200 bg-amber-50 text-amber-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:t.isVisible===!1?"Hidden":"Visible"})}),e.jsx(m,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",title:t.isVisible===!1?"Unhide Lecture":"Hide Lecture",onClick:async()=>{try{const o=t.isVisible===!1;
1await ne.mutateAsync({id:t.id,data:{courseId:d,title:t.title,description:t.description||void 0,videoUrl:t.videoUrl||void 0,pdfUrl:t.pdfUrl||void 0,duration:t.duration?Number(t.duration):void 0,orderIndex:t.orderIndex??l,sectionId:t.sectionId??s.id,completionThreshold:t.completionThreshold??80,notes:t.notes||void 0,resources:t.resources||void 0,isVisible:o}}),r({title:o?"Lecture is now visible":"Lecture is now hidden"}),p.invalidateQueries({queryKey:fe({courseId:d})})}catch(o){r({title:Ds(o,"Failed to toggle visibility"),variant:"destructive"})}},children:t.isVisible===!1?e.jsx(_t,{className:"h-4 w-4 text-amber-500"}):e.jsx(Rt,{className:"h-4 w-4 text-slate-500"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>os(t),children:e.jsx(Yt,{className:"h-4 w-4"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-600 hover:bg-red-50 hover:text-red-700",onClick:()=>{O(t),he(!0)},children:e.jsx(Y,{className:"h-4 w-4"})})]})})]},t.id))})]})})})]},s.id)}),(()=>{const s=new Set((le||[]).map(t=>t.id)),a=(Ue||[]).filter(t=>!t.sectionId||!s.has(t.sectionId));return a.length===0?null:e.jsxs(Q,{className:"overflow-hidden rounded-lg border border-amber-200 bg-amber-50/40 shadow-sm",children:[e.jsx("div",{className:"flex flex-col gap-3 border-b border-amber-200 bg-amber-50 px-5 py-4 md:flex-row md:items-center md:justify-between",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-amber-200 bg-white text-amber-500",children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-black text-slate-900",children:"Unsectioned Lectures"}),e.jsxs(w,{variant:"outline",className:"h-6 rounded-md bg-white text-[10px] font-bold text-amber-600 border-amber-300",children:[a.length," lectures"]})]}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-amber-700",children:"These lectures have no section assigned. Move them into a section using the edit button."})]})]})}),e.jsx(Ye,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ye,{className:"min-w-[920px]",children:[e.jsx(we,{className:"bg-white",children:e.jsxs(F,{className:"hover:bg-white",children:[e.jsx(x,{className:"w-12 text-center text-[10px] font-black uppercase text-slate-400",children:"#"}),e.jsx(x,{className:"min-w-[240px] text-[10px] font-black uppercase text-slate-400",children:"Lecture"}),e.jsx(x,{className:"min-w-[280px] text-[10px] font-black uppercase text-slate-400",children:"Video Link"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"PDF"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Duration"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Status"}),e.jsx(x,{className:"w-28 text-right text-[10px] font-black uppercase text-slate-400",children:"Actions"})]})}),e.jsx(ke,{children:a.map((t,l)=>e.jsxs(F,{className:"h-14 hover:bg-amber-50/60",children:[e.jsx(m,{className:"text-center",children:e.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-50 text-xs font-black text-amber-600",children:l+1})}),e.jsx(m,{className:"max-w-[280px]",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-900",children:t.title}),t.description&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] font-medium text-slate-500",children:t.description})]})}),e.jsx(m,{className:"max-w-[320px]",children:t.videoUrl?e.jsxs("a",{href:t.videoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-2 rounded-md border border-red-100 bg-red-50 px-2.5 py-1.5 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.videoUrl}),e.jsx(ws,{className:"h-3 w-3 shrink-0"})]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold text-slate-400",children:[e.jsx(ks,{className:"h-3.5 w-3.5"})," No video link"]})}),e.jsx(m,{children:t.pdfUrl?e.jsxs("a",{href:t.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 text-xs font-bold text-slate-700 hover:bg-slate-50",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," PDF"]}):e.jsx("span",{className:"text-xs font-medium text-slate-400",children:"None"})}),e.jsx(m,{className:"text-xs font-semibold text-slate-600",children:t.duration?`${t.duration} min`:"Not set"}),e.jsx(m,{children:e.jsx(w,{variant:"outline",className:`h-6 rounded-md text-[10px] font-black ${t.isVisible===!1?"border-amber-200 bg-amber-50 text-amber-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:t.isVisible===!1?"Hidden":"Visible"})}),e.jsx(m,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Edit Lecture",onClick:()=>os(t),children:e.jsx(De,{className:"h-3.5 w-3.5"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",title:"Delete Lecture",onClick:()=>{O(t),he(!0)},children:e.jsx(Y,{className:"h-3.5 w-3.5"})})]})})]},t.id))})]})})})]})})()]})}),e.jsx(Ne,{value:"assignments",children:us?.length===0?e.jsxs(Q,{className:"border-dashed py-12 flex flex-col items-center justify-center text-center bg-transparent",children:[e.jsx(He,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-20"}),e.jsx("h3",{className:"text-lg font-medium",children:"No assignments created"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mb-6",children:"Add assignments to evaluate student learning progress."}),e.jsxs(n,{onClick:()=>I(!0),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Create First Assignment"]})]}):e.jsx("div",{className:"overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ye,{className:"min-w-[860px]",children:[e.jsx(we,{className:"bg-slate-50",children:e.jsxs(F,{className:"hover:bg-slate-50",children:[e.jsx(x,{className:"w-12 text-center text-[10px] font-black uppercase text-slate-400",children:"#"}),e.jsx(x,{className:"min-w-[220px] text-[10px] font-black uppercase text-slate-400",children:"Assignment"}),e.jsx(x,{className:"min-w-[280px] text-[10px] font-black uppercase text-slate-400",children:"Instructions"}),e.jsx(x,{className:"w-44 text-[10px] font-black uppercase text-slate-400",children:"Due Date"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Marks"}),e.jsx(x,{className:"w-24 text-[10px] font-black uppercase text-slate-400",children:"Sheet"}),e.jsx(x,{className:"w-24 text-right text-[10px] font-black uppercase text-slate-400",children:"Actions"})]})}),e.jsx(ke,{children:us?.map((s,a)=>{const t=s.dueDate&&new Date(s.dueDate)<new Date;return e.jsxs(F,{className:"h-12 hover:bg-slate-50/80",children:[e.jsx(m,{className:"text-center text-xs font-semibold text-slate-400",children:a+1}),e.jsx(m,{className:"max-w-[260px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:e.jsx(He,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"truncate text-sm font-bold text-slate-900",children:s.title})]})}),e.jsx(m,{className:"max-w-[320px] truncate text-xs text-slate-500",children:s.description||"No instructions added"}),e.jsx(m,{className:`text-xs font-semibold ${t?"text-rose-600":"text-slate-600"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ht,{className:"h-3.5 w-3.5 text-slate-400"}
1),s.dueDate?new Date(s.dueDate).toLocaleString():"No limit"]})}),e.jsx(m,{children:e.jsxs(w,{variant:"outline",className:"h-6 rounded-md bg-white text-[10px] font-bold",children:[s.totalMarks," Marks"]})}),e.jsx(m,{children:s.fileUrl?e.jsxs("a",{href:s.fileUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/20 bg-primary/5 px-2 text-xs font-bold text-primary hover:bg-primary/10",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," PDF"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"None"})}),e.jsx(m,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{Ke(s.id),A({title:s.title,description:s.description||"",dueDate:s.dueDate?new Date(s.dueDate).toISOString().slice(0,16):"",totalMarks:s.totalMarks,fileUrl:s.fileUrl||""}),I(!0)},children:e.jsx(De,{className:"h-4 w-4"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>st(s.id),children:e.jsx(Y,{className:"h-4 w-4"})})]})})]},s.id)})})]})})})}),e.jsx(Ne,{value:"quizzes",children:xs?.length===0?e.jsxs(Q,{className:"border-dashed py-12 flex flex-col items-center justify-center text-center bg-transparent",children:[e.jsx(Se,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-20"}),e.jsx("h3",{className:"text-lg font-medium",children:"No quizzes created"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mb-6",children:"Create interactive quizzes to test student knowledge."}),e.jsxs(n,{onClick:()=>E(!0),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Create First Quiz"]})]}):e.jsx("div",{className:"overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ye,{className:"min-w-[720px]",children:[e.jsx(we,{className:"bg-slate-50",children:e.jsxs(F,{className:"hover:bg-slate-50",children:[e.jsx(x,{className:"w-12 text-center text-[10px] font-black uppercase text-slate-400",children:"#"}),e.jsx(x,{className:"min-w-[280px] text-[10px] font-black uppercase text-slate-400",children:"Quiz"}),e.jsx(x,{className:"w-32 text-[10px] font-black uppercase text-slate-400",children:"Questions"}),e.jsx(x,{className:"w-32 text-[10px] font-black uppercase text-slate-400",children:"Time"}),e.jsx(x,{className:"w-28 text-[10px] font-black uppercase text-slate-400",children:"Marks"}),e.jsx(x,{className:"w-24 text-right text-[10px] font-black uppercase text-slate-400",children:"Actions"})]})}),e.jsx(ke,{children:xs?.map((s,a)=>e.jsxs(F,{className:"h-12 hover:bg-slate-50/80",children:[e.jsx(m,{className:"text-center text-xs font-semibold text-slate-400",children:a+1}),e.jsx(m,{className:"max-w-[340px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-indigo-50 text-indigo-600",children:e.jsx(Se,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"truncate text-sm font-bold text-slate-900",children:s.title})]})}),e.jsx(m,{children:e.jsxs(w,{variant:"outline",className:"h-6 rounded-md bg-white text-[10px] font-bold",children:[s.questions?.length||0," Questions"]})}),e.jsx(m,{className:"text-xs font-semibold text-slate-600",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Wt,{className:"h-3.5 w-3.5 text-slate-400"}),s.timeLimit??30," min"]})}),e.jsx(m,{children:e.jsxs(w,{variant:"secondary",className:"h-6 rounded-md text-[10px] font-bold",children:[s.totalMarks," Marks"]})}),e.jsx(m,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{hs(s.id),y({title:s.title,timeLimit:s.timeLimit??30,timerMode:s.timerMode||"overall",questions:(s.questions||[{question:"",options:["","","",""],correctOption:0,marks:1}]).map(t=>({question:t.question||"",options:t.options||["","","",""],correctOption:t.correctOption??0,marks:t.marks??1}))}),E(!0)},children:e.jsx(De,{className:"h-4 w-4"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>at(s.id),disabled:ms.isPending,children:e.jsx(Y,{className:"h-4 w-4"})})]})})]},s.id))})]})})})}),e.jsx(Ne,{value:"details",children:e.jsxs(Q,{className:"border border-slate-200 shadow-sm rounded-xl",children:[e.jsxs(Ut,{className:"bg-slate-50/50 border-b pb-4",children:[e.jsxs(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(Gt,{className:"h-5 w-5 text-indigo-500"}),"Course Settings & Syllabus Design"]}),e.jsx("p",{className:"text-slate-500 text-xs mt-1",children:"Configure your course details, duration metrics, pricing plans, and course outline"})]}),e.jsx(Ye,{className:"p-6",children:e.jsxs("form",{onSubmit:qs,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{htmlFor:"detail-title",className:"font-bold text-slate-700",children:["Course Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(h,{id:"detail-title",placeholder:"e.g. Masterclass in Advanced Frontend & React Architecture",value:Te,onChange:s=>Ge(s.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{htmlFor:"detail-category",className:"font-bold text-slate-700",children:["Category ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(B,{value:ze,onValueChange:Je,children:[e.jsx($,{id:"detail-category",children:e.jsx(_,{placeholder:"Select Category"})}),e.jsxs(R,{children:[e.jsx(v,{value:"MS Office",children:"MS Office"}),e.jsx(v,{value:"Graphics",children:"Graphic Design"}),e.jsx(v,{value:"Freelancing",children:"Freelancing Mastery"}),e.jsx(v,{value:"AI",children:"Artificial Intelligence (AI)"}),e.jsx(v,{value:"Web",children:"Web Development"}),e.jsx(v,{value:"Computer Basic",children:"Computer Basic"})]})]})]}),(()=>{const s=l=>{if(!l)return{number:"3",unit:"Months"};const o=l.match(/(\d+)\s*(month|year|Month|Year|mon|yr|Mon|Yr)s?/i);if(o){const C=o[1],ge=o[2].toLowerCase(),K=ge.startsWith("yr")||ge.startsWith("year")?"Years":"Months";return{number:C,unit:K}}const N=l.match(/(\d+)/);return N?{number:N[1],unit:"Months"}:{number:"3",unit:"Months"}},{number:a,unit:t}=s(qe);return e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsxs(c,{htmlFor:"detail-duration",className:"font-bold text-slate-700",children:["Syllabus Duration ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(B,{value:a,onValueChange:l=>Pe(`${l} ${t}`),children:[e.jsx($,{id:"detail-duration",className:"h-10 rounded-md border-slate-200 text-sm font-medium flex-1 bg-white",children:e.jsx(_,{placeholder:"No."})}),e.jsx(R,{className:"rounded-md border border-slate-200 shadow-lg bg-white",children:Array.from({length:24},(l,o)=>
1o+1).map(l=>e.jsx(v,{value:l.toString(),className:"text-sm font-medium",children:l},l))})]}),e.jsxs(B,{value:t,onValueChange:l=>Pe(`${a} ${l}`),children:[e.jsx($,{className:"h-10 rounded-md border-slate-200 text-sm font-medium w-24 bg-white",children:e.jsx(_,{placeholder:"Unit"})}),e.jsxs(R,{className:"rounded-md border border-slate-200 shadow-lg bg-white",children:[e.jsx(v,{value:"Months",className:"text-sm font-medium",children:"Months"}),e.jsx(v,{value:"Years",className:"text-sm font-medium",children:"Years"})]})]})]})]})})()]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"detail-fee",className:"font-bold text-slate-700",children:"Course Fee (PKR)"}),e.jsx(h,{id:"detail-fee",type:"number",placeholder:"e.g. 6000",value:Ze,onChange:s=>Me(s.target.value),disabled:ce})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"detail-minAttendance",className:"font-bold text-slate-700",children:"Min Attendance Requirement (%)"}),e.jsx(h,{id:"detail-minAttendance",type:"number",min:"0",max:"100",placeholder:"e.g. 75",value:is,onChange:s=>rs(s.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 items-center pt-2",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm font-semibold text-slate-700",children:[e.jsx("input",{type:"checkbox",checked:ce,onChange:s=>{es(s.target.checked),s.target.checked&&Me("0")},className:"rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),"This is a Free Course"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"detail-thumbnail",className:"font-bold text-slate-700",children:"Cover Thumbnail Image URL"}),e.jsx(h,{id:"detail-thumbnail",placeholder:"e.g. https://images.unsplash.com/photo-...",value:de,onChange:s=>ss(s.target.value)}),de&&e.jsx("div",{className:"mt-2 h-36 w-64 rounded-lg overflow-hidden border",children:e.jsx("img",{src:de,alt:"Preview",className:"w-full h-full object-cover"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{htmlFor:"detail-description",className:"font-bold text-slate-700",children:["Short Description / Objectives ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(S,{id:"detail-description",placeholder:"Describe the course summary, target audience, and key goals...",value:Qe,onChange:s=>Xe(s.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"detail-syllabus",className:"font-bold text-slate-700",children:"Detailed Syllabus & Learning Plan"}),e.jsx(S,{id:"detail-syllabus",placeholder:"Provide a comprehensive weekly or modular course outline here...",value:ts,onChange:s=>as(s.target.value),rows:6})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(n,{type:"submit",className:"bg-primary hover:bg-primary/95 text-white gap-2 font-semibold",children:[e.jsx(Ce,{className:"h-4 w-4"})," Save Course Settings"]})})]})})]})})]}),e.jsx(ee,{open:Ps,onOpenChange:P,children:e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(ae,{children:Oe?"Edit Section":"Add New Section"})}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"section-title",children:"Section Title"}),e.jsx(h,{id:"section-title",value:oe,onChange:s=>ue(s.target.value),placeholder:"e.g. Introduction to React"})]})}),e.jsxs(ie,{children:[e.jsx(n,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsx(n,{onClick:Ws,children:"Save Section"})]})]})}),e.jsx(ee,{open:Ms,onOpenChange:xe,children:e.jsxs(se,{className:"max-h-[90vh] max-w-4xl overflow-y-auto rounded-xl",children:[e.jsxs(te,{children:[e.jsx(ae,{className:"text-xl font-bold",children:"Add New Lecture"}),e.jsx(fs,{children:"Add video lectures with YouTube embed links and PDF notes for students."})]}),e.jsxs("form",{onSubmit:Gs,className:"pt-2",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[1.4fr_0.9fr]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{htmlFor:"title",className:"text-xs font-black uppercase text-slate-500",children:["Lecture Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(h,{id:"title",placeholder:"e.g. Introduction to MS Word",value:i.title,onChange:s=>g({...i,title:s.target.value}),className:"h-11 rounded-lg border-slate-200 font-semibold",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"videoUrl",className:"text-xs font-black uppercase text-slate-500",children:"YouTube Lecture Link"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-red-500"}),e.jsx(h,{id:"videoUrl",placeholder:"https://www.youtube.com/watch?v=...",value:i.videoUrl,onChange:s=>g({...i,videoUrl:s.target.value}),className:"h-11 rounded-lg border-slate-200 pl-10 font-medium"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"description",className:"text-xs font-black uppercase text-slate-500",children:"Short Description"}),e.jsx(S,{id:"description",placeholder:"Brief description of what students will learn...",value:i.description,onChange:s=>g({...i,description:s.target.value}),className:"min-h-[96px] rounded-lg border-slate-200"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"notes",className:"text-xs font-black uppercase text-slate-500",children:"Lecture Notes"}),e.jsx(S,{id:"notes",placeholder:"Write lesson summaries, key takeaways, or written material...",value:i.notes,onChange:s=>g({...i,notes:s.target.value}),className:"min-h-[132px] rounded-lg border-slate-200"})]})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-slate-200 bg-slate-50/70 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"pdfUrl",className:"text-xs font-black uppercase text-slate-500",children:"PDF Notes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{id:"pdfUrl",placeholder:"https://example.com/notes.pdf",value:i.pdfUrl,onChange:s=>g({...i,pdfUrl:s.target.value}),className:"h-10 flex-1 rounded-lg border-slate-200 bg-white text-xs"}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(h,{type:"file",accept:".pdf",onChange:ns,className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",disabled:V}),e.jsxs(n,{type:"button",variant:"outline",className:"h-10 rounded-lg bg-white text-xs font-bold",disabled:V,children:[V?e.jsx(T,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(q,{className:"h-3.5 w-3.5"}),"Upload"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"duration",className:"text-xs font-black uppercase text-slate-500",children:"Minutes"}),e.jsx(h,{id:"duration",type:"number",placeholder:"45",value:i.duration,onChange:s=>g({...i,duration:s.target.value}),className:"h-10 rounded-lg border-slate-200 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"completionThreshold",className:"text-xs font-black uppercase text-slate-500",children:"Complete %"}),e.jsx(h,{id:"completionThreshold",type:"number",min:"1",max:"100",placeholder:"80",value:i.completionThreshold,onChange:s=>g({...i,completionThreshold:s.target.value}),className:"h-10 rounded-lg border-slate-200 bg-white"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"resources",className:"text-xs font-black uppercase text-slate-500",children:"Resources"}),e.jsx(S,{id:"resources",placeholder:"Add useful links or references...",value:i.resources,onChange:s=>g({...i,resources:s.target.value}),className:"min-h-[104px] rounded-lg border-slate-200 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"visibility",className:"text-xs font-black uppercase text-slate-500",children:"Visibility"}),e.jsxs(B,{value:i.isVisible?"true":"false",onValueChange:s=>g({...i,isVisible:s==="true"}),children:[e.jsx($,{id:"visibility",className:"h-10 rounded-lg border-slate-200 bg-white",children:e.jsx(_,{placeholder:"Select visibility status"})}),e.jsxs(R,{children:[e.jsx(v,{value:"true",children:"Visible to Students"}),e.jsx(v,{value:"false",children:"Hidden (Draft)"})]})]})]})]})]}),e.jsxs(ie,{className:"mt-6 border-t pt-4",children:[e.jsxs(n,{type:"button",variant:"outline",className:"rounded-lg",onClick:()=>{xe(!1),W()},children:[e.jsx(Cs,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(n,{type:"submit",className:"rounded-lg bg-primary text-white",disabled:Fe.isPending,children:[Fe.isPending?e.jsx(T,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ce,{className:"h-4 w-4 mr-2"}),"Add Lecture"]})]})]})]})}),e.jsx(ee,{open:Os,onOpenChange:me,children:e.jsxs(se,{className:"max-h-[90vh] max-w-4xl overflow-y-auto rounded-xl",children:[e.jsxs(te,{children:[e.jsx(ae,{className:"text-xl font-bold",children:"Edit Lecture"}),e.jsx(fs,{children:"Update lecture details, video links, and PDF notes."})]}),e.jsxs("form",{onSubmit:Xs,className:"pt-2",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[1.4fr_0.9fr]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{htmlFor:"edit-title",className:"text-xs font-black uppercase text-slate-500",children:["Lecture Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(h,{id:"edit-title",placeholder:"e.g. Introduction to MS Word",value:i.title,onChange:s=>g({...i,title:s.target.value}),className:"h-11 rounded-lg border-slate-200 font-semibold",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-videoUrl",className:"text-xs font-black uppercase text-slate-500",children:"YouTube Lecture Link"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-red-500"}),e.jsx(h,{id:"edit-videoUrl",placeholder:"https://www.youtube.com/watch?v=...",value:i.videoUrl,onChange:s=>g({...i,videoUrl:s.target.value}),className:"h-11 rounded-lg border-slate-200 pl-10 font-medium"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-description",className:"text-xs font-black uppercase text-slate-500",children:"Short Description"}),e.jsx(S,{id:"edit-description",placeholder:"Brief description of what students will learn...",value:i.description,onChange:s=>g({...i,description:s.target.value}),className:"min-h-[96px] rounded-lg border-slate-200"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-notes",className:"text-xs font-black uppercase text-slate-500",children:"Lecture Notes"}),e.jsx(S,{id:"edit-notes",placeholder:"Write lesson summaries, key takeaways, or written material...",value:i.notes,onChange:s=>g({...i,notes:s.target.value}),className:"min-h-[132px] rounded-lg border-slate-200"})]})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-slate-200 bg-slate-50/70 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-pdfUrl",className:"text-xs font-black uppercase text-slate-500",children:"PDF Notes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{id:"edit-pdfUrl",placeholder:"https://example.com/notes.pdf",value:i.pdfUrl,onChange:s=>g({...i,pdfUrl:s.target.value}),className:"h-10 flex-1 rounded-lg border-slate-200 bg-white text-xs"}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(h,{type:"file",accept:".pdf",onChange:ns,className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",disabled:V}),e.jsxs(n,{type:"button",variant:"outline",className:"h-10 rounded-lg bg-white text-xs font-bold",disabled:V,children:[V?e.jsx(T,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(q,{className:"h-3.5 w-3.5"}),"Upload"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-duration",className:"text-xs font-black uppercase text-slate-500",children:"Minutes"}),e.jsx(h,{id:"edit-duration",type:"number",placeholder:"45",value:i.duration,onChange:s=>g({...i,duration:s.target.value}),className:"h-10 rounded-lg border-slate-200 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-completionThreshold",className:"text-xs font-black uppercase text-slate-500",children:"Complete %"}),e.jsx(h,{id:"edit-completionThreshold",type:"number",min:"1",max:"100",placeholder:"80",value:i.completionThreshold,onChange:s=>g({...i,completionThreshold:s.target.value}),className:"h-10 rounded-lg border-slate-200 bg-white"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-resources",className:"text-xs font-black uppercase text-slate-500",children:"Resources"}),e.jsx(S,{id:"edit-resources",placeholder:"Add useful links or references...",value:i.resources,onChange:s=>g({...i,resources:s.target.value}),className:"min-h-[104px] rounded-lg border-slate-200 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"edit-visibility",className:"text-xs font-black uppercase text-slate-500",children:"Visibility"}),e.jsxs(B,{value:i.isVisible?"true":"false",onValueChange:s=>g({...i,isVisible:s==="true"}),children:[e.jsx($,{id:"edit-visibility",className:"h-10 rounded-lg border-slate-200 bg-white",children:e.jsx(_,{placeholder:"Select visibility status"})}),e.jsxs(R,{children:[e.jsx(v,{value:"true",children:"Visible to Students"}),e.jsx(v,{value:"false",children:"Hidden (Draft)"})]})]})]})]})]}),e.jsxs(ie,{className:"mt-6 border-t pt-4",children:[e.jsxs(n,{type:"button",variant:"outline",className:"rounded-lg",onClick:()=>{me(!1),O(null),W()},children:[e.jsx(Cs,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(n,{type:"submit",className:"rounded-lg bg-primary text-white",disabled:ne.isPending,children:[ne.isPending?e.jsx(T,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ce,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})}),e.jsx(Tt,{open:Vs,onOpenChange:he,children:e.jsxs(Qt,{className:"rounded-[24px]",children:[e.jsxs(zt,{children:[e.jsx(qt,{children:"Delete Lecture?"}),e.jsxs(Pt,{children:['This will permanently delete "',M?.title,'". This action cannot be undone.']})]}),e.jsxs(Mt,{children:[e.jsx(Ot,{children:"Cancel"}),e.jsxs(Vt,{onClick:Zs,className:"bg-red-600 hover:bg-red-700",children:[We.isPending?e.jsx(T,{className:"h-4 w-4 animate-spin mr-2"}):null,"Delete"]})]})]})}),e.jsx(ee,{open:Rs,onOpenChange:I,children:e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(ae,{children:Ee?"Edit Assignment":"New Assignment"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Assignment Title *"}),e.jsx(h,{value:b.title,onChange:s=>A({...b,title:s.target.value}),placeholder:"e.g. Final Project: Build a React App"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Description"}),e.jsx(S,{value:b.description,onChange:s=>A({...b,description:s.target.value}),placeholder:"Instructions for students..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Assignment PDF Sheet"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{placeholder:"Upload a PDF from your computer",value:b.fileUrl,readOnly:!0,className:"flex-1 bg-slate-50"}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(h,{type:"file",accept:".pdf",onChange:Es,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:pe}),e.jsxs(n,{type:"button",variant:"outline",disabled:pe,children:[pe?e.jsx(T,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(q,{className:"h-4 w-4 mr-2"}),"Upload PDF"]})]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["PDF only, max ",Ss,"MB. Compress larger files before uploading."]}),b.fileUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("a",{href:b.fileUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," Open uploaded PDF"]}),e.jsx("iframe",{src:b.fileUrl,className:"w-full h-40 rounded-lg border border-slate-200",title:"Assignment PDF Preview"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Due Date"}),e.jsx(h,{type:"datetime-local",value:b.dueDate,onChange:s=>A({...b,dueDate:s.targe
1t.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Total Marks"}),e.jsx(h,{type:"number",value:b.totalMarks,onChange:s=>A({...b,totalMarks:Number(s.target.value)})})]})]})]}),e.jsxs(ie,{children:[e.jsx(n,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(n,{onClick:et,disabled:pe,children:"Save Assignment"})]})]})}),e.jsx(ee,{open:Hs,onOpenChange:s=>{E(s),s||_e()},children:e.jsxs(se,{className:"max-w-4xl h-[90vh] p-0 flex flex-col rounded-3xl overflow-hidden border-none shadow-2xl bg-white",children:[e.jsx(te,{className:"p-6 border-b border-slate-100 flex-shrink-0 bg-slate-50/50",children:e.jsxs(ae,{className:"text-xl font-black text-slate-900 flex items-center gap-2",children:[e.jsx(Se,{className:"h-5 w-5 text-indigo-600"}),G?"Update Quiz":"Create New Quiz"]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(c,{className:"text-xs font-bold text-slate-600",children:["Quiz Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(h,{value:j.title,onChange:s=>y({...j,title:s.target.value}),placeholder:"e.g. Midterm Assessment",className:"rounded-xl border-slate-200 font-medium"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xs font-bold text-slate-600",children:"Timer Mode"}),e.jsxs(B,{value:j.timerMode||"overall",onValueChange:s=>y({...j,timerMode:s}),children:[e.jsx($,{className:"rounded-xl border-slate-200 font-bold bg-white text-xs h-10",children:e.jsx(_,{placeholder:"Select timer mode"})}),e.jsxs(R,{children:[e.jsx(v,{value:"overall",children:"Overall Quiz Timer"}),e.jsx(v,{value:"per_question",children:"Per-Question Timer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xs font-bold text-slate-600",children:j.timerMode==="per_question"?"Per-Question Time (min)":"Total Time Limit (min)"}),e.jsx(h,{type:"number",min:"1",value:j.timeLimit,onChange:s=>y({...j,timeLimit:Number(s.target.value)}),className:"rounded-xl border-slate-200 font-medium"})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex justify-between items-center border-b border-slate-100 pb-3",children:[e.jsx(c,{className:"text-base font-black text-slate-900",children:"Questions"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=["Question","Option A","Option B","Option C","Option D","Correct Option (A/B/C/D)","Marks"],a=["What is the capital of France?","London","Paris","Berlin","Rome","B","1"],t="data:text/csv;charset=utf-8,"+[s.join(","),a.join(",")].join(` 2`),l=encodeURI(t),o=document.createElement("a");o.setAttribute("href",l),o.setAttribute("download","quiz_mcq_template.csv"),document.body.appendChild(o),o.click(),document.body.removeChild(o)},className:"h-8 rounded-xl text-xs font-bold border-slate-200",children:[e.jsx(Xt,{className:"h-3.5 w-3.5 mr-1.5 text-slate-500"})," Template"]}),e.jsxs(n,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=document.createElement("input");s.type="file",s.accept=".csv",s.onchange=a=>{const t=a.target.files?.[0];if(!t)return;const l=new FileReader;l.onload=o=>{try{const C=o.target.result.split(` 3`).filter(L=>L.trim()),ge=C[0].toLowerCase().includes("question")?1:0,K=[];for(let L=ge;L<C.length;L++){const k=[];let je="",Re=!1;const gs=C[L];for(let X=0;X<gs.length;X++){const J=gs[X];J==='"'?Re=!Re:J===","&&!Re?(k.push(je.trim()),je=""):je+=J}if(k.push(je.trim()),k.length>=6){const X=k[0].replace(/^"|"$/g,""),J=[k[1].replace(/^"|"$/g,""),k[2].replace(/^"|"$/g,""),k[3].replace(/^"|"$/g,""),k[4].replace(/^"|"$/g,"")];let Z=0;const U=k[5].trim().toUpperCase();U==="A"||U==="0"?Z=0:U==="B"||U==="1"?Z=1:U==="C"||U==="2"?Z=2:(U==="D"||U==="3")&&(Z=3);const lt=Number(k[6])||1;K.push({question:X,options:J,correctOption:Z,marks:lt})}}if(K.length>0)y(L=>({...L,questions:[...L.questions,...K]})),r({title:`Successfully imported ${K.length} questions! ð`});else throw new Error("No valid question rows found in CSV")}catch(N){r({title:"CSV Parse Failed",description:N.message,variant:"destructive"})}},l.readAsText(t)},s.click()},className:"h-8 rounded-xl text-xs font-bold border-slate-200",children:[e.jsx(Jt,{className:"h-3.5 w-3.5 mr-1.5 text-indigo-600"})," Import CSV"]}),e.jsxs(n,{type:"button",variant:"outline",size:"sm",onClick:()=>{y(s=>({...s,questions:[...s.questions,{question:"",options:["","","",""],correctOption:0,marks:1}]}))},className:"h-8 rounded-xl text-xs font-bold border-slate-200",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"})," Add Question"]})]})]}),j.questions.map((s,a)=>e.jsxs(Q,{className:"p-5 border border-slate-200/80 rounded-2xl bg-slate-50/40 space-y-4 shadow-sm hover:border-slate-300 transition-all",children:[e.jsxs("div",{className:"flex justify-between items-center pb-1",children:[e.jsxs("span",{className:"font-black text-sm text-slate-700",children:["Question ",a+1]}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-rose-500 hover:text-rose-700 hover:bg-rose-50 rounded-lg",onClick:()=>{y(t=>({...t,questions:t.questions.filter((l,o)=>o!==a)}))},children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{placeholder:"Enter question text...",value:s.question,className:"bg-white rounded-xl border-slate-200 font-medium",onChange:t=>{const l=[...j.questions];l[a].question=t.target.value,y({...j,questions:l})}}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:s.options.map((t,l)=>e.jsxs("label",{className:`flex items-center gap-3 p-2.5 px-3.5 bg-white border rounded-xl cursor-pointer transition-all ${s.correctOption===l?"border-indigo-500 ring-2 ring-indigo-500/15 shadow-sm":"border-slate-200 hover:border-slate-300"}`,children:[e.jsx("input",{type:"radio",name:`correct-${a}`,checked:s.correctOption===l,className:"h-4 w-4 text-indigo-600 accent-indigo-600 focus:ring-indigo-500 cursor-pointer",onChange:()=>{const o=[...j.questions];o[a].correctOption=l,y({...j,questions:o})}}),e.jsx(h,{placeholder:`Option ${String.fromCharCode(65+l)}`,value:t,className:"border-none shadow-none focus-visible:ring-0 p-0 h-auto text-sm font-medium bg-transparent",onChange:o=>{const N=[...j.questions];N[a].options[l]=o.target.value,y({...j,questions:N})}})]},l))})]})]},a))]})]}),e.jsxs(ie,{className:"p-4 px-6 border-t border-slate-100 flex-shrink-0 bg-slate-50/80 flex justify-end gap-3",children:[e.jsx(n,{variant:"outline",className:"rounded-xl px-5 font-bold",onClick:()=>E(!1),children:"Cancel"}),e.jsxs(n,{onClick:tt,disabled:Be.isPending||$e.isPending,className:"rounded-xl px-6 font-black shadow-lg shadow-indigo-500/20 bg-indigo-600 hover:bg-indigo-700",children:[Be.isPending||$e.isPending?e.jsx(T,{className:"h-4 w-4 animate-spin mr-2"}):null,G?"Update Quiz":"Create Quiz"]})]})]})})]})}export{ca 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.