diff --git a/assets/AIChatPage-Ks78ql27.js b/assets/AIChatPage-CI1qQgCG.js similarity index 92% rename from assets/AIChatPage-Ks78ql27.js rename to assets/AIChatPage-CI1qQgCG.js index 13f389bf059eebb7251f9c06da273391919d2e3a..327630cda83ada3637486933722a9d4ac7db04d0 100644 --- a/assets/AIChatPage-Ks78ql27.js +++ b/assets/AIChatPage-CI1qQgCG.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Cb8VeSuW.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-Aaqs1LGb.css"])))=>i.map(i=>d[i]); -import{ay as D,u as F,_ as $,j as S,m as C,D as z}from"./index-Cb8VeSuW.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-De2q2xHf.js";import{I}from"./input-w3MoyecB.js";import H from"./ChatMarkdown-B5QlckxZ.js";import{P as Y}from"./plus-uFWGSQCY.js";import{S as G}from"./search-CMbwAzt9.js";import{T as Q}from"./trash-2-DB-oXtbr.js";import{S as V}from"./send-CMJOaNp6.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";function W(r){return r?r instanceof Date?r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof r=="object"&&"toDate"in r?r.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(r):""}const xe=()=>{const{sessions:r,activeSessionId:o,isLoading:l,loadingSessionId:A,setActiveSessionId:d,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=D(),{userProfile:c}=F(),[x,P]=a.useState(""),[n,g]=a.useState(""),[y,j]=a.useState(!1),m=a.useRef(null),h=a.useRef(!0),u=a.useRef(!1),i=_(),f=i?.messages||[],M=f.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&o===A&&!M,w=(t="auto")=>{const s=m.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},E=()=>{const t=m.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},R=()=>{h.current=E()};a.useEffect(()=>{$(async()=>{const{warmupBackend:t}=await import("./index-Cb8VeSuW.js").then(s=>s.aV);return{warmupBackend:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("AI chat warmup skipped:",t)})},[]),a.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[f,v]),a.useEffect(()=>{h.current=!0,w("auto")},[o]);const N=async()=>{if(!(!n.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=o;t||(t=b(),d(t));const s=n.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();d(t)},B=(t,s)=>{s.stopPropagation(),T(t)},p=r.filter(t=>t.title.toLowerCase().includes(x.toLowerCase())||t.preview.toLowerCase().includes(x.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex gap-4 px-4 sm:px-6 xl:px-10 py-6",children:[e.jsxs("div",{className:"w-80 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-2xl flex items-center justify-center",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-10 h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628]",children:"L.O.L.I."}),e.jsx("p",{className:"text-[10px] text-[#5a6578]",children:"Your AI Math Tutor"})]})]}),e.jsxs("button",{onClick:k,className:"w-full bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-4 py-3 rounded-xl text-sm font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(Y,{size:18}),"New Chat"]}),e.jsxs("div",{className:"relative mt-3",children:[e.jsx(G,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:14}),e.jsx(I,{type:"text",placeholder:"Search conversations...",value:x,onChange:t=>P(t.target.value),className:"w-full pl-9 pr-3 py-2 text-xs rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between mb-2 px-2",children:e.jsxs("span",{className:"text-xs font-bold text-[#5a6578]",children:[p.length," Conversations"]})}),e.jsx(S,{children:p.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>d(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${o===t.id?"bg-sky-50 border-sky-200 shadow-sm":"bg-[#edf1f7] border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("h3",{className:`text-xs font-bold mb-0.5 pr-6 line-clamp-1 ${o===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>B(t.id,s),className:"absolute top-2 right-2 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-100 text-slate-500 hover:text-red-600 transition-all",children:e.jsx(Q,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-2 line-clamp-2",children:t.preview}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-slate-500",children:t.date}),e.jsxs("span",{className:`px-2 py-0.5 rounded-full ${o===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),p.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-16 h-16 object-contain mx-auto mb-2 opacity-60 drop-shadow-sm grayscale contrast-50"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No conversations found"}),e.jsx("p",{className:"text-xs text-slate-500/60 mt-1",children:"Start a new chat!"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628]",children:i?.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:i?.date})]}),e.jsx("div",{className:"flex items-center gap-2",children:i?.topics.map((t,s)=>e.jsx("span",{className:"px-3 py-1 bg-sky-50 text-sky-600 text-xs font-bold rounded-lg",children:t},s))})]}),e.jsxs("div",{ref:m,onScroll:R,className:"flex-1 overflow-y-auto overscroll-contain p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex items-end gap-2 ${t.sender==="user"?"justify-end":"justify-start"}`,children:[t.sender!=="user"&&e.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-r from-sky-600 to-sky-500 flex items-center justify-center flex-shrink-0 mb-1",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI",className:"w-5 h-5 object-contain"})}),e.jsxs("div",{className:`max-w-[70%] rounded-2xl px-5 py-3 ${t.sender==="user"?"bg-gradient-to-r from-sky-600 to-sky-500 text-white":"bg-white text-[#0a1628] shadow-md border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:t.text}):e.jsx(H,{children:t.text}),e.jsx("p",{className:`text-[10px] mt-1.5 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:W(t.timestamp)})]}),t.sender==="user"&&e.jsx(z,{src:c?.photo,name:c?.name,gender:c?.gender,className:"w-7 h-7 flex-shrink-0 mb-1",fallbackClassName:"text-[10px]"})]},t.id))}),v&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white text-[#0a1628] shadow-md border border-[#dde3eb] rounded-2xl px-5 py-3 max-w-[70%]",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})})]}),e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(I,{type:"text",value:n,onChange:t=>g(t.target.value),onKeyPress:t=>t.key==="Enter"&&N(),placeholder:"Ask me anything about math...",className:"flex-1 px-5 py-3 rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100 text-sm"}),e.jsx(O,{onClick:N,disabled:!n.trim()||l||y,className:"px-6 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",children:e.jsx(V,{size:18})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-24 h-24 bg-gradient-to-r from-sky-100 to-cyan-100 rounded-3xl flex items-center justify-center mb-6",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-20 h-20 object-contain drop-shadow-lg"})}),e.jsx("h2",{className:"text-2xl font-bold font-display text-[#0a1628] mb-1",children:"Welcome to L.O.L.I."}),e.jsx("p",{className:"text-sky-600 text-sm font-bold tracking-wide uppercase mb-4",children:"Logical Operations & Learning Intelligence"}),e.jsx("p",{className:"text-[#5a6578] mb-6 max-w-md",children:"Your personal AI math tutor is here to help! Start a new conversation or select one from the sidebar."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl font-bold shadow-lg hover:shadow-xl transition-all",children:"Start Your First Chat"}),e.jsx("div",{className:"mt-8 grid grid-cols-3 gap-4 max-w-2xl",children:["Algebra","Geometry","Calculus"].map(t=>e.jsxs("div",{className:"p-4 bg-[#edf1f7] rounded-xl border border-[#dde3eb]",children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628]",children:t}),e.jsxs("p",{className:"text-xs text-[#5a6578] mt-1",children:["Get help with ",t.toLowerCase()]})]},t))})]})})]})};export{xe as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BaOs5Ayg.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-DdX2rVyy.css"])))=>i.map(i=>d[i]); +import{ay as D,u as F,_ as $,j as S,m as C,D as z}from"./index-BaOs5Ayg.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-DCfeFHoH.js";import{I}from"./input-D28h_UTJ.js";import H from"./ChatMarkdown-fgwaycBR.js";import{P as Y}from"./plus-DkG35AoH.js";import{S as G}from"./search-Bq99THgc.js";import{T as Q}from"./trash-2-HTnKafZd.js";import{S as W}from"./send-CwwDU3uJ.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";function q(r){return r?r instanceof Date?r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof r=="object"&&"toDate"in r?r.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(r):""}const xe=()=>{const{sessions:r,activeSessionId:o,isLoading:l,loadingSessionId:A,setActiveSessionId:d,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=D(),{userProfile:c}=F(),[x,P]=a.useState(""),[n,g]=a.useState(""),[y,j]=a.useState(!1),m=a.useRef(null),h=a.useRef(!0),u=a.useRef(!1),i=_(),f=i?.messages||[],M=f.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&o===A&&!M,w=(t="auto")=>{const s=m.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},E=()=>{const t=m.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},R=()=>{h.current=E()};a.useEffect(()=>{$(async()=>{const{warmupBackend:t}=await import("./index-BaOs5Ayg.js").then(s=>s.b2);return{warmupBackend:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("AI chat warmup skipped:",t)})},[]),a.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[f,v]),a.useEffect(()=>{h.current=!0,w("auto")},[o]);const N=async()=>{if(!(!n.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=o;t||(t=b(),d(t));const s=n.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();d(t)},B=(t,s)=>{s.stopPropagation(),T(t)},p=r.filter(t=>t.title.toLowerCase().includes(x.toLowerCase())||t.preview.toLowerCase().includes(x.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex gap-4 px-4 sm:px-6 xl:px-10 py-6",children:[e.jsxs("div",{className:"w-80 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-2xl flex items-center justify-center",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-10 h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628]",children:"L.O.L.I."}),e.jsx("p",{className:"text-[10px] text-[#5a6578]",children:"Your AI Math Tutor"})]})]}),e.jsxs("button",{onClick:k,className:"w-full bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-4 py-3 rounded-xl text-sm font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(Y,{size:18}),"New Chat"]}),e.jsxs("div",{className:"relative mt-3",children:[e.jsx(G,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:14}),e.jsx(I,{type:"text",placeholder:"Search conversations...",value:x,onChange:t=>P(t.target.value),className:"w-full pl-9 pr-3 py-2 text-xs rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between mb-2 px-2",children:e.jsxs("span",{className:"text-xs font-bold text-[#5a6578]",children:[p.length," Conversations"]})}),e.jsx(S,{children:p.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>d(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${o===t.id?"bg-sky-50 border-sky-200 shadow-sm":"bg-[#edf1f7] border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("h3",{className:`text-xs font-bold mb-0.5 pr-6 line-clamp-1 ${o===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>B(t.id,s),className:"absolute top-2 right-2 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-100 text-slate-500 hover:text-red-600 transition-all",children:e.jsx(Q,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-2 line-clamp-2",children:t.preview}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-slate-500",children:t.date}),e.jsxs("span",{className:`px-2 py-0.5 rounded-full ${o===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),p.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-16 h-16 object-contain mx-auto mb-2 opacity-60 drop-shadow-sm grayscale contrast-50"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No conversations found"}),e.jsx("p",{className:"text-xs text-slate-500/60 mt-1",children:"Start a new chat!"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628]",children:i?.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:i?.date})]}),e.jsx("div",{className:"flex items-center gap-2",children:i?.topics.map((t,s)=>e.jsx("span",{className:"px-3 py-1 bg-sky-50 text-sky-600 text-xs font-bold rounded-lg",children:t},s))})]}),e.jsxs("div",{ref:m,onScroll:R,className:"flex-1 overflow-y-auto overscroll-contain p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex items-end gap-2 ${t.sender==="user"?"justify-end":"justify-start"}`,children:[t.sender!=="user"&&e.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-r from-sky-600 to-sky-500 flex items-center justify-center flex-shrink-0 mb-1",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI",className:"w-5 h-5 object-contain"})}),e.jsxs("div",{className:`max-w-[70%] rounded-2xl px-5 py-3 ${t.sender==="user"?"bg-gradient-to-r from-sky-600 to-sky-500 text-white":"bg-white text-[#0a1628] shadow-md border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:t.text}):e.jsx(H,{children:t.text}),e.jsx("p",{className:`text-[10px] mt-1.5 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:q(t.timestamp)})]}),t.sender==="user"&&e.jsx(z,{src:c?.photo,name:c?.name,gender:c?.gender,className:"w-7 h-7 flex-shrink-0 mb-1",fallbackClassName:"text-[10px]"})]},t.id))}),v&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white text-[#0a1628] shadow-md border border-[#dde3eb] rounded-2xl px-5 py-3 max-w-[70%]",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})})]}),e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(I,{type:"text",value:n,onChange:t=>g(t.target.value),onKeyPress:t=>t.key==="Enter"&&N(),placeholder:"Ask me anything about math...",className:"flex-1 px-5 py-3 rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100 text-sm"}),e.jsx(O,{onClick:N,disabled:!n.trim()||l||y,className:"px-6 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",children:e.jsx(W,{size:18})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-24 h-24 bg-gradient-to-r from-sky-100 to-cyan-100 rounded-3xl flex items-center justify-center mb-6",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-20 h-20 object-contain drop-shadow-lg"})}),e.jsx("h2",{className:"text-2xl font-bold font-display text-[#0a1628] mb-1",children:"Welcome to L.O.L.I."}),e.jsx("p",{className:"text-sky-600 text-sm font-bold tracking-wide uppercase mb-4",children:"Logical Operations & Learning Intelligence"}),e.jsx("p",{className:"text-[#5a6578] mb-6 max-w-md",children:"Your personal AI math tutor is here to help! Start a new conversation or select one from the sidebar."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl font-bold shadow-lg hover:shadow-xl transition-all",children:"Start Your First Chat"}),e.jsx("div",{className:"mt-8 grid grid-cols-3 gap-4 max-w-2xl",children:["Algebra","Geometry","Calculus"].map(t=>e.jsxs("div",{className:"p-4 bg-[#edf1f7] rounded-xl border border-[#dde3eb]",children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628]",children:t}),e.jsxs("p",{className:"text-xs text-[#5a6578] mt-1",children:["Get help with ",t.toLowerCase()]})]},t))})]})})]})};export{xe as default}; diff --git a/assets/AdminDashboard-BCV7cX28.js b/assets/AdminDashboard-B2eiYi-q.js similarity index 98% rename from assets/AdminDashboard-BCV7cX28.js rename to assets/AdminDashboard-B2eiYi-q.js index 7c1a8dd6f2408101c96fcc1e04ef0c3010f87aa9..51b05c24f774ba8552f8660627e728a6e261a9e0 100644 --- a/assets/AdminDashboard-BCV7cX28.js +++ b/assets/AdminDashboard-B2eiYi-q.js @@ -1,4 +1,4 @@ -import{r as i,d as Jt,j as e}from"./vendor-react-B4AQeu28.js";import Fs from"./Sidebar-C2ctPQQf.js";import vs from"./ConfirmModal-B7469iTj.js";import{e as ce,h as ye,t as z,l as _,R as Ie,p as me,f as X,F as Zt,H as Yt,I as ea,k as ct,u as Re,m as U,z as Ns,L as ot,S as Ke,Z as mt,i as sa,J as Bs,K as qs,N as Os,U as Je,G as ks,y as xt,A as Ze,O as ut,B as ta,a as je,T as ht,o as aa,M as ra,D as ia}from"./index-Cb8VeSuW.js";import{B as M}from"./button-De2q2xHf.js";import{S as re,a as ie,b as le,c as ne,d as P}from"./select-CqJdJ0KN.js";import{I as R}from"./input-w3MoyecB.js";import{S as Xe}from"./subjects-Bnu0lJdU.js";import{U as fs}from"./upload-D5cppfxb.js";import{F as Ye,I as we,D as qe,T as la,a as na,b as Gs,c as De,d as da,e as Te,f as ca}from"./table-CQN68i0p.js";import{C as Hs,L as oa}from"./lightbulb-BjBRtEjU.js";import{C as es}from"./chart-column-CmH46HAG.js";import{C as ss}from"./circle-check-big-CNGbqkWz.js";import{D as gt,a as pt,b as ft,c as bt,d as jt,e as ma}from"./dialog-CCp2tnRr.js";import{getDocs as de,collection as se,query as ts,orderBy as vt,limit as ys,where as ws,addDoc as xa,serverTimestamp as Nt,doc as Cs,getDoc as yt,setDoc as ua,onSnapshot as ha}from"./vendor-firebase-firestore-CH1lNiRF.js";import{C as Se}from"./circle-alert-DgDGv7k5.js";import{S as wt}from"./search-CMbwAzt9.js";import{E as as,a as _s}from"./eye-DBkZRvYD.js";import{S as be}from"./switch-KjWJg4zs.js";import{S as St,M as ga}from"./LogoutActionButton-Cb7v3MhK.js";import{B as pa}from"./bell-DsHB20Hc.js";import{C as fa,b as ba}from"./vendor-radix-BorKzPz9.js";import{C as ja}from"./check-DSwzaW4Y.js";import{P as va}from"./plus-uFWGSQCY.js";import{C as Na}from"./check-check-CS5aviKH.js";import{M as ya}from"./mail-D1Sfp9RA.js";import{D as kt}from"./download-C-V0pYsk.js";import{T as Qs}from"./trash-2-DB-oXtbr.js";import{C as Ct}from"./clock-BodmJJnp.js";import{F as wa}from"./funnel-D-s_ygM_.js";import{S as Z}from"./skeleton-Bue6-H9w.js";import{u as Sa,t as ka,a as Ca}from"./useSubjectAvailability-d2Fw9DS6.js";import{S as Aa}from"./save-CpWDoSfX.js";import{u as za}from"./useQuery-PwtHq3dz.js";import{a as Pa}from"./chevron-up-Byo9SJJ4.js";import{M as Da}from"./minus-CMQilTBg.js";import"./tooltip-BY91VKdD.js";import"./x-CTLBAl-n.js";import"./chevron-right-CoVWpXdD.js";import"./chevron-left-CZaM7nZW.js";import"./shirt-CrJtkYx3.js";import"./log-out-CM6AS10M.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as i,d as Jt,j as e}from"./vendor-react-B4AQeu28.js";import Fs from"./Sidebar-2LZAqf7E.js";import vs from"./ConfirmModal-6cgkqXAT.js";import{e as ce,h as ye,t as z,l as _,R as Ie,p as me,f as X,F as Zt,H as Yt,I as ea,k as ct,u as Re,m as U,z as Ns,L as ot,S as Ke,Z as mt,i as sa,J as Bs,K as qs,N as Os,U as Je,G as ks,y as xt,A as Ze,O as ut,B as ta,a as je,T as ht,o as aa,M as ra,D as ia}from"./index-BaOs5Ayg.js";import{B as M}from"./button-DCfeFHoH.js";import{S as re,a as ie,b as le,c as ne,d as P}from"./select-DIjxRWza.js";import{I as R}from"./input-D28h_UTJ.js";import{S as Xe}from"./subjects-BFghB0SQ.js";import{U as fs}from"./upload-DayXhGwD.js";import{F as Ye,I as we,D as qe,T as la,a as na,b as Gs,c as De,d as da,e as Te,f as ca}from"./table-xeOJ8ZAA.js";import{C as Hs,L as oa}from"./lightbulb-Ce2KQzGM.js";import{C as es}from"./chart-column-B3jJOD5i.js";import{C as ss}from"./circle-check-big-m1SvzGFL.js";import{D as gt,a as pt,b as ft,c as bt,d as jt,e as ma}from"./dialog-CHtYkwVl.js";import{getDocs as de,collection as se,query as ts,orderBy as vt,limit as ys,where as ws,addDoc as xa,serverTimestamp as Nt,doc as Cs,getDoc as yt,setDoc as ua,onSnapshot as ha}from"./vendor-firebase-firestore-CH1lNiRF.js";import{C as Se}from"./circle-alert-CP9K3300.js";import{S as wt}from"./search-Bq99THgc.js";import{E as as,a as _s}from"./eye-Ig3S6mOs.js";import{S as be}from"./switch-CblAJO7o.js";import{S as St,M as ga}from"./LogoutActionButton-lUNItet6.js";import{B as pa}from"./bell-clcSMJn6.js";import{C as fa,b as ba}from"./vendor-radix-BorKzPz9.js";import{C as ja}from"./check-BLSo9L0H.js";import{P as va}from"./plus-DkG35AoH.js";import{C as Na}from"./check-check-B_HghS1Z.js";import{M as ya}from"./mail-BbG1phxL.js";import{D as kt}from"./download-DX_YebqQ.js";import{T as Qs}from"./trash-2-HTnKafZd.js";import{C as Ct}from"./clock-D1Ecvltm.js";import{F as wa}from"./funnel-BT77sgnz.js";import{S as Z}from"./skeleton-Bo6ISWhm.js";import{u as Sa,t as ka,a as Ca}from"./useSubjectAvailability-Bvu3fXaT.js";import{S as Aa}from"./save-CQIJrhLf.js";import{u as za}from"./useQuery-BnRttv09.js";import{a as Pa}from"./chevron-up-Cdvz2TMJ.js";import{M as Da}from"./minus-DfrEv-SC.js";import"./tooltip-ChRIOid3.js";import"./x-TNvtuOD9.js";import"./chevron-right-COqGruhh.js";import"./chevron-left-BWpgclqc.js";import"./shirt-S3NBuaPm.js";import"./log-out-BenDMDly.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/AssessmentPage-CluT59xB.js b/assets/AssessmentPage-YsCyxvJJ.js similarity index 96% rename from assets/AssessmentPage-CluT59xB.js rename to assets/AssessmentPage-YsCyxvJJ.js index e4ce7412e3b434af57a2cc2335135cd589d81301..f219eba9b89c223c637b70cb60467e44ec71f6d8 100644 --- a/assets/AssessmentPage-CluT59xB.js +++ b/assets/AssessmentPage-YsCyxvJJ.js @@ -1,4 +1,4 @@ -import{r as n,j as e}from"./vendor-react-B4AQeu28.js";import{B as P}from"./button-De2q2xHf.js";import{s as Q}from"./diagnosticService-BIetid_s.js";import{e as Y,m as a,Z as J,j as O,T as U,x as Z,y as G}from"./index-Cb8VeSuW.js";import{M as H}from"./maximize-2-DkEKBrNU.js";import{X as W}from"./x-CTLBAl-n.js";import{C as X}from"./clock-BodmJJnp.js";import{C as K}from"./circle-check-big-CNGbqkWz.js";import{C as V}from"./chevron-right-CoVWpXdD.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as n,j as e}from"./vendor-react-B4AQeu28.js";import{B as P}from"./button-DCfeFHoH.js";import{s as Q}from"./diagnosticService-BDYTUoqk.js";import{e as Y,m as a,Z as J,j as O,T as U,x as Z,y as G}from"./index-BaOs5Ayg.js";import{M as H}from"./maximize-2-EHa6JURc.js";import{X as W}from"./x-TNvtuOD9.js";import{C as X}from"./clock-D1Ecvltm.js";import{C as K}from"./circle-check-big-m1SvzGFL.js";import{C as V}from"./chevron-right-COqGruhh.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/AvatarShop-Cc7V2NMs.js b/assets/AvatarShop-BeFk31yM.js similarity index 97% rename from assets/AvatarShop-Cc7V2NMs.js rename to assets/AvatarShop-BeFk31yM.js index c8291185294c9c587d692718e55faacc500d8c91..c8cc0a350edc81d588a572326d72901a108d966c 100644 --- a/assets/AvatarShop-Cc7V2NMs.js +++ b/assets/AvatarShop-BeFk31yM.js @@ -1,4 +1,4 @@ -import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{f as se,L as ae,h as re,g as oe}from"./vendor-radix-BorKzPz9.js";import{e as S,u as le,L as w,W as R,m as y,j as ie,t as c,aG as ne,aH as ce}from"./index-Cb8VeSuW.js";import{u as de}from"./useFeatureAccess-RwJxbRkp.js";import{T as me,a as ue,b as xe}from"./tooltip-BY91VKdD.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-CpWDoSfX.js";import{S as V}from"./sparkles-v8V3LFaV.js";import{S as fe}from"./shirt-CrJtkYx3.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{f as se,L as ae,h as re,g as oe}from"./vendor-radix-BorKzPz9.js";import{e as S,u as le,L as w,W as R,m as y,j as ie,t as c,aG as ne,aH as ce}from"./index-BaOs5Ayg.js";import{u as de}from"./useFeatureAccess-BSpfx3vY.js";import{T as me,a as ue,b as xe}from"./tooltip-ChRIOid3.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-CQIJrhLf.js";import{S as V}from"./sparkles-By-vFjpv.js";import{S as fe}from"./shirt-S3NBuaPm.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ChatMarkdown-B5QlckxZ.js b/assets/ChatMarkdown-fgwaycBR.js similarity index 84% rename from assets/ChatMarkdown-B5QlckxZ.js rename to assets/ChatMarkdown-fgwaycBR.js index 92a07b87d5cdd5662462b56abf20ebfe648ada5e..ecbd393e7abddbfe266ac2cab1fd8893d1db1a48 100644 --- a/assets/ChatMarkdown-B5QlckxZ.js +++ b/assets/ChatMarkdown-fgwaycBR.js @@ -1,2 +1,2 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-react-B4AQeu28.js","assets/vendor-markdown-CfVKi3_s.css"])))=>i.map(i=>d[i]); -import{aT as d,_ as c}from"./index-Cb8VeSuW.js";import{r as m,j as r}from"./vendor-react-B4AQeu28.js";import{M as h,r as x,a as y}from"./vendor-markdown-yqZQ_iQm.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";let s=null;const p=()=>(s||(s=c(()=>import("./vendor-markdown-yqZQ_iQm.js").then(l=>l.k),__vite__mapDeps([0,1,2]))),s),M=({children:l})=>{if(m.useEffect(()=>{p()},[]),!l||typeof l!="string")return null;const t=d(l);return r.jsx("div",{className:"chat-markdown",children:r.jsx(h,{remarkPlugins:[y],rehypePlugins:[x],components:{a:({href:e,children:a})=>r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:a}),code:e=>{const{inline:a,className:o,children:n,...i}=e;return r.jsx("code",{className:`${a?"bg-gray-100 dark:bg-gray-800 rounded px-1 py-0.5 text-sm":"block bg-gray-100 dark:bg-gray-900 rounded p-3 overflow-x-auto my-2"} ${o||""}`,...i,children:n})},blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),h1:({children:e})=>r.jsx("h1",{className:"text-2xl font-bold my-2",children:e}),h2:({children:e})=>r.jsx("h2",{className:"text-xl font-bold my-2",children:e}),h3:({children:e})=>r.jsx("h3",{className:"text-lg font-bold my-2",children:e}),h4:({children:e})=>r.jsx("h4",{className:"text-base font-bold my-2",children:e}),h5:({children:e})=>r.jsx("h5",{className:"text-sm font-bold my-2",children:e}),h6:({children:e})=>r.jsx("h6",{className:"text-xs font-bold my-2",children:e}),ul:({children:e})=>r.jsx("ul",{className:"list-disc list-inside my-2",children:e}),ol:({children:e})=>r.jsx("ol",{className:"list-decimal list-inside my-2",children:e}),li:({children:e})=>r.jsx("li",{className:"ml-2",children:e}),hr:()=>r.jsx("hr",{className:"my-4 border-t border-gray-300 dark:border-gray-600"}),p:({children:e})=>r.jsx("p",{className:"my-1",children:e})},children:t})})};export{M as default}; +import{b0 as d,_ as c}from"./index-BaOs5Ayg.js";import{r as m,j as r}from"./vendor-react-B4AQeu28.js";import{M as h,r as x,a as y}from"./vendor-markdown-yqZQ_iQm.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";let a=null;const p=()=>(a||(a=c(()=>import("./vendor-markdown-yqZQ_iQm.js").then(l=>l.k),__vite__mapDeps([0,1,2]))),a),M=({children:l})=>{if(m.useEffect(()=>{p()},[]),!l||typeof l!="string")return null;const t=d(l);return r.jsx("div",{className:"chat-markdown",children:r.jsx(h,{remarkPlugins:[y],rehypePlugins:[x],components:{a:({href:e,children:s})=>r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:s}),code:e=>{const{inline:s,className:o,children:n,...i}=e;return r.jsx("code",{className:`${s?"bg-gray-100 dark:bg-gray-800 rounded px-1 py-0.5 text-sm":"block bg-gray-100 dark:bg-gray-900 rounded p-3 overflow-x-auto my-2"} ${o||""}`,...i,children:n})},blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),h1:({children:e})=>r.jsx("h1",{className:"text-2xl font-bold my-2",children:e}),h2:({children:e})=>r.jsx("h2",{className:"text-xl font-bold my-2",children:e}),h3:({children:e})=>r.jsx("h3",{className:"text-lg font-bold my-2",children:e}),h4:({children:e})=>r.jsx("h4",{className:"text-base font-bold my-2",children:e}),h5:({children:e})=>r.jsx("h5",{className:"text-sm font-bold my-2",children:e}),h6:({children:e})=>r.jsx("h6",{className:"text-xs font-bold my-2",children:e}),ul:({children:e})=>r.jsx("ul",{className:"list-disc list-inside my-2",children:e}),ol:({children:e})=>r.jsx("ol",{className:"list-decimal list-inside my-2",children:e}),li:({children:e})=>r.jsx("li",{className:"ml-2",children:e}),hr:()=>r.jsx("hr",{className:"my-4 border-t border-gray-300 dark:border-gray-600"}),p:({children:e})=>r.jsx("p",{className:"my-1",children:e})},children:t})})};export{M as default}; diff --git a/assets/CompetencyRadarChart-Br1qCKfl.js b/assets/CompetencyRadarChart-CBuH8ru8.js similarity index 98% rename from assets/CompetencyRadarChart-Br1qCKfl.js rename to assets/CompetencyRadarChart-CBuH8ru8.js index 82da0bffacddcf7bbd282de5fae08a6ac3afbedb..97ce394c3d42a295a452e9b5c473a81849630ef6 100644 --- a/assets/CompetencyRadarChart-Br1qCKfl.js +++ b/assets/CompetencyRadarChart-CBuH8ru8.js @@ -1 +1 @@ -import{r as g,j as t}from"./vendor-react-B4AQeu28.js";import{f as A,a4 as I,u as B,m as L,B as O,a as W}from"./index-Cb8VeSuW.js";import{collection as E,getDocs as R,query as H,orderBy as K,limit as U,Timestamp as G,getDoc as Y,doc as $}from"./vendor-firebase-firestore-CH1lNiRF.js";import{g as J,s as V}from"./subjects-Bnu0lJdU.js";import{S as X}from"./sparkles-v8V3LFaV.js";import{R as Z,f as ee,P as te,g as se,h as ne,i as ae,T as oe}from"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-CmH46HAG.js";const P=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];async function re(a){try{const r=E(A,"users",a,"quizResults"),u=H(r,K("timestamp","desc"),U(500)),d=await R(u);return d.empty?F(a):d.docs.map(s=>{const e=s.data();return{quizId:s.id,moduleId:e.moduleId||"",subjectId:e.subjectId||"",score:typeof e.score=="number"?e.score:0,totalQuestions:e.totalQuestions||0,correctAnswers:e.correctAnswers||0,questionType:e.questionType||"multiple_choice",timestamp:e.timestamp instanceof G||e.timestamp?.toDate?e.timestamp.toDate():new Date,timeSpent:e.timeSpent||0}})}catch(r){return console.error("[competencyService] fetchQuizResults failed, falling back:",r),F(a)}}async function F(a){const r=await Y($(A,"progress",a));return r.exists()?(r.data().quizAttempts||[]).map((s,e)=>({quizId:String(s.quizId||`attempt-${e}`),moduleId:String(s.moduleId||s.quizId||""),subjectId:String(s.subjectId||""),score:typeof s.score=="number"?s.score:0,totalQuestions:s.totalQuestions||0,correctAnswers:typeof s.correctAnswers=="number"?s.correctAnswers:0,questionType:s.questionType||"multiple_choice",timestamp:s.completedAt?new Date(s.completedAt):new Date,timeSpent:s.timeSpent||0})):[]}async function ie(a){try{const r=E(A,"users",a,"moduleProgress"),u=await R(r);if(u.empty)return{};const d={};return u.forEach(s=>{const e=s.data();d[s.id]={moduleId:s.id,subjectId:e.subjectId||"",sessionsCompleted:e.sessionsCompleted||0,lastActive:e.lastActive?e.lastActive instanceof G?e.lastActive.toDate():new Date(e.lastActive):new Date,moduleTitle:e.moduleTitle||s.id,lessonsCompleted:e.lessonsCompleted||[],quizzesCompleted:e.quizzesCompleted||[]}}),d}catch(r){return console.error("[competencyService] fetchModuleProgress failed:",r),{}}}function _(a,r,u,d){const s=r.filter(m=>m.moduleId===a),e=s.length>0?s.reduce((m,b)=>m+b.score,0)/s.length:0,h=["identification","multiple_choice"],p=s.filter(m=>h.includes(m.questionType)),i=p.length>0?p.reduce((m,b)=>m+b.score,0)/p.length:e*.9,o=["word_problem","equation_based","enumeration"],l=s.filter(m=>o.includes(m.questionType)),n=l.length>0?l.reduce((m,b)=>m+b.score,0)/l.length:e*.85,f=u,c=f?.lessonsCompleted?.length||0,k=f?.quizzesCompleted?.length||0,S=f?.sessionsCompleted||0,y=d.find(m=>m.id===a),x=y?.lessons?.length||1,N=y?.quizzes?.length||1,C=Math.min(100,c/x*100),M=Math.min(100,k/N*100),v=Math.min(100,(C+M+S*5)/2.5);if(s.length<2){const m=v>50?60+v*.3:v*.8;return{overallMastery:e,conceptGrasp:i,application:n,engagement:v,consistency:Math.min(100,m)}}const w=s.map(m=>m.score),z=w.reduce((m,b)=>m+b,0)/w.length,D=w.reduce((m,b)=>m+Math.pow(b-z,2),0)/w.length,j=Math.sqrt(D)/Math.max(z,1),q=Math.max(0,Math.min(100,(1-j)*100));return{overallMastery:Math.round(e),conceptGrasp:Math.round(i),application:Math.round(n),engagement:Math.round(v),consistency:Math.round(q)}}async function le(a){try{const r=E(A,"users",a,"competencyMatrix"),u=await R(r);if(u.empty)return{};const d={};return u.forEach(s=>{const e=s.data();d[s.id]={moduleId:s.id,moduleName:e.moduleName||s.id,overallMastery:e.overallMastery??0,conceptGrasp:e.conceptGrasp??0,application:e.application??0,engagement:e.engagement??0,consistency:e.consistency??0,computedAt:e.computedAt?.toDate?.()||new Date}}),d}catch(r){return console.error("[competencyService] fetchCachedCompetencyMatrix failed:",r),{}}}const Q=[{key:"progress",label:"Overall Mastery"},{key:"concept",label:"Concept Grasp"},{key:"application",label:"Application"},{key:"engagement",label:"Engagement"},{key:"consistency",label:"Consistency"}];function ce(a){const[r,u]=g.useState([]),[d,s]=g.useState([]),[e,h]=g.useState("N/A"),[p,i]=g.useState(!0),[o,l]=g.useState(null),[n,f]=g.useState(!1),c=g.useRef(0),k=g.useCallback(async(y,x)=>{if(x!==c.current)return;const C=J(null)[0]??"gen-math",M=V.find(j=>j.id===C)?.modules||[],v=M.map((j,q)=>({id:j.id,name:j.title.length>15?j.title.substring(0,15).trim()+"...":j.title,color:P[q%P.length]})),w=await le(a);if(x!==c.current)return;if(Object.keys(w).length>0){de(w,v,u,h),f(!1),i(!1);return}const z=await re(a),D=await ie(a);if(x!==c.current)return;const T=z.length>0;f(!T),ue(z,D,v,M,u,h),i(!1)},[a]),S=g.useCallback(async()=>{if(!a){i(!1);return}const y=++c.current;i(!0),l(null);try{const x=await new Promise(N=>{const C=I(a,M=>{C(),N(M)})});if(y!==c.current)return;await k(x,y)}catch(x){console.error("[useCompetencyMatrix] Failed to load:",x),y===c.current&&(l("Failed to load competency data. Please try again."),i(!1))}},[a,k]);return g.useEffect(()=>{if(!a)return;const y=I(a,x=>{const N=++c.current;k(x,N)});return()=>y()},[a,k]),{data:r,modulesList:d,topModule:e,loading:p,error:o,isEmpty:n,refresh:S}}function de(a,r,u,d){let s=-1,e="N/A";const h=Q.map(p=>{const i={metric:p.label,fullMark:100};return r.forEach(o=>{const l=a[o.id];l&&(p.key==="progress"?i[o.id]=l.overallMastery:p.key==="concept"?i[o.id]=l.conceptGrasp:p.key==="application"?i[o.id]=l.application:p.key==="engagement"?i[o.id]=l.engagement:p.key==="consistency"&&(i[o.id]=l.consistency))}),i});r.forEach(p=>{const i=a[p.id];if(i){const o=(i.overallMastery+i.conceptGrasp+i.application+i.engagement+i.consistency)/5;o>s&&(s=o,e=p.name)}}),d(e),u(h)}function ue(a,r,u,d,s,e){let h=-1,p="N/A";const i=Q.map(o=>{const l={metric:o.label,fullMark:100};return d.forEach(n=>{const f=r[n.id],c=_(n.id,a,f??{moduleId:n.id,sessionsCompleted:0,moduleTitle:n.title,lessonsCompleted:[],quizzesCompleted:[]},d);o.key==="progress"?l[n.id]=c.overallMastery:o.key==="concept"?l[n.id]=c.conceptGrasp:o.key==="application"?l[n.id]=c.application:o.key==="engagement"?l[n.id]=c.engagement:o.key==="consistency"&&(l[n.id]=c.consistency)}),l});d.forEach(o=>{const l=r[o.id],n=_(o.id,a,l??{moduleId:o.id,sessionsCompleted:0,moduleTitle:o.title,lessonsCompleted:[],quizzesCompleted:[]},d),f=(n.overallMastery+n.conceptGrasp+n.application+n.engagement+n.consistency)/5;f>h&&(h=f,p=u.find(c=>c.id===o.id)?.name||"N/A")}),e(p),s(i)}const Me=()=>{const{userProfile:a}=B(),{data:r,modulesList:u,topModule:d,loading:s,error:e,isEmpty:h,refresh:p}=ce(a?.uid??""),[i,o]=g.useState(!1),l=()=>{p()};return t.jsxs(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:[.22,1,.36,1]},className:"relative overflow-hidden bg-white/80 backdrop-blur-xl border border-white/50 shadow-[0_8px_30px_rgb(0,0,0,0.04)] rounded-[2rem] p-6 lg:p-8 isolate group",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[t.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-violet-400/5 rounded-full blur-3xl -translate-y-1/2 translate-x-1/4"}),t.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-rose-400/5 rounded-full blur-3xl translate-y-1/3 -translate-x-1/3"}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between mb-8 relative z-10 gap-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"p-2 bg-violet-100 text-violet-600 rounded-xl",children:t.jsx(O,{size:20,className:"stroke-[2.5]"})}),t.jsx("h3",{className:"text-xl font-display font-extrabold text-[#0a1628] tracking-tight",children:"Competency Matrix"})]}),t.jsx("p",{className:"text-sm text-[#5a6578] font-body ml-12",children:"Your realtime performance across modules"})]}),!s&&!h&&!e&&t.jsxs("div",{className:"flex items-center gap-3 bg-slate-50 border border-slate-100 px-4 py-2 rounded-2xl ml-12 sm:ml-0",children:[t.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-white shadow-sm border border-slate-100",children:t.jsx(X,{size:14,className:"text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Top Module"}),t.jsx("p",{className:"text-sm font-bold text-slate-700",children:d})]})]}),!s&&t.jsx("button",{onClick:l,className:"sm:ml-auto text-xs font-semibold text-slate-400 hover:text-violet-600 transition-colors px-2 py-1 rounded-lg hover:bg-violet-50",title:"Refresh competency data",children:"Refresh"})]}),t.jsx("div",{className:"h-[300px] sm:h-[360px] w-full relative z-10",children:s?t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 border-4 border-violet-200 border-t-violet-500 rounded-full animate-spin"}),t.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Analyzing skill vectors..."})]})}):h||e?t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4",children:[t.jsx("div",{className:"w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:t.jsx(W,{size:28,className:"text-slate-400"})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-semibold text-slate-600 mb-1",children:e?"Unable to load competency data":"No activity yet"}),t.jsx("p",{className:"text-xs text-slate-400 max-w-[260px]",children:e||"Complete quizzes and lessons to see your competency matrix here."})]}),e&&t.jsx("button",{onClick:l,className:"px-4 py-2 text-xs font-semibold bg-violet-100 text-violet-700 rounded-xl hover:bg-violet-200 transition-colors",children:"Try Again"})]}):t.jsx(Z,{width:"100%",height:"100%",children:t.jsxs(ee,{cx:"50%",cy:"50%",outerRadius:i?"75%":"70%",data:r,children:[t.jsx(te,{stroke:"#e2e8f0",strokeDasharray:"4 4",polarRadius:[20,40,60,80,100]}),t.jsx(se,{dataKey:"metric",tick:{fill:"#475569",fontSize:12,fontWeight:600,fontFamily:"Inter, sans-serif"}}),t.jsx(ne,{angle:90,domain:[0,100],tick:{fill:"#94a3b8",fontSize:10},tickCount:6,axisLine:!1}),u.map(n=>t.jsx(ae,{name:n.name,dataKey:n.id,stroke:n.color,strokeWidth:2,fill:n.color,fillOpacity:.35,dot:{r:3,fill:"#fff",stroke:n.color,strokeWidth:2},activeDot:{r:5,fill:n.color,stroke:"#fff",strokeWidth:2},isAnimationActive:!0,animationDuration:1500,animationEasing:"ease-out"},n.id)),t.jsx(oe,{cursor:!1,content:({active:n,payload:f})=>n&&f&&f.length?t.jsxs("div",{className:"bg-white/95 backdrop-blur shadow-[0_10px_40px_-10px_rgba(0,0,0,0.15)] border border-slate-100 rounded-xl p-4",children:[t.jsx("p",{className:"font-display font-bold text-slate-800 text-sm mb-3",children:f[0].payload.metric}),t.jsx("div",{className:"flex flex-col gap-2",children:f.map(c=>t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c.stroke}}),t.jsx("span",{className:"text-xs font-bold text-slate-600 uppercase tracking-wide truncate max-w-[120px]",title:String(c.name),children:String(c.name)})]}),t.jsxs("span",{className:"text-sm font-black",style:{color:c.stroke},children:[Math.round(c.value),"%"]})]},c.name))})]}):null})]})})}),!s&&!h&&!e&&u.length>0&&t.jsx("div",{className:"flex flex-wrap justify-center items-center gap-3 md:gap-5 mt-[5px] z-10 relative",children:u.map(n=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:n.color}}),t.jsx("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-widest",children:n.name.length>15?n.name.substring(0,12)+"...":n.name})]},n.id))})]})};export{Me as CompetencyRadarChart}; +import{r as g,j as t}from"./vendor-react-B4AQeu28.js";import{f as A,a4 as I,u as B,m as L,B as O,a as W}from"./index-BaOs5Ayg.js";import{collection as E,getDocs as R,query as H,orderBy as K,limit as U,Timestamp as G,getDoc as Y,doc as $}from"./vendor-firebase-firestore-CH1lNiRF.js";import{g as J,s as V}from"./subjects-BFghB0SQ.js";import{S as X}from"./sparkles-By-vFjpv.js";import{R as Z,f as ee,P as te,g as se,h as ne,i as ae,T as oe}from"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B3jJOD5i.js";const P=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];async function re(a){try{const r=E(A,"users",a,"quizResults"),u=H(r,K("timestamp","desc"),U(500)),d=await R(u);return d.empty?F(a):d.docs.map(s=>{const e=s.data();return{quizId:s.id,moduleId:e.moduleId||"",subjectId:e.subjectId||"",score:typeof e.score=="number"?e.score:0,totalQuestions:e.totalQuestions||0,correctAnswers:e.correctAnswers||0,questionType:e.questionType||"multiple_choice",timestamp:e.timestamp instanceof G||e.timestamp?.toDate?e.timestamp.toDate():new Date,timeSpent:e.timeSpent||0}})}catch(r){return console.error("[competencyService] fetchQuizResults failed, falling back:",r),F(a)}}async function F(a){const r=await Y($(A,"progress",a));return r.exists()?(r.data().quizAttempts||[]).map((s,e)=>({quizId:String(s.quizId||`attempt-${e}`),moduleId:String(s.moduleId||s.quizId||""),subjectId:String(s.subjectId||""),score:typeof s.score=="number"?s.score:0,totalQuestions:s.totalQuestions||0,correctAnswers:typeof s.correctAnswers=="number"?s.correctAnswers:0,questionType:s.questionType||"multiple_choice",timestamp:s.completedAt?new Date(s.completedAt):new Date,timeSpent:s.timeSpent||0})):[]}async function ie(a){try{const r=E(A,"users",a,"moduleProgress"),u=await R(r);if(u.empty)return{};const d={};return u.forEach(s=>{const e=s.data();d[s.id]={moduleId:s.id,subjectId:e.subjectId||"",sessionsCompleted:e.sessionsCompleted||0,lastActive:e.lastActive?e.lastActive instanceof G?e.lastActive.toDate():new Date(e.lastActive):new Date,moduleTitle:e.moduleTitle||s.id,lessonsCompleted:e.lessonsCompleted||[],quizzesCompleted:e.quizzesCompleted||[]}}),d}catch(r){return console.error("[competencyService] fetchModuleProgress failed:",r),{}}}function _(a,r,u,d){const s=r.filter(m=>m.moduleId===a),e=s.length>0?s.reduce((m,b)=>m+b.score,0)/s.length:0,h=["identification","multiple_choice"],p=s.filter(m=>h.includes(m.questionType)),i=p.length>0?p.reduce((m,b)=>m+b.score,0)/p.length:e*.9,o=["word_problem","equation_based","enumeration"],l=s.filter(m=>o.includes(m.questionType)),n=l.length>0?l.reduce((m,b)=>m+b.score,0)/l.length:e*.85,f=u,c=f?.lessonsCompleted?.length||0,k=f?.quizzesCompleted?.length||0,S=f?.sessionsCompleted||0,y=d.find(m=>m.id===a),x=y?.lessons?.length||1,N=y?.quizzes?.length||1,C=Math.min(100,c/x*100),M=Math.min(100,k/N*100),v=Math.min(100,(C+M+S*5)/2.5);if(s.length<2){const m=v>50?60+v*.3:v*.8;return{overallMastery:e,conceptGrasp:i,application:n,engagement:v,consistency:Math.min(100,m)}}const w=s.map(m=>m.score),z=w.reduce((m,b)=>m+b,0)/w.length,D=w.reduce((m,b)=>m+Math.pow(b-z,2),0)/w.length,j=Math.sqrt(D)/Math.max(z,1),q=Math.max(0,Math.min(100,(1-j)*100));return{overallMastery:Math.round(e),conceptGrasp:Math.round(i),application:Math.round(n),engagement:Math.round(v),consistency:Math.round(q)}}async function le(a){try{const r=E(A,"users",a,"competencyMatrix"),u=await R(r);if(u.empty)return{};const d={};return u.forEach(s=>{const e=s.data();d[s.id]={moduleId:s.id,moduleName:e.moduleName||s.id,overallMastery:e.overallMastery??0,conceptGrasp:e.conceptGrasp??0,application:e.application??0,engagement:e.engagement??0,consistency:e.consistency??0,computedAt:e.computedAt?.toDate?.()||new Date}}),d}catch(r){return console.error("[competencyService] fetchCachedCompetencyMatrix failed:",r),{}}}const Q=[{key:"progress",label:"Overall Mastery"},{key:"concept",label:"Concept Grasp"},{key:"application",label:"Application"},{key:"engagement",label:"Engagement"},{key:"consistency",label:"Consistency"}];function ce(a){const[r,u]=g.useState([]),[d,s]=g.useState([]),[e,h]=g.useState("N/A"),[p,i]=g.useState(!0),[o,l]=g.useState(null),[n,f]=g.useState(!1),c=g.useRef(0),k=g.useCallback(async(y,x)=>{if(x!==c.current)return;const C=J(null)[0]??"gen-math",M=V.find(j=>j.id===C)?.modules||[],v=M.map((j,q)=>({id:j.id,name:j.title.length>15?j.title.substring(0,15).trim()+"...":j.title,color:P[q%P.length]})),w=await le(a);if(x!==c.current)return;if(Object.keys(w).length>0){de(w,v,u,h),f(!1),i(!1);return}const z=await re(a),D=await ie(a);if(x!==c.current)return;const T=z.length>0;f(!T),ue(z,D,v,M,u,h),i(!1)},[a]),S=g.useCallback(async()=>{if(!a){i(!1);return}const y=++c.current;i(!0),l(null);try{const x=await new Promise(N=>{const C=I(a,M=>{C(),N(M)})});if(y!==c.current)return;await k(x,y)}catch(x){console.error("[useCompetencyMatrix] Failed to load:",x),y===c.current&&(l("Failed to load competency data. Please try again."),i(!1))}},[a,k]);return g.useEffect(()=>{if(!a)return;const y=I(a,x=>{const N=++c.current;k(x,N)});return()=>y()},[a,k]),{data:r,modulesList:d,topModule:e,loading:p,error:o,isEmpty:n,refresh:S}}function de(a,r,u,d){let s=-1,e="N/A";const h=Q.map(p=>{const i={metric:p.label,fullMark:100};return r.forEach(o=>{const l=a[o.id];l&&(p.key==="progress"?i[o.id]=l.overallMastery:p.key==="concept"?i[o.id]=l.conceptGrasp:p.key==="application"?i[o.id]=l.application:p.key==="engagement"?i[o.id]=l.engagement:p.key==="consistency"&&(i[o.id]=l.consistency))}),i});r.forEach(p=>{const i=a[p.id];if(i){const o=(i.overallMastery+i.conceptGrasp+i.application+i.engagement+i.consistency)/5;o>s&&(s=o,e=p.name)}}),d(e),u(h)}function ue(a,r,u,d,s,e){let h=-1,p="N/A";const i=Q.map(o=>{const l={metric:o.label,fullMark:100};return d.forEach(n=>{const f=r[n.id],c=_(n.id,a,f??{moduleId:n.id,sessionsCompleted:0,moduleTitle:n.title,lessonsCompleted:[],quizzesCompleted:[]},d);o.key==="progress"?l[n.id]=c.overallMastery:o.key==="concept"?l[n.id]=c.conceptGrasp:o.key==="application"?l[n.id]=c.application:o.key==="engagement"?l[n.id]=c.engagement:o.key==="consistency"&&(l[n.id]=c.consistency)}),l});d.forEach(o=>{const l=r[o.id],n=_(o.id,a,l??{moduleId:o.id,sessionsCompleted:0,moduleTitle:o.title,lessonsCompleted:[],quizzesCompleted:[]},d),f=(n.overallMastery+n.conceptGrasp+n.application+n.engagement+n.consistency)/5;f>h&&(h=f,p=u.find(c=>c.id===o.id)?.name||"N/A")}),e(p),s(i)}const Me=()=>{const{userProfile:a}=B(),{data:r,modulesList:u,topModule:d,loading:s,error:e,isEmpty:h,refresh:p}=ce(a?.uid??""),[i,o]=g.useState(!1),l=()=>{p()};return t.jsxs(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:[.22,1,.36,1]},className:"relative overflow-hidden bg-white/80 backdrop-blur-xl border border-white/50 shadow-[0_8px_30px_rgb(0,0,0,0.04)] rounded-[2rem] p-6 lg:p-8 isolate group",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[t.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-violet-400/5 rounded-full blur-3xl -translate-y-1/2 translate-x-1/4"}),t.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-rose-400/5 rounded-full blur-3xl translate-y-1/3 -translate-x-1/3"}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between mb-8 relative z-10 gap-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"p-2 bg-violet-100 text-violet-600 rounded-xl",children:t.jsx(O,{size:20,className:"stroke-[2.5]"})}),t.jsx("h3",{className:"text-xl font-display font-extrabold text-[#0a1628] tracking-tight",children:"Competency Matrix"})]}),t.jsx("p",{className:"text-sm text-[#5a6578] font-body ml-12",children:"Your realtime performance across modules"})]}),!s&&!h&&!e&&t.jsxs("div",{className:"flex items-center gap-3 bg-slate-50 border border-slate-100 px-4 py-2 rounded-2xl ml-12 sm:ml-0",children:[t.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-white shadow-sm border border-slate-100",children:t.jsx(X,{size:14,className:"text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Top Module"}),t.jsx("p",{className:"text-sm font-bold text-slate-700",children:d})]})]}),!s&&t.jsx("button",{onClick:l,className:"sm:ml-auto text-xs font-semibold text-slate-400 hover:text-violet-600 transition-colors px-2 py-1 rounded-lg hover:bg-violet-50",title:"Refresh competency data",children:"Refresh"})]}),t.jsx("div",{className:"h-[300px] sm:h-[360px] w-full relative z-10",children:s?t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 border-4 border-violet-200 border-t-violet-500 rounded-full animate-spin"}),t.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Analyzing skill vectors..."})]})}):h||e?t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4",children:[t.jsx("div",{className:"w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:t.jsx(W,{size:28,className:"text-slate-400"})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-semibold text-slate-600 mb-1",children:e?"Unable to load competency data":"No activity yet"}),t.jsx("p",{className:"text-xs text-slate-400 max-w-[260px]",children:e||"Complete quizzes and lessons to see your competency matrix here."})]}),e&&t.jsx("button",{onClick:l,className:"px-4 py-2 text-xs font-semibold bg-violet-100 text-violet-700 rounded-xl hover:bg-violet-200 transition-colors",children:"Try Again"})]}):t.jsx(Z,{width:"100%",height:"100%",children:t.jsxs(ee,{cx:"50%",cy:"50%",outerRadius:i?"75%":"70%",data:r,children:[t.jsx(te,{stroke:"#e2e8f0",strokeDasharray:"4 4",polarRadius:[20,40,60,80,100]}),t.jsx(se,{dataKey:"metric",tick:{fill:"#475569",fontSize:12,fontWeight:600,fontFamily:"Inter, sans-serif"}}),t.jsx(ne,{angle:90,domain:[0,100],tick:{fill:"#94a3b8",fontSize:10},tickCount:6,axisLine:!1}),u.map(n=>t.jsx(ae,{name:n.name,dataKey:n.id,stroke:n.color,strokeWidth:2,fill:n.color,fillOpacity:.35,dot:{r:3,fill:"#fff",stroke:n.color,strokeWidth:2},activeDot:{r:5,fill:n.color,stroke:"#fff",strokeWidth:2},isAnimationActive:!0,animationDuration:1500,animationEasing:"ease-out"},n.id)),t.jsx(oe,{cursor:!1,content:({active:n,payload:f})=>n&&f&&f.length?t.jsxs("div",{className:"bg-white/95 backdrop-blur shadow-[0_10px_40px_-10px_rgba(0,0,0,0.15)] border border-slate-100 rounded-xl p-4",children:[t.jsx("p",{className:"font-display font-bold text-slate-800 text-sm mb-3",children:f[0].payload.metric}),t.jsx("div",{className:"flex flex-col gap-2",children:f.map(c=>t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c.stroke}}),t.jsx("span",{className:"text-xs font-bold text-slate-600 uppercase tracking-wide truncate max-w-[120px]",title:String(c.name),children:String(c.name)})]}),t.jsxs("span",{className:"text-sm font-black",style:{color:c.stroke},children:[Math.round(c.value),"%"]})]},c.name))})]}):null})]})})}),!s&&!h&&!e&&u.length>0&&t.jsx("div",{className:"flex flex-wrap justify-center items-center gap-3 md:gap-5 mt-[5px] z-10 relative",children:u.map(n=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:n.color}}),t.jsx("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-widest",children:n.name.length>15?n.name.substring(0,12)+"...":n.name})]},n.id))})]})};export{Me as CompetencyRadarChart}; diff --git a/assets/ConfirmModal-B7469iTj.js b/assets/ConfirmModal-6cgkqXAT.js similarity index 91% rename from assets/ConfirmModal-B7469iTj.js rename to assets/ConfirmModal-6cgkqXAT.js index 33ee8541876ebc42113e7e1d3a6cef9a01c09764..79a8b6b0e609f553ade4ef358d52a65752708fba 100644 --- a/assets/ConfirmModal-B7469iTj.js +++ b/assets/ConfirmModal-6cgkqXAT.js @@ -1 +1 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{B as i}from"./button-De2q2xHf.js";import{j as f,m as r,p as h}from"./index-Cb8VeSuW.js";import{X as j}from"./x-CTLBAl-n.js";import{T as y}from"./trash-2-DB-oXtbr.js";import{L as w}from"./log-out-CM6AS10M.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const O=({isOpen:s,onClose:t,onConfirm:n,title:a,message:l,confirmText:c="Confirm",cancelText:d="Cancel",type:m="warning",icon:x="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(x){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(y,{size:32});case"warning":default:return e.jsx(h,{size:32})}},o=(()=>{switch(m){case"danger":return{iconBg:"bg-red-100",iconColor:"text-red-600",buttonBg:"bg-red-600 hover:bg-red-700",buttonText:"text-white"};case"warning":return{iconBg:"bg-rose-100",iconColor:"text-rose-600",buttonBg:"bg-rose-600 hover:bg-rose-700",buttonText:"text-white"};case"info":default:return{iconBg:"bg-sky-100",iconColor:"text-sky-600",buttonBg:"bg-sky-600 hover:bg-sky-700",buttonText:"text-white"}}})(),p=async()=>{try{await n(),t()}catch{}};return e.jsx(f,{children:s&&e.jsx(e.Fragment,{children:e.jsx(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:`fixed inset-0 bg-black/50 backdrop-blur-sm ${g} flex items-center justify-center p-4`,children:e.jsxs(r.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{type:"spring",damping:25,stiffness:300},onClick:u=>u.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl max-w-md w-full overflow-hidden border border-[#dde3eb]",children:[e.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-500 hover:text-[#0a1628] hover:bg-[#dde3eb] rounded-xl transition-colors z-10",children:e.jsx(j,{size:20})}),e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(r.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1,type:"spring",damping:15},className:`w-20 h-20 ${o.iconBg} rounded-full flex items-center justify-center mx-auto mb-6 ${o.iconColor}`,children:b()}),e.jsx("h2",{className:"text-2xl font-display font-bold text-[#0a1628] mb-3",children:a}),e.jsx("p",{className:"text-[#5a6578] mb-8 leading-relaxed",children:l}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(i,{onClick:t,variant:"outline",size:"lg",className:"flex-1 h-12 rounded-xl border-[#dde3eb] hover:border-[#d1cec6] hover:bg-[#edf1f7] font-bold",children:d}),e.jsx(i,{onClick:p,size:"lg",className:`flex-1 h-12 rounded-xl font-bold ${o.buttonBg} ${o.buttonText} transition-colors shadow-lg`,children:c})]})]})]})})})})};export{O as default}; +import{j as e}from"./vendor-react-B4AQeu28.js";import{B as i}from"./button-DCfeFHoH.js";import{j as f,m as r,p as h}from"./index-BaOs5Ayg.js";import{X as j}from"./x-TNvtuOD9.js";import{T as y}from"./trash-2-HTnKafZd.js";import{L as w}from"./log-out-BenDMDly.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const O=({isOpen:s,onClose:t,onConfirm:n,title:a,message:l,confirmText:c="Confirm",cancelText:d="Cancel",type:m="warning",icon:x="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(x){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(y,{size:32});case"warning":default:return e.jsx(h,{size:32})}},o=(()=>{switch(m){case"danger":return{iconBg:"bg-red-100",iconColor:"text-red-600",buttonBg:"bg-red-600 hover:bg-red-700",buttonText:"text-white"};case"warning":return{iconBg:"bg-rose-100",iconColor:"text-rose-600",buttonBg:"bg-rose-600 hover:bg-rose-700",buttonText:"text-white"};case"info":default:return{iconBg:"bg-sky-100",iconColor:"text-sky-600",buttonBg:"bg-sky-600 hover:bg-sky-700",buttonText:"text-white"}}})(),p=async()=>{try{await n(),t()}catch{}};return e.jsx(f,{children:s&&e.jsx(e.Fragment,{children:e.jsx(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:`fixed inset-0 bg-black/50 backdrop-blur-sm ${g} flex items-center justify-center p-4`,children:e.jsxs(r.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{type:"spring",damping:25,stiffness:300},onClick:u=>u.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl max-w-md w-full overflow-hidden border border-[#dde3eb]",children:[e.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-500 hover:text-[#0a1628] hover:bg-[#dde3eb] rounded-xl transition-colors z-10",children:e.jsx(j,{size:20})}),e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(r.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1,type:"spring",damping:15},className:`w-20 h-20 ${o.iconBg} rounded-full flex items-center justify-center mx-auto mb-6 ${o.iconColor}`,children:b()}),e.jsx("h2",{className:"text-2xl font-display font-bold text-[#0a1628] mb-3",children:a}),e.jsx("p",{className:"text-[#5a6578] mb-8 leading-relaxed",children:l}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(i,{onClick:t,variant:"outline",size:"lg",className:"flex-1 h-12 rounded-xl border-[#dde3eb] hover:border-[#d1cec6] hover:bg-[#edf1f7] font-bold",children:d}),e.jsx(i,{onClick:p,size:"lg",className:`flex-1 h-12 rounded-xl font-bold ${o.buttonBg} ${o.buttonText} transition-colors shadow-lg`,children:c})]})]})]})})})})};export{O as default}; diff --git a/assets/FloatingAITutor-C_4EP63I.js b/assets/FloatingAITutor-BIdguqCV.js similarity index 93% rename from assets/FloatingAITutor-C_4EP63I.js rename to assets/FloatingAITutor-BIdguqCV.js index 0b6546b6f340810d7c967b2b0e3cc3925588a8e2..cc087afc351e5c6a5ca8c68a9624c51cd66691d6 100644 --- a/assets/FloatingAITutor-C_4EP63I.js +++ b/assets/FloatingAITutor-BIdguqCV.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatMarkdown-B5QlckxZ.js","assets/index-Cb8VeSuW.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-Aaqs1LGb.css"])))=>i.map(i=>d[i]); -import{ay as C,_ as y,m as b,w as A}from"./index-Cb8VeSuW.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-DkEKBrNU.js";import{M as w}from"./minus-CMQilTBg.js";import{X as g}from"./x-CTLBAl-n.js";import{S as L}from"./send-CMJOaNp6.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-B5QlckxZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])));function O(a){return a?a instanceof Date?a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof a=="object"&&"toDate"in a?a.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(a):""}const Q=({constraintsRef:a,onFullScreen:j})=>{const{activeSessionId:r,setActiveSessionId:v,createNewSession:N,getActiveSession:k,sendMessage:I,isLoading:o}=C(),[s,l]=i.useState(!1),[c,u]=i.useState(()=>typeof window>"u"?!1:window.localStorage.getItem("floating_ai_tutor_minimized")==="1"),[n,m]=i.useState(""),h=i.useRef(null);i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("floating_ai_tutor_minimized",c?"1":"0")},[c]),i.useEffect(()=>{s&&y(async()=>{const{warmupBackend:t}=await import("./index-Cb8VeSuW.js").then(d=>d.aV);return{warmupBackend:t}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10,11,12])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("Floating tutor warmup skipped:",t)})},[s]),i.useEffect(()=>{if(s&&!r){const t={id:"1",sender:"ai",text:"Hi! I'm your AI math tutor. What would you like to learn about today?",timestamp:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},d=N(t);v(d)}},[s]);const x=k()?.messages||[],S=()=>{h.current?.scrollIntoView({behavior:"smooth"})};i.useEffect(()=>{S()},[x]);const p=async()=>{if(!n.trim()||!r||o)return;const t=n.trim();m(""),await I(r,t)},_=()=>{j()},f=()=>{l(!1),u(!0)},z=()=>{u(!1)};return e.jsxs("div",{className:"pointer-events-none flex flex-col items-end",children:[e.jsxs("div",{className:`pointer-events-auto mb-4 w-80 bg-[#f7f9fc] rounded-3xl shadow-2xl border border-[#dde3eb] flex flex-col overflow-hidden transition-all duration-300 origin-bottom-right select-none ${s?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-10 pointer-events-none h-0"}`,style:{"--max-h":s?"32rem":"0",willChange:"transform, opacity"},children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center backdrop-blur-sm",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-9 h-9 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-sm",children:"L.O.L.I."}),e.jsxs("p",{className:"text-sky-100 text-[10px] leading-tight",children:["Logical Operations &",e.jsx("br",{}),"Learning Intelligence"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:_,type:"button","aria-label":"Open fullscreen",className:"p-2 hover:bg-white/20 rounded-lg transition-colors",title:"Open fullscreen",children:e.jsx(M,{size:16,className:"text-white"})}),e.jsx("button",{type:"button","aria-label":"Minimize AI tutor launcher",onClick:f,className:"p-2 hover:bg-white/20 rounded-lg transition-colors",title:"Minimize",children:e.jsx(w,{size:16,className:"text-white"})}),e.jsx("button",{type:"button","aria-label":"Close chat",onClick:()=>l(!1),className:"p-2 hover:bg-white/20 rounded-lg transition-colors",children:e.jsx(g,{size:16,className:"text-white"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 bg-[#edf1f7]",children:[x.map(t=>e.jsx("div",{className:`flex ${t.sender==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[75%] rounded-2xl px-4 py-2.5 ${t.sender==="user"?"bg-sky-600 text-white":"bg-white text-[#0a1628] shadow-sm border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.text}):e.jsx(i.Suspense,{fallback:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.text}),children:e.jsx(E,{children:t.text})}),e.jsx("p",{className:`text-[10px] mt-1 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:O(t.timestamp)})]})},t.id)),o&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white text-[#0a1628] shadow-sm border border-[#dde3eb] rounded-2xl px-4 py-2.5 max-w-[75%]",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})}),e.jsx("div",{ref:h})]}),e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-tutor-input",name:"ai-tutor-input","aria-label":"Ask AI tutor a question",type:"text",value:n,onChange:t=>m(t.target.value),onKeyPress:t=>t.key==="Enter"&&p(),placeholder:"Ask me anything...",className:"flex-1 px-4 py-2.5 rounded-xl border border-[#dde3eb] focus:outline-none focus:ring-2 focus:ring-sky-500 text-sm bg-[#f7f9fc]"}),e.jsx("button",{type:"button","aria-label":"Send message",onClick:p,className:"p-2.5 bg-sky-600 hover:bg-sky-700 text-white rounded-xl transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:!n.trim()||o,children:e.jsx(L,{size:18})})]})})]}),e.jsx("div",{className:"pointer-events-auto relative self-end",children:c?e.jsx(b.button,{type:"button",onClick:z,whileHover:{scale:1.08},whileTap:{scale:.95},transition:{duration:.15,ease:"easeOut"},className:"h-9 w-9 rounded-full bg-slate-900/85 text-white shadow-lg ring-1 ring-white/20 backdrop-blur-sm flex items-center justify-center","aria-label":"Restore AI tutor launcher",title:"Show AI tutor",style:{willChange:"transform"},children:e.jsx(A,{size:14})}):e.jsxs("div",{className:"relative group",children:[!s&&e.jsxs("div",{className:"absolute right-full mr-4 top-1/2 -translate-y-1/2 px-4 py-2 bg-slate-800 text-white text-sm rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap shadow-xl z-50",children:["Hello! I'm L.O.L.I., how may I help you?",e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-3 h-3 bg-slate-800 rotate-45"})]}),!s&&e.jsx("button",{type:"button","aria-label":"Minimize AI tutor launcher",title:"Minimize",onClick:f,className:"absolute -top-2 -left-2 z-10 h-6 w-6 rounded-full bg-white text-slate-700 border border-slate-200 shadow-md hover:bg-slate-100 transition-colors flex items-center justify-center",children:e.jsx(w,{size:12})}),e.jsx(b.button,{type:"button",onClick:()=>l(!s),whileHover:{scale:1.1},whileTap:{scale:.9},transition:{duration:.15,ease:"easeOut"},className:"w-16 h-16 bg-gradient-to-br from-sky-600 to-sky-500 rounded-xl shadow-2xl flex items-center justify-center text-white hover:shadow-sky-300/50 transition-all","aria-label":s?"Close AI tutor chat":"Open AI tutor chat",style:{willChange:"transform"},children:s?e.jsx(g,{size:28}):e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-14 h-14 object-contain drop-shadow-lg"})})]})})]})};export{Q as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatMarkdown-fgwaycBR.js","assets/index-BaOs5Ayg.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-DdX2rVyy.css"])))=>i.map(i=>d[i]); +import{ay as C,_ as y,m as b,w as A}from"./index-BaOs5Ayg.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-EHa6JURc.js";import{M as w}from"./minus-DfrEv-SC.js";import{X as g}from"./x-TNvtuOD9.js";import{S as L}from"./send-CwwDU3uJ.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-fgwaycBR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])));function O(a){return a?a instanceof Date?a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof a=="object"&&"toDate"in a?a.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(a):""}const Q=({constraintsRef:a,onFullScreen:j})=>{const{activeSessionId:r,setActiveSessionId:v,createNewSession:N,getActiveSession:k,sendMessage:I,isLoading:o}=C(),[s,l]=i.useState(!1),[c,u]=i.useState(()=>typeof window>"u"?!1:window.localStorage.getItem("floating_ai_tutor_minimized")==="1"),[n,m]=i.useState(""),h=i.useRef(null);i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("floating_ai_tutor_minimized",c?"1":"0")},[c]),i.useEffect(()=>{s&&y(async()=>{const{warmupBackend:t}=await import("./index-BaOs5Ayg.js").then(d=>d.b2);return{warmupBackend:t}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10,11,12])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("Floating tutor warmup skipped:",t)})},[s]),i.useEffect(()=>{if(s&&!r){const t={id:"1",sender:"ai",text:"Hi! I'm your AI math tutor. What would you like to learn about today?",timestamp:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},d=N(t);v(d)}},[s]);const x=k()?.messages||[],S=()=>{h.current?.scrollIntoView({behavior:"smooth"})};i.useEffect(()=>{S()},[x]);const p=async()=>{if(!n.trim()||!r||o)return;const t=n.trim();m(""),await I(r,t)},_=()=>{j()},f=()=>{l(!1),u(!0)},z=()=>{u(!1)};return e.jsxs("div",{className:"pointer-events-none flex flex-col items-end",children:[e.jsxs("div",{className:`pointer-events-auto mb-4 w-80 bg-[#f7f9fc] rounded-3xl shadow-2xl border border-[#dde3eb] flex flex-col overflow-hidden transition-all duration-300 origin-bottom-right select-none ${s?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-10 pointer-events-none h-0"}`,style:{"--max-h":s?"32rem":"0",willChange:"transform, opacity"},children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center backdrop-blur-sm",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-9 h-9 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-sm",children:"L.O.L.I."}),e.jsxs("p",{className:"text-sky-100 text-[10px] leading-tight",children:["Logical Operations &",e.jsx("br",{}),"Learning Intelligence"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:_,type:"button","aria-label":"Open fullscreen",className:"p-2 hover:bg-white/20 rounded-lg transition-colors",title:"Open fullscreen",children:e.jsx(M,{size:16,className:"text-white"})}),e.jsx("button",{type:"button","aria-label":"Minimize AI tutor launcher",onClick:f,className:"p-2 hover:bg-white/20 rounded-lg transition-colors",title:"Minimize",children:e.jsx(w,{size:16,className:"text-white"})}),e.jsx("button",{type:"button","aria-label":"Close chat",onClick:()=>l(!1),className:"p-2 hover:bg-white/20 rounded-lg transition-colors",children:e.jsx(g,{size:16,className:"text-white"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 bg-[#edf1f7]",children:[x.map(t=>e.jsx("div",{className:`flex ${t.sender==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[75%] rounded-2xl px-4 py-2.5 ${t.sender==="user"?"bg-sky-600 text-white":"bg-white text-[#0a1628] shadow-sm border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.text}):e.jsx(i.Suspense,{fallback:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.text}),children:e.jsx(E,{children:t.text})}),e.jsx("p",{className:`text-[10px] mt-1 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:O(t.timestamp)})]})},t.id)),o&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white text-[#0a1628] shadow-sm border border-[#dde3eb] rounded-2xl px-4 py-2.5 max-w-[75%]",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})}),e.jsx("div",{ref:h})]}),e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-tutor-input",name:"ai-tutor-input","aria-label":"Ask AI tutor a question",type:"text",value:n,onChange:t=>m(t.target.value),onKeyPress:t=>t.key==="Enter"&&p(),placeholder:"Ask me anything...",className:"flex-1 px-4 py-2.5 rounded-xl border border-[#dde3eb] focus:outline-none focus:ring-2 focus:ring-sky-500 text-sm bg-[#f7f9fc]"}),e.jsx("button",{type:"button","aria-label":"Send message",onClick:p,className:"p-2.5 bg-sky-600 hover:bg-sky-700 text-white rounded-xl transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:!n.trim()||o,children:e.jsx(L,{size:18})})]})})]}),e.jsx("div",{className:"pointer-events-auto relative self-end",children:c?e.jsx(b.button,{type:"button",onClick:z,whileHover:{scale:1.08},whileTap:{scale:.95},transition:{duration:.15,ease:"easeOut"},className:"h-9 w-9 rounded-full bg-slate-900/85 text-white shadow-lg ring-1 ring-white/20 backdrop-blur-sm flex items-center justify-center","aria-label":"Restore AI tutor launcher",title:"Show AI tutor",style:{willChange:"transform"},children:e.jsx(A,{size:14})}):e.jsxs("div",{className:"relative group",children:[!s&&e.jsxs("div",{className:"absolute right-full mr-4 top-1/2 -translate-y-1/2 px-4 py-2 bg-slate-800 text-white text-sm rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap shadow-xl z-50",children:["Hello! I'm L.O.L.I., how may I help you?",e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-3 h-3 bg-slate-800 rotate-45"})]}),!s&&e.jsx("button",{type:"button","aria-label":"Minimize AI tutor launcher",title:"Minimize",onClick:f,className:"absolute -top-2 -left-2 z-10 h-6 w-6 rounded-full bg-white text-slate-700 border border-slate-200 shadow-md hover:bg-slate-100 transition-colors flex items-center justify-center",children:e.jsx(w,{size:12})}),e.jsx(b.button,{type:"button",onClick:()=>l(!s),whileHover:{scale:1.1},whileTap:{scale:.9},transition:{duration:.15,ease:"easeOut"},className:"w-16 h-16 bg-gradient-to-br from-sky-600 to-sky-500 rounded-xl shadow-2xl flex items-center justify-center text-white hover:shadow-sky-300/50 transition-all","aria-label":s?"Close AI tutor chat":"Open AI tutor chat",style:{willChange:"transform"},children:s?e.jsx(g,{size:28}):e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-14 h-14 object-contain drop-shadow-lg"})})]})})]})};export{Q as default}; diff --git a/assets/GradesPage-CmSMzBLK.js b/assets/GradesPage-Y0HsmLPP.js similarity index 97% rename from assets/GradesPage-CmSMzBLK.js rename to assets/GradesPage-Y0HsmLPP.js index 58c93449763bf47553029ca1d892d328394c51b7..bf953ceb69a27230744bd73e7ab8612d5069c1a7 100644 --- a/assets/GradesPage-CmSMzBLK.js +++ b/assets/GradesPage-Y0HsmLPP.js @@ -1,2 +1,2 @@ -import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as v}from"./button-De2q2xHf.js";import{u as J,az as K,aA as W,z as X,A as Z,y as z,T as R}from"./index-Cb8VeSuW.js";import{g as q,S as E}from"./subjects-Bnu0lJdU.js";import{u as ee}from"./useCurriculum-B8pRV6G_.js";import{D as te}from"./download-C-V0pYsk.js";import{F as P}from"./funnel-D-s_ygM_.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-CmH46HAG.js";const ge=()=>{const{currentUser:i,userProfile:w}=J(),[n,N]=o.useState("all"),[x,D]=o.useState("all"),[M,u]=o.useState(!0),[h,L]=o.useState(null),[F,G]=o.useState([]),y=w?.grade,S=q(y),_=new Set(S),{isLoading:Q}=ee(y);o.useEffect(()=>{},[Q]);const O=t=>{if(t==null)return"N/A";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"N/A":s.toISOString().split("T")[0]};o.useEffect(()=>{if(!i)return;u(!0);const t=K(i.uid,a=>{L(a),u(!1)}),s=W(i.uid,a=>{G(a),u(!1)});return()=>{t(),s()}},[i]);const b=h?.averageScore?Math.round(h.averageScore):0,U=h?.quizzesCompleted??0,B=b>0?(b/100*4).toFixed(2):"0.00",I={"gen-math":"indigo","stats-prob":"violet"},k={indigo:{dot:"bg-indigo-500",bar:"bg-indigo-500"},violet:{dot:"bg-violet-500",bar:"bg-violet-500"},fuchsia:{dot:"bg-fuchsia-500",bar:"bg-fuchsia-500"},purple:{dot:"bg-purple-500",bar:"bg-purple-500"},slate:{dot:"bg-slate-500",bar:"bg-slate-500"}},A=E.reduce((t,s)=>(t[s.id]={label:s.name,color:I[s.id]||"slate"},t),{}),c=E.filter(t=>_.has(t.id)).map(t=>t.name),T=Object.entries({}).filter(([t])=>_.has(t)).map(([t,s])=>{const a=A[t]||{label:t,color:"slate"},r=[],f=r.length>0?Math.round(r.reduce((g,p)=>g+p.score,0)/r.length):Math.round(s?.progress??0);return{subject:a.label,average:f,quizzes:r.length||s?.completedModules,color:a.color}}),H=S.map(t=>{const s=A[t]||{label:t,color:"slate"};return{subject:s.label,average:0,quizzes:0,color:s.color}}),C=T.length>0?T:H,$=F.slice().sort((t,s)=>{const a=t.completedAt?.toDate?.()?.getTime()??0;return(s.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((t,s)=>({id:s+1,title:t.title||`Assessment ${s+1}`,subject:t.subject||"General",score:t.score,date:t.completedAt?O(t.completedAt.toDate()):"N/A",type:t.type==="practice"?"practice":(t.type==="diagnostic","module"),status:t.score>=80?"Excellent":t.score>=60?"Passing":"Needs Review"})).filter(t=>c.includes(t.subject)),m=$.filter(t=>{if(!c.includes(t.subject))return!1;const s=n==="all"||t.subject===n,a=x==="all"||t.type===x;return s&&a});o.useEffect(()=>{n!=="all"&&(c.includes(n)||N("all"))},[c,n]);const V=()=>{const t=l=>{const j=String(l??"");return/[",\n]/.test(j)?`"${j.replace(/"/g,'""')}"`:j},s=[],a=w?.name||i?.displayName||i?.email||"Student",r=new Date().toISOString().split("T")[0];s.push("Grade Report"),s.push(`Student,${t(a)}`),s.push(`Export Date,${t(r)}`),s.push(`Subject Filter,${t(n)}`),s.push(`Type Filter,${t(x)}`),s.push(""),s.push("Subject Performance"),s.push("Subject,Average Score"),C.forEach(l=>{s.push([t(l.subject),t(l.average)].join(","))}),s.push(""),s.push("Recent Quizzes"),s.push("Title,Subject,Score,Date,Type,Status"),m.length===0?s.push("No quiz data available for the selected filters"):m.forEach(l=>{s.push([t(l.title),t(l.subject),t(l.score),t(l.date),t(l.type),t(l.status)].join(","))});const f=s.join(` +import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as v}from"./button-DCfeFHoH.js";import{u as J,az as K,aA as W,z as X,A as Z,y as z,T as R}from"./index-BaOs5Ayg.js";import{g as q,S as E}from"./subjects-BFghB0SQ.js";import{u as ee}from"./useCurriculum-DDCuCvMR.js";import{D as te}from"./download-DX_YebqQ.js";import{F as P}from"./funnel-BT77sgnz.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B3jJOD5i.js";const ge=()=>{const{currentUser:i,userProfile:w}=J(),[n,N]=o.useState("all"),[x,D]=o.useState("all"),[M,u]=o.useState(!0),[h,L]=o.useState(null),[F,G]=o.useState([]),y=w?.grade,S=q(y),_=new Set(S),{isLoading:Q}=ee(y);o.useEffect(()=>{},[Q]);const O=t=>{if(t==null)return"N/A";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"N/A":s.toISOString().split("T")[0]};o.useEffect(()=>{if(!i)return;u(!0);const t=K(i.uid,a=>{L(a),u(!1)}),s=W(i.uid,a=>{G(a),u(!1)});return()=>{t(),s()}},[i]);const b=h?.averageScore?Math.round(h.averageScore):0,U=h?.quizzesCompleted??0,B=b>0?(b/100*4).toFixed(2):"0.00",I={"gen-math":"indigo","stats-prob":"violet"},k={indigo:{dot:"bg-indigo-500",bar:"bg-indigo-500"},violet:{dot:"bg-violet-500",bar:"bg-violet-500"},fuchsia:{dot:"bg-fuchsia-500",bar:"bg-fuchsia-500"},purple:{dot:"bg-purple-500",bar:"bg-purple-500"},slate:{dot:"bg-slate-500",bar:"bg-slate-500"}},A=E.reduce((t,s)=>(t[s.id]={label:s.name,color:I[s.id]||"slate"},t),{}),c=E.filter(t=>_.has(t.id)).map(t=>t.name),T=Object.entries({}).filter(([t])=>_.has(t)).map(([t,s])=>{const a=A[t]||{label:t,color:"slate"},r=[],f=r.length>0?Math.round(r.reduce((g,p)=>g+p.score,0)/r.length):Math.round(s?.progress??0);return{subject:a.label,average:f,quizzes:r.length||s?.completedModules,color:a.color}}),H=S.map(t=>{const s=A[t]||{label:t,color:"slate"};return{subject:s.label,average:0,quizzes:0,color:s.color}}),C=T.length>0?T:H,$=F.slice().sort((t,s)=>{const a=t.completedAt?.toDate?.()?.getTime()??0;return(s.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((t,s)=>({id:s+1,title:t.title||`Assessment ${s+1}`,subject:t.subject||"General",score:t.score,date:t.completedAt?O(t.completedAt.toDate()):"N/A",type:t.type==="practice"?"practice":(t.type==="diagnostic","module"),status:t.score>=80?"Excellent":t.score>=60?"Passing":"Needs Review"})).filter(t=>c.includes(t.subject)),m=$.filter(t=>{if(!c.includes(t.subject))return!1;const s=n==="all"||t.subject===n,a=x==="all"||t.type===x;return s&&a});o.useEffect(()=>{n!=="all"&&(c.includes(n)||N("all"))},[c,n]);const V=()=>{const t=l=>{const j=String(l??"");return/[",\n]/.test(j)?`"${j.replace(/"/g,'""')}"`:j},s=[],a=w?.name||i?.displayName||i?.email||"Student",r=new Date().toISOString().split("T")[0];s.push("Grade Report"),s.push(`Student,${t(a)}`),s.push(`Export Date,${t(r)}`),s.push(`Subject Filter,${t(n)}`),s.push(`Type Filter,${t(x)}`),s.push(""),s.push("Subject Performance"),s.push("Subject,Average Score"),C.forEach(l=>{s.push([t(l.subject),t(l.average)].join(","))}),s.push(""),s.push("Recent Quizzes"),s.push("Title,Subject,Score,Date,Type,Status"),m.length===0?s.push("No quiz data available for the selected filters"):m.forEach(l=>{s.push([t(l.title),t(l.subject),t(l.score),t(l.date),t(l.type),t(l.status)].join(","))});const f=s.join(` `),g=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=window.URL.createObjectURL(g),d=document.createElement("a"),Y=a.replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()||"student";d.href=p,d.setAttribute("download",`grade-report-${Y}-${r}.csv`),document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(p)};return M?e.jsx("div",{className:"p-8 flex justify-center items-center h-full",children:e.jsx("div",{className:"w-10 h-10 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 space-y-8 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 bg-white p-6 rounded-[2rem] shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] border border-slate-50",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black text-slate-800 tracking-tight",children:"Assessment"}),e.jsx("p",{className:"text-slate-400 font-bold mt-1 text-[13px]",children:"Review your performance across subjects"})]}),e.jsxs("div",{className:"flex gap-3 w-full sm:w-auto",children:[e.jsxs(v,{variant:"outline",className:"flex-1 sm:flex-none border-slate-200 text-slate-500 font-bold rounded-xl h-11 px-5 hover:bg-slate-50 hover:text-slate-700",children:[e.jsx(X,{className:"w-4 h-4 mr-2 text-slate-400"}),"This Semester"]}),e.jsxs(v,{className:"flex-1 sm:flex-none bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl h-11 px-5 shadow-[0_8px_20px_-8px_rgba(79,70,229,0.5)] hover:-translate-y-0.5 transition-all",onClick:V,children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Report"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-indigo-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-indigo-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(Z,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Overall GPA"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:B})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-emerald-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-emerald-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-emerald-100 text-emerald-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(z,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Average Score"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsxs("h3",{className:"text-4xl font-display font-black text-slate-800",children:[b,"%"]})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-violet-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-violet-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-violet-100 text-violet-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(R,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Quizzes Completed"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:U})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 sm:p-8 border-b border-slate-50 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-black text-xl text-slate-800",children:"Recent Assessments"}),e.jsx("p",{className:"text-slate-400 font-bold text-[13px] mt-1",children:"Your latest quiz and practice results"})]}),e.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:n,onChange:t=>N(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[140px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Subjects"}),c.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:x,onChange:t=>D(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[120px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"module",children:"Module Quiz"}),e.jsx("option",{value:"practice",children:"Practice"})]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]})]}),e.jsx("div",{className:"overflow-x-auto flex-1 p-2",children:e.jsxs("table",{className:"w-full text-left border-separate border-spacing-y-2 px-4 sm:px-6 mb-4",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Assessment"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent min-w-[120px]",children:"Subject"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Type"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right border-b border-transparent",children:"Score"})]})}),e.jsx("tbody",{children:m.length>0?m.map(t=>e.jsxs("tr",{className:"group hover:bg-slate-50/70 transition-colors",children:[e.jsxs("td",{className:"px-4 py-4 rounded-l-2xl",children:[e.jsx("p",{className:"text-[14px] font-bold text-slate-800",children:t.title}),e.jsx("p",{className:"text-[11px] font-bold text-slate-400 mt-1",children:t.date})]}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:"inline-flex flex-col gap-1 items-start",children:e.jsx("span",{className:"text-[13px] font-bold text-slate-600 truncate max-w-[140px] block",children:t.subject})})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`inline-flex items-center px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wide ${t.type==="practice"?"bg-emerald-100/50 text-emerald-600":"bg-indigo-100/50 text-indigo-600"}`,children:t.type==="practice"?"Practice":"Quiz"})}),e.jsx("td",{className:"px-4 py-4 text-right rounded-r-2xl",children:e.jsxs("span",{className:`inline-flex items-center px-3 py-1.5 rounded-xl text-[13px] font-black ${t.score>=80?"bg-emerald-100 text-emerald-700":t.score>=60?"bg-amber-100 text-amber-700":"bg-rose-100 text-rose-700"}`,children:[t.score,"%"]})})]},t.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mb-4",children:e.jsx(z,{className:"w-8 h-8 text-slate-300"})}),e.jsx("p",{className:"text-slate-500 font-bold text-sm",children:"No recent assessments match the selected filters."})]})})})})]})})]})}),e.jsxs("div",{className:"space-y-6 lg:space-y-8 flex flex-col",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)]",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsx("h3",{className:"font-display font-black text-lg text-slate-800",children:"Subject Performance"})}),e.jsx("div",{className:"space-y-7",children:C.map((t,s)=>{const a=k[t.color]||k.slate;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex justify-between items-end mb-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[14px] font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.dot} group-hover:scale-125 transition-transform`}),t.subject]}),e.jsxs("p",{className:"text-[11px] text-slate-400 font-bold ml-4 mt-0.5",children:[t.quizzes," activities"]})]}),e.jsxs("span",{className:"text-[15px] font-black text-slate-800",children:[t.average,"%"]})]}),e.jsx("div",{className:"h-2.5 w-full bg-slate-100 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full e-w ${a.bar} shadow-sm relative overflow-hidden transition-all duration-1000`,style:{"--w":`${Math.max(t.average,5)}%`},children:e.jsx("div",{className:"absolute inset-0 bg-white/20 w-1/2 -skew-x-12 translate-x-[-100%] group-hover:animate-[shimmer_1.5s_ease-out]"})})})]},s)})})]}),e.jsxs("div",{className:"relative bg-gradient-to-br from-indigo-600 to-violet-700 rounded-[2rem] p-6 sm:p-8 shadow-[0_12px_30px_-10px_rgba(79,70,229,0.5)] text-white overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-white/10 rounded-full blur-3xl -mt-10 -mr-10 group-hover:bg-white/20 transition-all duration-700 ease-in-out"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-32 h-32 bg-indigo-400/30 rounded-full blur-2xl -mb-10 -ml-10"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-12 h-12 bg-white/10 rounded-2xl flex items-center justify-center mb-5 backdrop-blur-sm border border-white/20 shadow-sm group-hover:scale-110 transition-transform",children:e.jsx(R,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-2xl font-display font-black tracking-tight mb-2 leading-tight",children:"Keep up the momentum!"}),e.jsxs("p",{className:"text-white/80 text-[13px] font-medium leading-relaxed mb-8 max-w-[90%]",children:["You've completed ",e.jsx("span",{className:"font-black text-white",children:$.length})," activities recently. Try a practice session to boost your lowest scores."]}),e.jsx(v,{className:"w-full bg-white text-indigo-600 hover:bg-slate-50 border-0 font-black h-12 rounded-xl shadow-[0_8px_16px_rgba(0,0,0,0.15)] hover:shadow-[0_8px_24px_rgba(0,0,0,0.2)] hover:-translate-y-0.5 transition-all",children:"Start Practice Session"})]})]})]})]})]})};export{ge as default}; diff --git a/assets/HeroBanner-LXU_ph73.js b/assets/HeroBanner-CKiXGluA.js similarity index 98% rename from assets/HeroBanner-LXU_ph73.js rename to assets/HeroBanner-CKiXGluA.js index 9ecd86ccfa6f8cb71f1085e5c296a39af272f4a6..6db03c737326a0ae9b030683451288d4d5ccfca1 100644 --- a/assets/HeroBanner-LXU_ph73.js +++ b/assets/HeroBanner-CKiXGluA.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardAvatar-CbAKGmA6.js","assets/vendor-react-B4AQeu28.js","assets/avatarData-BuQSOXo3.js"])))=>i.map(i=>d[i]); -import{e as y,T as v,f as w,Q as k,j as M,m as p,A as P,B as u,y as A,Z as T,b as _,_ as E}from"./index-Cb8VeSuW.js";import{j as e,r as o}from"./vendor-react-B4AQeu28.js";import{D as V,a as Q}from"./dialog-CCp2tnRr.js";import{R as $,L as G,C as q,X as Y,Y as W,T as X,b as F}from"./vendor-charts-D8hf8tI0.js";import{collection as S,query as C,limit as L,orderBy as R,getDocs as D}from"./vendor-firebase-firestore-CH1lNiRF.js";import{X as K}from"./x-CTLBAl-n.js";import{C as z}from"./circle-alert-DgDGv7k5.js";import{C as U}from"./circle-check-CVJuYLp6.js";import{S as Z}from"./sparkles-v8V3LFaV.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{e as y,T as v,f as w,Q as k,j as M,m as p,A as P,B as u,y as A,Z as T,b as _,_ as E}from"./index-BaOs5Ayg.js";import{j as e,r as o}from"./vendor-react-B4AQeu28.js";import{D as V,a as Q}from"./dialog-CHtYkwVl.js";import{R as $,L as G,C as q,X as Y,Y as W,T as X,b as F}from"./vendor-charts-D8hf8tI0.js";import{collection as S,query as C,limit as L,orderBy as R,getDocs as D}from"./vendor-firebase-firestore-CH1lNiRF.js";import{X as K}from"./x-TNvtuOD9.js";import{C as z}from"./circle-alert-CP9K3300.js";import{C as U}from"./circle-check-C0FPGTrp.js";import{S as Z}from"./sparkles-By-vFjpv.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/InitialAssessmentModal-8dYkJoWr.js b/assets/InitialAssessmentModal-CknVaqMx.js similarity index 94% rename from assets/InitialAssessmentModal-8dYkJoWr.js rename to assets/InitialAssessmentModal-CknVaqMx.js index aaf5a49d141dc6106f11455603fcffedbd0b5b4d..8ea2b6e5a6229ab48d6f8ded67a543fe4513c01e 100644 --- a/assets/InitialAssessmentModal-8dYkJoWr.js +++ b/assets/InitialAssessmentModal-CknVaqMx.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{B as j}from"./button-De2q2xHf.js";import{g as y}from"./diagnosticService-BIetid_s.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CH1lNiRF.js";import{m as o,B as k,p as C,l as L,f as z}from"./index-Cb8VeSuW.js";import{X as S}from"./x-CTLBAl-n.js";import{C as A}from"./circle-check-big-CNGbqkWz.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const H=({isOpen:n,onClose:d,onDismiss:m,userId:c,strand:x,gradeLevel:p,onAssessmentStart:u,onAssessmentComplete:I})=>{const[t,a]=l.useState(!1),[r,i]=l.useState(null),h=async()=>{a(!0),i(null);try{const s=await y(x,p);sessionStorage.setItem("mathpulse_diagnostic",JSON.stringify({testId:s.test_id,questions:s.questions,totalItems:s.total_items,estimatedMinutes:s.estimated_minutes})),u(s.test_id,s.questions)}catch(s){const b=s instanceof Error?s.message:"Failed to load assessment";i(b),a(!1)}},f=()=>{sessionStorage.setItem("mathpulse_iar_session_dismissed","true"),d()},g=async()=>{try{await N(v(z,"users",c),{assessmentDismissed:!0,assessmentDismissedAt:w()})}catch(s){console.error("[diagnostic] Failed to save dismiss state:",s)}m()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.stopPropagation(),children:e.jsxs(o.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"bg-white rounded-2xl shadow-2xl max-w-[36rem] w-full flex flex-col overflow-hidden pointer-events-auto",onClick:s=>s.stopPropagation(),style:{willChange:"transform, opacity"},children:[e.jsxs("div",{className:"px-5 py-3 border-b border-[#dde3eb] flex items-center justify-between bg-[#edf1f7] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center text-purple-600",children:e.jsx(k,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-[#0a1628] leading-tight",children:"Initial Assessment"}),e.jsx("p",{className:"text-[11px] text-[#5a6578]",children:"Analyze your strengths & weaknesses"})]})]}),e.jsx("button",{onClick:f,"aria-label":"Close assessment modal",className:"ml-auto w-8 h-8 rounded-lg flex items-center justify-center text-[#5a6578] hover:bg-[#dde3eb] hover:text-[#0a1628] transition-colors",children:e.jsx(S,{size:18})})]}),e.jsx("div",{className:"p-5 text-center space-y-3",children:e.jsxs(o.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3,ease:"easeOut"},children:[e.jsx("div",{className:"w-20 h-20 bg-purple-50 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx("svg",{className:"w-9 h-9 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})})}),e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Welcome to MathPulse AI!"}),e.jsx("p",{className:"text-[13px] text-[#5a6578] max-w-[19rem] mx-auto leading-relaxed",children:"To personalize your learning path, complete a DepEd competency-based SHS diagnostic (15 items, around 11.6 minutes)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 max-w-[22rem] mx-auto text-left mt-4",children:[e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(A,{size:14,className:"text-teal-500"}),"Personalized Path"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Get recommendations based on your level."})]}),e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(C,{size:14,className:"text-rose-500"}),"Identify Risks"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Spot areas that need more attention early."})]})]}),r&&e.jsx("div",{className:"mt-3 p-2.5 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-xs text-red-700",children:r})}),e.jsxs("div",{className:"pt-3 space-y-2.5",children:[e.jsx(j,{onClick:h,disabled:t,className:"bg-gradient-to-r from-purple-600 to-purple-500 hover:from-purple-700 hover:to-purple-600 text-white px-5 py-3 rounded-xl text-sm font-bold shadow-lg shadow-purple-200 w-full max-w-[320px] mx-auto",children:t?e.jsxs(e.Fragment,{children:[e.jsx(L,{size:16,className:"animate-spin mr-2"}),"Crafting your assessment..."]}):"Start Assessment"}),t&&e.jsx("p",{className:"text-[10px] text-slate-400 max-w-[18rem] mx-auto text-center leading-relaxed",children:"This may take up to 90 seconds while AI generates your personalized test."}),!t&&e.jsx("button",{onClick:g,disabled:t,className:"block mx-auto text-xs text-slate-500 hover:text-[#5a6578] transition-colors font-medium disabled:opacity-40",children:"Skip for now"})]})]})})]})}):null};export{H as default}; +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{B as j}from"./button-DCfeFHoH.js";import{g as y}from"./diagnosticService-BDYTUoqk.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CH1lNiRF.js";import{m as o,B as k,p as C,l as L,f as z}from"./index-BaOs5Ayg.js";import{X as S}from"./x-TNvtuOD9.js";import{C as A}from"./circle-check-big-m1SvzGFL.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const H=({isOpen:n,onClose:d,onDismiss:m,userId:c,strand:x,gradeLevel:p,onAssessmentStart:u,onAssessmentComplete:I})=>{const[t,a]=l.useState(!1),[r,i]=l.useState(null),h=async()=>{a(!0),i(null);try{const s=await y(x,p);sessionStorage.setItem("mathpulse_diagnostic",JSON.stringify({testId:s.test_id,questions:s.questions,totalItems:s.total_items,estimatedMinutes:s.estimated_minutes})),u(s.test_id,s.questions)}catch(s){const b=s instanceof Error?s.message:"Failed to load assessment";i(b),a(!1)}},f=()=>{sessionStorage.setItem("mathpulse_iar_session_dismissed","true"),d()},g=async()=>{try{await N(v(z,"users",c),{assessmentDismissed:!0,assessmentDismissedAt:w()})}catch(s){console.error("[diagnostic] Failed to save dismiss state:",s)}m()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.stopPropagation(),children:e.jsxs(o.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"bg-white rounded-2xl shadow-2xl max-w-[36rem] w-full flex flex-col overflow-hidden pointer-events-auto",onClick:s=>s.stopPropagation(),style:{willChange:"transform, opacity"},children:[e.jsxs("div",{className:"px-5 py-3 border-b border-[#dde3eb] flex items-center justify-between bg-[#edf1f7] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center text-purple-600",children:e.jsx(k,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-[#0a1628] leading-tight",children:"Initial Assessment"}),e.jsx("p",{className:"text-[11px] text-[#5a6578]",children:"Analyze your strengths & weaknesses"})]})]}),e.jsx("button",{onClick:f,"aria-label":"Close assessment modal",className:"ml-auto w-8 h-8 rounded-lg flex items-center justify-center text-[#5a6578] hover:bg-[#dde3eb] hover:text-[#0a1628] transition-colors",children:e.jsx(S,{size:18})})]}),e.jsx("div",{className:"p-5 text-center space-y-3",children:e.jsxs(o.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3,ease:"easeOut"},children:[e.jsx("div",{className:"w-20 h-20 bg-purple-50 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx("svg",{className:"w-9 h-9 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})})}),e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Welcome to MathPulse AI!"}),e.jsx("p",{className:"text-[13px] text-[#5a6578] max-w-[19rem] mx-auto leading-relaxed",children:"To personalize your learning path, complete a DepEd competency-based SHS diagnostic (15 items, around 11.6 minutes)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 max-w-[22rem] mx-auto text-left mt-4",children:[e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(A,{size:14,className:"text-teal-500"}),"Personalized Path"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Get recommendations based on your level."})]}),e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(C,{size:14,className:"text-rose-500"}),"Identify Risks"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Spot areas that need more attention early."})]})]}),r&&e.jsx("div",{className:"mt-3 p-2.5 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-xs text-red-700",children:r})}),e.jsxs("div",{className:"pt-3 space-y-2.5",children:[e.jsx(j,{onClick:h,disabled:t,className:"bg-gradient-to-r from-purple-600 to-purple-500 hover:from-purple-700 hover:to-purple-600 text-white px-5 py-3 rounded-xl text-sm font-bold shadow-lg shadow-purple-200 w-full max-w-[320px] mx-auto",children:t?e.jsxs(e.Fragment,{children:[e.jsx(L,{size:16,className:"animate-spin mr-2"}),"Crafting your assessment..."]}):"Start Assessment"}),t&&e.jsx("p",{className:"text-[10px] text-slate-400 max-w-[18rem] mx-auto text-center leading-relaxed",children:"This may take up to 90 seconds while AI generates your personalized test."}),!t&&e.jsx("button",{onClick:g,disabled:t,className:"block mx-auto text-xs text-slate-500 hover:text-[#5a6578] transition-colors font-medium disabled:opacity-40",children:"Skip for now"})]})]})})]})}):null};export{H as default}; diff --git a/assets/LeaderboardPage-D1oaPEZD.js b/assets/LeaderboardPage-D9eaC9ey.js similarity index 99% rename from assets/LeaderboardPage-D1oaPEZD.js rename to assets/LeaderboardPage-D9eaC9ey.js index bc2c0c6633440601b27fc4eeb72208c9960e2e2d..b206d6f79e76945931f40c7fb831093987f92676 100644 --- a/assets/LeaderboardPage-D1oaPEZD.js +++ b/assets/LeaderboardPage-D9eaC9ey.js @@ -1,4 +1,4 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{e as Y,aC as W,j as H,m as c,a as y,y as P,A as k,x as m,T as E,l as z,W as X,X as U,O as q,u as $,aD as G,R as K,L as Q,r as T}from"./index-Cb8VeSuW.js";import{X as V}from"./x-CTLBAl-n.js";import{C as Z}from"./clock-BodmJJnp.js";import{u as J}from"./useFeatureAccess-RwJxbRkp.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{e as Y,aC as W,j as H,m as c,a as y,y as P,A as k,x as m,T as E,l as z,W as X,X as U,O as q,u as $,aD as G,R as K,L as Q,r as T}from"./index-BaOs5Ayg.js";import{X as V}from"./x-TNvtuOD9.js";import{C as Z}from"./clock-D1Ecvltm.js";import{u as J}from"./useFeatureAccess-BSpfx3vY.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/LearningPath-D68qmUJi.js b/assets/LearningPath-BBE0vZ0S.js similarity index 89% rename from assets/LearningPath-D68qmUJi.js rename to assets/LearningPath-BBE0vZ0S.js index 8f566197d8fb7676df775ccd5180c2278e17ae9f..6e98d8c8a29d14a371f7c4cfbe2a8b21369deed4 100644 --- a/assets/LearningPath-D68qmUJi.js +++ b/assets/LearningPath-BBE0vZ0S.js @@ -1 +1 @@ -import{r as m,d as p,j as r}from"./vendor-react-B4AQeu28.js";import{u as j,a2 as P,a3 as I,q as N,a as k,b as L}from"./index-Cb8VeSuW.js";import{M as S}from"./ModuleFolderCard-CITAgDA0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-d2Fw9DS6.js";import"./clock-BodmJJnp.js";const V=({onNavigateToModules:c,atRiskSubjects:d=[],priorityTopics:o=[],modules:a})=>{const{userProfile:l}=j(),[u,h]=m.useState(null),i=p.useMemo(()=>{const e=o.length>0?o:d.map(s=>P(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,d]),x=p.useMemo(()=>{if(i.length===0)return a.slice(0,3);const e=new Map(i.map((t,s)=>[I[t],s]));return[...a].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,b=e.get(s.id)??Number.POSITIVE_INFINITY;return n-b}).slice(0,3)},[a,i]);m.useEffect(()=>{l?.uid&&N(l.uid).then(h).catch(console.error)},[l?.uid]);const g=x.slice(0,3).map(e=>{const t=u?.subjects?.[e.subject]?.modulesProgress?.[e.id],s=e.lessons.length,n=t?.progress??(s>0?Math.round((t?.lessonsCompleted?.length||0)/s*100):0);return{...e,progress:n,status:n===100?"Completed":n>0?"In Progress":"Not Started"}}),f=g.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(k,{size:20,strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:f})]}),r.jsxs("button",{onClick:()=>c?.(),className:"text-primary font-bold text-sm flex items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-4 py-2 rounded-xl hover:bg-primary/20",children:["View All ",r.jsx(L,{size:16})]})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:g.map((e,t)=>r.jsx(S,{module:e,index:t,onClick:()=>c?.(e.id),isAtRisk:i.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0},e.id))})]})};export{V as default}; +import{r as m,d as p,j as r}from"./vendor-react-B4AQeu28.js";import{u as j,a2 as P,a3 as I,q as N,a as k,b as L}from"./index-BaOs5Ayg.js";import{M as S}from"./ModuleFolderCard-DKBrO5a8.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-Bvu3fXaT.js";import"./clock-D1Ecvltm.js";const V=({onNavigateToModules:c,atRiskSubjects:d=[],priorityTopics:o=[],modules:a})=>{const{userProfile:l}=j(),[u,h]=m.useState(null),i=p.useMemo(()=>{const e=o.length>0?o:d.map(s=>P(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,d]),x=p.useMemo(()=>{if(i.length===0)return a.slice(0,3);const e=new Map(i.map((t,s)=>[I[t],s]));return[...a].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,b=e.get(s.id)??Number.POSITIVE_INFINITY;return n-b}).slice(0,3)},[a,i]);m.useEffect(()=>{l?.uid&&N(l.uid).then(h).catch(console.error)},[l?.uid]);const g=x.slice(0,3).map(e=>{const t=u?.subjects?.[e.subject]?.modulesProgress?.[e.id],s=e.lessons.length,n=t?.progress??(s>0?Math.round((t?.lessonsCompleted?.length||0)/s*100):0);return{...e,progress:n,status:n===100?"Completed":n>0?"In Progress":"Not Started"}}),f=g.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(k,{size:20,strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:f})]}),r.jsxs("button",{onClick:()=>c?.(),className:"text-primary font-bold text-sm flex items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-4 py-2 rounded-xl hover:bg-primary/20",children:["View All ",r.jsx(L,{size:16})]})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:g.map((e,t)=>r.jsx(S,{module:e,index:t,onClick:()=>c?.(e.id),isAtRisk:i.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0},e.id))})]})};export{V as default}; diff --git a/assets/LoginPage-Bo_tg2xo.js b/assets/LoginPage-DLaoyzV8.js similarity index 98% rename from assets/LoginPage-Bo_tg2xo.js rename to assets/LoginPage-DLaoyzV8.js index 34835a42bed4a8fc846864d040aebcc3ea5389e2..06195d04e574f31319a9663306e6859bbf6fc249 100644 --- a/assets/LoginPage-Bo_tg2xo.js +++ b/assets/LoginPage-DLaoyzV8.js @@ -1 +1 @@ -import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as Me}from"./button-De2q2xHf.js";import{I as D}from"./input-w3MoyecB.js";import{m as r,B as Ee,T as Te,A as Re,U as te,G as se,a as ae,L as re,b as ie,s as oe,c as Ce,d as le}from"./index-Cb8VeSuW.js";import{S as Ie}from"./sparkles-v8V3LFaV.js";import{M as Le}from"./mail-D1Sfp9RA.js";import{E as De,a as ze}from"./eye-DBkZRvYD.js";import{S as qe}from"./shield-check-DqJE0odB.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const ne="/assets/shader-bg-DA7bEbBA.mp4",Be=[{id:"length",label:"At least 8 characters",test:i=>i.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:i=>/[A-Z]/.test(i)&&/[a-z]/.test(i)},{id:"number",label:"Contains at least one number",test:i=>/\d/.test(i)},{id:"special",label:"Contains at least one special character",test:i=>/[^A-Za-z0-9]/.test(i)}],z="Use at least 8 characters with uppercase, lowercase, number, and special character.",Oe=i=>{const c=typeof i=="object"&&i!==null?i:null,o=i instanceof Error?i.message:"";if(c?.code&&typeof c.code=="string")return{code:c.code.toLowerCase(),message:o};const d=o.match(/auth\/[a-z-]+/i);return{code:d?d[0].toLowerCase():"",message:o}},_e=i=>i.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),ce=(i,c)=>{const{code:o,message:d}=Oe(i),h=_e(d);return o==="auth/invalid-credential"||o==="auth/wrong-password"||o==="auth/user-not-found"?"Invalid email or password. Please check your credentials and try again.":o==="auth/email-already-in-use"?"This email is already registered. Please sign in instead.":o==="auth/weak-password"||o==="auth/password-does-not-meet-requirements"?h?`Password does not meet signup requirements. ${h}`:`Password does not meet signup requirements. ${z}`:o==="auth/too-many-requests"?"Access to this account has been temporarily disabled due to many failed login attempts. You can immediately restore it by resetting your password or you can try again later.":o==="auth/network-request-failed"?"Network error. Please check your internet connection and try again.":o.startsWith("auth/")?h||c:d.includes("Firebase:")||d.includes("auth/")?c:d||c},rt=()=>{const i=["Grade 11"],c={"Grade 11":["STEM A","STEM B","ABM A","HUMSS A"]},o={teacher:["Mathematics","Science","English","Technology","Humanities"]},[d,h]=s.useState(""),[f,q]=s.useState(""),[A,de]=s.useState(!1),[l,B]=s.useState(!1),[M,ue]=s.useState(""),[n,O]=s.useState("student"),[b,me]=s.useState("Grade 11"),[w,_]=s.useState(c["Grade 11"][0]),[g,V]=s.useState("Mathematics"),[G,x]=s.useState(!1),[v,m]=s.useState(null),[pe,xe]=s.useState(!1),[ye,he]=s.useState(!1),[E,be]=s.useState(16),[F,U]=s.useState("primary"),[$,T]=s.useState(0),R=s.useRef(null),C=s.useRef(null),N=pe&&ye,j=s.useRef("primary"),k=s.useRef(0),S=s.useRef(!1),W=1.1,H=.34,Y=t=>{const a=Math.max(0,Math.min(1,t));Math.abs(k.current-a)<.02||(k.current=a,T(a))},Z=t=>{!Number.isFinite(t)||t<=0||Math.abs(E-t)>.05&&be(t)},I=s.useMemo(()=>Be.map(t=>({...t,met:t.test(f)})),[f]),fe=s.useMemo(()=>I.every(t=>t.met),[I]),J=s.useMemo(()=>{if(!l||!v)return!1;const t=v.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[v,l]),ge=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)},ve=()=>{const t=C.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)};s.useEffect(()=>{if(!N)return;const t=R.current,a=C.current;if(!t||!a)return;let u=!1,p=0;j.current="primary",U("primary"),S.current=!1,k.current=0,T(0),t.loop=!1,a.loop=!1,t.currentTime=0,a.currentTime=0,a.pause(),t.play().catch(()=>{});const P=()=>{if(u)return;const y=j.current==="primary"?t:a,K=j.current==="primary"?a:t,Pe=Number.isFinite(y.duration)&&y.duration>0?y.duration:E,L=Math.max(Pe-y.currentTime,0);if(L<=W){S.current||(S.current=!0,K.currentTime=0,K.play().catch(()=>{}));const Ae=1-L/W;if(Y(Ae),L<=.03||y.ended){y.pause(),y.currentTime=0;const ee=j.current==="primary"?"secondary":"primary";j.current=ee,U(ee),S.current=!1,k.current=0,T(0)}}else Y(0);p=window.requestAnimationFrame(P)};return p=window.requestAnimationFrame(P),()=>{u=!0,p&&window.cancelAnimationFrame(p)}},[E,N]);const Q=N?H*(1-$):0,X=N?H*$:0,je=F==="primary"?Q:X,we=F==="secondary"?Q:X;s.useEffect(()=>{n==="teacher"&&!o.teacher.includes(g)&&V(o.teacher[0])},[g,n]),s.useEffect(()=>{const t=c[b]||[];t.length>0&&!t.includes(w)&&_(t[0])},[b,w]);const Ne=[{label:"Student",role:"student",email:"teststudent@school.edu",password:"TestPass123!",icon:se,color:"sky"},{label:"Teacher",role:"teacher",email:"testteacher@school.edu",password:"TestPass123!",icon:ae,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:qe,color:"rose"}],ke=async(t,a,u)=>{m(null),x(!0),h(t),q(a),O(u),B(!1);try{oe(u),await le(t,a)}catch(p){m(ce(p,"Demo sign-in failed. Please try again.")),x(!1)}},Se=async t=>{t.preventDefault(),m(null),x(!0);try{if(l){if(!M.trim()){m("Please enter your name"),x(!1);return}if(n==="student"&&!b){m("Please select a grade level"),x(!1);return}if(n!=="student"&&!g){m("Please select a department"),x(!1);return}if(n==="admin"){m("Admin account creation is restricted. Please contact an existing administrator."),x(!1);return}if(!fe){m(`Password does not meet signup requirements. ${z}`),x(!1);return}oe(n),await Ce(d,f,M,n,n==="student"?{grade:b,section:w}:{department:g})}else await le(d,f)}catch(a){const u=l?`Sign-up failed. ${z}`:"Sign-in failed. Please check your credentials and try again.";m(ce(a,u)),x(!1)}};return e.jsxs("div",{className:"h-screen w-full flex items-center justify-center px-6 overflow-hidden relative login-bg",children:[e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>xe(!0),onLoadedMetadata:ge,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":je},src:ne}),e.jsx("video",{ref:C,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>he(!0),onLoadedMetadata:ve,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":we},src:ne}),e.jsx("div",{className:"absolute inset-0 pointer-events-none login-frost-overlay"}),e.jsx("div",{className:"absolute top-[10%] left-[-10%] w-[60%] h-[60%] rounded-full blur-[140px] pointer-events-none mix-blend-multiply login-orb-purple"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[70%] h-[70%] rounded-full blur-[160px] pointer-events-none mix-blend-multiply login-orb-pink"}),e.jsx("div",{className:"absolute top-[40%] left-[40%] w-[40%] h-[40%] rounded-full blur-[120px] pointer-events-none mix-blend-screen login-orb-blue"}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 items-center",children:[e.jsxs(r.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col justify-center space-y-8",children:[e.jsxs(r.div,{className:"flex items-center gap-2.5",children:[e.jsx(r.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI Logo",className:"w-16 h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black tracking-tight text-slate-900 bg-clip-text text-transparent bg-gradient-to-r from-purple-600 via-pink-600 to-sky-500",children:"MathPulse"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(Ie,{size:12,className:"text-rose-500"}),e.jsx("span",{className:"text-xs text-slate-500 font-body font-medium tracking-wide",children:"Powered by Machine Learning"})]})]})]}),e.jsxs(r.div,{className:"space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-4xl lg:text-5xl xl:text-[3.4rem] font-display font-extrabold leading-[1.1] tracking-tight text-slate-900",children:["Transform Your",e.jsx("br",{}),e.jsx("span",{className:"bg-gradient-to-r from-sky-600 via-cyan-500 to-sky-500 bg-clip-text text-transparent",children:"Math Journey"})]}),e.jsx("p",{className:"text-base text-slate-500 leading-relaxed max-w-md font-body",children:"AI-powered predictive system designed to identify at-risk students and provide personalized learning recommendations."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{icon:Ee,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Te,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:Re,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,a)=>{const u=t.icon,p={sky:"border-sky-200/60 hover:border-sky-300",rose:"border-rose-200/60 hover:border-rose-300",emerald:"border-emerald-200/60 hover:border-emerald-300"},P={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},y={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(r.div,{className:`bg-white/80 backdrop-blur-xl border ${p[t.color]} rounded-xl p-4 transition-all cursor-pointer group shadow-md shadow-slate-900/[0.04]`,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5+a*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${y[t.color]} flex items-center justify-center mb-3`,children:e.jsx(u,{size:18,className:P[t.color]})}),e.jsx("h3",{className:"text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-xs text-slate-400 font-body",children:t.desc})]},a)})})]}),e.jsx(r.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.15,ease:[.22,1,.36,1]},className:"relative flex justify-center lg:justify-end",children:e.jsxs("div",{className:"bg-white/85 backdrop-blur-2xl border border-slate-200/60 rounded-3xl p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[3px] bg-gradient-to-r from-purple-500 via-pink-500 to-sky-500"}),e.jsx("div",{className:"absolute -top-40 left-1/2 -translate-x-1/2 w-80 h-80 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full blur-[60px] pointer-events-none"}),e.jsxs("div",{className:"text-center mb-6 relative",children:[e.jsx(r.h3,{className:"text-2xl font-display font-bold text-slate-900 mb-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},children:l?"Create Account":"Welcome Back"}),e.jsx(r.p,{className:"text-sm text-slate-500 font-body",initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:l?"Begin your learning journey":"Sign in to continue learning"})]}),e.jsxs("form",{onSubmit:Se,className:"space-y-4 mb-5 relative",children:[v&&!J&&e.jsx(r.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-rose-50 border border-rose-200 text-rose-600 px-4 py-3 rounded-lg text-sm font-body",children:v}),l&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"text",placeholder:"Your Name",value:M,onChange:t=>ue(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),l&&e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.45},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Account Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{role:"student",label:"Student"},{role:"teacher",label:"Teacher"}].map(t=>{const a=n===t.role;return e.jsx("button",{type:"button",onClick:()=>O(t.role),className:`rounded-lg border px-3 py-2 text-xs font-body font-semibold transition-all ${a?"border-sky-400 bg-sky-50 text-sky-700":"border-slate-200 bg-slate-50 text-slate-500 hover:border-slate-300"}`,children:t.label},t.role)})})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(se,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:b,onChange:t=>me(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:i.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:w,onChange:t=>_(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:(c[b]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n!=="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Department"}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:g,onChange:t=>V(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:o.teacher.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.5},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"email",placeholder:"your.email@school.edu",value:d,onChange:t=>h(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.6},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:A?"text":"password",placeholder:"••••••••",value:f,onChange:t=>q(t.target.value),className:"w-full pl-11 pr-11 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0,minLength:l?8:6}),e.jsx(r.button,{type:"button",onClick:()=>de(!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:A?e.jsx(De,{size:16}):e.jsx(ze,{size:16})})]}),l&&e.jsxs("div",{className:"mt-2 rounded-lg border border-sky-100/80 bg-sky-50/70 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-body font-semibold uppercase tracking-wider text-slate-600",children:"Password requirements"}),e.jsx("ul",{className:"mt-2 space-y-1",children:I.map(t=>e.jsxs("li",{className:`flex items-center gap-2 text-[11px] font-body ${t.met?"text-emerald-700":"text-slate-500"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t.met?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{children:t.label})]},t.id))}),J&&e.jsx("p",{className:"mt-2 text-[11px] font-body font-semibold text-rose-600",children:"Password does not meet signup requirements."})]})]}),e.jsx(r.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(Me,{type:"submit",disabled:G,className:"w-full bg-gradient-to-r from-purple-600 to-pink-500 hover:from-purple-500 hover:to-pink-400 text-white font-body font-semibold py-3 rounded-xl shadow-lg shadow-purple-600/25 hover:shadow-pink-500/35 hover:scale-[1.02] transition-all text-sm group relative overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(r.span,{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/15 to-white/0",animate:{x:["-100%","100%"]},transition:{duration:3,repeat:1/0,repeatDelay:2}}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[G?"Please wait...":l?"Create Account":"Sign In",e.jsx(ie,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{B(!l),m(null)},className:"text-sm text-slate-400 hover:text-sky-500 font-body font-medium transition-colors",children:l?"Already have an account? Sign in":"Don't have an account? Create one"})})]}),!l&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.85},className:"mb-4 relative",children:[e.jsxs("div",{className:"relative flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-[10px] font-body font-semibold text-slate-400 uppercase tracking-widest",children:"Quick Demo Access"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Ne.map(t=>{const a=t.icon,u={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},p={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(r.button,{type:"button",onClick:()=>ke(t.email,t.password,t.role),className:"group flex items-center gap-3 w-full px-4 py-2.5 rounded-lg bg-slate-50/80 border border-slate-200/70 hover:border-sky-300 hover:bg-sky-50/80 hover:shadow-sm transition-all text-left",whileHover:{scale:1.01},whileTap:{scale:.99},children:[e.jsx("div",{className:`w-8 h-8 rounded-md flex items-center justify-center shrink-0 ${u[t.color]}`,children:e.jsx(a,{size:15,className:p[t.color]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-body font-semibold text-slate-700 group-hover:text-sky-600 transition-colors",children:[t.label," Account"]}),e.jsx("p",{className:"text-[10px] text-slate-400 font-body truncate",children:t.email})]}),e.jsx(ie,{size:14,className:"text-slate-300 group-hover:text-sky-500 group-hover:translate-x-0.5 transition-all shrink-0"})]},t.label)})})]}),e.jsxs(r.p,{className:"text-xs text-slate-400 text-center mt-4 font-body relative",initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx(re,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{rt as default}; +import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as Me}from"./button-DCfeFHoH.js";import{I as D}from"./input-D28h_UTJ.js";import{m as r,B as Ee,T as Te,A as Re,U as te,G as se,a as ae,L as re,b as ie,s as oe,c as Ce,d as le}from"./index-BaOs5Ayg.js";import{S as Ie}from"./sparkles-By-vFjpv.js";import{M as Le}from"./mail-BbG1phxL.js";import{E as De,a as ze}from"./eye-Ig3S6mOs.js";import{S as qe}from"./shield-check-Dgisjfmb.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";const ne="/assets/shader-bg-DA7bEbBA.mp4",Be=[{id:"length",label:"At least 8 characters",test:i=>i.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:i=>/[A-Z]/.test(i)&&/[a-z]/.test(i)},{id:"number",label:"Contains at least one number",test:i=>/\d/.test(i)},{id:"special",label:"Contains at least one special character",test:i=>/[^A-Za-z0-9]/.test(i)}],z="Use at least 8 characters with uppercase, lowercase, number, and special character.",Oe=i=>{const c=typeof i=="object"&&i!==null?i:null,o=i instanceof Error?i.message:"";if(c?.code&&typeof c.code=="string")return{code:c.code.toLowerCase(),message:o};const d=o.match(/auth\/[a-z-]+/i);return{code:d?d[0].toLowerCase():"",message:o}},_e=i=>i.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),ce=(i,c)=>{const{code:o,message:d}=Oe(i),h=_e(d);return o==="auth/invalid-credential"||o==="auth/wrong-password"||o==="auth/user-not-found"?"Invalid email or password. Please check your credentials and try again.":o==="auth/email-already-in-use"?"This email is already registered. Please sign in instead.":o==="auth/weak-password"||o==="auth/password-does-not-meet-requirements"?h?`Password does not meet signup requirements. ${h}`:`Password does not meet signup requirements. ${z}`:o==="auth/too-many-requests"?"Access to this account has been temporarily disabled due to many failed login attempts. You can immediately restore it by resetting your password or you can try again later.":o==="auth/network-request-failed"?"Network error. Please check your internet connection and try again.":o.startsWith("auth/")?h||c:d.includes("Firebase:")||d.includes("auth/")?c:d||c},rt=()=>{const i=["Grade 11"],c={"Grade 11":["STEM A","STEM B","ABM A","HUMSS A"]},o={teacher:["Mathematics","Science","English","Technology","Humanities"]},[d,h]=s.useState(""),[f,q]=s.useState(""),[A,de]=s.useState(!1),[l,B]=s.useState(!1),[M,ue]=s.useState(""),[n,O]=s.useState("student"),[b,me]=s.useState("Grade 11"),[w,_]=s.useState(c["Grade 11"][0]),[g,V]=s.useState("Mathematics"),[G,x]=s.useState(!1),[v,m]=s.useState(null),[pe,xe]=s.useState(!1),[ye,he]=s.useState(!1),[E,be]=s.useState(16),[F,U]=s.useState("primary"),[$,T]=s.useState(0),R=s.useRef(null),C=s.useRef(null),N=pe&&ye,j=s.useRef("primary"),k=s.useRef(0),S=s.useRef(!1),W=1.1,H=.34,Y=t=>{const a=Math.max(0,Math.min(1,t));Math.abs(k.current-a)<.02||(k.current=a,T(a))},Z=t=>{!Number.isFinite(t)||t<=0||Math.abs(E-t)>.05&&be(t)},I=s.useMemo(()=>Be.map(t=>({...t,met:t.test(f)})),[f]),fe=s.useMemo(()=>I.every(t=>t.met),[I]),J=s.useMemo(()=>{if(!l||!v)return!1;const t=v.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[v,l]),ge=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)},ve=()=>{const t=C.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)};s.useEffect(()=>{if(!N)return;const t=R.current,a=C.current;if(!t||!a)return;let u=!1,p=0;j.current="primary",U("primary"),S.current=!1,k.current=0,T(0),t.loop=!1,a.loop=!1,t.currentTime=0,a.currentTime=0,a.pause(),t.play().catch(()=>{});const P=()=>{if(u)return;const y=j.current==="primary"?t:a,K=j.current==="primary"?a:t,Pe=Number.isFinite(y.duration)&&y.duration>0?y.duration:E,L=Math.max(Pe-y.currentTime,0);if(L<=W){S.current||(S.current=!0,K.currentTime=0,K.play().catch(()=>{}));const Ae=1-L/W;if(Y(Ae),L<=.03||y.ended){y.pause(),y.currentTime=0;const ee=j.current==="primary"?"secondary":"primary";j.current=ee,U(ee),S.current=!1,k.current=0,T(0)}}else Y(0);p=window.requestAnimationFrame(P)};return p=window.requestAnimationFrame(P),()=>{u=!0,p&&window.cancelAnimationFrame(p)}},[E,N]);const Q=N?H*(1-$):0,X=N?H*$:0,je=F==="primary"?Q:X,we=F==="secondary"?Q:X;s.useEffect(()=>{n==="teacher"&&!o.teacher.includes(g)&&V(o.teacher[0])},[g,n]),s.useEffect(()=>{const t=c[b]||[];t.length>0&&!t.includes(w)&&_(t[0])},[b,w]);const Ne=[{label:"Student",role:"student",email:"teststudent@school.edu",password:"TestPass123!",icon:se,color:"sky"},{label:"Teacher",role:"teacher",email:"testteacher@school.edu",password:"TestPass123!",icon:ae,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:qe,color:"rose"}],ke=async(t,a,u)=>{m(null),x(!0),h(t),q(a),O(u),B(!1);try{oe(u),await le(t,a)}catch(p){m(ce(p,"Demo sign-in failed. Please try again.")),x(!1)}},Se=async t=>{t.preventDefault(),m(null),x(!0);try{if(l){if(!M.trim()){m("Please enter your name"),x(!1);return}if(n==="student"&&!b){m("Please select a grade level"),x(!1);return}if(n!=="student"&&!g){m("Please select a department"),x(!1);return}if(n==="admin"){m("Admin account creation is restricted. Please contact an existing administrator."),x(!1);return}if(!fe){m(`Password does not meet signup requirements. ${z}`),x(!1);return}oe(n),await Ce(d,f,M,n,n==="student"?{grade:b,section:w}:{department:g})}else await le(d,f)}catch(a){const u=l?`Sign-up failed. ${z}`:"Sign-in failed. Please check your credentials and try again.";m(ce(a,u)),x(!1)}};return e.jsxs("div",{className:"h-screen w-full flex items-center justify-center px-6 overflow-hidden relative login-bg",children:[e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>xe(!0),onLoadedMetadata:ge,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":je},src:ne}),e.jsx("video",{ref:C,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>he(!0),onLoadedMetadata:ve,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":we},src:ne}),e.jsx("div",{className:"absolute inset-0 pointer-events-none login-frost-overlay"}),e.jsx("div",{className:"absolute top-[10%] left-[-10%] w-[60%] h-[60%] rounded-full blur-[140px] pointer-events-none mix-blend-multiply login-orb-purple"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[70%] h-[70%] rounded-full blur-[160px] pointer-events-none mix-blend-multiply login-orb-pink"}),e.jsx("div",{className:"absolute top-[40%] left-[40%] w-[40%] h-[40%] rounded-full blur-[120px] pointer-events-none mix-blend-screen login-orb-blue"}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 items-center",children:[e.jsxs(r.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col justify-center space-y-8",children:[e.jsxs(r.div,{className:"flex items-center gap-2.5",children:[e.jsx(r.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI Logo",className:"w-16 h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black tracking-tight text-slate-900 bg-clip-text text-transparent bg-gradient-to-r from-purple-600 via-pink-600 to-sky-500",children:"MathPulse"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(Ie,{size:12,className:"text-rose-500"}),e.jsx("span",{className:"text-xs text-slate-500 font-body font-medium tracking-wide",children:"Powered by Machine Learning"})]})]})]}),e.jsxs(r.div,{className:"space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-4xl lg:text-5xl xl:text-[3.4rem] font-display font-extrabold leading-[1.1] tracking-tight text-slate-900",children:["Transform Your",e.jsx("br",{}),e.jsx("span",{className:"bg-gradient-to-r from-sky-600 via-cyan-500 to-sky-500 bg-clip-text text-transparent",children:"Math Journey"})]}),e.jsx("p",{className:"text-base text-slate-500 leading-relaxed max-w-md font-body",children:"AI-powered predictive system designed to identify at-risk students and provide personalized learning recommendations."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{icon:Ee,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Te,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:Re,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,a)=>{const u=t.icon,p={sky:"border-sky-200/60 hover:border-sky-300",rose:"border-rose-200/60 hover:border-rose-300",emerald:"border-emerald-200/60 hover:border-emerald-300"},P={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},y={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(r.div,{className:`bg-white/80 backdrop-blur-xl border ${p[t.color]} rounded-xl p-4 transition-all cursor-pointer group shadow-md shadow-slate-900/[0.04]`,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5+a*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${y[t.color]} flex items-center justify-center mb-3`,children:e.jsx(u,{size:18,className:P[t.color]})}),e.jsx("h3",{className:"text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-xs text-slate-400 font-body",children:t.desc})]},a)})})]}),e.jsx(r.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.15,ease:[.22,1,.36,1]},className:"relative flex justify-center lg:justify-end",children:e.jsxs("div",{className:"bg-white/85 backdrop-blur-2xl border border-slate-200/60 rounded-3xl p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[3px] bg-gradient-to-r from-purple-500 via-pink-500 to-sky-500"}),e.jsx("div",{className:"absolute -top-40 left-1/2 -translate-x-1/2 w-80 h-80 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full blur-[60px] pointer-events-none"}),e.jsxs("div",{className:"text-center mb-6 relative",children:[e.jsx(r.h3,{className:"text-2xl font-display font-bold text-slate-900 mb-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},children:l?"Create Account":"Welcome Back"}),e.jsx(r.p,{className:"text-sm text-slate-500 font-body",initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:l?"Begin your learning journey":"Sign in to continue learning"})]}),e.jsxs("form",{onSubmit:Se,className:"space-y-4 mb-5 relative",children:[v&&!J&&e.jsx(r.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-rose-50 border border-rose-200 text-rose-600 px-4 py-3 rounded-lg text-sm font-body",children:v}),l&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"text",placeholder:"Your Name",value:M,onChange:t=>ue(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),l&&e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.45},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Account Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{role:"student",label:"Student"},{role:"teacher",label:"Teacher"}].map(t=>{const a=n===t.role;return e.jsx("button",{type:"button",onClick:()=>O(t.role),className:`rounded-lg border px-3 py-2 text-xs font-body font-semibold transition-all ${a?"border-sky-400 bg-sky-50 text-sky-700":"border-slate-200 bg-slate-50 text-slate-500 hover:border-slate-300"}`,children:t.label},t.role)})})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(se,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:b,onChange:t=>me(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:i.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:w,onChange:t=>_(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:(c[b]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n!=="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Department"}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:g,onChange:t=>V(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:o.teacher.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.5},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"email",placeholder:"your.email@school.edu",value:d,onChange:t=>h(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.6},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:A?"text":"password",placeholder:"••••••••",value:f,onChange:t=>q(t.target.value),className:"w-full pl-11 pr-11 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0,minLength:l?8:6}),e.jsx(r.button,{type:"button",onClick:()=>de(!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:A?e.jsx(De,{size:16}):e.jsx(ze,{size:16})})]}),l&&e.jsxs("div",{className:"mt-2 rounded-lg border border-sky-100/80 bg-sky-50/70 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-body font-semibold uppercase tracking-wider text-slate-600",children:"Password requirements"}),e.jsx("ul",{className:"mt-2 space-y-1",children:I.map(t=>e.jsxs("li",{className:`flex items-center gap-2 text-[11px] font-body ${t.met?"text-emerald-700":"text-slate-500"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t.met?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{children:t.label})]},t.id))}),J&&e.jsx("p",{className:"mt-2 text-[11px] font-body font-semibold text-rose-600",children:"Password does not meet signup requirements."})]})]}),e.jsx(r.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(Me,{type:"submit",disabled:G,className:"w-full bg-gradient-to-r from-purple-600 to-pink-500 hover:from-purple-500 hover:to-pink-400 text-white font-body font-semibold py-3 rounded-xl shadow-lg shadow-purple-600/25 hover:shadow-pink-500/35 hover:scale-[1.02] transition-all text-sm group relative overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(r.span,{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/15 to-white/0",animate:{x:["-100%","100%"]},transition:{duration:3,repeat:1/0,repeatDelay:2}}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[G?"Please wait...":l?"Create Account":"Sign In",e.jsx(ie,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{B(!l),m(null)},className:"text-sm text-slate-400 hover:text-sky-500 font-body font-medium transition-colors",children:l?"Already have an account? Sign in":"Don't have an account? Create one"})})]}),!l&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.85},className:"mb-4 relative",children:[e.jsxs("div",{className:"relative flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-[10px] font-body font-semibold text-slate-400 uppercase tracking-widest",children:"Quick Demo Access"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Ne.map(t=>{const a=t.icon,u={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},p={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(r.button,{type:"button",onClick:()=>ke(t.email,t.password,t.role),className:"group flex items-center gap-3 w-full px-4 py-2.5 rounded-lg bg-slate-50/80 border border-slate-200/70 hover:border-sky-300 hover:bg-sky-50/80 hover:shadow-sm transition-all text-left",whileHover:{scale:1.01},whileTap:{scale:.99},children:[e.jsx("div",{className:`w-8 h-8 rounded-md flex items-center justify-center shrink-0 ${u[t.color]}`,children:e.jsx(a,{size:15,className:p[t.color]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-body font-semibold text-slate-700 group-hover:text-sky-600 transition-colors",children:[t.label," Account"]}),e.jsx("p",{className:"text-[10px] text-slate-400 font-body truncate",children:t.email})]}),e.jsx(ie,{size:14,className:"text-slate-300 group-hover:text-sky-500 group-hover:translate-x-0.5 transition-all shrink-0"})]},t.label)})})]}),e.jsxs(r.p,{className:"text-xs text-slate-400 text-center mt-4 font-body relative",initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx(re,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{rt as default}; diff --git a/assets/LogoutActionButton-Cb7v3MhK.js b/assets/LogoutActionButton-lUNItet6.js similarity index 93% rename from assets/LogoutActionButton-Cb7v3MhK.js rename to assets/LogoutActionButton-lUNItet6.js index 9e4657950f9d3b00a92ba7f833212b588678b955..2063687e6b4283da1411fde4ee6ab366cd313454 100644 --- a/assets/LogoutActionButton-Cb7v3MhK.js +++ b/assets/LogoutActionButton-lUNItet6.js @@ -1,4 +1,4 @@ -import{e as a,m as s,i}from"./index-Cb8VeSuW.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as l}from"./log-out-CM6AS10M.js";/** +import{e as a,m as s,i}from"./index-BaOs5Ayg.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as l}from"./log-out-BenDMDly.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ModuleFolderCard-CITAgDA0.js b/assets/ModuleFolderCard-DKBrO5a8.js similarity index 97% rename from assets/ModuleFolderCard-CITAgDA0.js rename to assets/ModuleFolderCard-DKBrO5a8.js index 91cd146e77188b76d795da480a228a12528c7e95..9796d9ab5b38875074d1b3188e52cb9a62e40308 100644 --- a/assets/ModuleFolderCard-CITAgDA0.js +++ b/assets/ModuleFolderCard-DKBrO5a8.js @@ -1,4 +1,4 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{u as g}from"./useSubjectAvailability-d2Fw9DS6.js";import{e as w,m as f,a as j,p as v,L as k}from"./index-Cb8VeSuW.js";import{C as y}from"./clock-BodmJJnp.js";/** +import{j as e}from"./vendor-react-B4AQeu28.js";import{u as g}from"./useSubjectAvailability-Bvu3fXaT.js";import{e as w,m as f,a as j,p as v,L as k}from"./index-BaOs5Ayg.js";import{C as y}from"./clock-D1Ecvltm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ModulesPage-yaDxw1Cj.js b/assets/ModulesPage-cZJm_yoJ.js similarity index 99% rename from assets/ModulesPage-yaDxw1Cj.js rename to assets/ModulesPage-cZJm_yoJ.js index bce1b70da429d9f71d56358e35d20f5d66c26064..267af58c340940410b206ab0512d77f1aff2dad8 100644 --- a/assets/ModulesPage-yaDxw1Cj.js +++ b/assets/ModulesPage-cZJm_yoJ.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-core-CO26nNq6.js"])))=>i.map(i=>d[i]); -import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u as Gs}from"./useQuery-PwtHq3dz.js";import{getDoc as qt,doc as bt,onSnapshot as Gt,runTransaction as Vs,serverTimestamp as Ys,query as Ks,where as Zs,collection as Js}from"./vendor-firebase-firestore-CH1lNiRF.js";import{e as ie,m as v,Z as Re,C as mt,j as $e,O as As,M as ea,b as pt,T as Pt,y as qe,X as Es,R as Ps,x as Ct,_ as Lt,B as ns,F as ta,u as Ft,A as It,a as Je,i as At,p as Ts,n as sa,a4 as is,a5 as aa,a6 as os,a7 as ra,a8 as la,L as Vt,f as We,q as na,a9 as ia,aa as oa,ab as Ls,ac as ca,ad as da,ae as xa,a2 as ma,o as ua,af as cs,ag as pa,ah as ds,G as ha,a1 as fa,t as Bt,a3 as ba}from"./index-Cb8VeSuW.js";import{M as Wt}from"./ModuleFolderCard-CITAgDA0.js";import{B as ze}from"./button-De2q2xHf.js";import Fs from"./ScientificCalculator-CLmkIayw.js";import{C as lt}from"./check-DSwzaW4Y.js";import{X as De}from"./x-CTLBAl-n.js";import{V as Is,a as Ds,M as Rs,b as $s}from"./volume-x-BMxXZeNg.js";import{C as Yt}from"./chevron-left-CZaM7nZW.js";import{C as ht}from"./chevron-right-CoVWpXdD.js";import{C as ga}from"./circle-help-hn0lWYq9.js";import{S as xs,b as wa,L as ya}from"./quizService-CJqOfhFJ.js";import{L as Kt,C as Ht}from"./lightbulb-BjBRtEjU.js";import{logLessonView as ja}from"./trackingService-uiTTm34h.js";import{C as ft}from"./clock-BodmJJnp.js";import{C as Bs}from"./clipboard-check-BEObtDZM.js";import{C as zt}from"./circle-check-big-CNGbqkWz.js";import{s as Tt}from"./subjects-Bnu0lJdU.js";import{C as va}from"./circle-check-CVJuYLp6.js";import{triggerQuizSubmitted as Na}from"./automationService-BxQhaGqB.js";import ms from"./confetti.module-C94ZD2ww.js";import{u as ka}from"./useCurriculum-B8pRV6G_.js";import{S as Sa}from"./search-CMbwAzt9.js";import{F as Ca}from"./funnel-D-s_ygM_.js";import{S as za}from"./sparkles-v8V3LFaV.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-d2Fw9DS6.js";import"./chevron-up-Byo9SJJ4.js";import"./chart-column-CmH46HAG.js";/** +import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u as Gs}from"./useQuery-BnRttv09.js";import{getDoc as qt,doc as bt,onSnapshot as Gt,runTransaction as Vs,serverTimestamp as Ys,query as Ks,where as Zs,collection as Js}from"./vendor-firebase-firestore-CH1lNiRF.js";import{e as ie,m as v,Z as Re,C as mt,j as $e,O as As,M as ea,b as pt,T as Pt,y as qe,X as Es,R as Ps,x as Ct,_ as Lt,B as ns,F as ta,u as Ft,A as It,a as Je,i as At,p as Ts,n as sa,a4 as is,a5 as aa,a6 as os,a7 as ra,a8 as la,L as Vt,f as We,q as na,a9 as ia,aa as oa,ab as Ls,ac as ca,ad as da,ae as xa,a2 as ma,o as ua,af as cs,ag as pa,ah as ds,G as ha,a1 as fa,t as Bt,a3 as ba}from"./index-BaOs5Ayg.js";import{M as Wt}from"./ModuleFolderCard-DKBrO5a8.js";import{B as ze}from"./button-DCfeFHoH.js";import Fs from"./ScientificCalculator-DRuSfTXj.js";import{C as lt}from"./check-BLSo9L0H.js";import{X as De}from"./x-TNvtuOD9.js";import{V as Is,a as Ds,M as Rs,b as $s}from"./volume-x-Chtf_bSj.js";import{C as Yt}from"./chevron-left-BWpgclqc.js";import{C as ht}from"./chevron-right-COqGruhh.js";import{C as ga}from"./circle-help-B8apTIdU.js";import{S as xs,b as wa,L as ya}from"./quizService-8JHQlvu9.js";import{L as Kt,C as Ht}from"./lightbulb-Ce2KQzGM.js";import{logLessonView as ja}from"./trackingService-DQ12buWG.js";import{C as ft}from"./clock-D1Ecvltm.js";import{C as Bs}from"./clipboard-check-DqBu2Pqb.js";import{C as zt}from"./circle-check-big-m1SvzGFL.js";import{s as Tt}from"./subjects-BFghB0SQ.js";import{C as va}from"./circle-check-C0FPGTrp.js";import{triggerQuizSubmitted as Na}from"./automationService-7m3RFJA3.js";import ms from"./confetti.module-C94ZD2ww.js";import{u as ka}from"./useCurriculum-DDCuCvMR.js";import{S as Sa}from"./search-Bq99THgc.js";import{F as Ca}from"./funnel-BT77sgnz.js";import{S as za}from"./sparkles-By-vFjpv.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-Bvu3fXaT.js";import"./chevron-up-Cdvz2TMJ.js";import"./chart-column-B3jJOD5i.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ProfileModal-BYEUqArA.js b/assets/ProfileModal-Gwxh5tYO.js similarity index 96% rename from assets/ProfileModal-BYEUqArA.js rename to assets/ProfileModal-Gwxh5tYO.js index 828d03b6934e5605883e6524b480c87465b8f31f..b11dc6766a1cf1c86a086ef2b61b97cdba8d8c1d 100644 --- a/assets/ProfileModal-BYEUqArA.js +++ b/assets/ProfileModal-Gwxh5tYO.js @@ -1,4 +1,4 @@ -import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as c}from"./button-De2q2xHf.js";import{I as d}from"./input-w3MoyecB.js";import{S as _,a as R,c as U,d as h}from"./select-CqJdJ0KN.js";import{e as S,j as D,m as k,U as u,A as x,a as w,z as B,aM as T,aD as q,aO as G}from"./index-Cb8VeSuW.js";import{P as V,M as z,V as C}from"./ProfilePictureUploader-viKg_Exm.js";import{X}from"./x-CTLBAl-n.js";import{M as Y}from"./mail-D1Sfp9RA.js";import{C as L}from"./circle-help-hn0lWYq9.js";import{S as $}from"./save-CpWDoSfX.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./chevron-up-Byo9SJJ4.js";import"./check-DSwzaW4Y.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./minus-CMQilTBg.js";import"./plus-uFWGSQCY.js";import"./upload-D5cppfxb.js";/** +import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as c}from"./button-DCfeFHoH.js";import{I as d}from"./input-D28h_UTJ.js";import{S as _,a as R,c as U,d as h}from"./select-DIjxRWza.js";import{e as S,j as D,m as k,U as u,A as x,a as w,z as B,aM as T,aD as q,aO as G}from"./index-BaOs5Ayg.js";import{P as V,M as z,V as C}from"./ProfilePictureUploader-CX_IZAwE.js";import{X}from"./x-TNvtuOD9.js";import{M as Y}from"./mail-BbG1phxL.js";import{C as L}from"./circle-help-B8apTIdU.js";import{S as $}from"./save-CQIJrhLf.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./chevron-up-Cdvz2TMJ.js";import"./check-BLSo9L0H.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./minus-DfrEv-SC.js";import"./plus-DkG35AoH.js";import"./upload-DayXhGwD.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ProfilePictureUploader-viKg_Exm.js b/assets/ProfilePictureUploader-CX_IZAwE.js similarity index 99% rename from assets/ProfilePictureUploader-viKg_Exm.js rename to assets/ProfilePictureUploader-CX_IZAwE.js index 22308544c32a9f49ea78f620fdc17adc5ff3182f..1a44729889afab89d916e237319c9b317d66b52d 100644 --- a/assets/ProfilePictureUploader-viKg_Exm.js +++ b/assets/ProfilePictureUploader-CX_IZAwE.js @@ -1,4 +1,4 @@ -import{e as X,i as B,F as V,aQ as ve,aR as ge,u as we,J as xe,K as ye,N as be,j as Ce,m as K,t as J}from"./index-Cb8VeSuW.js";import{g as Pe,r as g,j as p}from"./vendor-react-B4AQeu28.js";import{_ as Re,p as b,q as Ee,r as Se,s as _e,t as ze}from"./vendor-radix-BorKzPz9.js";import{B as Q}from"./button-De2q2xHf.js";import{updateProfile as De}from"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-core-CO26nNq6.js";import{r as Me,u as Ae,a as Ne}from"./vendor-firebase-storage-B3igpVVS.js";import{X as Te}from"./x-CTLBAl-n.js";import{M as je}from"./minus-CMQilTBg.js";import{P as Ue}from"./plus-uFWGSQCY.js";import{U as Fe}from"./upload-D5cppfxb.js";/** +import{e as X,i as B,F as V,aZ as ve,a_ as ge,u as we,J as xe,K as ye,N as be,j as Ce,m as K,t as J}from"./index-BaOs5Ayg.js";import{g as Pe,r as g,j as p}from"./vendor-react-B4AQeu28.js";import{_ as Re,p as b,q as Ee,r as Se,s as _e,t as ze}from"./vendor-radix-BorKzPz9.js";import{B as Q}from"./button-DCfeFHoH.js";import{updateProfile as De}from"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-core-CO26nNq6.js";import{r as Me,u as Ae,a as Ne}from"./vendor-firebase-storage-B3igpVVS.js";import{X as Te}from"./x-TNvtuOD9.js";import{M as je}from"./minus-DfrEv-SC.js";import{P as Ue}from"./plus-DkG35AoH.js";import{U as Fe}from"./upload-DayXhGwD.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/QuizBattlePage-Bsec_0MM.js b/assets/QuizBattlePage-Bwu0snEF.js similarity index 99% rename from assets/QuizBattlePage-Bsec_0MM.js rename to assets/QuizBattlePage-Bwu0snEF.js index af396b00d384bbe3029038193f40bd6c5202550c..51395bef32cf584d80f526077ccea397c65ba65c 100644 --- a/assets/QuizBattlePage-Bsec_0MM.js +++ b/assets/QuizBattlePage-Bwu0snEF.js @@ -1,4 +1,4 @@ -import{e as Et,i as x,m as y,f as tt,aE as De,F as rt,aF as Q,O as Va,y as Ct,M as Wa,w as Pe,U as ve,j as Ke,l as Je,u as Ua,_ as Ya,P as wt,X as vt,x as jt,W as Xa}from"./index-Cb8VeSuW.js";import{r as i,j as e,d as Rt}from"./vendor-react-B4AQeu28.js";import{q as yt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Ga,s as ea}from"./subjects-Bnu0lJdU.js";import{doc as Za,getDoc as Ka,where as ta,orderBy as pa,limit as zt,getDocs as It,query as Mt,collection as Bt}from"./vendor-firebase-firestore-CH1lNiRF.js";import{$ as q,a0 as ha,a1 as ba,a2 as Ie,a3 as Ja}from"./vendor-firebase-core-CO26nNq6.js";import{B as A}from"./button-De2q2xHf.js";import{a as te,b as le,c as ie,e as pe,d as ge,C as aa}from"./card-DXoGKpl1.js";import{f as es,g as ts}from"./vendor-radix-BorKzPz9.js";import{S as _e,a as Se,b as Ae,c as Ce,d as J}from"./select-CqJdJ0KN.js";import{I as as}from"./input-w3MoyecB.js";import{S as sa}from"./switch-KjWJg4zs.js";import{S as we}from"./skeleton-Bue6-H9w.js";import{V as fa,a as ga,M as ss,b as rs}from"./volume-x-BMxXZeNg.js";import{C as ns}from"./CompositeAvatar-Col05lJc.js";import{S as et}from"./sparkles-v8V3LFaV.js";import{C as kt}from"./check-DSwzaW4Y.js";import{C as Ye}from"./chevron-right-CoVWpXdD.js";import{S as os}from"./shield-check-DqJE0odB.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-CmH46HAG.js";import"./chevron-up-Byo9SJJ4.js";import"./avatarData-BuQSOXo3.js";/** +import{e as Et,i as x,m as y,f as tt,aE as De,F as rt,aF as Q,O as Va,y as Ct,M as Wa,w as Pe,U as ve,j as Ke,l as Je,u as Ua,_ as Ya,P as wt,X as vt,x as jt,W as Xa}from"./index-BaOs5Ayg.js";import{r as i,j as e,d as Rt}from"./vendor-react-B4AQeu28.js";import{q as yt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Ga,s as ea}from"./subjects-BFghB0SQ.js";import{doc as Za,getDoc as Ka,where as ta,orderBy as pa,limit as zt,getDocs as It,query as Mt,collection as Bt}from"./vendor-firebase-firestore-CH1lNiRF.js";import{$ as q,a0 as ha,a1 as ba,a2 as Ie,a3 as Ja}from"./vendor-firebase-core-CO26nNq6.js";import{B as A}from"./button-DCfeFHoH.js";import{a as te,b as le,c as ie,e as pe,d as ge,C as aa}from"./card-D4dmQVNb.js";import{f as es,g as ts}from"./vendor-radix-BorKzPz9.js";import{S as _e,a as Se,b as Ae,c as Ce,d as J}from"./select-DIjxRWza.js";import{I as as}from"./input-D28h_UTJ.js";import{S as sa}from"./switch-CblAJO7o.js";import{S as we}from"./skeleton-Bo6ISWhm.js";import{V as fa,a as ga,M as ss,b as rs}from"./volume-x-Chtf_bSj.js";import{C as ns}from"./CompositeAvatar-Col05lJc.js";import{S as et}from"./sparkles-By-vFjpv.js";import{C as kt}from"./check-BLSo9L0H.js";import{C as Ye}from"./chevron-right-COqGruhh.js";import{S as os}from"./shield-check-Dgisjfmb.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B3jJOD5i.js";import"./chevron-up-Cdvz2TMJ.js";import"./avatarData-BuQSOXo3.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/RewardsModal-DTzrRjNP.js b/assets/RewardsModal-CPyFRkMy.js similarity index 99% rename from assets/RewardsModal-DTzrRjNP.js rename to assets/RewardsModal-CPyFRkMy.js index b885b5da48f392eb61bcb3195926300929e2f888..3f79103ac4c71fe5bc83150b53257cb507844dee 100644 --- a/assets/RewardsModal-DTzrRjNP.js +++ b/assets/RewardsModal-CPyFRkMy.js @@ -1 +1 @@ -import{r as d,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CH1lNiRF.js";import{aI as u,A as j,aJ as U,aK as P,U as B,z as I,aL as $,r as R,aM as L,T as g,aN as M,W as N,R as T,S as q,P as X,O as w,X as v,B as G,Z as H,y as W,x as Z,G as J,a as K,aC as O,f as Q}from"./index-Cb8VeSuW.js";import{X as V}from"./x-CTLBAl-n.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:K,GraduationCap:J,Trophy:Z,Target:W,Zap:H,Brain:G,Star:v,Flame:w,Swords:X,Shield:q,RefreshCw:T,Crown:N,Sun:M,TrendingUp:g,Globe:L,User:R,UserPlus:$,Calendar:I,Users:B,Compass:P,Heart:U,Award:j},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:i})=>{const[y,b]=d.useState(!0),[k,_]=d.useState(new Set),[C,E]=d.useState({});d.useEffect(()=>{if(!o||!i)return;(async()=>{b(!0);try{const t=await O(i);_(new Set(t.map(a=>a.id)));const r=await F(S(Q,"progress",i));r.exists()&&E(r.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,i]);const D=s=>{const{condition:t,threshold:r}=s,a=C;let l=0,f=r??1;switch(t){case"lesson_complete":l=a.totalLessonsCompleted||0;break;case"quiz_complete":l=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":l=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":l=a.consecutiveDaysActive||0;break;case"mastery_xp":l=p;break;case"explore_friend_added":case"social_friend":case"explore_social":l=a.friendsAdded||0;break;case"perfect_score":{l=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(l,f),total:f}},h=u.map(s=>{const t=Y[s.icon.name]??j,r=k.has(s.id),a=D(s);return{id:s.id,icon:t,title:s.title,description:s.description,progress:a?.progress,total:a?.total,unlocked:r,color:r?s.iconColor:"text-slate-500",bgColor:r?s.iconColor.replace("text-","bg-").replace("-500","/10").replace("-400","/10").replace("-600","/10"):"bg-slate-100"}}),z=h.filter(s=>s.unlocked).length;return o?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-8",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:c}),e.jsxs("div",{className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-6 text-white relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_14%_12%,rgba(251,150,187,0.35),transparent_42%),radial-gradient(circle_at_80%_80%,rgba(117,208,106,0.25),transparent_38%)]"}),e.jsxs("div",{className:"flex items-center justify-between mb-4 relative z-10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",u.length," Achievements Unlocked"]})]}),e.jsx("button",{onClick:c,className:"text-white/90 hover:text-white hover:bg-white/20 p-2 rounded-xl transition-colors",children:e.jsx(V,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(N,{size:18,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(v,{size:18,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(w,{size:18,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-2xl font-bold",children:"Check-in"})]})]}),e.jsxs("div",{className:"mt-4 relative z-10",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n]}),e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n+1]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsxs("span",{className:"text-xs text-white/90",children:[x," / ",m," XP"]})}),e.jsx("div",{className:"h-3 bg-white/20 rounded-full overflow-hidden border border-white/20",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full transition-all duration-500 e-w",style:{"--w":`${x/m*100}%`}})})]})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:y?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-[#9956DE] border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628] mb-4",children:"Achievements"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:h.map(s=>{const t=s.icon;return e.jsx("div",{className:`${s.unlocked?"bg-white border-[#9956DE]/25":"bg-[#edf1f7] border-[#dde3eb]"} border-2 rounded-xl p-4 transition-all ${s.unlocked?"shadow-md":"opacity-60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-12 h-12 ${s.bgColor} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(t,{size:24,className:s.color})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:`text-sm font-bold ${s.unlocked?"text-[#0a1628]":"text-slate-500"} font-body`,children:s.title}),s.unlocked&&e.jsx("span",{className:"px-2 py-0.5 bg-[#75D06A] text-white text-[9px] font-bold rounded-full",children:"Unlocked"})]}),e.jsx("p",{className:`text-xs ${s.unlocked?"text-[#5a6578]":"text-slate-500"} mb-2`,children:s.description}),s.progress!==void 0&&s.total!==void 0&&!s.unlocked&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Progress"}),e.jsxs("span",{className:"text-[10px] font-bold text-[#5a6578]",children:[s.progress," / ",s.total]})]}),e.jsx("div",{className:"h-1.5 bg-[#dde3eb] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#7274ED] to-[#1FA7E1] rounded-full transition-all e-w",style:{"--w":`${s.progress/s.total*100}%`}})})]})]})]})},s.id)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-[#7274ED] to-[#1FA7E1] rounded-lg flex items-center justify-center",children:e.jsx(g,{size:16,className:"text-white"})}),e.jsx("h3",{className:"text-base font-display font-bold text-[#0a1628]",children:"How to Earn XP"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{activity:"Complete a video lesson",xp:50},{activity:"Complete exercises",xp:100},{activity:"Perfect quiz score",xp:150},{activity:"Finish a quiz",xp:75},{activity:"Daily check-in",xp:"20-100"}].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-[#1FA7E1] rounded-full"}),e.jsxs("span",{className:"text-xs text-[#5a6578] font-body",children:[s.activity,":"]}),e.jsxs("span",{className:"text-xs font-bold text-[#7274ED]",children:["+",s.xp," XP"]})]},t))})]})]})})]})]}):null};export{me as default}; +import{r as d,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CH1lNiRF.js";import{aI as u,A as j,aJ as U,aK as P,U as B,z as I,aL as $,r as R,aM as L,T as g,aN as M,W as N,R as T,S as q,P as X,O as w,X as v,B as G,Z as H,y as W,x as Z,G as J,a as K,aC as O,f as Q}from"./index-BaOs5Ayg.js";import{X as V}from"./x-TNvtuOD9.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:K,GraduationCap:J,Trophy:Z,Target:W,Zap:H,Brain:G,Star:v,Flame:w,Swords:X,Shield:q,RefreshCw:T,Crown:N,Sun:M,TrendingUp:g,Globe:L,User:R,UserPlus:$,Calendar:I,Users:B,Compass:P,Heart:U,Award:j},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:i})=>{const[y,b]=d.useState(!0),[k,_]=d.useState(new Set),[C,E]=d.useState({});d.useEffect(()=>{if(!o||!i)return;(async()=>{b(!0);try{const t=await O(i);_(new Set(t.map(a=>a.id)));const r=await F(S(Q,"progress",i));r.exists()&&E(r.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,i]);const D=s=>{const{condition:t,threshold:r}=s,a=C;let l=0,f=r??1;switch(t){case"lesson_complete":l=a.totalLessonsCompleted||0;break;case"quiz_complete":l=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":l=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":l=a.consecutiveDaysActive||0;break;case"mastery_xp":l=p;break;case"explore_friend_added":case"social_friend":case"explore_social":l=a.friendsAdded||0;break;case"perfect_score":{l=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(l,f),total:f}},h=u.map(s=>{const t=Y[s.icon.name]??j,r=k.has(s.id),a=D(s);return{id:s.id,icon:t,title:s.title,description:s.description,progress:a?.progress,total:a?.total,unlocked:r,color:r?s.iconColor:"text-slate-500",bgColor:r?s.iconColor.replace("text-","bg-").replace("-500","/10").replace("-400","/10").replace("-600","/10"):"bg-slate-100"}}),z=h.filter(s=>s.unlocked).length;return o?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-8",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:c}),e.jsxs("div",{className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-6 text-white relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_14%_12%,rgba(251,150,187,0.35),transparent_42%),radial-gradient(circle_at_80%_80%,rgba(117,208,106,0.25),transparent_38%)]"}),e.jsxs("div",{className:"flex items-center justify-between mb-4 relative z-10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",u.length," Achievements Unlocked"]})]}),e.jsx("button",{onClick:c,className:"text-white/90 hover:text-white hover:bg-white/20 p-2 rounded-xl transition-colors",children:e.jsx(V,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(N,{size:18,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(v,{size:18,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(w,{size:18,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-2xl font-bold",children:"Check-in"})]})]}),e.jsxs("div",{className:"mt-4 relative z-10",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n]}),e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n+1]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsxs("span",{className:"text-xs text-white/90",children:[x," / ",m," XP"]})}),e.jsx("div",{className:"h-3 bg-white/20 rounded-full overflow-hidden border border-white/20",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full transition-all duration-500 e-w",style:{"--w":`${x/m*100}%`}})})]})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:y?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-[#9956DE] border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628] mb-4",children:"Achievements"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:h.map(s=>{const t=s.icon;return e.jsx("div",{className:`${s.unlocked?"bg-white border-[#9956DE]/25":"bg-[#edf1f7] border-[#dde3eb]"} border-2 rounded-xl p-4 transition-all ${s.unlocked?"shadow-md":"opacity-60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-12 h-12 ${s.bgColor} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(t,{size:24,className:s.color})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:`text-sm font-bold ${s.unlocked?"text-[#0a1628]":"text-slate-500"} font-body`,children:s.title}),s.unlocked&&e.jsx("span",{className:"px-2 py-0.5 bg-[#75D06A] text-white text-[9px] font-bold rounded-full",children:"Unlocked"})]}),e.jsx("p",{className:`text-xs ${s.unlocked?"text-[#5a6578]":"text-slate-500"} mb-2`,children:s.description}),s.progress!==void 0&&s.total!==void 0&&!s.unlocked&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Progress"}),e.jsxs("span",{className:"text-[10px] font-bold text-[#5a6578]",children:[s.progress," / ",s.total]})]}),e.jsx("div",{className:"h-1.5 bg-[#dde3eb] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#7274ED] to-[#1FA7E1] rounded-full transition-all e-w",style:{"--w":`${s.progress/s.total*100}%`}})})]})]})]})},s.id)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-[#7274ED] to-[#1FA7E1] rounded-lg flex items-center justify-center",children:e.jsx(g,{size:16,className:"text-white"})}),e.jsx("h3",{className:"text-base font-display font-bold text-[#0a1628]",children:"How to Earn XP"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{activity:"Complete a video lesson",xp:50},{activity:"Complete exercises",xp:100},{activity:"Perfect quiz score",xp:150},{activity:"Finish a quiz",xp:75},{activity:"Daily check-in",xp:"20-100"}].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-[#1FA7E1] rounded-full"}),e.jsxs("span",{className:"text-xs text-[#5a6578] font-body",children:[s.activity,":"]}),e.jsxs("span",{className:"text-xs font-bold text-[#7274ED]",children:["+",s.xp," XP"]})]},t))})]})]})})]})]}):null};export{me as default}; diff --git a/assets/RightSidebar-BDjjmpc8.js b/assets/RightSidebar-CmYzVUKQ.js similarity index 97% rename from assets/RightSidebar-BDjjmpc8.js rename to assets/RightSidebar-CmYzVUKQ.js index c32ad120d3e895ce627811a7b379722e929754e5..f210c82d273333f64ab1ae0e635e30b655fed416 100644 --- a/assets/RightSidebar-BDjjmpc8.js +++ b/assets/RightSidebar-CmYzVUKQ.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{j as B,m as c,Z as _,P,V as q,x as W,W as v,X,l as Y,r as k}from"./index-Cb8VeSuW.js";import{C as M}from"./circle-check-big-CNGbqkWz.js";import{T as O,a as Z,b as H}from"./tooltip-BY91VKdD.js";import{C as T}from"./chevron-right-CoVWpXdD.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const E=[{id:1,title:"Quiz Battle",subtitle:"Challenge players worldwide!",bgColor:"bg-[#9956de]",orbColor:"bg-[#6D28D9]",icon:e.jsx(P,{size:24,className:"text-white"}),buttonText:"Join Battle",actionType:"quiz-battle",avatarText:"Waiting for you to join..."},{id:2,title:"Topic Explorer",subtitle:"Dive into a new math topic today",bgColor:"bg-[#FF8B8B]",orbColor:"bg-[#E06A6A]",icon:e.jsx(_,{size:24,className:"text-white"}),buttonText:"Explore",actionType:"explore",avatarText:"Knowledge is power!"},{id:3,title:"Speed Runner",subtitle:"Finish a quiz in under 5 mins",bgColor:"bg-[#75D06A]",orbColor:"bg-[#58B34D]",icon:e.jsx(M,{size:24,className:"text-white"}),buttonText:null,actionType:null,avatarText:"Ready for action!"}],J=({onNavigateToQuizBattle:s,userPhoto:a})=>{const[x,m]=l.useState(0);l.useEffect(()=>{const r=setInterval(()=>{m(o=>(o+1)%E.length)},5e3);return()=>clearInterval(r)},[]);const t=E[x];return e.jsx("div",{className:"bg-white rounded-[24px] p-4 shadow-sm border border-slate-100 flex flex-col gap-6 mt-4 relative overflow-hidden",children:e.jsx("div",{className:"relative h-[185px] rounded-[-20px] rounded-2xl overflow-hidden cursor-pointer group",children:e.jsx(B,{mode:"wait",children:e.jsxs(c.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:`absolute inset-0 ${t.bgColor} p-4 sm:p-5 flex flex-col justify-between overflow-hidden`,children:[e.jsxs("div",{className:"absolute top-4 right-4 flex gap-1 items-center z-20",children:[e.jsx("div",{className:"w-3 h-1.5 rounded-full bg-white/60"}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40"}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40"})]}),t.actionType==="quiz-battle"&&e.jsx("div",{className:"absolute -right-4 -bottom-6 w-32 h-32 opacity-25 mix-blend-overlay pointer-events-none z-0 transform group-hover:scale-105 transition-transform duration-700",children:e.jsx("img",{src:S,alt:"",className:"w-full h-full object-contain"})}),e.jsx("div",{className:`absolute -right-4 -top-8 w-36 h-36 rounded-full ${t.orbColor} opacity-90 blur-2xl group-hover:scale-110 transition-transform duration-700 pointer-events-none`}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 w-[48px] h-[48px] rounded-2xl rotate-12 bg-white/20 backdrop-blur-md shadow-sm border border-white/20 group-hover:rotate-[25deg] group-hover:scale-110 transition-transform duration-700 flex items-center justify-center z-10",children:t.icon}),e.jsxs("div",{className:"relative z-10 w-full pr-[60px]",children:[e.jsx("h3",{className:"font-display font-bold text-[20px] leading-tight text-white mb-0.5",children:t.title}),e.jsx("p",{className:"text-[12px] font-medium text-white/90 leading-snug",children:t.subtitle}),t.buttonText&&e.jsx("button",{onClick:r=>{r.stopPropagation(),t.actionType==="quiz-battle"&&s&&s()},className:"mt-2.5 bg-white text-[#0a1628] px-2 py-1 rounded-lg font-bold text-xs shadow-sm hover:scale-105 transition-transform uppercase tracking-wider whitespace-nowrap w-fit",children:t.buttonText})]}),e.jsxs("div",{className:"flex items-center gap-2.5 relative z-10 mt-auto pt-2",children:[a?e.jsxs("div",{className:"relative group/avatar shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-white/40 blur-md rounded-full animate-pulse"}),e.jsx("img",{src:a,alt:"You",className:"w-8 h-8 rounded-full border-[2px] border-white object-cover relative z-10 shadow-md group-hover/avatar:scale-110 transition-transform"}),t.actionType==="quiz-battle"&&e.jsx("div",{className:"absolute -bottom-1 -right-1 w-[16px] h-[16px] bg-[#75D06A] border-2 border-[#7C3AED] rounded-full z-20 flex items-center justify-center",children:e.jsx(_,{size:8,className:"text-white",fill:"currentColor"})})]}):null,e.jsx("span",{className:"text-[12px] font-bold text-white tracking-wide leading-tight flex-1 pr-[60px]",children:t.avatarText})]})]},t.id)})})})},K=s=>{if(s>=1e3){const a=s/1e3;return a>=10?`${Math.round(a)}k`:`${a.toFixed(1)}k`}return`${s}`},V=({entry:s,rank:a,isYou:x,userPhoto:m,rankColor:t})=>{const r=x?s?.photo||m:s?.photo,o=x?"You":s?.name||"---",h=s?.xp||0;return e.jsxs(e.Fragment,{children:[e.jsxs(c.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3+a*.1},className:"relative mb-2",children:[a===1&&e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 z-20",children:e.jsx(v,{size:22,className:"text-amber-400 drop-shadow-md mb-1",fill:"#fbbf24",strokeWidth:1.5})}),e.jsx("div",{className:`w-10 h-10 rounded-full border-[3px] ${a===1?"w-[52px] h-[52px]":""} ${t.border} z-10 relative overflow-hidden ${t.shadow} bg-white`,children:r?e.jsx("img",{src:r,alt:o,className:"w-full h-full object-cover",onError:f=>{f.target.style.display="none"}}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-slate-200 to-slate-300 flex items-center justify-center",children:e.jsx(k,{size:a===1?22:16,className:"text-slate-400"})})}),e.jsx("div",{className:`absolute -bottom-2 left-1/2 -translate-x-1/2 ${t.badge} text-white text-[10px] font-bold px-2 py-0.5 rounded-full z-20 shadow-sm`,children:a})]}),e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("span",{className:`block ${a===1?"text-[13px] font-black":"text-[12px] font-bold"} text-[#0a1628] truncate max-w-[80px]`,children:o}),e.jsxs("span",{className:`block ${a===1?"text-[11px]":"text-[10px]"} ${t.badge.replace("bg-","text-").replace("-500","-600").replace("-400","-600").replace("amber","amber")} font-bold`,children:[K(h)," XP"]})]})]})},ce=({currentUserId:s,onOpenRewards:a,onOpenLeaderboard:x,onNavigateToModules:m,onNavigateToQuizBattle:t,userLevel:r,userPhoto:o,currentXP:h,xpToNextLevel:f})=>{const N=h/f*100,[$,D]=l.useState([]),[F,u]=l.useState(!0),[y,g]=l.useState(null),p=l.useRef(null),n=l.useRef(null);l.useEffect(()=>{if(!s){u(!1);return}u(!0),g(null);const d=q(b=>{D(b),u(!1),g(null),n.current&&(clearTimeout(n.current),n.current=null)},s,!1,"all",3);return p.current=d,n.current=setTimeout(()=>{u(!1),g("Leaderboard data unavailable")},15e3),()=>{n.current&&(clearTimeout(n.current),n.current=null),p.current&&(p.current(),p.current=null)}},[s]);const i=$.slice(0,3);i.some(d=>d.userId===s);const z=[{bg:"from-amber-100 to-amber-50",border:"border-amber-400",badge:"bg-amber-500",shadow:"shadow-md"},{bg:"from-slate-200 to-slate-100",border:"border-sky-400",badge:"bg-sky-500",shadow:"shadow-sm"},{bg:"from-orange-50 to-slate-50",border:"border-orange-400",badge:"bg-orange-500",shadow:"shadow-sm"}],A=["74px","54px","38px"],L=["w-[78px]","w-[70px]","w-[70px]"],j=(d,b,C,R,w)=>e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx(V,{entry:d,rank:C,isYou:R==="You",userPhoto:o,rankColor:z[w]}),e.jsxs(c.div,{initial:{height:0},animate:{height:A[b]},transition:{delay:.2+b*.1,duration:.5,ease:"easeOut"},className:`${L[b]} bg-gradient-to-b ${z[w].bg} rounded-t-xl rounded-b-md border-t-2 border-white/20 flex items-center justify-center relative shadow-[inset_0_-4px_6px_rgba(0,0,0,0.05),0_4px_6px_rgba(0,0,0,0.05)]`,children:[e.jsx("span",{className:`${w===0?"text-amber-400 text-3xl":"text-slate-400 text-2xl"} font-black opacity-40 translate-y-1`,children:C}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 bg-white/70 rounded-t-xl"})]})]});return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4,ease:[.22,1,.36,1]},onClick:a,className:"rounded-2xl border border-[#9956DE]/25 cursor-pointer transition-all group relative overflow-hidden bg-gradient-to-br from-[#9956DE] via-[#7274ED] to-[#1FA7E1] hover:shadow-[0_16px_40px_rgba(114,116,237,0.28)] hover:-translate-y-0.5",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_18%_8%,rgba(251,150,187,0.32),transparent_42%),radial-gradient(circle_at_85%_84%,rgba(117,208,106,0.24),transparent_40%)]"}),e.jsxs("div",{className:"relative z-10 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"shrink-0 w-8 h-8 bg-white/20 rounded-xl flex items-center justify-center border border-white/35 backdrop-blur-sm",children:e.jsx(W,{size:14,className:"text-white"})}),e.jsxs("h3",{className:"font-display font-bold text-[13px] leading-tight text-white tracking-wide",children:["Rewards & ",e.jsx("br",{className:"hidden 2xl:block"})," Achievements"]})]}),e.jsx(T,{size:14,className:"shrink-0 text-white/80 group-hover:text-white group-hover:translate-x-0.5 transition-all"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1 mb-3 bg-white/10 p-1.5 rounded-xl border border-white/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-body px-1 text-white",children:[e.jsx(v,{size:12,className:"text-[#FFB356]"}),e.jsxs("span",{className:"font-bold",children:["Lv ",r]})]}),e.jsx("div",{className:"w-px h-3 bg-white/35"}),e.jsxs(O,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("button",{onClick:d=>{d.stopPropagation(),m?.()},className:"flex items-center gap-1.5 text-xs font-body px-1 text-white cursor-pointer transition-colors active:scale-95",children:[e.jsx(X,{size:12,className:"text-[#6ED1CF]"}),e.jsxs("span",{className:"font-bold whitespace-nowrap",children:[h," XP"]})]})}),e.jsx(H,{side:"top",className:"bg-slate-900 text-white border border-slate-700",children:"Review more lessons to earn more XP!"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[e.jsxs("span",{className:"text-[11px] font-body text-white/90",children:["Next: Level ",r+1]}),e.jsxs("span",{className:"text-[11px] font-body font-semibold text-white",children:[Math.round(N),"%"]})]}),e.jsx("div",{className:"h-2 bg-white/25 rounded-full overflow-hidden border border-white/20",children:e.jsx(c.div,{initial:{width:0},animate:{width:`${N}%`},transition:{duration:1,ease:"easeOut"},className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full"})})]})]})]}),e.jsx(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.2,duration:.4,ease:[.22,1,.36,1]},children:e.jsx(J,{onNavigateToQuizBattle:t,userPhoto:o})}),e.jsxs(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.3,duration:.4,ease:[.22,1,.36,1]},onClick:x,className:"bg-white rounded-xl border border-slate-200/80 hover:shadow-md hover:border-amber-200/60 transition-all group overflow-hidden cursor-pointer",children:[e.jsxs("div",{className:"p-3 border-b border-slate-100 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 bg-amber-50 rounded-lg flex items-center justify-center border border-amber-200/60 transition-colors group-hover:bg-amber-100/50",children:e.jsx(v,{size:14,className:"text-amber-500"})}),e.jsx("h3",{className:"font-display font-bold text-sm text-[#0a1628]",children:"Leaderboards"})]}),e.jsx(T,{size:14,className:"text-slate-400 group-hover:translate-x-0.5 group-hover:text-amber-500 transition-transform"})]}),e.jsx("div",{className:"pt-8 pb-3 px-2 bg-gradient-to-b from-slate-50/30 to-white flex items-end justify-center gap-1.5 min-h-[170px]",children:F?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8",children:[e.jsx(Y,{className:"w-5 h-5 animate-spin text-amber-400 mb-2"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Loading rankings..."})]}):y||i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8",children:[e.jsx(k,{className:"w-8 h-8 text-slate-300 mb-2"}),e.jsx("span",{className:"text-xs text-slate-400 text-center",children:y||"No rankings available yet"})]}):e.jsxs(e.Fragment,{children:[j(i[1],1,2,i[1]?.name||"---",1),j(i[0],0,1,i[0]?.name||"---",0),j(i[2],2,3,i[2]?.name||"---",2)]})})]})]})};export{ce as default}; +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{j as B,m as c,Z as _,P,V as q,x as W,W as v,X,l as Y,r as k}from"./index-BaOs5Ayg.js";import{C as M}from"./circle-check-big-m1SvzGFL.js";import{T as O,a as Z,b as H}from"./tooltip-ChRIOid3.js";import{C as T}from"./chevron-right-COqGruhh.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const E=[{id:1,title:"Quiz Battle",subtitle:"Challenge players worldwide!",bgColor:"bg-[#9956de]",orbColor:"bg-[#6D28D9]",icon:e.jsx(P,{size:24,className:"text-white"}),buttonText:"Join Battle",actionType:"quiz-battle",avatarText:"Waiting for you to join..."},{id:2,title:"Topic Explorer",subtitle:"Dive into a new math topic today",bgColor:"bg-[#FF8B8B]",orbColor:"bg-[#E06A6A]",icon:e.jsx(_,{size:24,className:"text-white"}),buttonText:"Explore",actionType:"explore",avatarText:"Knowledge is power!"},{id:3,title:"Speed Runner",subtitle:"Finish a quiz in under 5 mins",bgColor:"bg-[#75D06A]",orbColor:"bg-[#58B34D]",icon:e.jsx(M,{size:24,className:"text-white"}),buttonText:null,actionType:null,avatarText:"Ready for action!"}],J=({onNavigateToQuizBattle:s,userPhoto:a})=>{const[x,m]=l.useState(0);l.useEffect(()=>{const r=setInterval(()=>{m(o=>(o+1)%E.length)},5e3);return()=>clearInterval(r)},[]);const t=E[x];return e.jsx("div",{className:"bg-white rounded-[24px] p-4 shadow-sm border border-slate-100 flex flex-col gap-6 mt-4 relative overflow-hidden",children:e.jsx("div",{className:"relative h-[185px] rounded-[-20px] rounded-2xl overflow-hidden cursor-pointer group",children:e.jsx(B,{mode:"wait",children:e.jsxs(c.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:`absolute inset-0 ${t.bgColor} p-4 sm:p-5 flex flex-col justify-between overflow-hidden`,children:[e.jsxs("div",{className:"absolute top-4 right-4 flex gap-1 items-center z-20",children:[e.jsx("div",{className:"w-3 h-1.5 rounded-full bg-white/60"}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40"}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/40"})]}),t.actionType==="quiz-battle"&&e.jsx("div",{className:"absolute -right-4 -bottom-6 w-32 h-32 opacity-25 mix-blend-overlay pointer-events-none z-0 transform group-hover:scale-105 transition-transform duration-700",children:e.jsx("img",{src:S,alt:"",className:"w-full h-full object-contain"})}),e.jsx("div",{className:`absolute -right-4 -top-8 w-36 h-36 rounded-full ${t.orbColor} opacity-90 blur-2xl group-hover:scale-110 transition-transform duration-700 pointer-events-none`}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 w-[48px] h-[48px] rounded-2xl rotate-12 bg-white/20 backdrop-blur-md shadow-sm border border-white/20 group-hover:rotate-[25deg] group-hover:scale-110 transition-transform duration-700 flex items-center justify-center z-10",children:t.icon}),e.jsxs("div",{className:"relative z-10 w-full pr-[60px]",children:[e.jsx("h3",{className:"font-display font-bold text-[20px] leading-tight text-white mb-0.5",children:t.title}),e.jsx("p",{className:"text-[12px] font-medium text-white/90 leading-snug",children:t.subtitle}),t.buttonText&&e.jsx("button",{onClick:r=>{r.stopPropagation(),t.actionType==="quiz-battle"&&s&&s()},className:"mt-2.5 bg-white text-[#0a1628] px-2 py-1 rounded-lg font-bold text-xs shadow-sm hover:scale-105 transition-transform uppercase tracking-wider whitespace-nowrap w-fit",children:t.buttonText})]}),e.jsxs("div",{className:"flex items-center gap-2.5 relative z-10 mt-auto pt-2",children:[a?e.jsxs("div",{className:"relative group/avatar shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-white/40 blur-md rounded-full animate-pulse"}),e.jsx("img",{src:a,alt:"You",className:"w-8 h-8 rounded-full border-[2px] border-white object-cover relative z-10 shadow-md group-hover/avatar:scale-110 transition-transform"}),t.actionType==="quiz-battle"&&e.jsx("div",{className:"absolute -bottom-1 -right-1 w-[16px] h-[16px] bg-[#75D06A] border-2 border-[#7C3AED] rounded-full z-20 flex items-center justify-center",children:e.jsx(_,{size:8,className:"text-white",fill:"currentColor"})})]}):null,e.jsx("span",{className:"text-[12px] font-bold text-white tracking-wide leading-tight flex-1 pr-[60px]",children:t.avatarText})]})]},t.id)})})})},K=s=>{if(s>=1e3){const a=s/1e3;return a>=10?`${Math.round(a)}k`:`${a.toFixed(1)}k`}return`${s}`},V=({entry:s,rank:a,isYou:x,userPhoto:m,rankColor:t})=>{const r=x?s?.photo||m:s?.photo,o=x?"You":s?.name||"---",h=s?.xp||0;return e.jsxs(e.Fragment,{children:[e.jsxs(c.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3+a*.1},className:"relative mb-2",children:[a===1&&e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 z-20",children:e.jsx(v,{size:22,className:"text-amber-400 drop-shadow-md mb-1",fill:"#fbbf24",strokeWidth:1.5})}),e.jsx("div",{className:`w-10 h-10 rounded-full border-[3px] ${a===1?"w-[52px] h-[52px]":""} ${t.border} z-10 relative overflow-hidden ${t.shadow} bg-white`,children:r?e.jsx("img",{src:r,alt:o,className:"w-full h-full object-cover",onError:f=>{f.target.style.display="none"}}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-slate-200 to-slate-300 flex items-center justify-center",children:e.jsx(k,{size:a===1?22:16,className:"text-slate-400"})})}),e.jsx("div",{className:`absolute -bottom-2 left-1/2 -translate-x-1/2 ${t.badge} text-white text-[10px] font-bold px-2 py-0.5 rounded-full z-20 shadow-sm`,children:a})]}),e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("span",{className:`block ${a===1?"text-[13px] font-black":"text-[12px] font-bold"} text-[#0a1628] truncate max-w-[80px]`,children:o}),e.jsxs("span",{className:`block ${a===1?"text-[11px]":"text-[10px]"} ${t.badge.replace("bg-","text-").replace("-500","-600").replace("-400","-600").replace("amber","amber")} font-bold`,children:[K(h)," XP"]})]})]})},ce=({currentUserId:s,onOpenRewards:a,onOpenLeaderboard:x,onNavigateToModules:m,onNavigateToQuizBattle:t,userLevel:r,userPhoto:o,currentXP:h,xpToNextLevel:f})=>{const N=h/f*100,[$,D]=l.useState([]),[F,u]=l.useState(!0),[y,g]=l.useState(null),p=l.useRef(null),n=l.useRef(null);l.useEffect(()=>{if(!s){u(!1);return}u(!0),g(null);const d=q(b=>{D(b),u(!1),g(null),n.current&&(clearTimeout(n.current),n.current=null)},s,!1,"all",3);return p.current=d,n.current=setTimeout(()=>{u(!1),g("Leaderboard data unavailable")},15e3),()=>{n.current&&(clearTimeout(n.current),n.current=null),p.current&&(p.current(),p.current=null)}},[s]);const i=$.slice(0,3);i.some(d=>d.userId===s);const z=[{bg:"from-amber-100 to-amber-50",border:"border-amber-400",badge:"bg-amber-500",shadow:"shadow-md"},{bg:"from-slate-200 to-slate-100",border:"border-sky-400",badge:"bg-sky-500",shadow:"shadow-sm"},{bg:"from-orange-50 to-slate-50",border:"border-orange-400",badge:"bg-orange-500",shadow:"shadow-sm"}],A=["74px","54px","38px"],L=["w-[78px]","w-[70px]","w-[70px]"],j=(d,b,C,R,w)=>e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx(V,{entry:d,rank:C,isYou:R==="You",userPhoto:o,rankColor:z[w]}),e.jsxs(c.div,{initial:{height:0},animate:{height:A[b]},transition:{delay:.2+b*.1,duration:.5,ease:"easeOut"},className:`${L[b]} bg-gradient-to-b ${z[w].bg} rounded-t-xl rounded-b-md border-t-2 border-white/20 flex items-center justify-center relative shadow-[inset_0_-4px_6px_rgba(0,0,0,0.05),0_4px_6px_rgba(0,0,0,0.05)]`,children:[e.jsx("span",{className:`${w===0?"text-amber-400 text-3xl":"text-slate-400 text-2xl"} font-black opacity-40 translate-y-1`,children:C}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 bg-white/70 rounded-t-xl"})]})]});return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4,ease:[.22,1,.36,1]},onClick:a,className:"rounded-2xl border border-[#9956DE]/25 cursor-pointer transition-all group relative overflow-hidden bg-gradient-to-br from-[#9956DE] via-[#7274ED] to-[#1FA7E1] hover:shadow-[0_16px_40px_rgba(114,116,237,0.28)] hover:-translate-y-0.5",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_18%_8%,rgba(251,150,187,0.32),transparent_42%),radial-gradient(circle_at_85%_84%,rgba(117,208,106,0.24),transparent_40%)]"}),e.jsxs("div",{className:"relative z-10 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"shrink-0 w-8 h-8 bg-white/20 rounded-xl flex items-center justify-center border border-white/35 backdrop-blur-sm",children:e.jsx(W,{size:14,className:"text-white"})}),e.jsxs("h3",{className:"font-display font-bold text-[13px] leading-tight text-white tracking-wide",children:["Rewards & ",e.jsx("br",{className:"hidden 2xl:block"})," Achievements"]})]}),e.jsx(T,{size:14,className:"shrink-0 text-white/80 group-hover:text-white group-hover:translate-x-0.5 transition-all"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1 mb-3 bg-white/10 p-1.5 rounded-xl border border-white/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-body px-1 text-white",children:[e.jsx(v,{size:12,className:"text-[#FFB356]"}),e.jsxs("span",{className:"font-bold",children:["Lv ",r]})]}),e.jsx("div",{className:"w-px h-3 bg-white/35"}),e.jsxs(O,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("button",{onClick:d=>{d.stopPropagation(),m?.()},className:"flex items-center gap-1.5 text-xs font-body px-1 text-white cursor-pointer transition-colors active:scale-95",children:[e.jsx(X,{size:12,className:"text-[#6ED1CF]"}),e.jsxs("span",{className:"font-bold whitespace-nowrap",children:[h," XP"]})]})}),e.jsx(H,{side:"top",className:"bg-slate-900 text-white border border-slate-700",children:"Review more lessons to earn more XP!"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[e.jsxs("span",{className:"text-[11px] font-body text-white/90",children:["Next: Level ",r+1]}),e.jsxs("span",{className:"text-[11px] font-body font-semibold text-white",children:[Math.round(N),"%"]})]}),e.jsx("div",{className:"h-2 bg-white/25 rounded-full overflow-hidden border border-white/20",children:e.jsx(c.div,{initial:{width:0},animate:{width:`${N}%`},transition:{duration:1,ease:"easeOut"},className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full"})})]})]})]}),e.jsx(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.2,duration:.4,ease:[.22,1,.36,1]},children:e.jsx(J,{onNavigateToQuizBattle:t,userPhoto:o})}),e.jsxs(c.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.3,duration:.4,ease:[.22,1,.36,1]},onClick:x,className:"bg-white rounded-xl border border-slate-200/80 hover:shadow-md hover:border-amber-200/60 transition-all group overflow-hidden cursor-pointer",children:[e.jsxs("div",{className:"p-3 border-b border-slate-100 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 bg-amber-50 rounded-lg flex items-center justify-center border border-amber-200/60 transition-colors group-hover:bg-amber-100/50",children:e.jsx(v,{size:14,className:"text-amber-500"})}),e.jsx("h3",{className:"font-display font-bold text-sm text-[#0a1628]",children:"Leaderboards"})]}),e.jsx(T,{size:14,className:"text-slate-400 group-hover:translate-x-0.5 group-hover:text-amber-500 transition-transform"})]}),e.jsx("div",{className:"pt-8 pb-3 px-2 bg-gradient-to-b from-slate-50/30 to-white flex items-end justify-center gap-1.5 min-h-[170px]",children:F?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8",children:[e.jsx(Y,{className:"w-5 h-5 animate-spin text-amber-400 mb-2"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Loading rankings..."})]}):y||i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8",children:[e.jsx(k,{className:"w-8 h-8 text-slate-300 mb-2"}),e.jsx("span",{className:"text-xs text-slate-400 text-center",children:y||"No rankings available yet"})]}):e.jsxs(e.Fragment,{children:[j(i[1],1,2,i[1]?.name||"---",1),j(i[0],0,1,i[0]?.name||"---",0),j(i[2],2,3,i[2]?.name||"---",2)]})})]})]})};export{ce as default}; diff --git a/assets/ScientificCalculator-CLmkIayw.js b/assets/ScientificCalculator-DRuSfTXj.js similarity index 99% rename from assets/ScientificCalculator-CLmkIayw.js rename to assets/ScientificCalculator-DRuSfTXj.js index 6d0a47ab4ad21fbdde173e7180ea7648a99cefe0..49ec7e4983172fef51db8c50523103ef035acfae 100644 --- a/assets/ScientificCalculator-CLmkIayw.js +++ b/assets/ScientificCalculator-DRuSfTXj.js @@ -1,4 +1,4 @@ -import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{e as Z,h as de,j as U,m as ue}from"./index-Cb8VeSuW.js";import{C as fe,a as pe}from"./chevron-up-Byo9SJJ4.js";import{X as be}from"./x-CTLBAl-n.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{e as Z,h as de,j as U,m as ue}from"./index-BaOs5Ayg.js";import{C as fe,a as pe}from"./chevron-up-Cdvz2TMJ.js";import{X as be}from"./x-TNvtuOD9.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/SettingsModal-BVXFPk7A.js b/assets/SettingsModal-BVXFPk7A.js deleted file mode 100644 index 48fbd10f8a733f42c6da7c533f3717093356f9a9..0000000000000000000000000000000000000000 --- a/assets/SettingsModal-BVXFPk7A.js +++ /dev/null @@ -1,11 +0,0 @@ -import{r,j as e}from"./vendor-react-B4AQeu28.js";import{S as ge,a as Ne,c as ve,d as D}from"./select-CqJdJ0KN.js";import{e as ie,r as we,S as ke,aM as Ce,j as Se,m as E,L as Ee,aP as ze,t as d}from"./index-Cb8VeSuW.js";import{B as x}from"./button-De2q2xHf.js";import{I as l}from"./input-w3MoyecB.js";import{S as m}from"./switch-KjWJg4zs.js";import ee from"./ConfirmModal-B7469iTj.js";import{P as Pe,M as se,V as te}from"./ProfilePictureUploader-viKg_Exm.js";import{B as Ae}from"./bell-DsHB20Hc.js";import{D as ae}from"./download-C-V0pYsk.js";import{X as ne}from"./x-CTLBAl-n.js";import{C as re}from"./circle-help-hn0lWYq9.js";import{C as Re}from"./clock-BodmJJnp.js";import{T as Me}from"./trash-2-DB-oXtbr.js";import{E as Te,a as Fe}from"./eye-DBkZRvYD.js";import"./vendor-radix-BorKzPz9.js";import"./chevron-up-Byo9SJJ4.js";import"./check-DSwzaW4Y.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-CM6AS10M.js";import"./minus-CMQilTBg.js";import"./plus-uFWGSQCY.js";import"./upload-D5cppfxb.js";/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qe=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],Ie=ie("palette",qe);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Le=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],De=ie("smartphone",Le),_=()=>JSON.parse(JSON.stringify(ze)),us=({isOpen:f,onClose:N,profileData:o,onSave:H,settingsData:w,onSaveSettings:O,onApplySettingsPreview:v,onUpdatePassword:z,onExportData:U,onClearCache:V,onDeleteAccount:P,onResetData:k})=>{const[h,le]=r.useState("account"),[a,c]=r.useState({}),[n,G]=r.useState(_()),[A,Q]=r.useState(!1),[j,X]=r.useState(!1),[R,B]=r.useState(!1),[M,J]=r.useState(!1),[y,$]=r.useState(!1),[oe,C]=r.useState(!1),[ce,S]=r.useState(!1),[de,g]=r.useState(!1),[u,K]=r.useState(!1),[W,b]=r.useState(""),[T,p]=r.useState(!1),F=r.useRef(!1),q=r.useRef(_());r.useEffect(()=>{if(!f){F.current=!1;return}if(F.current)return;F.current=!0;const s=w?JSON.parse(JSON.stringify(w)):_();q.current=s,c({uid:o?.uid,name:o?.name||"",email:o?.email||"",phone:o?.phone||"",photo:o?.photo||"",avatarLayers:o?.avatarLayers,role:o?.role,gender:o?.gender,lrn:o?.lrn||"",grade:o?.grade||"",section:o?.section||"",school:o?.school||"",department:o?.department||"",subject:o?.subject||"",yearsOfExperience:o?.yearsOfExperience||"",qualification:o?.qualification||"",position:o?.position||""}),G(s)},[f,o,w]),r.useEffect(()=>{f&&v?.(n)},[f,n,v]),r.useEffect(()=>{if(!f)return;const s=t=>{t.key==="Escape"&&(v?.(q.current),N())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[f,N,v,w]);const Y=r.useMemo(()=>[{id:"account",label:"Account",icon:we},{id:"notifications",label:"Notifications",icon:Ae},{id:"appearance",label:"Appearance",icon:Ie},{id:"privacy",label:"Privacy & Security",icon:ke},{id:"learning",label:"Learning",icon:Ce},{id:"data",label:"Data & Storage",icon:ae}],[]),i=s=>{G(t=>s(t))},xe=async()=>{Q(!0);try{H&&await H(a),O&&await O(n),N()}catch(s){console.error("Error saving settings:",s),d.error(s instanceof Error?s.message:"Failed to save settings")}finally{Q(!1)}},I=()=>{C(!1),S(!1),g(!1),b(""),p(!1),v?.(q.current),N()},me=()=>{!k||j||C(!0)},he=async()=>{if(!(!k||j)){C(!1),X(!0);try{await k(),d.success("Testing data reset completed")}catch(s){console.error("Error resetting testing data:",s),d.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{X(!1)}}},ue=async()=>{if(!z){d.info("Password update is not available in this environment.");return}b(""),p(!1),g(!0)},Z=async()=>{if(!z||u)return;const s=W.trim();if(!s){d.error("Password is required.");return}if(s.length<8){d.error("Password must be at least 8 characters long.");return}K(!0);try{await z(s),d.success("Password updated successfully."),g(!1),b(""),p(!1)}catch(t){console.error("Error updating password:",t),d.error(t instanceof Error?t.message:"Failed to update password")}finally{K(!1)}},fe=()=>{d.info("Two-factor authentication setup is not enabled for this project yet.")},be=async()=>{if(!U||R){d.info("Data export is not available right now.");return}B(!0);try{await U()}catch(s){console.error("Error exporting data:",s),d.error(s instanceof Error?s.message:"Failed to export data")}finally{B(!1)}},pe=async()=>{if(!V||M){d.info("Cache clearing is not available right now.");return}J(!0);try{await V()}catch(s){console.error("Error clearing cache:",s),d.error(s instanceof Error?s.message:"Failed to clear cache")}finally{J(!1)}},je=()=>{if(!P||y){d.info("Account deletion is not available right now.");return}S(!0)},ye=async()=>{if(!(!P||y)){S(!1),$(!0);try{await P(),N()}catch(s){console.error("Error deleting account:",s),d.error(s instanceof Error?s.message:"Failed to delete account")}finally{$(!1)}}};return f?e.jsx(Se,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:I,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(E.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-4xl max-h-[85vh] overflow-hidden flex",children:[e.jsxs("div",{className:"w-64 bg-slate-50 border-r border-slate-200 p-6 overflow-y-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-[#0a1628]",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Manage your preferences"})]}),e.jsx("nav",{className:"space-y-1",children:Y.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>le(s.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all ${h===s.id?"bg-sky-50 text-sky-700 shadow-sm":"text-slate-500 hover:bg-slate-100 hover:text-sky-700"}`,children:[e.jsx(t,{size:18}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]},s.id)})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:Y.find(s=>s.id===h)?.label}),e.jsx("button",{onClick:I,className:"p-2 hover:bg-[#edf1f7] rounded-xl transition-colors",children:e.jsx(ne,{size:20,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{uid:a.uid,photoURL:a.photo,displayName:a.name,onUploaded:s=>c(t=>({...t,photo:s}))}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Full Name"}),e.jsx(l,{type:"text",value:a.name||"",onChange:s=>c(t=>({...t,name:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Email Address"}),e.jsx(l,{type:"email",value:a.email||"",onChange:s=>c(t=>({...t,email:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Phone Number"}),e.jsx(l,{type:"tel",value:a.phone||"",onChange:s=>c(t=>({...t,phone:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Gender"}),e.jsxs(ge,{value:a.gender||"",onValueChange:s=>{c(t=>({...t,gender:s||void 0}))},children:[e.jsx(Ne,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg [&>span]:flex [&>span]:items-center [&>span]:gap-2",children:e.jsxs("span",{className:"flex items-center gap-2",children:[a.gender==="male"&&e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]}),a.gender==="female"&&e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]}),a.gender==="prefer_not_to_say"&&e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]}),!a.gender&&e.jsx("span",{className:"text-muted-foreground",children:"Select gender (optional)"})]})}),e.jsxs(ve,{children:[e.jsx(D,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(D,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(D,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),a.role==="student"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Learner's Reference Number (LRN)"}),e.jsx(l,{type:"text",value:a.lrn||"",onChange:s=>c(t=>({...t,lrn:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Grade Level"}),e.jsx(l,{type:"text",value:a.grade||"",onChange:s=>c(t=>({...t,grade:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Section"}),e.jsx(l,{type:"text",value:a.section||"",onChange:s=>c(t=>({...t,section:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"School"}),e.jsx(l,{type:"text",value:a.school||"",onChange:s=>c(t=>({...t,school:s.target.value})),className:"max-w-md"})]})]}),a.role==="teacher"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Department"}),e.jsx(l,{type:"text",value:a.department||"",onChange:s=>c(t=>({...t,department:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Subject"}),e.jsx(l,{type:"text",value:a.subject||"",onChange:s=>c(t=>({...t,subject:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Years of Experience"}),e.jsx(l,{type:"text",value:a.yearsOfExperience||"",onChange:s=>c(t=>({...t,yearsOfExperience:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Qualification"}),e.jsx(l,{type:"text",value:a.qualification||"",onChange:s=>c(t=>({...t,qualification:s.target.value})),className:"max-w-md"})]})]}),a.role==="admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Position"}),e.jsx(l,{type:"text",value:a.position||"",onChange:s=>c(t=>({...t,position:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Department"}),e.jsx(l,{type:"text",value:a.department||"",onChange:s=>c(t=>({...t,department:s.target.value})),className:"max-w-md"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Role"}),e.jsx(l,{type:"text",value:a.role||"",className:"max-w-md bg-slate-100",disabled:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Change Password"}),e.jsxs(x,{variant:"outline",className:"rounded-xl",onClick:ue,children:[e.jsx(Ee,{size:16,className:"mr-2"}),"Update Password"]})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Two-Factor Authentication"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Add an extra layer of security"})]}),e.jsx(x,{variant:"outline",size:"sm",className:"rounded-xl",onClick:fe,children:"Enable"})]})})]}),h==="notifications"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Email Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Receive updates via email"})]}),e.jsx(m,{checked:n.notifications.emailNotifications,onCheckedChange:s=>i(t=>({...t,notifications:{...t.notifications,emailNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(m,{checked:n.notifications.pushNotifications,onCheckedChange:s=>i(t=>({...t,notifications:{...t.notifications,pushNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Sound Effects"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Play sounds for notifications"})]}),e.jsx(m,{checked:n.notifications.soundEnabled,onCheckedChange:s=>i(t=>({...t,notifications:{...t.notifications,soundEnabled:s}}))})]}),e.jsxs("div",{className:"pt-4",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-3 font-body",children:"Notification Types"}),e.jsx("div",{className:"space-y-3",children:[{key:"quizReminders",label:"Quiz Reminders"},{key:"newContent",label:"New Content"},{key:"achievements",label:"Achievements"},{key:"streakAlerts",label:"Streak Alerts"},{key:"weeklySummary",label:"Weekly Summary"}].map(s=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n.notifications.notificationTypes[s.key],onChange:t=>i(L=>({...L,notifications:{...L.notifications,notificationTypes:{...L.notifications.notificationTypes,[s.key]:t.target.checked}}})),className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"}),e.jsx("span",{className:"text-sm text-[#0a1628] font-body",children:s.label})]},s.key))})]}),e.jsxs("div",{className:"pt-4 border-t border-[#dde3eb]",children:[e.jsxs("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:[e.jsx(Re,{size:16,className:"inline mr-2"}),"Quiet Hours"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l,{type:"time",value:n.notifications.quietHours.start,onChange:s=>i(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,start:s.target.value}}})),className:"w-32"}),e.jsx("span",{className:"text-[#5a6578]",children:"to"}),e.jsx(l,{type:"time",value:n.notifications.quietHours.end,onChange:s=>i(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,end:s.target.value}}})),className:"w-32"})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"No notifications during this time"})]})]}),h==="appearance"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Dark Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Smart invert colors like extension dark mode"})]}),e.jsx(m,{checked:n.appearance.darkMode,onCheckedChange:s=>i(t=>({...t,appearance:{...t.appearance,darkMode:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-3 block font-body uppercase tracking-wider text-xs",children:"Font Size"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Small"}),e.jsx("input",{type:"range",min:"12",max:"20",value:n.appearance.fontSize,onChange:s=>i(t=>({...t,appearance:{...t.appearance,fontSize:Number(s.target.value)}})),className:"flex-1"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Large"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Compact View"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show more content on screen"})]}),e.jsx(m,{checked:n.appearance.compactView,onCheckedChange:s=>i(t=>({...t,appearance:{...t.appearance,compactView:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Reduce Animations"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Minimize motion effects"})]}),e.jsx(m,{checked:n.appearance.reduceAnimations,onCheckedChange:s=>i(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),h==="privacy"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Profile Visibility"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Who can see your profile"})]}),e.jsxs("select",{value:n.privacy.profileVisibility,onChange:s=>i(t=>({...t,privacy:{...t.privacy,profileVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"everyone",children:"Everyone"}),e.jsx("option",{value:"students_and_staff",children:"Students and Staff"}),e.jsx("option",{value:"private",children:"Private"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Activity Status"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let others see when you're online"})]}),e.jsx(m,{checked:n.privacy.showActivityStatus,onCheckedChange:s=>i(t=>({...t,privacy:{...t.privacy,showActivityStatus:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Data Sharing"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Share anonymous usage data"})]}),e.jsx(m,{checked:n.privacy.dataSharing,onCheckedChange:s=>i(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),h==="learning"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Daily XP Goal"}),e.jsx(l,{type:"number",value:n.learning.dailyXpGoal,onChange:s=>i(t=>({...t,learning:{...t.learning,dailyXpGoal:Number(s.target.value||0)}})),className:"max-w-xs"}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"Set your daily learning target"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Preferred Study Time"}),e.jsxs("select",{value:n.learning.preferredStudyTime,onChange:s=>i(t=>({...t,learning:{...t.learning,preferredStudyTime:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"morning",children:"Morning (6AM - 12PM)"}),e.jsx("option",{value:"afternoon",children:"Afternoon (12PM - 6PM)"}),e.jsx("option",{value:"evening",children:"Evening (6PM - 12AM)"}),e.jsx("option",{value:"night",children:"Night (12AM - 6AM)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-play Next Lesson"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically start the next lesson"})]}),e.jsx(m,{checked:n.learning.autoPlayLessons,onCheckedChange:s=>i(t=>({...t,learning:{...t.learning,autoPlayLessons:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Hints During Quizzes"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Display helpful hints for questions"})]}),e.jsx(m,{checked:n.learning.showHints,onCheckedChange:s=>i(t=>({...t,learning:{...t.learning,showHints:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Quiz Difficulty Preference"}),e.jsxs("select",{value:n.learning.quizDifficultyPreference,onChange:s=>i(t=>({...t,learning:{...t.learning,quizDifficultyPreference:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"adaptive",children:"Adaptive (Recommended)"}),e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]})]}),e.jsxs("div",{className:"pt-4 border-t border-[#dde3eb]",children:[e.jsxs("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:[e.jsx(De,{size:16,className:"inline mr-2"}),"Study Reminders"]}),e.jsx(l,{type:"time",value:n.learning.studyReminderTime,onChange:s=>i(t=>({...t,learning:{...t.learning,studyReminderTime:s.target.value}})),className:"w-32"}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"Daily reminder to study"})]})]}),h==="data"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 bg-sky-50 border border-sky-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-sky-900 mb-1 font-body",children:"Download Your Data"}),e.jsx("p",{className:"text-xs text-sky-700 mb-3",children:"Export all your learning data and progress"}),e.jsxs(x,{variant:"outline",size:"sm",className:"rounded-xl",onClick:be,disabled:R,children:[e.jsx(ae,{size:16,className:"mr-2"}),R?"Exporting...":"Request Data Export"]})]}),e.jsxs("div",{className:"p-4 bg-white border border-[#dde3eb] rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-1 font-body",children:"Clear Cache"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-3",children:"Free up space by clearing cached data"}),e.jsx(x,{variant:"outline",size:"sm",className:"rounded-xl",onClick:pe,disabled:M,children:M?"Clearing...":"Clear Cache"})]}),e.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-rose-900 mb-1",children:"Reset Progress"}),e.jsxs("p",{className:"text-xs text-rose-700 mb-3",children:[(a.role||"student")==="student"&&"Reset quizzes, diagnostic state, XP, and learning progress for retesting.",a.role==="teacher"&&"Reset imported records, managed classrooms, and teacher-generated quiz artifacts for retesting.",a.role==="admin"&&"Reset admin testing artifacts like personal audit/content update records for QA loops."]}),e.jsx(x,{variant:"outline",size:"sm",className:"rounded-xl text-rose-700 border-rose-300",disabled:!k||j,onClick:me,children:j?"Resetting...":"Reset Testing Data"})]}),a.role==="admin"?e.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-red-900 mb-1",children:"Delete Account"}),e.jsx("p",{className:"text-xs text-red-700 mb-3",children:"Permanently delete your account and all data"}),e.jsxs(x,{variant:"outline",size:"sm",className:"rounded-xl text-red-700 border-red-300",onClick:je,disabled:y,children:[e.jsx(Me,{size:16,className:"mr-2"}),y?"Deleting...":"Delete Account"]})]}):e.jsxs("div",{className:"p-4 bg-emerald-50 border border-emerald-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-emerald-900 mb-1 font-body",children:"Protected Account Controls"}),e.jsx("p",{className:"text-xs text-emerald-700",children:"Account deletion is restricted to administrator accounts."})]})]})]}),e.jsxs("div",{className:"p-6 border-t border-[#dde3eb] bg-[#edf1f7] flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{variant:"outline",onClick:I,className:"rounded-lg border-[#dde3eb]",disabled:A,children:"Cancel"}),e.jsx(x,{onClick:xe,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white",disabled:A,children:A?"Saving...":"Save Changes"})]})]})]})]})]}),de?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[130] bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>{u||(g(!1),b(""),p(!1))},children:e.jsxs(E.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-md rounded-2xl border border-[#dde3eb] bg-[#f7f9fc] shadow-2xl",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[#dde3eb] px-6 py-4",children:[e.jsx("h4",{className:"text-lg font-display font-bold text-[#0a1628]",children:"Update Password"}),e.jsx("button",{onClick:()=>{u||(g(!1),b(""),p(!1))},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close password update dialog",children:e.jsx(ne,{size:18,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Enter a new password with at least 8 characters."}),e.jsxs("div",{className:"relative",children:[e.jsx(l,{type:T?"text":"password",value:W,onChange:s=>b(s.target.value),placeholder:"New password",autoFocus:!0,className:"pr-10",onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Z())},disabled:u}),e.jsx("button",{type:"button",onClick:()=>p(!T),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",tabIndex:-1,children:T?e.jsx(Te,{size:16}):e.jsx(Fe,{size:16})})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(x,{variant:"outline",onClick:()=>{u||(g(!1),b(""),p(!1))},disabled:u,children:"Cancel"}),e.jsx(x,{onClick:Z,className:"bg-sky-600 hover:bg-sky-700 text-white",disabled:u,children:u?"Updating...":"Update Password"})]})]})]})}):null,e.jsx(ee,{isOpen:oe,onClose:()=>{j||C(!1)},onConfirm:he,title:"Reset Testing Data?",message:`Reset ${a.role||"student"} testing data? This will clear quizzes, diagnostic assessments, assessment history, XP, and learning progress. This action is for QA/demo use and cannot be undone.`,confirmText:j?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(ee,{isOpen:ce,onClose:()=>{y||S(!1)},onConfirm:ye,title:"Delete Account?",message:"Delete account permanently? This action cannot be undone.",confirmText:y?"Deleting...":"Delete Account",cancelText:"Cancel",type:"danger",icon:"delete",zIndexClass:"z-[130]"})]})}):null};export{us as default}; diff --git a/assets/SettingsModal-BbkSqdYG.js b/assets/SettingsModal-BbkSqdYG.js new file mode 100644 index 0000000000000000000000000000000000000000..68b97312b1f97b6c194e8bef66daafb284f86f42 --- /dev/null +++ b/assets/SettingsModal-BbkSqdYG.js @@ -0,0 +1,16 @@ +import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{S as Se,a as Ae,b as Pe,c as Ee,d as J}from"./select-DIjxRWza.js";import{e as K,u as ze,aP as Re,aQ as Te,aR as Me,aS as Le,aT as qe,aU as De,r as Ie,S as Fe,aM as Ve,a as Oe,j as _e,m as V,L as He,aV as Ge,t as u,aW as Ue,aX as Xe,aY as Qe}from"./index-BaOs5Ayg.js";import{B as p}from"./button-DCfeFHoH.js";import{I as n}from"./input-D28h_UTJ.js";import{S as d}from"./switch-CblAJO7o.js";import me from"./ConfirmModal-6cgkqXAT.js";import{P as We,M as Be,V as Ye}from"./ProfilePictureUploader-CX_IZAwE.js";import{B as Je}from"./bell-clcSMJn6.js";import{D as he}from"./download-DX_YebqQ.js";import{X as ue}from"./x-TNvtuOD9.js";import{C as $e}from"./circle-help-B8apTIdU.js";import{C as Ke}from"./clock-D1Ecvltm.js";import{T as Ze}from"./trash-2-HTnKafZd.js";import{E as es,a as ss}from"./eye-Ig3S6mOs.js";import"./vendor-radix-BorKzPz9.js";import"./chevron-up-Cdvz2TMJ.js";import"./check-BLSo9L0H.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-BenDMDly.js";import"./minus-DfrEv-SC.js";import"./plus-DkG35AoH.js";import"./upload-DayXhGwD.js";/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ts=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],as=K("palette",ts);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ns=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],is=K("server",ns);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ls=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],rs=K("smartphone",ls),cs=()=>{const{userProfile:x,userRole:j}=ze(),[l,P]=a.useState(Re),[E,z]=a.useState(Te),[k,R]=a.useState(!1),[L,S]=a.useState(null);a.useEffect(()=>{if(!x?.uid)return;(async()=>{R(!0),S(null);try{if(j==="teacher"){const h=await qe(x.uid);P(h)}if(j==="admin"){const h=await De();z(h)}}catch(h){S(h instanceof Error?h.message:"Failed to load settings")}finally{R(!1)}})()},[x?.uid,j]);const r=a.useCallback(async w=>{if(!x?.uid)return;const h=await Me(x.uid,w);P(h)},[x?.uid]),T=a.useCallback(async w=>{const h=await Le(w);z(h)},[]);return{teacherPrefs:l,adminConfig:E,loading:k,error:L,saveTeacherPrefs:r,saveAdminConfig:T}},$=()=>JSON.parse(JSON.stringify(Ge)),Vs=({isOpen:x,onClose:j,profileData:l,onSave:P,settingsData:E,onSaveSettings:z,onApplySettingsPreview:k,onExportData:R,onClearCache:L,onResetData:S})=>{const r=l?.role||"student",{teacherPrefs:T,adminConfig:w,saveTeacherPrefs:h,saveAdminConfig:be}=cs(),[f,fe]=a.useState("account"),[o,m]=a.useState({}),[i,Z]=a.useState($()),[y,g]=a.useState(T),[v,N]=a.useState(w),[O,ee]=a.useState(!1),[q,se]=a.useState(!1),[_,te]=a.useState(!1),[H,ae]=a.useState(!1),[ne,os]=a.useState(!1),[pe,D]=a.useState(!1),[je,I]=a.useState(!1),[ye,A]=a.useState(!1),[M,ie]=a.useState(""),[b,ge]=a.useState(null),[C,le]=a.useState(!1),[G,re]=a.useState(!1),[U,ce]=a.useState(""),[F,oe]=a.useState(""),X=a.useRef(!1),Q=a.useRef($());a.useEffect(()=>{if(!x){X.current=!1;return}if(X.current)return;X.current=!0;const s=E?JSON.parse(JSON.stringify(E)):$();Q.current=s,m({uid:l?.uid,name:l?.name||"",email:l?.email||"",phone:l?.phone||"",photo:l?.photo||"",avatarLayers:l?.avatarLayers,role:l?.role,gender:l?.gender,lrn:l?.lrn||"",grade:l?.grade||"",section:l?.section||"",school:l?.school||"",department:l?.department||"",subject:l?.subject||"",yearsOfExperience:l?.yearsOfExperience||"",qualification:l?.qualification||"",position:l?.position||""}),Z(s),g(T),N(w)},[x,l,E,T,w]),a.useEffect(()=>{x&&k?.(i)},[x,i,k]),a.useEffect(()=>{if(!x)return;const s=t=>{t.key==="Escape"&&(k?.(Q.current),j())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x,j,k]);const de=a.useMemo(()=>{const s=[{id:"account",label:"Account",icon:Ie},{id:"notifications",label:"Notifications",icon:Je},{id:"appearance",label:"Appearance",icon:as},{id:"privacy",label:"Privacy & Security",icon:Fe}];return r==="student"&&s.push({id:"learning",label:"Learning",icon:Ve}),r==="teacher"&&s.push({id:"teaching",label:"Teaching",icon:Oe}),r==="admin"&&s.push({id:"system",label:"System",icon:is}),s.push({id:"data",label:"Data & Storage",icon:he}),s},[r]),c=s=>{Z(t=>s(t))},W=s=>{ge(s),ie(""),re(!1),s==="password"&&ce(""),s==="email"&&oe(o.email||""),A(!0)},xe=async()=>{if(!M.trim()){u.error("Current password is required");return}le(!0);try{if(b==="password"){if(U.length<8){u.error("New password must be at least 8 characters");return}await Ue(M,U),u.success("Password updated")}else if(b==="email"){if(!F.includes("@")){u.error("Enter a valid email");return}await Xe(M,F),m(s=>({...s,email:F})),u.success("Email updated")}else if(b==="delete"){await Qe(M,o.uid||""),u.success("Account deleted"),j();return}A(!1)}catch(s){u.error(s instanceof Error?s.message:"Authentication failed")}finally{le(!1)}},ve=async()=>{ee(!0);try{P&&await P(o),z&&await z(i),r==="teacher"&&await h(y),r==="admin"&&await be(v),j()}catch(s){u.error(s instanceof Error?s.message:"Failed to save settings")}finally{ee(!1)}},B=()=>{A(!1),D(!1),I(!1),k?.(Q.current),j()},Ne=async()=>{if(!(!R||_)){te(!0);try{await R()}catch(s){u.error(s instanceof Error?s.message:"Failed to export data")}finally{te(!1)}}},we=async()=>{if(!(!L||H)){ae(!0);try{await L()}catch(s){u.error(s instanceof Error?s.message:"Failed to clear cache")}finally{ae(!1)}}},Ce=async()=>{if(!(!S||q)){D(!1),se(!0);try{await S(),u.success("Testing data reset completed")}catch(s){u.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{se(!1)}}},ke=()=>{I(!1),W("delete")};return x?e.jsx(_e,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:B,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-4xl max-h-[85vh] overflow-hidden flex",children:[e.jsxs("div",{className:"w-64 bg-slate-50 border-r border-slate-200 p-6 overflow-y-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-[#0a1628]",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Manage your preferences"})]}),e.jsx("nav",{className:"space-y-1",children:de.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>fe(s.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all ${f===s.id?"bg-sky-50 text-sky-700 shadow-sm":"text-slate-500 hover:bg-slate-100 hover:text-sky-700"}`,children:[e.jsx(t,{size:18}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]},s.id)})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:de.find(s=>s.id===f)?.label}),e.jsx("button",{onClick:B,className:"p-2 hover:bg-[#edf1f7] rounded-xl transition-colors",children:e.jsx(ue,{size:20,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(We,{uid:o.uid,photoURL:o.photo,displayName:o.name,onUploaded:s=>m(t=>({...t,photo:s}))}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Full Name"}),e.jsx(n,{type:"text",value:o.name||"",onChange:s=>m(t=>({...t,name:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Email Address"}),e.jsxs("div",{className:"flex items-center gap-2 max-w-md",children:[e.jsx(n,{type:"email",value:o.email||"",disabled:!0,className:"flex-1 bg-slate-100"}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>W("email"),children:"Change"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Phone Number"}),e.jsx(n,{type:"tel",value:o.phone||"",onChange:s=>m(t=>({...t,phone:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Gender"}),e.jsxs(Se,{value:o.gender||"",onValueChange:s=>m(t=>({...t,gender:s})),children:[e.jsx(Ae,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg",children:e.jsx(Pe,{placeholder:"Select gender (optional)"})}),e.jsxs(Ee,{children:[e.jsx(J,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(J,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(J,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),r==="student"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"LRN"}),e.jsx(n,{value:o.lrn||"",onChange:s=>m(t=>({...t,lrn:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Grade Level"}),e.jsx(n,{value:o.grade||"",onChange:s=>m(t=>({...t,grade:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Section"}),e.jsx(n,{value:o.section||"",onChange:s=>m(t=>({...t,section:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"School"}),e.jsx(n,{value:o.school||"",onChange:s=>m(t=>({...t,school:s.target.value})),className:"max-w-md"})]})]}),r==="teacher"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Department"}),e.jsx(n,{value:o.department||"",onChange:s=>m(t=>({...t,department:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Subject"}),e.jsx(n,{value:o.subject||"",onChange:s=>m(t=>({...t,subject:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Years of Experience"}),e.jsx(n,{value:o.yearsOfExperience||"",onChange:s=>m(t=>({...t,yearsOfExperience:s.target.value})),className:"max-w-md"})]})]}),r==="admin"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Position"}),e.jsx(n,{value:o.position||"",onChange:s=>m(t=>({...t,position:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Change Password"}),e.jsxs(p,{variant:"outline",className:"rounded-xl",onClick:()=>W("password"),children:[e.jsx(He,{size:16,className:"mr-2"}),"Update Password"]})]})]}),f==="notifications"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Email Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Receive updates via email"})]}),e.jsx(d,{checked:i.notifications.emailNotifications,onCheckedChange:s=>c(t=>({...t,notifications:{...t.notifications,emailNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(d,{checked:i.notifications.pushNotifications,onCheckedChange:s=>c(t=>({...t,notifications:{...t.notifications,pushNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Sound Effects"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Play sounds for notifications"})]}),e.jsx(d,{checked:i.notifications.soundEnabled,onCheckedChange:s=>c(t=>({...t,notifications:{...t.notifications,soundEnabled:s}}))})]}),r==="teacher"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Submissions"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Notify when students submit work"})]}),e.jsx(d,{checked:y.notifyOnSubmission,onCheckedChange:s=>g(t=>({...t,notifyOnSubmission:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Activity Alerts"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Notify on at-risk student activity"})]}),e.jsx(d,{checked:y.notifyOnStudentActivity,onCheckedChange:s=>g(t=>({...t,notifyOnStudentActivity:s}))})]})]}),e.jsxs("div",{className:"pt-4",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-3 font-body",children:"Notification Types"}),e.jsx("div",{className:"space-y-3",children:[{key:"quizReminders",label:"Quiz Reminders"},{key:"newContent",label:"New Content"},{key:"achievements",label:"Achievements"},{key:"streakAlerts",label:"Streak Alerts"},{key:"weeklySummary",label:"Weekly Summary"}].map(s=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:i.notifications.notificationTypes[s.key],onChange:t=>c(Y=>({...Y,notifications:{...Y.notifications,notificationTypes:{...Y.notifications.notificationTypes,[s.key]:t.target.checked}}})),className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"}),e.jsx("span",{className:"text-sm text-[#0a1628] font-body",children:s.label})]},s.key))})]}),e.jsxs("div",{className:"pt-4 border-t border-[#dde3eb]",children:[e.jsxs("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:[e.jsx(Ke,{size:16,className:"inline mr-2"}),"Quiet Hours"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(n,{type:"time",value:i.notifications.quietHours.start,onChange:s=>c(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,start:s.target.value}}})),className:"w-32"}),e.jsx("span",{className:"text-[#5a6578]",children:"to"}),e.jsx(n,{type:"time",value:i.notifications.quietHours.end,onChange:s=>c(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,end:s.target.value}}})),className:"w-32"})]})]})]}),f==="appearance"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Dark Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Toggle dark theme"})]}),e.jsx(d,{checked:i.appearance.darkMode,onCheckedChange:s=>c(t=>({...t,appearance:{...t.appearance,darkMode:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-3 block font-body uppercase tracking-wider text-xs",children:"Font Size"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Small"}),e.jsx("input",{type:"range",min:"12",max:"20",value:i.appearance.fontSize,onChange:s=>c(t=>({...t,appearance:{...t.appearance,fontSize:Number(s.target.value)}})),className:"flex-1"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Large"}),e.jsxs("span",{className:"text-xs font-mono text-slate-600 w-8",children:[i.appearance.fontSize,"px"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Compact View"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show more content on screen"})]}),e.jsx(d,{checked:i.appearance.compactView,onCheckedChange:s=>c(t=>({...t,appearance:{...t.appearance,compactView:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Reduce Animations"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Minimize motion effects"})]}),e.jsx(d,{checked:i.appearance.reduceAnimations,onCheckedChange:s=>c(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),f==="privacy"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Profile Visibility"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Who can see your profile"})]}),e.jsxs("select",{value:i.privacy.profileVisibility,onChange:s=>c(t=>({...t,privacy:{...t.privacy,profileVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"everyone",children:"Everyone"}),e.jsx("option",{value:"students_and_staff",children:"Students and Staff"}),e.jsx("option",{value:"private",children:"Private"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Activity Status"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let others see when you're online"})]}),e.jsx(d,{checked:i.privacy.showActivityStatus,onCheckedChange:s=>c(t=>({...t,privacy:{...t.privacy,showActivityStatus:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Data Sharing"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Share anonymous usage data"})]}),e.jsx(d,{checked:i.privacy.dataSharing,onCheckedChange:s=>c(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),f==="learning"&&r==="student"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Daily XP Goal"}),e.jsx(n,{type:"number",value:i.learning.dailyXpGoal,onChange:s=>c(t=>({...t,learning:{...t.learning,dailyXpGoal:Number(s.target.value||0)}})),className:"max-w-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Preferred Study Time"}),e.jsxs("select",{value:i.learning.preferredStudyTime,onChange:s=>c(t=>({...t,learning:{...t.learning,preferredStudyTime:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"morning",children:"Morning (6AM - 12PM)"}),e.jsx("option",{value:"afternoon",children:"Afternoon (12PM - 6PM)"}),e.jsx("option",{value:"evening",children:"Evening (6PM - 12PM)"}),e.jsx("option",{value:"night",children:"Night (12AM - 6AM)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-play Next Lesson"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically start the next lesson"})]}),e.jsx(d,{checked:i.learning.autoPlayLessons,onCheckedChange:s=>c(t=>({...t,learning:{...t.learning,autoPlayLessons:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Hints During Quizzes"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Display helpful hints for questions"})]}),e.jsx(d,{checked:i.learning.showHints,onCheckedChange:s=>c(t=>({...t,learning:{...t.learning,showHints:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Quiz Difficulty Preference"}),e.jsxs("select",{value:i.learning.quizDifficultyPreference,onChange:s=>c(t=>({...t,learning:{...t.learning,quizDifficultyPreference:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"adaptive",children:"Adaptive (Recommended)"}),e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]})]}),e.jsxs("div",{className:"pt-4 border-t border-[#dde3eb]",children:[e.jsxs("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:[e.jsx(rs,{size:16,className:"inline mr-2"}),"Study Reminders"]}),e.jsx(n,{type:"time",value:i.learning.studyReminderTime,onChange:s=>c(t=>({...t,learning:{...t.learning,studyReminderTime:s.target.value}})),className:"w-32"})]})]}),f==="teaching"&&r==="teacher"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Quiz Defaults"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Time Limit (min)"}),e.jsx(n,{type:"number",value:y.quizDefaults.timeLimitMinutes,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,timeLimitMinutes:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Passing Score (%)"}),e.jsx(n,{type:"number",value:y.quizDefaults.passingScore,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,passingScore:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Attempts"}),e.jsx(n,{type:"number",value:y.quizDefaults.maxAttempts,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,maxAttempts:Number(s.target.value)}}))})]})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"Class Preferences"}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-Enroll Students"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically enroll new students"})]}),e.jsx(d,{checked:y.classPreferences.autoEnroll,onCheckedChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,autoEnroll:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Class Visibility"}),e.jsxs("select",{value:y.classPreferences.classVisibility,onChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,classVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"public",children:"Public"}),e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"invite_only",children:"Invite Only"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Analytics Visibility"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let students see their leaderboard rank"})]}),e.jsx(d,{checked:y.studentAnalyticsVisibility,onCheckedChange:s=>g(t=>({...t,studentAnalyticsVisibility:s}))})]})]}),f==="system"&&r==="admin"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Maintenance Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Disable platform access for non-admins"})]}),e.jsx(d,{checked:v.maintenanceMode,onCheckedChange:s=>N(t=>({...t,maintenanceMode:s}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Grade Level"}),e.jsx(n,{value:v.defaultGradeLevel,onChange:s=>N(t=>({...t,defaultGradeLevel:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Curriculum"}),e.jsx(n,{value:v.defaultCurriculum,onChange:s=>N(t=>({...t,defaultCurriculum:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Class Size"}),e.jsx(n,{type:"number",value:v.maxClassSize,onChange:s=>N(t=>({...t,maxClassSize:Number(s.target.value)}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Audit Log Visible"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show audit logs in admin dashboard"})]}),e.jsx(d,{checked:v.auditLogVisible,onCheckedChange:s=>N(t=>({...t,auditLogVisible:s}))})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"AI Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Model Name"}),e.jsx(n,{value:v.aiConfig.modelName,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,modelName:s.target.value}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Temperature"}),e.jsx(n,{type:"number",step:"0.1",min:"0",max:"2",value:v.aiConfig.temperature,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,temperature:Number(s.target.value)}}))})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"API Endpoint"}),e.jsx(n,{value:v.aiConfig.endpoint,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,endpoint:s.target.value}}))})]})]})]}),f==="data"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 bg-sky-50 border border-sky-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-sky-900 mb-1 font-body",children:"Download Your Data"}),e.jsx("p",{className:"text-xs text-sky-700 mb-3",children:"Export all your learning data and progress"}),e.jsxs(p,{variant:"outline",size:"sm",className:"rounded-xl",onClick:Ne,disabled:_,children:[e.jsx(he,{size:16,className:"mr-2"}),_?"Exporting...":"Request Data Export"]})]}),e.jsxs("div",{className:"p-4 bg-white border border-[#dde3eb] rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-1 font-body",children:"Clear Cache"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-3",children:"Free up space by clearing cached data"}),e.jsx(p,{variant:"outline",size:"sm",className:"rounded-xl",onClick:we,disabled:H,children:H?"Clearing...":"Clear Cache"})]}),e.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-rose-900 mb-1",children:"Reset Progress"}),e.jsxs("p",{className:"text-xs text-rose-700 mb-3",children:[r==="student"&&"Reset quizzes, diagnostic state, XP, and learning progress for retesting.",r==="teacher"&&"Reset imported records, managed classrooms, and teacher-generated quiz artifacts.",r==="admin"&&"Reset admin testing artifacts like personal audit/content update records."]}),e.jsx(p,{variant:"outline",size:"sm",className:"rounded-xl text-rose-700 border-rose-300",disabled:!S||q,onClick:()=>D(!0),children:q?"Resetting...":"Reset Testing Data"})]}),e.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-red-900 mb-1",children:"Delete Account"}),e.jsx("p",{className:"text-xs text-red-700 mb-3",children:"Permanently delete your account and all data"}),e.jsxs(p,{variant:"outline",size:"sm",className:"rounded-xl text-red-700 border-red-300",onClick:()=>I(!0),disabled:ne,children:[e.jsx(Ze,{size:16,className:"mr-2"}),ne?"Deleting...":"Delete Account"]})]})]})]}),e.jsxs("div",{className:"p-6 border-t border-[#dde3eb] bg-[#edf1f7] flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",onClick:B,className:"rounded-lg border-[#dde3eb]",disabled:O,children:"Cancel"}),e.jsx(p,{onClick:ve,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white",disabled:O,children:O?"Saving...":"Save Changes"})]})]})]})]})]}),ye&&e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[130] bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>{C||A(!1)},children:e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-md rounded-2xl border border-[#dde3eb] bg-[#f7f9fc] shadow-2xl",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[#dde3eb] px-6 py-4",children:[e.jsxs("h4",{className:"text-lg font-display font-bold text-[#0a1628]",children:[b==="password"&&"Change Password",b==="email"&&"Change Email",b==="delete"&&"Delete Account"]}),e.jsx("button",{onClick:()=>{C||A(!1)},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close",children:e.jsx(ue,{size:18,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Enter your current password to continue."}),e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:G?"text":"password",value:M,onChange:s=>ie(s.target.value),placeholder:"Current password",autoFocus:!0,className:"pr-10",disabled:C,onKeyDown:s=>{s.key==="Enter"&&xe()}}),e.jsx("button",{type:"button",onClick:()=>re(!G),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",tabIndex:-1,children:G?e.jsx(es,{size:16}):e.jsx(ss,{size:16})})]}),b==="password"&&e.jsx("div",{className:"relative",children:e.jsx(n,{type:"password",value:U,onChange:s=>ce(s.target.value),placeholder:"New password (min 8 chars)",disabled:C})}),b==="email"&&e.jsx(n,{type:"email",value:F,onChange:s=>oe(s.target.value),placeholder:"New email address",disabled:C}),b==="delete"&&e.jsx("p",{className:"text-sm text-red-600 font-medium",children:"This action is permanent and cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p,{variant:"outline",onClick:()=>A(!1),disabled:C,children:"Cancel"}),e.jsx(p,{onClick:()=>void xe(),className:b==="delete"?"bg-red-600 hover:bg-red-700 text-white":"bg-sky-600 hover:bg-sky-700 text-white",disabled:C,children:C?"Processing...":b==="delete"?"Delete Forever":"Confirm"})]})]})]})}),e.jsx(me,{isOpen:pe,onClose:()=>D(!1),onConfirm:Ce,title:"Reset Testing Data?",message:`Reset ${r} testing data? This will clear quizzes, diagnostic assessments, assessment history, XP, and learning progress. This action cannot be undone.`,confirmText:q?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(me,{isOpen:je,onClose:()=>I(!1),onConfirm:ke,title:"Delete Account?",message:"You will need to re-authenticate to permanently delete your account. This cannot be undone.",confirmText:"Continue",cancelText:"Cancel",type:"danger",icon:"delete",zIndexClass:"z-[130]"})]})}):null};export{Vs as default}; diff --git a/assets/Sidebar-C2ctPQQf.js b/assets/Sidebar-2LZAqf7E.js similarity index 93% rename from assets/Sidebar-C2ctPQQf.js rename to assets/Sidebar-2LZAqf7E.js index 145e1e52a3e5ad3326724f9bb37494cceec13ce2..e5302d42cb4839e4b0158469b9b096a2c6ea09c9 100644 --- a/assets/Sidebar-C2ctPQQf.js +++ b/assets/Sidebar-2LZAqf7E.js @@ -1,4 +1,4 @@ -import{r as p,j as e}from"./vendor-react-B4AQeu28.js";import{S as N,a as $,L as u,M as P}from"./LogoutActionButton-Cb7v3MhK.js";import{e as D,m as c,i as G,U as S,G as M,a as f,S as U,P as _,x as q}from"./index-Cb8VeSuW.js";import{T as L,a as C,b as A}from"./tooltip-BY91VKdD.js";import{X as F}from"./x-CTLBAl-n.js";import{C as Q}from"./chevron-right-CoVWpXdD.js";import{C as W}from"./chevron-left-CZaM7nZW.js";import{C as z}from"./chart-column-CmH46HAG.js";import{S as X}from"./shirt-CrJtkYx3.js";import"./log-out-CM6AS10M.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as p,j as e}from"./vendor-react-B4AQeu28.js";import{S as N,a as $,L as u,M as P}from"./LogoutActionButton-lUNItet6.js";import{e as D,m as c,i as G,U as S,G as M,a as f,S as U,P as _,x as q}from"./index-BaOs5Ayg.js";import{T as L,a as C,b as A}from"./tooltip-ChRIOid3.js";import{X as F}from"./x-TNvtuOD9.js";import{C as Q}from"./chevron-right-COqGruhh.js";import{C as W}from"./chevron-left-BWpgclqc.js";import{C as z}from"./chart-column-B3jJOD5i.js";import{S as X}from"./shirt-S3NBuaPm.js";import"./log-out-BenDMDly.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/SupplementalBanner-bYee7ru9.js b/assets/SupplementalBanner-DFkcXPOZ.js similarity index 97% rename from assets/SupplementalBanner-bYee7ru9.js rename to assets/SupplementalBanner-DFkcXPOZ.js index d0a5e2519350b7257020c22792072ae7455001ec..b6c3a323aeac7a1ed31cff246f790767a7840ccf 100644 --- a/assets/SupplementalBanner-bYee7ru9.js +++ b/assets/SupplementalBanner-DFkcXPOZ.js @@ -1 +1 @@ -import{j as e,r as j}from"./vendor-react-B4AQeu28.js";import{j as y,m as p,p as h,a as f,T as m,B as x}from"./index-Cb8VeSuW.js";import{X as v}from"./x-CTLBAl-n.js";import{S as w}from"./sparkles-v8V3LFaV.js";import{C as g}from"./chevron-right-CoVWpXdD.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const b={"General Mathematics":[{label:"Functions Deep Dive",description:"Interactive review of function types and graphs",icon:e.jsx(m,{size:14})},{label:"Business Math Basics",description:"Simple & compound interest practice",icon:e.jsx(f,{size:14})}],"Statistics and Probability":[{label:"Distribution Visualizer",description:"Explore normal distribution curves",icon:e.jsx(m,{size:14})},{label:"Hypothesis Practice",description:"Step-by-step hypothesis testing",icon:e.jsx(x,{size:14})}],"Pre-Calculus":[{label:"Conic Sections Explorer",description:"Visual parabola, ellipse, hyperbola tool",icon:e.jsx(m,{size:14})},{label:"Trig Identity Practice",description:"Identity verification drill set",icon:e.jsx(x,{size:14})}],"Basic Calculus":[{label:"Limits Visualizer",description:"Graphical approach to limits",icon:e.jsx(m,{size:14})},{label:"Derivative Rules Drill",description:"Practice chain rule & implicit diff",icon:e.jsx(x,{size:14})}]};function u(i){const s=i.toLowerCase();return s==="functions"||s.includes("function")||s==="businessmath"||s.includes("business")||s==="logic"||s.includes("reason")||s.includes("general")||s.includes("gen-math")||s.includes("gen math")?"General Mathematics":s.includes("stat")||s.includes("prob")?"Statistics and Probability":s.includes("pre-calc")||s.includes("pre calc")||s.includes("precalc")?"Pre-Calculus":s.includes("basic")||s.includes("calc")?"Basic Calculus":null}function N(i){const s=i.trim().toLowerCase();return s==="functions"?"Functions and Graphs":s==="businessmath"?"Business and Financial Mathematics":s==="logic"?"Logic and Reasoning":i}const k=({atRiskSubjects:i=[],onAction:s,onDismiss:n})=>{const[l,a]=j.useState(!1);if(l||i.length===0)return null;const r=()=>{a(!0),n?.()};return e.jsx(y,{children:!l&&e.jsx(p.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-10,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"relative bg-gradient-to-r from-sky-600 via-sky-500 to-sky-600 rounded-2xl p-5 text-white shadow-lg shadow-sky-500/20",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 w-7 h-7 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-colors",children:e.jsx(v,{size:14})}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(w,{size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-lg mb-1",children:"Supplemental Materials Available"}),e.jsx("p",{className:"text-sky-100 text-sm mb-3",children:"Based on your diagnostic assessment, we've identified topics that could use extra practice. Strengthening these areas will improve your overall performance."}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:i.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-white/20 backdrop-blur-sm px-3 py-1 rounded-full text-xs font-semibold",children:[e.jsx(h,{size:12}),N(t)]},t))}),e.jsxs("button",{onClick:s,className:"inline-flex items-center gap-2 bg-white text-sky-600 font-bold text-sm px-4 py-2 rounded-xl hover:bg-sky-50 transition-colors",children:["Review Topics",e.jsx(g,{size:16})]})]})]})]})})})},z=({quizSubject:i,atRiskSubjects:s=[]})=>{const n=i?u(i):null;if(!s.some(r=>{const t=u(r);return t&&t===n})||!n)return null;const a=b[n]||[];return e.jsx(p.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"mb-4 overflow-hidden",children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-50 to-orange-50 border border-rose-200 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(h,{size:14,className:"text-rose-600"}),e.jsxs("span",{className:"text-xs font-bold text-rose-800",children:["Supplemental Focus Area — ",n]})]}),e.jsx("p",{className:"text-xs text-rose-700 mb-2",children:"This topic was flagged in your diagnostic. Take your time and review the explanations carefully."}),a.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.slice(0,2).map((r,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-rose-100 text-rose-700 px-2 py-0.5 rounded-md text-xs font-medium",children:[r.icon,r.label]},t))})]})})},C=({quizSubject:i,quizScore:s=0,atRiskSubjects:n=[],onAction:l})=>{const a=i?u(i):null,r=n.some(c=>{const d=u(c);return d&&d===a});if(s>=70&&!r)return null;const t=a?b[a]||[]:[],o=s<70;return e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-4",children:e.jsx("div",{className:`rounded-2xl p-4 border-2 ${o?"bg-orange-50 border-orange-200":"bg-sky-50 border-sky-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${o?"bg-orange-500":"bg-sky-500"}`,children:e.jsx(f,{size:20,className:"text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-display font-bold text-[#0a1628] text-sm mb-1",children:o?"Review Recommended":"Supplemental Materials"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2",children:o?`You scored ${s}% on this quiz. We recommend reviewing the following resources to strengthen your understanding.`:"This topic was identified as an area for growth. Check out these additional resources."}),t.length>0&&e.jsx("div",{className:"space-y-1.5 mb-3",children:t.map((c,d)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center ${o?"bg-orange-100 text-orange-600":"bg-sky-100 text-sky-600"}`,children:c.icon}),e.jsx("span",{className:"font-medium text-[#0a1628]",children:c.label}),e.jsxs("span",{className:"text-slate-500",children:["— ",c.description]})]},d))}),l&&e.jsxs("button",{onClick:l,className:`inline-flex items-center gap-1.5 text-xs font-bold px-3 py-1.5 rounded-lg transition-colors ${o?"bg-orange-500 hover:bg-orange-600 text-white":"bg-sky-500 hover:bg-sky-600 text-white"}`,children:["Review Topics",e.jsx(g,{size:12})]})]})]})})})},I=i=>{switch(i.variant){case"compact":return e.jsx(z,{...i});case"results":return e.jsx(C,{...i});case"full":default:return e.jsx(k,{...i})}};export{I as default}; +import{j as e,r as j}from"./vendor-react-B4AQeu28.js";import{j as y,m as p,p as h,a as f,T as m,B as x}from"./index-BaOs5Ayg.js";import{X as v}from"./x-TNvtuOD9.js";import{S as w}from"./sparkles-By-vFjpv.js";import{C as g}from"./chevron-right-COqGruhh.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const b={"General Mathematics":[{label:"Functions Deep Dive",description:"Interactive review of function types and graphs",icon:e.jsx(m,{size:14})},{label:"Business Math Basics",description:"Simple & compound interest practice",icon:e.jsx(f,{size:14})}],"Statistics and Probability":[{label:"Distribution Visualizer",description:"Explore normal distribution curves",icon:e.jsx(m,{size:14})},{label:"Hypothesis Practice",description:"Step-by-step hypothesis testing",icon:e.jsx(x,{size:14})}],"Pre-Calculus":[{label:"Conic Sections Explorer",description:"Visual parabola, ellipse, hyperbola tool",icon:e.jsx(m,{size:14})},{label:"Trig Identity Practice",description:"Identity verification drill set",icon:e.jsx(x,{size:14})}],"Basic Calculus":[{label:"Limits Visualizer",description:"Graphical approach to limits",icon:e.jsx(m,{size:14})},{label:"Derivative Rules Drill",description:"Practice chain rule & implicit diff",icon:e.jsx(x,{size:14})}]};function u(i){const s=i.toLowerCase();return s==="functions"||s.includes("function")||s==="businessmath"||s.includes("business")||s==="logic"||s.includes("reason")||s.includes("general")||s.includes("gen-math")||s.includes("gen math")?"General Mathematics":s.includes("stat")||s.includes("prob")?"Statistics and Probability":s.includes("pre-calc")||s.includes("pre calc")||s.includes("precalc")?"Pre-Calculus":s.includes("basic")||s.includes("calc")?"Basic Calculus":null}function N(i){const s=i.trim().toLowerCase();return s==="functions"?"Functions and Graphs":s==="businessmath"?"Business and Financial Mathematics":s==="logic"?"Logic and Reasoning":i}const k=({atRiskSubjects:i=[],onAction:s,onDismiss:n})=>{const[l,a]=j.useState(!1);if(l||i.length===0)return null;const r=()=>{a(!0),n?.()};return e.jsx(y,{children:!l&&e.jsx(p.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-10,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"relative bg-gradient-to-r from-sky-600 via-sky-500 to-sky-600 rounded-2xl p-5 text-white shadow-lg shadow-sky-500/20",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 w-7 h-7 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-colors",children:e.jsx(v,{size:14})}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(w,{size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-lg mb-1",children:"Supplemental Materials Available"}),e.jsx("p",{className:"text-sky-100 text-sm mb-3",children:"Based on your diagnostic assessment, we've identified topics that could use extra practice. Strengthening these areas will improve your overall performance."}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:i.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-white/20 backdrop-blur-sm px-3 py-1 rounded-full text-xs font-semibold",children:[e.jsx(h,{size:12}),N(t)]},t))}),e.jsxs("button",{onClick:s,className:"inline-flex items-center gap-2 bg-white text-sky-600 font-bold text-sm px-4 py-2 rounded-xl hover:bg-sky-50 transition-colors",children:["Review Topics",e.jsx(g,{size:16})]})]})]})]})})})},z=({quizSubject:i,atRiskSubjects:s=[]})=>{const n=i?u(i):null;if(!s.some(r=>{const t=u(r);return t&&t===n})||!n)return null;const a=b[n]||[];return e.jsx(p.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"mb-4 overflow-hidden",children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-50 to-orange-50 border border-rose-200 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(h,{size:14,className:"text-rose-600"}),e.jsxs("span",{className:"text-xs font-bold text-rose-800",children:["Supplemental Focus Area — ",n]})]}),e.jsx("p",{className:"text-xs text-rose-700 mb-2",children:"This topic was flagged in your diagnostic. Take your time and review the explanations carefully."}),a.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.slice(0,2).map((r,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-rose-100 text-rose-700 px-2 py-0.5 rounded-md text-xs font-medium",children:[r.icon,r.label]},t))})]})})},C=({quizSubject:i,quizScore:s=0,atRiskSubjects:n=[],onAction:l})=>{const a=i?u(i):null,r=n.some(c=>{const d=u(c);return d&&d===a});if(s>=70&&!r)return null;const t=a?b[a]||[]:[],o=s<70;return e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-4",children:e.jsx("div",{className:`rounded-2xl p-4 border-2 ${o?"bg-orange-50 border-orange-200":"bg-sky-50 border-sky-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${o?"bg-orange-500":"bg-sky-500"}`,children:e.jsx(f,{size:20,className:"text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-display font-bold text-[#0a1628] text-sm mb-1",children:o?"Review Recommended":"Supplemental Materials"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2",children:o?`You scored ${s}% on this quiz. We recommend reviewing the following resources to strengthen your understanding.`:"This topic was identified as an area for growth. Check out these additional resources."}),t.length>0&&e.jsx("div",{className:"space-y-1.5 mb-3",children:t.map((c,d)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center ${o?"bg-orange-100 text-orange-600":"bg-sky-100 text-sky-600"}`,children:c.icon}),e.jsx("span",{className:"font-medium text-[#0a1628]",children:c.label}),e.jsxs("span",{className:"text-slate-500",children:["— ",c.description]})]},d))}),l&&e.jsxs("button",{onClick:l,className:`inline-flex items-center gap-1.5 text-xs font-bold px-3 py-1.5 rounded-lg transition-colors ${o?"bg-orange-500 hover:bg-orange-600 text-white":"bg-sky-500 hover:bg-sky-600 text-white"}`,children:["Review Topics",e.jsx(g,{size:12})]})]})]})})})},I=i=>{switch(i.variant){case"compact":return e.jsx(z,{...i});case"results":return e.jsx(C,{...i});case"full":default:return e.jsx(k,{...i})}};export{I as default}; diff --git a/assets/SupplementalPillCarousel-Bvno07XP.js b/assets/SupplementalPillCarousel-BqNTelmK.js similarity index 94% rename from assets/SupplementalPillCarousel-Bvno07XP.js rename to assets/SupplementalPillCarousel-BqNTelmK.js index 23bc956c13ae01a473478bcfff8619eb6fb10910..c486bc7e7f68eea02b2fcd3080bce57b48525d5f 100644 --- a/assets/SupplementalPillCarousel-Bvno07XP.js +++ b/assets/SupplementalPillCarousel-BqNTelmK.js @@ -1,4 +1,4 @@ -import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{m as f,p as x}from"./index-Cb8VeSuW.js";import{C as n}from"./chevron-right-CoVWpXdD.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const o={pillBg:"#E9D5FF",pillText:"#6B21A8",headerText:"#1F2937",arrowBg:"#F3F4F6"},b={functions:"Functions & Graphs",businessmath:"Business Math",logic:"Logic & Reasoning",statistics:"Statistics",probability:"Probability",precalc:"Pre-Calculus",calculus:"Basic Calculus",geometry:"Geometry",trigonometry:"Trigonometry",algebra:"Algebra"};function g(t){const s=t.toLowerCase().trim();return b[s]||t.split(/[-_]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}const L=({atRiskSubjects:t=[],onTopicClick:s})=>{const l=a.useRef(null),[c,m]=a.useState(!1);if(t.length===0)return null;const h=()=>{if(l.current){const{scrollLeft:r,scrollWidth:i,clientWidth:d}=l.current;m(r+d{s?.(r)},u=()=>{l.current&&l.current.scrollBy({left:200,behavior:"smooth"})};return e.jsxs(f.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-4",children:[e.jsx("h3",{className:"text-base font-bold mb-3",style:{color:o.headerText},children:"Recommended for Review"}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("div",{ref:l,onScroll:h,className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t.slice(0,8).map((r,i)=>e.jsxs("button",{onClick:()=>p(r),className:"flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-semibold transition-all hover:scale-[1.02] whitespace-nowrap",style:{backgroundColor:o.pillBg,color:o.pillText},children:[e.jsx(x,{size:14}),g(r),e.jsx(n,{size:14})]},`${r}-${i}`))}),c&&e.jsx("button",{onClick:u,className:"flex-shrink-0 ml-2 w-8 h-8 rounded-full flex items-center justify-center transition-colors",style:{backgroundColor:o.arrowBg},"aria-label":"Scroll right",children:e.jsx(n,{size:16,className:"text-gray-600"})})]}),e.jsx("style",{children:` +import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{m as f,p as x}from"./index-BaOs5Ayg.js";import{C as n}from"./chevron-right-COqGruhh.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const o={pillBg:"#E9D5FF",pillText:"#6B21A8",headerText:"#1F2937",arrowBg:"#F3F4F6"},b={functions:"Functions & Graphs",businessmath:"Business Math",logic:"Logic & Reasoning",statistics:"Statistics",probability:"Probability",precalc:"Pre-Calculus",calculus:"Basic Calculus",geometry:"Geometry",trigonometry:"Trigonometry",algebra:"Algebra"};function g(t){const s=t.toLowerCase().trim();return b[s]||t.split(/[-_]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}const L=({atRiskSubjects:t=[],onTopicClick:s})=>{const l=a.useRef(null),[c,m]=a.useState(!1);if(t.length===0)return null;const h=()=>{if(l.current){const{scrollLeft:r,scrollWidth:i,clientWidth:d}=l.current;m(r+d{s?.(r)},u=()=>{l.current&&l.current.scrollBy({left:200,behavior:"smooth"})};return e.jsxs(f.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-4",children:[e.jsx("h3",{className:"text-base font-bold mb-3",style:{color:o.headerText},children:"Recommended for Review"}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("div",{ref:l,onScroll:h,className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t.slice(0,8).map((r,i)=>e.jsxs("button",{onClick:()=>p(r),className:"flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-semibold transition-all hover:scale-[1.02] whitespace-nowrap",style:{backgroundColor:o.pillBg,color:o.pillText},children:[e.jsx(x,{size:14}),g(r),e.jsx(n,{size:14})]},`${r}-${i}`))}),c&&e.jsx("button",{onClick:u,className:"flex-shrink-0 ml-2 w-8 h-8 rounded-full flex items-center justify-center transition-colors",style:{backgroundColor:o.arrowBg},"aria-label":"Scroll right",children:e.jsx(n,{size:16,className:"text-gray-600"})})]}),e.jsx("style",{children:` .scrollbar-hide::-webkit-scrollbar { display: none; } diff --git a/assets/TeacherDashboard-CzDqNb42.js b/assets/TeacherDashboard-CZdYfdg9.js similarity index 99% rename from assets/TeacherDashboard-CzDqNb42.js rename to assets/TeacherDashboard-CZdYfdg9.js index 3b757079a54cf4cef60302d535e2f72ea906d3f0..18f428c6b8f9dcc4d04f8a5de0c4c967b98b5a2a 100644 --- a/assets/TeacherDashboard-CzDqNb42.js +++ b/assets/TeacherDashboard-CZdYfdg9.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/index-Cb8VeSuW.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-Aaqs1LGb.css"])))=>i.map(i=>d[i]); -import{e as pt,f as Ge,g as Wl,h as Ve,i as hr,a as Vt,j as Qt,m as Re,G as mo,B as uo,Z as $s,u as Ks,t as ce,k as Os,l as nt,T as ka,U as Ps,C as Vl,n as en,R as _s,o as ql,p as Gt,q as tn,r as sn,A as Yl,v as Kl,w as Xl,x as Jl,y as Zl,z as ei,M as ti,D as si,_ as ba,E as ai}from"./index-Cb8VeSuW.js";import{d as oe,j as e,r as p,c as ri}from"./vendor-react-B4AQeu28.js";import{c as ni,B as $e}from"./button-De2q2xHf.js";import{I as vt}from"./input-w3MoyecB.js";import{D as xo,a as ho,b as po,c as fo,d as go,e as bo,f as oi}from"./dialog-CCp2tnRr.js";import li from"./ConfirmModal-B7469iTj.js";import{M as ii,L as ci,S as di,a as mi}from"./LogoutActionButton-Cb7v3MhK.js";import{collection as Bt,query as zt,limit as vo,where as Ft,getDocs as qt,orderBy as ui,onSnapshot as Xs,setDoc as Ut,doc as et,updateDoc as yt,getDoc as ns,serverTimestamp as ot,deleteDoc as xi,arrayUnion as hi}from"./vendor-firebase-firestore-CH1lNiRF.js";import{S as pi,a as fi}from"./vendor-radix-BorKzPz9.js";import{T as gi,a as bi,b as vi}from"./tooltip-BY91VKdD.js";import{X as va}from"./x-CTLBAl-n.js";import{s as an,f as Ni,d as ji,L as yi,p as wi,a as Si,S as ki}from"./quizService-CJqOfhFJ.js";import{logQuizGeneration as Ci}from"./trackingService-uiTTm34h.js";import{C as Pt}from"./chevron-left-CZaM7nZW.js";import{E as pr,a as Ti}from"./eye-DBkZRvYD.js";import{S as zs}from"./send-CMJOaNp6.js";import{T as No}from"./trash-2-DB-oXtbr.js";import{C as Ca}from"./circle-alert-DgDGv7k5.js";import{C as gs}from"./check-DSwzaW4Y.js";import{I as tr,F as fr,T as Ii,a as Ei,b as _a,c as ms,d as Ri,e as ss,f as Ai,D as Mi}from"./table-CQN68i0p.js";import{C as Na,a as Ht}from"./chevron-up-Byo9SJJ4.js";import{M as jo}from"./minus-CMQilTBg.js";import{P as ma}from"./plus-uFWGSQCY.js";import{C as Li,a as Ts,b as Is,c as Es,d as Rs}from"./card-DXoGKpl1.js";import{D as gr}from"./download-C-V0pYsk.js";import{C as Wt}from"./chevron-right-CoVWpXdD.js";import{S as yo}from"./save-CpWDoSfX.js";import{S as Js}from"./search-CMbwAzt9.js";import{U as Di}from"./upload-D5cppfxb.js";import{u as zi}from"./useQuery-PwtHq3dz.js";import{S as rn,g as Fi,G as Bi,s as nn}from"./subjects-Bnu0lJdU.js";import{u as $i}from"./useCurriculum-B8pRV6G_.js";import{C as Hs}from"./chart-column-CmH46HAG.js";import{C as ja}from"./circle-check-big-CNGbqkWz.js";import wo from"./ChatMarkdown-B5QlckxZ.js";import{B as ua}from"./bell-DsHB20Hc.js";import{C as Oi}from"./check-check-CS5aviKH.js";import{C as So}from"./clock-BodmJJnp.js";import{S as he}from"./skeleton-Bue6-H9w.js";import{u as wt,r as Pi}from"./vendor-xlsx-uZelXSz_.js";import{C as ko}from"./circle-help-hn0lWYq9.js";import{S as Co}from"./shield-check-DqJE0odB.js";import{R as sr,L as _i,Y as ar,a as oa,T as rr,b as Hi,B as on,C as ln,X as cn,d as dn,e as Gi}from"./vendor-charts-D8hf8tI0.js";import{C as To}from"./clipboard-check-BEObtDZM.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-CM6AS10M.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/index-BaOs5Ayg.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-DdX2rVyy.css"])))=>i.map(i=>d[i]); +import{e as pt,f as Ge,g as Wl,h as Ve,i as hr,a as Vt,j as Qt,m as Re,G as mo,B as uo,Z as $s,u as Ks,t as ce,k as Os,l as nt,T as ka,U as Ps,C as Vl,n as en,R as _s,o as ql,p as Gt,q as tn,r as sn,A as Yl,v as Kl,w as Xl,x as Jl,y as Zl,z as ei,M as ti,D as si,_ as ba,E as ai}from"./index-BaOs5Ayg.js";import{d as oe,j as e,r as p,c as ri}from"./vendor-react-B4AQeu28.js";import{c as ni,B as $e}from"./button-DCfeFHoH.js";import{I as vt}from"./input-D28h_UTJ.js";import{D as xo,a as ho,b as po,c as fo,d as go,e as bo,f as oi}from"./dialog-CHtYkwVl.js";import li from"./ConfirmModal-6cgkqXAT.js";import{M as ii,L as ci,S as di,a as mi}from"./LogoutActionButton-lUNItet6.js";import{collection as Bt,query as zt,limit as vo,where as Ft,getDocs as qt,orderBy as ui,onSnapshot as Xs,setDoc as Ut,doc as et,updateDoc as yt,getDoc as ns,serverTimestamp as ot,deleteDoc as xi,arrayUnion as hi}from"./vendor-firebase-firestore-CH1lNiRF.js";import{S as pi,a as fi}from"./vendor-radix-BorKzPz9.js";import{T as gi,a as bi,b as vi}from"./tooltip-ChRIOid3.js";import{X as va}from"./x-TNvtuOD9.js";import{s as an,f as Ni,d as ji,L as yi,p as wi,a as Si,S as ki}from"./quizService-8JHQlvu9.js";import{logQuizGeneration as Ci}from"./trackingService-DQ12buWG.js";import{C as Pt}from"./chevron-left-BWpgclqc.js";import{E as pr,a as Ti}from"./eye-Ig3S6mOs.js";import{S as zs}from"./send-CwwDU3uJ.js";import{T as No}from"./trash-2-HTnKafZd.js";import{C as Ca}from"./circle-alert-CP9K3300.js";import{C as gs}from"./check-BLSo9L0H.js";import{I as tr,F as fr,T as Ii,a as Ei,b as _a,c as ms,d as Ri,e as ss,f as Ai,D as Mi}from"./table-xeOJ8ZAA.js";import{C as Na,a as Ht}from"./chevron-up-Cdvz2TMJ.js";import{M as jo}from"./minus-DfrEv-SC.js";import{P as ma}from"./plus-DkG35AoH.js";import{C as Li,a as Ts,b as Is,c as Es,d as Rs}from"./card-D4dmQVNb.js";import{D as gr}from"./download-DX_YebqQ.js";import{C as Wt}from"./chevron-right-COqGruhh.js";import{S as yo}from"./save-CQIJrhLf.js";import{S as Js}from"./search-Bq99THgc.js";import{U as Di}from"./upload-DayXhGwD.js";import{u as zi}from"./useQuery-BnRttv09.js";import{S as rn,g as Fi,G as Bi,s as nn}from"./subjects-BFghB0SQ.js";import{u as $i}from"./useCurriculum-DDCuCvMR.js";import{C as Hs}from"./chart-column-B3jJOD5i.js";import{C as ja}from"./circle-check-big-m1SvzGFL.js";import wo from"./ChatMarkdown-fgwaycBR.js";import{B as ua}from"./bell-clcSMJn6.js";import{C as Oi}from"./check-check-B_HghS1Z.js";import{C as So}from"./clock-D1Ecvltm.js";import{S as he}from"./skeleton-Bo6ISWhm.js";import{u as wt,r as Pi}from"./vendor-xlsx-uZelXSz_.js";import{C as ko}from"./circle-help-B8apTIdU.js";import{S as Co}from"./shield-check-Dgisjfmb.js";import{R as sr,L as _i,Y as ar,a as oa,T as rr,b as Hi,B as on,C as ln,X as cn,d as dn,e as Gi}from"./vendor-charts-D8hf8tI0.js";import{C as To}from"./clipboard-check-DqBu2Pqb.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-BenDMDly.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. @@ -77,7 +77,7 @@ ${o}`:void 0,curriculumRetrievalConfidence:i,curriculumRetrievalBand:c,curriculu `),Ne+=` Answer: ${A.correctAnswer} `,Ne+=` Explanation: ${A.explanation} `,Ne}).join(` -`);navigator.clipboard.writeText(x),W(!0),setTimeout(()=>W(!1),2e3)},$l=()=>{if(!V)return;const x=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),A=URL.createObjectURL(x),L=document.createElement("a");L.href=A,L.download=`quiz_${N.replace(/\s/g,"_")}_${Date.now()}.json`,L.click(),URL.revokeObjectURL(A)};k.length>0||Object.values(Da).flat().length>0;const qr=(x,A)=>{const L=A?.gradeLevel||N,Ne=A?.topics||k,Ue=x.questions.map((_e,St)=>({id:`q_${Date.now()}_${St}`,questionType:_e.questionType||"identification",question:_e.question,..._e.options?{options:_e.options}:{},correctAnswer:_e.correctAnswer,bloomLevel:_e.bloomLevel||"understand",difficulty:_e.difficulty||"medium",topic:_e.topic,subject:L,points:_e.points,explanation:_e.explanation}));return{title:`${L} Quiz – ${Ne.length>0?Ne.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:L,questions:Ue,totalPoints:x.totalPoints,metadata:{topicsCovered:Object.keys(x.metadata.topicsCovered),difficultyBreakdown:{easy:x.metadata.difficultyBreakdown.easy??0,medium:x.metadata.difficultyBreakdown.medium??0,hard:x.metadata.difficultyBreakdown.hard??0},bloomDistribution:x.metadata.bloomTaxonomyDistribution,questionTypeBreakdown:x.metadata.questionTypeBreakdown,supplementalPurpose:x.metadata.supplementalPurpose,recommendedTeacherActions:x.metadata.recommendedTeacherActions??[],generatedAt:new Date().toISOString(),generatedBy:"teacher_generated"},status:"draft",source:"teacher_generated"}},Yr=p.useCallback(x=>{Cs(A=>[x,...A.filter(L=>L.id!==x.id)])},[]);async function Kr(x,A){if(!n)return null;const L=qr(x,A),Ne=await an(L,n.uid,Be?{documentId:Be}:void 0);return Te(Ne),Yr({id:Ne,...L,teacherId:n.uid}),Ne}const Ol=async()=>{if(!V){ce.error("No quiz to save. Generate a quiz first.");return}if(!n){ce.error("You must be signed in to save quizzes.");return}ue(!0);try{const x=qr(V),A=await an(x,n.uid,Be?{documentId:Be}:void 0);Te(A),Yr({id:A,...x,teacherId:n.uid}),ce.success("Quiz saved to your library!")}catch(x){ce.error(x instanceof Error?x.message:"Failed to save quiz")}finally{ue(!1)}},Pl=async()=>{if(Be){xt(!0);try{await wi(Be),Cs(x=>x.map(A=>A.id===Be?{...A,status:"published"}:A)),ce.success("Quiz published to Quiz Bank!")}catch(x){ce.error(x instanceof Error?x.message:"Failed to publish quiz")}finally{xt(!1)}}},$a=async x=>{const A=x??Be;if(!A){ce.error("Save the quiz first before assigning.");return}if(_r(A),es(!0),$r(null),Br(""),zr.length===0&&n){Fr(!0);try{const L=await Ar(n.uid);Cl(L)}catch{ce.error("Failed to load students")}finally{Fr(!1)}}},_l=async()=>{const x=Rl??Be;if(!(!ts||!x||!n)){aa(!0);try{await Si(x,ts,n.uid),Cs(A=>A.map(L=>L.id===x?{...L,status:"assigned",metadata:{...L.metadata,assignedTo:ts}}:L)),ce.success("Quiz assigned to student!"),es(!1),_r(null),i==="bank"&&Oa()}catch(A){ce.error(A instanceof Error?A.message:"Failed to assign quiz")}finally{aa(!1)}}},Oa=p.useCallback(async()=>{if(n){Pr(!0);try{const x=await Ni(n.uid);Cs(x)}catch{ce.error("Failed to load quiz bank")}finally{Pr(!1)}}},[n]);p.useEffect(()=>{i==="bank"&&Oa()},[i,Oa]);const Hl=async x=>{try{await ji(x),Cs(A=>A.filter(L=>L.id!==x)),ce.success("Quiz deleted")}catch{ce.error("Failed to delete quiz")}},Xr=zr.filter(x=>x.name.toLowerCase().includes(Ma.toLowerCase())||x.email.toLowerCase().includes(Ma.toLowerCase())),Jr=La==="all"?Or:Or.filter(x=>x.status===La),Gl=x=>{const A=(x.metadata.topicsCovered||[]).reduce((L,Ne)=>(L[Ne]=(L[Ne]||0)+1,L),{});return{questions:x.questions.map(L=>({questionType:L.questionType,question:L.question,correctAnswer:L.correctAnswer,options:L.options??null,bloomLevel:L.bloomLevel,difficulty:L.difficulty,topic:L.topic,points:L.points,explanation:L.explanation})),totalPoints:x.totalPoints,metadata:{topicsCovered:A,difficultyBreakdown:x.metadata.difficultyBreakdown,bloomTaxonomyDistribution:x.metadata.bloomDistribution,questionTypeBreakdown:x.metadata.questionTypeBreakdown,gradeLevel:x.gradeLevel,totalQuestions:x.questions.length,includesGraphQuestions:!1,supplementalPurpose:x.metadata.supplementalPurpose,bloomTaxonomyRationale:"Loaded from saved quiz bank entry.",recommendedTeacherActions:x.metadata.recommendedTeacherActions||[]}}},Pa=x=>{Te(x.id),we(Gl(x)),ke(null),ra(x.id),He("all"),Xe("all"),Me(null),u("results"),c("create")},Ql={remember:"bg-sky-100 text-sky-700 border-sky-300",understand:"bg-rose-100 text-rose-700 border-rose-300",apply:"bg-emerald-100 text-emerald-700 border-emerald-300",analyze:"bg-rose-100 text-rose-700 border-rose-300"},Ul=(x,A,L)=>{const Ne=fe===A,Ue=Ql[x.bloomLevel]||"bg-[#edf1f7] text-[#5a6578] border-[#dde3eb]";return e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:A*.05},className:"border border-[#dde3eb] rounded-xl overflow-hidden relative",children:[e.jsx("div",{className:`absolute top-2 right-2 text-[10px] font-bold uppercase px-2 py-0.5 rounded border ${Ue} z-10`,children:x.bloomLevel}),e.jsx("div",{className:"p-4 cursor-pointer hover:bg-[#edf1f7] transition-colors",onClick:()=>Me(Ne?null:A),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-bold text-white bg-sky-600 px-2 py-0.5 rounded",children:["Q",A+1]}),e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded border ${Va[x.bloomLevel]?.color||"bg-[#edf1f7] text-[#5a6578]"}`,children:x.bloomLevel}),e.jsx("span",{className:`text-xs font-medium ${On[x.difficulty]||"text-[#5a6578]"}`,children:x.difficulty}),e.jsxs("span",{className:"text-xs text-slate-500",children:[x.points," pts"]}),e.jsx("span",{className:"text-xs bg-[#edf1f7] text-[#5a6578] px-2 py-0.5 rounded",children:x.topic})]}),e.jsx("p",{className:"text-sm text-[#0a1628] font-medium",children:x.question})]}),e.jsx("div",{className:"flex-shrink-0 mt-1",children:Ne?e.jsx(Na,{size:16,className:"text-slate-500"}):e.jsx(Ht,{size:16,className:"text-slate-500"})})]})}),e.jsx(Qt,{children:Ne&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-t border-[#dde3eb] overflow-hidden",children:e.jsxs("div",{className:"p-4 space-y-3 bg-[#edf1f7]/50",children:[x.options&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-1",children:"Options:"}),e.jsx("div",{className:"space-y-1",children:x.options.map((_e,St)=>e.jsx("div",{className:`text-sm px-3 py-1.5 rounded-lg ${_e.includes(x.correctAnswer)?"bg-green-100 text-green-800 font-medium":"bg-white text-[#0a1628]"}`,children:_e},St))})]}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-green-700 mb-1",children:"Correct Answer:"}),e.jsx("p",{className:"text-sm text-green-800 font-medium",children:x.correctAnswer})]}),e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-sky-700 mb-1",children:"Explanation:"}),e.jsx("p",{className:"text-sm text-sky-800",children:x.explanation})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-slate-500",children:[e.jsxs("span",{children:["Type: ",ca[x.questionType]?.label||x.questionType]}),e.jsxs("span",{children:["Bloom: ",x.bloomLevel]})]}),x.provenance&&e.jsxs("div",{className:"bg-[#f7fbff] border border-sky-100 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-sky-700 mb-1",children:"Item Provenance"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1 text-xs text-[#5a6578]",children:[x.provenance.title&&e.jsxs("p",{children:["Topic: ",x.provenance.title]}),x.provenance.topicId&&e.jsxs("p",{children:["Topic ID: ",x.provenance.topicId]}),x.provenance.materialId&&e.jsxs("p",{children:["Material ID: ",x.provenance.materialId]}),x.provenance.sourceFile&&e.jsxs("p",{children:["Source File: ",x.provenance.sourceFile]}),x.provenance.sectionId&&e.jsxs("p",{children:["Section ID: ",x.provenance.sectionId]})]})]})]})})})]},A)};return e.jsxs("div",{className:"w-full flex flex-col bg-[#f7f9fc] min-h-screen",children:[e.jsxs("div",{className:"bg-white border-b border-[#dde3eb] px-6 py-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("button",{onClick:Ba,className:"p-2 hover:bg-[#edf1f7] rounded-lg transition-colors text-slate-500",children:e.jsx(Pt,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-[#0a1628]",children:"AI Quiz Maker"}),e.jsx("p",{className:"text-[#5a6578] text-sm mt-1",children:"Generate AI-powered assessments with Bloom's Taxonomy"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>c("create"),className:`flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold transition-colors ${i==="create"?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:[e.jsx(hc,{size:16})," Create Quiz"]}),e.jsxs("button",{onClick:()=>c("bank"),className:`flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold transition-colors ${i==="bank"?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:[e.jsx(mn,{size:16})," Quiz Bank"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 sm:px-8 xl:px-10 py-8",children:[i==="bank"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:["all","draft","published","assigned","completed"].map(x=>e.jsx("button",{onClick:()=>El(x),className:`px-3 py-1.5 rounded-full text-xs font-semibold capitalize transition-colors ${La===x?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:x},x))}),Il?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(nt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):Jr.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(mn,{size:40,className:"mb-3"}),e.jsx("p",{className:"font-medium",children:"No quizzes found"}),e.jsx("p",{className:"text-xs mt-1",children:"Generate your first quiz in the Create tab"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Jr.map(x=>e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>Pa(x),role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),Pa(x))},className:"border border-[#dde3eb] rounded-xl p-4 hover:shadow-md transition-shadow cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] leading-tight",children:x.title}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full capitalize ${lm[x.status]}`,children:x.status})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:x.metadata.topicsCovered.slice(0,3).map(A=>e.jsx("span",{className:"text-[10px] bg-[#edf1f7] text-[#5a6578] px-2 py-0.5 rounded",children:A},A))}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#5a6578] mb-3",children:[e.jsxs("span",{children:[x.questions.length," questions"]}),e.jsxs("span",{children:[x.totalPoints," pts"]}),e.jsx("span",{children:x.gradeLevel})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:A=>{A.stopPropagation(),Pa(x)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-[#edf1f7] text-[#5a6578] rounded-lg hover:bg-[#dde3eb] transition-colors",children:[e.jsx(pr,{size:12})," View"]}),e.jsxs("button",{onClick:A=>{A.stopPropagation(),$a(x.id)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-sky-50 text-sky-700 rounded-lg hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:12})," Assign"]}),e.jsxs("button",{onClick:A=>{A.stopPropagation(),Hl(x.id)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition-colors",children:[e.jsx(No,{size:12})," Delete"]})]})]},x.id))})]}),i==="create"&&e.jsxs(e.Fragment,{children:[O&&e.jsxs(Re.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"mb-4 bg-red-50 border border-red-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(Ca,{size:18,className:"text-red-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-red-800 font-medium",children:"Error"}),e.jsx("p",{className:"text-sm text-red-600",children:O})]}),e.jsx("button",{onClick:()=>q(""),className:"ml-auto",children:e.jsx(va,{size:14,className:"text-red-400"})})]}),me&&e.jsxs(Re.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-4 bg-white border border-sky-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nt,{size:16,className:"animate-spin text-sky-600"}),e.jsx("p",{className:"text-sm font-semibold text-[#0a1628]",children:"Generating Quiz in Background"})]}),e.jsxs("span",{className:"text-xs font-bold text-sky-700",children:[xe,"%"]})]}),e.jsx("div",{className:"h-2 bg-[#edf1f7] rounded-full overflow-hidden",children:e.jsx(Re.div,{animate:{width:`${xe}%`},transition:{duration:.35,ease:"easeOut"},className:"h-full bg-gradient-to-r from-sky-600 to-cyan-500"})}),e.jsxs("p",{className:"mt-2 text-xs text-[#5a6578] capitalize",children:["Stage: ",G.replace(/_/g," ")]}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:le}),K&&e.jsxs("p",{className:"text-[11px] text-[#7b8798] mt-1",children:["Task ID: ",K]})]}),!me&&d!=="results"&&e.jsx("div",{className:"flex bg-white rounded-xl border border-[#dde3eb] mb-6 overflow-hidden shadow-sm",children:[{id:"setup",label:"Setup"},{id:"topics",label:"Topics"},{id:"style",label:"Question style"},{id:"preview",label:"Preview"}].map((x,A)=>{const Ne=["setup","topics","style","preview"].indexOf(d),Ue=Ne>A,_e=Ne===A;return e.jsxs("div",{className:`flex-1 flex items-center justify-center py-3 border-r last:border-r-0 border-[#dde3eb] ${_e?"bg-purple-50":"bg-white"}`,children:[Ue?e.jsx("div",{className:"w-5 h-5 rounded-full bg-green-500 text-white flex items-center justify-center mr-2",children:e.jsx(gs,{size:12,strokeWidth:3})}):e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-xs font-bold mr-2 ${_e?"bg-[#9b51e0] text-white":"bg-[#edf1f7] text-slate-500"}`,children:A+1}),e.jsx("span",{className:`text-sm font-semibold ${_e?"text-[#9b51e0]":Ue?"text-slate-700":"text-slate-400"}`,children:x.label})]},x.id)})}),d==="setup"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-purple-50 border border-purple-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(tr,{size:18,className:"text-[#9b51e0] flex-shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-purple-800",children:["This quiz maker generates ",e.jsx("span",{className:"font-bold",children:"supplemental assessments"})," to support classroom instruction. Questions follow Bloom's Taxonomy for comprehensive skill evaluation. Generation limit: up to ",Ms," questions and ",xs," topics per quiz."]})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"BASIC SETTINGS"})}),e.jsxs("div",{className:"p-5 grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"quiz-grade-level",className:"text-sm font-semibold text-[#0a1628] mb-2 block",children:"Grade level"}),e.jsx("select",{id:"quiz-grade-level",value:N,onChange:x=>m(qa(x.target.value)),className:"w-full bg-white text-[#0a1628] rounded-lg px-4 py-3 text-sm outline-none border border-[#dde3eb] focus:ring-2 focus:ring-purple-500",children:im.map(x=>e.jsx("option",{value:x,children:x},x))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"quiz-num-questions",className:"text-sm font-semibold text-[#0a1628] mb-2 block",children:"Number of questions"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:()=>w(Math.max(1,h-1)),className:"w-12 h-12 border border-[#dde3eb] rounded-l-lg flex items-center justify-center hover:bg-[#edf1f7] text-[#edf1f7] transition-colors bg-white font-bold text-xl",children:e.jsx("span",{className:"text-[#dde3eb]",children:"-"})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:Ms,value:h,onChange:x=>w(Math.min(Ms,Math.max(1,parseInt(x.target.value)||1))),className:"flex-1 h-12 text-center border-y border-[#dde3eb] px-3 text-base font-bold focus:outline-none bg-white text-[#0a1628]"}),e.jsx("button",{onClick:()=>w(Math.min(Ms,h+1)),className:"w-12 h-12 border border-[#dde3eb] rounded-r-lg flex items-center justify-center hover:bg-[#edf1f7] text-[#edf1f7] transition-colors bg-white font-bold text-xl",children:e.jsx("span",{className:"text-[#dde3eb]",children:"+"})})]})]})]})]})]}),d==="topics"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Select topics"}),e.jsxs("p",{className:"text-sm text-[#5a6578]",children:["Choose up to ",xs," topics across all strands"]})]}),e.jsxs("div",{className:"bg-purple-50 text-[#9b51e0] px-3 py-1 rounded-full text-sm font-bold",children:[k.filter(x=>!f.includes(x)).length," of ",xs," selected"]})]}),ae?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(nt,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries(Da).map(([x,A])=>{const L=A.filter(Ue=>k.includes(Ue)&&!f.includes(Ue)).length,Ne=pe===x;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>De(Ne?null:x),className:"w-full flex items-center justify-between p-4 hover:bg-[#f7f9fc] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-1 h-6 bg-[#9b51e0] rounded-full"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-bold text-[#0a1628] text-sm",children:x}),e.jsxs("p",{className:"text-xs text-slate-500",children:[A.length," topics"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"bg-purple-100 text-[#9b51e0] px-2.5 py-0.5 rounded-full text-xs font-semibold",children:[L," selected"]}),Ne?e.jsx(Na,{size:18,className:"text-slate-400"}):e.jsx(Ht,{size:18,className:"text-slate-400"})]})]}),e.jsx(Qt,{children:Ne&&e.jsx(Re.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},className:"overflow-hidden border-t border-[#edf1f7]",children:e.jsx("div",{className:"py-2",children:A.map((Ue,_e)=>{const St=k.includes(Ue),na=f.includes(Ue),ct=St&&!na;let kt="Core";return _e%3===0&&(kt="Foundation"),_e%3===2&&(kt="Advanced"),e.jsxs("div",{className:"flex items-center justify-between px-6 py-3 hover:bg-[#f7f9fc]",children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("div",{className:`w-5 h-5 rounded flex items-center justify-center transition-colors ${ct?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:ct&&e.jsx(gs,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:ct,onChange:()=>Al(Ue)}),e.jsx("span",{className:`text-sm font-semibold ${ct?"text-[#0a1628]":"text-[#5a6578]"}`,children:Ue})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${kt==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:kt})]},Ue)})})})})]},x)})})]}),d==="style"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"QUESTION TYPES"})}),e.jsx("div",{className:"p-5 grid grid-cols-1 md:grid-cols-3 gap-4",children:Object.entries(ca).map(([x,A])=>{const L=S.includes(x);return e.jsxs("button",{onClick:()=>Ml(x),className:`flex flex-col items-center justify-center p-4 rounded-xl border-2 transition-all ${L?"bg-purple-50 border-purple-300":"bg-white border-[#dde3eb] hover:border-purple-200"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center mb-2 ${L?"bg-purple-200 text-[#9b51e0]":"bg-[#edf1f7] text-slate-400"}`,children:A.icon}),e.jsx("span",{className:`text-sm font-semibold ${L?"text-purple-800":"text-[#5a6578]"}`,children:A.label})]},x)})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"BLOOM'S TAXONOMY LEVELS"})}),e.jsx("div",{className:"p-5 flex flex-wrap gap-3",children:Object.entries(Va).map(([x,A])=>{const L=j.includes(x);return e.jsx("button",{onClick:()=>Ll(x),className:`px-5 py-2.5 rounded-full border-2 transition-all text-sm font-semibold capitalize ${L?"bg-white text-[#9b51e0] border-purple-300":"bg-white border-[#dde3eb] text-[#5a6578] hover:border-purple-200"}`,children:x},x)})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"DIFFICULTY DISTRIBUTION"})}),e.jsx("div",{className:"p-5 space-y-5",children:Object.entries(T).map(([x,A])=>{const Ne={easy:"bg-[#55b963]",medium:"bg-[#faa541]",hard:"bg-[#f47a75]"}[x];return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-semibold w-16 capitalize text-[#5a6578]",children:x}),e.jsx("div",{className:"flex-1 h-2 bg-[#edf1f7] rounded-full overflow-hidden",children:e.jsx(Re.div,{animate:{width:`${A}%`},className:`h-full rounded-full ${Ne}`})}),e.jsxs("div",{className:"flex items-center gap-1 w-20 justify-end",children:[e.jsx("button",{onClick:()=>Vr(x,-5),className:"w-6 h-6 rounded border border-[#dde3eb] flex items-center justify-center hover:bg-[#edf1f7] text-slate-500",children:e.jsx(jo,{size:10})}),e.jsxs("span",{className:"text-sm font-bold w-10 text-center text-slate-500",children:[A,"%"]}),e.jsx("button",{onClick:()=>Vr(x,5),className:"w-6 h-6 rounded border border-[#dde3eb] flex items-center justify-center hover:bg-[#edf1f7] text-slate-500",children:e.jsx(ma,{size:10})})]})]},x)})})]})]}),d==="preview"&&!me&&!V&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"QUIZ SUMMARY"})}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:h}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"questions"})]}),e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:k.filter(x=>!f.includes(x)).length}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"topics"})]}),e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:N.replace("Grade ","Gr. ")}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"level"})]})]}),e.jsxs("div",{className:"bg-[#f7f9fc] rounded-lg p-5 border border-[#dde3eb] text-sm text-[#5a6578] leading-relaxed",children:[S.map(x=>ca[x]?.label).join(" and ")," questions across ",k.filter(x=>!f.includes(x)).length," topics — aligned to ",j.map(x=>Va[x]?.label).join(", ")," levels of Bloom's Taxonomy. Easy ",T.easy,"% · Medium ",T.medium,"% · Hard ",T.hard,"%."]})]})]})}),d==="results"&&V&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-sky-50 to-cyan-50 border border-sky-200 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-bold font-display text-[#0a1628]",children:"Quiz Generated"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Bl,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-[#dde3eb] rounded-lg text-xs font-medium text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:[E?e.jsx(gs,{size:14,className:"text-green-500"}):e.jsx(Li,{size:14}),E?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:$l,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-[#dde3eb] rounded-lg text-xs font-medium text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:[e.jsx(gr,{size:14}),"Export JSON"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-sky-600",children:V.questions.length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Questions"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-rose-600",children:V.totalPoints}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Total Points"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-rose-600",children:Object.keys(V.metadata.topicsCovered).length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Topics"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:Object.keys(V.metadata.bloomTaxonomyDistribution).length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Bloom Levels"})]})]}),(V.metadata.usedImportedTopics||(V.metadata.topicProvenance||[]).length>0)&&e.jsxs("div",{className:"mt-4 bg-white rounded-lg p-3 border border-[#dde3eb]",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Imported Topic Provenance"}),e.jsxs("p",{className:"text-xs text-[#5a6578] mb-2",children:["Imported topics used: ",V.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",V.metadata.importedMaterialsCount??0," • ","Topics: ",V.metadata.importedTopicCount??0]}),(V.metadata.topicProvenance||[]).slice(0,5).map((x,A)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[x.title||"Untitled topic",x.sourceFile?` • ${x.sourceFile}`:""]},`${x.topicId||x.title||"topic"}_${A}`)),(Ur.length>0||Wr.length>0)&&e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"text-xs text-[#5a6578] flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Filter by Source File"}),e.jsxs("select",{value:ge,onChange:x=>He(x.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All sources"}),Ur.map(x=>e.jsx("option",{value:x,children:x},x))]})]}),e.jsxs("label",{className:"text-xs text-[#5a6578] flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Filter by Material ID"}),e.jsxs("select",{value:Je,onChange:x=>Xe(x.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All materials"}),Wr.map(x=>e.jsx("option",{value:x,children:x},x))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",za.length," of ",V.questions.length," questions after provenance filters."]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Difficulty"}),Object.entries(V.metadata.difficultyBreakdown).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:`capitalize ${On[x]||"text-[#5a6578]"}`,children:x}),e.jsx("span",{className:"font-medium",children:A})]},x))]}),e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Bloom's Taxonomy"}),Object.entries(V.metadata.bloomTaxonomyDistribution).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"capitalize",children:x}),e.jsx("span",{className:"font-medium",children:A})]},x))]}),e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Question Types"}),Object.entries(V.metadata.questionTypeBreakdown).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{children:ca[x]?.label||x}),e.jsx("span",{className:"font-medium",children:A})]},x))]})]}),e.jsxs("div",{className:"mt-3 bg-sky-50 rounded-lg p-3 flex items-start gap-2",children:[e.jsx(tr,{size:14,className:"text-sky-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-sky-600",children:V.metadata.supplementalPurpose})]}),V.metadata.recommendedTeacherActions&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-1",children:"Recommended Actions:"}),e.jsx("ul",{className:"list-disc list-inside text-xs text-[#5a6578] space-y-0.5",children:V.metadata.recommendedTeacherActions.map((x,A)=>e.jsx("li",{children:x},A))})]})]}),e.jsx("div",{className:"space-y-3",children:za.length>0?za.map((x,A)=>Ul(x,A)):e.jsx("div",{className:"border border-[#dde3eb] rounded-xl p-4 bg-white text-sm text-[#5a6578]",children:"No questions match the selected provenance filters. Clear one or both filters to view all questions."})})]})]})]}),i==="create"&&e.jsxs("div",{className:"border-t border-[#dde3eb] px-6 sm:px-6 xl:px-10 py-4 bg-[#f7f9fc] flex items-center justify-between flex-shrink-0",children:[d==="setup"&&!me&&e.jsxs(e.Fragment,{children:[e.jsx("div",{}),e.jsxs("button",{onClick:()=>u("topics"),className:"bg-white border border-[#dde3eb] text-[#edf1f7] px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:text-slate-600 flex items-center",children:[e.jsx("span",{className:"text-[#edf1f7]",children:"Next: Topics"})," ",e.jsx(Wt,{size:16,className:"ml-2 text-slate-300"})]})]}),d==="topics"&&!me&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>{y([]),v([])},className:"text-[#9b51e0] text-sm font-semibold hover:underline",children:"Clear all"}),e.jsxs("span",{className:"text-sm text-[#9b51e0]",children:[k.filter(x=>!f.includes(x)).length," of ",xs," topics selected"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>u("setup"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:()=>u("style"),className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:["Next: Question style ",e.jsx(Wt,{size:16,className:"ml-2 text-purple-200"})]})]})]}),d==="style"&&!me&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>u("topics"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:()=>u("preview"),className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:["Preview ",e.jsx(Wt,{size:16,className:"ml-2 text-purple-200"})]})]}),d==="preview"&&!me&&!V&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>u("style"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:Fl,className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-bold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:[e.jsx(gs,{size:16,className:"mr-2"})," Generate quiz"]})]}),me&&e.jsx("div",{className:"w-full flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(nt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})}),d==="results"&&(Hr?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c("bank"),ra(null)},className:"px-4 py-2.5 rounded-xl text-sm font-medium bg-white border border-[#dde3eb] text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:"Back to Quiz Bank"}),e.jsxs("button",{onClick:()=>$a(Hr),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-sky-50 border border-sky-300 text-sky-700 hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:16})," Assign"]}),e.jsx("button",{onClick:Ba,className:"px-5 py-2.5 rounded-xl text-sm font-bold bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white transition-all",children:"Done"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{u("setup"),we(null),ke(null),Te(null),ra(null)},className:"px-4 py-2.5 rounded-xl text-sm font-medium bg-white border border-[#dde3eb] text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:"Create Another"}),Be?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:Pl,disabled:tt,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-green-50 border border-green-300 text-green-700 hover:bg-green-100 transition-colors",children:[tt?e.jsx(nt,{size:16,className:"animate-spin"}):e.jsx(ka,{size:16}),"Publish"]}),e.jsxs("button",{onClick:()=>$a(),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-sky-50 border border-sky-300 text-sky-700 hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:16})," Assign"]})]}):e.jsxs("button",{onClick:Ol,disabled:U,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-emerald-50 border border-emerald-300 text-emerald-700 hover:bg-emerald-100 transition-colors",children:[U?e.jsx(nt,{size:16,className:"animate-spin"}):e.jsx(yo,{size:16}),"Save to Library"]}),e.jsx("button",{onClick:Ba,className:"px-5 py-2.5 rounded-xl text-sm font-bold bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white transition-all",children:"Done"})]}))]}),e.jsx(om,{isOpen:I,onClose:()=>Y(!1)}),e.jsx(Qt,{children:Aa&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/40 z-[60] flex items-center justify-center p-4",onClick:()=>es(!1),children:e.jsxs(Re.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-[#f7f9fc] rounded-2xl shadow-2xl w-full max-w-md max-h-[70vh] flex flex-col overflow-hidden border border-[#dde3eb]",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-[#dde3eb] flex items-center justify-between",children:[e.jsxs("h3",{className:"text-base font-bold font-display text-[#0a1628] flex items-center gap-2",children:[e.jsx(Ps,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>es(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(va,{size:16,className:"text-slate-500"})})]}),e.jsx("div",{className:"px-5 py-3 border-b border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center gap-2 bg-[#edf1f7] rounded-xl px-3 py-2",children:[e.jsx(Js,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:Ma,onChange:x=>Br(x.target.value),className:"flex-1 bg-transparent text-sm outline-none placeholder:text-slate-500"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1",children:Tl?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(nt,{size:20,className:"animate-spin text-sky-500"})}):Xr.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):Xr.map(x=>e.jsxs("button",{onClick:()=>$r(x.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${ts===x.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:x.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(x.name)}&background=random&size=32`,alt:x.name,className:"w-8 h-8 rounded-lg object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-[#0a1628] truncate",children:x.name}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:x.email})]}),ts===x.id&&e.jsx(gs,{size:16,className:"text-sky-600 flex-shrink-0"})]},x.id))}),e.jsxs("div",{className:"px-5 py-3 border-t border-[#dde3eb] flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>es(!1),className:"px-4 py-2 text-sm font-medium text-[#5a6578] hover:bg-[#edf1f7] rounded-xl transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:_l,disabled:!ts||ks,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${ts&&!ks?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[ks?e.jsx(nt,{size:14,className:"animate-spin"}):e.jsx(zs,{size:14}),"Assign"]})]})]})})})]})};function Ka({className:t,...s}){return e.jsx(fi,{"data-slot":"label",className:hr("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const um=()=>{const[t,s]=p.useState([]),[a,r]=p.useState(!1),[n,o]=p.useState(!1),[l,i]=p.useState(""),[c,d]=p.useState(11),[u,N]=p.useState("general_mathematics"),m=p.useCallback(async()=>{r(!0);try{const y=await en("/api/quiz-battle/bank-status");s(y.pdfs)}catch(y){const f=y instanceof Os?y.message:"Failed to load bank status";ce.error(f)}finally{r(!1)}},[]);p.useEffect(()=>{m()},[m]);const h=async()=>{if(!l.trim()){ce.error("Please enter a storage path");return}o(!0);try{await en("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:l.trim(),grade_level:c,topic:u.trim(),force_reingest:!1})}),ce.success("PDF ingestion completed"),await m(),i("")}catch(y){const f=y instanceof Os?y.message:"Ingestion failed";ce.error(f)}finally{o(!1)}},w=t.reduce((y,f)=>y+f.question_count,0),k=t.filter(y=>y.processed).length;return e.jsxs("div",{className:"space-y-6 p-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-[#9956DE]/12 rounded-xl border border-[#9956DE]/30",children:e.jsx(Vt,{className:"h-5 w-5 text-[#9956DE]"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground",children:"Question Bank"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage PDF-ingested quiz questions for battle sessions"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(fr,{className:"h-4 w-4"}),"Total PDFs"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:t.length})})]}),e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Vt,{className:"h-4 w-4"}),"Total Questions"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:w})})]}),e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(_s,{className:"h-4 w-4"}),"Processed"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:k})})]})]}),e.jsxs(Ts,{children:[e.jsx(Is,{children:e.jsx(Es,{className:"text-base font-display font-bold",children:"Ingest New PDF"})}),e.jsxs(Rs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"storagePath",children:"Firebase Storage Path"}),e.jsx(vt,{id:"storagePath",placeholder:"quiz_pdfs/grade_11/general_math.pdf",value:l,onChange:y=>i(y.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"gradeLevel",children:"Grade Level"}),e.jsx(vt,{id:"gradeLevel",type:"number",min:7,max:12,value:c,onChange:y=>d(Number(y.target.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"topic",children:"Topic Slug"}),e.jsx(vt,{id:"topic",placeholder:"general_mathematics",value:u,onChange:y=>N(y.target.value)})]})]}),e.jsxs($e,{onClick:h,disabled:n,className:"bg-[#9956DE] hover:bg-[#9956DE]/90",children:[n?e.jsx(nt,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Di,{className:"mr-2 h-4 w-4"}),"Ingest PDF"]})]})]}),e.jsxs(Ts,{children:[e.jsxs(Is,{className:"flex flex-row items-center justify-between",children:[e.jsx(Es,{className:"text-base font-display font-bold",children:"Processing Status"}),e.jsx($e,{variant:"outline",size:"sm",onClick:m,disabled:a,children:e.jsx(_s,{className:`h-4 w-4 ${a?"animate-spin":""}`})})]}),e.jsx(Rs,{children:e.jsxs(Ii,{children:[e.jsx(Ei,{children:e.jsxs(_a,{children:[e.jsx(ms,{children:"Filename"}),e.jsx(ms,{children:"Grade"}),e.jsx(ms,{children:"Topic"}),e.jsx(ms,{children:"Questions"}),e.jsx(ms,{children:"Status"}),e.jsx(ms,{children:"Processed At"})]})}),e.jsxs(Ri,{children:[t.map(y=>e.jsxs(_a,{children:[e.jsx(ss,{className:"font-medium",children:y.filename}),e.jsx(ss,{children:y.grade_level}),e.jsx(ss,{children:y.topic}),e.jsx(ss,{children:y.question_count}),e.jsx(ss,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${y.processed?"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300"}`,children:y.processed?"Processed":"Pending"})}),e.jsx(ss,{children:y.timestamp?new Date(y.timestamp).toLocaleDateString():"-"})]},y.filename)),t.length===0&&e.jsx(_a,{children:e.jsx(ss,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No PDFs processed yet. Upload a PDF to get started."})})]})]})})]})]})},Pn={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},xm={"gen-math":{label:"GEN MATH",color:"bg-sky-100 text-sky-700"},"stats-prob":{label:"STAT&PROB",color:"bg-sky-100 text-sky-700"},"pre-calc":{label:"PRE-CALC",color:"bg-orange-100 text-orange-700"},"basic-calc":{label:"BASIC CALC",color:"bg-red-100 text-red-700"}},hm={mastered:{label:"MASTERED BY CLASS",color:"bg-green-100 text-green-700 border-green-300"},on_track:{label:"ON TRACK",color:"bg-sky-100 text-sky-700 border-sky-300"},needs_attention:{label:"NEEDS ATTENTION",color:"bg-red-100 text-red-700 border-red-300"},no_data:{label:"NO DATA YET",color:"bg-[#edf1f7] text-[#5a6578] border-[#dde3eb]"}},_n={needs_attention:0,on_track:1,no_data:2,mastered:3},pm=({classSectionId:t})=>{const{currentUser:s}=Ks(),[a,r]=p.useState([]),[n,o]=p.useState(Pn),[l,i]=p.useState(!0),[c,d]=p.useState("all"),[u,N]=p.useState("all"),[m,h]=p.useState(""),[w,k]=p.useState("classAverage"),[y,f]=p.useState("asc"),v=rn.map(D=>D.id),S=rn.reduce((D,te)=>(D[te.id]=te.name,D),{}),{isLoading:R}=$i();p.useEffect(()=>{},[R]);const[j,B]=p.useState(new Set),[g,b]=p.useState([]),T=zi({queryKey:ql.topicMastery(s?.uid||"anonymous",t),enabled:!!s,staleTime:120*1e3,gcTime:900*1e3,queryFn:async()=>{try{if(!s)return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}};const D=et(Ge,"teachers",s.uid,"settings","quizSettings"),te=await ns(D),J=te.exists()?te.data()?.excludedTopics||[]:[],me="https://deign86-mathpulse-api-v3test.hf.space",Ce=new URLSearchParams({teacherId:s.uid});t&&Ce.set("classSectionId",t);const F=await s.getIdToken(),C=await fetch(`${me}/api/analytics/topic-mastery?${Ce.toString()}`,{headers:{Authorization:`Bearer ${F}`}});if(!C.ok)return{excluded:J,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:J.length}};const K=await C.json(),P=(K.topics||[]).map(xe=>({...xe,isExcluded:J.includes(xe.topicName)}));return{excluded:J,topics:P,summary:K.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:J.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});p.useEffect(()=>{if(i(T.isLoading||T.isFetching),!T.data){b([]),r([]),o(Pn),B(new Set);return}b(T.data.excluded),r(T.data.topics),o(T.data.summary)},[T.data,T.isFetching,T.isLoading]);const z=async D=>{if(!s)return;const te=g.includes(D)?g.filter(J=>J!==D):[...g,D];b(te),r(J=>J.map(me=>me.topicName===D?{...me,isExcluded:!me.isExcluded}:me)),o(J=>({...J,excludedCount:te.length}));try{const J=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(J)).exists()?await yt(J,{excludedTopics:te}):await Ut(J,{excludedTopics:te})}catch{ce.error("Failed to update excluded topics")}},$=async()=>{if(!s)return;const D=[...new Set([...g,...j])];b(D),r(te=>te.map(J=>j.has(J.topicName)?{...J,isExcluded:!0}:J)),o(te=>({...te,excludedCount:D.length})),B(new Set);try{const te=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(te)).exists()?await yt(te,{excludedTopics:D}):await Ut(te,{excludedTopics:D}),ce.success(`${j.size} topics excluded from quizzes`)}catch{ce.error("Failed to update")}},Z=async()=>{if(!s)return;const D=g.filter(te=>!j.has(te));b(D),r(te=>te.map(J=>j.has(J.topicName)?{...J,isExcluded:!1}:J)),o(te=>({...te,excludedCount:D.length})),B(new Set);try{const te=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(te)).exists()?await yt(te,{excludedTopics:D}):await Ut(te,{excludedTopics:D}),ce.success(`${j.size} topics re-included in quizzes`)}catch{ce.error("Failed to update")}},ae=D=>{w===D?f(te=>te==="asc"?"desc":"asc"):(k(D),f("asc"))},H=u==="all"?v:Fi(u);p.useEffect(()=>{c!=="all"&&(H.includes(c)||d("all"))},[H,c]);const ee=a.filter(D=>!(c!=="all"&&D.subjectId!==c||!H.includes(D.subjectId)||m&&!D.topicName.toLowerCase().includes(m.toLowerCase()))).sort((D,te)=>{const J=y==="asc"?1:-1;switch(w){case"topicName":return J*D.topicName.localeCompare(te.topicName);case"classAverage":return J*(D.classAverage-te.classAverage);case"studentsAttempted":return J*(D.studentsAttempted-te.studentsAttempted);case"masteryStatus":return J*((_n[D.masteryStatus]||0)-(_n[te.masteryStatus]||0));default:return 0}}),re=()=>{j.size===ee.length?B(new Set):B(new Set(ee.map(D=>D.topicName)))},ne=({field:D})=>w!==D?e.jsx(Ht,{size:12,className:"text-slate-500"}):y==="asc"?e.jsx(Na,{size:12,className:"text-sky-600"}):e.jsx(Ht,{size:12,className:"text-sky-600"});return l?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(nt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-[#5a6578]",children:"Loading topic mastery data..."})]}):e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[#0a1628]",children:"Class Topic Mastery"}),e.jsx("p",{className:"text-sm text-[#5a6578] mt-1",children:"Topics where 75% or more of the class scored 85%+ are marked as mastered and can be excluded from future quiz generation."})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-sky-100 rounded-xl flex items-center justify-center",children:e.jsx(Hs,{size:20,className:"text-sky-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:n.totalTopicsTracked}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Total Topics Tracked"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-green-200",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-xl flex items-center justify-center",children:e.jsx(ja,{size:20,className:"text-green-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:n.masteredCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Mastered by Class"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-red-200",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-red-100 rounded-xl flex items-center justify-center",children:e.jsx(Gt,{size:20,className:"text-red-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:n.needsAttentionCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Needs Work"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-[#edf1f7] rounded-xl flex items-center justify-center",children:e.jsx(Ti,{size:20,className:"text-[#5a6578]"})})}),e.jsx("p",{className:"text-2xl font-bold text-[#5a6578]",children:n.excludedCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Excluded Topics"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white rounded-xl px-3 py-2 border border-[#dde3eb]",children:[e.jsx(Js,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:m,onChange:D=>h(D.target.value),className:"bg-transparent text-sm outline-none w-40 placeholder:text-slate-500"})]}),e.jsxs("select",{value:c,onChange:D=>d(D.target.value),className:"bg-white border border-[#dde3eb] rounded-xl px-3 py-2 text-sm outline-none",children:[e.jsx("option",{value:"all",children:"All Subjects"}),H.map(D=>e.jsx("option",{value:D,children:S[D]||D},D))]}),e.jsxs("select",{value:u,onChange:D=>N(D.target.value),className:"bg-white border border-[#dde3eb] rounded-xl px-3 py-2 text-sm outline-none",children:[e.jsx("option",{value:"all",children:"All Grades"}),Bi.map(D=>e.jsx("option",{value:D,children:D},D))]})]}),e.jsx(Qt,{children:j.size>0&&e.jsxs(Re.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"bg-sky-50 border border-sky-200 rounded-xl p-3 flex items-center gap-3 flex-wrap overflow-hidden",children:[e.jsxs("span",{className:"text-sm font-semibold text-sky-700",children:[j.size," topics selected"]}),e.jsx("button",{onClick:$,className:"px-3 py-1.5 bg-[#5a6578] text-white text-xs font-bold rounded-lg hover:bg-sky-600 transition-colors",children:"Exclude Selected Topics"}),e.jsx("button",{onClick:Z,className:"px-3 py-1.5 bg-green-600 text-white text-xs font-bold rounded-lg hover:bg-green-700 transition-colors",children:"Include Selected Topics"}),e.jsx("button",{onClick:()=>B(new Set),className:"px-3 py-1.5 bg-white border border-[#dde3eb] text-[#5a6578] text-xs font-bold rounded-lg hover:bg-[#edf1f7] transition-colors",children:"Clear Selection"})]})}),e.jsx("div",{className:"bg-white rounded-2xl shadow-sm border border-[#dde3eb] overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#edf1f7] border-b border-[#dde3eb]",children:[e.jsx("th",{className:"px-4 py-3 w-10",children:e.jsx("input",{type:"checkbox",checked:j.size===ee.length&&ee.length>0,onChange:re,className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("topicName"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Topic Name ",e.jsx(ne,{field:"topicName"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide",children:"Unit"}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("classAverage"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Class Avg % ",e.jsx(ne,{field:"classAverage"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("studentsAttempted"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Students ",e.jsx(ne,{field:"studentsAttempted"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("masteryStatus"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Status ",e.jsx(ne,{field:"masteryStatus"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide",children:"Exclude"})]})}),e.jsx("tbody",{children:ee.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-16 text-center",children:a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Hs,{size:32,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm font-medium text-[#5a6578]",children:"No topic data available yet"}),e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Import student quiz data to see class topic mastery analytics."})]}):e.jsx("span",{className:"text-sm text-slate-500",children:"No topics match the current filters."})})}):ee.map(D=>{const te=j.has(D.topicName),J=hm[D.masteryStatus],me=xm[D.subjectId]||{label:D.subjectId.toUpperCase(),color:"bg-[#edf1f7] text-[#5a6578]"},Ce=D.classAverage<60?"bg-red-500":D.classAverage<85?"bg-rose-500":"bg-green-500",F=D.isExcluded?"bg-[#edf1f7] opacity-60":D.masteryStatus==="needs_attention"?"bg-red-50/30":D.masteryStatus==="mastered"?"bg-green-50/30":"";return e.jsxs("tr",{className:`border-b border-[#dde3eb] hover:bg-[#edf1f7] transition-colors ${F} ${D.isExcluded?"line-through decoration-slate-400":""}`,children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"checkbox",checked:te,onChange:()=>{const C=new Set(j);te?C.delete(D.topicName):C.add(D.topicName),B(C)},className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#0a1628]",children:D.topicName}),e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${me.color}`,children:me.label})]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-[#5a6578]",children:D.unit}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-[#edf1f7] rounded-full overflow-hidden max-w-20",children:e.jsx("div",{className:`h-full rounded-full e-w ${Ce}`,style:{"--w":`${D.classAverage}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-[#0a1628] w-8 text-right",children:[D.classAverage,"%"]})]})}),e.jsxs("td",{className:"px-4 py-3 text-xs text-[#5a6578]",children:[D.studentsAttempted,"/",D.totalStudents]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${J.color}`,children:J.label})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"group relative",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D.isExcluded,onChange:()=>z(D.topicName),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-[#dde3eb] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-[#dde3eb] after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#5a6578]"})]}),e.jsx("div",{className:"hidden group-hover:block absolute z-20 bottom-full left-0 mb-1 px-2 py-1 bg-slate-800 text-white text-[10px] rounded whitespace-nowrap",children:"Excluded topics will not appear in AI-generated quizzes for your class"})]})})]},D.topicName)})})]})})})]})};function hl(t){return(t||"").trim().toLowerCase()}function Hn(t){const s=(t.lrn||"").trim().toLowerCase();if(s)return`lrn:${s}`;const a=(t.email||"").trim().toLowerCase();if(a)return`email:${a}`;const r=t.name.trim().toLowerCase();if(r)return`name:${r}`;const n=hl(t.classSectionId),o=(t.id||"").trim().toLowerCase();return n&&o?`${n}|id:${o}`:o?`id:${o}`:`${n}|anonymous`}function fm(t,s){const a=[],r=(t.lrn||"").trim().toLowerCase(),n=(t.email||"").trim().toLowerCase(),o=t.name.trim().toLowerCase(),l=(t.id||"").trim().toLowerCase();return r&&a.push(`${s}|lrn:${r}`),n&&a.push(`${s}|email:${n}`),o&&a.push(`${s}|name:${o}`),l&&a.push(`${s}|id:${l}`),a.length===0&&a.push(`${s}|anonymous`),a}function gm(t,s){const a=[t.riskLevel,s.riskLevel].includes("High")?"High":[t.riskLevel,s.riskLevel].includes("Medium")?"Medium":"Low";return{...t,lrn:t.lrn||s.lrn,classSectionId:t.classSectionId??s.classSectionId,avgQuizScore:s.avgQuizScore>0?s.avgQuizScore:t.avgQuizScore,engagementScore:s.engagementScore>0?s.engagementScore:t.engagementScore,weakestTopic:t.weakestTopic&&t.weakestTopic!=="Foundational Skills"?t.weakestTopic:s.weakestTopic,riskLevel:a}}function pl(t,s){const a=new Map,r=new Map,n=s?hl(s):"all";return t.forEach(o=>{const l=fm(o,n),i=l.map(u=>r.get(u)).find(Boolean)||l[0],c=a.get(i),d=c?gm(c,o):o;a.set(i,d),l.forEach(u=>r.set(u,i))}),Array.from(a.values())}function Gn(t,s){return pl([...t,...s])}function rs(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function bm(t){if(!t)return null;const s="gen-math",a=nn.find(l=>l.id===s)?.modules||[];if(a.length===0)return null;const r={mastery:0,concept:0,application:0,engagement:0,consistency:0},n=t.lessons??{};a.forEach(l=>{const i=nn.find(y=>y.modules.some(f=>f.id===l.id)),c=i?t?.subjects?.[i.id]?.modulesProgress?.[l.id]:null,d=rs(c?.progress||0),u=l.lessons.length?l.lessons.reduce((y,f)=>{const v=n?.[f.id]?.score;if(typeof v=="number"&&Number.isFinite(v))return y+rs(v);const S=!!c?.lessonsCompleted?.includes?.(f.id);return y+(S?100:0)},0)/l.lessons.length:0,N=l.quizzes.length?(c?.quizzesCompleted?.length||0)/l.quizzes.length*100:0,m=rs(u),h=rs(N),w=rs(Math.min(100,(m+h*2)/1.5)),k=rs(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=m,r.application+=h,r.engagement+=w,r.consistency+=k});const o=a.length;return{mastery:Math.round(r.mastery/o),concept:Math.round(r.concept/o),application:Math.round(r.application/o),engagement:Math.round(r.engagement/o),consistency:Math.round(r.consistency/o)}}const Xa={High:{bg:"bg-red-100",text:"text-red-700",ring:"ring-red-300"},Medium:{bg:"bg-rose-100",text:"text-rose-700",ring:"ring-rose-300"},Low:{bg:"bg-green-100",text:"text-green-700",ring:"ring-green-300"}},Qn={advanced:{bg:"bg-emerald-100",text:"text-emerald-700",bar:"bg-emerald-500"},proficient:{bg:"bg-sky-100",text:"text-sky-700",bar:"bg-sky-500"},developing:{bg:"bg-rose-100",text:"text-rose-700",bar:"bg-rose-500"},beginner:{bg:"bg-red-100",text:"text-red-700",bar:"bg-red-500"}},Un=[{key:"mastery",short:"M",label:"Overall Mastery",header:"Mastery"},{key:"concept",short:"C",label:"Concept Grasp",header:"Concept"},{key:"application",short:"A",label:"Application",header:"Application"},{key:"engagement",short:"E",label:"Engagement",header:"Engagement"},{key:"consistency",short:"S",label:"Consistency",header:"Consistency"}];function vm(t){const s=rs(t);return s>=80?{bg:"bg-[color-mix(in_srgb,var(--chart-3)_14%,transparent)]",text:"text-[var(--chart-3)]",ring:"ring-[color-mix(in_srgb,var(--chart-3)_40%,transparent)]"}:s>=60?{bg:"bg-[color-mix(in_srgb,var(--chart-4)_14%,transparent)]",text:"text-[var(--chart-4)]",ring:"ring-[color-mix(in_srgb,var(--chart-4)_40%,transparent)]"}:{bg:"bg-[color-mix(in_srgb,var(--chart-2)_14%,transparent)]",text:"text-[var(--chart-2)]",ring:"ring-[color-mix(in_srgb,var(--chart-2)_40%,transparent)]"}}const Nm=({classSectionId:t,className:s,fallbackStudents:a=[]})=>{const{currentUser:r}=Ks(),n=p.useRef(0),[o,l]=p.useState([]),[i,c]=p.useState(!0),[d,u]=p.useState(""),[N,m]=p.useState("riskLevel"),[h,w]=p.useState("desc"),[k,y]=p.useState("all"),[f,v]=p.useState([]),[S,R]=p.useState(!1),[j,B]=p.useState(""),[g,b]=p.useState(""),T=p.useCallback(C=>({id:C.id,lrn:C.lrn||void 0,name:C.name,email:C.email||"",avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(C.name)}&background=random`,classSectionId:C.classSectionId??null,riskLevel:C.riskLevel||"Low",engagementScore:C.engagementScore,avgQuizScore:C.avgQuizScore,weakestTopic:C.weakestTopic||"Foundational Skills"}),[]),z=p.useCallback(C=>({id:C.id,lrn:C.lrn,name:C.name,email:C.email||"",avatar:C.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(C.name)}&background=random`,classSectionId:C.classSectionId??null,riskLevel:String(C.riskLevel).charAt(0).toUpperCase()+String(C.riskLevel).slice(1).toLowerCase(),engagementScore:C.engagementScore,avgQuizScore:Number(C.avgQuizScore??C.avgScore??0),weakestTopic:C.weakestTopic||"Foundational Skills"}),[]),$=p.useCallback(async(C,K)=>{const P=new Map;C.forEach(M=>P.set(M.id,null));const xe=25;for(let M=0;M{try{const ie=await tn(le.id);return{studentId:le.id,summary:bm(ie)}}catch{return{studentId:le.id,summary:null}}}))).forEach((le,ie)=>{const V=G[ie]?.id;V&&(le.status==="fulfilled"?P.set(V,le.value.summary):P.set(V,null))})}n.current===K&&l(M=>M.map(G=>P.has(G.student.id)?{...G,competencyMatrix:P.get(G.student.id)??null,competencyMatrixLoading:!1}:G))},[]),Z=p.useCallback(async()=>{if(r?.uid){c(!0),b("");try{let K=(await Ar(r.uid)).map(G=>({id:G.id,name:G.name,email:G.email||"",avatar:G.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(G.name)}&background=random`,classSectionId:G.classSectionId??null,riskLevel:G.riskLevel,engagementScore:G.engagementScore,avgQuizScore:G.avgQuizScore,weakestTopic:G.weakestTopic||"Foundational Skills"}));a.length>0&&(K=Gn(K,a.map(z))),t&&(K=K.filter(G=>G.classSectionId===t));const P=await Ve.getImportedClassOverview({classSectionId:t,limit:3e3});P.warnings.length>0&&b(P.warnings.join(" ")),K=Gn(K,P.students.map(T));const xe=pl(K,t),M=n.current+=1;l(xe.map((G,X)=>({rowKey:`${Hn(G)}|row:${X}`,student:G,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),$(xe,M)}catch(C){if(console.error("Failed to load students:",C),a.length>0){const K=a.map(z).filter(P=>!t||P.classSectionId===t).map((P,xe)=>({rowKey:`${Hn(P)}|row:${xe}`,student:P,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));l(K),b("Showing recently imported students while backend roster sync catches up.")}else l([]),b("Student competency roster is unavailable right now.")}finally{c(!1)}}},[t,r?.uid,a,$,z,T]);p.useEffect(()=>{Z()},[Z]),p.useEffect(()=>{(async()=>{if(!t){v([]),B("");return}R(!0),B("");try{const K=await Ve.getCourseMaterialTopics({classSectionId:t,limit:20}),P=(K.topics||[]).filter(xe=>xe.title?.trim());v(P),K.warnings.length>0&&B(K.warnings.join(" "))}catch{v([]),B("Imported topic context is unavailable right now.")}finally{R(!1)}})()},[t]);const ae=async C=>{l(K=>K.map(P=>{if(P.rowKey!==C)return P;const xe=!P.expanded,M=P.student.id,G={weakestTopic:P.student.weakestTopic,avgQuizScore:P.student.avgQuizScore};return xe&&!P.competency&&!P.loading?(H(C,M,G),{...P,expanded:!0,loading:!0}):{...P,expanded:xe}}))},H=async(C,K,P)=>{try{const M=((await tn(K))?.quizAttempts??[]).map(X=>({topic:X.quizId,score:X.score,total:100,timeTaken:X.timeSpent})),G=await Ve.getStudentCompetency(K,M.length>0?M:void 0);l(X=>X.map(le=>le.rowKey===C?{...le,competency:G,loading:!1}:le))}catch{const M=P.avgQuizScore||50,G={studentId:K,competencies:[{topic:P.weakestTopic||"Unknown",efficiencyScore:Math.max(15,M-20),competencyLevel:M<50?"beginner":"developing",perspective:`Student needs focused practice in ${P.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,M+10),competencyLevel:M>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:M,competencyLevel:M>80?"advanced":M>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[P.weakestTopic||"Review fundamentals"],excludeTopics:[]};l(X=>X.map(le=>le.rowKey===C?{...le,competency:G,loading:!1}:le))}},ee=C=>{N===C?w(K=>K==="asc"?"desc":"asc"):(m(C),w("asc"))},re={High:0,Medium:1,Low:2},ne=o.filter(C=>{if(k!=="all"&&C.student.riskLevel!==k)return!1;if(d){const K=d.toLowerCase();return C.student.name.toLowerCase().includes(K)||C.student.email.toLowerCase().includes(K)}return!0}).sort((C,K)=>{let P=0;switch(N){case"name":P=C.student.name.localeCompare(K.student.name);break;case"avgQuizScore":P=C.student.avgQuizScore-K.student.avgQuizScore;break;case"riskLevel":P=re[C.student.riskLevel]-re[K.student.riskLevel];break;case"engagementScore":P=C.student.engagementScore-K.student.engagementScore;break}return h==="asc"?P:-P}),D=o.length,te=o.filter(C=>C.student.riskLevel==="High").length,J=D>0?Math.round(o.reduce((C,K)=>C+K.student.avgQuizScore,0)/D):0,me=D>0?Math.round(o.reduce((C,K)=>C+K.student.engagementScore,0)/D):0,Ce=Array.from(new Set(f.map(C=>C.title).filter(Boolean))).slice(0,10),F=({field:C})=>N!==C?e.jsx(Ht,{size:14,className:"text-slate-500"}):h==="asc"?e.jsx(Na,{size:14,className:"text-sky-600"}):e.jsx(Ht,{size:14,className:"text-sky-600"});return i?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(nt,{size:32,className:"animate-spin text-[var(--primary)]"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading student data..."})]}):e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Students",value:D,icon:e.jsx(sn,{size:20}),color:"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)]"},{label:"At-Risk Students",value:te,icon:e.jsx(Gt,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-2)_10%,transparent)] text-[var(--chart-2)]"},{label:"Class Average",value:`${J}%`,icon:e.jsx(Hs,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-3)_10%,transparent)] text-[var(--chart-3)]"},{label:"Avg. Engagement",value:`${me}%`,icon:e.jsx(ka,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-1)_10%,transparent)] text-[var(--chart-1)]"}].map((C,K)=>e.jsxs("div",{className:"bg-card rounded-xl border border-border p-4 flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${C.color}`,children:C.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-foreground",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]},K))}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1 w-full sm:max-w-xs",children:[e.jsx("label",{htmlFor:"student-search",className:"sr-only",children:"Search for students by name or email"}),e.jsx(Js,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx("input",{id:"student-search",type:"text",placeholder:"Search students...",value:d,onChange:C=>u(C.target.value),className:"w-full pl-9 pr-4 py-2 border border-border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-400"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["all","High","Medium","Low"].map(C=>e.jsx("button",{onClick:()=>y(C),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${k===C?"bg-[var(--primary)] text-white":"bg-muted text-muted-foreground hover:bg-accent"}`,children:C==="all"?"All":`${C} Risk`},C))}),e.jsxs("button",{onClick:Z,className:"sm:ml-auto w-full sm:w-auto flex items-center justify-center gap-1.5 px-3 py-1.5 bg-muted hover:bg-accent rounded-lg text-xs font-semibold text-muted-foreground transition-colors",children:[e.jsx(_s,{size:14}),"Refresh"]})]}),e.jsxs("div",{className:"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] border border-[color-mix(in_srgb,var(--primary)_30%,transparent)] rounded-xl p-4",children:[e.jsxs("p",{className:"text-sm font-semibold text-[var(--primary)]",children:["Imported Topic Context",s?` for ${s}`:""]}),e.jsx("p",{className:"text-xs text-[var(--primary)] mt-1 opacity-80",children:S?"Loading class-scoped imported topics...":Ce.length>0?`${Ce.length} imported topics loaded for competency guidance`:"No imported topics found for this class context"}),j&&e.jsx("p",{className:"text-[11px] text-[var(--chart-4)] mt-1",children:j}),g&&e.jsx("p",{className:"text-[11px] text-[var(--chart-4)] mt-1",children:g}),Ce.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ce.map(C=>e.jsx("span",{className:"text-[11px] bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)] px-2 py-0.5 rounded",children:C},C))})]}),e.jsx("div",{className:"bg-card rounded-xl border border-border",children:e.jsx("div",{className:"overflow-x-auto pb-2",children:e.jsxs("div",{className:"min-w-[1920px]",children:[e.jsxs("div",{className:"grid grid-cols-[48px_280px_120px_120px_120px_120px_120px_140px_170px_170px_220px] items-center gap-6 px-6 py-4 bg-muted/60 border-b border-border text-xs font-semibold text-muted-foreground tracking-normal",children:[e.jsx("div",{}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("name"),children:["Student ",e.jsx(F,{field:"name"})]}),Un.map(C=>e.jsx("div",{className:"text-center leading-none whitespace-nowrap tracking-normal",children:C.header},C.key)),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("riskLevel"),children:["Risk Level ",e.jsx(F,{field:"riskLevel"})]}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("avgQuizScore"),children:["Avg. Score ",e.jsx(F,{field:"avgQuizScore"})]}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("engagementScore"),children:["Engagement ",e.jsx(F,{field:"engagementScore"})]}),e.jsx("div",{className:"flex justify-end pr-2",children:"Weakest Topic"})]}),ne.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(sn,{size:32,className:"mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No students match the current filters"})]}):e.jsx("div",{className:"divide-y divide-border",children:ne.map(C=>{const K=C.student.riskLevel==="High"?{card:"bg-rose-50 border-rose-200",title:"text-rose-800",chip:"bg-rose-100 text-rose-700"}:C.student.riskLevel==="Medium"?{card:"bg-amber-50 border-amber-200",title:"text-amber-800",chip:"bg-amber-100 text-amber-700"}:{card:"bg-sky-50 border-sky-200",title:"text-sky-800",chip:"bg-sky-100 text-sky-700"};return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("button",{onClick:()=>void ae(C.rowKey),className:"w-full grid grid-cols-[48px_280px_120px_120px_120px_120px_120px_140px_170px_170px_220px] gap-6 px-6 py-5 items-center hover:bg-muted transition-colors text-left",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center text-slate-500",children:C.expanded?e.jsx(Ht,{size:16}):e.jsx(Wt,{size:16})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:C.student.avatar,alt:C.student.name,className:"w-8 h-8 rounded-full bg-border object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:C.student.name}),e.jsx("p",{className:"text-xs text-slate-500",children:C.student.email})]})]}),Un.map(P=>{const xe=C.competencyMatrix?.[P.key]??0,M=vm(xe);return e.jsx("div",{className:"flex items-center justify-center",children:C.competencyMatrixLoading?e.jsx(nt,{size:14,className:"animate-spin text-muted-foreground"}):C.competencyMatrix?e.jsxs("span",{title:`${P.label}: ${xe}%`,className:`inline-flex items-center justify-center rounded-md px-2 py-1 text-xs font-semibold ring-1 ${M.bg} ${M.text} ${M.ring}`,children:[xe,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},P.key)}),e.jsx("div",{children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-bold ring-1 ${Xa[C.student.riskLevel]?.bg} ${Xa[C.student.riskLevel]?.text} ${Xa[C.student.riskLevel]?.ring}`,children:[C.student.riskLevel==="High"&&e.jsx(Gt,{size:10}),C.student.riskLevel]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full e-w ${C.student.avgQuizScore>=80?"bg-[var(--chart-3)]":C.student.avgQuizScore>=60?"bg-[var(--chart-4)]":"bg-[var(--chart-2)]"}`,style:{"--w":`${C.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-8 text-right",children:[C.student.avgQuizScore,"%"]})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full e-w ${C.student.engagementScore>=75?"bg-[var(--primary)]":C.student.engagementScore>=50?"bg-[var(--primary)]/60":"bg-muted-foreground"}`,style:{"--w":`${C.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-8 text-right",children:[C.student.engagementScore,"%"]})]})}),e.jsx("div",{className:"flex justify-end pr-2",children:e.jsx("span",{className:"text-xs font-medium text-muted-foreground bg-muted px-2 py-1 rounded-md",children:C.student.weakestTopic})})]}),e.jsx(Qt,{children:C.expanded&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsx("div",{className:"px-6 py-4 bg-muted border-t border-border",children:C.loading?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(nt,{size:20,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Analyzing competency data..."})]}):C.competency?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:C.competency.competencies.map((P,xe)=>e.jsx(jm,{competency:P},xe))}),C.competency.recommendedTopics.length>0&&e.jsxs("div",{className:`border rounded-lg p-3 ${K.card}`,children:[e.jsxs("h5",{className:`text-xs font-bold mb-1.5 flex items-center gap-1 ${K.title}`,children:[e.jsx(Vt,{size:12}),"Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:C.competency.recommendedTopics.map((P,xe)=>e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${K.chip}`,children:P},xe))})]}),Ce.length>0&&e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-lg p-3",children:[e.jsxs("h5",{className:"text-xs font-bold text-sky-800 mb-1.5 flex items-center gap-1",children:[e.jsx(uo,{size:12}),"Class Imported Topics"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ce.slice(0,8).map((P,xe)=>e.jsx("span",{className:"inline-flex items-center bg-sky-100 text-sky-700 px-2 py-0.5 rounded text-xs font-medium",children:P},`${P}_${xe}`))})]}),C.competency.excludeTopics.length>0&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-200 rounded-lg p-3",children:[e.jsxs("h5",{className:"text-xs font-bold text-emerald-800 mb-1.5 flex items-center gap-1",children:[e.jsx(Yl,{size:12}),"Mastered Topics (can exclude from quizzes)"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:C.competency.excludeTopics.map((P,xe)=>e.jsx("span",{className:"inline-flex items-center bg-emerald-100 text-emerald-700 px-2 py-0.5 rounded text-xs font-medium",children:P},xe))})]})]}):e.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"No competency data available. Student needs to complete quizzes first."})})})})]},C.rowKey)})})]})})})]})},jm=({competency:t})=>{const s=Qn[t.competencyLevel]||Qn.developing;return e.jsxs("div",{className:"bg-card rounded-lg border border-border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h6",{className:"text-xs font-bold text-foreground truncate flex-1",children:t.topic}),e.jsx("span",{className:`ml-2 px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s.bg} ${s.text}`,children:t.competencyLevel})]}),e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-slate-500",children:"Efficiency"}),e.jsxs("span",{className:"font-bold text-muted-foreground",children:[t.efficiencyScore,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx(Re.div,{initial:{width:0},animate:{width:`${t.efficiencyScore}%`},transition:{duration:.6,delay:.1},className:`h-full rounded-full ${s.bar}`})})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug line-clamp-2",children:t.perspective})]})},ym=({liveActivity:t,atRiskStudents:s})=>{const{notifications:a,unreadCount:r,isLoading:n,markAsRead:o,markAllAsRead:l}=Kl(),i=u=>{const N=Date.now()-u.getTime(),m=Math.floor(N/6e4);if(m<1)return"Just now";if(m<60)return`${m} min ago`;const h=Math.floor(m/60);if(h<24)return`${h} hour${h===1?"":"s"} ago`;const w=Math.floor(h/24);return`${w} day${w===1?"":"s"} ago`},c=u=>{switch(u){case"achievement_unlocked":case"achievement":return Jl;case"message":return ii;case"grade":case"quiz_result":return mo;case"reminder":case"streak_reminder":return So;case"risk_alert":return Gt;case"automation":case"system_alert":return Xl;default:return ua}},d=u=>{switch(u){case"risk_alert":return"bg-destructive/10 text-destructive";case"achievement_unlocked":case"achievement":return"bg-rose-500/10 text-rose-600 dark:text-rose-400";case"message":return"bg-sky-500/10 text-sky-700 dark:text-sky-400";case"grade":case"quiz_result":return"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400";case"reminder":case"streak_reminder":return"bg-amber-500/10 text-amber-700 dark:text-amber-400";case"automation":case"system_alert":return"bg-violet-500/10 text-violet-700 dark:text-violet-400";default:return"bg-muted text-muted-foreground"}};return e.jsxs(Re.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},exit:{opacity:0,y:-18},className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-sky-100 text-sky-700 dark:bg-sky-500/15 dark:text-sky-300 flex items-center justify-center flex-shrink-0",children:e.jsx(ua,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Classroom alerts and updates"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-body",children:r>0?`${r} unread`:"All caught up"}),r>0&&e.jsxs($e,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(Oi,{}),"Mark all as read"]})]})]}),e.jsx("div",{className:"bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:n?e.jsxs("div",{className:"p-8 flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(nt,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-body",children:"Loading notifications…"})]}):a.length===0?e.jsx("div",{className:"p-10",children:e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-muted text-muted-foreground flex items-center justify-center mb-4",children:e.jsx(ua,{size:22})}),e.jsx("h3",{className:"text-lg font-display font-bold text-foreground mb-1",children:"No notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Teacher alerts and classroom updates will appear here."})]})}):e.jsxs("div",{children:[t&&t.length>0&&e.jsx("div",{children:t.map(u=>e.jsx("div",{className:"w-full text-left px-4 py-4 border-b border-border transition-colors hover:bg-accent/40",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${u.type==="success"?"bg-[#75D06A]/15 text-[#4D9F46]":u.type==="warning"?"bg-[#F08386]/15 text-[#C65E63]":"bg-[#9956DE]/15 text-[#9956DE]"}`,children:e.jsx($s,{size:18})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h4",{className:"text-sm font-body font-bold text-foreground line-clamp-1",children:[u.student," — ",u.action]})}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground font-body leading-relaxed line-clamp-2",children:["Topic: ",u.topic]})]}),e.jsx("div",{className:"text-xs text-muted-foreground font-body flex-shrink-0",children:u.time})]})})]})},u.id))}),a.map(u=>{const N=c(u.type),m=d(u.type),h=i(u.createdAt);return e.jsx("button",{onClick:()=>o(u.id),className:`w-full text-left px-4 py-4 border-b border-border last:border-b-0 transition-colors hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${u.isRead?"":"bg-sky-50/40 dark:bg-sky-500/5"}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${m}`,children:e.jsx(N,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-body font-bold text-foreground line-clamp-1",children:u.title}),!u.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground font-body leading-relaxed line-clamp-2",children:u.message})]}),e.jsx("div",{className:"text-xs text-muted-foreground font-body flex-shrink-0",children:h})]}),u.actionUrl&&e.jsx("div",{className:"mt-2 text-xs text-sky-600 dark:text-sky-400 font-body",children:"Opens link"})]})]})},u.id)})]})})]})},wm=t=>{const s=t.data(),a=s.startTime,r=s.endTime,n=s.createdAt,o=s.updatedAt,l=i=>{if(i){if(typeof i?.toDate=="function")return i.toDate();if(i instanceof Date)return i}};return{...s,id:t.id,startTime:l(a)||new Date,endTime:l(r),createdAt:l(n)||new Date,updatedAt:l(o)}},Sm=async(t,s)=>{const a=et(Bt(Ge,"calendarEvents")),r={id:a.id,userId:t,title:s.title,description:s.description,startTime:s.startTime,endTime:s.endTime,createdAt:new Date};return await Ut(a,{...r,createdAt:ot(),updatedAt:ot()}),r},km=async t=>{await xi(et(Ge,"calendarEvents",t))},Cm=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:n=500}=s,o=zt(Bt(Ge,"calendarEvents"),Ft("userId","==",t),vo(n));return Xs(o,l=>{a(l.docs.map(i=>wm(i)))},l=>{console.error("Error subscribing to calendar events:",l),r?.(l)})};function Tm({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:hr("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...s})}const Wn=t=>String(t).padStart(2,"0"),hs=t=>`${t.getFullYear()}-${Wn(t.getMonth()+1)}-${Wn(t.getDate())}`,ur=t=>new Date(t.getFullYear(),t.getMonth(),1),Vn=t=>new Date(t.getFullYear(),t.getMonth()+1,0),Im=t=>{const s=ur(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},Em=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},qn=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),Rm=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),Am=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),Yn=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),Kn=(t,s)=>{const[a,r,n]=t.split("-").map(i=>parseInt(i,10)),[o,l]=s.split(":").map(i=>parseInt(i,10));return new Date(a,(r||1)-1,n||1,o||0,l||0,0,0)},Ja=[{names:["sun","sunday"],day:0},{names:["mon","monday"],day:1},{names:["tue","tues","tuesday"],day:2},{names:["wed","wednesday"],day:3},{names:["thu","thurs","thursday"],day:4},{names:["fri","friday"],day:5},{names:["sat","saturday"],day:6}];function Mm(t){const s=t.toLowerCase(),a=new Set;if(s.includes("daily")||s.includes("everyday"))return[0,1,2,3,4,5,6];if(s.includes("weekends"))return[0,6];if(s.includes("weekdays"))return[1,2,3,4,5];const r=s.match(/(mon|tue|wed|thu|fri|sat|sun)[\s/-]*(mon|tue|wed|thu|fri|sat|sun)/);if(r){const n=Ja.find(l=>l.names.includes(r[1]))?.day,o=Ja.find(l=>l.names.includes(r[2]))?.day;if(n!==void 0&&o!==void 0){let l=n;for(;a.add(l),l!==o;)l=(l+1)%7;return Array.from(a)}}return Ja.forEach(({names:n,day:o})=>{n.some(l=>s.includes(l))&&a.add(o)}),Array.from(a).sort((n,o)=>n-o)}const Lm=({classes:t,teacherId:s})=>{const{currentUser:a}=Ks(),[r,n]=p.useState([]),[o,l]=p.useState(!0),[i,c]=p.useState(""),[d,u]=p.useState(()=>{const F=new Date;return F.setHours(0,0,0,0),F}),[N,m]=p.useState(()=>{const F=new Date;return F.setHours(0,0,0,0),F}),[h,w]=p.useState(!1),[k,y]=p.useState(!1),[f,v]=p.useState(""),[S,R]=p.useState(""),[j,B]=p.useState(()=>hs(new Date)),[g,b]=p.useState("09:00"),[T,z]=p.useState("");p.useEffect(()=>{if(!a?.uid){n([]),l(!1);return}c(""),l(!0);const F=Cm(a.uid,{limitCount:500},C=>{n(C),l(!1)},()=>{c("Unable to load calendar events right now."),l(!1)});return()=>F()},[a?.uid]);const $=p.useMemo(()=>{const F=ur(d);return F.setHours(0,0,0,0),F},[d]),Z=p.useMemo(()=>{const F=Vn(d);return F.setHours(23,59,59,999),F},[d]),ae=p.useMemo(()=>{if(!t||t.length===0)return[];const F=[],C=ur(d),K=Vn(d),P=new Date(C);for(;P<=K;){const xe=P.getDay();t.forEach(M=>{Mm(M.schedule).includes(xe)&&F.push({id:`schedule-${M.id}-${hs(P)}`,userId:s||"",title:M.name,startTime:new Date(P),createdAt:new Date})}),P.setDate(P.getDate()+1)}return F},[t,d,s]),H=p.useMemo(()=>[...r,...ae],[r,ae]),ee=p.useMemo(()=>H.filter(F=>F.startTime>=$&&F.startTime<=Z).sort((F,C)=>F.startTime.getTime()-C.startTime.getTime()),[H,$,Z]),re=p.useMemo(()=>{const F=new Map;for(const C of ee){const K=hs(C.startTime),P=F.get(K)||[];P.push(C),F.set(K,P)}return F},[ee]),ne=p.useMemo(()=>hs(N),[N]),D=p.useMemo(()=>[...re.get(ne)||[]].sort((C,K)=>C.startTime.getTime()-K.startTime.getTime()),[re,ne]),te=p.useMemo(()=>{const F=Im(d);return Array.from({length:42}).map((C,K)=>Em(F,K))},[d]),J=F=>{const C=hs(F);v(""),R(""),B(C),b("09:00"),z(""),w(!0)},me=async()=>{if(a?.uid){if(!f.trim()){c("Event title is required.");return}y(!0),c("");try{const F=Kn(j,g),C=T?Kn(j,T):void 0;await Sm(a.uid,{title:f.trim(),description:S.trim()?S.trim():void 0,startTime:F,endTime:C&&C.getTime()>F.getTime()?C:void 0}),w(!1)}catch(F){console.error(F),c("Failed to create event.")}finally{y(!1)}}},Ce=async F=>{c("");try{await km(F)}catch(C){console.error(C),c("Failed to delete event.")}};return e.jsxs(Re.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},exit:{opacity:0,y:-18},className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-secondary text-secondary-foreground flex items-center justify-center flex-shrink-0",children:e.jsx(Yi,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:"Calendar"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Check upcoming class events and schedule"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{variant:"outline",size:"sm",onClick:()=>{const F=new Date;F.setHours(0,0,0,0),u(F),m(F)},children:"Today"}),e.jsxs($e,{size:"sm",onClick:()=>J(N),children:[e.jsx(ma,{}),"Add event"]})]})]}),i&&e.jsx("div",{className:"bg-destructive/10 text-destructive border border-destructive/20 rounded-xl px-4 py-3 text-sm font-body",children:i}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"lg:col-span-8 bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>{const F=new Date(d.getFullYear(),d.getMonth()-1,1);u(F)},"aria-label":"Previous month",children:e.jsx(Pt,{})}),e.jsx("div",{className:"text-sm sm:text-base font-display font-bold text-foreground",children:Am(d)}),e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>{const F=new Date(d.getFullYear(),d.getMonth()+1,1);u(F)},"aria-label":"Next month",children:e.jsx(Wt,{})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-body",children:[ee.length," event",ee.length===1?"":"s"]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-px bg-border",children:[["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(F=>e.jsx("div",{className:"bg-card px-3 py-2 text-xs font-body font-bold text-muted-foreground",children:F},F)),te.map(F=>{const C=hs(F),K=re.get(C)?.length||0,P=qn(F,N),xe=qn(F,new Date),M=Rm(F,d);return e.jsxs("button",{onClick:()=>{const G=new Date(F);G.setHours(0,0,0,0),m(G)},className:"bg-card px-3 py-3 min-h-[78px] text-left transition-colors hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 "+(P?"ring-2 ring-primary/40 ":"")+(M?"":"opacity-50 "),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm font-body font-bold "+(xe?"bg-primary text-primary-foreground ":"text-foreground ")+(P&&!xe?"bg-secondary text-secondary-foreground ":""),children:F.getDate()}),K>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-xs font-body text-muted-foreground",children:K})]})]}),K>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[(re.get(C)||[]).slice(0,3).map(G=>e.jsx("span",{className:"inline-flex items-center rounded-md bg-secondary text-secondary-foreground px-2 py-0.5 text-[10px] font-body font-bold truncate max-w-full",title:G.title,children:G.title},G.id)),(re.get(C)?.length||0)>3&&e.jsxs("span",{className:"text-[10px] font-body text-muted-foreground",children:["+",(re.get(C)?.length||0)-3," more"]})]})]},C)})]}),o&&e.jsxs("div",{className:"px-4 py-4 border-t border-border flex items-center gap-2 text-muted-foreground",children:[e.jsx(nt,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-body",children:"Syncing events…"})]})]}),e.jsxs("div",{className:"lg:col-span-4 bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-display font-bold text-foreground",children:N.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("div",{className:"text-xs text-muted-foreground font-body",children:N.toLocaleDateString()})]}),e.jsxs($e,{variant:"outline",size:"sm",onClick:()=>J(N),children:[e.jsx(ma,{}),"Add"]})]}),e.jsx("div",{className:"p-4",children:D.length===0?e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-4",children:[e.jsx("div",{className:"text-sm font-body font-bold text-foreground",children:"No events"}),e.jsx("div",{className:"text-xs text-muted-foreground font-body mt-1",children:"Add reminders for quizzes, meetings, or deadlines."})]}):e.jsx("div",{className:"space-y-2",children:D.map(F=>e.jsxs("div",{className:"rounded-xl border border-border bg-background p-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary flex-shrink-0"}),e.jsx("div",{className:"text-sm font-body font-bold text-foreground truncate",children:F.title})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-body mt-1",children:[Yn(F.startTime),F.endTime?` – ${Yn(F.endTime)}`:""]}),F.description&&e.jsx("div",{className:"text-xs text-muted-foreground font-body mt-2 line-clamp-2",children:F.description})]}),e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>Ce(F.id),"aria-label":"Delete event",children:e.jsx(No,{})})]},F.id))})})]})]}),e.jsx(xo,{open:h,onOpenChange:w,children:e.jsxs(ho,{className:"sm:max-w-xl",children:[e.jsxs(po,{children:[e.jsx(fo,{className:"font-display",children:"Add event"}),e.jsx(go,{className:"font-body",children:"Create a reminder for your class schedule."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Title"}),e.jsx(vt,{value:f,onChange:F=>v(F.target.value),placeholder:"e.g., Quiz review session"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Date"}),e.jsx(vt,{type:"date",value:j,onChange:F=>B(F.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Start time"}),e.jsx(vt,{type:"time",value:g,onChange:F=>b(F.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"End time (optional)"}),e.jsx(vt,{type:"time",value:T,onChange:F=>z(F.target.value)})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Notes (optional)"}),e.jsx(Tm,{value:S,onChange:F=>R(F.target.value),placeholder:"Add context: class, room, agenda…",className:"min-h-24"})]})]}),e.jsxs(bo,{children:[e.jsx($e,{variant:"outline",onClick:()=>w(!1),disabled:k,children:"Cancel"}),e.jsx($e,{onClick:me,disabled:k,children:k?e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ma,{}),"Create event"]})})]})]})})]})},fl="PH_SHS_OFFICIAL_CLASS_RECORD",Dm=.85,xr=.85,zm="2026.04.24",gl=4,fa=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],Fm=[...fa,"Pursuant to DepEd Order 8 series of 2015","INITIAL GRADE","QUARTERLY GRADE","ADDITIONAL REMARKS","MALE","FEMALE","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS","LOOK UP","HELPER","ATTACHMENTS"],Bm=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],sa=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],$m=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],Om={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},ps={inputData:["input data"],firstQuarter:["first quarter","1st quarter","q1"],secondQuarter:["second quarter","2nd quarter","q2"],finalSemestral:["final semestral","final grades","semestral"],helper:["helper","weight","attachments"],lookup:["look up","lookup","reference"]},bt={region:["REGION"],division:["DIVISION"],schoolName:["SCHOOL NAME"],schoolId:["SCHOOL ID"],schoolYear:["SCHOOL YEAR"],gradeSection:["GRADE / SECTION","GRADE/SECTION"],semester:["SEMESTER"],track:["TRACK"],subjectCode:["SUBJECT CODE"],subjectName:["SUBJECT NAME","SUBJECT"],teacherName:["TEACHER","NAME OF TEACHER"]},Le={learnerNo:["NO","NO.","#"],learnerName:["LEARNERS NAMES","LEARNER NAME","NAME"],writtenWork:["WRITTEN WORK","WW"],performanceTasks:["PERFORMANCE TASKS","PT"],quarterlyAssessment:["QUARTERLY ASSESSMENT","QA"],total:["TOTAL"],ps:["PS"],ws:["WS"],initialGrade:["INITIAL GRADE"],quarterlyGrade:["QUARTERLY GRADE"],firstQuarter:["FIRST QUARTER","1ST QUARTER"],secondQuarter:["SECOND QUARTER","2ND QUARTER"],firstSemester:["FIRST SEMESTER"],finalGrades:["FINAL GRADES","FINAL GRADE"],remark:["REMARK","REMARKS"],additionalRemarks:["ADDITIONAL REMARKS","ADDITIONAL REMARK"]};function Pm(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function it(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function Xn(t){return it(t).replace(/[^A-Z0-9]+/g,"")}function Se(t,s){const a=it(t),r=it(s);if(!a||!r)return!1;if(a.includes(r))return!0;const n=Xn(t),o=Xn(s);return!n||!o?!1:n.includes(o)}function ga(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const s=t.replace(/,/g,"").trim();if(!s)return;const a=Number(s);if(Number.isFinite(a))return a}}function Za(t){return it(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function bl(t){const s={};return t.forEach(a=>{const r=wt.encode_cell(a.s);for(let n=a.s.r;n<=a.e.r;n+=1)for(let o=a.s.c;o<=a.e.c;o+=1){const l=wt.encode_cell({r:n,c:o});s[l]=r}}),s}function _m(t,s,a){const n=(a||bl(t.merges))[s]||s;return t.cells[n]||t.cells[s]}const vl="A1:A1",Jn=1200,Zn=200,eo=2e5;function Hm(t){const s=Math.max(0,t.s.r),a=Math.max(0,t.s.c);let r=Math.max(s,t.e.r),n=Math.max(a,t.e.c);r-s+1>Jn&&(r=s+Jn-1),n-a+1>Zn&&(n=a+Zn-1);const o=r-s+1,l=n-a+1;if(o*l>eo){const c=Math.max(1,Math.floor(eo/l));r=s+Math.min(o,c)-1}return{s:{r:s,c:a},e:{r,c:n}}}function Gm(t){try{return wt.decode_range(t)}catch{return wt.decode_range(vl)}}function Qm(t){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return Object.keys(t.cells).forEach(o=>{try{const l=wt.decode_cell(o);s=Math.min(s,l.r),a=Math.min(a,l.c),r=Math.max(r,l.r),n=Math.max(n,l.c)}catch{}}),t.merges.forEach(o=>{s=Math.min(s,o.s.r,o.e.r),a=Math.min(a,o.s.c,o.e.c),r=Math.max(r,o.s.r,o.e.r),n=Math.max(n,o.s.c,o.e.c)}),!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)?null:{s:{r:Math.max(0,Math.trunc(s)),c:Math.max(0,Math.trunc(a))},e:{r:Math.max(0,Math.trunc(r)),c:Math.max(0,Math.trunc(n))}}}function Um(t){const s=Gm(t.ref||vl),a=Qm(t);return Hm(a||s)}function Wm(t,s){const a=Um(s),r=`${wt.encode_cell(a.s)}:${wt.encode_cell(a.e)}`,n=bl(s.merges),o=a.e.r-a.s.r+1,l=a.e.c-a.s.c+1,i=[];for(let c=0;ct.endRow||at.endCol?null:t.cells[s-t.startRow]?.[a-t.startCol]??null}function Zt(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function Ls(t){return wt.encode_col(t)}function da(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return wt.decode_col(s)}catch{return-1}}function Vm(t){return`${wt.encode_cell(t.s)}:${wt.encode_cell(t.e)}`}function qm(t,s){const a=[];for(let r=s.s.r;r<=s.e.r;r+=1){const n=[];for(let o=s.s.c;o<=s.e.c;o+=1){const l=ze(t,r,o);n.push(l?.displayValue??null)}a.push(n)}return a}function Ym(t,s){const a=it(t),r=it(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function Mr(t,s){const a=[];for(let r=0;r{Se(i.normalizedText,c)&&a.push({sheetName:t.sheetName,anchor:c,row:i.row,col:i.col,address:i.address,value:String(i.displayValue??""),confidence:Ym(i.displayValue,c)})})}const n=t.startRow+r,o=Zt(t,n);o&&s.forEach(l=>{if(!Se(o,l))return;const i=t.cells[r].find(c=>c?.normalizedText);i&&a.push({sheetName:t.sheetName,anchor:l,row:n,col:i.col,address:i.address,value:o,confidence:.8})})}return a}function Km(t,s){return Object.values(t).flatMap(a=>Mr(a,s))}function dt(t,s){return Mr(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function Nl(t,s,a,r=6){for(let n=1;n<=r;n+=1){const l=ze(t,s,a+n)?.displayValue;if(l!=null&&String(l).trim())return String(l).trim()}for(let n=1;n<=r;n+=1){const l=ze(t,s+n,a)?.displayValue;if(l!=null&&String(l).trim())return String(l).trim()}}function jl(t,s,a=5){let r=s,n=-1;for(let o=Math.max(t.startRow,s-a);o<=Math.min(t.endRow,s+a);o+=1){const l=Zt(t,o),i=["LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK"].reduce((c,d)=>l.includes(d)?c+1:c,0);i>n&&(n=i,r=o)}return r}function Xm(t,s){const a=it(t).toLowerCase(),r=n=>[...s].some(o=>Se(o,n));return ps.inputData.some(n=>a.includes(n))||r("INPUT DATA")?"inputData":ps.finalSemestral.some(n=>a.includes(n))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":ps.firstQuarter.some(n=>a.includes(n))||r("FIRST QUARTER")?"firstQuarter":ps.secondQuarter.some(n=>a.includes(n))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":ps.helper.some(n=>a.includes(n))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":ps.lookup.some(n=>a.includes(n))||r("LOOK UP")?"lookup":"other"}function Jm(t){const s=t.criticalTotal>0?t.criticalFound/t.criticalTotal:0,a=t.totalSheets>0?t.recognizedSheets/t.totalSheets:0,r=t.hasDepedAnchor?1:0,n=.65*s+.2*a+.15*r;return Number(Math.max(0,Math.min(1,n)).toFixed(4))}function Zm(t){const s=Km(t.matrices,Fm),a=new Set,r=[];fa.forEach(h=>{s.some(k=>Se(k.anchor,h))&&(a.add(h),r.push(`Found critical anchor: ${h}`))});const n=fa.filter(h=>!a.has(h)),o=new Map;s.forEach(h=>{o.has(h.sheetName)||o.set(h.sheetName,new Set),o.get(h.sheetName)?.add(h.anchor)});const l=t.sheetNames.map(h=>{const w=o.get(h)||new Set,k=Xm(h,w),y=Math.min(1,.35+Math.min(.55,w.size*.08)),f=[`sheet:${h}`,`signals:${w.size}`,...[...w].slice(0,5)];return{sheetName:h,role:k,confidence:Number(y.toFixed(3)),evidence:f}}),i={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};l.forEach(h=>{switch(h.role){case"inputData":i.inputData?i.other.push(h.sheetName):i.inputData=h.sheetName;break;case"firstQuarter":i.firstQuarter.push(h.sheetName);break;case"secondQuarter":i.secondQuarter.push(h.sheetName);break;case"finalSemestral":i.finalSemestral.push(h.sheetName);break;case"helper":i.helper.push(h.sheetName);break;case"lookup":i.lookup.push(h.sheetName);break;case"other":default:i.other.push(h.sheetName);break}});const c=(i.inputData?1:0)+i.firstQuarter.length+i.secondQuarter.length+i.finalSemestral.length+i.helper.length+i.lookup.length,d=Jm({criticalFound:a.size,criticalTotal:fa.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(h=>Se(h.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),u=i.firstQuarter.length>0||i.secondQuarter.length>0,N=!!i.inputData&&u&&i.finalSemestral.length>0,m=d>=.55&&N;return i.inputData||r.push("Input Data sheet not confidently detected."),u||r.push("No quarter class record sheet detected."),i.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:fl,isOfficialFormatLikely:m,confidence:d,evidence:r,missingCriticalAnchors:n,detectedSheets:i,anchorMatches:s}}function Sa(t){if(typeof t=="number"&&Number.isFinite(t))return t;const s=String(t??"").trim();if(!s)return;const a=Number(s.replace(/[^0-9]/g,""));if(!(!Number.isFinite(a)||a<=0))return a}function Lr(t){const s=it(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function Dr(t){const s=it(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":Bm.some(a=>s.includes(a))?"signature":$m.some(a=>s.includes(a))?"helper":s.includes("LEARNERS NAMES")||s.includes("WRITTEN WORK")||s.includes("PERFORMANCE TASKS")||s.includes("QUARTERLY ASSESSMENT")||s.includes("INITIAL GRADE")||s.includes("QUARTERLY GRADE")?"header":t.hasLearnerName||t.hasLearnerNumber?"learner":s.includes("ATTACHMENTS")||s.includes("LOOK UP")?"helper":"unknown":"blank"}function eu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{a.push({role:r,name:String(ze(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function tu(t){const s=[],a=dt(t,"LEARNERS NAMES")[0],r=a?jl(t,a.row,5):t.startRow,n=(y,f)=>dt(t,y).find(S=>Math.abs(S.row-r)<=2)?.col??f,o=n(Le.learnerNo[0],t.startCol),l=n(Le.learnerName[0],t.startCol+1),i=n(Le.firstQuarter[0],l+1),c=n(Le.secondQuarter[0],i+1),d=n(Le.firstSemester[0],c+1),u=n(Le.finalGrades[0],d+1),N=n(Le.remark[0],u+1),m=n(Le.additionalRemarks[0],N+1),h=[];let w="UNKNOWN",k=0;for(let y=r+1;y<=t.endRow;y+=1){const f=Zt(t,y),v=Dr({rowText:f,hasLearnerNumber:/\b\d{1,2}\b/.test(f),hasLearnerName:/[A-Z]{2,}/.test(f)});if(v==="sex-header"){w=Lr(f)||w;continue}if(v==="signature"||v==="helper")break;if(v==="blank"){if(k+=1,k>=gl)break;continue}if(v!=="learner")continue;k=0;const S=Sa(ze(t,y,o)?.displayValue),R=String(ze(t,y,l)?.displayValue||"").trim();if(!R&&S===void 0)continue;const j=ze(t,y,i)?.displayValue??null,B=ze(t,y,c)?.displayValue??null,g=ze(t,y,d)?.displayValue??null,b=ze(t,y,u)?.displayValue??null,T=ze(t,y,N)?.displayValue??null;let z=ze(t,y,m)?.displayValue??null;const $=sa.filter(Z=>Se(f,Z));$.length>0&&(z=[z,$.join("; ")].filter(Boolean).join("; ")||null),!R&&S!==void 0&&s.push(`Row ${y+1} has learner number ${S} but empty learner name.`),h.push({learnerNo:S,fullName:R||`Unnamed Learner ${S||y+1}`,sex:w,firstQuarter:j,secondQuarter:B,firstSemester:g,finalGrades:b,remark:T,additionalRemarks:z,sourceRow:y+1})}return{sheetName:t.sheetName,learnerGrades:h,signatures:eu(t),warnings:s}}function Ct(t,s){for(const a of s){const r=dt(t,a);for(const n of r){const o=Nl(t,n.row,n.col,8);if(o&&o.trim())return o.trim()}}}function su(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(o=>{const l=Nl(t,o.row,o.col,10);a.push({role:r,name:l,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function au(t){const s=dt(t,"LEARNERS NAMES")[0];if(!s)return[];const a=s.row+1,r=s.col,n=Math.max(t.startCol,r-1),o=Math.min(t.endCol,r+1),l=Math.min(t.endCol,r+2),i=[];let c="UNKNOWN",d=0;for(let u=a;u<=t.endRow;u+=1){const N=Zt(t,u),m=Dr({rowText:N,hasLearnerNumber:!!Sa(ze(t,u,n)?.displayValue),hasLearnerName:!!String(ze(t,u,r)?.displayValue||"").trim()});if(m==="sex-header"){c=Lr(N)||c,d=0;continue}if(m==="signature"||m==="helper")break;if(m!=="learner"){if(m==="blank"&&(d+=1),d>=5)break;continue}d=0;const h=Sa(ze(t,u,n)?.displayValue),w=String(ze(t,u,r)?.displayValue||"").trim(),k=String(ze(t,u,o)?.displayValue||"").trim()||void 0,y=String(ze(t,u,l)?.displayValue||"").trim()||void 0,f=sa.filter(v=>Se(N,v));!w&&h===void 0||i.push({learnerNo:h,sex:c,fullName:w||`Unnamed Learner ${h||u}`,sourceSheet:t.sheetName,sourceRow:u+1,remarks:k,additionalRemarks:y,statuses:f.length>0?f:void 0})}return i}function ru(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const n=Zt(t,r);if(n){if(sa.some(o=>Se(n,o))){s.push(n);continue}(Se(n,"IMPORTANT")||Se(n,"NOTE")||Se(n,"ATTACHMENT")||Se(n,"LOOK UP"))&&a.push(n)}}return{attachmentRules:Array.from(new Set(s)),helperNotes:Array.from(new Set(a))}}function nu(t){const s=[],a={region:Ct(t,bt.region),division:Ct(t,bt.division),schoolName:Ct(t,bt.schoolName),schoolId:Ct(t,bt.schoolId),schoolYear:Ct(t,bt.schoolYear),gradeSection:Ct(t,bt.gradeSection),semester:Ct(t,bt.semester),track:Ct(t,bt.track),subjectCode:Ct(t,bt.subjectCode),subjectName:Ct(t,bt.subjectName),teacherName:Ct(t,bt.teacherName)},r=au(t),n=su(t),{attachmentRules:o,helperNotes:l}=ru(t);return a.schoolName||s.push("Input Data metadata is missing School Name."),a.schoolYear||s.push("Input Data metadata is missing School Year."),r.length===0&&s.push("No learners detected in Input Data sheet."),Mr(t,Object.values(bt).flat()).length<4&&s.push("Input Data sheet contains limited metadata anchors; layout may have drifted."),{sheetName:t.sheetName,schoolContext:a,learners:r,signatures:n,attachmentRules:o,helperNotes:l,warnings:s}}function ou(t){const s=it(t.sheetName);return Om.SECOND.some(a=>Se(s,a))?"SECOND":"FIRST"}function lu(t,s){const a=[],r=[],n=[];let o,l="NONE";for(let i=t.startCol;i<=t.endCol;i+=1){const c=ze(t,s,i),d=it(c?.displayValue||""),u=ze(t,s+1,i),N=String(u?.displayValue||c?.displayValue||"").trim();if(!d&&!N)continue;if(Se(d,Le.writtenWork[0])){l="WW";continue}if(Se(d,Le.performanceTasks[0])){l="PT";continue}if(Se(d,Le.quarterlyAssessment[0])){o={key:Za(N||"quarterly_assessment"),label:N||"Quarterly Assessment",column:Ls(i)},l="DERIVED";continue}if(Se(d,Le.initialGrade[0])||Se(d,Le.quarterlyGrade[0])||Se(d,Le.remark[0])||Se(d,Le.additionalRemarks[0])||Se(d,Le.firstQuarter[0])||Se(d,Le.secondQuarter[0])||Se(d,Le.firstSemester[0])||Se(d,Le.finalGrades[0])||Se(d,Le.ps[0])||Se(d,Le.ws[0])||Se(d,Le.total[0])){l="DERIVED",n.push({key:Za(N||d),label:N||d,column:Ls(i)});continue}const m={key:Za(N||d||Ls(i)),label:N||d||Ls(i),maxScore:ga(u?.displayValue),column:Ls(i)};l==="WW"?a.push(m):l==="PT"?r.push(m):l==="DERIVED"&&n.push(m)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:o,derived:n}}function iu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{const o=ze(t,n.row,n.col+1),l=String(o?.displayValue||"").trim()||void 0;a.push({role:r,name:l,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function to(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const n=it(ze(t,s,r)?.displayValue||""),o=it(ze(t,s+1,r)?.displayValue||"");if(a.some(l=>Se(n,l)||Se(o,l)))return r}}function cu(t,s,a,r){const n={learnerNo:Sa(ze(t,s,r.numberCol)?.displayValue),fullName:String(ze(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},o={};a.writtenWorks.forEach(d=>{const u=d.column?da(d.column):-1;if(u<0)return;const N=ze(t,s,u)?.displayValue;o[d.key]=N??null}),Object.keys(o).length>0&&(n.writtenWorks=o);const l={};if(a.performanceTasks.forEach(d=>{const u=d.column?da(d.column):-1;if(u<0)return;const N=ze(t,s,u)?.displayValue;l[d.key]=N??null}),Object.keys(l).length>0&&(n.performanceTasks=l),a.quarterlyAssessment?.column){const d=da(a.quarterlyAssessment.column);n.quarterlyAssessment=ze(t,s,d)?.displayValue??null}const i=a.derived||[],c={};return i.forEach(d=>{if(!d.column)return;const u=da(d.column);if(u<0)return;const N=ze(t,s,u)?.displayValue??null;c[d.key]=N,Se(d.label,Le.initialGrade[0])&&(n.initialGrade=N),Se(d.label,Le.quarterlyGrade[0])&&(n.quarterlyGrade=N),Se(d.label,Le.firstQuarter[0])&&(n.firstQuarter=N),Se(d.label,Le.secondQuarter[0])&&(n.secondQuarter=N),Se(d.label,Le.firstSemester[0])&&(n.firstSemester=N),Se(d.label,Le.finalGrades[0])&&(n.finalGrades=N),Se(d.label,Le.remark[0])&&(n.remark=N!==null?String(N):null),Se(d.label,Le.additionalRemarks[0])&&(n.additionalRemarks=N!==null?String(N):null)}),Object.keys(c).length>0&&(n.totals=c),n}function du(t){const s=ou(t),a=[],r=dt(t,Le.learnerName[0])[0]||dt(t,Le.learnerName[1])[0],n=r?jl(t,r.row,4):t.startRow,o=lu(t,n),l=to(t,n,Le.learnerNo)??t.startCol,i=to(t,n,Le.learnerName)??Math.min(t.endCol,l+1),c=[];let d="UNKNOWN",u=0;for(let w=n+1;w<=t.endRow;w+=1){const k=Zt(t,w),y=Dr({rowText:k,hasLearnerNumber:/\b\d{1,2}\b/.test(k),hasLearnerName:/[A-Z]{2,}/.test(k)});if(y==="sex-header"){d=Lr(k)||d;continue}if(y==="signature"||y==="helper")break;if(y==="blank"){if(u+=1,u>=gl)break;continue}if(y!=="learner")continue;u=0;const f=cu(t,w,o,{numberCol:l,nameCol:i});if(f.sex=d,!f.fullName&&f.learnerNo===void 0)continue;const v=sa.filter(S=>Se(k,S));v.length>0&&!f.additionalRemarks&&(f.additionalRemarks=v.join("; ")),!f.fullName&&f.learnerNo!==void 0&&(a.push(`Row ${w+1} has learner number ${f.learnerNo} but empty name.`),f.fullName=`Unnamed Learner ${f.learnerNo}`),c.push(f)}o.writtenWorks.length===0&&o.performanceTasks.length===0&&a.push(`No detailed assessment columns detected in ${t.sheetName}.`);const N=ga(dt(t,"WRITTEN WORK %")[0]?.value||dt(t,"WRITTEN WORK")[0]?.value),m=ga(dt(t,"PERFORMANCE TASKS %")[0]?.value||dt(t,"PERFORMANCE TASKS")[0]?.value),h=ga(dt(t,"QUARTERLY ASSESSMENT %")[0]?.value||dt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:N,performanceTasks:m,quarterlyAssessment:h},assessmentColumns:o,learnerGrades:c,signatures:iu(t),warnings:a}}function mu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{a.push({role:r,name:String(ze(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function uu(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const n=Zt(t,r);if(!n){if(a&&s.length>0)break;continue}if(Se(n,"WEIGHT OF COMPONENTS")){a=!0;continue}if(!a)continue;const o={sourceRow:r+1,raw:n};for(let l=t.startCol;l<=t.endCol;l+=1){const i=ze(t,r,l)?.displayValue;i==null||String(i).trim()===""||(o[`c${l}`]=i)}Object.keys(o).length>2&&s.push(o)}return s}function xu(t){const s=[],a=[],r=[],n=[],o=[];return t.forEach(l=>{mu(l).forEach(i=>a.push(i)),uu(l).forEach(i=>r.push({...i,sourceSheet:l.sheetName}));for(let i=l.startRow;i<=l.endRow;i+=1){const c=Zt(l,i);if(c){if(sa.some(d=>Se(c,d))){n.push(`${l.sheetName}: ${c}`);continue}(Se(c,"HELPER")||Se(c,"LOOK UP")||Se(c,"IMPORTANT")||Se(c,"REFERENCE")||Se(c,"ATTACHMENT"))&&o.push(`${l.sheetName}: ${c}`)}}}),r.length===0&&s.push("No component weight rows were parsed from reference sheets."),{sheetName:t.map(l=>l.sheetName).join(", "),componentWeights:r,attachmentRules:Array.from(new Set(n)),helperNotes:Array.from(new Set(o)),signatures:a,warnings:s}}function hu(t,s,a){const r=new Map,n=o=>{const l=`${it(o.fullName)}|${o.learnerNo||""}|${o.sourceSheet}`,i=r.get(l);if(!i){r.set(l,o);return}const c=Array.from(new Set([...i.statuses||[],...o.statuses||[]]));r.set(l,{...i,...o,remarks:o.remarks||i.remarks,additionalRemarks:o.additionalRemarks||i.additionalRemarks,statuses:c.length>0?c:void 0})};return t.forEach(n),s.forEach(o=>{o.learnerGrades.forEach(l=>{n({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:o.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})})}),a.forEach(o=>{o.learnerGrades.forEach(l=>{n({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:o.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})})}),Array.from(r.values())}function pu(t,s,a,r){const n=[...t.signatures,...s.flatMap(l=>l.signatures),...a.flatMap(l=>l.signatures),...r.signatures],o=new Map;return n.forEach(l=>{const i=`${it(l.role)}|${it(l.name||"")}|${l.sourceSheet}`;o.set(i,l)}),Array.from(o.values())}function fu(t){const s=hu(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:fl,version:zm,workbookMeta:{fileName:t.workbook.fileName,sheetNames:t.workbook.sheetNames,detectedSheets:{inputData:t.detection.detectedSheets.inputData,firstQuarter:t.detection.detectedSheets.firstQuarter,secondQuarter:t.detection.detectedSheets.secondQuarter,finalSemestral:t.detection.detectedSheets.finalSemestral,helper:t.detection.detectedSheets.helper,lookup:t.detection.detectedSheets.lookup,other:t.detection.detectedSheets.other}},schoolContext:{...t.inputData.schoolContext},learners:s,quarterlyRecords:t.quarterSheets.map(a=>({sheetName:a.sheetName,quarter:a.quarter,gradingWeights:a.gradingWeights,assessmentColumns:a.assessmentColumns,learnerGrades:a.learnerGrades})),finalSemestralRecords:t.finalSheets.map(a=>({sheetName:a.sheetName,learnerGrades:a.learnerGrades})),references:{componentWeights:t.references.componentWeights,attachmentRules:Array.from(new Set([...t.inputData.attachmentRules||[],...t.references.attachmentRules||[]])),helperNotes:Array.from(new Set([...t.inputData.helperNotes||[],...t.references.helperNotes||[]])),signatures:pu(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function gu(t){return!t||t.length===0?[]:t.map(s=>({s:{r:s.s.r,c:s.s.c},e:{r:s.e.r,c:s.e.c}}))}function bu(t){const s={ref:t["!ref"],merges:gu(t["!merges"]),cells:{}};return Object.keys(t).filter(a=>!a.startsWith("!")).forEach(a=>{const r=t[a];!r||!(r.v!==void 0||typeof r.w=="string"&&r.w.trim().length>0||typeof r.f=="string"&&r.f.trim().length>0)||(s.cells[a]={v:r.v,w:r.w,t:r.t,f:r.f})}),s}function vu(t,s){const a=Pi(s,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0,raw:!1}),r={},n={};return a.SheetNames.forEach(o=>{const l=a.Sheets[o];if(!l)return;const i=bu(l);n[o]=i,r[o]=Wm(o,i)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:n},matrices:r}}async function Nu(t){const s=await t.arrayBuffer();return vu(t.name,s)}class ju{state={};markRange(s,a,r){const n=s;this.state[n]||(this.state[n]={mappedAddresses:new Set,mappings:[]});for(let o=a.s.r;o<=a.e.r;o+=1)for(let l=a.s.c;l<=a.e.c;l+=1)this.state[n].mappedAddresses.add(`${o}:${l}`);this.state[n].mappings.push({sheetName:s,range:a,reason:r})}getMappings(){return Object.values(this.state).flatMap(s=>s.mappings)}getMappedRegionCount(){return this.getMappings().length}getUnmappedBlocks(s,a="unclassified"){const r=[];return Object.values(s).forEach(n=>{const o=new Set,l=this.state[n.sheetName]?.mappedAddresses??new Set;for(let i=n.startRow;i<=n.endRow;i+=1)for(let c=n.startCol;c<=n.endCol;c+=1){const d=`${i}:${c}`;if(o.has(d)||l.has(d))continue;const u=ze(n,i,c);if(!(u&&u.displayValue!==null&&u.displayValue!==void 0&&String(u.displayValue).trim())){o.add(d);continue}const m=this.collectComponent(n,i,c,l,o);m&&r.push({sheetName:n.sheetName,range:Vm(m),purposeGuess:a,raw2D:qm(n,m)})}}),r}collectComponent(s,a,r,n,o){const l=[{row:a,col:r}];let i=a,c=a,d=r,u=r,N=!1;for(;l.length>0;){const m=l.shift();if(!m)break;const h=`${m.row}:${m.col}`;if(o.has(h)||n.has(h))continue;o.add(h);const w=ze(s,m.row,m.col);w&&w.displayValue!==null&&w.displayValue!==void 0&&String(w.displayValue).trim()&&(N=!0,i=Math.min(i,m.row),c=Math.max(c,m.row),d=Math.min(d,m.col),u=Math.max(u,m.col),[{row:m.row-1,col:m.col},{row:m.row+1,col:m.col},{row:m.row,col:m.col-1},{row:m.row,col:m.col+1}].forEach(y=>{y.rows.endRow||y.cols.endCol||l.push(y)}))}return N?{s:{r:i,c:d},e:{r:c,c:u}}:null}}function yu(t){const s=t.detection.detectedSheets,a=[s.inputData?1:0,s.firstQuarter.length,s.secondQuarter.length,s.finalSemestral.length,s.helper.length,s.lookup.length].reduce((r,n)=>r+n,0);return{totalSheets:t.totalSheets,recognizedSheets:a,unclassifiedSheets:s.other.length,mappedCellRegions:t.mappedCellRegions,unmappedCellRegions:t.unmappedCellRegions}}function wu(t){const s=new Map;t.forEach(r=>{const n=`${r.learnerNo||""}|${r.fullName.trim().toUpperCase()}`;s.has(n)||s.set(n,[]),s.get(n)?.push(r.sourceRow)});const a=[];return s.forEach((r,n)=>{r.length>1&&a.push(`Duplicate learner entry detected for ${n} at rows ${r.join(", ")}.`)}),a}function Su(t){const s=[];return t.forEach(a=>{a.learnerGrades.forEach(r=>{r.fullName.trim()||s.push(`${a.sheetName} row ${r.sourceRow}: learner name is blank.`);const n=r.writtenWorks&&Object.values(r.writtenWorks).some(l=>l!==null&&l!==""),o=r.performanceTasks&&Object.values(r.performanceTasks).some(l=>l!==null&&l!=="");!n&&!o&&r.quarterlyAssessment==null&&s.push(`${a.sheetName} row ${r.sourceRow}: all grade blocks are empty.`)})}),s}function ku(t){const s=[];return t.forEach(a=>{a.learnerGrades.forEach(r=>{r.fullName.trim()||s.push(`${a.sheetName} row ${r.sourceRow}: learner name is blank.`),r.finalGrades==null&&r.firstSemester==null&&r.firstQuarter==null&&r.secondQuarter==null&&s.push(`${a.sheetName} row ${r.sourceRow}: no semestral/final values detected.`)})}),s}function Cu(t){const s=[],a=[];t.detection.detectedSheets.inputData||a.push("Missing Input Data sheet."),t.quarterSheets.length===0&&a.push("No quarter class record sheets were extracted."),t.finalSheets.length===0&&a.push("No Final Semestral sheet was extracted."),t.detection.missingCriticalAnchors.length>0&&s.push(`Missing critical anchors: ${t.detection.missingCriticalAnchors.join(", ")}.`),wu(t.inputData.learners).forEach(o=>s.push(o)),Su(t.quarterSheets).forEach(o=>s.push(o)),ku(t.finalSheets).forEach(o=>s.push(o)),s.push(...t.inputData.warnings),t.quarterSheets.forEach(o=>s.push(...o.warnings)),t.finalSheets.forEach(o=>s.push(...o.warnings)),t.unmappedCellRegions>t.mappedCellRegions&&s.push("A significant portion of workbook regions are unclassified; review diagnostics before confirming import.");const r=t.detection.confidence,n=t.detection.isOfficialFormatLikely&&a.length===0;return r({fullName:l.fullName,learnerNo:l.learnerNo,sex:l.sex,remarks:l.remarks,additionalRemarks:l.additionalRemarks,statuses:l.statuses,sourceSheet:l.sourceSheet,sourceRow:l.sourceRow})),r=t.quarterlyRecords.flatMap(l=>l.learnerGrades.map(i=>({fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,quarter:l.quarter,firstQuarter:i.firstQuarter,secondQuarter:i.secondQuarter,firstSemester:i.firstSemester,finalGrades:i.finalGrades,quarterlyGrade:i.quarterlyGrade,initialGrade:i.initialGrade,remark:i.remark,additionalRemarks:i.additionalRemarks}))),n=t.finalSemestralRecords.flatMap(l=>l.learnerGrades.map(i=>({fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,firstQuarter:i.firstQuarter,secondQuarter:i.secondQuarter,firstSemester:i.firstSemester,finalGrades:i.finalGrades,remark:i.remark,additionalRemarks:i.additionalRemarks}))),o=[...t.learners,...t.quarterlyRecords.flatMap(l=>l.learnerGrades.map(i=>({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})))].map(l=>({fullName:l.fullName,remark:l.remarks||null,additionalRemarks:l.additionalRemarks||null,statuses:"statuses"in l?l.statuses:void 0,sourceSheet:l.sourceSheet,sourceRow:l.sourceRow}));return{classEntity:s,studentEntities:a,gradeEntities:[...r,...n],remarksEntities:o}}const so=1500;function ao(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function ro(t){const s=`[shs-import] parse ${t.stage} file=${t.fileName} duration=${t.durationMs}ms sheets=${t.sheetCount} matrixCells=${t.matrixCellCount}`;if(t.stage==="failed"){console.error(`${s}${t.errorMessage?` error=${t.errorMessage}`:""}`);return}if(t.durationMs>=so){console.warn(`${s} slow=true threshold=${so}ms`);return}}function as(t,s){t?.onProgress?.(s)}function Iu(t,s){return Array.from(new Set(t.filter(a=>Number.isFinite(a)).map(a=>Math.max(s.startRow,Math.min(s.endRow,Math.trunc(a))))))}function Ds(t,s,a,r){Iu(a,s).forEach(n=>{t.markRange(s.sheetName,{s:{r:n,c:s.startCol},e:{r:n,c:s.endCol}},r)})}async function Eu(t,s){const a=s?.confidenceThreshold??Dm,r=Date.now();let n=null;try{if(as(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),n=await Nu(t),!n)throw new Error("Workbook read returned null");as(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const o=Zm(n);as(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const l=o.detectedSheets.inputData||n.sheetNames[0],i=n.matrices[l],c=i?nu(i):{sheetName:l,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},u=[...o.detectedSheets.firstQuarter||[],...o.detectedSheets.secondQuarter||[]].map(S=>n.matrices[S]).filter(S=>!!S).map(S=>du(S)),N=(o.detectedSheets.finalSemestral||[]).map(S=>n.matrices[S]).filter(S=>!!S).map(S=>tu(S)),m=[...o.detectedSheets.helper||[],...o.detectedSheets.lookup||[]].map(S=>n.matrices[S]).filter(S=>!!S),h=xu(m),w=new ju;o.anchorMatches.forEach(S=>{const R=n.matrices[S.sheetName];R&&Ds(w,R,[S.row],`Anchor match: ${S.anchor}`)}),[c.sheetName].forEach(S=>{const R=n.matrices[S];if(!R)return;const j=Array.from({length:Math.min(14,R.rowCount)},(b,T)=>R.startRow+T),B=c.learners.map(b=>b.sourceRow-1),g=c.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1);Ds(w,R,[...j,...B,...g],"Input Data parsed rows")}),u.forEach(S=>{const R=n.matrices[S.sheetName];if(!R)return;const j=S.learnerGrades.map(b=>b.sourceRow-1),B=S.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1),g=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Ds(w,R,[g,g+1,...j,...B],"Quarter sheet parsed rows")}),N.forEach(S=>{const R=n.matrices[S.sheetName];if(!R)return;const j=S.learnerGrades.map(b=>b.sourceRow-1),B=S.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1),g=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Ds(w,R,[g,g+1,...j,...B],"Final semestral parsed rows")}),m.forEach(S=>{const R=h.componentWeights.filter(g=>g.sourceSheet===S.sheetName).map(g=>g.sourceRow).filter(g=>typeof g=="number").map(g=>g-1),j=h.signatures?.filter(g=>g.sourceSheet===S.sheetName).map(g=>g.sourceRow).filter(g=>typeof g=="number").map(g=>g-1)||[],B=R.length===0&&j.length===0?[S.startRow,S.startRow+1,S.startRow+2]:[];Ds(w,S,[...R,...j,...B],"Reference/helper parsed rows")});const k=w.getUnmappedBlocks(n.matrices);as(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const y=Cu({detection:o,inputData:c,quarterSheets:u,finalSheets:N,mappedCellRegions:w.getMappedRegionCount(),unmappedCellRegions:k.length,totalSheets:n.sheetNames.length});as(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const f=fu({workbook:n,detection:o,inputData:c,quarterSheets:u,finalSheets:N,references:h,validation:y,unclassifiedBlocks:k});f.validation.confidence{const o=Ru[t??"null"],l=o.icon,i=r&&s!==null&&s!==void 0?`${o.label} ${s}`:o.label;return e.jsxs("span",{className:`inline-flex items-center rounded-full border font-medium transition-colors ${o.color} ${Au[a]} ${n}`,title:`WRI: ${s??"N/A"} — ${o.description}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${o.dotColor}`}),e.jsx(l,{className:"flex-shrink-0",size:a==="sm"?10:a==="md"?12:14}),i]})},Mu="https://deign86-mathpulse-api-v3test.hf.space";async function Lu(t){const s=et(Ge,"managedStudents",t),a=await ns(s);if(!a.exists())return null;const r=a.data();return{wri:r.wri??null,riskStatus:r.riskStatus??null,riskUpdatedAt:r.riskUpdatedAt?r.riskUpdatedAt.toDate():null,weights:r.weights??{w1:.3,w2:.4,w3:.3},diagnosticScore:r.diagnosticScore??null,externalGradesAvg:r.externalGradesAvg??null,systemPerformanceAvg:r.systemPerformanceAvg??null,riskHistory:r.riskHistory??[],riskRecalcNeeded:r.riskRecalcNeeded??!1}}async function wl(t,s,a="manual"){const r=et(Ge,"managedStudents",t),n={wri:s.wri??0,riskStatus:s.risk_status,computedAt:new Date,trigger:a},o=s.risk_status==="pending_assessment"?null:s.risk_status;await yt(r,{wri:s.wri,riskStatus:o,riskUpdatedAt:ot(),riskHistory:hi(n),riskRecalcNeeded:!1,diagnosticScore:s.inputs.D,externalGradesAvg:s.inputs.G,systemPerformanceAvg:s.inputs.P})}async function Sl(t,s,a,r={w1:.3,w2:.4,w3:.3}){try{const n=new AbortController,o=setTimeout(()=>n.abort(),3e4),l=await fetch(`${Mu}/api/risk/compute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({d:t,g:s,p:a,weights:r}),signal:n.signal});if(clearTimeout(o),!l.ok)throw new Error(`API error: ${l.status}`);return await l.json()}catch{return Du(t,s,a,r)}}function Du(t,s,a,r){if(t===null)return{wri:null,risk_status:"pending_assessment",inputs:{D:t,G:s,P:a},g_fallback:!1,p_fallback:!1};const n=s??t,o=a??t,l=s===null,i=a===null,c=Math.round((r.w1*t+r.w2*n+r.w3*o)*100)/100;let d;return c>=88?d="safe":c>=80?d="watch":c>=75?d="intervene":c>=68?d="critical":d="at_risk",{wri:c,risk_status:d,inputs:{D:t,G:n,P:o},g_fallback:l,p_fallback:i}}async function no(t){const s=await Lu(t);if(!s)throw new Error(`Student ${t} not found`);const a=await Sl(s.diagnosticScore??null,s.externalGradesAvg??null,s.systemPerformanceAvg??null,s.weights??{w1:.3,w2:.4,w3:.3});await wl(t,a,"manual")}function zu(t,s={}){const{autoRecalc:a=!1}=s,[r,n]=p.useState(null),[o,l]=p.useState(!0),[i,c]=p.useState(null);p.useEffect(()=>{if(!t){n(null),l(!1);return}const N=et(Ge,"managedStudents",t);return Xs(N,h=>{if(!h.exists()){n(null),l(!1);return}const w=h.data(),k={wri:w.wri??null,riskStatus:w.riskStatus??null,riskUpdatedAt:w.riskUpdatedAt?w.riskUpdatedAt.toDate():null,weights:w.weights??{w1:.3,w2:.4,w3:.3},diagnosticScore:w.diagnosticScore??null,externalGradesAvg:w.externalGradesAvg??null,systemPerformanceAvg:w.systemPerformanceAvg??null,riskHistory:w.riskHistory??[],riskRecalcNeeded:w.riskRecalcNeeded??!1};n(k),l(!1),c(null),a&&k.riskRecalcNeeded&&no(t).catch(y=>console.error("[useStudentRisk] auto-recalc failed:",y))},h=>{console.error("[useStudentRisk] snapshot error:",h),c(h instanceof Error?h.message:"Unknown error"),l(!1)})},[t,a]);const d=p.useCallback(async()=>{if(t){l(!0);try{await no(t)}catch(N){c(N instanceof Error?N.message:"Recalculation failed")}finally{l(!1)}}},[t]),u=p.useCallback(async N=>{if(!t||!r)return;n(h=>h&&{...h,weights:N});const m=await Sl(r.diagnosticScore??null,r.externalGradesAvg??null,r.systemPerformanceAvg??null,N);await wl(t,m,"manual")},[t,r]);return{wri:r?.wri??null,riskStatus:r?.riskStatus??null,diagnosticScore:r?.diagnosticScore??null,externalGradesAvg:r?.externalGradesAvg??null,systemPerformanceAvg:r?.systemPerformanceAvg??null,weights:r?.weights??{w1:.3,w2:.4,w3:.3},riskHistory:r?.riskHistory??[],riskUpdatedAt:r?.riskUpdatedAt??null,loading:o,error:i,recalculate:d,updateWeights:u,breakdown:{diagnostic:r?.diagnosticScore??null,external:r?.externalGradesAvg??null,system:r?.systemPerformanceAvg??null},pendingAssessment:r?.diagnosticScore===null}}const er=({label:t,value:s,weight:a,color:r})=>{const n=s??0;return(n*a).toFixed(1),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-600 font-medium",children:t}),e.jsxs("span",{className:"text-slate-900 font-semibold tabular-nums",children:[s!==null?`${s.toFixed(0)}%`:"—",e.jsxs("span",{className:"text-slate-400 font-normal text-xs ml-1",children:["(w=",a,")"]})]})]}),e.jsx("div",{className:"h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx(Re.div,{className:`h-full rounded-full ${r}`,initial:{width:0},animate:{width:`${n}%`},transition:{duration:.6,ease:"easeOut"}})})]})},Fu=({studentId:t,studentName:s,className:a=""})=>{const[r,n]=p.useState(!1),{wri:o,riskStatus:l,diagnosticScore:i,externalGradesAvg:c,systemPerformanceAvg:d,weights:u,riskHistory:N,riskUpdatedAt:m,loading:h,recalculate:w,pendingAssessment:k}=zu(t),y=(()=>{if(!N||N.length<2)return"stable";const B=N.slice(-2),g=B[1].wri-B[0].wri;return g>2?"improving":g<-2?"declining":"stable"})(),f=y==="improving"?ka:y==="declining"?Ai:jo,v=(N??[]).slice(-10).map(B=>({wri:B.wri,date:B.computedAt})),S=u.w1,R=u.w2,j=u.w3;return e.jsxs("div",{className:`bg-white border border-slate-200 rounded-lg overflow-hidden ${a}`,children:[e.jsxs("button",{onClick:()=>n(!r),className:"w-full flex items-center justify-between p-4 hover:bg-slate-50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yl,{status:l,wri:o,size:"md",showScore:!0}),s&&e.jsx("span",{className:"text-sm font-medium text-slate-700",children:s}),o!==null&&e.jsxs("span",{className:`flex items-center gap-1 text-xs ${y==="improving"?"text-emerald-600":y==="declining"?"text-rose-600":"text-slate-500"}`,children:[e.jsx(f,{size:12}),e.jsx("span",{className:"capitalize",children:y})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[!k&&e.jsxs($e,{variant:"ghost",size:"sm",onClick:B=>{B.stopPropagation(),w()},disabled:h,className:"text-xs h-7 px-2",children:[e.jsx(_s,{size:10,className:h?"animate-spin":""}),"Recalc"]}),e.jsx(Ht,{size:16,className:`text-slate-400 transition-transform ${r?"rotate-180":""}`})]})]}),k&&e.jsx("div",{className:"px-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 bg-slate-50 rounded-lg p-3",children:[e.jsx(ko,{size:14,className:"text-slate-400"}),e.jsx("span",{children:"Complete the initial diagnostic assessment to calculate WRI."})]})}),e.jsx(Qt,{children:r&&!k&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-slate-500 uppercase tracking-wide",children:[e.jsx(lc,{size:12}),"Score Breakdown"]}),e.jsx(er,{label:"Diagnostic (D)",value:i,weight:S,color:"bg-blue-500"}),e.jsx(er,{label:"External Grades (G)",value:c,weight:R,color:"bg-violet-500"}),e.jsx(er,{label:"System Performance (P)",value:d,weight:j,color:"bg-cyan-500"})]}),e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-slate-600",children:"Formula"}),e.jsxs("div",{className:"font-mono text-sm text-slate-700",children:["WRI = (",S,")×D + (",R,")×G + (",j,")×P"]}),e.jsxs("div",{className:"text-xs text-slate-500",children:["= (",S,"×",i?.toFixed(0)??"—",") + (",R,"×",c?.toFixed(0)??"—",") + (",j,"×",d?.toFixed(0)??"—",")"," ",e.jsxs("span",{className:"font-semibold text-slate-700",children:["= ",o??"—"]})]})]}),v.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide",children:"Risk Trend"}),e.jsx("div",{className:"h-16 w-full",children:e.jsx(sr,{width:"100%",height:"100%",children:e.jsxs(_i,{data:v,margin:{top:2,right:2,bottom:2,left:2},children:[e.jsx(ar,{domain:[0,100],hide:!0}),e.jsx(oa,{y:68,stroke:"#000000",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:75,stroke:"#f43f5e",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:80,stroke:"#3b82f6",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:88,stroke:"#10b981",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(rr,{formatter:B=>[`${B.toFixed(1)}`,"WRI"],labelFormatter:(B,g)=>g?.[0]?.payload?.date?new Date(g[0].payload.date).toLocaleDateString():""}),e.jsx(Hi,{type:"monotone",dataKey:"wri",stroke:"#6366f1",strokeWidth:2,dot:{r:2,fill:"#6366f1"},activeDot:{r:4}})]})})}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-400",children:[e.jsx("span",{className:"text-black",children:"— 68 (At-Risk floor)"}),e.jsx("span",{className:"text-rose-500",children:"— 75 (Critical threshold)"}),e.jsx("span",{className:"text-blue-500",children:"— 80 (Watch threshold)"}),e.jsx("span",{className:"text-emerald-500",children:"— 88 (Safe threshold)"})]})]}),m&&e.jsxs("div",{className:"text-xs text-slate-400 text-right",children:["Last computed: ",m.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-400 italic border-t border-slate-100 pt-2",children:"WRI thresholds based on DepEd DO No. 8, s. 2015. WRI is a support tool — final decisions remain with the teacher."})]})})})]})},Bu=({studentId:t,studentName:s})=>{const[a,r]=p.useState(null),[n,o]=p.useState(!0),[l,i]=p.useState(!1);p.useEffect(()=>{const m=et(Ge,"interventionChecklists",t);return Xs(m,w=>{if(!w.exists()){r(null),o(!1);return}const k=w.data();r({studentId:k.studentId,items:k.items||[],generatedAt:k.generatedAt?.toDate()||null,acknowledged:k.acknowledged===!0,acknowledgedAt:k.acknowledgedAt?.toDate()||null,acknowledgedBy:k.acknowledgedBy||null}),o(!1)},w=>{console.error("[InterventionChecklistPanel] error:",w),o(!1)})},[t]);const c=async m=>{if(!a||l)return;i(!0);const h=a.items.map(w=>w.id===m?{...w,completed:!w.completed}:w);try{const w=et(Ge,"interventionChecklists",t);await yt(w,{items:h})}catch(w){console.error("[InterventionChecklistPanel] toggle error:",w)}finally{i(!1)}},d=async()=>{if(!(!a||l)){i(!0);try{const m=et(Ge,"interventionChecklists",t);await yt(m,{acknowledged:!0,acknowledgedAt:ot()});const h=et(Ge,"users",t);await yt(h,{teacherAcknowledged:!0,teacherAckRequired:!1,teacherAcknowledgedAt:ot()})}catch(m){console.error("[InterventionChecklistPanel] acknowledge error:",m)}finally{i(!1)}}};if(n)return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-400 py-4",children:[e.jsx(nt,{size:14,className:"animate-spin"}),"Loading intervention checklist..."]});if(!a)return e.jsx("div",{className:"text-sm text-slate-400 py-2",children:"No intervention checklist generated yet."});const u=a.items.filter(m=>m.completed).length,N=u===a.items.length;return e.jsxs(Re.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"bg-white border border-slate-200 rounded-lg p-4 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Zi,{size:16,className:"text-rose-500"}),e.jsxs("h4",{className:"text-sm font-semibold text-slate-800",children:["Intervention Checklist ",s?`— ${s}`:""]}),e.jsxs("span",{className:"text-xs text-slate-400 ml-auto",children:[u,"/",a.items.length," completed"]})]}),e.jsx("div",{className:"space-y-2",children:a.items.map(m=>e.jsxs("button",{onClick:()=>c(m.id),disabled:l||a.acknowledged,className:`w-full flex items-center gap-3 text-left px-3 py-2 rounded-md transition-colors ${m.completed?"bg-emerald-50 text-emerald-700":"bg-slate-50 text-slate-700 hover:bg-slate-100"} ${a.acknowledged?"opacity-60 cursor-not-allowed":"cursor-pointer"}`,children:[m.completed?e.jsx(dc,{size:16,className:"flex-shrink-0"}):e.jsx(ki,{size:16,className:"flex-shrink-0 text-slate-400"}),e.jsx("span",{className:`text-sm ${m.completed?"line-through opacity-70":""}`,children:m.text})]},m.id))}),!a.acknowledged&&e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-slate-500",children:N?"All items completed. You can now acknowledge.":"Complete all items before acknowledging."}),e.jsxs($e,{size:"sm",onClick:d,disabled:l||!N,className:"text-xs",children:[l?e.jsx(nt,{size:12,className:"animate-spin mr-1"}):e.jsx(ja,{size:12,className:"mr-1"}),"Acknowledge & Unlock"]})]}),a.acknowledged&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-emerald-600 bg-emerald-50 rounded-md px-3 py-2",children:[e.jsx(ja,{size:14}),"Acknowledged on ",a.acknowledgedAt?.toLocaleDateString()||"—"]})]})},fs=({label:t,value:s,icon:a,color:r})=>e.jsxs("div",{className:"flex items-center gap-3 bg-white border border-slate-200 rounded-lg p-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${r}`,children:a}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900 tabular-nums",children:s}),e.jsx("div",{className:"text-xs text-slate-500 font-medium",children:t})]})]}),$u=()=>{const[t,s]=p.useState([]),[a,r]=p.useState(!0),[n,o]=p.useState("all"),[l,i]=p.useState(""),[c,d]=p.useState("wri"),[u,N]=p.useState("asc"),[m,h]=p.useState(null);p.useEffect(()=>{const v=Bt(Ge,"managedStudents");return Xs(v,R=>{const j=R.docs.map(B=>{const g=B.data();return{id:B.id,...g,wri:g.wri??null,riskStatus:g.riskStatus??null,diagnosticScore:g.diagnosticScore??null,externalGradesAvg:g.externalGradesAvg??null,systemPerformanceAvg:g.systemPerformanceAvg??null}});s(j),r(!1)},R=>{console.error("[AtRiskDashboard] error:",R),r(!1)})},[]);const w=p.useMemo(()=>{let v=[...t];if(n!=="all"&&(v=v.filter(S=>S.riskStatus===n)),l.trim()){const S=l.toLowerCase();v=v.filter(R=>(R.name||"").toLowerCase().includes(S)||(R.email||"").toLowerCase().includes(S)||(R.lrn||"").toLowerCase().includes(S))}return v.sort((S,R)=>{let j=0;return c==="name"?j=String(S.name||S.email||"").localeCompare(String(R.name||R.email||"")):c==="wri"?j=(S.wri??100)-(R.wri??100):c==="updatedAt"&&(j=(S.updatedAt?.seconds??0)-(R.updatedAt?.seconds??0)),u==="asc"?j:-j}),v},[t,n,l,c,u]),k=p.useMemo(()=>{const v=t.length,S=t.filter(b=>b.riskStatus==="safe").length,R=t.filter(b=>b.riskStatus==="watch").length,j=t.filter(b=>b.riskStatus==="intervene").length,B=t.filter(b=>b.riskStatus==="critical").length,g=t.filter(b=>b.riskStatus==="at_risk").length;return{total:v,safe:S,watch:R,intervene:j,critical:B,atRisk:g}},[t]),y=v=>{c===v?N(S=>S==="asc"?"desc":"asc"):(d(v),N("asc"))},f=({field:v})=>c!==v?null:u==="asc"?e.jsx(Vi,{size:12}):e.jsx(Ui,{size:12});return e.jsxs("div",{className:"min-h-screen bg-slate-50",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-slate-900",children:"At-Risk Student Monitoring"}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:"Track student risk using the Weighted Risk Index (WRI) based on DepEd grading standards"})]})})}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[e.jsx(fs,{label:"Total Students",value:k.total,icon:e.jsx(Ps,{size:20,className:"text-slate-600"}),color:"bg-slate-100"}),e.jsx(fs,{label:"Safe",value:k.safe,icon:e.jsx(Co,{size:20,className:"text-emerald-600"}),color:"bg-emerald-50"}),e.jsx(fs,{label:"Watch",value:k.watch,icon:e.jsx(pr,{size:20,className:"text-blue-600"}),color:"bg-blue-50"}),e.jsx(fs,{label:"Intervene",value:k.intervene,icon:e.jsx(Gt,{size:20,className:"text-amber-600"}),color:"bg-amber-50"}),e.jsx(fs,{label:"Critical",value:k.critical,icon:e.jsx(Ca,{size:20,className:"text-rose-600"}),color:"bg-rose-50"}),e.jsx(fs,{label:"At Risk",value:k.atRisk,icon:e.jsx(Eo,{size:20,className:"text-slate-600"}),color:"bg-slate-100"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 bg-white border border-slate-200 rounded-lg p-1",children:["all","safe","watch","intervene","critical","at_risk"].map(v=>e.jsxs("button",{onClick:()=>o(v),className:`px-3 py-1.5 text-sm rounded-md font-medium transition-colors ${n===v?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[v==="all"?"All":v==="at_risk"?"At Risk":v.charAt(0).toUpperCase()+v.slice(1),v!=="all"&&e.jsxs("span",{className:"ml-1.5 text-xs opacity-70",children:["(",k[v],")"]})]},v))}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(Js,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search student...",value:l,onChange:v=>i(v.target.value),className:"w-full pl-9 pr-3 py-2 text-sm bg-white border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-slate-900/10 focus:border-slate-300"})]}),e.jsxs("div",{className:"text-sm text-slate-500",children:[w.length," student",w.length!==1?"s":""]})]}),e.jsx("div",{className:"bg-white border border-slate-200 rounded-lg overflow-hidden",children:a?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(_s,{size:20,className:"animate-spin text-slate-400"}),e.jsx("span",{className:"ml-2 text-slate-500",children:"Loading students..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-400",children:[e.jsx(Ps,{size:32}),e.jsx("p",{className:"mt-2 text-sm",children:"No students found"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:e.jsxs("button",{onClick:()=>y("name"),className:"flex items-center gap-1 hover:text-slate-900",children:["Student ",e.jsx(f,{field:"name"})]})}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:e.jsxs("button",{onClick:()=>y("wri"),className:"flex items-center gap-1 hover:text-slate-900",children:["WRI ",e.jsx(f,{field:"wri"})]})}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden md:table-cell",children:"Diagnostic"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden lg:table-cell",children:"External"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden lg:table-cell",children:"System"}),e.jsx("th",{className:"text-right px-4 py-3 font-semibold text-slate-700",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:w.map(v=>e.jsxs(oe.Fragment,{children:[e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors cursor-pointer",onClick:()=>h(S=>S===v.id?null:v.id),children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-slate-900",children:v.name||"—"}),e.jsx("div",{className:"text-xs text-slate-500",children:v.email})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(yl,{status:v.riskStatus,wri:v.wri,size:"sm",showScore:!0})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"font-mono font-semibold tabular-nums",children:v.wri!==null?v.wri.toFixed(1):"—"})}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden md:table-cell tabular-nums",children:v.diagnosticScore!==null?`${v.diagnosticScore.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden lg:table-cell tabular-nums",children:v.externalGradesAvg!==null?`${v.externalGradesAvg.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden lg:table-cell tabular-nums",children:v.systemPerformanceAvg!==null?`${v.systemPerformanceAvg.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-right",onClick:S=>S.stopPropagation(),children:e.jsx("button",{onClick:()=>h(S=>S===v.id?null:v.id),className:"text-slate-400 hover:text-slate-600 transition-colors",children:e.jsx(Ht,{size:14,className:`transition-transform ${m===v.id?"rotate-180":""}`})})})]}),m===v.id&&e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-4 py-4 bg-slate-50/50",children:[e.jsx(Fu,{studentId:v.id,studentName:v.name}),(v.riskStatus==="critical"||v.riskStatus==="at_risk")&&e.jsx(Bu,{studentId:v.id,studentName:v.name})]})})]},v.id))})]})})}),e.jsx("div",{className:"text-xs text-slate-400 text-center",children:"WRI classification based on DepEd DO No. 8, s. 2015 (Policy Guidelines on Classroom Assessment). WRI is a support tool — final academic decisions remain with the teacher."})]})]})};function Ou(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.name,grade:t.grade,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId||t.teacherId,ownerTeacherName:t.ownerTeacherName,adviserTeacherId:t.adviserTeacherId||t.teacherId,adviserTeacherName:t.adviserTeacherName||t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName});return{id:t.id,name:a.className||t.name,classSectionId:a.classSectionId||t.classSectionId,classMetadata:a,gradeLevel:a.gradeLevel||void 0,classification:a.classification||void 0,strand:a.strand||void 0,managerId:a.managerId||void 0,managerName:a.managerName||void 0,schedule:t.schedule,studentCount:t.studentCount,avgScore:t.avgScore,atRiskCount:t.atRiskCount,riskLevel:s}}function Pu(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?kl(t.lastActive.toDate()):"Unknown",n=t.className||s||"Imported Class",o=Dt(n),l=t.grade||o.grade,i=t.section||o.section,c=lt({metadata:t.classMetadata,classSectionId:t.classSectionId||t.classroomId,className:[l,i].filter(Boolean).join(" - ")||n,grade:l,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:i,adviserTeacherId:t.teacherId,ownerTeacherId:t.teacherId,managerId:t.classMetadata?.managerId||t.managerId,managerName:t.classMetadata?.managerName||t.managerName});return{id:t.id,lrn:t.lrn,name:t.name,avatar:t.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:t.avgQuizScore,riskLevel:a,weakestTopic:t.weakestTopic||"N/A",classroomId:t.classroomId||c.classSectionId||n,className:c.className||[l,i].filter(Boolean).join(" - ")||n,grade:l,gradeLevel:c.gradeLevel||ds(l)||void 0,classification:c.classification||ws(c.gradeLevel||l)||void 0,strand:c.strand||Ss(c.className,i)||void 0,section:i,classSectionId:c.classSectionId||t.classSectionId,classMetadata:c,managerId:c.managerId||void 0,managerName:c.managerName||void 0,lastActive:r,struggles:t.struggles||[],engagementScore:t.engagementScore,attendance:t.attendance,assignmentCompletion:t.assignmentCompletion}}function _u(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.name,grade:t.grade,gradeLevel:t.gradeLevel||t.classMetadata?.gradeLevel,classification:t.classification||t.classMetadata?.classification,strand:t.strand||t.classMetadata?.strand,section:t.section,managerId:t.managerId||t.classMetadata?.managerId,managerName:t.managerName||t.classMetadata?.managerName});return{id:t.id,name:a.className||t.name,classSectionId:a.classSectionId||t.classSectionId||void 0,classMetadata:a,gradeLevel:a.gradeLevel||void 0,classification:a.classification||void 0,strand:a.strand||void 0,managerId:a.managerId||void 0,managerName:a.managerName||void 0,schedule:t.schedule||"Mon-Fri",studentCount:t.studentCount,avgScore:t.avgScore,atRiskCount:t.atRiskCount,riskLevel:s}}function Hu(t){const s=(t.riskLevel||"Low").toLowerCase(),a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.className||[t.grade,t.section].filter(Boolean).join(" - ")||"Imported Class",grade:t.grade,gradeLevel:t.gradeLevel||t.classMetadata?.gradeLevel,classification:t.classification||t.classMetadata?.classification,strand:t.strand||t.classMetadata?.strand,section:t.section,managerId:t.managerId||t.classMetadata?.managerId,managerName:t.managerName||t.classMetadata?.managerName}),r=a.className||"Imported Class";return{id:t.id,lrn:t.lrn||void 0,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:t.avgQuizScore,riskLevel:s,weakestTopic:t.weakestTopic||"Foundational Skills",classroomId:a.classSectionId||t.classSectionId||r,className:r,grade:a.grade||Dt(r).grade,gradeLevel:a.gradeLevel||ds(a.grade||Dt(r).grade)||void 0,classification:a.classification||ws(a.gradeLevel||a.grade)||void 0,strand:a.strand||Ss(r,a.section||t.section)||void 0,section:a.section||Dt(r).section,classSectionId:a.classSectionId||t.classSectionId||void 0,classMetadata:a,managerId:a.managerId||void 0,managerName:a.managerName||void 0,lastActive:"Recently imported",struggles:[t.weakestTopic||"Foundational Skills"],engagementScore:t.engagementScore,attendance:t.attendance,assignmentCompletion:t.assignmentCompletion}}function Gu(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function Qu(t,s,a,r){const n=lt({metadata:r,classSectionId:s,className:a}),o=n.className||"Imported Class",l=n.classSectionId||"imported_class",i=Number(t.avgQuizScore||0),c=Number(t.attendance||0),d=Number(t.engagementScore||0),u=Number(t.assignmentCompletion||0),N=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",m=Gu(i,c,d),h=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${l}-${h}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:i,riskLevel:m,weakestTopic:N,classroomId:l,className:o,grade:n.grade||Dt(o).grade,gradeLevel:n.gradeLevel||ds(n.grade||Dt(o).grade)||void 0,classification:n.classification||ws(n.gradeLevel||n.grade)||void 0,strand:n.strand||Ss(o,n.section)||void 0,section:n.section||Dt(o).section,classSectionId:l,classMetadata:n,managerId:n.managerId||void 0,managerName:n.managerName||void 0,lastActive:"Recently imported",struggles:[N],engagementScore:d,attendance:c,assignmentCompletion:u}}function Uu(t,s,a,r){const n=lt({metadata:t.dashboardSync?.classMetadata||t.classMetadata||r,classSectionId:t.dashboardSync?.classSectionId||s,className:t.dashboardSync?.className||a}),o=n.classSectionId||"imported_class",l=n.className||"Imported Class";return{classSectionId:o,className:l,classMetadata:{...n,classSectionId:o,className:l}}}function kl(t){const s=Date.now()-t.getTime(),a=Math.floor(s/6e4);if(a<1)return"Just now";if(a<60)return`${a} min${a>1?"s":""} ago`;const r=Math.floor(a/60);if(r<24)return`${r} hour${r>1?"s":""} ago`;const n=Math.floor(r/24);return`${n} day${n>1?"s":""} ago`}function rt(t){return(t||"").trim().toLowerCase()}function oo(t){const s=rt(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function lo(t,s){const a=new Map;return t.forEach(r=>{a.set(oo(r),r)}),s.forEach(r=>{const n=oo(r),o=a.get(n);if(!o){a.set(n,r);return}const l=Math.max(o.atRiskCount||0,r.atRiskCount||0),i=Math.max(o.studentCount||0,r.studentCount||0),c=r.avgScore>0?r.avgScore:o.avgScore,d=l>=5?"high":l>=2?"medium":"low",u=lt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.name||r.name,grade:o.classMetadata?.grade||r.classMetadata?.grade,gradeLevel:o.classMetadata?.gradeLevel||r.classMetadata?.gradeLevel,classification:o.classMetadata?.classification||r.classMetadata?.classification,strand:o.classMetadata?.strand||r.classMetadata?.strand,section:o.classMetadata?.section||r.classMetadata?.section,schoolYear:o.classMetadata?.schoolYear||r.classMetadata?.schoolYear,ownerTeacherId:o.classMetadata?.ownerTeacherId||r.classMetadata?.ownerTeacherId,ownerTeacherName:o.classMetadata?.ownerTeacherName||r.classMetadata?.ownerTeacherName,adviserTeacherId:o.classMetadata?.adviserTeacherId||r.classMetadata?.adviserTeacherId,adviserTeacherName:o.classMetadata?.adviserTeacherName||r.classMetadata?.adviserTeacherName,managerId:o.classMetadata?.managerId||r.classMetadata?.managerId,managerName:o.classMetadata?.managerName||r.classMetadata?.managerName});a.set(n,{...o,classSectionId:u.classSectionId||o.classSectionId||r.classSectionId,name:u.className||o.name||r.name,classMetadata:u,gradeLevel:u.gradeLevel||void 0,classification:u.classification||void 0,strand:u.strand||void 0,managerId:u.managerId||void 0,managerName:u.managerName||void 0,schedule:o.schedule||r.schedule,studentCount:i,atRiskCount:l,avgScore:c,riskLevel:d})}),Array.from(a.values())}function io(t){const s=(t.lrn||"").trim().toLowerCase();if(s)return`lrn:${s}`;const a=t.name.trim().toLowerCase();if(a)return`name:${a}`;const r=rt(t.classSectionId)||rt(t.classroomId),n=(t.id||"").trim().toLowerCase();return r&&n?`${r}|id:${n}`:`${r}|anonymous`}function Ns(t){const s=rt(t.classSectionId)||rt(t.classroomId),a=(t.lrn||"").trim().toLowerCase(),r=(t.id||"").trim().toLowerCase(),n=t.name.trim().toLowerCase().replace(/\s+/g,"_");return s&&a?`${s}|lrn:${a}`:s&&r?`${s}|id:${r}`:a?`lrn:${a}`:r&&n?`id:${r}|name:${n}`:r?`id:${r}`:s&&n?`${s}|name:${n}`:`name:${n||"unknown"}`}function co(t,s){const a=new Map;return t.forEach(r=>{a.set(io(r),r)}),s.forEach(r=>{const n=io(r),o=a.get(n);if(!o){a.set(n,r);return}const l=[o.riskLevel,r.riskLevel].includes("high")?"high":[o.riskLevel,r.riskLevel].includes("medium")?"medium":"low",i=lt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.className||r.className,grade:o.grade||r.grade,gradeLevel:o.gradeLevel||r.gradeLevel,classification:o.classification||r.classification,strand:o.strand||r.strand,section:o.section||r.section,managerId:o.managerId||r.managerId,managerName:o.managerName||r.managerName});a.set(n,{...o,lrn:o.lrn||r.lrn,classSectionId:i.classSectionId||o.classSectionId||r.classSectionId,classroomId:o.classroomId||r.classroomId,className:i.className||o.className||r.className,grade:i.grade||o.grade||r.grade,gradeLevel:i.gradeLevel||o.gradeLevel||r.gradeLevel,classification:i.classification||o.classification||r.classification,strand:i.strand||o.strand||r.strand,section:i.section||o.section||r.section,managerId:i.managerId||o.managerId||r.managerId,managerName:i.managerName||o.managerName||r.managerName,classMetadata:i,avgScore:r.avgScore>0?r.avgScore:o.avgScore,attendance:r.attendance>0?r.attendance:o.attendance,engagementScore:r.engagementScore>0?r.engagementScore:o.engagementScore,assignmentCompletion:r.assignmentCompletion>0?r.assignmentCompletion:o.assignmentCompletion,weakestTopic:o.weakestTopic&&o.weakestTopic!=="N/A"?o.weakestTopic:r.weakestTopic,riskLevel:l,struggles:o.struggles.length>0?o.struggles:r.struggles})}),Array.from(a.values())}const Kx=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:n}=Ks(),[o,l]=p.useState("dashboard"),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[N,m]=p.useState(!1),[h,w]=p.useState(!1),[k,y]=p.useState(!1),[f,v]=p.useState(null),[S,R]=p.useState(null),[j,B]=p.useState([]),[g,b]=p.useState([]),[T,z]=p.useState([]),[$,Z]=p.useState(""),[ae,H]=p.useState(!0),[ee,re]=p.useState(!1),[ne,D]=p.useState(0),[te,J]=p.useState([]),[me,Ce]=p.useState(!1),F=p.useRef(new Map);p.useEffect(()=>{if(!r)return;const E=r.uid;let W=!0,je;return(async()=>{H(!0);try{const De=await ml(E);let fe=De.map(Ou);const Me=await Kd(E).catch(()=>[]),I=new Map;Me.forEach(U=>{const ue=rt(U.classSectionId);ue&&I.set(ue,U)}),fe=fe.map(U=>{const ue=I.get(rt(U.classSectionId));if(!ue)return U;const Be=lt({metadata:U.classMetadata,classSectionId:ue.classSectionId||U.classSectionId,className:ue.className||U.name,grade:ue.grade||U.classMetadata?.grade,gradeLevel:ue.gradeLevel||U.classMetadata?.gradeLevel,classification:ue.classification||U.classMetadata?.classification,strand:ue.strand||U.classMetadata?.strand,section:ue.section||U.classMetadata?.section,schoolYear:ue.schoolYear||U.classMetadata?.schoolYear,ownerTeacherId:ue.ownerTeacherId||U.classMetadata?.ownerTeacherId,ownerTeacherName:ue.ownerTeacherName||U.classMetadata?.ownerTeacherName,managerId:ue.managerId||U.classMetadata?.managerId,managerName:ue.managerName||U.classMetadata?.managerName});return{...U,name:Be.className||U.name,classSectionId:Be.classSectionId||U.classSectionId,classMetadata:Be,gradeLevel:Be.gradeLevel||U.gradeLevel,classification:Be.classification||U.classification,strand:Be.strand||U.strand,managerId:Be.managerId||U.managerId,managerName:Be.managerName||U.managerName}});const Y=new Map,ge=new Map;De.forEach(U=>{const ue=lt({metadata:U.classMetadata,classSectionId:U.classSectionId,className:U.name,grade:U.grade,gradeLevel:U.gradeLevel,classification:U.classification,strand:U.strand,section:U.section,schoolYear:U.schoolYear,ownerTeacherId:U.ownerTeacherId||U.teacherId,ownerTeacherName:U.ownerTeacherName,adviserTeacherId:U.adviserTeacherId||U.teacherId,adviserTeacherName:U.adviserTeacherName,managerId:U.managerId,managerName:U.managerName});Y.set(U.id,ue.className||U.name),ge.set(U.id,ue);const Be=rt(U.classSectionId);if(Be){const Te=I.get(Be),tt=lt({metadata:ue,classSectionId:Te?.classSectionId||Be,className:Te?.className||ue.className,grade:Te?.grade||ue.grade,gradeLevel:Te?.gradeLevel||ue.gradeLevel,classification:Te?.classification||ue.classification,strand:Te?.strand||ue.strand,section:Te?.section||ue.section,schoolYear:Te?.schoolYear||ue.schoolYear,ownerTeacherId:Te?.ownerTeacherId||ue.ownerTeacherId,ownerTeacherName:Te?.ownerTeacherName||ue.ownerTeacherName,managerId:Te?.managerId||ue.managerId,managerName:Te?.managerName||ue.managerName});Y.set(Be,tt.className||U.name),ge.set(Be,tt)}});const Je=(await Ar(E)).map(U=>{const ue=rt(U.classSectionId||U.classroomId),Be=Y.get(U.classroomId)||(ue?Y.get(ue):void 0)||U.className||"Unknown",Te=Pu(U,Be);if(!ue)return Te;const tt=ge.get(ue);if(!tt)return Te;const xt=lt({metadata:tt,classSectionId:Te.classSectionId||tt.classSectionId,className:Te.className||tt.className,grade:Te.grade||tt.grade,gradeLevel:Te.gradeLevel||tt.gradeLevel,classification:Te.classification||tt.classification,strand:Te.strand||tt.strand,section:Te.section||tt.section,managerId:Te.managerId||tt.managerId,managerName:Te.managerName||tt.managerName});return{...Te,className:xt.className||Te.className,grade:xt.grade||Te.grade,gradeLevel:xt.gradeLevel||Te.gradeLevel,classification:xt.classification||Te.classification,strand:xt.strand||Te.strand,section:xt.section||Te.section,classSectionId:xt.classSectionId||Te.classSectionId,classMetadata:xt,managerId:xt.managerId||Te.managerId,managerName:xt.managerName||Te.managerName}});if(!W)return;B(U=>fe.length===0&&U.length>0?U:fe),b(U=>Je.length===0&&U.length>0?U:Je),Ve.getImportedClassOverview({limit:3e3,forceRefresh:ne>0}).then(U=>{W&&(U.warnings.length>0&&console.warn("Imported class overview warnings:",U.warnings.join(" ")),B(ue=>lo(ue,U.classrooms.map(_u))),b(ue=>co(ue,U.students.map(Hu))))}).catch(U=>{console.warn("Imported class overview merge unavailable:",U)});const Xe=De.map(U=>U.id);Xe.length>0&&(je=Jd(Xe,U=>{W&&z(U.map(ue=>({id:ue.id,student:ue.studentName,action:ue.action,topic:ue.topic,time:kl(ue.timestamp.toDate()),type:ue.type})))}))}catch(De){console.error("Failed to load teacher data:",De),ce.error("Failed to load dashboard data")}finally{H(!1)}})(),()=>{W=!1,je&&je()}},[r,ne]),p.useEffect(()=>{if(!r)return;let E=!0;return Xd("",80).then(W=>{E&&J(W)}).catch(W=>{console.warn("Failed to load teacher directory options:",W)}),()=>{E=!1}},[r]),p.useEffect(()=>{if(g.length===0)return;(async()=>{re(!0);try{const W=g.map(pe=>({name:pe.name,engagementScore:pe.engagementScore,avgQuizScore:pe.avgScore,attendance:pe.attendance,riskLevel:pe.riskLevel})),je=await Ve.getDailyInsight({students:W});Z(je.insight)}catch{Z(`${g.filter(W=>W.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{re(!1)}})()},[g]);const C=j.reduce((E,W)=>E+W.studentCount,0),K=j.reduce((E,W)=>E+W.atRiskCount,0),P=j.length>0?Math.round(j.reduce((E,W)=>E+W.avgScore,0)/j.length):0,xe=[{name:"High Risk",value:g.filter(E=>E.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:g.filter(E=>E.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:g.filter(E=>E.riskLevel==="low").length,color:"#75D06A"}],M={};g.forEach(E=>{E.weakestTopic&&E.weakestTopic!=="N/A"&&(M[E.weakestTopic]||(M[E.weakestTopic]={total:0,sum:0}),M[E.weakestTopic].total+=1,M[E.weakestTopic].sum+=E.avgScore)});const G=Object.entries(M).map(([E,W])=>({topic:E,score:Math.round(W.sum/W.total)})).sort((E,W)=>E.score-W.score).slice(0,6),X=E=>{v(E),l("analytics")},le=E=>{R(E),l("intervention")},ie=()=>{R(null),l("analytics")},V=()=>{v(null),R(null),l("dashboard")},we=async(E,W)=>{if(!r){ce.error("Unable to assign manager: teacher context is missing.");return}const je=Dt(E.classMetadata?.className||E.name),pe=lt({metadata:E.classMetadata,classSectionId:E.classSectionId,className:E.name,grade:E.classMetadata?.grade||je.grade,gradeLevel:E.classMetadata?.gradeLevel,classification:E.classMetadata?.classification,strand:E.classMetadata?.strand,section:E.classMetadata?.section||je.section,schoolYear:E.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:E.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:E.classMetadata?.ownerTeacherName||Pe,adviserTeacherId:E.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:E.classMetadata?.adviserTeacherName||Pe,managerId:W.uid,managerName:W.name}),De=pe.classSectionId||It(pe.grade||je.grade,pe.section||je.section);if(!De){ce.error("Unable to assign manager: missing class section ID.");return}Ce(!0);try{await Yd({classSectionId:De,className:pe.className||E.name,grade:pe.grade||je.grade,gradeLevel:pe.gradeLevel||ds(pe.grade||je.grade)||pe.grade||je.grade,classification:pe.classification||ws(pe.gradeLevel||pe.grade)||void 0,strand:pe.strand||Ss(pe.className,pe.section)||void 0,section:pe.section||je.section,schoolYear:pe.schoolYear||String(new Date().getFullYear()),ownerTeacherId:pe.ownerTeacherId||r.uid,ownerTeacherName:pe.ownerTeacherName||Pe,managerId:W.uid,managerName:W.name});const fe=lt({metadata:pe,classSectionId:De,managerId:W.uid,managerName:W.name}),Me=rt(De);B(I=>I.map(Y=>rt(Y.classSectionId)!==Me?Y:{...Y,name:fe.className||Y.name,classSectionId:fe.classSectionId||Y.classSectionId,classMetadata:fe,gradeLevel:fe.gradeLevel||Y.gradeLevel,classification:fe.classification||Y.classification,strand:fe.strand||Y.strand,managerId:W.uid,managerName:W.name})),b(I=>I.map(Y=>{if(rt(Y.classSectionId||Y.classroomId)!==Me)return Y;const He=lt({metadata:Y.classMetadata,classSectionId:fe.classSectionId||Y.classSectionId,className:Y.className||fe.className,grade:Y.grade||fe.grade,gradeLevel:Y.gradeLevel||fe.gradeLevel,classification:Y.classification||fe.classification,strand:Y.strand||fe.strand,section:Y.section||fe.section,managerId:W.uid,managerName:W.name});return{...Y,classMetadata:He,gradeLevel:He.gradeLevel||Y.gradeLevel,classification:He.classification||Y.classification,strand:He.strand||Y.strand,managerId:W.uid,managerName:W.name}})),v(I=>!I||rt(I.classSectionId)!==Me?I:{...I,classMetadata:fe,managerId:W.uid,managerName:W.name,gradeLevel:fe.gradeLevel||I.gradeLevel,classification:fe.classification||I.classification,strand:fe.strand||I.strand}),ce.success(`Assigned ${W.name} as section manager.`)}catch(fe){console.error("Failed to assign class manager:",fe),ce.error(fe instanceof Error?fe.message:"Failed to assign class manager")}finally{Ce(!1)}};p.useEffect(()=>{const E=()=>{const W=window.innerWidth<1024;w(W),W?c(!1):m(!1)};return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]),p.useEffect(()=>{h&&m(!1)},[o,h]);const Pe=n?.name||"Teacher",ke=p.useMemo(()=>{if(!f)return;if(f.classMetadata?.classSectionId)return f.classMetadata.classSectionId||void 0;if(f.classSectionId)return f.classSectionId;const E=Dt(f.classMetadata?.className||f.name);return It(E.grade,E.section)||void 0},[f]),O=p.useMemo(()=>f||j[0]||null,[f,j]),q=p.useMemo(()=>{if(!O)return g;const E=(O.id||"").trim().toLowerCase(),W=rt(O.classSectionId),je=(O.name||"").trim().toLowerCase();return g.filter(pe=>{const De=rt(pe.classroomId),fe=rt(pe.classSectionId),Me=(pe.className||"").trim().toLowerCase();return W&&(fe===W||De===W)||E&&(De===E||fe===E)||je&&Me===je})},[O,g]);return ae?e.jsxs("div",{className:"flex h-screen w-full bg-background p-6",children:[e.jsx("div",{className:"hidden lg:flex w-[280px] shrink-0 rounded-3xl border border-border bg-card p-5",children:e.jsxs("div",{className:"w-full space-y-4",children:[e.jsx(he,{className:"h-12 w-40"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"})]})}),e.jsxs("div",{className:"flex-1 space-y-4 lg:pl-6",children:[e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(he,{className:"h-28 w-full rounded-2xl"}),e.jsx(he,{className:"h-28 w-full rounded-2xl"}),e.jsx(he,{className:"h-28 w-full rounded-2xl"})]}),e.jsx(he,{className:"h-[420px] w-full rounded-2xl"})]})]}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[h&&N&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>m(!1)}),e.jsxs(Re.aside,{initial:!1,animate:{width:h?280:i&&!d?80:280,x:h?N?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!h&&i&&u(!0),onMouseLeave:()=>u(!1),className:"fixed inset-y-0 left-0 z-40 bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] flex flex-col shadow-sm lg:static lg:z-auto p-5",children:[e.jsxs("div",{className:`mb-8 flex items-center ${i&&!d?"justify-center":"justify-between"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-[#7274ED] to-[#9956DE] rounded-2xl flex items-center justify-center shadow-md flex-shrink-0",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"MathPulse AI",className:"w-10 h-10 object-contain drop-shadow-md"})}),(!i||d)&&e.jsx("div",{children:e.jsx("h1",{className:"text-base font-bold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),!h&&(!i||d)&&e.jsx(Re.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>c(!i),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":i?"Expand sidebar":"Collapse sidebar",children:i?e.jsx(Wt,{size:20}):e.jsx(Pt,{size:20})}),h&&e.jsx("button",{onClick:()=>m(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(va,{size:20})})]}),e.jsxs("nav",{className:"flex-1 space-y-5",children:[e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Overview"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:ci,label:"Dashboard",active:o==="dashboard",collapsed:i&&!d,onClick:V,forceExpanded:h}),e.jsx(At,{icon:Hs,label:"Class Analytics",active:o==="analytics",collapsed:i&&!d,onClick:()=>l("analytics"),forceExpanded:h})]})]}),e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Students"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:Zl,label:"Topic Mastery",active:o==="topic_mastery",collapsed:i&&!d,onClick:()=>l("topic_mastery"),forceExpanded:h}),e.jsx(At,{icon:Ps,label:"Competency",active:o==="competency",collapsed:i&&!d,onClick:()=>l("competency"),forceExpanded:h}),e.jsx(At,{icon:Gt,label:"At-Risk Monitor",active:o==="at_risk",collapsed:i&&!d,onClick:()=>l("at_risk"),forceExpanded:h})]})]}),e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Tools"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:Mi,label:"Data Import",active:o==="import",collapsed:i&&!d,onClick:()=>l("import"),forceExpanded:h}),e.jsx(At,{icon:To,label:"AI Quiz Maker",active:o==="quiz_maker",collapsed:i&&!d,onClick:()=>l("quiz_maker"),forceExpanded:h}),e.jsx(At,{icon:Vt,label:"Question Bank",active:o==="question_bank",collapsed:i&&!d,onClick:()=>l("question_bank"),forceExpanded:h}),e.jsx(At,{icon:ua,label:"Notifications",active:o==="notifications",collapsed:i&&!d,onClick:()=>l("notifications"),forceExpanded:h}),e.jsx(At,{icon:ei,label:"Calendar",active:o==="calendar",collapsed:i&&!d,onClick:()=>l("calendar"),forceExpanded:h})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t border-[#dde3eb] pt-4",children:[e.jsxs(Re.button,{whileHover:{x:2},whileTap:{scale:.98},className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl text-[#5a6578] font-bold border border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628] transition-all duration-200 whitespace-nowrap ${i&&!d?"justify-center":""}`,onClick:a,title:i&&!d?"Settings":"",children:[e.jsx(di,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!i||d)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]}),e.jsx("div",{className:"text-[#5a6578]",children:e.jsx(mi,{onClick:()=>y(!0),collapsed:i&&!d})})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-card/80 backdrop-blur-md border-b border-border px-6 py-3 sticky top-0 z-30",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[h&&e.jsx("button",{onClick:()=>m(!0),className:"mt-1 p-2 rounded-lg border border-border text-muted-foreground hover:text-[#9956DE] hover:border-[#9956DE]/30 hover:bg-[#9956DE]/12 transition-colors","aria-label":"Open navigation",children:e.jsx(ti,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-display font-bold text-foreground leading-tight",children:[o==="dashboard"&&"Teacher Dashboard",o==="analytics"&&(f?f.name:"Class Analytics"),o==="intervention"&&"Student Intervention",o==="topic_mastery"&&"Topic Mastery",o==="competency"&&"Student Competency",o==="import"&&"Data Import",o==="notifications"&&"Notifications",o==="calendar"&&"Calendar",o==="quiz_maker"&&"AI Quiz Maker",o==="question_bank"&&"Question Bank",o==="at_risk"&&"At-Risk Monitoring"]}),e.jsxs("p",{className:"text-xs text-muted-foreground font-body",children:[o==="dashboard"&&`Welcome back, ${Pe}`,o==="analytics"&&"Deep dive into class performance",o==="intervention"&&S?.name,o==="topic_mastery"&&"Monitor class-wide topic mastery",o==="competency"&&"Per-student topic-level breakdown",o==="import"&&"Upload class records and materials",o==="quiz_maker"&&"Create and manage AI-powered quizzes",o==="question_bank"&&"Manage RAG-powered quiz question bank",o==="notifications"&&"View classroom alerts and updates",o==="calendar"&&"Check upcoming class events and schedule",o==="at_risk"&&"Track student risk using the Weighted Risk Index (WRI)"]})]}),o==="dashboard"&&e.jsxs("div",{className:"hidden xl:flex items-center gap-2 ml-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg",children:[e.jsx(Ps,{size:13,className:"text-[#9956DE]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#9956DE]",children:[C," students"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#F08386]/12 border border-[#F08386]/30 rounded-lg",children:[e.jsx(Gt,{size:13,className:"text-[#F08386]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#C65E63]",children:[K," at risk"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#75D06A]/14 border border-[#75D06A]/35 rounded-lg",children:[e.jsx(ka,{size:13,className:"text-[#75D06A]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#4D9F46]",children:[P,"% avg"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{onClick:s,className:"flex items-center gap-2.5 bg-muted p-1.5 pr-3 rounded-lg cursor-pointer hover:bg-accent transition-all group max-w-[220px]",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden ring-1 ring-[#9956DE]/45 bg-card flex items-center justify-center",children:e.jsx(si,{src:n?.photo,name:Pe,gender:n?.gender,className:"w-full h-full rounded-lg"})}),e.jsxs("div",{className:"hidden md:block min-w-0 text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-none group-hover:text-[#9956DE] transition-colors truncate",children:Pe}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-none",children:"Teacher"})]})]})})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto",children:e.jsxs(Qt,{mode:"wait",children:[o==="dashboard"&&e.jsx(Vu,{classes:j,liveActivity:T,onViewClass:X,onViewAllClasses:()=>l("analytics"),onViewActivityStudent:E=>{const W=g.find(je=>je.name===E);W&&le(W)},dailyInsight:$,insightLoading:ee,totalStudents:C,totalAtRisk:K,avgPerformance:P}),o==="analytics"&&O&&e.jsx(Yu,{selectedClass:O,students:q,riskDistribution:xe,topicPerformance:G,onViewStudent:le,onBack:V,teacherOptions:te,managerUpdating:me,onAssignManager:E=>we(O,E)}),o==="analytics"&&!O&&e.jsx(Wu,{icon:Hs,title:"Class Analytics",description:"No classes available yet. Import class records to unlock analytics views."}),o==="intervention"&&S&&e.jsx(Ku,{student:S,teacherId:r?.uid||"",teacherName:Pe,initialCache:F.current.get(S.id),onCacheUpdate:(E,W)=>F.current.set(E,W),onStudentUpdated:E=>{const W=S?Ns(S):null;R(E),b(je=>je.map(pe=>{const De=Ns(pe),fe=W?De===W:!1,Me=pe.id===E.id&&rt(pe.classSectionId)===rt(E.classSectionId);return fe||Me?E:pe}))},onBack:ie}),o==="topic_mastery"&&e.jsx(pm,{classSectionId:ke}),o==="competency"&&e.jsx(Nm,{classSectionId:ke,className:f?.name,fallbackStudents:g}),o==="at_risk"&&e.jsx("div",{className:"flex-1 overflow-auto min-h-0",children:e.jsx($u,{})}),o==="import"&&e.jsx(Xu,{onEditRecords:()=>l("edit_records"),classSectionId:ke,className:f?.name,classMetadata:f?.classMetadata,onImportedClassRecords:E=>{const W=E.students.map(Y=>Qu(Y,E.classSectionId,E.className,E.classMetadata)),je=lt({metadata:E.classMetadata,classSectionId:E.classSectionId,className:E.className}),pe=je.classSectionId||"imported_class",De=je.className||"Imported Class",fe=W.filter(Y=>Y.riskLevel==="high").length,Me=W.length>0?Math.round(W.reduce((Y,ge)=>Y+ge.avgScore,0)/W.length):0,I={id:pe,name:De,classSectionId:pe,classMetadata:{...je,classSectionId:pe,className:De},schedule:"Mon-Fri",studentCount:W.length,avgScore:Me,atRiskCount:fe,riskLevel:fe>=5?"high":fe>=2?"medium":"low"};b(Y=>co(Y,W)),B(Y=>lo(Y,[I]))},onDataChanged:()=>D(E=>E+1)}),o==="notifications"&&e.jsx(ym,{liveActivity:T,atRiskStudents:g.filter(E=>E.riskLevel==="high").map(E=>({name:E.name,riskLevel:E.riskLevel,weakestTopic:E.weakestTopic}))}),o==="calendar"&&e.jsx(Lm,{classes:j,teacherId:r?.uid}),o==="edit_records"&&e.jsx(Ju,{students:g,teacherId:r?.uid||"",teacherName:Pe,onBack:()=>l("import")}),o==="quiz_maker"&&e.jsx(mm,{onBack:()=>l("dashboard")}),o==="question_bank"&&e.jsx(um,{})]})})]}),e.jsx(li,{isOpen:k,onClose:()=>y(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"})]})},At=({icon:t,label:s,active:a,collapsed:r,forceExpanded:n=!1,onClick:o})=>e.jsxs(Re.button,{onClick:o,whileHover:{x:2},whileTap:{scale:.98},className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl cursor-pointer transition-all duration-200 border whitespace-nowrap ${r&&!n?"justify-center":""} ${a?"bg-[#9956DE]/12 border-[#9956DE]/30 shadow-sm text-[#9956DE]":"bg-transparent border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]"}`,children:[e.jsx(t,{size:18,strokeWidth:a?2.5:2,className:"flex-shrink-0"}),(!r||n)&&e.jsx("span",{className:"font-body font-bold text-xs",children:s}),a&&!r&&e.jsx(Re.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-[#9956DE]",transition:{type:"spring",duration:.4}})]}),Wu=({icon:t,title:s,description:a})=>e.jsx(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-8 shadow-sm max-w-2xl",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#9956DE]/20 text-[#9956DE] flex items-center justify-center mb-4",children:e.jsx(t,{size:24})}),e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground mb-2",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed",children:a})]})}),Vu=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:n,dailyInsight:o,insightLoading:l,totalStudents:i,totalAtRisk:c,avgPerformance:d})=>{const u=i>0?Math.round(c/i*100):0,N=i>0?Math.round((i-c)/i*100):0;return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-r from-[#7274ED] to-[#9956DE] rounded-2xl p-5 text-white shadow-md",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-card/20 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Gt,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-display font-bold mb-1",children:"AI Insight"}),e.jsx(pa,{name:"teacher-dashboard-ai-insight",loading:l,fixture:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-11/12 bg-white/25"}),e.jsx(he,{className:"h-3.5 w-10/12 bg-white/20"}),e.jsx(he,{className:"h-3.5 w-8/12 bg-white/15"})]}),fallback:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-11/12 bg-white/25"}),e.jsx(he,{className:"h-3.5 w-10/12 bg-white/20"}),e.jsx(he,{className:"h-3.5 w-8/12 bg-white/15"})]}),children:e.jsx("div",{children:e.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"text-[#F1E4FF] text-sm leading-relaxed [&_p]:m-0 [&_strong]:font-semibold",children:e.jsx(wo,{children:o||`${c} students (${u}%) are at high risk of falling behind`})})})})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Total Students"}),e.jsx("p",{className:"text-2xl font-display font-bold text-foreground",children:i})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Class Average"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[d,"%"]})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Engagement Rate"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#75D06A]",children:[N,"%"]})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-[#FF8B8B]/35 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"At Risk"}),e.jsx("p",{className:"text-2xl font-display font-bold text-[#FF8B8B]",children:c})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"My Classes"}),e.jsxs("button",{onClick:r,className:"text-sm font-bold text-[#9956DE] hover:text-[#9956DE] flex items-center gap-1 group",children:["View All",e.jsx(Wt,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]}),e.jsx("div",{className:"space-y-4",children:t.map(m=>e.jsxs(Re.div,{whileHover:{scale:1.01},className:"bg-card border border-border rounded-2xl p-6 shadow-sm hover:shadow-md transition-all cursor-pointer",onClick:()=>a(m),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-foreground",children:m.name}),e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold border ${Ra(m.riskLevel)}`,children:m.riskLevel==="high"?"High Risk":m.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(So,{size:14}),e.jsx("span",{children:m.schedule})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:[m.gradeLevel,m.classification,m.strand].filter(Boolean).map(h=>e.jsx("span",{className:"px-2 py-0.5 rounded-md bg-[#9956DE]/12 border border-[#9956DE]/30 text-[#9956DE] text-[11px] font-semibold",children:h},`${m.id}-${h}`))}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Manager: ",m.managerName||m.classMetadata?.managerName||"Not assigned"]})]}),e.jsx($e,{className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold px-6 py-2 rounded-xl",children:"View Class"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Total Students"}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:m.studentCount})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"At Risk"}),e.jsx("p",{className:"text-xl font-bold text-[#FF8B8B]",children:m.atRiskCount})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-xl font-bold text-[#9956DE]",children:[m.avgScore,"%"]})]})]})]},m.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 bg-[#F08386]/20 rounded-xl flex items-center justify-center",children:e.jsx($s,{size:20,className:"text-[#F08386]"})}),e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"Live Classroom Pulse"})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-5 shadow-sm border border-border space-y-3 max-h-[600px] overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No live classroom events yet. Activity appears here in real time."}),s.map(m=>e.jsxs("div",{onClick:()=>n?.(m.student),className:`p-4 rounded-xl border-l-4 cursor-pointer hover:shadow-md transition-shadow ${m.type==="success"?"bg-[#75D06A]/14 border-[#75D06A]":m.type==="warning"?"bg-[#F08386]/12 border-[#F08386]":"bg-[#9956DE]/12 border-[#9956DE]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("p",{className:"font-bold text-foreground text-sm",children:m.student}),e.jsx("span",{className:"text-xs text-slate-500",children:m.time})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m.action," ",e.jsx("span",{className:"font-bold text-foreground",children:m.topic})]})]},m.id))]})]})]})]})},qu=oe.memo(({student:t,onViewStudent:s})=>e.jsxs(Re.div,{whileHover:{scale:1.02},onClick:()=>s(t),className:`p-4 rounded-2xl border-2 cursor-pointer hover:shadow-md transition-all ${Zu(t.riskLevel)}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-12 h-12 rounded-xl object-cover border-2 border-current"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-bold text-foreground",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.lastActive})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground",children:"Avg Score"}),e.jsxs("span",{className:"text-xs font-bold text-foreground",children:[t.avgScore,"%"]})]}),e.jsx("div",{className:"h-2 bg-card rounded-full overflow-hidden e-w",style:{"--w":`${t.avgScore}%`},children:e.jsx("div",{className:`h-full rounded-full ${t.riskLevel==="high"?"bg-[#FF8B8B]":t.riskLevel==="medium"?"bg-[#F08386]":"bg-[#75D06A]"}`})})]})]})),Yu=({selectedClass:t,students:s,riskDistribution:a,topicPerformance:r,onViewStudent:n,onBack:o,teacherOptions:l,managerUpdating:i,onAssignManager:c})=>{const[d,u]=p.useState(""),[N,m]=p.useState(""),[h,w]=p.useState([]);p.useEffect(()=>{m(t.classMetadata?.managerId||t.managerId||"")},[t]),p.useEffect(()=>{let b;return(async()=>{const{collection:T,query:z,where:$,onSnapshot:Z}=await ba(async()=>{const{collection:ee,query:re,where:ne,onSnapshot:D}=await import("./vendor-firebase-firestore-CH1lNiRF.js");return{collection:ee,query:re,where:ne,onSnapshot:D}},__vite__mapDeps([0,1])),{db:ae}=await ba(async()=>{const{db:ee}=await import("./index-Cb8VeSuW.js").then(re=>re.aU);return{db:ee}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11])),H=z(T(ae,"modules"),$("moduleType","==","teacher_uploaded"));b=Z(H,ee=>{const re=ee.docs.map(ne=>({id:ne.id,...ne.data()}));w(re)})})(),()=>{b?.()}},[]);const k=p.useMemo(()=>{const b=t.classMetadata?.classification||t.classification||"";return!b||h.length===0?[]:h.filter(T=>{const z=T.subject||"";return z.toLowerCase().includes(b.toLowerCase())||b.toLowerCase().includes(z.toLowerCase())}).slice(0,5)},[h,t]),y=p.useMemo(()=>{const b=d.trim().toLowerCase();return b?s.filter(T=>T.name.toLowerCase().includes(b)||(T.lrn||"").toLowerCase().includes(b)||(T.weakestTopic||"").toLowerCase().includes(b)):s},[d,s]),f=p.useMemo(()=>{if(s.length===0)return 0;const b=s.reduce((T,z)=>T+(z.assignmentCompletion||0),0);return Math.round(b/s.length)},[s]),v=p.useMemo(()=>{if(s.length===0)return 0;const b=s.reduce((z,$)=>z+($.attendance||0),0)/s.length,T=s.reduce((z,$)=>z+($.engagementScore||0),0)/s.length;return Math.round(b*.6+T*.4)},[s]),S=p.useMemo(()=>[...s].sort((b,T)=>T.avgScore-b.avgScore).slice(0,5),[s]),R=p.useMemo(()=>[...s].filter(b=>b.riskLevel==="high"||b.avgScore<70||b.assignmentCompletion<65).sort((b,T)=>{if(b.riskLevel!==T.riskLevel){const z={high:3,medium:2,low:1};return z[T.riskLevel]-z[b.riskLevel]}return b.avgScore-T.avgScore}).slice(0,6),[s]),j=p.useMemo(()=>l.find(b=>b.uid===N),[l,N]),B=()=>{if(!j){ce.error("Select a teacher manager first.");return}c(j)},g=[t.classMetadata?.gradeLevel||t.gradeLevel,t.classMetadata?.classification||t.classification,t.classMetadata?.strand||t.strand].filter(Boolean);return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-2 text-muted-foreground hover:text-[#9956DE] font-bold mb-6 transition-colors group",children:[e.jsx(Pt,{size:20,className:"group-hover:-translate-x-1 transition-transform"}),"Back to Dashboard"]}),e.jsx("div",{className:"bg-card rounded-2xl border border-border p-5 shadow-sm mb-6",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:t.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold border ${Ra(t.riskLevel)}`,children:t.riskLevel==="high"?"High Risk Cohort":t.riskLevel==="medium"?"Medium Risk Cohort":"Low Risk Cohort"}),g.map(b=>e.jsx("span",{className:"px-3 py-1 rounded-lg text-xs font-semibold border bg-[#9956DE]/12 border-[#9956DE]/30 text-[#9956DE]",children:b},b))]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Manager: ",t.classMetadata?.managerName||t.managerName||"Not assigned"]})]}),e.jsxs("div",{className:"min-w-[260px] bg-muted rounded-xl p-3 border border-border",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2 uppercase tracking-wide",children:"Section Manager"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{id:"analytics-section-manager-select",name:"analytics-section-manager-select","aria-label":"Select section manager",value:N||"",onChange:b=>m(b.target.value),className:"h-10 flex-1 rounded-lg border border-border bg-card px-3 text-sm focus:outline-none focus:ring-2 focus:ring-[#9956DE]/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select teacher"}),l.map(b=>e.jsxs("option",{value:b.uid,children:[b.name," (",b.email,")"]},b.uid))]}),e.jsx($e,{onClick:B,disabled:!N||i,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white",children:i?e.jsx(he,{className:"h-4 w-12 bg-white/35"}):"Assign"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Class Average"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Completion Rate"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#75D06A]",children:[f,"%"]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Participation"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[v,"%"]})]}),e.jsxs("div",{className:"bg-card border border-[#FF8B8B]/35 rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Needs Attention"}),e.jsx("p",{className:"text-2xl font-display font-bold text-[#FF8B8B]",children:R.length})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("h2",{className:"text-lg font-display font-bold text-foreground",children:["Students (",y.length,")"]}),e.jsxs("div",{className:"relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400",size:16}),e.jsx(vt,{id:"analytics-student-search",name:"analytics-student-search","aria-label":"Search students",type:"text",placeholder:"Search...",value:d,onChange:b=>u(b.target.value),className:"w-40 pl-9 pr-4 py-2 rounded-xl border-border text-sm"})]})]}),y.length===0?e.jsx("div",{className:"border border-dashed border-border rounded-xl p-4 text-sm text-muted-foreground",children:"No students match your search."}):e.jsx(Sd,{style:{height:"700px"},data:y,itemContent:(b,T)=>e.jsx(qu,{student:T,onViewStudent:n}),computeItemKey:(b,T)=>Ns(T)})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground mb-5",children:"Risk Distribution"}),e.jsx(sr,{width:"100%",height:250,children:e.jsxs(on,{data:a,children:[e.jsx(ln,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(cn,{dataKey:"name",tick:{fontSize:12}}),e.jsx(ar,{tick:{fontSize:12}}),e.jsx(rr,{}),e.jsx(dn,{dataKey:"value",radius:[8,8,0,0],children:a.map((b,T)=>e.jsx(Gi,{fill:b.color},`cell-${T}`))})]})})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground mb-5",children:"Topic Performance"}),e.jsx(sr,{width:"100%",height:250,children:e.jsxs(on,{data:r,children:[e.jsx(ln,{strokeDasharray:"3 3",stroke:"var(--border)"}),e.jsx(cn,{dataKey:"topic",tick:{fontSize:12}}),e.jsx(ar,{tick:{fontSize:12},domain:[0,100]}),e.jsx(rr,{}),e.jsx(dn,{dataKey:"score",fill:"#9956DE",radius:[8,8,0,0]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[e.jsx("h3",{className:"text-sm font-display font-bold text-foreground mb-3",children:"Top Performers"}),e.jsxs("div",{className:"space-y-2",children:[S.slice(0,4).map(b=>e.jsxs("button",{onClick:()=>n(b),className:"w-full flex items-center justify-between rounded-lg border border-border px-3 py-2 hover:bg-[#9956DE]/12 transition-colors",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:b.name}),e.jsxs("span",{className:"text-xs font-bold text-[#75D06A]",children:[b.avgScore,"%"]})]},`top-${Ns(b)}`)),S.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No students available yet."})]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[e.jsx("h3",{className:"text-sm font-display font-bold text-foreground mb-3",children:"Students Needing Attention"}),e.jsxs("div",{className:"space-y-2",children:[R.slice(0,4).map(b=>e.jsxs("button",{onClick:()=>n(b),className:"w-full flex items-center justify-between rounded-lg border border-[#FF8B8B]/35 bg-[#FF8B8B]/14 px-3 py-2 hover:bg-[#FF8B8B]/20 transition-colors",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:b.name}),e.jsx("span",{className:"text-xs font-bold text-[#FF8B8B]",children:b.riskLevel.toUpperCase()})]},`attention-${Ns(b)}`)),R.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students in this class right now."})]}),k.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground mb-2 flex items-center gap-1.5",children:[e.jsx(Vt,{size:12}),"Recommended Modules"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:k.map(b=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-[#9956DE]/10 border border-[#9956DE]/20 text-xs font-medium text-[#9956DE]",children:b.title||"Untitled Module"},b.moduleId||b.id))})]})]})]})]})]})]})},Ku=({student:t,teacherId:s,teacherName:a,onStudentUpdated:r,onBack:n,initialCache:o,onCacheUpdate:l})=>{const i=(t.riskLevel||"low").toLowerCase(),c=i==="high"||i==="medium",d=c?{card:"bg-[#FF8B8B]/14 border-[#FF8B8B]/35",icon:"bg-red-600",bullet:"text-[#FF8B8B]"}:{card:"bg-[#9956DE]/12 border-[#9956DE]/30",icon:"bg-[#9956DE]",bullet:"text-[#9956DE]"},u=p.useMemo(()=>Ve.getImportGroundedRolloutFlags(),[]),[N,m]=p.useState(o?.learningPath||""),[h,w]=p.useState(!0),[k,y]=p.useState(o?.gradeDraft||t.grade||"Grade 11"),[f,v]=p.useState(o?.sectionDraft||t.section||"Section A"),[S,R]=p.useState(!1),[j,B]=p.useState(o?.lessonPlan??null),[g,b]=p.useState([]),[T,z]=p.useState(""),[$,Z]=p.useState(!1),[ae,H]=p.useState(""),[ee,re]=p.useState("all"),[ne,D]=p.useState("all"),[te,J]=p.useState(!1),[me,Ce]=p.useState(!1),[F,C]=p.useState(null),[K,P]=p.useState(!1),[xe,M]=p.useState(!1),[G,X]=p.useState(0),[le,ie]=p.useState(null),[V,we]=p.useState(!1),[Pe,ke]=p.useState(!1);p.useEffect(()=>{y(t.grade||"Grade 11"),v(t.section||"Section A")},[t.grade,t.section]),p.useEffect(()=>{l?.(t.id,{lessonPlan:j,learningPath:N,gradeDraft:k,sectionDraft:f})},[j,N,k,f,t.id,l]),p.useEffect(()=>{(async()=>{w(!0);try{let Y="";try{Y=await ai(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),z(Y)}catch{z("")}const ge=await Ve.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),He=Y?`${ge.learningPath} +`);navigator.clipboard.writeText(x),W(!0),setTimeout(()=>W(!1),2e3)},$l=()=>{if(!V)return;const x=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),A=URL.createObjectURL(x),L=document.createElement("a");L.href=A,L.download=`quiz_${N.replace(/\s/g,"_")}_${Date.now()}.json`,L.click(),URL.revokeObjectURL(A)};k.length>0||Object.values(Da).flat().length>0;const qr=(x,A)=>{const L=A?.gradeLevel||N,Ne=A?.topics||k,Ue=x.questions.map((_e,St)=>({id:`q_${Date.now()}_${St}`,questionType:_e.questionType||"identification",question:_e.question,..._e.options?{options:_e.options}:{},correctAnswer:_e.correctAnswer,bloomLevel:_e.bloomLevel||"understand",difficulty:_e.difficulty||"medium",topic:_e.topic,subject:L,points:_e.points,explanation:_e.explanation}));return{title:`${L} Quiz – ${Ne.length>0?Ne.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:L,questions:Ue,totalPoints:x.totalPoints,metadata:{topicsCovered:Object.keys(x.metadata.topicsCovered),difficultyBreakdown:{easy:x.metadata.difficultyBreakdown.easy??0,medium:x.metadata.difficultyBreakdown.medium??0,hard:x.metadata.difficultyBreakdown.hard??0},bloomDistribution:x.metadata.bloomTaxonomyDistribution,questionTypeBreakdown:x.metadata.questionTypeBreakdown,supplementalPurpose:x.metadata.supplementalPurpose,recommendedTeacherActions:x.metadata.recommendedTeacherActions??[],generatedAt:new Date().toISOString(),generatedBy:"teacher_generated"},status:"draft",source:"teacher_generated"}},Yr=p.useCallback(x=>{Cs(A=>[x,...A.filter(L=>L.id!==x.id)])},[]);async function Kr(x,A){if(!n)return null;const L=qr(x,A),Ne=await an(L,n.uid,Be?{documentId:Be}:void 0);return Te(Ne),Yr({id:Ne,...L,teacherId:n.uid}),Ne}const Ol=async()=>{if(!V){ce.error("No quiz to save. Generate a quiz first.");return}if(!n){ce.error("You must be signed in to save quizzes.");return}ue(!0);try{const x=qr(V),A=await an(x,n.uid,Be?{documentId:Be}:void 0);Te(A),Yr({id:A,...x,teacherId:n.uid}),ce.success("Quiz saved to your library!")}catch(x){ce.error(x instanceof Error?x.message:"Failed to save quiz")}finally{ue(!1)}},Pl=async()=>{if(Be){xt(!0);try{await wi(Be),Cs(x=>x.map(A=>A.id===Be?{...A,status:"published"}:A)),ce.success("Quiz published to Quiz Bank!")}catch(x){ce.error(x instanceof Error?x.message:"Failed to publish quiz")}finally{xt(!1)}}},$a=async x=>{const A=x??Be;if(!A){ce.error("Save the quiz first before assigning.");return}if(_r(A),es(!0),$r(null),Br(""),zr.length===0&&n){Fr(!0);try{const L=await Ar(n.uid);Cl(L)}catch{ce.error("Failed to load students")}finally{Fr(!1)}}},_l=async()=>{const x=Rl??Be;if(!(!ts||!x||!n)){aa(!0);try{await Si(x,ts,n.uid),Cs(A=>A.map(L=>L.id===x?{...L,status:"assigned",metadata:{...L.metadata,assignedTo:ts}}:L)),ce.success("Quiz assigned to student!"),es(!1),_r(null),i==="bank"&&Oa()}catch(A){ce.error(A instanceof Error?A.message:"Failed to assign quiz")}finally{aa(!1)}}},Oa=p.useCallback(async()=>{if(n){Pr(!0);try{const x=await Ni(n.uid);Cs(x)}catch{ce.error("Failed to load quiz bank")}finally{Pr(!1)}}},[n]);p.useEffect(()=>{i==="bank"&&Oa()},[i,Oa]);const Hl=async x=>{try{await ji(x),Cs(A=>A.filter(L=>L.id!==x)),ce.success("Quiz deleted")}catch{ce.error("Failed to delete quiz")}},Xr=zr.filter(x=>x.name.toLowerCase().includes(Ma.toLowerCase())||x.email.toLowerCase().includes(Ma.toLowerCase())),Jr=La==="all"?Or:Or.filter(x=>x.status===La),Gl=x=>{const A=(x.metadata.topicsCovered||[]).reduce((L,Ne)=>(L[Ne]=(L[Ne]||0)+1,L),{});return{questions:x.questions.map(L=>({questionType:L.questionType,question:L.question,correctAnswer:L.correctAnswer,options:L.options??null,bloomLevel:L.bloomLevel,difficulty:L.difficulty,topic:L.topic,points:L.points,explanation:L.explanation})),totalPoints:x.totalPoints,metadata:{topicsCovered:A,difficultyBreakdown:x.metadata.difficultyBreakdown,bloomTaxonomyDistribution:x.metadata.bloomDistribution,questionTypeBreakdown:x.metadata.questionTypeBreakdown,gradeLevel:x.gradeLevel,totalQuestions:x.questions.length,includesGraphQuestions:!1,supplementalPurpose:x.metadata.supplementalPurpose,bloomTaxonomyRationale:"Loaded from saved quiz bank entry.",recommendedTeacherActions:x.metadata.recommendedTeacherActions||[]}}},Pa=x=>{Te(x.id),we(Gl(x)),ke(null),ra(x.id),He("all"),Xe("all"),Me(null),u("results"),c("create")},Ql={remember:"bg-sky-100 text-sky-700 border-sky-300",understand:"bg-rose-100 text-rose-700 border-rose-300",apply:"bg-emerald-100 text-emerald-700 border-emerald-300",analyze:"bg-rose-100 text-rose-700 border-rose-300"},Ul=(x,A,L)=>{const Ne=fe===A,Ue=Ql[x.bloomLevel]||"bg-[#edf1f7] text-[#5a6578] border-[#dde3eb]";return e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:A*.05},className:"border border-[#dde3eb] rounded-xl overflow-hidden relative",children:[e.jsx("div",{className:`absolute top-2 right-2 text-[10px] font-bold uppercase px-2 py-0.5 rounded border ${Ue} z-10`,children:x.bloomLevel}),e.jsx("div",{className:"p-4 cursor-pointer hover:bg-[#edf1f7] transition-colors",onClick:()=>Me(Ne?null:A),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-bold text-white bg-sky-600 px-2 py-0.5 rounded",children:["Q",A+1]}),e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded border ${Va[x.bloomLevel]?.color||"bg-[#edf1f7] text-[#5a6578]"}`,children:x.bloomLevel}),e.jsx("span",{className:`text-xs font-medium ${On[x.difficulty]||"text-[#5a6578]"}`,children:x.difficulty}),e.jsxs("span",{className:"text-xs text-slate-500",children:[x.points," pts"]}),e.jsx("span",{className:"text-xs bg-[#edf1f7] text-[#5a6578] px-2 py-0.5 rounded",children:x.topic})]}),e.jsx("p",{className:"text-sm text-[#0a1628] font-medium",children:x.question})]}),e.jsx("div",{className:"flex-shrink-0 mt-1",children:Ne?e.jsx(Na,{size:16,className:"text-slate-500"}):e.jsx(Ht,{size:16,className:"text-slate-500"})})]})}),e.jsx(Qt,{children:Ne&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-t border-[#dde3eb] overflow-hidden",children:e.jsxs("div",{className:"p-4 space-y-3 bg-[#edf1f7]/50",children:[x.options&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-1",children:"Options:"}),e.jsx("div",{className:"space-y-1",children:x.options.map((_e,St)=>e.jsx("div",{className:`text-sm px-3 py-1.5 rounded-lg ${_e.includes(x.correctAnswer)?"bg-green-100 text-green-800 font-medium":"bg-white text-[#0a1628]"}`,children:_e},St))})]}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-green-700 mb-1",children:"Correct Answer:"}),e.jsx("p",{className:"text-sm text-green-800 font-medium",children:x.correctAnswer})]}),e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-sky-700 mb-1",children:"Explanation:"}),e.jsx("p",{className:"text-sm text-sky-800",children:x.explanation})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-slate-500",children:[e.jsxs("span",{children:["Type: ",ca[x.questionType]?.label||x.questionType]}),e.jsxs("span",{children:["Bloom: ",x.bloomLevel]})]}),x.provenance&&e.jsxs("div",{className:"bg-[#f7fbff] border border-sky-100 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-sky-700 mb-1",children:"Item Provenance"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1 text-xs text-[#5a6578]",children:[x.provenance.title&&e.jsxs("p",{children:["Topic: ",x.provenance.title]}),x.provenance.topicId&&e.jsxs("p",{children:["Topic ID: ",x.provenance.topicId]}),x.provenance.materialId&&e.jsxs("p",{children:["Material ID: ",x.provenance.materialId]}),x.provenance.sourceFile&&e.jsxs("p",{children:["Source File: ",x.provenance.sourceFile]}),x.provenance.sectionId&&e.jsxs("p",{children:["Section ID: ",x.provenance.sectionId]})]})]})]})})})]},A)};return e.jsxs("div",{className:"w-full flex flex-col bg-[#f7f9fc] min-h-screen",children:[e.jsxs("div",{className:"bg-white border-b border-[#dde3eb] px-6 py-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("button",{onClick:Ba,className:"p-2 hover:bg-[#edf1f7] rounded-lg transition-colors text-slate-500",children:e.jsx(Pt,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-[#0a1628]",children:"AI Quiz Maker"}),e.jsx("p",{className:"text-[#5a6578] text-sm mt-1",children:"Generate AI-powered assessments with Bloom's Taxonomy"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>c("create"),className:`flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold transition-colors ${i==="create"?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:[e.jsx(hc,{size:16})," Create Quiz"]}),e.jsxs("button",{onClick:()=>c("bank"),className:`flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-semibold transition-colors ${i==="bank"?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:[e.jsx(mn,{size:16})," Quiz Bank"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 sm:px-8 xl:px-10 py-8",children:[i==="bank"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:["all","draft","published","assigned","completed"].map(x=>e.jsx("button",{onClick:()=>El(x),className:`px-3 py-1.5 rounded-full text-xs font-semibold capitalize transition-colors ${La===x?"bg-sky-100 text-sky-700 border border-sky-300":"bg-[#edf1f7] text-[#5a6578] hover:bg-[#dde3eb]"}`,children:x},x))}),Il?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(nt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):Jr.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(mn,{size:40,className:"mb-3"}),e.jsx("p",{className:"font-medium",children:"No quizzes found"}),e.jsx("p",{className:"text-xs mt-1",children:"Generate your first quiz in the Create tab"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Jr.map(x=>e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>Pa(x),role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),Pa(x))},className:"border border-[#dde3eb] rounded-xl p-4 hover:shadow-md transition-shadow cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] leading-tight",children:x.title}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full capitalize ${lm[x.status]}`,children:x.status})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:x.metadata.topicsCovered.slice(0,3).map(A=>e.jsx("span",{className:"text-[10px] bg-[#edf1f7] text-[#5a6578] px-2 py-0.5 rounded",children:A},A))}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#5a6578] mb-3",children:[e.jsxs("span",{children:[x.questions.length," questions"]}),e.jsxs("span",{children:[x.totalPoints," pts"]}),e.jsx("span",{children:x.gradeLevel})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:A=>{A.stopPropagation(),Pa(x)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-[#edf1f7] text-[#5a6578] rounded-lg hover:bg-[#dde3eb] transition-colors",children:[e.jsx(pr,{size:12})," View"]}),e.jsxs("button",{onClick:A=>{A.stopPropagation(),$a(x.id)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-sky-50 text-sky-700 rounded-lg hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:12})," Assign"]}),e.jsxs("button",{onClick:A=>{A.stopPropagation(),Hl(x.id)},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-semibold bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition-colors",children:[e.jsx(No,{size:12})," Delete"]})]})]},x.id))})]}),i==="create"&&e.jsxs(e.Fragment,{children:[O&&e.jsxs(Re.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"mb-4 bg-red-50 border border-red-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(Ca,{size:18,className:"text-red-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-red-800 font-medium",children:"Error"}),e.jsx("p",{className:"text-sm text-red-600",children:O})]}),e.jsx("button",{onClick:()=>q(""),className:"ml-auto",children:e.jsx(va,{size:14,className:"text-red-400"})})]}),me&&e.jsxs(Re.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-4 bg-white border border-sky-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nt,{size:16,className:"animate-spin text-sky-600"}),e.jsx("p",{className:"text-sm font-semibold text-[#0a1628]",children:"Generating Quiz in Background"})]}),e.jsxs("span",{className:"text-xs font-bold text-sky-700",children:[xe,"%"]})]}),e.jsx("div",{className:"h-2 bg-[#edf1f7] rounded-full overflow-hidden",children:e.jsx(Re.div,{animate:{width:`${xe}%`},transition:{duration:.35,ease:"easeOut"},className:"h-full bg-gradient-to-r from-sky-600 to-cyan-500"})}),e.jsxs("p",{className:"mt-2 text-xs text-[#5a6578] capitalize",children:["Stage: ",G.replace(/_/g," ")]}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:le}),K&&e.jsxs("p",{className:"text-[11px] text-[#7b8798] mt-1",children:["Task ID: ",K]})]}),!me&&d!=="results"&&e.jsx("div",{className:"flex bg-white rounded-xl border border-[#dde3eb] mb-6 overflow-hidden shadow-sm",children:[{id:"setup",label:"Setup"},{id:"topics",label:"Topics"},{id:"style",label:"Question style"},{id:"preview",label:"Preview"}].map((x,A)=>{const Ne=["setup","topics","style","preview"].indexOf(d),Ue=Ne>A,_e=Ne===A;return e.jsxs("div",{className:`flex-1 flex items-center justify-center py-3 border-r last:border-r-0 border-[#dde3eb] ${_e?"bg-purple-50":"bg-white"}`,children:[Ue?e.jsx("div",{className:"w-5 h-5 rounded-full bg-green-500 text-white flex items-center justify-center mr-2",children:e.jsx(gs,{size:12,strokeWidth:3})}):e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-xs font-bold mr-2 ${_e?"bg-[#9b51e0] text-white":"bg-[#edf1f7] text-slate-500"}`,children:A+1}),e.jsx("span",{className:`text-sm font-semibold ${_e?"text-[#9b51e0]":Ue?"text-slate-700":"text-slate-400"}`,children:x.label})]},x.id)})}),d==="setup"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-purple-50 border border-purple-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(tr,{size:18,className:"text-[#9b51e0] flex-shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-purple-800",children:["This quiz maker generates ",e.jsx("span",{className:"font-bold",children:"supplemental assessments"})," to support classroom instruction. Questions follow Bloom's Taxonomy for comprehensive skill evaluation. Generation limit: up to ",Ms," questions and ",xs," topics per quiz."]})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"BASIC SETTINGS"})}),e.jsxs("div",{className:"p-5 grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"quiz-grade-level",className:"text-sm font-semibold text-[#0a1628] mb-2 block",children:"Grade level"}),e.jsx("select",{id:"quiz-grade-level",value:N,onChange:x=>m(qa(x.target.value)),className:"w-full bg-white text-[#0a1628] rounded-lg px-4 py-3 text-sm outline-none border border-[#dde3eb] focus:ring-2 focus:ring-purple-500",children:im.map(x=>e.jsx("option",{value:x,children:x},x))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"quiz-num-questions",className:"text-sm font-semibold text-[#0a1628] mb-2 block",children:"Number of questions"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:()=>w(Math.max(1,h-1)),className:"w-12 h-12 border border-[#dde3eb] rounded-l-lg flex items-center justify-center hover:bg-[#edf1f7] text-[#edf1f7] transition-colors bg-white font-bold text-xl",children:e.jsx("span",{className:"text-[#dde3eb]",children:"-"})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:Ms,value:h,onChange:x=>w(Math.min(Ms,Math.max(1,parseInt(x.target.value)||1))),className:"flex-1 h-12 text-center border-y border-[#dde3eb] px-3 text-base font-bold focus:outline-none bg-white text-[#0a1628]"}),e.jsx("button",{onClick:()=>w(Math.min(Ms,h+1)),className:"w-12 h-12 border border-[#dde3eb] rounded-r-lg flex items-center justify-center hover:bg-[#edf1f7] text-[#edf1f7] transition-colors bg-white font-bold text-xl",children:e.jsx("span",{className:"text-[#dde3eb]",children:"+"})})]})]})]})]})]}),d==="topics"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Select topics"}),e.jsxs("p",{className:"text-sm text-[#5a6578]",children:["Choose up to ",xs," topics across all strands"]})]}),e.jsxs("div",{className:"bg-purple-50 text-[#9b51e0] px-3 py-1 rounded-full text-sm font-bold",children:[k.filter(x=>!f.includes(x)).length," of ",xs," selected"]})]}),ae?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(nt,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries(Da).map(([x,A])=>{const L=A.filter(Ue=>k.includes(Ue)&&!f.includes(Ue)).length,Ne=pe===x;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>De(Ne?null:x),className:"w-full flex items-center justify-between p-4 hover:bg-[#f7f9fc] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-1 h-6 bg-[#9b51e0] rounded-full"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-bold text-[#0a1628] text-sm",children:x}),e.jsxs("p",{className:"text-xs text-slate-500",children:[A.length," topics"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"bg-purple-100 text-[#9b51e0] px-2.5 py-0.5 rounded-full text-xs font-semibold",children:[L," selected"]}),Ne?e.jsx(Na,{size:18,className:"text-slate-400"}):e.jsx(Ht,{size:18,className:"text-slate-400"})]})]}),e.jsx(Qt,{children:Ne&&e.jsx(Re.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},className:"overflow-hidden border-t border-[#edf1f7]",children:e.jsx("div",{className:"py-2",children:A.map((Ue,_e)=>{const St=k.includes(Ue),na=f.includes(Ue),ct=St&&!na;let kt="Core";return _e%3===0&&(kt="Foundation"),_e%3===2&&(kt="Advanced"),e.jsxs("div",{className:"flex items-center justify-between px-6 py-3 hover:bg-[#f7f9fc]",children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("div",{className:`w-5 h-5 rounded flex items-center justify-center transition-colors ${ct?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:ct&&e.jsx(gs,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:ct,onChange:()=>Al(Ue)}),e.jsx("span",{className:`text-sm font-semibold ${ct?"text-[#0a1628]":"text-[#5a6578]"}`,children:Ue})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${kt==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:kt})]},Ue)})})})})]},x)})})]}),d==="style"&&!me&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"QUESTION TYPES"})}),e.jsx("div",{className:"p-5 grid grid-cols-1 md:grid-cols-3 gap-4",children:Object.entries(ca).map(([x,A])=>{const L=S.includes(x);return e.jsxs("button",{onClick:()=>Ml(x),className:`flex flex-col items-center justify-center p-4 rounded-xl border-2 transition-all ${L?"bg-purple-50 border-purple-300":"bg-white border-[#dde3eb] hover:border-purple-200"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center mb-2 ${L?"bg-purple-200 text-[#9b51e0]":"bg-[#edf1f7] text-slate-400"}`,children:A.icon}),e.jsx("span",{className:`text-sm font-semibold ${L?"text-purple-800":"text-[#5a6578]"}`,children:A.label})]},x)})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"BLOOM'S TAXONOMY LEVELS"})}),e.jsx("div",{className:"p-5 flex flex-wrap gap-3",children:Object.entries(Va).map(([x,A])=>{const L=j.includes(x);return e.jsx("button",{onClick:()=>Ll(x),className:`px-5 py-2.5 rounded-full border-2 transition-all text-sm font-semibold capitalize ${L?"bg-white text-[#9b51e0] border-purple-300":"bg-white border-[#dde3eb] text-[#5a6578] hover:border-purple-200"}`,children:x},x)})})]}),e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"DIFFICULTY DISTRIBUTION"})}),e.jsx("div",{className:"p-5 space-y-5",children:Object.entries(T).map(([x,A])=>{const Ne={easy:"bg-[#55b963]",medium:"bg-[#faa541]",hard:"bg-[#f47a75]"}[x];return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-semibold w-16 capitalize text-[#5a6578]",children:x}),e.jsx("div",{className:"flex-1 h-2 bg-[#edf1f7] rounded-full overflow-hidden",children:e.jsx(Re.div,{animate:{width:`${A}%`},className:`h-full rounded-full ${Ne}`})}),e.jsxs("div",{className:"flex items-center gap-1 w-20 justify-end",children:[e.jsx("button",{onClick:()=>Vr(x,-5),className:"w-6 h-6 rounded border border-[#dde3eb] flex items-center justify-center hover:bg-[#edf1f7] text-slate-500",children:e.jsx(jo,{size:10})}),e.jsxs("span",{className:"text-sm font-bold w-10 text-center text-slate-500",children:[A,"%"]}),e.jsx("button",{onClick:()=>Vr(x,5),className:"w-6 h-6 rounded border border-[#dde3eb] flex items-center justify-center hover:bg-[#edf1f7] text-slate-500",children:e.jsx(ma,{size:10})})]})]},x)})})]})]}),d==="preview"&&!me&&!V&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-white border border-[#dde3eb] rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-[#dde3eb]",children:e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"QUIZ SUMMARY"})}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:h}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"questions"})]}),e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:k.filter(x=>!f.includes(x)).length}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"topics"})]}),e.jsxs("div",{className:"bg-purple-50 rounded-xl p-6 text-center border border-purple-100",children:[e.jsx("p",{className:"text-3xl font-bold text-purple-800 mb-1",children:N.replace("Grade ","Gr. ")}),e.jsx("p",{className:"text-sm text-purple-600 font-medium",children:"level"})]})]}),e.jsxs("div",{className:"bg-[#f7f9fc] rounded-lg p-5 border border-[#dde3eb] text-sm text-[#5a6578] leading-relaxed",children:[S.map(x=>ca[x]?.label).join(" and ")," questions across ",k.filter(x=>!f.includes(x)).length," topics — aligned to ",j.map(x=>Va[x]?.label).join(", ")," levels of Bloom's Taxonomy. Easy ",T.easy,"% · Medium ",T.medium,"% · Hard ",T.hard,"%."]})]})]})}),d==="results"&&V&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-sky-50 to-cyan-50 border border-sky-200 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-bold font-display text-[#0a1628]",children:"Quiz Generated"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Bl,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-[#dde3eb] rounded-lg text-xs font-medium text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:[E?e.jsx(gs,{size:14,className:"text-green-500"}):e.jsx(Li,{size:14}),E?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:$l,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-[#dde3eb] rounded-lg text-xs font-medium text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:[e.jsx(gr,{size:14}),"Export JSON"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-sky-600",children:V.questions.length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Questions"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-rose-600",children:V.totalPoints}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Total Points"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-rose-600",children:Object.keys(V.metadata.topicsCovered).length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Topics"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:Object.keys(V.metadata.bloomTaxonomyDistribution).length}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Bloom Levels"})]})]}),(V.metadata.usedImportedTopics||(V.metadata.topicProvenance||[]).length>0)&&e.jsxs("div",{className:"mt-4 bg-white rounded-lg p-3 border border-[#dde3eb]",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Imported Topic Provenance"}),e.jsxs("p",{className:"text-xs text-[#5a6578] mb-2",children:["Imported topics used: ",V.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",V.metadata.importedMaterialsCount??0," • ","Topics: ",V.metadata.importedTopicCount??0]}),(V.metadata.topicProvenance||[]).slice(0,5).map((x,A)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[x.title||"Untitled topic",x.sourceFile?` • ${x.sourceFile}`:""]},`${x.topicId||x.title||"topic"}_${A}`)),(Ur.length>0||Wr.length>0)&&e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"text-xs text-[#5a6578] flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Filter by Source File"}),e.jsxs("select",{value:ge,onChange:x=>He(x.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All sources"}),Ur.map(x=>e.jsx("option",{value:x,children:x},x))]})]}),e.jsxs("label",{className:"text-xs text-[#5a6578] flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Filter by Material ID"}),e.jsxs("select",{value:Je,onChange:x=>Xe(x.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All materials"}),Wr.map(x=>e.jsx("option",{value:x,children:x},x))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",za.length," of ",V.questions.length," questions after provenance filters."]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Difficulty"}),Object.entries(V.metadata.difficultyBreakdown).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:`capitalize ${On[x]||"text-[#5a6578]"}`,children:x}),e.jsx("span",{className:"font-medium",children:A})]},x))]}),e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Bloom's Taxonomy"}),Object.entries(V.metadata.bloomTaxonomyDistribution).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"capitalize",children:x}),e.jsx("span",{className:"font-medium",children:A})]},x))]}),e.jsxs("div",{className:"bg-white rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-2",children:"Question Types"}),Object.entries(V.metadata.questionTypeBreakdown).map(([x,A])=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{children:ca[x]?.label||x}),e.jsx("span",{className:"font-medium",children:A})]},x))]})]}),e.jsxs("div",{className:"mt-3 bg-sky-50 rounded-lg p-3 flex items-start gap-2",children:[e.jsx(tr,{size:14,className:"text-sky-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-sky-600",children:V.metadata.supplementalPurpose})]}),V.metadata.recommendedTeacherActions&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#5a6578] mb-1",children:"Recommended Actions:"}),e.jsx("ul",{className:"list-disc list-inside text-xs text-[#5a6578] space-y-0.5",children:V.metadata.recommendedTeacherActions.map((x,A)=>e.jsx("li",{children:x},A))})]})]}),e.jsx("div",{className:"space-y-3",children:za.length>0?za.map((x,A)=>Ul(x,A)):e.jsx("div",{className:"border border-[#dde3eb] rounded-xl p-4 bg-white text-sm text-[#5a6578]",children:"No questions match the selected provenance filters. Clear one or both filters to view all questions."})})]})]})]}),i==="create"&&e.jsxs("div",{className:"border-t border-[#dde3eb] px-6 sm:px-6 xl:px-10 py-4 bg-[#f7f9fc] flex items-center justify-between flex-shrink-0",children:[d==="setup"&&!me&&e.jsxs(e.Fragment,{children:[e.jsx("div",{}),e.jsxs("button",{onClick:()=>u("topics"),className:"bg-white border border-[#dde3eb] text-[#edf1f7] px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:text-slate-600 flex items-center",children:[e.jsx("span",{className:"text-[#edf1f7]",children:"Next: Topics"})," ",e.jsx(Wt,{size:16,className:"ml-2 text-slate-300"})]})]}),d==="topics"&&!me&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>{y([]),v([])},className:"text-[#9b51e0] text-sm font-semibold hover:underline",children:"Clear all"}),e.jsxs("span",{className:"text-sm text-[#9b51e0]",children:[k.filter(x=>!f.includes(x)).length," of ",xs," topics selected"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>u("setup"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:()=>u("style"),className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:["Next: Question style ",e.jsx(Wt,{size:16,className:"ml-2 text-purple-200"})]})]})]}),d==="style"&&!me&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>u("topics"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:()=>u("preview"),className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:["Preview ",e.jsx(Wt,{size:16,className:"ml-2 text-purple-200"})]})]}),d==="preview"&&!me&&!V&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>u("style"),className:"bg-white border border-[#dde3eb] text-[#5a6578] px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors hover:bg-[#edf1f7] flex items-center",children:[e.jsx(Pt,{size:16,className:"mr-2 text-slate-400"})," Back"]}),e.jsxs("button",{onClick:Fl,className:"bg-[#9b51e0] text-white px-6 py-2.5 rounded-lg text-sm font-bold transition-colors hover:bg-purple-700 flex items-center shadow-md",children:[e.jsx(gs,{size:16,className:"mr-2"})," Generate quiz"]})]}),me&&e.jsx("div",{className:"w-full flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(nt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})}),d==="results"&&(Hr?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c("bank"),ra(null)},className:"px-4 py-2.5 rounded-xl text-sm font-medium bg-white border border-[#dde3eb] text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:"Back to Quiz Bank"}),e.jsxs("button",{onClick:()=>$a(Hr),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-sky-50 border border-sky-300 text-sky-700 hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:16})," Assign"]}),e.jsx("button",{onClick:Ba,className:"px-5 py-2.5 rounded-xl text-sm font-bold bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white transition-all",children:"Done"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{u("setup"),we(null),ke(null),Te(null),ra(null)},className:"px-4 py-2.5 rounded-xl text-sm font-medium bg-white border border-[#dde3eb] text-[#5a6578] hover:bg-[#edf1f7] transition-colors",children:"Create Another"}),Be?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:Pl,disabled:tt,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-green-50 border border-green-300 text-green-700 hover:bg-green-100 transition-colors",children:[tt?e.jsx(nt,{size:16,className:"animate-spin"}):e.jsx(ka,{size:16}),"Publish"]}),e.jsxs("button",{onClick:()=>$a(),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-sky-50 border border-sky-300 text-sky-700 hover:bg-sky-100 transition-colors",children:[e.jsx(zs,{size:16})," Assign"]})]}):e.jsxs("button",{onClick:Ol,disabled:U,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold bg-emerald-50 border border-emerald-300 text-emerald-700 hover:bg-emerald-100 transition-colors",children:[U?e.jsx(nt,{size:16,className:"animate-spin"}):e.jsx(yo,{size:16}),"Save to Library"]}),e.jsx("button",{onClick:Ba,className:"px-5 py-2.5 rounded-xl text-sm font-bold bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white transition-all",children:"Done"})]}))]}),e.jsx(om,{isOpen:I,onClose:()=>Y(!1)}),e.jsx(Qt,{children:Aa&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/40 z-[60] flex items-center justify-center p-4",onClick:()=>es(!1),children:e.jsxs(Re.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-[#f7f9fc] rounded-2xl shadow-2xl w-full max-w-md max-h-[70vh] flex flex-col overflow-hidden border border-[#dde3eb]",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-[#dde3eb] flex items-center justify-between",children:[e.jsxs("h3",{className:"text-base font-bold font-display text-[#0a1628] flex items-center gap-2",children:[e.jsx(Ps,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>es(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(va,{size:16,className:"text-slate-500"})})]}),e.jsx("div",{className:"px-5 py-3 border-b border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center gap-2 bg-[#edf1f7] rounded-xl px-3 py-2",children:[e.jsx(Js,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:Ma,onChange:x=>Br(x.target.value),className:"flex-1 bg-transparent text-sm outline-none placeholder:text-slate-500"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1",children:Tl?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(nt,{size:20,className:"animate-spin text-sky-500"})}):Xr.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):Xr.map(x=>e.jsxs("button",{onClick:()=>$r(x.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${ts===x.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:x.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(x.name)}&background=random&size=32`,alt:x.name,className:"w-8 h-8 rounded-lg object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-[#0a1628] truncate",children:x.name}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:x.email})]}),ts===x.id&&e.jsx(gs,{size:16,className:"text-sky-600 flex-shrink-0"})]},x.id))}),e.jsxs("div",{className:"px-5 py-3 border-t border-[#dde3eb] flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>es(!1),className:"px-4 py-2 text-sm font-medium text-[#5a6578] hover:bg-[#edf1f7] rounded-xl transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:_l,disabled:!ts||ks,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${ts&&!ks?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[ks?e.jsx(nt,{size:14,className:"animate-spin"}):e.jsx(zs,{size:14}),"Assign"]})]})]})})})]})};function Ka({className:t,...s}){return e.jsx(fi,{"data-slot":"label",className:hr("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const um=()=>{const[t,s]=p.useState([]),[a,r]=p.useState(!1),[n,o]=p.useState(!1),[l,i]=p.useState(""),[c,d]=p.useState(11),[u,N]=p.useState("general_mathematics"),m=p.useCallback(async()=>{r(!0);try{const y=await en("/api/quiz-battle/bank-status");s(y.pdfs)}catch(y){const f=y instanceof Os?y.message:"Failed to load bank status";ce.error(f)}finally{r(!1)}},[]);p.useEffect(()=>{m()},[m]);const h=async()=>{if(!l.trim()){ce.error("Please enter a storage path");return}o(!0);try{await en("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:l.trim(),grade_level:c,topic:u.trim(),force_reingest:!1})}),ce.success("PDF ingestion completed"),await m(),i("")}catch(y){const f=y instanceof Os?y.message:"Ingestion failed";ce.error(f)}finally{o(!1)}},w=t.reduce((y,f)=>y+f.question_count,0),k=t.filter(y=>y.processed).length;return e.jsxs("div",{className:"space-y-6 p-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-[#9956DE]/12 rounded-xl border border-[#9956DE]/30",children:e.jsx(Vt,{className:"h-5 w-5 text-[#9956DE]"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground",children:"Question Bank"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage PDF-ingested quiz questions for battle sessions"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(fr,{className:"h-4 w-4"}),"Total PDFs"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:t.length})})]}),e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Vt,{className:"h-4 w-4"}),"Total Questions"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:w})})]}),e.jsxs(Ts,{children:[e.jsx(Is,{className:"pb-2",children:e.jsxs(Es,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(_s,{className:"h-4 w-4"}),"Processed"]})}),e.jsx(Rs,{children:e.jsx("div",{className:"text-3xl font-display font-bold text-foreground",children:k})})]})]}),e.jsxs(Ts,{children:[e.jsx(Is,{children:e.jsx(Es,{className:"text-base font-display font-bold",children:"Ingest New PDF"})}),e.jsxs(Rs,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"storagePath",children:"Firebase Storage Path"}),e.jsx(vt,{id:"storagePath",placeholder:"quiz_pdfs/grade_11/general_math.pdf",value:l,onChange:y=>i(y.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"gradeLevel",children:"Grade Level"}),e.jsx(vt,{id:"gradeLevel",type:"number",min:7,max:12,value:c,onChange:y=>d(Number(y.target.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ka,{htmlFor:"topic",children:"Topic Slug"}),e.jsx(vt,{id:"topic",placeholder:"general_mathematics",value:u,onChange:y=>N(y.target.value)})]})]}),e.jsxs($e,{onClick:h,disabled:n,className:"bg-[#9956DE] hover:bg-[#9956DE]/90",children:[n?e.jsx(nt,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Di,{className:"mr-2 h-4 w-4"}),"Ingest PDF"]})]})]}),e.jsxs(Ts,{children:[e.jsxs(Is,{className:"flex flex-row items-center justify-between",children:[e.jsx(Es,{className:"text-base font-display font-bold",children:"Processing Status"}),e.jsx($e,{variant:"outline",size:"sm",onClick:m,disabled:a,children:e.jsx(_s,{className:`h-4 w-4 ${a?"animate-spin":""}`})})]}),e.jsx(Rs,{children:e.jsxs(Ii,{children:[e.jsx(Ei,{children:e.jsxs(_a,{children:[e.jsx(ms,{children:"Filename"}),e.jsx(ms,{children:"Grade"}),e.jsx(ms,{children:"Topic"}),e.jsx(ms,{children:"Questions"}),e.jsx(ms,{children:"Status"}),e.jsx(ms,{children:"Processed At"})]})}),e.jsxs(Ri,{children:[t.map(y=>e.jsxs(_a,{children:[e.jsx(ss,{className:"font-medium",children:y.filename}),e.jsx(ss,{children:y.grade_level}),e.jsx(ss,{children:y.topic}),e.jsx(ss,{children:y.question_count}),e.jsx(ss,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${y.processed?"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300"}`,children:y.processed?"Processed":"Pending"})}),e.jsx(ss,{children:y.timestamp?new Date(y.timestamp).toLocaleDateString():"-"})]},y.filename)),t.length===0&&e.jsx(_a,{children:e.jsx(ss,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No PDFs processed yet. Upload a PDF to get started."})})]})]})})]})]})},Pn={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},xm={"gen-math":{label:"GEN MATH",color:"bg-sky-100 text-sky-700"},"stats-prob":{label:"STAT&PROB",color:"bg-sky-100 text-sky-700"},"pre-calc":{label:"PRE-CALC",color:"bg-orange-100 text-orange-700"},"basic-calc":{label:"BASIC CALC",color:"bg-red-100 text-red-700"}},hm={mastered:{label:"MASTERED BY CLASS",color:"bg-green-100 text-green-700 border-green-300"},on_track:{label:"ON TRACK",color:"bg-sky-100 text-sky-700 border-sky-300"},needs_attention:{label:"NEEDS ATTENTION",color:"bg-red-100 text-red-700 border-red-300"},no_data:{label:"NO DATA YET",color:"bg-[#edf1f7] text-[#5a6578] border-[#dde3eb]"}},_n={needs_attention:0,on_track:1,no_data:2,mastered:3},pm=({classSectionId:t})=>{const{currentUser:s}=Ks(),[a,r]=p.useState([]),[n,o]=p.useState(Pn),[l,i]=p.useState(!0),[c,d]=p.useState("all"),[u,N]=p.useState("all"),[m,h]=p.useState(""),[w,k]=p.useState("classAverage"),[y,f]=p.useState("asc"),v=rn.map(D=>D.id),S=rn.reduce((D,te)=>(D[te.id]=te.name,D),{}),{isLoading:R}=$i();p.useEffect(()=>{},[R]);const[j,B]=p.useState(new Set),[g,b]=p.useState([]),T=zi({queryKey:ql.topicMastery(s?.uid||"anonymous",t),enabled:!!s,staleTime:120*1e3,gcTime:900*1e3,queryFn:async()=>{try{if(!s)return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}};const D=et(Ge,"teachers",s.uid,"settings","quizSettings"),te=await ns(D),J=te.exists()?te.data()?.excludedTopics||[]:[],me="https://deign86-mathpulse-api-v3test.hf.space",Ce=new URLSearchParams({teacherId:s.uid});t&&Ce.set("classSectionId",t);const F=await s.getIdToken(),C=await fetch(`${me}/api/analytics/topic-mastery?${Ce.toString()}`,{headers:{Authorization:`Bearer ${F}`}});if(!C.ok)return{excluded:J,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:J.length}};const K=await C.json(),P=(K.topics||[]).map(xe=>({...xe,isExcluded:J.includes(xe.topicName)}));return{excluded:J,topics:P,summary:K.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:J.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});p.useEffect(()=>{if(i(T.isLoading||T.isFetching),!T.data){b([]),r([]),o(Pn),B(new Set);return}b(T.data.excluded),r(T.data.topics),o(T.data.summary)},[T.data,T.isFetching,T.isLoading]);const z=async D=>{if(!s)return;const te=g.includes(D)?g.filter(J=>J!==D):[...g,D];b(te),r(J=>J.map(me=>me.topicName===D?{...me,isExcluded:!me.isExcluded}:me)),o(J=>({...J,excludedCount:te.length}));try{const J=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(J)).exists()?await yt(J,{excludedTopics:te}):await Ut(J,{excludedTopics:te})}catch{ce.error("Failed to update excluded topics")}},$=async()=>{if(!s)return;const D=[...new Set([...g,...j])];b(D),r(te=>te.map(J=>j.has(J.topicName)?{...J,isExcluded:!0}:J)),o(te=>({...te,excludedCount:D.length})),B(new Set);try{const te=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(te)).exists()?await yt(te,{excludedTopics:D}):await Ut(te,{excludedTopics:D}),ce.success(`${j.size} topics excluded from quizzes`)}catch{ce.error("Failed to update")}},Z=async()=>{if(!s)return;const D=g.filter(te=>!j.has(te));b(D),r(te=>te.map(J=>j.has(J.topicName)?{...J,isExcluded:!1}:J)),o(te=>({...te,excludedCount:D.length})),B(new Set);try{const te=et(Ge,"teachers",s.uid,"settings","quizSettings");(await ns(te)).exists()?await yt(te,{excludedTopics:D}):await Ut(te,{excludedTopics:D}),ce.success(`${j.size} topics re-included in quizzes`)}catch{ce.error("Failed to update")}},ae=D=>{w===D?f(te=>te==="asc"?"desc":"asc"):(k(D),f("asc"))},H=u==="all"?v:Fi(u);p.useEffect(()=>{c!=="all"&&(H.includes(c)||d("all"))},[H,c]);const ee=a.filter(D=>!(c!=="all"&&D.subjectId!==c||!H.includes(D.subjectId)||m&&!D.topicName.toLowerCase().includes(m.toLowerCase()))).sort((D,te)=>{const J=y==="asc"?1:-1;switch(w){case"topicName":return J*D.topicName.localeCompare(te.topicName);case"classAverage":return J*(D.classAverage-te.classAverage);case"studentsAttempted":return J*(D.studentsAttempted-te.studentsAttempted);case"masteryStatus":return J*((_n[D.masteryStatus]||0)-(_n[te.masteryStatus]||0));default:return 0}}),re=()=>{j.size===ee.length?B(new Set):B(new Set(ee.map(D=>D.topicName)))},ne=({field:D})=>w!==D?e.jsx(Ht,{size:12,className:"text-slate-500"}):y==="asc"?e.jsx(Na,{size:12,className:"text-sky-600"}):e.jsx(Ht,{size:12,className:"text-sky-600"});return l?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(nt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-[#5a6578]",children:"Loading topic mastery data..."})]}):e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[#0a1628]",children:"Class Topic Mastery"}),e.jsx("p",{className:"text-sm text-[#5a6578] mt-1",children:"Topics where 75% or more of the class scored 85%+ are marked as mastered and can be excluded from future quiz generation."})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-sky-100 rounded-xl flex items-center justify-center",children:e.jsx(Hs,{size:20,className:"text-sky-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:n.totalTopicsTracked}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Total Topics Tracked"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-green-200",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-xl flex items-center justify-center",children:e.jsx(ja,{size:20,className:"text-green-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:n.masteredCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Mastered by Class"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-red-200",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-red-100 rounded-xl flex items-center justify-center",children:e.jsx(Gt,{size:20,className:"text-red-600"})})}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:n.needsAttentionCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Needs Work"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("div",{className:"w-10 h-10 bg-[#edf1f7] rounded-xl flex items-center justify-center",children:e.jsx(Ti,{size:20,className:"text-[#5a6578]"})})}),e.jsx("p",{className:"text-2xl font-bold text-[#5a6578]",children:n.excludedCount}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Excluded Topics"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white rounded-xl px-3 py-2 border border-[#dde3eb]",children:[e.jsx(Js,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:m,onChange:D=>h(D.target.value),className:"bg-transparent text-sm outline-none w-40 placeholder:text-slate-500"})]}),e.jsxs("select",{value:c,onChange:D=>d(D.target.value),className:"bg-white border border-[#dde3eb] rounded-xl px-3 py-2 text-sm outline-none",children:[e.jsx("option",{value:"all",children:"All Subjects"}),H.map(D=>e.jsx("option",{value:D,children:S[D]||D},D))]}),e.jsxs("select",{value:u,onChange:D=>N(D.target.value),className:"bg-white border border-[#dde3eb] rounded-xl px-3 py-2 text-sm outline-none",children:[e.jsx("option",{value:"all",children:"All Grades"}),Bi.map(D=>e.jsx("option",{value:D,children:D},D))]})]}),e.jsx(Qt,{children:j.size>0&&e.jsxs(Re.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"bg-sky-50 border border-sky-200 rounded-xl p-3 flex items-center gap-3 flex-wrap overflow-hidden",children:[e.jsxs("span",{className:"text-sm font-semibold text-sky-700",children:[j.size," topics selected"]}),e.jsx("button",{onClick:$,className:"px-3 py-1.5 bg-[#5a6578] text-white text-xs font-bold rounded-lg hover:bg-sky-600 transition-colors",children:"Exclude Selected Topics"}),e.jsx("button",{onClick:Z,className:"px-3 py-1.5 bg-green-600 text-white text-xs font-bold rounded-lg hover:bg-green-700 transition-colors",children:"Include Selected Topics"}),e.jsx("button",{onClick:()=>B(new Set),className:"px-3 py-1.5 bg-white border border-[#dde3eb] text-[#5a6578] text-xs font-bold rounded-lg hover:bg-[#edf1f7] transition-colors",children:"Clear Selection"})]})}),e.jsx("div",{className:"bg-white rounded-2xl shadow-sm border border-[#dde3eb] overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#edf1f7] border-b border-[#dde3eb]",children:[e.jsx("th",{className:"px-4 py-3 w-10",children:e.jsx("input",{type:"checkbox",checked:j.size===ee.length&&ee.length>0,onChange:re,className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("topicName"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Topic Name ",e.jsx(ne,{field:"topicName"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide",children:"Unit"}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("classAverage"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Class Avg % ",e.jsx(ne,{field:"classAverage"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("studentsAttempted"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Students ",e.jsx(ne,{field:"studentsAttempted"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide cursor-pointer hover:text-sky-600",onClick:()=>ae("masteryStatus"),children:e.jsxs("span",{className:"flex items-center gap-1",children:["Status ",e.jsx(ne,{field:"masteryStatus"})]})}),e.jsx("th",{className:"px-4 py-3 text-xs font-bold text-[#5a6578] uppercase tracking-wide",children:"Exclude"})]})}),e.jsx("tbody",{children:ee.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-16 text-center",children:a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Hs,{size:32,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm font-medium text-[#5a6578]",children:"No topic data available yet"}),e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Import student quiz data to see class topic mastery analytics."})]}):e.jsx("span",{className:"text-sm text-slate-500",children:"No topics match the current filters."})})}):ee.map(D=>{const te=j.has(D.topicName),J=hm[D.masteryStatus],me=xm[D.subjectId]||{label:D.subjectId.toUpperCase(),color:"bg-[#edf1f7] text-[#5a6578]"},Ce=D.classAverage<60?"bg-red-500":D.classAverage<85?"bg-rose-500":"bg-green-500",F=D.isExcluded?"bg-[#edf1f7] opacity-60":D.masteryStatus==="needs_attention"?"bg-red-50/30":D.masteryStatus==="mastered"?"bg-green-50/30":"";return e.jsxs("tr",{className:`border-b border-[#dde3eb] hover:bg-[#edf1f7] transition-colors ${F} ${D.isExcluded?"line-through decoration-slate-400":""}`,children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"checkbox",checked:te,onChange:()=>{const C=new Set(j);te?C.delete(D.topicName):C.add(D.topicName),B(C)},className:"w-4 h-4 rounded border-[#dde3eb] text-sky-600 focus:ring-sky-500"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#0a1628]",children:D.topicName}),e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${me.color}`,children:me.label})]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-[#5a6578]",children:D.unit}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-[#edf1f7] rounded-full overflow-hidden max-w-20",children:e.jsx("div",{className:`h-full rounded-full e-w ${Ce}`,style:{"--w":`${D.classAverage}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-[#0a1628] w-8 text-right",children:[D.classAverage,"%"]})]})}),e.jsxs("td",{className:"px-4 py-3 text-xs text-[#5a6578]",children:[D.studentsAttempted,"/",D.totalStudents]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${J.color}`,children:J.label})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"group relative",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D.isExcluded,onChange:()=>z(D.topicName),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-[#dde3eb] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-[#dde3eb] after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#5a6578]"})]}),e.jsx("div",{className:"hidden group-hover:block absolute z-20 bottom-full left-0 mb-1 px-2 py-1 bg-slate-800 text-white text-[10px] rounded whitespace-nowrap",children:"Excluded topics will not appear in AI-generated quizzes for your class"})]})})]},D.topicName)})})]})})})]})};function hl(t){return(t||"").trim().toLowerCase()}function Hn(t){const s=(t.lrn||"").trim().toLowerCase();if(s)return`lrn:${s}`;const a=(t.email||"").trim().toLowerCase();if(a)return`email:${a}`;const r=t.name.trim().toLowerCase();if(r)return`name:${r}`;const n=hl(t.classSectionId),o=(t.id||"").trim().toLowerCase();return n&&o?`${n}|id:${o}`:o?`id:${o}`:`${n}|anonymous`}function fm(t,s){const a=[],r=(t.lrn||"").trim().toLowerCase(),n=(t.email||"").trim().toLowerCase(),o=t.name.trim().toLowerCase(),l=(t.id||"").trim().toLowerCase();return r&&a.push(`${s}|lrn:${r}`),n&&a.push(`${s}|email:${n}`),o&&a.push(`${s}|name:${o}`),l&&a.push(`${s}|id:${l}`),a.length===0&&a.push(`${s}|anonymous`),a}function gm(t,s){const a=[t.riskLevel,s.riskLevel].includes("High")?"High":[t.riskLevel,s.riskLevel].includes("Medium")?"Medium":"Low";return{...t,lrn:t.lrn||s.lrn,classSectionId:t.classSectionId??s.classSectionId,avgQuizScore:s.avgQuizScore>0?s.avgQuizScore:t.avgQuizScore,engagementScore:s.engagementScore>0?s.engagementScore:t.engagementScore,weakestTopic:t.weakestTopic&&t.weakestTopic!=="Foundational Skills"?t.weakestTopic:s.weakestTopic,riskLevel:a}}function pl(t,s){const a=new Map,r=new Map,n=s?hl(s):"all";return t.forEach(o=>{const l=fm(o,n),i=l.map(u=>r.get(u)).find(Boolean)||l[0],c=a.get(i),d=c?gm(c,o):o;a.set(i,d),l.forEach(u=>r.set(u,i))}),Array.from(a.values())}function Gn(t,s){return pl([...t,...s])}function rs(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function bm(t){if(!t)return null;const s="gen-math",a=nn.find(l=>l.id===s)?.modules||[];if(a.length===0)return null;const r={mastery:0,concept:0,application:0,engagement:0,consistency:0},n=t.lessons??{};a.forEach(l=>{const i=nn.find(y=>y.modules.some(f=>f.id===l.id)),c=i?t?.subjects?.[i.id]?.modulesProgress?.[l.id]:null,d=rs(c?.progress||0),u=l.lessons.length?l.lessons.reduce((y,f)=>{const v=n?.[f.id]?.score;if(typeof v=="number"&&Number.isFinite(v))return y+rs(v);const S=!!c?.lessonsCompleted?.includes?.(f.id);return y+(S?100:0)},0)/l.lessons.length:0,N=l.quizzes.length?(c?.quizzesCompleted?.length||0)/l.quizzes.length*100:0,m=rs(u),h=rs(N),w=rs(Math.min(100,(m+h*2)/1.5)),k=rs(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=m,r.application+=h,r.engagement+=w,r.consistency+=k});const o=a.length;return{mastery:Math.round(r.mastery/o),concept:Math.round(r.concept/o),application:Math.round(r.application/o),engagement:Math.round(r.engagement/o),consistency:Math.round(r.consistency/o)}}const Xa={High:{bg:"bg-red-100",text:"text-red-700",ring:"ring-red-300"},Medium:{bg:"bg-rose-100",text:"text-rose-700",ring:"ring-rose-300"},Low:{bg:"bg-green-100",text:"text-green-700",ring:"ring-green-300"}},Qn={advanced:{bg:"bg-emerald-100",text:"text-emerald-700",bar:"bg-emerald-500"},proficient:{bg:"bg-sky-100",text:"text-sky-700",bar:"bg-sky-500"},developing:{bg:"bg-rose-100",text:"text-rose-700",bar:"bg-rose-500"},beginner:{bg:"bg-red-100",text:"text-red-700",bar:"bg-red-500"}},Un=[{key:"mastery",short:"M",label:"Overall Mastery",header:"Mastery"},{key:"concept",short:"C",label:"Concept Grasp",header:"Concept"},{key:"application",short:"A",label:"Application",header:"Application"},{key:"engagement",short:"E",label:"Engagement",header:"Engagement"},{key:"consistency",short:"S",label:"Consistency",header:"Consistency"}];function vm(t){const s=rs(t);return s>=80?{bg:"bg-[color-mix(in_srgb,var(--chart-3)_14%,transparent)]",text:"text-[var(--chart-3)]",ring:"ring-[color-mix(in_srgb,var(--chart-3)_40%,transparent)]"}:s>=60?{bg:"bg-[color-mix(in_srgb,var(--chart-4)_14%,transparent)]",text:"text-[var(--chart-4)]",ring:"ring-[color-mix(in_srgb,var(--chart-4)_40%,transparent)]"}:{bg:"bg-[color-mix(in_srgb,var(--chart-2)_14%,transparent)]",text:"text-[var(--chart-2)]",ring:"ring-[color-mix(in_srgb,var(--chart-2)_40%,transparent)]"}}const Nm=({classSectionId:t,className:s,fallbackStudents:a=[]})=>{const{currentUser:r}=Ks(),n=p.useRef(0),[o,l]=p.useState([]),[i,c]=p.useState(!0),[d,u]=p.useState(""),[N,m]=p.useState("riskLevel"),[h,w]=p.useState("desc"),[k,y]=p.useState("all"),[f,v]=p.useState([]),[S,R]=p.useState(!1),[j,B]=p.useState(""),[g,b]=p.useState(""),T=p.useCallback(C=>({id:C.id,lrn:C.lrn||void 0,name:C.name,email:C.email||"",avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(C.name)}&background=random`,classSectionId:C.classSectionId??null,riskLevel:C.riskLevel||"Low",engagementScore:C.engagementScore,avgQuizScore:C.avgQuizScore,weakestTopic:C.weakestTopic||"Foundational Skills"}),[]),z=p.useCallback(C=>({id:C.id,lrn:C.lrn,name:C.name,email:C.email||"",avatar:C.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(C.name)}&background=random`,classSectionId:C.classSectionId??null,riskLevel:String(C.riskLevel).charAt(0).toUpperCase()+String(C.riskLevel).slice(1).toLowerCase(),engagementScore:C.engagementScore,avgQuizScore:Number(C.avgQuizScore??C.avgScore??0),weakestTopic:C.weakestTopic||"Foundational Skills"}),[]),$=p.useCallback(async(C,K)=>{const P=new Map;C.forEach(M=>P.set(M.id,null));const xe=25;for(let M=0;M{try{const ie=await tn(le.id);return{studentId:le.id,summary:bm(ie)}}catch{return{studentId:le.id,summary:null}}}))).forEach((le,ie)=>{const V=G[ie]?.id;V&&(le.status==="fulfilled"?P.set(V,le.value.summary):P.set(V,null))})}n.current===K&&l(M=>M.map(G=>P.has(G.student.id)?{...G,competencyMatrix:P.get(G.student.id)??null,competencyMatrixLoading:!1}:G))},[]),Z=p.useCallback(async()=>{if(r?.uid){c(!0),b("");try{let K=(await Ar(r.uid)).map(G=>({id:G.id,name:G.name,email:G.email||"",avatar:G.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(G.name)}&background=random`,classSectionId:G.classSectionId??null,riskLevel:G.riskLevel,engagementScore:G.engagementScore,avgQuizScore:G.avgQuizScore,weakestTopic:G.weakestTopic||"Foundational Skills"}));a.length>0&&(K=Gn(K,a.map(z))),t&&(K=K.filter(G=>G.classSectionId===t));const P=await Ve.getImportedClassOverview({classSectionId:t,limit:3e3});P.warnings.length>0&&b(P.warnings.join(" ")),K=Gn(K,P.students.map(T));const xe=pl(K,t),M=n.current+=1;l(xe.map((G,X)=>({rowKey:`${Hn(G)}|row:${X}`,student:G,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),$(xe,M)}catch(C){if(console.error("Failed to load students:",C),a.length>0){const K=a.map(z).filter(P=>!t||P.classSectionId===t).map((P,xe)=>({rowKey:`${Hn(P)}|row:${xe}`,student:P,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));l(K),b("Showing recently imported students while backend roster sync catches up.")}else l([]),b("Student competency roster is unavailable right now.")}finally{c(!1)}}},[t,r?.uid,a,$,z,T]);p.useEffect(()=>{Z()},[Z]),p.useEffect(()=>{(async()=>{if(!t){v([]),B("");return}R(!0),B("");try{const K=await Ve.getCourseMaterialTopics({classSectionId:t,limit:20}),P=(K.topics||[]).filter(xe=>xe.title?.trim());v(P),K.warnings.length>0&&B(K.warnings.join(" "))}catch{v([]),B("Imported topic context is unavailable right now.")}finally{R(!1)}})()},[t]);const ae=async C=>{l(K=>K.map(P=>{if(P.rowKey!==C)return P;const xe=!P.expanded,M=P.student.id,G={weakestTopic:P.student.weakestTopic,avgQuizScore:P.student.avgQuizScore};return xe&&!P.competency&&!P.loading?(H(C,M,G),{...P,expanded:!0,loading:!0}):{...P,expanded:xe}}))},H=async(C,K,P)=>{try{const M=((await tn(K))?.quizAttempts??[]).map(X=>({topic:X.quizId,score:X.score,total:100,timeTaken:X.timeSpent})),G=await Ve.getStudentCompetency(K,M.length>0?M:void 0);l(X=>X.map(le=>le.rowKey===C?{...le,competency:G,loading:!1}:le))}catch{const M=P.avgQuizScore||50,G={studentId:K,competencies:[{topic:P.weakestTopic||"Unknown",efficiencyScore:Math.max(15,M-20),competencyLevel:M<50?"beginner":"developing",perspective:`Student needs focused practice in ${P.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,M+10),competencyLevel:M>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:M,competencyLevel:M>80?"advanced":M>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[P.weakestTopic||"Review fundamentals"],excludeTopics:[]};l(X=>X.map(le=>le.rowKey===C?{...le,competency:G,loading:!1}:le))}},ee=C=>{N===C?w(K=>K==="asc"?"desc":"asc"):(m(C),w("asc"))},re={High:0,Medium:1,Low:2},ne=o.filter(C=>{if(k!=="all"&&C.student.riskLevel!==k)return!1;if(d){const K=d.toLowerCase();return C.student.name.toLowerCase().includes(K)||C.student.email.toLowerCase().includes(K)}return!0}).sort((C,K)=>{let P=0;switch(N){case"name":P=C.student.name.localeCompare(K.student.name);break;case"avgQuizScore":P=C.student.avgQuizScore-K.student.avgQuizScore;break;case"riskLevel":P=re[C.student.riskLevel]-re[K.student.riskLevel];break;case"engagementScore":P=C.student.engagementScore-K.student.engagementScore;break}return h==="asc"?P:-P}),D=o.length,te=o.filter(C=>C.student.riskLevel==="High").length,J=D>0?Math.round(o.reduce((C,K)=>C+K.student.avgQuizScore,0)/D):0,me=D>0?Math.round(o.reduce((C,K)=>C+K.student.engagementScore,0)/D):0,Ce=Array.from(new Set(f.map(C=>C.title).filter(Boolean))).slice(0,10),F=({field:C})=>N!==C?e.jsx(Ht,{size:14,className:"text-slate-500"}):h==="asc"?e.jsx(Na,{size:14,className:"text-sky-600"}):e.jsx(Ht,{size:14,className:"text-sky-600"});return i?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(nt,{size:32,className:"animate-spin text-[var(--primary)]"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading student data..."})]}):e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Students",value:D,icon:e.jsx(sn,{size:20}),color:"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)]"},{label:"At-Risk Students",value:te,icon:e.jsx(Gt,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-2)_10%,transparent)] text-[var(--chart-2)]"},{label:"Class Average",value:`${J}%`,icon:e.jsx(Hs,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-3)_10%,transparent)] text-[var(--chart-3)]"},{label:"Avg. Engagement",value:`${me}%`,icon:e.jsx(ka,{size:20}),color:"bg-[color-mix(in_srgb,var(--chart-1)_10%,transparent)] text-[var(--chart-1)]"}].map((C,K)=>e.jsxs("div",{className:"bg-card rounded-xl border border-border p-4 flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${C.color}`,children:C.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-foreground",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]},K))}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1 w-full sm:max-w-xs",children:[e.jsx("label",{htmlFor:"student-search",className:"sr-only",children:"Search for students by name or email"}),e.jsx(Js,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx("input",{id:"student-search",type:"text",placeholder:"Search students...",value:d,onChange:C=>u(C.target.value),className:"w-full pl-9 pr-4 py-2 border border-border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-400"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["all","High","Medium","Low"].map(C=>e.jsx("button",{onClick:()=>y(C),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${k===C?"bg-[var(--primary)] text-white":"bg-muted text-muted-foreground hover:bg-accent"}`,children:C==="all"?"All":`${C} Risk`},C))}),e.jsxs("button",{onClick:Z,className:"sm:ml-auto w-full sm:w-auto flex items-center justify-center gap-1.5 px-3 py-1.5 bg-muted hover:bg-accent rounded-lg text-xs font-semibold text-muted-foreground transition-colors",children:[e.jsx(_s,{size:14}),"Refresh"]})]}),e.jsxs("div",{className:"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] border border-[color-mix(in_srgb,var(--primary)_30%,transparent)] rounded-xl p-4",children:[e.jsxs("p",{className:"text-sm font-semibold text-[var(--primary)]",children:["Imported Topic Context",s?` for ${s}`:""]}),e.jsx("p",{className:"text-xs text-[var(--primary)] mt-1 opacity-80",children:S?"Loading class-scoped imported topics...":Ce.length>0?`${Ce.length} imported topics loaded for competency guidance`:"No imported topics found for this class context"}),j&&e.jsx("p",{className:"text-[11px] text-[var(--chart-4)] mt-1",children:j}),g&&e.jsx("p",{className:"text-[11px] text-[var(--chart-4)] mt-1",children:g}),Ce.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ce.map(C=>e.jsx("span",{className:"text-[11px] bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)] px-2 py-0.5 rounded",children:C},C))})]}),e.jsx("div",{className:"bg-card rounded-xl border border-border",children:e.jsx("div",{className:"overflow-x-auto pb-2",children:e.jsxs("div",{className:"min-w-[1920px]",children:[e.jsxs("div",{className:"grid grid-cols-[48px_280px_120px_120px_120px_120px_120px_140px_170px_170px_220px] items-center gap-6 px-6 py-4 bg-muted/60 border-b border-border text-xs font-semibold text-muted-foreground tracking-normal",children:[e.jsx("div",{}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("name"),children:["Student ",e.jsx(F,{field:"name"})]}),Un.map(C=>e.jsx("div",{className:"text-center leading-none whitespace-nowrap tracking-normal",children:C.header},C.key)),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("riskLevel"),children:["Risk Level ",e.jsx(F,{field:"riskLevel"})]}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("avgQuizScore"),children:["Avg. Score ",e.jsx(F,{field:"avgQuizScore"})]}),e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground",onClick:()=>ee("engagementScore"),children:["Engagement ",e.jsx(F,{field:"engagementScore"})]}),e.jsx("div",{className:"flex justify-end pr-2",children:"Weakest Topic"})]}),ne.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(sn,{size:32,className:"mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No students match the current filters"})]}):e.jsx("div",{className:"divide-y divide-border",children:ne.map(C=>{const K=C.student.riskLevel==="High"?{card:"bg-rose-50 border-rose-200",title:"text-rose-800",chip:"bg-rose-100 text-rose-700"}:C.student.riskLevel==="Medium"?{card:"bg-amber-50 border-amber-200",title:"text-amber-800",chip:"bg-amber-100 text-amber-700"}:{card:"bg-sky-50 border-sky-200",title:"text-sky-800",chip:"bg-sky-100 text-sky-700"};return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("button",{onClick:()=>void ae(C.rowKey),className:"w-full grid grid-cols-[48px_280px_120px_120px_120px_120px_120px_140px_170px_170px_220px] gap-6 px-6 py-5 items-center hover:bg-muted transition-colors text-left",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center text-slate-500",children:C.expanded?e.jsx(Ht,{size:16}):e.jsx(Wt,{size:16})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:C.student.avatar,alt:C.student.name,className:"w-8 h-8 rounded-full bg-border object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:C.student.name}),e.jsx("p",{className:"text-xs text-slate-500",children:C.student.email})]})]}),Un.map(P=>{const xe=C.competencyMatrix?.[P.key]??0,M=vm(xe);return e.jsx("div",{className:"flex items-center justify-center",children:C.competencyMatrixLoading?e.jsx(nt,{size:14,className:"animate-spin text-muted-foreground"}):C.competencyMatrix?e.jsxs("span",{title:`${P.label}: ${xe}%`,className:`inline-flex items-center justify-center rounded-md px-2 py-1 text-xs font-semibold ring-1 ${M.bg} ${M.text} ${M.ring}`,children:[xe,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},P.key)}),e.jsx("div",{children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-bold ring-1 ${Xa[C.student.riskLevel]?.bg} ${Xa[C.student.riskLevel]?.text} ${Xa[C.student.riskLevel]?.ring}`,children:[C.student.riskLevel==="High"&&e.jsx(Gt,{size:10}),C.student.riskLevel]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full e-w ${C.student.avgQuizScore>=80?"bg-[var(--chart-3)]":C.student.avgQuizScore>=60?"bg-[var(--chart-4)]":"bg-[var(--chart-2)]"}`,style:{"--w":`${C.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-8 text-right",children:[C.student.avgQuizScore,"%"]})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full e-w ${C.student.engagementScore>=75?"bg-[var(--primary)]":C.student.engagementScore>=50?"bg-[var(--primary)]/60":"bg-muted-foreground"}`,style:{"--w":`${C.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-8 text-right",children:[C.student.engagementScore,"%"]})]})}),e.jsx("div",{className:"flex justify-end pr-2",children:e.jsx("span",{className:"text-xs font-medium text-muted-foreground bg-muted px-2 py-1 rounded-md",children:C.student.weakestTopic})})]}),e.jsx(Qt,{children:C.expanded&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsx("div",{className:"px-6 py-4 bg-muted border-t border-border",children:C.loading?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(nt,{size:20,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Analyzing competency data..."})]}):C.competency?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:C.competency.competencies.map((P,xe)=>e.jsx(jm,{competency:P},xe))}),C.competency.recommendedTopics.length>0&&e.jsxs("div",{className:`border rounded-lg p-3 ${K.card}`,children:[e.jsxs("h5",{className:`text-xs font-bold mb-1.5 flex items-center gap-1 ${K.title}`,children:[e.jsx(Vt,{size:12}),"Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:C.competency.recommendedTopics.map((P,xe)=>e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${K.chip}`,children:P},xe))})]}),Ce.length>0&&e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-lg p-3",children:[e.jsxs("h5",{className:"text-xs font-bold text-sky-800 mb-1.5 flex items-center gap-1",children:[e.jsx(uo,{size:12}),"Class Imported Topics"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ce.slice(0,8).map((P,xe)=>e.jsx("span",{className:"inline-flex items-center bg-sky-100 text-sky-700 px-2 py-0.5 rounded text-xs font-medium",children:P},`${P}_${xe}`))})]}),C.competency.excludeTopics.length>0&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-200 rounded-lg p-3",children:[e.jsxs("h5",{className:"text-xs font-bold text-emerald-800 mb-1.5 flex items-center gap-1",children:[e.jsx(Yl,{size:12}),"Mastered Topics (can exclude from quizzes)"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:C.competency.excludeTopics.map((P,xe)=>e.jsx("span",{className:"inline-flex items-center bg-emerald-100 text-emerald-700 px-2 py-0.5 rounded text-xs font-medium",children:P},xe))})]})]}):e.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"No competency data available. Student needs to complete quizzes first."})})})})]},C.rowKey)})})]})})})]})},jm=({competency:t})=>{const s=Qn[t.competencyLevel]||Qn.developing;return e.jsxs("div",{className:"bg-card rounded-lg border border-border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h6",{className:"text-xs font-bold text-foreground truncate flex-1",children:t.topic}),e.jsx("span",{className:`ml-2 px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s.bg} ${s.text}`,children:t.competencyLevel})]}),e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-slate-500",children:"Efficiency"}),e.jsxs("span",{className:"font-bold text-muted-foreground",children:[t.efficiencyScore,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx(Re.div,{initial:{width:0},animate:{width:`${t.efficiencyScore}%`},transition:{duration:.6,delay:.1},className:`h-full rounded-full ${s.bar}`})})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug line-clamp-2",children:t.perspective})]})},ym=({liveActivity:t,atRiskStudents:s})=>{const{notifications:a,unreadCount:r,isLoading:n,markAsRead:o,markAllAsRead:l}=Kl(),i=u=>{const N=Date.now()-u.getTime(),m=Math.floor(N/6e4);if(m<1)return"Just now";if(m<60)return`${m} min ago`;const h=Math.floor(m/60);if(h<24)return`${h} hour${h===1?"":"s"} ago`;const w=Math.floor(h/24);return`${w} day${w===1?"":"s"} ago`},c=u=>{switch(u){case"achievement_unlocked":case"achievement":return Jl;case"message":return ii;case"grade":case"quiz_result":return mo;case"reminder":case"streak_reminder":return So;case"risk_alert":return Gt;case"automation":case"system_alert":return Xl;default:return ua}},d=u=>{switch(u){case"risk_alert":return"bg-destructive/10 text-destructive";case"achievement_unlocked":case"achievement":return"bg-rose-500/10 text-rose-600 dark:text-rose-400";case"message":return"bg-sky-500/10 text-sky-700 dark:text-sky-400";case"grade":case"quiz_result":return"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400";case"reminder":case"streak_reminder":return"bg-amber-500/10 text-amber-700 dark:text-amber-400";case"automation":case"system_alert":return"bg-violet-500/10 text-violet-700 dark:text-violet-400";default:return"bg-muted text-muted-foreground"}};return e.jsxs(Re.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},exit:{opacity:0,y:-18},className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-sky-100 text-sky-700 dark:bg-sky-500/15 dark:text-sky-300 flex items-center justify-center flex-shrink-0",children:e.jsx(ua,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Classroom alerts and updates"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-body",children:r>0?`${r} unread`:"All caught up"}),r>0&&e.jsxs($e,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(Oi,{}),"Mark all as read"]})]})]}),e.jsx("div",{className:"bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:n?e.jsxs("div",{className:"p-8 flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(nt,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-body",children:"Loading notifications…"})]}):a.length===0?e.jsx("div",{className:"p-10",children:e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-muted text-muted-foreground flex items-center justify-center mb-4",children:e.jsx(ua,{size:22})}),e.jsx("h3",{className:"text-lg font-display font-bold text-foreground mb-1",children:"No notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Teacher alerts and classroom updates will appear here."})]})}):e.jsxs("div",{children:[t&&t.length>0&&e.jsx("div",{children:t.map(u=>e.jsx("div",{className:"w-full text-left px-4 py-4 border-b border-border transition-colors hover:bg-accent/40",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${u.type==="success"?"bg-[#75D06A]/15 text-[#4D9F46]":u.type==="warning"?"bg-[#F08386]/15 text-[#C65E63]":"bg-[#9956DE]/15 text-[#9956DE]"}`,children:e.jsx($s,{size:18})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h4",{className:"text-sm font-body font-bold text-foreground line-clamp-1",children:[u.student," — ",u.action]})}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground font-body leading-relaxed line-clamp-2",children:["Topic: ",u.topic]})]}),e.jsx("div",{className:"text-xs text-muted-foreground font-body flex-shrink-0",children:u.time})]})})]})},u.id))}),a.map(u=>{const N=c(u.type),m=d(u.type),h=i(u.createdAt);return e.jsx("button",{onClick:()=>o(u.id),className:`w-full text-left px-4 py-4 border-b border-border last:border-b-0 transition-colors hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${u.isRead?"":"bg-sky-50/40 dark:bg-sky-500/5"}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${m}`,children:e.jsx(N,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-body font-bold text-foreground line-clamp-1",children:u.title}),!u.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground font-body leading-relaxed line-clamp-2",children:u.message})]}),e.jsx("div",{className:"text-xs text-muted-foreground font-body flex-shrink-0",children:h})]}),u.actionUrl&&e.jsx("div",{className:"mt-2 text-xs text-sky-600 dark:text-sky-400 font-body",children:"Opens link"})]})]})},u.id)})]})})]})},wm=t=>{const s=t.data(),a=s.startTime,r=s.endTime,n=s.createdAt,o=s.updatedAt,l=i=>{if(i){if(typeof i?.toDate=="function")return i.toDate();if(i instanceof Date)return i}};return{...s,id:t.id,startTime:l(a)||new Date,endTime:l(r),createdAt:l(n)||new Date,updatedAt:l(o)}},Sm=async(t,s)=>{const a=et(Bt(Ge,"calendarEvents")),r={id:a.id,userId:t,title:s.title,description:s.description,startTime:s.startTime,endTime:s.endTime,createdAt:new Date};return await Ut(a,{...r,createdAt:ot(),updatedAt:ot()}),r},km=async t=>{await xi(et(Ge,"calendarEvents",t))},Cm=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:n=500}=s,o=zt(Bt(Ge,"calendarEvents"),Ft("userId","==",t),vo(n));return Xs(o,l=>{a(l.docs.map(i=>wm(i)))},l=>{console.error("Error subscribing to calendar events:",l),r?.(l)})};function Tm({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:hr("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...s})}const Wn=t=>String(t).padStart(2,"0"),hs=t=>`${t.getFullYear()}-${Wn(t.getMonth()+1)}-${Wn(t.getDate())}`,ur=t=>new Date(t.getFullYear(),t.getMonth(),1),Vn=t=>new Date(t.getFullYear(),t.getMonth()+1,0),Im=t=>{const s=ur(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},Em=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},qn=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),Rm=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),Am=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),Yn=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),Kn=(t,s)=>{const[a,r,n]=t.split("-").map(i=>parseInt(i,10)),[o,l]=s.split(":").map(i=>parseInt(i,10));return new Date(a,(r||1)-1,n||1,o||0,l||0,0,0)},Ja=[{names:["sun","sunday"],day:0},{names:["mon","monday"],day:1},{names:["tue","tues","tuesday"],day:2},{names:["wed","wednesday"],day:3},{names:["thu","thurs","thursday"],day:4},{names:["fri","friday"],day:5},{names:["sat","saturday"],day:6}];function Mm(t){const s=t.toLowerCase(),a=new Set;if(s.includes("daily")||s.includes("everyday"))return[0,1,2,3,4,5,6];if(s.includes("weekends"))return[0,6];if(s.includes("weekdays"))return[1,2,3,4,5];const r=s.match(/(mon|tue|wed|thu|fri|sat|sun)[\s/-]*(mon|tue|wed|thu|fri|sat|sun)/);if(r){const n=Ja.find(l=>l.names.includes(r[1]))?.day,o=Ja.find(l=>l.names.includes(r[2]))?.day;if(n!==void 0&&o!==void 0){let l=n;for(;a.add(l),l!==o;)l=(l+1)%7;return Array.from(a)}}return Ja.forEach(({names:n,day:o})=>{n.some(l=>s.includes(l))&&a.add(o)}),Array.from(a).sort((n,o)=>n-o)}const Lm=({classes:t,teacherId:s})=>{const{currentUser:a}=Ks(),[r,n]=p.useState([]),[o,l]=p.useState(!0),[i,c]=p.useState(""),[d,u]=p.useState(()=>{const F=new Date;return F.setHours(0,0,0,0),F}),[N,m]=p.useState(()=>{const F=new Date;return F.setHours(0,0,0,0),F}),[h,w]=p.useState(!1),[k,y]=p.useState(!1),[f,v]=p.useState(""),[S,R]=p.useState(""),[j,B]=p.useState(()=>hs(new Date)),[g,b]=p.useState("09:00"),[T,z]=p.useState("");p.useEffect(()=>{if(!a?.uid){n([]),l(!1);return}c(""),l(!0);const F=Cm(a.uid,{limitCount:500},C=>{n(C),l(!1)},()=>{c("Unable to load calendar events right now."),l(!1)});return()=>F()},[a?.uid]);const $=p.useMemo(()=>{const F=ur(d);return F.setHours(0,0,0,0),F},[d]),Z=p.useMemo(()=>{const F=Vn(d);return F.setHours(23,59,59,999),F},[d]),ae=p.useMemo(()=>{if(!t||t.length===0)return[];const F=[],C=ur(d),K=Vn(d),P=new Date(C);for(;P<=K;){const xe=P.getDay();t.forEach(M=>{Mm(M.schedule).includes(xe)&&F.push({id:`schedule-${M.id}-${hs(P)}`,userId:s||"",title:M.name,startTime:new Date(P),createdAt:new Date})}),P.setDate(P.getDate()+1)}return F},[t,d,s]),H=p.useMemo(()=>[...r,...ae],[r,ae]),ee=p.useMemo(()=>H.filter(F=>F.startTime>=$&&F.startTime<=Z).sort((F,C)=>F.startTime.getTime()-C.startTime.getTime()),[H,$,Z]),re=p.useMemo(()=>{const F=new Map;for(const C of ee){const K=hs(C.startTime),P=F.get(K)||[];P.push(C),F.set(K,P)}return F},[ee]),ne=p.useMemo(()=>hs(N),[N]),D=p.useMemo(()=>[...re.get(ne)||[]].sort((C,K)=>C.startTime.getTime()-K.startTime.getTime()),[re,ne]),te=p.useMemo(()=>{const F=Im(d);return Array.from({length:42}).map((C,K)=>Em(F,K))},[d]),J=F=>{const C=hs(F);v(""),R(""),B(C),b("09:00"),z(""),w(!0)},me=async()=>{if(a?.uid){if(!f.trim()){c("Event title is required.");return}y(!0),c("");try{const F=Kn(j,g),C=T?Kn(j,T):void 0;await Sm(a.uid,{title:f.trim(),description:S.trim()?S.trim():void 0,startTime:F,endTime:C&&C.getTime()>F.getTime()?C:void 0}),w(!1)}catch(F){console.error(F),c("Failed to create event.")}finally{y(!1)}}},Ce=async F=>{c("");try{await km(F)}catch(C){console.error(C),c("Failed to delete event.")}};return e.jsxs(Re.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},exit:{opacity:0,y:-18},className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-secondary text-secondary-foreground flex items-center justify-center flex-shrink-0",children:e.jsx(Yi,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:"Calendar"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Check upcoming class events and schedule"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{variant:"outline",size:"sm",onClick:()=>{const F=new Date;F.setHours(0,0,0,0),u(F),m(F)},children:"Today"}),e.jsxs($e,{size:"sm",onClick:()=>J(N),children:[e.jsx(ma,{}),"Add event"]})]})]}),i&&e.jsx("div",{className:"bg-destructive/10 text-destructive border border-destructive/20 rounded-xl px-4 py-3 text-sm font-body",children:i}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"lg:col-span-8 bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>{const F=new Date(d.getFullYear(),d.getMonth()-1,1);u(F)},"aria-label":"Previous month",children:e.jsx(Pt,{})}),e.jsx("div",{className:"text-sm sm:text-base font-display font-bold text-foreground",children:Am(d)}),e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>{const F=new Date(d.getFullYear(),d.getMonth()+1,1);u(F)},"aria-label":"Next month",children:e.jsx(Wt,{})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-body",children:[ee.length," event",ee.length===1?"":"s"]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-px bg-border",children:[["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(F=>e.jsx("div",{className:"bg-card px-3 py-2 text-xs font-body font-bold text-muted-foreground",children:F},F)),te.map(F=>{const C=hs(F),K=re.get(C)?.length||0,P=qn(F,N),xe=qn(F,new Date),M=Rm(F,d);return e.jsxs("button",{onClick:()=>{const G=new Date(F);G.setHours(0,0,0,0),m(G)},className:"bg-card px-3 py-3 min-h-[78px] text-left transition-colors hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 "+(P?"ring-2 ring-primary/40 ":"")+(M?"":"opacity-50 "),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm font-body font-bold "+(xe?"bg-primary text-primary-foreground ":"text-foreground ")+(P&&!xe?"bg-secondary text-secondary-foreground ":""),children:F.getDate()}),K>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-xs font-body text-muted-foreground",children:K})]})]}),K>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[(re.get(C)||[]).slice(0,3).map(G=>e.jsx("span",{className:"inline-flex items-center rounded-md bg-secondary text-secondary-foreground px-2 py-0.5 text-[10px] font-body font-bold truncate max-w-full",title:G.title,children:G.title},G.id)),(re.get(C)?.length||0)>3&&e.jsxs("span",{className:"text-[10px] font-body text-muted-foreground",children:["+",(re.get(C)?.length||0)-3," more"]})]})]},C)})]}),o&&e.jsxs("div",{className:"px-4 py-4 border-t border-border flex items-center gap-2 text-muted-foreground",children:[e.jsx(nt,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-body",children:"Syncing events…"})]})]}),e.jsxs("div",{className:"lg:col-span-4 bg-card border border-border rounded-2xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-display font-bold text-foreground",children:N.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("div",{className:"text-xs text-muted-foreground font-body",children:N.toLocaleDateString()})]}),e.jsxs($e,{variant:"outline",size:"sm",onClick:()=>J(N),children:[e.jsx(ma,{}),"Add"]})]}),e.jsx("div",{className:"p-4",children:D.length===0?e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-4",children:[e.jsx("div",{className:"text-sm font-body font-bold text-foreground",children:"No events"}),e.jsx("div",{className:"text-xs text-muted-foreground font-body mt-1",children:"Add reminders for quizzes, meetings, or deadlines."})]}):e.jsx("div",{className:"space-y-2",children:D.map(F=>e.jsxs("div",{className:"rounded-xl border border-border bg-background p-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary flex-shrink-0"}),e.jsx("div",{className:"text-sm font-body font-bold text-foreground truncate",children:F.title})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-body mt-1",children:[Yn(F.startTime),F.endTime?` – ${Yn(F.endTime)}`:""]}),F.description&&e.jsx("div",{className:"text-xs text-muted-foreground font-body mt-2 line-clamp-2",children:F.description})]}),e.jsx($e,{variant:"ghost",size:"icon",onClick:()=>Ce(F.id),"aria-label":"Delete event",children:e.jsx(No,{})})]},F.id))})})]})]}),e.jsx(xo,{open:h,onOpenChange:w,children:e.jsxs(ho,{className:"sm:max-w-xl",children:[e.jsxs(po,{children:[e.jsx(fo,{className:"font-display",children:"Add event"}),e.jsx(go,{className:"font-body",children:"Create a reminder for your class schedule."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Title"}),e.jsx(vt,{value:f,onChange:F=>v(F.target.value),placeholder:"e.g., Quiz review session"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Date"}),e.jsx(vt,{type:"date",value:j,onChange:F=>B(F.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Start time"}),e.jsx(vt,{type:"time",value:g,onChange:F=>b(F.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"End time (optional)"}),e.jsx(vt,{type:"time",value:T,onChange:F=>z(F.target.value)})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"text-xs font-body font-bold text-muted-foreground",children:"Notes (optional)"}),e.jsx(Tm,{value:S,onChange:F=>R(F.target.value),placeholder:"Add context: class, room, agenda…",className:"min-h-24"})]})]}),e.jsxs(bo,{children:[e.jsx($e,{variant:"outline",onClick:()=>w(!1),disabled:k,children:"Cancel"}),e.jsx($e,{onClick:me,disabled:k,children:k?e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ma,{}),"Create event"]})})]})]})})]})},fl="PH_SHS_OFFICIAL_CLASS_RECORD",Dm=.85,xr=.85,zm="2026.04.24",gl=4,fa=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],Fm=[...fa,"Pursuant to DepEd Order 8 series of 2015","INITIAL GRADE","QUARTERLY GRADE","ADDITIONAL REMARKS","MALE","FEMALE","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS","LOOK UP","HELPER","ATTACHMENTS"],Bm=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],sa=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],$m=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],Om={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},ps={inputData:["input data"],firstQuarter:["first quarter","1st quarter","q1"],secondQuarter:["second quarter","2nd quarter","q2"],finalSemestral:["final semestral","final grades","semestral"],helper:["helper","weight","attachments"],lookup:["look up","lookup","reference"]},bt={region:["REGION"],division:["DIVISION"],schoolName:["SCHOOL NAME"],schoolId:["SCHOOL ID"],schoolYear:["SCHOOL YEAR"],gradeSection:["GRADE / SECTION","GRADE/SECTION"],semester:["SEMESTER"],track:["TRACK"],subjectCode:["SUBJECT CODE"],subjectName:["SUBJECT NAME","SUBJECT"],teacherName:["TEACHER","NAME OF TEACHER"]},Le={learnerNo:["NO","NO.","#"],learnerName:["LEARNERS NAMES","LEARNER NAME","NAME"],writtenWork:["WRITTEN WORK","WW"],performanceTasks:["PERFORMANCE TASKS","PT"],quarterlyAssessment:["QUARTERLY ASSESSMENT","QA"],total:["TOTAL"],ps:["PS"],ws:["WS"],initialGrade:["INITIAL GRADE"],quarterlyGrade:["QUARTERLY GRADE"],firstQuarter:["FIRST QUARTER","1ST QUARTER"],secondQuarter:["SECOND QUARTER","2ND QUARTER"],firstSemester:["FIRST SEMESTER"],finalGrades:["FINAL GRADES","FINAL GRADE"],remark:["REMARK","REMARKS"],additionalRemarks:["ADDITIONAL REMARKS","ADDITIONAL REMARK"]};function Pm(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function it(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function Xn(t){return it(t).replace(/[^A-Z0-9]+/g,"")}function Se(t,s){const a=it(t),r=it(s);if(!a||!r)return!1;if(a.includes(r))return!0;const n=Xn(t),o=Xn(s);return!n||!o?!1:n.includes(o)}function ga(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const s=t.replace(/,/g,"").trim();if(!s)return;const a=Number(s);if(Number.isFinite(a))return a}}function Za(t){return it(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function bl(t){const s={};return t.forEach(a=>{const r=wt.encode_cell(a.s);for(let n=a.s.r;n<=a.e.r;n+=1)for(let o=a.s.c;o<=a.e.c;o+=1){const l=wt.encode_cell({r:n,c:o});s[l]=r}}),s}function _m(t,s,a){const n=(a||bl(t.merges))[s]||s;return t.cells[n]||t.cells[s]}const vl="A1:A1",Jn=1200,Zn=200,eo=2e5;function Hm(t){const s=Math.max(0,t.s.r),a=Math.max(0,t.s.c);let r=Math.max(s,t.e.r),n=Math.max(a,t.e.c);r-s+1>Jn&&(r=s+Jn-1),n-a+1>Zn&&(n=a+Zn-1);const o=r-s+1,l=n-a+1;if(o*l>eo){const c=Math.max(1,Math.floor(eo/l));r=s+Math.min(o,c)-1}return{s:{r:s,c:a},e:{r,c:n}}}function Gm(t){try{return wt.decode_range(t)}catch{return wt.decode_range(vl)}}function Qm(t){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return Object.keys(t.cells).forEach(o=>{try{const l=wt.decode_cell(o);s=Math.min(s,l.r),a=Math.min(a,l.c),r=Math.max(r,l.r),n=Math.max(n,l.c)}catch{}}),t.merges.forEach(o=>{s=Math.min(s,o.s.r,o.e.r),a=Math.min(a,o.s.c,o.e.c),r=Math.max(r,o.s.r,o.e.r),n=Math.max(n,o.s.c,o.e.c)}),!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)?null:{s:{r:Math.max(0,Math.trunc(s)),c:Math.max(0,Math.trunc(a))},e:{r:Math.max(0,Math.trunc(r)),c:Math.max(0,Math.trunc(n))}}}function Um(t){const s=Gm(t.ref||vl),a=Qm(t);return Hm(a||s)}function Wm(t,s){const a=Um(s),r=`${wt.encode_cell(a.s)}:${wt.encode_cell(a.e)}`,n=bl(s.merges),o=a.e.r-a.s.r+1,l=a.e.c-a.s.c+1,i=[];for(let c=0;ct.endRow||at.endCol?null:t.cells[s-t.startRow]?.[a-t.startCol]??null}function Zt(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function Ls(t){return wt.encode_col(t)}function da(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return wt.decode_col(s)}catch{return-1}}function Vm(t){return`${wt.encode_cell(t.s)}:${wt.encode_cell(t.e)}`}function qm(t,s){const a=[];for(let r=s.s.r;r<=s.e.r;r+=1){const n=[];for(let o=s.s.c;o<=s.e.c;o+=1){const l=ze(t,r,o);n.push(l?.displayValue??null)}a.push(n)}return a}function Ym(t,s){const a=it(t),r=it(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function Mr(t,s){const a=[];for(let r=0;r{Se(i.normalizedText,c)&&a.push({sheetName:t.sheetName,anchor:c,row:i.row,col:i.col,address:i.address,value:String(i.displayValue??""),confidence:Ym(i.displayValue,c)})})}const n=t.startRow+r,o=Zt(t,n);o&&s.forEach(l=>{if(!Se(o,l))return;const i=t.cells[r].find(c=>c?.normalizedText);i&&a.push({sheetName:t.sheetName,anchor:l,row:n,col:i.col,address:i.address,value:o,confidence:.8})})}return a}function Km(t,s){return Object.values(t).flatMap(a=>Mr(a,s))}function dt(t,s){return Mr(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function Nl(t,s,a,r=6){for(let n=1;n<=r;n+=1){const l=ze(t,s,a+n)?.displayValue;if(l!=null&&String(l).trim())return String(l).trim()}for(let n=1;n<=r;n+=1){const l=ze(t,s+n,a)?.displayValue;if(l!=null&&String(l).trim())return String(l).trim()}}function jl(t,s,a=5){let r=s,n=-1;for(let o=Math.max(t.startRow,s-a);o<=Math.min(t.endRow,s+a);o+=1){const l=Zt(t,o),i=["LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK"].reduce((c,d)=>l.includes(d)?c+1:c,0);i>n&&(n=i,r=o)}return r}function Xm(t,s){const a=it(t).toLowerCase(),r=n=>[...s].some(o=>Se(o,n));return ps.inputData.some(n=>a.includes(n))||r("INPUT DATA")?"inputData":ps.finalSemestral.some(n=>a.includes(n))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":ps.firstQuarter.some(n=>a.includes(n))||r("FIRST QUARTER")?"firstQuarter":ps.secondQuarter.some(n=>a.includes(n))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":ps.helper.some(n=>a.includes(n))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":ps.lookup.some(n=>a.includes(n))||r("LOOK UP")?"lookup":"other"}function Jm(t){const s=t.criticalTotal>0?t.criticalFound/t.criticalTotal:0,a=t.totalSheets>0?t.recognizedSheets/t.totalSheets:0,r=t.hasDepedAnchor?1:0,n=.65*s+.2*a+.15*r;return Number(Math.max(0,Math.min(1,n)).toFixed(4))}function Zm(t){const s=Km(t.matrices,Fm),a=new Set,r=[];fa.forEach(h=>{s.some(k=>Se(k.anchor,h))&&(a.add(h),r.push(`Found critical anchor: ${h}`))});const n=fa.filter(h=>!a.has(h)),o=new Map;s.forEach(h=>{o.has(h.sheetName)||o.set(h.sheetName,new Set),o.get(h.sheetName)?.add(h.anchor)});const l=t.sheetNames.map(h=>{const w=o.get(h)||new Set,k=Xm(h,w),y=Math.min(1,.35+Math.min(.55,w.size*.08)),f=[`sheet:${h}`,`signals:${w.size}`,...[...w].slice(0,5)];return{sheetName:h,role:k,confidence:Number(y.toFixed(3)),evidence:f}}),i={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};l.forEach(h=>{switch(h.role){case"inputData":i.inputData?i.other.push(h.sheetName):i.inputData=h.sheetName;break;case"firstQuarter":i.firstQuarter.push(h.sheetName);break;case"secondQuarter":i.secondQuarter.push(h.sheetName);break;case"finalSemestral":i.finalSemestral.push(h.sheetName);break;case"helper":i.helper.push(h.sheetName);break;case"lookup":i.lookup.push(h.sheetName);break;case"other":default:i.other.push(h.sheetName);break}});const c=(i.inputData?1:0)+i.firstQuarter.length+i.secondQuarter.length+i.finalSemestral.length+i.helper.length+i.lookup.length,d=Jm({criticalFound:a.size,criticalTotal:fa.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(h=>Se(h.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),u=i.firstQuarter.length>0||i.secondQuarter.length>0,N=!!i.inputData&&u&&i.finalSemestral.length>0,m=d>=.55&&N;return i.inputData||r.push("Input Data sheet not confidently detected."),u||r.push("No quarter class record sheet detected."),i.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:fl,isOfficialFormatLikely:m,confidence:d,evidence:r,missingCriticalAnchors:n,detectedSheets:i,anchorMatches:s}}function Sa(t){if(typeof t=="number"&&Number.isFinite(t))return t;const s=String(t??"").trim();if(!s)return;const a=Number(s.replace(/[^0-9]/g,""));if(!(!Number.isFinite(a)||a<=0))return a}function Lr(t){const s=it(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function Dr(t){const s=it(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":Bm.some(a=>s.includes(a))?"signature":$m.some(a=>s.includes(a))?"helper":s.includes("LEARNERS NAMES")||s.includes("WRITTEN WORK")||s.includes("PERFORMANCE TASKS")||s.includes("QUARTERLY ASSESSMENT")||s.includes("INITIAL GRADE")||s.includes("QUARTERLY GRADE")?"header":t.hasLearnerName||t.hasLearnerNumber?"learner":s.includes("ATTACHMENTS")||s.includes("LOOK UP")?"helper":"unknown":"blank"}function eu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{a.push({role:r,name:String(ze(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function tu(t){const s=[],a=dt(t,"LEARNERS NAMES")[0],r=a?jl(t,a.row,5):t.startRow,n=(y,f)=>dt(t,y).find(S=>Math.abs(S.row-r)<=2)?.col??f,o=n(Le.learnerNo[0],t.startCol),l=n(Le.learnerName[0],t.startCol+1),i=n(Le.firstQuarter[0],l+1),c=n(Le.secondQuarter[0],i+1),d=n(Le.firstSemester[0],c+1),u=n(Le.finalGrades[0],d+1),N=n(Le.remark[0],u+1),m=n(Le.additionalRemarks[0],N+1),h=[];let w="UNKNOWN",k=0;for(let y=r+1;y<=t.endRow;y+=1){const f=Zt(t,y),v=Dr({rowText:f,hasLearnerNumber:/\b\d{1,2}\b/.test(f),hasLearnerName:/[A-Z]{2,}/.test(f)});if(v==="sex-header"){w=Lr(f)||w;continue}if(v==="signature"||v==="helper")break;if(v==="blank"){if(k+=1,k>=gl)break;continue}if(v!=="learner")continue;k=0;const S=Sa(ze(t,y,o)?.displayValue),R=String(ze(t,y,l)?.displayValue||"").trim();if(!R&&S===void 0)continue;const j=ze(t,y,i)?.displayValue??null,B=ze(t,y,c)?.displayValue??null,g=ze(t,y,d)?.displayValue??null,b=ze(t,y,u)?.displayValue??null,T=ze(t,y,N)?.displayValue??null;let z=ze(t,y,m)?.displayValue??null;const $=sa.filter(Z=>Se(f,Z));$.length>0&&(z=[z,$.join("; ")].filter(Boolean).join("; ")||null),!R&&S!==void 0&&s.push(`Row ${y+1} has learner number ${S} but empty learner name.`),h.push({learnerNo:S,fullName:R||`Unnamed Learner ${S||y+1}`,sex:w,firstQuarter:j,secondQuarter:B,firstSemester:g,finalGrades:b,remark:T,additionalRemarks:z,sourceRow:y+1})}return{sheetName:t.sheetName,learnerGrades:h,signatures:eu(t),warnings:s}}function Ct(t,s){for(const a of s){const r=dt(t,a);for(const n of r){const o=Nl(t,n.row,n.col,8);if(o&&o.trim())return o.trim()}}}function su(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(o=>{const l=Nl(t,o.row,o.col,10);a.push({role:r,name:l,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function au(t){const s=dt(t,"LEARNERS NAMES")[0];if(!s)return[];const a=s.row+1,r=s.col,n=Math.max(t.startCol,r-1),o=Math.min(t.endCol,r+1),l=Math.min(t.endCol,r+2),i=[];let c="UNKNOWN",d=0;for(let u=a;u<=t.endRow;u+=1){const N=Zt(t,u),m=Dr({rowText:N,hasLearnerNumber:!!Sa(ze(t,u,n)?.displayValue),hasLearnerName:!!String(ze(t,u,r)?.displayValue||"").trim()});if(m==="sex-header"){c=Lr(N)||c,d=0;continue}if(m==="signature"||m==="helper")break;if(m!=="learner"){if(m==="blank"&&(d+=1),d>=5)break;continue}d=0;const h=Sa(ze(t,u,n)?.displayValue),w=String(ze(t,u,r)?.displayValue||"").trim(),k=String(ze(t,u,o)?.displayValue||"").trim()||void 0,y=String(ze(t,u,l)?.displayValue||"").trim()||void 0,f=sa.filter(v=>Se(N,v));!w&&h===void 0||i.push({learnerNo:h,sex:c,fullName:w||`Unnamed Learner ${h||u}`,sourceSheet:t.sheetName,sourceRow:u+1,remarks:k,additionalRemarks:y,statuses:f.length>0?f:void 0})}return i}function ru(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const n=Zt(t,r);if(n){if(sa.some(o=>Se(n,o))){s.push(n);continue}(Se(n,"IMPORTANT")||Se(n,"NOTE")||Se(n,"ATTACHMENT")||Se(n,"LOOK UP"))&&a.push(n)}}return{attachmentRules:Array.from(new Set(s)),helperNotes:Array.from(new Set(a))}}function nu(t){const s=[],a={region:Ct(t,bt.region),division:Ct(t,bt.division),schoolName:Ct(t,bt.schoolName),schoolId:Ct(t,bt.schoolId),schoolYear:Ct(t,bt.schoolYear),gradeSection:Ct(t,bt.gradeSection),semester:Ct(t,bt.semester),track:Ct(t,bt.track),subjectCode:Ct(t,bt.subjectCode),subjectName:Ct(t,bt.subjectName),teacherName:Ct(t,bt.teacherName)},r=au(t),n=su(t),{attachmentRules:o,helperNotes:l}=ru(t);return a.schoolName||s.push("Input Data metadata is missing School Name."),a.schoolYear||s.push("Input Data metadata is missing School Year."),r.length===0&&s.push("No learners detected in Input Data sheet."),Mr(t,Object.values(bt).flat()).length<4&&s.push("Input Data sheet contains limited metadata anchors; layout may have drifted."),{sheetName:t.sheetName,schoolContext:a,learners:r,signatures:n,attachmentRules:o,helperNotes:l,warnings:s}}function ou(t){const s=it(t.sheetName);return Om.SECOND.some(a=>Se(s,a))?"SECOND":"FIRST"}function lu(t,s){const a=[],r=[],n=[];let o,l="NONE";for(let i=t.startCol;i<=t.endCol;i+=1){const c=ze(t,s,i),d=it(c?.displayValue||""),u=ze(t,s+1,i),N=String(u?.displayValue||c?.displayValue||"").trim();if(!d&&!N)continue;if(Se(d,Le.writtenWork[0])){l="WW";continue}if(Se(d,Le.performanceTasks[0])){l="PT";continue}if(Se(d,Le.quarterlyAssessment[0])){o={key:Za(N||"quarterly_assessment"),label:N||"Quarterly Assessment",column:Ls(i)},l="DERIVED";continue}if(Se(d,Le.initialGrade[0])||Se(d,Le.quarterlyGrade[0])||Se(d,Le.remark[0])||Se(d,Le.additionalRemarks[0])||Se(d,Le.firstQuarter[0])||Se(d,Le.secondQuarter[0])||Se(d,Le.firstSemester[0])||Se(d,Le.finalGrades[0])||Se(d,Le.ps[0])||Se(d,Le.ws[0])||Se(d,Le.total[0])){l="DERIVED",n.push({key:Za(N||d),label:N||d,column:Ls(i)});continue}const m={key:Za(N||d||Ls(i)),label:N||d||Ls(i),maxScore:ga(u?.displayValue),column:Ls(i)};l==="WW"?a.push(m):l==="PT"?r.push(m):l==="DERIVED"&&n.push(m)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:o,derived:n}}function iu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{const o=ze(t,n.row,n.col+1),l=String(o?.displayValue||"").trim()||void 0;a.push({role:r,name:l,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function to(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const n=it(ze(t,s,r)?.displayValue||""),o=it(ze(t,s+1,r)?.displayValue||"");if(a.some(l=>Se(n,l)||Se(o,l)))return r}}function cu(t,s,a,r){const n={learnerNo:Sa(ze(t,s,r.numberCol)?.displayValue),fullName:String(ze(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},o={};a.writtenWorks.forEach(d=>{const u=d.column?da(d.column):-1;if(u<0)return;const N=ze(t,s,u)?.displayValue;o[d.key]=N??null}),Object.keys(o).length>0&&(n.writtenWorks=o);const l={};if(a.performanceTasks.forEach(d=>{const u=d.column?da(d.column):-1;if(u<0)return;const N=ze(t,s,u)?.displayValue;l[d.key]=N??null}),Object.keys(l).length>0&&(n.performanceTasks=l),a.quarterlyAssessment?.column){const d=da(a.quarterlyAssessment.column);n.quarterlyAssessment=ze(t,s,d)?.displayValue??null}const i=a.derived||[],c={};return i.forEach(d=>{if(!d.column)return;const u=da(d.column);if(u<0)return;const N=ze(t,s,u)?.displayValue??null;c[d.key]=N,Se(d.label,Le.initialGrade[0])&&(n.initialGrade=N),Se(d.label,Le.quarterlyGrade[0])&&(n.quarterlyGrade=N),Se(d.label,Le.firstQuarter[0])&&(n.firstQuarter=N),Se(d.label,Le.secondQuarter[0])&&(n.secondQuarter=N),Se(d.label,Le.firstSemester[0])&&(n.firstSemester=N),Se(d.label,Le.finalGrades[0])&&(n.finalGrades=N),Se(d.label,Le.remark[0])&&(n.remark=N!==null?String(N):null),Se(d.label,Le.additionalRemarks[0])&&(n.additionalRemarks=N!==null?String(N):null)}),Object.keys(c).length>0&&(n.totals=c),n}function du(t){const s=ou(t),a=[],r=dt(t,Le.learnerName[0])[0]||dt(t,Le.learnerName[1])[0],n=r?jl(t,r.row,4):t.startRow,o=lu(t,n),l=to(t,n,Le.learnerNo)??t.startCol,i=to(t,n,Le.learnerName)??Math.min(t.endCol,l+1),c=[];let d="UNKNOWN",u=0;for(let w=n+1;w<=t.endRow;w+=1){const k=Zt(t,w),y=Dr({rowText:k,hasLearnerNumber:/\b\d{1,2}\b/.test(k),hasLearnerName:/[A-Z]{2,}/.test(k)});if(y==="sex-header"){d=Lr(k)||d;continue}if(y==="signature"||y==="helper")break;if(y==="blank"){if(u+=1,u>=gl)break;continue}if(y!=="learner")continue;u=0;const f=cu(t,w,o,{numberCol:l,nameCol:i});if(f.sex=d,!f.fullName&&f.learnerNo===void 0)continue;const v=sa.filter(S=>Se(k,S));v.length>0&&!f.additionalRemarks&&(f.additionalRemarks=v.join("; ")),!f.fullName&&f.learnerNo!==void 0&&(a.push(`Row ${w+1} has learner number ${f.learnerNo} but empty name.`),f.fullName=`Unnamed Learner ${f.learnerNo}`),c.push(f)}o.writtenWorks.length===0&&o.performanceTasks.length===0&&a.push(`No detailed assessment columns detected in ${t.sheetName}.`);const N=ga(dt(t,"WRITTEN WORK %")[0]?.value||dt(t,"WRITTEN WORK")[0]?.value),m=ga(dt(t,"PERFORMANCE TASKS %")[0]?.value||dt(t,"PERFORMANCE TASKS")[0]?.value),h=ga(dt(t,"QUARTERLY ASSESSMENT %")[0]?.value||dt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:N,performanceTasks:m,quarterlyAssessment:h},assessmentColumns:o,learnerGrades:c,signatures:iu(t),warnings:a}}function mu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{dt(t,r).forEach(n=>{a.push({role:r,name:String(ze(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function uu(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const n=Zt(t,r);if(!n){if(a&&s.length>0)break;continue}if(Se(n,"WEIGHT OF COMPONENTS")){a=!0;continue}if(!a)continue;const o={sourceRow:r+1,raw:n};for(let l=t.startCol;l<=t.endCol;l+=1){const i=ze(t,r,l)?.displayValue;i==null||String(i).trim()===""||(o[`c${l}`]=i)}Object.keys(o).length>2&&s.push(o)}return s}function xu(t){const s=[],a=[],r=[],n=[],o=[];return t.forEach(l=>{mu(l).forEach(i=>a.push(i)),uu(l).forEach(i=>r.push({...i,sourceSheet:l.sheetName}));for(let i=l.startRow;i<=l.endRow;i+=1){const c=Zt(l,i);if(c){if(sa.some(d=>Se(c,d))){n.push(`${l.sheetName}: ${c}`);continue}(Se(c,"HELPER")||Se(c,"LOOK UP")||Se(c,"IMPORTANT")||Se(c,"REFERENCE")||Se(c,"ATTACHMENT"))&&o.push(`${l.sheetName}: ${c}`)}}}),r.length===0&&s.push("No component weight rows were parsed from reference sheets."),{sheetName:t.map(l=>l.sheetName).join(", "),componentWeights:r,attachmentRules:Array.from(new Set(n)),helperNotes:Array.from(new Set(o)),signatures:a,warnings:s}}function hu(t,s,a){const r=new Map,n=o=>{const l=`${it(o.fullName)}|${o.learnerNo||""}|${o.sourceSheet}`,i=r.get(l);if(!i){r.set(l,o);return}const c=Array.from(new Set([...i.statuses||[],...o.statuses||[]]));r.set(l,{...i,...o,remarks:o.remarks||i.remarks,additionalRemarks:o.additionalRemarks||i.additionalRemarks,statuses:c.length>0?c:void 0})};return t.forEach(n),s.forEach(o=>{o.learnerGrades.forEach(l=>{n({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:o.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})})}),a.forEach(o=>{o.learnerGrades.forEach(l=>{n({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:o.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})})}),Array.from(r.values())}function pu(t,s,a,r){const n=[...t.signatures,...s.flatMap(l=>l.signatures),...a.flatMap(l=>l.signatures),...r.signatures],o=new Map;return n.forEach(l=>{const i=`${it(l.role)}|${it(l.name||"")}|${l.sourceSheet}`;o.set(i,l)}),Array.from(o.values())}function fu(t){const s=hu(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:fl,version:zm,workbookMeta:{fileName:t.workbook.fileName,sheetNames:t.workbook.sheetNames,detectedSheets:{inputData:t.detection.detectedSheets.inputData,firstQuarter:t.detection.detectedSheets.firstQuarter,secondQuarter:t.detection.detectedSheets.secondQuarter,finalSemestral:t.detection.detectedSheets.finalSemestral,helper:t.detection.detectedSheets.helper,lookup:t.detection.detectedSheets.lookup,other:t.detection.detectedSheets.other}},schoolContext:{...t.inputData.schoolContext},learners:s,quarterlyRecords:t.quarterSheets.map(a=>({sheetName:a.sheetName,quarter:a.quarter,gradingWeights:a.gradingWeights,assessmentColumns:a.assessmentColumns,learnerGrades:a.learnerGrades})),finalSemestralRecords:t.finalSheets.map(a=>({sheetName:a.sheetName,learnerGrades:a.learnerGrades})),references:{componentWeights:t.references.componentWeights,attachmentRules:Array.from(new Set([...t.inputData.attachmentRules||[],...t.references.attachmentRules||[]])),helperNotes:Array.from(new Set([...t.inputData.helperNotes||[],...t.references.helperNotes||[]])),signatures:pu(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function gu(t){return!t||t.length===0?[]:t.map(s=>({s:{r:s.s.r,c:s.s.c},e:{r:s.e.r,c:s.e.c}}))}function bu(t){const s={ref:t["!ref"],merges:gu(t["!merges"]),cells:{}};return Object.keys(t).filter(a=>!a.startsWith("!")).forEach(a=>{const r=t[a];!r||!(r.v!==void 0||typeof r.w=="string"&&r.w.trim().length>0||typeof r.f=="string"&&r.f.trim().length>0)||(s.cells[a]={v:r.v,w:r.w,t:r.t,f:r.f})}),s}function vu(t,s){const a=Pi(s,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0,raw:!1}),r={},n={};return a.SheetNames.forEach(o=>{const l=a.Sheets[o];if(!l)return;const i=bu(l);n[o]=i,r[o]=Wm(o,i)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:n},matrices:r}}async function Nu(t){const s=await t.arrayBuffer();return vu(t.name,s)}class ju{state={};markRange(s,a,r){const n=s;this.state[n]||(this.state[n]={mappedAddresses:new Set,mappings:[]});for(let o=a.s.r;o<=a.e.r;o+=1)for(let l=a.s.c;l<=a.e.c;l+=1)this.state[n].mappedAddresses.add(`${o}:${l}`);this.state[n].mappings.push({sheetName:s,range:a,reason:r})}getMappings(){return Object.values(this.state).flatMap(s=>s.mappings)}getMappedRegionCount(){return this.getMappings().length}getUnmappedBlocks(s,a="unclassified"){const r=[];return Object.values(s).forEach(n=>{const o=new Set,l=this.state[n.sheetName]?.mappedAddresses??new Set;for(let i=n.startRow;i<=n.endRow;i+=1)for(let c=n.startCol;c<=n.endCol;c+=1){const d=`${i}:${c}`;if(o.has(d)||l.has(d))continue;const u=ze(n,i,c);if(!(u&&u.displayValue!==null&&u.displayValue!==void 0&&String(u.displayValue).trim())){o.add(d);continue}const m=this.collectComponent(n,i,c,l,o);m&&r.push({sheetName:n.sheetName,range:Vm(m),purposeGuess:a,raw2D:qm(n,m)})}}),r}collectComponent(s,a,r,n,o){const l=[{row:a,col:r}];let i=a,c=a,d=r,u=r,N=!1;for(;l.length>0;){const m=l.shift();if(!m)break;const h=`${m.row}:${m.col}`;if(o.has(h)||n.has(h))continue;o.add(h);const w=ze(s,m.row,m.col);w&&w.displayValue!==null&&w.displayValue!==void 0&&String(w.displayValue).trim()&&(N=!0,i=Math.min(i,m.row),c=Math.max(c,m.row),d=Math.min(d,m.col),u=Math.max(u,m.col),[{row:m.row-1,col:m.col},{row:m.row+1,col:m.col},{row:m.row,col:m.col-1},{row:m.row,col:m.col+1}].forEach(y=>{y.rows.endRow||y.cols.endCol||l.push(y)}))}return N?{s:{r:i,c:d},e:{r:c,c:u}}:null}}function yu(t){const s=t.detection.detectedSheets,a=[s.inputData?1:0,s.firstQuarter.length,s.secondQuarter.length,s.finalSemestral.length,s.helper.length,s.lookup.length].reduce((r,n)=>r+n,0);return{totalSheets:t.totalSheets,recognizedSheets:a,unclassifiedSheets:s.other.length,mappedCellRegions:t.mappedCellRegions,unmappedCellRegions:t.unmappedCellRegions}}function wu(t){const s=new Map;t.forEach(r=>{const n=`${r.learnerNo||""}|${r.fullName.trim().toUpperCase()}`;s.has(n)||s.set(n,[]),s.get(n)?.push(r.sourceRow)});const a=[];return s.forEach((r,n)=>{r.length>1&&a.push(`Duplicate learner entry detected for ${n} at rows ${r.join(", ")}.`)}),a}function Su(t){const s=[];return t.forEach(a=>{a.learnerGrades.forEach(r=>{r.fullName.trim()||s.push(`${a.sheetName} row ${r.sourceRow}: learner name is blank.`);const n=r.writtenWorks&&Object.values(r.writtenWorks).some(l=>l!==null&&l!==""),o=r.performanceTasks&&Object.values(r.performanceTasks).some(l=>l!==null&&l!=="");!n&&!o&&r.quarterlyAssessment==null&&s.push(`${a.sheetName} row ${r.sourceRow}: all grade blocks are empty.`)})}),s}function ku(t){const s=[];return t.forEach(a=>{a.learnerGrades.forEach(r=>{r.fullName.trim()||s.push(`${a.sheetName} row ${r.sourceRow}: learner name is blank.`),r.finalGrades==null&&r.firstSemester==null&&r.firstQuarter==null&&r.secondQuarter==null&&s.push(`${a.sheetName} row ${r.sourceRow}: no semestral/final values detected.`)})}),s}function Cu(t){const s=[],a=[];t.detection.detectedSheets.inputData||a.push("Missing Input Data sheet."),t.quarterSheets.length===0&&a.push("No quarter class record sheets were extracted."),t.finalSheets.length===0&&a.push("No Final Semestral sheet was extracted."),t.detection.missingCriticalAnchors.length>0&&s.push(`Missing critical anchors: ${t.detection.missingCriticalAnchors.join(", ")}.`),wu(t.inputData.learners).forEach(o=>s.push(o)),Su(t.quarterSheets).forEach(o=>s.push(o)),ku(t.finalSheets).forEach(o=>s.push(o)),s.push(...t.inputData.warnings),t.quarterSheets.forEach(o=>s.push(...o.warnings)),t.finalSheets.forEach(o=>s.push(...o.warnings)),t.unmappedCellRegions>t.mappedCellRegions&&s.push("A significant portion of workbook regions are unclassified; review diagnostics before confirming import.");const r=t.detection.confidence,n=t.detection.isOfficialFormatLikely&&a.length===0;return r({fullName:l.fullName,learnerNo:l.learnerNo,sex:l.sex,remarks:l.remarks,additionalRemarks:l.additionalRemarks,statuses:l.statuses,sourceSheet:l.sourceSheet,sourceRow:l.sourceRow})),r=t.quarterlyRecords.flatMap(l=>l.learnerGrades.map(i=>({fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,quarter:l.quarter,firstQuarter:i.firstQuarter,secondQuarter:i.secondQuarter,firstSemester:i.firstSemester,finalGrades:i.finalGrades,quarterlyGrade:i.quarterlyGrade,initialGrade:i.initialGrade,remark:i.remark,additionalRemarks:i.additionalRemarks}))),n=t.finalSemestralRecords.flatMap(l=>l.learnerGrades.map(i=>({fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,firstQuarter:i.firstQuarter,secondQuarter:i.secondQuarter,firstSemester:i.firstSemester,finalGrades:i.finalGrades,remark:i.remark,additionalRemarks:i.additionalRemarks}))),o=[...t.learners,...t.quarterlyRecords.flatMap(l=>l.learnerGrades.map(i=>({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:l.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})))].map(l=>({fullName:l.fullName,remark:l.remarks||null,additionalRemarks:l.additionalRemarks||null,statuses:"statuses"in l?l.statuses:void 0,sourceSheet:l.sourceSheet,sourceRow:l.sourceRow}));return{classEntity:s,studentEntities:a,gradeEntities:[...r,...n],remarksEntities:o}}const so=1500;function ao(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function ro(t){const s=`[shs-import] parse ${t.stage} file=${t.fileName} duration=${t.durationMs}ms sheets=${t.sheetCount} matrixCells=${t.matrixCellCount}`;if(t.stage==="failed"){console.error(`${s}${t.errorMessage?` error=${t.errorMessage}`:""}`);return}if(t.durationMs>=so){console.warn(`${s} slow=true threshold=${so}ms`);return}}function as(t,s){t?.onProgress?.(s)}function Iu(t,s){return Array.from(new Set(t.filter(a=>Number.isFinite(a)).map(a=>Math.max(s.startRow,Math.min(s.endRow,Math.trunc(a))))))}function Ds(t,s,a,r){Iu(a,s).forEach(n=>{t.markRange(s.sheetName,{s:{r:n,c:s.startCol},e:{r:n,c:s.endCol}},r)})}async function Eu(t,s){const a=s?.confidenceThreshold??Dm,r=Date.now();let n=null;try{if(as(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),n=await Nu(t),!n)throw new Error("Workbook read returned null");as(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const o=Zm(n);as(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const l=o.detectedSheets.inputData||n.sheetNames[0],i=n.matrices[l],c=i?nu(i):{sheetName:l,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},u=[...o.detectedSheets.firstQuarter||[],...o.detectedSheets.secondQuarter||[]].map(S=>n.matrices[S]).filter(S=>!!S).map(S=>du(S)),N=(o.detectedSheets.finalSemestral||[]).map(S=>n.matrices[S]).filter(S=>!!S).map(S=>tu(S)),m=[...o.detectedSheets.helper||[],...o.detectedSheets.lookup||[]].map(S=>n.matrices[S]).filter(S=>!!S),h=xu(m),w=new ju;o.anchorMatches.forEach(S=>{const R=n.matrices[S.sheetName];R&&Ds(w,R,[S.row],`Anchor match: ${S.anchor}`)}),[c.sheetName].forEach(S=>{const R=n.matrices[S];if(!R)return;const j=Array.from({length:Math.min(14,R.rowCount)},(b,T)=>R.startRow+T),B=c.learners.map(b=>b.sourceRow-1),g=c.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1);Ds(w,R,[...j,...B,...g],"Input Data parsed rows")}),u.forEach(S=>{const R=n.matrices[S.sheetName];if(!R)return;const j=S.learnerGrades.map(b=>b.sourceRow-1),B=S.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1),g=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Ds(w,R,[g,g+1,...j,...B],"Quarter sheet parsed rows")}),N.forEach(S=>{const R=n.matrices[S.sheetName];if(!R)return;const j=S.learnerGrades.map(b=>b.sourceRow-1),B=S.signatures.map(b=>b.sourceRow).filter(b=>typeof b=="number").map(b=>b-1),g=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Ds(w,R,[g,g+1,...j,...B],"Final semestral parsed rows")}),m.forEach(S=>{const R=h.componentWeights.filter(g=>g.sourceSheet===S.sheetName).map(g=>g.sourceRow).filter(g=>typeof g=="number").map(g=>g-1),j=h.signatures?.filter(g=>g.sourceSheet===S.sheetName).map(g=>g.sourceRow).filter(g=>typeof g=="number").map(g=>g-1)||[],B=R.length===0&&j.length===0?[S.startRow,S.startRow+1,S.startRow+2]:[];Ds(w,S,[...R,...j,...B],"Reference/helper parsed rows")});const k=w.getUnmappedBlocks(n.matrices);as(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const y=Cu({detection:o,inputData:c,quarterSheets:u,finalSheets:N,mappedCellRegions:w.getMappedRegionCount(),unmappedCellRegions:k.length,totalSheets:n.sheetNames.length});as(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const f=fu({workbook:n,detection:o,inputData:c,quarterSheets:u,finalSheets:N,references:h,validation:y,unclassifiedBlocks:k});f.validation.confidence{const o=Ru[t??"null"],l=o.icon,i=r&&s!==null&&s!==void 0?`${o.label} ${s}`:o.label;return e.jsxs("span",{className:`inline-flex items-center rounded-full border font-medium transition-colors ${o.color} ${Au[a]} ${n}`,title:`WRI: ${s??"N/A"} — ${o.description}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${o.dotColor}`}),e.jsx(l,{className:"flex-shrink-0",size:a==="sm"?10:a==="md"?12:14}),i]})},Mu="https://deign86-mathpulse-api-v3test.hf.space";async function Lu(t){const s=et(Ge,"managedStudents",t),a=await ns(s);if(!a.exists())return null;const r=a.data();return{wri:r.wri??null,riskStatus:r.riskStatus??null,riskUpdatedAt:r.riskUpdatedAt?r.riskUpdatedAt.toDate():null,weights:r.weights??{w1:.3,w2:.4,w3:.3},diagnosticScore:r.diagnosticScore??null,externalGradesAvg:r.externalGradesAvg??null,systemPerformanceAvg:r.systemPerformanceAvg??null,riskHistory:r.riskHistory??[],riskRecalcNeeded:r.riskRecalcNeeded??!1}}async function wl(t,s,a="manual"){const r=et(Ge,"managedStudents",t),n={wri:s.wri??0,riskStatus:s.risk_status,computedAt:new Date,trigger:a},o=s.risk_status==="pending_assessment"?null:s.risk_status;await yt(r,{wri:s.wri,riskStatus:o,riskUpdatedAt:ot(),riskHistory:hi(n),riskRecalcNeeded:!1,diagnosticScore:s.inputs.D,externalGradesAvg:s.inputs.G,systemPerformanceAvg:s.inputs.P})}async function Sl(t,s,a,r={w1:.3,w2:.4,w3:.3}){try{const n=new AbortController,o=setTimeout(()=>n.abort(),3e4),l=await fetch(`${Mu}/api/risk/compute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({d:t,g:s,p:a,weights:r}),signal:n.signal});if(clearTimeout(o),!l.ok)throw new Error(`API error: ${l.status}`);return await l.json()}catch{return Du(t,s,a,r)}}function Du(t,s,a,r){if(t===null)return{wri:null,risk_status:"pending_assessment",inputs:{D:t,G:s,P:a},g_fallback:!1,p_fallback:!1};const n=s??t,o=a??t,l=s===null,i=a===null,c=Math.round((r.w1*t+r.w2*n+r.w3*o)*100)/100;let d;return c>=88?d="safe":c>=80?d="watch":c>=75?d="intervene":c>=68?d="critical":d="at_risk",{wri:c,risk_status:d,inputs:{D:t,G:n,P:o},g_fallback:l,p_fallback:i}}async function no(t){const s=await Lu(t);if(!s)throw new Error(`Student ${t} not found`);const a=await Sl(s.diagnosticScore??null,s.externalGradesAvg??null,s.systemPerformanceAvg??null,s.weights??{w1:.3,w2:.4,w3:.3});await wl(t,a,"manual")}function zu(t,s={}){const{autoRecalc:a=!1}=s,[r,n]=p.useState(null),[o,l]=p.useState(!0),[i,c]=p.useState(null);p.useEffect(()=>{if(!t){n(null),l(!1);return}const N=et(Ge,"managedStudents",t);return Xs(N,h=>{if(!h.exists()){n(null),l(!1);return}const w=h.data(),k={wri:w.wri??null,riskStatus:w.riskStatus??null,riskUpdatedAt:w.riskUpdatedAt?w.riskUpdatedAt.toDate():null,weights:w.weights??{w1:.3,w2:.4,w3:.3},diagnosticScore:w.diagnosticScore??null,externalGradesAvg:w.externalGradesAvg??null,systemPerformanceAvg:w.systemPerformanceAvg??null,riskHistory:w.riskHistory??[],riskRecalcNeeded:w.riskRecalcNeeded??!1};n(k),l(!1),c(null),a&&k.riskRecalcNeeded&&no(t).catch(y=>console.error("[useStudentRisk] auto-recalc failed:",y))},h=>{console.error("[useStudentRisk] snapshot error:",h),c(h instanceof Error?h.message:"Unknown error"),l(!1)})},[t,a]);const d=p.useCallback(async()=>{if(t){l(!0);try{await no(t)}catch(N){c(N instanceof Error?N.message:"Recalculation failed")}finally{l(!1)}}},[t]),u=p.useCallback(async N=>{if(!t||!r)return;n(h=>h&&{...h,weights:N});const m=await Sl(r.diagnosticScore??null,r.externalGradesAvg??null,r.systemPerformanceAvg??null,N);await wl(t,m,"manual")},[t,r]);return{wri:r?.wri??null,riskStatus:r?.riskStatus??null,diagnosticScore:r?.diagnosticScore??null,externalGradesAvg:r?.externalGradesAvg??null,systemPerformanceAvg:r?.systemPerformanceAvg??null,weights:r?.weights??{w1:.3,w2:.4,w3:.3},riskHistory:r?.riskHistory??[],riskUpdatedAt:r?.riskUpdatedAt??null,loading:o,error:i,recalculate:d,updateWeights:u,breakdown:{diagnostic:r?.diagnosticScore??null,external:r?.externalGradesAvg??null,system:r?.systemPerformanceAvg??null},pendingAssessment:r?.diagnosticScore===null}}const er=({label:t,value:s,weight:a,color:r})=>{const n=s??0;return(n*a).toFixed(1),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-600 font-medium",children:t}),e.jsxs("span",{className:"text-slate-900 font-semibold tabular-nums",children:[s!==null?`${s.toFixed(0)}%`:"—",e.jsxs("span",{className:"text-slate-400 font-normal text-xs ml-1",children:["(w=",a,")"]})]})]}),e.jsx("div",{className:"h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx(Re.div,{className:`h-full rounded-full ${r}`,initial:{width:0},animate:{width:`${n}%`},transition:{duration:.6,ease:"easeOut"}})})]})},Fu=({studentId:t,studentName:s,className:a=""})=>{const[r,n]=p.useState(!1),{wri:o,riskStatus:l,diagnosticScore:i,externalGradesAvg:c,systemPerformanceAvg:d,weights:u,riskHistory:N,riskUpdatedAt:m,loading:h,recalculate:w,pendingAssessment:k}=zu(t),y=(()=>{if(!N||N.length<2)return"stable";const B=N.slice(-2),g=B[1].wri-B[0].wri;return g>2?"improving":g<-2?"declining":"stable"})(),f=y==="improving"?ka:y==="declining"?Ai:jo,v=(N??[]).slice(-10).map(B=>({wri:B.wri,date:B.computedAt})),S=u.w1,R=u.w2,j=u.w3;return e.jsxs("div",{className:`bg-white border border-slate-200 rounded-lg overflow-hidden ${a}`,children:[e.jsxs("button",{onClick:()=>n(!r),className:"w-full flex items-center justify-between p-4 hover:bg-slate-50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yl,{status:l,wri:o,size:"md",showScore:!0}),s&&e.jsx("span",{className:"text-sm font-medium text-slate-700",children:s}),o!==null&&e.jsxs("span",{className:`flex items-center gap-1 text-xs ${y==="improving"?"text-emerald-600":y==="declining"?"text-rose-600":"text-slate-500"}`,children:[e.jsx(f,{size:12}),e.jsx("span",{className:"capitalize",children:y})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[!k&&e.jsxs($e,{variant:"ghost",size:"sm",onClick:B=>{B.stopPropagation(),w()},disabled:h,className:"text-xs h-7 px-2",children:[e.jsx(_s,{size:10,className:h?"animate-spin":""}),"Recalc"]}),e.jsx(Ht,{size:16,className:`text-slate-400 transition-transform ${r?"rotate-180":""}`})]})]}),k&&e.jsx("div",{className:"px-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 bg-slate-50 rounded-lg p-3",children:[e.jsx(ko,{size:14,className:"text-slate-400"}),e.jsx("span",{children:"Complete the initial diagnostic assessment to calculate WRI."})]})}),e.jsx(Qt,{children:r&&!k&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-slate-500 uppercase tracking-wide",children:[e.jsx(lc,{size:12}),"Score Breakdown"]}),e.jsx(er,{label:"Diagnostic (D)",value:i,weight:S,color:"bg-blue-500"}),e.jsx(er,{label:"External Grades (G)",value:c,weight:R,color:"bg-violet-500"}),e.jsx(er,{label:"System Performance (P)",value:d,weight:j,color:"bg-cyan-500"})]}),e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-slate-600",children:"Formula"}),e.jsxs("div",{className:"font-mono text-sm text-slate-700",children:["WRI = (",S,")×D + (",R,")×G + (",j,")×P"]}),e.jsxs("div",{className:"text-xs text-slate-500",children:["= (",S,"×",i?.toFixed(0)??"—",") + (",R,"×",c?.toFixed(0)??"—",") + (",j,"×",d?.toFixed(0)??"—",")"," ",e.jsxs("span",{className:"font-semibold text-slate-700",children:["= ",o??"—"]})]})]}),v.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide",children:"Risk Trend"}),e.jsx("div",{className:"h-16 w-full",children:e.jsx(sr,{width:"100%",height:"100%",children:e.jsxs(_i,{data:v,margin:{top:2,right:2,bottom:2,left:2},children:[e.jsx(ar,{domain:[0,100],hide:!0}),e.jsx(oa,{y:68,stroke:"#000000",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:75,stroke:"#f43f5e",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:80,stroke:"#3b82f6",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(oa,{y:88,stroke:"#10b981",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(rr,{formatter:B=>[`${B.toFixed(1)}`,"WRI"],labelFormatter:(B,g)=>g?.[0]?.payload?.date?new Date(g[0].payload.date).toLocaleDateString():""}),e.jsx(Hi,{type:"monotone",dataKey:"wri",stroke:"#6366f1",strokeWidth:2,dot:{r:2,fill:"#6366f1"},activeDot:{r:4}})]})})}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-400",children:[e.jsx("span",{className:"text-black",children:"— 68 (At-Risk floor)"}),e.jsx("span",{className:"text-rose-500",children:"— 75 (Critical threshold)"}),e.jsx("span",{className:"text-blue-500",children:"— 80 (Watch threshold)"}),e.jsx("span",{className:"text-emerald-500",children:"— 88 (Safe threshold)"})]})]}),m&&e.jsxs("div",{className:"text-xs text-slate-400 text-right",children:["Last computed: ",m.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-400 italic border-t border-slate-100 pt-2",children:"WRI thresholds based on DepEd DO No. 8, s. 2015. WRI is a support tool — final decisions remain with the teacher."})]})})})]})},Bu=({studentId:t,studentName:s})=>{const[a,r]=p.useState(null),[n,o]=p.useState(!0),[l,i]=p.useState(!1);p.useEffect(()=>{const m=et(Ge,"interventionChecklists",t);return Xs(m,w=>{if(!w.exists()){r(null),o(!1);return}const k=w.data();r({studentId:k.studentId,items:k.items||[],generatedAt:k.generatedAt?.toDate()||null,acknowledged:k.acknowledged===!0,acknowledgedAt:k.acknowledgedAt?.toDate()||null,acknowledgedBy:k.acknowledgedBy||null}),o(!1)},w=>{console.error("[InterventionChecklistPanel] error:",w),o(!1)})},[t]);const c=async m=>{if(!a||l)return;i(!0);const h=a.items.map(w=>w.id===m?{...w,completed:!w.completed}:w);try{const w=et(Ge,"interventionChecklists",t);await yt(w,{items:h})}catch(w){console.error("[InterventionChecklistPanel] toggle error:",w)}finally{i(!1)}},d=async()=>{if(!(!a||l)){i(!0);try{const m=et(Ge,"interventionChecklists",t);await yt(m,{acknowledged:!0,acknowledgedAt:ot()});const h=et(Ge,"users",t);await yt(h,{teacherAcknowledged:!0,teacherAckRequired:!1,teacherAcknowledgedAt:ot()})}catch(m){console.error("[InterventionChecklistPanel] acknowledge error:",m)}finally{i(!1)}}};if(n)return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-400 py-4",children:[e.jsx(nt,{size:14,className:"animate-spin"}),"Loading intervention checklist..."]});if(!a)return e.jsx("div",{className:"text-sm text-slate-400 py-2",children:"No intervention checklist generated yet."});const u=a.items.filter(m=>m.completed).length,N=u===a.items.length;return e.jsxs(Re.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"bg-white border border-slate-200 rounded-lg p-4 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Zi,{size:16,className:"text-rose-500"}),e.jsxs("h4",{className:"text-sm font-semibold text-slate-800",children:["Intervention Checklist ",s?`— ${s}`:""]}),e.jsxs("span",{className:"text-xs text-slate-400 ml-auto",children:[u,"/",a.items.length," completed"]})]}),e.jsx("div",{className:"space-y-2",children:a.items.map(m=>e.jsxs("button",{onClick:()=>c(m.id),disabled:l||a.acknowledged,className:`w-full flex items-center gap-3 text-left px-3 py-2 rounded-md transition-colors ${m.completed?"bg-emerald-50 text-emerald-700":"bg-slate-50 text-slate-700 hover:bg-slate-100"} ${a.acknowledged?"opacity-60 cursor-not-allowed":"cursor-pointer"}`,children:[m.completed?e.jsx(dc,{size:16,className:"flex-shrink-0"}):e.jsx(ki,{size:16,className:"flex-shrink-0 text-slate-400"}),e.jsx("span",{className:`text-sm ${m.completed?"line-through opacity-70":""}`,children:m.text})]},m.id))}),!a.acknowledged&&e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-slate-500",children:N?"All items completed. You can now acknowledge.":"Complete all items before acknowledging."}),e.jsxs($e,{size:"sm",onClick:d,disabled:l||!N,className:"text-xs",children:[l?e.jsx(nt,{size:12,className:"animate-spin mr-1"}):e.jsx(ja,{size:12,className:"mr-1"}),"Acknowledge & Unlock"]})]}),a.acknowledged&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-emerald-600 bg-emerald-50 rounded-md px-3 py-2",children:[e.jsx(ja,{size:14}),"Acknowledged on ",a.acknowledgedAt?.toLocaleDateString()||"—"]})]})},fs=({label:t,value:s,icon:a,color:r})=>e.jsxs("div",{className:"flex items-center gap-3 bg-white border border-slate-200 rounded-lg p-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${r}`,children:a}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900 tabular-nums",children:s}),e.jsx("div",{className:"text-xs text-slate-500 font-medium",children:t})]})]}),$u=()=>{const[t,s]=p.useState([]),[a,r]=p.useState(!0),[n,o]=p.useState("all"),[l,i]=p.useState(""),[c,d]=p.useState("wri"),[u,N]=p.useState("asc"),[m,h]=p.useState(null);p.useEffect(()=>{const v=Bt(Ge,"managedStudents");return Xs(v,R=>{const j=R.docs.map(B=>{const g=B.data();return{id:B.id,...g,wri:g.wri??null,riskStatus:g.riskStatus??null,diagnosticScore:g.diagnosticScore??null,externalGradesAvg:g.externalGradesAvg??null,systemPerformanceAvg:g.systemPerformanceAvg??null}});s(j),r(!1)},R=>{console.error("[AtRiskDashboard] error:",R),r(!1)})},[]);const w=p.useMemo(()=>{let v=[...t];if(n!=="all"&&(v=v.filter(S=>S.riskStatus===n)),l.trim()){const S=l.toLowerCase();v=v.filter(R=>(R.name||"").toLowerCase().includes(S)||(R.email||"").toLowerCase().includes(S)||(R.lrn||"").toLowerCase().includes(S))}return v.sort((S,R)=>{let j=0;return c==="name"?j=String(S.name||S.email||"").localeCompare(String(R.name||R.email||"")):c==="wri"?j=(S.wri??100)-(R.wri??100):c==="updatedAt"&&(j=(S.updatedAt?.seconds??0)-(R.updatedAt?.seconds??0)),u==="asc"?j:-j}),v},[t,n,l,c,u]),k=p.useMemo(()=>{const v=t.length,S=t.filter(b=>b.riskStatus==="safe").length,R=t.filter(b=>b.riskStatus==="watch").length,j=t.filter(b=>b.riskStatus==="intervene").length,B=t.filter(b=>b.riskStatus==="critical").length,g=t.filter(b=>b.riskStatus==="at_risk").length;return{total:v,safe:S,watch:R,intervene:j,critical:B,atRisk:g}},[t]),y=v=>{c===v?N(S=>S==="asc"?"desc":"asc"):(d(v),N("asc"))},f=({field:v})=>c!==v?null:u==="asc"?e.jsx(Vi,{size:12}):e.jsx(Ui,{size:12});return e.jsxs("div",{className:"min-h-screen bg-slate-50",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-slate-900",children:"At-Risk Student Monitoring"}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:"Track student risk using the Weighted Risk Index (WRI) based on DepEd grading standards"})]})})}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[e.jsx(fs,{label:"Total Students",value:k.total,icon:e.jsx(Ps,{size:20,className:"text-slate-600"}),color:"bg-slate-100"}),e.jsx(fs,{label:"Safe",value:k.safe,icon:e.jsx(Co,{size:20,className:"text-emerald-600"}),color:"bg-emerald-50"}),e.jsx(fs,{label:"Watch",value:k.watch,icon:e.jsx(pr,{size:20,className:"text-blue-600"}),color:"bg-blue-50"}),e.jsx(fs,{label:"Intervene",value:k.intervene,icon:e.jsx(Gt,{size:20,className:"text-amber-600"}),color:"bg-amber-50"}),e.jsx(fs,{label:"Critical",value:k.critical,icon:e.jsx(Ca,{size:20,className:"text-rose-600"}),color:"bg-rose-50"}),e.jsx(fs,{label:"At Risk",value:k.atRisk,icon:e.jsx(Eo,{size:20,className:"text-slate-600"}),color:"bg-slate-100"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 bg-white border border-slate-200 rounded-lg p-1",children:["all","safe","watch","intervene","critical","at_risk"].map(v=>e.jsxs("button",{onClick:()=>o(v),className:`px-3 py-1.5 text-sm rounded-md font-medium transition-colors ${n===v?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[v==="all"?"All":v==="at_risk"?"At Risk":v.charAt(0).toUpperCase()+v.slice(1),v!=="all"&&e.jsxs("span",{className:"ml-1.5 text-xs opacity-70",children:["(",k[v],")"]})]},v))}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(Js,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search student...",value:l,onChange:v=>i(v.target.value),className:"w-full pl-9 pr-3 py-2 text-sm bg-white border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-slate-900/10 focus:border-slate-300"})]}),e.jsxs("div",{className:"text-sm text-slate-500",children:[w.length," student",w.length!==1?"s":""]})]}),e.jsx("div",{className:"bg-white border border-slate-200 rounded-lg overflow-hidden",children:a?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(_s,{size:20,className:"animate-spin text-slate-400"}),e.jsx("span",{className:"ml-2 text-slate-500",children:"Loading students..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-400",children:[e.jsx(Ps,{size:32}),e.jsx("p",{className:"mt-2 text-sm",children:"No students found"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:e.jsxs("button",{onClick:()=>y("name"),className:"flex items-center gap-1 hover:text-slate-900",children:["Student ",e.jsx(f,{field:"name"})]})}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700",children:e.jsxs("button",{onClick:()=>y("wri"),className:"flex items-center gap-1 hover:text-slate-900",children:["WRI ",e.jsx(f,{field:"wri"})]})}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden md:table-cell",children:"Diagnostic"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden lg:table-cell",children:"External"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-slate-700 hidden lg:table-cell",children:"System"}),e.jsx("th",{className:"text-right px-4 py-3 font-semibold text-slate-700",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:w.map(v=>e.jsxs(oe.Fragment,{children:[e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors cursor-pointer",onClick:()=>h(S=>S===v.id?null:v.id),children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-slate-900",children:v.name||"—"}),e.jsx("div",{className:"text-xs text-slate-500",children:v.email})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(yl,{status:v.riskStatus,wri:v.wri,size:"sm",showScore:!0})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"font-mono font-semibold tabular-nums",children:v.wri!==null?v.wri.toFixed(1):"—"})}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden md:table-cell tabular-nums",children:v.diagnosticScore!==null?`${v.diagnosticScore.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden lg:table-cell tabular-nums",children:v.externalGradesAvg!==null?`${v.externalGradesAvg.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-slate-600 hidden lg:table-cell tabular-nums",children:v.systemPerformanceAvg!==null?`${v.systemPerformanceAvg.toFixed(0)}%`:"—"}),e.jsx("td",{className:"px-4 py-3 text-right",onClick:S=>S.stopPropagation(),children:e.jsx("button",{onClick:()=>h(S=>S===v.id?null:v.id),className:"text-slate-400 hover:text-slate-600 transition-colors",children:e.jsx(Ht,{size:14,className:`transition-transform ${m===v.id?"rotate-180":""}`})})})]}),m===v.id&&e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-4 py-4 bg-slate-50/50",children:[e.jsx(Fu,{studentId:v.id,studentName:v.name}),(v.riskStatus==="critical"||v.riskStatus==="at_risk")&&e.jsx(Bu,{studentId:v.id,studentName:v.name})]})})]},v.id))})]})})}),e.jsx("div",{className:"text-xs text-slate-400 text-center",children:"WRI classification based on DepEd DO No. 8, s. 2015 (Policy Guidelines on Classroom Assessment). WRI is a support tool — final academic decisions remain with the teacher."})]})]})};function Ou(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.name,grade:t.grade,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId||t.teacherId,ownerTeacherName:t.ownerTeacherName,adviserTeacherId:t.adviserTeacherId||t.teacherId,adviserTeacherName:t.adviserTeacherName||t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName});return{id:t.id,name:a.className||t.name,classSectionId:a.classSectionId||t.classSectionId,classMetadata:a,gradeLevel:a.gradeLevel||void 0,classification:a.classification||void 0,strand:a.strand||void 0,managerId:a.managerId||void 0,managerName:a.managerName||void 0,schedule:t.schedule,studentCount:t.studentCount,avgScore:t.avgScore,atRiskCount:t.atRiskCount,riskLevel:s}}function Pu(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?kl(t.lastActive.toDate()):"Unknown",n=t.className||s||"Imported Class",o=Dt(n),l=t.grade||o.grade,i=t.section||o.section,c=lt({metadata:t.classMetadata,classSectionId:t.classSectionId||t.classroomId,className:[l,i].filter(Boolean).join(" - ")||n,grade:l,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:i,adviserTeacherId:t.teacherId,ownerTeacherId:t.teacherId,managerId:t.classMetadata?.managerId||t.managerId,managerName:t.classMetadata?.managerName||t.managerName});return{id:t.id,lrn:t.lrn,name:t.name,avatar:t.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:t.avgQuizScore,riskLevel:a,weakestTopic:t.weakestTopic||"N/A",classroomId:t.classroomId||c.classSectionId||n,className:c.className||[l,i].filter(Boolean).join(" - ")||n,grade:l,gradeLevel:c.gradeLevel||ds(l)||void 0,classification:c.classification||ws(c.gradeLevel||l)||void 0,strand:c.strand||Ss(c.className,i)||void 0,section:i,classSectionId:c.classSectionId||t.classSectionId,classMetadata:c,managerId:c.managerId||void 0,managerName:c.managerName||void 0,lastActive:r,struggles:t.struggles||[],engagementScore:t.engagementScore,attendance:t.attendance,assignmentCompletion:t.assignmentCompletion}}function _u(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.name,grade:t.grade,gradeLevel:t.gradeLevel||t.classMetadata?.gradeLevel,classification:t.classification||t.classMetadata?.classification,strand:t.strand||t.classMetadata?.strand,section:t.section,managerId:t.managerId||t.classMetadata?.managerId,managerName:t.managerName||t.classMetadata?.managerName});return{id:t.id,name:a.className||t.name,classSectionId:a.classSectionId||t.classSectionId||void 0,classMetadata:a,gradeLevel:a.gradeLevel||void 0,classification:a.classification||void 0,strand:a.strand||void 0,managerId:a.managerId||void 0,managerName:a.managerName||void 0,schedule:t.schedule||"Mon-Fri",studentCount:t.studentCount,avgScore:t.avgScore,atRiskCount:t.atRiskCount,riskLevel:s}}function Hu(t){const s=(t.riskLevel||"Low").toLowerCase(),a=lt({metadata:t.classMetadata,classSectionId:t.classSectionId,className:t.className||[t.grade,t.section].filter(Boolean).join(" - ")||"Imported Class",grade:t.grade,gradeLevel:t.gradeLevel||t.classMetadata?.gradeLevel,classification:t.classification||t.classMetadata?.classification,strand:t.strand||t.classMetadata?.strand,section:t.section,managerId:t.managerId||t.classMetadata?.managerId,managerName:t.managerName||t.classMetadata?.managerName}),r=a.className||"Imported Class";return{id:t.id,lrn:t.lrn||void 0,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:t.avgQuizScore,riskLevel:s,weakestTopic:t.weakestTopic||"Foundational Skills",classroomId:a.classSectionId||t.classSectionId||r,className:r,grade:a.grade||Dt(r).grade,gradeLevel:a.gradeLevel||ds(a.grade||Dt(r).grade)||void 0,classification:a.classification||ws(a.gradeLevel||a.grade)||void 0,strand:a.strand||Ss(r,a.section||t.section)||void 0,section:a.section||Dt(r).section,classSectionId:a.classSectionId||t.classSectionId||void 0,classMetadata:a,managerId:a.managerId||void 0,managerName:a.managerName||void 0,lastActive:"Recently imported",struggles:[t.weakestTopic||"Foundational Skills"],engagementScore:t.engagementScore,attendance:t.attendance,assignmentCompletion:t.assignmentCompletion}}function Gu(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function Qu(t,s,a,r){const n=lt({metadata:r,classSectionId:s,className:a}),o=n.className||"Imported Class",l=n.classSectionId||"imported_class",i=Number(t.avgQuizScore||0),c=Number(t.attendance||0),d=Number(t.engagementScore||0),u=Number(t.assignmentCompletion||0),N=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",m=Gu(i,c,d),h=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${l}-${h}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:i,riskLevel:m,weakestTopic:N,classroomId:l,className:o,grade:n.grade||Dt(o).grade,gradeLevel:n.gradeLevel||ds(n.grade||Dt(o).grade)||void 0,classification:n.classification||ws(n.gradeLevel||n.grade)||void 0,strand:n.strand||Ss(o,n.section)||void 0,section:n.section||Dt(o).section,classSectionId:l,classMetadata:n,managerId:n.managerId||void 0,managerName:n.managerName||void 0,lastActive:"Recently imported",struggles:[N],engagementScore:d,attendance:c,assignmentCompletion:u}}function Uu(t,s,a,r){const n=lt({metadata:t.dashboardSync?.classMetadata||t.classMetadata||r,classSectionId:t.dashboardSync?.classSectionId||s,className:t.dashboardSync?.className||a}),o=n.classSectionId||"imported_class",l=n.className||"Imported Class";return{classSectionId:o,className:l,classMetadata:{...n,classSectionId:o,className:l}}}function kl(t){const s=Date.now()-t.getTime(),a=Math.floor(s/6e4);if(a<1)return"Just now";if(a<60)return`${a} min${a>1?"s":""} ago`;const r=Math.floor(a/60);if(r<24)return`${r} hour${r>1?"s":""} ago`;const n=Math.floor(r/24);return`${n} day${n>1?"s":""} ago`}function rt(t){return(t||"").trim().toLowerCase()}function oo(t){const s=rt(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function lo(t,s){const a=new Map;return t.forEach(r=>{a.set(oo(r),r)}),s.forEach(r=>{const n=oo(r),o=a.get(n);if(!o){a.set(n,r);return}const l=Math.max(o.atRiskCount||0,r.atRiskCount||0),i=Math.max(o.studentCount||0,r.studentCount||0),c=r.avgScore>0?r.avgScore:o.avgScore,d=l>=5?"high":l>=2?"medium":"low",u=lt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.name||r.name,grade:o.classMetadata?.grade||r.classMetadata?.grade,gradeLevel:o.classMetadata?.gradeLevel||r.classMetadata?.gradeLevel,classification:o.classMetadata?.classification||r.classMetadata?.classification,strand:o.classMetadata?.strand||r.classMetadata?.strand,section:o.classMetadata?.section||r.classMetadata?.section,schoolYear:o.classMetadata?.schoolYear||r.classMetadata?.schoolYear,ownerTeacherId:o.classMetadata?.ownerTeacherId||r.classMetadata?.ownerTeacherId,ownerTeacherName:o.classMetadata?.ownerTeacherName||r.classMetadata?.ownerTeacherName,adviserTeacherId:o.classMetadata?.adviserTeacherId||r.classMetadata?.adviserTeacherId,adviserTeacherName:o.classMetadata?.adviserTeacherName||r.classMetadata?.adviserTeacherName,managerId:o.classMetadata?.managerId||r.classMetadata?.managerId,managerName:o.classMetadata?.managerName||r.classMetadata?.managerName});a.set(n,{...o,classSectionId:u.classSectionId||o.classSectionId||r.classSectionId,name:u.className||o.name||r.name,classMetadata:u,gradeLevel:u.gradeLevel||void 0,classification:u.classification||void 0,strand:u.strand||void 0,managerId:u.managerId||void 0,managerName:u.managerName||void 0,schedule:o.schedule||r.schedule,studentCount:i,atRiskCount:l,avgScore:c,riskLevel:d})}),Array.from(a.values())}function io(t){const s=(t.lrn||"").trim().toLowerCase();if(s)return`lrn:${s}`;const a=t.name.trim().toLowerCase();if(a)return`name:${a}`;const r=rt(t.classSectionId)||rt(t.classroomId),n=(t.id||"").trim().toLowerCase();return r&&n?`${r}|id:${n}`:`${r}|anonymous`}function Ns(t){const s=rt(t.classSectionId)||rt(t.classroomId),a=(t.lrn||"").trim().toLowerCase(),r=(t.id||"").trim().toLowerCase(),n=t.name.trim().toLowerCase().replace(/\s+/g,"_");return s&&a?`${s}|lrn:${a}`:s&&r?`${s}|id:${r}`:a?`lrn:${a}`:r&&n?`id:${r}|name:${n}`:r?`id:${r}`:s&&n?`${s}|name:${n}`:`name:${n||"unknown"}`}function co(t,s){const a=new Map;return t.forEach(r=>{a.set(io(r),r)}),s.forEach(r=>{const n=io(r),o=a.get(n);if(!o){a.set(n,r);return}const l=[o.riskLevel,r.riskLevel].includes("high")?"high":[o.riskLevel,r.riskLevel].includes("medium")?"medium":"low",i=lt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.className||r.className,grade:o.grade||r.grade,gradeLevel:o.gradeLevel||r.gradeLevel,classification:o.classification||r.classification,strand:o.strand||r.strand,section:o.section||r.section,managerId:o.managerId||r.managerId,managerName:o.managerName||r.managerName});a.set(n,{...o,lrn:o.lrn||r.lrn,classSectionId:i.classSectionId||o.classSectionId||r.classSectionId,classroomId:o.classroomId||r.classroomId,className:i.className||o.className||r.className,grade:i.grade||o.grade||r.grade,gradeLevel:i.gradeLevel||o.gradeLevel||r.gradeLevel,classification:i.classification||o.classification||r.classification,strand:i.strand||o.strand||r.strand,section:i.section||o.section||r.section,managerId:i.managerId||o.managerId||r.managerId,managerName:i.managerName||o.managerName||r.managerName,classMetadata:i,avgScore:r.avgScore>0?r.avgScore:o.avgScore,attendance:r.attendance>0?r.attendance:o.attendance,engagementScore:r.engagementScore>0?r.engagementScore:o.engagementScore,assignmentCompletion:r.assignmentCompletion>0?r.assignmentCompletion:o.assignmentCompletion,weakestTopic:o.weakestTopic&&o.weakestTopic!=="N/A"?o.weakestTopic:r.weakestTopic,riskLevel:l,struggles:o.struggles.length>0?o.struggles:r.struggles})}),Array.from(a.values())}const Kx=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:n}=Ks(),[o,l]=p.useState("dashboard"),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[N,m]=p.useState(!1),[h,w]=p.useState(!1),[k,y]=p.useState(!1),[f,v]=p.useState(null),[S,R]=p.useState(null),[j,B]=p.useState([]),[g,b]=p.useState([]),[T,z]=p.useState([]),[$,Z]=p.useState(""),[ae,H]=p.useState(!0),[ee,re]=p.useState(!1),[ne,D]=p.useState(0),[te,J]=p.useState([]),[me,Ce]=p.useState(!1),F=p.useRef(new Map);p.useEffect(()=>{if(!r)return;const E=r.uid;let W=!0,je;return(async()=>{H(!0);try{const De=await ml(E);let fe=De.map(Ou);const Me=await Kd(E).catch(()=>[]),I=new Map;Me.forEach(U=>{const ue=rt(U.classSectionId);ue&&I.set(ue,U)}),fe=fe.map(U=>{const ue=I.get(rt(U.classSectionId));if(!ue)return U;const Be=lt({metadata:U.classMetadata,classSectionId:ue.classSectionId||U.classSectionId,className:ue.className||U.name,grade:ue.grade||U.classMetadata?.grade,gradeLevel:ue.gradeLevel||U.classMetadata?.gradeLevel,classification:ue.classification||U.classMetadata?.classification,strand:ue.strand||U.classMetadata?.strand,section:ue.section||U.classMetadata?.section,schoolYear:ue.schoolYear||U.classMetadata?.schoolYear,ownerTeacherId:ue.ownerTeacherId||U.classMetadata?.ownerTeacherId,ownerTeacherName:ue.ownerTeacherName||U.classMetadata?.ownerTeacherName,managerId:ue.managerId||U.classMetadata?.managerId,managerName:ue.managerName||U.classMetadata?.managerName});return{...U,name:Be.className||U.name,classSectionId:Be.classSectionId||U.classSectionId,classMetadata:Be,gradeLevel:Be.gradeLevel||U.gradeLevel,classification:Be.classification||U.classification,strand:Be.strand||U.strand,managerId:Be.managerId||U.managerId,managerName:Be.managerName||U.managerName}});const Y=new Map,ge=new Map;De.forEach(U=>{const ue=lt({metadata:U.classMetadata,classSectionId:U.classSectionId,className:U.name,grade:U.grade,gradeLevel:U.gradeLevel,classification:U.classification,strand:U.strand,section:U.section,schoolYear:U.schoolYear,ownerTeacherId:U.ownerTeacherId||U.teacherId,ownerTeacherName:U.ownerTeacherName,adviserTeacherId:U.adviserTeacherId||U.teacherId,adviserTeacherName:U.adviserTeacherName,managerId:U.managerId,managerName:U.managerName});Y.set(U.id,ue.className||U.name),ge.set(U.id,ue);const Be=rt(U.classSectionId);if(Be){const Te=I.get(Be),tt=lt({metadata:ue,classSectionId:Te?.classSectionId||Be,className:Te?.className||ue.className,grade:Te?.grade||ue.grade,gradeLevel:Te?.gradeLevel||ue.gradeLevel,classification:Te?.classification||ue.classification,strand:Te?.strand||ue.strand,section:Te?.section||ue.section,schoolYear:Te?.schoolYear||ue.schoolYear,ownerTeacherId:Te?.ownerTeacherId||ue.ownerTeacherId,ownerTeacherName:Te?.ownerTeacherName||ue.ownerTeacherName,managerId:Te?.managerId||ue.managerId,managerName:Te?.managerName||ue.managerName});Y.set(Be,tt.className||U.name),ge.set(Be,tt)}});const Je=(await Ar(E)).map(U=>{const ue=rt(U.classSectionId||U.classroomId),Be=Y.get(U.classroomId)||(ue?Y.get(ue):void 0)||U.className||"Unknown",Te=Pu(U,Be);if(!ue)return Te;const tt=ge.get(ue);if(!tt)return Te;const xt=lt({metadata:tt,classSectionId:Te.classSectionId||tt.classSectionId,className:Te.className||tt.className,grade:Te.grade||tt.grade,gradeLevel:Te.gradeLevel||tt.gradeLevel,classification:Te.classification||tt.classification,strand:Te.strand||tt.strand,section:Te.section||tt.section,managerId:Te.managerId||tt.managerId,managerName:Te.managerName||tt.managerName});return{...Te,className:xt.className||Te.className,grade:xt.grade||Te.grade,gradeLevel:xt.gradeLevel||Te.gradeLevel,classification:xt.classification||Te.classification,strand:xt.strand||Te.strand,section:xt.section||Te.section,classSectionId:xt.classSectionId||Te.classSectionId,classMetadata:xt,managerId:xt.managerId||Te.managerId,managerName:xt.managerName||Te.managerName}});if(!W)return;B(U=>fe.length===0&&U.length>0?U:fe),b(U=>Je.length===0&&U.length>0?U:Je),Ve.getImportedClassOverview({limit:3e3,forceRefresh:ne>0}).then(U=>{W&&(U.warnings.length>0&&console.warn("Imported class overview warnings:",U.warnings.join(" ")),B(ue=>lo(ue,U.classrooms.map(_u))),b(ue=>co(ue,U.students.map(Hu))))}).catch(U=>{console.warn("Imported class overview merge unavailable:",U)});const Xe=De.map(U=>U.id);Xe.length>0&&(je=Jd(Xe,U=>{W&&z(U.map(ue=>({id:ue.id,student:ue.studentName,action:ue.action,topic:ue.topic,time:kl(ue.timestamp.toDate()),type:ue.type})))}))}catch(De){console.error("Failed to load teacher data:",De),ce.error("Failed to load dashboard data")}finally{H(!1)}})(),()=>{W=!1,je&&je()}},[r,ne]),p.useEffect(()=>{if(!r)return;let E=!0;return Xd("",80).then(W=>{E&&J(W)}).catch(W=>{console.warn("Failed to load teacher directory options:",W)}),()=>{E=!1}},[r]),p.useEffect(()=>{if(g.length===0)return;(async()=>{re(!0);try{const W=g.map(pe=>({name:pe.name,engagementScore:pe.engagementScore,avgQuizScore:pe.avgScore,attendance:pe.attendance,riskLevel:pe.riskLevel})),je=await Ve.getDailyInsight({students:W});Z(je.insight)}catch{Z(`${g.filter(W=>W.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{re(!1)}})()},[g]);const C=j.reduce((E,W)=>E+W.studentCount,0),K=j.reduce((E,W)=>E+W.atRiskCount,0),P=j.length>0?Math.round(j.reduce((E,W)=>E+W.avgScore,0)/j.length):0,xe=[{name:"High Risk",value:g.filter(E=>E.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:g.filter(E=>E.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:g.filter(E=>E.riskLevel==="low").length,color:"#75D06A"}],M={};g.forEach(E=>{E.weakestTopic&&E.weakestTopic!=="N/A"&&(M[E.weakestTopic]||(M[E.weakestTopic]={total:0,sum:0}),M[E.weakestTopic].total+=1,M[E.weakestTopic].sum+=E.avgScore)});const G=Object.entries(M).map(([E,W])=>({topic:E,score:Math.round(W.sum/W.total)})).sort((E,W)=>E.score-W.score).slice(0,6),X=E=>{v(E),l("analytics")},le=E=>{R(E),l("intervention")},ie=()=>{R(null),l("analytics")},V=()=>{v(null),R(null),l("dashboard")},we=async(E,W)=>{if(!r){ce.error("Unable to assign manager: teacher context is missing.");return}const je=Dt(E.classMetadata?.className||E.name),pe=lt({metadata:E.classMetadata,classSectionId:E.classSectionId,className:E.name,grade:E.classMetadata?.grade||je.grade,gradeLevel:E.classMetadata?.gradeLevel,classification:E.classMetadata?.classification,strand:E.classMetadata?.strand,section:E.classMetadata?.section||je.section,schoolYear:E.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:E.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:E.classMetadata?.ownerTeacherName||Pe,adviserTeacherId:E.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:E.classMetadata?.adviserTeacherName||Pe,managerId:W.uid,managerName:W.name}),De=pe.classSectionId||It(pe.grade||je.grade,pe.section||je.section);if(!De){ce.error("Unable to assign manager: missing class section ID.");return}Ce(!0);try{await Yd({classSectionId:De,className:pe.className||E.name,grade:pe.grade||je.grade,gradeLevel:pe.gradeLevel||ds(pe.grade||je.grade)||pe.grade||je.grade,classification:pe.classification||ws(pe.gradeLevel||pe.grade)||void 0,strand:pe.strand||Ss(pe.className,pe.section)||void 0,section:pe.section||je.section,schoolYear:pe.schoolYear||String(new Date().getFullYear()),ownerTeacherId:pe.ownerTeacherId||r.uid,ownerTeacherName:pe.ownerTeacherName||Pe,managerId:W.uid,managerName:W.name});const fe=lt({metadata:pe,classSectionId:De,managerId:W.uid,managerName:W.name}),Me=rt(De);B(I=>I.map(Y=>rt(Y.classSectionId)!==Me?Y:{...Y,name:fe.className||Y.name,classSectionId:fe.classSectionId||Y.classSectionId,classMetadata:fe,gradeLevel:fe.gradeLevel||Y.gradeLevel,classification:fe.classification||Y.classification,strand:fe.strand||Y.strand,managerId:W.uid,managerName:W.name})),b(I=>I.map(Y=>{if(rt(Y.classSectionId||Y.classroomId)!==Me)return Y;const He=lt({metadata:Y.classMetadata,classSectionId:fe.classSectionId||Y.classSectionId,className:Y.className||fe.className,grade:Y.grade||fe.grade,gradeLevel:Y.gradeLevel||fe.gradeLevel,classification:Y.classification||fe.classification,strand:Y.strand||fe.strand,section:Y.section||fe.section,managerId:W.uid,managerName:W.name});return{...Y,classMetadata:He,gradeLevel:He.gradeLevel||Y.gradeLevel,classification:He.classification||Y.classification,strand:He.strand||Y.strand,managerId:W.uid,managerName:W.name}})),v(I=>!I||rt(I.classSectionId)!==Me?I:{...I,classMetadata:fe,managerId:W.uid,managerName:W.name,gradeLevel:fe.gradeLevel||I.gradeLevel,classification:fe.classification||I.classification,strand:fe.strand||I.strand}),ce.success(`Assigned ${W.name} as section manager.`)}catch(fe){console.error("Failed to assign class manager:",fe),ce.error(fe instanceof Error?fe.message:"Failed to assign class manager")}finally{Ce(!1)}};p.useEffect(()=>{const E=()=>{const W=window.innerWidth<1024;w(W),W?c(!1):m(!1)};return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]),p.useEffect(()=>{h&&m(!1)},[o,h]);const Pe=n?.name||"Teacher",ke=p.useMemo(()=>{if(!f)return;if(f.classMetadata?.classSectionId)return f.classMetadata.classSectionId||void 0;if(f.classSectionId)return f.classSectionId;const E=Dt(f.classMetadata?.className||f.name);return It(E.grade,E.section)||void 0},[f]),O=p.useMemo(()=>f||j[0]||null,[f,j]),q=p.useMemo(()=>{if(!O)return g;const E=(O.id||"").trim().toLowerCase(),W=rt(O.classSectionId),je=(O.name||"").trim().toLowerCase();return g.filter(pe=>{const De=rt(pe.classroomId),fe=rt(pe.classSectionId),Me=(pe.className||"").trim().toLowerCase();return W&&(fe===W||De===W)||E&&(De===E||fe===E)||je&&Me===je})},[O,g]);return ae?e.jsxs("div",{className:"flex h-screen w-full bg-background p-6",children:[e.jsx("div",{className:"hidden lg:flex w-[280px] shrink-0 rounded-3xl border border-border bg-card p-5",children:e.jsxs("div",{className:"w-full space-y-4",children:[e.jsx(he,{className:"h-12 w-40"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"}),e.jsx(he,{className:"h-10 w-full"})]})}),e.jsxs("div",{className:"flex-1 space-y-4 lg:pl-6",children:[e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(he,{className:"h-28 w-full rounded-2xl"}),e.jsx(he,{className:"h-28 w-full rounded-2xl"}),e.jsx(he,{className:"h-28 w-full rounded-2xl"})]}),e.jsx(he,{className:"h-[420px] w-full rounded-2xl"})]})]}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[h&&N&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>m(!1)}),e.jsxs(Re.aside,{initial:!1,animate:{width:h?280:i&&!d?80:280,x:h?N?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!h&&i&&u(!0),onMouseLeave:()=>u(!1),className:"fixed inset-y-0 left-0 z-40 bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] flex flex-col shadow-sm lg:static lg:z-auto p-5",children:[e.jsxs("div",{className:`mb-8 flex items-center ${i&&!d?"justify-center":"justify-between"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-[#7274ED] to-[#9956DE] rounded-2xl flex items-center justify-center shadow-md flex-shrink-0",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"MathPulse AI",className:"w-10 h-10 object-contain drop-shadow-md"})}),(!i||d)&&e.jsx("div",{children:e.jsx("h1",{className:"text-base font-bold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),!h&&(!i||d)&&e.jsx(Re.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>c(!i),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":i?"Expand sidebar":"Collapse sidebar",children:i?e.jsx(Wt,{size:20}):e.jsx(Pt,{size:20})}),h&&e.jsx("button",{onClick:()=>m(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(va,{size:20})})]}),e.jsxs("nav",{className:"flex-1 space-y-5",children:[e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Overview"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:ci,label:"Dashboard",active:o==="dashboard",collapsed:i&&!d,onClick:V,forceExpanded:h}),e.jsx(At,{icon:Hs,label:"Class Analytics",active:o==="analytics",collapsed:i&&!d,onClick:()=>l("analytics"),forceExpanded:h})]})]}),e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Students"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:Zl,label:"Topic Mastery",active:o==="topic_mastery",collapsed:i&&!d,onClick:()=>l("topic_mastery"),forceExpanded:h}),e.jsx(At,{icon:Ps,label:"Competency",active:o==="competency",collapsed:i&&!d,onClick:()=>l("competency"),forceExpanded:h}),e.jsx(At,{icon:Gt,label:"At-Risk Monitor",active:o==="at_risk",collapsed:i&&!d,onClick:()=>l("at_risk"),forceExpanded:h})]})]}),e.jsxs("div",{children:[i&&!d?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:"Tools"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(At,{icon:Mi,label:"Data Import",active:o==="import",collapsed:i&&!d,onClick:()=>l("import"),forceExpanded:h}),e.jsx(At,{icon:To,label:"AI Quiz Maker",active:o==="quiz_maker",collapsed:i&&!d,onClick:()=>l("quiz_maker"),forceExpanded:h}),e.jsx(At,{icon:Vt,label:"Question Bank",active:o==="question_bank",collapsed:i&&!d,onClick:()=>l("question_bank"),forceExpanded:h}),e.jsx(At,{icon:ua,label:"Notifications",active:o==="notifications",collapsed:i&&!d,onClick:()=>l("notifications"),forceExpanded:h}),e.jsx(At,{icon:ei,label:"Calendar",active:o==="calendar",collapsed:i&&!d,onClick:()=>l("calendar"),forceExpanded:h})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t border-[#dde3eb] pt-4",children:[e.jsxs(Re.button,{whileHover:{x:2},whileTap:{scale:.98},className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl text-[#5a6578] font-bold border border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628] transition-all duration-200 whitespace-nowrap ${i&&!d?"justify-center":""}`,onClick:a,title:i&&!d?"Settings":"",children:[e.jsx(di,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!i||d)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]}),e.jsx("div",{className:"text-[#5a6578]",children:e.jsx(mi,{onClick:()=>y(!0),collapsed:i&&!d})})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-card/80 backdrop-blur-md border-b border-border px-6 py-3 sticky top-0 z-30",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[h&&e.jsx("button",{onClick:()=>m(!0),className:"mt-1 p-2 rounded-lg border border-border text-muted-foreground hover:text-[#9956DE] hover:border-[#9956DE]/30 hover:bg-[#9956DE]/12 transition-colors","aria-label":"Open navigation",children:e.jsx(ti,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-display font-bold text-foreground leading-tight",children:[o==="dashboard"&&"Teacher Dashboard",o==="analytics"&&(f?f.name:"Class Analytics"),o==="intervention"&&"Student Intervention",o==="topic_mastery"&&"Topic Mastery",o==="competency"&&"Student Competency",o==="import"&&"Data Import",o==="notifications"&&"Notifications",o==="calendar"&&"Calendar",o==="quiz_maker"&&"AI Quiz Maker",o==="question_bank"&&"Question Bank",o==="at_risk"&&"At-Risk Monitoring"]}),e.jsxs("p",{className:"text-xs text-muted-foreground font-body",children:[o==="dashboard"&&`Welcome back, ${Pe}`,o==="analytics"&&"Deep dive into class performance",o==="intervention"&&S?.name,o==="topic_mastery"&&"Monitor class-wide topic mastery",o==="competency"&&"Per-student topic-level breakdown",o==="import"&&"Upload class records and materials",o==="quiz_maker"&&"Create and manage AI-powered quizzes",o==="question_bank"&&"Manage RAG-powered quiz question bank",o==="notifications"&&"View classroom alerts and updates",o==="calendar"&&"Check upcoming class events and schedule",o==="at_risk"&&"Track student risk using the Weighted Risk Index (WRI)"]})]}),o==="dashboard"&&e.jsxs("div",{className:"hidden xl:flex items-center gap-2 ml-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg",children:[e.jsx(Ps,{size:13,className:"text-[#9956DE]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#9956DE]",children:[C," students"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#F08386]/12 border border-[#F08386]/30 rounded-lg",children:[e.jsx(Gt,{size:13,className:"text-[#F08386]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#C65E63]",children:[K," at risk"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#75D06A]/14 border border-[#75D06A]/35 rounded-lg",children:[e.jsx(ka,{size:13,className:"text-[#75D06A]"}),e.jsxs("span",{className:"text-xs font-display font-bold text-[#4D9F46]",children:[P,"% avg"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{onClick:s,className:"flex items-center gap-2.5 bg-muted p-1.5 pr-3 rounded-lg cursor-pointer hover:bg-accent transition-all group max-w-[220px]",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden ring-1 ring-[#9956DE]/45 bg-card flex items-center justify-center",children:e.jsx(si,{src:n?.photo,name:Pe,gender:n?.gender,className:"w-full h-full rounded-lg"})}),e.jsxs("div",{className:"hidden md:block min-w-0 text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-none group-hover:text-[#9956DE] transition-colors truncate",children:Pe}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-none",children:"Teacher"})]})]})})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto",children:e.jsxs(Qt,{mode:"wait",children:[o==="dashboard"&&e.jsx(Vu,{classes:j,liveActivity:T,onViewClass:X,onViewAllClasses:()=>l("analytics"),onViewActivityStudent:E=>{const W=g.find(je=>je.name===E);W&&le(W)},dailyInsight:$,insightLoading:ee,totalStudents:C,totalAtRisk:K,avgPerformance:P}),o==="analytics"&&O&&e.jsx(Yu,{selectedClass:O,students:q,riskDistribution:xe,topicPerformance:G,onViewStudent:le,onBack:V,teacherOptions:te,managerUpdating:me,onAssignManager:E=>we(O,E)}),o==="analytics"&&!O&&e.jsx(Wu,{icon:Hs,title:"Class Analytics",description:"No classes available yet. Import class records to unlock analytics views."}),o==="intervention"&&S&&e.jsx(Ku,{student:S,teacherId:r?.uid||"",teacherName:Pe,initialCache:F.current.get(S.id),onCacheUpdate:(E,W)=>F.current.set(E,W),onStudentUpdated:E=>{const W=S?Ns(S):null;R(E),b(je=>je.map(pe=>{const De=Ns(pe),fe=W?De===W:!1,Me=pe.id===E.id&&rt(pe.classSectionId)===rt(E.classSectionId);return fe||Me?E:pe}))},onBack:ie}),o==="topic_mastery"&&e.jsx(pm,{classSectionId:ke}),o==="competency"&&e.jsx(Nm,{classSectionId:ke,className:f?.name,fallbackStudents:g}),o==="at_risk"&&e.jsx("div",{className:"flex-1 overflow-auto min-h-0",children:e.jsx($u,{})}),o==="import"&&e.jsx(Xu,{onEditRecords:()=>l("edit_records"),classSectionId:ke,className:f?.name,classMetadata:f?.classMetadata,onImportedClassRecords:E=>{const W=E.students.map(Y=>Qu(Y,E.classSectionId,E.className,E.classMetadata)),je=lt({metadata:E.classMetadata,classSectionId:E.classSectionId,className:E.className}),pe=je.classSectionId||"imported_class",De=je.className||"Imported Class",fe=W.filter(Y=>Y.riskLevel==="high").length,Me=W.length>0?Math.round(W.reduce((Y,ge)=>Y+ge.avgScore,0)/W.length):0,I={id:pe,name:De,classSectionId:pe,classMetadata:{...je,classSectionId:pe,className:De},schedule:"Mon-Fri",studentCount:W.length,avgScore:Me,atRiskCount:fe,riskLevel:fe>=5?"high":fe>=2?"medium":"low"};b(Y=>co(Y,W)),B(Y=>lo(Y,[I]))},onDataChanged:()=>D(E=>E+1)}),o==="notifications"&&e.jsx(ym,{liveActivity:T,atRiskStudents:g.filter(E=>E.riskLevel==="high").map(E=>({name:E.name,riskLevel:E.riskLevel,weakestTopic:E.weakestTopic}))}),o==="calendar"&&e.jsx(Lm,{classes:j,teacherId:r?.uid}),o==="edit_records"&&e.jsx(Ju,{students:g,teacherId:r?.uid||"",teacherName:Pe,onBack:()=>l("import")}),o==="quiz_maker"&&e.jsx(mm,{onBack:()=>l("dashboard")}),o==="question_bank"&&e.jsx(um,{})]})})]}),e.jsx(li,{isOpen:k,onClose:()=>y(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"})]})},At=({icon:t,label:s,active:a,collapsed:r,forceExpanded:n=!1,onClick:o})=>e.jsxs(Re.button,{onClick:o,whileHover:{x:2},whileTap:{scale:.98},className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl cursor-pointer transition-all duration-200 border whitespace-nowrap ${r&&!n?"justify-center":""} ${a?"bg-[#9956DE]/12 border-[#9956DE]/30 shadow-sm text-[#9956DE]":"bg-transparent border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]"}`,children:[e.jsx(t,{size:18,strokeWidth:a?2.5:2,className:"flex-shrink-0"}),(!r||n)&&e.jsx("span",{className:"font-body font-bold text-xs",children:s}),a&&!r&&e.jsx(Re.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-[#9956DE]",transition:{type:"spring",duration:.4}})]}),Wu=({icon:t,title:s,description:a})=>e.jsx(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-8 shadow-sm max-w-2xl",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#9956DE]/20 text-[#9956DE] flex items-center justify-center mb-4",children:e.jsx(t,{size:24})}),e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground mb-2",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed",children:a})]})}),Vu=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:n,dailyInsight:o,insightLoading:l,totalStudents:i,totalAtRisk:c,avgPerformance:d})=>{const u=i>0?Math.round(c/i*100):0,N=i>0?Math.round((i-c)/i*100):0;return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-r from-[#7274ED] to-[#9956DE] rounded-2xl p-5 text-white shadow-md",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-card/20 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Gt,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-display font-bold mb-1",children:"AI Insight"}),e.jsx(pa,{name:"teacher-dashboard-ai-insight",loading:l,fixture:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-11/12 bg-white/25"}),e.jsx(he,{className:"h-3.5 w-10/12 bg-white/20"}),e.jsx(he,{className:"h-3.5 w-8/12 bg-white/15"})]}),fallback:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-11/12 bg-white/25"}),e.jsx(he,{className:"h-3.5 w-10/12 bg-white/20"}),e.jsx(he,{className:"h-3.5 w-8/12 bg-white/15"})]}),children:e.jsx("div",{children:e.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"text-[#F1E4FF] text-sm leading-relaxed [&_p]:m-0 [&_strong]:font-semibold",children:e.jsx(wo,{children:o||`${c} students (${u}%) are at high risk of falling behind`})})})})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Total Students"}),e.jsx("p",{className:"text-2xl font-display font-bold text-foreground",children:i})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Class Average"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[d,"%"]})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-border shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"Engagement Rate"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#75D06A]",children:[N,"%"]})]}),e.jsxs("div",{className:"bg-card rounded-xl p-4 border border-[#FF8B8B]/35 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-body mb-1",children:"At Risk"}),e.jsx("p",{className:"text-2xl font-display font-bold text-[#FF8B8B]",children:c})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"My Classes"}),e.jsxs("button",{onClick:r,className:"text-sm font-bold text-[#9956DE] hover:text-[#9956DE] flex items-center gap-1 group",children:["View All",e.jsx(Wt,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]}),e.jsx("div",{className:"space-y-4",children:t.map(m=>e.jsxs(Re.div,{whileHover:{scale:1.01},className:"bg-card border border-border rounded-2xl p-6 shadow-sm hover:shadow-md transition-all cursor-pointer",onClick:()=>a(m),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-foreground",children:m.name}),e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold border ${Ra(m.riskLevel)}`,children:m.riskLevel==="high"?"High Risk":m.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(So,{size:14}),e.jsx("span",{children:m.schedule})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:[m.gradeLevel,m.classification,m.strand].filter(Boolean).map(h=>e.jsx("span",{className:"px-2 py-0.5 rounded-md bg-[#9956DE]/12 border border-[#9956DE]/30 text-[#9956DE] text-[11px] font-semibold",children:h},`${m.id}-${h}`))}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Manager: ",m.managerName||m.classMetadata?.managerName||"Not assigned"]})]}),e.jsx($e,{className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold px-6 py-2 rounded-xl",children:"View Class"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Total Students"}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:m.studentCount})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"At Risk"}),e.jsx("p",{className:"text-xl font-bold text-[#FF8B8B]",children:m.atRiskCount})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-xl font-bold text-[#9956DE]",children:[m.avgScore,"%"]})]})]})]},m.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 bg-[#F08386]/20 rounded-xl flex items-center justify-center",children:e.jsx($s,{size:20,className:"text-[#F08386]"})}),e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"Live Classroom Pulse"})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-5 shadow-sm border border-border space-y-3 max-h-[600px] overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No live classroom events yet. Activity appears here in real time."}),s.map(m=>e.jsxs("div",{onClick:()=>n?.(m.student),className:`p-4 rounded-xl border-l-4 cursor-pointer hover:shadow-md transition-shadow ${m.type==="success"?"bg-[#75D06A]/14 border-[#75D06A]":m.type==="warning"?"bg-[#F08386]/12 border-[#F08386]":"bg-[#9956DE]/12 border-[#9956DE]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("p",{className:"font-bold text-foreground text-sm",children:m.student}),e.jsx("span",{className:"text-xs text-slate-500",children:m.time})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m.action," ",e.jsx("span",{className:"font-bold text-foreground",children:m.topic})]})]},m.id))]})]})]})]})},qu=oe.memo(({student:t,onViewStudent:s})=>e.jsxs(Re.div,{whileHover:{scale:1.02},onClick:()=>s(t),className:`p-4 rounded-2xl border-2 cursor-pointer hover:shadow-md transition-all ${Zu(t.riskLevel)}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-12 h-12 rounded-xl object-cover border-2 border-current"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-bold text-foreground",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.lastActive})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground",children:"Avg Score"}),e.jsxs("span",{className:"text-xs font-bold text-foreground",children:[t.avgScore,"%"]})]}),e.jsx("div",{className:"h-2 bg-card rounded-full overflow-hidden e-w",style:{"--w":`${t.avgScore}%`},children:e.jsx("div",{className:`h-full rounded-full ${t.riskLevel==="high"?"bg-[#FF8B8B]":t.riskLevel==="medium"?"bg-[#F08386]":"bg-[#75D06A]"}`})})]})]})),Yu=({selectedClass:t,students:s,riskDistribution:a,topicPerformance:r,onViewStudent:n,onBack:o,teacherOptions:l,managerUpdating:i,onAssignManager:c})=>{const[d,u]=p.useState(""),[N,m]=p.useState(""),[h,w]=p.useState([]);p.useEffect(()=>{m(t.classMetadata?.managerId||t.managerId||"")},[t]),p.useEffect(()=>{let b;return(async()=>{const{collection:T,query:z,where:$,onSnapshot:Z}=await ba(async()=>{const{collection:ee,query:re,where:ne,onSnapshot:D}=await import("./vendor-firebase-firestore-CH1lNiRF.js");return{collection:ee,query:re,where:ne,onSnapshot:D}},__vite__mapDeps([0,1])),{db:ae}=await ba(async()=>{const{db:ee}=await import("./index-BaOs5Ayg.js").then(re=>re.b1);return{db:ee}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11])),H=z(T(ae,"modules"),$("moduleType","==","teacher_uploaded"));b=Z(H,ee=>{const re=ee.docs.map(ne=>({id:ne.id,...ne.data()}));w(re)})})(),()=>{b?.()}},[]);const k=p.useMemo(()=>{const b=t.classMetadata?.classification||t.classification||"";return!b||h.length===0?[]:h.filter(T=>{const z=T.subject||"";return z.toLowerCase().includes(b.toLowerCase())||b.toLowerCase().includes(z.toLowerCase())}).slice(0,5)},[h,t]),y=p.useMemo(()=>{const b=d.trim().toLowerCase();return b?s.filter(T=>T.name.toLowerCase().includes(b)||(T.lrn||"").toLowerCase().includes(b)||(T.weakestTopic||"").toLowerCase().includes(b)):s},[d,s]),f=p.useMemo(()=>{if(s.length===0)return 0;const b=s.reduce((T,z)=>T+(z.assignmentCompletion||0),0);return Math.round(b/s.length)},[s]),v=p.useMemo(()=>{if(s.length===0)return 0;const b=s.reduce((z,$)=>z+($.attendance||0),0)/s.length,T=s.reduce((z,$)=>z+($.engagementScore||0),0)/s.length;return Math.round(b*.6+T*.4)},[s]),S=p.useMemo(()=>[...s].sort((b,T)=>T.avgScore-b.avgScore).slice(0,5),[s]),R=p.useMemo(()=>[...s].filter(b=>b.riskLevel==="high"||b.avgScore<70||b.assignmentCompletion<65).sort((b,T)=>{if(b.riskLevel!==T.riskLevel){const z={high:3,medium:2,low:1};return z[T.riskLevel]-z[b.riskLevel]}return b.avgScore-T.avgScore}).slice(0,6),[s]),j=p.useMemo(()=>l.find(b=>b.uid===N),[l,N]),B=()=>{if(!j){ce.error("Select a teacher manager first.");return}c(j)},g=[t.classMetadata?.gradeLevel||t.gradeLevel,t.classMetadata?.classification||t.classification,t.classMetadata?.strand||t.strand].filter(Boolean);return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-2 text-muted-foreground hover:text-[#9956DE] font-bold mb-6 transition-colors group",children:[e.jsx(Pt,{size:20,className:"group-hover:-translate-x-1 transition-transform"}),"Back to Dashboard"]}),e.jsx("div",{className:"bg-card rounded-2xl border border-border p-5 shadow-sm mb-6",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:t.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold border ${Ra(t.riskLevel)}`,children:t.riskLevel==="high"?"High Risk Cohort":t.riskLevel==="medium"?"Medium Risk Cohort":"Low Risk Cohort"}),g.map(b=>e.jsx("span",{className:"px-3 py-1 rounded-lg text-xs font-semibold border bg-[#9956DE]/12 border-[#9956DE]/30 text-[#9956DE]",children:b},b))]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Manager: ",t.classMetadata?.managerName||t.managerName||"Not assigned"]})]}),e.jsxs("div",{className:"min-w-[260px] bg-muted rounded-xl p-3 border border-border",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2 uppercase tracking-wide",children:"Section Manager"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{id:"analytics-section-manager-select",name:"analytics-section-manager-select","aria-label":"Select section manager",value:N||"",onChange:b=>m(b.target.value),className:"h-10 flex-1 rounded-lg border border-border bg-card px-3 text-sm focus:outline-none focus:ring-2 focus:ring-[#9956DE]/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select teacher"}),l.map(b=>e.jsxs("option",{value:b.uid,children:[b.name," (",b.email,")"]},b.uid))]}),e.jsx($e,{onClick:B,disabled:!N||i,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white",children:i?e.jsx(he,{className:"h-4 w-12 bg-white/35"}):"Assign"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Class Average"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Completion Rate"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#75D06A]",children:[f,"%"]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Participation"}),e.jsxs("p",{className:"text-2xl font-display font-bold text-[#9956DE]",children:[v,"%"]})]}),e.jsxs("div",{className:"bg-card border border-[#FF8B8B]/35 rounded-xl p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Needs Attention"}),e.jsx("p",{className:"text-2xl font-display font-bold text-[#FF8B8B]",children:R.length})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("h2",{className:"text-lg font-display font-bold text-foreground",children:["Students (",y.length,")"]}),e.jsxs("div",{className:"relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400",size:16}),e.jsx(vt,{id:"analytics-student-search",name:"analytics-student-search","aria-label":"Search students",type:"text",placeholder:"Search...",value:d,onChange:b=>u(b.target.value),className:"w-40 pl-9 pr-4 py-2 rounded-xl border-border text-sm"})]})]}),y.length===0?e.jsx("div",{className:"border border-dashed border-border rounded-xl p-4 text-sm text-muted-foreground",children:"No students match your search."}):e.jsx(Sd,{style:{height:"700px"},data:y,itemContent:(b,T)=>e.jsx(qu,{student:T,onViewStudent:n}),computeItemKey:(b,T)=>Ns(T)})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground mb-5",children:"Risk Distribution"}),e.jsx(sr,{width:"100%",height:250,children:e.jsxs(on,{data:a,children:[e.jsx(ln,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(cn,{dataKey:"name",tick:{fontSize:12}}),e.jsx(ar,{tick:{fontSize:12}}),e.jsx(rr,{}),e.jsx(dn,{dataKey:"value",radius:[8,8,0,0],children:a.map((b,T)=>e.jsx(Gi,{fill:b.color},`cell-${T}`))})]})})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-lg font-display font-bold text-foreground mb-5",children:"Topic Performance"}),e.jsx(sr,{width:"100%",height:250,children:e.jsxs(on,{data:r,children:[e.jsx(ln,{strokeDasharray:"3 3",stroke:"var(--border)"}),e.jsx(cn,{dataKey:"topic",tick:{fontSize:12}}),e.jsx(ar,{tick:{fontSize:12},domain:[0,100]}),e.jsx(rr,{}),e.jsx(dn,{dataKey:"score",fill:"#9956DE",radius:[8,8,0,0]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[e.jsx("h3",{className:"text-sm font-display font-bold text-foreground mb-3",children:"Top Performers"}),e.jsxs("div",{className:"space-y-2",children:[S.slice(0,4).map(b=>e.jsxs("button",{onClick:()=>n(b),className:"w-full flex items-center justify-between rounded-lg border border-border px-3 py-2 hover:bg-[#9956DE]/12 transition-colors",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:b.name}),e.jsxs("span",{className:"text-xs font-bold text-[#75D06A]",children:[b.avgScore,"%"]})]},`top-${Ns(b)}`)),S.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No students available yet."})]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[e.jsx("h3",{className:"text-sm font-display font-bold text-foreground mb-3",children:"Students Needing Attention"}),e.jsxs("div",{className:"space-y-2",children:[R.slice(0,4).map(b=>e.jsxs("button",{onClick:()=>n(b),className:"w-full flex items-center justify-between rounded-lg border border-[#FF8B8B]/35 bg-[#FF8B8B]/14 px-3 py-2 hover:bg-[#FF8B8B]/20 transition-colors",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:b.name}),e.jsx("span",{className:"text-xs font-bold text-[#FF8B8B]",children:b.riskLevel.toUpperCase()})]},`attention-${Ns(b)}`)),R.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students in this class right now."})]}),k.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted-foreground mb-2 flex items-center gap-1.5",children:[e.jsx(Vt,{size:12}),"Recommended Modules"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:k.map(b=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-[#9956DE]/10 border border-[#9956DE]/20 text-xs font-medium text-[#9956DE]",children:b.title||"Untitled Module"},b.moduleId||b.id))})]})]})]})]})]})]})},Ku=({student:t,teacherId:s,teacherName:a,onStudentUpdated:r,onBack:n,initialCache:o,onCacheUpdate:l})=>{const i=(t.riskLevel||"low").toLowerCase(),c=i==="high"||i==="medium",d=c?{card:"bg-[#FF8B8B]/14 border-[#FF8B8B]/35",icon:"bg-red-600",bullet:"text-[#FF8B8B]"}:{card:"bg-[#9956DE]/12 border-[#9956DE]/30",icon:"bg-[#9956DE]",bullet:"text-[#9956DE]"},u=p.useMemo(()=>Ve.getImportGroundedRolloutFlags(),[]),[N,m]=p.useState(o?.learningPath||""),[h,w]=p.useState(!0),[k,y]=p.useState(o?.gradeDraft||t.grade||"Grade 11"),[f,v]=p.useState(o?.sectionDraft||t.section||"Section A"),[S,R]=p.useState(!1),[j,B]=p.useState(o?.lessonPlan??null),[g,b]=p.useState([]),[T,z]=p.useState(""),[$,Z]=p.useState(!1),[ae,H]=p.useState(""),[ee,re]=p.useState("all"),[ne,D]=p.useState("all"),[te,J]=p.useState(!1),[me,Ce]=p.useState(!1),[F,C]=p.useState(null),[K,P]=p.useState(!1),[xe,M]=p.useState(!1),[G,X]=p.useState(0),[le,ie]=p.useState(null),[V,we]=p.useState(!1),[Pe,ke]=p.useState(!1);p.useEffect(()=>{y(t.grade||"Grade 11"),v(t.section||"Section A")},[t.grade,t.section]),p.useEffect(()=>{l?.(t.id,{lessonPlan:j,learningPath:N,gradeDraft:k,sectionDraft:f})},[j,N,k,f,t.id,l]),p.useEffect(()=>{(async()=>{w(!0);try{let Y="";try{Y=await ai(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),z(Y)}catch{z("")}const ge=await Ve.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),He=Y?`${ge.learningPath} -${Y}`:ge.learningPath;m(He)}catch{m("Unable to generate learning path. Please try again later."),z("")}finally{w(!1)}})()},[t]);const O=p.useCallback(async()=>{Z(!0),H("");try{const I=t.classSectionId||It(k||"Grade 11",f||"Section A"),Y=t.struggles.length>0?t.struggles[0]:t.weakestTopic,ge=await tm({gradeLevel:k||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[k,f].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${Y}`,learningCompetency:Y,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:I,className:[k,f].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:u.lessonEnabled,allowReviewSources:te,allowUnverifiedLesson:me},!0);B(ge),b(ge.curriculumSources||[]),C(null),Ve.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:I,className:[k,f].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:ge.usedImportedTopics,importedTopicCount:ge.importedTopicCount,blockCount:ge.blocks.length,publishReady:ge.publishReady,sourceLegitimacyStatus:ge.sourceLegitimacy.status,selfValidationPassed:ge.selfValidation.passed,importGroundingEnabled:u.lessonEnabled}})}catch(I){let Y=I instanceof Error?I.message:"Unable to generate lesson plan at this time.";if(I instanceof Os&&I.status===422)try{const He=JSON.parse(I.responseBody)?.detail;He?.message&&(Y=He.message);const Je=He?.sourceLegitimacy?.issues||[],Xe=He?.selfValidation?.issues||[],U=[...Je,...Xe].filter(Boolean).slice(0,3);U.length>0&&(Y=`${Y} ${U.join(" ")}`)}catch{}H(Y),B(null),b([]),Ve.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||It(k||"Grade 11",f||"Section A"),className:[k,f].filter(Boolean).join(" - ")||t.className,metadata:{error:Y,allowReviewSources:te,allowUnverifiedLesson:me,importGroundingEnabled:u.lessonEnabled}})}finally{Z(!1)}},[t,k,f,u.lessonEnabled,te,me]),q=p.useCallback(async()=>{if(!j)return ce.error("Generate a lesson plan first."),null;P(!0);try{const I=await Zd(j,s,{teacherName:a,studentId:t.id,studentName:t.name});return C(I),ce.success("Lesson plan saved as draft."),I}catch(I){return console.error("Failed to save lesson draft:",I),ce.error(I instanceof Error?I.message:"Failed to save lesson draft."),null}finally{P(!1)}},[j,s,a,t.id,t.name]),E=p.useCallback(async()=>{if(!j){ce.error("Generate a lesson plan first.");return}if(!j.publishReady){const I=[...j.sourceLegitimacy.issues,...j.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");ce.error(I||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}M(!0);try{let I=F;if(I||(I=await q()),!I)return;await em(I),ce.success("Lesson plan published to class content."),Ve.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:I,publishReady:j.publishReady,sourceLegitimacyStatus:j.sourceLegitimacy.status,selfValidationPassed:j.selfValidation.passed}})}catch(I){console.error("Failed to publish lesson plan:",I),ce.error(I instanceof Error?I.message:"Failed to publish lesson plan."),Ve.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",error:I instanceof Error?I.message:"Failed to publish lesson plan."}})}finally{M(!1)}},[j,F,q,t.className,t.classSectionId]);p.useEffect(()=>{O()},[G]),p.useEffect(()=>{X(I=>I+1)},[t.id]),p.useEffect(()=>{re("all"),D("all")},[j]);const W=p.useMemo(()=>j?Array.from(new Set(j.blocks.map(I=>I.provenance?.sourceFile?.trim()).filter(I=>!!I))).sort((I,Y)=>I.localeCompare(Y)):[],[j]),je=p.useMemo(()=>j?Array.from(new Set(j.blocks.map(I=>I.provenance?.materialId?.trim()).filter(I=>!!I))).sort((I,Y)=>I.localeCompare(Y)):[],[j]),pe=p.useMemo(()=>j?j.blocks.filter(I=>{const Y=ee==="all"||(I.provenance?.sourceFile||"").trim()===ee,ge=ne==="all"||(I.provenance?.materialId||"").trim()===ne;return Y&&ge}):[],[j,ee,ne]),De=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:uc},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:To},{id:3,type:"assessment",title:"Final Check",questions:5,icon:ja}],fe=async()=>{if(!s){ce.error("Unable to update section: teacher context missing");return}R(!0);try{await xl(t.id,k,f,s,new Date().getFullYear().toString(),a),await dl(t.id,k,f);const I={...t,grade:k,section:f,className:[k,f].filter(Boolean).join(" - "),classSectionId:It(k,f)};r(I),ce.success("Student section assignment updated")}catch(I){console.error("Failed to update student section assignment:",I),ce.error("Failed to update section assignment")}finally{R(!1)}},Me=async()=>{we(!0);try{const I=t.struggles?.length>0?t.struggles:[t.weakestTopic||"General academic support"],Y=await Ve.generateInterventionPlan({lrn:t.id,subject:"Mathematics",quarter:"Quarter 1",riskFactors:I});ie(Y),ke(!0),ce.success("Intervention plan generated")}catch(I){ce.error(I instanceof Error?I.message:"Failed to generate intervention plan")}finally{we(!1)}};return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:[e.jsxs("button",{onClick:n,className:"flex items-center gap-2 text-muted-foreground hover:text-[#9956DE] font-bold mb-6 transition-colors group",children:[e.jsx(Pt,{size:20,className:"group-hover:-translate-x-1 transition-transform"}),"Back to Analytics"]}),e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-24 h-24 rounded-2xl object-cover"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h1",{className:"text-3xl font-display font-bold text-foreground",children:t.name}),e.jsx("span",{className:`px-4 py-1.5 rounded-xl text-sm font-bold border-2 ${Ra(t.riskLevel)}`,children:t.riskLevel==="high"?"High Risk":t.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t.className}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Last Active"}),e.jsx("p",{className:"text-sm font-bold text-foreground",children:t.lastActive})]}),e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Weakest Topic"}),e.jsx("p",{className:"text-sm font-bold text-[#FF8B8B]",children:t.weakestTopic})]})]}),e.jsxs("div",{className:"mt-5 p-4 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-xl",children:[e.jsx("p",{className:"text-xs font-semibold text-[#9956DE] mb-3 uppercase tracking-wider",children:"Section Assignment"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(vt,{value:k,onChange:I=>y(I.target.value),placeholder:"Grade",className:"h-10"}),e.jsx(vt,{value:f,onChange:I=>v(I.target.value),placeholder:"Section",className:"h-10"}),e.jsx($e,{onClick:fe,disabled:S||!k.trim()||!f.trim(),className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white h-10",children:S?e.jsx(he,{className:"h-4 w-20 bg-white/35"}):"Save Section"})]})]})]})]})}),e.jsx("div",{className:`${d.card} border-2 rounded-2xl p-6`,children:e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsx("div",{className:`w-12 h-12 ${d.icon} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(Ca,{size:24,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground mb-2",children:c?"AI Analysis - Learning Barriers":"AI Analysis - Learning Strengths & Next Steps"}),T&&e.jsx(Bn,{sources:g,className:"mt-1"}),e.jsx(pa,{name:"teacher-intervention-analysis",loading:h,fixture:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-64"}),e.jsx(he,{className:"h-3.5 w-56"}),e.jsx(he,{className:"h-3.5 w-44"})]}),fallback:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-64"}),e.jsx(he,{className:"h-3.5 w-56"}),e.jsx(he,{className:"h-3.5 w-44"})]}),children:e.jsx("ul",{className:"space-y-2 text-foreground",children:t.struggles.length>0?t.struggles.map((I,Y)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`${d.bullet} inline-flex h-5 items-center`,children:"•"}),e.jsxs("span",{children:[c?"Struggles with ":"Continue strengthening ",e.jsx("strong",{children:I})]})]},Y)):e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`${d.bullet} inline-flex h-5 items-center`,children:"•"}),e.jsxs("span",{children:[c?"Needs support in ":"Maintain momentum in ",e.jsx("strong",{children:t.weakestTopic})]})]})})})]})]})}),e.jsxs("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground mb-6",children:"AI-Generated Learning Path"}),e.jsxs(pa,{name:"teacher-intervention-learning-path",loading:h,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"})]}),children:[N?e.jsx("div",{className:"bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-xl p-5 mb-6 text-sm text-foreground",children:e.jsx(wo,{children:N})}):null,e.jsxs("div",{className:"space-y-4 relative",children:[e.jsx("div",{className:"absolute left-6 top-8 bottom-8 w-0.5 bg-border"}),De.map((I,Y)=>{const ge=I.icon;return e.jsxs(Re.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:Y*.1},className:"relative pl-16",children:[e.jsx("div",{className:"absolute left-0 w-12 h-12 bg-gradient-to-br from-[#7274ED] to-[#9956DE] rounded-xl flex items-center justify-center shadow-md",children:e.jsx(ge,{size:24,className:"text-white"})}),e.jsx("div",{className:"bg-gradient-to-br from-[#9956DE]/12 to-[#6ED1CF]/18 border border-[#9956DE]/30 rounded-2xl p-5 hover:shadow-md transition-all",children:e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-foreground mb-1",children:I.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[I.type==="video"&&`${I.duration} video lesson`,I.type==="quiz"&&`${I.questions} practice questions`,I.type==="assessment"&&`${I.questions} assessment questions`]})]}),e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold ${I.type==="video"?"bg-[#F08386]/20 text-[#C65E63]":I.type==="quiz"?"bg-[#9956DE]/20 text-[#9956DE]":"bg-[#75D06A]/22 text-[#4D9F46]"}`,children:I.type==="video"?"Video":I.type==="quiz"?"Quiz":"Assessment"})]})})]},I.id)})]})]})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"Targeted Lesson Plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Class records drive risk signals. Import-grounded lesson generation needs uploaded course materials for topic context."})]}),e.jsx($e,{onClick:()=>X(I=>I+1),disabled:$,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white",children:$?e.jsx(he,{className:"h-4 w-20 bg-white/35"}):"Regenerate"})]}),e.jsx("p",{className:"mb-4 text-xs text-muted-foreground bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg px-3 py-2",children:"Class records alone are not enough for import-grounded lesson plans. Upload course materials in Data Import to provide lesson topic grounding."}),e.jsxs("div",{className:"mb-4 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-[#f8fafc] border border-border rounded-lg px-3 py-2",children:[e.jsx("input",{type:"checkbox",checked:te,onChange:I=>J(I.target.checked)}),"Allow sources requiring manual review"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-[#f8fafc] border border-border rounded-lg px-3 py-2",children:[e.jsx("input",{type:"checkbox",checked:me,onChange:I=>Ce(I.target.checked)}),"Allow unverified lesson draft (publish remains blocked)"]})]}),e.jsxs(pa,{name:"teacher-intervention-lesson-plan",loading:$,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-24 w-full rounded-xl"})]}),e.jsx(he,{className:"h-28 w-full rounded-xl"}),e.jsx(he,{className:"h-28 w-full rounded-xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-24 w-full rounded-xl"})]}),e.jsx(he,{className:"h-28 w-full rounded-xl"}),e.jsx(he,{className:"h-28 w-full rounded-xl"})]}),children:[ae&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A]",children:ae}),j&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-secondary border border-border rounded-xl p-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx(Bn,{sources:g})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:j.lessonTitle}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Imported topics used: ",j.usedImportedTopics?"Yes":"No"," • ","Imported topic count: ",j.importedTopicCount]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Subject: ",j.subject||"general_math"," "," • ","Quarter: Q",j.quarter||1]}),j.curriculumCompetency&&e.jsxs("p",{className:"text-xs text-[#9956DE] font-semibold mt-1",children:["Competency: ",j.curriculumCompetency]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Publish readiness: ",j.publishReady?"Ready":"Blocked"]}),j.warnings.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.warnings.join(" ")})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Curriculum Grounding"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:"Source-backed lesson basis"})]}),j.curriculumGrounding&&e.jsxs("span",{className:`px-3 py-1 rounded-full text-[11px] font-semibold border ${j.curriculumGrounding.confidenceBand==="high"?"bg-[#75D06A]/15 text-[#2E7D32] border-[#75D06A]/40":j.curriculumGrounding.confidenceBand==="medium"?"bg-amber-100 text-amber-800 border-amber-200":"bg-[#FF8B8B]/14 text-[#C65E63] border-[#FF8B8B]/35"}`,children:[j.curriculumGrounding.confidenceBand.toUpperCase()," confidence"]})]}),j.lessonObjective&&e.jsxs("div",{className:"bg-muted/60 rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Lesson objective"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:j.lessonObjective})]}),j.realWorldHook&&e.jsxs("div",{className:"bg-[#9956DE]/10 border border-[#9956DE]/20 rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#9956DE] uppercase tracking-wider",children:"Real-life application"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:j.realWorldHook})]}),j.curriculumGrounding&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 text-xs",children:[e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Retrieval confidence"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[Math.round((j.curriculumGrounding.confidence||0)*100),"%"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Retrieved chunks"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:j.curriculumGrounding.retrievedChunks})]}),e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Review state"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:j.needsReview?"Needs review":"Ready for review"})]})]}),j.explanation&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-1",children:"Explanation"}),e.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:j.explanation})]}),e.jsxs("details",{className:"group rounded-xl border border-border bg-card p-3",children:[e.jsxs("summary",{className:"cursor-pointer list-none text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center justify-between gap-2",children:["Retrieved source snippets",e.jsx("span",{className:"text-[11px] text-[#9956DE] group-open:rotate-180 transition-transform",children:"▾"})]}),e.jsx("div",{className:"mt-3 space-y-2",children:(j.retrievedEvidence?.length||0)>0?j.retrievedEvidence?.map((I,Y)=>e.jsxs("div",{className:"rounded-xl bg-muted/60 border border-border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:I.sourceFile||"Curriculum source"}),e.jsxs("span",{children:["p.",I.page||"?"]}),e.jsx("span",{children:I.contentDomain||"n/a"}),e.jsxs("span",{children:["score ",(I.score*100).toFixed(1),"%"]})]}),e.jsx("p",{className:"text-sm text-foreground mt-2 leading-relaxed",children:I.content})]},`${I.sourceFile||"source"}-${I.page||Y}`)):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No retrieved snippets were returned."})})]}),j.sourceCitations&&j.sourceCitations.length>0&&e.jsxs("div",{className:"rounded-xl bg-muted/50 border border-border p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"Source citations"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:j.sourceCitations.slice(0,6).map(I=>e.jsx("span",{className:"px-2 py-1 rounded-full bg-card border border-border text-[11px] text-foreground",children:I},I))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Source Legitimacy"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[j.sourceLegitimacy.status," (",Math.round(j.sourceLegitimacy.score*100),"%)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Verified: ",j.sourceLegitimacy.verifiedMaterials," "," • ","Review: ",j.sourceLegitimacy.reviewMaterials," "," • ","Rejected: ",j.sourceLegitimacy.rejectedMaterials]}),j.sourceLegitimacy.issues.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.sourceLegitimacy.issues.slice(0,2).join(" ")})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Self Validation"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[j.selfValidation.passed?"Passed":"Failed"," (",Math.round(j.selfValidation.score*100),"%)"]}),j.selfValidation.issues.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.selfValidation.issues.slice(0,2).join(" ")})]})]}),(W.length>0||je.length>0)&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Provenance Filters"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"text-xs text-muted-foreground flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Source File"}),e.jsxs("select",{value:ee,onChange:I=>re(I.target.value),className:"bg-card border border-border rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All sources"}),W.map(I=>e.jsx("option",{value:I,children:I},I))]})]}),e.jsxs("label",{className:"text-xs text-muted-foreground flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Material ID"}),e.jsxs("select",{value:ne,onChange:I=>D(I.target.value),className:"bg-card border border-border rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All materials"}),je.map(I=>e.jsx("option",{value:I,children:I},I))]})]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-2",children:["Showing ",pe.length," of ",j.blocks.length," lesson blocks after provenance filters."]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:pe.map(I=>e.jsxs("div",{className:"border border-border rounded-xl p-4 bg-[#fcfdff]",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:I.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[I.estimatedMinutes," mins "," • "," ",I.strategy]}),e.jsx("p",{className:"text-sm text-foreground mt-2",children:I.objective}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Activities"}),I.activities.slice(0,2).map((Y,ge)=>e.jsxs("p",{className:"text-xs text-muted-foreground",children:["•"," ",Y]},ge))]}),I.provenance&&e.jsxs("div",{className:"mt-3 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg p-2",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#9956DE]",children:"Provenance"}),I.provenance.sourceFile&&e.jsxs("p",{className:"text-[11px] text-[#5E3388]",children:["Source: ",I.provenance.sourceFile]}),I.provenance.materialId&&e.jsxs("p",{className:"text-[11px] text-[#5E3388]",children:["Material: ",I.provenance.materialId]})]})]},I.blockId))}),pe.length===0&&e.jsx("div",{className:"border border-border rounded-xl p-4 bg-card text-sm text-muted-foreground",children:"No lesson blocks match the selected provenance filters. Clear one or both filters to view all blocks."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx($e,{variant:"outline",onClick:()=>void q(),disabled:K||!j,className:"border-[#9956DE]/45 text-[#9956DE]",children:K?e.jsx(he,{className:"h-4 w-16"}):"Save Draft"}),e.jsx($e,{onClick:()=>void E(),disabled:xe||!j||!j.publishReady,className:"bg-[#75D06A] hover:bg-[#5AB84E] text-white",children:xe?e.jsx(he,{className:"h-4 w-24 bg-white/35"}):"Publish Lesson Plan"}),F&&e.jsxs("p",{className:"text-xs text-muted-foreground self-center",children:["Draft ID: ",F]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsx($e,{onClick:Me,disabled:V,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 rounded-full bg-white/30 animate-pulse"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{size:20}),"Generate Intervention Plan"]})}),e.jsxs($e,{className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:[e.jsx(zs,{size:20}),"Schedule One-on-One Session"]}),e.jsxs($e,{variant:"outline",className:"border-2 border-[#9956DE] text-[#9956DE] hover:bg-[#9956DE]/12 font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:[e.jsx(gr,{size:20}),"Export Printed Materials"]})]}),e.jsx(xo,{open:Pe,onOpenChange:ke,children:e.jsxs(ho,{className:"max-w-lg",children:[e.jsxs(po,{children:[e.jsxs(fo,{className:"flex items-center gap-2 text-[#9956DE]",children:[e.jsx($s,{size:20}),"Intervention Plan"]}),e.jsxs(go,{children:["AI-generated 3-step intervention plan for"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.name})]})]}),le?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"bg-[#9956DE]/8 border border-[#9956DE]/25 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-bold text-foreground mb-1",children:"Overall Plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:le.plan})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Recommended Strategies"}),e.jsx("div",{className:"space-y-2",children:le.strategies.map((I,Y)=>e.jsxs("div",{className:"flex items-start gap-3 bg-muted/50 border border-border rounded-lg p-3",children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-[#9956DE]/15 text-[#9956DE] flex items-center justify-center text-xs font-bold",children:Y+1}),e.jsx("p",{className:"text-sm text-foreground",children:I})]},Y))})]})]}):e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:'No plan generated yet. Click "Generate Intervention Plan" to create one.'}),e.jsxs(bo,{className:"gap-2 sm:gap-0",children:[e.jsx($e,{variant:"default",size:"sm",className:"bg-emerald-600 hover:bg-emerald-700 text-white",onClick:async()=>{try{const{setDoc:I,doc:Y,serverTimestamp:ge}=await ba(async()=>{const{setDoc:Je,doc:Xe,serverTimestamp:U}=await import("./vendor-firebase-firestore-CH1lNiRF.js");return{setDoc:Je,doc:Xe,serverTimestamp:U}},__vite__mapDeps([0,1])),{db:He}=await ba(async()=>{const{db:Je}=await import("./index-Cb8VeSuW.js").then(Xe=>Xe.aU);return{db:Je}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11]));await I(Y(He,"managedStudents",s,"students",t.id),{interventionApplied:!0,interventionAppliedAt:ge()},{merge:!0}),ce.success("Intervention plan marked as applied"),ke(!1)}catch{ce.error("Failed to mark as applied")}},children:"Mark as Applied"}),e.jsx(oi,{asChild:!0,children:e.jsx($e,{variant:"outline",size:"sm",children:"Close"})})]})]})})]})]})]})},Xu=({onEditRecords:t,classSectionId:s,className:a,classMetadata:r,onImportedClassRecords:n,onDataChanged:o})=>{const[l,i]=p.useState(null),[c,d]=p.useState(!1),[u,N]=p.useState(!1),[m,h]=p.useState(!1),[w,k]=p.useState(!1),[y,f]=p.useState(""),[v,S]=p.useState(r?.classification||""),[R,j]=p.useState(""),[B,g]=p.useState(r?.strand||""),[b,T]=p.useState(r?.gradeLevel?.toString()||"");p.useEffect(()=>{const O=()=>{const q=new Date().getMonth()+1;return q<=3?"Quarter 1":q<=6?"Quarter 2":q<=9?"Quarter 3":"Quarter 4"};j(q=>q||O())},[r]);const[z,$]=p.useState(null),Z=p.useRef(null),ae=p.useRef(null),[H,ee]=p.useState(null),[re,ne]=p.useState(!1),[D,te]=p.useState(!1),J=p.useRef(null),[me,Ce]=p.useState(null),F=O=>O.trim().toLowerCase().replace(/\s+/g," "),C=O=>{if(typeof O=="number"&&Number.isFinite(O))return O;const q=Number(String(O??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(q)?q:null},K=(O,q)=>{const E=Number.isFinite(O)?O:q;return Math.max(0,Math.min(100,E))},P=O=>{const q=String(O??"");return/[",\n]/.test(q)?`"${q.replace(/"/g,'""')}"`:q},xe=(O,q)=>{const E=new Map,W=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];O.mapping.gradeEntities.forEach(ge=>{const He=F(ge.fullName||"");if(!He)return;const Je=W.map(U=>C(ge[U])).filter(U=>U!==null);if(Je.length===0)return;const Xe=E.get(He)||[];E.set(He,Xe.concat(Je))});const je=O.mapping.studentEntities||[];if(je.length===0)return null;const pe=(O.imported.schoolContext.semester||O.imported.schoolContext.schoolYear||"First Semester").trim(),De=(O.imported.schoolContext.subjectName||"Class Record Import").trim(),fe=(s||a||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",I=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(je.forEach((ge,He)=>{const Je=F(ge.fullName||""),Xe=E.get(Je)||[],U=Xe.length>0?Xe.reduce((ks,aa)=>ks+aa,0)/Xe.length:75,ue=K(U,75),Be=K(ue+5,85),Te=K(ue*.7+Be*.3,80),tt=K(Be*.6+ue*.4,82),xt=ge.learnerNo||He+1,Aa=`IMP-${fe}-${String(xt).padStart(4,"0")}`,es=ge.fullName||`Learner ${He+1}`;I.push([P(es),P(Aa),P(""),P(Number(Te.toFixed(1))),P(Number(ue.toFixed(1))),P(Number(Be.toFixed(1))),P(Number(tt.toFixed(1))),P(pe),P(De)].join(","))}),I.length<=1)return null;const Y=q.replace(/\.(xlsx|xls)$/i,"");return new File([I.join(` +${Y}`:ge.learningPath;m(He)}catch{m("Unable to generate learning path. Please try again later."),z("")}finally{w(!1)}})()},[t]);const O=p.useCallback(async()=>{Z(!0),H("");try{const I=t.classSectionId||It(k||"Grade 11",f||"Section A"),Y=t.struggles.length>0?t.struggles[0]:t.weakestTopic,ge=await tm({gradeLevel:k||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[k,f].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${Y}`,learningCompetency:Y,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:I,className:[k,f].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:u.lessonEnabled,allowReviewSources:te,allowUnverifiedLesson:me},!0);B(ge),b(ge.curriculumSources||[]),C(null),Ve.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:I,className:[k,f].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:ge.usedImportedTopics,importedTopicCount:ge.importedTopicCount,blockCount:ge.blocks.length,publishReady:ge.publishReady,sourceLegitimacyStatus:ge.sourceLegitimacy.status,selfValidationPassed:ge.selfValidation.passed,importGroundingEnabled:u.lessonEnabled}})}catch(I){let Y=I instanceof Error?I.message:"Unable to generate lesson plan at this time.";if(I instanceof Os&&I.status===422)try{const He=JSON.parse(I.responseBody)?.detail;He?.message&&(Y=He.message);const Je=He?.sourceLegitimacy?.issues||[],Xe=He?.selfValidation?.issues||[],U=[...Je,...Xe].filter(Boolean).slice(0,3);U.length>0&&(Y=`${Y} ${U.join(" ")}`)}catch{}H(Y),B(null),b([]),Ve.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||It(k||"Grade 11",f||"Section A"),className:[k,f].filter(Boolean).join(" - ")||t.className,metadata:{error:Y,allowReviewSources:te,allowUnverifiedLesson:me,importGroundingEnabled:u.lessonEnabled}})}finally{Z(!1)}},[t,k,f,u.lessonEnabled,te,me]),q=p.useCallback(async()=>{if(!j)return ce.error("Generate a lesson plan first."),null;P(!0);try{const I=await Zd(j,s,{teacherName:a,studentId:t.id,studentName:t.name});return C(I),ce.success("Lesson plan saved as draft."),I}catch(I){return console.error("Failed to save lesson draft:",I),ce.error(I instanceof Error?I.message:"Failed to save lesson draft."),null}finally{P(!1)}},[j,s,a,t.id,t.name]),E=p.useCallback(async()=>{if(!j){ce.error("Generate a lesson plan first.");return}if(!j.publishReady){const I=[...j.sourceLegitimacy.issues,...j.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");ce.error(I||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}M(!0);try{let I=F;if(I||(I=await q()),!I)return;await em(I),ce.success("Lesson plan published to class content."),Ve.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:I,publishReady:j.publishReady,sourceLegitimacyStatus:j.sourceLegitimacy.status,selfValidationPassed:j.selfValidation.passed}})}catch(I){console.error("Failed to publish lesson plan:",I),ce.error(I instanceof Error?I.message:"Failed to publish lesson plan."),Ve.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",error:I instanceof Error?I.message:"Failed to publish lesson plan."}})}finally{M(!1)}},[j,F,q,t.className,t.classSectionId]);p.useEffect(()=>{O()},[G]),p.useEffect(()=>{X(I=>I+1)},[t.id]),p.useEffect(()=>{re("all"),D("all")},[j]);const W=p.useMemo(()=>j?Array.from(new Set(j.blocks.map(I=>I.provenance?.sourceFile?.trim()).filter(I=>!!I))).sort((I,Y)=>I.localeCompare(Y)):[],[j]),je=p.useMemo(()=>j?Array.from(new Set(j.blocks.map(I=>I.provenance?.materialId?.trim()).filter(I=>!!I))).sort((I,Y)=>I.localeCompare(Y)):[],[j]),pe=p.useMemo(()=>j?j.blocks.filter(I=>{const Y=ee==="all"||(I.provenance?.sourceFile||"").trim()===ee,ge=ne==="all"||(I.provenance?.materialId||"").trim()===ne;return Y&&ge}):[],[j,ee,ne]),De=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:uc},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:To},{id:3,type:"assessment",title:"Final Check",questions:5,icon:ja}],fe=async()=>{if(!s){ce.error("Unable to update section: teacher context missing");return}R(!0);try{await xl(t.id,k,f,s,new Date().getFullYear().toString(),a),await dl(t.id,k,f);const I={...t,grade:k,section:f,className:[k,f].filter(Boolean).join(" - "),classSectionId:It(k,f)};r(I),ce.success("Student section assignment updated")}catch(I){console.error("Failed to update student section assignment:",I),ce.error("Failed to update section assignment")}finally{R(!1)}},Me=async()=>{we(!0);try{const I=t.struggles?.length>0?t.struggles:[t.weakestTopic||"General academic support"],Y=await Ve.generateInterventionPlan({lrn:t.id,subject:"Mathematics",quarter:"Quarter 1",riskFactors:I});ie(Y),ke(!0),ce.success("Intervention plan generated")}catch(I){ce.error(I instanceof Error?I.message:"Failed to generate intervention plan")}finally{we(!1)}};return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:[e.jsxs("button",{onClick:n,className:"flex items-center gap-2 text-muted-foreground hover:text-[#9956DE] font-bold mb-6 transition-colors group",children:[e.jsx(Pt,{size:20,className:"group-hover:-translate-x-1 transition-transform"}),"Back to Analytics"]}),e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-24 h-24 rounded-2xl object-cover"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h1",{className:"text-3xl font-display font-bold text-foreground",children:t.name}),e.jsx("span",{className:`px-4 py-1.5 rounded-xl text-sm font-bold border-2 ${Ra(t.riskLevel)}`,children:t.riskLevel==="high"?"High Risk":t.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t.className}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Last Active"}),e.jsx("p",{className:"text-sm font-bold text-foreground",children:t.lastActive})]}),e.jsxs("div",{className:"bg-muted rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Weakest Topic"}),e.jsx("p",{className:"text-sm font-bold text-[#FF8B8B]",children:t.weakestTopic})]})]}),e.jsxs("div",{className:"mt-5 p-4 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-xl",children:[e.jsx("p",{className:"text-xs font-semibold text-[#9956DE] mb-3 uppercase tracking-wider",children:"Section Assignment"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(vt,{value:k,onChange:I=>y(I.target.value),placeholder:"Grade",className:"h-10"}),e.jsx(vt,{value:f,onChange:I=>v(I.target.value),placeholder:"Section",className:"h-10"}),e.jsx($e,{onClick:fe,disabled:S||!k.trim()||!f.trim(),className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white h-10",children:S?e.jsx(he,{className:"h-4 w-20 bg-white/35"}):"Save Section"})]})]})]})]})}),e.jsx("div",{className:`${d.card} border-2 rounded-2xl p-6`,children:e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsx("div",{className:`w-12 h-12 ${d.icon} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(Ca,{size:24,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground mb-2",children:c?"AI Analysis - Learning Barriers":"AI Analysis - Learning Strengths & Next Steps"}),T&&e.jsx(Bn,{sources:g,className:"mt-1"}),e.jsx(pa,{name:"teacher-intervention-analysis",loading:h,fixture:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-64"}),e.jsx(he,{className:"h-3.5 w-56"}),e.jsx(he,{className:"h-3.5 w-44"})]}),fallback:e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(he,{className:"h-3.5 w-64"}),e.jsx(he,{className:"h-3.5 w-56"}),e.jsx(he,{className:"h-3.5 w-44"})]}),children:e.jsx("ul",{className:"space-y-2 text-foreground",children:t.struggles.length>0?t.struggles.map((I,Y)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`${d.bullet} inline-flex h-5 items-center`,children:"•"}),e.jsxs("span",{children:[c?"Struggles with ":"Continue strengthening ",e.jsx("strong",{children:I})]})]},Y)):e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`${d.bullet} inline-flex h-5 items-center`,children:"•"}),e.jsxs("span",{children:[c?"Needs support in ":"Maintain momentum in ",e.jsx("strong",{children:t.weakestTopic})]})]})})})]})]})}),e.jsxs("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground mb-6",children:"AI-Generated Learning Path"}),e.jsxs(pa,{name:"teacher-intervention-learning-path",loading:h,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"}),e.jsx(he,{className:"h-20 w-full rounded-2xl"})]}),children:[N?e.jsx("div",{className:"bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-xl p-5 mb-6 text-sm text-foreground",children:e.jsx(wo,{children:N})}):null,e.jsxs("div",{className:"space-y-4 relative",children:[e.jsx("div",{className:"absolute left-6 top-8 bottom-8 w-0.5 bg-border"}),De.map((I,Y)=>{const ge=I.icon;return e.jsxs(Re.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:Y*.1},className:"relative pl-16",children:[e.jsx("div",{className:"absolute left-0 w-12 h-12 bg-gradient-to-br from-[#7274ED] to-[#9956DE] rounded-xl flex items-center justify-center shadow-md",children:e.jsx(ge,{size:24,className:"text-white"})}),e.jsx("div",{className:"bg-gradient-to-br from-[#9956DE]/12 to-[#6ED1CF]/18 border border-[#9956DE]/30 rounded-2xl p-5 hover:shadow-md transition-all",children:e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-foreground mb-1",children:I.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[I.type==="video"&&`${I.duration} video lesson`,I.type==="quiz"&&`${I.questions} practice questions`,I.type==="assessment"&&`${I.questions} assessment questions`]})]}),e.jsx("span",{className:`px-3 py-1 rounded-lg text-xs font-bold ${I.type==="video"?"bg-[#F08386]/20 text-[#C65E63]":I.type==="quiz"?"bg-[#9956DE]/20 text-[#9956DE]":"bg-[#75D06A]/22 text-[#4D9F46]"}`,children:I.type==="video"?"Video":I.type==="quiz"?"Quiz":"Assessment"})]})})]},I.id)})]})]})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-8 shadow-sm border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"Targeted Lesson Plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Class records drive risk signals. Import-grounded lesson generation needs uploaded course materials for topic context."})]}),e.jsx($e,{onClick:()=>X(I=>I+1),disabled:$,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white",children:$?e.jsx(he,{className:"h-4 w-20 bg-white/35"}):"Regenerate"})]}),e.jsx("p",{className:"mb-4 text-xs text-muted-foreground bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg px-3 py-2",children:"Class records alone are not enough for import-grounded lesson plans. Upload course materials in Data Import to provide lesson topic grounding."}),e.jsxs("div",{className:"mb-4 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-[#f8fafc] border border-border rounded-lg px-3 py-2",children:[e.jsx("input",{type:"checkbox",checked:te,onChange:I=>J(I.target.checked)}),"Allow sources requiring manual review"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-[#f8fafc] border border-border rounded-lg px-3 py-2",children:[e.jsx("input",{type:"checkbox",checked:me,onChange:I=>Ce(I.target.checked)}),"Allow unverified lesson draft (publish remains blocked)"]})]}),e.jsxs(pa,{name:"teacher-intervention-lesson-plan",loading:$,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-24 w-full rounded-xl"})]}),e.jsx(he,{className:"h-28 w-full rounded-xl"}),e.jsx(he,{className:"h-28 w-full rounded-xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(he,{className:"h-24 w-full rounded-xl"}),e.jsx(he,{className:"h-24 w-full rounded-xl"})]}),e.jsx(he,{className:"h-28 w-full rounded-xl"}),e.jsx(he,{className:"h-28 w-full rounded-xl"})]}),children:[ae&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A]",children:ae}),j&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-secondary border border-border rounded-xl p-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx(Bn,{sources:g})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:j.lessonTitle}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Imported topics used: ",j.usedImportedTopics?"Yes":"No"," • ","Imported topic count: ",j.importedTopicCount]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Subject: ",j.subject||"general_math"," "," • ","Quarter: Q",j.quarter||1]}),j.curriculumCompetency&&e.jsxs("p",{className:"text-xs text-[#9956DE] font-semibold mt-1",children:["Competency: ",j.curriculumCompetency]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Publish readiness: ",j.publishReady?"Ready":"Blocked"]}),j.warnings.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.warnings.join(" ")})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Curriculum Grounding"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:"Source-backed lesson basis"})]}),j.curriculumGrounding&&e.jsxs("span",{className:`px-3 py-1 rounded-full text-[11px] font-semibold border ${j.curriculumGrounding.confidenceBand==="high"?"bg-[#75D06A]/15 text-[#2E7D32] border-[#75D06A]/40":j.curriculumGrounding.confidenceBand==="medium"?"bg-amber-100 text-amber-800 border-amber-200":"bg-[#FF8B8B]/14 text-[#C65E63] border-[#FF8B8B]/35"}`,children:[j.curriculumGrounding.confidenceBand.toUpperCase()," confidence"]})]}),j.lessonObjective&&e.jsxs("div",{className:"bg-muted/60 rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Lesson objective"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:j.lessonObjective})]}),j.realWorldHook&&e.jsxs("div",{className:"bg-[#9956DE]/10 border border-[#9956DE]/20 rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#9956DE] uppercase tracking-wider",children:"Real-life application"}),e.jsx("p",{className:"text-sm text-foreground mt-1",children:j.realWorldHook})]}),j.curriculumGrounding&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 text-xs",children:[e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Retrieval confidence"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[Math.round((j.curriculumGrounding.confidence||0)*100),"%"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Retrieved chunks"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:j.curriculumGrounding.retrievedChunks})]}),e.jsxs("div",{className:"bg-muted/50 rounded-xl p-3",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Review state"}),e.jsx("p",{className:"text-sm font-bold text-foreground mt-1",children:j.needsReview?"Needs review":"Ready for review"})]})]}),j.explanation&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-1",children:"Explanation"}),e.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:j.explanation})]}),e.jsxs("details",{className:"group rounded-xl border border-border bg-card p-3",children:[e.jsxs("summary",{className:"cursor-pointer list-none text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center justify-between gap-2",children:["Retrieved source snippets",e.jsx("span",{className:"text-[11px] text-[#9956DE] group-open:rotate-180 transition-transform",children:"▾"})]}),e.jsx("div",{className:"mt-3 space-y-2",children:(j.retrievedEvidence?.length||0)>0?j.retrievedEvidence?.map((I,Y)=>e.jsxs("div",{className:"rounded-xl bg-muted/60 border border-border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:I.sourceFile||"Curriculum source"}),e.jsxs("span",{children:["p.",I.page||"?"]}),e.jsx("span",{children:I.contentDomain||"n/a"}),e.jsxs("span",{children:["score ",(I.score*100).toFixed(1),"%"]})]}),e.jsx("p",{className:"text-sm text-foreground mt-2 leading-relaxed",children:I.content})]},`${I.sourceFile||"source"}-${I.page||Y}`)):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No retrieved snippets were returned."})})]}),j.sourceCitations&&j.sourceCitations.length>0&&e.jsxs("div",{className:"rounded-xl bg-muted/50 border border-border p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"Source citations"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:j.sourceCitations.slice(0,6).map(I=>e.jsx("span",{className:"px-2 py-1 rounded-full bg-card border border-border text-[11px] text-foreground",children:I},I))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Source Legitimacy"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[j.sourceLegitimacy.status," (",Math.round(j.sourceLegitimacy.score*100),"%)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Verified: ",j.sourceLegitimacy.verifiedMaterials," "," • ","Review: ",j.sourceLegitimacy.reviewMaterials," "," • ","Rejected: ",j.sourceLegitimacy.rejectedMaterials]}),j.sourceLegitimacy.issues.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.sourceLegitimacy.issues.slice(0,2).join(" ")})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Self Validation"}),e.jsxs("p",{className:"text-sm font-bold text-foreground mt-1",children:[j.selfValidation.passed?"Passed":"Failed"," (",Math.round(j.selfValidation.score*100),"%)"]}),j.selfValidation.issues.length>0&&e.jsx("p",{className:"text-xs text-[#CC8A37] mt-1",children:j.selfValidation.issues.slice(0,2).join(" ")})]})]}),(W.length>0||je.length>0)&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Provenance Filters"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"text-xs text-muted-foreground flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Source File"}),e.jsxs("select",{value:ee,onChange:I=>re(I.target.value),className:"bg-card border border-border rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All sources"}),W.map(I=>e.jsx("option",{value:I,children:I},I))]})]}),e.jsxs("label",{className:"text-xs text-muted-foreground flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Material ID"}),e.jsxs("select",{value:ne,onChange:I=>D(I.target.value),className:"bg-card border border-border rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All materials"}),je.map(I=>e.jsx("option",{value:I,children:I},I))]})]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-2",children:["Showing ",pe.length," of ",j.blocks.length," lesson blocks after provenance filters."]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:pe.map(I=>e.jsxs("div",{className:"border border-border rounded-xl p-4 bg-[#fcfdff]",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:I.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[I.estimatedMinutes," mins "," • "," ",I.strategy]}),e.jsx("p",{className:"text-sm text-foreground mt-2",children:I.objective}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Activities"}),I.activities.slice(0,2).map((Y,ge)=>e.jsxs("p",{className:"text-xs text-muted-foreground",children:["•"," ",Y]},ge))]}),I.provenance&&e.jsxs("div",{className:"mt-3 bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-lg p-2",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#9956DE]",children:"Provenance"}),I.provenance.sourceFile&&e.jsxs("p",{className:"text-[11px] text-[#5E3388]",children:["Source: ",I.provenance.sourceFile]}),I.provenance.materialId&&e.jsxs("p",{className:"text-[11px] text-[#5E3388]",children:["Material: ",I.provenance.materialId]})]})]},I.blockId))}),pe.length===0&&e.jsx("div",{className:"border border-border rounded-xl p-4 bg-card text-sm text-muted-foreground",children:"No lesson blocks match the selected provenance filters. Clear one or both filters to view all blocks."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx($e,{variant:"outline",onClick:()=>void q(),disabled:K||!j,className:"border-[#9956DE]/45 text-[#9956DE]",children:K?e.jsx(he,{className:"h-4 w-16"}):"Save Draft"}),e.jsx($e,{onClick:()=>void E(),disabled:xe||!j||!j.publishReady,className:"bg-[#75D06A] hover:bg-[#5AB84E] text-white",children:xe?e.jsx(he,{className:"h-4 w-24 bg-white/35"}):"Publish Lesson Plan"}),F&&e.jsxs("p",{className:"text-xs text-muted-foreground self-center",children:["Draft ID: ",F]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsx($e,{onClick:Me,disabled:V,className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 rounded-full bg-white/30 animate-pulse"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{size:20}),"Generate Intervention Plan"]})}),e.jsxs($e,{className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:[e.jsx(zs,{size:20}),"Schedule One-on-One Session"]}),e.jsxs($e,{variant:"outline",className:"border-2 border-[#9956DE] text-[#9956DE] hover:bg-[#9956DE]/12 font-bold py-4 rounded-xl flex items-center justify-center gap-2",children:[e.jsx(gr,{size:20}),"Export Printed Materials"]})]}),e.jsx(xo,{open:Pe,onOpenChange:ke,children:e.jsxs(ho,{className:"max-w-lg",children:[e.jsxs(po,{children:[e.jsxs(fo,{className:"flex items-center gap-2 text-[#9956DE]",children:[e.jsx($s,{size:20}),"Intervention Plan"]}),e.jsxs(go,{children:["AI-generated 3-step intervention plan for"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.name})]})]}),le?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"bg-[#9956DE]/8 border border-[#9956DE]/25 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-bold text-foreground mb-1",children:"Overall Plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:le.plan})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Recommended Strategies"}),e.jsx("div",{className:"space-y-2",children:le.strategies.map((I,Y)=>e.jsxs("div",{className:"flex items-start gap-3 bg-muted/50 border border-border rounded-lg p-3",children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-[#9956DE]/15 text-[#9956DE] flex items-center justify-center text-xs font-bold",children:Y+1}),e.jsx("p",{className:"text-sm text-foreground",children:I})]},Y))})]})]}):e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:'No plan generated yet. Click "Generate Intervention Plan" to create one.'}),e.jsxs(bo,{className:"gap-2 sm:gap-0",children:[e.jsx($e,{variant:"default",size:"sm",className:"bg-emerald-600 hover:bg-emerald-700 text-white",onClick:async()=>{try{const{setDoc:I,doc:Y,serverTimestamp:ge}=await ba(async()=>{const{setDoc:Je,doc:Xe,serverTimestamp:U}=await import("./vendor-firebase-firestore-CH1lNiRF.js");return{setDoc:Je,doc:Xe,serverTimestamp:U}},__vite__mapDeps([0,1])),{db:He}=await ba(async()=>{const{db:Je}=await import("./index-BaOs5Ayg.js").then(Xe=>Xe.b1);return{db:Je}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11]));await I(Y(He,"managedStudents",s,"students",t.id),{interventionApplied:!0,interventionAppliedAt:ge()},{merge:!0}),ce.success("Intervention plan marked as applied"),ke(!1)}catch{ce.error("Failed to mark as applied")}},children:"Mark as Applied"}),e.jsx(oi,{asChild:!0,children:e.jsx($e,{variant:"outline",size:"sm",children:"Close"})})]})]})})]})]})]})},Xu=({onEditRecords:t,classSectionId:s,className:a,classMetadata:r,onImportedClassRecords:n,onDataChanged:o})=>{const[l,i]=p.useState(null),[c,d]=p.useState(!1),[u,N]=p.useState(!1),[m,h]=p.useState(!1),[w,k]=p.useState(!1),[y,f]=p.useState(""),[v,S]=p.useState(r?.classification||""),[R,j]=p.useState(""),[B,g]=p.useState(r?.strand||""),[b,T]=p.useState(r?.gradeLevel?.toString()||"");p.useEffect(()=>{const O=()=>{const q=new Date().getMonth()+1;return q<=3?"Quarter 1":q<=6?"Quarter 2":q<=9?"Quarter 3":"Quarter 4"};j(q=>q||O())},[r]);const[z,$]=p.useState(null),Z=p.useRef(null),ae=p.useRef(null),[H,ee]=p.useState(null),[re,ne]=p.useState(!1),[D,te]=p.useState(!1),J=p.useRef(null),[me,Ce]=p.useState(null),F=O=>O.trim().toLowerCase().replace(/\s+/g," "),C=O=>{if(typeof O=="number"&&Number.isFinite(O))return O;const q=Number(String(O??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(q)?q:null},K=(O,q)=>{const E=Number.isFinite(O)?O:q;return Math.max(0,Math.min(100,E))},P=O=>{const q=String(O??"");return/[",\n]/.test(q)?`"${q.replace(/"/g,'""')}"`:q},xe=(O,q)=>{const E=new Map,W=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];O.mapping.gradeEntities.forEach(ge=>{const He=F(ge.fullName||"");if(!He)return;const Je=W.map(U=>C(ge[U])).filter(U=>U!==null);if(Je.length===0)return;const Xe=E.get(He)||[];E.set(He,Xe.concat(Je))});const je=O.mapping.studentEntities||[];if(je.length===0)return null;const pe=(O.imported.schoolContext.semester||O.imported.schoolContext.schoolYear||"First Semester").trim(),De=(O.imported.schoolContext.subjectName||"Class Record Import").trim(),fe=(s||a||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",I=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(je.forEach((ge,He)=>{const Je=F(ge.fullName||""),Xe=E.get(Je)||[],U=Xe.length>0?Xe.reduce((ks,aa)=>ks+aa,0)/Xe.length:75,ue=K(U,75),Be=K(ue+5,85),Te=K(ue*.7+Be*.3,80),tt=K(Be*.6+ue*.4,82),xt=ge.learnerNo||He+1,Aa=`IMP-${fe}-${String(xt).padStart(4,"0")}`,es=ge.fullName||`Learner ${He+1}`;I.push([P(es),P(Aa),P(""),P(Number(Te.toFixed(1))),P(Number(ue.toFixed(1))),P(Number(Be.toFixed(1))),P(Number(tt.toFixed(1))),P(pe),P(De)].join(","))}),I.length<=1)return null;const Y=q.replace(/\.(xlsx|xls)$/i,"");return new File([I.join(` `)],`${Y}-normalized.csv`,{type:"text/csv"})},M=async O=>{h(!0),f(""),$(null);let q=O;if(/\.(xlsx|xls)$/i.test(O.name))try{const E=await Eu(O,{confidenceThreshold:xr});i(E);const W=xe(E,O.name);W&&(q=W)}catch{i(null)}else i(null);try{const E=await Ve.uploadClassRecords(q,{classSectionId:s,className:a,datasetIntent:"synthetic_student_records"}),W=E.students.length,je=E.warnings&&E.warnings.length>0?E.warnings.slice(0,3).join(" "):"",pe=E.dashboardSync?` Dashboard sync: ${E.dashboardSync.synced?"ok":"pending"} (created ${E.dashboardSync.createdStudents}, updated ${E.dashboardSync.updatedStudents}).`:"",De=Uu(E,s,a,r);if(W>0&&n?.({students:E.students,classSectionId:De.classSectionId,className:De.className,classMetadata:De.classMetadata}),E.success){ce.success(`Successfully imported ${W} student records. Next step: upload course materials for AI lesson-plan grounding.`);const fe=E.riskRefresh?.queued?` Risk refresh queued for ${E.riskRefresh.studentsQueued} students (job ${E.riskRefresh.refreshId||"n/a"}).`:` Risk refresh not queued${E.riskRefresh?.reason?`: ${E.riskRefresh.reason}`:""}.`,Me=E.interpretationSummary,I=Me?` Interpreted columns - scoring: ${Me.scoringColumns}, display: ${Me.displayColumns}, storage-only: ${Me.storageOnlyColumns}, low-confidence: ${Me.lowConfidenceColumns}.`:"",Y=je?` Warnings: ${je}`:"";f(`Imported ${W} students. Next step: upload course materials to give AI lesson generation topic context.${fe}${pe}${I}${Y} Column mapping: ${JSON.stringify(E.columnMapping)}`),$({datasetIntent:E.datasetIntent,summary:E.interpretationSummary,columns:E.columnInterpretations?.map(ge=>({columnName:ge.columnName,mappedField:ge.mappedField,usagePolicy:ge.usagePolicy,confidenceBand:ge.confidenceBand,domainSignals:ge.domainSignals}))||[]}),o?.()}else{const Me=(E.files||[]).flatMap(I=>I.warnings||[]).slice(0,3).join(" ")||je||"Import completed but no usable student rows were detected. Check required columns and retry.";f(Me),ce.error(Me)}}catch(E){let W=E instanceof Error?E.message:"Upload failed";const je=W.toLowerCase();E instanceof Os&&je.includes("missing required educational columns after mapping")&&je.includes("assignmentcompletion")&&(W="Your file matches the minimal import schema, but the connected backend is running an older validator that still requires assignmentCompletion. Update/redeploy the backend or point VITE_API_URL to this updated backend."),ce.error(W),f(W),$(null)}finally{h(!1)}},G=async O=>{k(!0),f(""),Ce(null);try{const q=await Ve.uploadTeacherMaterial(O,{gradeLevel:b||void 0,subject:v||void 0,strandOrTrack:B||void 0,quarter:R||void 0,classId:s});q.success?(ce.success(q.message||"Teacher module created and available to students."),q.moduleId?Ce({title:q.title||"Untitled Module",moduleId:q.moduleId}):f(q.message||"Course material uploaded successfully."),o?.()):(ce.error(q.error||q.message||"Course material upload failed"),f(q.message||"Course material upload failed."))}catch(q){ce.error(q instanceof Error?q.message:"Course material upload failed"),f("Course material upload failed. Please check the file format and try again.")}finally{k(!1)}},X=O=>{O.preventDefault(),d(!1);const q=O.dataTransfer.files[0];q&&M(q)},le=O=>{const q=O.target.files?.[0];q&&M(q)},ie=O=>{O.preventDefault(),N(!1);const q=O.dataTransfer.files[0];q&&G(q)},V=O=>{const q=O.target.files?.[0];q&&G(q)},we=async()=>{te(!0);try{const O=await Ve.downloadClassRecordTemplate({quarter:R||void 0,subject:v||void 0,school_year:r?.schoolYear||void 0}),q=window.URL.createObjectURL(O),E=document.createElement("a");E.href=q,E.download=`class-record-template-${a||"default"}.xlsx`,document.body.appendChild(E),E.click(),document.body.removeChild(E),window.URL.revokeObjectURL(q),ce.success("Template downloaded")}catch(O){ce.error(O instanceof Error?O.message:"Failed to download template")}finally{te(!1)}},Pe=async O=>{ne(!0),ee(null);try{const q=await Ve.uploadClassRecordTemplate(O,{subject:v||void 0,quarter:R||void 0,gradeLevel:b||void 0});ee(q),q.success?ce.success(q.message||"Upload complete"):ce.error(q.error||"Upload failed")}catch(q){ce.error(q instanceof Error?q.message:"Upload failed")}finally{ne(!1),J.current&&(J.current.value="")}},ke=O=>{const q=O.target.files?.[0];q&&Pe(q)};return e.jsx(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-foreground",children:"Import Data"}),e.jsx("p",{className:"text-muted-foreground",children:"Class records drive analytics and at-risk signals. Course materials provide topic grounding for AI lesson plans."}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 items-center text-xs text-muted-foreground",children:[e.jsxs("span",{className:"px-2 py-1 rounded-md bg-muted border border-border",children:["Class scope: ",a||s||"All classes"]}),[r?.gradeLevel,r?.classification,r?.strand].filter(Boolean).map(O=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#9956DE]/12 border border-[#9956DE]/30 text-[#9956DE] font-medium",children:O},`import-meta-${O}`))]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[e.jsxs("div",{className:`bg-card border-4 border-dashed rounded-3xl p-6 transition-all ${c?"border-[#9956DE] bg-[#9956DE]/12":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-border",onClick:O=>O.stopPropagation(),children:[e.jsxs("button",{onClick:we,disabled:D,className:"flex items-center gap-2 text-sm font-medium text-[#9956DE] hover:text-[#7A44B3] transition-colors disabled:opacity-50",children:[e.jsx(gr,{size:16}),D?"Downloading...":"Download Template"]}),e.jsxs("div",{children:[e.jsx("input",{ref:J,type:"file",accept:".csv,.xlsx",onChange:ke,className:"hidden"}),e.jsx($e,{onClick:()=>J.current?.click(),disabled:re,size:"sm",className:"bg-[#9956DE] hover:bg-[#7A44B3] text-white font-semibold rounded-xl",children:re?"Uploading...":"Upload Filled Template"})]})]}),e.jsxs("div",{onDragOver:O=>{O.preventDefault(),d(!0)},onDragLeave:()=>d(!1),onDrop:X,onClick:()=>Z.current?.click(),className:"rounded-2xl border-2 border-dashed border-border p-8 text-center transition-all cursor-pointer hover:border-[#9956DE]/60 hover:bg-[#9956DE]/8",children:[e.jsx("input",{ref:Z,type:"file",accept:".csv,.xlsx,.pdf",onChange:le,className:"hidden"}),e.jsx("div",{className:"w-20 h-20 bg-[#9956DE]/20 rounded-2xl flex items-center justify-center mx-auto mb-6",children:m?e.jsx(he,{className:"h-10 w-10 rounded-2xl bg-[#9956DE]/32"}):e.jsx(ac,{size:40,className:"text-[#9956DE]"})}),e.jsx("h3",{className:"text-xl font-display font-bold text-foreground mb-2",children:"Class Records"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:m?e.jsxs("span",{className:"inline-flex flex-col items-center gap-2",children:[e.jsx(he,{className:"h-4 w-44 bg-[#9956DE]/32"}),e.jsx(he,{className:"h-4 w-36 bg-[#9956DE]/20"})]}):"Upload student grades, attendance, and quiz scores"}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4 flex items-center justify-center gap-2",children:[e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".csv"}),e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".xlsx"}),e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".xls"}),e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".pdf"})]}),e.jsx($e,{className:"bg-card border-2 border-border text-muted-foreground hover:border-[#9956DE] hover:text-[#9956DE] font-bold px-6 py-3 rounded-xl w-full transition-colors",children:"Click or drag & drop"})]}),H&&e.jsxs("div",{className:"mt-6 space-y-4",onClick:O=>O.stopPropagation(),children:[H.summary&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-muted rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-foreground",children:H.summary.totalStudents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Students"})]}),e.jsxs("div",{className:"bg-red-50 dark:bg-red-950/30 rounded-xl p-3 text-center border border-red-200 dark:border-red-800",children:[e.jsx("p",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:H.summary.atRiskCount}),e.jsx("p",{className:"text-xs text-red-500",children:"At Risk"})]}),e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 rounded-xl p-3 text-center border border-amber-200 dark:border-amber-800",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:H.summary.mediumRiskCount}),e.jsx("p",{className:"text-xs text-amber-500",children:"Medium Risk"})]}),e.jsxs("div",{className:"bg-emerald-50 dark:bg-emerald-950/30 rounded-xl p-3 text-center border border-emerald-200 dark:border-emerald-800",children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:H.summary.lowRiskCount}),e.jsx("p",{className:"text-xs text-emerald-500",children:"Low Risk"})]})]}),H.students&&H.students.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground mb-2",children:"At-Risk Students"}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:H.students.filter(O=>O.riskLevel==="high").slice(0,20).map((O,q)=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-950/20 rounded-lg px-3 py-2 border border-red-100 dark:border-red-900",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:O.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-red-500 font-semibold",children:[O.riskScore.toFixed(1),"%"]}),O.topFactors.length>0&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[120px]",children:O.topFactors.slice(0,2).join(", ")})]})]},q))})]}),H.metadata&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground border-t border-border pt-3",children:[H.metadata.className&&e.jsxs("span",{className:"bg-muted px-2 py-1 rounded",children:["Class: ",H.metadata.className]}),H.metadata.subject&&e.jsxs("span",{className:"bg-muted px-2 py-1 rounded",children:["Subject: ",H.metadata.subject]}),H.metadata.quarter&&e.jsxs("span",{className:"bg-muted px-2 py-1 rounded",children:["Quarter: ",H.metadata.quarter]}),H.metadata.schoolYear&&e.jsxs("span",{className:"bg-muted px-2 py-1 rounded",children:["SY: ",H.metadata.schoolYear]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 p-4 bg-muted/30 rounded-2xl border border-border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground",children:"Subject"}),e.jsxs("select",{value:v,onChange:O=>S(O.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-[#F08386]",children:[e.jsx("option",{value:"",children:"Select subject"}),e.jsx("option",{value:"Mathematics",children:"Mathematics"}),e.jsx("option",{value:"English",children:"English"}),e.jsx("option",{value:"Science",children:"Science"}),e.jsx("option",{value:"Filipino",children:"Filipino"}),e.jsx("option",{value:"Aralin Panlipunan",children:"Aralin Panlipunan"}),e.jsx("option",{value:"ESP",children:"ESP"}),e.jsx("option",{value:"TLE",children:"TLE"}),e.jsx("option",{value:"Music",children:"Music"}),e.jsx("option",{value:"Arts",children:"Arts"}),e.jsx("option",{value:"Physical Education",children:"Physical Education"}),e.jsx("option",{value:"Health",children:"Health"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground",children:"Quarter"}),e.jsxs("select",{value:R,onChange:O=>j(O.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-[#F08386]",children:[e.jsx("option",{value:"",children:"Select quarter"}),e.jsx("option",{value:"Quarter 1",children:"Quarter 1"}),e.jsx("option",{value:"Quarter 2",children:"Quarter 2"}),e.jsx("option",{value:"Quarter 3",children:"Quarter 3"}),e.jsx("option",{value:"Quarter 4",children:"Quarter 4"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground",children:"Grade Level"}),e.jsxs("select",{value:b,onChange:O=>T(O.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-[#F08386]",children:[e.jsx("option",{value:"",children:"Select grade"}),e.jsx("option",{value:"Grade 11",children:"Grade 11"}),e.jsx("option",{value:"Grade 12",children:"Grade 12"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground",children:"Strand/Track"}),e.jsx("input",{type:"text",value:B,onChange:O=>g(O.target.value),placeholder:"e.g. STEM",className:"w-full bg-background border border-border rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-[#F08386]"})]})]}),e.jsxs("div",{onDragOver:O=>{O.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:ie,onClick:()=>ae.current?.click(),className:`bg-card border-4 border-dashed rounded-3xl p-12 text-center transition-all cursor-pointer hover:border-[#F08386]/60 hover:bg-[#F08386]/12 flex-1 ${u?"border-[#F08386] bg-[#F08386]/12 scale-105":"border-border"}`,children:[e.jsx("input",{ref:ae,type:"file",accept:".pdf,.docx,.txt",onChange:V,className:"hidden"}),e.jsx("div",{className:"w-20 h-20 bg-[#F08386]/20 rounded-2xl flex items-center justify-center mx-auto mb-6",children:w?e.jsx(he,{className:"h-10 w-10 rounded-2xl bg-rose-200"}):e.jsx(fr,{size:40,className:"text-[#F08386]"})}),e.jsx("h3",{className:"text-xl font-display font-bold text-foreground mb-2",children:"Course Materials"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:w?e.jsxs("span",{className:"inline-flex flex-col items-center gap-2",children:[e.jsx(he,{className:"h-4 w-48 bg-rose-200"}),e.jsx(he,{className:"h-4 w-40 bg-[#F08386]/20"})]}):"Upload syllabus, lesson plans, and curriculum documents"}),e.jsxs("p",{className:"text-xs text-slate-500 mb-4 flex items-center justify-center gap-2",children:[e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".pdf"}),e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".docx"}),e.jsx("span",{className:"bg-muted px-2 py-1 rounded text-muted-foreground font-medium",children:".txt"})]}),e.jsx($e,{className:"bg-card border-2 border-border text-muted-foreground hover:border-[#F08386] hover:text-[#F08386] font-bold px-6 py-3 rounded-xl w-full transition-colors",children:"Click or drag & drop"})]})]})]}),l&&e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[e.jsx("h3",{className:"text-base font-display font-bold text-foreground mb-2",children:"Workbook Preview Summary"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"School"}),e.jsx("p",{className:"font-semibold text-foreground",children:l.imported.schoolContext.schoolName||"N/A"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Subject"}),e.jsx("p",{className:"font-semibold text-foreground",children:l.imported.schoolContext.subjectName||"N/A"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Learners"}),e.jsx("p",{className:"font-semibold text-foreground",children:l.imported.learners.length})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Confidence"}),e.jsx("p",{className:"font-semibold text-foreground",children:l.imported.validation.confidence.toFixed(2)})]})]})]}),e.jsxs("div",{className:"bg-[#9956DE]/12 border border-[#9956DE]/30 rounded-2xl p-6",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#7A44B3] mb-3",children:"How AI Uses Your Data"}),e.jsxs("div",{className:"space-y-2 text-[#5E3388]/80 text-sm",children:[e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#9956DE] font-bold",children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-[#7A44B3]",children:"Smart Format Detection:"})," AI understands various spreadsheet formats and column names"]})]}),e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#9956DE] font-bold",children:"•"}),e.jsx("span",{children:"Analyzes historical performance patterns to predict at-risk students"})]}),e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#9956DE] font-bold",children:"•"}),e.jsx("span",{children:"Maps curriculum topics to student knowledge gaps"})]}),e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#9956DE] font-bold",children:"•"}),e.jsx("span",{children:"Generates personalized remedial learning paths"})]}),e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#9956DE] font-bold",children:"•"}),e.jsx("span",{children:"All data is processed securely and never shared"})]})]})]}),y&&e.jsx("div",{className:"bg-[#75D06A]/14 border border-[#75D06A]/35 rounded-2xl p-4 text-sm text-[#3E8538]",children:y}),me&&e.jsxs("div",{className:"rounded-2xl border border-emerald-200 dark:border-emerald-800 bg-emerald-50 dark:bg-emerald-950/30 p-5 space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"px-2 py-1 rounded-md bg-emerald-100 text-emerald-700 text-xs font-bold",children:"Module Generated ✓"})}),e.jsx("h4",{className:"text-lg font-bold text-foreground",children:me.title}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full bg-emerald-100 text-emerald-700 text-xs font-medium",children:"Available to students now"}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["ID: ",me.moduleId]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx($e,{size:"sm",onClick:()=>Ce(null),children:"View in Modules tab"}),e.jsx($e,{size:"sm",variant:"outline",onClick:()=>Ce(null),children:"Dismiss"})]})]}),z&&e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-foreground",children:"Import Interpretation"}),e.jsxs("span",{className:"text-xs px-2 py-1 rounded bg-muted text-[#334155]",children:["Intent: ",z.datasetIntent||"synthetic_student_records"]})]}),z.summary&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-3 mb-4",children:[e.jsxs("div",{className:"bg-[#f8fbff] border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Scoring"}),e.jsx("p",{className:"text-lg font-bold text-foreground",children:z.summary.scoringColumns})]}),e.jsxs("div",{className:"bg-[#f8fbff] border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display"}),e.jsx("p",{className:"text-lg font-bold text-foreground",children:z.summary.displayColumns})]}),e.jsxs("div",{className:"bg-[#FFB356]/16 border border-[#FFB356]/38 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-[#CC8A37]",children:"Storage-only"}),e.jsx("p",{className:"text-lg font-bold text-[#A56D29]",children:z.summary.storageOnlyColumns})]}),e.jsxs("div",{className:"bg-[#F08386]/12 border border-[#F08386]/30 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-[#C65E63]",children:"Low confidence"}),e.jsx("p",{className:"text-lg font-bold text-[#A74B50]",children:z.summary.lowConfidenceColumns})]}),e.jsxs("div",{className:"bg-[#f8fbff] border border-border rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Domain warnings"}),e.jsx("p",{className:"text-lg font-bold text-foreground",children:z.summary.domainMismatchWarnings})]})]}),z.columns.length>0?e.jsx("div",{className:"space-y-2 max-h-64 overflow-auto pr-1",children:z.columns.slice(0,40).map(O=>e.jsxs("div",{className:"bg-[#f8fafc] border border-border rounded-lg px-3 py-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:O.columnName}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["mapped: ",O.mappedField||"none"," • ","usage: ",O.usagePolicy," • ","confidence: ",O.confidenceBand]}),O.domainSignals&&O.domainSignals.length>0&&e.jsxs("p",{className:"text-xs text-[#CC8A37] mt-1",children:["domain signals: ",O.domainSignals.join(", ")]})]},O.columnName))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No per-column interpretation data was returned for this upload."})]}),e.jsxs("div",{className:"bg-card rounded-2xl p-6 shadow-sm border border-border",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-foreground mb-4",children:"Manage Imported Data"}),e.jsxs("button",{onClick:t,className:"w-full bg-[#00a86b] hover:bg-[#008f5d] text-white rounded-xl p-5 flex items-center justify-between transition-all shadow-sm hover:shadow-md group",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-card/20 rounded-xl flex items-center justify-center backdrop-blur-sm",children:e.jsx(Io,{size:24,className:"text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h4",{className:"font-bold text-lg",children:"Edit Class Records"}),e.jsx("p",{className:"text-white/90 text-sm",children:"Review and correct AI-analyzed student data"})]})]}),e.jsx(Wt,{size:24,className:"text-white/80 group-hover:text-[#9956DE] group-hover:translate-x-1 transition-all"})]})]})]})})},Ju=({students:t,teacherId:s,teacherName:a,onBack:r})=>{const[n,o]=p.useState(t),[l,i]=p.useState(!1),c=p.useCallback(m=>Ns(m),[]),[d,u]=p.useState(()=>Object.fromEntries(t.map(m=>[c(m),{grade:m.grade||"Grade 11",section:m.section||"Section A"}])));p.useEffect(()=>{o(t),u(Object.fromEntries(t.map(m=>[c(m),{grade:m.grade||"Grade 11",section:m.section||"Section A"}])))},[c,t]);const N=async()=>{i(!0);try{for(const m of n){const h=d[c(m)],w=h?.grade||m.grade,k=h?.section||m.section;s&&(w!==m.grade||k!==m.section)&&(await xl(m.id,w,k,s,new Date().getFullYear().toString(),a),await dl(m.id,w,k));try{const y=await Ve.predictRisk({engagementScore:m.engagementScore,avgQuizScore:m.avgScore,attendance:m.attendance,assignmentCompletion:m.assignmentCompletion});await Vd(m.id,y.riskLevel,y.confidence)}catch{}}o(m=>m.map(h=>{const w=d[c(h)];if(!w)return h;const k=lt({metadata:h.classMetadata,classSectionId:h.classSectionId,className:[w.grade,w.section].filter(Boolean).join(" - "),grade:w.grade,section:w.section});return{...h,grade:w.grade,section:w.section,className:k.className||[w.grade,w.section].filter(Boolean).join(" - "),classSectionId:k.classSectionId||h.classSectionId,classMetadata:k}})),ce.success("Records saved and risk levels updated"),r()}catch{ce.error("Failed to save changes")}finally{i(!1)}};return e.jsxs(Re.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"p-6 h-full flex flex-col",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:r,className:"p-2 hover:bg-muted rounded-lg transition-colors text-muted-foreground",children:e.jsx(Pt,{size:24})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-display font-bold text-foreground",children:"Edit Class Records"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and modify student data manually"})]})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx($e,{variant:"outline",onClick:r,className:"border-border",children:"Cancel"}),e.jsxs($e,{onClick:N,disabled:l,className:"bg-[#75D06A] hover:bg-[#5AB84E] text-white gap-2",children:[l?e.jsx(he,{className:"h-5 w-5 rounded-full bg-white/35"}):e.jsx(yo,{size:18}),l?"Saving...":"Save Changes"]})]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-2xl shadow-sm flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-background flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(tr,{size:18}),e.jsx("span",{className:"text-sm",children:"Click on any field to edit"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",n.length," records"]})]}),e.jsx("div",{className:"overflow-auto flex-1",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-background sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Student Name"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"LRN"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Grade"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Section"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Avg Score"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Risk Level"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Weakest Topic"}),e.jsx("th",{className:"p-4 font-bold text-muted-foreground border-b border-border bg-background",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(m=>{const h=c(m);return e.jsxs("tr",{className:"border-b border-border hover:bg-[#9956DE]/12 group transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:m.avatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}),e.jsx("span",{className:"font-medium text-foreground",children:m.name})]})}),e.jsx("td",{className:"p-4 text-muted-foreground font-mono text-sm",children:m.lrn||"Not set"}),e.jsx("td",{className:"p-4 min-w-[140px]",children:e.jsx(vt,{id:`edit-record-grade-${h}`,name:`edit-record-grade-${h}`,"aria-label":`Edit grade for ${m.name}`,value:d[h]?.grade||m.grade,onChange:w=>u(k=>({...k,[h]:{...k[h],grade:w.target.value}})),className:"h-9 text-sm"})}),e.jsx("td",{className:"p-4 min-w-[140px]",children:e.jsx(vt,{id:`edit-record-section-${h}`,name:`edit-record-section-${h}`,"aria-label":`Edit section for ${m.name}`,value:d[h]?.section||m.section,onChange:w=>u(k=>({...k,[h]:{...k[h],section:w.target.value}})),className:"h-9 text-sm"})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:`font-bold ${m.avgScore<60?"text-[#FF8B8B]":m.avgScore<80?"text-[#F08386]":"text-green-600"}`,children:[m.avgScore,"%"]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:`px-2 py-1 rounded text-xs font-bold ${Ra(m.riskLevel)}`,children:m.riskLevel.toUpperCase()})}),e.jsx("td",{className:"p-4 text-muted-foreground",children:m.weakestTopic}),e.jsx("td",{className:"p-4",children:e.jsx("button",{className:"p-2 hover:bg-muted rounded-lg text-slate-500 hover:text-[#9956DE] transition-colors",children:e.jsx(Io,{size:16})})})]},h)})})]})})]})]})};function Ra(t){switch(t){case"high":return"bg-[#FF8B8B]/22 text-[#D66A6A] border-[#FF8B8B]/35";case"medium":return"bg-[#F08386]/20 text-[#C65E63] border-[#F08386]/30";case"low":return"bg-[#75D06A]/22 text-[#4D9F46] border-[#75D06A]/35"}}function Zu(t){switch(t){case"high":return"border-red-500 bg-[#FF8B8B]/14";case"medium":return"border-[#F08386] bg-[#F08386]/12";case"low":return"border-[#75D06A] bg-[#75D06A]/14"}}export{Kx as default}; diff --git a/assets/XPNotification-DZv3ypM9.js b/assets/XPNotification-DRsFdUWw.js similarity index 92% rename from assets/XPNotification-DZv3ypM9.js rename to assets/XPNotification-DRsFdUWw.js index 3a3394e4a0f9308b29179e632a8f4b7adff0a5cb..25e33a469ce081f79a3576655cb9367475fa14b0 100644 --- a/assets/XPNotification-DZv3ypM9.js +++ b/assets/XPNotification-DRsFdUWw.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{j as n,m as i,X as m}from"./index-Cb8VeSuW.js";import{S as c}from"./sparkles-v8V3LFaV.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const b=({xp:r,message:a,show:t,onComplete:s})=>(l.useEffect(()=>{if(t){const o=setTimeout(()=>{s()},3e3);return()=>clearTimeout(o)}},[t,s]),e.jsx(n,{children:t&&e.jsx(i.div,{initial:{opacity:0,y:-50,scale:.8},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"fixed top-8 left-1/2 -translate-x-1/2 z-50",style:{willChange:"transform, opacity"},children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-400 via-orange-500 to-rose-500 text-white px-6 py-4 rounded-2xl shadow-2xl border-2 border-rose-300 flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(m,{size:20,className:"text-white",fill:"currentColor"})}),e.jsx(i.div,{className:"absolute -top-1 -right-1",animate:{rotate:[0,360]},transition:{duration:2,repeat:1/0,ease:"linear"},style:{willChange:"transform"},children:e.jsx(c,{size:16,className:"text-rose-200"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",children:a}),e.jsxs("p",{className:"text-2xl font-black",children:["+",r," XP"]})]})]})})}));export{b as default}; +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{j as n,m as i,X as m}from"./index-BaOs5Ayg.js";import{S as c}from"./sparkles-By-vFjpv.js";import"./vendor-firebase-firestore-CH1lNiRF.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const b=({xp:r,message:a,show:t,onComplete:s})=>(l.useEffect(()=>{if(t){const o=setTimeout(()=>{s()},3e3);return()=>clearTimeout(o)}},[t,s]),e.jsx(n,{children:t&&e.jsx(i.div,{initial:{opacity:0,y:-50,scale:.8},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"fixed top-8 left-1/2 -translate-x-1/2 z-50",style:{willChange:"transform, opacity"},children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-400 via-orange-500 to-rose-500 text-white px-6 py-4 rounded-2xl shadow-2xl border-2 border-rose-300 flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(m,{size:20,className:"text-white",fill:"currentColor"})}),e.jsx(i.div,{className:"absolute -top-1 -right-1",animate:{rotate:[0,360]},transition:{duration:2,repeat:1/0,ease:"linear"},style:{willChange:"transform"},children:e.jsx(c,{size:16,className:"text-rose-200"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",children:a}),e.jsxs("p",{className:"text-2xl font-black",children:["+",r," XP"]})]})]})})}));export{b as default}; diff --git a/assets/automationService-BxQhaGqB.js b/assets/automationService-7m3RFJA3.js similarity index 98% rename from assets/automationService-BxQhaGqB.js rename to assets/automationService-7m3RFJA3.js index 0746c1d4a833a8c3f86eb56dc2d67e5da920bcdd..adbc5d2e91e0396513a0efb7bc27459e66fc00d7 100644 --- a/assets/automationService-BxQhaGqB.js +++ b/assets/automationService-7m3RFJA3.js @@ -1 +1 @@ -import{doc as g,collection as a,serverTimestamp as c,setDoc as l,addDoc as D,query as z,where as b,getDocs as A,updateDoc as C,writeBatch as Q}from"./vendor-firebase-firestore-CH1lNiRF.js";import{f as r,aS as $}from"./index-Cb8VeSuW.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const m=async(e,n,o,u,i)=>{try{const t=g(a(r,"notifications")),s={id:t.id,userId:e,type:n,title:o,message:u,read:!1,...i?{actionUrl:i}:{},createdAt:new Date},d={id:s.id,userId:s.userId,type:s.type,title:s.title,message:s.message,read:s.read,createdAt:c(),link:i||null};return await l(t,{...d}),s}catch(t){throw console.error("Error creating notification:",t),t}};async function E(e){if(!e)return 0;const n=a(r,"deepDiagnosticAssignments"),o=z(n,b("lrn","==",e));return(await A(o)).docs.filter(i=>{const t=i.data().status;return t==="pending"||t==="queued"||t==="in_progress"||t==="expired"}).length}async function M(e,n,o="Grade 11",u,i="iar_only",t="initial_assessment"){if(t==="followup_diagnostic"){const s=a(r,"deepDiagnosticAssignments"),d=z(s,b("lrn","==",e)),f=await A(d);if(!f.empty){const p=Q(r);let w=!1;for(const h of f.docs){const I=h.data().status;(I==="pending"||I==="queued")&&(p.update(h.ref,{status:"in_progress",startedAt:c()}),w=!0)}w&&await p.commit()}}return await l(g(r,"diagnosticResults",e),{lrn:e,results:n,gradeLevel:o,workflowMode:i,assessmentType:t,questionBreakdown:u||null,completedAt:c(),processed:!1,processing:!1}),{success:!0,event:"diagnostic_completed",lrn:e,message:`Diagnostic submitted for ${e}. Processing will begin automatically.`,remedialQuizzesCreated:0,notifications:["Your diagnostic results are being processed. Check back shortly!"]}}async function x(e){return await D(a(r,"quizResults"),{lrn:e.lrn,studentId:e.lrn,quizId:e.quizId,subject:e.subject,score:e.score,totalQuestions:e.totalQuestions,correctAnswers:e.correctAnswers,timeSpentSeconds:e.timeSpentSeconds,answers:e.answers||null,submittedAt:c()}),{success:!0,event:"quiz_submitted",lrn:e.lrn,message:`Quiz submitted for ${e.lrn}. Risk recalculation will run automatically.`,remedialQuizzesCreated:0,notifications:[`Quiz result recorded for ${e.subject}.`]}}async function N(e){return await $(e.lrn),await m(e.lrn,"reminder","Welcome to MathPulse AI!","Complete your diagnostic assessment to get started with personalised learning."),e.teacherId&&await m(e.teacherId,"message","New Student Enrolled",`${e.name} has joined. Diagnostic assessment is pending.`),{success:!0,event:"student_enrolled",lrn:e.lrn,message:`Student ${e.name} enrolled and initialised`,remedialQuizzesCreated:0,notifications:[`Welcome ${e.name}! Please complete the diagnostic assessment.`]}}async function W(e){return await D(a(r,"dataImports"),{teacherId:e.teacherId,studentCount:e.students.length,columnMapping:e.columnMapping,importedAt:c(),processed:!1}),await m(e.teacherId,"message","Data Import Processed",`Data import complete — ${e.students.length} student records processed.`),{success:!0,event:"data_imported",message:`Data import processed for ${e.students.length} students`,remedialQuizzesCreated:0,notifications:[`Data import complete — ${e.students.length} student records processed.`]}}async function G(e){const n=g(r,"curriculumContent",e.contentId);return e.action==="delete"?await C(n,{deleted:!0,deletedBy:e.adminId,deletedAt:c(),contentType:e.contentType,subjectId:e.subjectId||null}):await l(n,{contentType:e.contentType,subjectId:e.subjectId||null,details:e.details||null,updatedBy:e.adminId,action:e.action,updatedAt:c()},{merge:!0}),{success:!0,event:"content_updated",message:`Content ${e.action} processed for ${e.contentType}`,remedialQuizzesCreated:0,notifications:[]}}export{E as getPendingDeepDiagnosticCount,G as triggerContentUpdated,W as triggerDataImported,M as triggerDiagnosticCompleted,x as triggerQuizSubmitted,N as triggerStudentEnrolled}; +import{doc as g,collection as a,serverTimestamp as c,setDoc as l,addDoc as D,query as z,where as b,getDocs as A,updateDoc as C,writeBatch as Q}from"./vendor-firebase-firestore-CH1lNiRF.js";import{f as r,a$ as $}from"./index-BaOs5Ayg.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const m=async(e,n,o,u,i)=>{try{const t=g(a(r,"notifications")),s={id:t.id,userId:e,type:n,title:o,message:u,read:!1,...i?{actionUrl:i}:{},createdAt:new Date},d={id:s.id,userId:s.userId,type:s.type,title:s.title,message:s.message,read:s.read,createdAt:c(),link:i||null};return await l(t,{...d}),s}catch(t){throw console.error("Error creating notification:",t),t}};async function E(e){if(!e)return 0;const n=a(r,"deepDiagnosticAssignments"),o=z(n,b("lrn","==",e));return(await A(o)).docs.filter(i=>{const t=i.data().status;return t==="pending"||t==="queued"||t==="in_progress"||t==="expired"}).length}async function M(e,n,o="Grade 11",u,i="iar_only",t="initial_assessment"){if(t==="followup_diagnostic"){const s=a(r,"deepDiagnosticAssignments"),d=z(s,b("lrn","==",e)),f=await A(d);if(!f.empty){const p=Q(r);let w=!1;for(const h of f.docs){const I=h.data().status;(I==="pending"||I==="queued")&&(p.update(h.ref,{status:"in_progress",startedAt:c()}),w=!0)}w&&await p.commit()}}return await l(g(r,"diagnosticResults",e),{lrn:e,results:n,gradeLevel:o,workflowMode:i,assessmentType:t,questionBreakdown:u||null,completedAt:c(),processed:!1,processing:!1}),{success:!0,event:"diagnostic_completed",lrn:e,message:`Diagnostic submitted for ${e}. Processing will begin automatically.`,remedialQuizzesCreated:0,notifications:["Your diagnostic results are being processed. Check back shortly!"]}}async function x(e){return await D(a(r,"quizResults"),{lrn:e.lrn,studentId:e.lrn,quizId:e.quizId,subject:e.subject,score:e.score,totalQuestions:e.totalQuestions,correctAnswers:e.correctAnswers,timeSpentSeconds:e.timeSpentSeconds,answers:e.answers||null,submittedAt:c()}),{success:!0,event:"quiz_submitted",lrn:e.lrn,message:`Quiz submitted for ${e.lrn}. Risk recalculation will run automatically.`,remedialQuizzesCreated:0,notifications:[`Quiz result recorded for ${e.subject}.`]}}async function N(e){return await $(e.lrn),await m(e.lrn,"reminder","Welcome to MathPulse AI!","Complete your diagnostic assessment to get started with personalised learning."),e.teacherId&&await m(e.teacherId,"message","New Student Enrolled",`${e.name} has joined. Diagnostic assessment is pending.`),{success:!0,event:"student_enrolled",lrn:e.lrn,message:`Student ${e.name} enrolled and initialised`,remedialQuizzesCreated:0,notifications:[`Welcome ${e.name}! Please complete the diagnostic assessment.`]}}async function W(e){return await D(a(r,"dataImports"),{teacherId:e.teacherId,studentCount:e.students.length,columnMapping:e.columnMapping,importedAt:c(),processed:!1}),await m(e.teacherId,"message","Data Import Processed",`Data import complete — ${e.students.length} student records processed.`),{success:!0,event:"data_imported",message:`Data import processed for ${e.students.length} students`,remedialQuizzesCreated:0,notifications:[`Data import complete — ${e.students.length} student records processed.`]}}async function G(e){const n=g(r,"curriculumContent",e.contentId);return e.action==="delete"?await C(n,{deleted:!0,deletedBy:e.adminId,deletedAt:c(),contentType:e.contentType,subjectId:e.subjectId||null}):await l(n,{contentType:e.contentType,subjectId:e.subjectId||null,details:e.details||null,updatedBy:e.adminId,action:e.action,updatedAt:c()},{merge:!0}),{success:!0,event:"content_updated",message:`Content ${e.action} processed for ${e.contentType}`,remedialQuizzesCreated:0,notifications:[]}}export{E as getPendingDeepDiagnosticCount,G as triggerContentUpdated,W as triggerDataImported,M as triggerDiagnosticCompleted,x as triggerQuizSubmitted,N as triggerStudentEnrolled}; diff --git a/assets/bell-DsHB20Hc.js b/assets/bell-clcSMJn6.js similarity index 91% rename from assets/bell-DsHB20Hc.js rename to assets/bell-clcSMJn6.js index 1c4da5f73da13e00d3ac025555b6c23c345aba43..aa16175805f0fd1aeffb99f89877aa8d65959fe4 100644 --- a/assets/bell-DsHB20Hc.js +++ b/assets/bell-clcSMJn6.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/button-De2q2xHf.js b/assets/button-DCfeFHoH.js similarity index 97% rename from assets/button-De2q2xHf.js rename to assets/button-DCfeFHoH.js index a2d396b9954217a7cce77233615c5938febe2261..a0f6d7cb97c1bb4a47aee15b626b407860dacbff 100644 --- a/assets/button-De2q2xHf.js +++ b/assets/button-DCfeFHoH.js @@ -1 +1 @@ -import{j as y}from"./vendor-react-B4AQeu28.js";import{S as k}from"./vendor-radix-BorKzPz9.js";import{c as V}from"./vendor-charts-D8hf8tI0.js";import{i as p}from"./index-Cb8VeSuW.js";const g=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,m=V,j=(n,r)=>e=>{var o;if(r?.variants==null)return m(n,e?.class,e?.className);const{variants:u,defaultVariants:i}=r,b=Object.keys(u).map(t=>{const a=e?.[t],d=i?.[t];if(a===null)return null;const s=g(a)||g(d);return u[t][s]}),v=e&&Object.entries(e).reduce((t,a)=>{let[d,s]=a;return s===void 0||(t[d]=s),t},{}),f=r==null||(o=r.compoundVariants)===null||o===void 0?void 0:o.reduce((t,a)=>{let{class:d,className:s,...h}=a;return Object.entries(h).every(x=>{let[c,l]=x;return Array.isArray(l)?l.includes({...i,...v}[c]):{...i,...v}[c]===l})?[...t,d,s]:t},[]);return m(n,b,f,e?.class,e?.className)},N=j("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});function w({className:n,variant:r,size:e,asChild:o=!1,...u}){const i=o?k:"button";return y.jsx(i,{"data-slot":"button",className:p(N({variant:r,size:e,className:n})),...u})}export{w as B,j as c}; +import{j as y}from"./vendor-react-B4AQeu28.js";import{S as k}from"./vendor-radix-BorKzPz9.js";import{c as V}from"./vendor-charts-D8hf8tI0.js";import{i as p}from"./index-BaOs5Ayg.js";const g=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,m=V,j=(n,r)=>e=>{var o;if(r?.variants==null)return m(n,e?.class,e?.className);const{variants:u,defaultVariants:i}=r,b=Object.keys(u).map(t=>{const a=e?.[t],d=i?.[t];if(a===null)return null;const s=g(a)||g(d);return u[t][s]}),v=e&&Object.entries(e).reduce((t,a)=>{let[d,s]=a;return s===void 0||(t[d]=s),t},{}),f=r==null||(o=r.compoundVariants)===null||o===void 0?void 0:o.reduce((t,a)=>{let{class:d,className:s,...h}=a;return Object.entries(h).every(x=>{let[c,l]=x;return Array.isArray(l)?l.includes({...i,...v}[c]):{...i,...v}[c]===l})?[...t,d,s]:t},[]);return m(n,b,f,e?.class,e?.className)},N=j("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});function w({className:n,variant:r,size:e,asChild:o=!1,...u}){const i=o?k:"button";return y.jsx(i,{"data-slot":"button",className:p(N({variant:r,size:e,className:n})),...u})}export{w as B,j as c}; diff --git a/assets/card-DXoGKpl1.js b/assets/card-D4dmQVNb.js similarity index 95% rename from assets/card-DXoGKpl1.js rename to assets/card-D4dmQVNb.js index 2f8eccae220c79c93bff9e547e6fd658a18e47f2..ccf7888cc17b865038f5afb7296566ce2dae3f7f 100644 --- a/assets/card-DXoGKpl1.js +++ b/assets/card-D4dmQVNb.js @@ -1,4 +1,4 @@ -import{e as o,i as r}from"./index-Cb8VeSuW.js";import{j as e}from"./vendor-react-B4AQeu28.js";/** +import{e as o,i as r}from"./index-BaOs5Ayg.js";import{j as e}from"./vendor-react-B4AQeu28.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chart-column-CmH46HAG.js b/assets/chart-column-B3jJOD5i.js similarity index 89% rename from assets/chart-column-CmH46HAG.js rename to assets/chart-column-B3jJOD5i.js index 2d3919296749f70034b00cb2e88759986dea888d..60580c49ed97b3d5d8f5f0b6d220c65cf7755ed4 100644 --- a/assets/chart-column-CmH46HAG.js +++ b/assets/chart-column-B3jJOD5i.js @@ -1,4 +1,4 @@ -import{e as t}from"./index-Cb8VeSuW.js";/** +import{e as t}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chatService-D-gdHYgQ.js b/assets/chatService-DwVkLoat.js similarity index 97% rename from assets/chatService-D-gdHYgQ.js rename to assets/chatService-DwVkLoat.js index 47d4798ef9c3aab1f26bc8704a3e691a87886be4..0856b0dc9c16faba69ef6b0933f8c67ed9020d89 100644 --- a/assets/chatService-D-gdHYgQ.js +++ b/assets/chatService-DwVkLoat.js @@ -1 +1 @@ -import{doc as c,collection as u,getDoc as g,serverTimestamp as i,setDoc as w,updateDoc as p,query as l,where as d,orderBy as y,getDocs as A}from"./vendor-firebase-firestore-CH1lNiRF.js";import{f as a}from"./index-Cb8VeSuW.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const Q=async(s,t="New Conversation")=>{try{const e=c(u(a,"chatSessions")),n={id:e.id,userId:s,title:t,messages:[],createdAt:new Date,updatedAt:new Date,isActive:!0};return await w(e,{...n,createdAt:i(),updatedAt:i()}),n}catch(e){throw console.error("Error creating chat session:",e),e}},R=async s=>{try{const t=l(u(a,"chatSessions"),d("userId","==",s),d("isActive","==",!0),y("updatedAt","desc"));return(await A(t)).docs.map(n=>{const r=n.data();return{...r,createdAt:r.createdAt?.toDate()||new Date,updatedAt:r.updatedAt?.toDate()||new Date}})}catch(t){return console.error("Error getting chat sessions:",t),[]}},b=async s=>{try{const t=await g(c(a,"chatSessions",s));if(t.exists()){const e=t.data();return{...e,createdAt:e.createdAt?.toDate()||new Date,updatedAt:e.updatedAt?.toDate()||new Date}}return null}catch(t){return console.error("Error getting chat session:",t),null}},q=async(s,t,e,n)=>{try{const r=c(u(a,"chatMessages")),o={id:r.id,userId:"",role:t,content:e,timestamp:new Date,...n?{context:n}:{}},m=await g(c(a,"chatSessions",s));m.exists()&&(o.userId=m.data().userId);const h={id:o.id,userId:o.userId,role:o.role,content:o.content,sessionId:s,timestamp:i()};return o.context&&(h.context=o.context),await w(r,h),await p(c(a,"chatSessions",s),{updatedAt:i()}),o}catch(r){throw console.error("Error adding message:",r),r}},B=async(s,t)=>{try{const e=l(u(a,"chatMessages"),d("sessionId","==",s),d("userId","==",t),y("timestamp","asc"));return(await A(e)).docs.map(r=>{const o=r.data();return{...o,timestamp:o.timestamp?.toDate()||new Date}})}catch(e){return console.error("Error getting session messages:",e),[]}},N=async(s,t)=>{try{await p(c(a,"chatSessions",s),{title:t,updatedAt:i()})}catch(e){throw console.error("Error updating session title:",e),e}},U=async s=>{try{await p(c(a,"chatSessions",s),{isActive:!1,updatedAt:i()})}catch(t){throw console.error("Error deleting session:",t),t}};export{q as addMessageToSession,Q as createChatSession,U as deleteSession,b as getChatSession,B as getSessionMessages,R as getUserChatSessions,N as updateSessionTitle}; +import{doc as c,collection as u,getDoc as g,serverTimestamp as i,setDoc as w,updateDoc as p,query as l,where as d,orderBy as y,getDocs as A}from"./vendor-firebase-firestore-CH1lNiRF.js";import{f as a}from"./index-BaOs5Ayg.js";import"./vendor-firebase-core-CO26nNq6.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-BLpRW_zO.js";import"./vendor-firebase-storage-B3igpVVS.js";import"./vendor-firebase-analytics-CTiUNb0-.js";import"./vendor-radix-BorKzPz9.js";import"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";const Q=async(s,t="New Conversation")=>{try{const e=c(u(a,"chatSessions")),n={id:e.id,userId:s,title:t,messages:[],createdAt:new Date,updatedAt:new Date,isActive:!0};return await w(e,{...n,createdAt:i(),updatedAt:i()}),n}catch(e){throw console.error("Error creating chat session:",e),e}},R=async s=>{try{const t=l(u(a,"chatSessions"),d("userId","==",s),d("isActive","==",!0),y("updatedAt","desc"));return(await A(t)).docs.map(n=>{const r=n.data();return{...r,createdAt:r.createdAt?.toDate()||new Date,updatedAt:r.updatedAt?.toDate()||new Date}})}catch(t){return console.error("Error getting chat sessions:",t),[]}},b=async s=>{try{const t=await g(c(a,"chatSessions",s));if(t.exists()){const e=t.data();return{...e,createdAt:e.createdAt?.toDate()||new Date,updatedAt:e.updatedAt?.toDate()||new Date}}return null}catch(t){return console.error("Error getting chat session:",t),null}},q=async(s,t,e,n)=>{try{const r=c(u(a,"chatMessages")),o={id:r.id,userId:"",role:t,content:e,timestamp:new Date,...n?{context:n}:{}},m=await g(c(a,"chatSessions",s));m.exists()&&(o.userId=m.data().userId);const h={id:o.id,userId:o.userId,role:o.role,content:o.content,sessionId:s,timestamp:i()};return o.context&&(h.context=o.context),await w(r,h),await p(c(a,"chatSessions",s),{updatedAt:i()}),o}catch(r){throw console.error("Error adding message:",r),r}},B=async(s,t)=>{try{const e=l(u(a,"chatMessages"),d("sessionId","==",s),d("userId","==",t),y("timestamp","asc"));return(await A(e)).docs.map(r=>{const o=r.data();return{...o,timestamp:o.timestamp?.toDate()||new Date}})}catch(e){return console.error("Error getting session messages:",e),[]}},N=async(s,t)=>{try{await p(c(a,"chatSessions",s),{title:t,updatedAt:i()})}catch(e){throw console.error("Error updating session title:",e),e}},U=async s=>{try{await p(c(a,"chatSessions",s),{isActive:!1,updatedAt:i()})}catch(t){throw console.error("Error deleting session:",t),t}};export{q as addMessageToSession,Q as createChatSession,U as deleteSession,b as getChatSession,B as getSessionMessages,R as getUserChatSessions,N as updateSessionTitle}; diff --git a/assets/check-DSwzaW4Y.js b/assets/check-BLSo9L0H.js similarity index 85% rename from assets/check-DSwzaW4Y.js rename to assets/check-BLSo9L0H.js index d03bb6f4d10138503dde88440e82acff0dc22006..5b587772781ec2d95dc51c60fdc334f73387f243 100644 --- a/assets/check-DSwzaW4Y.js +++ b/assets/check-BLSo9L0H.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-Cb8VeSuW.js";/** +import{e as c}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/check-check-CS5aviKH.js b/assets/check-check-B_HghS1Z.js similarity index 88% rename from assets/check-check-CS5aviKH.js rename to assets/check-check-B_HghS1Z.js index 3d44882b4311de619613e6395dbf22f56622b02b..81f69360d3866b67d4b2c75998d4b532079f7354 100644 --- a/assets/check-check-CS5aviKH.js +++ b/assets/check-check-B_HghS1Z.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-left-CZaM7nZW.js b/assets/chevron-left-BWpgclqc.js similarity index 86% rename from assets/chevron-left-CZaM7nZW.js rename to assets/chevron-left-BWpgclqc.js index c8905b55541ea63e1face97c9fc1d1f6342f42cf..2d861468eab389e7a24615541fff540c1332dd91 100644 --- a/assets/chevron-left-CZaM7nZW.js +++ b/assets/chevron-left-BWpgclqc.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-right-CoVWpXdD.js b/assets/chevron-right-COqGruhh.js similarity index 85% rename from assets/chevron-right-CoVWpXdD.js rename to assets/chevron-right-COqGruhh.js index 76ea5b531a5978c0cd03f202a82e12c8e0025812..15058093259e5c7863ad43de2833e0eb6d723f61 100644 --- a/assets/chevron-right-CoVWpXdD.js +++ b/assets/chevron-right-COqGruhh.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-Cb8VeSuW.js";/** +import{e as o}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-up-Byo9SJJ4.js b/assets/chevron-up-Cdvz2TMJ.js similarity index 92% rename from assets/chevron-up-Byo9SJJ4.js rename to assets/chevron-up-Cdvz2TMJ.js index 2794ca904dc7646e7fc1be69eb5101db4e588bff..a41959e097f5b9b055cc56626f535a98a9a5e9bf 100644 --- a/assets/chevron-up-Byo9SJJ4.js +++ b/assets/chevron-up-Cdvz2TMJ.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-Cb8VeSuW.js";/** +import{e as o}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-alert-DgDGv7k5.js b/assets/circle-alert-CP9K3300.js similarity index 90% rename from assets/circle-alert-DgDGv7k5.js rename to assets/circle-alert-CP9K3300.js index a6ee9ce5967daee6d25d94a09d11b3acf55a12b3..8722e42ab17d19ee8ec1206b8ad03d515ad51325 100644 --- a/assets/circle-alert-DgDGv7k5.js +++ b/assets/circle-alert-CP9K3300.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-CVJuYLp6.js b/assets/circle-check-C0FPGTrp.js similarity index 87% rename from assets/circle-check-CVJuYLp6.js rename to assets/circle-check-C0FPGTrp.js index f9085a804fbb964db57778f5a7dca398b2dd44e1..8e21fab99cf8f900dda8299961c04c3034b07a7c 100644 --- a/assets/circle-check-CVJuYLp6.js +++ b/assets/circle-check-C0FPGTrp.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-Cb8VeSuW.js";/** +import{e as c}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-big-CNGbqkWz.js b/assets/circle-check-big-m1SvzGFL.js similarity index 88% rename from assets/circle-check-big-CNGbqkWz.js rename to assets/circle-check-big-m1SvzGFL.js index cdd0025401ca2043680331078e9e2aa6b6a1785a..2f09b14937ff3a10466409e376650d985e225fb3 100644 --- a/assets/circle-check-big-CNGbqkWz.js +++ b/assets/circle-check-big-m1SvzGFL.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-Cb8VeSuW.js";/** +import{e as c}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-help-hn0lWYq9.js b/assets/circle-help-B8apTIdU.js similarity index 89% rename from assets/circle-help-hn0lWYq9.js rename to assets/circle-help-B8apTIdU.js index b624901f3baaf60dad23372d803ae2b14ab72b6a..df46be8fd99be8bbbcf405815e074ba7cd2bc964 100644 --- a/assets/circle-help-hn0lWYq9.js +++ b/assets/circle-help-B8apTIdU.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-Cb8VeSuW.js";/** +import{e as c}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/clipboard-check-BEObtDZM.js b/assets/clipboard-check-DqBu2Pqb.js similarity index 91% rename from assets/clipboard-check-BEObtDZM.js rename to assets/clipboard-check-DqBu2Pqb.js index be78039337f98c5cdb000629391ac608aa106f7c..bbf74079d848eaa2f680c61ab60a7624821ab78a 100644 --- a/assets/clipboard-check-BEObtDZM.js +++ b/assets/clipboard-check-DqBu2Pqb.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/clock-BodmJJnp.js b/assets/clock-D1Ecvltm.js similarity index 87% rename from assets/clock-BodmJJnp.js rename to assets/clock-D1Ecvltm.js index 1831661330f73de361cba03686042720fcf3abdb..f726a73318861f552cb0991a1bad785a2f20bfe9 100644 --- a/assets/clock-BodmJJnp.js +++ b/assets/clock-D1Ecvltm.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-Cb8VeSuW.js";/** +import{e as c}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/diagnosticService-BIetid_s.js b/assets/diagnosticService-BDYTUoqk.js similarity index 62% rename from assets/diagnosticService-BIetid_s.js rename to assets/diagnosticService-BDYTUoqk.js index e41c327cd61400a7464137e9a4c8f490033dc564..5fdc892ad5360e81ba871f1710b60caf1a016604 100644 --- a/assets/diagnosticService-BIetid_s.js +++ b/assets/diagnosticService-BDYTUoqk.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Cb8VeSuW.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-Aaqs1LGb.css"])))=>i.map(i=>d[i]); -import{_ as w}from"./index-Cb8VeSuW.js";const y="https://deign86-mathpulse-api-v3test.hf.space";async function P(g,h){const f=`${y}/api/diagnostic/generate`,{auth:i}=await w(async()=>{const{auth:e}=await import("./index-Cb8VeSuW.js").then(s=>s.aU);return{auth:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),c=i.currentUser,l=async()=>{const e=new Headers({"Content-Type":"application/json"});if(c){const s=await c.getIdToken(!1);s&&e.set("Authorization",`Bearer ${s}`)}return e},u=async e=>fetch(f,{method:"POST",headers:await l(),body:JSON.stringify({strand:g,grade_level:h}),signal:e}),d=(e,s)=>{let t="Something went wrong. Please try again.";try{const a=JSON.parse(s);if(a.detail){const o=String(a.detail);o.includes("Database unavailable")||o.includes("unavailable")?t="Our servers are temporarily busy. Please try again in a moment.":o.includes("timeout")||o.includes("timed out")?t="The request timed out. Please check your connection and try again.":t=o}}catch{!e.ok&&s&&(t="Failed to start assessment. Please try again.")}return t},n=2,r=3e4;for(let e=1;e<=n;e++){const s=new AbortController,t=setTimeout(()=>s.abort(),r);try{const a=await u(s.signal);if(a.ok)return clearTimeout(t),a.json();if(a.status>=400&&a.status<500){clearTimeout(t);const m=await a.text().catch(()=>"");throw new Error(d(a,m))}const o=await a.text().catch(()=>""),p=d(a,o);if(clearTimeout(t),esetTimeout(T,m));continue}throw new Error(p)}catch(a){if(clearTimeout(t),a instanceof DOMException&&a.name==="AbortError"){if(e{const{auth:n}=await import("./index-Cb8VeSuW.js").then(r=>r.aU);return{auth:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),l=c.currentUser;if(l){const n=await l.getIdToken(!1);n&&i.set("Authorization",`Bearer ${n}`)}const u=new AbortController,d=setTimeout(()=>u.abort(),6e4);try{const n=await fetch(f,{method:"POST",headers:i,body:JSON.stringify({test_id:g,responses:h}),signal:u.signal});if(!n.ok){const r=await n.text().catch(()=>"");let e="Something went wrong. Please try again.";try{const s=JSON.parse(r);if(s.detail){const t=String(s.detail);t.includes("session")||t.includes("not found")?e="Your assessment session has expired. Please restart the assessment.":t.includes("Database unavailable")||t.includes("unavailable")?e="Our servers are temporarily busy. Please try again in a moment.":t.includes("timeout")||t.includes("timed out")?e="The request timed out. Please check your connection and try again.":e=t}}catch{r.includes("404")||r.includes("not found")?e="Your assessment session has expired. Please restart the assessment.":r&&(e="Something went wrong. Please try again.")}throw new Error(e)}return n.json()}finally{clearTimeout(d)}}export{P as g,_ as s}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BaOs5Ayg.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-DdX2rVyy.css"])))=>i.map(i=>d[i]); +import{_ as w}from"./index-BaOs5Ayg.js";const y="https://deign86-mathpulse-api-v3test.hf.space";async function P(g,h){const f=`${y}/api/diagnostic/generate`,{auth:i}=await w(async()=>{const{auth:e}=await import("./index-BaOs5Ayg.js").then(a=>a.b1);return{auth:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),c=i.currentUser,l=async()=>{const e=new Headers({"Content-Type":"application/json"});if(c){const a=await c.getIdToken(!1);a&&e.set("Authorization",`Bearer ${a}`)}return e},u=async e=>fetch(f,{method:"POST",headers:await l(),body:JSON.stringify({strand:g,grade_level:h}),signal:e}),d=(e,a)=>{let t="Something went wrong. Please try again.";try{const s=JSON.parse(a);if(s.detail){const o=String(s.detail);o.includes("Database unavailable")||o.includes("unavailable")?t="Our servers are temporarily busy. Please try again in a moment.":o.includes("timeout")||o.includes("timed out")?t="The request timed out. Please check your connection and try again.":t=o}}catch{!e.ok&&a&&(t="Failed to start assessment. Please try again.")}return t},n=2,r=3e4;for(let e=1;e<=n;e++){const a=new AbortController,t=setTimeout(()=>a.abort(),r);try{const s=await u(a.signal);if(s.ok)return clearTimeout(t),s.json();if(s.status>=400&&s.status<500){clearTimeout(t);const m=await s.text().catch(()=>"");throw new Error(d(s,m))}const o=await s.text().catch(()=>""),p=d(s,o);if(clearTimeout(t),esetTimeout(T,m));continue}throw new Error(p)}catch(s){if(clearTimeout(t),s instanceof DOMException&&s.name==="AbortError"){if(e{const{auth:n}=await import("./index-BaOs5Ayg.js").then(r=>r.b1);return{auth:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),l=c.currentUser;if(l){const n=await l.getIdToken(!1);n&&i.set("Authorization",`Bearer ${n}`)}const u=new AbortController,d=setTimeout(()=>u.abort(),6e4);try{const n=await fetch(f,{method:"POST",headers:i,body:JSON.stringify({test_id:g,responses:h}),signal:u.signal});if(!n.ok){const r=await n.text().catch(()=>"");let e="Something went wrong. Please try again.";try{const a=JSON.parse(r);if(a.detail){const t=String(a.detail);t.includes("session")||t.includes("not found")?e="Your assessment session has expired. Please restart the assessment.":t.includes("Database unavailable")||t.includes("unavailable")?e="Our servers are temporarily busy. Please try again in a moment.":t.includes("timeout")||t.includes("timed out")?e="The request timed out. Please check your connection and try again.":e=t}}catch{r.includes("404")||r.includes("not found")?e="Your assessment session has expired. Please restart the assessment.":r&&(e="Something went wrong. Please try again.")}throw new Error(e)}return n.json()}finally{clearTimeout(d)}}export{P as g,_ as s}; diff --git a/assets/dialog-CCp2tnRr.js b/assets/dialog-CHtYkwVl.js similarity index 94% rename from assets/dialog-CCp2tnRr.js rename to assets/dialog-CHtYkwVl.js index 88e2b12f354bb315f6c859ce7a7d0a04c60cb0b2..b319db804fe887522c78e5d12f7fe16e9a84c98b 100644 --- a/assets/dialog-CCp2tnRr.js +++ b/assets/dialog-CHtYkwVl.js @@ -1 +1 @@ -import{j as t,r as l}from"./vendor-react-B4AQeu28.js";import{c as m,d as n,e as i,T as r,D as d,P as p,O as c}from"./vendor-radix-BorKzPz9.js";import{i as s}from"./index-Cb8VeSuW.js";import{X as u}from"./x-CTLBAl-n.js";function w({...a}){return t.jsx(m,{"data-slot":"dialog",...a})}function x({...a}){return t.jsx(p,{"data-slot":"dialog-portal",...a})}function z({...a}){return t.jsx(i,{"data-slot":"dialog-close",...a})}const f=l.forwardRef(({className:a,...e},o)=>t.jsx(c,{ref:o,"data-slot":"dialog-overlay",className:s("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e}));f.displayName=c.displayName;const j=l.forwardRef(({className:a,children:e,...o},g)=>t.jsxs(x,{"data-slot":"dialog-portal",children:[t.jsx(f,{}),t.jsxs(n,{ref:g,"data-slot":"dialog-content",className:s("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...o,children:[e,t.jsxs(i,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));j.displayName=n.displayName;function R({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:s("flex flex-col gap-2 text-center sm:text-left",a),...e})}function C({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:s("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}const y=l.forwardRef(({className:a,...e},o)=>t.jsx(r,{ref:o,"data-slot":"dialog-title",className:s("text-lg leading-none font-semibold",a),...e}));y.displayName=r.displayName;const N=l.forwardRef(({className:a,...e},o)=>t.jsx(d,{ref:o,"data-slot":"dialog-description",className:s("text-muted-foreground text-sm",a),...e}));N.displayName=d.displayName;export{w as D,j as a,R as b,y as c,N as d,C as e,z as f}; +import{j as t,r as l}from"./vendor-react-B4AQeu28.js";import{c as m,d as n,e as i,T as r,D as d,P as p,O as c}from"./vendor-radix-BorKzPz9.js";import{i as s}from"./index-BaOs5Ayg.js";import{X as u}from"./x-TNvtuOD9.js";function w({...a}){return t.jsx(m,{"data-slot":"dialog",...a})}function x({...a}){return t.jsx(p,{"data-slot":"dialog-portal",...a})}function z({...a}){return t.jsx(i,{"data-slot":"dialog-close",...a})}const f=l.forwardRef(({className:a,...e},o)=>t.jsx(c,{ref:o,"data-slot":"dialog-overlay",className:s("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e}));f.displayName=c.displayName;const j=l.forwardRef(({className:a,children:e,...o},g)=>t.jsxs(x,{"data-slot":"dialog-portal",children:[t.jsx(f,{}),t.jsxs(n,{ref:g,"data-slot":"dialog-content",className:s("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...o,children:[e,t.jsxs(i,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));j.displayName=n.displayName;function R({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:s("flex flex-col gap-2 text-center sm:text-left",a),...e})}function C({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:s("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}const y=l.forwardRef(({className:a,...e},o)=>t.jsx(r,{ref:o,"data-slot":"dialog-title",className:s("text-lg leading-none font-semibold",a),...e}));y.displayName=r.displayName;const N=l.forwardRef(({className:a,...e},o)=>t.jsx(d,{ref:o,"data-slot":"dialog-description",className:s("text-muted-foreground text-sm",a),...e}));N.displayName=d.displayName;export{w as D,j as a,R as b,y as c,N as d,C as e,z as f}; diff --git a/assets/download-C-V0pYsk.js b/assets/download-DX_YebqQ.js similarity index 89% rename from assets/download-C-V0pYsk.js rename to assets/download-DX_YebqQ.js index 1c3f7ab268c644541a09c660b9b140f758bcd6d0..c314154ab0349668c951d2d4b8d254bc50391ac7 100644 --- a/assets/download-C-V0pYsk.js +++ b/assets/download-DX_YebqQ.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-Cb8VeSuW.js";/** +import{e as o}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/eye-DBkZRvYD.js b/assets/eye-Ig3S6mOs.js similarity index 96% rename from assets/eye-DBkZRvYD.js rename to assets/eye-Ig3S6mOs.js index 5b96bd72bedf6618aaa96b5853417066c8d24e54..ead363867eece6258fb2539ea9dd75be49918f87 100644 --- a/assets/eye-DBkZRvYD.js +++ b/assets/eye-Ig3S6mOs.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/funnel-D-s_ygM_.js b/assets/funnel-BT77sgnz.js similarity index 90% rename from assets/funnel-D-s_ygM_.js rename to assets/funnel-BT77sgnz.js index 57cb1e8eb51e728770c1574a133554a59e703436..1a4520899a1031862e4b91ae574d389119429c53 100644 --- a/assets/funnel-D-s_ygM_.js +++ b/assets/funnel-BT77sgnz.js @@ -1,4 +1,4 @@ -import{e}from"./index-Cb8VeSuW.js";/** +import{e}from"./index-BaOs5Ayg.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/index-BaOs5Ayg.js b/assets/index-BaOs5Ayg.js new file mode 100644 index 0000000000000000000000000000000000000000..77b9a42737da6bd3d7d51924c3bb93a49e9a61b1 --- /dev/null +++ b/assets/index-BaOs5Ayg.js @@ -0,0 +1,679 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/automationService-7m3RFJA3.js","assets/vendor-firebase-firestore-CH1lNiRF.js","assets/vendor-firebase-core-CO26nNq6.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-BLpRW_zO.js","assets/vendor-firebase-storage-B3igpVVS.js","assets/vendor-firebase-analytics-CTiUNb0-.js","assets/vendor-radix-BorKzPz9.js","assets/vendor-charts-D8hf8tI0.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/chatService-DwVkLoat.js","assets/trackingService-DQ12buWG.js","assets/LoginPage-DLaoyzV8.js","assets/button-DCfeFHoH.js","assets/input-D28h_UTJ.js","assets/sparkles-By-vFjpv.js","assets/mail-BbG1phxL.js","assets/eye-Ig3S6mOs.js","assets/shield-check-Dgisjfmb.js","assets/TeacherDashboard-CZdYfdg9.js","assets/dialog-CHtYkwVl.js","assets/x-TNvtuOD9.js","assets/ConfirmModal-6cgkqXAT.js","assets/trash-2-HTnKafZd.js","assets/log-out-BenDMDly.js","assets/LogoutActionButton-lUNItet6.js","assets/tooltip-ChRIOid3.js","assets/quizService-8JHQlvu9.js","assets/chevron-left-BWpgclqc.js","assets/send-CwwDU3uJ.js","assets/circle-alert-CP9K3300.js","assets/check-BLSo9L0H.js","assets/table-xeOJ8ZAA.js","assets/chevron-up-Cdvz2TMJ.js","assets/minus-DfrEv-SC.js","assets/plus-DkG35AoH.js","assets/card-D4dmQVNb.js","assets/download-DX_YebqQ.js","assets/chevron-right-COqGruhh.js","assets/save-CQIJrhLf.js","assets/search-Bq99THgc.js","assets/upload-DayXhGwD.js","assets/useQuery-BnRttv09.js","assets/subjects-BFghB0SQ.js","assets/chart-column-B3jJOD5i.js","assets/useCurriculum-DDCuCvMR.js","assets/circle-check-big-m1SvzGFL.js","assets/ChatMarkdown-fgwaycBR.js","assets/bell-clcSMJn6.js","assets/check-check-B_HghS1Z.js","assets/clock-D1Ecvltm.js","assets/skeleton-Bo6ISWhm.js","assets/vendor-xlsx-uZelXSz_.js","assets/circle-help-B8apTIdU.js","assets/clipboard-check-DqBu2Pqb.js","assets/AdminDashboard-B2eiYi-q.js","assets/Sidebar-2LZAqf7E.js","assets/shirt-S3NBuaPm.js","assets/select-DIjxRWza.js","assets/lightbulb-Ce2KQzGM.js","assets/switch-CblAJO7o.js","assets/funnel-BT77sgnz.js","assets/useSubjectAvailability-Bvu3fXaT.js","assets/HeroBanner-CKiXGluA.js","assets/circle-check-C0FPGTrp.js","assets/RightSidebar-CmYzVUKQ.js","assets/quiz_battle_avatar-BXHPSput.js","assets/XPNotification-DRsFdUWw.js","assets/index-CajSaEd0.js","assets/SupplementalBanner-DFkcXPOZ.js","assets/SupplementalPillCarousel-BqNTelmK.js","assets/LearningPath-BBE0vZ0S.js","assets/ModuleFolderCard-DKBrO5a8.js","assets/CompetencyRadarChart-CBuH8ru8.js","assets/ModulesPage-cZJm_yoJ.js","assets/ScientificCalculator-DRuSfTXj.js","assets/volume-x-Chtf_bSj.js","assets/confetti.module-C94ZD2ww.js","assets/AIChatPage-CI1qQgCG.js","assets/GradesPage-Y0HsmLPP.js","assets/LeaderboardPage-D9eaC9ey.js","assets/useFeatureAccess-BSpfx3vY.js","assets/QuizBattlePage-Bwu0snEF.js","assets/CompositeAvatar-Col05lJc.js","assets/avatarData-BuQSOXo3.js","assets/AvatarShop-BeFk31yM.js","assets/FloatingAITutor-BIdguqCV.js","assets/maximize-2-EHa6JURc.js","assets/RewardsModal-CPyFRkMy.js","assets/ProfileModal-Gwxh5tYO.js","assets/ProfilePictureUploader-CX_IZAwE.js","assets/SettingsModal-BbkSqdYG.js","assets/InitialAssessmentModal-CknVaqMx.js","assets/diagnosticService-BDYTUoqk.js","assets/AssessmentPage-YsCyxvJJ.js","assets/testResetService-gpYLnLG7.js"])))=>i.map(i=>d[i]); +import{r as f,j as b,d as D,c as Eh,f as kh}from"./vendor-react-B4AQeu28.js";import{persistentLocalCache as Ka,initializeFirestore as Qa,setDoc as Ne,doc as H,serverTimestamp as ce,getDoc as ge,getDocFromServer as oi,onSnapshot as rn,query as It,limit as Yn,orderBy as Sn,collection as We,getDocs as Tn,updateDoc as _t,arrayUnion as yc,where as At,increment as zn,deleteDoc as li,Timestamp as jn,runTransaction as Ah}from"./vendor-firebase-firestore-CH1lNiRF.js";import{U as Rh,V as Mh,Y as Dh,Z as Ih}from"./vendor-firebase-core-CO26nNq6.js";import{browserLocalPersistence as Xa,initializeAuth as Ya,browserSessionPersistence as _h,inMemoryPersistence as Ja,GoogleAuthProvider as Lh,createUserWithEmailAndPassword as Oh,updateProfile as Nh,signInWithEmailAndPassword as jh,signOut as Fh,onAuthStateChanged as Vh,updatePassword as $h,updateEmail as Bh,deleteUser as zh,EmailAuthProvider as Uh,reauthenticateWithCredential as qh}from"./vendor-firebase-auth-BLpRW_zO.js";import{g as Gh}from"./vendor-firebase-storage-B3igpVVS.js";import{g as Hh}from"./vendor-firebase-analytics-CTiUNb0-.js";import{R as Wh,I as Kh,F as Qh}from"./vendor-radix-BorKzPz9.js";import{c as Xh}from"./vendor-charts-D8hf8tI0.js";import"./vendor-markdown-yqZQ_iQm.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var nr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Yh=class extends nr{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},bc=new Yh,Jh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Zh=class{#e=Jh;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},ci=new Zh;function ef(e){setTimeout(e,0)}var tf=typeof window>"u"||"Deno"in globalThis;function lt(){}function nf(e,t){return typeof e=="function"?e(t):e}function sf(e){return typeof e=="number"&&e>=0&&e!==1/0}function rf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ui(e,t){return typeof e=="function"?e(t):e}function af(e,t){return typeof e=="function"?e(t):e}function Za(e,t){const{type:n="all",exact:s,fetchStatus:r,predicate:i,queryKey:a,stale:o}=e;if(a){if(s){if(t.queryHash!==Ki(a,t.options))return!1}else if(!qn(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||r&&r!==t.state.fetchStatus||i&&!i(t))}function eo(e,t){const{exact:n,status:s,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Un(t.options.mutationKey)!==Un(i))return!1}else if(!qn(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Ki(e,t){return(t?.queryKeyHashFn||Un)(e)}function Un(e){return JSON.stringify(e,(t,n)=>di(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}function qn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qn(e[n],t[n])):!1}var of=Object.prototype.hasOwnProperty;function vc(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=to(e)&&to(t);if(!s&&!(di(e)&&di(t)))return t;const i=(s?e:Object.keys(e)).length,a=s?t:Object.keys(t),o=a.length,l=s?new Array(o):{};let d=0;for(let u=0;u{ci.setTimeout(t,e)})}function cf(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?vc(e,t):t}function uf(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function df(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var Qi=Symbol();function wc(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Qi?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function GT(e,t){return typeof e=="function"?e(...t):!!e}function hf(e,t,n){let s=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??=t(),s||(s=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),e}var xc=(()=>{let e=()=>tf;return{isServer(){return e()},setIsServer(t){e=t}}})();function ff(){let e,t;const n=new Promise((r,i)=>{e=r,t=i});n.status="pending",n.catch(()=>{});function s(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},n.reject=r=>{s({status:"rejected",reason:r}),t(r)},n}var mf=ef;function pf(){let e=[],t=0,n=o=>{o()},s=o=>{o()},r=mf;const i=o=>{t?e.push(o):r(()=>{n(o)})},a=()=>{const o=e;e=[],o.length&&r(()=>{s(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;t++;try{l=o()}finally{t--,t||a()}return l},batchCalls:o=>(...l)=>{i(()=>{o(...l)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{s=o},setScheduler:o=>{r=o}}}var ze=pf(),gf=class extends nr{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},Bs=new gf;function yf(e){return Math.min(1e3*2**e,3e4)}function Sc(e){return(e??"online")==="online"?Bs.isOnline():!0}var hi=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Tc(e){let t=!1,n=0,s;const r=ff(),i=()=>r.status!=="pending",a=y=>{if(!i()){const g=new hi(y);h(g),e.onCancel?.(g)}},o=()=>{t=!0},l=()=>{t=!1},d=()=>bc.isFocused()&&(e.networkMode==="always"||Bs.isOnline())&&e.canRun(),u=()=>Sc(e.networkMode)&&e.canRun(),c=y=>{i()||(s?.(),r.resolve(y))},h=y=>{i()||(s?.(),r.reject(y))},m=()=>new Promise(y=>{s=g=>{(i()||d())&&y(g)},e.onPause?.()}).then(()=>{s=void 0,i()||e.onContinue?.()}),p=()=>{if(i())return;let y;const g=n===0?e.initialPromise:void 0;try{y=g??e.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(c).catch(v=>{if(i())return;const T=e.retry??(xc.isServer()?0:3),x=e.retryDelay??yf,S=typeof x=="function"?x(n,v):x,C=T===!0||typeof T=="number"&&nd()?void 0:m()).then(()=>{t?h(v):p()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(s?.(),r),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?p():m().then(p),r)}}var Cc=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sf(this.gcTime)&&(this.#e=ci.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xc.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(ci.clearTimeout(this.#e),this.#e=void 0)}};function bf(e){return{onFetch:(t,n)=>{const s=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const c=p=>{hf(p,()=>t.signal,()=>u=!0)},h=wc(t.options,t.fetchOptions),m=async(p,y,g)=>{if(u)return Promise.reject(t.signal.reason);if(y==null&&p.pages.length)return Promise.resolve(p);const T=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:y,direction:g?"backward":"forward",meta:t.options.meta};return c(P),P})(),x=await h(T),{maxPages:S}=t.options,C=g?df:uf;return{pages:C(p.pages,x,S),pageParams:C(p.pageParams,y,S)}};if(r&&i.length){const p=r==="backward",y=p?vf:so,g={pages:i,pageParams:a},v=y(s,g);o=await m(g,v,p)}else{const p=e??i.length;do{const y=l===0?a[0]??s.initialPageParam:so(s,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(lt.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function so(e,{pages:t,pageParams:n}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,n[s],n):void 0}function vf(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var wf=class extends Cc{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e){super(),this.#a=!1,this.#l=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=io(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#s?.promise}setOptions(e){if(this.options={...this.#l,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=io(this.options);t.data!==void 0&&(this.setState(ro(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=cf(this.state.data,e,this.options);return this.#o({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#o({type:"setState",state:e})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(lt).catch(lt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>af(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Qi||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ui(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!rf(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#a||this.#c()?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#s?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(d=>d.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,s=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},r=()=>{const l=wc(this.options,t),u=(()=>{const c={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(c),c})();return this.#a=!1,this.options.persister?this.options.persister(l,u,this):l(u)},a=(()=>{const l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:r};return s(l),l})();(this.#e==="infinite"?bf(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#o({type:"fetch",meta:a.fetchOptions?.meta}),this.#s=Tc({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:l=>{l instanceof hi&&l.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(l,d)=>{this.#o({type:"failed",failureCount:l,error:d})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const l=await this.#s.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#r.config.onSuccess?.(l,this),this.#r.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof hi){if(l.silent)return this.#s.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#o({type:"error",error:l}),this.#r.config.onError?.(l,this),this.#r.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#o(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...xf(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,...ro(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?s:void 0,s;case"error":const r=e.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function xf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Sc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ro(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function io(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Sf=class extends Cc{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Tf(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#i({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Tc({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const s=this.state.status==="pending",r=!this.#r.canStart();try{if(s)t();else{this.#i({type:"pending",variables:e,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:r})}const i=await this.#r.start();return await this.#n.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#n.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#i({type:"success",data:i}),i}catch(i){try{await this.#n.config.onError?.(i,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#n.runNext(this)}}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function Tf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Cf=class extends nr{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){const s=new Sf({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(s),s}add(e){this.#e.add(e);const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=hs(e);if(typeof t=="string"){const s=this.#t.get(t)?.find(r=>r.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=hs(e);return typeof t=="string"?this.#t.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>eo(t,n))}findAll(e={}){return this.getAll().filter(t=>eo(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(lt))))}};function hs(e){return e.options.scope?.id}var Pf=class extends nr{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const s=t.queryKey,r=t.queryHash??Ki(s,t);let i=this.get(r);return i||(i=new wf({client:e,queryKey:s,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Za(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Za(e,n)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ef=class{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e={}){this.#e=e.queryCache||new Pf,this.#t=e.mutationCache||new Cf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#l=bc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Bs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#l?.(),this.#l=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ui(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(s.queryHash)?.state.data,a=nf(t,i);if(a!==void 0)return this.#e.build(this,s).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=ze.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(s).then(lt).catch(lt)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=ze.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(lt)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(lt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(ui(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(lt).catch(lt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(lt).catch(lt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Bs.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Un(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(s=>{qn(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Un(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(s=>{qn(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ki(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Qi&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Pc=f.createContext(void 0),HT=e=>{const t=f.useContext(Pc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},kf=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Pc.Provider,{value:e,children:t}));/** + * react-router v7.14.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */var ao="popstate";function oo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Af(e={}){function t(s,r){let i=r.state?.masked,{pathname:a,search:o,hash:l}=i||s.location;return fi("",{pathname:a,search:o,hash:l},r.state&&r.state.usr||null,r.state&&r.state.key||"default",i?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,r){return typeof r=="string"?r:Gn(r)}return Mf(t,n,null,e)}function Ae(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function wt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Rf(){return Math.random().toString(36).substring(2,10)}function lo(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function fi(e,t,n=null,s,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jn(t):t,state:n,key:t&&t.key||s||Rf(),unstable_mask:r}}function Gn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function Mf(e,t,n,s={}){let{window:r=document.defaultView,v5Compat:i=!1}=s,a=r.history,o="POP",l=null,d=u();d==null&&(d=0,a.replaceState({...a.state,idx:d},""));function u(){return(a.state||{idx:null}).idx}function c(){o="POP";let g=u(),v=g==null?null:g-d;d=g,l&&l({action:o,location:y.location,delta:v})}function h(g,v){o="PUSH";let T=oo(g)?g:fi(y.location,g,v);d=u()+1;let x=lo(T,d),S=y.createHref(T.unstable_mask||T);try{a.pushState(x,"",S)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;r.location.assign(S)}i&&l&&l({action:o,location:y.location,delta:1})}function m(g,v){o="REPLACE";let T=oo(g)?g:fi(y.location,g,v);d=u();let x=lo(T,d),S=y.createHref(T.unstable_mask||T);a.replaceState(x,"",S),i&&l&&l({action:o,location:y.location,delta:0})}function p(g){return Df(g)}let y={get action(){return o},get location(){return e(r,a)},listen(g){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(ao,c),l=g,()=>{r.removeEventListener(ao,c),l=null}},createHref(g){return t(r,g)},createURL:p,encodeLocation(g){let v=p(g);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:h,replace:m,go(g){return a.go(g)}};return y}function Df(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ae(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:Gn(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function Ec(e,t,n="/"){return If(e,t,n,!1)}function If(e,t,n,s){let r=typeof t=="string"?Jn(t):t,i=Mt(r.pathname||"/",n);if(i==null)return null;let a=kc(e);_f(a);let o=null;for(let l=0;o==null&&l{let u={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(s)&&l)return;Ae(u.relativePath.startsWith(s),`Absolute route path "${u.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(s.length)}let c=ct([s,u.relativePath]),h=n.concat(u);a.children&&a.children.length>0&&(Ae(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),kc(a.children,t,h,c,l)),!(a.path==null&&!a.index)&&t.push({path:c,score:$f(c,a.index),routesMeta:h})};return e.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))i(a,o);else for(let l of Ac(a.path))i(a,o,!0,l)}),t}function Ac(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return r?[i,""]:[i];let a=Ac(s.join("/")),o=[];return o.push(...a.map(l=>l===""?i:[i,l].join("/"))),r&&o.push(...a),o.map(l=>e.startsWith("/")&&l===""?"/":l)}function _f(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Bf(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var Lf=/^:[\w-]+$/,Of=3,Nf=2,jf=1,Ff=10,Vf=-2,co=e=>e==="*";function $f(e,t){let n=e.split("/"),s=n.length;return n.some(co)&&(s+=Vf),t&&(s+=Nf),n.filter(r=>!co(r)).reduce((r,i)=>r+(Lf.test(i)?Of:i===""?jf:Ff),s)}function Bf(e,t){return e.length===t.length&&e.slice(0,-1).every((s,r)=>s===t[r])?e[e.length-1]-t[t.length-1]:0}function zf(e,t,n=!1){let{routesMeta:s}=e,r={},i="/",a=[];for(let o=0;o{if(u==="*"){let p=o[h]||"";a=i.slice(0,i.length-p.length).replace(/(.)\/+$/,"$1")}const m=o[h];return c&&!m?d[u]=void 0:d[u]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:a,pattern:e}}function Uf(e,t=!1,n=!0){wt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let s=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l,d,u)=>{if(s.push({paramName:o,isOptional:l!=null}),l){let c=u.charAt(d+a.length);return c&&c!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),s]}function qf(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Mt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}var Gf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Hf(e,t="/"){let{pathname:n,search:s="",hash:r=""}=typeof e=="string"?Jn(e):e,i;return n?(n=Mc(n),n.startsWith("/")?i=uo(n.substring(1),"/"):i=uo(n,t)):i=t,{pathname:i,search:Qf(s),hash:Xf(r)}}function uo(e,t){let n=Us(t).split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Ar(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Wf(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Rc(e){let t=Wf(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Xi(e,t,n,s=!1){let r;typeof e=="string"?r=Jn(e):(r={...e},Ae(!r.pathname||!r.pathname.includes("?"),Ar("?","pathname","search",r)),Ae(!r.pathname||!r.pathname.includes("#"),Ar("#","pathname","hash",r)),Ae(!r.search||!r.search.includes("#"),Ar("#","search","hash",r)));let i=e===""||r.pathname==="",a=i?"/":r.pathname,o;if(a==null)o=n;else{let c=t.length-1;if(!s&&a.startsWith("..")){let h=a.split("/");for(;h[0]==="..";)h.shift(),c-=1;r.pathname=h.join("/")}o=c>=0?t[c]:"/"}let l=Hf(r,o),d=a&&a!=="/"&&a.endsWith("/"),u=(i||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(d||u)&&(l.pathname+="/"),l}var Mc=e=>e.replace(/\/\/+/g,"/"),ct=e=>Mc(e.join("/")),Us=e=>e.replace(/\/+$/,""),Kf=e=>Us(e).replace(/^\/*/,"/"),Qf=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Xf=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Yf=class{constructor(e,t,n,s=!1){this.status=e,this.statusText=t||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Jf(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Zf(e){let t=e.map(n=>n.route.path).filter(Boolean);return ct(t)||"/"}var Dc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ic(e,t){let n=e;if(typeof n!="string"||!Gf.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,r=!1;if(Dc)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),o=Mt(a.pathname,t);a.origin===i.origin&&o!=null?n=o+a.search+a.hash:r=!0}catch{wt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _c=["POST","PUT","PATCH","DELETE"];new Set(_c);var em=["GET",..._c];new Set(em);var Cn=f.createContext(null);Cn.displayName="DataRouter";var sr=f.createContext(null);sr.displayName="DataRouterState";var Lc=f.createContext(!1);function tm(){return f.useContext(Lc)}var Oc=f.createContext({isTransitioning:!1});Oc.displayName="ViewTransition";var nm=f.createContext(new Map);nm.displayName="Fetchers";var sm=f.createContext(null);sm.displayName="Await";var tt=f.createContext(null);tt.displayName="Navigation";var rr=f.createContext(null);rr.displayName="Location";var Lt=f.createContext({outlet:null,matches:[],isDataRoute:!1});Lt.displayName="Route";var Yi=f.createContext(null);Yi.displayName="RouteError";var Nc="REACT_ROUTER_ERROR",rm="REDIRECT",im="ROUTE_ERROR_RESPONSE";function am(e){if(e.startsWith(`${Nc}:${rm}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function om(e){if(e.startsWith(`${Nc}:${im}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Yf(t.status,t.statusText,t.data)}catch{}}function lm(e,{relative:t}={}){Ae(Zn(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:s}=f.useContext(tt),{hash:r,pathname:i,search:a}=es(e,{relative:t}),o=i;return n!=="/"&&(o=i==="/"?n:ct([n,i])),s.createHref({pathname:o,search:a,hash:r})}function Zn(){return f.useContext(rr)!=null}function St(){return Ae(Zn(),"useLocation() may be used only in the context of a component."),f.useContext(rr).location}var jc="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Fc(e){f.useContext(tt).static||f.useLayoutEffect(e)}function Vc(){let{isDataRoute:e}=f.useContext(Lt);return e?xm():cm()}function cm(){Ae(Zn(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Cn),{basename:t,navigator:n}=f.useContext(tt),{matches:s}=f.useContext(Lt),{pathname:r}=St(),i=JSON.stringify(Rc(s)),a=f.useRef(!1);return Fc(()=>{a.current=!0}),f.useCallback((l,d={})=>{if(wt(a.current,jc),!a.current)return;if(typeof l=="number"){n.go(l);return}let u=Xi(l,JSON.parse(i),r,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:ct([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,r,e])}f.createContext(null);function es(e,{relative:t}={}){let{matches:n}=f.useContext(Lt),{pathname:s}=St(),r=JSON.stringify(Rc(n));return f.useMemo(()=>Xi(e,JSON.parse(r),s,t==="path"),[e,r,s,t])}function um(e,t,n){Ae(Zn(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=f.useContext(tt),{matches:r}=f.useContext(Lt),i=r[r.length-1],a=i?i.params:{},o=i?i.pathname:"/",l=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";Bc(o,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${o}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let u=St(),c;c=u;let h=c.pathname||"/",m=h;if(l!=="/"){let g=l.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let p=Ec(e,{pathname:m});return wt(d||p!=null,`No routes matched location "${c.pathname}${c.search}${c.hash}" `),wt(p==null||p[p.length-1].route.element!==void 0||p[p.length-1].route.Component!==void 0||p[p.length-1].route.lazy!==void 0,`Matched leaf route at location "${c.pathname}${c.search}${c.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`),pm(p&&p.map(g=>Object.assign({},g,{params:Object.assign({},a,g.params),pathname:ct([l,s.encodeLocation?s.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?l:ct([l,s.encodeLocation?s.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),r,n)}function dm(){let e=wm(),t=Jf(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:s},i={padding:"2px 4px",backgroundColor:s},a=null;return console.error("Error handled by React Router default ErrorBoundary:",e),a=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:i},"ErrorBoundary")," or"," ",f.createElement("code",{style:i},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:r},n):null,a)}var hm=f.createElement(dm,null),$c=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=om(e.digest);n&&(e=n)}let t=e!==void 0?f.createElement(Lt.Provider,{value:this.props.routeContext},f.createElement(Yi.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?f.createElement(fm,{error:e},t):t}};$c.contextType=Lc;var Rr=new WeakMap;function fm({children:e,error:t}){let{basename:n}=f.useContext(tt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=am(t.digest);if(s){let r=Rr.get(t);if(r)throw r;let i=Ic(s.location,n);if(Dc&&!Rr.get(t))if(i.isExternal||s.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:s.replace}));throw Rr.set(t,a),a}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function mm({routeContext:e,match:t,children:n}){let s=f.useContext(Cn);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(Lt.Provider,{value:e},n)}function pm(e,t=[],n){let s=n?.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let r=e,i=s?.errors;if(i!=null){let u=r.findIndex(c=>c.route.id&&i?.[c.route.id]!==void 0);Ae(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),r=r.slice(0,Math.min(r.length,u+1))}let a=!1,o=-1;if(n&&s){a=s.renderFallback;for(let u=0;u=0?r=r.slice(0,o+1):r=[r[0]];break}}}}let l=n?.onError,d=s&&l?(u,c)=>{l(u,{location:s.location,params:s.matches?.[0]?.params??{},unstable_pattern:Zf(s.matches),errorInfo:c})}:void 0;return r.reduceRight((u,c,h)=>{let m,p=!1,y=null,g=null;s&&(m=i&&c.route.id?i[c.route.id]:void 0,y=c.route.errorElement||hm,a&&(o<0&&h===0?(Bc("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):o===h&&(p=!0,g=c.route.hydrateFallbackElement||null)));let v=t.concat(r.slice(0,h+1)),T=()=>{let x;return m?x=y:p?x=g:c.route.Component?x=f.createElement(c.route.Component,null):c.route.element?x=c.route.element:x=u,f.createElement(mm,{match:c,routeContext:{outlet:u,matches:v,isDataRoute:s!=null},children:x})};return s&&(c.route.ErrorBoundary||c.route.errorElement||h===0)?f.createElement($c,{location:s.location,revalidation:s.revalidation,component:y,error:m,children:T(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:d}):T()},null)}function Ji(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gm(e){let t=f.useContext(Cn);return Ae(t,Ji(e)),t}function ym(e){let t=f.useContext(sr);return Ae(t,Ji(e)),t}function bm(e){let t=f.useContext(Lt);return Ae(t,Ji(e)),t}function Zi(e){let t=bm(e),n=t.matches[t.matches.length-1];return Ae(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function vm(){return Zi("useRouteId")}function wm(){let e=f.useContext(Yi),t=ym("useRouteError"),n=Zi("useRouteError");return e!==void 0?e:t.errors?.[n]}function xm(){let{router:e}=gm("useNavigate"),t=Zi("useNavigate"),n=f.useRef(!1);return Fc(()=>{n.current=!0}),f.useCallback(async(r,i={})=>{wt(n.current,jc),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var ho={};function Bc(e,t,n){!t&&!ho[e]&&(ho[e]=!0,wt(!1,n))}f.memo(Sm);function Sm({routes:e,future:t,state:n,isStatic:s,onError:r}){return um(e,void 0,{state:n,isStatic:s,onError:r})}function Tm({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:r,static:i=!1,unstable_useTransitions:a}){Ae(!Zn(),"You cannot render a inside another . You should never have more than one in your app.");let o=e.replace(/^\/*/,"/"),l=f.useMemo(()=>({basename:o,navigator:r,static:i,unstable_useTransitions:a,future:{}}),[o,r,i,a]);typeof n=="string"&&(n=Jn(n));let{pathname:d="/",search:u="",hash:c="",state:h=null,key:m="default",unstable_mask:p}=n,y=f.useMemo(()=>{let g=Mt(d,o);return g==null?null:{location:{pathname:g,search:u,hash:c,state:h,key:m,unstable_mask:p},navigationType:s}},[o,d,u,c,h,m,s,p]);return wt(y!=null,` is not able to match the URL "${d}${u}${c}" because it does not start with the basename, so the won't render anything.`),y==null?null:f.createElement(tt.Provider,{value:l},f.createElement(rr.Provider,{children:t,value:y}))}var ks="get",As="application/x-www-form-urlencoded";function ir(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Cm(e){return ir(e)&&e.tagName.toLowerCase()==="button"}function Pm(e){return ir(e)&&e.tagName.toLowerCase()==="form"}function Em(e){return ir(e)&&e.tagName.toLowerCase()==="input"}function km(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Am(e,t){return e.button===0&&(!t||t==="_self")&&!km(e)}var fs=null;function Rm(){if(fs===null)try{new FormData(document.createElement("form"),0),fs=!1}catch{fs=!0}return fs}var Mm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Mr(e){return e!=null&&!Mm.has(e)?(wt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${As}"`),null):e}function Dm(e,t){let n,s,r,i,a;if(Pm(e)){let o=e.getAttribute("action");s=o?Mt(o,t):null,n=e.getAttribute("method")||ks,r=Mr(e.getAttribute("enctype"))||As,i=new FormData(e)}else if(Cm(e)||Em(e)&&(e.type==="submit"||e.type==="image")){let o=e.form;if(o==null)throw new Error('Cannot submit a