openlearn-next 0.3.3 → 0.3.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.
Files changed (29) hide show
  1. package/dist/assets/{BatchPickerModal-2jsnyMYM.js → BatchPickerModal-CY5i3NQK.js} +1 -1
  2. package/dist/assets/{ClassesView-DUnZ5nFa.js → ClassesView-CnH8J5qP.js} +1 -1
  3. package/dist/assets/{CloudDriveModal-DXJktxoq.js → CloudDriveModal-CDIeKEs0.js} +1 -1
  4. package/dist/assets/{CourseManagement-ChHr_wNd.js → CourseManagement-DtpcoEym.js} +1 -1
  5. package/dist/assets/{CourseWizardModal-RAaltA_q.js → CourseWizardModal-CxT0II5U.js} +1 -1
  6. package/dist/assets/{Dashboard-BMXQhpnj.js → Dashboard-bLZ4SuB2.js} +1 -1
  7. package/dist/assets/{ExportWeightModal-BwW76Kqo.js → ExportWeightModal-DKWU7X1K.js} +1 -1
  8. package/dist/assets/{HelpView-BqUqq-QE.js → HelpView-DREbhrK_.js} +2 -2
  9. package/dist/assets/{ImportLessonsModal-DHLxg68P.js → ImportLessonsModal-CZuiK5N1.js} +1 -1
  10. package/dist/assets/{InteractiveCoursewareViewer-C8uZcebL.js → InteractiveCoursewareViewer-BbnRpnsW.js} +1 -1
  11. package/dist/assets/{InteractiveWhiteboard-C2HAx6zv.js → InteractiveWhiteboard-S80ZfeL0.js} +1 -1
  12. package/dist/assets/{LazyCourseware-C1bH8aKj.js → LazyCourseware-m3sBCM3Y.js} +1 -1
  13. package/dist/assets/{LazyWhiteboard-DE9sMBUF.js → LazyWhiteboard-Madzjeuh.js} +1 -1
  14. package/dist/assets/{LessonEditorView-mIxHUfYb.js → LessonEditorView-DtcWzFob.js} +1 -1
  15. package/dist/assets/{LiveClassroomView-DNGZaCC8.js → LiveClassroomView-DNTEVhxr.js} +1 -1
  16. package/dist/assets/{NotificationDetailModal-CPrHxHcC.js → NotificationDetailModal-CW42lyh0.js} +1 -1
  17. package/dist/assets/{PluginView-DSLBfNDj.js → PluginView-D70yD5sS.js} +1 -1
  18. package/dist/assets/{QuizGeneratorModal-CoeGXKck.js → QuizGeneratorModal-Vmdm_KlA.js} +1 -1
  19. package/dist/assets/{StudentAssignmentView-V7Kp6TnP.js → StudentAssignmentView-D036KnMv.js} +1 -1
  20. package/dist/assets/{StudentLessonView-IZVXM5kz.js → StudentLessonView-DFsfAhgG.js} +1 -1
  21. package/dist/assets/{StudentPreviewModal-DwumAjWX.js → StudentPreviewModal-B_ITJvkQ.js} +1 -1
  22. package/dist/assets/{StudentView-3mCaDwFB.js → StudentView-BSfVCBSV.js} +1 -1
  23. package/dist/assets/{SystemResourceLibraryModal-B6ms798K.js → SystemResourceLibraryModal-Cxjj_pd-.js} +1 -1
  24. package/dist/assets/{TeacherView-BVd_ZMFH.js → TeacherView-B7FWfCWx.js} +1 -1
  25. package/dist/assets/{index-Vr-_Vpp3.js → index-BER4YuRi.js} +1 -1
  26. package/dist/assets/{index-Cwf8LQbY.js → index-BWsJ_lVr.js} +3 -3
  27. package/dist/index.html +1 -1
  28. package/dist/server.cjs +55 -57
  29. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import{R as et,r as p,j as l,g as Da,b as Ph,d as Fa,h as Ba,i as Th}from"./vendor-react-0Lg0vA-4.js";import{G as lo,S as Nh,U as $a,C as co,a as gn,L as uo,A as ho,b as Va,c as Ih,P as Dr,d as fo,D as po,X as At,e as Fr,f as ls,g as jh,h as Ah,T as zh,E as Ua,B as ai,R as Lh,i as _h,j as Rh,k as Oh,M as Mh,H as Dh,l as Fh,m as Bh,n as Wa,o as li,p as Br,q as $h,K as Vh,r as Uh,s as qn,t as Wh,u as ci,v as qh,w as ui,x as Hh,y as Gh,z as Qh,F as Jh,I as qa,J as Zh,N as Yh,V as Kh,O as Xh,Q as ef,W as ur,Y as tf,Z as nf,_ as sf,$ as rf,a0 as of}from"./vendor-icons-Dq6MhgH9.js";import{_ as Ie,E as af}from"./vendor-pdf-Cp-cYteE.js";import{d as Ha,e as qt,f as lf}from"./vendor-utils-BEhuP0Zq.js";import{i as dr,g as cf,s as Ga,a as di,b as Qa,c as mo,d as uf,e as df,f as hf,h as ff,r as pf,j as mf,k as Ja,l as gf,m as yf,n as xf,o as bf,S as wf,H as Sf,F as vt,p as vf,q as Cf,t as Za,u as ns,v as go,w as Xe,x as Ya,y as kf,z as yo,A as Ef,B as ss,C as $r,D as xo,E as Pf,G as Tf,I as bt,J as Nf,K as If,L as jf,M as bo,N as Af,O as zf,P as wo,Q as Lf,R as _f,T as Hn,U as Rf,V as Of,W as Ka,X as Mf,Y as Df}from"./vendor-motion-DjY2czvL.js";import{v as Ff}from"./vendor-pptx-B_NheIKl.js";import{R as Bf}from"./vendor-charts-CRXa4AlU.js";const $f=e=>{const t=e.split(/\r?\n/);if(t.length<2)return[];const n=t[0],s=[",",";"," "];let r=",",i=0;s.forEach(h=>{const g=n.split(h).length;g>i&&(i=g,r=h)});const o=h=>{const g=[];let x=!1,v="";for(let w=0;w<h.length;w++){const I=h[w];I==='"'?x=!x:I===r&&!x?(g.push(v.trim()),v=""):v+=I}return g.push(v.trim()),g},a=o(n).map(h=>h.toLowerCase().replace(/["'\r]/g,"").trim()),c=a.findIndex(h=>h.includes("name")||h.includes("student")||h.includes("姓名")||h.includes("学生")),u=a.findIndex(h=>h.includes("email")||h.includes("mail")||h.includes("邮箱")),d=c>=0?c:0,f=u>=0?u:1,m=[];for(let h=1;h<t.length;h++){if(!t[h].trim())continue;const g=o(t[h]),x=g[d]?g[d].replace(/["'\r]/g,"").trim():"",v=g[f]?g[f].replace(/["'\r]/g,"").trim():"";x&&m.push({name:x,email:v})}return m},So={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:"暂无学生"},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"}},Vf=et.memo(function({onLoginSuccess:t,lang:n}){const[s,r]=p.useState("teacher"),[i,o]=p.useState(null),[a,c]=p.useState(""),[u,d]=p.useState(""),[f,m]=p.useState(""),[h,g]=p.useState(!1),[x,v]=p.useState([]),[w,I]=p.useState(""),[S,P]=p.useState(""),[z,E]=p.useState(""),[L,_]=p.useState(""),[M,N]=p.useState(!1);p.useEffect(()=>{(async()=>{try{const F=await fetch("/api/students");if(F.ok){const j=await F.json();v(j),j.length>0&&I(j[0].id)}}catch(F){console.warn("Failed to fetch student roster for login selection:",F)}})()},[]),p.useEffect(()=>{(async()=>{try{const F=await fetch("/api/site-settings");if(F.ok){const j=await F.json();o(j)}}catch(F){console.warn("Failed to fetch site settings for login branding:",F)}})()},[]);const A=async D=>{if(D.preventDefault(),!a.trim()||!u){m(n==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{m(""),g(!0);const F=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:a.trim(),password:u})});if(F.ok){const j=await F.json();t(j.session)}else{const j=await F.json();m(j.error||(n==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{m(n==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{g(!1)}},R=async D=>{D.preventDefault();const F=w||S.trim();if(!F){_(n==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!z.trim()){_(n==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{_(""),N(!0);const j=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:F,password:z.trim()})});if(j.ok){const T=await j.json();t(T.session)}else{const T=await j.json();_(T.error||(n==="zh"?"找不到该学生记录":"Student record not found"))}}catch{_(n==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{N(!1)}};return l.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:[l.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),l.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),l.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:[l.jsxs("div",{className:"text-center mb-8",children:[i?.logoUrl?l.jsx("img",{src:i.logoUrl,alt:i.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):l.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:l.jsx(lo,{size:32})}),l.jsxs("h1",{className:"text-2xl sm:text-3xl font-black text-white tracking-tight flex items-center justify-center gap-2",children:[i?.siteName||"OpenLearn Next"," ",l.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"})]}),l.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:i?.slogan||(n==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),l.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[l.jsxs("button",{onClick:()=>r("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:[l.jsx(Nh,{size:14}),n==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),l.jsxs("button",{onClick:()=>r("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:[l.jsx($a,{size:14}),n==="zh"?"学生自助端":"Student Self-Service"]})]}),s==="teacher"?l.jsxs("form",{onSubmit:A,className:"space-y-4",children:[f&&l.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:[l.jsx(co,{size:15,className:"shrink-0"}),l.jsx("span",{children:f})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[l.jsx(gn,{size:13}),n==="zh"?"教工账户名 / username":"Staff Username"]}),l.jsx("input",{type:"text",value:a,onChange:D=>c(D.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})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[l.jsx(uo,{size:13}),n==="zh"?"输入登录密码 / password":"Access Password"]}),l.jsx("input",{type:"password",value:u,onChange:D=>d(D.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})]}),l.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:[l.jsx("span",{children:h?n==="zh"?"鉴权登录中...":"Authorizing...":n==="zh"?"安全验证登录":"Authorized Sign In"}),l.jsx(ho,{size:15})]})]}):l.jsxs("form",{onSubmit:R,className:"space-y-4",children:[L&&l.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:[l.jsx(co,{size:15,className:"shrink-0"}),l.jsx("span",{children:L})]}),x.length>0?l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[l.jsx(lo,{size:14}),n==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),l.jsx("select",{value:w,onChange:D=>{I(D.target.value),P("")},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:x.map(D=>l.jsxs("option",{value:D.id,children:[D.name," (",D.student_number||D.id,")"]},D.id))}),l.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:n==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,l.jsxs("div",{className:"relative flex py-2 items-center",children:[l.jsx("div",{className:"flex-grow border-t border-slate-850"}),l.jsx("span",{className:"flex-shrink mx-3 text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:n==="zh"?"或手动输入学号":"Or input key manually"}),l.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[l.jsx(gn,{size:13}),n==="zh"?"学号 / Student ID":"Student Access Key"]}),l.jsx("input",{type:"text",value:S,onChange:D=>{P(D.target.value),I("")},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"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[l.jsx(uo,{size:13}),n==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),l.jsx("input",{type:"password",required:!0,value:z,onChange:D=>E(D.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"})]}),l.jsxs("button",{type:"submit",disabled:M,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:[l.jsx("span",{children:M?n==="zh"?"正在连接学生终端...":"Entering Desk...":n==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),l.jsx(ho,{size:15})]})]})]})]})});function Uf({session:e,lang:t,onLogout:n,onProfile:s}){const[r,i]=p.useState(!1),o=p.useRef(null);p.useEffect(()=>{if(!r)return;const c=u=>{o.current&&!o.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);const a=(c,u)=>t==="zh"?c:u;return l.jsxs("div",{className:"relative",ref:o,children:[l.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-haspopup":"menu","aria-expanded":r,title:e.name,className:"flex items-center gap-1 rounded-full p-1 hover:bg-gray-100 transition-colors cursor-pointer",children:[l.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?l.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):l.jsx(gn,{size:20})}),l.jsx(Va,{size:14,className:`text-gray-400 transition-transform duration-200 ${r?"rotate-180":""}`})]}),r&&l.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:[l.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[l.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),l.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),l.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{i(!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:[l.jsx(gn,{size:16,className:"text-gray-400"}),a("个人资料","Profile")]}),l.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{i(!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:[l.jsx(Ih,{size:16}),a("注销登录","Sign Out")]})]})]})}const Wf=[{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"}],Gn={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":"#64748b","--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":"#9ca3af","--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":"#3d6350","--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":"#81c784","--color-primary":"#4caf50","--color-primary-hover":"#388e3c"}},hr="openlearn_theme",rn="openlearn_custom_themes",rs={};function hi(e){return rs[e]?rs[e]:e in Gn?Gn[e]:Gn.light}function fr(e){typeof document>"u"||document.documentElement.setAttribute("data-theme",e)}function qf(e,t){if(typeof document>"u")return;rs[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 r=Object.entries(t).map(([i,o])=>` ${i}: ${o};`).join(`
2
2
  `);s.textContent=`[data-theme="${e}"] {
3
3
  ${r}
4
- }`}function Hf(e){if(typeof document>"u")return;delete rs[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function pr(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastThemeToIframes:t}=await Ie(async()=>{const{broadcastThemeToIframes:n}=await Promise.resolve().then(()=>Nw);return{broadcastThemeToIframes:n}},void 0);t(e,hi(e))}catch{}},0)}catch{}}const cs=Ha((e,t)=>({theme:"light",availableThemes:[...Wf],initTheme:()=>{if(typeof window>"u")return;try{const r=localStorage.getItem(rn);if(r){const i=JSON.parse(r);Array.isArray(i)&&i.forEach(o=>{o&&o.spec&&o.spec.id&&t().registerTheme(o.spec,o.cssVariables)})}}catch{}const s=localStorage.getItem(hr)||"light";fr(s),e({theme:s}),pr(s)},setTheme:n=>{fr(n),typeof window<"u"&&localStorage.setItem(hr,n),e({theme:n}),pr(n)},registerTheme:(n,s)=>{s&&qf(n.id,s),e(r=>({availableThemes:[...r.availableThemes.filter(o=>o.id!==n.id),n]}))},unregisterTheme:n=>{Hf(n),e(s=>{const r=s.availableThemes.filter(o=>o.id!==n),i=s.theme===n?"light":s.theme;return s.theme===n&&(fr("light"),typeof window<"u"&&localStorage.setItem(hr,"light"),pr("light")),{availableThemes:r,theme:i}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const r=localStorage.getItem(rn);let i=r?JSON.parse(r):[];Array.isArray(i)||(i=[]),i=i.filter(o=>o.spec.id!==n.id),i.push({spec:n,cssVariables:s}),localStorage.setItem(rn,JSON.stringify(i))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(rn);if(s){let r=JSON.parse(s);Array.isArray(r)&&(r=r.filter(i=>i.spec.id!==n),localStorage.setItem(rn,JSON.stringify(r)))}}catch{}t().unregisterTheme(n)}})),Gf=[{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"}}],vo={...Gn.light};function Qf({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:r,deleteCustomTheme:i}=cs(),o=p.useId(),[a,c]=p.useState("custom-mytheme"),[u,d]=p.useState("我的专属主题"),[f,m]=p.useState("自定义教学调色板配置"),[h,g]=p.useState({...vo}),[x,v]=p.useState("none"),[w,I]=p.useState(""),[S,P]=p.useState(!1),[z,E]=p.useState(null);if(!e)return null;const L=s.filter(k=>k.category==="custom"),_=k=>{E(k),setTimeout(()=>E(null),3e3)},M=k=>{c(k.id),d(k.label),m(k.description),g({...k.tokens}),_(`已载入预设: ${k.label}`)},N=k=>{c(k.id),d(k.label),m(k.description);const B=hi(k.id);B&&Object.keys(B).length>0&&g({...B}),_(`已载入自定义主题: ${k.label}`)},A=(k,B)=>{g(y=>({...y,[k]:B}))},R=()=>{const k=a.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!k){alert("请输入有效的主题标识 (ID)");return}const B={id:k,label:u.trim()||"未命名主题",description:f.trim()||"自定义主题",previewBg:h["--bg-app"]||"#ffffff",previewPrimary:h["--color-primary"]||"#4f46e5",category:"custom"};r(B,h),_(`主题「${B.label}」已保存并成功激活!`)},D=()=>{I(JSON.stringify({version:"1.0",id:a,label:u,description:f,tokens:h},null,2)),v("export")},F=()=>{I(""),v("import")},j=()=>{try{const k=JSON.parse(w);if(!k.tokens||typeof k.tokens!="object")throw new Error("缺少合法的 tokens 字段");k.id&&c(k.id),k.label&&d(k.label),k.description&&m(k.description),g(B=>({...B,...k.tokens})),v("none"),_("主题配置导入成功!")}catch(k){alert(`导入失败: ${k.message||"JSON 格式解析错误"}`)}},T=()=>{navigator.clipboard.writeText(w),P(!0),setTimeout(()=>P(!1),2e3)},$=[{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 l.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:l.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:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:l.jsx(Dr,{size:22})}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",l.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"})]}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{onClick:F,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:[l.jsx(fo,{size:14}),n==="zh"?"导入配置":"Import"]}),l.jsxs("button",{onClick:D,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:[l.jsx(po,{size:14}),n==="zh"?"导出配置":"Export"]}),l.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:l.jsx(At,{size:18})})]})]}),z&&l.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:[l.jsx(Fr,{size:14}),z]}),l.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[l.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[l.jsxs("section",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(ls,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),l.jsx("span",{className:"text-2xs text-muted",children:"一键填入调色板"})]}),l.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Gf.map(k=>l.jsxs("button",{onClick:()=>M(k),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:[l.jsxs("div",{className:"flex items-center justify-between w-full",children:[l.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[l.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:k.tokens["--color-primary"]}}),k.label]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:k.tokens["--bg-app"]}}),l.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:k.tokens["--bg-surface"]}})]})]}),l.jsx("p",{className:"text-3xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:k.description})]},k.id))})]}),l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(jh,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-themeId`,className:"block text-2xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),l.jsx("input",{id:`${o}-themeId`,type:"text",value:a,onChange:k=>c(k.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"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-label`,className:"block text-2xs font-medium text-muted mb-1",children:"主题名称"}),l.jsx("input",{id:`${o}-label`,type:"text",value:u,onChange:k=>d(k.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"})]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-description`,className:"block text-2xs font-medium text-muted mb-1",children:"主题描述"}),l.jsx("input",{id:`${o}-description`,type:"text",value:f,onChange:k=>m(k.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"})]})]}),l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(Dr,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),l.jsx("div",{className:"space-y-2.5",children:$.map(k=>{const B=h[k.key]||"#000000";return l.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[l.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-main",children:k.labelZh}),l.jsx("span",{className:"text-3xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:k.key})]}),l.jsx("p",{className:"text-3xs text-muted mt-0.5",children:k.desc})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx("div",{className:"relative flex items-center",children:l.jsx("input",{type:"color",value:B.startsWith("#")&&B.length===7?B:"#4f46e5",onChange:y=>A(k.key,y.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),l.jsx("input",{type:"text",value:B,onChange:y=>A(k.key,y.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"})]})]},k.key)})})]}),L.length>0&&l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(Ah,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),l.jsx("div",{className:"space-y-2",children:L.map(k=>l.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[l.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[l.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:k.previewPrimary}}),l.jsxs("div",{className:"truncate",children:[l.jsx("div",{className:"text-xs font-semibold text-main truncate",children:k.label}),l.jsx("div",{className:"text-3xs text-muted truncate",children:k.description})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[l.jsx("button",{onClick:()=>N(k),className:"px-2 py-1 text-2xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),l.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${k.label}」吗?`)&&(i(k.id),_(`已删除主题「${k.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:l.jsx(zh,{size:13})})]})]},k.id))})]})]}),l.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[l.jsx(Ua,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),l.jsxs("span",{className:"text-2xs text-muted font-mono",children:["当前预览: ",u," (",a,")"]})]}),l.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:[l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.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"}),l.jsx("span",{className:"font-bold text-xs",style:{color:h["--text-main"]},children:"OpenLearn V2"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-3xs 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"}),l.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-3xs font-bold text-white",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"T"})]})]}),l.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[l.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:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-bold text-sm",style:{color:h["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),l.jsx("p",{className:"text-xs mt-1",style:{color:h["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),l.jsx("span",{className:"text-3xs 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:"进行中"})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"光电门测速 (v)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"2.43 m/s"})]}),l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"动能增量 (ΔEk)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--color-primary"]},children:"0.589 J"})]}),l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"误差率 (Err)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"0.84 %"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.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:"开始数据采集"}),l.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:"重置实验"}),l.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:h["--text-muted"]},children:"查看教案"})]})]}),l.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-2xs font-semibold",style:{color:h["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),l.jsx("span",{className:"text-3xs font-mono",style:{color:h["--text-muted"]},children:"60 FPS"})]}),l.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:[l.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:l.jsx(ai,{size:20})}),l.jsx("div",{className:"absolute bottom-2 right-2 text-3xs 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"})]})]})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("button",{onClick:()=>{g({...vo}),_("已重置为系统默认调色板")},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:[l.jsx(Lh,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.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"}),l.jsxs("button",{onClick:R,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:[l.jsx(_h,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),x!=="none"&&l.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:l.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:x==="export"?l.jsxs(l.Fragment,{children:[l.jsx(po,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):l.jsxs(l.Fragment,{children:[l.jsx(fo,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),l.jsx("button",{onClick:()=>v("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:l.jsx(At,{size:16})})]}),l.jsx("div",{children:l.jsx("textarea",{value:w,readOnly:x==="export",onChange:k=>I(k.target.value),placeholder:x==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-2xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),l.jsx("div",{className:"flex items-center justify-end gap-2",children:x==="export"?l.jsx(l.Fragment,{children:l.jsxs("button",{onClick:T,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?l.jsx(Fr,{size:14}):l.jsx(Rh,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:()=>v("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"}),l.jsx("button",{onClick:j,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 Jf({lang:e="zh"}){const[t,n]=p.useState(!1),[s,r]=p.useState(!1),i=p.useRef(null),{theme:o,availableThemes:a,setTheme:c}=cs();p.useEffect(()=>{function d(f){i.current&&!i.current.contains(f.target)&&n(!1)}return t&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[t]);const u=d=>{switch(d){case"dark":return l.jsx(Mh,{size:16,className:"text-indigo-400"});case"eyecare":return l.jsx(Ua,{size:16,className:"text-emerald-500"});case"chalkboard":return l.jsx(Dr,{size:16,className:"text-green-400"});case"light":default:return l.jsx(Oh,{size:16,className:"text-amber-500"})}};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative",ref:i,children:[l.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:u(o)}),t&&l.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:[l.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[l.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),l.jsx("div",{className:"text-2xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),l.jsx("div",{className:"space-y-1",children:a.map(d=>{const f=o===d.id;return l.jsxs("button",{onClick:()=>{c(d.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 ${f?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.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:d.previewPrimary}}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium text-main leading-none",children:d.label}),l.jsx("div",{className:"text-3xs text-muted mt-1 leading-tight opacity-80",children:d.description})]})]}),f&&l.jsx(Fr,{size:14,className:"text-primary-theme shrink-0"})]},d.id)})}),l.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:l.jsxs("button",{onClick:()=>{n(!1),r(!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:[l.jsx(ls,{size:14}),l.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),l.jsx(Qf,{isOpen:s,onClose:()=>r(!1),lang:e})]})}function Zf(e){const{activeRole:t,lang:n,teacherTab:s,studentViewStatus:r,session:i,activeStudentId:o,students:a,studentDashboardData:c,isNotificationsOpen:u,studentNotifications:d,unreadNotifications:f,readNotifications:m,dbConnected:h,dbStatus:g,siteInfo:x,setActiveStudentId:v,setReadNotifications:w,setIsSystemResourceLibraryOpen:I,setProfileOpen:S,setTeacherTab:P,setStudentViewStatus:z,setIsNotificationsOpen:E,setSelectedNotificationForModal:L,handleLogout:_,toggleLanguage:M}=e;return l.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:[l.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[l.jsxs("button",{onClick:()=>{t==="teacher"?P("dashboard"):t==="student"&&z("dashboard")},className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:n==="zh"?"返回系统总览":"Back to Dashboard",children:[x.logoUrl?l.jsx("img",{src:x.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):l.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"}),l.jsxs("div",{className:"flex items-baseline gap-2",children:[l.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:x.siteName||"OpenLearn Next"}),l.jsxs("span",{className:"text-[10px] font-medium text-slate-400 tracking-tight",children:["v","0.3.3"]}),x.slogan&&l.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:x.slogan})]})]}),l.jsxs("button",{onClick:()=>{t==="teacher"?P("dashboard"):t==="student"&&z("dashboard")},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${t==="teacher"&&s==="dashboard"||t==="student"&&r==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"}`,children:[l.jsx(Dh,{size:16}),n==="zh"?"系统总览":"Dashboard"]}),t==="student"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),l.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[l.jsx(Fh,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&i.role==="teacher"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-gray-500",children:"View as:"}),l.jsxs("select",{className:"border border-gray-200 rounded p-1 text-sm bg-white",value:o||"",onChange:N=>v(N.target.value),children:[l.jsx("option",{value:"",children:"-- Select Student --"}),a.map(N=>l.jsx("option",{value:N.id,children:N.name},N.id))]})]})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>E(!u),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[l.jsx(Bh,{size:20}),f.length>0&&l.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:f.length})]}),u&&l.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:[l.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[l.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),f.length>0&&l.jsx("button",{onClick:async()=>{if(!o)return;try{const A=d.filter(R=>!m.has(R.id)).map(R=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:R.id})}));await Promise.all(A)}catch(A){console.error(A)}const N=new Set(m);d.forEach(A=>N.add(A.id)),w(N)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),l.jsx("div",{className:"max-h-96 overflow-y-auto",children:d.length===0?l.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):l.jsx("div",{className:"divide-y divide-gray-100",children:d.map(N=>{const A=!m.has(N.id);return l.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${A?"bg-indigo-50/30":""}`,onClick:()=>{if(A){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:N.id})}).catch(console.error);const D=new Set(m);D.add(N.id),w(D)}const R=c?.assignments?.find(D=>D.id===N.relatedId);L({...N,assignment:R}),E(!1)},children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx("div",{className:"mt-0.5",children:N.type==="new_assignment"?l.jsx(Wa,{size:16,className:"text-indigo-500"}):N.type==="rollcall_picked"?l.jsx(ls,{size:16,className:"text-amber-500 animate-pulse"}):l.jsx(li,{size:16,className:"text-green-500"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:`text-sm ${A?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:N.title}),l.jsx("div",{className:`text-xs mt-0.5 ${A?"text-gray-600":"text-gray-500"}`,children:N.message})]}),A&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},N.id)})})})]})]}),l.jsxs("button",{onClick:()=>I(!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:[l.jsx(Br,{size:14,className:"text-emerald-500 animate-pulse"}),n==="zh"?"系统资源库":"System Resource Library"]}),l.jsx("button",{onClick:M,title:n==="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:l.jsx(Br,{size:16})}),l.jsx(Jf,{lang:n}),(()=>{const N=g==="error"||!h?{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:n==="zh"?"SQLite 数据库连接出错或已断开":"SQLite DB Error / Disconnected"}:g==="warning"?{bg:"bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100",dot:"bg-amber-500",ping:"bg-amber-400",label:n==="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:n==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return l.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 ${N.bg}`,title:N.label,children:[l.jsx($h,{size:15}),l.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[l.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${N.ping}`}),l.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${N.dot}`})]})]})})(),l.jsx(Uf,{session:i,lang:n,onLogout:_,onProfile:()=>S(!0)})]})]})}function Yf({open:e,session:t,lang:n,onClose:s,onSaved:r,onAvatar:i}){const[o,a]=p.useState(t.name),[c,u]=p.useState(!1),[d,f]=p.useState(null),m=p.useRef(null),[h,g]=p.useState(!1),[x,v]=p.useState(null),[w,I]=p.useState(!1),[S,P]=p.useState(""),[z,E]=p.useState(""),[L,_]=p.useState(""),[M,N]=p.useState(!1),[A,R]=p.useState(null),[D,F]=p.useState(!1);if(!e)return null;const j=(q,ee)=>n==="zh"?q:ee,T=t.role==="teacher"?t.subRole==="administrator"?j("管理员","Administrator"):j("教师","Teacher"):j("学生","Student"),$=o.trim(),k=$.length>0&&$!==t.name,B=async()=>{if(!(!k||c)){u(!0),f(null);try{const q=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})}),ee=await q.json();if(!q.ok){f(ee.error||(n==="zh"?"保存失败":"Save failed"));return}r(ee.name??$)}catch{f(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{u(!1)}}},y=S.length>0&&z.length>=8&&/[a-zA-Z]/.test(z)&&/[0-9]/.test(z)&&z===L,te=async()=>{if(!(!y||M)){N(!0),R(null);try{const q=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:z})}),ee=await q.json();if(!q.ok){R(ee.error||(n==="zh"?"修改失败":"Change failed"));return}F(!0),P(""),E(""),_(""),I(!1)}catch{R(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{N(!1)}}},ae=async q=>{const ee=q.target.files?.[0];if(q.target.value="",!!ee){g(!0),v(null);try{const se=await new Promise((ze,je)=>{const he=new FileReader;he.onload=()=>ze(he.result),he.onerror=()=>je(he.error),he.readAsDataURL(ee)}),fe=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:ee.name,base64Data:se})}),ge=await fe.json();if(!fe.ok){v(ge.error||(n==="zh"?"上传失败":"Upload failed"));return}i?.(ge.avatar)}catch{v(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},b=async()=>{g(!0),v(null);try{const q=await fetch("/api/auth/avatar",{method:"DELETE"}),ee=await q.json().catch(()=>({}));if(!q.ok){v(ee.error||(n==="zh"?"移除失败":"Remove failed"));return}i?.(null)}catch{v(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:l.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:q=>q.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[l.jsx("h3",{className:"font-semibold text-gray-800",children:j("个人资料","Profile")}),l.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:l.jsx(At,{size:18})})]}),l.jsxs("div",{className:"p-5 space-y-5",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.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?l.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):l.jsx(gn,{size:28})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),l.jsx("p",{className:"text-xs text-gray-400",children:T}),l.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[l.jsx("button",{type:"button",onClick:()=>m.current?.click(),disabled:h,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:h?j("上传中…","Uploading…"):t.avatar?j("更换头像","Change avatar"):j("上传头像","Upload avatar")}),t.avatar&&l.jsx("button",{type:"button",onClick:b,disabled:h,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:j("移除","Remove")})]}),l.jsx("input",{ref:m,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:ae})]})]}),x&&l.jsx("p",{className:"text-xs text-rose-500",children:x}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:j("显示名称","Display Name")}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:o,onChange:q=>a(q.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"}),l.jsx("button",{onClick:B,disabled:!k||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?j("保存中…","Saving…"):j("保存","Save")})]}),d&&l.jsx("p",{className:"text-xs text-rose-500 mt-1",children:d})]}),l.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[l.jsx(Vh,{size:16,className:"text-gray-400"}),j("修改密码","Change Password")]}),!w&&!D&&l.jsx("button",{onClick:()=>{I(!0),R(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:j("修改","Edit")})]}),D&&l.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[l.jsx(li,{size:16}),j("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&l.jsxs("div",{className:"mt-3 space-y-3",children:[l.jsx("input",{type:"password",value:S,onChange:q=>P(q.target.value),placeholder:j("当前密码","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"}),l.jsx("input",{type:"password",value:z,onChange:q=>E(q.target.value),placeholder:j("新密码(≥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"}),l.jsx("input",{type:"password",value:L,onChange:q=>_(q.target.value),placeholder:j("确认新密码","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"}),A&&l.jsx("p",{className:"text-xs text-rose-500",children:A}),l.jsxs("div",{className:"flex gap-2 justify-end",children:[l.jsx("button",{onClick:()=>{I(!1),P(""),E(""),_(""),R(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:j("取消","Cancel")}),l.jsx("button",{onClick:te,disabled:!y||M,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:M?j("提交中…","Submitting…"):j("提交","Submit")})]})]})]}),l.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-gray-400",children:j("用户名(登录账号)","Username (login)")}),l.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-gray-400",children:j("角色","Role")}),l.jsx("span",{className:"text-sm font-medium text-gray-700",children:T})]})]})]})]})})}const u0={slate:{iconBg:"bg-slate-100",iconText:"text-slate-600",cardHoverBorder:"hover:border-slate-400",cardHoverRing:"group-hover:ring-slate-300",cardHoverShadow:"group-hover:shadow-slate-200/70",groupAccent:"bg-slate-400",groupText:"text-slate-500"},blue:{iconBg:"bg-blue-100",iconText:"text-blue-600",cardHoverBorder:"hover:border-blue-400",cardHoverRing:"group-hover:ring-blue-300",cardHoverShadow:"group-hover:shadow-blue-200/70",groupAccent:"bg-blue-400",groupText:"text-blue-500"},violet:{iconBg:"bg-violet-100",iconText:"text-violet-600",cardHoverBorder:"hover:border-violet-400",cardHoverRing:"group-hover:ring-violet-300",cardHoverShadow:"group-hover:shadow-violet-200/70",groupAccent:"bg-violet-400",groupText:"text-violet-500"},amber:{iconBg:"bg-amber-100",iconText:"text-amber-600",cardHoverBorder:"hover:border-amber-400",cardHoverRing:"group-hover:ring-amber-300",cardHoverShadow:"group-hover:shadow-amber-200/70",groupAccent:"bg-amber-400",groupText:"text-amber-500"},rose:{iconBg:"bg-rose-100",iconText:"text-rose-600",cardHoverBorder:"hover:border-rose-400",cardHoverRing:"group-hover:ring-rose-300",cardHoverShadow:"group-hover:shadow-rose-200/70",groupAccent:"bg-rose-400",groupText:"text-rose-500"},emerald:{iconBg:"bg-emerald-100",iconText:"text-emerald-600",cardHoverBorder:"hover:border-emerald-400",cardHoverRing:"group-hover:ring-emerald-300",cardHoverShadow:"group-hover:shadow-emerald-200/70",groupAccent:"bg-emerald-400",groupText:"text-emerald-500"},cyan:{iconBg:"bg-cyan-100",iconText:"text-cyan-600",cardHoverBorder:"hover:border-cyan-400",cardHoverRing:"group-hover:ring-cyan-300",cardHoverShadow:"group-hover:shadow-cyan-200/70",groupAccent:"bg-cyan-400",groupText:"text-cyan-500"},pink:{iconBg:"bg-pink-100",iconText:"text-pink-600",cardHoverBorder:"hover:border-pink-400",cardHoverRing:"group-hover:ring-pink-300",cardHoverShadow:"group-hover:shadow-pink-200/70",groupAccent:"bg-pink-400",groupText:"text-pink-500"},indigo:{iconBg:"bg-indigo-100",iconText:"text-indigo-600",cardHoverBorder:"hover:border-indigo-400",cardHoverRing:"group-hover:ring-indigo-300",cardHoverShadow:"group-hover:shadow-indigo-200/70",groupAccent:"bg-indigo-400",groupText:"text-indigo-500"}},d0=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"}],Kf=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:Uh,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
4
+ }`}function Hf(e){if(typeof document>"u")return;delete rs[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function pr(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastThemeToIframes:t}=await Ie(async()=>{const{broadcastThemeToIframes:n}=await Promise.resolve().then(()=>Nw);return{broadcastThemeToIframes:n}},void 0);t(e,hi(e))}catch{}},0)}catch{}}const cs=Ha((e,t)=>({theme:"light",availableThemes:[...Wf],initTheme:()=>{if(typeof window>"u")return;try{const r=localStorage.getItem(rn);if(r){const i=JSON.parse(r);Array.isArray(i)&&i.forEach(o=>{o&&o.spec&&o.spec.id&&t().registerTheme(o.spec,o.cssVariables)})}}catch{}const s=localStorage.getItem(hr)||"light";fr(s),e({theme:s}),pr(s)},setTheme:n=>{fr(n),typeof window<"u"&&localStorage.setItem(hr,n),e({theme:n}),pr(n)},registerTheme:(n,s)=>{s&&qf(n.id,s),e(r=>({availableThemes:[...r.availableThemes.filter(o=>o.id!==n.id),n]}))},unregisterTheme:n=>{Hf(n),e(s=>{const r=s.availableThemes.filter(o=>o.id!==n),i=s.theme===n?"light":s.theme;return s.theme===n&&(fr("light"),typeof window<"u"&&localStorage.setItem(hr,"light"),pr("light")),{availableThemes:r,theme:i}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const r=localStorage.getItem(rn);let i=r?JSON.parse(r):[];Array.isArray(i)||(i=[]),i=i.filter(o=>o.spec.id!==n.id),i.push({spec:n,cssVariables:s}),localStorage.setItem(rn,JSON.stringify(i))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(rn);if(s){let r=JSON.parse(s);Array.isArray(r)&&(r=r.filter(i=>i.spec.id!==n),localStorage.setItem(rn,JSON.stringify(r)))}}catch{}t().unregisterTheme(n)}})),Gf=[{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"}}],vo={...Gn.light};function Qf({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:r,deleteCustomTheme:i}=cs(),o=p.useId(),[a,c]=p.useState("custom-mytheme"),[u,d]=p.useState("我的专属主题"),[f,m]=p.useState("自定义教学调色板配置"),[h,g]=p.useState({...vo}),[x,v]=p.useState("none"),[w,I]=p.useState(""),[S,P]=p.useState(!1),[z,E]=p.useState(null);if(!e)return null;const L=s.filter(k=>k.category==="custom"),_=k=>{E(k),setTimeout(()=>E(null),3e3)},M=k=>{c(k.id),d(k.label),m(k.description),g({...k.tokens}),_(`已载入预设: ${k.label}`)},N=k=>{c(k.id),d(k.label),m(k.description);const B=hi(k.id);B&&Object.keys(B).length>0&&g({...B}),_(`已载入自定义主题: ${k.label}`)},A=(k,B)=>{g(y=>({...y,[k]:B}))},R=()=>{const k=a.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!k){alert("请输入有效的主题标识 (ID)");return}const B={id:k,label:u.trim()||"未命名主题",description:f.trim()||"自定义主题",previewBg:h["--bg-app"]||"#ffffff",previewPrimary:h["--color-primary"]||"#4f46e5",category:"custom"};r(B,h),_(`主题「${B.label}」已保存并成功激活!`)},D=()=>{I(JSON.stringify({version:"1.0",id:a,label:u,description:f,tokens:h},null,2)),v("export")},F=()=>{I(""),v("import")},j=()=>{try{const k=JSON.parse(w);if(!k.tokens||typeof k.tokens!="object")throw new Error("缺少合法的 tokens 字段");k.id&&c(k.id),k.label&&d(k.label),k.description&&m(k.description),g(B=>({...B,...k.tokens})),v("none"),_("主题配置导入成功!")}catch(k){alert(`导入失败: ${k.message||"JSON 格式解析错误"}`)}},T=()=>{navigator.clipboard.writeText(w),P(!0),setTimeout(()=>P(!1),2e3)},$=[{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 l.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:l.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:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:l.jsx(Dr,{size:22})}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",l.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"})]}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{onClick:F,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:[l.jsx(fo,{size:14}),n==="zh"?"导入配置":"Import"]}),l.jsxs("button",{onClick:D,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:[l.jsx(po,{size:14}),n==="zh"?"导出配置":"Export"]}),l.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:l.jsx(At,{size:18})})]})]}),z&&l.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:[l.jsx(Fr,{size:14}),z]}),l.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[l.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[l.jsxs("section",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(ls,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),l.jsx("span",{className:"text-2xs text-muted",children:"一键填入调色板"})]}),l.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Gf.map(k=>l.jsxs("button",{onClick:()=>M(k),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:[l.jsxs("div",{className:"flex items-center justify-between w-full",children:[l.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[l.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:k.tokens["--color-primary"]}}),k.label]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:k.tokens["--bg-app"]}}),l.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:k.tokens["--bg-surface"]}})]})]}),l.jsx("p",{className:"text-3xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:k.description})]},k.id))})]}),l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(jh,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-themeId`,className:"block text-2xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),l.jsx("input",{id:`${o}-themeId`,type:"text",value:a,onChange:k=>c(k.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"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-label`,className:"block text-2xs font-medium text-muted mb-1",children:"主题名称"}),l.jsx("input",{id:`${o}-label`,type:"text",value:u,onChange:k=>d(k.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"})]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:`${o}-description`,className:"block text-2xs font-medium text-muted mb-1",children:"主题描述"}),l.jsx("input",{id:`${o}-description`,type:"text",value:f,onChange:k=>m(k.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"})]})]}),l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(Dr,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),l.jsx("div",{className:"space-y-2.5",children:$.map(k=>{const B=h[k.key]||"#000000";return l.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[l.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-main",children:k.labelZh}),l.jsx("span",{className:"text-3xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:k.key})]}),l.jsx("p",{className:"text-3xs text-muted mt-0.5",children:k.desc})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx("div",{className:"relative flex items-center",children:l.jsx("input",{type:"color",value:B.startsWith("#")&&B.length===7?B:"#4f46e5",onChange:y=>A(k.key,y.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),l.jsx("input",{type:"text",value:B,onChange:y=>A(k.key,y.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"})]})]},k.key)})})]}),L.length>0&&l.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[l.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[l.jsx(Ah,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),l.jsx("div",{className:"space-y-2",children:L.map(k=>l.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[l.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[l.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:k.previewPrimary}}),l.jsxs("div",{className:"truncate",children:[l.jsx("div",{className:"text-xs font-semibold text-main truncate",children:k.label}),l.jsx("div",{className:"text-3xs text-muted truncate",children:k.description})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[l.jsx("button",{onClick:()=>N(k),className:"px-2 py-1 text-2xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),l.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${k.label}」吗?`)&&(i(k.id),_(`已删除主题「${k.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:l.jsx(zh,{size:13})})]})]},k.id))})]})]}),l.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[l.jsx(Ua,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),l.jsxs("span",{className:"text-2xs text-muted font-mono",children:["当前预览: ",u," (",a,")"]})]}),l.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:[l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.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"}),l.jsx("span",{className:"font-bold text-xs",style:{color:h["--text-main"]},children:"OpenLearn V2"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-3xs 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"}),l.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-3xs font-bold text-white",style:{backgroundColor:h["--color-primary"]||"#4f46e5"},children:"T"})]})]}),l.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[l.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:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-bold text-sm",style:{color:h["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),l.jsx("p",{className:"text-xs mt-1",style:{color:h["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),l.jsx("span",{className:"text-3xs 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:"进行中"})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"光电门测速 (v)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"2.43 m/s"})]}),l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"动能增量 (ΔEk)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--color-primary"]},children:"0.589 J"})]}),l.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:h["--bg-surface-secondary"]},children:[l.jsx("div",{className:"text-3xs",style:{color:h["--text-muted"]},children:"误差率 (Err)"}),l.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:h["--text-main"]},children:"0.84 %"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.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:"开始数据采集"}),l.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:"重置实验"}),l.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:h["--text-muted"]},children:"查看教案"})]})]}),l.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-2xs font-semibold",style:{color:h["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),l.jsx("span",{className:"text-3xs font-mono",style:{color:h["--text-muted"]},children:"60 FPS"})]}),l.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:[l.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:l.jsx(ai,{size:20})}),l.jsx("div",{className:"absolute bottom-2 right-2 text-3xs 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"})]})]})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("button",{onClick:()=>{g({...vo}),_("已重置为系统默认调色板")},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:[l.jsx(Lh,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.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"}),l.jsxs("button",{onClick:R,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:[l.jsx(_h,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),x!=="none"&&l.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:l.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:x==="export"?l.jsxs(l.Fragment,{children:[l.jsx(po,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):l.jsxs(l.Fragment,{children:[l.jsx(fo,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),l.jsx("button",{onClick:()=>v("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:l.jsx(At,{size:16})})]}),l.jsx("div",{children:l.jsx("textarea",{value:w,readOnly:x==="export",onChange:k=>I(k.target.value),placeholder:x==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-2xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),l.jsx("div",{className:"flex items-center justify-end gap-2",children:x==="export"?l.jsx(l.Fragment,{children:l.jsxs("button",{onClick:T,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?l.jsx(Fr,{size:14}):l.jsx(Rh,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:()=>v("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"}),l.jsx("button",{onClick:j,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 Jf({lang:e="zh"}){const[t,n]=p.useState(!1),[s,r]=p.useState(!1),i=p.useRef(null),{theme:o,availableThemes:a,setTheme:c}=cs();p.useEffect(()=>{function d(f){i.current&&!i.current.contains(f.target)&&n(!1)}return t&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[t]);const u=d=>{switch(d){case"dark":return l.jsx(Mh,{size:16,className:"text-indigo-400"});case"eyecare":return l.jsx(Ua,{size:16,className:"text-emerald-500"});case"chalkboard":return l.jsx(Dr,{size:16,className:"text-green-400"});case"light":default:return l.jsx(Oh,{size:16,className:"text-amber-500"})}};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative",ref:i,children:[l.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:u(o)}),t&&l.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:[l.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[l.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),l.jsx("div",{className:"text-2xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),l.jsx("div",{className:"space-y-1",children:a.map(d=>{const f=o===d.id;return l.jsxs("button",{onClick:()=>{c(d.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 ${f?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.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:d.previewPrimary}}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium text-main leading-none",children:d.label}),l.jsx("div",{className:"text-3xs text-muted mt-1 leading-tight opacity-80",children:d.description})]})]}),f&&l.jsx(Fr,{size:14,className:"text-primary-theme shrink-0"})]},d.id)})}),l.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:l.jsxs("button",{onClick:()=>{n(!1),r(!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:[l.jsx(ls,{size:14}),l.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),l.jsx(Qf,{isOpen:s,onClose:()=>r(!1),lang:e})]})}function Zf(e){const{activeRole:t,lang:n,teacherTab:s,studentViewStatus:r,session:i,activeStudentId:o,students:a,studentDashboardData:c,isNotificationsOpen:u,studentNotifications:d,unreadNotifications:f,readNotifications:m,dbConnected:h,dbStatus:g,siteInfo:x,setActiveStudentId:v,setReadNotifications:w,setIsSystemResourceLibraryOpen:I,setProfileOpen:S,setTeacherTab:P,setStudentViewStatus:z,setIsNotificationsOpen:E,setSelectedNotificationForModal:L,handleLogout:_,toggleLanguage:M}=e;return l.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:[l.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[l.jsxs("button",{onClick:()=>{t==="teacher"?P("dashboard"):t==="student"&&z("dashboard")},className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:n==="zh"?"返回系统总览":"Back to Dashboard",children:[x.logoUrl?l.jsx("img",{src:x.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):l.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"}),l.jsxs("div",{className:"flex items-baseline gap-2",children:[l.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:x.siteName||"OpenLearn Next"}),l.jsxs("span",{className:"text-[10px] font-medium text-slate-400 tracking-tight",children:["v","0.3.4"]}),x.slogan&&l.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:x.slogan})]})]}),l.jsxs("button",{onClick:()=>{t==="teacher"?P("dashboard"):t==="student"&&z("dashboard")},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${t==="teacher"&&s==="dashboard"||t==="student"&&r==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"}`,children:[l.jsx(Dh,{size:16}),n==="zh"?"系统总览":"Dashboard"]}),t==="student"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),l.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[l.jsx(Fh,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&i.role==="teacher"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-gray-500",children:"View as:"}),l.jsxs("select",{className:"border border-gray-200 rounded p-1 text-sm bg-white",value:o||"",onChange:N=>v(N.target.value),children:[l.jsx("option",{value:"",children:"-- Select Student --"}),a.map(N=>l.jsx("option",{value:N.id,children:N.name},N.id))]})]})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>E(!u),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[l.jsx(Bh,{size:20}),f.length>0&&l.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:f.length})]}),u&&l.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:[l.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[l.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),f.length>0&&l.jsx("button",{onClick:async()=>{if(!o)return;try{const A=d.filter(R=>!m.has(R.id)).map(R=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:R.id})}));await Promise.all(A)}catch(A){console.error(A)}const N=new Set(m);d.forEach(A=>N.add(A.id)),w(N)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),l.jsx("div",{className:"max-h-96 overflow-y-auto",children:d.length===0?l.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):l.jsx("div",{className:"divide-y divide-gray-100",children:d.map(N=>{const A=!m.has(N.id);return l.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${A?"bg-indigo-50/30":""}`,onClick:()=>{if(A){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:N.id})}).catch(console.error);const D=new Set(m);D.add(N.id),w(D)}const R=c?.assignments?.find(D=>D.id===N.relatedId);L({...N,assignment:R}),E(!1)},children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx("div",{className:"mt-0.5",children:N.type==="new_assignment"?l.jsx(Wa,{size:16,className:"text-indigo-500"}):N.type==="rollcall_picked"?l.jsx(ls,{size:16,className:"text-amber-500 animate-pulse"}):l.jsx(li,{size:16,className:"text-green-500"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:`text-sm ${A?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:N.title}),l.jsx("div",{className:`text-xs mt-0.5 ${A?"text-gray-600":"text-gray-500"}`,children:N.message})]}),A&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},N.id)})})})]})]}),l.jsxs("button",{onClick:()=>I(!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:[l.jsx(Br,{size:14,className:"text-emerald-500 animate-pulse"}),n==="zh"?"系统资源库":"System Resource Library"]}),l.jsx("button",{onClick:M,title:n==="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:l.jsx(Br,{size:16})}),l.jsx(Jf,{lang:n}),(()=>{const N=g==="error"||!h?{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:n==="zh"?"SQLite 数据库连接出错或已断开":"SQLite DB Error / Disconnected"}:g==="warning"?{bg:"bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100",dot:"bg-amber-500",ping:"bg-amber-400",label:n==="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:n==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return l.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 ${N.bg}`,title:N.label,children:[l.jsx($h,{size:15}),l.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[l.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${N.ping}`}),l.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${N.dot}`})]})]})})(),l.jsx(Uf,{session:i,lang:n,onLogout:_,onProfile:()=>S(!0)})]})]})}function Yf({open:e,session:t,lang:n,onClose:s,onSaved:r,onAvatar:i}){const[o,a]=p.useState(t.name),[c,u]=p.useState(!1),[d,f]=p.useState(null),m=p.useRef(null),[h,g]=p.useState(!1),[x,v]=p.useState(null),[w,I]=p.useState(!1),[S,P]=p.useState(""),[z,E]=p.useState(""),[L,_]=p.useState(""),[M,N]=p.useState(!1),[A,R]=p.useState(null),[D,F]=p.useState(!1);if(!e)return null;const j=(q,ee)=>n==="zh"?q:ee,T=t.role==="teacher"?t.subRole==="administrator"?j("管理员","Administrator"):j("教师","Teacher"):j("学生","Student"),$=o.trim(),k=$.length>0&&$!==t.name,B=async()=>{if(!(!k||c)){u(!0),f(null);try{const q=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})}),ee=await q.json();if(!q.ok){f(ee.error||(n==="zh"?"保存失败":"Save failed"));return}r(ee.name??$)}catch{f(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{u(!1)}}},y=S.length>0&&z.length>=8&&/[a-zA-Z]/.test(z)&&/[0-9]/.test(z)&&z===L,te=async()=>{if(!(!y||M)){N(!0),R(null);try{const q=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:z})}),ee=await q.json();if(!q.ok){R(ee.error||(n==="zh"?"修改失败":"Change failed"));return}F(!0),P(""),E(""),_(""),I(!1)}catch{R(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{N(!1)}}},ae=async q=>{const ee=q.target.files?.[0];if(q.target.value="",!!ee){g(!0),v(null);try{const se=await new Promise((ze,je)=>{const he=new FileReader;he.onload=()=>ze(he.result),he.onerror=()=>je(he.error),he.readAsDataURL(ee)}),fe=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:ee.name,base64Data:se})}),ge=await fe.json();if(!fe.ok){v(ge.error||(n==="zh"?"上传失败":"Upload failed"));return}i?.(ge.avatar)}catch{v(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},b=async()=>{g(!0),v(null);try{const q=await fetch("/api/auth/avatar",{method:"DELETE"}),ee=await q.json().catch(()=>({}));if(!q.ok){v(ee.error||(n==="zh"?"移除失败":"Remove failed"));return}i?.(null)}catch{v(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:l.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:q=>q.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[l.jsx("h3",{className:"font-semibold text-gray-800",children:j("个人资料","Profile")}),l.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:l.jsx(At,{size:18})})]}),l.jsxs("div",{className:"p-5 space-y-5",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.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?l.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):l.jsx(gn,{size:28})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),l.jsx("p",{className:"text-xs text-gray-400",children:T}),l.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[l.jsx("button",{type:"button",onClick:()=>m.current?.click(),disabled:h,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:h?j("上传中…","Uploading…"):t.avatar?j("更换头像","Change avatar"):j("上传头像","Upload avatar")}),t.avatar&&l.jsx("button",{type:"button",onClick:b,disabled:h,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:j("移除","Remove")})]}),l.jsx("input",{ref:m,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:ae})]})]}),x&&l.jsx("p",{className:"text-xs text-rose-500",children:x}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:j("显示名称","Display Name")}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:o,onChange:q=>a(q.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"}),l.jsx("button",{onClick:B,disabled:!k||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?j("保存中…","Saving…"):j("保存","Save")})]}),d&&l.jsx("p",{className:"text-xs text-rose-500 mt-1",children:d})]}),l.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[l.jsx(Vh,{size:16,className:"text-gray-400"}),j("修改密码","Change Password")]}),!w&&!D&&l.jsx("button",{onClick:()=>{I(!0),R(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:j("修改","Edit")})]}),D&&l.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[l.jsx(li,{size:16}),j("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&l.jsxs("div",{className:"mt-3 space-y-3",children:[l.jsx("input",{type:"password",value:S,onChange:q=>P(q.target.value),placeholder:j("当前密码","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"}),l.jsx("input",{type:"password",value:z,onChange:q=>E(q.target.value),placeholder:j("新密码(≥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"}),l.jsx("input",{type:"password",value:L,onChange:q=>_(q.target.value),placeholder:j("确认新密码","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"}),A&&l.jsx("p",{className:"text-xs text-rose-500",children:A}),l.jsxs("div",{className:"flex gap-2 justify-end",children:[l.jsx("button",{onClick:()=>{I(!1),P(""),E(""),_(""),R(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:j("取消","Cancel")}),l.jsx("button",{onClick:te,disabled:!y||M,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:M?j("提交中…","Submitting…"):j("提交","Submit")})]})]})]}),l.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-gray-400",children:j("用户名(登录账号)","Username (login)")}),l.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-gray-400",children:j("角色","Role")}),l.jsx("span",{className:"text-sm font-medium text-gray-700",children:T})]})]})]})]})})}const u0={slate:{iconBg:"bg-slate-100",iconText:"text-slate-600",cardHoverBorder:"hover:border-slate-400",cardHoverRing:"group-hover:ring-slate-300",cardHoverShadow:"group-hover:shadow-slate-200/70",groupAccent:"bg-slate-400",groupText:"text-slate-500"},blue:{iconBg:"bg-blue-100",iconText:"text-blue-600",cardHoverBorder:"hover:border-blue-400",cardHoverRing:"group-hover:ring-blue-300",cardHoverShadow:"group-hover:shadow-blue-200/70",groupAccent:"bg-blue-400",groupText:"text-blue-500"},violet:{iconBg:"bg-violet-100",iconText:"text-violet-600",cardHoverBorder:"hover:border-violet-400",cardHoverRing:"group-hover:ring-violet-300",cardHoverShadow:"group-hover:shadow-violet-200/70",groupAccent:"bg-violet-400",groupText:"text-violet-500"},amber:{iconBg:"bg-amber-100",iconText:"text-amber-600",cardHoverBorder:"hover:border-amber-400",cardHoverRing:"group-hover:ring-amber-300",cardHoverShadow:"group-hover:shadow-amber-200/70",groupAccent:"bg-amber-400",groupText:"text-amber-500"},rose:{iconBg:"bg-rose-100",iconText:"text-rose-600",cardHoverBorder:"hover:border-rose-400",cardHoverRing:"group-hover:ring-rose-300",cardHoverShadow:"group-hover:shadow-rose-200/70",groupAccent:"bg-rose-400",groupText:"text-rose-500"},emerald:{iconBg:"bg-emerald-100",iconText:"text-emerald-600",cardHoverBorder:"hover:border-emerald-400",cardHoverRing:"group-hover:ring-emerald-300",cardHoverShadow:"group-hover:shadow-emerald-200/70",groupAccent:"bg-emerald-400",groupText:"text-emerald-500"},cyan:{iconBg:"bg-cyan-100",iconText:"text-cyan-600",cardHoverBorder:"hover:border-cyan-400",cardHoverRing:"group-hover:ring-cyan-300",cardHoverShadow:"group-hover:shadow-cyan-200/70",groupAccent:"bg-cyan-400",groupText:"text-cyan-500"},pink:{iconBg:"bg-pink-100",iconText:"text-pink-600",cardHoverBorder:"hover:border-pink-400",cardHoverRing:"group-hover:ring-pink-300",cardHoverShadow:"group-hover:shadow-pink-200/70",groupAccent:"bg-pink-400",groupText:"text-pink-500"},indigo:{iconBg:"bg-indigo-100",iconText:"text-indigo-600",cardHoverBorder:"hover:border-indigo-400",cardHoverRing:"group-hover:ring-indigo-300",cardHoverShadow:"group-hover:shadow-indigo-200/70",groupAccent:"bg-indigo-400",groupText:"text-indigo-500"}},d0=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"}],Kf=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:Uh,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
5
5
  ---
6
6
  ## Slide 2`},editFields:[{key:"markdown",labelZh:"幻灯片内容 (Markdown)",labelEn:"Slides Content (Markdown)",kind:"textarea",placeholderZh:`# 标题
7
7
  ---
@@ -121,7 +121,7 @@ This course integrates cross-subject paradigms, cognitive practices, and critica
121
121
  2. Sketch the systemic flow diagram depicting interaction factors.
122
122
 
123
123
  ### 📥 Assignment Brief
124
- Draft a 300-word integration proposal based on today's whiteboard exercises.`}};async function zx(e="all"){const t=await fetch(`/api/activities?role=${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to load activities (${t.status})`);return(await t.json()).activities??[]}async function la(){const e=await fetch("/api/activities/running",{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load running activities (${e.status})`);return(await e.json()).activities??[]}async function Lx(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/finish`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to finish activity (${t.status})`)}}async function _x(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/pause`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to pause activity (${t.status})`)}}async function Rx(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to resume activity (${t.status})`)}}async function Ox(e,t,n){const s=await fetch(`/api/activities/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t??{},actorId:n})}),r=await s.json();if(!s.ok||r.ok===!1)throw new Error(r.error||`Failed to start activity (${s.status})`);return r}const Mn={padding:"12px",color:"#e2e8f0",fontSize:"13px"},Mx={HelpCircle:Xh,Vote:Kh,BarChart3:Yh,MessagesSquare:Zh,Users:$a,FileText:qa,Trophy:Jh,CheckCircle2:li,BookOpen:ai};function Dx({name:e,className:t}){const n=e&&Mx[e]||ci;return l.jsx(n,{size:18,className:t})}function Fx(e,t){if(!e)return t==="zh"?"进行中":"In progress";const n=Math.max(0,Math.floor((Date.now()-e)/1e3)),s=Math.floor(n/60),r=n%60;return t==="zh"?`${s} 分 ${r} 秒`:`${s}m ${r}s`}const Ml=({role:e,actorId:t,lang:n="en",classroomId:s,mode:r="launcher"})=>{const[i,o]=p.useState([]),[a,c]=p.useState(!0),[u,d]=p.useState(null),[f,m]=p.useState({}),[h,g]=p.useState([]),[x,v]=p.useState(!0),[w,I]=p.useState(null),[S,P]=p.useState(null),[z,E]=p.useState(!1),[L,_]=p.useState(null),M=ce(k=>k.setTeacherTab),N=p.useMemo(()=>{const k=new Map;for(const B of i){const y=B.category;k.has(y)||k.set(y,[]),k.get(y).push(B)}return Array.from(k.entries())},[i]);p.useEffect(()=>{if(r!=="launcher")return;let k=!1;return c(!0),zx(e).then(B=>{k||o(B)}).catch(B=>{k||d(B instanceof Error?B.message:String(B))}).finally(()=>{k||c(!1)}),()=>{k=!0}},[e,r]),p.useEffect(()=>{if(r!=="status")return;let k=!1;const B=async()=>{try{const te=await la();k||g(te)}catch(te){k||I(te instanceof Error?te.message:String(te))}finally{k||v(!1)}};B();const y=setInterval(B,5e3);return()=>{k=!0,clearInterval(y)}},[r]);const A=async k=>{if(S){E(!0),_(null);try{await k(S),g(await la())}catch(B){_(B instanceof Error?B.message:String(B))}finally{E(!1)}}},R=()=>A(Lx),D=()=>A(_x),F=()=>A(Rx),j=()=>{P(null),M("live_class")};if(r==="status"){if(x)return l.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(w||h.length===0)return null;const k=h.find(B=>B.id===S)||null;return l.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[l.jsx("span",{children:"🧩"}),l.jsx("span",{children:n==="zh"?"进行中的活动":"Activities in Progress"})]}),l.jsx("span",{className:"text-[10px] font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:h.length})]}),l.jsx("div",{className:"flex flex-col gap-2",children:h.map(B=>{const y=B.state==="running";return l.jsxs("button",{onClick:()=>P(B.id),className:"w-full flex items-center gap-3 text-left bg-slate-50 hover:bg-slate-100 border border-slate-200/70 rounded-xl p-3 transition-colors",children:[l.jsx(Dx,{name:B.icon,className:"text-indigo-600 shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"font-bold text-slate-800 truncate",children:B.name}),B.category&&l.jsx("div",{className:"text-[11px] text-slate-500 truncate",children:B.category})]}),l.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[l.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full ${y?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:y?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"}),l.jsxs("span",{className:"text-[10px] text-slate-400 flex items-center gap-1",children:[l.jsx(Hh,{size:10})," ",Fx(B.startedAt,n)]})]})]},B.id)})}),k&&l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>P(null),children:l.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsx("h3",{className:"font-bold text-slate-800",children:k.name}),l.jsx("button",{onClick:()=>P(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:l.jsx(At,{size:18})})]}),l.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[n==="zh"?"状态":"Status",":"," ",k.state==="running"?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"]}),l.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[n==="zh"?"开始时间":"Started",":"," ",k.startedAt?new Date(k.startedAt).toLocaleString():"-"]}),L&&l.jsx("div",{className:"text-xs text-rose-600 mb-2",children:L}),l.jsxs("div",{className:"flex gap-2",children:[k.state==="running"?l.jsxs("button",{disabled:z,onClick:D,className:"flex-1 flex items-center justify-center gap-1 bg-amber-500 hover:bg-amber-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[l.jsx(Gh,{size:14})," ",n==="zh"?"暂停":"Pause"]}):l.jsxs("button",{disabled:z,onClick:F,className:"flex-1 flex items-center justify-center gap-1 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[l.jsx(Qh,{size:14})," ",n==="zh"?"恢复":"Resume"]}),l.jsx("button",{disabled:z,onClick:R,className:"flex-1 flex items-center justify-center gap-1 bg-rose-600 hover:bg-rose-700 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:z?n==="zh"?"处理中…":"Working…":n==="zh"?"结束":"End"})]}),l.jsx("button",{onClick:j,className:"w-full mt-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg py-2 text-sm font-bold",children:n==="zh"?"进入课堂":"Enter Classroom"})]})})]})}const T=async k=>{m(B=>({...B,[k.id]:n==="zh"?"启动中…":"Starting…"}));try{const B=await Ox(k.id,{classroomId:s,role:e},t);m(y=>({...y,[k.id]:B.dispatched?n==="zh"?"已启动 ✓":"Started ✓":n==="zh"?"已通知 ✓":"Notified ✓"}))}catch(B){m(y=>({...y,[k.id]:B instanceof Error?B.message:String(B)}))}};if(a)return l.jsx("div",{style:Mn,children:n==="zh"?"加载活动中…":"Loading activities…"});if(u)return l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",n==="zh"?"活动中心":"Activity Center"]}),l.jsx("div",{style:{opacity:.7},children:u})]});const $=e==="teacher"?n==="zh"?"活动中心(教师)":"Activity Center":n==="zh"?"活动(学生)":"Activities";return i.length===0?l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",$]}),l.jsx("div",{style:{opacity:.7},children:n==="zh"?"暂无可用活动。":"No activities available."})]}):l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",$]}),N.map(([k,B])=>l.jsxs("div",{style:{marginBottom:10},children:[l.jsx("div",{style:{opacity:.6,fontSize:11,textTransform:"uppercase",marginBottom:4},children:k}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:B.map(y=>l.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[l.jsxs("div",{style:{fontWeight:600},children:[y.icon?`${y.icon} `:"▫️ ",y.name]}),y.description&&l.jsx("div",{style:{opacity:.7,fontSize:11,margin:"2px 0 6px"},children:y.description}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("button",{onClick:()=>T(y),style:{cursor:"pointer",background:e==="teacher"?"#2563eb":"#0ea5e9",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontSize:12},children:e==="teacher"?n==="zh"?"启动":"Start":n==="zh"?"参与":"Open"}),f[y.id]&&l.jsx("span",{style:{fontSize:11,opacity:.85},children:f[y.id]})]}),l.jsx("div",{style:{opacity:.5,fontSize:10,marginTop:4},children:y.provider==="official"?"official":y.provider})]},y.id))})]},k))]})},Bx=Object.freeze(Object.defineProperty({__proto__:null,ActivityWorkspaceWidget:Ml},Symbol.toStringTag,{value:"Module"}));let ca=!1;function $x(){if(ca)return;ca=!0;const e=()=>Ie(()=>Promise.resolve().then(()=>Bx),void 0).then(t=>({default:()=>l.jsx(Ml,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,ve.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}const ua="@openlearn/frontend:IFrontendAPI",da="@openlearn/frontend:ISocketService",ha="@openlearn/frontend:IUIService",fa="@openlearn/frontend:IStorageService",Vx="@openlearn/frontend:ISemesterGradeService";var pe=(e=>(e.INSTALLED="installed",e.ACTIVATING="activating",e.ACTIVE="active",e.DEACTIVATING="deactivating",e.INACTIVE="inactive",e.ERROR="error",e.UNINSTALLED="uninstalled",e))(pe||{});const Ux=p.lazy(()=>Ie(()=>import("./StudentView-3mCaDwFB.js"),[]).then(e=>({default:e.StudentView}))),Wx=p.lazy(()=>Ie(()=>import("./TeacherView-BVd_ZMFH.js"),[]).then(e=>({default:e.TeacherView})));function qx(e){const{activeRole:t}=e;return l.jsx(p.Suspense,{fallback:l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-slate-400 gap-3",children:[l.jsx(ui,{className:"w-8 h-8 animate-spin text-indigo-500"}),l.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?l.jsx(Ux,{...e}):l.jsx(Wx,{...e})})}const Ti=p.createContext({});function Ni(e){const t=p.useRef(null);return t.current===null&&(t.current=e()),t.current}const Hx=typeof window<"u",Dl=Hx?p.useLayoutEffect:p.useEffect,fs=p.createContext(null),Ii=p.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function pa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gx(...e){return t=>{let n=!1;const s=e.map(r=>{const i=pa(r,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<s.length;r++){const i=s[r];typeof i=="function"?i():pa(e[r],null)}}}}function Qx(...e){return p.useCallback(Gx(...e),e)}class Jx extends p.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(dr(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=dr(s)&&s.offsetWidth||0,i=dr(s)&&s.offsetHeight||0,o=getComputedStyle(n),a=this.props.sizeRef.current;a.height=parseFloat(o.height),a.width=parseFloat(o.width),a.top=n.offsetTop,a.left=n.offsetLeft,a.right=r-a.width-a.left,a.bottom=i-a.height-a.top,a.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Zx({children:e,isPresent:t,anchorX:n,anchorY:s,root:r,pop:i}){const o=p.useId(),a=p.useRef(null),c=p.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:u}=p.useContext(Ii),d=e.props?.ref??e?.ref,f=Qx(a,d);return p.useInsertionEffect(()=>{const{width:m,height:h,top:g,left:x,right:v,bottom:w,direction:I}=c.current;if(t||i===!1||!a.current||!m||!h)return;const S=I==="rtl",P=n==="left"?S?`right: ${v}`:`left: ${x}`:S?`left: ${x}`:`right: ${v}`,z=s==="bottom"?`bottom: ${w}`:`top: ${g}`;a.current.dataset.motionPopId=o;const E=document.createElement("style");u&&(E.nonce=u);const L=r??document.head;return L.appendChild(E),E.sheet&&E.sheet.insertRule(`
124
+ Draft a 300-word integration proposal based on today's whiteboard exercises.`}};async function zx(e="all"){const t=await fetch(`/api/activities?role=${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to load activities (${t.status})`);return(await t.json()).activities??[]}async function la(){const e=await fetch("/api/activities/running",{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load running activities (${e.status})`);return(await e.json()).activities??[]}async function Lx(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/finish`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to finish activity (${t.status})`)}}async function _x(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/pause`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to pause activity (${t.status})`)}}async function Rx(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to resume activity (${t.status})`)}}async function Ox(e,t,n){const s=await fetch(`/api/activities/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t??{},actorId:n})}),r=await s.json();if(!s.ok||r.ok===!1)throw new Error(r.error||`Failed to start activity (${s.status})`);return r}const Mn={padding:"12px",color:"#e2e8f0",fontSize:"13px"},Mx={HelpCircle:Xh,Vote:Kh,BarChart3:Yh,MessagesSquare:Zh,Users:$a,FileText:qa,Trophy:Jh,CheckCircle2:li,BookOpen:ai};function Dx({name:e,className:t}){const n=e&&Mx[e]||ci;return l.jsx(n,{size:18,className:t})}function Fx(e,t){if(!e)return t==="zh"?"进行中":"In progress";const n=Math.max(0,Math.floor((Date.now()-e)/1e3)),s=Math.floor(n/60),r=n%60;return t==="zh"?`${s} 分 ${r} 秒`:`${s}m ${r}s`}const Ml=({role:e,actorId:t,lang:n="en",classroomId:s,mode:r="launcher"})=>{const[i,o]=p.useState([]),[a,c]=p.useState(!0),[u,d]=p.useState(null),[f,m]=p.useState({}),[h,g]=p.useState([]),[x,v]=p.useState(!0),[w,I]=p.useState(null),[S,P]=p.useState(null),[z,E]=p.useState(!1),[L,_]=p.useState(null),M=ce(k=>k.setTeacherTab),N=p.useMemo(()=>{const k=new Map;for(const B of i){const y=B.category;k.has(y)||k.set(y,[]),k.get(y).push(B)}return Array.from(k.entries())},[i]);p.useEffect(()=>{if(r!=="launcher")return;let k=!1;return c(!0),zx(e).then(B=>{k||o(B)}).catch(B=>{k||d(B instanceof Error?B.message:String(B))}).finally(()=>{k||c(!1)}),()=>{k=!0}},[e,r]),p.useEffect(()=>{if(r!=="status")return;let k=!1;const B=async()=>{try{const te=await la();k||g(te)}catch(te){k||I(te instanceof Error?te.message:String(te))}finally{k||v(!1)}};B();const y=setInterval(B,5e3);return()=>{k=!0,clearInterval(y)}},[r]);const A=async k=>{if(S){E(!0),_(null);try{await k(S),g(await la())}catch(B){_(B instanceof Error?B.message:String(B))}finally{E(!1)}}},R=()=>A(Lx),D=()=>A(_x),F=()=>A(Rx),j=()=>{P(null),M("live_class")};if(r==="status"){if(x)return l.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(w||h.length===0)return null;const k=h.find(B=>B.id===S)||null;return l.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[l.jsx("span",{children:"🧩"}),l.jsx("span",{children:n==="zh"?"进行中的活动":"Activities in Progress"})]}),l.jsx("span",{className:"text-[10px] font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:h.length})]}),l.jsx("div",{className:"flex flex-col gap-2",children:h.map(B=>{const y=B.state==="running";return l.jsxs("button",{onClick:()=>P(B.id),className:"w-full flex items-center gap-3 text-left bg-slate-50 hover:bg-slate-100 border border-slate-200/70 rounded-xl p-3 transition-colors",children:[l.jsx(Dx,{name:B.icon,className:"text-indigo-600 shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"font-bold text-slate-800 truncate",children:B.name}),B.category&&l.jsx("div",{className:"text-[11px] text-slate-500 truncate",children:B.category})]}),l.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[l.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full ${y?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:y?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"}),l.jsxs("span",{className:"text-[10px] text-slate-400 flex items-center gap-1",children:[l.jsx(Hh,{size:10})," ",Fx(B.startedAt,n)]})]})]},B.id)})}),k&&l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>P(null),children:l.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsx("h3",{className:"font-bold text-slate-800",children:k.name}),l.jsx("button",{onClick:()=>P(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:l.jsx(At,{size:18})})]}),l.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[n==="zh"?"状态":"Status",":"," ",k.state==="running"?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"]}),l.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[n==="zh"?"开始时间":"Started",":"," ",k.startedAt?new Date(k.startedAt).toLocaleString():"-"]}),L&&l.jsx("div",{className:"text-xs text-rose-600 mb-2",children:L}),l.jsxs("div",{className:"flex gap-2",children:[k.state==="running"?l.jsxs("button",{disabled:z,onClick:D,className:"flex-1 flex items-center justify-center gap-1 bg-amber-500 hover:bg-amber-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[l.jsx(Gh,{size:14})," ",n==="zh"?"暂停":"Pause"]}):l.jsxs("button",{disabled:z,onClick:F,className:"flex-1 flex items-center justify-center gap-1 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[l.jsx(Qh,{size:14})," ",n==="zh"?"恢复":"Resume"]}),l.jsx("button",{disabled:z,onClick:R,className:"flex-1 flex items-center justify-center gap-1 bg-rose-600 hover:bg-rose-700 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:z?n==="zh"?"处理中…":"Working…":n==="zh"?"结束":"End"})]}),l.jsx("button",{onClick:j,className:"w-full mt-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg py-2 text-sm font-bold",children:n==="zh"?"进入课堂":"Enter Classroom"})]})})]})}const T=async k=>{m(B=>({...B,[k.id]:n==="zh"?"启动中…":"Starting…"}));try{const B=await Ox(k.id,{classroomId:s,role:e},t);m(y=>({...y,[k.id]:B.dispatched?n==="zh"?"已启动 ✓":"Started ✓":n==="zh"?"已通知 ✓":"Notified ✓"}))}catch(B){m(y=>({...y,[k.id]:B instanceof Error?B.message:String(B)}))}};if(a)return l.jsx("div",{style:Mn,children:n==="zh"?"加载活动中…":"Loading activities…"});if(u)return l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",n==="zh"?"活动中心":"Activity Center"]}),l.jsx("div",{style:{opacity:.7},children:u})]});const $=e==="teacher"?n==="zh"?"活动中心(教师)":"Activity Center":n==="zh"?"活动(学生)":"Activities";return i.length===0?l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",$]}),l.jsx("div",{style:{opacity:.7},children:n==="zh"?"暂无可用活动。":"No activities available."})]}):l.jsxs("div",{style:Mn,children:[l.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",$]}),N.map(([k,B])=>l.jsxs("div",{style:{marginBottom:10},children:[l.jsx("div",{style:{opacity:.6,fontSize:11,textTransform:"uppercase",marginBottom:4},children:k}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:B.map(y=>l.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[l.jsxs("div",{style:{fontWeight:600},children:[y.icon?`${y.icon} `:"▫️ ",y.name]}),y.description&&l.jsx("div",{style:{opacity:.7,fontSize:11,margin:"2px 0 6px"},children:y.description}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("button",{onClick:()=>T(y),style:{cursor:"pointer",background:e==="teacher"?"#2563eb":"#0ea5e9",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontSize:12},children:e==="teacher"?n==="zh"?"启动":"Start":n==="zh"?"参与":"Open"}),f[y.id]&&l.jsx("span",{style:{fontSize:11,opacity:.85},children:f[y.id]})]}),l.jsx("div",{style:{opacity:.5,fontSize:10,marginTop:4},children:y.provider==="official"?"official":y.provider})]},y.id))})]},k))]})},Bx=Object.freeze(Object.defineProperty({__proto__:null,ActivityWorkspaceWidget:Ml},Symbol.toStringTag,{value:"Module"}));let ca=!1;function $x(){if(ca)return;ca=!0;const e=()=>Ie(()=>Promise.resolve().then(()=>Bx),void 0).then(t=>({default:()=>l.jsx(Ml,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,ve.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}const ua="@openlearn/frontend:IFrontendAPI",da="@openlearn/frontend:ISocketService",ha="@openlearn/frontend:IUIService",fa="@openlearn/frontend:IStorageService",Vx="@openlearn/frontend:ISemesterGradeService";var pe=(e=>(e.INSTALLED="installed",e.ACTIVATING="activating",e.ACTIVE="active",e.DEACTIVATING="deactivating",e.INACTIVE="inactive",e.ERROR="error",e.UNINSTALLED="uninstalled",e))(pe||{});const Ux=p.lazy(()=>Ie(()=>import("./StudentView-BSfVCBSV.js"),[]).then(e=>({default:e.StudentView}))),Wx=p.lazy(()=>Ie(()=>import("./TeacherView-B7FWfCWx.js"),[]).then(e=>({default:e.TeacherView})));function qx(e){const{activeRole:t}=e;return l.jsx(p.Suspense,{fallback:l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-slate-400 gap-3",children:[l.jsx(ui,{className:"w-8 h-8 animate-spin text-indigo-500"}),l.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?l.jsx(Ux,{...e}):l.jsx(Wx,{...e})})}const Ti=p.createContext({});function Ni(e){const t=p.useRef(null);return t.current===null&&(t.current=e()),t.current}const Hx=typeof window<"u",Dl=Hx?p.useLayoutEffect:p.useEffect,fs=p.createContext(null),Ii=p.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function pa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gx(...e){return t=>{let n=!1;const s=e.map(r=>{const i=pa(r,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<s.length;r++){const i=s[r];typeof i=="function"?i():pa(e[r],null)}}}}function Qx(...e){return p.useCallback(Gx(...e),e)}class Jx extends p.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(dr(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=dr(s)&&s.offsetWidth||0,i=dr(s)&&s.offsetHeight||0,o=getComputedStyle(n),a=this.props.sizeRef.current;a.height=parseFloat(o.height),a.width=parseFloat(o.width),a.top=n.offsetTop,a.left=n.offsetLeft,a.right=r-a.width-a.left,a.bottom=i-a.height-a.top,a.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Zx({children:e,isPresent:t,anchorX:n,anchorY:s,root:r,pop:i}){const o=p.useId(),a=p.useRef(null),c=p.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:u}=p.useContext(Ii),d=e.props?.ref??e?.ref,f=Qx(a,d);return p.useInsertionEffect(()=>{const{width:m,height:h,top:g,left:x,right:v,bottom:w,direction:I}=c.current;if(t||i===!1||!a.current||!m||!h)return;const S=I==="rtl",P=n==="left"?S?`right: ${v}`:`left: ${x}`:S?`left: ${x}`:`right: ${v}`,z=s==="bottom"?`bottom: ${w}`:`top: ${g}`;a.current.dataset.motionPopId=o;const E=document.createElement("style");u&&(E.nonce=u);const L=r??document.head;return L.appendChild(E),E.sheet&&E.sheet.insertRule(`
125
125
  [data-motion-pop-id="${o}"] {
126
126
  position: absolute !important;
127
127
  width: ${m}px !important;
@@ -129,7 +129,7 @@ Draft a 300-word integration proposal based on today's whiteboard exercises.`}};
129
129
  ${P}px !important;
130
130
  ${z}px !important;
131
131
  }
132
- `),()=>{a.current?.removeAttribute("data-motion-pop-id"),L.contains(E)&&L.removeChild(E)}},[t]),l.jsx(Jx,{isPresent:t,childRef:a,sizeRef:c,pop:i,children:i===!1?e:p.cloneElement(e,{ref:f})})}const Yx=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:o,anchorX:a,anchorY:c,root:u})=>{const d=Ni(Kx),f=p.useId();let m=!0,h=p.useMemo(()=>(m=!1,{id:f,initial:t,isPresent:n,custom:r,onExitComplete:g=>{d.set(g,!0);for(const x of d.values())if(!x)return;s&&s()},register:g=>(d.set(g,!1),()=>d.delete(g))}),[n,d,s]);return i&&m&&(h={...h}),p.useMemo(()=>{d.forEach((g,x)=>d.set(x,!1))},[n]),p.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=l.jsx(Zx,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:c,root:u,children:e}),l.jsx(fs.Provider,{value:h,children:e})};function Kx(){return new Map}function Fl(e=!0){const t=p.useContext(fs);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,i=p.useId();p.useEffect(()=>{if(e)return r(i)},[e]);const o=p.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,o]:[!0]}const Dn=e=>e.key||"";function ma(e){const t=[];return p.Children.forEach(e,n=>{p.isValidElement(n)&&t.push(n)}),t}const Xx=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:o=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[d,f]=Fl(o),m=p.useMemo(()=>ma(e),[e]),h=o&&!d?[]:m.map(Dn),g=p.useRef(!0),x=p.useRef(m),v=Ni(()=>new Map),w=p.useRef(new Set),[I,S]=p.useState(m),[P,z]=p.useState(m);Dl(()=>{g.current=!1,x.current=m;for(let _=0;_<P.length;_++){const M=Dn(P[_]);h.includes(M)?(v.delete(M),w.current.delete(M)):v.get(M)!==!0&&v.set(M,!1)}},[P,h.length,h.join("-")]);const E=[];if(m!==I){let _=[...m];for(let M=0;M<P.length;M++){const N=P[M],A=Dn(N);h.includes(A)||(_.splice(M,0,N),E.push(N))}return i==="wait"&&E.length&&(_=E),z(ma(_)),S(m),null}const{forceRender:L}=p.useContext(Ti);return l.jsx(l.Fragment,{children:P.map(_=>{const M=Dn(_),N=o&&!d?!1:m===P||h.includes(M),A=()=>{if(w.current.has(M))return;if(v.has(M))w.current.add(M),v.set(M,!0);else return;let R=!0;v.forEach(D=>{D||(R=!1)}),R&&(L?.(),z(x.current),o&&f?.(),s&&s())};return l.jsx(Yx,{isPresent:N,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:i,root:u,onExitComplete:N?void 0:A,anchorX:a,anchorY:c,children:_},M)})})},Bl=p.createContext({strict:!1}),ga={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 ya=!1;function eb(){if(ya)return;const e={};for(const t in ga)e[t]={isEnabled:n=>ga[t].some(s=>!!n[s])};Ga(e),ya=!0}function $l(){return eb(),cf()}function tb(e){const t=$l();for(const n in e)t[n]={...t[n],...e[n]};Ga(t)}const nb=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 as(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||nb.has(e)}let Vl=e=>!as(e);function sb(e){typeof e=="function"&&(Vl=t=>t.startsWith("on")?!as(t):e(t))}try{sb(require("@emotion/is-prop-valid").default)}catch{}function rb(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||di(e[r])||(Vl(r)||n===!0&&as(r)||!t&&!as(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const ps=p.createContext({});function ib(e,t){if(Qa(e)){const{initial:n,animate:s}=e;return{initial:n===!1||mo(n)?n:void 0,animate:mo(s)?s:void 0}}return e.inherit!==!1?t:{}}function ob(e){const{initial:t,animate:n}=ib(e,p.useContext(ps));return p.useMemo(()=>({initial:t,animate:n}),[xa(t),xa(n)])}function xa(e){return Array.isArray(e)?e.join(" "):e}const ji=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ul(e,t,n){for(const s in t)!di(t[s])&&!uf(s,n)&&(e[s]=t[s])}function ab({transformTemplate:e},t){return p.useMemo(()=>{const n=ji();return df(n,t,e),Object.assign({},n.vars,n.style)},[t])}function lb(e,t){const n=e.style||{},s={};return Ul(s,n,e),Object.assign(s,ab(e,t)),s}function cb(e,t){const n={},s=lb(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 Wl=()=>({...ji(),attrs:{}});function ub(e,t,n,s){const r=p.useMemo(()=>{const i=Wl();return hf(i,t,ff(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Ul(i,e.style,e),r.style={...i,...r.style}}return r}const db=["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 Ai(e){return typeof e!="string"||e.includes("-")?!1:!!(db.indexOf(e)>-1||/[A-Z]/u.test(e))}function hb(e,t,n,{latestValues:s},r,i=!1,o){const c=(o??Ai(e)?ub:cb)(t,s,r,e),u=rb(t,typeof e=="string",i),d=e!==p.Fragment?{...u,...c,ref:n}:{},{children:f}=t,m=p.useMemo(()=>di(f)?f.get():f,[f]);return p.createElement(e,{...d,children:m})}function fb({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:pb(n,s,r,e),renderState:t()}}function pb(e,t,n,s){const r={},i=s(e,{});for(const m in i)r[m]=pf(i[m]);let{initial:o,animate:a}=e;const c=Qa(e),u=mf(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const f=d?a:o;if(f&&typeof f!="boolean"&&!Ja(f)){const m=Array.isArray(f)?f:[f];for(let h=0;h<m.length;h++){const g=gf(e,m[h]);if(g){const{transitionEnd:x,transition:v,...w}=g;for(const I in w){let S=w[I];if(Array.isArray(S)){const P=d?S.length-1:0;S=S[P]}S!==null&&(r[I]=S)}for(const I in x)r[I]=x[I]}}}return r}const ql=e=>(t,n)=>{const s=p.useContext(ps),r=p.useContext(fs),i=()=>fb(e,t,s,r);return n?i():Ni(i)},mb=ql({scrapeMotionValuesFromProps:yf,createRenderState:ji}),gb=ql({scrapeMotionValuesFromProps:xf,createRenderState:Wl}),yb=Symbol.for("motionComponentSymbol");function xb(e,t,n){const s=p.useRef(n);p.useInsertionEffect(()=>{s.current=n});const r=p.useRef(null);return p.useCallback(i=>{i&&e.onMount?.(i),t&&(i?t.mount(i):t.unmount());const o=s.current;if(typeof o=="function")if(i){const a=o(i);typeof a=="function"&&(r.current=a)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[t])}const Hl=p.createContext({});function Ut(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function bb(e,t,n,s,r,i){const{visualElement:o}=p.useContext(ps),a=p.useContext(Bl),c=p.useContext(fs),u=p.useContext(Ii),d=u.reducedMotion,f=u.skipAnimations,m=p.useRef(null),h=p.useRef(!1);s=s||a.renderer,!m.current&&s&&(m.current=s(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:d,skipAnimations:f,isSVG:i}),h.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const g=m.current,x=p.useContext(Hl);g&&!g.projection&&r&&(g.type==="html"||g.type==="svg")&&wb(m.current,n,r,x);const v=p.useRef(!1);p.useInsertionEffect(()=>{g&&v.current&&g.update(n,c)});const w=n[bf],I=p.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Dl(()=>{h.current=!0,g&&(v.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),I.current&&g.animationState&&g.animationState.animateChanges())}),p.useEffect(()=>{g&&(!I.current&&g.animationState&&g.animationState.animateChanges(),I.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),I.current=!1),g.enteringChildren=void 0)}),g}function wb(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutAnchor:d,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Gl(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||a&&Ut(a),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:d})}function Gl(e){if(e)return e.options.allowProjection!==!1?e.projection:Gl(e.parent)}function Ir(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&tb(s);const i=n?n==="svg":Ai(e),o=i?gb:mb;function a(u,d){let f;const m={...p.useContext(Ii),...u,layoutId:Sb(u)},{isStatic:h}=m,g=ob(u),x=o(u,h);if(!h&&typeof window<"u"){vb();const v=Cb(m);f=v.MeasureLayout,g.visualElement=bb(e,x,m,r,v.ProjectionNode,i)}return l.jsxs(ps.Provider,{value:g,children:[f&&g.visualElement?l.jsx(f,{visualElement:g.visualElement,...m}):null,hb(e,u,xb(x,g.visualElement,d),x,h,t,i)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=p.forwardRef(a);return c[yb]=e,c}function Sb({layoutId:e}){const t=p.useContext(Ti).id;return t&&e!==void 0?t+"-"+e:e}function vb(e,t){p.useContext(Bl).strict}function Cb(e){const t=$l(),{drag:n,layout:s}=t;if(!n&&!s)return{};const r={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function kb(e,t){if(typeof Proxy>"u")return Ir;const n=new Map,s=(i,o)=>Ir(i,o,e,t),r=(i,o)=>s(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?s:(n.has(o)||n.set(o,Ir(o,void 0,e,t)),n.get(o))})}const Eb=(e,t)=>t.isSVG??Ai(e)?new wf(t):new Sf(t,{allowProjection:e!==p.Fragment});class Pb extends vt{constructor(t){super(t),t.animationState||(t.animationState=vf(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ja(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 Tb=0;class Nb extends vt{constructor(){super(...arguments),this.id=Tb++,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:i,custom:o}=this.node.getProps();if(typeof i=="string"||typeof i=="object"&&i!==null&&!Array.isArray(i)){const a=Cf(this.node,i,o);if(a){const{transition:c,transitionEnd:u,...d}=a;for(const f in d)this.node.getValue(f)?.jump(d[f])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.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 Ib={animation:{Feature:Pb},exit:{Feature:Nb}};function wn(e){return{point:{x:e.pageX,y:e.pageY}}}const jb=e=>t=>Za(t)&&e(t,wn(t));function mn(e,t,n,s){return ns(e,t,jb(n),s)}const Ql=({current:e})=>e?e.ownerDocument.defaultView:null,ba=(e,t)=>Math.abs(e-t);function Ab(e,t){const n=ba(e.x,t.x),s=ba(e.y,t.y);return Math.sqrt(n**2+s**2)}const wa=new Set(["auto","scroll"]);class Jl{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:a}={}){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=Fn(this.lastRawMoveEventInfo,this.transformPagePoint));const h=jr(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Ab(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=h,{timestamp:w}=go;this.history.push({...v,timestamp:w});const{onStart:I,onMove:S}=this.handlers;g||(I&&I(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,h)},this.handlePointerMove=(h,g)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=Fn(g,this.transformPagePoint),Xe.update(this.updatePoint,!0)},this.handlePointerUp=(h,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const I=jr(h.type==="pointercancel"?this.lastMoveEventInfo:Fn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(h,I),v&&v(h,I)},!Za(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const c=wn(t),u=Fn(c,this.transformPagePoint),{point:d}=u,{timestamp:f}=go;this.history=[{...d,timestamp:f}];const{onSessionStart:m}=n;m&&m(t,jr(u,this.history)),this.removeListeners=Ya(mn(this.contextWindow,"pointermove",this.handlePointerMove),mn(this.contextWindow,"pointerup",this.handlePointerUp),mn(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(wa.has(s.overflowX)||wa.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,r=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,r),Xe.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),kf(this.updatePoint)}}function Fn(e,t){return t?{point:t(e.point)}:e}function Sa(e,t){return{x:e.x-t.x,y:e.y-t.y}}function jr({point:e},t){return{point:e,delta:Sa(e,Zl(t)),offset:Sa(e,zb(t)),velocity:Lb(t,.1)}}function zb(e){return e[0]}function Zl(e){return e[e.length-1]}function Lb(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Zl(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>yo(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>yo(t)*2&&(s=e[1]);const i=Ef(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function _b(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?ss(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?ss(n,e,s.max):Math.min(e,n)),e}function va(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 Rb(e,{top:t,left:n,bottom:s,right:r}){return{x:va(e.x,n,r),y:va(e.y,t,s)}}function Ca(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 Ob(e,t){return{x:Ca(e.x,t.x),y:Ca(e.y,t.y)}}function Mb(e,t){let n=.5;const s=$r(e),r=$r(t);return r>s?n=xo(t.min,t.max-s,e.min):s>r&&(n=xo(e.min,e.max-r,t.min)),Pf(0,1,n)}function Db(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 Kr=.35;function Fb(e=Kr){return e===!1?e=0:e===!0&&(e=Kr),{x:ka(e,"left","right"),y:ka(e,"top","bottom")}}function ka(e,t,n){return{min:Ea(e,t),max:Ea(e,n)}}function Ea(e,t){return typeof e=="number"?e:e[t]||0}const Bb=new WeakMap;class $b{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=Tf(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=f=>{n&&this.snapToCursor(wn(f).point),this.stopAnimation()},o=(f,m)=>{const{drag:h,dragPropagation:g,onDragStart:x}=this.getProps();if(h&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=zf(h),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bt(w=>{let I=this.getAxisMotionValue(w).get()||0;if(Lf.test(I)){const{projection:S}=this.visualElement;if(S&&S.layout){const P=S.layout.layoutBox[w];P&&(I=$r(P)*(parseFloat(I)/100))}}this.originPoint[w]=I}),x&&Xe.update(()=>x(f,m),!1,!0),bo(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},a=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m;const{dragPropagation:h,dragDirectionLock:g,onDirectionLock:x,onDrag:v}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=m;if(g&&this.currentDirection===null){this.currentDirection=Ub(w),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),v&&Xe.update(()=>v(f,m),!1,!0)},c=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m,this.stop(f,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Jl(t,{onSessionStart:i,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ql(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&Xe.postRender(()=>a(s,r))}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:r}=this.getProps();if(!s||!Bn(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=_b(o,this.constraints[t],this.elastic[t])),i.set(o)}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,r=this.constraints;t&&Ut(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Rb(s.layoutBox,t):this.constraints=!1,this.elastic=Fb(n),r!==this.constraints&&!Ut(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&bt(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=Db(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ut(t))return!1;const s=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const i=Nf(s,r.root,this.visualElement.getTransformPagePoint());let o=Ob(r.layout.layoutBox,i);if(n){const a=n(If(o));this.hasMutatedConstraints=!!a,a&&(o=jf(a))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=bt(d=>{if(!Bn(d,n,this.currentDirection))return;let f=c&&c[d]||{};(o===!0||o===d)&&(f={min:0,max:0});const m=r?200:1e6,h=r?40:1e7,g={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...i,...f};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return bo(this.visualElement,t),s.start(Af(t,s,0,n,this.visualElement,!1))}stopAnimation(){bt(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps()[n];return r||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){bt(n=>{const{drag:s}=this.getProps();if(!Bn(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:a}=r.layout.layoutBox[n],c=i.get()||0;i.set(t[n]-ss(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Ut(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};bt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();r[o]=Mb({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),bt(o=>{if(!Bn(o,t,null))return;const a=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];a.set(ss(c,u,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Bb.set(this.visualElement,this);const t=this.visualElement.current,n=mn(t,"pointerdown",u=>{const{drag:d,dragListener:f=!0}=this.getProps(),m=u.target,h=m!==t&&_f(m);d&&f&&!h&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Ut(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Vb(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Xe.read(r);const a=ns(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:d})=>{this.isDragging&&d&&(bt(f=>{const m=this.getAxisMotionValue(f);m&&(this.originPoint[f]+=u[f].translate,m.set(m.get()+u[f].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),c&&c(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=Kr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:a}}}function Pa(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Vb(e,t,n){const s=wo(e,Pa(n)),r=wo(t,Pa(n));return()=>{s(),r()}}function Bn(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ub(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Wb extends vt{constructor(t){super(t),this.removeGroupControls=Hn,this.removeListeners=Hn,this.controls=new $b(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hn}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 Ar=e=>(t,n)=>{e&&Xe.update(()=>e(t,n),!1,!0)};class qb extends vt{constructor(){super(...arguments),this.removePointerDownListener=Hn}onPointerDown(t){this.session=new Jl(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ql(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Ar(t),onStart:Ar(n),onMove:Ar(s),onEnd:(i,o)=>{delete this.session,r&&Xe.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=mn(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 zr=!1;class Hb extends p.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&r&&s.register(i),zr&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Of.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:i}=this.props,{projection:o}=s;return o&&(o.isPresent=i,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),zr=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||Xe.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Rf.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;zr=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Yl(e){const[t,n]=Fl(),s=p.useContext(Ti);return l.jsx(Hb,{...e,layoutGroup:s,switchLayoutGroup:p.useContext(Hl),isPresent:t,safeToRemove:n})}const Gb={pan:{Feature:qb},drag:{Feature:Wb,ProjectionNode:Ka,MeasureLayout:Yl}};function Ta(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=s[r];i&&Xe.postRender(()=>i(t,wn(t)))}class Qb extends vt{mount(){const{current:t}=this.node;t&&(this.unmount=Mf(t,(n,s)=>(Ta(this.node,s,"Start"),r=>Ta(this.node,r,"End"))))}unmount(){}}class Jb extends vt{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=Ya(ns(this.node.current,"focus",()=>this.onFocus()),ns(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Na(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 r="onTap"+(n==="End"?"":n),i=s[r];i&&Xe.postRender(()=>i(t,wn(t)))}class Zb extends vt{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Df(t,(r,i)=>(Na(this.node,i,"Start"),(o,{success:a})=>Na(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Xr=new WeakMap,Lr=new WeakMap,Yb=e=>{const t=Xr.get(e.target);t&&t(e)},Kb=e=>{e.forEach(Yb)};function Xb({root:e,...t}){const n=e||document;Lr.has(n)||Lr.set(n,{});const s=Lr.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Kb,{root:e,...t})),s[r]}function ew(e,t,n){const s=Xb(t);return Xr.set(e,n),s.observe(e),()=>{Xr.delete(e),s.unobserve(e)}}const tw={some:0,all:1};class nw extends vt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:tw[r]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),m=u?d:f;m&&m(c)};this.stopObserver=ew(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(sw(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function sw({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const rw={inView:{Feature:nw},tap:{Feature:Zb},focus:{Feature:Jb},hover:{Feature:Qb}},iw={layout:{ProjectionNode:Ka,MeasureLayout:Yl}},ow={...Ib,...rw,...Gb,...iw},aw=kb(ow,Eb);function lw(){const e=ce(t=>t.toasts);return l.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:l.jsx(Xx,{children:e.map(t=>l.jsxs(aw.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 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 border-l-4 border-emerald-500 overflow-hidden",id:`toast-${t.id}`,children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"p-1 rounded-full bg-emerald-50 text-emerald-600",children:l.jsx(ef,{size:16})}),l.jsx("p",{className:"font-semibold text-gray-900 text-sm font-sans",children:t.title})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-2 leading-relaxed font-sans",children:t.message})]}),l.jsx("button",{type:"button",onClick:()=>Ce.getState().removeToast(t.id),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:l.jsx(At,{size:14})})]},t.id))})})}function cw({showRightSidebar:e,setShowRightSidebar:t,rightSidebarTab:n,setRightSidebarTab:s,effectiveAgentProviderId:r,agentProviderId:i,setAgentProviderId:o,aiProviders:a,selectedAgentProvider:c,chatLog:u,loading:d,input:f,setInput:m,handleSend:h,chatAttachments:g,setChatAttachments:x,handleChatFileChange:v,handleChatDrop:w,onClearAgentMemory:I,events:S,lang:P,t:z}){const E=p.useRef(null);return p.useEffect(()=>{E.current?.scrollIntoView({behavior:"smooth"})},[u]),l.jsx("div",{className:`transition-all duration-300 bg-white border-l border-gray-200 flex flex-col shadow-xl relative z-30 shrink-0 ${e?"w-96":"w-12 items-center cursor-pointer hover:bg-gray-50"}`,children:e?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[l.jsxs("button",{onClick:()=>s("agent"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="agent"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[l.jsx(ur,{size:14})," Agent"]}),l.jsxs("button",{onClick:()=>s("shell"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="shell"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[l.jsx(qn,{size:14})," Shell"]}),l.jsx("button",{onClick:()=>t(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:l.jsx(tf,{size:14})})]}),n==="agent"?l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:l.jsx(ur,{size:16})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:z.agentTitle}),l.jsx("p",{className:"text-[10px] text-gray-500",children:z.agentSubtitle}),l.jsxs("button",{onClick:I,title:P==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-[10px] text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",P==="zh"?"清除记忆":"Clear memory"]})]})]}),l.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400",children:P==="zh"?"AI 提供商":"AI Provider"}),l.jsxs("div",{className:"relative w-full",children:[l.jsxs("select",{value:r,onChange:L=>o(L.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-[11px] font-medium text-gray-700 shadow-sm outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:[l.jsx("option",{value:"system",children:P==="zh"?"系统默认(Gemini)":"System Default (Gemini)"}),a.map(L=>l.jsx("option",{value:L.id,children:L.name},L.id))]}),l.jsx(Va,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),l.jsx("div",{className:"text-[10px] text-gray-400 truncate w-full text-right",title:r==="system"?P==="zh"?"使用内置 Gemini 系统模型":"Using the built-in Gemini system model":c?.model_name||"",children:r==="system"?P==="zh"?"内置系统模型":"Built-in system model":`${c?.name||(P==="zh"?"已选提供商":"Selected provider")}`})]})]})}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u.map((L,_)=>l.jsx("div",{className:`flex flex-col ${L.role==="user"?"items-end":"items-start"}`,children:l.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${L.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:L.content})},_)),d&&l.jsx("div",{className:"flex items-start",children:l.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:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),l.jsx("div",{ref:E})]}),l.jsxs("form",{onSubmit:h,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:L=>L.preventDefault(),onDrop:w,children:[g.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:g.map((L,_)=>l.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-[10px]",children:[l.jsx(qa,{size:10,className:"shrink-0"}),l.jsx("span",{className:"truncate max-w-[100px]",title:L.name,children:L.name}),l.jsx("button",{type:"button",onClick:()=>x(M=>M.filter((N,A)=>A!==_)),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:l.jsx(At,{size:10})})]},_))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.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:[l.jsx(nf,{size:14}),l.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:v,accept:".csv,.txt,.json,.md"})]}),l.jsxs("div",{className:"relative flex-1",children:[l.jsx("input",{type:"text",value:f,onChange:L=>m(L.target.value),placeholder:z.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"}),l.jsx("button",{type:"submit",disabled:d||!f.trim(),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",children:l.jsx(sf,{size:10})})]})]})]})]}):l.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-[10px] min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[l.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:l.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[l.jsx(qn,{size:14}),l.jsx("span",{className:"text-xs",children:z.eventStream})]})}),l.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:S.length===0?l.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):S.map((L,_)=>l.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[l.jsxs("span",{className:"text-gray-500 shrink-0 text-[9px]",children:["[",new Date(L.timestamp).toLocaleTimeString(),"]"]}),l.jsx("span",{className:"text-blue-400 shrink-0 truncate text-[9px]",title:L.source,children:L.source})]}),l.jsx("div",{className:"text-green-300 font-bold",children:L.type}),l.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:L.payload})]},_))})]})]}):l.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-gray-400 w-full",onClick:()=>t(!0),children:[l.jsx(ur,{size:18,className:"mb-6 hover:text-indigo-500"}),l.jsx(qn,{size:18,className:"hover:text-indigo-500"}),l.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:l.jsx("div",{className:"uppercase tracking-widest text-[9px] rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const uw=p.lazy(()=>Ie(()=>import("./ImportModal-BTfia0Ah.js"),[]).then(e=>({default:e.ImportModal}))),dw=p.lazy(()=>Ie(()=>import("./CourseWizardModal-RAaltA_q.js"),[]).then(e=>({default:e.CourseWizardModal}))),hw=p.lazy(()=>Ie(()=>import("./ImportLessonsModal-DHLxg68P.js"),[]).then(e=>({default:e.ImportLessonsModal}))),fw=p.lazy(()=>Ie(()=>import("./QuizGeneratorModal-CoeGXKck.js"),[]).then(e=>({default:e.QuizGeneratorModal}))),pw=p.lazy(()=>Ie(()=>import("./StudentPreviewModal-DwumAjWX.js"),[]).then(e=>({default:e.StudentPreviewModal}))),mw=p.lazy(()=>Ie(()=>import("./ProcessLogsModal-01S7zsw0.js"),[]).then(e=>({default:e.ProcessLogsModal}))),gw=p.lazy(()=>Ie(()=>import("./CloudDriveModal-DXJktxoq.js"),[]).then(e=>({default:e.CloudDriveModal}))),yw=p.lazy(()=>Ie(()=>import("./SystemResourceLibraryModal-B6ms798K.js"),[]).then(e=>({default:e.SystemResourceLibraryModal}))),xw=p.lazy(()=>Ie(()=>import("./BatchPickerModal-2jsnyMYM.js"),[]).then(e=>({default:e.BatchPickerModal}))),bw=p.lazy(()=>Ie(()=>import("./ExportWeightModal-BwW76Kqo.js"),[]).then(e=>({default:e.ExportWeightModal}))),ww=p.lazy(()=>Ie(()=>import("./NotificationDetailModal-CPrHxHcC.js"),[]).then(e=>({default:e.NotificationDetailModal}))),Sw=p.lazy(()=>Ie(()=>import("./HelpTour-CHPIK2ae.js"),[]).then(e=>({default:e.HelpTour}))),vw=p.lazy(()=>Ie(()=>import("./CoursewareHubPanel-LpUgjqbH.js"),[]).then(e=>({default:e.CoursewareHubPanel})));function Cw(e){const{lang:t,t:n,showImportModal:s=!1,setShowImportModal:r=()=>{},handleImportFile:i=()=>{},importError:o=null,importSuccess:a=null,isImporting:c=!1,downloadCSVTemplate:u=()=>{},addToast:d=()=>{},generateTemplateContent:f=()=>"",isImportLessonsOpen:m=!1,setIsImportLessonsOpen:h=()=>{},importStatus:g="idle",setIsDraggingImport:x=()=>{},handleCSVFileChange:v=()=>{},downloadCsvTemplate:w=()=>{},isDraggingImport:I=!1,previewImportData:S=[],setPreviewImportData:P=()=>{},setImportStatus:z=()=>{},importProgress:E=0,importProgressTotal:L=0,importErrorMsg:_="",setImportErrorMsg:M=()=>{},handleCSVImportSubmit:N=()=>{},lessons:A=[],fetchClassDashboard:R=()=>{},isLessonPreviewVisible:D=!1,setIsLessonPreviewVisible:F=()=>{},selectedLesson:j=null,previewFullscreenPanel:T="none",setPreviewFullscreenPanel:$=()=>{},previewLessonTab:k="whiteboard",setPreviewLessonTab:B=()=>{},activeRole:y="teacher",elements:te=[],activeSegmentId:ae=null,setActiveSegmentId:b=()=>{},fetchElements:q=()=>{},currentVfsParent:ee=null,setCurrentVfsParent:se=()=>{},vfsNodes:fe=[],previewSelectedCourseware:ge=null,setPreviewSelectedCourseware:ze=()=>{},showProcessLogs:je=null,setShowProcessLogs:he=()=>{},processLogsContent:ft="",isCloudDriveOpen:Lt=!1,setIsCloudDriveOpen:_t=()=>{},cloudDrivePreviewNode:pt=null,setCloudDrivePreviewNode:mt=()=>{},isSystemResourceLibraryOpen:G=!1,setIsSystemResourceLibraryOpen:K=()=>{},systemResourceTab:re="system",setSystemResourceTab:we=()=>{},selectedLibraryResourceId:qe=null,setSelectedLibraryResourceId:de=()=>{},loadingLibraryResources:Te=!1,libraryResources:ke=[],fetchLibraryResources:Ze=()=>{},classes:O=[],expandedClassId:W=null,isExportWeightModalOpen:Q=!1,setIsExportWeightModalOpen:Z=()=>{},quizzesWeight:ie=40,setQuizzesWeight:Ne=()=>{},assignmentsWeight:Ye=60,setAssignmentsWeight:Le=()=>{},handleQuizzesWeightChange:lt=()=>{},handleAssignmentsWeightChange:_e=()=>{},customCategoryOverrides:ye={},setCustomCategoryOverrides:He=()=>{},classDashboardMap:Fe={},exportClassId:ys="",exportClassName:xs="",csvPreviewData:bs=null,handleExportGrades:ws=()=>{},setSelectedAssignment:Ss=()=>{},setStudentViewStatus:vs=()=>{},setQuizStudentAnswers:Cs=()=>{},setSubAssignmentTab:Sn=()=>{},isTourOpen:ks=!1,setIsTourOpen:Es=()=>{},handleSeedSuccess:Ps=()=>{},setTeacherTab:Jt=()=>{},showCoursewareHub:Zt=!1,setShowCoursewareHub:vn=()=>{}}=e,Ee=e.courseWizard,Rt=Ee?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Ts=Ee?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),tt=Ee?.wizardStep??e.wizardStep??1,Cn=Ee?.setWizardStep??e.setWizardStep??(()=>{}),Ns=Ee?.wizardIsSubmitting??e.wizardIsSubmitting??!1,kn=Ee?.wizardCourseTitle??e.wizardCourseTitle??"",Is=Ee?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),Ot=Ee?.wizardCourseDescription??e.wizardCourseDescription??"",js=Ee?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),En=Ee?.wizardCourseCategory??e.wizardCourseCategory??"",As=Ee?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),zs=Ee?.wizardCourseTimeline??e.wizardCourseTimeline??[],Ls=Ee?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),_s=Ee?.wizardCourseContent??e.wizardCourseContent??"",Rs=Ee?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),Os=Ee?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),me=e.quizGenerator,Ms=me?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,kt=me?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),Ds=me?.quizGenMode??e.quizGenMode??"scan_lesson",Fs=me?.setQuizGenMode??e.setQuizGenMode??(()=>{}),Bs=me?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",Pn=me?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),Tn=me?.quizGenTopic??e.quizGenTopic??"",$s=me?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Vs=me?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,Nn=me?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),Yt=me?.suggestedObjectives??e.suggestedObjectives??[],Kt=me?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),Us=me?.suggestedQuestions??e.suggestedQuestions??[],Ws=me?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),Se=me?.quizGenTimeLimit??e.quizGenTimeLimit??0,Et=me?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),In=me?.savingQuiz??e.savingQuiz??!1,jn=me?.setSavingQuiz??e.setSavingQuiz??(()=>{}),Be=me?.quizGeneratorClassId??e.quizGeneratorClassId??null,Re=e.classBatch,qs=Re?.batchPicker??e.batchPicker??null,Hs=Re?.setBatchPicker??e.setBatchPicker??(()=>{}),Gs=Re?.batchPickerLesson??e.batchPickerLesson??"",Mt=Re?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),Qs=Re?.batchPickerDate??e.batchPickerDate??"",Pt=Re?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),gt=Re?.batchPickerTargetClass??e.batchPickerTargetClass??"",$e=Re?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),Js=Re?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Dt=e.studentNotificationsHook,Zs=Dt?.selectedNotificationForModal??e.selectedNotificationForModal??null,Ys=Dt?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return l.jsxs(p.Suspense,{fallback:null,children:[l.jsx(uw,{show:s,onClose:()=>r(!1),lang:t,handleImportFile:i,importError:o,importSuccess:a,isImporting:c,downloadCSVTemplate:u}),l.jsx(dw,{isCourseWizardOpen:Rt,setIsCourseWizardOpen:Ts,lang:t,wizardStep:tt,setWizardStep:Cn,wizardIsSubmitting:Ns,wizardCourseTitle:kn,setWizardCourseTitle:Is,wizardCourseDescription:Ot,setWizardCourseDescription:js,wizardCourseCategory:En,setWizardCourseCategory:As,wizardCourseTimeline:zs,setWizardCourseTimeline:Ls,wizardCourseContent:_s,setWizardCourseContent:Rs,addToast:d,generateTemplateContent:f,handleDeployWizardCourse:Os}),l.jsx(hw,{isImportLessonsOpen:m,setIsImportLessonsOpen:h,lang:t,importStatus:g,setIsDraggingImport:x,handleCSVFileChange:v,downloadCsvTemplate:w,isDraggingImport:I,previewImportData:S,setPreviewImportData:P,setImportStatus:z,importProgress:E,importProgressTotal:L,importErrorMsg:_,setImportErrorMsg:M,handleCSVImportSubmit:N}),l.jsx(fw,{isQuizGeneratorOpen:Ms,setIsQuizGeneratorOpen:kt,lessons:A,quizGenMode:Ds,setQuizGenMode:Fs,quizGenSelectedLessonId:Bs,setQuizGenSelectedLessonId:Pn,quizGenTopic:Tn,setQuizGenTopic:$s,isGeneratingSuggestions:Vs,setIsGeneratingSuggestions:Nn,suggestedObjectives:Yt,setSuggestedObjectives:Kt,suggestedQuestions:Us,setSuggestedQuestions:Ws,quizGenTimeLimit:Se,setQuizGenTimeLimit:Et,savingQuiz:In,setSavingQuiz:jn,quizGeneratorClassId:Be,fetchClassDashboard:R}),l.jsx(pw,{isLessonPreviewVisible:D,setIsLessonPreviewVisible:F,lessons:A,selectedLesson:j,previewFullscreenPanel:T,setPreviewFullscreenPanel:$,previewLessonTab:k,setPreviewLessonTab:B,activeRole:y,elements:te,activeSegmentId:ae,setActiveSegmentId:b,fetchElements:q,currentVfsParent:ee,setCurrentVfsParent:se,vfsNodes:fe,previewSelectedCourseware:ge,setPreviewSelectedCourseware:ze}),l.jsx(mw,{showProcessLogs:je,setShowProcessLogs:he,processLogsContent:ft,t:n}),l.jsx(gw,{isOpen:Lt,onClose:()=>_t(!1),vfsNodes:fe,currentVfsParent:ee,setCurrentVfsParent:se,cloudDrivePreviewNode:pt,setCloudDrivePreviewNode:mt}),l.jsx(yw,{isSystemResourceLibraryOpen:G,setIsSystemResourceLibraryOpen:K,lang:t,systemResourceTab:re,setSystemResourceTab:we,selectedLibraryResourceId:qe,setSelectedLibraryResourceId:de,vfsNodes:fe,currentVfsParent:ee,setCurrentVfsParent:se,cloudDrivePreviewNode:pt,setCloudDrivePreviewNode:mt,loadingLibraryResources:Te,libraryResources:ke,fetchLibraryResources:Ze}),l.jsx(xw,{batchPicker:qs,setBatchPicker:Hs,batchPickerLesson:Gs,setBatchPickerLesson:Mt,batchPickerDate:Qs,setBatchPickerDate:Pt,batchPickerTargetClass:gt,setBatchPickerTargetClass:$e,lessons:A,classes:O,expandedClassId:W,confirmBatchPicker:Js,lang:t}),l.jsx(bw,{isExportWeightModalOpen:Q,setIsExportWeightModalOpen:Z,lang:t,quizzesWeight:ie,setQuizzesWeight:Ne,assignmentsWeight:Ye,setAssignmentsWeight:Le,handleQuizzesWeightChange:lt,handleAssignmentsWeightChange:_e,customCategoryOverrides:ye,setCustomCategoryOverrides:He,classDashboardMap:Fe,exportClassId:ys,exportClassName:xs,csvPreviewData:bs,handleExportGrades:ws}),l.jsx(ww,{notification:Zs,onClose:()=>Ys(null),lang:t,onOpenWorkspace:Xt=>{Ss(Xt),vs("assignment"),Cs({}),Sn("quiz")}}),l.jsx(Sw,{isOpen:ks,onClose:()=>Es(!1),lang:t,onSeedSuccess:Ps,onJumpTab:Xt=>Jt(Xt)}),Zt&&l.jsx(vw,{onClose:()=>vn(!1),lang:t})]})}const kw=["whiteboard.","courseware.","quiz.","rollcall."];class Ew{constructor(){this.handlers=new Map}setSocketBridge(t){this.socketBridge=t}hasSocketBridge(){return!!this.socketBridge}subscribe(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>{this.handlers.get(t)?.delete(n)}}async publish(t){const n=this.handlers.get(t.type);if(n)for(const s of n)try{s(t)}catch(r){console.error("[FrontendEventBus] handler error:",r)}this.socketBridge&&kw.some(s=>t.type.startsWith(s))&&this.socketBridge(t)}}const Pw=new Ew;async function Kl(e){const t=e.data;if(!t||typeof t!="object")return;if(typeof window<"u"&&typeof document<"u"&&e.source)try{if(!Array.from(document.querySelectorAll("iframe")).some(u=>u.contentWindow===e.source)&&e.source!==window)return}catch{}let n=t.attempt_id;const s=t.type||"",r=t.payload||t;if(!n&&e.source)try{const a=Array.from(document.querySelectorAll("iframe")).find(c=>c.contentWindow===e.source);if(a&&a.contentWindow){const c=a.contentWindow;c.__LMS_STUDENT__?.attempt_id&&(n=c.__LMS_STUDENT__.attempt_id)}}catch{}if(!n||typeof n!="string")return;if(s==="LMS_CONFIG"){$n("courseware.config_reported",n,t.config??r);return}if(s==="LMS_GET_PROGRESS"){const a=t.requestId,c=e.source;if(a&&c&&typeof c.postMessage=="function"){if(typeof document<"u"&&!Array.from(document.querySelectorAll("iframe")).some(h=>h.contentWindow===c)&&c!==window){console.warn("[LMS Bridge Security] Dropping response to untrusted window");return}let u;try{u=(await(await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/progress`)).json()).progress??null}catch{u=null}const d=e.origin&&e.origin!=="null"?e.origin:"*";c.postMessage({type:"LMS_PROGRESS_RESPONSE",requestId:a,progress:u},d)}return}const i=s==="LMS_SUBMIT"||s==="LMS_FINISH"||s==="submit"||s==="finish"||s==="completed"||r&&typeof r=="object"&&(r.score!==void 0||r.grade!==void 0||r.result!==void 0||r.points!==void 0),o=s==="LMS_SAVE_PROGRESS"||s==="saveProgress";if(i){$n("courseware.submitted",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??r?.note??void 0,completion:r?.completion??1,status:"submitted",extra:r})})}catch(a){console.error("[LMS Bridge] Failed to submit attempt data to backend:",a)}}else if(o){$n("courseware.progress_saved",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??void 0,completion:r?.completion??void 0,status:"inprogress",extra:r})})}catch(a){console.error("[LMS Bridge] Failed to save progress to backend:",a)}}else{$n("courseware.event_logged",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventType:s||"log",payload:r})})}catch(a){console.error("[LMS Bridge] Failed to log event to backend:",a)}}}function $n(e,t,n){Pw.publish({id:Ff(),type:e,source:"courseware-bridge",payload:{attemptId:t,data:n},timestamp:Date.now(),correlationId:t})}function Tw(e,t,n,s){try{let r=s;if(!r&&e.src&&typeof window<"u")try{const i=new URL(e.src,window.location.href);i.origin&&i.origin!=="null"&&!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&(r=i.origin)}catch{}e.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:t,payload:n},r||"*")}catch{}}function Xl(e){p.useEffect(()=>{if(!e)return;const t=n=>{Kl(n)};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[e])}function ec(e,t={}){if(!(typeof document>"u"))try{document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"theme:changed",payload:{theme:e,tokens:t}},"*"),s.contentWindow?.postMessage({type:"LMS_THEME_CHANGED",theme:e,tokens:t},"*")}catch{}})}catch{}}const Nw=Object.freeze(Object.defineProperty({__proto__:null,broadcastThemeToIframes:ec,processLmsMessage:Kl,sendCommandToCourseware:Tw,useLmsBridge:Xl},Symbol.toStringTag,{value:"Module"}));function Iw(e){const{session:t,showProcessLogs:n,activeStudentId:s,currentVfsParent:r,selectedLesson:i,selectedAssignment:o,expandedClassId:a,fetchLessons:c,fetchPlugins:u,fetchRegisteredCommands:d,fetchEvents:f,fetchApprovals:m,fetchProcesses:h,fetchClasses:g,fetchTodaySchedules:x,fetchStudents:v,fetchLabs:w,fetchVfs:I,fetchProcessLogs:S,fetchClassStudents:P,fetchElements:z}=e,E=p.useRef(r),L=p.useRef(i),_=p.useRef(o),M=p.useRef(a);p.useEffect(()=>{E.current=r},[r]),p.useEffect(()=>{L.current=i},[i]),p.useEffect(()=>{_.current=o},[o]),p.useEffect(()=>{M.current=a},[a]),p.useEffect(()=>{if(!t)return;c(),u(),d(),f(),m(),h(),g(),x(),v(),w(),I(E.current);let N=!1;const A=setInterval(async()=>{if(!N){N=!0;try{if(await f(),await c(),await m(),await h(),await g(),await x().catch(()=>{}),await v(),await w(),await I(E.current),await d(),n&&await S(n),M.current&&await P(M.current),L.current&&await z(L.current),_.current){const R=s||_.current.student_id;await z(`assignment-${_.current.id}-student-${R}`)}}finally{N=!1}}},2e3);return()=>clearInterval(A)},[t,n,s]),p.useEffect(()=>{I(r)},[r]),p.useEffect(()=>{i&&z(i)},[i])}function jw(e){const{lang:t,t:n,selectedLesson:s,effectiveAgentProviderId:r,expandedClassId:i,fetchLessons:o,fetchClasses:a,fetchStudents:c,fetchClassStudents:u,fetchClassProgress:d,fetchClassDashboard:f,fetchElements:m}=e,[h,g]=p.useState([{role:"agent",content:n.agentIntro||""}]),[x,v]=p.useState(""),[w,I]=p.useState(!1),[S,P]=p.useState([]);p.useEffect(()=>{h.length===1&&h[0].role==="agent"&&g([{role:"agent",content:n.agentIntro}])},[t,n.agentIntro]);const z=p.useCallback(async N=>{try{const A=await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(N||"")}`);if(!A.ok)return;const R=await A.json(),D=Array.isArray(R.messages)?R.messages:[];D.length>0?g(D.map(F=>({role:F.role==="assistant"?"agent":"user",content:F.content}))):g([{role:"agent",content:n.agentIntro}])}catch{}},[n.agentIntro]),E=p.useCallback(async()=>{try{await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(s||"")}`,{method:"DELETE"})}catch{}g([{role:"agent",content:n.agentIntro}])},[s,n.agentIntro]);return p.useEffect(()=>{z(s)},[s,z]),{chatLog:h,setChatLog:g,input:x,setInput:v,loading:w,setLoading:I,chatAttachments:S,setChatAttachments:P,handleChatFileChange:N=>{N.target.files&&Array.from(N.target.files).forEach(A=>{const R=new FileReader;R.onload=D=>{D.target?.result&&P(F=>[...F,{name:A.name,content:D.target.result}])},A.name.endsWith(".zip")?R.readAsDataURL(A):R.readAsText(A)})},handleChatDrop:N=>{N.preventDefault(),N.dataTransfer.files&&Array.from(N.dataTransfer.files).forEach(A=>{const R=new FileReader;R.onload=D=>{D.target?.result&&P(F=>[...F,{name:A.name,content:D.target.result}])},A.name.endsWith(".zip")?R.readAsDataURL(A):R.readAsText(A)})},handleSend:async N=>{if(N.preventDefault(),!x.trim()||w)return;const A=[...S];let R=x;A.length>0&&(R+=`
132
+ `),()=>{a.current?.removeAttribute("data-motion-pop-id"),L.contains(E)&&L.removeChild(E)}},[t]),l.jsx(Jx,{isPresent:t,childRef:a,sizeRef:c,pop:i,children:i===!1?e:p.cloneElement(e,{ref:f})})}const Yx=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:o,anchorX:a,anchorY:c,root:u})=>{const d=Ni(Kx),f=p.useId();let m=!0,h=p.useMemo(()=>(m=!1,{id:f,initial:t,isPresent:n,custom:r,onExitComplete:g=>{d.set(g,!0);for(const x of d.values())if(!x)return;s&&s()},register:g=>(d.set(g,!1),()=>d.delete(g))}),[n,d,s]);return i&&m&&(h={...h}),p.useMemo(()=>{d.forEach((g,x)=>d.set(x,!1))},[n]),p.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=l.jsx(Zx,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:c,root:u,children:e}),l.jsx(fs.Provider,{value:h,children:e})};function Kx(){return new Map}function Fl(e=!0){const t=p.useContext(fs);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,i=p.useId();p.useEffect(()=>{if(e)return r(i)},[e]);const o=p.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,o]:[!0]}const Dn=e=>e.key||"";function ma(e){const t=[];return p.Children.forEach(e,n=>{p.isValidElement(n)&&t.push(n)}),t}const Xx=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:o=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[d,f]=Fl(o),m=p.useMemo(()=>ma(e),[e]),h=o&&!d?[]:m.map(Dn),g=p.useRef(!0),x=p.useRef(m),v=Ni(()=>new Map),w=p.useRef(new Set),[I,S]=p.useState(m),[P,z]=p.useState(m);Dl(()=>{g.current=!1,x.current=m;for(let _=0;_<P.length;_++){const M=Dn(P[_]);h.includes(M)?(v.delete(M),w.current.delete(M)):v.get(M)!==!0&&v.set(M,!1)}},[P,h.length,h.join("-")]);const E=[];if(m!==I){let _=[...m];for(let M=0;M<P.length;M++){const N=P[M],A=Dn(N);h.includes(A)||(_.splice(M,0,N),E.push(N))}return i==="wait"&&E.length&&(_=E),z(ma(_)),S(m),null}const{forceRender:L}=p.useContext(Ti);return l.jsx(l.Fragment,{children:P.map(_=>{const M=Dn(_),N=o&&!d?!1:m===P||h.includes(M),A=()=>{if(w.current.has(M))return;if(v.has(M))w.current.add(M),v.set(M,!0);else return;let R=!0;v.forEach(D=>{D||(R=!1)}),R&&(L?.(),z(x.current),o&&f?.(),s&&s())};return l.jsx(Yx,{isPresent:N,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:i,root:u,onExitComplete:N?void 0:A,anchorX:a,anchorY:c,children:_},M)})})},Bl=p.createContext({strict:!1}),ga={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 ya=!1;function eb(){if(ya)return;const e={};for(const t in ga)e[t]={isEnabled:n=>ga[t].some(s=>!!n[s])};Ga(e),ya=!0}function $l(){return eb(),cf()}function tb(e){const t=$l();for(const n in e)t[n]={...t[n],...e[n]};Ga(t)}const nb=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 as(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||nb.has(e)}let Vl=e=>!as(e);function sb(e){typeof e=="function"&&(Vl=t=>t.startsWith("on")?!as(t):e(t))}try{sb(require("@emotion/is-prop-valid").default)}catch{}function rb(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||di(e[r])||(Vl(r)||n===!0&&as(r)||!t&&!as(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const ps=p.createContext({});function ib(e,t){if(Qa(e)){const{initial:n,animate:s}=e;return{initial:n===!1||mo(n)?n:void 0,animate:mo(s)?s:void 0}}return e.inherit!==!1?t:{}}function ob(e){const{initial:t,animate:n}=ib(e,p.useContext(ps));return p.useMemo(()=>({initial:t,animate:n}),[xa(t),xa(n)])}function xa(e){return Array.isArray(e)?e.join(" "):e}const ji=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ul(e,t,n){for(const s in t)!di(t[s])&&!uf(s,n)&&(e[s]=t[s])}function ab({transformTemplate:e},t){return p.useMemo(()=>{const n=ji();return df(n,t,e),Object.assign({},n.vars,n.style)},[t])}function lb(e,t){const n=e.style||{},s={};return Ul(s,n,e),Object.assign(s,ab(e,t)),s}function cb(e,t){const n={},s=lb(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 Wl=()=>({...ji(),attrs:{}});function ub(e,t,n,s){const r=p.useMemo(()=>{const i=Wl();return hf(i,t,ff(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Ul(i,e.style,e),r.style={...i,...r.style}}return r}const db=["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 Ai(e){return typeof e!="string"||e.includes("-")?!1:!!(db.indexOf(e)>-1||/[A-Z]/u.test(e))}function hb(e,t,n,{latestValues:s},r,i=!1,o){const c=(o??Ai(e)?ub:cb)(t,s,r,e),u=rb(t,typeof e=="string",i),d=e!==p.Fragment?{...u,...c,ref:n}:{},{children:f}=t,m=p.useMemo(()=>di(f)?f.get():f,[f]);return p.createElement(e,{...d,children:m})}function fb({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:pb(n,s,r,e),renderState:t()}}function pb(e,t,n,s){const r={},i=s(e,{});for(const m in i)r[m]=pf(i[m]);let{initial:o,animate:a}=e;const c=Qa(e),u=mf(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const f=d?a:o;if(f&&typeof f!="boolean"&&!Ja(f)){const m=Array.isArray(f)?f:[f];for(let h=0;h<m.length;h++){const g=gf(e,m[h]);if(g){const{transitionEnd:x,transition:v,...w}=g;for(const I in w){let S=w[I];if(Array.isArray(S)){const P=d?S.length-1:0;S=S[P]}S!==null&&(r[I]=S)}for(const I in x)r[I]=x[I]}}}return r}const ql=e=>(t,n)=>{const s=p.useContext(ps),r=p.useContext(fs),i=()=>fb(e,t,s,r);return n?i():Ni(i)},mb=ql({scrapeMotionValuesFromProps:yf,createRenderState:ji}),gb=ql({scrapeMotionValuesFromProps:xf,createRenderState:Wl}),yb=Symbol.for("motionComponentSymbol");function xb(e,t,n){const s=p.useRef(n);p.useInsertionEffect(()=>{s.current=n});const r=p.useRef(null);return p.useCallback(i=>{i&&e.onMount?.(i),t&&(i?t.mount(i):t.unmount());const o=s.current;if(typeof o=="function")if(i){const a=o(i);typeof a=="function"&&(r.current=a)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[t])}const Hl=p.createContext({});function Ut(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function bb(e,t,n,s,r,i){const{visualElement:o}=p.useContext(ps),a=p.useContext(Bl),c=p.useContext(fs),u=p.useContext(Ii),d=u.reducedMotion,f=u.skipAnimations,m=p.useRef(null),h=p.useRef(!1);s=s||a.renderer,!m.current&&s&&(m.current=s(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:d,skipAnimations:f,isSVG:i}),h.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const g=m.current,x=p.useContext(Hl);g&&!g.projection&&r&&(g.type==="html"||g.type==="svg")&&wb(m.current,n,r,x);const v=p.useRef(!1);p.useInsertionEffect(()=>{g&&v.current&&g.update(n,c)});const w=n[bf],I=p.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Dl(()=>{h.current=!0,g&&(v.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),I.current&&g.animationState&&g.animationState.animateChanges())}),p.useEffect(()=>{g&&(!I.current&&g.animationState&&g.animationState.animateChanges(),I.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),I.current=!1),g.enteringChildren=void 0)}),g}function wb(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutAnchor:d,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Gl(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||a&&Ut(a),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:d})}function Gl(e){if(e)return e.options.allowProjection!==!1?e.projection:Gl(e.parent)}function Ir(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&tb(s);const i=n?n==="svg":Ai(e),o=i?gb:mb;function a(u,d){let f;const m={...p.useContext(Ii),...u,layoutId:Sb(u)},{isStatic:h}=m,g=ob(u),x=o(u,h);if(!h&&typeof window<"u"){vb();const v=Cb(m);f=v.MeasureLayout,g.visualElement=bb(e,x,m,r,v.ProjectionNode,i)}return l.jsxs(ps.Provider,{value:g,children:[f&&g.visualElement?l.jsx(f,{visualElement:g.visualElement,...m}):null,hb(e,u,xb(x,g.visualElement,d),x,h,t,i)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=p.forwardRef(a);return c[yb]=e,c}function Sb({layoutId:e}){const t=p.useContext(Ti).id;return t&&e!==void 0?t+"-"+e:e}function vb(e,t){p.useContext(Bl).strict}function Cb(e){const t=$l(),{drag:n,layout:s}=t;if(!n&&!s)return{};const r={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function kb(e,t){if(typeof Proxy>"u")return Ir;const n=new Map,s=(i,o)=>Ir(i,o,e,t),r=(i,o)=>s(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?s:(n.has(o)||n.set(o,Ir(o,void 0,e,t)),n.get(o))})}const Eb=(e,t)=>t.isSVG??Ai(e)?new wf(t):new Sf(t,{allowProjection:e!==p.Fragment});class Pb extends vt{constructor(t){super(t),t.animationState||(t.animationState=vf(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ja(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 Tb=0;class Nb extends vt{constructor(){super(...arguments),this.id=Tb++,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:i,custom:o}=this.node.getProps();if(typeof i=="string"||typeof i=="object"&&i!==null&&!Array.isArray(i)){const a=Cf(this.node,i,o);if(a){const{transition:c,transitionEnd:u,...d}=a;for(const f in d)this.node.getValue(f)?.jump(d[f])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.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 Ib={animation:{Feature:Pb},exit:{Feature:Nb}};function wn(e){return{point:{x:e.pageX,y:e.pageY}}}const jb=e=>t=>Za(t)&&e(t,wn(t));function mn(e,t,n,s){return ns(e,t,jb(n),s)}const Ql=({current:e})=>e?e.ownerDocument.defaultView:null,ba=(e,t)=>Math.abs(e-t);function Ab(e,t){const n=ba(e.x,t.x),s=ba(e.y,t.y);return Math.sqrt(n**2+s**2)}const wa=new Set(["auto","scroll"]);class Jl{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:a}={}){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=Fn(this.lastRawMoveEventInfo,this.transformPagePoint));const h=jr(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Ab(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=h,{timestamp:w}=go;this.history.push({...v,timestamp:w});const{onStart:I,onMove:S}=this.handlers;g||(I&&I(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,h)},this.handlePointerMove=(h,g)=>{this.lastMoveEvent=h,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=Fn(g,this.transformPagePoint),Xe.update(this.updatePoint,!0)},this.handlePointerUp=(h,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const I=jr(h.type==="pointercancel"?this.lastMoveEventInfo:Fn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(h,I),v&&v(h,I)},!Za(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const c=wn(t),u=Fn(c,this.transformPagePoint),{point:d}=u,{timestamp:f}=go;this.history=[{...d,timestamp:f}];const{onSessionStart:m}=n;m&&m(t,jr(u,this.history)),this.removeListeners=Ya(mn(this.contextWindow,"pointermove",this.handlePointerMove),mn(this.contextWindow,"pointerup",this.handlePointerUp),mn(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(wa.has(s.overflowX)||wa.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,r=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,r),Xe.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),kf(this.updatePoint)}}function Fn(e,t){return t?{point:t(e.point)}:e}function Sa(e,t){return{x:e.x-t.x,y:e.y-t.y}}function jr({point:e},t){return{point:e,delta:Sa(e,Zl(t)),offset:Sa(e,zb(t)),velocity:Lb(t,.1)}}function zb(e){return e[0]}function Zl(e){return e[e.length-1]}function Lb(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Zl(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>yo(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>yo(t)*2&&(s=e[1]);const i=Ef(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function _b(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?ss(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?ss(n,e,s.max):Math.min(e,n)),e}function va(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 Rb(e,{top:t,left:n,bottom:s,right:r}){return{x:va(e.x,n,r),y:va(e.y,t,s)}}function Ca(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 Ob(e,t){return{x:Ca(e.x,t.x),y:Ca(e.y,t.y)}}function Mb(e,t){let n=.5;const s=$r(e),r=$r(t);return r>s?n=xo(t.min,t.max-s,e.min):s>r&&(n=xo(e.min,e.max-r,t.min)),Pf(0,1,n)}function Db(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 Kr=.35;function Fb(e=Kr){return e===!1?e=0:e===!0&&(e=Kr),{x:ka(e,"left","right"),y:ka(e,"top","bottom")}}function ka(e,t,n){return{min:Ea(e,t),max:Ea(e,n)}}function Ea(e,t){return typeof e=="number"?e:e[t]||0}const Bb=new WeakMap;class $b{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=Tf(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=f=>{n&&this.snapToCursor(wn(f).point),this.stopAnimation()},o=(f,m)=>{const{drag:h,dragPropagation:g,onDragStart:x}=this.getProps();if(h&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=zf(h),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bt(w=>{let I=this.getAxisMotionValue(w).get()||0;if(Lf.test(I)){const{projection:S}=this.visualElement;if(S&&S.layout){const P=S.layout.layoutBox[w];P&&(I=$r(P)*(parseFloat(I)/100))}}this.originPoint[w]=I}),x&&Xe.update(()=>x(f,m),!1,!0),bo(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},a=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m;const{dragPropagation:h,dragDirectionLock:g,onDirectionLock:x,onDrag:v}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=m;if(g&&this.currentDirection===null){this.currentDirection=Ub(w),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),v&&Xe.update(()=>v(f,m),!1,!0)},c=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m,this.stop(f,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Jl(t,{onSessionStart:i,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ql(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&Xe.postRender(()=>a(s,r))}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:r}=this.getProps();if(!s||!Bn(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=_b(o,this.constraints[t],this.elastic[t])),i.set(o)}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,r=this.constraints;t&&Ut(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Rb(s.layoutBox,t):this.constraints=!1,this.elastic=Fb(n),r!==this.constraints&&!Ut(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&bt(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=Db(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ut(t))return!1;const s=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const i=Nf(s,r.root,this.visualElement.getTransformPagePoint());let o=Ob(r.layout.layoutBox,i);if(n){const a=n(If(o));this.hasMutatedConstraints=!!a,a&&(o=jf(a))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=bt(d=>{if(!Bn(d,n,this.currentDirection))return;let f=c&&c[d]||{};(o===!0||o===d)&&(f={min:0,max:0});const m=r?200:1e6,h=r?40:1e7,g={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...i,...f};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return bo(this.visualElement,t),s.start(Af(t,s,0,n,this.visualElement,!1))}stopAnimation(){bt(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps()[n];return r||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){bt(n=>{const{drag:s}=this.getProps();if(!Bn(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:a}=r.layout.layoutBox[n],c=i.get()||0;i.set(t[n]-ss(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Ut(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};bt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();r[o]=Mb({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),bt(o=>{if(!Bn(o,t,null))return;const a=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];a.set(ss(c,u,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Bb.set(this.visualElement,this);const t=this.visualElement.current,n=mn(t,"pointerdown",u=>{const{drag:d,dragListener:f=!0}=this.getProps(),m=u.target,h=m!==t&&_f(m);d&&f&&!h&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Ut(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Vb(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Xe.read(r);const a=ns(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:d})=>{this.isDragging&&d&&(bt(f=>{const m=this.getAxisMotionValue(f);m&&(this.originPoint[f]+=u[f].translate,m.set(m.get()+u[f].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),c&&c(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=Kr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:a}}}function Pa(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Vb(e,t,n){const s=wo(e,Pa(n)),r=wo(t,Pa(n));return()=>{s(),r()}}function Bn(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ub(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Wb extends vt{constructor(t){super(t),this.removeGroupControls=Hn,this.removeListeners=Hn,this.controls=new $b(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hn}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 Ar=e=>(t,n)=>{e&&Xe.update(()=>e(t,n),!1,!0)};class qb extends vt{constructor(){super(...arguments),this.removePointerDownListener=Hn}onPointerDown(t){this.session=new Jl(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ql(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Ar(t),onStart:Ar(n),onMove:Ar(s),onEnd:(i,o)=>{delete this.session,r&&Xe.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=mn(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 zr=!1;class Hb extends p.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&r&&s.register(i),zr&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Of.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:i}=this.props,{projection:o}=s;return o&&(o.isPresent=i,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),zr=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||Xe.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Rf.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;zr=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Yl(e){const[t,n]=Fl(),s=p.useContext(Ti);return l.jsx(Hb,{...e,layoutGroup:s,switchLayoutGroup:p.useContext(Hl),isPresent:t,safeToRemove:n})}const Gb={pan:{Feature:qb},drag:{Feature:Wb,ProjectionNode:Ka,MeasureLayout:Yl}};function Ta(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=s[r];i&&Xe.postRender(()=>i(t,wn(t)))}class Qb extends vt{mount(){const{current:t}=this.node;t&&(this.unmount=Mf(t,(n,s)=>(Ta(this.node,s,"Start"),r=>Ta(this.node,r,"End"))))}unmount(){}}class Jb extends vt{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=Ya(ns(this.node.current,"focus",()=>this.onFocus()),ns(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Na(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 r="onTap"+(n==="End"?"":n),i=s[r];i&&Xe.postRender(()=>i(t,wn(t)))}class Zb extends vt{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Df(t,(r,i)=>(Na(this.node,i,"Start"),(o,{success:a})=>Na(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Xr=new WeakMap,Lr=new WeakMap,Yb=e=>{const t=Xr.get(e.target);t&&t(e)},Kb=e=>{e.forEach(Yb)};function Xb({root:e,...t}){const n=e||document;Lr.has(n)||Lr.set(n,{});const s=Lr.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Kb,{root:e,...t})),s[r]}function ew(e,t,n){const s=Xb(t);return Xr.set(e,n),s.observe(e),()=>{Xr.delete(e),s.unobserve(e)}}const tw={some:0,all:1};class nw extends vt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:tw[r]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),m=u?d:f;m&&m(c)};this.stopObserver=ew(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(sw(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function sw({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const rw={inView:{Feature:nw},tap:{Feature:Zb},focus:{Feature:Jb},hover:{Feature:Qb}},iw={layout:{ProjectionNode:Ka,MeasureLayout:Yl}},ow={...Ib,...rw,...Gb,...iw},aw=kb(ow,Eb);function lw(){const e=ce(t=>t.toasts);return l.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:l.jsx(Xx,{children:e.map(t=>l.jsxs(aw.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 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 border-l-4 border-emerald-500 overflow-hidden",id:`toast-${t.id}`,children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"p-1 rounded-full bg-emerald-50 text-emerald-600",children:l.jsx(ef,{size:16})}),l.jsx("p",{className:"font-semibold text-gray-900 text-sm font-sans",children:t.title})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-2 leading-relaxed font-sans",children:t.message})]}),l.jsx("button",{type:"button",onClick:()=>Ce.getState().removeToast(t.id),className:"text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:l.jsx(At,{size:14})})]},t.id))})})}function cw({showRightSidebar:e,setShowRightSidebar:t,rightSidebarTab:n,setRightSidebarTab:s,effectiveAgentProviderId:r,agentProviderId:i,setAgentProviderId:o,aiProviders:a,selectedAgentProvider:c,chatLog:u,loading:d,input:f,setInput:m,handleSend:h,chatAttachments:g,setChatAttachments:x,handleChatFileChange:v,handleChatDrop:w,onClearAgentMemory:I,events:S,lang:P,t:z}){const E=p.useRef(null);return p.useEffect(()=>{E.current?.scrollIntoView({behavior:"smooth"})},[u]),l.jsx("div",{className:`transition-all duration-300 bg-white border-l border-gray-200 flex flex-col shadow-xl relative z-30 shrink-0 ${e?"w-96":"w-12 items-center cursor-pointer hover:bg-gray-50"}`,children:e?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[l.jsxs("button",{onClick:()=>s("agent"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="agent"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[l.jsx(ur,{size:14})," Agent"]}),l.jsxs("button",{onClick:()=>s("shell"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="shell"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[l.jsx(qn,{size:14})," Shell"]}),l.jsx("button",{onClick:()=>t(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:l.jsx(tf,{size:14})})]}),n==="agent"?l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:l.jsx(ur,{size:16})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:z.agentTitle}),l.jsx("p",{className:"text-[10px] text-gray-500",children:z.agentSubtitle}),l.jsxs("button",{onClick:I,title:P==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-[10px] text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",P==="zh"?"清除记忆":"Clear memory"]})]})]}),l.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400",children:P==="zh"?"AI 提供商":"AI Provider"}),l.jsxs("div",{className:"relative w-full",children:[l.jsxs("select",{value:r,onChange:L=>o(L.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-[11px] font-medium text-gray-700 shadow-sm outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:[l.jsx("option",{value:"system",children:P==="zh"?"系统默认(Gemini)":"System Default (Gemini)"}),a.map(L=>l.jsx("option",{value:L.id,children:L.name},L.id))]}),l.jsx(Va,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),l.jsx("div",{className:"text-[10px] text-gray-400 truncate w-full text-right",title:r==="system"?P==="zh"?"使用内置 Gemini 系统模型":"Using the built-in Gemini system model":c?.model_name||"",children:r==="system"?P==="zh"?"内置系统模型":"Built-in system model":`${c?.name||(P==="zh"?"已选提供商":"Selected provider")}`})]})]})}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u.map((L,_)=>l.jsx("div",{className:`flex flex-col ${L.role==="user"?"items-end":"items-start"}`,children:l.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${L.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:L.content})},_)),d&&l.jsx("div",{className:"flex items-start",children:l.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:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),l.jsx("div",{ref:E})]}),l.jsxs("form",{onSubmit:h,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:L=>L.preventDefault(),onDrop:w,children:[g.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:g.map((L,_)=>l.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-[10px]",children:[l.jsx(qa,{size:10,className:"shrink-0"}),l.jsx("span",{className:"truncate max-w-[100px]",title:L.name,children:L.name}),l.jsx("button",{type:"button",onClick:()=>x(M=>M.filter((N,A)=>A!==_)),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:l.jsx(At,{size:10})})]},_))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.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:[l.jsx(nf,{size:14}),l.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:v,accept:".csv,.txt,.json,.md"})]}),l.jsxs("div",{className:"relative flex-1",children:[l.jsx("input",{type:"text",value:f,onChange:L=>m(L.target.value),placeholder:z.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"}),l.jsx("button",{type:"submit",disabled:d||!f.trim(),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",children:l.jsx(sf,{size:10})})]})]})]})]}):l.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-[10px] min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[l.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:l.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[l.jsx(qn,{size:14}),l.jsx("span",{className:"text-xs",children:z.eventStream})]})}),l.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:S.length===0?l.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):S.map((L,_)=>l.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[l.jsxs("span",{className:"text-gray-500 shrink-0 text-[9px]",children:["[",new Date(L.timestamp).toLocaleTimeString(),"]"]}),l.jsx("span",{className:"text-blue-400 shrink-0 truncate text-[9px]",title:L.source,children:L.source})]}),l.jsx("div",{className:"text-green-300 font-bold",children:L.type}),l.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:L.payload})]},_))})]})]}):l.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-gray-400 w-full",onClick:()=>t(!0),children:[l.jsx(ur,{size:18,className:"mb-6 hover:text-indigo-500"}),l.jsx(qn,{size:18,className:"hover:text-indigo-500"}),l.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:l.jsx("div",{className:"uppercase tracking-widest text-[9px] rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const uw=p.lazy(()=>Ie(()=>import("./ImportModal-BTfia0Ah.js"),[]).then(e=>({default:e.ImportModal}))),dw=p.lazy(()=>Ie(()=>import("./CourseWizardModal-CxT0II5U.js"),[]).then(e=>({default:e.CourseWizardModal}))),hw=p.lazy(()=>Ie(()=>import("./ImportLessonsModal-CZuiK5N1.js"),[]).then(e=>({default:e.ImportLessonsModal}))),fw=p.lazy(()=>Ie(()=>import("./QuizGeneratorModal-Vmdm_KlA.js"),[]).then(e=>({default:e.QuizGeneratorModal}))),pw=p.lazy(()=>Ie(()=>import("./StudentPreviewModal-B_ITJvkQ.js"),[]).then(e=>({default:e.StudentPreviewModal}))),mw=p.lazy(()=>Ie(()=>import("./ProcessLogsModal-01S7zsw0.js"),[]).then(e=>({default:e.ProcessLogsModal}))),gw=p.lazy(()=>Ie(()=>import("./CloudDriveModal-CDIeKEs0.js"),[]).then(e=>({default:e.CloudDriveModal}))),yw=p.lazy(()=>Ie(()=>import("./SystemResourceLibraryModal-Cxjj_pd-.js"),[]).then(e=>({default:e.SystemResourceLibraryModal}))),xw=p.lazy(()=>Ie(()=>import("./BatchPickerModal-CY5i3NQK.js"),[]).then(e=>({default:e.BatchPickerModal}))),bw=p.lazy(()=>Ie(()=>import("./ExportWeightModal-DKWU7X1K.js"),[]).then(e=>({default:e.ExportWeightModal}))),ww=p.lazy(()=>Ie(()=>import("./NotificationDetailModal-CW42lyh0.js"),[]).then(e=>({default:e.NotificationDetailModal}))),Sw=p.lazy(()=>Ie(()=>import("./HelpTour-CHPIK2ae.js"),[]).then(e=>({default:e.HelpTour}))),vw=p.lazy(()=>Ie(()=>import("./CoursewareHubPanel-LpUgjqbH.js"),[]).then(e=>({default:e.CoursewareHubPanel})));function Cw(e){const{lang:t,t:n,showImportModal:s=!1,setShowImportModal:r=()=>{},handleImportFile:i=()=>{},importError:o=null,importSuccess:a=null,isImporting:c=!1,downloadCSVTemplate:u=()=>{},addToast:d=()=>{},generateTemplateContent:f=()=>"",isImportLessonsOpen:m=!1,setIsImportLessonsOpen:h=()=>{},importStatus:g="idle",setIsDraggingImport:x=()=>{},handleCSVFileChange:v=()=>{},downloadCsvTemplate:w=()=>{},isDraggingImport:I=!1,previewImportData:S=[],setPreviewImportData:P=()=>{},setImportStatus:z=()=>{},importProgress:E=0,importProgressTotal:L=0,importErrorMsg:_="",setImportErrorMsg:M=()=>{},handleCSVImportSubmit:N=()=>{},lessons:A=[],fetchClassDashboard:R=()=>{},isLessonPreviewVisible:D=!1,setIsLessonPreviewVisible:F=()=>{},selectedLesson:j=null,previewFullscreenPanel:T="none",setPreviewFullscreenPanel:$=()=>{},previewLessonTab:k="whiteboard",setPreviewLessonTab:B=()=>{},activeRole:y="teacher",elements:te=[],activeSegmentId:ae=null,setActiveSegmentId:b=()=>{},fetchElements:q=()=>{},currentVfsParent:ee=null,setCurrentVfsParent:se=()=>{},vfsNodes:fe=[],previewSelectedCourseware:ge=null,setPreviewSelectedCourseware:ze=()=>{},showProcessLogs:je=null,setShowProcessLogs:he=()=>{},processLogsContent:ft="",isCloudDriveOpen:Lt=!1,setIsCloudDriveOpen:_t=()=>{},cloudDrivePreviewNode:pt=null,setCloudDrivePreviewNode:mt=()=>{},isSystemResourceLibraryOpen:G=!1,setIsSystemResourceLibraryOpen:K=()=>{},systemResourceTab:re="system",setSystemResourceTab:we=()=>{},selectedLibraryResourceId:qe=null,setSelectedLibraryResourceId:de=()=>{},loadingLibraryResources:Te=!1,libraryResources:ke=[],fetchLibraryResources:Ze=()=>{},classes:O=[],expandedClassId:W=null,isExportWeightModalOpen:Q=!1,setIsExportWeightModalOpen:Z=()=>{},quizzesWeight:ie=40,setQuizzesWeight:Ne=()=>{},assignmentsWeight:Ye=60,setAssignmentsWeight:Le=()=>{},handleQuizzesWeightChange:lt=()=>{},handleAssignmentsWeightChange:_e=()=>{},customCategoryOverrides:ye={},setCustomCategoryOverrides:He=()=>{},classDashboardMap:Fe={},exportClassId:ys="",exportClassName:xs="",csvPreviewData:bs=null,handleExportGrades:ws=()=>{},setSelectedAssignment:Ss=()=>{},setStudentViewStatus:vs=()=>{},setQuizStudentAnswers:Cs=()=>{},setSubAssignmentTab:Sn=()=>{},isTourOpen:ks=!1,setIsTourOpen:Es=()=>{},handleSeedSuccess:Ps=()=>{},setTeacherTab:Jt=()=>{},showCoursewareHub:Zt=!1,setShowCoursewareHub:vn=()=>{}}=e,Ee=e.courseWizard,Rt=Ee?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Ts=Ee?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),tt=Ee?.wizardStep??e.wizardStep??1,Cn=Ee?.setWizardStep??e.setWizardStep??(()=>{}),Ns=Ee?.wizardIsSubmitting??e.wizardIsSubmitting??!1,kn=Ee?.wizardCourseTitle??e.wizardCourseTitle??"",Is=Ee?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),Ot=Ee?.wizardCourseDescription??e.wizardCourseDescription??"",js=Ee?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),En=Ee?.wizardCourseCategory??e.wizardCourseCategory??"",As=Ee?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),zs=Ee?.wizardCourseTimeline??e.wizardCourseTimeline??[],Ls=Ee?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),_s=Ee?.wizardCourseContent??e.wizardCourseContent??"",Rs=Ee?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),Os=Ee?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),me=e.quizGenerator,Ms=me?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,kt=me?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),Ds=me?.quizGenMode??e.quizGenMode??"scan_lesson",Fs=me?.setQuizGenMode??e.setQuizGenMode??(()=>{}),Bs=me?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",Pn=me?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),Tn=me?.quizGenTopic??e.quizGenTopic??"",$s=me?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Vs=me?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,Nn=me?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),Yt=me?.suggestedObjectives??e.suggestedObjectives??[],Kt=me?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),Us=me?.suggestedQuestions??e.suggestedQuestions??[],Ws=me?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),Se=me?.quizGenTimeLimit??e.quizGenTimeLimit??0,Et=me?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),In=me?.savingQuiz??e.savingQuiz??!1,jn=me?.setSavingQuiz??e.setSavingQuiz??(()=>{}),Be=me?.quizGeneratorClassId??e.quizGeneratorClassId??null,Re=e.classBatch,qs=Re?.batchPicker??e.batchPicker??null,Hs=Re?.setBatchPicker??e.setBatchPicker??(()=>{}),Gs=Re?.batchPickerLesson??e.batchPickerLesson??"",Mt=Re?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),Qs=Re?.batchPickerDate??e.batchPickerDate??"",Pt=Re?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),gt=Re?.batchPickerTargetClass??e.batchPickerTargetClass??"",$e=Re?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),Js=Re?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Dt=e.studentNotificationsHook,Zs=Dt?.selectedNotificationForModal??e.selectedNotificationForModal??null,Ys=Dt?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return l.jsxs(p.Suspense,{fallback:null,children:[l.jsx(uw,{show:s,onClose:()=>r(!1),lang:t,handleImportFile:i,importError:o,importSuccess:a,isImporting:c,downloadCSVTemplate:u}),l.jsx(dw,{isCourseWizardOpen:Rt,setIsCourseWizardOpen:Ts,lang:t,wizardStep:tt,setWizardStep:Cn,wizardIsSubmitting:Ns,wizardCourseTitle:kn,setWizardCourseTitle:Is,wizardCourseDescription:Ot,setWizardCourseDescription:js,wizardCourseCategory:En,setWizardCourseCategory:As,wizardCourseTimeline:zs,setWizardCourseTimeline:Ls,wizardCourseContent:_s,setWizardCourseContent:Rs,addToast:d,generateTemplateContent:f,handleDeployWizardCourse:Os}),l.jsx(hw,{isImportLessonsOpen:m,setIsImportLessonsOpen:h,lang:t,importStatus:g,setIsDraggingImport:x,handleCSVFileChange:v,downloadCsvTemplate:w,isDraggingImport:I,previewImportData:S,setPreviewImportData:P,setImportStatus:z,importProgress:E,importProgressTotal:L,importErrorMsg:_,setImportErrorMsg:M,handleCSVImportSubmit:N}),l.jsx(fw,{isQuizGeneratorOpen:Ms,setIsQuizGeneratorOpen:kt,lessons:A,quizGenMode:Ds,setQuizGenMode:Fs,quizGenSelectedLessonId:Bs,setQuizGenSelectedLessonId:Pn,quizGenTopic:Tn,setQuizGenTopic:$s,isGeneratingSuggestions:Vs,setIsGeneratingSuggestions:Nn,suggestedObjectives:Yt,setSuggestedObjectives:Kt,suggestedQuestions:Us,setSuggestedQuestions:Ws,quizGenTimeLimit:Se,setQuizGenTimeLimit:Et,savingQuiz:In,setSavingQuiz:jn,quizGeneratorClassId:Be,fetchClassDashboard:R}),l.jsx(pw,{isLessonPreviewVisible:D,setIsLessonPreviewVisible:F,lessons:A,selectedLesson:j,previewFullscreenPanel:T,setPreviewFullscreenPanel:$,previewLessonTab:k,setPreviewLessonTab:B,activeRole:y,elements:te,activeSegmentId:ae,setActiveSegmentId:b,fetchElements:q,currentVfsParent:ee,setCurrentVfsParent:se,vfsNodes:fe,previewSelectedCourseware:ge,setPreviewSelectedCourseware:ze}),l.jsx(mw,{showProcessLogs:je,setShowProcessLogs:he,processLogsContent:ft,t:n}),l.jsx(gw,{isOpen:Lt,onClose:()=>_t(!1),vfsNodes:fe,currentVfsParent:ee,setCurrentVfsParent:se,cloudDrivePreviewNode:pt,setCloudDrivePreviewNode:mt}),l.jsx(yw,{isSystemResourceLibraryOpen:G,setIsSystemResourceLibraryOpen:K,lang:t,systemResourceTab:re,setSystemResourceTab:we,selectedLibraryResourceId:qe,setSelectedLibraryResourceId:de,vfsNodes:fe,currentVfsParent:ee,setCurrentVfsParent:se,cloudDrivePreviewNode:pt,setCloudDrivePreviewNode:mt,loadingLibraryResources:Te,libraryResources:ke,fetchLibraryResources:Ze}),l.jsx(xw,{batchPicker:qs,setBatchPicker:Hs,batchPickerLesson:Gs,setBatchPickerLesson:Mt,batchPickerDate:Qs,setBatchPickerDate:Pt,batchPickerTargetClass:gt,setBatchPickerTargetClass:$e,lessons:A,classes:O,expandedClassId:W,confirmBatchPicker:Js,lang:t}),l.jsx(bw,{isExportWeightModalOpen:Q,setIsExportWeightModalOpen:Z,lang:t,quizzesWeight:ie,setQuizzesWeight:Ne,assignmentsWeight:Ye,setAssignmentsWeight:Le,handleQuizzesWeightChange:lt,handleAssignmentsWeightChange:_e,customCategoryOverrides:ye,setCustomCategoryOverrides:He,classDashboardMap:Fe,exportClassId:ys,exportClassName:xs,csvPreviewData:bs,handleExportGrades:ws}),l.jsx(ww,{notification:Zs,onClose:()=>Ys(null),lang:t,onOpenWorkspace:Xt=>{Ss(Xt),vs("assignment"),Cs({}),Sn("quiz")}}),l.jsx(Sw,{isOpen:ks,onClose:()=>Es(!1),lang:t,onSeedSuccess:Ps,onJumpTab:Xt=>Jt(Xt)}),Zt&&l.jsx(vw,{onClose:()=>vn(!1),lang:t})]})}const kw=["whiteboard.","courseware.","quiz.","rollcall."];class Ew{constructor(){this.handlers=new Map}setSocketBridge(t){this.socketBridge=t}hasSocketBridge(){return!!this.socketBridge}subscribe(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>{this.handlers.get(t)?.delete(n)}}async publish(t){const n=this.handlers.get(t.type);if(n)for(const s of n)try{s(t)}catch(r){console.error("[FrontendEventBus] handler error:",r)}this.socketBridge&&kw.some(s=>t.type.startsWith(s))&&this.socketBridge(t)}}const Pw=new Ew;async function Kl(e){const t=e.data;if(!t||typeof t!="object")return;if(typeof window<"u"&&typeof document<"u"&&e.source)try{if(!Array.from(document.querySelectorAll("iframe")).some(u=>u.contentWindow===e.source)&&e.source!==window)return}catch{}let n=t.attempt_id;const s=t.type||"",r=t.payload||t;if(!n&&e.source)try{const a=Array.from(document.querySelectorAll("iframe")).find(c=>c.contentWindow===e.source);if(a&&a.contentWindow){const c=a.contentWindow;c.__LMS_STUDENT__?.attempt_id&&(n=c.__LMS_STUDENT__.attempt_id)}}catch{}if(!n||typeof n!="string")return;if(s==="LMS_CONFIG"){$n("courseware.config_reported",n,t.config??r);return}if(s==="LMS_GET_PROGRESS"){const a=t.requestId,c=e.source;if(a&&c&&typeof c.postMessage=="function"){if(typeof document<"u"&&!Array.from(document.querySelectorAll("iframe")).some(h=>h.contentWindow===c)&&c!==window){console.warn("[LMS Bridge Security] Dropping response to untrusted window");return}let u;try{u=(await(await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/progress`)).json()).progress??null}catch{u=null}const d=e.origin&&e.origin!=="null"?e.origin:"*";c.postMessage({type:"LMS_PROGRESS_RESPONSE",requestId:a,progress:u},d)}return}const i=s==="LMS_SUBMIT"||s==="LMS_FINISH"||s==="submit"||s==="finish"||s==="completed"||r&&typeof r=="object"&&(r.score!==void 0||r.grade!==void 0||r.result!==void 0||r.points!==void 0),o=s==="LMS_SAVE_PROGRESS"||s==="saveProgress";if(i){$n("courseware.submitted",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??r?.note??void 0,completion:r?.completion??1,status:"submitted",extra:r})})}catch(a){console.error("[LMS Bridge] Failed to submit attempt data to backend:",a)}}else if(o){$n("courseware.progress_saved",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??void 0,completion:r?.completion??void 0,status:"inprogress",extra:r})})}catch(a){console.error("[LMS Bridge] Failed to save progress to backend:",a)}}else{$n("courseware.event_logged",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventType:s||"log",payload:r})})}catch(a){console.error("[LMS Bridge] Failed to log event to backend:",a)}}}function $n(e,t,n){Pw.publish({id:Ff(),type:e,source:"courseware-bridge",payload:{attemptId:t,data:n},timestamp:Date.now(),correlationId:t})}function Tw(e,t,n,s){try{let r=s;if(!r&&e.src&&typeof window<"u")try{const i=new URL(e.src,window.location.href);i.origin&&i.origin!=="null"&&!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&(r=i.origin)}catch{}e.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:t,payload:n},r||"*")}catch{}}function Xl(e){p.useEffect(()=>{if(!e)return;const t=n=>{Kl(n)};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[e])}function ec(e,t={}){if(!(typeof document>"u"))try{document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"theme:changed",payload:{theme:e,tokens:t}},"*"),s.contentWindow?.postMessage({type:"LMS_THEME_CHANGED",theme:e,tokens:t},"*")}catch{}})}catch{}}const Nw=Object.freeze(Object.defineProperty({__proto__:null,broadcastThemeToIframes:ec,processLmsMessage:Kl,sendCommandToCourseware:Tw,useLmsBridge:Xl},Symbol.toStringTag,{value:"Module"}));function Iw(e){const{session:t,showProcessLogs:n,activeStudentId:s,currentVfsParent:r,selectedLesson:i,selectedAssignment:o,expandedClassId:a,fetchLessons:c,fetchPlugins:u,fetchRegisteredCommands:d,fetchEvents:f,fetchApprovals:m,fetchProcesses:h,fetchClasses:g,fetchTodaySchedules:x,fetchStudents:v,fetchLabs:w,fetchVfs:I,fetchProcessLogs:S,fetchClassStudents:P,fetchElements:z}=e,E=p.useRef(r),L=p.useRef(i),_=p.useRef(o),M=p.useRef(a);p.useEffect(()=>{E.current=r},[r]),p.useEffect(()=>{L.current=i},[i]),p.useEffect(()=>{_.current=o},[o]),p.useEffect(()=>{M.current=a},[a]),p.useEffect(()=>{if(!t)return;c(),u(),d(),f(),m(),h(),g(),x(),v(),w(),I(E.current);let N=!1;const A=setInterval(async()=>{if(!N){N=!0;try{if(await f(),await c(),await m(),await h(),await g(),await x().catch(()=>{}),await v(),await w(),await I(E.current),await d(),n&&await S(n),M.current&&await P(M.current),L.current&&await z(L.current),_.current){const R=s||_.current.student_id;await z(`assignment-${_.current.id}-student-${R}`)}}finally{N=!1}}},2e3);return()=>clearInterval(A)},[t,n,s]),p.useEffect(()=>{I(r)},[r]),p.useEffect(()=>{i&&z(i)},[i])}function jw(e){const{lang:t,t:n,selectedLesson:s,effectiveAgentProviderId:r,expandedClassId:i,fetchLessons:o,fetchClasses:a,fetchStudents:c,fetchClassStudents:u,fetchClassProgress:d,fetchClassDashboard:f,fetchElements:m}=e,[h,g]=p.useState([{role:"agent",content:n.agentIntro||""}]),[x,v]=p.useState(""),[w,I]=p.useState(!1),[S,P]=p.useState([]);p.useEffect(()=>{h.length===1&&h[0].role==="agent"&&g([{role:"agent",content:n.agentIntro}])},[t,n.agentIntro]);const z=p.useCallback(async N=>{try{const A=await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(N||"")}`);if(!A.ok)return;const R=await A.json(),D=Array.isArray(R.messages)?R.messages:[];D.length>0?g(D.map(F=>({role:F.role==="assistant"?"agent":"user",content:F.content}))):g([{role:"agent",content:n.agentIntro}])}catch{}},[n.agentIntro]),E=p.useCallback(async()=>{try{await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(s||"")}`,{method:"DELETE"})}catch{}g([{role:"agent",content:n.agentIntro}])},[s,n.agentIntro]);return p.useEffect(()=>{z(s)},[s,z]),{chatLog:h,setChatLog:g,input:x,setInput:v,loading:w,setLoading:I,chatAttachments:S,setChatAttachments:P,handleChatFileChange:N=>{N.target.files&&Array.from(N.target.files).forEach(A=>{const R=new FileReader;R.onload=D=>{D.target?.result&&P(F=>[...F,{name:A.name,content:D.target.result}])},A.name.endsWith(".zip")?R.readAsDataURL(A):R.readAsText(A)})},handleChatDrop:N=>{N.preventDefault(),N.dataTransfer.files&&Array.from(N.dataTransfer.files).forEach(A=>{const R=new FileReader;R.onload=D=>{D.target?.result&&P(F=>[...F,{name:A.name,content:D.target.result}])},A.name.endsWith(".zip")?R.readAsDataURL(A):R.readAsText(A)})},handleSend:async N=>{if(N.preventDefault(),!x.trim()||w)return;const A=[...S];let R=x;A.length>0&&(R+=`
133
133
  (📁 ${t==="zh"?"附件":"Attachments"}: ${A.map(D=>D.name).join(", ")})`),g(D=>[...D,{role:"user",content:R}]),v(""),P([]),I(!0);try{const D=await fetch("/api/agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x,lang:t,currentLessonId:s,attachments:A,providerId:r==="system"?null:r})}),F=await D.json();let j="";!D.ok||F.success===!1?j=`⚠️ [System Error] ${F.error||(t==="zh"?"未知系统错误":"Unknown System Error")}`:(j=F.agentText||"",F.toolResults&&F.toolResults.length>0&&(j+=`
134
134
 
135
135
  ${n.executedCommands}`+F.toolResults.map(T=>T.callName).join(", "))),g(T=>[...T,{role:"agent",content:j}]),await o(),await a(),await c(),i&&(await u(i),await d(i),await f(i)),s&&await m(s)}catch{g(D=>[...D,{role:"agent",content:n.simulationError}])}finally{I(!1)}},handleClearAgentMemory:E,restoreAgentMemory:z}}const at=Object.create(null);at.open="0";at.close="1";at.ping="2";at.pong="3";at.message="4";at.upgrade="5";at.noop="6";const Jn=Object.create(null);Object.keys(at).forEach(e=>{Jn[at[e]]=e});const ei={type:"error",data:"parser error"},tc=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",nc=typeof ArrayBuffer=="function",sc=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,zi=({type:e,data:t},n,s)=>tc&&t instanceof Blob?n?s(t):Ia(t,s):nc&&(t instanceof ArrayBuffer||sc(t))?n?s(t):Ia(new Blob([t]),s):s(at[e]+(t||"")),Ia=(e,t)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];t("b"+(s||""))},n.readAsDataURL(e)};function ja(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let _r;function Aw(e,t){if(tc&&e.data instanceof Blob)return e.data.arrayBuffer().then(ja).then(t);if(nc&&(e.data instanceof ArrayBuffer||sc(e.data)))return t(ja(e.data));zi(e,!1,n=>{_r||(_r=new TextEncoder),t(_r.encode(n))})}const Aa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Aa.length;e++)dn[Aa.charCodeAt(e)]=e;const zw=e=>{let t=e.length*.75,n=e.length,s,r=0,i,o,a,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(s=0;s<n;s+=4)i=dn[e.charCodeAt(s)],o=dn[e.charCodeAt(s+1)],a=dn[e.charCodeAt(s+2)],c=dn[e.charCodeAt(s+3)],d[r++]=i<<2|o>>4,d[r++]=(o&15)<<4|a>>2,d[r++]=(a&3)<<6|c&63;return u},Lw=typeof ArrayBuffer=="function",Li=(e,t)=>{if(typeof e!="string")return{type:"message",data:rc(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:_w(e.substring(1),t)}:Jn[n]?e.length>1?{type:Jn[n],data:e.substring(1)}:{type:Jn[n]}:ei},_w=(e,t)=>{if(Lw){const n=zw(e);return rc(n,t)}else return{base64:!0,data:e}},rc=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},ic="",Rw=(e,t)=>{const n=e.length,s=new Array(n);let r=0;e.forEach((i,o)=>{zi(i,!1,a=>{s[o]=a,++r===n&&t(s.join(ic))})})},Ow=(e,t)=>{const n=e.split(ic),s=[];for(let r=0;r<n.length;r++){const i=Li(n[r],t);if(s.push(i),i.type==="error")break}return s};function Mw(){return new TransformStream({transform(e,t){Aw(e,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}e.data&&typeof e.data!="string"&&(r[0]|=128),t.enqueue(r),t.enqueue(n)})}})}let Rr;function Vn(e){return e.reduce((t,n)=>t+n.length,0)}function Un(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)n[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),n}function Dw(e,t){Rr||(Rr=new TextDecoder);const n=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(s===0){if(Vn(n)<1)break;const c=Un(n,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Vn(n)<2)break;const c=Un(n,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(Vn(n)<8)break;const c=Un(n,8),u=new DataView(c.buffer,c.byteOffset,c.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(ei);break}r=d*Math.pow(2,32)+u.getUint32(4),s=3}else{if(Vn(n)<r)break;const c=Un(n,r);a.enqueue(Li(i?c:Rr.decode(c),t)),s=0}if(r===0||r>e){a.enqueue(ei);break}}}})}const oc=4;function be(e){if(e)return Fw(e)}function Fw(e){for(var t in be.prototype)e[t]=be.prototype[t];return e}be.prototype.on=be.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};be.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};be.prototype.off=be.prototype.removeListener=be.prototype.removeAllListeners=be.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var s,r=0;r<n.length;r++)if(s=n[r],s===t||s.fn===t){n.splice(r,1);break}return n.length===0&&delete this._callbacks["$"+e],this};be.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,r=n.length;s<r;++s)n[s].apply(this,t)}return this};be.prototype.emitReserved=be.prototype.emit;be.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};be.prototype.hasListeners=function(e){return!!this.listeners(e).length};const ms=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Je=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Bw="arraybuffer";function ac(e,...t){return t.reduce((n,s)=>(e.hasOwnProperty(s)&&(n[s]=e[s]),n),{})}const $w=Je.setTimeout,Vw=Je.clearTimeout;function gs(e,t){t.useNativeTimers?(e.setTimeoutFn=$w.bind(Je),e.clearTimeoutFn=Vw.bind(Je)):(e.setTimeoutFn=Je.setTimeout.bind(Je),e.clearTimeoutFn=Je.clearTimeout.bind(Je))}const Uw=1.33;function Ww(e){return typeof e=="string"?qw(e):Math.ceil((e.byteLength||e.size)*Uw)}function qw(e){let t=0,n=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n}function lc(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Hw(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Gw(e){let t={},n=e.split("&");for(let s=0,r=n.length;s<r;s++){let i=n[s].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class Qw extends Error{constructor(t,n,s){super(t),this.description=n,this.context=s,this.type="TransportError"}}class _i extends be{constructor(t){super(),this.writable=!1,gs(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,s){return super.emitReserved("error",new Qw(t,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Li(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Hw(t);return n.length?"?"+n:""}}class Jw extends _i{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Ow(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Rw(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=lc()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let cc=!1;try{cc=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Zw=cc;function Yw(){}class Kw extends Jw{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||s!==t.port}}doWrite(t,n){const s=this.request({method:"POST",data:t});s.on("success",n),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=t}}class it extends be{constructor(t,n,s){super(),this.createRequest=t,gs(this,s),this._opts=s,this._method=s.method||"GET",this._uri=n,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var t;const n=ac(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(n);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=it.requestsCount++,it.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Yw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete it.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}it.requestsCount=0;it.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",za);else if(typeof addEventListener=="function"){const e="onpagehide"in Je?"pagehide":"unload";addEventListener(e,za,!1)}}function za(){for(let e in it.requests)it.requests.hasOwnProperty(e)&&it.requests[e].abort()}const Xw=(function(){const e=uc({xdomain:!1});return e&&e.responseType!==null})();class eS extends Kw{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Xw&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new it(uc,this.uri(),t)}}function uc(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Zw))return new XMLHttpRequest}catch{}if(!t)try{return new Je[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const dc=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tS extends _i{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,s=dc?{}:ac(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const s=t[n],r=n===t.length-1;zi(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&ms(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=lc()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Or=Je.WebSocket||Je.MozWebSocket;class nS extends tS{createSocket(t,n,s){return dc?new Or(t,n,s):n?new Or(t,n):new Or(t)}doWrite(t,n){this.ws.send(n)}}class sS extends _i{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Dw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(n).getReader(),r=Mw();r.readable.pipeTo(t.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const s=t[n],r=n===t.length-1;this._writer.write(s).then(()=>{r&&ms(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const rS={websocket:nS,webtransport:sS,polling:eS},iS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,oS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ti(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),s=e.indexOf("]");n!=-1&&s!=-1&&(e=e.substring(0,n)+e.substring(n,s).replace(/:/g,";")+e.substring(s,e.length));let r=iS.exec(e||""),i={},o=14;for(;o--;)i[oS[o]]=r[o]||"";return n!=-1&&s!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=aS(i,i.path),i.queryKey=lS(i,i.query),i}function aS(e,t){const n=/\/{2,9}/g,s=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&s.splice(0,1),t.slice(-1)=="/"&&s.splice(s.length-1,1),s}function lS(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(n[r]=i)}),n}const ni=typeof addEventListener=="function"&&typeof removeEventListener=="function",Zn=[];ni&&addEventListener("offline",()=>{Zn.forEach(e=>e())},!1);class St extends be{constructor(t,n){if(super(),this.binaryType=Bw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const s=ti(t);n.hostname=s.host,n.secure=s.protocol==="https"||s.protocol==="wss",n.port=s.port,s.query&&(n.query=s.query)}else n.host&&(n.hostname=ti(n.host).host);gs(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Gw(this.opts.query)),ni&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Zn.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=oc,n.transport=t,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&St.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",St.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(n+=Ww(r)),s>0&&n>this._maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ms(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,s){return this._sendPacket("message",t,n,s),this}send(t,n,s){return this._sendPacket("message",t,n,s),this}_sendPacket(t,n,s,r){if(typeof n=="function"&&(r=n,n=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:t,data:n,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}_onError(t){if(St.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ni&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Zn.indexOf(this._offlineEventListener);s!==-1&&Zn.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}St.protocol=oc;class cS extends St{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),s=!1;St.priorWebsocketSuccess=!1;const r=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!s)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;St.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=n.name,this.emitReserved("upgradeError",m)}}))};function i(){s||(s=!0,d(),n.close(),n=null)}const o=f=>{const m=new Error("probe error: "+f);m.transport=n.name,i(),this.emitReserved("upgradeError",m)};function a(){o("transport closed")}function c(){o("socket closed")}function u(f){n&&f.name!==n.name&&i()}const d=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};n.once("open",r),n.once("error",o),n.once("close",a),this.once("close",c),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let s=0;s<t.length;s++)~this.transports.indexOf(t[s])&&n.push(t[s]);return n}}let uS=class extends cS{constructor(t,n={}){const s=typeof t=="object"?t:n;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>rS[r]).filter(r=>!!r)),super(t,s)}};function dS(e,t="",n){let s=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),s=ti(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+t,s.href=s.protocol+"://"+i+(n&&n.port===s.port?"":":"+s.port),s}const hS=typeof ArrayBuffer=="function",fS=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,hc=Object.prototype.toString,pS=typeof Blob=="function"||typeof Blob<"u"&&hc.call(Blob)==="[object BlobConstructor]",mS=typeof File=="function"||typeof File<"u"&&hc.call(File)==="[object FileConstructor]";function Ri(e){return hS&&(e instanceof ArrayBuffer||fS(e))||pS&&e instanceof Blob||mS&&e instanceof File}function Yn(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,s=e.length;n<s;n++)if(Yn(e[n]))return!0;return!1}if(Ri(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Yn(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Yn(e[n]))return!0;return!1}function gS(e){const t=[],n=e.data,s=e;return s.data=Kn(n,t),s.attachments=t.length,{packet:s,buffers:t}}function Kn(e,t,n){if(!e)return e;if(Ri(e)){const s={_placeholder:!0,num:t.length};return t.push(e),s}else if(Array.isArray(e)){const s=new Array(e.length);for(let r=0;r<e.length;r++)s[r]=Kn(e[r],t);return s}else if(typeof e=="object"&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON=="function"&&!n)return Kn(e.toJSON(),t,!0);const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=Kn(e[r],t));return s}return e}function yS(e,t){return e.data=si(e.data,t),delete e.attachments,e}function si(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=si(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=si(e[n],t));return e}const xS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ne;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(ne||(ne={}));class bS{constructor(t){this.replacer=t}encode(t){return(t.type===ne.EVENT||t.type===ne.ACK)&&Yn(t)?this.encodeAsBinary({type:t.type===ne.EVENT?ne.BINARY_EVENT:ne.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===ne.BINARY_EVENT||t.type===ne.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=gS(t),s=this.encodeAsString(n.packet),r=n.buffers;return r.unshift(s),r}}class Oi extends be{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const s=n.type===ne.BINARY_EVENT;s||n.type===ne.BINARY_ACK?(n.type=s?ne.EVENT:ne.ACK,this.reconstructor=new wS(n)):super.emitReserved("decoded",n)}else if(Ri(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const s={type:Number(t.charAt(0))};if(ne[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===ne.BINARY_EVENT||s.type===ne.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");const a=Number(o);if(!SS(a)||a<1)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=a}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););s.nsp=t.substring(i,n)}else s.nsp="/";const r=t.charAt(n+1);if(r!==""&&Number(r)==r){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}s.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(Oi.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case ne.CONNECT:return La(n);case ne.DISCONNECT:return n===void 0;case ne.CONNECT_ERROR:return typeof n=="string"||La(n);case ne.EVENT:case ne.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&xS.indexOf(n[0])===-1);case ne.ACK:case ne.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class wS{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=yS(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const SS=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function La(e){return Object.prototype.toString.call(e)==="[object Object]"}const vS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Oi,Encoder:bS,get PacketType(){return ne}},Symbol.toStringTag,{value:"Module"}));function Ke(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const CS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class fc extends be{constructor(t,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Ke(t,"open",this.onopen.bind(this)),Ke(t,"packet",this.onpacket.bind(this)),Ke(t,"error",this.onerror.bind(this)),Ke(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var s,r,i;if(CS.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:ne.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,f=n.pop();this._registerAckCallback(d,f),o.id=d}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(i),n.apply(this,a)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((s,r)=>{const i=(o,a)=>o?r(o):s(a);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((r,...i)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(r)):(this._queue.shift(),n&&n(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:ne.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(s=>String(s.id)===t)){const s=this.acks[t];delete this.acks[t],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case ne.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ne.EVENT:case ne.BINARY_EVENT:this.onevent(t);break;case ne.ACK:case ne.BINARY_ACK:this.onack(t);break;case ne.DISCONNECT:this.ondisconnect();break;case ne.CONNECT_ERROR:this.destroy();const s=new Error(t.data.message);s.data=t.data.data,this.emitReserved("connect_error",s);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let s=!1;return function(...r){s||(s=!0,n.packet({type:ne.ACK,id:t,data:r}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ne.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(t===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(t===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,t.data)}}}function Qt(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Qt.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};Qt.prototype.reset=function(){this.attempts=0};Qt.prototype.setMin=function(e){this.ms=e};Qt.prototype.setMax=function(e){this.max=e};Qt.prototype.setJitter=function(e){this.jitter=e};class ri extends be{constructor(t,n){var s;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,gs(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Qt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const r=n.parser||vS;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new uS(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Ke(n,"open",function(){s.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},o=Ke(n,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),n.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Ke(t,"ping",this.onping.bind(this)),Ke(t,"data",this.ondata.bind(this)),Ke(t,"error",this.onerror.bind(this)),Ke(t,"close",this.onclose.bind(this)),Ke(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){ms(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new fc(this,t,n),this.nsps[t]=s),s}_destroy(t){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let s=0;s<n.length;s++)this.engine.write(n[s],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(r=>{r?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",r)):t.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const un={};function Xn(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=dS(e,t.path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=un[r]&&i in un[r].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return a?c=new ri(s,t):(un[r]||(un[r]=new ri(s,t)),c=un[r]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Xn,{Manager:ri,Socket:fc,io:Xn,connect:Xn});class kS{constructor(t=""){this.baseUrl=t}async get(t){return this.request("GET",t)}async post(t,n){return this.request("POST",t,n)}async del(t){return this.request("DELETE",t)}async request(t,n,s){try{const r=`${this.baseUrl}${n}`,i={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json"}};return s!==void 0&&t!=="GET"&&t!=="DELETE"&&(i.body=JSON.stringify(s)),await(await fetch(r,i)).json()}catch(r){return{success:!1,error:r.message??"Network error"}}}}let ii=null;function ES(e){ii=e}function p0(){if(!ii)throw new Error("Socket instance not initialized. Call setSocketInstance() first.");return ii}class PS{constructor(t){this.socket=t,ES(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()}}class TS{constructor(t){this.modalState=null,this.addToastFn=t??null}showToast(t,n,s="info"){this.addToastFn?this.addToastFn(t,n,s):console.warn("[UIService] No addToast callback registered — toast not shown:",t,n)}showModal(t,n){this.modalState={visible:!0,title:t,content:n}}closeModal(){this.modalState=null}getModalState(){return this.modalState}downloadFile(t,n,s="application/octet-stream"){const r=typeof t=="string"?new Blob([t],{type:s}):t,i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}}class NS{constructor(t){this.prefix=`edu_os_plugin:${t}:`}get(t){return localStorage.getItem(this.prefix+t)}set(t,n){localStorage.setItem(this.prefix+t,n)}delete(t){localStorage.removeItem(this.prefix+t)}clear(){this.prefix.length;const t=[];for(let n=0;n<localStorage.length;n++){const s=localStorage.key(n);s&&s.startsWith(this.prefix)&&t.push(s)}for(const n of t)localStorage.removeItem(n)}}function IS(e){const{session:t,host:n,activeRole:s,activeStudentId:r,selectedLesson:i,activeSegmentId:o,studentViewStatus:a,lang:c,students:u,addToast:d,setOnlineStudentIds:f,setActiveStudentLessons:m,setLessons:h,setActiveSegmentId:g,setLiveClassStudentProgress:x,setLiveClassAcknowledgedMap:v,setLiveClassFeed:w,setSelectedLesson:I,setStudentViewStatus:S,setLocalProgressPercent:P,fetchStudentDashboard:z,fetchStudents:E,fetchElements:L}=e,_=p.useRef(null),M=p.useRef(s),N=p.useRef(r),A=p.useRef(c),R=p.useRef(u),D=p.useRef(d),F=p.useRef(i);return p.useEffect(()=>{M.current=s},[s]),p.useEffect(()=>{N.current=r},[r]),p.useEffect(()=>{A.current=c},[c]),p.useEffect(()=>{R.current=u},[u]),p.useEffect(()=>{D.current=d},[d]),p.useEffect(()=>{F.current=i},[i]),p.useEffect(()=>{if(!t)return;const j=Xn();return _.current=j,n.isInitialized()||n.initialize(new kS,new PS(j),new TS(D.current),new NS("__app__")),M.current==="student"&&N.current&&j.emit("register-student",{studentId:N.current,name:R.current.find(T=>T.id===N.current)?.name||N.current}),j.emit("join-room","whiteboard-broadcast"),j.on("presence-update",T=>{f(T.onlineStudentIds),m(T.activeStudentLessons)}),j.on("lesson-progress-mode-changed",T=>{const{lessonId:$,progressMode:k,progressConditions:B}=T;h(y=>y.map(te=>te.id===$?{...te,progress_mode:k,progress_conditions:B}:te))}),j.on("student-active-segment-changed",T=>{const{activeSegmentId:$}=T;g($)}),j.on("student-pinged",T=>{const $=T.message||(A.current==="zh"?"⚠️ 学习进度预警:老师注意到您的进度有些落后,请抓紧时间跟上!":"⚠️ Progress Alert: The teacher noticed you are falling behind. Please keep up!");d(A.current==="zh"?"⚠️ 学习进度预警":"⚠️ Progress Warning",$,"warning")}),j.on("student-progress-updated",T=>{const{studentId:$,progressPercent:k,completed:B}=T;x(y=>{const te=y.findIndex(ae=>ae.student_id===$);if(te!==-1){const ae=[...y];return ae[te]={...ae[te],progress_percent:k,completed:B?1:0},ae}else return[...y,{student_id:$,progress_percent:k,completed:B?1:0}]})}),j.on("assignment-graded-toast",T=>{if(M.current==="student"&&N.current&&T.studentId===N.current){const $=T.assignmentTitle||T.assignmentId,k=A.current==="zh"?`您的作业"${$}"已完成评分!得分:${T.score}%。建议反馈已收到,快去查看。`:`Your assignment "${$}" was graded. Score: ${T.score}%. Tutoring feedback has been posted.`;d(A.current==="zh"?"🎓 作业已评分":"🎓 Assignment Graded",k,"success"),z(N.current)}}),j.on("student-picked",T=>{if(M.current==="student"&&N.current&&T.studentId===N.current){const $=A.current==="zh"?"闪电警报!您已被老师在课程随机提问点名中抽中!请立即集中注意力参与课堂。":"Attention alert! You have been randomly picked by the teacher! Please pay immediate attention.";d(A.current==="zh"?"⚡️ 随机点名提问":"⚡️ Classroom Pick Alert",$,"warning"),z(N.current)}w($=>[{id:`feed-pick-${T.studentId}-${T.pickedTime||Date.now()}`,time:new Date(T.pickedTime||Date.now()).toLocaleTimeString(),type:"picked",message:A.current==="zh"?`点名互动:随机抽中学生【${T.studentName}】。`:`Classroom Pick: Randomly selected student "${T.studentName}".`},...$])}),j.on("student-acknowledged",T=>{const{studentId:$}=T;v(k=>{const B=new Map(k);return B.set($,!0),B}),w(k=>[{id:`feed-ack-${$}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:A.current==="zh"?`学生已确认收到提问点名(学生 ID: ${$})。`:`Student acknowledged the classroom call (Student ID: ${$}).`},...k]),E()}),j.on("class-lock-status-changed",T=>{const{lessonId:$,locked:k}=T;M.current==="student"&&N.current?(Promise.resolve(E()).then(()=>{k&&$&&(I($),S("lesson"),d(A.current==="zh"?"🔒 课程已被锁定":"🔒 Lesson Locked",A.current==="zh"?"老师已锁定当前授课,您将无法切换到其他页面。":"The teacher has locked the active lesson. You cannot leave this page.","info"))}),z(N.current)):E()}),j.on("whiteboard-sync",T=>{const{roomId:$,type:k}=T||{};k==="refresh"&&$&&(L($),!F.current&&M.current==="student"&&(I($),S("lesson")),j.emit("join-room",$))}),()=>{j.disconnect(),_.current=null}},[t,s,r]),p.useEffect(()=>{_.current&&s==="student"&&r&&(a==="lesson"&&i?(_.current.emit("enter-lesson",{studentId:r,lessonId:i}),fetch(`/api/students/${r}/progress`).then(j=>j.json()).then(j=>{if(Array.isArray(j)){const T=j.find($=>$.lesson_id===i);P(T?T.progress_percent:0)}}).catch(console.error)):_.current.emit("leave-lesson",{studentId:r}))},[a,i,s,r]),p.useEffect(()=>{s==="teacher"&&i&&o&&_.current&&_.current.emit("teacher-broadcast-segment",{lessonId:i,activeSegmentId:o})},[o,i,s]),{socketRef:_}}const jS=`exports.default = {