openlearn-next 0.3.19 → 0.3.21

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 (31) hide show
  1. package/dist/assets/{BatchPickerModal-MnNnNwFT.js → BatchPickerModal-CPmu_uF8.js} +1 -1
  2. package/dist/assets/{ClassesView-CpblTKWg.js → ClassesView-TVobZ_Vs.js} +1 -1
  3. package/dist/assets/{CloudDriveModal-BMjXCoju.js → CloudDriveModal-ul9v6wHK.js} +1 -1
  4. package/dist/assets/{CourseManagement-BqlboC1S.js → CourseManagement-DFQsUxE1.js} +1 -1
  5. package/dist/assets/{CourseWizardModal-DO1n4T2T.js → CourseWizardModal-D92teHMD.js} +1 -1
  6. package/dist/assets/{Dashboard-CfgOPb6z.js → Dashboard-CY138ODd.js} +1 -1
  7. package/dist/assets/{ExportWeightModal-d9A2R6Ur.js → ExportWeightModal-BvoODxwp.js} +1 -1
  8. package/dist/assets/{HelpView-bHc3tQPD.js → HelpView-CHkXbtfB.js} +1 -1
  9. package/dist/assets/{ImportLessonsModal-C25NubUA.js → ImportLessonsModal-YuTV3mnv.js} +1 -1
  10. package/dist/assets/{InteractiveCoursewareViewer-BcXVoPUb.js → InteractiveCoursewareViewer-BBeuViik.js} +1 -1
  11. package/dist/assets/{InteractiveWhiteboard-BxvOZE3l.js → InteractiveWhiteboard-BASy3Ak8.js} +1 -1
  12. package/dist/assets/{LazyCourseware-D3_YrYGR.js → LazyCourseware-Du9MgZyH.js} +2 -2
  13. package/dist/assets/{LazyWhiteboard-CFPDpdYV.js → LazyWhiteboard-CpSzdON0.js} +2 -2
  14. package/dist/assets/{LessonEditorView-CYHcC9EA.js → LessonEditorView-D9YYZQyP.js} +1 -1
  15. package/dist/assets/{LiveClassroomView-BSPW9gVe.js → LiveClassroomView-B2lKKiZK.js} +1 -1
  16. package/dist/assets/{NotificationDetailModal-D4w-m1D-.js → NotificationDetailModal-BthQNwyd.js} +1 -1
  17. package/dist/assets/PluginView-CQLEVURc.js +65 -0
  18. package/dist/assets/{QuizGeneratorModal-bCASRfsi.js → QuizGeneratorModal-Bp4pUx-H.js} +1 -1
  19. package/dist/assets/{StudentAssignmentView-B0b4spYC.js → StudentAssignmentView-B-jN_m_B.js} +1 -1
  20. package/dist/assets/{StudentLessonView-SLcpNqtY.js → StudentLessonView-8-zC7BLx.js} +1 -1
  21. package/dist/assets/{StudentPreviewModal-nO5C3nq5.js → StudentPreviewModal-DZdcKy1x.js} +1 -1
  22. package/dist/assets/{StudentView-BtleJCxa.js → StudentView-Cg5G4Guz.js} +2 -2
  23. package/dist/assets/{SystemResourceLibraryModal-D00BK5Xh.js → SystemResourceLibraryModal-CJ16MGxn.js} +1 -1
  24. package/dist/assets/{TeacherView-BP04D9dn.js → TeacherView-_n9QWf7y.js} +2 -2
  25. package/dist/assets/{index-hTc1h9s2.js → index-BApV4fuy.js} +3 -3
  26. package/dist/assets/index-Ch_mD6B0.css +1 -0
  27. package/dist/index.html +2 -2
  28. package/dist/server.cjs +126 -49
  29. package/package.json +1 -1
  30. package/dist/assets/PluginView-DogON4Dd.js +0 -65
  31. package/dist/assets/index-CM3Tw-Rg.css +0 -1
@@ -1,7 +1,7 @@
1
1
  import{R as Je,r as p,j as a,u as Nf,g as Tl,b as Pf,d as ui,h as di,J as Wo,i as Go,k as Tf}from"./vendor-react-B0t7H3hh.js";import{G as Qo,S as If,U as Il,C as hi,a as In,L as fi,A as Jo,b as Ps,c as Oi,P as pi,d as Zo,D as Yo,X as ot,e as yt,f as _n,g as Af,h as zf,T as Al,E as Ts,B as Di,R as zl,i as _f,j as An,k as Lf,M as Rf,l as Mf,m as Of,n as Df,H as _l,o as Ff,p as Bf,q as Ll,r as Ln,s as mi,t as $f,K as Vf,u as Uf,v as ls,w as Hf,x as Fi,y as qf,z as Bi,F as Wf,I as Gf,J as Qf,N as Jf,O as Rl,Q as Zf,V as Yf,W as Kf,Y as Xf,Z as ep,_ as $i,$ as zr,a0 as tp,a1 as np,a2 as sp,a3 as rp,a4 as Ml,a5 as Ol,a6 as ip,a7 as Ko,a8 as op,a9 as Xo}from"./vendor-icons-B2DRJfZU.js";import{_ as Ie,E as ap}from"./vendor-pdf-Bw0ZQZtM.js";import{e as Vi,f as bt,h as Is}from"./vendor-utils-m0Urvtws.js";import{i as _r,g as lp,s as Dl,a as Ui,b as Fl,c as ea,d as cp,e as up,f as dp,h as hp,r as fp,j as pp,k as Bl,l as mp,m as gp,n as xp,o as yp,S as bp,H as wp,F as At,p as Sp,q as vp,t as $l,u as Ss,v as ta,w as et,x as Vl,y as Cp,z as na,A as kp,B as vs,C as gi,D as sa,E as Ep,G as jp,I as Pt,J as Np,K as Pp,L as Tp,M as ra,N as Ip,O as Ap,P as ia,Q as zp,R as _p,T as cs,U as Lp,V as Rp,W as Ul,X as Mp,Y as Op}from"./vendor-motion-DjY2czvL.js";import{v as Dp}from"./vendor-pptx-C5-U7ieS.js";import{R as oa}from"./vendor-charts-U9fLlNC_.js";const Fp=e=>{const t=e.split(/\r?\n/);if(t.length<2)return[];const n=t[0],s=[",",";"," "];let r=",",i=0;s.forEach(g=>{const y=n.split(g).length;y>i&&(i=y,r=g)});const o=g=>{const y=[];let C=!1,w="";for(let N=0;N<g.length;N++){const S=g[N];S==='"'?C=!C:S===r&&!C?(y.push(w.trim()),w=""):w+=S}return y.push(w.trim()),y},l=o(n).map(g=>g.toLowerCase().replace(/["'\r]/g,"").trim()),c=l.findIndex(g=>g.includes("student_number")||g.includes("studentnumber")||g.includes("student_id")||g.includes("studentid")||g.includes("学号")||g.includes("编号")||g.includes("id")&&!g.includes("class")&&!g.includes("lesson")),u=l.findIndex(g=>g.includes("name")||g.includes("姓名")||g.includes("student")&&!g.includes("num")&&!g.includes("id")||g.includes("学生")&&!g.includes("号")),d=l.findIndex(g=>g.includes("email")||g.includes("mail")||g.includes("邮箱")),h=u>=0?u:0,m=d>=0?d:1,f=[];for(let g=1;g<t.length;g++){if(!t[g].trim())continue;const y=o(t[g]),C=y[h]?y[h].replace(/["'\r]/g,"").trim():"",w=y[m]?y[m].replace(/["'\r]/g,"").trim():"",N=c>=0&&y[c]?y[c].replace(/["'\r]/g,"").trim():void 0;C&&f.push({name:C,email:w,...N?{student_number:N}:{}})}return f},aa={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"}},Bp=Je.memo(function({onLoginSuccess:t,lang:n}){const[s,r]=p.useState("teacher"),[i,o]=p.useState(null),[l,c]=p.useState(""),[u,d]=p.useState(""),[h,m]=p.useState(""),[f,g]=p.useState(!1),[y,C]=p.useState([]),[w,N]=p.useState(""),[S,E]=p.useState(""),[I,k]=p.useState(""),[z,D]=p.useState(""),[F,_]=p.useState(!1);p.useEffect(()=>{(async()=>{try{const R=await fetch("/api/students");if(R.ok){const P=await R.json();C(P),P.length>0&&N(P[0].id)}}catch(R){console.warn("Failed to fetch student roster for login selection:",R)}})()},[]),p.useEffect(()=>{(async()=>{try{const R=await fetch("/api/site-settings");if(R.ok){const P=await R.json();o(P)}}catch(R){console.warn("Failed to fetch site settings for login branding:",R)}})()},[]);const A=async O=>{if(O.preventDefault(),!l.trim()||!u){m(n==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{m(""),g(!0);const R=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:l.trim(),password:u})});if(R.ok){const P=await R.json();t(P.session)}else{const P=await R.json();m(P.error||(n==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{m(n==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{g(!1)}},L=async O=>{O.preventDefault();const R=w||S.trim();if(!R){D(n==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!I.trim()){D(n==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{D(""),_(!0);const P=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:R,password:I.trim()})});if(P.ok){const T=await P.json();t(T.session)}else{const T=await P.json();D(T.error||(n==="zh"?"找不到该学生记录":"Student record not found"))}}catch{D(n==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{_(!1)}};return a.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:[a.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),a.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),a.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:[a.jsxs("div",{className:"text-center mb-8",children:[i?.logoUrl?a.jsx("img",{src:i.logoUrl,alt:i.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):a.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:a.jsx(Qo,{size:32})}),a.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"," ",a.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"})]}),a.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:i?.slogan||(n==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),a.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[a.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:[a.jsx(If,{size:14}),n==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),a.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:[a.jsx(Il,{size:14}),n==="zh"?"学生自助端":"Student Self-Service"]})]}),s==="teacher"?a.jsxs("form",{onSubmit:A,className:"space-y-4",children:[h&&a.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:[a.jsx(hi,{size:15,className:"shrink-0"}),a.jsx("span",{children:h})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(In,{size:13}),n==="zh"?"教工账户名 / username":"Staff Username"]}),a.jsx("input",{type:"text",value:l,onChange:O=>c(O.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})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(fi,{size:13}),n==="zh"?"输入登录密码 / password":"Access Password"]}),a.jsx("input",{type:"password",value:u,onChange:O=>d(O.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})]}),a.jsxs("button",{type:"submit",disabled:f,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:[a.jsx("span",{children:f?n==="zh"?"鉴权登录中...":"Authorizing...":n==="zh"?"安全验证登录":"Authorized Sign In"}),a.jsx(Jo,{size:15})]})]}):a.jsxs("form",{onSubmit:L,className:"space-y-4",children:[z&&a.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:[a.jsx(hi,{size:15,className:"shrink-0"}),a.jsx("span",{children:z})]}),y.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(Qo,{size:14}),n==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),a.jsx("select",{value:w,onChange:O=>{N(O.target.value),E("")},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:y.map(O=>a.jsxs("option",{value:O.id,children:[O.name," (",O.student_number||O.id,")"]},O.id))}),a.jsx("p",{className:"text-xs text-slate-500 font-medium",children:n==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,a.jsxs("div",{className:"relative flex py-2 items-center",children:[a.jsx("div",{className:"flex-grow border-t border-slate-850"}),a.jsx("span",{className:"flex-shrink mx-3 text-xs font-bold text-slate-500 uppercase tracking-wider",children:n==="zh"?"或手动输入学号":"Or input key manually"}),a.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(In,{size:13}),n==="zh"?"学号 / Student ID":"Student Access Key"]}),a.jsx("input",{type:"text",value:S,onChange:O=>{E(O.target.value),N("")},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"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(fi,{size:13}),n==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),a.jsx("input",{type:"password",required:!0,value:I,onChange:O=>k(O.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"})]}),a.jsxs("button",{type:"submit",disabled:F,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:[a.jsx("span",{children:F?n==="zh"?"正在连接学生终端...":"Entering Desk...":n==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),a.jsx(Jo,{size:15})]})]})]})]})});function $p({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 l=(c,u)=>t==="zh"?c:u;return a.jsxs("div",{className:"relative",ref:o,children:[a.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:[a.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?a.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):a.jsx(In,{size:20})}),a.jsx(Ps,{size:14,className:`text-gray-400 transition-transform duration-200 ${r?"rotate-180":""}`})]}),r&&a.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:[a.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[a.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),a.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),a.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:[a.jsx(In,{size:16,className:"text-gray-400"}),l("个人资料","Profile")]}),a.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:[a.jsx(Oi,{size:16}),l("注销登录","Sign Out")]})]})]})}const Vp=[{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"}],us={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"}},Lr="openlearn_theme",xn="openlearn_custom_themes",Cs={};function Hi(e){return Cs[e]?Cs[e]:e in us?us[e]:us.light}function Rr(e){typeof document>"u"||document.documentElement.setAttribute("data-theme",e)}function Up(e,t){if(typeof document>"u")return;Cs[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 Hp(e){if(typeof document>"u")return;delete Cs[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function Mr(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastThemeToIframes:t}=await Ie(async()=>{const{broadcastThemeToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastThemeToIframes:n}},void 0);t(e,Hi(e))}catch{}},0)}catch{}}const As=Vi((e,t)=>({theme:"light",availableThemes:[...Vp],initTheme:()=>{if(typeof window>"u")return;try{const r=localStorage.getItem(xn);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(Lr)||"light";Rr(s),e({theme:s}),Mr(s)},setTheme:n=>{Rr(n),typeof window<"u"&&localStorage.setItem(Lr,n),e({theme:n}),Mr(n)},registerTheme:(n,s)=>{s&&Up(n.id,s),e(r=>({availableThemes:[...r.availableThemes.filter(o=>o.id!==n.id),n]}))},unregisterTheme:n=>{Hp(n),e(s=>{const r=s.availableThemes.filter(o=>o.id!==n),i=s.theme===n?"light":s.theme;return s.theme===n&&(Rr("light"),typeof window<"u"&&localStorage.setItem(Lr,"light"),Mr("light")),{availableThemes:r,theme:i}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const r=localStorage.getItem(xn);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(xn,JSON.stringify(i))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(xn);if(s){let r=JSON.parse(s);Array.isArray(r)&&(r=r.filter(i=>i.spec.id!==n),localStorage.setItem(xn,JSON.stringify(r)))}}catch{}t().unregisterTheme(n)}})),qp=[{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"}}],la={...us.light};function Wp({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:r,deleteCustomTheme:i}=As(),o=p.useId(),[l,c]=p.useState("custom-mytheme"),[u,d]=p.useState("我的专属主题"),[h,m]=p.useState("自定义教学调色板配置"),[f,g]=p.useState({...la}),[y,C]=p.useState("none"),[w,N]=p.useState(""),[S,E]=p.useState(!1),[I,k]=p.useState(null);if(!e)return null;const z=s.filter(j=>j.category==="custom"),D=j=>{k(j),setTimeout(()=>k(null),3e3)},F=j=>{c(j.id),d(j.label),m(j.description),g({...j.tokens}),D(`已载入预设: ${j.label}`)},_=j=>{c(j.id),d(j.label),m(j.description);const $=Hi(j.id);$&&Object.keys($).length>0&&g({...$}),D(`已载入自定义主题: ${j.label}`)},A=(j,$)=>{g(x=>({...x,[j]:$}))},L=()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!j){alert("请输入有效的主题标识 (ID)");return}const $={id:j,label:u.trim()||"未命名主题",description:h.trim()||"自定义主题",previewBg:f["--bg-app"]||"#ffffff",previewPrimary:f["--color-primary"]||"#4f46e5",category:"custom"};r($,f),D(`主题「${$.label}」已保存并成功激活!`)},O=()=>{N(JSON.stringify({version:"1.0",id:l,label:u,description:h,tokens:f},null,2)),C("export")},R=()=>{N(""),C("import")},P=()=>{try{const j=JSON.parse(w);if(!j.tokens||typeof j.tokens!="object")throw new Error("缺少合法的 tokens 字段");j.id&&c(j.id),j.label&&d(j.label),j.description&&m(j.description),g($=>({...$,...j.tokens})),C("none"),D("主题配置导入成功!")}catch(j){alert(`导入失败: ${j.message||"JSON 格式解析错误"}`)}},T=()=>{navigator.clipboard.writeText(w),E(!0),setTimeout(()=>E(!1),2e3)},W=[{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 a.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:a.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:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:a.jsx(pi,{size:22})}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",a.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"})]}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:R,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导入 JSON",children:[a.jsx(Zo,{size:14}),n==="zh"?"导入配置":"Import"]}),a.jsxs("button",{onClick:O,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导出 JSON",children:[a.jsx(Yo,{size:14}),n==="zh"?"导出配置":"Export"]}),a.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:a.jsx(ot,{size:18})})]})]}),I&&a.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:[a.jsx(yt,{size:14}),I]}),a.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[a.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[a.jsxs("section",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(_n,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),a.jsx("span",{className:"text-xs text-muted",children:"一键填入调色板"})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:qp.map(j=>a.jsxs("button",{onClick:()=>F(j),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:[a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.tokens["--color-primary"]}}),j.label]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-app"]}}),a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-surface"]}})]})]}),a.jsx("p",{className:"text-xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:j.description})]},j.id))})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(Af,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-themeId`,className:"block text-xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),a.jsx("input",{id:`${o}-themeId`,type:"text",value:l,onChange:j=>c(j.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"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-label`,className:"block text-xs font-medium text-muted mb-1",children:"主题名称"}),a.jsx("input",{id:`${o}-label`,type:"text",value:u,onChange:j=>d(j.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"})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-description`,className:"block text-xs font-medium text-muted mb-1",children:"主题描述"}),a.jsx("input",{id:`${o}-description`,type:"text",value:h,onChange:j=>m(j.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"})]})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(pi,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),a.jsx("div",{className:"space-y-2.5",children:W.map(j=>{const $=f[j.key]||"#000000";return a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-medium text-main",children:j.labelZh}),a.jsx("span",{className:"text-xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:j.key})]}),a.jsx("p",{className:"text-xs text-muted mt-0.5",children:j.desc})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("div",{className:"relative flex items-center",children:a.jsx("input",{type:"color",value:$.startsWith("#")&&$.length===7?$:"#4f46e5",onChange:x=>A(j.key,x.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),a.jsx("input",{type:"text",value:$,onChange:x=>A(j.key,x.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"})]})]},j.key)})})]}),z.length>0&&a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(zf,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),a.jsx("div",{className:"space-y-2",children:z.map(j=>a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[a.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.previewPrimary}}),a.jsxs("div",{className:"truncate",children:[a.jsx("div",{className:"text-xs font-semibold text-main truncate",children:j.label}),a.jsx("div",{className:"text-xs text-muted truncate",children:j.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[a.jsx("button",{onClick:()=>_(j),className:"px-2 py-1 text-xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),a.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${j.label}」吗?`)&&(i(j.id),D(`已删除主题「${j.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:a.jsx(Al,{size:13})})]})]},j.id))})]})]}),a.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[a.jsx(Ts,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),a.jsxs("span",{className:"text-xs text-muted font-mono",children:["当前预览: ",u," (",l,")"]})]}),a.jsxs("div",{className:"flex-1 rounded-2xl border shadow-inner overflow-hidden flex flex-col transition-colors duration-200",style:{backgroundColor:f["--bg-app"]||"#f8fafc",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:[a.jsxs("div",{className:"h-12 border-b px-4 flex items-center justify-between shrink-0",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-white text-xs",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"OL"}),a.jsx("span",{className:"font-bold text-xs",style:{color:f["--text-main"]},children:"OpenLearn V2"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"text-xs px-2 py-0.5 rounded-md font-mono",style:{backgroundColor:f["--bg-surface-secondary"]||"#f1f5f9",color:f["--text-muted"]||"#64748b"},children:"10:30:00"}),a.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"T"})]})]}),a.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[a.jsxs("div",{className:"p-4 rounded-xl border shadow-xs space-y-3",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-bold text-sm",style:{color:f["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),a.jsx("p",{className:"text-xs mt-1",style:{color:f["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:f["--bg-surface-secondary"],color:f["--color-primary"],border:`1px solid ${f["--border-theme"]}`},children:"进行中"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"光电门测速 (v)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"2.43 m/s"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"动能增量 (ΔEk)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--color-primary"]},children:"0.589 J"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"误差率 (Err)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"0.84 %"})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.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:f["--color-primary"]||"#4f46e5"},children:"开始数据采集"}),a.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors cursor-pointer",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:"重置实验"}),a.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:f["--text-muted"]},children:"查看教案"})]})]}),a.jsxs("div",{className:"p-3 rounded-xl border space-y-2",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme-subtle"]||"#f1f5f9"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs font-semibold",style:{color:f["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),a.jsx("span",{className:"text-xs font-mono",style:{color:f["--text-muted"]},children:"60 FPS"})]}),a.jsxs("div",{className:"h-28 rounded-lg border border-dashed flex items-center justify-center p-3 relative overflow-hidden",style:{backgroundColor:f["--bg-app"],borderColor:f["--border-theme"]},children:[a.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:f["--color-primary"]},children:a.jsx(Di,{size:20})}),a.jsx("div",{className:"absolute bottom-2 right-2 text-xs font-mono px-1.5 py-0.5 rounded border",style:{backgroundColor:f["--bg-surface"],borderColor:f["--border-theme"],color:f["--text-muted"]},children:"iframe Bridge Sync Ready"})]})]})]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("button",{onClick:()=>{g({...la}),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",children:[a.jsx(zl,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("button",{onClick:L,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:[a.jsx(_f,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),y!=="none"&&a.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:a.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:y==="export"?a.jsxs(a.Fragment,{children:[a.jsx(Yo,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):a.jsxs(a.Fragment,{children:[a.jsx(Zo,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),a.jsx("button",{onClick:()=>C("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:a.jsx(ot,{size:16})})]}),a.jsx("div",{children:a.jsx("textarea",{value:w,readOnly:y==="export",onChange:j=>N(j.target.value),placeholder:y==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),a.jsx("div",{className:"flex items-center justify-end gap-2",children:y==="export"?a.jsx(a.Fragment,{children:a.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?a.jsx(yt,{size:14}):a.jsx(An,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>C("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"}),a.jsx("button",{onClick:P,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 Gp({lang:e="zh"}){const[t,n]=p.useState(!1),[s,r]=p.useState(!1),i=p.useRef(null),{theme:o,availableThemes:l,setTheme:c}=As();p.useEffect(()=>{function d(h){i.current&&!i.current.contains(h.target)&&n(!1)}return t&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[t]);const u=d=>{switch(d){case"dark":return a.jsx(Rf,{size:16,className:"text-indigo-400"});case"eyecare":return a.jsx(Ts,{size:16,className:"text-emerald-500"});case"chalkboard":return a.jsx(pi,{size:16,className:"text-green-400"});case"light":default:return a.jsx(Lf,{size:16,className:"text-amber-500"})}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative",ref:i,children:[a.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&&a.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:[a.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[a.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),a.jsx("div",{className:"space-y-1",children:l.map(d=>{const h=o===d.id;return a.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 ${h?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.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}}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-main leading-none",children:d.label}),a.jsx("div",{className:"text-xs text-muted mt-1 leading-tight opacity-80",children:d.description})]})]}),h&&a.jsx(yt,{size:14,className:"text-primary-theme shrink-0"})]},d.id)})}),a.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:a.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:[a.jsx(_n,{size:14}),a.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),a.jsx(Wp,{isOpen:s,onClose:()=>r(!1),lang:e})]})}const Or="openlearn_font_scale",Zt=85,Yt=140,Dr=5,ds=100,ca=[{scale:90,labelZh:"紧凑 (90%)",labelEn:"Compact (90%)"},{scale:100,labelZh:"标准 (100%)",labelEn:"Standard (100%)"},{scale:110,labelZh:"中大 (110%)",labelEn:"Medium (110%)"},{scale:120,labelZh:"大号 (120%)",labelEn:"Large (120%)"},{scale:130,labelZh:"特大 (130%)",labelEn:"Extra Large (130%)"}];function Fr(e){if(typeof document>"u")return;const t=Math.min(Yt,Math.max(Zt,Math.round(e)));document.documentElement.style.fontSize=`${t}%`,document.documentElement.style.setProperty("--app-font-scale",(t/100).toFixed(2)),document.documentElement.setAttribute("data-font-scale",String(t))}function Br(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastFontScaleToIframes:t}=await Ie(async()=>{const{broadcastFontScaleToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastFontScaleToIframes:n}},void 0);t(e)}catch{}},0)}catch{}}const Xt=Vi((e,t)=>({scale:ds,minScale:Zt,maxScale:Yt,step:Dr,initFontSize:()=>{if(typeof window>"u")return;let n=ds;try{const s=localStorage.getItem(Or);if(s){const r=Number(s);!isNaN(r)&&r>=Zt&&r<=Yt&&(n=r)}}catch{}Fr(n),e({scale:n}),Br(n);try{window.addEventListener("storage",s=>{if(s.key===Or&&s.newValue){const r=Number(s.newValue);!isNaN(r)&&r>=Zt&&r<=Yt&&(Fr(r),e({scale:r}),Br(r))}})}catch{}},setScale:n=>{const s=Math.min(Yt,Math.max(Zt,Math.round(n)));if(Fr(s),typeof window<"u")try{localStorage.setItem(Or,String(s))}catch{}e({scale:s}),Br(s)},increaseScale:()=>{const n=t().scale,s=Math.min(Yt,n+Dr);t().setScale(s)},decreaseScale:()=>{const n=t().scale,s=Math.max(Zt,n-Dr);t().setScale(s)},resetScale:()=>{t().setScale(ds)}}));function Hl({lang:e="zh"}){const[t,n]=p.useState(!1),s=p.useRef(null),{scale:r,minScale:i,maxScale:o,setScale:l,increaseScale:c,decreaseScale:u,resetScale:d}=Xt();p.useEffect(()=>{function f(g){s.current&&!s.current.contains(g.target)&&n(!1)}return t&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[t]);const h=ca.find(f=>f.scale===r),m=r===ds;return a.jsxs("div",{className:"relative",ref:s,children:[a.jsxs("button",{type:"button",onClick:()=>n(!t),title:e==="zh"?`界面字体缩放: ${r}%(点击调节)`:`Interface Font Scaling: ${r}% (Click to adjust)`,className:`p-2 hover:bg-surface-secondary transition-colors rounded-lg border shadow-3xs flex items-center justify-center shrink-0 cursor-pointer relative ${m?"bg-surface border-theme text-main":"bg-primary-theme-light border-primary-theme text-primary-theme font-bold"}`,"aria-label":"Font size selector","aria-expanded":t,children:[a.jsx(Mf,{size:16}),!m&&a.jsxs("span",{className:"absolute -bottom-1 -right-1 text-xs px-1 py-0.2 rounded-full bg-primary-theme text-white font-extrabold leading-none shadow-xs",children:[r,"%"]})]}),t&&a.jsxs("div",{className:"absolute right-0 mt-2 w-72 rounded-xl border border-theme bg-surface shadow-xl z-50 p-3 overflow-hidden animate-in fade-in zoom-in-95 duration-100 select-none",children:[a.jsxs("div",{className:"px-1 pb-2 border-b border-theme-subtle mb-2.5 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-main",children:e==="zh"?"界面字号大小":"Interface Font Size"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"全局等比缩放排版与文字":"Proportionally scale typography"})]}),!m&&a.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1 text-xs text-muted hover:text-primary-theme transition-colors cursor-pointer px-1.5 py-0.5 rounded hover:bg-surface-secondary",title:e==="zh"?"恢复默认 100%":"Reset to 100%",children:[a.jsx(zl,{size:11}),a.jsx("span",{children:e==="zh"?"重置":"Reset"})]})]}),a.jsxs("div",{className:"bg-surface-secondary/70 rounded-lg p-2 flex items-center justify-between mb-3 border border-theme-subtle",children:[a.jsx("button",{type:"button",onClick:u,disabled:r<=i,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"减小字体 (A-)":"Decrease (A-)",children:a.jsx(Of,{size:14})}),a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-sm font-black text-main leading-tight",children:[r,"%"]}),a.jsx("div",{className:"text-xs text-muted",children:h?e==="zh"?h.labelZh.split(" ")[0]:h.labelEn.split(" ")[0]:e==="zh"?"自定义比例":"Custom"})]}),a.jsx("button",{type:"button",onClick:c,disabled:r>=o,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"增大字体 (A+)":"Increase (A+)",children:a.jsx(Df,{size:14})})]}),a.jsxs("div",{className:"space-y-1 mb-3",children:[a.jsx("div",{className:"text-xs font-bold text-muted uppercase tracking-wider px-1",children:e==="zh"?"常用档位":"Presets"}),a.jsx("div",{className:"grid grid-cols-1 gap-1",children:ca.map(f=>{const g=r===f.scale;return a.jsxs("button",{type:"button",onClick:()=>l(f.scale),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs transition-all cursor-pointer ${g?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/30":"text-main hover:bg-surface-secondary border border-transparent"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-60"}),a.jsx("span",{children:e==="zh"?f.labelZh:f.labelEn})]}),g&&a.jsx(yt,{size:13,className:"text-primary-theme shrink-0"})]},f.scale)})})]}),a.jsxs("div",{className:"p-2.5 rounded-lg border border-theme-subtle bg-surface-secondary/40 mb-2",children:[a.jsxs("div",{className:"text-xs text-muted mb-1 flex items-center justify-between",children:[a.jsx("span",{children:e==="zh"?"实时效果预览":"Live Preview"}),a.jsxs("span",{children:[r,"%"]})]}),a.jsx("p",{className:"text-xs text-main font-medium leading-relaxed",children:e==="zh"?"让每一个文字都清晰舒适,智能赋能教学。":"Clear and comfortable typography empowers modern teaching."})]}),a.jsx("div",{className:"text-xs text-muted/80 text-center px-1",children:e==="zh"?"快捷键:Ctrl + Alt + 加号/减号":"Shortcut: Ctrl + Alt + +/-"})]})]})}function Qp(e){const{activeRole:t,lang:n,teacherTab:s,studentViewStatus:r,session:i,activeStudentId:o,students:l,studentDashboardData:c,isNotificationsOpen:u,studentNotifications:d,unreadNotifications:h,readNotifications:m,dbConnected:f,dbStatus:g,siteInfo:y,setActiveStudentId:C,setReadNotifications:w,setIsSystemResourceLibraryOpen:N,setProfileOpen:S,setTeacherTab:E,setStudentViewStatus:I,setIsNotificationsOpen:k,setSelectedNotificationForModal:z,handleLogout:D,toggleLanguage:F,setActiveRole:_,isStudentLocked:A=!1,onBlockedNavigate:L}=e,O=t==="student"&&A,R=()=>{if(O){L?.();return}t==="teacher"?E("dashboard"):t==="student"&&I("dashboard")};return a.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:[a.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[a.jsxs("button",{onClick:R,className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:O?n==="zh"?"全班专注锁定中,无法返回系统总览":"Class focus locked — cannot return to dashboard":n==="zh"?"返回系统总览":"Back to Dashboard",children:[y.logoUrl?a.jsx("img",{src:y.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):a.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"}),a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:y.siteName||"OpenLearn Next"}),a.jsxs("span",{className:"text-xs font-medium text-slate-400 tracking-tight",children:["v","0.3.19"]}),y.slogan&&a.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:y.slogan})]})]}),a.jsxs("button",{onClick:R,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"} ${O?"opacity-50":""}`,children:[O?a.jsx(fi,{size:16}):a.jsx(_l,{size:16}),n==="zh"?"系统总览":"Dashboard"]}),t==="student"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),a.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[a.jsx(Ff,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&i?.role==="teacher"&&a.jsxs("div",{className:"flex items-center gap-2 bg-amber-50/90 border border-amber-200/80 px-2.5 py-1 rounded-lg shadow-2xs",children:[a.jsxs("span",{className:"text-xs font-semibold text-amber-800 flex items-center gap-1",children:[a.jsx(Ts,{size:13,className:"text-amber-600"}),n==="zh"?"模拟学生:":"View as:"]}),a.jsxs("select",{className:"border border-amber-300 rounded px-1.5 py-0.5 text-xs bg-white text-gray-800 font-medium focus:ring-1 focus:ring-amber-400 focus:outline-hidden",value:o||"",onChange:P=>C(P.target.value),children:[a.jsxs("option",{value:"",children:["-- ",n==="zh"?"选择学生":"Select Student"," --"]}),l.map(P=>a.jsx("option",{value:P.id,children:P.name},P.id))]}),_&&a.jsxs("button",{type:"button",onClick:()=>_("teacher"),className:"ml-1 px-2.5 py-1 bg-amber-600 hover:bg-amber-700 active:bg-amber-800 text-white text-xs font-bold rounded-md flex items-center gap-1 transition-all cursor-pointer shadow-2xs",title:n==="zh"?"退出模拟学生并返回教师端工作台":"Exit student view and return to teacher workspace",children:[a.jsx(Oi,{size:12}),n==="zh"?"返回教师端":"Exit Student View"]})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>k(!u),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[a.jsx(Bf,{size:20}),h.length>0&&a.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:h.length})]}),u&&a.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:[a.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),h.length>0&&a.jsx("button",{onClick:async()=>{if(!o)return;try{const T=d.filter(W=>!m.has(W.id)).map(W=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:W.id})}));await Promise.all(T)}catch(T){console.error(T)}const P=new Set(m);d.forEach(T=>P.add(T.id)),w(P)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),a.jsx("div",{className:"max-h-96 overflow-y-auto",children:d.length===0?a.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):a.jsx("div",{className:"divide-y divide-gray-100",children:d.map(P=>{const T=!m.has(P.id);return a.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${T?"bg-indigo-50/30":""}`,onClick:()=>{if(T){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:P.id})}).catch(console.error);const j=new Set(m);j.add(P.id),w(j)}const W=c?.assignments?.find(j=>j.id===P.relatedId);z({...P,assignment:W}),k(!1)},children:a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"mt-0.5",children:P.type==="new_assignment"?a.jsx(Ll,{size:16,className:"text-indigo-500"}):P.type==="rollcall_picked"?a.jsx(_n,{size:16,className:"text-amber-500 animate-pulse"}):a.jsx(Ln,{size:16,className:"text-green-500"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`text-sm ${T?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:P.title}),a.jsx("div",{className:`text-xs mt-0.5 ${T?"text-gray-600":"text-gray-500"}`,children:P.message})]}),T&&a.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},P.id)})})})]})]}),a.jsxs("button",{onClick:()=>N(!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:[a.jsx(mi,{size:14,className:"text-emerald-500 animate-pulse"}),n==="zh"?"系统资源库":"System Resource Library"]}),a.jsx("button",{onClick:F,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:a.jsx(mi,{size:16})}),a.jsx(Hl,{lang:n}),a.jsx(Gp,{lang:n}),(()=>{const P=g==="error"||!f?{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 a.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 ${P.bg}`,title:P.label,children:[a.jsx($f,{size:15}),a.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[a.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${P.ping}`}),a.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${P.dot}`})]})]})})(),a.jsx($p,{session:i,lang:n,onLogout:D,onProfile:()=>S(!0)})]})]})}const Jp="openlearn_live_classroom_sync";class ua{constructor(t=Jp){this.channel=null,this.isDestroyed=!1,this.messageListeners=[],typeof window<"u"&&typeof window.BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(t),this.channel.onmessage=n=>{this.isDestroyed||!n.data||this.messageListeners.forEach(s=>{try{s(n.data)}catch(r){console.error("[ClassroomSyncChannel] Listener error:",r)}})})}onMessage(t){return this.messageListeners.push(t),()=>{this.messageListeners=this.messageListeners.filter(n=>n!==t)}}postMessage(t){if(!(this.isDestroyed||!this.channel))try{this.channel.postMessage(t)}catch(n){console.warn("[ClassroomSyncChannel] Failed to post message:",n)}}broadcastInitState(t){this.postMessage({type:"TEACHER_INIT_STATE",payload:t})}broadcastChangeLesson(t){this.postMessage({type:"TEACHER_CHANGE_LESSON",payload:{lessonId:t}})}broadcastChangeSegment(t){this.postMessage({type:"TEACHER_CHANGE_SEGMENT",payload:{segmentId:t}})}broadcastChangeTab(t){this.postMessage({type:"TEACHER_CHANGE_TAB",payload:{tab:t}})}broadcastLockClass(t){this.postMessage({type:"TEACHER_LOCK_CLASS",payload:{locked:t}})}broadcastPickStudent(t,n){this.postMessage({type:"TEACHER_PICK_STUDENT",payload:{studentId:t,studentName:n}})}broadcastSyncTimer(t,n){this.postMessage({type:"TEACHER_SYNC_TIMER",payload:{timeRemaining:t,isRunning:n}})}broadcastPingStudent(t,n){this.postMessage({type:"TEACHER_PING_STUDENT",payload:{studentId:t,message:n}})}broadcastFullscreen(t,n){this.postMessage({type:"TEACHER_BROADCAST_FULLSCREEN",payload:{elementId:t,lessonId:n}})}requestHandshake(){this.postMessage({type:"STUDENT_HANDSHAKE_REQUEST"})}acknowledgePick(t){this.postMessage({type:"STUDENT_ACKNOWLEDGE_PICK",payload:{studentId:t}})}sendHeartbeat(t){this.postMessage({type:"STUDENT_HEARTBEAT",payload:{studentId:t,timestamp:Date.now()}})}destroy(){this.isDestroyed=!0,this.messageListeners=[],this.channel&&(this.channel.close(),this.channel=null)}}const tn=bt(e=>({remoteFullscreenElementId:null,setRemoteFullscreenElementId:t=>e({remoteFullscreenElementId:t}),clearRemoteFullscreen:()=>e({remoteFullscreenElementId:null})})),pC=e=>Is(tn,e);function Zp({open:e,session:t,lang:n,onClose:s,onSaved:r,onAvatar:i}){const[o,l]=p.useState(t.name),[c,u]=p.useState(!1),[d,h]=p.useState(null),m=p.useRef(null),[f,g]=p.useState(!1),[y,C]=p.useState(null),[w,N]=p.useState(!1),[S,E]=p.useState(""),[I,k]=p.useState(""),[z,D]=p.useState(""),[F,_]=p.useState(!1),[A,L]=p.useState(null),[O,R]=p.useState(!1);if(!e)return null;const P=(J,U)=>n==="zh"?J:U,T=t.role==="teacher"?t.subRole==="administrator"?P("管理员","Administrator"):P("教师","Teacher"):P("学生","Student"),W=o.trim(),j=W.length>0&&W!==t.name,$=async()=>{if(!(!j||c)){u(!0),h(null);try{const J=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})}),U=await J.json();if(!J.ok){h(U.error||(n==="zh"?"保存失败":"Save failed"));return}r(U.name??W)}catch{h(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{u(!1)}}},x=S.length>0&&I.length>=8&&/[a-zA-Z]/.test(I)&&/[0-9]/.test(I)&&I===z,oe=async()=>{if(!(!x||F)){_(!0),L(null);try{const J=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:I})}),U=await J.json();if(!J.ok){L(U.error||(n==="zh"?"修改失败":"Change failed"));return}R(!0),E(""),k(""),D(""),N(!1)}catch{L(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{_(!1)}}},pe=async J=>{const U=J.target.files?.[0];if(J.target.value="",!!U){g(!0),C(null);try{const Q=await new Promise((we,me)=>{const le=new FileReader;le.onload=()=>we(le.result),le.onerror=()=>me(le.error),le.readAsDataURL(U)}),re=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:U.name,base64Data:Q})}),se=await re.json();if(!re.ok){C(se.error||(n==="zh"?"上传失败":"Upload failed"));return}i?.(se.avatar)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},b=async()=>{g(!0),C(null);try{const J=await fetch("/api/auth/avatar",{method:"DELETE"}),U=await J.json().catch(()=>({}));if(!J.ok){C(U.error||(n==="zh"?"移除失败":"Remove failed"));return}i?.(null)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return a.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:J=>J.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:P("个人资料","Profile")}),a.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.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?a.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):a.jsx(In,{size:28})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),a.jsx("p",{className:"text-xs text-gray-400",children:T}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:()=>m.current?.click(),disabled:f,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:f?P("上传中…","Uploading…"):t.avatar?P("更换头像","Change avatar"):P("上传头像","Upload avatar")}),t.avatar&&a.jsx("button",{type:"button",onClick:b,disabled:f,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:P("移除","Remove")})]}),a.jsx("input",{ref:m,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:pe})]})]}),y&&a.jsx("p",{className:"text-xs text-rose-500",children:y}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:P("显示名称","Display Name")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:o,onChange:J=>l(J.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"}),a.jsx("button",{onClick:$,disabled:!j||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?P("保存中…","Saving…"):P("保存","Save")})]}),d&&a.jsx("p",{className:"text-xs text-rose-500 mt-1",children:d})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[a.jsx(Vf,{size:16,className:"text-gray-400"}),P("修改密码","Change Password")]}),!w&&!O&&a.jsx("button",{onClick:()=>{N(!0),L(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:P("修改","Edit")})]}),O&&a.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[a.jsx(Ln,{size:16}),P("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&a.jsxs("div",{className:"mt-3 space-y-3",children:[a.jsx("input",{type:"password",value:S,onChange:J=>E(J.target.value),placeholder:P("当前密码","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"}),a.jsx("input",{type:"password",value:I,onChange:J=>k(J.target.value),placeholder:P("新密码(≥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"}),a.jsx("input",{type:"password",value:z,onChange:J=>D(J.target.value),placeholder:P("确认新密码","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&&a.jsx("p",{className:"text-xs text-rose-500",children:A}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{onClick:()=>{N(!1),E(""),k(""),D(""),L(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:P("取消","Cancel")}),a.jsx("button",{onClick:oe,disabled:!x||F,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:F?P("提交中…","Submitting…"):P("提交","Submit")})]})]})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("用户名(登录账号)","Username (login)")}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("角色","Role")}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:T})]})]})]})]})})}class Yp{constructor(){this.store=bt(()=>({items:new Map}))}register(t,n){const s=n||t.pluginId;this.store.setState(r=>{const i=new Map(r.items);return i.set(t.type,{config:{...t,pluginId:s},pluginId:s}),{items:i}})}unregister(t,n){this.store.setState(s=>{const r=s.items.get(t);if(!r||n&&r.pluginId!==n)return s;const i=new Map(s.items);return i.delete(t),{items:i}})}unregisterPlugin(t){this.store.setState(n=>{let s=!1;const r=new Map(n.items);for(const[i,o]of n.items)o.pluginId===t&&(r.delete(i),s=!0);return s?{items:r}:n})}get(t){return this.store.getState().items.get(t)?.config}getAll(){return Array.from(this.store.getState().items.values()).map(t=>t.config)}has(t){return this.store.getState().items.has(t)}getStore(){return this.store}}const En=new Yp;function mC(){return Is(En.getStore(),Nf(e=>Array.from(e.items.values()).map(t=>t.config)))}const gC={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"}},xC=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"},{id:"extension",labelZh:"插件扩展",labelEn:"Extensions"}],Kp=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:Uf,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
4
+ }`}function Hp(e){if(typeof document>"u")return;delete Cs[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function Mr(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastThemeToIframes:t}=await Ie(async()=>{const{broadcastThemeToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastThemeToIframes:n}},void 0);t(e,Hi(e))}catch{}},0)}catch{}}const As=Vi((e,t)=>({theme:"light",availableThemes:[...Vp],initTheme:()=>{if(typeof window>"u")return;try{const r=localStorage.getItem(xn);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(Lr)||"light";Rr(s),e({theme:s}),Mr(s)},setTheme:n=>{Rr(n),typeof window<"u"&&localStorage.setItem(Lr,n),e({theme:n}),Mr(n)},registerTheme:(n,s)=>{s&&Up(n.id,s),e(r=>({availableThemes:[...r.availableThemes.filter(o=>o.id!==n.id),n]}))},unregisterTheme:n=>{Hp(n),e(s=>{const r=s.availableThemes.filter(o=>o.id!==n),i=s.theme===n?"light":s.theme;return s.theme===n&&(Rr("light"),typeof window<"u"&&localStorage.setItem(Lr,"light"),Mr("light")),{availableThemes:r,theme:i}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const r=localStorage.getItem(xn);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(xn,JSON.stringify(i))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(xn);if(s){let r=JSON.parse(s);Array.isArray(r)&&(r=r.filter(i=>i.spec.id!==n),localStorage.setItem(xn,JSON.stringify(r)))}}catch{}t().unregisterTheme(n)}})),qp=[{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"}}],la={...us.light};function Wp({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:r,deleteCustomTheme:i}=As(),o=p.useId(),[l,c]=p.useState("custom-mytheme"),[u,d]=p.useState("我的专属主题"),[h,m]=p.useState("自定义教学调色板配置"),[f,g]=p.useState({...la}),[y,C]=p.useState("none"),[w,N]=p.useState(""),[S,E]=p.useState(!1),[I,k]=p.useState(null);if(!e)return null;const z=s.filter(j=>j.category==="custom"),D=j=>{k(j),setTimeout(()=>k(null),3e3)},F=j=>{c(j.id),d(j.label),m(j.description),g({...j.tokens}),D(`已载入预设: ${j.label}`)},_=j=>{c(j.id),d(j.label),m(j.description);const $=Hi(j.id);$&&Object.keys($).length>0&&g({...$}),D(`已载入自定义主题: ${j.label}`)},A=(j,$)=>{g(x=>({...x,[j]:$}))},L=()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!j){alert("请输入有效的主题标识 (ID)");return}const $={id:j,label:u.trim()||"未命名主题",description:h.trim()||"自定义主题",previewBg:f["--bg-app"]||"#ffffff",previewPrimary:f["--color-primary"]||"#4f46e5",category:"custom"};r($,f),D(`主题「${$.label}」已保存并成功激活!`)},O=()=>{N(JSON.stringify({version:"1.0",id:l,label:u,description:h,tokens:f},null,2)),C("export")},R=()=>{N(""),C("import")},P=()=>{try{const j=JSON.parse(w);if(!j.tokens||typeof j.tokens!="object")throw new Error("缺少合法的 tokens 字段");j.id&&c(j.id),j.label&&d(j.label),j.description&&m(j.description),g($=>({...$,...j.tokens})),C("none"),D("主题配置导入成功!")}catch(j){alert(`导入失败: ${j.message||"JSON 格式解析错误"}`)}},T=()=>{navigator.clipboard.writeText(w),E(!0),setTimeout(()=>E(!1),2e3)},W=[{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 a.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:a.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:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:a.jsx(pi,{size:22})}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",a.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"})]}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:R,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导入 JSON",children:[a.jsx(Zo,{size:14}),n==="zh"?"导入配置":"Import"]}),a.jsxs("button",{onClick:O,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导出 JSON",children:[a.jsx(Yo,{size:14}),n==="zh"?"导出配置":"Export"]}),a.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:a.jsx(ot,{size:18})})]})]}),I&&a.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:[a.jsx(yt,{size:14}),I]}),a.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[a.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[a.jsxs("section",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(_n,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),a.jsx("span",{className:"text-xs text-muted",children:"一键填入调色板"})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:qp.map(j=>a.jsxs("button",{onClick:()=>F(j),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:[a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.tokens["--color-primary"]}}),j.label]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-app"]}}),a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-surface"]}})]})]}),a.jsx("p",{className:"text-xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:j.description})]},j.id))})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(Af,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-themeId`,className:"block text-xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),a.jsx("input",{id:`${o}-themeId`,type:"text",value:l,onChange:j=>c(j.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"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-label`,className:"block text-xs font-medium text-muted mb-1",children:"主题名称"}),a.jsx("input",{id:`${o}-label`,type:"text",value:u,onChange:j=>d(j.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"})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-description`,className:"block text-xs font-medium text-muted mb-1",children:"主题描述"}),a.jsx("input",{id:`${o}-description`,type:"text",value:h,onChange:j=>m(j.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"})]})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(pi,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),a.jsx("div",{className:"space-y-2.5",children:W.map(j=>{const $=f[j.key]||"#000000";return a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-medium text-main",children:j.labelZh}),a.jsx("span",{className:"text-xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:j.key})]}),a.jsx("p",{className:"text-xs text-muted mt-0.5",children:j.desc})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("div",{className:"relative flex items-center",children:a.jsx("input",{type:"color",value:$.startsWith("#")&&$.length===7?$:"#4f46e5",onChange:x=>A(j.key,x.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),a.jsx("input",{type:"text",value:$,onChange:x=>A(j.key,x.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"})]})]},j.key)})})]}),z.length>0&&a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(zf,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),a.jsx("div",{className:"space-y-2",children:z.map(j=>a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[a.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.previewPrimary}}),a.jsxs("div",{className:"truncate",children:[a.jsx("div",{className:"text-xs font-semibold text-main truncate",children:j.label}),a.jsx("div",{className:"text-xs text-muted truncate",children:j.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[a.jsx("button",{onClick:()=>_(j),className:"px-2 py-1 text-xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),a.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${j.label}」吗?`)&&(i(j.id),D(`已删除主题「${j.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:a.jsx(Al,{size:13})})]})]},j.id))})]})]}),a.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[a.jsx(Ts,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),a.jsxs("span",{className:"text-xs text-muted font-mono",children:["当前预览: ",u," (",l,")"]})]}),a.jsxs("div",{className:"flex-1 rounded-2xl border shadow-inner overflow-hidden flex flex-col transition-colors duration-200",style:{backgroundColor:f["--bg-app"]||"#f8fafc",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:[a.jsxs("div",{className:"h-12 border-b px-4 flex items-center justify-between shrink-0",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-white text-xs",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"OL"}),a.jsx("span",{className:"font-bold text-xs",style:{color:f["--text-main"]},children:"OpenLearn V2"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"text-xs px-2 py-0.5 rounded-md font-mono",style:{backgroundColor:f["--bg-surface-secondary"]||"#f1f5f9",color:f["--text-muted"]||"#64748b"},children:"10:30:00"}),a.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"T"})]})]}),a.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[a.jsxs("div",{className:"p-4 rounded-xl border shadow-xs space-y-3",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-bold text-sm",style:{color:f["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),a.jsx("p",{className:"text-xs mt-1",style:{color:f["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:f["--bg-surface-secondary"],color:f["--color-primary"],border:`1px solid ${f["--border-theme"]}`},children:"进行中"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"光电门测速 (v)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"2.43 m/s"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"动能增量 (ΔEk)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--color-primary"]},children:"0.589 J"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"误差率 (Err)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"0.84 %"})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.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:f["--color-primary"]||"#4f46e5"},children:"开始数据采集"}),a.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors cursor-pointer",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:"重置实验"}),a.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:f["--text-muted"]},children:"查看教案"})]})]}),a.jsxs("div",{className:"p-3 rounded-xl border space-y-2",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme-subtle"]||"#f1f5f9"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs font-semibold",style:{color:f["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),a.jsx("span",{className:"text-xs font-mono",style:{color:f["--text-muted"]},children:"60 FPS"})]}),a.jsxs("div",{className:"h-28 rounded-lg border border-dashed flex items-center justify-center p-3 relative overflow-hidden",style:{backgroundColor:f["--bg-app"],borderColor:f["--border-theme"]},children:[a.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:f["--color-primary"]},children:a.jsx(Di,{size:20})}),a.jsx("div",{className:"absolute bottom-2 right-2 text-xs font-mono px-1.5 py-0.5 rounded border",style:{backgroundColor:f["--bg-surface"],borderColor:f["--border-theme"],color:f["--text-muted"]},children:"iframe Bridge Sync Ready"})]})]})]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("button",{onClick:()=>{g({...la}),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",children:[a.jsx(zl,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("button",{onClick:L,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:[a.jsx(_f,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),y!=="none"&&a.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:a.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:y==="export"?a.jsxs(a.Fragment,{children:[a.jsx(Yo,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):a.jsxs(a.Fragment,{children:[a.jsx(Zo,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),a.jsx("button",{onClick:()=>C("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:a.jsx(ot,{size:16})})]}),a.jsx("div",{children:a.jsx("textarea",{value:w,readOnly:y==="export",onChange:j=>N(j.target.value),placeholder:y==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),a.jsx("div",{className:"flex items-center justify-end gap-2",children:y==="export"?a.jsx(a.Fragment,{children:a.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?a.jsx(yt,{size:14}):a.jsx(An,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>C("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"}),a.jsx("button",{onClick:P,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 Gp({lang:e="zh"}){const[t,n]=p.useState(!1),[s,r]=p.useState(!1),i=p.useRef(null),{theme:o,availableThemes:l,setTheme:c}=As();p.useEffect(()=>{function d(h){i.current&&!i.current.contains(h.target)&&n(!1)}return t&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[t]);const u=d=>{switch(d){case"dark":return a.jsx(Rf,{size:16,className:"text-indigo-400"});case"eyecare":return a.jsx(Ts,{size:16,className:"text-emerald-500"});case"chalkboard":return a.jsx(pi,{size:16,className:"text-green-400"});case"light":default:return a.jsx(Lf,{size:16,className:"text-amber-500"})}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative",ref:i,children:[a.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&&a.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:[a.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[a.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),a.jsx("div",{className:"space-y-1",children:l.map(d=>{const h=o===d.id;return a.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 ${h?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.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}}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-main leading-none",children:d.label}),a.jsx("div",{className:"text-xs text-muted mt-1 leading-tight opacity-80",children:d.description})]})]}),h&&a.jsx(yt,{size:14,className:"text-primary-theme shrink-0"})]},d.id)})}),a.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:a.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:[a.jsx(_n,{size:14}),a.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),a.jsx(Wp,{isOpen:s,onClose:()=>r(!1),lang:e})]})}const Or="openlearn_font_scale",Zt=85,Yt=140,Dr=5,ds=100,ca=[{scale:90,labelZh:"紧凑 (90%)",labelEn:"Compact (90%)"},{scale:100,labelZh:"标准 (100%)",labelEn:"Standard (100%)"},{scale:110,labelZh:"中大 (110%)",labelEn:"Medium (110%)"},{scale:120,labelZh:"大号 (120%)",labelEn:"Large (120%)"},{scale:130,labelZh:"特大 (130%)",labelEn:"Extra Large (130%)"}];function Fr(e){if(typeof document>"u")return;const t=Math.min(Yt,Math.max(Zt,Math.round(e)));document.documentElement.style.fontSize=`${t}%`,document.documentElement.style.setProperty("--app-font-scale",(t/100).toFixed(2)),document.documentElement.setAttribute("data-font-scale",String(t))}function Br(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastFontScaleToIframes:t}=await Ie(async()=>{const{broadcastFontScaleToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastFontScaleToIframes:n}},void 0);t(e)}catch{}},0)}catch{}}const Xt=Vi((e,t)=>({scale:ds,minScale:Zt,maxScale:Yt,step:Dr,initFontSize:()=>{if(typeof window>"u")return;let n=ds;try{const s=localStorage.getItem(Or);if(s){const r=Number(s);!isNaN(r)&&r>=Zt&&r<=Yt&&(n=r)}}catch{}Fr(n),e({scale:n}),Br(n);try{window.addEventListener("storage",s=>{if(s.key===Or&&s.newValue){const r=Number(s.newValue);!isNaN(r)&&r>=Zt&&r<=Yt&&(Fr(r),e({scale:r}),Br(r))}})}catch{}},setScale:n=>{const s=Math.min(Yt,Math.max(Zt,Math.round(n)));if(Fr(s),typeof window<"u")try{localStorage.setItem(Or,String(s))}catch{}e({scale:s}),Br(s)},increaseScale:()=>{const n=t().scale,s=Math.min(Yt,n+Dr);t().setScale(s)},decreaseScale:()=>{const n=t().scale,s=Math.max(Zt,n-Dr);t().setScale(s)},resetScale:()=>{t().setScale(ds)}}));function Hl({lang:e="zh"}){const[t,n]=p.useState(!1),s=p.useRef(null),{scale:r,minScale:i,maxScale:o,setScale:l,increaseScale:c,decreaseScale:u,resetScale:d}=Xt();p.useEffect(()=>{function f(g){s.current&&!s.current.contains(g.target)&&n(!1)}return t&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[t]);const h=ca.find(f=>f.scale===r),m=r===ds;return a.jsxs("div",{className:"relative",ref:s,children:[a.jsxs("button",{type:"button",onClick:()=>n(!t),title:e==="zh"?`界面字体缩放: ${r}%(点击调节)`:`Interface Font Scaling: ${r}% (Click to adjust)`,className:`p-2 hover:bg-surface-secondary transition-colors rounded-lg border shadow-3xs flex items-center justify-center shrink-0 cursor-pointer relative ${m?"bg-surface border-theme text-main":"bg-primary-theme-light border-primary-theme text-primary-theme font-bold"}`,"aria-label":"Font size selector","aria-expanded":t,children:[a.jsx(Mf,{size:16}),!m&&a.jsxs("span",{className:"absolute -bottom-1 -right-1 text-xs px-1 py-0.2 rounded-full bg-primary-theme text-white font-extrabold leading-none shadow-xs",children:[r,"%"]})]}),t&&a.jsxs("div",{className:"absolute right-0 mt-2 w-72 rounded-xl border border-theme bg-surface shadow-xl z-50 p-3 overflow-hidden animate-in fade-in zoom-in-95 duration-100 select-none",children:[a.jsxs("div",{className:"px-1 pb-2 border-b border-theme-subtle mb-2.5 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-main",children:e==="zh"?"界面字号大小":"Interface Font Size"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"全局等比缩放排版与文字":"Proportionally scale typography"})]}),!m&&a.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1 text-xs text-muted hover:text-primary-theme transition-colors cursor-pointer px-1.5 py-0.5 rounded hover:bg-surface-secondary",title:e==="zh"?"恢复默认 100%":"Reset to 100%",children:[a.jsx(zl,{size:11}),a.jsx("span",{children:e==="zh"?"重置":"Reset"})]})]}),a.jsxs("div",{className:"bg-surface-secondary/70 rounded-lg p-2 flex items-center justify-between mb-3 border border-theme-subtle",children:[a.jsx("button",{type:"button",onClick:u,disabled:r<=i,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"减小字体 (A-)":"Decrease (A-)",children:a.jsx(Of,{size:14})}),a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-sm font-black text-main leading-tight",children:[r,"%"]}),a.jsx("div",{className:"text-xs text-muted",children:h?e==="zh"?h.labelZh.split(" ")[0]:h.labelEn.split(" ")[0]:e==="zh"?"自定义比例":"Custom"})]}),a.jsx("button",{type:"button",onClick:c,disabled:r>=o,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"增大字体 (A+)":"Increase (A+)",children:a.jsx(Df,{size:14})})]}),a.jsxs("div",{className:"space-y-1 mb-3",children:[a.jsx("div",{className:"text-xs font-bold text-muted uppercase tracking-wider px-1",children:e==="zh"?"常用档位":"Presets"}),a.jsx("div",{className:"grid grid-cols-1 gap-1",children:ca.map(f=>{const g=r===f.scale;return a.jsxs("button",{type:"button",onClick:()=>l(f.scale),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs transition-all cursor-pointer ${g?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/30":"text-main hover:bg-surface-secondary border border-transparent"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-60"}),a.jsx("span",{children:e==="zh"?f.labelZh:f.labelEn})]}),g&&a.jsx(yt,{size:13,className:"text-primary-theme shrink-0"})]},f.scale)})})]}),a.jsxs("div",{className:"p-2.5 rounded-lg border border-theme-subtle bg-surface-secondary/40 mb-2",children:[a.jsxs("div",{className:"text-xs text-muted mb-1 flex items-center justify-between",children:[a.jsx("span",{children:e==="zh"?"实时效果预览":"Live Preview"}),a.jsxs("span",{children:[r,"%"]})]}),a.jsx("p",{className:"text-xs text-main font-medium leading-relaxed",children:e==="zh"?"让每一个文字都清晰舒适,智能赋能教学。":"Clear and comfortable typography empowers modern teaching."})]}),a.jsx("div",{className:"text-xs text-muted/80 text-center px-1",children:e==="zh"?"快捷键:Ctrl + Alt + 加号/减号":"Shortcut: Ctrl + Alt + +/-"})]})]})}function Qp(e){const{activeRole:t,lang:n,teacherTab:s,studentViewStatus:r,session:i,activeStudentId:o,students:l,studentDashboardData:c,isNotificationsOpen:u,studentNotifications:d,unreadNotifications:h,readNotifications:m,dbConnected:f,dbStatus:g,siteInfo:y,setActiveStudentId:C,setReadNotifications:w,setIsSystemResourceLibraryOpen:N,setProfileOpen:S,setTeacherTab:E,setStudentViewStatus:I,setIsNotificationsOpen:k,setSelectedNotificationForModal:z,handleLogout:D,toggleLanguage:F,setActiveRole:_,isStudentLocked:A=!1,onBlockedNavigate:L}=e,O=t==="student"&&A,R=()=>{if(O){L?.();return}t==="teacher"?E("dashboard"):t==="student"&&I("dashboard")};return a.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:[a.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[a.jsxs("button",{onClick:R,className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:O?n==="zh"?"全班专注锁定中,无法返回系统总览":"Class focus locked — cannot return to dashboard":n==="zh"?"返回系统总览":"Back to Dashboard",children:[y.logoUrl?a.jsx("img",{src:y.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):a.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"}),a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:y.siteName||"OpenLearn Next"}),a.jsxs("span",{className:"text-xs font-medium text-slate-400 tracking-tight",children:["v","0.3.21"]}),y.slogan&&a.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:y.slogan})]})]}),a.jsxs("button",{onClick:R,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"} ${O?"opacity-50":""}`,children:[O?a.jsx(fi,{size:16}):a.jsx(_l,{size:16}),n==="zh"?"系统总览":"Dashboard"]}),t==="student"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),a.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[a.jsx(Ff,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&i?.role==="teacher"&&a.jsxs("div",{className:"flex items-center gap-2 bg-amber-50/90 border border-amber-200/80 px-2.5 py-1 rounded-lg shadow-2xs",children:[a.jsxs("span",{className:"text-xs font-semibold text-amber-800 flex items-center gap-1",children:[a.jsx(Ts,{size:13,className:"text-amber-600"}),n==="zh"?"模拟学生:":"View as:"]}),a.jsxs("select",{className:"border border-amber-300 rounded px-1.5 py-0.5 text-xs bg-white text-gray-800 font-medium focus:ring-1 focus:ring-amber-400 focus:outline-hidden",value:o||"",onChange:P=>C(P.target.value),children:[a.jsxs("option",{value:"",children:["-- ",n==="zh"?"选择学生":"Select Student"," --"]}),l.map(P=>a.jsx("option",{value:P.id,children:P.name},P.id))]}),_&&a.jsxs("button",{type:"button",onClick:()=>_("teacher"),className:"ml-1 px-2.5 py-1 bg-amber-600 hover:bg-amber-700 active:bg-amber-800 text-white text-xs font-bold rounded-md flex items-center gap-1 transition-all cursor-pointer shadow-2xs",title:n==="zh"?"退出模拟学生并返回教师端工作台":"Exit student view and return to teacher workspace",children:[a.jsx(Oi,{size:12}),n==="zh"?"返回教师端":"Exit Student View"]})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>k(!u),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[a.jsx(Bf,{size:20}),h.length>0&&a.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:h.length})]}),u&&a.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:[a.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),h.length>0&&a.jsx("button",{onClick:async()=>{if(!o)return;try{const T=d.filter(W=>!m.has(W.id)).map(W=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:W.id})}));await Promise.all(T)}catch(T){console.error(T)}const P=new Set(m);d.forEach(T=>P.add(T.id)),w(P)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),a.jsx("div",{className:"max-h-96 overflow-y-auto",children:d.length===0?a.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):a.jsx("div",{className:"divide-y divide-gray-100",children:d.map(P=>{const T=!m.has(P.id);return a.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${T?"bg-indigo-50/30":""}`,onClick:()=>{if(T){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:P.id})}).catch(console.error);const j=new Set(m);j.add(P.id),w(j)}const W=c?.assignments?.find(j=>j.id===P.relatedId);z({...P,assignment:W}),k(!1)},children:a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"mt-0.5",children:P.type==="new_assignment"?a.jsx(Ll,{size:16,className:"text-indigo-500"}):P.type==="rollcall_picked"?a.jsx(_n,{size:16,className:"text-amber-500 animate-pulse"}):a.jsx(Ln,{size:16,className:"text-green-500"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`text-sm ${T?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:P.title}),a.jsx("div",{className:`text-xs mt-0.5 ${T?"text-gray-600":"text-gray-500"}`,children:P.message})]}),T&&a.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},P.id)})})})]})]}),a.jsxs("button",{onClick:()=>N(!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:[a.jsx(mi,{size:14,className:"text-emerald-500 animate-pulse"}),n==="zh"?"系统资源库":"System Resource Library"]}),a.jsx("button",{onClick:F,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:a.jsx(mi,{size:16})}),a.jsx(Hl,{lang:n}),a.jsx(Gp,{lang:n}),(()=>{const P=g==="error"||!f?{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 a.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 ${P.bg}`,title:P.label,children:[a.jsx($f,{size:15}),a.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[a.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${P.ping}`}),a.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${P.dot}`})]})]})})(),a.jsx($p,{session:i,lang:n,onLogout:D,onProfile:()=>S(!0)})]})]})}const Jp="openlearn_live_classroom_sync";class ua{constructor(t=Jp){this.channel=null,this.isDestroyed=!1,this.messageListeners=[],typeof window<"u"&&typeof window.BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(t),this.channel.onmessage=n=>{this.isDestroyed||!n.data||this.messageListeners.forEach(s=>{try{s(n.data)}catch(r){console.error("[ClassroomSyncChannel] Listener error:",r)}})})}onMessage(t){return this.messageListeners.push(t),()=>{this.messageListeners=this.messageListeners.filter(n=>n!==t)}}postMessage(t){if(!(this.isDestroyed||!this.channel))try{this.channel.postMessage(t)}catch(n){console.warn("[ClassroomSyncChannel] Failed to post message:",n)}}broadcastInitState(t){this.postMessage({type:"TEACHER_INIT_STATE",payload:t})}broadcastChangeLesson(t){this.postMessage({type:"TEACHER_CHANGE_LESSON",payload:{lessonId:t}})}broadcastChangeSegment(t){this.postMessage({type:"TEACHER_CHANGE_SEGMENT",payload:{segmentId:t}})}broadcastChangeTab(t){this.postMessage({type:"TEACHER_CHANGE_TAB",payload:{tab:t}})}broadcastLockClass(t){this.postMessage({type:"TEACHER_LOCK_CLASS",payload:{locked:t}})}broadcastPickStudent(t,n){this.postMessage({type:"TEACHER_PICK_STUDENT",payload:{studentId:t,studentName:n}})}broadcastSyncTimer(t,n){this.postMessage({type:"TEACHER_SYNC_TIMER",payload:{timeRemaining:t,isRunning:n}})}broadcastPingStudent(t,n){this.postMessage({type:"TEACHER_PING_STUDENT",payload:{studentId:t,message:n}})}broadcastFullscreen(t,n){this.postMessage({type:"TEACHER_BROADCAST_FULLSCREEN",payload:{elementId:t,lessonId:n}})}requestHandshake(){this.postMessage({type:"STUDENT_HANDSHAKE_REQUEST"})}acknowledgePick(t){this.postMessage({type:"STUDENT_ACKNOWLEDGE_PICK",payload:{studentId:t}})}sendHeartbeat(t){this.postMessage({type:"STUDENT_HEARTBEAT",payload:{studentId:t,timestamp:Date.now()}})}destroy(){this.isDestroyed=!0,this.messageListeners=[],this.channel&&(this.channel.close(),this.channel=null)}}const tn=bt(e=>({remoteFullscreenElementId:null,setRemoteFullscreenElementId:t=>e({remoteFullscreenElementId:t}),clearRemoteFullscreen:()=>e({remoteFullscreenElementId:null})})),pC=e=>Is(tn,e);function Zp({open:e,session:t,lang:n,onClose:s,onSaved:r,onAvatar:i}){const[o,l]=p.useState(t.name),[c,u]=p.useState(!1),[d,h]=p.useState(null),m=p.useRef(null),[f,g]=p.useState(!1),[y,C]=p.useState(null),[w,N]=p.useState(!1),[S,E]=p.useState(""),[I,k]=p.useState(""),[z,D]=p.useState(""),[F,_]=p.useState(!1),[A,L]=p.useState(null),[O,R]=p.useState(!1);if(!e)return null;const P=(J,U)=>n==="zh"?J:U,T=t.role==="teacher"?t.subRole==="administrator"?P("管理员","Administrator"):P("教师","Teacher"):P("学生","Student"),W=o.trim(),j=W.length>0&&W!==t.name,$=async()=>{if(!(!j||c)){u(!0),h(null);try{const J=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})}),U=await J.json();if(!J.ok){h(U.error||(n==="zh"?"保存失败":"Save failed"));return}r(U.name??W)}catch{h(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{u(!1)}}},x=S.length>0&&I.length>=8&&/[a-zA-Z]/.test(I)&&/[0-9]/.test(I)&&I===z,oe=async()=>{if(!(!x||F)){_(!0),L(null);try{const J=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:I})}),U=await J.json();if(!J.ok){L(U.error||(n==="zh"?"修改失败":"Change failed"));return}R(!0),E(""),k(""),D(""),N(!1)}catch{L(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{_(!1)}}},pe=async J=>{const U=J.target.files?.[0];if(J.target.value="",!!U){g(!0),C(null);try{const Q=await new Promise((we,me)=>{const le=new FileReader;le.onload=()=>we(le.result),le.onerror=()=>me(le.error),le.readAsDataURL(U)}),re=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:U.name,base64Data:Q})}),se=await re.json();if(!re.ok){C(se.error||(n==="zh"?"上传失败":"Upload failed"));return}i?.(se.avatar)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},b=async()=>{g(!0),C(null);try{const J=await fetch("/api/auth/avatar",{method:"DELETE"}),U=await J.json().catch(()=>({}));if(!J.ok){C(U.error||(n==="zh"?"移除失败":"Remove failed"));return}i?.(null)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return a.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:J=>J.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:P("个人资料","Profile")}),a.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.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?a.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):a.jsx(In,{size:28})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),a.jsx("p",{className:"text-xs text-gray-400",children:T}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:()=>m.current?.click(),disabled:f,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:f?P("上传中…","Uploading…"):t.avatar?P("更换头像","Change avatar"):P("上传头像","Upload avatar")}),t.avatar&&a.jsx("button",{type:"button",onClick:b,disabled:f,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:P("移除","Remove")})]}),a.jsx("input",{ref:m,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:pe})]})]}),y&&a.jsx("p",{className:"text-xs text-rose-500",children:y}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:P("显示名称","Display Name")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:o,onChange:J=>l(J.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"}),a.jsx("button",{onClick:$,disabled:!j||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?P("保存中…","Saving…"):P("保存","Save")})]}),d&&a.jsx("p",{className:"text-xs text-rose-500 mt-1",children:d})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[a.jsx(Vf,{size:16,className:"text-gray-400"}),P("修改密码","Change Password")]}),!w&&!O&&a.jsx("button",{onClick:()=>{N(!0),L(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:P("修改","Edit")})]}),O&&a.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[a.jsx(Ln,{size:16}),P("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&a.jsxs("div",{className:"mt-3 space-y-3",children:[a.jsx("input",{type:"password",value:S,onChange:J=>E(J.target.value),placeholder:P("当前密码","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"}),a.jsx("input",{type:"password",value:I,onChange:J=>k(J.target.value),placeholder:P("新密码(≥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"}),a.jsx("input",{type:"password",value:z,onChange:J=>D(J.target.value),placeholder:P("确认新密码","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&&a.jsx("p",{className:"text-xs text-rose-500",children:A}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{onClick:()=>{N(!1),E(""),k(""),D(""),L(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:P("取消","Cancel")}),a.jsx("button",{onClick:oe,disabled:!x||F,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:F?P("提交中…","Submitting…"):P("提交","Submit")})]})]})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("用户名(登录账号)","Username (login)")}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("角色","Role")}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:T})]})]})]})]})})}class Yp{constructor(){this.store=bt(()=>({items:new Map}))}register(t,n){const s=n||t.pluginId;this.store.setState(r=>{const i=new Map(r.items);return i.set(t.type,{config:{...t,pluginId:s},pluginId:s}),{items:i}})}unregister(t,n){this.store.setState(s=>{const r=s.items.get(t);if(!r||n&&r.pluginId!==n)return s;const i=new Map(s.items);return i.delete(t),{items:i}})}unregisterPlugin(t){this.store.setState(n=>{let s=!1;const r=new Map(n.items);for(const[i,o]of n.items)o.pluginId===t&&(r.delete(i),s=!0);return s?{items:r}:n})}get(t){return this.store.getState().items.get(t)?.config}getAll(){return Array.from(this.store.getState().items.values()).map(t=>t.config)}has(t){return this.store.getState().items.has(t)}getStore(){return this.store}}const En=new Yp;function mC(){return Is(En.getStore(),Nf(e=>Array.from(e.items.values()).map(t=>t.config)))}const gC={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"}},xC=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"},{id:"extension",labelZh:"插件扩展",labelEn:"Extensions"}],Kp=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:Uf,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 _b(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 Za(){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 Lb(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 Rb(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 Mb(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 Ob(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 es={padding:"12px",color:"#e2e8f0",fontSize:"13px"},Db={HelpCircle:Xf,Vote:Kf,BarChart3:Yf,MessagesSquare:Zf,Users:Il,FileText:Rl,Trophy:Jf,CheckCircle2:Ln,BookOpen:Di};function Fb({name:e,className:t}){const n=e&&Db[e]||Fi;return a.jsx(n,{size:18,className:t})}function Bb(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 Tc=({role:e,actorId:t,lang:n="en",classroomId:s,mode:r="launcher"})=>{const[i,o]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState(null),[h,m]=p.useState({}),[f,g]=p.useState([]),[y,C]=p.useState(!0),[w,N]=p.useState(null),[S,E]=p.useState(null),[I,k]=p.useState(!1),[z,D]=p.useState(null),F=he(j=>j.setTeacherTab),_=p.useMemo(()=>{const j=new Map;for(const $ of i){const x=$.category;j.has(x)||j.set(x,[]),j.get(x).push($)}return Array.from(j.entries())},[i]);p.useEffect(()=>{if(r!=="launcher")return;let j=!1;return c(!0),_b(e).then($=>{j||o($)}).catch($=>{j||d($ instanceof Error?$.message:String($))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[e,r]),p.useEffect(()=>{if(r!=="status")return;let j=!1;const $=async()=>{try{const oe=await Za();j||g(oe)}catch(oe){j||N(oe instanceof Error?oe.message:String(oe))}finally{j||C(!1)}};$();const x=setInterval($,5e3);return()=>{j=!0,clearInterval(x)}},[r]);const A=async j=>{if(S){k(!0),D(null);try{await j(S),g(await Za())}catch($){D($ instanceof Error?$.message:String($))}finally{k(!1)}}},L=()=>A(Lb),O=()=>A(Rb),R=()=>A(Mb),P=()=>{E(null),F("live_class")};if(r==="status"){if(y)return a.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(w||f.length===0)return null;const j=f.find($=>$.id===S)||null;return a.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[a.jsx("span",{children:"🧩"}),a.jsx("span",{children:n==="zh"?"进行中的活动":"Activities in Progress"})]}),a.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:f.length})]}),a.jsx("div",{className:"flex flex-col gap-2",children:f.map($=>{const x=$.state==="running";return a.jsxs("button",{onClick:()=>E($.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:[a.jsx(Fb,{name:$.icon,className:"text-indigo-600 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"font-bold text-slate-800 truncate",children:$.name}),$.category&&a.jsx("div",{className:"text-xs text-slate-500 truncate",children:$.category})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[a.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${x?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:x?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"}),a.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1",children:[a.jsx(Wf,{size:10})," ",Bb($.startedAt,n)]})]})]},$.id)})}),j&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>E(null),children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:$=>$.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-bold text-slate-800",children:j.name}),a.jsx("button",{onClick:()=>E(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[n==="zh"?"状态":"Status",":"," ",j.state==="running"?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[n==="zh"?"开始时间":"Started",":"," ",j.startedAt?new Date(j.startedAt).toLocaleString():"-"]}),z&&a.jsx("div",{className:"text-xs text-rose-600 mb-2",children:z}),a.jsxs("div",{className:"flex gap-2",children:[j.state==="running"?a.jsxs("button",{disabled:I,onClick:O,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:[a.jsx(Gf,{size:14})," ",n==="zh"?"暂停":"Pause"]}):a.jsxs("button",{disabled:I,onClick:R,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:[a.jsx(Qf,{size:14})," ",n==="zh"?"恢复":"Resume"]}),a.jsx("button",{disabled:I,onClick:L,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:I?n==="zh"?"处理中…":"Working…":n==="zh"?"结束":"End"})]}),a.jsx("button",{onClick:P,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 j=>{m($=>({...$,[j.id]:n==="zh"?"启动中…":"Starting…"}));try{const $=await Ob(j.id,{classroomId:s,role:e},t);m(x=>({...x,[j.id]:$.dispatched?n==="zh"?"已启动 ✓":"Started ✓":n==="zh"?"已通知 ✓":"Notified ✓"}))}catch($){m(x=>({...x,[j.id]:$ instanceof Error?$.message:String($)}))}};if(l)return a.jsx("div",{style:es,children:n==="zh"?"加载活动中…":"Loading activities…"});if(u)return a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",n==="zh"?"活动中心":"Activity Center"]}),a.jsx("div",{style:{opacity:.7},children:u})]});const W=e==="teacher"?n==="zh"?"活动中心(教师)":"Activity Center":n==="zh"?"活动(学生)":"Activities";return i.length===0?a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",W]}),a.jsx("div",{style:{opacity:.7},children:n==="zh"?"暂无可用活动。":"No activities available."})]}):a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",W]}),_.map(([j,$])=>a.jsxs("div",{style:{marginBottom:10},children:[a.jsx("div",{style:{opacity:.6,fontSize:12,textTransform:"uppercase",marginBottom:4},children:j}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:$.map(x=>a.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[a.jsxs("div",{style:{fontWeight:600},children:[x.icon?`${x.icon} `:"▫️ ",x.name]}),x.description&&a.jsx("div",{style:{opacity:.7,fontSize:12,margin:"2px 0 6px"},children:x.description}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("button",{onClick:()=>T(x),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"}),h[x.id]&&a.jsx("span",{style:{fontSize:12,opacity:.85},children:h[x.id]})]}),a.jsx("div",{style:{opacity:.5,fontSize:12,marginTop:4},children:x.provider==="official"?"official":x.provider})]},x.id))})]},j))]})},$b=Object.freeze(Object.defineProperty({__proto__:null,ActivityWorkspaceWidget:Tc},Symbol.toStringTag,{value:"Module"}));let Ya=!1;function Vb(){if(Ya)return;Ya=!0;const e=()=>Ie(()=>Promise.resolve().then(()=>$b),void 0).then(t=>({default:()=>a.jsx(Tc,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,ke.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}const Ka="@openlearn/frontend:IFrontendAPI",Xa="@openlearn/frontend:ISocketService",el="@openlearn/frontend:IUIService",tl="@openlearn/frontend:IStorageService",Ub="@openlearn/frontend:ISemesterGradeService";var be=(e=>(e.INSTALLED="installed",e.ACTIVATING="activating",e.ACTIVE="active",e.DEACTIVATING="deactivating",e.INACTIVE="inactive",e.ERROR="error",e.UNINSTALLED="uninstalled",e))(be||{});const Hb=p.lazy(()=>Ie(()=>import("./StudentView-BtleJCxa.js"),[]).then(e=>({default:e.StudentView}))),qb=p.lazy(()=>Ie(()=>import("./TeacherView-BP04D9dn.js"),[]).then(e=>({default:e.TeacherView})));function Wb(e){const{activeRole:t}=e;return a.jsx(p.Suspense,{fallback:a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-slate-400 gap-3",children:[a.jsx(Bi,{className:"w-8 h-8 animate-spin text-indigo-500"}),a.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?a.jsx(Hb,{...e}):a.jsx(qb,{...e})})}const io=p.createContext({});function oo(e){const t=p.useRef(null);return t.current===null&&(t.current=e()),t.current}const Gb=typeof window<"u",Ic=Gb?p.useLayoutEffect:p.useEffect,Rs=p.createContext(null),ao=p.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function nl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Qb(...e){return t=>{let n=!1;const s=e.map(r=>{const i=nl(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():nl(e[r],null)}}}}function Jb(...e){return p.useCallback(Qb(...e),e)}class Zb extends p.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(_r(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=_r(s)&&s.offsetWidth||0,i=_r(s)&&s.offsetHeight||0,o=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(o.height),l.width=parseFloat(o.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=r-l.width-l.left,l.bottom=i-l.height-l.top,l.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Yb({children:e,isPresent:t,anchorX:n,anchorY:s,root:r,pop:i}){const o=p.useId(),l=p.useRef(null),c=p.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:u}=p.useContext(ao),d=e.props?.ref??e?.ref,h=Jb(l,d);return p.useInsertionEffect(()=>{const{width:m,height:f,top:g,left:y,right:C,bottom:w,direction:N}=c.current;if(t||i===!1||!l.current||!m||!f)return;const S=N==="rtl",E=n==="left"?S?`right: ${C}`:`left: ${y}`:S?`left: ${y}`:`right: ${C}`,I=s==="bottom"?`bottom: ${w}`:`top: ${g}`;l.current.dataset.motionPopId=o;const k=document.createElement("style");u&&(k.nonce=u);const z=r??document.head;return z.appendChild(k),k.sheet&&k.sheet.insertRule(`
124
+ Draft a 300-word integration proposal based on today's whiteboard exercises.`}};async function _b(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 Za(){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 Lb(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 Rb(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 Mb(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 Ob(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 es={padding:"12px",color:"#e2e8f0",fontSize:"13px"},Db={HelpCircle:Xf,Vote:Kf,BarChart3:Yf,MessagesSquare:Zf,Users:Il,FileText:Rl,Trophy:Jf,CheckCircle2:Ln,BookOpen:Di};function Fb({name:e,className:t}){const n=e&&Db[e]||Fi;return a.jsx(n,{size:18,className:t})}function Bb(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 Tc=({role:e,actorId:t,lang:n="en",classroomId:s,mode:r="launcher"})=>{const[i,o]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState(null),[h,m]=p.useState({}),[f,g]=p.useState([]),[y,C]=p.useState(!0),[w,N]=p.useState(null),[S,E]=p.useState(null),[I,k]=p.useState(!1),[z,D]=p.useState(null),F=he(j=>j.setTeacherTab),_=p.useMemo(()=>{const j=new Map;for(const $ of i){const x=$.category;j.has(x)||j.set(x,[]),j.get(x).push($)}return Array.from(j.entries())},[i]);p.useEffect(()=>{if(r!=="launcher")return;let j=!1;return c(!0),_b(e).then($=>{j||o($)}).catch($=>{j||d($ instanceof Error?$.message:String($))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[e,r]),p.useEffect(()=>{if(r!=="status")return;let j=!1;const $=async()=>{try{const oe=await Za();j||g(oe)}catch(oe){j||N(oe instanceof Error?oe.message:String(oe))}finally{j||C(!1)}};$();const x=setInterval($,5e3);return()=>{j=!0,clearInterval(x)}},[r]);const A=async j=>{if(S){k(!0),D(null);try{await j(S),g(await Za())}catch($){D($ instanceof Error?$.message:String($))}finally{k(!1)}}},L=()=>A(Lb),O=()=>A(Rb),R=()=>A(Mb),P=()=>{E(null),F("live_class")};if(r==="status"){if(y)return a.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(w||f.length===0)return null;const j=f.find($=>$.id===S)||null;return a.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[a.jsx("span",{children:"🧩"}),a.jsx("span",{children:n==="zh"?"进行中的活动":"Activities in Progress"})]}),a.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:f.length})]}),a.jsx("div",{className:"flex flex-col gap-2",children:f.map($=>{const x=$.state==="running";return a.jsxs("button",{onClick:()=>E($.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:[a.jsx(Fb,{name:$.icon,className:"text-indigo-600 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"font-bold text-slate-800 truncate",children:$.name}),$.category&&a.jsx("div",{className:"text-xs text-slate-500 truncate",children:$.category})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[a.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${x?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:x?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"}),a.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1",children:[a.jsx(Wf,{size:10})," ",Bb($.startedAt,n)]})]})]},$.id)})}),j&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>E(null),children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:$=>$.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-bold text-slate-800",children:j.name}),a.jsx("button",{onClick:()=>E(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[n==="zh"?"状态":"Status",":"," ",j.state==="running"?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[n==="zh"?"开始时间":"Started",":"," ",j.startedAt?new Date(j.startedAt).toLocaleString():"-"]}),z&&a.jsx("div",{className:"text-xs text-rose-600 mb-2",children:z}),a.jsxs("div",{className:"flex gap-2",children:[j.state==="running"?a.jsxs("button",{disabled:I,onClick:O,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:[a.jsx(Gf,{size:14})," ",n==="zh"?"暂停":"Pause"]}):a.jsxs("button",{disabled:I,onClick:R,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:[a.jsx(Qf,{size:14})," ",n==="zh"?"恢复":"Resume"]}),a.jsx("button",{disabled:I,onClick:L,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:I?n==="zh"?"处理中…":"Working…":n==="zh"?"结束":"End"})]}),a.jsx("button",{onClick:P,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 j=>{m($=>({...$,[j.id]:n==="zh"?"启动中…":"Starting…"}));try{const $=await Ob(j.id,{classroomId:s,role:e},t);m(x=>({...x,[j.id]:$.dispatched?n==="zh"?"已启动 ✓":"Started ✓":n==="zh"?"已通知 ✓":"Notified ✓"}))}catch($){m(x=>({...x,[j.id]:$ instanceof Error?$.message:String($)}))}};if(l)return a.jsx("div",{style:es,children:n==="zh"?"加载活动中…":"Loading activities…"});if(u)return a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",n==="zh"?"活动中心":"Activity Center"]}),a.jsx("div",{style:{opacity:.7},children:u})]});const W=e==="teacher"?n==="zh"?"活动中心(教师)":"Activity Center":n==="zh"?"活动(学生)":"Activities";return i.length===0?a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",W]}),a.jsx("div",{style:{opacity:.7},children:n==="zh"?"暂无可用活动。":"No activities available."})]}):a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",W]}),_.map(([j,$])=>a.jsxs("div",{style:{marginBottom:10},children:[a.jsx("div",{style:{opacity:.6,fontSize:12,textTransform:"uppercase",marginBottom:4},children:j}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:$.map(x=>a.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[a.jsxs("div",{style:{fontWeight:600},children:[x.icon?`${x.icon} `:"▫️ ",x.name]}),x.description&&a.jsx("div",{style:{opacity:.7,fontSize:12,margin:"2px 0 6px"},children:x.description}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("button",{onClick:()=>T(x),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"}),h[x.id]&&a.jsx("span",{style:{fontSize:12,opacity:.85},children:h[x.id]})]}),a.jsx("div",{style:{opacity:.5,fontSize:12,marginTop:4},children:x.provider==="official"?"official":x.provider})]},x.id))})]},j))]})},$b=Object.freeze(Object.defineProperty({__proto__:null,ActivityWorkspaceWidget:Tc},Symbol.toStringTag,{value:"Module"}));let Ya=!1;function Vb(){if(Ya)return;Ya=!0;const e=()=>Ie(()=>Promise.resolve().then(()=>$b),void 0).then(t=>({default:()=>a.jsx(Tc,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,ke.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}const Ka="@openlearn/frontend:IFrontendAPI",Xa="@openlearn/frontend:ISocketService",el="@openlearn/frontend:IUIService",tl="@openlearn/frontend:IStorageService",Ub="@openlearn/frontend:ISemesterGradeService";var be=(e=>(e.INSTALLED="installed",e.ACTIVATING="activating",e.ACTIVE="active",e.DEACTIVATING="deactivating",e.INACTIVE="inactive",e.ERROR="error",e.UNINSTALLED="uninstalled",e))(be||{});const Hb=p.lazy(()=>Ie(()=>import("./StudentView-Cg5G4Guz.js"),[]).then(e=>({default:e.StudentView}))),qb=p.lazy(()=>Ie(()=>import("./TeacherView-_n9QWf7y.js"),[]).then(e=>({default:e.TeacherView})));function Wb(e){const{activeRole:t}=e;return a.jsx(p.Suspense,{fallback:a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-slate-400 gap-3",children:[a.jsx(Bi,{className:"w-8 h-8 animate-spin text-indigo-500"}),a.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?a.jsx(Hb,{...e}):a.jsx(qb,{...e})})}const io=p.createContext({});function oo(e){const t=p.useRef(null);return t.current===null&&(t.current=e()),t.current}const Gb=typeof window<"u",Ic=Gb?p.useLayoutEffect:p.useEffect,Rs=p.createContext(null),ao=p.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function nl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Qb(...e){return t=>{let n=!1;const s=e.map(r=>{const i=nl(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():nl(e[r],null)}}}}function Jb(...e){return p.useCallback(Qb(...e),e)}class Zb extends p.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(_r(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=_r(s)&&s.offsetWidth||0,i=_r(s)&&s.offsetHeight||0,o=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(o.height),l.width=parseFloat(o.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=r-l.width-l.left,l.bottom=i-l.height-l.top,l.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Yb({children:e,isPresent:t,anchorX:n,anchorY:s,root:r,pop:i}){const o=p.useId(),l=p.useRef(null),c=p.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:u}=p.useContext(ao),d=e.props?.ref??e?.ref,h=Jb(l,d);return p.useInsertionEffect(()=>{const{width:m,height:f,top:g,left:y,right:C,bottom:w,direction:N}=c.current;if(t||i===!1||!l.current||!m||!f)return;const S=N==="rtl",E=n==="left"?S?`right: ${C}`:`left: ${y}`:S?`left: ${y}`:`right: ${C}`,I=s==="bottom"?`bottom: ${w}`:`top: ${g}`;l.current.dataset.motionPopId=o;const k=document.createElement("style");u&&(k.nonce=u);const z=r??document.head;return z.appendChild(k),k.sheet&&k.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
  ${E}px !important;
130
130
  ${I}px !important;
131
131
  }
132
- `),()=>{l.current?.removeAttribute("data-motion-pop-id"),z.contains(k)&&z.removeChild(k)}},[t]),a.jsx(Zb,{isPresent:t,childRef:l,sizeRef:c,pop:i,children:i===!1?e:p.cloneElement(e,{ref:h})})}const Kb=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:o,anchorX:l,anchorY:c,root:u})=>{const d=oo(Xb),h=p.useId();let m=!0,f=p.useMemo(()=>(m=!1,{id:h,initial:t,isPresent:n,custom:r,onExitComplete:g=>{d.set(g,!0);for(const y of d.values())if(!y)return;s&&s()},register:g=>(d.set(g,!1),()=>d.delete(g))}),[n,d,s]);return i&&m&&(f={...f}),p.useMemo(()=>{d.forEach((g,y)=>d.set(y,!1))},[n]),p.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=a.jsx(Yb,{pop:o==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:u,children:e}),a.jsx(Rs.Provider,{value:f,children:e})};function Xb(){return new Map}function Ac(e=!0){const t=p.useContext(Rs);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 ts=e=>e.key||"";function sl(e){const t=[];return p.Children.forEach(e,n=>{p.isValidElement(n)&&t.push(n)}),t}const zc=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:o=!1,anchorX:l="left",anchorY:c="top",root:u})=>{const[d,h]=Ac(o),m=p.useMemo(()=>sl(e),[e]),f=o&&!d?[]:m.map(ts),g=p.useRef(!0),y=p.useRef(m),C=oo(()=>new Map),w=p.useRef(new Set),[N,S]=p.useState(m),[E,I]=p.useState(m);Ic(()=>{g.current=!1,y.current=m;for(let D=0;D<E.length;D++){const F=ts(E[D]);f.includes(F)?(C.delete(F),w.current.delete(F)):C.get(F)!==!0&&C.set(F,!1)}},[E,f.length,f.join("-")]);const k=[];if(m!==N){let D=[...m];for(let F=0;F<E.length;F++){const _=E[F],A=ts(_);f.includes(A)||(D.splice(F,0,_),k.push(_))}return i==="wait"&&k.length&&(D=k),I(sl(D)),S(m),null}const{forceRender:z}=p.useContext(io);return a.jsx(a.Fragment,{children:E.map(D=>{const F=ts(D),_=o&&!d?!1:m===E||f.includes(F),A=()=>{if(w.current.has(F))return;if(C.has(F))w.current.add(F),C.set(F,!0);else return;let L=!0;C.forEach(O=>{O||(L=!1)}),L&&(z?.(),I(y.current),o&&h?.(),s&&s())};return a.jsx(Kb,{isPresent:_,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:i,root:u,onExitComplete:_?void 0:A,anchorX:l,anchorY:c,children:D},F)})})},_c=p.createContext({strict:!1}),rl={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 il=!1;function e0(){if(il)return;const e={};for(const t in rl)e[t]={isEnabled:n=>rl[t].some(s=>!!n[s])};Dl(e),il=!0}function Lc(){return e0(),lp()}function t0(e){const t=Lc();for(const n in e)t[n]={...t[n],...e[n]};Dl(t)}const n0=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 js(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||n0.has(e)}let Rc=e=>!js(e);function s0(e){typeof e=="function"&&(Rc=t=>t.startsWith("on")?!js(t):e(t))}try{s0(require("@emotion/is-prop-valid").default)}catch{}function r0(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||Ui(e[r])||(Rc(r)||n===!0&&js(r)||!t&&!js(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const Ms=p.createContext({});function i0(e,t){if(Fl(e)){const{initial:n,animate:s}=e;return{initial:n===!1||ea(n)?n:void 0,animate:ea(s)?s:void 0}}return e.inherit!==!1?t:{}}function o0(e){const{initial:t,animate:n}=i0(e,p.useContext(Ms));return p.useMemo(()=>({initial:t,animate:n}),[ol(t),ol(n)])}function ol(e){return Array.isArray(e)?e.join(" "):e}const lo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Mc(e,t,n){for(const s in t)!Ui(t[s])&&!cp(s,n)&&(e[s]=t[s])}function a0({transformTemplate:e},t){return p.useMemo(()=>{const n=lo();return up(n,t,e),Object.assign({},n.vars,n.style)},[t])}function l0(e,t){const n=e.style||{},s={};return Mc(s,n,e),Object.assign(s,a0(e,t)),s}function c0(e,t){const n={},s=l0(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 Oc=()=>({...lo(),attrs:{}});function u0(e,t,n,s){const r=p.useMemo(()=>{const i=Oc();return dp(i,t,hp(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Mc(i,e.style,e),r.style={...i,...r.style}}return r}const d0=["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 co(e){return typeof e!="string"||e.includes("-")?!1:!!(d0.indexOf(e)>-1||/[A-Z]/u.test(e))}function h0(e,t,n,{latestValues:s},r,i=!1,o){const c=(o??co(e)?u0:c0)(t,s,r,e),u=r0(t,typeof e=="string",i),d=e!==p.Fragment?{...u,...c,ref:n}:{},{children:h}=t,m=p.useMemo(()=>Ui(h)?h.get():h,[h]);return p.createElement(e,{...d,children:m})}function f0({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:p0(n,s,r,e),renderState:t()}}function p0(e,t,n,s){const r={},i=s(e,{});for(const m in i)r[m]=fp(i[m]);let{initial:o,animate:l}=e;const c=Fl(e),u=pp(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const h=d?l:o;if(h&&typeof h!="boolean"&&!Bl(h)){const m=Array.isArray(h)?h:[h];for(let f=0;f<m.length;f++){const g=mp(e,m[f]);if(g){const{transitionEnd:y,transition:C,...w}=g;for(const N in w){let S=w[N];if(Array.isArray(S)){const E=d?S.length-1:0;S=S[E]}S!==null&&(r[N]=S)}for(const N in y)r[N]=y[N]}}}return r}const Dc=e=>(t,n)=>{const s=p.useContext(Ms),r=p.useContext(Rs),i=()=>f0(e,t,s,r);return n?i():oo(i)},m0=Dc({scrapeMotionValuesFromProps:gp,createRenderState:lo}),g0=Dc({scrapeMotionValuesFromProps:xp,createRenderState:Oc}),x0=Symbol.for("motionComponentSymbol");function y0(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 l=o(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[t])}const Fc=p.createContext({});function Kt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function b0(e,t,n,s,r,i){const{visualElement:o}=p.useContext(Ms),l=p.useContext(_c),c=p.useContext(Rs),u=p.useContext(ao),d=u.reducedMotion,h=u.skipAnimations,m=p.useRef(null),f=p.useRef(!1);s=s||l.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:h,isSVG:i}),f.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const g=m.current,y=p.useContext(Fc);g&&!g.projection&&r&&(g.type==="html"||g.type==="svg")&&w0(m.current,n,r,y);const C=p.useRef(!1);p.useInsertionEffect(()=>{g&&C.current&&g.update(n,c)});const w=n[yp],N=p.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Ic(()=>{f.current=!0,g&&(C.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),N.current&&g.animationState&&g.animationState.animateChanges())}),p.useEffect(()=>{g&&(!N.current&&g.animationState&&g.animationState.animateChanges(),N.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),N.current=!1),g.enteringChildren=void 0)}),g}function w0(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:u,layoutAnchor:d,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Bc(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||l&&Kt(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:h,layoutScroll:c,layoutRoot:u,layoutAnchor:d})}function Bc(e){if(e)return e.options.allowProjection!==!1?e.projection:Bc(e.parent)}function ti(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&t0(s);const i=n?n==="svg":co(e),o=i?g0:m0;function l(u,d){let h;const m={...p.useContext(ao),...u,layoutId:S0(u)},{isStatic:f}=m,g=o0(u),y=o(u,f);if(!f&&typeof window<"u"){v0();const C=C0(m);h=C.MeasureLayout,g.visualElement=b0(e,y,m,r,C.ProjectionNode,i)}return a.jsxs(Ms.Provider,{value:g,children:[h&&g.visualElement?a.jsx(h,{visualElement:g.visualElement,...m}):null,h0(e,u,y0(y,g.visualElement,d),y,f,t,i)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=p.forwardRef(l);return c[x0]=e,c}function S0({layoutId:e}){const t=p.useContext(io).id;return t&&e!==void 0?t+"-"+e:e}function v0(e,t){p.useContext(_c).strict}function C0(e){const t=Lc(),{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 k0(e,t){if(typeof Proxy>"u")return ti;const n=new Map,s=(i,o)=>ti(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,ti(o,void 0,e,t)),n.get(o))})}const E0=(e,t)=>t.isSVG??co(e)?new bp(t):new wp(t,{allowProjection:e!==p.Fragment});class j0 extends At{constructor(t){super(t),t.animationState||(t.animationState=Sp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Bl(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 N0=0;class P0 extends At{constructor(){super(...arguments),this.id=N0++,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 l=vp(this.node,i,o);if(l){const{transition:c,transitionEnd:u,...d}=l;for(const h in d)this.node.getValue(h)?.jump(d[h])}}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 T0={animation:{Feature:j0},exit:{Feature:P0}};function On(e){return{point:{x:e.pageX,y:e.pageY}}}const I0=e=>t=>$l(t)&&e(t,On(t));function Tn(e,t,n,s){return Ss(e,t,I0(n),s)}const $c=({current:e})=>e?e.ownerDocument.defaultView:null,al=(e,t)=>Math.abs(e-t);function A0(e,t){const n=al(e.x,t.x),s=al(e.y,t.y);return Math.sqrt(n**2+s**2)}const ll=new Set(["auto","scroll"]);class Vc{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ns(this.lastRawMoveEventInfo,this.transformPagePoint));const f=ni(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=A0(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:C}=f,{timestamp:w}=ta;this.history.push({...C,timestamp:w});const{onStart:N,onMove:S}=this.handlers;g||(N&&N(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=ns(g,this.transformPagePoint),et.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:C,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const N=ni(f.type==="pointercancel"?this.lastMoveEventInfo:ns(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,N),C&&C(f,N)},!$l(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const c=On(t),u=ns(c,this.transformPagePoint),{point:d}=u,{timestamp:h}=ta;this.history=[{...d,timestamp:h}];const{onSessionStart:m}=n;m&&m(t,ni(u,this.history)),this.removeListeners=Vl(Tn(this.contextWindow,"pointermove",this.handlePointerMove),Tn(this.contextWindow,"pointerup",this.handlePointerUp),Tn(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(ll.has(s.overflowX)||ll.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),et.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Cp(this.updatePoint)}}function ns(e,t){return t?{point:t(e.point)}:e}function cl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ni({point:e},t){return{point:e,delta:cl(e,Uc(t)),offset:cl(e,z0(t)),velocity:_0(t,.1)}}function z0(e){return e[0]}function Uc(e){return e[e.length-1]}function _0(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Uc(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>na(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>na(t)*2&&(s=e[1]);const i=kp(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 L0(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?vs(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?vs(n,e,s.max):Math.min(e,n)),e}function ul(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 R0(e,{top:t,left:n,bottom:s,right:r}){return{x:ul(e.x,n,r),y:ul(e.y,t,s)}}function dl(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 M0(e,t){return{x:dl(e.x,t.x),y:dl(e.y,t.y)}}function O0(e,t){let n=.5;const s=gi(e),r=gi(t);return r>s?n=sa(t.min,t.max-s,e.min):s>r&&(n=sa(e.min,e.max-r,t.min)),Ep(0,1,n)}function D0(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 Ni=.35;function F0(e=Ni){return e===!1?e=0:e===!0&&(e=Ni),{x:hl(e,"left","right"),y:hl(e,"top","bottom")}}function hl(e,t,n){return{min:fl(e,t),max:fl(e,n)}}function fl(e,t){return typeof e=="number"?e:e[t]||0}const B0=new WeakMap;class $0{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=jp(),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=h=>{n&&this.snapToCursor(On(h).point),this.stopAnimation()},o=(h,m)=>{const{drag:f,dragPropagation:g,onDragStart:y}=this.getProps();if(f&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ap(f),!this.openDragLock))return;this.latestPointerEvent=h,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),Pt(w=>{let N=this.getAxisMotionValue(w).get()||0;if(zp.test(N)){const{projection:S}=this.visualElement;if(S&&S.layout){const E=S.layout.layoutBox[w];E&&(N=gi(E)*(parseFloat(N)/100))}}this.originPoint[w]=N}),y&&et.update(()=>y(h,m),!1,!0),ra(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:f,dragDirectionLock:g,onDirectionLock:y,onDrag:C}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=m;if(g&&this.currentDirection===null){this.currentDirection=U0(w),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),C&&et.update(()=>C(h,m),!1,!0)},c=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Vc(t,{onSessionStart:i,onStart:o,onMove:l,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:$c(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:l}=this.getProps();l&&et.postRender(()=>l(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||!ss(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=L0(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&&Kt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=R0(s.layoutBox,t):this.constraints=!1,this.elastic=F0(n),r!==this.constraints&&!Kt(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&Pt(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=D0(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Kt(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=Np(s,r.root,this.visualElement.getTransformPagePoint());let o=M0(r.layout.layoutBox,i);if(n){const l=n(Pp(o));this.hasMutatedConstraints=!!l,l&&(o=Tp(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},u=Pt(d=>{if(!ss(d,n,this.currentDirection))return;let h=c&&c[d]||{};(o===!0||o===d)&&(h={min:0,max:0});const m=r?200:1e6,f=r?40:1e7,g={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ra(this.visualElement,t),s.start(Ip(t,s,0,n,this.visualElement,!1))}stopAnimation(){Pt(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){Pt(n=>{const{drag:s}=this.getProps();if(!ss(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:l}=r.layout.layoutBox[n],c=i.get()||0;i.set(t[n]-vs(o,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Kt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Pt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();r[o]=O0({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(),Pt(o=>{if(!ss(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];l.set(vs(c,u,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;B0.set(this.visualElement,this);const t=this.visualElement.current,n=Tn(t,"pointerdown",u=>{const{drag:d,dragListener:h=!0}=this.getProps(),m=u.target,f=m!==t&&_p(m);d&&h&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Kt(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=V0(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),et.read(r);const l=Ss(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:d})=>{this.isDragging&&d&&(Pt(h=>{const m=this.getAxisMotionValue(h);m&&(this.originPoint[h]+=u[h].translate,m.set(m.get()+u[h].translate))}),this.visualElement.render())}));return()=>{l(),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=Ni,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function pl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function V0(e,t,n){const s=ia(e,pl(n)),r=ia(t,pl(n));return()=>{s(),r()}}function ss(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function U0(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class H0 extends At{constructor(t){super(t),this.removeGroupControls=cs,this.removeListeners=cs,this.controls=new $0(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||cs}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 si=e=>(t,n)=>{e&&et.update(()=>e(t,n),!1,!0)};class q0 extends At{constructor(){super(...arguments),this.removePointerDownListener=cs}onPointerDown(t){this.session=new Vc(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$c(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:si(t),onStart:si(n),onMove:si(s),onEnd:(i,o)=>{delete this.session,r&&et.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Tn(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 ri=!1;class W0 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),ri&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Rp.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}),ri=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||et.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Lp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;ri=!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 Hc(e){const[t,n]=Ac(),s=p.useContext(io);return a.jsx(W0,{...e,layoutGroup:s,switchLayoutGroup:p.useContext(Fc),isPresent:t,safeToRemove:n})}const G0={pan:{Feature:q0},drag:{Feature:H0,ProjectionNode:Ul,MeasureLayout:Hc}};function ml(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&&et.postRender(()=>i(t,On(t)))}class Q0 extends At{mount(){const{current:t}=this.node;t&&(this.unmount=Mp(t,(n,s)=>(ml(this.node,s,"Start"),r=>ml(this.node,r,"End"))))}unmount(){}}class J0 extends At{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=Vl(Ss(this.node.current,"focus",()=>this.onFocus()),Ss(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gl(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&&et.postRender(()=>i(t,On(t)))}class Z0 extends At{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Op(t,(r,i)=>(gl(this.node,i,"Start"),(o,{success:l})=>gl(this.node,o,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Pi=new WeakMap,ii=new WeakMap,Y0=e=>{const t=Pi.get(e.target);t&&t(e)},K0=e=>{e.forEach(Y0)};function X0({root:e,...t}){const n=e||document;ii.has(n)||ii.set(n,{});const s=ii.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(K0,{root:e,...t})),s[r]}function ew(e,t,n){const s=X0(t);return Pi.set(e,n),s.observe(e),()=>{Pi.delete(e),s.unobserve(e)}}const tw={some:0,all:1};class nw extends At{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]},l=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:h}=this.node.getProps(),m=u?d:h;m&&m(c)};this.stopObserver=ew(this.node.current,o,l)}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:Z0},focus:{Feature:J0},hover:{Feature:Q0}},iw={layout:{ProjectionNode:Ul,MeasureLayout:Hc}},ow={...T0,...rw,...G0,...iw},Ti=k0(ow,E0);async function Ns(e){if(typeof window>"u")return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("[OpenLearn Clipboard] Failed to copy text to clipboard:",t),!1}}function aw(){const e=he(i=>i.toasts),[t,n]=p.useState(null),s=async(i,o)=>{i.stopPropagation();const l=`[${o.title}] ${o.message}`;await Ns(l)&&(n(o.id),setTimeout(()=>n(null),2e3))},r=i=>{switch(i){case"error":return{border:"border-l-4 border-rose-500",iconBg:"bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400",icon:a.jsx(hi,{size:16})};case"warning":return{border:"border-l-4 border-amber-500",iconBg:"bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400",icon:a.jsx($i,{size:16})};case"info":return{border:"border-l-4 border-blue-500",iconBg:"bg-blue-50 text-blue-600 dark:bg-blue-950/60 dark:text-blue-400",icon:a.jsx(ep,{size:16})};case"success":default:return{border:"border-l-4 border-emerald-500",iconBg:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400",icon:a.jsx(Ln,{size:16})}}};return a.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:a.jsx(zc,{children:e.map(i=>{const o=r(i.type),l=t===i.id;return a.jsxs(Ti.div,{initial:{opacity:0,y:50,x:50,scale:.9},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,scale:.85,transition:{duration:.2}},transition:{type:"spring",stiffness:300,damping:24},className:`pointer-events-auto w-full bg-white dark:bg-slate-900 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 ${o.border} overflow-hidden text-gray-900 dark:text-gray-100`,id:`toast-${i.id}`,children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`p-1 rounded-full shrink-0 ${o.iconBg}`,children:o.icon}),a.jsx("p",{className:"font-semibold text-sm font-sans truncate",children:i.title})]}),(i.type==="error"||i.type==="warning")&&a.jsxs("button",{type:"button",onClick:c=>s(c,i),className:`text-xs font-bold px-1.5 py-0.5 rounded transition-all flex items-center gap-1 cursor-pointer shrink-0 ${l?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 dark:bg-slate-800 dark:hover:bg-slate-700 text-gray-600 dark:text-gray-300"}`,title:"复制错误内容",children:[l?a.jsx(yt,{size:11}):a.jsx(An,{size:11}),a.jsx("span",{children:l?"已复制":"复制"})]})]}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 leading-relaxed font-sans break-words",children:i.message})]}),a.jsx("button",{type:"button",onClick:()=>Ee.getState().removeToast(i.id),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-slate-800 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:a.jsx(ot,{size:14})})]},i.id)})})})}function lw({showRightSidebar:e,setShowRightSidebar:t,rightSidebarTab:n,setRightSidebarTab:s,effectiveAgentProviderId:r,agentProviderId:i,setAgentProviderId:o,aiProviders:l,selectedAgentProvider:c,chatLog:u,loading:d,input:h,setInput:m,handleSend:f,chatAttachments:g,setChatAttachments:y,handleChatFileChange:C,handleChatDrop:w,onClearAgentMemory:N,events:S,lang:E,t:I}){const k=p.useRef(null);return p.useEffect(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[u]),a.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?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[a.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:[a.jsx(zr,{size:14})," Agent"]}),a.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:[a.jsx(ls,{size:14})," Shell"]}),a.jsx("button",{onClick:()=>t(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:a.jsx(tp,{size:14})})]}),n==="agent"?a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:a.jsx(zr,{size:16})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:I.agentTitle}),a.jsx("p",{className:"text-xs text-gray-500",children:I.agentSubtitle}),a.jsxs("button",{onClick:N,title:E==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-xs text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",E==="zh"?"清除记忆":"Clear memory"]})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[a.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-gray-400",children:E==="zh"?"AI 提供商":"AI Provider"}),a.jsxs("div",{className:"relative w-full",children:[l.length===0?a.jsx("select",{disabled:!0,value:"",className:"w-full appearance-none rounded-xl border border-amber-200 bg-amber-50/50 px-3 py-2 pr-9 text-xs font-medium text-amber-700 shadow-xs outline-none cursor-not-allowed",children:a.jsx("option",{value:"",children:E==="zh"?"未配置 AI 提供商":"No AI Provider"})}):a.jsx("select",{value:r,onChange:z=>o(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 pr-9 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:l.map(z=>a.jsx("option",{value:z.id,children:z.name},z.id))}),a.jsx(Ps,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),a.jsx("div",{className:"text-xs text-gray-400 truncate w-full text-right",title:c?.model_name||"",children:c?`${c.model_name}`:E==="zh"?"未配置提供商":"No Provider"})]})]})}),l.length===0&&a.jsxs("div",{className:"mx-4 mt-3 p-3 bg-amber-50 border border-amber-200/80 rounded-xl text-xs text-amber-900 flex items-start gap-2 shadow-xs shrink-0",children:[a.jsx($i,{size:15,className:"shrink-0 text-amber-600 mt-0.5"}),a.jsxs("div",{className:"flex-1 leading-relaxed",children:[a.jsx("span",{className:"font-semibold",children:E==="zh"?"未配置 AI 提供商":"No AI Provider Configured"}),a.jsx("p",{className:"mt-0.5 text-amber-700",children:E==="zh"?"请前往「系统管理 -> AI 提供商管理」添加大模型服务(如 DeepSeek、Qwen、OpenAI 等)。":'Please configure an AI provider in "System Management -> AI Provider Management" to use the AI assistant.'})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u.map((z,D)=>a.jsx("div",{className:`flex flex-col ${z.role==="user"?"items-end":"items-start"}`,children:a.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${z.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:z.content})},D)),d&&a.jsx("div",{className:"flex items-start",children:a.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:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),a.jsx("div",{ref:k})]}),a.jsxs("form",{onSubmit:f,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:z=>z.preventDefault(),onDrop:w,children:[g.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:g.map((z,D)=>a.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full text-xs",children:[a.jsx(Rl,{size:10,className:"shrink-0"}),a.jsx("span",{className:"truncate max-w-[100px]",title:z.name,children:z.name}),a.jsx("button",{type:"button",onClick:()=>y(F=>F.filter((_,A)=>A!==D)),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:a.jsx(ot,{size:10})})]},D))}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.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:[a.jsx(np,{size:14}),a.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:C,accept:".csv,.txt,.json,.md"})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"text",value:h,disabled:l.length===0,onChange:z=>m(z.target.value),placeholder:l.length===0?E==="zh"?"请先配置 AI 提供商":"Please configure AI provider first":I.placeholder,className:"w-full bg-gray-50 border border-gray-200 rounded-full pl-4 pr-10 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all disabled:opacity-60 disabled:cursor-not-allowed"}),a.jsx("button",{type:"submit",disabled:d||!h.trim()||l.length===0,className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:a.jsx(sp,{size:10})})]})]})]})]}):a.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-xs min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[a.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:a.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[a.jsx(ls,{size:14}),a.jsx("span",{className:"text-xs",children:I.eventStream})]})}),a.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:S.length===0?a.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):S.map((z,D)=>a.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[a.jsxs("span",{className:"text-gray-500 shrink-0 text-xs",children:["[",new Date(z.timestamp).toLocaleTimeString(),"]"]}),a.jsx("span",{className:"text-blue-400 shrink-0 truncate text-xs",title:z.source,children:z.source})]}),a.jsx("div",{className:"text-green-300 font-bold",children:z.type}),a.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:z.payload})]},D))})]})]}):a.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-gray-400 w-full",onClick:()=>t(!0),children:[a.jsx(zr,{size:18,className:"mb-6 hover:text-indigo-500"}),a.jsx(ls,{size:18,className:"hover:text-indigo-500"}),a.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:a.jsx("div",{className:"uppercase tracking-widest text-xs rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const cw=p.lazy(()=>Ie(()=>import("./ImportModal-B2acbUT8.js"),[]).then(e=>({default:e.ImportModal}))),uw=p.lazy(()=>Ie(()=>import("./CourseWizardModal-DO1n4T2T.js"),[]).then(e=>({default:e.CourseWizardModal}))),dw=p.lazy(()=>Ie(()=>import("./ImportLessonsModal-C25NubUA.js"),[]).then(e=>({default:e.ImportLessonsModal}))),hw=p.lazy(()=>Ie(()=>import("./QuizGeneratorModal-bCASRfsi.js"),[]).then(e=>({default:e.QuizGeneratorModal}))),fw=p.lazy(()=>Ie(()=>import("./StudentPreviewModal-nO5C3nq5.js"),[]).then(e=>({default:e.StudentPreviewModal}))),pw=p.lazy(()=>Ie(()=>import("./ProcessLogsModal-MtK-Pe4R.js"),[]).then(e=>({default:e.ProcessLogsModal}))),mw=p.lazy(()=>Ie(()=>import("./CloudDriveModal-BMjXCoju.js"),[]).then(e=>({default:e.CloudDriveModal}))),gw=p.lazy(()=>Ie(()=>import("./SystemResourceLibraryModal-D00BK5Xh.js"),[]).then(e=>({default:e.SystemResourceLibraryModal}))),xw=p.lazy(()=>Ie(()=>import("./BatchPickerModal-MnNnNwFT.js"),[]).then(e=>({default:e.BatchPickerModal}))),yw=p.lazy(()=>Ie(()=>import("./ExportWeightModal-d9A2R6Ur.js"),[]).then(e=>({default:e.ExportWeightModal}))),bw=p.lazy(()=>Ie(()=>import("./NotificationDetailModal-D4w-m1D-.js"),[]).then(e=>({default:e.NotificationDetailModal}))),ww=p.lazy(()=>Ie(()=>import("./HelpTour-Dlc1vvy3.js"),[]).then(e=>({default:e.HelpTour}))),Sw=p.lazy(()=>Ie(()=>import("./CoursewareHubPanel-CEK_QEc5.js"),[]).then(e=>({default:e.CoursewareHubPanel})));function vw(e){const{lang:t,t:n,showImportModal:s=!1,setShowImportModal:r=()=>{},handleImportFile:i=()=>{},importError:o=null,importSuccess:l=null,isImporting:c=!1,downloadCSVTemplate:u=()=>{},addToast:d=()=>{},generateTemplateContent:h=()=>"",isImportLessonsOpen:m=!1,setIsImportLessonsOpen:f=()=>{},importStatus:g="idle",setIsDraggingImport:y=()=>{},handleCSVFileChange:C=()=>{},downloadCsvTemplate:w=()=>{},isDraggingImport:N=!1,previewImportData:S=[],setPreviewImportData:E=()=>{},setImportStatus:I=()=>{},importProgress:k=0,importProgressTotal:z=0,importErrorMsg:D="",setImportErrorMsg:F=()=>{},handleCSVImportSubmit:_=()=>{},lessons:A=[],fetchClassDashboard:L=()=>{},isLessonPreviewVisible:O=!1,setIsLessonPreviewVisible:R=()=>{},selectedLesson:P=null,previewFullscreenPanel:T="none",setPreviewFullscreenPanel:W=()=>{},previewLessonTab:j="whiteboard",setPreviewLessonTab:$=()=>{},activeRole:x="teacher",elements:oe=[],activeSegmentId:pe=null,setActiveSegmentId:b=()=>{},fetchElements:J=()=>{},currentVfsParent:U=null,setCurrentVfsParent:Q=()=>{},vfsNodes:re=[],previewSelectedCourseware:se=null,setPreviewSelectedCourseware:we=()=>{},showProcessLogs:me=null,setShowProcessLogs:le=()=>{},processLogsContent:Ve="",isCloudDriveOpen:wt=!1,setIsCloudDriveOpen:Ft=()=>{},cloudDrivePreviewNode:St=null,setCloudDrivePreviewNode:vt=()=>{},isSystemResourceLibraryOpen:_t=!1,setIsSystemResourceLibraryOpen:Y=()=>{},systemResourceTab:te="system",setSystemResourceTab:ae=()=>{},selectedLibraryResourceId:je=null,setSelectedLibraryResourceId:Ue=()=>{},loadingLibraryResources:He=!1,libraryResources:ct=[],fetchLibraryResources:Ne=()=>{},classes:M=[],expandedClassId:H=null,isExportWeightModalOpen:K=!1,setIsExportWeightModalOpen:Z=()=>{},quizzesWeight:X=40,setQuizzesWeight:Pe=()=>{},assignmentsWeight:Ze=60,setAssignmentsWeight:Fe=()=>{},handleQuizzesWeightChange:tt=()=>{},handleAssignmentsWeightChange:ut=()=>{},customCategoryOverrides:ge={},setCustomCategoryOverrides:nt=()=>{},classDashboardMap:_e={},exportClassId:Fs="",exportClassName:Dn="",csvPreviewData:Bs=null,handleExportGrades:Ct=()=>{},setSelectedAssignment:Bt=()=>{},setStudentViewStatus:ln=()=>{},setQuizStudentAnswers:$s=()=>{},setSubAssignmentTab:Vs=()=>{},isTourOpen:Us=!1,setIsTourOpen:Hs=()=>{},handleSeedSuccess:qs=()=>{},setTeacherTab:Ws=()=>{},showCoursewareHub:Gs=!1,setShowCoursewareHub:Qs=()=>{}}=e,Ce=e.courseWizard,Js=Ce?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Zs=Ce?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),Ys=Ce?.wizardStep??e.wizardStep??1,cn=Ce?.setWizardStep??e.setWizardStep??(()=>{}),un=Ce?.wizardIsSubmitting??e.wizardIsSubmitting??!1,Fn=Ce?.wizardCourseTitle??e.wizardCourseTitle??"",Ks=Ce?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),$t=Ce?.wizardCourseDescription??e.wizardCourseDescription??"",Xs=Ce?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),Re=Ce?.wizardCourseCategory??e.wizardCourseCategory??"",Bn=Ce?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),er=Ce?.wizardCourseTimeline??e.wizardCourseTimeline??[],$n=Ce?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),tr=Ce?.wizardCourseContent??e.wizardCourseContent??"",Vt=Ce?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),nr=Ce?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),xe=e.quizGenerator,sr=xe?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,rr=xe?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),ir=xe?.quizGenMode??e.quizGenMode??"scan_lesson",or=xe?.setQuizGenMode??e.setQuizGenMode??(()=>{}),ar=xe?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",lr=xe?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),cr=xe?.quizGenTopic??e.quizGenTopic??"",ur=xe?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Lt=xe?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,dr=xe?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),hr=xe?.suggestedObjectives??e.suggestedObjectives??[],fr=xe?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),Vn=xe?.suggestedQuestions??e.suggestedQuestions??[],Un=xe?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),pr=xe?.quizGenTimeLimit??e.quizGenTimeLimit??0,mr=xe?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),Hn=xe?.savingQuiz??e.savingQuiz??!1,dn=xe?.setSavingQuiz??e.setSavingQuiz??(()=>{}),hn=xe?.quizGeneratorClassId??e.quizGeneratorClassId??null,Ye=e.classBatch,gr=Ye?.batchPicker??e.batchPicker??null,ye=Ye?.setBatchPicker??e.setBatchPicker??(()=>{}),Rt=Ye?.batchPickerLesson??e.batchPickerLesson??"",qn=Ye?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),Wn=Ye?.batchPickerDate??e.batchPickerDate??"",Le=Ye?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),dt=Ye?.batchPickerTargetClass??e.batchPickerTargetClass??"",xr=Ye?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),yr=Ye?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Gn=e.studentNotificationsHook,Ut=Gn?.selectedNotificationForModal??e.selectedNotificationForModal??null,br=Gn?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return a.jsxs(p.Suspense,{fallback:null,children:[a.jsx(cw,{show:s,onClose:()=>r(!1),lang:t,handleImportFile:i,importError:o,importSuccess:l,isImporting:c,downloadCSVTemplate:u}),a.jsx(uw,{isCourseWizardOpen:Js,setIsCourseWizardOpen:Zs,lang:t,wizardStep:Ys,setWizardStep:cn,wizardIsSubmitting:un,wizardCourseTitle:Fn,setWizardCourseTitle:Ks,wizardCourseDescription:$t,setWizardCourseDescription:Xs,wizardCourseCategory:Re,setWizardCourseCategory:Bn,wizardCourseTimeline:er,setWizardCourseTimeline:$n,wizardCourseContent:tr,setWizardCourseContent:Vt,addToast:d,generateTemplateContent:h,handleDeployWizardCourse:nr}),a.jsx(dw,{isImportLessonsOpen:m,setIsImportLessonsOpen:f,lang:t,importStatus:g,setIsDraggingImport:y,handleCSVFileChange:C,downloadCsvTemplate:w,isDraggingImport:N,previewImportData:S,setPreviewImportData:E,setImportStatus:I,importProgress:k,importProgressTotal:z,importErrorMsg:D,setImportErrorMsg:F,handleCSVImportSubmit:_}),a.jsx(hw,{isQuizGeneratorOpen:sr,setIsQuizGeneratorOpen:rr,lessons:A,quizGenMode:ir,setQuizGenMode:or,quizGenSelectedLessonId:ar,setQuizGenSelectedLessonId:lr,quizGenTopic:cr,setQuizGenTopic:ur,isGeneratingSuggestions:Lt,setIsGeneratingSuggestions:dr,suggestedObjectives:hr,setSuggestedObjectives:fr,suggestedQuestions:Vn,setSuggestedQuestions:Un,quizGenTimeLimit:pr,setQuizGenTimeLimit:mr,savingQuiz:Hn,setSavingQuiz:dn,quizGeneratorClassId:hn,fetchClassDashboard:L}),a.jsx(fw,{isLessonPreviewVisible:O,setIsLessonPreviewVisible:R,lessons:A,selectedLesson:P,previewFullscreenPanel:T,setPreviewFullscreenPanel:W,previewLessonTab:j,setPreviewLessonTab:$,activeRole:x,elements:oe,activeSegmentId:pe,setActiveSegmentId:b,fetchElements:J,currentVfsParent:U,setCurrentVfsParent:Q,vfsNodes:re,previewSelectedCourseware:se,setPreviewSelectedCourseware:we}),a.jsx(pw,{showProcessLogs:me,setShowProcessLogs:le,processLogsContent:Ve,t:n}),a.jsx(mw,{isOpen:wt,onClose:()=>Ft(!1),vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt}),a.jsx(gw,{isSystemResourceLibraryOpen:_t,setIsSystemResourceLibraryOpen:Y,lang:t,systemResourceTab:te,setSystemResourceTab:ae,selectedLibraryResourceId:je,setSelectedLibraryResourceId:Ue,vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt,loadingLibraryResources:He,libraryResources:ct,fetchLibraryResources:Ne}),a.jsx(xw,{batchPicker:gr,setBatchPicker:ye,batchPickerLesson:Rt,setBatchPickerLesson:qn,batchPickerDate:Wn,setBatchPickerDate:Le,batchPickerTargetClass:dt,setBatchPickerTargetClass:xr,lessons:A,classes:M,expandedClassId:H,confirmBatchPicker:yr,lang:t}),a.jsx(yw,{isExportWeightModalOpen:K,setIsExportWeightModalOpen:Z,lang:t,quizzesWeight:X,setQuizzesWeight:Pe,assignmentsWeight:Ze,setAssignmentsWeight:Fe,handleQuizzesWeightChange:tt,handleAssignmentsWeightChange:ut,customCategoryOverrides:ge,setCustomCategoryOverrides:nt,classDashboardMap:_e,exportClassId:Fs,exportClassName:Dn,csvPreviewData:Bs,handleExportGrades:Ct}),a.jsx(bw,{notification:Ut,onClose:()=>br(null),lang:t,onOpenWorkspace:ht=>{Bt(ht),ln("assignment"),$s({}),Vs("quiz")}}),a.jsx(ww,{isOpen:Us,onClose:()=>Hs(!1),lang:t,onSeedSuccess:qs,onJumpTab:ht=>Ws(ht)}),Gs&&a.jsx(Sw,{onClose:()=>Qs(!1),lang:t})]})}const Cw=["whiteboard.","courseware.","quiz.","rollcall."];class kw{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&&Cw.some(s=>t.type.startsWith(s))&&this.socketBridge(t)}}const Ew=new kw;async function qc(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 l=Array.from(document.querySelectorAll("iframe")).find(c=>c.contentWindow===e.source);if(l&&l.contentWindow){const c=l.contentWindow;c.__LMS_STUDENT__?.attempt_id&&(n=c.__LMS_STUDENT__.attempt_id)}}catch{}if(!n||typeof n!="string")return;if(s==="LMS_CONFIG"){rs("courseware.config_reported",n,t.config??r);return}if(s==="LMS_GET_PROGRESS"){const l=t.requestId,c=e.source;if(l&&c&&typeof c.postMessage=="function"){if(typeof document<"u"&&!Array.from(document.querySelectorAll("iframe")).some(f=>f.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:l,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){rs("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(l){console.error("[LMS Bridge] Failed to submit attempt data to backend:",l)}}else if(o){rs("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(l){console.error("[LMS Bridge] Failed to save progress to backend:",l)}}else{rs("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(l){console.error("[LMS Bridge] Failed to log event to backend:",l)}}}function rs(e,t,n){Ew.publish({id:Dp(),type:e,source:"courseware-bridge",payload:{attemptId:t,data:n},timestamp:Date.now(),correlationId:t})}function jw(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 Wc(e){p.useEffect(()=>{if(!e)return;const t=n=>{qc(n)};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[e])}function Gc(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{}}function Qc(e){if(!(typeof document>"u"))try{const t=Math.min(140,Math.max(85,Math.round(e)));document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"font-scale:changed",payload:{scale:t,fontScale:(t/100).toFixed(2)}},"*"),s.contentWindow?.postMessage({type:"LMS_FONT_SCALE_CHANGED",scale:t,fontScale:(t/100).toFixed(2)},"*")}catch{}})}catch{}}const Jc=Object.freeze(Object.defineProperty({__proto__:null,broadcastFontScaleToIframes:Qc,broadcastThemeToIframes:Gc,processLmsMessage:qc,sendCommandToCourseware:jw,useLmsBridge:Wc},Symbol.toStringTag,{value:"Module"}));function Nw(e){const{session:t,showProcessLogs:n,activeStudentId:s,currentVfsParent:r,selectedLesson:i,selectedAssignment:o,expandedClassId:l,fetchLessons:c,fetchPlugins:u,fetchRegisteredCommands:d,fetchEvents:h,fetchApprovals:m,fetchProcesses:f,fetchClasses:g,fetchTodaySchedules:y,fetchStudents:C,fetchLabs:w,fetchVfs:N,fetchProcessLogs:S,fetchClassStudents:E,fetchElements:I}=e,k=p.useRef(r),z=p.useRef(i),D=p.useRef(o),F=p.useRef(l);p.useEffect(()=>{k.current=r},[r]),p.useEffect(()=>{z.current=i},[i]),p.useEffect(()=>{D.current=o},[o]),p.useEffect(()=>{F.current=l},[l]),p.useEffect(()=>{if(!t)return;const _=t.role==="student",A=t.role==="teacher",L=A&&(t.subRole==="administrator"||t.username==="admin"||t.userId==="usr_admin");c(),u(),d(),y().catch(()=>{}),L&&(h(),m(),f()),A?(g(),C(),w(),N(k.current)):_&&k.current&&N(k.current);let O=!1;const R=setInterval(async()=>{if(!O){O=!0;try{if(L&&(await h(),await m(),await f(),n&&await S(n)),await c(),await d(),await y().catch(()=>{}),A&&(await g(),await C(),await w(),await N(k.current),F.current&&await E(F.current)),z.current&&await I(z.current),D.current){const P=s||D.current.student_id;await I(`assignment-${D.current.id}-student-${P}`)}}finally{O=!1}}},2e3);return()=>clearInterval(R)},[t,n,s]),p.useEffect(()=>{t&&(t.role==="teacher"||r)&&N(r)},[r,t]),p.useEffect(()=>{i&&I(i)},[i])}function Pw(e){const{lang:t,t:n,selectedLesson:s,effectiveAgentProviderId:r,expandedClassId:i,fetchLessons:o,fetchClasses:l,fetchStudents:c,fetchClassStudents:u,fetchClassProgress:d,fetchClassDashboard:h,fetchElements:m}=e,[f,g]=p.useState([{role:"agent",content:n.agentIntro||""}]),[y,C]=p.useState(""),[w,N]=p.useState(!1),[S,E]=p.useState([]);p.useEffect(()=>{f.length===1&&f[0].role==="agent"&&g([{role:"agent",content:n.agentIntro}])},[t,n.agentIntro]);const I=p.useCallback(async _=>{try{const A=await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(_||"")}`);if(!A.ok)return;const L=await A.json(),O=Array.isArray(L.messages)?L.messages:[];O.length>0?g(O.map(R=>({role:R.role==="assistant"?"agent":"user",content:R.content}))):g([{role:"agent",content:n.agentIntro}])}catch{}},[n.agentIntro]),k=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(()=>{I(s)},[s,I]),{chatLog:f,setChatLog:g,input:y,setInput:C,loading:w,setLoading:N,chatAttachments:S,setChatAttachments:E,handleChatFileChange:_=>{_.target.files&&Array.from(_.target.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleChatDrop:_=>{_.preventDefault(),_.dataTransfer.files&&Array.from(_.dataTransfer.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleSend:async _=>{if(_.preventDefault(),!y.trim()||w)return;const A=[...S];let L=y;A.length>0&&(L+=`
132
+ `),()=>{l.current?.removeAttribute("data-motion-pop-id"),z.contains(k)&&z.removeChild(k)}},[t]),a.jsx(Zb,{isPresent:t,childRef:l,sizeRef:c,pop:i,children:i===!1?e:p.cloneElement(e,{ref:h})})}const Kb=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:o,anchorX:l,anchorY:c,root:u})=>{const d=oo(Xb),h=p.useId();let m=!0,f=p.useMemo(()=>(m=!1,{id:h,initial:t,isPresent:n,custom:r,onExitComplete:g=>{d.set(g,!0);for(const y of d.values())if(!y)return;s&&s()},register:g=>(d.set(g,!1),()=>d.delete(g))}),[n,d,s]);return i&&m&&(f={...f}),p.useMemo(()=>{d.forEach((g,y)=>d.set(y,!1))},[n]),p.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=a.jsx(Yb,{pop:o==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:u,children:e}),a.jsx(Rs.Provider,{value:f,children:e})};function Xb(){return new Map}function Ac(e=!0){const t=p.useContext(Rs);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 ts=e=>e.key||"";function sl(e){const t=[];return p.Children.forEach(e,n=>{p.isValidElement(n)&&t.push(n)}),t}const zc=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:o=!1,anchorX:l="left",anchorY:c="top",root:u})=>{const[d,h]=Ac(o),m=p.useMemo(()=>sl(e),[e]),f=o&&!d?[]:m.map(ts),g=p.useRef(!0),y=p.useRef(m),C=oo(()=>new Map),w=p.useRef(new Set),[N,S]=p.useState(m),[E,I]=p.useState(m);Ic(()=>{g.current=!1,y.current=m;for(let D=0;D<E.length;D++){const F=ts(E[D]);f.includes(F)?(C.delete(F),w.current.delete(F)):C.get(F)!==!0&&C.set(F,!1)}},[E,f.length,f.join("-")]);const k=[];if(m!==N){let D=[...m];for(let F=0;F<E.length;F++){const _=E[F],A=ts(_);f.includes(A)||(D.splice(F,0,_),k.push(_))}return i==="wait"&&k.length&&(D=k),I(sl(D)),S(m),null}const{forceRender:z}=p.useContext(io);return a.jsx(a.Fragment,{children:E.map(D=>{const F=ts(D),_=o&&!d?!1:m===E||f.includes(F),A=()=>{if(w.current.has(F))return;if(C.has(F))w.current.add(F),C.set(F,!0);else return;let L=!0;C.forEach(O=>{O||(L=!1)}),L&&(z?.(),I(y.current),o&&h?.(),s&&s())};return a.jsx(Kb,{isPresent:_,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:i,root:u,onExitComplete:_?void 0:A,anchorX:l,anchorY:c,children:D},F)})})},_c=p.createContext({strict:!1}),rl={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 il=!1;function e0(){if(il)return;const e={};for(const t in rl)e[t]={isEnabled:n=>rl[t].some(s=>!!n[s])};Dl(e),il=!0}function Lc(){return e0(),lp()}function t0(e){const t=Lc();for(const n in e)t[n]={...t[n],...e[n]};Dl(t)}const n0=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 js(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||n0.has(e)}let Rc=e=>!js(e);function s0(e){typeof e=="function"&&(Rc=t=>t.startsWith("on")?!js(t):e(t))}try{s0(require("@emotion/is-prop-valid").default)}catch{}function r0(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||Ui(e[r])||(Rc(r)||n===!0&&js(r)||!t&&!js(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const Ms=p.createContext({});function i0(e,t){if(Fl(e)){const{initial:n,animate:s}=e;return{initial:n===!1||ea(n)?n:void 0,animate:ea(s)?s:void 0}}return e.inherit!==!1?t:{}}function o0(e){const{initial:t,animate:n}=i0(e,p.useContext(Ms));return p.useMemo(()=>({initial:t,animate:n}),[ol(t),ol(n)])}function ol(e){return Array.isArray(e)?e.join(" "):e}const lo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Mc(e,t,n){for(const s in t)!Ui(t[s])&&!cp(s,n)&&(e[s]=t[s])}function a0({transformTemplate:e},t){return p.useMemo(()=>{const n=lo();return up(n,t,e),Object.assign({},n.vars,n.style)},[t])}function l0(e,t){const n=e.style||{},s={};return Mc(s,n,e),Object.assign(s,a0(e,t)),s}function c0(e,t){const n={},s=l0(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 Oc=()=>({...lo(),attrs:{}});function u0(e,t,n,s){const r=p.useMemo(()=>{const i=Oc();return dp(i,t,hp(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Mc(i,e.style,e),r.style={...i,...r.style}}return r}const d0=["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 co(e){return typeof e!="string"||e.includes("-")?!1:!!(d0.indexOf(e)>-1||/[A-Z]/u.test(e))}function h0(e,t,n,{latestValues:s},r,i=!1,o){const c=(o??co(e)?u0:c0)(t,s,r,e),u=r0(t,typeof e=="string",i),d=e!==p.Fragment?{...u,...c,ref:n}:{},{children:h}=t,m=p.useMemo(()=>Ui(h)?h.get():h,[h]);return p.createElement(e,{...d,children:m})}function f0({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:p0(n,s,r,e),renderState:t()}}function p0(e,t,n,s){const r={},i=s(e,{});for(const m in i)r[m]=fp(i[m]);let{initial:o,animate:l}=e;const c=Fl(e),u=pp(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const h=d?l:o;if(h&&typeof h!="boolean"&&!Bl(h)){const m=Array.isArray(h)?h:[h];for(let f=0;f<m.length;f++){const g=mp(e,m[f]);if(g){const{transitionEnd:y,transition:C,...w}=g;for(const N in w){let S=w[N];if(Array.isArray(S)){const E=d?S.length-1:0;S=S[E]}S!==null&&(r[N]=S)}for(const N in y)r[N]=y[N]}}}return r}const Dc=e=>(t,n)=>{const s=p.useContext(Ms),r=p.useContext(Rs),i=()=>f0(e,t,s,r);return n?i():oo(i)},m0=Dc({scrapeMotionValuesFromProps:gp,createRenderState:lo}),g0=Dc({scrapeMotionValuesFromProps:xp,createRenderState:Oc}),x0=Symbol.for("motionComponentSymbol");function y0(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 l=o(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[t])}const Fc=p.createContext({});function Kt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function b0(e,t,n,s,r,i){const{visualElement:o}=p.useContext(Ms),l=p.useContext(_c),c=p.useContext(Rs),u=p.useContext(ao),d=u.reducedMotion,h=u.skipAnimations,m=p.useRef(null),f=p.useRef(!1);s=s||l.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:h,isSVG:i}),f.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const g=m.current,y=p.useContext(Fc);g&&!g.projection&&r&&(g.type==="html"||g.type==="svg")&&w0(m.current,n,r,y);const C=p.useRef(!1);p.useInsertionEffect(()=>{g&&C.current&&g.update(n,c)});const w=n[yp],N=p.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Ic(()=>{f.current=!0,g&&(C.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),N.current&&g.animationState&&g.animationState.animateChanges())}),p.useEffect(()=>{g&&(!N.current&&g.animationState&&g.animationState.animateChanges(),N.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),N.current=!1),g.enteringChildren=void 0)}),g}function w0(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:u,layoutAnchor:d,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Bc(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||l&&Kt(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:h,layoutScroll:c,layoutRoot:u,layoutAnchor:d})}function Bc(e){if(e)return e.options.allowProjection!==!1?e.projection:Bc(e.parent)}function ti(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&t0(s);const i=n?n==="svg":co(e),o=i?g0:m0;function l(u,d){let h;const m={...p.useContext(ao),...u,layoutId:S0(u)},{isStatic:f}=m,g=o0(u),y=o(u,f);if(!f&&typeof window<"u"){v0();const C=C0(m);h=C.MeasureLayout,g.visualElement=b0(e,y,m,r,C.ProjectionNode,i)}return a.jsxs(Ms.Provider,{value:g,children:[h&&g.visualElement?a.jsx(h,{visualElement:g.visualElement,...m}):null,h0(e,u,y0(y,g.visualElement,d),y,f,t,i)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=p.forwardRef(l);return c[x0]=e,c}function S0({layoutId:e}){const t=p.useContext(io).id;return t&&e!==void 0?t+"-"+e:e}function v0(e,t){p.useContext(_c).strict}function C0(e){const t=Lc(),{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 k0(e,t){if(typeof Proxy>"u")return ti;const n=new Map,s=(i,o)=>ti(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,ti(o,void 0,e,t)),n.get(o))})}const E0=(e,t)=>t.isSVG??co(e)?new bp(t):new wp(t,{allowProjection:e!==p.Fragment});class j0 extends At{constructor(t){super(t),t.animationState||(t.animationState=Sp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Bl(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 N0=0;class P0 extends At{constructor(){super(...arguments),this.id=N0++,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 l=vp(this.node,i,o);if(l){const{transition:c,transitionEnd:u,...d}=l;for(const h in d)this.node.getValue(h)?.jump(d[h])}}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 T0={animation:{Feature:j0},exit:{Feature:P0}};function On(e){return{point:{x:e.pageX,y:e.pageY}}}const I0=e=>t=>$l(t)&&e(t,On(t));function Tn(e,t,n,s){return Ss(e,t,I0(n),s)}const $c=({current:e})=>e?e.ownerDocument.defaultView:null,al=(e,t)=>Math.abs(e-t);function A0(e,t){const n=al(e.x,t.x),s=al(e.y,t.y);return Math.sqrt(n**2+s**2)}const ll=new Set(["auto","scroll"]);class Vc{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ns(this.lastRawMoveEventInfo,this.transformPagePoint));const f=ni(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=A0(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:C}=f,{timestamp:w}=ta;this.history.push({...C,timestamp:w});const{onStart:N,onMove:S}=this.handlers;g||(N&&N(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=ns(g,this.transformPagePoint),et.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:C,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const N=ni(f.type==="pointercancel"?this.lastMoveEventInfo:ns(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,N),C&&C(f,N)},!$l(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const c=On(t),u=ns(c,this.transformPagePoint),{point:d}=u,{timestamp:h}=ta;this.history=[{...d,timestamp:h}];const{onSessionStart:m}=n;m&&m(t,ni(u,this.history)),this.removeListeners=Vl(Tn(this.contextWindow,"pointermove",this.handlePointerMove),Tn(this.contextWindow,"pointerup",this.handlePointerUp),Tn(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(ll.has(s.overflowX)||ll.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),et.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Cp(this.updatePoint)}}function ns(e,t){return t?{point:t(e.point)}:e}function cl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ni({point:e},t){return{point:e,delta:cl(e,Uc(t)),offset:cl(e,z0(t)),velocity:_0(t,.1)}}function z0(e){return e[0]}function Uc(e){return e[e.length-1]}function _0(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Uc(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>na(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>na(t)*2&&(s=e[1]);const i=kp(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 L0(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?vs(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?vs(n,e,s.max):Math.min(e,n)),e}function ul(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 R0(e,{top:t,left:n,bottom:s,right:r}){return{x:ul(e.x,n,r),y:ul(e.y,t,s)}}function dl(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 M0(e,t){return{x:dl(e.x,t.x),y:dl(e.y,t.y)}}function O0(e,t){let n=.5;const s=gi(e),r=gi(t);return r>s?n=sa(t.min,t.max-s,e.min):s>r&&(n=sa(e.min,e.max-r,t.min)),Ep(0,1,n)}function D0(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 Ni=.35;function F0(e=Ni){return e===!1?e=0:e===!0&&(e=Ni),{x:hl(e,"left","right"),y:hl(e,"top","bottom")}}function hl(e,t,n){return{min:fl(e,t),max:fl(e,n)}}function fl(e,t){return typeof e=="number"?e:e[t]||0}const B0=new WeakMap;class $0{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=jp(),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=h=>{n&&this.snapToCursor(On(h).point),this.stopAnimation()},o=(h,m)=>{const{drag:f,dragPropagation:g,onDragStart:y}=this.getProps();if(f&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ap(f),!this.openDragLock))return;this.latestPointerEvent=h,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),Pt(w=>{let N=this.getAxisMotionValue(w).get()||0;if(zp.test(N)){const{projection:S}=this.visualElement;if(S&&S.layout){const E=S.layout.layoutBox[w];E&&(N=gi(E)*(parseFloat(N)/100))}}this.originPoint[w]=N}),y&&et.update(()=>y(h,m),!1,!0),ra(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:f,dragDirectionLock:g,onDirectionLock:y,onDrag:C}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=m;if(g&&this.currentDirection===null){this.currentDirection=U0(w),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),C&&et.update(()=>C(h,m),!1,!0)},c=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Vc(t,{onSessionStart:i,onStart:o,onMove:l,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:$c(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:l}=this.getProps();l&&et.postRender(()=>l(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||!ss(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=L0(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&&Kt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=R0(s.layoutBox,t):this.constraints=!1,this.elastic=F0(n),r!==this.constraints&&!Kt(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&Pt(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=D0(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Kt(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=Np(s,r.root,this.visualElement.getTransformPagePoint());let o=M0(r.layout.layoutBox,i);if(n){const l=n(Pp(o));this.hasMutatedConstraints=!!l,l&&(o=Tp(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},u=Pt(d=>{if(!ss(d,n,this.currentDirection))return;let h=c&&c[d]||{};(o===!0||o===d)&&(h={min:0,max:0});const m=r?200:1e6,f=r?40:1e7,g={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ra(this.visualElement,t),s.start(Ip(t,s,0,n,this.visualElement,!1))}stopAnimation(){Pt(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){Pt(n=>{const{drag:s}=this.getProps();if(!ss(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:l}=r.layout.layoutBox[n],c=i.get()||0;i.set(t[n]-vs(o,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Kt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Pt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();r[o]=O0({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(),Pt(o=>{if(!ss(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];l.set(vs(c,u,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;B0.set(this.visualElement,this);const t=this.visualElement.current,n=Tn(t,"pointerdown",u=>{const{drag:d,dragListener:h=!0}=this.getProps(),m=u.target,f=m!==t&&_p(m);d&&h&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Kt(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=V0(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),et.read(r);const l=Ss(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:d})=>{this.isDragging&&d&&(Pt(h=>{const m=this.getAxisMotionValue(h);m&&(this.originPoint[h]+=u[h].translate,m.set(m.get()+u[h].translate))}),this.visualElement.render())}));return()=>{l(),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=Ni,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function pl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function V0(e,t,n){const s=ia(e,pl(n)),r=ia(t,pl(n));return()=>{s(),r()}}function ss(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function U0(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class H0 extends At{constructor(t){super(t),this.removeGroupControls=cs,this.removeListeners=cs,this.controls=new $0(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||cs}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 si=e=>(t,n)=>{e&&et.update(()=>e(t,n),!1,!0)};class q0 extends At{constructor(){super(...arguments),this.removePointerDownListener=cs}onPointerDown(t){this.session=new Vc(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$c(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:si(t),onStart:si(n),onMove:si(s),onEnd:(i,o)=>{delete this.session,r&&et.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Tn(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 ri=!1;class W0 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),ri&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Rp.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}),ri=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||et.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Lp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;ri=!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 Hc(e){const[t,n]=Ac(),s=p.useContext(io);return a.jsx(W0,{...e,layoutGroup:s,switchLayoutGroup:p.useContext(Fc),isPresent:t,safeToRemove:n})}const G0={pan:{Feature:q0},drag:{Feature:H0,ProjectionNode:Ul,MeasureLayout:Hc}};function ml(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&&et.postRender(()=>i(t,On(t)))}class Q0 extends At{mount(){const{current:t}=this.node;t&&(this.unmount=Mp(t,(n,s)=>(ml(this.node,s,"Start"),r=>ml(this.node,r,"End"))))}unmount(){}}class J0 extends At{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=Vl(Ss(this.node.current,"focus",()=>this.onFocus()),Ss(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gl(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&&et.postRender(()=>i(t,On(t)))}class Z0 extends At{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Op(t,(r,i)=>(gl(this.node,i,"Start"),(o,{success:l})=>gl(this.node,o,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Pi=new WeakMap,ii=new WeakMap,Y0=e=>{const t=Pi.get(e.target);t&&t(e)},K0=e=>{e.forEach(Y0)};function X0({root:e,...t}){const n=e||document;ii.has(n)||ii.set(n,{});const s=ii.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(K0,{root:e,...t})),s[r]}function ew(e,t,n){const s=X0(t);return Pi.set(e,n),s.observe(e),()=>{Pi.delete(e),s.unobserve(e)}}const tw={some:0,all:1};class nw extends At{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]},l=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:h}=this.node.getProps(),m=u?d:h;m&&m(c)};this.stopObserver=ew(this.node.current,o,l)}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:Z0},focus:{Feature:J0},hover:{Feature:Q0}},iw={layout:{ProjectionNode:Ul,MeasureLayout:Hc}},ow={...T0,...rw,...G0,...iw},Ti=k0(ow,E0);async function Ns(e){if(typeof window>"u")return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("[OpenLearn Clipboard] Failed to copy text to clipboard:",t),!1}}function aw(){const e=he(i=>i.toasts),[t,n]=p.useState(null),s=async(i,o)=>{i.stopPropagation();const l=`[${o.title}] ${o.message}`;await Ns(l)&&(n(o.id),setTimeout(()=>n(null),2e3))},r=i=>{switch(i){case"error":return{border:"border-l-4 border-rose-500",iconBg:"bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400",icon:a.jsx(hi,{size:16})};case"warning":return{border:"border-l-4 border-amber-500",iconBg:"bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400",icon:a.jsx($i,{size:16})};case"info":return{border:"border-l-4 border-blue-500",iconBg:"bg-blue-50 text-blue-600 dark:bg-blue-950/60 dark:text-blue-400",icon:a.jsx(ep,{size:16})};case"success":default:return{border:"border-l-4 border-emerald-500",iconBg:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400",icon:a.jsx(Ln,{size:16})}}};return a.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:a.jsx(zc,{children:e.map(i=>{const o=r(i.type),l=t===i.id;return a.jsxs(Ti.div,{initial:{opacity:0,y:50,x:50,scale:.9},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,scale:.85,transition:{duration:.2}},transition:{type:"spring",stiffness:300,damping:24},className:`pointer-events-auto w-full bg-white dark:bg-slate-900 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 ${o.border} overflow-hidden text-gray-900 dark:text-gray-100`,id:`toast-${i.id}`,children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`p-1 rounded-full shrink-0 ${o.iconBg}`,children:o.icon}),a.jsx("p",{className:"font-semibold text-sm font-sans truncate",children:i.title})]}),(i.type==="error"||i.type==="warning")&&a.jsxs("button",{type:"button",onClick:c=>s(c,i),className:`text-xs font-bold px-1.5 py-0.5 rounded transition-all flex items-center gap-1 cursor-pointer shrink-0 ${l?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 dark:bg-slate-800 dark:hover:bg-slate-700 text-gray-600 dark:text-gray-300"}`,title:"复制错误内容",children:[l?a.jsx(yt,{size:11}):a.jsx(An,{size:11}),a.jsx("span",{children:l?"已复制":"复制"})]})]}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 leading-relaxed font-sans break-words",children:i.message})]}),a.jsx("button",{type:"button",onClick:()=>Ee.getState().removeToast(i.id),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-slate-800 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:a.jsx(ot,{size:14})})]},i.id)})})})}function lw({showRightSidebar:e,setShowRightSidebar:t,rightSidebarTab:n,setRightSidebarTab:s,effectiveAgentProviderId:r,agentProviderId:i,setAgentProviderId:o,aiProviders:l,selectedAgentProvider:c,chatLog:u,loading:d,input:h,setInput:m,handleSend:f,chatAttachments:g,setChatAttachments:y,handleChatFileChange:C,handleChatDrop:w,onClearAgentMemory:N,events:S,lang:E,t:I}){const k=p.useRef(null);return p.useEffect(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[u]),a.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?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[a.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:[a.jsx(zr,{size:14})," Agent"]}),a.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:[a.jsx(ls,{size:14})," Shell"]}),a.jsx("button",{onClick:()=>t(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:a.jsx(tp,{size:14})})]}),n==="agent"?a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:a.jsx(zr,{size:16})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:I.agentTitle}),a.jsx("p",{className:"text-xs text-gray-500",children:I.agentSubtitle}),a.jsxs("button",{onClick:N,title:E==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-xs text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",E==="zh"?"清除记忆":"Clear memory"]})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[a.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-gray-400",children:E==="zh"?"AI 提供商":"AI Provider"}),a.jsxs("div",{className:"relative w-full",children:[l.length===0?a.jsx("select",{disabled:!0,value:"",className:"w-full appearance-none rounded-xl border border-amber-200 bg-amber-50/50 px-3 py-2 pr-9 text-xs font-medium text-amber-700 shadow-xs outline-none cursor-not-allowed",children:a.jsx("option",{value:"",children:E==="zh"?"未配置 AI 提供商":"No AI Provider"})}):a.jsx("select",{value:r,onChange:z=>o(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 pr-9 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:l.map(z=>a.jsx("option",{value:z.id,children:z.name},z.id))}),a.jsx(Ps,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),a.jsx("div",{className:"text-xs text-gray-400 truncate w-full text-right",title:c?.model_name||"",children:c?`${c.model_name}`:E==="zh"?"未配置提供商":"No Provider"})]})]})}),l.length===0&&a.jsxs("div",{className:"mx-4 mt-3 p-3 bg-amber-50 border border-amber-200/80 rounded-xl text-xs text-amber-900 flex items-start gap-2 shadow-xs shrink-0",children:[a.jsx($i,{size:15,className:"shrink-0 text-amber-600 mt-0.5"}),a.jsxs("div",{className:"flex-1 leading-relaxed",children:[a.jsx("span",{className:"font-semibold",children:E==="zh"?"未配置 AI 提供商":"No AI Provider Configured"}),a.jsx("p",{className:"mt-0.5 text-amber-700",children:E==="zh"?"请前往「系统管理 -> AI 提供商管理」添加大模型服务(如 DeepSeek、Qwen、OpenAI 等)。":'Please configure an AI provider in "System Management -> AI Provider Management" to use the AI assistant.'})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u.map((z,D)=>a.jsx("div",{className:`flex flex-col ${z.role==="user"?"items-end":"items-start"}`,children:a.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${z.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:z.content})},D)),d&&a.jsx("div",{className:"flex items-start",children:a.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:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),a.jsx("div",{ref:k})]}),a.jsxs("form",{onSubmit:f,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:z=>z.preventDefault(),onDrop:w,children:[g.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:g.map((z,D)=>a.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full text-xs",children:[a.jsx(Rl,{size:10,className:"shrink-0"}),a.jsx("span",{className:"truncate max-w-[100px]",title:z.name,children:z.name}),a.jsx("button",{type:"button",onClick:()=>y(F=>F.filter((_,A)=>A!==D)),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:a.jsx(ot,{size:10})})]},D))}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.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:[a.jsx(np,{size:14}),a.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:C,accept:".csv,.txt,.json,.md"})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"text",value:h,disabled:l.length===0,onChange:z=>m(z.target.value),placeholder:l.length===0?E==="zh"?"请先配置 AI 提供商":"Please configure AI provider first":I.placeholder,className:"w-full bg-gray-50 border border-gray-200 rounded-full pl-4 pr-10 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all disabled:opacity-60 disabled:cursor-not-allowed"}),a.jsx("button",{type:"submit",disabled:d||!h.trim()||l.length===0,className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:a.jsx(sp,{size:10})})]})]})]})]}):a.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-xs min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[a.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:a.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[a.jsx(ls,{size:14}),a.jsx("span",{className:"text-xs",children:I.eventStream})]})}),a.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:S.length===0?a.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):S.map((z,D)=>a.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[a.jsxs("span",{className:"text-gray-500 shrink-0 text-xs",children:["[",new Date(z.timestamp).toLocaleTimeString(),"]"]}),a.jsx("span",{className:"text-blue-400 shrink-0 truncate text-xs",title:z.source,children:z.source})]}),a.jsx("div",{className:"text-green-300 font-bold",children:z.type}),a.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:z.payload})]},D))})]})]}):a.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-gray-400 w-full",onClick:()=>t(!0),children:[a.jsx(zr,{size:18,className:"mb-6 hover:text-indigo-500"}),a.jsx(ls,{size:18,className:"hover:text-indigo-500"}),a.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:a.jsx("div",{className:"uppercase tracking-widest text-xs rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const cw=p.lazy(()=>Ie(()=>import("./ImportModal-B2acbUT8.js"),[]).then(e=>({default:e.ImportModal}))),uw=p.lazy(()=>Ie(()=>import("./CourseWizardModal-D92teHMD.js"),[]).then(e=>({default:e.CourseWizardModal}))),dw=p.lazy(()=>Ie(()=>import("./ImportLessonsModal-YuTV3mnv.js"),[]).then(e=>({default:e.ImportLessonsModal}))),hw=p.lazy(()=>Ie(()=>import("./QuizGeneratorModal-Bp4pUx-H.js"),[]).then(e=>({default:e.QuizGeneratorModal}))),fw=p.lazy(()=>Ie(()=>import("./StudentPreviewModal-DZdcKy1x.js"),[]).then(e=>({default:e.StudentPreviewModal}))),pw=p.lazy(()=>Ie(()=>import("./ProcessLogsModal-MtK-Pe4R.js"),[]).then(e=>({default:e.ProcessLogsModal}))),mw=p.lazy(()=>Ie(()=>import("./CloudDriveModal-ul9v6wHK.js"),[]).then(e=>({default:e.CloudDriveModal}))),gw=p.lazy(()=>Ie(()=>import("./SystemResourceLibraryModal-CJ16MGxn.js"),[]).then(e=>({default:e.SystemResourceLibraryModal}))),xw=p.lazy(()=>Ie(()=>import("./BatchPickerModal-CPmu_uF8.js"),[]).then(e=>({default:e.BatchPickerModal}))),yw=p.lazy(()=>Ie(()=>import("./ExportWeightModal-BvoODxwp.js"),[]).then(e=>({default:e.ExportWeightModal}))),bw=p.lazy(()=>Ie(()=>import("./NotificationDetailModal-BthQNwyd.js"),[]).then(e=>({default:e.NotificationDetailModal}))),ww=p.lazy(()=>Ie(()=>import("./HelpTour-Dlc1vvy3.js"),[]).then(e=>({default:e.HelpTour}))),Sw=p.lazy(()=>Ie(()=>import("./CoursewareHubPanel-CEK_QEc5.js"),[]).then(e=>({default:e.CoursewareHubPanel})));function vw(e){const{lang:t,t:n,showImportModal:s=!1,setShowImportModal:r=()=>{},handleImportFile:i=()=>{},importError:o=null,importSuccess:l=null,isImporting:c=!1,downloadCSVTemplate:u=()=>{},addToast:d=()=>{},generateTemplateContent:h=()=>"",isImportLessonsOpen:m=!1,setIsImportLessonsOpen:f=()=>{},importStatus:g="idle",setIsDraggingImport:y=()=>{},handleCSVFileChange:C=()=>{},downloadCsvTemplate:w=()=>{},isDraggingImport:N=!1,previewImportData:S=[],setPreviewImportData:E=()=>{},setImportStatus:I=()=>{},importProgress:k=0,importProgressTotal:z=0,importErrorMsg:D="",setImportErrorMsg:F=()=>{},handleCSVImportSubmit:_=()=>{},lessons:A=[],fetchClassDashboard:L=()=>{},isLessonPreviewVisible:O=!1,setIsLessonPreviewVisible:R=()=>{},selectedLesson:P=null,previewFullscreenPanel:T="none",setPreviewFullscreenPanel:W=()=>{},previewLessonTab:j="whiteboard",setPreviewLessonTab:$=()=>{},activeRole:x="teacher",elements:oe=[],activeSegmentId:pe=null,setActiveSegmentId:b=()=>{},fetchElements:J=()=>{},currentVfsParent:U=null,setCurrentVfsParent:Q=()=>{},vfsNodes:re=[],previewSelectedCourseware:se=null,setPreviewSelectedCourseware:we=()=>{},showProcessLogs:me=null,setShowProcessLogs:le=()=>{},processLogsContent:Ve="",isCloudDriveOpen:wt=!1,setIsCloudDriveOpen:Ft=()=>{},cloudDrivePreviewNode:St=null,setCloudDrivePreviewNode:vt=()=>{},isSystemResourceLibraryOpen:_t=!1,setIsSystemResourceLibraryOpen:Y=()=>{},systemResourceTab:te="system",setSystemResourceTab:ae=()=>{},selectedLibraryResourceId:je=null,setSelectedLibraryResourceId:Ue=()=>{},loadingLibraryResources:He=!1,libraryResources:ct=[],fetchLibraryResources:Ne=()=>{},classes:M=[],expandedClassId:H=null,isExportWeightModalOpen:K=!1,setIsExportWeightModalOpen:Z=()=>{},quizzesWeight:X=40,setQuizzesWeight:Pe=()=>{},assignmentsWeight:Ze=60,setAssignmentsWeight:Fe=()=>{},handleQuizzesWeightChange:tt=()=>{},handleAssignmentsWeightChange:ut=()=>{},customCategoryOverrides:ge={},setCustomCategoryOverrides:nt=()=>{},classDashboardMap:_e={},exportClassId:Fs="",exportClassName:Dn="",csvPreviewData:Bs=null,handleExportGrades:Ct=()=>{},setSelectedAssignment:Bt=()=>{},setStudentViewStatus:ln=()=>{},setQuizStudentAnswers:$s=()=>{},setSubAssignmentTab:Vs=()=>{},isTourOpen:Us=!1,setIsTourOpen:Hs=()=>{},handleSeedSuccess:qs=()=>{},setTeacherTab:Ws=()=>{},showCoursewareHub:Gs=!1,setShowCoursewareHub:Qs=()=>{}}=e,Ce=e.courseWizard,Js=Ce?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Zs=Ce?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),Ys=Ce?.wizardStep??e.wizardStep??1,cn=Ce?.setWizardStep??e.setWizardStep??(()=>{}),un=Ce?.wizardIsSubmitting??e.wizardIsSubmitting??!1,Fn=Ce?.wizardCourseTitle??e.wizardCourseTitle??"",Ks=Ce?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),$t=Ce?.wizardCourseDescription??e.wizardCourseDescription??"",Xs=Ce?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),Re=Ce?.wizardCourseCategory??e.wizardCourseCategory??"",Bn=Ce?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),er=Ce?.wizardCourseTimeline??e.wizardCourseTimeline??[],$n=Ce?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),tr=Ce?.wizardCourseContent??e.wizardCourseContent??"",Vt=Ce?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),nr=Ce?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),xe=e.quizGenerator,sr=xe?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,rr=xe?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),ir=xe?.quizGenMode??e.quizGenMode??"scan_lesson",or=xe?.setQuizGenMode??e.setQuizGenMode??(()=>{}),ar=xe?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",lr=xe?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),cr=xe?.quizGenTopic??e.quizGenTopic??"",ur=xe?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Lt=xe?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,dr=xe?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),hr=xe?.suggestedObjectives??e.suggestedObjectives??[],fr=xe?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),Vn=xe?.suggestedQuestions??e.suggestedQuestions??[],Un=xe?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),pr=xe?.quizGenTimeLimit??e.quizGenTimeLimit??0,mr=xe?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),Hn=xe?.savingQuiz??e.savingQuiz??!1,dn=xe?.setSavingQuiz??e.setSavingQuiz??(()=>{}),hn=xe?.quizGeneratorClassId??e.quizGeneratorClassId??null,Ye=e.classBatch,gr=Ye?.batchPicker??e.batchPicker??null,ye=Ye?.setBatchPicker??e.setBatchPicker??(()=>{}),Rt=Ye?.batchPickerLesson??e.batchPickerLesson??"",qn=Ye?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),Wn=Ye?.batchPickerDate??e.batchPickerDate??"",Le=Ye?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),dt=Ye?.batchPickerTargetClass??e.batchPickerTargetClass??"",xr=Ye?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),yr=Ye?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Gn=e.studentNotificationsHook,Ut=Gn?.selectedNotificationForModal??e.selectedNotificationForModal??null,br=Gn?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return a.jsxs(p.Suspense,{fallback:null,children:[a.jsx(cw,{show:s,onClose:()=>r(!1),lang:t,handleImportFile:i,importError:o,importSuccess:l,isImporting:c,downloadCSVTemplate:u}),a.jsx(uw,{isCourseWizardOpen:Js,setIsCourseWizardOpen:Zs,lang:t,wizardStep:Ys,setWizardStep:cn,wizardIsSubmitting:un,wizardCourseTitle:Fn,setWizardCourseTitle:Ks,wizardCourseDescription:$t,setWizardCourseDescription:Xs,wizardCourseCategory:Re,setWizardCourseCategory:Bn,wizardCourseTimeline:er,setWizardCourseTimeline:$n,wizardCourseContent:tr,setWizardCourseContent:Vt,addToast:d,generateTemplateContent:h,handleDeployWizardCourse:nr}),a.jsx(dw,{isImportLessonsOpen:m,setIsImportLessonsOpen:f,lang:t,importStatus:g,setIsDraggingImport:y,handleCSVFileChange:C,downloadCsvTemplate:w,isDraggingImport:N,previewImportData:S,setPreviewImportData:E,setImportStatus:I,importProgress:k,importProgressTotal:z,importErrorMsg:D,setImportErrorMsg:F,handleCSVImportSubmit:_}),a.jsx(hw,{isQuizGeneratorOpen:sr,setIsQuizGeneratorOpen:rr,lessons:A,quizGenMode:ir,setQuizGenMode:or,quizGenSelectedLessonId:ar,setQuizGenSelectedLessonId:lr,quizGenTopic:cr,setQuizGenTopic:ur,isGeneratingSuggestions:Lt,setIsGeneratingSuggestions:dr,suggestedObjectives:hr,setSuggestedObjectives:fr,suggestedQuestions:Vn,setSuggestedQuestions:Un,quizGenTimeLimit:pr,setQuizGenTimeLimit:mr,savingQuiz:Hn,setSavingQuiz:dn,quizGeneratorClassId:hn,fetchClassDashboard:L}),a.jsx(fw,{isLessonPreviewVisible:O,setIsLessonPreviewVisible:R,lessons:A,selectedLesson:P,previewFullscreenPanel:T,setPreviewFullscreenPanel:W,previewLessonTab:j,setPreviewLessonTab:$,activeRole:x,elements:oe,activeSegmentId:pe,setActiveSegmentId:b,fetchElements:J,currentVfsParent:U,setCurrentVfsParent:Q,vfsNodes:re,previewSelectedCourseware:se,setPreviewSelectedCourseware:we}),a.jsx(pw,{showProcessLogs:me,setShowProcessLogs:le,processLogsContent:Ve,t:n}),a.jsx(mw,{isOpen:wt,onClose:()=>Ft(!1),vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt}),a.jsx(gw,{isSystemResourceLibraryOpen:_t,setIsSystemResourceLibraryOpen:Y,lang:t,systemResourceTab:te,setSystemResourceTab:ae,selectedLibraryResourceId:je,setSelectedLibraryResourceId:Ue,vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt,loadingLibraryResources:He,libraryResources:ct,fetchLibraryResources:Ne}),a.jsx(xw,{batchPicker:gr,setBatchPicker:ye,batchPickerLesson:Rt,setBatchPickerLesson:qn,batchPickerDate:Wn,setBatchPickerDate:Le,batchPickerTargetClass:dt,setBatchPickerTargetClass:xr,lessons:A,classes:M,expandedClassId:H,confirmBatchPicker:yr,lang:t}),a.jsx(yw,{isExportWeightModalOpen:K,setIsExportWeightModalOpen:Z,lang:t,quizzesWeight:X,setQuizzesWeight:Pe,assignmentsWeight:Ze,setAssignmentsWeight:Fe,handleQuizzesWeightChange:tt,handleAssignmentsWeightChange:ut,customCategoryOverrides:ge,setCustomCategoryOverrides:nt,classDashboardMap:_e,exportClassId:Fs,exportClassName:Dn,csvPreviewData:Bs,handleExportGrades:Ct}),a.jsx(bw,{notification:Ut,onClose:()=>br(null),lang:t,onOpenWorkspace:ht=>{Bt(ht),ln("assignment"),$s({}),Vs("quiz")}}),a.jsx(ww,{isOpen:Us,onClose:()=>Hs(!1),lang:t,onSeedSuccess:qs,onJumpTab:ht=>Ws(ht)}),Gs&&a.jsx(Sw,{onClose:()=>Qs(!1),lang:t})]})}const Cw=["whiteboard.","courseware.","quiz.","rollcall."];class kw{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&&Cw.some(s=>t.type.startsWith(s))&&this.socketBridge(t)}}const Ew=new kw;async function qc(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 l=Array.from(document.querySelectorAll("iframe")).find(c=>c.contentWindow===e.source);if(l&&l.contentWindow){const c=l.contentWindow;c.__LMS_STUDENT__?.attempt_id&&(n=c.__LMS_STUDENT__.attempt_id)}}catch{}if(!n||typeof n!="string")return;if(s==="LMS_CONFIG"){rs("courseware.config_reported",n,t.config??r);return}if(s==="LMS_GET_PROGRESS"){const l=t.requestId,c=e.source;if(l&&c&&typeof c.postMessage=="function"){if(typeof document<"u"&&!Array.from(document.querySelectorAll("iframe")).some(f=>f.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:l,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){rs("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(l){console.error("[LMS Bridge] Failed to submit attempt data to backend:",l)}}else if(o){rs("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(l){console.error("[LMS Bridge] Failed to save progress to backend:",l)}}else{rs("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(l){console.error("[LMS Bridge] Failed to log event to backend:",l)}}}function rs(e,t,n){Ew.publish({id:Dp(),type:e,source:"courseware-bridge",payload:{attemptId:t,data:n},timestamp:Date.now(),correlationId:t})}function jw(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 Wc(e){p.useEffect(()=>{if(!e)return;const t=n=>{qc(n)};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[e])}function Gc(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{}}function Qc(e){if(!(typeof document>"u"))try{const t=Math.min(140,Math.max(85,Math.round(e)));document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"font-scale:changed",payload:{scale:t,fontScale:(t/100).toFixed(2)}},"*"),s.contentWindow?.postMessage({type:"LMS_FONT_SCALE_CHANGED",scale:t,fontScale:(t/100).toFixed(2)},"*")}catch{}})}catch{}}const Jc=Object.freeze(Object.defineProperty({__proto__:null,broadcastFontScaleToIframes:Qc,broadcastThemeToIframes:Gc,processLmsMessage:qc,sendCommandToCourseware:jw,useLmsBridge:Wc},Symbol.toStringTag,{value:"Module"}));function Nw(e){const{session:t,showProcessLogs:n,activeStudentId:s,currentVfsParent:r,selectedLesson:i,selectedAssignment:o,expandedClassId:l,fetchLessons:c,fetchPlugins:u,fetchRegisteredCommands:d,fetchEvents:h,fetchApprovals:m,fetchProcesses:f,fetchClasses:g,fetchTodaySchedules:y,fetchStudents:C,fetchLabs:w,fetchVfs:N,fetchProcessLogs:S,fetchClassStudents:E,fetchElements:I}=e,k=p.useRef(r),z=p.useRef(i),D=p.useRef(o),F=p.useRef(l);p.useEffect(()=>{k.current=r},[r]),p.useEffect(()=>{z.current=i},[i]),p.useEffect(()=>{D.current=o},[o]),p.useEffect(()=>{F.current=l},[l]),p.useEffect(()=>{if(!t)return;const _=t.role==="student",A=t.role==="teacher",L=A&&(t.subRole==="administrator"||t.username==="admin"||t.userId==="usr_admin");c(),u(),d(),y().catch(()=>{}),L&&(h(),m(),f()),A?(g(),C(),w(),N(k.current)):_&&k.current&&N(k.current);let O=!1;const R=setInterval(async()=>{if(!O){O=!0;try{if(L&&(await h(),await m(),await f(),n&&await S(n)),await c(),await d(),await y().catch(()=>{}),A&&(await g(),await C(),await w(),await N(k.current),F.current&&await E(F.current)),z.current&&await I(z.current),D.current){const P=s||D.current.student_id;await I(`assignment-${D.current.id}-student-${P}`)}}finally{O=!1}}},2e3);return()=>clearInterval(R)},[t,n,s]),p.useEffect(()=>{t&&(t.role==="teacher"||r)&&N(r)},[r,t]),p.useEffect(()=>{i&&I(i)},[i])}function Pw(e){const{lang:t,t:n,selectedLesson:s,effectiveAgentProviderId:r,expandedClassId:i,fetchLessons:o,fetchClasses:l,fetchStudents:c,fetchClassStudents:u,fetchClassProgress:d,fetchClassDashboard:h,fetchElements:m}=e,[f,g]=p.useState([{role:"agent",content:n.agentIntro||""}]),[y,C]=p.useState(""),[w,N]=p.useState(!1),[S,E]=p.useState([]);p.useEffect(()=>{f.length===1&&f[0].role==="agent"&&g([{role:"agent",content:n.agentIntro}])},[t,n.agentIntro]);const I=p.useCallback(async _=>{try{const A=await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(_||"")}`);if(!A.ok)return;const L=await A.json(),O=Array.isArray(L.messages)?L.messages:[];O.length>0?g(O.map(R=>({role:R.role==="assistant"?"agent":"user",content:R.content}))):g([{role:"agent",content:n.agentIntro}])}catch{}},[n.agentIntro]),k=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(()=>{I(s)},[s,I]),{chatLog:f,setChatLog:g,input:y,setInput:C,loading:w,setLoading:N,chatAttachments:S,setChatAttachments:E,handleChatFileChange:_=>{_.target.files&&Array.from(_.target.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleChatDrop:_=>{_.preventDefault(),_.dataTransfer.files&&Array.from(_.dataTransfer.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleSend:async _=>{if(_.preventDefault(),!y.trim()||w)return;const A=[...S];let L=y;A.length>0&&(L+=`
133
133
  (📁 ${t==="zh"?"附件":"Attachments"}: ${A.map(O=>O.name).join(", ")})`),g(O=>[...O,{role:"user",content:L}]),C(""),E([]),N(!0);try{const O=await fetch("/api/agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:y,lang:t,currentLessonId:s,attachments:A,providerId:r||null})}),R=await O.json();let P="";!O.ok||R.success===!1?P=`⚠️ ${R.message||R.error||(t==="zh"?"未知系统错误":"Unknown System Error")}`:(P=R.agentText||"",R.toolResults&&R.toolResults.length>0&&(P+=`
134
134
 
135
135
  ${n.executedCommands}`+R.toolResults.map(T=>T.callName).join(", "))),g(T=>[...T,{role:"agent",content:P}]),await o(),await l(),await c(),i&&(await u(i),await d(i),await h(i)),s&&await m(s)}catch{g(O=>[...O,{role:"agent",content:n.simulationError}])}finally{N(!1)}},handleClearAgentMemory:k,restoreAgentMemory:I}}const lt=Object.create(null);lt.open="0";lt.close="1";lt.ping="2";lt.pong="3";lt.message="4";lt.upgrade="5";lt.noop="6";const fs=Object.create(null);Object.keys(lt).forEach(e=>{fs[lt[e]]=e});const Ii={type:"error",data:"parser error"},Zc=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Yc=typeof ArrayBuffer=="function",Kc=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,uo=({type:e,data:t},n,s)=>Zc&&t instanceof Blob?n?s(t):xl(t,s):Yc&&(t instanceof ArrayBuffer||Kc(t))?n?s(t):xl(new Blob([t]),s):s(lt[e]+(t||"")),xl=(e,t)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];t("b"+(s||""))},n.readAsDataURL(e)};function yl(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let oi;function Tw(e,t){if(Zc&&e.data instanceof Blob)return e.data.arrayBuffer().then(yl).then(t);if(Yc&&(e.data instanceof ArrayBuffer||Kc(e.data)))return t(yl(e.data));uo(e,!1,n=>{oi||(oi=new TextEncoder),t(oi.encode(n))})}const bl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",kn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<bl.length;e++)kn[bl.charCodeAt(e)]=e;const Iw=e=>{let t=e.length*.75,n=e.length,s,r=0,i,o,l,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=kn[e.charCodeAt(s)],o=kn[e.charCodeAt(s+1)],l=kn[e.charCodeAt(s+2)],c=kn[e.charCodeAt(s+3)],d[r++]=i<<2|o>>4,d[r++]=(o&15)<<4|l>>2,d[r++]=(l&3)<<6|c&63;return u},Aw=typeof ArrayBuffer=="function",ho=(e,t)=>{if(typeof e!="string")return{type:"message",data:Xc(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:zw(e.substring(1),t)}:fs[n]?e.length>1?{type:fs[n],data:e.substring(1)}:{type:fs[n]}:Ii},zw=(e,t)=>{if(Aw){const n=Iw(e);return Xc(n,t)}else return{base64:!0,data:e}},Xc=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},eu="",_w=(e,t)=>{const n=e.length,s=new Array(n);let r=0;e.forEach((i,o)=>{uo(i,!1,l=>{s[o]=l,++r===n&&t(s.join(eu))})})},Lw=(e,t)=>{const n=e.split(eu),s=[];for(let r=0;r<n.length;r++){const i=ho(n[r],t);if(s.push(i),i.type==="error")break}return s};function Rw(){return new TransformStream({transform(e,t){Tw(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 ai;function is(e){return e.reduce((t,n)=>t+n.length,0)}function os(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 Mw(e,t){ai||(ai=new TextDecoder);const n=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,l){for(n.push(o);;){if(s===0){if(is(n)<1)break;const c=os(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(is(n)<2)break;const c=os(n,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(is(n)<8)break;const c=os(n,8),u=new DataView(c.buffer,c.byteOffset,c.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){l.enqueue(Ii);break}r=d*Math.pow(2,32)+u.getUint32(4),s=3}else{if(is(n)<r)break;const c=os(n,r);l.enqueue(ho(i?c:ai.decode(c),t)),s=0}if(r===0||r>e){l.enqueue(Ii);break}}}})}const tu=4;function ve(e){if(e)return Ow(e)}function Ow(e){for(var t in ve.prototype)e[t]=ve.prototype[t];return e}ve.prototype.on=ve.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ve.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ve.prototype.off=ve.prototype.removeListener=ve.prototype.removeAllListeners=ve.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};ve.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};ve.prototype.emitReserved=ve.prototype.emit;ve.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ve.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Os=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qe=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Dw="arraybuffer";function nu(e,...t){return t.reduce((n,s)=>(e.hasOwnProperty(s)&&(n[s]=e[s]),n),{})}const Fw=Qe.setTimeout,Bw=Qe.clearTimeout;function Ds(e,t){t.useNativeTimers?(e.setTimeoutFn=Fw.bind(Qe),e.clearTimeoutFn=Bw.bind(Qe)):(e.setTimeoutFn=Qe.setTimeout.bind(Qe),e.clearTimeoutFn=Qe.clearTimeout.bind(Qe))}const $w=1.33;function Vw(e){return typeof e=="string"?Uw(e):Math.ceil((e.byteLength||e.size)*$w)}function Uw(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 su(){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 qw(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 Ww extends Error{constructor(t,n,s){super(t),this.description=n,this.context=s,this.type="TransportError"}}class fo extends ve{constructor(t){super(),this.writable=!1,Ds(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 Ww(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=ho(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 Gw extends fo{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)};Lw(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,_w(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]=su()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let ru=!1;try{ru=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Qw=ru;function Jw(){}class Zw extends Gw{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}}let sn=class ps extends ve{constructor(t,n,s){super(),this.createRequest=t,Ds(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=nu(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=ps.requestsCount++,ps.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=Jw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ps.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()}};sn.requestsCount=0;sn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",wl);else if(typeof addEventListener=="function"){const e="onpagehide"in Qe?"pagehide":"unload";addEventListener(e,wl,!1)}}function wl(){for(let e in sn.requests)sn.requests.hasOwnProperty(e)&&sn.requests[e].abort()}const Yw=(function(){const e=iu({xdomain:!1});return e&&e.responseType!==null})();class Kw extends Zw{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Yw&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new sn(iu,this.uri(),t)}}function iu(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Qw))return new XMLHttpRequest}catch{}if(!t)try{return new Qe[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ou=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Xw extends fo{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,s=ou?{}:nu(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;uo(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&Os(()=>{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]=su()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const li=Qe.WebSocket||Qe.MozWebSocket;class eS extends Xw{createSocket(t,n,s){return ou?new li(t,n,s):n?new li(t,n):new li(t)}doWrite(t,n){this.ws.send(n)}}class tS extends fo{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=Mw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(n).getReader(),r=Rw();r.readable.pipeTo(t.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:l,value:c})=>{l||(this.onPacket(c),i())}).catch(l=>{})};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&&Os(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const nS={websocket:eS,webtransport:tS,polling:Kw},sS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,rS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ai(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=sS.exec(e||""),i={},o=14;for(;o--;)i[rS[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=iS(i,i.path),i.queryKey=oS(i,i.query),i}function iS(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 oS(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(n[r]=i)}),n}const zi=typeof addEventListener=="function"&&typeof removeEventListener=="function",ms=[];zi&&addEventListener("offline",()=>{ms.forEach(e=>e())},!1);class It extends ve{constructor(t,n){if(super(),this.binaryType=Dw,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=Ai(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=Ai(n.host).host);Ds(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=qw(this.opts.query)),zi&&(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"})},ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=tu,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&&It.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",It.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+=Vw(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,Os(()=>{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(It.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(),zi&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=ms.indexOf(this._offlineEventListener);s!==-1&&ms.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}It.protocol=tu;class aS extends It{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;It.priorWebsocketSuccess=!1;const r=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!s)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;It.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=h=>{const m=new Error("probe error: "+h);m.transport=n.name,i(),this.emitReserved("upgradeError",m)};function l(){o("transport closed")}function c(){o("socket closed")}function u(h){n&&h.name!==n.name&&i()}const d=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",l),this.off("close",c),this.off("upgrading",u)};n.once("open",r),n.once("error",o),n.once("close",l),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 lS=class extends aS{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=>nS[r]).filter(r=>!!r)),super(t,s)}};function cS(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=Ai(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 uS=typeof ArrayBuffer=="function",dS=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,au=Object.prototype.toString,hS=typeof Blob=="function"||typeof Blob<"u"&&au.call(Blob)==="[object BlobConstructor]",fS=typeof File=="function"||typeof File<"u"&&au.call(File)==="[object FileConstructor]";function po(e){return uS&&(e instanceof ArrayBuffer||dS(e))||hS&&e instanceof Blob||fS&&e instanceof File}function gs(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,s=e.length;n<s;n++)if(gs(e[n]))return!0;return!1}if(po(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return gs(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&gs(e[n]))return!0;return!1}function pS(e){const t=[],n=e.data,s=e;return s.data=xs(n,t),s.attachments=t.length,{packet:s,buffers:t}}function xs(e,t,n){if(!e)return e;if(po(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]=xs(e[r],t);return s}else if(typeof e=="object"&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON=="function"&&!n)return xs(e.toJSON(),t,!0);const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=xs(e[r],t));return s}return e}function mS(e,t){return e.data=_i(e.data,t),delete e.attachments,e}function _i(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]=_i(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=_i(e[n],t));return e}const gS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ie;(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"})(ie||(ie={}));class xS{constructor(t){this.replacer=t}encode(t){return(t.type===ie.EVENT||t.type===ie.ACK)&&gs(t)?this.encodeAsBinary({type:t.type===ie.EVENT?ie.BINARY_EVENT:ie.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===ie.BINARY_EVENT||t.type===ie.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=pS(t),s=this.encodeAsString(n.packet),r=n.buffers;return r.unshift(s),r}}class mo extends ve{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===ie.BINARY_EVENT;s||n.type===ie.BINARY_ACK?(n.type=s?ie.EVENT:ie.ACK,this.reconstructor=new yS(n)):super.emitReserved("decoded",n)}else if(po(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(ie[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===ie.BINARY_EVENT||s.type===ie.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 l=Number(o);if(!bS(l)||l<1)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=l}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(mo.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 ie.CONNECT:return Sl(n);case ie.DISCONNECT:return n===void 0;case ie.CONNECT_ERROR:return typeof n=="string"||Sl(n);case ie.EVENT:case ie.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&gS.indexOf(n[0])===-1);case ie.ACK:case ie.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class yS{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=mS(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const bS=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Sl(e){return Object.prototype.toString.call(e)==="[object Object]"}const wS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:mo,Encoder:xS,get PacketType(){return ie}},Symbol.toStringTag,{value:"Module"}));function Xe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const SS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class lu extends ve{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=[Xe(t,"open",this.onopen.bind(this)),Xe(t,"packet",this.onpacket.bind(this)),Xe(t,"error",this.onerror.bind(this)),Xe(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(SS.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:ie.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,h=n.pop();this._registerAckCallback(d,h),o.id=d}const l=(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&&!l||(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 l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},r),o=(...l)=>{this.io.clearTimeoutFn(i),n.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((s,r)=>{const i=(o,l)=>o?r(o):s(l);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:ie.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 ie.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 ie.EVENT:case ie.BINARY_EVENT:this.onevent(t);break;case ie.ACK:case ie.BINARY_ACK:this.onack(t);break;case ie.DISCONNECT:this.ondisconnect();break;case ie.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:ie.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:ie.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 an(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}an.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};an.prototype.reset=function(){this.attempts=0};an.prototype.setMin=function(e){this.ms=e};an.prototype.setMax=function(e){this.max=e};an.prototype.setJitter=function(e){this.jitter=e};class Li extends ve{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,Ds(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 an({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||wS;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 lS(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Xe(n,"open",function(){s.onopen(),t&&t()}),i=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Xe(n,"error",i);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),n.close()},l);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(Xe(t,"ping",this.onping.bind(this)),Xe(t,"data",this.ondata.bind(this)),Xe(t,"error",this.onerror.bind(this)),Xe(t,"close",this.onclose.bind(this)),Xe(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){Os(()=>{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 lu(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 vn={};function ys(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=cS(e,t.path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=vn[r]&&i in vn[r].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new Li(s,t):(vn[r]||(vn[r]=new Li(s,t)),c=vn[r]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(ys,{Manager:Li,Socket:lu,io:ys,connect:ys});class vS{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 Ri=null;function cu(e){Ri=e}function wC(){if(!Ri)throw new Error("Socket instance not initialized. Call setSocketInstance() first.");return Ri}class CS{constructor(t){this.socket=t,cu(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 kS{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 ES{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 jS(e){const{session:t,host:n,activeRole:s,activeStudentId:r,selectedLesson:i,activeSegmentId:o,studentViewStatus:l,lang:c,students:u,addToast:d,setOnlineStudentIds:h,setActiveStudentLessons:m,setLessons:f,setActiveSegmentId:g,setLiveClassStudentProgress:y,setLiveClassAcknowledgedMap:C,setLiveClassFeed:w,setSelectedLesson:N,setStudentViewStatus:S,studentLessonTab:E,setStudentLessonTab:I,selectedAssignment:k,setSelectedAssignment:z,setLocalProgressPercent:D,fetchStudentDashboard:F,fetchStudents:_,fetchElements:A}=e,L=p.useRef(null),O=p.useRef(s),R=p.useRef(r),P=p.useRef(c),T=p.useRef(u),W=p.useRef(d),j=p.useRef(i),$=p.useRef(null),x=p.useRef(l),oe=p.useRef(E),pe=p.useRef(null);return p.useEffect(()=>{O.current=s},[s]),p.useEffect(()=>{R.current=r},[r]),p.useEffect(()=>{P.current=c},[c]),p.useEffect(()=>{T.current=u},[u]),p.useEffect(()=>{W.current=d},[d]),p.useEffect(()=>{j.current=i},[i]),p.useEffect(()=>{x.current=l},[l]),p.useEffect(()=>{oe.current=E},[E]),p.useEffect(()=>{$.current=k},[k]),p.useEffect(()=>{if(!t)return;const b=ys();L.current=b,cu(b),n.isInitialized()||n.initialize(new vS,new CS(b),new kS(W.current),new ES("__app__")),O.current==="student"&&R.current&&b.emit("register-student",{studentId:R.current,name:T.current.find(U=>U.id===R.current)?.name||R.current}),b.emit("join-room","whiteboard-broadcast"),b.on("presence-update",U=>{h(U.onlineStudentIds),m(U.activeStudentLessons)}),b.on("lesson-progress-mode-changed",U=>{const{lessonId:Q,progressMode:re,progressConditions:se}=U;f(we=>we.map(me=>me.id===Q?{...me,progress_mode:re,progress_conditions:se}:me))}),b.on("student-active-segment-changed",U=>{const{activeSegmentId:Q}=U;g(Q)}),b.on("student-pinged",U=>{const Q=U.message||(P.current==="zh"?"⚠️ 学习进度预警:老师注意到您的进度有些落后,请抓紧时间跟上!":"⚠️ Progress Alert: The teacher noticed you are falling behind. Please keep up!");d(P.current==="zh"?"⚠️ 学习进度预警":"⚠️ Progress Warning",Q,"warning")}),b.on("student-progress-updated",U=>{const{studentId:Q,progressPercent:re,completed:se}=U;y(we=>{const me=we.findIndex(le=>le.student_id===Q);if(me!==-1){const le=[...we];return le[me]={...le[me],progress_percent:re,completed:se?1:0},le}else return[...we,{student_id:Q,progress_percent:re,completed:se?1:0}]})}),b.on("assignment-graded-toast",U=>{if(O.current==="student"&&R.current&&U.studentId===R.current){const Q=U.assignmentTitle||U.assignmentId,re=P.current==="zh"?`您的作业"${Q}"已完成评分!得分:${U.score}%。建议反馈已收到,快去查看。`:`Your assignment "${Q}" was graded. Score: ${U.score}%. Tutoring feedback has been posted.`;d(P.current==="zh"?"🎓 作业已评分":"🎓 Assignment Graded",re,"success"),F(R.current)}}),b.on("student-picked",U=>{if(O.current==="student"&&R.current&&U.studentId===R.current){const Q=P.current==="zh"?"闪电警报!您已被老师在课程随机提问点名中抽中!请立即集中注意力参与课堂。":"Attention alert! You have been randomly picked by the teacher! Please pay immediate attention.";d(P.current==="zh"?"⚡️ 随机点名提问":"⚡️ Classroom Pick Alert",Q,"warning"),F(R.current)}w(Q=>[{id:`feed-pick-${U.studentId}-${U.pickedTime||Date.now()}`,time:new Date(U.pickedTime||Date.now()).toLocaleTimeString(),type:"picked",message:P.current==="zh"?`点名互动:随机抽中学生【${U.studentName}】。`:`Classroom Pick: Randomly selected student "${U.studentName}".`},...Q])}),b.on("student-acknowledged",U=>{const{studentId:Q}=U;C(re=>{const se=new Map(re);return se.set(Q,!0),se}),w(re=>[{id:`feed-ack-${Q}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:P.current==="zh"?`学生已确认收到提问点名(学生 ID: ${Q})。`:`Student acknowledged the classroom call (Student ID: ${Q}).`},...re]),_()}),b.on("class-lock-status-changed",U=>{const{lessonId:Q,locked:re}=U;O.current==="student"&&R.current?(Promise.resolve(_()).then(()=>{re&&Q&&(N(Q),S("lesson"),d(P.current==="zh"?"🔒 课程已被锁定":"🔒 Lesson Locked",P.current==="zh"?"老师已锁定当前授课,您将无法切换到其他页面。":"The teacher has locked the active lesson. You cannot leave this page.","info"))}),F(R.current)):_()}),b.on("whiteboard-sync",U=>{const{roomId:Q,type:re}=U||{};re==="refresh"&&Q&&(A(Q),!j.current&&O.current==="student"&&(N(Q),S("lesson")),b.emit("join-room",Q))});const J=()=>{tn.getState().clearRemoteFullscreen();const U=pe.current;pe.current=null,U&&(I(U.lessonTab),U.viewStatus==="assignment"&&(z(U.assignment??null),U.lessonId&&N(U.lessonId),S("assignment")))};return b.on("whiteboard-fullscreen-changed",U=>{if(O.current!=="student")return;const Q=U?.lessonId,re=U?.elementId??null;if(!re){J();return}if(!Q)return;const se=x.current;(se==="lesson"?j.current===Q:se==="assignment")&&(tn.getState().remoteFullscreenElementId||(pe.current={viewStatus:se,lessonTab:oe.current,lessonId:j.current,assignment:se==="assignment"?$.current:null}),tn.getState().setRemoteFullscreenElementId(re),se==="assignment"&&z(null),N(Q),A(Q),S("lesson"),I("whiteboard"))}),b.on("connect",()=>{J()}),()=>{b.disconnect(),L.current=null}},[t,s,r]),p.useEffect(()=>{L.current&&s==="student"&&r&&(l==="lesson"&&i?(L.current.emit("enter-lesson",{studentId:r,lessonId:i}),fetch(`/api/students/${r}/progress`).then(b=>b.json()).then(b=>{if(Array.isArray(b)){const J=b.find(U=>U.lesson_id===i);D(J?J.progress_percent:0)}}).catch(console.error)):L.current.emit("leave-lesson",{studentId:r}))},[l,i,s,r]),p.useEffect(()=>{s==="teacher"&&i&&o&&L.current&&L.current.emit("teacher-broadcast-segment",{lessonId:i,activeSegmentId:o})},[o,i,s]),{socketRef:L}}const NS=`exports.default = {