openlearn-next 0.4.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -21
- package/cli-data.mjs +535 -40
- package/cli-doctor.mjs +456 -17
- package/cli.mjs +214 -12
- package/dist/assets/AcademicYearFilter-DUUGpDKt.js +1 -0
- package/dist/assets/ActivityWorkspaceWidget-5PzyxF6a.js +1 -0
- package/dist/assets/AdminDirectoryView-BCtmQTEK.js +5 -0
- package/dist/assets/AssessmentCenter-B43ojHG-.js +1 -0
- package/dist/assets/BatchPickerModal-CbmjInp7.js +1 -0
- package/dist/assets/ClassesView-DEnMaDOt.js +32 -0
- package/dist/assets/ClassroomCountdownWidget-CHq4983w.js +2 -0
- package/dist/assets/CloudDriveModal-D2t3Uyzr.js +1 -0
- package/dist/assets/ComputerLabView-YtnoT5Rb.js +1 -0
- package/dist/assets/CourseManagement-DOXyJ_j-.js +1 -0
- package/dist/assets/CourseWizardModal-Dbi6Caw2.js +3 -0
- package/dist/assets/CoursewareHubPanel-CyxDIJAF.js +1 -0
- package/dist/assets/Dashboard-2rLu_ZBy.js +8 -0
- package/dist/assets/ExportWeightModal-BrmAh6VX.js +1 -0
- package/dist/assets/GLTFLoader-CZJbo_y1.js +1 -0
- package/dist/assets/HelpTour-D_q1z_MI.js +1 -0
- package/dist/assets/HelpView-CVBrKDrd.js +204 -0
- package/dist/assets/ImportLessonsModal-PhHtX31R.js +1 -0
- package/dist/assets/ImportModal-DqjqNeH4.js +2 -0
- package/dist/assets/InteractiveCoursewareViewer-Vi6lLz7a.js +1 -0
- package/dist/assets/InteractiveWhiteboard-lTzeayX5.js +65 -0
- package/dist/assets/LazyCourseware-KIt0rGtW.js +2 -0
- package/dist/assets/LazyWhiteboard-CCN3pYcW.js +2 -0
- package/dist/assets/LessonEditorView-D_GVhHuM.js +1 -0
- package/dist/assets/LiveClassroomView-BRsZ6QEq.js +61 -0
- package/dist/assets/NotificationDetailModal-tY5rxYCN.js +1 -0
- package/dist/assets/OrbitControls-CQjN_uwS.js +1 -0
- package/dist/assets/PluginView-CedpAW6d.js +77 -0
- package/dist/assets/ProcessLogsModal-Cfr-T9Gd.js +1 -0
- package/dist/assets/QuizGeneratorModal-bUA002kP.js +1 -0
- package/dist/assets/StudentAssignmentView-BhAz6Hfk.js +1 -0
- package/dist/assets/StudentLessonView-DC1yX4kG.js +1 -0
- package/dist/assets/StudentView-PHKxIV9T.js +2 -0
- package/dist/assets/SystemResourceLibraryModal-DgXYe6_x.js +1 -0
- package/dist/assets/TeacherView-DscJtOJ9.js +2 -0
- package/dist/assets/TimetableView-D2ozoj_D.js +6 -0
- package/dist/assets/UTIF-FfCsrHhe.js +1 -0
- package/dist/assets/__vite-optional-peer-dep_ai_ooxml-ui-BIHI7g3E.js +1 -0
- package/dist/assets/browser-DEI0QxZC.js +1 -0
- package/dist/assets/html2canvas-pro.esm-Bo50djkB.js +12 -0
- package/dist/assets/index-2676X8YB.js +131 -0
- package/dist/assets/index-C6hlh8pw.css +1 -0
- package/dist/assets/{index.es-C5eWEO4o.js → index.es-DyEF0CZ9.js} +1 -1
- package/dist/assets/pluginParsers-e4PSm2Iy.js +1 -0
- package/dist/assets/react_pptx-react-viewer-BIHI7g3E.js +1 -0
- package/dist/assets/teaching-modes-client-BeVaDdJ-.js +1 -0
- package/dist/assets/three.module-iOYB3rD4.js +4228 -0
- package/dist/assets/timeline-duration-BgdJCSrW.js +1 -0
- package/dist/assets/{vendor-charts-qLbgF1eL.js → vendor-charts-SrpBsvM3.js} +2 -2
- package/dist/assets/{vendor-icons-BRmhY6fg.js → vendor-icons-CXrZ3R2V.js} +2 -2
- package/dist/assets/{vendor-konva-CEOq4dcl.js → vendor-konva-Dne0Z-WC.js} +1 -1
- package/dist/assets/{vendor-pdf-D7rGevI1.js → vendor-pdf-C1Vh2Aqq.js} +56 -56
- package/dist/assets/vendor-pptx-Bzn6whfK.js +11311 -0
- package/dist/assets/vendor-pptx-DIWdXF1L.css +1 -0
- package/dist/assets/{vendor-react-B0t7H3hh.js → vendor-react-Kv_JATwr.js} +1 -1
- package/dist/assets/vendor-utils-aM7aYvPP.js +1 -0
- package/dist/cli-migrator.cjs +310 -0
- package/dist/env-validation.cjs +351 -0
- package/dist/index.html +13 -10
- package/dist/plugin-net-preload.cjs +263 -0
- package/dist/server.cjs +51140 -27229
- package/migrations/000_initial_schema.sql +410 -0
- package/migrations/001_add_execution_mode.sql +6 -0
- package/migrations/002_add_client_session_expiry.sql +6 -0
- package/migrations/003_classroom_runtime.sql +33 -0
- package/migrations/004_courseware_score_config.sql +26 -0
- package/migrations/005_assignment_hub.sql +155 -0
- package/migrations/006_classroom_event_bus.sql +28 -0
- package/migrations/007_interactive_classroom.sql +119 -0
- package/migrations/008_teaching_modes.sql +36 -0
- package/migrations/009_classroom_peer_review.sql +159 -0
- package/migrations/010_class_groups.sql +33 -0
- package/migrations/011_classroom_feed.sql +34 -0
- package/migrations/012_auto_record_score.sql +48 -0
- package/migrations/013_score_source_strategy.sql +81 -0
- package/migrations/014_performance_indexes.sql +21 -0
- package/migrations/015_demo_data_registry.sql +26 -0
- package/migrations/016_preset_polls_and_passcode_expiry.sql +33 -0
- package/migrations/017_pacing_signals_segment.sql +6 -0
- package/migrations/018_processes_plugin_owner.sql +26 -0
- package/migrations/019_plugins_version.sql +61 -0
- package/migrations/020_upload_max_file_mb.sql +14 -0
- package/migrations/021_class_owner_and_password_gate.sql +11 -0
- package/migrations/022_plugin_public_routes.sql +14 -0
- package/migrations/023_encrypt_class_passcodes.sql +18 -0
- package/migrations/024_segment_gates.sql +37 -0
- package/migrations/025_assignment_lookup_indexes.sql +11 -0
- package/migrations/026_plugin_grants.sql +21 -0
- package/migrations/027_academic_year.sql +26 -0
- package/migrations/028_classroom_indexes.sql +14 -0
- package/migrations/029_clean_lesson_think_artifacts.sql +13 -0
- package/migrations/030_backfill_academic_year.sql +30 -0
- package/migrations/031_assessment_core.sql +158 -0
- package/migrations/032_progress_verification.sql +17 -0
- package/migrations/033_student_lock_mode.sql +9 -0
- package/migrations/034_plugin_orphan_data.sql +27 -0
- package/migrations/035_icebreaker_checkins.sql +26 -0
- package/migrations/036_student_read_notifications_created_at.sql +19 -0
- package/migrations/037_plugin_config_scopes.sql +40 -0
- package/migrations/038_assessment_ai_grading_suggestion.sql +10 -0
- package/migrations/039_question_bank_sharing_and_papers.sql +14 -0
- package/migrations/040_assignment_grade_history.sql +37 -0
- package/migrations/041_course_package_idempotency.sql +33 -0
- package/migrations/042_assignment_grade_resubmit_audit.sql +12 -0
- package/migrations/043_mark_sha256_passwords.sql +31 -0
- package/migrations/README.md +61 -0
- package/migrations/schema-golden.json +640 -0
- package/package.json +54 -28
- package/dist/assets/AdminDirectoryView-DY--WM5Z.js +0 -1
- package/dist/assets/BatchPickerModal-BpWu0Lil.js +0 -1
- package/dist/assets/ClassesView-KbHEqJto.js +0 -22
- package/dist/assets/ClassroomCountdownWidget-96WFRO9A.js +0 -2
- package/dist/assets/CloudDriveModal-DEQ1nkNk.js +0 -1
- package/dist/assets/ComputerLabView-1qWDNRQ2.js +0 -1
- package/dist/assets/CourseManagement-D3ZpxY0l.js +0 -1
- package/dist/assets/CourseWizardModal-Ck_-M8pk.js +0 -3
- package/dist/assets/CoursewareHubPanel-CaEizhxl.js +0 -1
- package/dist/assets/Dashboard-CYbpbofV.js +0 -8
- package/dist/assets/ExportWeightModal-DW2bu9Zz.js +0 -1
- package/dist/assets/HelpTour-CMJbbGne.js +0 -1
- package/dist/assets/HelpView-CtzdqhBq.js +0 -204
- package/dist/assets/ImportLessonsModal-jBuIK453.js +0 -1
- package/dist/assets/ImportModal-D7L-KNhZ.js +0 -1
- package/dist/assets/InteractiveCoursewareViewer-Bj7ahXMs.js +0 -1
- package/dist/assets/InteractiveWhiteboard-B7JcJvDu.js +0 -77
- package/dist/assets/LazyCourseware-CuiPxhDg.js +0 -2
- package/dist/assets/LazyWhiteboard-BJwCEZAU.js +0 -2
- package/dist/assets/LessonEditorView-DFrOp2qp.js +0 -1
- package/dist/assets/LiveClassroomView-BZ5nGee3.js +0 -59
- package/dist/assets/NotificationDetailModal-Baqnc5pU.js +0 -1
- package/dist/assets/PluginView-CCbIuZ24.js +0 -66
- package/dist/assets/ProcessLogsModal-DmFXg9mG.js +0 -1
- package/dist/assets/QuizGeneratorModal-BBEDssp7.js +0 -1
- package/dist/assets/StudentAssignmentView-DgIjUsXz.js +0 -1
- package/dist/assets/StudentLessonView-CBJbI5x6.js +0 -1
- package/dist/assets/StudentPreviewModal-Bh8OZs0t.js +0 -1
- package/dist/assets/StudentView--uGxc5TJ.js +0 -2
- package/dist/assets/SystemResourceLibraryModal-BVCclcqA.js +0 -1
- package/dist/assets/TeacherView-D4Zsc0eZ.js +0 -2
- package/dist/assets/TimetableView-BQG-rEb5.js +0 -6
- package/dist/assets/index-BKBCBKvy.js +0 -217
- package/dist/assets/index-CvGu7LSj.css +0 -1
- package/dist/assets/purify.es-CYR4BTuT.js +0 -3
- package/dist/assets/vendor-pptx-C5-U7ieS.js +0 -39
- package/dist/assets/vendor-utils-m0Urvtws.js +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{r as i,j as e,R as Et}from"./vendor-react-Kv_JATwr.js";import{B as Ks,E as me,s as Na,F as ps,G as va,H as wa,I as ka,i as Wt,J as nt,K as xt,L as za,b as Sa,e as Ca,N as Br,O as $a,x as Aa,Q as Ea,y as Ta,R as Pa,T as St,U as _a}from"./index-2676X8YB.js";import{L as Ra}from"./LazyWhiteboard-CCN3pYcW.js";import{R as Pe,k as ft,aZ as Ia,C as fs,a3 as La,w as yt,E as tn,U as $e,ax as Xs,a6 as Ut,ap as qt,ae as er,N as ut,bd as Ma,a5 as Oe,X as we,B as Rt,o as Ce,ay as sn,y as bt,be as rn,bf as Vt,bg as bs,bh as Oa,$ as De,bi as nn,D as gs,b7 as tr,n as an,f as ms,z as ve,bj as on,p as Js,ad as Jt,a2 as ln,bk as Da,bl as Fa,bm as us,ac as et,ak as Tt,bn as cn,bo as Ba,T as Ie,q as qe,aA as dn,bp as Ga,bq as js,br as Ha,i as ys,bs as Wa,ab as It,K as Ua,a9 as gt,af as Yt,bt as qa,h as Va,aU as Kt,e as xn,bu as mn,W as sr,Q as rr,a4 as Ht,bv as Ka,G as nr,bw as Ja,A as Ns,bx as un,by as ar,a$ as Lt,t as or,c as jt,_ as vs,bz as hn,bA as Ya,bB as Pt,aG as Gr,b2 as Qa,bC as ds,L as Za,u as Qt,O as ir,s as pn,bD as Xa,aj as fn,aM as eo,aF as lr,V as bn,bE as gn,bF as cr,bG as to,bH as jn,bI as yn,r as so,bJ as ro,bK as no,b as Ys,as as ao,bL as oo,bM as Hr,bN as Bs,S as Wr,aT as io,bO as Ur,bP as lo,az as co,bQ as xo}from"./vendor-icons-CXrZ3R2V.js";import{C as mo,T as uo}from"./ClassroomCountdownWidget-CHq4983w.js";import{a as Nn,P as ho,h as po,g as fo,A as bo,C as go,X as jo,Y as yo,b as No,T as vo,e as wo}from"./vendor-charts-SrpBsvM3.js";import{r as dr,f as vn,D as wn,s as kn}from"./timeline-duration-BgdJCSrW.js";import{f as ko,t as zo}from"./teaching-modes-client-BeVaDdJ-.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-C1Vh2Aqq.js";import"./vendor-motion-BFAPOs-b.js";const qr=Ks;function zn({lessonId:t,lang:n,addToast:a}){const[o,d]=i.useState(!1),[r,l]=i.useState(!1),[s,h]=i.useState([]),[c,u]=i.useState(60),[m,p]=i.useState(40),[w,f]=i.useState({}),[N,b]=i.useState({}),[$,P]=i.useState({}),[y,k]=i.useState({}),[g,A]=i.useState({}),[U,W]=i.useState({}),T=n==="zh",Q=async(j=!1)=>{j?l(!0):d(!0);try{const ee=await(await fetch(`/api/lessons/${t}/eval-grades`)).json();if(Array.isArray(ee)){h(ee);const R={},O={},L={},X={};ee.forEach(K=>{K.grade?(R[K.id]=K.grade.teacher_score,O[K.id]=K.grade.teacher_comment,L[K.id]=Math.round(K.grade.teacher_weight*100),X[K.id]=Math.round(K.grade.peer_weight*100)):(R[K.id]=w[K.id]!==void 0?w[K.id]:80,O[K.id]=N[K.id]!==void 0?N[K.id]:"",L[K.id]=$[K.id]!==void 0?$[K.id]:c,X[K.id]=y[K.id]!==void 0?y[K.id]:m)}),f(K=>({...R,...K})),b(K=>({...O,...K})),P(K=>({...L,...K})),k(K=>({...X,...K}))}else throw new Error("Invalid submissions data format")}catch(q){console.error("Error fetching submissions grades:",q),a(T?"数据加载失败":"Failed to Load Data",T?"请检查网络连接或刷新页面。":"Please check your connection and try again.","warning")}finally{d(!1),l(!1)}};i.useEffect(()=>{t&&Q()},[t]),i.useEffect(()=>{const j=ps();if(!j||!t)return;const q=ee=>{(!ee?.lessonId||ee.lessonId===t)&&Q()};return j.on("assignment-submitted-toast",q),()=>{typeof j.off=="function"&&j.off("assignment-submitted-toast",q)}},[t]);const V=j=>{u(j),p(100-j),P(q=>{const ee={...q};return s.forEach(R=>{(!R.grade||R.grade.status!=="confirmed")&&(ee[R.id]=j)}),ee}),k(q=>{const ee={...q};return s.forEach(R=>{(!R.grade||R.grade.status!=="confirmed")&&(ee[R.id]=100-j)}),ee})},le=(j,q)=>{P(ee=>({...ee,[j]:q})),k(ee=>({...ee,[j]:100-q}))},F=async(j,q)=>{const ee=w[j],R=N[j]||"",O=($[j]??c)/100,L=(y[j]??m)/100;if(ee===void 0||isNaN(ee)||ee<0||ee>100){a(T?"评分无效":"Invalid Score",T?"教师评分必须在 0 到 100 之间!":"Teacher score must be between 0 and 100!","warning");return}if(q==="confirmed"){const X=T?"确认同步后,最终得分将直接同步写入宿主学期成绩库,此后该学生的作业成绩将锁定不可修改。是否确认?":"Once confirmed, the final score will be synced to the host semester reports and locked. Proceed?";if(!window.confirm(X))return}W(X=>({...X,[j]:q}));try{const K=await(await fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"assignment.grade",payload:{submissionId:j,teacherScore:Number(ee),teacherComment:R,teacherWeight:O,peerWeight:L,status:q}})})).json();if(K.success)a(q==="confirmed"?T?"平时成绩同步成功":"Semester Grade Synced":T?"平时成绩草稿已保存":"Grade Draft Saved",q==="confirmed"?T?`已将平时成绩 ${K.result.calculatedFinalScore} 分同步至学期报告!`:`Successfully synced grade ${K.result.calculatedFinalScore}!`:T?"成功保存了教师打分与评语草稿。":"Successfully saved score and comment draft.","success"),Q(!0);else throw new Error(K.error||"Failed to submit grade")}catch(X){a(T?"操作失败":"Operation Failed",X.message,"warning")}finally{W(X=>({...X,[j]:null}))}},D=j=>{A(q=>({...q,[j]:!q[j]}))};return o?e.jsxs("div",{className:"flex-grow flex flex-col items-center justify-center py-12 text-gray-500",children:[e.jsx(Pe,{className:"animate-spin text-indigo-500 mb-2",size:32}),e.jsx("p",{className:"text-xs",children:T?"正在读取学生作业与成绩状态...":"Loading student submissions and grades..."})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 w-full relative rounded-xl overflow-hidden border border-slate-200 shadow-md bg-white p-5 text-left",children:[e.jsxs("div",{className:"flex justify-between items-center pb-4 border-b border-slate-100 mb-4 gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 select-none",children:[e.jsx(ft,{size:16,className:"text-indigo-655"}),T?"学生作业成绩评定与折算系统":"Student Assignment Grading & Sync"]}),e.jsxs("span",{className:"text-xs bg-indigo-50 text-indigo-750 px-2 py-0.5 rounded-full border border-indigo-100 font-bold",children:[s.length," ",T?"个提交":"submissions"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{slot:"assignment.grade.toolbar.action",slotProps:{lessonId:t,submissions:s,refresh:()=>Q(!0),lang:n}}),e.jsx("button",{onClick:()=>Q(!0),disabled:r,className:"p-1.5 bg-white hover:bg-slate-55 border border-slate-200 rounded-lg text-slate-600 transition-colors flex items-center justify-center cursor-pointer shadow-4xs",title:T?"刷新数据":"Refresh",children:e.jsx(Pe,{size:12,className:r?"animate-spin":""})})]})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-xl p-4 mb-5 shrink-0 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(Ia,{className:"text-indigo-500 shrink-0 mt-0.5",size:16}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-slate-700",children:T?"全局默认折算权重设置":"Default Grading Weights Configuration"}),e.jsx("p",{className:"text-xs text-subtle mt-0.5 font-medium",children:T?"调整权重分配,所有尚未锁定成绩的学生将自动应用此默认权重比例。":"Setting global default weights. Changes will automatically apply to non-confirmed grades."})]})]}),e.jsxs("div",{className:"flex items-center gap-4 shrink-0 bg-white px-3.5 py-2 rounded-lg border border-slate-200 shadow-3xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500",children:T?"教师评分:":"Teacher:"}),e.jsx("input",{type:"range","aria-label":T?"教师评分权重":"Teacher weight",min:"0",max:"100",step:"5",value:c,onChange:j=>V(Number(j.target.value)),className:"w-20 accent-indigo-650 cursor-pointer"}),e.jsxs("span",{className:"text-xs font-bold text-indigo-700 w-8 text-right",children:[c,"%"]})]}),e.jsx("div",{className:"h-4 w-[1px] bg-slate-200"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500",children:T?"学生互评:":"Peer Review:"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 w-8",children:[m,"%"]})]})]}),e.jsx(me,{slot:"assignment.grade.rubric.addon",slotProps:{lessonId:t,defaultTeacherWeight:c,defaultPeerWeight:m,onTeacherWeightChange:V,lang:n}})]}),e.jsx("div",{className:"flex-grow flex-1 overflow-y-auto space-y-4 pr-1 scrollbar-thin",children:s.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center py-12 text-slate-400 gap-2",children:[e.jsx(fs,{size:32,className:"text-slate-350"}),e.jsx("p",{className:"text-xs",children:T?"本节课目前没有任何学生提交作业。":"No students have submitted assignments yet for this lesson."})]}):s.map(j=>{const q=w[j.id]!==void 0?w[j.id]:80,ee=N[j.id]||"",R=$[j.id]??c,O=y[j.id]??m,L=j.grade?.status==="confirmed",X=Math.round(q*(R/100)+j.peerAverageScore*(O/100));return e.jsxs("div",{className:`bg-white border rounded-xl shadow-3xs overflow-hidden transition-all ${L?"border-emerald-200 bg-emerald-50/5":"border-slate-200"}`,children:[e.jsxs("div",{className:"px-4 py-3 bg-slate-50/50 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-700 font-bold text-xs select-none",children:j.studentName?.charAt(0)||"S"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-800",children:j.studentName}),e.jsxs("div",{className:"text-xs text-slate-400 font-mono mt-0.5 flex items-center gap-1.5",children:[e.jsxs("span",{children:["V",j.version]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(j.updatedAt).toLocaleString()})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[L?e.jsxs("span",{className:"bg-emerald-55 text-emerald-700 text-xs font-black px-2.5 py-1 rounded-full border border-emerald-150 flex items-center gap-1 shadow-3xs select-none",children:[e.jsx(La,{size:12}),T?"成绩已同步":"Synced to Reports"]}):e.jsx("span",{className:"bg-amber-50 text-amber-805 text-xs font-bold px-2 py-0.5 rounded-full border border-amber-200/60 select-none",children:j.grade?T?"草稿状态":"Draft":T?"未评定":"Ungraded"}),(()=>{const K=Na(j.filePath);return K?e.jsxs("a",{href:K,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-indigo-600 hover:text-indigo-850 font-medium hover:underline flex items-center gap-1 bg-white border border-slate-200 px-2 py-1 rounded-lg shadow-4xs",title:j.filePath,children:[e.jsx(yt,{size:11}),T?"查看作业":"View File",e.jsx(tn,{size:8})]}):null})()]})]}),e.jsxs("div",{className:"p-4 grid grid-cols-1 lg:grid-cols-12 gap-5",children:[e.jsxs("div",{className:"lg:col-span-5 flex flex-col gap-2.5 border-r border-slate-100 pr-0 lg:pr-5 text-left",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-xs font-bold text-slate-650 flex items-center gap-1 select-none",children:[e.jsx($e,{size:13,className:"text-slate-400"}),T?"学生互评详情":"Peer Review Details"]}),e.jsxs("span",{className:"text-xs font-bold text-slate-500 bg-slate-100 px-2 py-0.5 rounded-md",children:[T?"互评人数:":"Reviews:"," ",j.peerReviews.length]})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-100 rounded-xl p-3 flex items-center gap-3",children:[e.jsxs("div",{className:"bg-white border border-slate-200 w-12 h-12 rounded-lg flex flex-col items-center justify-center shrink-0 shadow-3xs",children:[e.jsx("span",{className:"text-xs text-slate-405 select-none font-bold",children:T?"均分":"Avg"}),e.jsx("span",{className:"text-sm font-extrabold text-slate-700 leading-none mt-0.5",children:j.peerAverageScore})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-450 leading-normal font-medium",children:j.peerReviews.length>0?T?"根据同学互评分数得出的平均值。":"Average score computed from classmate evaluations.":T?"暂无同学对此作业给出评分。":"No classmate peer reviews received yet."}),j.peerReviews.length>0&&e.jsx("button",{onClick:()=>D(j.id),className:"text-xs text-indigo-650 hover:text-indigo-800 font-bold mt-1.5 flex items-center gap-0.5 cursor-pointer outline-none",children:g[j.id]?e.jsxs(e.Fragment,{children:[T?"收起互评详情":"Hide Details"," ",e.jsx(Xs,{size:12})]}):e.jsxs(e.Fragment,{children:[T?"展开互评详情":"Show Details"," ",e.jsx(Ut,{size:12})]})})]})]}),g[j.id]&&j.peerReviews.length>0&&e.jsx("div",{className:"mt-2 space-y-2 border-t border-slate-100 pt-2.5 max-h-40 overflow-y-auto scrollbar-thin",children:j.peerReviews.map(K=>e.jsxs("div",{className:"bg-white border border-slate-200 rounded-lg p-2.5 text-xs text-left shadow-4xs",children:[e.jsxs("div",{className:"flex justify-between items-center font-bold text-slate-700",children:[e.jsxs("span",{className:"flex items-center gap-1 font-semibold text-slate-655",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-300"}),K.reviewer_name]}),e.jsxs("span",{className:"text-indigo-650 bg-indigo-50 border border-indigo-100 rounded px-1.5 py-0.5 text-xs",children:[K.score," ",T?"分":"pts"]})]}),K.comment&&e.jsxs("p",{className:"text-xs text-slate-550 mt-1 italic pl-2.5 border-l-2 border-slate-100 font-medium",children:['"',K.comment,'"']})]},K.id))})]}),e.jsxs("div",{className:"lg:col-span-7 flex flex-col gap-3 justify-between",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-650 mb-1 select-none",children:T?"教师平时分评分 (0-100)":"Teacher Score (0-100)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:`teacher_score_input_${j.id}`,type:"number",min:"0",max:"100",disabled:L,value:q,onChange:K=>f(H=>({...H,[j.id]:Math.min(100,Math.max(0,Number(K.target.value)))})),className:"bg-white border border-slate-250 rounded-lg text-xs font-bold text-slate-700 px-3 py-1.5 focus:ring-1 focus:ring-indigo-500 outline-none w-20 shadow-4xs disabled:opacity-50 disabled:bg-slate-50"}),e.jsx("input",{type:"range","aria-label":T?`${j.studentName||"学生"} 的得分`:`Score for ${j.studentName||"student"}`,min:"0",max:"100",disabled:L,value:q,onChange:K=>f(H=>({...H,[j.id]:Number(K.target.value)})),className:"flex-1 accent-indigo-650 disabled:opacity-40 cursor-pointer"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"block text-xs font-bold text-slate-600 select-none",children:T?"打分占比 (教师权重)":"Teacher Score Weight"}),e.jsx("span",{className:"text-xs font-bold text-slate-400",children:T?`学生互评: ${O}%`:`Peer: ${O}%`})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:`teacher_weight_input_${j.id}`,type:"range",min:"0",max:"100",step:"5",disabled:L,value:R,onChange:K=>le(j.id,Number(K.target.value)),className:"flex-1 accent-indigo-650 disabled:opacity-40 cursor-pointer"}),e.jsxs("span",{className:"text-xs font-extrabold text-indigo-750 w-9 text-right",children:[R,"%"]})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-655 mb-1 select-none",children:T?"教师评价评语":"Teacher Comments & Feedback"}),e.jsx("textarea",{id:`teacher_comment_input_${j.id}`,disabled:L,value:ee,placeholder:T?"在此输入对学生作业作品的改进指导意见及评语。":"Enter guiding feedback for this student.",onChange:K=>b(H=>({...H,[j.id]:K.target.value})),rows:2,className:"w-full bg-white border border-slate-250 rounded-lg text-xs p-2 focus:ring-1 focus:ring-indigo-500 outline-none shadow-4xs disabled:opacity-50 disabled:bg-slate-50 resize-none font-medium text-slate-700"})]}),e.jsx(me,{slot:"assignment.grade.item.addon",slotProps:{submission:j,studentId:j.student_id,lessonId:t,score:q,comment:ee,isConfirmed:L,onScoreChange:K=>f(H=>({...H,[j.id]:K})),onCommentChange:K=>b(H=>({...H,[j.id]:K})),lang:n}}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pt-2 border-t border-slate-100 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`p-1.5 rounded-lg border flex items-center justify-center shrink-0 ${L?"bg-emerald-50 text-emerald-600 border-emerald-100":"bg-indigo-50 text-indigo-700 border-indigo-100"}`,children:e.jsx(qt,{size:14})}),e.jsxs("div",{className:"text-xs text-slate-500 font-medium",children:[e.jsxs("div",{children:[T?"平时总分计算公式":"Calculated Final Grade",":"]}),e.jsxs("div",{className:"font-bold text-slate-700 mt-0.5 animate-formula",children:[R,"% × ",e.jsx("span",{className:"text-indigo-650 font-bold",children:q}),j.peerReviews.length>0&&` + ${O}% × ${j.peerAverageScore}`," = ",e.jsx("span",{className:L?"text-emerald-700 font-black text-xs":"text-indigo-700 font-black text-xs",children:L&&j.grade?.calculated_final_score||X}),T?"分":" pts"]})]})]}),!L&&e.jsxs("div",{className:"flex gap-2 justify-end shrink-0",children:[e.jsxs("button",{id:`teacher_draft_btn_${j.id}`,type:"button",disabled:!!U[j.id],onClick:()=>F(j.id,"draft"),className:"px-3 py-1.5 bg-white border border-slate-350 rounded-lg text-xs font-bold text-slate-700 hover:bg-slate-55 flex items-center gap-1.5 shadow-4xs cursor-pointer select-none disabled:opacity-50",children:[e.jsx(er,{size:12}),U[j.id]==="draft"?T?"保存中...":"Saving...":T?"暂存草稿":"Save Draft"]}),e.jsxs("button",{id:`teacher_confirm_btn_${j.id}`,type:"button",disabled:!!U[j.id],onClick:()=>F(j.id,"confirmed"),className:"px-3.5 py-1.5 bg-indigo-600 border border-indigo-700 rounded-lg text-xs font-bold text-white hover:bg-indigo-700 flex items-center gap-1.5 shadow-3xs cursor-pointer select-none disabled:opacity-50",children:[e.jsx(ut,{size:12}),U[j.id]==="confirmed"?T?"同步中...":"Syncing...":T?"确认并同步":"Confirm & Sync"]})]})]})]})]})]},j.id)})})]})}function So({isOpen:t,onClose:n,lessonId:a,lessonTitle:o,lang:d="zh"}){const{data:r,health:l,lastSyncedAt:s}=va(a,{enabled:t});return t?e.jsx(wa,{lessonId:a,lessonTitle:o,data:r,lang:d,health:l,lastSyncedAt:s,onClose:n}):null}function Co({lessonId:t,lessonTitle:n,lang:a}){const o=new URLSearchParams({mode:"stage_display",lessonId:t});n&&o.set("title",n),a&&o.set("lang",a);const{pathname:d,origin:r}=window.location;return`${r}${d}?${o.toString()}#/stage_display`}function $o(){const t=i.useRef(null),[n,a]=i.useState(!1),[o,d]=i.useState(!1);i.useEffect(()=>()=>{t.current=null},[]),i.useEffect(()=>{const h=setInterval(()=>{const c=t.current;c&&c.closed&&(t.current=null)},3e3);return()=>clearInterval(h)},[]);const r=i.useCallback(h=>{const c=t.current;if(c&&!c.closed){c.focus();return}let u;try{u=window.open(Co(h),"openlearn-stage-display","width=1280,height=720,menubar=no,toolbar=no,location=no")}catch(m){console.warn("[StageDisplay] window.open threw:",m),u=null}if(!u){d(!0),a(!0);return}t.current=u,d(!1),a(!1),u.focus?.()},[]),l=i.useCallback(()=>a(!1),[]),s=i.useCallback(()=>d(!1),[]);return{fallbackOpen:n,blocked:o,openStageWindow:r,closeFallback:l,clearBlockedHint:s}}const Gs={CLEAR:{emoji:"💡",zh:"理解",en:"Clear",color:"#10b981"},CONFUSED:{emoji:"❓",zh:"困惑",en:"Confused",color:"#f59e0b"},TOO_FAST:{emoji:"🐇",zh:"慢一点",en:"Slow down",color:"#f43f5e"},SLOW:{emoji:"🐢",zh:"快一点",en:"Speed up",color:"#6366f1"}},Ao=["CLEAR","CONFUSED","TOO_FAST","SLOW"];function Eo({lessonId:t,lang:n,signals:a,onlineCount:o=0,onClose:d,activeSegmentTitle:r}){const l=n==="zh",[s,h]=i.useState(a);i.useEffect(()=>{const f=ps();if(!f)return;const N=b=>{b?.lessonId===t&&b?.summary&&h(b.summary)};return f.on("classroom:pacing_updated",N),()=>{typeof f.off=="function"&&f.off("classroom:pacing_updated",N)}},[t]);const c=Ao.map(f=>({key:f,count:Number(s[f]??0)})),u=c.reduce((f,N)=>f+N.count,0);Number(s.CONFUSED??0)+Number(s.TOO_FAST??0)+Number(s.SLOW??0);const m=u>0?Math.round(Number(s.CLEAR??0)/u*100):null,p=i.useCallback(()=>u===0?{text:l?"暂无学生反馈,等待中…":"No feedback yet",tone:"text-muted"}:Number(s.CONFUSED??0)>=Math.max(2,u*.3)?{text:l?"⚠ 较多学生困惑,建议放慢并重新讲解当前环节":"⚠ Many students are confused — slow down and re-explain",tone:"text-amber-600"}:Number(s.TOO_FAST??0)>=Math.max(2,u*.3)?{text:l?"🐇 较多学生希望放慢节奏":"🐇 Many students want you to slow down",tone:"text-rose-600"}:Number(s.SLOW??0)>=Math.max(2,u*.3)?{text:l?"🐢 较多学生希望加快节奏":"🐢 Many students want you to speed up",tone:"text-indigo-600"}:{text:l?"✓ 节奏反馈健康,可按当前节奏继续":"✓ Pace is healthy — carry on",tone:"text-emerald-700 dark:text-emerald-400"},[s,u,l]),w=c.filter(f=>f.count>0).map(f=>({name:Gs[f.key][l?"zh":"en"],value:f.count,color:Gs[f.key].color}));return e.jsx("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-slate-900/60 backdrop-blur-2xs",onPointerDown:d,children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-[560px] max-w-[92vw] max-h-[86vh] overflow-y-auto p-5 font-sans text-main",onPointerDown:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 bg-primary-theme/10 text-primary-theme rounded-xl",children:e.jsx(Ma,{size:18})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm font-black text-main flex items-center gap-1.5",children:[l?"课堂反馈情绪仪表盘":"Classroom Feedback Dashboard",e.jsxs("span",{className:"flex items-center gap-1 text-2xs font-bold text-emerald-700 dark:text-emerald-400 bg-emerald-500/10 px-1.5 py-0.5 rounded-full",children:[e.jsx(Oe,{size:10})," ",l?"实时":"LIVE"]})]}),e.jsx("p",{className:"text-2xs text-muted mt-0.5",children:r?l?`当前教学环节: ${r} · 去重实时聚合`:`Active Segment: ${r} · Real-time`:l?"按环节去重 · 实时节奏反馈聚合":"Deduplicated real-time pacing feedback"})]})]}),e.jsx("button",{onClick:d,className:"p-1.5 rounded-lg hover:bg-surface-secondary text-muted cursor-pointer",title:l?"关闭":"Close",children:e.jsx(we,{size:16})})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-center",children:[e.jsxs("div",{className:"w-[200px] h-[200px] relative shrink-0",children:[u>0?e.jsx(Nn,{width:"100%",height:"100%",children:e.jsx(ho,{children:e.jsx(po,{data:w,dataKey:"value",nameKey:"name",innerRadius:52,outerRadius:85,paddingAngle:3,strokeWidth:0,isAnimationActive:!1,children:w.map((f,N)=>e.jsx(fo,{fill:f.color},N))})})}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-3xl opacity-30",children:"📊"}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center pointer-events-none",children:[e.jsxs("span",{className:"text-2xs text-muted flex items-center gap-1",children:[e.jsx($e,{size:10})," ",o," ",l?"在线":"online"]}),e.jsx("span",{className:`text-xl font-black ${m===null?"text-muted":m>=60?"text-emerald-700 dark:text-emerald-400":m>=30?"text-amber-700 dark:text-amber-400":"text-rose-700 dark:text-rose-400"}`,children:m===null?"—":`${m}%`}),e.jsx("span",{className:"text-2xs text-muted",children:l?"理解占比":"clear ratio"})]})]}),e.jsxs("div",{className:"flex-1 w-full flex flex-col gap-2.5",children:[c.map(({key:f,count:N})=>{const b=Gs[f],$=u>0?Math.round(N/u*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-0.5",children:[e.jsxs("span",{className:"font-bold text-main",children:[b.emoji," ",l?b.zh:b.en]}),e.jsxs("span",{className:"text-muted font-mono",children:[N," · ",$,"%"]})]}),e.jsx("div",{className:"h-2.5 bg-surface-secondary rounded-full overflow-hidden border border-theme/50",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${$}%`,background:b.color}})})]},f)}),e.jsx("div",{className:`mt-1 text-xs font-bold ${p().tone}`,children:p().text}),e.jsx(me,{slot:"classroom.barometer.metric",slotProps:{lessonId:t,signals:s,total:u,health:m,lang:n}})]})]})]})})}function To({progressHistory:t,lang:n="zh",compact:a=!1}){const o=i.useMemo(()=>({title:n==="zh"?"课程学习进度趋势":"Learning Progress Trend",badge:n==="zh"?"历史趋势":"History",subtitle:n==="zh"?"按课程追踪学习完成度与进度变化曲线":"Track lesson completion progress over time",emptyTitle:n==="zh"?"暂无学习进度记录":"No Progress Records Yet",emptyDesc:n==="zh"?"当学生被分配课程并开始学习后,进度趋势将在此展示。":"Progress trends will appear here once lessons are assigned and started.",tooltipLesson:n==="zh"?"课程":"Lesson",tooltipProgress:n==="zh"?"完成进度":"Progress",tooltipDate:n==="zh"?"分配时间":"Assigned",tooltipStatus:n==="zh"?"状态":"Status",completed:n==="zh"?"已完成":"Completed",inProgress:n==="zh"?"进行中":"In Progress",statAvg:n==="zh"?"平均进度":"Avg Progress",statCompleted:n==="zh"?"已完成":"Completed",statTotal:n==="zh"?"总课程数":"Total Lessons"}),[n]),{chartData:d,stats:r}=i.useMemo(()=>{if(!t||t.length===0)return{chartData:[],stats:{avg:0,completed:0,total:0}};const s=new Map;for(const p of t){const w=s.get(p.lesson_id);(!w||p.assigned_at>w.assigned_at)&&s.set(p.lesson_id,p)}const c=Array.from(s.values()).sort((p,w)=>p.assigned_at-w.assigned_at).map(p=>{const w=new Date(p.assigned_at),f=n==="zh"?`${w.getMonth()+1}月${w.getDate()}日`:w.toLocaleDateString("en-US",{month:"short",day:"numeric"});return{label:p.lesson_title.length>8?p.lesson_title.slice(0,8)+"…":p.lesson_title,lessonTitle:p.lesson_title,progressPercent:Math.max(0,Math.min(100,Math.round(p.progress_percent))),completed:p.completed===1,dateLabel:f,timestamp:p.assigned_at}}),u=c.reduce((p,w)=>p+w.progressPercent,0),m=c.filter(p=>p.completed).length;return{chartData:c,stats:{avg:c.length>0?Math.round(u/c.length):0,completed:m,total:c.length}}},[t,n]);if(d.length===0)return e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-3.5 shadow-3xs","data-testid":"learning-progress-trend-empty",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Oe,{size:15,className:"text-primary-theme"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:o.title})]}),e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-4 text-center",children:[e.jsx(fs,{size:24,className:"mx-auto text-muted mb-1.5"}),e.jsx("p",{className:"text-[11px] font-semibold text-muted",children:o.emptyTitle}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:o.emptyDesc})]})]});const l=a?180:220;return e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-3.5 shadow-3xs","data-testid":"learning-progress-trend-chart",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Oe,{size:15,className:"text-primary-theme"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:o.title}),e.jsx("span",{className:"text-[10px] font-mono font-bold px-1.5 py-0.5 rounded-md bg-primary-theme/10 text-primary-theme border border-primary-theme/20",children:o.badge})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-2.5",children:[e.jsxs("div",{className:"bg-surface-secondary/40 rounded-lg px-2 py-1.5 border border-border/50",children:[e.jsx("div",{className:"text-[10px] text-muted font-medium",children:o.statAvg}),e.jsxs("div",{className:"text-sm font-extrabold text-foreground font-mono",children:[r.avg,"%"]})]}),e.jsxs("div",{className:"bg-surface-secondary/40 rounded-lg px-2 py-1.5 border border-border/50",children:[e.jsx("div",{className:"text-[10px] text-muted font-medium",children:o.statCompleted}),e.jsxs("div",{className:"text-sm font-extrabold text-emerald-600 dark:text-emerald-400 font-mono",children:[r.completed,"/",r.total]})]}),e.jsxs("div",{className:"bg-surface-secondary/40 rounded-lg px-2 py-1.5 border border-border/50",children:[e.jsx("div",{className:"text-[10px] text-muted font-medium",children:o.statTotal}),e.jsx("div",{className:"text-sm font-extrabold text-foreground font-mono",children:r.total})]})]}),e.jsx("div",{style:{width:"100%",height:l},children:e.jsx(Nn,{width:"100%",height:"100%",children:e.jsxs(bo,{data:d,margin:{top:10,right:10,left:-25,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"progressGradientFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:.02})]}),e.jsxs("linearGradient",{id:"progressStrokeGrad",x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:"#6366f1"}),e.jsx("stop",{offset:"50%",stopColor:"#818cf8"}),e.jsx("stop",{offset:"100%",stopColor:"#a78bfa"})]})]}),e.jsx(go,{strokeDasharray:"3 3",vertical:!1,stroke:"#e2e8f0",opacity:.5}),e.jsx(jo,{dataKey:"label",tick:{fontSize:10,fill:"#64748b",fontWeight:600},axisLine:{stroke:"#e2e8f0"},tickLine:!1,interval:d.length>8?Math.floor(d.length/6):0}),e.jsx(yo,{domain:[0,100],ticks:[0,25,50,75,100],tick:{fontSize:10,fill:"#64748b",fontWeight:600},axisLine:{stroke:"#e2e8f0"},tickLine:!1,tickFormatter:s=>`${s}%`}),e.jsx(No,{y:100,stroke:"#10b981",strokeDasharray:"4 4",strokeWidth:1,label:{value:n==="zh"?"完成 100%":"100% Complete",fill:"#059669",fontSize:9,fontWeight:700,position:"insideTopRight"}}),e.jsx(vo,{content:({active:s,payload:h})=>{if(!s||!h||!h.length)return null;const c=h[0].payload;return e.jsxs("div",{className:"bg-slate-900 text-white rounded-xl p-2.5 shadow-xl border border-slate-700/80 text-xs min-w-[180px] z-50",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pb-1.5 border-b border-slate-800",children:[e.jsx(Rt,{size:12,className:"text-indigo-300"}),e.jsx("span",{className:"font-bold text-indigo-300 truncate max-w-[150px]",children:c.lessonTitle})]}),e.jsxs("div",{className:"pt-1.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-slate-300",children:[o.tooltipProgress,":"]}),e.jsxs("span",{className:"font-extrabold text-emerald-400 font-mono",children:[c.progressPercent,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-slate-300",children:[o.tooltipDate,":"]}),e.jsx("span",{className:"text-slate-200 font-mono text-[11px]",children:c.dateLabel})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-slate-300",children:[o.tooltipStatus,":"]}),e.jsxs("span",{className:`flex items-center gap-1 font-semibold ${c.completed?"text-emerald-400":"text-amber-400"}`,children:[e.jsx(Ce,{size:11}),c.completed?o.completed:o.inProgress]})]})]})]})}}),e.jsx(wo,{type:"monotone",dataKey:"progressPercent",name:n==="zh"?"完成进度":"Progress",stroke:"url(#progressStrokeGrad)",strokeWidth:2.5,fill:"url(#progressGradientFill)",dot:{r:3.5,fill:"#6366f1",stroke:"#ffffff",strokeWidth:2},activeDot:{r:6,stroke:"#a78bfa",strokeWidth:2,fill:"#ffffff"},animationDuration:600})]})})})]})}function xr({isOpen:t,onClose:n,student:a,lessonId:o,classId:d,lang:r="zh",addToast:l,onInspectSandbox:s,onCastStudentScreen:h,onAwardPoints:c,progressHistory:u}){const[m,p]=i.useState(!1),[w,f]=i.useState([]),[N,b]=i.useState("overview"),$=ka(H=>H.version);i.useEffect(()=>{t&&b("overview")},[t,a?.id]),i.useEffect(()=>{if(u!==void 0)return;if(!t||!a?.id){f([]);return}let H=!0;return(async()=>{try{const te=await fetch(`/api/students/${a.id}/progress`);if(te.ok){const de=await te.json();H&&Array.isArray(de)&&f(de)}}catch{}})(),()=>{H=!1}},[t,a?.id,u,$]);const P=u!==void 0?u:w,y=a?.competencyScores,k=i.useMemo(()=>[{key:"logic",label:r==="zh"?"算法逻辑":"Logic"},{key:"engineering",label:r==="zh"?"代码工程":"Engineering"},{key:"creativity",label:r==="zh"?"创新思维":"Creativity"},{key:"collaboration",label:r==="zh"?"团队协作":"Collaboration"},{key:"focus",label:r==="zh"?"课堂专注":"Focus"}],[r]),g=i.useMemo(()=>k.map(H=>{const re=y?.[H.key],te=typeof re=="number"&&Number.isFinite(re);return{key:H.key,label:H.label,score:te?Math.max(0,Math.min(100,Math.round(re))):0,available:te}}),[y,k]),A=g.some(H=>H.available),U=g.filter(H=>!H.available).map(H=>H.label),W=i.useMemo(()=>{const H=r==="zh",re=a?.name??(r==="zh"?"该学生":"This student"),te=g.filter(B=>B.available);if(te.length===0)return H?`${re}本节暂无可用的维度数据(未参与随堂测/课件互动),无法生成掌握度评语。建议下节课关注其参与情况。`:`${re} has no competency data for this session (no quiz/courseware interaction).`;const de=Math.round(te.reduce((B,se)=>B+se.score,0)/te.length),G=te.reduce((B,se)=>se.score>B.score?se:B),S=te.reduce((B,se)=>se.score<B.score?se:B),M=g.filter(B=>!B.available).map(B=>B.label);return(H?[`本节已采集维度:${te.map(B=>`${B.label} ${B.score}`).join("、")},平均 ${de}。`,`相对优势为${G.label}(${G.score}),相对薄弱为${S.label}(${S.score})。`,M.length>0?`未采集维度:${M.join("、")}。`:""]:[`Collected: ${te.map(B=>`${B.label} ${B.score}`).join(", ")}; average ${de}.`,`Strongest ${G.label} (${G.score}), weakest ${S.label} (${S.score}).`,M.length>0?`Missing: ${M.join(", ")}.`:""]).filter(Boolean).join(" ")},[g,r,a]),T=i.useMemo(()=>{const H=r==="zh",re=g.filter(de=>de.available);if(re.length===0)return H?"数据不足,暂不生成建议":"Insufficient data";const te=re.reduce((de,G)=>de+G.score,0)/re.length;return te>=85?H?"建议进入算法创新挑战营":"Recommended for Advanced Camp":te>=70?H?"建议保持当前节奏并补强薄弱维度":"Keep pace, strengthen weak areas":H?"建议课后补充基础微练习":"Suggest remedial practice"},[g,r]),Q=i.useMemo(()=>{const H=g.filter(te=>te.available);if(H.length===0)return"—";const re=H.reduce((te,de)=>te+de.score,0)/H.length;return re>=90?"A+":re>=80?"A":re>=70?"B+":re>=60?"B":"C"},[g]),V=i.useMemo(()=>{const de=(B,se)=>{const v=-Math.PI/2+2*Math.PI/5*se;return{x:100+B*Math.cos(v),y:100+B*Math.sin(v)}},G=[1,.66,.33].map(B=>{const se=75*B;return Array.from({length:5},(_,Z)=>{const{x:ie,y:xe}=de(se,Z);return`${ie.toFixed(1)},${xe.toFixed(1)}`}).join(" ")}),S=Array.from({length:5},(B,se)=>{const{x:v,y:_}=de(75,se);return{x1:100,y1:100,x2:v,y2:_}}),M=g.map((B,se)=>{const v=75*Math.min(Math.max(B.score/100,.1),1);return de(v,se)}),I=M.map(B=>`${B.x.toFixed(1)},${B.y.toFixed(1)}`).join(" ");return{gridLevels:G,axes:S,dataPoints:M,dataPolygonString:I}},[g]);if(!t||!a)return null;const le=a.points??0,F=a.deltaPoints??4,D=a.focusPercentage,j=a.accuracyPercentage,q=a.helpCount??3,ee=a.role||a.student_number||"",R=a.group_name||"",O=a.student_number||a.id.slice(-6),L=a.timeline??[],X=async(H,re)=>{p(!0);try{c?c(a.id,H,re):await fetch(`/api/students/${a.id}/points`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({delta:H,dimension:"attribution",reason:re,classId:d,lessonId:o})}),l?.(r==="zh"?"成长积分已发放":"Points Awarded",r==="zh"?`已为学生 [${a.name}] ${H>=0?"+":""}${H} 分(${re})`:`Awarded ${H} pts to [${a.name}]`,"success")}catch(te){const de=te instanceof Error?te.message:String(te);l?.("Error",de,"error")}finally{p(!1)}},K=()=>{const H=`# 学生个人全景学情与成长档案 (${a.name})
|
|
2
|
+
- **学生姓名**: ${a.name}
|
|
3
|
+
- **学号**: ${O}
|
|
4
|
+
- **所属班级**: ${a.className||d||"默认班级"}
|
|
5
|
+
- **小组归属**: ${R} (${ee})
|
|
6
|
+
- **生成时间**: ${new Date().toLocaleString()}
|
|
7
|
+
|
|
8
|
+
## 1. 课堂核心素养与成长指标
|
|
9
|
+
- **总积分**: ${le} 分 (本节新增: +${F})
|
|
10
|
+
- **专注度**: ${typeof D=="number"?`${D}%`:"—"}
|
|
11
|
+
- **答题正确率**: ${typeof j=="number"?`${j}%`:"—"}
|
|
12
|
+
- **互助答疑频次**: ${q} 次
|
|
13
|
+
|
|
14
|
+
## 2. 五维计算思维雷达评级
|
|
15
|
+
${g.map(re=>`- **${re.label}**: ${re.score} / 100`).join(`
|
|
16
|
+
`)}
|
|
17
|
+
|
|
18
|
+
## 3. 本堂答题与互动轨迹
|
|
19
|
+
${L.length>0?L.map(re=>`- [${re.time}] ${re.title} (${re.points?"+"+re.points+"分":""}) - ${re.description}`).join(`
|
|
20
|
+
`):"- 本节暂无作答或互动记录"}
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
*OpenLearn Next 过程性评价系统自动生成*
|
|
24
|
+
`;try{const re=new Blob([H],{type:"text/markdown;charset=utf-8"}),te=URL.createObjectURL(re),de=document.createElement("a");de.href=te,de.download=`学生学情档案_${a.name}_${O}.md`,de.click(),URL.revokeObjectURL(te),l?.(r==="zh"?"学情档案导出成功":"Report Exported",r==="zh"?`已生成 [${a.name}] 个人学情 Markdown 档案`:"Exported student report","success")}catch{navigator.clipboard?.writeText(H),l?.(r==="zh"?"已复制至剪贴板":"Copied to Clipboard",r==="zh"?"学情报告内容已复制":"Report copied","info")}};return e.jsx("div",{id:"student-growth-profile-modal-backdrop",className:"fixed inset-0 z-50 bg-slate-950/65 backdrop-blur-md flex items-center justify-center p-3 sm:p-5 select-none animate-in fade-in duration-200",onClick:H=>{H.target===H.currentTarget&&n()},children:e.jsxs("div",{className:"w-full max-w-4xl bg-surface border border-border/80 rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[92vh] text-foreground animate-in zoom-in-95 duration-150",role:"dialog","aria-modal":"true","aria-labelledby":"student-profile-title",children:[e.jsxs("header",{className:"px-5 py-3.5 bg-gradient-to-r from-indigo-50/70 via-surface to-amber-50/40 dark:from-indigo-950/30 dark:via-surface dark:to-amber-950/20 border-b border-border/80 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:n,className:"w-8 h-8 rounded-xl bg-surface hover:bg-surface-secondary text-foreground flex items-center justify-center transition border border-border shadow-3xs cursor-pointer",title:r==="zh"?"返回全班列表":"Back",children:e.jsx(sn,{size:16})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-600 text-white flex items-center justify-center font-bold text-sm shadow-3xs",children:a.avatar?e.jsx("img",{src:a.avatar,alt:a.name,className:"w-full h-full object-cover rounded-xl"}):e.jsx("span",{children:a.name.slice(0,1)})}),e.jsx("span",{className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-emerald-500 border-2 border-surface"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{id:"student-profile-title",className:"text-sm font-bold text-foreground tracking-tight",children:a.name}),ee&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700 dark:text-indigo-300 text-[10px] font-bold",children:ee}),R&&e.jsxs("span",{className:"px-1.5 py-0.2 rounded bg-amber-100 dark:bg-amber-900/50 text-amber-800 dark:text-amber-300 text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(bt,{size:11,className:"text-amber-600 dark:text-amber-400"}),e.jsx("span",{children:R})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-700 dark:text-emerald-300 bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-200 dark:border-emerald-800 px-1.5 py-0.2 rounded-full font-medium",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsxs("span",{children:[typeof D=="number"?`${D}%`:"—"," ",r==="zh"?"专注在线":"Focus"]})]})]}),e.jsxs("div",{className:"text-[11px] text-muted flex items-center gap-2 mt-0.5",children:[e.jsxs("span",{children:[r==="zh"?"学号: ":"ID: ",e.jsx("strong",{className:"font-mono font-normal text-foreground",children:O})]}),e.jsx("span",{className:"text-border",children:"|"}),e.jsx("span",{children:a.className||(r==="zh"?"示范班级":"Class")}),e.jsx("span",{className:"text-border",children:"|"}),e.jsx("span",{className:"text-primary-theme font-medium",children:r==="zh"?"个人综合成长档案":"Growth Profile"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[h&&e.jsxs("button",{onClick:()=>h(a.id),className:"px-2.5 py-1.5 rounded-xl bg-indigo-50 hover:bg-indigo-100 dark:bg-indigo-950/40 dark:hover:bg-indigo-900/50 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-800 text-xs font-semibold flex items-center gap-1.5 transition shadow-3xs cursor-pointer",title:r==="zh"?"将该生操作白板/代码投屏至大屏幕":"Cast Student Screen",children:[e.jsx(rn,{size:13,className:"text-indigo-600 dark:text-indigo-400"}),e.jsx("span",{children:r==="zh"?"投屏其工作台":"Cast Screen"})]}),e.jsx(me,{slot:"student.profile.action",slotProps:{student:a,lessonId:o,classId:d}}),e.jsx("button",{onClick:n,"aria-label":"Close",className:"p-1.5 rounded-lg hover:bg-surface-secondary text-muted hover:text-foreground transition cursor-pointer",title:r==="zh"?"关闭弹窗":"Close",children:e.jsx(we,{size:16})})]})]}),e.jsx("div",{className:"px-5 py-2 bg-surface border-b border-border/80 flex items-center justify-between gap-2 overflow-x-auto shrink-0",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>b("overview"),className:`px-3 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${N==="overview"?"bg-primary-theme text-white shadow-xs":"text-muted hover:text-foreground hover:bg-surface-secondary"}`,children:[e.jsx(Oe,{size:14,className:"shrink-0"}),e.jsx("span",{children:r==="zh"?"全景概览":"Overview"})]}),e.jsx(me,{slot:"student.profile.tab",slotProps:{renderType:"button",studentActiveTab:N,setStudentActiveTab:b,student:a,lessonId:o,classId:d,lang:r}})]})}),N==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"px-5 py-3 bg-surface-secondary/40 border-b border-border/70 grid grid-cols-2 sm:grid-cols-4 gap-3 shrink-0",children:[e.jsxs("div",{className:"bg-surface p-2.5 rounded-xl border border-border/80 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-muted font-medium",children:r==="zh"?"本节总积分":"Total Points"}),e.jsxs("div",{className:"text-lg font-extrabold text-indigo-700 dark:text-indigo-300 font-mono flex items-baseline gap-1",children:[le," ",e.jsx("span",{className:"text-[10px] text-muted font-normal",children:r==="zh"?"分":"pts"}),e.jsxs("span",{className:"text-[10px] font-mono text-emerald-600 dark:text-emerald-400 font-bold bg-emerald-50 dark:bg-emerald-950/40 px-1 py-0.2 rounded ml-0.5",children:["+",F]})]}),e.jsxs("div",{className:"text-[10px] text-muted mt-0.5",children:[r==="zh"?"组内贡献率: ":"Team Share: ",e.jsx("strong",{className:"text-primary-theme font-semibold",children:"26%"})]})]}),e.jsx("div",{className:"w-9 h-9 rounded-xl bg-indigo-50 dark:bg-indigo-950/40 text-indigo-600 dark:text-indigo-300 flex items-center justify-center text-lg shadow-3xs",children:e.jsx(bt,{size:18})})]}),e.jsxs("div",{className:"bg-surface p-2.5 rounded-xl border border-border/80 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-muted font-medium",children:r==="zh"?"本堂专注度":"Focus Rate"}),e.jsxs("div",{className:"text-lg font-extrabold text-emerald-600 dark:text-emerald-400 font-mono flex items-baseline gap-1",children:[typeof D=="number"?`${D}%`:"—"," ",typeof D=="number"&&e.jsx("span",{className:"text-[10px] text-muted font-normal font-sans",children:D>=80?r==="zh"?"优良":"Good":r==="zh"?"待提升":"Needs work"})]}),e.jsxs("div",{className:"text-[10px] text-muted mt-0.5",children:[r==="zh"?"击败全班 ":"Top ",e.jsx("strong",{className:"text-emerald-600 dark:text-emerald-400 font-semibold",children:"96%"})," ",r==="zh"?"同学":"students"]})]}),e.jsx("div",{className:"w-9 h-9 rounded-xl bg-emerald-50 dark:bg-emerald-950/40 text-emerald-600 dark:text-emerald-400 flex items-center justify-center text-lg shadow-3xs",children:e.jsx(Vt,{size:18})})]}),e.jsxs("div",{className:"bg-surface p-2.5 rounded-xl border border-border/80 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-muted font-medium",children:r==="zh"?"答题正确率":"Accuracy"}),e.jsxs("div",{className:"text-lg font-extrabold text-foreground font-mono flex items-baseline gap-1",children:[typeof j=="number"?`${j}%`:"—"," ",typeof j=="number"&&e.jsx("span",{className:"text-[10px] text-muted font-normal",children:j>=90?r==="zh"?"优秀":"Excellent":r==="zh"?"待巩固":"Needs review"})]}),e.jsx("div",{className:"text-[10px] text-muted mt-0.5",children:r==="zh"?"共 2 次提交 · 2 次首发通过":"2 Submissions · 100% 1st pass"})]}),e.jsx("div",{className:"w-9 h-9 rounded-xl bg-amber-50 dark:bg-amber-950/40 text-amber-600 dark:text-amber-400 flex items-center justify-center text-lg shadow-3xs",children:e.jsx(bs,{size:18})})]}),e.jsxs("div",{className:"bg-surface p-2.5 rounded-xl border border-border/80 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-muted font-medium",children:r==="zh"?"互助答疑频次":"Collaboration"}),e.jsxs("div",{className:"text-lg font-extrabold text-sky-600 dark:text-sky-400 font-mono flex items-baseline gap-1",children:[q," ",e.jsx("span",{className:"text-[10px] text-muted font-normal",children:r==="zh"?"次":"times"})]}),e.jsx("div",{className:"text-[10px] text-muted mt-0.5",children:r==="zh"?"协助解决嵌套语法障碍":"Resolved loop syntax obstacles"})]}),e.jsx("div",{className:"w-9 h-9 rounded-xl bg-sky-50 dark:bg-sky-950/40 text-sky-600 dark:text-sky-400 flex items-center justify-center text-lg shadow-3xs",children:e.jsx($e,{size:18})})]})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-y-auto grid grid-cols-1 md:grid-cols-12 gap-4 bg-surface-secondary/20",children:[e.jsxs("div",{className:"md:col-span-5 flex flex-col gap-3",children:[e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-3.5 shadow-3xs",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Oe,{size:15,className:"text-primary-theme"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:r==="zh"?"多维素养与计算思维雷达":"Competency Radar"})]}),e.jsx("span",{className:`text-[10px] font-mono font-bold px-2 py-0.5 rounded-lg border ${A?"text-primary-theme bg-primary-theme/10 border-primary-theme/20":"text-muted bg-surface-secondary border-border/60"}`,title:U.length>0?`${r==="zh"?"暂无数据":"No data"}: ${U.join(", ")}`:void 0,children:A?`${r==="zh"?"综合评级":"Rating"} ${Q}`:r==="zh"?"暂无数据":"No data"})]}),e.jsx("div",{className:"flex items-center justify-center py-1",children:e.jsxs("svg",{className:"w-52 h-52 select-none",viewBox:"0 0 200 200","aria-label":"Competency Radar Chart",children:[V.gridLevels.map((H,re)=>e.jsx("polygon",{points:H,fill:"none",stroke:"currentColor",className:"text-border/60",strokeWidth:"1"},re)),V.axes.map((H,re)=>e.jsx("line",{x1:H.x1,y1:H.y1,x2:H.x2,y2:H.y2,stroke:"currentColor",className:"text-border/50",strokeWidth:"1"},re)),e.jsx("polygon",{points:V.dataPolygonString,fill:A?"rgba(99, 102, 241, 0.25)":"rgba(148, 163, 184, 0.12)",stroke:A?"#6366f1":"#94a3b8",strokeWidth:"2",strokeDasharray:A?void 0:"4 3"}),V.dataPoints.map((H,re)=>e.jsx("circle",{cx:H.x,cy:H.y,r:"3",fill:g[re]?.available?"#6366f1":"#cbd5e1"},re)),e.jsxs("text",{x:"100",y:"14",textAnchor:"middle",fill:"#6366f1",fontSize:"9",fontWeight:"bold",children:[g[0].label," ",g[0].score]}),e.jsxs("text",{x:"180",y:"80",textAnchor:"start",fill:"currentColor",fontSize:"9",fontWeight:"bold",children:[g[1].label," ",g[1].score]}),e.jsxs("text",{x:"145",y:"180",textAnchor:"start",fill:"currentColor",fontSize:"9",fontWeight:"bold",children:[g[2].label," ",g[2].score]}),e.jsxs("text",{x:"55",y:"180",textAnchor:"end",fill:"currentColor",fontSize:"9",fontWeight:"bold",children:[g[3].label," ",g[3].score]}),e.jsxs("text",{x:"20",y:"80",textAnchor:"end",fill:"#10b981",fontSize:"9",fontWeight:"bold",children:[g[4].label," ",g[4].score]})]})}),e.jsx("div",{className:"space-y-1.5 pt-2 border-t border-border/70 text-xs",children:g.slice(0,3).map(H=>e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"text-muted",children:H.label}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-24 bg-surface-secondary h-1.5 rounded-full overflow-hidden border border-border/40",children:e.jsx("div",{className:"bg-primary-theme h-1.5 rounded-full transition-all duration-300",style:{width:`${H.score}%`}})}),e.jsx("span",{className:"font-mono font-bold text-foreground text-[10px] w-7 text-right",children:H.score})]})]},H.key))}),e.jsx(me,{slot:"student.profile.dimension",slotProps:{student:a,dimensions:g}})]}),e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-3.5 shadow-3xs flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Oa,{size:15,className:"text-amber-500"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:r==="zh"?"AI 导师学情评语与成长潜质":"AI Pedagogical Insights"})]}),e.jsx("p",{className:"text-[11px] text-muted leading-relaxed bg-amber-500/10 p-2.5 rounded-xl border border-amber-500/20 mb-2",children:W})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted pt-1",children:[e.jsxs("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-medium",children:[e.jsx(Ce,{size:12}),e.jsx("span",{children:T})]}),e.jsx("span",{className:"text-primary-theme font-semibold cursor-pointer hover:underline",children:r==="zh"?"历次报告":"History"})]})]}),P&&P.length>0&&e.jsx(To,{progressHistory:P,lang:r,compact:!0}),e.jsx(me,{slot:"student.profile.card",slotProps:{student:a,lessonId:o,classId:d}})]}),e.jsx("div",{className:"md:col-span-7 flex flex-col gap-3",children:e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-4 shadow-3xs flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(De,{size:15,className:"text-primary-theme"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:r==="zh"?"本堂答题与互动轨迹 (Live Timeline)":"Live Interactive Timeline"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-emerald-600 dark:text-emerald-400",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{children:r==="zh"?"实时追踪中":"Tracking"})]})]}),L.length===0&&e.jsx("div",{className:"rounded-xl border border-dashed border-border/60 p-4 text-center text-[11px] text-muted flex-1 flex items-center justify-center",children:r==="zh"?"本节暂无作答或互动记录(尚未参与随堂测 / 投票 / 抢答)。":"No in-class activity recorded for this session yet."}),e.jsxs("div",{className:"space-y-3 relative before:absolute before:inset-0 before:left-3 before:w-0.5 before:bg-border text-xs pl-0.5 flex-1",children:[L.map(H=>e.jsxs("div",{className:"relative flex items-start gap-3 pl-6",children:[e.jsx("span",{className:"absolute left-1.5 top-1 -translate-x-1/2 w-3.5 h-3.5 rounded-full bg-primary-theme text-white flex items-center justify-center text-[8px] ring-4 ring-surface",children:e.jsx(Ce,{size:10})}),e.jsxs("div",{className:"flex-1 bg-surface-secondary/40 rounded-xl p-2.5 border border-border/80 hover:border-primary-theme/40 transition",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono font-bold text-primary-theme text-[10px]",children:H.time}),e.jsx("span",{className:"font-bold text-foreground text-xs",children:H.title})]}),H.points!==void 0&&e.jsxs("span",{className:"text-[10px] font-mono font-bold text-emerald-700 dark:text-emerald-400 bg-emerald-500/10 px-1.5 py-0.2 rounded-md",children:["+",H.points]})]}),e.jsx("p",{className:"text-[11px] text-muted mb-1.5",children:H.description}),H.details&&e.jsx("div",{className:"text-[10px] text-foreground/80 bg-surface p-1.5 rounded-lg border border-border/60",children:H.details}),H.submissionId&&e.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.jsxs("button",{onClick:()=>s?.(a.id,H.submissionId),className:"px-2 py-1 bg-primary-theme text-white rounded-lg text-[10px] font-bold flex items-center gap-1 shadow-3xs cursor-pointer hover:bg-primary-theme/90",children:[e.jsx(nn,{size:11}),e.jsx("span",{children:r==="zh"?"查验代码沙箱":"Inspect Sandbox"})]})})]})]},H.id)),e.jsx(me,{slot:"student.profile.timeline_item",slotProps:{student:a,lessonId:o,classId:d}})]})]})})]})]}):e.jsx("div",{className:"p-4 flex-1 overflow-y-auto bg-surface-secondary/20",children:e.jsx(me,{slot:"student.profile.tab",slotProps:{renderType:"panel",studentActiveTab:N,student:a,lessonId:o,classId:d,lang:r,progressHistory:P}})}),e.jsxs("footer",{className:"px-5 py-3 bg-surface border-t border-border/80 flex flex-wrap items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs text-muted font-medium",children:r==="zh"?"快速表现激励:":"Quick Award:"}),e.jsx("button",{onClick:()=>X(1,r==="zh"?"勇于发言":"Active Speaking"),disabled:m,className:"px-2 py-1 bg-amber-500/10 hover:bg-amber-500/20 text-amber-700 dark:text-amber-300 border border-amber-300/40 rounded-lg text-xs font-semibold flex items-center gap-1 transition cursor-pointer",children:e.jsxs("span",{children:["👏 +1 ",r==="zh"?"发言":"Speaking"]})}),e.jsx("button",{onClick:()=>X(2,r==="zh"?"逻辑清晰":"Logical Thinking"),disabled:m,className:"px-2 py-1 bg-indigo-500/10 hover:bg-indigo-500/20 text-indigo-700 dark:text-indigo-300 border border-indigo-300/40 rounded-lg text-xs font-semibold flex items-center gap-1 transition cursor-pointer",children:e.jsxs("span",{children:["💡 +2 ",r==="zh"?"逻辑":"Logic"]})}),e.jsx("button",{onClick:()=>X(2,r==="zh"?"互助示范":"Peer Assistance"),disabled:m,className:"px-2 py-1 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border border-emerald-300/40 rounded-lg text-xs font-semibold flex items-center gap-1 transition cursor-pointer",children:e.jsxs("span",{children:["🌟 +2 ",r==="zh"?"互助":"Helper"]})}),e.jsx("button",{onClick:()=>X(3,r==="zh"?"创意满分":"Creative Thinking"),disabled:m,className:"px-2 py-1 bg-purple-500/10 hover:bg-purple-500/20 text-purple-700 dark:text-purple-300 border border-purple-300/40 rounded-lg text-xs font-semibold flex items-center gap-1 transition cursor-pointer",children:e.jsxs("span",{children:["🚀 +3 ",r==="zh"?"创意":"Creative"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:K,className:"px-3 py-1.5 border border-border/80 hover:bg-surface-secondary text-foreground rounded-xl text-xs font-medium transition flex items-center gap-1.5 cursor-pointer shadow-3xs",title:r==="zh"?"导出个人 Markdown 学情报告":"Export Report",children:[e.jsx(gs,{size:13}),e.jsx("span",{children:r==="zh"?"导出学情报告":"Export"})]}),e.jsx("button",{onClick:n,className:"px-4 py-1.5 bg-primary-theme hover:bg-primary-theme/90 text-white rounded-xl text-xs font-bold transition shadow-3xs cursor-pointer",children:r==="zh"?"完成并返回":"Done"})]})]})]})})}const Po=[{id:"logic_clarity",dimensionId:"logic_clarity",emoji:"💡",deltaPoints:2,nameZh:"逻辑清晰",nameEn:"Clear Logic",descZh:"算法流程叙述规范",descEn:"Structured algorithm reasoning",borderColor:"border-amber-200 dark:border-amber-700/60",bgLight:"bg-amber-50/80 hover:bg-amber-100/90 dark:bg-amber-950/30 dark:hover:bg-amber-900/40",textColor:"text-amber-700 dark:text-amber-300"},{id:"creative_bonus",dimensionId:"creative_bonus",emoji:"🚀",deltaPoints:3,nameZh:"创意满分",nameEn:"High Creativity",descZh:"方案构思新颖独特",descEn:"Innovative & unique solution",borderColor:"border-indigo-200 dark:border-indigo-700/60",bgLight:"bg-indigo-50/80 hover:bg-indigo-100/90 dark:bg-indigo-950/30 dark:hover:bg-indigo-900/40",textColor:"text-indigo-700 dark:text-indigo-300"},{id:"brave_speech",dimensionId:"brave_speech",emoji:"👏",deltaPoints:1,nameZh:"勇于发言",nameEn:"Active Voice",descZh:"积极参与大胆质疑",descEn:"Constructive question & participation",borderColor:"border-emerald-200 dark:border-emerald-700/60",bgLight:"bg-emerald-50/80 hover:bg-emerald-100/90 dark:bg-emerald-950/30 dark:hover:bg-emerald-900/40",textColor:"text-emerald-700 dark:text-emerald-300"},{id:"peer_help",dimensionId:"peer_help",emoji:"🌟",deltaPoints:2,nameZh:"互助示范",nameEn:"Peer Mentoring",descZh:"协助同伴答疑排错",descEn:"Assisted peer in debugging",borderColor:"border-sky-200 dark:border-sky-700/60",bgLight:"bg-sky-50/80 hover:bg-sky-100/90 dark:bg-sky-950/30 dark:hover:bg-sky-900/40",textColor:"text-sky-700 dark:text-sky-300"}];function _o({isOpen:t,onClose:n,classId:a,lessonId:o,students:d=[],initialStudent:r=null,lang:l="zh",addToast:s,onOpenLeaderboard:h,onOpenStudentSandbox:c,onOpenProfile:u}){const[m,p]=i.useState(null),[w,f]=i.useState(!1),[N,b]=i.useState(null),[$,P]=i.useState({}),[y,k]=i.useState(!1),[g,A]=i.useState(!1);i.useEffect(()=>{if(!t){b(null);return}if(r)p(r);else if(d.length>0){const V=Math.floor(Math.random()*d.length);p(d[V])}},[t,r,d]);const U=i.useCallback(()=>{if(d.length<=1)return;f(!0);let V=0;const le=setInterval(()=>{const F=Math.floor(Math.random()*d.length);p(d[F]),V++,V>=10&&(clearInterval(le),f(!1))},50)},[d]),W=i.useCallback(()=>{if(!m||d.length===0)return;const le=(d.findIndex(F=>F.id===m.id)+1)%d.length;p(d[le]),b(null)},[m,d]),T=async(V,le,F)=>{if(m){k(!0);try{a&&await fetch(`/api/students/${m.id}/points`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({classId:a,dimensionId:V,deltaPoints:le,reason:F,pluginId:"classroom-attribution"})}),P(D=>({...D,[m.id]:(D[m.id]??m.currentPoints??0)+le})),b(`${le>=0?"+":""}${le} ${F}`),setTimeout(()=>b(null),2500),s?.(l==="zh"?"加分成功":"Points Awarded",`${m.name} ${le>=0?"+":""}${le} (${F})`,"success")}catch(D){s?.("Error",D.message||"Failed to award points","error")}finally{k(!1)}}},Q=i.useMemo(()=>m?$[m.id]??m.currentPoints??0:0,[m,$]);return t?e.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-sm animate-in fade-in duration-200",children:[e.jsxs("div",{className:"relative w-full max-w-2xl bg-surface border border-border/80 rounded-2xl shadow-2xl overflow-hidden flex flex-col select-none",children:[e.jsxs("div",{className:"px-5 py-3.5 border-b border-border/60 bg-surface-secondary/40 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-8 h-8 rounded-xl bg-amber-500/10 text-amber-600 dark:text-amber-400 flex items-center justify-center text-base",children:"🎲"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-extrabold text-sm text-foreground",children:l==="zh"?"课堂抽问与表现激励":"Classroom Question & Attribution Points"}),e.jsx("p",{className:"text-[11px] text-muted",children:l==="zh"?"即时评价学生表现,积分同步至小组与大屏勋章榜":"Live reward attribution synced to team leaderboard"})]})]}),e.jsx("button",{onClick:n,"aria-label":"Close",className:"p-1.5 rounded-lg text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:e.jsx(we,{size:18})})]}),e.jsxs("div",{className:"p-5 space-y-4 max-h-[80vh] overflow-y-auto",children:[m?e.jsxs("div",{className:"bg-surface-secondary/60 rounded-xl border border-border/80 p-4 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3.5 min-w-[240px]",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-indigo-500 to-primary-theme p-0.5 shadow-sm",children:e.jsxs("div",{className:"w-full h-full rounded-2xl bg-surface flex flex-col items-center justify-center text-primary-theme font-black",children:[e.jsx("span",{className:"text-[10px] leading-none text-muted font-mono",children:m.seatNumber||"—"}),e.jsx("span",{className:"text-base leading-none font-extrabold mt-0.5",children:m.studentNo?.slice(-2)||"—"})]})})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-base font-extrabold text-foreground",children:m.name}),m.studentNo&&e.jsxs("span",{className:"text-[11px] text-muted font-mono",children:["(",m.studentNo,")"]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 text-[10px] font-bold",children:m.groupName||(l==="zh"?"未分组":"Ungrouped")})]}),e.jsxs("div",{className:"flex items-center gap-2.5 text-xs",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 font-semibold text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-300/40 px-2 py-0.5 rounded-md",children:[e.jsx(bt,{size:12,className:"text-amber-500"}),e.jsxs("span",{children:[l==="zh"?"当前积分":"Points",": ",e.jsxs("strong",{children:[Q,"分"]})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 font-medium text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-300/40 px-2 py-0.5 rounded-md",children:[e.jsx(tr,{size:12,className:"text-emerald-500"}),e.jsxs("span",{children:[l==="zh"?"专注度":"Focus",":"," ",e.jsx("strong",{children:typeof m.focusScore=="number"?`${m.focusScore}%`:"—"})]})]}),e.jsx("span",{className:"text-muted text-[11px]",children:l==="zh"?`今日抽中 ${m.pickedCountToday??0} 次`:`Picked ${m.pickedCountToday??0}x`})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{u&&m?u(m):A(!0)},className:"px-3 py-2 bg-indigo-50 hover:bg-indigo-100 dark:bg-indigo-950/40 dark:hover:bg-indigo-900/50 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-800 rounded-xl text-xs font-semibold transition flex items-center gap-1.5 cursor-pointer shadow-3xs",title:l==="zh"?"查看学生五维成长雷达与学情档案":"View Growth Profile",children:[e.jsx(Oe,{size:14,className:"text-indigo-600 dark:text-indigo-400"}),e.jsx("span",{children:l==="zh"?"学情档案":"Profile"})]}),e.jsxs("button",{onClick:U,disabled:w,className:"px-3.5 py-2 bg-primary-theme hover:bg-primary-theme/90 active:scale-95 text-white rounded-xl text-xs font-bold shadow-xs transition flex items-center gap-1.5 cursor-pointer disabled:opacity-50",children:[e.jsx(an,{size:14,className:w?"animate-spin":""}),e.jsx("span",{children:l==="zh"?"重新抽取":"Shuffle"})]}),e.jsxs("button",{onClick:W,className:"px-3 py-2 bg-surface hover:bg-surface-secondary text-foreground border border-border rounded-xl text-xs font-semibold transition flex items-center gap-1 cursor-pointer",title:l==="zh"?"轮候下一位学生":"Next Student",children:[e.jsx("span",{children:l==="zh"?"下一位":"Next"}),e.jsx(ms,{size:14})]})]})]}):e.jsx("div",{className:"text-center py-6 text-muted text-xs",children:l==="zh"?"当前班级暂无学生":"No students found in current class"}),N&&e.jsxs("div",{className:"p-2.5 rounded-xl bg-amber-500/15 border border-amber-400/50 text-amber-700 dark:text-amber-300 flex items-center justify-between text-xs font-bold animate-in fade-in slide-in-from-top-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{size:16,className:"text-amber-500 animate-bounce"}),e.jsx("span",{children:N})]}),e.jsx("span",{className:"text-[10px] text-amber-600 dark:text-amber-400 font-normal",children:l==="zh"?"已实时累加":"Awarded live"})]}),e.jsxs("div",{className:"bg-surface rounded-xl border border-border/80 p-4 shadow-3xs",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(on,{size:14,className:"text-amber-500"}),e.jsx("span",{className:"text-xs font-bold text-foreground",children:l==="zh"?"课堂即时表现评价与加分":"Classroom Attribution Awards"}),e.jsx("span",{className:"text-[11px] text-muted",children:l==="zh"?"(自动累加至小组成绩)":"(Aggregated to group)"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted text-[11px]",children:l==="zh"?"快速微调:":"Adjust:"}),[{label:"+1",delta:1},{label:"+2",delta:2},{label:"-1",delta:-1}].map(V=>e.jsx("button",{onClick:()=>T("micro_adjust",V.delta,l==="zh"?`课堂即时微调 ${V.label}`:`Micro adjustment ${V.label}`),disabled:y||!m,className:"px-2 py-0.5 rounded bg-surface-secondary hover:bg-primary-theme/10 hover:text-primary-theme text-foreground font-mono font-bold text-xs border border-border/80 transition cursor-pointer disabled:opacity-50",children:V.label},V.label))]})]}),e.jsx(me,{slot:"anchor:classroom-attribution:awards",placement:"before",slotProps:{student:m,classId:a,lessonId:o,onAwardPoints:T}}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5",children:Po.map(V=>e.jsxs("button",{onClick:()=>T(V.dimensionId,V.deltaPoints,l==="zh"?`${V.nameZh}:${V.descZh}`:`${V.nameEn}: ${V.descEn}`),disabled:y||!m,className:`group p-2.5 rounded-xl border ${V.borderColor} ${V.bgLight} text-left transition relative flex flex-col justify-between shadow-3xs cursor-pointer active:scale-95 disabled:opacity-50`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-lg",children:V.emoji}),e.jsxs("span",{className:`text-xs font-extrabold ${V.textColor} font-mono bg-surface px-1.5 py-0.2 rounded border border-border shadow-3xs`,children:["+",V.deltaPoints]})]}),e.jsx("div",{className:"font-bold text-xs text-foreground group-hover:text-primary-theme",children:l==="zh"?V.nameZh:V.nameEn}),e.jsx("div",{className:"text-[10px] text-muted line-clamp-1",children:l==="zh"?V.descZh:V.descEn})]},V.id))}),e.jsx(me,{slot:"classroom.attribution.award",slotProps:{student:m,classId:a,lessonId:o,onAwardPoints:T}}),e.jsx(me,{slot:"anchor:classroom-attribution:awards",placement:"after",slotProps:{student:m,classId:a,lessonId:o,onAwardPoints:T}})]})]}),e.jsxs("div",{className:"p-4 border-t border-border/60 bg-surface-secondary/30 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h&&e.jsxs("button",{onClick:()=>{n(),h()},className:"px-3.5 py-1.5 rounded-lg border border-border text-foreground hover:bg-surface-secondary font-semibold text-xs transition flex items-center gap-1.5 cursor-pointer",children:[e.jsx(bt,{size:13,className:"text-amber-500"}),e.jsx("span",{children:l==="zh"?"全班积分榜 & 批量加分":"Class Leaderboard"})]}),c&&m&&e.jsxs("button",{onClick:()=>c(m),className:"px-3 py-1.5 rounded-lg border border-border text-muted hover:text-foreground hover:bg-surface-secondary text-xs transition flex items-center gap-1.5 cursor-pointer",children:[e.jsx(nn,{size:13}),e.jsx("span",{children:l==="zh"?"查验代码沙箱":"Inspect Code Sandbox"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{slot:"classroom.attribution.action",slotProps:{student:m,classId:a,lessonId:o,currentPoints:Q}}),e.jsx("button",{onClick:n,className:"px-4 py-1.5 bg-primary-theme hover:bg-primary-theme/90 text-white rounded-lg text-xs font-bold transition shadow-xs cursor-pointer",children:l==="zh"?"完成":"Done"})]})]})]}),m&&e.jsx(xr,{isOpen:g,onClose:()=>A(!1),student:{id:m.id,name:m.name,student_number:m.studentNo,role:void 0,group_name:m.groupName,points:Q,focusPercentage:m.focusScore,competencyScores:m.competencyScores},lessonId:o,classId:a,lang:l,addToast:s,onInspectSandbox:()=>c?.(m),onAwardPoints:(V,le,F)=>T("attribution",le,F||"课堂表现")})]}):null}function Ro({isOpen:t,onClose:n,classId:a,lessonId:o,students:d=[],lang:r="zh",addToast:l,onSelectStudentToAward:s,onViewStudentProfile:h}){const[c,u]=i.useState("groups"),[m,p]=i.useState("group-1"),[w,f]=i.useState(null),[N,b]=i.useState(null),[$,P]=i.useState([]),[y,k]=i.useState(!1),g=i.useRef(null),A=i.useCallback(async()=>{if(!a){P([]),g.current=null;return}k(!0);try{const F=await fetch(`/api/classes/${encodeURIComponent(a)}/groups`);if(!F.ok)throw new Error("Failed to load class groups");const D=await F.json();P(Array.isArray(D)?D:[]),g.current=a}catch(F){console.warn("[ClassroomLeaderboardModal] load class groups failed:",F),P([])}finally{k(!1)}},[a]);i.useEffect(()=>{t&&A()},[t,A]),i.useEffect(()=>{if(!t||!a)return;let F=null;const D=Wt(j=>{const q=ee=>{!ee||ee.classId!==a||A()};F?.(),j.on("classroom:groups_changed",q),F=()=>j.off("classroom:groups_changed",q)});return()=>{D(),F?.()}},[t,a,A]);const U=i.useMemo(()=>{if($.length===0)return[];const F=new Map(d.map(D=>[D.id,D]));return $.map(D=>{const j=(D.memberIds??[]).map(ee=>F.get(ee)).filter(Boolean),q=j.reduce((ee,R)=>ee+(R.currentPoints??0),0);return{id:D.id,name:(r==="en"&&D.name_en?.trim()?D.name_en:D.name)||D.id,totalScore:q,rank:0,members:j,growthScore:void 0,color:D.color??void 0,leaderId:D.leader_id??null}}).sort((D,j)=>j.totalScore-D.totalScore).map((D,j)=>({...D,rank:j+1}))},[$,d,r]),W=i.useMemo(()=>{const F=new Map;for(const D of $){const j=(r==="en"&&D.name_en?.trim()?D.name_en:D.name)||D.id;for(const q of D.memberIds??[])F.set(q,j)}return F},[$,r]),T=i.useCallback(F=>W.get(F)||(r==="zh"?"未分组":"Ungrouped"),[W,r]),[Q,V]=i.useState(null),le=async(F,D,j,q)=>{if(!a||Q)return;const R=(U.find(X=>X.id===F)?.members??[]).filter(X=>X.id);if(R.length===0){l?.(r==="zh"?"该小组没有成员":"Group has no members",D,"warning");return}V(F),f(`${D} 全员 +${j} (${q})`),setTimeout(()=>f(null),3e3);let O=0,L=0;for(const X of R)try{(await fetch(`/api/students/${X.id}/points`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({classId:a,dimensionId:"creative_bonus",deltaPoints:j,reason:`${q}(${D} 整组)`,pluginId:"classroom-leaderboard"})})).ok?O+=1:L+=1}catch{L+=1}l?.(r==="zh"?"小组集体加分":"Team Points Awarded",r==="zh"?`${D}:成功 ${O} 人${L>0?`,失败 ${L} 人`:""}`:`${D}: ${O} ok${L>0?`, ${L} failed`:""}`,L===0?"success":"warning"),V(null)};return t?e.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-sm animate-in fade-in duration-200",children:[e.jsxs("div",{className:"relative w-full max-w-3xl bg-surface border border-border/80 rounded-2xl shadow-2xl overflow-hidden flex flex-col select-none max-h-[85vh]",children:[e.jsxs("div",{className:"px-5 py-3.5 border-b border-border/60 bg-surface-secondary/40 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"w-8 h-8 rounded-xl bg-amber-500/10 text-amber-600 dark:text-amber-400 flex items-center justify-center text-base",children:"🏆"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-extrabold text-sm text-foreground",children:r==="zh"?"全班积分榜与小组积分明细":"Class Points & Team Leaderboard"}),e.jsx("p",{className:"text-[11px] text-muted",children:r==="zh"?"随堂表现实时积分累加,激发小组合作共进":"Live classroom performance points & teamwork league"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center p-0.5 rounded-lg bg-surface border border-border text-xs",children:[e.jsx("button",{onClick:()=>u("groups"),className:`px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${c==="groups"?"bg-primary-theme text-white shadow-3xs":"text-muted hover:text-foreground"}`,children:r==="zh"?"小组联赛":"Teams"}),e.jsx("button",{onClick:()=>u("individual"),className:`px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${c==="individual"?"bg-primary-theme text-white shadow-3xs":"text-muted hover:text-foreground"}`,children:r==="zh"?"个人英雄榜":"Individual"})]}),e.jsx("button",{onClick:n,"aria-label":"Close",className:"p-1.5 rounded-lg text-muted hover:text-foreground hover:bg-surface-secondary transition-colors cursor-pointer",children:e.jsx(we,{size:18})})]})]}),w&&e.jsxs("div",{className:"mx-5 mt-4 p-2.5 rounded-xl bg-amber-500/15 border border-amber-400/50 text-amber-700 dark:text-amber-300 flex items-center justify-between text-xs font-bold animate-in fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{size:16,className:"text-amber-500 animate-bounce"}),e.jsx("span",{children:w})]}),e.jsx("span",{className:"text-[10px] text-amber-600 dark:text-amber-400",children:r==="zh"?"大屏同步广播":"Synced to Stage"})]}),e.jsx("div",{className:"p-5 space-y-3.5 overflow-y-auto flex-1",children:c==="groups"?e.jsxs("div",{className:"space-y-3",children:[U.map(F=>{const D=m===F.id,j=F.rank===1?"bg-amber-700 text-white":F.rank===2?"bg-slate-400 text-white":F.rank===3?"bg-amber-700/80 text-white":"bg-surface-secondary text-muted";return e.jsxs("div",{className:"border border-border/80 rounded-xl bg-surface-secondary/20 overflow-hidden shadow-3xs transition-all",children:[e.jsxs("div",{className:"p-3.5 flex flex-wrap items-center justify-between gap-3 bg-surface hover:bg-surface-secondary/30 transition",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`w-6 h-6 rounded-lg ${j} font-mono font-extrabold text-xs flex items-center justify-center`,children:F.rank}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-extrabold text-sm text-foreground",children:F.name}),e.jsx("span",{className:"text-[11px] font-mono text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 px-1.5 py-0.2 rounded font-bold",children:typeof F.growthScore=="number"?r==="zh"?`本节 +${F.growthScore}`:`+${F.growthScore}`:""})]}),e.jsx("span",{className:"text-[11px] text-muted",children:r==="zh"?`组内成员 ${F.members.length} 人 · 均分 ${Math.round(F.totalScore/F.members.length)} 分`:`${F.members.length} members`})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:"font-mono text-base font-extrabold text-primary-theme pr-2",children:[F.totalScore,e.jsx("span",{className:"text-xs font-normal text-muted ml-0.5",children:r==="zh"?"分":"pts"})]}),e.jsxs("button",{onClick:()=>le(F.id,F.name,2,r==="zh"?"团队协作之星:组内积极帮扶答疑":"Team Collaboration Star"),className:"px-2.5 py-1 rounded-lg bg-indigo-500/10 hover:bg-indigo-500/20 text-indigo-600 dark:text-indigo-400 border border-indigo-200 dark:border-indigo-800 text-xs font-semibold flex items-center gap-1 transition cursor-pointer",title:r==="zh"?"整组每人 +2 协作分":"Whole group +2 Collaboration points",children:[e.jsx(Js,{size:12}),e.jsxs("span",{children:["+2 ",r==="zh"?"协作":"Collab"]})]}),e.jsxs("button",{onClick:()=>le(F.id,F.name,1,r==="zh"?"全员全勤奖:按时到齐投入学习":"Perfect Attendance Award"),className:"px-2.5 py-1 rounded-lg bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800 text-xs font-semibold flex items-center gap-1 transition cursor-pointer",title:r==="zh"?"整组每人 +1 全勤分":"Whole group +1 Attendance points",children:[e.jsx(on,{size:12}),e.jsxs("span",{children:["+1 ",r==="zh"?"全勤":"Attendance"]})]}),e.jsx("button",{onClick:()=>p(D?null:F.id),className:"p-1 rounded-lg text-muted hover:text-foreground hover:bg-surface-secondary transition cursor-pointer",children:D?e.jsx(Xs,{size:16}):e.jsx(Ut,{size:16})})]})]}),D&&e.jsx("div",{className:"px-4 py-2.5 bg-surface-secondary/40 border-t border-border/60 space-y-1.5 animate-in slide-in-from-top-1 duration-150",children:F.members.map(q=>e.jsxs("div",{className:"p-2 rounded-lg bg-surface border border-border/60 flex items-center justify-between text-xs hover:border-primary-theme/40 transition",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"w-5 h-5 rounded-md bg-surface-secondary text-muted font-mono font-bold text-[10px] flex items-center justify-center",children:q.seatNumber?.slice(-2)||"01"}),e.jsx("span",{className:"font-bold text-foreground",children:q.name}),e.jsx("span",{className:"text-[11px] text-muted font-mono",children:q.studentNo})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-mono font-bold text-foreground",children:[q.currentPoints??28," ",e.jsx("span",{className:"text-[10px] text-muted",children:"分"})]}),e.jsxs("button",{onClick:()=>{h?h(q):b(q)},className:"px-2 py-0.5 rounded bg-surface-secondary hover:bg-surface text-foreground font-semibold text-[11px] transition border border-border cursor-pointer flex items-center gap-0.5",title:r==="zh"?"查看学情档案":"View Profile",children:[e.jsx(Oe,{size:11,className:"text-primary-theme"}),e.jsx("span",{children:r==="zh"?"档案":"Profile"})]}),s&&e.jsx("button",{onClick:()=>{n(),s(q)},className:"px-2 py-0.5 rounded bg-primary-theme/10 hover:bg-primary-theme/20 text-primary-theme font-semibold text-[11px] transition cursor-pointer",children:r==="zh"?"单人评价":"Award"})]})]},q.id))})]},F.id)}),U.length===0&&e.jsx("div",{className:"py-10 px-4 text-center",children:y?e.jsx("p",{className:"text-xs text-muted animate-pulse",children:r==="zh"?"正在加载分组方案…":"Loading group plans…"}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted font-semibold",children:r==="zh"?"本班尚未配置分组方案":"No group plan configured for this class"}),e.jsx("p",{className:"text-2xs text-muted/80 mt-1",children:r==="zh"?"可在「班级分组」中创建分组后在此查看小组联赛":"Create groups under Class Groups to see the team league here"})]})})]}):e.jsx("div",{className:"space-y-1.5",children:[...d].sort((F,D)=>(D.currentPoints??0)-(F.currentPoints??0)).map((F,D)=>e.jsxs("div",{className:"p-3 rounded-xl border border-border/80 bg-surface flex items-center justify-between text-xs hover:bg-surface-secondary/30 transition shadow-3xs",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`w-6 h-6 rounded-lg font-mono font-bold text-xs flex items-center justify-center ${D===0?"bg-amber-700 text-white":D===1?"bg-slate-400 text-white":D===2?"bg-amber-700/80 text-white":"bg-surface-secondary text-muted"}`,children:D+1}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-extrabold text-foreground",children:F.name}),e.jsx("span",{className:"px-1.5 py-0.2 rounded-full bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 text-[10px] font-bold",children:T(F.id)})]}),e.jsx("span",{className:"text-[11px] text-muted font-mono",children:F.studentNo})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-semibold text-[11px]",children:[e.jsx(tr,{size:12}),e.jsx("span",{children:typeof F.focusScore=="number"?`${F.focusScore}%`:"—"})]}),e.jsxs("span",{className:"font-mono font-extrabold text-sm text-primary-theme",children:[F.currentPoints??0," ",e.jsx("span",{className:"text-xs font-normal text-muted",children:"分"})]}),e.jsxs("button",{onClick:()=>{h?h(F):b(F)},className:"px-2.5 py-1 rounded-lg bg-surface-secondary hover:bg-surface text-foreground font-semibold text-xs transition border border-border cursor-pointer flex items-center gap-1 shadow-3xs",title:r==="zh"?"查看学情成长雷达档案":"View Growth Profile",children:[e.jsx(Oe,{size:12,className:"text-primary-theme"}),e.jsx("span",{children:r==="zh"?"档案":"Profile"})]}),s&&e.jsx("button",{onClick:()=>{n(),s(F)},className:"px-2.5 py-1 rounded-lg bg-primary-theme/10 hover:bg-primary-theme/20 text-primary-theme font-bold text-xs transition cursor-pointer",children:r==="zh"?"加分":"Award"})]})]},F.id))})}),e.jsx("div",{className:"p-4 border-t border-border/60 bg-surface-secondary/30 flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{slot:"classroom.leaderboard.action",slotProps:{classId:a,lessonId:o,groups:U}}),e.jsx("button",{onClick:n,className:"px-4 py-1.5 border border-border text-foreground hover:bg-surface-secondary rounded-lg text-xs font-semibold transition cursor-pointer",children:r==="zh"?"关闭":"Close"})]})})]}),N&&e.jsx(xr,{isOpen:!!N,onClose:()=>b(null),student:{id:N.id,name:N.name,student_number:N.studentNo,group_name:T(N.id),points:N.currentPoints,focusPercentage:N.focusScore},lessonId:o,classId:a,lang:r,addToast:l})]}):null}const Sn={PRE_CLASS_READY:["IN_CLASS_TEACHING"],IN_CLASS_TEACHING:["WRAP_UP_EXIT_TICKET"],WRAP_UP_EXIT_TICKET:["IN_CLASS_TEACHING","ARCHIVED_REPORT"],ARCHIVED_REPORT:["IN_CLASS_TEACHING","PRE_CLASS_READY"]};function Io(t,n){return t===n?!0:(Sn[t]||[]).includes(n)}function Vr(t,n,a="zh"){return t===n?null:t==="IN_CLASS_TEACHING"&&n==="PRE_CLASS_READY"?a==="zh"?"课堂正在授课中,无法直接退回课前;如需下课请推进至「结课通票」":"Cannot return to pre-class during active teaching. Proceed to Exit Ticket to conclude.":t==="PRE_CLASS_READY"&&(n==="WRAP_UP_EXIT_TICKET"||n==="ARCHIVED_REPORT")?a==="zh"?"课堂尚未开始,请先点击「课中授课」开课":"Class has not started. Please start teaching first.":t==="IN_CLASS_TEACHING"&&n==="ARCHIVED_REPORT"?a==="zh"?"请先推进至「结课通票」完成学生作答小结,再生成学情简报":"Please conclude via Exit Ticket before generating the final report.":(Sn[t]||[]).includes(n)?null:a==="zh"?"当前教学环节不允许直接切换至该阶段":"Direct transition to this stage is not allowed."}function Lo({lessonId:t,lessonTitle:n,classId:a,lang:o="zh",addToast:d,currentStage:r,onStageChange:l,students:s=[]}){const[h,c]=i.useState("IN_CLASS_TEACHING"),u=r!==void 0?r:h,m=z=>{c(z),l?.(z)},[p,w]=i.useState(!1),{fallbackOpen:f,blocked:N,openStageWindow:b,closeFallback:$,clearBlockedHint:P}=$o(),y=()=>{b({lessonId:t||"",lessonTitle:n,lang:o==="zh"?"zh":"en"})},[k,g]=i.useState(!1),[A,U]=i.useState(!1),[W,T]=i.useState(!1),[Q,V]=i.useState("课堂极速单选投票"),[le,F]=i.useState("ABCD"),[D,j]=i.useState(["A","B","C","D"]),[q,ee]=i.useState(""),[R,O]=i.useState([]),[L,X]=i.useState(!1),[K,H]=i.useState(null),[re,te]=i.useState(null),[de,G]=i.useState({TOO_FAST:0,SLOW:0,CONFUSED:0,CLEAR:0}),[S,M]=i.useState(null),[I,B]=i.useState({}),[se,v]=i.useState(!1),[_,Z]=i.useState(null),[ie,xe]=i.useState(!1),[he,ke]=i.useState(0);i.useEffect(()=>{if(!t)return;let z=!0,ce=0;const fe=async()=>{const be=++ce;try{const Le=await fetch(`/api/classroom/sessions/${t}`);if(Le.ok&&z&&be===ce){const ye=await Le.json();ye.hasActiveSession&&(ye.stage&&m(ye.stage),ye.session?.current_segment_id&&M(ye.session.current_segment_id)),H(ye.activePoll||null),te(ye.activeBuzzer||null)}const Fe=await fetch(`/api/classroom/stage/${t}/data`);if(Fe.ok&&z&&be===ce){const ye=await Fe.json();G(ye.pacing||{TOO_FAST:0,SLOW:0,CONFUSED:0,CLEAR:0}),typeof ye.attendance?.online=="number"&&ke(ye.attendance.online)}}catch{}};fe();const ue=setInterval(fe,3e3);return()=>{z=!1,clearInterval(ue)}},[t]),i.useEffect(()=>{t&&fetch(`/api/lessons/${t}`).then(z=>z.ok?z.json():null).then(z=>{if(z?.timeline)try{const ce=typeof z.timeline=="string"?JSON.parse(z.timeline):z.timeline;if(Array.isArray(ce)){const fe={};ce.forEach(ue=>{ue?.id&&ue?.title&&(fe[ue.id]=ue.title)}),B(fe)}}catch{}}).catch(()=>{})},[t]),i.useEffect(()=>{const z=ps();if(!z||!t)return;const ce=ue=>{ue?.lessonId===t&&ue?.summary&&(G(ue.summary),ue?.segmentId&&M(ue.segmentId))},fe=ue=>{ue?.lessonId===t&&ue?.activeSegmentId&&M(ue.activeSegmentId)};return z.on("classroom:pacing_updated",ce),z.on("student-active-segment-changed",fe),()=>{typeof z.off=="function"&&(z.off("classroom:pacing_updated",ce),z.off("student-active-segment-changed",fe))}},[t]);const ze=i.useCallback(async()=>{if(t){X(!0);try{const z=await fetch(`/api/lessons/${t}/preset-polls`);if(z.ok){const ce=await z.json();O(ce.presets||[])}}catch{}finally{X(!1)}}},[t]);if(i.useEffect(()=>{W&&ze()},[W,ze]),!t)return null;const ge=async z=>{if(z===u)return;const ce=Vr(u,z,o);if(ce){d(o==="zh"?"阶段切换被拦截":"Stage Transition Blocked",ce,"warning");return}try{const fe=await fetch(`/api/classroom/sessions/${t}/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stage:z,classId:a})});if(fe.ok){if(m(z),d(o==="zh"?"课堂阶段已切换":"Classroom Stage Updated",o==="zh"?`当前进入阶段:${z}`:`Current stage: ${z}`,"success"),z==="ARCHIVED_REPORT"){const ue=await fetch(`/api/classroom/sessions/${t}/panoramic-report`);if(ue.ok){const be=await ue.json();Z(be),xe(!0)}}}else{const be=(await fe.json().catch(()=>({}))).error||"";let Le=be;be.includes("IN_CLASS_TEACHING -> PRE_CLASS_READY")?Le=o==="zh"?"课堂正在授课中,无法直接退回课前;如需下课请推进至「结课通票」":"Cannot return to pre-class during active teaching.":be.startsWith("Illegal transition")&&(Le=o==="zh"?"当前环节不允许此阶段流转,请按教学步骤推进":be),d(o==="zh"?"阶段切换被拦截":"Stage Transition Blocked",Le||"Check guards","warning")}}catch(fe){d("Error",fe.message,"error")}},Ae=z=>{F(z),z==="ABCD"?j(["A","B","C","D"]):z==="TF"&&j(["正确","错误"]),ee("")},_e=async()=>{if(!t||!Q.trim()){d(o==="zh"?"保存失败":"Save Failed",o==="zh"?"题目标题不能为空":"Title required","warning");return}try{(await fetch(`/api/lessons/${t}/preset-polls`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:Q,questionType:le,options:D,correctOption:q||null})})).ok&&(d(o==="zh"?"已保存":"Saved",o==="zh"?"题目已保存到本课程题库":"Preset saved","success"),ze())}catch(z){d("Error",z.message,"error")}},Be=async z=>{if(t)try{await fetch(`/api/lessons/${t}/preset-polls/${z}`,{method:"DELETE"}),O(ce=>ce.filter(fe=>fe.id!==z))}catch(ce){d("Error",ce.message,"error")}},Mt=z=>{V(z.title),F(z.questionType),j([...z.options]),ee(z.correctOption||"")},at=async(z,ce,fe,ue)=>{try{const be=z||Q,Le=ce||le,Fe=fe||D,ye=ue!==void 0?ue:q||null,Xt=await fetch(`/api/classroom/sessions/${t}/quick-poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:be,questionType:Le,options:Fe,correctOption:ye})});if(Xt.ok){const ws=await Xt.json();H(ws.poll),T(!1),d(o==="zh"?"极速投票已启动":"Quick Poll Launched",o==="zh"?"学生端已弹出作答卡,大屏展台同步更新":"Poll active for students","success")}}catch(be){d("Error",be.message,"error")}},tt=async()=>{if(K)try{await fetch(`/api/classroom/sessions/${t}/quick-poll/${K.id}/close`,{method:"POST"}),H(null),d(o==="zh"?"投票已结束":"Poll Closed",o==="zh"?"已汇总全班作答结果":"Results aggregated","info")}catch(z){d("Error",z.message,"error")}},Ge=async()=>{try{const z=await fetch(`/api/classroom/sessions/${t}/buzzer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"全班极速抢答"})});if(z.ok){const ce=await z.json();te(ce.buzzer),d(o==="zh"?"抢答器已激活":"Buzzer Ready",o==="zh"?"学生端已出现红色抢答按钮":"Students can buzz now","success")}}catch(z){d("Error",z.message,"error")}},Nt=async()=>{if(re)try{await fetch(`/api/classroom/sessions/${t}/buzzer/${re.id}/reset`,{method:"POST"}),te(z=>z?{...z,status:"READY",winner_student_id:null}:null),d(o==="zh"?"抢答已重置":"Buzzer Reset","","info")}catch(z){d("Error",z.message,"error")}},J=[{id:"PRE_CLASS_READY",labelZh:"课前就绪",labelEn:"Pre-Class"},{id:"IN_CLASS_TEACHING",labelZh:"课中授课",labelEn:"Teaching"},{id:"WRAP_UP_EXIT_TICKET",labelZh:"结课通票",labelEn:"Exit Ticket"},{id:"ARCHIVED_REPORT",labelZh:"学情简报",labelEn:"Report"}];return e.jsxs(e.Fragment,{children:[e.jsx(me,{slot:"classroom.alert.banner",slotProps:{classId:a,lessonId:t,currentStage:u}}),e.jsxs("div",{id:"classroom-interactive-cockpit",className:"bg-surface border-b border-border/80 px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 select-none text-xs transition-colors",children:[e.jsx("div",{className:"flex items-center gap-1.5 bg-surface-secondary/70 p-1 rounded-xl border border-border/60 shadow-3xs",children:J.map((z,ce)=>{const fe=u===z.id,ue=fe||Io(u,z.id),be=Vr(u,z.id,o),Le=fe?o==="zh"?"当前处于此阶段":"Current stage":ue?o==="zh"?`点击切换至 ${z.labelZh}`:`Switch to ${z.labelEn}`:be||(o==="zh"?"当前环节不可直接切换":"Not available directly");return e.jsxs("button",{disabled:!ue,"aria-disabled":!ue,title:Le,onClick:()=>ge(z.id),className:`px-3 py-1.5 rounded-lg font-bold flex items-center gap-1.5 transition-all ${fe?"bg-primary-solid text-white shadow-sm ring-2 ring-primary-theme/20 cursor-default":ue?"text-muted hover:text-foreground hover:bg-surface cursor-pointer":"opacity-40 text-muted/60 cursor-not-allowed hover:bg-transparent"}`,children:[e.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[10px] ${fe?"bg-white/20":ue?"bg-foreground/10":"bg-muted/20"}`,children:ce+1}),e.jsx("span",{children:o==="zh"?z.labelZh:z.labelEn})]},z.id)})}),e.jsxs("div",{className:"flex items-center gap-2",children:[K&&K.status==="ACTIVE"?e.jsxs("button",{onClick:tt,className:"px-3 py-1.5 bg-amber-700 text-white font-bold rounded-lg hover:bg-amber-800 transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer animate-pulse",children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:o==="zh"?`结束投票 (${K.totalVotes||0}人)`:`Close Poll (${K.totalVotes||0})`})]}):e.jsxs("button",{onClick:()=>T(!0),className:"px-3 py-1.5 bg-surface-secondary hover:bg-surface border border-border/80 text-foreground font-semibold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",children:[e.jsx(ve,{size:13,className:"text-amber-700 dark:text-amber-400"}),e.jsx("span",{children:o==="zh"?"极速投票":"Quick Poll"})]}),re?e.jsxs("button",{onClick:Nt,className:"px-3 py-1.5 bg-rose-600 text-white font-bold rounded-lg hover:bg-rose-700 transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",children:[e.jsx(Jt,{size:13}),e.jsx("span",{children:o==="zh"?"重置抢答":"Reset Buzzer"})]}):e.jsxs("button",{onClick:Ge,className:"px-3 py-1.5 bg-surface-secondary hover:bg-surface border border-border/80 text-foreground font-semibold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",children:[e.jsx(ln,{size:13,className:"text-rose-700 dark:text-rose-400"}),e.jsx("span",{children:o==="zh"?"发起抢答":"Start Buzzer"})]}),e.jsxs("button",{onClick:()=>ge("WRAP_UP_EXIT_TICKET"),className:"px-3 py-1.5 bg-surface-secondary hover:bg-surface border border-border/80 text-foreground font-semibold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",title:"发起 60 秒下课通票",children:[e.jsx(Ce,{size:13,className:"text-indigo-500"}),e.jsx("span",{children:o==="zh"?"60s 通票":"Exit Ticket"})]}),e.jsxs("button",{onClick:y,className:"px-3 py-1.5 bg-blue-50 hover:bg-blue-100 dark:bg-blue-950/40 dark:hover:bg-blue-900/50 border border-blue-200 dark:border-blue-800 text-blue-700 dark:text-blue-300 font-bold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",title:o==="zh"?"新开窗口投放大屏展台到副屏/投影,授课界面留在当前窗口":"Open the stage display in a new window for a second screen",children:[e.jsx(rn,{size:13,className:"text-blue-500"}),e.jsx("span",{children:o==="zh"?"打开大屏展台":"Stage Display"})]}),e.jsxs("button",{onClick:()=>g(!0),className:"px-3 py-1.5 bg-indigo-50 hover:bg-indigo-100 dark:bg-indigo-950/40 dark:hover:bg-indigo-900/50 border border-indigo-200 dark:border-indigo-800 text-indigo-700 dark:text-indigo-300 font-bold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",title:o==="zh"?"随机抽问与归因表现激励":"Random Pick & Attribution Points",children:[e.jsx(Da,{size:13,className:"text-indigo-500"}),e.jsx("span",{children:o==="zh"?"随机抽问":"Roll Call"})]}),e.jsxs("button",{onClick:()=>U(!0),className:"px-3 py-1.5 bg-amber-50 hover:bg-amber-100 dark:bg-amber-950/40 dark:hover:bg-amber-900/50 border border-amber-200 dark:border-amber-800 text-amber-700 dark:text-amber-300 font-bold rounded-lg transition-colors flex items-center gap-1.5 shadow-3xs cursor-pointer",title:o==="zh"?"全班积分榜与小组联赛":"Class Points & Team Leaderboard",children:[e.jsx(bt,{size:13,className:"text-amber-700 dark:text-amber-400"}),e.jsx("span",{children:o==="zh"?"积分榜":"Leaderboard"})]}),e.jsx(me,{slot:"classroom.quick_activity",slotProps:{lessonId:t,classId:a,stage:u}}),e.jsx(me,{slot:"classroom.cockpit.drawer.item",slotProps:{lessonId:t,classId:a,stage:u}}),e.jsx(me,{slot:"classroom.topbar.action",slotProps:{lessonId:t,classId:a,stage:u}}),e.jsx(me,{slot:"classroom.topbar.pill",slotProps:{lessonId:t,classId:a,stage:u}})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-2 border-l border-border/60",children:[e.jsx(me,{slot:"classroom.header.action",slotProps:{lessonId:t,classId:a,stage:u}}),e.jsxs("button",{onClick:()=>v(!0),className:"flex items-center gap-1.5 px-2 py-1 rounded-xl hover:bg-surface-secondary transition-colors cursor-pointer group",title:o==="zh"?"打开课堂反馈情绪仪表盘":"Open feedback dashboard",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-muted group-hover:text-main",children:[e.jsx(Oe,{size:12,className:"text-primary-ink"}),e.jsx("span",{children:o==="zh"?"节奏晴雨表:":"Barometer:"}),S&&I[S]&&e.jsxs("span",{className:"text-[10px] text-primary-ink font-medium truncate max-w-[90px]",children:["[",I[S],"]"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 font-bold text-[10px]",title:"理解 / 节奏适宜",children:["💡 ",de.CLEAR||0]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-700 dark:text-amber-400 font-bold text-[10px]",title:"困惑",children:["❓ ",de.CONFUSED||0]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-rose-500/10 text-rose-700 dark:text-rose-400 font-bold text-[10px]",title:"慢一点(讲太快)",children:["🐇 ",de.TOO_FAST||0]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 font-bold text-[10px]",title:"快一点(讲太慢)",children:["🐢 ",de.SLOW||0]})]})]})]}),se&&t&&e.jsx(Eo,{lessonId:t,lang:o==="zh"?"zh":"en",signals:de,onlineCount:he,onClose:()=>v(!1),activeSegmentTitle:S?I[S]:null}),e.jsx(So,{isOpen:p||f,onClose:()=>{w(!1),$(),P()},lessonId:t,lessonTitle:n,lang:o}),N&&e.jsxs("div",{"data-testid":"stage-window-blocked-hint",className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[10001] px-4 py-3 rounded-xl bg-amber-500/15 border border-amber-500/40 text-amber-700 dark:text-amber-300 text-xs font-semibold flex items-center gap-3 shadow-2xl backdrop-blur-md",role:"alert",children:[e.jsx("span",{children:o==="zh"?"浏览器拦截了新窗口,已临时在当前页展示。请在地址栏放行弹窗后可再次打开独立展台。":"The new window was blocked; showing the stage inline. Allow pop-ups to open it in a separate window."}),e.jsx("button",{onClick:P,className:"shrink-0 px-2 py-1 rounded-lg border border-amber-500/40 hover:bg-amber-500/20 transition-colors cursor-pointer",children:o==="zh"?"知道了":"Got it"})]}),e.jsx(_o,{isOpen:k,onClose:()=>g(!1),classId:a??null,lessonId:t,students:s,lang:o,addToast:d,onOpenLeaderboard:()=>U(!0)}),e.jsx(Ro,{isOpen:A,onClose:()=>U(!1),classId:a??null,lessonId:t,students:s,lang:o,addToast:d,onSelectStudentToAward:()=>{U(!1),g(!0)}}),W&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-xs flex items-center justify-center p-4",children:e.jsxs("div",{"data-testid":"classroom-quick-poll-dialog",className:"bg-surface rounded-2xl border border-border p-6 w-full max-w-lg shadow-xl flex flex-col gap-4 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-bold text-base text-foreground flex items-center gap-2",children:[e.jsx(ve,{size:18,className:"text-amber-700 dark:text-amber-400"}),e.jsx("span",{children:o==="zh"?"极速投票配置":"Quick Poll Setup"})]}),e.jsx("button",{type:"button",onClick:()=>T(!1),className:"p-1.5 rounded-lg text-muted hover:bg-surface-secondary transition-colors cursor-pointer",children:e.jsx(we,{size:16})})]}),R.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted",children:[e.jsx(Rt,{size:13}),e.jsx("span",{children:o==="zh"?`本课已保存题目 (${R.length})`:`Saved Presets (${R.length})`})]}),e.jsx("div",{className:"flex flex-col gap-1.5 max-h-40 overflow-y-auto pr-1",children:R.map(z=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border/60 bg-surface-secondary/50 hover:bg-surface-secondary transition-colors group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:z.title}),e.jsxs("div",{className:"text-xs text-muted flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-secondary border border-border text-[10px] font-bold",children:z.questionType==="TF"?"判断":z.questionType==="ABCD"?"ABCD":"自定义"}),e.jsx("span",{className:"truncate",children:z.options.join(" / ")}),z.correctOption&&e.jsxs("span",{className:"flex items-center gap-0.5 text-emerald-700 dark:text-emerald-400",children:[e.jsx(Js,{size:10,className:"fill-current"}),z.correctOption]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-60 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>Mt(z),className:"p-1.5 rounded-md hover:bg-primary-theme/10 text-primary-ink transition-colors cursor-pointer",title:o==="zh"?"引入到编辑器":"Load to editor",children:e.jsx(Fa,{size:14})}),e.jsx("button",{type:"button",onClick:()=>at(z.title,z.questionType,z.options,z.correctOption),className:"p-1.5 rounded-md hover:bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 transition-colors cursor-pointer",title:o==="zh"?"直接发送":"Send now",children:e.jsx(us,{size:14})}),e.jsx("button",{type:"button",onClick:()=>Be(z.id),className:"p-1.5 rounded-md hover:bg-red-500/10 text-red-600 dark:text-red-400 transition-colors cursor-pointer",title:o==="zh"?"删除":"Delete",children:e.jsx(et,{size:14})})]})]},z.id))})]}),L&&e.jsx("div",{className:"text-xs text-muted text-center py-2",children:o==="zh"?"加载预设题库...":"Loading presets..."}),R.length>0&&e.jsx("div",{className:"border-t border-border/60"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"font-semibold text-muted text-xs",children:o==="zh"?"投票标题 / 题干":"Poll Title / Question"}),e.jsx("input",{type:"text",value:Q,onChange:z=>V(z.target.value),placeholder:o==="zh"?"例:下列哪个选项正确?":"e.g. Which is correct?",className:"w-full px-3 py-2 bg-surface-secondary border border-border rounded-lg text-foreground text-sm focus:outline-hidden focus:ring-2 focus:ring-primary-theme"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"font-semibold text-muted text-xs",children:o==="zh"?"题型选择":"Question Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{key:"ABCD",label:"ABCD 四选一"},{key:"TF",label:"正确 / 错误"},{key:"CUSTOM",label:"自定义选项"}].map(({key:z,label:ce})=>e.jsx("button",{type:"button",onClick:()=>Ae(z),className:`p-2 rounded-lg border font-bold text-center text-xs transition-colors cursor-pointer ${le===z?"border-primary-theme bg-primary-theme/10 text-primary-ink":"border-border bg-surface-secondary text-muted"}`,children:ce},z))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("label",{className:"font-semibold text-muted text-xs",children:[o==="zh"?"选项列表":"Options"," ",q&&e.jsxs("span",{className:"text-emerald-700 dark:text-emerald-400 ml-1",children:["✓ ",o==="zh"?"参考答案":"Answer",": ",q]})]}),e.jsx("div",{className:"flex flex-col gap-1.5",children:D.map((z,ce)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>ee(q===z?"":z),className:`p-1.5 rounded-md transition-colors cursor-pointer shrink-0 ${q===z?"text-emerald-700 dark:text-emerald-400 bg-emerald-500/10":"text-subtle hover:text-emerald-700 dark:hover:text-emerald-400"}`,title:o==="zh"?"设为参考答案":"Set as correct",children:e.jsx(Js,{size:14,className:q===z?"fill-current":""})}),e.jsx("input",{type:"text",value:z,onChange:fe=>{const ue=[...D];ue[ce]=fe.target.value,j(ue),le!=="CUSTOM"&&F("CUSTOM")},className:"flex-1 px-3 py-1.5 bg-surface-secondary border border-border rounded-lg text-foreground text-sm focus:outline-hidden focus:ring-2 focus:ring-primary-theme"}),D.length>2&&e.jsx("button",{type:"button",onClick:()=>{const fe=D.filter((ue,be)=>be!==ce);j(fe),q===z&&ee(""),le!=="CUSTOM"&&F("CUSTOM")},className:"p-1.5 rounded-md text-red-600 dark:text-red-400 hover:bg-red-500/10 transition-colors cursor-pointer shrink-0",children:e.jsx(et,{size:14})})]},ce))}),D.length<8&&e.jsxs("button",{type:"button",onClick:()=>{j([...D,`选项${D.length+1}`]),le!=="CUSTOM"&&F("CUSTOM")},className:"flex items-center gap-1.5 text-xs text-primary-ink hover:text-primary-ink-hover font-semibold mt-1 cursor-pointer",children:[e.jsx(Tt,{size:13}),o==="zh"?"添加选项":"Add Option"," ",e.jsxs("span",{className:"text-muted font-normal",children:["(",D.length,"/8)"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/60",children:[e.jsxs("button",{type:"button",onClick:_e,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-semibold text-muted hover:bg-surface-secondary border border-border/60 transition-colors cursor-pointer",children:[e.jsx(er,{size:14}),o==="zh"?"保存到本课程":"Save to Lesson"]}),e.jsxs("button",{type:"button",onClick:()=>at(),className:"flex items-center gap-1.5 px-4 py-2 bg-primary-solid text-white font-bold rounded-lg hover:bg-primary-solid-hover transition-colors cursor-pointer",children:[e.jsx(us,{size:14}),o==="zh"?"立即发布":"Launch"]})]})]})}),ie&&_&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface rounded-3xl border border-border p-8 w-full max-w-2xl shadow-2xl flex flex-col gap-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/80 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-primary-theme/10 text-primary-ink rounded-2xl",children:e.jsx(cn,{size:28})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-black text-foreground",children:o==="zh"?"全景课堂学情简报":"Panoramic Classroom Report"}),e.jsx("p",{className:"text-xs text-muted",children:o==="zh"?`授课时长: ${_.session?.durationMin||0} 分钟`:"Session Summary"})]})]}),e.jsx("button",{onClick:()=>xe(!1),className:"p-2 text-muted hover:text-foreground rounded-lg cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 bg-surface-secondary rounded-2xl border border-border/80 flex flex-col items-center text-center",children:[e.jsx("span",{className:"text-xs font-bold text-muted mb-1",children:o==="zh"?"随堂测验正确率":"Quiz Accuracy"}),e.jsxs("span",{className:"text-3xl font-black text-emerald-700 dark:text-emerald-400 font-mono",children:[_.metrics?.quizAccuracy||0,"%"]}),e.jsxs("span",{className:"text-[10px] text-muted mt-1",children:[_.metrics?.quizCount||0," 题次提交"]})]}),e.jsxs("div",{className:"p-4 bg-surface-secondary rounded-2xl border border-border/80 flex flex-col items-center text-center",children:[e.jsx("span",{className:"text-xs font-bold text-muted mb-1",children:o==="zh"?"课堂互动参与人次":"Poll Interactions"}),e.jsx("span",{className:"text-3xl font-black text-amber-700 dark:text-amber-400 font-mono",children:_.metrics?.pollVotesTotal||0}),e.jsx("span",{className:"text-[10px] text-muted mt-1",children:"口播投票互动"})]}),e.jsxs("div",{className:"p-4 bg-surface-secondary rounded-2xl border border-border/80 flex flex-col items-center text-center",children:[e.jsx("span",{className:"text-xs font-bold text-muted mb-1",children:o==="zh"?"结课通票综合评分":"Exit Ticket Rating"}),e.jsx("span",{className:"text-3xl font-black text-indigo-500 font-mono",children:_.metrics?.exitTicketsAvgRating!=null?`${_.metrics.exitTicketsAvgRating} ★`:"—"}),e.jsxs("span",{className:"text-[10px] text-muted mt-1",children:[_.metrics?.exitTicketsCount||0," 人提交"]})]})]}),_.metrics?.topPuzzledConcepts?.length>0&&e.jsxs("div",{className:"p-4 bg-amber-500/5 rounded-2xl border border-amber-500/20 flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-amber-600 dark:text-amber-400",children:o==="zh"?"📌 需重点讲评或个别辅导的困惑点 (来自结课通票)":"Top Puzzled Concepts"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:_.metrics.topPuzzledConcepts.map((z,ce)=>e.jsx("span",{className:"px-3 py-1 bg-amber-500/10 text-amber-700 dark:text-amber-300 font-medium rounded-lg text-xs border border-amber-500/30",children:z},ce))})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>xe(!1),className:"px-6 py-2.5 bg-primary-solid text-white font-bold rounded-xl hover:bg-primary-solid-hover transition-colors cursor-pointer",children:o==="zh"?"完成归档":"Done"})})]})})]})]})}function Mo({lessonId:t,classId:n,lang:a="zh"}){const[o,d]=i.useState(null),[r,l]=i.useState(!1),[s,h]=i.useState(1),[c,u]=i.useState(null),m=()=>{t&&(l(!0),fetch(`/api/lessons/${t}/pre-class-diagnostic${n?`?classId=${encodeURIComponent(n)}`:""}`).then(P=>{if(!P.ok)throw new Error("Failed to load diagnostic");return P.json()}).then(P=>{d(P)}).catch(P=>{console.warn("[PreClassDiagnosticHub] fetch fallback:",P)}).finally(()=>{l(!1)}))};if(i.useEffect(()=>{m()},[t,n]),i.useEffect(()=>{u(null)},[t,n]),i.useEffect(()=>{if(!n)return;let P=null;const y=Wt(k=>{const g=A=>{!A||A.classId!==n||!A.stats||u(A.stats)};P?.(),k.on("classroom:icebreaker_updated",g),P=()=>k.off("classroom:icebreaker_updated",g)});return()=>{y(),P?.()}},[n]),!t)return null;const p=o?.prepSummary||{totalStudents:0,completedCount:0,completionRate:0},w=o?.topMistakes||[],f=c||o?.icebreakerStats||{fullPower:0,needCoffee:0,needHelp:0},N=f.fullPower+f.needCoffee+f.needHelp,b=N>0,$=Math.max(1,N);return e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-indigo-500/10 text-indigo-600 dark:text-indigo-400",children:e.jsx(Ba,{size:16})}),e.jsx("div",{children:e.jsxs("h3",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx("span",{children:a==="zh"?"预习学情穿透看板 (以学定教)":"Pre-Lesson Diagnostic Hub"}),e.jsx("span",{className:"px-1.5 py-0.2 rounded-md bg-indigo-100 dark:bg-indigo-900/60 text-indigo-700 dark:text-indigo-300 text-[10px] font-mono font-bold",children:"AI Diagnostic"})]})})]}),e.jsx("button",{onClick:m,disabled:r,className:"p-1 text-muted hover:text-main rounded-md hover:bg-surface-secondary transition-colors cursor-pointer",title:a==="zh"?"刷新学情数据":"Refresh Diagnostics",children:e.jsx(Pe,{size:12,className:r?"animate-spin":""})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2.5 rounded-xl bg-surface-secondary/60 border border-theme/60 flex flex-col justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted font-medium",children:a==="zh"?"预习视频/导学完成":"Prep Completed"}),e.jsxs("div",{className:"flex items-baseline gap-1.5 mt-1",children:[e.jsxs("span",{className:"text-base font-black text-emerald-600 dark:text-emerald-400 font-mono",children:[p.completionRate,"%"]}),e.jsx("span",{className:"text-2xs text-muted font-mono",children:p.totalStudents>0?`(${p.completedCount}/${p.totalStudents} 人)`:a==="zh"?"(暂无班级名单)":"(no roster)"})]}),e.jsx("div",{className:"w-full bg-slate-200 dark:bg-slate-700 h-1.5 rounded-full overflow-hidden mt-1.5",children:e.jsx("div",{className:"bg-emerald-500 h-full rounded-full transition-all duration-500",style:{width:`${p.completionRate}%`}})})]}),e.jsxs("div",{className:"p-2.5 rounded-xl bg-surface-secondary/60 border border-theme/60 flex flex-col justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted font-medium",children:a==="zh"?"全班心态基线调研":"Class Energy Baseline"}),b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 text-xs mt-1 font-bold",children:[e.jsxs("span",{className:"text-amber-500 flex items-center gap-0.5 text-2xs",title:"满格电量",children:["⚡ ",Math.round(f.fullPower/$*100),"%"]}),e.jsxs("span",{className:"text-blue-500 flex items-center gap-0.5 text-2xs",title:"需要充能",children:["☕ ",Math.round(f.needCoffee/$*100),"%"]}),e.jsxs("span",{className:"text-rose-500 flex items-center gap-0.5 text-2xs",title:"需要求助",children:["🆘 ",Math.round(f.needHelp/$*100),"%"]})]}),e.jsxs("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex gap-0.5 mt-1.5 bg-slate-200 dark:bg-slate-700",children:[e.jsx("div",{style:{width:`${f.fullPower/$*100}%`},className:"bg-amber-400"}),e.jsx("div",{style:{width:`${f.needCoffee/$*100}%`},className:"bg-blue-400"}),e.jsx("div",{style:{width:`${f.needHelp/$*100}%`},className:"bg-rose-400"})]})]}):e.jsx("div",{className:"flex items-center justify-center py-2 text-2xs text-muted",children:e.jsx("span",{children:a==="zh"?"等待学生课前打卡破冰":"Awaiting student check-in"})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-2xs text-muted font-bold px-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1 text-rose-600 dark:text-rose-400",children:[e.jsx(Ie,{size:11}),e.jsx("span",{children:a==="zh"?"前置导学测验错误率最高 Top 3 疑难卡点":"Top 3 Diagnostic Stumbling Blocks"})]}),e.jsx("span",{children:a==="zh"?"点击展开以学定教建议":"Click for strategies"})]}),w.length===0?e.jsx("div",{className:"p-3 rounded-xl border border-dashed border-theme/60 bg-surface-secondary/20 text-center text-2xs text-muted",children:a==="zh"?"暂无前置练习错题卡点,学生完成前置导学测验后将自动分析高频失分概念。":"No diagnostic stumbling blocks found. Student quiz errors will appear here."}):e.jsx("div",{className:"space-y-1.5",children:w.map(P=>{const y=s===P.rank;return e.jsxs("div",{onClick:()=>h(y?null:P.rank),className:`p-2.5 rounded-xl border transition-all cursor-pointer ${y?"bg-rose-50/40 dark:bg-rose-950/20 border-rose-400/50 shadow-2xs":"bg-surface-secondary/40 border-theme/60 hover:bg-surface-secondary"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-black shrink-0 ${P.rank===1?"bg-rose-500 text-white":P.rank===2?"bg-amber-500 text-white":"bg-slate-400 text-white"}`,children:P.rank}),e.jsx("span",{className:"text-xs font-bold text-main truncate",children:P.concept})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-2xs font-mono font-bold text-rose-600 dark:text-rose-400",children:["错率 ",P.mistakeRate,"%"]}),e.jsx(ms,{size:12,className:`text-muted transition-transform duration-200 ${y?"rotate-90":""}`})]})]}),y&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-rose-200/50 dark:border-rose-900/50 space-y-1.5 text-2xs animate-fadeIn",children:[e.jsxs("div",{className:"text-muted",children:[e.jsx("span",{className:"font-semibold text-main",children:a==="zh"?"典型错题:":"Sample Trap: "}),P.sampleQuestion]}),e.jsxs("div",{className:"flex items-start gap-1 text-emerald-700 dark:text-emerald-300 bg-emerald-500/10 p-1.5 rounded-lg border border-emerald-500/20 font-medium",children:[e.jsx(Vt,{size:12,className:"shrink-0 mt-0.5 text-emerald-600 dark:text-emerald-400"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-bold",children:a==="zh"?"以学定教建议:":"Teaching Strategy: "}),P.pedagogicalAdvice]})]})]})]},P.rank)})})]})]})}function Oo({isOpen:t,onClose:n,classId:a,className:o,lang:d="zh"}){const[r,l]=i.useState(!1),[s,h]=i.useState(null),[c,u]=i.useState(null),m=()=>{l(!0),u(null),fetch(`/api/classes/${a||"default"}/preflight-health`).then(p=>{if(!p.ok)throw new Error(`HTTP ${p.status}`);return p.json()}).then(p=>{h({localApiLatencyMs:p.checks?.localApiLatencyMs,staticResources:p.checks?.staticResources,pluginSandbox:p.checks?.pluginSandbox,socketMesh:p.checks?.socketMesh,healthScore:p.healthScore}),l(!1)}).catch(p=>{h(null),u(p?.message||"无法连接服务器"),l(!1)})};return Et.useEffect(()=>{t&&m()},[t]),t?e.jsx("div",{"data-testid":"preflight-health-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-fadeIn",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl max-w-md w-full overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-theme flex items-center justify-between bg-surface-secondary/50",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"p-2 rounded-xl bg-teal-500/10 text-teal-600 dark:text-teal-400",children:e.jsx(bs,{size:20})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-extrabold text-sm text-main flex items-center gap-1.5",children:e.jsx("span",{children:d==="zh"?"课前环境一键预检飞检":"Pre-flight Environmental Healthcheck"})}),e.jsx("p",{className:"text-2xs text-muted",children:o||(d==="zh"?"当前教学环境":"Current Classroom Environment")})]})]}),e.jsx("button",{onClick:n,className:"p-1 rounded-lg text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer",children:e.jsx(we,{size:16})})]}),e.jsxs("div",{className:"p-5 flex flex-col gap-4 text-xs",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-teal-500/10 via-emerald-500/10 to-teal-500/10 border border-teal-500/20 flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("span",{className:"text-2xs uppercase tracking-wider text-muted font-bold",children:d==="zh"?"系统就绪综合健康指数":"Overall Health Score"}),e.jsx("div",{className:"text-2xl font-black text-teal-600 dark:text-teal-400 font-mono",children:r?"--":c?"—":`${s?.healthScore??"--"} / 100`}),e.jsxs("div",{className:"text-2xs text-muted flex items-center gap-1",children:[e.jsx(qe,{size:10,className:"text-emerald-500"}),e.jsx("span",{children:d==="zh"?"局域网低延迟 • 无单点故障风险":"Low Latency • No Single Point Failure"})]})]}),e.jsxs("button",{onClick:m,disabled:r,className:"px-3 py-1.5 rounded-lg bg-teal-600 hover:bg-teal-700 text-white font-bold text-xs flex items-center gap-1.5 shadow-xs transition-all active:scale-95 disabled:opacity-50 cursor-pointer",children:[e.jsx(Pe,{size:12,className:r?"animate-spin":""}),e.jsx("span",{children:r?d==="zh"?"飞检中...":"Checking...":d==="zh"?"重新飞检":"Re-check"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary/50 border border-theme/60 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(dn,{size:15,className:"text-amber-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-main",children:d==="zh"?"局域网内核响应时延":"Local Kernel Latency"}),e.jsx("div",{className:"text-2xs text-muted",children:"Express + SQLite API ping-pong"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:"font-mono font-bold text-emerald-600 text-xs",children:r?"...":`${s?.localApiLatencyMs??5} ms`}),e.jsx("span",{className:"block text-3xs text-muted",children:d==="zh"?"极佳":"Optimal"})]})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary/50 border border-theme/60 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ga,{size:15,className:"text-blue-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-main",children:d==="zh"?"课件音视频与交互资源":"Courseware & Static Media"}),e.jsx("div",{className:"text-2xs text-muted",children:s?.staticResources.message||"静态文件与 HTML 沙箱资源完整"})]})]}),e.jsx(Ce,{size:15,className:"text-emerald-500 shrink-0"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary/50 border border-theme/60 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(js,{size:15,className:"text-purple-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-main",children:d==="zh"?"微前端与安全沙箱隔离":"Plugin Sandbox & CSP"}),e.jsx("div",{className:"text-2xs text-muted",children:s?.pluginSandbox.message||"Bridge SDK Proxy 拦截通道就绪"})]})]}),e.jsx(Ce,{size:15,className:"text-emerald-500 shrink-0"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary/50 border border-theme/60 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ha,{size:15,className:"text-emerald-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-main",children:d==="zh"?"学生机 Socket.IO 局域网连通率":"Student LAN Socket Mesh"}),e.jsx("div",{className:"text-2xs text-muted",children:s?.socketMesh.message||"WebSocket 双向通道通畅"})]})]}),e.jsx(Ce,{size:15,className:"text-emerald-500 shrink-0"})]})]})]}),e.jsxs("div",{className:"px-5 py-3 border-t border-theme flex items-center justify-between bg-surface-secondary/30",children:[e.jsx("span",{className:"text-2xs text-muted",children:d==="zh"?"💡 飞检自检保证课堂音视频与白板零卡顿":"Ensures zero stuttering during class"}),e.jsx("button",{onClick:n,className:"px-4 py-1.5 rounded-lg bg-surface-secondary hover:bg-surface border border-theme text-main font-bold text-xs transition-colors cursor-pointer",children:d==="zh"?"完成自检并返回":"Dismiss"})]})]})}):null}function Do({selectedLesson:t,lessonTitle:n,selectedClassId:a,className:o,students:d,onlineStudentIds:r,timelineSegments:l,lang:s,isClassLocked:h,onToggleClassLock:c,onStartClass:u,onPingStudent:m,onOpenStudentWindow:p,isStudentWindowOpen:w,addToast:f,onBroadcastNotice:N,onUpdateClassPasscode:b}){const[$,P]=i.useState(!1),[y,k]=i.useState(null),[g,A]=i.useState(null),[U,W]=i.useState(!1),[T,Q]=i.useState(!1),[V,le]=i.useState(""),[F,D]=i.useState("2h"),[j,q]=i.useState(!1),[ee,R]=i.useState(Date.now());i.useEffect(()=>{const J=setInterval(()=>R(Date.now()),1e3);return()=>clearInterval(J)},[]);const O=async()=>{if(!a){k(null),A(null);return}try{W(!0);const J=await fetch(`/api/classes/${a}/passcode`);if(J.ok){const z=await J.json();k(z.classPasscode||null),A(z.expiresAt??null),le(z.classPasscode||"")}}catch(J){console.error("Failed to fetch class passcode info",J)}finally{W(!1)}};i.useEffect(()=>{O()},[a]);const L=J=>{const z=Date.now();if(J==="45m")return z+2700*1e3;if(J==="2h")return z+2*3600*1e3;if(J==="today"){const ce=new Date;return ce.setHours(23,59,59,999),ce.getTime()}return null},X=async(J,z)=>{if(a)try{W(!0),(await fetch(`/api/classes/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({class_passcode:J,class_passcode_expires_at:z})})).ok?(k(J),A(z),Q(!1),b&&b(a,J),f(s==="zh"?"班级临时密码已更新":"Class Passcode Updated",J?s==="zh"?`已设定班级上课临时密码为 [${J}],学生可凭此密码快速登录。`:`Passcode [${J}] is now active for this class.`:s==="zh"?"已清除班级临时密码,学生需使用个人自设密码登录。":"Passcode cleared. Students will use personal passwords.","success")):f(s==="zh"?"更新失败":"Update Failed",s==="zh"?"无法保存班级临时密码,请稍后重试":"Could not save class passcode.","error")}catch(ce){f(s==="zh"?"网络错误":"Network Error",String(ce),"error")}finally{W(!1)}},K=()=>{const J=Math.floor(1e3+Math.random()*9e3).toString(),z=L(F);X(J,z)},H=()=>{X(null,null)},re=()=>{y&&(navigator.clipboard.writeText(y),q(!0),setTimeout(()=>q(!1),2e3),f(s==="zh"?"已复制临时密码":"Copied Passcode",s==="zh"?`密码 [${y}] 已复制到剪贴板`:`Passcode [${y}] copied to clipboard`,"info"))},te=!!(y&&g&&ee>g),de=g&&!te?Math.max(0,Math.floor((g-ee)/1e3)):0,G=J=>{const z=Math.floor(J/60),ce=J%60;if(z>=60){const fe=Math.floor(z/60),ue=z%60;return`${fe}小时${ue}分`}return`${z}分${ce}秒`},[S,M]=i.useState({resources:!0,audioVideo:!0,sandbox:!0,objective:!0}),[I,B]=i.useState(s==="zh"?"请同学们打开课本对应单元,准备好随堂笔记本,并保持网络通畅。":"Please open your course materials and ensure your screen is active."),[se,v]=i.useState(!1),_=i.useRef(null),[Z,ie]=i.useState(new Set);i.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]);const xe=J=>{M(z=>({...z,[J]:!z[J]}))},he=()=>{I.trim()&&(v(!0),N&&N(I),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(!1),f(s==="zh"?"📢 课前提示已记录":"📢 Warm-up Notice Recorded",s==="zh"?"已记录到课堂动态流。学生端实时推送通道尚未接通,请口头同步。":"Recorded to the classroom feed. Student push is not wired yet.","info")},400))},ke=()=>{const J=new Set(d.map(z=>z.id));ie(J),f(s==="zh"?"✓ 已本地预标记(未落库)":"✓ Locally Pre-marked (not persisted)",s==="zh"?`已在本地将全班 ${d.length} 名学生预标记为就绪。正式出勤以扫码签到为准。`:`Pre-marked ${d.length} students locally. Official attendance comes from check-in.`,"info")},ze=J=>{ie(z=>{const ce=new Set(z);return ce.has(J)?ce.delete(J):ce.add(J),ce})},ge=J=>r.includes(J.id)||!!(J.student_number&&r.includes(J.student_number)),Ae=d.length,_e=d.filter(ge).length,Be=d.filter(J=>ge(J)||Z.has(J.id)).length,Mt=Ae>0?Math.round(Be/Ae*100):0,at=l.map(J=>dr(J,{fallbackSeconds:wn})),tt=at.map(J=>J.seconds).filter(J=>J!=null&&Number.isFinite(J)),Ge=tt.reduce((J,z)=>J+z,0),Nt=l.length===0?s==="zh"?"45 分钟":"45 mins":tt.length===0?s==="zh"?"未设置":"Unset":s==="zh"?`${Math.round(Ge/60)} 分钟`:`${Math.round(Ge/60)} mins`;return e.jsxs("div",{id:"pre-class-ready-view",className:"flex-1 flex flex-col min-h-0 bg-surface-secondary/20 p-4 gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-500/10 border border-amber-500/20 text-amber-600 dark:text-amber-400 flex items-center justify-center shrink-0",children:e.jsx(De,{size:24,className:"animate-pulse"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-black bg-amber-500/10 text-amber-700 dark:text-amber-300 border border-amber-500/30 uppercase tracking-wider",children:s==="zh"?"阶段 1 / 4 · 课前准备与就绪":"Stage 1/4 · Pre-Class Preparation"}),e.jsxs("span",{className:"text-xs text-muted flex items-center gap-1 font-mono",children:[e.jsx(qe,{size:11,className:"text-emerald-500"}),s==="zh"?"预备就绪中":"Standby"]})]}),e.jsxs("h1",{className:"text-lg font-black text-main tracking-tight mt-1 flex items-center gap-2",children:[e.jsx("span",{children:n||(s==="zh"?"未选定课程":"Untitled Lesson")}),o&&e.jsx("span",{className:"text-xs font-semibold px-2 py-0.5 bg-surface-secondary rounded-lg border border-theme text-muted",children:o})]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:s==="zh"?`预计授课时长: ${Nt} · 共 ${l.length} 个教学环节 · 白板仅在进入课中授课时展示`:`Est. Duration: ${Nt} · ${l.length} segments · Whiteboard activates in-class`})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap w-full md:w-auto justify-end",children:[e.jsxs("button",{id:"pre-class-healthcheck-btn",type:"button",onClick:()=>P(!0),className:"px-3.5 py-2.5 text-xs font-bold rounded-xl border border-teal-500/30 bg-teal-50/60 dark:bg-teal-950/20 text-teal-700 dark:text-teal-300 hover:bg-teal-100/60 dark:hover:bg-teal-900/40 transition-all cursor-pointer flex items-center gap-1.5 shadow-2xs",title:s==="zh"?"一键自检局域网延迟、课件与沙箱健康度":"Environmental Healthcheck",children:[e.jsx(bs,{size:14,className:"text-teal-600 dark:text-teal-400"}),e.jsx("span",{children:s==="zh"?"环境一键飞检":"Healthcheck"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})]}),e.jsxs("button",{id:"pre-class-start-teaching-btn",type:"button",onClick:u,className:"px-5 py-2.5 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-700 hover:to-teal-700 text-white font-extrabold rounded-xl text-xs flex items-center gap-2 shadow-md hover:shadow-lg transition-all active:scale-95 cursor-pointer",children:[e.jsx(ys,{size:14,className:"fill-current"}),e.jsx("span",{children:s==="zh"?"一键开启课中授课 (进入白板)":"Start Live Teaching (Launch Whiteboard)"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4 flex-1 min-h-0",children:[e.jsxs("div",{className:"lg:col-span-5 flex flex-col gap-4",children:[e.jsx(Mo,{lessonId:t,classId:a,lang:s}),e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2.5",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(Wa,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"备课预检与教学就绪项":"Pre-flight Readiness Checklist"})]}),e.jsxs("span",{className:"text-xs text-muted font-semibold",children:[Object.values(S).filter(Boolean).length," / 4 就绪"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{onClick:()=>xe("resources"),className:"flex items-start gap-2.5 p-2.5 rounded-xl border border-theme/60 hover:bg-surface-secondary/50 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:S.resources,onChange:()=>{},className:"mt-0.5 rounded text-primary-theme focus:ring-primary-theme cursor-pointer"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-bold text-main",children:s==="zh"?"课件与互动资源已就绪":"Courseware & Resources Ready"}),e.jsx("div",{className:"text-[11px] text-muted",children:s==="zh"?"已校验实验沙箱、微前端挂载点及白板插槽":"Sandbox and extensions verified"})]}),S.resources&&e.jsx(Ce,{size:13,className:"text-emerald-500 shrink-0 mt-0.5"})]}),e.jsxs("label",{onClick:()=>xe("audioVideo"),className:"flex items-start gap-2.5 p-2.5 rounded-xl border border-theme/60 hover:bg-surface-secondary/50 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:S.audioVideo,onChange:()=>{},className:"mt-0.5 rounded text-primary-theme focus:ring-primary-theme cursor-pointer"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-bold text-main",children:s==="zh"?"广播同步信道与大屏投屏":"Broadcast & Stage Mirroring"}),e.jsx("div",{className:"text-[11px] text-muted",children:s==="zh"?"Socket.IO 实时通信广播就绪,全屏大屏展台待命":"Real-time WebSocket connection active"})]}),S.audioVideo&&e.jsx(Ce,{size:13,className:"text-emerald-500 shrink-0 mt-0.5"})]}),e.jsxs("label",{onClick:()=>xe("sandbox"),className:"flex items-start gap-2.5 p-2.5 rounded-xl border border-theme/60 hover:bg-surface-secondary/50 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:S.sandbox,onChange:()=>{},className:"mt-0.5 rounded text-primary-theme focus:ring-primary-theme cursor-pointer"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-bold text-main",children:s==="zh"?"安全沙箱与专注模式策略":"Sandbox & Anti-Distraction Guard"}),e.jsx("div",{className:"text-[11px] text-muted",children:s==="zh"?"iframe CSP 隔离与学生端防作弊专注锁定待发":"CSP frame sandbox configured"})]}),S.sandbox&&e.jsx(Ce,{size:13,className:"text-emerald-500 shrink-0 mt-0.5"})]}),e.jsxs("label",{onClick:()=>xe("objective"),className:"flex items-start gap-2.5 p-2.5 rounded-xl border border-theme/60 hover:bg-surface-secondary/50 cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:S.objective,onChange:()=>{},className:"mt-0.5 rounded text-primary-theme focus:ring-primary-theme cursor-pointer"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-bold text-main",children:s==="zh"?"教学目标与重难点梳理":"Key Teaching Goals Set"}),e.jsx("div",{className:"text-[11px] text-muted",children:s==="zh"?"导入、探究、练习与评价环节时序已锚定":"Segments timing calibrated"})]}),S.objective&&e.jsx(Ce,{size:13,className:"text-emerald-500 shrink-0 mt-0.5"})]})]})]}),e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-4 shadow-sm flex flex-col gap-2.5 flex-1 min-h-[180px]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(It,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"授课环节大纲预演":"Segments Timeline Preview"})]}),e.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[l.length," 个环节"]})]}),e.jsx("div",{className:"flex flex-col gap-2 overflow-y-auto pr-1",children:l.length>0?l.map((J,z)=>e.jsxs("div",{className:"p-2.5 rounded-xl bg-surface-secondary/60 border border-theme/70 flex items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:"w-5 h-5 rounded-lg bg-primary-theme/10 text-primary-theme font-black flex items-center justify-center text-[10px] shrink-0",children:z+1}),e.jsxs("div",{className:"truncate",children:[e.jsx("div",{className:"font-bold text-main truncate",children:J.title}),J.description&&e.jsx("div",{className:"text-[10px] text-muted truncate",children:J.description})]})]}),e.jsxs("span",{className:"font-mono text-[11px] text-muted shrink-0 flex items-center gap-1",children:[e.jsx(De,{size:10}),vn(at[z]?.seconds??null,s).prose]})]},J.id||z)):e.jsx("div",{className:"text-center py-6 text-xs text-muted italic",children:s==="zh"?"暂未配置环节大纲,系统将在课中按默认时长授课":"No custom segments"})})]})]}),e.jsxs("div",{className:"lg:col-span-7 flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-theme pb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx($e,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"学生到课与设备就绪监控":"Student Readiness & Attendance"})]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-mono font-bold bg-primary-theme/10 text-primary-theme border border-primary-theme/20",children:[Be," / ",Ae," (",Mt,"%)"]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-mono font-bold bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsxs("span",{children:[_e," ",s==="zh"?"设备连入":"Online"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:ke,className:"px-2.5 py-1 text-xs font-bold rounded-lg bg-surface-secondary hover:bg-surface border border-theme text-main transition-colors cursor-pointer",children:s==="zh"?"全员标记已就绪":"Mark All Ready"})})]}),e.jsx("div",{className:"w-full bg-surface-secondary h-2 rounded-full overflow-hidden border border-theme/40",children:e.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-500 h-full transition-all duration-500",style:{width:`${Mt}%`}})}),e.jsxs("div",{className:"p-3 rounded-2xl bg-gradient-to-r from-indigo-50/80 to-purple-50/60 dark:from-indigo-950/30 dark:to-purple-950/20 border border-indigo-200/80 dark:border-indigo-800/50 flex flex-col gap-2.5 text-xs shadow-xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"p-1.5 rounded-xl bg-indigo-600 text-white shadow-xs",children:e.jsx(Ua,{size:16})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-black text-main flex items-center gap-2",children:[e.jsx("span",{children:s==="zh"?"班级上课临时密码":"Class Temporary Passcode"}),y?te?e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/30",children:s==="zh"?"已过期":"Expired"}):e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/30 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),g?s==="zh"?`有效 (剩 ${G(de)})`:`Active (${G(de)} left)`:s==="zh"?"长期有效":"Permanent"]}):e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-slate-200 dark:bg-slate-800 text-muted",children:s==="zh"?"未设定":"Not set"})]}),e.jsx("div",{className:"text-[11px] text-muted",children:s==="zh"?"设置后所在班级学生可凭此临时密码或个人密码登录系统":"Students can login using this passcode or their personal passwords."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[y&&!T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`px-3 py-1 rounded-xl font-mono text-base font-black tracking-widest border shadow-2xs select-all ${te?"bg-amber-50 dark:bg-amber-950/40 text-amber-600 dark:text-amber-400 border-amber-300 dark:border-amber-700/60 line-through":"bg-white dark:bg-slate-900 text-indigo-600 dark:text-indigo-400 border-indigo-300 dark:border-indigo-700"}`,title:s==="zh"?"当前班级上课临时密码":"Active class temporary passcode",children:y}),e.jsx("button",{type:"button",onClick:re,disabled:U,className:"p-1.5 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-main transition-colors cursor-pointer",title:s==="zh"?"复制临时密码":"Copy passcode",children:j?e.jsx(gt,{size:14,className:"text-emerald-500"}):e.jsx(Yt,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{le(y),Q(!0)},disabled:U,className:"p-1.5 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-main transition-colors cursor-pointer",title:s==="zh"?"编辑临时密码":"Edit passcode",children:e.jsx(qa,{size:14})}),e.jsx("button",{type:"button",onClick:H,disabled:U,className:"p-1.5 rounded-lg bg-surface hover:bg-rose-50 dark:hover:bg-rose-950/30 border border-theme hover:border-rose-300 text-muted hover:text-rose-600 transition-colors cursor-pointer",title:s==="zh"?"清除临时密码(恢复仅个人密码登录)":"Clear temporary passcode",children:e.jsx(et,{size:14})})]}):null,T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:V,onChange:J=>le(J.target.value),placeholder:s==="zh"?"输入自定义密码":"Passcode",className:"w-24 px-2 py-1 text-xs font-mono font-bold bg-white dark:bg-slate-900 border border-indigo-300 dark:border-indigo-700 rounded-lg text-main outline-none focus:ring-1 focus:ring-indigo-500",maxLength:12}),e.jsxs("button",{type:"button",onClick:()=>{if(!V.trim())H();else{const J=L(F);X(V.trim(),J)}},disabled:U,className:"px-2 py-1 rounded-lg bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs flex items-center gap-1 cursor-pointer transition-colors shadow-2xs",children:[e.jsx(er,{size:12}),e.jsx("span",{children:s==="zh"?"保存":"Save"})]}),e.jsx("button",{type:"button",onClick:()=>Q(!1),className:"p-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-muted cursor-pointer",children:e.jsx(we,{size:14})})]}):y?null:e.jsxs("button",{type:"button",onClick:K,disabled:U||!a,className:"px-3 py-1.5 rounded-xl bg-indigo-600 hover:bg-indigo-700 active:scale-95 text-white font-bold text-xs flex items-center gap-1.5 shadow-sm shadow-indigo-600/20 cursor-pointer transition-all disabled:opacity-50",children:[e.jsx(ve,{size:13}),e.jsx("span",{children:s==="zh"?"随机生成密码":"Generate Passcode"})]}),y&&!T&&e.jsx("button",{type:"button",onClick:K,disabled:U,className:"p-1.5 rounded-lg bg-indigo-50 dark:bg-indigo-900/30 hover:bg-indigo-100 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-800 transition-colors cursor-pointer",title:s==="zh"?"重新随机生成密码":"Regenerate random passcode",children:e.jsx(Jt,{size:14,className:U?"animate-spin":""})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-indigo-100 dark:border-indigo-900/40 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-muted flex items-center gap-1",children:[e.jsx(Va,{size:12}),e.jsx("span",{children:s==="zh"?"有效期限:":"Validity:"})]}),e.jsx("div",{className:"flex items-center gap-1",children:[{id:"45m",label:s==="zh"?"45分钟":"45m"},{id:"2h",label:s==="zh"?"2小时":"2h"},{id:"today",label:s==="zh"?"今日":"Today"},{id:"permanent",label:s==="zh"?"长期":"Permanent"}].map(J=>e.jsx("button",{type:"button",onClick:()=>{if(D(J.id),y&&!T){const z=L(J.id);X(y,z)}},className:`px-2 py-0.5 rounded-md font-medium cursor-pointer transition-colors ${F===J.id?"bg-indigo-600 text-white font-bold":"bg-surface hover:bg-surface-secondary border border-theme text-muted"}`,children:J.label},J.id))})]}),e.jsx("div",{className:"flex items-center gap-1.5 ml-auto",children:e.jsx(me,{slot:"classroom.preclass.passcode_action",slotProps:{classId:a,className:o,classPasscode:y,expiresAt:g,isExpired:te,onRefresh:O}})})]}),e.jsx(me,{slot:"classroom.preclass.passcode_addon",slotProps:{classId:a,className:o,classPasscode:y,expiresAt:g,isExpired:te,onRefresh:O}})]}),e.jsx("div",{className:"max-h-[260px] overflow-y-auto border border-theme/70 rounded-xl divide-y divide-border/60 bg-surface-secondary/20",children:d.length>0?d.map(J=>{const z=ge(J),ce=Z.has(J.id),fe=z||ce;return e.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-3 hover:bg-surface-secondary transition-colors text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${z?"bg-emerald-500 shadow-xs shadow-emerald-500/50":"bg-slate-300 dark:bg-slate-600"}`,title:z?"在线连接活跃":"离线未连入"}),e.jsx("span",{className:"font-bold text-main truncate",children:J.name}),J.student_number&&e.jsxs("span",{className:"font-mono text-[10px] text-muted",children:["(",J.student_number,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>ze(J.id),className:`px-2 py-0.5 rounded text-[11px] font-bold border transition-colors cursor-pointer ${fe?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30":"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30"}`,children:fe?s==="zh"?"✓ 已就绪":"Ready":s==="zh"?"未就绪":"Pending"}),e.jsx("button",{type:"button",onClick:()=>m?.(J.id,s==="zh"?"请尽快进入课堂":"Please join class"),className:"p-1 text-muted hover:text-primary-theme hover:bg-surface rounded transition-colors cursor-pointer",title:s==="zh"?"给该学生发送连接提醒":"Ping Student",children:e.jsx(ln,{size:13})})]})]},J.id)}):e.jsx("div",{className:"py-6 text-center text-xs text-muted italic",children:s==="zh"?"该班级暂未关联学生名单":"No students found for this class"})})]}),e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(ve,{size:14,className:"text-amber-500"}),e.jsx("span",{children:s==="zh"?"课前热身提示与学生端广播":"Pre-Class Warm-up Notice"})]}),e.jsx("span",{className:"text-[11px] text-muted",children:s==="zh"?"实时推送至学生待命屏":"Pushed to student stand-by UI"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("textarea",{value:I,onChange:J=>B(J.target.value),rows:2,placeholder:s==="zh"?"输入广播给全班学生的课前热身指导...":"Type a warm-up prompt for students...",className:"w-full bg-surface-secondary border border-theme rounded-xl p-2.5 text-xs text-main placeholder-muted focus:ring-1 focus:ring-primary-theme outline-none resize-none"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-muted",children:[e.jsx("span",{children:s==="zh"?"预设提示:":"Presets:"}),e.jsx("button",{type:"button",onClick:()=>B(s==="zh"?"请大家翻到课本对应章节,准备思考探究题。":"Open chapter materials."),className:"hover:text-primary-theme underline cursor-pointer",children:s==="zh"?"预备教材":"Textbook"}),e.jsx("span",{children:"·"}),e.jsx("button",{type:"button",onClick:()=>B(s==="zh"?"课前思考:如何用生活中的常见现象解释本节核心定律?":"Pre-class thought starter"),className:"hover:text-primary-theme underline cursor-pointer",children:s==="zh"?"思考题":"Question"})]}),e.jsxs("button",{type:"button",onClick:he,disabled:se||!I.trim(),className:"px-3.5 py-1.5 bg-primary-theme hover:bg-primary-theme-hover text-white rounded-xl text-xs font-bold flex items-center gap-1.5 transition-all shadow-xs cursor-pointer disabled:opacity-50",children:[e.jsx(ut,{size:12}),e.jsx("span",{children:se?s==="zh"?"广播中...":"Sending...":s==="zh"?"广播到学生端":"Broadcast to Students"})]})]})]})]})]})]}),e.jsx(Oo,{isOpen:$,onClose:()=>P(!1),classId:a,className:o,lang:s})]})}const Fo="/api/ping",Bo=15e3;let mt={latencyMs:null,quality:"smooth",isOnline:!0,measuredAt:null};const Gt=new Set;let as=null,Hs=!1;function Go(t){return t<80?"smooth":t<250?"fair":"poor"}function Ho(){for(const t of Gt)t(mt)}async function hs(){if(Hs||typeof fetch!="function")return;Hs=!0;const t=performance.now();try{const n=await fetch(`${Fo}?_=${Date.now()}`,{cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);await n.json();const a=Math.max(0,Math.round(performance.now()-t));mt={latencyMs:a,isOnline:!0,quality:Go(a),measuredAt:Date.now()}}catch{const n=typeof navigator>"u"?!0:navigator.onLine;mt={latencyMs:mt.latencyMs,isOnline:n,quality:n?"poor":"offline",measuredAt:mt.measuredAt}}finally{Hs=!1,Ho()}}function os(){hs()}function Wo(t){return Gt.add(t),t(mt),Gt.size===1&&(hs(),as=setInterval(()=>void hs(),Bo),typeof window<"u"&&(window.addEventListener("online",os),window.addEventListener("offline",os))),()=>{Gt.delete(t),Gt.size===0&&as&&(clearInterval(as),as=null,typeof window<"u"&&(window.removeEventListener("online",os),window.removeEventListener("offline",os)))}}function mr(t=!0){const[n,a]=i.useState(mt);i.useEffect(()=>{if(t)return Wo(a)},[t]);const o=i.useCallback(()=>{hs()},[]);return{...n,refresh:o}}function Uo({classId:t,students:n,onlineStudentIds:a,lang:o,fetcher:d=fetch}){const r=o==="zh",[l,s]=i.useState({lab:null,seats:[]}),[h,c]=i.useState([]),[u,m]=i.useState(!0),[p,w]=i.useState(null);i.useEffect(()=>{let $=!1;return(async()=>{try{m(!0),w(null);const[P,y]=await Promise.all([d(`/api/classes/${t}/seats`),d("/api/labs")]);if($)return;const k=P.ok?await P.json():{lab_id:null,seats:[]},g=y.ok?await y.json():[],A=g.find(U=>U.id===k.lab_id)||null;s({lab:A,seats:k.seats||[]}),c(g)}catch(P){$||w(P instanceof Error?P.message:String(P))}finally{$||m(!1)}})(),()=>{$=!0}},[t,d]);const f=i.useMemo(()=>{const $=new Map;for(const P of n)$.set(P.id,P);return $},[n]),N=i.useMemo(()=>{if(!l.lab)return null;const{rows:$,cols:P}=l.lab,y=Array.from({length:$},()=>Array.from({length:P},()=>null));for(const k of l.seats)k.row_idx>=0&&k.row_idx<$&&k.col_idx>=0&&k.col_idx<P&&(y[k.row_idx][k.col_idx]=k);return y},[l]),b=i.useMemo(()=>{const $=l.lab?l.lab.rows*l.lab.cols:0,P=l.seats.length,y=l.seats.filter(g=>a.includes(g.student_id)).length,k=$-P;return{totalSeats:$,assignedCount:P,onlineCount:y,emptySeats:k}},[l,a]);return u?e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm flex items-center justify-center gap-2",children:[e.jsx(Pe,{size:14,className:"animate-spin text-primary-theme"}),e.jsx("span",{className:"text-xs text-muted",children:r?"加载座位图...":"Loading seating map..."})]}):p?e.jsx("div",{className:"bg-surface border border-rose-200 dark:border-rose-800 rounded-2xl p-5 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2 text-rose-600 dark:text-rose-400",children:[e.jsx(fs,{size:14}),e.jsxs("span",{className:"text-xs font-semibold",children:[r?"加载失败":"Load failed",": ",p]})]})}):l.lab?e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{size:16,className:"text-primary-theme"}),e.jsx("h3",{className:"text-sm font-black text-main",children:r?"机房座位图":"Computer Lab Seating Map"}),e.jsx("span",{className:"text-2xs font-semibold text-muted px-2 py-0.5 rounded-lg bg-surface-secondary border border-theme",children:l.lab.room_number})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(me,{slot:"classroom.seating.toolbar",lang:o,slotProps:{classId:t,lab:l.lab,stats:b}})})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsxs("div",{className:"bg-surface-secondary border border-theme rounded-xl px-6 py-2 flex items-center gap-2",children:[e.jsx(mn,{size:14,className:"text-primary-theme"}),e.jsx("span",{className:"text-2xs font-bold text-main",children:r?"教师机":"Teacher Station"})]})}),N&&e.jsx("div",{className:"bg-surface-secondary border border-theme rounded-xl p-4",children:e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${l.lab.cols}, minmax(0, 1fr))`},children:N.flatMap(($,P)=>$.map((y,k)=>{const g=y?f.get(y.student_id):null,A=y?a.includes(y.student_id):!1,U=String.fromCharCode(65+P)+String(k+1).padStart(2,"0");return e.jsx(qo,{seatLabel:U,student:g,isOnline:A,hasSeat:!!y,lang:o,classId:t,seat:y},`${P}-${k}`)}))})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-2xs",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 rounded bg-emerald-100 border border-emerald-300 dark:bg-emerald-900/50 dark:border-emerald-700"}),e.jsx("span",{className:"text-muted font-medium",children:r?`在线 (${b.onlineCount})`:`Online (${b.onlineCount})`})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 rounded bg-slate-100 border border-slate-300 dark:bg-slate-800 dark:border-slate-600"}),e.jsx("span",{className:"text-muted font-medium",children:r?`离线 (${b.assignedCount-b.onlineCount})`:`Offline (${b.assignedCount-b.onlineCount})`})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 rounded bg-surface border border-dashed border-theme"}),e.jsx("span",{className:"text-muted font-medium",children:r?`空位 (${b.emptySeats})`:`Empty (${b.emptySeats})`})]}),e.jsx(me,{slot:"classroom.seating.legend",lang:o,slotProps:{classId:t,stats:b}})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Ws,{icon:$e,label:r?"已分配座位":"Assigned Seats",value:b.assignedCount,total:b.totalSeats,lang:o}),e.jsx(Ws,{icon:sr,label:r?"当前在线":"Currently Online",value:b.onlineCount,total:b.assignedCount,lang:o,tone:"emerald"}),e.jsx(Ws,{icon:rr,label:r?"在线率":"Online Rate",value:b.assignedCount>0?Math.round(b.onlineCount/b.assignedCount*100):0,suffix:"%",lang:o,tone:b.onlineCount===b.assignedCount?"emerald":"amber"})]}),e.jsx(me,{slot:"classroom.seating.summary",lang:o,slotProps:{classId:t,stats:b,onlineStudentIds:a}})]}):e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Kt,{size:16,className:"text-primary-theme"}),e.jsx("h3",{className:"text-sm font-black text-main",children:r?"机房座位图":"Computer Lab Seating Map"})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(xn,{size:32,className:"text-muted mb-3"}),e.jsx("p",{className:"text-xs text-muted font-medium",children:r?"该班级尚未分配机房":"No computer lab assigned to this class"}),e.jsx("p",{className:"text-2xs text-subtle mt-1",children:r?"请在「班级管理」→「座位安排」中为该班级分配机房并设置座位":"Go to Classes → Seating to assign a lab and configure seats"})]})]})}function qo({seatLabel:t,student:n,isOnline:a,hasSeat:o,lang:d,classId:r,seat:l}){const s=d==="zh",h=o?a?"bg-emerald-50 border-emerald-200 dark:bg-emerald-950/40 dark:border-emerald-800/70":"bg-slate-50 border-slate-200 dark:bg-slate-900/40 dark:border-slate-700":"bg-surface border-dashed border-theme-subtle",c=o?a?"bg-emerald-500":"bg-slate-400 dark:bg-slate-500":null;return e.jsxs("div",{className:`relative rounded-lg border p-1.5 flex flex-col items-center gap-0.5 min-h-[56px] transition-colors ${h}`,title:o?`${n?.name??"?"}${a?s?" (在线)":" (online)":s?" (离线)":" (offline)"}`:s?"空座位":"Empty seat",children:[e.jsx("span",{className:"text-2xs font-mono font-bold text-muted leading-none",children:t}),n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-main truncate w-full text-center leading-tight font-medium",children:(n.name??"").slice(0,3)}),e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),e.jsx(me,{slot:"classroom.seating.seat_badge",lang:d,slotProps:{seat:l,student:n,isOnline:a,classId:r}}),e.jsx(me,{slot:"classroom.seating.seat_actions",lang:d,slotProps:{seat:l,student:n,isOnline:a,classId:r}})]}):o?e.jsx("span",{className:"text-2xs text-subtle italic",children:s?"未分配":"Unassigned"}):e.jsx("span",{className:"text-2xs text-subtle/50",children:"—"})]})}function Ws({icon:t,label:n,value:a,total:o,suffix:d,lang:r,tone:l="default"}){const s={default:"text-main",emerald:"text-emerald-600 dark:text-emerald-400",amber:"text-amber-600 dark:text-amber-400"};return e.jsxs("div",{className:"bg-surface-secondary border border-theme rounded-xl p-3 flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-surface border border-theme flex items-center justify-center shrink-0",children:e.jsx(t,{size:14,className:"text-primary-theme"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-2xs text-muted truncate",children:n}),e.jsxs("div",{className:`text-sm font-black font-mono leading-none mt-0.5 ${s[l]}`,children:[a,o!==void 0&&e.jsxs("span",{className:"text-2xs text-muted font-normal",children:["/",o]}),d&&e.jsx("span",{className:"text-2xs text-muted font-normal",children:d})]})]})]})}const Vo=new Set(["IN_CLASS_TEACHING","WRAP_UP_EXIT_TICKET"]);function Cn(t){return!!t&&Vo.has(t)}function ht(t){return t==="zh"?"需结束本节课才能换班":"End this lesson before switching classes"}const Ko={Presentation:Ht,FlaskConical:Ya,Users:$e,Sparkles:ve,Target:hn,BookOpen:Rt,FolderKanban:un,Layers:It,Cpu:js,GraduationCap:nr};function Kr(t,n){return t<6?n?"凌晨好":"Good early morning":t<12?n?"上午好":"Good morning":t<18?n?"下午好":"Good afternoon":n?"晚上好":"Good evening"}function pt(t){return String(t).padStart(2,"0")}function ur(t=new Date){return`${t.getFullYear()}-${pt(t.getMonth()+1)}-${pt(t.getDate())}`}function Jo(t){const n=new Date;return n.setDate(n.getDate()+t),ur(n)}function Us(t){if(!t||typeof t!="string")return null;const n=t.match(/(\d{1,2}):(\d{2})/);if(!n)return null;const a=parseInt(n[1],10),o=parseInt(n[2],10);return a<0||a>23||o<0||o>59?null:a*60+o}function Yo(t,n,a=ur()){if(t===a)return n?"今天":"Today";const[o,d,r]=a.split("-").map(p=>parseInt(p,10)),[l,s,h]=t.split("-").map(p=>parseInt(p,10)),c=new Date(o,d-1,r).getTime(),u=new Date(l,s-1,h).getTime(),m=Math.round((u-c)/864e5);return m===1?n?"明天":"Tomorrow":m===2?n?"后天":"In 2 days":m>2&&m<7?n?`${m} 天后`:`In ${m} days`:`${pt(s)}-${pt(h)}`}function Qo({lang:t,seatCount:n,onlineCount:a,readinessRate:o}){const d=t==="zh",{latencyMs:r,quality:l,isOnline:s,measuredAt:h}=mr(),[c,u]=i.useState(()=>new Date);i.useEffect(()=>{const f=setInterval(()=>u(new Date),1e3);return()=>clearInterval(f)},[]);const m=h===null?d?"检测中":"Checking":l==="offline"?d?"离线":"Offline":l==="smooth"?d?"流畅":"Smooth":l==="fair"?d?"一般":"Fair":d?"较差":"Poor",p=h===null?"text-muted bg-surface-secondary border-theme":l==="smooth"?"text-emerald-700 bg-emerald-50 border-emerald-200/80 dark:bg-emerald-950/40 dark:border-emerald-800/80 dark:text-emerald-300":l==="fair"?"text-amber-700 bg-amber-50 border-amber-200/80 dark:bg-amber-950/40 dark:border-amber-800/80 dark:text-amber-300":"text-rose-700 bg-rose-50 border-rose-200/80 dark:bg-rose-950/40 dark:border-rose-800/80 dark:text-rose-300",w=[{icon:mn,label:d?"授课控制台":"Teaching Console",value:d?"当前设备":"This device",hint:d?"本浏览器窗口":"Current browser window"},{icon:ar,label:d?"学生端连接":"Student Connections",value:`${a} / ${n}`,hint:o},{icon:h===null?qe:s?sr:rr,label:d?"网络时延":"Network RTT",value:r===null?"—":`${r} ms`,hint:m,tone:p},{icon:De,label:d?"授课系统时钟":"System Clock",value:`${pt(c.getHours())}:${pt(c.getMinutes())}:${pt(c.getSeconds())}`,hint:d?"本地时间":"Local time"}];return e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[w.map(f=>{const N=f.icon;return e.jsxs("div",{className:"bg-surface border border-theme rounded-xl px-2.5 py-2 flex items-center gap-2 shadow-3xs min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-surface-secondary border border-theme-subtle flex items-center justify-center shrink-0",children:e.jsx(N,{size:14,className:"text-primary-theme"})}),e.jsxs("div",{className:"min-w-0 flex-1 leading-tight",children:[e.jsx("div",{className:"text-2xs text-muted truncate",title:f.label,children:f.label}),e.jsx("div",{className:`font-mono font-bold text-xs truncate ${f.tone?"":"text-main"}`,children:f.tone?e.jsx("span",{className:`px-1.5 py-0.5 rounded border ${f.tone}`,children:f.value}):f.value}),e.jsx("div",{className:"text-2xs text-subtle truncate",title:f.hint,children:f.hint})]})]},f.label)}),e.jsx(me,{slot:"classroom.portal.telemetry",lang:t})]})}function Zt({step:t,title:n,subtitle:a,aside:o,children:d,className:r}){return e.jsxs("section",{className:`bg-surface border border-theme rounded-2xl shadow-3xs p-4 ${r??""}`,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 mb-3.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t&&e.jsx("span",{className:"w-6 h-6 rounded-lg bg-primary-theme-light text-primary-theme border border-primary-theme font-bold text-2xs flex items-center justify-center shrink-0",children:t}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-bold text-sm text-main truncate",children:n}),a&&e.jsx("p",{className:"text-2xs text-muted truncate",children:a})]})]}),o&&e.jsx("div",{className:"shrink-0",children:o})]}),d]})}function Zo({lessons:t,selectedLesson:n,onSelect:a,onEditLesson:o,lang:d}){const r=d==="zh",[l,s]=i.useState(""),h=t.filter(c=>String(c.title??"").toLocaleLowerCase().includes(l.trim().toLocaleLowerCase()));return e.jsx(Zt,{step:"01",title:r?"选择授课课程":"Select Course",subtitle:r?`共 ${t.length} 门关联课`:`${t.length} courses available`,children:t.length===0?e.jsx("p",{className:"text-xs text-muted italic py-6 text-center",children:r?"暂无可用课程,请先在「课程管理」中创建课节":"No courses yet — create a lesson first"}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"relative block mb-3",children:[e.jsx(Lt,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"search","aria-label":r?"搜索课程":"Search courses",value:l,onChange:c=>s(c.target.value),placeholder:r?"搜索全部课程...":"Search all courses...",className:"w-full pl-8 pr-3 py-2 bg-surface-secondary border border-theme rounded-xl text-xs text-main placeholder-muted outline-none focus:border-primary-theme focus:ring-1 focus:ring-primary-theme"})]}),h.length===0?e.jsx("p",{className:"text-xs text-muted italic py-6 text-center",children:r?"没有匹配的课程":"No matching courses"}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 max-h-[28rem] overflow-y-auto",children:h.map(c=>{const u=c.id===n;return e.jsxs("div",{className:`rounded-xl border transition-all flex flex-col justify-between overflow-hidden ${u?"border-primary-theme bg-primary-theme-light shadow-3xs":"border-theme bg-surface hover:border-primary-theme/60 hover:bg-surface-secondary/60"}`,children:[e.jsxs("button",{type:"button",onClick:()=>a(c.id),"aria-pressed":u,className:"text-left p-3.5 pb-2 transition-all cursor-pointer flex flex-col gap-2 w-full focus:outline-none",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs font-mono font-bold text-muted",children:[e.jsx(It,{size:11}),r?"课节":"Lesson"]}),u?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-bold text-primary-theme",children:[e.jsx(Ce,{size:12}),r?"已选":"Selected"]}):e.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-theme"})]}),e.jsx("div",{className:"font-bold text-xs text-main line-clamp-2 leading-relaxed",children:c.title})]}),e.jsxs("div",{className:"px-3.5 pb-3 pt-1 flex items-center justify-between gap-2 text-2xs text-muted border-t border-theme/30 mt-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Rt,{size:11,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:Array.isArray(c.timeline)?r?`${c.timeline.length} 个环节`:`${c.timeline.length} segments`:r?"按默认时长授课":"Default pacing"})]}),o&&e.jsxs("button",{type:"button",onClick:m=>{m.stopPropagation(),o(c.id)},title:r?"进入课程编辑器":"Edit course in Lesson Editor",className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg text-2xs font-medium text-primary-theme hover:bg-primary-theme/15 active:scale-95 border border-primary-theme/30 transition-all cursor-pointer shrink-0",children:[e.jsx(or,{size:11}),e.jsx("span",{children:r?"编辑":"Edit"})]})]}),e.jsx(me,{slot:"classroom.portal.course_badge",lang:d,slotProps:{lessonId:c.id,lesson:c,isSelected:u}})]},c.id)})})]})})}function Xo({modes:t,selectedId:n,onSelect:a,loading:o,lang:d}){const r=d==="zh",l=t.slice(0,3);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-2xs font-semibold text-muted flex items-center gap-1.5",children:[e.jsx(hn,{size:13,className:"text-primary-theme"}),r?"开课默认授课模式:":"Default teaching mode:"]}),o?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[e.jsx(jt,{size:12,className:"animate-spin"}),r?"加载中…":"Loading…"]}):l.length===0?e.jsx("span",{className:"text-2xs text-subtle italic",children:r?"暂无可用模式":"No modes available"}):e.jsx("div",{role:"radiogroup","aria-label":r?"教学模式":"Teaching mode",className:"grid grid-cols-3 p-1 rounded-xl bg-surface-secondary border border-theme gap-1 min-w-[260px]",children:l.map(s=>{const h=s.id===n,c=Ko[s.icon]??Rt,u=zo(s.color);return e.jsxs("button",{type:"button",role:"radio","aria-checked":h,onClick:()=>a(s.id),title:r?s.description:s.descriptionEn??s.description,className:`px-2.5 py-1.5 rounded-lg text-2xs font-semibold transition-all cursor-pointer flex items-center justify-center gap-1.5 truncate ${h?`bg-surface border shadow-3xs ${u.chipActive}`:"text-muted hover:text-main hover:bg-surface/60 border border-transparent"}`,children:[e.jsx(c,{size:12,className:h?u.iconActive:""}),e.jsx("span",{className:"truncate",children:r?s.name:s.nameEn??s.name})]},s.id)})})]}),e.jsx(me,{slot:"classroom.portal.teaching_mode",lang:d,slotProps:{modes:t,selectedModeId:n,onSelect:a,registerHint:r?"插件可通过 classroom.portal.teaching_mode 槽位注册自定义教学模式":"Plugins can add modes via the classroom.portal.teaching_mode slot"}})]})}function ei({classes:t,students:n,selectedClassId:a,onSelectClass:o,classLocked:d=!1,onlineStudentIds:r,modes:l,selectedModeId:s,onSelectMode:h,modesLoading:c,fetcher:u,lang:m}){const p=m==="zh",[w,f]=i.useState(""),N=t.filter($=>String($.name??"").toLocaleLowerCase().includes(w.trim().toLocaleLowerCase())),b=n.filter($=>r.includes($.id)).length;return n.length&&Math.round(b/n.length*100),mr(),e.jsx(Zt,{step:"02",title:p?"挑选授课班级":"Pick Class",subtitle:d?ht(m):p?"选择本节课面向的班级":"Choose the class for this session",aside:e.jsxs("span",{className:"text-2xs font-semibold text-muted inline-flex items-center gap-1.5",children:[e.jsx(qe,{size:11,className:"text-emerald-500"}),p?`${b} 节点在线`:`${b} nodes online`]}),children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[d&&e.jsx("p",{"data-testid":"portal-class-lock-hint",role:"status",className:"text-xs font-semibold text-amber-800 bg-amber-50 border border-amber-200 rounded-lg px-3 py-2",children:ht(m)}),t.length===0?e.jsx("p",{className:"text-xs text-muted italic py-3 text-center",children:p?"暂无班级,请先在「班级管理」中创建":"No classes yet"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted",children:[e.jsx($e,{size:13,className:"text-primary-theme shrink-0"}),e.jsxs("span",{children:[p?`共 ${t.length} 个班级`:`${t.length} classes total`,w.trim()&&(p?` · 筛选出 ${N.length} 个`:` · ${N.length} matched`)]})]}),t.length>2&&e.jsxs("label",{className:"relative block w-44 sm:w-52 shrink-0",children:[e.jsx(Lt,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"search","aria-label":p?"搜索班级":"Search classes",value:w,onChange:$=>f($.target.value),placeholder:p?"筛选班级...":"Filter classes...",className:"w-full pl-7 pr-2.5 py-1 bg-surface-secondary border border-theme rounded-lg text-xs text-main placeholder-muted outline-none focus:border-primary-theme focus:ring-1 focus:ring-primary-theme transition-all"})]})]}),N.length===0?e.jsx("p",{className:"text-xs text-muted italic py-3 text-center",children:p?"没有匹配的班级":"No matching classes"}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2 max-h-48 overflow-y-auto",children:N.map($=>{const P=$.id===a;return e.jsxs("button",{type:"button",onClick:()=>{d||o($.id)},disabled:d,"aria-pressed":P,title:d?ht(m):void 0,className:`group text-left rounded-xl border px-3 py-2 transition-all flex items-center justify-between gap-2 min-w-0 ${d?"cursor-not-allowed opacity-80":"cursor-pointer"} ${P?"border-primary-theme bg-primary-theme-light shadow-3xs ring-1 ring-primary-theme/30":"border-theme bg-surface hover:border-primary-theme hover:bg-surface-secondary"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${P?"bg-primary-theme":"bg-muted/40 group-hover:bg-primary-theme/60"}`}),e.jsx("span",{className:"font-bold text-xs text-main truncate",children:$.name})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[$.student_count!==void 0&&e.jsxs("span",{className:"text-2xs font-mono text-muted",children:[$.student_count,p?"人":""]}),P&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-2xs font-bold text-primary-theme",children:[e.jsx(gt,{size:12,className:"stroke-[3]"}),e.jsx("span",{children:p?"已选":"Selected"})]})]})]},$.id)})})]}),a&&e.jsx(Uo,{classId:a,students:n,onlineStudentIds:r,lang:m,fetcher:u}),e.jsx(Xo,{modes:l,selectedId:s,onSelect:h,loading:c,lang:m})]})})}function ti({lessonTitle:t,className:n,seatCount:a,canLaunch:o,launching:d,onLaunch:r,lang:l}){const s=l==="zh";return e.jsxs("div",{className:"sticky bottom-4 z-20 bg-surface border border-theme rounded-2xl shadow-3xs px-4 py-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary-theme text-white flex items-center justify-center shrink-0",children:e.jsx(us,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-main truncate",children:s?"已锁定开课流水线":"Launch pipeline locked"}),e.jsx("span",{className:`text-2xs font-bold px-1.5 py-0.5 rounded border ${o?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800/70":"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800/70"}`,children:o?s?"配置完成":"Configured":s?"待配置":"Needs setup"})]}),e.jsxs("p",{className:"text-2xs text-muted truncate",children:[t||(s?"未选择课程":"No course selected"),n?` · ${n}`:"",a?` (${a}${s?"席":" seats"})`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(me,{slot:"classroom.portal.launch_action",lang:l,slotProps:{canLaunch:o}}),e.jsxs("button",{type:"button",onClick:r,disabled:!o||d,className:"inline-flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold bg-primary-theme text-white hover:bg-primary-theme-hover transition-colors shadow-3xs disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[d?e.jsx(jt,{size:13,className:"animate-spin"}):e.jsx(us,{size:13}),e.jsx("span",{children:s?"开始上课":"Start Class"}),e.jsx(Ns,{size:13})]})]})]})}function si({lessonTitle:t,timelineSegments:n,lang:a}){const o=a==="zh",d=o?"zh":"en",r=n??[],l=r.map(m=>dr(m,{fallbackSeconds:wn})),s=l.reduce((m,p)=>{const w=p.seconds;return w!=null&&Number.isFinite(w)?m+w:m},0),c=l.some(m=>m.seconds!=null&&Number.isFinite(m.seconds))?Math.round(s/60):null,u=c==null?o?"课堂节拍节奏设计(未设置)":"Pacing (unset)":o?`课堂节拍节奏设计(${c} 分钟)`:`Pacing (${c} min)`;return e.jsx(Zt,{title:o?"本节课教学蓝图":"Lesson Blueprint",subtitle:t||(o?"未选择课程":"No course selected"),children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xs font-bold text-subtle mb-1.5 flex items-center gap-1.5",children:[e.jsx(Rt,{size:11}),u]}),r.length===0?e.jsx("p",{className:"text-2xs text-muted italic",children:o?"暂未配置环节大纲,将在课中按默认时长授课":"No segments configured yet"}):e.jsx("ol",{className:"flex flex-col gap-1.5",children:r.slice(0,6).map((m,p)=>{const w=l[p]?.seconds??null,f=vn(w,d),N=w!=null&&s>0?Math.max(8,Math.round(w/s*100)):0;return e.jsxs("li",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-2xs",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-4 h-4 rounded bg-primary-theme-light text-primary-theme font-bold flex items-center justify-center shrink-0",children:p+1}),e.jsx("span",{className:"font-semibold text-main truncate",children:m.title})]}),e.jsx("span",{className:"font-mono text-muted shrink-0",children:f.compact})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary-theme",style:{width:`${N}%`}})})]},m.id||p)})})]})})})}function ri({students:t,onlineStudentIds:n,lang:a}){const o=a==="zh",d=t.filter(r=>!n.includes(r.id)).slice(0,2);return e.jsx(Zt,{title:o?"课前学生状态":"Pre-class Student Status",subtitle:o?"依据当前在线连接提示":"Based on current online connections",aside:e.jsx(ve,{size:13,className:"text-primary-theme"}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.length===0?e.jsx("p",{className:"text-2xs text-muted py-3 text-center",children:o?"当前班级没有学生名单,暂时无法判断在线状态":"No student roster is available to assess connections"}):d.length===0?e.jsxs("p",{className:"text-2xs text-muted py-3 text-center inline-flex items-center justify-center gap-1.5",children:[e.jsx(bs,{size:12,className:"text-emerald-500"}),o?"全员席位已连接,暂无需要关注的学生":"All seats connected — nothing needs attention"]}):d.map(r=>e.jsxs("div",{className:"rounded-xl border border-amber-200/80 bg-amber-50/70 dark:bg-amber-950/30 dark:border-amber-800/70 p-2.5 flex gap-2.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-surface border border-amber-200/80 dark:border-amber-800/70 flex items-center justify-center font-bold text-2xs text-amber-700 dark:text-amber-300 shrink-0",children:(r.name??"?").slice(0,1)}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-2xs font-bold text-main truncate",children:[r.name,r.student_number?e.jsxs("span",{className:"font-mono font-normal text-muted",children:[" · ",r.student_number]}):null]}),e.jsx("p",{className:"text-2xs text-muted leading-relaxed",children:o?"学生端尚未连接,建议课前确认设备或网络状态。":"Student端 not connected yet — check device or network."})]}),e.jsx(Ie,{size:12,className:"text-amber-500 shrink-0 mt-0.5"})]},r.id)),e.jsx(me,{slot:"classroom.portal.insight",lang:a,slotProps:{students:t,onlineStudentIds:n}})]})})}function ni({hasSelectedLesson:t,hasSelectedClass:n,seatCount:a,onlineCount:o,lang:d}){const r=d==="zh",{isOnline:l,quality:s,measuredAt:h}=mr(),c=[{icon:Ce,label:r?"课程与班级配置":"Course and class selection",value:t&&n?r?"已选择":"Selected":r?"待选择":"Select both",ok:t&&n},{icon:ar,label:r?"学生端在线连接":"Student connections",value:a?`${o}/${a} ${r?"在线":"online"}`:r?"暂无学生名单":"No roster",ok:a>0&&o===a},{icon:vs,label:r?"平台网络连接":"Platform network",value:h===null?r?"检测中":"Checking":l?s==="poor"?r?"时延偏高":"High latency":r?"网络可达":"Network reachable":r?"离线":"Offline",ok:h!==null&&l&&s!=="poor"}];return e.jsx(Zt,{title:r?"课前三项自检体检卡":"Pre-flight Checks",subtitle:r?"开课前环境自检":"Environment self-check",aside:e.jsx("span",{className:`text-2xs font-bold px-1.5 py-0.5 rounded border ${c.every(u=>u.ok)?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800/70":"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800/70"}`,children:c.every(u=>u.ok)?"ALL PASS":r?"需注意":"ATTENTION"}),children:e.jsxs("ul",{className:"flex flex-col gap-2",children:[c.map(u=>{const m=u.icon;return e.jsxs("li",{className:"flex items-center justify-between gap-2.5 text-2xs",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(m,{size:12,className:u.ok?"text-emerald-500":"text-amber-500"}),e.jsx("span",{className:"text-main truncate",children:u.label})]}),e.jsx("span",{className:`font-mono shrink-0 ${u.ok?"text-muted":"text-amber-700 dark:text-amber-400"}`,children:u.value})]},u.label)}),e.jsx(me,{slot:"classroom.portal.preflight",lang:d})]})})}function ai({lessons:t,classes:n,students:a,selectedLesson:o,setSelectedLesson:d,liveClassSelectedClassId:r,setLiveClassSelectedClassId:l,timelineSegments:s,onlineStudentIds:h,lang:c,addToast:u,onEditLesson:m,onEnterClassroom:p,onGoToTimetable:w,onOpenSessionManager:f,fetcher:N}){const b=c==="zh",[$,P]=i.useState([]),[y,k]=i.useState(null),[g,A]=i.useState(!0),[U,W]=i.useState(!1),T=i.useRef(!0);i.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),i.useEffect(()=>{let I=!1;return(async()=>{try{const B=await ko(N);if(I||!T.current)return;P(B),k(se=>se??B[0]?.id??null)}catch{!I&&T.current&&P([])}finally{!I&&T.current&&A(!1)}})(),()=>{I=!0}},[N]);const[Q,V]=i.useState(null),[le,F]=i.useState(!1);i.useEffect(()=>{let I=!1;const B=N??((...Z)=>fetch(...Z)),se=ur(),v=async Z=>{try{const ie=await B(`/api/schedules/today?date=${encodeURIComponent(Z)}`);if(!ie||!ie.ok)return null;const xe=await ie.json(),ke=[...xe?.success&&Array.isArray(xe.schedules)?xe.schedules:[]].sort((ze,ge)=>{const Ae=Us(ze?.time_slot),_e=Us(ge?.time_slot);return Ae===null&&_e===null?0:Ae===null?1:_e===null?-1:Ae-_e});for(const ze of ke){const ge=Us(ze?.time_slot);if(Z===se){if(ge===null)return _(ze,Z,null);const Ae=new Date().getHours()*60+new Date().getMinutes();if(ge>Ae)return _(ze,Z,ge)}else return _(ze,Z,ge)}return null}catch{return null}},_=(Z,ie,xe)=>Z?{id:String(Z.id??""),lesson_id:Z.lesson_id??null,lesson_title:Z.lesson_title||(b?"未设定内容":"Unspecified lesson"),class_id:String(Z.class_id??""),class_name:Z.class_name||(b?"未指定班级":"Unspecified class"),scheduled_date:String(Z.scheduled_date??ie),time_slot:Z.time_slot??null,startMinutes:xe}:null;return(async()=>{let Z=null;for(let ie=0;ie<7&&!Z;ie++){const xe=Jo(ie);if(ie===0?Z=await v(xe):Z=await v(xe),I)return}I||(V(Z),F(!0))})(),()=>{I=!0}},[N]);const[D,j]=i.useState(null),q=i.useRef(null),[ee,R]=i.useState(!1);i.useEffect(()=>{let I=!1;return j(null),q.current=null,o?((N??((...se)=>fetch(...se)))(`/api/classroom/sessions/${encodeURIComponent(o)}`).then(se=>se&&se.ok?se.json():null).then(se=>{if(I||!se?.hasActiveSession)return;const v=Cn(se.stage),_=se.session?.class_id?String(se.session.class_id):null;v&&(j({lessonId:o,stage:se.stage,classId:_,classLocked:!0}),_&&(q.current={lessonId:o,classId:_},l(_)))}).catch(()=>{}),()=>{I=!0}):void 0},[o,N,l]);const O=i.useMemo(()=>t.find(I=>I.id===o)??null,[t,o]),L=i.useMemo(()=>n.find(I=>I.id===r)??null,[n,r]),X=a.filter(I=>h.includes(I.id)).length,K=a.length?`${Math.round(X/a.length*100)}%`:"—",H=!!O&&!!L,re=new Date,te=Kr(re.getHours(),!0),de=Kr(re.getHours(),!1),G=i.useCallback(async()=>{if(!O)return;const I=D?.lessonId===O.id?D:null,B=(I?.classLocked?I.classId:null)??L?.id??I?.classId??null;if(B){R(!0);try{await p({lessonId:O.id,classId:B,teachingModeId:y})}catch(se){u?.(b?"回到课堂失败":"Failed to resume classroom",se instanceof Error?se.message:String(se),"error")}finally{T.current&&R(!1)}}},[D,u,L,O,p,y,b]),S=i.useCallback(()=>{if(!Q)return;const I=Q.lesson_id||null,B=q.current;if(B&&I===B.lessonId&&Q.class_id!==B.classId){I&&d(I),l(B.classId),u?.(b?"不能更换班级":"Class is locked",ht(c),"warning");return}I&&d(I),l(Q.class_id)},[u,c,Q,l,d,b]),M=i.useCallback(async()=>{if(!O||!L){u?.(b?"无法开课":"Cannot start",b?"请先选择课程与班级":"Select a course and a class first","warning");return}const I=D?.lessonId===O.id?D:null,B=I?.classLocked?I.classId:null;B&&L.id!==B&&(l(B),u?.(b?"不能更换班级":"Class is locked",ht(c),"warning"));const se=B||L.id;W(!0);try{await p({lessonId:O.id,classId:se,teachingModeId:y})}catch(v){u?.(b?"进入课堂失败":"Failed to enter classroom",v instanceof Error?v.message:String(v),"error")}finally{T.current&&W(!1)}},[D,u,L,O,c,p,y,l,b]);return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-app text-main",children:e.jsxs("div",{className:"p-4 md:p-6 flex flex-col gap-4 max-w-[1800px] mx-auto",children:[e.jsxs("section",{className:"bg-surface border border-theme rounded-2xl shadow-3xs p-5 flex flex-col lg:flex-row lg:items-center justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-2xs font-mono font-semibold px-2 py-0.5 rounded bg-surface-secondary border border-theme text-muted inline-flex items-center gap-1",children:[e.jsx(De,{size:10}),b?"今日教学排期 · 准备窗口":"Today · Preparation window"]}),O&&e.jsxs("span",{className:"text-2xs font-mono font-semibold px-2 py-0.5 rounded bg-primary-theme-light border border-primary-theme text-primary-theme inline-flex items-center gap-1",children:[e.jsx(Ht,{size:10}),O.title]})]}),Q?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-black tracking-tight text-main cursor-pointer hover:text-primary-theme transition-colors",role:"button",tabIndex:0,title:b?"点击预选该课并聚焦到该班级。进行中的本节课不能因此换班。":"Pre-select this lesson and class. An in-progress lesson keeps its class.",onClick:()=>S(),onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),S())},children:b?`${te}!下一节`:`${de}! Next up`}),e.jsxs("p",{className:"text-xs text-muted mt-1 leading-relaxed max-w-2xl inline-flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono",children:[e.jsx(Ka,{size:12,className:"text-primary-theme"}),Yo(Q.scheduled_date,b)]}),Q.time_slot&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono",children:[e.jsx(De,{size:12,className:"text-muted"}),Q.time_slot]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nr,{size:12,className:"text-muted"}),Q.class_name]})]})]}):le?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-black tracking-tight text-main",children:b?`${te}!今日课堂待开启`:`${de}! Ready to start`}),e.jsxs("p",{className:"text-xs text-muted mt-1 leading-relaxed max-w-2xl inline-flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:b?"今日课表尚未设置,先去安排本节内容吧。":"No schedule set for today yet."}),w&&e.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1 text-xs font-semibold text-primary-theme hover:text-primary-theme/80 transition-colors underline underline-offset-2",children:[e.jsx(Ja,{size:12}),b?"前往课表设置":"Open timetable settings",e.jsx(Ns,{size:12})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-black tracking-tight text-main",children:b?`${te}!今日课堂待开启`:`${de}! Ready to start`}),e.jsx("p",{className:"text-xs text-muted mt-1 leading-relaxed max-w-2xl",children:b?"请确认本节课程、授课班级与教学模式,确认无误后启动进入数字赋能课堂。":"Confirm the course, class and teaching mode, then launch the classroom."})]}),f&&e.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:e.jsxs("button",{type:"button",id:"classroom-portal-open-session-manager",onClick:f,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-surface border border-theme text-xs font-semibold text-main hover:bg-surface-secondary shadow-3xs hover:border-primary-theme/40 transition-all cursor-pointer",children:[e.jsx(un,{size:13,className:"text-primary-theme"}),e.jsx("span",{children:b?"课堂会话与档案管理":"Session Management"})]})})]}),e.jsx("div",{className:"xl:w-[620px] shrink-0",children:e.jsx(Qo,{lang:c,seatCount:a.length,onlineCount:X,readinessRate:K})})]}),D&&O&&e.jsxs("section",{"data-testid":"active-session-banner",className:"bg-emerald-50 border border-emerald-200 rounded-2xl p-4 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-emerald-500"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-emerald-800 truncate",children:b?`课堂进行中:${O.title}`:`Class in progress: ${O.title}`}),e.jsx("p",{className:"text-xs text-emerald-600 mt-0.5",children:b?"学生数据、作业与课堂动态均已保存,点击右侧回到当前状态。":"Student data, assignments and feed are saved. Resume to continue."})]})]}),e.jsx("button",{onClick:()=>void G(),disabled:ee||!(L||D?.classId),className:"shrink-0 inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:ee?b?"恢复中…":"Resuming…":b?"回到课堂":"Resume"})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"xl:col-span-8 flex flex-col gap-4 min-w-0",children:[e.jsx(Zo,{lessons:t,selectedLesson:o,onSelect:I=>d(I),onEditLesson:m,lang:c}),e.jsx(ei,{classes:n,students:a,selectedClassId:r,onSelectClass:I=>{D?.classLocked||l(I)},classLocked:!!(D?.classLocked&&D.lessonId===o),onlineStudentIds:h,modes:$,selectedModeId:y,onSelectMode:k,modesLoading:g,fetcher:N,lang:c}),e.jsx(ti,{lessonTitle:O?.title??"",className:L?.name??"",seatCount:a.length,canLaunch:H,launching:U,onLaunch:()=>void M(),lang:c})]}),e.jsxs("div",{className:"xl:col-span-4 flex flex-col gap-4 min-w-0",children:[e.jsx(si,{lessonTitle:O?.title??"",timelineSegments:s,lang:c}),e.jsx(ri,{students:a,onlineStudentIds:h,lang:c}),e.jsx(ni,{hasSelectedLesson:!!O,hasSelectedClass:!!L,seatCount:a.length,onlineCount:X,lang:c})]})]})]})})}function oi({isOpen:t,onClose:n,onConfirm:a,sessionTitle:o,className:d,stageLabel:r,isDeleting:l=!1,lang:s="zh"}){if(i.useEffect(()=>{if(!t||l)return;const c=u=>{u.key==="Escape"&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t,l,n]),!t)return null;const h=s==="zh";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-in fade-in duration-200",role:"dialog","aria-modal":"true","aria-labelledby":"delete-session-modal-title",onClick:()=>{l||n()},children:e.jsxs("div",{className:"w-full max-w-md bg-surface border border-theme rounded-2xl shadow-2xl p-6 relative overflow-hidden",onClick:c=>c.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:n,disabled:l,className:"absolute top-4 right-4 p-1.5 rounded-lg text-muted hover:text-main hover:bg-surface-secondary transition-colors","aria-label":h?"关闭":"Close",children:e.jsx(we,{size:18})}),e.jsxs("div",{className:"flex items-start gap-3.5 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-rose-500/10 text-rose-600 flex items-center justify-center shrink-0 border border-rose-500/20",children:e.jsx(Ie,{size:20})}),e.jsxs("div",{className:"min-w-0 pr-6",children:[e.jsx("h3",{id:"delete-session-modal-title",className:"text-base font-bold text-main",children:h?"删除课堂会话":"Delete Classroom Session"}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:h?"此操作将彻底删除会话记录,且不可撤销":"This action is irreversible and cannot be undone"})]})]}),e.jsxs("div",{className:"bg-surface-secondary border border-theme rounded-xl p-3.5 mb-4 text-xs space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:h?"关联课节:":"Course:"}),e.jsx("span",{className:"font-semibold text-main truncate max-w-[220px]",children:o})]}),d&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:h?"授课班级:":"Class:"}),e.jsx("span",{className:"font-medium text-main",children:d})]}),r&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:h?"当前状态:":"Stage:"}),e.jsx("span",{className:"font-medium text-main",children:r})]})]}),e.jsx("div",{className:"text-xs text-rose-600/90 bg-rose-50 dark:bg-rose-950/30 border border-rose-200 dark:border-rose-900/50 rounded-xl p-3 mb-5 leading-relaxed",children:h?"⚠️ 提示:删除会话将一并清理本次课堂关联的随堂测试、即时投票、抢答、结课通票提交及互动动态流数据。":"⚠️ Notice: Deleting this session will cascade clean all quick polls, buzzers, exit ticket submissions, and interaction feeds associated with it."}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5",children:[e.jsx("button",{type:"button",onClick:n,disabled:l,className:"px-4 py-2 rounded-xl border border-theme text-xs font-semibold text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer disabled:opacity-50",children:h?"取消":"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void a(),disabled:l,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-xl bg-rose-600 hover:bg-rose-700 text-white text-xs font-bold shadow-sm transition-all cursor-pointer disabled:opacity-50",children:[l?e.jsx(jt,{size:14,className:"animate-spin"}):e.jsx(et,{size:14}),e.jsx("span",{children:l?h?"删除中...":"Deleting...":h?"确认删除":"Delete"})]})]})]})})}function ii(t,n,a,o){if(!t)return o?"未开课":"Not started";const d=n||Date.now(),r=Math.max(0,Math.floor((d-t)/1e3)),l=Math.floor(r/60),s=Math.floor(l/60);return a!=="ARCHIVED_REPORT"?o?`已进行 ${l} 分钟`:`${l}m elapsed`:s>0?o?`${s}小时${l%60}分`:`${l} 分钟`:o?`${l} 分钟`:`${l} mins`}function li(t){if(!t)return"—";const n=new Date(t),a=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${a(n.getMonth()+1)}-${a(n.getDate())} ${a(n.getHours())}:${a(n.getMinutes())}`}function ci({lessons:t,classes:n,lang:a="zh",onBackToPortal:o,onResumeSession:d,onViewReport:r,onSessionArchived:l,onSessionDeleted:s,addToast:h}){const c=a==="zh",u=i.useRef(h);i.useEffect(()=>{u.current=h},[h]);const[m,p]=i.useState([]),[w,f]=i.useState(0),[N,b]=i.useState(1),$=10,[P,y]=i.useState(!1),[k,g]=i.useState("all"),[A,U]=i.useState(""),[W,T]=i.useState(""),[Q,V]=i.useState(""),[le,F]=i.useState("");i.useEffect(()=>{const G=setTimeout(()=>{F(Q)},250);return()=>clearTimeout(G)},[Q]);const[D,j]=i.useState(null),[q,ee]=i.useState(null),[R,O]=i.useState(!1),L=i.useRef(null),X=i.useCallback(async()=>{L.current?.abort();const G=new AbortController;L.current=G,y(!0);try{const S=new URLSearchParams;S.set("page",String(N)),S.set("pageSize",String($)),k!=="all"&&S.set("status",k),A&&S.set("lessonId",A),W&&S.set("classId",W),le.trim()&&S.set("search",le.trim());const M=await fetch(`/api/classroom/sessions?${S.toString()}`,{signal:G.signal});if(!M.ok)throw new Error(`HTTP ${M.status}`);const I=await M.json();if(G.signal.aborted)return;p(I.items||[]),f(I.total||0)}catch(S){if(S?.name==="AbortError"||G.signal.aborted)return;console.error("Failed to fetch sessions:",S),u.current?.(c?"加载会话失败":"Failed to load sessions",S.message||(c?"网络请求异常":"Network error"),"error")}finally{G.signal.aborted||y(!1)}},[N,k,A,W,le,c]);i.useEffect(()=>(X(),()=>{L.current?.abort()}),[X]);const K=async G=>{const S=m.find(M=>M.id===G);j(G);try{const M=await fetch(`/api/classroom/sessions/${G}/archive`,{method:"POST"});if(!M.ok){const I=await M.json().catch(()=>({}));throw new Error(I.error||`HTTP ${M.status}`)}u.current?.(c?"归档成功":"Archived successfully",c?"会话已移入已归档档案库":"Session moved to archived reports","success"),S&&l?.(S),X()}catch(M){u.current?.(c?"归档失败":"Failed to archive",M.message||(c?"未知错误":"Unknown error"),"error")}finally{j(null)}},H=async()=>{if(!q)return;const G=q;O(!0);try{const S=await fetch(`/api/classroom/sessions/${G.id}`,{method:"DELETE"});if(!S.ok){const M=await S.json().catch(()=>({}));throw new Error(M.error||`HTTP ${S.status}`)}u.current?.(c?"删除成功":"Deleted successfully",c?"会话及其关联数据已彻底清理":"Session and cascaded data removed","success"),ee(null),s?.(G),X()}catch(S){u.current?.(c?"删除失败":"Failed to delete",S.message||(c?"未知错误":"Unknown error"),"error")}finally{O(!1)}},re=i.useMemo(()=>m.filter(G=>G.stage!=="ARCHIVED_REPORT").length,[m]),te=Math.max(1,Math.ceil(w/$)),de=G=>{switch(G){case"IN_CLASS_TEACHING":return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-2xs font-bold bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800/60",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),c?"授课进行中":"In Progress"]});case"WRAP_UP_EXIT_TICKET":return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-2xs font-bold bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-400 border border-amber-200 dark:border-amber-800/60",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500"}),c?"结课通票中":"Wrap-up Ticket"]});case"PRE_CLASS_READY":return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-2xs font-bold bg-blue-50 text-blue-700 dark:bg-blue-950/40 dark:text-blue-400 border border-blue-200 dark:border-blue-800/60",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-400"}),c?"课前准备":"Pre-class Ready"]});case"ARCHIVED_REPORT":default:return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-2xs font-medium bg-surface-secondary text-muted border border-theme",children:[e.jsx(Pt,{size:11}),c?"已归档战报":"Archived"]})}};return e.jsxs("div",{className:"flex-1 flex flex-col h-full min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden font-sans",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-theme bg-surface-secondary/70 flex flex-col sm:flex-row sm:items-center justify-between gap-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{type:"button",onClick:o,className:"p-2 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-muted hover:text-main transition-colors shrink-0 shadow-3xs cursor-pointer",title:c?"返回课堂启动门户":"Back to entry portal",children:e.jsx(sn,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-base font-bold text-main truncate",children:c?"课堂会话与档案管理":"Classroom Sessions & Archive"}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme border border-primary-theme/20 text-2xs font-bold",children:[w," ",c?"场会话":"Sessions"]})]}),e.jsx("p",{className:"text-xs text-muted mt-0.5 truncate",children:c?"查看、恢复当前活跃授课或归档历史课节记录,支持级联安全清理":"Manage, resume, archive or delete interactive classroom session lifecycles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 self-end sm:self-auto shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>void X(),disabled:P,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main transition-colors shadow-3xs cursor-pointer disabled:opacity-50",children:[e.jsx(Pe,{size:13,className:P?"animate-spin":""}),e.jsx("span",{children:c?"刷新列表":"Refresh"})]}),e.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-primary-theme text-white text-xs font-bold shadow-sm hover:brightness-105 transition-all cursor-pointer",children:[e.jsx(ve,{size:13}),e.jsx("span",{children:c?"前往开课门户":"Launch New Class"})]})]})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-theme bg-surface grid grid-cols-2 sm:grid-cols-4 gap-3 shrink-0",children:[e.jsxs("div",{className:"bg-surface-secondary/50 border border-theme rounded-xl px-3.5 py-2.5 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/10 text-emerald-600 flex items-center justify-center shrink-0",children:e.jsx(qe,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-2xs text-muted font-medium",children:c?"本页进行中会话":"Active on Page"}),e.jsx("p",{className:"text-sm font-bold text-main",children:re})]})]}),e.jsxs("div",{className:"bg-surface-secondary/50 border border-theme rounded-xl px-3.5 py-2.5 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/10 text-purple-600 flex items-center justify-center shrink-0",children:e.jsx(Pt,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-2xs text-muted font-medium",children:c?"全部会话记录":"Total Sessions"}),e.jsx("p",{className:"text-sm font-bold text-main",children:w})]})]}),e.jsxs("div",{className:"bg-surface-secondary/50 border border-theme rounded-xl px-3.5 py-2.5 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/10 text-blue-600 flex items-center justify-center shrink-0",children:e.jsx(It,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-2xs text-muted font-medium",children:c?"关联课程数":"Lessons"}),e.jsx("p",{className:"text-sm font-bold text-main",children:t.length})]})]}),e.jsxs("div",{className:"bg-surface-secondary/50 border border-theme rounded-xl px-3.5 py-2.5 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-500/10 text-amber-600 flex items-center justify-center shrink-0",children:e.jsx(nr,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-2xs text-muted font-medium",children:c?"关联班级数":"Classes"}),e.jsx("p",{className:"text-sm font-bold text-main",children:n.length})]})]})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-theme bg-surface flex flex-wrap items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"inline-flex p-1 bg-surface-secondary border border-theme rounded-xl text-xs font-semibold",children:[e.jsx("button",{type:"button",onClick:()=>{g("all"),b(1)},className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${k==="all"?"bg-surface text-main shadow-3xs font-bold":"text-muted hover:text-main"}`,children:c?"全部会话":"All"}),e.jsx("button",{type:"button",onClick:()=>{g("active"),b(1)},className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${k==="active"?"bg-surface text-emerald-600 dark:text-emerald-400 shadow-3xs font-bold":"text-muted hover:text-main"}`,children:c?"进行中":"Active"}),e.jsx("button",{type:"button",onClick:()=>{g("archived"),b(1)},className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${k==="archived"?"bg-surface text-purple-600 dark:text-purple-400 shadow-3xs font-bold":"text-muted hover:text-main"}`,children:c?"已归档":"Archived"})]}),e.jsxs("select",{value:A,onChange:G=>{U(G.target.value),b(1)},className:"px-3 py-1.5 bg-surface-secondary border border-theme rounded-xl text-xs text-main outline-none focus:border-primary-theme",children:[e.jsx("option",{value:"",children:c?"全部课节":"All Lessons"}),t.map(G=>e.jsx("option",{value:G.id,children:G.title},G.id))]}),e.jsxs("select",{value:W,onChange:G=>{T(G.target.value),b(1)},className:"px-3 py-1.5 bg-surface-secondary border border-theme rounded-xl text-xs text-main outline-none focus:border-primary-theme",children:[e.jsx("option",{value:"",children:c?"全部班级":"All Classes"}),n.map(G=>e.jsx("option",{value:G.id,children:G.name},G.id))]})]}),e.jsxs("div",{className:"relative min-w-[200px] max-w-xs flex-1",children:[e.jsx(Lt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"search",value:Q,onChange:G=>{V(G.target.value),b(1)},placeholder:c?"搜索课程、班级或会话 ID...":"Search course, class...",className:"w-full pl-8 pr-3 py-1.5 bg-surface-secondary border border-theme rounded-xl text-xs text-main placeholder-muted outline-none focus:border-primary-theme"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 min-h-0",children:P&&m.length===0?e.jsxs("div",{className:"h-64 flex flex-col items-center justify-center text-muted gap-3",children:[e.jsx(jt,{className:"w-7 h-7 animate-spin text-primary-theme"}),e.jsx("p",{className:"text-xs",children:c?"正在加载课堂会话数据...":"Loading classroom sessions..."})]}):m.length===0?e.jsxs("div",{className:"h-64 border border-dashed border-theme rounded-2xl flex flex-col items-center justify-center text-muted gap-3 p-6 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-secondary flex items-center justify-center text-muted",children:e.jsx(Gr,{size:24})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-main",children:c?"暂无匹配的课堂会话":"No classroom sessions found"}),e.jsx("p",{className:"text-xs text-muted mt-1 max-w-sm",children:c?"当前筛选条件下没有找到授课记录。您可以前往开课门户发起新课堂。":"No records under current filters. You can launch a new classroom session."})]}),e.jsx("button",{type:"button",onClick:o,className:"mt-2 px-4 py-2 rounded-xl bg-primary-theme text-white text-xs font-bold shadow-xs hover:brightness-105 transition-all cursor-pointer",children:c?"前往开课门户":"Launch New Class"})]}):e.jsx("div",{className:"grid grid-cols-1 gap-3.5",children:m.map(G=>{const S=G.stage==="ARCHIVED_REPORT",M=D===G.id;return e.jsxs("div",{className:"bg-surface border border-theme hover:border-primary-theme/40 rounded-2xl p-4.5 shadow-3xs hover:shadow-2xs transition-all flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center shrink-0 border ${S?"bg-surface-secondary text-muted border-theme":"bg-emerald-500/10 text-emerald-600 border-emerald-500/20"}`,children:S?e.jsx(yt,{size:22}):e.jsx(qe,{size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("h4",{className:"text-sm font-bold text-main truncate max-w-md",children:G.lessonTitle}),de(G.stage),G.teachingModeName&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg bg-surface-secondary text-muted border border-theme text-2xs font-semibold",children:G.teachingModeName}),G.checkinCode&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-2xs font-mono bg-blue-50 dark:bg-blue-950/40 text-blue-600 dark:text-blue-400 border border-blue-200 dark:border-blue-900/40",children:c?`签到码 ${G.checkinCode}`:`Code ${G.checkinCode}`})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx($e,{size:13,className:"shrink-0"}),e.jsx("span",{className:"font-medium text-main/90",children:G.className})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(De,{size:13,className:"shrink-0"}),e.jsx("span",{children:ii(G.startedAt,G.endedAt,G.stage,c)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs",children:[e.jsx(Gr,{size:12,className:"shrink-0"}),e.jsx("span",{children:li(G.createdAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs px-2 py-0.5 rounded-md bg-surface-secondary border border-theme text-muted",title:c?"随堂快速投票":"Quick polls",children:[e.jsx(Qa,{size:11}),e.jsx("span",{children:c?`${G.stats.pollCount} 次互动投票`:`${G.stats.pollCount} polls`})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs px-2 py-0.5 rounded-md bg-surface-secondary border border-theme text-muted",title:c?"结课通票提交数":"Exit ticket submissions",children:[e.jsx(Ce,{size:11}),e.jsx("span",{children:c?`${G.stats.exitTicketCount} 份结课通票`:`${G.stats.exitTicketCount} exit tickets`})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 self-end lg:self-auto border-t lg:border-t-0 pt-3 lg:pt-0 border-theme w-full lg:w-auto justify-end",children:[S?r&&e.jsxs("button",{type:"button",onClick:()=>r(G),className:"inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-primary-theme text-xs font-bold transition-colors cursor-pointer",children:[e.jsx(tn,{size:13}),e.jsx("span",{children:c?"查看战报":"Report"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>d(G),className:"inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-bold shadow-xs transition-colors cursor-pointer",children:[e.jsx(ys,{size:13}),e.jsx("span",{children:c?"进入课堂":"Resume"})]}),e.jsxs("button",{type:"button",onClick:()=>void K(G.id),disabled:M,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-amber-300 dark:border-amber-800/60 bg-amber-50 dark:bg-amber-950/30 hover:bg-amber-100 text-amber-700 dark:text-amber-300 text-xs font-bold transition-colors cursor-pointer disabled:opacity-50",children:[M?e.jsx(jt,{size:13,className:"animate-spin"}):e.jsx(Pt,{size:13}),e.jsx("span",{children:c?"一键归档":"Archive"})]})]}),e.jsx("button",{type:"button",onClick:()=>ee(G),className:"p-1.5 rounded-xl border border-theme hover:border-rose-300 hover:bg-rose-50 dark:hover:bg-rose-950/30 text-muted hover:text-rose-600 transition-colors cursor-pointer",title:c?"删除此会话":"Delete session",children:e.jsx(et,{size:14})})]})]},G.id)})})}),te>1&&e.jsxs("div",{className:"px-6 py-3 border-t border-theme bg-surface-secondary/40 flex items-center justify-between text-xs text-muted shrink-0",children:[e.jsx("div",{children:c?`第 ${(N-1)*$+1} - ${Math.min(N*$,w)} 条,共 ${w} 条会话`:`Showing ${(N-1)*$+1} - ${Math.min(N*$,w)} of ${w}`}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>b(G=>Math.max(1,G-1)),disabled:N<=1,className:"px-3 py-1 rounded-lg border border-theme bg-surface disabled:opacity-40 hover:bg-surface-secondary transition-colors cursor-pointer disabled:cursor-not-allowed font-medium text-main",children:c?"上一页":"Previous"}),e.jsxs("span",{className:"px-2 font-semibold text-main",children:[N," / ",te]}),e.jsx("button",{type:"button",onClick:()=>b(G=>Math.min(te,G+1)),disabled:N>=te,className:"px-3 py-1 rounded-lg border border-theme bg-surface disabled:opacity-40 hover:bg-surface-secondary transition-colors cursor-pointer disabled:cursor-not-allowed font-medium text-main",children:c?"下一页":"Next"})]})]}),e.jsx(oi,{isOpen:!!q,onClose:()=>ee(null),onConfirm:H,sessionTitle:q?.lessonTitle||"",className:q?.className,stageLabel:q?c?"已选会话":"Selected":void 0,isDeleting:R,lang:a})]})}const di={IN_CLASS_TEACHING:{zh:"授课进行中",en:"In Progress",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400 border-emerald-200 dark:border-emerald-800/60"},WRAP_UP_EXIT_TICKET:{zh:"结课出门票中",en:"Wrap-up Ticket",cls:"bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-400 border-amber-200 dark:border-amber-800/60"},PRE_CLASS_READY:{zh:"课前准备",en:"Pre-class Ready",cls:"bg-blue-50 text-blue-700 dark:bg-blue-950/40 dark:text-blue-400 border-blue-200 dark:border-blue-800/60"}};function xi(t,n){const a=di[t];return a?{text:n?a.zh:a.en,cls:a.cls}:{text:t||"—",cls:"bg-surface-secondary text-muted border-theme"}}function mi(t,n){if(!t)return n?"未开课":"Not started";const a=Math.max(0,Math.floor((Date.now()-t)/1e3/60));if(a<60)return n?`已进行 ${a} 分钟`:`${a}m elapsed`;const o=Math.floor(a/60);return n?`已进行 ${o} 小时 ${a%60} 分`:`${o}h ${a%60}m elapsed`}function ui(t,n){if(!t)return n?"未开课":"Not started";const a=new Date(t),o=d=>String(d).padStart(2,"0");return`${o(a.getMonth()+1)}-${o(a.getDate())} ${o(a.getHours())}:${o(a.getMinutes())}`}function hi({lang:t="zh",currentLessonId:n,onResume:a,onStartNew:o,onOpenArchive:d,onEmpty:r,addToast:l}){const s=t==="zh",[h,c]=i.useState(null),[u,m]=i.useState(null),[p,w]=i.useState(!1),[f,N]=i.useState(null),[b,$]=i.useState(null),P=i.useRef(l),y=i.useRef(r),k=i.useRef(!1);i.useEffect(()=>{P.current=l},[l]),i.useEffect(()=>{y.current=r},[r]);const g=i.useCallback(async(W=!1)=>{W&&w(!0);try{const T=await fetch("/api/classroom/sessions?status=active&pageSize=all");if(!T.ok)throw new Error(`HTTP ${T.status}`);const Q=await T.json(),V=Array.isArray(Q?.items)?Q.items:[];c(V),m(null),V.length===0&&!k.current&&(k.current=!0,y.current())}catch(T){m(T?.message||(s?"网络请求异常":"Network error"))}finally{w(!1)}},[s]);i.useEffect(()=>{g();const W=setInterval(()=>void g(),15e3);return()=>clearInterval(W)},[g]);const A=async W=>{N(W.id);try{const T=await fetch(`/api/classroom/sessions/${W.id}/archive`,{method:"POST"});if(!T.ok){const Q=await T.json().catch(()=>({}));throw new Error(Q?.error||`HTTP ${T.status}`)}P.current?.(s?"已结束并归档":"Session archived",s?"该会话已移出进行中列表":"The session was moved out of the in-progress list","success"),$(null),c(Q=>Q&&Q.filter(V=>V.id!==W.id)),g(!0)}catch(T){P.current?.(s?"归档失败":"Failed to archive",T?.message||(s?"未知错误":"Unknown error"),"error")}finally{N(null)}};if(h===null&&!u)return e.jsxs("div",{"data-testid":"in-progress-sessions-loading",className:"flex-1 flex items-center justify-center gap-2 text-sm text-muted",children:[e.jsx(jt,{size:16,className:"animate-spin"}),s?"正在加载进行中的课堂会话…":"Loading in-progress sessions…"]});if(u)return e.jsxs("div",{"data-testid":"in-progress-sessions-error",className:"flex-1 flex flex-col items-center justify-center gap-3 text-sm text-muted",children:[e.jsx("span",{children:s?"加载进行中的会话失败":"Failed to load in-progress sessions"}),e.jsx("span",{className:"text-xs",children:u}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{m(null),g(!0)},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main cursor-pointer",children:[e.jsx(Pe,{size:13}),s?"重试":"Retry"]}),e.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-primary-theme text-white text-xs font-bold cursor-pointer",children:[e.jsx(Tt,{size:13}),s?"开始一节新课":"Start a new lesson"]})]})]});const U=(h??[]).slice().sort((W,T)=>{const Q=n&&W.lessonId===n?1:0,V=n&&T.lessonId===n?1:0;return Q!==V?V-Q:(T.startedAt??T.createdAt)-(W.startedAt??W.createdAt)});return e.jsxs("div",{"data-testid":"in-progress-session-list",className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden font-sans",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-theme bg-surface-secondary/70 flex flex-col sm:flex-row sm:items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"text-base font-bold text-main flex items-center gap-2",children:[e.jsx(qe,{size:16,className:"text-emerald-500"}),s?"进行中的课堂会话":"In-progress classroom sessions"]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:s?"选择一场继续上课,或开始一节新课。进行中的课不能换班。":"Resume a session or start a new lesson. An in-progress session keeps its class."})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 self-end sm:self-auto",children:[e.jsxs("button",{type:"button",onClick:()=>void g(!0),disabled:p,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main cursor-pointer disabled:opacity-50",children:[e.jsx(Pe,{size:13,className:p?"animate-spin":""}),s?"刷新":"Refresh"]}),e.jsxs("button",{type:"button",onClick:d,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main cursor-pointer",children:[e.jsx(Pt,{size:13}),s?"全部会话档案":"All sessions"]}),e.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-primary-theme text-white text-xs font-bold shadow-sm hover:brightness-105 cursor-pointer",children:[e.jsx(Tt,{size:13}),s?"开始一节新课":"Start a new lesson"]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:U.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-sm text-muted",children:[e.jsx("span",{children:s?"当前没有进行中的课堂会话":"No in-progress sessions right now"}),e.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-primary-theme text-white text-xs font-bold cursor-pointer",children:[e.jsx(Tt,{size:13}),s?"开始一节新课":"Start a new lesson"]})]}):U.map(W=>{const T=xi(W.stage,s),Q=!!(n&&W.lessonId===n),V=b===W.id;return e.jsxs("div",{"data-testid":`in-progress-session-${W.id}`,"data-current":Q?"true":"false",className:`bg-surface border rounded-xl px-4 py-3 flex flex-col lg:flex-row lg:items-center gap-3 ${Q?"border-emerald-400/70 ring-1 ring-emerald-400/40":"border-theme"}`,children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-sm text-main truncate max-w-[320px]",children:W.lessonTitle}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-2xs font-bold border ${T.cls}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),T.text]}),Q&&e.jsx("span",{className:"px-2 py-0.5 rounded-full text-2xs font-bold bg-primary-theme/10 text-primary-ink border border-primary-theme/25",children:s?"当前课节":"Current lesson"})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-2xs text-muted",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx($e,{size:11}),W.className]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(De,{size:11}),mi(W.startedAt,s)]}),e.jsx("span",{className:"inline-flex items-center gap-1",title:s?"开课时间":"Started at",children:ui(W.startedAt,s)}),e.jsxs("span",{className:"inline-flex items-center gap-1",title:s?"已进入本节课堂且在线的学生数":"Students currently in this live class",children:[e.jsx($e,{size:11,className:"text-emerald-500"}),s?`在场 ${W.presentCount??0} 人`:`${W.presentCount??0} present`]}),W.teachingModeName&&e.jsx("span",{className:"truncate max-w-[160px]",children:W.teachingModeName})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>a(W),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-700 text-white text-xs font-bold shadow-sm hover:bg-emerald-800 cursor-pointer",children:[e.jsx(ys,{size:13}),s?"继续上课":"Resume"]}),V?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>void A(W),disabled:f===W.id,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-rose-600 text-white text-xs font-bold cursor-pointer disabled:opacity-50",children:[f===W.id?e.jsx(jt,{size:13,className:"animate-spin"}):e.jsx(Pt,{size:13}),s?"确认归档":"Confirm archive"]}),e.jsx("button",{type:"button",onClick:()=>$(null),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main cursor-pointer",children:s?"取消":"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>$(W.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main cursor-pointer",children:[e.jsx(Pt,{size:13}),s?"结束并归档":"End & archive"]})]})]},W.id)})})]})}const Qs="openlearn.liveClass.activeLessonId";function $n(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function dt(t){try{const n=$n();if(!n)return;t?n.setItem(Qs,t):n.removeItem(Qs)}catch{}}function pi(){try{return $n()?.getItem(Qs)??null}catch{return null}}const fi=({concepts:t,totalFeedbackCount:n,avgRating:a,tierDistribution:o={passed:18,remediation:6,challenge_done:8},onOpenKnowledgeTree:d,lang:r="zh"})=>{const[l,s]=i.useState(0),[h,c]=i.useState(null),u=(p,w)=>{navigator.clipboard.writeText(p),c(w),setTimeout(()=>c(null),2e3)},m=o.passed+o.remediation+o.challenge_done||1;return e.jsxs("div",{"data-testid":"concept-wordcloud-panel",className:"bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-4 text-main",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-amber-500/10 text-amber-500 flex items-center justify-center font-bold",children:e.jsx(tr,{size:16})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:e.jsx("span",{children:r==="zh"?"全班困惑概念聚类词云与收口总结":"Top Puzzled Concepts & Summary"})}),e.jsxs("p",{className:"text-3xs text-muted",children:[n," ",r==="zh"?"份真实结课通票聚类分析":"student tickets analyzed"]})]})]}),d&&e.jsxs("button",{type:"button",onClick:d,className:"px-3 py-1.5 rounded-xl bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-600 hover:to-amber-700 text-white font-extrabold text-xs flex items-center gap-1.5 shadow-xs transition-all cursor-pointer hover:scale-[1.02]",children:[e.jsx(ds,{size:14}),e.jsx("span",{children:r==="zh"?"🌟 点亮本堂课知识树":"Light Up Knowledge Tree"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 p-2.5 rounded-xl bg-surface-secondary/60 border border-theme/60 text-center text-xs",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-3xs text-muted font-bold",children:r==="zh"?"思维跃迁(挑战完成)":"Challenge Done"}),e.jsxs("span",{className:"font-mono font-black text-emerald-600 text-sm mt-0.5",children:[o.challenge_done," ",e.jsxs("span",{className:"text-3xs text-muted",children:["(",Math.round(o.challenge_done/m*100),"%)"]})]})]}),e.jsxs("div",{className:"flex flex-col items-center border-x border-theme/60",children:[e.jsx("span",{className:"text-3xs text-muted font-bold",children:r==="zh"?"基础通关(掌握良好)":"Core Passed"}),e.jsxs("span",{className:"font-mono font-black text-indigo-600 text-sm mt-0.5",children:[o.passed," ",e.jsxs("span",{className:"text-3xs text-muted",children:["(",Math.round(o.passed/m*100),"%)"]})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-3xs text-muted font-bold",children:r==="zh"?"支架补强(存在卡点)":"Remediation"}),e.jsxs("span",{className:"font-mono font-black text-rose-500 text-sm mt-0.5",children:[o.remediation," ",e.jsxs("span",{className:"text-3xs text-muted",children:["(",Math.round(o.remediation/m*100),"%)"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("span",{className:"text-2xs font-extrabold text-muted uppercase tracking-wider flex items-center gap-1",children:[e.jsx(Ie,{size:12,className:"text-amber-500"}),e.jsx("span",{children:r==="zh"?"点击气泡展开 2 分钟收口教学建议:":"Click bubble for 2-min recap advice:"})]}),e.jsx("div",{className:"flex flex-wrap gap-2.5 pt-1",children:t.map((p,w)=>{const f=l===w,N=w===0?"text-xs px-3.5 py-1.5":w===1?"text-xs px-3 py-1.2":"text-2xs px-2.5 py-1";return e.jsxs("button",{type:"button",onClick:()=>s(f?null:w),className:`rounded-2xl font-bold flex items-center gap-1.5 transition-all cursor-pointer border shadow-2xs ${N} ${f?"bg-amber-700 text-white border-amber-800 ring-2 ring-amber-400/40 scale-105":"bg-amber-500/10 text-amber-800 dark:text-amber-200 border-amber-500/30 hover:bg-amber-500/20"}`,children:[e.jsx("span",{children:"🔥"}),e.jsx("span",{children:p.concept}),e.jsxs("span",{className:`font-mono text-3xs px-1.5 py-0.2 rounded-full ${f?"bg-amber-700/60 text-white":"bg-surface border border-theme text-muted"}`,children:[p.frequency,"人"]}),f?e.jsx(Xs,{size:12}):e.jsx(Ut,{size:12})]},p.concept)})})]}),l!==null&&t[l]&&e.jsxs("div",{"data-testid":"recap-advice-box",className:"p-3.5 rounded-2xl bg-amber-50/70 dark:bg-amber-950/30 border border-amber-500/30 text-amber-900 dark:text-amber-200 flex flex-col gap-2 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-extrabold text-xs flex items-center gap-1.5",children:[e.jsx(Vt,{size:14,className:"text-amber-600 dark:text-amber-400"}),e.jsxs("span",{children:["「",t[l].concept,"」收口突破话术建议"]})]}),e.jsxs("button",{type:"button",onClick:()=>u(t[l].remediationAdvice,l),className:"px-2 py-0.5 rounded-md bg-surface text-main border border-theme text-3xs font-bold hover:bg-surface-secondary flex items-center gap-1 cursor-pointer transition-colors",children:[h===l?e.jsx(gt,{size:11,className:"text-emerald-500"}):e.jsx(Yt,{size:11}),e.jsx("span",{children:h===l?"已复制":"复制话术"})]})]}),e.jsx("p",{className:"text-2xs leading-relaxed font-medium",children:t[l].remediationAdvice})]})]})},bi=({isOpen:t,onClose:n,lessonTitle:a,className:o,masteryPercent:d=0,puzzledConcepts:r=[],lang:l="zh"})=>{const s=r.map(w=>w.trim()).filter(Boolean).slice(0,3),[h,c]=i.useState(!1),[u,m]=i.useState(!1);if(!t)return null;const p=l==="zh";return s.length===0?e.jsx("div",{"data-testid":"knowledge-tree-lighting-modal",className:"fixed inset-0 z-[125] bg-black/75 backdrop-blur-md flex items-center justify-center p-4 md:p-6 animate-fade-in select-none text-main",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-3xl shadow-2xl w-full max-w-md overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-surface-secondary/80 px-6 py-4 border-b border-theme flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-amber-500/10 text-amber-500 flex items-center justify-center border border-amber-500/20",children:e.jsx(ds,{size:22})}),e.jsx("h2",{className:"text-base font-black text-main",children:p?"课堂知识树即时点亮仪式":"Knowledge Tree Lighting"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-xl hover:bg-surface text-muted hover:text-main transition-colors cursor-pointer","aria-label":"Close",children:e.jsx(we,{size:20})})]}),e.jsxs("div",{className:"p-10 flex flex-col items-center gap-3 text-center",children:[e.jsx(ds,{size:36,className:"text-muted"}),e.jsx("p",{className:"text-sm font-bold text-main",children:p?"本课暂未收集到困惑点反馈":"No confused concepts collected this lesson"}),e.jsx("p",{className:"text-xs text-muted leading-relaxed max-w-xs",children:p?"知识树由学生在结课通票中反馈的真实困惑点生成。本节课没有收到任何困惑点,无树可点亮。":"The tree grows from confused concepts reported in exit tickets. None were collected this lesson."}),e.jsx("button",{onClick:n,className:"mt-2 px-5 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs transition-colors cursor-pointer",children:p?"我知道了":"Got it"})]})]})}):e.jsx("div",{"data-testid":"knowledge-tree-lighting-modal",className:"fixed inset-0 z-[125] bg-black/75 backdrop-blur-md flex items-center justify-center p-4 md:p-6 animate-fade-in select-none text-main",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-3xl shadow-2xl w-full max-w-4xl overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-surface-secondary/80 px-6 py-4 border-b border-theme flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-amber-500/10 text-amber-500 flex items-center justify-center border border-amber-500/20",children:e.jsx(ds,{size:22})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-base font-black text-main",children:p?"课堂知识树即时点亮仪式":"Knowledge Tree Lighting Ceremony"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-3xs font-mono font-bold bg-amber-500/10 text-amber-600 border border-amber-500/20",children:"Real Exit Tickets"})]}),e.jsxs("p",{className:"text-2xs text-muted mt-0.5",children:[o?`${o} · `:"","《",a||(p?"本堂课":"This lesson"),"》"]})]})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-xl hover:bg-surface text-muted hover:text-main transition-colors cursor-pointer","aria-label":"Close",children:e.jsx(we,{size:20})})]}),e.jsxs("div",{className:"p-8 bg-gradient-to-b from-surface to-surface-secondary/40 flex flex-col items-center justify-center relative overflow-hidden",children:[u&&e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-radial from-amber-500/10 via-transparent to-transparent animate-pulse"}),e.jsx("div",{className:"w-full max-w-2xl flex flex-col md:flex-row items-center justify-between gap-6 z-10 py-6",children:s.map((w,f)=>{const N=u;return e.jsxs(Et.Fragment,{children:[e.jsxs("div",{className:`flex-1 w-full rounded-2xl p-5 border transition-all duration-700 flex flex-col items-center text-center gap-3 shadow-md relative ${N?"bg-amber-500/10 border-amber-500/50 shadow-amber-500/10 scale-105 ring-2 ring-amber-400/40":"bg-surface-secondary/50 border-theme/60 opacity-60"}`,children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center transition-all duration-700 ${N?"bg-gradient-to-br from-amber-400 to-amber-600 text-white shadow-lg shadow-amber-500/30":"bg-surface border border-theme text-muted"}`,children:N?e.jsx(ve,{size:22,className:"animate-spin-slow"}):e.jsx(Za,{size:20})}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-3xs font-mono font-bold uppercase text-muted",children:p?`困惑点 ${f+1}`:`Concept ${f+1}`}),e.jsx("h4",{className:"text-xs font-black text-main leading-tight",children:w})]}),e.jsx("p",{className:"text-[11px] text-muted leading-relaxed max-w-[180px]",children:p?"学生结课通票真实反馈":"Reported in student exit tickets"}),e.jsxs("div",{className:"mt-1 pt-2 border-t border-theme/60 w-full flex items-center justify-between text-2xs font-mono font-bold",children:[e.jsx("span",{className:"text-muted",children:p?"复盘状态":"Review"}),e.jsx("span",{className:N?"text-amber-600 dark:text-amber-400":"text-muted",children:N?p?"已集体复盘点亮":"Reviewed":p?"待复盘":"Pending"})]})]}),f<s.length-1&&e.jsx("div",{className:"hidden md:flex text-muted/60",children:e.jsx(Ns,{size:24,className:u?"text-amber-500 animate-pulse":""})})]},w)})}),e.jsx("div",{className:"mt-4 flex flex-col items-center gap-3 z-10",children:u?e.jsxs("div",{"data-testid":"tree-lit-badge",className:"p-4 rounded-2xl bg-amber-500/10 border border-amber-500/40 text-center flex flex-col items-center gap-1.5 animate-bounce-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 dark:text-amber-400 font-black text-sm",children:[e.jsx(ft,{size:20}),e.jsx(Ce,{size:20}),e.jsx("span",{children:p?`${s.length} 个真实困惑点已全班集体复盘!`:`${s.length} real concepts reviewed by the class!`})]}),e.jsx("p",{className:"text-xs text-muted max-w-md",children:p?"以上困惑点全部来自本课学生的结课通票反馈,建议下节课针对性巩固。":"All concepts came from real student exit tickets. Consolidate them next lesson."})]}):e.jsxs("button",{type:"button",disabled:h,onClick:()=>{c(!0),setTimeout(()=>{c(!1),m(!0)},700)},className:"px-8 py-3 rounded-2xl bg-gradient-to-r from-amber-500 via-amber-600 to-amber-500 hover:scale-105 text-white font-black text-sm flex items-center gap-2 shadow-xl shadow-amber-500/25 transition-all cursor-pointer",children:[e.jsx(ve,{size:18}),e.jsx("span",{children:h?p?"正在连接知识图谱...":"Lighting...":p?"🌟 点亮本堂课困惑点知识树":"Light Up Tree"})]})})]})]})})},gi=new Set(["老师","今天","这个","我们","概念","感觉","还是","什么","没有","关于","为什么","有点","不太","不懂","听不懂","不是很","想问","请问","这道题","课件","大家","自己","一些","可以","需要","以及","the","a","an","and","or","in","of","to","is","for","with"]),Jr={微元:{standard:"变力做功与微元累加法",advice:"提示学生:变力无法直接用 W=Fs,必须将位移无限细分为小段 Δs,在每小段内力近似恒定,其几何本质即为 F-s 图象下的面积!"},积分:{standard:"变力做功与微元累加法",advice:"提示学生:微元积分在物理上的直观体现就是曲线下的梯形累加,重点理解“以恒代变”的思想。"},临界:{standard:"斜面滑动临界条件与摩擦突变",advice:"强调静摩擦力与滑动摩擦力的突变边界:当 tanθ=μ 时物块恰好匀速下滑;若外界压力突变,摩擦力立刻进入动摩擦计算。"},摩擦:{standard:"斜面滑动临界条件与摩擦突变",advice:"引导学生回顾摩擦力性质三步判断法:先定接触面、再找相对运动趋势、最后联立平衡方程。"},动量:{standard:"动量与机械能综合转化边界",advice:"请全班同学牢记:系统不受外力则动量必然守恒;但机械能守恒要求无摩擦生热(内能损耗),两者切忌混淆。"},守恒:{standard:"动量与机械能综合转化边界",advice:"提醒学生先画出始末状态示意图,明确研究对象是单个质点还是系统,再列守恒守恒方程。"},公式:{standard:"公式推导步骤与符号正负定义",advice:"板书提示:先规定正方向!标量与矢量运算法则不同,动能定理 W总=ΔEk 是标量式,无需分解正交方向。"},单位:{standard:"国际单位制量纲核验",advice:"交卷前花10秒做量纲检查:功的单位是 N·m (焦耳 J),等式两侧单位必须严格自洽。"}};function ji(t,n=3){if(!t||t.length===0)return[{concept:"变力做功微元累加与动能定理",frequency:1,weight:.5,remediationAdvice:"提示学生重点掌握 F-s 图象面积求功的物理思想,下课前再强调一遍标量方程特性。"},{concept:"动量守恒与机械能转化临界条件",frequency:1,weight:.5,remediationAdvice:"引导学生分清动量守恒与机械能守恒的适用前提,防止在有摩擦碰撞时误用机械能守恒。"}];const a={};for(const r of t){if(!r||typeof r!="string")continue;const l=r.trim();if(!l)continue;let s=!1;const h=new Set;for(const[c,u]of Object.entries(Jr))l.includes(c)&&h.add(u.standard);if(h.size>0){for(const c of h){const u=Object.values(Jr).find(m=>m.standard===c);a[c]||(a[c]={count:0,advice:u?.advice||""}),a[c].count+=1}s=!0}if(!s){const c=l.split(/[\s,,、。!?;;]+/);for(const u of c)if(u.length>=2&&!gi.has(u)){const m=u.length>10?u.slice(0,10):u;a[m]||(a[m]={count:0,advice:`针对「${m}」,建议教师在下课前引导全班回顾核心定义与典型例题解题步骤。`}),a[m].count+=1}}}const o=Object.values(a).reduce((r,l)=>r+l.count,0)||1,d=Object.entries(a).sort((r,l)=>l[1].count-r[1].count).slice(0,n).map(([r,l])=>({concept:r,frequency:l.count,weight:parseFloat((l.count/o).toFixed(2)),remediationAdvice:l.advice}));return d.length===0?[{concept:"本堂综合概念融合",frequency:1,weight:1,remediationAdvice:"全班掌握度整体良好,教师可进行常规要点归纳并下发课后拓展题。"}]:d}function yi({selectedLesson:t,lessonTitle:n,selectedClassId:a,className:o,students:d,lang:r,attempts:l,loadingAttempts:s,onFetchAttempts:h,onPromoteAttempt:c,onViewRaw:u,onAdvanceToReport:m,onReturnToTeaching:p,addToast:w,onBroadcastNotice:f}){const[N,b]=i.useState("grades"),[$,P]=i.useState("all"),[y,k]=i.useState(""),[g,A]=i.useState([]),[U,W]=i.useState({avgRating:0,count:0,topConcepts:[]}),[T,Q]=i.useState(!1),[V,le]=i.useState([]),[F,D]=i.useState({passed:0,remediation:0,challenge_done:0}),[j,q]=i.useState(r==="zh"?"第3课时课后拓展巩固微练习":"Lesson 3 Post-Class Exercise"),[ee,R]=i.useState(r==="zh"?"请在今晚 20:00 前完成平台微课复习,并上传教材 P42 思考题简答。":"Please complete the chapter review and submit exercises by 8 PM."),[O,L]=i.useState(()=>localStorage.getItem(`reflection_${t}`)||""),X=i.useCallback(()=>{t&&(fetch(`/api/classroom/sessions/${t}/panoramic-report`).then(S=>S.ok?S.json():null).then(S=>{S?.metrics&&W(M=>({avgRating:S.metrics.exitTicketsAvgRating??M.avgRating,count:S.metrics.exitTicketsCount||M.count,topConcepts:S.metrics.topPuzzledConcepts&&S.metrics.topPuzzledConcepts.length>0?S.metrics.topPuzzledConcepts:M.topConcepts}))}).catch(()=>{}),fetch(`/api/classroom/sessions/${t}/exit-ticket-summary`).then(S=>S.ok?S.json():null).then(S=>{S?.success&&(S.tierDistribution&&D(S.tierDistribution),S.submissions&&A(S.submissions),S.puzzledConcepts&&S.puzzledConcepts.length>0&&le(S.puzzledConcepts),S.totalCount!==void 0&&W(M=>({...M,count:S.totalCount,avgRating:S.avgRating??M.avgRating,topConcepts:S.puzzledConcepts&&S.puzzledConcepts.length>0?S.puzzledConcepts:M.topConcepts})))}).catch(()=>{}))},[t]);i.useEffect(()=>{X()},[X,N,T]),i.useEffect(()=>{let S=null;const M=Wt(I=>{S?.();const B=se=>{(!se?.lessonId||se.lessonId===t)&&X()};I.on("classroom:exit_ticket_submitted",B),S=()=>{I.off("classroom:exit_ticket_submitted",B)}});return()=>{M(),S?.()}},[X,t]);const K=Et.useMemo(()=>ji(V),[V]),H=()=>{t&&(localStorage.setItem(`reflection_${t}`,O),w(r==="zh"?"✓ 反思已保存":"✓ Reflection Saved",r==="zh"?"教学小结与课后反思备忘录已保存。":"Reflection saved.","success"))},re=()=>{if(!j.trim())return;const S=`📢 【课后作业通知】${j}:${ee}`;f&&f(S),w(r==="zh"?"✓ 作业通知已记录":"✓ Homework Recorded",r==="zh"?`已记录 ${o||"全班"} 的课后巩固任务到课堂动态流。学生端实时推送尚未接通,请口头同步。`:"Recorded to the classroom feed. Student push is not wired yet.","info")},te=a?d.map(S=>S.id):[],G=(a?l.filter(S=>te.includes(S.studentId)):l).filter(S=>{const M=S.studentName?.toLowerCase().includes(y.toLowerCase())||S.coursewareName?.toLowerCase().includes(y.toLowerCase()),I=["completed","submitted","finished"],B=["active","inprogress","started"],se=$==="all"||$==="submitted"&&I.includes(S.status)||$==="started"&&B.includes(S.status);return M&&se});return e.jsxs("div",{id:"post-class-wrapup-view",className:"flex-1 flex flex-col min-h-0 bg-surface-secondary/20 p-4 gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-500/10 border border-indigo-500/20 text-indigo-600 dark:text-indigo-400 flex items-center justify-center shrink-0",children:e.jsx(ft,{size:24})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-black bg-indigo-500/10 text-indigo-700 dark:text-indigo-300 border border-indigo-500/30 uppercase tracking-wider",children:r==="zh"?"阶段 3 / 4 · 课后小结与作业批改":"Stage 3/4 · Post-Class Wrap-up & Evaluation"}),e.jsxs("span",{className:"text-xs text-muted font-semibold",children:[o," · ",n]})]}),e.jsx("h1",{className:"text-lg font-black text-main tracking-tight mt-1 flex items-center gap-2",children:e.jsx("span",{children:r==="zh"?"随堂作业评定、60s通票反馈与课后任务下发":"Post-Class Evaluation & Feedback"})}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:r==="zh"?`课中白板讲授已结束 · 已汇总 ${G.length} 份随堂提交 · 结课通票平均得分 ${U.avgRating} ★`:`Teaching finished · ${G.length} submissions · Avg Exit Ticket: ${U.avgRating} ★`})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap w-full md:w-auto justify-end",children:[e.jsxs("button",{type:"button",onClick:p,className:"px-3 py-2 text-xs font-bold rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-main transition-colors cursor-pointer flex items-center gap-1.5 shadow-2xs",children:[e.jsx(Jt,{size:13}),e.jsx("span",{children:r==="zh"?"返回课中白板":"Back to Teaching"})]}),e.jsxs("button",{id:"post-class-advance-report-btn",type:"button",onClick:m,className:"px-5 py-2.5 bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-700 hover:to-purple-700 text-white font-extrabold rounded-xl text-xs flex items-center gap-2 shadow-md hover:shadow-lg transition-all active:scale-95 cursor-pointer",children:[e.jsx("span",{children:r==="zh"?"生成学情全景简报":"Generate Briefing Report"}),e.jsx(Ns,{size:14})]}),e.jsx(me,{slot:"classroom.post_class.exporter",slotProps:{summaryData:{selectedLesson:t,lessonTitle:n,selectedClassId:a,className:o,attemptsCount:G.length,exitTicketStats:U},classId:a,lessonId:t,lang:r}})]})]}),e.jsx(me,{slot:"classroom.post_class.widget",slotProps:{lessonId:t,classId:a,lang:r}}),e.jsxs("div",{className:"flex items-center gap-2 bg-surface p-1.5 rounded-xl border border-theme shadow-xs shrink-0 overflow-x-auto",children:[e.jsxs("button",{type:"button",onClick:()=>b("grades"),className:`px-3.5 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${N==="grades"?"bg-primary-theme text-white shadow-xs":"text-muted hover:text-main hover:bg-surface-secondary"}`,children:[e.jsx(ft,{size:13}),e.jsx("span",{children:r==="zh"?"作业成绩评定 (核心评卷)":"Assignment Grading"})]}),e.jsxs("button",{type:"button",onClick:()=>{b("submissions"),h()},className:`px-3.5 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${N==="submissions"?"bg-primary-theme text-white shadow-xs":"text-muted hover:text-main hover:bg-surface-secondary"}`,children:[e.jsx(qt,{size:13}),e.jsx("span",{children:r==="zh"?`随堂互动提交明细 (${G.length})`:`Interactive Submissions (${G.length})`})]}),e.jsxs("button",{type:"button",onClick:()=>b("exitTicket"),className:`px-3.5 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${N==="exitTicket"?"bg-primary-theme text-white shadow-xs":"text-muted hover:text-main hover:bg-surface-secondary"}`,children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:r==="zh"?"60s 结课通票反馈":"60s Exit Ticket"})]}),e.jsxs("button",{type:"button",onClick:()=>b("homework"),className:`px-3.5 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 cursor-pointer ${N==="homework"?"bg-primary-theme text-white shadow-xs":"text-muted hover:text-main hover:bg-surface-secondary"}`,children:[e.jsx(ut,{size:13}),e.jsx("span",{children:r==="zh"?"课后任务下发与反思备忘":"Homework & Notes"})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[N==="grades"&&e.jsx("div",{className:"flex-1 min-h-[480px] bg-surface rounded-2xl border border-theme overflow-hidden shadow-sm flex flex-col",children:e.jsx(zn,{lessonId:t||"",lang:r==="zh"?"zh":"en",addToast:w})}),N==="submissions"&&e.jsxs("div",{className:"flex-1 min-h-[480px] bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-black text-main uppercase tracking-wider",children:r==="zh"?"互动课件作答记录":"Courseware Attempts"}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme font-bold border border-primary-theme/20",children:[G.length," ",r==="zh"?"条":"items"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",placeholder:r==="zh"?"搜索学生或课件...":"Search student...",value:y,onChange:S=>k(S.target.value),className:"bg-surface-secondary border border-theme rounded-xl text-xs pl-8 pr-3 py-1.5 text-main outline-none w-44"}),e.jsx(Lt,{size:12,className:"absolute left-2.5 top-2.5 text-muted"})]}),e.jsxs("div",{className:"flex rounded-xl bg-surface-secondary p-0.5 border border-theme",children:[e.jsx("button",{type:"button",onClick:()=>P("all"),className:`px-2.5 py-1 text-xs font-bold rounded-lg transition-colors cursor-pointer ${$==="all"?"bg-surface text-main shadow-2xs":"text-muted"}`,children:r==="zh"?"全部":"All"}),e.jsx("button",{type:"button",onClick:()=>P("submitted"),className:`px-2.5 py-1 text-xs font-bold rounded-lg transition-colors cursor-pointer ${$==="submitted"?"bg-surface text-main shadow-2xs":"text-muted"}`,children:r==="zh"?"已提交":"Submitted"}),e.jsx("button",{type:"button",onClick:()=>P("started"),className:`px-2.5 py-1 text-xs font-bold rounded-lg transition-colors cursor-pointer ${$==="started"?"bg-surface text-main shadow-2xs":"text-muted"}`,children:r==="zh"?"作答中":"In Progress"})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:s?e.jsx("div",{className:"text-center py-12 text-xs text-muted",children:r==="zh"?"正在加载作答数据...":"Loading submissions..."}):G.length===0?e.jsx("div",{className:"text-center py-12 text-xs text-muted italic",children:r==="zh"?"暂无匹配的随堂提交记录":"No matching submissions found"}):e.jsxs("table",{className:"w-full border-collapse text-left text-xs text-main",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-secondary border-b border-theme font-bold text-muted select-none",children:[e.jsx("th",{className:"p-3",children:r==="zh"?"学生姓名":"Student"}),e.jsx("th",{className:"p-3",children:r==="zh"?"课件项目":"Courseware"}),e.jsx("th",{className:"p-3",children:r==="zh"?"状态":"Status"}),e.jsx("th",{className:"p-3 text-center",children:r==="zh"?"成绩 / 得分":"Score"}),e.jsx("th",{className:"p-3 text-right",children:r==="zh"?"操作":"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border/60",children:G.map(S=>e.jsxs("tr",{className:"hover:bg-surface-secondary/40 transition-colors",children:[e.jsx("td",{className:"p-3 font-bold text-main",children:S.studentName||"Unknown Student"}),e.jsx("td",{className:"p-3 text-muted",children:S.coursewareName||"Interactive Exercise"}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[11px] font-bold ${S.status==="completed"||S.status==="finished"||S.status==="submitted"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/30":"bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/30"}`,children:S.status==="completed"||S.status==="finished"||S.status==="submitted"?r==="zh"?"已提交":"Submitted":r==="zh"?"作答中":"In Progress"})}),e.jsx("td",{className:"p-3 text-center font-mono font-bold text-main",children:S.score!==void 0&&S.score!==null?`${S.score} 分`:"--"}),e.jsx("td",{className:"p-3 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>u(S),className:"px-2 py-1 text-[11px] font-bold rounded-lg border border-theme bg-surface hover:bg-surface-secondary text-main transition-colors flex items-center gap-1 cursor-pointer",children:[e.jsx(Qt,{size:11}),e.jsx("span",{children:r==="zh"?"查看明细":"Details"})]}),e.jsxs("button",{type:"button",onClick:()=>c(S.attemptId),className:"px-2 py-1 text-[11px] font-bold rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white transition-colors flex items-center gap-1 cursor-pointer",children:[e.jsx(qt,{size:11}),e.jsx("span",{children:r==="zh"?"录入成绩":"Record"})]})]})})]},S.attemptId||Math.random()))})]})})]}),N==="exitTicket"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4 flex-1",children:[e.jsx("div",{className:"md:col-span-6 flex flex-col gap-4",children:e.jsx(fi,{concepts:K,totalFeedbackCount:U.count,avgRating:U.avgRating,tierDistribution:F,onOpenKnowledgeTree:()=>Q(!0),lang:r})}),e.jsxs("div",{className:"md:col-span-6 bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-3",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(ir,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:r==="zh"?"学生课后原声与提问留言":"Student Feedback Stream"})]}),e.jsx("span",{className:"text-xs text-muted",children:r==="zh"?"实时随堂流":"Live stream"})]}),e.jsx("div",{className:"flex flex-col gap-2.5 overflow-y-auto max-h-[360px] pr-1",children:g.length===0?e.jsx("div",{className:"text-center py-12 text-xs text-muted italic",children:r==="zh"?"暂无学生课后反馈与留言":"No student feedback submissions yet"}):g.map((S,M)=>e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary/60 border border-theme/60 flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-bold text-main",children:S.student_name||S.student_id||(r==="zh"?"匿名同学":"Anonymous")}),S.rating!==void 0&&S.rating!==null&&e.jsxs("span",{className:"text-[11px] text-amber-500 font-bold",children:[Number(S.rating).toFixed(1)," ★"]})]}),S.feedback?e.jsxs("p",{className:"text-muted",children:["“",S.feedback,"”"]}):S.puzzled_concept?e.jsxs("p",{className:"text-muted",children:["“",r==="zh"?"困惑知识点:":"Puzzled by: ",S.puzzled_concept,"”"]}):e.jsx("p",{className:"text-muted/60 italic",children:r==="zh"?"(未填写留言)":"(No written feedback)"})]},S.student_id||M))})]})]}),N==="homework"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 flex-1",children:[e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2.5",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(ut,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:r==="zh"?"课后巩固任务发布":"Assign Homework"})]}),e.jsx("span",{className:"text-xs text-muted",children:o||"全班学生"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-bold text-muted",children:r==="zh"?"作业任务标题":"Title"}),e.jsx("input",{type:"text",value:j,onChange:S=>q(S.target.value),className:"w-full bg-surface-secondary border border-theme rounded-xl px-3 py-2 text-xs text-main outline-none focus:ring-1 focus:ring-primary-theme"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-bold text-muted",children:r==="zh"?"任务要求与说明":"Instructions"}),e.jsx("textarea",{value:ee,onChange:S=>R(S.target.value),rows:4,className:"w-full bg-surface-secondary border border-theme rounded-xl p-3 text-xs text-main outline-none focus:ring-1 focus:ring-primary-theme resize-none"})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs("button",{type:"button",onClick:re,className:"px-4 py-2 bg-primary-theme hover:bg-primary-theme-hover text-white rounded-xl text-xs font-bold flex items-center gap-1.5 shadow-xs cursor-pointer",children:[e.jsx(ut,{size:12}),e.jsx("span",{children:r==="zh"?"一键下发到学生端":"Broadcast to Class"})]})})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2.5",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(yt,{size:14,className:"text-indigo-500"}),e.jsx("span",{children:r==="zh"?"教师课后教学反思备忘录":"Teacher Post-Lesson Reflection"})]}),e.jsx("span",{className:"text-xs text-muted",children:r==="zh"?"本地自动归档":"Auto-saved"})]}),e.jsx("textarea",{value:O,onChange:S=>L(S.target.value),placeholder:r==="zh"?"记录本次课的教学亮点、节奏把控、学生互动亮点及下次课的改进点...":"Notes on what went well, pacing, student engagement, and next steps...",rows:7,className:"w-full flex-1 bg-surface-secondary border border-theme rounded-xl p-3 text-xs text-main outline-none focus:ring-1 focus:ring-primary-theme resize-none"}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{type:"button",onClick:H,className:"px-4 py-2 bg-surface-secondary hover:bg-surface border border-theme text-main rounded-xl text-xs font-bold transition-colors cursor-pointer",children:r==="zh"?"保存反思记录":"Save Memo"})})]})]})]}),e.jsx(bi,{isOpen:T,onClose:()=>Q(!1),lessonTitle:n,className:o,masteryPercent:Math.round(U.avgRating/5*100),puzzledConcepts:U.topConcepts.length>0?U.topConcepts:V.length>0?V:K.map(S=>S.concept),lang:r})]})}function Ni(t){const n=Math.max(1,t.durationMin||45),a=Math.max(1,t.totalStudents||30),o=typeof t.lectureMin=="number"&&t.lectureMin>0,d=t.lectureMin,r=o?Math.min(100,Math.round(d/n*100)):null,l=55,s=Math.round(t.interactiveCount/a*100),h=Math.min(100,Math.max(0,s)),c=t.pacingData.CLEAR+t.pacingData.CONFUSED+t.pacingData.TOO_FAST||1,u=Math.round(t.pacingData.CLEAR/c*100),m=Math.round(t.pacingData.CONFUSED/c*100),p=Math.round(t.pacingData.TOO_FAST/c*100),w=[],f=t.primaryPuzzledConcept;m>=10&&w.push({type:"CONFUSED",count:t.pacingData.CONFUSED,percentage:m,...f?{contextConcept:f}:{}}),p>=8&&w.push({type:"TOO_FAST",count:t.pacingData.TOO_FAST,percentage:p});const N=[];t.quizAccuracy>=80?N.push({title:"核心概念掌握扎实",description:`随堂检测整体正答率达 ${t.quizAccuracy}%,知识点理解转化率高,学生具备良好的基础认知。`,metricTag:`正答率 ${t.quizAccuracy}%`}):t.quizAccuracy>=60&&N.push({title:"主干知识形成基本框架",description:`全班 ${t.quizAccuracy}% 的学生能够正确解答核心随堂测验,课堂学习目标初步达成。`,metricTag:`正答率 ${t.quizAccuracy}%`}),u>=75&&N.push({title:"课堂主线节奏适宜",description:`晴雨表显示 ${u}% 的学生反馈授课节奏平稳清晰,教学演示与板书逻辑易于吸收。`,metricTag:`满意度 ${u}%`}),t.interactiveCount>=a*.8&&N.push({title:"随堂互动积极热烈",description:`互动总人次达到 ${t.interactiveCount} 次,抢答器与投票工具有效调动了课堂气氛。`,metricTag:`${t.interactiveCount} 人次`}),N.length===0&&N.push({title:"本节无达到亮点阈值的数据信号",description:"各数据面均在正常区间,未触发亮点判定;可结合课堂观察补充定性记录。"});const b=[];o&&r!==null&&r>l&&b.push({title:"教师单向讲授用时偏高",description:`讲授时间占比达 ${r}%(超出推荐阈值 ${l}%),学生的自主探究与互评表达时间受到挤压。`,attribution:"课堂结构失衡:讲解与演算过多,留白探究时间不足。",metricTag:`讲授 ${r}%`}),h<45&&b.push({title:"抽问互动覆盖面受限",description:`提问与深度互动覆盖率仅 ${h}%,存在部分静默或后排学生未被有效触达。`,attribution:"抽问模式偏向主动举手或集中在前排学生,未充分启动公平分层点名。",metricTag:`覆盖率 ${h}%`}),(m>=15||t.quizAccuracy<70)&&b.push({title:`重难点卡点聚集: ${f}`,description:`约 ${m}% 的学生在晴雨表或通票中反馈概念理解存在卡点,测验正答率仅 ${t.quizAccuracy}%。`,attribution:"该知识点抽象度高,缺乏从直观物理/生活情境到符号推导的认知阶梯。",metricTag:`困惑占比 ${m}%`}),b.length===0&&b.push({title:"本节无显著薄弱点信号",description:"随堂测正答率、晴雨表与互动覆盖率均未触发薄弱判定。",attribution:"本次归因基于课内真实数据面,未触发阈值。"});const $=[];return(m>=15||t.quizAccuracy<75)&&$.push({title:"下节课前 3 分钟针对性温故练习",suggestion:`在下堂课「课前就绪」阶段,推送针对“${f}”的 2 道情境化变式微练习,现场纠正认知误区。`,timing:"next_pre_class"}),r!==null&&r>l&&$.push({title:"重构课堂结构,增加拼板探究与画廊互评",suggestion:"下节课建议采用「随堂拼板教学」,将 15 分钟的例题讲解拆为“小组白板分工探索 + 画廊互评展台”,提升生生互动。",timing:"next_in_class"}),h<50&&$.push({title:"启用分层随机点名轮盘 (Fair Tiered Picker)",suggestion:"授课时开启“分层公平模式”,系统将自动优先呼叫本学期发言频次较低的学生,并根据问题难度精准匹配。",timing:"next_in_class"}),$.push({title:"课后启动差异化分流作业派发",suggestion:"依据当堂测评结果,为 A/B/C 三个梯队分别派发拓展探究题、核心巩固题及微课补强包,落实因材施教。",timing:"homework"}),{lectureRatio:r,recommendedLectureMaxRatio:l,interactionCoverage:h,pacingAlerts:w,strengths:N,bottlenecks:b,actionableSuggestions:$}}function An(t){const n=t.quizScore??(t.rating?t.rating*20:75);return n>=90&&(t.rating===null||t.rating>=4)?"TIER_A_ADVANCED":n<70||t.rating!==null&&t.rating<=2?"TIER_C_REINFORCE":"TIER_B_STANDARD"}function vi(t,n="本节课"){const a=[],o=[],d=[];return t.forEach(r=>{const l=An(r),s={studentId:r.id,studentName:r.name,studentNumber:r.studentNumber,quizScore:r.quizScore,exitRating:r.rating,puzzledConcept:r.puzzledConcept};l==="TIER_A_ADVANCED"?a.push(s):l==="TIER_C_REINFORCE"?d.push(s):o.push(s)}),[{tier:"TIER_A_ADVANCED",title:"A 梯队 · 通关拔高型",subtitle:"核心概念已通关,重在发展高阶思维与探究迁移",badgeColor:"emerald",packageTitle:`【拔高拓展包】${n} 高阶物理探究与综合挑战题`,packageDescription:"包含 1 道开放性工程探究任务 + 1 道多情境复合受力分析变式题。",resourceCount:2,resourceType:"challenge_task",students:a},{tier:"TIER_B_STANDARD",title:"B 梯队 · 稳健巩固型",subtitle:"概念掌握良好,重在变式巩固与答题熟练度",badgeColor:"blue",packageTitle:`【稳健巩固包】${n} 核心考点过关精选 3 题`,packageDescription:"针对随堂测典型考点进行正向迁移演练,强化解题规范与公式应用。",resourceCount:3,resourceType:"standard_quiz",students:o},{tier:"TIER_C_REINFORCE",title:"C 梯队 · 支架补强型",subtitle:"部分公式或步骤存在卡点,重在微课回放与图解纠错",badgeColor:"amber",packageTitle:`【认知支架包】${n} 疑难突破微课 + 概念梳理卡`,packageDescription:"内含授课核心片断 3 分钟精要回放、公式符号图解对照卡及 1 道阶梯式填空提示题。",resourceCount:2,resourceType:"micro_lesson_card",students:d}]}function Yr(t,n="本堂课",a="高一(1)班"){const o=An(t),d={TIER_A_ADVANCED:"A 梯队 (卓越拔高)",TIER_B_STANDARD:"B 梯队 (扎实巩固)",TIER_C_REINFORCE:"C 梯队 (定向强基)"},r=[];t.pollsAnswered>=3&&r.push({id:"active_buzzer",name:"抢答先锋",icon:"⚡",desc:`随堂主动互动抢答 ${t.pollsAnswered} 次,思维敏捷`}),(t.quizScore??0)>=90&&r.push({id:"accuracy_master",name:"神准解题官",icon:"🎯",desc:"随堂测验答题全对,高阶概念迁移达成"}),t.rating&&t.rating>=4&&r.push({id:"confidence_star",name:"自信领航者",icon:"⭐",desc:"结课通票自我评估满分,对本节主干理解胸有成竹"}),r.length===0&&r.push({id:"persistent_scholar",name:"笃学潜能星",icon:"🌱",desc:"全过程完整参与课堂互动,具备持续突破潜力"});let l="课堂表现沉稳,建议继续保持严谨求真的探究态度。",s="已完成当堂标准练习,今晚请鼓励孩子保持复习习惯。";o==="TIER_A_ADVANCED"?(l="知识掌握扎实全面,主动参与探究,具备出色的自学与迁移能力。",s="孩子今天课堂表现卓越,系统已为其匹配课后拔高拓展题,鼓励孩子勇于挑战!"):o==="TIER_C_REINFORCE"&&(l=`在个别难点推导(${t.puzzledConcept||"概念公式转换"})上略显困惑,已下发定向微课补强包。`,s="孩子课堂听讲认真,为帮助巩固重难点,老师已下发 3 分钟精要微课,请协助孩子抽空温习。");const h=`【${a}·课堂成长日报】
|
|
25
|
+
亲爱的 ${t.name} 家长:
|
|
26
|
+
您好!孩子在今天的《${n}》课程中:
|
|
27
|
+
· 随堂测验得分:${t.quizScore!==null?`${t.quizScore} 分`:"—"}
|
|
28
|
+
· 课堂互动答题:${t.pollsAnswered} 次
|
|
29
|
+
· 通票自评星级:${t.rating!==null?`${t.rating} 星`:"—"}
|
|
30
|
+
· 荣获荣誉勋章:${r.map(c=>`${c.icon} ${c.name}`).join("、")}
|
|
31
|
+
【教师评价】:${l}
|
|
32
|
+
【课后跟进】:${s}`;return{studentId:t.id,studentName:t.name,studentNumber:t.studentNumber,attendance:t.attendance,quizScore:t.quizScore,accuracy:t.accuracy,pollsAnswered:t.pollsAnswered,exitRating:t.rating,puzzledConcept:t.puzzledConcept,tier:o,tierLabel:d[o],badges:r,teacherNote:l,parentReportText:h}}function wi({initialTiers:t,lessonTitle:n,onDispatchHomework:a,onSelectStudent:o,addToast:d}){const[r,l]=i.useState(t),[s,h]=i.useState(!1),[c,u]=i.useState(!1),m=r.reduce((f,N)=>f+N.students.length,0),p=(f,N,b)=>{N!==b&&(l($=>$.map(P=>P.tier===N?{...P,students:P.students.filter(y=>y.studentId!==f.studentId)}:P.tier===b?{...P,students:[...P.students,f]}:P)),h(!1))},w=()=>{u(!0),setTimeout(()=>{u(!1),h(!0),a&&a(r),d("✓ 差异化课后任务已成功派发",`已向全班 ${m} 名同学精准分流推送对应学习资源包。`,"success")},600)};return e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-theme/10 text-primary-theme flex items-center justify-center font-bold",children:e.jsx(It,{size:18})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm font-black text-main tracking-tight flex items-center gap-2",children:[e.jsx("span",{children:"差异化课后巩固派发中枢 (Differentiated Follow-up Hub)"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold bg-primary-theme/10 text-primary-theme",children:"AI 自动分流"})]}),e.jsx("p",{className:"text-xs text-muted",children:"依据测验表现与 Exit Ticket 卡点自动聚类,支持微调并一键派发至学生端。"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s&&e.jsxs("span",{className:"text-xs text-emerald-600 font-bold flex items-center gap-1 bg-emerald-500/10 px-2.5 py-1 rounded-xl border border-emerald-500/20",children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:"已全员派发到位"})]}),e.jsxs("button",{type:"button",id:"btn-dispatch-differentiated-tasks",onClick:w,disabled:c||m===0,className:`px-4 py-2 rounded-xl text-xs font-black flex items-center gap-1.5 transition-all shadow-xs cursor-pointer ${s?"bg-emerald-600 text-white hover:bg-emerald-700":"bg-primary-theme text-white hover:bg-primary-theme-hover"} disabled:opacity-50`,children:[e.jsx(ut,{size:13,className:c?"animate-spin":""}),e.jsx("span",{children:c?"派发中...":s?"重新派发任务包":`一键派发至全班 (${m}人)`})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:r.map(f=>{const N=f.tier==="TIER_A_ADVANCED",b=f.tier==="TIER_B_STANDARD",$=f.tier==="TIER_C_REINFORCE",P=N?"border-emerald-500/30 bg-emerald-500/5":b?"border-blue-500/30 bg-blue-500/5":"border-amber-500/30 bg-amber-500/5",y=N?"text-emerald-700 dark:text-emerald-400":b?"text-blue-700 dark:text-blue-400":"text-amber-700 dark:text-amber-400",k=N?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":b?"bg-blue-500/15 text-blue-700 dark:text-blue-300":"bg-amber-500/15 text-amber-700 dark:text-amber-300";return e.jsxs("div",{className:`rounded-2xl border p-4 flex flex-col justify-between gap-3.5 transition-all ${P}`,children:[e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[N&&e.jsx(ve,{size:16,className:"text-emerald-600"}),b&&e.jsx(Oe,{size:16,className:"text-blue-600"}),$&&e.jsx(xn,{size:16,className:"text-amber-600"}),e.jsx("span",{className:`text-xs font-black ${y}`,children:f.title})]}),e.jsxs("span",{className:`text-[11px] font-bold px-2 py-0.5 rounded-full ${k}`,children:[f.students.length," 人"]})]}),e.jsx("p",{className:"text-[11px] text-muted leading-tight",children:f.subtitle}),e.jsxs("div",{className:"p-2.5 rounded-xl bg-surface border border-theme/80 flex flex-col gap-1 shadow-2xs",children:[e.jsx("span",{className:"text-[11px] font-bold text-main line-clamp-1",children:f.packageTitle}),e.jsx("p",{className:"text-[10px] text-muted line-clamp-2 leading-relaxed",children:f.packageDescription})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-bold text-muted",children:[e.jsxs("span",{children:["成员名单 (",f.students.length,")"]}),e.jsx("span",{className:"text-[10px]",children:"点击切换梯队"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-36 overflow-y-auto p-1 bg-surface/50 rounded-xl border border-theme/50",children:f.students.length===0?e.jsx("span",{className:"text-[11px] text-muted/60 p-2 italic w-full text-center",children:"暂无归入此梯队的同学"}):f.students.map(g=>e.jsxs("div",{className:"group relative flex items-center gap-1 px-2 py-1 rounded-lg bg-surface border border-theme text-[11px] font-medium text-main hover:border-primary-theme transition-all shadow-2xs",children:[e.jsx("span",{className:"cursor-pointer hover:underline",onClick:()=>o&&o(g.studentId),title:"点击查看个人课节报告",children:g.studentName}),g.quizScore!==null&&e.jsxs("span",{className:"text-[9px] font-mono text-muted",children:["(",g.quizScore,"分)"]}),e.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-0.5 ml-1 transition-opacity",children:[!N&&e.jsx("button",{type:"button",title:"上调至 A 梯队",onClick:()=>p(g,f.tier,"TIER_A_ADVANCED"),className:"text-[9px] px-1 py-0.2 bg-emerald-500/20 text-emerald-600 rounded hover:bg-emerald-500/40",children:"↑A"}),!b&&e.jsx("button",{type:"button",title:"调整至 B 梯队",onClick:()=>p(g,f.tier,"TIER_B_STANDARD"),className:"text-[9px] px-1 py-0.2 bg-blue-500/20 text-blue-600 rounded hover:bg-blue-500/40",children:"B"}),!$&&e.jsx("button",{type:"button",title:"下调至 C 梯队",onClick:()=>p(g,f.tier,"TIER_C_REINFORCE"),className:"text-[9px] px-1 py-0.2 bg-amber-500/20 text-amber-600 rounded hover:bg-amber-500/40",children:"↓C"})]})]},g.studentId))})]})]},f.tier)})})]})}function ki({digest:t,onClose:n,addToast:a}){const[o,d]=i.useState(!1),[r,l]=i.useState(t?.parentReportText||"");if(!t)return null;const s=()=>{typeof navigator<"u"&&navigator.clipboard?.writeText?navigator.clipboard.writeText(r).then(()=>{d(!0),a("✓ 已复制到剪贴板","家长同步报告文案已复制,可直接发送微信群或家长私信。","success"),setTimeout(()=>d(!1),2e3)}).catch(()=>{d(!0),a("✓ 内容已就绪","请直接在文本框中全选复制。","info"),setTimeout(()=>d(!1),2e3)}):(d(!0),a("✓ 已复制到剪贴板","家长同步报告文案已复制。","success"),setTimeout(()=>d(!1),2e3))};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl max-w-xl w-full p-6 shadow-2xl flex flex-col gap-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary-theme/10 text-primary-theme flex items-center justify-center font-bold text-lg",children:t.studentName.slice(0,1)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-black text-main",children:t.studentName}),e.jsxs("span",{className:"text-xs font-mono text-muted",children:["(",t.studentNumber,")"]}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold bg-primary-theme/10 text-primary-theme border border-primary-theme/20",children:t.tierLabel})]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:"课堂全景表现个人报告与家校同步成长单"})]})]}),e.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-xl hover:bg-surface-secondary text-muted hover:text-main transition-colors cursor-pointer",children:e.jsx(we,{size:18})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2.5 text-center",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary border border-theme flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted font-bold",children:"随堂得分"}),e.jsx("span",{className:"text-lg font-black font-mono text-primary-theme mt-0.5",children:t.quizScore!==null?`${t.quizScore}分`:"—"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary border border-theme flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted font-bold",children:"答题互动"}),e.jsxs("span",{className:"text-lg font-black font-mono text-amber-500 mt-0.5",children:[t.pollsAnswered," 次"]})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary border border-theme flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted font-bold",children:"通票自评"}),e.jsx("span",{className:"text-lg font-black font-mono text-indigo-500 mt-0.5",children:t.exitRating!==null?`${t.exitRating}★`:"—"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-surface-secondary border border-theme flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted font-bold",children:"出勤状态"}),e.jsx("span",{className:"text-lg font-black text-emerald-600 mt-0.5",children:t.attendance})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("span",{className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(ft,{size:14,className:"text-amber-500"}),e.jsx("span",{children:"当堂获得成就勋章"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:t.badges.map(h=>e.jsxs("div",{className:"p-2.5 rounded-xl bg-amber-500/5 border border-amber-500/20 flex items-center gap-2.5",children:[e.jsx("span",{className:"text-2xl",children:h.icon}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-bold text-amber-700 dark:text-amber-400",children:h.name}),e.jsx("span",{className:"text-[10px] text-muted leading-tight",children:h.desc})]})]},h.id))})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-primary-theme/5 border border-primary-theme/20 flex flex-col gap-1",children:[e.jsxs("span",{className:"text-xs font-bold text-primary-theme flex items-center gap-1",children:[e.jsx(ir,{size:13}),e.jsx("span",{children:"教师诊断与课堂评价"})]}),e.jsx("p",{className:"text-xs text-main leading-relaxed",children:t.teacherNote})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-theme pt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(pn,{size:13,className:"text-indigo-500"}),e.jsx("span",{children:"家校互联·家长端同步文案"})]}),e.jsxs("button",{type:"button",id:"btn-copy-parent-digest",onClick:s,className:"px-3 py-1 bg-surface-secondary hover:bg-primary-theme hover:text-white border border-theme text-main rounded-xl text-xs font-bold flex items-center gap-1.5 transition-colors cursor-pointer",children:[o?e.jsx(gt,{size:12,className:"text-emerald-500"}):e.jsx(Yt,{size:12}),e.jsx("span",{children:o?"已复制":"一键复制文案"})]})]}),e.jsx("textarea",{value:r,onChange:h=>l(h.target.value),rows:5,className:"w-full bg-surface-secondary border border-theme rounded-xl p-3 text-xs text-main font-mono leading-relaxed outline-none focus:border-primary-theme resize-none"})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 bg-surface hover:bg-surface-secondary border border-theme text-main rounded-xl text-xs font-bold transition-colors cursor-pointer",children:"关闭预览"})})]})})}function zi({selectedLesson:t,sessionId:n,lessonTitle:a,selectedClassId:o,className:d,students:r,lang:l,onReturnToTeaching:s,onReturnToPreClass:h,addToast:c}){const[u,m]=i.useState(!1),[p,w]=i.useState(""),[f,N]=i.useState(null),[b,$]=i.useState({TOO_FAST:0,SLOW:0,CONFUSED:0,CLEAR:0}),[P,y]=i.useState({}),[k,g]=i.useState(null);i.useEffect(()=>{if(!t)return;m(!0);const M=n?`?sessionId=${encodeURIComponent(n)}`:"";Promise.all([fetch(`/api/classroom/sessions/${t}/panoramic-report${M}`).then(I=>I.ok?I.json():null).catch(()=>null),fetch(`/api/classroom/stage/${t}/data`).then(I=>I.ok?I.json():null).catch(()=>null),fetch(`/api/lessons/${t}`).then(I=>I.ok?I.json():null).catch(()=>null)]).then(([I,B,se])=>{if(I&&(N(I),I.metrics?.pacingOverall&&$({TOO_FAST:0,SLOW:0,CONFUSED:0,CLEAR:0,...I.metrics.pacingOverall})),B?.pacing&&(!I||!I.metrics?.pacingOverall)&&$({TOO_FAST:0,SLOW:0,CONFUSED:0,CLEAR:0,...B.pacing}),se?.timeline)try{const v=typeof se.timeline=="string"?JSON.parse(se.timeline):se.timeline;if(Array.isArray(v)){const _={};v.forEach(Z=>{Z?.id&&Z?.title&&(_[Z.id]=Z.title)}),y(_)}}catch{}m(!1)})},[t,n]);const A=r.length||f?.students?.length||0,U=f?.students?.filter(M=>M.attendance).length??0,W=A>0?Math.round(U/A*100):null,T=f?.metrics?.quizAccuracy??0,Q=f?.metrics?.pollVotesTotal??0,V=Array.isArray(f?.metrics?.pollOptionBreakdown)?f.metrics.pollOptionBreakdown:[],le=f?.metrics?.exitTicketsAvgRating??null,F=f?.session?.durationMin??0,D=(b.CLEAR||0)+(b.CONFUSED||0)+(b.TOO_FAST||0)+(b.SLOW||0),j=D>0,q=j?D:0,ee=j?Math.round((b.CLEAR||0)/D*100):0,R=j?Math.round((b.CONFUSED||0)/D*100):0,O=j?Math.round((b.TOO_FAST||0)/D*100):0,L=j?Math.max(0,100-ee-R-O):0,X=f?.metrics?.pacingBySegment||{},K=i.useMemo(()=>{const M=Array.isArray(f?.students)?f.students:[];return(M.length>0?M:r.map(B=>({studentId:B.id,studentName:B.name,studentNumber:B.student_number,attendance:!1,quizScore:null,accuracy:null,pollsAnswered:0,exitRating:null,puzzledConcept:null}))).map(B=>{const se=typeof B.quizScore=="number"?B.quizScore:null,v=se===null?"无数据":se>=90?"优秀":se>=75?"良好":"需关注",_=se===null?"本节无可用的随堂测记录":se<75?"建议课后补充探究微练习":"课堂掌握扎实,互动积极";return{id:B.studentId,name:B.studentName,studentNumber:B.studentNumber||B.studentId,attendance:B.attendance?"出勤":"未互动",quizScore:se,accuracy:typeof B.accuracy=="number"?B.accuracy:null,pollsAnswered:Number(B.pollsAnswered)||0,rating:typeof B.exitRating=="number"?B.exitRating:null,puzzledConcept:B.puzzledConcept||"",status:v,note:_}})},[f,r]),H=K.filter(M=>M.name.toLowerCase().includes(p.toLowerCase())||M.studentNumber.toLowerCase().includes(p.toLowerCase())),re=i.useMemo(()=>Ni({durationMin:F,totalStudents:A,quizAccuracy:T,interactiveCount:Q,pacingData:b,primaryPuzzledConcept:f?.metrics?.topPuzzledConcepts?.[0]}),[a,F,A,T,Q,b,f]),te=re.lectureRatio,de=te!==null&&te>re.recommendedLectureMaxRatio,G=i.useMemo(()=>vi(K,a||"本节课"),[K,a]),S=()=>{const M=["学生学号","学生姓名","考勤状态","随堂测验得分","互动投票参与数","通票掌握评价","学情评级","教师诊断建议"],I=H.map(_=>[nt(_.studentNumber),nt(_.name),nt(_.attendance),nt(_.quizScore===null?"—":`${_.quizScore}分`),nt(`${_.pollsAnswered}次`),nt(_.rating===null?"—":`${_.rating}星`),nt(_.status),nt(_.note)]),B="data:text/csv;charset=utf-8,\uFEFF"+[M.join(","),...I.map(_=>_.join(","))].join(`
|
|
33
|
+
`),se=encodeURI(B),v=document.createElement("a");v.setAttribute("href",se),v.setAttribute("download",`${d||"Class"}_${a||"Lesson"}_学情简报.csv`),document.body.appendChild(v),v.click(),document.body.removeChild(v),c(l==="zh"?"✓ 学情简报已导出":"✓ Report Exported",l==="zh"?"CSV 简报报表已下载至本地。":"CSV report downloaded.","success")};return e.jsxs("div",{id:"classroom-briefing-view",className:"flex-1 flex flex-col min-h-0 bg-surface-secondary/20 p-4 gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 shadow-sm flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-700 dark:text-emerald-400 flex items-center justify-center shrink-0",children:e.jsx(cn,{size:24})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-black bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border border-emerald-500/30 uppercase tracking-wider",children:l==="zh"?"阶段 4 / 4 · 课堂学情全景简报":"Stage 4/4 · Panoramic Classroom Briefing"}),e.jsxs("span",{className:"text-xs text-muted font-semibold",children:[d," · ",a]})]}),e.jsx("h1",{className:"text-lg font-black text-main tracking-tight mt-1 flex items-center gap-2",children:e.jsx("span",{children:l==="zh"?"多维学情数据分析、教学反思与学业总览":"Learning Analytics & Reflection"})}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:l==="zh"?`总教学时长: ${F} 分钟 · 到课互动 ${U}/${A} 人 · 随堂测验准确率 ${T}%`:`Duration: ${F} mins · Active: ${U}/${A} · Quiz Accuracy: ${T}%`})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap w-full md:w-auto justify-end",children:[e.jsxs("button",{type:"button",onClick:s,className:"px-3 py-2 text-xs font-bold rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-main transition-colors cursor-pointer flex items-center gap-1.5 shadow-2xs",children:[e.jsx(Jt,{size:13}),e.jsx("span",{children:l==="zh"?"返回课中白板":"Back to Whiteboard"})]}),e.jsxs("button",{type:"button",onClick:h,className:"px-3 py-2 text-xs font-bold rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-main transition-colors cursor-pointer flex items-center gap-1.5 shadow-2xs",children:[e.jsx(De,{size:13}),e.jsx("span",{children:l==="zh"?"新课节准备 (课前)":"Next Lesson (Pre-Class)"})]}),e.jsxs("button",{id:"briefing-export-csv-btn",type:"button",onClick:S,className:"px-4 py-2 bg-primary-theme hover:bg-primary-theme-hover text-white rounded-xl text-xs font-bold flex items-center gap-1.5 shadow-xs cursor-pointer",children:[e.jsx(gs,{size:13}),e.jsx("span",{children:l==="zh"?"导出学情简报 (CSV)":"Export CSV"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3.5",children:[e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted uppercase tracking-wider",children:l==="zh"?"全班出勤率":"Attendance"}),e.jsx("div",{className:"text-2xl font-black text-emerald-700 dark:text-emerald-400 font-mono mt-1",children:W!=null?`${W}%`:"—"}),e.jsxs("span",{className:"text-[10px] text-muted mt-1",children:[U," / ",A," 人到课"]})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted uppercase tracking-wider",children:l==="zh"?"随堂测验正确率":"Quiz Accuracy"}),e.jsxs("div",{className:"text-2xl font-black text-primary-theme font-mono mt-1",children:[T,"%"]}),e.jsx("span",{className:"text-[10px] text-muted mt-1",children:l==="zh"?"交互题作答均分":"Interactive Avg"})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted uppercase tracking-wider",children:l==="zh"?"口播投票与抢答":"Interactions"}),e.jsxs("div",{className:"text-2xl font-black text-amber-700 dark:text-amber-400 font-mono mt-1",children:[Q," ",e.jsx("span",{className:"text-xs font-normal",children:"人次"})]}),e.jsx("span",{className:"text-[10px] text-muted mt-1",children:l==="zh"?"高参与度活跃":"High engagement"})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted uppercase tracking-wider",children:l==="zh"?"结课通票评分":"Exit Rating"}),e.jsx("div",{className:"text-2xl font-black text-indigo-500 font-mono mt-1",children:le!=null?`${le} ★`:"—"}),e.jsx("span",{className:"text-[10px] text-muted mt-1",children:l==="zh"?"掌握度 5.0 满分制":"Out of 5.0"})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted uppercase tracking-wider",children:l==="zh"?"教学节奏晴雨表":"Pacing Score"}),e.jsx("div",{className:"text-2xl font-black text-teal-600 dark:text-teal-400 font-mono mt-1",children:j?`${ee}%`:"—"}),e.jsx("span",{className:"text-[10px] text-muted mt-1",children:j?l==="zh"?"反馈节奏适宜":"Clear & Optimal":l==="zh"?"暂无反馈":"No feedback"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"lg:col-span-5 flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(Oe,{size:14,className:"text-primary-theme"}),e.jsx("span",{children:l==="zh"?"随堂节奏晴雨表分布":"Classroom Pacing Distribution"})]}),e.jsx("span",{className:"text-[11px] text-muted",children:j?`${q} 次反馈`:l==="zh"?"暂无反馈":"No feedback"})]}),j?e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-semibold mb-1",children:[e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400 flex items-center gap-1",children:"💡 听懂了 / 节奏适宜"}),e.jsxs("span",{className:"font-mono",children:[b.CLEAR," 人 (",ee,"%)"]})]}),e.jsx("div",{className:"w-full bg-surface-secondary h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500 h-full",style:{width:`${ee}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-semibold mb-1",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-400 flex items-center gap-1",children:"❓ 有些困惑 / 需要细讲"}),e.jsxs("span",{className:"font-mono",children:[b.CONFUSED," 人 (",R,"%)"]})]}),e.jsx("div",{className:"w-full bg-surface-secondary h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-amber-500 h-full",style:{width:`${R}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-semibold mb-1",children:[e.jsx("span",{className:"text-rose-600 dark:text-rose-400 flex items-center gap-1",children:"🐇 讲太快了 / 跟不上"}),e.jsxs("span",{className:"font-mono",children:[b.TOO_FAST||0," 人 (",O,"%)"]})]}),e.jsx("div",{className:"w-full bg-surface-secondary h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-rose-500 h-full",style:{width:`${O}%`}})})]}),(b.SLOW||0)>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-semibold mb-1",children:[e.jsx("span",{className:"text-indigo-600 dark:text-indigo-400 flex items-center gap-1",children:"🐢 讲太慢了 / 希望提速"}),e.jsxs("span",{className:"font-mono",children:[b.SLOW," 人 (",L,"%)"]})]}),e.jsx("div",{className:"w-full bg-surface-secondary h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-indigo-500 h-full",style:{width:`${L}%`}})})]}),Object.keys(X).length>0&&e.jsxs("div",{className:"pt-3 border-t border-theme/60 mt-1 flex flex-col gap-2",children:[e.jsx("span",{className:"text-3xs font-extrabold text-muted uppercase",children:l==="zh"?"各教学环节反馈对比:":"Breakdown by Segment:"}),e.jsx("div",{className:"space-y-1.5",children:Object.entries(X).map(([M,I])=>{const B=(I.CLEAR||0)+(I.CONFUSED||0)+(I.TOO_FAST||0)+(I.SLOW||0),se=B>0?Math.round((I.CLEAR||0)/B*100):0,v=P[M]||(M==="default"?l==="zh"?"课堂全段":"Default":M);return e.jsxs("div",{className:"p-2 rounded-xl bg-surface-secondary/40 border border-theme/40 text-2xs flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between font-bold",children:[e.jsx("span",{className:"text-main truncate max-w-[140px]",children:v}),e.jsxs("span",{className:"text-muted font-mono",children:[B," 人反馈 · 掌握度 ",se,"%"]})]}),e.jsxs("div",{className:"w-full bg-surface-secondary h-1.5 rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"bg-emerald-500 h-full",style:{width:`${B>0?(I.CLEAR||0)/B*100:0}%`},title:`听懂了: ${I.CLEAR||0}`}),e.jsx("div",{className:"bg-amber-500 h-full",style:{width:`${B>0?(I.CONFUSED||0)/B*100:0}%`},title:`困惑: ${I.CONFUSED||0}`}),e.jsx("div",{className:"bg-rose-500 h-full",style:{width:`${B>0?(I.TOO_FAST||0)/B*100:0}%`},title:`太快: ${I.TOO_FAST||0}`}),e.jsx("div",{className:"bg-indigo-500 h-full",style:{width:`${B>0?(I.SLOW||0)/B*100:0}%`},title:`太慢: ${I.SLOW||0}`})]})]},M)})})]})]}):e.jsx("div",{className:"py-8 text-center text-xs text-muted italic",children:l==="zh"?"课堂中暂无学生提交节奏晴雨表反馈":"No student pacing feedback received yet"})]}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(ve,{size:14,className:"text-amber-700 dark:text-amber-400"}),e.jsx("span",{children:l==="zh"?"极速投票作答选项分布":"Quick Poll Option Breakdown"})]}),e.jsx("span",{className:"text-[11px] text-muted font-mono",children:Q>0?l==="zh"?`共 ${Q} 票`:`${Q} votes`:l==="zh"?"暂无投票":"No votes"})]}),V.length===0?e.jsx("div",{className:"py-5 text-center text-xs text-muted bg-surface-secondary/40 rounded-xl border border-dashed border-theme",children:l==="zh"?"本场课堂会话暂无极速投票作答记录":"No quick poll votes recorded in this session"}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-center text-xs",children:V.map((M,I)=>e.jsxs("div",{className:`p-2.5 rounded-xl flex flex-col ${I===0?"bg-emerald-500/10 border border-emerald-500/30":"bg-surface-secondary border border-theme/60"}`,children:[e.jsx("span",{className:`font-bold ${I===0?"text-emerald-700 dark:text-emerald-300":"text-muted"}`,children:l==="zh"?`选项 ${M.option}`:`Option ${M.option}`}),e.jsxs("span",{className:`text-xl font-black font-mono mt-1 ${I===0?"text-emerald-700 dark:text-emerald-400":"text-main"}`,children:[M.percent,"%"]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[M.count," ",l==="zh"?"人":"votes"]})]},M.option))})]})]}),e.jsxs("div",{className:"lg:col-span-7 bg-surface rounded-2xl border border-theme p-5 shadow-sm flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between border-b border-theme pb-3 gap-2",children:[e.jsxs("span",{className:"text-xs font-black uppercase text-main tracking-wider flex items-center gap-1.5",children:[e.jsx(Vt,{size:14,className:"text-indigo-500"}),e.jsx("span",{children:l==="zh"?"AI 教学副驾反思建议 (Teaching Co-Pilot)":"AI Teaching Reflection & Insights"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-full font-bold ${te===null?"bg-surface-secondary text-muted border border-theme/60":de?"bg-rose-500/10 text-rose-700 dark:text-rose-400 border border-rose-500/20":"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 border border-emerald-500/20"}`,children:te===null?"讲授用时未采集":`讲授用时 ${te}%`}),e.jsxs("span",{className:"text-[11px] px-2 py-0.5 bg-primary-theme/10 text-primary-theme rounded-full font-bold border border-primary-theme/20",children:["互动覆盖率 ",re.interactionCoverage,"%"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 text-xs leading-relaxed max-h-[460px] overflow-y-auto pr-1",children:[re.strengths.map((M,I)=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-emerald-500/5 border border-emerald-500/20 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-emerald-700 dark:text-emerald-300 flex items-center gap-1",children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:M.title})]}),M.metricTag&&e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.2 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 rounded",children:M.metricTag})]}),e.jsx("p",{className:"text-muted",children:M.description})]},I)),re.bottlenecks.map((M,I)=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-amber-500/5 border border-amber-500/20 flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[e.jsx(Ie,{size:13}),e.jsx("span",{children:M.title})]}),M.metricTag&&e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.2 bg-amber-500/15 text-amber-700 dark:text-amber-300 rounded",children:M.metricTag})]}),e.jsx("p",{className:"text-muted",children:M.description}),e.jsxs("div",{className:"text-[11px] text-amber-800 dark:text-amber-300/80 bg-amber-500/10 p-2 rounded-lg font-mono",children:["💡 量化归因: ",M.attribution]})]},I)),re.actionableSuggestions.map((M,I)=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-indigo-500/5 border border-indigo-500/20 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-indigo-700 dark:text-indigo-300 flex items-center gap-1",children:[e.jsx(Vt,{size:13}),e.jsx("span",{children:M.title})]}),e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.2 bg-indigo-500/15 text-indigo-700 dark:text-indigo-300 rounded",children:M.timing==="next_pre_class"?"下节课前预热":M.timing==="next_in_class"?"课中环节调整":"课后分流巩固"})]}),e.jsx("p",{className:"text-muted",children:M.suggestion})]},I))]})]})]}),e.jsx(wi,{initialTiers:G,lessonTitle:a,onSelectStudent:M=>{const I=K.find(B=>B.id===M);I&&g(Yr(I,a,d))},addToast:c}),e.jsxs("div",{className:"bg-surface rounded-2xl border border-theme p-4 shadow-sm flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-black text-main uppercase tracking-wider",children:l==="zh"?"全班学生个体学习表现总览表":"Student Performance Roster"}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme font-bold border border-primary-theme/20",children:[H.length," ",l==="zh"?"人":"students"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",placeholder:l==="zh"?"搜索学生姓名或学号...":"Search student...",value:p,onChange:M=>w(M.target.value),className:"bg-surface-secondary border border-theme rounded-xl text-xs pl-8 pr-3 py-1.5 text-main outline-none w-52"}),e.jsx(Lt,{size:12,className:"absolute left-2.5 top-2.5 text-muted"})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-left text-xs text-main",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-secondary border-b border-theme font-bold text-muted select-none",children:[e.jsx("th",{className:"p-3",children:l==="zh"?"学号":"ID"}),e.jsx("th",{className:"p-3",children:l==="zh"?"学生姓名":"Student Name"}),e.jsx("th",{className:"p-3",children:l==="zh"?"考勤":"Attendance"}),e.jsx("th",{className:"p-3 text-center",children:l==="zh"?"随堂得分":"Quiz Score"}),e.jsx("th",{className:"p-3 text-center",children:l==="zh"?"互动次数":"Interactions"}),e.jsx("th",{className:"p-3 text-center",children:l==="zh"?"掌握度评分":"Rating"}),e.jsx("th",{className:"p-3",children:l==="zh"?"学情评定":"Rating Tier"}),e.jsx("th",{className:"p-3",children:l==="zh"?"个性化建议":"Recommendation"}),e.jsx("th",{className:"p-3 text-center",children:l==="zh"?"个人报告":"Digest"})]})}),e.jsx("tbody",{className:"divide-y divide-border/60",children:H.map(M=>e.jsxs("tr",{className:"hover:bg-surface-secondary/40 transition-colors",children:[e.jsx("td",{className:"p-3 font-mono text-muted",children:M.studentNumber}),e.jsx("td",{className:"p-3 font-bold text-main",children:M.name}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[11px] font-bold bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 border border-emerald-500/30",children:M.attendance})}),e.jsx("td",{className:"p-3 text-center font-mono font-bold text-main",children:M.quizScore===null?"—":`${M.quizScore} 分`}),e.jsxs("td",{className:"p-3 text-center font-mono",children:[M.pollsAnswered," 次"]}),e.jsx("td",{className:"p-3 text-center font-bold text-amber-700 dark:text-amber-400",children:M.rating===null?"—":`${M.rating} ★`}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-[11px] font-bold ${M.status==="优秀"?"bg-purple-500/10 text-purple-600 border border-purple-500/30":M.status==="良好"?"bg-blue-500/10 text-blue-700 dark:text-blue-400 border border-blue-500/30":"bg-amber-500/10 text-amber-700 dark:text-amber-400 border border-amber-500/30"}`,children:M.status})}),e.jsx("td",{className:"p-3 text-muted text-[11px] truncate max-w-xs",children:M.note}),e.jsx("td",{className:"p-3 text-center",children:e.jsxs("button",{type:"button",onClick:()=>g(Yr(M,a,d)),className:"px-2.5 py-1 text-[11px] font-bold rounded-lg border border-theme bg-surface hover:bg-primary-theme hover:text-white transition-colors cursor-pointer inline-flex items-center gap-1 shadow-2xs",children:[e.jsx(yt,{size:11}),e.jsx("span",{children:l==="zh"?"查看":"View"})]})})]},M.id))})]})})]}),e.jsx(ki,{digest:k,onClose:()=>g(null),addToast:c})]})}const Si=80,Ci=50,$i=new Set(["quiz_answered","assignment_submitted","assignment_graded","achievement","checkin","progress","courseware_submitted","success","answer"]),Ai=6;function Ei(t,n,a,o,d){const r=new Map;for(const c of n){if(!c?.student_id)continue;const u=typeof c.progress_percent=="number"?c.progress_percent:0;r.set(c.student_id,Math.max(r.get(c.student_id)??0,u))}const l=new Map;for(const c of o){if(!c?.studentId||c.studentId==="teacher"||c.studentId==="guest")continue;const u=l.get(c.studentId)??{},m=typeof c.score=="number"?c.score:void 0,p=typeof c.completion=="number"?c.completion:void 0;l.set(c.studentId,{score:m===void 0?u.score:Math.max(u.score??-1/0,m),completion:p===void 0?u.completion:Math.max(u.completion??-1/0,p)})}const s=new Set(a),h=new Set(d.map(c=>c.studentId).filter(Boolean));return t.map(c=>{const u=Math.round(r.get(c.id)??0),m=s.has(c.id),{score:p,completion:w}=l.get(c.id)??{},f=[];return m?f.push("在线"):f.push("未接入"),u>=Si?f.push(`进度领先 ${u}%`):u>=Ci?f.push(`进度 ${u}%`):u>0?f.push(`进度滞后 ${u}%`):f.push("暂无进度"),p!==void 0&&f.push(`课件 ${p} 分`),w!==void 0&&w>=1&&f.push("课件已完成"),h.has(c.id)&&f.push("发生异常"),{studentId:c.id,studentName:c.name??c.student_number??c.id,studentNumber:c.student_number,online:m,progressPercent:u,participationScore:u,quizScore:p,completion:w,behaviorTags:f,hasError:h.has(c.id)}})}function Ti(t){return t.filter(n=>n?.type&&$i.has(n.type)&&typeof n.message=="string"&&n.message.trim()).map(n=>`${n.time?`[${n.time}] `:""}${n.message.trim()}`).slice(0,Ai)}function Pi(t,n,a){if(t.length===0)return[];const o=t.map(r=>({name:r.title?.trim()||"未命名环节",minutes:kn(r)}));let d=Math.max(0,n);return o.map(r=>{const l=Math.min(r.minutes,d);return d=Math.max(0,d-l),{stageName:r.name,plannedMin:r.minutes,actualMin:Math.round(l)}})}function _i(t,n){if(!t||!Number.isFinite(t))return 0;const a=n-t;return a<=0?0:Math.floor(a/6e4)}function Ri(t){const{students:n,liveClassStudentProgress:a,onlineStudentIds:o,liveClassFeed:d,timelineSegments:r,attempts:l,sessionStartedAt:s,classroomStage:h,studentErrors:c,now:u}=t;return i.useMemo(()=>{const m=a??[],p=o??[],w=d??[],f=r??[],N=l??[],b=c??[],$=u??Date.now(),P=_i(s,$),y=Ei(n,m,p,N,b),k={};for(const A of y)k[A.studentId]=A;const g=y.filter(A=>A.online&&(A.completion!==void 0||(A.progressPercent??0)>=100)).length;return{studentMetrics:y,metricsById:k,highlights:Ti(w),stages:Pi(f,P),elapsedMin:P,plannedTotalMin:f.reduce((A,U)=>A+kn(U),0),onlineCount:y.filter(A=>A.online).length,submittedCount:g,hasRealData:m.length>0||p.length>0||w.length>0||f.length>0||N.length>0}},[n,a,o,d,r,l,s,h,c,u])}const Ii=({isOpen:t,onClose:n,snapshot:a,addToast:o,lang:d="zh"})=>{const[r,l]=i.useState(null),[s,h]=i.useState(!1),[c,u]=i.useState("class"),[m,p]=i.useState(null),[w,f]=i.useState(!1),N=i.useMemo(()=>({lessonTitle:a.lessonTitle,className:a.className,startTimeMs:a.startTimeMs,endTimeMs:a.endTimeMs,totalStudents:a.totalStudents,onlineCount:a.onlineStudentIds.length,highlights:a.highlights,stages:a.stages,studentReports:a.students.map(k=>({studentId:k.id,studentName:k.name,online:a.onlineStudentIds.includes(k.id),participationScore:k.participationScore,quizScore:k.quizScore,behaviorTags:k.behaviorTags,note:k.note}))}),[a]),b=i.useCallback(async()=>{if(a.lessonId){h(!0);try{const k=await fetch(`/api/classroom/${a.lessonId}/parent-notification`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!k.ok){const A=await k.text();throw new Error(`HTTP ${k.status}: ${A.slice(0,200)}`)}const g=await k.json();l(g),o(d==="zh"?"✅ 通知生成成功":"✅ Notifications generated",`${g.counts.students} ${d==="zh"?"位学生":"students"}`,"success")}catch(k){o(d==="zh"?"❌ 生成失败":"❌ Generation failed",k?.message??"Unknown error","error")}finally{h(!1)}}},[a.lessonId,N,o,d]);i.useEffect(()=>{t&&!r&&!s&&b()},[t,r,s,b]),i.useEffect(()=>{t||(l(null),p(null),f(!1))},[t]);const $=c==="class"?r?.classMarkdown??"":r?.studentNotifications.find(k=>k.studentId===m)?.markdown??"",P=i.useCallback(async()=>{try{await navigator.clipboard.writeText($),f(!0),o(d==="zh"?"已复制到剪贴板":"Copied to clipboard",d==="zh"?"可粘贴到微信/邮件":"Paste anywhere","success"),setTimeout(()=>f(!1),2e3)}catch{o(d==="zh"?"复制失败":"Copy failed","","error")}},[$,o,d]),y=i.useCallback(()=>{if(!r)return;const k=new Blob([r.classMarkdown,`
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
`,r.studentNotifications.map(U=>`## ${U.studentName}
|
|
38
|
+
|
|
39
|
+
${U.markdown}`).join(`
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
`)],{type:"text/markdown;charset=utf-8"}),g=URL.createObjectURL(k),A=document.createElement("a");A.href=g,A.download=`parent-notification-${a.lessonTitle}-${new Date().toISOString().slice(0,10)}.md`,A.click(),URL.revokeObjectURL(g)},[r,a.lessonTitle]);return t?e.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[120] bg-black/40 backdrop-blur-sm flex items-center justify-center p-4 animate-fade-in",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-surface-secondary px-6 py-4 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary-theme/10 flex items-center justify-center",children:e.jsx(yt,{size:20,className:"text-primary-theme"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-extrabold text-main",children:d==="zh"?"家校通知生成器":"Parent Notification Generator"}),e.jsxs("p",{className:"text-xs text-muted mt-0.5",children:[a.lessonTitle," · ",a.className," ·"," ",e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx($e,{size:10}),a.totalStudents]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:b,disabled:s,className:"px-3 py-1.5 text-xs font-bold rounded-lg border border-theme text-main hover:bg-surface transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(Pe,{size:12,className:s?"animate-spin":""}),d==="zh"?"重新生成":"Regenerate"]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface text-muted hover:text-main transition-colors","aria-label":"Close",children:e.jsx(we,{size:18})})]})]}),e.jsxs("div",{className:"px-6 pt-4 flex items-center gap-1 border-b border-theme shrink-0",children:[e.jsx(Qr,{active:c==="class",onClick:()=>u("class"),icon:e.jsx(ve,{size:12}),label:d==="zh"?"全班简报":"Class Summary",count:1}),e.jsx(Qr,{active:c==="students",onClick:()=>u("students"),icon:e.jsx($e,{size:12}),label:d==="zh"?"逐生通知":"Per-Student",count:r?.studentNotifications.length??0}),e.jsx(me,{slot:"classroom.notification.tabs"})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[c==="students"&&r&&e.jsx("div",{className:"w-64 shrink-0 border-r border-theme bg-surface-secondary overflow-y-auto scrollbar-thin",children:e.jsx("div",{className:"p-3 space-y-1",children:r.studentNotifications.map(k=>e.jsxs("button",{onClick:()=>p(k.studentId),className:`w-full text-left px-3 py-2 rounded-lg text-xs transition-colors ${m===k.studentId?"bg-primary-theme text-white shadow-sm":"hover:bg-surface text-main"}`,children:[e.jsx("div",{className:"font-bold truncate",children:k.studentName}),e.jsx("div",{className:"text-[10px] opacity-70 truncate",children:k.studentId})]},k.studentId))})}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col bg-surface",children:s&&!r?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 text-muted",children:[e.jsx(ve,{size:32,className:"animate-pulse text-primary-theme"}),e.jsx("p",{className:"text-sm font-bold",children:d==="zh"?"AI 正在生成家校通知…":"AI is generating notifications…"}),e.jsx("p",{className:"text-xs",children:d==="zh"?"通常需要 5-15 秒":"Usually takes 5-15s"})]}):c==="students"&&!m?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-muted p-8",children:[e.jsx($e,{size:32,className:"opacity-30"}),e.jsx("p",{className:"text-sm",children:d==="zh"?"从左侧选择一位学生查看通知":"Select a student from the left"})]}):e.jsx("pre",{className:"flex-1 min-h-0 overflow-auto scrollbar-thin p-6 text-sm font-mono whitespace-pre-wrap text-main leading-relaxed",children:$||(d==="zh"?"无内容":"No content")})})]}),e.jsxs("div",{className:"bg-surface-secondary px-6 py-3 border-t border-theme flex items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"text-xs text-muted flex items-center gap-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[d==="zh"?"生成时间":"Generated",": ",new Date(r.generatedAt).toLocaleTimeString()]}),r.counts.highlights>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-700 dark:text-emerald-400",children:[e.jsx(gt,{size:10}),r.counts.highlights," highlights"]})]}),r===null&&!s&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-warning",children:[e.jsx(Ie,{size:12}),d==="zh"?"尚未生成":"Not generated"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:y,disabled:!r,className:"px-3 py-1.5 text-xs font-bold rounded-lg border border-theme text-main hover:bg-surface transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(gs,{size:12}),d==="zh"?"导出 Markdown":"Export MD"]}),e.jsxs("button",{onClick:P,disabled:!$,className:`px-3 py-1.5 text-xs font-bold rounded-lg transition-colors flex items-center gap-1.5 ${w?"bg-emerald-700 text-white":"bg-primary-theme text-white hover:bg-primary-theme-hover disabled:opacity-50"}`,children:[w?e.jsx(gt,{size:12}):e.jsx(Yt,{size:12}),w?d==="zh"?"已复制":"Copied":d==="zh"?"复制到剪贴板":"Copy"]})]})]})]})}):null},Qr=({active:t,onClick:n,icon:a,label:o,count:d})=>e.jsxs("button",{onClick:n,className:`px-4 py-2 text-xs font-bold rounded-t-lg transition-colors flex items-center gap-1.5 ${t?"bg-surface text-main border-b-2 border-primary-theme":"text-muted hover:text-main"}`,children:[a,o,d>0&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded-full text-[10px] ${t?"bg-primary-theme/15 text-primary-theme":"bg-surface text-muted"}`,children:d})]}),Li=[{key:"algorithmic",label:"算法逻辑",color:"bg-indigo-500"},{key:"engineering",label:"代码工程",color:"bg-cyan-500"},{key:"creativity",label:"创新思维",color:"bg-purple-500"},{key:"collaboration",label:"团队协作",color:"bg-pink-500"},{key:"focus",label:"课堂专注",color:"bg-amber-500"}],Mi=({isOpen:t,onClose:n,lessonId:a,lessonTitle:o,currentStageName:d,elapsedMin:r,plannedTotalMin:l,studentSnapshots:s,addToast:h,lang:c="zh"})=>{const[u,m]=i.useState(null),[p,w]=i.useState(!1),[f,N]=i.useState("risk"),b=i.useCallback(async()=>{if(!(!a||s.length===0)){w(!0);try{const k=await fetch(`/api/classroom/${a}/predict-mastery`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonTitle:o,currentStageName:d,elapsedMin:r,plannedTotalMin:l,studentSnapshots:s})});if(!k.ok){const A=await k.text();throw new Error(`HTTP ${k.status}: ${A.slice(0,200)}`)}const g=await k.json();m(g)}catch(k){h(c==="zh"?"❌ 预测失败":"❌ Prediction failed",k?.message??"Unknown error","error")}finally{w(!1)}}},[a,o,d,r,l,s,h,c]);if(i.useEffect(()=>{t&&!u&&!p&&b(),t||m(null)},[t,u,p,b]),!t)return null;const $=Math.min(100,Math.round(r/Math.max(1,l)*100)),P=u?[...u.predictions].sort((k,g)=>{if(f==="risk"){const W=T=>T==="high"?0:T==="medium"?1:2;return W(k.risk)-W(g.risk)}if(f==="name")return k.studentName.localeCompare(g.studentName);const A=Object.values(k.prediction).reduce((W,T)=>W+T,0)/5,U=Object.values(g.prediction).reduce((W,T)=>W+T,0)/5;return A-U}):[],y=u?.predictions.reduce((k,g)=>(k[g.risk]=(k[g.risk]??0)+1,k),{})??{};return e.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[110] bg-black/40 backdrop-blur-sm flex items-center justify-center p-4 animate-fade-in",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-full max-w-6xl max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-surface-secondary px-6 py-4 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary-theme/10 flex items-center justify-center",children:e.jsx(Xa,{size:20,className:"text-primary-theme"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-extrabold text-main",children:c==="zh"?"AI 实时学情预测":"AI Mastery Prediction"}),e.jsxs("p",{className:"text-xs text-muted mt-0.5",children:[o," · ",d," · ",r,"/",l," min (",$,"%)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:b,disabled:p,className:"px-3 py-1.5 text-xs font-bold rounded-lg border border-theme text-main hover:bg-surface transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(Pe,{size:12,className:p?"animate-spin":""}),c==="zh"?"重新预测":"Re-predict"]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface text-muted hover:text-main transition-colors","aria-label":"Close",children:e.jsx(we,{size:18})})]})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-theme bg-surface shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"text-xs font-bold text-muted",children:c==="zh"?"课堂进度":"Progress"}),e.jsx("div",{className:"flex-1 h-2 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary-theme transition-all",style:{width:`${$}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-main",children:[$,"%"]})]}),u&&e.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[e.jsx(qs,{level:"high",count:y.high??0,lang:c}),e.jsx(qs,{level:"medium",count:y.medium??0,lang:c}),e.jsx(qs,{level:"low",count:y.low??0,lang:c}),e.jsx("span",{className:"ml-auto text-muted",children:u.aiSucceeded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600",children:[e.jsx(ve,{size:10})," AI"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-muted",children:[e.jsx(fn,{size:10})," ",c==="zh"?"降级模式":"Fallback"]})})]})]}),e.jsxs("div",{className:"px-6 pt-3 flex items-center gap-2 text-xs shrink-0",children:[e.jsxs("span",{className:"text-muted",children:[c==="zh"?"排序":"Sort",":"]}),e.jsx("button",{onClick:()=>N("risk"),className:`px-2.5 py-1 rounded font-bold ${f==="risk"?"bg-primary-theme text-white":"bg-surface-secondary text-main"}`,children:c==="zh"?"风险优先":"Risk"}),e.jsx("button",{onClick:()=>N("composite"),className:`px-2.5 py-1 rounded font-bold ${f==="composite"?"bg-primary-theme text-white":"bg-surface-secondary text-main"}`,children:c==="zh"?"综合掌握":"Composite"}),e.jsx("button",{onClick:()=>N("name"),className:`px-2.5 py-1 rounded font-bold ${f==="name"?"bg-primary-theme text-white":"bg-surface-secondary text-main"}`,children:c==="zh"?"姓名":"Name"}),e.jsx(me,{slot:"classroom.pacing.dashboard"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-thin p-6 space-y-3",children:p&&!u?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-muted",children:[e.jsx(ve,{size:32,className:"animate-pulse text-primary-theme"}),e.jsx("p",{className:"text-sm font-bold",children:c==="zh"?"AI 正在分析本节课学情…":"AI analyzing class mastery…"})]}):P.length===0?e.jsx("div",{className:"text-center text-muted text-sm py-8",children:c==="zh"?"暂无学生数据":"No student data"}):P.map(k=>e.jsx(Oi,{prediction:k,lang:c},k.studentId))}),e.jsxs("div",{className:"bg-surface-secondary px-6 py-3 border-t border-theme text-xs text-muted flex items-center justify-between shrink-0",children:[e.jsx("span",{children:u&&e.jsxs(e.Fragment,{children:[c==="zh"?"预测基于":"Based on",": ",s.length," ",c==="zh"?"位学生实时数据":"students"," · ",new Date(u.generatedAt).toLocaleTimeString()]})}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ve,{size:10}),c==="zh"?"AI 输出仅供参考,最终判断请结合教学经验":"AI suggestions only — combine with teaching experience"]})]})]})})},Oi=({prediction:t,lang:n})=>{const a=Object.values(t.prediction).reduce((l,s)=>l+s,0)/5,o=a>=75?"up":a>=55?"flat":"down",d=o==="up"?Oe:o==="flat"?fn:eo,r=t.risk==="high"?"border-rose-500 bg-rose-50":t.risk==="medium"?"border-amber-500 bg-amber-50":"border-emerald-500 bg-emerald-50";return e.jsxs("div",{className:`border-2 rounded-xl p-4 bg-surface ${r}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-extrabold text-sm text-main",children:t.studentName}),e.jsx(Di,{level:t.risk,lang:n})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(d,{size:14,className:o==="up"?"text-emerald-600":o==="flat"?"text-muted":"text-rose-600"}),e.jsx("span",{className:"font-bold text-main",children:Math.round(a)}),e.jsx("span",{className:"text-muted",children:n==="zh"?"综合":"Avg"})]})]}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mb-3",children:Li.map(l=>{const s=t.prediction[l.key];return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-muted",children:l.label}),e.jsx("span",{className:"font-bold text-main",children:s})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:`h-full ${l.color} transition-all`,style:{width:`${s}%`}})})]},l.key)})}),t.note&&e.jsxs("div",{className:"text-xs text-muted flex items-start gap-1.5",children:[e.jsx(Ie,{size:10,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:t.note})]})]})},qs=({level:t,count:n,lang:a})=>{const o=t==="high"?"bg-rose-100 text-rose-700":t==="medium"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700",d=t==="high"?a==="zh"?"高风险":"High Risk":t==="medium"?a==="zh"?"中风险":"Medium":a==="zh"?"低风险":"Low";return e.jsxs("span",{className:`px-2 py-0.5 rounded-full font-bold ${o}`,children:[d,": ",n]})},Di=({level:t,lang:n})=>{const a=t==="high"?"bg-rose-600 text-white":t==="medium"?"bg-amber-700 text-white":"bg-emerald-700 text-white",o=t==="low"?Ce:Ie,d=t==="high"?n==="zh"?"需关注":"Alert":t==="medium"?n==="zh"?"观察":"Watch":n==="zh"?"良好":"Good";return e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold inline-flex items-center gap-1 ${a}`,children:[e.jsx(o,{size:10}),d]})},En={react:"rose",promise:"rose",runtime:"rose",api:"amber",custom:"blue"},Fi=({isOpen:t,onClose:n,addToast:a,lang:o="zh"})=>{const d=xt(y=>y.errors),r=xt(y=>y.studentErrors),l=xt(y=>y.removeError),s=xt(y=>y.removeStudentError),h=xt(y=>y.clearErrors),c=xt(y=>y.clearStudentErrors),[u,m]=i.useState("student"),[p,w]=i.useState("all");i.useEffect(()=>{t&&r.length>0&&m("student")},[t,r.length]);const f=i.useMemo(()=>r.filter(y=>p==="all"||y.type===p),[r,p]),N=i.useMemo(()=>d.filter(y=>p==="all"||y.type===p),[d,p]),b=i.useCallback(()=>{const y=Array.from(new Set(r.map(k=>k.studentId))).join(", ");if(!y){a(o==="zh"?"暂无学生 ID":"No student IDs","","warning");return}navigator.clipboard.writeText(y).then(()=>a(o==="zh"?"已复制学生 ID 列表":"Copied student IDs","","success"),()=>a(o==="zh"?"复制失败":"Copy failed","","error"))},[r,a,o]);if(!t)return null;const $=u==="student"?f:N,P=u==="student"?r.length:d.length;return e.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[115] bg-black/40 backdrop-blur-sm flex items-center justify-center p-4 animate-fade-in",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-surface-secondary px-6 py-4 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-rose-500/10 flex items-center justify-center",children:e.jsx(lr,{size:20,className:"text-rose-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-extrabold text-main",children:o==="zh"?"课堂异常告警中心":"Classroom Diagnostic Center"}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:o==="zh"?"实时监控教师/学生端异常":"Real-time teacher & student error monitoring"})]})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface text-muted hover:text-main transition-colors","aria-label":"Close",children:e.jsx(we,{size:18})})]}),e.jsxs("div",{className:"px-6 pt-3 flex items-center gap-1 border-b border-theme shrink-0",children:[e.jsx(Zr,{active:u==="student",onClick:()=>m("student"),icon:e.jsx($e,{size:12}),label:o==="zh"?"学生端异常":"Student",count:r.length,accent:"rose"}),e.jsx(Zr,{active:u==="local",onClick:()=>m("local"),icon:e.jsx(js,{size:12}),label:o==="zh"?"本机异常":"Local",count:d.length,accent:"amber"}),e.jsx(me,{slot:"classroom.diagnostic.feed"})]}),e.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-theme shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"text-muted",children:[o==="zh"?"筛选":"Filter",":"]}),["all","react","runtime","promise","api","custom"].map(y=>e.jsx("button",{onClick:()=>w(y),className:`px-2 py-1 rounded font-bold ${p===y?"bg-primary-theme text-white":"bg-surface-secondary text-main"}`,children:y==="all"?o==="zh"?"全部":"All":y},y))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u==="student"&&e.jsxs("button",{onClick:b,className:"px-2.5 py-1 text-xs font-bold rounded-lg border border-theme text-main hover:bg-surface transition-colors flex items-center gap-1.5",children:[e.jsx(Yt,{size:12}),o==="zh"?"复制所有学生 ID":"Copy all IDs"]}),e.jsxs("button",{onClick:()=>u==="student"?c():h(),disabled:P===0,className:"px-2.5 py-1 text-xs font-bold rounded-lg border border-rose-500 text-rose-600 hover:bg-rose-50 transition-colors flex items-center gap-1.5 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(et,{size:12}),o==="zh"?"清空":"Clear"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-thin p-4 space-y-2",children:[$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted",children:[e.jsx(Ie,{size:32,className:"opacity-30 mb-2"}),e.jsx("p",{className:"text-sm",children:u==="student"?o==="zh"?"暂无学生端异常":"No student errors":o==="zh"?"暂无本机异常":"No local errors"})]}):$.map(y=>u==="student"?e.jsx(Bi,{error:y,onRemove:()=>s(y.id),lang:o},y.id):e.jsx(Gi,{error:y,onRemove:()=>l(y.id),lang:o},y.id)),e.jsx(me,{slot:"classroom.audit.event",slotProps:{activeTab:u,totalCount:P,currentList:$,lang:o}})]}),e.jsxs("div",{className:"bg-surface-secondary px-6 py-3 border-t border-theme text-xs text-muted flex items-center justify-between shrink-0",children:[e.jsx("span",{children:P>0?o==="zh"?`共 ${P} 条异常`:`${P} total`:o==="zh"?"一切正常":"All clear"}),e.jsxs("button",{onClick:()=>{a(o==="zh"?"已刷新":"Refreshed",o==="zh"?"本机列表":"Local list","info")},className:"inline-flex items-center gap-1 text-muted hover:text-main transition-colors",children:[e.jsx(Pe,{size:10}),o==="zh"?"刷新":"Refresh"]})]})]})})},Zr=({active:t,onClick:n,icon:a,label:o,count:d,accent:r})=>e.jsxs("button",{onClick:n,className:`px-4 py-2 text-xs font-bold rounded-t-lg transition-colors flex items-center gap-1.5 ${t?r==="rose"?"bg-surface text-rose-600 border-b-2 border-rose-500":"bg-surface text-amber-600 border-b-2 border-amber-500":"text-muted hover:text-main"}`,children:[a,o,d>0&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-extrabold ${t?r==="rose"?"bg-rose-600 text-white":"bg-amber-700 text-white":"bg-surface text-muted"}`,children:d})]}),Bi=({error:t,onRemove:n,lang:a})=>{const o=En[t.type]??"blue",d=o==="rose"?lr:o==="amber"?Ie:bn,r=o==="rose"?"border-rose-500 bg-rose-50":o==="amber"?"border-amber-500 bg-amber-50":"border-blue-500 bg-blue-50",l=o==="rose"?"text-rose-600":o==="amber"?"text-amber-600":"text-blue-600";return e.jsxs("div",{className:`border-l-4 ${r} rounded-lg p-3 flex items-start gap-3 bg-surface`,children:[e.jsx(d,{size:16,className:`${l} mt-0.5 shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-bold text-sm text-main",children:t.studentName??t.studentId}),e.jsx("span",{className:"text-[10px] text-muted font-mono",children:t.studentId}),e.jsx("span",{className:"text-[10px] text-muted",children:new Date(t.timestamp).toLocaleTimeString()})]}),e.jsx("div",{className:"text-xs font-bold text-main mb-1",children:t.title}),e.jsx("div",{className:"text-xs text-muted line-clamp-2",children:t.message})]}),e.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-surface text-muted hover:text-rose-600 transition-colors shrink-0",title:a==="zh"?"移除":"Remove",children:e.jsx(we,{size:14})})]})},Gi=({error:t,onRemove:n,lang:a})=>{const o=En[t.type]??"blue",d=o==="rose"?lr:o==="amber"?Ie:bn,r=o==="rose"?"border-rose-500 bg-rose-50":o==="amber"?"border-amber-500 bg-amber-50":"border-blue-500 bg-blue-50",l=o==="rose"?"text-rose-600":o==="amber"?"text-amber-600":"text-blue-600";return e.jsxs("div",{className:`border-l-4 ${r} rounded-lg p-3 flex items-start gap-3 bg-surface`,children:[e.jsx(d,{size:16,className:`${l} mt-0.5 shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-bold text-sm text-main",children:t.title}),t.endpoint&&e.jsxs("span",{className:"text-[10px] text-muted",children:["[",t.endpoint,"]"]}),e.jsx("span",{className:"text-[10px] text-muted",children:new Date(t.timestamp).toLocaleTimeString()})]}),e.jsx("div",{className:"text-xs text-muted line-clamp-3",children:t.message})]}),e.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-surface text-muted hover:text-rose-600 transition-colors shrink-0",title:a==="zh"?"移除":"Remove",children:e.jsx(we,{size:14})})]})},_t=["bg-indigo-500","bg-cyan-500","bg-purple-500","bg-pink-500","bg-amber-500","bg-emerald-500","bg-rose-500","bg-teal-500"];function Hi(t,n=4){if(n<=0)return[];const a=Math.max(1,n),o={advanced:3,intermediate:2,basic:1},d=[...t].sort((s,h)=>{const c=s.tier?o[s.tier]:s.score!==void 0?s.score:2;return(h.tier?o[h.tier]:h.score!==void 0?h.score:2)-c}),r=Array.from({length:a},(s,h)=>{let c="intermediate";h===0?c="advanced":h===a-1&&(c="basic");const u=c==="advanced"?"拔高组":c==="basic"?"基础组":"进阶组";return{id:`group-${h+1}`,name:`第 ${h+1} 组 (${u})`,memberIds:[],color:_t[h%_t.length],focusTier:c,likesCount:0,inquiryTags:[],isSpotlight:!1}}),l=Math.ceil(d.length/a);for(let s=0;s<d.length;s++){const h=Math.min(Math.floor(s/l),a-1);r[h].memberIds.push(d[s].id)}return r}function Wi(t,n=4){if(n<=0)return[];const a=Math.max(1,n),o={advanced:3,intermediate:2,basic:1},d=[...t].sort((h,c)=>{const u=h.tier?o[h.tier]:h.score!==void 0?h.score:2;return(c.tier?o[c.tier]:c.score!==void 0?c.score:2)-u}),r=Array.from({length:a},(h,c)=>({id:`group-${c+1}`,name:`第 ${c+1} 协作组 (拼板互助)`,memberIds:[],color:_t[c%_t.length],focusTier:"balanced",likesCount:0,inquiryTags:[],isSpotlight:!1}));let l=!0,s=0;for(let h=0;h<d.length;h++)r[s].memberIds.push(d[h].id),l?s===a-1?l=!1:s++:s===0?l=!0:s--;return r}function Ui(t,n=4,a=Math.random){if(n<=0)return[];const o=Math.max(1,n),d=[...t].sort(()=>a()-.5),r=Array.from({length:o},(l,s)=>({id:`group-${s+1}`,name:`第 ${s+1} 小组`,memberIds:[],color:_t[s%_t.length],focusTier:"balanced",likesCount:0,inquiryTags:[],isSpotlight:!1}));return d.forEach((l,s)=>{const h=s%o;r[h].memberIds.push(l.id)}),r}function qi(t,n=4,a="heterogeneous",o=Math.random){return a==="homogeneous"?Hi(t,n):a==="heterogeneous"?Wi(t,n):Ui(t,n,o)}const Xr=["#4f46e5","#06b6d4","#a855f7","#ec4899","#f59e0b","#10b981","#ef4444","#1e293b"],Vi=["思路新颖","极值合理","受力严谨","需补充推导"],Ki=({isOpen:t,onClose:n,lessonId:a,classId:o,availableStudents:d,addToast:r,lang:l="zh"})=>{const[s,h]=i.useState([]),[c,u]=i.useState([]),[m,p]=i.useState(null),[w,f]=i.useState(Xr[0]),[N,b]=i.useState(3),[$,P]=i.useState("pen"),[y,k]=i.useState(!1),[g,A]=i.useState(!0),[U,W]=i.useState("heterogeneous"),[T,Q]=i.useState(!1),[V,le]=i.useState(l==="zh"?"随堂探究驱动题:请各小组针对本题受力与运动过程进行受力拆解绘图,并标出关键守恒量。":"In-class Jigsaw Task: Collaborate to draw the state diagram and identify conserved quantities."),[F,D]=i.useState({}),[j,q]=i.useState({}),[ee,R]=i.useState(null),O=i.useRef(null);i.useEffect(()=>{if(t&&s.length===0){const v=["bg-indigo-500","bg-emerald-500","bg-amber-500","bg-rose-500"],_=Array.from({length:4}).map((Z,ie)=>({id:`group-${ie+1}`,name:l==="zh"?`第 ${ie+1} 小组`:`Group ${ie+1}`,memberIds:[],color:v[ie%v.length],focusTier:"balanced",likesCount:0,inquiryTags:[],isSpotlight:!1}));h(_),p(_[0].id)}t||(h([]),u([]),p(null),Q(!1))},[t,l]);const L=i.useCallback(()=>{if(s.length===0)return;const v=d.map((ie,xe)=>({id:ie.id,name:ie.name,tier:ie.tier||(xe%3===0?"advanced":xe%3===1?"intermediate":"basic")})),_=qi(v,s.length,U);h(_);const Z=U==="heterogeneous"?l==="zh"?"异质拼板互助(以优带新)":"Heterogeneous Jigsaw":U==="homogeneous"?l==="zh"?"同质分层探讨":"Homogeneous Tiered":l==="zh"?"随机均分":"Random";r(l==="zh"?"✅ 自动分配完成":"✅ Auto-assigned",l==="zh"?`已按「${Z}」将 ${v.length} 名学生自动分配完毕。`:`Assigned by ${Z}.`,"success")},[s.length,d,U,r,l]),X=i.useCallback(()=>{const v={id:`group-${Date.now()}`,name:l==="zh"?`第 ${s.length+1} 小组`:`Group ${s.length+1}`,memberIds:[],color:"bg-indigo-500",focusTier:"balanced",likesCount:0,inquiryTags:[],isSpotlight:!1};h(_=>[..._,v]),p(v.id)},[s.length,l]),K=i.useCallback(v=>{h(_=>_.filter(Z=>Z.id!==v)),u(_=>_.filter(Z=>Z.groupId!==v)),m===v&&p(_=>s.filter(ie=>ie.id!==v)[0]?.id??null)},[m,s]),H=i.useCallback((v,_,Z)=>{h(ie=>ie.map(xe=>{if(xe.id!==v)return xe;const he=Z?[...xe.memberIds,_]:xe.memberIds.filter(ke=>ke!==_);return{...xe,memberIds:he}}))},[]),re=i.useCallback(v=>{u(_=>_.filter(Z=>Z.groupId!==v))},[]),te=(v,_)=>{D(Z=>({...Z,[v]:(Z[v]||0)+1})),r(l==="zh"?"🌸 送花点赞成功":"🌸 Flower Awarded",l==="zh"?`已为「${_}」送出一朵协作探究鲜花!`:`Awarded flower to ${_}!`,"success")},de=(v,_)=>{q(Z=>{const ie=Z[v]||[];return ie.includes(_)?Z:{...Z,[v]:[...ie,_]}})},G=i.useRef({active:!1,start:{x:0,y:0}}),S=i.useCallback(v=>{if(!m||!O.current||T)return;const _=O.current.getBoundingClientRect(),Z={x:v.clientX-_.left,y:v.clientY-_.top};G.current={active:!0,start:Z,currentStroke:{id:`s-${Date.now()}-${Math.random()}`,groupId:m,tool:$,color:$==="eraser"?"#ffffff":w,width:N,points:[Z]}}},[m,$,w,N,T]),M=i.useCallback(v=>{const _=G.current;if(!_.active||!_.currentStroke||!O.current)return;const Z=O.current.getBoundingClientRect(),ie={x:v.clientX-Z.left,y:v.clientY-Z.top};if(_.currentStroke.tool==="pen"||_.currentStroke.tool==="eraser")_.currentStroke.points=[..._.currentStroke.points,ie];else if(_.currentStroke.tool==="rect")_.currentStroke.rect={x:Math.min(_.start.x,ie.x),y:Math.min(_.start.y,ie.y),w:Math.abs(ie.x-_.start.x),h:Math.abs(ie.y-_.start.y)};else if(_.currentStroke.tool==="circle"){const xe=ie.x-_.start.x,he=ie.y-_.start.y;_.currentStroke.circle={cx:_.start.x+xe/2,cy:_.start.y+he/2,r:Math.sqrt(xe*xe+he*he)/2}}u(xe=>[...xe.filter(he=>he.id!==_.currentStroke.id),_.currentStroke])},[]),I=i.useCallback(()=>{G.current={active:!1,start:{x:0,y:0}}},[]),B=i.useCallback(()=>{if(!m||!O.current)return;const v=O.current.outerHTML,_=new Blob([v],{type:"image/svg+xml;charset=utf-8"}),Z=URL.createObjectURL(_),ie=document.createElement("a");ie.href=Z,ie.download=`${m}-${new Date().toISOString().slice(0,10)}.svg`,ie.click(),URL.revokeObjectURL(Z)},[m]),se=i.useMemo(()=>y?c:c.filter(v=>v.groupId===m),[c,m,y]);return t?e.jsx("div",{className:"fixed inset-0 z-[118] bg-black/50 backdrop-blur-xs flex items-center justify-center p-4 animate-fade-in",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-full max-w-7xl h-[92vh] flex flex-col overflow-hidden text-main",children:[e.jsxs("div",{className:"bg-surface-secondary px-5 py-3 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-indigo-500/10 flex items-center justify-center",children:e.jsx($e,{size:18,className:"text-indigo-600 dark:text-indigo-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-extrabold text-main",children:l==="zh"?"随堂小组协作与画廊互评":"Group Collaboration & Gallery Walk"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-indigo-100 dark:bg-indigo-900/60 text-indigo-700 dark:text-indigo-300 font-mono",children:"Jigsaw & Battle"})]}),e.jsxs("p",{className:"text-2xs text-muted mt-0.5",children:[s.length," ",l==="zh"?"个探究小组":"groups"," ·"," ",T?l==="zh"?"当前处于画廊大屏互评并览":"Gallery Walk Active":l==="zh"?"当前处于组内精修":"Single Canvas Active"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(!T),className:`px-3 py-1.5 rounded-xl text-xs font-bold flex items-center gap-1.5 transition-all cursor-pointer shadow-2xs ${T?"bg-amber-700 hover:bg-amber-800 text-white shadow-amber-500/20":"bg-surface hover:bg-surface-secondary border border-theme text-main"}`,children:[e.jsx(Kt,{size:13}),e.jsx("span",{children:T?l==="zh"?"返回单组画布":"Exit Gallery":l==="zh"?"画廊互评大屏并览 (Gallery Walk)":"Gallery Walk"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface text-muted hover:text-main transition-colors cursor-pointer","aria-label":"Close",children:e.jsx(we,{size:18})})]})]}),e.jsxs("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-5 py-2 flex items-center justify-between gap-3 text-xs shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(ve,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"font-bold text-amber-700 dark:text-amber-400 shrink-0",children:l==="zh"?"探究任务:":"Mission: "}),e.jsx("input",{type:"text",value:V,onChange:v=>le(v.target.value),className:"bg-transparent border-none text-main focus:outline-hidden text-xs flex-1 truncate font-medium",placeholder:l==="zh"?"输入或调整小组驱动探究任务...":"Enter collaboration mission..."})]}),e.jsxs("span",{className:"text-3xs text-muted font-mono shrink-0 flex items-center gap-1",children:[e.jsx(or,{size:10}),l==="zh"?"各组画布实时同步":"Synced to all canvases"]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[g&&!T&&e.jsxs("div",{className:"w-72 shrink-0 border-r border-theme bg-surface-secondary/50 overflow-y-auto scrollbar-thin flex flex-col p-3.5 gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-extrabold text-main uppercase tracking-wider",children:l==="zh"?"分组策略":"Strategy"}),e.jsx("button",{onClick:X,className:"p-1 rounded hover:bg-surface text-primary-theme cursor-pointer",title:l==="zh"?"新建小组":"New group",children:e.jsx(Tt,{size:14})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 p-0.5 bg-surface rounded-lg border border-theme mb-2.5",children:[e.jsx("button",{onClick:()=>W("heterogeneous"),className:`py-1 text-2xs font-bold rounded transition-colors ${U==="heterogeneous"?"bg-primary-theme text-white":"text-muted hover:text-main"}`,title:l==="zh"?"拼板互助(1优+2中+1潜)":"Heterogeneous",children:"拼板互助"}),e.jsx("button",{onClick:()=>W("homogeneous"),className:`py-1 text-2xs font-bold rounded transition-colors ${U==="homogeneous"?"bg-primary-theme text-white":"text-muted hover:text-main"}`,title:l==="zh"?"同质分层探讨":"Homogeneous",children:"同质分层"}),e.jsx("button",{onClick:()=>W("random"),className:`py-1 text-2xs font-bold rounded transition-colors ${U==="random"?"bg-primary-theme text-white":"text-muted hover:text-main"}`,title:l==="zh"?"随机均分":"Random",children:"随机均分"})]}),e.jsxs("button",{onClick:L,className:"w-full px-3 py-1.5 text-xs font-bold rounded-xl bg-primary-theme hover:bg-primary-theme-hover text-white transition-colors flex items-center justify-center gap-1.5 shadow-2xs cursor-pointer",children:[e.jsx($e,{size:12}),e.jsx("span",{children:l==="zh"?"一键自动分配":"Auto-assign"})]})]}),e.jsxs("div",{className:"space-y-1.5 flex-1 min-h-[160px]",children:[e.jsx("h4",{className:"text-2xs font-bold text-muted uppercase tracking-wider",children:l==="zh"?"小组列表":"Groups"}),s.map(v=>e.jsxs("div",{onClick:()=>p(v.id),className:`p-2 rounded-xl border transition-all cursor-pointer ${m===v.id?"border-primary-theme bg-surface shadow-2xs font-semibold":"border-theme/40 hover:bg-surface"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${v.color}`}),e.jsx("span",{className:"text-xs font-bold text-main truncate",children:v.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[F[v.id]>0&&e.jsxs("span",{className:"text-2xs text-rose-500 font-mono flex items-center gap-0.5",children:["🌸",F[v.id]]}),e.jsx("button",{onClick:_=>{_.stopPropagation(),K(v.id)},className:"p-0.5 rounded text-muted hover:text-rose-600 hover:bg-rose-50 transition-colors",title:l==="zh"?"删除":"Remove",children:e.jsx(et,{size:11})})]})]}),e.jsx("div",{className:"text-[10px] text-muted truncate",children:v.memberIds.length===0?l==="zh"?"未分配成员":"No members":v.memberIds.map(_=>d.find(Z=>Z.id===_)?.name??_.slice(0,6)).join(", ")})]},v.id))]}),e.jsxs("div",{className:"pt-2 border-t border-theme/60",children:[e.jsx("h4",{className:"text-2xs font-bold text-muted uppercase tracking-wider mb-1.5",children:l==="zh"?"班级学生库":"Roster"}),e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto scrollbar-thin",children:d.map(v=>{const _=s.some(Z=>Z.memberIds.includes(v.id));return e.jsxs("div",{className:"flex items-center justify-between p-1 rounded hover:bg-surface text-2xs",children:[e.jsx("span",{className:_?"text-muted line-through":"text-main font-medium",children:v.name}),m&&e.jsx("button",{onClick:()=>H(m,v.id,!_),className:`px-1.5 py-0.5 rounded text-3xs font-bold ${_?"bg-surface-secondary text-muted hover:text-rose-600":"bg-primary-theme/10 text-primary-theme hover:bg-primary-theme hover:text-white"}`,children:_?"−":"+"})]},v.id)})})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col bg-surface",children:T?e.jsx("div",{className:"flex-1 p-5 overflow-y-auto bg-surface-secondary/30",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-extrabold text-sm text-main flex items-center gap-1.5",children:[e.jsx(Kt,{size:16,className:"text-amber-500"}),e.jsx("span",{children:l==="zh"?"全班小组探究画廊展台":"Classroom Gallery Walk Showcase"})]}),e.jsx("p",{className:"text-2xs text-muted",children:l==="zh"?"多组画布并排投屏,支持师生端送花点赞、思辨发问与成果置顶评选":"Side-by-side presentation, like and praise student submissions."})]}),e.jsxs("div",{className:"text-xs font-mono font-bold text-amber-600 dark:text-amber-400 bg-amber-500/10 px-3 py-1 rounded-xl border border-amber-500/30",children:["🌸 协作热度总计: ",Object.values(F).reduce((v,_)=>v+_,0)," 朵鲜花"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(v=>{const _=c.filter(he=>he.groupId===v.id),Z=F[v.id]||0,ie=j[v.id]||[],xe=ee===v.id;return e.jsxs("div",{className:`bg-surface border rounded-2xl p-3.5 shadow-sm flex flex-col gap-2.5 transition-all ${xe?"border-amber-400 ring-2 ring-amber-400/40 shadow-amber-500/10":"border-theme hover:border-primary-theme/60"}`,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme/50 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${v.color}`}),e.jsx("span",{className:"font-bold text-xs text-main",children:v.name}),xe&&e.jsx("span",{className:"px-1.5 py-0.2 rounded-md bg-amber-700 text-white text-[9px] font-bold",children:"🌟 置顶高光"})]}),e.jsxs("span",{className:"text-2xs text-muted font-mono",children:[v.memberIds.length," 成员"]})]}),e.jsxs("div",{onClick:()=>{p(v.id),Q(!1)},className:"w-full h-44 bg-white rounded-xl border border-theme/60 overflow-hidden relative cursor-pointer group",title:l==="zh"?"点击切入单组精修":"Click to edit canvas",children:[e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1200 800",preserveAspectRatio:"xMidYMid meet",children:[e.jsx("rect",{width:"1200",height:"800",fill:"#ffffff"}),_.map(he=>{if(he.tool==="pen"||he.tool==="eraser"){const ke=he.points.map((ze,ge)=>ge===0?`M ${ze.x} ${ze.y}`:`L ${ze.x} ${ze.y}`).join(" ");return e.jsx("path",{d:ke,stroke:he.color,strokeWidth:he.width*1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},he.id)}return null})]}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center",children:e.jsx("span",{className:"opacity-0 group-hover:opacity-100 bg-surface/90 text-main text-2xs font-bold px-2 py-1 rounded-lg shadow-sm transition-opacity",children:"🔍 点击切入画布"})})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsxs("button",{onClick:()=>te(v.id,v.name),className:"flex-1 py-1 px-2 rounded-lg bg-rose-500/10 hover:bg-rose-500/20 text-rose-600 dark:text-rose-400 font-bold text-xs flex items-center justify-center gap-1.5 transition-colors cursor-pointer",children:[e.jsx("span",{children:"🌸 送花赞赏"}),e.jsxs("span",{className:"font-mono text-2xs",children:["(",Z,")"]})]}),e.jsxs("button",{onClick:()=>R(xe?null:v.id),className:`py-1 px-2 rounded-lg text-xs font-bold flex items-center gap-1 transition-colors cursor-pointer ${xe?"bg-amber-700 text-white":"bg-surface-secondary text-muted hover:text-main"}`,title:l==="zh"?"设为全班高光":"Spotlight",children:[e.jsx(ft,{size:12}),e.jsx("span",{children:xe?"取消高光":"高光"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Vi.map(he=>{const ke=ie.includes(he);return e.jsx("button",{onClick:()=>de(v.id,he),className:`px-1.5 py-0.5 rounded text-[10px] transition-colors cursor-pointer ${ke?"bg-indigo-600 text-white font-bold":"bg-surface-secondary text-muted hover:text-main"}`,children:ke?`✓ ${he}`:`+ ${he}`},he)})})]})]},v.id)})})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-surface-secondary/40 px-4 py-2 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(is,{active:$==="pen",onClick:()=>P("pen"),icon:e.jsx(gn,{size:14}),label:l==="zh"?"笔":"Pen"}),e.jsx(is,{active:$==="rect",onClick:()=>P("rect"),icon:e.jsx(cr,{size:14}),label:l==="zh"?"矩形":"Rectangle"}),e.jsx(is,{active:$==="circle",onClick:()=>P("circle"),icon:e.jsx(to,{size:14}),label:l==="zh"?"圆形":"Circle"}),e.jsx(is,{active:$==="eraser",onClick:()=>P("eraser"),icon:e.jsx(jn,{size:14}),label:l==="zh"?"橡皮":"Eraser"}),e.jsx("div",{className:"h-4 w-px bg-theme mx-1"}),e.jsx("div",{className:"flex items-center gap-1",children:Xr.map(v=>e.jsx("button",{onClick:()=>f(v),style:{backgroundColor:v},className:`w-5 h-5 rounded-full transition-transform ${w===v?"scale-125 ring-2 ring-primary-theme":"hover:scale-110"}`},v))}),e.jsx("div",{className:"h-4 w-px bg-theme mx-1"}),e.jsx("div",{className:"flex items-center gap-1 text-xs",children:[1,3,5,8].map(v=>e.jsxs("button",{onClick:()=>b(v),className:`px-2 py-0.5 rounded text-2xs font-mono font-bold ${N===v?"bg-primary-theme text-white":"hover:bg-surface"}`,children:[v,"px"]},v))})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>k(!y),className:`px-2.5 py-1 text-xs font-bold rounded-lg flex items-center gap-1 transition-colors cursor-pointer ${y?"bg-primary-theme text-white":"bg-surface-secondary text-main"}`,children:[y?e.jsx(Qt,{size:12}):e.jsx(yn,{size:12}),e.jsx("span",{children:y?l==="zh"?"查看全部":"All groups":l==="zh"?"仅当前":"Single"})]}),e.jsx("button",{onClick:()=>m&&re(m),className:"px-2.5 py-1 text-xs font-bold rounded-lg bg-surface-secondary hover:bg-rose-50 hover:text-rose-600 transition-colors cursor-pointer",children:l==="zh"?"清空本组":"Clear"}),e.jsxs("button",{onClick:B,className:"px-2.5 py-1 text-xs font-bold rounded-lg bg-surface-secondary hover:bg-surface transition-colors flex items-center gap-1 cursor-pointer",children:[e.jsx(gs,{size:12}),e.jsx("span",{children:"SVG"})]}),e.jsx(me,{slot:"classroom.collab.canvas",slotProps:{lessonId:a,classId:o,activeGroupId:m,activeTool:$,activeColor:w,activeWidth:N,lang:l}})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 bg-white relative",children:[e.jsxs("svg",{ref:O,className:"w-full h-full",viewBox:"0 0 1200 800",preserveAspectRatio:"xMidYMid meet",onMouseDown:S,onMouseMove:M,onMouseUp:I,onMouseLeave:I,style:{cursor:"crosshair"},children:[e.jsx("defs",{children:e.jsx("pattern",{id:"grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M 40 0 L 0 0 0 40",fill:"none",stroke:"#f1f5f9",strokeWidth:"1"})})}),e.jsx("rect",{width:"1200",height:"800",fill:"url(#grid)"}),se.map(v=>{if(v.tool==="pen"||v.tool==="eraser"){const _=v.points.map((Z,ie)=>ie===0?`M ${Z.x} ${Z.y}`:`L ${Z.x} ${Z.y}`).join(" ");return e.jsx("path",{d:_,stroke:v.color,strokeWidth:v.width,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",opacity:v.tool==="eraser"?.4:1},v.id)}else{if(v.tool==="rect"&&v.rect)return e.jsx("rect",{x:v.rect.x,y:v.rect.y,width:v.rect.w,height:v.rect.h,stroke:v.color,strokeWidth:v.width,fill:"none"},v.id);if(v.tool==="circle"&&v.circle)return e.jsx("circle",{cx:v.circle.cx,cy:v.circle.cy,r:v.circle.r,stroke:v.color,strokeWidth:v.width,fill:"none"},v.id)}return null})]}),e.jsxs("div",{className:"absolute top-3 left-3 px-3 py-1.5 bg-surface/95 border border-theme rounded-xl text-xs font-bold text-main shadow-sm backdrop-blur-xs flex items-center gap-2",children:[e.jsxs("span",{children:[l==="zh"?"当前画布:":"Canvas: ",s.find(v=>v.id===m)?.name??(l==="zh"?"未选小组":"No group")]}),m&&F[m]>0&&e.jsxs("span",{className:"text-2xs text-rose-500 font-mono flex items-center gap-0.5",children:["🌸 ",F[m]]})]})]})]})})]})]})}):null},is=({active:t,onClick:n,icon:a,label:o})=>e.jsx("button",{onClick:n,className:`p-1.5 rounded-lg flex items-center gap-1 transition-colors cursor-pointer ${t?"bg-primary-theme text-white":"bg-surface-secondary text-main hover:bg-surface"}`,title:o,children:a}),Zs=[{type:"pitfall",label:"⚠️ 典型思维死角",shortLabel:"思维死角",icon:"⚠️",bgColor:"bg-rose-500/20",textColor:"text-rose-600 dark:text-rose-300",borderColor:"border-rose-500/40"},{type:"smart",label:"💡 巧妙化简/妙解",shortLabel:"巧妙妙解",icon:"💡",bgColor:"bg-amber-500/20",textColor:"text-amber-600 dark:text-amber-300",borderColor:"border-amber-500/40"},{type:"miss_force",label:"❌ 漏掉临界/守恒条件",shortLabel:"漏临界条件",icon:"❌",bgColor:"bg-purple-500/20",textColor:"text-purple-600 dark:text-purple-300",borderColor:"border-purple-500/40"},{type:"exemplary",label:"✅ 规范书写示范",shortLabel:"规范示范",icon:"✅",bgColor:"bg-emerald-500/20",textColor:"text-emerald-600 dark:text-emerald-300",borderColor:"border-emerald-500/40"}],en=[{name:"荧光黄",hex:"#fde047",strokeHex:"rgba(253, 224, 71, 0.45)"},{name:"荧光粉",hex:"#f472b6",strokeHex:"rgba(244, 114, 182, 0.45)"},{name:"荧光青",hex:"#22d3ee",strokeHex:"rgba(34, 211, 238, 0.45)"},{name:"荧光绿",hex:"#4ade80",strokeHex:"rgba(74, 222, 128, 0.45)"}],Ji=[{name:"批改红",hex:"#ef4444"},{name:"标注蓝",hex:"#3b82f6"},{name:"警示橙",hex:"#f97316"},{name:"强调白",hex:"#ffffff"}],Yi=({activeTool:t,activeColor:n,activeStampType:a,strokes:o,setStrokes:d,stamps:r,setStamps:l,isOverlayActive:s})=>{const h=i.useRef(null),[c,u]=i.useState(null),[m,p]=i.useState(!1),w=i.useRef(null),f=i.useRef(null),N=i.useCallback(y=>{if(!s||!h.current)return;const k=h.current.getBoundingClientRect(),g={x:y.clientX-k.left,y:y.clientY-k.top};if(t==="laser"){u(g);return}if(t==="stamp"){const A=Zs.find(W=>W.type===a),U={id:`stamp-${Date.now()}-${Math.random()}`,x:g.x,y:g.y,type:a,label:A?.label??"思维剖析",color:n,screenIndex:0};l(W=>[...W,U]);return}if(t==="highlighter"||t==="pen"){p(!0);const A={id:`stroke-${Date.now()}-${Math.random()}`,tool:t,color:n,width:t==="highlighter"?18:3,opacity:t==="highlighter"?.45:1,points:[g]};w.current=A,d(U=>[...U,A])}},[t,n,a,s,l,d]),b=i.useCallback(y=>{if(!s||!h.current)return;const k=h.current.getBoundingClientRect(),g={x:y.clientX-k.left,y:y.clientY-k.top};if(t==="laser"){u(g),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{u(null)},1200);return}if(m&&w.current){w.current.points.push(g);const A=w.current.id;d(U=>U.map(W=>W.id===A?{...W,points:[...w.current.points]}:W))}},[t,m,s,d]),$=i.useCallback(()=>{p(!1),w.current=null},[]),P=(y,k)=>{k.stopPropagation(),t==="eraser"&&l(g=>g.filter(A=>A.id!==y))};return i.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),s?e.jsxs("div",{ref:h,onPointerDown:N,onPointerMove:b,onPointerUp:$,onPointerLeave:$,"data-testid":"diff-annotation-overlay",className:`absolute inset-0 z-20 overflow-hidden select-none ${t==="laser"?"cursor-none":t==="stamp"?"cursor-copy":t==="eraser"?"cursor-cell":"cursor-crosshair"}`,style:{touchAction:"none"},children:[e.jsx("svg",{className:"w-full h-full pointer-events-none absolute inset-0",children:o.map(y=>{if(y.points.length<2)return null;const k=y.points.reduce((g,A,U)=>U===0?`M ${A.x} ${A.y}`:`${g} L ${A.x} ${A.y}`,"");return e.jsx("path",{d:k,stroke:y.color,strokeWidth:y.width,strokeOpacity:y.opacity,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"},y.id)})}),r.map(y=>{const k=Zs.find(g=>g.type===y.type);return e.jsxs("div",{onClick:g=>P(y.id,g),style:{left:`${y.x}px`,top:`${y.y}px`,transform:"translate(-50%, -50%)"},className:`absolute z-30 px-2.5 py-1 rounded-full border shadow-lg flex items-center gap-1 text-xs font-bold backdrop-blur-md transition-transform hover:scale-105 pointer-events-auto ${k?.bgColor??"bg-amber-500/20"} ${k?.borderColor??"border-amber-500/40"} ${k?.textColor??"text-amber-500"}`,children:[e.jsx("span",{children:k?.icon}),e.jsx("span",{children:k?.shortLabel??y.label})]},y.id)}),t==="laser"&&c&&e.jsxs("div",{"data-testid":"laser-pointer-cursor",style:{left:`${c.x}px`,top:`${c.y}px`,transform:"translate(-50%, -50%)"},className:"absolute pointer-events-none z-40 flex items-center justify-center",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-red-500/30 animate-ping absolute"}),e.jsx("div",{className:"w-4 h-4 rounded-full bg-red-500 shadow-[0_0_15px_#ef4444] border-2 border-white"})]})]}):null},Qi=({isOpen:t,onClose:n,lessonTitle:a="随堂探究与物理规律推导",availableStudents:o=[],candidateWorks:d,addToast:r,lang:l="zh",onSyncToClass:s})=>{const h=i.useMemo(()=>{if(d&&d.length>0)return d;const R=o;if(!R||R.length===0)return[];const O=[{title:"微元累加与动能定理联立",source:"code",content:`// 思路 A:基于动能定理与变力做功微元积分
|
|
44
|
+
const W_gravity = m * g * h;
|
|
45
|
+
const W_friction = -mu * m * g * s;
|
|
46
|
+
// 求解末速度方程:
|
|
47
|
+
const E_k = 0.5 * m * (v ** 2);
|
|
48
|
+
v = Math.sqrt(2 * g * h - 2 * mu * g * s);
|
|
49
|
+
console.log("终端速度:", v.toFixed(2), "m/s");`,tags:["经典解法","极值严密","步骤规范"],durationSec:195,category:"exemplary",accuracyScore:100},{title:"动量守恒与临界碰撞解法",source:"code",content:`// 思路 B:直接运用能量守恒定律进行代数化简
|
|
50
|
+
// 注意:未对沿斜面下滑过程的静摩擦力突变进行临界判断!
|
|
51
|
+
const delta_E = m * g * (h1 - h2);
|
|
52
|
+
// 错误点:忽略了动摩擦因数随压力的非线性衰减
|
|
53
|
+
v_end = Math.sqrt(2 * delta_E / m);`,tags:["典型死角","漏临界条件","待补充受力"],durationSec:142,category:"typical_error",accuracyScore:68},{title:"几何相交法与向量三角形",source:"whiteboard",content:`// 思路 C:基于向量合成与正弦定理求解
|
|
54
|
+
tan(theta) = F_electric / (m * g);
|
|
55
|
+
F_resultant = sqrt( (m*g)^2 + F_electric^2 );
|
|
56
|
+
// 极值判断: 当垂直于重力与电场力合力方向时加速度取得极大值`,tags:["妙解法","几何直观","图象法"],durationSec:210,category:"alternative",accuracyScore:95},{title:"拉格朗日乘子约束方程",source:"code",content:`// 思路 D:广义坐标与约束极值
|
|
57
|
+
const L = T - V; // 拉格朗日量
|
|
58
|
+
// d/dt(dL/dq_dot) - dL/dq = 0
|
|
59
|
+
// 规范矩阵化求解,推导过程工整`,tags:["大学先修","严密推演","拔高拓展"],durationSec:280,category:"exemplary",accuracyScore:100}];return R.slice(0,4).map((L,X)=>({studentId:L.id,studentName:L.name,studentNumber:L.studentNumber,seatNumber:L.seatNumber??`机位-${X+1}`,source:O[X%O.length].source,title:O[X%O.length].title,content:O[X%O.length].content,tags:O[X%O.length].tags,durationSec:O[X%O.length].durationSec,category:O[X%O.length].category,accuracyScore:O[X%O.length].accuracyScore}))},[d,o]),[c,u]=i.useState(()=>h.slice(0,2).map(R=>R.studentId));i.useEffect(()=>{c.length===0&&h.length>0&&u(h.slice(0,2).map(R=>R.studentId))},[h]);const[m,p]=i.useState(!1),[w,f]=i.useState(!0),[N,b]=i.useState(!1),[$,P]=i.useState("highlighter"),[y,k]=i.useState(en[0].strokeHex),[g,A]=i.useState("pitfall"),[U,W]=i.useState([]),[T,Q]=i.useState([]),V=i.useMemo(()=>c.length<=2?"dual":c.length===3?"triple":"quad",[c.length]),le=i.useMemo(()=>c.map(R=>h.find(O=>O.studentId===R)).filter(R=>!!R),[c,h]),F=i.useCallback(R=>{u(O=>O.includes(R)?O.length<=2?(r?.("提示","对比屏幕至少保留 2 位学生","info"),O):O.filter(L=>L!==R):O.length>=4?(r?.("提示","多屏对比最多支持 4 位学生同时投屏","warning"),O):[...O,R])},[r]),D=R=>{if(!(h.length<2))if(R==="typical_error_diff"){const O=h.find(X=>X.category==="exemplary")??h[0],L=h.find(X=>X.category==="typical_error")??h[1];u([O.studentId,L.studentId]),r?.("对比模式更新","已切换至「规范典范 vs 典型思维死角」对比","success")}else u(h.slice(0,Math.min(4,h.length)).map(O=>O.studentId)),r?.("对比模式更新",`已载入 ${Math.min(4,h.length)} 种代表性解题过程`,"success")},j=()=>{U.length>0?W(R=>R.slice(0,-1)):T.length>0&&Q(R=>R.slice(0,-1))},q=()=>{W([]),Q([]),r?.("清空完毕","已清除所有覆盖批注与印章","info")},ee=()=>{s?.({selectedIds:c,layout:V}),r?.(l==="zh"?"📡 大屏同步已下发":"📡 Broadcast Sent",l==="zh"?"已将当前多屏对比与教师实时批注图层推送到全班学生机":"Synced diff viewport to students.","success")};return t?e.jsx("div",{className:"fixed inset-0 z-[120] bg-black/60 backdrop-blur-md flex items-center justify-center p-3 md:p-6 animate-fade-in select-none",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl w-full max-w-[96vw] h-[94vh] flex flex-col overflow-hidden text-main",children:[e.jsxs("div",{className:"bg-surface-secondary/80 px-5 py-3 border-b border-theme flex flex-wrap items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-purple-500/10 flex items-center justify-center text-purple-600 dark:text-purple-400 border border-purple-500/20",children:e.jsx(so,{size:18})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-black text-main tracking-tight",children:l==="zh"?"优秀作业 / 屏幕一键多屏对比投屏批注":"Showcase & Multi-Screen Diff"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-purple-100 dark:bg-purple-900/60 text-purple-700 dark:text-purple-300 font-mono",children:V==="dual"?"2-Screen Dual":V==="triple"?"3-Screen Triple":"4-Screen Quad"})]}),e.jsxs("p",{className:"text-2xs text-muted mt-0.5",children:[a," · ",le.length," ",l==="zh"?"位学生对比中":"works compared"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>b(!N),className:`px-3 py-1.5 rounded-xl text-xs font-bold flex items-center gap-1.5 transition-all cursor-pointer shadow-2xs border ${N?"bg-purple-600 text-white border-purple-600":"bg-surface hover:bg-surface-secondary border-theme text-main"}`,children:[e.jsx($e,{size:13}),e.jsx("span",{children:l==="zh"?`勾选对比 (${c.length}/4)`:`Select (${c.length}/4)`})]}),e.jsxs("button",{onClick:()=>p(!m),className:`px-2.5 py-1.5 rounded-xl text-xs font-bold flex items-center gap-1 transition-all cursor-pointer border ${m?"bg-amber-500/10 text-amber-600 border-amber-500/30":"bg-surface border-theme text-muted hover:text-main"}`,title:l==="zh"?"匿名脱敏模式(保护学生隐私)":"Anonymous Mode",children:[m?e.jsx(yn,{size:13}):e.jsx(Qt,{size:13}),e.jsx("span",{children:m?l==="zh"?"盲评匿名中":"Anonymous":l==="zh"?"实名显示":"Real Name"})]}),e.jsxs("button",{onClick:ee,className:"px-3 py-1.5 rounded-xl text-xs font-bold bg-emerald-600 hover:bg-emerald-700 text-white flex items-center gap-1.5 transition-colors shadow-2xs cursor-pointer",children:[e.jsx(pn,{size:13}),e.jsx("span",{children:l==="zh"?"同步广播至全班":"Broadcast to Class"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface text-muted hover:text-main transition-colors cursor-pointer","aria-label":"Close",children:e.jsx(we,{size:18})})]})]}),e.jsxs("div",{className:"bg-surface px-5 py-2 border-b border-theme flex flex-wrap items-center justify-between gap-3 text-xs shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-2xs font-extrabold text-muted uppercase tracking-wider",children:[l==="zh"?"批注图层":"Overlay",":"]}),e.jsxs("button",{onClick:()=>{P("laser"),f(!0)},className:`px-2.5 py-1 rounded-lg font-bold flex items-center gap-1 transition-colors cursor-pointer ${$==="laser"&&w?"bg-red-500 text-white shadow-xs":"bg-surface-secondary text-main hover:bg-surface"}`,title:l==="zh"?"动态激光笔(光晕聚焦点)":"Laser Pointer",children:[e.jsx(vs,{size:13}),e.jsx("span",{children:l==="zh"?"激光笔":"Laser"})]}),e.jsxs("button",{onClick:()=>{P("highlighter"),f(!0),k(en[0].strokeHex)},className:`px-2.5 py-1 rounded-lg font-bold flex items-center gap-1 transition-colors cursor-pointer ${$==="highlighter"&&w?"bg-amber-400 text-black shadow-xs font-black":"bg-surface-secondary text-main hover:bg-surface"}`,title:l==="zh"?"荧光笔(半透明高亮差异)":"Highlighter",children:[e.jsx(ro,{size:13}),e.jsx("span",{children:l==="zh"?"荧光笔":"Highlighter"})]}),e.jsxs("button",{onClick:()=>{P("pen"),f(!0),k(Ji[0].hex)},className:`px-2.5 py-1 rounded-lg font-bold flex items-center gap-1 transition-colors cursor-pointer ${$==="pen"&&w?"bg-purple-600 text-white shadow-xs":"bg-surface-secondary text-main hover:bg-surface"}`,title:l==="zh"?"细线批注笔(公式推导/画箭头)":"Pen",children:[e.jsx(gn,{size:13}),e.jsx("span",{children:l==="zh"?"批注笔":"Pen"})]}),e.jsxs("button",{onClick:()=>{P("eraser"),f(!0)},className:`px-2.5 py-1 rounded-lg font-bold flex items-center gap-1 transition-colors cursor-pointer ${$==="eraser"&&w?"bg-rose-600 text-white shadow-xs":"bg-surface-secondary text-main hover:bg-surface"}`,title:l==="zh"?"橡皮擦":"Eraser",children:[e.jsx(jn,{size:13}),e.jsx("span",{children:l==="zh"?"橡皮":"Eraser"})]}),e.jsx("div",{className:"h-4 w-px bg-theme mx-1"}),e.jsx("div",{className:"flex items-center gap-1",children:Zs.map(R=>e.jsxs("button",{onClick:()=>{P("stamp"),A(R.type),f(!0)},className:`px-2 py-0.5 rounded-lg text-2xs font-bold transition-all cursor-pointer border ${$==="stamp"&&g===R.type&&w?"scale-105 ring-2 ring-purple-500 shadow-xs":"hover:bg-surface-secondary"} ${R.bgColor} ${R.borderColor} ${R.textColor}`,title:`点击后在画布上盖章:${R.label}`,children:[e.jsx("span",{children:R.icon}),e.jsx("span",{className:"ml-1",children:R.shortLabel})]},R.type))})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>f(!w),className:`px-2 py-1 rounded-lg text-2xs font-bold transition-colors cursor-pointer ${w?"text-purple-600 bg-purple-50 dark:bg-purple-950/40":"text-muted hover:text-main"}`,children:w?"图层已启用":"图层已隐藏"}),e.jsx("button",{onClick:j,className:"p-1.5 rounded-lg bg-surface-secondary hover:bg-surface text-muted hover:text-main transition-colors cursor-pointer",title:l==="zh"?"撤销上一笔":"Undo",children:e.jsx(Jt,{size:13})}),e.jsxs("button",{onClick:q,className:"px-2 py-1 rounded-lg bg-surface-secondary hover:bg-rose-50 hover:text-rose-600 transition-colors text-2xs font-bold cursor-pointer flex items-center gap-1",children:[e.jsx(et,{size:12}),e.jsx("span",{children:l==="zh"?"清空批注":"Clear"})]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 relative flex overflow-hidden bg-app",children:[N&&e.jsxs("div",{"data-testid":"student-candidate-drawer",className:"w-80 shrink-0 border-r border-theme bg-surface-secondary/70 backdrop-blur-md p-4 flex flex-col gap-3 overflow-y-auto animate-slide-right z-30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-black text-main uppercase tracking-wider",children:l==="zh"?"学生作答候选池":"Candidate Works"}),e.jsxs("span",{className:"text-2xs font-mono text-muted",children:[h.length," 份作答"]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 pt-1 border-t border-theme/60",children:[e.jsx("span",{className:"text-3xs font-extrabold text-muted uppercase",children:"快捷场景预设:"}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx("button",{onClick:()=>D("typical_error_diff"),className:"p-1.5 rounded-lg bg-surface hover:bg-purple-50 hover:text-purple-600 dark:hover:bg-purple-950/40 border border-theme text-2xs font-bold text-left transition-colors",children:"🎯 典范 vs 错解"}),e.jsx("button",{onClick:()=>D("all_top"),className:"p-1.5 rounded-lg bg-surface hover:bg-purple-50 hover:text-purple-600 dark:hover:bg-purple-950/40 border border-theme text-2xs font-bold text-left transition-colors",children:"💡 四路并行对比"})]})]}),e.jsxs("div",{className:"space-y-2 flex-1 pt-1",children:[e.jsx("span",{className:"text-3xs font-extrabold text-muted uppercase",children:"选择 2~4 位学生:"}),h.map(R=>{const O=c.includes(R.studentId);return e.jsxs("div",{onClick:()=>F(R.studentId),className:`p-2.5 rounded-xl border transition-all cursor-pointer ${O?"border-purple-500 bg-purple-50/40 dark:bg-purple-950/30 shadow-2xs font-semibold":"border-theme/60 hover:bg-surface"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O?e.jsx(no,{size:14,className:"text-purple-600"}):e.jsx(cr,{size:14,className:"text-muted"}),e.jsx("span",{className:"text-xs font-bold text-main",children:R.studentName}),e.jsx("span",{className:"text-3xs font-mono px-1 rounded bg-surface border border-theme text-muted",children:R.seatNumber})]}),e.jsx("span",{className:`text-3xs font-mono font-bold px-1.5 py-0.5 rounded ${R.category==="exemplary"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300":R.category==="typical_error"?"bg-rose-100 text-rose-700 dark:bg-rose-950 dark:text-rose-300":"bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300"}`,children:R.category==="exemplary"?"示范":R.category==="typical_error"?"典型错误":"创新"})]}),e.jsx("p",{className:"text-[11px] text-muted truncate pl-6 font-medium",children:R.title})]},R.studentId)})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 h-full relative overflow-hidden flex flex-col p-4",children:[e.jsx(Yi,{activeTool:$,activeColor:y,activeStampType:g,strokes:U,setStrokes:W,stamps:T,setStamps:Q,isOverlayActive:w}),le.length===0?e.jsxs("div",{"data-testid":"showcase-diff-empty",className:"w-full h-full flex flex-col items-center justify-center text-center p-8 bg-surface rounded-2xl border border-dashed border-theme",children:[e.jsx($e,{size:36,className:"text-muted/40 mb-3"}),e.jsx("h4",{className:"text-sm font-bold text-main",children:l==="zh"?"暂无可对比展示的学生作答":"No student works available for comparison"}),e.jsx("p",{className:"text-xs text-muted mt-1 max-w-sm",children:l==="zh"?"请等待学生在白板或互动课件中提交作答,或点击上方“勾选对比”选择学生。":"Wait for students to submit whiteboard or courseware work, or select students from the drawer."})]}):e.jsx("div",{"data-testid":"showcase-diff-grid",className:`w-full h-full grid gap-4 ${V==="dual"?"grid-cols-1 md:grid-cols-2":V==="triple"?"grid-cols-1 md:grid-cols-3":"grid-cols-1 md:grid-cols-2 grid-rows-2"}`,children:le.map((R,O)=>{const L=m?`作答方案 ${String.fromCharCode(65+O)}`:R.studentName;return e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-sm flex flex-col overflow-hidden transition-all hover:border-purple-500/50",children:[e.jsxs("div",{className:"bg-surface-secondary/60 px-4 py-2.5 border-b border-theme flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-600 text-white flex items-center justify-center font-bold text-xs shadow-2xs",children:String.fromCharCode(65+O)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-extrabold text-xs text-main",children:L}),!m&&R.seatNumber&&e.jsx("span",{className:"text-3xs text-muted font-mono bg-surface px-1.5 py-0.5 rounded border border-theme",children:R.seatNumber})]}),e.jsx("span",{className:"text-[10px] text-muted truncate block",children:R.title})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[R.durationSec&&e.jsxs("span",{className:"text-2xs font-mono text-muted flex items-center gap-0.5",children:[e.jsx(De,{size:11}),Math.floor(R.durationSec/60),"分",R.durationSec%60,"秒"]}),e.jsxs("span",{className:`px-2 py-0.5 rounded-full text-2xs font-bold font-mono ${(R.accuracyScore??0)>=90?"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300":"bg-rose-100 text-rose-700 dark:bg-rose-950 dark:text-rose-300"}`,children:[R.accuracyScore,"%"]})]})]}),e.jsxs("div",{className:"flex-1 p-4 overflow-y-auto font-mono text-xs leading-relaxed bg-surface/40",children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-2.5",children:R.tags.map(X=>e.jsxs("span",{className:"px-2 py-0.5 rounded-md text-3xs font-bold bg-surface-secondary border border-theme text-main",children:["#",X]},X))}),e.jsx("pre",{className:"p-3.5 rounded-xl bg-slate-950 text-slate-100 dark:bg-black/90 font-mono text-2xs overflow-x-auto border border-slate-800 shadow-inner",children:e.jsx("code",{children:R.content})})]}),e.jsxs("div",{className:"px-4 py-2 bg-surface-secondary/40 border-t border-theme flex items-center justify-between text-2xs text-muted",children:[e.jsx("span",{children:R.category==="exemplary"?"🌟 步骤严谨规范,适合作为全班示范":R.category==="typical_error"?"⚠️ 存在临界条件缺失,建议重点剖析":"💡 包含创新视角,可启发多元思维"}),e.jsx("span",{className:"font-mono text-3xs",children:R.source})]})]},R.studentId)})})]})]})]})}):null};class Ct{constructor(){this.mode="CLOUD_ONLINE",this.isInternetReachable=!0,this.isLocalServerReachable=!0,this.latencyMs=5,this.lastPingTimestamp=Date.now(),this.offlineEvents=[],this.listeners=new Set,this.pingIntervalTimer=null,this.syncFlushHandler=null,this.initBrowserListeners()}static{this.instance=null}static getInstance(){return Ct.instance||(Ct.instance=new Ct),Ct.instance}initBrowserListeners(){typeof window<"u"&&(window.addEventListener("online",()=>this.handleBrowserOnlineStatus(!0)),window.addEventListener("offline",()=>this.handleBrowserOnlineStatus(!1)))}startHeartbeat(n=1e4){this.pingIntervalTimer||(this.pingIntervalTimer=setInterval(()=>{this.checkConnectivity()},n))}stopHeartbeat(){this.pingIntervalTimer&&(clearInterval(this.pingIntervalTimer),this.pingIntervalTimer=null)}async checkConnectivity(){const n=Date.now();try{const o=await fetch("/api/health",{method:"GET",cache:"no-store"}).catch(()=>null);this.isLocalServerReachable=!!(o&&o.ok),this.latencyMs=Date.now()-n;const d=typeof navigator<"u"?navigator.onLine:!0;if(!this.isLocalServerReachable&&!d)this.mode="OFFLINE_DISCONNECTED",this.isInternetReachable=!1;else if(this.isLocalServerReachable&&!d)this.mode="EDGE_LAN_ONLY",this.isInternetReachable=!1;else{const r=this.mode;this.mode="CLOUD_ONLINE",this.isInternetReachable=!0,r==="EDGE_LAN_ONLY"&&this.offlineEvents.length>0&&this.flushOfflineJournal()}}catch{this.isLocalServerReachable=!1,this.mode="OFFLINE_DISCONNECTED"}this.lastPingTimestamp=Date.now();const a=this.getState();return this.notifyListeners(a),a}async setSimulatedState(n,a){const o=this.mode;this.isInternetReachable=n,this.isLocalServerReachable=a,!a&&!n?this.mode="OFFLINE_DISCONNECTED":a&&!n?this.mode="EDGE_LAN_ONLY":(this.mode="CLOUD_ONLINE",o==="EDGE_LAN_ONLY"&&this.offlineEvents.length>0&&await this.flushOfflineJournal()),this.lastPingTimestamp=Date.now(),this.notifyListeners(this.getState())}recordOfflineEvent(n,a){const o={id:`evt-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,eventType:n,payload:a,timestamp:Date.now(),synced:!1};return this.offlineEvents.push(o),this.notifyListeners(this.getState()),o}async flushOfflineJournal(){if(this.offlineEvents.length===0)return!0;if(this.syncFlushHandler){if(await this.syncFlushHandler([...this.offlineEvents]))return this.offlineEvents=[],this.notifyListeners(this.getState()),!0}else return this.offlineEvents=[],this.notifyListeners(this.getState()),!0;return!1}setSyncFlushHandler(n){this.syncFlushHandler=n}handleBrowserOnlineStatus(n){n?(this.isInternetReachable=!0,this.mode="CLOUD_ONLINE",this.flushOfflineJournal()):(this.isInternetReachable=!1,this.isLocalServerReachable?this.mode="EDGE_LAN_ONLY":this.mode="OFFLINE_DISCONNECTED"),this.notifyListeners(this.getState())}getState(){return{mode:this.mode,isInternetReachable:this.isInternetReachable,isLocalServerReachable:this.isLocalServerReachable,latencyMs:this.latencyMs,lastPingTimestamp:this.lastPingTimestamp,bufferedOfflineEventsCount:this.offlineEvents.length}}subscribe(n){return this.listeners.add(n),n(this.getState()),()=>{this.listeners.delete(n)}}notifyListeners(n){this.listeners.forEach(a=>{try{a(n)}catch(o){console.error("Error in network state listener:",o)}})}}const Vs=Ct.getInstance();function Zi({className:t="",onRefreshManual:n}){const[a,o]=i.useState(Vs.getState()),[d,r]=i.useState(!1),[l,s]=i.useState(!1);i.useEffect(()=>{const p=Vs.subscribe(w=>{o(w)});return()=>p()},[]);const h=async()=>{s(!0),await Vs.checkConnectivity(),n&&n(),setTimeout(()=>s(!1),400)},c=a.mode==="CLOUD_ONLINE",u=a.mode==="EDGE_LAN_ONLY",m=a.mode==="OFFLINE_DISCONNECTED";return e.jsxs("div",{className:`relative inline-flex items-center ${t}`,children:[e.jsxs("button",{type:"button",onClick:()=>r(!d),className:`px-2.5 py-1 rounded-full text-[11px] font-bold border transition-all flex items-center gap-1.5 cursor-pointer shadow-2xs ${c?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30 hover:bg-emerald-500/20":u?"bg-amber-500/15 text-amber-700 dark:text-amber-400 border-amber-500/40 animate-pulse hover:bg-amber-500/25":"bg-rose-500/15 text-rose-600 border-rose-500/30 hover:bg-rose-500/25"}`,title:"点击查看网络与边缘局域网状态",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${c?"bg-emerald-500":u?"bg-amber-500":"bg-rose-500"}`}),c&&e.jsx(sr,{size:12}),u&&e.jsx(ar,{size:12}),m&&e.jsx(rr,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:c?"云端在线":u?"局域网高可用模式":"网络已断开"}),u&&a.bufferedOfflineEventsCount>0&&e.jsxs("span",{className:"px-1 py-0.2 bg-amber-500/30 text-amber-900 dark:text-amber-200 rounded text-[9px] font-mono",children:[a.bufferedOfflineEventsCount," 待同步"]})]}),d&&e.jsxs("div",{className:"absolute right-0 top-full mt-2 w-72 bg-surface border border-theme rounded-2xl p-4 shadow-xl z-50 flex flex-col gap-3 animate-in fade-in duration-150",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-2",children:[e.jsx("span",{className:"text-xs font-black text-main",children:"网络拓扑与边缘节点监控"}),e.jsx("button",{type:"button",onClick:h,disabled:l,className:"text-muted hover:text-main p-1 rounded-lg hover:bg-surface-secondary cursor-pointer",title:"立即检测网络连通性",children:e.jsx(Pe,{size:12,className:l?"animate-spin":""})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted",children:"当前运行模式"}),e.jsx("span",{className:"font-bold text-main",children:c?"全功能云端在线":u?"局域网 Mesh 离线直连":"无网络连接"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted",children:"智慧教室本地主机"}),e.jsx("span",{className:`font-mono font-bold ${a.isLocalServerReachable?"text-emerald-600":"text-rose-500"}`,children:a.isLocalServerReachable?"✓ 正常响应":"✗ 未响应"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted",children:"校园外网云端连接"}),e.jsx("span",{className:`font-mono font-bold ${a.isInternetReachable?"text-emerald-600":"text-amber-600"}`,children:a.isInternetReachable?"✓ 连通":"离线 (自动降级)"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted",children:"待同步学情日志"}),e.jsxs("span",{className:"font-mono text-main",children:[a.bufferedOfflineEventsCount," 条"]})]})]}),u&&e.jsxs("div",{className:"p-2.5 rounded-xl bg-amber-500/10 border border-amber-500/20 text-[11px] text-amber-800 dark:text-amber-300 flex items-start gap-2",children:[e.jsx(Ys,{size:14,className:"shrink-0 mt-0.5"}),e.jsx("span",{children:"外网中断不影响当堂授课:师生抢答、白板同步、投屏与测验均基于本地 Socket.IO 正常运转,待网络恢复后自动完成云端数据对账。"})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{type:"button",onClick:()=>r(!1),className:"text-[11px] text-primary-theme font-bold hover:underline cursor-pointer",children:"收起详情"})})]})]})}class $t{constructor(){this.listeners=new Set,this.deviceBindings=new Map,this.isSimulationMode=!1,this.initKeyboardSimulationListener()}static{this.instance=null}static getInstance(){return $t.instance||($t.instance=new $t),$t.instance}bindDeviceToStudent(n,a,o,d){this.deviceBindings.set(n,{studentId:a,studentNumber:o,studentName:d})}getDeviceBinding(n){return this.deviceBindings.get(n)}getAllBindings(){return Array.from(this.deviceBindings.entries()).map(([n,a])=>({deviceId:n,...a}))}dispatchRawInput(n){let a="CLICKER_SUBMIT_OPTION";if(n.deviceType==="RF_CLICKER"){const r=String(n.keyOrAction).toUpperCase();["A","B","C","D","E","F","TRUE","FALSE"].includes(r)?a="CLICKER_SUBMIT_OPTION":(r==="BUZZER"||r==="OK"||r==="ENTER")&&(a="CLICKER_BUZZER_PRESS")}else if(n.deviceType==="PRESENTER_PEN"){const r=String(n.keyOrAction).toLowerCase();r==="pagedown"||r==="right"||r==="next"?a="PRESENTER_NEXT_PAGE":r==="pageup"||r==="left"||r==="prev"?a="PRESENTER_PREV_PAGE":r==="laser"||r==="b"?a="PRESENTER_LASER_TOGGLE":(r==="blank"||r==="period"||r===".")&&(a="PRESENTER_BLANK_SCREEN")}else n.deviceType==="DIGITAL_TABLET"&&(a="TABLET_DRAW_STROKE");const o=this.deviceBindings.get(n.deviceId),d={deviceId:n.deviceId,deviceType:n.deviceType,action:a,studentId:o?.studentId,studentNumber:o?.studentNumber,value:n.value??n.keyOrAction,rawPayload:n,timestamp:Date.now()};return this.notify(d),d}enableKeyboardSimulation(n=!0){this.isSimulationMode=n}initKeyboardSimulationListener(){typeof window>"u"||window.addEventListener("keydown",n=>{this.isSimulationMode&&(n.key==="PageDown"?this.dispatchRawInput({deviceId:"virtual-presenter-01",deviceType:"PRESENTER_PEN",keyOrAction:"next"}):n.key==="PageUp"&&this.dispatchRawInput({deviceId:"virtual-presenter-01",deviceType:"PRESENTER_PEN",keyOrAction:"prev"}))})}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}notify(n){this.listeners.forEach(a=>{try{a(n)}catch(o){console.error("Error executing hardware event listener:",o)}})}}const ls=$t.getInstance();function Xi({isOpen:t,onClose:n,addToast:a}){const[o,d]=i.useState([]),[r,l]=i.useState(!0);if(i.useEffect(()=>{ls.enableKeyboardSimulation(r);const c=ls.subscribe(u=>{d(m=>[u,...m].slice(0,20))});return()=>c()},[r]),!t)return null;const s=c=>{ls.dispatchRawInput({deviceId:"clicker-rf-001",deviceType:"RF_CLICKER",keyOrAction:c}),a("模拟硬件触发",`物理答题器发送选项: ${c}`,"info")},h=c=>{ls.dispatchRawInput({deviceId:"presenter-pen-01",deviceType:"PRESENTER_PEN",keyOrAction:c}),a("模拟翻页笔",`触发翻页动作: ${c}`,"info")};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl max-w-2xl w-full p-6 shadow-2xl flex flex-col gap-4 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-theme/10 text-primary-theme flex items-center justify-center",children:e.jsx(js,{size:18})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black text-main",children:"硬件教具生态标准化网关 (Hardware Bridge)"}),e.jsx("p",{className:"text-xs text-muted",children:"RF433/2.4G 物理答题器、数位板与翻页笔统一映射"})]})]}),e.jsx("button",{type:"button",onClick:n,className:"p-1 rounded-lg text-muted hover:text-main hover:bg-surface-secondary cursor-pointer",children:e.jsx(we,{size:18})})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-surface-secondary border border-theme flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(vs,{size:14,className:"text-emerald-500 animate-pulse"}),e.jsx("span",{children:"硬件按键自检与虚拟调试模拟器"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:c=>l(c.target.checked),className:"rounded text-primary-theme"}),e.jsx("span",{children:"启用键盘快捷键仿真"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-surface border border-theme/80 flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted",children:"模拟学生物理答题器"}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[["A","B","C","D"].map(c=>e.jsxs("button",{type:"button",onClick:()=>s(c),className:"px-2.5 py-1 text-xs font-black rounded-lg bg-primary-theme/10 hover:bg-primary-theme hover:text-white text-primary-theme border border-primary-theme/20 transition-all cursor-pointer",children:["按键 ",c]},c)),e.jsx("button",{type:"button",onClick:()=>s("BUZZER"),className:"px-2.5 py-1 text-xs font-black rounded-lg bg-amber-500/10 hover:bg-amber-500 hover:text-white text-amber-600 border border-amber-500/20 transition-all cursor-pointer",children:"抢答键"})]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-surface border border-theme/80 flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted",children:"模拟教师无线翻页笔"}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>h("prev"),className:"px-2.5 py-1 text-xs font-bold rounded-lg border border-theme hover:bg-surface-secondary text-main cursor-pointer",children:"◀ 上一页"}),e.jsx("button",{type:"button",onClick:()=>h("next"),className:"px-2.5 py-1 text-xs font-bold rounded-lg border border-theme hover:bg-surface-secondary text-main cursor-pointer",children:"下一页 ▶"}),e.jsx("button",{type:"button",onClick:()=>h("laser"),className:"px-2.5 py-1 text-xs font-bold rounded-lg bg-rose-500/10 text-rose-600 hover:bg-rose-500 hover:text-white border border-rose-500/20 cursor-pointer",children:"🔴 激光笔"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold text-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ao,{size:12}),e.jsx("span",{children:"底层硬件事件标准化总线监控"})]}),e.jsxs("span",{children:[o.length," 条已捕获事件"]})]}),e.jsx("div",{className:"p-2.5 rounded-xl bg-black/80 font-mono text-[11px] text-emerald-400 h-40 overflow-y-auto flex flex-col gap-1 border border-theme",children:o.length===0?e.jsx("span",{className:"text-zinc-500 italic p-2",children:"等待硬件信号接入中..."}):o.map((c,u)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-zinc-500",children:new Date(c.timestamp).toLocaleTimeString()}),e.jsxs("span",{className:"text-amber-300",children:["[",c.deviceType,"]"]}),e.jsx("span",{className:"text-sky-300",children:c.action}),e.jsxs("span",{className:"text-white",children:["值: ",String(c.value)]}),c.studentNumber&&e.jsxs("span",{className:"text-zinc-400",children:["(学号:",c.studentNumber,")"]})]},u))})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t border-theme",children:e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 bg-surface hover:bg-surface-secondary border border-theme text-main rounded-xl text-xs font-bold transition-colors cursor-pointer",children:"完成并关闭"})})]})})}const xs=[{id:"MACRO_BURST_QUIZ",name:"3分钟随堂突击检测",description:"自动触发:全屏锁定学生机 ➔ 推送检测练习 ➔ 启动倒计时 ➔ 切大屏动态榜 ➔ 自动收卷",icon:"⚡",category:"evaluation",estimatedSeconds:180,steps:[{id:"step-1",title:"广播随堂检测就绪指令",description:"向全班学生机发送高优先级通知,预热随堂检测环境。",actionType:"BROADCAST_NOTIFICATION",payload:{message:"随堂突击检测开始,请迅速就位作答!"}},{id:"step-2",title:"锁定学生端全屏作答",description:"学生机屏幕自动进入全屏防切屏作答模式。",actionType:"LOCK_STUDENT_SCREENS",payload:{locked:!0,reason:"burst_quiz"}},{id:"step-3",title:"启动 180 秒倒计时总线",description:"下发全班倒计时并在大屏与学生端同步显示。",actionType:"START_COUNTDOWN",payload:{durationSeconds:180}},{id:"step-4",title:"大屏切至 Top Performers 动态榜",description:"主屏展示实时答题进度与排行榜,营造积极竞争氛围。",actionType:"NAVIGATE_VIEW",payload:{target:"top_performers_leaderboard"}},{id:"step-5",title:"倒计时结束自动收卷与正答分析",description:"时间截止后自动提交所有未完成答卷并弹出正答率简报。",actionType:"AUTO_COLLECT_QUIZ",payload:{autoSubmit:!0}}]},{id:"MACRO_BREAKOUT_SYNC",name:"小组探究收口与画廊互评",description:"自动触发:广播讨论结束 ➔ 冻结小组画布 ➔ 弹出画廊互评展台 ➔ 开启 2 分钟点赞送花",icon:"🎨",category:"collaboration",estimatedSeconds:120,steps:[{id:"step-1",title:"广播探究收口指令",description:"提示各小组停笔,准备进行班级成果互评。",actionType:"BROADCAST_NOTIFICATION",payload:{message:"小组探究时间到,准备进入画廊互评!"}},{id:"step-2",title:"冻结子画布编辑并同步成果",description:"将各小组白板切至只读状态并向服务器提交最新画布快照。",actionType:"LOCK_STUDENT_SCREENS",payload:{subCanvasReadOnly:!0}},{id:"step-3",title:"弹出全班画廊互评展台 (Gallery Walk)",description:"主屏 4~6 组探究成果并排陈列,学生端进入互评送花界面。",actionType:"OPEN_GALLERY_WALK",payload:{durationSeconds:120}}]},{id:"MACRO_FOCUS_SILENCE",name:"全员专注静默与黑板聚焦",description:"自动触发:全屏锁定学生机画面 ➔ 提示视线回黑板 ➔ 教师白板高亮放大解题焦点",icon:"🎯",category:"focus",estimatedSeconds:30,steps:[{id:"step-1",title:"全员视线聚焦回黑板提示",description:"向全班机房学生下发视线回拢广播。",actionType:"BROADCAST_NOTIFICATION",payload:{message:"请同学们暂停操作,视线聚焦到主屏黑板!"}},{id:"step-2",title:"全屏遮罩锁定学生终端操作",description:"防止学生分心,强制统一课堂视线焦点。",actionType:"LOCK_STUDENT_SCREENS",payload:{blackout:!0}},{id:"step-3",title:"教师白板高亮核心推导区域",description:"白板自动居中并放大关键板书。",actionType:"HIGHLIGHT_WHITEBOARD",payload:{zoomScale:1.25}}]}];class At{constructor(){this.currentMacro=null,this.state={macroId:"MACRO_BURST_QUIZ",status:"idle",currentStepIndex:0,progressPercent:0,stepStartTime:0,totalSteps:0,logMessages:[]},this.listeners=new Set,this.stepExecutor=null,this.isAborted=!1}static{this.instance=null}static getInstance(){return At.instance||(At.instance=new At),At.instance}setStepExecutor(n){this.stepExecutor=n}getPresetById(n){return xs.find(a=>a.id===n)}async runMacro(n){const a=this.getPresetById(n);if(!a)return!1;this.currentMacro=a,this.isAborted=!1,this.state={macroId:n,status:"running",currentStepIndex:0,progressPercent:0,stepStartTime:Date.now(),totalSteps:a.steps.length,logMessages:[`[${new Date().toLocaleTimeString()}] 启动宏动作流: ${a.name}`]},this.notify();for(let o=0;o<a.steps.length;o++){if(this.isAborted)return this.state.status="aborted",this.state.logMessages.push(`[${new Date().toLocaleTimeString()}] 宏动作流被教师手动中止`),this.notify(),!1;const d=a.steps[o];if(this.state.currentStepIndex=o,this.state.progressPercent=Math.round((o+1)/a.steps.length*100),this.state.logMessages.push(`[${new Date().toLocaleTimeString()}] 执行步骤 ${o+1}/${a.steps.length}: ${d.title}`),this.notify(),this.stepExecutor)try{await this.stepExecutor(d)}catch(r){this.state.logMessages.push(`[${new Date().toLocaleTimeString()}] 步骤执行异常: ${r?.message}`)}}return this.state.status="completed",this.state.logMessages.push(`[${new Date().toLocaleTimeString()}] 宏动作流编排全部执行完成 ✓`),this.notify(),!0}abortCurrentMacro(){this.state.status==="running"&&(this.isAborted=!0,this.state.status="aborted",this.notify())}reset(){this.isAborted=!1,this.currentMacro=null,this.state={macroId:"MACRO_BURST_QUIZ",status:"idle",currentStepIndex:0,progressPercent:0,stepStartTime:0,totalSteps:0,logMessages:[]},this.notify()}getState(){return{...this.state}}subscribe(n){return this.listeners.add(n),n(this.getState()),()=>{this.listeners.delete(n)}}notify(){const n=this.getState();this.listeners.forEach(a=>{try{a(n)}catch(o){console.error("Error in macro state listener:",o)}})}}const cs=At.getInstance();function el({isOpen:t,onClose:n,addToast:a}){const[o,d]=i.useState("MACRO_BURST_QUIZ"),[r,l]=i.useState(cs.getState());if(i.useEffect(()=>{const m=cs.subscribe(p=>{l(p)});return()=>m()},[]),!t)return null;const s=xs.find(m=>m.id===o)||xs[0],h=r.status==="running",c=async()=>{a("教学动作流启动",`正在执行宏动作: ${s.name}`,"info"),await cs.runMacro(o)&&a("✓ 教学宏动作执行完成",`${s.name} 所有流水线步骤已全部落实。`,"success")},u=()=>{cs.abortCurrentMacro(),a("已中止宏动作","当前流水线操作已停止。","warning")};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl max-w-2xl w-full p-6 shadow-2xl flex flex-col gap-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-theme/10 text-primary-theme flex items-center justify-center font-bold",children:e.jsx(ve,{size:18})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-black text-main flex items-center gap-2",children:[e.jsx("span",{children:"课堂宏动作编排中枢 (Classroom Action Macros)"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold bg-primary-theme/10 text-primary-theme",children:"一键教学流"})]}),e.jsx("p",{className:"text-xs text-muted",children:"自定义与预设一键动作流:倒计时、锁屏推题、切榜单无缝联动"})]})]}),e.jsx("button",{type:"button",onClick:n,className:"p-1 rounded-lg text-muted hover:text-main hover:bg-surface-secondary cursor-pointer",children:e.jsx(we,{size:18})})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5",children:xs.map(m=>{const p=m.id===o;return e.jsxs("button",{type:"button",disabled:h,onClick:()=>d(m.id),className:`p-3 rounded-xl border text-left flex flex-col justify-between gap-2 transition-all cursor-pointer ${p?"border-primary-theme bg-primary-theme/5 ring-1 ring-primary-theme shadow-xs":"border-theme bg-surface hover:bg-surface-secondary/60"} disabled:opacity-50`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xl",children:m.icon}),e.jsxs("span",{className:"text-[10px] font-mono text-muted flex items-center gap-1",children:[e.jsx(De,{size:10}),e.jsxs("span",{children:["~",m.estimatedSeconds,"s"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-black text-main",children:m.name}),e.jsx("p",{className:"text-[10px] text-muted line-clamp-2 mt-0.5",children:m.description})]})]},m.id)})}),e.jsxs("div",{className:"p-4 rounded-xl bg-surface-secondary border border-theme flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(It,{size:14,className:"text-primary-theme"}),e.jsxs("span",{children:["动作流水线拆解 (",s.steps.length," 个原子动作)"]})]}),h&&e.jsxs("span",{className:"text-xs font-mono font-bold text-primary-theme animate-pulse",children:["执行中 · ",r.progressPercent,"%"]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:s.steps.map((m,p)=>{const w=h&&p<r.currentStepIndex,f=h&&p===r.currentStepIndex;return e.jsxs("div",{className:`p-2.5 rounded-lg border text-xs flex items-center justify-between transition-all ${f?"border-primary-theme bg-primary-theme/10 text-main font-bold shadow-2xs":w?"border-emerald-500/30 bg-emerald-500/5 text-muted":"border-theme bg-surface text-muted"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-mono font-bold ${f?"bg-primary-theme text-white animate-spin":w?"bg-emerald-700 text-white":"bg-surface-secondary text-muted"}`,children:w?"✓":p+1}),e.jsxs("div",{children:[e.jsx("div",{className:"text-main font-bold",children:m.title}),e.jsx("div",{className:"text-[10px] text-muted",children:m.description})]})]}),e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-surface border border-theme",children:m.actionType})]},m.id)})})]}),r.logMessages.length>0&&e.jsx("div",{className:"p-2.5 rounded-xl bg-black/80 font-mono text-[11px] text-sky-400 h-24 overflow-y-auto border border-theme flex flex-col gap-0.5",children:r.logMessages.map((m,p)=>e.jsx("div",{children:m},p))}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-theme",children:[e.jsx("button",{type:"button",onClick:n,className:"px-3 py-1.5 bg-surface hover:bg-surface-secondary border border-theme text-main rounded-xl text-xs font-bold transition-colors cursor-pointer",children:"关闭窗口"}),e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsxs("button",{type:"button",id:"btn-abort-macro",onClick:u,className:"px-4 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl text-xs font-bold flex items-center gap-1.5 transition-colors cursor-pointer",children:[e.jsx(cr,{size:13}),e.jsx("span",{children:"中止执行"})]}):e.jsxs("button",{type:"button",id:"btn-execute-macro",onClick:c,className:"px-4 py-2 bg-primary-theme hover:bg-primary-theme-hover text-white rounded-xl text-xs font-bold flex items-center gap-1.5 transition-colors cursor-pointer shadow-xs",children:[e.jsx(ys,{size:13}),e.jsx("span",{children:"立即一键执行宏动作"})]})})]})]})})}const tl=({lang:t,addToast:n,selectedLesson:a,lessonTitle:o,className:d,liveClassSelectedClassId:r,classroomStage:l,sessionStartedAt:s,students:h,liveData:c,isGrowthProfileOpen:u,onCloseGrowthProfile:m,growthProfileStudentId:p,isPeerReviewShowcaseOpen:w,onClosePeerReviewShowcase:f,onAdvanceToStage3:N,peerReviewData:b,showcaseWorks:$,onSelectSpotlightWork:P,onAutoAssignPeerReview:y,autoAssigning:k,isParentNotificationOpen:g,onCloseParentNotification:A,isMasteryPredictionOpen:U,onCloseMasteryPrediction:W,isDiagnosticCenterOpen:T,onCloseDiagnosticCenter:Q,isGroupCollabOpen:V,onCloseGroupCollab:le,isShowcaseDiffOpen:F,onCloseShowcaseDiff:D,isMacroRunnerOpen:j,onCloseMacroRunner:q,isHardwareSettingsOpen:ee,onCloseHardwareSettings:R})=>{const O=Date.now();return e.jsxs(e.Fragment,{children:[e.jsx(xr,{isOpen:u,onClose:m,student:p?(()=>{const L=h.find(X=>X.id===p);return L?{...L,name:L.name??L.student_number??L.id}:null})():null,lessonId:a,classId:r,lang:t,addToast:n}),e.jsx(za,{isOpen:w,onClose:f,lessonTitle:o,addToast:n,onAdvanceToStage3:N,workA:b.workA,workB:b.workB,showcaseWorks:$,onSelectSpotlightWork:P,matchingItems:b.matchingItems,badges:b.badges,podiumStudents:b.podiumStudents,danmaku:b.danmaku,reactions:b.reactions,rubricDimensions:b.rubricDimensions,reviewProgress:b.reviewProgress,onAutoAssign:y,autoAssigning:k}),e.jsx(Ii,{isOpen:g,onClose:A,snapshot:{lessonTitle:o,lessonId:a,className:d,classId:r,startTimeMs:s??O,endTimeMs:O,totalStudents:h.length,onlineStudentIds:c.studentMetrics.filter(L=>L.online).map(L=>L.studentId),highlights:c.highlights,stages:c.stages,students:c.studentMetrics.map(L=>({id:L.studentId,name:L.studentName,student_number:L.studentNumber,participationScore:L.participationScore,quizScore:L.quizScore,behaviorTags:L.behaviorTags}))},addToast:n,lang:t}),e.jsx(Mi,{isOpen:U,onClose:W,lessonId:a,lessonTitle:o,currentStageName:l??"IN_CLASS_TEACHING",elapsedMin:c.elapsedMin,plannedTotalMin:c.plannedTotalMin,studentSnapshots:c.studentMetrics.map(L=>({studentId:L.studentId,studentName:L.studentName,participationScore:L.participationScore,quizScore:L.quizScore,paceIndicator:L.progressPercent>=80?"fast":L.progressPercent>=50?"on-track":L.progressPercent>0?"slow":"stalled",behaviorSignals:L.behaviorTags})),addToast:n,lang:t}),e.jsx(Fi,{isOpen:T,onClose:Q,addToast:n,lang:t}),e.jsx(Ki,{isOpen:V,onClose:le,lessonId:a,classId:r,availableStudents:h.map(L=>({id:L.id,name:L.name??L.student_number??L.id})),addToast:n,lang:t}),e.jsx(Qi,{isOpen:!!F,onClose:D??(()=>{}),lessonTitle:o,availableStudents:h.map(L=>({id:L.id,name:L.name??L.student_number??L.id,seatNumber:L.seat_number??L.seatNumber})),addToast:n,lang:t}),e.jsx(el,{isOpen:!!j,onClose:q??(()=>{}),addToast:n}),e.jsx(Xi,{isOpen:!!ee,onClose:R??(()=>{}),addToast:n})]})};function sl({lang:t,onOpenDiagnosticCenter:n,onOpenMasteryPrediction:a,onOpenGroupCollab:o,onOpenShowcaseDiff:d,onOpenPeerReviewShowcase:r,onOpenParentNotification:l,onOpenMacroRunner:s,onOpenHardwareSettings:h,selectedLesson:c,syncChannel:u,onlineStudentCount:m,onTimeRemainingChange:p}){return e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto border-l border-theme pl-2.5 shrink-0",children:[e.jsx("button",{onClick:n,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-rose-50 text-rose-700 hover:bg-rose-100 border border-rose-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"课堂异常告警中心":"Diagnostic Center","aria-label":t==="zh"?"课堂异常告警中心":"Diagnostic Center",children:"⚠️"}),e.jsx("button",{onClick:a,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border border-indigo-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"AI 实时学情预测":"AI Mastery Prediction","aria-label":t==="zh"?"AI 实时学情预测":"AI Mastery Prediction",children:"🧠"}),e.jsx("button",{onClick:o,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-emerald-50 text-emerald-700 hover:bg-emerald-100 border border-emerald-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"随堂小组协作与画廊互评展台 (Jigsaw & Gallery Walk)":"Group Collab & Gallery Walk","aria-label":t==="zh"?"随堂小组协作与画廊互评展台 (Jigsaw & Gallery Walk)":"Group Collab & Gallery Walk",children:"👥"}),e.jsx("button",{onClick:d,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-purple-50 text-purple-700 hover:bg-purple-100 border border-purple-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"优秀作业 / 屏幕一键多屏对比投屏批注 (Showcase & Dual-Screen Diff)":"Showcase & Multi-Screen Diff","aria-label":t==="zh"?"优秀作业 / 屏幕一键多屏对比投屏批注 (Showcase & Dual-Screen Diff)":"Showcase & Multi-Screen Diff",children:"🔍"}),r&&e.jsx("button",{id:"btn-open-peer-review-showcase",onClick:r,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-amber-50 text-amber-700 hover:bg-amber-100 border border-amber-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"全班大屏作业互评与协同赏析秀场 (Peer Review & Showcase)":"Peer Review & Showcase","aria-label":t==="zh"?"全班大屏作业互评与协同赏析秀场 (Peer Review & Showcase)":"Peer Review & Showcase",children:"🌟"}),e.jsx("button",{onClick:l,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-amber-50 text-amber-700 hover:bg-amber-100 border border-amber-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"家校通知生成器(课中预生成可在下课期间直接复制)":"Parent Notification","aria-label":t==="zh"?"家校通知生成器(课中预生成可在下课期间直接复制)":"Parent Notification",children:"✉️"}),e.jsx("button",{id:"btn-open-classroom-macros",onClick:s,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-sky-50 text-sky-700 hover:bg-sky-100 border border-sky-200 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"课堂宏动作编排中枢 (Classroom Action Macros)":"Action Macros","aria-label":t==="zh"?"课堂宏动作编排中枢 (Classroom Action Macros)":"Action Macros",children:"⚡"}),e.jsx("button",{id:"btn-open-hardware-bridge",onClick:h,className:"w-7 h-7 sm:w-8 sm:h-8 text-xs font-bold rounded-lg bg-slate-100 text-slate-700 hover:bg-slate-200 border border-slate-300 transition-all flex items-center justify-center cursor-pointer shadow-2xs hover:scale-105 active:scale-95 shrink-0",title:t==="zh"?"硬件教具生态标准化网关设置":"Hardware Bridge","aria-label":t==="zh"?"硬件教具生态标准化网关设置":"Hardware Bridge",children:"🎛️"}),e.jsx(Zi,{className:"ml-1 shrink-0"}),e.jsx(mo,{variant:"header",lessonId:c,lang:t,syncChannel:u,onlineStudentCount:m,onTimeRemainingChange:p})]})}const Tn=["completed","submitted","finished"],rl=["active","inprogress","started"];function nl({lang:t,selectedLesson:n,liveClassSelectedClassId:a,attempts:o,displayAttempts:d,loadingAttempts:r,searchQuery:l,setSearchQuery:s,submissionFilter:h,setSubmissionFilter:c,fetchAttempts:u,setMiddleTab:m,autoRecordRule:p,autoRecordRuleLoaded:w,savingAutoRecordRule:f,saveAutoRecordRule:N,autoRecordReport:b,runAutoRecord:$,autoRecordRunning:P,handleViewRaw:y,handlePromoteAttempt:k,handleMarkAbsent:g}){return e.jsxs("div",{className:"flex-grow flex-1 min-h-0 w-full relative rounded-xl overflow-hidden border border-theme shadow-md bg-surface flex flex-col p-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4 gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-main",children:t==="zh"?"学生互动提交数据列表":"Student Submissions"}),o.length>0&&e.jsxs("span",{className:"text-xs bg-primary-theme/10 text-primary-theme px-2 py-0.5 rounded-full border border-primary-theme/20 font-bold",title:d.length===o.length?void 0:t==="zh"?`已按所选班级/筛选条件过滤,全部记录共 ${o.length} 条`:`Filtered by the selected class/filters. ${o.length} records in total.`,children:[d.length," ",t==="zh"?"条记录":"records",d.length!==o.length&&e.jsxs("span",{className:"ml-1 font-normal opacity-70",children:["/ ",o.length]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",placeholder:t==="zh"?"搜索学生或课件...":"Search student or courseware...",value:l,onChange:A=>s(A.target.value),className:"bg-surface border border-theme rounded-lg text-xs pl-8 pr-3 py-1.5 focus:ring-1 focus:ring-primary-theme text-main outline-none w-44 transition-all"}),e.jsx(Lt,{size:12,className:"absolute left-2.5 top-2.5 text-muted"})]}),e.jsxs("select",{value:h,onChange:A=>c(A.target.value),className:"bg-surface border border-theme rounded-lg text-xs px-3 py-1.5 focus:ring-1 focus:ring-primary-theme text-main outline-none cursor-pointer hover:bg-surface-secondary transition-colors",children:[e.jsx("option",{value:"all",children:t==="zh"?"全部状态":"All Status"}),e.jsx("option",{value:"submitted",children:t==="zh"?"已提交/完成":"Submitted/Finished"}),e.jsx("option",{value:"started",children:t==="zh"?"进行中":"In Progress"})]}),e.jsx("button",{onClick:u,disabled:r,className:"p-1.5 bg-surface hover:bg-surface-secondary border border-theme rounded-lg text-muted hover:text-main transition-colors cursor-pointer flex items-center justify-center shadow-sm disabled:opacity-50",title:t==="zh"?"刷新数据":"Refresh",children:e.jsx(Pe,{size:12,className:r?"animate-spin":""})}),e.jsxs("button",{onClick:()=>m("top_performers"),className:"px-2.5 py-1.5 bg-amber-500/10 hover:bg-amber-500/20 text-amber-600 dark:text-amber-400 border border-amber-500/30 rounded-lg text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 shadow-xs",title:t==="zh"?"查看随堂测验 Top 5 榜单":"View Top 5 Performers",children:[e.jsx(bt,{size:12,className:"text-amber-500"}),e.jsx("span",{children:t==="zh"?"优秀榜":"Top 5"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap mb-3 shrink-0 px-3 py-2 rounded-lg border border-theme bg-surface-secondary/40",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:p.enabled,disabled:!w||f,onChange:A=>void N({...p,enabled:A.target.checked}),className:"w-3.5 h-3.5 accent-primary-theme cursor-pointer disabled:opacity-50"}),e.jsxs("span",{className:"text-xs font-bold text-main flex items-center gap-1",children:[e.jsx(dn,{size:12,className:"text-primary-theme"}),t==="zh"?"自动录入成绩":"Auto-record scores"]})]}),e.jsx("span",{className:"text-[11px] text-muted",title:t==="zh"?"规则在「全局默认策略」上配置,个别课件可在成绩配置中单独覆盖。学生提交后由服务端直接写入学期成绩,无需逐条点击「录入成绩」。":"Configured on the global default; individual courseware can override.",children:p.enabled?t==="zh"?`已开启 · 完成后自动写入学期成绩${b?`(本次 ${b.recorded} 条)`:""}`:`On${b?` (${b.recorded} recorded)`:""}`:t==="zh"?"关闭中 · 仍可逐条手动录入":"Off · manual recording still available"}),p.enabled&&e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("span",{className:"text-[11px] text-muted whitespace-nowrap",children:t==="zh"?"完成度门槛":"Min completion"}),e.jsx("input",{type:"range","aria-label":t==="zh"?"完成度门槛":"Min completion",min:0,max:100,step:5,value:Math.round(p.minCompletion*100),disabled:f,onChange:A=>N({...p,minCompletion:Number(A.target.value)/100}),onMouseUp:()=>void N(p),onTouchEnd:()=>void N(p),className:"w-24 accent-primary-theme cursor-pointer disabled:opacity-50"}),e.jsxs("span",{className:"text-[11px] font-bold font-mono text-main w-9 text-right",children:[Math.round(p.minCompletion*100),"%"]})]}),p.enabled&&e.jsxs("label",{className:"flex items-center gap-1.5 select-none",children:[e.jsx("span",{className:"text-[11px] text-muted whitespace-nowrap",children:t==="zh"?"更新策略":"Update policy"}),e.jsxs("select",{value:p.strategy,disabled:f,onChange:A=>{const U=A.target.value==="highest"?"highest":"latest";N({...p,strategy:U})},className:"text-[11px] px-1.5 py-0.5 bg-surface border border-theme rounded-lg text-main cursor-pointer disabled:opacity-50",title:t==="zh"?"自动录入行被学生重做后的分数取法:最新 = 取最新一次提交;最高 = 仅新分更高才覆盖。教师手动录入的分数永远受保护。":"How auto-recorded rows update on resubmission: latest = newest attempt wins; highest = only overwrite when higher. Manual scores are always protected.",children:[e.jsx("option",{value:"latest",children:t==="zh"?"最新一次":"Latest"}),e.jsx("option",{value:"highest",children:t==="zh"?"最高分":"Highest"})]})]}),e.jsxs("button",{onClick:()=>void $(!1),disabled:P||!n||!a,className:"px-2.5 py-1 bg-primary-theme/10 hover:bg-primary-theme/20 text-primary-theme border border-primary-theme/30 rounded-lg text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed",title:t==="zh"?"按当前规则,把本课节本班已提交但未录入的记录补录进来(重复点击不会重复记分)":"Record any submitted-but-unrecorded rows per the current rule (idempotent)",children:[e.jsx(qt,{size:12,className:P?"animate-pulse":""}),e.jsx("span",{children:P?t==="zh"?"补录中…":"Recording…":t==="zh"?"立即补录":"Run now"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto border border-theme rounded-xl scrollbar-thin",children:r?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-muted gap-2",children:[e.jsx(Pe,{size:24,className:"animate-spin text-primary-theme mb-2"}),e.jsx("span",{className:"text-xs",children:t==="zh"?"正在加载学生提交数据...":"Loading submissions..."})]}):d.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center py-12 text-muted gap-2",children:[e.jsx(yt,{size:32,className:"text-muted/60"}),e.jsx("span",{className:"text-xs",children:t==="zh"?"暂无匹配的提交数据。":"No matching submissions found."}),!a&&e.jsx("span",{className:"text-xs text-muted italic",children:t==="zh"?"提示:请在顶部选择一个班级进行筛选。":"Tip: Select a class at the top to filter."})]}):e.jsxs("table",{className:"w-full border-collapse text-left text-xs text-main",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-secondary border-b border-theme font-bold text-muted select-none",children:[e.jsx("th",{className:"p-3",children:t==="zh"?"学生姓名":"Student Name"}),e.jsx("th",{className:"p-3",children:t==="zh"?"交互课件":"Courseware"}),e.jsx("th",{className:"p-3",children:t==="zh"?"状态":"Status"}),e.jsx("th",{className:"p-3 text-center",children:t==="zh"?"成绩":"Score"}),e.jsx("th",{className:"p-3 text-center",children:t==="zh"?"完成度":"Completion"}),e.jsx("th",{className:"p-3 text-right",children:t==="zh"?"操作":"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-theme",children:d.map(A=>{const U=Tn.includes(A.status),W=A.score!==null&&A.score!==void 0,T=U&&W,Q=U?W?void 0:t==="zh"?"该提交没有分数,无法录入(不会凭空记分)":"No score available":t==="zh"?"该提交仍在进行中,完成后才能录入学期成绩":"Still in progress",V=A.started_at?new Date(A.started_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"N/A";return e.jsxs("tr",{className:"hover:bg-surface-secondary/50 transition-colors group",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("div",{className:"font-semibold text-main",children:A.studentName}),e.jsxs("div",{className:"text-xs text-muted mt-0.5",children:[t==="zh"?"时间":"Time",": ",V]})]}),e.jsx("td",{className:"p-3 font-medium text-main max-w-[150px] truncate",title:A.coursewareName,children:A.coursewareName}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full border text-xs font-bold ${U?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-blue-50 text-blue-700 border-blue-100 animate-pulse"}`,children:U?t==="zh"?"已提交":"Finished":t==="zh"?"进行中":"Running"})}),e.jsx("td",{className:"p-3 text-center font-bold font-mono",children:A.score!==null?e.jsxs("span",{className:"text-primary-theme bg-primary-theme/10 border border-primary-theme/20 px-1.5 py-0.5 rounded-md",children:[A.score,"分"]}):e.jsx("span",{className:"text-muted font-medium",children:"-"})}),e.jsx("td",{className:"p-3 text-center font-semibold font-mono",children:A.completion!==null?`${Math.round(A.completion*100)}%`:"0%"}),e.jsx("td",{className:"p-3 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs("button",{onClick:()=>y(A),className:"p-1 text-muted hover:text-primary-theme hover:bg-surface-secondary border border-transparent hover:border-theme rounded-lg transition-colors cursor-pointer flex items-center gap-1 text-xs",title:t==="zh"?"查看提交轨迹事件数据":"View Raw Data",children:[e.jsx(Qt,{size:12}),e.jsx("span",{children:t==="zh"?"轨迹":"Events"})]}),A.isPromoted>0?e.jsxs("span",{className:"px-2 py-1 text-emerald-650 font-bold text-xs flex items-center gap-0.5 bg-emerald-50/50 rounded-lg border border-emerald-100",children:[e.jsx(gt,{size:11}),t==="zh"?"已归档":"Saved"]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>k(A.attemptId),disabled:!T,className:`px-2 py-1 text-xs font-bold rounded-lg flex items-center gap-1 shadow-sm transition-all active:scale-95 cursor-pointer border ${T?"bg-primary-theme hover:bg-primary-theme-hover text-white border-primary-theme":"bg-surface-secondary text-muted border-theme cursor-not-allowed opacity-60"}`,title:Q??(t==="zh"?"将分数和进度作为随堂学习数据存入数据库,记入学期成绩":"Save to DB & Semester grade"),children:[e.jsx(qt,{size:11}),e.jsx("span",{children:t==="zh"?"录入成绩":"Record"})]}),e.jsx("button",{onClick:()=>{window.confirm(t==="zh"?`确定把【${A.studentName}】的「${A.coursewareName}」标记为缺考吗?
|
|
60
|
+
缺考按 0 分计入学期成绩;学生补交不会自动覆盖,教师改判请手动录入。`:`Mark ${A.studentName} as absent for "${A.coursewareName}"?
|
|
61
|
+
Absent counts as 0 in semester grades; resubmission won't override it — use manual recording instead.`)&&g(A.studentId,A.coursewareId)},className:"px-2 py-1 text-xs font-bold rounded-lg flex items-center gap-1 shadow-sm transition-all active:scale-95 cursor-pointer border bg-surface text-muted hover:text-red-600 hover:border-red-200 border-theme",title:t==="zh"?"该生未参加本次课件学习(如缺席),成绩按 0 分计":"Student did not participate (e.g. absent); counts as 0",children:e.jsx("span",{children:t==="zh"?"标缺考":"Absent"})})]})]})})]},A.attemptId)})})]})})]})}function jl({initialPortalOpen:t=!0}){const{selectedLesson:n,setSelectedLesson:a,setTeacherTab:o,lessons:d,classes:r,plugins:l,lang:s,timelineSegments:h,activeSegmentId:c,setActiveSegmentId:u,liveClassSelectedClassId:m,setLiveClassSelectedClassId:p,liveClassIsActive:w,setLiveClassIsActive:f,liveClassFeed:N,setLiveClassFeed:b,liveClassAcknowledgedMap:$,setLiveClassAcknowledgedMap:P,elements:y,fetchElements:k,addToast:g,onlineStudentIds:A,activeStudentLessons:U,liveClassStudentProgress:W,classStudentsMap:T,fetchClassStudents:Q,socketRef:V,session:le,showCoursewareHub:F,setShowCoursewareHub:D}=Sa(),j=m?T[m]||[]:[],q=async()=>{await Ks.getState().loadStudents(),m&&await Q(m)},ee=(x,C)=>{V?.current&&V.current.emit("teacher-ping-student",{studentId:x,lessonId:n,message:C})},R=()=>D(!0),[O,L]=i.useState(!1),[X,K]=i.useState(!1),[H,re]=i.useState(null),[te,de]=i.useState(null),G=xt(x=>x.studentErrors),S=Ca(x=>x.setTeacherTab);i.useEffect(()=>{de(null)},[m]),i.useEffect(()=>{te&&!j.some(x=>x.id===te)&&de(null)},[j,te]),i.useEffect(()=>{if(!te)return;const x=C=>{C.key==="Escape"&&de(null)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[te]);const[M,I]=i.useState(!1),[B,se]=i.useState(null),[v,_]=i.useState([]),Z=i.useRef(!1),ie=i.useRef({lesson:null,classId:null}),xe=i.useRef(null),he=i.useRef(null),[ke,ze]=i.useState(!1),ge=i.useRef(null),Ae=i.useRef(null),_e=i.useRef(null),Be=i.useRef(null),[Mt,at]=i.useState(null);i.useEffect(()=>()=>{he.current&&clearInterval(he.current),Ae.current&&clearTimeout(Ae.current),_e.current&&clearTimeout(_e.current),Be.current&&clearTimeout(Be.current)},[]);const tt=i.useRef(null),[Ge,Nt]=i.useState([]),[J,z]=i.useState(0),[ce,fe]=i.useState(!1),[ue,be]=i.useState("PRE_CLASS_READY"),[Le,Fe]=i.useState(null),ye=i.useRef(null),[Xt,ws]=i.useState(void 0),[Me,ks]=i.useState(n),[Pn,zs]=i.useState(!1),[vt,hr]=i.useState(!1);i.useEffect(()=>{ks(n)},[n]);const es=!!n&&pi()===n,Ve=Br.getState().pendingLiveClassLaunch,[pr,He]=i.useState(t&&!es&&!Ve),[_n,wt]=i.useState(!1),[Rn,We]=i.useState(t&&!es&&!Ve),[In,ot]=i.useState(!t||es||!!Ve),Ue=i.useRef(!1),Ke=i.useRef(!t||es||!!Ve);i.useEffect(()=>{Ve&&(a(Ve.lessonId),Ve.classId&&p(Ve.classId),k(Ve.lessonId),Ue.current=!1,Br.getState().setPendingLiveClassLaunch(null))},[]);const[Ln,Mn]=i.useState(!1),[On,Dn]=i.useState(null),[fr,br]=i.useState(!1),[Fn,gr]=i.useState(!1),[Bn,jr]=i.useState(!1),[Gn,yr]=i.useState(!1),[Hn,Nr]=i.useState(!1),[Wn,vr]=i.useState(!1),[Un,wr]=i.useState(!1),[qn,kr]=i.useState(!1),[zr,ts]=i.useState(null),[Ss,Vn]=i.useState(!1),[kt,Kn]=i.useState([]);i.useEffect(()=>{if(!n){be("PRE_CLASS_READY"),ts(null),ot(!0);return}let x=!0;Ue.current||ot(!1),ye.current||be("PRE_CLASS_READY");const C=()=>{fetch(`/api/classroom/sessions/${n}`).then(Y=>Y.ok?Y.json():null).then(Y=>{if(!x||!Y)return;Vn(!!Y.hasActiveSession),ye.current?be("ARCHIVED_REPORT"):Y.hasActiveSession&&Y.stage?be(Y.stage):Y.stage==="ARCHIVED_REPORT"?be("ARCHIVED_REPORT"):be(Re=>Re==="ARCHIVED_REPORT"?"ARCHIVED_REPORT":"PRE_CLASS_READY");const ae=Y.session?.class_id?String(Y.session.class_id):null,ne=!!Y.hasActiveSession&&Cn(Y.stage);ne&&!Ue.current&&!Ke.current&&(He(!1),We(!0));const pe=Ks.getState().liveClassSelectedClassId;(ne&&ae&&pe!==ae||!ne&&ae&&!pe)&&p(ae);const je=Y.session?.started_at??Y.startedAt??null;ts(typeof je=="number"?je:null),Array.isArray(Y.feedReplay)&&Y.feedReplay.length>0&&b(Re=>{const ct=new Set(Re.map(Xe=>Xe?.id).filter(Boolean)),Te=Y.feedReplay.filter(Xe=>!ct.has(Xe.id));return Te.length>0?[...Te,...Re]:Re});const oe=Y.session?.current_segment_id??null;oe&&!c&&u(oe);const Ee=Number(Y.viewState?.currentPage);Number.isFinite(Ee)&&Ee>0&&ws(Ee)}).catch(()=>{}).finally(()=>{x&&ot(!0)})};C();const E=setInterval(C,15e3);return()=>{x=!1,clearInterval(E)}},[n]);const[Sr,Cr]=Et.useState(new Map);Et.useEffect(()=>{if(!n){Cr(new Map);return}let x=!0;const C=()=>{fetch(`/api/lessons/${n}/rollcall-counts`).then(Y=>Y.ok?Y.json():null).then(Y=>{!x||!Y?.counts||Cr(new Map(Object.entries(Y.counts)))}).catch(()=>{})};C();const E=setInterval(C,15e3);return()=>{x=!1,clearInterval(E)}},[n]);const Cs=Ri({students:j,liveClassStudentProgress:W,onlineStudentIds:A,liveClassFeed:N,timelineSegments:h,attempts:kt,sessionStartedAt:zr,classroomStage:ue,studentErrors:G}),{data:Jn,topPerformers:$s,showcaseWorks:Yn,setSpotlightWork:Qn,autoAssigning:Zn,autoAssign:Xn}=$a({lessonId:n,enabled:fr,attempts:kt,studentCount:j.length,addToast:g,lang:s}),ea=Et.useMemo(()=>{const x=new Map($s.map(E=>[E.studentId,E.cumulativeScore])),C=new Map($s.map(E=>[E.studentId,E.accuracy]));return Cs.studentMetrics.map((E,Y)=>{const ae=C.get(E.studentId),ne={};return typeof ae=="number"&&ae>0&&(ne.logic=Math.round(ae)),typeof E.completion=="number"&&(ne.engineering=Math.round(E.completion*100)),E.progressPercent>0&&(ne.focus=E.progressPercent),{id:E.studentId,name:E.studentName,studentNo:E.studentNumber,groupName:j[Y]?.group_name??void 0,seatNumber:j[Y]?.seat_number??void 0,currentPoints:x.get(E.studentId)??0,focusScore:E.progressPercent,pickedCountToday:Sr.get(E.studentId)??0,competencyScores:Object.keys(ne).length>0?ne:void 0}})},[Cs.studentMetrics,$s,j,Sr]),it=async x=>{if(!n){be(x);return}try{const C=await fetch(`/api/classroom/sessions/${n}/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stage:x,classId:m})});if(!C.ok){const E=await C.json().catch(()=>({}));g(s==="zh"?"⚠️ 阶段切换被拒绝":"⚠️ Stage change rejected",E?.error||E?.message||`HTTP ${C.status}`,"warning");return}be(x)}catch(C){console.error("Failed to update stage:",C),g(s==="zh"?"⚠️ 阶段切换失败":"⚠️ Stage change failed",s==="zh"?"网络异常,请重试":"Network error, please retry","warning")}},ta=async({lessonId:x,classId:C,teachingModeId:E})=>{const Y=await fetch(`/api/classroom/sessions/${x}/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({classId:C,teachingModeId:E??void 0})});if(!Y.ok){const ae=await Y.json().catch(()=>null);throw new Error(ae?.error||(s==="zh"?"初始化课堂会话失败":"Failed to initialise the classroom session"))}a(x),p(C),k(x),Ue.current=!1,Ke.current=!0,dt(x),We(!1),He(!1)},[Ne,Je]=i.useState("whiteboard"),As=(Aa()?.getExtensions("classroom.active_segment.main")||[]).length>0,st=h.find(x=>x.id===c),[$r,Ar]=i.useState(!1),[Ye,Es]=i.useState(null),[Ts,ss]=i.useState(null),[sa,Er]=i.useState(!1),[rs,ra]=i.useState("all"),[Ps,na]=i.useState(""),[_s,Rs]=i.useState({enabled:!1,minCompletion:0,strategy:"latest"}),[Is,aa]=i.useState(!1),[oa,Tr]=i.useState(!1),[ia,la]=i.useState(null),[ca,Pr]=i.useState(!1),_r=i.useRef(g);i.useEffect(()=>{_r.current=g},[g]);const Ot=i.useCallback((x,C,E="info")=>_r.current(x,C,E),[]),Qe=i.useCallback(async()=>{Ar(!0);try{const x=await fetch("/api/courseware/attempts?pageSize=all");if(x.ok){const C=Ea(await x.json());Kn(C)}}catch(x){console.error("Failed to fetch attempts",x)}finally{Ar(!1)}},[]);i.useEffect(()=>{Ne==="submissions"&&Qe()},[Ne]),i.useEffect(()=>{let x=null;const C=Wt(E=>{x?.();const Y=()=>{Qe()};E.on("courseware-attempt-updated",Y),x=()=>{typeof E.off=="function"&&E.off("courseware-attempt-updated",Y)}});return()=>{C(),x?.()}},[Qe]);const Rr=async x=>{if(!n||!m){g(s==="zh"?"⚠️ 无法操作":"⚠️ Action Prevented",s==="zh"?"请先在顶部栏选择要绑定的课节和班级。":"Please select lesson and class first.","warning");return}try{const C=await fetch(`/api/courseware/attempts/${x}/promote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:n,classId:m})});if(C.ok){const E=await C.json();g(s==="zh"?"✓ 学习数据已保存":"✓ Data Recorded",s==="zh"?`成功将该数据存入数据库!分数: ${E.score},已同步更新至学生学习进度。`:`Successfully recorded submission! Score: ${E.score}.`,"success"),Qe(),q&&q()}else{const E=await C.json();throw new Error(E.error||"Server error")}}catch(C){g(s==="zh"?"❌ 保存失败":"❌ Save Failed",C.message||"Error occurred while saving.","warning")}},da=async(x,C)=>{if(!n||!m){g(s==="zh"?"⚠️ 无法操作":"⚠️ Action Prevented",s==="zh"?"请先在顶部栏选择要绑定的课节和班级。":"Please select lesson and class first.","warning");return}if(!C){g(s==="zh"?"⚠️ 无法标记缺考":"⚠️ Cannot Mark Absent",s==="zh"?"该提交缺少课件标识。":"Missing courseware identity.","warning");return}try{const E=await fetch("/api/courseware/attempts/mark-absent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:n,classId:m,studentId:x,coursewareId:C})}),Y=await E.json().catch(()=>({}));if(E.ok)g(s==="zh"?"✓ 已标记缺考":"✓ Marked Absent",s==="zh"?`已将【${Y.coursewareName??"该课件"}】成绩标记为缺考(结算按 0 分计)。学生补交不会自动覆盖,教师改判请手动录入。`:`Marked as absent for ${Y.coursewareName??"the courseware"}. Manual recording overrides this.`,"success"),Qe(),q&&q();else throw new Error(Y.error||"Server error")}catch(E){g(s==="zh"?"❌ 标记缺考失败":"❌ Mark Absent Failed",E.message||"Error occurred while marking absent.","warning")}},Ir=i.useCallback(async()=>{try{const x=await fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"courseware.get_score_config",payload:{coursewareId:"*"}})});if(!x.ok)return;const C=await x.json(),E=C?.result??C;Rs({enabled:!!(E?.auto_record_enabled??E?.autoRecordEnabled),minCompletion:Number(E?.auto_record_min_completion??E?.autoRecordMinCompletion??0)||0,strategy:E?.auto_record_strategy==="highest"||E?.autoRecordStrategy==="highest"?"highest":"latest"})}catch{}finally{aa(!0)}},[]),xa=async x=>{const C=_s;Rs(x),Tr(!0);try{const E=await fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"courseware.save_score_config",payload:{coursewareId:"*",autoRecordEnabled:x.enabled,autoRecordMinCompletion:x.minCompletion,autoRecordStrategy:x.strategy}})});if(!E.ok)throw new Error("Failed to save rule");const Y=await E.json();if(Y&&Y.success===!1)throw new Error(Y.error||"save_score_config rejected");Ot(s==="zh"?"✓ 规则已保存":"✓ Rule Saved",x.enabled?s==="zh"?`学生提交课件后将自动录入学期成绩(完成度门槛 ${Math.round(x.minCompletion*100)}%)`:`Scores will be recorded automatically (completion ≥ ${Math.round(x.minCompletion*100)}%)`:s==="zh"?"已关闭自动录入,仍可逐条手动录入":"Auto-record disabled; manual recording still available","success")}catch(E){Rs(C),console.error("[LiveClassroomView] save auto-record rule failed:",E),Ot(s==="zh"?"❌ 规则保存失败":"❌ Failed to save rule",s==="zh"?"请检查网络后重试。":"Please retry.","warning")}finally{Tr(!1)}},Ls=i.useCallback(async(x=!1)=>{if(!(!n||!m)){Pr(!0);try{const C=await fetch("/api/courseware/attempts/auto-record",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:n,classId:m})});if(!C.ok)throw new Error("auto-record failed");const E=await C.json();la({recorded:E.recorded??0,skipped:E.skipped??0}),(E.recorded??0)>0&&await Qe(),x||Ot(s==="zh"?"✓ 自动录入完成":"✓ Auto-record done",s==="zh"?`已录入 ${E.recorded??0} 条,跳过 ${E.skipped??0} 条(已录入 / 无分数 / 未达门槛)`:`Recorded ${E.recorded??0}, skipped ${E.skipped??0}`,"success")}catch{x||Ot(s==="zh"?"❌ 自动录入失败":"❌ Auto-record failed",s==="zh"?"请稍后重试,或使用逐条手动录入。":"Please retry or record manually.","warning")}finally{Pr(!1)}}},[n,m,Qe,Ot,s]),Lr=async x=>{Es(x),Er(!0),ss(null);try{const C=await fetch(`/api/courseware/attempts/${x.attemptId}/raw`);if(C.ok){const E=await C.json();ss(E)}else ss({error:"Failed to load raw data"})}catch(C){ss({error:C.message||"Error loading data"})}finally{Er(!1)}},Ms=j.filter(x=>x.locked_lesson_id===n),lt=!!(m&&Ms.length>0),Ze=Ms.some(x=>x.lock_mode==="navigation")&&!Ms.some(x=>x.lock_mode==="full")?"navigation":"full";i.useEffect(()=>{Ne==="submissions"&&Ir()},[Ne,Ir]),i.useEffect(()=>{Ne!=="submissions"||!Is||!_s.enabled||!n||!m||Ls(!0)},[Ne,Is,n,m,Ls]);const Mr=()=>{if(xe.current&&!xe.current.closed){xe.current.focus(),g(s==="zh"?"🎓 学生Tab已激活":"🎓 Student Tab Focused",s==="zh"?"已将联动学生端浏览器Tab置顶激活。":"Focused the student browser tab.","info");return}const x=j[0],C=x?.id||"student-demo",E=x?.name||(s==="zh"?"演示学生":"Demo Student"),Y=n||"",ae=m||"",ne=`${window.location.origin}${window.location.pathname}?mode=student_live&studentId=${encodeURIComponent(C)}&lessonId=${encodeURIComponent(Y)}&classId=${encodeURIComponent(ae)}#/student_live`,pe=window.open(ne,"_blank");if(!pe||pe.closed){g(s==="zh"?"⚠️ 新Tab打开被拦截":"⚠️ Tab Open Blocked",s==="zh"?"请在浏览器设置中允许打开新标签页,以查看联动学生端。":"Please allow new tabs in browser settings.","warning");return}xe.current=pe,ze(!0),he.current&&clearInterval(he.current),he.current=setInterval(()=>{(!xe.current||xe.current.closed)&&(ze(!1),xe.current=null,he.current&&(clearInterval(he.current),he.current=null))},1e3),g(s==="zh"?"🎓 学生端新Tab已打开":"🎓 Student Tab Opened",s==="zh"?`已在独立浏览器Tab中打开【${E}】学生端,教师端所有操作将实时同步!`:`Opened student tab for ${E}. Operations are syncing in real time!`,"success")},Dt=i.useRef({selectedLesson:n,activeSegmentId:c,middleTab:Ne,isClassLocked:lt,liveClassSelectedClassId:m,liveClassIsActive:w,students:j,lang:s});Dt.current={selectedLesson:n,activeSegmentId:c,middleTab:Ne,isClassLocked:lt,liveClassSelectedClassId:m,liveClassIsActive:w,students:j,lang:s},i.useEffect(()=>{const x=new Ta(Pa,n,m);ge.current=x;const C=x.onMessage(E=>{if(E.type==="STUDENT_ACKNOWLEDGE_PICK"){const Y=E.payload.studentId,ae=Dt.current.students.find(ne=>ne.id===Y)?.name||Y;P(ne=>{const pe=new Map(ne);return pe.set(Y,!0),pe}),b(ne=>[{id:`feed-ack-${Y}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:Dt.current.lang==="zh"?`学生【${ae}】已在独立视窗中确认点名并举手答到!`:`Student "${ae}" acknowledged classroom pick from student window!`},...ne]),g(Dt.current.lang==="zh"?"🙋♂️ 学生已举手应答":"🙋♂️ Student Acknowledged",Dt.current.lang==="zh"?`学生【${ae}】已在独立视窗中确认收到点名!`:`Student "${ae}" acknowledged!`,"success")}});return()=>{C(),x.destroy(),ge.current=null}},[n,m]),i.useEffect(()=>{ge.current?.setLessonContext(n,m),ge.current?.broadcastChangeLesson(n)},[n,m]),i.useEffect(()=>{ge.current?.broadcastChangeSegment(c),n&&Ss&&Ae.current&&clearTimeout(Ae.current),n&&Ss&&(Ae.current=setTimeout(()=>{fetch(`/api/classroom/sessions/${encodeURIComponent(n)}/view-state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activeSegmentId:c})}).catch(()=>{})},500))},[c,n,Ss]),i.useEffect(()=>{if(!n)return;const x=ne=>{!ne||typeof ne!="object"||b(pe=>pe.some(je=>je?.id&&je.id===ne.id)?pe:[ne,...pe])},C=ne=>{!ne||ne.lessonId!==n||ne.stage&&(be(ne.stage),ne.stage==="ARCHIVED_REPORT"&&f(!1))},E=ne=>{!ne||ne.lessonId!==n||(ye.current=null,Fe(null),be("PRE_CLASS_READY"),f(!1),ts(null))};let Y=null;const ae=Wt(ne=>{Y?.(),ne.on("classroom:feed_appended",x),ne.on("classroom:stage_changed",C),ne.on("classroom:session_deleted",E),Y=()=>{typeof ne.off=="function"?(ne.off("classroom:feed_appended",x),ne.off("classroom:stage_changed",C),ne.off("classroom:session_deleted",E)):typeof ne.removeListener=="function"&&(ne.removeListener("classroom:feed_appended",x),ne.removeListener("classroom:stage_changed",C),ne.removeListener("classroom:session_deleted",E))}});return()=>{ae(),Y?.()}},[n]),i.useEffect(()=>{ge.current?.broadcastChangeTab(Ne==="submissions"||Ne==="top_performers"||Ne==="segment_main"?"courseware":Ne)},[Ne]),i.useEffect(()=>{ge.current?.broadcastLockClass(lt)},[lt]);const ma=l.filter(x=>x.status==="active"),ua=Array.from(new Map(ma.flatMap(x=>{try{const C=typeof x.manifest=="string"?JSON.parse(x.manifest):x.manifest,E=C.classroomTools||[],Y=C.contributes?.["classroom.tool"]||[];return[...E,...Y].map(ae=>({...ae,pluginId:x.id,manifestId:C.id}))}catch{return[]}}).map(x=>[x.id,x])).values());i.useEffect(()=>{if(!n||!m){ie.current={lesson:null,classId:null};return}(ie.current.lesson!==n||ie.current.classId!==m)&&(ie.current={lesson:n,classId:m},zt(!0))},[n,m]);const ha=x=>{u(x.id);const C=dr(x,{fallbackSeconds:300}).seconds??300;qr.getState().setLiveClassTimeRemaining(C),f(!0),As&&Je("segment_main"),b(E=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"info",message:`教学环节切换并广播:进入 [${x.title}] 环节,设定时间 ${x.duration}。`},...E]),g(s==="zh"?"📢 环节已广播":"📢 Phase Synchronized",s==="zh"?`已同步广播 [${x.title}] 环节至所有在线学生端。`:`Broadcasted phase [${x.title}] to all active students.`,"success")},zt=async(x,C="full")=>{if(!m||!n){g(s==="zh"?"⚠️ 无法操作":"⚠️ Action Prevented",s==="zh"?"请先选择需要授课的课节及班级。":"Please select a lesson and class first.","warning");return}L(!0);try{const E=x?`/api/classes/${m}/lock_lesson`:`/api/classes/${m}/unlock_lesson`;if((await fetch(E,{method:"POST",headers:{"Content-Type":"application/json"},body:x?JSON.stringify({lessonId:n,mode:C}):void 0})).ok){await q();const ae=C==="navigation";b(ne=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:x?"warning":"info",message:x?ae?"已对全班学生开启答题锁定(放开作答,限制离开当前页面)。":"已对全班学生强制锁定专注模式(限定当前课程,只读跟随)。":"已解锁全班学生专注模式限制。"},...ne]),g(s==="zh"?"🔒 锁状态更新":"🔒 Class Status Updated",x?ae?"全班答题锁定成功,学生可在当前页面作答,无法切出。":"全班专注锁定成功,学生将无法切回主页。":"全班屏幕解锁成功,学生已恢复自由浏览。","success")}}catch(E){console.error("Failed to toggle class focus lock",E)}finally{L(!1)}},Os=async(x,C,E,Y)=>{let ae=n,ne=Y||"full";C&&(Y&&E!==Y?(ae=n,ne=Y):ae=null);try{if((await fetch(`/api/students/${x}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({locked_lesson_id:ae,lock_mode:ae?ne:"full"})})).ok){await q();const je=j.find(Ee=>Ee.id===x)?.name||x,oe=ne==="navigation";b(Ee=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:ae?"warning":"info",message:ae?`已针对学生 [${je}] 开启${oe?"答题锁定":"专注限制锁定"}。`:`已解锁学生 [${je}] 的屏幕锁定。`},...Ee])}}catch(pe){console.error("Failed to toggle student lock",pe)}},pa=async x=>{if(!n||!c){g(s==="zh"?"请先进入教学环节":"Choose a segment",s==="zh"?"放行需要当前课堂环节。":"An active segment is required.","warning");return}try{const C=await fetch(`/api/classroom/sessions/${encodeURIComponent(n)}/segment-overrides`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:x,segmentId:c,reason:"教师放行"})}),E=j.find(Y=>Y.id===x)?.name||x;C.ok?g(s==="zh"?"已放行":"Override saved",s==="zh"?`已允许 ${E} 进入当前环节。`:`${E} may enter the current segment.`,"success"):g(s==="zh"?"放行失败":"Override failed",s==="zh"?"请稍后重试。":"Try again.","warning")}catch(C){console.error("Failed to override segment gate",C)}},fa=async x=>{if(!n){g(s==="zh"?"⚠️ 请选择课节":"⚠️ Select Lesson",s==="zh"?"请先选择要授课的课节。":"Please select a lesson first.","warning");return}if(JSON.stringify(x.payload||"").includes("$classId")&&!m){g(s==="zh"?"⚠️ 请选择班级":"⚠️ Select Class",s==="zh"?"该工具需要指定上课班级,请在顶部先选择班级。":"Please select class first for this tool.","warning");return}b(E=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"info",message:`正在运行插件工具 [${x.name}]...`},...E]);try{const E=JSON.parse(JSON.stringify(x.payload||{}).replace(/\$classId/g,m||"").replace(/\$lessonId/g,n||""));if(E.type==="plugin"&&E.data)try{const pe=JSON.parse(E.data);!pe.segmentId&&c&&(pe.segmentId=c,E.data=JSON.stringify(pe))}catch{}const ae=!/^(whiteboard|lesson|assignment|class|student|vfs|plugin|ai|agent|system)\./.test(x.commandType)&&x.manifestId?_a(x.commandType,x.manifestId):x.commandType,ne=await fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:ae,payload:E})});if(ne.ok)R&&(x.id==="courseware-hub-teacher"||x.commandType==="courseware.open_panel")&&R(),b(pe=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"success",message:`插件工具 [${x.name}] 执行完毕,数据成功下发。`},...pe]),g(s==="zh"?"✓ 工具下发成功":"✓ Tool Synchronized",s==="zh"?`工具 [${x.name}] 已成功在当前白板上部署并投射。`:`Tool [${x.name}] synchronized successfully.`,"success"),await k(n);else{const pe=await ne.json();throw new Error(pe.error||"Server error")}}catch(E){b(Y=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"error",message:`运行插件工具 [${x.name}] 失败: ${E.message}`},...Y]),g(s==="zh"?"❌ 运行失败":"❌ Tool Failed",E.message||"Execution error","warning")}},Or=()=>{if(j.length===0||M)return;const x=j.filter(ne=>A.includes(ne.id)&&U[ne.id]===n);if(x.length===0){g(s==="zh"?"⚠️ 无法抽问":"⚠️ Cannot Draw",s==="zh"?"当前课堂中没有已进入的活跃学生。":"No students have entered the classroom yet.","warning");return}I(!0);let C=0;const E=18;let Y=75;const ae=()=>{const ne=Math.floor(Math.random()*x.length),pe=x[ne];if(se(pe.id),C++,C<E)C>E-5&&(Y+=45),_e.current=setTimeout(ae,Y);else{const je=x[ne];if(se(null),I(!1),_(oe=>oe.includes(je.id)?oe:[...oe,je.id]),b(oe=>[{id:Math.random().toString(),time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"success",message:`🎯 随机提问抽选:学生 [${je.name}] 被抽中回答问题!`},...oe]),g(s==="zh"?"🎯 随机提问抽选":"🎯 Student Drawn",s==="zh"?`恭喜学生 [${je.name}] 被抽中回答问题!`:`Student [${je.name}] was selected to answer!`,"success"),ge.current)ge.current.broadcastPickStudent(je.id,je.name);else{const oe=ps();oe&&oe.emit("teacher-pick-student",{studentId:je.id,studentName:je.name,lessonId:n,classId:m})}Be.current&&clearTimeout(Be.current),Be.current=setTimeout(()=>{_(oe=>oe.filter(Ee=>Ee!==je.id))},8e3)}};_e.current&&clearTimeout(_e.current),_e.current=setTimeout(ae,Y)},ba=m?j.map(x=>x.id):[],ga=(m?kt.filter(x=>ba.includes(x.studentId)):kt).filter(x=>{const C=x.studentName?.toLowerCase().includes(Ps.toLowerCase())||x.coursewareName?.toLowerCase().includes(Ps.toLowerCase()),E=rs==="all"||rs==="submitted"&&Tn.includes(x.status)||rs==="started"&&rl.includes(x.status);return C&&E}),Dr=x=>{a(x),k&&k(x),o?o("lesson_editor"):S("lesson_editor")},ja=i.useCallback(()=>{o?o("timetable"):S("timetable")},[o,S]);return _n?e.jsx(ci,{lessons:d,classes:r,lang:s,addToast:g,onBackToPortal:()=>{Ue.current=!0,Ke.current=!1,dt(null),ot(!0),wt(!1),We(!1),He(!0)},onResumeSession:x=>{ye.current=null,Fe(null),Ue.current=!1,Ke.current=!0,dt(x.lessonId),a(x.lessonId),x.classId&&p(x.classId),be(x.stage||"IN_CLASS_TEACHING"),wt(!1),We(!1),He(!1)},onViewReport:x=>{ye.current=x.id,Fe(x.id),a(x.lessonId),x.classId&&p(x.classId),be("ARCHIVED_REPORT"),wt(!1),He(!1)},onSessionArchived:x=>{x.lessonId===n&&(ye.current=x.id,Fe(x.id),be("ARCHIVED_REPORT"),f(!1))},onSessionDeleted:x=>{x.lessonId===n&&(ye.current=null,Fe(null),be("PRE_CLASS_READY"),f(!1),ts(null),Ue.current=!0,Ke.current=!1,dt(null),ot(!0),We(!1),He(!0))}}):Rn?e.jsx(hi,{lang:s,currentLessonId:n,addToast:g,onResume:x=>{ye.current=null,Fe(null),Ue.current=!1,Ke.current=!0,dt(x.lessonId),a(x.lessonId),x.classId&&p(x.classId),be(x.stage||"IN_CLASS_TEACHING"),We(!1),He(!1)},onStartNew:()=>{Ue.current=!0,Ke.current=!1,dt(null),ot(!0),We(!1),He(!0)},onOpenArchive:()=>{We(!1),wt(!0)},onEmpty:()=>{We(!1),Ke.current||He(!0)}}):pr&&!In?e.jsx("div",{"data-testid":"live-class-entry-pending",className:"flex-1 flex items-center justify-center text-sm text-muted",children:s==="zh"?"正在确认本节课班级…":"Checking this lesson’s class…"}):pr?e.jsx(ai,{lessons:d,classes:r,students:j,selectedLesson:n,setSelectedLesson:a,liveClassSelectedClassId:m,setLiveClassSelectedClassId:p,timelineSegments:h,onlineStudentIds:A,lang:s,addToast:g,onEnterClassroom:ta,onEditLesson:Dr,onGoToTimetable:ja,onOpenSessionManager:()=>wt(!0)}):e.jsxs("div",{className:"flex-grow flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl text-main overflow-hidden font-sans",children:[e.jsxs("div",{className:"bg-surface-secondary px-4 py-2.5 border-b border-theme flex items-center justify-between gap-3 shrink-0 overflow-x-auto no-scrollbar",children:[e.jsxs("div",{className:"flex items-center gap-2.5 select-none shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("span",{className:`w-3 h-3 rounded-full ${w?"bg-emerald-500 animate-ping":"bg-rose-500"} absolute`}),e.jsx("span",{className:`w-2 h-2 rounded-full ${w?"bg-emerald-500":"bg-rose-500"} relative`})]}),e.jsx("h2",{className:"text-sm font-extrabold tracking-tight text-main flex items-center gap-2 shrink-0",children:s==="zh"?"🔴 在线课堂":"🔴 Live Classroom"})]}),e.jsxs("div",{id:"live-classroom-current-class-badge",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-primary-theme/10 border border-primary-theme/25 text-primary-ink text-xs font-bold select-none shrink-0",title:ht(s),role:"status",children:[e.jsx(oo,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[160px]",children:r.find(x=>x.id===m)?.name||(s==="zh"?"未分配班级":"No Class")}),e.jsx("span",{"data-testid":"live-class-lock-hint",className:"text-2xs font-semibold text-muted truncate max-w-[140px]",children:ht(s)})]}),e.jsx("button",{type:"button",id:"live-classroom-back-to-portal",onClick:()=>{Ue.current=!0,Ke.current=!1,dt(null),ot(!0),We(!1),He(!0)},className:"inline-flex items-center text-2xs font-semibold px-2 py-1 rounded-lg border border-theme text-muted hover:text-main hover:bg-surface shrink-0 cursor-pointer",title:s==="zh"?"回到起始门户。进行中的课不能换班":"Back to the start portal. In-progress lessons stay on this class.",children:s==="zh"?"返回门户":"Back to portal"}),e.jsx("button",{type:"button",id:"live-classroom-open-sessions",onClick:()=>wt(!0),className:"inline-flex items-center text-2xs font-semibold px-2 py-1 rounded-lg border border-theme text-muted hover:text-main hover:bg-surface shrink-0 cursor-pointer",title:s==="zh"?"管理课堂历史与进行中会话":"Manage classroom sessions",children:s==="zh"?"会话档案":"Sessions"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("select",{id:"live-classroom-lesson-select","aria-label":s==="zh"?"选择授课课程":"Select lesson to teach",value:Me||"",onChange:x=>{const C=x.target.value===""?null:x.target.value;ks(C)},className:"bg-surface border border-theme rounded-lg text-xs font-semibold px-2.5 py-1.5 focus:ring-1 focus:ring-primary-theme text-main outline-none cursor-pointer hover:bg-surface-secondary transition-colors max-w-[180px] sm:max-w-[240px] truncate",children:[e.jsx("option",{value:"",children:s==="zh"?"-- 选择授课课节 --":"-- Select Lesson --"}),d.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id))]}),e.jsxs("button",{type:"button",id:"live-classroom-switch-lesson-btn",disabled:!Me||Me===n,onClick:()=>zs(!0),className:`inline-flex items-center gap-1 text-xs font-bold px-2.5 py-1.5 rounded-lg transition-all cursor-pointer ${Me&&Me!==n?"bg-primary-solid hover:opacity-90 text-white shadow-2xs ring-1 ring-primary-theme/50 active:scale-95":"bg-surface border border-theme/60 text-muted opacity-45 cursor-not-allowed"}`,title:Me&&Me!==n?s==="zh"?"点击切换上课课程(将弹出确认框)":"Switch lesson (confirmation needed)":s==="zh"?"在下拉框选择不同课程后点击切换":"Select a different lesson to switch",children:[e.jsx(Hr,{size:12}),e.jsx("span",{children:s==="zh"?"切换":"Switch"})]}),n&&e.jsxs("button",{type:"button",onClick:()=>Dr(n),title:s==="zh"?"进入此课程的课程编辑器":"Edit lesson in Lesson Editor",className:"inline-flex items-center gap-1 bg-surface border border-theme hover:border-primary-theme hover:bg-surface-secondary text-main text-xs font-semibold px-2 py-1.5 rounded-lg transition-colors cursor-pointer",children:[e.jsx(or,{size:12}),e.jsx("span",{children:s==="zh"?"编辑":"Edit"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:[e.jsxs("button",{onClick:Mr,className:`w-8 h-8 rounded-lg transition-all cursor-pointer flex items-center justify-center relative shadow-sm active:scale-95 shrink-0 ${ke?"bg-emerald-600 hover:bg-emerald-700 text-white ring-2 ring-emerald-400/50 shadow-emerald-500/20":"bg-gradient-to-r from-pink-600 to-rose-600 hover:from-pink-700 hover:to-rose-700 text-white"}`,title:s==="zh"?ke?"学生端已联动 (独立Tab) - 点击激活":"学生视角预览 (独立Tab) - 在新窗口中联动打开":ke?"Student Linked (Focus Tab)":"Student Preview (New Tab)","aria-label":s==="zh"?ke?"学生端已联动 (独立Tab)":"学生视角预览 (独立Tab)":ke?"Student Linked (Focus Tab)":"Student Preview (New Tab)",children:[e.jsx(Qt,{size:16}),ke&&e.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-300 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-400"})]})]}),lt?e.jsxs("div",{className:"inline-flex rounded-lg shadow-sm shrink-0",children:[e.jsxs("button",{onClick:()=>zt(!1),disabled:O||!n||!m,className:`px-3 py-1.5 rounded-l-lg font-bold text-xs uppercase tracking-wider flex items-center gap-1.5 shadow-sm transition-all active:scale-95 disabled:opacity-50 cursor-pointer shrink-0 text-white ${Ze==="navigation"?"bg-amber-600 hover:bg-amber-700":"bg-rose-600 hover:bg-rose-700"}`,title:s==="zh"?`${Ze==="navigation"?"答题锁定中":"专注锁定中"} · 点击一键解锁全班`:`${Ze==="navigation"?"Answer Lock Active":"Focus Lock Active"} · Click to unlock`,children:[Ze==="navigation"?e.jsx(Bs,{size:12}):e.jsx(Ys,{size:12}),e.jsx("span",{children:Ze==="navigation"?s==="zh"?"答题锁定 · 解锁":"Answer Lock · Unlock":s==="zh"?"专注锁定 · 解锁":"Focus Lock · Unlock"})]}),e.jsxs("button",{onClick:()=>zt(!0,Ze==="navigation"?"full":"navigation"),disabled:O||!n||!m,className:`px-2 py-1.5 rounded-r-lg font-bold text-[11px] flex items-center gap-1 transition-all active:scale-95 disabled:opacity-50 cursor-pointer shrink-0 text-white border-l border-white/20 ${Ze==="navigation"?"bg-amber-700 hover:bg-amber-800":"bg-rose-700 hover:bg-rose-800"}`,title:Ze==="navigation"?s==="zh"?"切换为全班专注锁定(只读跟随,禁止交互)":"Switch to Full Focus Lock":s==="zh"?"切换为全班答题锁定(放开作答,禁止离开)":"Switch to Answer Lock",children:[e.jsx(Hr,{size:11}),e.jsx("span",{children:Ze==="navigation"?s==="zh"?"切专注":"To Focus":s==="zh"?"切答题":"To Answer"})]})]}):e.jsxs("div",{className:"inline-flex rounded-lg shadow-sm shrink-0",children:[e.jsxs("button",{onClick:()=>zt(!0,"full"),disabled:O||!n||!m,className:"px-2.5 py-1.5 rounded-l-lg font-bold text-xs uppercase tracking-wider flex items-center gap-1.5 bg-indigo-600 hover:bg-indigo-700 text-white transition-all active:scale-95 disabled:opacity-50 cursor-pointer shrink-0",title:s==="zh"?"全班专注锁定(只读跟随,限制离开)":"Class Focus Lock (Read-only, navigation restricted)",children:[e.jsx(Wr,{size:12}),e.jsx("span",{children:s==="zh"?"全班专注":"Focus Lock"})]}),e.jsxs("button",{onClick:()=>zt(!0,"navigation"),disabled:O||!n||!m,className:"px-2.5 py-1.5 rounded-r-lg font-bold text-xs uppercase tracking-wider flex items-center gap-1.5 bg-amber-600 hover:bg-amber-700 text-white border-l border-amber-700 transition-all active:scale-95 disabled:opacity-50 cursor-pointer shrink-0",title:s==="zh"?"全班答题锁定(允许正常作答与输入,限制离开)":"Class Answer Lock (Allow interaction/submissions, navigation restricted)",children:[e.jsx(Bs,{size:12}),e.jsx("span",{children:s==="zh"?"答题锁定":"Answer Lock"})]})]}),e.jsx(sl,{lang:s,onOpenDiagnosticCenter:()=>yr(!0),onOpenMasteryPrediction:()=>jr(!0),onOpenGroupCollab:()=>Nr(!0),onOpenShowcaseDiff:()=>vr(!0),onOpenPeerReviewShowcase:()=>br(!0),onOpenParentNotification:()=>gr(!0),onOpenMacroRunner:()=>wr(!0),onOpenHardwareSettings:()=>kr(!0),selectedLesson:n,syncChannel:ge.current,onlineStudentCount:A?.length||$.size||0,onTimeRemainingChange:(x,C)=>{const E=Z.current;Z.current=C,qr.getState().setLiveClassTimeRemaining(x),E!==C&&(f(C),E&&!C&&g(s==="zh"?"⏰ 环节时间到":"⏰ Phase Timer Ended",s==="zh"?"当前教学环节设定的时间已耗尽,建议转入下一环节。":"The current segment duration has elapsed. Transition recommended.","warning")),ge.current?.broadcastSyncTimer(x,C)}})]})]}),e.jsx(Lo,{lessonId:n,lessonTitle:d.find(x=>x.id===n)?.title,classId:m,lang:s,addToast:g,currentStage:ue,onStageChange:x=>be(x),students:ea}),n?ue==="PRE_CLASS_READY"?e.jsx(Do,{selectedLesson:n,lessonTitle:d.find(x=>x.id===n)?.title||"",selectedClassId:m,className:r.find(x=>x.id===m)?.name||"",students:j,onlineStudentIds:A,timelineSegments:h,lang:s,isClassLocked:lt,onToggleClassLock:()=>zt(!lt),onStartClass:()=>it("IN_CLASS_TEACHING"),onPingStudent:()=>Or(),onOpenStudentWindow:Mr,isStudentWindowOpen:ke,addToast:g,onBroadcastNotice:x=>{b(C=>[{id:`feed-notice-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:x},...C])}}):ue==="WRAP_UP_EXIT_TICKET"?e.jsx(yi,{selectedLesson:n,lessonTitle:d.find(x=>x.id===n)?.title||"",selectedClassId:m,className:r.find(x=>x.id===m)?.name||"",students:j,lang:s,attempts:kt,loadingAttempts:$r,onFetchAttempts:()=>Qe(),onPromoteAttempt:Rr,onViewRaw:x=>Lr(x),onAdvanceToReport:()=>it("ARCHIVED_REPORT"),onReturnToTeaching:()=>it("IN_CLASS_TEACHING"),addToast:g,onBroadcastNotice:x=>{b(C=>[{id:`feed-hw-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:x},...C])}}):ue==="ARCHIVED_REPORT"?e.jsx(zi,{selectedLesson:n,lessonTitle:d.find(x=>x.id===n)?.title||"",selectedClassId:m,className:r.find(x=>x.id===m)?.name||"",students:j,lang:s,onReturnToTeaching:()=>it("IN_CLASS_TEACHING"),onReturnToPreClass:()=>it("PRE_CLASS_READY"),addToast:g}):e.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 bg-surface-secondary/30",children:[!X&&e.jsxs("div",{className:"w-[268px] shrink-0 bg-surface border-r border-theme flex flex-col min-h-0 select-none shadow-xs transition-all duration-200",children:[e.jsxs("div",{className:"p-3 border-b border-theme/60 flex items-center justify-between shrink-0 bg-surface-secondary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-primary-theme/10 text-primary-ink flex items-center justify-center shrink-0",children:e.jsx(De,{size:13})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-xs font-black text-main uppercase tracking-wider truncate",children:s==="zh"?"教学步骤与页面大纲":"Lesson Flow & Outline"}),e.jsxs("div",{className:"text-[10px] text-muted flex items-center gap-1.5 font-medium",children:[e.jsxs("span",{children:[h.length," ",s==="zh"?"环节":"steps"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[Ge.length||1," ",s==="zh"?"页面":"pages"]})]})]})]}),e.jsx("button",{onClick:()=>K(!0),className:"p-1 rounded-md text-muted hover:text-main hover:bg-surface border border-theme/40 transition-colors cursor-pointer shrink-0",title:s==="zh"?"收起边栏以扩大白板视野":"Collapse Sidebar",children:e.jsx(io,{size:13})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 flex flex-col gap-3.5 scrollbar-thin",children:[e.jsxs("div",{className:"bg-surface rounded-xl border border-theme p-2.5 flex flex-col gap-2 shadow-2xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{type:"button",onClick:()=>fe(x=>!x),className:"flex items-center gap-1.5 text-xs font-bold text-main hover:text-primary-ink transition-colors cursor-pointer",children:[e.jsx(Kt,{size:13,className:"text-primary-ink"}),e.jsx("span",{children:s==="zh"?"白板页面大纲":"Whiteboard Outline"}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.2 rounded-full bg-primary-theme/10 text-primary-ink font-mono font-bold",children:Ge.length||1}),e.jsx(Ut,{size:12,className:`text-muted transition-transform duration-200 ${ce?"-rotate-90":""}`})]}),e.jsx("button",{type:"button",onClick:()=>tt.current?.addPage?.(),className:"p-1 rounded-md text-muted hover:text-primary-ink hover:bg-primary-theme/10 transition-colors cursor-pointer",title:s==="zh"?"新建白板页面":"Add Whiteboard Page",children:e.jsx(Tt,{size:13})})]}),ce?e.jsxs("div",{onClick:()=>fe(!1),className:"flex items-center justify-between text-2xs px-2.5 py-1.5 bg-surface-secondary/60 rounded-lg text-muted hover:text-main cursor-pointer transition-colors",children:[e.jsxs("span",{className:"truncate max-w-[170px] font-medium",children:[s==="zh"?"当前":"Active",":"," ",Ge[J]?.title||`P${J+1}`]}),e.jsx("span",{className:"text-[10px] text-primary-ink font-bold",children:s==="zh"?"展开":"Expand"})]}):e.jsx("div",{className:"flex flex-col gap-1 max-h-40 overflow-y-auto pr-0.5 no-scrollbar",children:(Ge.length>0?Ge:[{id:"p0",title:"P1 · 默认页"}]).map((x,C)=>{const E=C===J,Y=y.filter(ae=>{try{return(JSON.parse(ae.data).page??0)===C}catch{return!1}}).length;return e.jsxs("div",{onClick:()=>tt.current?.switchPage?.(C),className:`group flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all cursor-pointer ${E?"bg-primary-solid text-white font-semibold shadow-xs ring-1 ring-primary-theme/30":"bg-surface hover:bg-surface-secondary text-main border border-theme/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate min-w-0 flex-1",children:[e.jsxs("span",{className:`text-[10px] px-1 py-0.2 rounded font-mono shrink-0 ${E?"bg-primary-solid/85 text-white":"bg-surface-secondary text-muted"}`,children:["P",C+1]}),e.jsx("span",{className:"truncate tracking-tight",children:x.title||`页面 ${C+1}`})]}),e.jsxs("span",{className:`text-[9px] px-1.5 py-0.2 rounded shrink-0 ${E?"bg-primary-solid/85 text-white":"text-muted"}`,children:[Y," ",s==="zh"?"组件":"items"]})]},x.id||C)})})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(vs,{size:12,className:"text-primary-ink"}),e.jsx("h4",{className:"text-xs font-black uppercase text-main tracking-wider",children:s==="zh"?"教学环节进度表":"Timeline Segments"})]}),e.jsx("span",{className:"text-[10px] text-muted font-medium",children:h.findIndex(x=>x.id===c)>=0?`${s==="zh"?"进行中: ":"Active: "}#${h.findIndex(x=>x.id===c)+1}`:""})]}),n?e.jsx("div",{className:"space-y-2 overflow-y-auto flex-1 pr-0.5 scrollbar-thin",children:h.map((x,C)=>{const E=c===x.id;return e.jsxs("div",{className:`p-2.5 rounded-xl border transition-all flex flex-col gap-1.5 relative overflow-hidden ${E?"bg-primary-theme/10 border-primary-theme shadow-xs ring-1 ring-primary-theme/20":"bg-surface border-theme/70 hover:border-primary-theme/40 hover:bg-surface-secondary/50"}`,children:[E&&e.jsx("div",{className:"absolute top-0 left-0 bottom-0 w-1 bg-primary-theme rounded-r"}),e.jsxs("div",{className:"flex justify-between items-center pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[e.jsx("span",{className:`w-4 h-4 rounded-full text-[10px] font-bold flex items-center justify-center shrink-0 ${E?"bg-primary-solid text-white":"bg-surface-secondary text-muted"}`,children:C+1}),e.jsx("span",{className:`text-xs font-bold truncate ${E?"text-primary-ink":"text-main"}`,children:x.title})]}),e.jsx("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded bg-surface-secondary text-muted border border-theme/60 shrink-0",children:x.duration})]}),e.jsx("div",{className:`text-2xs line-clamp-2 leading-relaxed pl-1 ${E?"text-primary-ink/90":"text-muted"}`,children:x.notes||(s==="zh"?"无步骤描述备注信息。":"No description notes.")}),e.jsx("button",{onClick:()=>ha(x),className:`w-full py-1.5 rounded-lg text-xs font-bold transition-all cursor-pointer flex items-center justify-center gap-1.5 ${E?"bg-primary-solid text-white hover:bg-primary-solid-hover shadow-xs":"bg-surface-secondary text-muted hover:text-main hover:bg-surface border border-theme"}`,children:E?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),e.jsx("span",{children:s==="zh"?"同步演示中":"Broadcasting"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{size:11}),e.jsx("span",{children:s==="zh"?"广播此环节":"Broadcast Step"})]})}),e.jsx(me,{slot:"classroom.agenda.action",slotProps:{segment:x,isActive:E,idx:C,lessonId:n,lang:s}})]},x.id)})}):e.jsx("div",{className:"text-xs text-muted italic py-4 text-center",children:s==="zh"?"请选择一个课节加载流程表":"Select a lesson to view schedule."})]})]})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-surface-secondary/40 p-3 gap-3 relative",children:n?e.jsxs("div",{className:"w-full h-full relative flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center px-1.5 py-1 select-none text-muted text-xs uppercase font-extrabold tracking-wide shrink-0 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[X&&e.jsxs("button",{onClick:()=>K(!1),className:"p-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-primary-ink hover:text-primary-ink-hover transition-colors cursor-pointer mr-1.5 flex items-center gap-1 shadow-sm",title:s==="zh"?"展开环节大纲":"Expand Sidebar",children:[e.jsx(ms,{size:10}),e.jsx("span",{className:"text-xs font-bold tracking-wider",children:s==="zh"?"展开":"Expand"})]}),e.jsxs("div",{className:"bg-surface-secondary p-0.5 rounded-lg flex items-center gap-1 border border-theme",children:[e.jsx("button",{onClick:()=>Je("whiteboard"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer ${Ne==="whiteboard"?"bg-surface text-primary-ink shadow-sm":"text-muted hover:text-main"}`,children:s==="zh"?"💻 演示白板":"💻 Whiteboard"}),e.jsx("button",{onClick:()=>Je("submissions"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer ${Ne==="submissions"?"bg-surface text-primary-ink shadow-sm":"text-muted hover:text-main"}`,children:s==="zh"?"📊 学生提交数据":"📊 Student Submissions"}),e.jsx("button",{id:"teacher_assignment_eval_tab_btn",onClick:()=>Je("assignment"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer ${Ne==="assignment"?"bg-surface text-primary-ink shadow-sm":"text-muted hover:text-main"}`,children:s==="zh"?"🎓 作业成绩评定":"🎓 Assignment Grades"}),e.jsxs("button",{id:"teacher_top_performers_tab_btn","data-testid":"teacher-top-performers-tab-btn",onClick:()=>Je("top_performers"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer flex items-center gap-1 ${Ne==="top_performers"?"bg-surface text-amber-700 dark:text-amber-400 shadow-sm":"text-muted hover:text-main"}`,children:[e.jsx(bt,{size:12,className:"text-amber-700 dark:text-amber-400"}),e.jsx("span",{children:s==="zh"?"🏆 随堂测验榜":"🏆 Top Performers"})]}),As&&st&&e.jsxs("button",{id:"teacher_active_segment_main_tab_btn","data-testid":"teacher-active-segment-main-tab-btn",onClick:()=>Je("segment_main"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer flex items-center gap-1 ${Ne==="segment_main"?"bg-surface text-primary-theme shadow-sm":"text-muted hover:text-main"}`,children:[e.jsx(ve,{size:12,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?`🧩 ${st.title||"环节工作区"}`:`🧩 ${st.title||"Segment Workspace"}`})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[G.length>0&&e.jsxs("button",{type:"button",onClick:()=>{St.getState().setActiveTab("student"),St.getState().setIsErrorCenterOpen(!0)},className:"flex items-center gap-1 px-2 py-0.5 rounded-lg text-xs font-bold bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-400 border border-rose-200 dark:border-rose-800 hover:bg-rose-100 transition-colors cursor-pointer mr-1",title:s==="zh"?"点击查看学生端异常诊断日志":"View Student Client Errors",children:[e.jsx(Ie,{size:12,className:"text-rose-700 dark:text-rose-400 animate-pulse"}),e.jsx("span",{children:s==="zh"?`学生端异常 (${G.length})`:`Student Errors (${G.length})`})]}),e.jsxs("span",{className:"text-primary-ink font-mono tracking-widest animate-pulse flex items-center gap-1",children:[e.jsx(qe,{size:10})," Live Broadcaster Connected"]}),e.jsxs("button",{type:"button",onClick:()=>it("WRAP_UP_EXIT_TICKET"),className:"ml-2 px-3 py-1 bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-700 hover:to-purple-700 text-white rounded-lg text-xs font-bold flex items-center gap-1 shadow-xs cursor-pointer hover:shadow-md transition-all active:scale-95",children:[e.jsx("span",{children:s==="zh"?"完成授课,进入课后":"Finish Teaching → Post-Class"}),e.jsx(ms,{size:12})]})]})]}),Ne==="whiteboard"?e.jsxs(e.Fragment,{children:[As&&st&&e.jsxs("div",{"data-testid":"classroom-active-segment-main-hint",className:"flex items-center justify-between px-3 py-1.5 bg-primary-theme/10 border border-primary-theme/20 rounded-lg text-xs text-primary-theme shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-medium truncate",children:[e.jsx(ve,{size:13,className:"shrink-0"}),e.jsx("span",{children:s==="zh"?`当前环节「${st.title}」已配备专属互动工作区`:`Current segment "${st.title}" has a dedicated interactive workspace`})]}),e.jsx("button",{type:"button",onClick:()=>Je("segment_main"),className:"px-2.5 py-0.5 bg-primary-theme text-white rounded-md font-bold hover:bg-primary-theme-hover cursor-pointer text-xs shrink-0 transition-colors shadow-xs",children:s==="zh"?"切换至环节工作区":"Switch to Workspace"})]}),e.jsx("div",{className:"flex-grow flex-1 min-h-0 w-full relative rounded-xl overflow-hidden border border-theme shadow-md bg-surface flex flex-col",children:e.jsx(Ra,{ref:tt,lessonId:n,classId:m,userRole:"teacher",initialPage:Xt,isEditMode:!1,broadcastFullscreen:!0,fullscreenBroadcastClassId:m,onFullscreenSync:x=>{at(x),ge.current?.broadcastFullscreen(x,n||void 0)},elements:y,activeSegmentId:c,onSegmentSync:x=>u(x),classroomTools:ua,onExecuteTool:fa,hidePageBar:!0,onPagesStateChange:({pages:x,currentPage:C})=>{Nt(x),z(C)},onElementAdd:async(x,C)=>{await fetch(`/api/lessons/${n}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:x,data:C})}),k(n)},onElementUpdate:async(x,C)=>{await fetch(`/api/lessons/${n}/whiteboard/${x}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:C})}),k(n)},onElementDelete:async x=>{await fetch(`/api/lessons/${n}/whiteboard/${x}`,{method:"DELETE"}),k(n)},onRefresh:()=>k(n)})})]}):Ne==="submissions"?e.jsx(nl,{lang:s,selectedLesson:n,liveClassSelectedClassId:m,attempts:kt,displayAttempts:ga,loadingAttempts:$r,searchQuery:Ps,setSearchQuery:na,submissionFilter:rs,setSubmissionFilter:ra,fetchAttempts:Qe,setMiddleTab:Je,autoRecordRule:_s,autoRecordRuleLoaded:Is,savingAutoRecordRule:oa,saveAutoRecordRule:xa,autoRecordReport:ia,runAutoRecord:Ls,autoRecordRunning:ca,handleViewRaw:Lr,handlePromoteAttempt:Rr,handleMarkAbsent:da}):Ne==="top_performers"?e.jsx("div",{className:"flex-grow flex-1 min-h-0 w-full relative rounded-xl overflow-y-auto border border-theme shadow-md bg-surface flex flex-col p-4",children:e.jsx(uo,{lang:s,lessonId:n,classId:m,lessons:d,classes:r,students:j,addToast:g})}):Ne==="segment_main"?e.jsx("div",{"data-testid":"classroom-active-segment-main-container",className:"flex-grow flex-1 min-h-0 w-full relative rounded-xl overflow-hidden border border-theme shadow-md bg-surface flex flex-col p-4",children:st?e.jsx(me,{slot:"classroom.active_segment.main",slotProps:{segment:st,lessonId:n,classId:m,lang:s,onRefresh:()=>k(n)}}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-muted text-sm space-y-2",children:[e.jsx("p",{children:s==="zh"?"当前没有正在进行的教学环节。":"No active lesson segment currently."}),e.jsx("button",{type:"button",onClick:()=>Je("whiteboard"),className:"px-3 py-1 text-xs font-bold bg-primary-theme text-white rounded-lg cursor-pointer hover:bg-primary-theme-hover transition-colors",children:s==="zh"?"返回演示白板":"Back to Whiteboard"})]})}):e.jsx(zn,{lessonId:n||"",lang:s==="zh"?"zh":"en",addToast:g})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-subtle gap-2.5 select-none",children:[e.jsx(Ht,{size:38,className:"text-slate-300 animate-bounce",style:{animationDuration:"2.5s"}}),e.jsx("div",{className:"text-sm font-bold text-muted",children:s==="zh"?"请在顶部栏选择一个授课课节":"Please select a lesson to start teaching"}),e.jsx("p",{className:"text-xs text-subtle",children:"白板及环节控制面板将在课节载入后自动生成"})]})}),e.jsxs("div",{className:"w-[264px] shrink-0 bg-surface p-3 border-l border-theme flex flex-col gap-2.5 overflow-hidden transition-all duration-300",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0 select-none pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-muted truncate",children:s==="zh"?"学生专注力监控":"Student Focus Console"}),m&&e.jsxs("button",{onClick:Or,disabled:j.length===0||M,className:"text-[11px] font-bold bg-primary-theme/10 text-primary-ink hover:bg-primary-theme/20 border border-primary-theme/25 px-2 py-0.5 rounded-full transition-all flex items-center gap-1 active:scale-95 disabled:opacity-50 cursor-pointer shadow-2xs shrink-0",title:s==="zh"?"随机抽取一名学生提问":"Pick a student randomly",children:[e.jsx(an,{size:10,className:M?"animate-spin":""}),e.jsx("span",{children:s==="zh"?"抽问":"Pick"})]})]}),e.jsxs("span",{className:"text-[10px] font-mono font-bold px-2 py-0.5 rounded-full border border-theme bg-surface-secondary text-muted shrink-0 flex items-center gap-1",title:s==="zh"?"已锁定学生屏幕人数 (专注 / 答题)":"Locked count (Focus / Answer)",children:[e.jsxs("span",{children:["🔒 ",j.filter(x=>x.locked_lesson_id===n).length,"/",j.length]}),j.some(x=>x.locked_lesson_id===n&&x.lock_mode==="navigation")&&e.jsx("span",{className:"text-amber-600 text-[9px] font-sans",children:"✏️答题"})]})]}),m?e.jsx("div",{onClick:()=>de(null),className:"overflow-y-auto flex-1 pr-1 grid grid-cols-3 gap-1.5 justify-items-center auto-rows-max scrollbar-thin py-1",children:j.map(x=>{const C=x.locked_lesson_id===n,E=x.lock_mode||"full",Y=$.get(x.id),ae=A.includes(x.id),pe=U[x.id]===n,oe=W.find(Se=>Se.student_id===x.id)?.progress_percent??0,Ee=c?h.findIndex(Se=>Se.id===c):-1,Re=h.length>0?Math.round((Ee+1)/h.length*100):0,ct=Ee>=0&&oe<Re,Te=v.includes(x.id),Xe=B===x.id,Ft=te===x.id,Ds=19.5,Fr=3,Fs=2*Math.PI*Ds,ya=Fs-oe/100*Fs;let rt="stroke-primary-theme";Te?rt="stroke-amber-500 stroke-[3.5px]":Xe?rt="stroke-indigo-500 stroke-[3.5px] animate-pulse":ae?C?rt=E==="navigation"?"stroke-amber-500 animate-pulse":"stroke-rose-500 animate-pulse":ct?rt="stroke-amber-500 animate-pulse":pe?oe===100&&(rt="stroke-emerald-500"):rt="stroke-blue-400":rt="stroke-slate-200 dark:stroke-slate-700";const ns=G.filter(Se=>Se.studentId===x.id);return e.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":Ft,"aria-label":`学生 ${x.name},学习进度 ${oe}%${Ft?",已固定概况":""}`,onMouseEnter:()=>re(x.id),onMouseLeave:()=>re(null),onClick:Se=>{Se.stopPropagation(),de(Bt=>Bt===x.id?null:x.id)},onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),Se.stopPropagation(),de(Bt=>Bt===x.id?null:x.id))},className:`group relative flex flex-col items-center justify-center p-1.5 rounded-xl transition-all cursor-pointer w-full focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-theme ${Te?"z-20 duration-300 bg-amber-500/10 ring-2 ring-amber-400 shadow-md scale-105":Xe?"z-20 ring-1 ring-primary-theme bg-primary-theme/5 scale-102":Ft?"z-10 bg-primary-theme/10 ring-2 ring-primary-theme shadow-xs scale-102":"hover:bg-surface-secondary/70"}`,children:[e.jsxs("div",{className:`relative w-12 h-12 flex items-center justify-center rounded-full transition-all duration-300 ${Te?"shadow-[0_0_15px_#f59e0b] scale-105 z-10 bg-amber-50 ring-2 ring-amber-400":Xe?"shadow-[0_0_10px_#6366f1] scale-105 z-10 bg-indigo-50 ring-1 ring-indigo-400":Ft?"shadow-xs bg-primary-theme/5 ring-1 ring-primary-theme/30":""}`,children:[ns.length>0&&e.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),St.getState().setActiveTab("student"),St.getState().setIsErrorCenterOpen(!0)},className:"absolute -top-1 -right-1 z-30 w-4 h-4 rounded-full bg-rose-600 text-white flex items-center justify-center shadow-md cursor-pointer hover:scale-125 transition-transform",title:`该学生端捕获到 ${ns.length} 处异常: ${ns[0].title||ns[0].message}`,children:e.jsx(Ie,{size:9,className:"animate-pulse"})}),Ft&&!Te&&e.jsx("span",{className:"absolute -top-1 -left-1 z-20 text-[9px] bg-primary-theme text-white rounded-full w-3.5 h-3.5 flex items-center justify-center font-bold shadow-xs",title:"已固定选中",children:e.jsx(Ur,{size:7})}),Te&&e.jsx("div",{className:"absolute inset-0 rounded-full bg-amber-400/30 animate-ping",style:{animationDuration:"2s"}}),e.jsxs("svg",{className:"absolute w-full h-full transform -rotate-90",viewBox:"0 0 46 46",children:[e.jsx("circle",{cx:"23",cy:"23",r:Ds,className:"stroke-slate-100 dark:stroke-slate-800 fill-white dark:fill-slate-900",strokeWidth:Fr}),e.jsx("circle",{cx:"23",cy:"23",r:Ds,className:`fill-transparent transition-all duration-300 ${rt}`,strokeWidth:Fr,strokeDasharray:Fs,strokeDashoffset:ya,strokeLinecap:"round"})]}),e.jsxs("div",{className:`relative z-10 w-8.5 h-8.5 rounded-full flex items-center justify-center overflow-hidden transition-colors ${Te?"bg-amber-100/90":""}`,children:[e.jsx("span",{className:`text-[11px] font-bold tracking-tight truncate max-w-[32px] group-hover:scale-0 group-hover:opacity-0 transition-all duration-200 select-none ${Te?"text-amber-900 font-extrabold":ae?"text-slate-700 dark:text-slate-200":"text-slate-400"}`,children:x.name}),e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center gap-1 opacity-0 scale-50 group-hover:opacity-100 group-hover:scale-100 transition-all duration-200 bg-surface/95 rounded-full shadow-inner",children:[n&&ee&&e.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation();const Bt=s==="zh"?`⚠️ 学习进度预警:您当前的进度 (${oe}%) 落后于老师的讲解进度。请专注课堂,跟上讲解!`:`⚠️ Progress Alert: Your progress (${oe}%) is behind.`;ee(x.id,Bt),g(s==="zh"?"🔔 已发送提醒":"🔔 Alert Sent",`已向学生 ${x.name} 发送进度提醒。`,"success")},className:`p-0.5 rounded-md hover:bg-surface-secondary transition-colors shrink-0 cursor-pointer ${ct?"text-amber-500 hover:text-amber-600 animate-pulse":"text-slate-400 hover:text-primary-ink"}`,title:"提醒",children:e.jsx(ut,{size:9})}),e.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),pa(x.id)},disabled:!n||!c,className:"p-0.5 rounded-md hover:bg-surface-secondary transition-colors shrink-0 cursor-pointer text-slate-400 hover:text-emerald-600",title:s==="zh"?"放行当前环节":"Allow this segment",children:e.jsx(lo,{size:9})}),e.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),Os(x.id,x.locked_lesson_id,x.lock_mode)},disabled:!n,className:`p-0.5 rounded-md hover:bg-surface-secondary transition-colors shrink-0 cursor-pointer ${C?E==="navigation"?"text-amber-500 hover:text-amber-600":"text-rose-500 hover:text-rose-600":"text-slate-400 hover:text-rose-500"}`,title:C?E==="navigation"?"解除答题锁定":"解除专注锁定":"开启专注锁定",children:C?E==="navigation"?e.jsx(Bs,{size:9}):e.jsx(Ys,{size:9}):e.jsx(Wr,{size:9})})]})]}),Te?e.jsx("span",{className:"absolute -top-1.5 -right-1.5 z-20 text-[10px] bg-amber-700 text-white rounded-full w-4 h-4 flex items-center justify-center font-bold shadow-md animate-bounce",children:"🎯"}):ae&&e.jsx("span",{className:`absolute top-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface shrink-0 ${pe?"bg-emerald-500":"bg-blue-400"}`,title:pe?"正在上课":"在线(但未进课堂)"}),Y===!0&&!Te&&e.jsx("span",{className:"absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface bg-amber-500 shrink-0 animate-bounce",title:"已确认/就位"})]}),e.jsx("span",{className:`text-[10px] font-mono mt-1 truncate max-w-[48px] select-none font-bold ${Te?"text-amber-700 dark:text-amber-400 font-extrabold animate-bounce":ae?oe===100?"text-emerald-700 dark:text-emerald-400":ct?"text-amber-700 dark:text-amber-400":"text-muted":"text-slate-400"}`,children:Te?"🎯 抽中":`${oe}%`})]},x.id)})}):e.jsx("div",{className:"text-xs text-subtle italic py-4 text-center flex-1 flex items-center justify-center",children:s==="zh"?"请选择班级以显示学生":"Select class to show student monitors."})]}),e.jsx("div",{className:"bg-surface-secondary border border-theme rounded-xl p-3 flex flex-col gap-1.5 h-[128px] shrink-0 shadow-xs select-none justify-center",children:(()=>{const x=H??te;if(!x)return e.jsxs("div",{className:"flex flex-col gap-1 text-xs text-main h-full justify-center",children:[e.jsxs("div",{className:"font-extrabold text-main border-b border-theme pb-1.5 flex items-center gap-1.5 shrink-0",children:[e.jsx(qe,{size:12,className:"text-primary-ink animate-pulse"}),e.jsx("span",{children:s==="zh"?"班级学情概况":"Class Overview"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 text-xs leading-tight mt-1 shrink-0",children:[e.jsxs("div",{className:"flex flex-col items-center bg-surface py-1 px-0.5 rounded-lg border border-theme",children:[e.jsx("span",{className:"text-muted font-medium text-[10px]",children:"在线/总数"}),e.jsxs("span",{className:"font-bold font-mono text-emerald-700 dark:text-emerald-400 text-xs mt-0.5",children:[j.filter(oe=>A.includes(oe.id)).length,"/",j.length]})]}),e.jsxs("div",{className:"flex flex-col items-center bg-surface py-1 px-0.5 rounded-lg border border-theme",children:[e.jsx("span",{className:"text-muted font-medium text-[10px]",children:"屏幕锁定"}),e.jsxs("span",{className:"font-bold font-mono text-xs mt-0.5",children:[e.jsx("span",{className:"text-rose-600",title:"专注锁定",children:j.filter(oe=>oe.locked_lesson_id===n&&oe.lock_mode!=="navigation").length}),e.jsx("span",{className:"text-muted",children:"/"}),e.jsx("span",{className:"text-amber-600",title:"答题锁定",children:j.filter(oe=>oe.locked_lesson_id===n&&oe.lock_mode==="navigation").length})]})]}),e.jsxs("div",{className:"flex flex-col items-center bg-surface py-1 px-0.5 rounded-lg border border-theme",children:[e.jsx("span",{className:"text-muted font-medium text-[10px]",children:"平均进度"}),e.jsx("span",{className:"font-bold font-mono text-primary-ink text-xs mt-0.5",children:(()=>{const oe=j.filter(Re=>A.includes(Re.id));if(oe.length===0)return"0%";const Ee=oe.reduce((Re,ct)=>{const Te=W.find(Xe=>Xe.student_id===ct.id);return Re+(Te?.progress_percent??0)},0);return`${Math.round(Ee/oe.length)}%`})()})]})]})]});const C=j.find(oe=>oe.id===x);if(!C)return null;const E=te===C.id,Y=H===C.id&&te!==null&&te!==C.id,ae=W.find(oe=>oe.student_id===C.id),ne=ae?.progress_percent??0,pe=(()=>{if(!ae||!ae.completed_segments)return[];try{return typeof ae.completed_segments=="string"?JSON.parse(ae.completed_segments):ae.completed_segments}catch{return[]}})(),je=G.filter(oe=>oe.studentId===C.id);return e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs text-main",children:[e.jsxs("div",{className:"font-extrabold text-main border-b border-theme pb-1 flex justify-between items-center shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${A.includes(C.id)?"bg-emerald-500 animate-pulse":"bg-slate-300"}`}),e.jsxs("span",{className:"truncate max-w-[120px]",children:[C.name," (",C.student_number||"N/A",")"]}),C.locked_lesson_id===n&&e.jsx("span",{className:`text-[9px] px-1 py-0.2 rounded font-bold border shrink-0 ${C.lock_mode==="navigation"?"bg-amber-50 dark:bg-amber-950/40 text-amber-600 border-amber-200 dark:border-amber-800":"bg-rose-50 dark:bg-rose-950/40 text-rose-600 border-rose-200 dark:border-rose-800"}`,children:C.lock_mode==="navigation"?"✏️答题锁":"🔒专注锁"}),E&&!Y&&e.jsxs("span",{className:"text-[10px] font-semibold text-primary-ink bg-primary-theme/10 border border-primary-theme/20 px-1 py-0.2 rounded flex items-center gap-0.5 shrink-0",title:"已固定显示该学生概况,点击空白处或 Esc 取消",children:[e.jsx(Ur,{size:8,className:"rotate-45"}),e.jsx("span",{children:"固定"})]}),Y&&e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 bg-amber-500/10 border border-amber-500/20 px-1 py-0.2 rounded shrink-0",title:"临时悬浮预览中,鼠标移开后恢复已固定学生",children:"预览"}),je.length>0&&e.jsxs("button",{type:"button",onClick:oe=>{oe.stopPropagation(),St.getState().setActiveTab("student"),St.getState().setIsErrorCenterOpen(!0)},className:"flex items-center gap-1 text-[10px] font-bold text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-950/60 border border-rose-200 dark:border-rose-800 px-1 py-0.2 rounded hover:bg-rose-100 transition-colors cursor-pointer shrink-0",title:`学生端存在 ${je.length} 处异常: ${je[0].title||je[0].message}`,children:[e.jsx(Ie,{size:10,className:"text-rose-700 dark:text-rose-400 animate-pulse"}),e.jsxs("span",{children:[je.length," 异常"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n&&(C.locked_lesson_id===n?e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),Os(C.id,C.locked_lesson_id,C.lock_mode,C.lock_mode==="navigation"?"full":"navigation")},className:"text-[9px] px-1 py-0.2 rounded bg-surface hover:bg-surface-secondary border border-theme text-primary-ink font-bold transition-colors cursor-pointer",title:C.lock_mode==="navigation"?"切换为专注锁定":"切换为答题锁定",children:C.lock_mode==="navigation"?"切专注":"切答题"}):e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),Os(C.id,null,null,"navigation")},className:"text-[9px] px-1 py-0.2 rounded bg-amber-50 dark:bg-amber-950/40 hover:bg-amber-100 text-amber-600 border border-amber-200 dark:border-amber-800 font-bold transition-colors cursor-pointer",title:"对该学生开启答题锁定",children:"答题锁"})),e.jsxs("span",{className:"text-xs text-primary-ink font-mono font-black",children:[ne,"%"]}),E&&e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),de(null)},className:"text-muted hover:text-main p-0.5 rounded hover:bg-surface transition-colors cursor-pointer",title:"取消固定","aria-label":"取消固定学生概况",children:e.jsx(we,{size:11})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-xs leading-tight shrink-0",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 bg-surface p-1 rounded-lg border border-theme",children:[e.jsx("span",{className:"text-muted font-bold text-[10px]",children:"随堂测验"}),e.jsx("span",{className:`font-bold font-mono text-xs ${ae!=null&&ae.quiz_score!==null?"text-primary-ink":"text-muted"}`,children:ae!=null&&ae.quiz_score!==null?`${ae.quiz_score} / 100`:"未提交"})]}),e.jsxs("div",{className:"flex flex-col gap-0.5 bg-surface p-1 rounded-lg border border-theme",children:[e.jsx("span",{className:"text-muted font-bold text-[10px]",children:"教学环节进度"}),e.jsxs("span",{className:"font-bold text-main text-xs",children:[Array.isArray(pe)?pe.length:0," / ",h.length]})]})]}),e.jsxs("div",{className:"text-xs text-muted leading-relaxed truncate mt-0.5 shrink-0",children:["环节:"," ",h.length>0?h.map((oe,Ee)=>{const Re=Array.isArray(pe)&&pe.includes(oe.id);return e.jsxs("span",{className:`mr-1 px-1 py-0.2 rounded text-[10px] ${Re?"bg-emerald-50 text-emerald-700 border border-emerald-100 dark:bg-emerald-950/40 dark:text-emerald-400":"bg-surface text-muted border border-theme"}`,title:oe.title,children:[Ee+1,":",Re?"✓":"✗"]},oe.id)}):e.jsx("span",{className:"italic text-muted",children:"暂无步骤"})]})]})})()}),e.jsxs("div",{className:`flex flex-col border-t border-theme pt-2 min-h-0 gap-1.5 shrink-0 transition-all duration-300 ease-in-out ${vt?"h-[36px]":"h-[165px]"}`,children:[e.jsxs("div",{onClick:()=>hr(x=>!x),className:"flex items-center justify-between text-xs font-black uppercase text-muted tracking-wider select-none cursor-pointer hover:text-main transition-colors px-0.5 group",title:vt?s==="zh"?"点击展开课堂互动反馈流":"Click to expand feed":s==="zh"?"点击收起课堂互动反馈流":"Click to collapse feed",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Ut,{size:13,className:`text-muted group-hover:text-primary-ink transition-transform duration-200 shrink-0 ${vt?"-rotate-90":"rotate-0"}`}),e.jsx(ir,{size:12,className:"text-primary-ink shrink-0"}),e.jsx("span",{className:"font-extrabold text-main text-xs truncate",children:s==="zh"?"课堂互动反馈流":"Live Feed"}),e.jsx("span",{className:"text-[10px] font-mono font-bold px-1.5 py-0.2 rounded-full bg-surface-secondary border border-theme text-muted shrink-0",children:N.length})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",onClick:x=>x.stopPropagation(),children:[!vt&&e.jsxs("button",{onClick:()=>b([{id:"clear",time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),type:"info",message:"反馈流已清空。"}]),className:"text-[10px] font-bold hover:text-rose-700 dark:hover:text-rose-400 text-muted transition-colors flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-surface-secondary cursor-pointer",title:s==="zh"?"清空互动反馈记录":"Clear feed",children:[e.jsx(et,{size:10}),e.jsx("span",{children:"Clear"})]}),e.jsx("button",{type:"button",onClick:()=>hr(x=>!x),className:"text-[10px] text-muted hover:text-primary-ink font-medium cursor-pointer",children:vt?s==="zh"?"展开":"Expand":s==="zh"?"收起":"Collapse"})]})]}),!vt&&e.jsx("div",{className:"flex-1 bg-surface-secondary/70 border border-theme rounded-xl p-2 font-mono text-[11px] leading-relaxed overflow-y-auto space-y-1.5 select-text text-left text-main shadow-inner scrollbar-thin",children:N.map(x=>e.jsxs("div",{className:"border-b border-theme pb-1 last:border-b-0",children:[e.jsxs("div",{className:"flex justify-between items-center text-muted font-bold mb-0.5",children:[e.jsx("span",{className:"text-[10px]",children:x.time}),e.jsx("span",{className:`px-1 rounded uppercase tracking-wide text-[9px] ${x.type==="success"?"bg-emerald-50 text-emerald-600 border border-emerald-100 dark:bg-emerald-950/40 dark:text-emerald-400":x.type==="warning"?"bg-amber-50 text-amber-700 border border-amber-100 dark:bg-amber-950/40 dark:text-amber-400":"bg-surface text-muted border border-theme"}`,children:x.type})]}),e.jsx("p",{className:x.type==="success"?"text-emerald-700 dark:text-emerald-300 font-medium":x.type==="warning"?"text-amber-700 dark:text-amber-300 font-medium":"text-main",children:x.message})]},x.id))})]})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-subtle gap-2.5 select-none bg-surface",children:[e.jsx(Ht,{size:38,className:"text-slate-300 animate-bounce",style:{animationDuration:"2.5s"}}),e.jsx("div",{className:"text-sm font-bold text-muted",children:s==="zh"?"请在顶部栏选择一个授课课节":"Please select a lesson to start teaching"}),e.jsx("p",{className:"text-xs text-subtle",children:s==="zh"?"课前准备、课中白板、课后小结与简报将在选择课节后就绪":"Classroom workflows activate once a lesson is selected."})]}),Ye&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/60 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface rounded-2xl shadow-2xl max-w-2xl w-full max-h-[85vh] flex flex-col overflow-hidden border border-theme animate-in fade-in zoom-in duration-200 text-main",children:[e.jsxs("div",{className:"bg-surface-secondary px-6 py-4 border-b border-theme flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"text-primary-ink",size:18}),e.jsx("h3",{className:"text-sm font-bold text-main",children:s==="zh"?`[${Ye.studentName}] 的互动提交轨迹详情`:`Submission Details - ${Ye.studentName}`})]}),e.jsx("button",{onClick:()=>Es(null),className:"text-muted hover:text-main p-1.5 hover:bg-surface-secondary rounded-lg transition-colors cursor-pointer",children:e.jsx(co,{size:18})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto space-y-4 flex-1 scrollbar-thin",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-surface-secondary p-3 rounded-xl border border-theme",children:[e.jsx("div",{className:"text-xs text-muted font-bold uppercase tracking-wider",children:s==="zh"?"课件名称":"Courseware"}),e.jsx("div",{className:"text-xs font-semibold text-main mt-1 truncate",title:Ye.coursewareName,children:Ye.coursewareName})]}),e.jsxs("div",{className:"bg-surface-secondary p-3 rounded-xl border border-theme",children:[e.jsx("div",{className:"text-xs text-muted font-bold uppercase tracking-wider",children:s==="zh"?"提交成绩":"Score"}),e.jsx("div",{className:"text-xs font-bold text-primary-ink mt-1",children:Ye.score!==null?`${Ye.score} 分`:s==="zh"?"未打分":"N/A"})]}),e.jsxs("div",{className:"bg-surface-secondary p-3 rounded-xl border border-theme",children:[e.jsx("div",{className:"text-xs text-muted font-bold uppercase tracking-wider",children:s==="zh"?"课件完成度":"Completion"}),e.jsx("div",{className:"text-xs font-bold text-emerald-600 mt-1",children:Ye.completion!==null?`${Math.round(Ye.completion*100)}%`:"0%"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"text-xs font-bold text-main border-b border-theme pb-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx(qe,{size:13,className:"text-primary-ink"}),e.jsx("span",{children:s==="zh"?"实时捕获轨迹事件流 (LMS Bridge)":"LMS Event Captures"})]}),sa?e.jsxs("div",{className:"py-12 flex flex-col items-center justify-center text-muted gap-2",children:[e.jsx(Pe,{size:20,className:"animate-spin text-primary-ink"}),e.jsx("span",{className:"text-xs",children:s==="zh"?"正在查询原始数据...":"Loading raw data..."})]}):Array.isArray(Ts)&&Ts.length>0?e.jsx("div",{className:"space-y-3 font-mono text-xs max-h-[40vh] overflow-y-auto pr-1 scrollbar-thin",children:Ts.map((x,C)=>{let E={};try{E=typeof x.payload_json=="string"?JSON.parse(x.payload_json):x.payload_json}catch{}return e.jsxs("div",{className:"p-3 bg-slate-900 text-slate-200 rounded-xl border border-slate-800 flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs text-slate-400 border-b border-slate-800 pb-1",children:[e.jsx("span",{className:"font-bold text-indigo-400 bg-indigo-950/50 border border-indigo-900/50 px-1.5 py-0.5 rounded",children:x.event_type}),e.jsx("span",{children:new Date(x.created_at).toLocaleTimeString()})]}),e.jsx("pre",{className:"overflow-x-auto text-xs leading-relaxed p-1 text-emerald-400/90 whitespace-pre-wrap word-break-all",children:JSON.stringify(E,null,2)})]},x.id||C)})}):e.jsx("div",{className:"py-8 text-center text-xs text-muted italic",children:s==="zh"?"该学生未产生任何轨迹事件数据。":"No trace events captured."})]})]}),e.jsxs("div",{className:"bg-surface-secondary px-6 py-4 border-t border-theme flex justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"text-xs text-muted flex items-center gap-1",children:[e.jsx(ft,{size:10}),e.jsx("span",{children:"Powered by LMS Bridge API v1"})]}),e.jsx("button",{onClick:()=>Es(null),className:"px-4 py-1.5 bg-surface hover:bg-surface-secondary border border-theme text-main font-bold rounded-lg text-xs transition-all cursor-pointer shadow-sm active:scale-95",children:s==="zh"?"关闭窗口":"Close"})]})]})}),e.jsx(tl,{lang:s,addToast:g,selectedLesson:n,lessonTitle:d.find(x=>x.id===n)?.title??"",className:r.find(x=>x.id===m)?.name??"",liveClassSelectedClassId:m,classroomStage:ue,sessionStartedAt:zr,students:j,liveData:Cs,isGrowthProfileOpen:Ln,onCloseGrowthProfile:()=>{Mn(!1),Dn(null)},growthProfileStudentId:On,isPeerReviewShowcaseOpen:fr,onClosePeerReviewShowcase:()=>br(!1),onAdvanceToStage3:()=>it("WRAP_UP_EXIT_TICKET"),peerReviewData:Jn,showcaseWorks:Yn,onSelectSpotlightWork:Qn,onAutoAssignPeerReview:Xn,autoAssigning:Zn,isParentNotificationOpen:Fn,onCloseParentNotification:()=>gr(!1),isMasteryPredictionOpen:Bn,onCloseMasteryPrediction:()=>jr(!1),isDiagnosticCenterOpen:Gn,onCloseDiagnosticCenter:()=>yr(!1),isGroupCollabOpen:Hn,onCloseGroupCollab:()=>Nr(!1),isShowcaseDiffOpen:Wn,onCloseShowcaseDiff:()=>vr(!1),isMacroRunnerOpen:Un,onCloseMacroRunner:()=>wr(!1),isHardwareSettingsOpen:qn,onCloseHardwareSettings:()=>kr(!1)}),Pn&&e.jsx("div",{id:"live-classroom-switch-lesson-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-in fade-in duration-150 select-none",children:e.jsxs("div",{className:"bg-surface border border-theme rounded-2xl shadow-2xl max-w-md w-full p-5 flex flex-col gap-4 text-main",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/15 text-amber-700 dark:text-amber-400 border border-amber-500/25 flex items-center justify-center shrink-0",children:e.jsx(fs,{size:22})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-extrabold text-main",children:s==="zh"?"确认切换上课课程?":"Confirm Lesson Switch?"}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:s==="zh"?"当前课堂将立即切换至新课程":"Current live session will switch to new lesson"})]})]}),e.jsxs("div",{className:"p-3 bg-surface-secondary/70 border border-theme/60 rounded-xl flex flex-col gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between text-muted",children:[e.jsxs("span",{children:[s==="zh"?"当前课程":"Current Lesson",":"]}),e.jsx("span",{className:"font-semibold text-main truncate max-w-[240px]",children:d.find(x=>x.id===n)?.title||(s==="zh"?"未选择":"None")})]}),e.jsx("div",{className:"flex items-center justify-center text-muted",children:e.jsx(xo,{size:14,className:"text-primary-ink animate-bounce"})}),e.jsxs("div",{className:"flex items-center justify-between text-primary-ink font-bold",children:[e.jsxs("span",{children:[s==="zh"?"目标新课程":"New Lesson",":"]}),e.jsx("span",{className:"truncate max-w-[240px]",children:d.find(x=>x.id===Me)?.title})]})]}),e.jsx("p",{className:"text-xs text-muted leading-relaxed",children:s==="zh"?"切换后,课堂白板、教学环节步骤与已连接的学生端屏幕将同步切换至新课程。是否确认切换?":"Switching lessons will update the whiteboard, lesson segments, and sync the screen for all connected students. Continue?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 pt-2 border-t border-theme/60",children:[e.jsx("button",{type:"button",id:"live-classroom-switch-lesson-cancel-btn",onClick:()=>{ks(n),zs(!1)},className:"px-3.5 py-1.5 rounded-xl border border-theme hover:bg-surface-secondary text-xs font-semibold text-main transition-colors cursor-pointer",children:s==="zh"?"取消":"Cancel"}),e.jsx("button",{type:"button",id:"live-classroom-switch-lesson-confirm-btn",onClick:()=>{Me&&(a(Me),k(Me),g?.(s==="zh"?"课程已切换":"Lesson Switched",s==="zh"?`已切换到课程《${d.find(x=>x.id===Me)?.title}》`:"Switched successfully","success")),zs(!1)},className:"px-4 py-1.5 rounded-xl bg-primary-solid hover:opacity-90 text-white text-xs font-bold transition-all shadow-sm cursor-pointer",children:s==="zh"?"确认切换":"Confirm Switch"})]})]})})]})}export{Tn as FINISHED_STATUSES,rl as IN_PROGRESS_STATUSES,jl as LiveClassroomView};
|