1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ai-prediction-dashboard-CBWsHxpS.js","assets/dnd-CNQ8BvKU.js","assets/index-DpuP5qk5.js","assets/xyflow-C0vxhnBz.js","assets/datefns-D4dTs_7e.js","assets/index-CHd5TuPh.css","assets/AreaChart-BbZQLzOS.js","assets/org-selector-mADo5AxL.js","assets/trending-up-BJDOLQkF.js"])))=>i.map(i=>d[i]); 2import{c as ve,g as y,A as N,H as Qs,I as Ws,J as Ks,K as Xs,N as Be,O as et,u as ks,x as Le,j as D,C as F,m as B,B as g,t as C,Q as oe,R as Cs,V as Ss,W as be,P as zs,k as Fe,l as as,F as st,Y as tt,o as Ge,Z as Es,_ as at,$ as rt,D as nt,a0 as it,a1 as lt,a2 as ot,a3 as Ne,a4 as ct,h as xs,a5 as dt,G as rs,a6 as ye,f as J,i as H,a7 as mt,a8 as ut,a9 as xt,aa as ns,X as Ts,ab as $s,ac as As,E as ht,ad as pt,ae as gt,af as ft,ag as jt,ah as bt}from"./index-DpuP5qk5.js";import{a as d,j as e}from"./dnd-CNQ8BvKU.js";import{B as V,a as Nt,O as yt,A as vt,b as wt}from"./org-selector-mADo5AxL.js";import"./xyflow-C0vxhnBz.js";import"./datefns-D4dTs_7e.js";/** 3 * @license lucide-react v0.487.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const kt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ct=ve("info",kt);/** 8 * @license lucide-react v0.487.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const St=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],zt=ve("plug",St);/** 13 * @license lucide-react v0.487.0 - ISC 14 * 15 * This source code is licensed under the ISC license. 16 * See the LICENSE file in the root directory of this source tree. 17 */const Tt=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],$t=ve("quote",Tt);/** 18 * @license lucide-react v0.487.0 - ISC 19 * 20 * This source code is licensed under the ISC license. 21 * See the LICENSE file in the root directory of this source tree. 22 */const At=[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]],hs=ve("thumbs-down",At);/** 23 * @license lucide-react v0.487.0 - ISC 24 * 25 * This source code is licensed under the ISC license. 26 * See the LICENSE file in the root directory of this source tree. 27 */const Et=[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]],ps=ve("thumbs-up",Et);/** 28 * @license lucide-react v0.487.0 - ISC 29 * 30 * This source code is licensed under the ISC license. 31 * See the LICENSE file in the root directory of this source tree. 32 */const _t=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Dt=ve("unplug",_t),Pt=["General",...Object.keys(Es),"Personal"],It=[{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}];function ie(r){switch(r){case"high":return"bg-green-500";case"medium":return"bg-amber-500";case"low":return"bg-red-500";case"learned":return"bg-violet-500";default:return"bg-muted-foreground"}}function te(r){return r==="low"?"border-red-300 dark:border-red-500/50":r==="learned"?"border-violet-300 dark:border-violet-500/50":"border-border"}function Lt(r){const S=Es[r];return S?S.accentColor:at.accentColor}async function M(r){const S=await r.text();try{return JSON.parse(S)}catch{throw new Error(r.ok?`Invalid response from server: ${S.substring(0,200)}`:`Server error (${r.status}): ${S.substring(0,200)}`)}}function Ft({isOpen:r,onClose:S,onAssignmentsImported:we}
32){const[v,f]=d.useState("scan"),[ae,E]=d.useState(null),[w,q]=d.useState([]),[ce,de]=d.useState(!1),[Re,ke]=d.useState(!1),[re,ne]=d.useState([]),[Ce,me]=d.useState(0),[Se,Me]=d.useState(0),[Oe,Y]=d.useState(1),[ue,ze]=d.useState(!1),[xe,is]=d.useState(20),[I,ls]=d.useState(!1),[Te,$e]=d.useState(!1),[Ae,Ee]=d.useState([]),[os,_e]=d.useState(!1),[P,Z]=d.useState([]),[gs,De]=d.useState(!1),[Ue,Je]=d.useState(!1),[L,He]=d.useState([]),[Q,Ve]=d.useState([]),[qe,O]=d.useState(new Set);d.useEffect(()=>{r&&(f("scan"),E(null),$e(!1),q([]),ne([]),Ee([]),Z([]),me(0),O(new Set),We(),Ye(),Ze(),cs())},[r]),d.useEffect(()=>{r&&v==="scan"&&w.length===0&&P.length===0&&W()},[r,P]);const Ye=async()=>{var o;const s=y();if(s){De(!0);try{const t=await fetch(`${N}/google/gmail/auto-classified`,{headers:{Authorization:`Bearer ${s}`}}),l=await M(t);l.success&&((o=l.emails)==null?void 0:o.length)>0&&Z(l.emails.map(c=>({...c,reviewAction:c.classificationType==="other"||c.classificationType==="general"?"dismiss":"confirm"})))}catch{}finally{De(!1)}}},Ze=async()=>{const s=y();if(s)try{const o=await fetch(`${N}/classes`,{headers:{Authorization:`Bearer ${s}`}}),t=await M(o);t.success&&t.classes&&He(t.classes.map(l=>({id:l.id,name:l.name,color:l.color})))}catch{}},cs=async()=>{const s=y();if(s)try{const o=await fetch(`${N}/teachers`,{headers:{Authorization:`Bearer ${s}`}}),t=await M(o);t.success&&t.teachers&&Ve(t.teachers.map(l=>({id:l.id,name:l.name,email:l.email})))}catch{}},Qe=async()=>{const s=y();if(!(!s||P.length===0)){Je(!0);try{const o=P.map(c=>({emailId:c.emailId,action:c.reviewAction,correctedType:c.reviewAction==="correct"?c.correctedType:void 0})),t=await fetch(`${N}/google/gmail/review-auto-classified`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({reviews:o})});(await M(t)).success&&(Z([]),W())}catch(o){E(o.message||"Failed to submit reviews")}finally{Je(!1)}}},We=async()=>{var o;const s=y();try{const t=await fetch(`${N}/google/gmail/examples`,{headers:{Authorization:`Bearer ${s}`}}),l=await M(t);l.success&&Me(((o=l.examples)==null?void 0:o.length)||0)}catch{}},ds=async s=>{const o=y();ze(!0);try{const t=s.filter(u=>!u.alreadyImported).map(u=>({id:u.emailId,subject:u.subject,from:u.from,snippet:u.snippet}));if(t.length===0)return;const l=await fetch(`${N}/google/gmail/classify`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({emails:t})}),c=await M(l);c.success&&c.classifications&&q(u=>{const b=new Map(c.classifications.map(x=>[x.emailId,{score:x.score,type:x.type,reason:x.reason}]));return u.map(x=>{const j=b.get(x.emailId);return j?{...x,aiScore:j.score,aiType:j.type,aiReason:j.reason}:x}).sort((x,j)=>x.alreadyImported!==j.alreadyImported?x.alreadyImported?1:-1:(j.aiScore??50)-(x.aiScore??50))})}catch(t){console.error("Classification failed:",t)}finally{ze(!1)}},W=async()=>{de(!0),E(null);const s=y();try{const o=await fetch(`${N}/google/gmail/scan?days=${Oe}`,{headers:{Authorization:`Bearer ${s}`}}),t=await M(o);if(t.success){const l=(t.emails||[]).map(c=>({emailId:c.id,subject:c.subject,from:c.from,snippet:c.snippet,date:c.date,attachmentCount:c.attachmentCount||0,alreadyImported:c.alreadyImported||!1,label:c.previousLabel||"unlabeled",reason:c.previousReason||""}));q(l),ds(l)}else{const l=t.error||"Failed to scan Gmail";l.toLowerCase().includes("no google credentials")?$e(!0):E(l)}}catch(o){const t=o.message||"";t.toLowerCase().includes("no google credentials")?$e(!0):E(t)}finally{de(!1)}},he=(s,o)=>
32{if(o==="unlabeled")return;const t=y();fetch(`${N}/google/gmail/label`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({labels:[{emailId:s.emailId,subject:s.subject,from:s.from,snippet:s.snippet,isAssignment:o==="assignment",reason:s.reason||void 0}]})}).catch(l=>console.error("Auto-save label failed:",l))},pe=(s,o)=>{q(t=>t.map(l=>{if(l.emailId!==s)return l;const c=l.label===o?"unlabeled":o,u={...l,label:c};return c==="grade_return"?he(u,"not_assignment"):he(u,c),u}))},Pe=(s,o)=>{q(t=>t.map(l=>l.emailId===s?{...l,reason:o}:l))},Ke=s=>{s.label!=="unlabeled"&&s.label!=="grade_return"&&he(s,s.label)},ge=async()=>{const s=w.filter(c=>c.label!=="unlabeled"),o=w.filter(c=>c.label==="assignment"),t=w.filter(c=>c.label==="grade_return");if(o.length===0&&t.length===0){E("Mark at least one email as an assignment or grade return to continue.");return}ke(!0),E(null);const l=y();if(s.length>0)try{const c=s.map(u=>({emailId:u.emailId,subject:u.subject,from:u.from,snippet:u.snippet,isAssignment:u.label==="assignment",reason:u.reason||void 0}));await fetch(`${N}/google/gmail/label`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({labels:c})})}catch(c){console.error("Failed to save labels:",c)}f("extracting"),ke(!1);try{if(o.length>0){const c=o.map(p=>p.emailId),u=await fetch(`${N}/google/gmail/extract`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({emailIds:c})}),b=await M(u);if(b.success&&b.extractions){const p=b.extractions.map(x=>({emailId:x.emailId,gmailImportId:x.gmailImportId,subject:x.subject,from:x.from,date:x.date,body:x.body||"",attachments:x.attachments||[],summary:x.summary,expanded:!0,showBody:!1,assignments:(x.assignments||[]).map(j=>({included:!0,title:j.title,class:j.class||"General",teacher:j.teacher||"",dueDate:j.dueDate||"",description:j.description||"",priority:j.priority||"medium",estimatedTime:j.estimatedTime||30,confidence:j.confidence||{},sources:j.sources||{},subtasks:(j.subtasks||[]).map(R=>({title:R.title,explanation:R.explanation||"",included:!0})),senderPattern:j.senderPattern}))}));ne(p)}else{E(b.error||"Extraction failed"),f("label");return}}if(t.length>0){_e(!0);try{const c=t.map(p=>p.emailId),u=await fetch(`${N}/google/gmail/detect-grades`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({emailIds:c})}),b=await M(u);if(b.success&&b.results){const p=b.results.map(x=>({emailId:x.emailId,gmailImportId:x.gmailImportId||"",subject:x.subject||"",from:x.from||"",date:x.date||"",body:x.body||"",grade:x.grade||null,matchedAssignmentId:x.matchedAssignmentId||void 0,expanded:!0}));Ee(p)}}catch(c){console.error("Grade detection failed:",c)}finally{_e(!1)}}f("review")}catch(c){E(c.message),f("label")}},$=(s,o,t,l)=>{ne(c=>{const u=[...c],b={...u[s]},p=[...b.assignments];return p[o]={...p[o],[t]:l},b.assignments=p,u[s]=b,u})},fe=s=>{ne(o=>{const t=[...o];return t[s]={...t[s],expanded:!t[s].expanded},t})},ms=s=>{ne(o=>{const t=[...o];return t[s]={...t[s],showBody:!t[s].showBody},t})},Xe=async()=>{var t;E(null);const s=y(),o=re.map(l=>{const c=l.assignments.filter(u=>u.included);return{gmailImportId:l.gmailImportId,emailId:l.emailId,approved:c.length>0,assignments:c.map(u=>({title:u.title,class:u.class,teacher:u.teacher,dueDate:u.dueDate||null,description:u.description,priority:u.priority,estimatedTime:u.estimatedTime,confidence:u.confidence,subtasks:u.subtasks.filter(b=>b.included).map(b=>({title:b.title,explanation:b.explanation}))}))}});try{const l=await fetch(`${N}/google/gmail/approve`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({decisions:o})}),c=await M(l);if(c.success){const u=((t=c.assignments)==null?void 0:t.length)||0;if(me(u),c.assignments&&c.assignments.length>0){const b=c.assignments.map(p=>({id:p.id,title:p.title,class:p.class,classColor:p.classColor||Lt(p.class),dueDate:p.dueDate?new Date(p.dueDate):new Date,priority:p.priority||"medium",estimatedTime:p.estimatedTime||30,c
32ompleted:!1,subtasks:(p.subtasks||[]).map(x=>({id:x.id,text:x.title||x.text,completed:!1,explanation:x.explanation||""})),attachments:0,aiSuggestions:[],description:p.description||void 0,sourceEmail:p.sourceEmail||void 0}));we(b)}f("done")}else E(c.error||"Approval failed")}catch(l){E(l.message)}},K=w.filter(s=>!s.alreadyImported&&s.label==="unlabeled"&&s.aiScore!=null&&s.aiScore<xe),es=I?w:w.filter(s=>!K.includes(s));w.filter(s=>s.label!=="unlabeled").length;const Ie=w.filter(s=>s.label==="assignment").length,X=w.filter(s=>s.label==="grade_return").length,ss=w.filter(s=>s.label==="not_assignment").length,ee=re.reduce((s,o)=>s+o.assignments.filter(t=>t.included).length,0),U=re.some(s=>s.assignments.some(o=>o.included&&!o.dueDate));return e.jsx(Qs,{open:r,onOpenChange:S,children:e.jsxs(Ws,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ks,{children:[e.jsxs(Xs,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"size-5 text-primary"}),"Gmail Assignment Import"]}),e.jsxs(et,{children:[v==="scan"&&"Scanning your inbox for recent emails...",v==="label"&&"Tell me which emails contain assignments. This trains the system on your preferences.",v==="extracting"&&"Analyzing emails...",v==="review"&&"Review and edit extracted assignments before importing.",v==="done"&&"Import complete!"]})]}),ae&&e.jsxs("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(ks,{className:"size-4 shrink-0"}),ae]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 py-2",children:[v==="scan"&&P.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Le,{className:"size-4 text-primary"}),e.jsxs("h3",{className:"text-sm font-semibold",children:[P.length," email",P.length!==1?"s":""," detected automatically"]}),e.jsx(D,{variant:"secondary",className:"text-[10px]",children:"Push"})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1",children:"These arrived while you were away. Confirm or dismiss each one to help SmartAleck learn your preferences."}),P.map((s,o)=>e.jsx(F,{className:`transition-colors ${s.reviewAction==="confirm"?"border-green-300 dark:border-green-700":s.reviewAction==="dismiss"?"border-muted opacity-60":"border-amber-300 dark:border-amber-700"}`,children:e.jsxs(B,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.subject||"(no subject)"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.from})]}),e.jsxs(D,{variant:["assignment","test","quiz"].includes(s.classificationType)?"default":["grade","grade_return","test_prep","quiz_prep","study_guide"].includes(s.classificationType)?"secondary":"outline",className:"text-[10px] shrink-0",children:[{assignment:"Assignment",test:"Test",test_prep:"Test Prep",quiz:"Quiz",quiz_prep:"Quiz Prep",grade:"Grade",grade_return:"Grade",study_guide:"Study Guide",general:"General"}[s.classificationType]||"Other",` ${s.classificationScore}%`]})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.snippet}),s.classificationReason&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:s.classificationReason}),e.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[e.jsxs(g,{size:"sm",variant:s.reviewAction==="confirm"?"default":"outline",className:"h-7 text-xs gap-1",onClick:()=>Z(t=>t.map((l,c)=>c===o?{...l,reviewAction:"confirm"}:l)),children:[e.jsx(ps,{className:"size-3"}),"Confirm"]}),e.jsxs(g,{size:"sm",variant:s.reviewAction==="dismiss"?"destructive":"outline",className:"h-7 text-xs gap-1",onClick:()=>Z(t=>t.map((l,c)=>c===o?{...l,reviewAction:"dismiss"}:l)),children:[e.jsx(hs,{className:"size-3"}),"Not relevant"]})]})]})},s.emailId)),e.jsx("div",{className:"flex gap-2 pt-2",children:e.jsxs(g,{onClick:Qe,disabled:Ue,className:"flex-1",children:[Ue?e.jsx(C,{className:"size-4 animate-spin mr-2"}):e.jsx(oe,{className:"size-4 mr-2"}),"Submit Reviews (",P.filter(s=>s.reviewAction==="confirm").length," confirmed,"," ",P.filter(s=>
32s.reviewAction==="dismiss").length," dismissed)"]})})]}),v==="scan"&&P.length===0&&e.jsx("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:Te?e.jsxs(e.Fragment,{children:[e.jsx(Cs,{className:"size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Google account not connected"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-xs",children:"Connect your Google account in Settings to scan Gmail for assignments."}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{S(),window.location.href="/settings?tab=integrations"},children:[e.jsx(Cs,{className:"size-4 mr-2"}),"Go to Settings"]})]}):ce?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Scanning your inbox..."})]}):w.length===0?e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No emails found in the last 24 hours."}),e.jsxs(g,{variant:"outline",size:"sm",onClick:W,children:[e.jsx(Ss,{className:"size-4 mr-2"}),"Scan Again"]})]}):e.jsx(Bt,{count:w.length,exampleCount:Se,onContinue:()=>f("label"),onRescan:W})}),v==="label"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-3 flex items-start gap-3",children:[e.jsx(V,{className:"size-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-foreground flex-1",children:[e.jsx("p",{className:"font-medium",children:"Train the system on what your assignments look like"}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:["Mark emails as assignments (",e.jsx(ps,{className:"size-3 inline"}),") or not (",e.jsx(hs,{className:"size-3 inline"}),").",Se>0&&` You have ${Se} past examples â the system is already learning your preferences.`," ","The more you label, the smarter it gets."]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Show emails from last"}),e.jsxs("select",{value:Oe,onChange:s=>{Y(parseInt(s.target.value))},className:"text-xs bg-background border border-border rounded px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[e.jsx("option",{value:1,children:"1 day"}),e.jsx("option",{value:3,children:"3 days"}),e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:14,children:"14 days"}),e.jsx("option",{value:30,children:"30 days"})]}),e.jsxs(g,{variant:"ghost",size:"sm",onClick:W,disabled:ce,className:"text-xs h-7",children:[ce?e.jsx(C,{className:"size-3 animate-spin mr-1"}):e.jsx(Ss,{className:"size-3 mr-1"}),"Rescan"]})]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[w.length," email",w.length!==1?"s":"",ue&&e.jsxs("span",{className:"flex items-center gap-1 text-primary",children:[e.jsx(C,{className:"size-3 animate-spin"}),"Scoring..."]})]})]}),es.map(s=>e.jsx("div",{className:`p-3 rounded-lg border transition-colors ${s.alreadyImported?"border-border bg-muted/30 opacity-50":s.label==="assignment"?"border-green-400 dark:border-green-500/50 bg-green-50 dark:bg-green-500/5":s.label==="not_assignment"?"border-red-300 dark:border-red-500/30 bg-red-50/50 dark:bg-red-500/5":"border-border hover:bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1 shrink-0 mt-0.5",children:[e.jsx("button",{onClick:()=>!s.alreadyImported&&pe(s.emailId,"assignment"),disabled:s.alreadyImported,className:`size-7 rounded flex items-center justify-center transition-colors ${s.label==="assignment"?"bg-green-500 text-white":"bg-muted hover:bg-green-100 dark:hover:bg-green-500/20 text-muted-foreground"}`,title:"This is an assignment",children:e.jsx(ps,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>!s.alreadyImported&&pe(s.emailId,"grade_return"),disabled:s.alreadyImported,className:`size-7 rounded flex items-center justify-center transition-colors ${s.label==="grade_return"?"bg-emerald-500 text-white":"bg-muted hover:bg-emerald-100 dark:hover:bg-emerald-500/20 text-muted-foreground"}`,title:"Grade return",children:e.jsx(be,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>!s.alreadyImported&&pe(s.emailId,"not_assignment"),disabled:s.alreadyImported,className:`size-7 rounded flex items-center justify-center transition-colors ${s.label==="not_assignment"?"bg-red-500 text-white":"bg-muted hover:bg-red-100 dark:hover:bg-red-500/20 text-muted-foreground"}`,title:"Not an assignment",children:e.jsx(hs,{className:"size-3.5"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.subject}),s.alreadyImported&&e.jsx(D,{variant:"secondary",className:"text-[10px] shrink-0",children:"Already imported"}),s.label==="assignment"&&e.jsx(D,{className:"text-[10px] bg-green-500 text-white shrink-0",children:"Assignment"}),s.label==="grade_return"&&e.jsxs(D,{className:"text-[10px] bg-emerald-500 text-white shrink-0 flex items-center gap-0.5",children:[e.jsx(be,{className:"size-2.5"}),"Grade Return"]}),s.label==="not_assignment"&&e.jsx(D,{variant:"secondary",className:"text-[10px] shrink-0",children:"Not assignment"}),s.label==="unlabeled"&&!s.alreadyImported&&s.aiScore!=null&&e.jsxs(D,{variant:"outline",className:`text-[10px] shrink-0 ${s.aiType==="grade_return"?"border-emerald-400 text-emerald-600 dark:text-emerald-400":s.aiScore>=70?"border-green-400 text-green-600 dark:text-green-400":s.aiScore>
32=40?"border-amber-400 text-amber-600 dark:text-amber-400":"border-muted-foreground/30 text-muted-foreground"}`,title:s.aiReason||"",children:[s.aiType==="grade_return"?e.jsx(be,{className:"size-2.5 mr-0.5"}):e.jsx(Le,{className:"size-2.5 mr-0.5"}),s.aiScore,"%",s.aiType==="grade_return"?" Grade":""]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:s.from}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.date).toLocaleDateString()}),s.attachmentCount>0&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zs,{className:"size-3"}),s.attachmentCount]})]}),s.aiReason&&s.label==="unlabeled"&&!s.alreadyImported&&e.jsxs("p",{className:`text-[10px] mt-1 flex items-center gap-1 ${s.aiType==="grade_return"?"text-emerald-600/70 dark:text-emerald-400/70":"text-primary/70"}`,children:[s.aiType==="grade_return"?e.jsx(be,{className:"size-2.5 shrink-0"}):e.jsx(Le,{className:"size-2.5 shrink-0"}),s.aiReason]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.snippet}),s.label!=="unlabeled"&&!s.alreadyImported&&e.jsx("input",{type:"text",placeholder:s.label==="assignment"?'Why? e.g. "Math homework from teacher"':'Why not? e.g. "Newsletter, not homework"',value:s.reason,onChange:o=>Pe(s.emailId,o.target.value),onBlur:()=>Ke(s),className:"mt-2 w-full text-xs bg-background border border-border rounded px-2 py-1 text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-1 focus:ring-primary"})]})]})},s.emailId)),K.length>0&&!ue&&e.jsx("button",{onClick:()=>ls(!I),className:"w-full text-center text-[11px] text-muted-foreground hover:text-foreground py-2 transition-colors flex items-center justify-center gap-1.5",children:I?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"size-3"}),"Hide ",K.length," low-confidence email",K.length!==1?"s":""," (below ",xe,"%)"]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"size-3"}),"Show ",K.length," hidden low-confidence email",K.length!==1?"s":""," (below ",xe,"%)"]})})]}),v==="extracting"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(C,{className:"size-12 animate-spin text-primary"}),e.jsx(Le,{className:"size-5 text-primary absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Extracting assignments..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Using your labeled examples to identify assignments"})]})]}),v==="review"&&e.jsxs("div",{className:"space-y-3",children:[re.some(s=>s.assignments.some(o=>o.senderPattern))&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md bg-violet-500/10 border border-violet-500/20 text-xs text-violet-700 dark:text-violet-300",children:[e.jsx(V,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"Some fields were auto-filled based on your previous approvals from this sender. You can still edit them."})]}),re.map((s,o)=>e.jsxs(F,{className:"overflow-hidden",children:[e.jsxs("div",{className:"p-3 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>fe(o),children:[s.expanded?e.jsx(Fe,{className:"size-4 text-muted-foreground shrink-0"}):e.jsx(as,{className:"size-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.subject}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.from}),!s.expanded&&s.summary&&e.jsx("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5 truncate",children:s.summary})]}),e.jsxs(D,{variant:"secondary",className:"text-xs shrink-0",children:[s.assignments.filter(t=>t.included).length," of ",s.assignments.length," assignment",s.assignments.length!==1?"s":""]})]}),s.expanded&&e.jsxs(B,{className:"pt-0 space-y-3",children:[s.summary&&e.jsxs("div",{className:"bg-muted/50 border border-border rounded-md px-3 py-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:"Summary"}),e.jsx("p",{className:"text-xs text-foreground mt-0.5",children:s.summary})]}),s.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.attachments.map((t,l)=>e.jsxs(D,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(zs,{className:"size-2.5"}),t.filename]},l))}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>ms(o),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(st,{className:"size-3"}),s.showBody?"Hide":"View"," Email Body",s.showBody?e.jsx(Fe,{className:"size-3"}):e.jsx(as,{className:"size-3"})]}),s.showBody&&e.jsx("pre",{className:"mt-1.5 text-[11px] text-muted-foreground bg-muted/50 border border-border rounded-md p-3 max-h-48 overflow-y-auto whitespace-pre-wrap font-sans leading-relaxed",children:s.body||"(Email body not available â try re-extracting)"})]}),s.assignments.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No assignments found in this email."}):s.assignments.map((t,l)=>{var c,u,b,p,x,j,R;return e.jsxs("div",{className:`rounded-lg border p-3 space-y-3 transition-colors ${t.included?"border-border bg-card":"border-border bg-muted/30 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(o,l,"included",!t.included),className:`size-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors ${t.included?"border-primary bg-primary":"border-muted-foreground"}`,children:t.included&&e.jsx(oe,{className:"size-3 text-primary-foreground"})}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase",children:["Assignment ",l+1]})]}),t.included&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Title",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.title)}`,title:`Confidence: ${t.confidence.title||"unknown"}`})]}),e.jsx("input",{type:"text",value:t.title,onChange:m=>$(o,l,"title",m.target.value),className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.title)}`}),e.jsx(le,{text:(c=t.sources)==null?void 0:c.title})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Class",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.class)}`,title:`Confidence: ${t.confidence.class||"unknown"}`}),t.confidence.class==="learned"&&t.senderPattern&&e.jsxs("span",{className:"text-violet-500 flex items-center gap-0.5",title:`Learned from ${t.senderPattern.approvalCount} approval${t.senderPattern.approvalCount!==1?"s":""} of ${t.senderPattern.senderName}`,children:[e.jsx(V,{className:"size-2.5"}),e.jsx("span",{className:"text-[9px] normal-case",children:"Learned"})]})]}),e.jsx("select",{value:t.class,onChange:m=>$(o,l,"class",m.target.value),className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.class)}`,children:(()=>{const m=L.map(A=>A.name),z=Pt.filter(A=>!m.includes(A)),G=[...m,...z];return G.includes(t.class)||G.push(t.class),e.jsxs(e.Fragment,{children:[m.length>0&&e.jsx("optgroup",{label:"Your Classes",children:L.map(A=>e.jsx("option",{value:A.name,children:A.name},A.id))}),e.jsx("optgroup",{label:m.length>0?"Other Subjects":"Subjects",children:z.map(A=>e.jsx("option",{value:A,children:A},A))}),!m.includes(t.class)&&!z.includes(t.class)&&e.jsx("option",{value:t.class,children:t.class})]})})()}),e.jsx(le,{text:(u=t.sources)==null?void 0:u.class})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Teacher",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.teacher)}`,title:`Confidence: ${t.confidence.teacher||"unknown"}`}),t.confidence.teacher==="learned"&&t.senderPattern&&e.jsxs("span",{className:"text-violet-500 flex items-center gap-0.5",title:`Learned from ${t.senderPattern.approvalCount} approval${t.senderPattern.approvalCount!==1?"s":""} of ${t.senderPattern.senderName}`,children:[e.jsx(V,{className:"size-2.5"}),e.jsx("span",{className:"text-[9px] normal-case",children:"Learned"})]})]}),Q.length>0&&!qe.has(`${o}-${l}`)?e.jsxs("select",{value:Q.some(m=>
32m.name===t.teacher)?t.teacher:"__other__",onChange:m=>{m.target.value==="__other__"?(O(z=>new Set(z).add(`${o}-${l}`)),$(o,l,"teacher","")):$(o,l,"teacher",m.target.value)},className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.teacher)}`,children:[e.jsx("option",{value:"",disabled:!0,children:"Select teacher..."}),Q.map(m=>e.jsx("option",{value:m.name,children:m.name},m.id)),t.teacher&&!Q.some(m=>m.name===t.teacher)&&t.teacher!==""&&e.jsx("option",{value:t.teacher,children:t.teacher}),e.jsx("option",{value:"__other__",children:"Other..."})]}):e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("input",{type:"text",value:t.teacher,onChange:m=>$(o,l,"teacher",m.target.value),className:`w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.teacher)}`,placeholder:"e.g., Mrs. Johnson"}),Q.length>0&&e.jsx("button",{type:"button",onClick:()=>O(m=>{const z=new Set(m);return z.delete(`${o}-${l}`),z}),className:"text-xs text-primary hover:text-primary/80 shrink-0 px-1",title:"Choose from list",children:e.jsx(Fe,{className:"size-4"})})]}),e.jsx(le,{text:(b=t.sources)==null?void 0:b.teacher})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Due Date ",e.jsx("span",{className:"text-red-500",children:"*"}),e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.dueDate)}`,title:`Confidence: ${t.confidence.dueDate||"unknown"}`})]}),e.jsx("input",{type:"date",value:t.dueDate?t.dueDate.split("T")[0]:"",onChange:m=>$(o,l,"dueDate",m.target.value?`${m.target.value}T23:59:00Z`:""),className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${!t.dueDate&&t.included?"border-red-400 ring-1 ring-red-300 dark:border-red-500 dark:ring-red-500/30":te(t.confidence.dueDate)}`}),!t.dueDate&&t.included&&e.jsx("p",{className:"text-[10px] text-red-500 mt-0.5",children:"Please set a due date"}),e.jsx(le,{text:(p=t.sources)==null?void 0:p.dueDate})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Priority",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.priority)}`,title:`Confidence: ${t.confidence.priority||"unknown"}`}),t.confidence.priority==="learned"&&t.senderPattern&&e.jsxs("span",{className:"text-violet-500 flex items-center gap-0.5",title:`Learned from ${t.senderPattern.approvalCount} approval${t.senderPattern.approvalCount!==1?"s":""} of ${t.senderPattern.senderName}`,children:[e.jsx(V,{className:"size-2.5"}),e.jsx("span",{className:"text-[9px] normal-case",children:"Learned"})]})]}),e.jsx("select",{value:t.priority,onChange:m=>$(o,l,"priority",m.target.value),className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.priority)}`,children:It.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))}),e.jsx(le,{text:(x=t.sources)==null?void 0:x.priority})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Est. Time (min)",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.estimatedTime)}`,title:`Confidence: ${t.confidence.estimatedTime||"unknown"}`}),t.confidence.estimatedTime==="learned"&&t.senderPattern&&e.jsxs("span",{className:"text-violet-500 flex items-center gap-0.5",title:`Learned from ${t.senderPattern.approvalCount} approval${t.senderPattern.approvalCount!==1?"s":""} of ${t.senderPattern.senderName}`,children:[e.jsx(V,{className:"size-2.5"}),e.jsx("span",{className:"text-[9px] normal-case",children:"Learned"})]})]}),e.jsx("input",{type:"number",min:5,max:480,value:t.estimatedTime,onChange:m=>$(o,l,"estimatedTime",parseInt(m.target.value)||30),className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary ${te(t.confidence.estimatedTime)}`}),e.jsx(le,{text:(j=t.sources)==null?void 0:j.estimatedTime})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:["Description",e.jsx("span",{className:`size-1.5 rounded-full ${ie(t.confidence.description)}`,title:`Confidence: ${t.confidence.description||"unknown"}`})]}),e.jsx("textarea",{value:t.description,onChange:m=>$(o,l,"description",m.target.value),rows:2,className:`mt-1 w-full text-sm bg-background border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary resize-none ${te(t.confidence.description)}`}),e.jsx(le,{text:(R=t.sources)==null?void 0:R.description})]}),t.subtasks.length>0&&e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1.5",children:[e.jsx(tt,{className:"size-3"}),"Subtasks (",t.subtasks.filter(m=>m.included).length,"/",t.subtasks.length,")"]}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:t.subtasks.map((m,z)=>e.jsxs("div",{className:`flex items-start gap-2 rounded-md border px-2.5 py-1.5 transition-colors ${m.included?"border-border bg-background":"border-border bg-muted/30 opacity-60"}`,children:[e.jsx("button",{onClick:()=>{const G=[...t.subtasks];G[z]={...G[z],included:!m.included},$(o,l,"subtasks",G)},className:`size-4 rounded border shrink-0 mt-0.5 flex items-center justify-center transition-colors ${m.included?"border-primary bg-primary":"border-muted-foreground"}`,children:m.included&&e.jsx(oe,{className:"size-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:m.title}),m.explanation&&e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-start gap-1 mt-0.5",children:[e.jsx(Ct,{className:"size-2.5 shrink-0 mt-px"}),m.explanation]})]})]},z))})]})]})]},l)})]})]},s.emailId)),Ae.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground pt-2",children:[e.jsx(be,{className:"size-4 text-emerald-500"}),"Grade Returns"]}),Ae.map((s,o)=>e.jsxs(F,{className:"overflow-hidden border-emerald-200 dark:border-emerald-800",children:[e.jsxs("div",{className:"p-3 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>Ee(t=>{const l=[...t];return l[o]={...l[o],expanded:!l[o].expanded},l}),children:[s.expanded?e.jsx(Fe,{className:"size-4 text-muted-foreground shrink-0"}):e.jsx(as,{className:"size-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.subject}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.from})]}),s.grade&&e.jsxs(D,{className:"text-xs bg-emerald-500 text-white shrink-0",children:[s.grade.percentage,"% â ",s.grade.type]})]}),s.expanded&&e.jsx(B,{className:"pt-0 space-y-3",children:s.grade?e.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-950/20 border border-emerald-200 dark:border-emerald-800 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"size-4 text-emerald-600 dark:text-emerald-400"}),e.jsxs("span",{className:"text-sm font-medium text-emerald-900 dark:text-emerald-300",children:[s.grade.score,"/",s.grade.total," (",s.grade.percentage,"%)"]}),e.jsx(D,{variant:"outline",className:"text-[10px] border-emerald-300 text-emerald-600 dark:text-emerald-400",children:s.grade.type})]}),s.grade.assignmentName&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Assignment:"})," ",s.grade.assignmentName]}),s.grade.class&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Class:"})," ",s.grade.class]})]}):e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No grade information detected in this email."})})]},s.emailId))]}),os&&e.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[e.jsx(C,{className:"size-3 animate-spin"}),"Detecting grades..."]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-muted-foreground pt-1",children:[e.jsx("span",{className:"font-medium",children:"Confidence:"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-green-500"})," High"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-amber-500"})," Medium"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-red-500"})," Low"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-violet-500"})," Learned"]})]})]}),v==="done"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-4",children:[e.jsx("div",{className:"size-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Ge,{className:"size-8 text-primary"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-lg font-semibold text-foreground",children:[Ce," Assignment",Ce!==1?"s":""," Imported"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ce>0?"Assignments have been added to your dashboard.":"No assignments were approved for import."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-border",children:[v==="scan"&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"ghost",onClick:S,children:"Cancel"}),e.jsx("div",{})]}),v==="label"&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"ghost",onClick:S,children:"Cancel"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Ie," assignment",Ie!==1?"s":"",X>0&&`, ${X} grade${X!==1?"s":""}`,ss>0&&`, ${ss} not`]}),e.jsxs(g,{onClick:ge,disabled:Ie===0&&X===0||Re,className:"gradient-brand text-white",children:[Re?e.jsx(C,{className:"size-4 mr-2 animate-spin"}):e.jsx(Le,{className:"size-4 mr-2"}),"Extract Assignments"]})]})]}),v==="extracting"&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"ghost",onClick:()=>f("label"),children:"Back"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"This may take a moment..."})]}),v==="review"&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"ghost",onClick:()=>f("label"),children:"Back"}),e.jsxs("div",{className:"flex items-center gap-2",children:[U&&ee>0&&e.jsxs("span",{className:"text-xs text-red-500 flex items-center gap-1",children:[e.jsx(ks,{className:"size-3"}),"Set due dates first"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[ee," assignment",ee!==1?"s":""," selected"]}),e.jsxs(g,{onClick:Xe,disabled:ee===0||U,className:"gradient-brand text-white",children:[e.jsx(oe,{className:"size-4 mr-2"}),"Approve Selected"]})]})]}),v==="done"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{}),e.jsx(g,{onClick:S,className:"gradient-brand text-white",children:"Done"})]})]})]})})}function le({text:r}){return r?e.jsxs("p",{className:"mt-0.5 text-[10px] text-muted-foreground
32/70 flex items-start gap-1 leading-tight",children:[e.jsx($t,{className:"size-2.5 shrink-0 mt-px rotate-180"}),e.jsx("span",{className:"italic truncate",title:r,children:r})]}):null}function Bt({count:r,exampleCount:S,onContinue:we,onRescan:v}){return d.useEffect(()=>{const f=setTimeout(we,600);return()=>clearTimeout(f)},[]),e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"size-8 text-primary"}),e.jsxs("p",{className:"text-sm text-foreground font-medium",children:["Found ",r," email",r!==1?"s":""]}),S>0&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(V,{className:"size-3"}),S," past examples training the system"]})]})}const Gt=d.lazy(()=>bt(()=>import("./ai-prediction-dashboard-CBWsHxpS.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(r=>({default:r.AIPredictionDashboard}))),Rt=[{id:"smartalecks",label:"Smart Alecks",color:"#1fae75"},{id:"google",label:"Google",color:"#1a73e8"},{id:"stripe",label:"Stripe",color:"#635bff"},{id:"linear",label:"Linear",color:"#5e6ad2"},{id:"spotify",label:"Spotify",color:"#1db954"}],Mt=["https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/classroom.courses.readonly","https://www.googleapis.com/auth/classroom.coursework.students.readonly","https://www.googleapis.com/auth/classroom.student-submissions.students.readonly","https://www.googleapis.com/auth/classroom.push-notifications","https://www.googleapis.com/auth/forms.body.readonly","https://www.googleapis.com/auth/forms.responses.readonly","https://www.googleapis.com/auth/admin.directory.user.readonly","https://www.googleapis.com/auth/classroom.rosters"].join(" ");function qt({user:r,onBack:S,defaultTab:we="profile",onAssignmentsImported:v,parentOversight:f,selectedChildId:ae,childName:E,linkedChildren:w,onSelectChild:q,onEnterClassroomPreview:ce}){var bs,Ns,ys,vs,ws;const[de,Re]=d.useState(()=>document.documentElement.classList.contains("dark")),[ke,re]=d.useState(()=>localStorage.getItem("smartaleck_scheme")||"smartalecks"),[ne,Ce]=d.useState(rt),[me,Se]=d.useState(()=>{var a;return((a=r==null?void 0:r.academic_calendar)==null?void 0:a.enabled)??!1}),[Me,Oe]=d.useState(()=>{var a;return((a=r==null?void 0:r.academic_calendar)==null?void 0:a.subdivision)??"semester"}),[Y,ue]=d.useState(()=>{var a;return((a=r==null?void 0:r.academic_calendar)==null?void 0:a.periods)??[]}),[ze,xe]=d.useState(!1),[is,I]=d.useState(null),[ls,Te]=d.useState(!1),[$e,Ae]=d.useState(null),[Ee,os]=d.useState((r==null?void 0:r.org_id)||null),_e=d.useRef((r==null?void 0:r.org_id)||null),[P,Z]=d.useState(!1),[gs,De]=d.useState(!1),Ue=async a=>{if(os(a),a===_e.current)return;const n=y();if(n){Z(!0);try{(await fetch(`${N}/users/${r==null?void 0:r.id}/org`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({orgId:a})})).ok&&(_e.current=a,De(!0),setTimeout(()=>De(!1),3e3))}catch(i){console.error("Failed to save org:",i)}finally{Z(!1)}}},Je=a=>{re(a),a==="smartalecks"?document.documentElement.removeAttribute("data-scheme"):document.documentElement.setAttribute("data-scheme",a),localStorage.setItem("smartaleck_scheme",a)},[L,He]=d.useState({connected:!1,lastSynced:null,importedCount:0}),[Q,Ve]=d.useState(!1),[qe,O]=d.useState(null),[Ye,Ze]=d.useState(null),[cs,Qe]=d.useState(!1),[We,ds]=d.useState([]),[W,he]=d.useState(!1),[pe,Pe]=d.useState(null),[Ke,ge]=d.useState([]),[$,fe]=d.useState([]),[ms,Xe]=d.useState(!1),[K,es]=d.useState(!1),[Ie,X]=d.useState(null),[ss,ee]=d.useState(null),[U,s]=d.useState({name:"",color:"",teacher_id:null}),[o,t]=d.useState({name:"",email:""}),[l,c]=d.useState(!1),[u,b]=d.useState(!1),[p,x]=d.useState({name:"",color:"#64748b",teacherId:null}),[j,R]=d.useState({name:"",email:""}),[m,z]=d.useState(!1),[G,A]=d.useState(!1),[fs,k]=d.useState(null),_s=async()=>{const a=y();if(a){Xe(!0);try{const i=await(await fetch(`${N}/classes`,{headers:{Authorization:`Bearer ${a}`}})).json();i.success&&ge(i.classes||[])}catch(n){console.error("Failed to fetch classes:",n)}finally{Xe(!1)}}},Ds=async()=>{const a=y();if(a){es(!0);try{const i=await(await fetch(`${N}/teachers`,{headers:{Authorization:`Bearer ${a}`}})).json();i.success&&fe(i.teachers||[])}catch(n){console.error("Failed to fetch teachers:",n)}finally{es(!1)}}},Ps=async()=>{const a=y();if(!(!a||!p.name.trim())){z(!0),k(null);try{const i=await(await fetch(`${N}/classes`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({name:p.name,color:p.color,teacherId:p.teacherId})})).json();i.success?(ge(h=>[...h,i.class].sort((_,T)=>_.name.localeCompare(T.name))),x({name:"",color:"#64748b",teacherId:null}),c(!1)):k(i.error||"Failed to create class")}catch(n){k(n.message)}finally{z(!1)}}},Is=async a=>{const n=y();if(n){z(!0),k(null);try{const h=await(await fetch(`${N}/classes/${a}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({name:U.name,color:U.color,teacher_id:U.teacher_id})})).json();h.success?(ge(_=>_.map(T=>T.id===a?h.class:T)),X(null)):k(h.error||"Failed to update class")}catch(i){k(i.message)}finally{z(!1)}}},Ls=async a=>{const n=y();if(n){k(null);try{const h=await(await fetch(`${N}/classes/${a}`,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}})).json();h.success?ge(_=>_.filter(T=>T.id!==a)):k(h.error||"Failed to delete class")}catch(i){k(i.message)}}},Fs=async()=>{const a=y();if(!(!a||!j.name.trim())){A(!0),k(null);try{const i=await(await fetch(`${N}/teachers`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({name:j.name,email:j.email||void 0})})).json();i.success?(fe(h=>[...h,i.teacher].sort((_,T)=>_.name.localeCompare(T.name))),R({name:"",email:""}),b(!1)):k(i.error||"Failed to create teacher")}catch(n){k(n.message)}finally{A(!1)}}},Bs=async a=>{const n=y();if(n){A(!0),k(null);try{const h=await(await fetch(`${N}/teachers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({name:o.name,email:o.email||void 0})})).json();h.success?(fe(_=>_.map(T=>T.id===a?h.teacher:T)),ee(null)):k(h.error||"Failed to update teacher")}catch(i){k(i.message)}finally{A(!1)}}},Gs=async a=>{const n=y();if(n){k(null);try{const h=await(await fetch(`${N}/teachers/${a}`,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}})).json();h.success?fe(_=>_.filter(T=>T.id!==a)):k(h.error||"Failed to delete teacher")}catch(i){k(i.message)}}},js=async()=>{const a=y();if(a)try{const i=await(await fetch(`${N}/google/classroom/status`,{headers:{Authorization:`Bearer ${a}`}})).json();i.success&&He({connected:i.connected,lastSynced:i.lastSynced,importedCount:i.importedCount})}catch(n){console.error("Failed to fetch Google status:",n)}};d.useEffect(()=>{js(),_s(),Ds()},[]),d.useEffect(()=>{const a=async n=>{var i,h;if(((i=n.data)==null?void 0:i.type)==="google-oauth-callback"&&((h=n.data)!=null&&h.co
32de)){Ve(!0),O(null);const _=y();try{const se=await(await fetch(`${N}/google/auth`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_}`},body:JSON.stringify({code:n.data.code})})).json();se.success?(await js(),Ze("Google account connected successfully!")):O(se.error||"Failed to connect")}catch(T){O(T.message)}finally{Ve(!1)}}};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[]);const Rs=()=>{const a="690865703195-18dh9c6qvnc0a5mvpf6lu0sg7shvjrl9.apps.googleusercontent.com",n=`${window.location.origin}/google-callback`,i=new URL("https://accounts.google.com/o/oauth2/v2/auth");i.searchParams.set("client_id",a),i.searchParams.set("redirect_uri",n),i.searchParams.set("response_type","code"),i.searchParams.set("scope",Mt),i.searchParams.set("access_type","offline"),i.searchParams.set("prompt","consent select_account"),window.open(i.toString(),"google-auth","width=500,height=700,left=100,top=100")||O("Popup blocked. Please allow popups for this site.")},Ms=async()=>{const a=y();try{await fetch(`${N}/google/classroom/disconnect`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}}),He({connected:!1,lastSynced:null,importedCount:0}),Ze(null)}catch(n){O(n.message)}},Os=async()=>{const a=y();if(a){he(!0),Pe(null);try{const i=await(await fetch(`${N}/google/classroom/courses`,{headers:{Authorization:`Bearer ${a}`}})).json();i.success?ds(i.courses||[]):Pe(i.error||"Failed to fetch courses")}catch(n){Pe(n.message)}finally{he(!1)}}},Us=()=>{const a=!de;Re(a),document.documentElement.classList.toggle("dark",a),localStorage.setItem("smartaleck_theme",a?"dark":"light")},Js=[{id:"fall-semester",name:"Fall Semester",startDate:"2025-08-20",endDate:"2025-12-15"},{id:"spring-semester",name:"Spring Semester",startDate:"2026-01-10",endDate:"2026-05-20"}],Hs=[{id:"fall-trimester",name:"Fall Trimester",startDate:"2025-08-20",endDate:"2025-11-20"},{id:"winter-trimester",name:"Winter Trimester",startDate:"2025-11-21",endDate:"2026-03-10"},{id:"spring-trimester",name:"Spring Trimester",startDate:"2026-03-11",endDate:"2026-06-10"}],Vs=a=>{Oe(a),(Y.length===0||Y.every(n=>!n.syllabus))&&ue(a==="semester"?Js:Hs)},qs=()=>{const a=[...Y].filter(n=>n.startDate&&n.endDate).sort((n,i)=>n.startDate.localeCompare(i.startDate));for(let n=1;n<a.length;n++)if(a[n].startDate<=a[n-1].endDate)return`Periods "${a[n-1].name}" and "${a[n].name}" overlap`;return null},Ys=async()=>{if(I(null),Te(!1),me){for(const i of Y){if(!i.startDate||!i.endDate){I(`Period "${i.name}" is missing dates`);return}if(i.startDate>=i.endDate){I(`Period "${i.name}": start date must be before end date`);return}}const n=qs();if(n){I(n);return}}xe(!0);const a=y();try{const n=me?{academic_calendar:{enabled:!0,subdivision:Me,periods:Y}}:{academic_calendar:null},i=await fetch(`${N}/auth/academic-calendar`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(n)}),h=await i.json();i.ok?(Te(!0),setTimeout(()=>Te(!1),3e3)):I(h.error||"Failed to save")}catch(n){I(n.message)}finally{xe(!1)}},Zs=async(a,n)=>{Ae(a);const i=y();try{const h=new FileReader,_=await new Promise((us,je)=>{h.onload=()=>{const ts=h.result;us(ts.split(",")[1])},h.onerror=je,h.readAsDataURL(n)}),se=await(await fetch(`${N}/auth/academic-calendar/syllabus`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({periodId:a,fileData:_,filename:n.name,mimeType:n.type})})).json();se.success?ue(us=>us.map(je=>{var ts;return je.id!==a?je:{...je,syllabus:se.syllabus,checkIns:(ts=se.checkIns)!=null&&ts.length?se.checkIns:je.checkIns}})):I(se.error||"Failed to upload syllabus")}catch(h){I(h.message)}finally{Ae(null)}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"bg-card border-b border-border sticky top-0 z-50 shadow-sm",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-3 flex items-center gap-4",children:[e.jsx(g,{variant:"ghost",size:"icon",onClick:S,children:e.jsx(nt,{className:"size-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground",children:"Settings"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage your account and integrations"})]})]})}),ae&&w&&q&&e.jsx(it,{children:w,selectedChildId:ae,onSelectChild:q}),e.jsxs("main",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs(lt,{defaultValue:we,className:"space-y-6",children:[(()=>{const a=(r==null?void 0:r.is_admin)||(r==null?void 0:r.role)!=="student"||!(r!=null&&r.requiresParentOversight),n=!(r!=null&&r.role)||(r==null?void 0:r.role)==="student",i=4+(n?1:0)+(a?1:0);return e.jsxs(ot,{className:"grid w-full",style:{gridTemplateColumns:`repeat(${i}, minmax(0, 1fr))`},children:[e.jsxs(Ne,{value:"profile",className:"flex items-center gap-2",children:[e.jsx(ct,{className:"size-4"}),"Profile"]}),n&&e.jsxs(Ne,{value:"classes",className:"flex items-center gap-2",children:[e.jsx(xs,{className:"size-4"}),"Classes"]}
32),e.jsxs(Ne,{value:"integrations",className:"flex items-center gap-2",children:[e.jsx(zt,{className:"size-4"}),"Integrations"]}),e.jsxs(Ne,{value:"preferences",className:"flex items-center gap-2",children:[e.jsx(dt,{className:"size-4"}),"Preferences"]}),e.jsxs(Ne,{value:"ai-management",className:"flex items-center gap-2",children:[e.jsx(V,{className:"size-4"}),"Insights"]}),a&&e.jsxs(Ne,{value:"oversight",className:"flex items-center gap-2",children:[e.jsx(rs,{className:"size-4"}),"Oversight"]})]})})(),e.jsx(ye,{value:"profile",className:"space-y-6",children:e.jsxs(F,{children:[e.jsx(J,{children:e.jsx(H,{children:"Your Profile"})}),e.jsxs(B,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(mt,{className:"size-16",children:e.jsxs(ut,{className:"gradient-brand text-white text-xl border-2 border-primary/40",children:[(bs=r==null?void 0:r.firstName)==null?void 0:bs[0],(Ns=r==null?void 0:r.lastName)==null?void 0:Ns[0]]})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:r==null?void 0:r.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r==null?void 0:r.email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"First Name"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:r==null?void 0:r.firstName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Last Name"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:r==null?void 0:r.lastName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Role"}),e.jsx("div",{className:"mt-1",children:e.jsx(D,{variant:"secondary",className:"capitalize",children:r==null?void 0:r.role})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:r==null?void 0:r.email})]})]}),e.jsxs("div",{className:"border-t border-border pt-4 space-y-2",children:[e.jsxs(xt,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Nt,{className:"size-4"}),"School / Organization"]}),e.jsx(yt,{value:Ee,onChange:Ue,accessToken:y()||""}),P&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(C,{className:"size-3 animate-spin"})," Saving..."]}),gs&&e.jsxs("p",{className:"text-xs text-primary flex items-center gap-1",children:[e.jsx(Ge,{className:"size-3"})," School updated!"]})]})]})]})}),e.jsxs(ye,{value:"classes",className:"space-y-6",children:[fs&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3",children:fs}),e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(H,{
32className:"flex items-center gap-2",children:[e.jsx(xs,{className:"size-5"}),"Your Classes"]}),!l&&e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{c(!0),x({name:"",color:"#64748b",teacherId:null})},children:[e.jsx(ns,{className:"size-4 mr-1"}),"Add Class"]})]})}),e.jsxs(B,{className:"space-y-3",children:[l&&e.jsxs("div",{className:"border border-primary/30 bg-primary/5 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Name"}),e.jsx("input",{type:"text",value:p.name,onChange:a=>x(n=>({...n,name:a.target.value})),placeholder:"e.g., Algebra",className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Color"}),e.jsx("input",{type:"color",value:p.color,onChange:a=>x(n=>({...n,color:a.target.value})),className:"mt-1 size-9 rounded-md border border-border cursor-pointer"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Teacher"}),e.jsxs("select",{value:p.teacherId||"",onChange:a=>x(n=>({...n,teacherId:a.target.value||null})),className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[e.jsx("option",{value:"",children:"None"}),$.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(g,{size:"sm",onClick:Ps,disabled:!p.name.trim()||m,children:[m?e.jsx(C,{className:"size-4 animate-spin mr-1"}):e.jsx(ns,{className:"size-4 mr-1"}),"Add"]})]})]}),ms?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(C,{className:"size-5 animate-spin text-muted-foreground"})}):Ke.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No classes yet. Add your first class to get started."}):Ke.map(a=>{var n;return e.jsx("div",{className:"border border-border rounded-lg p-3",children:Ie===a.id?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Name"}),e.jsx("input",{type:"text",value:U.name,onChange:i=>s(h=>({...h,name:i.target.value})),className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Color"}),e.jsx("input",{type:"color",value:U.color,onChange:i=>s(h=>({...h,color:i.target.value})),className:"mt-1 size-9 rounded-md border border-border cursor-pointer"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Teacher"}),e.jsxs("select",{value:U.teacher_id||"",onChange:i=>s(h=>({...h,teacher_id:i.target.value||null})),className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[e.jsx("option",{value:"",children:"None"}),$.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>X(null),children:[e.jsx(Ts,{className:"size-4 mr-1"}),"Cancel"]}),e.jsxs(g,{size:"sm",onClick:()=>Is(a.id),disabled:m,children:[m?e.jsx(C,{className:"size-4 animate-spin mr-1"}):e.jsx(oe,{className:"size-4 mr-1"}),"Save"]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-4 rounded-full ring-1 ring-black/10",style:{backgroundColor:a.color||"#64748b"}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:a.name}),((n=a.teachers)==null?void 0:n.name)&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.teachers.name})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(g,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{X(a.id),s({name:a.name,color:a.color||"#64748b",teacher_id:a.teacher_id||null})},children:e.jsx($s,{className:"size-3.5"})}),e.jsx(g,{variant:"ghost",size:"icon",className:"size-8 text-destructive hover:text-destructive",onClick:()=>Ls(a.id),children:e.jsx(As,{className:"size-3.5"})})]})]})},a.id)})]})]}),e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(H,{
32className:"flex items-center gap-2",children:[e.jsx(rs,{className:"size-5"}),"Your Teachers"]}),!u&&e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{b(!0),R({name:"",email:""})},children:[e.jsx(ns,{className:"size-4 mr-1"}),"Add Teacher"]})]})}),e.jsxs(B,{className:"space-y-3",children:[u&&e.jsxs("div",{className:"border border-primary/30 bg-primary/5 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Name"}),e.jsx("input",{type:"text",value:j.name,onChange:a=>R(n=>({...n,name:a.target.value})),placeholder:"e.g., Mrs. Johnson",className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Email (optional)"}),e.jsx("input",{type:"email",value:j.email,onChange:a=>R(n=>({...n,email:a.target.value})),placeholder:"[email protected]",className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Cancel"}),e.jsxs(g,{size:"sm",onClick:Fs,disabled:!j.name.trim()||G,children:[G?e.jsx(C,{className:"size-4 animate-spin mr-1"}):e.jsx(ns,{className:"size-4 mr-1"}),"Add"]})]})]}),K?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(C,{className:"size-5 animate-spin text-muted-foreground"})}):$.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No teachers yet. Add your first teacher to get started."}):$.map(a=>{var n;return e.jsx("div",{className:"border border-border rounded-lg p-3",children:ss===a.id?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Name"}),e.jsx("input",{type:"text",value:o.name,onChange:i=>t(h=>({...h,name:i.target.value})),className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("input",{type:"email",value:o.email,onChange:i=>t(h=>({...h,email:i.target.value})),className:"mt-1 w-full text-sm bg-background border border-border rounded-md px-2.5 py-1.5 text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>ee(null),children:[e.jsx(Ts,{className:"size-4 mr-1"}),"Cancel"]}),e.jsxs(g,{size:"sm",onClick:()=>Bs(a.id),disabled:G,children:[G?e.jsx(C,{className:"size-4 animate-spin mr-1"}):e.jsx(oe,{className:"size-4 mr-1"}),"Save"]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:a.name}),((n=a.classes)==null?void 0:n.length)>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.classes.map(i=>i.name).join(", ")}),a.email&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.email})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(g,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{ee(a.id),t({name:a.name,email:a.email||""})},children:e.jsx($s,{className:"size-3.5"})}),e.jsx(g,{variant:"ghost",size:"icon",className:"size-8 text-destructive hover:text-destructive",onClick:()=>Gs(a.id),children:e.jsx(As,{className:"size-3.5"})})]})]})},a.id)})]})]})]}),e.jsxs(ye,{value:"integrations",className:"space-y-6",children:[e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs(H,{
32className:"flex items-center gap-2",children:[e.jsx(Be,{className:"size-5"}),"Google Account"]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`size-3 rounded-full ${L.connected?"bg-green-500":"bg-muted-foreground"}`}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:L.connected?"Connected":"Not Connected"}),L.lastSynced&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last synced: ",new Date(L.lastSynced).toLocaleString()]})]})]}),L.connected&&e.jsxs(D,{variant:"secondary",className:"text-xs",children:[L.importedCount," imported"]})]}),qe&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3",children:qe}),Ye&&e.jsxs("div",{className:"text-sm text-primary bg-primary/10 border border-primary/20 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(Ge,{className:"size-4 shrink-0"}),Ye]}),L.connected?e.jsx("div",{className:"flex gap-2",children:e.jsxs(g,{variant:"outline",onClick:Ms,className:"text-destructive hover:text-destructive",children:[e.jsx(Dt,{className:"size-4 mr-2"}),"Disconnect"]})}):e.jsx(g,{onClick:Rs,disabled:Q,className:"w-full",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-4 mr-2 animate-spin"}),"Connecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"size-4 mr-2"}),"Connect Google Account"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connects Gmail and Google Classroom to import assignments."})]})]}),L.connected&&e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"size-5"}),"Gmail Assignment Import"]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan your inbox for assignment-related emails, review auto-detected details, and import them as assignments."}),e.jsxs(g,{onClick:()=>Qe(!0),className:"gradient-brand text-white",children:[e.jsx(Be,{className:"size-4 mr-2"}),"Scan & Import from Gmail"]})]})]}),L.connected&&e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"size-5"}),"Google Classroom"]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2.5 rounded-full bg-green-500"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Connected â assignments sync live"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Google Classroom assignments appear automatically in your dashboard. SmartAleck reads live from Classroom and layers its own tools on top."}),pe&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3",children:pe}),e.jsx(g,{variant:"outline",onClick:Os,disabled:W,children:W?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-4 mr-2 animate-spin"}),"Loading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"size-4 mr-2"}),"View Courses"]})}),We.length>0&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Your Courses"}),We.map(a=>{var n;return e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:a.name}),a.section&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.section})]}),e.jsxs(D,{variant:"secondary",className:"text-xs",children:[a.courseworkCount??0," items"]})]}),((n=a.coursework)==null?void 0:n.length)>0&&e.jsx("div",{className:"space-y-1 pl-3 border-l-2 border-muted",children:a.coursework.map(i=>e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx("p",{className:"text-xs text-foreground",children:i.title}),i.state&&e.jsx(D,{variant:"outline",className:"text-[10px] px-1.5",children:i.state})]},i.id))}),a.courseworkError&&e.jsx("p",{className:"text-xs text-destructive",children:a.courseworkError})]},a.id)})]})]})]}),(r==null?void 0:r.is_admin)&&ce&&e.jsxs(F,{children:[e.jsx(J,{children:e.jsx(H,{children:"Classroom Preview Mode"})}),e.jsxs(B,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"View Google Classroom as any student or teacher in your organization."}),e.jsxs(g,{onClick:ce,children:[e.jsx(rs,{className:"size-4 mr-2"}),"Enter Classroom Preview"]})]})]}),e.jsx(Ft,{isOpen:cs,onClose:()=>Qe(!1),onAssignmentsImported:a=>{v==null||v(a)}})]}),e.jsxs(ye,{value:"preferences",className:"space-y-6",children:[e.jsxs(F,{children:[e.jsx(J,{children:e.jsx(H,{children:"Appearance"})}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Theme"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose between light and dark mode"})]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:Us,className:"flex items-center gap-2",children:[de?e.jsx(pt,{className:"size-4"}):e.jsx(gt,{className:"size-4"}),de?"Light Mode":"Dark Mode"]})]}),e.jsxs("div",{className:"border-t border-border pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-1",children:"Color Scheme"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Choose a color palette for the entire app"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Rt.map(a=>e.jsxs("button",{onClick:()=>Je(a.id),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg border-2 transition-all ${ke===a.id?"border-primary bg-primary/5 shadow-sm":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:"size-5 rounded-full ring-1 ring-black/10 flex items-center justify-center",style:{backgroundColor:a.color},children:ke===a.id&&e.jsx(oe,{className:"size-3 text-white"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:a.label})]},a.id))})]})]})]}),e.jsxs(F,{children:[e.jsx(J,{children:e.jsx(H,{children:"Notifications"})}),e.jsx(B,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Notification preferences will be available in a future update."})})]})]}),e.jsxs(ye,{value:"ai-management",className:"space-y-6",children:[ae&&E&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950/30 text-sm text-blue-800 dark:text-blue-200",children:[e.jsx(V,{className:"size-4 shrink-0"}
32),"Showing insights for ",E]}),e.jsx(d.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(C,{className:"size-6 animate-spin text-muted-foreground"})}),children:e.jsx(Gt,{userId:ae||void 0})})]}),((r==null?void 0:r.is_admin)||(r==null?void 0:r.role)!=="student"||!(r!=null&&r.requiresParentOversight))&&e.jsxs(ye,{value:"oversight",className:"space-y-6",children:[f&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-amber-300 bg-amber-50 dark:border-amber-700 dark:bg-amber-950/30 text-sm text-amber-800 dark:text-amber-300",children:[e.jsx(ft,{className:"size-4 shrink-0"}),"These settings are managed by your parent and cannot be changed here."]}),e.jsx(vt,{value:(f==null?void 0:f.aiEngagement)??ne,onChange:a=>{f||(Ce(a),localStorage.setItem(jt,a))},disabled:!!f}),e.jsx(wt,{enabled:((ys=f==null?void 0:f.academicCalendar)==null?void 0:ys.enabled)??me,subdivision:((vs=f==null?void 0:f.academicCalendar)==null?void 0:vs.subdivision)??Me,periods:((ws=f==null?void 0:f.academicCalendar)==null?void 0:ws.periods)??Y,onEnabledChange:a=>{f||Se(a)},onSubdivisionChange:a=>{f||Vs(a)},onPeriodsChange:a=>{f||ue(a)},onSyllabusUpload:f?void 0:Zs,syllabusUploading:$e,disabled:!!f}),!f&&e.jsxs(e.Fragment,{children:[is&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3",children:is}),ls&&e.jsxs("div",{className:"text-sm text-primary bg-primary/10 border border-primary/20 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(Ge,{className:"size-4 shrink-0"}),"Academic calendar saved!"]}),e.jsx(g,{onClick:Ys,disabled:ze,className:"w-full",children:ze?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-4 mr-2 animate-spin"}),"Saving..."]}):"Save Academic Calendar"})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center mt-6",children:["Smart Alecks v","0.0.1"]})]})]})}export{qt as SettingsPage};
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.