1import{k as q,m as U,o as D,n as r,j as e,B as M,p as n,q as w,t as Q,c as C}from"./index-euS5ES71.js";import{C as R,a as z,b as H,c as W,d as G,I as j}from"./card-DKdbKAHj.js";import{L as S,S as V}from"./label-DIZRt-dd.js";import{S as k,K as X,U as I}from"./user-W8rK_TNB.js";import{M as Y}from"./message-square-DWQtHNYL.js";import{C as Z}from"./check-1wLzMGyy.js";import{A as T}from"./arrow-left-BFgkYHoc.js";import{A}from"./arrow-right-CbvSbWKb.js";function ce(){const d=q();U();const{t:a}=D(),[l,h]=r.useState(1),[o,F]=r.useState(""),[g,J]=r.useState([]),[c,f]=r.useState(null),[u,_]=r.useState(""),[m,K]=r.useState(""),[x,N]=r.useState(!1),[b,y]=r.useState(!1),[p,L]=r.useState(null),[O,P]=r.useState(null),v=async()=>{if(o.trim()){N(!0);try{const t=await(await C("/api/student/search-teachers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:o})})).json();J(t.teachers||[])}catch(s){console.error("Search error:",s)}finally{N(!1)}}},$=s=>{f(s),h(2)},B=async()=>{if(!(!c||!u.trim()||!m.trim())){y(!0);try{const t=await(await C("/api/student/activate-classroom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teacher_id:c.id,access_key:m.trim()})})).json();t.success&&t.classroom?(L(t.classroom.id),P(t.classroom.name),h(3)):alert(t.error||"Failed to join classroom")}catch(s){console.error("Join error:",s)}finally{y(!1)}}},E=()=>{d(p?`/classroom/${p}`:"/dashboard")},i=[{icon:e.jsx(k,{className:"h-6 w-6"}),title:a("onboarding.student.step1.title"),subtitle:a("onboarding.student.step1.subtitle")},{icon:e.jsx(X,{className:"h-6 w-6"}),title:a("classroom.join.title"),subtitle:a("classroom.join.subtitle")},{icon:e.jsx(Y,{className:"h-6 w-6"}),title:a("onboarding.student.step2.title"),subtitle:a("onboarding.student.step2.subtitle")}];return e.jsxs("div",{className:"min-h-screen bg-background font-mono relative",children:[e.jsx(M,{}),e.jsxs("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center p-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-8",children:i.map((s,t)=>e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold transition-colors ${t+1<=l?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground"}`,children:t+1<l?e.jsx(Z,{className:"h-4 w-4"}):t+1}),t<i.length-1&&e.jsx("div",{className:`w-12 h-1 mx-1 transition-colors ${t+1<l?"bg-primary":"bg-secondary"}`})]},t))}),e.jsxs(R,{className:"w-full max-w-md bg-card/80 backdrop-blur-sm",children:[e.jsxs(z,{className:"text-center",children:[e.jsx("div",{className:"mx-auto p-3 rounded-full bg-primary/20 mb-2",children:i[l-1].icon}),e.jsx(H,{children:i[l-1].title}),e.jsx(W,{children:i[l-1].subtitle})]}),e.jsxs(G,{className:"space-y-4",children:[l===1&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:o,onChange:s=>F(s.target.value),placeholder:a("search.teacher.placeholder"),onKeyDown:s=>s.key==="Enter"&&v()}),e.jsx(n,{onClick:v,disabled:x||!o.trim(),children:x?e.jsx(w,{className:"h-4 w-4 animate-spin"}):e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:[g.length===0&&o&&!x&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:a("search.no.results")}),g.map(s=>e.jsxs("button",{onClick:()=>$(s),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-secondary/50 transition-colors text-left",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url?.startsWith("/api/")?`${Q}${s.avatar_url}`:s.avatar_url,alt:s.name,className:"w-10 h-10 rounded-full object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(I,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email})]})]},s.id))]}),e.jsxs(n,{variant:"outline",onClick:()=>d("/onboarding"),className:"w-full",children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),a("back")]})]}),l===2&&c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(I,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:c.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.email})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"classroom-id",children:a("classroom.id")}),e.jsx(j,{id:"classroom-id",value:u,onChange:s=>_(s.target.value),placeholder:a("classroom.id.placeholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"access-key",children:a("access.code")}),e.jsx(j,{id:"access-key",value:m,onChange:s=>K(s.target.value.toUpperCase()),placeholder:a("access.code.placeholder"),className:"font-mono tracking-wider"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>{h(1),f(null)},className:"flex-1",children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),a("back")]}),e.jsxs(n,{onClick:B,disabled:b||!u.trim()||!m.trim(),className:"flex-1",children:[b?e.jsx(w,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(A,{className:"mr-2 h-4 w-4"}),a("join")]})]})]}),l===3&&p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-secondary/50 rounded-lg p-4 text-center",children:[e.jsx(V,{className:"h-8 w-8 text-primary mx-auto mb-2"}),e.jsx("p",{className:"font-medium",children:O||"Classroom"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a("classroom.activated.success")})]}),e.jsxs(n,{onClick:E,className:"w-full",children:[a("onboarding.finish"),e.jsx(A,{className:"ml-2 h-4 w-4"})]})]})]})]}),e.jsx(n,{variant:"ghost",className:"mt-4 text-muted-foreground",onClick:()=>
1d("/dashboard"),children:a("onboarding.skip")})]})]})}export{ce 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.