openlearn-next 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityWorkspaceWidget-5PzyxF6a.js → ActivityWorkspaceWidget-CMN8elwQ.js} +1 -1
- package/dist/assets/{AdminDirectoryView-BCtmQTEK.js → AdminDirectoryView-Dlz7q-xf.js} +1 -1
- package/dist/assets/{AssessmentCenter-B43ojHG-.js → AssessmentCenter-CaoAI9Ke.js} +1 -1
- package/dist/assets/{BatchPickerModal-CbmjInp7.js → BatchPickerModal-CzutdtIz.js} +1 -1
- package/dist/assets/{ClassesView-DEnMaDOt.js → ClassesView-RkFPpWRu.js} +1 -1
- package/dist/assets/{ClassroomCountdownWidget-CHq4983w.js → ClassroomCountdownWidget-gs42lIGW.js} +1 -1
- package/dist/assets/{CloudDriveModal-D2t3Uyzr.js → CloudDriveModal-C6JtK08M.js} +1 -1
- package/dist/assets/{ComputerLabView-YtnoT5Rb.js → ComputerLabView-Dr-g8FrU.js} +1 -1
- package/dist/assets/{CourseManagement-DOXyJ_j-.js → CourseManagement-DNeaJcT9.js} +1 -1
- package/dist/assets/{CourseWizardModal-Dbi6Caw2.js → CourseWizardModal-vw876VJr.js} +1 -1
- package/dist/assets/{Dashboard-2rLu_ZBy.js → Dashboard-C1iYnfCh.js} +1 -1
- package/dist/assets/{ExportWeightModal-BrmAh6VX.js → ExportWeightModal-CTZ-O_wi.js} +1 -1
- package/dist/assets/{HelpView-CVBrKDrd.js → HelpView-wyKldm_R.js} +1 -1
- package/dist/assets/{ImportLessonsModal-PhHtX31R.js → ImportLessonsModal-C09Z-qtx.js} +1 -1
- package/dist/assets/{InteractiveCoursewareViewer-Vi6lLz7a.js → InteractiveCoursewareViewer-V97euiJF.js} +1 -1
- package/dist/assets/{InteractiveWhiteboard-lTzeayX5.js → InteractiveWhiteboard-COLMh_-w.js} +1 -1
- package/dist/assets/{LazyCourseware-KIt0rGtW.js → LazyCourseware-0iFYlRGj.js} +2 -2
- package/dist/assets/{LazyWhiteboard-CCN3pYcW.js → LazyWhiteboard-CcoBIx6V.js} +2 -2
- package/dist/assets/{LessonEditorView-D_GVhHuM.js → LessonEditorView-BWmtKwmP.js} +1 -1
- package/dist/assets/{LiveClassroomView-BRsZ6QEq.js → LiveClassroomView-CaS1DzSS.js} +1 -1
- package/dist/assets/{NotificationDetailModal-tY5rxYCN.js → NotificationDetailModal-4MdNF4tw.js} +1 -1
- package/dist/assets/{PluginView-CedpAW6d.js → PluginView-BqTbAp30.js} +1 -1
- package/dist/assets/{QuizGeneratorModal-bUA002kP.js → QuizGeneratorModal-xTq22vDq.js} +1 -1
- package/dist/assets/{StudentAssignmentView-BhAz6Hfk.js → StudentAssignmentView-Cy_JdPYB.js} +1 -1
- package/dist/assets/{StudentLessonView-DC1yX4kG.js → StudentLessonView-B3fKejCU.js} +1 -1
- package/dist/assets/{StudentView-PHKxIV9T.js → StudentView-CpJsG7FT.js} +2 -2
- package/dist/assets/{SystemResourceLibraryModal-DgXYe6_x.js → SystemResourceLibraryModal-YZ85mv_v.js} +1 -1
- package/dist/assets/{TeacherView-DscJtOJ9.js → TeacherView-B3zhzd5g.js} +2 -2
- package/dist/assets/{TimetableView-D2ozoj_D.js → TimetableView-D_4XmrRN.js} +1 -1
- package/dist/assets/{index-2676X8YB.js → index-BzXADCXZ.js} +5 -5
- package/dist/assets/{pluginParsers-e4PSm2Iy.js → pluginParsers-PzgFzxS9.js} +1 -1
- package/dist/cli-migrator.cjs +18 -1
- package/dist/index.html +1 -1
- package/dist/server.cjs +339 -249
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StudentView-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StudentView-CpJsG7FT.js","assets/vendor-react-Kv_JATwr.js","assets/vendor-utils-aM7aYvPP.js","assets/vendor-icons-CXrZ3R2V.js","assets/vendor-motion-BFAPOs-b.js","assets/TeacherView-B3zhzd5g.js","assets/ImportModal-DqjqNeH4.js","assets/CourseWizardModal-vw876VJr.js","assets/ImportLessonsModal-C09Z-qtx.js","assets/QuizGeneratorModal-xTq22vDq.js","assets/ProcessLogsModal-Cfr-T9Gd.js","assets/CloudDriveModal-C6JtK08M.js","assets/LazyCourseware-0iFYlRGj.js","assets/SystemResourceLibraryModal-YZ85mv_v.js","assets/BatchPickerModal-CzutdtIz.js","assets/ExportWeightModal-CTZ-O_wi.js","assets/NotificationDetailModal-4MdNF4tw.js","assets/HelpTour-D_q1z_MI.js","assets/CoursewareHubPanel-CyxDIJAF.js","assets/ActivityWorkspaceWidget-CMN8elwQ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as f,j as r,R as De,u as Fc,g as Bc,b as kp,d as Wi,h as qi,J as Ba,i as Ua,k as Cp}from"./vendor-react-Kv_JATwr.js";import{G as xr,S as Np,U as Uc,C as br,a as vs,L as Gi,A as yr,b as Ep,c as $t,K as Lo,d as zr,X as Oe,e as Vc,T as Mt,P as Hc,I as wr,E as Wc,R as Lr,f as Cn,g as qc,h as Tp,i as Ro,j as Pp,H as Ip,F as _o,M as Ap,k as Oo,l as Qi,m as Do,n as Gc,o as at,p as vr,q as Mo,r as Qc,s as zp,t as Lp,u as Ns,v as Kr,w as Jc,D as Ji,x as Rp,W as Ki,y as _p,z as yt,B as Rr,J as Yi,N as Op,O as Kc,Q as Va,V as Yc,Y as Dp,Z as Mp,_ as Zc,$ as Es,a0 as $p,a1 as Fp,a2 as $o,a3 as Bp,a4 as Fo,a5 as Up,a6 as Nn,a7 as Zi,a8 as Ha,a9 as ht,aa as Vp,ab as Xc,ac as _r,ad as ed,ae as Hp,af as vn,ag as Wp,ah as qp,ai as Gp,aj as Qp,ak as Bo,al as td,am as Jp,an as Ss,ao as Xi,ap as Kp,aq as Yp,ar as Yr,as as Xs,at as Zp,au as Xp,av as eg,aw as tg,ax as ng,ay as Uo,az as sg,aA as rg,aB as ig,aC as og,aD as ag,aE as lg,aF as cg}from"./vendor-icons-CXrZ3R2V.js";import{f as St,h as Ft,j as Vo}from"./vendor-utils-aM7aYvPP.js";import{_ as Je}from"./vendor-pdf-C1Vh2Aqq.js";import{i as Zr,g as dg,s as nd,a as Ho,b as sd,c as Wa,d as ug,e as hg,f as fg,h as mg,r as pg,j as gg,k as rd,l as xg,m as bg,n as yg,o as wg,S as vg,H as Sg,F as Bt,p as jg,q as kg,t as id,u as Sr,v as qa,w as ft,x as od,y as Cg,z as Ga,A as Ng,B as jr,C as eo,D as Qa,E as Eg,G as Tg,I as zt,J as Pg,K as Ig,L as Ag,M as Ja,N as zg,O as Lg,P as Ka,Q as Rg,R as _g,T as er,U as Og,V as Dg,W as ad,X as Mg,Y as $g}from"./vendor-motion-BFAPOs-b.js";import{R as Ya}from"./vendor-charts-SrpBsvM3.js";const Wo=f.createContext(null);function _s({value:e,children:t}){return r.jsx(Wo.Provider,{value:e,children:t})}function CN(){const e=f.useContext(Wo);if(!e)throw new Error("useAppData must be used within <AppDataProvider>");return e}function nn(){return f.useContext(Wo)}async function Fg(){const e=await fetch("/api/resources");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function Bg(){const e=await fetch("/api/db-status");let t;try{t=await e.json()}catch{t={}}return{ok:e.ok,status:e.status,data:t}}async function Ug(){const e=await fetch("/api/auth/session");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function ld(){const e=await fetch("/api/site-settings");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function Vg(){await fetch("/api/auth/logout",{method:"POST"})}const cd=f.createContext(null),to="openlearn_academic_year";function Hg(){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search).get("academicYear");return t||null}function Wg(){if(typeof window>"u")return null;try{return window.localStorage.getItem(to)}catch{return null}}function qg(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(to,e):window.localStorage.removeItem(to)}catch{}}function Os({children:e}){const[t,n]=f.useState(()=>Hg()||Wg()||null),[s,i]=f.useState(null),[o,a]=f.useState(!0);f.useEffect(()=>{let u=!0;return(async()=>{try{const m=await ld();if(!u)return;if(m.ok&&m.data){const p=m.data.currentAcademicYear||null;i(p),!t&&p&&n(p)}}catch{}finally{u&&a(!1)}})(),()=>{u=!1}},[]);const l=u=>{const m=u==="all"?null:u;if(n(m),qg(m),typeof window<"u"){const p=new URL(window.location.href);m?p.searchParams.set("academicYear",m):p.searchParams.delete("academicYear"),window.history.replaceState({},"",p.toString())}},c=t==="all"||t===null?null:t,d=f.useMemo(()=>({academicYear:t,setAcademicYear:l,apiAcademicYear:c,currentAcademicYear:s,loading:o}),[t,c,s,o]);return r.jsx(cd.Provider,{value:d,children:e})}function Gg(){return f.useContext(cd)}function En(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:[]}const Qg=De.memo(function({onLoginSuccess:t,lang:n}){const[s,i]=f.useState("teacher"),[o,a]=f.useState(null),[l,c]=f.useState(""),[d,u]=f.useState(""),[m,p]=f.useState(""),[h,x]=f.useState(!1),[g,b]=f.useState([]),[w,y]=f.useState(""),[S,C]=f.useState(""),[k,v]=f.useState(""),[N,O]=f.useState(""),[D,_]=f.useState(!1);f.useEffect(()=>{(async()=>{try{const $=await fetch("/api/students?pageSize=all");if($.ok){const I=En(await $.json());b(I),I.length>0&&y(I[0].id)}}catch($){console.warn("Failed to fetch student roster for login selection:",$)}})()},[]),f.useEffect(()=>{(async()=>{try{const $=await fetch("/api/site-settings");if($.ok){const I=await $.json();a(I)}}catch($){console.warn("Failed to fetch site settings for login branding:",$)}})()},[]);const T=async R=>{if(R.preventDefault(),!l.trim()||!d){p(n==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{p(""),x(!0);const $=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:l.trim(),password:d})});if($.ok){const I=await $.json();t(I.session)}else{const I=await $.json();p(I.error||(n==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{p(n==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{x(!1)}},z=async R=>{R.preventDefault();const $=w||S.trim();if(!$){O(n==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!k.trim()){O(n==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{O(""),_(!0);const I=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:$,password:k.trim()})});if(I.ok){const B=await I.json();t(B.session)}else{const B=await I.json();O(B.error||(n==="zh"?"找不到该学生记录":"Student record not found"))}}catch{O(n==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{_(!1)}};return r.jsxs("div",{className:"min-h-screen bg-slate-900 flex flex-col items-center justify-center p-4 relative overflow-hidden font-sans",id:"login_page_container",children:[r.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),r.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),r.jsxs("div",{className:"w-full max-w-md bg-slate-950/85 backdrop-blur-md rounded-2xl border border-slate-800 shadow-2xl p-6 sm:p-8",id:"login_card",children:[r.jsxs("div",{className:"text-center mb-8",children:[o?.logoUrl?r.jsx("img",{src:o.logoUrl,alt:o.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):r.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-gradient-to-tr from-indigo-500 to-indigo-600 rounded-2xl shadow-lg border border-indigo-400/20 mb-4 text-white",children:r.jsx(xr,{size:32})}),r.jsxs("h1",{className:"text-2xl sm:text-3xl font-black text-white tracking-tight flex items-center justify-center gap-2",children:[o?.siteName||"OpenLearn Next"," ",r.jsx("span",{className:"text-indigo-400 font-medium text-xs bg-indigo-500/20 px-2 py-0.5 rounded-full border border-indigo-400/20",children:"V2.0"})]}),r.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:o?.slogan||(n==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),r.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[r.jsxs("button",{onClick:()=>i("teacher"),className:`flex-1 py-2.5 rounded-lg text-xs font-bold transition-all duration-200 flex items-center justify-center gap-2 focus:outline-none ${s==="teacher"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[r.jsx(Np,{size:14}),n==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),r.jsxs("button",{onClick:()=>i("student"),className:`flex-1 py-2.5 rounded-lg text-xs font-bold transition-all duration-200 flex items-center justify-center gap-2 focus:outline-none ${s==="student"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[r.jsx(Uc,{size:14}),n==="zh"?"学生自助端":"Student Self-Service"]})]}),s==="teacher"?r.jsxs("form",{onSubmit:T,className:"space-y-4",children:[m&&r.jsxs("div",{className:"p-3 bg-red-950/50 border border-red-800 text-red-300 text-xs rounded-xl flex items-center gap-2",children:[r.jsx(br,{size:15,className:"shrink-0"}),r.jsx("span",{children:m})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[r.jsx(vs,{size:13}),n==="zh"?"教工账户名 / username":"Staff Username"]}),r.jsx("input",{type:"text",value:l,onChange:R=>c(R.target.value),placeholder:n==="zh"?"输入教工账户名":"Enter staff username",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors",required:!0})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[r.jsx(Gi,{size:13}),n==="zh"?"输入登录密码 / password":"Access Password"]}),r.jsx("input",{type:"password",value:d,onChange:R=>u(R.target.value),placeholder:n==="zh"?"输入登录密码":"Enter access password",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors",required:!0})]}),r.jsxs("button",{type:"submit",disabled:h,className:"w-full mt-6 bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-500 hover:to-violet-500 disabled:opacity-50 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm flex items-center justify-center gap-2 transition-all duration-200 cursor-pointer shadow-lg shadow-indigo-600/20 active:scale-[0.98]",children:[r.jsx("span",{children:h?n==="zh"?"鉴权登录中...":"Authorizing...":n==="zh"?"安全验证登录":"Authorized Sign In"}),r.jsx(yr,{size:15})]})]}):r.jsxs("form",{onSubmit:z,className:"space-y-4",children:[N&&r.jsxs("div",{className:"p-3 bg-red-950/50 border border-red-800 text-red-300 text-xs rounded-xl flex items-center gap-2",children:[r.jsx(br,{size:15,className:"shrink-0"}),r.jsx("span",{children:N})]}),g.length>0?r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[r.jsx(xr,{size:14}),n==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),r.jsx("select",{value:w,onChange:R=>{y(R.target.value),C("")},className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none transition-colors cursor-pointer",children:g.map(R=>r.jsxs("option",{value:R.id,children:[R.name," (",R.student_number||R.id,")"]},R.id))}),r.jsx("p",{className:"text-xs text-slate-500 font-medium",children:n==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,r.jsxs("div",{className:"relative flex py-2 items-center",children:[r.jsx("div",{className:"flex-grow border-t border-slate-850"}),r.jsx("span",{className:"flex-shrink mx-3 text-xs font-bold text-slate-500 uppercase tracking-wider",children:n==="zh"?"或手动输入学号":"Or input key manually"}),r.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[r.jsx(vs,{size:13}),n==="zh"?"学号 / Student ID":"Student Access Key"]}),r.jsx("input",{type:"text",value:S,onChange:R=>{C(R.target.value),y("")},placeholder:n==="zh"?"手工输入您的特有学号":"Enter specific numeric ID code",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[r.jsx(Gi,{size:13}),n==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),r.jsx("input",{type:"password",required:!0,value:k,onChange:R=>v(R.target.value),placeholder:n==="zh"?"输入个人密码或临时班级密码":"Enter personal password or class passcode",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors"})]}),r.jsxs("button",{type:"submit",disabled:D,className:"w-full mt-6 bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-500 hover:to-violet-500 disabled:opacity-50 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm flex items-center justify-center gap-2 transition-all duration-200 cursor-pointer shadow-lg shadow-indigo-600/20 active:scale-[0.98]",children:[r.jsx("span",{children:D?n==="zh"?"正在连接学生终端...":"Entering Desk...":n==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),r.jsx(yr,{size:15})]})]})]})]})});function Jg({lang:e,username:t,onDone:n,onLogout:s}){const[i,o]=f.useState(""),[a,l]=f.useState(""),[c,d]=f.useState(""),[u,m]=f.useState(null),[p,h]=f.useState(!1),x=e==="zh",g=()=>!i||!a||!c?x?"请填写完整":"All fields are required":a.length<8?x?"新密码至少 8 位":"Password must be at least 8 characters long":!/[a-zA-Z]/.test(a)||!/[0-9]/.test(a)?x?"新密码需同时包含字母和数字":"Password must contain both letters and numbers":a===i?x?"新密码不能与当前密码相同":"New password must differ from the current one":a!==c?x?"两次输入的新密码不一致":"Passwords do not match":null,b=async()=>{const y=g();if(y){m(y);return}h(!0),m(null);try{const S=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:i,newPassword:a})}),C=await S.json().catch(()=>({}));if(!S.ok){m(C.error||(x?"修改失败,请重试":"Change failed, please retry"));return}n()}catch{m(x?"网络异常,请重试":"Network error, please retry")}finally{h(!1)}},w="w-full px-3 py-2 rounded-lg bg-white border border-slate-300 text-sm text-slate-800 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent";return r.jsx("div",{className:"min-h-screen bg-slate-900 flex flex-col items-center justify-center p-4 font-sans",children:r.jsxs("div",{className:"w-full max-w-md bg-white rounded-2xl shadow-xl p-6",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[r.jsx("div",{className:"p-2 rounded-lg bg-amber-100",children:r.jsx(Ep,{size:20,className:"text-amber-600"})}),r.jsx("h1",{className:"text-lg font-bold text-slate-800",children:x?"安全要求:修改默认密码":"Security: Change Default Password"})]}),r.jsx("p",{className:"text-xs text-slate-500 leading-relaxed mb-5",children:x?`当前账号${t?`(${t})`:""}仍在使用初始默认密码,存在被接管的风险。请设置新密码后继续使用平台;修改前所有数据变更已被暂时冻结。`:`This account${t?` (${t})`:""} still uses the initial default password. Set a new password to continue; data changes are frozen until then.`}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-slate-600 mb-1",children:x?"当前密码":"Current password"}),r.jsx("input",{type:"password",value:i,onChange:y=>o(y.target.value),className:w,autoComplete:"current-password"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-slate-600 mb-1",children:x?"新密码(至少 8 位,含字母和数字)":"New password (8+ chars, letters & numbers)"}),r.jsx("input",{type:"password",value:a,onChange:y=>l(y.target.value),className:w,autoComplete:"new-password"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-slate-600 mb-1",children:x?"确认新密码":"Confirm new password"}),r.jsx("input",{type:"password",value:c,onChange:y=>d(y.target.value),className:w,autoComplete:"new-password"})]})]}),u&&r.jsx("div",{"data-testid":"force-change-error",className:"mt-3 text-xs text-red-600 bg-red-50 border border-red-200 rounded-lg px-3 py-2",children:u}),r.jsxs("button",{type:"button",onClick:b,disabled:p,"data-testid":"force-change-submit",className:"mt-5 w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-indigo-600 hover:bg-indigo-700 disabled:opacity-60 text-white text-sm font-semibold transition-colors cursor-pointer",children:[p?r.jsx($t,{size:16,className:"animate-spin"}):r.jsx(Lo,{size:16}),x?"修改密码并继续":"Change password and continue"]}),r.jsxs("button",{type:"button",onClick:s,className:"mt-2 w-full flex items-center justify-center gap-2 px-4 py-2 rounded-lg text-slate-500 hover:text-slate-700 hover:bg-slate-100 text-xs font-medium transition-colors cursor-pointer",children:[r.jsx(zr,{size:13}),x?"退出登录":"Log out"]})]})})}async function Kg(){const e=await fetch("/api/lessons?pageSize=all");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function Yg(e){const t=await fetch("/api/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?{ok:!0,data:await t.json().catch(()=>({}))}:{ok:!1}}async function Zg(e){const t=await fetch(`/api/lessons/${e}`,{method:"DELETE"});return t.ok?{ok:!0,data:await t.json().catch(()=>({}))}:{ok:!1,data:await t.json().catch(()=>({}))}}async function Xg(e){const t=await fetch(`/api/lessons/${e}/clone`,{method:"POST"});return t.ok?{ok:!0,data:await t.json().catch(()=>({}))}:{ok:!1,data:await t.json().catch(()=>({}))}}async function ex(e){const t=await fetch(`/api/lessons/${e}/whiteboard`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}const tx=(e,t)=>({lessons:[],selectedLesson:null,elements:[],vfsNodes:[],setLessons:n=>e(s=>({lessons:typeof n=="function"?n(s.lessons):n})),setSelectedLesson:n=>e({selectedLesson:n}),setElements:n=>e({elements:n}),setVfsNodes:n=>e({vfsNodes:n}),loadLessons:async()=>{try{const{ok:n,data:s}=await Kg();if(n){const i=En(s);e(o=>({lessons:i,selectedLesson:o.selectedLesson??(nx(t())&&i.length>0?i[0].id:o.selectedLesson)}))}}catch(n){console.warn("Failed to fetch lessons",n)}}});function nx(e){return e.session?.role==="teacher"}async function sx(){const e=await fetch("/api/classes?pageSize=all");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function rx(){const e=await fetch("/api/students?pageSize=all");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function ix(e){const t=await fetch(`/api/classes/${e}/students`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}const ox=e=>({classes:[],students:[],classStudentsMap:{},classDashboardMap:{},studentProgressMap:{},classSchedulesMap:{},scheduleAttendanceMap:{},assignmentSubmissionsMap:{},classAssignmentsMap:{},classProgressMap:{},classSeats:{lab_id:null,seats:[]},dataVersion:0,setClasses:t=>e({classes:t}),setStudents:t=>e({students:t}),setClassStudents:(t,n)=>e(s=>({classStudentsMap:{...s.classStudentsMap,[t]:n}})),setClassDashboard:(t,n)=>e(s=>({classDashboardMap:{...s.classDashboardMap,[t]:n}})),setStudentProgress:(t,n)=>e(s=>({studentProgressMap:{...s.studentProgressMap,[t]:n}})),setClassSchedules:(t,n)=>e(s=>({classSchedulesMap:{...s.classSchedulesMap,[t]:n}})),setScheduleAttendance:(t,n)=>e(s=>({scheduleAttendanceMap:{...s.scheduleAttendanceMap,[t]:n}})),setAssignmentSubmissions:(t,n)=>e(s=>({assignmentSubmissionsMap:{...s.assignmentSubmissionsMap,[t]:n}})),setClassAssignments:(t,n)=>e(s=>({classAssignmentsMap:{...s.classAssignmentsMap,[t]:n}})),setClassProgress:(t,n)=>e(s=>({classProgressMap:{...s.classProgressMap,[t]:n}})),setClassSeats:t=>e({classSeats:t}),loadClasses:async()=>{try{const{ok:t,data:n}=await sx();t&&e(s=>({classes:En(n),dataVersion:s.dataVersion+1}))}catch(t){console.warn("Failed to fetch classes",t)}},loadStudents:async()=>{try{const{ok:t,data:n}=await rx();t&&e(s=>({students:En(n),dataVersion:s.dataVersion+1}))}catch(t){console.warn("Failed to fetch students",t)}}}),ax=e=>({liveClassSelectedClassId:null,liveClassIsActive:!1,liveClassFeed:[],liveClassTimeRemaining:0,liveClassAcknowledgedMap:new Map,liveClassStudentProgress:[],onlineStudentIds:[],activeStudentLessons:{},setLiveClassSelectedClassId:t=>e({liveClassSelectedClassId:t}),setLiveClassIsActive:t=>e({liveClassIsActive:t}),setLiveClassFeed:t=>e({liveClassFeed:t}),appendLiveClassFeed:t=>e(n=>({liveClassFeed:[...n.liveClassFeed.slice(-49),t]})),setLiveClassTimeRemaining:t=>e({liveClassTimeRemaining:t}),setLiveClassAcknowledgedMap:t=>e({liveClassAcknowledgedMap:t}),setLiveClassStudentProgress:t=>e({liveClassStudentProgress:t}),setOnlineStudentIds:t=>e({onlineStudentIds:t}),setActiveStudentLessons:t=>e({activeStudentLessons:t})}),lx=e=>({session:null,sessionLoading:!0,dbConnected:!1,setSession:t=>e({session:t}),setSessionLoading:t=>e({sessionLoading:t}),setDbConnected:t=>e({dbConnected:t})}),cx=e=>({aiProviders:[],plugins:[],registeredCommands:[],events:[],approvals:[],processes:[],todaySchedules:[],computerLabs:[],setAiProviders:t=>e({aiProviders:t}),setPlugins:t=>e({plugins:t}),setRegisteredCommands:t=>e({registeredCommands:t}),setEvents:t=>e({events:t}),setApprovals:t=>e({approvals:t}),setProcesses:t=>e({processes:t}),setTodaySchedules:t=>e({todaySchedules:t}),setComputerLabs:t=>e({computerLabs:t})}),dx=e=>({studentDashboardData:null,notifications:[],setStudentDashboardData:t=>e({studentDashboardData:t}),setNotifications:t=>e({notifications:t})});function dd(e){return"#/"+e}function ms(e){const t=e.replace(/^#/,"");return!t||t==="/"?null:t.replace(/^\//,"")}function ux(e){return window.location.pathname+window.location.search+dd(e)}function hx(e){const t=ux(e);window.open(t,"_blank","noopener,noreferrer")}function fx(){if(typeof window<"u"&&window.location?.hash){const e=ms(window.location.hash);if(e)return e}return"live_class"}const Ve=St(e=>({lang:"zh",activeRole:"teacher",teacherTab:fx(),pendingTimetableSubTab:null,pendingLiveClassLaunch:null,profileOpen:!1,isCourseWizardOpen:!1,isImportLessonsOpen:!1,isQuizGeneratorOpen:!1,isSystemResourceLibraryOpen:!1,batchPicker:null,isExportWeightModalOpen:!1,toasts:[],siteInfo:{siteName:"",slogan:"",logoUrl:null},setLang:t=>e({lang:t}),setActiveRole:t=>e({activeRole:t}),setTeacherTab:t=>e({teacherTab:t}),setPendingTimetableSubTab:t=>e({pendingTimetableSubTab:t}),setPendingLiveClassLaunch:t=>e({pendingLiveClassLaunch:t}),setProfileOpen:t=>e({profileOpen:t}),setIsCourseWizardOpen:t=>e({isCourseWizardOpen:t}),setIsImportLessonsOpen:t=>e({isImportLessonsOpen:t}),setIsQuizGeneratorOpen:t=>e({isQuizGeneratorOpen:t}),setIsSystemResourceLibraryOpen:t=>e({isSystemResourceLibraryOpen:t}),setBatchPicker:t=>e({batchPicker:t}),setIsExportWeightModalOpen:t=>e({isExportWeightModalOpen:t}),addToast:t=>e(n=>({toasts:[...n.toasts,t]})),removeToast:t=>e(n=>({toasts:n.toasts.filter(s=>s.id!==t)})),setSiteInfo:t=>e({siteInfo:t})})),mx=e=>Ft(Ve,e),px=e=>({lang:Ve.getState().lang,teacherTab:Ve.getState().teacherTab,toasts:Ve.getState().toasts,siteInfo:Ve.getState().siteInfo,setLang:t=>{Ve.getState().setLang(t),e({lang:t})},setTeacherTab:t=>{Ve.getState().setTeacherTab(t),e({teacherTab:t})},addToast:t=>{Ve.getState().addToast(t),e({toasts:Ve.getState().toasts})},removeToast:t=>{Ve.getState().removeToast(t),e({toasts:Ve.getState().toasts})},setSiteInfo:t=>{Ve.getState().setSiteInfo(t),e({siteInfo:t})}}),ve=St()((...e)=>({...tx(...e),...ox(...e),...ax(...e),...lx(...e),...cx(...e),...dx(...e),...px(...e)})),de=e=>Ft(ve,e);class gx{constructor(){this.handlers=new Map,this.subscribers=new Map,this.middlewares=[],this.activeModals=[],this.modalListeners=new Set,this.registerBuiltinHandlers()}async dispatch(t,n){const s="act_"+Math.random().toString(36).slice(2,10),i={action:t,sourcePluginId:n?.sourcePluginId,timestamp:Date.now(),correlationId:s},o=async()=>{const c=this.handlers.get(t.type);if(c&&c.size>0){const d=Array.from(c);if(d.length===1)return await d[0](i);const u=await Promise.all(d.map(m=>m(i)));if(t.type==="host:refresh"){const m=new Set;for(const p of u)p&&Array.isArray(p.refreshed)&&p.refreshed.forEach(h=>m.add(h));return{success:!0,refreshed:Array.from(m)}}return u[u.length-1]}};let l=(async()=>{let c=-1;const d=async u=>{if(u<=c)throw new Error("next() called multiple times in middleware");if(c=u,u<this.middlewares.length){const m=this.middlewares[u];return m(i,()=>d(u+1))}return o()};return d(0)})();if(n?.timeoutMs&&n.timeoutMs>0){let c;const d=new Promise((u,m)=>{c=setTimeout(()=>{m(new Error(`Action "${t.type}" timed out after ${n.timeoutMs}ms`))},n.timeoutMs)});l=Promise.race([l,d]).finally(()=>{clearTimeout(c)})}try{const c=await l;return this.notifySubscribers(i,c,void 0),c}catch(c){throw this.notifySubscribers(i,void 0,c),c}}registerHandler(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const s=this.handlers.get(t);return s.add(n),{dispose:()=>{s.delete(n),s.size===0&&this.handlers.delete(t)}}}subscribe(t,n){this.subscribers.has(t)||this.subscribers.set(t,new Set);const s=this.subscribers.get(t);return s.add(n),{dispose:()=>{s.delete(n),s.size===0&&this.subscribers.delete(t)}}}use(t){return this.middlewares.push(t),{dispose:()=>{const n=this.middlewares.indexOf(t);n!==-1&&this.middlewares.splice(n,1)}}}getActiveModals(){return[...this.activeModals]}subscribeModals(t){return this.modalListeners.add(t),t(this.getActiveModals()),{dispose:()=>{this.modalListeners.delete(t)}}}resolveModal(t,n){const s=this.activeModals.findIndex(i=>i.id===t);if(s!==-1){const[i]=this.activeModals.splice(s,1);i.resolve(n),this.notifyModalListeners()}}closeAllModals(){for(;this.activeModals.length>0;)this.activeModals.pop().resolve({closed:!0,confirmed:!1});this.notifyModalListeners()}notifyModalListeners(){const t=this.getActiveModals();this.modalListeners.forEach(n=>{try{n(t)}catch(s){console.error("[HostActionDispatcher] Error notifying modal listener:",s)}})}createScopedDispatcher(t){return{dispatch:(n,s)=>this.dispatch(n,{sourcePluginId:t,...s}),registerHandler:(n,s)=>this.registerHandler(n,s),subscribe:(n,s)=>this.subscribe(n,s),use:n=>this.use(n)}}registerBuiltinHandlers(){this.registerHandler("host:refresh",async t=>{const s=t.action.payload.target,i=[];try{const a=ve.getState();(s==="classes"||s==="all")&&typeof a.loadClasses=="function"&&(await a.loadClasses(),i.push("classes")),(s==="lessons"||s==="all")&&typeof a.loadLessons=="function"&&(await a.loadLessons(),i.push("lessons")),(s==="students"||s==="all")&&typeof a.loadStudents=="function"&&(await a.loadStudents(),i.push("students"))}catch(a){console.warn("[HostActionDispatcher] Builtin refresh failed:",a)}return{success:!0,refreshed:i}}),this.registerHandler("host:modal:confirm",t=>{const n=t.action.payload,s=n.id||"modal_confirm_"+Math.random().toString(36).slice(2,9);return new Promise(i=>{const o={id:s,type:"confirm",title:n.title,message:n.message,confirmText:n.confirmText,cancelText:n.cancelText,variant:n.variant||"primary",sourcePluginId:t.sourcePluginId,createdAt:Date.now(),resolve:a=>{const l=typeof a?.confirmed=="boolean"?a.confirmed:!1;i({confirmed:l})}};this.activeModals.push(o),this.notifyModalListeners()})}),this.registerHandler("host:modal:open",t=>{const n=t.action.payload,s=n.id||"modal_open_"+Math.random().toString(36).slice(2,9);return new Promise(i=>{const o={id:s,type:"open",title:n.title,content:n.content,size:n.size||"md",showCloseButton:n.showCloseButton!==!1,closableByBackdrop:n.closableByBackdrop!==!1,actions:n.actions,sourcePluginId:t.sourcePluginId,createdAt:Date.now(),resolve:a=>{i({actionId:a?.actionId,closed:a?.closed??!0})}};this.activeModals.push(o),this.notifyModalListeners()})}),this.registerHandler("host:modal:close",t=>{const n=t.action.payload;if(n.id)this.resolveModal(n.id,n.result??{closed:!0});else if(this.activeModals.length>0){const s=this.activeModals[this.activeModals.length-1];this.resolveModal(s.id,n.result??{closed:!0})}return{closed:!0}}),this.registerHandler("host:toast",t=>{const n=t.action.payload,s="toast_"+Math.random().toString(36).slice(2,9);try{ve.getState().addToast({id:s,title:n.title,message:n.message,type:n.type||"info"})}catch(o){console.warn("[HostActionDispatcher] Failed to add toast:",o)}return{delivered:!0}}),this.registerHandler("host:navigate",t=>{const n=t.action.payload;try{ve.getState().setTeacherTab(n.tab)}catch(i){console.warn("[HostActionDispatcher] Failed to navigate:",i)}return{navigated:!0}})}notifySubscribers(t,n,s){const i=o=>{o&&o.forEach(a=>{try{a(t,n,s)}catch(l){console.error("[HostActionDispatcher] Subscriber threw error:",l)}})};i(this.subscribers.get(t.action.type)),i(this.subscribers.get("*"))}}const ud=new gx,xx=({dispatcher:e})=>{const t=e||ud,[n,s]=f.useState([]);if(f.useEffect(()=>{const g=t;if(typeof g.subscribeModals=="function"){const b=g.subscribeModals(w=>{s([...w])});return()=>{b.dispose()}}},[t]),f.useEffect(()=>{if(n.length===0)return;const g=b=>{if(b.key==="Escape"){const w=n[n.length-1],y=t;y.resolveModal&&(w.type==="confirm"?y.resolveModal(w.id,{confirmed:!1}):y.resolveModal(w.id,{closed:!0}))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[n,t]),n.length===0)return null;const i=n[n.length-1],o=t,a=()=>{o.resolveModal?.(i.id,{confirmed:!0})},l=()=>{o.resolveModal?.(i.id,{confirmed:!1})},c=()=>{i.type==="confirm"?o.resolveModal?.(i.id,{confirmed:!1}):o.resolveModal?.(i.id,{closed:!0})},d=(g,b)=>{o.resolveModal?.(i.id,{actionId:g,closed:!!b})},m={sm:"max-w-sm",md:"max-w-md",lg:"max-w-xl",xl:"max-w-3xl",full:"max-w-5xl"}[i.size||"md"]||"max-w-md",p=()=>{switch(i.variant){case"danger":return r.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 text-red-600 flex items-center justify-center shrink-0",children:r.jsx(Mt,{size:20})});case"warning":return r.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-100 text-amber-600 flex items-center justify-center shrink-0",children:r.jsx(br,{size:20})});case"primary":default:return r.jsx("div",{className:"w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0",children:r.jsx(Vc,{size:20})})}},h=()=>{switch(i.variant){case"danger":return"bg-red-600 hover:bg-red-700 text-white shadow-xs focus:ring-red-500";case"warning":return"bg-amber-600 hover:bg-amber-700 text-white shadow-xs focus:ring-amber-500";case"primary":default:return"bg-indigo-600 hover:bg-indigo-700 text-white shadow-xs focus:ring-indigo-500"}},x=g=>{switch(g){case"danger":return"bg-red-600 hover:bg-red-700 text-white";case"secondary":return"bg-gray-100 hover:bg-gray-200 text-gray-700";case"ghost":return"hover:bg-gray-100 text-gray-600";case"primary":default:return"bg-indigo-600 hover:bg-indigo-700 text-white"}};return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"host-modal-title",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs transition-opacity",onClick:g=>{g.target===g.currentTarget&&i.closableByBackdrop!==!1&&c()},children:r.jsxs("div",{className:`w-full ${m} bg-white rounded-2xl shadow-2xl border border-gray-100 overflow-hidden flex flex-col transform transition-all animate-in fade-in zoom-in-95 duration-150`,onClick:g=>g.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[i.type==="confirm"&&p(),r.jsx("h3",{id:"host-modal-title",className:"text-base font-bold text-gray-900 truncate",children:i.title})]}),i.showCloseButton!==!1&&r.jsx("button",{onClick:c,className:"p-1.5 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer","aria-label":"关闭",children:r.jsx(Oe,{size:18})})]}),r.jsx("div",{className:"px-6 py-4 overflow-y-auto max-h-[70vh]",children:i.type==="confirm"?r.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:i.message}):i.content}),r.jsx("div",{className:"flex items-center justify-end gap-2.5 px-6 py-3.5 bg-gray-50/80 border-t border-gray-100",children:i.type==="confirm"?r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:l,className:"px-4 py-2 text-xs font-bold text-gray-600 bg-white border border-gray-200 hover:bg-gray-50 rounded-xl transition-all cursor-pointer shadow-2xs",children:i.cancelText||"取消"}),r.jsx("button",{onClick:a,className:`px-4 py-2 text-xs font-bold rounded-xl transition-all cursor-pointer focus:outline-hidden focus:ring-2 focus:ring-offset-2 ${h()}`,children:i.confirmText||"确定"})]}):i.actions&&i.actions.length>0?i.actions.map(g=>r.jsx("button",{onClick:()=>d(g.actionId,g.isClose),className:`px-4 py-2 text-xs font-bold rounded-xl transition-all cursor-pointer ${x(g.variant)}`,children:g.label},g.actionId)):r.jsx("button",{onClick:c,className:"px-4 py-2 text-xs font-bold text-gray-600 bg-white border border-gray-200 hover:bg-gray-50 rounded-xl transition-all cursor-pointer shadow-2xs",children:"关闭"})})]})})},qo=f.createContext(null);function bx({children:e,host:t}){return r.jsxs(qo.Provider,{value:t,children:[e,r.jsx(xx,{dispatcher:t?.getDispatcher?.()})]})}function yx(){const e=f.useContext(qo);if(!e)throw new Error("usePluginHost must be used within PluginHostProvider");return e}function hd(){return f.useContext(qo)}typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("storage",e=>{e.key===Go&&Ne.setState({dashboardVisibility:fd()})});const Go="openlearn:dashboardVisibility";function fd(){try{const e=localStorage.getItem(Go);if(e)return new Map(JSON.parse(e))}catch{}return new Map}function Za(e){try{localStorage.setItem(Go,JSON.stringify([...e.entries()]))}catch{}}const Ne=Vo()((e,t)=>({activePlugins:[],extensionPoints:new Map,services:null,dashboardVisibility:fd(),pluginErrors:new Map,initialized:!1,initialize:n=>e({services:n,initialized:!0}),addPlugin:n=>e(s=>({activePlugins:[...s.activePlugins,n]})),removePlugin:n=>e(s=>({activePlugins:s.activePlugins.filter(i=>i.id!==n)})),updatePluginState:(n,s)=>e(i=>({activePlugins:i.activePlugins.map(o=>o.id===n?{...o,state:s}:o)})),registerExtensionPoint:(n,s)=>e(i=>{const o=i.extensionPoints.get(n)??[],a=o.find(c=>c.id===s.id);if(a){if(a.pluginId!==s.pluginId)return console.warn(`[PluginHost] Extension point "${n}/${s.id}" is owned by plugin "${a.pluginId}"; registration from "${s.pluginId}" was rejected (cross-plugin overwrite).`),i;const c=new Map(i.extensionPoints);return c.set(n,o.map(d=>d.id===s.id?s:d)),{extensionPoints:c}}const l=new Map(i.extensionPoints);return l.set(n,[...o,s]),{extensionPoints:l}}),unregisterExtensionPoint:(n,s,i)=>e(o=>{const a=o.extensionPoints.get(n);if(!a)return o;const l=a.find(u=>u.id===s);if(!l)return o;if(i&&l.pluginId!==i)return console.warn(`[PluginHost] Plugin "${i}" cannot unregister extension point "${n}/${s}" owned by "${l.pluginId}".`),o;const c=a.filter(u=>u.id!==s),d=new Map(o.extensionPoints);return c.length===0?d.delete(n):d.set(n,c),{extensionPoints:d}}),unregisterPluginExtensionPoints:n=>e(s=>{const i=new Map(s.extensionPoints);for(const[o,a]of i){const l=a.filter(c=>c.pluginId!==n);l.length===0?i.delete(o):i.set(o,l)}return{extensionPoints:i}}),unregisterPluginRuntimeExtensionPoints:n=>e(s=>{const i=new Map(s.extensionPoints);let o=!1;for(const[a,l]of i){const c=l.filter(d=>d.pluginId!==n||d.origin==="manifest");c.length!==l.length&&(o=!0,c.length===0?i.delete(a):i.set(a,c))}return o?{extensionPoints:i}:s}),getExtensions:n=>[...t().extensionPoints.get(n)??[]].sort((i,o)=>(i.position??100)-(o.position??100)),setDashboardVisibility:(n,s)=>e(i=>{const o=new Map(i.dashboardVisibility);return o.set(n,s),Za(o),{dashboardVisibility:o}}),setPluginError:(n,s)=>e(i=>{const o=new Map(i.pluginErrors);return o.set(n,s),{pluginErrors:o}}),clearPluginError:n=>e(s=>{if(!s.pluginErrors.has(n))return s;const i=new Map(s.pluginErrors);return i.delete(n),{pluginErrors:i}}),setDashboardVisibilityBatch:n=>e(s=>{const i=new Map(s.dashboardVisibility);for(const[o,a]of n)i.set(o,a);return Za(i),{dashboardVisibility:i}})}));function wx(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:image/")||e.startsWith("/")||e.startsWith("./")||/\.(svg|png|jpe?g|webp|gif|ico)(\?.*)?$/i.test(e)}function vx(e){return!(!e||e.length>8||/^[a-zA-Z0-9_-]+$/.test(e))}function Sx(e){if(!e)return null;const t=wr;if(t[e])return t[e];const n=e.split(/[-_\s]+/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("");return t[n]?t[n]:null}function un({icon:e,size:t=18,className:n="shrink-0",fallback:s=Hc,alt:i=""}){const[o,a]=f.useState(!1);if(!e)return r.jsx(s,{size:t,className:n});if(typeof e=="function"||typeof e=="object"&&e!==null&&"$$typeof"in e){const l=e;return r.jsx(l,{size:t,className:n})}if(typeof e=="string"){const l=e.trim();if(!l)return r.jsx(s,{size:t,className:n});if(wx(l))return o?r.jsx(s,{size:t,className:n}):r.jsx("img",{src:l,alt:i,style:{width:`${t}px`,height:`${t}px`},className:`object-contain rounded-xs ${n}`,onError:()=>a(!0),loading:"lazy"});if(vx(l))return r.jsx("span",{className:`inline-flex items-center justify-center font-normal leading-none select-none ${n}`,style:{fontSize:`${Math.round(t*.95)}px`,width:`${t}px`,height:`${t}px`},"aria-hidden":!i,title:i,children:l});const c=Sx(l);if(c)return r.jsx(c,{size:t,className:n})}return r.jsx(s,{size:t,className:n})}const Qo="zh",Ct={zh:{migratableBadge:"可迁移",migrateToFormat:"迁移到新格式",migrationPromptHeading:"发现可迁移的旧格式插件",migrationPromptBody:"该插件使用旧格式运行。上传新格式 ZIP 包以完成迁移,迁移后旧版本可安全卸载。",zipParseError:"ZIP 文件解析失败,请确认文件包含有效的 manifest.json",workerActivationError:"插件在 Worker 环境中激活失败,请检查插件代码与浏览器兼容性",extensionLoadError:"扩展组件加载失败",retry:"重新加载",noExtensionPoints:"暂无已注册的扩展组件",dropZipHere:"拖拽 ZIP 文件到此处",zipFileHint:"仅支持 .zip 格式的插件包",analyzing:"分析中...",dragActive:"释放以上传",legacyTooltip:"该插件使用旧执行格式运行。新格式版本可能可用。",ready:"就绪",uploadZipPlugin:"上传并安装 ZIP 插件",agentTitle:"内核助手",agentSubtitle:"自主 Shell 控制器",agentIntro:"你好!我是你的教育系统 OS 内核助手。你可以让我“创建一节物理课并在白板上画一个圆”,我将通过底层总线为你构建。",placeholder:"例如:创建一节历史课并画一张地图...",dashboard:"系统总览",kernelRunning:"系统正常运行",lessons:"课程",noLessons:"暂无课程。请让助手创建一节课!",noContent:"无内容...",whiteboardCanvas:"白板画布",emptyWhiteboard:"白板为空",simulationError:"系统错误:执行 OS 命令失败。",executedCommands:"执行的命令:",switchLang:"Switch to English",plugins:"插件中心",uploadPlugin:"上传并安装插件",pluginSource:"扩展插件源码 (JS)",installPlugin:"验证并安装",installing:"安装中...",installedPlugins:"已运行插件",noPlugins:"未发现第三方插件",lessonContent:"课程教案与笔记",eventStream:"内核审计事件流",selectLesson:"请先在左侧选择一节课程",systemLogs:"系统日志",hideLogs:"隐藏日志",showLogs:"显示日志",approvals:"待审批高危操作",approve:"批准",reject:"拒绝",noApprovals:"暂无待审批命令",fileSystem:"虚拟文件系统",noFiles:"当前目录为空",processes:"进程管理",noProcesses:"没有正在运行的进程",processLogs:"查看日志",classes:"班级管理",students:"学生管理",noClasses:"暂无班级",noStudents:"暂无学生",openInNewTab:"在新标签页打开"},en:{migratableBadge:"Migratable",migrateToFormat:"Migrate to New Format",migrationPromptHeading:"Legacy Plugin Detected",migrationPromptBody:"This plugin runs in legacy mode. Upload a new-format ZIP package to migrate. The old version can be safely uninstalled afterwards.",zipParseError:"Failed to parse ZIP file. Ensure the package contains a valid manifest.json.",workerActivationError:"Plugin activation in Worker environment failed. Check plugin code and browser compatibility.",extensionLoadError:"Extension failed to load",retry:"Retry Load",noExtensionPoints:"No extension points registered",dropZipHere:"Drop ZIP file here",zipFileHint:".zip plugin packages only",analyzing:"Analyzing...",dragActive:"Release to upload",legacyTooltip:"This plugin uses the old execution format. A new-format version may be available.",ready:"Ready",uploadZipPlugin:"Upload & Install ZIP Plugin",agentTitle:"Kernel Agent",agentSubtitle:"Autonomous Shell Controller",agentIntro:'Hello! I am your Educational OS Kernel Agent. You can ask me to "create a physics lesson and draw a circle on its whiteboard" and I will use the Command Bus to build it.',placeholder:"e.g. Create a history lesson and draw a map...",dashboard:"OS Dashboard",kernelRunning:"Kernel Running",lessons:"Lessons",noLessons:"No lessons yet. Ask the Agent to create one!",noContent:"No content...",whiteboardCanvas:"Whiteboard Canvas",emptyWhiteboard:"Empty Whiteboard",simulationError:"Simulation Error: Failed to execute OS command.",executedCommands:"Executed Commands: ",switchLang:"切换到中文",plugins:"Plugin Center",uploadPlugin:"Upload & Install Plugin",pluginSource:"Extension Source Code (JS)",installPlugin:"Validate & Install",installing:"Installing...",installedPlugins:"Running Plugins",noPlugins:"No 3rd-party plugins found",lessonContent:"Lesson Content & Notes",eventStream:"Kernel Audit Event Stream",selectLesson:"Please select a lesson from the left",systemLogs:"System Logs",hideLogs:"Hide Logs",showLogs:"Show Logs",approvals:"Pending Approvals",approve:"Approve",reject:"Reject",noApprovals:"No pending commands",fileSystem:"Virtual File System",noFiles:"Directory is empty",processes:"Process Manager",noProcesses:"No active processes",processLogs:"View Logs",classes:"Classes",students:"Students",noClasses:"No classes found",noStudents:"No students found",openInNewTab:"Open in new tab"}};function Jo(e){return e?e.toLowerCase().startsWith("en")?"en":"zh":Qo}const Tn=new Map;let Ko="zh";function jx(e,t){if(!e||!t||typeof t!="object")return;const n={};for(const[i,o]of Object.entries(t))if(o&&typeof o=="object"){const a=Jo(i);n[a]={...n[a]||{},...o}}const s=Tn.get(e)||{};Tn.set(e,{...s,...n,...Object.fromEntries(Object.entries(n).map(([i,o])=>[i,{...s[i]||{},...o}]))})}function kx(e){Tn.delete(e)}function Cx(){return Ko}function Jt(e,t){return!e||!t?e:e.replace(/\{([^{}]+)\}/g,(n,s)=>{const i=t[s.trim()];return i!=null?String(i):n})}function md(e){if(!e)return"";let t=e.replace(/^%+|%+$/g,"").trim();t.includes(":")&&(t=t.split(":").slice(1).join(":"));const n=t.split(".").filter(Boolean);return(n.length>1?n.slice(-2).join(" "):n[0]||t).replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(/\s+/).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ")||e}function pd(e,t,n,s){let i,o,a=s||Ko;typeof t=="string"?(i=t,o=n):t&&typeof t=="object"&&(o=t,n&&typeof n=="object"&&"defaultValue"in n&&(i=n.defaultValue));const l=Jo(a),c=Qo;if(e.includes(":")){const d=e.indexOf(":"),u=e.substring(0,d),m=e.substring(d+1),p=Tn.get(u);if(p){if(p[l]&&p[l][m]!==void 0)return Jt(p[l][m],o);if(p[c]&&p[c][m]!==void 0)return Jt(p[c][m],o)}}if(Ct[l]?.[e]!==void 0)return Jt(Ct[l][e],o);if(Ct[c]?.[e]!==void 0)return Jt(Ct[c][e],o);for(const[,d]of Tn){if(d[l]?.[e]!==void 0)return Jt(d[l][e],o);if(d[c]?.[e]!==void 0)return Jt(d[c][e],o)}return i!=null?Jt(i,o):md(e)}function hn(e,t,n){if(!e)return"";const s=String(e).trim();if(/^%([\w.-]+)%$/.test(s)){const o=s.slice(1,-1),a=Jo(n||Ko),l=Qo;if(t){const c=Tn.get(t);if(c){if(c[a]?.[o]!==void 0)return c[a][o];if(c[l]?.[o]!==void 0)return c[l][o]}}return Ct[a]?.[o]!==void 0?Ct[a][o]:Ct[l]?.[o]!==void 0?Ct[l][o]:md(o)}return s.includes(":")&&!s.includes(" ")&&!s.includes("/")?pd(s,void 0,void 0,n):s}const no=Ct,gd=3,Nx=300*1e3,js=new Map;function Ex(e){const t=Date.now(),n=js.get(e);if(!n||t-n.lastAt>Nx)return js.set(e,{count:1,lastAt:t,blown:!1}),{shouldBreak:!1,count:1};n.count+=1,n.lastAt=t;const s=n.count>=gd;return s&&(n.blown=!0),{shouldBreak:s,count:n.count}}function Tx(e){js.delete(e)}function Xr(e){return js.get(e)?.blown??!1}function ei(e){js.delete(e)}function ti(e,t){Ne.getState().unregisterPluginRuntimeExtensionPoints(e),(t?.suspendPlugin?t.suspendPlugin(e):t?.deactivatePlugin(e))?.catch(i=>console.error(`[ExtensionBreaker] auto-deactivate "${e}" failed:`,i))}function ni(){return r.jsx("div",{className:"w-full h-32 bg-gray-100 rounded-xl animate-pulse flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx($t,{size:24,className:"text-gray-400 animate-spin"}),r.jsx("span",{className:"text-xs text-gray-400",children:"Loading..."})]})})}function fn({pluginId:e,message:t,lang:n="zh",compact:s=!1}){const i=hd(),[o,a]=De.useState(!1),l=n==="zh",c=De.useCallback(()=>{!i||o||(a(!0),i.retryPlugin(e).catch(()=>!1).finally(()=>a(!1)))},[i,e,o]),d=l?"插件加载失败":"Plugin failed to load",u=l?"重试":"Retry";return r.jsxs("div",{role:"alert","data-testid":`plugin-error-state-${e}`,className:`flex flex-col items-center justify-center text-center ${s?"py-4 px-3":"py-10 px-6"}`,children:[r.jsx(Mt,{size:s?20:32,className:"text-amber-500 mb-2","aria-hidden":"true"}),r.jsx("p",{className:`font-semibold text-amber-800 ${s?"text-xs":"text-sm"}`,children:d}),r.jsx("p",{className:"text-xs text-muted mt-1 max-w-md break-words",children:t}),r.jsxs("button",{type:"button",onClick:c,disabled:o||!i,"data-testid":`plugin-retry-btn-${e}`,className:"mt-3 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold bg-amber-700 text-white hover:bg-amber-800 disabled:opacity-60 disabled:cursor-not-allowed transition-colors",children:[o?r.jsx($t,{size:13,className:"animate-spin","aria-hidden":"true"}):r.jsx(Lr,{size:13,"aria-hidden":"true"}),o?l?"重试中…":"Retrying…":u]})]})}class si extends De.Component{constructor(t){super(t),this.state={hasError:!1},this.props=t}componentDidCatch(t){const n=this.props.pluginId;if(!n)return;const{shouldBreak:s,count:i}=Ex(n);if(console.error(`[ExtensionBreaker] Plugin "${n}" frontend crash #${i}/${gd}`+(s?" — 达到熔断阈值,自动停用":""),t?.message?.slice(0,120)),s)try{this.props.onBreakerTrip?.(n)}catch(o){console.error("[ExtensionBreaker] breaker trip callback failed:",o)}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}}function ri({pluginId:e,children:t}){return De.useEffect(()=>{e&&Tx(e)}),r.jsx(r.Fragment,{children:t})}function ii({ext:e,route:t,slotProps:n,slot:s}){const i=De.useRef(null),o=JSON.stringify(n||{});De.useEffect(()=>{i.current&&typeof e.render=="function"&&(i.current.innerHTML="",Promise.resolve(e.render(i.current,{route:t,...n})).catch(console.error))},[e,t,o]);const l=s==="teacher.dashboard.widget"?"h-auto":"h-full min-h-0";return r.jsx("div",{ref:i,className:`w-full ${l}`})}const Ds=new WeakMap;function oi(e){const t=e?.component;if(typeof t!="function")return()=>null;const n=Ds.get(t);if(n)return n;if(t.__isLazyFactory===!0){const s=De.lazy(t);return Ds.set(t,s),s}if(typeof t=="function"&&!t.prototype?.isReactComponent){let s=!1;try{const i=t();i&&typeof i.then=="function"&&(s=!0)}catch{}if(s){console.error(`[ExtensionPoint] Detected an UNMARKED lazy factory (function returned a Promise). React would suspend forever without throwing. Auto-wrapping with React.lazy; please set \`__isLazyFactory = true\` on the factory or register the component directly. Offending function: ${t.name||"(anonymous)"}`);const i=De.lazy(t);return Ds.set(t,i),i}}return Ds.set(t,t),t}function ss(e,t,n){if(n)return n;if(!e||typeof e.getDispatcher!="function")return;const s=e.getDispatcher();return typeof s?.createScopedDispatcher=="function"?s.createScopedDispatcher(t):s}function Me({slot:e,fallback:t,lang:n,route:s,slotProps:i,placement:o}){const a=De.useRef(new Set),l=hd(),c=Ne(g=>g.activePlugins),d=Ne(g=>g.dashboardVisibility),u=Ne(g=>g.pluginErrors),m=de(g=>g.selectedLesson),p=de(g=>g.liveClassSelectedClassId);if(!l)return t??null;let h=l.getExtensions(e);if(o&&(h=h.filter(g=>(g.placement??"after")===o)),h.length===0)return null;const x=(g,b,w)=>{const y=u.get(g.pluginId);if(y)return r.jsx(fn,{pluginId:g.pluginId,message:y});if(Xr(g.pluginId))return a.current.has(g.pluginId)||(a.current.add(g.pluginId),console.warn(`[ExtensionBreaker] Plugin "${g.pluginId}" 已熔断(连续崩溃 ≥3 次),跳过渲染。重新激活插件可恢复。`)),r.jsx(fn,{pluginId:g.pluginId,message:n==="en"?"The plugin frontend crashed repeatedly and was suspended.":"插件前端连续崩溃,已自动降级。",lang:n==="en"?"en":"zh"});const S=typeof g.component=="function",C=typeof g.render=="function";if(!S&&!C)return null;const k={...g.slotProps,...b,dispatcher:ss(l,g.pluginId,i?.dispatcher)};return r.jsx(si,{pluginId:g.pluginId,onBreakerTrip:v=>ti(v,l),fallback:r.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-sm text-red-700",children:w}),children:r.jsx(f.Suspense,{fallback:r.jsx(ni,{}),children:r.jsx(ri,{pluginId:g.pluginId,children:S?De.createElement(oi(g),k):r.jsx(ii,{ext:g,route:g.route||s,slotProps:k,slot:e})})})},`${g.pluginId}/${g.id}`)};if(e==="class.tab"&&i?.renderType==="button"){const g=i?.lang||"zh";return r.jsx(r.Fragment,{children:h.map(b=>{const w=`plugin:${b.pluginId}/${b.id}`,y=i?.classActiveTab===w,S=b.title||b.label||b.id,C=hn(S,b.pluginId,g),k=c.find(N=>N.id===b.pluginId),v=b.icon||k?.icon;return r.jsxs("button",{onClick:N=>{N.stopPropagation(),i?.setClassActiveTab?.(w)},className:`py-1.5 px-3 rounded-lg text-xs font-semibold flex items-center justify-center gap-1.5 transition-all duration-200 cursor-pointer ${y?"bg-white text-indigo-600 shadow-xs font-bold border border-slate-200/50":"text-slate-500 hover:text-slate-800 hover:bg-white/40"}`,title:C,children:[r.jsx(un,{icon:v,size:12,className:"shrink-0",alt:C}),r.jsx("span",{children:C})]},`${b.pluginId}/${b.id}`)})})}if(e==="class.tab"&&i?.renderType==="panel"){const g=i?.classActiveTab,b=h.find(w=>`plugin:${w.pluginId}/${w.id}`===g);return b?x(b,{classId:i?.classId,students:i?.students,lang:i?.lang},"扩展 Tab 加载失败"):null}if(e==="timetable.tab"&&i?.renderType==="button"){const g=i?.lang||"zh";return r.jsx(r.Fragment,{children:h.map(b=>{const w=`plugin:${b.pluginId}/${b.id}`,y=i?.timetableActiveTab===w,S=b.title||b.label||b.id,C=hn(S,b.pluginId,g),k=c.find(N=>N.id===b.pluginId),v=b.icon||k?.icon;return r.jsxs("button",{onClick:N=>{N.stopPropagation(),i?.setTimetableActiveTab?.(w)},className:`px-3 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all cursor-pointer flex items-center gap-1.5 ${y?"bg-white text-indigo-700 shadow-sm font-bold":"text-gray-500 hover:text-gray-800"}`,title:C,children:[r.jsx(un,{icon:v,size:14,className:"shrink-0",alt:C}),r.jsx("span",{children:C})]},`${b.pluginId}/${b.id}`)})})}if(e==="timetable.tab"&&i?.renderType==="panel"){const g=i?.timetableActiveTab,b=h.find(w=>`plugin:${w.pluginId}/${w.id}`===g);return b?x(b,{classes:i?.classes,lessons:i?.lessons,lang:i?.lang,onSchedulesUpdated:i?.onSchedulesUpdated,onClassesUpdated:i?.onClassesUpdated},"课表扩展 Tab 加载失败"):null}if(e==="ai_sidebar.tab"&&i?.renderType==="button"){const g=i?.lang||"zh";return r.jsx(r.Fragment,{children:h.map(b=>{const w=`plugin:${b.pluginId}/${b.id}`,y=i?.activeTab===w,S=b.title||b.label||b.id,C=hn(S,b.pluginId,g),k=c.find(N=>N.id===b.pluginId),v=b.icon||k?.icon;return r.jsxs("button",{onClick:N=>{N.stopPropagation(),i?.setActiveTab?.(w)},className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 min-w-0 cursor-pointer ${y?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,title:C,children:[r.jsx(un,{icon:v,size:14,className:"shrink-0",alt:C}),r.jsx("span",{className:"truncate",children:C})]},`${b.pluginId}/${b.id}`)})})}if(e==="ai_sidebar.tab"&&i?.renderType==="panel"){const g=i?.activeTab,b=h.find(w=>`plugin:${w.pluginId}/${w.id}`===g);return b?x(b,{activeTab:i?.activeTab,lang:i?.lang},"扩展面板加载失败"):null}if(e==="admin.tab"&&i?.renderType==="button"){const g=i?.lang||"zh";return r.jsx(r.Fragment,{children:h.map(b=>{const w=`plugin:${b.pluginId}/${b.id}`,y=i?.adminActiveTab===w,S=b.title||b.label||b.id,C=hn(S,b.pluginId,g),k=c.find(N=>N.id===b.pluginId),v=b.icon||k?.icon;return r.jsxs("button",{onClick:N=>{N.stopPropagation(),i?.setAdminActiveTab?.(w)},className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${y?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,title:C,children:[r.jsx(un,{icon:v,size:14,className:"shrink-0",alt:C}),r.jsx("span",{children:C})]},`${b.pluginId}/${b.id}`)})})}if(e==="admin.tab"&&i?.renderType==="panel"){const g=i?.adminActiveTab,b=h.find(w=>`plugin:${w.pluginId}/${w.id}`===g);return b?x(b,{currentUserId:i?.currentUserId,currentUserRole:i?.currentUserRole,lang:i?.lang,siteInfo:i?.siteInfo,aiProviders:i?.aiProviders},"管理后台扩展 Tab 加载失败"):null}if(e==="student.profile.tab"&&i?.renderType==="button"){const g=i?.lang||"zh";return r.jsx(r.Fragment,{children:h.map(b=>{const w=`plugin:${b.pluginId}/${b.id}`,y=i?.studentActiveTab===w,S=b.title||b.label||b.id,C=hn(S,b.pluginId,g),k=c.find(N=>N.id===b.pluginId),v=b.icon||k?.icon;return r.jsxs("button",{onClick:N=>{N.stopPropagation(),i?.setStudentActiveTab?.(w)},className:`px-3 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${y?"bg-surface text-primary-theme shadow-xs border border-theme/60":"text-muted hover:text-main"}`,title:C,children:[r.jsx(un,{icon:v,size:14,className:"shrink-0",alt:C}),r.jsx("span",{children:C})]},`${b.pluginId}/${b.id}`)})})}if(e==="student.profile.tab"&&i?.renderType==="panel"){const g=i?.studentActiveTab,b=h.find(w=>`plugin:${w.pluginId}/${w.id}`===g);return b?x(b,{student:i?.student,lessonId:i?.lessonId,classId:i?.classId,lang:i?.lang,progressHistory:i?.progressHistory},"学生画像扩展 Tab 加载失败"):null}if(e==="teacher.tab"&&i?.renderType==="button"){const g=[...h].sort((y,S)=>(y.position??100)-(S.position??100)),b=i?.lang??"zh",w=no[b];return r.jsx(r.Fragment,{children:g.map(y=>{const S=`${y.pluginId}/${y.id}`,C=i?.teacherTab===S,k=y.title||y.label||y.id,v=hn(k,y.pluginId,b),N=c.find(z=>z.id===y.pluginId),O=y.icon||N?.icon,D=u.has(y.pluginId),_=b==="zh"?`在新标签页打开"${v}"`:`Open "${v}" in a new tab`,T=S.replace(/[^a-zA-Z0-9_-]/g,"_");return r.jsxs("div",{className:`group relative flex items-center rounded-xl transition-all duration-150 ${C?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/25 shadow-3xs":"border border-transparent text-muted hover:bg-surface-secondary hover:text-main"} ${D?"ring-1 ring-amber-400/70":""} ${i?.mainNavCollapsed?"justify-center":""}`,title:v,children:[r.jsxs("button",{type:"button",onClick:()=>i?.setTeacherTab?.(S),id:`nav_btn_${T}`,className:`flex items-center gap-2.5 py-2 flex-1 min-w-0 text-sm font-medium focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-theme/50 rounded-lg ${C?"font-bold":""} ${i?.mainNavCollapsed?"justify-center px-2":"pl-2.5 pr-8"}`,children:[r.jsx(un,{icon:O,size:18,className:"shrink-0",alt:v}),r.jsx("span",{className:i?.mainNavCollapsed?"hidden":"block truncate",children:v})]}),!i?.mainNavCollapsed&&r.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),hx(S)},id:`nav_btn_${T}_newtab`,"aria-label":_,title:w.openInNewTab,"data-testid":`nav_newtab_${T}`,className:"absolute right-1.5 p-1 rounded-md opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-black/10 dark:hover:bg-white/15 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-theme/50 transition-opacity text-current",children:r.jsx(Wc,{size:12,className:"shrink-0"})})]},`${y.pluginId}/${y.id}`)})})}if(e==="whiteboard.renderer"){const g=i?.elementType;if(!g)return null;const b=h.find(C=>{const k=C;return k.targetType===g||C.id===g||C.route===g||`${C.pluginId}/${C.id}`===g||k.slotProps?.elementType===g||k.slotProps?.targetType===g});if(!b)return null;const w=u.get(b.pluginId);if(w)return r.jsx(fn,{pluginId:b.pluginId,message:w,compact:!0});if(Xr(b.pluginId))return a.current.has(b.pluginId)||(a.current.add(b.pluginId),console.warn(`[ExtensionBreaker] Plugin "${b.pluginId}" 已熔断(连续崩溃 ≥3 次),跳过渲染。重新激活插件可恢复。`)),r.jsx(fn,{pluginId:b.pluginId,message:n==="en"?"The plugin frontend crashed repeatedly and was suspended.":"插件前端连续崩溃,已自动降级。",lang:n==="en"?"en":"zh",compact:!0});const y=typeof b.component=="function",S=typeof b.render=="function";return!y&&!S?null:r.jsx(si,{pluginId:b.pluginId,onBreakerTrip:C=>ti(C,l),fallback:t??r.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-2 text-xs text-red-600 flex items-center justify-center",children:r.jsx("span",{children:n==="zh"?"自定义图元加载失败":"Custom object failed to load"})}),children:r.jsx(f.Suspense,{fallback:t??r.jsx(ni,{}),children:r.jsx(ri,{pluginId:b.pluginId,children:y?De.createElement(oi(b),{...b.slotProps,...i,dispatcher:ss(l,b.pluginId,i?.dispatcher)}):r.jsx(ii,{ext:b,route:b.route||s,slotProps:{...b.slotProps,...i,dispatcher:ss(l,b.pluginId,i?.dispatcher)},slot:e})})})},`${b.pluginId}/${b.id}`)}return r.jsx(r.Fragment,{children:h.map(g=>{const b=typeof g.component=="function",w=typeof g.render=="function";if(e==="teacher.dashboard.widget"&&d.get(g.pluginId)===!1||!b&&!w)return null;const y=u.get(g.pluginId);return y?r.jsx(fn,{pluginId:g.pluginId,message:y},`${g.pluginId}/${g.id}`):Xr(g.pluginId)?(a.current.has(g.pluginId)||(a.current.add(g.pluginId),console.warn(`[ExtensionBreaker] Plugin "${g.pluginId}" 已熔断(连续崩溃 ≥3 次),跳过渲染。重新激活插件可恢复。`)),r.jsx(fn,{pluginId:g.pluginId,message:n==="en"?"The plugin frontend crashed repeatedly and was suspended.":"插件前端连续崩溃,已自动降级。",lang:n==="en"?"en":"zh"},`${g.pluginId}/${g.id}`)):r.jsx(si,{pluginId:g.pluginId,onBreakerTrip:S=>ti(S,l),fallback:r.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-sm text-red-700",children:r.jsx("p",{children:n==="zh"?"扩展组件加载失败":"Extension failed to load"})}),children:r.jsx(f.Suspense,{fallback:t??r.jsx(ni,{}),children:r.jsx(ri,{pluginId:g.pluginId,children:b?De.createElement(oi(g),{route:g.route||s,lessonId:m,classId:p,dispatcher:ss(l,g.pluginId,i?.dispatcher),...g.slotProps,...i}):r.jsx(ii,{ext:g,route:g.route||s,slotProps:{lessonId:m,classId:p,dispatcher:ss(l,g.pluginId,i?.dispatcher),...g.slotProps,...i},slot:e})})})},`${g.pluginId}/${g.id}`)})})}const Px=({state:e,onToggleAnonymous:t,onOpenRubricModal:n,onToggleVoiceDanmaku:s,onAdvanceStage:i,onAddMinute:o,onTogglePauseTimer:a,isFullscreen:l,onToggleFullscreen:c,onClose:d})=>{const u=p=>{const h=Math.floor(Math.max(0,p)/60),x=Math.max(0,p)%60;return`${String(h).padStart(2,"0")}:${String(x).padStart(2,"0")}`},m=Math.round(e.completedReviews/Math.max(1,e.totalStudents)*100);return r.jsxs("div",{id:"peer-review-telemetry-header",className:"w-full bg-[#131b2e] border-b border-[#2d3449] px-6 py-3 flex flex-wrap items-center justify-between gap-4 select-none shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 rounded bg-[#171f33] text-[#908fa0] text-[10px] font-mono font-semibold tracking-wider",children:"STAGE 02.4"}),r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[#c7c4d7]",children:[r.jsx("span",{children:"随堂巩固"}),r.jsx(Cn,{size:13,className:"text-[#908fa0]"}),r.jsx("span",{children:"收卷归档"}),r.jsx(Cn,{size:13,className:"text-[#908fa0]"}),r.jsxs("span",{className:"text-[#4edea3] font-medium flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#4edea3] animate-ping"}),"全班大屏协同互评阶段 ",e.isLocked&&"(已锁定全班终端)"]})]})]}),r.jsx("div",{className:"h-4 w-[1px] bg-[#2d3449] hidden md:block"}),r.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 px-2.5 py-1 rounded bg-[#00a572]/20 text-[#4edea3] text-xs font-medium border border-[#00a572]/30",children:[r.jsx(qc,{size:14,className:"text-[#4edea3]"}),r.jsxs("span",{children:["教室主大屏协同输出 ",e.isDualScreen?"(4K 双屏模式)":"(投影模式)"]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[r.jsxs("div",{className:"flex items-center gap-2 bg-[#060e20] px-3 py-1.5 rounded-xl border border-[#2d3449]/60",children:[r.jsx(Tp,{size:18,className:"text-[#ffb95f] animate-pulse"}),r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0] leading-none",children:"COUNTDOWN"}),o&&r.jsx("button",{type:"button",onClick:o,className:"text-[10px] text-[#ffb95f] hover:text-[#ffddb8] font-mono transition-colors",title:"加时 1 分钟",children:"+1m"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r.jsxs("span",{className:"text-sm font-semibold font-mono text-[#dae2fd] leading-none",children:[u(e.timeRemainingSeconds),r.jsxs("span",{className:"text-[#908fa0] text-xs font-normal",children:[" / ",u(e.totalTimeSeconds)]})]}),a&&r.jsx("button",{type:"button",onClick:a,className:"text-[#c7c4d7] hover:text-white transition-colors",title:e.isPaused?"恢复倒计时":"暂停倒计时",children:e.isPaused?r.jsx(Ro,{size:12,className:"text-[#4edea3]"}):r.jsx(Pp,{size:12})})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsxs("div",{className:"relative w-8 h-8 flex items-center justify-center",children:[r.jsxs("svg",{className:"w-8 h-8 -rotate-90",viewBox:"0 0 36 36",children:[r.jsx("path",{className:"text-[#2d3449]",d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",stroke:"currentColor",strokeWidth:"3.5"}),r.jsx("path",{className:"text-[#4edea3] transition-all duration-500",d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831",fill:"none",stroke:"currentColor",strokeDasharray:`${m}, 100`,strokeLinecap:"round",strokeWidth:"3.5"})]}),r.jsxs("span",{className:"absolute text-[9px] font-mono text-[#dae2fd] font-semibold",children:[m,"%"]})]}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0] leading-none",children:"SUBMISSIONS"}),r.jsxs("span",{className:"text-xs font-medium text-[#dae2fd] mt-0.5",children:[e.completedReviews," / ",e.totalStudents," 人已评"]})]})]}),r.jsxs("div",{className:"hidden lg:flex items-center gap-2 bg-[#171f33] px-3 py-1.5 rounded-xl border border-[#2d3449]/60",children:[r.jsx(Ip,{size:16,className:"text-[#c0c1ff]"}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0] leading-none",children:"PEER REACTIONS"}),r.jsxs("span",{className:"text-xs font-mono font-medium text-[#c0c1ff] mt-0.5",children:[e.totalLikes," 次点赞 · ",e.totalNominations," 份提名"]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("label",{htmlFor:"toggle-anon",className:"flex items-center gap-2 cursor-pointer bg-[#171f33] px-2.5 py-1.5 rounded-xl hover:bg-[#222a3d] transition-colors border border-[#2d3449]/50",title:"开启后隐藏学生真实姓名",children:[r.jsx("input",{id:"toggle-anon",type:"checkbox",checked:e.isAnonymous,onChange:t,className:"sr-only peer"}),r.jsx("div",{className:"w-7 h-4 bg-[#2d3449] peer-checked:bg-[#4edea3] rounded-full relative transition-colors",children:r.jsx("div",{className:`w-3 h-3 bg-white rounded-full absolute top-0.5 left-0.5 transition-transform ${e.isAnonymous?"translate-x-3":""}`})}),r.jsx("span",{className:"text-xs text-[#c7c4d7] font-medium",children:"双盲匿名"})]}),r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-[#171f33] hover:bg-[#222a3d] text-[#c7c4d7] hover:text-[#dae2fd] transition-colors text-xs font-medium border border-[#2d3449]/50",children:[r.jsx(_o,{size:15,className:"text-[#ffb95f]"}),r.jsx("span",{children:"互评量规"})]}),r.jsxs("button",{type:"button",onClick:s,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl transition-colors text-xs font-medium border ${e.showDanmaku?"bg-[#00a572]/20 border-[#00a572]/40 text-[#4edea3]":"bg-[#171f33] border-[#2d3449]/50 text-[#c7c4d7] hover:text-[#dae2fd]"}`,title:"开关大屏弹幕墙",children:[r.jsx(Ap,{size:15,className:"text-[#4edea3]"}),r.jsx("span",{children:"全员语音弹幕"})]}),r.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 px-3.5 py-1.5 rounded-xl bg-[#c0c1ff] text-[#1000a9] hover:bg-[#8083ff] hover:text-white transition-all shadow-sm text-xs font-semibold",children:[r.jsx(Oo,{size:15}),r.jsx("span",{children:"揭晓勋章榜"}),r.jsx("span",{className:"font-mono text-[10px] bg-[#1000a9]/15 px-1 py-0.5 rounded leading-none",children:"Enter"})]}),r.jsx(Me,{slot:"peer_review.action"}),c&&r.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-xl text-[#c7c4d7] hover:text-white hover:bg-[#222a3d] transition-colors ml-1",title:l?"退出全屏":"全屏展示",children:l?r.jsx(Qi,{size:16}):r.jsx(Do,{size:16})}),d&&r.jsx("button",{type:"button",onClick:d,className:"p-1.5 rounded-xl text-[#ffb4ab] hover:text-white hover:bg-[#93000a]/50 transition-colors ml-1",title:"关闭大屏互评",children:r.jsx(Oe,{size:16})})]})]})},Ix=({matchingItems:e,badges:t,isAnonymous:n=!1,onSelectMatchingItem:s})=>{const i=(o,a)=>!a||o.length<=1?o:`${o[0]}**`;return r.jsxs("div",{id:"peer-review-matrix-panel",className:"flex flex-col gap-4 w-full select-none",children:[r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#c0c1ff]/15 flex items-center justify-center text-[#c0c1ff]",children:r.jsx(Gc,{size:16})}),r.jsx("h2",{className:"text-sm font-semibold text-[#dae2fd]",children:"智能交叉互评"})]}),r.jsx("span",{className:"px-2 py-0.5 rounded bg-[#8083ff]/20 text-[#c0c1ff] font-mono text-[10px] font-semibold",children:"1生评2份"})]}),r.jsx("p",{className:"text-xs text-[#c7c4d7] leading-relaxed",children:"分层对调机制:将满分逻辑范本与攻坚调试作业交叉分发,激发逆向审阅与自愈思考。"})]}),r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-[#908fa0] font-mono text-[10px] font-semibold",children:"PEER MATCHING REALTIME"}),r.jsxs("span",{className:"text-[#4edea3] font-mono text-[11px] flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#4edea3] animate-pulse"})," 实时同步中"]})]}),r.jsx("div",{className:"flex flex-col gap-2.5 max-h-[380px] overflow-y-auto pr-0.5",children:e.map(o=>{const a=i(o.reviewerName,n),l=i(o.targetStudentName,n);return r.jsxs("div",{onClick:()=>s?.(o),className:`p-3 rounded-lg border transition-all cursor-pointer ${o.status==="submitted"?"bg-[#222a3d] border-[#4edea3]/40 shadow-sm":"bg-[#171f33] border-[#2d3449]/60 hover:bg-[#222a3d] hover:border-[#464554]"}`,children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"font-mono text-[11px] text-[#ffb95f] font-semibold",children:o.code}),r.jsxs("span",{className:"text-xs text-[#dae2fd] font-semibold truncate max-w-[130px]",children:[a," ",o.reviewerGroup?`(${o.reviewerGroup})`:""]})]}),o.status==="submitted"&&r.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-[#00a572]/20 text-[#4edea3]",children:"已提交评语"}),o.status==="in_progress"&&r.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-[#ca8100]/20 text-[#ffb95f] animate-pulse",children:"正在推导 (2/3)"}),o.status==="completed"&&r.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-[#00a572]/20 text-[#4edea3] flex items-center gap-1",children:[r.jsx(at,{size:10})," 已完成"]}),o.status==="improvement"&&r.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-[#c0c1ff]/20 text-[#c0c1ff]",children:"提出改进建议 💡"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[#c7c4d7] mb-1.5",children:[r.jsx(yr,{size:12,className:"text-[#908fa0] shrink-0"}),r.jsxs("span",{className:"text-[#c0c1ff] font-medium truncate",children:[l," · ",o.targetWorkTitle]})]}),o.comment&&r.jsxs("div",{className:"bg-[#060e20] p-2 rounded text-xs text-[#c7c4d7] italic border border-[#2d3449]/40 mb-1.5 leading-relaxed",children:['"',o.comment,'"']}),o.progressPercent!==void 0&&o.status==="in_progress"&&r.jsx("div",{className:"w-full bg-[#2d3449] h-1 rounded-full mt-2 overflow-hidden",children:r.jsx("div",{className:"bg-[#ffb95f] h-full rounded-full transition-all duration-300",style:{width:`${o.progressPercent}%`}})}),o.stars!==void 0&&r.jsxs("div",{className:"flex items-center justify-between mt-1.5 pt-1.5 border-t border-[#2d3449]/50",children:[r.jsx("div",{className:"flex text-[#ffb95f]",children:Array.from({length:5}).map((c,d)=>r.jsx(vr,{size:13,className:d<o.stars?"text-[#ffb95f] fill-[#ffb95f]":"text-[#464554]"},d))}),r.jsxs("span",{className:"text-[10px] font-mono text-[#908fa0]",children:[o.score?.toFixed(1)||"5.0"," / ",o.maxScore||"5.0"]})]})]},o.id)})})]}),r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] font-mono font-semibold text-[#908fa0]",children:"LIVE PEER BADGE STREAM"}),r.jsx(Mo,{size:14,className:"text-[#908fa0]"})]}),r.jsx("div",{className:"flex flex-col gap-2 overflow-hidden",children:t.map(o=>r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-[#171f33] border border-[#2d3449]/50 text-xs text-[#dae2fd]",children:[r.jsx("span",{className:"text-sm shrink-0",children:o.emoji}),r.jsxs("div",{className:"truncate",children:[r.jsx("span",{className:"text-[#4edea3] font-medium",children:i(o.senderName,n)}),r.jsx("span",{className:"text-[#c7c4d7] mx-1",children:"为"}),r.jsx("span",{className:"text-[#c0c1ff] font-medium",children:i(o.receiverName,n)}),r.jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[#222a3d] rounded text-[10px] font-mono text-[#ffb95f]",children:o.badgeTitle})]})]},o.id))}),r.jsx(Me,{slot:"peer_review.badge"})]})]})},Ax=["http:","https:"],zx=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Lx=/[\u0000-\u001f\u007f]/;function tr(e){if(typeof e!="string")return null;const t=e.trim();if(!t||Lx.test(t)||t.startsWith("//")||t.startsWith("\\\\"))return null;if(zx.exec(t)){const s=t.slice(0,t.indexOf(":")+1).toLowerCase();if(!Ax.includes(s))return null}return t}const Rx=({workA:e,workB:t,annotations:n,isAnonymous:s=!1,onFullscreenCanvas:i,onSyncSandboxToClass:o,onAddAnnotation:a})=>{const[l,c]=f.useState("visual"),[d,u]=f.useState(!1),[m,p]=f.useState(""),[h,x]=f.useState(null),g=(y,S)=>!S||y.length<=1?y:`${y[0]}**`,b=y=>{y.preventDefault(),m.trim()&&(a?.(m.trim()),p(""),u(!1))},w=y=>{const S=y.files?.filter(k=>k.isImage||/\.(jpe?g|png|gif|webp|svg)$/i.test(k.name||k.url||""))||[],C=y.files?.filter(k=>!S.includes(k))||[];return r.jsxs("div",{"data-testid":`work-preview-${y.slot}`,className:"w-full h-44 rounded-lg bg-[#060e20] flex flex-col justify-center relative overflow-hidden border border-[#2d3449]/60",children:[r.jsx(Me,{slot:"peer_review.work.preview",slotProps:{work:y,slot:y.slot,isAnonymous:s}}),S.length>0?r.jsxs("div",{className:"w-full h-full p-2.5 flex items-center gap-2 overflow-x-auto",children:[S.map((k,v)=>r.jsxs("div",{onClick:()=>k.url&&x(k.url),className:"relative group h-full rounded-md overflow-hidden border border-[#2d3449] bg-[#131b2e] cursor-pointer shrink-0 aspect-4/3 flex items-center justify-center",title:`${k.name} (点击放大)`,children:[r.jsx("img",{src:k.url,alt:k.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}),r.jsxs("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1 text-[11px] text-white font-medium",children:[r.jsx(Ns,{size:14}),r.jsx("span",{children:"放大"})]}),r.jsx("span",{className:"absolute bottom-1 left-1 right-1 px-1 py-0.5 rounded bg-black/60 text-[9px] text-[#dae2fd] truncate",children:k.name})]},v)),C.length>0&&r.jsx("div",{className:"h-full flex flex-col justify-center gap-1 shrink-0 pl-1",children:C.map((k,v)=>{const N=tr(k.url);return N?r.jsxs("a",{href:N,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449] text-[11px] text-[#c0c1ff] hover:text-white transition-colors",children:[r.jsx(Kr,{size:13,className:"text-[#8083ff]"}),r.jsx("span",{className:"max-w-[120px] truncate",children:k.name}),r.jsx(Wc,{size:11,className:"opacity-70"})]},v):r.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded bg-[#171f33] border border-[#2d3449] text-[11px] text-[#c0c1ff]",children:[r.jsx(Kr,{size:13,className:"text-[#8083ff]"}),r.jsx("span",{className:"max-w-[120px] truncate",children:k.name})]},v)})})]}):C.length>0?r.jsxs("div",{className:"w-full h-full p-3 flex flex-col gap-2 overflow-y-auto",children:[r.jsxs("div",{className:"text-[11px] text-[#908fa0] flex items-center gap-1 mb-0.5",children:[r.jsx(Jc,{size:13,className:"text-[#8083ff]"}),r.jsxs("span",{children:["提交附件 (",C.length," 个文件)"]})]}),C.map((k,v)=>r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-[#131b2e] border border-[#2d3449] text-xs",children:[r.jsxs("div",{className:"flex items-center gap-2 truncate",children:[r.jsx(Kr,{size:15,className:"text-[#8083ff] shrink-0"}),r.jsx("span",{className:"text-[#dae2fd] truncate font-medium",children:k.name}),typeof k.size=="number"&&r.jsxs("span",{className:"text-[10px] text-[#908fa0] shrink-0",children:["(",(k.size/1024).toFixed(1)," KB)"]})]}),k.url&&tr(k.url)&&r.jsxs("a",{href:tr(k.url),target:"_blank",rel:"noreferrer",download:k.name,className:"flex items-center gap-1 px-2 py-1 rounded bg-[#171f33] hover:bg-[#222a3d] text-[#c0c1ff] hover:text-white text-[11px] font-medium border border-[#2d3449] transition-colors shrink-0",children:[r.jsx(Ji,{size:12}),r.jsx("span",{children:"下载"})]})]},v))]}):y.codeLines&&y.codeLines.length>0?r.jsx("pre",{className:"px-4 py-3 font-mono text-[11px] leading-5 text-[#dae2fd] overflow-y-auto max-h-full whitespace-pre-wrap break-words",children:y.codeLines.map((k,v)=>r.jsx("div",{className:k.isHighlight?"text-[#4edea3]":"",style:{paddingLeft:`${(k.indent||0)*12}px`},children:k.text},v))}):y.textContent?r.jsx("div",{className:"px-4 py-3 font-sans text-xs leading-5 text-[#dae2fd] overflow-y-auto max-h-full whitespace-pre-wrap break-words",children:y.textContent}):r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(Rp,{size:28,className:"text-[#4a5570]"}),r.jsxs("span",{className:"text-[11px] text-[#908fa0] leading-relaxed",children:["该作品没有可展示的作答内容",r.jsx("br",{}),r.jsx("span",{className:"text-[10px] opacity-70",children:"(原始作答流水为空或为纯数值型)"})]})]}),y.workContent&&r.jsxs("span",{className:"absolute bottom-2 right-2 text-[10px] font-mono text-[#908fa0] bg-[#131b2e]/90 px-1.5 py-0.5 rounded border border-[#2d3449]/50",children:["真实作答 · ",y.workContent.eventCount," 条事件"]})]})};return r.jsxs("div",{id:"spotlight-dual-work-arena",className:"flex flex-col gap-4 w-full select-none",children:[r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-wrap items-center justify-between gap-3 shadow-md",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#8083ff]/20 flex items-center justify-center text-[#c0c1ff] border border-[#8083ff]/30",children:r.jsx(Qc,{size:20})}),r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-base font-bold text-[#dae2fd]",children:"大屏焦点作品对比赏析"}),r.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#ca8100]/20 text-[#ffb95f] font-mono text-[10px] font-semibold flex items-center gap-1 border border-[#ca8100]/30",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#ffb95f] animate-ping"}),"教师激光笔协同标记中"]})]}),r.jsxs("span",{className:"text-xs text-[#c7c4d7] mt-0.5",children:["标杆创新解法 (",g(e.studentName,s),") ⟷ 经典逆风翻盘解法 (",g(t.studentName,s),")"]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[o&&r.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#171f33] hover:bg-[#222a3d] text-[#c7c4d7] hover:text-white border border-[#2d3449]/60 transition-colors text-xs font-medium",title:"将对比沙箱推送到全班学生机",children:[r.jsx(zp,{size:14,className:"text-[#4edea3]"}),r.jsx("span",{children:"同步沙箱至全班"})]}),i&&r.jsx("button",{type:"button",onClick:i,className:"p-2 rounded-lg bg-[#171f33] hover:bg-[#222a3d] text-[#c7c4d7] hover:text-white border border-[#2d3449]/60 transition-colors",title:"全屏沉浸投影",children:r.jsx(Do,{size:16})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"bg-[#131b2e] rounded-xl p-4 flex flex-col gap-3 border border-[#2d3449]/60 shadow-md relative",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#8083ff] text-white flex items-center justify-center font-bold text-xs shadow-sm",children:s?"A":e.studentInitial}),r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsxs("span",{className:"text-sm font-semibold text-[#dae2fd]",children:[g(e.studentName,s)," (作品 A)"]}),e.sourceLabel&&r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium border ${e.source==="plugin"?"bg-[#8083ff]/15 text-[#c0c1ff] border-[#8083ff]/30":e.source==="assignment"?"bg-[#00a572]/15 text-[#4edea3] border-[#00a572]/30":"bg-[#ca8100]/15 text-[#ffb95f] border-[#ca8100]/30"}`,children:e.sourceLabel})]}),r.jsx("span",{className:"text-[11px] font-mono text-[#908fa0]",children:e.workSubtitle})]})]}),r.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded bg-[#ca8100]/20 text-[#ffb95f] border border-[#ca8100]/30",children:[r.jsx(vr,{size:13,className:"text-[#ffb95f] fill-[#ffb95f]"}),r.jsx("span",{className:"font-mono text-xs font-semibold",children:typeof e.rating=="number"?e.rating.toFixed(1):"—"}),r.jsxs("span",{className:"text-[10px] text-[#908fa0]",children:["(",e.reviewCount??0,"评)"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.badges.map((y,S)=>r.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono font-medium ${y.colorClass}`,children:y.label},S))}),w(e),e.codeLines?.some(y=>y.comment)?r.jsxs("div",{className:"bg-[#060e20] rounded-lg p-3 font-mono text-[11px] leading-5 border border-[#2d3449]/60 overflow-x-auto text-[#dae2fd]",children:[r.jsxs("div",{className:"text-[#908fa0] mb-1",children:["# ",e.codeTitle??""]}),e.codeLines.filter(y=>y.comment).map((y,S)=>r.jsx("div",{className:y.isHighlight?"bg-[#8083ff]/20 px-1 rounded -mx-1":"",children:r.jsx("span",{className:"text-[#908fa0]",children:y.comment})},S))]}):null]}),r.jsxs("div",{className:"bg-[#131b2e] rounded-xl p-4 flex flex-col gap-3 border border-[#2d3449]/60 shadow-md relative",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#00a572] text-white flex items-center justify-center font-bold text-xs shadow-sm",children:s?"B":t.studentInitial}),r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsxs("span",{className:"text-sm font-semibold text-[#dae2fd]",children:[g(t.studentName,s)," (作品 B)"]}),t.sourceLabel&&r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium border ${t.source==="plugin"?"bg-[#8083ff]/15 text-[#c0c1ff] border-[#8083ff]/30":t.source==="assignment"?"bg-[#00a572]/15 text-[#4edea3] border-[#00a572]/30":"bg-[#ca8100]/15 text-[#ffb95f] border-[#ca8100]/30"}`,children:t.sourceLabel})]}),r.jsx("span",{className:"text-[11px] font-mono text-[#908fa0]",children:t.workSubtitle})]})]}),r.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded bg-[#ca8100]/20 text-[#ffb95f] border border-[#ca8100]/30",children:[r.jsx(vr,{size:13,className:"text-[#ffb95f] fill-[#ffb95f]"}),r.jsx("span",{className:"font-mono text-xs font-semibold",children:typeof t.rating=="number"?t.rating.toFixed(1):"—"}),r.jsxs("span",{className:"text-[10px] text-[#908fa0]",children:["(",t.reviewCount??0,"评)"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.badges.map((y,S)=>r.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono font-medium ${y.colorClass}`,children:y.label},S))}),w(t),t.codeLines?.some(y=>y.comment)?r.jsxs("div",{className:"bg-[#060e20] rounded-lg p-3 font-mono text-[11px] leading-5 border border-[#2d3449]/60 overflow-x-auto text-[#dae2fd]",children:[r.jsxs("div",{className:"text-[#908fa0] mb-1",children:["# ",t.codeTitle??""]}),t.codeLines.filter(y=>y.comment).map((y,S)=>r.jsx("div",{className:y.isSuccess?"bg-[#00a572]/20 px-1 rounded -mx-1":"",children:r.jsx("span",{className:"text-[#4edea3] text-[10px]",children:y.comment})},S))]}):null]})]}),r.jsxs("div",{className:"bg-[#131b2e] rounded-xl p-4 flex flex-col gap-3 border border-[#2d3449]/60 shadow-md",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Lp,{size:16,className:"text-[#ffb95f]"}),r.jsx("span",{className:"text-xs font-semibold text-[#dae2fd]",children:"协同板书标注与点评审阅"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-[10px] font-mono text-[#908fa0]",children:[n.length," 条实时批注挂载"]}),a&&r.jsx("button",{type:"button",onClick:()=>u(!d),className:"text-[11px] text-[#c0c1ff] hover:text-white font-medium transition-colors",children:d?"取消批注":"+ 追加教师批注"})]})]}),d&&r.jsxs("form",{onSubmit:b,className:"flex gap-2",children:[r.jsx("input",{type:"text",value:m,onChange:y=>p(y.target.value),placeholder:"输入大屏协同批注要点...",className:"flex-1 px-3 py-1.5 rounded-lg bg-[#060e20] border border-[#2d3449] text-xs text-[#dae2fd] placeholder-[#908fa0] focus:outline-none focus:border-[#8083ff]"}),r.jsx("button",{type:"submit",className:"px-3 py-1.5 rounded-lg bg-[#c0c1ff] text-[#1000a9] font-semibold text-xs hover:bg-[#8083ff] hover:text-white transition-colors",children:"发送批注"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:n.map(y=>r.jsxs("div",{className:"bg-[#171f33] p-3 rounded-lg flex flex-col gap-1.5 relative overflow-hidden border border-[#2d3449]/50",children:[r.jsx("div",{className:"w-1 absolute left-0 top-0 bottom-0",style:{backgroundColor:y.borderColor}}),r.jsxs("div",{className:"flex items-center justify-between pl-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-bold ${y.authorType==="teacher"?"bg-[#8083ff] text-white":"bg-[#00a572] text-white"}`,children:y.authorRole}),r.jsx("span",{className:"text-xs font-semibold text-[#dae2fd]",children:g(y.authorName,s)})]}),r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0]",children:y.timeAgo})]}),r.jsx("p",{className:"text-xs text-[#dae2fd] pl-2 leading-relaxed",children:y.content})]},y.id))})]}),r.jsx(Me,{slot:"peer_review.showcase.widget",slotProps:{workA:e,workB:t,annotations:n,isAnonymous:s}}),h&&r.jsx("div",{className:"fixed inset-0 z-[10000] bg-black/80 backdrop-blur-xs flex items-center justify-center p-4",onClick:()=>x(null),children:r.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] bg-[#131b2e] rounded-xl overflow-hidden border border-[#2d3449] shadow-2xl p-2",onClick:y=>y.stopPropagation(),children:[r.jsx("button",{type:"button",onClick:()=>x(null),className:"absolute top-3 right-3 p-1.5 rounded-lg bg-[#060e20]/80 hover:bg-[#060e20] text-white transition-colors",children:r.jsx(Oe,{size:18})}),r.jsx("img",{src:h,alt:"Work preview",className:"max-w-full max-h-[85vh] object-contain rounded-lg"})]})})]})},_x=({dimensions:e,averagePercentage:t,reactions:n,onReactionClick:s,syncedStudentsCount:i})=>r.jsxs("div",{id:"peer-review-rubric-stats",className:"bg-[#131b2e] rounded-xl p-4 flex flex-col gap-4 border border-[#2d3449]/60 shadow-md select-none w-full",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-[#dae2fd]",children:"全班三维量规综合达标率"}),r.jsxs("span",{className:"text-[11px] font-mono text-[#4edea3] font-semibold",children:["AVERAGE: ",typeof t=="number"?`${t.toFixed(1)}%`:"—"]})]}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:e.map(o=>r.jsxs("div",{className:"bg-[#171f33] p-2.5 rounded-lg flex flex-col gap-1.5 border border-[#2d3449]/50",children:[r.jsxs("div",{className:"flex justify-between text-xs",children:[r.jsx("span",{className:"text-[#908fa0] truncate",children:o.label}),r.jsxs("span",{className:`font-mono font-medium ${o.colorClass}`,children:[o.percentage,"%"]})]}),r.jsx("div",{className:"w-full bg-[#2d3449] h-1.5 rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${o.barColorClass}`,style:{width:`${o.percentage}%`}})})]},o.id))}),r.jsx(Me,{slot:"peer_review.rubric.dimension"}),r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-1 border-t border-[#2d3449]/40",children:[r.jsx("div",{className:"flex items-center gap-2",children:n.map(o=>r.jsxs("button",{type:"button",onClick:()=>s?.(o.id),className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449]/60 transition-all text-xs text-[#dae2fd] active:scale-95 group",children:[r.jsx("span",{children:o.emoji}),r.jsx("span",{className:"font-medium group-hover:text-white",children:o.label}),r.jsxs("span",{className:`font-mono font-semibold ${o.colorClass}`,children:["+",o.count]})]},o.id))}),r.jsxs("span",{className:"text-[10px] font-mono text-[#908fa0] flex items-center gap-1",children:[r.jsx(Ki,{size:13,className:"text-[#4edea3]"}),typeof i=="number"?`${i}台学生端已同步点赞动画`:"学生端同步状态未知"]})]})]}),Ox=({podiumStudents:e,isAnonymous:t=!1,onAwardPeerReviewPoints:n,onArchiveTopWorks:s,onCallStudentMic:i,onInviteScreenShare:o,onAdvanceToStage3:a})=>{const l=(c,d)=>!d||c.length<=1?c:`${c[0]}**`;return r.jsxs("div",{id:"peer-review-leaderboard-panel",className:"flex flex-col gap-4 w-full select-none",children:[r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-3 shadow-md",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_p,{size:18,className:"text-[#ffb95f]"}),r.jsx("h2",{className:"text-sm font-semibold text-[#dae2fd]",children:"互评推荐先锋榜"})]}),r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0] font-semibold",children:"TOP NOMINATED"})]}),r.jsx("div",{className:"flex flex-col gap-2.5",children:e.map(c=>r.jsxs("div",{className:`p-3 rounded-lg border transition-all ${c.rank===1?"bg-[#222a3d] border-[#ffb95f]/40 shadow-sm":"bg-[#171f33] border-[#2d3449]/50 hover:bg-[#222a3d]"} flex flex-col gap-1.5`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-5 h-5 rounded-full font-mono text-[11px] font-bold flex items-center justify-center ${c.rankBadgeClass}`,children:c.rank}),r.jsx("span",{className:"text-xs font-semibold text-[#dae2fd]",children:l(c.name,t)})]}),r.jsxs("span",{className:"font-mono text-xs font-semibold text-[#ffb95f]",children:[c.votes," 票推荐"]})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-[#c7c4d7] truncate max-w-[140px]",children:c.workTitle}),r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-medium ${c.tagBadgeClass}`,children:c.honorTitle})]})]},c.rank))})]}),r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-3 shadow-md",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-[#dae2fd]",children:"随堂微勋章即时分发箱"}),r.jsx(Oo,{size:15,className:"text-[#4edea3]"})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between px-3 py-2 rounded-lg bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449]/50 text-[#dae2fd] transition-colors text-xs text-left",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(yt,{size:14,className:"text-[#ffb95f]"}),r.jsx("span",{children:"为全员互评认真学生 +2 积分"})]}),r.jsx("span",{className:"font-mono text-[10px] text-[#4edea3] font-semibold bg-[#00a572]/20 px-1.5 py-0.5 rounded",children:"一键发放"})]}),r.jsxs("button",{type:"button",onClick:s,className:"w-full flex items-center justify-between px-3 py-2 rounded-lg bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449]/50 text-[#dae2fd] transition-colors text-xs text-left",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Rr,{size:14,className:"text-[#c0c1ff]"}),r.jsx("span",{children:"TOP 2 优秀代码入库数字馆"})]}),r.jsx("span",{className:"font-mono text-[10px] text-[#c0c1ff] font-semibold bg-[#8083ff]/20 px-1.5 py-0.5 rounded",children:"入库归档"})]})]})]}),r.jsxs("div",{className:"bg-[#131b2e] p-4 rounded-xl border border-[#2d3449]/60 flex flex-col gap-3 shadow-md",children:[r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0] font-semibold",children:"TEACHER BROADCAST & STAGE TRANSITION"}),r.jsx("div",{className:"flex flex-col gap-2",children:(()=>{const c=e[0]?.name,d=e[1]?.name??c;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:!c,onClick:()=>c&&i(c),className:"w-full flex items-center justify-between px-3 py-2 rounded-lg bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449]/50 text-[#dae2fd] transition-colors text-xs text-left disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Yi,{size:14,className:"text-[#c0c1ff]"}),r.jsx("span",{children:c?`连麦作者 ${l(c,t)} (分享思路)`:"暂无提名,无法连麦"})]}),r.jsx("span",{className:"text-[#908fa0] text-[10px] font-mono",children:"连线"})]}),r.jsxs("button",{type:"button",disabled:!d,onClick:()=>d&&o(d),className:"w-full flex items-center justify-between px-3 py-2 rounded-lg bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449]/50 text-[#dae2fd] transition-colors text-xs text-left disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(qc,{size:14,className:"text-[#4edea3]"}),r.jsx("span",{children:d?`邀请 ${l(d,t)} 投屏分享`:"暂无提名,无法投屏"})]}),r.jsx("span",{className:"text-[#908fa0] text-[10px] font-mono",children:"邀请"})]})]})})()}),r.jsx(Me,{slot:"peer_review.action"}),r.jsxs("div",{className:"pt-2",children:[r.jsxs("button",{type:"button",onClick:a,className:"w-full flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[#c0c1ff] text-[#1000a9] hover:bg-[#8083ff] hover:text-white transition-all shadow-md group font-semibold text-xs text-center",children:[r.jsx("span",{children:"结束互评,公布全堂总积分榜与学情报告"}),r.jsx(yr,{size:14,className:"group-hover:translate-x-1 transition-transform"})]}),r.jsx("div",{className:"text-center mt-2",children:r.jsx("span",{className:"text-[10px] font-mono text-[#908fa0]",children:"HOTKEY: PRESS ENTER TO ADVANCE TO STAGE 03"})})]})]})]})},Dx=({isVisible:e,danmakuList:t,onSendDanmaku:n,isAnonymous:s=!1})=>{const[i,o]=f.useState(""),[a,l]=f.useState(!1);if(!e)return null;const c=u=>{u.preventDefault(),i.trim()&&(n?.(i.trim(),"text"),o(""))},d=()=>{n?.("语音弹幕 · 点赞神仙算法!","voice")};return r.jsxs("div",{id:"peer-review-danmaku-overlay",className:"absolute inset-0 pointer-events-none overflow-hidden z-20",children:[t.map(u=>r.jsx("div",{className:"absolute whitespace-nowrap animate-danmaku-slide pointer-events-auto",style:{top:`${u.topPercent??Math.floor(Math.random()*60)+15}%`,right:"-100%"},children:r.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-[#131b2e]/85 backdrop-blur-md border border-[#2d3449] shadow-lg text-xs text-[#dae2fd]",children:[u.type==="voice"?r.jsxs("span",{className:"flex items-center gap-1 text-[#4edea3] font-mono text-[11px]",children:[r.jsx(Yi,{size:12,className:"animate-pulse"}),r.jsxs("span",{children:[u.voiceDuration||3,"s"]})]}):r.jsx("span",{className:"text-sm",children:"💬"}),r.jsxs("span",{className:"text-[#c0c1ff] font-medium",children:[s&&u.sender.length>1?`${u.sender[0]}**`:u.sender,":"]}),r.jsx("span",{className:u.color||"text-white",children:u.text})]})},u.id)),r.jsx("div",{className:"absolute bottom-4 right-4 pointer-events-auto flex items-center gap-2",children:a?r.jsxs("form",{onSubmit:c,className:"flex items-center gap-1.5 bg-[#131b2e]/95 backdrop-blur-md border border-[#2d3449] p-1.5 rounded-full shadow-xl",children:[r.jsx("input",{type:"text",value:i,onChange:u=>o(u.target.value),placeholder:"发送大屏实时弹幕...",className:"bg-transparent px-3 py-1 text-xs text-white placeholder-[#908fa0] focus:outline-none w-48"}),r.jsx("button",{type:"submit",className:"p-1.5 rounded-full bg-[#c0c1ff] text-[#1000a9] hover:bg-white transition-colors",title:"发送",children:r.jsx(Op,{size:13})}),r.jsx("button",{type:"button",onClick:d,className:"p-1.5 rounded-full bg-[#171f33] hover:bg-[#222a3d] text-[#4edea3] transition-colors",title:"发送语音弹幕",children:r.jsx(Yi,{size:13})}),r.jsx("button",{type:"button",onClick:()=>l(!1),className:"px-2 text-xs text-[#908fa0] hover:text-white",children:"收起"})]}):r.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#131b2e]/90 hover:bg-[#222a3d] backdrop-blur-md border border-[#2d3449] text-xs text-[#c7c4d7] hover:text-white shadow-lg transition-colors cursor-pointer",children:[r.jsx(Kc,{size:13,className:"text-[#c0c1ff]"}),r.jsx("span",{children:"发弹幕"})]})})]})},Mx=({isOpen:e,onClose:t})=>e?r.jsx("div",{id:"peer-review-rubric-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm p-4 select-none",children:r.jsxs("div",{className:"bg-[#131b2e] border border-[#2d3449] rounded-2xl w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh]",children:[r.jsxs("div",{className:"px-6 py-4 bg-[#171f33] border-b border-[#2d3449] flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-xl bg-[#ca8100]/20 text-[#ffb95f] flex items-center justify-center border border-[#ca8100]/30",children:r.jsx(_o,{size:18})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-bold text-[#dae2fd]",children:"随堂交叉互评量规细则"}),r.jsx("p",{className:"text-[11px] text-[#908fa0]",children:"三维评价基准 · 激励互助逆向思考"})]})]}),r.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-[#908fa0] hover:text-white hover:bg-[#222a3d] transition-colors",children:r.jsx(Oe,{size:18})})]}),r.jsxs("div",{className:"p-6 flex flex-col gap-4 overflow-y-auto",children:[r.jsxs("div",{className:"bg-[#171f33] rounded-xl p-4 border border-[#2d3449]/60 flex flex-col gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-6 h-6 rounded-lg bg-[#8083ff]/20 text-[#c0c1ff] font-mono text-xs font-bold flex items-center justify-center",children:"1"}),r.jsx("span",{className:"text-sm font-semibold text-[#dae2fd]",children:"算法逻辑正确性 (40% 权重)"})]}),r.jsx("span",{className:"text-[10px] font-mono text-[#4edea3] bg-[#00a572]/20 px-2 py-0.5 rounded",children:"全班达标率 98%"})]}),r.jsxs("ul",{className:"text-xs text-[#c7c4d7] space-y-1.5 pl-8 list-disc",children:[r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"5.0分(优秀):"}),"算法逻辑自适应,无死循环或边界越界,自适应笔触与角度动态计算完全闭合。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"4.0分(良好):"}),"核心功能正常,少数极端情况存在未自增或微小卡顿。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"3.0分(需改进):"}),"存在语法报错或死循环,需在互评中指明行号与修复要点。"]})]})]}),r.jsxs("div",{className:"bg-[#171f33] rounded-xl p-4 border border-[#2d3449]/60 flex flex-col gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-6 h-6 rounded-lg bg-[#00a572]/20 text-[#4edea3] font-mono text-xs font-bold flex items-center justify-center",children:"2"}),r.jsx("span",{className:"text-sm font-semibold text-[#dae2fd]",children:"代码规范与缩进 (30% 权重)"})]}),r.jsx("span",{className:"text-[10px] font-mono text-[#4edea3] bg-[#00a572]/20 px-2 py-0.5 rounded",children:"全班达标率 96%"})]}),r.jsxs("ul",{className:"text-xs text-[#c7c4d7] space-y-1.5 pl-8 list-disc",children:[r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"5.0分(优秀):"}),"遵循 PEP8 规范,严格对齐 4 空格缩进,变量语义化规范清晰,关键算子附有说明注释。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"4.0分(良好):"}),"缩进基本统一,可读性良好。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"3.0分(需改进):"}),"Tab 与空格混用,循环体代码未有效缩进。"]})]})]}),r.jsxs("div",{className:"bg-[#171f33] rounded-xl p-4 border border-[#2d3449]/60 flex flex-col gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-6 h-6 rounded-lg bg-[#ca8100]/20 text-[#ffb95f] font-mono text-xs font-bold flex items-center justify-center",children:"3"}),r.jsx("span",{className:"text-sm font-semibold text-[#dae2fd]",children:"创意美感与拓展 (30% 权重)"})]}),r.jsx("span",{className:"text-[10px] font-mono text-[#ffb95f] bg-[#ca8100]/20 px-2 py-0.5 rounded",children:"全班达标率 92%"})]}),r.jsxs("ul",{className:"text-xs text-[#c7c4d7] space-y-1.5 pl-8 list-disc",children:[r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"5.0分(优秀):"}),"巧妙运用数学模运算(`i % 3`)或外角定理,呈现层次丰富的动态发散图形。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"4.0分(良好):"}),"图形规则美观,配色和谐。"]}),r.jsxs("li",{children:[r.jsx("strong",{className:"text-white",children:"3.0分(需改进):"}),"单色基础图形,未探索步长或角度变化。"]})]})]}),r.jsx(Me,{slot:"peer_review.rubric.dimension"})]}),r.jsx("div",{className:"px-6 py-3 bg-[#171f33] border-t border-[#2d3449] flex justify-end",children:r.jsx("button",{type:"button",onClick:t,className:"px-4 py-1.5 rounded-xl bg-[#c0c1ff] text-[#1000a9] font-semibold text-xs hover:bg-white transition-colors",children:"我已知晓"})})]})}):null;function $x(e){if(!Array.isArray(e)||e.length===0)return null;let t=0,n=0;for(const s of e){const i=s,o=Number(i.score??i.percentage??i.value);if(!Number.isFinite(o))continue;const a=Number(i.weight??0);!Number.isFinite(a)||a<=0||(t+=o*a,n+=a)}return n<=0?null:Math.round(t/n*10)/10}const Fx=({isOpen:e,onClose:t,onAdvanceToStage3:n,lessonTitle:s="",addToast:i,workA:o,workB:a,showcaseWorks:l=[],onSelectSpotlightWork:c,reviewProgress:d,countdownSeconds:u,onAutoAssign:m,autoAssigning:p=!1,matchingItems:h,badges:x,annotations:g,rubricDimensions:b,reactions:w,podiumStudents:y,danmaku:S,syncedStudentsCount:C,teacherName:k,stageLabel:v})=>{const[N,O]=f.useState({stage:v||"",isLocked:!0,isDualScreen:!0,isAnonymous:!0,timeRemainingSeconds:u??0,totalTimeSeconds:u??0,isPaused:!1,completedReviews:d?.completed??0,totalStudents:d?.total??0,totalLikes:0,totalNominations:0,showVoiceDanmaku:!0,showDanmaku:!0}),[D,_]=f.useState(!1),[T,z]=f.useState(!1),[R,$]=f.useState(!1),[I,B]=f.useState(h??[]),[H,A]=f.useState(x??[]),[U,j]=f.useState(o??null),[V,G]=f.useState(a??null),[E,W]=f.useState(g??[]),[Y,K]=f.useState(b??[]),[ne,fe]=f.useState(w??[]),[je,X]=f.useState(y??[]),[me,ke]=f.useState(S??[]);f.useEffect(()=>{o!==void 0&&j(o)},[o]),f.useEffect(()=>{a!==void 0&&G(a)},[a]),f.useEffect(()=>{h&&B(h)},[h]),f.useEffect(()=>{x&&A(x)},[x]),f.useEffect(()=>{g&&W(g)},[g]),f.useEffect(()=>{b&&K(b)},[b]),f.useEffect(()=>{w&&fe(w)},[w]),f.useEffect(()=>{y&&X(y)},[y]),f.useEffect(()=>{S&&ke(S)},[S]),f.useEffect(()=>{if(!e||N.isPaused)return;const P=setInterval(()=>{O(L=>L.timeRemainingSeconds<=1?{...L,timeRemainingSeconds:0,isPaused:!0}:{...L,timeRemainingSeconds:L.timeRemainingSeconds-1})},1e3);return()=>clearInterval(P)},[e,N.isPaused]);const Se=f.useCallback(P=>{e&&(P.key==="Enter"?(P.preventDefault(),re()):P.key==="Escape"?(P.preventDefault(),t()):P.code==="Space"&&P.target===document.body&&(P.preventDefault(),ee()))},[e,t]);if(f.useEffect(()=>(window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)),[Se]),!e)return null;const M=()=>{O(P=>({...P,isAnonymous:!P.isAnonymous})),i?.("互评模式已切换",N.isAnonymous?"已恢复显示真实学生姓名":"已开启双盲匿名评价模式","info")},Z=()=>{O(P=>({...P,timeRemainingSeconds:P.timeRemainingSeconds+60,totalTimeSeconds:P.totalTimeSeconds+60})),i?.("互评加时","倒计时已增加 1 分钟","success")},ee=()=>{O(P=>({...P,isPaused:!P.isPaused}))},te=()=>{document.fullscreenElement?document.exitFullscreen&&(document.exitFullscreen().catch(()=>{}),_(!1)):(document.documentElement.requestFullscreen().catch(()=>{}),_(!0))},ce=P=>{fe(L=>L.map(F=>F.id===P?{...F,count:F.count+1}:F)),O(L=>({...L,totalLikes:L.totalLikes+1}))},oe=P=>{const L={id:`ann-${Date.now()}`,authorType:"teacher",authorRole:"主讲教师",authorName:k||"教师",timeAgo:"刚刚",content:P,borderColor:"#8083ff"};W(F=>[L,...F]),i?.("批注已挂载","协同板书批注已同步至大屏","success")},xe=(P,L="text")=>{const F={id:`d-${Date.now()}`,sender:k||"教师",text:P,type:L,voiceDuration:void 0,color:"text-[#4edea3]"};ke(q=>[...q,F])},ie=()=>{i?.("功能尚未接入","批量积分发放通道建设中,本次未写入任何积分。","warning")},Pe=()=>{i?.("功能尚未接入","作品归档通道建设中,本次未做任何存储。","warning")},ze=P=>{i?.("功能尚未接入",`向 ${P} 发起连麦的信令通道建设中。`,"warning")},ue=P=>{i?.("功能尚未接入",`向 ${P} 的投屏邀请通道建设中。`,"warning")},re=()=>{i?.("互评阶段已结束","正在推进至 Stage 03 结课巡查与全堂总积分榜...","success"),n&&n(),t()};return r.jsxs("div",{id:"peer-review-showcase-modal",className:"fixed inset-0 z-[9999] bg-[#0b1326] text-[#dae2fd] flex flex-col select-none overflow-hidden font-sans",children:[r.jsx(Px,{state:N,onToggleAnonymous:M,onOpenRubricModal:()=>z(!0),onToggleVoiceDanmaku:()=>O(P=>({...P,showDanmaku:!P.showDanmaku})),onAdvanceStage:re,onAddMinute:Z,onTogglePauseTimer:ee,isFullscreen:D,onToggleFullscreen:te,onClose:t}),r.jsxs("main",{className:"relative flex-1 overflow-y-auto w-full px-6 py-5",children:[!U&&!V&&l.length===0&&I.length===0&&je.length===0&&r.jsxs("div",{className:"mb-4 rounded-xl border border-[#2d3449] bg-[#0b1326] px-4 py-2.5 flex items-center gap-3 text-[11px] text-[#908fa0]",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),r.jsx("span",{className:"flex-1",children:"本节暂无可展示的互评数据(需至少 2 份学生提交作品)。点击右侧按钮按「1 生评 2 份」自动分配。"}),m&&r.jsx("button",{type:"button",disabled:p,onClick:()=>void m(),className:"px-3 py-1 rounded-lg bg-[#8083ff] text-white text-[11px] font-bold hover:bg-[#9497ff] transition-colors disabled:opacity-50 shrink-0",children:p?"分配中…":"一键分配互评"})]}),l&&l.length>0&&r.jsxs("div",{className:"mb-4 rounded-xl border border-[#2d3449] bg-[#131b2e] p-3 flex flex-col gap-2 shadow-md",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-[#4edea3] animate-pulse"}),r.jsxs("span",{className:"text-xs font-bold text-[#dae2fd]",children:["本节提交作品池(跨来源已聚合 ",l.length," 份作品)"]}),r.jsx("span",{className:"text-[10px] text-[#908fa0]",children:"包含课件作答、课堂作业与插件提交,点击可设为大屏焦点 A / B"})]}),r.jsx("button",{type:"button",onClick:()=>$(!R),className:"px-2.5 py-1 rounded-lg bg-[#171f33] hover:bg-[#222a3d] border border-[#2d3449] text-[11px] text-[#c0c1ff] hover:text-white font-medium transition-colors cursor-pointer",children:R?"收起作品池 ▲":`展开作品池 (${l.length}) ▼`})]}),R&&r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2.5 pt-2 border-t border-[#2d3449]/60 max-h-60 overflow-y-auto",children:l.map(P=>{const L=U?.id===P.workId,F=V?.id===P.workId,q=N.isAnonymous&&P.studentName.length>1?`${P.studentName[0]}**`:P.studentName;return r.jsxs("div",{className:`p-2.5 rounded-lg border text-xs flex flex-col gap-1.5 transition-all ${L?"bg-[#8083ff]/15 border-[#8083ff]":F?"bg-[#00a572]/15 border-[#00a572]":"bg-[#171f33] border-[#2d3449]/80 hover:border-[#8083ff]/40"}`,children:[r.jsxs("div",{className:"flex items-center justify-between gap-1",children:[r.jsx("span",{className:"font-semibold text-[#dae2fd] truncate",children:q}),r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium border ${P.source==="plugin"?"bg-[#8083ff]/20 text-[#c0c1ff] border-[#8083ff]/30":P.source==="assignment"?"bg-[#00a572]/20 text-[#4edea3] border-[#00a572]/30":"bg-[#ca8100]/20 text-[#ffb95f] border-[#ca8100]/30"}`,children:P.sourceLabel})]}),r.jsx("div",{className:"text-[11px] text-[#908fa0] truncate",title:P.title,children:P.title}),P.files&&P.files.length>0&&r.jsxs("div",{className:"text-[10px] text-[#8083ff] truncate",children:["📎 ",P.files.length," 个附件 (",P.files.map(J=>J.name).join(", "),")"]}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-auto pt-1",children:[r.jsx("button",{type:"button",onClick:()=>c?.("A",P.workId),className:`flex-1 py-1 rounded text-[10px] font-semibold transition-colors cursor-pointer ${L?"bg-[#8083ff] text-white shadow-xs":"bg-[#222a3d] hover:bg-[#8083ff]/40 text-[#dae2fd]"}`,children:L?"焦点 A ★":"设为焦点 A"}),r.jsx("button",{type:"button",onClick:()=>c?.("B",P.workId),className:`flex-1 py-1 rounded text-[10px] font-semibold transition-colors cursor-pointer ${F?"bg-[#00a572] text-white shadow-xs":"bg-[#222a3d] hover:bg-[#00a572]/40 text-[#dae2fd]"}`,children:F?"焦点 B ★":"设为焦点 B"})]})]},P.workId)})})]}),r.jsx(Dx,{isVisible:N.showDanmaku,danmakuList:me,onSendDanmaku:xe,isAnonymous:N.isAnonymous}),r.jsxs("div",{className:"grid grid-cols-12 gap-5 items-start",children:[r.jsx("div",{className:"col-span-12 lg:col-span-3",children:r.jsx(Ix,{matchingItems:I,badges:H,isAnonymous:N.isAnonymous,onSelectMatchingItem:P=>{i?.(`查看互评明细 ${P.code}`,`${P.reviewerName} 正在审阅 ${P.targetStudentName} 的作业`,"info")}})}),r.jsxs("div",{className:"col-span-12 lg:col-span-6 flex flex-col gap-4",children:[!U&&!V&&r.jsxs("div",{className:"rounded-xl border border-dashed border-[#2d3449] bg-[#0b1326] p-6 text-center",children:[r.jsx("p",{className:"text-xs font-bold text-[#dae2fd]",children:"暂无提交作品可供对比"}),r.jsx("p",{className:"text-[10px] text-[#908fa0] mt-1",children:"学生提交课件作业后,此处将自动展示两份真实作品的并排对比。"})]}),U||V?r.jsx(Rx,{workA:U,workB:V,annotations:E,isAnonymous:N.isAnonymous,onFullscreenCanvas:te,onSyncSandboxToClass:()=>{i?.("沙箱广播已生效",`对比范本已同步至全班 ${N.totalStudents||0} 台学生机控制台`,"success")},onAddAnnotation:oe}):null,r.jsx(_x,{dimensions:Y,averagePercentage:$x(Y),reactions:ne,onReactionClick:ce,syncedStudentsCount:C})]}),r.jsx("div",{className:"col-span-12 lg:col-span-3",children:r.jsx(Ox,{podiumStudents:je,isAnonymous:N.isAnonymous,onAwardPeerReviewPoints:ie,onArchiveTopWorks:Pe,onCallStudentMic:ze,onInviteScreenShare:ue,onAdvanceToStage3:re})})]})]}),r.jsx(Mx,{isOpen:T,onClose:()=>z(!1)})]})};let Pn=null;const so=new Set;function xd(e){if(Pn=e,!!e)for(const t of so)try{t(e)}catch(n){console.error("[socket-service] socket-ready listener error:",n)}}function Yo(e){if(so.add(e),Pn)try{e(Pn)}catch(t){console.error("[socket-service] socket listener error:",t)}return()=>{so.delete(e)}}function Bx(){if(!Pn)throw new Error("Socket instance not initialized. Call setSocketInstance() first.");return Pn}function lt(){return Pn}class Ux{constructor(t){this.socket=t,xd(t)}emit(t,...n){this.socket.emit(t,...n)}on(t,n){this.socket.on(t,n)}off(t,n){this.socket.off(t,n)}disconnect(){this.socket.disconnect()}}const nr={stage:"IN_CLASS_TEACHING",checkinCode:null,activePoll:null,activeBuzzer:null,pacing:{TOO_FAST:0,CONFUSED:0,CLEAR:0},classId:null,sessionId:null,stageStartedAt:null,attendance:{online:0,onlineInClass:0,expected:0,attended:0},feed:[],courseware:{attempts:0,participants:0,completed:0,avgCompletion:0},exitTicketSubmitted:0},Vx=["classroom:stage_changed","classroom:quick_poll_started","classroom:quick_poll_updated","classroom:quick_poll_closed","classroom:buzzer_ready","classroom:buzzer_winner","classroom:buzzer_reset","classroom:pacing_updated","classroom:countdown_updated","classroom:exit_ticket_submitted","classroom:feed_appended","classroom:pulse_check_requested","classroom:checkin_submitted"],Hx=4e3;function Wx(e,t={}){const{enabled:n=!0,reconcileMs:s=Hx}=t,[i,o]=f.useState(nr),[a,l]=f.useState("polling"),[c,d]=f.useState(null),u=f.useRef(0),m=f.useRef(!0);f.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const p=f.useCallback(async()=>{if(!e)return;const h=++u.current;try{const x=await fetch(`/api/classroom/stage/${encodeURIComponent(e)}/data`);if(!x.ok)throw new Error(`stage data HTTP ${x.status}`);const g=await x.json();if(!m.current||h!==u.current)return;o({...nr,...g,pacing:{...nr.pacing,...g.pacing||{}}}),d(Date.now()),l(b=>b==="reconnecting"?"live":b==="error"?"polling":b)}catch(x){if(!m.current)return;l(g=>g==="live"?"reconnecting":g),console.warn("[StageDisplay] sync failed:",x)}},[e]);return f.useEffect(()=>{if(!n||!e)return;p();const h=setInterval(()=>void p(),s);return()=>clearInterval(h)},[n,e,s,p]),f.useEffect(()=>{if(!n||!e)return;let h=null;const x=()=>{h||(h=setTimeout(()=>{h=null,p()},120))};let g=null;const b=Yo(w=>{g?.(),w.emit("join-room",e);const y=Vx.map(v=>{const N=O=>{const D=O?.lessonId;D&&D!==e||x()};return w.on(v,N),[v,N]}),S=()=>{l("live"),p()},C=()=>l("reconnecting"),k=()=>l("reconnecting");w.on("connect",S),w.on("disconnect",C),w.on("connect_error",k),w.connected&&l("live"),g=()=>{for(const[v,N]of y)w.off(v,N);w.off("connect",S),w.off("disconnect",C),w.off("connect_error",k)}});return()=>{b(),g?.(),h&&clearTimeout(h)}},[n,e,p]),{data:i,health:a,lastSyncedAt:c,refresh:p}}const qx={PRE_CLASS_READY:{zh:"课前就绪 · 准备上课",en:"Pre-Class Preparation"},IN_CLASS_TEACHING:{zh:"课中授课 · 互动探索",en:"Interactive Teaching"},WRAP_UP_EXIT_TICKET:{zh:"总结提升 · 结课通票",en:"Wrap-Up & Exit Ticket"},ARCHIVED_REPORT:{zh:"下课归档 · 学情简报",en:"Archived Report"}};function Zo(e,t="zh"){const n=qx[e];return n?t==="zh"?n.zh:n.en:e}let Xa=0;function Rt(e){return Xa+=1,`${e}-${Date.now().toString(36)}-${Xa}`}function Gx(e,t,n={}){const{lang:s="zh",isFirstFrame:i=!1}=n,o=s==="zh",a=[];if(!e||i)return a;if(e.stage!==t.stage){const h=Zo(t.stage,s),x=t.stage==="ARCHIVED_REPORT",g=t.stage==="WRAP_UP_EXIT_TICKET";let b;g?b=o?"请提醒学生在设备上完成 60 秒结课通票":"Remind students to complete the 60s exit ticket":x&&(b=o?"本课节已归档,大屏将展示学情简报":"Lesson archived; the stage will show the learning report");let w="info",y="🎓";g?(w="accent",y="🎫"):x&&(w="warning",y="📦"),a.push({id:Rt("stage"),tone:w,icon:y,title:o?`课堂环节已切换:${h}`:`Stage changed: ${h}`,detail:b,dedupeKey:`stage:${t.stage}`})}const l=e.activePoll?.id??null,c=t.activePoll?.id??null;if(c&&c!==l)a.push({id:Rt("poll-start"),tone:"accent",icon:"⚡",title:o?"课堂极速投票已开始":"Quick poll started",detail:t.activePoll?.title?String(t.activePoll.title):void 0,dedupeKey:`poll-start:${c}`});else if(l&&!c){const h=e.activePoll?.totalVotes??0;a.push({id:Rt("poll-end"),tone:"info",icon:"📊",title:o?"课堂投票已结束":"Quick poll closed",detail:o?`本轮共 ${h} 人作答`:`${h} responded in this round`,dedupeKey:`poll-end:${l}`})}const d=e.activeBuzzer?.id??null,u=t.activeBuzzer?.id??null,m=e.activeBuzzer?.status??null,p=t.activeBuzzer?.status??null;if(u&&u!==d)a.push({id:Rt("buzz-start"),tone:"accent",icon:"🔔",title:o?"抢答已开始":"Buzz-in started",detail:t.activeBuzzer?.title?String(t.activeBuzzer.title):void 0,dedupeKey:`buzz-start:${u}`});else if(u&&u===d&&p==="LOCKED"&&m!=="LOCKED"){const h=t.activeBuzzer?.winnerName,x=t.activeBuzzer?.responseTimeMs;a.push({id:Rt("buzz-winner"),tone:"success",icon:"🏆",title:o?"抢答已产生赢家":"Buzz-in winner decided",detail:h?o?`${h}${x?` · 响应用时 ${x} 毫秒`:""}`:`${h}${x?` · ${x} ms`:""}`:void 0,dedupeKey:`buzz-winner:${u}`})}else u&&u===d&&p==="READY"&&m==="LOCKED"&&a.push({id:Rt("buzz-reset"),tone:"info",icon:"♻️",title:o?"抢答已重置,可以开始新一轮":"Buzzer reset — ready for a new round",dedupeKey:`buzz-reset:${u}`});return a}function Qx(e,t,n="zh"){const s=n==="zh";return e===t?null:e==="reconnecting"?{id:Rt("conn"),tone:"warning",icon:"📡",title:s?"实时连接已断开,正在重连":"Live connection lost, reconnecting…",detail:s?"大屏内容可能不是最新,将以低频轮询兜底":"Falling back to low-frequency polling",dedupeKey:"conn:reconnecting"}:e==="live"&&t==="reconnecting"?{id:Rt("conn"),tone:"success",icon:"✅",title:s?"实时连接已恢复":"Live connection restored",dedupeKey:"conn:live"}:null}const el={info:{ring:"border-sky-500/50 bg-sky-500/10 text-sky-200",icon:Yc},success:{ring:"border-emerald-500/50 bg-emerald-500/10 text-emerald-200",icon:at},warning:{ring:"border-amber-500/50 bg-amber-500/10 text-amber-200",icon:Mt},accent:{ring:"border-indigo-500/50 bg-indigo-500/10 text-indigo-200",icon:yt}},Jx=6e3,tl=8e3;function Kx({notices:e,onDismiss:t,lang:n="zh"}){const s=e.slice(-4),i=f.useRef(new Map);return f.useEffect(()=>{for(const a of s){if(i.current.has(a.id))continue;const l=setTimeout(()=>{i.current.delete(a.id),t(a.id)},Jx);i.current.set(a.id,l)}const o=new Set(s.map(a=>a.id));for(const[a,l]of i.current)o.has(a)||(clearTimeout(l),i.current.delete(a))},[s,t]),f.useEffect(()=>()=>{for(const o of i.current.values())clearTimeout(o);i.current.clear()},[]),s.length===0?null:r.jsx("div",{"aria-live":"polite","data-testid":"stage-notice-stack",className:"fixed top-24 right-8 z-[10000] flex flex-col gap-2.5 w-[360px] pointer-events-none",children:s.map(o=>{const a=el[o.tone]??el.info,l=a.icon;return r.jsxs("div",{"data-testid":"stage-notice","data-dedupe-key":o.dedupeKey,className:`pointer-events-auto flex items-start gap-3 px-4 py-3 rounded-2xl border backdrop-blur-md shadow-2xl animate-slide-up ${a.ring}`,children:[r.jsx("span",{className:"text-xl leading-none shrink-0 mt-0.5","aria-hidden":"true",children:o.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(l,{size:14,className:"shrink-0"}),r.jsx("span",{className:"text-sm font-bold truncate",children:o.title})]}),o.detail&&r.jsx("p",{className:"text-xs opacity-80 mt-1 line-clamp-2",children:o.detail})]}),r.jsx("button",{onClick:()=>t(o.id),"aria-label":n==="zh"?"关闭提示":"Dismiss",className:"shrink-0 p-1 rounded-lg opacity-60 hover:opacity-100 hover:bg-white/10 transition-colors cursor-pointer",children:r.jsx(Oe,{size:14})})]},o.id)})})}function Yx(e="zh"){const[t,n]=f.useState([]),s=f.useRef(new Map),i=f.useCallback(l=>{if(l.length===0)return;const c=Date.now();n(d=>{let u=d;for(const m of l){const p=s.current.get(m.dedupeKey);if(!(p&&c-p<tl)){s.current.set(m.dedupeKey,c);for(const[h,x]of s.current)c-x>tl&&s.current.delete(h);u=[...u,m]}}return u.length>40?u.slice(u.length-40):u})},[]),o=f.useCallback(l=>{n(c=>c.filter(d=>d.id!==l))},[]),a=f.useCallback(()=>n([]),[]);return{notices:t,push:i,dismiss:o,clear:a}}function Zx({health:e,lastSyncedAt:t,lang:n="zh"}){const s=n==="zh",o={live:{label:s?"实时连接":"Live",cls:"text-emerald-300 border-emerald-500/40 bg-emerald-500/10",dot:"bg-emerald-400 animate-pulse",Icon:Ki},reconnecting:{label:s?"重连中":"Reconnecting",cls:"text-amber-300 border-amber-500/40 bg-amber-500/10",dot:"bg-amber-400 animate-ping",Icon:Va},polling:{label:s?"轮询同步":"Polling",cls:"text-sky-300 border-sky-500/40 bg-sky-500/10",dot:"bg-sky-400",Icon:Ki},error:{label:s?"连接异常":"Error",cls:"text-rose-300 border-rose-500/40 bg-rose-500/10",dot:"bg-rose-400",Icon:Va}}[e],a=o.Icon,l=t?new Date(t).toLocaleTimeString():"--:--:--";return r.jsxs("div",{"data-testid":"stage-connection-badge","data-health":e,className:`flex items-center gap-2 px-3 py-2 rounded-xl border font-semibold text-xs ${o.cls}`,title:s?`最近同步:${l}`:`Last sync: ${l}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${o.dot}`}),r.jsx(a,{size:13}),r.jsx("span",{children:o.label}),r.jsx("span",{className:"font-mono opacity-70",children:l})]})}function Xx(){if(typeof document>"u")return!1;const e=document.documentElement;return!!(e.requestFullscreen||e.webkitRequestFullscreen)}function Ms(){return typeof document>"u"?!1:!!(document.fullscreenElement||document.webkitFullscreenElement)}function eb(){const[e,t]=f.useState(!1),[n,s]=f.useState(!1),i=f.useRef(!1);f.useEffect(()=>{if(typeof document>"u")return;const c=()=>{const d=Ms();s(d),d||(i.current=!1,t(!1))};return document.addEventListener("fullscreenchange",c),document.addEventListener("webkitfullscreenchange",c),()=>{document.removeEventListener("fullscreenchange",c),document.removeEventListener("webkitfullscreenchange",c)}},[]),f.useEffect(()=>{if(typeof window>"u")return;const c=d=>{d.key==="Escape"&&(Ms()||i.current&&(i.current=!1,t(!1)))};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[]);const o=f.useCallback(async()=>{if(t(!0),!Xx()){i.current=!0;return}try{const c=document.documentElement;await(c.requestFullscreen?.()??c.webkitRequestFullscreen?.()),s(!0)}catch(c){i.current=!0,console.warn("[ViewportFullscreen] native fullscreen rejected, falling back to viewport fill:",c)}},[]),a=f.useCallback(async()=>{if(i.current=!1,t(!1),s(!1),Ms())try{await document.exitFullscreen?.()}catch(c){console.warn("[ViewportFullscreen] exit failed:",c)}},[]),l=f.useCallback(()=>{Ms()||i.current?a():o()},[o,a]);return{isFullscreen:e,nativeActive:n,toggle:l,exit:a}}function Nt(e){return typeof e=="number"&&Number.isFinite(e)?String(e):"—"}function ps(e,t){return!t||t<=0?"—":`${Math.round(e/t*100)}%`}function tb({attendance:e,zh:t=!0}){const n=e?.onlineInClass??0,s=e?.expected??0,i=e?.attended??0,o=ps(n,s),a=s>0;return r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-6 shadow-xl flex flex-col gap-4",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800/80 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-white font-bold text-base",children:[r.jsx(Uc,{size:18,className:"text-blue-400"}),r.jsx("span",{children:t?"课堂出勤":"Attendance"})]}),r.jsxs("span",{"data-testid":"stage-attendance-online",className:"flex items-center gap-1.5 text-xs font-semibold text-emerald-300",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),t?"实时在线":"Online"," ",Nt(n)]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsx("div",{className:"text-2xl font-black font-mono text-white",children:Nt(n)}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"本班在线":"Online"})]}),r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsx("div",{className:"text-2xl font-black font-mono text-white",children:Nt(i)}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"已到课":"Attended"})]}),r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsx("div",{className:"text-2xl font-black font-mono text-white",children:Nt(s)}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"应到":"Expected"})]})]}),a?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:t?"实到率":"Attendance rate"}),r.jsx("span",{className:"font-mono font-bold text-white",children:ps(i,s)})]}),r.jsx("div",{className:"h-3 w-full bg-slate-800 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-blue-500 rounded-full transition-all duration-500",style:{width:ps(i,s)}})}),r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:t?"当前在线率":"Live online rate"}),r.jsx("span",{className:"font-mono font-bold text-emerald-300",children:o})]})]}):r.jsx("p",{className:"text-[11px] text-slate-400 leading-relaxed",children:t?"本课节未绑定班级名单,暂无应到/实到口径(避免用 0% 误导为「无人到课」)。":"No class roster bound to this lesson; expected/attended is unavailable."})]})}function nb({stats:e,zh:t=!0}){const n=e?.attempts??0,s=e?.participants??0,i=e?.completed??0,o=e?.avgCompletion??0,a=n>0;return r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-6 shadow-xl flex flex-col gap-4",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800/80 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-white font-bold text-base",children:[r.jsx(Dp,{size:18,className:"text-amber-400"}),r.jsx("span",{children:t?"互动课件参与":"Courseware Activity"})]}),a&&r.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:[n," ",t?"次作答":"attempts"]})]}),a?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsx("div",{className:"text-2xl font-black font-mono text-white",children:Nt(s)}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"参与人数":"Students"})]}),r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsx("div",{className:"text-2xl font-black font-mono text-white",children:Nt(i)}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"已完成":"Completed"})]}),r.jsxs("div",{className:"bg-slate-800/50 rounded-2xl border border-slate-700/50 py-3",children:[r.jsxs("div",{className:"text-2xl font-black font-mono text-white",children:[Nt(o),"%"]}),r.jsx("div",{className:"text-[11px] text-slate-400 mt-1",children:t?"平均完成度":"Avg done"})]})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:t?"完成率":"Completion rate"}),r.jsx("span",{className:"font-mono font-bold text-white",children:ps(i,n)})]}),r.jsx("div",{className:"h-3 w-full bg-slate-800 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-amber-500 rounded-full transition-all duration-500",style:{width:ps(i,n)}})})]}):r.jsxs("p",{className:"text-[11px] text-slate-400 leading-relaxed flex items-center gap-2",children:[r.jsx(_o,{size:14,className:"shrink-0"}),t?"还没有学生打开互动课件。展示口径为平台累计(含往期课节),作答数据将在学生开始操作后实时出现。":"No courseware activity yet."]})]})}const sb={quiz_answered:"✅",checkin:"🙋",achievement:"🏅",assignment_submitted:"📄",assignment_graded:"🖊️",progress:"📈",courseware_submitted:"🖥️",answer:"💡",success:"🎉",info:"ℹ️"};function rb({feed:e,zh:t=!0}){const n=e??[];return r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-6 shadow-xl flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800/80 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-white font-bold text-base",children:[r.jsx(Mo,{size:18,className:"text-blue-400"}),r.jsx("span",{children:t?"课堂动态":"Live Feed"})]}),r.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:[n.length," ",t?"条":"items"]})]}),n.length>0?r.jsx("ul",{className:"flex flex-col gap-1.5 max-h-64 overflow-y-auto no-scrollbar",children:n.map(s=>r.jsxs("li",{className:"flex items-start gap-2 text-xs text-slate-300 px-2 py-1.5 rounded-lg hover:bg-slate-800/50 transition-colors",children:[r.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:sb[s.type]??"•"}),r.jsxs("span",{className:"flex-1 leading-relaxed break-words",children:[s.actorName?r.jsx("span",{className:"font-bold text-white",children:s.actorName}):null,r.jsx("span",{className:"ml-1",children:s.message})]}),s.at>0&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-slate-400",children:new Date(s.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},s.id))}):r.jsxs("p",{className:"text-[11px] text-slate-400 leading-relaxed flex items-center gap-2",children:[r.jsx(Zc,{size:14,className:"shrink-0"}),t?"课堂动态会在学生答题、签到、提交课件时实时出现在这里。":"Live events will appear here."]})]})}function ib({submitted:e,expected:t,zh:n=!0}){const s=e??0,i=t??0;return r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Mp,{size:13,className:"text-indigo-400"}),n?"结课通票已提交":"Exit tickets submitted"]}),r.jsxs("span",{className:"font-mono font-bold text-white",children:[Nt(s),i>0?` / ${Nt(i)}`:""]})]})}function ob({lessonId:e,lessonTitle:t="互动课堂",data:n,lang:s="zh",health:i,lastSyncedAt:o,showCloseButton:a=!0,onClose:l,peerReview:c,syncedStudentsCount:d,peerReviewOpen:u,onOpenPeerReview:m,onClosePeerReview:p}){const{isFullscreen:h,toggle:x}=eb(),[g,b]=f.useState(""),[w,y]=f.useState(!1),S=u??w,C=N=>{u===void 0&&y(N),N?m?.():p?.()};f.useEffect(()=>{const N=()=>{b(new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}))};N();const O=setInterval(N,1e3);return()=>clearInterval(O)},[]);const k=n.pacing??nr.pacing,v=(k.TOO_FAST||0)+(k.CONFUSED||0)+(k.CLEAR||0);return r.jsxs("div",{id:"stage-display-modal",className:"fixed inset-0 z-[9999] bg-slate-950 text-slate-100 flex flex-col select-none overflow-hidden",children:[r.jsxs("header",{className:"h-20 px-8 bg-slate-900/80 border-b border-slate-800 flex items-center justify-between backdrop-blur-md",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5 bg-blue-500/10 border border-blue-500/30 rounded-full text-blue-400 font-semibold text-sm",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-blue-400 animate-ping"}),r.jsx("span",{children:s==="zh"?"大屏教学展台":"Stage Display"})]}),r.jsx("h1",{className:"text-2xl font-bold tracking-tight text-white line-clamp-1",children:t}),r.jsx("span",{className:"px-3 py-1 bg-slate-800 text-slate-300 text-xs font-mono rounded-md border border-slate-700",children:Zo(n.stage,s)})]}),r.jsxs("div",{className:"flex items-center gap-6",children:[i&&r.jsx(Zx,{health:i,lastSyncedAt:o??null,lang:s}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-800/60 rounded-xl border border-slate-700/60 font-mono text-xl font-bold text-slate-200",children:[r.jsx(Es,{size:20,className:"text-blue-400"}),r.jsx("span",{children:g})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Me,{slot:"stage.display.action",slotProps:{lessonId:e,lessonTitle:t,stage:n.stage,data:n,isFullscreen:h,lang:s,onToggleFullscreen:x,onOpenPeerReview:()=>C(!0)}}),r.jsxs("button",{id:"stage-peer-review-toggle",type:"button",onClick:()=>C(!0),className:"flex items-center gap-1.5 px-3 py-2 bg-teal-500/20 hover:bg-teal-500/30 text-teal-300 rounded-xl transition-colors border border-teal-500/40 text-xs font-semibold cursor-pointer",title:"进入全班大屏作业互评与协同赏析模式 (Stitch 21e2dac1)",children:[r.jsx(Qc,{size:15}),r.jsx("span",{children:"作业互评赏析"})]}),r.jsx("button",{id:"stage-fullscreen-toggle",onClick:x,className:"p-3 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl transition-colors border border-slate-700 cursor-pointer",title:h?"退出全屏":"全屏展示",children:h?r.jsx($p,{size:20}):r.jsx(Fp,{size:20})}),a&&r.jsx("button",{id:"stage-close-button",onClick:l,className:"p-3 bg-rose-900/40 hover:bg-rose-900/70 text-rose-300 rounded-xl transition-colors border border-rose-800/50 cursor-pointer",title:"关闭展台",children:r.jsx(Oe,{size:20})})]})]})]}),r.jsx("div",{className:"max-h-12 overflow-hidden shrink-0",children:r.jsx(Me,{slot:"classroom.stage.display.ticker",slotProps:{lessonId:e,lessonTitle:t,stage:n.stage,data:n,lang:s}})}),r.jsxs("main",{className:"flex-1 p-8 grid grid-cols-12 gap-8 overflow-y-auto",children:[r.jsxs("section",{className:"col-span-8 flex flex-col gap-6",children:[n.stage==="PRE_CLASS_READY"&&r.jsxs("div",{className:"flex-1 bg-gradient-to-br from-slate-900 to-slate-800 rounded-3xl border border-slate-800 p-10 flex flex-col justify-center items-center text-center shadow-2xl",children:[r.jsx("div",{className:"p-4 bg-blue-500/10 rounded-3xl border border-blue-500/20 text-blue-400 mb-6",children:r.jsx(Zc,{size:48,className:"animate-pulse"})}),r.jsx("h2",{className:"text-3xl font-extrabold text-white mb-2",children:s==="zh"?"即将开始上课,请同学们准备":"Class Starting Soon"}),r.jsx("p",{className:"text-slate-400 text-lg mb-8 max-w-md",children:s==="zh"?"请打开平板或电脑进入课堂,输入口令加入":"Please join the interactive session using your device"}),n.checkinCode&&r.jsxs("div",{className:"px-10 py-6 bg-slate-800/90 rounded-2xl border border-blue-500/40 shadow-inner flex flex-col items-center",children:[r.jsx("span",{className:"text-xs uppercase tracking-widest text-slate-400 font-bold mb-2",children:s==="zh"?"课堂入课口令":"Class Code"}),r.jsx("span",{className:"text-6xl font-mono font-black tracking-wider text-blue-400",children:n.checkinCode})]})]}),n.activePoll&&r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-8 shadow-xl flex flex-col gap-6",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800/80 pb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"p-2.5 bg-amber-500/10 text-amber-400 rounded-xl border border-amber-500/20",children:r.jsx(yt,{size:24})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-xs font-bold text-amber-400 uppercase tracking-wide",children:s==="zh"?"课堂极速互动":"Quick Activity"}),r.jsx("h3",{className:"text-xl font-bold text-white",children:n.activePoll.title})]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("span",{className:"text-3xl font-black text-amber-400 font-mono",children:n.activePoll.totalVotes||0}),r.jsx("span",{className:"text-xs text-slate-400 block",children:s==="zh"?"人已作答":"Responded"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-4 my-2",children:(Array.isArray(n.activePoll.options)&&n.activePoll.options.length>0?n.activePoll.options:[]).map(N=>{const O=n.activePoll.distribution?.[N]||0,D=Math.round(O/(n.activePoll.totalVotes||1)*100);return r.jsxs("div",{className:"p-5 bg-slate-800/50 rounded-2xl border border-slate-700/50 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"w-10 h-10 rounded-xl bg-blue-600 text-white font-bold text-lg flex items-center justify-center shadow-md",children:N}),r.jsxs("span",{className:"font-semibold text-slate-200 text-lg",children:["选项 ",N]})]}),r.jsxs("span",{className:"font-mono font-bold text-xl text-blue-400",children:[D,"% (",O,")"]})]}),r.jsx("div",{className:"h-4 w-full bg-slate-700/40 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-indigo-500 transition-all duration-500 rounded-full",style:{width:`${D}%`}})})]},N)})})]}),n.activeBuzzer&&r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-8 shadow-xl flex flex-col items-center text-center justify-center",children:[r.jsx("div",{className:"p-4 bg-rose-500/10 rounded-2xl border border-rose-500/20 text-rose-400 mb-4",children:r.jsx($o,{size:36,className:"animate-bounce"})}),r.jsx("h3",{className:"text-2xl font-bold text-white mb-2",children:n.activeBuzzer.title}),n.activeBuzzer.status==="READY"?r.jsxs("div",{className:"my-6 py-6 px-12 bg-rose-950/30 border border-rose-500/30 rounded-2xl",children:[r.jsx("span",{className:"text-4xl font-extrabold text-rose-400 animate-pulse block",children:s==="zh"?"⚡ 全班抢答中...":"⚡ Buzzing in progress..."}),r.jsx("span",{className:"text-sm text-slate-400 mt-2 block",children:s==="zh"?"请按手中的抢答按钮!":"Press your buzzer now!"})]}):r.jsxs("div",{className:"my-6 py-6 px-12 bg-emerald-950/30 border border-emerald-500/40 rounded-2xl flex flex-col items-center",children:[r.jsx(Oo,{size:48,className:"text-amber-400 mb-2"}),r.jsx("span",{className:"text-sm text-emerald-400 font-bold tracking-wide uppercase",children:s==="zh"?"🎉 抢答成功!":"🎉 First to Buzz!"}),r.jsx("span",{className:"text-5xl font-black text-white my-2 font-mono",children:n.activeBuzzer.winnerName||"同学"}),n.activeBuzzer.responseTimeMs&&r.jsx("span",{className:"text-sm font-mono text-emerald-300",children:s==="zh"?`响应用时:${n.activeBuzzer.responseTimeMs} 毫秒`:`Reaction time: ${n.activeBuzzer.responseTimeMs} ms`})]})]}),n.stage==="WRAP_UP_EXIT_TICKET"&&r.jsxs("div",{className:"bg-gradient-to-br from-indigo-950/40 to-slate-900 rounded-3xl border border-indigo-800/40 p-8 shadow-xl flex flex-col items-center text-center",children:[r.jsx(Bp,{size:48,className:"text-indigo-400 mb-4"}),r.jsx("h3",{className:"text-3xl font-extrabold text-white mb-2",children:s==="zh"?"60 秒结课通票 (Exit Ticket)":"60s Exit Ticket"}),r.jsx("p",{className:"text-slate-300 text-lg max-w-lg mb-6",children:s==="zh"?"请同学们打开设备完成本次课堂评估:选星级、写下今天最困惑的一个知识点。":"Please complete your 60-second summary ticket on your device."})]}),!n.activePoll&&!n.activeBuzzer&&n.stage!=="PRE_CLASS_READY"&&n.stage!=="WRAP_UP_EXIT_TICKET"&&r.jsxs("div",{className:"flex-1 min-h-[220px] bg-gradient-to-br from-slate-900 to-slate-800 rounded-3xl border border-slate-800 p-10 flex flex-col justify-center items-center text-center",children:[r.jsx("div",{className:"p-4 bg-slate-800/60 rounded-3xl border border-slate-700/50 text-slate-400 mb-5",children:r.jsx(Fo,{size:40})}),r.jsx("h3",{className:"text-2xl font-extrabold text-white mb-2",children:s==="zh"?"等待课堂互动":"Waiting for classroom activity"}),r.jsx("p",{className:"text-slate-400 text-base max-w-lg",children:s==="zh"?"当前没有进行中的投票或抢答。教师发起互动后,这里会立刻展示实时结果;右侧的出勤、课件参与与课堂动态为实时数据。":"No poll or buzz-in is running. Real-time results will appear here; attendance and activity metrics are live on the right."})]}),r.jsx(Me,{slot:"stage.display.card",slotProps:{lessonId:e,stage:n.stage}})]}),r.jsxs("aside",{className:"col-span-4 flex flex-col gap-6",children:[r.jsx(tb,{attendance:n.attendance,zh:s==="zh"}),r.jsx(nb,{stats:n.courseware,zh:s==="zh"}),n.stage==="WRAP_UP_EXIT_TICKET"&&r.jsx("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-5 shadow-xl",children:r.jsx(ib,{submitted:n.exitTicketSubmitted,expected:n.attendance?.expected,zh:s==="zh"})}),r.jsx(rb,{feed:n.feed,zh:s==="zh"}),r.jsxs("div",{className:"bg-slate-900/90 rounded-3xl border border-slate-800 p-6 shadow-xl flex flex-col gap-4",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800/80 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-white font-bold text-base",children:[r.jsx(Up,{size:18,className:"text-blue-400"}),r.jsx("span",{children:s==="zh"?"学习节奏晴雨表":"Pacing Barometer"})]}),r.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:[v," ",s==="zh"?"次反馈":"signals"]})]}),r.jsxs("div",{className:"flex flex-col gap-3 my-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("span",{className:"flex items-center gap-2 text-emerald-300 font-medium",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400"}),s==="zh"?"听懂了 / 节奏合适":"Clear & Smooth"]}),r.jsx("span",{className:"font-mono font-bold text-white",children:k.CLEAR||0})]}),r.jsx("div",{className:"h-3 w-full bg-slate-800 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all duration-500",style:{width:`${v>0?(k.CLEAR||0)/v*100:0}%`}})}),r.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[r.jsxs("span",{className:"flex items-center gap-2 text-amber-300 font-medium",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400"}),s==="zh"?"有些困惑 / 需点拨":"Confused"]}),r.jsx("span",{className:"font-mono font-bold text-white",children:k.CONFUSED||0})]}),r.jsx("div",{className:"h-3 w-full bg-slate-800 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-amber-500 rounded-full transition-all duration-500",style:{width:`${v>0?(k.CONFUSED||0)/v*100:0}%`}})}),r.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[r.jsxs("span",{className:"flex items-center gap-2 text-rose-300 font-medium",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-rose-400"}),s==="zh"?"讲太快了 / 跟不上":"Too Fast"]}),r.jsx("span",{className:"font-mono font-bold text-white",children:k.TOO_FAST||0})]}),r.jsx("div",{className:"h-3 w-full bg-slate-800 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-rose-500 rounded-full transition-all duration-500",style:{width:`${v>0?(k.TOO_FAST||0)/v*100:0}%`}})})]}),r.jsx("p",{className:"text-xs text-slate-400 text-center mt-2",children:s==="zh"?"提示:此数据来自学生端匿名点击,自动脱敏保护学生自尊。":"Aggregated anonymized signals from student devices."})]})]})]}),S&&r.jsx(Fx,{isOpen:S,onClose:()=>C(!1),lessonTitle:t,syncedStudentsCount:d,...c??{}}),r.jsx("div",{className:"absolute inset-0 pointer-events-none z-30 overflow-hidden",children:r.jsx(Me,{slot:"stage.display.overlay",slotProps:{lessonId:e,lessonTitle:t,stage:n.stage,data:n,isFullscreen:h,lang:s}})})]})}const ab=/\b(function|const|let|var|class|def|import|return|if|for|while|print|console)\b|[{};]\s*$/;function lb(e){const t=Array.isArray(e)?e.filter(Boolean):[];if(t.length===0)return{kind:"empty",lines:[],eventCount:0};const n=t.filter(u=>{const m=String(u?.eventType??u?.event_type??"").toLowerCase();return m.includes("submit")||m.includes("finish")||m.includes("complete")}),s=n.length>0?n:t,i=s[s.length-1],o=i?.payload??i?.payloadJson??i?.data??{},a=db(o,["code","source","src","program","html","content","answer"]);if(a&&(ab.test(a)||a.includes(`
|
|
3
3
|
`)||a.length>120))return{kind:"code",lines:a.split(`
|
|
4
4
|
`).slice(0,14).map(u=>({text:u.slice(0,160),indent:Math.floor((u.match(/^\s*/)?.[0].length??0)/2),isHighlight:/correct|answer|正确|对|错|✓|✗/i.test(u)})),eventCount:t.length};const l=Object.entries(o).filter(([,u])=>typeof u!="object"||u===null),c=l.filter(([u])=>!cb.has(u.toLowerCase()));if(c.length>=3)return{kind:"structured",lines:c.slice(0,10).map(([u,m])=>({text:`${u}: ${ub(m)}`,indent:0})),eventCount:t.length};if(a)return{kind:"text",lines:a.split(`
|
|
@@ -7,9 +7,9 @@ import{r as f,j as r,R as De,u as Fc,g as Bc,b as kp,d as Wi,h as qi,J as Ba,i a
|
|
|
7
7
|
`).slice(0,16).map(a=>({text:a,indent:0})):void 0;return{id:e.workId,slot:t,studentName:s,studentInitial:s.slice(0,1),workTitle:e.title||`${s} · ${e.sourceLabel}`,workSubtitle:`${e.sourceLabel}${typeof e.score=="number"?` · 得分 ${e.score}`:""}`,source:e.source,sourceLabel:e.sourceLabel,textContent:e.textContent,files:e.files,submittedAt:e.submittedAt,badges:[],workContent:i??null,codeTitle:e.title?`${e.sourceLabel} · ${e.title}`:void 0,codeLines:o}}function fb({lessonId:e,enabled:t,attempts:n,studentCount:s,addToast:i,lang:o="zh"}){const[a,l]=f.useState([]),[c,d]=f.useState(null),[u,m]=f.useState([]),[p,h]=f.useState(null),[x,g]=f.useState(null),[b,w]=f.useState(!1),y=f.useCallback((D,_)=>{D==="A"?h(_):g(_)},[]);f.useEffect(()=>{if(!e){l([]);return}let D=!0;const _=async()=>{try{const z=await fetch(`/api/classroom/sessions/${e}/top-performers?limit=50`);if(!z.ok||!D)return;const R=await z.json(),$=Array.isArray(R?.topPerformers)?R.topPerformers:[];if(!D)return;l($.map(I=>({studentId:String(I.studentId??""),studentName:String(I.studentName??""),cumulativeScore:Number(I.cumulativeScore)||0,accuracy:Number(I.accuracy)||0})))}catch{}};_();const T=setInterval(()=>void _(),2e4);return()=>{D=!1,clearInterval(T)}},[e]);const[S,C]=f.useState({}),k=f.useCallback(async D=>{if(D)try{const _=await fetch(`/api/courseware/attempts/${encodeURIComponent(D)}/raw`);if(!_.ok)return;const T=await _.json(),z=Array.isArray(T?.events)?T.events:Array.isArray(T)?T:[];if(z.length===0)return;C(R=>({...R,[D]:lb(z)}))}catch{}},[]);f.useEffect(()=>{const D=[...n].filter(_=>_?.studentId&&_.studentId!=="teacher"&&_.studentId!=="guest").sort((_,T)=>(Number(T.score)||0)-(Number(_.score)||0)).slice(0,2);for(const _ of D)_.attemptId&&!S[_.attemptId]&&k(String(_.attemptId))},[n,S,k]);const v=f.useCallback(async()=>{if(!e){d(null),m([]);return}try{const[D,_]=await Promise.all([fetch(`/api/classroom/sessions/${e}/peer-review`),fetch(`/api/classroom/sessions/${e}/showcase-works`)]);if(D.ok){const T=await D.json();d(T),Array.isArray(T?.showcaseWorks)&&T.showcaseWorks.length>0&&m(T.showcaseWorks)}if(_.ok){const T=await _.json();Array.isArray(T?.works)&&T.works.length>0&&m(T.works)}}catch{}},[e]);f.useEffect(()=>{if(!t)return;v();const D=setInterval(()=>void v(),5e3);return()=>clearInterval(D)},[t,v]);const N=f.useCallback(async()=>{if(e){w(!0);try{const D=await fetch(`/api/classroom/sessions/${e}/peer-review/auto-assign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({perStudent:2})}),_=await D.json().catch(()=>null);if(!D.ok){i?.(o==="zh"?"分配失败":"Assign failed",_?.error??`HTTP ${D.status}`,"error");return}i?.(o==="zh"?"✅ 互评已分配":"✅ Peer reviews assigned",o==="zh"?`${_.works} 份作品 · 生成 ${_.tasks} 条任务(口径:${_.scope==="lesson"?"本课节作品池":"本班全部"})`:`${_.tasks} tasks created`,"success"),await v()}finally{w(!1)}}},[e,i,o,v]);return{data:f.useMemo(()=>{const D=n.filter(I=>I?.studentId&&I.studentId!=="teacher"&&I.studentId!=="guest"),_=[...D].sort((I,B)=>(Number(B.score)||0)-(Number(I.score)||0)),T=(I,B)=>{if(!I)return null;const H=String(I.studentName||I.studentId),A=typeof I.score=="number"?I.score:null,U=String(I.attemptId??`work-${B}`),j=S[U];return{id:U,slot:B,studentName:H,studentInitial:H.slice(0,1),workTitle:`${H} · ${I.coursewareName??"课件作品"}`,workSubtitle:A===null?I.status==="completed"?"已完成提交":"作答中":`得分 ${A}${typeof I.completion=="number"?` · 完成度 ${Math.round(I.completion*100)}%`:""}`,source:"courseware",sourceLabel:"课件作答",badges:[],workContent:j??null,codeTitle:j?`真实作答内容(${hb[j.kind]})`:void 0,codeLines:j?.lines.length?j.lines:void 0}};let z=null,R=null;if(u.length>0){const I=u.find(H=>H.workId===p)||u[0],B=u.find(H=>H.workId===x)||u.find(H=>H.workId!==I?.workId)||u[1];z=sl(I,"A",S),R=sl(B,"B",S)}else z=T(_[0],"A"),R=T(_[1],"B");const $=c?.podiumStudents?.length>0?c.podiumStudents:a.slice(0,3).map((I,B)=>({rank:B+1,name:I.studentName,votes:I.cumulativeScore,workTitle:`${I.accuracy}% 正确率`,honorTitle:B===0?"本节最高分":"优秀表现",rankBadgeClass:B===0?"bg-[#ffb95f] text-[#2a1700]":"bg-[#171f33] text-[#908fa0]",tagBadgeClass:"bg-[#ca8100]/20 text-[#ffb95f]"}));return c?.matchingItems?.length||c?.podiumStudents?.length?{...nl,workA:z,workB:R,matchingItems:c.matchingItems??[],badges:c.badges??[],podiumStudents:$,danmaku:c.danmaku??[],reactions:c.reactions??[],rubricDimensions:c.dimensions??[],reviewProgress:c.progress??{completed:0,total:0},fromServer:!0}:{...nl,workA:z,workB:R,podiumStudents:$,reviewProgress:{completed:D.filter(I=>I.status==="completed").length,total:s}}},[c,n,a,s,S,u,p,x]),topPerformers:a,showcaseWorks:u,selectedWorkAId:p,selectedWorkBId:x,setSpotlightWork:y,autoAssigning:b,autoAssign:N,refresh:v}}function mb({lessonId:e,lessonTitle:t="互动课堂",lang:n="zh"}){const{data:s,health:i,lastSyncedAt:o}=Wx(e),{notices:a,push:l,dismiss:c}=Yx(n),[d,u]=f.useState(!1),[m,p]=f.useState([]),[h,x]=f.useState("");f.useEffect(()=>{if(!d||!e)return;let C=!1;return(async()=>{try{const k=await fetch("/api/courseware/attempts?pageSize=all");k.ok&&!C&&p(En(await k.json()))}catch{}})(),()=>{C=!0}},[d,e]),f.useEffect(()=>{let C=!1;return(async()=>{try{const k=await fetch("/api/auth/session");if(k.ok&&!C){const v=await k.json();x(String(v?.session?.name??v?.session?.username??""))}}catch{}})(),()=>{C=!0}},[]);const g=fb({lessonId:e,enabled:d,attempts:m,studentCount:s.attendance?.expected??0,lang:n}),b=f.useMemo(()=>({workA:g.data.workA,workB:g.data.workB,matchingItems:g.data.matchingItems,badges:g.data.badges,podiumStudents:g.data.podiumStudents,danmaku:g.data.danmaku,reactions:g.data.reactions,rubricDimensions:g.data.rubricDimensions,reviewProgress:g.data.reviewProgress,onAutoAssign:g.autoAssign,autoAssigning:g.autoAssigning,syncedStudentsCount:s.attendance?.onlineInClass,teacherName:h,stageLabel:Zo(s.stage,n)}),[g,s.attendance,h,s.stage,n]),w=f.useRef(null),y=f.useRef(!0),S=f.useRef(i);return f.useEffect(()=>{if(y.current){y.current=!1,w.current=s;return}const C=w.current;w.current=s,C&&l(Gx(C,s,{lang:n,isFirstFrame:!1}))},[s,n,l]),f.useEffect(()=>{const C=Qx(i,S.current,n);S.current=i,C&&l([C])},[i,n,l]),e?r.jsxs(r.Fragment,{children:[r.jsx(ob,{lessonId:e,lessonTitle:t,data:s,lang:n,health:i,lastSyncedAt:o,peerReviewOpen:d,onOpenPeerReview:()=>u(!0),onClosePeerReview:()=>u(!1),peerReview:b,showCloseButton:!1}),r.jsx(Kx,{notices:a,onDismiss:c,lang:n})]}):r.jsxs("div",{className:"fixed inset-0 z-[9999] bg-slate-950 text-slate-100 flex flex-col items-center justify-center gap-3",children:[r.jsx("div",{className:"text-5xl",children:"📺"}),r.jsx("h1",{className:"text-2xl font-extrabold",children:n==="zh"?"大屏展台 · 等待课节":"Stage Display · Waiting for lesson"}),r.jsx("p",{className:"text-slate-400 text-sm max-w-md text-center px-6",children:n==="zh"?"请在教师端「在线课堂」中选择要授课的课节,这里会自动接入对应课堂的实时数据。":"Select a lesson in the teacher console; the stage will connect to it automatically."})]})}function pb(e){const t=nn(),n=e.session!==void 0?e.session:t?.session,s=e.activeRole??t?.activeRole??"teacher",i=e.setActiveRole??t?.setActiveRole??(()=>{}),o=e.isStudentLiveMode??t?.isStudentLiveMode??!1,a=e.isStudentPreviewMode??t?.isStudentPreviewMode??!1,l=e.lang??t?.lang??"zh",c=e.students??t?.students??[],d=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null;return n?.role==="teacher"&&s==="student"&&!o?r.jsxs("div",{className:"bg-gradient-to-r from-amber-500 via-amber-600 to-orange-500 text-white px-6 py-1.5 flex items-center justify-between text-xs font-medium shadow-sm z-30 shrink-0 border-b border-amber-600/30",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsxs("span",{className:"bg-black/20 text-amber-100 px-2 py-0.5 rounded font-bold uppercase tracking-wider text-xs flex items-center gap-1",children:[r.jsx(Ns,{size:12}),l==="zh"?a?"学生视角预览":"学生模拟模式":a?"Student Preview":"Student View Mode"]}),r.jsx("span",{children:l==="zh"?`您当前正在以学生身份(${c.find(u=>u.id===d)?.name||"未选择"})预览系统界面与交互。`:`You are currently previewing the platform as student (${c.find(u=>u.id===d)?.name||"None"}).`})]}),r.jsxs("button",{type:"button",onClick:()=>{if(a){window.close();return}i("teacher")},className:"bg-white text-amber-800 hover:bg-amber-50 active:bg-amber-100 font-bold px-3 py-1 rounded-md shadow-xs transition-all flex items-center gap-1.5 cursor-pointer text-xs",children:[a?r.jsx(Oe,{size:13}):r.jsx(zr,{size:13}),l==="zh"?a?"关闭此预览标签页":"退出模拟并返回教师端":a?"Close Preview Tab":"Exit Student View"]})]}):null}function gb({userId:e,lang:t,onOpenProfile:n}){const s=`edu_os_default_pwd_hint_dismissed_${e||"unknown"}`,[i,o]=f.useState(()=>{try{return localStorage.getItem(s)==="1"}catch{return!1}});if(i)return null;const a=()=>{o(!0);try{localStorage.setItem(s,"1")}catch{}},l=t==="zh";return r.jsxs("div",{id:"student_default_password_banner",role:"status",className:"flex items-center gap-2 px-4 py-1.5 text-xs bg-amber-50 dark:bg-amber-950/40 text-amber-800 dark:text-amber-200 border-b border-amber-200 dark:border-amber-900/50",children:[r.jsx(Lo,{size:13,className:"shrink-0","aria-hidden":"true"}),r.jsx("span",{className:"flex-1",children:l?"你当前仍在使用初始默认密码,建议尽快修改以保护账号安全。":"You are still using the initial default password. Please change it soon to protect your account."}),r.jsx("button",{type:"button",onClick:n,className:"shrink-0 px-2 py-0.5 rounded-md font-semibold bg-amber-100 dark:bg-amber-900/60 hover:bg-amber-200 dark:hover:bg-amber-900 text-amber-900 dark:text-amber-100 border border-amber-300 dark:border-amber-800 transition-colors",children:l?"去修改":"Change now"}),r.jsx("button",{type:"button",onClick:a,"aria-label":l?"关闭提示":"Dismiss hint",className:"shrink-0 p-1 rounded-md hover:bg-amber-100 dark:hover:bg-amber-900/60 transition-colors",children:r.jsx(Oe,{size:13,"aria-hidden":"true"})})]})}const rs="openlearn_timetable_ocr_task",ai="openlearn_timetable_ocr_draft";function rl(e){try{const t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function $s(e,t,n=[]){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{if(n.length>0&&t&&typeof t=="object")try{const s={...t};for(const i of n)s[i]=null;sessionStorage.setItem(e,JSON.stringify(s))}catch{}}}function il(e){try{sessionStorage.removeItem(e)}catch{}}const xb=St((e,t)=>({timetableOcrTask:rl(rs),timetableOcrDraft:rl(ai),isAnyTaskRunning:!1,startTimetableOcr:async({imageBase64:n,lang:s,providerId:i,fileName:o})=>{const a=`task_ocr_${Date.now()}`,l={id:a,type:"timetable_ocr",title:s==="zh"?"课表图片 AI 识别":"Timetable Image AI Recognition",status:"running",startedAt:Date.now(),meta:{fileName:o}};e({timetableOcrTask:l,isAnyTaskRunning:!0}),$s(rs,l),Ve.getState().addToast({id:`toast_start_${a}`,title:s==="zh"?"⏳ 课表识别已在后台启动":"⏳ Timetable OCR Running in Background",message:s==="zh"?"大模型正在后台分析提取课表内容,您可以继续进行其他操作,识别完成后将通过通知提醒您。":"AI is analyzing your timetable image in the background. You can navigate freely; you will be notified upon completion.",type:"info"});try{const c=await fetch("/api/timetable/ocr",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageBase64:n,lang:s,providerId:i||void 0})}),d=await c.json();if(!c.ok||!d.success)throw new Error(d.error||(s==="zh"?"识别请求失败":"OCR recognition failed"));const u=Array.isArray(d.entries)?d.entries:[],m={...l,status:"completed",completedAt:Date.now(),result:{entries:u,providerUsed:d.providerUsed}};e({timetableOcrTask:m,isAnyTaskRunning:!1}),$s(rs,m),Ve.getState().addToast({id:`toast_done_${a}`,title:s==="zh"?"🎉 AI 课表识别完成":"🎉 Timetable OCR Completed",message:s==="zh"?`已成功从图片中解析出 ${u.length} 节课程,点击前往核对并导入。`:`Successfully parsed ${u.length} timetable entries. Click to review and import.`,type:"success",action:{label:s==="zh"?"查看并导入课表":"View Timetable",onClick:()=>{ve.getState().setTeacherTab("timetable"),Ve.getState().setPendingTimetableSubTab("ocr_import")}}})}catch(c){console.error("[AsyncTask] Timetable OCR failed:",c);const d={...l,status:"failed",completedAt:Date.now(),error:c?.message||(s==="zh"?"未知识别错误":"Unknown OCR error")};e({timetableOcrTask:d,isAnyTaskRunning:!1}),$s(rs,d),Ve.getState().addToast({id:`toast_fail_${a}`,title:s==="zh"?"AI 课表识别失败":"Timetable OCR Failed",message:c?.message||(s==="zh"?"请检查图片是否清晰可见,或前往「系统管理 -> AI 提供商管理」检查模型连通性。":"Please check the image quality or AI provider settings."),type:"error"})}},setTimetableOcrDraft:n=>{const s={imagePreview:null,imageBase64:null,fileName:"",providerId:"",entries:[],selected:[],...t().timetableOcrDraft||{},...n,updatedAt:Date.now()};e({timetableOcrDraft:s}),$s(ai,s,["imagePreview","imageBase64"])},clearTimetableOcrTask:()=>{e({timetableOcrTask:null,isAnyTaskRunning:!1,timetableOcrDraft:null}),il(rs),il(ai)}})),bb=e=>Ft(xb,e);function yb({session:e,lang:t,onLogout:n,onProfile:s}){const[i,o]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(!i)return;const c=d=>{a.current&&!a.current.contains(d.target)&&o(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const l=(c,d)=>t==="zh"?c:d;return r.jsxs("div",{className:"relative",ref:a,children:[r.jsxs("button",{type:"button",onClick:()=>o(c=>!c),"aria-haspopup":"menu","aria-expanded":i,title:e.name,className:"flex items-center gap-1 rounded-full p-1 hover:bg-gray-100 transition-colors cursor-pointer",children:[r.jsx("span",{className:"w-9 h-9 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0 overflow-hidden",children:e.avatar?r.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):r.jsx(vs,{size:20})}),r.jsx(Nn,{size:14,className:`text-gray-400 transition-transform duration-200 ${i?"rotate-180":""}`})]}),i&&r.jsxs("div",{role:"menu",className:"absolute right-0 mt-2 w-52 bg-white border border-gray-200 shadow-lg rounded-xl z-50 overflow-hidden py-1",children:[r.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[r.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),r.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),r.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),s()},className:"w-full flex items-center gap-2 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors cursor-pointer",children:[r.jsx(vs,{size:16,className:"text-gray-400"}),l("个人资料","Profile")]}),r.jsx(Me,{slot:"nav.user_menu",slotProps:{session:e,lang:t,closeMenu:()=>o(!1)}}),r.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),n()},className:"w-full flex items-center gap-2 px-4 py-2 text-sm text-rose-600 hover:bg-rose-50 transition-colors cursor-pointer",children:[r.jsx(zr,{size:16}),l("注销登录","Sign Out")]})]})]})}const Qe=[];for(let e=0;e<256;++e)Qe.push((e+256).toString(16).slice(1));function wb(e,t=0){return(Qe[e[t+0]]+Qe[e[t+1]]+Qe[e[t+2]]+Qe[e[t+3]]+"-"+Qe[e[t+4]]+Qe[e[t+5]]+"-"+Qe[e[t+6]]+Qe[e[t+7]]+"-"+Qe[e[t+8]]+Qe[e[t+9]]+"-"+Qe[e[t+10]]+Qe[e[t+11]]+Qe[e[t+12]]+Qe[e[t+13]]+Qe[e[t+14]]+Qe[e[t+15]]).toLowerCase()}const vb=new Uint8Array(16);function Sb(){return crypto.getRandomValues(vb)}const li={};function Or(e,t,n){let s;{const i=Date.now(),o=Sb();jb(li,i,o),s=kb(o,li.msecs,li.seq,t,n)}return t??wb(s)}function jb(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function kb(e,t,n,s,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),i=0;else if(i<0||i+16>s.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],s[i++]=t/1099511627776&255,s[i++]=t/4294967296&255,s[i++]=t/16777216&255,s[i++]=t/65536&255,s[i++]=t/256&255,s[i++]=t&255,s[i++]=112|n>>>28&15,s[i++]=n>>>20&255,s[i++]=128|n>>>14&63,s[i++]=n>>>6&255,s[i++]=n<<2&255|e[10]&3,s[i++]=e[11],s[i++]=e[12],s[i++]=e[13],s[i++]=e[14],s[i++]=e[15],s}function ci(e){return e==="*"?{kind:"global",key:"*"}:e.length>2&&e.endsWith(".*")&&!e.slice(0,-2).includes("*")?{kind:"prefix",key:e.slice(0,-1)}:{kind:"exact",key:e}}class Cb{constructor(){this.handlers=new Map,this.prefixHandlers=new Map,this.globalHandlers=new Set,this.wildcardCount=0}subscribe(t,n){const{kind:s,key:i}=ci(t);let o;if(s==="global")o=this.globalHandlers,this.wildcardCount++;else if(s==="prefix"){let l=this.prefixHandlers.get(i);l||(l=new Set,this.prefixHandlers.set(i,l)),o=l,this.wildcardCount++}else{let l=this.handlers.get(i);l||(l=new Set,this.handlers.set(i,l)),o=l}o.add(n);let a=!1;return()=>{a||(a=!0,o.delete(n),!(o.size>0)&&(s==="global"?this.wildcardCount--:s==="prefix"?(this.wildcardCount--,this.prefixHandlers.delete(i)):this.handlers.delete(i)))}}subscribePayload(t,n){const s=i=>n(i.payload,i);return this.subscribe(t,s)}once(t,n){const s=this.subscribe(t,i=>{s(),n(i)});return s}resolveHandlers(t){const n=this.handlers.get(t);if(this.wildcardCount===0)return n&&n.size>0?Array.from(n):[];let s=null;for(const[i,o]of this.prefixHandlers)if(t.startsWith(i)){if(!s&&(s=new Set,n))for(const a of n)s.add(a);for(const a of o)s.add(a)}if(this.globalHandlers.size>0){if(!s&&(s=new Set,n))for(const i of n)s.add(i);for(const i of this.globalHandlers)s.add(i)}return s?Array.from(s):n&&n.size>0?Array.from(n):[]}async publish(t){const n=this.resolveHandlers(t.type);if(n.length!==0)for(const s of n)try{const i=s(t);i instanceof Promise&&i.catch(o=>{console.error(`[FrontendEventBus] Async handler error on '${t.type}':`,o)})}catch(i){console.error(`[FrontendEventBus] Handler error on '${t.type}':`,i)}}async emit(t,n,s="frontend"){const i={id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`fe-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:t,source:s,payload:n,timestamp:Date.now()};return this.publish(i)}listenerCount(t){if(t){const{kind:s,key:i}=ci(t);return s==="global"?this.globalHandlers.size:s==="prefix"?this.prefixHandlers.get(i)?.size??0:this.handlers.get(i)?.size||0}let n=this.wildcardCount;for(const s of this.handlers.values())n+=s.size;return n}clear(t){if(t){const{kind:n,key:s}=ci(t);if(n==="global")this.wildcardCount-=this.globalHandlers.size,this.globalHandlers.clear();else if(n==="prefix"){const i=this.prefixHandlers.get(s);i&&(this.wildcardCount-=i.size),this.prefixHandlers.delete(s)}else this.handlers.delete(s)}else this.handlers.clear(),this.prefixHandlers.clear(),this.globalHandlers.clear(),this.wildcardCount=0}}const tn=new Cb,Nb=[{id:"light",label:"浅色日间",description:"明亮通透,适合自然采光良好的日间课堂",previewBg:"#f8fafc",previewPrimary:"#4f46e5",category:"builtin"},{id:"dark",label:"暗夜极客",description:"深邃内敛,适合计算机房与夜间专注备课",previewBg:"#0b0f19",previewPrimary:"#6366f1",category:"builtin"},{id:"eyecare",label:"教学护眼",description:"柔和舒缓,防教室大屏眩光,减轻视觉疲劳",previewBg:"#f2f7f4",previewPrimary:"#2d6a4f",category:"builtin"},{id:"chalkboard",label:"经典黑板",description:"经典墨绿板书质感,沉浸式板书演练",previewBg:"#0e1713",previewPrimary:"#4caf50",category:"builtin"}],sr={light:{"--bg-app":"#f8fafc","--bg-surface":"#ffffff","--bg-surface-secondary":"#f1f5f9","--bg-surface-elevated":"#ffffff","--border-theme":"#e2e8f0","--border-theme-subtle":"#f1f5f9","--text-main":"#0f172a","--text-muted":"#475569","--text-subtle":"#5a6b80","--primary-solid":"#4f46e5","--primary-ink":"#4f46e5","--color-primary":"#4f46e5","--color-primary-hover":"#4338ca"},dark:{"--bg-app":"#0b0f19","--bg-surface":"#111827","--bg-surface-secondary":"#1f2937","--bg-surface-elevated":"#1f2937","--border-theme":"#374151","--border-theme-subtle":"#1f2937","--text-main":"#f9fafb","--text-muted":"#94a3b8","--text-subtle":"#8698ad","--primary-solid":"#4f46e5","--primary-ink":"#818cf8","--color-primary":"#6366f1","--color-primary-hover":"#4f46e5"},eyecare:{"--bg-app":"#f2f7f4","--bg-surface":"#ffffff","--bg-surface-secondary":"#e4eee8","--bg-surface-elevated":"#ffffff","--border-theme":"#cbe0d5","--border-theme-subtle":"#dbeef2","--text-main":"#143526","--text-muted":"#2f5a44","--text-subtle":"#457057","--primary-solid":"#2d6a4f","--primary-ink":"#2d6a4f","--color-primary":"#2d6a4f","--color-primary-hover":"#1b4332"},chalkboard:{"--bg-app":"#0e1713","--bg-surface":"#15241e","--bg-surface-secondary":"#1b2f27","--bg-surface-elevated":"#1f382e","--border-theme":"#28473a","--border-theme-subtle":"#1b2f27","--text-main":"#e8f5e9","--text-muted":"#a5d6a7","--text-subtle":"#66bb6a","--primary-solid":"#2f7d32","--primary-ink":"#66bb6a","--color-primary":"#4caf50","--color-primary-hover":"#388e3c"}},di="openlearn_theme",is="openlearn_custom_themes",kr={};function Xo(e){return kr[e]?kr[e]:e in sr?sr[e]:sr.light}function ui(e){typeof document>"u"||document.documentElement.setAttribute("data-theme",e)}function Eb(e,t){if(typeof document>"u")return;kr[e]=t;const n=`openlearn-custom-theme-${e}`;let s=document.getElementById(n);s||(s=document.createElement("style"),s.id=n,document.head.appendChild(s));const i=Object.entries(t).map(([o,a])=>` ${o}: ${a};`).join(`
|
|
8
8
|
`);s.textContent=`[data-theme="${e}"] {
|
|
9
9
|
${i}
|
|
10
|
-
}`}function Tb(e){if(typeof document>"u")return;delete kr[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function hi(e){if(!(typeof window>"u"))try{tn.publish({id:Or(),type:"theme.changed",source:"theme-store",payload:{theme:e,tokens:Xo(e)},timestamp:Date.now()})}catch{}}const Dr=Vo((e,t)=>({theme:"light",availableThemes:[...Nb],initTheme:()=>{if(typeof window>"u")return;try{const i=localStorage.getItem(is);if(i){const o=JSON.parse(i);Array.isArray(o)&&o.forEach(a=>{a&&a.spec&&a.spec.id&&t().registerTheme(a.spec,a.cssVariables)})}}catch{}const s=localStorage.getItem(di)||"light";ui(s),e({theme:s}),hi(s)},setTheme:n=>{ui(n),typeof window<"u"&&localStorage.setItem(di,n),e({theme:n}),hi(n)},registerTheme:(n,s)=>{s&&Eb(n.id,s),e(i=>({availableThemes:[...i.availableThemes.filter(a=>a.id!==n.id),n]}))},unregisterTheme:n=>{Tb(n),e(s=>{const i=s.availableThemes.filter(a=>a.id!==n),o=s.theme===n?"light":s.theme;return s.theme===n&&(ui("light"),typeof window<"u"&&localStorage.setItem(di,"light"),hi("light")),{availableThemes:i,theme:o}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const i=localStorage.getItem(is);let o=i?JSON.parse(i):[];Array.isArray(o)||(o=[]),o=o.filter(a=>a.spec.id!==n.id),o.push({spec:n,cssVariables:s}),localStorage.setItem(is,JSON.stringify(o))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(is);if(s){let i=JSON.parse(s);Array.isArray(i)&&(i=i.filter(o=>o.spec.id!==n),localStorage.setItem(is,JSON.stringify(i)))}}catch{}t().unregisterTheme(n)}})),Pb=[{id:"sapphire-classic",label:"高雅墨蓝",description:"深海午夜蓝灰与经典宝石蓝,适合沉浸式研究与高对比度投影",tokens:{"--bg-app":"#0d131f","--bg-surface":"#161f30","--bg-surface-secondary":"#1f2c42","--bg-surface-elevated":"#24334d","--border-theme":"#2e3f5b","--border-theme-subtle":"#1f2c42","--text-main":"#f1f5f9","--text-muted":"#94a3b8","--color-primary":"#3b82f6","--color-primary-hover":"#2563eb"}},{id:"sakura-dusk",label:"暮樱柔粉",description:"柔和日系樱花与温暖象牙白,适合美育、艺术与温馨研讨课堂",tokens:{"--bg-app":"#fff9fa","--bg-surface":"#ffffff","--bg-surface-secondary":"#fceef1","--bg-surface-elevated":"#ffffff","--border-theme":"#f5d5db","--border-theme-subtle":"#fae8eb","--text-main":"#3f2d33","--text-muted":"#8a6d76","--color-primary":"#f43f5e","--color-primary-hover":"#e11d48"}},{id:"autumn-amber",label:"复古秋叶",description:"温暖金秋落叶色调与复古羊皮纸质感,适合文科通识与阅读研讨",tokens:{"--bg-app":"#fdfaf6","--bg-surface":"#ffffff","--bg-surface-secondary":"#f5eee6","--bg-surface-elevated":"#ffffff","--border-theme":"#e6d7c3","--border-theme-subtle":"#ede3d5","--text-main":"#2d241e","--text-muted":"#7c6a59","--color-primary":"#d97706","--color-primary-hover":"#b45309"}},{id:"deep-sea-cyber",label:"深海极客",description:"赛博暗黑青绿冷光,极高现代感与未来科技探索质感",tokens:{"--bg-app":"#091014","--bg-surface":"#0f1a20","--bg-surface-secondary":"#16262e","--bg-surface-elevated":"#1d333e","--border-theme":"#25414e","--border-theme-subtle":"#16262e","--text-main":"#e0f2fe","--text-muted":"#7dd3fc","--color-primary":"#06b6d4","--color-primary-hover":"#0891b2"}}],ol={...sr.light};function Ib({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:i,deleteCustomTheme:o}=Dr(),a=f.useId(),[l,c]=f.useState("custom-mytheme"),[d,u]=f.useState("我的专属主题"),[m,p]=f.useState("自定义教学调色板配置"),[h,x]=f.useState({...ol}),[g,b]=f.useState("none"),[w,y]=f.useState(""),[S,C]=f.useState(!1),[k,v]=f.useState(null);if(!e)return null;const N=s.filter(A=>A.category==="custom"),O=A=>{v(A),setTimeout(()=>v(null),3e3)},D=A=>{c(A.id),u(A.label),p(A.description),x({...A.tokens}),O(`已载入预设: ${A.label}`)},_=A=>{c(A.id),u(A.label),p(A.description);const U=Xo(A.id);U&&Object.keys(U).length>0&&x({...U}),O(`已载入自定义主题: ${A.label}`)},T=(A,U)=>{x(j=>({...j,[A]:U}))},z=()=>{const A=l.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!A){alert("请输入有效的主题标识 (ID)");return}const U={id:A,label:d.trim()||"未命名主题",description:m.trim()||"自定义主题",previewBg:h["--bg-app"]||"#ffffff",previewPrimary:h["--color-primary"]||"#4f46e5",category:"custom"};i(U,h),O(`主题「${U.label}」已保存并成功激活!`)},R=()=>{y(JSON.stringify({version:"1.0",id:l,label:d,description:m,tokens:h},null,2)),b("export")},$=()=>{y(""),b("import")},I=()=>{try{const A=JSON.parse(w);if(!A.tokens||typeof A.tokens!="object")throw new Error("缺少合法的 tokens 字段");A.id&&c(A.id),A.label&&u(A.label),A.description&&p(A.description),x(U=>({...U,...A.tokens})),b("none"),O("主题配置导入成功!")}catch(A){alert(`导入失败: ${A.message||"JSON 格式解析错误"}`)}},B=()=>{navigator.clipboard.writeText(w),C(!0),setTimeout(()=>C(!1),2e3)},H=[{key:"--color-primary",labelZh:"核心主色",labelEn:"Primary Brand Color",desc:"按钮高亮、焦点描边与重点图标"},{key:"--color-primary-hover",labelZh:"主色悬浮",labelEn:"Primary Hover",desc:"按钮悬停交互色"},{key:"--bg-app",labelZh:"全局底色",labelEn:"App Background",desc:"页面整体底衬颜色"},{key:"--bg-surface",labelZh:"卡片底色",labelEn:"Surface Background",desc:"白板卡片、浮层与侧边栏底色"},{key:"--bg-surface-secondary",labelZh:"次级底色",labelEn:"Secondary Surface",desc:"表格斑马纹、标签与次级面板"},{key:"--bg-surface-elevated",labelZh:"浮层底色",labelEn:"Elevated Surface",desc:"弹窗与下拉菜单浮动卡片"},{key:"--border-theme",labelZh:"主边框色",labelEn:"Border Color",desc:"卡片外边框、网格分割线"},{key:"--border-theme-subtle",labelZh:"弱化边框",labelEn:"Subtle Border",desc:"细微内部分割线"},{key:"--text-main",labelZh:"主文本色",labelEn:"Main Text",desc:"正文文字、标题"},{key:"--text-muted",labelZh:"弱化文本",labelEn:"Muted Text",desc:"副标题、辅助信息与提示说明"}];return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 bg-black/60 backdrop-blur-xs animate-in fade-in duration-150",children:r.jsxs("div",{className:"bg-surface text-main border border-theme rounded-2xl shadow-2xl w-full max-w-6xl h-[92vh] max-h-[900px] flex flex-col overflow-hidden relative",children:[r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:r.jsx(Zi,{size:22})}),r.jsxs("div",{children:[r.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme font-medium",children:"v0.3.0"})]}),r.jsx("p",{className:"text-xs text-muted mt-0.5",children:n==="zh"?"自定义课堂交互色盘,支持一键载入创意预设、实时拟真沙箱预览与微前端自动同步":"Customize learning palettes with live previews, creative presets, and micro-frontend sync"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:$,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导入 JSON",children:[r.jsx(Ha,{size:14}),n==="zh"?"导入配置":"Import"]}),r.jsxs("button",{onClick:R,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导出 JSON",children:[r.jsx(Ji,{size:14}),n==="zh"?"导出配置":"Export"]}),r.jsx("button",{onClick:t,className:"p-2 rounded-lg text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer ml-1","aria-label":"Close",children:r.jsx(Oe,{size:18})})]})]}),k&&r.jsxs("div",{className:"absolute top-18 left-1/2 -translate-x-1/2 z-50 bg-primary-theme text-white px-4 py-2 rounded-xl shadow-lg text-xs font-medium flex items-center gap-2 animate-in fade-in slide-in-from-top-2",children:[r.jsx(ht,{size:14}),k]}),r.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[r.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[r.jsxs("section",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(yt,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),r.jsx("span",{className:"text-xs text-muted",children:"一键填入调色板"})]}),r.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Pb.map(A=>r.jsxs("button",{onClick:()=>D(A),className:"flex flex-col p-3 rounded-xl border border-theme hover:border-primary-theme/50 hover:bg-surface-secondary text-left transition-all cursor-pointer group relative overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between w-full",children:[r.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:A.tokens["--color-primary"]}}),A.label]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:A.tokens["--bg-app"]}}),r.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:A.tokens["--bg-surface"]}})]})]}),r.jsx("p",{className:"text-xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:A.description})]},A.id))})]}),r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Vp,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-themeId`,className:"block text-xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),r.jsx("input",{id:`${a}-themeId`,type:"text",value:l,onChange:A=>c(A.target.value),placeholder:"custom-mytheme",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-label`,className:"block text-xs font-medium text-muted mb-1",children:"主题名称"}),r.jsx("input",{id:`${a}-label`,type:"text",value:d,onChange:A=>u(A.target.value),placeholder:"我的专属主题",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-description`,className:"block text-xs font-medium text-muted mb-1",children:"主题描述"}),r.jsx("input",{id:`${a}-description`,type:"text",value:m,onChange:A=>p(A.target.value),placeholder:"针对特定课堂采光与演示场景优化",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Zi,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),r.jsx("div",{className:"space-y-2.5",children:H.map(A=>{const U=h[A.key]||"#000000";return r.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-main",children:A.labelZh}),r.jsx("span",{className:"text-xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:A.key})]}),r.jsx("p",{className:"text-xs text-muted mt-0.5",children:A.desc})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"relative flex items-center",children:r.jsx("input",{type:"color",value:U.startsWith("#")&&U.length===7?U:"#4f46e5",onChange:j=>T(A.key,j.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),r.jsx("input",{type:"text",value:U,onChange:j=>T(A.key,j.target.value),className:"w-20 px-2 py-1 text-xs font-mono rounded-lg border border-theme bg-surface text-main text-center focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]},A.key)})})]}),N.length>0&&r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Xc,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),r.jsx("div",{className:"space-y-2",children:N.map(A=>r.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[r.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[r.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:A.previewPrimary}}),r.jsxs("div",{className:"truncate",children:[r.jsx("div",{className:"text-xs font-semibold text-main truncate",children:A.label}),r.jsx("div",{className:"text-xs text-muted truncate",children:A.description})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[r.jsx("button",{onClick:()=>_(A),className:"px-2 py-1 text-xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),r.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${A.label}」吗?`)&&(o(A.id),O(`已删除主题「${A.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:r.jsx(_r,{size:13})})]})]},A.id))})]})]}),r.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[r.jsx(Ns,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),r.jsxs("span",{className:"text-xs text-muted font-mono",children:["当前预览: ",d," (",l,")"]})]}),r.jsxs("div",{className:"flex-1 rounded-2xl border shadow-inner overflow-hidden flex flex-col transition-colors duration-200",style:{backgroundColor:h["--bg-app"]||"#f8fafc",borderColor:h["--border-theme"]||"#e2e8f0",color:h["--text-main"]||"#0f172a"},children:[r.jsxs("div",{className:"h-12 border-b px-4 flex items-center justify-between shrink-0",style:{backgroundColor:h["--bg-surface"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-white text-xs",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"OL"}),r.jsx("span",{className:"font-bold text-xs",style:{color:h["--text-main"]},children:"OpenLearn V2"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"text-xs px-2 py-0.5 rounded-md font-mono",style:{backgroundColor:h["--bg-surface-secondary"]||"#f1f5f9",color:h["--text-muted"]||"#64748b"},children:"10:30:00"}),r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"T"})]})]}),r.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[r.jsxs("div",{className:"p-4 rounded-xl border shadow-xs space-y-3",style:{backgroundColor:h["--bg-surface"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0"},children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"font-bold text-sm",style:{color:h["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),r.jsx("p",{className:"text-xs mt-1",style:{color:h["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:h["--bg-surface-secondary"],color:h["--color-primary"],border:`1px solid ${h["--border-theme"]}`},children:"进行中"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"光电门测速 (v)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"2.43 m/s"})]}),r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"动能增量 (ΔEk)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--color-primary"]},children:"0.589 J"})]}),r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"误差率 (Err)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"0.84 %"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white shadow-xs transition-opacity hover:opacity-90 cursor-pointer",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"开始数据采集"}),r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors cursor-pointer",style:{backgroundColor:h["--bg-surface-elevated"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0",color:h["--text-main"]||"#0f172a"},children:"重置实验"}),r.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:h["--text-muted"]},children:"查看教案"})]})]}),r.jsxs("div",{className:"p-3 rounded-xl border space-y-2",style:{backgroundColor:h["--bg-surface-elevated"]||"#ffffff",borderColor:h["--border-theme-subtle"]||"#f1f5f9"},children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold",style:{color:h["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),r.jsx("span",{className:"text-xs font-mono",style:{color:h["--text-muted"]},children:"60 FPS"})]}),r.jsxs("div",{className:"h-28 rounded-lg border border-dashed flex items-center justify-center p-3 relative overflow-hidden",style:{backgroundColor:h["--bg-app"],borderColor:h["--border-theme"]},children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white font-bold shadow-md transform -rotate-6",style:{backgroundColor:h["--color-primary"]},children:r.jsx(Rr,{size:20})}),r.jsx("div",{className:"absolute bottom-2 right-2 text-xs font-mono px-1.5 py-0.5 rounded border",style:{backgroundColor:h["--bg-surface"],borderColor:h["--border-theme"],color:h["--text-muted"]},children:"iframe Bridge Sync Ready"})]})]})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("button",{onClick:()=>{x({...ol}),O("已重置为系统默认调色板")},className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",children:[r.jsx(ed,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:t,className:"px-4 py-2 rounded-xl border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:n==="zh"?"关闭":"Close"}),r.jsxs("button",{onClick:z,className:"px-5 py-2 rounded-xl bg-primary-theme text-white text-xs font-semibold shadow-sm hover:opacity-95 transition-opacity flex items-center gap-1.5 cursor-pointer",children:[r.jsx(Hp,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),g!=="none"&&r.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center p-6 z-50 animate-in fade-in duration-100",children:r.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:g==="export"?r.jsxs(r.Fragment,{children:[r.jsx(Ji,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ha,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),r.jsx("button",{onClick:()=>b("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:r.jsx(Oe,{size:16})})]}),r.jsx("div",{children:r.jsx("textarea",{value:w,readOnly:g==="export",onChange:A=>y(A.target.value),placeholder:g==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),r.jsx("div",{className:"flex items-center justify-end gap-2",children:g==="export"?r.jsx(r.Fragment,{children:r.jsxs("button",{onClick:B,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium flex items-center gap-1.5 cursor-pointer",children:[S?r.jsx(ht,{size:14}):r.jsx(vn,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>b("none"),className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main cursor-pointer",children:n==="zh"?"取消":"Cancel"}),r.jsx("button",{onClick:I,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium cursor-pointer",children:n==="zh"?"解析并导入":"Parse & Import"})]})})]})})]})})}function Ab({lang:e="zh"}){const[t,n]=f.useState(!1),[s,i]=f.useState(!1),o=f.useRef(null),{theme:a,availableThemes:l,setTheme:c}=Dr();f.useEffect(()=>{function u(m){o.current&&!o.current.contains(m.target)&&n(!1)}return t&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[t]);const d=u=>{switch(u){case"dark":return r.jsx(qp,{size:16,className:"text-indigo-400"});case"eyecare":return r.jsx(Ns,{size:16,className:"text-emerald-500"});case"chalkboard":return r.jsx(Zi,{size:16,className:"text-green-400"});case"light":default:return r.jsx(Wp,{size:16,className:"text-amber-500"})}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",ref:o,children:[r.jsx("button",{onClick:()=>n(!t),title:e==="zh"?"切换教学界面主题":"Switch Theme",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer","aria-label":"Theme selector",children:d(a)}),t&&r.jsxs("div",{className:"absolute right-0 mt-2 w-64 rounded-xl border border-theme bg-surface shadow-xl z-50 p-2 overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[r.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[r.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),r.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),r.jsx("div",{className:"space-y-1",children:l.map(u=>{const m=a===u.id;return r.jsxs("button",{onClick:()=>{c(u.id),n(!1)},className:`w-full flex items-center justify-between px-3 py-2 rounded-lg text-left text-xs transition-all cursor-pointer ${m?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 dark:border-white/20 shrink-0 shadow-inner",style:{backgroundColor:u.previewPrimary}}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-main leading-none",children:u.label}),r.jsx("div",{className:"text-xs text-muted mt-1 leading-tight opacity-80",children:u.description})]})]}),m&&r.jsx(ht,{size:14,className:"text-primary-theme shrink-0"})]},u.id)})}),r.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:r.jsxs("button",{onClick:()=>{n(!1),i(!0)},className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",children:[r.jsx(yt,{size:14}),r.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),r.jsx(Ib,{isOpen:s,onClose:()=>i(!1),lang:e})]})}const fi="openlearn_font_scale",gn=85,xn=140,mi=5,rr=100,al=[{scale:90,labelZh:"紧凑 (90%)",labelEn:"Compact (90%)"},{scale:100,labelZh:"标准 (100%)",labelEn:"Standard (100%)"},{scale:110,labelZh:"中大 (110%)",labelEn:"Medium (110%)"},{scale:120,labelZh:"大号 (120%)",labelEn:"Large (120%)"},{scale:130,labelZh:"特大 (130%)",labelEn:"Extra Large (130%)"}];function pi(e){if(typeof document>"u")return;const t=Math.min(xn,Math.max(gn,Math.round(e)));document.documentElement.style.fontSize=`${t}%`,document.documentElement.style.setProperty("--app-font-scale",(t/100).toFixed(2)),document.documentElement.setAttribute("data-font-scale",String(t))}function gi(e){if(!(typeof window>"u"))try{tn.publish({id:Or(),type:"font-scale.changed",source:"font-size-store",payload:{scale:e},timestamp:Date.now()})}catch{}}const wn=Vo((e,t)=>({scale:rr,minScale:gn,maxScale:xn,step:mi,initFontSize:()=>{if(typeof window>"u")return;let n=rr;try{const s=localStorage.getItem(fi);if(s){const i=Number(s);!isNaN(i)&&i>=gn&&i<=xn&&(n=i)}}catch{}pi(n),e({scale:n}),gi(n);try{window.addEventListener("storage",s=>{if(s.key===fi&&s.newValue){const i=Number(s.newValue);!isNaN(i)&&i>=gn&&i<=xn&&(pi(i),e({scale:i}),gi(i))}})}catch{}},setScale:n=>{const s=Math.min(xn,Math.max(gn,Math.round(n)));if(pi(s),typeof window<"u")try{localStorage.setItem(fi,String(s))}catch{}e({scale:s}),gi(s)},increaseScale:()=>{const n=t().scale,s=Math.min(xn,n+mi);t().setScale(s)},decreaseScale:()=>{const n=t().scale,s=Math.max(gn,n-mi);t().setScale(s)},resetScale:()=>{t().setScale(rr)}}));function bd({lang:e="zh"}){const[t,n]=f.useState(!1),s=f.useRef(null),{scale:i,minScale:o,maxScale:a,setScale:l,increaseScale:c,decreaseScale:d,resetScale:u}=wn();f.useEffect(()=>{function h(x){s.current&&!s.current.contains(x.target)&&n(!1)}return t&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[t]);const m=al.find(h=>h.scale===i),p=i===rr;return r.jsxs("div",{className:"relative",ref:s,children:[r.jsxs("button",{type:"button",onClick:()=>n(!t),title:e==="zh"?`界面字体缩放: ${i}%(点击调节)`:`Interface Font Scaling: ${i}% (Click to adjust)`,className:`p-2 hover:bg-surface-secondary transition-colors rounded-lg border shadow-3xs flex items-center justify-center shrink-0 cursor-pointer relative ${p?"bg-surface border-theme text-main":"bg-primary-theme-light border-primary-theme text-primary-theme font-bold"}`,"aria-label":"Font size selector","aria-expanded":t,children:[r.jsx(Gp,{size:16}),!p&&r.jsxs("span",{className:"absolute -bottom-1 -right-1 text-xs px-1 py-0.2 rounded-full bg-primary-theme text-white font-extrabold leading-none shadow-xs",children:[i,"%"]})]}),t&&r.jsxs("div",{className:"absolute right-0 mt-2 w-72 rounded-xl border border-theme bg-surface shadow-xl z-50 p-3 overflow-hidden animate-in fade-in zoom-in-95 duration-100 select-none",children:[r.jsxs("div",{className:"px-1 pb-2 border-b border-theme-subtle mb-2.5 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-xs font-semibold text-main",children:e==="zh"?"界面字号大小":"Interface Font Size"}),r.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"全局等比缩放排版与文字":"Proportionally scale typography"})]}),!p&&r.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 text-xs text-muted hover:text-primary-theme transition-colors cursor-pointer px-1.5 py-0.5 rounded hover:bg-surface-secondary",title:e==="zh"?"恢复默认 100%":"Reset to 100%",children:[r.jsx(ed,{size:11}),r.jsx("span",{children:e==="zh"?"重置":"Reset"})]})]}),r.jsxs("div",{className:"bg-surface-secondary/70 rounded-lg p-2 flex items-center justify-between mb-3 border border-theme-subtle",children:[r.jsx("button",{type:"button",onClick:d,disabled:i<=o,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"减小字体 (A-)":"Decrease (A-)",children:r.jsx(Qp,{size:14})}),r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-sm font-black text-main leading-tight",children:[i,"%"]}),r.jsx("div",{className:"text-xs text-muted",children:m?e==="zh"?m.labelZh.split(" ")[0]:m.labelEn.split(" ")[0]:e==="zh"?"自定义比例":"Custom"})]}),r.jsx("button",{type:"button",onClick:c,disabled:i>=a,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"增大字体 (A+)":"Increase (A+)",children:r.jsx(Bo,{size:14})})]}),r.jsxs("div",{className:"space-y-1 mb-3",children:[r.jsx("div",{className:"text-xs font-bold text-muted uppercase tracking-wider px-1",children:e==="zh"?"常用档位":"Presets"}),r.jsx("div",{className:"grid grid-cols-1 gap-1",children:al.map(h=>{const x=i===h.scale;return r.jsxs("button",{type:"button",onClick:()=>l(h.scale),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs transition-all cursor-pointer ${x?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/30":"text-main hover:bg-surface-secondary border border-transparent"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-60"}),r.jsx("span",{children:e==="zh"?h.labelZh:h.labelEn})]}),x&&r.jsx(ht,{size:13,className:"text-primary-theme shrink-0"})]},h.scale)})})]}),r.jsxs("div",{className:"p-2.5 rounded-lg border border-theme-subtle bg-surface-secondary/40 mb-2",children:[r.jsxs("div",{className:"text-xs text-muted mb-1 flex items-center justify-between",children:[r.jsx("span",{children:e==="zh"?"实时效果预览":"Live Preview"}),r.jsxs("span",{children:[i,"%"]})]}),r.jsx("p",{className:"text-xs text-main font-medium leading-relaxed",children:e==="zh"?"让每一个文字都清晰舒适,智能赋能教学。":"Clear and comfortable typography empowers modern teaching."})]}),r.jsx("div",{className:"text-xs text-muted/80 text-center px-1",children:e==="zh"?"快捷键:Ctrl + Alt + 加号/减号":"Shortcut: Ctrl + Alt + +/-"})]})]})}function zb(e){const t=nn(),n=e.lang??t?.lang??"zh",s=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,i=e.students??t?.students??[],o=e.selectedLesson!==void 0?e.selectedLesson:t?.selectedLesson??null,a=e.lessons??t?.lessons??[],l=e.isStudentLocked??t?.isNavigationLocked??t?.isStudentLocked??!1,c=e.isFollowingTeacher??t?.isFollowingTeacher??!1,d=e.setIsFollowingTeacher??t?.setIsFollowingTeacher??(()=>{}),u=e.notifyLockedNavigation??t?.notifyLockedNavigation??(()=>{});return r.jsxs("header",{className:"h-13 bg-surface/95 backdrop-blur-md border-b border-theme px-4 flex items-center justify-between z-20 shrink-0 select-none shadow-xs",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-tr from-pink-500 to-rose-600 flex items-center justify-center text-white font-black shadow-sm text-sm",children:"🎓"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-sm font-black text-main tracking-wide",children:n==="zh"?"互动课堂 · 学生端":"Interactive Classroom · Student Client"}),r.jsxs("span",{className:"flex items-center gap-1 text-xs font-bold text-emerald-700 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),n==="zh"?"已与教师中控台实时联动":"Synced with Teacher"]})]}),r.jsxs("div",{className:"text-xs text-muted flex items-center gap-2",children:[r.jsx("span",{children:s?`学生: ${i.find(m=>m.id===s)?.name||s}`:"学生端"}),r.jsx("span",{children:"•"}),r.jsx("span",{children:o?`课节: ${a.find(m=>m.id===o)?.title||o}`:"等待教师推流课节..."})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{if(l){u();return}d(!c)},disabled:l,className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all flex items-center gap-1.5 shadow-2xs ${l?"cursor-not-allowed":"cursor-pointer"} ${c?"bg-indigo-50 dark:bg-indigo-950/40 text-indigo-600 dark:text-indigo-400 border-indigo-200 dark:border-indigo-800":"bg-surface text-muted border-theme hover:text-main"} ${l?"opacity-70":""}`,title:l?n==="zh"?"全班专注锁定中,已强制跟随教师步调":"Class focus is locked; following the teacher is enforced":n==="zh"?"开启后,教师端切换课节/环节/Tab时,学生端将自动同步跟随":"Follow teacher navigation",children:[r.jsx(Lr,{size:12,className:c?"animate-spin":""}),r.jsx("span",{children:n==="zh"?`跟随教师步调: ${c?"开":"关"}`:`Follow Teacher: ${c?"ON":"OFF"}`})]}),r.jsx(bd,{lang:n}),r.jsx("button",{type:"button",onClick:()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):document.documentElement.requestFullscreen().catch(()=>{})},className:"p-1.5 text-muted hover:text-main rounded-lg border border-theme hover:bg-surface-secondary transition-colors cursor-pointer",title:n==="zh"?"切换全屏":"Toggle Fullscreen",children:r.jsx(Do,{size:14})}),r.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-2.5 py-1.5 text-xs font-bold text-rose-700 dark:text-rose-400 hover:text-rose-800 bg-rose-50 dark:bg-rose-950/30 border border-rose-200 dark:border-rose-900 rounded-lg transition-colors cursor-pointer",title:n==="zh"?"关闭学生端Tab":"Close Tab",children:n==="zh"?"关闭Tab":"Close Tab"})]})]})}function Lb(e){const t=nn(),n=e.activeRole??t?.activeRole??"teacher",s=e.studentPreviewTab??t?.isStudentPreviewMode??!1,i=e.lang??t?.lang??"zh",o=e.teacherTab??t?.teacherTab??"live_class",a=e.studentViewStatus??t?.studentViewStatus??"dashboard",l=e.session!==void 0?e.session:t?.session,c=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,d=e.students??t?.students??[],u=e.studentDashboardData??t?.studentDashboardData??null,m=e.isNotificationsOpen??t?.isNotificationsOpen??!1,p=e.studentNotifications??t?.studentNotifications??[],h=e.unreadNotifications??t?.unreadNotifications??[],x=e.readNotifications??t?.readNotifications??new Set;e.selectedNotificationForModal!==void 0?e.selectedNotificationForModal:t?.selectedNotificationForModal;const g=e.dbConnected??t?.dbConnected??!1,b=e.dbStatus??t?.dbStatus??"normal",w=e.siteInfo??t?.siteInfo,y=e.setActiveStudentId??t?.setActiveStudentId??(()=>{}),S=e.setReadNotifications??t?.setReadNotifications??(()=>{}),C=e.setIsSystemResourceLibraryOpen??t?.setIsSystemResourceLibraryOpen??(()=>{}),k=e.setProfileOpen??t?.setProfileOpen??(()=>{}),v=e.setTeacherTab??t?.setTeacherTab??(()=>{}),N=e.setStudentViewStatus??t?.setStudentViewStatus??(()=>{}),O=e.setIsNotificationsOpen??t?.setIsNotificationsOpen??(()=>{}),D=e.setSelectedNotificationForModal??t?.setSelectedNotificationForModal??(()=>{}),_=e.handleLogout??t?.handleLogout??t?.onLogout??(()=>{}),T=e.toggleLanguage??t?.toggleLanguage??(()=>{}),z=e.setActiveRole??t?.setActiveRole??(()=>{}),R=e.isStudentLocked??t?.isNavigationLocked??t?.isStudentLocked??!1,$=e.onBlockedNavigate??t?.notifyLockedNavigation,I=bb(U=>U.timetableOcrTask);if(t?.isStudentLiveMode)return r.jsx(zb,{});const B=n==="student"&&R,H=()=>{if(B){$?.();return}n==="teacher"?v("live_class"):n==="student"&&N("dashboard")},A=()=>{if(B){$?.();return}n==="teacher"?v("dashboard"):n==="student"&&N("dashboard")};return r.jsxs("header",{className:"h-16 border-b border-theme bg-surface text-main flex items-center px-6 justify-between shrink-0 shadow-sm relative z-20 transition-colors duration-200",children:[r.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[r.jsxs("button",{onClick:H,className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:B?i==="zh"?"全班专注锁定中,无法返回首页":"Class focus locked — cannot return to home":i==="zh"?"返回首页":"Back to Home",children:[w.logoUrl?r.jsx("img",{src:w.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):r.jsx("div",{className:"h-8 w-8 rounded-lg bg-gradient-to-tr from-indigo-600 to-indigo-700 flex items-center justify-center text-white font-black text-sm shadow-xs shrink-0",children:"OL"}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:w.siteName||"OpenLearn Next"}),r.jsxs("span",{className:"text-xs font-medium text-subtle tracking-tight",children:["v","0.7.2"]}),w.slogan&&r.jsx("span",{className:"hidden md:inline text-xs text-subtle font-normal truncate max-w-[200px]",children:w.slogan})]})]}),r.jsx(Me,{slot:"header.status_pill",slotProps:{dbConnected:g,dbStatus:b,lang:i}}),I?.status==="running"&&r.jsxs("div",{className:"hidden md:flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-violet-50 text-violet-700 text-xs font-semibold border border-violet-200 animate-pulse select-none",title:i==="zh"?"大模型正在后台分析提取课表内容...":"AI is processing timetable in background...",children:[r.jsx($t,{size:13,className:"animate-spin text-violet-600"}),r.jsx("span",{children:i==="zh"?"后台识别课表中...":"Timetable OCR Running..."})]}),I?.status==="completed"&&o!=="timetable"&&r.jsxs("button",{type:"button",onClick:()=>{v("timetable"),Ve.getState().setPendingTimetableSubTab("ocr_import")},className:"hidden md:flex items-center gap-1.5 px-3 py-1 rounded-full bg-emerald-50 text-emerald-700 hover:bg-emerald-100 text-xs font-bold border border-emerald-200 transition-colors shadow-2xs cursor-pointer select-none",title:i==="zh"?"点击前往课表管理查看识别结果":"Click to view timetable result",children:[r.jsx(at,{size:13,className:"text-emerald-600"}),r.jsx("span",{children:i==="zh"?`课表识别已完成 (${I.result?.entries.length||0}节) · 查看`:`Timetable Ready (${I.result?.entries.length||0})`})]}),r.jsx(Me,{slot:"header.async_task.item",slotProps:{lang:i,activeRole:n,teacherTab:o,setTeacherTab:v}}),r.jsxs("button",{onClick:A,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${n==="teacher"&&o==="dashboard"||n==="student"&&a==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"} ${B?"opacity-50":""}`,children:[B?r.jsx(Gi,{size:16}):r.jsx(td,{size:16}),i==="zh"?"系统总览":"Dashboard"]}),n==="student"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),r.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[r.jsx(Jp,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),n==="student"&&l?.role==="teacher"&&r.jsxs("div",{className:"flex items-center gap-2 bg-amber-50/90 border border-amber-200/80 px-2.5 py-1 rounded-lg shadow-2xs",children:[r.jsxs("span",{className:"text-xs font-semibold text-amber-800 flex items-center gap-1",children:[r.jsx(Ns,{size:13,className:"text-amber-600"}),i==="zh"?"模拟学生:":"View as:"]}),r.jsxs("select",{className:"border border-amber-300 rounded px-1.5 py-0.5 text-xs bg-white text-gray-800 font-medium focus:ring-1 focus:ring-amber-400 focus:outline-hidden",value:c||"",onChange:U=>y(U.target.value),children:[r.jsxs("option",{value:"",children:["-- ",i==="zh"?"选择学生":"Select Student"," --"]}),d.map(U=>r.jsx("option",{value:U.id,children:U.name},U.id))]}),r.jsxs("button",{type:"button",onClick:()=>{if(s){window.close();return}z?.("teacher")},className:"ml-1 px-2.5 py-1 bg-amber-600 hover:bg-amber-700 active:bg-amber-800 text-white text-xs font-bold rounded-md flex items-center gap-1 transition-all cursor-pointer shadow-2xs",title:i==="zh"?s?"关闭此学生视角预览标签页":"退出模拟学生并返回教师端工作台":s?"Close this student preview tab":"Exit student view and return to teacher workspace",children:[s?r.jsx(Oe,{size:12}):r.jsx(zr,{size:12}),i==="zh"?s?"关闭预览":"返回教师端":s?"Close Tab":"Exit Student View"]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[n==="student"&&c&&u&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{type:"button",onClick:()=>O(!m),"aria-label":i==="zh"?`通知${h.length>0?`(${h.length} 条未读)`:""}`:`Notifications${h.length>0?` (${h.length} unread)`:""}`,"aria-expanded":m,className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[r.jsx($o,{size:20,"aria-hidden":"true"}),h.length>0&&r.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:h.length})]}),m&&r.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-white border border-gray-200 shadow-lg rounded-xl z-50 overflow-hidden",children:[r.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[r.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),h.length>0&&r.jsx("button",{onClick:async()=>{if(c){try{const U=p.filter(j=>!x.has(j.id)).map(j=>fetch(`/api/students/${c}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:j.id})}));await Promise.all(U)}catch(U){console.error(U)}S(U=>{const j=new Set(U);return p.forEach(V=>j.add(V.id)),j})}},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:p.length===0?r.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):r.jsx("div",{className:"divide-y divide-gray-100",children:p.map(U=>{const j=!x.has(U.id);return r.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${j?"bg-indigo-50/30":""}`,onClick:()=>{j&&(c&&fetch(`/api/students/${c}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:U.id})}).catch(console.error),S(G=>new Set(G).add(U.id)));const V=u?.assignments?.find(G=>G.id===U.relatedId);D({...U,assignment:V}),O(!1)},children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx("div",{className:"mt-0.5",children:U.type==="new_assignment"?r.jsx(Ss,{size:16,className:"text-indigo-500"}):r.jsx(at,{size:16,className:"text-green-500"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:`text-sm ${j?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:U.title}),r.jsx("div",{className:`text-xs mt-0.5 ${j?"text-gray-600":"text-gray-500"}`,children:U.message})]}),j&&r.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},U.id)})})})]})]}),r.jsx("div",{id:"app-header-plugin-actions",className:"flex items-center gap-2 empty:hidden",children:r.jsx(Me,{slot:"header.action",lang:i,fallback:r.jsx(r.Fragment,{}),slotProps:{session:l,currentRole:n,lang:i}})}),r.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-1.5 hover:text-primary-theme transition-colors bg-surface text-main px-3 py-1.5 rounded-md border border-theme shadow-sm font-medium cursor-pointer",children:[r.jsx(Xi,{size:14,className:"text-emerald-500 animate-pulse"}),i==="zh"?"系统资源库":"System Resource Library"]}),r.jsx("button",{onClick:T,title:i==="zh"?"Switch to English":"切换为中文",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",children:r.jsx(Xi,{size:16})}),r.jsx(bd,{lang:i}),r.jsx(Ab,{lang:i}),n!=="student"&&(()=>{const U=b==="error"||!g?{bg:"bg-rose-50 border-rose-200 text-rose-600 hover:bg-rose-100 animate-pulse",dot:"bg-rose-500",ping:"bg-rose-400",label:i==="zh"?"SQLite 数据库连接出错或已断开":"SQLite DB Error / Disconnected"}:b==="warning"?{bg:"bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100",dot:"bg-amber-500",ping:"bg-amber-400",label:i==="zh"?"SQLite 数据库存在状态警告":"SQLite DB Warning"}:{bg:"bg-emerald-50 border-emerald-200 text-emerald-600 hover:bg-emerald-100",dot:"bg-emerald-500",ping:"bg-emerald-400",label:i==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return r.jsxs("div",{id:"db-connection-status-badge",className:`w-8 h-8 rounded-lg border flex items-center justify-center relative select-none shrink-0 cursor-pointer transition-colors shadow-3xs ${U.bg}`,title:U.label,children:[r.jsx(Kp,{size:15}),r.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[r.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${U.ping}`}),r.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${U.dot}`})]})]})})(),r.jsx(yb,{session:l,lang:i,onLogout:_,onProfile:()=>k(!0)})]})]})}function Rb(){const[e,t]=f.useState(()=>typeof navigator>"u"?!0:navigator.onLine);return f.useEffect(()=>{const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n),window.addEventListener("offline",s),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}},[]),e}function _b(){const e=nn(),t=Rb(),n=e?.lang??"zh",s=e?.activeRole??"teacher",i=e?.session;return r.jsx("footer",{id:"app-statusbar",role:"status",className:"h-7 shrink-0 border-t border-theme bg-surface text-muted text-xs flex items-center justify-end gap-3 px-4 empty:hidden",children:r.jsx(Me,{slot:"statusbar.item",lang:n,fallback:r.jsx(r.Fragment,{}),slotProps:{session:i,currentRole:s,lang:n,isOnline:t}})})}function Ob({open:e,session:t,lang:n,onClose:s,onSaved:i,onAvatar:o}){const[a,l]=f.useState(t.name),[c,d]=f.useState(!1),[u,m]=f.useState(null),p=f.useRef(null),[h,x]=f.useState(!1),[g,b]=f.useState(null),[w,y]=f.useState(!1),[S,C]=f.useState(""),[k,v]=f.useState(""),[N,O]=f.useState(""),[D,_]=f.useState(!1),[T,z]=f.useState(null),[R,$]=f.useState(!1);if(!e)return null;const I=(W,Y)=>n==="zh"?W:Y,B=t.role==="teacher"?t.subRole==="administrator"?I("管理员","Administrator"):I("教师","Teacher"):I("学生","Student"),H=a.trim(),A=H.length>0&&H!==t.name,U=async()=>{if(!(!A||c)){d(!0),m(null);try{const W=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H})}),Y=await W.json();if(!W.ok){m(Y.error||(n==="zh"?"保存失败":"Save failed"));return}i(Y.name??H)}catch{m(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{d(!1)}}},j=S.length>0&&k.length>=8&&/[a-zA-Z]/.test(k)&&/[0-9]/.test(k)&&k===N,V=async()=>{if(!(!j||D)){_(!0),z(null);try{const W=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:k})}),Y=await W.json();if(!W.ok){z(Y.error||(n==="zh"?"修改失败":"Change failed"));return}$(!0),C(""),v(""),O(""),y(!1)}catch{z(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{_(!1)}}},G=async W=>{const Y=W.target.files?.[0];if(W.target.value="",!!Y){x(!0),b(null);try{const K=await new Promise((je,X)=>{const me=new FileReader;me.onload=()=>je(me.result),me.onerror=()=>X(me.error),me.readAsDataURL(Y)}),ne=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:Y.name,base64Data:K})}),fe=await ne.json();if(!ne.ok){b(fe.error||(n==="zh"?"上传失败":"Upload failed"));return}o?.(fe.avatar)}catch{b(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{x(!1)}}},E=async()=>{x(!0),b(null);try{const W=await fetch("/api/auth/avatar",{method:"DELETE"}),Y=await W.json().catch(()=>({}));if(!W.ok){b(Y.error||(n==="zh"?"移除失败":"Remove failed"));return}o?.(null)}catch{b(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{x(!1)}};return r.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:r.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:W=>W.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[r.jsx("h3",{className:"font-semibold text-gray-800",children:I("个人资料","Profile")}),r.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:r.jsx(Oe,{size:18})})]}),r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"w-14 h-14 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0 overflow-hidden",children:t.avatar?r.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):r.jsx(vs,{size:28})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),r.jsx("p",{className:"text-xs text-gray-400",children:B}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:()=>p.current?.click(),disabled:h,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:h?I("上传中…","Uploading…"):t.avatar?I("更换头像","Change avatar"):I("上传头像","Upload avatar")}),t.avatar&&r.jsx("button",{type:"button",onClick:E,disabled:h,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:I("移除","Remove")})]}),r.jsx("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:G})]})]}),g&&r.jsx("p",{className:"text-xs text-rose-500",children:g}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:I("显示名称","Display Name")}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:a,onChange:W=>l(W.target.value),maxLength:50,className:"flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("button",{onClick:U,disabled:!A||c,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer shrink-0",children:c?I("保存中…","Saving…"):I("保存","Save")})]}),u&&r.jsx("p",{className:"text-xs text-rose-500 mt-1",children:u})]}),r.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[r.jsx(Lo,{size:16,className:"text-gray-400"}),I("修改密码","Change Password")]}),!w&&!R&&r.jsx("button",{onClick:()=>{y(!0),z(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:I("修改","Edit")})]}),R&&r.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[r.jsx(at,{size:16}),I("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsx("input",{type:"password",value:S,onChange:W=>C(W.target.value),placeholder:I("当前密码","Current password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("input",{type:"password",value:k,onChange:W=>v(W.target.value),placeholder:I("新密码(≥8 位,含字母和数字)","New password (≥8 chars, letters + numbers)"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("input",{type:"password",value:N,onChange:W=>O(W.target.value),placeholder:I("确认新密码","Confirm new password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),T&&r.jsx("p",{className:"text-xs text-rose-500",children:T}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:()=>{y(!1),C(""),v(""),O(""),z(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:I("取消","Cancel")}),r.jsx("button",{onClick:V,disabled:!j||D,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer",children:D?I("提交中…","Submitting…"):I("提交","Submit")})]})]})]}),r.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-400",children:I("用户名(登录账号)","Username (login)")}),r.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-400",children:I("角色","Role")}),r.jsx("span",{className:"text-sm font-medium text-gray-700",children:B})]})]})]})]})})}const Db=f.lazy(()=>Je(()=>import("./StudentView-PHKxIV9T.js").then(e=>e.S),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.StudentView}))),Mb=f.lazy(()=>Je(()=>import("./TeacherView-DscJtOJ9.js"),__vite__mapDeps([5,1,2,3,4])).then(e=>({default:e.TeacherView})));function $b(e){const{activeRole:t}=e;return r.jsx(f.Suspense,{fallback:r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-subtle gap-3",children:[r.jsx($t,{className:"w-8 h-8 animate-spin text-indigo-500"}),r.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?r.jsx(Db,{}):r.jsx(Mb,{})})}const Fb=(e,t,n)=>e.replace(/\{\{\s*([\w-]+)\s*\}\}/g,(s,i)=>{const o=n[i];return o!==void 0&&o!==""?o:t?.find(l=>l.name===i)?.default??`{{${i}}}`});function Bb({setInput:e,currentInput:t,lang:n="zh"}){const s=Ne(x=>x.extensionPoints),[i,o]=f.useState(!1),[a,l]=f.useState(null),[c,d]=f.useState({}),u=f.useMemo(()=>s.get("ai.prompt.template")??[],[s]),m=n==="zh",p=u.find(x=>x.id===a);if(u.length===0)return null;const h=(x,g)=>{const b=x.slotProps?.prompt??"",w=Fb(b,x.slotProps?.parameters,g);e(t?`${t.trimEnd()}
|
|
10
|
+
}`}function Tb(e){if(typeof document>"u")return;delete kr[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function hi(e){if(!(typeof window>"u"))try{tn.publish({id:Or(),type:"theme.changed",source:"theme-store",payload:{theme:e,tokens:Xo(e)},timestamp:Date.now()})}catch{}}const Dr=Vo((e,t)=>({theme:"light",availableThemes:[...Nb],initTheme:()=>{if(typeof window>"u")return;try{const i=localStorage.getItem(is);if(i){const o=JSON.parse(i);Array.isArray(o)&&o.forEach(a=>{a&&a.spec&&a.spec.id&&t().registerTheme(a.spec,a.cssVariables)})}}catch{}const s=localStorage.getItem(di)||"light";ui(s),e({theme:s}),hi(s)},setTheme:n=>{ui(n),typeof window<"u"&&localStorage.setItem(di,n),e({theme:n}),hi(n)},registerTheme:(n,s)=>{s&&Eb(n.id,s),e(i=>({availableThemes:[...i.availableThemes.filter(a=>a.id!==n.id),n]}))},unregisterTheme:n=>{Tb(n),e(s=>{const i=s.availableThemes.filter(a=>a.id!==n),o=s.theme===n?"light":s.theme;return s.theme===n&&(ui("light"),typeof window<"u"&&localStorage.setItem(di,"light"),hi("light")),{availableThemes:i,theme:o}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const i=localStorage.getItem(is);let o=i?JSON.parse(i):[];Array.isArray(o)||(o=[]),o=o.filter(a=>a.spec.id!==n.id),o.push({spec:n,cssVariables:s}),localStorage.setItem(is,JSON.stringify(o))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(is);if(s){let i=JSON.parse(s);Array.isArray(i)&&(i=i.filter(o=>o.spec.id!==n),localStorage.setItem(is,JSON.stringify(i)))}}catch{}t().unregisterTheme(n)}})),Pb=[{id:"sapphire-classic",label:"高雅墨蓝",description:"深海午夜蓝灰与经典宝石蓝,适合沉浸式研究与高对比度投影",tokens:{"--bg-app":"#0d131f","--bg-surface":"#161f30","--bg-surface-secondary":"#1f2c42","--bg-surface-elevated":"#24334d","--border-theme":"#2e3f5b","--border-theme-subtle":"#1f2c42","--text-main":"#f1f5f9","--text-muted":"#94a3b8","--color-primary":"#3b82f6","--color-primary-hover":"#2563eb"}},{id:"sakura-dusk",label:"暮樱柔粉",description:"柔和日系樱花与温暖象牙白,适合美育、艺术与温馨研讨课堂",tokens:{"--bg-app":"#fff9fa","--bg-surface":"#ffffff","--bg-surface-secondary":"#fceef1","--bg-surface-elevated":"#ffffff","--border-theme":"#f5d5db","--border-theme-subtle":"#fae8eb","--text-main":"#3f2d33","--text-muted":"#8a6d76","--color-primary":"#f43f5e","--color-primary-hover":"#e11d48"}},{id:"autumn-amber",label:"复古秋叶",description:"温暖金秋落叶色调与复古羊皮纸质感,适合文科通识与阅读研讨",tokens:{"--bg-app":"#fdfaf6","--bg-surface":"#ffffff","--bg-surface-secondary":"#f5eee6","--bg-surface-elevated":"#ffffff","--border-theme":"#e6d7c3","--border-theme-subtle":"#ede3d5","--text-main":"#2d241e","--text-muted":"#7c6a59","--color-primary":"#d97706","--color-primary-hover":"#b45309"}},{id:"deep-sea-cyber",label:"深海极客",description:"赛博暗黑青绿冷光,极高现代感与未来科技探索质感",tokens:{"--bg-app":"#091014","--bg-surface":"#0f1a20","--bg-surface-secondary":"#16262e","--bg-surface-elevated":"#1d333e","--border-theme":"#25414e","--border-theme-subtle":"#16262e","--text-main":"#e0f2fe","--text-muted":"#7dd3fc","--color-primary":"#06b6d4","--color-primary-hover":"#0891b2"}}],ol={...sr.light};function Ib({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:i,deleteCustomTheme:o}=Dr(),a=f.useId(),[l,c]=f.useState("custom-mytheme"),[d,u]=f.useState("我的专属主题"),[m,p]=f.useState("自定义教学调色板配置"),[h,x]=f.useState({...ol}),[g,b]=f.useState("none"),[w,y]=f.useState(""),[S,C]=f.useState(!1),[k,v]=f.useState(null);if(!e)return null;const N=s.filter(A=>A.category==="custom"),O=A=>{v(A),setTimeout(()=>v(null),3e3)},D=A=>{c(A.id),u(A.label),p(A.description),x({...A.tokens}),O(`已载入预设: ${A.label}`)},_=A=>{c(A.id),u(A.label),p(A.description);const U=Xo(A.id);U&&Object.keys(U).length>0&&x({...U}),O(`已载入自定义主题: ${A.label}`)},T=(A,U)=>{x(j=>({...j,[A]:U}))},z=()=>{const A=l.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!A){alert("请输入有效的主题标识 (ID)");return}const U={id:A,label:d.trim()||"未命名主题",description:m.trim()||"自定义主题",previewBg:h["--bg-app"]||"#ffffff",previewPrimary:h["--color-primary"]||"#4f46e5",category:"custom"};i(U,h),O(`主题「${U.label}」已保存并成功激活!`)},R=()=>{y(JSON.stringify({version:"1.0",id:l,label:d,description:m,tokens:h},null,2)),b("export")},$=()=>{y(""),b("import")},I=()=>{try{const A=JSON.parse(w);if(!A.tokens||typeof A.tokens!="object")throw new Error("缺少合法的 tokens 字段");A.id&&c(A.id),A.label&&u(A.label),A.description&&p(A.description),x(U=>({...U,...A.tokens})),b("none"),O("主题配置导入成功!")}catch(A){alert(`导入失败: ${A.message||"JSON 格式解析错误"}`)}},B=()=>{navigator.clipboard.writeText(w),C(!0),setTimeout(()=>C(!1),2e3)},H=[{key:"--color-primary",labelZh:"核心主色",labelEn:"Primary Brand Color",desc:"按钮高亮、焦点描边与重点图标"},{key:"--color-primary-hover",labelZh:"主色悬浮",labelEn:"Primary Hover",desc:"按钮悬停交互色"},{key:"--bg-app",labelZh:"全局底色",labelEn:"App Background",desc:"页面整体底衬颜色"},{key:"--bg-surface",labelZh:"卡片底色",labelEn:"Surface Background",desc:"白板卡片、浮层与侧边栏底色"},{key:"--bg-surface-secondary",labelZh:"次级底色",labelEn:"Secondary Surface",desc:"表格斑马纹、标签与次级面板"},{key:"--bg-surface-elevated",labelZh:"浮层底色",labelEn:"Elevated Surface",desc:"弹窗与下拉菜单浮动卡片"},{key:"--border-theme",labelZh:"主边框色",labelEn:"Border Color",desc:"卡片外边框、网格分割线"},{key:"--border-theme-subtle",labelZh:"弱化边框",labelEn:"Subtle Border",desc:"细微内部分割线"},{key:"--text-main",labelZh:"主文本色",labelEn:"Main Text",desc:"正文文字、标题"},{key:"--text-muted",labelZh:"弱化文本",labelEn:"Muted Text",desc:"副标题、辅助信息与提示说明"}];return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 bg-black/60 backdrop-blur-xs animate-in fade-in duration-150",children:r.jsxs("div",{className:"bg-surface text-main border border-theme rounded-2xl shadow-2xl w-full max-w-6xl h-[92vh] max-h-[900px] flex flex-col overflow-hidden relative",children:[r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:r.jsx(Zi,{size:22})}),r.jsxs("div",{children:[r.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme font-medium",children:"v0.3.0"})]}),r.jsx("p",{className:"text-xs text-muted mt-0.5",children:n==="zh"?"自定义课堂交互色盘,支持一键载入创意预设、实时拟真沙箱预览与微前端自动同步":"Customize learning palettes with live previews, creative presets, and micro-frontend sync"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:$,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导入 JSON",children:[r.jsx(Ha,{size:14}),n==="zh"?"导入配置":"Import"]}),r.jsxs("button",{onClick:R,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导出 JSON",children:[r.jsx(Ji,{size:14}),n==="zh"?"导出配置":"Export"]}),r.jsx("button",{onClick:t,className:"p-2 rounded-lg text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer ml-1","aria-label":"Close",children:r.jsx(Oe,{size:18})})]})]}),k&&r.jsxs("div",{className:"absolute top-18 left-1/2 -translate-x-1/2 z-50 bg-primary-theme text-white px-4 py-2 rounded-xl shadow-lg text-xs font-medium flex items-center gap-2 animate-in fade-in slide-in-from-top-2",children:[r.jsx(ht,{size:14}),k]}),r.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[r.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[r.jsxs("section",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(yt,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),r.jsx("span",{className:"text-xs text-muted",children:"一键填入调色板"})]}),r.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Pb.map(A=>r.jsxs("button",{onClick:()=>D(A),className:"flex flex-col p-3 rounded-xl border border-theme hover:border-primary-theme/50 hover:bg-surface-secondary text-left transition-all cursor-pointer group relative overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between w-full",children:[r.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:A.tokens["--color-primary"]}}),A.label]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:A.tokens["--bg-app"]}}),r.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:A.tokens["--bg-surface"]}})]})]}),r.jsx("p",{className:"text-xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:A.description})]},A.id))})]}),r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Vp,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-themeId`,className:"block text-xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),r.jsx("input",{id:`${a}-themeId`,type:"text",value:l,onChange:A=>c(A.target.value),placeholder:"custom-mytheme",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-label`,className:"block text-xs font-medium text-muted mb-1",children:"主题名称"}),r.jsx("input",{id:`${a}-label`,type:"text",value:d,onChange:A=>u(A.target.value),placeholder:"我的专属主题",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:`${a}-description`,className:"block text-xs font-medium text-muted mb-1",children:"主题描述"}),r.jsx("input",{id:`${a}-description`,type:"text",value:m,onChange:A=>p(A.target.value),placeholder:"针对特定课堂采光与演示场景优化",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Zi,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),r.jsx("div",{className:"space-y-2.5",children:H.map(A=>{const U=h[A.key]||"#000000";return r.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-main",children:A.labelZh}),r.jsx("span",{className:"text-xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:A.key})]}),r.jsx("p",{className:"text-xs text-muted mt-0.5",children:A.desc})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"relative flex items-center",children:r.jsx("input",{type:"color",value:U.startsWith("#")&&U.length===7?U:"#4f46e5",onChange:j=>T(A.key,j.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),r.jsx("input",{type:"text",value:U,onChange:j=>T(A.key,j.target.value),className:"w-20 px-2 py-1 text-xs font-mono rounded-lg border border-theme bg-surface text-main text-center focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]},A.key)})})]}),N.length>0&&r.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[r.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[r.jsx(Xc,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),r.jsx("div",{className:"space-y-2",children:N.map(A=>r.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[r.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[r.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:A.previewPrimary}}),r.jsxs("div",{className:"truncate",children:[r.jsx("div",{className:"text-xs font-semibold text-main truncate",children:A.label}),r.jsx("div",{className:"text-xs text-muted truncate",children:A.description})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[r.jsx("button",{onClick:()=>_(A),className:"px-2 py-1 text-xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),r.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${A.label}」吗?`)&&(o(A.id),O(`已删除主题「${A.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:r.jsx(_r,{size:13})})]})]},A.id))})]})]}),r.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[r.jsx(Ns,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),r.jsxs("span",{className:"text-xs text-muted font-mono",children:["当前预览: ",d," (",l,")"]})]}),r.jsxs("div",{className:"flex-1 rounded-2xl border shadow-inner overflow-hidden flex flex-col transition-colors duration-200",style:{backgroundColor:h["--bg-app"]||"#f8fafc",borderColor:h["--border-theme"]||"#e2e8f0",color:h["--text-main"]||"#0f172a"},children:[r.jsxs("div",{className:"h-12 border-b px-4 flex items-center justify-between shrink-0",style:{backgroundColor:h["--bg-surface"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-white text-xs",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"OL"}),r.jsx("span",{className:"font-bold text-xs",style:{color:h["--text-main"]},children:"OpenLearn V2"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"text-xs px-2 py-0.5 rounded-md font-mono",style:{backgroundColor:h["--bg-surface-secondary"]||"#f1f5f9",color:h["--text-muted"]||"#64748b"},children:"10:30:00"}),r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"T"})]})]}),r.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[r.jsxs("div",{className:"p-4 rounded-xl border shadow-xs space-y-3",style:{backgroundColor:h["--bg-surface"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0"},children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"font-bold text-sm",style:{color:h["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),r.jsx("p",{className:"text-xs mt-1",style:{color:h["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:h["--bg-surface-secondary"],color:h["--color-primary"],border:`1px solid ${h["--border-theme"]}`},children:"进行中"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"光电门测速 (v)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"2.43 m/s"})]}),r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"动能增量 (ΔEk)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--color-primary"]},children:"0.589 J"})]}),r.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[r.jsx("div",{className:"text-xs",style:{color:h["--text-muted"]},children:"误差率 (Err)"}),r.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"0.84 %"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white shadow-xs transition-opacity hover:opacity-90 cursor-pointer",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"开始数据采集"}),r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors cursor-pointer",style:{backgroundColor:h["--bg-surface-elevated"]||"#ffffff",borderColor:h["--border-theme"]||"#e2e8f0",color:h["--text-main"]||"#0f172a"},children:"重置实验"}),r.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:h["--text-muted"]},children:"查看教案"})]})]}),r.jsxs("div",{className:"p-3 rounded-xl border space-y-2",style:{backgroundColor:h["--bg-surface-elevated"]||"#ffffff",borderColor:h["--border-theme-subtle"]||"#f1f5f9"},children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold",style:{color:h["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),r.jsx("span",{className:"text-xs font-mono",style:{color:h["--text-muted"]},children:"60 FPS"})]}),r.jsxs("div",{className:"h-28 rounded-lg border border-dashed flex items-center justify-center p-3 relative overflow-hidden",style:{backgroundColor:h["--bg-app"],borderColor:h["--border-theme"]},children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white font-bold shadow-md transform -rotate-6",style:{backgroundColor:h["--color-primary"]},children:r.jsx(Rr,{size:20})}),r.jsx("div",{className:"absolute bottom-2 right-2 text-xs font-mono px-1.5 py-0.5 rounded border",style:{backgroundColor:h["--bg-surface"],borderColor:h["--border-theme"],color:h["--text-muted"]},children:"iframe Bridge Sync Ready"})]})]})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("button",{onClick:()=>{x({...ol}),O("已重置为系统默认调色板")},className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",children:[r.jsx(ed,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:t,className:"px-4 py-2 rounded-xl border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:n==="zh"?"关闭":"Close"}),r.jsxs("button",{onClick:z,className:"px-5 py-2 rounded-xl bg-primary-theme text-white text-xs font-semibold shadow-sm hover:opacity-95 transition-opacity flex items-center gap-1.5 cursor-pointer",children:[r.jsx(Hp,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),g!=="none"&&r.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center p-6 z-50 animate-in fade-in duration-100",children:r.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:g==="export"?r.jsxs(r.Fragment,{children:[r.jsx(Ji,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ha,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),r.jsx("button",{onClick:()=>b("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:r.jsx(Oe,{size:16})})]}),r.jsx("div",{children:r.jsx("textarea",{value:w,readOnly:g==="export",onChange:A=>y(A.target.value),placeholder:g==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),r.jsx("div",{className:"flex items-center justify-end gap-2",children:g==="export"?r.jsx(r.Fragment,{children:r.jsxs("button",{onClick:B,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium flex items-center gap-1.5 cursor-pointer",children:[S?r.jsx(ht,{size:14}):r.jsx(vn,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>b("none"),className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main cursor-pointer",children:n==="zh"?"取消":"Cancel"}),r.jsx("button",{onClick:I,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium cursor-pointer",children:n==="zh"?"解析并导入":"Parse & Import"})]})})]})})]})})}function Ab({lang:e="zh"}){const[t,n]=f.useState(!1),[s,i]=f.useState(!1),o=f.useRef(null),{theme:a,availableThemes:l,setTheme:c}=Dr();f.useEffect(()=>{function u(m){o.current&&!o.current.contains(m.target)&&n(!1)}return t&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[t]);const d=u=>{switch(u){case"dark":return r.jsx(qp,{size:16,className:"text-indigo-400"});case"eyecare":return r.jsx(Ns,{size:16,className:"text-emerald-500"});case"chalkboard":return r.jsx(Zi,{size:16,className:"text-green-400"});case"light":default:return r.jsx(Wp,{size:16,className:"text-amber-500"})}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",ref:o,children:[r.jsx("button",{onClick:()=>n(!t),title:e==="zh"?"切换教学界面主题":"Switch Theme",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer","aria-label":"Theme selector",children:d(a)}),t&&r.jsxs("div",{className:"absolute right-0 mt-2 w-64 rounded-xl border border-theme bg-surface shadow-xl z-50 p-2 overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[r.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[r.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),r.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),r.jsx("div",{className:"space-y-1",children:l.map(u=>{const m=a===u.id;return r.jsxs("button",{onClick:()=>{c(u.id),n(!1)},className:`w-full flex items-center justify-between px-3 py-2 rounded-lg text-left text-xs transition-all cursor-pointer ${m?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 dark:border-white/20 shrink-0 shadow-inner",style:{backgroundColor:u.previewPrimary}}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-main leading-none",children:u.label}),r.jsx("div",{className:"text-xs text-muted mt-1 leading-tight opacity-80",children:u.description})]})]}),m&&r.jsx(ht,{size:14,className:"text-primary-theme shrink-0"})]},u.id)})}),r.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:r.jsxs("button",{onClick:()=>{n(!1),i(!0)},className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",children:[r.jsx(yt,{size:14}),r.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),r.jsx(Ib,{isOpen:s,onClose:()=>i(!1),lang:e})]})}const fi="openlearn_font_scale",gn=85,xn=140,mi=5,rr=100,al=[{scale:90,labelZh:"紧凑 (90%)",labelEn:"Compact (90%)"},{scale:100,labelZh:"标准 (100%)",labelEn:"Standard (100%)"},{scale:110,labelZh:"中大 (110%)",labelEn:"Medium (110%)"},{scale:120,labelZh:"大号 (120%)",labelEn:"Large (120%)"},{scale:130,labelZh:"特大 (130%)",labelEn:"Extra Large (130%)"}];function pi(e){if(typeof document>"u")return;const t=Math.min(xn,Math.max(gn,Math.round(e)));document.documentElement.style.fontSize=`${t}%`,document.documentElement.style.setProperty("--app-font-scale",(t/100).toFixed(2)),document.documentElement.setAttribute("data-font-scale",String(t))}function gi(e){if(!(typeof window>"u"))try{tn.publish({id:Or(),type:"font-scale.changed",source:"font-size-store",payload:{scale:e},timestamp:Date.now()})}catch{}}const wn=Vo((e,t)=>({scale:rr,minScale:gn,maxScale:xn,step:mi,initFontSize:()=>{if(typeof window>"u")return;let n=rr;try{const s=localStorage.getItem(fi);if(s){const i=Number(s);!isNaN(i)&&i>=gn&&i<=xn&&(n=i)}}catch{}pi(n),e({scale:n}),gi(n);try{window.addEventListener("storage",s=>{if(s.key===fi&&s.newValue){const i=Number(s.newValue);!isNaN(i)&&i>=gn&&i<=xn&&(pi(i),e({scale:i}),gi(i))}})}catch{}},setScale:n=>{const s=Math.min(xn,Math.max(gn,Math.round(n)));if(pi(s),typeof window<"u")try{localStorage.setItem(fi,String(s))}catch{}e({scale:s}),gi(s)},increaseScale:()=>{const n=t().scale,s=Math.min(xn,n+mi);t().setScale(s)},decreaseScale:()=>{const n=t().scale,s=Math.max(gn,n-mi);t().setScale(s)},resetScale:()=>{t().setScale(rr)}}));function bd({lang:e="zh"}){const[t,n]=f.useState(!1),s=f.useRef(null),{scale:i,minScale:o,maxScale:a,setScale:l,increaseScale:c,decreaseScale:d,resetScale:u}=wn();f.useEffect(()=>{function h(x){s.current&&!s.current.contains(x.target)&&n(!1)}return t&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[t]);const m=al.find(h=>h.scale===i),p=i===rr;return r.jsxs("div",{className:"relative",ref:s,children:[r.jsxs("button",{type:"button",onClick:()=>n(!t),title:e==="zh"?`界面字体缩放: ${i}%(点击调节)`:`Interface Font Scaling: ${i}% (Click to adjust)`,className:`p-2 hover:bg-surface-secondary transition-colors rounded-lg border shadow-3xs flex items-center justify-center shrink-0 cursor-pointer relative ${p?"bg-surface border-theme text-main":"bg-primary-theme-light border-primary-theme text-primary-theme font-bold"}`,"aria-label":"Font size selector","aria-expanded":t,children:[r.jsx(Gp,{size:16}),!p&&r.jsxs("span",{className:"absolute -bottom-1 -right-1 text-xs px-1 py-0.2 rounded-full bg-primary-theme text-white font-extrabold leading-none shadow-xs",children:[i,"%"]})]}),t&&r.jsxs("div",{className:"absolute right-0 mt-2 w-72 rounded-xl border border-theme bg-surface shadow-xl z-50 p-3 overflow-hidden animate-in fade-in zoom-in-95 duration-100 select-none",children:[r.jsxs("div",{className:"px-1 pb-2 border-b border-theme-subtle mb-2.5 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-xs font-semibold text-main",children:e==="zh"?"界面字号大小":"Interface Font Size"}),r.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"全局等比缩放排版与文字":"Proportionally scale typography"})]}),!p&&r.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 text-xs text-muted hover:text-primary-theme transition-colors cursor-pointer px-1.5 py-0.5 rounded hover:bg-surface-secondary",title:e==="zh"?"恢复默认 100%":"Reset to 100%",children:[r.jsx(ed,{size:11}),r.jsx("span",{children:e==="zh"?"重置":"Reset"})]})]}),r.jsxs("div",{className:"bg-surface-secondary/70 rounded-lg p-2 flex items-center justify-between mb-3 border border-theme-subtle",children:[r.jsx("button",{type:"button",onClick:d,disabled:i<=o,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"减小字体 (A-)":"Decrease (A-)",children:r.jsx(Qp,{size:14})}),r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-sm font-black text-main leading-tight",children:[i,"%"]}),r.jsx("div",{className:"text-xs text-muted",children:m?e==="zh"?m.labelZh.split(" ")[0]:m.labelEn.split(" ")[0]:e==="zh"?"自定义比例":"Custom"})]}),r.jsx("button",{type:"button",onClick:c,disabled:i>=a,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"增大字体 (A+)":"Increase (A+)",children:r.jsx(Bo,{size:14})})]}),r.jsxs("div",{className:"space-y-1 mb-3",children:[r.jsx("div",{className:"text-xs font-bold text-muted uppercase tracking-wider px-1",children:e==="zh"?"常用档位":"Presets"}),r.jsx("div",{className:"grid grid-cols-1 gap-1",children:al.map(h=>{const x=i===h.scale;return r.jsxs("button",{type:"button",onClick:()=>l(h.scale),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs transition-all cursor-pointer ${x?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/30":"text-main hover:bg-surface-secondary border border-transparent"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-60"}),r.jsx("span",{children:e==="zh"?h.labelZh:h.labelEn})]}),x&&r.jsx(ht,{size:13,className:"text-primary-theme shrink-0"})]},h.scale)})})]}),r.jsxs("div",{className:"p-2.5 rounded-lg border border-theme-subtle bg-surface-secondary/40 mb-2",children:[r.jsxs("div",{className:"text-xs text-muted mb-1 flex items-center justify-between",children:[r.jsx("span",{children:e==="zh"?"实时效果预览":"Live Preview"}),r.jsxs("span",{children:[i,"%"]})]}),r.jsx("p",{className:"text-xs text-main font-medium leading-relaxed",children:e==="zh"?"让每一个文字都清晰舒适,智能赋能教学。":"Clear and comfortable typography empowers modern teaching."})]}),r.jsx("div",{className:"text-xs text-muted/80 text-center px-1",children:e==="zh"?"快捷键:Ctrl + Alt + 加号/减号":"Shortcut: Ctrl + Alt + +/-"})]})]})}function zb(e){const t=nn(),n=e.lang??t?.lang??"zh",s=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,i=e.students??t?.students??[],o=e.selectedLesson!==void 0?e.selectedLesson:t?.selectedLesson??null,a=e.lessons??t?.lessons??[],l=e.isStudentLocked??t?.isNavigationLocked??t?.isStudentLocked??!1,c=e.isFollowingTeacher??t?.isFollowingTeacher??!1,d=e.setIsFollowingTeacher??t?.setIsFollowingTeacher??(()=>{}),u=e.notifyLockedNavigation??t?.notifyLockedNavigation??(()=>{});return r.jsxs("header",{className:"h-13 bg-surface/95 backdrop-blur-md border-b border-theme px-4 flex items-center justify-between z-20 shrink-0 select-none shadow-xs",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-tr from-pink-500 to-rose-600 flex items-center justify-center text-white font-black shadow-sm text-sm",children:"🎓"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-sm font-black text-main tracking-wide",children:n==="zh"?"互动课堂 · 学生端":"Interactive Classroom · Student Client"}),r.jsxs("span",{className:"flex items-center gap-1 text-xs font-bold text-emerald-700 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),n==="zh"?"已与教师中控台实时联动":"Synced with Teacher"]})]}),r.jsxs("div",{className:"text-xs text-muted flex items-center gap-2",children:[r.jsx("span",{children:s?`学生: ${i.find(m=>m.id===s)?.name||s}`:"学生端"}),r.jsx("span",{children:"•"}),r.jsx("span",{children:o?`课节: ${a.find(m=>m.id===o)?.title||o}`:"等待教师推流课节..."})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{if(l){u();return}d(!c)},disabled:l,className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all flex items-center gap-1.5 shadow-2xs ${l?"cursor-not-allowed":"cursor-pointer"} ${c?"bg-indigo-50 dark:bg-indigo-950/40 text-indigo-600 dark:text-indigo-400 border-indigo-200 dark:border-indigo-800":"bg-surface text-muted border-theme hover:text-main"} ${l?"opacity-70":""}`,title:l?n==="zh"?"全班专注锁定中,已强制跟随教师步调":"Class focus is locked; following the teacher is enforced":n==="zh"?"开启后,教师端切换课节/环节/Tab时,学生端将自动同步跟随":"Follow teacher navigation",children:[r.jsx(Lr,{size:12,className:c?"animate-spin":""}),r.jsx("span",{children:n==="zh"?`跟随教师步调: ${c?"开":"关"}`:`Follow Teacher: ${c?"ON":"OFF"}`})]}),r.jsx(bd,{lang:n}),r.jsx("button",{type:"button",onClick:()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):document.documentElement.requestFullscreen().catch(()=>{})},className:"p-1.5 text-muted hover:text-main rounded-lg border border-theme hover:bg-surface-secondary transition-colors cursor-pointer",title:n==="zh"?"切换全屏":"Toggle Fullscreen",children:r.jsx(Do,{size:14})}),r.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-2.5 py-1.5 text-xs font-bold text-rose-700 dark:text-rose-400 hover:text-rose-800 bg-rose-50 dark:bg-rose-950/30 border border-rose-200 dark:border-rose-900 rounded-lg transition-colors cursor-pointer",title:n==="zh"?"关闭学生端Tab":"Close Tab",children:n==="zh"?"关闭Tab":"Close Tab"})]})]})}function Lb(e){const t=nn(),n=e.activeRole??t?.activeRole??"teacher",s=e.studentPreviewTab??t?.isStudentPreviewMode??!1,i=e.lang??t?.lang??"zh",o=e.teacherTab??t?.teacherTab??"live_class",a=e.studentViewStatus??t?.studentViewStatus??"dashboard",l=e.session!==void 0?e.session:t?.session,c=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,d=e.students??t?.students??[],u=e.studentDashboardData??t?.studentDashboardData??null,m=e.isNotificationsOpen??t?.isNotificationsOpen??!1,p=e.studentNotifications??t?.studentNotifications??[],h=e.unreadNotifications??t?.unreadNotifications??[],x=e.readNotifications??t?.readNotifications??new Set;e.selectedNotificationForModal!==void 0?e.selectedNotificationForModal:t?.selectedNotificationForModal;const g=e.dbConnected??t?.dbConnected??!1,b=e.dbStatus??t?.dbStatus??"normal",w=e.siteInfo??t?.siteInfo,y=e.setActiveStudentId??t?.setActiveStudentId??(()=>{}),S=e.setReadNotifications??t?.setReadNotifications??(()=>{}),C=e.setIsSystemResourceLibraryOpen??t?.setIsSystemResourceLibraryOpen??(()=>{}),k=e.setProfileOpen??t?.setProfileOpen??(()=>{}),v=e.setTeacherTab??t?.setTeacherTab??(()=>{}),N=e.setStudentViewStatus??t?.setStudentViewStatus??(()=>{}),O=e.setIsNotificationsOpen??t?.setIsNotificationsOpen??(()=>{}),D=e.setSelectedNotificationForModal??t?.setSelectedNotificationForModal??(()=>{}),_=e.handleLogout??t?.handleLogout??t?.onLogout??(()=>{}),T=e.toggleLanguage??t?.toggleLanguage??(()=>{}),z=e.setActiveRole??t?.setActiveRole??(()=>{}),R=e.isStudentLocked??t?.isNavigationLocked??t?.isStudentLocked??!1,$=e.onBlockedNavigate??t?.notifyLockedNavigation,I=bb(U=>U.timetableOcrTask);if(t?.isStudentLiveMode)return r.jsx(zb,{});const B=n==="student"&&R,H=()=>{if(B){$?.();return}n==="teacher"?v("live_class"):n==="student"&&N("dashboard")},A=()=>{if(B){$?.();return}n==="teacher"?v("dashboard"):n==="student"&&N("dashboard")};return r.jsxs("header",{className:"h-16 border-b border-theme bg-surface text-main flex items-center px-6 justify-between shrink-0 shadow-sm relative z-20 transition-colors duration-200",children:[r.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[r.jsxs("button",{onClick:H,className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:B?i==="zh"?"全班专注锁定中,无法返回首页":"Class focus locked — cannot return to home":i==="zh"?"返回首页":"Back to Home",children:[w.logoUrl?r.jsx("img",{src:w.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):r.jsx("div",{className:"h-8 w-8 rounded-lg bg-gradient-to-tr from-indigo-600 to-indigo-700 flex items-center justify-center text-white font-black text-sm shadow-xs shrink-0",children:"OL"}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:w.siteName||"OpenLearn Next"}),r.jsxs("span",{className:"text-xs font-medium text-subtle tracking-tight",children:["v","0.7.4"]}),w.slogan&&r.jsx("span",{className:"hidden md:inline text-xs text-subtle font-normal truncate max-w-[200px]",children:w.slogan})]})]}),r.jsx(Me,{slot:"header.status_pill",slotProps:{dbConnected:g,dbStatus:b,lang:i}}),I?.status==="running"&&r.jsxs("div",{className:"hidden md:flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-violet-50 text-violet-700 text-xs font-semibold border border-violet-200 animate-pulse select-none",title:i==="zh"?"大模型正在后台分析提取课表内容...":"AI is processing timetable in background...",children:[r.jsx($t,{size:13,className:"animate-spin text-violet-600"}),r.jsx("span",{children:i==="zh"?"后台识别课表中...":"Timetable OCR Running..."})]}),I?.status==="completed"&&o!=="timetable"&&r.jsxs("button",{type:"button",onClick:()=>{v("timetable"),Ve.getState().setPendingTimetableSubTab("ocr_import")},className:"hidden md:flex items-center gap-1.5 px-3 py-1 rounded-full bg-emerald-50 text-emerald-700 hover:bg-emerald-100 text-xs font-bold border border-emerald-200 transition-colors shadow-2xs cursor-pointer select-none",title:i==="zh"?"点击前往课表管理查看识别结果":"Click to view timetable result",children:[r.jsx(at,{size:13,className:"text-emerald-600"}),r.jsx("span",{children:i==="zh"?`课表识别已完成 (${I.result?.entries.length||0}节) · 查看`:`Timetable Ready (${I.result?.entries.length||0})`})]}),r.jsx(Me,{slot:"header.async_task.item",slotProps:{lang:i,activeRole:n,teacherTab:o,setTeacherTab:v}}),r.jsxs("button",{onClick:A,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${n==="teacher"&&o==="dashboard"||n==="student"&&a==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"} ${B?"opacity-50":""}`,children:[B?r.jsx(Gi,{size:16}):r.jsx(td,{size:16}),i==="zh"?"系统总览":"Dashboard"]}),n==="student"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),r.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[r.jsx(Jp,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),n==="student"&&l?.role==="teacher"&&r.jsxs("div",{className:"flex items-center gap-2 bg-amber-50/90 border border-amber-200/80 px-2.5 py-1 rounded-lg shadow-2xs",children:[r.jsxs("span",{className:"text-xs font-semibold text-amber-800 flex items-center gap-1",children:[r.jsx(Ns,{size:13,className:"text-amber-600"}),i==="zh"?"模拟学生:":"View as:"]}),r.jsxs("select",{className:"border border-amber-300 rounded px-1.5 py-0.5 text-xs bg-white text-gray-800 font-medium focus:ring-1 focus:ring-amber-400 focus:outline-hidden",value:c||"",onChange:U=>y(U.target.value),children:[r.jsxs("option",{value:"",children:["-- ",i==="zh"?"选择学生":"Select Student"," --"]}),d.map(U=>r.jsx("option",{value:U.id,children:U.name},U.id))]}),r.jsxs("button",{type:"button",onClick:()=>{if(s){window.close();return}z?.("teacher")},className:"ml-1 px-2.5 py-1 bg-amber-600 hover:bg-amber-700 active:bg-amber-800 text-white text-xs font-bold rounded-md flex items-center gap-1 transition-all cursor-pointer shadow-2xs",title:i==="zh"?s?"关闭此学生视角预览标签页":"退出模拟学生并返回教师端工作台":s?"Close this student preview tab":"Exit student view and return to teacher workspace",children:[s?r.jsx(Oe,{size:12}):r.jsx(zr,{size:12}),i==="zh"?s?"关闭预览":"返回教师端":s?"Close Tab":"Exit Student View"]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[n==="student"&&c&&u&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{type:"button",onClick:()=>O(!m),"aria-label":i==="zh"?`通知${h.length>0?`(${h.length} 条未读)`:""}`:`Notifications${h.length>0?` (${h.length} unread)`:""}`,"aria-expanded":m,className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[r.jsx($o,{size:20,"aria-hidden":"true"}),h.length>0&&r.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:h.length})]}),m&&r.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-white border border-gray-200 shadow-lg rounded-xl z-50 overflow-hidden",children:[r.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[r.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),h.length>0&&r.jsx("button",{onClick:async()=>{if(c){try{const U=p.filter(j=>!x.has(j.id)).map(j=>fetch(`/api/students/${c}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:j.id})}));await Promise.all(U)}catch(U){console.error(U)}S(U=>{const j=new Set(U);return p.forEach(V=>j.add(V.id)),j})}},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:p.length===0?r.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):r.jsx("div",{className:"divide-y divide-gray-100",children:p.map(U=>{const j=!x.has(U.id);return r.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${j?"bg-indigo-50/30":""}`,onClick:()=>{j&&(c&&fetch(`/api/students/${c}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:U.id})}).catch(console.error),S(G=>new Set(G).add(U.id)));const V=u?.assignments?.find(G=>G.id===U.relatedId);D({...U,assignment:V}),O(!1)},children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx("div",{className:"mt-0.5",children:U.type==="new_assignment"?r.jsx(Ss,{size:16,className:"text-indigo-500"}):r.jsx(at,{size:16,className:"text-green-500"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:`text-sm ${j?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:U.title}),r.jsx("div",{className:`text-xs mt-0.5 ${j?"text-gray-600":"text-gray-500"}`,children:U.message})]}),j&&r.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},U.id)})})})]})]}),r.jsx("div",{id:"app-header-plugin-actions",className:"flex items-center gap-2 empty:hidden",children:r.jsx(Me,{slot:"header.action",lang:i,fallback:r.jsx(r.Fragment,{}),slotProps:{session:l,currentRole:n,lang:i}})}),r.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-1.5 hover:text-primary-theme transition-colors bg-surface text-main px-3 py-1.5 rounded-md border border-theme shadow-sm font-medium cursor-pointer",children:[r.jsx(Xi,{size:14,className:"text-emerald-500 animate-pulse"}),i==="zh"?"系统资源库":"System Resource Library"]}),r.jsx("button",{onClick:T,title:i==="zh"?"Switch to English":"切换为中文",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",children:r.jsx(Xi,{size:16})}),r.jsx(bd,{lang:i}),r.jsx(Ab,{lang:i}),n!=="student"&&(()=>{const U=b==="error"||!g?{bg:"bg-rose-50 border-rose-200 text-rose-600 hover:bg-rose-100 animate-pulse",dot:"bg-rose-500",ping:"bg-rose-400",label:i==="zh"?"SQLite 数据库连接出错或已断开":"SQLite DB Error / Disconnected"}:b==="warning"?{bg:"bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100",dot:"bg-amber-500",ping:"bg-amber-400",label:i==="zh"?"SQLite 数据库存在状态警告":"SQLite DB Warning"}:{bg:"bg-emerald-50 border-emerald-200 text-emerald-600 hover:bg-emerald-100",dot:"bg-emerald-500",ping:"bg-emerald-400",label:i==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return r.jsxs("div",{id:"db-connection-status-badge",className:`w-8 h-8 rounded-lg border flex items-center justify-center relative select-none shrink-0 cursor-pointer transition-colors shadow-3xs ${U.bg}`,title:U.label,children:[r.jsx(Kp,{size:15}),r.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[r.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${U.ping}`}),r.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${U.dot}`})]})]})})(),r.jsx(yb,{session:l,lang:i,onLogout:_,onProfile:()=>k(!0)})]})]})}function Rb(){const[e,t]=f.useState(()=>typeof navigator>"u"?!0:navigator.onLine);return f.useEffect(()=>{const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n),window.addEventListener("offline",s),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}},[]),e}function _b(){const e=nn(),t=Rb(),n=e?.lang??"zh",s=e?.activeRole??"teacher",i=e?.session;return r.jsx("footer",{id:"app-statusbar",role:"status",className:"h-7 shrink-0 border-t border-theme bg-surface text-muted text-xs flex items-center justify-end gap-3 px-4 empty:hidden",children:r.jsx(Me,{slot:"statusbar.item",lang:n,fallback:r.jsx(r.Fragment,{}),slotProps:{session:i,currentRole:s,lang:n,isOnline:t}})})}function Ob({open:e,session:t,lang:n,onClose:s,onSaved:i,onAvatar:o}){const[a,l]=f.useState(t.name),[c,d]=f.useState(!1),[u,m]=f.useState(null),p=f.useRef(null),[h,x]=f.useState(!1),[g,b]=f.useState(null),[w,y]=f.useState(!1),[S,C]=f.useState(""),[k,v]=f.useState(""),[N,O]=f.useState(""),[D,_]=f.useState(!1),[T,z]=f.useState(null),[R,$]=f.useState(!1);if(!e)return null;const I=(W,Y)=>n==="zh"?W:Y,B=t.role==="teacher"?t.subRole==="administrator"?I("管理员","Administrator"):I("教师","Teacher"):I("学生","Student"),H=a.trim(),A=H.length>0&&H!==t.name,U=async()=>{if(!(!A||c)){d(!0),m(null);try{const W=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H})}),Y=await W.json();if(!W.ok){m(Y.error||(n==="zh"?"保存失败":"Save failed"));return}i(Y.name??H)}catch{m(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{d(!1)}}},j=S.length>0&&k.length>=8&&/[a-zA-Z]/.test(k)&&/[0-9]/.test(k)&&k===N,V=async()=>{if(!(!j||D)){_(!0),z(null);try{const W=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:k})}),Y=await W.json();if(!W.ok){z(Y.error||(n==="zh"?"修改失败":"Change failed"));return}$(!0),C(""),v(""),O(""),y(!1)}catch{z(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{_(!1)}}},G=async W=>{const Y=W.target.files?.[0];if(W.target.value="",!!Y){x(!0),b(null);try{const K=await new Promise((je,X)=>{const me=new FileReader;me.onload=()=>je(me.result),me.onerror=()=>X(me.error),me.readAsDataURL(Y)}),ne=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:Y.name,base64Data:K})}),fe=await ne.json();if(!ne.ok){b(fe.error||(n==="zh"?"上传失败":"Upload failed"));return}o?.(fe.avatar)}catch{b(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{x(!1)}}},E=async()=>{x(!0),b(null);try{const W=await fetch("/api/auth/avatar",{method:"DELETE"}),Y=await W.json().catch(()=>({}));if(!W.ok){b(Y.error||(n==="zh"?"移除失败":"Remove failed"));return}o?.(null)}catch{b(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{x(!1)}};return r.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:r.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:W=>W.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[r.jsx("h3",{className:"font-semibold text-gray-800",children:I("个人资料","Profile")}),r.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:r.jsx(Oe,{size:18})})]}),r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"w-14 h-14 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0 overflow-hidden",children:t.avatar?r.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):r.jsx(vs,{size:28})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),r.jsx("p",{className:"text-xs text-gray-400",children:B}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:()=>p.current?.click(),disabled:h,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:h?I("上传中…","Uploading…"):t.avatar?I("更换头像","Change avatar"):I("上传头像","Upload avatar")}),t.avatar&&r.jsx("button",{type:"button",onClick:E,disabled:h,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:I("移除","Remove")})]}),r.jsx("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:G})]})]}),g&&r.jsx("p",{className:"text-xs text-rose-500",children:g}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:I("显示名称","Display Name")}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:a,onChange:W=>l(W.target.value),maxLength:50,className:"flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("button",{onClick:U,disabled:!A||c,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer shrink-0",children:c?I("保存中…","Saving…"):I("保存","Save")})]}),u&&r.jsx("p",{className:"text-xs text-rose-500 mt-1",children:u})]}),r.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[r.jsx(Lo,{size:16,className:"text-gray-400"}),I("修改密码","Change Password")]}),!w&&!R&&r.jsx("button",{onClick:()=>{y(!0),z(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:I("修改","Edit")})]}),R&&r.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[r.jsx(at,{size:16}),I("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsx("input",{type:"password",value:S,onChange:W=>C(W.target.value),placeholder:I("当前密码","Current password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("input",{type:"password",value:k,onChange:W=>v(W.target.value),placeholder:I("新密码(≥8 位,含字母和数字)","New password (≥8 chars, letters + numbers)"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),r.jsx("input",{type:"password",value:N,onChange:W=>O(W.target.value),placeholder:I("确认新密码","Confirm new password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),T&&r.jsx("p",{className:"text-xs text-rose-500",children:T}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:()=>{y(!1),C(""),v(""),O(""),z(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:I("取消","Cancel")}),r.jsx("button",{onClick:V,disabled:!j||D,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer",children:D?I("提交中…","Submitting…"):I("提交","Submit")})]})]})]}),r.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-400",children:I("用户名(登录账号)","Username (login)")}),r.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-gray-400",children:I("角色","Role")}),r.jsx("span",{className:"text-sm font-medium text-gray-700",children:B})]})]})]})]})})}const Db=f.lazy(()=>Je(()=>import("./StudentView-CpJsG7FT.js").then(e=>e.S),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.StudentView}))),Mb=f.lazy(()=>Je(()=>import("./TeacherView-B3zhzd5g.js"),__vite__mapDeps([5,1,2,3,4])).then(e=>({default:e.TeacherView})));function $b(e){const{activeRole:t}=e;return r.jsx(f.Suspense,{fallback:r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-subtle gap-3",children:[r.jsx($t,{className:"w-8 h-8 animate-spin text-indigo-500"}),r.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?r.jsx(Db,{}):r.jsx(Mb,{})})}const Fb=(e,t,n)=>e.replace(/\{\{\s*([\w-]+)\s*\}\}/g,(s,i)=>{const o=n[i];return o!==void 0&&o!==""?o:t?.find(l=>l.name===i)?.default??`{{${i}}}`});function Bb({setInput:e,currentInput:t,lang:n="zh"}){const s=Ne(x=>x.extensionPoints),[i,o]=f.useState(!1),[a,l]=f.useState(null),[c,d]=f.useState({}),u=f.useMemo(()=>s.get("ai.prompt.template")??[],[s]),m=n==="zh",p=u.find(x=>x.id===a);if(u.length===0)return null;const h=(x,g)=>{const b=x.slotProps?.prompt??"",w=Fb(b,x.slotProps?.parameters,g);e(t?`${t.trimEnd()}
|
|
11
11
|
|
|
12
|
-
${w}`:w),o(!1),l(null),d({})};return r.jsxs("div",{className:"relative shrink-0",children:[r.jsx("button",{type:"button",onClick:()=>o(!i),disabled:a!==null&&!!p,className:`p-1 px-1.5 rounded-full transition-colors cursor-pointer ${i?"text-indigo-600 bg-indigo-50":"text-gray-500 hover:text-indigo-600 hover:bg-gray-100"}`,title:m?"插件提示词模板":"Plugin prompt templates",children:r.jsx(Yp,{size:14})}),i&&r.jsxs("div",{className:"absolute bottom-full mb-2 left-0 w-80 max-h-72 overflow-y-auto bg-white border border-gray-200 rounded-xl shadow-xl z-40 text-xs",children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100 sticky top-0 bg-white",children:[r.jsx("span",{className:"font-semibold text-gray-700",children:m?"插件提示词模板":"Prompt templates"}),r.jsx("button",{type:"button",onClick:()=>{o(!1),l(null)},className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:r.jsx(Oe,{size:12})})]}),p?r.jsxs("div",{className:"p-3 space-y-2",children:[r.jsx("div",{className:"font-medium text-gray-800",children:p.slotProps?.title||p.id}),(p.slotProps?.parameters??[]).map(x=>r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] text-gray-500",children:x.label||x.name}),r.jsx("input",{value:c[x.name]??"",onChange:g=>d(b=>({...b,[x.name]:g.target.value})),className:"mt-0.5 w-full border border-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300",placeholder:x.default||x.name})]},x.name)),r.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[r.jsx("button",{type:"button",onClick:()=>h(p,c),className:"flex-1 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-semibold transition-colors cursor-pointer",children:m?"插入到输入框":"Insert"}),r.jsx("button",{type:"button",onClick:()=>l(null),className:"px-3 py-1.5 text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg transition-colors cursor-pointer",children:m?"返回":"Back"})]})]}):r.jsx("div",{className:"py-1",children:u.map(x=>{const g=x.slotProps?.title||x.id,b=x.slotProps?.description;return r.jsxs("button",{type:"button",onClick:()=>{const w=x.slotProps?.parameters??[];if(w.length>0){const y={};for(const S of w)S.default&&(y[S.name]=S.default);d(y),l(x.id)}else h(x,{})},className:"w-full text-left px-3 py-2 hover:bg-indigo-50 transition-colors cursor-pointer",children:[r.jsx("div",{className:"font-medium text-gray-800",children:g}),b&&r.jsx("div",{className:"text-[11px] text-gray-500 mt-0.5 line-clamp-2",children:b})]},x.id)})})]})]})}function Ub(e={}){const t=nn(),n=e.showRightSidebar??t?.showRightSidebar??!1,s=e.setShowRightSidebar??t?.setShowRightSidebar??(()=>{}),i=e.rightSidebarTab??t?.rightSidebarTab??"agent",o=e.setRightSidebarTab??t?.setRightSidebarTab??(()=>{}),a=e.effectiveAgentProviderId??t?.effectiveAgentProviderId??"";e.agentProviderId??t?.agentProviderId;const l=e.setAgentProviderId??t?.setAgentProviderId??(()=>{}),c=e.personaId??t?.personaId??"",d=e.setPersonaId??t?.setPersonaId??(()=>{}),u=e.aiProviders??t?.aiProviders??[],m=e.selectedAgentProvider!==void 0?e.selectedAgentProvider:t?.selectedAgentProvider??null,p=e.chatLog??t?.chatLog??[],h=e.loading??t?.loading??!1,x=e.input??t?.input??"",g=e.setInput??t?.setInput??(()=>{}),b=e.handleSend??t?.handleSend??(async()=>{}),w=e.chatAttachments??t?.chatAttachments??[],y=e.setChatAttachments??t?.setChatAttachments??(()=>{}),S=e.handleChatFileChange??t?.handleChatFileChange??(()=>{}),C=e.handleChatDrop??t?.handleChatDrop??(()=>{}),k=e.onClearAgentMemory??t?.handleClearAgentMemory??(()=>{}),v=e.events??t?.events??[],N=e.lang??t?.lang??"zh",O=e.t??t?.t??{},D=f.useRef(null);f.useEffect(()=>{D.current?.scrollIntoView({behavior:"smooth"})},[p]);const[_,T]=f.useState([]);return f.useEffect(()=>{!n||_.length>0||fetch("/api/agent/personas").then(z=>z.ok?z.json():null).then(z=>{z?.success&&Array.isArray(z.personas)&&T(z.personas)}).catch(()=>{})},[n]),r.jsx("div",{className:`transition-all duration-300 bg-white border-l border-gray-200 flex flex-col shadow-xl relative z-30 shrink-0 ${n?"w-96":"w-12 items-center cursor-pointer hover:bg-gray-50"}`,children:n?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[r.jsxs("button",{onClick:()=>o("agent"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${i==="agent"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[r.jsx(Yr,{size:14})," Agent"]}),r.jsxs("button",{onClick:()=>o("shell"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${i==="shell"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[r.jsx(Xs,{size:14})," Shell"]}),r.jsx(Me,{slot:"ai_sidebar.tab",slotProps:{renderType:"button",activeTab:i,setActiveTab:o,lang:N}}),r.jsx("button",{onClick:()=>s(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:r.jsx(Zp,{size:14})})]}),i==="agent"?r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:r.jsx(Yr,{size:16})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:O.agentTitle}),r.jsx("p",{className:"text-xs text-gray-500",children:O.agentSubtitle}),r.jsxs("button",{onClick:k,title:N==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-xs text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",N==="zh"?"清除记忆":"Clear memory"]})]})]}),r.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[r.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-gray-400",children:N==="zh"?"AI 提供商":"AI Provider"}),r.jsxs("div",{className:"relative w-full",children:[u.length===0?r.jsx("select",{disabled:!0,value:"",className:"w-full appearance-none rounded-xl border border-amber-200 bg-amber-50/50 px-3 py-2 pr-9 text-xs font-medium text-amber-700 shadow-xs outline-none cursor-not-allowed",children:r.jsx("option",{value:"",children:N==="zh"?"未配置 AI 提供商":"No AI Provider"})}):r.jsx("select",{value:a,onChange:z=>l(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 pr-9 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:u.map(z=>r.jsx("option",{value:z.id,children:z.name},z.id))}),r.jsx(Nn,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),r.jsx("div",{className:"text-xs text-gray-400 truncate w-full text-right",title:m?.model_name||"",children:m?`${m.model_name}`:N==="zh"?"未配置提供商":"No Provider"})]})]})}),d&&_.length>0&&r.jsx("div",{className:"mx-4 mb-3",children:r.jsxs("select",{value:c||"",onChange:z=>d(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:[r.jsx("option",{value:"",children:N==="zh"?"🤖 助教角色:默认":"🤖 Persona: Default"}),_.filter(z=>z.id!=="plain_assistant").map(z=>r.jsxs("option",{value:z.id,children:[z.icon||"🎯"," ",N==="zh"?z.nameZh:z.nameEn]},z.id))]})}),u.length===0&&r.jsxs("div",{className:"mx-4 mt-3 p-3 bg-amber-50 border border-amber-200/80 rounded-xl text-xs text-amber-900 flex items-start gap-2 shadow-xs shrink-0",children:[r.jsx(Mt,{size:15,className:"shrink-0 text-amber-600 mt-0.5"}),r.jsxs("div",{className:"flex-1 leading-relaxed",children:[r.jsx("span",{className:"font-semibold",children:N==="zh"?"未配置 AI 提供商":"No AI Provider Configured"}),r.jsx("p",{className:"mt-0.5 text-amber-700",children:N==="zh"?"请前往「系统管理 -> AI 提供商管理」添加大模型服务(如 DeepSeek、Qwen、OpenAI 等)。":'Please configure an AI provider in "System Management -> AI Provider Management" to use the AI assistant.'})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[p.map((z,R)=>r.jsx("div",{className:`flex flex-col ${z.role==="user"?"items-end":"items-start"}`,children:r.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${z.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:z.content})},R)),h&&r.jsx("div",{className:"flex items-start",children:r.jsxs("div",{className:"px-4 py-2.5 rounded-2xl max-w-[85%] text-xs bg-gray-100 text-gray-500 rounded-bl-none flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),r.jsx("div",{ref:D})]}),r.jsxs("form",{onSubmit:b,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:z=>z.preventDefault(),onDrop:C,children:[w.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:w.map((z,R)=>r.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full text-xs",children:[r.jsx(Jc,{size:10,className:"shrink-0"}),r.jsx("span",{className:"truncate max-w-[100px]",title:z.name,children:z.name}),r.jsx("button",{type:"button",onClick:()=>y($=>$.filter((I,B)=>B!==R)),className:"hover:bg-indigo-200 rounded-full p-0.5 cursor-pointer ml-0.5 transition-colors text-indigo-400 hover:text-indigo-600",children:r.jsx(Oe,{size:10})})]},R))}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("label",{className:"p-1 px-1.5 text-gray-500 hover:text-indigo-600 rounded-full hover:bg-gray-100 cursor-pointer transition-colors shrink-0",children:[r.jsx(Xp,{size:14}),r.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:S,accept:".csv,.txt,.json,.md"})]}),r.jsx(Bb,{setInput:g,currentInput:x,lang:N}),r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:"text",value:x,disabled:u.length===0,onChange:z=>g(z.target.value),placeholder:u.length===0?N==="zh"?"请先配置 AI 提供商":"Please configure AI provider first":O.placeholder,className:"w-full bg-gray-50 border border-gray-200 rounded-full pl-4 pr-10 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all disabled:opacity-60 disabled:cursor-not-allowed"}),r.jsx("button",{type:"submit",disabled:h||!x.trim()||u.length===0,className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:r.jsx(Kc,{size:10})})]})]})]})]}):i==="shell"?r.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-xs min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[r.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:r.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[r.jsx(Xs,{size:14}),r.jsx("span",{className:"text-xs",children:O.eventStream})]})}),r.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:v.length===0?r.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):v.map((z,R)=>r.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[r.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[r.jsxs("span",{className:"text-gray-500 shrink-0 text-xs",children:["[",new Date(z.timestamp).toLocaleTimeString(),"]"]}),r.jsx("span",{className:"text-blue-400 shrink-0 truncate text-xs",title:z.source,children:z.source})]}),r.jsx("div",{className:"text-green-300 font-bold",children:z.type}),r.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:z.payload})]},R))})]}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto p-4",children:r.jsx(Me,{slot:"ai_sidebar.tab",slotProps:{renderType:"panel",activeTab:i,lang:N}})})]}):r.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-subtle w-full",onClick:()=>s(!0),children:[r.jsx(Yr,{size:18,className:"mb-6 hover:text-indigo-500"}),r.jsx(Xs,{size:18,className:"hover:text-indigo-500"}),r.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:r.jsx("div",{className:"uppercase tracking-widest text-xs rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const Vb=f.lazy(()=>Je(()=>import("./ImportModal-DqjqNeH4.js"),__vite__mapDeps([6,1,2,3])).then(e=>({default:e.ImportModal}))),Hb=f.lazy(()=>Je(()=>import("./CourseWizardModal-Dbi6Caw2.js"),__vite__mapDeps([7,1,2,3,4])).then(e=>({default:e.CourseWizardModal}))),Wb=f.lazy(()=>Je(()=>import("./ImportLessonsModal-PhHtX31R.js"),__vite__mapDeps([8,1,2,3,4])).then(e=>({default:e.ImportLessonsModal}))),qb=f.lazy(()=>Je(()=>import("./QuizGeneratorModal-bUA002kP.js"),__vite__mapDeps([9,1,2,3,4])).then(e=>({default:e.QuizGeneratorModal}))),Gb=f.lazy(()=>Je(()=>import("./ProcessLogsModal-Cfr-T9Gd.js"),__vite__mapDeps([10,1,2,3])).then(e=>({default:e.ProcessLogsModal}))),Qb=f.lazy(()=>Je(()=>import("./CloudDriveModal-D2t3Uyzr.js"),__vite__mapDeps([11,1,2,12,3,4])).then(e=>({default:e.CloudDriveModal}))),Jb=f.lazy(()=>Je(()=>import("./SystemResourceLibraryModal-DgXYe6_x.js"),__vite__mapDeps([13,1,2,11,12,3,4])).then(e=>({default:e.SystemResourceLibraryModal}))),Kb=f.lazy(()=>Je(()=>import("./BatchPickerModal-CbmjInp7.js"),__vite__mapDeps([14,1,2,3,4])).then(e=>({default:e.BatchPickerModal}))),Yb=f.lazy(()=>Je(()=>import("./ExportWeightModal-BrmAh6VX.js"),__vite__mapDeps([15,1,2,3,4])).then(e=>({default:e.ExportWeightModal}))),Zb=f.lazy(()=>Je(()=>import("./NotificationDetailModal-tY5rxYCN.js"),__vite__mapDeps([16,1,2,3,4])).then(e=>({default:e.NotificationDetailModal}))),Xb=f.lazy(()=>Je(()=>import("./HelpTour-D_q1z_MI.js"),__vite__mapDeps([17,1,2,3])).then(e=>({default:e.HelpTour}))),e0=f.lazy(()=>Je(()=>import("./CoursewareHubPanel-CyxDIJAF.js"),__vite__mapDeps([18,1,2,3])).then(e=>({default:e.CoursewareHubPanel})));function t0(e={}){const t=nn(),{lang:n=t?.lang??"zh",t:s=t?.t??{},showImportModal:i=t?.showImportModal??!1,setShowImportModal:o=t?.setShowImportModal??(()=>{}),handleImportFile:a=t?.handleImportFile??(()=>{}),importError:l=t?.importError??null,importSuccess:c=t?.importSuccess??null,isImporting:d=t?.isImporting??!1,downloadCSVTemplate:u=t?.downloadCSVTemplate??(()=>{}),addToast:m=t?.addToast??(()=>{}),isImportLessonsOpen:p=t?.isImportLessonsOpen??!1,setIsImportLessonsOpen:h=t?.setIsImportLessonsOpen??(()=>{}),importStatus:x=t?.importStatus??"idle",setIsDraggingImport:g=t?.setIsDraggingImport??(()=>{}),handleCSVFileChange:b=t?.handleCSVFileChange??(()=>{}),handleImportFileChange:w=t?.handleImportFileChange??(()=>{}),downloadCsvTemplate:y=t?.downloadCsvTemplate??(()=>{}),downloadCourseTemplate:S=t?.downloadCourseTemplate??(()=>{}),packagePreview:C=t?.packagePreview??null,handlePackageImportSubmit:k=t?.handlePackageImportSubmit??(()=>{}),packageDuplicate:v=t?.packageDuplicate??null,handlePackageDuplicateDismiss:N=t?.handlePackageDuplicateDismiss??(()=>{}),isDraggingImport:O=t?.isDraggingImport??!1,previewImportData:D=t?.previewImportData??[],setPreviewImportData:_=t?.setPreviewImportData??(()=>{}),setImportStatus:T=t?.setImportStatus??(()=>{}),importProgress:z=t?.importProgress??0,importProgressTotal:R=t?.importProgressTotal??0,importErrorMsg:$=t?.importErrorMsg??"",setImportErrorMsg:I=t?.setImportErrorMsg??(()=>{}),handleCSVImportSubmit:B=t?.handleCSVImportSubmit??(()=>{}),lessons:H=t?.lessons??[],fetchClassDashboard:A=t?.fetchClassDashboard??(()=>{}),currentVfsParent:U=t?.currentVfsParent??null,setCurrentVfsParent:j=t?.setCurrentVfsParent??(()=>{}),vfsNodes:V=t?.vfsNodes??[],showProcessLogs:G=t?.showProcessLogs??null,setShowProcessLogs:E=t?.setShowProcessLogs??(()=>{}),processLogsContent:W=t?.processLogsContent??"",isCloudDriveOpen:Y=t?.isCloudDriveOpen??!1,setIsCloudDriveOpen:K=t?.setIsCloudDriveOpen??(()=>{}),cloudDrivePreviewNode:ne=t?.cloudDrivePreviewNode??null,setCloudDrivePreviewNode:fe=t?.setCloudDrivePreviewNode??(()=>{}),isSystemResourceLibraryOpen:je=t?.isSystemResourceLibraryOpen??!1,setIsSystemResourceLibraryOpen:X=t?.setIsSystemResourceLibraryOpen??(()=>{}),systemResourceTab:me=t?.systemResourceTab??"system",setSystemResourceTab:ke=t?.setSystemResourceTab??(()=>{}),selectedLibraryResourceId:Se=t?.selectedLibraryResourceId??null,setSelectedLibraryResourceId:M=t?.setSelectedLibraryResourceId??(()=>{}),loadingLibraryResources:Z=t?.loadingLibraryResources??!1,libraryResources:ee=t?.libraryResources??[],fetchLibraryResources:te=t?.fetchLibraryResources??(()=>{}),classes:ce=t?.classes??[],expandedClassId:oe=t?.expandedClassId??null,isExportWeightModalOpen:xe=t?.isExportWeightModalOpen??!1,setIsExportWeightModalOpen:ie=t?.setIsExportWeightModalOpen??(()=>{}),quizzesWeight:Pe=t?.quizzesWeight??40,setQuizzesWeight:ze=t?.setQuizzesWeight??(()=>{}),assignmentsWeight:ue=t?.assignmentsWeight??60,setAssignmentsWeight:re=t?.setAssignmentsWeight??(()=>{}),handleQuizzesWeightChange:P=t?.handleQuizzesWeightChange??(()=>{}),handleAssignmentsWeightChange:L=t?.handleAssignmentsWeightChange??(()=>{}),customCategoryOverrides:F=t?.customCategoryOverrides??{},setCustomCategoryOverrides:q=t?.setCustomCategoryOverrides??(()=>{}),classDashboardMap:J=t?.classDashboardMap??{},exportClassId:be=t?.exportClassId??"",exportClassName:se=t?.exportClassName??"",csvPreviewData:ye=t?.csvPreviewData??null,handleExportGrades:$e=t?.handleExportGrades??(()=>{}),setSelectedAssignment:Fe=t?.setSelectedAssignment??(()=>{}),setStudentViewStatus:Ce=t?.setStudentViewStatus??(()=>{}),setQuizStudentAnswers:We=t?.setQuizStudentAnswers??(()=>{}),setSubAssignmentTab:He=t?.setSubAssignmentTab??(()=>{}),isTourOpen:Et=t?.isTourOpen??!1,setIsTourOpen:et=t?.setIsTourOpen??(()=>{}),handleSeedSuccess:jt=t?.handleSeedSuccess??(()=>{}),setTeacherTab:Vt=t?.setTeacherTab??(()=>{}),showCoursewareHub:Ln=t?.showCoursewareHub??!1,setShowCoursewareHub:Ht=t?.setShowCoursewareHub??(()=>{})}=e,Re=e.courseWizard??t,rn=Re?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Rn=Re?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),_n=Re?.wizardStep??e.wizardStep??1,On=Re?.setWizardStep??e.setWizardStep??(()=>{}),on=Re?.wizardIsSubmitting??e.wizardIsSubmitting??!1,Dn=Re?.wizardCourseTitle??e.wizardCourseTitle??"",an=Re?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),Mn=Re?.wizardCourseDescription??e.wizardCourseDescription??"",$n=Re?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),Fn=Re?.wizardCourseCategory??e.wizardCourseCategory??"",Tt=Re?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),ln=Re?.wizardCourseTimeline??e.wizardCourseTimeline??[],Wt=Re?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),Bn=Re?.wizardCourseContent??e.wizardCourseContent??"",Un=Re?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),Pt=Re?.wizardIsGeneratingOutline??e.wizardIsGeneratingOutline??!1,cn=Re?.handleGenerateOutline??e.handleGenerateOutline??(async()=>{}),dn=Re?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),_e=e.quizGenerator??t,Vn=_e?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,Hn=_e?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),Wn=_e?.quizGenMode??e.quizGenMode??"scan_lesson",qn=_e?.setQuizGenMode??e.setQuizGenMode??(()=>{}),Gn=_e?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",Qn=_e?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),Jn=_e?.quizGenTopic??e.quizGenTopic??"",Kn=_e?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Yn=_e?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,Zn=_e?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),Xn=_e?.suggestedObjectives??e.suggestedObjectives??[],es=_e?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),ts=_e?.suggestedQuestions??e.suggestedQuestions??[],ge=_e?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),Ke=_e?.quizGenTimeLimit??e.quizGenTimeLimit??0,qt=_e?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),pe=_e?.savingQuiz??e.savingQuiz??!1,qe=_e?.setSavingQuiz??e.setSavingQuiz??(()=>{}),Ze=_e?.quizGeneratorClassId??e.quizGeneratorClassId??null,Xe=e.classBatch??t,mt=Xe?.batchPicker??e.batchPicker??null,rt=Xe?.setBatchPicker??e.setBatchPicker??(()=>{}),It=Xe?.batchPickerLesson??e.batchPickerLesson??"",Gt=Xe?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),zs=Xe?.batchPickerDate??e.batchPickerDate??"",Wr=Xe?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),Ls=Xe?.batchPickerTargetClass??e.batchPickerTargetClass??"",qr=Xe?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),Gr=Xe?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Rs=e.studentNotificationsHook??t,Qr=Rs?.selectedNotificationForModal??e.selectedNotificationForModal??null,Jr=Rs?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return r.jsxs(f.Suspense,{fallback:null,children:[r.jsx(Vb,{show:i,onClose:()=>o(!1),lang:n,handleImportFile:a,importError:l,importSuccess:c,isImporting:d,downloadCSVTemplate:u}),r.jsx(Hb,{isCourseWizardOpen:rn,setIsCourseWizardOpen:Rn,lang:n,wizardStep:_n,setWizardStep:On,wizardIsSubmitting:on,wizardCourseTitle:Dn,setWizardCourseTitle:an,wizardCourseDescription:Mn,setWizardCourseDescription:$n,wizardCourseCategory:Fn,setWizardCourseCategory:Tt,wizardCourseTimeline:ln,setWizardCourseTimeline:Wt,wizardCourseContent:Bn,setWizardCourseContent:Un,addToast:m,wizardIsGeneratingOutline:Pt,handleGenerateOutline:cn,handleDeployWizardCourse:dn}),r.jsx(Wb,{isImportLessonsOpen:p,setIsImportLessonsOpen:h,lang:n,importStatus:x,setIsDraggingImport:g,handleCSVFileChange:b,handleImportFileChange:w,downloadCsvTemplate:y,downloadCourseTemplate:S,packagePreview:C,handlePackageImportSubmit:k,packageDuplicate:v,handlePackageDuplicateDismiss:N,isDraggingImport:O,previewImportData:D,setPreviewImportData:_,setImportStatus:T,importProgress:z,importProgressTotal:R,importErrorMsg:$,setImportErrorMsg:I,handleCSVImportSubmit:B}),r.jsx(qb,{isQuizGeneratorOpen:Vn,setIsQuizGeneratorOpen:Hn,lessons:H,quizGenMode:Wn,setQuizGenMode:qn,quizGenSelectedLessonId:Gn,setQuizGenSelectedLessonId:Qn,quizGenTopic:Jn,setQuizGenTopic:Kn,isGeneratingSuggestions:Yn,setIsGeneratingSuggestions:Zn,suggestedObjectives:Xn,setSuggestedObjectives:es,suggestedQuestions:ts,setSuggestedQuestions:ge,quizGenTimeLimit:Ke,setQuizGenTimeLimit:qt,savingQuiz:pe,setSavingQuiz:qe,quizGeneratorClassId:Ze,fetchClassDashboard:A}),r.jsx(Gb,{showProcessLogs:G,setShowProcessLogs:E,processLogsContent:W,t:s}),r.jsx(Qb,{isOpen:Y,onClose:()=>K(!1),vfsNodes:V,currentVfsParent:U,setCurrentVfsParent:j,cloudDrivePreviewNode:ne,setCloudDrivePreviewNode:fe}),r.jsx(Jb,{isSystemResourceLibraryOpen:je,setIsSystemResourceLibraryOpen:X,lang:n,systemResourceTab:me,setSystemResourceTab:ke,selectedLibraryResourceId:Se,setSelectedLibraryResourceId:M,vfsNodes:V,currentVfsParent:U,setCurrentVfsParent:j,cloudDrivePreviewNode:ne,setCloudDrivePreviewNode:fe,loadingLibraryResources:Z,libraryResources:ee,fetchLibraryResources:te}),r.jsx(Kb,{batchPicker:mt,setBatchPicker:rt,batchPickerLesson:It,setBatchPickerLesson:Ge=>Gt(typeof Ge=="function"?Ge(It):Ge),batchPickerDate:zs,setBatchPickerDate:Ge=>Wr(typeof Ge=="function"?Ge(zs):Ge),batchPickerTargetClass:Ls,setBatchPickerTargetClass:Ge=>qr(typeof Ge=="function"?Ge(Ls):Ge),lessons:H,classes:ce,expandedClassId:oe,confirmBatchPicker:Gr,lang:n}),r.jsx(Yb,{isExportWeightModalOpen:xe,setIsExportWeightModalOpen:ie,lang:n,quizzesWeight:Pe,setQuizzesWeight:ze,assignmentsWeight:ue,setAssignmentsWeight:re,handleQuizzesWeightChange:P,handleAssignmentsWeightChange:L,customCategoryOverrides:F,setCustomCategoryOverrides:q,classDashboardMap:J,exportClassId:be,exportClassName:se,csvPreviewData:ye,handleExportGrades:$e}),r.jsx(Zb,{notification:Qr,onClose:()=>Jr(null),lang:n,onOpenWorkspace:Ge=>{Fe(Ge),Ce("assignment"),We({}),He("quiz")}}),r.jsx(Xb,{isOpen:Et,onClose:()=>et(!1),lang:n,onSeedSuccess:jt,onJumpTab:Ge=>Vt(Ge)}),Ln&&r.jsx(e0,{onClose:()=>Ht(!1),lang:n})]})}const n0="openlearn_live_classroom_sync";class yd{constructor(t=n0,n,s){this.channel=null,this.isDestroyed=!1,this.messageListeners=[],this.lessonId=null,this.classId=null,this.socketBoundTo=null,this.offSocketReady=null,this.handleRemoteSync=i=>{this.isDestroyed||!i?.message||this.lessonId&&i.lessonId&&i.lessonId!==this.lessonId||this.emitToListeners(i.message)},this.lessonId=n||null,this.classId=s||null,typeof window<"u"&&typeof window.BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(t),this.channel.onmessage=i=>{this.isDestroyed||!i.data||this.emitToListeners(i.data)}),this.offSocketReady=Yo(()=>this.ensureSocketBound())}ensureSocketBound(){if(this.isDestroyed)return;const t=lt();!t||t===this.socketBoundTo||(this.unbindSocket(),t.on("classroom:sync_message",this.handleRemoteSync),this.socketBoundTo=t)}unbindSocket(){this.socketBoundTo&&(this.socketBoundTo.off("classroom:sync_message",this.handleRemoteSync),this.socketBoundTo=null)}setLessonContext(t,n){this.lessonId=t,n!==void 0&&(this.classId=n)}emitToListeners(t){this.messageListeners.forEach(n=>{try{n(t)}catch(s){console.error("[ClassroomSyncChannel] Listener error:",s)}})}onMessage(t){return this.ensureSocketBound(),this.messageListeners.push(t),()=>{this.messageListeners=this.messageListeners.filter(n=>n!==t)}}postMessage(t){if(this.isDestroyed)return;if(this.ensureSocketBound(),this.channel)try{this.channel.postMessage(t)}catch(s){console.warn("[ClassroomSyncChannel] Failed to post message to BroadcastChannel:",s)}const n=lt();if(n&&this.lessonId)try{n.emit("teacher-sync-message",{lessonId:this.lessonId,message:t})}catch(s){console.warn("[ClassroomSyncChannel] Failed to emit socket sync message:",s)}}broadcastChangeLesson(t){this.lessonId=t,this.postMessage({type:"TEACHER_CHANGE_LESSON",payload:{lessonId:t,classId:this.classId}});const n=lt();n&&t&&n.emit("teacher-broadcast-lesson",{lessonId:t,classId:this.classId})}broadcastChangeSegment(t){this.postMessage({type:"TEACHER_CHANGE_SEGMENT",payload:{segmentId:t,lessonId:this.lessonId}});const n=lt();n&&this.lessonId&&t&&n.emit("teacher-broadcast-segment",{lessonId:this.lessonId,activeSegmentId:t})}broadcastChangeTab(t){this.postMessage({type:"TEACHER_CHANGE_TAB",payload:{tab:t,lessonId:this.lessonId}});const n=lt();n&&this.lessonId&&n.emit("teacher-broadcast-tab",{lessonId:this.lessonId,tab:t})}broadcastLockClass(t){this.postMessage({type:"TEACHER_LOCK_CLASS",payload:{locked:t,lessonId:this.lessonId,classId:this.classId}});const n=lt();n&&this.lessonId&&n.emit("teacher-broadcast-lock",{lessonId:this.lessonId,locked:t,classId:this.classId})}broadcastPickStudent(t,n){this.postMessage({type:"TEACHER_PICK_STUDENT",payload:{studentId:t,studentName:n}});const s=lt();s&&s.emit("teacher-pick-student",{studentId:t,studentName:n,lessonId:this.lessonId,classId:this.classId})}broadcastSyncTimer(t,n){this.postMessage({type:"TEACHER_SYNC_TIMER",payload:{timeRemaining:t,isRunning:n,lessonId:this.lessonId}})}broadcastCountdown(t){this.postMessage({type:"TEACHER_BROADCAST_COUNTDOWN",payload:t}),this.broadcastSyncTimer(t.timeRemaining,t.isRunning)}broadcastPingStudent(t,n){this.postMessage({type:"TEACHER_PING_STUDENT",payload:{studentId:t,message:n}});const s=lt();s&&this.lessonId&&s.emit("teacher-ping-student",{studentId:t,lessonId:this.lessonId,message:n})}broadcastFullscreen(t,n){const s=n||this.lessonId||void 0;this.postMessage({type:"TEACHER_BROADCAST_FULLSCREEN",payload:{elementId:t,lessonId:s}});const i=lt();i&&s&&i.emit("teacher-broadcast-fullscreen",{elementId:t,lessonId:s,classId:this.classId})}acknowledgePick(t){this.postMessage({type:"STUDENT_ACKNOWLEDGE_PICK",payload:{studentId:t}});const n=lt();n&&n.emit("student-acknowledge-pick",{studentId:t,lessonId:this.lessonId})}sendHeartbeat(t){this.postMessage({type:"STUDENT_HEARTBEAT",payload:{studentId:t,timestamp:Date.now()}})}destroy(){this.isDestroyed=!0,this.messageListeners=[],this.offSocketReady?.(),this.offSocketReady=null,this.unbindSocket(),this.channel&&(this.channel.close(),this.channel=null)}}async function s0(e){const t=await fetch(`/api/students/${e}/read_notifications`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function r0(e,t){await fetch(`/api/students/${e}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:t})})}async function i0(e,t){await fetch(`/api/students/${e}/progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function o0(e,t){const n=await fetch(`/api/classes/${e}/lessons/${t}/progress`);return n.ok?{ok:!0,data:await n.json()}:{ok:!1}}async function a0(e){const t=await fetch(`/api/students/${e}/progress`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}function l0(e,t,n=typeof window<"u"?window:null){const s=f.useRef(t);s.current=t,f.useEffect(()=>{if(!n)return;const i=o=>{const a=o;s.current?.(a.detail,a)};return n.addEventListener(e,i),()=>{n.removeEventListener(e,i)}},[e,n])}function c0(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const t=new e,n=t.currentTime,s=t.createOscillator(),i=t.createGain();s.type="sine",s.frequency.setValueAtTime(587.33,n),s.frequency.exponentialRampToValueAtTime(880,n+.3),i.gain.setValueAtTime(.25,n),i.gain.exponentialRampToValueAtTime(.001,n+.8),s.connect(i),i.connect(t.destination),s.start(n),s.stop(n+.8)}catch{}}function d0({lessonId:e,lang:t="zh",syncChannel:n}){const[s,i]=f.useState(null),[o,a]=f.useState(!1),[l,c]=f.useState(!0),[d,u]=f.useState(!1),m=f.useRef(s);m.current=s,f.useEffect(()=>{if(!e)return;let y=null,S;try{y=n||new yd,S=y.onMessage(N=>{N.type==="TEACHER_BROADCAST_COUNTDOWN"?i(N.payload):N.type==="TEACHER_SYNC_TIMER"&&i(O=>O?{...O,timeRemaining:N.payload.timeRemaining,isRunning:N.payload.isRunning,endsAt:N.payload.isRunning?Date.now()+N.payload.timeRemaining*1e3:null}:{lessonId:e,totalDuration:Math.max(300,N.payload.timeRemaining),timeRemaining:N.payload.timeRemaining,isRunning:N.payload.isRunning,isPaused:!1,label:t==="zh"?"⏱️ 课堂限时任务":"⏱️ Timed Task",endsAt:N.payload.isRunning?Date.now()+N.payload.timeRemaining*1e3:null,updatedAt:Date.now()})})}catch{}(async()=>{try{const N=await fetch(`/api/classroom/sessions/${e}/countdown`);if(N.ok){const O=await N.json();O.success&&O.countdown&&i(O.countdown)}}catch{}})();let k=null;const v=Yo(N=>{const O=D=>{!D||D.lessonId&&D.lessonId!==e||i(D)};k?.(),N.on("classroom:countdown_updated",O),k=()=>N.off("classroom:countdown_updated",O)});return()=>{S?.(),v(),k?.(),!n&&typeof y?.destroy=="function"&&y.destroy()}},[e,t]),l0("openlearn:countdown:updated",y=>{y&&i(y)});const p=f.useRef(null);if(f.useEffect(()=>{!s?.isRunning||!s.endsAt||p.current!==s.endsAt&&(p.current=s.endsAt,u(!1))},[s?.isRunning,s?.endsAt]),f.useEffect(()=>{if(!s||!s.isRunning||!s.endsAt)return;const y=setInterval(()=>{const S=m.current;if(!S||!S.isRunning||!S.endsAt)return;const C=Date.now(),k=Math.max(0,Math.round((S.endsAt-C)/1e3));if(k!==S.timeRemaining){const v={...S,timeRemaining:k,updatedAt:C};k<=0&&(v.isRunning=!1,v.isPaused=!1,v.endsAt=null,l&&!d&&(c0(),u(!0))),i(v);try{window.dispatchEvent(new CustomEvent("openlearn:student:countdown_tick",{detail:{timeRemaining:k,totalDuration:S.totalDuration,label:S.label}}))}catch{}}},500);return()=>clearInterval(y)},[s?.isRunning,s?.endsAt,l,d]),!s||s.timeRemaining===0&&!s.isRunning&&!d)return null;const h=y=>{const S=Math.floor(y/60),C=y%60,k=v=>v.toString().padStart(2,"0");return`${k(S)}:${k(C)}`},x=s.totalDuration>0?Math.min(100,Math.max(0,s.timeRemaining/s.totalDuration*100)):0,g=s.timeRemaining>0&&s.timeRemaining<=60,b=s.timeRemaining>60&&s.timeRemaining<=180,w=s.timeRemaining===0;return r.jsx("aside",{id:"student-classroom-countdown-banner","aria-label":t==="zh"?"课堂倒计时通知":"Classroom Countdown Alert",className:`fixed top-4 right-6 z-50 transition-all duration-300 select-none ${o?"w-auto":"w-72 sm:w-80"}`,children:r.jsxs("div",{className:`bg-surface/95 backdrop-blur-md border rounded-2xl shadow-2xl p-3 flex flex-col gap-2 transition-all ${g?"border-rose-500/80 shadow-rose-500/20":b?"border-amber-500/80 shadow-amber-500/20":w?"border-emerald-500/80 shadow-emerald-500/20":"border-theme shadow-primary-theme/10"}`,children:[r.jsxs("div",{className:"flex items-center justify-between gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx("span",{className:`p-1 rounded-lg text-white shrink-0 ${g?"bg-rose-500 animate-pulse":b?"bg-amber-500":w?"bg-emerald-500":"bg-primary-theme"}`,children:r.jsx(Es,{size:12,className:s.isRunning?"animate-spin":"",style:{animationDuration:"6s"}})}),r.jsx("span",{className:"text-xs font-bold text-main truncate",children:s.label||(t==="zh"?"课堂任务":"Task")})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{type:"button",onClick:()=>c(!l),className:"p-1 rounded-md text-muted hover:text-main text-xs transition-colors cursor-pointer",title:l?"提示音已开启":"提示音已静音",children:l?r.jsx(eg,{size:12}):r.jsx(tg,{size:12})}),r.jsx("button",{type:"button",onClick:()=>a(!o),className:"p-1 rounded-md text-muted hover:text-main text-xs transition-colors cursor-pointer",title:o?"展开":"收起",children:o?r.jsx(Nn,{size:12}):r.jsx(ng,{size:12})})]})]}),!o&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-baseline justify-between px-1",children:[r.jsx("span",{id:"student-countdown-digits",className:`text-2xl font-black font-mono tracking-widest ${g?"text-rose-500 animate-pulse":b?"text-amber-500":w?"text-emerald-500":"text-primary-theme"}`,children:h(s.timeRemaining)}),r.jsx("span",{className:"text-[11px] font-semibold text-muted",children:w?t==="zh"?"🎉 时间已截止!":"Time is up!":s.isPaused?t==="zh"?"⏸️ 老师已暂停计时":"Paused":t==="zh"?"与全班同步中":"Synced"})]}),r.jsx("div",{className:"w-full h-1.5 bg-surface-secondary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full transition-all duration-500 ${g?"bg-rose-500":b?"bg-amber-500":w?"bg-emerald-500":"bg-primary-theme"}`,style:{width:`${x}%`}})}),r.jsx(Me,{slot:"student.classroom.countdown",slotProps:{countdown:s,lang:t}})]})]})})}const u0=({isOpen:e,onClose:t,lessonId:n,studentName:s="我",lang:i="zh",coreQuestion:o,challengeQuestion:a,onSubmitSuccess:l})=>{const[c,d]=f.useState(null),[u,m]=f.useState(!1),[p,h]=f.useState(null),x=!!o,g=x&&!!a,[b,w]=f.useState(null),[y,S]=f.useState(5),[C,k]=f.useState(""),[v,N]=f.useState(""),[O,D]=f.useState(!1),[_,T]=f.useState(!1),z=()=>{if(!c||!o)return;const I=c===o.correctOption;h(I),m(!0)},R=async()=>{if(O)return;D(!0);const I=x?p?b?"challenge_done":"passed":"remediation":null;try{n&&await fetch(`/api/classroom/sessions/${n}/exit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:y,puzzledConcept:C.trim(),feedback:v.trim(),...x?{coreAnswer:c,isCorrect:p,tierLevel:I,challengeAnswer:b}:{}})}),T(!0),l?.()}catch{T(!0),l?.()}finally{D(!1)}},$=()=>{l?.(),t()};return e?r.jsx("div",{"data-testid":"adaptive-exit-ticket-modal",className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-fade-in select-none",children:r.jsxs("div",{className:"bg-surface rounded-3xl border border-indigo-500/40 p-6 w-full max-w-lg shadow-2xl flex flex-col gap-4 max-h-[92vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/80 pb-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-indigo-500 font-extrabold text-base",children:[r.jsx(at,{size:20}),r.jsx("span",{children:i==="zh"?"60 秒自适应结课通票 (Adaptive Exit Ticket)":"60s Adaptive Exit Ticket"})]}),r.jsx("button",{onClick:$,className:"text-muted hover:text-main rounded-lg p-1 cursor-pointer","aria-label":"Close",children:r.jsx(Oe,{size:18})})]}),_?r.jsxs("div",{className:"py-8 flex flex-col items-center justify-center text-center gap-3",children:[r.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 flex items-center justify-center",children:r.jsx(at,{size:32})}),r.jsx("h3",{className:"text-base font-black text-main",children:i==="zh"?"结课通票提交成功!":"Exit Ticket Submitted!"}),r.jsx("p",{className:"text-xs text-muted max-w-xs",children:i==="zh"?"你的学情反馈与梯级作答已实时同步至教师大屏与个人课后学情卡。":"Feedback synced to classroom dashboard."}),r.jsx("button",{onClick:$,className:"mt-2 px-6 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs transition-colors cursor-pointer",children:i==="zh"?"完成":"Done"})]}):r.jsxs("div",{className:"flex flex-col gap-4 text-xs",children:[o&&r.jsxs("div",{className:"bg-surface-secondary/70 p-4 rounded-2xl border border-border/60 flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"font-extrabold text-main flex items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"px-2 py-0.5 rounded bg-indigo-500 text-white font-mono text-[10px]",children:"必做诊断"}),r.jsx("span",{children:"1. 核心概念过关题"})]}),u&&r.jsx("span",{className:`text-2xs font-bold px-2 py-0.5 rounded-full ${p?"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300":"bg-rose-100 text-rose-700 dark:bg-rose-950 dark:text-rose-300"}`,children:p?"✓ 概念通关":"需巩固"})]}),r.jsx("p",{className:"text-main font-semibold leading-relaxed",children:o.question}),r.jsx("div",{className:"space-y-1.5",children:o.options.map(I=>r.jsxs("button",{type:"button",disabled:u,onClick:()=>d(I.key),className:`w-full p-2.5 rounded-xl border text-left flex items-start gap-2.5 transition-all cursor-pointer ${c===I.key?"border-indigo-500 bg-indigo-50/50 dark:bg-indigo-950/40 font-bold text-indigo-700 dark:text-indigo-300":"border-border/60 hover:bg-surface text-main"} ${u?"cursor-default opacity-90":""}`,children:[r.jsx("span",{className:"w-5 h-5 rounded-full bg-surface-secondary border border-border flex items-center justify-center text-[10px] font-mono shrink-0",children:I.key}),r.jsx("span",{className:"text-2xs leading-relaxed",children:I.text})]},I.key))}),!u&&r.jsxs("button",{type:"button",disabled:!c,onClick:z,className:`mt-1 py-1.5 px-3 rounded-xl font-bold text-2xs transition-colors flex items-center justify-center gap-1 ${c?"bg-indigo-600 hover:bg-indigo-700 text-white cursor-pointer shadow-xs":"bg-surface-secondary text-muted cursor-not-allowed"}`,children:[r.jsx("span",{children:"确认本题答案"}),r.jsx(Cn,{size:12})]}),u&&p&&g&&a&&r.jsxs("div",{"data-testid":"challenge-branch",className:"mt-2 p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-800 dark:text-emerald-200 space-y-2 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-2xs",children:[r.jsx(yt,{size:14,className:"text-emerald-600 dark:text-emerald-400"}),r.jsx("span",{children:"太棒了!已解锁【Lv.2 进阶探究挑战题】(冲刺思维勋章)"})]}),r.jsx("p",{className:"text-2xs font-semibold text-main",children:a.prompt}),r.jsx("div",{className:"grid grid-cols-1 gap-1",children:a.options.map(I=>r.jsxs("button",{type:"button",onClick:()=>w(I.key),className:`p-2 rounded-lg border text-left text-2xs transition-colors ${b===I.key?"border-emerald-500 bg-emerald-100/60 dark:bg-emerald-950 font-bold text-emerald-800 dark:text-emerald-200":"border-emerald-500/20 bg-surface text-main hover:bg-surface-secondary"}`,children:[r.jsxs("span",{className:"font-mono font-bold mr-1.5",children:[I.key,"."]}),r.jsx("span",{children:I.text})]},I.key))})]}),u&&!p&&r.jsxs("div",{"data-testid":"scaffold-branch",className:"mt-2 p-3 rounded-xl bg-amber-500/10 border border-amber-500/30 text-amber-800 dark:text-amber-200 space-y-1.5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-2xs text-amber-600 dark:text-amber-400",children:[r.jsx(Rr,{size:14}),r.jsx("span",{children:"核心概念支架提示卡"})]}),r.jsx("p",{className:"text-2xs leading-relaxed",children:o.scaffoldHint}),r.jsxs("p",{className:"text-3xs text-muted",children:["解析:",o.explanation]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"2. 今日课堂综合掌握感评估":"Rate Today Lesson"}),r.jsxs("div",{className:"flex items-center gap-2",children:[[1,2,3,4,5].map(I=>r.jsx("button",{type:"button",onClick:()=>S(I),"aria-label":`${I} 星`,"aria-pressed":I===y,className:"p-0.5 text-xl transition-transform hover:scale-125 cursor-pointer",children:r.jsx(vr,{size:20,className:I<=y?"text-amber-400 fill-amber-400":"text-slate-300"})},I)),r.jsxs("span",{className:"text-2xs font-bold text-amber-700 dark:text-amber-400 font-mono ml-1",children:[y,".0 星"]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"3. 今天最困惑或没完全搞懂的知识点/卡点是什么?":"Most Confused Concept"}),r.jsx("input",{type:"text",value:C,onChange:I=>k(I.target.value),placeholder:i==="zh"?"用几个关键词概括本节课的卡点...":"e.g. friction boundary...",className:"w-full px-3 py-2 bg-surface-secondary border border-border rounded-xl text-xs text-main focus:outline-hidden focus:ring-2 focus:ring-indigo-500"})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"4. 给老师的一句小建议 (选填)":"Feedback (Optional)"}),r.jsx("input",{type:"text",value:v,onChange:I=>N(I.target.value),placeholder:i==="zh"?"例如:希望能补充一道微元积分经典例题...":"Feedback...",className:"w-full px-3 py-1.5 bg-surface-secondary border border-border rounded-xl text-xs text-main focus:outline-hidden focus:ring-2 focus:ring-indigo-500"})]}),r.jsx("button",{type:"button",disabled:O,onClick:R,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white font-extrabold rounded-xl transition-colors cursor-pointer shadow-md text-xs flex items-center justify-center gap-1.5",children:r.jsx("span",{children:O?i==="zh"?"正在提交...":"Submitting...":i==="zh"?"提交自适应结课通票":"Submit Exit Ticket"})})]})]})}):null};class ro extends Error{constructor(t,n){super(n),this.name="ApiError",this.status=t}}async function Te(e,t={}){const n=await fetch(e,{credentials:"same-origin",...t,headers:{...t.body?{"Content-Type":"application/json"}:{},...t.headers??{}}}),s=await n.text();let i=null;try{i=s?JSON.parse(s):null}catch{i=null}if(!n.ok)throw new ro(n.status,i?.error||`HTTP ${n.status}`);return i}const Ot={listQuestionTypes:()=>Te("/api/assessment-question-types"),list:(e={})=>{const t=new URLSearchParams;e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status);const n=t.toString();return Te(`/api/assessments${n?`?${n}`:""}`)},get:e=>Te(`/api/assessments/${encodeURIComponent(e)}`),create:e=>Te("/api/assessments",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>Te(`/api/assessments/${encodeURIComponent(e)}`,{method:"DELETE"}),replaceItems:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}/items`,{method:"PUT",body:JSON.stringify({items:t})}),listBank:e=>Te(`/api/question-bank${e?`?type=${encodeURIComponent(e)}`:""}`),createBankItem:e=>Te("/api/question-bank",{method:"POST",body:JSON.stringify(e)}),removeBankItem:e=>Te(`/api/question-bank/${encodeURIComponent(e)}`,{method:"DELETE"}),getAssignments:e=>Te(`/api/assessments/${encodeURIComponent(e)}/assignments`),getTeacherView:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/teacher-view`),publish:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}/publish`,{method:"POST",body:JSON.stringify(t)}),closeAssignment:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/close`,{method:"POST"}),releaseScores:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/release`,{method:"POST"}),syncGradebook:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/sync-gradebook`,{method:"POST"}),getAssignmentProgress:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/progress`),listAttempts:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/attempts`),stats:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/stats`),gradeAnswer:(e,t,n)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/grade`,{method:"PUT",body:JSON.stringify(n)}),aiSuggestGrade:(e,t)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/ai-suggest`,{method:"POST"}),regrade:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/regrade`,{method:"POST"}),exportCsvUrl:e=>`/api/assessment-assignments/${encodeURIComponent(e)}/export?format=csv`,startClassroomAssessment:(e,t)=>Te(`/api/classroom/sessions/${encodeURIComponent(e)}/assessment`,{method:"POST",body:JSON.stringify(t)}),getClassroomAssessmentProgress:(e,t)=>Te(`/api/classroom/sessions/${encodeURIComponent(e)}/assessment-progress${t?`?assignmentId=${encodeURIComponent(t)}`:""}`),myAssessments:()=>Te("/api/me/assessments"),startAttempt:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/attempts`,{method:"POST"}),reportProctor:(e,t)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/proctor`,{method:"PUT",body:JSON.stringify(t)}),saveAnswer:(e,t,n)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({answer:n})}),submitAttempt:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/submit`,{method:"POST"}),attemptResult:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/result`)};class h0{constructor(){this.store=St(()=>({items:new Map}))}register(t,n){if(!t?.type||typeof t.type!="string"||!t.type.trim())throw new Error("[AssessmentQuestionTypeUiRegistry] type is required");if(typeof t.Editor!="function")throw new Error(`[AssessmentQuestionTypeUiRegistry] ${t.type}: Editor must be a component`);const s=t.type.trim();if(this.store.getState().items.has(s))throw new Error(`[AssessmentQuestionTypeUiRegistry] duplicate question type: ${s}`);this.store.setState(i=>{const o=new Map(i.items);return o.set(s,{config:{...t,type:s},pluginId:n||s}),{items:o}})}unregister(t,n){const s=this.store.getState().items.get(t);return!s||n!==void 0&&s.pluginId!==n?!1:(this.store.setState(i=>{const o=new Map(i.items);return o.delete(t),{items:o}}),!0)}clearOwned(t){const n=this.store.getState(),s=[...n.items.entries()].filter(([,i])=>i.pluginId===t);return s.length===0?0:(this.store.setState(()=>{const i=new Map(n.items);for(const[o]of s)i.delete(o);return{items:i}}),s.length)}get(t){return this.store.getState().items.get(t)?.config}list(){return[...this.store.getState().items.values()].map(t=>t.config)}subscribe(t){return this.store.subscribe(t)}getSnapshot(){return this.list()}}const kt=new h0,ks="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function f0(e){const t=e.options;return Array.isArray(t)?t.map(n=>String(n)):[]}function Cr({htmlFor:e,children:t}){return r.jsx("label",{htmlFor:e,className:"block text-xs font-semibold text-muted mb-1",children:t})}function wd({config:e,answerKey:t,onChange:n,lang:s,disabled:i,multiple:o,idPrefix:a}){const l=f0(e),c=o?Array.isArray(t?.indexes)?t.indexes.map(Number).filter(p=>Number.isInteger(p)):[]:typeof t?.index=="number"?[t.index]:[],d=p=>n({config:{...e,options:p},answerKey:t}),u=(p,h)=>{if(o){const x=h?[...new Set([...c,p])].sort((g,b)=>g-b):c.filter(g=>g!==p);n({config:e,answerKey:x.length>0?{indexes:x}:null})}else n({config:e,answerKey:{index:p}})},m=p=>String.fromCharCode(65+p);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("fieldset",{className:"space-y-1.5",children:[r.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:s==="zh"?"选项与正确答案":"Options & correct answer"}),l.map((p,h)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:o?"checkbox":"radio",id:`${a}-opt-${h}`,name:`${a}-answer`,checked:c.includes(h),disabled:i,onChange:x=>u(h,x.target.checked),"aria-label":`${s==="zh"?"把选项":"Mark option"} ${m(h)} ${s==="zh"?"标为正确答案":"as correct"}`,className:"shrink-0 accent-indigo-600"}),r.jsx("label",{htmlFor:`${a}-opt-${h}`,className:"sr-only",children:s==="zh"?`选项 ${m(h)}`:`Option ${m(h)}`}),r.jsx("span",{className:"text-xs font-bold text-muted w-4 shrink-0",children:m(h)}),r.jsx("input",{type:"text",value:p,disabled:i,"aria-label":s==="zh"?`选项 ${m(h)} 内容`:`Option ${m(h)} text`,onChange:x=>{const g=[...l];g[h]=x.target.value,d(g)},className:ks}),r.jsx("button",{type:"button",disabled:i||l.length<=2,onClick:()=>{const x=l.filter((g,b)=>b!==h);d(x),n({config:{...e,options:x},answerKey:null})},"aria-label":s==="zh"?`删除选项 ${m(h)}`:`Delete option ${m(h)}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 disabled:opacity-40 cursor-pointer shrink-0",children:r.jsx(_r,{size:13})})]},h))]}),r.jsxs("button",{type:"button",disabled:i,onClick:()=>d([...l,s==="zh"?`选项 ${m(l.length)}`:`Option ${m(l.length)}`]),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[r.jsx(Bo,{size:12}),s==="zh"?"添加选项":"Add option"]}),c.length===0&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"未设置正确答案:该题交卷后进入人工批改。":"No correct answer set: this item will need manual grading."})]})}const m0=e=>r.jsx(wd,{...e,multiple:!1,idPrefix:`sc-${e.lang}`}),p0=e=>r.jsx(wd,{...e,multiple:!0,idPrefix:`mc-${e.lang}`}),g0=({config:e,answerKey:t,onChange:n,lang:s,disabled:i})=>{const o=t?.value;return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:s==="zh"?"正确答案":"Correct answer"}),r.jsx("div",{className:"flex items-center gap-4",children:[{value:!0,label:String(e.trueLabel??(s==="zh"?"正确":"True"))},{value:!1,label:String(e.falseLabel??(s==="zh"?"错误":"False"))}].map(a=>r.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-main",children:[r.jsx("input",{type:"radio",name:`tf-${s}`,checked:o===a.value,disabled:i,onChange:()=>n({config:e,answerKey:{value:a.value}}),className:"accent-indigo-600"}),a.label]},String(a.value)))}),o===void 0&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"未设置正确答案:该题交卷后进入人工批改。":"No correct answer set."})]})};function x0(e){const t=e.blanks;return Array.isArray(t)?t:[]}function b0(e,t){const n=e?.blanks,s=[];for(let i=0;i<t;i++){const o=Array.isArray(n)?n[i]:void 0;s.push(Array.isArray(o)?o.join(" | "):"")}return s}const y0=({config:e,answerKey:t,onChange:n,lang:s,disabled:i})=>{const o=x0(e),a=b0(t,o.length),l=(c,d)=>{const u=d.map(h=>h.split("|").map(x=>x.trim()).filter(Boolean)),m=u.some(h=>h.length>0),p=c.map((h,x)=>u[x]??[]);n({config:{...e,blanks:c},answerKey:m&&p.every(h=>h.length>0)?{blanks:p}:null})};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs text-muted",children:s==="zh"?"每个空一行;可接受答案用 | 分隔(任一命中即得分)。数值空按数值比较。":"One blank per row; separate accepted answers with |. Numeric blanks compare by value."}),o.map((c,d)=>r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_1fr_auto] gap-2 items-center",children:[r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:`fb-accepted-${c.id}`,children:s==="zh"?`第 ${d+1} 空的可接受答案`:`Accepted answers for blank ${d+1}`}),r.jsx("input",{id:`fb-accepted-${c.id}`,type:"text",value:a[d]??"",disabled:i,onChange:u=>{const m=[...a];m[d]=u.target.value,l(o,m)},placeholder:s==="zh"?"光合作用 | photosynthesis":"photosynthesis",className:ks})]}),r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:`fb-type-${c.id}`,children:s==="zh"?"作答类型":"Answer type"}),r.jsxs("select",{id:`fb-type-${c.id}`,value:c.inputType??"text",disabled:i,onChange:u=>{const m=o.map((p,h)=>h===d?{...p,inputType:u.target.value}:p);l(m,a)},className:ks,children:[r.jsx("option",{value:"text",children:s==="zh"?"文本":"Text"}),r.jsx("option",{value:"numeric",children:s==="zh"?"数值":"Numeric"})]})]}),r.jsx("button",{type:"button",disabled:i||o.length<=1,onClick:()=>{const u=o.filter((m,p)=>p!==d);l(u,a.filter((m,p)=>p!==d))},"aria-label":s==="zh"?`删除第 ${d+1} 空`:`Delete blank ${d+1}`,className:"p-1 mt-4 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 disabled:opacity-40 cursor-pointer justify-self-start",children:r.jsx(_r,{size:13})})]},c.id)),r.jsxs("button",{type:"button",disabled:i,onClick:()=>{const c=`b${o.length+1}-${Date.now().toString(36)}`;l([...o,{id:c,inputType:"text"}],[...a,""])},className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[r.jsx(Bo,{size:12}),s==="zh"?"添加空位":"Add blank"]}),!t&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"每个空都填了可接受答案后才会启用自动判分。":"Fill every blank to enable auto-grading."})]})},w0=({config:e,onChange:t,lang:n,disabled:s})=>r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:"sa-placeholder",children:n==="zh"?"作答占位提示":"Placeholder"}),r.jsx("input",{id:"sa-placeholder",type:"text",value:String(e.placeholder??""),disabled:s,onChange:i=>t({config:{...e,placeholder:i.target.value},answerKey:null}),className:ks})]}),r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:"sa-maxlength",children:n==="zh"?"最多字数":"Max length"}),r.jsx("input",{id:"sa-maxlength",type:"number",min:1,value:Number(e.maxLength??2e3),disabled:s,onChange:i=>t({config:{...e,maxLength:Number(i.target.value)||2e3},answerKey:null}),className:ks})]}),r.jsx("p",{className:"col-span-2 text-xs text-muted",children:n==="zh"?"简答题不自动判分,交卷后进入人工批改队列。":"Short answers are always graded manually."})]}),ea="w-full px-3 py-2 border border-theme rounded-xl text-sm bg-surface text-main focus:outline-none focus:ring-2 focus:ring-indigo-500";function v0(e){const t=e.options;return Array.isArray(t)?t.map(n=>String(n)):[]}function S0(e){return String.fromCharCode(65+e)}const vd=({config:e,value:t,onChange:n,lang:s,readOnly:i,multiple:o,name:a})=>{const l=v0(e),c=typeof t=="number"?t:null,d=Array.isArray(t)?t.map(Number).filter(u=>Number.isInteger(u)):[];return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"sr-only",children:o?s==="zh"?"可多选":"Select all that apply":s==="zh"?"单选":"Pick one"}),l.map((u,m)=>{const p=o?d.includes(m):c===m;return r.jsxs("label",{className:`flex items-start gap-2.5 px-3 py-2 rounded-xl border cursor-pointer transition-colors ${p?"border-indigo-400 bg-indigo-50 text-main dark:bg-indigo-950/40":"border-theme bg-surface text-main hover:border-indigo-300"} ${i?"cursor-default":""}`,children:[r.jsx("input",{type:o?"checkbox":"radio",name:a,checked:p,disabled:i,onChange:h=>{if(!i)if(o){const x=h.target.checked?[...new Set([...d,m])].sort((g,b)=>g-b):d.filter(g=>g!==m);n(x)}else n(m)},className:"mt-0.5 accent-indigo-600 shrink-0"}),r.jsxs("span",{className:"text-sm leading-snug",children:[r.jsxs("span",{className:"font-bold text-muted mr-1.5",children:[S0(m),"."]}),u]})]},m)}),r.jsx("p",{className:"text-2xs text-muted",children:o?s==="zh"?"可多选:全对得满分,少选按命中比例给分,错选不得分。":"Select all: full marks for all correct, partial credit for fewer, zero for wrong picks.":s==="zh"?"单选题":"Single choice"})]})},j0=e=>r.jsx(vd,{...e,multiple:!1,name:"answer-single"}),k0=e=>r.jsx(vd,{...e,multiple:!0,name:"answer-multi"}),C0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=[{v:!0,label:String(e.trueLabel??(s==="zh"?"正确":"True"))},{v:!1,label:String(e.falseLabel??(s==="zh"?"错误":"False"))}];return r.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[r.jsx("legend",{className:"sr-only",children:s==="zh"?"判断":"True or false"}),o.map(a=>r.jsxs("label",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-xl border text-sm cursor-pointer ${t===a.v?"border-indigo-400 bg-indigo-50 text-main dark:bg-indigo-950/40":"border-theme bg-surface text-main hover:border-indigo-300"}`,children:[r.jsx("input",{type:"radio",name:"answer-tf",checked:t===a.v,disabled:i,onChange:()=>!i&&n(a.v),className:"accent-indigo-600"}),a.label]},String(a.v)))]})},N0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=Array.isArray(e.blanks)?e.blanks:[],a=Array.isArray(t)?t:o.map(()=>"");return r.jsx("div",{className:"space-y-2",children:o.map((l,c)=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`blank-${l.id}`,className:"block text-2xs font-semibold text-muted mb-1",children:s==="zh"?`第 ${c+1} 空`:`Blank ${c+1}`}),r.jsx("input",{id:`blank-${l.id}`,type:l.inputType==="numeric"?"number":"text",value:String(a[c]??""),disabled:i,placeholder:l.placeholder,onChange:d=>{const u=o.map((m,p)=>p===c?d.target.value:String(a[p]??""));n(u)},className:ea})]},l.id))})},E0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=typeof e.maxLength=="number"?e.maxLength:2e3,a=typeof t=="string"?t:"";return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"short-answer",className:"sr-only",children:s==="zh"?"作答内容":"Your answer"}),r.jsx("textarea",{id:"short-answer",rows:6,value:a,maxLength:o,disabled:i,placeholder:String(e.placeholder??(s==="zh"?"请输入你的作答":"Type your answer")),onChange:l=>n(l.target.value),className:`${ea} resize-y`}),r.jsxs("p",{className:"text-2xs text-muted mt-1 text-right",children:[a.length,"/",o]})]})},T0=({value:e,onChange:t,lang:n,readOnly:s})=>{const[i,o]=De.useState(()=>{try{return e==null?"":JSON.stringify(e)}catch{return""}});return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fallback-answer",className:"block text-2xs font-semibold text-muted mb-1",children:n==="zh"?"作答(JSON)":"Answer (JSON)"}),r.jsx("textarea",{id:"fallback-answer",rows:4,value:i,disabled:s,onChange:a=>{o(a.target.value);try{t(a.target.value.trim()?JSON.parse(a.target.value):null)}catch{t(a.target.value)}},className:`${ea} resize-y font-mono`})]})},ll=["选项 A","选项 B","选项 C","选项 D"];let cl=!1;function P0(){cl||(cl=!0,kt.register({type:"single_choice",label:{zh:"单选题",en:"Single choice"},category:"objective",supports:["quiz","exam","survey"],Editor:m0,Answer:j0,createDefaultConfig:()=>({options:[...ll]}),createDefaultAnswerKey:()=>({index:0})}),kt.register({type:"multiple_choice",label:{zh:"多选题",en:"Multiple choice"},category:"objective",supports:["quiz","exam","survey"],Editor:p0,Answer:k0,createDefaultConfig:()=>({options:[...ll]}),createDefaultAnswerKey:()=>({indexes:[0]})}),kt.register({type:"true_false",label:{zh:"判断题",en:"True / false"},category:"objective",supports:["quiz","exam","survey"],Editor:g0,Answer:C0,createDefaultConfig:()=>({trueLabel:"正确",falseLabel:"错误"}),createDefaultAnswerKey:()=>({value:!0})}),kt.register({type:"fill_blank",label:{zh:"填空题",en:"Fill in the blank"},category:"objective",supports:["quiz","exam","survey"],Editor:y0,Answer:N0,createDefaultConfig:()=>({blanks:[{id:"b1",inputType:"text"}]}),createDefaultAnswerKey:()=>null}),kt.register({type:"short_answer",label:{zh:"简答/论述",en:"Short answer"},category:"subjective",supports:["quiz","exam","survey"],Editor:w0,Answer:E0,createDefaultConfig:()=>({placeholder:"请输入你的作答",maxLength:2e3}),createDefaultAnswerKey:()=>null}))}P0();const I0=1500;function A0(e){if(e===null)return"—";const t=Math.max(0,e),n=Math.floor(t/60),s=t%60;return n>=60?`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function dl(e){return e==null||e===""?"(未作答)":Array.isArray(e)?e.length===0?"(未作答)":e.map(t=>String(t)).join(" | "):typeof e=="object"?JSON.stringify(e):String(e)}function z0({lang:e,onExit:t}){const n=e==="zh",[s,i]=f.useState({mode:"list"}),[o,a]=f.useState(null),[l,c]=f.useState(!1),[d,u]=f.useState(null),m=f.useCallback(async()=>{c(!0),u(null);try{const g=await Ot.myAssessments();a(g.items)}catch(g){u(g instanceof ro?g.message:String(g?.message??g))}finally{c(!1)}},[]);f.useEffect(()=>{s.mode==="list"&&m()},[s.mode,m]);const p=async g=>{u(null),c(!0);try{if(g.completed&&g.attempt){const b=await Ot.attemptResult(g.attempt.id);i({mode:"result",result:b})}else{const b=await Ot.startAttempt(g.assignmentId);i({mode:"answering",payload:b,answers:{...b.answers}})}}catch(b){u(b instanceof ro?b.message:String(b?.message??b))}finally{c(!1)}};if(s.mode==="answering")return r.jsx(ta,{lang:e,payload:s.payload,initialAnswers:s.answers,onSubmitted:g=>i({mode:"result",result:g}),onExit:()=>i({mode:"list"})});if(s.mode==="result")return r.jsx(na,{lang:e,result:s.result,onBack:()=>{i({mode:"list"}),m()}});const h=(o??[]).filter(g=>!g.completed),x=(o??[]).filter(g=>g.completed);return r.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[t&&r.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":n?"返回学习看板":"Back to dashboard",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("h1",{className:"text-base font-bold text-main flex items-center gap-2",children:[r.jsx(Ss,{size:17,className:"text-indigo-500"}),n?"我的测评":"My assessments"]}),r.jsx("p",{className:"text-xs text-muted",children:n?"按截止时间排序。作答过程自动保存,断线后可续答;超时以服务端时间为准。":"Sorted by deadline. Answers autosave and resume after reconnecting; timing is server-authoritative."})]}),r.jsxs("button",{type:"button",onClick:()=>void m(),disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[r.jsx(Lr,{size:13,className:l?"animate-spin":""}),n?"刷新":"Refresh"]})]}),d&&r.jsx("p",{role:"alert",className:"mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:d}),r.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-5",children:o===null&&l?r.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[r.jsx($t,{size:13,className:"animate-spin"}),n?"加载中…":"Loading…"]}):(o?.length??0)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-center",children:[r.jsx(Ss,{size:36,className:"text-muted opacity-40"}),r.jsx("p",{className:"text-sm font-semibold text-main",children:n?"暂无待完成测评":"No assessments yet"}),r.jsx("p",{className:"text-xs text-muted",children:n?"老师发布测评后会出现在这里。":"Published assessments will show up here."})]}):r.jsxs(r.Fragment,{children:[r.jsxs("section",{"aria-labelledby":"pending-heading",children:[r.jsxs("h2",{id:"pending-heading",className:"text-xs font-bold text-main mb-2",children:[n?"待完成":"To do","(",h.length,")"]}),h.length===0?r.jsx("p",{className:"text-xs text-muted",children:n?"没有待完成的测评。":"Nothing pending."}):r.jsx("ul",{"data-testid":"student-pending-list",className:"space-y-2",children:h.map(g=>r.jsx("li",{children:r.jsx(ul,{entry:g,lang:e,disabled:l,onOpen:()=>void p(g)})},g.assignmentId))})]}),x.length>0&&r.jsxs("section",{"aria-labelledby":"done-heading",children:[r.jsxs("h2",{id:"done-heading",className:"text-xs font-bold text-main mb-2",children:[n?"已完成":"Completed","(",x.length,")"]}),r.jsx("ul",{"data-testid":"student-completed-list",className:"space-y-2",children:x.map(g=>r.jsx("li",{children:r.jsx(ul,{entry:g,lang:e,disabled:l,onOpen:()=>void p(g)})},g.assignmentId))})]})]})})]})}function ul({entry:e,lang:t,disabled:n,onOpen:s}){const i=t==="zh",o=e.windowState==="after_close",a=e.windowState==="before_open",l=!e.completed&&(o||a),c=e.kind==="quiz"?i?"测试":"Quiz":e.kind==="exam"?i?"考试":"Exam":i?"问卷":"Survey";return r.jsxs("div",{"data-testid":`student-assessment-${e.assignmentId}`,className:"bg-surface border border-theme rounded-xl px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"font-bold text-sm text-main truncate",children:e.title}),r.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme text-2xs font-semibold text-main",children:c}),e.completed&&e.attempt?.needsManualReview&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-2xs font-semibold bg-amber-50 text-amber-700 border border-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800",children:i?"待批改":"Pending review"})]}),r.jsxs("div",{className:"flex items-center gap-3 text-2xs text-muted flex-wrap",children:[r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Es,{size:11}),o?i?"已截止":"Closed":a?i?"未开始":"Not open yet":e.closesAt?`${i?"截止":"Due"} ${new Date(e.closesAt).toLocaleString()}`:i?"不限时":"No deadline"]}),e.durationSec&&r.jsx("span",{children:i?`限时 ${Math.round(e.durationSec/60)} 分钟`:`${Math.round(e.durationSec/60)} min`}),e.completed&&e.attempt&&r.jsx("span",{children:e.attempt.score===null?i?"成绩待发布":"Score pending":`${i?"得分":"Score"} ${e.attempt.score}/${e.attempt.maxScore??"—"}`})]})]}),r.jsxs("button",{type:"button",onClick:s,disabled:n||l,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold shrink-0 ${l?"bg-surface-secondary text-muted border border-theme cursor-not-allowed":e.completed?"border border-theme text-main hover:bg-surface-secondary cursor-pointer":"bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer"}`,children:[!l&&!e.completed&&r.jsx(Ro,{size:12}),l?o?i?"已截止":"Closed":i?"未开始":"Not open":e.completed?i?"查看结果":"View result":i?"开始作答":"Start"]})]})}function ta({lang:e,payload:t,initialAnswers:n,onSubmitted:s,onExit:i}){const o=e==="zh",a=t.attempt.id,l=t.assignment.kind==="exam"||!!t.assignment.settings?.strictProctor,[c,d]=f.useState(n),[u,m]=f.useState(new Set),[p,h]=f.useState(t.attempt.remainingSeconds??null),[x,g]=f.useState(!1),[b,w]=f.useState(null),[y,S]=f.useState(null),[C,k]=f.useState(!!document.fullscreenElement),[v,N]=f.useState(0),[O,D]=f.useState(null),_=f.useRef({}),T=f.useRef(c),z=f.useRef(!1);T.current=c;const R=f.useCallback(async j=>{if(!(!l||z.current))try{N(G=>G+1),D({blur:o?"检测到窗口失去焦点,已记录监考日志!":"Window lost focus — logged to proctor record!",visibility_hidden:o?"检测到切换屏幕/应用,已记录监考日志!":"Screen/tab switched — logged to proctor record!",fullscreen_exit:o?"检测到退出全屏作答,已记录监考日志!":"Exited fullscreen — logged to proctor record!"}[j]),await Ot.reportProctor(a,{type:j})}catch{}},[a,l,o]);f.useEffect(()=>{if(!l)return;const j=()=>{document.visibilityState==="hidden"&&R("visibility_hidden")},V=()=>{R("blur")},G=()=>{const Y=!!document.fullscreenElement;k(Y),!Y&&!z.current&&R("fullscreen_exit")},E=Y=>{Y.preventDefault()},W=Y=>{Y.preventDefault()};return document.addEventListener("visibilitychange",j),window.addEventListener("blur",V),document.addEventListener("fullscreenchange",G),document.addEventListener("contextmenu",E),document.addEventListener("copy",W),document.addEventListener("cut",W),document.addEventListener("paste",W),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("blur",V),document.removeEventListener("fullscreenchange",G),document.removeEventListener("contextmenu",E),document.removeEventListener("copy",W),document.removeEventListener("cut",W),document.removeEventListener("paste",W)}},[l,R]);const $=async()=>{try{document.fullscreenElement||await document.documentElement.requestFullscreen()}catch{}},I=f.useCallback(async j=>{try{await Ot.saveAnswer(a,j,T.current[j]??null),S(Date.now()),m(V=>{const G=new Set(V);return G.delete(j),G})}catch(V){w(V?.message??String(V))}},[a]),B=(j,V)=>{d(G=>({...G,[j]:V})),m(G=>new Set(G).add(j)),_.current[j]&&clearTimeout(_.current[j]),_.current[j]=setTimeout(()=>void I(j),I0)},H=f.useCallback(async()=>{if(!z.current){z.current=!0,g(!0),w(null);try{for(const G of Object.keys(_.current))_.current[G]&&clearTimeout(_.current[G]);const j=[...u];await Promise.all(j.map(G=>Ot.saveAnswer(a,G,T.current[G]??null)));const V=await Ot.submitAttempt(a);document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),s(V)}catch(j){z.current=!1,w(j?.message??String(j))}finally{g(!1)}}},[a,u,s]);f.useEffect(()=>{if(p===null)return;if(p<=0){H();return}const j=setTimeout(()=>h(V=>V===null?null:V-1),1e3);return()=>clearTimeout(j)},[p,H]),f.useEffect(()=>()=>{Object.values(_.current).forEach(j=>clearTimeout(j))},[]);const A=f.useMemo(()=>[...t.items].sort((j,V)=>j.sortOrder-V.sortOrder),[t.items]),U=A.filter(j=>{const V=c[j.id];return V==null||V===""?!1:Array.isArray(V)?V.length>0:!0}).length;return r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden relative ${l?"select-none":""}`,children:[l&&r.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 opacity-[0.035] dark:opacity-[0.06] overflow-hidden flex flex-wrap items-center justify-around gap-16 select-none p-4",children:Array.from({length:24}).map((j,V)=>r.jsxs("div",{className:"transform -rotate-25 text-xs font-mono font-bold tracking-widest text-main",children:[t.assignment.title," · #",a.slice(-6)]},V))}),r.jsxs("div",{className:"relative z-10 px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[!l&&r.jsx("button",{type:"button",onClick:i,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":o?"返回测评列表(作答已自动保存)":"Back to list (answers are saved)",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-sm font-bold text-main truncate",children:t.assignment.title}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-2xs font-extrabold bg-rose-50 text-rose-700 border border-rose-200 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800",children:o?"严格考试模式":"Exam Mode"})]}),r.jsxs("p",{className:"text-2xs text-muted",children:[o?"已作答":"Answered"," ",U,"/",A.length,y&&` · ${o?"已自动保存":"autosaved"}`,u.size>0&&` · ${o?"保存中…":"saving…"}`,l&&v>0&&r.jsx("span",{className:"text-rose-600 font-semibold ml-2",children:o?`异常记录 ${v} 次`:`Violations: ${v}`})]})]}),l&&!C&&r.jsx("button",{type:"button",onClick:()=>void $(),className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-xl bg-amber-600 text-white text-xs font-bold hover:bg-amber-700 cursor-pointer animate-pulse",children:o?"进入全屏锁定":"Enter Fullscreen"}),p!==null&&r.jsxs("span",{"data-testid":"assessment-countdown",className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-xl border text-xs font-bold ${p<=60?"border-rose-300 bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"border-theme bg-surface text-main"}`,role:"timer","aria-live":"off",children:[r.jsx(Es,{size:12}),A0(p)]}),r.jsxs("button",{type:"button",onClick:()=>void H(),disabled:x,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-700 text-white text-xs font-bold hover:bg-emerald-800 disabled:opacity-50 cursor-pointer",children:[x?r.jsx($t,{size:13,className:"animate-spin"}):r.jsx(at,{size:13}),o?"提交交卷":"Submit"]}),r.jsx(Me,{slot:"assessment.attempt.toolbar",slotProps:{assignmentId:t.assignment.id,attemptId:a,lang:e},lang:e})]}),O&&r.jsxs("div",{role:"alert",className:"relative z-10 mx-5 mt-3 px-3 py-2 rounded-xl border border-amber-200 bg-amber-50 text-amber-800 text-xs flex items-center justify-between gap-2",children:[r.jsxs("span",{children:["⚠️ ",O]}),r.jsx("button",{type:"button",onClick:()=>D(null),className:"text-2xs font-bold underline cursor-pointer",children:o?"知道了":"Dismiss"})]}),b&&r.jsx("p",{role:"alert",className:"relative z-10 mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:b}),r.jsx("div",{className:"relative z-10 flex-1 overflow-y-auto p-5",children:r.jsx("ol",{className:"space-y-4 max-w-3xl mx-auto",children:A.map((j,V)=>{const E=kt.get(j.type)?.Answer??T0;return r.jsxs("li",{"data-testid":`answer-item-${j.id}`,className:"border border-theme rounded-xl p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsxs("span",{className:"text-2xs font-bold text-muted mt-0.5",children:["#",V+1]}),r.jsx("p",{className:"text-sm font-semibold text-main whitespace-pre-wrap break-words flex-1",children:j.stem}),r.jsxs("span",{className:"text-2xs text-muted shrink-0",children:[j.maxScore," 分"]})]}),r.jsx(E,{config:j.config,value:c[j.id],onChange:W=>B(j.id,W),lang:e})]},j.id)})})})]})}function na({lang:e,result:t,onBack:n}){const s=e==="zh",{attempt:i,assignment:o}=t;return r.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[r.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":s?"返回测评列表":"Back to assessments",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h1",{className:"text-sm font-bold text-main truncate",children:o.title}),r.jsx("p",{className:"text-2xs text-muted",children:i?.submittedAt?`${s?"交卷时间":"Submitted"} ${new Date(i.submittedAt).toLocaleString()}`:s?"已交卷":"Submitted"})]}),t.showScore&&i&&r.jsxs("span",{"data-testid":"result-score",className:"text-sm font-bold text-main",children:[i.score??"—","/",i.maxScore??"—"]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4 max-w-3xl mx-auto w-full",children:[!t.showScore&&r.jsx("p",{className:"text-xs text-muted border border-theme rounded-xl px-3 py-2 bg-surface-secondary/40",children:s?"本次成绩待老师发布后可见。你的作答已保存,可以关闭页面。":"Your score will be visible after the teacher releases it. Your answers are saved."}),t.showScore&&i?.needsManualReview&&r.jsx("p",{className:"text-xs border border-amber-200 bg-amber-50 text-amber-700 rounded-xl px-3 py-2 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800",children:s?"主观题待人工批改,最终分数可能变化。":"Some items await manual grading; the score may change."}),t.aggregate.consideredAttempts>1&&t.aggregate.score!==null&&r.jsxs("p",{className:"text-xs text-muted",children:[s?`多次作答聚合(${t.aggregate.consideredAttempts} 次)`:`Aggregated over ${t.aggregate.consideredAttempts} attempts`,":",t.aggregate.score,"/",t.aggregate.maxScore??"—",t.aggregate.provisional&&(s?"(含待批改)":" (provisional)")]}),r.jsx("ul",{className:"space-y-3",children:t.items.map((a,l)=>r.jsxs("li",{"data-testid":`result-item-${a.itemId}`,className:"border border-theme rounded-xl p-4 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsxs("span",{className:"text-2xs font-bold text-muted mt-0.5",children:["#",l+1]}),r.jsx("p",{className:"text-sm font-semibold text-main whitespace-pre-wrap break-words flex-1",children:a.stem}),t.showAnalysis&&(a.needsManualReview?r.jsx("span",{className:"text-2xs text-amber-700 dark:text-amber-300 shrink-0",children:s?"待批改":"pending"}):a.isCorrect?r.jsx(at,{size:15,className:"text-emerald-600 shrink-0","aria-label":s?"正确":"Correct"}):r.jsx(sg,{size:15,className:"text-rose-600 shrink-0","aria-label":s?"错误":"Incorrect"}))]}),r.jsxs("p",{className:"text-xs text-main bg-surface-secondary rounded-lg px-2 py-1.5 whitespace-pre-wrap break-words",children:[r.jsx("span",{className:"text-muted mr-1",children:s?"你的作答:":"Your answer:"}),dl(a.answer)]}),t.showAnalysis&&a.answerKey!==void 0&&a.answerKey!==null&&r.jsxs("p",{className:"text-2xs text-muted",children:[s?"参考答案:":"Reference answer:"," ",dl(a.answerKey)]}),t.showAnalysis&&a.feedback&&r.jsxs("p",{className:"text-2xs text-indigo-700 dark:text-indigo-300",children:[s?"教师评语:":"Feedback:"," ",a.feedback]}),t.showAnalysis&&a.score!==null&&r.jsxs("p",{className:"text-2xs text-muted",children:[s?"本题得分":"Item score",":",a.score,"/",a.maxScore]})]},a.itemId))}),!o.scoreReleased&&t.showScore&&r.jsxs("p",{className:"text-2xs text-muted flex items-center gap-1",children:[r.jsx(Mt,{size:11}),s?"成绩尚未正式发布。":"Scores are not officially released yet."]})]})]})}const NN=Object.freeze(Object.defineProperty({__proto__:null,AssessmentRunner:ta,ResultView:na,StudentAssessmentsView:z0},Symbol.toStringTag,{value:"Module"}));function L0({lessonId:e,studentId:t,studentName:n="我",lang:s="zh"}){const[i,o]=f.useState(null),[a,l]=f.useState(null),[c,d]=f.useState("IN_CLASS_TEACHING"),[u,m]=f.useState(null),[p,h]=f.useState({}),[x,g]=f.useState(null),[b,w]=f.useState(null),[y,S]=f.useState(!1),[C,k]=f.useState("IDLE"),[v,N]=f.useState(null),[O,D]=f.useState(null),[_,T]=f.useState(!1),[z,R]=f.useState(!1),[$,I]=f.useState(null),[B,H]=f.useState(null),[A,U]=f.useState(5),[j,V]=f.useState(""),[G,E]=f.useState(""),[W,Y]=f.useState(null),[K,ne]=f.useState("closed"),[fe,je]=f.useState(null),[X,me]=f.useState(null),[ke,Se]=f.useState(!1),[M,Z]=f.useState(null),ee=f.useRef(Date.now()),te=f.useRef(null),ce=f.useRef(0),oe=f.useRef(0),xe=f.useRef(null),ie=f.useRef(null),Pe=f.useRef(!1);f.useEffect(()=>{if(!e)return;let L=!0;const F=async()=>{const J=++ce.current;try{const be=await fetch(`/api/classroom/sessions/${e}`);if(be.ok&&L){const se=await be.json();if(se.hasActiveSession){if(d(se.stage),se.session?.current_segment_id&&m(se.session.current_segment_id),se.stage==="WRAP_UP_EXIT_TICKET"&&!Pe.current&&T(!0),se.exitTicketCoreQuestion!==void 0&&I(se.exitTicketCoreQuestion),se.exitTicketChallengeQuestion!==void 0&&H(se.exitTicketChallengeQuestion),se.activeCountdown)try{window.dispatchEvent(new CustomEvent("openlearn:countdown:updated",{detail:se.activeCountdown}))}catch{}se.activePoll&&(!xe.current||xe.current.id!==se.activePoll.id)?(xe.current=se.activePoll,o(se.activePoll),w(null),S(!1)):!se.activePoll&&xe.current&&(xe.current=null,o(null));const ye=ie.current;if(se.activeBuzzer)if(!ye||ye.id!==se.activeBuzzer.id)ie.current=se.activeBuzzer,l(se.activeBuzzer),k("IDLE"),N(null),te.current=null,ee.current=Date.now();else if(se.activeBuzzer.status==="LOCKED"){const Fe=te.current,Ce=Fe&&Fe.buzzerId===se.activeBuzzer.id?Fe.status:t&&se.activeBuzzer.winner_student_id===t?"WINNER":"MISSED";te.current={buzzerId:se.activeBuzzer.id,status:Ce},ie.current=se.activeBuzzer,k(Ce),l(se.activeBuzzer)}else se.activeBuzzer.status==="READY"&&!(J<=oe.current)&&te.current?.buzzerId===se.activeBuzzer.id&&(te.current=null,ie.current=se.activeBuzzer,k("IDLE"),l(se.activeBuzzer),N(null),ee.current=Date.now());else ye&&(ie.current=null,l(null),k("IDLE"),te.current=null)}}}catch{}};F();const q=setInterval(F,2500);return()=>{L=!1,clearInterval(q)}},[e,t]),f.useEffect(()=>{const L=lt();if(!L||!e)return;const F=J=>{J?.lessonId===e&&J?.activeSegmentId&&m(J.activeSegmentId)},q=J=>{J?.lessonId===e&&J?.assignmentId&&(Y({assignmentId:J.assignmentId,title:J.title||(s==="zh"?"随堂测评":"Classroom Assessment"),kind:J.kind||"quiz",durationSec:J.durationSec??null,totalItems:J.totalItems??0,maxScore:J.maxScore??0}),ne("prompt"))};return L.on("student-active-segment-changed",F),L.on("classroom:assessment_started",q),()=>{typeof L.off=="function"&&(L.off("student-active-segment-changed",F),L.off("classroom:assessment_started",q))}},[e,s]);const ze=async()=>{if(W){Se(!0),Z(null);try{const L=await Ot.startAttempt(W.assignmentId);je(L),ne("answering")}catch(L){Z(L?.message||String(L))}finally{Se(!1)}}};if(f.useEffect(()=>{e&&fetch(`/api/lessons/${e}`).then(L=>L.ok?L.json():null).then(L=>{if(L?.timeline)try{const F=typeof L.timeline=="string"?JSON.parse(L.timeline):L.timeline;if(Array.isArray(F)){const q={};F.forEach(J=>{J?.id&&J?.title&&(q[J.id]=J.title)}),h(q)}}catch{}}).catch(()=>{})},[e]),f.useEffect(()=>{if(!e)return;fetch(`/api/classroom/sessions/${e}/pacing-summary?segmentId=${encodeURIComponent(u||"default")}`).then(F=>F.ok?F.json():null).then(F=>{F?.success&&g(F.mySignal||null)}).catch(()=>{})},[e,u]),!e)return null;const ue=async L=>{try{const F=x===L,q=await fetch(`/api/classroom/sessions/${e}/pacing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:F?null:L,action:F?"cancel":void 0,toggle:!0,segmentId:u||"default"})});if(q.ok){const J=await q.json();g(J.currentSignal??null),J.currentSignal?D(L==="TOO_FAST"?s==="zh"?"已反馈: 🐇 讲太快":"Pacing: Too Fast":L==="SLOW"?s==="zh"?"已反馈: 🐢 讲太慢":"Pacing: Too Slow":L==="CONFUSED"?s==="zh"?"已反馈: ❓ 有疑问":"Pacing: Confused":s==="zh"?"已反馈: 💡 听懂了":"Pacing: Clear"):D(s==="zh"?"已取消反馈":"Feedback cleared"),setTimeout(()=>D(null),2500)}}catch{}},re=async L=>{if(!(!i||y))try{w(L),S(!0),await fetch(`/api/classroom/sessions/${e}/quick-poll/${i.id}/vote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({option:L})})}catch{}},P=async()=>{if(!a||a.status!=="READY"||C!=="IDLE")return;const L=Date.now()-ee.current;oe.current=ce.current,k("BUZZED");try{const F=await fetch(`/api/classroom/sessions/${e}/buzzer/${a.id}/buzz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentName:n,responseTimeMs:L})});if(F.ok){const q=await F.json(),J=q.won??q.winner===!0,be=J?"WINNER":"MISSED";if(te.current={buzzerId:a.id,status:be},k(be),!J&&q.winner){const se={...a,status:"LOCKED",winner_student_id:q.winner.studentId??null,winner_student_name:q.winner.studentName??null,winner_response_time_ms:q.winner.responseTimeMs??null};ie.current=se,l(se)}}else k("IDLE")}catch{k("IDLE")}};return r.jsxs(r.Fragment,{children:[r.jsx(d0,{lessonId:e,lang:s}),r.jsx(Me,{slot:"student.classroom.overlay",slotProps:{studentId:t,lessonId:e}}),r.jsx(Me,{slot:"student.fullscreen",slotProps:{studentId:t,lessonId:e}}),r.jsxs("aside",{"aria-label":s==="zh"?"课堂互动工具栏":"Classroom interaction toolbar",className:"fixed bottom-6 right-6 z-40 flex items-center gap-2.5 bg-surface/95 backdrop-blur-md border border-theme p-2 rounded-2xl shadow-2xl transition-all",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-surface-secondary/70 rounded-xl border border-theme text-2xs font-bold text-muted",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary-theme animate-pulse"}),r.jsx("span",{className:"truncate max-w-[120px]",children:u&&p[u]?p[u]:s==="zh"?"当前环节":"Current Segment"})]}),O&&r.jsx("span",{className:"text-2xs font-bold text-primary-ink px-1.5 py-0.5 animate-fade-in whitespace-nowrap",children:O}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs("button",{type:"button",onClick:()=>ue("CLEAR"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="CLEAR"?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 ring-2 ring-emerald-500/60 shadow-xs":"hover:bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"}`,title:s==="zh"?"听懂了,节奏适宜(再次点击取消)":"Clear & Optimal (Click again to cancel)",children:[r.jsx("span",{children:"💡"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"听懂了":"Clear"}),x==="CLEAR"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("CONFUSED"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="CONFUSED"?"bg-amber-500/20 text-amber-700 dark:text-amber-300 ring-2 ring-amber-500/60 shadow-xs":"hover:bg-amber-500/10 text-amber-700 dark:text-amber-400"}`,title:s==="zh"?"有点困惑,希望老师点拨(再次点击取消)":"Confused (Click again to cancel)",children:[r.jsx("span",{children:"❓"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"有疑问":"Confused"}),x==="CONFUSED"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("TOO_FAST"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="TOO_FAST"?"bg-rose-500/20 text-rose-700 dark:text-rose-300 ring-2 ring-rose-500/60 shadow-xs":"hover:bg-rose-500/10 text-rose-700 dark:text-rose-400"}`,title:s==="zh"?"讲得太快了,希望能慢一点(再次点击取消)":"Too fast (Click again to cancel)",children:[r.jsx("span",{children:"🐇"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"讲太快":"Too Fast"}),x==="TOO_FAST"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("SLOW"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="SLOW"?"bg-indigo-500/20 text-indigo-600 dark:text-indigo-300 ring-2 ring-indigo-500/60 shadow-xs":"hover:bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}`,title:s==="zh"?"讲太慢了,希望快一点(再次点击取消)":"Too slow (Click again to cancel)",children:[r.jsx("span",{children:"🐢"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"讲太慢":"Too Slow"}),x==="SLOW"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]})]})]}),i&&i.status==="ACTIVE"&&r.jsxs("div",{"data-testid":"student-quick-poll-card",className:"fixed bottom-20 right-6 z-50 bg-surface rounded-2xl border border-amber-500/40 p-5 shadow-2xl w-80 flex flex-col gap-3 animate-slide-up",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-2",children:[r.jsxs("span",{className:"text-xs font-extrabold text-amber-700 dark:text-amber-400 flex items-center gap-1.5",children:[r.jsx(yt,{size:14}),s==="zh"?"极速答题进行中":"Quick Poll Active"]}),y&&r.jsxs("span",{className:"text-[11px] text-emerald-700 dark:text-emerald-400 font-bold flex items-center gap-1",children:[r.jsx(at,{size:12}),s==="zh"?"已提交":"Submitted"]})]}),r.jsx("p",{className:"font-bold text-sm text-foreground",children:i.title}),r.jsx("div",{className:"grid grid-cols-2 gap-2 mt-1",children:(i.options||["A","B","C","D"]).map(L=>{const F=b===L;return r.jsx("button",{disabled:y,onClick:()=>re(L),className:`p-3 rounded-xl font-bold text-center text-sm transition-all cursor-pointer ${F?"bg-primary-solid text-white ring-2 ring-primary-theme shadow-md scale-95":y?"bg-surface-secondary text-muted opacity-60 cursor-not-allowed":"bg-surface-secondary hover:bg-primary-theme/10 hover:border-primary-theme border border-border text-foreground"}`,children:L},L)})})]}),a&&v!==a.id&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",onClick:()=>N(a.id),children:r.jsxs("div",{className:"relative bg-surface rounded-3xl border border-rose-500/50 p-8 w-full max-w-sm shadow-2xl flex flex-col items-center text-center gap-4 animate-scale-up",onClick:L=>L.stopPropagation(),children:[r.jsx("button",{onClick:()=>N(a.id),"aria-label":s==="zh"?"关闭抢答":"Close buzzer",className:"absolute top-3 right-3 p-1.5 rounded-full text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:r.jsx(Oe,{size:18})}),r.jsxs("h3",{className:"text-xl font-black text-foreground flex items-center gap-2",children:[r.jsx($o,{size:22,className:"text-rose-700 dark:text-rose-400 animate-bounce"}),r.jsx("span",{children:a.title||"全班极速抢答"})]}),C==="BUZZED"&&r.jsxs("div",{className:"my-4 p-6 bg-amber-500/10 border border-amber-500/30 rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2 animate-pulse",children:"⚡"}),r.jsx("span",{className:"text-base font-bold text-foreground",children:"正在提交抢答…"}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"请稍候,马上公布结果"})]}),C==="IDLE"&&a.status==="READY"&&r.jsxs("div",{className:"my-4 flex flex-col items-center gap-3",children:[r.jsxs("button",{onClick:P,className:"w-36 h-36 rounded-full bg-gradient-to-tr from-rose-700 to-rose-600 text-white font-black text-2xl shadow-xl hover:scale-105 active:scale-95 transition-all flex flex-col items-center justify-center border-4 border-white dark:border-slate-800 cursor-pointer animate-pulse",children:[r.jsx(rg,{size:32,className:"mb-1"}),r.jsx("span",{children:"抢!"})]}),r.jsx("span",{className:"text-xs text-muted",children:"点击红色大按钮抢得首答权"})]}),C==="WINNER"&&r.jsxs("div",{className:"my-4 p-6 bg-emerald-500/10 border border-emerald-500/30 rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2",children:"🎉"}),r.jsx("span",{className:"text-lg font-black text-emerald-700 dark:text-emerald-400",children:"恭喜你率先抢答!"}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"请起立或开麦回答老师的问题"}),r.jsx("button",{onClick:()=>N(a.id),className:"mt-3 px-4 py-1.5 rounded-xl text-xs font-bold text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:s==="zh"?"知道了,返回课堂":"Got it, back to class"})]}),C==="MISSED"&&r.jsxs("div",{className:"my-4 p-6 bg-slate-800/20 border border-border rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2",children:"⚡"}),r.jsxs("span",{className:"text-base font-bold text-foreground",children:["已被 ",a.winner_student_name||"其他同学"," 抢先一步!"]}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"下次手速要更快哦"}),r.jsx("button",{onClick:()=>N(a.id),className:"mt-3 px-4 py-1.5 rounded-xl text-xs font-bold text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:s==="zh"?"知道了,返回课堂":"Got it, back to class"})]})]})}),r.jsx(u0,{isOpen:_,onClose:()=>T(!1),lessonId:e,studentName:n,lang:s,coreQuestion:$,challengeQuestion:B,onSubmitSuccess:()=>{Pe.current=!0,R(!0)}}),W&&K==="prompt"&&r.jsxs("div",{"data-testid":"student-classroom-assessment-card",className:"fixed bottom-20 left-6 z-50 bg-surface rounded-2xl border border-indigo-500/40 p-5 shadow-2xl w-80 flex flex-col gap-3 animate-slide-up",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-2",children:[r.jsxs("span",{className:"text-xs font-extrabold text-indigo-700 dark:text-indigo-400 flex items-center gap-1.5",children:[r.jsx(Ss,{size:14}),s==="zh"?"随堂测评已发起":"Classroom Assessment"]}),r.jsx("button",{onClick:()=>ne("closed"),"aria-label":s==="zh"?"关闭":"Close",className:"p-1 rounded-lg text-muted hover:text-foreground cursor-pointer",children:r.jsx(Oe,{size:14})})]}),r.jsx("p",{className:"font-bold text-sm text-foreground",children:W.title}),r.jsxs("div",{className:"flex items-center gap-2 text-2xs text-muted flex-wrap",children:[r.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme",children:W.kind==="exam"?s==="zh"?"考试":"Exam":W.kind==="survey"?s==="zh"?"问卷":"Survey":s==="zh"?"测试":"Quiz"}),r.jsxs("span",{children:[W.totalItems," ",s==="zh"?"道题":"items"]}),r.jsxs("span",{children:[s==="zh"?"满分":"Total"," ",W.maxScore]}),W.durationSec&&r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Es,{size:11}),Math.round(W.durationSec/60)," ",s==="zh"?"分钟":"min"]})]}),M&&r.jsx("p",{className:"text-2xs text-rose-600 bg-rose-50 dark:bg-rose-950/40 p-1.5 rounded-lg",children:M}),r.jsxs("button",{type:"button",onClick:()=>void ze(),disabled:ke,className:"w-full py-2 px-3 rounded-xl bg-indigo-600 text-white font-bold text-xs hover:bg-indigo-700 transition-colors flex items-center justify-center gap-1.5 cursor-pointer disabled:opacity-50",children:[ke?r.jsx("span",{className:"animate-spin text-xs",children:"⏳"}):r.jsx(Ro,{size:13}),s==="zh"?"立即开始作答":"Start Assessment"]})]}),K==="answering"&&fe&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6 animate-fade-in",children:r.jsx("div",{className:"w-full max-w-4xl h-[92vh] flex flex-col",children:r.jsx(ta,{lang:s,payload:fe,initialAnswers:fe.answers,onSubmitted:L=>{me(L),ne("result")},onExit:()=>ne("closed")})})}),K==="result"&&X&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6 animate-fade-in",children:r.jsx("div",{className:"w-full max-w-4xl h-[92vh] flex flex-col",children:r.jsx(na,{lang:s,result:X,onBack:()=>{ne("closed"),Y(null),je(null),me(null)}})})})]})}function R0(e){const t=nn(),n=e.pickedAnnouncement!==void 0?e.pickedAnnouncement:t?.pickedAnnouncement,s=e.setPickedAnnouncement??t?.setPickedAnnouncement,i=e.pickedAlertData!==void 0?e.pickedAlertData:t?.pickedAlertData,o=e.setPickedAlertData??t?.setPickedAlertData,a=e.lang??t?.lang??"zh",l=e.selectedLesson!==void 0?e.selectedLesson:t?.selectedLesson??null,c=e.liveClassSelectedClassId!==void 0?e.liveClassSelectedClassId:t?.liveClassSelectedClassId??null,d=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,u=e.students??t?.students??[],m=e.activeRole??t?.activeRole??"teacher",p=e.isStudentLiveMode??t?.isStudentLiveMode??!1,h=e.liveStudentParam!==void 0?e.liveStudentParam:t?.liveStudentParam??null,x=e.addToast??t?.addToast??(()=>{}),g=e.setReadNotifications??t?.setReadNotifications??(()=>{});return r.jsxs(r.Fragment,{children:[n&&!i&&r.jsx("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-[9990] animate-in slide-in-from-top-4 duration-300 pointer-events-auto max-w-lg w-auto",children:r.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 bg-gradient-to-r from-amber-500 to-orange-500 text-white rounded-full shadow-xl shadow-amber-500/25 backdrop-blur-xs text-sm font-bold border border-amber-300/40",children:[r.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-white"})]}),r.jsx(yt,{size:16,className:"text-amber-200 shrink-0"}),r.jsx("span",{className:"truncate",children:a==="zh"?`🎯 课堂抽问:老师随机抽中了【${n.studentName}】同学回答问题!`:`🎯 Classroom Pick: Teacher randomly selected [${n.studentName}] to answer!`}),s&&r.jsx("button",{type:"button",onClick:()=>s(null),className:"ml-2 hover:bg-white/20 rounded-full p-1 transition-colors cursor-pointer text-white/80 hover:text-white shrink-0","aria-label":"Close announcement",children:r.jsx(Oe,{size:14})})]})}),i&&r.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/70 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-200",children:r.jsxs("div",{className:"bg-surface border-4 border-amber-500 rounded-3xl shadow-2xl shadow-amber-500/40 ring-8 ring-amber-500/20 p-7 max-w-md w-full text-center space-y-5 animate-in zoom-in-95 duration-300",children:[r.jsxs("div",{className:"relative w-20 h-20 mx-auto",children:[r.jsx("div",{className:"absolute inset-0 bg-amber-500/30 rounded-full animate-ping"}),r.jsx("div",{className:"relative w-20 h-20 bg-gradient-to-tr from-amber-500 to-orange-500 text-white rounded-full flex items-center justify-center shadow-lg shadow-amber-500/40",children:r.jsx(yt,{size:40,className:"animate-pulse"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-2xl font-black text-main tracking-tight",children:a==="zh"?"⚡️ 闪电抽问:老师抽中了你!":"⚡️ Classroom Pick: Teacher Selected You!"}),r.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-amber-500/10 border border-amber-500/30 text-amber-600 dark:text-amber-400 font-black text-lg",children:[r.jsx("span",{children:"🎯"}),r.jsx("span",{children:i.studentName})]}),r.jsx("p",{className:"text-sm text-muted leading-relaxed",children:a==="zh"?r.jsx(r.Fragment,{children:"老师在课堂随机抽问中抽中了你,请立即集中注意力参与互动回答!"}):r.jsx(r.Fragment,{children:"The teacher selected you in the classroom random pick. Please respond and participate now!"})})]}),r.jsx("div",{className:"pt-2",children:r.jsxs("button",{type:"button",onClick:()=>{const b=new yd(void 0,l,c);if(b.acknowledgePick(i.studentId),b.destroy(),i.rollcallId){const w=i.rollcallId;d&&r0(d,w).catch(console.error),g(y=>new Set(y).add(w))}o?.(null),x(a==="zh"?"🙋♂️ 已确认答到":"🙋♂️ Acknowledged",a==="zh"?"已向老师中控台发送举手答到信号!":"Sent acknowledge signal to teacher!","success")},className:"w-full py-3.5 bg-gradient-to-r from-amber-500 to-orange-600 hover:from-amber-600 hover:to-orange-700 text-white font-black text-base rounded-2xl shadow-xl shadow-amber-500/35 transition-all active:scale-95 cursor-pointer flex items-center justify-center gap-2",children:[r.jsx(at,{size:20}),r.jsx("span",{children:a==="zh"?"🙋♂️ 我已准备好 / 确认答到 (反馈给老师)":"🙋♂️ Ready / Acknowledge to Teacher"})]})})]})}),(m==="student"||p)&&r.jsx(L0,{lessonId:l,studentId:d||h||void 0,studentName:u.find(b=>b.id===(d||h))?.name||void 0,lang:a})]})}const sa=f.createContext({});function ra(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const _0=typeof window<"u",Sd=_0?f.useLayoutEffect:f.useEffect,Mr=f.createContext(null),ia=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function hl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function O0(...e){return t=>{let n=!1;const s=e.map(i=>{const o=hl(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():hl(e[i],null)}}}}function D0(...e){return f.useCallback(O0(...e),e)}class M0 extends f.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Zr(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,i=Zr(s)&&s.offsetWidth||0,o=Zr(s)&&s.offsetHeight||0,a=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(a.height),l.width=parseFloat(a.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=i-l.width-l.left,l.bottom=o-l.height-l.top,l.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function $0({children:e,isPresent:t,anchorX:n,anchorY:s,root:i,pop:o}){const a=f.useId(),l=f.useRef(null),c=f.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:d}=f.useContext(ia),u=e.props?.ref??e?.ref,m=D0(l,u);return f.useInsertionEffect(()=>{const{width:p,height:h,top:x,left:g,right:b,bottom:w,direction:y}=c.current;if(t||o===!1||!l.current||!p||!h)return;const S=y==="rtl",C=n==="left"?S?`right: ${b}`:`left: ${g}`:S?`left: ${g}`:`right: ${b}`,k=s==="bottom"?`bottom: ${w}`:`top: ${x}`;l.current.dataset.motionPopId=a;const v=document.createElement("style");d&&(v.nonce=d);const N=i??document.head;return N.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
12
|
+
${w}`:w),o(!1),l(null),d({})};return r.jsxs("div",{className:"relative shrink-0",children:[r.jsx("button",{type:"button",onClick:()=>o(!i),disabled:a!==null&&!!p,className:`p-1 px-1.5 rounded-full transition-colors cursor-pointer ${i?"text-indigo-600 bg-indigo-50":"text-gray-500 hover:text-indigo-600 hover:bg-gray-100"}`,title:m?"插件提示词模板":"Plugin prompt templates",children:r.jsx(Yp,{size:14})}),i&&r.jsxs("div",{className:"absolute bottom-full mb-2 left-0 w-80 max-h-72 overflow-y-auto bg-white border border-gray-200 rounded-xl shadow-xl z-40 text-xs",children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100 sticky top-0 bg-white",children:[r.jsx("span",{className:"font-semibold text-gray-700",children:m?"插件提示词模板":"Prompt templates"}),r.jsx("button",{type:"button",onClick:()=>{o(!1),l(null)},className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:r.jsx(Oe,{size:12})})]}),p?r.jsxs("div",{className:"p-3 space-y-2",children:[r.jsx("div",{className:"font-medium text-gray-800",children:p.slotProps?.title||p.id}),(p.slotProps?.parameters??[]).map(x=>r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] text-gray-500",children:x.label||x.name}),r.jsx("input",{value:c[x.name]??"",onChange:g=>d(b=>({...b,[x.name]:g.target.value})),className:"mt-0.5 w-full border border-gray-200 rounded-lg px-2 py-1 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-100 focus:border-indigo-300",placeholder:x.default||x.name})]},x.name)),r.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[r.jsx("button",{type:"button",onClick:()=>h(p,c),className:"flex-1 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-semibold transition-colors cursor-pointer",children:m?"插入到输入框":"Insert"}),r.jsx("button",{type:"button",onClick:()=>l(null),className:"px-3 py-1.5 text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg transition-colors cursor-pointer",children:m?"返回":"Back"})]})]}):r.jsx("div",{className:"py-1",children:u.map(x=>{const g=x.slotProps?.title||x.id,b=x.slotProps?.description;return r.jsxs("button",{type:"button",onClick:()=>{const w=x.slotProps?.parameters??[];if(w.length>0){const y={};for(const S of w)S.default&&(y[S.name]=S.default);d(y),l(x.id)}else h(x,{})},className:"w-full text-left px-3 py-2 hover:bg-indigo-50 transition-colors cursor-pointer",children:[r.jsx("div",{className:"font-medium text-gray-800",children:g}),b&&r.jsx("div",{className:"text-[11px] text-gray-500 mt-0.5 line-clamp-2",children:b})]},x.id)})})]})]})}function Ub(e={}){const t=nn(),n=e.showRightSidebar??t?.showRightSidebar??!1,s=e.setShowRightSidebar??t?.setShowRightSidebar??(()=>{}),i=e.rightSidebarTab??t?.rightSidebarTab??"agent",o=e.setRightSidebarTab??t?.setRightSidebarTab??(()=>{}),a=e.effectiveAgentProviderId??t?.effectiveAgentProviderId??"";e.agentProviderId??t?.agentProviderId;const l=e.setAgentProviderId??t?.setAgentProviderId??(()=>{}),c=e.personaId??t?.personaId??"",d=e.setPersonaId??t?.setPersonaId??(()=>{}),u=e.aiProviders??t?.aiProviders??[],m=e.selectedAgentProvider!==void 0?e.selectedAgentProvider:t?.selectedAgentProvider??null,p=e.chatLog??t?.chatLog??[],h=e.loading??t?.loading??!1,x=e.input??t?.input??"",g=e.setInput??t?.setInput??(()=>{}),b=e.handleSend??t?.handleSend??(async()=>{}),w=e.chatAttachments??t?.chatAttachments??[],y=e.setChatAttachments??t?.setChatAttachments??(()=>{}),S=e.handleChatFileChange??t?.handleChatFileChange??(()=>{}),C=e.handleChatDrop??t?.handleChatDrop??(()=>{}),k=e.onClearAgentMemory??t?.handleClearAgentMemory??(()=>{}),v=e.events??t?.events??[],N=e.lang??t?.lang??"zh",O=e.t??t?.t??{},D=f.useRef(null);f.useEffect(()=>{D.current?.scrollIntoView({behavior:"smooth"})},[p]);const[_,T]=f.useState([]);return f.useEffect(()=>{!n||_.length>0||fetch("/api/agent/personas").then(z=>z.ok?z.json():null).then(z=>{z?.success&&Array.isArray(z.personas)&&T(z.personas)}).catch(()=>{})},[n]),r.jsx("div",{className:`transition-all duration-300 bg-white border-l border-gray-200 flex flex-col shadow-xl relative z-30 shrink-0 ${n?"w-96":"w-12 items-center cursor-pointer hover:bg-gray-50"}`,children:n?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[r.jsxs("button",{onClick:()=>o("agent"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${i==="agent"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[r.jsx(Yr,{size:14})," Agent"]}),r.jsxs("button",{onClick:()=>o("shell"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${i==="shell"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[r.jsx(Xs,{size:14})," Shell"]}),r.jsx(Me,{slot:"ai_sidebar.tab",slotProps:{renderType:"button",activeTab:i,setActiveTab:o,lang:N}}),r.jsx("button",{onClick:()=>s(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:r.jsx(Zp,{size:14})})]}),i==="agent"?r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:r.jsx(Yr,{size:16})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:O.agentTitle}),r.jsx("p",{className:"text-xs text-gray-500",children:O.agentSubtitle}),r.jsxs("button",{onClick:k,title:N==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-xs text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",N==="zh"?"清除记忆":"Clear memory"]})]})]}),r.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[r.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-gray-400",children:N==="zh"?"AI 提供商":"AI Provider"}),r.jsxs("div",{className:"relative w-full",children:[u.length===0?r.jsx("select",{disabled:!0,value:"",className:"w-full appearance-none rounded-xl border border-amber-200 bg-amber-50/50 px-3 py-2 pr-9 text-xs font-medium text-amber-700 shadow-xs outline-none cursor-not-allowed",children:r.jsx("option",{value:"",children:N==="zh"?"未配置 AI 提供商":"No AI Provider"})}):r.jsx("select",{value:a,onChange:z=>l(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 pr-9 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:u.map(z=>r.jsx("option",{value:z.id,children:z.name},z.id))}),r.jsx(Nn,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),r.jsx("div",{className:"text-xs text-gray-400 truncate w-full text-right",title:m?.model_name||"",children:m?`${m.model_name}`:N==="zh"?"未配置提供商":"No Provider"})]})]})}),d&&_.length>0&&r.jsx("div",{className:"mx-4 mb-3",children:r.jsxs("select",{value:c||"",onChange:z=>d(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:[r.jsx("option",{value:"",children:N==="zh"?"🤖 助教角色:默认":"🤖 Persona: Default"}),_.filter(z=>z.id!=="plain_assistant").map(z=>r.jsxs("option",{value:z.id,children:[z.icon||"🎯"," ",N==="zh"?z.nameZh:z.nameEn]},z.id))]})}),u.length===0&&r.jsxs("div",{className:"mx-4 mt-3 p-3 bg-amber-50 border border-amber-200/80 rounded-xl text-xs text-amber-900 flex items-start gap-2 shadow-xs shrink-0",children:[r.jsx(Mt,{size:15,className:"shrink-0 text-amber-600 mt-0.5"}),r.jsxs("div",{className:"flex-1 leading-relaxed",children:[r.jsx("span",{className:"font-semibold",children:N==="zh"?"未配置 AI 提供商":"No AI Provider Configured"}),r.jsx("p",{className:"mt-0.5 text-amber-700",children:N==="zh"?"请前往「系统管理 -> AI 提供商管理」添加大模型服务(如 DeepSeek、Qwen、OpenAI 等)。":'Please configure an AI provider in "System Management -> AI Provider Management" to use the AI assistant.'})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[p.map((z,R)=>r.jsx("div",{className:`flex flex-col ${z.role==="user"?"items-end":"items-start"}`,children:r.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${z.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:z.content})},R)),h&&r.jsx("div",{className:"flex items-start",children:r.jsxs("div",{className:"px-4 py-2.5 rounded-2xl max-w-[85%] text-xs bg-gray-100 text-gray-500 rounded-bl-none flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),r.jsx("div",{ref:D})]}),r.jsxs("form",{onSubmit:b,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:z=>z.preventDefault(),onDrop:C,children:[w.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:w.map((z,R)=>r.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full text-xs",children:[r.jsx(Jc,{size:10,className:"shrink-0"}),r.jsx("span",{className:"truncate max-w-[100px]",title:z.name,children:z.name}),r.jsx("button",{type:"button",onClick:()=>y($=>$.filter((I,B)=>B!==R)),className:"hover:bg-indigo-200 rounded-full p-0.5 cursor-pointer ml-0.5 transition-colors text-indigo-400 hover:text-indigo-600",children:r.jsx(Oe,{size:10})})]},R))}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("label",{className:"p-1 px-1.5 text-gray-500 hover:text-indigo-600 rounded-full hover:bg-gray-100 cursor-pointer transition-colors shrink-0",children:[r.jsx(Xp,{size:14}),r.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:S,accept:".csv,.txt,.json,.md"})]}),r.jsx(Bb,{setInput:g,currentInput:x,lang:N}),r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:"text",value:x,disabled:u.length===0,onChange:z=>g(z.target.value),placeholder:u.length===0?N==="zh"?"请先配置 AI 提供商":"Please configure AI provider first":O.placeholder,className:"w-full bg-gray-50 border border-gray-200 rounded-full pl-4 pr-10 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all disabled:opacity-60 disabled:cursor-not-allowed"}),r.jsx("button",{type:"submit",disabled:h||!x.trim()||u.length===0,className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:r.jsx(Kc,{size:10})})]})]})]})]}):i==="shell"?r.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-xs min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[r.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:r.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[r.jsx(Xs,{size:14}),r.jsx("span",{className:"text-xs",children:O.eventStream})]})}),r.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:v.length===0?r.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):v.map((z,R)=>r.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[r.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[r.jsxs("span",{className:"text-gray-500 shrink-0 text-xs",children:["[",new Date(z.timestamp).toLocaleTimeString(),"]"]}),r.jsx("span",{className:"text-blue-400 shrink-0 truncate text-xs",title:z.source,children:z.source})]}),r.jsx("div",{className:"text-green-300 font-bold",children:z.type}),r.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:z.payload})]},R))})]}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto p-4",children:r.jsx(Me,{slot:"ai_sidebar.tab",slotProps:{renderType:"panel",activeTab:i,lang:N}})})]}):r.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-subtle w-full",onClick:()=>s(!0),children:[r.jsx(Yr,{size:18,className:"mb-6 hover:text-indigo-500"}),r.jsx(Xs,{size:18,className:"hover:text-indigo-500"}),r.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:r.jsx("div",{className:"uppercase tracking-widest text-xs rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const Vb=f.lazy(()=>Je(()=>import("./ImportModal-DqjqNeH4.js"),__vite__mapDeps([6,1,2,3])).then(e=>({default:e.ImportModal}))),Hb=f.lazy(()=>Je(()=>import("./CourseWizardModal-vw876VJr.js"),__vite__mapDeps([7,1,2,3,4])).then(e=>({default:e.CourseWizardModal}))),Wb=f.lazy(()=>Je(()=>import("./ImportLessonsModal-C09Z-qtx.js"),__vite__mapDeps([8,1,2,3,4])).then(e=>({default:e.ImportLessonsModal}))),qb=f.lazy(()=>Je(()=>import("./QuizGeneratorModal-xTq22vDq.js"),__vite__mapDeps([9,1,2,3,4])).then(e=>({default:e.QuizGeneratorModal}))),Gb=f.lazy(()=>Je(()=>import("./ProcessLogsModal-Cfr-T9Gd.js"),__vite__mapDeps([10,1,2,3])).then(e=>({default:e.ProcessLogsModal}))),Qb=f.lazy(()=>Je(()=>import("./CloudDriveModal-C6JtK08M.js"),__vite__mapDeps([11,1,2,12,3,4])).then(e=>({default:e.CloudDriveModal}))),Jb=f.lazy(()=>Je(()=>import("./SystemResourceLibraryModal-YZ85mv_v.js"),__vite__mapDeps([13,1,2,11,12,3,4])).then(e=>({default:e.SystemResourceLibraryModal}))),Kb=f.lazy(()=>Je(()=>import("./BatchPickerModal-CzutdtIz.js"),__vite__mapDeps([14,1,2,3,4])).then(e=>({default:e.BatchPickerModal}))),Yb=f.lazy(()=>Je(()=>import("./ExportWeightModal-CTZ-O_wi.js"),__vite__mapDeps([15,1,2,3,4])).then(e=>({default:e.ExportWeightModal}))),Zb=f.lazy(()=>Je(()=>import("./NotificationDetailModal-4MdNF4tw.js"),__vite__mapDeps([16,1,2,3,4])).then(e=>({default:e.NotificationDetailModal}))),Xb=f.lazy(()=>Je(()=>import("./HelpTour-D_q1z_MI.js"),__vite__mapDeps([17,1,2,3])).then(e=>({default:e.HelpTour}))),e0=f.lazy(()=>Je(()=>import("./CoursewareHubPanel-CyxDIJAF.js"),__vite__mapDeps([18,1,2,3])).then(e=>({default:e.CoursewareHubPanel})));function t0(e={}){const t=nn(),{lang:n=t?.lang??"zh",t:s=t?.t??{},showImportModal:i=t?.showImportModal??!1,setShowImportModal:o=t?.setShowImportModal??(()=>{}),handleImportFile:a=t?.handleImportFile??(()=>{}),importError:l=t?.importError??null,importSuccess:c=t?.importSuccess??null,isImporting:d=t?.isImporting??!1,downloadCSVTemplate:u=t?.downloadCSVTemplate??(()=>{}),addToast:m=t?.addToast??(()=>{}),isImportLessonsOpen:p=t?.isImportLessonsOpen??!1,setIsImportLessonsOpen:h=t?.setIsImportLessonsOpen??(()=>{}),importStatus:x=t?.importStatus??"idle",setIsDraggingImport:g=t?.setIsDraggingImport??(()=>{}),handleCSVFileChange:b=t?.handleCSVFileChange??(()=>{}),handleImportFileChange:w=t?.handleImportFileChange??(()=>{}),downloadCsvTemplate:y=t?.downloadCsvTemplate??(()=>{}),downloadCourseTemplate:S=t?.downloadCourseTemplate??(()=>{}),packagePreview:C=t?.packagePreview??null,handlePackageImportSubmit:k=t?.handlePackageImportSubmit??(()=>{}),packageDuplicate:v=t?.packageDuplicate??null,handlePackageDuplicateDismiss:N=t?.handlePackageDuplicateDismiss??(()=>{}),isDraggingImport:O=t?.isDraggingImport??!1,previewImportData:D=t?.previewImportData??[],setPreviewImportData:_=t?.setPreviewImportData??(()=>{}),setImportStatus:T=t?.setImportStatus??(()=>{}),importProgress:z=t?.importProgress??0,importProgressTotal:R=t?.importProgressTotal??0,importErrorMsg:$=t?.importErrorMsg??"",setImportErrorMsg:I=t?.setImportErrorMsg??(()=>{}),handleCSVImportSubmit:B=t?.handleCSVImportSubmit??(()=>{}),lessons:H=t?.lessons??[],fetchClassDashboard:A=t?.fetchClassDashboard??(()=>{}),currentVfsParent:U=t?.currentVfsParent??null,setCurrentVfsParent:j=t?.setCurrentVfsParent??(()=>{}),vfsNodes:V=t?.vfsNodes??[],showProcessLogs:G=t?.showProcessLogs??null,setShowProcessLogs:E=t?.setShowProcessLogs??(()=>{}),processLogsContent:W=t?.processLogsContent??"",isCloudDriveOpen:Y=t?.isCloudDriveOpen??!1,setIsCloudDriveOpen:K=t?.setIsCloudDriveOpen??(()=>{}),cloudDrivePreviewNode:ne=t?.cloudDrivePreviewNode??null,setCloudDrivePreviewNode:fe=t?.setCloudDrivePreviewNode??(()=>{}),isSystemResourceLibraryOpen:je=t?.isSystemResourceLibraryOpen??!1,setIsSystemResourceLibraryOpen:X=t?.setIsSystemResourceLibraryOpen??(()=>{}),systemResourceTab:me=t?.systemResourceTab??"system",setSystemResourceTab:ke=t?.setSystemResourceTab??(()=>{}),selectedLibraryResourceId:Se=t?.selectedLibraryResourceId??null,setSelectedLibraryResourceId:M=t?.setSelectedLibraryResourceId??(()=>{}),loadingLibraryResources:Z=t?.loadingLibraryResources??!1,libraryResources:ee=t?.libraryResources??[],fetchLibraryResources:te=t?.fetchLibraryResources??(()=>{}),classes:ce=t?.classes??[],expandedClassId:oe=t?.expandedClassId??null,isExportWeightModalOpen:xe=t?.isExportWeightModalOpen??!1,setIsExportWeightModalOpen:ie=t?.setIsExportWeightModalOpen??(()=>{}),quizzesWeight:Pe=t?.quizzesWeight??40,setQuizzesWeight:ze=t?.setQuizzesWeight??(()=>{}),assignmentsWeight:ue=t?.assignmentsWeight??60,setAssignmentsWeight:re=t?.setAssignmentsWeight??(()=>{}),handleQuizzesWeightChange:P=t?.handleQuizzesWeightChange??(()=>{}),handleAssignmentsWeightChange:L=t?.handleAssignmentsWeightChange??(()=>{}),customCategoryOverrides:F=t?.customCategoryOverrides??{},setCustomCategoryOverrides:q=t?.setCustomCategoryOverrides??(()=>{}),classDashboardMap:J=t?.classDashboardMap??{},exportClassId:be=t?.exportClassId??"",exportClassName:se=t?.exportClassName??"",csvPreviewData:ye=t?.csvPreviewData??null,handleExportGrades:$e=t?.handleExportGrades??(()=>{}),setSelectedAssignment:Fe=t?.setSelectedAssignment??(()=>{}),setStudentViewStatus:Ce=t?.setStudentViewStatus??(()=>{}),setQuizStudentAnswers:We=t?.setQuizStudentAnswers??(()=>{}),setSubAssignmentTab:He=t?.setSubAssignmentTab??(()=>{}),isTourOpen:Et=t?.isTourOpen??!1,setIsTourOpen:et=t?.setIsTourOpen??(()=>{}),handleSeedSuccess:jt=t?.handleSeedSuccess??(()=>{}),setTeacherTab:Vt=t?.setTeacherTab??(()=>{}),showCoursewareHub:Ln=t?.showCoursewareHub??!1,setShowCoursewareHub:Ht=t?.setShowCoursewareHub??(()=>{})}=e,Re=e.courseWizard??t,rn=Re?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Rn=Re?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),_n=Re?.wizardStep??e.wizardStep??1,On=Re?.setWizardStep??e.setWizardStep??(()=>{}),on=Re?.wizardIsSubmitting??e.wizardIsSubmitting??!1,Dn=Re?.wizardCourseTitle??e.wizardCourseTitle??"",an=Re?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),Mn=Re?.wizardCourseDescription??e.wizardCourseDescription??"",$n=Re?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),Fn=Re?.wizardCourseCategory??e.wizardCourseCategory??"",Tt=Re?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),ln=Re?.wizardCourseTimeline??e.wizardCourseTimeline??[],Wt=Re?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),Bn=Re?.wizardCourseContent??e.wizardCourseContent??"",Un=Re?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),Pt=Re?.wizardIsGeneratingOutline??e.wizardIsGeneratingOutline??!1,cn=Re?.handleGenerateOutline??e.handleGenerateOutline??(async()=>{}),dn=Re?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),_e=e.quizGenerator??t,Vn=_e?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,Hn=_e?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),Wn=_e?.quizGenMode??e.quizGenMode??"scan_lesson",qn=_e?.setQuizGenMode??e.setQuizGenMode??(()=>{}),Gn=_e?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",Qn=_e?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),Jn=_e?.quizGenTopic??e.quizGenTopic??"",Kn=_e?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Yn=_e?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,Zn=_e?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),Xn=_e?.suggestedObjectives??e.suggestedObjectives??[],es=_e?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),ts=_e?.suggestedQuestions??e.suggestedQuestions??[],ge=_e?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),Ke=_e?.quizGenTimeLimit??e.quizGenTimeLimit??0,qt=_e?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),pe=_e?.savingQuiz??e.savingQuiz??!1,qe=_e?.setSavingQuiz??e.setSavingQuiz??(()=>{}),Ze=_e?.quizGeneratorClassId??e.quizGeneratorClassId??null,Xe=e.classBatch??t,mt=Xe?.batchPicker??e.batchPicker??null,rt=Xe?.setBatchPicker??e.setBatchPicker??(()=>{}),It=Xe?.batchPickerLesson??e.batchPickerLesson??"",Gt=Xe?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),zs=Xe?.batchPickerDate??e.batchPickerDate??"",Wr=Xe?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),Ls=Xe?.batchPickerTargetClass??e.batchPickerTargetClass??"",qr=Xe?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),Gr=Xe?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Rs=e.studentNotificationsHook??t,Qr=Rs?.selectedNotificationForModal??e.selectedNotificationForModal??null,Jr=Rs?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return r.jsxs(f.Suspense,{fallback:null,children:[r.jsx(Vb,{show:i,onClose:()=>o(!1),lang:n,handleImportFile:a,importError:l,importSuccess:c,isImporting:d,downloadCSVTemplate:u}),r.jsx(Hb,{isCourseWizardOpen:rn,setIsCourseWizardOpen:Rn,lang:n,wizardStep:_n,setWizardStep:On,wizardIsSubmitting:on,wizardCourseTitle:Dn,setWizardCourseTitle:an,wizardCourseDescription:Mn,setWizardCourseDescription:$n,wizardCourseCategory:Fn,setWizardCourseCategory:Tt,wizardCourseTimeline:ln,setWizardCourseTimeline:Wt,wizardCourseContent:Bn,setWizardCourseContent:Un,addToast:m,wizardIsGeneratingOutline:Pt,handleGenerateOutline:cn,handleDeployWizardCourse:dn}),r.jsx(Wb,{isImportLessonsOpen:p,setIsImportLessonsOpen:h,lang:n,importStatus:x,setIsDraggingImport:g,handleCSVFileChange:b,handleImportFileChange:w,downloadCsvTemplate:y,downloadCourseTemplate:S,packagePreview:C,handlePackageImportSubmit:k,packageDuplicate:v,handlePackageDuplicateDismiss:N,isDraggingImport:O,previewImportData:D,setPreviewImportData:_,setImportStatus:T,importProgress:z,importProgressTotal:R,importErrorMsg:$,setImportErrorMsg:I,handleCSVImportSubmit:B}),r.jsx(qb,{isQuizGeneratorOpen:Vn,setIsQuizGeneratorOpen:Hn,lessons:H,quizGenMode:Wn,setQuizGenMode:qn,quizGenSelectedLessonId:Gn,setQuizGenSelectedLessonId:Qn,quizGenTopic:Jn,setQuizGenTopic:Kn,isGeneratingSuggestions:Yn,setIsGeneratingSuggestions:Zn,suggestedObjectives:Xn,setSuggestedObjectives:es,suggestedQuestions:ts,setSuggestedQuestions:ge,quizGenTimeLimit:Ke,setQuizGenTimeLimit:qt,savingQuiz:pe,setSavingQuiz:qe,quizGeneratorClassId:Ze,fetchClassDashboard:A}),r.jsx(Gb,{showProcessLogs:G,setShowProcessLogs:E,processLogsContent:W,t:s}),r.jsx(Qb,{isOpen:Y,onClose:()=>K(!1),vfsNodes:V,currentVfsParent:U,setCurrentVfsParent:j,cloudDrivePreviewNode:ne,setCloudDrivePreviewNode:fe}),r.jsx(Jb,{isSystemResourceLibraryOpen:je,setIsSystemResourceLibraryOpen:X,lang:n,systemResourceTab:me,setSystemResourceTab:ke,selectedLibraryResourceId:Se,setSelectedLibraryResourceId:M,vfsNodes:V,currentVfsParent:U,setCurrentVfsParent:j,cloudDrivePreviewNode:ne,setCloudDrivePreviewNode:fe,loadingLibraryResources:Z,libraryResources:ee,fetchLibraryResources:te}),r.jsx(Kb,{batchPicker:mt,setBatchPicker:rt,batchPickerLesson:It,setBatchPickerLesson:Ge=>Gt(typeof Ge=="function"?Ge(It):Ge),batchPickerDate:zs,setBatchPickerDate:Ge=>Wr(typeof Ge=="function"?Ge(zs):Ge),batchPickerTargetClass:Ls,setBatchPickerTargetClass:Ge=>qr(typeof Ge=="function"?Ge(Ls):Ge),lessons:H,classes:ce,expandedClassId:oe,confirmBatchPicker:Gr,lang:n}),r.jsx(Yb,{isExportWeightModalOpen:xe,setIsExportWeightModalOpen:ie,lang:n,quizzesWeight:Pe,setQuizzesWeight:ze,assignmentsWeight:ue,setAssignmentsWeight:re,handleQuizzesWeightChange:P,handleAssignmentsWeightChange:L,customCategoryOverrides:F,setCustomCategoryOverrides:q,classDashboardMap:J,exportClassId:be,exportClassName:se,csvPreviewData:ye,handleExportGrades:$e}),r.jsx(Zb,{notification:Qr,onClose:()=>Jr(null),lang:n,onOpenWorkspace:Ge=>{Fe(Ge),Ce("assignment"),We({}),He("quiz")}}),r.jsx(Xb,{isOpen:Et,onClose:()=>et(!1),lang:n,onSeedSuccess:jt,onJumpTab:Ge=>Vt(Ge)}),Ln&&r.jsx(e0,{onClose:()=>Ht(!1),lang:n})]})}const n0="openlearn_live_classroom_sync";class yd{constructor(t=n0,n,s){this.channel=null,this.isDestroyed=!1,this.messageListeners=[],this.lessonId=null,this.classId=null,this.socketBoundTo=null,this.offSocketReady=null,this.handleRemoteSync=i=>{this.isDestroyed||!i?.message||this.lessonId&&i.lessonId&&i.lessonId!==this.lessonId||this.emitToListeners(i.message)},this.lessonId=n||null,this.classId=s||null,typeof window<"u"&&typeof window.BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(t),this.channel.onmessage=i=>{this.isDestroyed||!i.data||this.emitToListeners(i.data)}),this.offSocketReady=Yo(()=>this.ensureSocketBound())}ensureSocketBound(){if(this.isDestroyed)return;const t=lt();!t||t===this.socketBoundTo||(this.unbindSocket(),t.on("classroom:sync_message",this.handleRemoteSync),this.socketBoundTo=t)}unbindSocket(){this.socketBoundTo&&(this.socketBoundTo.off("classroom:sync_message",this.handleRemoteSync),this.socketBoundTo=null)}setLessonContext(t,n){this.lessonId=t,n!==void 0&&(this.classId=n)}emitToListeners(t){this.messageListeners.forEach(n=>{try{n(t)}catch(s){console.error("[ClassroomSyncChannel] Listener error:",s)}})}onMessage(t){return this.ensureSocketBound(),this.messageListeners.push(t),()=>{this.messageListeners=this.messageListeners.filter(n=>n!==t)}}postMessage(t){if(this.isDestroyed)return;if(this.ensureSocketBound(),this.channel)try{this.channel.postMessage(t)}catch(s){console.warn("[ClassroomSyncChannel] Failed to post message to BroadcastChannel:",s)}const n=lt();if(n&&this.lessonId)try{n.emit("teacher-sync-message",{lessonId:this.lessonId,message:t})}catch(s){console.warn("[ClassroomSyncChannel] Failed to emit socket sync message:",s)}}broadcastChangeLesson(t){this.lessonId=t,this.postMessage({type:"TEACHER_CHANGE_LESSON",payload:{lessonId:t,classId:this.classId}});const n=lt();n&&t&&n.emit("teacher-broadcast-lesson",{lessonId:t,classId:this.classId})}broadcastChangeSegment(t){this.postMessage({type:"TEACHER_CHANGE_SEGMENT",payload:{segmentId:t,lessonId:this.lessonId}});const n=lt();n&&this.lessonId&&t&&n.emit("teacher-broadcast-segment",{lessonId:this.lessonId,activeSegmentId:t})}broadcastChangeTab(t){this.postMessage({type:"TEACHER_CHANGE_TAB",payload:{tab:t,lessonId:this.lessonId}});const n=lt();n&&this.lessonId&&n.emit("teacher-broadcast-tab",{lessonId:this.lessonId,tab:t})}broadcastLockClass(t){this.postMessage({type:"TEACHER_LOCK_CLASS",payload:{locked:t,lessonId:this.lessonId,classId:this.classId}});const n=lt();n&&this.lessonId&&n.emit("teacher-broadcast-lock",{lessonId:this.lessonId,locked:t,classId:this.classId})}broadcastPickStudent(t,n){this.postMessage({type:"TEACHER_PICK_STUDENT",payload:{studentId:t,studentName:n}});const s=lt();s&&s.emit("teacher-pick-student",{studentId:t,studentName:n,lessonId:this.lessonId,classId:this.classId})}broadcastSyncTimer(t,n){this.postMessage({type:"TEACHER_SYNC_TIMER",payload:{timeRemaining:t,isRunning:n,lessonId:this.lessonId}})}broadcastCountdown(t){this.postMessage({type:"TEACHER_BROADCAST_COUNTDOWN",payload:t}),this.broadcastSyncTimer(t.timeRemaining,t.isRunning)}broadcastPingStudent(t,n){this.postMessage({type:"TEACHER_PING_STUDENT",payload:{studentId:t,message:n}});const s=lt();s&&this.lessonId&&s.emit("teacher-ping-student",{studentId:t,lessonId:this.lessonId,message:n})}broadcastFullscreen(t,n){const s=n||this.lessonId||void 0;this.postMessage({type:"TEACHER_BROADCAST_FULLSCREEN",payload:{elementId:t,lessonId:s}});const i=lt();i&&s&&i.emit("teacher-broadcast-fullscreen",{elementId:t,lessonId:s,classId:this.classId})}acknowledgePick(t){this.postMessage({type:"STUDENT_ACKNOWLEDGE_PICK",payload:{studentId:t}});const n=lt();n&&n.emit("student-acknowledge-pick",{studentId:t,lessonId:this.lessonId})}sendHeartbeat(t){this.postMessage({type:"STUDENT_HEARTBEAT",payload:{studentId:t,timestamp:Date.now()}})}destroy(){this.isDestroyed=!0,this.messageListeners=[],this.offSocketReady?.(),this.offSocketReady=null,this.unbindSocket(),this.channel&&(this.channel.close(),this.channel=null)}}async function s0(e){const t=await fetch(`/api/students/${e}/read_notifications`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function r0(e,t){await fetch(`/api/students/${e}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:t})})}async function i0(e,t){await fetch(`/api/students/${e}/progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function o0(e,t){const n=await fetch(`/api/classes/${e}/lessons/${t}/progress`);return n.ok?{ok:!0,data:await n.json()}:{ok:!1}}async function a0(e){const t=await fetch(`/api/students/${e}/progress`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}function l0(e,t,n=typeof window<"u"?window:null){const s=f.useRef(t);s.current=t,f.useEffect(()=>{if(!n)return;const i=o=>{const a=o;s.current?.(a.detail,a)};return n.addEventListener(e,i),()=>{n.removeEventListener(e,i)}},[e,n])}function c0(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const t=new e,n=t.currentTime,s=t.createOscillator(),i=t.createGain();s.type="sine",s.frequency.setValueAtTime(587.33,n),s.frequency.exponentialRampToValueAtTime(880,n+.3),i.gain.setValueAtTime(.25,n),i.gain.exponentialRampToValueAtTime(.001,n+.8),s.connect(i),i.connect(t.destination),s.start(n),s.stop(n+.8)}catch{}}function d0({lessonId:e,lang:t="zh",syncChannel:n}){const[s,i]=f.useState(null),[o,a]=f.useState(!1),[l,c]=f.useState(!0),[d,u]=f.useState(!1),m=f.useRef(s);m.current=s,f.useEffect(()=>{if(!e)return;let y=null,S;try{y=n||new yd,S=y.onMessage(N=>{N.type==="TEACHER_BROADCAST_COUNTDOWN"?i(N.payload):N.type==="TEACHER_SYNC_TIMER"&&i(O=>O?{...O,timeRemaining:N.payload.timeRemaining,isRunning:N.payload.isRunning,endsAt:N.payload.isRunning?Date.now()+N.payload.timeRemaining*1e3:null}:{lessonId:e,totalDuration:Math.max(300,N.payload.timeRemaining),timeRemaining:N.payload.timeRemaining,isRunning:N.payload.isRunning,isPaused:!1,label:t==="zh"?"⏱️ 课堂限时任务":"⏱️ Timed Task",endsAt:N.payload.isRunning?Date.now()+N.payload.timeRemaining*1e3:null,updatedAt:Date.now()})})}catch{}(async()=>{try{const N=await fetch(`/api/classroom/sessions/${e}/countdown`);if(N.ok){const O=await N.json();O.success&&O.countdown&&i(O.countdown)}}catch{}})();let k=null;const v=Yo(N=>{const O=D=>{!D||D.lessonId&&D.lessonId!==e||i(D)};k?.(),N.on("classroom:countdown_updated",O),k=()=>N.off("classroom:countdown_updated",O)});return()=>{S?.(),v(),k?.(),!n&&typeof y?.destroy=="function"&&y.destroy()}},[e,t]),l0("openlearn:countdown:updated",y=>{y&&i(y)});const p=f.useRef(null);if(f.useEffect(()=>{!s?.isRunning||!s.endsAt||p.current!==s.endsAt&&(p.current=s.endsAt,u(!1))},[s?.isRunning,s?.endsAt]),f.useEffect(()=>{if(!s||!s.isRunning||!s.endsAt)return;const y=setInterval(()=>{const S=m.current;if(!S||!S.isRunning||!S.endsAt)return;const C=Date.now(),k=Math.max(0,Math.round((S.endsAt-C)/1e3));if(k!==S.timeRemaining){const v={...S,timeRemaining:k,updatedAt:C};k<=0&&(v.isRunning=!1,v.isPaused=!1,v.endsAt=null,l&&!d&&(c0(),u(!0))),i(v);try{window.dispatchEvent(new CustomEvent("openlearn:student:countdown_tick",{detail:{timeRemaining:k,totalDuration:S.totalDuration,label:S.label}}))}catch{}}},500);return()=>clearInterval(y)},[s?.isRunning,s?.endsAt,l,d]),!s||s.timeRemaining===0&&!s.isRunning&&!d)return null;const h=y=>{const S=Math.floor(y/60),C=y%60,k=v=>v.toString().padStart(2,"0");return`${k(S)}:${k(C)}`},x=s.totalDuration>0?Math.min(100,Math.max(0,s.timeRemaining/s.totalDuration*100)):0,g=s.timeRemaining>0&&s.timeRemaining<=60,b=s.timeRemaining>60&&s.timeRemaining<=180,w=s.timeRemaining===0;return r.jsx("aside",{id:"student-classroom-countdown-banner","aria-label":t==="zh"?"课堂倒计时通知":"Classroom Countdown Alert",className:`fixed top-4 right-6 z-50 transition-all duration-300 select-none ${o?"w-auto":"w-72 sm:w-80"}`,children:r.jsxs("div",{className:`bg-surface/95 backdrop-blur-md border rounded-2xl shadow-2xl p-3 flex flex-col gap-2 transition-all ${g?"border-rose-500/80 shadow-rose-500/20":b?"border-amber-500/80 shadow-amber-500/20":w?"border-emerald-500/80 shadow-emerald-500/20":"border-theme shadow-primary-theme/10"}`,children:[r.jsxs("div",{className:"flex items-center justify-between gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx("span",{className:`p-1 rounded-lg text-white shrink-0 ${g?"bg-rose-500 animate-pulse":b?"bg-amber-500":w?"bg-emerald-500":"bg-primary-theme"}`,children:r.jsx(Es,{size:12,className:s.isRunning?"animate-spin":"",style:{animationDuration:"6s"}})}),r.jsx("span",{className:"text-xs font-bold text-main truncate",children:s.label||(t==="zh"?"课堂任务":"Task")})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{type:"button",onClick:()=>c(!l),className:"p-1 rounded-md text-muted hover:text-main text-xs transition-colors cursor-pointer",title:l?"提示音已开启":"提示音已静音",children:l?r.jsx(eg,{size:12}):r.jsx(tg,{size:12})}),r.jsx("button",{type:"button",onClick:()=>a(!o),className:"p-1 rounded-md text-muted hover:text-main text-xs transition-colors cursor-pointer",title:o?"展开":"收起",children:o?r.jsx(Nn,{size:12}):r.jsx(ng,{size:12})})]})]}),!o&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-baseline justify-between px-1",children:[r.jsx("span",{id:"student-countdown-digits",className:`text-2xl font-black font-mono tracking-widest ${g?"text-rose-500 animate-pulse":b?"text-amber-500":w?"text-emerald-500":"text-primary-theme"}`,children:h(s.timeRemaining)}),r.jsx("span",{className:"text-[11px] font-semibold text-muted",children:w?t==="zh"?"🎉 时间已截止!":"Time is up!":s.isPaused?t==="zh"?"⏸️ 老师已暂停计时":"Paused":t==="zh"?"与全班同步中":"Synced"})]}),r.jsx("div",{className:"w-full h-1.5 bg-surface-secondary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full transition-all duration-500 ${g?"bg-rose-500":b?"bg-amber-500":w?"bg-emerald-500":"bg-primary-theme"}`,style:{width:`${x}%`}})}),r.jsx(Me,{slot:"student.classroom.countdown",slotProps:{countdown:s,lang:t}})]})]})})}const u0=({isOpen:e,onClose:t,lessonId:n,studentName:s="我",lang:i="zh",coreQuestion:o,challengeQuestion:a,onSubmitSuccess:l})=>{const[c,d]=f.useState(null),[u,m]=f.useState(!1),[p,h]=f.useState(null),x=!!o,g=x&&!!a,[b,w]=f.useState(null),[y,S]=f.useState(5),[C,k]=f.useState(""),[v,N]=f.useState(""),[O,D]=f.useState(!1),[_,T]=f.useState(!1),z=()=>{if(!c||!o)return;const I=c===o.correctOption;h(I),m(!0)},R=async()=>{if(O)return;D(!0);const I=x?p?b?"challenge_done":"passed":"remediation":null;try{n&&await fetch(`/api/classroom/sessions/${n}/exit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:y,puzzledConcept:C.trim(),feedback:v.trim(),...x?{coreAnswer:c,isCorrect:p,tierLevel:I,challengeAnswer:b}:{}})}),T(!0),l?.()}catch{T(!0),l?.()}finally{D(!1)}},$=()=>{l?.(),t()};return e?r.jsx("div",{"data-testid":"adaptive-exit-ticket-modal",className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-fade-in select-none",children:r.jsxs("div",{className:"bg-surface rounded-3xl border border-indigo-500/40 p-6 w-full max-w-lg shadow-2xl flex flex-col gap-4 max-h-[92vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/80 pb-3 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-indigo-500 font-extrabold text-base",children:[r.jsx(at,{size:20}),r.jsx("span",{children:i==="zh"?"60 秒自适应结课通票 (Adaptive Exit Ticket)":"60s Adaptive Exit Ticket"})]}),r.jsx("button",{onClick:$,className:"text-muted hover:text-main rounded-lg p-1 cursor-pointer","aria-label":"Close",children:r.jsx(Oe,{size:18})})]}),_?r.jsxs("div",{className:"py-8 flex flex-col items-center justify-center text-center gap-3",children:[r.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 flex items-center justify-center",children:r.jsx(at,{size:32})}),r.jsx("h3",{className:"text-base font-black text-main",children:i==="zh"?"结课通票提交成功!":"Exit Ticket Submitted!"}),r.jsx("p",{className:"text-xs text-muted max-w-xs",children:i==="zh"?"你的学情反馈与梯级作答已实时同步至教师大屏与个人课后学情卡。":"Feedback synced to classroom dashboard."}),r.jsx("button",{onClick:$,className:"mt-2 px-6 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs transition-colors cursor-pointer",children:i==="zh"?"完成":"Done"})]}):r.jsxs("div",{className:"flex flex-col gap-4 text-xs",children:[o&&r.jsxs("div",{className:"bg-surface-secondary/70 p-4 rounded-2xl border border-border/60 flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"font-extrabold text-main flex items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"px-2 py-0.5 rounded bg-indigo-500 text-white font-mono text-[10px]",children:"必做诊断"}),r.jsx("span",{children:"1. 核心概念过关题"})]}),u&&r.jsx("span",{className:`text-2xs font-bold px-2 py-0.5 rounded-full ${p?"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300":"bg-rose-100 text-rose-700 dark:bg-rose-950 dark:text-rose-300"}`,children:p?"✓ 概念通关":"需巩固"})]}),r.jsx("p",{className:"text-main font-semibold leading-relaxed",children:o.question}),r.jsx("div",{className:"space-y-1.5",children:o.options.map(I=>r.jsxs("button",{type:"button",disabled:u,onClick:()=>d(I.key),className:`w-full p-2.5 rounded-xl border text-left flex items-start gap-2.5 transition-all cursor-pointer ${c===I.key?"border-indigo-500 bg-indigo-50/50 dark:bg-indigo-950/40 font-bold text-indigo-700 dark:text-indigo-300":"border-border/60 hover:bg-surface text-main"} ${u?"cursor-default opacity-90":""}`,children:[r.jsx("span",{className:"w-5 h-5 rounded-full bg-surface-secondary border border-border flex items-center justify-center text-[10px] font-mono shrink-0",children:I.key}),r.jsx("span",{className:"text-2xs leading-relaxed",children:I.text})]},I.key))}),!u&&r.jsxs("button",{type:"button",disabled:!c,onClick:z,className:`mt-1 py-1.5 px-3 rounded-xl font-bold text-2xs transition-colors flex items-center justify-center gap-1 ${c?"bg-indigo-600 hover:bg-indigo-700 text-white cursor-pointer shadow-xs":"bg-surface-secondary text-muted cursor-not-allowed"}`,children:[r.jsx("span",{children:"确认本题答案"}),r.jsx(Cn,{size:12})]}),u&&p&&g&&a&&r.jsxs("div",{"data-testid":"challenge-branch",className:"mt-2 p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-800 dark:text-emerald-200 space-y-2 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-2xs",children:[r.jsx(yt,{size:14,className:"text-emerald-600 dark:text-emerald-400"}),r.jsx("span",{children:"太棒了!已解锁【Lv.2 进阶探究挑战题】(冲刺思维勋章)"})]}),r.jsx("p",{className:"text-2xs font-semibold text-main",children:a.prompt}),r.jsx("div",{className:"grid grid-cols-1 gap-1",children:a.options.map(I=>r.jsxs("button",{type:"button",onClick:()=>w(I.key),className:`p-2 rounded-lg border text-left text-2xs transition-colors ${b===I.key?"border-emerald-500 bg-emerald-100/60 dark:bg-emerald-950 font-bold text-emerald-800 dark:text-emerald-200":"border-emerald-500/20 bg-surface text-main hover:bg-surface-secondary"}`,children:[r.jsxs("span",{className:"font-mono font-bold mr-1.5",children:[I.key,"."]}),r.jsx("span",{children:I.text})]},I.key))})]}),u&&!p&&r.jsxs("div",{"data-testid":"scaffold-branch",className:"mt-2 p-3 rounded-xl bg-amber-500/10 border border-amber-500/30 text-amber-800 dark:text-amber-200 space-y-1.5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-2xs text-amber-600 dark:text-amber-400",children:[r.jsx(Rr,{size:14}),r.jsx("span",{children:"核心概念支架提示卡"})]}),r.jsx("p",{className:"text-2xs leading-relaxed",children:o.scaffoldHint}),r.jsxs("p",{className:"text-3xs text-muted",children:["解析:",o.explanation]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"2. 今日课堂综合掌握感评估":"Rate Today Lesson"}),r.jsxs("div",{className:"flex items-center gap-2",children:[[1,2,3,4,5].map(I=>r.jsx("button",{type:"button",onClick:()=>S(I),"aria-label":`${I} 星`,"aria-pressed":I===y,className:"p-0.5 text-xl transition-transform hover:scale-125 cursor-pointer",children:r.jsx(vr,{size:20,className:I<=y?"text-amber-400 fill-amber-400":"text-slate-300"})},I)),r.jsxs("span",{className:"text-2xs font-bold text-amber-700 dark:text-amber-400 font-mono ml-1",children:[y,".0 星"]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"3. 今天最困惑或没完全搞懂的知识点/卡点是什么?":"Most Confused Concept"}),r.jsx("input",{type:"text",value:C,onChange:I=>k(I.target.value),placeholder:i==="zh"?"用几个关键词概括本节课的卡点...":"e.g. friction boundary...",className:"w-full px-3 py-2 bg-surface-secondary border border-border rounded-xl text-xs text-main focus:outline-hidden focus:ring-2 focus:ring-indigo-500"})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("label",{className:"text-2xs font-bold text-main",children:i==="zh"?"4. 给老师的一句小建议 (选填)":"Feedback (Optional)"}),r.jsx("input",{type:"text",value:v,onChange:I=>N(I.target.value),placeholder:i==="zh"?"例如:希望能补充一道微元积分经典例题...":"Feedback...",className:"w-full px-3 py-1.5 bg-surface-secondary border border-border rounded-xl text-xs text-main focus:outline-hidden focus:ring-2 focus:ring-indigo-500"})]}),r.jsx("button",{type:"button",disabled:O,onClick:R,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white font-extrabold rounded-xl transition-colors cursor-pointer shadow-md text-xs flex items-center justify-center gap-1.5",children:r.jsx("span",{children:O?i==="zh"?"正在提交...":"Submitting...":i==="zh"?"提交自适应结课通票":"Submit Exit Ticket"})})]})]})}):null};class ro extends Error{constructor(t,n){super(n),this.name="ApiError",this.status=t}}async function Te(e,t={}){const n=await fetch(e,{credentials:"same-origin",...t,headers:{...t.body?{"Content-Type":"application/json"}:{},...t.headers??{}}}),s=await n.text();let i=null;try{i=s?JSON.parse(s):null}catch{i=null}if(!n.ok)throw new ro(n.status,i?.error||`HTTP ${n.status}`);return i}const Ot={listQuestionTypes:()=>Te("/api/assessment-question-types"),list:(e={})=>{const t=new URLSearchParams;e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status);const n=t.toString();return Te(`/api/assessments${n?`?${n}`:""}`)},get:e=>Te(`/api/assessments/${encodeURIComponent(e)}`),create:e=>Te("/api/assessments",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>Te(`/api/assessments/${encodeURIComponent(e)}`,{method:"DELETE"}),replaceItems:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}/items`,{method:"PUT",body:JSON.stringify({items:t})}),listBank:e=>Te(`/api/question-bank${e?`?type=${encodeURIComponent(e)}`:""}`),createBankItem:e=>Te("/api/question-bank",{method:"POST",body:JSON.stringify(e)}),removeBankItem:e=>Te(`/api/question-bank/${encodeURIComponent(e)}`,{method:"DELETE"}),getAssignments:e=>Te(`/api/assessments/${encodeURIComponent(e)}/assignments`),getTeacherView:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/teacher-view`),publish:(e,t)=>Te(`/api/assessments/${encodeURIComponent(e)}/publish`,{method:"POST",body:JSON.stringify(t)}),closeAssignment:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/close`,{method:"POST"}),releaseScores:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/release`,{method:"POST"}),syncGradebook:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/sync-gradebook`,{method:"POST"}),getAssignmentProgress:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/progress`),listAttempts:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/attempts`),stats:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/stats`),gradeAnswer:(e,t,n)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/grade`,{method:"PUT",body:JSON.stringify(n)}),aiSuggestGrade:(e,t)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/ai-suggest`,{method:"POST"}),regrade:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/regrade`,{method:"POST"}),exportCsvUrl:e=>`/api/assessment-assignments/${encodeURIComponent(e)}/export?format=csv`,startClassroomAssessment:(e,t)=>Te(`/api/classroom/sessions/${encodeURIComponent(e)}/assessment`,{method:"POST",body:JSON.stringify(t)}),getClassroomAssessmentProgress:(e,t)=>Te(`/api/classroom/sessions/${encodeURIComponent(e)}/assessment-progress${t?`?assignmentId=${encodeURIComponent(t)}`:""}`),myAssessments:()=>Te("/api/me/assessments"),startAttempt:e=>Te(`/api/assessment-assignments/${encodeURIComponent(e)}/attempts`,{method:"POST"}),reportProctor:(e,t)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/proctor`,{method:"PUT",body:JSON.stringify(t)}),saveAnswer:(e,t,n)=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({answer:n})}),submitAttempt:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/submit`,{method:"POST"}),attemptResult:e=>Te(`/api/assessment-attempts/${encodeURIComponent(e)}/result`)};class h0{constructor(){this.store=St(()=>({items:new Map}))}register(t,n){if(!t?.type||typeof t.type!="string"||!t.type.trim())throw new Error("[AssessmentQuestionTypeUiRegistry] type is required");if(typeof t.Editor!="function")throw new Error(`[AssessmentQuestionTypeUiRegistry] ${t.type}: Editor must be a component`);const s=t.type.trim();if(this.store.getState().items.has(s))throw new Error(`[AssessmentQuestionTypeUiRegistry] duplicate question type: ${s}`);this.store.setState(i=>{const o=new Map(i.items);return o.set(s,{config:{...t,type:s},pluginId:n||s}),{items:o}})}unregister(t,n){const s=this.store.getState().items.get(t);return!s||n!==void 0&&s.pluginId!==n?!1:(this.store.setState(i=>{const o=new Map(i.items);return o.delete(t),{items:o}}),!0)}clearOwned(t){const n=this.store.getState(),s=[...n.items.entries()].filter(([,i])=>i.pluginId===t);return s.length===0?0:(this.store.setState(()=>{const i=new Map(n.items);for(const[o]of s)i.delete(o);return{items:i}}),s.length)}get(t){return this.store.getState().items.get(t)?.config}list(){return[...this.store.getState().items.values()].map(t=>t.config)}subscribe(t){return this.store.subscribe(t)}getSnapshot(){return this.list()}}const kt=new h0,ks="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function f0(e){const t=e.options;return Array.isArray(t)?t.map(n=>String(n)):[]}function Cr({htmlFor:e,children:t}){return r.jsx("label",{htmlFor:e,className:"block text-xs font-semibold text-muted mb-1",children:t})}function wd({config:e,answerKey:t,onChange:n,lang:s,disabled:i,multiple:o,idPrefix:a}){const l=f0(e),c=o?Array.isArray(t?.indexes)?t.indexes.map(Number).filter(p=>Number.isInteger(p)):[]:typeof t?.index=="number"?[t.index]:[],d=p=>n({config:{...e,options:p},answerKey:t}),u=(p,h)=>{if(o){const x=h?[...new Set([...c,p])].sort((g,b)=>g-b):c.filter(g=>g!==p);n({config:e,answerKey:x.length>0?{indexes:x}:null})}else n({config:e,answerKey:{index:p}})},m=p=>String.fromCharCode(65+p);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("fieldset",{className:"space-y-1.5",children:[r.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:s==="zh"?"选项与正确答案":"Options & correct answer"}),l.map((p,h)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:o?"checkbox":"radio",id:`${a}-opt-${h}`,name:`${a}-answer`,checked:c.includes(h),disabled:i,onChange:x=>u(h,x.target.checked),"aria-label":`${s==="zh"?"把选项":"Mark option"} ${m(h)} ${s==="zh"?"标为正确答案":"as correct"}`,className:"shrink-0 accent-indigo-600"}),r.jsx("label",{htmlFor:`${a}-opt-${h}`,className:"sr-only",children:s==="zh"?`选项 ${m(h)}`:`Option ${m(h)}`}),r.jsx("span",{className:"text-xs font-bold text-muted w-4 shrink-0",children:m(h)}),r.jsx("input",{type:"text",value:p,disabled:i,"aria-label":s==="zh"?`选项 ${m(h)} 内容`:`Option ${m(h)} text`,onChange:x=>{const g=[...l];g[h]=x.target.value,d(g)},className:ks}),r.jsx("button",{type:"button",disabled:i||l.length<=2,onClick:()=>{const x=l.filter((g,b)=>b!==h);d(x),n({config:{...e,options:x},answerKey:null})},"aria-label":s==="zh"?`删除选项 ${m(h)}`:`Delete option ${m(h)}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 disabled:opacity-40 cursor-pointer shrink-0",children:r.jsx(_r,{size:13})})]},h))]}),r.jsxs("button",{type:"button",disabled:i,onClick:()=>d([...l,s==="zh"?`选项 ${m(l.length)}`:`Option ${m(l.length)}`]),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[r.jsx(Bo,{size:12}),s==="zh"?"添加选项":"Add option"]}),c.length===0&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"未设置正确答案:该题交卷后进入人工批改。":"No correct answer set: this item will need manual grading."})]})}const m0=e=>r.jsx(wd,{...e,multiple:!1,idPrefix:`sc-${e.lang}`}),p0=e=>r.jsx(wd,{...e,multiple:!0,idPrefix:`mc-${e.lang}`}),g0=({config:e,answerKey:t,onChange:n,lang:s,disabled:i})=>{const o=t?.value;return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:s==="zh"?"正确答案":"Correct answer"}),r.jsx("div",{className:"flex items-center gap-4",children:[{value:!0,label:String(e.trueLabel??(s==="zh"?"正确":"True"))},{value:!1,label:String(e.falseLabel??(s==="zh"?"错误":"False"))}].map(a=>r.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-main",children:[r.jsx("input",{type:"radio",name:`tf-${s}`,checked:o===a.value,disabled:i,onChange:()=>n({config:e,answerKey:{value:a.value}}),className:"accent-indigo-600"}),a.label]},String(a.value)))}),o===void 0&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"未设置正确答案:该题交卷后进入人工批改。":"No correct answer set."})]})};function x0(e){const t=e.blanks;return Array.isArray(t)?t:[]}function b0(e,t){const n=e?.blanks,s=[];for(let i=0;i<t;i++){const o=Array.isArray(n)?n[i]:void 0;s.push(Array.isArray(o)?o.join(" | "):"")}return s}const y0=({config:e,answerKey:t,onChange:n,lang:s,disabled:i})=>{const o=x0(e),a=b0(t,o.length),l=(c,d)=>{const u=d.map(h=>h.split("|").map(x=>x.trim()).filter(Boolean)),m=u.some(h=>h.length>0),p=c.map((h,x)=>u[x]??[]);n({config:{...e,blanks:c},answerKey:m&&p.every(h=>h.length>0)?{blanks:p}:null})};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs text-muted",children:s==="zh"?"每个空一行;可接受答案用 | 分隔(任一命中即得分)。数值空按数值比较。":"One blank per row; separate accepted answers with |. Numeric blanks compare by value."}),o.map((c,d)=>r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_1fr_auto] gap-2 items-center",children:[r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:`fb-accepted-${c.id}`,children:s==="zh"?`第 ${d+1} 空的可接受答案`:`Accepted answers for blank ${d+1}`}),r.jsx("input",{id:`fb-accepted-${c.id}`,type:"text",value:a[d]??"",disabled:i,onChange:u=>{const m=[...a];m[d]=u.target.value,l(o,m)},placeholder:s==="zh"?"光合作用 | photosynthesis":"photosynthesis",className:ks})]}),r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:`fb-type-${c.id}`,children:s==="zh"?"作答类型":"Answer type"}),r.jsxs("select",{id:`fb-type-${c.id}`,value:c.inputType??"text",disabled:i,onChange:u=>{const m=o.map((p,h)=>h===d?{...p,inputType:u.target.value}:p);l(m,a)},className:ks,children:[r.jsx("option",{value:"text",children:s==="zh"?"文本":"Text"}),r.jsx("option",{value:"numeric",children:s==="zh"?"数值":"Numeric"})]})]}),r.jsx("button",{type:"button",disabled:i||o.length<=1,onClick:()=>{const u=o.filter((m,p)=>p!==d);l(u,a.filter((m,p)=>p!==d))},"aria-label":s==="zh"?`删除第 ${d+1} 空`:`Delete blank ${d+1}`,className:"p-1 mt-4 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 disabled:opacity-40 cursor-pointer justify-self-start",children:r.jsx(_r,{size:13})})]},c.id)),r.jsxs("button",{type:"button",disabled:i,onClick:()=>{const c=`b${o.length+1}-${Date.now().toString(36)}`;l([...o,{id:c,inputType:"text"}],[...a,""])},className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[r.jsx(Bo,{size:12}),s==="zh"?"添加空位":"Add blank"]}),!t&&r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:s==="zh"?"每个空都填了可接受答案后才会启用自动判分。":"Fill every blank to enable auto-grading."})]})},w0=({config:e,onChange:t,lang:n,disabled:s})=>r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:"sa-placeholder",children:n==="zh"?"作答占位提示":"Placeholder"}),r.jsx("input",{id:"sa-placeholder",type:"text",value:String(e.placeholder??""),disabled:s,onChange:i=>t({config:{...e,placeholder:i.target.value},answerKey:null}),className:ks})]}),r.jsxs("div",{children:[r.jsx(Cr,{htmlFor:"sa-maxlength",children:n==="zh"?"最多字数":"Max length"}),r.jsx("input",{id:"sa-maxlength",type:"number",min:1,value:Number(e.maxLength??2e3),disabled:s,onChange:i=>t({config:{...e,maxLength:Number(i.target.value)||2e3},answerKey:null}),className:ks})]}),r.jsx("p",{className:"col-span-2 text-xs text-muted",children:n==="zh"?"简答题不自动判分,交卷后进入人工批改队列。":"Short answers are always graded manually."})]}),ea="w-full px-3 py-2 border border-theme rounded-xl text-sm bg-surface text-main focus:outline-none focus:ring-2 focus:ring-indigo-500";function v0(e){const t=e.options;return Array.isArray(t)?t.map(n=>String(n)):[]}function S0(e){return String.fromCharCode(65+e)}const vd=({config:e,value:t,onChange:n,lang:s,readOnly:i,multiple:o,name:a})=>{const l=v0(e),c=typeof t=="number"?t:null,d=Array.isArray(t)?t.map(Number).filter(u=>Number.isInteger(u)):[];return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"sr-only",children:o?s==="zh"?"可多选":"Select all that apply":s==="zh"?"单选":"Pick one"}),l.map((u,m)=>{const p=o?d.includes(m):c===m;return r.jsxs("label",{className:`flex items-start gap-2.5 px-3 py-2 rounded-xl border cursor-pointer transition-colors ${p?"border-indigo-400 bg-indigo-50 text-main dark:bg-indigo-950/40":"border-theme bg-surface text-main hover:border-indigo-300"} ${i?"cursor-default":""}`,children:[r.jsx("input",{type:o?"checkbox":"radio",name:a,checked:p,disabled:i,onChange:h=>{if(!i)if(o){const x=h.target.checked?[...new Set([...d,m])].sort((g,b)=>g-b):d.filter(g=>g!==m);n(x)}else n(m)},className:"mt-0.5 accent-indigo-600 shrink-0"}),r.jsxs("span",{className:"text-sm leading-snug",children:[r.jsxs("span",{className:"font-bold text-muted mr-1.5",children:[S0(m),"."]}),u]})]},m)}),r.jsx("p",{className:"text-2xs text-muted",children:o?s==="zh"?"可多选:全对得满分,少选按命中比例给分,错选不得分。":"Select all: full marks for all correct, partial credit for fewer, zero for wrong picks.":s==="zh"?"单选题":"Single choice"})]})},j0=e=>r.jsx(vd,{...e,multiple:!1,name:"answer-single"}),k0=e=>r.jsx(vd,{...e,multiple:!0,name:"answer-multi"}),C0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=[{v:!0,label:String(e.trueLabel??(s==="zh"?"正确":"True"))},{v:!1,label:String(e.falseLabel??(s==="zh"?"错误":"False"))}];return r.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[r.jsx("legend",{className:"sr-only",children:s==="zh"?"判断":"True or false"}),o.map(a=>r.jsxs("label",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-xl border text-sm cursor-pointer ${t===a.v?"border-indigo-400 bg-indigo-50 text-main dark:bg-indigo-950/40":"border-theme bg-surface text-main hover:border-indigo-300"}`,children:[r.jsx("input",{type:"radio",name:"answer-tf",checked:t===a.v,disabled:i,onChange:()=>!i&&n(a.v),className:"accent-indigo-600"}),a.label]},String(a.v)))]})},N0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=Array.isArray(e.blanks)?e.blanks:[],a=Array.isArray(t)?t:o.map(()=>"");return r.jsx("div",{className:"space-y-2",children:o.map((l,c)=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`blank-${l.id}`,className:"block text-2xs font-semibold text-muted mb-1",children:s==="zh"?`第 ${c+1} 空`:`Blank ${c+1}`}),r.jsx("input",{id:`blank-${l.id}`,type:l.inputType==="numeric"?"number":"text",value:String(a[c]??""),disabled:i,placeholder:l.placeholder,onChange:d=>{const u=o.map((m,p)=>p===c?d.target.value:String(a[p]??""));n(u)},className:ea})]},l.id))})},E0=({config:e,value:t,onChange:n,lang:s,readOnly:i})=>{const o=typeof e.maxLength=="number"?e.maxLength:2e3,a=typeof t=="string"?t:"";return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"short-answer",className:"sr-only",children:s==="zh"?"作答内容":"Your answer"}),r.jsx("textarea",{id:"short-answer",rows:6,value:a,maxLength:o,disabled:i,placeholder:String(e.placeholder??(s==="zh"?"请输入你的作答":"Type your answer")),onChange:l=>n(l.target.value),className:`${ea} resize-y`}),r.jsxs("p",{className:"text-2xs text-muted mt-1 text-right",children:[a.length,"/",o]})]})},T0=({value:e,onChange:t,lang:n,readOnly:s})=>{const[i,o]=De.useState(()=>{try{return e==null?"":JSON.stringify(e)}catch{return""}});return r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fallback-answer",className:"block text-2xs font-semibold text-muted mb-1",children:n==="zh"?"作答(JSON)":"Answer (JSON)"}),r.jsx("textarea",{id:"fallback-answer",rows:4,value:i,disabled:s,onChange:a=>{o(a.target.value);try{t(a.target.value.trim()?JSON.parse(a.target.value):null)}catch{t(a.target.value)}},className:`${ea} resize-y font-mono`})]})},ll=["选项 A","选项 B","选项 C","选项 D"];let cl=!1;function P0(){cl||(cl=!0,kt.register({type:"single_choice",label:{zh:"单选题",en:"Single choice"},category:"objective",supports:["quiz","exam","survey"],Editor:m0,Answer:j0,createDefaultConfig:()=>({options:[...ll]}),createDefaultAnswerKey:()=>({index:0})}),kt.register({type:"multiple_choice",label:{zh:"多选题",en:"Multiple choice"},category:"objective",supports:["quiz","exam","survey"],Editor:p0,Answer:k0,createDefaultConfig:()=>({options:[...ll]}),createDefaultAnswerKey:()=>({indexes:[0]})}),kt.register({type:"true_false",label:{zh:"判断题",en:"True / false"},category:"objective",supports:["quiz","exam","survey"],Editor:g0,Answer:C0,createDefaultConfig:()=>({trueLabel:"正确",falseLabel:"错误"}),createDefaultAnswerKey:()=>({value:!0})}),kt.register({type:"fill_blank",label:{zh:"填空题",en:"Fill in the blank"},category:"objective",supports:["quiz","exam","survey"],Editor:y0,Answer:N0,createDefaultConfig:()=>({blanks:[{id:"b1",inputType:"text"}]}),createDefaultAnswerKey:()=>null}),kt.register({type:"short_answer",label:{zh:"简答/论述",en:"Short answer"},category:"subjective",supports:["quiz","exam","survey"],Editor:w0,Answer:E0,createDefaultConfig:()=>({placeholder:"请输入你的作答",maxLength:2e3}),createDefaultAnswerKey:()=>null}))}P0();const I0=1500;function A0(e){if(e===null)return"—";const t=Math.max(0,e),n=Math.floor(t/60),s=t%60;return n>=60?`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function dl(e){return e==null||e===""?"(未作答)":Array.isArray(e)?e.length===0?"(未作答)":e.map(t=>String(t)).join(" | "):typeof e=="object"?JSON.stringify(e):String(e)}function z0({lang:e,onExit:t}){const n=e==="zh",[s,i]=f.useState({mode:"list"}),[o,a]=f.useState(null),[l,c]=f.useState(!1),[d,u]=f.useState(null),m=f.useCallback(async()=>{c(!0),u(null);try{const g=await Ot.myAssessments();a(g.items)}catch(g){u(g instanceof ro?g.message:String(g?.message??g))}finally{c(!1)}},[]);f.useEffect(()=>{s.mode==="list"&&m()},[s.mode,m]);const p=async g=>{u(null),c(!0);try{if(g.completed&&g.attempt){const b=await Ot.attemptResult(g.attempt.id);i({mode:"result",result:b})}else{const b=await Ot.startAttempt(g.assignmentId);i({mode:"answering",payload:b,answers:{...b.answers}})}}catch(b){u(b instanceof ro?b.message:String(b?.message??b))}finally{c(!1)}};if(s.mode==="answering")return r.jsx(ta,{lang:e,payload:s.payload,initialAnswers:s.answers,onSubmitted:g=>i({mode:"result",result:g}),onExit:()=>i({mode:"list"})});if(s.mode==="result")return r.jsx(na,{lang:e,result:s.result,onBack:()=>{i({mode:"list"}),m()}});const h=(o??[]).filter(g=>!g.completed),x=(o??[]).filter(g=>g.completed);return r.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[t&&r.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":n?"返回学习看板":"Back to dashboard",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("h1",{className:"text-base font-bold text-main flex items-center gap-2",children:[r.jsx(Ss,{size:17,className:"text-indigo-500"}),n?"我的测评":"My assessments"]}),r.jsx("p",{className:"text-xs text-muted",children:n?"按截止时间排序。作答过程自动保存,断线后可续答;超时以服务端时间为准。":"Sorted by deadline. Answers autosave and resume after reconnecting; timing is server-authoritative."})]}),r.jsxs("button",{type:"button",onClick:()=>void m(),disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[r.jsx(Lr,{size:13,className:l?"animate-spin":""}),n?"刷新":"Refresh"]})]}),d&&r.jsx("p",{role:"alert",className:"mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:d}),r.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-5",children:o===null&&l?r.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[r.jsx($t,{size:13,className:"animate-spin"}),n?"加载中…":"Loading…"]}):(o?.length??0)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-center",children:[r.jsx(Ss,{size:36,className:"text-muted opacity-40"}),r.jsx("p",{className:"text-sm font-semibold text-main",children:n?"暂无待完成测评":"No assessments yet"}),r.jsx("p",{className:"text-xs text-muted",children:n?"老师发布测评后会出现在这里。":"Published assessments will show up here."})]}):r.jsxs(r.Fragment,{children:[r.jsxs("section",{"aria-labelledby":"pending-heading",children:[r.jsxs("h2",{id:"pending-heading",className:"text-xs font-bold text-main mb-2",children:[n?"待完成":"To do","(",h.length,")"]}),h.length===0?r.jsx("p",{className:"text-xs text-muted",children:n?"没有待完成的测评。":"Nothing pending."}):r.jsx("ul",{"data-testid":"student-pending-list",className:"space-y-2",children:h.map(g=>r.jsx("li",{children:r.jsx(ul,{entry:g,lang:e,disabled:l,onOpen:()=>void p(g)})},g.assignmentId))})]}),x.length>0&&r.jsxs("section",{"aria-labelledby":"done-heading",children:[r.jsxs("h2",{id:"done-heading",className:"text-xs font-bold text-main mb-2",children:[n?"已完成":"Completed","(",x.length,")"]}),r.jsx("ul",{"data-testid":"student-completed-list",className:"space-y-2",children:x.map(g=>r.jsx("li",{children:r.jsx(ul,{entry:g,lang:e,disabled:l,onOpen:()=>void p(g)})},g.assignmentId))})]})]})})]})}function ul({entry:e,lang:t,disabled:n,onOpen:s}){const i=t==="zh",o=e.windowState==="after_close",a=e.windowState==="before_open",l=!e.completed&&(o||a),c=e.kind==="quiz"?i?"测试":"Quiz":e.kind==="exam"?i?"考试":"Exam":i?"问卷":"Survey";return r.jsxs("div",{"data-testid":`student-assessment-${e.assignmentId}`,className:"bg-surface border border-theme rounded-xl px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"font-bold text-sm text-main truncate",children:e.title}),r.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme text-2xs font-semibold text-main",children:c}),e.completed&&e.attempt?.needsManualReview&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-2xs font-semibold bg-amber-50 text-amber-700 border border-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800",children:i?"待批改":"Pending review"})]}),r.jsxs("div",{className:"flex items-center gap-3 text-2xs text-muted flex-wrap",children:[r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Es,{size:11}),o?i?"已截止":"Closed":a?i?"未开始":"Not open yet":e.closesAt?`${i?"截止":"Due"} ${new Date(e.closesAt).toLocaleString()}`:i?"不限时":"No deadline"]}),e.durationSec&&r.jsx("span",{children:i?`限时 ${Math.round(e.durationSec/60)} 分钟`:`${Math.round(e.durationSec/60)} min`}),e.completed&&e.attempt&&r.jsx("span",{children:e.attempt.score===null?i?"成绩待发布":"Score pending":`${i?"得分":"Score"} ${e.attempt.score}/${e.attempt.maxScore??"—"}`})]})]}),r.jsxs("button",{type:"button",onClick:s,disabled:n||l,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold shrink-0 ${l?"bg-surface-secondary text-muted border border-theme cursor-not-allowed":e.completed?"border border-theme text-main hover:bg-surface-secondary cursor-pointer":"bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer"}`,children:[!l&&!e.completed&&r.jsx(Ro,{size:12}),l?o?i?"已截止":"Closed":i?"未开始":"Not open":e.completed?i?"查看结果":"View result":i?"开始作答":"Start"]})]})}function ta({lang:e,payload:t,initialAnswers:n,onSubmitted:s,onExit:i}){const o=e==="zh",a=t.attempt.id,l=t.assignment.kind==="exam"||!!t.assignment.settings?.strictProctor,[c,d]=f.useState(n),[u,m]=f.useState(new Set),[p,h]=f.useState(t.attempt.remainingSeconds??null),[x,g]=f.useState(!1),[b,w]=f.useState(null),[y,S]=f.useState(null),[C,k]=f.useState(!!document.fullscreenElement),[v,N]=f.useState(0),[O,D]=f.useState(null),_=f.useRef({}),T=f.useRef(c),z=f.useRef(!1);T.current=c;const R=f.useCallback(async j=>{if(!(!l||z.current))try{N(G=>G+1),D({blur:o?"检测到窗口失去焦点,已记录监考日志!":"Window lost focus — logged to proctor record!",visibility_hidden:o?"检测到切换屏幕/应用,已记录监考日志!":"Screen/tab switched — logged to proctor record!",fullscreen_exit:o?"检测到退出全屏作答,已记录监考日志!":"Exited fullscreen — logged to proctor record!"}[j]),await Ot.reportProctor(a,{type:j})}catch{}},[a,l,o]);f.useEffect(()=>{if(!l)return;const j=()=>{document.visibilityState==="hidden"&&R("visibility_hidden")},V=()=>{R("blur")},G=()=>{const Y=!!document.fullscreenElement;k(Y),!Y&&!z.current&&R("fullscreen_exit")},E=Y=>{Y.preventDefault()},W=Y=>{Y.preventDefault()};return document.addEventListener("visibilitychange",j),window.addEventListener("blur",V),document.addEventListener("fullscreenchange",G),document.addEventListener("contextmenu",E),document.addEventListener("copy",W),document.addEventListener("cut",W),document.addEventListener("paste",W),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("blur",V),document.removeEventListener("fullscreenchange",G),document.removeEventListener("contextmenu",E),document.removeEventListener("copy",W),document.removeEventListener("cut",W),document.removeEventListener("paste",W)}},[l,R]);const $=async()=>{try{document.fullscreenElement||await document.documentElement.requestFullscreen()}catch{}},I=f.useCallback(async j=>{try{await Ot.saveAnswer(a,j,T.current[j]??null),S(Date.now()),m(V=>{const G=new Set(V);return G.delete(j),G})}catch(V){w(V?.message??String(V))}},[a]),B=(j,V)=>{d(G=>({...G,[j]:V})),m(G=>new Set(G).add(j)),_.current[j]&&clearTimeout(_.current[j]),_.current[j]=setTimeout(()=>void I(j),I0)},H=f.useCallback(async()=>{if(!z.current){z.current=!0,g(!0),w(null);try{for(const G of Object.keys(_.current))_.current[G]&&clearTimeout(_.current[G]);const j=[...u];await Promise.all(j.map(G=>Ot.saveAnswer(a,G,T.current[G]??null)));const V=await Ot.submitAttempt(a);document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),s(V)}catch(j){z.current=!1,w(j?.message??String(j))}finally{g(!1)}}},[a,u,s]);f.useEffect(()=>{if(p===null)return;if(p<=0){H();return}const j=setTimeout(()=>h(V=>V===null?null:V-1),1e3);return()=>clearTimeout(j)},[p,H]),f.useEffect(()=>()=>{Object.values(_.current).forEach(j=>clearTimeout(j))},[]);const A=f.useMemo(()=>[...t.items].sort((j,V)=>j.sortOrder-V.sortOrder),[t.items]),U=A.filter(j=>{const V=c[j.id];return V==null||V===""?!1:Array.isArray(V)?V.length>0:!0}).length;return r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden relative ${l?"select-none":""}`,children:[l&&r.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 opacity-[0.035] dark:opacity-[0.06] overflow-hidden flex flex-wrap items-center justify-around gap-16 select-none p-4",children:Array.from({length:24}).map((j,V)=>r.jsxs("div",{className:"transform -rotate-25 text-xs font-mono font-bold tracking-widest text-main",children:[t.assignment.title," · #",a.slice(-6)]},V))}),r.jsxs("div",{className:"relative z-10 px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[!l&&r.jsx("button",{type:"button",onClick:i,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":o?"返回测评列表(作答已自动保存)":"Back to list (answers are saved)",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-sm font-bold text-main truncate",children:t.assignment.title}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-2xs font-extrabold bg-rose-50 text-rose-700 border border-rose-200 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800",children:o?"严格考试模式":"Exam Mode"})]}),r.jsxs("p",{className:"text-2xs text-muted",children:[o?"已作答":"Answered"," ",U,"/",A.length,y&&` · ${o?"已自动保存":"autosaved"}`,u.size>0&&` · ${o?"保存中…":"saving…"}`,l&&v>0&&r.jsx("span",{className:"text-rose-600 font-semibold ml-2",children:o?`异常记录 ${v} 次`:`Violations: ${v}`})]})]}),l&&!C&&r.jsx("button",{type:"button",onClick:()=>void $(),className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-xl bg-amber-600 text-white text-xs font-bold hover:bg-amber-700 cursor-pointer animate-pulse",children:o?"进入全屏锁定":"Enter Fullscreen"}),p!==null&&r.jsxs("span",{"data-testid":"assessment-countdown",className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-xl border text-xs font-bold ${p<=60?"border-rose-300 bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"border-theme bg-surface text-main"}`,role:"timer","aria-live":"off",children:[r.jsx(Es,{size:12}),A0(p)]}),r.jsxs("button",{type:"button",onClick:()=>void H(),disabled:x,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-700 text-white text-xs font-bold hover:bg-emerald-800 disabled:opacity-50 cursor-pointer",children:[x?r.jsx($t,{size:13,className:"animate-spin"}):r.jsx(at,{size:13}),o?"提交交卷":"Submit"]}),r.jsx(Me,{slot:"assessment.attempt.toolbar",slotProps:{assignmentId:t.assignment.id,attemptId:a,lang:e},lang:e})]}),O&&r.jsxs("div",{role:"alert",className:"relative z-10 mx-5 mt-3 px-3 py-2 rounded-xl border border-amber-200 bg-amber-50 text-amber-800 text-xs flex items-center justify-between gap-2",children:[r.jsxs("span",{children:["⚠️ ",O]}),r.jsx("button",{type:"button",onClick:()=>D(null),className:"text-2xs font-bold underline cursor-pointer",children:o?"知道了":"Dismiss"})]}),b&&r.jsx("p",{role:"alert",className:"relative z-10 mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:b}),r.jsx("div",{className:"relative z-10 flex-1 overflow-y-auto p-5",children:r.jsx("ol",{className:"space-y-4 max-w-3xl mx-auto",children:A.map((j,V)=>{const E=kt.get(j.type)?.Answer??T0;return r.jsxs("li",{"data-testid":`answer-item-${j.id}`,className:"border border-theme rounded-xl p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsxs("span",{className:"text-2xs font-bold text-muted mt-0.5",children:["#",V+1]}),r.jsx("p",{className:"text-sm font-semibold text-main whitespace-pre-wrap break-words flex-1",children:j.stem}),r.jsxs("span",{className:"text-2xs text-muted shrink-0",children:[j.maxScore," 分"]})]}),r.jsx(E,{config:j.config,value:c[j.id],onChange:W=>B(j.id,W),lang:e})]},j.id)})})})]})}function na({lang:e,result:t,onBack:n}){const s=e==="zh",{attempt:i,assignment:o}=t;return r.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[r.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":s?"返回测评列表":"Back to assessments",children:r.jsx(Uo,{size:15})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h1",{className:"text-sm font-bold text-main truncate",children:o.title}),r.jsx("p",{className:"text-2xs text-muted",children:i?.submittedAt?`${s?"交卷时间":"Submitted"} ${new Date(i.submittedAt).toLocaleString()}`:s?"已交卷":"Submitted"})]}),t.showScore&&i&&r.jsxs("span",{"data-testid":"result-score",className:"text-sm font-bold text-main",children:[i.score??"—","/",i.maxScore??"—"]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4 max-w-3xl mx-auto w-full",children:[!t.showScore&&r.jsx("p",{className:"text-xs text-muted border border-theme rounded-xl px-3 py-2 bg-surface-secondary/40",children:s?"本次成绩待老师发布后可见。你的作答已保存,可以关闭页面。":"Your score will be visible after the teacher releases it. Your answers are saved."}),t.showScore&&i?.needsManualReview&&r.jsx("p",{className:"text-xs border border-amber-200 bg-amber-50 text-amber-700 rounded-xl px-3 py-2 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800",children:s?"主观题待人工批改,最终分数可能变化。":"Some items await manual grading; the score may change."}),t.aggregate.consideredAttempts>1&&t.aggregate.score!==null&&r.jsxs("p",{className:"text-xs text-muted",children:[s?`多次作答聚合(${t.aggregate.consideredAttempts} 次)`:`Aggregated over ${t.aggregate.consideredAttempts} attempts`,":",t.aggregate.score,"/",t.aggregate.maxScore??"—",t.aggregate.provisional&&(s?"(含待批改)":" (provisional)")]}),r.jsx("ul",{className:"space-y-3",children:t.items.map((a,l)=>r.jsxs("li",{"data-testid":`result-item-${a.itemId}`,className:"border border-theme rounded-xl p-4 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsxs("span",{className:"text-2xs font-bold text-muted mt-0.5",children:["#",l+1]}),r.jsx("p",{className:"text-sm font-semibold text-main whitespace-pre-wrap break-words flex-1",children:a.stem}),t.showAnalysis&&(a.needsManualReview?r.jsx("span",{className:"text-2xs text-amber-700 dark:text-amber-300 shrink-0",children:s?"待批改":"pending"}):a.isCorrect?r.jsx(at,{size:15,className:"text-emerald-600 shrink-0","aria-label":s?"正确":"Correct"}):r.jsx(sg,{size:15,className:"text-rose-600 shrink-0","aria-label":s?"错误":"Incorrect"}))]}),r.jsxs("p",{className:"text-xs text-main bg-surface-secondary rounded-lg px-2 py-1.5 whitespace-pre-wrap break-words",children:[r.jsx("span",{className:"text-muted mr-1",children:s?"你的作答:":"Your answer:"}),dl(a.answer)]}),t.showAnalysis&&a.answerKey!==void 0&&a.answerKey!==null&&r.jsxs("p",{className:"text-2xs text-muted",children:[s?"参考答案:":"Reference answer:"," ",dl(a.answerKey)]}),t.showAnalysis&&a.feedback&&r.jsxs("p",{className:"text-2xs text-indigo-700 dark:text-indigo-300",children:[s?"教师评语:":"Feedback:"," ",a.feedback]}),t.showAnalysis&&a.score!==null&&r.jsxs("p",{className:"text-2xs text-muted",children:[s?"本题得分":"Item score",":",a.score,"/",a.maxScore]})]},a.itemId))}),!o.scoreReleased&&t.showScore&&r.jsxs("p",{className:"text-2xs text-muted flex items-center gap-1",children:[r.jsx(Mt,{size:11}),s?"成绩尚未正式发布。":"Scores are not officially released yet."]})]})]})}const NN=Object.freeze(Object.defineProperty({__proto__:null,AssessmentRunner:ta,ResultView:na,StudentAssessmentsView:z0},Symbol.toStringTag,{value:"Module"}));function L0({lessonId:e,studentId:t,studentName:n="我",lang:s="zh"}){const[i,o]=f.useState(null),[a,l]=f.useState(null),[c,d]=f.useState("IN_CLASS_TEACHING"),[u,m]=f.useState(null),[p,h]=f.useState({}),[x,g]=f.useState(null),[b,w]=f.useState(null),[y,S]=f.useState(!1),[C,k]=f.useState("IDLE"),[v,N]=f.useState(null),[O,D]=f.useState(null),[_,T]=f.useState(!1),[z,R]=f.useState(!1),[$,I]=f.useState(null),[B,H]=f.useState(null),[A,U]=f.useState(5),[j,V]=f.useState(""),[G,E]=f.useState(""),[W,Y]=f.useState(null),[K,ne]=f.useState("closed"),[fe,je]=f.useState(null),[X,me]=f.useState(null),[ke,Se]=f.useState(!1),[M,Z]=f.useState(null),ee=f.useRef(Date.now()),te=f.useRef(null),ce=f.useRef(0),oe=f.useRef(0),xe=f.useRef(null),ie=f.useRef(null),Pe=f.useRef(!1);f.useEffect(()=>{if(!e)return;let L=!0;const F=async()=>{const J=++ce.current;try{const be=await fetch(`/api/classroom/sessions/${e}`);if(be.ok&&L){const se=await be.json();if(se.hasActiveSession){if(d(se.stage),se.session?.current_segment_id&&m(se.session.current_segment_id),se.stage==="WRAP_UP_EXIT_TICKET"&&!Pe.current&&T(!0),se.exitTicketCoreQuestion!==void 0&&I(se.exitTicketCoreQuestion),se.exitTicketChallengeQuestion!==void 0&&H(se.exitTicketChallengeQuestion),se.activeCountdown)try{window.dispatchEvent(new CustomEvent("openlearn:countdown:updated",{detail:se.activeCountdown}))}catch{}se.activePoll&&(!xe.current||xe.current.id!==se.activePoll.id)?(xe.current=se.activePoll,o(se.activePoll),w(null),S(!1)):!se.activePoll&&xe.current&&(xe.current=null,o(null));const ye=ie.current;if(se.activeBuzzer)if(!ye||ye.id!==se.activeBuzzer.id)ie.current=se.activeBuzzer,l(se.activeBuzzer),k("IDLE"),N(null),te.current=null,ee.current=Date.now();else if(se.activeBuzzer.status==="LOCKED"){const Fe=te.current,Ce=Fe&&Fe.buzzerId===se.activeBuzzer.id?Fe.status:t&&se.activeBuzzer.winner_student_id===t?"WINNER":"MISSED";te.current={buzzerId:se.activeBuzzer.id,status:Ce},ie.current=se.activeBuzzer,k(Ce),l(se.activeBuzzer)}else se.activeBuzzer.status==="READY"&&!(J<=oe.current)&&te.current?.buzzerId===se.activeBuzzer.id&&(te.current=null,ie.current=se.activeBuzzer,k("IDLE"),l(se.activeBuzzer),N(null),ee.current=Date.now());else ye&&(ie.current=null,l(null),k("IDLE"),te.current=null)}}}catch{}};F();const q=setInterval(F,2500);return()=>{L=!1,clearInterval(q)}},[e,t]),f.useEffect(()=>{const L=lt();if(!L||!e)return;const F=J=>{J?.lessonId===e&&J?.activeSegmentId&&m(J.activeSegmentId)},q=J=>{J?.lessonId===e&&J?.assignmentId&&(Y({assignmentId:J.assignmentId,title:J.title||(s==="zh"?"随堂测评":"Classroom Assessment"),kind:J.kind||"quiz",durationSec:J.durationSec??null,totalItems:J.totalItems??0,maxScore:J.maxScore??0}),ne("prompt"))};return L.on("student-active-segment-changed",F),L.on("classroom:assessment_started",q),()=>{typeof L.off=="function"&&(L.off("student-active-segment-changed",F),L.off("classroom:assessment_started",q))}},[e,s]);const ze=async()=>{if(W){Se(!0),Z(null);try{const L=await Ot.startAttempt(W.assignmentId);je(L),ne("answering")}catch(L){Z(L?.message||String(L))}finally{Se(!1)}}};if(f.useEffect(()=>{e&&fetch(`/api/lessons/${e}`).then(L=>L.ok?L.json():null).then(L=>{if(L?.timeline)try{const F=typeof L.timeline=="string"?JSON.parse(L.timeline):L.timeline;if(Array.isArray(F)){const q={};F.forEach(J=>{J?.id&&J?.title&&(q[J.id]=J.title)}),h(q)}}catch{}}).catch(()=>{})},[e]),f.useEffect(()=>{if(!e)return;fetch(`/api/classroom/sessions/${e}/pacing-summary?segmentId=${encodeURIComponent(u||"default")}`).then(F=>F.ok?F.json():null).then(F=>{F?.success&&g(F.mySignal||null)}).catch(()=>{})},[e,u]),!e)return null;const ue=async L=>{try{const F=x===L,q=await fetch(`/api/classroom/sessions/${e}/pacing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:F?null:L,action:F?"cancel":void 0,toggle:!0,segmentId:u||"default"})});if(q.ok){const J=await q.json();g(J.currentSignal??null),J.currentSignal?D(L==="TOO_FAST"?s==="zh"?"已反馈: 🐇 讲太快":"Pacing: Too Fast":L==="SLOW"?s==="zh"?"已反馈: 🐢 讲太慢":"Pacing: Too Slow":L==="CONFUSED"?s==="zh"?"已反馈: ❓ 有疑问":"Pacing: Confused":s==="zh"?"已反馈: 💡 听懂了":"Pacing: Clear"):D(s==="zh"?"已取消反馈":"Feedback cleared"),setTimeout(()=>D(null),2500)}}catch{}},re=async L=>{if(!(!i||y))try{w(L),S(!0),await fetch(`/api/classroom/sessions/${e}/quick-poll/${i.id}/vote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({option:L})})}catch{}},P=async()=>{if(!a||a.status!=="READY"||C!=="IDLE")return;const L=Date.now()-ee.current;oe.current=ce.current,k("BUZZED");try{const F=await fetch(`/api/classroom/sessions/${e}/buzzer/${a.id}/buzz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentName:n,responseTimeMs:L})});if(F.ok){const q=await F.json(),J=q.won??q.winner===!0,be=J?"WINNER":"MISSED";if(te.current={buzzerId:a.id,status:be},k(be),!J&&q.winner){const se={...a,status:"LOCKED",winner_student_id:q.winner.studentId??null,winner_student_name:q.winner.studentName??null,winner_response_time_ms:q.winner.responseTimeMs??null};ie.current=se,l(se)}}else k("IDLE")}catch{k("IDLE")}};return r.jsxs(r.Fragment,{children:[r.jsx(d0,{lessonId:e,lang:s}),r.jsx(Me,{slot:"student.classroom.overlay",slotProps:{studentId:t,lessonId:e}}),r.jsx(Me,{slot:"student.fullscreen",slotProps:{studentId:t,lessonId:e}}),r.jsxs("aside",{"aria-label":s==="zh"?"课堂互动工具栏":"Classroom interaction toolbar",className:"fixed bottom-6 right-6 z-40 flex items-center gap-2.5 bg-surface/95 backdrop-blur-md border border-theme p-2 rounded-2xl shadow-2xl transition-all",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-surface-secondary/70 rounded-xl border border-theme text-2xs font-bold text-muted",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary-theme animate-pulse"}),r.jsx("span",{className:"truncate max-w-[120px]",children:u&&p[u]?p[u]:s==="zh"?"当前环节":"Current Segment"})]}),O&&r.jsx("span",{className:"text-2xs font-bold text-primary-ink px-1.5 py-0.5 animate-fade-in whitespace-nowrap",children:O}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs("button",{type:"button",onClick:()=>ue("CLEAR"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="CLEAR"?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 ring-2 ring-emerald-500/60 shadow-xs":"hover:bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"}`,title:s==="zh"?"听懂了,节奏适宜(再次点击取消)":"Clear & Optimal (Click again to cancel)",children:[r.jsx("span",{children:"💡"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"听懂了":"Clear"}),x==="CLEAR"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("CONFUSED"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="CONFUSED"?"bg-amber-500/20 text-amber-700 dark:text-amber-300 ring-2 ring-amber-500/60 shadow-xs":"hover:bg-amber-500/10 text-amber-700 dark:text-amber-400"}`,title:s==="zh"?"有点困惑,希望老师点拨(再次点击取消)":"Confused (Click again to cancel)",children:[r.jsx("span",{children:"❓"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"有疑问":"Confused"}),x==="CONFUSED"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("TOO_FAST"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="TOO_FAST"?"bg-rose-500/20 text-rose-700 dark:text-rose-300 ring-2 ring-rose-500/60 shadow-xs":"hover:bg-rose-500/10 text-rose-700 dark:text-rose-400"}`,title:s==="zh"?"讲得太快了,希望能慢一点(再次点击取消)":"Too fast (Click again to cancel)",children:[r.jsx("span",{children:"🐇"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"讲太快":"Too Fast"}),x==="TOO_FAST"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]}),r.jsxs("button",{type:"button",onClick:()=>ue("SLOW"),className:`px-2.5 py-1.5 rounded-xl font-bold text-xs transition-all flex items-center gap-1 cursor-pointer ${x==="SLOW"?"bg-indigo-500/20 text-indigo-600 dark:text-indigo-300 ring-2 ring-indigo-500/60 shadow-xs":"hover:bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}`,title:s==="zh"?"讲太慢了,希望快一点(再次点击取消)":"Too slow (Click again to cancel)",children:[r.jsx("span",{children:"🐢"}),r.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"讲太慢":"Too Slow"}),x==="SLOW"&&r.jsx("span",{className:"text-3xs ml-0.5 font-bold",children:"✓"})]})]})]}),i&&i.status==="ACTIVE"&&r.jsxs("div",{"data-testid":"student-quick-poll-card",className:"fixed bottom-20 right-6 z-50 bg-surface rounded-2xl border border-amber-500/40 p-5 shadow-2xl w-80 flex flex-col gap-3 animate-slide-up",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-2",children:[r.jsxs("span",{className:"text-xs font-extrabold text-amber-700 dark:text-amber-400 flex items-center gap-1.5",children:[r.jsx(yt,{size:14}),s==="zh"?"极速答题进行中":"Quick Poll Active"]}),y&&r.jsxs("span",{className:"text-[11px] text-emerald-700 dark:text-emerald-400 font-bold flex items-center gap-1",children:[r.jsx(at,{size:12}),s==="zh"?"已提交":"Submitted"]})]}),r.jsx("p",{className:"font-bold text-sm text-foreground",children:i.title}),r.jsx("div",{className:"grid grid-cols-2 gap-2 mt-1",children:(i.options||["A","B","C","D"]).map(L=>{const F=b===L;return r.jsx("button",{disabled:y,onClick:()=>re(L),className:`p-3 rounded-xl font-bold text-center text-sm transition-all cursor-pointer ${F?"bg-primary-solid text-white ring-2 ring-primary-theme shadow-md scale-95":y?"bg-surface-secondary text-muted opacity-60 cursor-not-allowed":"bg-surface-secondary hover:bg-primary-theme/10 hover:border-primary-theme border border-border text-foreground"}`,children:L},L)})})]}),a&&v!==a.id&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",onClick:()=>N(a.id),children:r.jsxs("div",{className:"relative bg-surface rounded-3xl border border-rose-500/50 p-8 w-full max-w-sm shadow-2xl flex flex-col items-center text-center gap-4 animate-scale-up",onClick:L=>L.stopPropagation(),children:[r.jsx("button",{onClick:()=>N(a.id),"aria-label":s==="zh"?"关闭抢答":"Close buzzer",className:"absolute top-3 right-3 p-1.5 rounded-full text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:r.jsx(Oe,{size:18})}),r.jsxs("h3",{className:"text-xl font-black text-foreground flex items-center gap-2",children:[r.jsx($o,{size:22,className:"text-rose-700 dark:text-rose-400 animate-bounce"}),r.jsx("span",{children:a.title||"全班极速抢答"})]}),C==="BUZZED"&&r.jsxs("div",{className:"my-4 p-6 bg-amber-500/10 border border-amber-500/30 rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2 animate-pulse",children:"⚡"}),r.jsx("span",{className:"text-base font-bold text-foreground",children:"正在提交抢答…"}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"请稍候,马上公布结果"})]}),C==="IDLE"&&a.status==="READY"&&r.jsxs("div",{className:"my-4 flex flex-col items-center gap-3",children:[r.jsxs("button",{onClick:P,className:"w-36 h-36 rounded-full bg-gradient-to-tr from-rose-700 to-rose-600 text-white font-black text-2xl shadow-xl hover:scale-105 active:scale-95 transition-all flex flex-col items-center justify-center border-4 border-white dark:border-slate-800 cursor-pointer animate-pulse",children:[r.jsx(rg,{size:32,className:"mb-1"}),r.jsx("span",{children:"抢!"})]}),r.jsx("span",{className:"text-xs text-muted",children:"点击红色大按钮抢得首答权"})]}),C==="WINNER"&&r.jsxs("div",{className:"my-4 p-6 bg-emerald-500/10 border border-emerald-500/30 rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2",children:"🎉"}),r.jsx("span",{className:"text-lg font-black text-emerald-700 dark:text-emerald-400",children:"恭喜你率先抢答!"}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"请起立或开麦回答老师的问题"}),r.jsx("button",{onClick:()=>N(a.id),className:"mt-3 px-4 py-1.5 rounded-xl text-xs font-bold text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:s==="zh"?"知道了,返回课堂":"Got it, back to class"})]}),C==="MISSED"&&r.jsxs("div",{className:"my-4 p-6 bg-slate-800/20 border border-border rounded-2xl flex flex-col items-center text-center",children:[r.jsx("span",{className:"text-4xl mb-2",children:"⚡"}),r.jsxs("span",{className:"text-base font-bold text-foreground",children:["已被 ",a.winner_student_name||"其他同学"," 抢先一步!"]}),r.jsx("span",{className:"text-xs text-muted mt-1",children:"下次手速要更快哦"}),r.jsx("button",{onClick:()=>N(a.id),className:"mt-3 px-4 py-1.5 rounded-xl text-xs font-bold text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:s==="zh"?"知道了,返回课堂":"Got it, back to class"})]})]})}),r.jsx(u0,{isOpen:_,onClose:()=>T(!1),lessonId:e,studentName:n,lang:s,coreQuestion:$,challengeQuestion:B,onSubmitSuccess:()=>{Pe.current=!0,R(!0)}}),W&&K==="prompt"&&r.jsxs("div",{"data-testid":"student-classroom-assessment-card",className:"fixed bottom-20 left-6 z-50 bg-surface rounded-2xl border border-indigo-500/40 p-5 shadow-2xl w-80 flex flex-col gap-3 animate-slide-up",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-2",children:[r.jsxs("span",{className:"text-xs font-extrabold text-indigo-700 dark:text-indigo-400 flex items-center gap-1.5",children:[r.jsx(Ss,{size:14}),s==="zh"?"随堂测评已发起":"Classroom Assessment"]}),r.jsx("button",{onClick:()=>ne("closed"),"aria-label":s==="zh"?"关闭":"Close",className:"p-1 rounded-lg text-muted hover:text-foreground cursor-pointer",children:r.jsx(Oe,{size:14})})]}),r.jsx("p",{className:"font-bold text-sm text-foreground",children:W.title}),r.jsxs("div",{className:"flex items-center gap-2 text-2xs text-muted flex-wrap",children:[r.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme",children:W.kind==="exam"?s==="zh"?"考试":"Exam":W.kind==="survey"?s==="zh"?"问卷":"Survey":s==="zh"?"测试":"Quiz"}),r.jsxs("span",{children:[W.totalItems," ",s==="zh"?"道题":"items"]}),r.jsxs("span",{children:[s==="zh"?"满分":"Total"," ",W.maxScore]}),W.durationSec&&r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Es,{size:11}),Math.round(W.durationSec/60)," ",s==="zh"?"分钟":"min"]})]}),M&&r.jsx("p",{className:"text-2xs text-rose-600 bg-rose-50 dark:bg-rose-950/40 p-1.5 rounded-lg",children:M}),r.jsxs("button",{type:"button",onClick:()=>void ze(),disabled:ke,className:"w-full py-2 px-3 rounded-xl bg-indigo-600 text-white font-bold text-xs hover:bg-indigo-700 transition-colors flex items-center justify-center gap-1.5 cursor-pointer disabled:opacity-50",children:[ke?r.jsx("span",{className:"animate-spin text-xs",children:"⏳"}):r.jsx(Ro,{size:13}),s==="zh"?"立即开始作答":"Start Assessment"]})]}),K==="answering"&&fe&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6 animate-fade-in",children:r.jsx("div",{className:"w-full max-w-4xl h-[92vh] flex flex-col",children:r.jsx(ta,{lang:s,payload:fe,initialAnswers:fe.answers,onSubmitted:L=>{me(L),ne("result")},onExit:()=>ne("closed")})})}),K==="result"&&X&&r.jsx("div",{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-xs flex items-center justify-center p-3 sm:p-6 animate-fade-in",children:r.jsx("div",{className:"w-full max-w-4xl h-[92vh] flex flex-col",children:r.jsx(na,{lang:s,result:X,onBack:()=>{ne("closed"),Y(null),je(null),me(null)}})})})]})}function R0(e){const t=nn(),n=e.pickedAnnouncement!==void 0?e.pickedAnnouncement:t?.pickedAnnouncement,s=e.setPickedAnnouncement??t?.setPickedAnnouncement,i=e.pickedAlertData!==void 0?e.pickedAlertData:t?.pickedAlertData,o=e.setPickedAlertData??t?.setPickedAlertData,a=e.lang??t?.lang??"zh",l=e.selectedLesson!==void 0?e.selectedLesson:t?.selectedLesson??null,c=e.liveClassSelectedClassId!==void 0?e.liveClassSelectedClassId:t?.liveClassSelectedClassId??null,d=e.activeStudentId!==void 0?e.activeStudentId:t?.activeStudentId??null,u=e.students??t?.students??[],m=e.activeRole??t?.activeRole??"teacher",p=e.isStudentLiveMode??t?.isStudentLiveMode??!1,h=e.liveStudentParam!==void 0?e.liveStudentParam:t?.liveStudentParam??null,x=e.addToast??t?.addToast??(()=>{}),g=e.setReadNotifications??t?.setReadNotifications??(()=>{});return r.jsxs(r.Fragment,{children:[n&&!i&&r.jsx("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-[9990] animate-in slide-in-from-top-4 duration-300 pointer-events-auto max-w-lg w-auto",children:r.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 bg-gradient-to-r from-amber-500 to-orange-500 text-white rounded-full shadow-xl shadow-amber-500/25 backdrop-blur-xs text-sm font-bold border border-amber-300/40",children:[r.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-white"})]}),r.jsx(yt,{size:16,className:"text-amber-200 shrink-0"}),r.jsx("span",{className:"truncate",children:a==="zh"?`🎯 课堂抽问:老师随机抽中了【${n.studentName}】同学回答问题!`:`🎯 Classroom Pick: Teacher randomly selected [${n.studentName}] to answer!`}),s&&r.jsx("button",{type:"button",onClick:()=>s(null),className:"ml-2 hover:bg-white/20 rounded-full p-1 transition-colors cursor-pointer text-white/80 hover:text-white shrink-0","aria-label":"Close announcement",children:r.jsx(Oe,{size:14})})]})}),i&&r.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/70 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-200",children:r.jsxs("div",{className:"bg-surface border-4 border-amber-500 rounded-3xl shadow-2xl shadow-amber-500/40 ring-8 ring-amber-500/20 p-7 max-w-md w-full text-center space-y-5 animate-in zoom-in-95 duration-300",children:[r.jsxs("div",{className:"relative w-20 h-20 mx-auto",children:[r.jsx("div",{className:"absolute inset-0 bg-amber-500/30 rounded-full animate-ping"}),r.jsx("div",{className:"relative w-20 h-20 bg-gradient-to-tr from-amber-500 to-orange-500 text-white rounded-full flex items-center justify-center shadow-lg shadow-amber-500/40",children:r.jsx(yt,{size:40,className:"animate-pulse"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-2xl font-black text-main tracking-tight",children:a==="zh"?"⚡️ 闪电抽问:老师抽中了你!":"⚡️ Classroom Pick: Teacher Selected You!"}),r.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-amber-500/10 border border-amber-500/30 text-amber-600 dark:text-amber-400 font-black text-lg",children:[r.jsx("span",{children:"🎯"}),r.jsx("span",{children:i.studentName})]}),r.jsx("p",{className:"text-sm text-muted leading-relaxed",children:a==="zh"?r.jsx(r.Fragment,{children:"老师在课堂随机抽问中抽中了你,请立即集中注意力参与互动回答!"}):r.jsx(r.Fragment,{children:"The teacher selected you in the classroom random pick. Please respond and participate now!"})})]}),r.jsx("div",{className:"pt-2",children:r.jsxs("button",{type:"button",onClick:()=>{const b=new yd(void 0,l,c);if(b.acknowledgePick(i.studentId),b.destroy(),i.rollcallId){const w=i.rollcallId;d&&r0(d,w).catch(console.error),g(y=>new Set(y).add(w))}o?.(null),x(a==="zh"?"🙋♂️ 已确认答到":"🙋♂️ Acknowledged",a==="zh"?"已向老师中控台发送举手答到信号!":"Sent acknowledge signal to teacher!","success")},className:"w-full py-3.5 bg-gradient-to-r from-amber-500 to-orange-600 hover:from-amber-600 hover:to-orange-700 text-white font-black text-base rounded-2xl shadow-xl shadow-amber-500/35 transition-all active:scale-95 cursor-pointer flex items-center justify-center gap-2",children:[r.jsx(at,{size:20}),r.jsx("span",{children:a==="zh"?"🙋♂️ 我已准备好 / 确认答到 (反馈给老师)":"🙋♂️ Ready / Acknowledge to Teacher"})]})})]})}),(m==="student"||p)&&r.jsx(L0,{lessonId:l,studentId:d||h||void 0,studentName:u.find(b=>b.id===(d||h))?.name||void 0,lang:a})]})}const sa=f.createContext({});function ra(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const _0=typeof window<"u",Sd=_0?f.useLayoutEffect:f.useEffect,Mr=f.createContext(null),ia=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function hl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function O0(...e){return t=>{let n=!1;const s=e.map(i=>{const o=hl(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():hl(e[i],null)}}}}function D0(...e){return f.useCallback(O0(...e),e)}class M0 extends f.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Zr(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,i=Zr(s)&&s.offsetWidth||0,o=Zr(s)&&s.offsetHeight||0,a=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(a.height),l.width=parseFloat(a.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=i-l.width-l.left,l.bottom=o-l.height-l.top,l.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function $0({children:e,isPresent:t,anchorX:n,anchorY:s,root:i,pop:o}){const a=f.useId(),l=f.useRef(null),c=f.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:d}=f.useContext(ia),u=e.props?.ref??e?.ref,m=D0(l,u);return f.useInsertionEffect(()=>{const{width:p,height:h,top:x,left:g,right:b,bottom:w,direction:y}=c.current;if(t||o===!1||!l.current||!p||!h)return;const S=y==="rtl",C=n==="left"?S?`right: ${b}`:`left: ${g}`:S?`left: ${g}`:`right: ${b}`,k=s==="bottom"?`bottom: ${w}`:`top: ${x}`;l.current.dataset.motionPopId=a;const v=document.createElement("style");d&&(v.nonce=d);const N=i??document.head;return N.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
13
13
|
[data-motion-pop-id="${a}"] {
|
|
14
14
|
position: absolute !important;
|
|
15
15
|
width: ${p}px !important;
|
|
@@ -17,7 +17,7 @@ ${w}`:w),o(!1),l(null),d({})};return r.jsxs("div",{className:"relative shrink-0"
|
|
|
17
17
|
${C}px !important;
|
|
18
18
|
${k}px !important;
|
|
19
19
|
}
|
|
20
|
-
`),()=>{l.current?.removeAttribute("data-motion-pop-id"),N.contains(v)&&N.removeChild(v)}},[t]),r.jsx(M0,{isPresent:t,childRef:l,sizeRef:c,pop:o,children:o===!1?e:f.cloneElement(e,{ref:m})})}const F0=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:a,anchorX:l,anchorY:c,root:d})=>{const u=ra(B0),m=f.useId();let p=!0,h=f.useMemo(()=>(p=!1,{id:m,initial:t,isPresent:n,custom:i,onExitComplete:x=>{u.set(x,!0);for(const g of u.values())if(!g)return;s&&s()},register:x=>(u.set(x,!1),()=>u.delete(x))}),[n,u,s]);return o&&p&&(h={...h}),f.useMemo(()=>{u.forEach((x,g)=>u.set(g,!1))},[n]),f.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),e=r.jsx($0,{pop:a==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:d,children:e}),r.jsx(Mr.Provider,{value:h,children:e})};function B0(){return new Map}function jd(e=!0){const t=f.useContext(Mr);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,o=f.useId();f.useEffect(()=>{if(e)return i(o)},[e]);const a=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,a]:[!0]}const Fs=e=>e.key||"";function fl(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const kd=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:a=!1,anchorX:l="left",anchorY:c="top",root:d})=>{const[u,m]=jd(a),p=f.useMemo(()=>fl(e),[e]),h=a&&!u?[]:p.map(Fs),x=f.useRef(!0),g=f.useRef(p),b=ra(()=>new Map),w=f.useRef(new Set),[y,S]=f.useState(p),[C,k]=f.useState(p);Sd(()=>{x.current=!1,g.current=p;for(let O=0;O<C.length;O++){const D=Fs(C[O]);h.includes(D)?(b.delete(D),w.current.delete(D)):b.get(D)!==!0&&b.set(D,!1)}},[C,h.length,h.join("-")]);const v=[];if(p!==y){let O=[...p];for(let D=0;D<C.length;D++){const _=C[D],T=Fs(_);h.includes(T)||(O.splice(D,0,_),v.push(_))}return o==="wait"&&v.length&&(O=v),k(fl(O)),S(p),null}const{forceRender:N}=f.useContext(sa);return r.jsx(r.Fragment,{children:C.map(O=>{const D=Fs(O),_=a&&!u?!1:p===C||h.includes(D),T=()=>{if(w.current.has(D))return;if(b.has(D))w.current.add(D),b.set(D,!0);else return;let z=!0;b.forEach(R=>{R||(z=!1)}),z&&(N?.(),k(g.current),a&&m?.(),s&&s())};return r.jsx(F0,{isPresent:_,initial:!x.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:d,onExitComplete:_?void 0:T,anchorX:l,anchorY:c,children:O},D)})})},Cd=f.createContext({strict:!1}),ml={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let pl=!1;function U0(){if(pl)return;const e={};for(const t in ml)e[t]={isEnabled:n=>ml[t].some(s=>!!n[s])};nd(e),pl=!0}function Nd(){return U0(),dg()}function V0(e){const t=Nd();for(const n in e)t[n]={...t[n],...e[n]};nd(t)}const H0=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Nr(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||H0.has(e)}let Ed=e=>!Nr(e);function W0(e){typeof e=="function"&&(Ed=t=>t.startsWith("on")?!Nr(t):e(t))}try{W0(require("@emotion/is-prop-valid").default)}catch{}function q0(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||Ho(e[i])||(Ed(i)||n===!0&&Nr(i)||!t&&!Nr(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const $r=f.createContext({});function G0(e,t){if(sd(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Wa(n)?n:void 0,animate:Wa(s)?s:void 0}}return e.inherit!==!1?t:{}}function Q0(e){const{initial:t,animate:n}=G0(e,f.useContext($r));return f.useMemo(()=>({initial:t,animate:n}),[gl(t),gl(n)])}function gl(e){return Array.isArray(e)?e.join(" "):e}const oa=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Td(e,t,n){for(const s in t)!Ho(t[s])&&!ug(s,n)&&(e[s]=t[s])}function J0({transformTemplate:e},t){return f.useMemo(()=>{const n=oa();return hg(n,t,e),Object.assign({},n.vars,n.style)},[t])}function K0(e,t){const n=e.style||{},s={};return Td(s,n,e),Object.assign(s,J0(e,t)),s}function Y0(e,t){const n={},s=K0(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Pd=()=>({...oa(),attrs:{}});function Z0(e,t,n,s){const i=f.useMemo(()=>{const o=Pd();return fg(o,t,mg(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};Td(o,e.style,e),i.style={...o,...i.style}}return i}const X0=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function aa(e){return typeof e!="string"||e.includes("-")?!1:!!(X0.indexOf(e)>-1||/[A-Z]/u.test(e))}function ey(e,t,n,{latestValues:s},i,o=!1,a){const c=(a??aa(e)?Z0:Y0)(t,s,i,e),d=q0(t,typeof e=="string",o),u=e!==f.Fragment?{...d,...c,ref:n}:{},{children:m}=t,p=f.useMemo(()=>Ho(m)?m.get():m,[m]);return f.createElement(e,{...u,children:p})}function ty({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:ny(n,s,i,e),renderState:t()}}function ny(e,t,n,s){const i={},o=s(e,{});for(const p in o)i[p]=pg(o[p]);let{initial:a,animate:l}=e;const c=sd(e),d=gg(e);t&&d&&!c&&e.inherit!==!1&&(a===void 0&&(a=t.initial),l===void 0&&(l=t.animate));let u=n?n.initial===!1:!1;u=u||a===!1;const m=u?l:a;if(m&&typeof m!="boolean"&&!rd(m)){const p=Array.isArray(m)?m:[m];for(let h=0;h<p.length;h++){const x=xg(e,p[h]);if(x){const{transitionEnd:g,transition:b,...w}=x;for(const y in w){let S=w[y];if(Array.isArray(S)){const C=u?S.length-1:0;S=S[C]}S!==null&&(i[y]=S)}for(const y in g)i[y]=g[y]}}}return i}const Id=e=>(t,n)=>{const s=f.useContext($r),i=f.useContext(Mr),o=()=>ty(e,t,s,i);return n?o():ra(o)},sy=Id({scrapeMotionValuesFromProps:bg,createRenderState:oa}),ry=Id({scrapeMotionValuesFromProps:yg,createRenderState:Pd}),iy=Symbol.for("motionComponentSymbol");function oy(e,t,n){const s=f.useRef(n);f.useInsertionEffect(()=>{s.current=n});const i=f.useRef(null);return f.useCallback(o=>{o&&e.onMount?.(o),t&&(o?t.mount(o):t.unmount());const a=s.current;if(typeof a=="function")if(o){const l=a(o);typeof l=="function"&&(i.current=l)}else i.current?(i.current(),i.current=null):a(o);else a&&(a.current=o)},[t])}const Ad=f.createContext({});function bn(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function ay(e,t,n,s,i,o){const{visualElement:a}=f.useContext($r),l=f.useContext(Cd),c=f.useContext(Mr),d=f.useContext(ia),u=d.reducedMotion,m=d.skipAnimations,p=f.useRef(null),h=f.useRef(!1);s=s||l.renderer,!p.current&&s&&(p.current=s(e,{visualState:t,parent:a,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:m,isSVG:o}),h.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));const x=p.current,g=f.useContext(Ad);x&&!x.projection&&i&&(x.type==="html"||x.type==="svg")&&ly(p.current,n,i,g);const b=f.useRef(!1);f.useInsertionEffect(()=>{x&&b.current&&x.update(n,c)});const w=n[wg],y=f.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Sd(()=>{h.current=!0,x&&(b.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),y.current&&x.animationState&&x.animationState.animateChanges())}),f.useEffect(()=>{x&&(!y.current&&x.animationState&&x.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),y.current=!1),x.enteringChildren=void 0)}),x}function ly(e,t,n,s){const{layoutId:i,layout:o,drag:a,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutAnchor:u,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:zd(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!a||l&&bn(l),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:m,layoutScroll:c,layoutRoot:d,layoutAnchor:u})}function zd(e){if(e)return e.options.allowProjection!==!1?e.projection:zd(e.parent)}function xi(e,{forwardMotionProps:t=!1,type:n}={},s,i){s&&V0(s);const o=n?n==="svg":aa(e),a=o?ry:sy;function l(d,u){let m;const p={...f.useContext(ia),...d,layoutId:cy(d)},{isStatic:h}=p,x=Q0(d),g=a(d,h);if(!h&&typeof window<"u"){dy();const b=uy(p);m=b.MeasureLayout,x.visualElement=ay(e,g,p,i,b.ProjectionNode,o)}return r.jsxs($r.Provider,{value:x,children:[m&&x.visualElement?r.jsx(m,{visualElement:x.visualElement,...p}):null,ey(e,d,oy(g,x.visualElement,u),g,h,t,o)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=f.forwardRef(l);return c[iy]=e,c}function cy({layoutId:e}){const t=f.useContext(sa).id;return t&&e!==void 0?t+"-"+e:e}function dy(e,t){f.useContext(Cd).strict}function uy(e){const t=Nd(),{drag:n,layout:s}=t;if(!n&&!s)return{};const i={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function hy(e,t){if(typeof Proxy>"u")return xi;const n=new Map,s=(o,a)=>xi(o,a,e,t),i=(o,a)=>s(o,a);return new Proxy(i,{get:(o,a)=>a==="create"?s:(n.has(a)||n.set(a,xi(a,void 0,e,t)),n.get(a))})}const fy=(e,t)=>t.isSVG??aa(e)?new vg(t):new Sg(t,{allowProjection:e!==f.Fragment});class my extends Bt{constructor(t){super(t),t.animationState||(t.animationState=jg(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();rd(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let py=0;class gy extends Bt{constructor(){super(...arguments),this.id=py++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;if(t&&s===!1){if(this.isExitComplete){const{initial:o,custom:a}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const l=kg(this.node,o,a);if(l){const{transition:c,transitionEnd:d,...u}=l;for(const m in u)this.node.getValue(m)?.jump(u[m])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const xy={animation:{Feature:my},exit:{Feature:gy}};function Ts(e){return{point:{x:e.pageX,y:e.pageY}}}const by=e=>t=>id(t)&&e(t,Ts(t));function gs(e,t,n,s){return Sr(e,t,by(n),s)}const Ld=({current:e})=>e?e.ownerDocument.defaultView:null,xl=(e,t)=>Math.abs(e-t);function yy(e,t){const n=xl(e.x,t.x),s=xl(e.y,t.y);return Math.sqrt(n**2+s**2)}const bl=new Set(["auto","scroll"]);class Rd{constructor(t,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:a=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=h=>{this.handleScroll(h.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Bs(this.lastRawMoveEventInfo,this.transformPagePoint));const h=bi(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,g=yy(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!g)return;const{point:b}=h,{timestamp:w}=qa;this.history.push({...b,timestamp:w});const{onStart:y,onMove:S}=this.handlers;x||(y&&y(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,h)},this.handlePointerMove=(h,x)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=Bs(x,this.transformPagePoint),ft.update(this.updatePoint,!0)},this.handlePointerUp=(h,x)=>{this.end();const{onEnd:g,onSessionEnd:b,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=bi(h.type==="pointercancel"?this.lastMoveEventInfo:Bs(x,this.transformPagePoint),this.history);this.startEvent&&g&&g(h,y),b&&b(h,y)},!id(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=i||window;const c=Ts(t),d=Bs(c,this.transformPagePoint),{point:u}=d,{timestamp:m}=qa;this.history=[{...u,timestamp:m}];const{onSessionStart:p}=n;p&&p(t,bi(d,this.history)),this.removeListeners=od(gs(this.contextWindow,"pointermove",this.handlePointerMove),gs(this.contextWindow,"pointerup",this.handlePointerUp),gs(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(bl.has(s.overflowX)||bl.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,i=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:i.x-n.x,y:i.y-n.y};o.x===0&&o.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,i),ft.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Cg(this.updatePoint)}}function Bs(e,t){return t?{point:t(e.point)}:e}function yl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function bi({point:e},t){return{point:e,delta:yl(e,_d(t)),offset:yl(e,wy(t)),velocity:vy(t,.1)}}function wy(e){return e[0]}function _d(e){return e[e.length-1]}function vy(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=_d(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Ga(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&i.timestamp-s.timestamp>Ga(t)*2&&(s=e[1]);const o=Ng(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const a={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Sy(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?jr(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?jr(n,e,s.max):Math.min(e,n)),e}function wl(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function jy(e,{top:t,left:n,bottom:s,right:i}){return{x:wl(e.x,n,i),y:wl(e.y,t,s)}}function vl(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function ky(e,t){return{x:vl(e.x,t.x),y:vl(e.y,t.y)}}function Cy(e,t){let n=.5;const s=eo(e),i=eo(t);return i>s?n=Qa(t.min,t.max-s,e.min):s>i&&(n=Qa(e.min,e.max-i,t.min)),Eg(0,1,n)}function Ny(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const io=.35;function Ey(e=io){return e===!1?e=0:e===!0&&(e=io),{x:Sl(e,"left","right"),y:Sl(e,"top","bottom")}}function Sl(e,t,n){return{min:jl(e,t),max:jl(e,n)}}function jl(e,t){return typeof e=="number"?e:e[t]||0}const Ty=new WeakMap;class Py{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Tg(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=m=>{n&&this.snapToCursor(Ts(m).point),this.stopAnimation()},a=(m,p)=>{const{drag:h,dragPropagation:x,onDragStart:g}=this.getProps();if(h&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lg(h),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),zt(w=>{let y=this.getAxisMotionValue(w).get()||0;if(Rg.test(y)){const{projection:S}=this.visualElement;if(S&&S.layout){const C=S.layout.layoutBox[w];C&&(y=eo(C)*(parseFloat(y)/100))}}this.originPoint[w]=y}),g&&ft.update(()=>g(m,p),!1,!0),Ja(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},l=(m,p)=>{this.latestPointerEvent=m,this.latestPanInfo=p;const{dragPropagation:h,dragDirectionLock:x,onDirectionLock:g,onDrag:b}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=p;if(x&&this.currentDirection===null){this.currentDirection=Ay(w),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",p.point,w),this.updateAxis("y",p.point,w),this.visualElement.render(),b&&ft.update(()=>b(m,p),!1,!0)},c=(m,p)=>{this.latestPointerEvent=m,this.latestPanInfo=p,this.stop(m,p),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new Rd(t,{onSessionStart:o,onStart:a,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Ld(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:a}=i;this.startAnimation(a);const{onDragEnd:l}=this.getProps();l&&ft.postRender(()=>l(s,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!Us(t,i,this.currentDirection))return;const o=this.getAxisMotionValue(t);let a=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(a=Sy(a,this.constraints[t],this.elastic[t])),o.set(a)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&bn(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=jy(s.layoutBox,t):this.constraints=!1,this.elastic=Ey(n),i!==this.constraints&&!bn(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&zt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Ny(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!bn(t))return!1;const s=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;i.root&&(i.root.scroll=void 0,i.root.updateScroll());const o=Pg(s,i.root,this.visualElement.getTransformPagePoint());let a=ky(i.layout.layoutBox,o);if(n){const l=n(Ig(a));this.hasMutatedConstraints=!!l,l&&(a=Ag(l))}return a}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:a,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=zt(u=>{if(!Us(u,n,this.currentDirection))return;let m=c&&c[u]||{};(a===!0||a===u)&&(m={min:0,max:0});const p=i?200:1e6,h=i?40:1e7,x={type:"inertia",velocity:s?t[u]:0,bounceStiffness:p,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(u,x)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Ja(this.visualElement,t),s.start(zg(t,s,0,n,this.visualElement,!1))}stopAnimation(){zt(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps()[n];return i||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){zt(n=>{const{drag:s}=this.getProps();if(!Us(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:a,max:l}=i.layout.layoutBox[n],c=o.get()||0;o.set(t[n]-jr(a,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!bn(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};zt(a=>{const l=this.getAxisMotionValue(a);if(l&&this.constraints!==!1){const c=l.get();i[a]=Cy({min:c,max:c},this.constraints[a])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),zt(a=>{if(!Us(a,t,null))return;const l=this.getAxisMotionValue(a),{min:c,max:d}=this.constraints[a];l.set(jr(c,d,i[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ty.set(this.visualElement,this);const t=this.visualElement.current,n=gs(t,"pointerdown",d=>{const{drag:u,dragListener:m=!0}=this.getProps(),p=d.target,h=p!==t&&_g(p);u&&m&&!h&&this.start(d)});let s;const i=()=>{const{dragConstraints:d}=this.getProps();bn(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Iy(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,a=o.addEventListener("measure",i);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ft.read(i);const l=Sr(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:u})=>{this.isDragging&&u&&(zt(m=>{const p=this.getAxisMotionValue(m);p&&(this.originPoint[m]+=d[m].translate,p.set(p.get()+d[m].translate))}),this.visualElement.render())}));return()=>{l(),n(),a(),c&&c(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:a=io,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:a,dragMomentum:l}}}function kl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Iy(e,t,n){const s=Ka(e,kl(n)),i=Ka(t,kl(n));return()=>{s(),i()}}function Us(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ay(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class zy extends Bt{constructor(t){super(t),this.removeGroupControls=er,this.removeListeners=er,this.controls=new Py(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||er}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const yi=e=>(t,n)=>{e&&ft.update(()=>e(t,n),!1,!0)};class Ly extends Bt{constructor(){super(...arguments),this.removePointerDownListener=er}onPointerDown(t){this.session=new Rd(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ld(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:yi(t),onStart:yi(n),onMove:yi(s),onEnd:(o,a)=>{delete this.session,i&&ft.postRender(()=>i(o,a))}}}mount(){this.removePointerDownListener=gs(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let wi=!1;class Ry extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),wi&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Dg.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:a}=s;return a&&(a.isPresent=o,t.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),wi=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==o?a.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?a.promote():a.relegate()||ft.postRender(()=>{const l=a.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Og.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;wi=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Od(e){const[t,n]=jd(),s=f.useContext(sa);return r.jsx(Ry,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Ad),isPresent:t,safeToRemove:n})}const _y={pan:{Feature:Ly},drag:{Feature:zy,ProjectionNode:ad,MeasureLayout:Od}};function Cl(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&ft.postRender(()=>o(t,Ts(t)))}class Oy extends Bt{mount(){const{current:t}=this.node;t&&(this.unmount=Mg(t,(n,s)=>(Cl(this.node,s,"Start"),i=>Cl(this.node,i,"End"))))}unmount(){}}class Dy extends Bt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=od(Sr(this.node.current,"focus",()=>this.onFocus()),Sr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nl(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&ft.postRender(()=>o(t,Ts(t)))}class My extends Bt{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=$g(t,(i,o)=>(Nl(this.node,o,"Start"),(a,{success:l})=>Nl(this.node,a,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const oo=new WeakMap,vi=new WeakMap,$y=e=>{const t=oo.get(e.target);t&&t(e)},Fy=e=>{e.forEach($y)};function By({root:e,...t}){const n=e||document;vi.has(n)||vi.set(n,{});const s=vi.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Fy,{root:e,...t})),s[i]}function Uy(e,t,n){const s=By(t);return oo.set(e,n),s.observe(e),()=>{oo.delete(e),s.unobserve(e)}}const Vy={some:0,all:1};class Hy extends Bt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=t,a={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Vy[i]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,o&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:u,onViewportLeave:m}=this.node.getProps(),p=d?u:m;p&&p(c)};this.stopObserver=Uy(this.node.current,a,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Wy(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function Wy({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const qy={inView:{Feature:Hy},tap:{Feature:My},focus:{Feature:Dy},hover:{Feature:Oy}},Gy={layout:{ProjectionNode:ad,MeasureLayout:Od}},Qy={...xy,...qy,..._y,...Gy},ir=hy(Qy,fy);async function Er(e){if(typeof window>"u")return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("[OpenLearn Clipboard] Failed to copy text to clipboard:",t),!1}}function Jy(){const e=mx(o=>o.toasts),[t,n]=f.useState(null),s=async(o,a)=>{o.stopPropagation();const l=`[${a.title}] ${a.message}`;await Er(l)&&(n(a.id),setTimeout(()=>n(null),2e3))},i=o=>{switch(o){case"error":return{border:"border-l-4 border-rose-500",iconBg:"bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400",icon:r.jsx(br,{size:16})};case"warning":return{border:"border-l-4 border-amber-500",iconBg:"bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400",icon:r.jsx(Mt,{size:16})};case"info":return{border:"border-l-4 border-blue-500",iconBg:"bg-blue-50 text-blue-600 dark:bg-blue-950/60 dark:text-blue-400",icon:r.jsx(Yc,{size:16})};case"success":default:return{border:"border-l-4 border-emerald-500",iconBg:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400",icon:r.jsx(at,{size:16})}}};return r.jsx("div",{className:"fixed bottom-6 right-6 z-50 flex flex-col gap-3 min-w-[320px] max-w-sm pointer-events-none",children:r.jsx(kd,{children:e.map(o=>{const a=i(o.type),l=t===o.id;return r.jsxs(ir.div,{initial:{opacity:0,y:50,x:50,scale:.9},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,scale:.85,transition:{duration:.2}},transition:{type:"spring",stiffness:300,damping:24},className:`pointer-events-auto w-full bg-white dark:bg-slate-900 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 ${a.border} overflow-hidden text-gray-900 dark:text-gray-100`,id:`toast-${o.id}`,children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:`p-1 rounded-full shrink-0 ${a.iconBg}`,children:a.icon}),r.jsx("p",{className:"font-semibold text-sm font-sans truncate",children:o.title})]}),(o.type==="error"||o.type==="warning")&&r.jsxs("button",{type:"button",onClick:c=>s(c,o),className:`text-xs font-bold px-1.5 py-0.5 rounded transition-all flex items-center gap-1 cursor-pointer shrink-0 ${l?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 dark:bg-slate-800 dark:hover:bg-slate-700 text-gray-600 dark:text-gray-300"}`,title:"复制错误内容",children:[l?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:l?"已复制":"复制"})]})]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 leading-relaxed font-sans break-words",children:o.message}),o.action&&r.jsx("div",{className:"mt-2.5",children:r.jsx("button",{type:"button",onClick:()=>{o.action?.onClick(),Ve.getState().removeToast(o.id)},className:"px-3 py-1 bg-indigo-600 hover:bg-indigo-700 text-white text-xs font-bold rounded-lg shadow-xs transition-colors cursor-pointer flex items-center gap-1",children:r.jsx("span",{children:o.action.label})})})]}),r.jsx("button",{type:"button",onClick:()=>Ve.getState().removeToast(o.id),"aria-label":"关闭提示",className:"text-subtle hover:text-main hover:bg-gray-50 dark:hover:bg-slate-800 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:r.jsx(Oe,{size:14})})]},o.id)})})})}const ao=new Set;function Ky(e){return ao.add(e),()=>{ao.delete(e)}}const El=30,Tl=(e,t)=>Math.min(e,t.length);function la(e){const t=new Date(e.timestamp).toLocaleString(),n=[`### [${e.type.toUpperCase()}] ${e.title}`,`- **发生时间**: ${t}`,`- **页面路径**: ${e.url||"N/A"}`,`- **错误摘要**: ${e.message}`];return e.endpoint&&n.push(`- **请求接口**: \`${e.endpoint}\` (HTTP ${e.status||"Unknown"})`),e.componentStack&&n.push("- **组件堆栈**:","```",e.componentStack.trim(),"```"),e.stack&&n.push("- **调用栈 (Stack Trace)**:","```",e.stack.trim(),"```"),n.join(`
|
|
20
|
+
`),()=>{l.current?.removeAttribute("data-motion-pop-id"),N.contains(v)&&N.removeChild(v)}},[t]),r.jsx(M0,{isPresent:t,childRef:l,sizeRef:c,pop:o,children:o===!1?e:f.cloneElement(e,{ref:m})})}const F0=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:a,anchorX:l,anchorY:c,root:d})=>{const u=ra(B0),m=f.useId();let p=!0,h=f.useMemo(()=>(p=!1,{id:m,initial:t,isPresent:n,custom:i,onExitComplete:x=>{u.set(x,!0);for(const g of u.values())if(!g)return;s&&s()},register:x=>(u.set(x,!1),()=>u.delete(x))}),[n,u,s]);return o&&p&&(h={...h}),f.useMemo(()=>{u.forEach((x,g)=>u.set(g,!1))},[n]),f.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),e=r.jsx($0,{pop:a==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:d,children:e}),r.jsx(Mr.Provider,{value:h,children:e})};function B0(){return new Map}function jd(e=!0){const t=f.useContext(Mr);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,o=f.useId();f.useEffect(()=>{if(e)return i(o)},[e]);const a=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,a]:[!0]}const Fs=e=>e.key||"";function fl(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const kd=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:a=!1,anchorX:l="left",anchorY:c="top",root:d})=>{const[u,m]=jd(a),p=f.useMemo(()=>fl(e),[e]),h=a&&!u?[]:p.map(Fs),x=f.useRef(!0),g=f.useRef(p),b=ra(()=>new Map),w=f.useRef(new Set),[y,S]=f.useState(p),[C,k]=f.useState(p);Sd(()=>{x.current=!1,g.current=p;for(let O=0;O<C.length;O++){const D=Fs(C[O]);h.includes(D)?(b.delete(D),w.current.delete(D)):b.get(D)!==!0&&b.set(D,!1)}},[C,h.length,h.join("-")]);const v=[];if(p!==y){let O=[...p];for(let D=0;D<C.length;D++){const _=C[D],T=Fs(_);h.includes(T)||(O.splice(D,0,_),v.push(_))}return o==="wait"&&v.length&&(O=v),k(fl(O)),S(p),null}const{forceRender:N}=f.useContext(sa);return r.jsx(r.Fragment,{children:C.map(O=>{const D=Fs(O),_=a&&!u?!1:p===C||h.includes(D),T=()=>{if(w.current.has(D))return;if(b.has(D))w.current.add(D),b.set(D,!0);else return;let z=!0;b.forEach(R=>{R||(z=!1)}),z&&(N?.(),k(g.current),a&&m?.(),s&&s())};return r.jsx(F0,{isPresent:_,initial:!x.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:d,onExitComplete:_?void 0:T,anchorX:l,anchorY:c,children:O},D)})})},Cd=f.createContext({strict:!1}),ml={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let pl=!1;function U0(){if(pl)return;const e={};for(const t in ml)e[t]={isEnabled:n=>ml[t].some(s=>!!n[s])};nd(e),pl=!0}function Nd(){return U0(),dg()}function V0(e){const t=Nd();for(const n in e)t[n]={...t[n],...e[n]};nd(t)}const H0=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Nr(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||H0.has(e)}let Ed=e=>!Nr(e);function W0(e){typeof e=="function"&&(Ed=t=>t.startsWith("on")?!Nr(t):e(t))}try{W0(require("@emotion/is-prop-valid").default)}catch{}function q0(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||Ho(e[i])||(Ed(i)||n===!0&&Nr(i)||!t&&!Nr(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const $r=f.createContext({});function G0(e,t){if(sd(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Wa(n)?n:void 0,animate:Wa(s)?s:void 0}}return e.inherit!==!1?t:{}}function Q0(e){const{initial:t,animate:n}=G0(e,f.useContext($r));return f.useMemo(()=>({initial:t,animate:n}),[gl(t),gl(n)])}function gl(e){return Array.isArray(e)?e.join(" "):e}const oa=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Td(e,t,n){for(const s in t)!Ho(t[s])&&!ug(s,n)&&(e[s]=t[s])}function J0({transformTemplate:e},t){return f.useMemo(()=>{const n=oa();return hg(n,t,e),Object.assign({},n.vars,n.style)},[t])}function K0(e,t){const n=e.style||{},s={};return Td(s,n,e),Object.assign(s,J0(e,t)),s}function Y0(e,t){const n={},s=K0(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Pd=()=>({...oa(),attrs:{}});function Z0(e,t,n,s){const i=f.useMemo(()=>{const o=Pd();return fg(o,t,mg(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};Td(o,e.style,e),i.style={...o,...i.style}}return i}const X0=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function aa(e){return typeof e!="string"||e.includes("-")?!1:!!(X0.indexOf(e)>-1||/[A-Z]/u.test(e))}function ey(e,t,n,{latestValues:s},i,o=!1,a){const c=(a??aa(e)?Z0:Y0)(t,s,i,e),d=q0(t,typeof e=="string",o),u=e!==f.Fragment?{...d,...c,ref:n}:{},{children:m}=t,p=f.useMemo(()=>Ho(m)?m.get():m,[m]);return f.createElement(e,{...u,children:p})}function ty({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:ny(n,s,i,e),renderState:t()}}function ny(e,t,n,s){const i={},o=s(e,{});for(const p in o)i[p]=pg(o[p]);let{initial:a,animate:l}=e;const c=sd(e),d=gg(e);t&&d&&!c&&e.inherit!==!1&&(a===void 0&&(a=t.initial),l===void 0&&(l=t.animate));let u=n?n.initial===!1:!1;u=u||a===!1;const m=u?l:a;if(m&&typeof m!="boolean"&&!rd(m)){const p=Array.isArray(m)?m:[m];for(let h=0;h<p.length;h++){const x=xg(e,p[h]);if(x){const{transitionEnd:g,transition:b,...w}=x;for(const y in w){let S=w[y];if(Array.isArray(S)){const C=u?S.length-1:0;S=S[C]}S!==null&&(i[y]=S)}for(const y in g)i[y]=g[y]}}}return i}const Id=e=>(t,n)=>{const s=f.useContext($r),i=f.useContext(Mr),o=()=>ty(e,t,s,i);return n?o():ra(o)},sy=Id({scrapeMotionValuesFromProps:bg,createRenderState:oa}),ry=Id({scrapeMotionValuesFromProps:yg,createRenderState:Pd}),iy=Symbol.for("motionComponentSymbol");function oy(e,t,n){const s=f.useRef(n);f.useInsertionEffect(()=>{s.current=n});const i=f.useRef(null);return f.useCallback(o=>{o&&e.onMount?.(o),t&&(o?t.mount(o):t.unmount());const a=s.current;if(typeof a=="function")if(o){const l=a(o);typeof l=="function"&&(i.current=l)}else i.current?(i.current(),i.current=null):a(o);else a&&(a.current=o)},[t])}const Ad=f.createContext({});function bn(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function ay(e,t,n,s,i,o){const{visualElement:a}=f.useContext($r),l=f.useContext(Cd),c=f.useContext(Mr),d=f.useContext(ia),u=d.reducedMotion,m=d.skipAnimations,p=f.useRef(null),h=f.useRef(!1);s=s||l.renderer,!p.current&&s&&(p.current=s(e,{visualState:t,parent:a,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:m,isSVG:o}),h.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));const x=p.current,g=f.useContext(Ad);x&&!x.projection&&i&&(x.type==="html"||x.type==="svg")&&ly(p.current,n,i,g);const b=f.useRef(!1);f.useInsertionEffect(()=>{x&&b.current&&x.update(n,c)});const w=n[wg],y=f.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Sd(()=>{h.current=!0,x&&(b.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),y.current&&x.animationState&&x.animationState.animateChanges())}),f.useEffect(()=>{x&&(!y.current&&x.animationState&&x.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),y.current=!1),x.enteringChildren=void 0)}),x}function ly(e,t,n,s){const{layoutId:i,layout:o,drag:a,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutAnchor:u,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:zd(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!a||l&&bn(l),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:m,layoutScroll:c,layoutRoot:d,layoutAnchor:u})}function zd(e){if(e)return e.options.allowProjection!==!1?e.projection:zd(e.parent)}function xi(e,{forwardMotionProps:t=!1,type:n}={},s,i){s&&V0(s);const o=n?n==="svg":aa(e),a=o?ry:sy;function l(d,u){let m;const p={...f.useContext(ia),...d,layoutId:cy(d)},{isStatic:h}=p,x=Q0(d),g=a(d,h);if(!h&&typeof window<"u"){dy();const b=uy(p);m=b.MeasureLayout,x.visualElement=ay(e,g,p,i,b.ProjectionNode,o)}return r.jsxs($r.Provider,{value:x,children:[m&&x.visualElement?r.jsx(m,{visualElement:x.visualElement,...p}):null,ey(e,d,oy(g,x.visualElement,u),g,h,t,o)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=f.forwardRef(l);return c[iy]=e,c}function cy({layoutId:e}){const t=f.useContext(sa).id;return t&&e!==void 0?t+"-"+e:e}function dy(e,t){f.useContext(Cd).strict}function uy(e){const t=Nd(),{drag:n,layout:s}=t;if(!n&&!s)return{};const i={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function hy(e,t){if(typeof Proxy>"u")return xi;const n=new Map,s=(o,a)=>xi(o,a,e,t),i=(o,a)=>s(o,a);return new Proxy(i,{get:(o,a)=>a==="create"?s:(n.has(a)||n.set(a,xi(a,void 0,e,t)),n.get(a))})}const fy=(e,t)=>t.isSVG??aa(e)?new vg(t):new Sg(t,{allowProjection:e!==f.Fragment});class my extends Bt{constructor(t){super(t),t.animationState||(t.animationState=jg(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();rd(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let py=0;class gy extends Bt{constructor(){super(...arguments),this.id=py++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;if(t&&s===!1){if(this.isExitComplete){const{initial:o,custom:a}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const l=kg(this.node,o,a);if(l){const{transition:c,transitionEnd:d,...u}=l;for(const m in u)this.node.getValue(m)?.jump(u[m])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const xy={animation:{Feature:my},exit:{Feature:gy}};function Ts(e){return{point:{x:e.pageX,y:e.pageY}}}const by=e=>t=>id(t)&&e(t,Ts(t));function gs(e,t,n,s){return Sr(e,t,by(n),s)}const Ld=({current:e})=>e?e.ownerDocument.defaultView:null,xl=(e,t)=>Math.abs(e-t);function yy(e,t){const n=xl(e.x,t.x),s=xl(e.y,t.y);return Math.sqrt(n**2+s**2)}const bl=new Set(["auto","scroll"]);class Rd{constructor(t,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:a=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=h=>{this.handleScroll(h.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Bs(this.lastRawMoveEventInfo,this.transformPagePoint));const h=bi(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,g=yy(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!g)return;const{point:b}=h,{timestamp:w}=qa;this.history.push({...b,timestamp:w});const{onStart:y,onMove:S}=this.handlers;x||(y&&y(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,h)},this.handlePointerMove=(h,x)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=Bs(x,this.transformPagePoint),ft.update(this.updatePoint,!0)},this.handlePointerUp=(h,x)=>{this.end();const{onEnd:g,onSessionEnd:b,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=bi(h.type==="pointercancel"?this.lastMoveEventInfo:Bs(x,this.transformPagePoint),this.history);this.startEvent&&g&&g(h,y),b&&b(h,y)},!id(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=i||window;const c=Ts(t),d=Bs(c,this.transformPagePoint),{point:u}=d,{timestamp:m}=qa;this.history=[{...u,timestamp:m}];const{onSessionStart:p}=n;p&&p(t,bi(d,this.history)),this.removeListeners=od(gs(this.contextWindow,"pointermove",this.handlePointerMove),gs(this.contextWindow,"pointerup",this.handlePointerUp),gs(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(bl.has(s.overflowX)||bl.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,i=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:i.x-n.x,y:i.y-n.y};o.x===0&&o.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,i),ft.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Cg(this.updatePoint)}}function Bs(e,t){return t?{point:t(e.point)}:e}function yl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function bi({point:e},t){return{point:e,delta:yl(e,_d(t)),offset:yl(e,wy(t)),velocity:vy(t,.1)}}function wy(e){return e[0]}function _d(e){return e[e.length-1]}function vy(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=_d(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Ga(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&i.timestamp-s.timestamp>Ga(t)*2&&(s=e[1]);const o=Ng(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const a={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Sy(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?jr(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?jr(n,e,s.max):Math.min(e,n)),e}function wl(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function jy(e,{top:t,left:n,bottom:s,right:i}){return{x:wl(e.x,n,i),y:wl(e.y,t,s)}}function vl(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function ky(e,t){return{x:vl(e.x,t.x),y:vl(e.y,t.y)}}function Cy(e,t){let n=.5;const s=eo(e),i=eo(t);return i>s?n=Qa(t.min,t.max-s,e.min):s>i&&(n=Qa(e.min,e.max-i,t.min)),Eg(0,1,n)}function Ny(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const io=.35;function Ey(e=io){return e===!1?e=0:e===!0&&(e=io),{x:Sl(e,"left","right"),y:Sl(e,"top","bottom")}}function Sl(e,t,n){return{min:jl(e,t),max:jl(e,n)}}function jl(e,t){return typeof e=="number"?e:e[t]||0}const Ty=new WeakMap;class Py{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Tg(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=m=>{n&&this.snapToCursor(Ts(m).point),this.stopAnimation()},a=(m,p)=>{const{drag:h,dragPropagation:x,onDragStart:g}=this.getProps();if(h&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lg(h),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),zt(w=>{let y=this.getAxisMotionValue(w).get()||0;if(Rg.test(y)){const{projection:S}=this.visualElement;if(S&&S.layout){const C=S.layout.layoutBox[w];C&&(y=eo(C)*(parseFloat(y)/100))}}this.originPoint[w]=y}),g&&ft.update(()=>g(m,p),!1,!0),Ja(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},l=(m,p)=>{this.latestPointerEvent=m,this.latestPanInfo=p;const{dragPropagation:h,dragDirectionLock:x,onDirectionLock:g,onDrag:b}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=p;if(x&&this.currentDirection===null){this.currentDirection=Ay(w),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",p.point,w),this.updateAxis("y",p.point,w),this.visualElement.render(),b&&ft.update(()=>b(m,p),!1,!0)},c=(m,p)=>{this.latestPointerEvent=m,this.latestPanInfo=p,this.stop(m,p),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new Rd(t,{onSessionStart:o,onStart:a,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Ld(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:a}=i;this.startAnimation(a);const{onDragEnd:l}=this.getProps();l&&ft.postRender(()=>l(s,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!Us(t,i,this.currentDirection))return;const o=this.getAxisMotionValue(t);let a=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(a=Sy(a,this.constraints[t],this.elastic[t])),o.set(a)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&bn(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=jy(s.layoutBox,t):this.constraints=!1,this.elastic=Ey(n),i!==this.constraints&&!bn(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&zt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Ny(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!bn(t))return!1;const s=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;i.root&&(i.root.scroll=void 0,i.root.updateScroll());const o=Pg(s,i.root,this.visualElement.getTransformPagePoint());let a=ky(i.layout.layoutBox,o);if(n){const l=n(Ig(a));this.hasMutatedConstraints=!!l,l&&(a=Ag(l))}return a}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:a,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=zt(u=>{if(!Us(u,n,this.currentDirection))return;let m=c&&c[u]||{};(a===!0||a===u)&&(m={min:0,max:0});const p=i?200:1e6,h=i?40:1e7,x={type:"inertia",velocity:s?t[u]:0,bounceStiffness:p,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(u,x)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Ja(this.visualElement,t),s.start(zg(t,s,0,n,this.visualElement,!1))}stopAnimation(){zt(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps()[n];return i||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){zt(n=>{const{drag:s}=this.getProps();if(!Us(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:a,max:l}=i.layout.layoutBox[n],c=o.get()||0;o.set(t[n]-jr(a,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!bn(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};zt(a=>{const l=this.getAxisMotionValue(a);if(l&&this.constraints!==!1){const c=l.get();i[a]=Cy({min:c,max:c},this.constraints[a])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),zt(a=>{if(!Us(a,t,null))return;const l=this.getAxisMotionValue(a),{min:c,max:d}=this.constraints[a];l.set(jr(c,d,i[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ty.set(this.visualElement,this);const t=this.visualElement.current,n=gs(t,"pointerdown",d=>{const{drag:u,dragListener:m=!0}=this.getProps(),p=d.target,h=p!==t&&_g(p);u&&m&&!h&&this.start(d)});let s;const i=()=>{const{dragConstraints:d}=this.getProps();bn(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Iy(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,a=o.addEventListener("measure",i);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ft.read(i);const l=Sr(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:u})=>{this.isDragging&&u&&(zt(m=>{const p=this.getAxisMotionValue(m);p&&(this.originPoint[m]+=d[m].translate,p.set(p.get()+d[m].translate))}),this.visualElement.render())}));return()=>{l(),n(),a(),c&&c(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:a=io,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:a,dragMomentum:l}}}function kl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Iy(e,t,n){const s=Ka(e,kl(n)),i=Ka(t,kl(n));return()=>{s(),i()}}function Us(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ay(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class zy extends Bt{constructor(t){super(t),this.removeGroupControls=er,this.removeListeners=er,this.controls=new Py(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||er}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const yi=e=>(t,n)=>{e&&ft.update(()=>e(t,n),!1,!0)};class Ly extends Bt{constructor(){super(...arguments),this.removePointerDownListener=er}onPointerDown(t){this.session=new Rd(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ld(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:yi(t),onStart:yi(n),onMove:yi(s),onEnd:(o,a)=>{delete this.session,i&&ft.postRender(()=>i(o,a))}}}mount(){this.removePointerDownListener=gs(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let wi=!1;class Ry extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),wi&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Dg.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:a}=s;return a&&(a.isPresent=o,t.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),wi=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==o?a.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?a.promote():a.relegate()||ft.postRender(()=>{const l=a.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Og.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;wi=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Od(e){const[t,n]=jd(),s=f.useContext(sa);return r.jsx(Ry,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Ad),isPresent:t,safeToRemove:n})}const _y={pan:{Feature:Ly},drag:{Feature:zy,ProjectionNode:ad,MeasureLayout:Od}};function Cl(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&ft.postRender(()=>o(t,Ts(t)))}class Oy extends Bt{mount(){const{current:t}=this.node;t&&(this.unmount=Mg(t,(n,s)=>(Cl(this.node,s,"Start"),i=>Cl(this.node,i,"End"))))}unmount(){}}class Dy extends Bt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=od(Sr(this.node.current,"focus",()=>this.onFocus()),Sr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nl(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&ft.postRender(()=>o(t,Ts(t)))}class My extends Bt{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=$g(t,(i,o)=>(Nl(this.node,o,"Start"),(a,{success:l})=>Nl(this.node,a,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const oo=new WeakMap,vi=new WeakMap,$y=e=>{const t=oo.get(e.target);t&&t(e)},Fy=e=>{e.forEach($y)};function By({root:e,...t}){const n=e||document;vi.has(n)||vi.set(n,{});const s=vi.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Fy,{root:e,...t})),s[i]}function Uy(e,t,n){const s=By(t);return oo.set(e,n),s.observe(e),()=>{oo.delete(e),s.unobserve(e)}}const Vy={some:0,all:1};class Hy extends Bt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=t,a={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Vy[i]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,o&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:u,onViewportLeave:m}=this.node.getProps(),p=d?u:m;p&&p(c)};this.stopObserver=Uy(this.node.current,a,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Wy(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function Wy({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const qy={inView:{Feature:Hy},tap:{Feature:My},focus:{Feature:Dy},hover:{Feature:Oy}},Gy={layout:{ProjectionNode:ad,MeasureLayout:Od}},Qy={...xy,...qy,..._y,...Gy},ir=hy(Qy,fy);async function Er(e){if(typeof window>"u")return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("[OpenLearn Clipboard] Failed to copy text to clipboard:",t),!1}}function Jy(){const e=mx(o=>o.toasts),[t,n]=f.useState(null),s=async(o,a)=>{o.stopPropagation();const l=`[${a.title}] ${a.message}`;await Er(l)&&(n(a.id),setTimeout(()=>n(null),2e3))},i=o=>{switch(o){case"error":return{border:"border-l-4 border-rose-500",iconBg:"bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400",icon:r.jsx(br,{size:16})};case"warning":return{border:"border-l-4 border-amber-500",iconBg:"bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400",icon:r.jsx(Mt,{size:16})};case"info":return{border:"border-l-4 border-blue-500",iconBg:"bg-blue-50 text-blue-600 dark:bg-blue-950/60 dark:text-blue-400",icon:r.jsx(Yc,{size:16})};case"success":default:return{border:"border-l-4 border-emerald-500",iconBg:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400",icon:r.jsx(at,{size:16})}}};return r.jsx("div",{className:"fixed bottom-6 right-6 z-50 flex flex-col gap-3 min-w-[320px] max-w-sm pointer-events-none",children:r.jsx(kd,{children:e.map(o=>{const a=i(o.type),l=t===o.id;return r.jsxs(ir.div,{initial:{y:50,x:50,scale:.9},animate:{y:0,x:0,scale:1},exit:{scale:.85,transition:{duration:.2}},transition:{type:"spring",stiffness:300,damping:24},className:`pointer-events-auto w-full bg-white dark:bg-slate-900 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 ${a.border} overflow-hidden text-gray-900 dark:text-gray-100`,id:`toast-${o.id}`,children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:`p-1 rounded-full shrink-0 ${a.iconBg}`,children:a.icon}),r.jsx("p",{className:"font-semibold text-sm font-sans truncate",children:o.title})]}),(o.type==="error"||o.type==="warning")&&r.jsxs("button",{type:"button",onClick:c=>s(c,o),className:`text-xs font-bold px-1.5 py-0.5 rounded transition-all flex items-center gap-1 cursor-pointer shrink-0 ${l?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 dark:bg-slate-800 dark:hover:bg-slate-700 text-gray-600 dark:text-gray-300"}`,title:"复制错误内容",children:[l?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:l?"已复制":"复制"})]})]}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mt-2 leading-relaxed font-sans break-words",children:o.message}),o.action&&r.jsx("div",{className:"mt-2.5",children:r.jsx("button",{type:"button",onClick:()=>{o.action?.onClick(),Ve.getState().removeToast(o.id)},className:"px-3 py-1 bg-indigo-600 hover:bg-indigo-700 text-white text-xs font-bold rounded-lg shadow-xs transition-colors cursor-pointer flex items-center gap-1",children:r.jsx("span",{children:o.action.label})})})]}),r.jsx("button",{type:"button",onClick:()=>Ve.getState().removeToast(o.id),"aria-label":"关闭提示",className:"text-subtle hover:text-main hover:bg-gray-50 dark:hover:bg-slate-800 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:r.jsx(Oe,{size:14})})]},o.id)})})})}const ao=new Set;function Ky(e){return ao.add(e),()=>{ao.delete(e)}}const El=30,Tl=(e,t)=>Math.min(e,t.length);function la(e){const t=new Date(e.timestamp).toLocaleString(),n=[`### [${e.type.toUpperCase()}] ${e.title}`,`- **发生时间**: ${t}`,`- **页面路径**: ${e.url||"N/A"}`,`- **错误摘要**: ${e.message}`];return e.endpoint&&n.push(`- **请求接口**: \`${e.endpoint}\` (HTTP ${e.status||"Unknown"})`),e.componentStack&&n.push("- **组件堆栈**:","```",e.componentStack.trim(),"```"),e.stack&&n.push("- **调用栈 (Stack Trace)**:","```",e.stack.trim(),"```"),n.join(`
|
|
21
21
|
`)}function Dd(e){const t=new Date(e.timestamp).toLocaleString(),n=[`### [学生端异常] ${e.studentName||e.studentId} - ${e.title}`,`- **学生信息**: ${e.studentName||"未知"} (\`${e.studentId}\`)`,`- **关联课节**: ${e.lessonId||"未指定"}`,`- **关联班级**: ${e.classId||"未指定"}`,`- **发生时间**: ${t}`,`- **页面路径**: ${e.url||"N/A"}`,`- **错误摘要**: ${e.message}`];return e.endpoint&&n.push(`- **请求接口**: \`${e.endpoint}\` (HTTP ${e.status||"Unknown"})`),e.componentStack&&n.push("- **组件堆栈**:","```",e.componentStack.trim(),"```"),e.stack&&n.push("- **调用栈 (Stack Trace)**:","```",e.stack.trim(),"```"),n.join(`
|
|
22
22
|
`)}function Yy(e,t=[]){const n=new Date().toLocaleString(),s=typeof window<"u"?window.location.href:"Unknown",i=typeof navigator<"u"?navigator.userAgent:"Unknown";if(e.length===0&&t.length===0)return`# 🛠️ OpenLearn 系统诊断报告
|
|
23
23
|
- 生成时间: ${n}
|
|
@@ -40,7 +40,7 @@ ${w}`:w),o(!1),l(null),d({})};return r.jsxs("div",{className:"relative shrink-0"
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
`)}const Xt=St((e,t)=>({errors:[],studentErrors:[],activeTab:"local",isErrorCenterOpen:!1,unreadCount:0,addError:n=>{const s=Date.now(),i=n.url||(typeof window<"u"?window.location.href:""),o=n.userAgent||(typeof navigator<"u"?navigator.userAgent:""),a=t().errors.findIndex(c=>c.type===n.type&&c.message===n.message&&s-c.timestamp<2e3);if(a>=0)return t().errors[a];const l={id:`err_${s}_${Math.random().toString(36).slice(2,7)}`,timestamp:n.timestamp||s,url:i,userAgent:o,type:n.type,title:n.title,message:n.message,stack:n.stack,componentStack:n.componentStack,endpoint:n.endpoint,status:n.status};return e(c=>{const d=[l,...c.errors].slice(0,El);return{errors:d,unreadCount:Tl(c.unreadCount+1,d)}}),ao.forEach(c=>{try{c(l)}catch(d){console.error("[ErrorStore] Error in errorListener:",d)}}),l},removeError:n=>e(s=>{const i=s.errors.filter(o=>o.id!==n);return{errors:i,unreadCount:Tl(s.unreadCount,i)}}),clearErrors:()=>e({errors:[],unreadCount:0}),addStudentError:n=>{const s=Date.now(),i=n.timestamp||s;e(o=>o.studentErrors.some(d=>d.studentId===n.studentId&&d.type===n.type&&d.message===n.message&&Math.abs(i-d.timestamp)<2e3)?o:{studentErrors:[{...n,id:n.id||`st_err_${s}_${Math.random().toString(36).slice(2,7)}`,timestamp:i},...o.studentErrors].slice(0,El)})},removeStudentError:n=>e(s=>({studentErrors:s.studentErrors.filter(i=>i.id!==n)})),clearStudentErrors:()=>e({studentErrors:[]}),setIsErrorCenterOpen:n=>e({isErrorCenterOpen:n,unreadCount:n?0:t().unreadCount}),setActiveTab:n=>e({activeTab:n}),markAllRead:()=>e({unreadCount:0})}));function pt(e){return Ft(Xt,e||(t=>t))}function Zy(){const e=de(T=>T.session),t=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live")),n=e?.role==="student"||t,s=pt(T=>T.errors),i=pt(T=>T.studentErrors),o=pt(T=>T.activeTab),a=pt(T=>T.setActiveTab),l=pt(T=>T.isErrorCenterOpen),c=pt(T=>T.setIsErrorCenterOpen),d=pt(T=>T.clearErrors),u=pt(T=>T.clearStudentErrors),m=pt(T=>T.removeError),p=pt(T=>T.removeStudentError),[h,x]=f.useState(!1),[g,b]=f.useState(null),[w,y]=f.useState(new Set),[S,C]=f.useState(!1),k=s.length+(n?0:i.length),v=s.length>0||!n&&i.length>0,N=T=>{y(z=>{const R=new Set(z);return R.has(T)?R.delete(T):R.add(T),R})},O=async()=>{const T=Yy(s,n?[]:i);await Er(T)&&(x(!0),setTimeout(()=>x(!1),2500))},D=async(T,z,R=!1)=>{T.stopPropagation();const $=R?Dd(z):la(z);await Er($)&&(b(z.id),setTimeout(()=>b(null),2500))},_=T=>{switch(T){case"react":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/60 dark:text-rose-400 border border-rose-200 dark:border-rose-800",children:"React"});case"api":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-purple-100 text-purple-700 dark:bg-purple-950/60 dark:text-purple-400 border border-purple-200 dark:border-purple-800",children:"API 5xx"});case"promise":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-amber-100 text-amber-700 dark:bg-amber-950/60 dark:text-amber-400 border border-amber-200 dark:border-amber-800",children:"Promise"});default:return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-blue-100 text-blue-700 dark:bg-blue-950/60 dark:text-blue-400 border border-blue-200 dark:border-blue-800",children:"Runtime"})}};return r.jsxs(r.Fragment,{children:[v&&!l&&!S&&(n?r.jsxs(ir.button,{type:"button",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},className:"fixed bottom-5 left-5 z-40 w-8 h-8 rounded-full bg-slate-900/80 hover:bg-slate-900 text-rose-400 border border-rose-500/40 shadow-lg flex items-center justify-center cursor-pointer transition-all hover:scale-105 select-none",onClick:()=>c(!0),id:"system-error-pill",title:`系统状态提示: ${s.length} 处异常`,children:[r.jsx(Mt,{size:15}),r.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 rounded-full bg-rose-500 text-white text-[10px] font-bold flex items-center justify-center leading-none shadow-xs border border-slate-900",children:s.length})]}):r.jsxs(ir.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.9},className:"fixed bottom-5 left-5 z-40 flex items-center gap-2 bg-slate-900/90 hover:bg-slate-900 backdrop-blur-md text-white px-3.5 py-2 rounded-2xl shadow-xl border border-rose-500/40 cursor-pointer select-none transition-all group",onClick:()=>{s.length===0&&i.length>0&&a("student"),c(!0)},id:"system-error-pill",children:[r.jsxs("div",{className:"relative flex items-center justify-center",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-3 w-3 rounded-full bg-rose-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-rose-500"})]}),r.jsx(Mt,{size:15,className:"text-rose-400 group-hover:scale-110 transition-transform"}),r.jsxs("div",{className:"text-xs font-semibold flex items-center gap-1.5",children:[r.jsx("span",{children:"捕获到"}),r.jsx("span",{className:"bg-rose-500/80 text-white font-mono px-1.5 py-0.2 rounded-md text-xs font-bold",children:k}),r.jsx("span",{children:"处系统异常"}),i.length>0&&r.jsxs("span",{className:"text-[10px] text-rose-300 font-normal",children:["(含学生端 ",i.length,")"]})]}),r.jsx("button",{type:"button",className:"text-xs font-bold text-rose-300 hover:text-white bg-white/10 hover:bg-white/20 px-2 py-0.5 rounded-lg transition-colors ml-1",children:"查看与复制"}),r.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),C(!0)},className:"text-gray-400 hover:text-gray-200 p-0.5 hover:bg-white/10 rounded transition-colors ml-0.5",title:"暂时隐藏胶囊",children:r.jsx(Oe,{size:13})})]})),r.jsx(kd,{children:l&&r.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-xs flex items-center justify-center p-4 z-50 overflow-hidden select-text",children:r.jsxs(ir.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden text-gray-900 dark:text-gray-100",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-gray-800 flex items-center justify-between bg-gray-50/80 dark:bg-slate-850/80 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-rose-500/10 text-rose-600 dark:text-rose-400 border border-rose-500/20 rounded-xl",children:r.jsx(ig,{size:18})}),r.jsxs("div",{children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[r.jsx("span",{children:"系统异常诊断中心 (System Diagnostics)"}),r.jsxs("span",{className:"text-xs font-normal text-gray-500 dark:text-gray-400",children:["(",k," 项记录)"]})]})}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"自动捕获运行时、Promise 及接口 5xx 异常,支持一键导出 Markdown 格式排查报告。"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:O,disabled:k===0,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 shadow-xs cursor-pointer ${h?"bg-emerald-600 text-white":"bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-40 disabled:cursor-not-allowed"}`,title:"复制所有异常报告为 Markdown 文本",children:[h?r.jsx(ht,{size:13}):r.jsx(vn,{size:13}),r.jsx("span",{children:h?"已复制全部!":"一键复制全部诊断日志"})]}),r.jsx("button",{type:"button",onClick:()=>{!n&&o==="student"?u():d()},disabled:o==="student"?i.length===0:s.length===0,className:"p-1.5 text-gray-500 hover:text-rose-600 dark:text-gray-400 dark:hover:text-rose-400 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",title:o==="student"?"清空学生端异常记录":"清空记录",children:r.jsx(_r,{size:16})}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"p-1.5 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors cursor-pointer",children:r.jsx(Oe,{size:16})})]})]}),!n&&r.jsxs("div",{className:"px-5 py-2 border-b border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-slate-900/50 flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>a("local"),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${o==="local"?"bg-white dark:bg-slate-800 text-indigo-600 dark:text-indigo-400 shadow-xs border border-gray-200 dark:border-gray-700":"text-gray-500 hover:text-gray-800 dark:text-gray-400"}`,children:[r.jsx(og,{size:13}),r.jsxs("span",{children:["本机异常 (",s.length,")"]})]}),r.jsxs("button",{type:"button",onClick:()=>a("student"),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${o==="student"?"bg-white dark:bg-slate-800 text-rose-600 dark:text-rose-400 shadow-xs border border-gray-200 dark:border-gray-700":"text-gray-500 hover:text-gray-800 dark:text-gray-400"}`,children:[r.jsx(xr,{size:14}),r.jsxs("span",{children:["学生端异常 (",i.length,")"]}),i.length>0&&r.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-rose-500 animate-pulse"})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 min-h-0 bg-slate-50/50 dark:bg-slate-950/30",children:!n&&o==="student"?i.length===0?r.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500 space-y-2",children:[r.jsx(ht,{size:32,className:"mx-auto text-emerald-500 opacity-80"}),r.jsx("p",{className:"text-sm font-semibold",children:"暂无学生端上报的系统异常"}),r.jsx("p",{className:"text-xs opacity-75",children:"全班学生端运行良好,未发生未捕获的前端崩溃或接口 5xx 故障。"})]}):i.map((T,z)=>{const R=w.has(T.id),$=g===T.id;return r.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden shadow-2xs hover:border-gray-300 dark:hover:border-gray-700 transition-colors",children:[r.jsxs("div",{onClick:()=>N(T.id),className:"px-4 py-3 flex items-start justify-between gap-3 cursor-pointer select-none hover:bg-gray-50/50 dark:hover:bg-slate-850/50 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-2.5 min-w-0 flex-1",children:[r.jsx("span",{className:"text-gray-400 mt-0.5 shrink-0",children:R?r.jsx(Nn,{size:15}):r.jsx(Cn,{size:15})}),r.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/60 dark:text-rose-400 border border-rose-200 dark:border-rose-800 flex items-center gap-1",children:[r.jsx(xr,{size:11}),r.jsx("span",{children:T.studentName||T.studentId})]}),_(T.type),r.jsxs("span",{className:"font-bold text-xs text-gray-900 dark:text-gray-100 truncate",children:["#",i.length-z," ",T.title]}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:new Date(T.timestamp).toLocaleTimeString()})]}),r.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-mono break-all line-clamp-2",children:T.message}),r.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 font-mono truncate",children:[r.jsxs("span",{children:["学生学号/ID: ",T.studentId]}),T.lessonId&&r.jsxs("span",{children:["课节: ",T.lessonId]}),T.classId&&r.jsxs("span",{children:["班级: ",T.classId]}),T.endpoint&&r.jsxs("span",{children:["接口: ",T.endpoint]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsxs("button",{type:"button",onClick:I=>D(I,T,!0),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1 cursor-pointer ${$?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-slate-800 dark:hover:bg-slate-700 dark:text-gray-200"}`,title:"一键复制此条学生错误报告",children:[$?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:$?"已复制":"复制"})]}),r.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),p(T.id)},className:"p-1 text-gray-400 hover:text-rose-600 rounded transition-colors cursor-pointer",title:"移除此项",children:r.jsx(Oe,{size:13})})]})]}),R&&r.jsxs("div",{className:"px-4 py-3 bg-slate-900 text-slate-200 border-t border-gray-100 dark:border-gray-800 text-xs font-mono space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 border-b border-slate-800 pb-1.5",children:[r.jsxs("span",{children:["学生: ",T.studentName||"未知"," (",T.studentId,")"]}),r.jsxs("span",{children:["页面地址: ",T.url||"未知"]}),r.jsxs("span",{children:["时间: ",new Date(T.timestamp).toLocaleString()]})]}),T.stack&&r.jsxs("div",{children:[r.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-48 overflow-y-auto opacity-90",children:T.stack})]}),T.componentStack&&r.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[r.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-36 overflow-y-auto opacity-80",children:T.componentStack})]})]})]},T.id)}):s.length===0?r.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500 space-y-2",children:[r.jsx(ht,{size:32,className:"mx-auto text-emerald-500 opacity-80"}),r.jsx("p",{className:"text-sm font-semibold",children:"暂无捕获到的系统异常"}),r.jsx("p",{className:"text-xs opacity-75",children:"系统运行顺畅,所有模块均在正常状态下运作。"})]}):s.map((T,z)=>{const R=w.has(T.id),$=g===T.id;return r.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden shadow-2xs hover:border-gray-300 dark:hover:border-gray-700 transition-colors",children:[r.jsxs("div",{onClick:()=>N(T.id),className:"px-4 py-3 flex items-start justify-between gap-3 cursor-pointer select-none hover:bg-gray-50/50 dark:hover:bg-slate-850/50 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-2.5 min-w-0 flex-1",children:[r.jsx("span",{className:"text-gray-400 mt-0.5 shrink-0",children:R?r.jsx(Nn,{size:15}):r.jsx(Cn,{size:15})}),r.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[_(T.type),r.jsxs("span",{className:"font-bold text-xs text-gray-900 dark:text-gray-100 truncate",children:["#",s.length-z," ",T.title]}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:new Date(T.timestamp).toLocaleTimeString()})]}),r.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-mono break-all line-clamp-2",children:T.message}),T.endpoint&&r.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate",children:["接口: ",T.endpoint]})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsxs("button",{type:"button",onClick:I=>D(I,T,!1),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1 cursor-pointer ${$?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-slate-800 dark:hover:bg-slate-700 dark:text-gray-200"}`,title:"一键复制此条错误报告",children:[$?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:$?"已复制":"复制"})]}),r.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),m(T.id)},className:"p-1 text-gray-400 hover:text-rose-600 rounded transition-colors cursor-pointer",title:"移除此项",children:r.jsx(Oe,{size:13})})]})]}),R&&r.jsxs("div",{className:"px-4 py-3 bg-slate-900 text-slate-200 border-t border-gray-100 dark:border-gray-800 text-xs font-mono space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 border-b border-slate-800 pb-1.5",children:[r.jsxs("span",{children:["页面地址: ",T.url||"未知"]}),r.jsxs("span",{children:["时间: ",new Date(T.timestamp).toLocaleString()]})]}),T.stack&&r.jsxs("div",{children:[r.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-48 overflow-y-auto opacity-90",children:T.stack})]}),T.componentStack&&r.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[r.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-36 overflow-y-auto opacity-80",children:T.componentStack})]})]})]},T.id)})})]})})})]})}let Pl=!1;function Xy(){if(Pl)return;Pl=!0;const e=()=>Je(()=>import("./ActivityWorkspaceWidget-5PzyxF6a.js"),__vite__mapDeps([19,1,2,3,4])).then(t=>({default:()=>r.jsx(t.ActivityWorkspaceWidget,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,Ne.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}function ew(){return{addToast:f.useCallback((t,n,s="info")=>{const i=Math.random().toString(36).substring(2,9);ve.getState().addToast({id:i,title:t,message:n,type:s}),setTimeout(()=>{ve.getState().removeToast(i)},6e3)},[])}}function Il(e){if(typeof window>"u")return;const t=JSON.stringify({source:e.source,message:e.message.slice(0,500),stack:e.stack?e.stack.slice(0,2e3):void 0,path:window.location.pathname});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&navigator.sendBeacon("/api/client-errors",new Blob([t],{type:"application/json"})))return}catch{}fetch("/api/client-errors",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}function tw(){f.useEffect(()=>{if(typeof window>"u")return;const e=o=>{const a=o.reason,l=a instanceof Error?a.message:typeof a=="string"?a:JSON.stringify(a)||"Unhandled promise rejection",c=a instanceof Error?a.stack:void 0;Xt.getState().addError({type:"promise",title:"未捕获的异步异常 (Unhandled Promise)",message:l,stack:c}),Il({source:"promise",message:l,stack:c}),console.warn("[GlobalErrorCapture] Caught unhandled rejection:",a)},t=o=>{if(!o.message&&!o.error)return;const a=o.message||(o.error?.message??"Unknown script error"),l=o.error?.stack;Xt.getState().addError({type:"runtime",title:"JavaScript 运行时错误 (Runtime Error)",message:a,stack:l}),Il({source:"runtime",message:a,stack:l}),console.warn("[GlobalErrorCapture] Caught window error:",o.error||o.message)},n=window.fetch,s=async(...o)=>{try{const a=await n(...o);if(!a.ok&&a.status>=500)try{const c=await a.clone().text();let d="";try{const p=JSON.parse(c);d=p.error||p.message||p.details||c}catch{d=c.slice(0,300)}const u=o[0],m=typeof u=="string"?u:u instanceof Request?u.url:String(u);Xt.getState().addError({type:"api",title:`服务端接口错误 (HTTP ${a.status})`,message:d||`Request failed with status ${a.status}`,endpoint:m,status:a.status})}catch{}return a}catch(a){const l=o[0],c=typeof l=="string"?l:l instanceof Request?l.url:String(l);throw c&&(c.startsWith("/api")||c.includes("/api/"))&&Xt.getState().addError({type:"api",title:"网络请求失败 (Network Disconnected / Error)",message:a?.message||"Failed to fetch API endpoint",endpoint:c,stack:a?.stack}),a}},i=Ky(o=>{try{const a=ve.getState(),l=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live"));if(!(a.session?.role==="student"||l))return;const d=typeof window<"u"?new URLSearchParams(window.location.search):null,u=a.session?.userId||d?.get("studentId")||"anonymous_student",m=a.session?.name||a.session?.username||d?.get("studentName")||u,p=a.selectedLesson||d?.get("lessonId")||null,h=a.liveClassSelectedClassId||d?.get("classId")||null,x={studentId:u,studentName:m,lessonId:p,classId:h,error:o},g=lt();if(g&&g.connected)g.emit("student-client-error",x);else{const b="/api/diagnostics/report",w=JSON.stringify(x);typeof navigator<"u"&&navigator.sendBeacon?navigator.sendBeacon(b,new Blob([w],{type:"application/json"})):fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:w}).catch(()=>{})}}catch(a){console.warn("[GlobalErrorCapture] Failed to report student error:",a)}});return window.fetch=s,window.addEventListener("unhandledrejection",e),window.addEventListener("error",t),()=>{window.fetch=n,window.removeEventListener("unhandledrejection",e),window.removeEventListener("error",t),i()}},[])}function nw(e){const{fetchStudents:t}=e,n=de(S=>S.session),s=de(S=>S.setSession),i=de(S=>S.lang),o=de(S=>S.setLang),[a,l]=f.useState("teacher"),[c,d]=f.useState(!0),[u,m]=f.useState("normal"),[p,h]=f.useState(null),[x,g]=f.useState(!1);return f.useEffect(()=>{if(!n||n.role!=="teacher")return;const S=async()=>{try{const{ok:k,status:v,data:N}=await Bg();k?(N.status==="warning"||N.warning?m("warning"):m("normal"),d(!0)):v===429||v===503?(m("warning"),d(!0)):(m("error"),d(!1))}catch{m("error"),d(!1)}};S();const C=setInterval(S,5e3);return()=>clearInterval(C)},[n]),f.useEffect(()=>{(async()=>{try{const{ok:C,data:k}=await ld();C&&ve.getState().setSiteInfo({siteName:k.siteName||"",slogan:k.slogan||"",logoUrl:k.logoUrl||null})}catch(C){console.warn("Failed to fetch site settings:",C)}})()},[]),{session:n,setSession:s,lang:i,setLang:o,activeRole:a,setActiveRole:l,setActiveStudentId:h,activeStudentId:p,dbConnected:c,dbStatus:u,profileOpen:x,setProfileOpen:g,handleLoginSuccess:S=>{if(s(S),S.role==="teacher"){l("teacher");const C=typeof window<"u"?ms(window.location.hash):null;ve.getState().setTeacherTab(C||"live_class")}else l("student"),h(S.studentId),t()},handleLogout:async()=>{try{await Vg()}catch(S){console.error("Logout failed",S)}s(null)},toggleLanguage:()=>{o(i==="zh"?"en":"zh")}}}function sw(e){const{activeStudentId:t,activeRole:n,students:s,liveClassFocusLocked:i,setIsFollowingTeacher:o,lang:a,addToast:l}=e,[c,d]=f.useState("dashboard"),u=s.find(R=>R.id===t),m=n==="student"&&(!!t&&!!u?.locked_lesson_id||i),p=u?.lock_mode||"full",h=m,x=m&&p==="full",g=(()=>{if(!u?.lock_target)return null;try{return typeof u.lock_target=="string"?JSON.parse(u.lock_target):u.lock_target}catch{return null}})(),b=f.useRef(h),w=f.useRef(p),y=f.useRef(c);f.useEffect(()=>{b.current=h,w.current=p,y.current=c},[h,p,c]),f.useEffect(()=>{h&&(o(!0),d("lesson"))},[h,o]);const[S,C]=f.useState("whiteboard");f.useEffect(()=>{h&&g?.tab&&C(g.tab)},[h,g?.tab]);const k=R=>{const $=typeof R=="function"?R(y.current):R;if(b.current&&$!=="lesson"){v();return}d($)},v=()=>{const R=w.current==="navigation";l(a==="zh"?R?"🔒 答题锁定":"🔒 全班专注锁定":R?"🔒 Answer Locked":"🔒 Class Focus Locked",a==="zh"?R?"老师已开启答题锁定,请在当前页面完成作答并提交,暂时无法离开本页。":"老师已开启全班专注锁定,暂时无法切换页面,请跟随教师当前授课内容。":R?"The teacher locked the screen for answering. Please complete your work on this page before leaving.":"The teacher locked the class focus. Navigation is disabled — please follow the current lesson.","warning")},[N,O]=f.useState(null),[D,_]=f.useState("none"),[T,z]=f.useState(!0);return f.useEffect(()=>{c!=="lesson"&&z(!0)},[c]),{studentViewStatus:c,setStudentViewStatus:k,isStudentLocked:m,isNavigationLocked:h,isInteractionLocked:x,studentLockMode:p,studentLockTarget:g,studentLessonTab:S,setStudentLessonTab:C,studentSelectedCourseware:N,setStudentSelectedCourseware:O,studentFullscreenPanel:D,setStudentFullscreenPanel:_,isStudentLessonContentCollapsed:T,setIsStudentLessonContentCollapsed:z,notifyLockedNavigation:v}}function rw({lang:e,addToast:t,fetchStudents:n}){const[s,i]=f.useState(!1),o=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live")),a=typeof window<"u"?new URLSearchParams(window.location.search).get("studentId"):null,l=typeof window<"u"?new URLSearchParams(window.location.search).get("lessonId"):null,c=typeof window<"u"?new URLSearchParams(window.location.search).get("classId"):null,d=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="stage_display"||window.location.hash.includes("stage_display")),u=typeof window<"u"?new URLSearchParams(window.location.search).get("lessonId"):null,m=typeof window<"u"?new URLSearchParams(window.location.search).get("title"):null,p=typeof window<"u"?new URLSearchParams(window.location.search).get("lang"):null,h=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_preview"||window.location.hash.includes("student_preview")),x=o||h,[g,b]=f.useState(!0),[w,y]=f.useState(!1);f.useEffect(()=>{Dr.getState().initTheme(),wn.getState().initFontSize();const L=F=>{(F.ctrlKey||F.metaKey)&&F.altKey&&(F.key==="+"||F.key==="="?(F.preventDefault(),wn.getState().increaseScale()):F.key==="-"||F.key==="_"?(F.preventDefault(),wn.getState().decreaseScale()):F.key==="0"&&(F.preventDefault(),wn.getState().resetScale()))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const S=de(L=>L.session),C=de(L=>L.setSession),[k,v]=f.useState(!0),N=nw({fetchStudents:n}),{activeRole:O,setActiveRole:D,activeStudentId:_,setActiveStudentId:T,dbConnected:z,dbStatus:R,profileOpen:$,setProfileOpen:I,handleLoginSuccess:B,handleLogout:H,toggleLanguage:A}=N,U=de(L=>L.students);de(L=>L.dataVersion);const j=de(L=>L.setSelectedLesson),V=sw({activeStudentId:_,activeRole:O,students:U,liveClassFocusLocked:w,setIsFollowingTeacher:b,lang:e,addToast:t}),{studentViewStatus:G,setStudentViewStatus:E,isStudentLocked:W,isNavigationLocked:Y,isInteractionLocked:K,studentLockMode:ne,studentLockTarget:fe,studentLessonTab:je,setStudentLessonTab:X,studentSelectedCourseware:me,setStudentSelectedCourseware:ke,studentFullscreenPanel:Se,setStudentFullscreenPanel:M,isStudentLessonContentCollapsed:Z,setIsStudentLessonContentCollapsed:ee,notifyLockedNavigation:te}=V;f.useEffect(()=>{(async()=>{try{const{ok:F,data:q}=await Ug();if(F&&q&&q.session)if(C(q.session),x){D("student"),E("lesson");const J=a||q.session.studentId;J&&T(J),l&&j(l),n()}else D(q.session.role),l&&j(l),q.session.role==="student"&&q.session.studentId&&(T(q.session.studentId),n())}catch(F){console.warn("Session check failed",F)}finally{v(!1)}})()},[]);const ce=de(L=>L.teacherTab),oe=de(L=>L.setTeacherTab),xe=f.useRef(!0);f.useEffect(()=>{if(x||d)return;const L=()=>{const q=ms(window.location.hash);q&&q!==ve.getState().teacherTab&&oe(q)};window.addEventListener("hashchange",L);const F=ms(window.location.hash);return F&&F!==ve.getState().teacherTab&&oe(F),()=>window.removeEventListener("hashchange",L)},[oe,x,d]),f.useEffect(()=>{if(x||d)return;if(xe.current){xe.current=!1;const F=ms(window.location.hash);if(F&&F!==ce)return}const L=dd(ce);window.location.hash!==L&&(window.location.hash=L)},[ce,oe,x,d]);const[ie,Pe]=f.useState(!1),[ze,ue]=f.useState(!1),[re,P]=f.useState(!1);return f.useEffect(()=>{S?.subRole==="administrator"&&localStorage.getItem("edu_os_tour_completed")!=="true"&&Pe(!0)},[S]),f.useEffect(()=>{ce==="live_class"&&i(!0)},[ce]),{mainNavCollapsed:s,setMainNavCollapsed:i,isStudentLiveMode:o,liveStudentParam:a,liveLessonParam:l,liveClassParam:c,isStageDisplayMode:d,stageLessonParam:u,stageTitleParam:m,stageLangParam:p,isStudentPreviewMode:h,isStudentTabMode:x,isFollowingTeacher:g,setIsFollowingTeacher:b,liveClassFocusLocked:w,setLiveClassFocusLocked:y,session:S,setSession:C,sessionLoading:k,fetchStudents:n,sessionBootstrapData:N,activeRole:O,setActiveRole:D,activeStudentId:_,setActiveStudentId:T,dbConnected:z,dbStatus:R,profileOpen:$,setProfileOpen:I,handleLoginSuccess:B,handleLogout:H,toggleLanguage:A,students:U,setSelectedLesson:j,studentViewStateData:V,studentViewStatus:G,setStudentViewStatus:E,isStudentLocked:W,isNavigationLocked:Y,isInteractionLocked:K,studentLockMode:ne,studentLockTarget:fe,studentLessonTab:je,setStudentLessonTab:X,studentSelectedCourseware:me,setStudentSelectedCourseware:ke,studentFullscreenPanel:Se,setStudentFullscreenPanel:M,isStudentLessonContentCollapsed:Z,setIsStudentLessonContentCollapsed:ee,notifyLockedNavigation:te,teacherTab:ce,setTeacherTab:oe,isTourOpen:ie,setIsTourOpen:Pe,isApprovalsCollapsed:ze,setIsApprovalsCollapsed:ue,isProcessesCollapsed:re,setIsProcessesCollapsed:P}}function iw(e){const[t,n]=f.useState(""),[s,i]=f.useState("recent"),[o,a]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(!1),[m,p]=f.useState(null),h=f.useMemo(()=>{let x=[...e];if(t.trim()){const g=t.toLowerCase();x=x.filter(b=>b.title.toLowerCase().includes(g)||b.content.toLowerCase().includes(g))}if(o&&(x=x.filter(g=>(g.enrollment_count||0)>0)),l&&(x=x.filter(g=>g.content&&g.content.trim().length>0)),d){const g=new Date(new Date().getFullYear(),new Date().getMonth(),1).getTime();x=x.filter(b=>(b.created_at||0)>=g)}return s==="recent"?x.sort((g,b)=>(b.created_at||0)-(g.created_at||0)):s==="alphabetical"?x.sort((g,b)=>g.title.localeCompare(b.title)):s==="enrollment"&&x.sort((g,b)=>(b.enrollment_count||0)-(g.enrollment_count||0)),x},[e,t,s,o,l,d]);return{lessonsSearchQuery:t,setLessonsSearchQuery:n,lessonsSortOrder:s,setLessonsSortOrder:i,filterEnrollment:o,setFilterEnrollment:a,filterHasContent:l,setFilterHasContent:c,filterThisMonth:d,setFilterThisMonth:u,copyingLessonId:m,setCopyingLessonId:p,filteredAndSortedLessons:h}}function ow(){const e=Gg(),t=e?.academicYear==="all"?null:e?.academicYear??null,[n,s]=f.useState([]),[i,o]=f.useState(!1),[a,l]=f.useState({lab_id:null,seats:[]}),[c,d]=f.useState(!1),[u,m]=f.useState([]),[p,h]=f.useState({}),[x,g]=f.useState({}),[b,w]=f.useState(null),[y,S]=f.useState(""),[C,k]=f.useState(""),v=f.useCallback(async()=>{try{o(!0);const T=await fetch("/api/labs");T.ok&&s(await T.json())}catch(T){console.error(T)}finally{o(!1)}},[]),N=f.useCallback(async T=>{try{const z=await fetch(`/api/classes/${T}/seats`);if(z.ok){const R=await z.json();l(R)}}catch(z){console.error(z)}},[]),O=f.useCallback(async()=>{try{const T=new Date().toISOString().split("T")[0],z=await fetch(`/api/schedules/today?date=${T}`);if(z.ok){const R=await z.json();R.success&&R.schedules&&m(R.schedules)}}catch(T){console.warn("Failed to fetch today schedules",T)}},[]),D=f.useCallback(async T=>{try{const z=await fetch(`/api/classes/${T}/schedules${t?`?academicYear=${encodeURIComponent(t)}`:""}`);if(z.ok){const R=await z.json();h($=>({...$,[T]:R}))}}catch{}},[t]),_=f.useCallback(async T=>{try{const z=await fetch(`/api/schedules/${T}/attendance`);if(z.ok){const R=await z.json();g($=>({...$,[T]:R}))}}catch{}},[]);return{computerLabs:n,setComputerLabs:s,loadingLabs:i,setLoadingLabs:o,fetchLabs:v,classSeats:a,setClassSeats:l,savingSeats:c,setSavingSeats:d,fetchClassSeats:N,todaySchedules:u,setTodaySchedules:m,fetchTodaySchedules:O,classSchedulesMap:p,setClassSchedulesMap:h,fetchClassSchedules:D,scheduleAttendanceMap:x,setScheduleAttendanceMap:g,fetchScheduleAttendance:_,expandedScheduleId:b,setExpandedScheduleId:w,newScheduleDate:y,setNewScheduleDate:S,newScheduleLessonId:C,setNewScheduleLessonId:k}}function aw(e){const{lang:t,addToast:n,setCopyingLessonId:s}=e,i=de(h=>h.selectedLesson),o=de(h=>h.setSelectedLesson),a=de(h=>h.setElements),l=f.useRef(new Map),c=async()=>{await ve.getState().loadLessons()};return{fetchLessons:c,handleQuickCreateLesson:async(h,x)=>{try{const{ok:g,data:b}=await Yg({title:h,content:x});if(g)return await c(),b.id||"lesson-created"}catch(g){console.error("Quick create lesson failed",g)}return""},handleDeleteCourse:async h=>{const{ok:x,data:g}=await Zg(h);if(!x)throw new Error(g.error||"Failed to delete course");await c(),i===h&&o(null),n(t==="zh"?"课程已删除":"Course Deleted",t==="zh"?"课程及其所有关联数据已被删除。":"The course and all associated data have been deleted.","success")},handleCopyCourse:async h=>{s(h);try{const{ok:x,data:g}=await Xg(h);if(!x)throw new Error(g.error||"Failed to copy course");await c(),n(t==="zh"?"复制成功":"Course Copied",t==="zh"?"课程已成功复制。":"Course has been copied successfully.","success")}catch(x){n(t==="zh"?"复制失败":"Copy Failed",x.message||(t==="zh"?"复制课程时发生错误。":"An error occurred while copying the course."),"error")}finally{s(null)}},fetchElements:async h=>{try{const{ok:x,data:g}=await ex(h);if(!x)return;const b=JSON.stringify(g);b!==l.current.get(h)&&(l.current.set(h,b),a(g))}catch{}},lastElementsJsonByRoomRef:l}}async function lw(){const e=await fetch("/api/commands/registered");return e.ok?{ok:!0,data:await e.json(),contentType:e.headers.get("content-type")}:{ok:!1,contentType:e.headers.get("content-type")}}async function cw(e){const t=await fetch(`/api/vfs${e?`?parentId=${e}`:""}`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function dw(){const e=await fetch("/api/processes");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function uw(e){const t=await fetch(`/api/processes/${e}/logs`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function hw(e,t){return{ok:(await fetch(`/api/classes/${e}/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}}async function fw(e,t){return{ok:(await fetch(`/api/assignments/${e}/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}}async function mw(e,t){const n=await fetch(`/api/classes/${e}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t})});return n.ok?{ok:!0,data:await n.json().catch(()=>({}))}:{ok:!1}}async function pw(e){const t=await fetch(`/api/classes/${e}/progress`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function gw(e){const t=await fetch(`/api/classes/${e}/dashboard`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function xw(e){const t=await fetch(`/api/students/${e}/dashboard`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function EN(e,t){let n=`/api/students/${e}/academic-year-comparison`;if(t){const i=Array.isArray(t)?t.join(","):t;n+=`?years=${encodeURIComponent(i)}`}const s=await fetch(n);if(!s.ok)try{return{ok:!1,error:(await s.json()).error||"Request failed"}}catch{return{ok:!1,error:"Request failed"}}return{ok:!0,data:await s.json()}}function bw(e){const{fetchClassSchedules:t}=e,[n,s]=f.useState({}),[i,o]=f.useState({}),[a,l]=f.useState({}),[c,d]=f.useState({}),[u,m]=f.useState({}),[p,h]=f.useState([]),x=async C=>{try{const{ok:k,data:v}=await ix(C);k&&s(N=>({...N,[C]:v}))}catch{}},g=async C=>{try{const{ok:k,data:v}=await pw(C);k&&o(N=>({...N,[C]:v}))}catch{}},b=async C=>{try{const{ok:k,data:v}=await gw(C);k&&l(N=>({...N,[C]:v}))}catch{}};return{classStudentsMap:n,setClassStudentsMap:s,classProgressMap:i,setClassProgressMap:o,classDashboardMap:a,setClassDashboardMap:l,classAssignmentsMap:c,setClassAssignmentsMap:d,assignmentSubmissionsMap:u,setAssignmentSubmissionsMap:m,liveClassStudentProgress:p,setLiveClassStudentProgress:h,fetchClassStudents:x,fetchClassProgress:g,fetchClassDashboard:b,fetchLiveClassStudentProgress:async(C,k)=>{try{const{ok:v,data:N}=await o0(C,k);v&&h(N)}catch{}},handleQuickScheduleClass:async(C,k,v)=>{try{const{ok:N}=await hw(C,{lessonId:k,scheduledDate:v});if(N)return await t(C),!0}catch(N){console.error("Quick schedule class failed",N)}return!1},handleQuickGenerateAssignment:async(C,k,v)=>{const N=k||v||"Assignment";try{const{ok:O,data:D}=await mw(C,N);if(O)return await b(C),D.id||"assignment-created"}catch(O){console.error("Quick generate assignment failed",O)}return null}}}function yw(e){const[t,n]=f.useState([]),[s,i]=f.useState([]),[o,a]=f.useState([]),[l,c]=f.useState(null),[d,u]=f.useState(""),[m,p]=f.useState(!1),[h,x]=f.useState(null);return{registeredCommands:t,setRegisteredCommands:n,vfsNodes:s,setVfsNodes:i,processes:o,setProcesses:a,showProcessLogs:l,setShowProcessLogs:c,processLogsContent:d,setProcessLogsContent:u,showLogs:m,setShowLogs:p,currentVfsParent:h,setCurrentVfsParent:x,fetchRegisteredCommands:async()=>{try{const{ok:S,data:C,contentType:k}=await lw();S&&k&&k.includes("application/json")&&Array.isArray(C)&&n(C)}catch(S){console.warn("Failed to fetch registered commands",S)}},fetchVfs:async S=>{if(e)try{const{ok:C,data:k}=await cw(S);C&&i(k)}catch(C){console.warn("Failed to fetch VFS nodes",C)}},fetchProcesses:async()=>{try{const{ok:S,data:C}=await dw();S&&a(C)}catch{}},fetchProcessLogs:async S=>{try{const{ok:C,data:k}=await uw(S);C&&(u(k.logs||""),c(S))}catch{}}}}function xs(e,t=","){const n=[];let s="",i=!1;for(let o=0;o<e.length;o++){const a=e[o];a==='"'?i&&e[o+1]==='"'?(s+='"',o++):i=!i:a===t&&!i?(n.push(s.trim()),s=""):s+=a}return n.push(s.trim()),n}function ww(e){const t=[];let n="",s=!1;for(const i of e){const o=i.replace(/\r$/,"");if(!(!n&&!s&&!o.trim())){n=n?n+`
|
|
43
|
+
`)}const Xt=St((e,t)=>({errors:[],studentErrors:[],activeTab:"local",isErrorCenterOpen:!1,unreadCount:0,addError:n=>{const s=Date.now(),i=n.url||(typeof window<"u"?window.location.href:""),o=n.userAgent||(typeof navigator<"u"?navigator.userAgent:""),a=t().errors.findIndex(c=>c.type===n.type&&c.message===n.message&&s-c.timestamp<2e3);if(a>=0)return t().errors[a];const l={id:`err_${s}_${Math.random().toString(36).slice(2,7)}`,timestamp:n.timestamp||s,url:i,userAgent:o,type:n.type,title:n.title,message:n.message,stack:n.stack,componentStack:n.componentStack,endpoint:n.endpoint,status:n.status};return e(c=>{const d=[l,...c.errors].slice(0,El);return{errors:d,unreadCount:Tl(c.unreadCount+1,d)}}),ao.forEach(c=>{try{c(l)}catch(d){console.error("[ErrorStore] Error in errorListener:",d)}}),l},removeError:n=>e(s=>{const i=s.errors.filter(o=>o.id!==n);return{errors:i,unreadCount:Tl(s.unreadCount,i)}}),clearErrors:()=>e({errors:[],unreadCount:0}),addStudentError:n=>{const s=Date.now(),i=n.timestamp||s;e(o=>o.studentErrors.some(d=>d.studentId===n.studentId&&d.type===n.type&&d.message===n.message&&Math.abs(i-d.timestamp)<2e3)?o:{studentErrors:[{...n,id:n.id||`st_err_${s}_${Math.random().toString(36).slice(2,7)}`,timestamp:i},...o.studentErrors].slice(0,El)})},removeStudentError:n=>e(s=>({studentErrors:s.studentErrors.filter(i=>i.id!==n)})),clearStudentErrors:()=>e({studentErrors:[]}),setIsErrorCenterOpen:n=>e({isErrorCenterOpen:n,unreadCount:n?0:t().unreadCount}),setActiveTab:n=>e({activeTab:n}),markAllRead:()=>e({unreadCount:0})}));function pt(e){return Ft(Xt,e||(t=>t))}function Zy(){const e=de(T=>T.session),t=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live")),n=e?.role==="student"||t,s=pt(T=>T.errors),i=pt(T=>T.studentErrors),o=pt(T=>T.activeTab),a=pt(T=>T.setActiveTab),l=pt(T=>T.isErrorCenterOpen),c=pt(T=>T.setIsErrorCenterOpen),d=pt(T=>T.clearErrors),u=pt(T=>T.clearStudentErrors),m=pt(T=>T.removeError),p=pt(T=>T.removeStudentError),[h,x]=f.useState(!1),[g,b]=f.useState(null),[w,y]=f.useState(new Set),[S,C]=f.useState(!1),k=s.length+(n?0:i.length),v=s.length>0||!n&&i.length>0,N=T=>{y(z=>{const R=new Set(z);return R.has(T)?R.delete(T):R.add(T),R})},O=async()=>{const T=Yy(s,n?[]:i);await Er(T)&&(x(!0),setTimeout(()=>x(!1),2500))},D=async(T,z,R=!1)=>{T.stopPropagation();const $=R?Dd(z):la(z);await Er($)&&(b(z.id),setTimeout(()=>b(null),2500))},_=T=>{switch(T){case"react":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/60 dark:text-rose-400 border border-rose-200 dark:border-rose-800",children:"React"});case"api":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-purple-100 text-purple-700 dark:bg-purple-950/60 dark:text-purple-400 border border-purple-200 dark:border-purple-800",children:"API 5xx"});case"promise":return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-amber-100 text-amber-700 dark:bg-amber-950/60 dark:text-amber-400 border border-amber-200 dark:border-amber-800",children:"Promise"});default:return r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-blue-100 text-blue-700 dark:bg-blue-950/60 dark:text-blue-400 border border-blue-200 dark:border-blue-800",children:"Runtime"})}};return r.jsxs(r.Fragment,{children:[v&&!l&&!S&&(n?r.jsxs(ir.button,{type:"button",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},className:"fixed bottom-5 left-5 z-40 w-8 h-8 rounded-full bg-slate-900/80 hover:bg-slate-900 text-rose-400 border border-rose-500/40 shadow-lg flex items-center justify-center cursor-pointer transition-all hover:scale-105 select-none",onClick:()=>c(!0),id:"system-error-pill",title:`系统状态提示: ${s.length} 处异常`,children:[r.jsx(Mt,{size:15}),r.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 rounded-full bg-rose-500 text-white text-[10px] font-bold flex items-center justify-center leading-none shadow-xs border border-slate-900",children:s.length})]}):r.jsxs(ir.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.9},className:"fixed bottom-5 left-5 z-40 flex items-center gap-2 bg-slate-900/90 hover:bg-slate-900 backdrop-blur-md text-white px-3.5 py-2 rounded-2xl shadow-xl border border-rose-500/40 cursor-pointer select-none transition-all group",onClick:()=>{s.length===0&&i.length>0&&a("student"),c(!0)},id:"system-error-pill",children:[r.jsxs("div",{className:"relative flex items-center justify-center",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-3 w-3 rounded-full bg-rose-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-rose-500"})]}),r.jsx(Mt,{size:15,className:"text-rose-400 group-hover:scale-110 transition-transform"}),r.jsxs("div",{className:"text-xs font-semibold flex items-center gap-1.5",children:[r.jsx("span",{children:"捕获到"}),r.jsx("span",{className:"bg-rose-500/80 text-white font-mono px-1.5 py-0.2 rounded-md text-xs font-bold",children:k}),r.jsx("span",{children:"处系统异常"}),i.length>0&&r.jsxs("span",{className:"text-[10px] text-rose-300 font-normal",children:["(含学生端 ",i.length,")"]})]}),r.jsx("button",{type:"button",className:"text-xs font-bold text-rose-300 hover:text-white bg-white/10 hover:bg-white/20 px-2 py-0.5 rounded-lg transition-colors ml-1",children:"查看与复制"}),r.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),C(!0)},className:"text-gray-400 hover:text-gray-200 p-0.5 hover:bg-white/10 rounded transition-colors ml-0.5",title:"暂时隐藏胶囊",children:r.jsx(Oe,{size:13})})]})),r.jsx(kd,{children:l&&r.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-xs flex items-center justify-center p-4 z-50 overflow-hidden select-text",children:r.jsxs(ir.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden text-gray-900 dark:text-gray-100",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-gray-800 flex items-center justify-between bg-gray-50/80 dark:bg-slate-850/80 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-rose-500/10 text-rose-600 dark:text-rose-400 border border-rose-500/20 rounded-xl",children:r.jsx(ig,{size:18})}),r.jsxs("div",{children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[r.jsx("span",{children:"系统异常诊断中心 (System Diagnostics)"}),r.jsxs("span",{className:"text-xs font-normal text-gray-500 dark:text-gray-400",children:["(",k," 项记录)"]})]})}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"自动捕获运行时、Promise 及接口 5xx 异常,支持一键导出 Markdown 格式排查报告。"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:O,disabled:k===0,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 shadow-xs cursor-pointer ${h?"bg-emerald-600 text-white":"bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-40 disabled:cursor-not-allowed"}`,title:"复制所有异常报告为 Markdown 文本",children:[h?r.jsx(ht,{size:13}):r.jsx(vn,{size:13}),r.jsx("span",{children:h?"已复制全部!":"一键复制全部诊断日志"})]}),r.jsx("button",{type:"button",onClick:()=>{!n&&o==="student"?u():d()},disabled:o==="student"?i.length===0:s.length===0,className:"p-1.5 text-gray-500 hover:text-rose-600 dark:text-gray-400 dark:hover:text-rose-400 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",title:o==="student"?"清空学生端异常记录":"清空记录",children:r.jsx(_r,{size:16})}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"p-1.5 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors cursor-pointer",children:r.jsx(Oe,{size:16})})]})]}),!n&&r.jsxs("div",{className:"px-5 py-2 border-b border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-slate-900/50 flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>a("local"),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${o==="local"?"bg-white dark:bg-slate-800 text-indigo-600 dark:text-indigo-400 shadow-xs border border-gray-200 dark:border-gray-700":"text-gray-500 hover:text-gray-800 dark:text-gray-400"}`,children:[r.jsx(og,{size:13}),r.jsxs("span",{children:["本机异常 (",s.length,")"]})]}),r.jsxs("button",{type:"button",onClick:()=>a("student"),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${o==="student"?"bg-white dark:bg-slate-800 text-rose-600 dark:text-rose-400 shadow-xs border border-gray-200 dark:border-gray-700":"text-gray-500 hover:text-gray-800 dark:text-gray-400"}`,children:[r.jsx(xr,{size:14}),r.jsxs("span",{children:["学生端异常 (",i.length,")"]}),i.length>0&&r.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-rose-500 animate-pulse"})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 min-h-0 bg-slate-50/50 dark:bg-slate-950/30",children:!n&&o==="student"?i.length===0?r.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500 space-y-2",children:[r.jsx(ht,{size:32,className:"mx-auto text-emerald-500 opacity-80"}),r.jsx("p",{className:"text-sm font-semibold",children:"暂无学生端上报的系统异常"}),r.jsx("p",{className:"text-xs opacity-75",children:"全班学生端运行良好,未发生未捕获的前端崩溃或接口 5xx 故障。"})]}):i.map((T,z)=>{const R=w.has(T.id),$=g===T.id;return r.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden shadow-2xs hover:border-gray-300 dark:hover:border-gray-700 transition-colors",children:[r.jsxs("div",{onClick:()=>N(T.id),className:"px-4 py-3 flex items-start justify-between gap-3 cursor-pointer select-none hover:bg-gray-50/50 dark:hover:bg-slate-850/50 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-2.5 min-w-0 flex-1",children:[r.jsx("span",{className:"text-gray-400 mt-0.5 shrink-0",children:R?r.jsx(Nn,{size:15}):r.jsx(Cn,{size:15})}),r.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/60 dark:text-rose-400 border border-rose-200 dark:border-rose-800 flex items-center gap-1",children:[r.jsx(xr,{size:11}),r.jsx("span",{children:T.studentName||T.studentId})]}),_(T.type),r.jsxs("span",{className:"font-bold text-xs text-gray-900 dark:text-gray-100 truncate",children:["#",i.length-z," ",T.title]}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:new Date(T.timestamp).toLocaleTimeString()})]}),r.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-mono break-all line-clamp-2",children:T.message}),r.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 font-mono truncate",children:[r.jsxs("span",{children:["学生学号/ID: ",T.studentId]}),T.lessonId&&r.jsxs("span",{children:["课节: ",T.lessonId]}),T.classId&&r.jsxs("span",{children:["班级: ",T.classId]}),T.endpoint&&r.jsxs("span",{children:["接口: ",T.endpoint]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsxs("button",{type:"button",onClick:I=>D(I,T,!0),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1 cursor-pointer ${$?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-slate-800 dark:hover:bg-slate-700 dark:text-gray-200"}`,title:"一键复制此条学生错误报告",children:[$?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:$?"已复制":"复制"})]}),r.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),p(T.id)},className:"p-1 text-gray-400 hover:text-rose-600 rounded transition-colors cursor-pointer",title:"移除此项",children:r.jsx(Oe,{size:13})})]})]}),R&&r.jsxs("div",{className:"px-4 py-3 bg-slate-900 text-slate-200 border-t border-gray-100 dark:border-gray-800 text-xs font-mono space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 border-b border-slate-800 pb-1.5",children:[r.jsxs("span",{children:["学生: ",T.studentName||"未知"," (",T.studentId,")"]}),r.jsxs("span",{children:["页面地址: ",T.url||"未知"]}),r.jsxs("span",{children:["时间: ",new Date(T.timestamp).toLocaleString()]})]}),T.stack&&r.jsxs("div",{children:[r.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-48 overflow-y-auto opacity-90",children:T.stack})]}),T.componentStack&&r.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[r.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-36 overflow-y-auto opacity-80",children:T.componentStack})]})]})]},T.id)}):s.length===0?r.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500 space-y-2",children:[r.jsx(ht,{size:32,className:"mx-auto text-emerald-500 opacity-80"}),r.jsx("p",{className:"text-sm font-semibold",children:"暂无捕获到的系统异常"}),r.jsx("p",{className:"text-xs opacity-75",children:"系统运行顺畅,所有模块均在正常状态下运作。"})]}):s.map((T,z)=>{const R=w.has(T.id),$=g===T.id;return r.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden shadow-2xs hover:border-gray-300 dark:hover:border-gray-700 transition-colors",children:[r.jsxs("div",{onClick:()=>N(T.id),className:"px-4 py-3 flex items-start justify-between gap-3 cursor-pointer select-none hover:bg-gray-50/50 dark:hover:bg-slate-850/50 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-2.5 min-w-0 flex-1",children:[r.jsx("span",{className:"text-gray-400 mt-0.5 shrink-0",children:R?r.jsx(Nn,{size:15}):r.jsx(Cn,{size:15})}),r.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[_(T.type),r.jsxs("span",{className:"font-bold text-xs text-gray-900 dark:text-gray-100 truncate",children:["#",s.length-z," ",T.title]}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:new Date(T.timestamp).toLocaleTimeString()})]}),r.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-mono break-all line-clamp-2",children:T.message}),T.endpoint&&r.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate",children:["接口: ",T.endpoint]})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsxs("button",{type:"button",onClick:I=>D(I,T,!1),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1 cursor-pointer ${$?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-slate-800 dark:hover:bg-slate-700 dark:text-gray-200"}`,title:"一键复制此条错误报告",children:[$?r.jsx(ht,{size:11}):r.jsx(vn,{size:11}),r.jsx("span",{children:$?"已复制":"复制"})]}),r.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),m(T.id)},className:"p-1 text-gray-400 hover:text-rose-600 rounded transition-colors cursor-pointer",title:"移除此项",children:r.jsx(Oe,{size:13})})]})]}),R&&r.jsxs("div",{className:"px-4 py-3 bg-slate-900 text-slate-200 border-t border-gray-100 dark:border-gray-800 text-xs font-mono space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 border-b border-slate-800 pb-1.5",children:[r.jsxs("span",{children:["页面地址: ",T.url||"未知"]}),r.jsxs("span",{children:["时间: ",new Date(T.timestamp).toLocaleString()]})]}),T.stack&&r.jsxs("div",{children:[r.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-48 overflow-y-auto opacity-90",children:T.stack})]}),T.componentStack&&r.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[r.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-36 overflow-y-auto opacity-80",children:T.componentStack})]})]})]},T.id)})})]})})})]})}let Pl=!1;function Xy(){if(Pl)return;Pl=!0;const e=()=>Je(()=>import("./ActivityWorkspaceWidget-CMN8elwQ.js"),__vite__mapDeps([19,1,2,3,4])).then(t=>({default:()=>r.jsx(t.ActivityWorkspaceWidget,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,Ne.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}function ew(){return{addToast:f.useCallback((t,n,s="info")=>{const i=Math.random().toString(36).substring(2,9);ve.getState().addToast({id:i,title:t,message:n,type:s}),setTimeout(()=>{ve.getState().removeToast(i)},6e3)},[])}}function Il(e){if(typeof window>"u")return;const t=JSON.stringify({source:e.source,message:e.message.slice(0,500),stack:e.stack?e.stack.slice(0,2e3):void 0,path:window.location.pathname});try{if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"&&navigator.sendBeacon("/api/client-errors",new Blob([t],{type:"application/json"})))return}catch{}fetch("/api/client-errors",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}function tw(){f.useEffect(()=>{if(typeof window>"u")return;const e=o=>{const a=o.reason,l=a instanceof Error?a.message:typeof a=="string"?a:JSON.stringify(a)||"Unhandled promise rejection",c=a instanceof Error?a.stack:void 0;Xt.getState().addError({type:"promise",title:"未捕获的异步异常 (Unhandled Promise)",message:l,stack:c}),Il({source:"promise",message:l,stack:c}),console.warn("[GlobalErrorCapture] Caught unhandled rejection:",a)},t=o=>{if(!o.message&&!o.error)return;const a=o.message||(o.error?.message??"Unknown script error"),l=o.error?.stack;Xt.getState().addError({type:"runtime",title:"JavaScript 运行时错误 (Runtime Error)",message:a,stack:l}),Il({source:"runtime",message:a,stack:l}),console.warn("[GlobalErrorCapture] Caught window error:",o.error||o.message)},n=window.fetch,s=async(...o)=>{try{const a=await n(...o);if(!a.ok&&a.status>=500)try{const c=await a.clone().text();let d="";try{const p=JSON.parse(c);d=p.error||p.message||p.details||c}catch{d=c.slice(0,300)}const u=o[0],m=typeof u=="string"?u:u instanceof Request?u.url:String(u);Xt.getState().addError({type:"api",title:`服务端接口错误 (HTTP ${a.status})`,message:d||`Request failed with status ${a.status}`,endpoint:m,status:a.status})}catch{}return a}catch(a){const l=o[0],c=typeof l=="string"?l:l instanceof Request?l.url:String(l);throw c&&(c.startsWith("/api")||c.includes("/api/"))&&Xt.getState().addError({type:"api",title:"网络请求失败 (Network Disconnected / Error)",message:a?.message||"Failed to fetch API endpoint",endpoint:c,stack:a?.stack}),a}},i=Ky(o=>{try{const a=ve.getState(),l=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live"));if(!(a.session?.role==="student"||l))return;const d=typeof window<"u"?new URLSearchParams(window.location.search):null,u=a.session?.userId||d?.get("studentId")||"anonymous_student",m=a.session?.name||a.session?.username||d?.get("studentName")||u,p=a.selectedLesson||d?.get("lessonId")||null,h=a.liveClassSelectedClassId||d?.get("classId")||null,x={studentId:u,studentName:m,lessonId:p,classId:h,error:o},g=lt();if(g&&g.connected)g.emit("student-client-error",x);else{const b="/api/diagnostics/report",w=JSON.stringify(x);typeof navigator<"u"&&navigator.sendBeacon?navigator.sendBeacon(b,new Blob([w],{type:"application/json"})):fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:w}).catch(()=>{})}}catch(a){console.warn("[GlobalErrorCapture] Failed to report student error:",a)}});return window.fetch=s,window.addEventListener("unhandledrejection",e),window.addEventListener("error",t),()=>{window.fetch=n,window.removeEventListener("unhandledrejection",e),window.removeEventListener("error",t),i()}},[])}function nw(e){const{fetchStudents:t}=e,n=de(S=>S.session),s=de(S=>S.setSession),i=de(S=>S.lang),o=de(S=>S.setLang),[a,l]=f.useState("teacher"),[c,d]=f.useState(!0),[u,m]=f.useState("normal"),[p,h]=f.useState(null),[x,g]=f.useState(!1);return f.useEffect(()=>{if(!n||n.role!=="teacher")return;const S=async()=>{try{const{ok:k,status:v,data:N}=await Bg();k?(N.status==="warning"||N.warning?m("warning"):m("normal"),d(!0)):v===429||v===503?(m("warning"),d(!0)):(m("error"),d(!1))}catch{m("error"),d(!1)}};S();const C=setInterval(S,5e3);return()=>clearInterval(C)},[n]),f.useEffect(()=>{(async()=>{try{const{ok:C,data:k}=await ld();C&&ve.getState().setSiteInfo({siteName:k.siteName||"",slogan:k.slogan||"",logoUrl:k.logoUrl||null})}catch(C){console.warn("Failed to fetch site settings:",C)}})()},[]),{session:n,setSession:s,lang:i,setLang:o,activeRole:a,setActiveRole:l,setActiveStudentId:h,activeStudentId:p,dbConnected:c,dbStatus:u,profileOpen:x,setProfileOpen:g,handleLoginSuccess:S=>{if(s(S),S.role==="teacher"){l("teacher");const C=typeof window<"u"?ms(window.location.hash):null;ve.getState().setTeacherTab(C||"live_class")}else l("student"),h(S.studentId),t()},handleLogout:async()=>{try{await Vg()}catch(S){console.error("Logout failed",S)}s(null)},toggleLanguage:()=>{o(i==="zh"?"en":"zh")}}}function sw(e){const{activeStudentId:t,activeRole:n,students:s,liveClassFocusLocked:i,setIsFollowingTeacher:o,lang:a,addToast:l}=e,[c,d]=f.useState("dashboard"),u=s.find(R=>R.id===t),m=n==="student"&&(!!t&&!!u?.locked_lesson_id||i),p=u?.lock_mode||"full",h=m,x=m&&p==="full",g=(()=>{if(!u?.lock_target)return null;try{return typeof u.lock_target=="string"?JSON.parse(u.lock_target):u.lock_target}catch{return null}})(),b=f.useRef(h),w=f.useRef(p),y=f.useRef(c);f.useEffect(()=>{b.current=h,w.current=p,y.current=c},[h,p,c]),f.useEffect(()=>{h&&(o(!0),d("lesson"))},[h,o]);const[S,C]=f.useState("whiteboard");f.useEffect(()=>{h&&g?.tab&&C(g.tab)},[h,g?.tab]);const k=R=>{const $=typeof R=="function"?R(y.current):R;if(b.current&&$!=="lesson"){v();return}d($)},v=()=>{const R=w.current==="navigation";l(a==="zh"?R?"🔒 答题锁定":"🔒 全班专注锁定":R?"🔒 Answer Locked":"🔒 Class Focus Locked",a==="zh"?R?"老师已开启答题锁定,请在当前页面完成作答并提交,暂时无法离开本页。":"老师已开启全班专注锁定,暂时无法切换页面,请跟随教师当前授课内容。":R?"The teacher locked the screen for answering. Please complete your work on this page before leaving.":"The teacher locked the class focus. Navigation is disabled — please follow the current lesson.","warning")},[N,O]=f.useState(null),[D,_]=f.useState("none"),[T,z]=f.useState(!0);return f.useEffect(()=>{c!=="lesson"&&z(!0)},[c]),{studentViewStatus:c,setStudentViewStatus:k,isStudentLocked:m,isNavigationLocked:h,isInteractionLocked:x,studentLockMode:p,studentLockTarget:g,studentLessonTab:S,setStudentLessonTab:C,studentSelectedCourseware:N,setStudentSelectedCourseware:O,studentFullscreenPanel:D,setStudentFullscreenPanel:_,isStudentLessonContentCollapsed:T,setIsStudentLessonContentCollapsed:z,notifyLockedNavigation:v}}function rw({lang:e,addToast:t,fetchStudents:n}){const[s,i]=f.useState(!1),o=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live")),a=typeof window<"u"?new URLSearchParams(window.location.search).get("studentId"):null,l=typeof window<"u"?new URLSearchParams(window.location.search).get("lessonId"):null,c=typeof window<"u"?new URLSearchParams(window.location.search).get("classId"):null,d=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="stage_display"||window.location.hash.includes("stage_display")),u=typeof window<"u"?new URLSearchParams(window.location.search).get("lessonId"):null,m=typeof window<"u"?new URLSearchParams(window.location.search).get("title"):null,p=typeof window<"u"?new URLSearchParams(window.location.search).get("lang"):null,h=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_preview"||window.location.hash.includes("student_preview")),x=o||h,[g,b]=f.useState(!0),[w,y]=f.useState(!1);f.useEffect(()=>{Dr.getState().initTheme(),wn.getState().initFontSize();const L=F=>{(F.ctrlKey||F.metaKey)&&F.altKey&&(F.key==="+"||F.key==="="?(F.preventDefault(),wn.getState().increaseScale()):F.key==="-"||F.key==="_"?(F.preventDefault(),wn.getState().decreaseScale()):F.key==="0"&&(F.preventDefault(),wn.getState().resetScale()))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const S=de(L=>L.session),C=de(L=>L.setSession),[k,v]=f.useState(!0),N=nw({fetchStudents:n}),{activeRole:O,setActiveRole:D,activeStudentId:_,setActiveStudentId:T,dbConnected:z,dbStatus:R,profileOpen:$,setProfileOpen:I,handleLoginSuccess:B,handleLogout:H,toggleLanguage:A}=N,U=de(L=>L.students);de(L=>L.dataVersion);const j=de(L=>L.setSelectedLesson),V=sw({activeStudentId:_,activeRole:O,students:U,liveClassFocusLocked:w,setIsFollowingTeacher:b,lang:e,addToast:t}),{studentViewStatus:G,setStudentViewStatus:E,isStudentLocked:W,isNavigationLocked:Y,isInteractionLocked:K,studentLockMode:ne,studentLockTarget:fe,studentLessonTab:je,setStudentLessonTab:X,studentSelectedCourseware:me,setStudentSelectedCourseware:ke,studentFullscreenPanel:Se,setStudentFullscreenPanel:M,isStudentLessonContentCollapsed:Z,setIsStudentLessonContentCollapsed:ee,notifyLockedNavigation:te}=V;f.useEffect(()=>{(async()=>{try{const{ok:F,data:q}=await Ug();if(F&&q&&q.session)if(C(q.session),x){D("student"),E("lesson");const J=a||q.session.studentId;J&&T(J),l&&j(l),n()}else D(q.session.role),l&&j(l),q.session.role==="student"&&q.session.studentId&&(T(q.session.studentId),n())}catch(F){console.warn("Session check failed",F)}finally{v(!1)}})()},[]);const ce=de(L=>L.teacherTab),oe=de(L=>L.setTeacherTab),xe=f.useRef(!0);f.useEffect(()=>{if(x||d)return;const L=()=>{const q=ms(window.location.hash);q&&q!==ve.getState().teacherTab&&oe(q)};window.addEventListener("hashchange",L);const F=ms(window.location.hash);return F&&F!==ve.getState().teacherTab&&oe(F),()=>window.removeEventListener("hashchange",L)},[oe,x,d]),f.useEffect(()=>{if(x||d)return;if(xe.current){xe.current=!1;const F=ms(window.location.hash);if(F&&F!==ce)return}const L=dd(ce);window.location.hash!==L&&(window.location.hash=L)},[ce,oe,x,d]);const[ie,Pe]=f.useState(!1),[ze,ue]=f.useState(!1),[re,P]=f.useState(!1);return f.useEffect(()=>{S?.subRole==="administrator"&&localStorage.getItem("edu_os_tour_completed")!=="true"&&Pe(!0)},[S]),f.useEffect(()=>{ce==="live_class"&&i(!0)},[ce]),{mainNavCollapsed:s,setMainNavCollapsed:i,isStudentLiveMode:o,liveStudentParam:a,liveLessonParam:l,liveClassParam:c,isStageDisplayMode:d,stageLessonParam:u,stageTitleParam:m,stageLangParam:p,isStudentPreviewMode:h,isStudentTabMode:x,isFollowingTeacher:g,setIsFollowingTeacher:b,liveClassFocusLocked:w,setLiveClassFocusLocked:y,session:S,setSession:C,sessionLoading:k,fetchStudents:n,sessionBootstrapData:N,activeRole:O,setActiveRole:D,activeStudentId:_,setActiveStudentId:T,dbConnected:z,dbStatus:R,profileOpen:$,setProfileOpen:I,handleLoginSuccess:B,handleLogout:H,toggleLanguage:A,students:U,setSelectedLesson:j,studentViewStateData:V,studentViewStatus:G,setStudentViewStatus:E,isStudentLocked:W,isNavigationLocked:Y,isInteractionLocked:K,studentLockMode:ne,studentLockTarget:fe,studentLessonTab:je,setStudentLessonTab:X,studentSelectedCourseware:me,setStudentSelectedCourseware:ke,studentFullscreenPanel:Se,setStudentFullscreenPanel:M,isStudentLessonContentCollapsed:Z,setIsStudentLessonContentCollapsed:ee,notifyLockedNavigation:te,teacherTab:ce,setTeacherTab:oe,isTourOpen:ie,setIsTourOpen:Pe,isApprovalsCollapsed:ze,setIsApprovalsCollapsed:ue,isProcessesCollapsed:re,setIsProcessesCollapsed:P}}function iw(e){const[t,n]=f.useState(""),[s,i]=f.useState("recent"),[o,a]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(!1),[m,p]=f.useState(null),h=f.useMemo(()=>{let x=[...e];if(t.trim()){const g=t.toLowerCase();x=x.filter(b=>b.title.toLowerCase().includes(g)||b.content.toLowerCase().includes(g))}if(o&&(x=x.filter(g=>(g.enrollment_count||0)>0)),l&&(x=x.filter(g=>g.content&&g.content.trim().length>0)),d){const g=new Date(new Date().getFullYear(),new Date().getMonth(),1).getTime();x=x.filter(b=>(b.created_at||0)>=g)}return s==="recent"?x.sort((g,b)=>(b.created_at||0)-(g.created_at||0)):s==="alphabetical"?x.sort((g,b)=>g.title.localeCompare(b.title)):s==="enrollment"&&x.sort((g,b)=>(b.enrollment_count||0)-(g.enrollment_count||0)),x},[e,t,s,o,l,d]);return{lessonsSearchQuery:t,setLessonsSearchQuery:n,lessonsSortOrder:s,setLessonsSortOrder:i,filterEnrollment:o,setFilterEnrollment:a,filterHasContent:l,setFilterHasContent:c,filterThisMonth:d,setFilterThisMonth:u,copyingLessonId:m,setCopyingLessonId:p,filteredAndSortedLessons:h}}function ow(){const e=Gg(),t=e?.academicYear==="all"?null:e?.academicYear??null,[n,s]=f.useState([]),[i,o]=f.useState(!1),[a,l]=f.useState({lab_id:null,seats:[]}),[c,d]=f.useState(!1),[u,m]=f.useState([]),[p,h]=f.useState({}),[x,g]=f.useState({}),[b,w]=f.useState(null),[y,S]=f.useState(""),[C,k]=f.useState(""),v=f.useCallback(async()=>{try{o(!0);const T=await fetch("/api/labs");T.ok&&s(await T.json())}catch(T){console.error(T)}finally{o(!1)}},[]),N=f.useCallback(async T=>{try{const z=await fetch(`/api/classes/${T}/seats`);if(z.ok){const R=await z.json();l(R)}}catch(z){console.error(z)}},[]),O=f.useCallback(async()=>{try{const T=new Date().toISOString().split("T")[0],z=await fetch(`/api/schedules/today?date=${T}`);if(z.ok){const R=await z.json();R.success&&R.schedules&&m(R.schedules)}}catch(T){console.warn("Failed to fetch today schedules",T)}},[]),D=f.useCallback(async T=>{try{const z=await fetch(`/api/classes/${T}/schedules${t?`?academicYear=${encodeURIComponent(t)}`:""}`);if(z.ok){const R=await z.json();h($=>({...$,[T]:R}))}}catch{}},[t]),_=f.useCallback(async T=>{try{const z=await fetch(`/api/schedules/${T}/attendance`);if(z.ok){const R=await z.json();g($=>({...$,[T]:R}))}}catch{}},[]);return{computerLabs:n,setComputerLabs:s,loadingLabs:i,setLoadingLabs:o,fetchLabs:v,classSeats:a,setClassSeats:l,savingSeats:c,setSavingSeats:d,fetchClassSeats:N,todaySchedules:u,setTodaySchedules:m,fetchTodaySchedules:O,classSchedulesMap:p,setClassSchedulesMap:h,fetchClassSchedules:D,scheduleAttendanceMap:x,setScheduleAttendanceMap:g,fetchScheduleAttendance:_,expandedScheduleId:b,setExpandedScheduleId:w,newScheduleDate:y,setNewScheduleDate:S,newScheduleLessonId:C,setNewScheduleLessonId:k}}function aw(e){const{lang:t,addToast:n,setCopyingLessonId:s}=e,i=de(h=>h.selectedLesson),o=de(h=>h.setSelectedLesson),a=de(h=>h.setElements),l=f.useRef(new Map),c=async()=>{await ve.getState().loadLessons()};return{fetchLessons:c,handleQuickCreateLesson:async(h,x)=>{try{const{ok:g,data:b}=await Yg({title:h,content:x});if(g)return await c(),b.id||"lesson-created"}catch(g){console.error("Quick create lesson failed",g)}return""},handleDeleteCourse:async h=>{const{ok:x,data:g}=await Zg(h);if(!x)throw new Error(g.error||"Failed to delete course");await c(),i===h&&o(null),n(t==="zh"?"课程已删除":"Course Deleted",t==="zh"?"课程及其所有关联数据已被删除。":"The course and all associated data have been deleted.","success")},handleCopyCourse:async h=>{s(h);try{const{ok:x,data:g}=await Xg(h);if(!x)throw new Error(g.error||"Failed to copy course");await c(),n(t==="zh"?"复制成功":"Course Copied",t==="zh"?"课程已成功复制。":"Course has been copied successfully.","success")}catch(x){n(t==="zh"?"复制失败":"Copy Failed",x.message||(t==="zh"?"复制课程时发生错误。":"An error occurred while copying the course."),"error")}finally{s(null)}},fetchElements:async h=>{try{const{ok:x,data:g}=await ex(h);if(!x)return;const b=JSON.stringify(g);b!==l.current.get(h)&&(l.current.set(h,b),a(g))}catch{}},lastElementsJsonByRoomRef:l}}async function lw(){const e=await fetch("/api/commands/registered");return e.ok?{ok:!0,data:await e.json(),contentType:e.headers.get("content-type")}:{ok:!1,contentType:e.headers.get("content-type")}}async function cw(e){const t=await fetch(`/api/vfs${e?`?parentId=${e}`:""}`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function dw(){const e=await fetch("/api/processes");return e.ok?{ok:!0,data:await e.json()}:{ok:!1}}async function uw(e){const t=await fetch(`/api/processes/${e}/logs`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function hw(e,t){return{ok:(await fetch(`/api/classes/${e}/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}}async function fw(e,t){return{ok:(await fetch(`/api/assignments/${e}/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}}async function mw(e,t){const n=await fetch(`/api/classes/${e}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t})});return n.ok?{ok:!0,data:await n.json().catch(()=>({}))}:{ok:!1}}async function pw(e){const t=await fetch(`/api/classes/${e}/progress`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function gw(e){const t=await fetch(`/api/classes/${e}/dashboard`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function xw(e){const t=await fetch(`/api/students/${e}/dashboard`);return t.ok?{ok:!0,data:await t.json()}:{ok:!1}}async function EN(e,t){let n=`/api/students/${e}/academic-year-comparison`;if(t){const i=Array.isArray(t)?t.join(","):t;n+=`?years=${encodeURIComponent(i)}`}const s=await fetch(n);if(!s.ok)try{return{ok:!1,error:(await s.json()).error||"Request failed"}}catch{return{ok:!1,error:"Request failed"}}return{ok:!0,data:await s.json()}}function bw(e){const{fetchClassSchedules:t}=e,[n,s]=f.useState({}),[i,o]=f.useState({}),[a,l]=f.useState({}),[c,d]=f.useState({}),[u,m]=f.useState({}),[p,h]=f.useState([]),x=async C=>{try{const{ok:k,data:v}=await ix(C);k&&s(N=>({...N,[C]:v}))}catch{}},g=async C=>{try{const{ok:k,data:v}=await pw(C);k&&o(N=>({...N,[C]:v}))}catch{}},b=async C=>{try{const{ok:k,data:v}=await gw(C);k&&l(N=>({...N,[C]:v}))}catch{}};return{classStudentsMap:n,setClassStudentsMap:s,classProgressMap:i,setClassProgressMap:o,classDashboardMap:a,setClassDashboardMap:l,classAssignmentsMap:c,setClassAssignmentsMap:d,assignmentSubmissionsMap:u,setAssignmentSubmissionsMap:m,liveClassStudentProgress:p,setLiveClassStudentProgress:h,fetchClassStudents:x,fetchClassProgress:g,fetchClassDashboard:b,fetchLiveClassStudentProgress:async(C,k)=>{try{const{ok:v,data:N}=await o0(C,k);v&&h(N)}catch{}},handleQuickScheduleClass:async(C,k,v)=>{try{const{ok:N}=await hw(C,{lessonId:k,scheduledDate:v});if(N)return await t(C),!0}catch(N){console.error("Quick schedule class failed",N)}return!1},handleQuickGenerateAssignment:async(C,k,v)=>{const N=k||v||"Assignment";try{const{ok:O,data:D}=await mw(C,N);if(O)return await b(C),D.id||"assignment-created"}catch(O){console.error("Quick generate assignment failed",O)}return null}}}function yw(e){const[t,n]=f.useState([]),[s,i]=f.useState([]),[o,a]=f.useState([]),[l,c]=f.useState(null),[d,u]=f.useState(""),[m,p]=f.useState(!1),[h,x]=f.useState(null);return{registeredCommands:t,setRegisteredCommands:n,vfsNodes:s,setVfsNodes:i,processes:o,setProcesses:a,showProcessLogs:l,setShowProcessLogs:c,processLogsContent:d,setProcessLogsContent:u,showLogs:m,setShowLogs:p,currentVfsParent:h,setCurrentVfsParent:x,fetchRegisteredCommands:async()=>{try{const{ok:S,data:C,contentType:k}=await lw();S&&k&&k.includes("application/json")&&Array.isArray(C)&&n(C)}catch(S){console.warn("Failed to fetch registered commands",S)}},fetchVfs:async S=>{if(e)try{const{ok:C,data:k}=await cw(S);C&&i(k)}catch(C){console.warn("Failed to fetch VFS nodes",C)}},fetchProcesses:async()=>{try{const{ok:S,data:C}=await dw();S&&a(C)}catch{}},fetchProcessLogs:async S=>{try{const{ok:C,data:k}=await uw(S);C&&(u(k.logs||""),c(S))}catch{}}}}function xs(e,t=","){const n=[];let s="",i=!1;for(let o=0;o<e.length;o++){const a=e[o];a==='"'?i&&e[o+1]==='"'?(s+='"',o++):i=!i:a===t&&!i?(n.push(s.trim()),s=""):s+=a}return n.push(s.trim()),n}function ww(e){const t=[];let n="",s=!1;for(const i of e){const o=i.replace(/\r$/,"");if(!(!n&&!s&&!o.trim())){n=n?n+`
|
|
44
44
|
`+o:o;for(let a=0;a<o.length;a++)o[a]==='"'&&(s&&o[a+1]==='"'?a++:s=!s);s||(t.push(n),n="")}}return n&&t.push(n),t}function Kt(e,t){const n=i=>i.replace(/[\s_\-()()]/g,""),s=e.map(n);for(const i of t){const o=s.indexOf(n(i));if(o!==-1)return o}for(const i of[...t].sort((o,a)=>n(a).length-n(o).length)){const o=n(i),a=s.findIndex(l=>l.includes(o));if(a!==-1)return a}return-1}function Al(e){return{name:e?.name||e?.studentName||e?.student_name||"",email:e?.email||e?.studentEmail||e?.student_email||"",student_number:e?.student_number||e?.studentNumber||e?.studentNo||"",password:e?.password||e?.initialPassword||e?.initial_password||"",private_notes:e?.private_notes||e?.privateNotes||e?.notes||e?.note||""}}function zl(e,t){if(!e||e.length===0)return"";const n=e.map(s=>`${s.student_number||"-"} / ${s.name} / ${s.initial_password}`).join(`
|
|
45
45
|
`);return t==="zh"?`
|
|
46
46
|
|