diff --git a/assets/AIChatPage-DAxLSWfo.js b/assets/AIChatPage-DUfoPWot.js similarity index 94% rename from assets/AIChatPage-DAxLSWfo.js rename to assets/AIChatPage-DUfoPWot.js index 4947e134fe04fa014bb59f23ac2b2f8696ba705a..b26ca513162b12a7cba1daff9b6ad8e0091b86d1 100644 --- a/assets/AIChatPage-DAxLSWfo.js +++ b/assets/AIChatPage-DUfoPWot.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{aE as B,u as z,_ as F,h as S,m as C,J as D}from"./index-dPnhhJ9w.js";import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-WbM5w2Bp.js";import{I}from"./input-BUQJctP7.js";import H from"./ChatMarkdown-3H5bHtZy.js";import{P as Y}from"./plus-BIEera7J.js";import{S as G}from"./search-DqYX8akO.js";import{T as Q}from"./trash-2-BCXZR1t7.js";import{C as W}from"./chevron-left-DfHtS3Om.js";import{S as q}from"./send-C3s19g5N.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";function J(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 he=()=>{const{sessions:r,activeSessionId:a,isLoading:l,loadingSessionId:A,setActiveSessionId:n,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=B(),{userProfile:c}=z(),[m,P]=o.useState(""),[i,g]=o.useState(""),[y,j]=o.useState(!1),x=o.useRef(null),h=o.useRef(!0),u=o.useRef(!1),d=_(),p=d?.messages||[],E=p.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&a===A&&!E,w=(t="auto")=>{const s=x.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},M=()=>{const t=x.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},R=()=>{h.current=M()};o.useEffect(()=>{F(async()=>{const{warmupBackend:t}=await import("./index-dPnhhJ9w.js").then(s=>s.b6);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)})},[]),o.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[p,v]),o.useEffect(()=>{h.current=!0,w("auto")},[a]);const N=async()=>{if(!(!i.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=a;t||(t=b(),n(t));const s=i.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();n(t)},$=(t,s)=>{s.stopPropagation(),T(t)},f=r.filter(t=>t.title.toLowerCase().includes(m.toLowerCase())||t.preview.toLowerCase().includes(m.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex md:gap-4 px-0 md:px-4 sm:px-6 xl:px-10 py-0 md:py-6",children:[e.jsxs("div",{className:`${a?"hidden md:flex":"flex"} w-full md:w-80 min-h-0 flex-col bg-[#f7f9fc] rounded-none md:rounded-3xl border-0 md: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 justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 md:w-12 md:h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-xl md:rounded-2xl flex items-center justify-center shrink-0",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-8 h-8 md:w-10 md:h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm md: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:"bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-3 py-2 rounded-xl text-xs font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-1.5 shrink-0",children:[e.jsx(Y,{size:14}),"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:m,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:[f.length," Conversations"]})}),e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>n(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${a===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 ${a===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>$(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 ${a===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),f.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:`${a?"flex":"hidden md:flex"} flex-1 min-h-0 flex-col bg-[#f7f9fc] rounded-none md:rounded-3xl border-0 md:border border-[#dde3eb] overflow-hidden`,children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 md:p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0 bg-white md:bg-transparent shadow-sm md:shadow-none z-10 relative",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("button",{onClick:()=>n(null),className:"md:hidden p-1.5 -ml-1 text-slate-500 hover:text-slate-800 rounded-lg hover:bg-slate-100",children:e.jsx(W,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628] text-sm md:text-base",children:d?.title}),e.jsx("p",{className:"text-[10px] md:text-xs text-[#5a6578]",children:d?.date})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:d?.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:x,onScroll:R,className:"flex-1 overflow-y-auto overscroll-contain p-4 md:p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:p.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:J(t.timestamp)})]}),t.sender==="user"&&e.jsx(D,{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-3 md:p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 md:gap-3",children:[e.jsx(I,{type:"text",value:i,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:!i.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(q,{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{he as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{aE as B,u as z,_ as F,h as S,m as C,J as D}from"./index-CGNBpSmO.js";import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-DVjn4LkC.js";import{I}from"./input-CBi6xF4I.js";import H from"./ChatMarkdown-BAxWaDZo.js";import{P as Y}from"./plus-ck_SGnHK.js";import{S as G}from"./search-C_DiQDej.js";import{T as Q}from"./trash-2-BhQyV3WQ.js";import{C as W}from"./chevron-left-BuATOj9f.js";import{S as q}from"./send-DnRgK3MX.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";function J(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 he=()=>{const{sessions:r,activeSessionId:a,isLoading:l,loadingSessionId:A,setActiveSessionId:n,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=B(),{userProfile:c}=z(),[m,P]=o.useState(""),[i,g]=o.useState(""),[y,j]=o.useState(!1),x=o.useRef(null),h=o.useRef(!0),u=o.useRef(!1),d=_(),p=d?.messages||[],E=p.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&a===A&&!E,w=(t="auto")=>{const s=x.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},M=()=>{const t=x.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},R=()=>{h.current=M()};o.useEffect(()=>{F(async()=>{const{warmupBackend:t}=await import("./index-CGNBpSmO.js").then(s=>s.b6);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)})},[]),o.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[p,v]),o.useEffect(()=>{h.current=!0,w("auto")},[a]);const N=async()=>{if(!(!i.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=a;t||(t=b(),n(t));const s=i.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();n(t)},$=(t,s)=>{s.stopPropagation(),T(t)},f=r.filter(t=>t.title.toLowerCase().includes(m.toLowerCase())||t.preview.toLowerCase().includes(m.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex md:gap-4 px-0 md:px-4 sm:px-6 xl:px-10 py-0 md:py-6",children:[e.jsxs("div",{className:`${a?"hidden md:flex":"flex"} w-full md:w-80 min-h-0 flex-col bg-[#f7f9fc] rounded-none md:rounded-3xl border-0 md: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 justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 md:w-12 md:h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-xl md:rounded-2xl flex items-center justify-center shrink-0",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-8 h-8 md:w-10 md:h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm md: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:"bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-3 py-2 rounded-xl text-xs font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-1.5 shrink-0",children:[e.jsx(Y,{size:14}),"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:m,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:[f.length," Conversations"]})}),e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>n(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${a===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 ${a===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>$(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 ${a===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),f.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:`${a?"flex":"hidden md:flex"} flex-1 min-h-0 flex-col bg-[#f7f9fc] rounded-none md:rounded-3xl border-0 md:border border-[#dde3eb] overflow-hidden`,children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 md:p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0 bg-white md:bg-transparent shadow-sm md:shadow-none z-10 relative",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("button",{onClick:()=>n(null),className:"md:hidden p-1.5 -ml-1 text-slate-500 hover:text-slate-800 rounded-lg hover:bg-slate-100",children:e.jsx(W,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628] text-sm md:text-base",children:d?.title}),e.jsx("p",{className:"text-[10px] md:text-xs text-[#5a6578]",children:d?.date})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:d?.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:x,onScroll:R,className:"flex-1 overflow-y-auto overscroll-contain p-4 md:p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:p.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:J(t.timestamp)})]}),t.sender==="user"&&e.jsx(D,{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-3 md:p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 md:gap-3",children:[e.jsx(I,{type:"text",value:i,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:!i.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(q,{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{he as default}; diff --git a/assets/AdminDashboard-D4ep7elR.js b/assets/AdminDashboard-DdSNmQm3.js similarity index 98% rename from assets/AdminDashboard-D4ep7elR.js rename to assets/AdminDashboard-DdSNmQm3.js index aa543a5120d4d7fedb2b2d66b3463cbe4bf1b62e..9f5786c3bb058f768473a81ea26e1e680f8e9555 100644 --- a/assets/AdminDashboard-D4ep7elR.js +++ b/assets/AdminDashboard-DdSNmQm3.js @@ -1,4 +1,4 @@ -import{j as e,r as l,d as ps}from"./vendor-react-B4AQeu28.js";import{C as Vs,S as Ds}from"./Sidebar-DT74kKuo.js";import Ws from"./ConfirmModal-CtRcSVjb.js";import{e as fe,n as Ae,g as q,l as ke,j as w,h as Et,m as se,p as B,R as Ce,N as zt,r as hs,O as Dt,P as Pt,o as Xs,u as Ze,L as Qs,S as us,x as Ks,v as ye,U as Pe,G as Ye,i as Rt,Q as Ps,V as Rs,W as Ts,q as Tt,A as Ms,Z as Re,X as Mt,B as $t,T as Ys,a as Ue,F as Lt,Y as Ut,$ as It,D as Ft,M as Ot,J as _t}from"./index-dPnhhJ9w.js";import{B as S}from"./button-WbM5w2Bp.js";import{S as Y,a as J,b as ze,c as Z,d as k}from"./select-Ca_HQeg8.js";import{I as ie}from"./input-BUQJctP7.js";import{S as Qe}from"./subjects-DzQfiusb.js";import{getDocs as ee,query as Te,collection as Q,orderBy as Ie,deleteDoc as Bt,doc as Gt,limit as Je,where as $s,addDoc as Ht,serverTimestamp as qt}from"./vendor-firebase-firestore-CNv3xXal.js";import{U as He}from"./upload-Dezt40XU.js";import{D as ge}from"./LogoutActionButton-USB3vnm6.js";import{F as we,A as Me,I as Js,N as Vt}from"./NotificationDropdown-CMhB7x-Z.js";import{T as be}from"./trash-2-BCXZR1t7.js";import{S as Ls}from"./sparkles-DPFO64ZX.js";import{S as Us,D as Zs,a as et,b as st,c as tt,e as Wt}from"./dialog-C4ok-Axi.js";import{D as fs}from"./download-B80nBe--.js";import{S as gs}from"./shield-check-CS0qf70Z.js";import{S as at}from"./search-DqYX8akO.js";import{C as js}from"./clock-Dy5eVj9o.js";import{E as lt,a as Xt}from"./eye-BmZ1sFKD.js";import{C as rt}from"./chevron-left-DfHtS3Om.js";import{C as it}from"./chevron-right-DL17FiOB.js";import{C as Se}from"./circle-alert-DCyh_PVA.js";import{C as Qt,a as Kt}from"./vendor-radix-BPuEd8FG.js";import{C as Yt}from"./check-CAUeuCaw.js";import{M as Jt}from"./mail-DiIt1YFo.js";import{P as Is}from"./plus-BIEera7J.js";import{S as nt}from"./save-DxX0wJjA.js";import{C as Zt}from"./chart-column-DtQRo3DE.js";import{u as ea}from"./useQuery-C1X-hCq5.js";import{X as vs}from"./x-Ck4mo_h-.js";import{S as ds}from"./skeleton-BOUN1xTD.js";import{D as sa}from"./dollar-sign-CQIhGvzp.js";import{S as ta}from"./switch-CuAphvDQ.js";import{u as aa,t as la,a as ra}from"./useSubjectAvailability-D0TkEgbI.js";import{C as ia}from"./circle-help-BkKMcGF2.js";import{B as na}from"./bell-cxZiilDJ.js";import{R as xs,B as ca,C as oa,X as da,Y as xa,T as ma,a as Fs,A as pa,d as ha,P as ua,e as ga,b as Os}from"./vendor-charts-D7t7JfSr.js";import{C as ba}from"./circle-check-BjsGkfB1.js";import"./tooltip-Dz2m8mUv.js";import"./shirt-DP8IJVug.js";import"./log-out-BUfoSJF2.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-D9yeZehY.js";import"./formatDistanceToNow-JAG-bydR.js";/** +import{j as e,r as l,d as ps}from"./vendor-react-B4AQeu28.js";import{C as Vs,S as Ds}from"./Sidebar-DjsHKc7l.js";import Ws from"./ConfirmModal-Bjb3K2ht.js";import{e as fe,n as Ae,g as q,l as ke,j as w,h as Et,m as se,p as B,R as Ce,N as zt,r as hs,O as Dt,P as Pt,o as Xs,u as Ze,L as Qs,S as us,x as Ks,v as ye,U as Pe,G as Ye,i as Rt,Q as Ps,V as Rs,W as Ts,q as Tt,A as Ms,Z as Re,X as Mt,B as $t,T as Ys,b as Ue,F as Lt,Y as Ut,$ as It,D as Ft,M as Ot,J as _t}from"./index-CGNBpSmO.js";import{B as S}from"./button-DVjn4LkC.js";import{S as Y,a as J,b as ze,c as Z,d as k}from"./select-3FfJraPy.js";import{I as ie}from"./input-CBi6xF4I.js";import{S as Qe}from"./subjects-DP2R71lN.js";import{getDocs as ee,query as Te,collection as Q,orderBy as Ie,deleteDoc as Bt,doc as Gt,limit as Je,where as $s,addDoc as Ht,serverTimestamp as qt}from"./vendor-firebase-firestore-CNv3xXal.js";import{U as He}from"./upload-Daz-vKaw.js";import{D as ge}from"./LogoutActionButton-ynXvSPMf.js";import{F as we,A as Me,I as Js,N as Vt}from"./NotificationDropdown-DGCnp7MU.js";import{T as be}from"./trash-2-BhQyV3WQ.js";import{S as Ls}from"./sparkles-C0ju-UTT.js";import{S as Us,D as Zs,a as et,b as st,c as tt,e as Wt}from"./dialog-DDOyFRnI.js";import{D as fs}from"./download-Dg4u7Zq0.js";import{S as gs}from"./shield-check-h8afT4cG.js";import{S as at}from"./search-C_DiQDej.js";import{C as js}from"./clock-D2bky9WI.js";import{E as lt,a as Xt}from"./eye-_x45syMF.js";import{C as rt}from"./chevron-left-BuATOj9f.js";import{C as it}from"./chevron-right-C39hNstc.js";import{C as Se}from"./circle-alert-fZn6_hMx.js";import{C as Qt,a as Kt}from"./vendor-radix-BPuEd8FG.js";import{C as Yt}from"./check-BfYhdun3.js";import{M as Jt}from"./mail-C1tKDR_N.js";import{P as Is}from"./plus-ck_SGnHK.js";import{S as nt}from"./save-CNayyZ15.js";import{C as Zt}from"./chart-column-g5DztEPT.js";import{u as ea}from"./useQuery-C7Nbsm2w.js";import{X as vs}from"./x-Deb9zs8O.js";import{S as ds}from"./skeleton-C6ieN9wR.js";import{D as sa}from"./dollar-sign-CZpwYJk-.js";import{S as ta}from"./switch-bpTyEA6p.js";import{u as aa,t as la,a as ra}from"./useSubjectAvailability-iyC7Wdl7.js";import{C as ia}from"./circle-help-DMiD6EQw.js";import{B as na}from"./bell-DbwiSyKd.js";import{R as xs,B as ca,C as oa,X as da,Y as xa,T as ma,a as Fs,A as pa,d as ha,P as ua,e as ga,b as Os}from"./vendor-charts-D7t7JfSr.js";import{C as ba}from"./circle-check-BhLH88x1.js";import"./tooltip-A8-ihp1Q.js";import"./shirt-T-KPAkDY.js";import"./log-out-G6mObnLf.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-B59xV3SY.js";import"./formatDistanceToNow-Csp8CCDy.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/AssessmentPage-D95xz_DH.js b/assets/AssessmentPage-D5fw57-T.js similarity index 96% rename from assets/AssessmentPage-D95xz_DH.js rename to assets/AssessmentPage-D5fw57-T.js index 0508af8926f0e8b8918af6f5f0636d7a28af427c..c0b74d073819363169e2433129b3696a1b854a03 100644 --- a/assets/AssessmentPage-D95xz_DH.js +++ b/assets/AssessmentPage-D5fw57-T.js @@ -1,4 +1,4 @@ -import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as Q}from"./button-WbM5w2Bp.js";import{s as Y}from"./diagnosticService-ukrfKIf7.js";import{e as J,m as i,Z as O,h as U,T as Z,E as G,q as H}from"./index-dPnhhJ9w.js";import{M as W}from"./maximize-2-DZunkZ7R.js";import{X}from"./x-Ck4mo_h-.js";import{C as K}from"./clock-Dy5eVj9o.js";import{C as V}from"./circle-check-big-DJBKLvuw.js";import{C as ee}from"./chevron-right-DL17FiOB.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as Q}from"./button-DVjn4LkC.js";import{s as Y}from"./diagnosticService-DLw8ENQS.js";import{e as J,m as i,Z as O,h as U,T as Z,E as G,q as H}from"./index-CGNBpSmO.js";import{M as W}from"./maximize-2-CwlOKVNo.js";import{X}from"./x-Deb9zs8O.js";import{C as K}from"./clock-D2bky9WI.js";import{C as V}from"./circle-check-big-yCNC9yfs.js";import{C as ee}from"./chevron-right-C39hNstc.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.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-DVBimCS2.js b/assets/AvatarShop-CiTbxvY9.js similarity index 97% rename from assets/AvatarShop-DVBimCS2.js rename to assets/AvatarShop-CiTbxvY9.js index 0f8389a8e1cd32e7e7345dcc15872b98d692fee5..6f9f6013333053fe8059e391e4357972527e474c 100644 --- a/assets/AvatarShop-DVBimCS2.js +++ b/assets/AvatarShop-CiTbxvY9.js @@ -1,4 +1,4 @@ -import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{e as se,L as ae,g as re,f as oe}from"./vendor-radix-BPuEd8FG.js";import{e as S,u as le,L as w,a4 as R,m as y,h as ie,j as c,aM as ne,aN as ce}from"./index-dPnhhJ9w.js";import{u as de}from"./useFeatureAccess-Bk0jlnA0.js";import{T as me,a as ue,b as xe}from"./tooltip-Dz2m8mUv.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-DxX0wJjA.js";import{S as V}from"./sparkles-DPFO64ZX.js";import{S as fe}from"./shirt-DP8IJVug.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{e as se,L as ae,g as re,f as oe}from"./vendor-radix-BPuEd8FG.js";import{e as S,u as le,L as w,a4 as R,m as y,h as ie,j as c,aM as ne,aN as ce}from"./index-CGNBpSmO.js";import{u as de}from"./useFeatureAccess-BUoKpUf3.js";import{T as me,a as ue,b as xe}from"./tooltip-A8-ihp1Q.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-CNayyZ15.js";import{S as V}from"./sparkles-C0ju-UTT.js";import{S as fe}from"./shirt-T-KPAkDY.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-charts-D7t7JfSr.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-3H5bHtZy.js b/assets/ChatMarkdown-BAxWaDZo.js similarity index 97% rename from assets/ChatMarkdown-3H5bHtZy.js rename to assets/ChatMarkdown-BAxWaDZo.js index ab7ceaf77159fc58b886f2c684fd68973d48278d..295deeeb6c370b716738588bedaf58e51bbc7358 100644 --- a/assets/ChatMarkdown-3H5bHtZy.js +++ b/assets/ChatMarkdown-BAxWaDZo.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{b4 as d,_ as c}from"./index-dPnhhJ9w.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-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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}; +import{b4 as d,_ as c}from"./index-CGNBpSmO.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-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-c4f5tOE1.js b/assets/CompetencyRadarChart-CnxqIqQb.js similarity index 97% rename from assets/CompetencyRadarChart-c4f5tOE1.js rename to assets/CompetencyRadarChart-CnxqIqQb.js index bcabbcb459010e9bdb13d3e7cc2581c654345cbc..747f3053759243334b0b3cc70c38be8fc3d0ed5e 100644 --- a/assets/CompetencyRadarChart-c4f5tOE1.js +++ b/assets/CompetencyRadarChart-CnxqIqQb.js @@ -1 +1 @@ -import{r as g,j as t}from"./vendor-react-B4AQeu28.js";import{g as A,ab as I,u as B,m as L,B as O,R as W,a as H}from"./index-dPnhhJ9w.js";import{collection as R,getDocs as q,query as K,orderBy as U,limit as $,Timestamp as G,getDoc as J,doc as V}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as X,s as Y}from"./subjects-DzQfiusb.js";import{S as Z}from"./sparkles-DPFO64ZX.js";import{R as ee,g as te,h as se,i as ne,j as ae,k as oe,T as re}from"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-DtQRo3DE.js";const P=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];async function ie(a){try{const r=R(A,"users",a,"quizResults"),d=K(r,U("timestamp","desc"),$(500)),l=await q(d);return l.empty?F(a):l.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 J(V(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 ce(a){try{const r=R(A,"users",a,"moduleProgress"),d=await q(r);if(d.empty)return{};const l={};return d.forEach(s=>{const e=s.data();l[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||[]}}),l}catch(r){return console.error("[competencyService] fetchModuleProgress failed:",r),{}}}function _(a,r,d,l){const s=r.filter(p=>p.moduleId===a),e=s.length>0?s.reduce((p,b)=>p+b.score,0)/s.length:0,h=["identification","multiple_choice"],u=s.filter(p=>h.includes(p.questionType)),i=u.length>0?u.reduce((p,b)=>p+b.score,0)/u.length:e*.9,o=["word_problem","equation_based","enumeration"],n=s.filter(p=>o.includes(p.questionType)),c=n.length>0?n.reduce((p,b)=>p+b.score,0)/n.length:e*.85,m=d,f=m?.lessonsCompleted?.length||0,N=m?.quizzesCompleted?.length||0,D=m?.sessionsCompleted||0,y=l.find(p=>p.id===a),x=y?.lessons?.length||1,k=y?.quizzes?.length||1,z=Math.min(100,f/x*100),C=Math.min(100,N/k*100),v=Math.min(100,(z+C+D*5)/2.5);if(s.length<2){const p=v>50?60+v*.3:v*.8;return{overallMastery:e,conceptGrasp:i,application:c,engagement:v,consistency:Math.min(100,p)}}const w=s.map(p=>p.score),M=w.reduce((p,b)=>p+b,0)/w.length,E=w.reduce((p,b)=>p+Math.pow(b-M,2),0)/w.length,j=Math.sqrt(E)/Math.max(M,1),S=Math.max(0,Math.min(100,(1-j)*100));return{overallMastery:Math.round(e),conceptGrasp:Math.round(i),application:Math.round(c),engagement:Math.round(v),consistency:Math.round(S)}}async function le(a){try{const r=R(A,"users",a,"competencyMatrix"),d=await q(r);if(d.empty)return{};const l={};return d.forEach(s=>{const e=s.data();l[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}}),l}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 de(a){const[r,d]=g.useState([]),[l,s]=g.useState([]),[e,h]=g.useState("N/A"),[u,i]=g.useState(!0),[o,n]=g.useState(null),[c,m]=g.useState(!1),f=g.useRef(0),N=g.useCallback(async(y,x)=>{if(x!==f.current)return;const z=X(null)[0]??"gen-math",C=Y.find(j=>j.id===z)?.modules||[],v=C.map((j,S)=>({id:j.id,name:j.title.length>15?j.title.substring(0,15).trim()+"...":j.title,color:P[S%P.length]})),w=await le(a);if(x!==f.current)return;if(Object.keys(w).length>0){ue(w,v,d,h),m(!1),i(!1);return}const M=await ie(a),E=await ce(a);if(x!==f.current)return;const T=M.length>0;m(!T),pe(M,E,v,C,d,h),i(!1)},[a]),D=g.useCallback(async()=>{if(!a){i(!1);return}const y=++f.current;i(!0),n(null);try{const x=await new Promise(k=>{const z=I(a,C=>{z(),k(C)})});if(y!==f.current)return;await N(x,y)}catch(x){console.error("[useCompetencyMatrix] Failed to load:",x),y===f.current&&(n("Failed to load competency data. Please try again."),i(!1))}},[a,N]);return g.useEffect(()=>{if(!a)return;const y=I(a,x=>{const k=++f.current;N(x,k)});return()=>y()},[a,N]),{data:r,modulesList:l,topModule:e,loading:u,error:o,isEmpty:c,refresh:D}}function ue(a,r,d,l){let s=-1,e="N/A";const h=Q.map(u=>{const i={metric:u.label,fullMark:100};return r.forEach(o=>{const n=a[o.id];n&&(u.key==="progress"?i[o.id]=n.overallMastery:u.key==="concept"?i[o.id]=n.conceptGrasp:u.key==="application"?i[o.id]=n.application:u.key==="engagement"?i[o.id]=n.engagement:u.key==="consistency"&&(i[o.id]=n.consistency))}),i});r.forEach(u=>{const i=a[u.id];if(i){const o=(i.overallMastery+i.conceptGrasp+i.application+i.engagement+i.consistency)/5;o>s&&(s=o,e=u.name)}}),l(e),d(h)}function pe(a,r,d,l,s,e){let h=-1,u="N/A";const i=Q.map(o=>{const n={metric:o.label,fullMark:100};return l.forEach(c=>{const m=r[c.id],f=_(c.id,a,m??{moduleId:c.id,sessionsCompleted:0,moduleTitle:c.title,lessonsCompleted:[],quizzesCompleted:[]},l);o.key==="progress"?n[c.id]=f.overallMastery:o.key==="concept"?n[c.id]=f.conceptGrasp:o.key==="application"?n[c.id]=f.application:o.key==="engagement"?n[c.id]=f.engagement:o.key==="consistency"&&(n[c.id]=f.consistency)}),n});l.forEach(o=>{const n=r[o.id],c=_(o.id,a,n??{moduleId:o.id,sessionsCompleted:0,moduleTitle:o.title,lessonsCompleted:[],quizzesCompleted:[]},l),m=(c.overallMastery+c.conceptGrasp+c.application+c.engagement+c.consistency)/5;m>h&&(h=m,u=d.find(f=>f.id===o.id)?.name||"N/A")}),e(u),s(i)}const ze=()=>{const{userProfile:a}=B(),{data:r,modulesList:d,topModule:l,loading:s,error:e,isEmpty:h,refresh:u}=de(a?.uid??""),[i,o]=g.useState(!1);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 rounded-[16px] border border-slate-200 shadow-sm p-6 lg:p-8 group",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[t.jsx("div",{className:"absolute -right-12 -bottom-12 w-32 h-32 bg-[#9956DE]/5 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between mb-6 relative z-10 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-[12px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center shadow-[0_4px_12px_rgba(168,85,247,0.2)]",children:t.jsx(O,{size:20,className:"text-white"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-[15px] font-bold text-slate-900",children:"Competency Matrix"}),t.jsx("p",{className:"text-[12px] text-slate-500",children:"Realtime performance across modules"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!s&&!h&&!e&&t.jsxs("div",{className:"flex items-center gap-2 bg-[#f5f3ff] border border-[#e0e7ff] px-3 py-1.5 rounded-full",children:[t.jsx(Z,{size:12,className:"text-amber-500"}),t.jsx("span",{className:"text-[11px] font-bold text-[#9956DE] uppercase tracking-wider",children:l})]}),!s&&t.jsx("button",{onClick:u,className:"w-8 h-8 rounded-full bg-white border border-slate-200 flex items-center justify-center hover:bg-[#f5f3ff] hover:border-[#9956DE]/30 transition-colors shadow-sm",title:"Refresh",children:t.jsx(W,{size:13,className:"text-slate-400"})})]})]}),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-[#9956DE]/20 border-t-[#9956DE] rounded-full animate-spin"}),t.jsx("p",{className:"text-[13px] 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-14 h-14 rounded-[16px] bg-gradient-to-br from-slate-100 to-slate-50 flex items-center justify-center border border-slate-200",children:t.jsx(H,{size:24,className:"text-slate-400"})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-[13px] font-semibold text-slate-600 mb-1",children:e?"Unable to load competency data":"No activity yet"}),t.jsx("p",{className:"text-[12px] text-slate-400 max-w-[260px]",children:e||"Complete quizzes and lessons to see your competency matrix here."})]}),e&&t.jsx("button",{onClick:u,className:"px-4 py-2 text-[12px] font-semibold bg-[#9956DE] text-white rounded-full hover:bg-[#8b45d1] transition-colors shadow-md",children:"Try Again"})]}):t.jsx(ee,{width:"100%",height:"100%",children:t.jsxs(te,{cx:"50%",cy:"50%",outerRadius:i?"75%":"70%",data:r,children:[t.jsx(se,{stroke:"#e2e8f0",strokeDasharray:"4 4",polarRadius:[20,40,60,80,100]}),t.jsx(ne,{dataKey:"metric",tick:{fill:"#475569",fontSize:12,fontWeight:600}}),t.jsx(ae,{angle:90,domain:[0,100],tick:{fill:"#94a3b8",fontSize:10},tickCount:6,axisLine:!1}),d.map(n=>t.jsx(oe,{name:n.name,dataKey:n.id,stroke:n.color,strokeWidth:2,fill:n.color,fillOpacity:.3,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(re,{cursor:!1,content:({active:n,payload:c})=>n&&c&&c.length?t.jsxs("div",{className:"bg-white/95 backdrop-blur-[12px] shadow-[0_8px_24px_rgba(0,0,0,0.12)] border border-slate-100 rounded-[12px] p-4",children:[t.jsx("p",{className:"font-bold text-slate-800 text-[13px] mb-2",children:c[0].payload.metric}),t.jsx("div",{className:"flex flex-col gap-1.5",children:c.map(m=>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:m.stroke}}),t.jsx("span",{className:"text-[11px] font-semibold text-slate-600 truncate max-w-[120px]",children:String(m.name)})]}),t.jsxs("span",{className:"text-[13px] font-bold",style:{color:m.stroke},children:[Math.round(m.value),"%"]})]},m.name))})]}):null})]})})}),!s&&!h&&!e&&d.length>0&&t.jsx("div",{className:"flex flex-wrap justify-center items-center gap-3 mt-4 relative z-10",children:d.map(n=>t.jsxs("div",{className:"flex items-center gap-1.5 bg-slate-50 px-2.5 py-1 rounded-full border border-slate-100",children:[t.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.color}}),t.jsx("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-wider",children:n.name.length>15?n.name.substring(0,12)+"...":n.name})]},n.id))})]})};export{ze as CompetencyRadarChart}; +import{r as g,j as t}from"./vendor-react-B4AQeu28.js";import{g as A,ab as I,u as B,m as L,B as O,R as W,b as H}from"./index-CGNBpSmO.js";import{collection as R,getDocs as q,query as K,orderBy as U,limit as $,Timestamp as G,getDoc as J,doc as V}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as X,s as Y}from"./subjects-DP2R71lN.js";import{S as Z}from"./sparkles-C0ju-UTT.js";import{R as ee,g as te,h as se,i as ne,j as ae,k as oe,T as re}from"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-g5DztEPT.js";const P=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];async function ie(a){try{const r=R(A,"users",a,"quizResults"),d=K(r,U("timestamp","desc"),$(500)),l=await q(d);return l.empty?F(a):l.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 J(V(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 ce(a){try{const r=R(A,"users",a,"moduleProgress"),d=await q(r);if(d.empty)return{};const l={};return d.forEach(s=>{const e=s.data();l[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||[]}}),l}catch(r){return console.error("[competencyService] fetchModuleProgress failed:",r),{}}}function _(a,r,d,l){const s=r.filter(p=>p.moduleId===a),e=s.length>0?s.reduce((p,b)=>p+b.score,0)/s.length:0,h=["identification","multiple_choice"],u=s.filter(p=>h.includes(p.questionType)),i=u.length>0?u.reduce((p,b)=>p+b.score,0)/u.length:e*.9,o=["word_problem","equation_based","enumeration"],n=s.filter(p=>o.includes(p.questionType)),c=n.length>0?n.reduce((p,b)=>p+b.score,0)/n.length:e*.85,m=d,f=m?.lessonsCompleted?.length||0,N=m?.quizzesCompleted?.length||0,D=m?.sessionsCompleted||0,y=l.find(p=>p.id===a),x=y?.lessons?.length||1,k=y?.quizzes?.length||1,z=Math.min(100,f/x*100),C=Math.min(100,N/k*100),v=Math.min(100,(z+C+D*5)/2.5);if(s.length<2){const p=v>50?60+v*.3:v*.8;return{overallMastery:e,conceptGrasp:i,application:c,engagement:v,consistency:Math.min(100,p)}}const w=s.map(p=>p.score),M=w.reduce((p,b)=>p+b,0)/w.length,E=w.reduce((p,b)=>p+Math.pow(b-M,2),0)/w.length,j=Math.sqrt(E)/Math.max(M,1),S=Math.max(0,Math.min(100,(1-j)*100));return{overallMastery:Math.round(e),conceptGrasp:Math.round(i),application:Math.round(c),engagement:Math.round(v),consistency:Math.round(S)}}async function le(a){try{const r=R(A,"users",a,"competencyMatrix"),d=await q(r);if(d.empty)return{};const l={};return d.forEach(s=>{const e=s.data();l[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}}),l}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 de(a){const[r,d]=g.useState([]),[l,s]=g.useState([]),[e,h]=g.useState("N/A"),[u,i]=g.useState(!0),[o,n]=g.useState(null),[c,m]=g.useState(!1),f=g.useRef(0),N=g.useCallback(async(y,x)=>{if(x!==f.current)return;const z=X(null)[0]??"gen-math",C=Y.find(j=>j.id===z)?.modules||[],v=C.map((j,S)=>({id:j.id,name:j.title.length>15?j.title.substring(0,15).trim()+"...":j.title,color:P[S%P.length]})),w=await le(a);if(x!==f.current)return;if(Object.keys(w).length>0){ue(w,v,d,h),m(!1),i(!1);return}const M=await ie(a),E=await ce(a);if(x!==f.current)return;const T=M.length>0;m(!T),pe(M,E,v,C,d,h),i(!1)},[a]),D=g.useCallback(async()=>{if(!a){i(!1);return}const y=++f.current;i(!0),n(null);try{const x=await new Promise(k=>{const z=I(a,C=>{z(),k(C)})});if(y!==f.current)return;await N(x,y)}catch(x){console.error("[useCompetencyMatrix] Failed to load:",x),y===f.current&&(n("Failed to load competency data. Please try again."),i(!1))}},[a,N]);return g.useEffect(()=>{if(!a)return;const y=I(a,x=>{const k=++f.current;N(x,k)});return()=>y()},[a,N]),{data:r,modulesList:l,topModule:e,loading:u,error:o,isEmpty:c,refresh:D}}function ue(a,r,d,l){let s=-1,e="N/A";const h=Q.map(u=>{const i={metric:u.label,fullMark:100};return r.forEach(o=>{const n=a[o.id];n&&(u.key==="progress"?i[o.id]=n.overallMastery:u.key==="concept"?i[o.id]=n.conceptGrasp:u.key==="application"?i[o.id]=n.application:u.key==="engagement"?i[o.id]=n.engagement:u.key==="consistency"&&(i[o.id]=n.consistency))}),i});r.forEach(u=>{const i=a[u.id];if(i){const o=(i.overallMastery+i.conceptGrasp+i.application+i.engagement+i.consistency)/5;o>s&&(s=o,e=u.name)}}),l(e),d(h)}function pe(a,r,d,l,s,e){let h=-1,u="N/A";const i=Q.map(o=>{const n={metric:o.label,fullMark:100};return l.forEach(c=>{const m=r[c.id],f=_(c.id,a,m??{moduleId:c.id,sessionsCompleted:0,moduleTitle:c.title,lessonsCompleted:[],quizzesCompleted:[]},l);o.key==="progress"?n[c.id]=f.overallMastery:o.key==="concept"?n[c.id]=f.conceptGrasp:o.key==="application"?n[c.id]=f.application:o.key==="engagement"?n[c.id]=f.engagement:o.key==="consistency"&&(n[c.id]=f.consistency)}),n});l.forEach(o=>{const n=r[o.id],c=_(o.id,a,n??{moduleId:o.id,sessionsCompleted:0,moduleTitle:o.title,lessonsCompleted:[],quizzesCompleted:[]},l),m=(c.overallMastery+c.conceptGrasp+c.application+c.engagement+c.consistency)/5;m>h&&(h=m,u=d.find(f=>f.id===o.id)?.name||"N/A")}),e(u),s(i)}const ze=()=>{const{userProfile:a}=B(),{data:r,modulesList:d,topModule:l,loading:s,error:e,isEmpty:h,refresh:u}=de(a?.uid??""),[i,o]=g.useState(!1);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 rounded-[16px] border border-slate-200 shadow-sm p-6 lg:p-8 group",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[t.jsx("div",{className:"absolute -right-12 -bottom-12 w-32 h-32 bg-[#9956DE]/5 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between mb-6 relative z-10 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-[12px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center shadow-[0_4px_12px_rgba(168,85,247,0.2)]",children:t.jsx(O,{size:20,className:"text-white"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-[15px] font-bold text-slate-900",children:"Competency Matrix"}),t.jsx("p",{className:"text-[12px] text-slate-500",children:"Realtime performance across modules"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!s&&!h&&!e&&t.jsxs("div",{className:"flex items-center gap-2 bg-[#f5f3ff] border border-[#e0e7ff] px-3 py-1.5 rounded-full",children:[t.jsx(Z,{size:12,className:"text-amber-500"}),t.jsx("span",{className:"text-[11px] font-bold text-[#9956DE] uppercase tracking-wider",children:l})]}),!s&&t.jsx("button",{onClick:u,className:"w-8 h-8 rounded-full bg-white border border-slate-200 flex items-center justify-center hover:bg-[#f5f3ff] hover:border-[#9956DE]/30 transition-colors shadow-sm",title:"Refresh",children:t.jsx(W,{size:13,className:"text-slate-400"})})]})]}),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-[#9956DE]/20 border-t-[#9956DE] rounded-full animate-spin"}),t.jsx("p",{className:"text-[13px] 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-14 h-14 rounded-[16px] bg-gradient-to-br from-slate-100 to-slate-50 flex items-center justify-center border border-slate-200",children:t.jsx(H,{size:24,className:"text-slate-400"})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-[13px] font-semibold text-slate-600 mb-1",children:e?"Unable to load competency data":"No activity yet"}),t.jsx("p",{className:"text-[12px] text-slate-400 max-w-[260px]",children:e||"Complete quizzes and lessons to see your competency matrix here."})]}),e&&t.jsx("button",{onClick:u,className:"px-4 py-2 text-[12px] font-semibold bg-[#9956DE] text-white rounded-full hover:bg-[#8b45d1] transition-colors shadow-md",children:"Try Again"})]}):t.jsx(ee,{width:"100%",height:"100%",children:t.jsxs(te,{cx:"50%",cy:"50%",outerRadius:i?"75%":"70%",data:r,children:[t.jsx(se,{stroke:"#e2e8f0",strokeDasharray:"4 4",polarRadius:[20,40,60,80,100]}),t.jsx(ne,{dataKey:"metric",tick:{fill:"#475569",fontSize:12,fontWeight:600}}),t.jsx(ae,{angle:90,domain:[0,100],tick:{fill:"#94a3b8",fontSize:10},tickCount:6,axisLine:!1}),d.map(n=>t.jsx(oe,{name:n.name,dataKey:n.id,stroke:n.color,strokeWidth:2,fill:n.color,fillOpacity:.3,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(re,{cursor:!1,content:({active:n,payload:c})=>n&&c&&c.length?t.jsxs("div",{className:"bg-white/95 backdrop-blur-[12px] shadow-[0_8px_24px_rgba(0,0,0,0.12)] border border-slate-100 rounded-[12px] p-4",children:[t.jsx("p",{className:"font-bold text-slate-800 text-[13px] mb-2",children:c[0].payload.metric}),t.jsx("div",{className:"flex flex-col gap-1.5",children:c.map(m=>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:m.stroke}}),t.jsx("span",{className:"text-[11px] font-semibold text-slate-600 truncate max-w-[120px]",children:String(m.name)})]}),t.jsxs("span",{className:"text-[13px] font-bold",style:{color:m.stroke},children:[Math.round(m.value),"%"]})]},m.name))})]}):null})]})})}),!s&&!h&&!e&&d.length>0&&t.jsx("div",{className:"flex flex-wrap justify-center items-center gap-3 mt-4 relative z-10",children:d.map(n=>t.jsxs("div",{className:"flex items-center gap-1.5 bg-slate-50 px-2.5 py-1 rounded-full border border-slate-100",children:[t.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.color}}),t.jsx("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-wider",children:n.name.length>15?n.name.substring(0,12)+"...":n.name})]},n.id))})]})};export{ze as CompetencyRadarChart}; diff --git a/assets/ConfirmModal-CtRcSVjb.js b/assets/ConfirmModal-Bjb3K2ht.js similarity index 91% rename from assets/ConfirmModal-CtRcSVjb.js rename to assets/ConfirmModal-Bjb3K2ht.js index 04fed9ff24c2349548271b9f3bb9f2117281c459..09cf6c70a742ff5f0715e182ca268f6b4c575b9f 100644 --- a/assets/ConfirmModal-CtRcSVjb.js +++ b/assets/ConfirmModal-Bjb3K2ht.js @@ -1 +1 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{B as i}from"./button-WbM5w2Bp.js";import{h as u,m as r,x as f}from"./index-dPnhhJ9w.js";import{X as y}from"./x-Ck4mo_h-.js";import{T as j}from"./trash-2-BCXZR1t7.js";import{L as w}from"./log-out-BUfoSJF2.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.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:x="warning",icon:m="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(m){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(j,{size:32});case"warning":default:return e.jsx(f,{size:32})}},o=(()=>{switch(x){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(u,{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:h=>h.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(y,{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-DVjn4LkC.js";import{h as u,m as r,x as f}from"./index-CGNBpSmO.js";import{X as y}from"./x-Deb9zs8O.js";import{T as j}from"./trash-2-BhQyV3WQ.js";import{L as w}from"./log-out-G6mObnLf.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.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:x="warning",icon:m="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(m){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(j,{size:32});case"warning":default:return e.jsx(f,{size:32})}},o=(()=>{switch(x){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(u,{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:h=>h.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(y,{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/DiagnosticBreakdown-Beq-2PZi.js b/assets/DiagnosticBreakdown--QQ0WiYU.js similarity index 97% rename from assets/DiagnosticBreakdown-Beq-2PZi.js rename to assets/DiagnosticBreakdown--QQ0WiYU.js index 1e75249b6d73273c1f87ca5804455fcdb6f5f9d2..1518cdb236cf37f6a639ac24c3ab0c42c46a2859 100644 --- a/assets/DiagnosticBreakdown-Beq-2PZi.js +++ b/assets/DiagnosticBreakdown--QQ0WiYU.js @@ -1 +1 @@ -import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as y,doc as _}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as k,v as Z,B as H,Z as J,x as C,T as W,q as S,m,h as Y}from"./index-dPnhhJ9w.js";import{X as G}from"./x-Ck4mo_h-.js";import{C as q}from"./clock-Dy5eVj9o.js";import{L as A,C as K}from"./lightbulb-RToQsqFn.js";import{C as T}from"./circle-check-BjsGkfB1.js";import{C as D}from"./chart-column-DtQRo3DE.js";import{a as O,C as V}from"./chevron-up-D9yeZehY.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const ge=({userId:d,mode:h,isOpen:c=!0,onClose:p})=>{const[o,P]=i.useState([]),[B,$]=i.useState({}),[r,R]=i.useState({}),[a,E]=i.useState(null),[L,x]=i.useState(!0),[Q,j]=i.useState(!0),[g,z]=i.useState(null);i.useEffect(()=>{!d||!c||M()},[d,c]);const M=async()=>{x(!0);try{const s=await y(_(k,"diagnosticResults",d));if(!s.exists()){x(!1);return}const t=s.data(),U=t.responses||[];$(t.domainScores||{}),R(t.riskProfile||{});const N=t.testId;let v={};if(N){const l=await y(_(k,"diagnosticSessions",N));if(l.exists()){const X=l.data();for(const w of X.questions||[])v[w.question_id]=w.question_text}}P(U.map(l=>({...l,question_text:v[l.question_id]}))),x(!1),j(!0);try{const l=await Z("/api/diagnostic/analyze",{method:"POST",body:JSON.stringify({user_id:d})});l.success&&E(l.analysis)}catch(l){console.error("[DiagnosticBreakdown] AI analysis failed:",l)}finally{j(!1)}}catch(s){console.error("[DiagnosticBreakdown] Failed to load data:",s),x(!1),j(!1)}},b=o.filter(s=>s.is_correct).length,n=o.length,u=o.reduce((s,t)=>s+t.time_spent_seconds,0),F=n>0?Math.round(u/n):0,I=n>0?Math.round(b/n*100):0;if(!c)return null;const f=e.jsxs("div",{className:`${h==="fullscreen"?"min-h-screen bg-gradient-to-br from-slate-50 via-white to-indigo-50/30":""} flex flex-col`,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white/80 backdrop-blur-xl border-b border-slate-200/60 px-6 py-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl flex items-center justify-center shadow-lg shadow-indigo-200",children:e.jsx(H,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-slate-900",children:"Diagnostic Assessment Breakdown"}),e.jsx("p",{className:"text-xs text-slate-500",children:"AI-powered analysis of your performance"})]})]}),e.jsx("button",{onClick:p,className:"p-2 hover:bg-slate-100 rounded-xl transition-colors",title:"Close",children:e.jsx(G,{className:"w-5 h-5 text-slate-500"})})]})}),e.jsx("div",{className:"max-w-6xl mx-auto w-full px-6 py-8 space-y-8",children:L?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"h-32 bg-slate-100 rounded-2xl animate-pulse"},s))}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-indigo-500 to-purple-600 rounded-2xl p-5 text-white shadow-lg shadow-indigo-200/50",children:[e.jsx("p",{className:"text-indigo-200 text-xs font-medium uppercase",children:"Score"}),e.jsxs("p",{className:"text-3xl font-black mt-1",children:[I,"%"]}),e.jsxs("p",{className:"text-indigo-200 text-sm",children:[b,"/",n," correct"]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(q,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Avg Time"})]}),e.jsxs("p",{className:"text-2xl font-bold text-slate-800",children:[F,"s"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"per question"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(J,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Total Time"})]}),e.jsxs("p",{className:"text-2xl font-bold text-slate-800",children:[Math.floor(u/60),"m ",u%60,"s"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"assessment duration"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(C,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Risk"})]}),e.jsx("p",{className:`text-2xl font-bold ${r.overall_risk==="high"||r.overall_risk==="critical"?"text-red-600":r.overall_risk==="moderate"?"text-amber-600":"text-emerald-600"}`,children:(r.overall_risk||"unknown").charAt(0).toUpperCase()+(r.overall_risk||"unknown").slice(1)}),e.jsx("p",{className:"text-xs text-slate-400",children:"risk level"})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100 bg-gradient-to-r from-amber-50 to-orange-50",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5 text-amber-500"}),e.jsx("h2",{className:"font-bold text-slate-800",children:"AI Analysis"})]})}),e.jsx("div",{className:"p-6",children:Q?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-3/4"}),e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-1/2"}),e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-5/6"})]}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-slate-700 leading-relaxed",children:a.overall_summary}),e.jsxs("div",{className:"bg-sky-50 border border-sky-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-sky-800 text-sm mb-2 flex items-center gap-2",children:[e.jsx(q,{className:"w-4 h-4"})," Timing Patterns"]}),e.jsx("p",{className:"text-sm text-sky-700",children:a.time_analysis.insight}),a.time_analysis.slow_questions.length>0&&e.jsxs("p",{className:"text-xs text-sky-600 mt-2",children:[e.jsx("span",{className:"font-medium",children:"Took longest on:"})," ",a.time_analysis.slow_questions.join(", ")]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.strength_areas.length>0&&e.jsxs("div",{className:"border border-emerald-100 bg-emerald-50/50 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-emerald-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4"})," Strengths"]}),e.jsx("ul",{className:"space-y-2",children:a.strength_areas.map((s,t)=>e.jsxs("li",{className:"text-sm text-emerald-700 flex items-start gap-2",children:[e.jsx(T,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.domain,":"]})," ",s.detail]})]},t))})]}),a.weakness_areas.length>0&&e.jsxs("div",{className:"border border-red-100 bg-red-50/50 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-red-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4"})," Weak Areas"]}),e.jsx("ul",{className:"space-y-2",children:a.weakness_areas.map((s,t)=>e.jsxs("li",{className:"text-sm text-red-700 flex items-start gap-2",children:[e.jsx(C,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.domain,":"]})," ",s.detail]})]},t))})]})]}),a.answer_patterns.common_mistakes.length>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-xl p-4",children:[e.jsx("h3",{className:"font-semibold text-amber-800 text-sm mb-2",children:"Answer Patterns"}),e.jsx("p",{className:"text-sm text-amber-700 mb-2",children:a.answer_patterns.description}),e.jsx("ul",{className:"space-y-1",children:a.answer_patterns.common_mistakes.map((s,t)=>e.jsxs("li",{className:"text-xs text-amber-600",children:["• ",s]},t))})]}),a.recommendations.length>0&&e.jsxs("div",{className:"bg-indigo-50 border border-indigo-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-indigo-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(A,{className:"w-4 h-4"})," Recommendations"]}),e.jsx("ol",{className:"space-y-2",children:a.recommendations.map((s,t)=>e.jsxs("li",{className:"text-sm text-indigo-700",children:[e.jsxs("span",{className:"font-medium",children:[t+1,". ",s.action]}),e.jsxs("span",{className:"text-indigo-500 text-xs ml-2",children:["— ",s.reason]})]},t))})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-slate-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4"})," Performance by Difficulty"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Easy"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.easy_performance})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Medium"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.medium_performance})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Hard"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.hard_performance})]})]})]})]}):e.jsx("p",{className:"text-slate-500 text-sm",children:"Analysis unavailable."})})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:e.jsxs("h2",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(D,{className:"w-5 h-5 text-indigo-500"})," Domain Scores"]})}),e.jsx("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(B).map(([s,t])=>e.jsxs("div",{className:"border border-slate-100 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-2",children:s}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("span",{className:"text-2xl font-black text-slate-800",children:[t.percentage,"%"]}),e.jsxs("span",{className:"text-xs text-slate-400 mb-1",children:[t.correct,"/",t.total]})]}),e.jsx("div",{className:"mt-2 h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${t.percentage>=80?"bg-emerald-500":t.percentage>=60?"bg-amber-500":"bg-red-500"}`,style:{width:`${t.percentage}%`}})}),e.jsx("p",{className:`text-xs mt-1 font-medium ${t.mastery_level==="mastered"?"text-emerald-600":t.mastery_level==="developing"?"text-amber-600":"text-red-600"}`,children:t.mastery_level})]},s))})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:e.jsxs("h2",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(S,{className:"w-5 h-5 text-indigo-500"})," Question-by-Question Breakdown"]})}),e.jsx("div",{className:"divide-y divide-slate-50",children:o.map((s,t)=>e.jsxs("div",{className:"px-6 py-3 hover:bg-slate-50/50 transition-colors",children:[e.jsxs("button",{onClick:()=>z(g===t?null:t),className:"w-full flex items-center gap-3 text-left",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${s.is_correct?"bg-emerald-100 text-emerald-600":"bg-red-100 text-red-600"}`,children:s.is_correct?e.jsx(T,{className:"w-4 h-4"}):e.jsx(K,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700 truncate",children:["Q",t+1,". ",s.question_text||`${s.topic} (${s.domain})`]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsx("span",{className:"text-xs text-slate-400",children:s.difficulty}),e.jsxs("span",{className:"text-xs text-slate-400",children:[s.time_spent_seconds,"s"]}),e.jsx("span",{className:"text-xs text-slate-400",children:s.domain})]})]}),g===t?e.jsx(O,{className:"w-4 h-4 text-slate-400"}):e.jsx(V,{className:"w-4 h-4 text-slate-400"})]}),g===t&&e.jsxs(m.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"ml-10 mt-2 pb-2 space-y-2",children:[s.question_text&&e.jsx("p",{className:"text-sm text-slate-600",children:s.question_text}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs",children:[e.jsxs("span",{className:s.is_correct?"text-emerald-600":"text-red-600",children:["Your answer: ",e.jsx("strong",{children:s.student_answer||"—"})]}),!s.is_correct&&e.jsxs("span",{className:"text-emerald-600",children:["Correct: ",e.jsx("strong",{children:s.correct_answer})]}),e.jsxs("span",{className:"text-slate-500",children:["Time: ",s.time_spent_seconds,"s"]}),e.jsxs("span",{className:"text-slate-500",children:["Bloom: ",s.bloom_level]})]})]})]},t))})]}),e.jsx("div",{className:"flex justify-center pb-8",children:e.jsx("button",{onClick:p,className:"px-8 py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl shadow-lg shadow-indigo-200 transition-all",children:h==="fullscreen"?"Continue to Dashboard":"Close"})})]})})]});return h==="modal"?e.jsx(Y,{children:c&&e.jsx(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:p,children:e.jsx(m.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white rounded-2xl shadow-2xl w-full max-w-5xl max-h-[90vh] overflow-y-auto",onClick:s=>s.stopPropagation(),children:f})})}):e.jsx(m.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-50 overflow-y-auto bg-gradient-to-br from-slate-50 via-white to-indigo-50/30",children:f})};export{ge as default}; +import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as y,doc as _}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as k,v as Z,B as H,Z as J,x as C,T as W,q as S,m,h as Y}from"./index-CGNBpSmO.js";import{X as G}from"./x-Deb9zs8O.js";import{C as q}from"./clock-D2bky9WI.js";import{L as A,C as K}from"./lightbulb-CrdekHc8.js";import{C as T}from"./circle-check-BhLH88x1.js";import{C as D}from"./chart-column-g5DztEPT.js";import{a as O,C as V}from"./chevron-up-B59xV3SY.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const ge=({userId:d,mode:h,isOpen:c=!0,onClose:p})=>{const[o,P]=i.useState([]),[B,$]=i.useState({}),[r,R]=i.useState({}),[a,E]=i.useState(null),[L,x]=i.useState(!0),[Q,j]=i.useState(!0),[g,z]=i.useState(null);i.useEffect(()=>{!d||!c||M()},[d,c]);const M=async()=>{x(!0);try{const s=await y(_(k,"diagnosticResults",d));if(!s.exists()){x(!1);return}const t=s.data(),U=t.responses||[];$(t.domainScores||{}),R(t.riskProfile||{});const N=t.testId;let v={};if(N){const l=await y(_(k,"diagnosticSessions",N));if(l.exists()){const X=l.data();for(const w of X.questions||[])v[w.question_id]=w.question_text}}P(U.map(l=>({...l,question_text:v[l.question_id]}))),x(!1),j(!0);try{const l=await Z("/api/diagnostic/analyze",{method:"POST",body:JSON.stringify({user_id:d})});l.success&&E(l.analysis)}catch(l){console.error("[DiagnosticBreakdown] AI analysis failed:",l)}finally{j(!1)}}catch(s){console.error("[DiagnosticBreakdown] Failed to load data:",s),x(!1),j(!1)}},b=o.filter(s=>s.is_correct).length,n=o.length,u=o.reduce((s,t)=>s+t.time_spent_seconds,0),F=n>0?Math.round(u/n):0,I=n>0?Math.round(b/n*100):0;if(!c)return null;const f=e.jsxs("div",{className:`${h==="fullscreen"?"min-h-screen bg-gradient-to-br from-slate-50 via-white to-indigo-50/30":""} flex flex-col`,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white/80 backdrop-blur-xl border-b border-slate-200/60 px-6 py-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl flex items-center justify-center shadow-lg shadow-indigo-200",children:e.jsx(H,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-slate-900",children:"Diagnostic Assessment Breakdown"}),e.jsx("p",{className:"text-xs text-slate-500",children:"AI-powered analysis of your performance"})]})]}),e.jsx("button",{onClick:p,className:"p-2 hover:bg-slate-100 rounded-xl transition-colors",title:"Close",children:e.jsx(G,{className:"w-5 h-5 text-slate-500"})})]})}),e.jsx("div",{className:"max-w-6xl mx-auto w-full px-6 py-8 space-y-8",children:L?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"h-32 bg-slate-100 rounded-2xl animate-pulse"},s))}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-indigo-500 to-purple-600 rounded-2xl p-5 text-white shadow-lg shadow-indigo-200/50",children:[e.jsx("p",{className:"text-indigo-200 text-xs font-medium uppercase",children:"Score"}),e.jsxs("p",{className:"text-3xl font-black mt-1",children:[I,"%"]}),e.jsxs("p",{className:"text-indigo-200 text-sm",children:[b,"/",n," correct"]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(q,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Avg Time"})]}),e.jsxs("p",{className:"text-2xl font-bold text-slate-800",children:[F,"s"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"per question"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(J,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Total Time"})]}),e.jsxs("p",{className:"text-2xl font-bold text-slate-800",children:[Math.floor(u/60),"m ",u%60,"s"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"assessment duration"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-500 mb-1",children:[e.jsx(C,{className:"w-4 h-4"})," ",e.jsx("span",{className:"text-xs font-medium uppercase",children:"Risk"})]}),e.jsx("p",{className:`text-2xl font-bold ${r.overall_risk==="high"||r.overall_risk==="critical"?"text-red-600":r.overall_risk==="moderate"?"text-amber-600":"text-emerald-600"}`,children:(r.overall_risk||"unknown").charAt(0).toUpperCase()+(r.overall_risk||"unknown").slice(1)}),e.jsx("p",{className:"text-xs text-slate-400",children:"risk level"})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100 bg-gradient-to-r from-amber-50 to-orange-50",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5 text-amber-500"}),e.jsx("h2",{className:"font-bold text-slate-800",children:"AI Analysis"})]})}),e.jsx("div",{className:"p-6",children:Q?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-3/4"}),e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-1/2"}),e.jsx("div",{className:"h-4 bg-slate-100 rounded animate-pulse w-5/6"})]}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-slate-700 leading-relaxed",children:a.overall_summary}),e.jsxs("div",{className:"bg-sky-50 border border-sky-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-sky-800 text-sm mb-2 flex items-center gap-2",children:[e.jsx(q,{className:"w-4 h-4"})," Timing Patterns"]}),e.jsx("p",{className:"text-sm text-sky-700",children:a.time_analysis.insight}),a.time_analysis.slow_questions.length>0&&e.jsxs("p",{className:"text-xs text-sky-600 mt-2",children:[e.jsx("span",{className:"font-medium",children:"Took longest on:"})," ",a.time_analysis.slow_questions.join(", ")]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.strength_areas.length>0&&e.jsxs("div",{className:"border border-emerald-100 bg-emerald-50/50 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-emerald-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4"})," Strengths"]}),e.jsx("ul",{className:"space-y-2",children:a.strength_areas.map((s,t)=>e.jsxs("li",{className:"text-sm text-emerald-700 flex items-start gap-2",children:[e.jsx(T,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.domain,":"]})," ",s.detail]})]},t))})]}),a.weakness_areas.length>0&&e.jsxs("div",{className:"border border-red-100 bg-red-50/50 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-red-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4"})," Weak Areas"]}),e.jsx("ul",{className:"space-y-2",children:a.weakness_areas.map((s,t)=>e.jsxs("li",{className:"text-sm text-red-700 flex items-start gap-2",children:[e.jsx(C,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.domain,":"]})," ",s.detail]})]},t))})]})]}),a.answer_patterns.common_mistakes.length>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-xl p-4",children:[e.jsx("h3",{className:"font-semibold text-amber-800 text-sm mb-2",children:"Answer Patterns"}),e.jsx("p",{className:"text-sm text-amber-700 mb-2",children:a.answer_patterns.description}),e.jsx("ul",{className:"space-y-1",children:a.answer_patterns.common_mistakes.map((s,t)=>e.jsxs("li",{className:"text-xs text-amber-600",children:["• ",s]},t))})]}),a.recommendations.length>0&&e.jsxs("div",{className:"bg-indigo-50 border border-indigo-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-indigo-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(A,{className:"w-4 h-4"})," Recommendations"]}),e.jsx("ol",{className:"space-y-2",children:a.recommendations.map((s,t)=>e.jsxs("li",{className:"text-sm text-indigo-700",children:[e.jsxs("span",{className:"font-medium",children:[t+1,". ",s.action]}),e.jsxs("span",{className:"text-indigo-500 text-xs ml-2",children:["— ",s.reason]})]},t))})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-100 rounded-xl p-4",children:[e.jsxs("h3",{className:"font-semibold text-slate-800 text-sm mb-3 flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4"})," Performance by Difficulty"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Easy"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.easy_performance})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Medium"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.medium_performance})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase font-medium",children:"Hard"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 mt-1",children:a.difficulty_analysis.hard_performance})]})]})]})]}):e.jsx("p",{className:"text-slate-500 text-sm",children:"Analysis unavailable."})})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:e.jsxs("h2",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(D,{className:"w-5 h-5 text-indigo-500"})," Domain Scores"]})}),e.jsx("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(B).map(([s,t])=>e.jsxs("div",{className:"border border-slate-100 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-2",children:s}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("span",{className:"text-2xl font-black text-slate-800",children:[t.percentage,"%"]}),e.jsxs("span",{className:"text-xs text-slate-400 mb-1",children:[t.correct,"/",t.total]})]}),e.jsx("div",{className:"mt-2 h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${t.percentage>=80?"bg-emerald-500":t.percentage>=60?"bg-amber-500":"bg-red-500"}`,style:{width:`${t.percentage}%`}})}),e.jsx("p",{className:`text-xs mt-1 font-medium ${t.mastery_level==="mastered"?"text-emerald-600":t.mastery_level==="developing"?"text-amber-600":"text-red-600"}`,children:t.mastery_level})]},s))})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:e.jsxs("h2",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(S,{className:"w-5 h-5 text-indigo-500"})," Question-by-Question Breakdown"]})}),e.jsx("div",{className:"divide-y divide-slate-50",children:o.map((s,t)=>e.jsxs("div",{className:"px-6 py-3 hover:bg-slate-50/50 transition-colors",children:[e.jsxs("button",{onClick:()=>z(g===t?null:t),className:"w-full flex items-center gap-3 text-left",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${s.is_correct?"bg-emerald-100 text-emerald-600":"bg-red-100 text-red-600"}`,children:s.is_correct?e.jsx(T,{className:"w-4 h-4"}):e.jsx(K,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700 truncate",children:["Q",t+1,". ",s.question_text||`${s.topic} (${s.domain})`]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsx("span",{className:"text-xs text-slate-400",children:s.difficulty}),e.jsxs("span",{className:"text-xs text-slate-400",children:[s.time_spent_seconds,"s"]}),e.jsx("span",{className:"text-xs text-slate-400",children:s.domain})]})]}),g===t?e.jsx(O,{className:"w-4 h-4 text-slate-400"}):e.jsx(V,{className:"w-4 h-4 text-slate-400"})]}),g===t&&e.jsxs(m.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"ml-10 mt-2 pb-2 space-y-2",children:[s.question_text&&e.jsx("p",{className:"text-sm text-slate-600",children:s.question_text}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs",children:[e.jsxs("span",{className:s.is_correct?"text-emerald-600":"text-red-600",children:["Your answer: ",e.jsx("strong",{children:s.student_answer||"—"})]}),!s.is_correct&&e.jsxs("span",{className:"text-emerald-600",children:["Correct: ",e.jsx("strong",{children:s.correct_answer})]}),e.jsxs("span",{className:"text-slate-500",children:["Time: ",s.time_spent_seconds,"s"]}),e.jsxs("span",{className:"text-slate-500",children:["Bloom: ",s.bloom_level]})]})]})]},t))})]}),e.jsx("div",{className:"flex justify-center pb-8",children:e.jsx("button",{onClick:p,className:"px-8 py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl shadow-lg shadow-indigo-200 transition-all",children:h==="fullscreen"?"Continue to Dashboard":"Close"})})]})})]});return h==="modal"?e.jsx(Y,{children:c&&e.jsx(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:p,children:e.jsx(m.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white rounded-2xl shadow-2xl w-full max-w-5xl max-h-[90vh] overflow-y-auto",onClick:s=>s.stopPropagation(),children:f})})}):e.jsx(m.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-50 overflow-y-auto bg-gradient-to-br from-slate-50 via-white to-indigo-50/30",children:f})};export{ge as default}; diff --git a/assets/FloatingAITutor-CSkan2Lo.js b/assets/FloatingAITutor-BkfkayUl.js similarity index 94% rename from assets/FloatingAITutor-CSkan2Lo.js rename to assets/FloatingAITutor-BkfkayUl.js index 0747d91feb8f7155e37589eaff926f4bcc5a290c..145dac8e19894d56c7e55cb267d8f32645925f04 100644 --- a/assets/FloatingAITutor-CSkan2Lo.js +++ b/assets/FloatingAITutor-BkfkayUl.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatMarkdown-3H5bHtZy.js","assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{aE as C,_ as y,m as b,I as A}from"./index-dPnhhJ9w.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-DZunkZ7R.js";import{M as w}from"./minus-BpJABcv4.js";import{X as g}from"./x-Ck4mo_h-.js";import{S as L}from"./send-C3s19g5N.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-3H5bHtZy.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-dPnhhJ9w.js").then(d=>d.b6);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-BAxWaDZo.js","assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{aE as C,_ as y,m as b,I as A}from"./index-CGNBpSmO.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-CwlOKVNo.js";import{M as w}from"./minus-DV5fnWn8.js";import{X as g}from"./x-Deb9zs8O.js";import{S as L}from"./send-DnRgK3MX.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-BAxWaDZo.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-CGNBpSmO.js").then(d=>d.b6);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-eugSRvtq.js b/assets/GradesPage-eBdPESCo.js similarity index 95% rename from assets/GradesPage-eugSRvtq.js rename to assets/GradesPage-eBdPESCo.js index 932360b855c12ab4a94c25fe150881ba1d44820b..b730a1b4ef1c64450ce576d293d1710b9063dd75 100644 --- a/assets/GradesPage-eugSRvtq.js +++ b/assets/GradesPage-eBdPESCo.js @@ -1,3 +1,3 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagnosticBreakdown-Beq-2PZi.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/index-dPnhhJ9w.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css","assets/x-Ck4mo_h-.js","assets/clock-Dy5eVj9o.js","assets/lightbulb-RToQsqFn.js","assets/circle-check-BjsGkfB1.js","assets/chart-column-DtQRo3DE.js","assets/chevron-up-D9yeZehY.js"])))=>i.map(i=>d[i]); -import{u as se,aF as te,aG as ae,g as P,F as re,A as le,q as M,T as $,B as ne,_ as oe}from"./index-dPnhhJ9w.js";import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as N}from"./button-WbM5w2Bp.js";import{g as ie,S as B}from"./subjects-DzQfiusb.js";import{u as de}from"./useCurriculum-BbSzWiM_.js";import{getDoc as F,doc as G}from"./vendor-firebase-firestore-CNv3xXal.js";import{D as ce}from"./download-B80nBe--.js";import{C as me}from"./circle-check-BjsGkfB1.js";import{C as xe}from"./circle-alert-DCyh_PVA.js";import{F as Q}from"./funnel-Bt7LE1rx.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-DtQRo3DE.js";const pe=r.lazy(()=>oe(()=>import("./DiagnosticBreakdown-Beq-2PZi.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),Ee=()=>{const{currentUser:l,userProfile:y}=se(),[d,S]=r.useState("all"),[x,O]=r.useState("all"),[I,h]=r.useState(!0),[b,U]=r.useState(null),[H,V]=r.useState([]),[n,k]=r.useState(null),[_,g]=r.useState(!1),A=y?.grade,C=ie(A),T=new Set(C),{isLoading:Y}=de(A);r.useEffect(()=>{},[Y]);const K=s=>{if(s==null)return"N/A";const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?"N/A":t.toISOString().split("T")[0]};r.useEffect(()=>{if(!l)return;h(!0);const s=te(l.uid,a=>{U(a),h(!1)}),t=ae(l.uid,a=>{V(a),h(!1)});return()=>{s(),t()}},[l]),r.useEffect(()=>{l?.uid&&(async()=>{try{const s=await F(G(P,"users",l.uid,"dashboardSummary","heroBannerModal"));if(s.exists()){const a=s.data();if(a.status==="ready"){k({score:a.latestScorePercent||0,riskLevel:a.latestRiskLevel||"Unknown",weaknesses:a.weaknesses||[],recommendation:a.recommendation||""});return}}const t=await F(G(P,"users",l.uid));if(t.exists()){const a=t.data();(a.initialAssessmentCompleted||a.hasCompletedInitialAssessment)&&k({score:0,riskLevel:a.atRiskSubjects?.length>0?"Moderate":"Low",weaknesses:a.atRiskSubjects||[],recommendation:"Continue with your personalized learning path."})}}catch{}})()},[l?.uid]);const f=b?.averageScore?Math.round(b.averageScore):0,J=b?.quizzesCompleted??0,W=f>0?(f/100*4).toFixed(2):"0.00",X={"gen-math":"indigo","stats-prob":"violet"},L={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"}},R=B.reduce((s,t)=>(s[t.id]={label:t.name,color:X[t.id]||"slate"},s),{}),c=B.filter(s=>T.has(s.id)).map(s=>s.name),E=Object.entries({}).filter(([s])=>T.has(s)).map(([s,t])=>{const a=R[s]||{label:s,color:"slate"},i=[],j=i.length>0?Math.round(i.reduce((w,u)=>w+u.score,0)/i.length):Math.round(t?.progress??0);return{subject:a.label,average:j,quizzes:i.length||t?.completedModules,color:a.color}}),Z=C.map(s=>{const t=R[s]||{label:s,color:"slate"};return{subject:t.label,average:0,quizzes:0,color:t.color}}),z=E.length>0?E:Z,D=H.slice().sort((s,t)=>{const a=s.completedAt?.toDate?.()?.getTime()??0;return(t.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((s,t)=>({id:t+1,title:s.title||`Assessment ${t+1}`,subject:s.subject||"General",score:s.score,date:s.completedAt?K(s.completedAt.toDate()):"N/A",type:s.type==="practice"?"practice":(s.type==="diagnostic","module"),status:s.score>=80?"Excellent":s.score>=60?"Passing":"Needs Review"})).filter(s=>c.includes(s.subject)),p=D.filter(s=>{if(!c.includes(s.subject))return!1;const t=d==="all"||s.subject===d,a=x==="all"||s.type===x;return t&&a});r.useEffect(()=>{d!=="all"&&(c.includes(d)||S("all"))},[c,d]);const q=()=>{const s=o=>{const v=String(o??"");return/[",\n]/.test(v)?`"${v.replace(/"/g,'""')}"`:v},t=[],a=y?.name||l?.displayName||l?.email||"Student",i=new Date().toISOString().split("T")[0];t.push("Grade Report"),t.push(`Student,${s(a)}`),t.push(`Export Date,${s(i)}`),t.push(`Subject Filter,${s(d)}`),t.push(`Type Filter,${s(x)}`),t.push(""),t.push("Subject Performance"),t.push("Subject,Average Score"),z.forEach(o=>{t.push([s(o.subject),s(o.average)].join(","))}),t.push(""),t.push("Recent Quizzes"),t.push("Title,Subject,Score,Date,Type,Status"),p.length===0?t.push("No quiz data available for the selected filters"):p.forEach(o=>{t.push([s(o.title),s(o.subject),s(o.score),s(o.date),s(o.type),s(o.status)].join(","))});const j=t.join(` +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagnosticBreakdown--QQ0WiYU.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/index-CGNBpSmO.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css","assets/x-Deb9zs8O.js","assets/clock-D2bky9WI.js","assets/lightbulb-CrdekHc8.js","assets/circle-check-BhLH88x1.js","assets/chart-column-g5DztEPT.js","assets/chevron-up-B59xV3SY.js"])))=>i.map(i=>d[i]); +import{u as se,aF as te,aG as ae,g as P,F as re,A as le,q as M,T as $,B as ne,_ as oe}from"./index-CGNBpSmO.js";import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as N}from"./button-DVjn4LkC.js";import{g as ie,S as B}from"./subjects-DP2R71lN.js";import{u as de}from"./useCurriculum-cH2ZLq43.js";import{getDoc as F,doc as G}from"./vendor-firebase-firestore-CNv3xXal.js";import{D as ce}from"./download-Dg4u7Zq0.js";import{C as me}from"./circle-check-BhLH88x1.js";import{C as xe}from"./circle-alert-fZn6_hMx.js";import{F as Q}from"./funnel-pOzgdLsf.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-g5DztEPT.js";const pe=r.lazy(()=>oe(()=>import("./DiagnosticBreakdown--QQ0WiYU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),Ee=()=>{const{currentUser:l,userProfile:y}=se(),[d,S]=r.useState("all"),[x,O]=r.useState("all"),[I,h]=r.useState(!0),[b,U]=r.useState(null),[H,V]=r.useState([]),[n,k]=r.useState(null),[_,g]=r.useState(!1),A=y?.grade,C=ie(A),T=new Set(C),{isLoading:Y}=de(A);r.useEffect(()=>{},[Y]);const K=s=>{if(s==null)return"N/A";const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?"N/A":t.toISOString().split("T")[0]};r.useEffect(()=>{if(!l)return;h(!0);const s=te(l.uid,a=>{U(a),h(!1)}),t=ae(l.uid,a=>{V(a),h(!1)});return()=>{s(),t()}},[l]),r.useEffect(()=>{l?.uid&&(async()=>{try{const s=await F(G(P,"users",l.uid,"dashboardSummary","heroBannerModal"));if(s.exists()){const a=s.data();if(a.status==="ready"){k({score:a.latestScorePercent||0,riskLevel:a.latestRiskLevel||"Unknown",weaknesses:a.weaknesses||[],recommendation:a.recommendation||""});return}}const t=await F(G(P,"users",l.uid));if(t.exists()){const a=t.data();(a.initialAssessmentCompleted||a.hasCompletedInitialAssessment)&&k({score:0,riskLevel:a.atRiskSubjects?.length>0?"Moderate":"Low",weaknesses:a.atRiskSubjects||[],recommendation:"Continue with your personalized learning path."})}}catch{}})()},[l?.uid]);const f=b?.averageScore?Math.round(b.averageScore):0,J=b?.quizzesCompleted??0,W=f>0?(f/100*4).toFixed(2):"0.00",X={"gen-math":"indigo","stats-prob":"violet"},L={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"}},R=B.reduce((s,t)=>(s[t.id]={label:t.name,color:X[t.id]||"slate"},s),{}),c=B.filter(s=>T.has(s.id)).map(s=>s.name),E=Object.entries({}).filter(([s])=>T.has(s)).map(([s,t])=>{const a=R[s]||{label:s,color:"slate"},i=[],j=i.length>0?Math.round(i.reduce((w,u)=>w+u.score,0)/i.length):Math.round(t?.progress??0);return{subject:a.label,average:j,quizzes:i.length||t?.completedModules,color:a.color}}),Z=C.map(s=>{const t=R[s]||{label:s,color:"slate"};return{subject:t.label,average:0,quizzes:0,color:t.color}}),z=E.length>0?E:Z,D=H.slice().sort((s,t)=>{const a=s.completedAt?.toDate?.()?.getTime()??0;return(t.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((s,t)=>({id:t+1,title:s.title||`Assessment ${t+1}`,subject:s.subject||"General",score:s.score,date:s.completedAt?K(s.completedAt.toDate()):"N/A",type:s.type==="practice"?"practice":(s.type==="diagnostic","module"),status:s.score>=80?"Excellent":s.score>=60?"Passing":"Needs Review"})).filter(s=>c.includes(s.subject)),p=D.filter(s=>{if(!c.includes(s.subject))return!1;const t=d==="all"||s.subject===d,a=x==="all"||s.type===x;return t&&a});r.useEffect(()=>{d!=="all"&&(c.includes(d)||S("all"))},[c,d]);const q=()=>{const s=o=>{const v=String(o??"");return/[",\n]/.test(v)?`"${v.replace(/"/g,'""')}"`:v},t=[],a=y?.name||l?.displayName||l?.email||"Student",i=new Date().toISOString().split("T")[0];t.push("Grade Report"),t.push(`Student,${s(a)}`),t.push(`Export Date,${s(i)}`),t.push(`Subject Filter,${s(d)}`),t.push(`Type Filter,${s(x)}`),t.push(""),t.push("Subject Performance"),t.push("Subject,Average Score"),z.forEach(o=>{t.push([s(o.subject),s(o.average)].join(","))}),t.push(""),t.push("Recent Quizzes"),t.push("Title,Subject,Score,Date,Type,Status"),p.length===0?t.push("No quiz data available for the selected filters"):p.forEach(o=>{t.push([s(o.title),s(o.subject),s(o.score),s(o.date),s(o.type),s(o.status)].join(","))});const j=t.join(` `),w=new Blob([j],{type:"text/csv;charset=utf-8;"}),u=window.URL.createObjectURL(w),m=document.createElement("a"),ee=a.replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()||"student";m.href=u,m.setAttribute("download",`grade-report-${ee}-${i}.csv`),document.body.appendChild(m),m.click(),document.body.removeChild(m),window.URL.revokeObjectURL(u)};return I?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-6 lg: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-5 sm:p-6 rounded-[1.5rem] sm: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(N,{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(re,{className:"w-4 h-4 mr-2 text-slate-400"}),"This Quarter"]}),e.jsxs(N,{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:q,children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),"Report"]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[1.2rem] sm:rounded-[2rem] border border-slate-100 p-4 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-6 -top-6 sm:-right-8 sm:-top-8 w-20 h-20 sm:w-32 sm: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-10 h-10 sm:w-14 sm:h-14 bg-indigo-100 text-indigo-600 rounded-xl sm:rounded-2xl flex items-center justify-center mb-3 sm:mb-6 shadow-sm",children:e.jsx(le,{className:"w-5 h-5 sm:w-7 sm:h-7"})}),e.jsxs("p",{className:"text-slate-400 font-bold text-[9px] sm:text-sm tracking-wider sm:tracking-wide uppercase h-6 sm:h-auto flex items-end sm:block",children:[e.jsx("span",{className:"sm:hidden",children:"GPA"}),e.jsx("span",{className:"hidden sm:inline",children:"Overall GPA"})]}),e.jsx("div",{className:"flex items-end gap-2 mt-1 sm:mt-2",children:e.jsx("h3",{className:"text-xl sm:text-4xl font-display font-black text-slate-800",children:W})})]})]}),e.jsxs("div",{className:"bg-white rounded-[1.2rem] sm:rounded-[2rem] border border-slate-100 p-4 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-6 -top-6 sm:-right-8 sm:-top-8 w-20 h-20 sm:w-32 sm: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-10 h-10 sm:w-14 sm:h-14 bg-emerald-100 text-emerald-600 rounded-xl sm:rounded-2xl flex items-center justify-center mb-3 sm:mb-6 shadow-sm",children:e.jsx(M,{className:"w-5 h-5 sm:w-7 sm:h-7"})}),e.jsxs("p",{className:"text-slate-400 font-bold text-[9px] sm:text-sm tracking-wider sm:tracking-wide uppercase h-6 sm:h-auto flex items-end sm:block",children:[e.jsx("span",{className:"sm:hidden",children:"Avg Score"}),e.jsx("span",{className:"hidden sm:inline",children:"Average Score"})]}),e.jsx("div",{className:"flex items-end gap-2 mt-1 sm:mt-2",children:e.jsxs("h3",{className:"text-xl sm:text-4xl font-display font-black text-slate-800",children:[f,"%"]})})]})]}),e.jsxs("div",{className:"bg-white rounded-[1.2rem] sm:rounded-[2rem] border border-slate-100 p-4 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-6 -top-6 sm:-right-8 sm:-top-8 w-20 h-20 sm:w-32 sm: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-10 h-10 sm:w-14 sm:h-14 bg-violet-100 text-violet-600 rounded-xl sm:rounded-2xl flex items-center justify-center mb-3 sm:mb-6 shadow-sm",children:e.jsx($,{className:"w-5 h-5 sm:w-7 sm:h-7"})}),e.jsxs("p",{className:"text-slate-400 font-bold text-[9px] sm:text-sm tracking-wider sm:tracking-wide uppercase h-6 sm:h-auto flex items-end sm:block",children:[e.jsx("span",{className:"sm:hidden",children:"Quizzes"}),e.jsx("span",{className:"hidden sm:inline",children:"Quizzes Completed"})]}),e.jsx("div",{className:"flex items-end gap-2 mt-1 sm:mt-2",children:e.jsx("h3",{className:"text-xl sm:text-4xl font-display font-black text-slate-800",children:J})})]})]})]}),n&&e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 p-6 shadow-sm cursor-pointer hover:shadow-md hover:border-indigo-200 transition-all",onClick:()=>g(!0),role:"button",tabIndex:0,onKeyDown:s=>{s.key==="Enter"&&g(!0)},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-indigo-100 rounded-xl flex items-center justify-center",children:e.jsx(ne,{className:"w-5 h-5 text-indigo-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-slate-800",children:"Diagnostic Assessment Results"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Your initial competency evaluation"})]})]}),e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-bold flex items-center gap-1.5 ${n.riskLevel==="Low"?"bg-emerald-100 text-emerald-700":n.riskLevel==="High"||n.riskLevel==="At Risk"?"bg-red-100 text-red-700":"bg-amber-100 text-amber-700"}`,children:[n.riskLevel==="Low"?e.jsx(me,{size:12}):e.jsx(xe,{size:12}),n.riskLevel]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.score>0&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase mb-1",children:"Score"}),e.jsxs("p",{className:"text-2xl font-black text-slate-800",children:[n.score,"%"]})]}),n.weaknesses.length>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs font-bold text-amber-600 uppercase mb-2",children:"Focus Areas"}),e.jsx("ul",{className:"space-y-1",children:n.weaknesses.map((s,t)=>e.jsxs("li",{className:"text-sm text-amber-800 flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),s]},t))})]}),n.recommendation&&e.jsxs("div",{className:"bg-indigo-50 border border-indigo-100 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs font-bold text-indigo-600 uppercase mb-2",children:"Recommendation"}),e.jsx("p",{className:"text-sm text-indigo-800",children:n.recommendation})]})]})]}),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-[1.5rem] sm:rounded-[2rem] border border-slate-100 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] overflow-hidden flex flex-col h-full w-full",children:[e.jsxs("div",{className:"p-5 sm:p-8 border-b border-slate-50 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 sm: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-2 sm:gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:d,onChange:s=>S(s.target.value),className:"appearance-none w-full pl-3 pr-8 py-2.5 border-none bg-slate-50 rounded-xl text-xs sm:text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-0 sm:min-w-[140px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Subjects"}),c.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx(Q,{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:s=>O(s.target.value),className:"appearance-none w-full pl-3 pr-8 py-2.5 border-none bg-slate-50 rounded-xl text-xs sm:text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-0 sm: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(Q,{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 no-scrollbar flex-1 px-4 sm:px-6 pb-4 -mx-4 sm:mx-0",children:e.jsxs("table",{className:"w-full text-left border-separate border-spacing-y-2 mb-4 whitespace-nowrap md:whitespace-normal",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:p.length>0?p.map(s=>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:s.title}),e.jsx("p",{className:"text-[11px] font-bold text-slate-400 mt-1",children:s.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:s.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 ${s.type==="practice"?"bg-emerald-100/50 text-emerald-600":"bg-indigo-100/50 text-indigo-600"}`,children:s.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 ${s.score>=80?"bg-emerald-100 text-emerald-700":s.score>=60?"bg-amber-100 text-amber-700":"bg-rose-100 text-rose-700"}`,children:[s.score,"%"]})})]},s.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(M,{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-[1.5rem] sm:rounded-[2rem] border border-slate-100 p-5 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:z.map((s,t)=>{const a=L[s.color]||L.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`}),s.subject]}),e.jsxs("p",{className:"text-[11px] text-slate-400 font-bold ml-4 mt-0.5",children:[s.quizzes," activities"]})]}),e.jsxs("span",{className:"text-[15px] font-black text-slate-800",children:[s.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(s.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]"})})})]},t)})})]}),e.jsxs("div",{className:"relative bg-gradient-to-br from-indigo-600 to-violet-700 rounded-[1.5rem] sm:rounded-[2rem] p-5 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($,{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:D.length})," activities recently. Try a practice session to boost your lowest scores."]}),e.jsx(N,{onClick:()=>{sessionStorage.setItem("mathpulse_modules_tab","practice"),window.dispatchEvent(new CustomEvent("mathpulse:navigate",{detail:{tab:"Modules"}}))},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"})]})]})]})]}),_&&l?.uid&&e.jsx(r.Suspense,{fallback:null,children:e.jsx(pe,{userId:l.uid,mode:"modal",isOpen:_,onClose:()=>g(!1)})})]})};export{Ee as default}; diff --git a/assets/HeroBanner-BqAsDsi9.js b/assets/HeroBanner-Db1VgQom.js similarity index 98% rename from assets/HeroBanner-BqAsDsi9.js rename to assets/HeroBanner-Db1VgQom.js index 624ec7a545c3c8782cb662a277542e2b2193eea8..3725ed60db856e94c599ae511c336f8ed5659508 100644 --- a/assets/HeroBanner-BqAsDsi9.js +++ b/assets/HeroBanner-Db1VgQom.js @@ -1,3 +1,3 @@ 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{T as R,g as b,a1 as M,h as _,m as f,a2 as E,A as G,B as S,q as z,Z as Y,b as F,_ as Q}from"./index-dPnhhJ9w.js";import{j as e,r as m}from"./vendor-react-B4AQeu28.js";import{D as W,a as q,S as V}from"./dialog-C4ok-Axi.js";import{R as K,L as X,C as U,X as Z,Y as O,T as I,f as J}from"./vendor-charts-D7t7JfSr.js";import{collection as v,query as w,limit as N,orderBy as k,getDocs as A,getDoc as L,doc as C}from"./vendor-firebase-firestore-CNv3xXal.js";import{X as ee}from"./x-Ck4mo_h-.js";import{C as H}from"./circle-alert-DCyh_PVA.js";import{C as se}from"./circle-check-BjsGkfB1.js";import{S as te}from"./sparkles-DPFO64ZX.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.js";const ae=({history:s})=>{if(s.length===0)return e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(R,{className:"w-12 h-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Complete more assessments to see your progress history."})]});const a=s.map(r=>({date:new Date(r.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),score:r.percentage,level:r.proficiencyLevel}));return e.jsx("div",{className:"w-full",children:e.jsx(K,{width:"100%",height:250,children:e.jsxs(X,{data:a,margin:{top:10,right:20,left:0,bottom:5},children:[e.jsx(U,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(Z,{dataKey:"date",tick:{fontSize:12,fill:"#64748b"}}),e.jsx(O,{domain:[0,100],tick:{fontSize:12,fill:"#64748b"}}),e.jsx(I,{contentStyle:{borderRadius:"12px",border:"1px solid #e2e8f0",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"}}),e.jsx(J,{type:"monotone",dataKey:"score",stroke:"#0ea5e9",strokeWidth:3,dot:{fill:"#0ea5e9",strokeWidth:2,r:5},activeDot:{r:7,fill:"#0284c7"}})]})})})};async function re(s){const a=v(b,"assessmentResults",s,"attempts"),r=w(a,k("completedAt","desc"),N(10));return(await A(r)).docs.map(i=>{const n=i.data();return{attemptId:n.attemptId,score:n.score,totalQuestions:n.totalQuestions,percentage:n.percentage,completedAt:n.completedAt?.toDate?.()?.toISOString()||n.completedAt,proficiencyLevel:n.proficiencyLevel}})}async function le(s){const a=v(b,"assessmentResults",s,"attempts"),r=w(a,k("completedAt","desc"),N(1)),c=await A(r);if(c.empty)return null;const n=c.docs[0].data();return{...n,completedAt:n.completedAt?.toDate?.()?.toISOString()||n.completedAt}}const oe={Beginner:"bg-amber-100 text-amber-700 border-amber-300",Developing:"bg-blue-100 text-blue-700 border-blue-300",Proficient:"bg-emerald-100 text-emerald-700 border-emerald-300",Advanced:"bg-violet-100 text-violet-700 border-violet-300"},ne=({result:s})=>e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-br from-sky-500 to-teal-600 rounded-xl p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sky-200 text-sm font-medium",children:"Total Score"}),e.jsxs("p",{className:"text-4xl font-bold",children:[s.score,"/",s.totalQuestions]}),e.jsxs("p",{className:"text-sky-200 text-sm mt-1",children:[s.percentage,"% Correct"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sky-200 text-sm font-medium",children:"Proficiency"}),e.jsx("span",{className:`inline-block mt-1 px-3 py-1 rounded-full text-sm font-semibold border ${oe[s.proficiencyLevel]}`,children:s.proficiencyLevel})]})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-sky-500"}),"Competency Breakdown"]}),e.jsx("div",{className:"space-y-2",children:s.competencyBreakdown.map((a,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700",children:a.topic}),e.jsxs("p",{className:"text-xs text-slate-500",children:[a.correctAnswers,"/",a.totalQuestions," correct"]})]}),e.jsx("div",{className:"w-20 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${a.accuracyPercent>=70?"bg-emerald-500":"bg-red-400"}`,style:{width:`${a.accuracyPercent}%`}})}),e.jsxs("span",{className:"text-sm font-semibold text-slate-600 w-10 text-right",children:[a.accuracyPercent,"%"]})]},r))})]}),s.aiNarrative&&e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-amber-500 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-amber-800 leading-relaxed",children:s.aiNarrative})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4 text-sky-500"}),"Question Breakdown"]}),e.jsx("div",{className:"space-y-3",children:s.answers.map((a,r)=>e.jsxs("div",{className:`p-4 rounded-xl border-2 ${a.isCorrect?"border-emerald-200 bg-emerald-50/30":"border-red-200 bg-red-50/30"}`,children:[e.jsxs("p",{className:"text-sm font-medium text-slate-800 mb-2",children:["Q",r+1,". ",a.questionText]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("span",{className:"text-slate-500",children:["Your answer: ",e.jsx("span",{className:a.isCorrect?"text-emerald-600 font-medium":"text-red-500 font-medium",children:a.userAnswer||"—"})]}),!a.isCorrect&&e.jsxs("span",{className:"text-slate-500",children:["Correct: ",e.jsx("span",{className:"text-emerald-600 font-medium",children:a.correctAnswer})]})]}),a.explanation&&e.jsx("p",{className:"text-xs text-slate-500 mt-2 leading-relaxed",children:a.explanation})]},r))})]})]}),ie=({summary:s})=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"bg-sky-50 border border-sky-100 rounded-2xl p-4 flex items-center gap-4 flex-1",children:[e.jsxs("div",{className:"w-12 h-12 bg-sky-500 rounded-full flex items-center justify-center text-white font-bold text-lg shadow-sm",children:[s.latestScorePercent,"%"]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-slate-500",children:"Latest Score"}),e.jsx("p",{className:"text-slate-800 font-bold",children:s.headline})]})]}),s.latestRiskLevel&&e.jsxs("div",{className:`px-4 py-2 rounded-full text-sm font-semibold flex items-center gap-2 +import{T as R,g as b,a1 as M,h as _,m as f,a2 as E,A as G,B as S,q as z,Z as Y,a as F,_ as Q}from"./index-CGNBpSmO.js";import{j as e,r as m}from"./vendor-react-B4AQeu28.js";import{D as W,a as q,S as V}from"./dialog-DDOyFRnI.js";import{R as K,L as X,C as U,X as Z,Y as O,T as I,f as J}from"./vendor-charts-D7t7JfSr.js";import{collection as v,query as w,limit as N,orderBy as k,getDocs as A,getDoc as L,doc as C}from"./vendor-firebase-firestore-CNv3xXal.js";import{X as ee}from"./x-Deb9zs8O.js";import{C as H}from"./circle-alert-fZn6_hMx.js";import{C as se}from"./circle-check-BhLH88x1.js";import{S as te}from"./sparkles-C0ju-UTT.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.js";const ae=({history:s})=>{if(s.length===0)return e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(R,{className:"w-12 h-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Complete more assessments to see your progress history."})]});const a=s.map(r=>({date:new Date(r.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),score:r.percentage,level:r.proficiencyLevel}));return e.jsx("div",{className:"w-full",children:e.jsx(K,{width:"100%",height:250,children:e.jsxs(X,{data:a,margin:{top:10,right:20,left:0,bottom:5},children:[e.jsx(U,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(Z,{dataKey:"date",tick:{fontSize:12,fill:"#64748b"}}),e.jsx(O,{domain:[0,100],tick:{fontSize:12,fill:"#64748b"}}),e.jsx(I,{contentStyle:{borderRadius:"12px",border:"1px solid #e2e8f0",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"}}),e.jsx(J,{type:"monotone",dataKey:"score",stroke:"#0ea5e9",strokeWidth:3,dot:{fill:"#0ea5e9",strokeWidth:2,r:5},activeDot:{r:7,fill:"#0284c7"}})]})})})};async function re(s){const a=v(b,"assessmentResults",s,"attempts"),r=w(a,k("completedAt","desc"),N(10));return(await A(r)).docs.map(i=>{const n=i.data();return{attemptId:n.attemptId,score:n.score,totalQuestions:n.totalQuestions,percentage:n.percentage,completedAt:n.completedAt?.toDate?.()?.toISOString()||n.completedAt,proficiencyLevel:n.proficiencyLevel}})}async function le(s){const a=v(b,"assessmentResults",s,"attempts"),r=w(a,k("completedAt","desc"),N(1)),c=await A(r);if(c.empty)return null;const n=c.docs[0].data();return{...n,completedAt:n.completedAt?.toDate?.()?.toISOString()||n.completedAt}}const oe={Beginner:"bg-amber-100 text-amber-700 border-amber-300",Developing:"bg-blue-100 text-blue-700 border-blue-300",Proficient:"bg-emerald-100 text-emerald-700 border-emerald-300",Advanced:"bg-violet-100 text-violet-700 border-violet-300"},ne=({result:s})=>e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-br from-sky-500 to-teal-600 rounded-xl p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sky-200 text-sm font-medium",children:"Total Score"}),e.jsxs("p",{className:"text-4xl font-bold",children:[s.score,"/",s.totalQuestions]}),e.jsxs("p",{className:"text-sky-200 text-sm mt-1",children:[s.percentage,"% Correct"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sky-200 text-sm font-medium",children:"Proficiency"}),e.jsx("span",{className:`inline-block mt-1 px-3 py-1 rounded-full text-sm font-semibold border ${oe[s.proficiencyLevel]}`,children:s.proficiencyLevel})]})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-sky-500"}),"Competency Breakdown"]}),e.jsx("div",{className:"space-y-2",children:s.competencyBreakdown.map((a,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700",children:a.topic}),e.jsxs("p",{className:"text-xs text-slate-500",children:[a.correctAnswers,"/",a.totalQuestions," correct"]})]}),e.jsx("div",{className:"w-20 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${a.accuracyPercent>=70?"bg-emerald-500":"bg-red-400"}`,style:{width:`${a.accuracyPercent}%`}})}),e.jsxs("span",{className:"text-sm font-semibold text-slate-600 w-10 text-right",children:[a.accuracyPercent,"%"]})]},r))})]}),s.aiNarrative&&e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-amber-500 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-amber-800 leading-relaxed",children:s.aiNarrative})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4 text-sky-500"}),"Question Breakdown"]}),e.jsx("div",{className:"space-y-3",children:s.answers.map((a,r)=>e.jsxs("div",{className:`p-4 rounded-xl border-2 ${a.isCorrect?"border-emerald-200 bg-emerald-50/30":"border-red-200 bg-red-50/30"}`,children:[e.jsxs("p",{className:"text-sm font-medium text-slate-800 mb-2",children:["Q",r+1,". ",a.questionText]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("span",{className:"text-slate-500",children:["Your answer: ",e.jsx("span",{className:a.isCorrect?"text-emerald-600 font-medium":"text-red-500 font-medium",children:a.userAnswer||"—"})]}),!a.isCorrect&&e.jsxs("span",{className:"text-slate-500",children:["Correct: ",e.jsx("span",{className:"text-emerald-600 font-medium",children:a.correctAnswer})]})]}),a.explanation&&e.jsx("p",{className:"text-xs text-slate-500 mt-2 leading-relaxed",children:a.explanation})]},r))})]})]}),ie=({summary:s})=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"bg-sky-50 border border-sky-100 rounded-2xl p-4 flex items-center gap-4 flex-1",children:[e.jsxs("div",{className:"w-12 h-12 bg-sky-500 rounded-full flex items-center justify-center text-white font-bold text-lg shadow-sm",children:[s.latestScorePercent,"%"]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-slate-500",children:"Latest Score"}),e.jsx("p",{className:"text-slate-800 font-bold",children:s.headline})]})]}),s.latestRiskLevel&&e.jsxs("div",{className:`px-4 py-2 rounded-full text-sm font-semibold flex items-center gap-2 ${s.latestRiskLevel==="At Risk"?"bg-red-100 text-red-700":s.latestRiskLevel==="Needs Attention"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700"}`,children:[s.latestRiskLevel==="At Risk"?e.jsx(V,{className:"w-4 h-4"}):s.latestRiskLevel==="Needs Attention"?e.jsx(H,{className:"w-4 h-4"}):e.jsx(se,{className:"w-4 h-4"}),s.latestRiskLevel]})]}),e.jsx("div",{className:"bg-slate-50 p-5 rounded-2xl border border-slate-100",children:e.jsx("p",{className:"text-slate-700 leading-relaxed",children:s.summary})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.strengths?.length>0&&e.jsxs("div",{className:"border border-emerald-100 bg-emerald-50/30 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-semibold text-emerald-800 mb-3 flex items-center gap-2",children:[e.jsx(R,{className:"w-4 h-4"}),"Strengths"]}),e.jsx("ul",{className:"space-y-2",children:s.strengths.map((a,r)=>e.jsxs("li",{className:"text-sm text-emerald-700 flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 mt-1.5 flex-shrink-0"}),e.jsx("span",{children:a})]},r))})]}),s.weaknesses?.length>0&&e.jsxs("div",{className:"border border-amber-100 bg-amber-50/30 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-semibold text-amber-800 mb-3 flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"Focus Areas"]}),e.jsx("ul",{className:"space-y-2",children:s.weaknesses.map((a,r)=>e.jsxs("li",{className:"text-sm text-amber-700 flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 mt-1.5 flex-shrink-0"}),e.jsx("span",{children:a})]},r))})]})]}),s.recommendation&&e.jsxs("div",{className:"bg-gradient-to-br from-indigo-50 to-purple-50 rounded-xl p-5 border border-indigo-100",children:[e.jsxs("h4",{className:"font-semibold text-indigo-900 mb-2 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-indigo-500"}),"Recommended Next Step"]}),e.jsx("p",{className:"text-sm text-indigo-800 leading-relaxed",children:s.recommendation})]})]}),de=({heroBannerSummary:s,latestResult:a,loading:r})=>r?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-32 bg-slate-200 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-slate-200 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-slate-200 rounded w-1/2"}),e.jsx("div",{className:"h-4 bg-slate-200 rounded w-5/6"})]})]}):!s&&!a?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-sky-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(S,{className:"w-8 h-8 text-sky-500"})}),e.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-2",children:"Let's personalize your learning"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-xs mx-auto",children:"Complete your diagnostic assessment so I can understand your strengths, weak areas, and the best next lessons for you."})]}):s?.status==="ready"?e.jsx(ie,{summary:s}):a?e.jsx(ne,{result:a}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-amber-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(H,{className:"w-8 h-8 text-amber-500"})}),e.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-2",children:"Your learning summary is being prepared"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-xs mx-auto",children:"Please try opening this again in a moment."})]});async function ce(s){const a=await L(C(b,"competencyProfiles",s)).catch(()=>null);if(a?.exists()){const t=a.data(),l=t.primaryStrength?[t.primaryStrength]:[],o=t.primaryWeakness?[t.primaryWeakness]:[];return{status:"ready",headline:t.overallScore>=70?"Good job — keep it up!":"Let's build your foundation",summary:o.length>0?`Focus on strengthening ${o[0]} to improve your overall performance.`:"Keep practicing to maintain and expand your skills.",strengths:l,weaknesses:o,recommendation:t.suggestedModule?`Start with the ${t.suggestedModule} module.`:"Continue with your personalized learning path.",latestAssessmentId:"",latestScorePercent:t.overallScore||0,latestRiskLevel:t.overallScore>=70?"Low":t.overallScore>=50?"Moderate":"High",updatedAt:t.updatedAt?.toDate?.()||new Date}}const r=await A(w(v(b,"assessments",s,"attempts"),k("completedAt","desc"),N(1))).catch(()=>null);if(r&&!r.empty){const t=r.docs[0].data(),l=t.rawScore||t.overallScorePercent||0,o=t.proficiencyProfile;return{status:"ready",headline:l>=70?"Good job — keep it up!":"Let's build your foundation",summary:o?.weaknesses?.length>0?`Focus on strengthening ${o.weaknesses[0]} to improve.`:l>=70?"You have a solid foundation!":"With practice, you'll build confidence.",strengths:o?.strengths||[],weaknesses:o?.weaknesses||[],recommendation:o?.suggestedStartingModule?`Start with ${o.suggestedStartingModule}.`:"Follow your personalized learning path.",latestAssessmentId:t.assessmentId||"",latestScorePercent:l,latestRiskLevel:l>=70?"Low":l>=50?"Moderate":"High",updatedAt:t.completedAt?.toDate?.()||new Date}}const c=await L(C(b,"diagnosticResults",s)).catch(()=>null);if(c?.exists()){const t=c.data(),l=t.overallScorePercent||t.overall_score_percent||0,o=t.riskProfile?.weak_domains||[];return{status:"ready",headline:l>=70?"Good job — keep it up!":"Let's build your foundation",summary:o.length>0?`Areas to focus on: ${o.join(", ")}.`:"Assessment completed. Follow your learning path.",strengths:[],weaknesses:o,recommendation:t.recommended_intervention||"Continue with your personalized learning path.",latestAssessmentId:"",latestScorePercent:l,latestRiskLevel:t.overall_risk||(l>=70?"Low":"Moderate"),updatedAt:t.completedAt?.toDate?.()||new Date}}const i=await A(w(v(b,"users",s,"assessments"),k("completedAt","desc"),N(5))).catch(()=>null);if(i&&!i.empty){const t=i.docs.map(p=>p.data()),l=t[0],o=l.score||l.scorePercent||0,x=t.length,j=Math.round(t.reduce((p,u)=>p+(u.score||u.scorePercent||0),0)/x);return{status:"ready",headline:o>=70?"Good job — keep it up!":"Let's build your foundation",summary:`You've completed ${x} diagnostic assessment${x>1?"s":""}. Your latest score is ${o}% (average: ${j}%).`,strengths:[],weaknesses:l.risk==="At Risk"||l.risk==="High"?[l.subject||"General Mathematics"]:[],recommendation:"Continue with your personalized learning path to strengthen weak areas.",latestAssessmentId:l.testId||"",latestScorePercent:o,latestRiskLevel:l.risk||(o>=70?"Low":o>=50?"Moderate":"High"),updatedAt:l.completedAt?.toDate?.()||new Date}}const n=await L(C(b,"users",s)).catch(()=>null);if(n?.exists()){const t=n.data();if(t.initialAssessmentCompleted||t.hasCompletedInitialAssessment){const l=t.atRiskSubjects||[];return{status:"ready",headline:"Assessment Complete! ✓",summary:l.length>0?`Areas to focus on: ${l.join(", ")}. Follow your personalized learning path to improve.`:"Your diagnostic assessment is complete. Your personalized learning path is ready.",strengths:[],weaknesses:l,recommendation:"Continue with your recommended lessons to strengthen your skills.",latestAssessmentId:"",latestScorePercent:0,latestRiskLevel:l.length>0?"Moderate":"Low",updatedAt:t.assessmentCompletedAt?.toDate?.()||new Date}}}return null}const me=({isOpen:s,onClose:a,studentId:r,latestResult:c,heroBannerSummary:i})=>{const[n,t]=m.useState("latest"),[l,o]=m.useState(c||null),[x,j]=m.useState([]),[p,u]=m.useState(!1),[g,y]=m.useState(null);m.useEffect(()=>{if(s&&r&&!i){const d=M(r,h=>{y(h)});return()=>d()}},[s,r,i]);const $=i||g;m.useEffect(()=>{s&&r&&(u(!0),(async()=>{try{const[h,T]=await Promise.all([c?Promise.resolve(c):le(r),re(r)]);if(o(h),j(T),!i&&!g){const D=await E(r);if(D)y(D);else{const P=await ce(r);P&&y(P)}}}catch(h){console.error("[AssessmentResultsModal] fetch error:",h)}finally{u(!1)}})())},[s,r,c]);const B=[{key:"latest",label:"Last Results",icon:e.jsx(G,{className:"w-4 h-4"})},{key:"history",label:"History & Trends",icon:e.jsx(R,{className:"w-4 h-4"})}];return e.jsx(W,{open:s,onOpenChange:d=>!d&&a(),children:e.jsxs(q,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0 bg-white rounded-2xl shadow-2xl border-0",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-white border-b border-slate-200 rounded-t-2xl px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-xl font-bold text-slate-800",children:"Assessment Results"}),e.jsx("button",{onClick:a,className:"p-1.5 rounded-lg hover:bg-slate-100 transition-colors",children:e.jsx(ee,{className:"w-5 h-5 text-slate-400"})})]}),e.jsx("div",{className:"flex gap-1 bg-slate-100 p-1 rounded-lg",children:B.map(d=>e.jsxs("button",{onClick:()=>t(d.key),className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all ${n===d.key?"bg-white text-sky-600 shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:[d.icon,d.label]},d.key))})]}),e.jsx("div",{className:"px-6 py-5",children:e.jsxs(_,{mode:"wait",children:[n==="latest"&&e.jsx(f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:e.jsx(de,{heroBannerSummary:$,latestResult:l,loading:p})},"latest"),n==="history"&&e.jsxs(f.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:[e.jsx(ae,{history:x}),x.length>0&&e.jsxs("div",{className:"mt-6 space-y-2",children:[e.jsx("h3",{className:"font-semibold text-slate-800 mb-3",children:"All Attempts"}),x.map((d,h)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:["Attempt ",x.length-h]}),e.jsx("p",{className:"text-xs text-slate-500",children:new Date(d.completedAt).toLocaleDateString()})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-semibold text-sky-600",children:[d.percentage,"%"]}),e.jsx("p",{className:"text-xs text-slate-500",children:d.proficiencyLevel})]})]},h))]})]},"history")]})})]})})},xe=m.lazy(()=>Q(()=>import("./DashboardAvatar-CbAKGmA6.js"),__vite__mapDeps([0,1,2]))),Ce=({userName:s="Student",userLevel:a=1,avatarLayers:r,onContinueLearning:c,showAssessmentTooltip:i,onOpenAssessment:n,studentId:t,assessmentCompleted:l=!1})=>{const[o,x]=m.useState(!1),[j,p]=m.useState(null);m.useEffect(()=>{if(!o||!t)return;const g=M(t,y=>{p(y)});return()=>g()},[o,t]),m.useEffect(()=>{o||p(null)},[o]);const u=()=>{const g=new Date().getHours();return g<12?"Good Morning":g<18?"Good Afternoon":"Good Evening"};return e.jsxs(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,ease:[.22,1,.36,1]},className:"relative w-full mt-0 rounded-2xl md:rounded-[2rem] p-5 md:p-6 lg:p-8 bg-gradient-to-br from-white via-sky-50/50 to-white border border-slate-200/80 card-elevated-lg",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-2xl md:rounded-[2rem] pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-sky-400/50 to-transparent"}),e.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-sky-100/40 rounded-full blur-3xl -translate-y-1/2 translate-x-1/4"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-64 h-64 bg-rose-100/30 rounded-full blur-3xl translate-y-1/2 -translate-x-1/4"}),e.jsx("div",{className:"absolute inset-0 bg-dot-pattern opacity-40"})]}),e.jsx("div",{className:"relative z-10 flex flex-col md:flex-row min-h-[140px] lg:min-h-[160px] items-start md:items-center justify-between gap-4 md:gap-6 pb-0",children:e.jsxs("div",{className:"flex-1 w-full md:w-auto min-w-0 pr-0 md:pr-40 lg:pr-[280px] pb-2 md:pb-0 py-1",children:[e.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-2 mb-3 md:mb-2",children:[e.jsx("div",{className:"px-3 md:px-4 py-1.5 rounded-full bg-sky-100 border border-sky-200",children:e.jsxs("span",{className:"text-xs md:text-sm font-body font-bold text-sky-700",children:["Level ",a]})}),e.jsxs("div",{className:"px-3 md:px-4 py-1.5 rounded-full bg-rose-50 border border-rose-200",children:[e.jsx(Y,{size:14,className:"inline -mt-0.5 text-rose-500 mr-1"}),e.jsx("span",{className:"text-xs md:text-sm font-body font-bold text-rose-700",children:"Active"})]})]}),e.jsxs("h1",{className:"text-2xl md:text-2xl lg:text-3xl font-display font-black text-[#0a1628] mb-1.5 tracking-tight leading-[1.1]",children:[u(),", ",s,"!"]}),e.jsx("p",{className:"text-slate-500 mb-2 md:mb-1 text-sm md:text-sm font-body font-bold pr-[155px] md:pr-0",children:"Today is a great day to move one step forward in math mastery."}),e.jsx("p",{className:"text-xs md:text-xs text-slate-400 font-body mb-5 md:mb-4 pr-[150px] md:pr-0",children:"Focus on your next recommended lesson and keep your momentum."}),e.jsxs(f.button,{onClick:c,whileHover:{scale:1.03},whileTap:{scale:.97},className:"mt-2 md:mt-2 bg-gradient-to-r from-purple-600 to-[#9956DE] text-white px-5 py-3 md:py-2 rounded-xl font-body font-bold text-base md:text-sm shadow-lg shadow-purple-500/20 hover:shadow-purple-500/30 transition-all flex justify-center md:justify-start items-center gap-2 group w-auto md:w-auto",children:["Continue Learning",e.jsx(F,{size:14,className:"group-hover:translate-x-1 transition-transform"})]})]})}),i&&e.jsx(f.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:n,className:"absolute hidden md:block right-[150px] lg:right-[250px] bottom-16 lg:bottom-20 z-30 cursor-pointer drop-shadow-lg group",children:e.jsxs("div",{className:"bg-white px-4 py-3 rounded-2xl rounded-br-sm border-2 border-amber-300 relative transition-all group-hover:bg-amber-50 group-hover:border-amber-400 group-hover:-translate-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-amber-500",children:e.jsx(S,{size:16})}),e.jsxs("p",{className:"text-xs lg:text-sm font-bold text-amber-900 leading-tight",children:["Don't forget to take the",e.jsx("br",{}),"Initial Assessment!"]})]}),e.jsx("div",{className:"absolute -right-2 bottom-0 w-4 h-4 bg-white border-2 border-transparent border-r-amber-300 border-b-amber-300 rotate-45 group-hover:bg-amber-50 group-hover:border-r-amber-400 group-hover:border-b-amber-400 transition-colors"})]})}),l&&!i&&e.jsx(f.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:()=>window.dispatchEvent(new CustomEvent("mathpulse:navigate",{detail:{tab:"Grades"}})),className:"absolute hidden md:block right-[150px] lg:right-[250px] bottom-16 lg:bottom-20 z-30 cursor-pointer drop-shadow-lg group",children:e.jsxs("div",{className:"bg-white px-4 py-3 rounded-2xl rounded-br-sm border-2 border-teal-300 relative transition-all group-hover:bg-teal-50 group-hover:border-teal-400 group-hover:-translate-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 bg-teal-100 rounded-full flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"text-teal-600",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),e.jsxs("p",{className:"text-xs lg:text-sm font-bold text-teal-900 leading-tight",children:["Assessment Complete!",e.jsx("br",{}),e.jsx("span",{className:"text-[10px] lg:text-[11px] font-normal text-teal-700",children:"View results & history"})]})]}),e.jsx("div",{className:"absolute -right-2 bottom-0 w-4 h-4 bg-white border-2 border-transparent border-r-teal-300 border-b-teal-300 rotate-45 group-hover:bg-teal-50 group-hover:border-r-teal-400 group-hover:border-b-teal-400 transition-colors"})]})}),o&&t&&e.jsx(me,{isOpen:o,onClose:()=>x(!1),studentId:t,heroBannerSummary:j}),e.jsx("div",{className:"absolute right-0 bottom-0 lg:right-10 w-[160px] md:w-[150px] lg:w-[270px] pointer-events-none z-20",style:{clipPath:"inset(-100% -50% 0 -50%)"},children:e.jsx("div",{className:"relative w-full aspect-[4/5] translate-y-[10%] md:translate-y-[21%] lg:translate-y-[19%] drop-shadow-2xl",children:e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"w-full h-full scale-[1.15] md:scale-[1.25] lg:scale-[1.3] origin-bottom"}),children:e.jsx(xe,{layers:r,className:"w-full h-full scale-[1.35] md:scale-[1.25] lg:scale-[1.3] origin-bottom"})})})})]})};export{Ce as default}; diff --git a/assets/InitialAssessmentModal-BZbG1PlT.js b/assets/InitialAssessmentModal-J2vAV5pW.js similarity index 94% rename from assets/InitialAssessmentModal-BZbG1PlT.js rename to assets/InitialAssessmentModal-J2vAV5pW.js index 41a34dda0f163f1b2e437ac0a295778ef87474f0..0faba91fa06cbe0fc67047482c2f2415328cd148 100644 --- a/assets/InitialAssessmentModal-BZbG1PlT.js +++ b/assets/InitialAssessmentModal-J2vAV5pW.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{B as j}from"./button-WbM5w2Bp.js";import{g as y}from"./diagnosticService-ukrfKIf7.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CNv3xXal.js";import{m as o,B as k,x as C,p as L,g as z}from"./index-dPnhhJ9w.js";import{X as S}from"./x-Ck4mo_h-.js";import{C as A}from"./circle-check-big-DJBKLvuw.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.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-[44rem] 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-[24rem] 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-[28rem] 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-[380px] 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-[24rem] 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-DVjn4LkC.js";import{g as y}from"./diagnosticService-DLw8ENQS.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CNv3xXal.js";import{m as o,B as k,x as C,p as L,g as z}from"./index-CGNBpSmO.js";import{X as S}from"./x-Deb9zs8O.js";import{C as A}from"./circle-check-big-yCNC9yfs.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.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-[44rem] 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-[24rem] 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-[28rem] 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-[380px] 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-[24rem] 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-BSAGck0o.js b/assets/LeaderboardPage-Bttk2eAz.js similarity index 98% rename from assets/LeaderboardPage-BSAGck0o.js rename to assets/LeaderboardPage-Bttk2eAz.js index dc6835b44da59c78b8b25ae7313732ab578125d8..17e5e6f69a3728dc401e665cd79cdd3bffcaf4ae 100644 --- a/assets/LeaderboardPage-BSAGck0o.js +++ b/assets/LeaderboardPage-Bttk2eAz.js @@ -1,4 +1,4 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{e as O,aI as W,h as q,m as n,a as y,q as P,A as k,E as m,T as E,p as _,a4 as I,a5 as H,X as U,u as $,aJ as G,R as J,L as K,z as X}from"./index-dPnhhJ9w.js";import{X as Q}from"./x-Ck4mo_h-.js";import{C as V}from"./clock-Dy5eVj9o.js";import{u as Z}from"./useFeatureAccess-Bk0jlnA0.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{e as O,aI as W,h as q,m as n,b as y,q as P,A as k,E as m,T as E,p as _,a4 as I,a5 as H,X as U,u as $,aJ as G,R as J,L as K,z as X}from"./index-CGNBpSmO.js";import{X as Q}from"./x-Deb9zs8O.js";import{C as V}from"./clock-D2bky9WI.js";import{u as Z}from"./useFeatureAccess-BUoKpUf3.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-3spRtYqf.js b/assets/LearningPath-B5QBkJ31.js similarity index 91% rename from assets/LearningPath-3spRtYqf.js rename to assets/LearningPath-B5QBkJ31.js index 4e9a5258a4ec07c2b17580cafb4884c787b4c0a3..5631e6ab16ad15e511624152d5f7258e5916b2cc 100644 --- a/assets/LearningPath-3spRtYqf.js +++ b/assets/LearningPath-B5QBkJ31.js @@ -1 +1 @@ -import{r as p,d as g,j as r}from"./vendor-react-B4AQeu28.js";import{u as b,a9 as j,aa as N,y as k,a as P,b as I}from"./index-dPnhhJ9w.js";import{M as v}from"./ModuleFolderCard-BDMyLDzi.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-D0TkEgbI.js";import"./clock-Dy5eVj9o.js";const z=({onNavigateToModules:m,atRiskSubjects:l=[],priorityTopics:o=[],modules:i})=>{const{userProfile:d}=b(),[x,h]=p.useState(null),a=g.useMemo(()=>{const e=o.length>0?o:l.map(s=>j(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,l]),u=g.useMemo(()=>{if(a.length===0)return i.slice(0,3);const e=new Map(a.map((t,s)=>[N[t],s]));return[...i].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,w=e.get(s.id)??Number.POSITIVE_INFINITY;return n-w}).slice(0,3)},[i,a]);p.useEffect(()=>{d?.uid&&k(d.uid).then(h).catch(console.error)},[d?.uid]);const c=u.slice(0,3).map(e=>{const t=x?.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=c.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4 md:mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[r.jsx("div",{className:"w-8 h-8 md:w-10 md:h-10 shrink-0 rounded-xl md:rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(P,{className:"w-4 h-4 md:w-5 md:h-5",strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-lg md:text-[24px] text-slate-800 tracking-tight whitespace-nowrap",children:f})]}),r.jsxs("button",{onClick:()=>m?.(),className:"text-primary font-bold text-xs md:text-sm flex shrink-0 items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-3 py-1.5 md:px-4 md:py-2 rounded-lg md:rounded-xl hover:bg-primary/20 whitespace-nowrap",children:["View All ",r.jsx(I,{className:"w-3.5 h-3.5 md:w-4 md:h-4"})]})]}),r.jsx("div",{className:"flex overflow-x-auto snap-x snap-mandatory scrollbar-hide -mx-4 px-4 pb-4 gap-4 md:grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 md:gap-6 md:pb-0 md:mx-0 md:px-0 md:overflow-visible",children:c.map((e,t)=>r.jsx("div",{className:"w-[72vw] max-w-[260px] h-[220px] shrink-0 snap-center md:min-w-0 md:max-w-none md:w-auto md:shrink md:h-auto",children:r.jsx(v,{module:e,index:t,onClick:()=>m?.(e.id),isAtRisk:a.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0})},e.id))})]})};export{z as default}; +import{r as p,d as g,j as r}from"./vendor-react-B4AQeu28.js";import{u as b,a9 as j,aa as N,y as k,b as P,a as I}from"./index-CGNBpSmO.js";import{M as v}from"./ModuleFolderCard-dHGX9Tik.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-iyC7Wdl7.js";import"./clock-D2bky9WI.js";const z=({onNavigateToModules:m,atRiskSubjects:l=[],priorityTopics:o=[],modules:i})=>{const{userProfile:d}=b(),[x,h]=p.useState(null),a=g.useMemo(()=>{const e=o.length>0?o:l.map(s=>j(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,l]),u=g.useMemo(()=>{if(a.length===0)return i.slice(0,3);const e=new Map(a.map((t,s)=>[N[t],s]));return[...i].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,w=e.get(s.id)??Number.POSITIVE_INFINITY;return n-w}).slice(0,3)},[i,a]);p.useEffect(()=>{d?.uid&&k(d.uid).then(h).catch(console.error)},[d?.uid]);const c=u.slice(0,3).map(e=>{const t=x?.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=c.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4 md:mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[r.jsx("div",{className:"w-8 h-8 md:w-10 md:h-10 shrink-0 rounded-xl md:rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(P,{className:"w-4 h-4 md:w-5 md:h-5",strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-lg md:text-[24px] text-slate-800 tracking-tight whitespace-nowrap",children:f})]}),r.jsxs("button",{onClick:()=>m?.(),className:"text-primary font-bold text-xs md:text-sm flex shrink-0 items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-3 py-1.5 md:px-4 md:py-2 rounded-lg md:rounded-xl hover:bg-primary/20 whitespace-nowrap",children:["View All ",r.jsx(I,{className:"w-3.5 h-3.5 md:w-4 md:h-4"})]})]}),r.jsx("div",{className:"flex overflow-x-auto snap-x snap-mandatory scrollbar-hide -mx-4 px-4 pb-4 gap-4 md:grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 md:gap-6 md:pb-0 md:mx-0 md:px-0 md:overflow-visible",children:c.map((e,t)=>r.jsx("div",{className:"w-[72vw] max-w-[260px] h-[220px] shrink-0 snap-center md:min-w-0 md:max-w-none md:w-auto md:shrink md:h-auto",children:r.jsx(v,{module:e,index:t,onClick:()=>m?.(e.id),isAtRisk:a.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0})},e.id))})]})};export{z as default}; diff --git a/assets/LoginPage-BHI-A5a1.js b/assets/LoginPage-BHI-A5a1.js new file mode 100644 index 0000000000000000000000000000000000000000..beb58253c1b2d3add75bfc00200b208fa88cfcdb --- /dev/null +++ b/assets/LoginPage-BHI-A5a1.js @@ -0,0 +1 @@ +import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as je}from"./button-DVjn4LkC.js";import{I as L}from"./input-CBi6xF4I.js";import{m as i,B as we,T as Ne,A as ke,U as Q,L as X,a as K,G as Se,b as Pe,s as ee,c as Ae,d as te}from"./index-CGNBpSmO.js";import{S as Me}from"./sparkles-C0ju-UTT.js";import{M as Re}from"./mail-C1tKDR_N.js";import{E as Ce,a as Ee}from"./eye-_x45syMF.js";import{S as Te}from"./shield-check-h8afT4cG.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";const se="/assets/shader-bg-DA7bEbBA.mp4",Le=[{id:"length",label:"At least 8 characters",test:a=>a.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:a=>/[A-Z]/.test(a)&&/[a-z]/.test(a)},{id:"number",label:"Contains at least one number",test:a=>/\d/.test(a)},{id:"special",label:"Contains at least one special character",test:a=>/[^A-Za-z0-9]/.test(a)}],I="Use at least 8 characters with uppercase, lowercase, number, and special character.",Ie=a=>{const c=typeof a=="object"&&a!==null?a:null,o=a instanceof Error?a.message:"";if(c?.code&&typeof c.code=="string")return{code:c.code.toLowerCase(),message:o};const n=o.match(/auth\/[a-z-]+/i);return{code:n?n[0].toLowerCase():"",message:o}},ze=a=>a.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),ae=(a,c)=>{const{code:o,message:n}=Ie(a),h=ze(n);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. ${I}`: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:n.includes("Firebase:")||n.includes("auth/")?c:n||c},et=()=>{const a={"Grade 11":["Academic","Tech-Pro"]},[c,o]=s.useState(""),[n,h]=s.useState(""),[S,re]=s.useState(!1),[l,z]=s.useState(!1),[P,ie]=s.useState(""),[y,D]=s.useState("student"),[b,De]=s.useState("Grade 11"),[v,B]=s.useState(a["Grade 11"][0]),[_,x]=s.useState(!1),[f,u]=s.useState(null),[oe,le]=s.useState(!1),[ne,ce]=s.useState(!1),[A,de]=s.useState(16),[q,V]=s.useState("primary"),[O,M]=s.useState(0),R=s.useRef(null),C=s.useRef(null),j=oe&&ne,g=s.useRef("primary"),w=s.useRef(0),N=s.useRef(!1),F=1.1,G=.34,U=t=>{const r=Math.max(0,Math.min(1,t));Math.abs(w.current-r)<.02||(w.current=r,M(r))},$=t=>{!Number.isFinite(t)||t<=0||Math.abs(A-t)>.05&&de(t)},E=s.useMemo(()=>Le.map(t=>({...t,met:t.test(n)})),[n]),W=s.useMemo(()=>E.every(t=>t.met),[E]),me=s.useMemo(()=>{if(!l||!f)return!1;const t=f.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[f,l]),ue=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&$(t)},pe=()=>{const t=C.current?.duration;t&&Number.isFinite(t)&&t>0&&$(t)};s.useEffect(()=>{if(!j)return;const t=R.current,r=C.current;if(!t||!r)return;let d=!1,m=0;g.current="primary",V("primary"),N.current=!1,w.current=0,M(0),t.loop=!1,r.loop=!1,t.currentTime=0,r.currentTime=0,r.pause(),t.play().catch(()=>{});const k=()=>{if(d)return;const p=g.current==="primary"?t:r,Z=g.current==="primary"?r:t,ge=Number.isFinite(p.duration)&&p.duration>0?p.duration:A,T=Math.max(ge-p.currentTime,0);if(T<=F){N.current||(N.current=!0,Z.currentTime=0,Z.play().catch(()=>{}));const ve=1-T/F;if(U(ve),T<=.03||p.ended){p.pause(),p.currentTime=0;const J=g.current==="primary"?"secondary":"primary";g.current=J,V(J),N.current=!1,w.current=0,M(0)}}else U(0);m=window.requestAnimationFrame(k)};return m=window.requestAnimationFrame(k),()=>{d=!0,m&&window.cancelAnimationFrame(m)}},[A,j]);const Y=j?G*(1-O):0,H=j?G*O:0,xe=q==="primary"?Y:H,ye=q==="secondary"?Y:H;s.useEffect(()=>{const t=a[b]||[];t.length>0&&!t.includes(v)&&B(t[0])},[b,v]);const he=[{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:Pe,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:Te,color:"rose"}],be=async(t,r,d)=>{u(null),x(!0),o(t),h(r),D(d),z(!1);try{ee(d),await te(t,r)}catch(m){u(ae(m,"Demo sign-in failed. Please try again.")),x(!1)}},fe=async t=>{t.preventDefault(),u(null),x(!0);try{if(l){if(!P.trim()){u("Please enter your name"),x(!1);return}if(y==="student"&&!b){u("Please select a grade level"),x(!1);return}if(y==="admin"){u("Admin account creation is restricted. Please contact an existing administrator."),x(!1);return}if(!W){u(`Password does not meet signup requirements. ${I}`),x(!1);return}ee(y),await Ae(c,n,P,y,y==="student"?{grade:b,section:v}:{department:"Mathematics"})}else await te(c,n)}catch(r){const d=l?`Sign-up failed. ${I}`:"Sign-in failed. Please check your credentials and try again.";u(ae(r,d)),x(!1)}};return e.jsxs("div",{className:"min-h-screen w-full flex items-center justify-center px-4 sm:px-6 py-8 overflow-y-auto relative login-bg",children:[e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>le(!0),onLoadedMetadata:ue,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":xe},src:se}),e.jsx("video",{ref:C,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>ce(!0),onLoadedMetadata:pe,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":ye},src:se}),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(i.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col items-center lg:items-start justify-center space-y-5 lg:space-y-8 text-center lg:text-left",children:[e.jsxs(i.div,{className:"flex items-center justify-center lg:justify-start gap-2.5",children:[e.jsx(i.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_final_logo.png",alt:"MathPulse AI Logo",className:"w-10 h-10 lg:w-16 lg:h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl lg: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(Me,{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(i.div,{className:"space-y-3 lg:space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-3xl sm: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-sm lg:text-base text-slate-500 leading-relaxed max-w-md mx-auto lg:mx-0 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-2 lg:gap-3",children:[{icon:we,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Ne,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:ke,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,r)=>{const d=t.icon,m={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"},k={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},p={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(i.div,{className:`bg-white/80 backdrop-blur-xl border ${m[t.color]} rounded-xl p-3 lg: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+r*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-7 h-7 lg:w-9 lg:h-9 rounded-lg ${p[t.color]} flex items-center justify-center mx-auto lg:mx-0 mb-2 lg:mb-3`,children:e.jsx(d,{size:15,className:k[t.color]})}),e.jsx("h3",{className:"text-xs lg:text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-[10px] lg:text-xs text-slate-400 font-body",children:t.desc})]},r)})})]}),e.jsx(i.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-6 sm:p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)] max-h-[85vh] overflow-y-auto",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-4 relative",children:[e.jsx(i.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(i.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:fe,className:"space-y-3 mb-4 relative",children:[f&&!me&&e.jsx(i.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:f}),l&&e.jsxs(i.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(Q,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:"text",placeholder:"Your Name",value:P,onChange:t=>ie(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(i.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 r=y===t.role;return e.jsx("button",{type:"button",onClick:()=>D(t.role),className:`rounded-lg border px-3 py-2.5 text-sm font-body font-semibold transition-all ${r?"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&&y==="student"&&e.jsx(i.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"space-y-3",children:e.jsxs("div",{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(Q,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:v,onChange:t=>B(t.target.value),className:"w-full pl-11 pr-4 py-2.5 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:(a[b]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]})}),e.jsxs(i.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(Re,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:"email",placeholder:"your.email@school.edu",value:c,onChange:t=>o(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(i.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(X,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:S?"text":"password",placeholder:"••••••••",value:n,onChange:t=>h(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(i.button,{type:"button",onClick:()=>re(!S),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:S?e.jsx(Ce,{size:16}):e.jsx(Ee,{size:16})})]}),l&&n.length>0&&!W&&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:E.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))})]})]}),e.jsx(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(je,{type:"submit",disabled:_,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(i.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:[_?"Please wait...":l?"Create Account":"Sign In",e.jsx(K,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{z(!l),u(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(i.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:he.map(t=>{const r=t.icon,d={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},m={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(i.button,{type:"button",onClick:()=>be(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 ${d[t.color]}`,children:e.jsx(r,{size:15,className:m[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(K,{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(i.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(X,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{et as default}; diff --git a/assets/LoginPage-DktsN1Jx.js b/assets/LoginPage-DktsN1Jx.js deleted file mode 100644 index 5c0257a4d9dfffb4cee76bfbb951f139d642e478..0000000000000000000000000000000000000000 --- a/assets/LoginPage-DktsN1Jx.js +++ /dev/null @@ -1 +0,0 @@ -import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as Se}from"./button-WbM5w2Bp.js";import{I as L}from"./input-BUQJctP7.js";import{m as i,B as Pe,T as Ae,A as Ee,U as ee,a as te,L as se,b as ae,G as Me,s as re,c as Te,d as ie}from"./index-dPnhhJ9w.js";import{S as Re}from"./sparkles-DPFO64ZX.js";import{M as Ce}from"./mail-DiIt1YFo.js";import{E as Ie,a as Le}from"./eye-BmZ1sFKD.js";import{S as De}from"./shield-check-CS0qf70Z.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";const le="/assets/shader-bg-DA7bEbBA.mp4",ze=[{id:"length",label:"At least 8 characters",test:a=>a.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:a=>/[A-Z]/.test(a)&&/[a-z]/.test(a)},{id:"number",label:"Contains at least one number",test:a=>/\d/.test(a)},{id:"special",label:"Contains at least one special character",test:a=>/[^A-Za-z0-9]/.test(a)}],D="Use at least 8 characters with uppercase, lowercase, number, and special character.",_e=a=>{const n=typeof a=="object"&&a!==null?a:null,l=a instanceof Error?a.message:"";if(n?.code&&typeof n.code=="string")return{code:n.code.toLowerCase(),message:l};const m=l.match(/auth\/[a-z-]+/i);return{code:m?m[0].toLowerCase():"",message:l}},qe=a=>a.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),oe=(a,n)=>{const{code:l,message:m}=_e(a),u=qe(m);return l==="auth/invalid-credential"||l==="auth/wrong-password"||l==="auth/user-not-found"?"Invalid email or password. Please check your credentials and try again.":l==="auth/email-already-in-use"?"This email is already registered. Please sign in instead.":l==="auth/weak-password"||l==="auth/password-does-not-meet-requirements"?u?`Password does not meet signup requirements. ${u}`:`Password does not meet signup requirements. ${D}`:l==="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.":l==="auth/network-request-failed"?"Network error. Please check your internet connection and try again.":l.startsWith("auth/")?u||n:m.includes("Firebase:")||m.includes("auth/")?n:m||n},at=()=>{const a={"Grade 11":["Academic","Tech-Pro"]},n={teacher:["Mathematics","Science","English","Technology","Humanities"]},[l,m]=s.useState(""),[u,z]=s.useState(""),[P,ne]=s.useState(!1),[o,_]=s.useState(!1),[A,ce]=s.useState(""),[c,q]=s.useState("student"),[f,Be]=s.useState("Grade 11"),[j,B]=s.useState(a["Grade 11"][0]),[b,O]=s.useState("Mathematics"),[V,y]=s.useState(!1),[g,p]=s.useState(null),[de,me]=s.useState(!1),[ue,pe]=s.useState(!1),[E,xe]=s.useState(16),[F,G]=s.useState("primary"),[U,M]=s.useState(0),T=s.useRef(null),R=s.useRef(null),w=de&&ue,v=s.useRef("primary"),N=s.useRef(0),k=s.useRef(!1),$=1.1,W=.34,H=t=>{const r=Math.max(0,Math.min(1,t));Math.abs(N.current-r)<.02||(N.current=r,M(r))},Y=t=>{!Number.isFinite(t)||t<=0||Math.abs(E-t)>.05&&xe(t)},C=s.useMemo(()=>ze.map(t=>({...t,met:t.test(u)})),[u]),Z=s.useMemo(()=>C.every(t=>t.met),[C]),ye=s.useMemo(()=>{if(!o||!g)return!1;const t=g.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[g,o]),he=()=>{const t=T.current?.duration;t&&Number.isFinite(t)&&t>0&&Y(t)},fe=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&Y(t)};s.useEffect(()=>{if(!w)return;const t=T.current,r=R.current;if(!t||!r)return;let d=!1,x=0;v.current="primary",G("primary"),k.current=!1,N.current=0,M(0),t.loop=!1,r.loop=!1,t.currentTime=0,r.currentTime=0,r.pause(),t.play().catch(()=>{});const S=()=>{if(d)return;const h=v.current==="primary"?t:r,X=v.current==="primary"?r:t,Ne=Number.isFinite(h.duration)&&h.duration>0?h.duration:E,I=Math.max(Ne-h.currentTime,0);if(I<=$){k.current||(k.current=!0,X.currentTime=0,X.play().catch(()=>{}));const ke=1-I/$;if(H(ke),I<=.03||h.ended){h.pause(),h.currentTime=0;const K=v.current==="primary"?"secondary":"primary";v.current=K,G(K),k.current=!1,N.current=0,M(0)}}else H(0);x=window.requestAnimationFrame(S)};return x=window.requestAnimationFrame(S),()=>{d=!0,x&&window.cancelAnimationFrame(x)}},[E,w]);const J=w?W*(1-U):0,Q=w?W*U:0,be=F==="primary"?J:Q,ge=F==="secondary"?J:Q;s.useEffect(()=>{c==="teacher"&&!n.teacher.includes(b)&&O(n.teacher[0])},[b,c]),s.useEffect(()=>{const t=a[f]||[];t.length>0&&!t.includes(j)&&B(t[0])},[f,j]);const ve=[{label:"Student",role:"student",email:"teststudent@school.edu",password:"TestPass123!",icon:Me,color:"sky"},{label:"Teacher",role:"teacher",email:"testteacher@school.edu",password:"TestPass123!",icon:te,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:De,color:"rose"}],je=async(t,r,d)=>{p(null),y(!0),m(t),z(r),q(d),_(!1);try{re(d),await ie(t,r)}catch(x){p(oe(x,"Demo sign-in failed. Please try again.")),y(!1)}},we=async t=>{t.preventDefault(),p(null),y(!0);try{if(o){if(!A.trim()){p("Please enter your name"),y(!1);return}if(c==="student"&&!f){p("Please select a grade level"),y(!1);return}if(c!=="student"&&!b){p("Please select a department"),y(!1);return}if(c==="admin"){p("Admin account creation is restricted. Please contact an existing administrator."),y(!1);return}if(!Z){p(`Password does not meet signup requirements. ${D}`),y(!1);return}re(c),await Te(l,u,A,c,c==="student"?{grade:f,section:j}:{department:b})}else await ie(l,u)}catch(r){const d=o?`Sign-up failed. ${D}`:"Sign-in failed. Please check your credentials and try again.";p(oe(r,d)),y(!1)}};return e.jsxs("div",{className:"min-h-screen w-full flex items-center justify-center px-4 sm:px-6 py-8 overflow-y-auto relative login-bg",children:[e.jsx("video",{ref:T,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>me(!0),onLoadedMetadata:he,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":be},src:le}),e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>pe(!0),onLoadedMetadata:fe,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":ge},src:le}),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(i.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col items-center lg:items-start justify-center space-y-5 lg:space-y-8 text-center lg:text-left",children:[e.jsxs(i.div,{className:"flex items-center justify-center lg:justify-start gap-2.5",children:[e.jsx(i.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_final_logo.png",alt:"MathPulse AI Logo",className:"w-10 h-10 lg:w-16 lg:h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl lg: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(Re,{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(i.div,{className:"space-y-3 lg:space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-3xl sm: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-sm lg:text-base text-slate-500 leading-relaxed max-w-md mx-auto lg:mx-0 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-2 lg:gap-3",children:[{icon:Pe,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Ae,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:Ee,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,r)=>{const d=t.icon,x={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"},S={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},h={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(i.div,{className:`bg-white/80 backdrop-blur-xl border ${x[t.color]} rounded-xl p-3 lg: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+r*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-7 h-7 lg:w-9 lg:h-9 rounded-lg ${h[t.color]} flex items-center justify-center mx-auto lg:mx-0 mb-2 lg:mb-3`,children:e.jsx(d,{size:15,className:S[t.color]})}),e.jsx("h3",{className:"text-xs lg:text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-[10px] lg:text-xs text-slate-400 font-body",children:t.desc})]},r)})})]}),e.jsx(i.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-6 sm:p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)] max-h-[85vh] overflow-y-auto",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-4 relative",children:[e.jsx(i.h3,{className:"text-2xl font-display font-bold text-slate-900 mb-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},children:o?"Create Account":"Welcome Back"}),e.jsx(i.p,{className:"text-sm text-slate-500 font-body",initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:o?"Begin your learning journey":"Sign in to continue learning"})]}),e.jsxs("form",{onSubmit:we,className:"space-y-3 mb-4 relative",children:[g&&!ye&&e.jsx(i.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:g}),o&&e.jsxs(i.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(ee,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:"text",placeholder:"Your Name",value:A,onChange:t=>ce(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})]})]}),o&&e.jsxs(i.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 r=c===t.role;return e.jsx("button",{type:"button",onClick:()=>q(t.role),className:`rounded-lg border px-3 py-2.5 text-sm font-body font-semibold transition-all ${r?"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)})})]}),o&&c==="student"&&e.jsx(i.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"space-y-3",children:e.jsxs("div",{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(ee,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:j,onChange:t=>B(t.target.value),className:"w-full pl-11 pr-4 py-2.5 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:(a[f]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]})}),o&&c!=="student"&&e.jsxs(i.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(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:b,onChange:t=>O(t.target.value),className:"w-full pl-11 pr-4 py-2.5 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:n.teacher.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs(i.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(Ce,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:"email",placeholder:"your.email@school.edu",value:l,onChange:t=>m(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(i.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(se,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(L,{type:P?"text":"password",placeholder:"••••••••",value:u,onChange:t=>z(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:o?8:6}),e.jsx(i.button,{type:"button",onClick:()=>ne(!P),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:P?e.jsx(Ie,{size:16}):e.jsx(Le,{size:16})})]}),o&&u.length>0&&!Z&&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:C.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))})]})]}),e.jsx(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(Se,{type:"submit",disabled:V,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(i.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:[V?"Please wait...":o?"Create Account":"Sign In",e.jsx(ae,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{_(!o),p(null)},className:"text-sm text-slate-400 hover:text-sky-500 font-body font-medium transition-colors",children:o?"Already have an account? Sign in":"Don't have an account? Create one"})})]}),!o&&e.jsxs(i.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:ve.map(t=>{const r=t.icon,d={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},x={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(i.button,{type:"button",onClick:()=>je(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 ${d[t.color]}`,children:e.jsx(r,{size:15,className:x[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(ae,{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(i.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(se,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{at as default}; diff --git a/assets/LogoutActionButton-USB3vnm6.js b/assets/LogoutActionButton-ynXvSPMf.js similarity index 94% rename from assets/LogoutActionButton-USB3vnm6.js rename to assets/LogoutActionButton-ynXvSPMf.js index 1714b3fd835cfc04d86176f9bdcd3a4ae0a74d34..8ef4668b9d3c862da9e78a95986916ecd10b8f57 100644 --- a/assets/LogoutActionButton-USB3vnm6.js +++ b/assets/LogoutActionButton-ynXvSPMf.js @@ -1,4 +1,4 @@ -import{e,m as r,n as l}from"./index-dPnhhJ9w.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as n}from"./log-out-BUfoSJF2.js";/** +import{e,m as r,n as l}from"./index-CGNBpSmO.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as n}from"./log-out-G6mObnLf.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ModuleFolderCard-BDMyLDzi.js b/assets/ModuleFolderCard-dHGX9Tik.js similarity index 93% rename from assets/ModuleFolderCard-BDMyLDzi.js rename to assets/ModuleFolderCard-dHGX9Tik.js index ddfd3f72cd8d0d6efff4717ba5f78d2381e0f22d..b306e8d45c79980c528a2a83f23d1db6eef56d7b 100644 --- a/assets/ModuleFolderCard-BDMyLDzi.js +++ b/assets/ModuleFolderCard-dHGX9Tik.js @@ -1,6 +1,6 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{u}from"./useSubjectAvailability-D0TkEgbI.js";import{e as w,m as f,a as j,x as v,L as y}from"./index-dPnhhJ9w.js";import{C as k}from"./clock-Dy5eVj9o.js";/** +import{j as e}from"./vendor-react-B4AQeu28.js";import{u}from"./useSubjectAvailability-iyC7Wdl7.js";import{e as w,m as f,b as j,x as v,L as y}from"./index-CGNBpSmO.js";import{C as k}from"./clock-D2bky9WI.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 N=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],B=w("link-2",N),n=[{bg:"bg-[#9956DE]",tab:"bg-[#8544c7]",shadow:"shadow-[#9956DE]/30"},{bg:"bg-[#1FA7E1]",tab:"bg-[#158abf]",shadow:"shadow-[#1FA7E1]/30"},{bg:"bg-[#FFB356]",tab:"bg-[#e69940]",shadow:"shadow-[#FFB356]/30"},{bg:"bg-[#FB96BB]",tab:"bg-[#df7b9e]",shadow:"shadow-[#FB96BB]/30"},{bg:"bg-[#75D06A]",tab:"bg-[#62b658]",shadow:"shadow-[#75D06A]/30"},{bg:"bg-[#FF8B8B]",tab:"bg-[#e67070]",shadow:"shadow-[#FF8B8B]/30"}],E=({module:t,index:x,onClick:l,onPreviewSources:r,isAtRisk:m,badgeLabel:o,precomputedAvailable:d,isRecommended:c})=>{const i=n[x%n.length],p=`${t.active_grade_level??""} · ${t.subject??"Module"} ${t.quarter??""}`.trim(),b=d===void 0,{isSubjectAvailable:h}=u(),g=d!==void 0?d:b?h(t.subjectId):!0,s=t.isAvailable!==!1&&g;return e.jsxs(f.div,{role:s?"button":"img",tabIndex:s?0:-1,whileHover:s?{y:-8}:void 0,onClick:s?l:void 0,onKeyDown:s?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),l())}:void 0,className:`relative text-left rounded-2xl md:rounded-[1.4rem] overflow-visible h-full min-h-[185px] md:min-h-[290px] bg-transparent group w-full flex flex-col ${s?"cursor-pointer":"cursor-not-allowed"}`,children:[e.jsx("div",{className:`absolute top-0 left-3 md:left-4 h-5 md:h-7 w-20 md:w-32 rounded-t-lg md:rounded-t-xl shadow-sm transition-colors duration-300 ${i.tab}`}),e.jsxs("div",{className:`relative mt-4 md:mt-6 rounded-2xl md:rounded-[1.4rem] p-3.5 md:p-6 transition-all duration-300 overflow-hidden flex flex-col h-[calc(100%-16px)] md:h-[calc(100%-24px)] flex-1 ${i.bg} shadow-[0_18px_30px_-20px_rgba(0,0,0,0.45)] group-hover:shadow-[0_24px_40px_-15px_rgba(0,0,0,0.5)]`,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 mix-blend-overlay bg-white/40"}),e.jsx("div",{className:"absolute -bottom-8 right-[-20%] w-48 h-48 bg-white opacity-10 rounded-full transition-transform duration-500 group-hover:scale-110"}),e.jsx("div",{className:"absolute bottom-4 right-12 w-32 h-32 bg-white opacity-10 rounded-full transition-transform duration-500 group-hover:scale-110 delay-75"}),e.jsxs("div",{className:"relative z-10 flex-1 flex flex-col h-full",children:[e.jsx("div",{className:"flex items-start justify-end",children:(o||t.status==="Locked")&&e.jsx("span",{className:"px-2.5 py-1 rounded-full bg-black/30 text-white/90 text-[10px] font-black uppercase tracking-wider backdrop-blur-sm",children:o||"Locked"})}),e.jsx("h3",{className:"text-base md:text-[22px] font-display font-black text-white leading-[1.15] md:leading-[1.1] mb-1.5 md:mb-2 drop-shadow-sm pr-4 line-clamp-2",children:t.title}),e.jsxs("div",{className:"mb-2 md:mb-3 flex flex-wrap gap-1 md:gap-1.5",children:[e.jsx("span",{className:"rounded-full border border-white/20 bg-black/15 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-white/95 leading-none",children:p}),t.content_domain&&e.jsx("span",{className:"rounded-full border border-white/20 bg-black/15 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-white/95 leading-none",children:t.content_domain}),c&&e.jsx("span",{className:"rounded-full border border-purple-200 bg-purple-100 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-purple-700 shadow-sm animate-pulse leading-none",children:"Recommended"})]}),e.jsx("p",{className:"text-white/85 text-[10px] md:text-[13px] line-clamp-1 md:line-clamp-2 mb-2 md:mb-4 font-medium leading-snug md:leading-relaxed pr-2",children:t.subtitle||t.description||"Master this module to unlock the next level of your mathematical journey."}),e.jsxs("div",{className:"mt-auto space-y-2 md:space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-white font-bold text-[10px] md:text-[12px] mb-1 md:mb-1.5 drop-shadow-sm",children:[e.jsx("span",{className:"opacity-90 uppercase tracking-wider",children:"Progress"}),e.jsxs("span",{children:[t.progress>0?t.progress:0,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 md:h-2 rounded-full bg-black/20 overflow-hidden shadow-inner",children:e.jsx("div",{className:"h-full bg-white rounded-full transition-all duration-1000 ease-out e-w",style:{"--w":`${t.progress>0?t.progress:0}%`}})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1.5 md:gap-2",children:[e.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-1 md:gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1 px-1.5 md:px-2 py-0.5 md:py-1 bg-white/20 rounded-md md:rounded-lg text-white font-bold text-[9px] md:text-[11px] backdrop-blur-sm shadow-sm border border-white/10",children:[e.jsx(j,{size:10,className:"md:w-3 md:h-3 opacity-90"})," ",t.totalLessons||t.lessons?.length||0," lessons"]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5 md:px-2 py-0.5 md:py-1 bg-white/20 rounded-md md:rounded-lg text-white font-bold text-[9px] md:text-[11px] backdrop-blur-sm shadow-sm border border-white/10",children:[e.jsx(k,{size:10,className:"md:w-3 md:h-3 opacity-90"})," ",t.totalQuizzes||t.quizzes?.length||0," quizzes"]})]}),r&&e.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),r()},className:"flex shrink-0 items-center gap-0.5 md:gap-1 rounded-md md:rounded-lg bg-black/20 hover:bg-black/40 px-1.5 md:px-2 py-1 font-bold uppercase tracking-wider text-white transition-all shadow-sm border border-white/10 leading-none text-[7px] md:text-[8px]",children:[e.jsx(B,{size:8,className:"md:w-[10px] md:h-[10px]"}),"SOURCE"]})]})]}),m&&e.jsxs("div",{className:"absolute -top-3 -right-2 bg-rose-500 text-white px-3 py-1.5 rounded-full text-[11px] font-black uppercase tracking-wider flex items-center gap-1.5 shadow-lg border border-rose-400 animate-pulse",children:[e.jsx(v,{size:12,strokeWidth:3})," Review"]}),!s&&e.jsx("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center rounded-[1.4rem] bg-black/60 backdrop-blur-[2px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 md:gap-3",children:[e.jsx("div",{className:"w-10 h-10 md:w-14 md:h-14 rounded-xl md:rounded-2xl bg-white/10 border border-white/20 flex items-center justify-center backdrop-blur-md",children:e.jsx(y,{className:"w-5 h-5 md:w-7 md:h-7 text-white"})}),e.jsxs("div",{className:"text-center px-2",children:[e.jsx("p",{className:"text-white font-black text-xs md:text-sm tracking-wide",children:"Content Unavailable"}),e.jsx("p",{className:"text-white/70 text-[9px] md:text-[11px] font-semibold mt-0.5 md:mt-1 max-w-[140px] md:max-w-[180px] mx-auto leading-tight",children:"Teaching module PDF not yet loaded."})]})]})})]})]})]})};export{E as M}; + */const N=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],B=w("link-2",N),n=[{bg:"bg-[#9956DE]",tab:"bg-[#8544c7]",shadow:"shadow-[#9956DE]/30"},{bg:"bg-[#1FA7E1]",tab:"bg-[#158abf]",shadow:"shadow-[#1FA7E1]/30"},{bg:"bg-[#FFB356]",tab:"bg-[#e69940]",shadow:"shadow-[#FFB356]/30"},{bg:"bg-[#FB96BB]",tab:"bg-[#df7b9e]",shadow:"shadow-[#FB96BB]/30"},{bg:"bg-[#75D06A]",tab:"bg-[#62b658]",shadow:"shadow-[#75D06A]/30"},{bg:"bg-[#FF8B8B]",tab:"bg-[#e67070]",shadow:"shadow-[#FF8B8B]/30"}],E=({module:t,index:x,onClick:l,onPreviewSources:r,isAtRisk:m,badgeLabel:o,precomputedAvailable:a,isRecommended:c})=>{const i=n[x%n.length],p=`${t.active_grade_level??""} · ${t.subject??"Module"} ${t.quarter??""}`.trim(),b=a===void 0,{isSubjectAvailable:h}=u(),g=a!==void 0?a:b?h(t.subjectId):!0,s=t.isAvailable!==!1&&g;return e.jsxs(f.div,{role:s?"button":"img",tabIndex:s?0:-1,whileHover:s?{y:-8}:void 0,onClick:s?l:void 0,onKeyDown:s?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),l())}:void 0,className:`relative text-left rounded-2xl md:rounded-[1.4rem] overflow-visible h-full min-h-[185px] md:min-h-[290px] bg-transparent group w-full flex flex-col ${s?"cursor-pointer":"cursor-not-allowed"}`,children:[e.jsx("div",{className:`absolute top-0 left-3 md:left-4 h-5 md:h-7 w-20 md:w-32 rounded-t-lg md:rounded-t-xl shadow-sm transition-colors duration-300 ${i.tab}`}),e.jsxs("div",{className:`relative mt-4 md:mt-6 rounded-2xl md:rounded-[1.4rem] p-3.5 md:p-6 transition-all duration-300 overflow-hidden flex flex-col h-[calc(100%-16px)] md:h-[calc(100%-24px)] flex-1 ${i.bg} shadow-[0_18px_30px_-20px_rgba(0,0,0,0.45)] group-hover:shadow-[0_24px_40px_-15px_rgba(0,0,0,0.5)]`,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 mix-blend-overlay bg-white/40"}),e.jsx("div",{className:"absolute -bottom-8 right-[-20%] w-48 h-48 bg-white opacity-10 rounded-full transition-transform duration-500 group-hover:scale-110"}),e.jsx("div",{className:"absolute bottom-4 right-12 w-32 h-32 bg-white opacity-10 rounded-full transition-transform duration-500 group-hover:scale-110 delay-75"}),e.jsxs("div",{className:"relative z-10 flex-1 flex flex-col h-full",children:[e.jsx("div",{className:"flex items-start justify-end",children:(o||t.status==="Locked")&&e.jsx("span",{className:"px-2.5 py-1 rounded-full bg-black/30 text-white/90 text-[10px] font-black uppercase tracking-wider backdrop-blur-sm",children:o||"Locked"})}),e.jsx("h3",{className:"text-base md:text-[22px] font-display font-black text-white leading-[1.15] md:leading-[1.1] mb-1.5 md:mb-2 drop-shadow-sm pr-4 line-clamp-2",children:t.title}),e.jsxs("div",{className:"mb-2 md:mb-3 flex flex-wrap gap-1 md:gap-1.5",children:[e.jsx("span",{className:"rounded-full border border-white/20 bg-black/15 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-white/95 leading-none",children:p}),t.content_domain&&e.jsx("span",{className:"rounded-full border border-white/20 bg-black/15 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-white/95 leading-none",children:t.content_domain}),c&&e.jsx("span",{className:"rounded-full border border-purple-200 bg-purple-100 px-2 md:px-2.5 py-0.5 md:py-1 text-[9px] md:text-[10px] font-bold text-purple-700 shadow-sm animate-pulse leading-none",children:"Recommended"})]}),e.jsx("p",{className:"text-white/85 text-[10px] md:text-[13px] line-clamp-1 md:line-clamp-2 mb-2 md:mb-4 font-medium leading-snug md:leading-relaxed pr-2",children:t.subtitle||t.description||"Master this module to unlock the next level of your mathematical journey."}),e.jsxs("div",{className:"mt-auto space-y-2 md:space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-white font-bold text-[10px] md:text-[12px] mb-1 md:mb-1.5 drop-shadow-sm",children:[e.jsx("span",{className:"opacity-90 uppercase tracking-wider",children:"Progress"}),e.jsxs("span",{children:[t.progress>0?t.progress:0,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 md:h-2 rounded-full bg-black/20 overflow-hidden shadow-inner",children:e.jsx("div",{className:"h-full bg-white rounded-full transition-all duration-1000 ease-out e-w",style:{"--w":`${t.progress>0?t.progress:0}%`}})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1.5 md:gap-2",children:[e.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-1 md:gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1 px-1.5 md:px-2 py-0.5 md:py-1 bg-white/20 rounded-md md:rounded-lg text-white font-bold text-[9px] md:text-[11px] backdrop-blur-sm shadow-sm border border-white/10",children:[e.jsx(j,{size:10,className:"md:w-3 md:h-3 opacity-90"})," ",t.totalLessons||t.lessons?.length||0," lessons"]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5 md:px-2 py-0.5 md:py-1 bg-white/20 rounded-md md:rounded-lg text-white font-bold text-[9px] md:text-[11px] backdrop-blur-sm shadow-sm border border-white/10",children:[e.jsx(k,{size:10,className:"md:w-3 md:h-3 opacity-90"})," ",t.totalQuizzes||t.quizzes?.length||0," quizzes"]})]}),r&&e.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),r()},className:"flex shrink-0 items-center gap-0.5 md:gap-1 rounded-md md:rounded-lg bg-black/20 hover:bg-black/40 px-1.5 md:px-2 py-1 font-bold uppercase tracking-wider text-white transition-all shadow-sm border border-white/10 leading-none text-[7px] md:text-[8px]",children:[e.jsx(B,{size:8,className:"md:w-[10px] md:h-[10px]"}),"SOURCE"]})]})]}),m&&e.jsxs("div",{className:"absolute -top-3 -right-2 bg-rose-500 text-white px-3 py-1.5 rounded-full text-[11px] font-black uppercase tracking-wider flex items-center gap-1.5 shadow-lg border border-rose-400 animate-pulse",children:[e.jsx(v,{size:12,strokeWidth:3})," Review"]}),!s&&e.jsx("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center rounded-[1.4rem] bg-black/60 backdrop-blur-[2px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 md:gap-3",children:[e.jsx("div",{className:"w-10 h-10 md:w-14 md:h-14 rounded-xl md:rounded-2xl bg-white/10 border border-white/20 flex items-center justify-center backdrop-blur-md",children:e.jsx(y,{className:"w-5 h-5 md:w-7 md:h-7 text-white"})}),e.jsxs("div",{className:"text-center px-2",children:[e.jsx("p",{className:"text-white font-black text-xs md:text-sm tracking-wide",children:"Content Unavailable"}),e.jsx("p",{className:"text-white/70 text-[9px] md:text-[11px] font-semibold mt-0.5 md:mt-1 max-w-[140px] md:max-w-[180px] mx-auto leading-tight",children:"Teaching module PDF not yet loaded."})]})]})})]})]})]})};export{E as M}; diff --git a/assets/ModulesPage-TA1UiY8-.js b/assets/ModulesPage--hVGaLzB.js similarity index 99% rename from assets/ModulesPage-TA1UiY8-.js rename to assets/ModulesPage--hVGaLzB.js index 60084f55110d1ca8a11882ca33824ea046ac4c79..f59c117622734f1622be695c8ce1033f38b0c9d1 100644 --- a/assets/ModulesPage-TA1UiY8-.js +++ b/assets/ModulesPage--hVGaLzB.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-core-D7GXCeNu.js"])))=>i.map(i=>d[i]); -import{r as s,j as e,b as Ct,d as Te,c as aa}from"./vendor-react-B4AQeu28.js";import{u as ra}from"./useQuery-C1X-hCq5.js";import{getDoc as Kt,doc as zt,onSnapshot as ts,runTransaction as la,serverTimestamp as na,query as ia,where as oa,collection as ca}from"./vendor-firebase-firestore-CNv3xXal.js";import{e as pe,m as S,Z as rt,C as Nt,h as tt,X as qs,M as da,b as bt,T as At,q as it,a5 as ss,R as Hs,E as Bt,_ as as,v as qt,I as ma,N as xa,u as Ht,A as Pt,a as Je,n as It,x as Os,ab as hs,ac as ua,ad as fs,ae as pa,p as Qs,af as ha,L as Ws,g as ct,B as fa,ag as ba,ah as ga,ai as Us,aj as wa,ak as ya,al as ja,a9 as va,w as Na,am as bs,an as ka,ao as gs,G as Ca,j as Mt,a7 as Sa,aa as za}from"./index-dPnhhJ9w.js";import{M as Zt}from"./ModuleFolderCard-BDMyLDzi.js";import{B as Fe}from"./button-WbM5w2Bp.js";import rs from"./ScientificCalculator-Cc_fXNNW.js";import{C as Dt}from"./check-CAUeuCaw.js";import{X as et}from"./x-Ck4mo_h-.js";import{V as Ft,a as Rt,M as ls,b as ns}from"./volume-x-ChU-f35o.js";import{C as $t}from"./chevron-left-DfHtS3Om.js";import{C as qe}from"./chevron-right-DL17FiOB.js";import{C as Gs}from"./circle-help-BkKMcGF2.js";import{P as Xs,A as Jt,b as es,c as Ma,L as _a}from"./quizService-DyO77cdL.js";import{C as ot}from"./circle-check-big-DJBKLvuw.js";import{C as Et,L as kt}from"./lightbulb-RToQsqFn.js";import{logLessonView as Aa}from"./trackingService-DGIx7EWv.js";import{C as St}from"./clock-Dy5eVj9o.js";import{C as Ea}from"./clipboard-check-DfL2oC8x.js";import{s as Gt,S as ws}from"./subjects-DzQfiusb.js";import{C as Vs}from"./circle-check-BjsGkfB1.js";import{C as Ta}from"./chart-column-DtQRo3DE.js";import{D as Pa}from"./dollar-sign-CQIhGvzp.js";import{triggerQuizSubmitted as La}from"./automationService-aNpxrln-.js";import ys from"./confetti.module-C94ZD2ww.js";import{u as Ia}from"./useCurriculum-BbSzWiM_.js";import{S as Da}from"./search-DqYX8akO.js";import{F as Fa}from"./funnel-Bt7LE1rx.js";import{S as Ra}from"./sparkles-DPFO64ZX.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-D0TkEgbI.js";import"./chevron-up-D9yeZehY.js";/** +import{r as s,j as e,b as Ct,d as Te,c as aa}from"./vendor-react-B4AQeu28.js";import{u as ra}from"./useQuery-C7Nbsm2w.js";import{getDoc as Kt,doc as zt,onSnapshot as ts,runTransaction as la,serverTimestamp as na,query as ia,where as oa,collection as ca}from"./vendor-firebase-firestore-CNv3xXal.js";import{e as pe,m as S,Z as rt,C as Nt,h as tt,X as qs,M as da,a as bt,T as At,q as it,a5 as ss,R as Hs,E as Bt,_ as as,v as qt,I as ma,N as xa,u as Ht,A as Pt,b as Je,n as It,x as Os,ab as hs,ac as ua,ad as fs,ae as pa,p as Qs,af as ha,L as Ws,g as ct,B as fa,ag as ba,ah as ga,ai as Us,aj as wa,ak as ya,al as ja,a9 as va,w as Na,am as bs,an as ka,ao as gs,G as Ca,j as Mt,a7 as Sa,aa as za}from"./index-CGNBpSmO.js";import{M as Zt}from"./ModuleFolderCard-dHGX9Tik.js";import{B as Fe}from"./button-DVjn4LkC.js";import rs from"./ScientificCalculator-Bdrlg1Yp.js";import{C as Dt}from"./check-BfYhdun3.js";import{X as et}from"./x-Deb9zs8O.js";import{V as Ft,a as Rt,M as ls,b as ns}from"./volume-x-BprCnnkN.js";import{C as $t}from"./chevron-left-BuATOj9f.js";import{C as qe}from"./chevron-right-C39hNstc.js";import{C as Gs}from"./circle-help-DMiD6EQw.js";import{P as Xs,A as Jt,b as es,c as Ma,L as _a}from"./quizService-CuH9jeN9.js";import{C as ot}from"./circle-check-big-yCNC9yfs.js";import{C as Et,L as kt}from"./lightbulb-CrdekHc8.js";import{logLessonView as Aa}from"./trackingService-mnaKocvn.js";import{C as St}from"./clock-D2bky9WI.js";import{C as Ea}from"./clipboard-check-DSPNHJXj.js";import{s as Gt,S as ws}from"./subjects-DP2R71lN.js";import{C as Vs}from"./circle-check-BhLH88x1.js";import{C as Ta}from"./chart-column-g5DztEPT.js";import{D as Pa}from"./dollar-sign-CZpwYJk-.js";import{triggerQuizSubmitted as La}from"./automationService-BaY4ockN.js";import ys from"./confetti.module-C94ZD2ww.js";import{u as Ia}from"./useCurriculum-cH2ZLq43.js";import{S as Da}from"./search-C_DiQDej.js";import{F as Fa}from"./funnel-pOzgdLsf.js";import{S as Ra}from"./sparkles-C0ju-UTT.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-iyC7Wdl7.js";import"./chevron-up-B59xV3SY.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/NotificationDropdown-CMhB7x-Z.js b/assets/NotificationDropdown-DGCnp7MU.js similarity index 93% rename from assets/NotificationDropdown-CMhB7x-Z.js rename to assets/NotificationDropdown-DGCnp7MU.js index 41dfd2640f0035b118fd1d26945cc2cfa8168d3b..96d35a803c174994afdd7f88c45a2650037cf23d 100644 --- a/assets/NotificationDropdown-CMhB7x-Z.js +++ b/assets/NotificationDropdown-DGCnp7MU.js @@ -1,4 +1,4 @@ -import{e as a,D as b,u as N,h as w,m as y,b as j,U as k}from"./index-dPnhhJ9w.js";import{r as _,j as e}from"./vendor-react-B4AQeu28.js";import"./vendor-firebase-firestore-CNv3xXal.js";import{C as g,f as v}from"./formatDistanceToNow-JAG-bydR.js";import{B as n}from"./bell-cxZiilDJ.js";import{C}from"./circle-check-BjsGkfB1.js";import{C as A}from"./circle-alert-DCyh_PVA.js";import{S as M}from"./sparkles-DPFO64ZX.js";/** +import{e as a,D as b,u as N,h as w,m as y,a as j,U as k}from"./index-CGNBpSmO.js";import{r as _,j as e}from"./vendor-react-B4AQeu28.js";import"./vendor-firebase-firestore-CNv3xXal.js";import{C as g,f as v}from"./formatDistanceToNow-Csp8CCDy.js";import{B as n}from"./bell-DbwiSyKd.js";import{C}from"./circle-check-BhLH88x1.js";import{C as A}from"./circle-alert-fZn6_hMx.js";import{S as M}from"./sparkles-C0ju-UTT.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ProfileModal-BDGytXZz.js b/assets/ProfileModal-Jm1jfkzc.js similarity index 96% rename from assets/ProfileModal-BDGytXZz.js rename to assets/ProfileModal-Jm1jfkzc.js index ec544353135d261a7f603fcf68b9b93661e656fb..5f6317840bb518ec03fd099d5cd2523704dade83 100644 --- a/assets/ProfileModal-BDGytXZz.js +++ b/assets/ProfileModal-Jm1jfkzc.js @@ -1,4 +1,4 @@ -import{r,j as e}from"./vendor-react-B4AQeu28.js";import{e as R,h as U,m as k,U as u,A as x,a as w,F as _,$ as D,aJ as T,aS as B,j as $}from"./index-dPnhhJ9w.js";import{B as b}from"./button-WbM5w2Bp.js";import{I as d}from"./input-BUQJctP7.js";import{S as q,a as G,c as V,d as p}from"./select-Ca_HQeg8.js";import{P as X,M as z,V as C}from"./ProfilePictureUploader-BaBXPmnP.js";import{X as Y}from"./x-Ck4mo_h-.js";import{M as H}from"./mail-DiIt1YFo.js";import{C as L}from"./circle-help-BkKMcGF2.js";import{S as J}from"./save-DxX0wJjA.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-D9yeZehY.js";import"./check-CAUeuCaw.js";import"./minus-BpJABcv4.js";import"./plus-BIEera7J.js";import"./upload-Dezt40XU.js";/** +import{r,j as e}from"./vendor-react-B4AQeu28.js";import{e as R,h as U,m as k,U as u,A as x,b as w,F as _,$ as D,aJ as T,aS as B,j as $}from"./index-CGNBpSmO.js";import{B as b}from"./button-DVjn4LkC.js";import{I as d}from"./input-CBi6xF4I.js";import{S as q,a as G,c as V,d as p}from"./select-3FfJraPy.js";import{P as X,M as z,V as C}from"./ProfilePictureUploader-CCiptDXE.js";import{X as Y}from"./x-Deb9zs8O.js";import{M as H}from"./mail-C1tKDR_N.js";import{C as L}from"./circle-help-DMiD6EQw.js";import{S as J}from"./save-CNayyZ15.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-B59xV3SY.js";import"./check-BfYhdun3.js";import"./minus-DV5fnWn8.js";import"./plus-ck_SGnHK.js";import"./upload-Daz-vKaw.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ProfilePictureUploader-BaBXPmnP.js b/assets/ProfilePictureUploader-CCiptDXE.js similarity index 98% rename from assets/ProfilePictureUploader-BaBXPmnP.js rename to assets/ProfilePictureUploader-CCiptDXE.js index 6561430bbb728b969b71545c73d9fa240ac52065..4fc6c5f2b352e7d38a1a72db64a2ff57795ffbbc 100644 --- a/assets/ProfilePictureUploader-BaBXPmnP.js +++ b/assets/ProfilePictureUploader-CCiptDXE.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{e as V,n as B,N as K,_ as $,b1 as ge,b2 as we,u as xe,Q as ye,V as be,W as Ce,h as Pe,m as J,j as Q}from"./index-dPnhhJ9w.js";import{g as Re,r as x,j as p}from"./vendor-react-B4AQeu28.js";import{_ as Ee,o as b,p as Se,q as _e,r as ze,s as De}from"./vendor-radix-BPuEd8FG.js";import{B as ee}from"./button-WbM5w2Bp.js";import{updateProfile as Me}from"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-core-D7GXCeNu.js";import{r as Ae,u as Te,a as Ne}from"./vendor-firebase-storage-Bi7H_66d.js";import{X as je}from"./x-Ck4mo_h-.js";import{M as Ue}from"./minus-BpJABcv4.js";import{P as Fe}from"./plus-BIEera7J.js";import{U as Ie}from"./upload-Dezt40XU.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{e as V,n as B,N as K,_ as $,b1 as ge,b2 as we,u as xe,Q as ye,V as be,W as Ce,h as Pe,m as J,j as Q}from"./index-CGNBpSmO.js";import{g as Re,r as x,j as p}from"./vendor-react-B4AQeu28.js";import{_ as Ee,o as b,p as Se,q as _e,r as ze,s as De}from"./vendor-radix-BPuEd8FG.js";import{B as ee}from"./button-DVjn4LkC.js";import{updateProfile as Me}from"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-core-D7GXCeNu.js";import{r as Ae,u as Te,a as Ne}from"./vendor-firebase-storage-Bi7H_66d.js";import{X as je}from"./x-Deb9zs8O.js";import{M as Ue}from"./minus-DV5fnWn8.js";import{P as Fe}from"./plus-ck_SGnHK.js";import{U as Ie}from"./upload-Daz-vKaw.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. @@ -107,4 +107,4 @@ import{e as V,n as B,N as K,_ as $,b1 as ge,b2 as we,u as xe,Q as ye,V as be,W a border-left: 0; border-right: 0; } -`,nt=1,at=3,st=1,ct=(function(a){Ee(o,a);function o(){var e=a!==null&&a.apply(this,arguments)||this;return e.cropperRef=x.createRef(),e.imageRef=x.createRef(),e.videoRef=x.createRef(),e.containerPosition={x:0,y:0},e.containerRef=null,e.styleRef=null,e.containerRect=null,e.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},e.dragStartPosition={x:0,y:0},e.dragStartCrop={x:0,y:0},e.gestureZoomStart=0,e.gestureRotationStart=0,e.isTouching=!1,e.lastPinchDistance=0,e.lastPinchRotation=0,e.rafDragTimeout=null,e.rafPinchTimeout=null,e.wheelTimer=null,e.currentDoc=typeof document<"u"?document:null,e.currentWindow=typeof window<"u"?window:null,e.resizeObserver=null,e.previousCropSize=null,e.isInitialized=!1,e.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},e.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!e.containerRef)){var t=!0;e.resizeObserver=new window.ResizeObserver(function(r){if(t){t=!1;return}e.computeSizes()}),e.resizeObserver.observe(e.containerRef)}},e.preventZoomSafari=function(t){return t.preventDefault()},e.cleanEvents=function(){e.currentDoc&&(e.currentDoc.removeEventListener("mousemove",e.onMouseMove),e.currentDoc.removeEventListener("mouseup",e.onDragStopped),e.currentDoc.removeEventListener("touchmove",e.onTouchMove),e.currentDoc.removeEventListener("touchend",e.onDragStopped),e.currentDoc.removeEventListener("gesturechange",e.onGestureChange),e.currentDoc.removeEventListener("gestureend",e.onGestureEnd),e.currentDoc.removeEventListener("scroll",e.onScroll))},e.clearScrollEvent=function(){e.containerRef&&e.containerRef.removeEventListener("wheel",e.onWheel),e.wheelTimer&&clearTimeout(e.wheelTimer)},e.onMediaLoad=function(){var t=e.computeSizes();t&&(e.previousCropSize=t,e.emitCropData(),e.setInitialCrop(t),e.isInitialized=!0),e.props.onMediaLoaded&&e.props.onMediaLoaded(e.mediaSize)},e.setInitialCrop=function(t){if(e.props.initialCroppedAreaPercentages){var r=et(e.props.initialCroppedAreaPercentages,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=r.crop,n=r.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(n)}else if(e.props.initialCroppedAreaPixels){var s=rt(e.props.initialCroppedAreaPixels,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=s.crop,n=s.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(n)}},e.computeSizes=function(){var t,r,i,n,s,c,l=e.imageRef.current||e.videoRef.current;if(l&&e.containerRef){e.containerRect=e.containerRef.getBoundingClientRect(),e.saveContainerPosition();var u=e.containerRect.width/e.containerRect.height,h=((t=e.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((r=e.videoRef.current)===null||r===void 0?void 0:r.videoWidth)||0,d=((i=e.imageRef.current)===null||i===void 0?void 0:i.naturalHeight)||((n=e.videoRef.current)===null||n===void 0?void 0:n.videoHeight)||0,m=l.offsetWidthw?{width:e.containerRect.height*w,height:e.containerRect.height}:{width:e.containerRect.width,height:e.containerRect.width/w};break;case"horizontal-cover":v={width:e.containerRect.width,height:e.containerRect.width/w};break;case"vertical-cover":v={width:e.containerRect.height*w,height:e.containerRect.height};break}else v={width:l.offsetWidth,height:l.offsetHeight};e.mediaSize=b(b({},v),{naturalWidth:h,naturalHeight:d}),e.props.setMediaSize&&e.props.setMediaSize(e.mediaSize);var f=e.props.cropSize?e.props.cropSize:Xe(e.mediaSize.width,e.mediaSize.height,e.containerRect.width,e.containerRect.height,e.props.aspect,e.props.rotation);return(((s=e.state.cropSize)===null||s===void 0?void 0:s.height)!==f.height||((c=e.state.cropSize)===null||c===void 0?void 0:c.width)!==f.width)&&e.props.onCropSizeChange&&e.props.onCropSizeChange(f),e.setState({cropSize:f},e.recomputeCropPosition),e.props.setCropSize&&e.props.setCropSize(f),f}},e.saveContainerPosition=function(){if(e.containerRef){var t=e.containerRef.getBoundingClientRect();e.containerPosition={x:t.left,y:t.top}}},e.onMouseDown=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("mousemove",e.onMouseMove),e.currentDoc.addEventListener("mouseup",e.onDragStopped),e.saveContainerPosition(),e.onDragStart(o.getMousePoint(t)))},e.onMouseMove=function(t){return e.onDrag(o.getMousePoint(t))},e.onScroll=function(t){e.currentDoc&&(t.preventDefault(),e.saveContainerPosition())},e.onTouchStart=function(t){e.currentDoc&&(e.isTouching=!0,!(e.props.onTouchRequest&&!e.props.onTouchRequest(t))&&(e.currentDoc.addEventListener("touchmove",e.onTouchMove,{passive:!1}),e.currentDoc.addEventListener("touchend",e.onDragStopped),e.saveContainerPosition(),t.touches.length===2?e.onPinchStart(t):t.touches.length===1&&e.onDragStart(o.getTouchPoint(t.touches[0]))))},e.onTouchMove=function(t){t.preventDefault(),t.touches.length===2?e.onPinchMove(t):t.touches.length===1&&e.onDrag(o.getTouchPoint(t.touches[0]))},e.onGestureStart=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("gesturechange",e.onGestureChange),e.currentDoc.addEventListener("gestureend",e.onGestureEnd),e.gestureZoomStart=e.props.zoom,e.gestureRotationStart=e.props.rotation)},e.onGestureChange=function(t){if(t.preventDefault(),!e.isTouching){var r=o.getMousePoint(t),i=e.gestureZoomStart-1+t.scale;if(e.setNewZoom(i,r,{shouldUpdatePosition:!0}),e.props.onRotationChange){var n=e.gestureRotationStart+t.rotation;e.props.onRotationChange(n)}}},e.onGestureEnd=function(t){e.cleanEvents()},e.onDragStart=function(t){var r,i,n=t.x,s=t.y;e.dragStartPosition={x:n,y:s},e.dragStartCrop=b({},e.props.crop),(i=(r=e.props).onInteractionStart)===null||i===void 0||i.call(r)},e.onDrag=function(t){var r=t.x,i=t.y;e.currentWindow&&(e.rafDragTimeout&&e.currentWindow.cancelAnimationFrame(e.rafDragTimeout),e.rafDragTimeout=e.currentWindow.requestAnimationFrame(function(){if(e.state.cropSize&&!(r===void 0||i===void 0)){var n=r-e.dragStartPosition.x,s=i-e.dragStartPosition.y,c={x:e.dragStartCrop.x+n,y:e.dragStartCrop.y+s},l=e.props.restrictPosition?N(c,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):c;e.props.onCropChange(l)}}))},e.onDragStopped=function(){var t,r;e.isTouching=!1,e.cleanEvents(),e.emitCropData(),(r=(t=e.props).onInteractionEnd)===null||r===void 0||r.call(t)},e.onWheel=function(t){if(e.currentWindow&&!(e.props.onWheelRequest&&!e.props.onWheelRequest(t))){t.preventDefault();var r=o.getMousePoint(t),i=Ye(t).pixelY,n=e.props.zoom-i*e.props.zoomSpeed/200;e.setNewZoom(n,r,{shouldUpdatePosition:!0}),e.state.hasWheelJustStarted||e.setState({hasWheelJustStarted:!0},function(){var s,c;return(c=(s=e.props).onInteractionStart)===null||c===void 0?void 0:c.call(s)}),e.wheelTimer&&clearTimeout(e.wheelTimer),e.wheelTimer=e.currentWindow.setTimeout(function(){return e.setState({hasWheelJustStarted:!1},function(){var s,c;return(c=(s=e.props).onInteractionEnd)===null||c===void 0?void 0:c.call(s)})},250)}},e.getPointOnContainer=function(t,r){var i=t.x,n=t.y;if(!e.containerRect)throw new Error("The Cropper is not mounted");return{x:e.containerRect.width/2-(i-r.x),y:e.containerRect.height/2-(n-r.y)}},e.getPointOnMedia=function(t){var r=t.x,i=t.y,n=e.props,s=n.crop,c=n.zoom;return{x:(r+s.x)/c,y:(i+s.y)/c}},e.setNewZoom=function(t,r,i){var n=i===void 0?{}:i,s=n.shouldUpdatePosition,c=s===void 0?!0:s;if(!(!e.state.cropSize||!e.props.onZoomChange)){var l=O(t,e.props.minZoom,e.props.maxZoom);if(c){var u=e.getPointOnContainer(r,e.containerPosition),h=e.getPointOnMedia(u),d={x:h.x*l-u.x,y:h.y*l-u.y},m=e.props.restrictPosition?N(d,e.mediaSize,e.state.cropSize,l,e.props.rotation):d;e.props.onCropChange(m)}e.props.onZoomChange(l)}},e.getCropData=function(){if(!e.state.cropSize)return null;var t=e.props.restrictPosition?N(e.props.crop,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):e.props.crop;return Ke(t,e.mediaSize,e.state.cropSize,e.getAspect(),e.props.zoom,e.props.rotation,e.props.restrictPosition)},e.emitCropData=function(){var t=e.getCropData();if(t){var r=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropComplete&&e.props.onCropComplete(r,i),e.props.onCropAreaChange&&e.props.onCropAreaChange(r,i)}},e.emitCropAreaChange=function(){var t=e.getCropData();if(t){var r=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropAreaChange&&e.props.onCropAreaChange(r,i)}},e.recomputeCropPosition=function(){var t,r;if(e.state.cropSize){var i=e.props.crop;if(e.isInitialized&&(!((t=e.previousCropSize)===null||t===void 0)&&t.width)&&(!((r=e.previousCropSize)===null||r===void 0)&&r.height)){var n=Math.abs(e.previousCropSize.width-e.state.cropSize.width)>1e-6||Math.abs(e.previousCropSize.height-e.state.cropSize.height)>1e-6;if(n){var s=e.state.cropSize.width/e.previousCropSize.width,c=e.state.cropSize.height/e.previousCropSize.height;i={x:e.props.crop.x*s,y:e.props.crop.y*c}}}var l=e.props.restrictPosition?N(i,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):i;e.previousCropSize=e.state.cropSize,e.props.onCropChange(l),e.emitCropData()}},e.onKeyDown=function(t){var r,i,n=e.props,s=n.crop,c=n.onCropChange,l=n.keyboardStep,u=n.zoom,h=n.rotation,d=l;if(e.state.cropSize){t.shiftKey&&(d*=.2);var m=b({},s);switch(t.key){case"ArrowUp":m.y-=d,t.preventDefault();break;case"ArrowDown":m.y+=d,t.preventDefault();break;case"ArrowLeft":m.x-=d,t.preventDefault();break;case"ArrowRight":m.x+=d,t.preventDefault();break;default:return}e.props.restrictPosition&&(m=N(m,e.mediaSize,e.state.cropSize,u,h)),t.repeat||(i=(r=e.props).onInteractionStart)===null||i===void 0||i.call(r),c(m)}},e.onKeyUp=function(t){var r,i;switch(t.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":t.preventDefault();break;default:return}e.emitCropData(),(i=(r=e.props).onInteractionEnd)===null||i===void 0||i.call(r)},e}return o.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=it,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},o.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)===null||t===void 0||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},o.prototype.componentDidUpdate=function(e){var t,r,i,n,s,c,l,u,h;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():((t=e.cropSize)===null||t===void 0?void 0:t.height)!==((r=this.props.cropSize)===null||r===void 0?void 0:r.height)||((i=e.cropSize)===null||i===void 0?void 0:i.width)!==((n=this.props.cropSize)===null||n===void 0?void 0:n.width)?this.computeSizes():(((s=e.crop)===null||s===void 0?void 0:s.x)!==((c=this.props.crop)===null||c===void 0?void 0:c.x)||((l=e.crop)===null||l===void 0?void 0:l.y)!==((u=this.props.crop)===null||u===void 0?void 0:u.y))&&this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((h=this.videoRef.current)===null||h===void 0||h.load());var d=this.getObjectFit();d!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:d},this.computeSizes)},o.prototype.getAspect=function(){var e=this.props,t=e.cropSize,r=e.aspect;return t?t.width/t.height:r},o.prototype.getObjectFit=function(){var e,t,r,i;if(this.props.objectFit==="cover"){var n=this.imageRef.current||this.videoRef.current;if(n&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var s=this.containerRect.width/this.containerRect.height,c=((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalWidth)||((t=this.videoRef.current)===null||t===void 0?void 0:t.videoWidth)||0,l=((r=this.imageRef.current)===null||r===void 0?void 0:r.naturalHeight)||((i=this.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,u=c/l;return uArray.isArray(e)?e:Array.isArray(o)?o:[t,r],[e,o,t,r]);return p.jsxs(Se,{"data-slot":"slider",defaultValue:o,value:e,min:t,max:r,className:B("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",a),...i,children:[p.jsx(_e,{"data-slot":"slider-track",className:B("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-4 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:p.jsx(ze,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:n.length},(s,c)=>p.jsx(De,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const de=["image/png","image/jpeg","image/webp"],he=2*1024*1024,fe=256,ut=a=>{const o=a.normalize("NFKD").toLowerCase(),e=o.lastIndexOf("."),t=e>0?o.slice(0,e):o,r=e>0?o.slice(e).replace(/[^.a-z0-9]/g,""):"";return`${t.replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"profile-picture"}${r}`},pt=(a,o,e=Date.now())=>`profile-pictures/${a}/${e}-${ut(o)}`,me=a=>de.includes(a.type)?a.size>he?"Profile pictures must be 2MB or smaller.":a.name.trim()?null:"Please choose a valid image file.":"Only PNG, JPEG, and WebP images are allowed.",dt=a=>new Promise((o,e)=>{const t=URL.createObjectURL(a),r=new Image,i=setTimeout(()=>{URL.revokeObjectURL(t),e(new Error("Image loading timed out. Please try a different file."))},15e3);r.onload=()=>{clearTimeout(i),URL.revokeObjectURL(t),o(r)},r.onerror=()=>{clearTimeout(i),URL.revokeObjectURL(t),e(new Error("Unable to read the selected image. Please try another file."))},r.crossOrigin="anonymous",r.src=t}),ue=(a,o,e)=>new Promise((t,r)=>{a.toBlob(i=>{if(!i){r(new Error("Failed to prepare the image for upload."));return}t(i)},o,e)}),ht=async(a,o=fe)=>{const e=await dt(a),t=document.createElement("canvas");t.width=o,t.height=o;const r=t.getContext("2d");if(!r)throw new Error("Your browser cannot process image uploads right now.");const i=e.naturalWidth||e.width,n=e.naturalHeight||e.height,s=Math.min(i,n),c=Math.max(0,(i-s)/2),l=Math.max(0,(n-s)/2);r.clearRect(0,0,o,o),r.drawImage(e,c,l,s,s,0,0,o,o);try{return await ue(t,"image/webp",.9)}catch{return await ue(t,"image/jpeg",.9)}},j=(a,o,e)=>{let t;const r=new Promise((i,n)=>{t=setTimeout(()=>n(new Error(`${e} timed out after ${Math.round(o/1e3)}s`)),o)});return Promise.race([a,r]).finally(()=>clearTimeout(t))},ft=async(a,o,e)=>{const t=we.options.projectId;if(!t)throw new Error("Firebase project ID is not configured.");const r=await a.getIdToken(),i=`https://firestore.googleapis.com/v1/projects/${t}/databases/(default)/documents/users/${o}?updateMask.fieldPaths=photo&updateMask.fieldPaths=updatedAt`,n=await fetch(i,{method:"PATCH",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({fields:{photo:{stringValue:e},updatedAt:{timestampValue:new Date().toISOString()}}})});if(!n.ok){const s=await n.text().catch(()=>"");throw new Error(`Firestore REST update failed (${n.status}): ${s}`)}},mt=async({file:a,uid:o,currentUser:e=K.currentUser,syncFirestore:t=!0})=>{const r=me(a);if(r)throw new Error(r);const i=e??K.currentUser;if(!i)throw new Error("You need to be signed in to change your profile picture.");const n=o||i.uid;if(!n)throw new Error("Unable to determine which profile should be updated.");if(i.uid!==n)throw new Error("The signed-in user does not match the profile being edited.");const s=await j(ht(a,fe),2e4,"Image processing"),c=pt(n,a.name),l=Ae(ge,c),u=await j(Te(l,s,{contentType:s.type||"image/webp",cacheControl:"public, max-age=31536000, immutable"}),3e4,"Storage upload"),h=await j(Ne(u.ref),1e4,"Download URL retrieval");try{await j(Me(i,{photoURL:h}),1e4,"Auth profile update")}catch(d){console.warn("[PROFILE UPLOAD] Auth profile update failed (non-fatal):",d)}if(t){try{await j(ft(i,n,h),1e4,"Firestore profile sync")}catch(d){console.error("[PROFILE UPLOAD] Firestore REST sync failed:",d),console.warn("[PROFILE UPLOAD] Photo was uploaded but the database record may be stale. It will refresh on next login.")}try{const{doc:d,updateDoc:m}=await $(async()=>{const{doc:v,updateDoc:f}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{doc:v,updateDoc:f}},__vite__mapDeps([0,1])),{db:w}=await $(async()=>{const{db:v}=await import("./index-dPnhhJ9w.js").then(f=>f.b5);return{db:v}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11]));await m(d(w,"leaderboard",n),{photo:h}).catch(()=>$(async()=>{const{setDoc:v}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{setDoc:v}},__vite__mapDeps([0,1])).then(({setDoc:v})=>v(d(w,"leaderboard",n),{photo:h},{merge:!0})))}catch{}}return h},vt=a=>`${(a/(1024*1024)).toFixed(1)} MB`,gt=a=>{const o=(a||"").trim();return o?o.split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()).join(""):"U"},wt=a=>new Promise((o,e)=>{const t=new Image;t.onload=()=>o(t),t.onerror=()=>e(new Error("Unable to load the image for cropping.")),t.src=a}),pe=(a,o,e)=>new Promise((t,r)=>{a.toBlob(i=>{if(!i){r(new Error("Failed to prepare the cropped image."));return}t(i)},o,e)}),xt=async(a,o,e)=>{const t=await wt(a),r=document.createElement("canvas"),i=640;r.width=i,r.height=i;const n=r.getContext("2d");if(!n)throw new Error("Your browser cannot process the selected image right now.");n.clearRect(0,0,i,i),n.drawImage(t,o.x,o.y,o.width,o.height,0,0,i,i);let s;try{s=await pe(r,"image/webp",.92)}catch{s=await pe(r,"image/jpeg",.92)}if(!s)throw new Error("Could not create an image from the cropped area.");const c=s.type==="image/webp"?"webp":"jpg",u=`${e.name.replace(/\.[^/.]+$/,"")||"profile-picture"}-cropped.${c}`;return new File([s],u,{type:s.type,lastModified:Date.now()})},Nt=({uid:a,photoURL:o,displayName:e,className:t="",onUploaded:r,syncFirestore:i=!0})=>{const{currentUser:n,refreshProfile:s}=xe(),[c,l]=x.useState(null),[u,h]=x.useState(null),[d,m]=x.useState({x:0,y:0}),[w,v]=x.useState(1),[f,R]=x.useState(null),[y,g]=x.useState(""),[E,_]=x.useState(!1),P=x.useRef(null);x.useEffect(()=>{if(!c){h(null);return}const C=URL.createObjectURL(c);return h(C),()=>URL.revokeObjectURL(C)},[c]);const W=u||o||"",k=x.useMemo(()=>`${de.map(S=>S.replace("image/","").toUpperCase()).join(", ")} up to ${vt(he)}. The image will be cropped to a circular avatar.`,[]),D=()=>{l(null),m({x:0,y:0}),v(1),R(null),g(""),P.current&&(P.current.value="")},z=C=>{const S=C.target.files?.[0]||null;if(!S)return;const M=me(S);if(M){g(M),l(null),C.target.value="";return}g(""),l(S),m({x:0,y:0}),v(1),R(null)},T=async()=>{if(!c){g("Choose an image before saving.");return}_(!0),g("");const C=6e4;let S;try{const M=(async()=>{const I=u&&f?await xt(u,f,c):c,Z=a||n?.uid;return mt({file:I,uid:Z,currentUser:n,syncFirestore:i})})(),F=new Promise((I,Z)=>{S=setTimeout(()=>Z(new Error("Upload timed out. Please check your connection and try again.")),C)}),ve=await Promise.race([M,F]);r?.(ve),s().catch(I=>console.warn("[ProfilePictureUploader] refreshProfile failed:",I)),Q.success("Profile picture updated."),D()}catch(M){const F=M instanceof Error?M.message:"Failed to update your profile picture.";g(F),Q.error(F)}finally{clearTimeout(S),_(!1)}},U=()=>{P.current?.click()};return p.jsxs(p.Fragment,{children:[p.jsxs("section",{className:`flex items-center gap-4 rounded-xl border border-slate-200 bg-white p-4 shadow-sm ${t}`,children:[p.jsxs("div",{className:"relative cursor-pointer group",onClick:U,role:"button",tabIndex:0,onKeyDown:C=>C.key==="Enter"&&U(),"aria-label":"Change profile picture",children:[p.jsxs(ye,{className:"size-16 sm:size-20 ring-4 ring-sky-50 shadow-sm transition-transform duration-200 group-hover:scale-105",children:[p.jsx(be,{src:W,alt:`${e||"User"} profile picture`}),p.jsx(Ce,{className:"bg-gradient-to-br from-sky-600 to-cyan-500 text-lg font-semibold text-white",children:gt(e)})]}),p.jsx("span",{className:"absolute -right-1 -top-1 inline-flex items-center justify-center rounded-full bg-slate-900 p-1.5 text-white shadow-md transition-colors group-hover:bg-slate-700",children:p.jsx(Oe,{size:14})})]}),p.jsxs("div",{className:"space-y-1 flex-1",children:[p.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Profile picture"}),p.jsx("p",{className:"text-xs text-slate-500",children:"Click your avatar to upload a new photo."}),y&&p.jsx("p",{className:"text-xs font-medium text-rose-600 mt-1",children:y})]}),p.jsx("input",{ref:P,type:"file",accept:"image/*",onChange:z,className:"sr-only","aria-label":"Choose profile picture"})]}),p.jsx(Pe,{children:u&&p.jsxs(p.Fragment,{children:[p.jsx(J.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[60]",onClick:D}),p.jsx(J.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",duration:.5,bounce:.3},className:"fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onClick:C=>C.stopPropagation(),children:p.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-100",children:[p.jsx("h3",{className:"text-lg font-bold text-slate-900",children:"Update profile picture"}),p.jsx("button",{onClick:D,className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors","aria-label":"Close modal",children:p.jsx(je,{size:20})})]}),p.jsxs("div",{className:"p-4 sm:p-6 bg-slate-50 flex flex-col items-center",children:[p.jsx("div",{className:"relative h-[350px] sm:h-[450px] w-[350px] sm:w-[450px] mx-auto overflow-hidden rounded-xl bg-slate-100 ring-1 ring-inset ring-slate-200 shadow-inner",children:p.jsx(ct,{image:u,crop:d,zoom:w,aspect:1,cropShape:"round",showGrid:!1,objectFit:"cover",restrictPosition:!0,onCropChange:m,onZoomChange:v,onCropComplete:(C,S)=>R(S),style:{containerStyle:{backgroundColor:"#f8fafc"}}})}),p.jsxs("div",{className:"mt-6 w-full max-w-xs flex items-center gap-4",children:[p.jsx(Ue,{size:18,className:"text-slate-500"}),p.jsx(lt,{value:[w],min:1,max:3,step:.05,onValueChange:C=>v(C[0]||1),"aria-label":"Profile picture zoom",className:"flex-1 cursor-pointer"}),p.jsx(Fe,{size:18,className:"text-slate-500"})]}),p.jsx("p",{className:"mt-4 text-xs text-slate-500 text-center",children:k})]}),p.jsxs("div",{className:"p-4 border-t border-slate-100 flex items-center justify-end gap-3 bg-white",children:[p.jsx(ee,{type:"button",variant:"ghost",onClick:D,disabled:E,className:"font-medium text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-5",children:"Cancel"}),p.jsx(ee,{type:"button",onClick:T,disabled:E||!c,className:"bg-sky-600 hover:bg-sky-700 text-white min-w-[120px] gap-2 shadow-sm",children:E?p.jsxs(p.Fragment,{children:[p.jsx(Ie,{size:16,className:"animate-pulse"}),"Saving..."]}):"Save picture"})]})]})})]})})]})};export{At as M,Nt as P,Tt as V}; +`,nt=1,at=3,st=1,ct=(function(a){Ee(o,a);function o(){var e=a!==null&&a.apply(this,arguments)||this;return e.cropperRef=x.createRef(),e.imageRef=x.createRef(),e.videoRef=x.createRef(),e.containerPosition={x:0,y:0},e.containerRef=null,e.styleRef=null,e.containerRect=null,e.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},e.dragStartPosition={x:0,y:0},e.dragStartCrop={x:0,y:0},e.gestureZoomStart=0,e.gestureRotationStart=0,e.isTouching=!1,e.lastPinchDistance=0,e.lastPinchRotation=0,e.rafDragTimeout=null,e.rafPinchTimeout=null,e.wheelTimer=null,e.currentDoc=typeof document<"u"?document:null,e.currentWindow=typeof window<"u"?window:null,e.resizeObserver=null,e.previousCropSize=null,e.isInitialized=!1,e.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},e.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!e.containerRef)){var t=!0;e.resizeObserver=new window.ResizeObserver(function(r){if(t){t=!1;return}e.computeSizes()}),e.resizeObserver.observe(e.containerRef)}},e.preventZoomSafari=function(t){return t.preventDefault()},e.cleanEvents=function(){e.currentDoc&&(e.currentDoc.removeEventListener("mousemove",e.onMouseMove),e.currentDoc.removeEventListener("mouseup",e.onDragStopped),e.currentDoc.removeEventListener("touchmove",e.onTouchMove),e.currentDoc.removeEventListener("touchend",e.onDragStopped),e.currentDoc.removeEventListener("gesturechange",e.onGestureChange),e.currentDoc.removeEventListener("gestureend",e.onGestureEnd),e.currentDoc.removeEventListener("scroll",e.onScroll))},e.clearScrollEvent=function(){e.containerRef&&e.containerRef.removeEventListener("wheel",e.onWheel),e.wheelTimer&&clearTimeout(e.wheelTimer)},e.onMediaLoad=function(){var t=e.computeSizes();t&&(e.previousCropSize=t,e.emitCropData(),e.setInitialCrop(t),e.isInitialized=!0),e.props.onMediaLoaded&&e.props.onMediaLoaded(e.mediaSize)},e.setInitialCrop=function(t){if(e.props.initialCroppedAreaPercentages){var r=et(e.props.initialCroppedAreaPercentages,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=r.crop,n=r.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(n)}else if(e.props.initialCroppedAreaPixels){var s=rt(e.props.initialCroppedAreaPixels,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=s.crop,n=s.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(n)}},e.computeSizes=function(){var t,r,i,n,s,c,l=e.imageRef.current||e.videoRef.current;if(l&&e.containerRef){e.containerRect=e.containerRef.getBoundingClientRect(),e.saveContainerPosition();var u=e.containerRect.width/e.containerRect.height,h=((t=e.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((r=e.videoRef.current)===null||r===void 0?void 0:r.videoWidth)||0,d=((i=e.imageRef.current)===null||i===void 0?void 0:i.naturalHeight)||((n=e.videoRef.current)===null||n===void 0?void 0:n.videoHeight)||0,m=l.offsetWidthw?{width:e.containerRect.height*w,height:e.containerRect.height}:{width:e.containerRect.width,height:e.containerRect.width/w};break;case"horizontal-cover":v={width:e.containerRect.width,height:e.containerRect.width/w};break;case"vertical-cover":v={width:e.containerRect.height*w,height:e.containerRect.height};break}else v={width:l.offsetWidth,height:l.offsetHeight};e.mediaSize=b(b({},v),{naturalWidth:h,naturalHeight:d}),e.props.setMediaSize&&e.props.setMediaSize(e.mediaSize);var f=e.props.cropSize?e.props.cropSize:Xe(e.mediaSize.width,e.mediaSize.height,e.containerRect.width,e.containerRect.height,e.props.aspect,e.props.rotation);return(((s=e.state.cropSize)===null||s===void 0?void 0:s.height)!==f.height||((c=e.state.cropSize)===null||c===void 0?void 0:c.width)!==f.width)&&e.props.onCropSizeChange&&e.props.onCropSizeChange(f),e.setState({cropSize:f},e.recomputeCropPosition),e.props.setCropSize&&e.props.setCropSize(f),f}},e.saveContainerPosition=function(){if(e.containerRef){var t=e.containerRef.getBoundingClientRect();e.containerPosition={x:t.left,y:t.top}}},e.onMouseDown=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("mousemove",e.onMouseMove),e.currentDoc.addEventListener("mouseup",e.onDragStopped),e.saveContainerPosition(),e.onDragStart(o.getMousePoint(t)))},e.onMouseMove=function(t){return e.onDrag(o.getMousePoint(t))},e.onScroll=function(t){e.currentDoc&&(t.preventDefault(),e.saveContainerPosition())},e.onTouchStart=function(t){e.currentDoc&&(e.isTouching=!0,!(e.props.onTouchRequest&&!e.props.onTouchRequest(t))&&(e.currentDoc.addEventListener("touchmove",e.onTouchMove,{passive:!1}),e.currentDoc.addEventListener("touchend",e.onDragStopped),e.saveContainerPosition(),t.touches.length===2?e.onPinchStart(t):t.touches.length===1&&e.onDragStart(o.getTouchPoint(t.touches[0]))))},e.onTouchMove=function(t){t.preventDefault(),t.touches.length===2?e.onPinchMove(t):t.touches.length===1&&e.onDrag(o.getTouchPoint(t.touches[0]))},e.onGestureStart=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("gesturechange",e.onGestureChange),e.currentDoc.addEventListener("gestureend",e.onGestureEnd),e.gestureZoomStart=e.props.zoom,e.gestureRotationStart=e.props.rotation)},e.onGestureChange=function(t){if(t.preventDefault(),!e.isTouching){var r=o.getMousePoint(t),i=e.gestureZoomStart-1+t.scale;if(e.setNewZoom(i,r,{shouldUpdatePosition:!0}),e.props.onRotationChange){var n=e.gestureRotationStart+t.rotation;e.props.onRotationChange(n)}}},e.onGestureEnd=function(t){e.cleanEvents()},e.onDragStart=function(t){var r,i,n=t.x,s=t.y;e.dragStartPosition={x:n,y:s},e.dragStartCrop=b({},e.props.crop),(i=(r=e.props).onInteractionStart)===null||i===void 0||i.call(r)},e.onDrag=function(t){var r=t.x,i=t.y;e.currentWindow&&(e.rafDragTimeout&&e.currentWindow.cancelAnimationFrame(e.rafDragTimeout),e.rafDragTimeout=e.currentWindow.requestAnimationFrame(function(){if(e.state.cropSize&&!(r===void 0||i===void 0)){var n=r-e.dragStartPosition.x,s=i-e.dragStartPosition.y,c={x:e.dragStartCrop.x+n,y:e.dragStartCrop.y+s},l=e.props.restrictPosition?N(c,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):c;e.props.onCropChange(l)}}))},e.onDragStopped=function(){var t,r;e.isTouching=!1,e.cleanEvents(),e.emitCropData(),(r=(t=e.props).onInteractionEnd)===null||r===void 0||r.call(t)},e.onWheel=function(t){if(e.currentWindow&&!(e.props.onWheelRequest&&!e.props.onWheelRequest(t))){t.preventDefault();var r=o.getMousePoint(t),i=Ye(t).pixelY,n=e.props.zoom-i*e.props.zoomSpeed/200;e.setNewZoom(n,r,{shouldUpdatePosition:!0}),e.state.hasWheelJustStarted||e.setState({hasWheelJustStarted:!0},function(){var s,c;return(c=(s=e.props).onInteractionStart)===null||c===void 0?void 0:c.call(s)}),e.wheelTimer&&clearTimeout(e.wheelTimer),e.wheelTimer=e.currentWindow.setTimeout(function(){return e.setState({hasWheelJustStarted:!1},function(){var s,c;return(c=(s=e.props).onInteractionEnd)===null||c===void 0?void 0:c.call(s)})},250)}},e.getPointOnContainer=function(t,r){var i=t.x,n=t.y;if(!e.containerRect)throw new Error("The Cropper is not mounted");return{x:e.containerRect.width/2-(i-r.x),y:e.containerRect.height/2-(n-r.y)}},e.getPointOnMedia=function(t){var r=t.x,i=t.y,n=e.props,s=n.crop,c=n.zoom;return{x:(r+s.x)/c,y:(i+s.y)/c}},e.setNewZoom=function(t,r,i){var n=i===void 0?{}:i,s=n.shouldUpdatePosition,c=s===void 0?!0:s;if(!(!e.state.cropSize||!e.props.onZoomChange)){var l=O(t,e.props.minZoom,e.props.maxZoom);if(c){var u=e.getPointOnContainer(r,e.containerPosition),h=e.getPointOnMedia(u),d={x:h.x*l-u.x,y:h.y*l-u.y},m=e.props.restrictPosition?N(d,e.mediaSize,e.state.cropSize,l,e.props.rotation):d;e.props.onCropChange(m)}e.props.onZoomChange(l)}},e.getCropData=function(){if(!e.state.cropSize)return null;var t=e.props.restrictPosition?N(e.props.crop,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):e.props.crop;return Ke(t,e.mediaSize,e.state.cropSize,e.getAspect(),e.props.zoom,e.props.rotation,e.props.restrictPosition)},e.emitCropData=function(){var t=e.getCropData();if(t){var r=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropComplete&&e.props.onCropComplete(r,i),e.props.onCropAreaChange&&e.props.onCropAreaChange(r,i)}},e.emitCropAreaChange=function(){var t=e.getCropData();if(t){var r=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropAreaChange&&e.props.onCropAreaChange(r,i)}},e.recomputeCropPosition=function(){var t,r;if(e.state.cropSize){var i=e.props.crop;if(e.isInitialized&&(!((t=e.previousCropSize)===null||t===void 0)&&t.width)&&(!((r=e.previousCropSize)===null||r===void 0)&&r.height)){var n=Math.abs(e.previousCropSize.width-e.state.cropSize.width)>1e-6||Math.abs(e.previousCropSize.height-e.state.cropSize.height)>1e-6;if(n){var s=e.state.cropSize.width/e.previousCropSize.width,c=e.state.cropSize.height/e.previousCropSize.height;i={x:e.props.crop.x*s,y:e.props.crop.y*c}}}var l=e.props.restrictPosition?N(i,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):i;e.previousCropSize=e.state.cropSize,e.props.onCropChange(l),e.emitCropData()}},e.onKeyDown=function(t){var r,i,n=e.props,s=n.crop,c=n.onCropChange,l=n.keyboardStep,u=n.zoom,h=n.rotation,d=l;if(e.state.cropSize){t.shiftKey&&(d*=.2);var m=b({},s);switch(t.key){case"ArrowUp":m.y-=d,t.preventDefault();break;case"ArrowDown":m.y+=d,t.preventDefault();break;case"ArrowLeft":m.x-=d,t.preventDefault();break;case"ArrowRight":m.x+=d,t.preventDefault();break;default:return}e.props.restrictPosition&&(m=N(m,e.mediaSize,e.state.cropSize,u,h)),t.repeat||(i=(r=e.props).onInteractionStart)===null||i===void 0||i.call(r),c(m)}},e.onKeyUp=function(t){var r,i;switch(t.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":t.preventDefault();break;default:return}e.emitCropData(),(i=(r=e.props).onInteractionEnd)===null||i===void 0||i.call(r)},e}return o.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=it,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},o.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)===null||t===void 0||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},o.prototype.componentDidUpdate=function(e){var t,r,i,n,s,c,l,u,h;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():((t=e.cropSize)===null||t===void 0?void 0:t.height)!==((r=this.props.cropSize)===null||r===void 0?void 0:r.height)||((i=e.cropSize)===null||i===void 0?void 0:i.width)!==((n=this.props.cropSize)===null||n===void 0?void 0:n.width)?this.computeSizes():(((s=e.crop)===null||s===void 0?void 0:s.x)!==((c=this.props.crop)===null||c===void 0?void 0:c.x)||((l=e.crop)===null||l===void 0?void 0:l.y)!==((u=this.props.crop)===null||u===void 0?void 0:u.y))&&this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((h=this.videoRef.current)===null||h===void 0||h.load());var d=this.getObjectFit();d!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:d},this.computeSizes)},o.prototype.getAspect=function(){var e=this.props,t=e.cropSize,r=e.aspect;return t?t.width/t.height:r},o.prototype.getObjectFit=function(){var e,t,r,i;if(this.props.objectFit==="cover"){var n=this.imageRef.current||this.videoRef.current;if(n&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var s=this.containerRect.width/this.containerRect.height,c=((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalWidth)||((t=this.videoRef.current)===null||t===void 0?void 0:t.videoWidth)||0,l=((r=this.imageRef.current)===null||r===void 0?void 0:r.naturalHeight)||((i=this.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,u=c/l;return uArray.isArray(e)?e:Array.isArray(o)?o:[t,r],[e,o,t,r]);return p.jsxs(Se,{"data-slot":"slider",defaultValue:o,value:e,min:t,max:r,className:B("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",a),...i,children:[p.jsx(_e,{"data-slot":"slider-track",className:B("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-4 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:p.jsx(ze,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:n.length},(s,c)=>p.jsx(De,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const de=["image/png","image/jpeg","image/webp"],he=2*1024*1024,fe=256,ut=a=>{const o=a.normalize("NFKD").toLowerCase(),e=o.lastIndexOf("."),t=e>0?o.slice(0,e):o,r=e>0?o.slice(e).replace(/[^.a-z0-9]/g,""):"";return`${t.replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"profile-picture"}${r}`},pt=(a,o,e=Date.now())=>`profile-pictures/${a}/${e}-${ut(o)}`,me=a=>de.includes(a.type)?a.size>he?"Profile pictures must be 2MB or smaller.":a.name.trim()?null:"Please choose a valid image file.":"Only PNG, JPEG, and WebP images are allowed.",dt=a=>new Promise((o,e)=>{const t=URL.createObjectURL(a),r=new Image,i=setTimeout(()=>{URL.revokeObjectURL(t),e(new Error("Image loading timed out. Please try a different file."))},15e3);r.onload=()=>{clearTimeout(i),URL.revokeObjectURL(t),o(r)},r.onerror=()=>{clearTimeout(i),URL.revokeObjectURL(t),e(new Error("Unable to read the selected image. Please try another file."))},r.crossOrigin="anonymous",r.src=t}),ue=(a,o,e)=>new Promise((t,r)=>{a.toBlob(i=>{if(!i){r(new Error("Failed to prepare the image for upload."));return}t(i)},o,e)}),ht=async(a,o=fe)=>{const e=await dt(a),t=document.createElement("canvas");t.width=o,t.height=o;const r=t.getContext("2d");if(!r)throw new Error("Your browser cannot process image uploads right now.");const i=e.naturalWidth||e.width,n=e.naturalHeight||e.height,s=Math.min(i,n),c=Math.max(0,(i-s)/2),l=Math.max(0,(n-s)/2);r.clearRect(0,0,o,o),r.drawImage(e,c,l,s,s,0,0,o,o);try{return await ue(t,"image/webp",.9)}catch{return await ue(t,"image/jpeg",.9)}},j=(a,o,e)=>{let t;const r=new Promise((i,n)=>{t=setTimeout(()=>n(new Error(`${e} timed out after ${Math.round(o/1e3)}s`)),o)});return Promise.race([a,r]).finally(()=>clearTimeout(t))},ft=async(a,o,e)=>{const t=we.options.projectId;if(!t)throw new Error("Firebase project ID is not configured.");const r=await a.getIdToken(),i=`https://firestore.googleapis.com/v1/projects/${t}/databases/(default)/documents/users/${o}?updateMask.fieldPaths=photo&updateMask.fieldPaths=updatedAt`,n=await fetch(i,{method:"PATCH",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({fields:{photo:{stringValue:e},updatedAt:{timestampValue:new Date().toISOString()}}})});if(!n.ok){const s=await n.text().catch(()=>"");throw new Error(`Firestore REST update failed (${n.status}): ${s}`)}},mt=async({file:a,uid:o,currentUser:e=K.currentUser,syncFirestore:t=!0})=>{const r=me(a);if(r)throw new Error(r);const i=e??K.currentUser;if(!i)throw new Error("You need to be signed in to change your profile picture.");const n=o||i.uid;if(!n)throw new Error("Unable to determine which profile should be updated.");if(i.uid!==n)throw new Error("The signed-in user does not match the profile being edited.");const s=await j(ht(a,fe),2e4,"Image processing"),c=pt(n,a.name),l=Ae(ge,c),u=await j(Te(l,s,{contentType:s.type||"image/webp",cacheControl:"public, max-age=31536000, immutable"}),3e4,"Storage upload"),h=await j(Ne(u.ref),1e4,"Download URL retrieval");try{await j(Me(i,{photoURL:h}),1e4,"Auth profile update")}catch(d){console.warn("[PROFILE UPLOAD] Auth profile update failed (non-fatal):",d)}if(t){try{await j(ft(i,n,h),1e4,"Firestore profile sync")}catch(d){console.error("[PROFILE UPLOAD] Firestore REST sync failed:",d),console.warn("[PROFILE UPLOAD] Photo was uploaded but the database record may be stale. It will refresh on next login.")}try{const{doc:d,updateDoc:m}=await $(async()=>{const{doc:v,updateDoc:f}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{doc:v,updateDoc:f}},__vite__mapDeps([0,1])),{db:w}=await $(async()=>{const{db:v}=await import("./index-CGNBpSmO.js").then(f=>f.b5);return{db:v}},__vite__mapDeps([2,3,0,1,4,5,6,7,8,9,10,11]));await m(d(w,"leaderboard",n),{photo:h}).catch(()=>$(async()=>{const{setDoc:v}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{setDoc:v}},__vite__mapDeps([0,1])).then(({setDoc:v})=>v(d(w,"leaderboard",n),{photo:h},{merge:!0})))}catch{}}return h},vt=a=>`${(a/(1024*1024)).toFixed(1)} MB`,gt=a=>{const o=(a||"").trim();return o?o.split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()).join(""):"U"},wt=a=>new Promise((o,e)=>{const t=new Image;t.onload=()=>o(t),t.onerror=()=>e(new Error("Unable to load the image for cropping.")),t.src=a}),pe=(a,o,e)=>new Promise((t,r)=>{a.toBlob(i=>{if(!i){r(new Error("Failed to prepare the cropped image."));return}t(i)},o,e)}),xt=async(a,o,e)=>{const t=await wt(a),r=document.createElement("canvas"),i=640;r.width=i,r.height=i;const n=r.getContext("2d");if(!n)throw new Error("Your browser cannot process the selected image right now.");n.clearRect(0,0,i,i),n.drawImage(t,o.x,o.y,o.width,o.height,0,0,i,i);let s;try{s=await pe(r,"image/webp",.92)}catch{s=await pe(r,"image/jpeg",.92)}if(!s)throw new Error("Could not create an image from the cropped area.");const c=s.type==="image/webp"?"webp":"jpg",u=`${e.name.replace(/\.[^/.]+$/,"")||"profile-picture"}-cropped.${c}`;return new File([s],u,{type:s.type,lastModified:Date.now()})},Nt=({uid:a,photoURL:o,displayName:e,className:t="",onUploaded:r,syncFirestore:i=!0})=>{const{currentUser:n,refreshProfile:s}=xe(),[c,l]=x.useState(null),[u,h]=x.useState(null),[d,m]=x.useState({x:0,y:0}),[w,v]=x.useState(1),[f,R]=x.useState(null),[y,g]=x.useState(""),[E,_]=x.useState(!1),P=x.useRef(null);x.useEffect(()=>{if(!c){h(null);return}const C=URL.createObjectURL(c);return h(C),()=>URL.revokeObjectURL(C)},[c]);const W=u||o||"",k=x.useMemo(()=>`${de.map(S=>S.replace("image/","").toUpperCase()).join(", ")} up to ${vt(he)}. The image will be cropped to a circular avatar.`,[]),D=()=>{l(null),m({x:0,y:0}),v(1),R(null),g(""),P.current&&(P.current.value="")},z=C=>{const S=C.target.files?.[0]||null;if(!S)return;const M=me(S);if(M){g(M),l(null),C.target.value="";return}g(""),l(S),m({x:0,y:0}),v(1),R(null)},T=async()=>{if(!c){g("Choose an image before saving.");return}_(!0),g("");const C=6e4;let S;try{const M=(async()=>{const I=u&&f?await xt(u,f,c):c,Z=a||n?.uid;return mt({file:I,uid:Z,currentUser:n,syncFirestore:i})})(),F=new Promise((I,Z)=>{S=setTimeout(()=>Z(new Error("Upload timed out. Please check your connection and try again.")),C)}),ve=await Promise.race([M,F]);r?.(ve),s().catch(I=>console.warn("[ProfilePictureUploader] refreshProfile failed:",I)),Q.success("Profile picture updated."),D()}catch(M){const F=M instanceof Error?M.message:"Failed to update your profile picture.";g(F),Q.error(F)}finally{clearTimeout(S),_(!1)}},U=()=>{P.current?.click()};return p.jsxs(p.Fragment,{children:[p.jsxs("section",{className:`flex items-center gap-4 rounded-xl border border-slate-200 bg-white p-4 shadow-sm ${t}`,children:[p.jsxs("div",{className:"relative cursor-pointer group",onClick:U,role:"button",tabIndex:0,onKeyDown:C=>C.key==="Enter"&&U(),"aria-label":"Change profile picture",children:[p.jsxs(ye,{className:"size-16 sm:size-20 ring-4 ring-sky-50 shadow-sm transition-transform duration-200 group-hover:scale-105",children:[p.jsx(be,{src:W,alt:`${e||"User"} profile picture`}),p.jsx(Ce,{className:"bg-gradient-to-br from-sky-600 to-cyan-500 text-lg font-semibold text-white",children:gt(e)})]}),p.jsx("span",{className:"absolute -right-1 -top-1 inline-flex items-center justify-center rounded-full bg-slate-900 p-1.5 text-white shadow-md transition-colors group-hover:bg-slate-700",children:p.jsx(Oe,{size:14})})]}),p.jsxs("div",{className:"space-y-1 flex-1",children:[p.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Profile picture"}),p.jsx("p",{className:"text-xs text-slate-500",children:"Click your avatar to upload a new photo."}),y&&p.jsx("p",{className:"text-xs font-medium text-rose-600 mt-1",children:y})]}),p.jsx("input",{ref:P,type:"file",accept:"image/*",onChange:z,className:"sr-only","aria-label":"Choose profile picture"})]}),p.jsx(Pe,{children:u&&p.jsxs(p.Fragment,{children:[p.jsx(J.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[60]",onClick:D}),p.jsx(J.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",duration:.5,bounce:.3},className:"fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onClick:C=>C.stopPropagation(),children:p.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-100",children:[p.jsx("h3",{className:"text-lg font-bold text-slate-900",children:"Update profile picture"}),p.jsx("button",{onClick:D,className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors","aria-label":"Close modal",children:p.jsx(je,{size:20})})]}),p.jsxs("div",{className:"p-4 sm:p-6 bg-slate-50 flex flex-col items-center",children:[p.jsx("div",{className:"relative h-[350px] sm:h-[450px] w-[350px] sm:w-[450px] mx-auto overflow-hidden rounded-xl bg-slate-100 ring-1 ring-inset ring-slate-200 shadow-inner",children:p.jsx(ct,{image:u,crop:d,zoom:w,aspect:1,cropShape:"round",showGrid:!1,objectFit:"cover",restrictPosition:!0,onCropChange:m,onZoomChange:v,onCropComplete:(C,S)=>R(S),style:{containerStyle:{backgroundColor:"#f8fafc"}}})}),p.jsxs("div",{className:"mt-6 w-full max-w-xs flex items-center gap-4",children:[p.jsx(Ue,{size:18,className:"text-slate-500"}),p.jsx(lt,{value:[w],min:1,max:3,step:.05,onValueChange:C=>v(C[0]||1),"aria-label":"Profile picture zoom",className:"flex-1 cursor-pointer"}),p.jsx(Fe,{size:18,className:"text-slate-500"})]}),p.jsx("p",{className:"mt-4 text-xs text-slate-500 text-center",children:k})]}),p.jsxs("div",{className:"p-4 border-t border-slate-100 flex items-center justify-end gap-3 bg-white",children:[p.jsx(ee,{type:"button",variant:"ghost",onClick:D,disabled:E,className:"font-medium text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-5",children:"Cancel"}),p.jsx(ee,{type:"button",onClick:T,disabled:E||!c,className:"bg-sky-600 hover:bg-sky-700 text-white min-w-[120px] gap-2 shadow-sm",children:E?p.jsxs(p.Fragment,{children:[p.jsx(Ie,{size:16,className:"animate-pulse"}),"Saving..."]}):"Save picture"})]})]})})]})})]})};export{At as M,Nt as P,Tt as V}; diff --git a/assets/QuizBattlePage-BarEesP3.js b/assets/QuizBattlePage-mLpt23lk.js similarity index 99% rename from assets/QuizBattlePage-BarEesP3.js rename to assets/QuizBattlePage-mLpt23lk.js index 229b41d5ba1037edf11e4594203825f428bb5620..ea26960f9d174a95bbdb7f9beea29c2e54404c3b 100644 --- a/assets/QuizBattlePage-BarEesP3.js +++ b/assets/QuizBattlePage-mLpt23lk.js @@ -1,4 +1,4 @@ -import{e as ma,n as u,m as y,g as et,aK as De,N as st,aL as Q,X as $a,q as St,M as Oa,I as Te,U as ge,h as Ze,p as Ke,u as Ha,_ as Va,a0 as gt,a5 as wt,E as Kt,a4 as Jt}from"./index-dPnhhJ9w.js";import{r as i,j as e,d as Mt}from"./vendor-react-B4AQeu28.js";import{q as vt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Ua,s as ea}from"./subjects-DzQfiusb.js";import{doc as Wa,getDoc as Ya,where as ta,orderBy as xa,limit as At,getDocs as zt,query as Ct,collection as It}from"./vendor-firebase-firestore-CNv3xXal.js";import{a4 as q,a5 as pa,a6 as ha,a7 as _e,a8 as Xa}from"./vendor-firebase-core-D7GXCeNu.js";import{B as A}from"./button-WbM5w2Bp.js";import{e as Ga,f as Za}from"./vendor-radix-BPuEd8FG.js";import{S as Me,a as Fe,b as Ee,c as Re,d as de}from"./select-Ca_HQeg8.js";import{I as Ka}from"./input-BUQJctP7.js";import{S as Ja}from"./switch-CuAphvDQ.js";import{S as xe}from"./skeleton-BOUN1xTD.js";import{V as ba,a as fa,M as es,b as ts}from"./volume-x-ChU-f35o.js";import{C as as}from"./CompositeAvatar-Col05lJc.js";import{S as Je}from"./sparkles-DPFO64ZX.js";import{C as jt}from"./check-CAUeuCaw.js";import{H as ss,C as aa}from"./history-CL_DqqWk.js";import{C as Ue}from"./chevron-right-DL17FiOB.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-DtQRo3DE.js";import"./chevron-up-D9yeZehY.js";import"./avatarData-BuQSOXo3.js";/** +import{e as ma,n as u,m as y,g as et,aK as De,N as st,aL as Q,X as $a,q as St,M as Oa,I as Te,U as ge,h as Ze,p as Ke,u as Ha,_ as Va,a0 as gt,a5 as wt,E as Kt,a4 as Jt}from"./index-CGNBpSmO.js";import{r as i,j as e,d as Mt}from"./vendor-react-B4AQeu28.js";import{q as vt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Ua,s as ea}from"./subjects-DP2R71lN.js";import{doc as Wa,getDoc as Ya,where as ta,orderBy as xa,limit as At,getDocs as zt,query as Ct,collection as It}from"./vendor-firebase-firestore-CNv3xXal.js";import{a4 as q,a5 as pa,a6 as ha,a7 as _e,a8 as Xa}from"./vendor-firebase-core-D7GXCeNu.js";import{B as A}from"./button-DVjn4LkC.js";import{e as Ga,f as Za}from"./vendor-radix-BPuEd8FG.js";import{S as Me,a as Fe,b as Ee,c as Re,d as de}from"./select-3FfJraPy.js";import{I as Ka}from"./input-CBi6xF4I.js";import{S as Ja}from"./switch-bpTyEA6p.js";import{S as xe}from"./skeleton-C6ieN9wR.js";import{V as ba,a as fa,M as es,b as ts}from"./volume-x-BprCnnkN.js";import{C as as}from"./CompositeAvatar-Col05lJc.js";import{S as Je}from"./sparkles-C0ju-UTT.js";import{C as jt}from"./check-BfYhdun3.js";import{H as ss,C as aa}from"./history-Dajczx-K.js";import{C as Ue}from"./chevron-right-C39hNstc.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-g5DztEPT.js";import"./chevron-up-B59xV3SY.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-Cur-YLkw.js b/assets/RewardsModal-DnABWb4U.js similarity index 98% rename from assets/RewardsModal-Cur-YLkw.js rename to assets/RewardsModal-DnABWb4U.js index 6f4f131932e552b96381561cb64d96c8f3f5b28a..f868b163c12d851d9fffb94234b94bdb6dfe55de 100644 --- a/assets/RewardsModal-Cur-YLkw.js +++ b/assets/RewardsModal-DnABWb4U.js @@ -1 +1 @@ -import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CNv3xXal.js";import{aO as g,A as u,aP as U,aQ as P,U as $,F as B,i as I,z as R,$ as q,T as j,aR as T,a4 as N,R as L,S as M,a0 as X,X as v,a5 as w,B as G,Z as H,q as Q,E as Z,G as O,a as V,aI as W,g as J}from"./index-dPnhhJ9w.js";import{X as K}from"./x-Ck4mo_h-.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:V,GraduationCap:O,Trophy:Z,Target:Q,Zap:H,Brain:G,Star:w,Flame:v,Swords:X,Shield:M,RefreshCw:L,Crown:N,Sun:T,TrendingUp:j,Globe:q,User:R,UserPlus:I,Calendar:B,Users:$,Compass:P,Heart:U,Award:u},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:d})=>{const[y,b]=i.useState(!0),[k,_]=i.useState(new Set),[E,C]=i.useState({});i.useEffect(()=>{if(!o||!d)return;(async()=>{b(!0);try{const t=await W(d);_(new Set(t.map(a=>a.id)));const l=await F(S(J,"progress",d));l.exists()&&C(l.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,d]);const D=s=>{const{condition:t,threshold:l}=s,a=E;let r=0,f=l??1;switch(t){case"lesson_complete":r=a.totalLessonsCompleted||0;break;case"quiz_complete":r=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":r=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":r=a.consecutiveDaysActive||0;break;case"mastery_xp":r=p;break;case"explore_friend_added":case"social_friend":case"explore_social":r=a.friendsAdded||0;break;case"perfect_score":{r=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(r,f),total:f}},h=g.map(s=>{const t=Y[s.icon.name]??u,l=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:l,color:l?s.iconColor:"text-slate-500",bgColor:l?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-2 sm: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-[90vh] sm:max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-4 md: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-xl md:text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",g.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(K,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 md:gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(N,{size:16,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(w,{size:16,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(v,{size:16,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-xl md: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-4 md: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-1 sm: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(j,{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-1 sm: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 i,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CNv3xXal.js";import{aO as g,A as u,aP as U,aQ as P,U as $,F as B,i as I,z as R,$ as q,T as j,aR as T,a4 as N,R as L,S as M,a0 as X,X as v,a5 as w,B as G,Z as H,q as Q,E as Z,G as O,b as V,aI as W,g as J}from"./index-CGNBpSmO.js";import{X as K}from"./x-Deb9zs8O.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:V,GraduationCap:O,Trophy:Z,Target:Q,Zap:H,Brain:G,Star:w,Flame:v,Swords:X,Shield:M,RefreshCw:L,Crown:N,Sun:T,TrendingUp:j,Globe:q,User:R,UserPlus:I,Calendar:B,Users:$,Compass:P,Heart:U,Award:u},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:d})=>{const[y,b]=i.useState(!0),[k,_]=i.useState(new Set),[E,C]=i.useState({});i.useEffect(()=>{if(!o||!d)return;(async()=>{b(!0);try{const t=await W(d);_(new Set(t.map(a=>a.id)));const l=await F(S(J,"progress",d));l.exists()&&C(l.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,d]);const D=s=>{const{condition:t,threshold:l}=s,a=E;let r=0,f=l??1;switch(t){case"lesson_complete":r=a.totalLessonsCompleted||0;break;case"quiz_complete":r=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":r=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":r=a.consecutiveDaysActive||0;break;case"mastery_xp":r=p;break;case"explore_friend_added":case"social_friend":case"explore_social":r=a.friendsAdded||0;break;case"perfect_score":{r=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(r,f),total:f}},h=g.map(s=>{const t=Y[s.icon.name]??u,l=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:l,color:l?s.iconColor:"text-slate-500",bgColor:l?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-2 sm: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-[90vh] sm:max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-4 md: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-xl md:text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",g.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(K,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 md:gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(N,{size:16,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(w,{size:16,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-3 md:p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 mb-1",children:[e.jsx(v,{size:16,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-xl md: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-4 md: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-1 sm: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(j,{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-1 sm: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-C3z9K6VT.js b/assets/RightSidebar-3FHMx0H9.js similarity index 98% rename from assets/RightSidebar-C3z9K6VT.js rename to assets/RightSidebar-3FHMx0H9.js index a41d85d7f7459437b4f9259853d758269e7d6759..3ce5d2a0bc2486cf695d3e3ece688e0c6aaae64f 100644 --- a/assets/RightSidebar-C3z9K6VT.js +++ b/assets/RightSidebar-3FHMx0H9.js @@ -1 +1 @@ -import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{h as B,m as c,Z as _,a0 as q,a3 as P,E as W,a4 as v,a5 as X,p as Y,z as k}from"./index-dPnhhJ9w.js";import{C as M}from"./circle-check-big-DJBKLvuw.js";import{T as O,a as Z,b as H}from"./tooltip-Dz2m8mUv.js";import{C as T}from"./chevron-right-DL17FiOB.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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(q,{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]=o.useState(0);o.useEffect(()=>{const r=setInterval(()=>{m(l=>(l+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}`},G=({entry:s,rank:a,isYou:x,userPhoto:m,rankColor:t})=>{const r=x?s?.photo||m:s?.photo,l=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:l,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:l}),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:l,currentXP:h,xpToNextLevel:f})=>{const N=h/f*100,[$,D]=o.useState([]),[F,u]=o.useState(!0),[y,g]=o.useState(null),p=o.useRef(null),n=o.useRef(null);o.useEffect(()=>{if(!s){u(!1);return}u(!0),g(null);const d=P(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]"],w=(d,b,C,R,j)=>e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx(G,{entry:d,rank:C,isYou:R==="You",userPhoto:l,rankColor:z[j]}),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[j].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:`${j===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:l})}),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:[w(i[1],1,2,i[1]?.name||"---",1),w(i[0],0,1,i[0]?.name||"---",0),w(i[2],2,3,i[2]?.name||"---",2)]})})]})]})};export{ce as default}; +import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{h as B,m as c,Z as _,a0 as q,a3 as P,E as W,a4 as v,a5 as X,p as Y,z as k}from"./index-CGNBpSmO.js";import{C as M}from"./circle-check-big-yCNC9yfs.js";import{T as O,a as Z,b as H}from"./tooltip-A8-ihp1Q.js";import{C as T}from"./chevron-right-C39hNstc.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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(q,{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]=o.useState(0);o.useEffect(()=>{const r=setInterval(()=>{m(l=>(l+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}`},G=({entry:s,rank:a,isYou:x,userPhoto:m,rankColor:t})=>{const r=x?s?.photo||m:s?.photo,l=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:l,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:l}),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:l,currentXP:h,xpToNextLevel:f})=>{const N=h/f*100,[$,D]=o.useState([]),[F,u]=o.useState(!0),[y,g]=o.useState(null),p=o.useRef(null),n=o.useRef(null);o.useEffect(()=>{if(!s){u(!1);return}u(!0),g(null);const d=P(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]"],w=(d,b,C,R,j)=>e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx(G,{entry:d,rank:C,isYou:R==="You",userPhoto:l,rankColor:z[j]}),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[j].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:`${j===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:l})}),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:[w(i[1],1,2,i[1]?.name||"---",1),w(i[0],0,1,i[0]?.name||"---",0),w(i[2],2,3,i[2]?.name||"---",2)]})})]})]})};export{ce as default}; diff --git a/assets/ScientificCalculator-Cc_fXNNW.js b/assets/ScientificCalculator-Bdrlg1Yp.js similarity index 99% rename from assets/ScientificCalculator-Cc_fXNNW.js rename to assets/ScientificCalculator-Bdrlg1Yp.js index 12b1ddc001974ab878cfc2be802385ec7e843a93..639eff03ee41e9af67fe5d63ff121ff35263e0ed 100644 --- a/assets/ScientificCalculator-Cc_fXNNW.js +++ b/assets/ScientificCalculator-Bdrlg1Yp.js @@ -1,4 +1,4 @@ -import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{e as Z,l as de,h as U,m as ue}from"./index-dPnhhJ9w.js";import{a as fe,C as pe}from"./chevron-up-D9yeZehY.js";import{X as be}from"./x-Ck4mo_h-.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{e as Z,l as de,h as U,m as ue}from"./index-CGNBpSmO.js";import{a as fe,C as pe}from"./chevron-up-B59xV3SY.js";import{X as be}from"./x-Deb9zs8O.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-fWJefMB6.js b/assets/SettingsModal-B-pY0VOy.js similarity index 96% rename from assets/SettingsModal-fWJefMB6.js rename to assets/SettingsModal-B-pY0VOy.js index 9c03455aeb6d286875ec21f5464df85d99f4d2d9..5f18a7b82f0c7b55f6485702f5d5711b52c578aa 100644 --- a/assets/SettingsModal-fWJefMB6.js +++ b/assets/SettingsModal-B-pY0VOy.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{e as D,u as Me,aT as Le,aU as De,aV as qe,aW as Ie,aX as Fe,aY as Ve,z as Oe,S as He,$ as Ge,a as Ue,h as $e,m as G,L as Xe,E as Be,a0 as Ye,X as Qe,_ as U,j as d,aZ as We,aS as Je,a_ as Ke,a$ as Ze,b0 as es}from"./index-dPnhhJ9w.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{S as ss,a as ts,b as as,c as ns,d as te}from"./select-Ca_HQeg8.js";import{B as p}from"./button-WbM5w2Bp.js";import{I as n}from"./input-BUQJctP7.js";import{S as x}from"./switch-CuAphvDQ.js";import je from"./ConfirmModal-CtRcSVjb.js";import{P as is,M as rs,V as ls}from"./ProfilePictureUploader-BaBXPmnP.js";import{B as ge}from"./bell-cxZiilDJ.js";import{D as ve}from"./download-B80nBe--.js";import{X as Ne}from"./x-Ck4mo_h-.js";import{C as cs}from"./circle-help-BkKMcGF2.js";import{C as os}from"./chart-column-DtQRo3DE.js";import{M as ds}from"./megaphone-BbTJf9po.js";import{C as xs}from"./clock-Dy5eVj9o.js";import{T as ms}from"./trash-2-BCXZR1t7.js";import{E as hs,a as us}from"./eye-BmZ1sFKD.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-D9yeZehY.js";import"./check-CAUeuCaw.js";import"./log-out-BUfoSJF2.js";import"./minus-BpJABcv4.js";import"./plus-BIEera7J.js";import"./upload-Dezt40XU.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{e as D,u as Me,aT as Le,aU as De,aV as qe,aW as Ie,aX as Fe,aY as Ve,z as Oe,S as He,$ as Ge,b as Ue,h as $e,m as G,L as Xe,E as Be,a0 as Ye,X as Qe,_ as U,j as d,aZ as We,aS as Je,a_ as Ke,a$ as Ze,b0 as es}from"./index-CGNBpSmO.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{S as ss,a as ts,b as as,c as ns,d as te}from"./select-3FfJraPy.js";import{B as p}from"./button-DVjn4LkC.js";import{I as n}from"./input-CBi6xF4I.js";import{S as x}from"./switch-bpTyEA6p.js";import je from"./ConfirmModal-Bjb3K2ht.js";import{P as is,M as rs,V as ls}from"./ProfilePictureUploader-CCiptDXE.js";import{B as ge}from"./bell-DbwiSyKd.js";import{D as ve}from"./download-Dg4u7Zq0.js";import{X as Ne}from"./x-Deb9zs8O.js";import{C as cs}from"./circle-help-DMiD6EQw.js";import{C as os}from"./chart-column-g5DztEPT.js";import{M as ds}from"./megaphone-DFHZ2_eA.js";import{C as xs}from"./clock-D2bky9WI.js";import{T as ms}from"./trash-2-BhQyV3WQ.js";import{E as hs,a as us}from"./eye-_x45syMF.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-B59xV3SY.js";import"./check-BfYhdun3.js";import"./log-out-G6mObnLf.js";import"./minus-DV5fnWn8.js";import"./plus-ck_SGnHK.js";import"./upload-Daz-vKaw.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. @@ -24,4 +24,4 @@ import{e as D,u as Me,aT as Le,aU as De,aV as qe,aW as Ie,aX as Fe,aY as Ve,z as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ks=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],ws=D("smartphone",ks),Cs=()=>{const{userProfile:m,userRole:y}=Me(),[r,z]=a.useState(Le),[_,R]=a.useState(De),[k,T]=a.useState(!1),[q,E]=a.useState(null);a.useEffect(()=>{if(!m?.uid)return;(async()=>{T(!0),E(null);try{if(y==="teacher"){const u=await Fe(m.uid);z(u)}if(y==="admin"){const u=await Ve();R(u)}}catch(u){E(u instanceof Error?u.message:"Failed to load settings")}finally{T(!1)}})()},[m?.uid,y]);const o=a.useCallback(async g=>{if(!m?.uid)return;const u=await qe(m.uid,g);z(u)},[m?.uid]),M=a.useCallback(async g=>{const u=await Ie(g);R(u)},[]);return{teacherPrefs:r,adminConfig:_,loading:k,error:q,saveTeacherPrefs:o,saveAdminConfig:M}},ae=()=>JSON.parse(JSON.stringify(We)),rt=({isOpen:m,onClose:y,profileData:r,onSave:z,settingsData:_,onSaveSettings:R,onApplySettingsPreview:k,onExportData:T,onClearCache:q,onResetData:E})=>{const o=r?.role||"student",{teacherPrefs:M,adminConfig:g,saveTeacherPrefs:u,saveAdminConfig:ke}=Cs(),[b,ne]=a.useState("account"),[l,h]=a.useState({}),[i,ie]=a.useState(ae()),[w,C]=a.useState(M),[j,$]=a.useState(g),[X,re]=a.useState(!1),[I,le]=a.useState(!1),[B,ce]=a.useState(!1),[Y,oe]=a.useState(!1),[de,Ss]=a.useState(!1),[we,F]=a.useState(!1),[Ce,V]=a.useState(!1),[Se,P]=a.useState(!1),[L,xe]=a.useState(""),[f,Ae]=a.useState(null),[v,me]=a.useState(!1),[Q,he]=a.useState(!1),[W,ue]=a.useState(""),[O,be]=a.useState(""),J=a.useRef(!1),K=a.useRef(ae());a.useEffect(()=>{if(!m){J.current=!1;return}if(J.current)return;J.current=!0;const s=_?JSON.parse(JSON.stringify(_)):ae();K.current=s,h({uid:r?.uid,name:r?.name||"",email:r?.email||"",phone:r?.phone||"",photo:r?.photo||"",avatarLayers:r?.avatarLayers,role:r?.role,gender:r?.gender,lrn:r?.lrn||"",grade:r?.grade||"",section:r?.section||"",school:r?.school||"",department:r?.department||"",subject:r?.subject||"",yearsOfExperience:r?.yearsOfExperience||"",qualification:r?.qualification||"",position:r?.position||""}),ie(s),C(M),$(g)},[m,r,_,M,g]),a.useEffect(()=>{m&&k?.(i)},[m,i,k]),a.useEffect(()=>{if(!m)return;const s=t=>{t.key==="Escape"&&(k?.(K.current),y())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[m,y,k]);const Z=a.useMemo(()=>{const s=[{id:"account",label:"Account",icon:Oe},{id:"notifications",label:"Notifications",icon:ge},{id:"appearance",label:"Appearance",icon:gs}];return o==="student"&&(s.push({id:"privacy",label:"Privacy & Security",icon:He}),s.push({id:"learning",label:"Learning",icon:Ge})),o==="teacher"&&s.push({id:"teaching",label:"Teaching",icon:Ue}),o==="admin"&&s.push({id:"system",label:"System",icon:Ns}),s.push({id:"data",label:"Data & Storage",icon:ve}),s},[o]),c=s=>{ie(t=>s(t))},ee=s=>{Ae(s),xe(""),he(!1),s==="password"&&ue(""),s==="email"&&be(l.email||""),P(!0)},fe=async()=>{if(!L.trim()){d.error("Current password is required");return}me(!0);try{if(f==="password"){if(W.length<8){d.error("New password must be at least 8 characters");return}await Ke(L,W),d.success("Password updated")}else if(f==="email"){if(!O.includes("@")){d.error("Enter a valid email");return}await Ze(L,O),h(s=>({...s,email:O})),d.success("Email updated")}else if(f==="delete"){await es(L,l.uid||""),d.success("Account deleted"),y();return}P(!1)}catch(s){d.error(s instanceof Error?s.message:"Authentication failed")}finally{me(!1)}},Ee=async()=>{const s=Je({name:l.name,phone:l.phone});if(s){d.error(s);return}re(!0);try{z&&await z(l),R&&await R(i),o==="teacher"&&await u(w),o==="admin"&&await ke(j),y()}catch(t){d.error(t instanceof Error?t.message:"Failed to save settings")}finally{re(!1)}},se=()=>{P(!1),F(!1),V(!1),k?.(K.current),y()},Pe=async()=>{if(!(!T||B)){ce(!0);try{await T()}catch(s){d.error(s instanceof Error?s.message:"Failed to export data")}finally{ce(!1)}}},ze=async()=>{if(!(!q||Y)){oe(!0);try{await q()}catch(s){d.error(s instanceof Error?s.message:"Failed to clear cache")}finally{oe(!1)}}},_e=async()=>{if(!(!E||I)){F(!1),le(!0);try{await E(),d.success("Testing data reset completed")}catch(s){d.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{le(!1)}}},Re=()=>{V(!1),ee("delete")};return m?e.jsx($e,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-end sm:items-center justify-center sm:p-4",children:[e.jsx(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:se,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(G.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-t-2xl sm:rounded-2xl shadow-2xl border border-[#dde3eb] w-full sm:max-w-4xl h-[92vh] sm:max-h-[85vh] overflow-hidden flex flex-col sm:flex-row",children:[e.jsxs("div",{className:"hidden sm:flex w-64 flex-shrink-0 bg-slate-50 border-r border-slate-200 flex-col 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:Z.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>ne(s.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all ${b===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 min-h-0",children:[e.jsx("div",{className:"sm:hidden flex items-center border-b border-[#dde3eb] bg-slate-50 overflow-x-auto no-scrollbar px-2",children:Z.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>ne(s.id),className:`flex flex-col items-center gap-0.5 px-3 py-2.5 shrink-0 text-xs font-medium border-b-2 transition-colors ${b===s.id?"border-sky-600 text-sky-700":"border-transparent text-slate-500"}`,children:[e.jsx(t,{size:16}),e.jsx("span",{className:"whitespace-nowrap",children:s.label})]},s.id)})}),e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-base sm:text-lg font-display font-bold text-[#0a1628]",children:Z.find(s=>s.id===b)?.label}),e.jsx("button",{onClick:se,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-4 sm:p-6",children:[b==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(is,{uid:l.uid,photoURL:l.photo,displayName:l.name,onUploaded:s=>h(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:l.name||"",onChange:s=>h(t=>({...t,name:s.target.value})),maxLength:100,autoComplete:"name",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:l.email||"",disabled:!0,className:"flex-1 bg-slate-100"}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>ee("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:l.phone||"",onChange:s=>h(t=>({...t,phone:s.target.value})),maxLength:20,inputMode:"tel",autoComplete:"tel",pattern:"^\\+?[0-9 ()\\-.]{7,20}$",placeholder:"+63 912 345 6789",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(ss,{value:l.gender||"",onValueChange:s=>h(t=>({...t,gender:s})),children:[e.jsx(ts,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg",children:e.jsx(as,{placeholder:"Select gender (optional)"})}),e.jsxs(ns,{children:[e.jsx(te,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(te,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(te,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),o==="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:l.lrn||"",onChange:s=>h(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:l.grade||"",onChange:s=>h(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:l.section||"",onChange:s=>h(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:l.school||"",onChange:s=>h(t=>({...t,school:s.target.value})),className:"max-w-md"})]})]}),o==="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:l.department||"",onChange:s=>h(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:l.subject||"",onChange:s=>h(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:l.yearsOfExperience||"",onChange:s=>h(t=>({...t,yearsOfExperience:s.target.value})),className:"max-w-md"})]})]}),o==="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:l.position||"",onChange:s=>h(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:()=>ee("password"),children:[e.jsx(Xe,{size:16,className:"mr-2"}),"Update Password"]})]})]}),b==="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:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(x,{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(x,{checked:i.notifications.soundEnabled,onCheckedChange:s=>c(t=>({...t,notifications:{...t.notifications,soundEnabled:s}}))})]}),o==="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(x,{checked:w.notifyOnSubmission,onCheckedChange:s=>C(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(x,{checked:w.notifyOnStudentActivity,onCheckedChange:s=>C(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(N=>({...N,notifications:{...N.notifications,notificationTypes:{...N.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.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-1 font-body",children:"Push Notification Categories"}),e.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"Choose which kinds of pushes you want to receive on this device."}),e.jsxs("div",{className:"flex items-center justify-between py-2 mb-2 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Enable Push (master)"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Turn off to silence ALL push categories."})]}),e.jsx(x,{checked:i.pushPreferences.pushEnabled,onCheckedChange:s=>c(t=>({...t,pushPreferences:{...t.pushPreferences,pushEnabled:s}}))})]}),e.jsx("div",{className:"space-y-2",children:[{key:"achievement",label:"Achievements unlocked",icon:Be},{key:"quiz_battle",label:"Quiz battle invites & results",icon:Ye},{key:"daily_reward",label:"Daily reward reminders",icon:ys},{key:"assignment",label:"New assignments / deadlines",icon:fs},{key:"streak_reminder",label:"Streak reminders",icon:Qe},{key:"leaderboard",label:"Leaderboard updates",icon:os},{key:"system",label:"System announcements",icon:ds}].map(s=>{const t=s.key,N=s.icon;return e.jsxs("label",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("span",{className:"text-sm text-[#0a1628] font-body flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 text-[#6c47ff]"}),s.label]}),e.jsx(x,{checked:!!i.pushPreferences[t],onCheckedChange:pe=>c(H=>({...H,pushPreferences:{...H.pushPreferences,[s.key]:pe}})),disabled:!i.pushPreferences.pushEnabled&&t!=="pushEnabled"})]},s.key)})}),e.jsx("div",{className:"mt-4",children:e.jsxs(p,{type:"button",variant:"outline",size:"sm",onClick:async()=>{try{const{requestPushPermissionAndRegister:s}=await U(async()=>{const{requestPushPermissionAndRegister:S}=await import("./index-dPnhhJ9w.js").then(A=>A.b7);return{requestPushPermissionAndRegister:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),{auth:t}=await U(async()=>{const{auth:S}=await import("./index-dPnhhJ9w.js").then(A=>A.b5);return{auth:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),N=t.currentUser?.uid;if(!N){d.error("You must be signed in to test push notifications.");return}if(!await s(N)){d.error("Push setup failed. Check that VITE_FIREBASE_VAPID_KEY is configured and notifications are allowed.");return}const{httpsCallable:H}=await U(async()=>{const{httpsCallable:S}=await import("./vendor-firebase-core-D7GXCeNu.js").then(A=>A.a9);return{httpsCallable:S}},[]),{cloudFunctions:Te}=await U(async()=>{const{cloudFunctions:S}=await import("./index-dPnhhJ9w.js").then(A=>A.b5);return{cloudFunctions:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),ye=(await H(Te,"sendTestPush")({}))?.data?.sent??0;ye>0?d.success(`Sent test push to ${ye} device(s).`):d.message("No active devices found. Enable browser notifications first.")}catch(s){d.error(s instanceof Error?s.message:"Failed to send test push")}},children:[e.jsx(ge,{size:14,className:"mr-2"}),"Send test push"]})})]}),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(xs,{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"})]})]})]}),b==="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(x,{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(x,{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(x,{checked:i.appearance.reduceAnimations,onCheckedChange:s=>c(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),b==="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(x,{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(x,{checked:i.privacy.dataSharing,onCheckedChange:s=>c(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),b==="learning"&&o==="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(x,{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(x,{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(ws,{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"})]})]}),b==="teaching"&&o==="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:w.quizDefaults.timeLimitMinutes,onChange:s=>C(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:w.quizDefaults.passingScore,onChange:s=>C(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:w.quizDefaults.maxAttempts,onChange:s=>C(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-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(x,{checked:w.studentAnalyticsVisibility,onCheckedChange:s=>C(t=>({...t,studentAnalyticsVisibility:s}))})]})]}),b==="system"&&o==="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(x,{checked:j.maintenanceMode,onCheckedChange:s=>$(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:j.defaultGradeLevel,disabled:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Curriculum"}),e.jsx(n,{value:j.defaultCurriculum,disabled:!0})]}),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:j.maxClassSize,disabled:!0})]})]}),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(x,{checked:j.auditLogVisible,onCheckedChange:s=>$(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:j.aiConfig.modelName,disabled:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Temperature"}),e.jsx(n,{type:"number",value:j.aiConfig.temperature,disabled:!0})]}),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:j.aiConfig.endpoint,disabled:!0})]})]})]}),b==="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:Pe,disabled:B,children:[e.jsx(ve,{size:16,className:"mr-2"}),B?"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:ze,disabled:Y,children:Y?"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:[o==="student"&&"Reset quizzes, diagnostic state, XP, and learning progress for retesting.",o==="teacher"&&"Reset imported records, managed classrooms, and teacher-generated quiz artifacts.",o==="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:!E||I,onClick:()=>F(!0),children:I?"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:()=>V(!0),disabled:de,children:[e.jsx(ms,{size:16,className:"mr-2"}),de?"Deleting...":"Delete Account"]})]})]})]}),e.jsxs("div",{className:"shrink-0 px-4 sm:px-6 py-3 sm:py-4 border-t border-[#dde3eb] bg-[#edf1f7] flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2 sm:gap-0",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body text-center sm:text-left",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(p,{variant:"outline",onClick:se,className:"rounded-lg border-[#dde3eb] flex-1 sm:flex-none",disabled:X,children:"Cancel"}),e.jsx(p,{onClick:Ee,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white flex-1 sm:flex-none",disabled:X,children:X?"Saving...":"Save Changes"})]})]})]})]})]}),Se&&e.jsx(G.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:()=>{v||P(!1)},children:e.jsxs(G.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:[f==="password"&&"Change Password",f==="email"&&"Change Email",f==="delete"&&"Delete Account"]}),e.jsx("button",{onClick:()=>{v||P(!1)},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close",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 your current password to continue."}),e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:Q?"text":"password",value:L,onChange:s=>xe(s.target.value),placeholder:"Current password",autoFocus:!0,className:"pr-10",disabled:v,onKeyDown:s=>{s.key==="Enter"&&fe()}}),e.jsx("button",{type:"button",onClick:()=>he(!Q),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",tabIndex:-1,children:Q?e.jsx(hs,{size:16}):e.jsx(us,{size:16})})]}),f==="password"&&e.jsx("div",{className:"relative",children:e.jsx(n,{type:"password",value:W,onChange:s=>ue(s.target.value),placeholder:"New password (min 8 chars)",disabled:v})}),f==="email"&&e.jsx(n,{type:"email",value:O,onChange:s=>be(s.target.value),placeholder:"New email address",disabled:v}),f==="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:()=>P(!1),disabled:v,children:"Cancel"}),e.jsx(p,{onClick:()=>void fe(),className:f==="delete"?"bg-red-600 hover:bg-red-700 text-white":"bg-sky-600 hover:bg-sky-700 text-white",disabled:v,children:v?"Processing...":f==="delete"?"Delete Forever":"Confirm"})]})]})]})}),e.jsx(je,{isOpen:we,onClose:()=>F(!1),onConfirm:_e,title:"Reset Testing Data?",message:`Reset ${o} testing data? This will clear quizzes, diagnostic assessments, assessment history, XP, and learning progress. This action cannot be undone.`,confirmText:I?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(je,{isOpen:Ce,onClose:()=>V(!1),onConfirm:Re,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{rt as default}; + */const ks=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],ws=D("smartphone",ks),Cs=()=>{const{userProfile:m,userRole:y}=Me(),[r,z]=a.useState(Le),[_,R]=a.useState(De),[k,T]=a.useState(!1),[q,E]=a.useState(null);a.useEffect(()=>{if(!m?.uid)return;(async()=>{T(!0),E(null);try{if(y==="teacher"){const u=await Fe(m.uid);z(u)}if(y==="admin"){const u=await Ve();R(u)}}catch(u){E(u instanceof Error?u.message:"Failed to load settings")}finally{T(!1)}})()},[m?.uid,y]);const o=a.useCallback(async g=>{if(!m?.uid)return;const u=await qe(m.uid,g);z(u)},[m?.uid]),M=a.useCallback(async g=>{const u=await Ie(g);R(u)},[]);return{teacherPrefs:r,adminConfig:_,loading:k,error:q,saveTeacherPrefs:o,saveAdminConfig:M}},ae=()=>JSON.parse(JSON.stringify(We)),rt=({isOpen:m,onClose:y,profileData:r,onSave:z,settingsData:_,onSaveSettings:R,onApplySettingsPreview:k,onExportData:T,onClearCache:q,onResetData:E})=>{const o=r?.role||"student",{teacherPrefs:M,adminConfig:g,saveTeacherPrefs:u,saveAdminConfig:ke}=Cs(),[b,ne]=a.useState("account"),[l,h]=a.useState({}),[i,ie]=a.useState(ae()),[w,C]=a.useState(M),[j,$]=a.useState(g),[X,re]=a.useState(!1),[I,le]=a.useState(!1),[B,ce]=a.useState(!1),[Y,oe]=a.useState(!1),[de,Ss]=a.useState(!1),[we,F]=a.useState(!1),[Ce,V]=a.useState(!1),[Se,P]=a.useState(!1),[L,xe]=a.useState(""),[f,Ae]=a.useState(null),[v,me]=a.useState(!1),[Q,he]=a.useState(!1),[W,ue]=a.useState(""),[O,be]=a.useState(""),J=a.useRef(!1),K=a.useRef(ae());a.useEffect(()=>{if(!m){J.current=!1;return}if(J.current)return;J.current=!0;const s=_?JSON.parse(JSON.stringify(_)):ae();K.current=s,h({uid:r?.uid,name:r?.name||"",email:r?.email||"",phone:r?.phone||"",photo:r?.photo||"",avatarLayers:r?.avatarLayers,role:r?.role,gender:r?.gender,lrn:r?.lrn||"",grade:r?.grade||"",section:r?.section||"",school:r?.school||"",department:r?.department||"",subject:r?.subject||"",yearsOfExperience:r?.yearsOfExperience||"",qualification:r?.qualification||"",position:r?.position||""}),ie(s),C(M),$(g)},[m,r,_,M,g]),a.useEffect(()=>{m&&k?.(i)},[m,i,k]),a.useEffect(()=>{if(!m)return;const s=t=>{t.key==="Escape"&&(k?.(K.current),y())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[m,y,k]);const Z=a.useMemo(()=>{const s=[{id:"account",label:"Account",icon:Oe},{id:"notifications",label:"Notifications",icon:ge},{id:"appearance",label:"Appearance",icon:gs}];return o==="student"&&(s.push({id:"privacy",label:"Privacy & Security",icon:He}),s.push({id:"learning",label:"Learning",icon:Ge})),o==="teacher"&&s.push({id:"teaching",label:"Teaching",icon:Ue}),o==="admin"&&s.push({id:"system",label:"System",icon:Ns}),s.push({id:"data",label:"Data & Storage",icon:ve}),s},[o]),c=s=>{ie(t=>s(t))},ee=s=>{Ae(s),xe(""),he(!1),s==="password"&&ue(""),s==="email"&&be(l.email||""),P(!0)},fe=async()=>{if(!L.trim()){d.error("Current password is required");return}me(!0);try{if(f==="password"){if(W.length<8){d.error("New password must be at least 8 characters");return}await Ke(L,W),d.success("Password updated")}else if(f==="email"){if(!O.includes("@")){d.error("Enter a valid email");return}await Ze(L,O),h(s=>({...s,email:O})),d.success("Email updated")}else if(f==="delete"){await es(L,l.uid||""),d.success("Account deleted"),y();return}P(!1)}catch(s){d.error(s instanceof Error?s.message:"Authentication failed")}finally{me(!1)}},Ee=async()=>{const s=Je({name:l.name,phone:l.phone});if(s){d.error(s);return}re(!0);try{z&&await z(l),R&&await R(i),o==="teacher"&&await u(w),o==="admin"&&await ke(j),y()}catch(t){d.error(t instanceof Error?t.message:"Failed to save settings")}finally{re(!1)}},se=()=>{P(!1),F(!1),V(!1),k?.(K.current),y()},Pe=async()=>{if(!(!T||B)){ce(!0);try{await T()}catch(s){d.error(s instanceof Error?s.message:"Failed to export data")}finally{ce(!1)}}},ze=async()=>{if(!(!q||Y)){oe(!0);try{await q()}catch(s){d.error(s instanceof Error?s.message:"Failed to clear cache")}finally{oe(!1)}}},_e=async()=>{if(!(!E||I)){F(!1),le(!0);try{await E(),d.success("Testing data reset completed")}catch(s){d.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{le(!1)}}},Re=()=>{V(!1),ee("delete")};return m?e.jsx($e,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-end sm:items-center justify-center sm:p-4",children:[e.jsx(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:se,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(G.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-t-2xl sm:rounded-2xl shadow-2xl border border-[#dde3eb] w-full sm:max-w-4xl h-[92vh] sm:max-h-[85vh] overflow-hidden flex flex-col sm:flex-row",children:[e.jsxs("div",{className:"hidden sm:flex w-64 flex-shrink-0 bg-slate-50 border-r border-slate-200 flex-col 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:Z.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>ne(s.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all ${b===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 min-h-0",children:[e.jsx("div",{className:"sm:hidden flex items-center border-b border-[#dde3eb] bg-slate-50 overflow-x-auto no-scrollbar px-2",children:Z.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>ne(s.id),className:`flex flex-col items-center gap-0.5 px-3 py-2.5 shrink-0 text-xs font-medium border-b-2 transition-colors ${b===s.id?"border-sky-600 text-sky-700":"border-transparent text-slate-500"}`,children:[e.jsx(t,{size:16}),e.jsx("span",{className:"whitespace-nowrap",children:s.label})]},s.id)})}),e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-base sm:text-lg font-display font-bold text-[#0a1628]",children:Z.find(s=>s.id===b)?.label}),e.jsx("button",{onClick:se,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-4 sm:p-6",children:[b==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(is,{uid:l.uid,photoURL:l.photo,displayName:l.name,onUploaded:s=>h(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:l.name||"",onChange:s=>h(t=>({...t,name:s.target.value})),maxLength:100,autoComplete:"name",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:l.email||"",disabled:!0,className:"flex-1 bg-slate-100"}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>ee("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:l.phone||"",onChange:s=>h(t=>({...t,phone:s.target.value})),maxLength:20,inputMode:"tel",autoComplete:"tel",pattern:"^\\+?[0-9 ()\\-.]{7,20}$",placeholder:"+63 912 345 6789",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(ss,{value:l.gender||"",onValueChange:s=>h(t=>({...t,gender:s})),children:[e.jsx(ts,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg",children:e.jsx(as,{placeholder:"Select gender (optional)"})}),e.jsxs(ns,{children:[e.jsx(te,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(te,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(te,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),o==="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:l.lrn||"",onChange:s=>h(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:l.grade||"",onChange:s=>h(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:l.section||"",onChange:s=>h(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:l.school||"",onChange:s=>h(t=>({...t,school:s.target.value})),className:"max-w-md"})]})]}),o==="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:l.department||"",onChange:s=>h(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:l.subject||"",onChange:s=>h(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:l.yearsOfExperience||"",onChange:s=>h(t=>({...t,yearsOfExperience:s.target.value})),className:"max-w-md"})]})]}),o==="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:l.position||"",onChange:s=>h(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:()=>ee("password"),children:[e.jsx(Xe,{size:16,className:"mr-2"}),"Update Password"]})]})]}),b==="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:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(x,{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(x,{checked:i.notifications.soundEnabled,onCheckedChange:s=>c(t=>({...t,notifications:{...t.notifications,soundEnabled:s}}))})]}),o==="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(x,{checked:w.notifyOnSubmission,onCheckedChange:s=>C(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(x,{checked:w.notifyOnStudentActivity,onCheckedChange:s=>C(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(N=>({...N,notifications:{...N.notifications,notificationTypes:{...N.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.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-1 font-body",children:"Push Notification Categories"}),e.jsx("p",{className:"text-xs text-slate-500 mb-3",children:"Choose which kinds of pushes you want to receive on this device."}),e.jsxs("div",{className:"flex items-center justify-between py-2 mb-2 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Enable Push (master)"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Turn off to silence ALL push categories."})]}),e.jsx(x,{checked:i.pushPreferences.pushEnabled,onCheckedChange:s=>c(t=>({...t,pushPreferences:{...t.pushPreferences,pushEnabled:s}}))})]}),e.jsx("div",{className:"space-y-2",children:[{key:"achievement",label:"Achievements unlocked",icon:Be},{key:"quiz_battle",label:"Quiz battle invites & results",icon:Ye},{key:"daily_reward",label:"Daily reward reminders",icon:ys},{key:"assignment",label:"New assignments / deadlines",icon:fs},{key:"streak_reminder",label:"Streak reminders",icon:Qe},{key:"leaderboard",label:"Leaderboard updates",icon:os},{key:"system",label:"System announcements",icon:ds}].map(s=>{const t=s.key,N=s.icon;return e.jsxs("label",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("span",{className:"text-sm text-[#0a1628] font-body flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 text-[#6c47ff]"}),s.label]}),e.jsx(x,{checked:!!i.pushPreferences[t],onCheckedChange:pe=>c(H=>({...H,pushPreferences:{...H.pushPreferences,[s.key]:pe}})),disabled:!i.pushPreferences.pushEnabled&&t!=="pushEnabled"})]},s.key)})}),e.jsx("div",{className:"mt-4",children:e.jsxs(p,{type:"button",variant:"outline",size:"sm",onClick:async()=>{try{const{requestPushPermissionAndRegister:s}=await U(async()=>{const{requestPushPermissionAndRegister:S}=await import("./index-CGNBpSmO.js").then(A=>A.b7);return{requestPushPermissionAndRegister:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),{auth:t}=await U(async()=>{const{auth:S}=await import("./index-CGNBpSmO.js").then(A=>A.b5);return{auth:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),N=t.currentUser?.uid;if(!N){d.error("You must be signed in to test push notifications.");return}if(!await s(N)){d.error("Push setup failed. Check that VITE_FIREBASE_VAPID_KEY is configured and notifications are allowed.");return}const{httpsCallable:H}=await U(async()=>{const{httpsCallable:S}=await import("./vendor-firebase-core-D7GXCeNu.js").then(A=>A.a9);return{httpsCallable:S}},[]),{cloudFunctions:Te}=await U(async()=>{const{cloudFunctions:S}=await import("./index-CGNBpSmO.js").then(A=>A.b5);return{cloudFunctions:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),ye=(await H(Te,"sendTestPush")({}))?.data?.sent??0;ye>0?d.success(`Sent test push to ${ye} device(s).`):d.message("No active devices found. Enable browser notifications first.")}catch(s){d.error(s instanceof Error?s.message:"Failed to send test push")}},children:[e.jsx(ge,{size:14,className:"mr-2"}),"Send test push"]})})]}),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(xs,{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"})]})]})]}),b==="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(x,{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(x,{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(x,{checked:i.appearance.reduceAnimations,onCheckedChange:s=>c(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),b==="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(x,{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(x,{checked:i.privacy.dataSharing,onCheckedChange:s=>c(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),b==="learning"&&o==="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(x,{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(x,{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(ws,{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"})]})]}),b==="teaching"&&o==="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:w.quizDefaults.timeLimitMinutes,onChange:s=>C(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:w.quizDefaults.passingScore,onChange:s=>C(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:w.quizDefaults.maxAttempts,onChange:s=>C(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-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(x,{checked:w.studentAnalyticsVisibility,onCheckedChange:s=>C(t=>({...t,studentAnalyticsVisibility:s}))})]})]}),b==="system"&&o==="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(x,{checked:j.maintenanceMode,onCheckedChange:s=>$(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:j.defaultGradeLevel,disabled:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Curriculum"}),e.jsx(n,{value:j.defaultCurriculum,disabled:!0})]}),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:j.maxClassSize,disabled:!0})]})]}),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(x,{checked:j.auditLogVisible,onCheckedChange:s=>$(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:j.aiConfig.modelName,disabled:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Temperature"}),e.jsx(n,{type:"number",value:j.aiConfig.temperature,disabled:!0})]}),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:j.aiConfig.endpoint,disabled:!0})]})]})]}),b==="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:Pe,disabled:B,children:[e.jsx(ve,{size:16,className:"mr-2"}),B?"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:ze,disabled:Y,children:Y?"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:[o==="student"&&"Reset quizzes, diagnostic state, XP, and learning progress for retesting.",o==="teacher"&&"Reset imported records, managed classrooms, and teacher-generated quiz artifacts.",o==="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:!E||I,onClick:()=>F(!0),children:I?"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:()=>V(!0),disabled:de,children:[e.jsx(ms,{size:16,className:"mr-2"}),de?"Deleting...":"Delete Account"]})]})]})]}),e.jsxs("div",{className:"shrink-0 px-4 sm:px-6 py-3 sm:py-4 border-t border-[#dde3eb] bg-[#edf1f7] flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2 sm:gap-0",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body text-center sm:text-left",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(p,{variant:"outline",onClick:se,className:"rounded-lg border-[#dde3eb] flex-1 sm:flex-none",disabled:X,children:"Cancel"}),e.jsx(p,{onClick:Ee,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white flex-1 sm:flex-none",disabled:X,children:X?"Saving...":"Save Changes"})]})]})]})]})]}),Se&&e.jsx(G.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:()=>{v||P(!1)},children:e.jsxs(G.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:[f==="password"&&"Change Password",f==="email"&&"Change Email",f==="delete"&&"Delete Account"]}),e.jsx("button",{onClick:()=>{v||P(!1)},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close",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 your current password to continue."}),e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:Q?"text":"password",value:L,onChange:s=>xe(s.target.value),placeholder:"Current password",autoFocus:!0,className:"pr-10",disabled:v,onKeyDown:s=>{s.key==="Enter"&&fe()}}),e.jsx("button",{type:"button",onClick:()=>he(!Q),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",tabIndex:-1,children:Q?e.jsx(hs,{size:16}):e.jsx(us,{size:16})})]}),f==="password"&&e.jsx("div",{className:"relative",children:e.jsx(n,{type:"password",value:W,onChange:s=>ue(s.target.value),placeholder:"New password (min 8 chars)",disabled:v})}),f==="email"&&e.jsx(n,{type:"email",value:O,onChange:s=>be(s.target.value),placeholder:"New email address",disabled:v}),f==="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:()=>P(!1),disabled:v,children:"Cancel"}),e.jsx(p,{onClick:()=>void fe(),className:f==="delete"?"bg-red-600 hover:bg-red-700 text-white":"bg-sky-600 hover:bg-sky-700 text-white",disabled:v,children:v?"Processing...":f==="delete"?"Delete Forever":"Confirm"})]})]})]})}),e.jsx(je,{isOpen:we,onClose:()=>F(!1),onConfirm:_e,title:"Reset Testing Data?",message:`Reset ${o} testing data? This will clear quizzes, diagnostic assessments, assessment history, XP, and learning progress. This action cannot be undone.`,confirmText:I?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(je,{isOpen:Ce,onClose:()=>V(!1),onConfirm:Re,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{rt as default}; diff --git a/assets/Sidebar-DT74kKuo.js b/assets/Sidebar-DjsHKc7l.js similarity index 93% rename from assets/Sidebar-DT74kKuo.js rename to assets/Sidebar-DjsHKc7l.js index a21a1cefefd3a17e1d3c2f08eba634bd901927e0..b87e89e3836fb37d939ee7dc357b0443b35568b7 100644 --- a/assets/Sidebar-DT74kKuo.js +++ b/assets/Sidebar-DjsHKc7l.js @@ -1,4 +1,4 @@ -import{r as x,j as e}from"./vendor-react-B4AQeu28.js";import{S as H,a as $,L as u,D as B,M as D}from"./LogoutActionButton-USB3vnm6.js";import{e as G,m as c,n as P,U as S,G as N,a as m,S as U,a0 as q,E as F}from"./index-dPnhhJ9w.js";import{T as M,a as L,b as C}from"./tooltip-Dz2m8mUv.js";import{X as Q}from"./x-Ck4mo_h-.js";import{C as W}from"./chevron-right-DL17FiOB.js";import{C as R}from"./chevron-left-DfHtS3Om.js";import{C as A}from"./chart-column-DtQRo3DE.js";import{S as X}from"./shirt-DP8IJVug.js";/** +import{r as x,j as e}from"./vendor-react-B4AQeu28.js";import{S as H,a as $,L as u,D as B,M as D}from"./LogoutActionButton-ynXvSPMf.js";import{e as G,m as c,n as P,U as S,G as N,b as m,S as U,a0 as q,E as F}from"./index-CGNBpSmO.js";import{T as M,a as L,b as C}from"./tooltip-A8-ihp1Q.js";import{X as Q}from"./x-Deb9zs8O.js";import{C as W}from"./chevron-right-C39hNstc.js";import{C as R}from"./chevron-left-BuATOj9f.js";import{C as A}from"./chart-column-g5DztEPT.js";import{S as X}from"./shirt-T-KPAkDY.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/SupplementalBanner-Cl_1p9XH.js b/assets/SupplementalBanner-DqWH4k4T.js similarity index 97% rename from assets/SupplementalBanner-Cl_1p9XH.js rename to assets/SupplementalBanner-DqWH4k4T.js index 07a50b87535b6c4a671e131d400c64144774fba0..a74e4b5d1dcb598f2cbbe75705f2373e3ac7b93c 100644 --- a/assets/SupplementalBanner-Cl_1p9XH.js +++ b/assets/SupplementalBanner-DqWH4k4T.js @@ -1 +1 @@ -import{j as e,r as y}from"./vendor-react-B4AQeu28.js";import{h as j,m as p,x as h,a as f,T as m,B as u}from"./index-dPnhhJ9w.js";import{X as v}from"./x-Ck4mo_h-.js";import{S as w}from"./sparkles-DPFO64ZX.js";import{C as g}from"./chevron-right-DL17FiOB.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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(u,{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(u,{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(u,{size:14})}]};function x(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]=y.useState(!1);if(l||i.length===0)return null;const r=()=>{a(!0),n?.()};return e.jsx(j,{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?x(i):null;if(!s.some(r=>{const t=x(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?x(i):null,r=n.some(c=>{const d=x(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 y}from"./vendor-react-B4AQeu28.js";import{h as j,m as p,x as h,b as f,T as m,B as u}from"./index-CGNBpSmO.js";import{X as v}from"./x-Deb9zs8O.js";import{S as w}from"./sparkles-C0ju-UTT.js";import{C as g}from"./chevron-right-C39hNstc.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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(u,{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(u,{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(u,{size:14})}]};function x(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]=y.useState(!1);if(l||i.length===0)return null;const r=()=>{a(!0),n?.()};return e.jsx(j,{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?x(i):null;if(!s.some(r=>{const t=x(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?x(i):null,r=n.some(c=>{const d=x(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-BCZGCjNt.js b/assets/SupplementalPillCarousel-CFX0nks9.js similarity index 94% rename from assets/SupplementalPillCarousel-BCZGCjNt.js rename to assets/SupplementalPillCarousel-CFX0nks9.js index afcc251a31c930cf56ea14cef9d12a3a6b8a994f..fe7f501cc47b212acaa5978a85d244c889cc0ca0 100644 --- a/assets/SupplementalPillCarousel-BCZGCjNt.js +++ b/assets/SupplementalPillCarousel-CFX0nks9.js @@ -1,4 +1,4 @@ -import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{m as f,x}from"./index-dPnhhJ9w.js";import{C as n}from"./chevron-right-DL17FiOB.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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,x}from"./index-CGNBpSmO.js";import{C as n}from"./chevron-right-C39hNstc.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-6v6okHB7.js b/assets/TeacherDashboard-6v6okHB7.js new file mode 100644 index 0000000000000000000000000000000000000000..7c6dca2b102201ad3d4a2adaa755442c7211aff4 --- /dev/null +++ b/assets/TeacherDashboard-6v6okHB7.js @@ -0,0 +1,109 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{e as ht,t as gl,f as jn,g as Ue,_ as _r,u as ds,h as Et,m as Re,i as Ko,j as me,k as bl,l as nt,n as Xo,b as Qt,G as Jo,B as Mr,Z as vl,o as qa,p as mt,A as Zo,U as is,q as ws,T as Ta,r as Qa,C as wl,v as yn,R as zs,w as Nl,x as Xs,y as Sn,z as kn,D as ei,E as jl,F as Ya,H as yl,M as Sl,I as Cn,J as kl,K as Cl}from"./index-CGNBpSmO.js";import{d as de,j as e,r as u,c as Ar}from"./vendor-react-B4AQeu28.js";import{B as pt,c as Il}from"./button-DVjn4LkC.js";import{I as Ns}from"./input-CBi6xF4I.js";import Tl from"./ConfirmModal-Bjb3K2ht.js";import{collection as $t,query as kt,limit as Vr,where as jt,getDocs as Dt,doc as dt,getDoc as gs,updateDoc as Zt,serverTimestamp as ot,setDoc as es,Timestamp as El,orderBy as Rl,onSnapshot as ti,deleteDoc as _l}from"./vendor-firebase-firestore-CNv3xXal.js";import{X as cs}from"./x-Deb9zs8O.js";import{S as Os}from"./search-C_DiQDej.js";import{C as Mt}from"./check-BfYhdun3.js";import{P as Js}from"./plus-ck_SGnHK.js";import{I as ga,F as bs,N as Ml,A as si}from"./NotificationDropdown-DGCnp7MU.js";import{M as Al,L as zl,D as Ll,S as Dl,a as $l}from"./LogoutActionButton-ynXvSPMf.js";import{s as In,f as ai,L as Ka,d as Fl,p as Ol,a as Bl,A as Xa,P as Pl,b as Hl}from"./quizService-CuH9jeN9.js";import{S as Ql}from"./vendor-radix-BPuEd8FG.js";import{T as Gl,a as Ul,b as Vl}from"./tooltip-A8-ihp1Q.js";import{C as Wl}from"./circle-help-DMiD6EQw.js";import{E as ql,a as Yl}from"./eye-_x45syMF.js";import{S as La}from"./send-DnRgK3MX.js";import{T as ri}from"./trash-2-BhQyV3WQ.js";import{C as or}from"./circle-alert-fZn6_hMx.js";import{C as Tt,a as wa}from"./chevron-up-B59xV3SY.js";import{M as Tn}from"./minus-DV5fnWn8.js";import{C as Ds}from"./chart-column-g5DztEPT.js";import{C as zr,H as En}from"./history-Dajczx-K.js";import{D as Kl}from"./download-Dg4u7Zq0.js";import{C as Ss}from"./chevron-left-BuATOj9f.js";import{C as ys}from"./chevron-right-C39hNstc.js";import{S as ni}from"./save-CNayyZ15.js";import{C as Wr}from"./circle-check-BhLH88x1.js";import{S as $s}from"./sparkles-C0ju-UTT.js";import{U as Rn}from"./upload-Daz-vKaw.js";import{u as Xl}from"./useQuery-C7Nbsm2w.js";import{S as _n,g as Jl,G as Zl,s as Mn}from"./subjects-DP2R71lN.js";import{u as ec}from"./useCurriculum-cH2ZLq43.js";import{C as qr}from"./circle-check-big-yCNC9yfs.js";import tc from"./ChatMarkdown-BAxWaDZo.js";import{c as sc,a as oi,C as ac,f as rc}from"./formatDistanceToNow-Csp8CCDy.js";import{C as Zs}from"./clock-D2bky9WI.js";import{B as Ja}from"./bell-DbwiSyKd.js";import{D as An,a as zn,b as nc,c as oc,d as ic,S as lc}from"./dialog-DDOyFRnI.js";import{S as Ln}from"./skeleton-C6ieN9wR.js";import{u as Vt,r as cc}from"./vendor-xlsx-uZelXSz_.js";import{C as ii}from"./clipboard-check-DSPNHJXj.js";import{R as Dn,B as $n,C as Fn,X as On,Y as Bn,T as Pn,a as Hn,b as Qn}from"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-G6mObnLf.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 dc=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],mc=ht("align-left",dc);/** + * @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 uc=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],br=ht("calendar-days",uc);/** + * @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 xc=[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]],pc=ht("chart-no-axes-column",xc);/** + * @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 hc=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],fc=ht("ellipsis-vertical",hc);/** + * @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 gc=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Lr=ht("ellipsis",gc);/** + * @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 bc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],vc=ht("external-link",bc);/** + * @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 wc=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],Nc=ht("file-spreadsheet",wc);/** + * @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 jc=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Za=ht("library",jc);/** + * @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 yc=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],li=ht("list-checks",yc);/** + * @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 Sc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],kc=ht("panel-right",Sc);/** + * @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 Cc=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Ic=ht("pen-line",Cc);/** + * @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 Tc=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ci=ht("pen",Tc);/** + * @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 Ec=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Rc=ht("printer",Ec);/** + * @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 _c=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],Mc=ht("scan-line",_c);/** + * @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 Ac=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],zc=ht("table",Ac);/** + * @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 Lc=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],di=ht("trending-down",Lc);/** + * @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 Dc=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Gn=ht("video",Dc);/** + * @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 $c=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Dr=ht("wand-sparkles",$c);function Fc(t,s){const a=gl(t);return isNaN(s)?sc(t,NaN):(a.setDate(a.getDate()+s),a)}function mi(t,s){const a=jn(t),r=jn(s);return+a==+r}function Un(t){return mi(t,oi(t))}function Oc(t,s){return Fc(t,-1)}function Vn(t){return mi(t,Oc(oi(t)))}const ir=0,Cs=1,ea=2,ui=4;function Wn(t){return()=>t}function Bc(t){t()}function xi(t,s){return a=>t(s(a))}function qn(t,s){return()=>t(s)}function Pc(t,s){return a=>t(s,a)}function Yr(t){return t!==void 0}function Hc(...t){return()=>{t.map(Bc)}}function ta(){}function lr(t,s){return s(t),t}function Qc(t,s){return s(t)}function Ze(...t){return t}function Ve(t,s){return t(Cs,s)}function Ie(t,s){t(ir,s)}function Kr(t){t(ea)}function tt(t){return t(ui)}function ue(t,s){return Ve(t,Pc(s,ir))}function ts(t,s){const a=t(Cs,r=>{a(),s(r)});return a}function Yn(t){let s,a;return r=>o=>{s=o,a&&clearTimeout(a),a=setTimeout(()=>{r(s)},t)}}function pi(t,s){return t===s}function Je(t=pi){let s;return a=>r=>{t(s,r)||(s=r,a(r))}}function ve(t){return s=>a=>{t(a)&&s(a)}}function ie(t){return s=>xi(s,t)}function ns(t){return s=>()=>{s(t)}}function Q(t,...s){const a=Gc(...s);return((r,o)=>{switch(r){case ea:Kr(t);return;case Cs:return Ve(t,a(o))}})}function os(t,s){return a=>r=>{a(s=t(s,r))}}function Fs(t){return s=>a=>{t>0?t--:s(a)}}function vs(t){let s=null,a;return r=>o=>{s=o,!a&&(a=setTimeout(()=>{a=void 0,r(s)},t))}}function Te(...t){const s=new Array(t.length);let a=0,r=null;const o=2**t.length-1;return t.forEach((n,i)=>{const l=2**i;Ve(n,c=>{const d=a;a|=l,s[i]=c,d!==o&&a===o&&r&&(r(),r=null)})}),n=>i=>{const l=()=>{n([i].concat(s))};a===o?l():r=l}}function Gc(...t){return s=>t.reduceRight(Qc,s)}function Uc(t){let s,a;const r=()=>s?.();return function(o,n){switch(o){case Cs:return n?a===n?void 0:(r(),a=n,s=Ve(t,n),s):(r(),ta);case ea:r(),a=null;return}}}function W(t){let s=t;const a=Le();return((r,o)=>{switch(r){case ir:s=o;break;case Cs:{o(s);break}case ui:return s}return a(r,o)})}function yt(t,s){return lr(W(s),a=>ue(t,a))}function Le(){const t=[];return((s,a)=>{switch(s){case ir:t.slice().forEach(r=>{r(a)});return;case ea:t.splice(0,t.length);return;case Cs:return t.push(a),()=>{const r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function zt(t){return lr(Le(),s=>ue(t,s))}function He(t,s=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:s,id:Vc(),singleton:a}}const Vc=()=>Symbol();function Wc(t){const s=new Map,a=({constructor:r,dependencies:o,id:n,singleton:i})=>{if(i&&s.has(n))return s.get(n);const l=r(o.map(c=>a(c)));return i&&s.set(n,l),l};return a(t)}function ct(...t){const s=Le(),a=new Array(t.length);let r=0;const o=2**t.length-1;return t.forEach((n,i)=>{const l=2**i;Ve(n,c=>{a[i]=c,r|=l,r===o&&Ie(s,a)})}),function(n,i){switch(n){case ea:{Kr(s);return}case Cs:return r===o&&i(a),Ve(s,i)}}}function be(t,s=pi){return Q(t,Je(s))}function $r(...t){return function(s,a){switch(s){case ea:return;case Cs:return Hc(...t.map(r=>Ve(r,a)))}}}const xt={DEBUG:0,INFO:1,WARN:2,ERROR:3},qc={[xt.DEBUG]:"debug",[xt.ERROR]:"error",[xt.INFO]:"log",[xt.WARN]:"warn"},Yc=()=>typeof globalThis>"u"?window:globalThis,Is=He(()=>{const t=W(xt.ERROR);return{log:W((s,a,r=xt.INFO)=>{const o=Yc().VIRTUOSO_LOG_LEVEL??tt(t);r>=o&&console[qc[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",s,a)}),logLevel:t}},[],{singleton:!0});function Bs(t,s,a){return Xr(t,s,a).callbackRef}function Xr(t,s,a){const r=de.useRef(null);let o=i=>{};const n=de.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const c=i[0].target;c.offsetParent!==null&&t(c)};a?l():requestAnimationFrame(l)}):null,[t,a]);return o=i=>{i&&s?(n?.observe(i),r.current=i):(r.current&&n?.unobserve(r.current),r.current=null)},{callbackRef:o,ref:r}}function Kc(t,s,a,r,o,n,i,l,c){const d=de.useCallback(m=>{const f=Xc(m.children,s,l?"offsetWidth":"offsetHeight",o);let h=m.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const b=h.lastElementChild.dataset.viewportType==="window";let y;b&&(y=h.ownerDocument.defaultView);const j=i?l?i.scrollLeft:i.scrollTop:b?l?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:l?h.scrollLeft:h.scrollTop,k=i?l?i.scrollWidth:i.scrollHeight:b?l?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:l?h.scrollWidth:h.scrollHeight,p=i?l?i.offsetWidth:i.offsetHeight:b?l?y.innerWidth:y.innerHeight:l?h.offsetWidth:h.offsetHeight;r({scrollHeight:k,scrollTop:Math.max(j,0),viewportHeight:p}),n?.(l?Kn("column-gap",getComputedStyle(m).columnGap,o):Kn("row-gap",getComputedStyle(m).rowGap,o)),f!==null&&t(f)},[t,s,o,n,i,r,l]);return Xr(d,a,c)}function Xc(t,s,a,r){const o=t.length;if(o===0)return null;const n=[];for(let i=0;i{if(!c?.offsetParent)return;const d=c.getBoundingClientRect(),m=d.width;let f,h;if(s){const b=s.getBoundingClientRect(),y=d.top-b.top;h=b.height-Math.max(0,y),f=y+s.scrollTop}else{const b=i.current.ownerDocument.defaultView;h=b.innerHeight-Math.max(0,d.top),f=d.top+b.scrollY}r.current={listHeight:d.height,offsetTop:f,visibleHeight:h,visibleWidth:m},t(r.current)},[t,s]),{callbackRef:n,ref:i}=Xr(o,!0,a),l=de.useCallback(()=>{o(i.current)},[o,i]);return de.useEffect(()=>{if(s){s.addEventListener("scroll",l);const d=new ResizeObserver(()=>{requestAnimationFrame(l)});return d.observe(s),()=>{s.removeEventListener("scroll",l),d.unobserve(s)}}const c=i.current?.ownerDocument.defaultView;return c?.addEventListener("scroll",l),c?.addEventListener("resize",l),()=>{c?.removeEventListener("scroll",l),c?.removeEventListener("resize",l)}},[l,s,i]),n}const Ct=He(()=>{const t=Le(),s=Le(),a=W(0),r=Le(),o=W(0),n=Le(),i=Le(),l=W(0),c=W(0),d=W(0),m=W(0),f=Le(),h=Le(),b=W(!1),y=W(!1),j=W(!1);return ue(Q(t,ie(({scrollTop:k})=>k)),s),ue(Q(t,ie(({scrollHeight:k})=>k)),i),ue(s,o),{deviation:a,fixedFooterHeight:d,fixedHeaderHeight:c,footerHeight:m,headerHeight:l,horizontalDirection:y,scrollBy:h,scrollContainerState:t,scrollHeight:i,scrollingInProgress:b,scrollTo:f,scrollTop:s,skipAnimationFrameInResizeObserver:j,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:n}},[],{singleton:!0}),Na={lvl:0};function fi(t,s){const a=t.length;if(a===0)return[];let{index:r,value:o}=s(t[0]);const n=[];for(let i=1;is&&(l=l.concat(Or(o,s,a))),r>=s&&r<=a&&l.push({k:r,v:i}),r<=a&&(l=l.concat(Or(n,s,a))),l}function Ga(t){const{l:s,lvl:a,r}=t;if(r.lvl>=a-1&&s.lvl>=a-1)return t;if(a>r.lvl+1){if(vr(s))return wi(ut(t,{lvl:a-1}));if(!qe(s)&&!qe(s.r))return ut(s.r,{l:ut(s,{r:s.r.l}),lvl:a,r:ut(t,{l:s.r.r,lvl:a-1})});throw new Error("Unexpected empty nodes")}if(vr(t))return Br(ut(t,{lvl:a-1}));if(!qe(r)&&!qe(r.l)){const o=r.l,n=vr(o)?r.lvl-1:r.lvl;return ut(o,{l:ut(t,{lvl:a-1,r:o.l}),lvl:o.lvl+1,r:Br(ut(r,{l:o.r,lvl:n}))})}throw new Error("Unexpected empty nodes")}function ut(t,s){return vi(s.k!==void 0?s.k:t.k,s.v!==void 0?s.v:t.v,s.lvl!==void 0?s.lvl:t.lvl,s.l!==void 0?s.l:t.l,s.r!==void 0?s.r:t.r)}function gi(t){return qe(t.r)?t.l:Ga(ut(t,{r:gi(t.r)}))}function vr(t){return qe(t)||t.lvl>t.r.lvl}function bi(t){return qe(t.r)?[t.k,t.v]:bi(t.r)}function vi(t,s,a,r=Na,o=Na){return{k:t,l:r,lvl:a,r:o,v:s}}function Xn(t){return Br(wi(t))}function wi(t){const{l:s}=t;return!qe(s)&&s.lvl===t.lvl?ut(s,{r:ut(t,{l:s.r})}):t}function Br(t){const{lvl:s,r:a}=t;return!qe(a)&&!qe(a.r)&&a.lvl===s&&a.r.lvl===s?ut(a,{l:ut(t,{r:a.l}),lvl:s+1}):t}function Jc(t){return fi(t,({k:s,v:a})=>({index:s,value:a}))}function Ni(t,s){return!!(t&&t.startIndex===s.startIndex&&t.endIndex===s.endIndex)}function ya(t,s){return!!(t&&t[0]===s[0]&&t[1]===s[1])}const Jr=He(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function ji(t,s,a){return t[er(t,s,a)]}function er(t,s,a,r=0){let o=t.length-1;for(;r<=o;){const n=Math.floor((r+o)/2),i=t[n],l=a(i,s);if(l===0)return n;if(l===-1){if(o-r<2)return n-1;o=n-1}else{if(o===r)return n;r=n+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${s}`)}function Zc(t,s,a,r){const o=er(t,s,r),n=er(t,a,r,o);return t.slice(o,n+1)}function ks(t,s){return Math.round(t.getBoundingClientRect()[s])}function cr(t){return!qe(t.groupOffsetTree)}function Zr({index:t},s){return s===t?0:s=f||n===h)&&(t=Fr(t,f)):(d=h!==n,c=!0),m>o&&o>=f&&h!==n&&(t=At(t,o+1,h));d&&(t=At(t,i,n))}return[t,a]}function sd(t){return typeof t.groupIndex<"u"}function ad({offset:t},s){return s===t?0:s0?l+a:l}function yi(t,s){if(!cr(s))return t;let a=0;for(;s.groupIndices[a]<=t+a;)a++;return t+a}function Si(t,s,a){if(sd(t))return s.groupIndices[t.groupIndex]+1;const r=t.index==="LAST"?a:t.index;let o=yi(r,s);return o=Math.max(0,o,Math.min(a,o)),o}function rd(t,s,a,r=0){return r>0&&(s=Math.max(s,ji(t,r,Zr).offset)),fi(Zc(t,s,a,ad),id)}function nd(t,[s,a,r,o]){s.length>0&&r("received item sizes",s,xt.DEBUG);const n=t.sizeTree;let i=n,l=0;if(a.length>0&&qe(n)&&s.length===2){const h=s[0].size,b=s[1].size;i=a.reduce((y,j)=>At(At(y,j,h),j+1,b),i)}else[i,l]=td(i,s);if(i===n)return t;const{lastIndex:c,lastOffset:d,lastSize:m,offsetTree:f}=Pr(t.offsetTree,l,i,o);return{groupIndices:a,groupOffsetTree:a.reduce((h,b)=>At(h,b,Sa(b,f,o)),Ys()),lastIndex:c,lastOffset:d,lastSize:m,offsetTree:f,sizeTree:i}}function od(t){return Ls(t).map(({k:s,v:a},r,o)=>{const n=o[r+1];return{endIndex:n!==void 0?n.k-1:1/0,size:a,startIndex:s}})}function Jn(t,s){let a=0,r=0;for(;ao.start===r&&(o.end===s||o.end===1/0)&&o.value===a}const cd={offsetHeight:"height",offsetWidth:"width"},ms=He(([{log:t},{recalcInProgress:s}])=>{const a=Le(),r=Le(),o=yt(r,0),n=Le(),i=Le(),l=W(0),c=W([]),d=W(void 0),m=W(void 0),f=W(void 0),h=W(void 0),b=W((v,S)=>ks(v,cd[S])),y=W(void 0),j=W(0),k=ed(),p=yt(Q(a,Te(c,t,j),os(nd,k),Je()),k),N=yt(Q(c,Je(),os((v,S)=>({current:S,prev:v.current}),{current:[],prev:[]}),ie(({prev:v})=>v)),[]);ue(Q(c,ve(v=>v.length>0),Te(p,j),ie(([v,S,w])=>{const z=v.reduce((O,T,G)=>At(O,T,Sa(T,S.offsetTree,w)||G),Ys());return{...S,groupIndices:v,groupOffsetTree:z}})),p),ue(Q(r,Te(p),ve(([v,{lastIndex:S}])=>v[{endIndex:S,size:w,startIndex:v}])),a),ue(d,m);const I=yt(Q(d,ie(v=>v===void 0)),!0);ue(Q(m,ve(v=>v!==void 0&&qe(tt(p).sizeTree)),ie(v=>{const S=tt(f),w=tt(c).length>0;return S!==void 0&&S!==0?w?[{endIndex:0,size:S,startIndex:0},{endIndex:1,size:v,startIndex:1}]:[]:[{endIndex:0,size:v,startIndex:0}]})),a),ue(Q(h,ve(v=>v!==void 0&&v.length>0&&qe(tt(p).sizeTree)),ie(v=>{const S=[];let w=v[0],z=0;for(let O=1;Ov!==void 0&&S!==void 0),ie(([v,S,w])=>{const z=[];for(let O=0;O({changed:w!==v,sizes:w}),{changed:!1,sizes:k}),ie(v=>v.changed)));Ve(Q(l,os((v,S)=>({diff:v.prev-S,prev:S}),{diff:0,prev:0}),ie(v=>v.diff)),v=>{const{groupIndices:S}=tt(p);if(v>0)Ie(s,!0),Ie(n,v+Jn(v,S));else if(v<0){const w=tt(N);w.length>0&&(v-=Jn(-v,w)),Ie(i,v)}}),Ve(Q(l,Te(t)),([v,S])=>{v<0&&S("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},xt.ERROR)});const C=zt(n);ue(Q(n,Te(p),ie(([v,S])=>{const w=S.groupIndices.length>0,z=[],O=S.lastSize;if(w){const T=ja(S.sizeTree,0);let G=0,q=0;for(;G{let pe=le.ranges;return le.prevSize!==0&&(pe=[...le.ranges,{endIndex:ae+v-1,size:le.prevSize,startIndex:le.prevIndex}]),{prevIndex:ae+v,prevSize:fe,ranges:pe}},{prevIndex:v,prevSize:0,ranges:z}).ranges}return Ls(S.sizeTree).reduce((T,{k:G,v:q})=>({prevIndex:G+v,prevSize:q,ranges:[...T.ranges,{endIndex:G+v-1,size:T.prevSize,startIndex:T.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),a);const U=zt(Q(i,Te(p,j),ie(([v,{offsetTree:S},w])=>{const z=-v;return Sa(z,S,w)})));return ue(Q(i,Te(p,j),ie(([v,S,w])=>{if(S.groupIndices.length>0){if(qe(S.sizeTree))return S;let O=Ys();const T=tt(N);let G=0,q=0,se=0;for(;G<-v;){se=T[q];const le=T[q+1]-se-1;q++,G+=le+1}if(O=Ls(S.sizeTree).reduce((le,{k:ae,v:fe})=>At(le,Math.max(0,ae+v),fe),O),G!==-v){const le=ja(S.sizeTree,se);O=At(O,0,le);const ae=ss(S.sizeTree,-v+1)[1];O=At(O,1,ae)}return{...S,sizeTree:O,...Pr(S.offsetTree,0,O,w)}}const z=Ls(S.sizeTree).reduce((O,{k:T,v:G})=>At(O,Math.max(0,T+v),G),Ys());return{...S,sizeTree:z,...Pr(S.offsetTree,0,z,w)}})),p),{beforeUnshiftWith:C,data:y,defaultItemSize:m,firstItemIndex:l,fixedItemSize:d,fixedGroupSize:f,gap:j,groupIndices:c,heightEstimates:h,itemSize:b,listRefresh:A,shiftWith:i,shiftWithOffset:U,sizeRanges:a,sizes:p,statefulTotalCount:o,totalCount:r,trackItemSizes:I,unshiftWith:n}},Ze(Is,Jr),{singleton:!0});function dd(t){return t.reduce((s,a)=>(s.groupIndices.push(s.totalCount),s.totalCount+=a+1,s),{groupIndices:[],totalCount:0})}const ki=He(([{groupIndices:t,sizes:s,totalCount:a},{headerHeight:r,scrollTop:o}])=>{const n=Le(),i=Le(),l=zt(Q(n,ie(dd)));return ue(Q(l,ie(c=>c.totalCount)),a),ue(Q(l,ie(c=>c.groupIndices)),t),ue(Q(ct(o,s,r),ve(([c,d])=>cr(d)),ie(([c,d,m])=>ss(d.groupOffsetTree,Math.max(c-m,0),"v")[0]),Je(),ie(c=>[c])),i),{groupCounts:n,topItemsIndexes:i}},Ze(ms,Ct)),Ts=He(([{log:t}])=>{const s=W(!1),a=zt(Q(s,ve(r=>r),Je()));return Ve(s,r=>{r&&tt(t)("props updated",{},xt.DEBUG)}),{didMount:a,propsReady:s}},Ze(Is),{singleton:!0}),md=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ci(t){const s=typeof t=="number"?{index:t}:t;return s.align||(s.align="start"),(!s.behavior||!md)&&(s.behavior="auto"),s.offset===void 0&&(s.offset=0),s}const Ea=He(([{gap:t,listRefresh:s,sizes:a,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:n,footerHeight:i,headerHeight:l,scrollingInProgress:c,scrollTo:d,smoothScrollTargetReached:m,viewportHeight:f},{log:h}])=>{const b=Le(),y=Le(),j=W(0);let k=null,p=null,N=null;function I(){k!==null&&(k(),k=null),N!==null&&(N(),N=null),p&&(clearTimeout(p),p=null),Ie(c,!1)}return ue(Q(b,Te(a,f,r,j,l,i,h),Te(t,n,o),ie(([[A,C,U,v,S,w,z,O],T,G,q])=>{const se=Ci(A),{align:le,behavior:ae,offset:fe}=se,pe=v-1,P=Si(se,C,pe);let Y=Sa(P,C.offsetTree,T)+w;le==="end"?(Y+=G+ss(C.sizeTree,P)[1]-U+q,P===pe&&(Y+=z)):le==="center"?Y+=(G+ss(C.sizeTree,P)[1]-U+q)/2:Y-=S,fe!==void 0&&fe!==0&&(Y+=fe);const M=K=>{I(),K?(O("retrying to scroll to",{location:A},xt.DEBUG),Ie(b,A)):(Ie(y,!0),O("list did not change, scroll successful",{},xt.DEBUG))};if(I(),ae==="smooth"){let K=!1;N=Ve(s,re=>{K=K||re}),k=ts(m,()=>{M(K)})}else k=ts(Q(s,ud(150)),M);return p=setTimeout(()=>{I()},1200),Ie(c,!0),O("scrolling from index to",{behavior:ae,index:P,top:Y},xt.DEBUG),{behavior:ae,top:Y}})),d),{scrollTargetReached:y,scrollToIndex:b,topListHeight:j}},Ze(ms,Ct,Is),{singleton:!0});function ud(t){return s=>{const a=setTimeout(()=>{s(!1)},t);return r=>{r&&(s(!0),clearTimeout(a))}}}function en(t,s){t===0?s():requestAnimationFrame(()=>{en(t-1,s)})}function tn(t,s){const a=s-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}const Ra=He(([{defaultItemSize:t,listRefresh:s,sizes:a},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:n},{didMount:i}])=>{const l=W(!0),c=W(0),d=W(!0);return ue(Q(i,Te(c),ve(([m,f])=>f!==0),ns(!1)),l),ue(Q(i,Te(c),ve(([m,f])=>f!==0),ns(!1)),d),Ve(Q(ct(s,i),Te(l,a,t,d),ve(([[,m],f,{sizeTree:h},b,y])=>m&&(!qe(h)||Yr(b))&&!f&&!y),Te(c)),([,m])=>{ts(o,()=>{Ie(d,!0)}),en(4,()=>{ts(r,()=>{Ie(l,!0)}),Ie(n,m)})}),{initialItemFinalLocationReached:d,initialTopMostItemIndex:c,scrolledToInitialItem:l}},Ze(ms,Ct,Ea,Ts),{singleton:!0});function Ii(t,s){return Math.abs(t-s)<1.01}const ka="up",ba="down",xd="none",pd={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},hd=0,_a=He(([{footerHeight:t,headerHeight:s,scrollBy:a,scrollContainerState:r,scrollTop:o,viewportHeight:n}])=>{const i=W(!1),l=W(!0),c=Le(),d=Le(),m=W(4),f=W(hd),h=yt(Q($r(Q(be(o),Fs(1),ns(!0)),Q(be(o),Fs(1),ns(!1),Yn(100))),Je()),!1),b=yt(Q($r(Q(a,ns(!0)),Q(a,ns(!1),Yn(200))),Je()),!1);ue(Q(ct(be(o),be(f)),ie(([N,I])=>N<=I),Je()),l),ue(Q(l,vs(50)),d);const y=zt(Q(ct(r,be(n),be(s),be(t),be(m)),os((N,[{scrollHeight:I,scrollTop:A},C,U,v,S])=>{const w=A+C-I>-S,z={scrollHeight:I,scrollTop:A,viewportHeight:C};if(w){let T,G;return A>N.state.scrollTop?(T="SCROLLED_DOWN",G=N.state.scrollTop-A):(T="SIZE_DECREASED",G=N.state.scrollTop-A||N.scrollTopDelta),{atBottom:!0,atBottomBecause:T,scrollTopDelta:G,state:z}}let O;return z.scrollHeight>N.state.scrollHeight?O="SIZE_INCREASED":CN!==void 0&&N.atBottom===I.atBottom))),j=yt(Q(r,os((N,{scrollHeight:I,scrollTop:A,viewportHeight:C})=>{if(!Ii(N.scrollHeight,I)){const U=I-(A+C)<1;return N.scrollTop!==A&&U?{changed:!0,jump:N.scrollTop-A,scrollHeight:I,scrollTop:A}:{changed:!0,jump:0,scrollHeight:I,scrollTop:A}}return{changed:!1,jump:0,scrollHeight:I,scrollTop:A}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ve(N=>N.changed),ie(N=>N.jump)),0);ue(Q(y,ie(N=>N.atBottom)),i),ue(Q(i,vs(50)),c);const k=W(ba);ue(Q(r,ie(({scrollTop:N})=>N),Je(),os((N,I)=>tt(b)?{direction:N.direction,prevScrollTop:I}:{direction:IN.direction)),k),ue(Q(r,vs(50),ns(xd)),k);const p=W(0);return ue(Q(h,ve(N=>!N),ns(0)),p),ue(Q(o,vs(100),Te(h),ve(([N,I])=>I),os(([N,I],[A])=>[I,A],[0,0]),ie(([N,I])=>I-N)),p),{atBottomState:y,atBottomStateChange:c,atBottomThreshold:m,atTopStateChange:d,atTopThreshold:f,isAtBottom:i,isAtTop:l,isScrolling:h,lastJumpDueToItemResize:j,scrollDirection:k,scrollVelocity:p}},Ze(Ct)),Ca="top",Ia="bottom",Zn="none";function eo(t,s,a){return typeof t=="number"?a===ka&&s===Ca||a===ba&&s===Ia?t:0:a===ka?s===Ca?t.main:t.reverse:s===Ia?t.main:t.reverse}function to(t,s){return typeof t=="number"?t:t[s]??0}const sn=He(([{deviation:t,fixedHeaderHeight:s,headerHeight:a,scrollTop:r,viewportHeight:o}])=>{const n=Le(),i=W(0),l=W(0),c=W(0),d=yt(Q(ct(be(r),be(o),be(a),be(n,ya),be(c),be(i),be(s),be(t),be(l)),ie(([m,f,h,[b,y],j,k,p,N,I])=>{const A=m-N,C=k+p,U=Math.max(h-A,0);let v=Zn;const S=to(I,Ca),w=to(I,Ia);return b-=N,b+=h+p,y+=h+p,y-=N,b>m+C-S&&(v=ka),ym!==null),Je(ya)),[0,0]);return{increaseViewportBy:l,listBoundary:n,overscan:c,topListHeight:i,visibleRange:d}},Ze(Ct),{singleton:!0});function fd(t,s,a){if(cr(s)){const r=yi(t,s);return[{index:ss(s.groupOffsetTree,r)[0],offset:0,size:0},{data:a?.[0],index:r,offset:0,size:0}]}return[{data:a?.[0],index:t,offset:0,size:0}]}const wr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ua(t,s,a,r,o,n){const{lastIndex:i,lastOffset:l,lastSize:c}=o;let d=0,m=0;if(t.length>0){d=t[0].offset;const j=t[t.length-1];m=j.offset+j.size}const f=a-i,h=l+f*c+(f-1)*r,b=d,y=h-m;return{bottom:m,firstItemIndex:n,items:so(t,o,n),offsetBottom:y,offsetTop:d,top:b,topItems:so(s,o,n),topListHeight:s.reduce((j,k)=>k.size+j,0),totalCount:a}}function Ti(t,s,a,r,o,n){let i=0;if(a.groupIndices.length>0)for(const m of a.groupIndices){if(m-i>=t)break;i++}const l=t+i,c=tn(s,l),d=Array.from({length:l}).map((m,f)=>({data:n[f+c],index:f+c,offset:0,size:0}));return Ua(d,[],l,o,a,r)}function so(t,s,a){if(t.length===0)return[];if(!cr(s))return t.map(d=>({...d,index:d.index+a,originalIndex:d.index}));const r=t[0].index,o=t[t.length-1].index,n=[],i=Ks(s.groupOffsetTree,r,o);let l,c=0;for(const d of t){(!l||l.end{const j=W([]),k=W(0),p=Le(),N=W(0);ue(n.topItemsIndexes,j);const I=yt(Q(ct(b,y,be(c,ya),be(o),be(r),be(d),m,be(j),be(s),be(a),be(N),t),ve(([v,S,,w,,,,,,,,z])=>{const O=z!==void 0&&z.length!==w;return v&&!S&&!O}),ie(([,,[v,S],w,z,O,T,G,q,se,le,ae])=>{const fe=z,{offsetTree:pe,sizeTree:P}=fe,Y=tt(k);if(w===0)return{...wr,totalCount:w};if(v===0&&S===0)return Y===0?{...wr,totalCount:w}:Ti(Y,O,z,q,se,ae||[]);if(qe(P))return Y>0?null:Ua(fd(tn(O,w),fe,ae),[],w,se,fe,q);const M=[];if(G.length>0){const ee=G[0],g=G[G.length-1];let E=0;for(const R of Ks(P,ee,g)){const X=R.value,J=Math.max(R.start,ee),ne=Math.min(R.end,g);for(let ce=J;ce<=ne;ce++)M.push({data:ae?.[ce],index:ce,offset:E,size:X}),E+=X}}if(!T)return Ua([],M,w,se,fe,q);const K=G.length>0?G[G.length-1]+1:0,re=rd(pe,v,S,K);if(re.length===0)return null;const $e=w-1,Me=lr([],ee=>{for(const g of re){const E=g.value;let R=E.offset,X=g.start;const J=E.size;if(E.offset=S);ce++)ee.push({data:ae?.[ce],index:ce,offset:R,size:J}),R+=J+se}}),Qe=ao(le,Ca),H=ao(le,Ia);if(Me.length>0&&(Qe>0||H>0)){const ee=Me[0],g=Me[Me.length-1];if(Qe>0&&ee.index>K){const E=Math.min(Qe,ee.index-K),R=[];let X=ee.offset;for(let J=ee.index-1;J>=ee.index-E;J--){const ne=Ks(P,J,J)[0]?.value??ee.size;X-=ne+se,R.unshift({data:ae?.[J],index:J,offset:X,size:ne})}Me.unshift(...R)}if(H>0&&g.index<$e){const E=Math.min(H,$e-g.index);let R=g.offset+g.size+se;for(let X=g.index+1;X<=g.index+E;X++){const J=Ks(P,X,X)[0]?.value??g.size;Me.push({data:ae?.[X],index:X,offset:R,size:J}),R+=J+se}}}return Ua(Me,M,w,se,fe,q)}),ve(v=>v!==null),Je()),wr);ue(Q(t,ve(Yr),ie(v=>v?.length)),o),ue(Q(I,ie(v=>v.topListHeight)),f),ue(f,l),ue(Q(I,ie(v=>[v.top,v.bottom])),i),ue(Q(I,ie(v=>v.items)),p);const A=zt(Q(I,ve(({items:v})=>v.length>0),Te(o,t),ve(([{items:v},S])=>v[v.length-1].originalIndex===S-1),ie(([,v,S])=>[v-1,S]),Je(ya),ie(([v])=>v))),C=zt(Q(I,vs(200),ve(({items:v,topItems:S})=>v.length>0&&v[0].originalIndex===S.length),ie(({items:v})=>v[0].index),Je())),U=zt(Q(I,ve(({items:v})=>v.length>0),ie(({items:v})=>{let S=0,w=v.length-1;for(;v[S].type==="group"&&SS;)w--;return{endIndex:v[w].index,startIndex:v[S].index}}),Je(Ni)));return{endReached:A,initialItemCount:k,itemsRendered:p,listState:I,minOverscanItemCount:N,rangeChanged:U,startReached:C,topItemsIndexes:j,...h}},Ze(ms,ki,sn,Ra,Ea,_a,Ts,Jr),{singleton:!0}),Ei=He(([{fixedFooterHeight:t,fixedHeaderHeight:s,footerHeight:a,headerHeight:r},{listState:o}])=>{const n=Le(),i=yt(Q(ct(a,t,r,s,o),ie(([l,c,d,m,f])=>l+c+d+m+f.offsetBottom+f.bottom)),0);return ue(be(i),n),{totalListHeight:i,totalListHeightChanged:n}},Ze(Ct,Ps),{singleton:!0}),gd=He(([{viewportHeight:t},{totalListHeight:s}])=>{const a=W(!1),r=yt(Q(ct(a,t,s),ve(([o])=>o),ie(([,o,n])=>Math.max(0,o-n)),vs(0),Je()),0);return{alignToBottom:a,paddingTopAddition:r}},Ze(Ct,Ei),{singleton:!0}),Ri=He(()=>({context:W(null)})),bd=({itemBottom:t,itemTop:s,locationParams:{align:a,behavior:r,...o},viewportBottom:n,viewportTop:i})=>sn?{...o,align:a??"end",...r!==void 0?{behavior:r}:{}}:null,_i=He(([{gap:t,sizes:s,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:n,scrollingInProgress:i,scrollTop:l,viewportHeight:c},{scrollToIndex:d}])=>{const m=Le();return ue(Q(m,Te(s,c,a,n,o,r,l),Te(t),ie(([[f,h,b,y,j,k,p,N],I])=>{const{calculateViewLocation:A=bd,done:C,...U}=f,v=Si(f,h,y-1),S=Sa(v,h.offsetTree,I)+j+k,w=S+ss(h.sizeTree,v)[1],z=N+k,O=N+b-p,T=A({itemBottom:w,itemTop:S,locationParams:U,viewportBottom:O,viewportTop:z});return T!==null?C&&ts(Q(i,ve(G=>!G),Fs(tt(i)?1:2)),C):C?.(),T}),ve(f=>f!==null)),d),{scrollIntoView:m}},Ze(ms,Ct,Ea,Ps,Is),{singleton:!0});function ro(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const vd=(t,s)=>typeof t=="function"?ro(t(s)):s&&ro(t),wd=He(([{listRefresh:t,totalCount:s,fixedItemSize:a,data:r},{atBottomState:o,isAtBottom:n},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:c,propsReady:d},{log:m},{scrollingInProgress:f},{context:h},{scrollIntoView:b}])=>{const y=W(!1),j=Le();let k=null;function p(C){Ie(i,{align:"end",behavior:C,index:"LAST"})}Ve(Q(ct(Q(be(s),Fs(1)),c),Te(be(y),n,l,f),ie(([[C,U],v,S,w,z])=>{let O=U&&w,T="auto";return O&&(T=vd(v,S||z),O=O&&T!==!1),{followOutputBehavior:T,shouldFollow:O,totalCount:C}}),ve(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:U})=>{k!==null&&(k(),k=null),tt(a)!==void 0?requestAnimationFrame(()=>{tt(m)("following output to ",{totalCount:U},xt.DEBUG),p(C)}):k=ts(t,()=>{tt(m)("following output to ",{totalCount:U},xt.DEBUG),p(C),k=null})});function N(C){const U=ts(o,v=>{C&&!v.atBottom&&v.notAtBottomBecause==="SIZE_INCREASED"&&k===null&&(tt(m)("scrolling to bottom due to increased size",{},xt.DEBUG),p("auto"))});setTimeout(U,100)}Ve(Q(ct(be(y),s,d),ve(([C,,U])=>C!==!1&&U),os(({value:C},[,U])=>({refreshed:C===U,value:U}),{refreshed:!1,value:0}),ve(({refreshed:C})=>C),Te(y,s)),([,C])=>{tt(l)&&N(C!==!1)}),Ve(j,()=>{N(tt(y)!==!1)}),Ve(ct(be(y),o),([C,U])=>{C!==!1&&!U.atBottom&&U.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&p("auto")});const I=W(null),A=Le();return ue($r(Q(be(r),ie(C=>C?.length??0)),Q(be(s))),A),Ve(Q(ct(Q(A,Fs(1)),c),Te(be(I),l,f,h),ie(([[C,U],v,S,w,z])=>U&&S&&v?.({context:z,totalCount:C,scrollingInProgress:w})),ve(C=>!!C),vs(0)),C=>{k!==null&&(k(),k=null),tt(a)!==void 0?requestAnimationFrame(()=>{tt(m)("scrolling into view",{}),Ie(b,C)}):k=ts(t,()=>{tt(m)("scrolling into view",{}),Ie(b,C),k=null})}),{autoscrollToBottom:j,followOutput:y,scrollIntoViewOnChange:I}},Ze(ms,_a,Ea,Ra,Ts,Is,Ct,Ri,_i)),Nd=He(([{data:t,firstItemIndex:s,gap:a,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:n,listState:i},{didMount:l}])=>(ue(Q(l,Te(n),ve(([,c])=>c!==0),Te(o,r,s,a,t),ie(([[,c],d,m,f,h,b=[]])=>Ti(c,d,m,f,h,b))),i),{}),Ze(ms,Ra,Ps,Ts),{singleton:!0}),jd=He(([{didMount:t},{scrollTo:s},{listState:a}])=>{const r=W(0);return Ve(Q(t,Te(r),ve(([,o])=>o!==0),ie(([,o])=>({top:o}))),o=>{ts(Q(a,Fs(1),ve(n=>n.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(s,o)})})}),{initialScrollTop:r}},Ze(Ts,Ct,Ps),{singleton:!0}),Mi=He(([{scrollVelocity:t}])=>{const s=W(!1),a=Le(),r=W(!1);return ue(Q(t,Te(r,s,a),ve(([o,n])=>n!==!1&&n!==void 0),ie(([o,n,i,l])=>{const{enter:c,exit:d}=n;if(i){if(d(o,l))return!1}else if(c(o,l))return!0;return i}),Je()),s),Ve(Q(ct(s,t,a),Te(r)),([[o,n,i],l])=>{o&&l!==!1&&l!==void 0&&l.change&&l.change(n,i)}),{isSeeking:s,scrollSeekConfiguration:r,scrollSeekRangeChanged:a,scrollVelocity:t}},Ze(_a),{singleton:!0}),an=He(([{scrollContainerState:t,scrollTo:s}])=>{const a=Le(),r=Le(),o=Le(),n=W(!1),i=W(void 0);return ue(Q(ct(a,r),ie(([{scrollTop:l,viewportHeight:c},{offsetTop:d,listHeight:m}])=>({scrollHeight:m,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),ue(Q(s,Te(r),ie(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),o),{customScrollParent:i,useWindowScroll:n,windowScrollContainerState:a,windowScrollTo:o,windowViewportRect:r}},Ze(Ct)),yd=He(([{sizeRanges:t,sizes:s},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:o},{didMount:n},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:c}])=>{const d=Le(),m=W(void 0),f=W(null),h=W(null);return ue(l,f),ue(c,h),Ve(Q(d,Te(s,r,i,f,h,a)),([b,y,j,k,p,N,I])=>{const A=od(y.sizeTree);k&&p!==null&&N!==null&&(j=p.scrollTop-N.offsetTop),j-=I,b({ranges:A,scrollTop:j})}),ue(Q(m,ve(Yr),ie(Sd)),o),ue(Q(n,Te(m),ve(([,b])=>b!==void 0),Je(),ie(([,b])=>b.ranges)),t),{getState:d,restoreStateFrom:m}},Ze(ms,Ct,Ra,Ts,an));function Sd(t){return{align:"start",index:0,offset:t.scrollTop}}const kd=He(([{topItemsIndexes:t}])=>{const s=W(0);return ue(Q(s,ve(a=>a>=0),ie(a=>Array.from({length:a}).map((r,o)=>o))),t),{topItemCount:s}},Ze(Ps));function Ai(t){let s=!1,a;return(()=>(s||(s=!0,a=t()),a))}const Cd=Ai(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Id=He(([{deviation:t,scrollBy:s,scrollingInProgress:a,scrollTop:r},{isAtBottom:o,isScrolling:n,lastJumpDueToItemResize:i,scrollDirection:l},{listState:c},{beforeUnshiftWith:d,gap:m,shiftWithOffset:f,sizes:h},{log:b},{recalcInProgress:y}])=>{const j=zt(Q(c,Te(i),os(([,p,N,I],[{bottom:A,items:C,offsetBottom:U,totalCount:v},S])=>{const w=A+U;let z=0;return N===v&&p.length>0&&C.length>0&&(C[0].originalIndex===0&&p[0].originalIndex===0||(z=w-I,z!==0&&(z+=S))),[z,C,v,w]},[0,[],0,0]),ve(([p])=>p!==0),Te(r,l,a,o,b,y),ve(([,p,N,I,,,A])=>!A&&!I&&p!==0&&N===ka),ie(([[p],,,,,N])=>(N("Upward scrolling compensation",{amount:p},xt.DEBUG),p))));function k(p){p>0?(Ie(s,{behavior:"auto",top:-p}),Ie(t,0)):(Ie(t,0),Ie(s,{behavior:"auto",top:-p}))}return Ve(Q(j,Te(t,n)),([p,N,I])=>{I&&Cd()?Ie(t,N-p):k(-p)}),Ve(Q(ct(yt(n,!1),t,y),ve(([p,N,I])=>!p&&!I&&N!==0),ie(([p,N])=>N),vs(1)),k),ue(Q(f,ie(p=>({top:-p}))),s),Ve(Q(d,Te(h,m),ie(([p,{groupIndices:N,lastSize:I,sizeTree:A},C])=>{function U(O){return O*(I+C)}if(N.length===0)return U(p);let v=0;const S=ja(A,0);let w=0,z=0;for(;wp&&(v-=S,O=p-w+1),w+=O,v+=U(O),z++}return v})),p=>{Ie(t,p),requestAnimationFrame(()=>{Ie(s,{top:p}),requestAnimationFrame(()=>{Ie(t,0),Ie(y,!1)})})}),{deviation:t}},Ze(Ct,_a,Ps,ms,Is,Jr)),Td=He(([t,s,a,r,o,n,i,l,c,d,m])=>({...t,...s,...a,...r,...o,...n,...i,...l,...c,...d,...m}),Ze(sn,Nd,Ts,Mi,Ei,jd,gd,an,_i,Is,Ri)),zi=He(([{data:t,defaultItemSize:s,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:o,gap:n,groupIndices:i,heightEstimates:l,itemSize:c,sizeRanges:d,sizes:m,statefulTotalCount:f,totalCount:h,trackItemSizes:b},{initialItemFinalLocationReached:y,initialTopMostItemIndex:j,scrolledToInitialItem:k},p,N,I,A,{scrollToIndex:C},U,{topItemCount:v},{groupCounts:S},w])=>{const{listState:z,minOverscanItemCount:O,topItemsIndexes:T,rangeChanged:G,...q}=A;return ue(G,w.scrollSeekRangeChanged),ue(Q(w.windowViewportRect,ie(se=>se.visibleHeight)),p.viewportHeight),{data:t,defaultItemHeight:s,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:o,gap:n,groupCounts:S,heightEstimates:l,initialItemFinalLocationReached:y,initialTopMostItemIndex:j,scrolledToInitialItem:k,sizeRanges:d,topItemCount:v,topItemsIndexes:T,totalCount:h,...I,groupIndices:i,itemSize:c,listState:z,minOverscanItemCount:O,scrollToIndex:C,statefulTotalCount:f,trackItemSizes:b,rangeChanged:G,...q,...w,...p,sizes:m,...N}},Ze(ms,Ra,Ct,yd,wd,Ps,Ea,Id,kd,ki,Td));function Ed(t,s){const a={},r={};let o=0;const n=t.length;for(;o(p[N]=I=>{const A=k[s.methods[N]];Ie(A,I)},p),{})}function m(k){return i.reduce((p,N)=>(p[N]=Uc(k[s.events[N]]),p),{})}const f=de.forwardRef(function(k,p){const{children:N,...I}=k,[A]=de.useState(()=>lr(Wc(t),v=>{c(v,I)})),[C]=de.useState(qn(m,A));Da(()=>{for(const v of i)v in I&&Ve(C[v],I[v]);return()=>{Object.values(C).map(Kr)}},[I,C,A]),Da(()=>{c(A,I)}),de.useImperativeHandle(p,Wn(d(A)));const U=a;return e.jsx(l.Provider,{value:A,children:a!==void 0?e.jsx(U,{...Ed([...r,...o,...i],I),children:N}):N})}),h=k=>{const p=de.useContext(l);return de.useCallback(N=>{Ie(p[k],N)},[p,k])},b=k=>{const p=de.useContext(l)[k],N=de.useCallback(I=>Ve(p,I),[p]);return de.useSyncExternalStore(N,()=>tt(p),()=>tt(p))},y=k=>{const p=de.useContext(l)[k],[N,I]=de.useState(qn(tt,p));return Da(()=>Ve(p,A=>{A!==N&&I(Wn(A))}),[p,N]),N},j=parseInt(de.version)>=18?b:y;return{Component:f,useEmitter:(k,p)=>{const N=de.useContext(l)[k];Da(()=>Ve(N,p),[p,N])},useEmitterValue:j,usePublisher:h}}const Di=de.createContext(void 0),$i=de.createContext(void 0),Nr="-webkit-sticky",no="sticky",rn=Ai(()=>{if(typeof document>"u")return no;const t=document.createElement("div");return t.style.position=Nr,t.style.position===Nr?Nr:no}),Fi=typeof document<"u"?de.useLayoutEffect:de.useEffect;function jr(t){return"self"in t}function Rd(t){return"body"in t}function Oi(t,s,a,r=ta,o,n){const i=de.useRef(null),l=de.useRef(null),c=de.useRef(null),d=de.useCallback(h=>{let b,y,j;const k=h.target;if(Rd(k)||jr(k)){const N=jr(k)?k:k.defaultView;j=n===!0?N.scrollX:N.scrollY,b=n===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,y=n===!0?N.innerWidth:N.innerHeight}else j=n===!0?k.scrollLeft:k.scrollTop,b=n===!0?k.scrollWidth:k.scrollHeight,y=n===!0?k.offsetWidth:k.offsetHeight;const p=()=>{t({scrollHeight:b,scrollTop:Math.max(j,0),viewportHeight:y})};h.suppressFlushSync===!0?p():Ar.flushSync(p),l.current!==null&&(j===l.current||j<=0||j===b-y)&&(l.current=null,s(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,s,n]);de.useEffect(()=>{const h=o||i.current;return r(o||i.current),d({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",d,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",d)}},[i,d,a,r,o]);function m(h){const b=i.current;if(!b||(n===!0?"offsetWidth"in b&&b.offsetWidth===0:"offsetHeight"in b&&b.offsetHeight===0))return;const y=h.behavior==="smooth";let j,k,p;jr(b)?(k=Math.max(ks(b.document.documentElement,n===!0?"width":"height"),n===!0?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight),j=n===!0?b.innerWidth:b.innerHeight,p=n===!0?window.scrollX:window.scrollY):(k=b[n===!0?"scrollWidth":"scrollHeight"],j=ks(b,n===!0?"width":"height"),p=b[n===!0?"scrollLeft":"scrollTop"]);const N=k-j;if(h.top=Math.ceil(Math.max(Math.min(N,h.top),0)),Ii(j,k)||h.top===p){t({scrollHeight:k,scrollTop:p,viewportHeight:j}),y&&s(!0);return}y?(l.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,s(!0)},1e3)):l.current=null,n===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:h.top}),b.scrollTo(h)}function f(h){n===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:h.top}:{}}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:m}}function nn(t){return t}const _d=He(()=>{const t=W(l=>`Item ${l}`),s=W(l=>`Group ${l}`),a=W({}),r=W(nn),o=W("div"),n=W(ta),i=(l,c=null)=>yt(Q(a,ie(d=>d[l]),Je()),c);return{components:a,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:s,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:t,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:n,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Md=He(([t,s])=>({...t,...s}),Ze(zi,_d)),Ad=({height:t})=>e.jsx("div",{style:{height:t}}),zd={overflowAnchor:"none",position:rn(),zIndex:1},Bi={overflowAnchor:"none"},Ld={...Bi,display:"inline-block",height:"100%"},oo=de.memo(function({showTopList:t=!1}){const s=ye("listState"),a=Gt("sizeRanges"),r=ye("useWindowScroll"),o=ye("customScrollParent"),n=Gt("windowScrollContainerState"),i=Gt("scrollContainerState"),l=o||r?n:i,c=ye("itemContent"),d=ye("context"),m=ye("groupContent"),f=ye("trackItemSizes"),h=ye("itemSize"),b=ye("log"),y=Gt("gap"),j=ye("horizontalDirection"),{callbackRef:k}=Kc(a,h,f,t?ta:l,b,y,o,j,ye("skipAnimationFrameInResizeObserver")),[p,N]=de.useState(0);ln("deviation",q=>{p!==q&&N(q)});const I=ye("EmptyPlaceholder"),A=ye("ScrollSeekPlaceholder")??Ad,C=ye("ListComponent"),U=ye("ItemComponent"),v=ye("GroupComponent"),S=ye("computeItemKey"),w=ye("isSeeking"),z=ye("groupIndices").length>0,O=ye("alignToBottom"),T=ye("initialItemFinalLocationReached"),G=t?{}:{boxSizing:"border-box",...j?{display:"inline-block",height:"100%",marginLeft:p!==0?p:O?"auto":0,paddingLeft:s.offsetTop,paddingRight:s.offsetBottom,whiteSpace:"nowrap"}:{marginTop:p!==0?p:O?"auto":0,paddingBottom:s.offsetBottom,paddingTop:s.offsetTop},...T?{}:{visibility:"hidden"}};return!t&&s.totalCount===0&&I!==null&&I!==void 0?e.jsx(I,{...Nt(I,d)}):e.jsx(C,{...Nt(C,d),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:G,children:(t?s.topItems:s.items).map(q=>{const se=q.originalIndex,le=S(se+s.firstItemIndex,q.data,d);return w?u.createElement(A,{...Nt(A,d),height:q.size,index:q.index,key:le,type:q.type||"item",...q.type==="group"?{}:{groupIndex:q.groupIndex}}):q.type==="group"?u.createElement(v,{...Nt(v,d),"data-index":se,"data-item-index":q.index,"data-known-size":q.size,key:le,style:zd},m(q.index,d)):u.createElement(U,{...Nt(U,d),...Od(U,q.data),"data-index":se,"data-item-group-index":q.groupIndex,"data-item-index":q.index,"data-known-size":q.size,key:le,style:j?Ld:Bi},z?c(q.index,q.groupIndex,q.data,d):c(q.index,q.data,d))})})}),Dd={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},$d={outline:"none",overflowX:"auto",position:"relative"},on=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Pi=(t,s,a=0)=>({...on(t),position:s?"relative":"absolute",top:s?-a:0}),Fd={position:rn(),top:0,width:"100%",zIndex:1};function Nt(t,s){if(typeof t!="string")return{context:s}}function Od(t,s){return{item:typeof t=="string"?void 0:s}}const Bd=de.memo(function(){const t=ye("HeaderComponent"),s=Gt("headerHeight"),a=ye("HeaderFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),Pd=de.memo(function(){const t=ye("FooterComponent"),s=Gt("footerHeight"),a=ye("HeaderFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null});function Hi({useEmitter:t,useEmitterValue:s,usePublisher:a}){return de.memo(function({children:r,style:o,context:n,...i}){const l=a("scrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),m=s("scrollerRef"),f=s("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:b,scrollToCallback:y}=Oi(l,d,c,m,void 0,f);return t("scrollTo",y),t("scrollBy",h),e.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:b,style:{...f?$d:Dd,...o},tabIndex:0,...i,...Nt(c,n),children:r})})}function Qi({useEmitter:t,useEmitterValue:s,usePublisher:a}){return de.memo(function({children:r,style:o,context:n,...i}){const l=a("windowScrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),m=s("totalListHeight"),f=s("deviation"),h=s("customScrollParent"),b=de.useRef(null),y=s("scrollerRef"),{scrollByCallback:j,scrollerRef:k,scrollToCallback:p}=Oi(l,d,c,y,h);return Fi(()=>(k.current=h||b.current?.ownerDocument.defaultView,()=>{k.current=null}),[k,h]),t("windowScrollTo",p),t("scrollBy",j),e.jsx(c,{ref:b,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...m!==0?{height:m+f}:void 0},...i,...Nt(c,n),children:r})})}const Hd=({children:t})=>{const s=de.useContext(Di),a=Gt("viewportHeight"),r=Gt("fixedItemHeight"),o=ye("alignToBottom"),n=ye("horizontalDirection"),i=de.useMemo(()=>xi(a,c=>ks(c,n?"width":"height")),[a,n]),l=Bs(i,!0,ye("skipAnimationFrameInResizeObserver"));return de.useEffect(()=>{s&&(a(s.viewportHeight),r(s.itemHeight))},[s,a,r]),e.jsx("div",{"data-viewport-type":"element",ref:l,style:on(o),children:t})},Qd=({children:t})=>{const s=de.useContext(Di),a=Gt("windowViewportRect"),r=Gt("fixedItemHeight"),o=ye("customScrollParent"),n=ye("useWindowScroll"),i=ye("topListHeight"),l=hi(a,o,ye("skipAnimationFrameInResizeObserver")),c=ye("alignToBottom");return de.useEffect(()=>{s&&(r(s.itemHeight),a({listHeight:0,offsetTop:0,visibleHeight:s.viewportHeight,visibleWidth:100}))},[s,a,r]),e.jsx("div",{"data-viewport-type":"window",ref:l,style:Pi(c,n,i),children:t})},Gd=({children:t})=>{const s=ye("TopItemListComponent")??"div",a=ye("headerHeight"),r={...Fd,marginTop:`${a}px`},o=ye("context");return e.jsx(s,{style:r,...Nt(s,o),children:t})},Ud=de.memo(function(t){const s=ye("useWindowScroll"),a=ye("topItemsIndexes").length>0,r=ye("customScrollParent"),o=ye("context");return e.jsxs(r||s?qd:Wd,{...t,context:o,children:[a&&e.jsx(Gd,{children:e.jsx(oo,{showTopList:!0})}),e.jsxs(r||s?Qd:Hd,{children:[e.jsx(Bd,{}),e.jsx(oo,{}),e.jsx(Pd,{})]})]})}),{Component:Vd,useEmitter:ln,useEmitterValue:ye,usePublisher:Gt}=Li(Md,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Ud),Wd=Hi({useEmitter:ln,useEmitterValue:ye,usePublisher:Gt}),qd=Qi({useEmitter:ln,useEmitterValue:ye,usePublisher:Gt}),Yd=Vd,Kd=He(()=>{const t=W(d=>e.jsxs("td",{children:["Item $",d]})),s=W(null),a=W(d=>e.jsxs("td",{colSpan:1e3,children:["Group ",d]})),r=W(null),o=W(null),n=W({}),i=W(nn),l=W(ta),c=(d,m=null)=>yt(Q(n,ie(f=>f[d]),Je()),m);return{components:n,computeItemKey:i,context:s,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:t,groupContent:a,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}});Ze(zi,Kd);rn();const io={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Xd={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:lo,floor:tr,max:va,min:yr,round:co}=Math;function mo(t,s,a){return Array.from({length:s-t+1}).map((r,o)=>({data:a===null?null:a[o+t],index:o+t}))}function Jd(t){return{...Xd,items:t}}function $a(t,s){return t!==void 0&&t.width===s.width&&t.height===s.height}function Zd(t,s){return t!==void 0&&t.column===s.column&&t.row===s.row}const em=He(([{increaseViewportBy:t,listBoundary:s,overscan:a,visibleRange:r},{footerHeight:o,headerHeight:n,scrollBy:i,scrollContainerState:l,scrollTo:c,scrollTop:d,smoothScrollTargetReached:m,viewportHeight:f},h,b,{didMount:y,propsReady:j},{customScrollParent:k,useWindowScroll:p,windowScrollContainerState:N,windowScrollTo:I,windowViewportRect:A},C])=>{const U=W(0),v=W(0),S=W(io),w=W({height:0,width:0}),z=W({height:0,width:0}),O=Le(),T=Le(),G=W(0),q=W(null),se=W({column:0,row:0}),le=Le(),ae=Le(),fe=W(!1),pe=W(0),P=W(!0),Y=W(!1),M=W(!1);Ve(Q(y,Te(pe),ve(([H,ee])=>ee!==0)),()=>{Ie(P,!1)}),Ve(Q(ct(y,P,z,w,pe,Y),ve(([H,ee,g,E,,R])=>H&&!ee&&g.height!==0&&E.height!==0&&!R)),([,,,,H])=>{Ie(Y,!0),en(1,()=>{Ie(O,H)}),ts(Q(d),()=>{Ie(s,[0,0]),Ie(P,!0)})}),ue(Q(ae,ve(H=>H!=null&&H.scrollTop>0),ns(0)),v),Ve(Q(y,Te(ae),ve(([,H])=>H!=null)),([,H])=>{H&&(Ie(w,H.viewport),Ie(z,H.item),Ie(se,H.gap),H.scrollTop>0&&(Ie(fe,!0),ts(Q(d,Fs(1)),ee=>{Ie(fe,!1)}),Ie(c,{top:H.scrollTop})))}),ue(Q(w,ie(({height:H})=>H)),f),ue(Q(ct(be(w,$a),be(z,$a),be(se,(H,ee)=>H!==void 0&&H.column===ee.column&&H.row===ee.row),be(d)),ie(([H,ee,g,E])=>({gap:g,item:ee,scrollTop:E,viewport:H}))),le),ue(Q(ct(be(U),r,be(se,Zd),be(z,$a),be(w,$a),be(q),be(v),be(fe),be(P),be(pe)),ve(([,,,,,,,H])=>!H),ie(([H,[ee,g],E,R,X,J,ne,,ce,$])=>{const{column:oe,row:xe}=E,{height:we,width:te}=R,{width:he}=X;if(ne===0&&(H===0||he===0))return io;if(te===0){const B=tn($,H),Ae=B+Math.max(ne-1,0);return Jd(mo(B,Ae,J))}const et=Gi(he,te,oe);let Fe,Ke;ce?ee===0&&g===0&&ne>0?(Fe=0,Ke=ne-1):(Fe=et*tr((ee+xe)/(we+xe)),Ke=et*lo((g+xe)/(we+xe))-1,Ke=yr(H-1,va(Ke,et-1)),Fe=yr(Ke,va(0,Fe))):(Fe=0,Ke=-1);const rt=mo(Fe,Ke,J),{bottom:Rt,top:St}=uo(X,E,R,rt),Ft=lo(H/et),as=Ft*we+(Ft-1)*xe-Rt;return{bottom:Rt,itemHeight:we,items:rt,itemWidth:te,offsetBottom:as,offsetTop:St,top:St}})),S),ue(Q(q,ve(H=>H!==null),ie(H=>H.length)),U),ue(Q(ct(w,z,S,se),ve(([H,ee,{items:g}])=>g.length>0&&ee.height!==0&&H.height!==0),ie(([H,ee,{items:g},E])=>{const{bottom:R,top:X}=uo(H,E,ee,g);return[X,R]}),Je(ya)),s);const K=W(!1);ue(Q(d,Te(K),ie(([H,ee])=>ee||H!==0)),K);const re=zt(Q(ct(S,U),ve(([{items:H}])=>H.length>0),Te(K),ve(([[H,ee],g])=>{const E=H.items[H.items.length-1].index===ee-1;return(g||H.bottom>0&&H.itemHeight>0&&H.offsetBottom===0&&H.items.length===ee)&&E}),ie(([[,H]])=>H-1),Je())),$e=zt(Q(be(S),ve(({items:H})=>H.length>0&&H[0].index===0),ns(0),Je())),Me=zt(Q(be(S),Te(fe),ve(([{items:H},ee])=>H.length>0&&!ee),ie(([{items:H}])=>({endIndex:H[H.length-1].index,startIndex:H[0].index})),Je(Ni),vs(0)));ue(Me,b.scrollSeekRangeChanged),ue(Q(O,Te(w,z,U,se),ie(([H,ee,g,E,R])=>{const X=Ci(H),{align:J,behavior:ne,offset:ce}=X;let $=X.index;$==="LAST"&&($=E-1),$=va(0,$,yr(E-1,$));let oe=Hr(ee,R,g,$);return J==="end"?oe=co(oe-ee.height+g.height):J==="center"&&(oe=co(oe-ee.height/2+g.height/2)),ce!==void 0&&ce!==0&&(oe+=ce),{behavior:ne,top:oe}})),c);const Qe=yt(Q(S,ie(H=>H.offsetBottom+H.bottom)),0);return ue(Q(A,ie(H=>({height:H.visibleHeight,width:H.visibleWidth}))),w),{customScrollParent:k,data:q,deviation:G,footerHeight:o,gap:se,headerHeight:n,increaseViewportBy:t,initialItemCount:v,itemDimensions:z,overscan:a,restoreStateFrom:ae,scrollBy:i,scrollContainerState:l,scrollHeight:T,scrollTo:c,scrollToIndex:O,scrollTop:d,smoothScrollTargetReached:m,totalCount:U,useWindowScroll:p,viewportDimensions:w,windowScrollContainerState:N,windowScrollTo:I,windowViewportRect:A,...b,gridState:S,horizontalDirection:M,initialTopMostItemIndex:pe,totalListHeight:Qe,...h,endReached:re,propsReady:j,rangeChanged:Me,startReached:$e,stateChanged:le,stateRestoreInProgress:fe,...C}},Ze(sn,Ct,_a,Mi,Ts,an,Is));function Gi(t,s,a){return va(1,tr((t+a)/(tr(s)+a)))}function uo(t,s,a,r){const{height:o}=a;if(o===void 0||r.length===0)return{bottom:0,top:0};const n=Hr(t,s,a,r[0].index);return{bottom:Hr(t,s,a,r[r.length-1].index)+o,top:n}}function Hr(t,s,a,r){const o=Gi(t.width,a.width,s.column),n=tr(r/o),i=n*a.height+va(0,n-1)*s.row;return i>0?i+s.row:i}const tm=He(()=>{const t=W(f=>`Item ${f}`),s=W({}),a=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),n=W(nn),i=W("div"),l=W(ta),c=(f,h=null)=>yt(Q(s,ie(b=>b[f]),Je()),h),d=W(!1),m=W(!1);return ue(be(m),d),{components:s,computeItemKey:n,context:a,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:t,listClassName:o,ListComponent:c("List","div"),readyStateChanged:d,reportReadyState:m,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),sm=He(([t,s])=>({...t,...s}),Ze(em,tm)),am=de.memo(function(){const t=Xe("gridState"),s=Xe("listClassName"),a=Xe("itemClassName"),r=Xe("itemContent"),o=Xe("computeItemKey"),n=Xe("isSeeking"),i=Ut("scrollHeight"),l=Xe("ItemComponent"),c=Xe("ListComponent"),d=Xe("ScrollSeekPlaceholder"),m=Xe("context"),f=Ut("itemDimensions"),h=Ut("gap"),b=Xe("log"),y=Xe("stateRestoreInProgress"),j=Ut("reportReadyState"),k=Bs(de.useMemo(()=>p=>{const N=p.parentElement.parentElement.scrollHeight;i(N);const I=p.firstChild;if(I!==null){const{height:A,width:C}=I.getBoundingClientRect();f({height:A,width:C})}h({column:xo("column-gap",getComputedStyle(p).columnGap,b),row:xo("row-gap",getComputedStyle(p).rowGap,b)})},[i,f,h,b]),!0,!1);return Fi(()=>{t.itemHeight>0&&t.itemWidth>0&&j(!0)},[t]),y?null:e.jsx(c,{className:s,ref:k,...Nt(c,m),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(p=>{const N=o(p.index,p.data,m);return n?e.jsx(d,{...Nt(d,m),height:t.itemHeight,index:p.index,width:t.itemWidth},N):u.createElement(l,{...Nt(l,m),className:a,"data-index":p.index,key:N},r(p.index,p.data,m))})})}),rm=de.memo(function(){const t=Xe("HeaderComponent"),s=Ut("headerHeight"),a=Xe("headerFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,!1),o=Xe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),nm=de.memo(function(){const t=Xe("FooterComponent"),s=Ut("footerHeight"),a=Xe("headerFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,!1),o=Xe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),om=({children:t})=>{const s=de.useContext($i),a=Ut("itemDimensions"),r=Ut("viewportDimensions"),o=Bs(de.useMemo(()=>n=>{r(n.getBoundingClientRect())},[r]),!0,!1);return de.useEffect(()=>{s&&(r({height:s.viewportHeight,width:s.viewportWidth}),a({height:s.itemHeight,width:s.itemWidth}))},[s,r,a]),e.jsx("div",{ref:o,style:on(!1),children:t})},im=({children:t})=>{const s=de.useContext($i),a=Ut("windowViewportRect"),r=Ut("itemDimensions"),o=Xe("customScrollParent"),n=Xe("useWindowScroll"),i=hi(a,o,!1);return de.useEffect(()=>{s&&(r({height:s.itemHeight,width:s.itemWidth}),a({listHeight:0,offsetTop:0,visibleHeight:s.viewportHeight,visibleWidth:s.viewportWidth}))},[s,a,r]),e.jsx("div",{ref:i,style:Pi(!1,n),children:t})},lm=de.memo(function({...t}){const s=Xe("useWindowScroll"),a=Xe("customScrollParent"),r=a||s?dm:cm,o=a||s?im:om,n=Xe("context");return e.jsx(r,{...t,...Nt(r,n),children:e.jsxs(o,{children:[e.jsx(rm,{}),e.jsx(am,{}),e.jsx(nm,{})]})})}),{useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut}=Li(sm,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},lm),cm=Hi({useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut}),dm=Qi({useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut});function xo(t,s,a){return s!=="normal"&&s?.endsWith("px")!==!0&&a(`${t} was not resolved to pixel value correctly`,s,xt.WARN),s==="normal"?0:parseInt(s??"0",10)}function po(t){if(Array.isArray(t)){if(t.length<5||t.length>6)throw new Error(`Invalid bone format: expected [x,y,w,h,r,c?] but got ${t.length} elements`);const s=t;return{x:s[0],y:s[1],w:s[2],h:s[3],r:s[4],c:s[5]||void 0}}return t}const ho=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th"]);function mm(t,s="component",a){const r=t.getBoundingClientRect(),o=[],n=a?.leafTags?new Set([...ho,...a.leafTags]):ho,i=a?.captureRoundedBorders??!0,l=a?.excludeTags?new Set(a.excludeTags):null,c=a?.excludeSelectors??null;function d(m){const f=getComputedStyle(m);if(f.display==="none"||f.visibility==="hidden"||f.opacity==="0")return;const h=m.tagName.toLowerCase();if(l?.has(h)||c?.some(w=>m.matches(w)))return;const b=[...m.children].filter(w=>{const z=getComputedStyle(w);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}),y=h==="img"||h==="svg"||h==="video"||h==="canvas",j=h==="input"||h==="button"||h==="textarea"||h==="select",k=b.length===0||y||j||n.has(h),p=f.backgroundColor,N=p!=="rgba(0, 0, 0, 0)"&&p!=="transparent",I=f.backgroundImage!=="none",A=parseFloat(f.borderTopWidth)||0,C=i&&A>0&&f.borderTopColor!=="rgba(0, 0, 0, 0)"&&f.borderTopColor!=="transparent",U=(parseFloat(f.borderTopLeftRadius)||0)>0,v=N||I||C&&U,S=h==="tr"||h==="td"||h==="th"||h==="thead"||h==="tbody"||h==="table";if(k){const w=m.getBoundingClientRect();if(w.width<1||w.height<1)return;const z=y&&w.width>0&&w.height>0&&Math.abs(w.width-w.height)<4,O=S?0:z?"50%":fo(f,m)??8,T=r.width;o.push({x:T>0?+((w.left-r.left)/T*100).toFixed(4):0,y:Math.round(w.top-r.top),w:T>0?+(w.width/T*100).toFixed(4):0,h:Math.round(w.height),r:O});return}if(v){const w=m.getBoundingClientRect();if(w.width>=1&&w.height>=1){const z=S?0:fo(f,m)??8,O=r.width;o.push({x:O>0?+((w.left-r.left)/O*100).toFixed(4):0,y:Math.round(w.top-r.top),w:O>0?+(w.width/O*100).toFixed(4):0,h:Math.round(w.height),r:z,c:!0})}}for(const w of b)d(w)}for(const m of t.children)d(m);return{name:s,viewportWidth:Math.round(r.width),width:Math.round(r.width),height:Math.round(r.height),bones:o}}function fo(t,s){const a=parseFloat(t.borderTopLeftRadius)||0,r=parseFloat(t.borderTopRightRadius)||0,o=parseFloat(t.borderBottomRightRadius)||0,n=parseFloat(t.borderBottomLeftRadius)||0;if(a===0&&r===0&&o===0&&n===0)return;const i=s?(()=>{const d=s.getBoundingClientRect();return d.width>0&&d.height>0&&Math.abs(d.width-d.height)<4})():!1;return t.borderRadius==="50%"?"50%":Math.max(a,r,o,n)>9998?i?"50%":9999:a===r&&r===o&&o===n?a!==8?a:void 0:`${a}px ${r}px ${o}px ${n}px`}const um=new Map;function xm(t){return um.get(t)}function pm(){typeof window<"u"&&window.__BONEYARD_BUILD&&(window.__BONEYARD_SNAPSHOT=mm)}function hm(){return typeof window<"u"&&window.__BONEYARD_BUILD===!0}function fm(t,s){if(!("breakpoints"in t))return t;const a=Object.keys(t.breakpoints).map(Number).sort((o,n)=>o-n);if(a.length===0)return null;const r=[...a].reverse().find(o=>s>=o)??a[0];return t.breakpoints[r]??null}const Us={angle:110,start:30,end:70,speed:"2s",lightHighlight:"#f7f7f7",darkHighlight:"#2c2c2c"},ua={speed:"1.8s",lightAdjust:.3,darkAdjust:.02},go={web:{light:"#f0f0f0",dark:"#222222"}},gm=/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/;function bo(t,s){const a=t.match(gm);if(a){const[,r,o,n,i="1"]=a,l=Math.min(1,parseFloat(i)+s*.5);return`rgba(${r},${o},${n},${l.toFixed(3)})`}if(t.startsWith("#")&&t.length>=7){const r=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);if(!isNaN(r)&&!isNaN(o)&&!isNaN(n)){const i=Math.round(r+(255-r)*s),l=Math.round(o+(255-o)*s),c=Math.round(n+(255-n)*s);return`#${i.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}}return t}pm();let rs={};function vo({loading:t,children:s,name:a,initialBones:r,color:o,darkColor:n,animate:i,stagger:l=!1,transition:c=!1,boneClass:d,className:m,fallback:f,fixture:h,snapshotConfig:b}){const y=u.useRef(null),j=u.useRef(Math.random().toString(36).slice(2,8)).current,[k,p]=u.useState(0),[N,I]=u.useState(0),[A,C]=u.useState(!1);u.useEffect(()=>{if(typeof window>"u")return;const g=()=>{const X=document.documentElement.classList.contains("dark")||!!y.current?.closest(".dark");C(X)};g();const E=new MutationObserver(g);E.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const R=window.matchMedia("(prefers-color-scheme: dark)");return R.addEventListener("change",g),()=>{E.disconnect(),R.removeEventListener("change",g)}},[]);const U=o??rs.color??go.web.light,v=n??rs.darkColor??go.web.dark,S=A?v:U,w=i??rs.animate??"pulse",z=w===!0?"pulse":w===!1?"solid":w;u.useEffect(()=>{const g=y.current;if(!g)return;const E=new ResizeObserver(X=>{const J=X[0]?.contentRect;p(Math.round(J?.width??0)),J&&J.height>0&&I(Math.round(J.height))});E.observe(g);const R=g.getBoundingClientRect();return p(Math.round(R.width)),R.height>0&&I(Math.round(R.height)),()=>E.disconnect()},[]);const O={};if(a&&(O["data-boneyard"]=a,b&&(O["data-boneyard-config"]=JSON.stringify(b))),hm())return e.jsx("div",{ref:y,className:m,style:{position:"relative"},...O,children:e.jsx("div",{children:h??s})});const[T,G]=u.useState(!1);u.useLayoutEffect(()=>{G(!0)},[]);const q=r??(a?xm(a):void 0),se=T&&typeof window<"u"?window.innerWidth:0,le=k>0?k:se,ae=q&&le>0?fm(q,le):null,fe=d??rs.boneClass,pe=(()=>{const g=l??rs.stagger;return g===!0?80:g===!1||!g?0:g})(),P=(()=>{const g=c??rs.transition;return g===!0?300:g===!1||!g?0:g})(),[Y,M]=u.useState(!1),K=u.useRef(t),re=u.useRef(null);u.useEffect(()=>(K.current&&!t&&P>0&&ae&&(re.current&&clearTimeout(re.current),M(!0),re.current=setTimeout(()=>{M(!1),re.current=null},P)),K.current=t,()=>{re.current&&clearTimeout(re.current)}),[t,P,ae]);const $e=(t||Y)&&ae,Me=t&&!ae&&!Y,Qe=N>0?N:ae?.height??0,H=ae?.height??0,ee=Qe>0&&H>0?Qe/H:1;return e.jsxs("div",{ref:y,className:m,style:{position:"relative"},...O,children:[e.jsx("div",{"data-boneyard-content":"true",style:$e&&!Y?{visibility:"hidden"}:void 0,children:Me?f:s}),$e&&e.jsx("div",{"data-boneyard-overlay":"true",style:{position:"absolute",inset:0,overflow:"hidden",opacity:Y?0:1,transition:P>0?`opacity ${P}ms ease-out`:void 0},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ae.bones.filter(g=>!po(g).c).map((g,E)=>{const R=po(g),X=S;bo(S,A?ua.darkAdjust:ua.lightAdjust);const J=R.w/100*(ae.width??0),ne=R.r==="50%"&&Math.abs(J-R.h)<4,ce={position:"absolute",left:`${R.x}%`,top:R.y*ee,width:ne?R.h*ee:`${R.w}%`,height:R.h*ee,borderRadius:typeof R.r=="string"?R.r:`${R.r}px`,backgroundColor:X},$=rs.speed;if(z==="pulse")ce.animation=`bp-${j} ${$??ua.speed} ease-in-out infinite`;else if(z==="shimmer"){const oe=A?rs.darkShimmerColor??Us.darkHighlight:rs.shimmerColor??Us.lightHighlight,xe=rs.shimmerAngle??Us.angle;delete ce.backgroundColor,ce.backgroundImage=`linear-gradient(${xe}deg, ${X} ${Us.start}%, ${oe} 50%, ${X} ${Us.end}%)`,ce.backgroundSize="200% 100%",ce.animation=`bs-${j} ${$??Us.speed} linear infinite`}return pe>0&&(ce.opacity=0,ce.animation=`${ce.animation?ce.animation+",":""} by-${j} 0.3s ease-out ${E*pe}ms forwards`),e.jsx("div",{"data-boneyard-bone":"true",className:fe,style:ce},E)}),z==="pulse"&&e.jsx("style",{children:`@keyframes bp-${j}{0%,100%{background-color:${S}}50%{background-color:${bo(S,A?ua.darkAdjust:ua.lightAdjust)}}}`}),z==="shimmer"&&e.jsx("style",{children:`@keyframes bs-${j}{0%{background-position:200% 0}100%{background-position:-200% 0}}`}),pe>0&&e.jsx("style",{children:`@keyframes by-${j}{from{opacity:0}to{opacity:1}}`})]})})]})}async function cn(t){const s=$t(Ue,"managedStudents");try{const n=kt(s,jt("teacherId","==",t)),i=await Dt(n);if(!i.empty)return i.docs.map(c=>({id:c.id,...c.data()})).sort((c,d)=>String(c.name||"").localeCompare(String(d.name||"")))}catch{}const r=(await Wi(t)).map(n=>n.id);if(r.length===0)return[];const o=new Map;for(let n=0;n{o.set(d.id,{id:d.id,...d.data()})})}return Array.from(o.values()).sort((n,i)=>String(n.name||"").localeCompare(String(i.name||"")))}async function bm(t,s=[]){if(!t)return[];const a=$t(Ue,"users"),r=new Map,o=(i,l)=>String(l.role||"").toLowerCase()!=="student"?null:{uid:i,name:String(l.name||l.displayName||"").trim()||"Student",email:String(l.email||"").trim(),lrn:l.lrn&&String(l.lrn).trim()||void 0,photo:l.photo?String(l.photo).trim()||void 0:l.photoURL&&String(l.photoURL).trim()||void 0,grade:l.grade&&String(l.grade).trim()||void 0,section:l.section&&String(l.section).trim()||void 0,classSectionId:l.classSectionId&&String(l.classSectionId).trim()||void 0,adviserTeacherId:l.adviserTeacherId&&String(l.adviserTeacherId).trim()||void 0,role:"student",createdAt:l.createdAt||void 0};try{const i=kt(a,jt("role","==","student"),jt("adviserTeacherId","==",t));(await Dt(i)).docs.forEach(c=>{const d=o(c.id,c.data());d&&r.set(c.id,d)})}catch(i){console.warn("[studentService] adviser-scoped student query failed:",i)}const n=Array.from(new Set((s||[]).map(i=>(i||"").trim()).filter(i=>!!i)));for(let i=0;i{if(r.has(m.id))return;const f=o(m.id,m.data());f&&r.set(m.id,f)})}catch(c){console.warn("[studentService] section-scoped student query failed:",c)}}return Array.from(r.values()).sort((i,l)=>i.name.localeCompare(l.name))}function vm(t){const s=`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||"Student")}&background=random`,a=El.now();return{id:t.uid,accountUid:t.uid,lrn:t.lrn,name:t.name,email:t.email,avatar:t.photo||s,teacherId:t.adviserTeacherId,grade:t.grade,gradeLevel:us(t.grade)||void 0,section:t.section,classSectionId:t.classSectionId,riskLevel:"Low",engagementScore:0,avgQuizScore:0,weakestTopic:"N/A",classroomId:t.classSectionId||"",attendance:0,assignmentCompletion:0,lastActive:null,struggles:[],createdAt:t.createdAt||a,updatedAt:a,hasRegisteredAccount:!0,source:"registered"}}function wo(t){return(t||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\s]+/g," ").trim().replace(/\s+/g," ")}async function wm(t){const s=(t.studentId||"").trim();if(!s)throw new Error("Cannot reassign section: studentId is required.");const a=(t.newClassSectionId||"").trim()||Lt(t.newGrade,t.newSection);if(!a)throw new Error("Cannot reassign section: a target class section is required.");const r=(t.teacherId||"").trim(),o=(t.teacherName||"").trim(),n=(t.schoolYear||"").trim(),i=(t.previousClassSectionId||"").trim();try{const l=dt(Ue,"managedStudents",s),c=await gs(l);c.exists()&&await Zt(l,{grade:t.newGrade,section:t.newSection,classSectionId:a,gradeLevel:us(t.newGrade)||t.newGrade,teacherId:r||c.data()?.teacherId,updatedAt:ot()})}catch(l){console.warn("[studentService] reassignStudentSection: managedStudents update failed:",l)}if(t.isRegisteredAccount)try{await es(dt(Ue,"users",s),{grade:t.newGrade,section:t.newSection,classSectionId:a,adviserTeacherId:r||void 0,adviserTeacherName:o||void 0,updatedAt:ot()},{merge:!0})}catch(l){console.warn("[studentService] reassignStudentSection: users profile update failed:",l)}try{await dr({classSectionId:a,grade:t.newGrade,section:t.newSection,schoolYear:n,ownerTeacherId:r,ownerTeacherName:o,studentUids:[s]})}catch(l){console.warn("[studentService] reassignStudentSection: ownership upsert failed:",l)}if(i&&i!==a)try{const l=dt(Ue,"classSectionOwnership",i),c=await gs(l);if(c.exists()){const m=(c.data().studentUids||[]).filter(f=>f!==s);await Zt(l,{studentUids:m,updatedAt:ot()})}}catch(l){console.warn("[studentService] reassignStudentSection: previous-section cleanup failed:",l)}}async function Nm(t){const{apiService:s}=await _r(async()=>{const{apiService:d}=await import("./index-CGNBpSmO.js").then(m=>m.b6);return{apiService:d}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),a=(t.adviserTeacherId||"").trim();if(!a)throw new Error("createStudentAccountFromRoster requires adviserTeacherId.");const r=(t.email||"").trim().toLowerCase();if(!r)throw new Error("createStudentAccountFromRoster requires an email.");const o=(t.grade||"").trim(),n=(t.section||"").trim(),i=(t.classSectionId||"").trim()||(o&&n?Lt(o,n):""),c=((await s.createStudentAccount({name:(t.name||"").trim()||"Student",email:r,temporaryPassword:t.temporaryPassword,lrn:t.lrn?.trim()||void 0,grade:o||void 0,section:n||void 0,classSectionId:i||void 0,adviserTeacherId:a,adviserTeacherName:t.adviserTeacherName?.trim()||void 0,schoolYear:t.schoolYear?.trim()||void 0})).uid||"").trim();if(!c)throw new Error("Backend did not return a uid for the newly created student.");try{await es(dt(Ue,"managedStudents",c),sr({accountUid:c,name:(t.name||"").trim()||"Student",email:r,lrn:t.lrn?.trim()||null,teacherId:a,grade:o||null,gradeLevel:us(o)||null,section:n||null,classSectionId:i||null,classroomId:i||null,riskLevel:"Low",avgQuizScore:0,engagementScore:0,attendance:0,assignmentCompletion:0,weakestTopic:"",struggles:[],avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||"Student")}&background=random`,hasRegisteredAccount:!0,source:"both",createdAt:ot(),updatedAt:ot()}))}catch(d){console.warn("[studentService] createStudentAccountFromRoster: managed-student merge failed:",d)}if(i&&o&&n)try{await dr({classSectionId:i,grade:o,section:n,schoolYear:t.schoolYear||"",ownerTeacherId:a,ownerTeacherName:t.adviserTeacherName,studentUids:[c]})}catch(d){console.warn("[studentService] createStudentAccountFromRoster: ownership upsert failed:",d)}return{uid:c,email:r,temporaryPassword:t.temporaryPassword}}async function jm(t,s,a){const r=dt(Ue,"managedStudents",t);await Zt(r,{riskLevel:s,...a!==void 0?{riskConfidence:a}:{},updatedAt:ot()})}async function Vi(t,s,a){const r=Lt(s,a),o=dt(Ue,"managedStudents",t);await Zt(o,{grade:s,section:a,classSectionId:r,updatedAt:ot()})}function Lt(t,s){return[t,s].filter(Boolean).join("_").replace(/\s+/g,"_").toLowerCase()}function sr(t){const s=Object.entries(t).filter(([,a])=>a!==void 0);return Object.fromEntries(s)}function us(t){const s=(t||"").trim();if(!s)return null;const a=s.match(/(\d{1,2})/);return a?`Grade ${a[1]}`:/^grade\s+/i.test(s)?s.replace(/\s+/g," ").trim().replace(/^grade/i,"Grade"):s}function sa(t){const a=us(t)?.match(/(\d{1,2})/),r=a?Number.parseInt(a[1],10):Number.NaN;return Number.isFinite(r)?r>=11?"Senior High School":"Junior High School":null}function aa(t,s){const a=`${t||""} ${s||""}`.toUpperCase();if(!a.trim())return null;const r=["STEM","ABM","HUMSS","GAS","TVL","ICT"];for(const o of r)if(new RegExp(`\\b${o}\\b`).test(a))return o;return null}function ls(t){const s=(t||"").trim();if(!s)return{grade:"Grade 11",section:"Section A"};const[a="Grade 11",r="Section A"]=s.split(" - ").map(o=>o.trim());return{grade:a||"Grade 11",section:r||"Section A"}}function gt(t){const s=t.metadata||{},a=t.className||s.className,r=ls(a),o=(t.grade||s.grade||r.grade||"").trim()||null,n=(t.section||s.section||r.section||"").trim()||null,i=(t.classSectionId||s.classSectionId||"").trim()||(o&&n?Lt(o,n):"")||null,l=(a||"").trim()||(o&&n?`${o} - ${n}`:"")||null,c=us(t.gradeLevel||s.gradeLevel||o),d=(t.classification||s.classification||"").trim()||sa(c)||null,m=(t.strand||s.strand||"").trim()||aa(l,n)||null;return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:m,schoolYear:(t.schoolYear||s.schoolYear||"").trim()||null,ownerTeacherId:(t.ownerTeacherId||s.ownerTeacherId||"").trim()||null,ownerTeacherName:(t.ownerTeacherName||s.ownerTeacherName||"").trim()||null,adviserTeacherId:(t.adviserTeacherId||s.adviserTeacherId||"").trim()||null,adviserTeacherName:(t.adviserTeacherName||s.adviserTeacherName||"").trim()||null,managerId:(t.managerId||s.managerId||"").trim()||null,managerName:(t.managerName||s.managerName||"").trim()||null}}function ym(t){const s=(t.className||"").trim(),[a="",r=""]=s.split(" - "),o=(t.grade||a||"").trim()||null,n=(t.section||r||"").trim()||null,i=(t.classSectionId||"").trim()||(o&&n?Lt(o,n):"")||null,l=s||(o&&n?`${o} - ${n}`:null),c=us(t.gradeLevel||o),d=(t.classification||"").trim()||sa(c),m=(t.strand||"").trim()||aa(l,n);return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:m,schoolYear:(t.schoolYear||"").trim()||null,ownerTeacherId:(t.ownerTeacherId||"").trim()||null,ownerTeacherName:(t.ownerTeacherName||"").trim()||null,adviserTeacherId:(t.adviserTeacherId||"").trim()||null,adviserTeacherName:(t.adviserTeacherName||"").trim()||null,managerId:(t.managerId||"").trim()||null,managerName:(t.managerName||"").trim()||null}}async function Wi(t){const s=$t(Ue,"classrooms"),a=new Map,r=kt(s,jt("teacherId","==",t));(await Dt(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=kt(s,jt("managerId","==",t));return(await Dt(n)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})}),Array.from(a.values()).sort((l,c)=>String(l.name||"").localeCompare(String(c.name||"")))}async function dr(t){const s=t.classSectionId||Lt(t.grade,t.section),a=dt(Ue,"classSectionOwnership",s),r=await gs(a),o=r.exists()?r.data().studentUids||[]:[],n=Array.from(new Set([...t.studentUids||[],...o])),i=sr(t);return r.exists()?await Zt(a,{...i,classSectionId:s,studentUids:n,updatedAt:ot()}):await es(a,{...i,classSectionId:s,studentUids:n,createdAt:ot(),updatedAt:ot()}),s}async function qi(t){const s=(t.classSectionId||"").trim()||Lt(t.grade,t.section),a=(t.className||"").trim()||`${t.grade} - ${t.section}`,r=ym({classSectionId:s,className:a,grade:t.grade,section:t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName,adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName,classification:t.classification,strand:t.strand,gradeLevel:t.gradeLevel});await dr({classSectionId:s,className:a,grade:r.grade||t.grade,gradeLevel:r.gradeLevel||t.gradeLevel||t.grade,classification:r.classification||t.classification,strand:r.strand||t.strand,section:r.section||t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName,studentUids:[]});const o=$t(Ue,"classrooms"),n=kt(o,jt("classSectionId","==",s)),i=await Dt(n);if(i.empty){const l=sr({name:a,teacherId:t.ownerTeacherId,grade:r.grade,gradeLevel:r.gradeLevel,classification:r.classification,strand:r.strand,section:r.section,classSectionId:s,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName||"",adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName||"",managerId:t.managerId,managerName:t.managerName||"",classMetadata:r,schedule:"Mon-Fri",studentCount:0,avgScore:0,atRiskCount:0,createdAt:ot(),updatedAt:ot()});await es(dt(Ue,"classrooms",s),l,{merge:!0})}else for(const l of i.docs){const c=sr({name:a,grade:r.grade,gradeLevel:r.gradeLevel,classification:r.classification,strand:r.strand,section:r.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName||"",adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName||"",managerId:t.managerId,managerName:t.managerName||"",classMetadata:r,updatedAt:ot()});await Zt(l.ref,c)}return s}async function mr(t,s,a,r,o,n){const i=Lt(s,a);await dr({classSectionId:i,grade:s,section:a,schoolYear:o,ownerTeacherId:r,ownerTeacherName:n,studentUids:[t]});const l=await gs(dt(Ue,"users",t)),c=l.exists()?l.data():{};await es(dt(Ue,"users",t),{grade:s,section:a,classSectionId:i,adviserTeacherId:r,adviserTeacherName:n||"",updatedAt:ot()},{merge:!0}),await es(dt(Ue,"managedStudents",t),{accountUid:t,name:c.name||c.displayName||"Student",email:c.email||"",lrn:c.lrn||null,teacherId:r,grade:s,gradeLevel:s,section:a,classSectionId:i,classroomId:i,hasRegisteredAccount:!0,source:"registered",updatedAt:ot()},{merge:!0})}async function Sm(t){const s=$t(Ue,"classSectionOwnership"),a=new Map,r=kt(s,jt("ownerTeacherId","==",t));(await Dt(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=kt(s,jt("managerId","==",t));return(await Dt(n)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})}),Array.from(a.values()).sort((l,c)=>String(l.classSectionId||"").localeCompare(String(c.classSectionId||"")))}async function km(t="",s=25){const a=$t(Ue,"users"),r=Math.max(1,Math.min(100,s)),o=kt(a,jt("role","==","teacher"),Vr(r*4)),n=await Dt(o),i=t.trim().toLowerCase();return n.docs.map(c=>{const d=c.data(),m=String(d.name||"").trim(),f=String(d.email||"").trim();return{uid:c.id,name:m||"Teacher",email:f,photo:String(d.photo||d.photoURL||"").trim()||void 0}}).filter(c=>i?c.name.toLowerCase().includes(i)||c.email.toLowerCase().includes(i):!0).sort((c,d)=>c.name.localeCompare(d.name)).slice(0,r)}function Cm(t,s,a=20){if(t.length===0)return s([]),()=>{};const r=$t(Ue,"activities"),o=kt(r,jt("classroomId","in",t),Rl("timestamp","desc"));return ti(o,n=>{const i=n.docs.slice(0,a).map(l=>({id:l.id,...l.data()}));s(i)},n=>{console.error("[studentService] subscribeToActivities error:",n),s([])})}const Im=({open:t,onClose:s,onCreated:a,teacherName:r})=>{const{currentUser:o}=ds(),[n,i]=u.useState("details"),[l,c]=u.useState(""),d="Grade 11",[m,f]=u.useState(""),[h,b]=u.useState(!1),[y,j]=u.useState(""),[k,p]=u.useState([]),[N,I]=u.useState(new Set),[A,C]=u.useState(""),[U,v]=u.useState(!1);u.useEffect(()=>{t||(i("details"),c(""),f(""),j(""),I(new Set),C(""))},[t]),u.useEffect(()=>{t&&n==="students"&&S()},[t,n]);const S=async()=>{v(!0);try{const T=$t(Ue,"users"),G=kt(T,jt("role","==","student")),q=await Dt(G),se=[];q.docs.forEach(le=>{const ae=le.data();se.push({uid:le.id,name:ae.name||ae.displayName||"Student",email:ae.email||"",grade:ae.grade,section:ae.section})}),p(se.sort((le,ae)=>le.name.localeCompare(ae.name)))}catch(T){console.error("[CreateClassModal] Failed to load students:",T)}finally{v(!1)}},w=async()=>{if(o){if(!m.trim()){j("Section name is required");return}j(""),b(!0);try{const T=String(new Date().getFullYear());if(await qi({classSectionId:"",grade:d,section:m.trim(),schoolYear:T,ownerTeacherId:o.uid,ownerTeacherName:r||o.displayName||"",managerId:o.uid,managerName:r||o.displayName||"",className:l.trim()||`${d} - ${m.trim()}`}),N.size>0){const G=Array.from(N).map(q=>mr(q,d,m.trim(),o.uid,T,r||o.displayName||""));await Promise.allSettled(G)}a(),s()}catch(T){j(T instanceof Error?T.message:"Failed to create class")}finally{b(!1)}}},z=T=>{I(G=>{const q=new Set(G);return q.has(T)?q.delete(T):q.add(T),q})},O=k.filter(T=>T.name.toLowerCase().includes(A.toLowerCase())||T.email.toLowerCase().includes(A.toLowerCase()));return t?e.jsx(Et,{children:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white rounded-2xl shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#f1f5f9]",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#1e293b]",children:n==="details"?"Create New Class":"Add Students"}),e.jsx("button",{onClick:s,className:"p-1 rounded-lg hover:bg-[#f1f5f9] transition-colors",children:e.jsx(cs,{size:20,className:"text-[#64748b]"})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto flex-1",children:[n==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#475569] block mb-1.5",children:"Class Name"}),e.jsx(Ns,{placeholder:"e.g. Grade 11 - Section A",value:l,onChange:T=>c(T.target.value)}),e.jsx("p",{className:"text-xs text-[#94a3b8] mt-1",children:"Optional. Auto-generated from grade + section if empty."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#475569] block mb-1.5",children:"Section"}),e.jsx(Ns,{placeholder:"e.g. Section A, STEM-1, Rizal",value:m,onChange:T=>f(T.target.value)})]}),y&&e.jsx("p",{className:"text-sm text-rose-500",children:y})]}),n==="students"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Os,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#94a3b8]"}),e.jsx(Ns,{placeholder:"Search students...",value:A,onChange:T=>C(T.target.value),className:"pl-9"})]}),e.jsxs("p",{className:"text-xs text-[#64748b]",children:[N.size," student(s) selected"]}),U?e.jsx("p",{className:"text-sm text-[#64748b] text-center py-4",children:"Loading students..."}):O.length===0?e.jsx("p",{className:"text-sm text-[#64748b] text-center py-4",children:"No students found."}):e.jsx("div",{className:"space-y-1 max-h-[300px] overflow-y-auto",children:O.map(T=>e.jsxs("button",{onClick:()=>z(T.uid),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors ${N.has(T.uid)?"bg-purple-50 border border-purple-200":"hover:bg-[#f8fafc] border border-transparent"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-md border-2 flex items-center justify-center ${N.has(T.uid)?"bg-[#9956DE] border-[#9956DE]":"border-[#cbd5e1]"}`,children:N.has(T.uid)&&e.jsx(Mt,{size:12,className:"text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#1e293b] truncate",children:T.name}),e.jsx("p",{className:"text-xs text-[#64748b] truncate",children:T.email})]}),T.grade&&e.jsx("span",{className:"text-xs text-[#94a3b8]",children:T.grade})]},T.uid))}),y&&e.jsx("p",{className:"text-sm text-rose-500",children:y})]})]}),e.jsx("div",{className:"flex items-center justify-between p-6 border-t border-[#f1f5f9]",children:n==="details"?e.jsxs(e.Fragment,{children:[e.jsx(pt,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pt,{variant:"outline",onClick:()=>{if(!m.trim()){j("Section is required");return}j(""),i("students")},children:"Add Students"}),e.jsx(pt,{onClick:w,disabled:h||!m.trim(),className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:h?"Creating...":"Create Class"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{variant:"outline",onClick:()=>i("details"),children:"Back"}),e.jsxs(pt,{onClick:w,disabled:h,className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Js,{size:16,className:"mr-1"}),h?"Creating...":`Create with ${N.size} Student${N.size!==1?"s":""}`]})]})})]})]})}):null},Tm=({open:t,onClose:s,onAdded:a,grade:r,section:o,teacherName:n,existingStudentUids:i=[]})=>{const{currentUser:l}=ds(),[c,d]=u.useState([]),[m,f]=u.useState(new Set),[h,b]=u.useState(""),[y,j]=u.useState(!1),[k,p]=u.useState(!1);u.useEffect(()=>{t&&(f(new Set),b(""),N())},[t]);const N=async()=>{j(!0);try{const C=kt($t(Ue,"users"),jt("role","==","student")),v=(await Dt(C)).docs.filter(S=>!i.includes(S.id)).map(S=>{const w=S.data();return{uid:S.id,name:w.name||w.displayName||"Student",email:w.email||""}}).sort((S,w)=>S.name.localeCompare(w.name));d(v)}catch{}j(!1)},I=async()=>{if(!(!l||m.size===0)){p(!0);try{const C=String(new Date().getFullYear()),U=Array.from(m).map(v=>mr(v,r,o,l.uid,C,n||l.displayName||""));await Promise.allSettled(U),me.success(`Added ${m.size} student(s) to class`),a(),s()}catch{me.error("Failed to add students")}p(!1)}},A=c.filter(C=>C.name.toLowerCase().includes(h.toLowerCase())||C.email.toLowerCase().includes(h.toLowerCase()));return t?e.jsx(Et,{children:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white rounded-2xl shadow-xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-[#f1f5f9]",children:[e.jsxs("h2",{className:"text-base font-semibold text-[#1e293b]",children:["Add Students to ",r," - ",o]}),e.jsx("button",{onClick:s,className:"p-1 rounded-lg hover:bg-[#f1f5f9]",children:e.jsx(cs,{size:18,className:"text-[#64748b]"})})]}),e.jsxs("div",{className:"p-4 space-y-3 flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#94a3b8]"}),e.jsx(Ns,{placeholder:"Search students...",value:h,onChange:C=>b(C.target.value),className:"pl-8 h-9 text-sm"})]}),e.jsx("button",{onClick:()=>{m.size===A.length?f(new Set):f(new Set(A.map(C=>C.uid)))},className:"text-[11px] font-semibold text-[#9956DE] hover:text-[#7c3aed] bg-[#9956DE]/10 hover:bg-[#9956DE]/20 px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",children:m.size===A.length&&A.length>0?"Deselect All":"Select All"})]}),e.jsxs("p",{className:"text-xs text-[#64748b]",children:[m.size," of ",A.length," selected"]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-1 min-h-[300px]",children:y?e.jsx("p",{className:"text-sm text-center text-[#64748b] py-6",children:"Loading..."}):A.length===0?e.jsx("p",{className:"text-sm text-center text-[#64748b] py-6",children:"No students available"}):A.map(C=>e.jsxs("button",{onClick:()=>f(U=>{const v=new Set(U);return v.has(C.uid)?v.delete(C.uid):v.add(C.uid),v}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors ${m.has(C.uid)?"bg-purple-50 border border-purple-200":"hover:bg-[#f8fafc] border border-transparent"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-md border-2 flex items-center justify-center shrink-0 ${m.has(C.uid)?"bg-[#9956DE] border-[#9956DE]":"border-[#cbd5e1]"}`,children:m.has(C.uid)&&e.jsx(Mt,{size:12,className:"text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#1e293b] truncate",children:C.name}),e.jsx("p",{className:"text-[11px] text-[#64748b] truncate",children:C.email})]})]},C.uid))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-[#f1f5f9]",children:[e.jsx(pt,{variant:"outline",size:"sm",onClick:s,children:"Cancel"}),e.jsxs(pt,{size:"sm",onClick:I,disabled:k||m.size===0,className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Ko,{size:14,className:"mr-1.5"}),k?"Adding...":`Add ${m.size} Student${m.size!==1?"s":""}`]})]})]})]})}):null};async function Em(t,s,a){const r=dt($t(Ue,"generatedLessonPlans"));return await es(r,{...t,teacherId:s,teacherName:a?.teacherName||null,studentId:a?.studentId||null,studentName:a?.studentName||null,status:"draft",createdAt:ot(),updatedAt:ot()}),r.id}async function Rm(t){const s=dt(Ue,"generatedLessonPlans",t),a=await gs(s);if(!a.exists())throw new Error("Lesson draft not found. Save draft before publishing.");if(!a.data().publishReady)throw new Error("Lesson is not publish-ready. Resolve source legitimacy and validation issues first.");await Zt(s,{status:"published",publishedAt:ot(),updatedAt:ot()})}async function _m(t,s=!0){const a=t.learningCompetency||t.lessonTitle||t.focusTopics&&t.focusTopics[0]||"general mathematics",r=t.subject||"general_math",o=t.quarter??1;let n="",i=[],l,c,d,m=!1;if(s)try{const b=await bl(a,r,o,{lessonTitle:t.lessonTitle,learningCompetency:t.learningCompetency,moduleUnit:t.moduleUnit,learnerLevel:t.learnerLevel});i=b.sources||[],n=b.explanation||"",l=b.retrievalConfidence,c=b.retrievalBand,d=b.retrievalQuery,m=b.needsReview??!1}catch{n="",i=[]}const f={...t,subject:r,quarter:o,curriculumContext:n?`[CURRICULUM CONTEXT] +${n}`:void 0,curriculumRetrievalConfidence:l,curriculumRetrievalBand:c,curriculumRetrievalQuery:d,needsReview:m};return{...await nt.generateLessonPlan(f),curriculumSources:i,curriculumContext:n}}const Mm=Il("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Am({className:t,variant:s,asChild:a=!1,...r}){const o=a?Ql:"span";return e.jsx(o,{"data-slot":"badge",className:Xo(Mm({variant:s}),t),...r})}function zm(t){return t.length<=42?t:`${t.slice(0,18)}...${t.slice(-20)}`}const No=({sources:t=[],className:s})=>t.length?e.jsxs(Gl,{children:[e.jsx(Ul,{asChild:!0,children:e.jsxs(Am,{className:["bg-[#75D06A]/15 text-[#2E7D32] border-[#75D06A]/40 font-body font-semibold text-[11px] px-2.5 py-1 rounded-full cursor-help",s||""].join(" "),variant:"outline",children:[e.jsx(Qt,{size:12}),"DepEd Aligned"]})}),e.jsxs(Vl,{side:"top",sideOffset:6,className:"max-w-sm bg-white border border-[#dde3eb] text-[#0a1628] shadow-lg p-3",children:[e.jsx("p",{className:"text-[11px] font-display font-bold uppercase tracking-wide text-[#5a6578] mb-2",children:"Curriculum Sources"}),e.jsx("div",{className:"space-y-2",children:t.slice(0,5).map((a,r)=>e.jsxs("div",{className:"text-xs leading-relaxed",children:[e.jsxs("p",{className:"font-semibold text-[#0a1628]",children:[a.subject," | Q",a.quarter]}),e.jsxs("p",{className:"text-[#5a6578]",children:[zm(a.sourceFile)," | p.",a.page]}),e.jsxs("p",{className:"text-[#5a6578]",children:["Similarity: ",(a.score*100).toFixed(1),"%"]})]},`${a.sourceFile}-${a.page}-${r}`))})]})]}):null,Lm=[{level:"Remember",icon:Mr,bgColor:"bg-sky-500/20",borderColor:"border-sky-500/40",textColor:"text-sky-400",description:"Recall facts, formulas, definitions, and basic procedures.",mathExample:"State the quadratic formula.",mapsTo:"Identification, Enumeration",defaultWeight:"Included by default"},{level:"Understand",icon:Qt,bgColor:"bg-sky-500/20",borderColor:"border-sky-500/40",textColor:"text-sky-400",description:"Explain concepts, interpret graphs, classify mathematical objects.",mathExample:"Explain why the discriminant determines the number of roots.",mapsTo:"Multiple Choice, Identification",defaultWeight:"Included by default"},{level:"Apply",icon:vl,bgColor:"bg-green-500/20",borderColor:"border-green-500/40",textColor:"text-green-400",description:"Use formulas and procedures to solve routine problems.",mathExample:"Solve: 2x² + 5x - 3 = 0 using the quadratic formula.",mapsTo:"Equation-Based, Word Problem",defaultWeight:"Included by default"},{level:"Analyze",icon:pc,bgColor:"bg-orange-500/20",borderColor:"border-orange-500/40",textColor:"text-orange-400",description:"Break down problems, compare solution methods, identify patterns.",mathExample:"Given f(x) = x³ - 3x, find and classify all critical points.",mapsTo:"Word Problem, Equation-Based",defaultWeight:"Included by default"}],Dm=({isOpen:t,onClose:s})=>t?e.jsx(Et,{children:t&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[70] flex items-center justify-center p-4",onClick:s,children:e.jsxs(Re.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white border border-slate-200 rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 px-6 py-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",children:e.jsx(Jo,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"Bloom's Taxonomy in MathPulse AI"}),e.jsx("p",{className:"text-cyan-200 text-xs",children:"Understanding cognitive levels in assessments"})]})]}),e.jsx("button",{onClick:s,className:"w-8 h-8 bg-white/20 hover:bg-white/30 rounded-lg flex items-center justify-center transition-colors",children:e.jsx(cs,{size:16,className:"text-white"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-2",children:"What is Bloom's Taxonomy?"}),e.jsx("p",{className:"text-sm text-slate-500 leading-relaxed",children:"Bloom's Taxonomy is an educational framework developed by Benjamin Bloom in 1956 and revised in 2001. It classifies learning objectives into six cognitive levels, from basic recall of facts up to complex evaluation and creation. MathPulse AI uses the first four levels most relevant to Senior High School mathematics."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-2",children:"Why MathPulse AI Uses It"}),e.jsx("p",{className:"text-sm text-slate-500 leading-relaxed",children:"Using Bloom's Taxonomy ensures that assessments do not only test memorization. A well-balanced math quiz should challenge students at multiple cognitive levels: remembering formulas, understanding concepts, applying procedures, and analyzing relationships. This mirrors the DepEd K-12 competency framework which requires higher-order thinking skills (HOTS) alongside foundational knowledge."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-3",children:"Level-by-Level Breakdown"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Lm.map(a=>{const r=a.icon;return e.jsxs("div",{className:`${a.bgColor} border ${a.borderColor} rounded-xl p-4 space-y-2`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{size:18,className:a.textColor}),e.jsx("span",{className:`font-bold text-sm ${a.textColor}`,children:a.level})]}),e.jsx("p",{className:"text-xs text-slate-500",children:a.description}),e.jsxs("div",{className:"bg-black/20 rounded-lg p-2",children:[e.jsx("p",{className:"text-[10px] font-semibold text-slate-500 uppercase tracking-wide mb-0.5",children:"Math Example"}),e.jsx("p",{className:"text-xs text-[#dde3eb] italic",children:a.mathExample})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsxs("span",{className:"text-slate-500",children:["Maps to: ",e.jsx("span",{className:"text-slate-500 font-medium",children:a.mapsTo})]}),e.jsx("span",{className:"text-green-400 font-medium",children:a.defaultWeight})]})]},a.level)})})]}),e.jsx("div",{className:"bg-slate-50 border border-slate-200 rounded-xl p-4",children:e.jsxs("p",{className:"text-xs text-slate-500 leading-relaxed",children:[e.jsx("span",{className:"font-semibold text-slate-600",children:"Note:"})," ","All four levels are selected by default to produce a balanced, HOTS-aligned assessment. Deselecting a level will remove questions of that cognitive depth from the generated quiz."]})})]}),e.jsxs("div",{className:"border-t border-slate-200 px-6 py-3 flex items-center justify-between flex-shrink-0 bg-slate-50",children:[e.jsxs("a",{href:"https://cft.vanderbilt.edu/guides-sub-pages/blooms-taxonomy/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-rose-400 hover:text-rose-300 font-medium transition-colors",children:[e.jsx(vc,{size:12}),"Learn More"]}),e.jsx("button",{onClick:s,className:"px-5 py-2 bg-sky-600 hover:bg-rose-500 text-white text-sm font-bold rounded-xl transition-colors",children:"Got it"})]})]})})}):null,$m={draft:"bg-[#edf1f7] text-[#5a6578]",published:"bg-green-100 text-green-700",assigned:"bg-sky-100 text-sky-700",completed:"bg-rose-100 text-rose-700"},Fa={identification:{label:"Identification",icon:e.jsx(bs,{size:16}),description:"Define or identify concepts"},enumeration:{label:"Enumeration",icon:e.jsx(Ka,{size:16}),description:"List steps or properties"},multiple_choice:{label:"Multiple Choice",icon:e.jsx(Mt,{size:16}),description:"Choose from 4 options"},word_problem:{label:"Word Problem",icon:e.jsx(Qt,{size:16}),description:"Real-world scenarios"},equation_based:{label:"Equation-Based",icon:e.jsx(wl,{size:16}),description:"Solve equations"}},jo={remember:{label:"Remember",color:"bg-sky-100 text-sky-700 border-sky-300",description:"Recall facts & formulas"},understand:{label:"Understand",color:"bg-emerald-100 text-emerald-700 border-emerald-300",description:"Explain concepts"},apply:{label:"Apply",color:"bg-rose-100 text-rose-700 border-rose-300",description:"Use in new contexts"},analyze:{label:"Analyze",color:"bg-rose-100 text-rose-700 border-rose-300",description:"Examine & compare"}},Fm=["Grade 11","Grade 12"],Sr=t=>{const s=(t||"").trim().toLowerCase();return s==="grade 12"||s==="12"||s.includes("12")?"Grade 12":"Grade 11"},Om={"Grade 11":{"General Mathematics - Patterns, Relations, and Functions":["Patterns and Real-Life Relationships","Functions as Mathematical Models","Function Notation and Evaluation","Domain and Range of Functions","Operations on Functions","Composite Functions","Inverse Functions","Graphs of Rational Functions","Graphs of Exponential Functions","Graphs of Logarithmic Functions"],"General Mathematics - Financial Mathematics":["Simple and Compound Interest","Simple and General Annuities","Present and Future Value","Loans, Amortization, and Sinking Funds","Stocks, Bonds, and Market Indices","Business Decision-Making with Mathematical Models"],"General Mathematics - Logic and Mathematical Reasoning":["Propositions and Logical Connectives","Truth Values and Truth Tables","Logical Equivalence and Implication","Quantifiers and Negation","Validity of Arguments"]},"Grade 12":{"Pre-Calculus - Analytic Geometry":["Conic Sections - Parabola","Conic Sections - Ellipse","Conic Sections - Hyperbola","Conic Sections - Circle","Systems of Nonlinear Equations"],"Pre-Calculus - Series and Induction":["Sequences and Series","Arithmetic Sequences","Geometric Sequences","Mathematical Induction","Binomial Theorem"],"Pre-Calculus - Trigonometry":["Angles and Unit Circle","Trigonometric Functions","Trigonometric Identities","Sum and Difference Formulas","Inverse Trigonometric Functions","Polar Coordinates"],"Basic Calculus - Limits":["Limits of Functions","Limit Theorems","One-Sided Limits","Infinite Limits and Limits at Infinity","Continuity of Functions"],"Basic Calculus - Derivatives":["Definition of the Derivative","Differentiation Rules","Chain Rule","Implicit Differentiation","Higher-Order Derivatives","Related Rates","Extrema and the First Derivative Test","Concavity and the Second Derivative Test","Optimization Problems"],"Basic Calculus - Integration":["Antiderivatives and Indefinite Integrals","Definite Integrals and the FTC","Integration by Substitution","Area Under a Curve"]}},Bm={"Grade 11":["General Mathematics - "],"Grade 12":["Pre-Calculus - ","Basic Calculus - "]},yo=(t,s)=>{const a=Bm[s];return Object.fromEntries(Object.entries(t).filter(([r])=>a.some(o=>r.startsWith(o))))},xa=30,pa=12,kr="mathpulse:quiz-maker:active-task",Pm={easy:"text-green-600",medium:"text-rose-600",hard:"text-red-600"},Yi=({onBack:t,gradeLevel:s,selectedClassId:a,selectedClassName:r,onOpenNotifications:o,onOpenProfile:n,onOpenInsightModal:i,userPhoto:l,teacherName:c,drawerMode:d=!1,onQuizSaved:m,onQuizGenerating:f})=>{const{currentUser:h,loading:b}=ds(),y=u.useMemo(()=>nt.getImportGroundedRolloutFlags(),[]),[j,k]=u.useState("create"),[p,N]=u.useState("setup"),[I,A]=u.useState(Sr(s)),[C,U]=u.useState(10),[v,S]=u.useState([]),[w,z]=u.useState([]),[O,T]=u.useState(["multiple_choice","word_problem","identification"]),[G,q]=u.useState(["remember","understand","apply","analyze"]),[se,le]=u.useState(!1),[ae,fe]=u.useState({easy:30,medium:50,hard:20}),[pe,P]=u.useState({}),[Y,M]=u.useState(!1),[K,re]=u.useState([]),[$e,Me]=u.useState(!1),[Qe,H]=u.useState(""),[ee,g]=u.useState(!1),[E,R]=u.useState(!1),[X,J]=u.useState(null),[ne,ce]=u.useState(0),[$,oe]=u.useState("queued"),[xe,we]=u.useState("Waiting to start generation..."),[te,he]=u.useState(null),[et,Fe]=u.useState(null),[Ke,rt]=u.useState(""),[Rt,St]=u.useState(!1),Ft=u.useRef(!1),[as,B]=u.useState("topics"),[Ae,Ye]=u.useState(null),[vt,xs]=u.useState(!1),[Ot,Wt]=u.useState("all"),[qt,Rs]=u.useState("all"),[st,Aa]=u.useState(!1),[_t,_]=u.useState(null),[Z,ze]=u.useState(!1),[Ne,Ge]=u.useState(!1),[je,ft]=u.useState(!1),[it,Ce]=u.useState([]),[ps,Yt]=u.useState(!1),[_s,za]=u.useState(""),[Kt,ra]=u.useState(null),[na,hs]=u.useState([]),[oa,ia]=u.useState(!1),[Hs,ur]=u.useState("all"),[xr,la]=u.useState(null),[ca,L]=u.useState(null),V=u.useCallback(async()=>{M(!0);const x=Sr(I);try{const D=await nt.getQuizTopics(x);D.topics&&P(yo(D.topics,x))}catch{P(yo(Om[x],x))}finally{M(!1)}},[I]),ke=u.useCallback(async()=>{if(!y.quizEnabled){re([]),H("Import-grounded quiz generation is disabled by rollout flag; using curriculum defaults."),Me(!1);return}Me(!0),H("");try{const x=await nt.getCourseMaterialTopics({classSectionId:a,limit:20}),D=(x.topics||[]).filter(F=>F.title?.trim());re(D),x.warnings&&x.warnings.length>0&&H(x.warnings.join(" "))}catch{re([]),H("Imported topics are currently unavailable; quiz generation will use curriculum defaults.")}finally{Me(!1)}},[a,y.quizEnabled]);u.useEffect(()=>{V(),S([]),z([])},[V]),u.useEffect(()=>{ke()},[ke]);const _e=u.useMemo(()=>{const x=Array.from(new Set(K.map(D=>D.title.trim()).filter(Boolean)));return x.length===0?pe:{"Imported Course Materials":x,...pe}},[pe,K]);u.useEffect(()=>{Wt("all"),Rs("all")},[te]);const Bt=u.useMemo(()=>{if(!te)return[];const x=te.questions.map(F=>F.provenance?.sourceFile?.trim()).filter(F=>!!F),D=(te.metadata.topicProvenance||[]).map(F=>F.sourceFile?.trim()).filter(F=>!!F);return Array.from(new Set([...x,...D])).sort((F,ge)=>F.localeCompare(ge))},[te]),Ee=u.useMemo(()=>{if(!te)return[];const x=te.questions.map(F=>F.provenance?.materialId?.trim()).filter(F=>!!F),D=(te.metadata.topicProvenance||[]).map(F=>F.materialId?.trim()).filter(F=>!!F);return Array.from(new Set([...x,...D])).sort((F,ge)=>F.localeCompare(ge))},[te]),Qs=u.useMemo(()=>te?te.questions.filter(x=>{const D=Ot==="all"||(x.provenance?.sourceFile||"").trim()===Ot,F=qt==="all"||(x.provenance?.materialId||"").trim()===qt;return D&&F}):[],[te,Ot,qt]),It=(x,D)=>{const F={...ae},ge=Math.max(0,Math.min(100,F[x]+D)),Oe=ge-F[x];F[x]=ge;const We=Object.keys(F).filter(lt=>lt!==x),Pt=We.reduce((lt,Xt)=>lt+F[Xt],0);if(Pt>0)for(const lt of We)F[lt]=Math.max(0,Math.round(F[lt]-Oe*F[lt]/Pt));const Gs=Object.values(F).reduce((lt,Xt)=>lt+Xt,0);if(Gs!==100){const lt=We.reduce((Xt,Nn)=>F[Xt]>=F[Nn]?Xt:Nn);F[lt]+=100-Gs}fe(F)},Pe=x=>{S(D=>D.includes(x)?D.filter(F=>F!==x):[...D,x]),z(D=>D.filter(F=>F!==x))},da=x=>{T(D=>D.includes(x)?D.length>1?D.filter(F=>F!==x):D:[...D,x])},ma=x=>{q(D=>D.includes(x)?D.length>1?D.filter(F=>F!==x):D:[...D,x])},ol=()=>{let x=v.length>0?v.filter(F=>!w.includes(F)):Object.values(_e).flat().filter(F=>!w.includes(F)).slice(0,3);x.length>pa&&(x=x.slice(0,pa));const D=Math.min(C,xa);return{topics:x,gradeLevel:I,numQuestions:D,questionTypes:O,includeGraphs:se,difficultyDistribution:ae,bloomLevels:G,excludeTopics:w,classSectionId:a,className:r,preferImportedTopics:y.quizEnabled}},il=u.useCallback((x,D)=>{const F={taskId:x,request:D,createdAt:new Date().toISOString(),ownerUid:h?.uid};try{sessionStorage.setItem(kr,JSON.stringify(F))}catch{}},[h]),fs=u.useCallback(()=>{try{sessionStorage.removeItem(kr)}catch{}},[]),pr=u.useCallback(x=>{const D=Math.max(0,Math.min(100,Math.round(typeof x.progressPercent=="number"?x.progressPercent:x.status==="queued"?10:x.status==="running"?65:x.status==="completed"?100:x.status==="cancelling"?95:100)));ce(F=>{let ge=Math.max(F,D);if(x.status==="running"&&D<=F){const Oe=String(x.progressStage||"").toLowerCase(),We=Oe.includes("assembling")||Oe.includes("final")?97:Oe.includes("generating")?89:95;ge=Math.min(We,F+1)}return ge}),oe(x.progressStage||x.status),we(x.progressMessage||(x.status==="queued"?"Task queued for generation.":x.status==="running"?"Generating quiz in the background...":x.status==="completed"?"Generation complete.":x.status==="cancelling"?"Cancelling generation...":"Generation finished with an error."))},[]);u.useEffect(()=>{if(b||Ft.current)return;if(Ft.current=!0,!h){fs();return}let x=!1;const D=sessionStorage.getItem(kr);if(!D)return;let F=null;try{F=JSON.parse(D)}catch{fs();return}if(!F?.taskId){fs();return}if(F.ownerUid&&F.ownerUid!==h.uid){fs();return}return g(!0),J(F.taskId),rt(""),nt.waitForTaskResult(F.taskId,{timeoutMs:24e4,pollIntervalMs:1500,onProgress:pr}).then(async ge=>{if(x)return;const Oe=ge.result;if(!Oe||typeof Oe!="object")throw new Error("Quiz generation completed without a valid result payload.");const We=Oe;he(We),N("results"),ce(100),oe("completed"),we("Generation complete."),J(null),fs();try{await fn(We,F.request),me.success("Quiz auto-saved to your library as draft.")}catch(Pt){me.error(Pt instanceof Error?Pt.message:"Quiz generated but failed to save to library")}}).catch(ge=>{if(!x){if(ge instanceof qa&&(ge.status===401||ge.status===403)){Ft.current=!1,g(!1);return}rt(ge instanceof Error?ge.message:"Failed to resume quiz generation"),J(null),fs()}}).finally(()=>{x||g(!1)}),()=>{x=!0}},[pr,b,fs,h]);const xn=()=>{if(ee){window.confirm("Quiz generation is in progress. Are you sure you want to leave?")&&(N("setup"),he(null),rt(""),t());return}N("setup"),he(null),rt(""),t()},ll=async()=>{f?.(),rt(""),g(!0),L(null),ce(8),oe("queued"),we("Submitting quiz generation task..."),he(null);const x=ol();try{const D=await nt.generateQuiz(x,{onTaskCreated:F=>{J(F),il(F,x),ce(ge=>Math.max(ge,12)),oe("queued"),we("Task queued. Generation is running in the background.")},onProgress:F=>{pr(F),F.taskId&&F.taskId!==X&&J(F.taskId)}});he(D),N("results"),ce(100),oe("completed"),we("Generation complete."),J(null),fs();try{await fn(D,x),me.success("Quiz auto-saved to your library as draft.")}catch(F){me.error(F instanceof Error?F.message:"Quiz generated but failed to save to library")}nt.reportImportGroundedFeedback({flow:"quiz",status:"success",classSectionId:x.classSectionId,className:x.className,metadata:{totalQuestions:D.metadata.totalQuestions,usedImportedTopics:!!D.metadata.usedImportedTopics,importedTopicCount:D.metadata.importedTopicCount??0,importGroundingEnabled:y.quizEnabled}})}catch(D){rt(D instanceof Error?D.message:"Quiz generation failed"),ce(100),oe("failed"),we("Generation failed."),J(null),fs(),nt.reportImportGroundedFeedback({flow:"quiz",status:"failed",classSectionId:x.classSectionId,className:x.className,metadata:{error:D instanceof Error?D.message:"Quiz generation failed",importGroundingEnabled:y.quizEnabled}})}finally{g(!1)}},cl=()=>{if(!te)return;const x=te.questions.map((D,F)=>{let ge=`${F+1}. [${D.difficulty.toUpperCase()}] [${D.bloomLevel}] (${D.points} pts) +`;return ge+=` ${D.question} +`,D.options&&(ge+=D.options.map(Oe=>` ${Oe}`).join(` +`)+` +`),ge+=` Answer: ${D.correctAnswer} +`,ge+=` Explanation: ${D.explanation} +`,ge}).join(` +`);navigator.clipboard.writeText(x),St(!0),setTimeout(()=>St(!1),2e3)},dl=()=>{if(!te)return;const x=new Blob([JSON.stringify(te,null,2)],{type:"application/json"}),D=URL.createObjectURL(x),F=document.createElement("a");F.href=D,F.download=`quiz_${I.replace(/\s/g,"_")}_${Date.now()}.json`,F.click(),URL.revokeObjectURL(D)};v.length>0||Object.values(_e).flat().length>0;const pn=(x,D)=>{const F=D?.gradeLevel||I,ge=D?.topics||v,Oe=x.questions.map((We,Pt)=>({id:`q_${Date.now()}_${Pt}`,questionType:We.questionType||"identification",question:We.question,...We.options?{options:We.options}:{},correctAnswer:We.correctAnswer,bloomLevel:We.bloomLevel||"understand",difficulty:We.difficulty||"medium",topic:We.topic,subject:F,points:We.points,explanation:We.explanation}));return{title:`${F} Quiz – ${ge.length>0?ge.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:F,questions:Oe,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"}},hn=u.useCallback(x=>{hs(D=>[x,...D.filter(F=>F.id!==x.id)])},[]);async function fn(x,D){if(!h)return null;const F=pn(x,D),ge=await In(F,h.uid,_t?{documentId:_t}:void 0);return _(ge),hn({id:ge,...F,teacherId:h.uid}),ge}const ml=async()=>{if(!te){me.error("No quiz to save. Generate a quiz first.");return}if(!h){me.error("You must be signed in to save quizzes.");return}Aa(!0);try{const x=pn(te),D=await In(x,h.uid,_t?{documentId:_t}:void 0);_(D),hn({id:D,...x,teacherId:h.uid}),me.success("Quiz saved to your library!"),m?.(D)}catch(x){me.error(x instanceof Error?x.message:"Failed to save quiz")}finally{Aa(!1)}},ul=async()=>{if(_t){ze(!0);try{await Ol(_t),hs(x=>x.map(D=>D.id===_t?{...D,status:"published"}:D)),me.success("Quiz published to Quiz Bank!")}catch(x){me.error(x instanceof Error?x.message:"Failed to publish quiz")}finally{ze(!1)}}},hr=async x=>{const D=x??_t;if(!D){me.error("Save the quiz first before assigning.");return}if(la(D),Ge(!0),ra(null),za(""),it.length===0&&h){Yt(!0);try{const F=await cn(h.uid);Ce(F)}catch{me.error("Failed to load students")}finally{Yt(!1)}}},xl=async()=>{const x=xr??_t;if(!(!Kt||!x||!h)){ft(!0);try{await Bl(x,Kt,h.uid),hs(D=>D.map(F=>F.id===x?{...F,status:"assigned",metadata:{...F.metadata,assignedTo:Kt}}:F)),me.success("Quiz assigned to student!"),Ge(!1),la(null),j==="bank"&&fr()}catch(D){me.error(D instanceof Error?D.message:"Failed to assign quiz")}finally{ft(!1)}}},fr=u.useCallback(async()=>{if(h){ia(!0);try{const x=await ai(h.uid);hs(x)}catch{me.error("Failed to load quiz bank")}finally{ia(!1)}}},[h]);u.useEffect(()=>{j==="bank"&&fr()},[j,fr]);const pl=async x=>{try{await Fl(x),hs(D=>D.filter(F=>F.id!==x)),me.success("Quiz deleted")}catch{me.error("Failed to delete quiz")}},gn=it.filter(x=>x.name.toLowerCase().includes(_s.toLowerCase())||x.email.toLowerCase().includes(_s.toLowerCase())),bn=Hs==="all"?na:na.filter(x=>x.status===Hs),hl=x=>{const D=(x.metadata.topicsCovered||[]).reduce((F,ge)=>(F[ge]=(F[ge]||0)+1,F),{});return{questions:x.questions.map(F=>({questionType:F.questionType,question:F.question,correctAnswer:F.correctAnswer,options:F.options??null,bloomLevel:F.bloomLevel,difficulty:F.difficulty,topic:F.topic,points:F.points,explanation:F.explanation})),totalPoints:x.totalPoints,metadata:{topicsCovered:D,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||[]}}},gr=x=>{_(x.id),he(hl(x)),Fe(null),L(x.id),Wt("all"),Rs("all"),Ye(null),N("results"),k("create")},vn={remember:{badge:"border-purple-200 text-purple-700 bg-purple-50",card:"from-[#a855f7] to-[#9333ea]",num:"text-purple-700 bg-purple-100 border-purple-200"},understand:{badge:"border-blue-200 text-blue-700 bg-blue-50",card:"from-[#3b82f6] to-[#2563eb]",num:"text-blue-700 bg-blue-100 border-blue-200"},apply:{badge:"border-amber-200 text-amber-700 bg-amber-50",card:"from-[#f59e0b] to-[#d97706]",num:"text-amber-700 bg-amber-100 border-amber-200"},analyze:{badge:"border-orange-200 text-orange-700 bg-orange-50",card:"from-[#f97316] to-[#ea580c]",num:"text-orange-700 bg-orange-100 border-orange-200"},evaluate:{badge:"border-rose-200 text-rose-700 bg-rose-50",card:"from-[#f43f5e] to-[#e11d48]",num:"text-rose-700 bg-rose-100 border-rose-200"},create:{badge:"border-emerald-200 text-emerald-700 bg-emerald-50",card:"from-[#10b981] to-[#059669]",num:"text-emerald-700 bg-emerald-100 border-emerald-200"}},fl=(x,D,F)=>{const ge=Ae===D,Oe=vn[x.bloomLevel?.toLowerCase()]||vn.remember,We=x.bloomLevel?.toLowerCase()==="remember"?"hover:border-purple-200":x.bloomLevel?.toLowerCase()==="understand"?"hover:border-blue-200":x.bloomLevel?.toLowerCase()==="apply"?"hover:border-amber-200":"hover:border-slate-200";return e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:D*.05},className:`border border-[#e2e8f0] rounded-[20px] overflow-hidden bg-white shadow-sm hover:shadow-md ${We} transition-all duration-300`,children:[e.jsxs("div",{className:"p-6 flex justify-between items-start cursor-pointer hover:bg-slate-50/50 transition-colors",onClick:()=>Ye(ge?null:D),children:[e.jsxs("div",{className:"space-y-3 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap mb-1",children:[e.jsxs("span",{className:`w-8 h-8 rounded-lg bg-gradient-to-br ${Oe.card} text-white flex items-center justify-center font-bold text-[13px] shadow-sm`,children:["Q",D+1]}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${Oe.badge}`,children:x.bloomLevel}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${x.difficulty==="easy"?"border-emerald-200 text-emerald-700 bg-emerald-50":x.difficulty==="hard"?"border-rose-200 text-rose-700 bg-rose-50":"border-amber-200 text-amber-700 bg-amber-50"}`,children:x.difficulty}),e.jsxs("span",{className:"text-[12px] font-bold text-[#64748b] bg-slate-100 px-2 py-1 rounded-md",children:[x.points," pts"]}),x.topic&&e.jsx("span",{className:"text-[12px] font-semibold text-[#64748b] px-2 py-1 hidden sm:inline-block border-l border-slate-200",children:x.topic})]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b] pr-4 leading-relaxed",children:x.question})]}),e.jsxs("div",{className:"flex flex-col items-end justify-between h-full gap-4 shrink-0 mt-1",children:[e.jsx("span",{className:`px-3 py-1.5 rounded-md text-[10px] font-bold uppercase tracking-widest hidden sm:block border shadow-sm ${Oe.badge}`,children:x.bloomLevel}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-50 flex items-center justify-center border border-slate-200 mt-2",children:ge?e.jsx(wa,{size:16,className:"text-[#64748b] transition-transform duration-300"}):e.jsx(Tt,{size:16,className:"text-[#64748b]"})})]})]}),e.jsx(Et,{children:ge&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsxs("div",{className:"p-6 pt-0 bg-white",children:[e.jsx("div",{className:"h-px w-full bg-gradient-to-r from-transparent via-[#e2e8f0] to-transparent mb-6"}),x.options&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[13px] font-bold text-[#64748b] mb-3 uppercase tracking-wider",children:"Options:"}),e.jsx("div",{className:"space-y-3",children:x.options.map((Pt,Gs)=>{const lt=Pt.includes(x.correctAnswer);return e.jsxs("div",{className:`rounded-[12px] p-4 text-[14px] font-medium transition-all cursor-pointer relative overflow-hidden ${lt?"bg-gradient-to-r from-emerald-50 to-emerald-100/30 border-2 border-emerald-400 text-emerald-800 font-bold shadow-sm":"bg-white border border-[#e2e8f0] text-[#475569] hover:border-[#a855f7] hover:shadow-[0_2px_8px_rgba(168,85,247,0.1)]"}`,children:[lt&&e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-500"}),e.jsx("span",{className:lt?"pl-2":"",children:Pt}),lt&&e.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500 text-white flex items-center justify-center shadow-sm absolute right-4 top-1/2 -translate-y-1/2",children:e.jsx(Mt,{size:13})})]},Gs)})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-5",children:[e.jsxs("div",{className:"bg-emerald-50/80 border border-emerald-200/60 rounded-[16px] p-5 shadow-sm",children:[e.jsxs("p",{className:"text-[11px] font-bold text-emerald-700 uppercase tracking-wider mb-2 flex items-center gap-1.5",children:[e.jsx(Wr,{size:14})," Correct Answer"]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b]",children:x.correctAnswer})]}),e.jsxs("div",{className:"bg-purple-50/80 border border-purple-200/60 rounded-[16px] p-5 shadow-sm",children:[e.jsxs("p",{className:"text-[11px] font-bold text-purple-700 uppercase tracking-wider mb-2 flex items-center gap-1.5",children:[e.jsx($s,{size:14})," AI Explanation"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed font-medium",children:x.explanation})]})]}),e.jsxs("div",{className:"flex gap-6 text-[12px] font-medium text-[#64748b] mt-5 pt-4 border-t border-slate-100",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(bs,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Type:"})," ",Fa[x.questionType]?.label||x.questionType]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Mr,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Bloom:"})," ",x.bloomLevel]})]})]})})})]},D)},wn=e.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto bg-gradient-to-br from-[#eef2ff] via-[#f5f3ff] to-[#fff7ed]",children:[e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-[12px] pb-4",children:e.jsxs("div",{className:"flex items-center gap-1 bg-white/50 backdrop-blur-md p-1.5 rounded-full border border-white shadow-[0_2px_8px_rgba(0,0,0,0.04)] w-max",children:[e.jsxs("button",{onClick:()=>k("create"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${j==="create"?"bg-white text-[#a855f7] shadow-[0_2px_8px_rgba(168,85,247,0.15)] scale-100":"bg-transparent text-[#64748b] hover:text-[#1e293b] hover:bg-white/60 scale-95 hover:scale-100"}`,children:[e.jsx(Dr,{size:16})," Create Quiz"]}),e.jsxs("button",{onClick:()=>k("bank"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${j==="bank"?"bg-white text-[#a855f7] shadow-[0_2px_8px_rgba(168,85,247,0.15)] scale-100":"bg-transparent text-[#64748b] hover:text-[#1e293b] hover:bg-white/60 scale-95 hover:scale-100"}`,children:[e.jsx(Za,{size:16})," Quiz Bank"]})]})}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] flex-1",children:[j==="bank"&&e.jsxs("div",{className:"w-full space-y-[24px]",children:[e.jsx("div",{className:"flex items-center gap-3 overflow-x-auto pb-2 border-b border-[#e2e8f0] mb-6",style:{scrollbarWidth:"none"},children:["all","draft","published","assigned","completed"].map(x=>e.jsx("button",{onClick:()=>ur(x),className:`px-5 py-2 text-[13px] font-bold rounded-full whitespace-nowrap transition-all duration-300 mb-4 capitalize ${Hs===x?"bg-purple-50 text-[#9333ea] border border-purple-200 shadow-[0_2px_8px_rgba(168,85,247,0.15)] hover:scale-105":"bg-white/80 text-[#64748b] border border-white hover:border-[#e2e8f0] hover:bg-white shadow-sm hover:shadow-md hover:-translate-y-0.5"}`,children:x==="all"?"All":x.charAt(0).toUpperCase()+x.slice(1)},x))}),oa?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(mt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):bn.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(Za,{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:bn.map(x=>e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>gr(x),role:"button",tabIndex:0,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),gr(x))},className:`relative bg-white/80 backdrop-blur-md rounded-[20px] p-6 shadow-sm border flex flex-col group hover:-translate-y-1 transition-all duration-300 cursor-pointer overflow-hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#a855f7] ${x.status==="assigned"||x.status==="published"?"border-white hover:border-purple-100 hover:shadow-[0_8px_24px_rgba(168,85,247,0.1)]":"border-white hover:border-slate-200 hover:shadow-[0_8px_24px_rgba(0,0,0,0.06)]"}`,children:[e.jsx("div",{className:`absolute top-0 left-0 w-[6px] h-full transition-colors duration-300 ${x.status==="assigned"||x.status==="published"?"bg-purple-300 group-hover:bg-[#a855f7]":"bg-slate-200 group-hover:bg-slate-400"}`}),e.jsxs("div",{className:"flex justify-between items-start mb-4 gap-4 pl-3",children:[e.jsx("h3",{className:`font-bold text-[15px] text-[#1e293b] leading-tight transition-colors ${x.status==="assigned"||x.status==="published"?"group-hover:text-[#9333ea]":"group-hover:text-slate-700"}`,children:x.title}),e.jsx("span",{className:`px-2.5 py-1 rounded-[6px] text-[10px] font-bold uppercase tracking-wider shrink-0 shadow-sm ${$m[x.status]}`,children:x.status})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-5 pl-3",children:x.metadata.topicsCovered.slice(0,3).map(D=>e.jsx("span",{className:"px-2.5 py-1 bg-[#f8fafc] text-slate-600 text-[11px] font-medium rounded-md border border-slate-200 group-hover:border-slate-300 transition-colors",children:D},D))}),e.jsxs("div",{className:"flex items-center gap-5 text-[13px] text-[#64748b] font-medium mb-6 pl-3",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Wl,{size:14})," ",x.questions.length," questions"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Zo,{size:14})," ",x.totalPoints," pts"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(is,{size:14})," ",x.gradeLevel]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-5 border-t border-[#f1f5f9] pl-3",children:[e.jsxs("button",{onClick:D=>{D.stopPropagation(),gr(x)},className:"flex items-center gap-1.5 text-[13px] font-semibold text-[#64748b] hover:text-[#1e293b] transition-colors bg-slate-50 hover:bg-slate-100 border border-slate-200 px-4 py-2 rounded-full shadow-sm",children:[e.jsx(ql,{size:14})," View"]}),e.jsxs("button",{onClick:D=>{D.stopPropagation(),hr(x.id)},className:"flex items-center gap-1.5 text-[13px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors",children:[e.jsx(La,{size:14})," Assign"]}),e.jsxs("button",{onClick:D=>{D.stopPropagation(),pl(x.id)},className:"flex items-center gap-1.5 text-[13px] font-semibold text-rose-500 hover:text-rose-700 transition-colors ml-auto opacity-60 group-hover:opacity-100",children:[e.jsx(ri,{size:14})," Delete"]})]})]},x.id))})]}),j==="create"&&e.jsxs(e.Fragment,{children:[Ke&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-4",children:e.jsxs(Re.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-red-50 border border-red-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(or,{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:Ke})]}),e.jsx("button",{onClick:()=>rt(""),className:"ml-auto",children:e.jsx(cs,{size:14,className:"text-red-400"})})]})}),ee&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-[24px] xl:p-[32px]",children:[e.jsxs("div",{className:"bg-white p-8 rounded-[16px] shadow-sm border border-[#e2e8f0] w-full max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-[16px] font-bold text-[#1e293b] flex items-center gap-3",children:[e.jsx(mt,{size:20,className:"animate-spin text-[#a855f7]"}),"Generating Quiz in Background"]}),e.jsxs("span",{className:"text-[14px] font-extrabold text-[#9333ea]",children:[ne,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 h-2.5 rounded-full overflow-hidden mb-6",children:e.jsx(Re.div,{animate:{width:`${ne}%`},transition:{duration:.35,ease:"easeOut"},className:"bg-gradient-to-r from-sky-400 via-indigo-500 to-purple-500 h-full rounded-full"})}),e.jsxs("div",{className:"text-[13px] text-[#64748b]",children:[e.jsxs("p",{className:"font-medium text-[#475569] mb-1",children:["Stage: ",e.jsx("span",{className:"font-bold text-[#1e293b] capitalize",children:$.replace(/_/g," ")})]}),e.jsx("p",{children:xe}),X&&e.jsxs("p",{className:"text-[11px] mt-3 opacity-60 font-mono",children:["Task ID: ",X]})]})]}),e.jsxs("p",{className:"mt-8 text-[14px] font-medium text-[#64748b] flex items-center gap-2 animate-pulse",children:[e.jsx(mt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})]}),!ee&&p!=="results"&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] mb-8",children:e.jsx("div",{className:"flex items-center justify-between bg-white/80 backdrop-blur-[12px] rounded-2xl border border-white shadow-[0_4px_16px_rgba(0,0,0,0.03)] p-1.5",children:[{id:"setup",label:"Setup"},{id:"topics",label:"Topics"},{id:"style",label:"Question Style"},{id:"preview",label:"Preview"}].map((x,D)=>{const ge=["setup","topics","style","preview"].indexOf(p),Oe=ge>D,We=ge===D;return e.jsxs("div",{className:`flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl transition-all duration-500 ${We?"bg-purple-50/80 shadow-[0_1px_3px_rgba(168,85,247,0.1)]":Oe?"bg-transparent":"bg-transparent opacity-60"}`,children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[12px] font-bold shrink-0 ${We?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":Oe?"bg-emerald-500 text-white shadow-sm":"bg-slate-100 text-[#64748b]"}`,children:Oe?e.jsx(Mt,{size:13,strokeWidth:3}):D+1}),e.jsx("span",{className:`text-[13px] font-bold whitespace-nowrap ${We?"text-[#9333ea]":Oe?"text-[#1e293b]":"text-[#64748b]"}`,children:x.label})]},x.id)})})}),p==="setup"&&!ee&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-gradient-to-r from-purple-50/80 to-indigo-50/80 backdrop-blur-sm border border-purple-100/50 rounded-[16px] p-5 flex items-start gap-4 shadow-sm hover:shadow-md transition-shadow duration-300",children:[e.jsx("div",{className:"bg-white p-2 rounded-full shadow-sm shrink-0",children:e.jsx(ga,{size:18,className:"text-[#9333ea]"})}),e.jsxs("p",{className:"text-[13px] text-[#475569] leading-relaxed pt-0.5",children:["This quiz maker generates ",e.jsx("span",{className:"font-bold text-[#9333ea]",children:"supplemental assessments"})," to support classroom instruction. Questions follow Bloom's Taxonomy for comprehensive skill evaluation. Generation limit: up to ",xa," questions and ",pa," topics per quiz."]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-white shadow-[0_4px_16px_rgba(0,0,0,0.03)] overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.06)] transition-all duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Basic Settings"})}),e.jsxs("div",{className:"p-8 flex flex-col md:flex-row gap-8",children:[e.jsxs("div",{className:"flex-1 group",children:[e.jsx("label",{htmlFor:"quiz-grade-level",className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Grade level"}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{id:"quiz-grade-level",value:I,onChange:x=>A(Sr(x.target.value)),className:"appearance-none w-full bg-white border border-[#e2e8f0] hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl px-4 py-3.5 outline-none focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 cursor-pointer transition-all duration-200 shadow-sm",children:Fm.map(x=>e.jsx("option",{value:x,children:x},x))}),e.jsx(Tt,{size:18,className:"text-[#64748b] absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"flex-1 group",children:[e.jsx("label",{htmlFor:"quiz-num-questions",className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Number of questions"}),e.jsxs("div",{className:"flex items-center bg-white border border-[#e2e8f0] rounded-xl overflow-hidden focus-within:border-[#a855f7] focus-within:ring-4 focus-within:ring-[#a855f7]/10 transition-all duration-200 h-[50px] shadow-sm hover:border-[#cbd5e1]",children:[e.jsx("button",{onClick:()=>U(Math.max(1,C-1)),className:"w-14 h-full flex items-center justify-center text-[#64748b] bg-slate-50 hover:bg-slate-100 hover:text-[#1e293b] transition-colors border-r border-[#e2e8f0] active:bg-slate-200",children:e.jsx(Tn,{size:16})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:xa,value:C,onChange:x=>U(Math.min(xa,Math.max(1,parseInt(x.target.value)||1))),className:"flex-1 text-center font-bold text-[16px] text-[#1e293b] border-none outline-none focus:ring-0 w-full h-full p-0"}),e.jsx("button",{onClick:()=>U(Math.min(xa,C+1)),className:"w-14 h-full flex items-center justify-center text-[#64748b] bg-slate-50 hover:bg-slate-100 hover:text-[#1e293b] transition-colors border-l border-[#e2e8f0] active:bg-slate-200",children:e.jsx(Js,{size:16})})]})]})]})]})]}),p==="topics"&&!ee&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"flex items-end justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b] mb-1",children:"Select topics"}),e.jsxs("p",{className:"text-[13px] text-[#64748b]",children:["Choose up to ",pa," topics across all strands"]})]}),e.jsxs("div",{className:"bg-purple-50 border border-purple-100 px-3 py-1.5 rounded-full flex items-center gap-2 shadow-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#a855f7] animate-pulse"}),e.jsxs("span",{className:"text-[12px] font-bold text-[#a855f7]",children:[v.filter(x=>!w.includes(x)).length," of ",pa," selected"]})]})]}),Y?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(mt,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries(_e).map(([x,D])=>{const F=D.filter(Oe=>v.includes(Oe)&&!w.includes(Oe)).length,ge=as===x;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>B(ge?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:[D.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:[F," selected"]}),ge?e.jsx(wa,{size:18,className:"text-slate-400"}):e.jsx(Tt,{size:18,className:"text-slate-400"})]})]}),e.jsx(Et,{children:ge&&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:D.map((Oe,We)=>{const Pt=v.includes(Oe),Gs=w.includes(Oe),lt=Pt&&!Gs;let Xt="Core";return We%3===0&&(Xt="Foundation"),We%3===2&&(Xt="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 ${lt?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:lt&&e.jsx(Mt,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:lt,onChange:()=>Pe(Oe)}),e.jsx("span",{className:`text-sm font-semibold ${lt?"text-[#0a1628]":"text-[#5a6578]"}`,children:Oe})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${Xt==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:Xt})]},Oe)})})})})]},x)})})]}),p==="style"&&!ee&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Question Types"})}),e.jsx("div",{className:"p-4 grid grid-cols-2 sm:grid-cols-5 gap-3",children:Object.entries(Fa).map(([x,D])=>{const F=O.includes(x);return e.jsxs("button",{onClick:()=>da(x),className:`border-2 rounded-[16px] p-4 flex flex-col items-center justify-center text-center cursor-pointer transition-all duration-300 relative overflow-hidden group hover:-translate-y-1 ${F?"border-[#a855f7] bg-gradient-to-b from-purple-50/80 to-white/80 shadow-[0_4px_12px_rgba(168,85,247,0.12)]":"border-slate-100 bg-slate-50/50 shadow-sm hover:shadow-md hover:border-purple-200"}`,children:[F&&e.jsx("div",{className:"absolute top-2 right-2 w-5 h-5 bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-full flex items-center justify-center shadow-md",children:e.jsx(Mt,{size:11,className:"text-white"})}),e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center mb-3 group-hover:scale-110 transition-transform duration-300 ${F?"bg-white border border-purple-200 shadow-md":"bg-white border border-slate-200 shadow-sm group-hover:shadow-md"}`,children:e.jsx("span",{className:F?"text-[#a855f7]":"text-slate-500",children:D.icon})}),e.jsx("span",{className:`font-bold text-[12px] leading-tight ${F?"text-[#9333ea]":"text-slate-700"}`,children:D.label})]},x)})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Bloom's Taxonomy Levels"})}),e.jsx("div",{className:"p-6 flex flex-wrap gap-4",children:Object.entries(jo).map(([x,D])=>{const F=G.includes(x);return e.jsx("button",{onClick:()=>ma(x),className:`px-6 py-2.5 rounded-full border-2 font-bold text-[13px] transition-all duration-200 hover:-translate-y-0.5 capitalize ${F?"border-[#a855f7] text-[#9333ea] bg-purple-50/80 shadow-[0_2px_8px_rgba(168,85,247,0.15)]":"border-slate-200 text-[#64748b] bg-white shadow-sm hover:border-slate-300 hover:bg-slate-50"}`,children:x},x)})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Difficulty Distribution"})}),e.jsx("div",{className:"p-8 space-y-8",children:Object.entries(ae).map(([x,D])=>{const F={easy:"bg-emerald-400",medium:"bg-amber-400",hard:"bg-rose-400"},ge={easy:"text-emerald-600",medium:"text-amber-500",hard:"text-rose-500"},Oe={easy:"group-hover:border-emerald-200",medium:"group-hover:border-amber-200",hard:"group-hover:border-rose-200"};return e.jsxs("div",{className:"flex items-center gap-6 group",children:[e.jsx("span",{className:`w-16 text-[13px] font-bold text-[#475569] capitalize group-hover:${ge[x]} transition-colors`,children:x}),e.jsx("div",{className:"flex-1 bg-slate-100 h-3 rounded-full overflow-hidden shadow-inner",children:e.jsx(Re.div,{animate:{width:`${D}%`},className:`h-full rounded-full transition-all duration-500 ease-out ${F[x]}`})}),e.jsxs("div",{className:`flex items-center bg-white border border-[#e2e8f0] rounded-xl shadow-sm overflow-hidden p-0.5 w-28 h-10 transition-colors ${Oe[x]}`,children:[e.jsx("button",{onClick:()=>It(x,-5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${ge[x]} rounded-lg transition-colors`,children:e.jsx(Tn,{className:"w-3.5 h-3.5"})}),e.jsx("input",{type:"text",value:`${D}%`,readOnly:!0,className:"flex-1 text-center font-bold text-[14px] text-[#1e293b] border-none outline-none focus:ring-0 w-full p-0 pointer-events-none"}),e.jsx("button",{onClick:()=>It(x,5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${ge[x]} rounded-lg transition-colors`,children:e.jsx(Js,{className:"w-3.5 h-3.5"})})]})]},x)})})]})]}),p==="preview"&&!ee&&!te&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:e.jsxs("div",{className:"bg-white/80 backdrop-blur-md rounded-[20px] border border-[#e2e8f0] shadow-[0_8px_24px_rgba(0,0,0,0.04)] overflow-hidden p-8",children:[e.jsxs("h3",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-6 flex items-center gap-2",children:[e.jsx(Ds,{size:16,className:"text-[#a855f7]"})," Quiz Summary"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-6",children:[{label:"Questions",value:C},{label:"Topics",value:v.filter(x=>!w.includes(x)).length},{label:"Level",value:I.replace("Grade ","Gr. ")}].map(x=>e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-purple-50 to-indigo-50 rounded-[16px] p-6 text-center border border-purple-100/50 shadow-sm flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-16 h-16 bg-purple-200/30 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx("span",{className:"text-[36px] font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-[#a855f7] to-[#9333ea] leading-none mb-1 relative z-10",children:x.value}),e.jsx("span",{className:"text-[13px] font-bold text-[#64748b] relative z-10",children:x.label})]},x.label))}),e.jsxs("div",{className:"bg-slate-50/80 rounded-[14px] p-5 border border-slate-200/60 text-[#475569] text-[14px] leading-relaxed flex gap-4 items-start shadow-inner",children:[e.jsx(ga,{size:18,className:"text-[#94a3b8] shrink-0 mt-0.5"}),e.jsxs("p",{children:[O.map(x=>Fa[x]?.label).join(" and ")," questions across"," ",e.jsxs("span",{className:"font-bold text-[#1e293b]",children:[v.filter(x=>!w.includes(x)).length," topics"]})," ","— aligned to ",e.jsx("span",{className:"font-semibold",children:G.map(x=>jo[x]?.label).join(", ")})," levels of Bloom's Taxonomy."," ",e.jsxs("span",{className:"font-semibold text-emerald-600",children:["Easy ",ae.easy,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-amber-500",children:["Medium ",ae.medium,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-rose-500",children:["Hard ",ae.hard,"%"]}),"."]})]})]})}),p==="results"&&te&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-md rounded-[20px] border border-[#e2e8f0] shadow-[0_8px_24px_rgba(0,0,0,0.04)] p-6",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:cl,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:[Rt?e.jsx(Mt,{size:14,className:"text-green-500"}):e.jsx(zr,{size:14}),Rt?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:dl,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(Kl,{size:14}),"Export JSON"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-[0_8px_16px_rgba(168,85,247,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(bs,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:te.questions.length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Questions"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f43f5e] to-[#e11d48] text-white shadow-[0_8px_16px_rgba(244,63,94,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(ws,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:te.totalPoints}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Total Points"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f59e0b] to-[#d97706] text-white shadow-[0_8px_16px_rgba(245,158,11,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(Qt,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:Object.keys(te.metadata.topicsCovered).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Topics"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] text-white shadow-[0_8px_16px_rgba(16,185,129,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(Ka,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:Object.keys(te.metadata.bloomTaxonomyDistribution).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Bloom Levels"})]})]}),(te.metadata.usedImportedTopics||(te.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: ",te.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",te.metadata.importedMaterialsCount??0," • ","Topics: ",te.metadata.importedTopicCount??0]}),(te.metadata.topicProvenance||[]).slice(0,5).map((x,D)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[x.title||"Untitled topic",x.sourceFile?` • ${x.sourceFile}`:""]},`${x.topicId||x.title||"topic"}_${D}`)),(Bt.length>0||Ee.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:Ot,onChange:x=>Wt(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"}),Bt.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:qt,onChange:x=>Rs(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"}),Ee.map(x=>e.jsx("option",{value:x,children:x},x))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",Qs.length," of ",te.questions.length," questions after provenance filters."]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mt-8 mb-10",children:[e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#10b981] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Ds,{size:14})," Difficulty"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(te.metadata.difficultyBreakdown).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:`font-bold capitalize ${Pm[x]||"text-[#475569]"}`,children:x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]}),e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#a855f7] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Mr,{size:14})," Bloom's Taxonomy"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(te.metadata.bloomTaxonomyDistribution).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:"text-[#1e293b] font-semibold capitalize",children:x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]}),e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#0ea5e9] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Ka,{size:14})," Question Types"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(te.metadata.questionTypeBreakdown).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:"text-[#1e293b] font-semibold",children:Fa[x]?.label||x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-purple-50 to-indigo-50/50 border border-purple-100 rounded-[16px] p-6 mb-10 flex items-start gap-4 shadow-sm relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full bg-[#a855f7]"}),e.jsx("div",{className:"bg-white p-2 rounded-full shadow-sm shrink-0",children:e.jsx(ga,{size:18,className:"text-[#9333ea]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#9333ea] mb-3",children:te.metadata.supplementalPurpose||"This quiz is designed to supplement classroom instruction, not replace teacher-led learning."}),te.metadata.recommendedTeacherActions&&te.metadata.recommendedTeacherActions.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[13px] font-bold text-[#1e293b] mb-2",children:"Recommended Actions:"}),e.jsx("ul",{className:"list-disc pl-5 text-[13px] font-medium text-[#475569] space-y-1.5",children:te.metadata.recommendedTeacherActions.map((x,D)=>e.jsx("li",{children:x},D))})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("h3",{className:"text-[18px] font-bold text-[#1e293b] flex items-center gap-2",children:[e.jsx(li,{size:20,className:"text-[#a855f7]"})," Review Questions"]}),e.jsx("div",{className:"space-y-4",children:Qs.length>0?Qs.map((x,D)=>fl(x,D)):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."})})]})]})]})]}),j==="create"&&e.jsx("div",{className:"sticky bottom-0 mt-auto w-full bg-white/90 backdrop-blur-[12px] border-t border-[#e2e8f0] z-30 shadow-[0_-4px_12px_rgba(0,0,0,0.03)]",children:e.jsxs("div",{className:"w-full px-6 xl:px-8 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[p==="topics"&&!ee&&e.jsx("button",{onClick:()=>{S([]),z([])},className:"text-[13px] font-semibold text-[#a855f7] hover:underline",children:"Clear all"}),(p==="style"||p==="preview")&&!ee&&e.jsxs("button",{onClick:()=>N(p==="preview"?"style":"topics"),className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Ss,{size:16})," Back"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[p==="setup"&&!ee&&e.jsxs("button",{onClick:()=>N("topics"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Topics ",e.jsx(ys,{size:16})]}),p==="topics"&&!ee&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>N("setup"),className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Ss,{size:16})," Back"]}),e.jsxs("button",{onClick:()=>N("style"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Question Style ",e.jsx(ys,{size:16})]})]}),p==="style"&&!ee&&e.jsxs("button",{onClick:()=>N("preview"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Preview ",e.jsx(ys,{size:16})]}),p==="preview"&&!ee&&!te&&e.jsxs("button",{onClick:ll,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-all hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Mt,{size:16})," Generate Quiz"]}),ee&&e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(mt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]}),p==="results"&&(ca?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{k("bank"),L(null)},className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02]",children:"Back to Quiz Bank"}),e.jsxs("button",{onClick:()=>hr(ca),className:"bg-white border border-[#a855f7] text-[#9333ea] hover:bg-purple-50 text-[14px] font-bold rounded-full px-8 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(La,{size:16})," Assign"]}),e.jsx("button",{onClick:xn,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-10 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02]",children:"Done"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{N("setup"),he(null),Fe(null),_(null),L(null)},className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02]",children:"Create Another"}),_t?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:ul,disabled:Z,className:"bg-white border border-[#a855f7] text-[#9333ea] hover:bg-purple-50 text-[14px] font-bold rounded-full px-8 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[Z?e.jsx(mt,{size:16,className:"animate-spin"}):e.jsx(Ta,{size:16})," Publish"]}),e.jsxs("button",{onClick:()=>hr(),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(La,{size:16})," Assign to Class"]})]}):e.jsxs("button",{onClick:ml,disabled:st,className:"bg-emerald-600 hover:bg-emerald-700 text-white px-8 py-2.5 rounded-full font-bold shadow-lg shadow-emerald-500/30 hover:-translate-y-1 transition-all flex items-center gap-2 text-[14px]",children:[st?e.jsx(mt,{size:16,className:"animate-spin"}):e.jsx(ni,{size:16})," Save to Library"]}),e.jsx("button",{onClick:xn,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-10 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02]",children:"Done"})]}))]})]})}),e.jsx(Dm,{isOpen:vt,onClose:()=>xs(!1)}),e.jsx(Et,{children:Ne&&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:()=>Ge(!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(is,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>Ge(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(cs,{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(Os,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:_s,onChange:x=>za(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:ps?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(mt,{size:20,className:"animate-spin text-sky-500"})}):gn.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):gn.map(x=>e.jsxs("button",{onClick:()=>ra(x.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${Kt===x.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:x.avatar&&!x.avatar.includes("ui-avatars.com")?x.avatar:Qa(x.gender),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})]}),Kt===x.id&&e.jsx(Mt,{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:()=>Ge(!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:xl,disabled:!Kt||je,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${Kt&&!je?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[je?e.jsx(mt,{size:14,className:"animate-spin"}):e.jsx(La,{size:14}),"Assign"]})]})]})})})]});return d?e.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-white",children:wn}):wn},Hm=({onOpenNotifications:t,onOpenProfile:s,onOpenInsightModal:a,userPhoto:r,teacherName:o})=>{const[n,i]=u.useState([]),[l,c]=u.useState(!1),[d,m]=u.useState(!1),[f,h]=u.useState(""),[b,y]=u.useState(11),[j,k]=u.useState("general_mathematics"),[p,N]=u.useState([]),[I,A]=u.useState(!1),[C,U]=u.useState(null),v=u.useCallback(async()=>{A(!0);try{const T=kt($t(Ue,"quizBattleQuestionBank"),Vr(50)),q=(await Dt(T)).docs.map(se=>{const le=se.data();return{id:se.id,question:le.question||"",choices:le.choices||[],correct_answer:le.correct_answer||"",explanation:le.explanation||"",topic:le.topic||"",difficulty:le.difficulty||"medium",grade_level:le.grade_level||11}});N(q)}catch(T){console.warn("[QuestionBankPanel] Failed to load questions:",T)}finally{A(!1)}},[]);u.useEffect(()=>{v()},[v]);const S=u.useCallback(async()=>{c(!0);try{const T=await yn("/api/quiz-battle/bank-status");i(T.pdfs)}catch(T){const G=T instanceof qa?T.message:"Failed to load bank status";me.error(G)}finally{c(!1)}},[]);u.useEffect(()=>{S()},[S]);const w=async()=>{if(!f.trim()){me.error("Please enter a storage path");return}m(!0);try{await yn("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:f.trim(),grade_level:b,topic:j.trim(),force_reingest:!1})}),me.success("PDF ingestion completed"),await S(),h("")}catch(T){const G=T instanceof qa?T.message:"Ingestion failed";me.error(G)}finally{m(!1)}},z=n.reduce((T,G)=>T+G.question_count,0),O=n.filter(T=>T.processed).length;return e.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto bg-gradient-to-br from-[#f8fafc] to-[#f1f5f9]",children:[e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-[12px] pb-2"}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] space-y-[32px]",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#3b82f6] to-[#2563eb] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(59,130,246,0.2)] hover:shadow-[0_8px_24px_rgba(59,130,246,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total PDFs"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(bs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:n.length})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] hover:shadow-[0_8px_24px_rgba(168,85,247,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Questions"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Qt,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:z})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] hover:shadow-[0_8px_24px_rgba(16,185,129,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Processed"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(zs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:O})]})]}),e.jsx("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden",children:e.jsxs("div",{className:"p-[24px] sm:p-[32px]",children:[e.jsxs("h2",{className:"text-[20px] font-bold text-[#1e293b] mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center shadow-md shadow-purple-500/20",children:e.jsx(Rn,{className:"w-4 h-4 text-white"})}),"Ingest New PDF"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 items-end",children:[e.jsxs("div",{className:"md:col-span-6 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Firebase Storage Path"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(bs,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"quiz_pdfs/grade_11/gen_math_q1.pdf",value:f,onChange:T=>h(T.target.value),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl pl-11 pr-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]})]}),e.jsxs("div",{className:"md:col-span-2 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Grade Level"}),e.jsx("input",{type:"number",placeholder:"11",min:7,max:12,value:b,onChange:T=>y(Number(T.target.value)),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl px-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]}),e.jsxs("div",{className:"md:col-span-4 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Topic Slug"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(Qt,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"general_mathematics",value:j,onChange:T=>k(T.target.value),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl pl-11 pr-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]})]})]}),e.jsx("div",{className:"mt-6 flex justify-end pt-6 border-t border-slate-100",children:e.jsxs("button",{onClick:w,disabled:d,className:"bg-gradient-to-r from-[#a855f7] to-[#9333ea] hover:from-[#9333ea] hover:to-[#7e22ce] text-white text-[14px] font-bold rounded-full px-8 py-3 shadow-[0_4px_16px_rgba(168,85,247,0.3)] transition-all hover:scale-[1.02] flex items-center gap-2 hover:shadow-[0_8px_24px_rgba(168,85,247,0.4)] disabled:opacity-50 disabled:hover:scale-100",children:[d?e.jsx(mt,{className:"w-4 h-4 animate-spin"}):e.jsx(Rn,{className:"w-4 h-4"}),"Ingest PDF"]})})]})}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] p-[24px] sm:p-[32px]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b]",children:"Processing Status"}),e.jsx("button",{onClick:S,disabled:l,className:"w-9 h-9 rounded-full bg-white border border-slate-200 flex items-center justify-center text-[#64748b] hover:text-[#9333ea] hover:border-purple-200 shadow-sm transition-all hover:scale-105 active:scale-95 disabled:opacity-50",children:e.jsx(zs,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsx("div",{className:"bg-white rounded-[16px] border border-[#f1f5f9] overflow-hidden shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#9956DE] border-b border-[#8b5cf6] shadow-md relative z-10",children:[e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Filename"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Grade"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Topic"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap text-center",children:"Questions"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Status"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Processed At"})]})}),e.jsxs("tbody",{className:"divide-y divide-[#f1f5f9] bg-white",children:[n.map(T=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors group",children:[e.jsx("td",{className:"py-4 px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${T.processed?"bg-indigo-50 text-indigo-500":"bg-amber-50 text-amber-500"}`,children:e.jsx(bs,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-[13px] font-bold text-[#1e293b] group-hover:text-purple-600 transition-colors line-clamp-1",children:T.filename})]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-semibold text-[#475569]",children:T.grade_level}),e.jsx("td",{className:"py-4 px-6",children:e.jsx("span",{className:"text-[12px] font-medium bg-slate-100 text-slate-600 px-2.5 py-1 rounded-md line-clamp-1",children:T.topic})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-bold text-[#1e293b] text-center",children:T.question_count||"-"}),e.jsx("td",{className:"py-4 px-6",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 text-[11px] font-bold rounded-full border shadow-sm ${T.processed?"bg-emerald-50 text-emerald-600 border-emerald-200/50":"bg-amber-50 text-amber-600 border-amber-200/50"}`,children:[T.processed?e.jsx(zs,{className:"w-3 h-3"}):e.jsx(mt,{className:"w-3 h-3 animate-spin"}),T.processed?"Completed":"Processing..."]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-medium text-[#64748b]",children:T.timestamp?new Date(T.timestamp).toLocaleDateString():"-"})]},T.filename)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-12 px-6 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-[#64748b]",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mb-4 border border-slate-100",children:e.jsx(bs,{className:"w-8 h-8 text-slate-300"})}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-1",children:"No PDFs processed yet"}),e.jsx("p",{className:"text-[13px]",children:"Upload a PDF using the form above to get started."})]})})})]})]})})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] p-[24px] sm:p-[32px]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("h2",{className:"text-[20px] font-bold text-[#1e293b] flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] bg-gradient-to-br from-[#3b82f6] to-[#2563eb] flex items-center justify-center shadow-md shadow-blue-500/20",children:e.jsx(Qt,{className:"w-4 h-4 text-white"})}),"Question Bank (",p.length,")"]}),e.jsx("button",{onClick:v,disabled:I,className:"w-9 h-9 rounded-full bg-white border border-slate-200 flex items-center justify-center text-[#64748b] hover:text-[#9333ea] hover:border-purple-200 shadow-sm transition-all hover:scale-105 active:scale-95 disabled:opacity-50",children:e.jsx(zs,{className:`w-4 h-4 ${I?"animate-spin":""}`})})]}),I?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(mt,{className:"w-6 h-6 animate-spin text-[#9956DE]"})}):p.length===0?e.jsxs("div",{className:"text-center py-12 text-[#64748b]",children:[e.jsx(Qt,{className:"w-10 h-10 mx-auto mb-3 text-slate-300"}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-1",children:"No questions in the bank yet"}),e.jsx("p",{className:"text-[13px]",children:"Ingest a PDF above to populate the question bank."})]}):e.jsx("div",{className:"space-y-2 max-h-[500px] overflow-y-auto",children:p.map(T=>e.jsxs("div",{className:"border border-[#f1f5f9] rounded-xl p-4 hover:border-purple-200 transition-colors bg-white",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 cursor-pointer",onClick:()=>U(C===T.id?null:T.id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-[#1e293b] line-clamp-2",children:T.question}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-md bg-blue-50 text-blue-600 font-semibold",children:["Grade ",T.grade_level]}),e.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-md bg-slate-100 text-slate-600 font-medium",children:T.topic}),e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-md font-semibold ${T.difficulty==="easy"?"bg-green-50 text-green-600":T.difficulty==="hard"?"bg-rose-50 text-rose-600":"bg-amber-50 text-amber-600"}`,children:T.difficulty})]})]}),C===T.id?e.jsx(wa,{size:16,className:"text-[#94a3b8] shrink-0"}):e.jsx(Tt,{size:16,className:"text-[#94a3b8] shrink-0"})]}),C===T.id&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#f1f5f9] space-y-2",children:[e.jsx("div",{className:"space-y-1",children:T.choices.map((G,q)=>e.jsxs("p",{className:`text-[12px] px-3 py-1.5 rounded-lg ${G===T.correct_answer?"bg-green-50 text-green-700 font-semibold border border-green-200":"bg-slate-50 text-[#475569]"}`,children:[String.fromCharCode(65+q),". ",G]},q))}),T.explanation&&e.jsxs("p",{className:"text-[12px] text-[#64748b] italic mt-2",children:["💡 ",T.explanation]})]})]},T.id))})]})]})]})},So={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},Qm={"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"}},ko={mastered:{label:"Mastered",color:"text-emerald-600 bg-emerald-50 border-emerald-100"},on_track:{label:"On Track",color:"text-amber-600 bg-amber-50 border-amber-100"},needs_attention:{label:"Needs Work",color:"text-rose-600 bg-rose-50 border-rose-100"},no_data:{label:"No Data",color:"text-slate-600 bg-slate-50 border-slate-200"}},Co={needs_attention:0,on_track:1,no_data:2,mastered:3},Gm=({classSectionId:t,onOpenNotifications:s,onOpenProfile:a})=>{const{currentUser:r,userProfile:o}=ds(),[n,i]=u.useState([]),[l,c]=u.useState(So),[d,m]=u.useState(!0),[f,h]=u.useState("all"),[b,y]=u.useState("all"),[j,k]=u.useState(""),[p,N]=u.useState("classAverage"),[I,A]=u.useState("asc"),C=_n.map(M=>M.id),U=_n.reduce((M,K)=>(M[K.id]=K.name,M),{}),{isLoading:v,refetch:S}=ec();u.useEffect(()=>{v||(console.log("[TopicMasteryView] Curriculum ready"),S())},[v,S]);const[w,z]=u.useState(new Set),[O,T]=u.useState([]),G=Xl({queryKey:Nl.topicMastery(r?.uid||"anonymous",t),enabled:!!r,staleTime:120*1e3,gcTime:900*1e3,queryFn:async()=>{try{if(!r)return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}};const M=dt(Ue,"teachers",r.uid,"settings","quizSettings"),K=await gs(M),re=K.exists()?K.data()?.excludedTopics||[]:[],$e="https://deign86-mathpulse-api-v3test.hf.space",Me=new URLSearchParams({teacherId:r.uid});t&&Me.set("classSectionId",t);const Qe=await r.getIdToken(),H=await fetch(`${$e}/api/analytics/topic-mastery?${Me.toString()}`,{headers:{Authorization:`Bearer ${Qe}`}});if(!H.ok)return{excluded:re,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:re.length}};const ee=await H.json(),g=(ee.topics||[]).map(E=>({...E,isExcluded:re.includes(E.topicName)}));return{excluded:re,topics:g,summary:ee.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:re.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});u.useEffect(()=>{if(m(G.isLoading||G.isFetching),!G.data){T([]),i([]),c(So),z(new Set);return}T(G.data.excluded),i(G.data.topics),c(G.data.summary)},[G.data,G.isFetching,G.isLoading]);const q=async M=>{if(!r)return;const K=O.includes(M)?O.filter(re=>re!==M):[...O,M];T(K),i(re=>re.map($e=>$e.topicName===M?{...$e,isExcluded:!$e.isExcluded}:$e)),c(re=>({...re,excludedCount:K.length}));try{const re=dt(Ue,"teachers",r.uid,"settings","quizSettings");(await gs(re)).exists()?await Zt(re,{excludedTopics:K}):await es(re,{excludedTopics:K})}catch{me.error("Failed to update excluded topics")}},se=async()=>{if(!r)return;const M=[...new Set([...O,...w])];T(M),i(K=>K.map(re=>w.has(re.topicName)?{...re,isExcluded:!0}:re)),c(K=>({...K,excludedCount:M.length})),z(new Set);try{const K=dt(Ue,"teachers",r.uid,"settings","quizSettings");(await gs(K)).exists()?await Zt(K,{excludedTopics:M}):await es(K,{excludedTopics:M}),me.success(`${w.size} topics excluded from quizzes`)}catch{me.error("Failed to update")}},le=async()=>{if(!r)return;const M=O.filter(K=>!w.has(K));T(M),i(K=>K.map(re=>w.has(re.topicName)?{...re,isExcluded:!1}:re)),c(K=>({...K,excludedCount:M.length})),z(new Set);try{const K=dt(Ue,"teachers",r.uid,"settings","quizSettings");(await gs(K)).exists()?await Zt(K,{excludedTopics:M}):await es(K,{excludedTopics:M}),me.success(`${w.size} topics re-included in quizzes`)}catch{me.error("Failed to update")}},ae=M=>{p===M?A(K=>K==="asc"?"desc":"asc"):(N(M),A("asc"))},fe=b==="all"?C:Jl(b);u.useEffect(()=>{f!=="all"&&(fe.includes(f)||h("all"))},[fe,f]);const pe=n.filter(M=>!(f!=="all"&&M.subjectId!==f||!fe.includes(M.subjectId)||j&&!M.topicName.toLowerCase().includes(j.toLowerCase()))).sort((M,K)=>{const re=I==="asc"?1:-1;switch(p){case"topicName":return re*M.topicName.localeCompare(K.topicName);case"classAverage":return re*(M.classAverage-K.classAverage);case"studentsAttempted":return re*(M.studentsAttempted-K.studentsAttempted);case"masteryStatus":return re*((Co[M.masteryStatus]||0)-(Co[K.masteryStatus]||0));default:return 0}}),P=()=>{w.size===pe.length?z(new Set):z(new Set(pe.map(M=>M.topicName)))},Y=({field:M})=>p!==M?e.jsx(Tt,{size:14,className:"text-white/40"}):I==="asc"?e.jsx(wa,{size:14,className:"text-white font-bold"}):e.jsx(Tt,{size:14,className:"text-white font-bold"});return d?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(mt,{size:24,className:"animate-spin text-indigo-500"}),e.jsx("span",{className:"ml-2 text-[#64748b]",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:"w-full p-[24px] xl:p-[32px] space-y-[24px]",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Topics Tracked"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ds,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.totalTopicsTracked})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Mastered by Class"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(qr,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.masteredCount})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f43f5e] to-[#e11d48] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(244,63,94,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Needs Work"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Xs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.needsAttentionCount})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#64748b] to-[#475569] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(100,116,139,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Excluded Topics"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Yl,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.excludedCount})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center bg-white px-4 py-2.5 rounded-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-[#e2e8f0] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all w-full md:w-64",children:[e.jsx(Os,{size:16,className:"text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:j,onChange:M=>k(M.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]}),e.jsxs("div",{className:"relative w-full md:w-48",children:[e.jsxs("select",{value:f,onChange:M=>h(M.target.value),className:"appearance-none w-full bg-white border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[12px] pl-4 pr-10 py-2.5 outline-none focus:border-[#a855f7] focus:ring-2 focus:ring-[#a855f7]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer",children:[e.jsx("option",{value:"all",children:"All Subjects"}),fe.map(M=>e.jsx("option",{value:M,children:U[M]||M},M))]}),e.jsx(Tt,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsxs("div",{className:"relative w-full md:w-48",children:[e.jsxs("select",{value:b,onChange:M=>y(M.target.value),className:"appearance-none w-full bg-white border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[12px] pl-4 pr-10 py-2.5 outline-none focus:border-[#a855f7] focus:ring-2 focus:ring-[#a855f7]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer",children:[e.jsx("option",{value:"all",children:"All Grades"}),Zl.map(M=>e.jsx("option",{value:M,children:M},M))]}),e.jsx(Tt,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsx(Et,{children:w.size>0&&e.jsxs(Re.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-4 bg-indigo-50 border border-indigo-200 rounded-[12px] p-3 flex items-center gap-3 flex-wrap overflow-hidden",children:[e.jsxs("span",{className:"text-[13px] font-semibold text-indigo-700",children:[w.size," topics selected"]}),e.jsx("button",{onClick:se,className:"px-4 py-1.5 bg-[#475569] text-white text-[11px] font-bold rounded-full hover:bg-[#334155] transition-colors shadow-sm",children:"Exclude Selected"}),e.jsx("button",{onClick:le,className:"px-4 py-1.5 bg-emerald-600 text-white text-[11px] font-bold rounded-full hover:bg-emerald-700 transition-colors shadow-sm",children:"Include Selected"}),e.jsx("button",{onClick:()=>z(new Set),className:"px-4 py-1.5 bg-white border border-[#e2e8f0] text-[#64748b] text-[11px] font-bold rounded-full hover:bg-[#f8fafc] transition-colors shadow-sm",children:"Clear Selection"})]})}),e.jsx("div",{className:"bg-white rounded-[16px] border border-[#f1f5f9] overflow-hidden shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"bg-[#9956DE] grid grid-cols-12 gap-4 p-4 border-b border-[#8b5cf6] items-center text-[11px] font-bold text-white tracking-wider uppercase shadow-md relative z-10 h-12",children:[e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx("input",{type:"checkbox",checked:w.size===pe.length&&pe.length>0,onChange:P,className:"rounded text-[#4f46e5] focus:ring-[#4f46e5] w-4 h-4 border-white/30 bg-white/10 cursor-pointer"})}),e.jsxs("div",{className:"col-span-3 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ae("topicName"),children:["TOPIC NAME ",e.jsx(Y,{field:"topicName"})]}),e.jsx("div",{className:"col-span-2",children:"UNIT"}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ae("classAverage"),children:["CLASS AVG % ",e.jsx(Y,{field:"classAverage"})]}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ae("studentsAttempted"),children:["STUDENTS ",e.jsx(Y,{field:"studentsAttempted"})]}),e.jsxs("div",{className:"col-span-1 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ae("masteryStatus"),children:["STATUS ",e.jsx(Y,{field:"masteryStatus"})]}),e.jsx("div",{className:"col-span-1 text-center",children:"EXCLUDE"})]}),e.jsx("div",{className:"flex flex-col",children:pe.length===0?e.jsx("div",{className:"p-16 text-center border-b border-[#f1f5f9]",children:n.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ds,{size:32,className:"text-[#cbd5e1]"}),e.jsx("p",{className:"text-[13px] font-semibold text-[#64748b]",children:"No topic data available yet"}),e.jsx("p",{className:"text-[11px] text-[#94a3b8]",children:"Import student quiz data to see class topic mastery analytics."})]}):e.jsx("span",{className:"text-[13px] text-[#64748b]",children:"No topics match the current filters."})}):pe.map(M=>{const K=w.has(M.topicName),re=ko[M.masteryStatus]||ko.no_data,$e=Qm[M.subjectId]||{label:M.subjectId.toUpperCase(),color:"bg-[#f8fafc] text-[#64748b]"},Me=M.classAverage<60?"bg-rose-500":M.classAverage<85?"bg-amber-500":"bg-emerald-500",Qe=M.isExcluded?"bg-slate-50/60 opacity-70":M.masteryStatus==="needs_attention"?"bg-rose-50/30":M.masteryStatus==="mastered"?"bg-emerald-50/20":"";return e.jsxs("div",{className:`grid grid-cols-12 gap-4 p-4 border-b border-[#f1f5f9] items-center hover:bg-slate-50/80 transition-colors group ${Qe} ${M.isExcluded?"line-through decoration-slate-400":""}`,children:[e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx("input",{type:"checkbox",checked:K,onChange:()=>{const H=new Set(w);K?H.delete(M.topicName):H.add(M.topicName),z(H)},className:"rounded text-[#4f46e5] focus:ring-[#4f46e5] w-4 h-4 border-gray-300 cursor-pointer"})}),e.jsxs("div",{className:"col-span-3 flex flex-col sm:flex-row sm:items-center gap-1.5 pr-2 min-w-0",children:[e.jsx("span",{className:"font-semibold text-[#1e293b] text-[13px] truncate",children:M.topicName}),e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded shrink-0 ${$e.color}`,children:$e.label})]}),e.jsx("div",{className:"col-span-2 text-[#475569] text-[13px] truncate pr-2",children:M.unit}),e.jsx("div",{className:"col-span-2",children:e.jsxs("span",{className:"font-bold text-[#1e293b] text-[14px]",children:[M.classAverage,"%"]})}),e.jsxs("div",{className:"col-span-2 pr-4",children:[e.jsx("div",{className:"flex justify-between items-center text-[11px] mb-1",children:e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[M.studentsAttempted," / ",M.totalStudents]})}),e.jsx("div",{className:"w-full bg-[#f1f5f9] h-1.5 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Me}`,style:{width:`${M.classAverage}%`}})})]}),e.jsx("div",{className:"col-span-1",children:e.jsx("span",{className:`text-[10px] font-bold px-2.5 py-1 rounded-full border whitespace-nowrap ${re.color}`,children:re.label})}),e.jsxs("div",{className:"col-span-1 flex justify-center relative",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer group/toggle",children:[e.jsx("input",{type:"checkbox",checked:M.isExcluded,onChange:()=>q(M.topicName),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]}),e.jsx("div",{className:"hidden group-hover/toggle:block absolute z-20 bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded whitespace-nowrap shadow-lg",children:M.isExcluded?"Include in generation":"Exclude from generation"})]})]},M.topicName)})})]})})})]})]})};function Ki(t){return(t||"").trim().toLowerCase()}function Io(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 o=Ki(t.classSectionId),n=(t.id||"").trim().toLowerCase();return o&&n?`${o}|id:${n}`:n?`id:${n}`:`${o}|anonymous`}function Um(t,s){const a=[],r=(t.lrn||"").trim().toLowerCase(),o=(t.email||"").trim().toLowerCase(),n=t.name.trim().toLowerCase(),i=(t.id||"").trim().toLowerCase();return r&&a.push(`${s}|lrn:${r}`),o&&a.push(`${s}|email:${o}`),n&&a.push(`${s}|name:${n}`),i&&a.push(`${s}|id:${i}`),a.length===0&&a.push(`${s}|anonymous`),a}function Vm(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 Xi(t,s){const a=new Map,r=new Map,o=s?Ki(s):"all";return t.forEach(n=>{const i=Um(n,o),l=i.map(m=>r.get(m)).find(Boolean)||i[0],c=a.get(l),d=c?Vm(c,n):n;a.set(l,d),i.forEach(m=>r.set(m,l))}),Array.from(a.values())}function To(t,s){return Xi([...t,...s])}function Vs(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function Wm(t){if(!t)return null;const s="gen-math",a=Mn.find(i=>i.id===s)?.modules||[];if(a.length===0)return null;const r={mastery:0,concept:0,application:0,engagement:0,consistency:0},o=t.lessons??{};a.forEach(i=>{const l=Mn.find(k=>k.modules.some(p=>p.id===i.id)),c=l?t?.subjects?.[l.id]?.modulesProgress?.[i.id]:null,d=Vs(c?.progress||0),m=i.lessons.length?i.lessons.reduce((k,p)=>{const N=o?.[p.id]?.score;if(typeof N=="number"&&Number.isFinite(N))return k+Vs(N);const I=!!c?.lessonsCompleted?.includes?.(p.id);return k+(I?100:0)},0)/i.lessons.length:0,f=i.quizzes.length?(c?.quizzesCompleted?.length||0)/i.quizzes.length*100:0,h=Vs(m),b=Vs(f),y=Vs(Math.min(100,(h+b*2)/1.5)),j=Vs(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=h,r.application+=b,r.engagement+=y,r.consistency+=j});const n=a.length;return{mastery:Math.round(r.mastery/n),concept:Math.round(r.concept/n),application:Math.round(r.application/n),engagement:Math.round(r.engagement/n),consistency:Math.round(r.consistency/n)}}const Eo={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"}},Cr=[{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:"Applications"},{key:"consistency",short:"S",label:"Consistency",header:"Consistency"}],qm=({classSectionId:t,className:s,fallbackStudents:a=[],onBack:r,onOpenNotifications:o,onOpenProfile:n,insightDismissed:i,onOpenInsightModal:l})=>{const{currentUser:c,userProfile:d}=ds(),m=u.useRef(0),[f,h]=u.useState([]),[b,y]=u.useState(!0),[j,k]=u.useState(""),[p,N]=u.useState("riskLevel"),[I,A]=u.useState("desc"),[C,U]=u.useState("all"),[v,S]=u.useState([]),[w,z]=u.useState(!1),[O,T]=u.useState(""),[G,q]=u.useState(""),se=u.useCallback(g=>({id:g.id,lrn:g.lrn||void 0,name:g.name,email:g.email||"",avatar:Qa(g.gender),classSectionId:g.classSectionId??null,riskLevel:g.riskLevel||"Low",engagementScore:g.engagementScore,avgQuizScore:g.avgQuizScore,weakestTopic:g.weakestTopic||"Foundational Skills"}),[]),le=u.useCallback(g=>({id:g.id,lrn:g.lrn,name:g.name,email:g.email||"",avatar:g.avatar&&!g.avatar.includes("ui-avatars.com")?g.avatar:Qa(g.gender),classSectionId:g.classSectionId??null,riskLevel:String(g.riskLevel).charAt(0).toUpperCase()+String(g.riskLevel).slice(1).toLowerCase(),engagementScore:g.engagementScore,avgQuizScore:Number(g.avgQuizScore??g.avgScore??0),weakestTopic:g.weakestTopic||"Foundational Skills"}),[]),ae=u.useCallback(async(g,E)=>{const R=new Map;g.forEach(J=>R.set(J.id,null));const X=25;for(let J=0;J{try{const oe=await Sn($.id);return{studentId:$.id,summary:Wm(oe)}}catch{return{studentId:$.id,summary:null}}}))).forEach(($,oe)=>{const xe=ne[oe]?.id;xe&&($.status==="fulfilled"?R.set(xe,$.value.summary):R.set(xe,null))})}m.current===E&&h(J=>J.map(ne=>R.has(ne.student.id)?{...ne,competencyMatrix:R.get(ne.student.id)??null,competencyMatrixLoading:!1}:ne))},[]),fe=u.useCallback(async()=>{if(c?.uid){y(!0),q("");try{let E=(await cn(c.uid)).map(ne=>({id:ne.id,name:ne.name,email:ne.email||"",avatar:ne.avatar&&!ne.avatar.includes("ui-avatars.com")?ne.avatar:Qa(ne.gender),classSectionId:ne.classSectionId??null,riskLevel:ne.riskLevel,engagementScore:ne.engagementScore,avgQuizScore:ne.avgQuizScore,weakestTopic:ne.weakestTopic||"Foundational Skills"}));a.length>0&&(E=To(E,a.map(le))),t&&(E=E.filter(ne=>ne.classSectionId===t));const R=await nt.getImportedClassOverview({classSectionId:t,limit:3e3});R.warnings.length>0&&q(R.warnings.join(" ")),E=To(E,R.students.map(se));const X=Xi(E,t),J=m.current+=1;h(X.map((ne,ce)=>({rowKey:`${Io(ne)}|row:${ce}`,student:ne,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),ae(X,J)}catch(g){if(console.error("Failed to load students:",g),a.length>0){const E=a.map(le).filter(R=>!t||R.classSectionId===t).map((R,X)=>({rowKey:`${Io(R)}|row:${X}`,student:R,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));h(E),q("Showing recently imported students while backend roster sync catches up.")}else h([]),q("Student competency roster is unavailable right now.")}finally{y(!1)}}},[t,c?.uid,a,ae,le,se]);u.useEffect(()=>{fe()},[fe]),u.useEffect(()=>{(async()=>{if(!t){S([]),T("");return}z(!0),T("");try{const E=await nt.getCourseMaterialTopics({classSectionId:t,limit:20}),R=(E.topics||[]).filter(X=>X.title?.trim());S(R),E.warnings.length>0&&T(E.warnings.join(" "))}catch{S([]),T("Imported topic context is unavailable right now.")}finally{z(!1)}})()},[t]);const pe=async g=>{h(E=>E.map(R=>{if(R.rowKey!==g)return R;const X=!R.expanded,J=R.student.id,ne={weakestTopic:R.student.weakestTopic,avgQuizScore:R.student.avgQuizScore};return X&&!R.competency&&!R.loading?(P(g,J,ne),{...R,expanded:!0,loading:!0}):{...R,expanded:X}}))},P=async(g,E,R)=>{try{const J=((await Sn(E))?.quizAttempts??[]).map(ce=>({topic:ce.quizId,score:ce.score,total:100,timeTaken:ce.timeSpent})),ne=await nt.getStudentCompetency(E,J.length>0?J:void 0);h(ce=>ce.map($=>$.rowKey===g?{...$,competency:ne,loading:!1}:$))}catch{const J=R.avgQuizScore||50,ne={studentId:E,competencies:[{topic:R.weakestTopic||"Unknown",efficiencyScore:Math.max(15,J-20),competencyLevel:J<50?"beginner":"developing",perspective:`Student needs focused practice in ${R.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,J+10),competencyLevel:J>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:J,competencyLevel:J>80?"advanced":J>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[R.weakestTopic||"Review fundamentals"],excludeTopics:[]};h(ce=>ce.map($=>$.rowKey===g?{...$,competency:ne,loading:!1}:$))}},Y=g=>{p===g?A(E=>E==="asc"?"desc":"asc"):(N(g),A("asc"))},M={High:0,Medium:1,Low:2},K=f.filter(g=>{if(C!=="all"&&g.student.riskLevel!==C)return!1;if(j){const E=j.toLowerCase();return g.student.name.toLowerCase().includes(E)||g.student.email.toLowerCase().includes(E)}return!0}).sort((g,E)=>{let R=0;switch(p){case"name":R=g.student.name.localeCompare(E.student.name);break;case"avgQuizScore":R=g.student.avgQuizScore-E.student.avgQuizScore;break;case"riskLevel":R=M[g.student.riskLevel]-M[E.student.riskLevel];break;case"engagementScore":R=g.student.engagementScore-E.student.engagementScore;break}return I==="asc"?R:-R}),re=f.length,$e=f.filter(g=>g.student.riskLevel==="High").length,Me=re>0?Math.round(f.reduce((g,E)=>g+E.student.avgQuizScore,0)/re):0,Qe=re>0?Math.round(f.reduce((g,E)=>g+E.student.engagementScore,0)/re):0,H=Array.from(new Set(v.map(g=>g.title).filter(Boolean))).slice(0,10),ee=({field:g})=>p!==g?e.jsx(Tt,{size:14,className:"text-white/40"}):I==="asc"?e.jsx(wa,{size:14,className:"text-white font-bold"}):e.jsx(Tt,{size:14,className:"text-white font-bold"});return b?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(mt,{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:[r&&e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("button",{onClick:r,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Ss,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-[16px] mb-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(168,85,247,0.2)] hover:shadow-[0_8px_24px_rgba(168,85,247,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Students"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(kn,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:re}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Evaluated in this class"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(249,115,22,0.2)] hover:shadow-[0_8px_24px_rgba(249,115,22,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"At-Risk Students"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Xs,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:$e}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Need immediate intervention"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(14,165,233,0.2)] hover:shadow-[0_8px_24px_rgba(14,165,233,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Class Average"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ds,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Me,"%"]}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. expected benchmark"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(16,185,129,0.2)] hover:shadow-[0_8px_24px_rgba(16,185,129,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Avg. Engagement"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ta,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Qe,"%"]}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Activity completion rate"})})]})]}),e.jsx("div",{className:"sticky top-0 z-30 py-4 -my-4 bg-[#f8fafc]/80 backdrop-blur-[16px] border-b border-slate-200/50 shadow-[0_4px_20px_rgba(0,0,0,0.02)] px-2 sm:-mx-6 sm:px-6 mb-6 rounded-b-[18px]",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 w-full md:w-auto items-center",children:[e.jsxs("div",{className:"flex items-center bg-white px-4 py-2.5 rounded-full shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#e2e8f0] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all w-full sm:w-64",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#9956DE] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search students...",value:j,onChange:g=>k(g.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]}),e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar w-full sm:w-auto p-2 -m-2",children:["all","High","Medium","Low"].map(g=>e.jsx("button",{onClick:()=>U(g),className:`px-4 py-1.5 text-[13px] font-semibold rounded-full whitespace-nowrap transition-colors shadow-md ${C===g?"bg-[#9956DE] text-white":"bg-white text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:g==="all"?"All":`${g} Risk`},g))})]}),e.jsxs("button",{onClick:fe,className:"flex items-center gap-2 text-[13px] font-semibold text-slate-500 hover:text-slate-700 transition-colors shrink-0 bg-white px-4 py-2 rounded-full shadow-md hover:bg-slate-50 self-end sm:self-auto",children:[e.jsx(zs,{className:"w-4 h-4"})," Refresh"]})]})}),e.jsxs("div",{className:"bg-[#f5f3ff]/60 border border-[#e0e7ff] rounded-[14px] px-5 py-3 mb-6 flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"mt-0.5 sm:mt-0 shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#9956DE]",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center flex-1",children:[e.jsxs("span",{className:"text-[#9956DE] font-semibold text-[13px] whitespace-nowrap mr-1",children:["Imported Topic Context",s?` for ${s}`:"",":"]}),w?e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:"Loading class-scoped imported topics..."}):H.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-1 sm:mt-0",children:H.map((g,E)=>e.jsxs(de.Fragment,{children:[e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:g}),EY("name"),children:["Student ",e.jsx(ee,{field:"name"})]}),e.jsxs("div",{className:"w-[120px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",onClick:()=>Y("riskLevel"),children:["Risk Level ",e.jsx(ee,{field:"riskLevel"})]}),e.jsxs("div",{className:"w-[200px] shrink-0 px-4 flex items-center gap-1 cursor-pointer hover:text-white/80 transition-colors",onClick:()=>Y("avgQuizScore"),children:["Avg. Score ",e.jsx(ee,{field:"avgQuizScore"})]}),e.jsxs("div",{className:"w-[180px] shrink-0 px-4 flex items-center gap-1 cursor-pointer hover:text-white/80 transition-colors",onClick:()=>Y("engagementScore"),children:["Engagement ",e.jsx(ee,{field:"engagementScore"})]}),e.jsx("div",{className:"w-[160px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",children:"Weakest Topic"}),Cr.map((g,E)=>e.jsx("div",{className:`w-[100px] shrink-0 px-2 flex justify-center ${E===Cr.length-1?"border-r border-transparent":""}`,children:g.header},g.key))]}),K.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(kn,{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:K.map(g=>(g.student.riskLevel==="High"||g.student.riskLevel,e.jsxs("div",{className:"flex flex-col border-b border-slate-100 group",children:[e.jsxs("div",{className:"flex items-center min-h-[64px] hover:bg-slate-50/60 transition-colors cursor-pointer relative",onClick:()=>void pe(g.rowKey),children:[e.jsxs("div",{className:"w-[260px] shrink-0 sticky left-0 z-10 bg-white group-hover:bg-slate-50/90 transition-colors px-5 h-full min-h-[64px] flex items-center border-r border-slate-100 shadow-[2px_0_4px_rgba(0,0,0,0.01)]",children:[e.jsx("div",{className:`transition-transform duration-200 mr-3 shrink-0 ${g.expanded?"rotate-90":""}`,children:e.jsx(ys,{className:"w-4 h-4 text-slate-400"})}),e.jsx("img",{src:g.student.avatar,alt:g.student.name,className:"w-8 h-8 rounded-full bg-border object-cover shrink-0 mr-3"}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:g.student.name})]}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:`px-3 py-1 rounded-full border text-[11px] font-bold uppercase tracking-wider ${g.student.riskLevel==="High"?"bg-rose-50 text-rose-600 border-rose-200":g.student.riskLevel==="Medium"?"bg-amber-50 text-amber-600 border-amber-200":"bg-emerald-50 text-emerald-600 border-emerald-200"}`,children:g.student.riskLevel})}),e.jsxs("div",{className:"w-[200px] shrink-0 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-slate-100 h-2.5 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${g.student.avgQuizScore>=80?"bg-emerald-500":g.student.avgQuizScore>=60?"bg-amber-400":"bg-rose-500"}`,style:{width:`${g.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[g.student.avgQuizScore,"%"]})]}),e.jsxs("div",{className:"w-[180px] shrink-0 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-slate-100 h-2.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#9956DE]",style:{width:`${g.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[g.student.engagementScore,"%"]})]}),e.jsx("div",{className:"w-[160px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-600 text-[11px] font-medium rounded-full truncate max-w-full border border-slate-200",children:g.student.weakestTopic})}),Cr.map(E=>{const R=g.competencyMatrix?.[E.key]??0;return e.jsx("div",{className:"w-[100px] shrink-0 px-2 flex justify-center",children:g.competencyMatrixLoading?e.jsx(mt,{size:12,className:"animate-spin text-muted-foreground"}):g.competencyMatrix?e.jsxs("span",{className:`text-[12px] font-medium px-2 rounded-full border ${R>=80?"text-emerald-600 bg-emerald-50 border-emerald-100":R>=60?"text-amber-600 bg-amber-50 border-amber-100":"text-rose-500 bg-rose-50 border-rose-100"}`,children:[R,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},E.key)})]}),e.jsx(Et,{children:g.expanded&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden bg-slate-50/80 border-t border-slate-100 shadow-inner",children:e.jsxs("div",{className:"flex min-w-[1320px]",children:[e.jsx("div",{className:"w-[260px] shrink-0 sticky left-0 z-10 bg-slate-50/90 border-r border-slate-100 flex items-start justify-end pr-4 py-4",children:e.jsx("div",{className:"w-1.5 h-full rounded-full bg-[#9956DE]/30"})}),e.jsx("div",{className:"flex-1 py-4 pl-6 pr-6",children:g.loading?e.jsxs("div",{className:"flex items-center py-4",children:[e.jsx(mt,{size:16,className:"animate-spin text-indigo-500 mr-2"}),e.jsx("span",{className:"text-sm text-slate-500",children:"Analyzing competency data..."})]}):g.competency?e.jsxs("div",{className:"space-y-4 max-w-4xl",children:[g.competency.recommendedTopics.length>0&&e.jsxs("div",{className:"bg-[#f5f3ff] rounded-[12px] p-4 border border-[#e0e7ff] inline-block shadow-sm mb-4",children:[e.jsxs("h4",{className:"text-[#7274ED] font-semibold text-[13px] flex items-center gap-2 mb-1.5",children:[e.jsx(Qt,{className:"w-4 h-4"})," Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:g.competency.recommendedTopics.map((E,R)=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full border border-indigo-100 bg-white text-indigo-700 text-xs font-medium shadow-sm",children:E},R))})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:g.competency.competencies.map((E,R)=>e.jsx(Ym,{competency:E},R))})]}):e.jsx("div",{className:"text-sm text-slate-500 py-4",children:"Failed to load competency details."})})]})})})]},g.rowKey)))})]})})]})},Ym=({competency:t})=>{const s=Eo[t.competencyLevel]||Eo.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})]})},Km=()=>{const{notifications:t,unreadCount:s,isLoading:a,markAsRead:r,markAllAsRead:o}=ei(),[n,i]=u.useState("all"),l=["streak_reminder","daily_checkin","streak_milestone","achievement_unlocked","level_up","xp_earned","quiz_result"],c=t.filter(y=>!y.isRead&&!l.includes(y.type)).length,d=y=>{switch(y){case"achievement_unlocked":case"achievement":return jl;case"message":return Al;case"grade":case"quiz_result":return Jo;case"reminder":case"streak_reminder":case"daily_checkin":return Zs;case"risk_alert":return Xs;case"sparkles":case"lesson_plan_ready":return $s;case"users":case"student_import":return is;default:return Ja}},m=(y,j)=>{switch(y){case"risk_alert":return"bg-rose-50/30 text-rose-500 border-rose-100";case"sparkles":case"lesson_plan_ready":return"bg-purple-50/30 text-[#a855f7] border-purple-100";case"daily_checkin":return"bg-amber-50/20 text-amber-500 border-amber-100";case"users":case"student_import":return"bg-blue-50/30 text-blue-500 border-blue-100";default:return"bg-slate-50 text-slate-500 border-slate-100"}},f=y=>{switch(y){case"risk_alert":return"from-rose-400 to-rose-600 shadow-[0_4px_12px_rgba(244,63,94,0.3)]";case"sparkles":case"lesson_plan_ready":return"from-[#a855f7] to-[#9333ea] shadow-[0_4px_12px_rgba(168,85,247,0.3)]";case"daily_checkin":return"from-amber-300 to-amber-500 shadow-[0_4px_12px_rgba(245,158,11,0.3)]";case"users":case"student_import":return"from-blue-400 to-blue-600 shadow-[0_4px_12px_rgba(59,130,246,0.3)]";default:return"from-slate-400 to-slate-600 shadow-[0_4px_12px_rgba(100,116,139,0.3)]"}},h=u.useMemo(()=>{let y=t.filter(j=>!l.includes(j.type));return n==="unread"&&(y=y.filter(j=>!j.isRead)),n==="important"&&(y=y.filter(j=>j.type==="risk_alert")),y},[t,n]),b=u.useMemo(()=>{const y=[],j=h.filter(N=>Un(N.createdAt)),k=h.filter(N=>Vn(N.createdAt)),p=h.filter(N=>!Un(N.createdAt)&&!Vn(N.createdAt));return j.length>0&&y.push({title:"Today",icon:Zs,items:j}),k.length>0&&y.push({title:"Yesterday",icon:En,items:k}),p.length>0&&y.push({title:"Earlier",icon:En,items:p}),y},[h]);return e.jsx("div",{className:"w-full h-full flex flex-col bg-[#f8fafc]/50",children:e.jsxs("div",{className:"max-w-[900px] mx-auto w-full p-[24px] xl:p-[32px] space-y-[24px] flex-1 overflow-y-auto no-scrollbar pb-12",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>i("all"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border ${n==="all"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:"All"}),e.jsxs("button",{onClick:()=>i("unread"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border flex items-center gap-2 ${n==="unread"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:["Unread",e.jsx("span",{className:"w-5 h-5 rounded-full bg-slate-100 text-[10px] font-bold flex items-center justify-center text-slate-500",children:c})]}),e.jsxs("button",{onClick:()=>i("important"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border flex items-center gap-2 ${n==="important"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:["Important",t.some(y=>y.type==="risk_alert"&&!y.isRead)&&e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-rose-500 shadow-[0_0_8px_rgba(244,63,94,0.6)]"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-3 shrink-0",children:[e.jsx("span",{className:"text-[13px] font-bold text-[#64748b]",children:c>0?`${c} unread`:"No unread"}),e.jsxs("button",{onClick:o,disabled:c===0,className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[13px] font-bold rounded-full px-5 py-2 shadow-sm transition-all hover:shadow-md hover:-translate-y-0.5 flex items-center gap-2 group disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-sm",children:[e.jsx(ac,{className:"w-4 h-4 text-[#94a3b8] group-hover:text-emerald-500 transition-colors"}),"Mark all as read"]})]})]}),e.jsx("div",{className:"space-y-8",children:a?e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white p-12 flex flex-col items-center justify-center gap-4",children:[e.jsx(mt,{className:"w-8 h-8 text-[#a855f7] animate-spin"}),e.jsx("p",{className:"text-[14px] font-medium text-[#64748b]",children:"Syncing notifications..."})]}):b.length===0?e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white p-16 flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mb-6 border border-slate-100",children:e.jsx(Ja,{className:"w-10 h-10 text-slate-300"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:"All clear!"}),e.jsx("p",{className:"text-[14px] text-[#64748b] max-w-sm",children:"No notifications found for this filter. New alerts will appear here automatically."})]}):b.map(y=>e.jsxs("div",{children:[e.jsxs("h3",{className:"text-[12px] font-bold text-[#94a3b8] uppercase tracking-wider mb-3 ml-2 flex items-center gap-2",children:[e.jsx(y.icon,{className:"w-4 h-4"})," ",y.title]}),e.jsx("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_4px_24px_rgba(0,0,0,0.03)] overflow-hidden divide-y divide-[#f1f5f9]",children:y.items.map(j=>{const k=d(j.type),p=j.type==="risk_alert";return e.jsxs(Re.div,{layout:!0,onClick:()=>!j.isRead&&r(j.id),className:`relative p-5 flex gap-5 group cursor-pointer hover:bg-white transition-all duration-300 ${j.isRead?"opacity-80":m(j.type)}`,children:[e.jsx("div",{className:`absolute left-0 top-0 w-1.5 h-full transition-colors ${j.isRead?"bg-transparent":p?"bg-rose-500":"bg-[#a855f7]"}`}),e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-white shrink-0 group-hover:scale-110 transition-transform bg-gradient-to-br ${f(j.type)}`,children:e.jsx(k,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsxs("h4",{className:"text-[15px] font-bold text-[#1e293b] flex items-center gap-2 truncate pr-4",children:[j.title,!j.isRead&&e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${p?"bg-rose-500 shadow-[0_0_6px_rgba(244,63,94,0.8)]":"bg-[#a855f7] shadow-[0_0_6px_rgba(168,85,247,0.8)]"}`})]}),e.jsxs("span",{className:`text-[12px] font-bold whitespace-nowrap ${j.isRead?"text-[#94a3b8]":p?"text-rose-600":"text-[#a855f7]"}`,children:[rc(j.createdAt)," ago"]})]}),e.jsx("p",{className:"text-[14px] text-[#475569] font-medium leading-relaxed",children:j.message}),!j.isRead&&j.actionUrl&&e.jsx("div",{className:"mt-3 flex gap-2",children:e.jsx("button",{className:`px-5 py-2 bg-white border rounded-full text-[12px] font-bold shadow-sm transition-all hover:-translate-y-0.5 ${p?"border-rose-200 text-rose-600 hover:bg-rose-50":"border-purple-200 text-[#9333ea] hover:bg-purple-50"}`,children:"Review Plan"})})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 p-2 text-slate-400 hover:text-slate-600 transition-all rounded-full hover:bg-slate-100 shrink-0 self-start",children:e.jsx(fc,{size:18})})]},j.id)})})]},y.title))})]})})},Xm=t=>{const s=t.data(),a=s.startTime,r=s.endTime,o=s.createdAt,n=s.updatedAt,i=l=>{if(l){if(typeof l?.toDate=="function")return l.toDate();if(l instanceof Date)return l}};return{...s,id:t.id,startTime:i(a)||new Date,endTime:i(r),createdAt:i(o)||new Date,updatedAt:i(n)}},Jm=async(t,s)=>{const a=dt($t(Ue,"calendarEvents")),r={id:a.id,userId:t,title:s.title,description:s.description,startTime:s.startTime,endTime:s.endTime,color:s.color,createdAt:new Date};return await es(a,{...r,createdAt:ot(),updatedAt:ot()}),r},Zm=async(t,s)=>{const a=dt(Ue,"calendarEvents",t);await Zt(a,{...s,updatedAt:ot()})},eu=async t=>{await _l(dt(Ue,"calendarEvents",t))},Ji=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:o=500}=s,n=kt($t(Ue,"calendarEvents"),jt("userId","==",t),Vr(o));return ti(n,i=>{a(i.docs.map(l=>Xm(l)))},i=>{console.error("Error subscribing to calendar events:",i),r?.(i)})};function tu({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Xo("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 qs=t=>String(t).padStart(2,"0"),Ms=t=>`${t.getFullYear()}-${qs(t.getMonth()+1)}-${qs(t.getDate())}`,Qr=t=>new Date(t.getFullYear(),t.getMonth(),1),Ro=t=>new Date(t.getFullYear(),t.getMonth()+1,0),su=t=>{const s=Qr(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},au=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},_o=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),ru=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),nu=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),Oa=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),Mo=(t,s)=>{const[a,r,o]=t.split("-").map(l=>parseInt(l,10)),[n,i]=s.split(":").map(l=>parseInt(l,10));return new Date(a,(r||1)-1,o||1,n||0,i||0,0,0)},ou=["purple","blue","emerald","amber","rose"],Ir=t=>{switch(t){case"blue":return"#3b82f6";case"emerald":return"#10b981";case"amber":return"#f59e0b";case"rose":return"#f43f5e";case"purple":default:return"#a855f7"}},iu=(t,s=!1)=>{if(s)return"bg-blue-50 text-blue-700 border-blue-100 opacity-80";switch(t){case"blue":return"bg-blue-50 text-blue-700 border-blue-100 opacity-90 hover:bg-blue-100";case"emerald":return"bg-emerald-50 text-emerald-700 border-emerald-100 opacity-90 hover:bg-emerald-100";case"amber":return"bg-amber-50 text-amber-700 border-amber-100 opacity-90 hover:bg-amber-100";case"rose":return"bg-rose-50 text-rose-700 border-rose-100 opacity-90 hover:bg-rose-100";case"purple":default:return"bg-purple-50 text-purple-700 border-purple-100 opacity-90 hover:bg-purple-100"}},lu=(t,s=!1)=>{if(s)return{dot:"bg-[#3b82f6]",border:"border-l-blue-400",time:"text-blue-600 border-blue-50"};switch(t){case"blue":return{dot:"bg-blue-500",border:"border-l-blue-400",time:"text-blue-600 border-blue-50"};case"emerald":return{dot:"bg-emerald-500",border:"border-l-emerald-400",time:"text-emerald-600 border-emerald-50"};case"amber":return{dot:"bg-amber-500",border:"border-l-amber-400",time:"text-amber-600 border-amber-50"};case"rose":return{dot:"bg-rose-500",border:"border-l-rose-400",time:"text-rose-600 border-rose-50"};case"purple":default:return{dot:"bg-[#a855f7]",border:"border-l-[#a855f7]",time:"text-[#a855f7] border-purple-50"}}},Tr=[{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 cu(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 o=Tr.find(i=>i.names.includes(r[1]))?.day,n=Tr.find(i=>i.names.includes(r[2]))?.day;if(o!==void 0&&n!==void 0){let i=o;for(;a.add(i),i!==n;)i=(i+1)%7;return Array.from(a)}}return Tr.forEach(({names:o,day:n})=>{o.some(i=>s.includes(i))&&a.add(n)}),Array.from(a).sort((o,n)=>o-n)}const du=({classes:t,teacherId:s})=>{const{currentUser:a}=ds(),[r,o]=u.useState([]),[n,i]=u.useState(!0),[l,c]=u.useState(""),[d,m]=u.useState(!0),[f,h]=u.useState(()=>{const $=new Date;return $.setHours(0,0,0,0),$}),[b,y]=u.useState(()=>{const $=new Date;return $.setHours(0,0,0,0),$}),[j,k]=u.useState(new Set),[p,N]=u.useState(!1),[I,A]=u.useState(null),[C,U]=u.useState(!1),[v,S]=u.useState(""),[w,z]=u.useState(""),[O,T]=u.useState(()=>Ms(new Date)),[G,q]=u.useState("09:00"),[se,le]=u.useState(""),[ae,fe]=u.useState("purple"),[pe,P]=u.useState(!1),[Y,M]=u.useState(null);u.useEffect(()=>{if(!a?.uid){o([]),i(!1);return}c(""),i(!0);const $=Ji(a.uid,{limitCount:500},oe=>{o(oe),i(!1)},()=>{c("Unable to load calendar events right now."),i(!1)});return()=>$()},[a?.uid]);const K=u.useMemo(()=>{const $=Qr(f);return $.setHours(0,0,0,0),$},[f]),re=u.useMemo(()=>{const $=Ro(f);return $.setHours(23,59,59,999),$},[f]),$e=u.useMemo(()=>{if(!t||t.length===0)return[];const $=[],oe=Qr(f),xe=Ro(f),we=new Date(oe);for(;we<=xe;){const te=we.getDay();t.forEach(he=>{if(cu(he.schedule).includes(te)){const Fe=`schedule-${he.id}-${Ms(we)}`;j.has(Fe)||$.push({id:Fe,userId:s||"",title:he.name,startTime:new Date(we),createdAt:new Date})}}),we.setDate(we.getDate()+1)}return $},[t,f,s,j]),Me=u.useMemo(()=>[...r,...$e],[r,$e]),Qe=u.useMemo(()=>Me.filter($=>$.startTime>=K&&$.startTime<=re).sort(($,oe)=>$.startTime.getTime()-oe.startTime.getTime()),[Me,K,re]),H=u.useMemo(()=>{const $=new Map;for(const oe of Qe){const xe=Ms(oe.startTime),we=$.get(xe)||[];we.push(oe),$.set(xe,we)}return $},[Qe]),ee=u.useMemo(()=>Ms(b),[b]),g=u.useMemo(()=>[...H.get(ee)||[]].sort((oe,xe)=>oe.startTime.getTime()-xe.startTime.getTime()),[H,ee]),E=u.useMemo(()=>{const $=su(f);return Array.from({length:42}).map((oe,xe)=>au($,xe))},[f]),R=$=>{const oe=Ms($);A(null),S(""),z(""),T(oe),q("09:00"),le(""),fe("purple"),N(!0)},X=$=>{$.id.startsWith("schedule-")?(k(oe=>new Set(oe).add($.id)),A(null)):A($.id),S($.title),z($.description||""),T(Ms($.startTime)),q(qs($.startTime.getHours())+":"+qs($.startTime.getMinutes())),le($.endTime?qs($.endTime.getHours())+":"+qs($.endTime.getMinutes()):""),fe($.color||"purple"),P(!1),N(!0)},J=($,oe)=>{$.stopPropagation(),M(oe),P(!0)},ne=async()=>{const $=a?.uid||s||"local-user";if(!v.trim()){c("Event title is required.");return}U(!0),c("");const oe=Mo(O,G),xe=se?Mo(O,se):void 0,we={title:v.trim(),description:w.trim()?w.trim():void 0,startTime:oe,endTime:xe&&xe.getTime()>oe.getTime()?xe:void 0,color:ae};try{if(I)o(te=>te.map(he=>he.id===I?{...he,...we}:he)),await Zm(I,we);else{const te=`temp-${Date.now()}`;o(he=>[...he,{id:te,userId:$,createdAt:new Date,...we}]),await Jm($,we)}N(!1)}catch(te){console.error(te),N(!1)}finally{U(!1)}},ce=async $=>{if($.startsWith("schedule-")){k(oe=>new Set(oe).add($)),Y?.id===$&&P(!1);return}c(""),o(oe=>oe.filter(xe=>xe.id!==$)),Y?.id===$&&P(!1);try{await eu($)}catch(oe){console.error(oe)}};return e.jsxs("div",{className:"w-full h-full flex flex-col px-[24px] xl:px-[32px] py-[24px] xl:py-[32px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 flex-1 min-h-0 w-full max-w-[1400px] mx-auto",children:[e.jsx("div",{className:`flex flex-col flex-1 min-w-0 transition-all duration-500 ${d?"lg:w-[65%] xl:w-[70%]":"lg:w-full"}`,children:e.jsxs("div",{className:"bg-white/90 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 border-b border-[#a855f7] bg-[#a855f7] shrink-0 flex justify-between items-center rounded-t-[24px] relative overflow-hidden group",children:[e.jsx("div",{className:"absolute -bottom-24 -right-12 w-64 h-64 bg-white/10 rounded-full"}),e.jsx("div",{className:"absolute -top-20 left-1/4 w-40 h-40 bg-white/5 rounded-full"}),e.jsxs("div",{className:"flex items-center gap-5 relative z-10",children:[e.jsx("button",{onClick:()=>h(new Date(f.getFullYear(),f.getMonth()-1,1)),"aria-label":"Previous month",className:"w-9 h-9 rounded-full flex items-center justify-center text-[#6d28d9] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(Ss,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-[22px] font-bold text-white w-44 text-center tracking-tight",children:nu(f)}),e.jsx("button",{onClick:()=>h(new Date(f.getFullYear(),f.getMonth()+1,1)),"aria-label":"Next month",className:"w-9 h-9 rounded-full flex items-center justify-center text-[#6d28d9] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(ys,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-3 relative z-10",children:[e.jsxs("span",{className:"text-[13px] font-bold text-[#6d28d9] bg-white px-4 py-1.5 rounded-full shadow-sm",children:[Qe.length," events"]}),e.jsx("button",{onClick:()=>m(!d),className:`w-9 h-9 rounded-full flex items-center justify-center transition-all shadow-sm hover:shadow-md border ${d?"text-[#6d28d9] bg-white border-white":"text-white bg-white/20 border-white/30 backdrop-blur-md"}`,title:d?"Hide Sidebar":"Show Sidebar","aria-label":d?"Hide Sidebar":"Show Sidebar",children:e.jsx(kc,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto custom-scrollbar",children:[e.jsx("div",{className:"grid grid-cols-7 text-center border-b border-slate-200/60 pb-5 shrink-0 sticky top-0 bg-white z-20 shadow-[0_10px_10px_-10px_rgba(0,0,0,0.05)] px-4 pt-6",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map($=>e.jsx("div",{className:"text-[12px] font-bold text-[#475569] uppercase tracking-widest",children:$},$))}),e.jsx("div",{className:"grid grid-cols-7 gap-2 pb-6 px-4",children:E.map($=>{const oe=Ms($),xe=H.get(oe)||[],we=_o($,b),te=_o($,new Date),he=ru($,f);return e.jsxs("div",{onClick:()=>y(new Date($)),className:`group p-2 rounded-lg transition-all cursor-pointer border-2 flex flex-col relative min-h-[100px] xl:min-h-[120px] ${we?"bg-purple-50/50 border-[#a855f7] shadow-sm z-10":te?"bg-purple-50/20 border-purple-300 shadow-[inset_0_0_20px_rgba(168,85,247,0.05)] hover:bg-purple-50/40 hover:border-purple-400":"border-transparent hover:bg-slate-50 hover:border-slate-200"} ${he?"":"opacity-30 grayscale"}`,children:[e.jsx("div",{className:"flex justify-between items-start",children:e.jsx("span",{className:`w-7 h-7 rounded-full flex items-center justify-center font-bold text-[14px] transition-all ${te?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":we?"text-[#9333ea]":"text-[#1e293b]"}`,children:$.getDate()})}),e.jsxs("div",{className:"mt-1 space-y-1",children:[xe.slice(0,3).map(et=>{const Fe=et.id.startsWith("schedule-");return e.jsx("div",{onClick:Ke=>J(Ke,et),className:`w-full truncate text-[11px] font-bold px-2 py-1.5 rounded border shadow-sm transition-all hover:-translate-y-[1px] hover:shadow-md cursor-pointer ${iu(et.color,Fe)}`,children:et.title},et.id)}),xe.length>3&&e.jsxs("div",{className:"text-[10px] font-bold text-[#64748b] pl-1 pt-0.5",children:["+",xe.length-3," more"]})]})]},oe)})})]})]})}),e.jsx(Et,{children:d&&e.jsx(Re.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"lg:w-[35%] xl:w-[30%] h-full shrink-0",children:e.jsxs("div",{className:"bg-white/90 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 border-b border-[#f1f5f9] bg-white shrink-0 flex justify-between items-center relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-[-30px] right-[-30px] w-24 h-24 bg-purple-50 rounded-full mix-blend-multiply filter blur-2xl opacity-50 transition-transform duration-700 group-hover:scale-150"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b]",children:b.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:b.toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})})]}),e.jsx("button",{onClick:()=>R(b),title:"Add Event",className:"w-10 h-10 flex items-center justify-center rounded-full bg-[#a855f7] text-white hover:bg-[#9333ea] shadow-md shadow-purple-200 transition-all hover:scale-105 active:scale-95 relative z-10",children:e.jsx(Js,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar pb-12",children:g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[e.jsx(br,{className:"w-12 h-12 text-slate-300 mb-4"}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b]",children:"No events today"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Schedule a meeting or add a class."})]}):g.map($=>{const oe=$.id.startsWith("schedule-"),xe=lu($.color,oe);return e.jsxs("div",{className:"relative pl-6 before:absolute before:left-2 before:top-2 before:bottom-[-24px] before:w-[2px] before:bg-slate-100 last:before:hidden",children:[e.jsx("div",{className:`absolute left-0 top-1.5 w-4 h-4 rounded-full border-[3px] border-white shadow-sm z-10 ${xe.dot}`}),e.jsxs("div",{onClick:we=>J(we,$),className:`group relative bg-white border border-[#e2e8f0] rounded-[20px] p-5 shadow-sm hover:shadow-md hover:-translate-y-0.5 transition-all border-l-[6px] cursor-pointer ${xe.border}`,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsx("h4",{className:"text-[15px] font-bold text-[#1e293b] group-hover:text-[#9333ea] transition-colors break-words line-clamp-2 w-full pr-2",children:$.title})}),e.jsxs("div",{className:`flex items-center gap-2 text-[11px] font-bold bg-slate-50 w-max px-2.5 py-1 rounded-lg border mb-3 ${xe.time}`,children:[e.jsx(Zs,{className:"w-3.5 h-3.5"})," ",e.jsxs("span",{children:[Oa($.startTime),$.endTime?` - ${Oa($.endTime)}`:""]})]}),$.description&&e.jsx("p",{className:"text-[13px] font-medium text-[#64748b] bg-slate-50/50 px-3 py-2 rounded-xl border border-slate-100/30 break-words whitespace-normal w-full overflow-hidden",children:$.description})]})]},$.id)})})]})})})]}),e.jsx(An,{open:p,onOpenChange:N,children:e.jsx(zn,{className:"sm:max-w-[500px] p-0 overflow-hidden rounded-[28px] border-none shadow-2xl [&>button]:hidden",children:e.jsxs("div",{className:"p-8 bg-white",children:[e.jsxs(nc,{className:"mb-6",children:[e.jsx(oc,{className:"text-[24px] font-bold text-[#1e293b] tracking-tight",children:I?"Edit Event":"Add New Event"}),e.jsx(ic,{className:"text-[14px] text-[#64748b]",children:"Schedule a classroom activity or reminder."})]}),l&&e.jsx("p",{className:"text-rose-500 text-sm font-semibold mb-4",children:l}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Event Title"}),e.jsx(Ns,{value:v,onChange:$=>S($.target.value),placeholder:"e.g., Mathematics Quiz - Grade 11",className:"bg-white border-slate-200 focus:border-[#a855f7] focus:ring-4 focus:ring-purple-50 rounded-xl h-12 px-4 transition-all text-[14px]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Date"}),e.jsx(Ns,{type:"date",value:O,onChange:$=>T($.target.value),className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl h-12 px-4 text-[14px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Start Time"}),e.jsx(Ns,{type:"time",value:G,onChange:$=>q($.target.value),className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl h-12 px-4 text-[14px]"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Notes (Optional)"}),e.jsx(tu,{value:w,onChange:$=>z($.target.value),placeholder:"Additional details about this event...",className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl min-h-[100px] p-4 transition-all text-[14px] break-all"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Color Theme"}),e.jsx("div",{className:"flex gap-3 ml-1",children:ou.map($=>e.jsx("button",{onClick:()=>fe($),className:`w-8 h-8 rounded-full flex items-center justify-center transition-all ${ae===$?"ring-2 ring-offset-2 ring-slate-800 scale-110 shadow-sm":"hover:scale-110 opacity-80 hover:opacity-100"}`,style:{backgroundColor:Ir($)},title:$,children:ae===$&&e.jsx(Mt,{className:"w-4 h-4 text-white"})},$))})]})]}),e.jsxs("div",{className:"flex gap-3 mt-8",children:[e.jsx(pt,{variant:"outline",onClick:()=>N(!1),className:"flex-1 h-12 rounded-xl font-bold border-slate-200 hover:bg-slate-100 transition-all text-[14px]",children:"Cancel"}),e.jsx(pt,{onClick:ne,disabled:C,className:"flex-[1.5] h-12 rounded-xl font-bold bg-[#a855f7] hover:bg-[#9333ea] text-white shadow-lg shadow-purple-200 transition-all hover:scale-[1.02] text-[14px]",children:C?e.jsx(mt,{className:"w-5 h-5 animate-spin"}):"Save Event"})]})]})})}),e.jsx(An,{open:pe,onOpenChange:P,children:e.jsx(zn,{className:"sm:max-w-[400px] p-0 overflow-hidden rounded-[24px] border-none shadow-2xl [&>button]:hidden",children:Y&&e.jsxs("div",{className:"p-8 bg-white relative",children:[e.jsx("button",{onClick:()=>P(!1),"aria-label":"Close event details",className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(cs,{size:18})}),e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center shrink-0",style:{backgroundColor:Ir(Y.color||"purple")+"20",color:Ir(Y.color||"purple")},children:Y.id.startsWith("schedule-")?e.jsx(Ya,{size:24}):e.jsx(br,{size:24})}),e.jsxs("div",{className:"pr-6",children:[e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] leading-tight mb-2",children:Y.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-[12px] font-semibold border border-slate-200",children:[e.jsx(br,{size:12}),Y.startTime.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-[12px] font-semibold border border-slate-200",children:[e.jsx(Zs,{size:12}),Oa(Y.startTime),Y.endTime?` - ${Oa(Y.endTime)}`:""]})]})]})]}),Y.description&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(mc,{size:16,className:"text-slate-400"}),e.jsx("h4",{className:"text-[13px] font-bold text-slate-700",children:"Details"})]}),e.jsx("p",{className:"text-[14px] text-slate-600 leading-relaxed bg-slate-50/50 p-4 rounded-xl border border-slate-100/50 break-words",children:Y.description})]}),e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-slate-100",children:[e.jsxs(pt,{variant:"outline",onClick:()=>ce(Y.id),className:"flex-1 h-11 rounded-xl font-bold border-rose-200 text-rose-600 hover:bg-rose-50 hover:text-rose-700 transition-all text-[13px]",children:[e.jsx(ri,{className:"w-4 h-4 mr-2"})," Delete"]}),e.jsxs(pt,{onClick:()=>X(Y),className:"flex-1 h-11 rounded-xl font-bold bg-[#1e293b] hover:bg-slate-800 text-white shadow-lg shadow-slate-200 transition-all hover:scale-[1.02] text-[13px]",children:[e.jsx(ci,{className:"w-4 h-4 mr-2"})," Edit Event"]})]})]})})})]})},ar=[{hex:"#9956DE",bg:"bg-[#9956DE]/10",border:"border-[#9956DE]/20",borderLeft:"border-l-[#9956DE]",text:"text-[#9956DE]",groupHover:"group-hover:text-[#9956DE]"},{hex:"#7274ED",bg:"bg-[#7274ED]/10",border:"border-[#7274ED]/20",borderLeft:"border-l-[#7274ED]",text:"text-[#7274ED]",groupHover:"group-hover:text-[#7274ED]"},{hex:"#1FA7E1",bg:"bg-[#1FA7E1]/10",border:"border-[#1FA7E1]/20",borderLeft:"border-l-[#1FA7E1]",text:"text-[#1FA7E1]",groupHover:"group-hover:text-[#1FA7E1]"},{hex:"#6ED1CF",bg:"bg-[#6ED1CF]/10",border:"border-[#6ED1CF]/20",borderLeft:"border-l-[#6ED1CF]",text:"text-[#6ED1CF]",groupHover:"group-hover:text-[#6ED1CF]"},{hex:"#FFB356",bg:"bg-[#FFB356]/10",border:"border-[#FFB356]/20",borderLeft:"border-l-[#FFB356]",text:"text-[#FFB356]",groupHover:"group-hover:text-[#FFB356]"}],Ao=({classes:t,onSelectClass:s,onOpenNotifications:a,onOpenProfile:r,insightDismissed:o,onOpenInsightModal:n,viewType:i="analytics",onCreateClass:l})=>{const{currentUser:c,userProfile:d}=ds(),[m,f]=u.useState(""),h=i==="competency",b=t.reduce((p,N)=>p+(N.studentCount||0),0),y=t.reduce((p,N)=>p+(N.atRiskCount||0),0),j=t.length>0?(t.reduce((p,N)=>p+(N.avgScore||0),0)/t.length).toFixed(1):0,k=t.filter(p=>p.name.toLowerCase().includes(m.toLowerCase())||(p.gradeLevel||"").toLowerCase().includes(m.toLowerCase()));return e.jsx("div",{className:"h-full overflow-y-auto w-full block",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto p-3 sm:p-[24px] xl:p-[32px] space-y-3 sm:space-y-[24px]",children:[e.jsx("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:e.jsx("div",{className:"flex-1 max-w-xl",children:e.jsxs("div",{className:"flex items-center bg-white/80 px-4 py-2.5 rounded-[16px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white backdrop-blur-[12px] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Global search for a student across all classes...",value:m,onChange:p=>f(p.target.value),className:"bg-transparent border-none focus:outline-none ml-3 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]})})}),h?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Students Evaluated"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(is,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:b}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Active across all classes"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Global Avg Competency"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(ws,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[j,"%"]}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. expected benchmark"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:"+1.4%"})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Universal Weakness"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(ws,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[20px] font-bold relative z-10 leading-tight mb-2 truncate",children:"Foundational Skills"}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsxs("span",{className:"text-[12px] font-medium text-white/90",children:["Identified in ",t.length," classes"]})})]})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-2 sm:gap-[16px]",children:[e.jsxs("div",{className:"lg:col-span-8 grid grid-cols-3 sm:grid-cols-3 gap-2 sm:gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"Attendance rate"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(is,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:"94%"}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Active participants"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:b>0?Math.round(b*.94):0})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"Class average"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(ws,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:[j,"%"]}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. last month"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:"+2.1%"})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"At risk"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(or,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:y}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Requires attention"}),e.jsxs("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:[b>0?Math.round(y/b*100):0,"%"]})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col text-white",children:[e.jsx("div",{className:"absolute -right-12 -top-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex justify-between items-center mb-4 relative z-10 border-b border-white/20 pb-3",children:[e.jsxs("h3",{className:"text-[14px] font-semibold text-white flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-white animate-pulse shadow-[0_0_8px_rgba(255,255,255,0.8)]"}),"AI Action Items"]}),e.jsx("span",{className:"text-[10px] font-bold text-[#9333ea] bg-white px-2 py-0.5 rounded-[4px]",children:"2 Pending"})]}),e.jsxs("div",{className:"space-y-[8px] flex-1 overflow-y-auto no-scrollbar relative z-10",children:[e.jsxs("div",{className:"bg-white/10 hover:bg-white/20 rounded-[8px] p-3 text-[12px] border border-white/10 transition-colors backdrop-blur-sm group cursor-pointer flex gap-3 items-start",children:[e.jsx("div",{className:"mt-0.5 shrink-0 text-white/80 group-hover:text-white transition-colors",children:e.jsx(di,{className:"w-4 h-4"})}),e.jsxs("div",{className:"leading-snug text-white/90",children:[e.jsx("span",{className:"font-bold text-white",children:"Grade 11 - Section B"})," average dropped by 4% after the last quiz."]})]}),e.jsxs("div",{className:"bg-white/10 hover:bg-white/20 rounded-[8px] p-3 text-[12px] border border-white/10 transition-colors backdrop-blur-sm group cursor-pointer flex gap-3 items-start",children:[e.jsx("div",{className:"mt-0.5 shrink-0 text-white/80 group-hover:text-white transition-colors",children:e.jsx(bs,{className:"w-4 h-4"})}),e.jsxs("div",{className:"leading-snug text-white/90",children:[e.jsx("span",{className:"font-bold text-white",children:"3 Lesson Plans"})," generated and awaiting your review."]})]})]})]})]}),e.jsxs("div",{className:"bg-white/60 backdrop-blur-[12px] rounded-[24px] p-3 sm:p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-3 sm:mt-[24px]",children:[e.jsxs("div",{className:"mb-6 border-b border-[#f1f5f9] pb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[18px] font-semibold text-[#1e293b]",children:h?"Select a Class":"My Classes"}),l&&!h&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-semibold text-[#9956DE] bg-[#9956DE]/10 rounded-lg hover:bg-[#9956DE]/20 transition-colors",children:[e.jsx(Js,{size:14}),"Create Class"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-[16px]",children:[k.map((p,N)=>{const I=ar[N%ar.length];let A=null;return p.riskLevel==="high"?A=e.jsx("span",{className:"inline-flex px-2 py-1 bg-rose-50 text-rose-600 text-[10px] font-bold rounded-md border border-rose-100/50 uppercase",children:"High Risk"}):p.riskLevel==="medium"?A=e.jsx("span",{className:"inline-flex px-2 py-1 bg-amber-50 text-amber-600 text-[10px] font-bold rounded-md border border-amber-100/50 uppercase",children:"Medium Risk"}):A=e.jsx("span",{className:"inline-flex px-2 py-1 bg-emerald-50 text-emerald-600 text-[10px] font-bold rounded-md border border-emerald-100/50 uppercase",children:"On Track"}),e.jsxs("div",{onClick:()=>s(p),className:`flex flex-col p-[16px] bg-white shadow-[0_1px_4px_rgba(0,0,0,0.04)] hover:shadow-md hover:-translate-y-0.5 rounded-[18px] transition-all cursor-pointer group border border-[#f1f5f9] border-l-[6px] ${I.borderLeft}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-[12px] ${I.bg} flex items-center justify-center border ${I.border}`,children:e.jsx(Qt,{className:`w-5 h-5 ${I.text}`})}),e.jsxs("div",{children:[e.jsx("h4",{className:`font-bold text-[14px] text-[#1e293b] mb-0.5 transition-colors ${I.groupHover}`,children:p.name}),e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider",children:p.gradeLevel||"Senior High"})]})]}),A]}),e.jsxs("div",{className:"flex items-center justify-between text-[13px] text-[#475569] bg-[#f8fafc] rounded-[12px] p-3 border border-[#f1f5f9]",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Students"}),e.jsx("span",{className:"font-semibold text-[#1e293b]",children:p.studentCount})]}),e.jsx("div",{className:"w-[1px] h-8 bg-[#e2e8f0]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:h?"Avg Competency":"Average"}),e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[p.avgScore,"%"]})]}),!h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-[1px] h-8 bg-[#e2e8f0]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Schedule"}),e.jsx("span",{className:"font-semibold text-[#1e293b]",children:p.schedule||"Mon-Fri"})]})]})]})]},p.id)}),k.length===0&&e.jsx("div",{className:"col-span-full py-8 text-center text-[#64748b] text-[13px] bg-[#f8fafc] rounded-[18px] border border-[#e2e8f0]",children:"No classes match your search."})]})]})]})})},Zi="PH_SHS_OFFICIAL_CLASS_RECORD",mu=.85,Gr=.85,uu="2026.04.24",el=4,Va=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],xu=[...Va,"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"],pu=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],Ma=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],hu=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],fu={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},Ws={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"]},Ht={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"]},De={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 gu(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function bt(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function zo(t){return bt(t).replace(/[^A-Z0-9]+/g,"")}function Se(t,s){const a=bt(t),r=bt(s);if(!a||!r)return!1;if(a.includes(r))return!0;const o=zo(t),n=zo(s);return!o||!n?!1:o.includes(n)}function Wa(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 Er(t){return bt(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function tl(t){const s={};return t.forEach(a=>{const r=Vt.encode_cell(a.s);for(let o=a.s.r;o<=a.e.r;o+=1)for(let n=a.s.c;n<=a.e.c;n+=1){const i=Vt.encode_cell({r:o,c:n});s[i]=r}}),s}function bu(t,s,a){const o=(a||tl(t.merges))[s]||s;return t.cells[o]||t.cells[s]}const sl="A1:A1",Lo=1200,Do=200,$o=2e5;function vu(t){const s=Math.max(0,t.s.r),a=Math.max(0,t.s.c);let r=Math.max(s,t.e.r),o=Math.max(a,t.e.c);r-s+1>Lo&&(r=s+Lo-1),o-a+1>Do&&(o=a+Do-1);const n=r-s+1,i=o-a+1;if(n*i>$o){const c=Math.max(1,Math.floor($o/i));r=s+Math.min(n,c)-1}return{s:{r:s,c:a},e:{r,c:o}}}function wu(t){try{return Vt.decode_range(t)}catch{return Vt.decode_range(sl)}}function Nu(t){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;return Object.keys(t.cells).forEach(n=>{try{const i=Vt.decode_cell(n);s=Math.min(s,i.r),a=Math.min(a,i.c),r=Math.max(r,i.r),o=Math.max(o,i.c)}catch{}}),t.merges.forEach(n=>{s=Math.min(s,n.s.r,n.e.r),a=Math.min(a,n.s.c,n.e.c),r=Math.max(r,n.s.r,n.e.r),o=Math.max(o,n.s.c,n.e.c)}),!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(o)?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(o))}}}function ju(t){const s=wu(t.ref||sl),a=Nu(t);return vu(a||s)}function yu(t,s){const a=ju(s),r=`${Vt.encode_cell(a.s)}:${Vt.encode_cell(a.e)}`,o=tl(s.merges),n=a.e.r-a.s.r+1,i=a.e.c-a.s.c+1,l=[];for(let c=0;ct.endRow||at.endCol?null:t.cells[s-t.startRow]?.[a-t.startCol]??null}function Es(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function ha(t){return Vt.encode_col(t)}function Ba(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return Vt.decode_col(s)}catch{return-1}}function Su(t){return`${Vt.encode_cell(t.s)}:${Vt.encode_cell(t.e)}`}function ku(t,s){const a=[];for(let r=s.s.r;r<=s.e.r;r+=1){const o=[];for(let n=s.s.c;n<=s.e.c;n+=1){const i=Be(t,r,n);o.push(i?.displayValue??null)}a.push(o)}return a}function Cu(t,s){const a=bt(t),r=bt(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function dn(t,s){const a=[];for(let r=0;r{Se(l.normalizedText,c)&&a.push({sheetName:t.sheetName,anchor:c,row:l.row,col:l.col,address:l.address,value:String(l.displayValue??""),confidence:Cu(l.displayValue,c)})})}const o=t.startRow+r,n=Es(t,o);n&&s.forEach(i=>{if(!Se(n,i))return;const l=t.cells[r].find(c=>c?.normalizedText);l&&a.push({sheetName:t.sheetName,anchor:i,row:o,col:l.col,address:l.address,value:n,confidence:.8})})}return a}function Iu(t,s){return Object.values(t).flatMap(a=>dn(a,s))}function wt(t,s){return dn(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function al(t,s,a,r=6){for(let o=1;o<=r;o+=1){const i=Be(t,s,a+o)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}for(let o=1;o<=r;o+=1){const i=Be(t,s+o,a)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}}function rl(t,s,a=5){let r=s,o=-1;for(let n=Math.max(t.startRow,s-a);n<=Math.min(t.endRow,s+a);n+=1){const i=Es(t,n),l=["LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK"].reduce((c,d)=>i.includes(d)?c+1:c,0);l>o&&(o=l,r=n)}return r}function Tu(t,s){const a=bt(t).toLowerCase(),r=o=>[...s].some(n=>Se(n,o));return Ws.inputData.some(o=>a.includes(o))||r("INPUT DATA")?"inputData":Ws.finalSemestral.some(o=>a.includes(o))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":Ws.firstQuarter.some(o=>a.includes(o))||r("FIRST QUARTER")?"firstQuarter":Ws.secondQuarter.some(o=>a.includes(o))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":Ws.helper.some(o=>a.includes(o))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":Ws.lookup.some(o=>a.includes(o))||r("LOOK UP")?"lookup":"other"}function Eu(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,o=.65*s+.2*a+.15*r;return Number(Math.max(0,Math.min(1,o)).toFixed(4))}function Ru(t){const s=Iu(t.matrices,xu),a=new Set,r=[];Va.forEach(b=>{s.some(j=>Se(j.anchor,b))&&(a.add(b),r.push(`Found critical anchor: ${b}`))});const o=Va.filter(b=>!a.has(b)),n=new Map;s.forEach(b=>{n.has(b.sheetName)||n.set(b.sheetName,new Set),n.get(b.sheetName)?.add(b.anchor)});const i=t.sheetNames.map(b=>{const y=n.get(b)||new Set,j=Tu(b,y),k=Math.min(1,.35+Math.min(.55,y.size*.08)),p=[`sheet:${b}`,`signals:${y.size}`,...[...y].slice(0,5)];return{sheetName:b,role:j,confidence:Number(k.toFixed(3)),evidence:p}}),l={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};i.forEach(b=>{switch(b.role){case"inputData":l.inputData?l.other.push(b.sheetName):l.inputData=b.sheetName;break;case"firstQuarter":l.firstQuarter.push(b.sheetName);break;case"secondQuarter":l.secondQuarter.push(b.sheetName);break;case"finalSemestral":l.finalSemestral.push(b.sheetName);break;case"helper":l.helper.push(b.sheetName);break;case"lookup":l.lookup.push(b.sheetName);break;case"other":default:l.other.push(b.sheetName);break}});const c=(l.inputData?1:0)+l.firstQuarter.length+l.secondQuarter.length+l.finalSemestral.length+l.helper.length+l.lookup.length,d=Eu({criticalFound:a.size,criticalTotal:Va.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(b=>Se(b.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),m=l.firstQuarter.length>0||l.secondQuarter.length>0,f=!!l.inputData&&m&&l.finalSemestral.length>0,h=d>=.55&&f;return l.inputData||r.push("Input Data sheet not confidently detected."),m||r.push("No quarter class record sheet detected."),l.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:Zi,isOfficialFormatLikely:h,confidence:d,evidence:r,missingCriticalAnchors:o,detectedSheets:l,anchorMatches:s}}function rr(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 mn(t){const s=bt(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function un(t){const s=bt(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":pu.some(a=>s.includes(a))?"signature":hu.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 _u(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{a.push({role:r,name:String(Be(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Mu(t){const s=[],a=wt(t,"LEARNERS NAMES")[0],r=a?rl(t,a.row,5):t.startRow,o=(k,p)=>wt(t,k).find(I=>Math.abs(I.row-r)<=2)?.col??p,n=o(De.learnerNo[0],t.startCol),i=o(De.learnerName[0],t.startCol+1),l=o(De.firstQuarter[0],i+1),c=o(De.secondQuarter[0],l+1),d=o(De.firstSemester[0],c+1),m=o(De.finalGrades[0],d+1),f=o(De.remark[0],m+1),h=o(De.additionalRemarks[0],f+1),b=[];let y="UNKNOWN",j=0;for(let k=r+1;k<=t.endRow;k+=1){const p=Es(t,k),N=un({rowText:p,hasLearnerNumber:/\b\d{1,2}\b/.test(p),hasLearnerName:/[A-Z]{2,}/.test(p)});if(N==="sex-header"){y=mn(p)||y;continue}if(N==="signature"||N==="helper")break;if(N==="blank"){if(j+=1,j>=el)break;continue}if(N!=="learner")continue;j=0;const I=rr(Be(t,k,n)?.displayValue),A=String(Be(t,k,i)?.displayValue||"").trim();if(!A&&I===void 0)continue;const C=Be(t,k,l)?.displayValue??null,U=Be(t,k,c)?.displayValue??null,v=Be(t,k,d)?.displayValue??null,S=Be(t,k,m)?.displayValue??null,w=Be(t,k,f)?.displayValue??null;let z=Be(t,k,h)?.displayValue??null;const O=Ma.filter(T=>Se(p,T));O.length>0&&(z=[z,O.join("; ")].filter(Boolean).join("; ")||null),!A&&I!==void 0&&s.push(`Row ${k+1} has learner number ${I} but empty learner name.`),b.push({learnerNo:I,fullName:A||`Unnamed Learner ${I||k+1}`,sex:y,firstQuarter:C,secondQuarter:U,firstSemester:v,finalGrades:S,remark:w,additionalRemarks:z,sourceRow:k+1})}return{sheetName:t.sheetName,learnerGrades:b,signatures:_u(t),warnings:s}}function Jt(t,s){for(const a of s){const r=wt(t,a);for(const o of r){const n=al(t,o.row,o.col,8);if(n&&n.trim())return n.trim()}}}function Au(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(n=>{const i=al(t,n.row,n.col,10);a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function zu(t){const s=wt(t,"LEARNERS NAMES")[0];if(!s)return[];const a=s.row+1,r=s.col,o=Math.max(t.startCol,r-1),n=Math.min(t.endCol,r+1),i=Math.min(t.endCol,r+2),l=[];let c="UNKNOWN",d=0;for(let m=a;m<=t.endRow;m+=1){const f=Es(t,m),h=un({rowText:f,hasLearnerNumber:!!rr(Be(t,m,o)?.displayValue),hasLearnerName:!!String(Be(t,m,r)?.displayValue||"").trim()});if(h==="sex-header"){c=mn(f)||c,d=0;continue}if(h==="signature"||h==="helper")break;if(h!=="learner"){if(h==="blank"&&(d+=1),d>=5)break;continue}d=0;const b=rr(Be(t,m,o)?.displayValue),y=String(Be(t,m,r)?.displayValue||"").trim(),j=String(Be(t,m,n)?.displayValue||"").trim()||void 0,k=String(Be(t,m,i)?.displayValue||"").trim()||void 0,p=Ma.filter(N=>Se(f,N));!y&&b===void 0||l.push({learnerNo:b,sex:c,fullName:y||`Unnamed Learner ${b||m}`,sourceSheet:t.sheetName,sourceRow:m+1,remarks:j,additionalRemarks:k,statuses:p.length>0?p:void 0})}return l}function Lu(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const o=Es(t,r);if(o){if(Ma.some(n=>Se(o,n))){s.push(o);continue}(Se(o,"IMPORTANT")||Se(o,"NOTE")||Se(o,"ATTACHMENT")||Se(o,"LOOK UP"))&&a.push(o)}}return{attachmentRules:Array.from(new Set(s)),helperNotes:Array.from(new Set(a))}}function Du(t){const s=[],a={region:Jt(t,Ht.region),division:Jt(t,Ht.division),schoolName:Jt(t,Ht.schoolName),schoolId:Jt(t,Ht.schoolId),schoolYear:Jt(t,Ht.schoolYear),gradeSection:Jt(t,Ht.gradeSection),semester:Jt(t,Ht.semester),track:Jt(t,Ht.track),subjectCode:Jt(t,Ht.subjectCode),subjectName:Jt(t,Ht.subjectName),teacherName:Jt(t,Ht.teacherName)},r=zu(t),o=Au(t),{attachmentRules:n,helperNotes:i}=Lu(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."),dn(t,Object.values(Ht).flat()).length<4&&s.push("Input Data sheet contains limited metadata anchors; layout may have drifted."),{sheetName:t.sheetName,schoolContext:a,learners:r,signatures:o,attachmentRules:n,helperNotes:i,warnings:s}}function $u(t){const s=bt(t.sheetName);return fu.SECOND.some(a=>Se(s,a))?"SECOND":"FIRST"}function Fu(t,s){const a=[],r=[],o=[];let n,i="NONE";for(let l=t.startCol;l<=t.endCol;l+=1){const c=Be(t,s,l),d=bt(c?.displayValue||""),m=Be(t,s+1,l),f=String(m?.displayValue||c?.displayValue||"").trim();if(!d&&!f)continue;if(Se(d,De.writtenWork[0])){i="WW";continue}if(Se(d,De.performanceTasks[0])){i="PT";continue}if(Se(d,De.quarterlyAssessment[0])){n={key:Er(f||"quarterly_assessment"),label:f||"Quarterly Assessment",column:ha(l)},i="DERIVED";continue}if(Se(d,De.initialGrade[0])||Se(d,De.quarterlyGrade[0])||Se(d,De.remark[0])||Se(d,De.additionalRemarks[0])||Se(d,De.firstQuarter[0])||Se(d,De.secondQuarter[0])||Se(d,De.firstSemester[0])||Se(d,De.finalGrades[0])||Se(d,De.ps[0])||Se(d,De.ws[0])||Se(d,De.total[0])){i="DERIVED",o.push({key:Er(f||d),label:f||d,column:ha(l)});continue}const h={key:Er(f||d||ha(l)),label:f||d||ha(l),maxScore:Wa(m?.displayValue),column:ha(l)};i==="WW"?a.push(h):i==="PT"?r.push(h):i==="DERIVED"&&o.push(h)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:n,derived:o}}function Ou(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{const n=Be(t,o.row,o.col+1),i=String(n?.displayValue||"").trim()||void 0;a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Fo(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const o=bt(Be(t,s,r)?.displayValue||""),n=bt(Be(t,s+1,r)?.displayValue||"");if(a.some(i=>Se(o,i)||Se(n,i)))return r}}function Bu(t,s,a,r){const o={learnerNo:rr(Be(t,s,r.numberCol)?.displayValue),fullName:String(Be(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},n={};a.writtenWorks.forEach(d=>{const m=d.column?Ba(d.column):-1;if(m<0)return;const f=Be(t,s,m)?.displayValue;n[d.key]=f??null}),Object.keys(n).length>0&&(o.writtenWorks=n);const i={};if(a.performanceTasks.forEach(d=>{const m=d.column?Ba(d.column):-1;if(m<0)return;const f=Be(t,s,m)?.displayValue;i[d.key]=f??null}),Object.keys(i).length>0&&(o.performanceTasks=i),a.quarterlyAssessment?.column){const d=Ba(a.quarterlyAssessment.column);o.quarterlyAssessment=Be(t,s,d)?.displayValue??null}const l=a.derived||[],c={};return l.forEach(d=>{if(!d.column)return;const m=Ba(d.column);if(m<0)return;const f=Be(t,s,m)?.displayValue??null;c[d.key]=f,Se(d.label,De.initialGrade[0])&&(o.initialGrade=f),Se(d.label,De.quarterlyGrade[0])&&(o.quarterlyGrade=f),Se(d.label,De.firstQuarter[0])&&(o.firstQuarter=f),Se(d.label,De.secondQuarter[0])&&(o.secondQuarter=f),Se(d.label,De.firstSemester[0])&&(o.firstSemester=f),Se(d.label,De.finalGrades[0])&&(o.finalGrades=f),Se(d.label,De.remark[0])&&(o.remark=f!==null?String(f):null),Se(d.label,De.additionalRemarks[0])&&(o.additionalRemarks=f!==null?String(f):null)}),Object.keys(c).length>0&&(o.totals=c),o}function Pu(t){const s=$u(t),a=[],r=wt(t,De.learnerName[0])[0]||wt(t,De.learnerName[1])[0],o=r?rl(t,r.row,4):t.startRow,n=Fu(t,o),i=Fo(t,o,De.learnerNo)??t.startCol,l=Fo(t,o,De.learnerName)??Math.min(t.endCol,i+1),c=[];let d="UNKNOWN",m=0;for(let y=o+1;y<=t.endRow;y+=1){const j=Es(t,y),k=un({rowText:j,hasLearnerNumber:/\b\d{1,2}\b/.test(j),hasLearnerName:/[A-Z]{2,}/.test(j)});if(k==="sex-header"){d=mn(j)||d;continue}if(k==="signature"||k==="helper")break;if(k==="blank"){if(m+=1,m>=el)break;continue}if(k!=="learner")continue;m=0;const p=Bu(t,y,n,{numberCol:i,nameCol:l});if(p.sex=d,!p.fullName&&p.learnerNo===void 0)continue;const N=Ma.filter(I=>Se(j,I));N.length>0&&!p.additionalRemarks&&(p.additionalRemarks=N.join("; ")),!p.fullName&&p.learnerNo!==void 0&&(a.push(`Row ${y+1} has learner number ${p.learnerNo} but empty name.`),p.fullName=`Unnamed Learner ${p.learnerNo}`),c.push(p)}n.writtenWorks.length===0&&n.performanceTasks.length===0&&a.push(`No detailed assessment columns detected in ${t.sheetName}.`);const f=Wa(wt(t,"WRITTEN WORK %")[0]?.value||wt(t,"WRITTEN WORK")[0]?.value),h=Wa(wt(t,"PERFORMANCE TASKS %")[0]?.value||wt(t,"PERFORMANCE TASKS")[0]?.value),b=Wa(wt(t,"QUARTERLY ASSESSMENT %")[0]?.value||wt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:f,performanceTasks:h,quarterlyAssessment:b},assessmentColumns:n,learnerGrades:c,signatures:Ou(t),warnings:a}}function Hu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{a.push({role:r,name:String(Be(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Qu(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const o=Es(t,r);if(!o){if(a&&s.length>0)break;continue}if(Se(o,"WEIGHT OF COMPONENTS")){a=!0;continue}if(!a)continue;const n={sourceRow:r+1,raw:o};for(let i=t.startCol;i<=t.endCol;i+=1){const l=Be(t,r,i)?.displayValue;l==null||String(l).trim()===""||(n[`c${i}`]=l)}Object.keys(n).length>2&&s.push(n)}return s}function Gu(t){const s=[],a=[],r=[],o=[],n=[];return t.forEach(i=>{Hu(i).forEach(l=>a.push(l)),Qu(i).forEach(l=>r.push({...l,sourceSheet:i.sheetName}));for(let l=i.startRow;l<=i.endRow;l+=1){const c=Es(i,l);if(c){if(Ma.some(d=>Se(c,d))){o.push(`${i.sheetName}: ${c}`);continue}(Se(c,"HELPER")||Se(c,"LOOK UP")||Se(c,"IMPORTANT")||Se(c,"REFERENCE")||Se(c,"ATTACHMENT"))&&n.push(`${i.sheetName}: ${c}`)}}}),r.length===0&&s.push("No component weight rows were parsed from reference sheets."),{sheetName:t.map(i=>i.sheetName).join(", "),componentWeights:r,attachmentRules:Array.from(new Set(o)),helperNotes:Array.from(new Set(n)),signatures:a,warnings:s}}function Uu(t,s,a){const r=new Map,o=n=>{const i=`${bt(n.fullName)}|${n.learnerNo||""}|${n.sourceSheet}`,l=r.get(i);if(!l){r.set(i,n);return}const c=Array.from(new Set([...l.statuses||[],...n.statuses||[]]));r.set(i,{...l,...n,remarks:n.remarks||l.remarks,additionalRemarks:n.additionalRemarks||l.additionalRemarks,statuses:c.length>0?c:void 0})};return t.forEach(o),s.forEach(n=>{n.learnerGrades.forEach(i=>{o({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:n.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),a.forEach(n=>{n.learnerGrades.forEach(i=>{o({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:n.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),Array.from(r.values())}function Vu(t,s,a,r){const o=[...t.signatures,...s.flatMap(i=>i.signatures),...a.flatMap(i=>i.signatures),...r.signatures],n=new Map;return o.forEach(i=>{const l=`${bt(i.role)}|${bt(i.name||"")}|${i.sourceSheet}`;n.set(l,i)}),Array.from(n.values())}function Wu(t){const s=Uu(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:Zi,version:uu,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:Vu(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function qu(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 Yu(t){const s={ref:t["!ref"],merges:qu(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 Ku(t,s){const a=cc(s,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0,raw:!1}),r={},o={};return a.SheetNames.forEach(n=>{const i=a.Sheets[n];if(!i)return;const l=Yu(i);o[n]=l,r[n]=yu(n,l)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:o},matrices:r}}async function Xu(t){const s=await t.arrayBuffer();return Ku(t.name,s)}class Ju{state={};markRange(s,a,r){const o=s;this.state[o]||(this.state[o]={mappedAddresses:new Set,mappings:[]});for(let n=a.s.r;n<=a.e.r;n+=1)for(let i=a.s.c;i<=a.e.c;i+=1)this.state[o].mappedAddresses.add(`${n}:${i}`);this.state[o].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(o=>{const n=new Set,i=this.state[o.sheetName]?.mappedAddresses??new Set;for(let l=o.startRow;l<=o.endRow;l+=1)for(let c=o.startCol;c<=o.endCol;c+=1){const d=`${l}:${c}`;if(n.has(d)||i.has(d))continue;const m=Be(o,l,c);if(!(m&&m.displayValue!==null&&m.displayValue!==void 0&&String(m.displayValue).trim())){n.add(d);continue}const h=this.collectComponent(o,l,c,i,n);h&&r.push({sheetName:o.sheetName,range:Su(h),purposeGuess:a,raw2D:ku(o,h)})}}),r}collectComponent(s,a,r,o,n){const i=[{row:a,col:r}];let l=a,c=a,d=r,m=r,f=!1;for(;i.length>0;){const h=i.shift();if(!h)break;const b=`${h.row}:${h.col}`;if(n.has(b)||o.has(b))continue;n.add(b);const y=Be(s,h.row,h.col);y&&y.displayValue!==null&&y.displayValue!==void 0&&String(y.displayValue).trim()&&(f=!0,l=Math.min(l,h.row),c=Math.max(c,h.row),d=Math.min(d,h.col),m=Math.max(m,h.col),[{row:h.row-1,col:h.col},{row:h.row+1,col:h.col},{row:h.row,col:h.col-1},{row:h.row,col:h.col+1}].forEach(k=>{k.rows.endRow||k.cols.endCol||i.push(k)}))}return f?{s:{r:l,c:d},e:{r:c,c:m}}:null}}function Zu(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,o)=>r+o,0);return{totalSheets:t.totalSheets,recognizedSheets:a,unclassifiedSheets:s.other.length,mappedCellRegions:t.mappedCellRegions,unmappedCellRegions:t.unmappedCellRegions}}function ex(t){const s=new Map;t.forEach(r=>{const o=`${r.learnerNo||""}|${r.fullName.trim().toUpperCase()}`;s.has(o)||s.set(o,[]),s.get(o)?.push(r.sourceRow)});const a=[];return s.forEach((r,o)=>{r.length>1&&a.push(`Duplicate learner entry detected for ${o} at rows ${r.join(", ")}.`)}),a}function tx(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 o=r.writtenWorks&&Object.values(r.writtenWorks).some(i=>i!==null&&i!==""),n=r.performanceTasks&&Object.values(r.performanceTasks).some(i=>i!==null&&i!=="");!o&&!n&&r.quarterlyAssessment==null&&s.push(`${a.sheetName} row ${r.sourceRow}: all grade blocks are empty.`)})}),s}function sx(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 ax(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(", ")}.`),ex(t.inputData.learners).forEach(n=>s.push(n)),tx(t.quarterSheets).forEach(n=>s.push(n)),sx(t.finalSheets).forEach(n=>s.push(n)),s.push(...t.inputData.warnings),t.quarterSheets.forEach(n=>s.push(...n.warnings)),t.finalSheets.forEach(n=>s.push(...n.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,o=t.detection.isOfficialFormatLikely&&a.length===0;return r({fullName:i.fullName,learnerNo:i.learnerNo,sex:i.sex,remarks:i.remarks,additionalRemarks:i.additionalRemarks,statuses:i.statuses,sourceSheet:i.sourceSheet,sourceRow:i.sourceRow})),r=t.quarterlyRecords.flatMap(i=>i.learnerGrades.map(l=>({fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,quarter:i.quarter,firstQuarter:l.firstQuarter,secondQuarter:l.secondQuarter,firstSemester:l.firstSemester,finalGrades:l.finalGrades,quarterlyGrade:l.quarterlyGrade,initialGrade:l.initialGrade,remark:l.remark,additionalRemarks:l.additionalRemarks}))),o=t.finalSemestralRecords.flatMap(i=>i.learnerGrades.map(l=>({fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,firstQuarter:l.firstQuarter,secondQuarter:l.secondQuarter,firstSemester:l.firstSemester,finalGrades:l.finalGrades,remark:l.remark,additionalRemarks:l.additionalRemarks}))),n=[...t.learners,...t.quarterlyRecords.flatMap(i=>i.learnerGrades.map(l=>({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})))].map(i=>({fullName:i.fullName,remark:i.remarks||null,additionalRemarks:i.additionalRemarks||null,statuses:"statuses"in i?i.statuses:void 0,sourceSheet:i.sourceSheet,sourceRow:i.sourceRow}));return{classEntity:s,studentEntities:a,gradeEntities:[...r,...o],remarksEntities:n}}const Oo=1500;function Bo(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function Po(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>=Oo){console.warn(`${s} slow=true threshold=${Oo}ms`);return}}function As(t,s){t?.onProgress?.(s)}function nx(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 fa(t,s,a,r){nx(a,s).forEach(o=>{t.markRange(s.sheetName,{s:{r:o,c:s.startCol},e:{r:o,c:s.endCol}},r)})}async function ox(t,s){const a=s?.confidenceThreshold??mu,r=Date.now();let o=null;try{if(As(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),o=await Xu(t),!o)throw new Error("Workbook read returned null");As(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const n=Ru(o);As(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const i=n.detectedSheets.inputData||o.sheetNames[0],l=o.matrices[i],c=l?Du(l):{sheetName:i,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},m=[...n.detectedSheets.firstQuarter||[],...n.detectedSheets.secondQuarter||[]].map(I=>o.matrices[I]).filter(I=>!!I).map(I=>Pu(I)),f=(n.detectedSheets.finalSemestral||[]).map(I=>o.matrices[I]).filter(I=>!!I).map(I=>Mu(I)),h=[...n.detectedSheets.helper||[],...n.detectedSheets.lookup||[]].map(I=>o.matrices[I]).filter(I=>!!I),b=Gu(h),y=new Ju;n.anchorMatches.forEach(I=>{const A=o.matrices[I.sheetName];A&&fa(y,A,[I.row],`Anchor match: ${I.anchor}`)}),[c.sheetName].forEach(I=>{const A=o.matrices[I];if(!A)return;const C=Array.from({length:Math.min(14,A.rowCount)},(S,w)=>A.startRow+w),U=c.learners.map(S=>S.sourceRow-1),v=c.signatures.map(S=>S.sourceRow).filter(S=>typeof S=="number").map(S=>S-1);fa(y,A,[...C,...U,...v],"Input Data parsed rows")}),m.forEach(I=>{const A=o.matrices[I.sheetName];if(!A)return;const C=I.learnerGrades.map(S=>S.sourceRow-1),U=I.signatures.map(S=>S.sourceRow).filter(S=>typeof S=="number").map(S=>S-1),v=C.length>0?Math.max(A.startRow,Math.min(...C)-2):A.startRow;fa(y,A,[v,v+1,...C,...U],"Quarter sheet parsed rows")}),f.forEach(I=>{const A=o.matrices[I.sheetName];if(!A)return;const C=I.learnerGrades.map(S=>S.sourceRow-1),U=I.signatures.map(S=>S.sourceRow).filter(S=>typeof S=="number").map(S=>S-1),v=C.length>0?Math.max(A.startRow,Math.min(...C)-2):A.startRow;fa(y,A,[v,v+1,...C,...U],"Final semestral parsed rows")}),h.forEach(I=>{const A=b.componentWeights.filter(v=>v.sourceSheet===I.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1),C=b.signatures?.filter(v=>v.sourceSheet===I.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1)||[],U=A.length===0&&C.length===0?[I.startRow,I.startRow+1,I.startRow+2]:[];fa(y,I,[...A,...C,...U],"Reference/helper parsed rows")});const j=y.getUnmappedBlocks(o.matrices);As(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const k=ax({detection:n,inputData:c,quarterSheets:m,finalSheets:f,mappedCellRegions:y.getMappedRegionCount(),unmappedCellRegions:j.length,totalSheets:o.sheetNames.length});As(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const p=Wu({workbook:o,detection:n,inputData:c,quarterSheets:m,finalSheets:f,references:b,validation:k,unclassifiedBlocks:j});p.validation.confidenceg.trim().toLowerCase().replace(/\s+/g," "),ae=g=>{if(typeof g=="number"&&Number.isFinite(g))return g;const E=Number(String(g??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(E)?E:null},fe=(g,E)=>{const R=Number.isFinite(g)?g:E;return Math.max(0,Math.min(100,R))},pe=g=>{const E=String(g??"");return/[",\n]/.test(E)?`"${E.replace(/"/g,'""')}"`:E},P=(g,E)=>{const R=new Map,X=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];g.mapping.gradeEntities.forEach(te=>{const he=le(te.fullName||"");if(!he)return;const et=X.map(Ke=>ae(te[Ke])).filter(Ke=>Ke!==null);if(et.length===0)return;const Fe=R.get(he)||[];R.set(he,Fe.concat(et))});const J=g.mapping.studentEntities||[];if(J.length===0)return null;const ne=(g.imported.schoolContext.semester||g.imported.schoolContext.schoolYear||"First Semester").trim(),ce=(g.imported.schoolContext.subjectName||"Class Record Import").trim(),$=(t||s||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",xe=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(J.forEach((te,he)=>{const et=le(te.fullName||""),Fe=R.get(et)||[],Ke=Fe.length>0?Fe.reduce((Ye,vt)=>Ye+vt,0)/Fe.length:75,rt=fe(Ke,75),Rt=fe(rt+5,85),St=fe(rt*.7+Rt*.3,80),Ft=fe(Rt*.6+rt*.4,82),as=te.learnerNo||he+1,B=`IMP-${$}-${String(as).padStart(4,"0")}`,Ae=te.fullName||`Learner ${he+1}`;xe.push([pe(Ae),pe(B),pe(""),pe(Number(St.toFixed(1))),pe(Number(rt.toFixed(1))),pe(Number(Rt.toFixed(1))),pe(Number(Ft.toFixed(1))),pe(ne),pe(ce)].join(","))}),xe.length<=1)return null;const we=E.replace(/\.(xlsx|xls)$/i,"");return new File([xe.join(` +`)],`${we}-normalized.csv`,{type:"text/csv"})},Y=async g=>{v(!0),O(""),G(null);let E=g;if(/\.(xlsx|xls)$/i.test(g.name))try{const R=await ox(g,{confidenceThreshold:Gr});p(R);const X=P(R,g.name);X&&(E=X)}catch{p(null)}else p(null);try{const R=await nt.uploadClassRecords(E,{classSectionId:t,className:s,datasetIntent:"synthetic_student_records"}),X=R.students.length,ne=((ce,$,oe,xe)=>({classSectionId:ce.classSectionId||$||"imported_class",className:ce.className||oe||"Imported Class",classMetadata:ce.classMetadata||xe}))(R,t,s,a);X>0&&i?.({students:R.students,classSectionId:ne.classSectionId,className:ne.className,classMetadata:ne.classMetadata}),R.success?(me.success(`Successfully imported ${X} student records.`),G({datasetIntent:R.datasetIntent,summary:R.interpretationSummary,columns:R.columnInterpretations?.map(ce=>({columnName:ce.columnName,mappedField:ce.mappedField,usagePolicy:ce.usagePolicy,confidenceBand:ce.confidenceBand,domainSignals:ce.domainSignals}))||[]}),l?.()):me.error("Import completed but no usable student rows were detected. Check required columns and retry.")}catch(R){me.error(R instanceof Error?R.message:"Upload failed")}finally{v(!1)}},M=async g=>{w(!0);try{const E=await nt.uploadCourseMaterials(g,{classSectionId:t,className:s});if(E.success){const R=E.topics?.length??0;me.success(`Course material imported (${R} topics extracted).`),l?.()}}catch(E){me.error(E instanceof Error?E.message:"Course material upload failed")}finally{w(!1)}},[K,re]=u.useState(r),[$e,Me]=u.useState(!1);u.useEffect(()=>{re(r),H(Object.fromEntries(r.map(g=>[Pa(g),{grade:g.grade||"Grade 11",section:g.section||"Section A"}])))},[r]);const[Qe,H]=u.useState({}),ee=async()=>{Me(!0);try{for(const E of K){const R=Qe[Pa(E)],X=R?.grade||E.grade,J=R?.section||E.section;o&&(X!==E.grade||J!==E.section)&&(await mr(E.id,X,J,o,new Date().getFullYear().toString(),n),await Vi(E.id,X,J));try{const ne=await nt.predictRisk({engagementScore:E.engagementScore,avgQuizScore:E.avgScore,attendance:E.attendance,assignmentCompletion:E.assignmentCompletion});await jm(E.id,ne.riskLevel,ne.confidence)}catch(ne){console.error("Failed to update risk:",ne)}}const g=K.map(E=>{const R=Qe[Pa(E)];if(!R)return E;const X=gt({metadata:E.classMetadata,classSectionId:E.classSectionId,className:[R.grade,R.section].filter(Boolean).join(" - "),grade:R.grade,section:R.section});return{...E,grade:R.grade,section:R.section,className:X.className||[R.grade,R.section].filter(Boolean).join(" - "),classSectionId:X.classSectionId||E.classSectionId,classMetadata:X}});re(g),d?.(g),me.success("Records saved and risk levels updated"),j("main")}catch{me.error("Failed to save changes")}finally{Me(!1)}};return e.jsx("div",{className:"h-full overflow-y-auto w-full block",children:e.jsxs("div",{className:"w-full p-[24px] xl:p-[32px] space-y-[24px]",children:[y==="main"&&e.jsxs("div",{className:"block space-y-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[16px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-slate-200 flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-indigo-50 flex items-center justify-center border border-indigo-100/50",children:e.jsx(Ka,{className:"w-5 h-5 text-indigo-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[14px] font-bold text-[#1e293b]",children:"Upload Context"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Select where the imported data should be applied"})]})]}),e.jsxs("div",{className:"relative w-full md:w-[300px]",children:[e.jsxs("select",{className:"appearance-none bg-[#f8fafc] border border-[#e2e8f0] text-[#1e293b] font-bold text-[13px] rounded-lg pl-4 pr-10 py-2.5 outline-none focus:border-[#4f46e5] focus:ring-2 focus:ring-[#4f46e5]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer w-full transition-colors",value:s||t||"All Classes",onChange:()=>{},children:[e.jsx("option",{value:s||t||"All Classes",children:s||t?`${s} ${t?`(${t})`:""}`:"All Classes"}),e.jsx("option",{value:"Grade 11 - Section A",children:"Grade 11 - Section A"}),e.jsx("option",{value:"Grade 11 - Section B",children:"Grade 11 - Section B"})]}),e.jsx(Tt,{className:"w-4 h-4 text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{onDragOver:g=>{g.preventDefault(),I(!0)},onDragLeave:()=>I(!1),onDrop:g=>{g.preventDefault(),I(!1);const E=g.dataTransfer.files[0];E&&Y(E)},onClick:()=>q.current?.click(),className:`border-2 border-dashed transition-all rounded-[24px] p-8 flex flex-col items-center justify-center text-center cursor-pointer group shadow-[0_4px_20px_rgba(0,0,0,0.02)] relative overflow-hidden h-[280px] ${N?"border-[#1FA7E1] bg-[#1FA7E1]/10":"border-[#1FA7E1]/30 hover:border-[#1FA7E1] bg-white hover:bg-[#1FA7E1]/5"}`,children:[e.jsx("input",{ref:q,type:"file",accept:".csv,.xlsx,.xls",onChange:g=>{const E=g.target.files?.[0];E&&Y(E)},className:"hidden"}),e.jsx("div",{className:"w-16 h-16 rounded-full bg-[#1FA7E1]/10 flex items-center justify-center mb-4 group-hover:scale-110 transition-transform duration-300 shadow-sm border border-[#1FA7E1]/20",children:U?e.jsx("span",{className:"animate-spin text-[#1FA7E1]",children:"..."}):e.jsx(zc,{className:"w-8 h-8 text-[#1FA7E1]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:U?"Uploading...":"Class Records"}),e.jsx("p",{className:"text-[13px] text-[#64748b] max-w-sm mb-6",children:"Upload student grades, attendance logs, and quiz scores to power predictive analytics."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".csv"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".xlsx"})]})]}),e.jsxs("div",{onDragOver:g=>{g.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:g=>{g.preventDefault(),C(!1);const E=g.dataTransfer.files[0];E&&M(E)},onClick:()=>se.current?.click(),className:`border-2 border-dashed transition-all rounded-[24px] p-8 flex flex-col items-center justify-center text-center cursor-pointer group shadow-[0_4px_20px_rgba(0,0,0,0.02)] relative overflow-hidden h-[280px] ${A?"border-[#9956DE] bg-[#9956DE]/10":"border-[#9956DE]/30 hover:border-[#9956DE] bg-white hover:bg-[#9956DE]/5"}`,children:[e.jsx("input",{ref:se,type:"file",accept:".pdf,.docx,.txt",onChange:g=>{const E=g.target.files?.[0];E&&M(E)},className:"hidden"}),e.jsx("div",{className:"w-16 h-16 rounded-full bg-[#9956DE]/10 flex items-center justify-center mb-4 group-hover:scale-110 transition-transform duration-300 shadow-sm border border-[#9956DE]/20",children:S?e.jsx("span",{className:"animate-spin text-[#9956DE]",children:"..."}):e.jsx(bs,{className:"w-8 h-8 text-[#9956DE]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:S?"Uploading...":"Course Materials"}),e.jsx("p",{className:"text-[13px] text-[#64748b] max-w-sm mb-6",children:"Upload syllabus, lesson plans, and curriculum docs to ground AI lesson generation."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".pdf"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".docx"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".txt"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-sky-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx(Mc,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Smart Parsing"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"AI automatically understands varied spreadsheet formats and maps column names securely."})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-orange-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx(di,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Risk Prediction"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"Analyzes historical performance patterns across your data to predict at-risk students."})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-purple-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx($s,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Contextual AI"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"Maps curriculum topics to generate highly personalized remedial lesson paths."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white flex flex-col justify-between h-full",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[#1e293b] mb-4",children:"Data Health"}),e.jsxs("div",{className:"flex-1 bg-emerald-50/50 border border-emerald-100 rounded-[16px] p-6 flex flex-col items-center justify-center text-center transition-all duration-300 hover:bg-emerald-50 hover:shadow-md hover:border-emerald-200",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-100 flex items-center justify-center mb-3 text-emerald-600 transition-transform duration-300 hover:scale-110 hover:-translate-y-1",children:e.jsx(Wr,{className:"w-6 h-6"})}),e.jsx("h3",{className:"text-emerald-700 font-bold text-[15px] mb-1",children:"All Records Synced"}),e.jsx("p",{className:"text-emerald-600/80 text-[12px] max-w-[200px]",children:"AI parsing completed successfully with no anomalies detected."})]}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4",children:[e.jsxs("button",{onClick:()=>j("edit-records"),className:"w-full flex items-center justify-center gap-2 bg-[#1e293b] hover:bg-black text-white text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-transform hover:scale-[1.02]",children:[e.jsx(Ic,{className:"w-4 h-4"})," Edit Class Records"]}),e.jsx("button",{onClick:()=>j("mapping-logs"),className:"w-full flex items-center justify-center gap-2 bg-white text-[#475569] border border-slate-300 hover:bg-slate-50 text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-colors",children:"View Mapping Logs"})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[#1e293b]",children:"Recent Uploads"}),e.jsx("button",{onClick:()=>j("mapping-logs"),className:"text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors",children:"View All"})]}),e.jsxs("div",{className:"flex-1 space-y-[12px] overflow-y-auto no-scrollbar flex flex-col justify-center items-center h-[120px]",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-50 flex items-center justify-center mb-2 border border-slate-100",children:e.jsx(Nc,{className:"w-5 h-5 text-slate-300"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-500",children:"There are no recent uploads yet."})]})]})]})]}),y==="mapping-logs"&&e.jsxs("div",{className:"space-y-[16px]",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>j("main"),className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors w-max bg-white px-[18px] py-2 rounded-full shadow-sm border border-slate-200",children:[e.jsx(Xa,{className:"w-4 h-4"})," Back to Uploads"]})}),e.jsxs("div",{className:"bg-white rounded-[18px] border border-[#f1f5f9] overflow-hidden shadow-sm",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-slate-50 flex justify-between items-center",children:e.jsx("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Latest Import Mapping"})}),e.jsx("div",{className:"p-5",children:T?e.jsx("div",{className:"space-y-3",children:T.columns.map((g,E)=>e.jsxs("div",{className:"flex justify-between p-3 border rounded bg-slate-50",children:[e.jsx("span",{className:"font-semibold text-sm",children:g.columnName}),e.jsx("span",{className:"text-sm text-indigo-600",children:g.mappedField||"Unmapped"})]},E))}):e.jsx("p",{className:"text-slate-500 text-sm",children:"No recent mapping logs to display."})})]})]}),y==="edit-records"&&e.jsxs("div",{className:"space-y-[16px] h-full flex flex-col",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>j("main"),className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors w-max bg-white px-[18px] py-2 rounded-full shadow-sm border border-slate-200",children:[e.jsx(Xa,{className:"w-4 h-4"})," Back to Uploads"]})}),e.jsxs("div",{className:"bg-white rounded-[18px] border border-slate-200 shadow-sm overflow-hidden flex flex-col flex-1",children:[e.jsxs("div",{className:"p-5 border-b border-slate-200 flex justify-between items-center bg-white",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[18px] font-bold text-[#1e293b]",children:"Edit Class Records"}),e.jsx("p",{className:"text-[13px] text-[#64748b]",children:"Review and modify student data manually"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>j("main"),className:"px-5 py-2 rounded-full border border-slate-300 text-slate-700 font-semibold text-[13px] hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:ee,disabled:$e,className:"px-5 py-2 rounded-full bg-emerald-500 text-white font-semibold text-[13px] hover:bg-emerald-600 flex items-center gap-2 disabled:opacity-50",children:$e?"Saving...":e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"w-4 h-4"})," Save Changes"]})})]})]}),e.jsxs("div",{className:"px-5 py-3 border-b border-slate-200 flex justify-between items-center bg-slate-50/50 shrink-0 text-slate-500 text-[13px]",children:[e.jsxs("span",{className:"flex items-center gap-2 font-medium",children:[e.jsx(ga,{className:"w-4 h-4"})," Click on any field to edit"]}),e.jsxs("span",{children:["Showing ",K.length," records"]})]}),e.jsx("div",{className:"overflow-auto flex-1 table-scrollbar bg-white relative",children:e.jsxs("div",{className:"min-w-[1100px] w-full flex flex-col min-h-full",children:[e.jsxs("div",{className:"flex items-center w-full bg-slate-100/90 border-b border-slate-200 text-[12px] font-semibold text-slate-500 tracking-wide sticky top-0 z-20 shadow-[0_1px_2px_rgba(0,0,0,0.02)] h-12",children:[e.jsx("div",{className:"flex-[1.5] min-w-[240px] px-6 sticky left-0 z-30 bg-slate-100/90 backdrop-blur-sm border-r border-slate-200 h-full flex items-center shadow-[2px_0_4px_rgba(0,0,0,0.02)]",children:"Student Name"}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 h-full flex items-center justify-center",children:"LRN"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 h-full flex items-center justify-center",children:"Grade"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 h-full flex items-center justify-center",children:"Section"}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 h-full flex items-center justify-center",children:"Avg Score"}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 h-full flex items-center justify-center",children:"Risk Level"}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 h-full flex items-center justify-center",children:"Weakest Topic"}),e.jsx("div",{className:"w-[80px] shrink-0 px-4 h-full flex items-center justify-center border-r border-transparent",children:"Action"})]}),e.jsx("div",{className:"flex flex-col w-full pb-4",children:K.map((g,E)=>{const R=Pa(g),X=g.name.split(" "),J=X.length>1?`${X[0][0]}${X[X.length-1][0]}`.toUpperCase():g.name.substring(0,2).toUpperCase(),ne=["bg-[#be185d]","bg-[#3b82f6]","bg-[#f43f5e]","bg-[#2563eb]","bg-[#059669]","bg-[#d946ef]"],ce=ne[E%ne.length],$=(g.avgScore??0)>=75?"text-emerald-500":(g.avgScore??0)>=60?"text-orange-500":"text-rose-500";let oe="bg-slate-50 text-slate-600 border-slate-200";const xe=(g.riskLevel||"").toLowerCase();return xe==="low"?oe="bg-emerald-50 text-emerald-600 border-emerald-200":xe==="high"?oe="bg-rose-50 text-rose-600 border-rose-200":xe==="medium"&&(oe="bg-orange-50 text-orange-600 border-orange-200"),e.jsxs("div",{className:"flex items-center w-full border-b border-slate-100 hover:bg-slate-50 transition-colors group min-h-[64px]",children:[e.jsxs("div",{className:"flex-[1.5] min-w-[240px] px-6 sticky left-0 z-10 bg-white group-hover:bg-slate-50 border-r border-slate-100 h-full flex items-center gap-4 shadow-[2px_0_4px_rgba(0,0,0,0.01)]",children:[e.jsx("div",{className:`w-8 h-8 rounded-full ${ce} text-white flex items-center justify-center font-bold text-[12px] shrink-0`,children:J}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:g.name})]}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center text-[13px] text-slate-500",children:g.lrn||"—"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Qe[R]?.grade||g.grade||"",onChange:we=>H(te=>({...te,[R]:{...te[R],grade:we.target.value}})),className:"bg-slate-100 focus:bg-white outline-none px-4 py-1.5 rounded-full text-[13px] font-medium text-slate-600 w-full transition-all border border-transparent focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 text-center"})}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Qe[R]?.section||g.section||"",onChange:we=>H(te=>({...te,[R]:{...te[R],section:we.target.value}})),className:"bg-slate-100 focus:bg-white outline-none px-4 py-1.5 rounded-full text-[13px] font-medium text-slate-600 w-full transition-all border border-transparent focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 text-center"})}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center",children:e.jsxs("span",{className:`${$} font-bold text-[14px]`,children:[g.avgScore,"%"]})}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:`px-3 py-1 text-[10px] font-bold rounded uppercase border ${oe}`,children:g.riskLevel||"Unknown"})}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 flex justify-center text-[13px] text-slate-600 truncate",children:g.weakestTopic||"Foundational Skills"}),e.jsx("div",{className:"w-[80px] shrink-0 px-4 flex justify-center border-r border-transparent",children:e.jsx("button",{className:"w-8 h-8 rounded-full hover:bg-slate-200 flex items-center justify-center transition-colors",children:e.jsx(ci,{className:"w-4 h-4 text-slate-400"})})})]},R)})})]})})]})]})]})})}const Ha="ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789",Qo="school.mathpulse.local";function Go(t=10){const s=typeof globalThis<"u"&&typeof globalThis.crypto<"u"?globalThis.crypto:void 0;if(s&&typeof s.getRandomValues=="function"){const r=new Uint32Array(t);s.getRandomValues(r);let o="";for(let n=0;n{const[l,c]=u.useState(""),[d,m]=u.useState(""),[f,h]=u.useState(!1),[b,y]=u.useState(null),[j,k]=u.useState(null),[p,N]=u.useState(!1);u.useEffect(()=>{t&&(y(null),N(!1),h(!1),k(null),c((a?.email||lx(a)).trim()),m(Go()))},[t,a]);const I=u.useMemo(()=>a?[a.grade,a.section].filter(Boolean).join(" · ")||"Unassigned section":null,[a]),A=()=>{m(Go()),N(!1)},C=async()=>{try{const S=j?.temporaryPassword||d;if(!S)return;typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(S),N(!0),me.success("Temporary password copied. Share it with the student now — it will not be shown again."),window.setTimeout(()=>N(!1),2500)}catch(S){console.warn("Clipboard write failed:",S),me.error("Unable to copy password. Please copy it manually.")}},U=async()=>{if(!a)return;const S=l.trim();if(!cx(S)){y("Enter a valid email address before creating the account.");return}if(!d||d.length<8){y("Temporary password must be at least 8 characters.");return}if(!r){y("Missing teacher context. Please refresh and try again.");return}h(!0),y(null);try{const w=await Nm({name:a.name,lrn:a.lrn,email:S,grade:a.grade,section:a.section,classSectionId:a.classSectionId,adviserTeacherId:r,adviserTeacherName:o,schoolYear:n,temporaryPassword:d});k(w),i?.({...w,rosterId:a.rosterId}),me.success(`Account created for ${a.name}.`)}catch(w){const z=w instanceof Error?w.message:"Failed to create account.";y(z)}finally{h(!1)}},v=j?.temporaryPassword||d;return e.jsx(Et,{children:t&&a&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",onClick:()=>{f||s()},children:e.jsxs(Re.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{type:"spring",damping:28,stiffness:320},onClick:S=>S.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl w-full max-w-lg overflow-hidden border border-[#dde3eb]",role:"dialog","aria-modal":"true","aria-labelledby":"create-student-account-modal-title",children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-6",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0",children:e.jsx(Ko,{size:22})}),e.jsxs("div",{children:[e.jsx("h2",{id:"create-student-account-modal-title",className:"text-[16px] font-bold text-[#0a1628]",children:j?"Account Created":"Create Student Account"}),e.jsx("p",{className:"text-[12px] text-[#5a6578] mt-0.5",children:j?"Share these credentials with the student. The password will not be shown again.":`Provision a system account for ${a.name}.`})]})]}),e.jsx("button",{type:"button",onClick:()=>{f||s()},className:"p-1.5 rounded-lg hover:bg-[#dde3eb] transition-colors","aria-label":"Close",children:e.jsx(cs,{className:"w-4 h-4 text-[#5a6578]"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-2xl p-4",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-[#64748b]",children:"Roster Row"}),e.jsx("p",{className:"text-[14px] font-semibold text-[#0a1628] mt-1",children:a.name}),e.jsxs("p",{className:"text-[12px] text-[#475569] mt-0.5",children:[a.lrn?`LRN ${a.lrn} · `:"",I]})]}),!j&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#0a1628]",children:"Email address"}),e.jsx("input",{type:"email",value:l,onChange:S=>c(S.target.value),disabled:f,className:"mt-1 w-full rounded-xl border border-[#dde3eb] bg-white px-3 py-2 text-[13px] text-[#0a1628] focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"student@school.example",autoComplete:"off",spellCheck:!1}),e.jsx("span",{className:"text-[11px] text-[#64748b] mt-1 block",children:"Auto-generated from LRN if available. The student will sign in with this address."})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#0a1628] block",children:"Temporary password"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:d,readOnly:!0,className:"flex-1 rounded-xl border border-[#dde3eb] bg-white px-3 py-2 text-[13px] font-mono tracking-wide text-[#0a1628] focus:outline-none"}),e.jsx("button",{type:"button",onClick:A,disabled:f,className:"p-2 rounded-xl border border-[#dde3eb] bg-white hover:bg-[#f1f5f9] transition-colors disabled:opacity-60","aria-label":"Regenerate temporary password",children:e.jsx(zs,{className:"w-4 h-4 text-[#475569]"})}),e.jsx("button",{type:"button",onClick:C,className:"p-2 rounded-xl border border-[#dde3eb] bg-white hover:bg-[#f1f5f9] transition-colors","aria-label":"Copy temporary password",children:p?e.jsx(Mt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(zr,{className:"w-4 h-4 text-[#475569]"})})]}),e.jsx("span",{className:"text-[11px] text-[#64748b] mt-1 block",children:"The student should change this on first sign-in. Share it once — it will not be persisted."})]}),b&&e.jsxs("div",{className:"flex items-start gap-2 rounded-xl bg-rose-50 border border-rose-200 px-3 py-2 text-[12px] text-rose-700",children:[e.jsx(lc,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsx("span",{children:b})]})]}),j&&e.jsxs("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-4 space-y-2",children:[e.jsx("p",{className:"text-[12px] font-semibold text-emerald-800",children:"Credentials"}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-white border border-emerald-100 px-3 py-2",children:[e.jsx("span",{className:"text-[12px] text-[#475569]",children:"Email"}),e.jsx("span",{className:"text-[13px] font-semibold text-[#0a1628]",children:j.email})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-white border border-emerald-100 px-3 py-2",children:[e.jsx("span",{className:"text-[12px] text-[#475569]",children:"Temporary password"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold font-mono text-[#0a1628]",children:v}),e.jsx("button",{type:"button",onClick:C,className:"p-1.5 rounded-lg border border-emerald-200 bg-white hover:bg-emerald-100 transition-colors","aria-label":"Copy temporary password",children:p?e.jsx(Mt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(zr,{className:"w-4 h-4 text-emerald-700"})})]})]}),e.jsx("p",{className:"text-[11px] text-emerald-800",children:"This password is not stored anywhere. If you close this dialog without copying, you will need to reset it from the admin tools."})]})]}),e.jsx("div",{className:"flex items-center justify-end gap-2 px-6 pb-6",children:j?e.jsx(pt,{type:"button",onClick:s,className:"bg-indigo-600 hover:bg-indigo-700 text-white text-[13px] font-semibold rounded-xl px-5 py-2",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{type:"button",variant:"ghost",onClick:s,disabled:f,className:"text-[13px] font-semibold text-[#475569] rounded-xl px-4 py-2 hover:bg-[#dde3eb]",children:"Cancel"}),e.jsx(pt,{type:"button",onClick:U,disabled:f,className:"bg-indigo-600 hover:bg-indigo-700 text-white text-[13px] font-semibold rounded-xl px-5 py-2 disabled:opacity-60",children:f?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Creating…"]}):"Create account"})]})})]})})})};function mx(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=gt({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 Rr(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?nl(t.lastActive.toDate()):"Unknown",o=t.className||s||"Imported Class",n=ls(o),i=t.grade||n.grade,l=t.section||n.section,c=gt({metadata:t.classMetadata,classSectionId:t.classSectionId||t.classroomId,className:[i,l].filter(Boolean).join(" - ")||o,grade:i,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:l,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||o,className:c.className||[i,l].filter(Boolean).join(" - ")||o,grade:i,gradeLevel:c.gradeLevel||us(i)||void 0,classification:c.classification||sa(c.gradeLevel||i)||void 0,strand:c.strand||aa(c.className,l)||void 0,section:l,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,hasRegisteredAccount:t.hasRegisteredAccount,source:t.source,accountUid:t.accountUid,email:t.email}}function ux(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=gt({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 xx(t){const s=(t.riskLevel||"Low").toLowerCase(),a=gt({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||ls(r).grade,gradeLevel:a.gradeLevel||us(a.grade||ls(r).grade)||void 0,classification:a.classification||sa(a.gradeLevel||a.grade)||void 0,strand:a.strand||aa(r,a.section||t.section)||void 0,section:a.section||ls(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 px(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function hx(t,s,a,r){const o=gt({metadata:r,classSectionId:s,className:a}),n=o.className||"Imported Class",i=o.classSectionId||"imported_class",l=Number(t.avgQuizScore||0),c=Number(t.attendance||0),d=Number(t.engagementScore||0),m=Number(t.assignmentCompletion||0),f=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",h=px(l,c,d),b=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${i}-${b}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:l,riskLevel:h,weakestTopic:f,classroomId:i,className:n,grade:o.grade||ls(n).grade,gradeLevel:o.gradeLevel||us(o.grade||ls(n).grade)||void 0,classification:o.classification||sa(o.gradeLevel||o.grade)||void 0,strand:o.strand||aa(n,o.section)||void 0,section:o.section||ls(n).section,classSectionId:i,classMetadata:o,managerId:o.managerId||void 0,managerName:o.managerName||void 0,lastActive:"Recently imported",struggles:[f],engagementScore:d,attendance:c,assignmentCompletion:m}}function nl(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 o=Math.floor(r/24);return`${o} day${o>1?"s":""} ago`}function at(t){return(t||"").trim().toLowerCase()}function Uo(t){const s=at(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function Vo(t,s){const a=new Map;return t.forEach(r=>{a.set(Uo(r),r)}),s.forEach(r=>{const o=Uo(r),n=a.get(o);if(!n){a.set(o,r);return}const i=Math.max(n.atRiskCount||0,r.atRiskCount||0),l=Math.max(n.studentCount||0,r.studentCount||0),c=r.avgScore>0?r.avgScore:n.avgScore,d=i>=5?"high":i>=2?"medium":"low",m=gt({metadata:n.classMetadata,classSectionId:n.classSectionId||r.classSectionId,className:n.name||r.name,grade:n.classMetadata?.grade||r.classMetadata?.grade,gradeLevel:n.classMetadata?.gradeLevel||r.classMetadata?.gradeLevel,classification:n.classMetadata?.classification||r.classMetadata?.classification,strand:n.classMetadata?.strand||r.classMetadata?.strand,section:n.classMetadata?.section||r.classMetadata?.section,schoolYear:n.classMetadata?.schoolYear||r.classMetadata?.schoolYear,ownerTeacherId:n.classMetadata?.ownerTeacherId||r.classMetadata?.ownerTeacherId,ownerTeacherName:n.classMetadata?.ownerTeacherName||r.classMetadata?.ownerTeacherName,adviserTeacherId:n.classMetadata?.adviserTeacherId||r.classMetadata?.adviserTeacherId,adviserTeacherName:n.classMetadata?.adviserTeacherName||r.classMetadata?.adviserTeacherName,managerId:n.classMetadata?.managerId||r.classMetadata?.managerId,managerName:n.classMetadata?.managerName||r.classMetadata?.managerName});a.set(o,{...n,classSectionId:m.classSectionId||n.classSectionId||r.classSectionId,name:m.className||n.name||r.name,classMetadata:m,gradeLevel:m.gradeLevel||void 0,classification:m.classification||void 0,strand:m.strand||void 0,managerId:m.managerId||void 0,managerName:m.managerName||void 0,schedule:n.schedule||r.schedule,studentCount:l,atRiskCount:i,avgScore:c,riskLevel:d})}),Array.from(a.values())}function nr(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=at(t.classSectionId)||at(t.classroomId),o=(t.id||"").trim().toLowerCase();return r&&o?`${r}|id:${o}`:`${r}|anonymous`}function Ur(t){const s=at(t.classSectionId)||at(t.classroomId),a=(t.lrn||"").trim().toLowerCase(),r=(t.id||"").trim().toLowerCase(),o=t.name.trim().toLowerCase().replace(/\s+/g,"_");return s&&a?`${s}|lrn:${a}`:s&&r?`${s}|id:${r}`:a?`lrn:${a}`:r&&o?`id:${r}|name:${o}`:r?`id:${r}`:s&&o?`${s}|name:${o}`:`name:${o||"unknown"}`}function Wo(t,s){const a=new Map;return t.forEach(r=>{a.set(nr(r),r)}),s.forEach(r=>{const o=nr(r),n=a.get(o);if(!n){a.set(o,r);return}const i=[n.riskLevel,r.riskLevel].includes("high")?"high":[n.riskLevel,r.riskLevel].includes("medium")?"medium":"low",l=gt({metadata:n.classMetadata,classSectionId:n.classSectionId||r.classSectionId,className:n.className||r.className,grade:n.grade||r.grade,gradeLevel:n.gradeLevel||r.gradeLevel,classification:n.classification||r.classification,strand:n.strand||r.strand,section:n.section||r.section,managerId:n.managerId||r.managerId,managerName:n.managerName||r.managerName});a.set(o,{...n,lrn:n.lrn||r.lrn,classSectionId:l.classSectionId||n.classSectionId||r.classSectionId,classroomId:n.classroomId||r.classroomId,className:l.className||n.className||r.className,grade:l.grade||n.grade||r.grade,gradeLevel:l.gradeLevel||n.gradeLevel||r.gradeLevel,classification:l.classification||n.classification||r.classification,strand:l.strand||n.strand||r.strand,section:l.section||n.section||r.section,managerId:l.managerId||n.managerId||r.managerId,managerName:l.managerName||n.managerName||r.managerName,classMetadata:l,avgScore:r.avgScore>0?r.avgScore:n.avgScore,attendance:r.attendance>0?r.attendance:n.attendance,engagementScore:r.engagementScore>0?r.engagementScore:n.engagementScore,assignmentCompletion:r.assignmentCompletion>0?r.assignmentCompletion:n.assignmentCompletion,weakestTopic:n.weakestTopic&&n.weakestTopic!=="N/A"?n.weakestTopic:r.weakestTopic,riskLevel:i,struggles:n.struggles.length>0?n.struggles:r.struggles,hasRegisteredAccount:n.hasRegisteredAccount===!0||r.hasRegisteredAccount===!0?!0:n.hasRegisteredAccount??r.hasRegisteredAccount,source:n.source==="registered"&&r.source==="import"||n.source==="import"&&r.source==="registered"||n.source==="both"||r.source==="both"?"both":n.source||r.source,accountUid:n.accountUid||r.accountUid,email:n.email||r.email})}),Array.from(a.values())}const bp=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:o}=ds(),[n,i]=u.useState("dashboard"),[l,c]=u.useState(!1),[d,m]=u.useState(!1),[f,h]=u.useState(!1),[b,y]=u.useState(!1),[j,k]=u.useState(!1),[p,N]=u.useState(!1),[I,A]=u.useState(!1),C=["streak_reminder","daily_checkin","streak_milestone","achievement_unlocked","level_up","xp_earned","quiz_result"],{notifications:U}=ei(),v=U.filter(_=>!_.isRead&&!C.includes(_.type)).length,[S,w]=u.useState(null),[z,O]=u.useState(null),[T,G]=u.useState(!1),[q,se]=u.useState(!1),[le,ae]=u.useState(!1),[fe,pe]=u.useState(!1),[P,Y]=u.useState([]),[M,K]=u.useState([]),[re,$e]=u.useState([]),[Me,Qe]=u.useState(""),[H,ee]=u.useState(!0),[g,E]=u.useState(!1),[R,X]=u.useState(0),[J,ne]=u.useState([]),[ce,$]=u.useState(!1),[oe,xe]=u.useState(null),[we,te]=u.useState(null),he=o?.name||"Teacher",et=u.useRef(new Map);u.useEffect(()=>{const _=()=>y(window.innerWidth<1024);return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),u.useEffect(()=>{if(!r)return;const _=r.uid;let Z=!0,ze;return(async()=>{ee(!0);try{const Ge=await Wi(_);let je=Ge.map(mx);const ft=await Sm(_).catch(()=>[]),it=new Map;ft.forEach(L=>{const V=at(L.classSectionId);V&&it.set(V,L)}),je=je.map(L=>{const V=it.get(at(L.classSectionId));if(!V)return L;const ke=gt({metadata:L.classMetadata,classSectionId:V.classSectionId||L.classSectionId,className:V.className||L.name,grade:V.grade||L.classMetadata?.grade,gradeLevel:V.gradeLevel||L.classMetadata?.gradeLevel,classification:V.classification||L.classMetadata?.classification,strand:V.strand||L.classMetadata?.strand,section:V.section||L.classMetadata?.section,schoolYear:V.schoolYear||L.classMetadata?.schoolYear,ownerTeacherId:V.ownerTeacherId||L.classMetadata?.ownerTeacherId,ownerTeacherName:V.ownerTeacherName||L.classMetadata?.ownerTeacherName,managerId:V.managerId||L.classMetadata?.managerId,managerName:V.managerName||L.classMetadata?.managerName});return{...L,name:ke.className||L.name,classSectionId:ke.classSectionId||L.classSectionId,classMetadata:ke,gradeLevel:ke.gradeLevel||L.gradeLevel,classification:ke.classification||L.classification,strand:ke.strand||L.strand,managerId:ke.managerId||L.managerId,managerName:ke.managerName||L.managerName}});const Ce=new Map,ps=new Map;Ge.forEach(L=>{const V=gt({metadata:L.classMetadata,classSectionId:L.classSectionId,className:L.name,grade:L.grade,gradeLevel:L.gradeLevel,classification:L.classification,strand:L.strand,section:L.section,schoolYear:L.schoolYear,ownerTeacherId:L.ownerTeacherId||L.teacherId,ownerTeacherName:L.ownerTeacherName,adviserTeacherId:L.adviserTeacherId||L.teacherId,adviserTeacherName:L.adviserTeacherName,managerId:L.managerId,managerName:L.managerName});Ce.set(L.id,V.className||L.name),ps.set(L.id,V);const ke=at(L.classSectionId);if(ke){const _e=it.get(ke),Bt=gt({metadata:V,classSectionId:_e?.classSectionId||ke,className:_e?.className||V.className,grade:_e?.grade||V.grade,gradeLevel:_e?.gradeLevel||V.gradeLevel,classification:_e?.classification||V.classification,strand:_e?.strand||V.strand,section:_e?.section||V.section,schoolYear:_e?.schoolYear||V.schoolYear,ownerTeacherId:_e?.ownerTeacherId||V.ownerTeacherId,ownerTeacherName:_e?.ownerTeacherName||V.ownerTeacherName,managerId:_e?.managerId||V.managerId,managerName:_e?.managerName||V.managerName});Ce.set(ke,Bt.className||L.name),ps.set(ke,Bt)}});const Yt=L=>{const V=at(L.classSectionId||L.classroomId);if(!V)return L;const ke=ps.get(V);if(!ke)return L;const _e=gt({metadata:ke,classSectionId:L.classSectionId||ke.classSectionId,className:L.className||ke.className,grade:L.grade||ke.grade,gradeLevel:L.gradeLevel||ke.gradeLevel,classification:L.classification||ke.classification,strand:L.strand||ke.strand,section:L.section||ke.section,managerId:L.managerId||ke.managerId,managerName:L.managerName||ke.managerName});return{...L,className:_e.className||L.className,grade:_e.grade||L.grade,gradeLevel:_e.gradeLevel||L.gradeLevel,classification:_e.classification||L.classification,strand:_e.strand||L.strand,section:_e.section||L.section,classSectionId:_e.classSectionId||L.classSectionId,classMetadata:_e,managerId:_e.managerId||L.managerId,managerName:_e.managerName||L.managerName}},_s=(L,V,ke)=>Ce.get(L)||(V?Ce.get(V):void 0)||ke||"Unknown",za=Array.from(new Set([...ft.map(L=>L.classSectionId),...Ge.map(L=>L.classSectionId).filter(Boolean),...je.map(L=>L.classSectionId).filter(Boolean)].map(L=>(L||"").trim()).filter(L=>!!L))),[Kt,ra]=await Promise.all([cn(_).catch(L=>(console.warn("[TeacherDashboard] managed-student fetch failed:",L),[])),bm(_,za).catch(L=>(console.warn("[TeacherDashboard] registered-student fetch failed:",L),[]))]);let na=ra;if(ra.length===0&&Kt.length===0)try{const{collection:L,query:V,where:ke,getDocs:_e}=await _r(async()=>{const{collection:It,query:Pe,where:da,getDocs:ma}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{collection:It,query:Pe,where:da,getDocs:ma}},__vite__mapDeps([2,3])),{db:Bt}=await _r(async()=>{const{db:It}=await import("./index-CGNBpSmO.js").then(Pe=>Pe.b5);return{db:It}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),Ee=V(L(Bt,"users"),ke("role","==","student"));na=(await _e(Ee)).docs.map(It=>{const Pe=It.data();return{uid:It.id,name:String(Pe.name||Pe.displayName||"").trim()||"Student",email:String(Pe.email||"").trim(),lrn:Pe.lrn?String(Pe.lrn).trim():void 0,photo:Pe.photo?String(Pe.photo).trim():Pe.photoURL?String(Pe.photoURL).trim():void 0,grade:Pe.grade?String(Pe.grade).trim():void 0,section:Pe.section?String(Pe.section).trim():void 0,classSectionId:Pe.classSectionId?String(Pe.classSectionId).trim():void 0,adviserTeacherId:Pe.adviserTeacherId?String(Pe.adviserTeacherId).trim():void 0,role:"student",createdAt:Pe.createdAt||void 0}}).filter(It=>It.name!=="Student"||It.email)}catch(L){console.warn("[TeacherDashboard] fallback all-students fetch failed:",L)}const hs=new Map,oa=new Map,ia=new Map;Kt.forEach(L=>{hs.set(L.id,L),L.lrn&&oa.set(L.lrn.trim().toLowerCase(),L);const V=wo(L.name),ke=at(L.classSectionId||L.classroomId);V&&ia.set(`${V}|${ke}`,L)});const Hs=new Set,ur=na.map(L=>{const V=vm(L),ke=(L.lrn||"").trim().toLowerCase(),_e=wo(L.name),Bt=at(L.classSectionId);let Ee;if(hs.has(L.uid))Ee=hs.get(L.uid);else if(ke&&oa.has(ke))Ee=oa.get(ke);else if(_e){const Pe=`${_e}|${Bt}`;Ee=ia.get(Pe)}if(Ee){Hs.add(Ee.id);const Pe={...V,id:L.uid,accountUid:L.uid,email:V.email||Ee.email,lrn:V.lrn||Ee.lrn,name:V.name||Ee.name,avatar:V.avatar||Ee.avatar,riskLevel:Ee.riskLevel||V.riskLevel,avgQuizScore:Ee.avgQuizScore||V.avgQuizScore,engagementScore:Ee.engagementScore||V.engagementScore,attendance:Ee.attendance||V.attendance,assignmentCompletion:Ee.assignmentCompletion||V.assignmentCompletion,weakestTopic:Ee.weakestTopic||V.weakestTopic,struggles:Ee.struggles||V.struggles,lastActive:Ee.lastActive||V.lastActive,wri:Ee.wri??null,riskStatus:Ee.riskStatus??null,riskUpdatedAt:Ee.riskUpdatedAt??null,diagnosticScore:Ee.diagnosticScore??null,externalGradesAvg:Ee.externalGradesAvg??null,systemPerformanceAvg:Ee.systemPerformanceAvg??null,riskHistory:Ee.riskHistory,grade:V.grade||Ee.grade,gradeLevel:V.gradeLevel||Ee.gradeLevel,section:V.section||Ee.section,classSectionId:V.classSectionId||Ee.classSectionId,classroomId:V.classroomId||Ee.classroomId,classMetadata:Ee.classMetadata||V.classMetadata,hasRegisteredAccount:!0,source:"both"},da=at(Pe.classSectionId||Pe.classroomId),ma=_s(Pe.classroomId||"",da,Pe.className);return Yt(Rr(Pe,ma))}const Qs=at(V.classSectionId||V.classroomId),It=_s(V.classroomId||"",Qs,V.className);return Yt(Rr(V,It))}),xr=Kt.filter(L=>!Hs.has(L.id)).map(L=>{const V={...L,hasRegisteredAccount:!1,source:"import"},ke=at(V.classSectionId||V.classroomId),_e=_s(V.classroomId,ke,V.className);return Yt(Rr(V,_e))}),la=[...ur,...xr];if(!Z)return;Y(L=>je.length===0&&L.length>0?L:je),K(L=>la.length===0&&L.length>0?L:la),nt.getImportedClassOverview({limit:3e3,forceRefresh:R>0}).then(L=>{Z&&(L.warnings.length>0&&console.warn("Imported class overview warnings:",L.warnings.join(" ")),Y(V=>Vo(V,L.classrooms.map(ux))),K(V=>{if(V.length===0)return V;const ke=L.students.map(xx),_e=new Set;V.forEach(Ee=>_e.add(nr(Ee)));const Bt=ke.filter(Ee=>_e.has(nr(Ee)));return Bt.length===0?V:Wo(V,Bt)}))}).catch(L=>{console.warn("Imported class overview merge unavailable:",L)});const ca=Ge.map(L=>L.id);ca.length>0&&(ze=Cm(ca,L=>{Z&&$e(L.map(V=>({id:V.id,student:V.studentName,action:V.action,topic:V.topic,time:nl(V.timestamp.toDate()),type:V.type})))}))}catch(Ge){console.error("Failed to load teacher data:",Ge),me.error("Failed to load dashboard data")}finally{ee(!1)}})(),()=>{Z=!1,ze&&ze()}},[r,R]),u.useEffect(()=>{if(!r)return;let _=!0;return km("",80).then(Z=>{_&&ne(Z)}).catch(Z=>{console.warn("Failed to load teacher directory options:",Z)}),()=>{_=!1}},[r]),u.useEffect(()=>{if(M.length===0)return;(async()=>{if(M.length===0){Qe("");return}E(!0);try{const Z=M.map(Ne=>({name:Ne.name,engagementScore:Ne.engagementScore,avgQuizScore:Ne.avgScore,attendance:Ne.attendance,riskLevel:Ne.riskLevel})),ze=await nt.getDailyInsight({students:Z});Qe(ze.insight)}catch{Qe(`${M.filter(Z=>Z.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{E(!1)}})()},[M]);const Fe=P.reduce((_,Z)=>_+Z.studentCount,0),Ke=P.reduce((_,Z)=>_+Z.atRiskCount,0),rt=P.length>0?Math.round(P.reduce((_,Z)=>_+Z.avgScore,0)/P.length):0,Rt=[{name:"High Risk",value:M.filter(_=>_.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:M.filter(_=>_.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:M.filter(_=>_.riskLevel==="low").length,color:"#75D06A"}],St={};M.forEach(_=>{_.weakestTopic&&_.weakestTopic!=="N/A"&&(St[_.weakestTopic]||(St[_.weakestTopic]={total:0,sum:0}),St[_.weakestTopic].total+=1,St[_.weakestTopic].sum+=_.avgScore)});const Ft=Object.entries(St).map(([_,Z])=>({topic:_,score:Math.round(Z.sum/Z.total)})).sort((_,Z)=>_.score-Z.score).slice(0,6),as=_=>{w(_),i("analytics")},B=_=>{O(_),i("intervention")},Ae=()=>{O(null),i("analytics")},Ye=()=>{w(null),O(null),i("dashboard")},vt=async(_,Z)=>{if(!r){me.error("Unable to assign manager: teacher context is missing.");return}const ze=ls(_.classMetadata?.className||_.name),Ne=gt({metadata:_.classMetadata,classSectionId:_.classSectionId,className:_.name,grade:_.classMetadata?.grade||ze.grade,gradeLevel:_.classMetadata?.gradeLevel,classification:_.classMetadata?.classification,strand:_.classMetadata?.strand,section:_.classMetadata?.section||ze.section,schoolYear:_.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:_.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:_.classMetadata?.ownerTeacherName||he,adviserTeacherId:_.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:_.classMetadata?.adviserTeacherName||he,managerId:Z.uid,managerName:Z.name}),Ge=Ne.classSectionId||Lt(Ne.grade||ze.grade,Ne.section||ze.section);if(!Ge){me.error("Unable to assign manager: missing class section ID.");return}$(!0);try{await qi({classSectionId:Ge,className:Ne.className||_.name,grade:Ne.grade||ze.grade,gradeLevel:Ne.gradeLevel||us(Ne.grade||ze.grade)||Ne.grade||ze.grade,classification:Ne.classification||sa(Ne.gradeLevel||Ne.grade)||void 0,strand:Ne.strand||aa(Ne.className,Ne.section)||void 0,section:Ne.section||ze.section,schoolYear:Ne.schoolYear||String(new Date().getFullYear()),ownerTeacherId:Ne.ownerTeacherId||r.uid,ownerTeacherName:Ne.ownerTeacherName||he,managerId:Z.uid,managerName:Z.name});const je=gt({metadata:Ne,classSectionId:Ge,managerId:Z.uid,managerName:Z.name}),ft=at(Ge);Y(it=>it.map(Ce=>at(Ce.classSectionId)!==ft?Ce:{...Ce,name:je.className||Ce.name,classSectionId:je.classSectionId||Ce.classSectionId,classMetadata:je,gradeLevel:je.gradeLevel||Ce.gradeLevel,classification:je.classification||Ce.classification,strand:je.strand||Ce.strand,managerId:Z.uid,managerName:Z.name})),K(it=>it.map(Ce=>{if(at(Ce.classSectionId||Ce.classroomId)!==ft)return Ce;const Yt=gt({metadata:Ce.classMetadata,classSectionId:je.classSectionId||Ce.classSectionId,className:Ce.className||je.className,grade:Ce.grade||je.grade,gradeLevel:Ce.gradeLevel||je.gradeLevel,classification:Ce.classification||je.classification,strand:Ce.strand||je.strand,section:Ce.section||je.section,managerId:Z.uid,managerName:Z.name});return{...Ce,classMetadata:Yt,gradeLevel:Yt.gradeLevel||Ce.gradeLevel,classification:Yt.classification||Ce.classification,strand:Yt.strand||Ce.strand,managerId:Z.uid,managerName:Z.name}})),w(it=>!it||at(it.classSectionId)!==ft?it:{...it,classMetadata:je,managerId:Z.uid,managerName:Z.name,gradeLevel:je.gradeLevel||it.gradeLevel,classification:je.classification||it.classification,strand:je.strand||it.strand}),me.success(`Assigned ${Z.name} as section manager.`)}catch(je){console.error("Failed to assign class manager:",je),me.error(je instanceof Error?je.message:"Failed to assign class manager")}finally{$(!1)}},xs=u.useCallback(_=>{xe({rosterId:_.id,name:_.name,lrn:_.lrn,email:_.email,grade:_.grade,section:_.section,classSectionId:_.classSectionId})},[]),Ot=u.useCallback(_=>{K(Z=>Z.map(ze=>ze.id===_.rosterId?{...ze,hasRegisteredAccount:!0,source:"both",accountUid:_.uid,email:_.email||ze.email}:ze)),X(Z=>Z+1)},[]),Wt=u.useCallback(async(_,Z)=>{if(!r){me.error("Cannot reassign section without an authenticated teacher.");return}const ze=r.uid,Ne=(Z.classSectionId||"").trim();if(!Ne){me.error("Pick a target section first.");return}te(_.id);try{await wm({studentId:_.accountUid||_.id,isRegisteredAccount:!!_.hasRegisteredAccount,newClassSectionId:Ne,newGrade:Z.grade,newSection:Z.section,previousClassSectionId:_.classSectionId,teacherId:ze,teacherName:he,schoolYear:_.classMetadata?.schoolYear||String(new Date().getFullYear())}),K(Ge=>Ge.map(je=>{if(je.id!==_.id)return je;const ft=gt({metadata:je.classMetadata,classSectionId:Ne,className:je.className,grade:Z.grade,section:Z.section});return{...je,grade:Z.grade,section:Z.section,classSectionId:Ne,classroomId:Ne,classMetadata:ft}})),me.success(`Moved ${_.name} to ${Z.grade} - ${Z.section}.`)}catch(Ge){console.error("Section reassignment failed:",Ge),me.error(Ge instanceof Error?Ge.message:"Failed to reassign section.")}finally{te(null)}},[r,he]);u.useEffect(()=>{const _=()=>{const Z=window.innerWidth<1024;y(Z),Z?c(!1):h(!1)};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),u.useEffect(()=>{b&&h(!1)},[n,b]);const qt=_=>{i(_),w(null),O(null)},Rs=u.useMemo(()=>{if(!S)return;if(S.classMetadata?.classSectionId)return S.classMetadata.classSectionId||void 0;if(S.classSectionId)return S.classSectionId;const _=ls(S.classMetadata?.className||S.name);return Lt(_.grade,_.section)||void 0},[S]),st=u.useMemo(()=>S||null,[S]),Aa=u.useMemo(()=>{if(!st)return;const _=P.findIndex(Z=>Z.id===st.id);return ar[Math.max(0,_)%ar.length]},[st,P]),_t=u.useMemo(()=>{if(!st)return M;const _=(st.id||"").trim().toLowerCase(),Z=at(st.classSectionId),ze=(st.name||"").trim().toLowerCase();return M.filter(Ne=>{const Ge=at(Ne.classroomId),je=at(Ne.classSectionId),ft=(Ne.className||"").trim().toLowerCase();return Z&&(je===Z||Ge===Z)||_&&(Ge===_||je===_)||ze&&ft===ze})},[st,M]);return H?e.jsx(yl,{message:"Loading dashboard..."}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[b&&f&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>h(!1)}),e.jsxs(Re.aside,{initial:!1,animate:{width:b?280:l&&!d?80:280,x:b?f?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!b&&l&&m(!0),onMouseLeave:()=>m(!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 ${l&&!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"})}),(!l||d)&&e.jsx("div",{children:e.jsx("h1",{className:"text-base font-semibold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),!b&&(!l||d)&&e.jsx(Re.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>c(!l),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":l?"Expand sidebar":"Collapse sidebar",children:l?e.jsx(ys,{size:20}):e.jsx(Ss,{size:20})}),b&&e.jsx("button",{onClick:()=>h(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(cs,{size:20})})]}),e.jsxs("nav",{className:"flex-1 space-y-5",children:[e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Overview"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(js,{icon:zl,label:"Dashboard",active:n==="dashboard",collapsed:l&&!d,onClick:Ye,forceExpanded:b}),e.jsx(js,{icon:Ds,label:"Class Analytics",active:n==="analytics"||n==="intervention",collapsed:l&&!d,onClick:()=>qt("analytics"),forceExpanded:b})]})]}),e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Students"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(js,{icon:ws,label:"Topic Mastery",active:n==="topic_mastery",collapsed:l&&!d,onClick:()=>qt("topic_mastery"),forceExpanded:b}),e.jsx(js,{icon:is,label:"Competency",active:n==="competency",collapsed:l&&!d,onClick:()=>qt("competency"),forceExpanded:b})]})]}),e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Tools"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(js,{icon:Ll,label:"Data Import",active:n==="import",collapsed:l&&!d,onClick:()=>i("import"),forceExpanded:b}),e.jsx(js,{icon:ii,label:"AI Quiz Maker",active:n==="quiz_maker",collapsed:l&&!d,onClick:()=>i("quiz_maker"),forceExpanded:b}),e.jsx(js,{icon:Qt,label:"Question Bank",active:n==="question_bank",collapsed:l&&!d,onClick:()=>i("question_bank"),forceExpanded:b}),e.jsx(js,{icon:Ya,label:"Calendar",active:n==="calendar",collapsed:l&&!d,onClick:()=>i("calendar"),forceExpanded:b})]})]})]}),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-semibold border border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628] transition-all duration-200 whitespace-nowrap ${l&&!d?"justify-center":""}`,onClick:a,title:l&&!d?"Settings":"",children:[e.jsx(Dl,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!l||d)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]}),e.jsx("div",{className:"text-[#5a6578]",children:e.jsx($l,{onClick:()=>k(!0),collapsed:l&&!d})})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden bg-gradient-to-br from-[#eef2ff] via-[#f5f3ff] to-[#fff7ed]",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[["dashboard","analytics","intervention","competency","topic_mastery","calendar","notifications","question_bank","import","quiz_maker"].includes(n)&&e.jsx("header",{className:"bg-transparent border-b border-[#e2e8f0]/40 px-[24px] xl:px-[32px] pt-[24px] pb-[16px] flex-shrink-0 z-30",children:e.jsxs("div",{className:"flex flex-row items-center justify-between gap-2 mb-0",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[b&&e.jsx("button",{onClick:()=>h(!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(Sl,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg sm:text-[26px] font-bold text-[#1e293b] tracking-tight leading-tight truncate",children:[n==="dashboard"&&"Teacher Dashboard",n==="analytics"&&"Class Analytics",n==="intervention"&&"Intervention Center",n==="competency"&&"Student Competency",n==="topic_mastery"&&"Topic Mastery",n==="calendar"&&"Academic Calendar",n==="notifications"&&"Notifications",n==="question_bank"&&"Question Bank",n==="import"&&"Data Import",n==="quiz_maker"&&"AI Quiz Maker"]}),e.jsxs("p",{className:"text-[13px] text-[#64748b] mt-1",children:[n==="dashboard"&&`Welcome back, ${he}`,n==="analytics"&&"Analyze performance and risk across your classes.",n==="intervention"&&"Identify and support students who need immediate help.",n==="competency"&&"Track individual student progress against learning goals.",n==="topic_mastery"&&"Overview of student mastery levels across different math topics.",n==="calendar"&&"Manage your schedules and academic events.",n==="notifications"&&"Stay updated with student activity and system alerts.",n==="question_bank"&&"Manage and create math questions for your quizzes.",n==="import"&&"Upload class records and materials to power AI analytics.",n==="quiz_maker"&&"Create AI-powered quizzes based on your curriculum."]})]}),n==="dashboard"&&e.jsxs("div",{className:"hidden xl:flex items-center gap-2 ml-4 mt-1",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(is,{size:13,className:"text-[#9956DE]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#9956DE]",children:[Fe," 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(Xs,{size:13,className:"text-[#F08386]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#C65E63]",children:[Ke," 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(Ta,{size:13,className:"text-[#75D06A]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#4D9F46]",children:[rt,"% avg"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:()=>{se(!0),G(!0)},className:"relative w-10 h-10 flex items-center justify-center bg-[#eef2ff]/80 hover:bg-[#e0e7ff] rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#a5b4fc]/60 text-[#4f46e5] hover:border-[#818cf8] transition-colors cursor-pointer hover:scale-[1.02]","aria-label":"View AI Insight",children:[e.jsx($s,{size:18}),!T&&Me&&e.jsx("div",{className:"absolute top-2.5 right-2.5 w-2 h-2 bg-rose-500 rounded-full border border-white animate-pulse"})]}),e.jsx("span",{className:"absolute -bottom-8 left-1/2 -translate-x-1/2 text-[10px] bg-[#1e293b] text-white px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-50 pointer-events-none",children:"AI Insight"})]}),b&&n==="dashboard"&&e.jsx("button",{onClick:()=>pe(_=>!_),className:`relative w-10 h-10 flex items-center justify-center rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border transition-colors cursor-pointer hover:scale-[1.02] ${fe?"bg-[#818cf8] border-[#6366f1] text-white":"bg-white/60 hover:bg-white/80 border-white/50 text-[#64748b] hover:text-[#1e293b]"}`,"aria-label":fe?"Close calendar panel":"Open calendar panel",title:fe?"Close calendar":"View calendar",children:e.jsx(Ya,{size:18})}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ae(!le),className:"relative w-10 h-10 flex items-center justify-center bg-white/60 hover:bg-white/80 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50 text-[#64748b] hover:text-[#1e293b] transition-colors cursor-pointer hover:scale-[1.02]","aria-label":"View notifications",title:"Notifications",children:[e.jsx(Ja,{size:18}),v>0&&e.jsx("span",{className:"absolute top-2.5 right-2.5 w-2 h-2 bg-rose-500 rounded-full border border-white"})]}),e.jsx(Ml,{isOpen:le,onClose:()=>ae(!1),onViewAll:()=>i("notifications")})]}),n!=="dashboard"&&e.jsxs("div",{onClick:s,className:"flex items-center gap-2 bg-white/60 px-4 py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50 cursor-pointer hover:bg-white/80 transition-colors h-10 hover:scale-[1.02]",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-indigo-100 overflow-hidden shrink-0",children:e.jsx("img",{src:o?.photo||`https://ui-avatars.com/api/?name=${encodeURIComponent(he)}&background=e0e7ff&color=4f46e5`,alt:"Profile",className:"w-full h-full object-cover"})}),e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:he})]})]})]})}),e.jsx("main",{className:`flex-1 flex flex-col ${n==="intervention"||n==="analytics"?"overflow-hidden":"overflow-y-auto"}`,children:e.jsxs(Et,{mode:"wait",children:[n==="dashboard"&&e.jsx(gx,{classes:P,liveActivity:re,onViewClass:as,onViewAllClasses:()=>i("analytics"),onViewActivityStudent:_=>{const Z=M.find(ze=>ze.name===_);Z&&B(Z)},dailyInsight:Me,insightLoading:g,isInsightDismissed:T,onDismissInsight:()=>G(!0),onOpenInsightModal:()=>{se(!0),G(!0)},totalStudents:Fe,totalAtRisk:Ke,avgPerformance:rt,onCreateClass:()=>N(!0)}),n==="analytics"&&st&&e.jsx(wx,{selectedClass:st,students:_t,allClasses:P,riskDistribution:Rt,topicPerformance:Ft,onViewStudent:B,onCreateAccount:xs,onReassignSection:Wt,reassignBusyId:we,onBack:()=>w(null),teacherOptions:J,managerUpdating:ce,onAssignManager:_=>vt(st,_),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,classColor:Aa,insightDismissed:T,onOpenInsightModal:()=>se(!0),onAddStudents:()=>A(!0)}),n==="analytics"&&!st&&P.length>0&&e.jsx(Ao,{classes:P,onSelectClass:as,onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:T,onOpenInsightModal:()=>se(!0),onCreateClass:()=>N(!0)}),n==="analytics"&&!st&&P.length===0&&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(Ds,{size:24})}),e.jsx("h2",{className:"text-2xl font-display font-semibold text-foreground mb-2",children:"Class Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed mb-4",children:"No classes available yet. Create a class or import class records to unlock analytics views."}),e.jsxs(pt,{onClick:()=>N(!0),className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Js,{size:16,className:"mr-1.5"}),"Create Class"]})]})}),n==="intervention"&&z&&e.jsx(Nx,{student:z,teacherId:r?.uid||"",teacherName:he,initialCache:et.current.get(z.id),onCacheUpdate:(_,Z)=>et.current.set(_,Z),onStudentUpdated:_=>{const Z=z?Ur(z):null;O(_),K(ze=>ze.map(Ne=>{const Ge=Ur(Ne),je=Z?Ge===Z:!1,ft=Ne.id===_.id&&at(Ne.classSectionId)===at(_.classSectionId);return je||ft?_:Ne}))},onBack:Ae,onNavigateToQuizMaker:_=>{i("quiz_maker"),_&&sessionStorage.setItem("quizMakerInitialTab",_)}}),n==="topic_mastery"&&e.jsx(Gm,{classSectionId:Rs,onOpenNotifications:()=>i("notifications"),onOpenProfile:s}),n==="competency"&&st&&e.jsx(qm,{classSectionId:Rs,className:S?.name,fallbackStudents:M,onBack:()=>w(null),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:T,onOpenInsightModal:()=>se(!0)}),n==="competency"&&!st&&P.length>0&&e.jsx(Ao,{classes:P,onSelectClass:_=>w(_),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:T,onOpenInsightModal:()=>se(!0),viewType:"competency"}),n==="competency"&&!st&&P.length===0&&e.jsx(fx,{icon:is,title:"Student Competency",description:"No classes available yet. Import class records to view competency breakdowns."}),n==="import"&&e.jsx(ix,{classSectionId:Rs,className:S?.name,classMetadata:S?.classMetadata,students:M,teacherId:r?.uid||"",teacherName:he,onStudentsUpdated:_=>K(_),onBackToClasses:()=>i("dashboard"),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{se(!0),G(!0)},userPhoto:o?.photo,onImportedClassRecords:_=>{const Z=_.students.map(Ce=>hx(Ce,_.classSectionId,_.className,_.classMetadata)),ze=gt({metadata:_.classMetadata,classSectionId:_.classSectionId,className:_.className}),Ne=ze.classSectionId||"imported_class",Ge=ze.className||"Imported Class",je=Z.filter(Ce=>Ce.riskLevel==="high").length,ft=Z.length>0?Math.round(Z.reduce((Ce,ps)=>Ce+ps.avgScore,0)/Z.length):0,it={id:Ne,name:Ge,classSectionId:Ne,classMetadata:{...ze,classSectionId:Ne,className:Ge},schedule:"Mon-Fri",studentCount:Z.length,avgScore:ft,atRiskCount:je,riskLevel:je>=5?"high":je>=2?"medium":"low"};K(Ce=>Wo(Ce,Z)),Y(Ce=>Vo(Ce,[it]))},onDataChanged:()=>X(_=>_+1)}),n==="notifications"&&e.jsx(Km,{liveActivity:re,atRiskStudents:M.filter(_=>_.riskLevel==="high").map(_=>({name:_.name,riskLevel:_.riskLevel,weakestTopic:_.weakestTopic})),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{se(!0),G(!0)},userPhoto:o?.photo,teacherName:he}),n==="calendar"&&e.jsx(du,{classes:P,teacherId:r?.uid}),n==="quiz_maker"&&e.jsx(Yi,{onBack:()=>{const _=sessionStorage.getItem("quizMakerReturnTo");sessionStorage.removeItem("quizMakerReturnTo"),sessionStorage.removeItem("quizMakerInitialTab"),i(_==="intervention"?"intervention":"dashboard")},onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{se(!0),G(!0)},userPhoto:o?.photo,teacherName:he}),n==="question_bank"&&e.jsx(Hm,{onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{se(!0),G(!0)},userPhoto:o?.photo,teacherName:he})]})})]}),n==="dashboard"&&!b&&e.jsx(Yo,{onViewCalendar:()=>i("calendar"),onOpenProfile:s,userProfile:o,teacherName:he,liveActivity:re})]}),e.jsx(Et,{children:b&&n==="dashboard"&&fe&&e.jsxs(e.Fragment,{children:[e.jsx(Re.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-40 bg-slate-900/40 backdrop-blur-[2px]","aria-label":"Close calendar panel",onClick:()=>pe(!1)},"cal-backdrop"),e.jsx(Re.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:320,damping:32},className:"fixed top-0 right-0 bottom-0 z-50 w-[300px] max-w-[85vw] shadow-2xl",children:e.jsx(Yo,{onViewCalendar:()=>{i("calendar"),pe(!1)},onOpenProfile:()=>{s?.(),pe(!1)},userProfile:o,teacherName:he,liveActivity:re})},"cal-drawer")]})}),e.jsx(Et,{children:q&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden border border-slate-200",children:[e.jsxs("div",{className:"p-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600",children:e.jsx($s,{size:16})}),e.jsx("h3",{className:"font-semibold text-slate-800",children:"Detailed AI Insight"})]}),e.jsx("button",{onClick:()=>{se(!1)},className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(cs,{size:18})})]}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-sm text-slate-600 leading-relaxed",children:e.jsx(tc,{children:Me?.replace(/[*_]*\s*\(?Word\s*count\s*:\s*[*_]*\s*\d+\)?\s*[*_]*/gi,"").trim()||`**${Ke} students (${Fe>0?Math.round(Ke/Fe*100):0}%)** are currently at high risk of falling behind in recent topics. Review their progress in the analytics view to plan interventions.`})})}),e.jsx("div",{className:"p-4 border-t border-slate-100 bg-slate-50 flex justify-end gap-2",children:e.jsx("button",{onClick:()=>{se(!1)},className:"px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 hover:bg-slate-200 rounded-lg transition-colors",children:"Minimize to Menu"})})]})})}),e.jsx(Tl,{isOpen:j,onClose:()=>k(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"}),e.jsx(Im,{open:p,onClose:()=>N(!1),onCreated:()=>X(_=>_+1),teacherName:he}),e.jsx(Tm,{open:I,onClose:()=>A(!1),onAdded:()=>X(_=>_+1),grade:st?.gradeLevel||st?.classMetadata?.grade||"Grade 11",section:st?.classMetadata?.section||st?.name?.split(" - ")[1]||"",teacherName:he,existingStudentUids:_t.map(_=>_.id)}),e.jsx(dx,{isOpen:!!oe,onClose:()=>xe(null),seed:oe,adviserTeacherId:r?.uid||"",adviserTeacherName:he,schoolYear:oe?M.find(_=>_.id===oe.rosterId)?.classMetadata?.schoolYear||String(new Date().getFullYear()):void 0,onCreated:Ot})]})},js=({icon:t,label:s,active:a,collapsed:r,forceExpanded:o=!1,onClick:n})=>e.jsxs(Re.button,{onClick:n,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&&!o?"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||o)&&e.jsx("span",{className:"font-body font-semibold 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}})]}),fx=({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-semibold text-foreground mb-2",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed",children:a})]})}),gx=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:o,dailyInsight:n,insightLoading:i,isInsightDismissed:l,onDismissInsight:c,onOpenInsightModal:d,totalStudents:m,totalAtRisk:f,avgPerformance:h,onCreateClass:b})=>{const y=m>0?Math.round(f/m*100):0,j=m>0?Math.round((m-f)/m*100):0;return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-3 sm:p-6 space-y-4",children:[!l&&n&&e.jsxs("div",{onClick:d,className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[14px_16px] sm:p-[18px_20px] flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4 shadow-[0_1px_4px_rgba(0,0,0,0.04)] cursor-pointer hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"absolute -inset-[5px] rounded-full border-2 border-[#a5b4fc] opacity-50 animate-pulse"}),e.jsx("div",{className:"w-[46px] h-[46px] rounded-full bg-[#eef2ff] border-2 border-[#c7d2fe] flex items-center justify-center text-[#4f46e5] text-xl relative overflow-hidden group-hover:scale-[1.05] transition-transform",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Mascot",className:"w-[85%] h-[85%] object-contain"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"text-[13.5px] font-semibold text-[#1e1b4b] flex flex-wrap items-center gap-2 mb-1",children:[e.jsx($s,{size:14,className:"text-[#818cf8]"}),"MathPulse AI insight",e.jsx("span",{className:"bg-[#fee2e2] text-[#b91c1c] text-[10px] font-semibold px-2 py-0.5 rounded-full border border-[#fca5a5]",children:"Attention needed"})]}),e.jsx("div",{className:"text-[12.5px] text-[#475569] leading-[1.55]",children:"Some students may be at risk of falling behind. Click to view detailed analysis."})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0 self-end sm:self-auto",children:[e.jsx("button",{onClick:k=>{k.stopPropagation(),c()},className:"px-[15px] py-[7px] rounded-[10px] text-xs font-medium cursor-pointer border border-[#e2e8f0] bg-white text-[#475569] hover:bg-[#f8fafc] transition-colors",children:"Dismiss"}),e.jsx("button",{onClick:k=>{k.stopPropagation(),r()},className:"px-[15px] py-[7px] rounded-[10px] text-xs font-medium cursor-pointer border border-[#4f46e5] bg-[#4f46e5] text-white shadow-[0_2px_8px_rgba(79,70,229,0.13)] hover:bg-[#4338ca] transition-colors",children:"Review students"})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1.5 sm:gap-3",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#10b981] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Total students"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(is,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:m}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Added this year"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:m>0?"+1":"0"})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#0ea5e9] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Class average"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(ws,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:[h,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Vs. last month"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:"+2.5%"})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#a855f7] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Engage­ment"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(si,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:[j,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Active participants"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:Math.round(j/100*m)})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"At risk"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(or,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:f}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Requires attention"}),e.jsxs("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:[y,"%"]})]})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[18px_20px] shadow-[0_1px_4px_rgba(0,0,0,0.04)]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-[14px]",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:"My classes"}),e.jsx("span",{onClick:r,className:"text-[12px] text-[#10b981] font-semibold cursor-pointer hover:underline",children:"View all"})]}),e.jsxs("div",{className:"space-y-[9px]",children:[t.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-slate-500 mb-3",children:"No classes imported yet."}),b&&e.jsx("button",{onClick:b,className:"text-sm text-[#9956DE] font-semibold hover:underline",children:"+ Create a class"})]}),t.map((k,p)=>{const N=[{bg:"bg-[#f3e8ff]",text:"text-[#a855f7]",borderHover:"hover:border-[#d8b4fe]",stripe:"bg-[#a855f7]"},{bg:"bg-[#eff6ff]",text:"text-[#3b82f6]",borderHover:"hover:border-[#bfdbfe]",stripe:"bg-[#3b82f6]"},{bg:"bg-[#f0fdf4]",text:"text-[#22c55e]",borderHover:"hover:border-[#bbf7d0]",stripe:"bg-[#22c55e]"},{bg:"bg-[#fff7ed]",text:"text-[#f97316]",borderHover:"hover:border-[#fed7aa]",stripe:"bg-[#f97316]"},{bg:"bg-[#fff1f2]",text:"text-[#f43f5e]",borderHover:"hover:border-[#fecdd3]",stripe:"bg-[#f43f5e]"}],I=N[p%N.length];return e.jsxs("div",{onClick:()=>a(k),className:`relative overflow-hidden flex items-center gap-3 p-[12px_13px] pl-[16px] border border-[#f1f5f9] rounded-[14px] cursor-pointer ${I.borderHover} hover:shadow-[0_2px_10px_rgba(0,0,0,0.04)] hover:bg-[#fafbff] transition-all group`,children:[e.jsx("div",{className:`absolute left-0 top-0 bottom-0 w-[5px] ${I.stripe}`}),e.jsx("div",{className:`w-[38px] h-[38px] rounded-[10px] flex items-center justify-center flex-shrink-0 text-[17px] ${I.bg} ${I.text} group-hover:scale-110 transition-transform duration-300`,children:e.jsx(Qt,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-[#1e293b]",children:k.name}),e.jsx("div",{className:"text-[11px] text-[#94a3b8] mt-[1px]",children:k.classification||"High School"})]}),e.jsx("div",{className:"hidden sm:block text-[12px] text-[#64748b] min-w-[65px]",children:k.schedule||"Mon-Fri"}),e.jsxs("div",{className:"hidden sm:block text-[12px] text-[#64748b] min-w-[85px]",children:[k.studentCount," students"]}),e.jsx("span",{className:`text-[10px] font-semibold px-[9px] py-[3px] rounded-[6px] ${k.riskLevel==="high"?"bg-[#fee2e2] text-[#b91c1c] border border-[#fca5a5]":k.riskLevel==="medium"?"bg-[#fffbeb] text-[#b45309] border border-[#fcd34d]":"bg-[#ecfdf5] text-[#065f46] border border-[#6ee7b7]"}`,children:k.riskLevel==="high"?"High risk":k.riskLevel==="medium"?"Medium risk":"On track"}),e.jsx(Lr,{size:16,className:"text-[#cbd5e1] ml-auto hover:text-[#64748b]"})]},k.id)})]})]})]})},bx=de.memo(({student:t,onViewStudent:s,onCreateAccount:a})=>{const o=t.riskLevel==="high"?{borderLeft:"border-l-rose-500",bgAvatar:"bg-rose-50 text-rose-600 border-rose-100/50",badge:"text-rose-600 bg-rose-50",progress:"bg-rose-500"}:t.riskLevel==="medium"?{borderLeft:"border-l-amber-500",bgAvatar:"bg-amber-50 text-amber-600 border-amber-100/50",badge:"text-amber-600 bg-amber-50",progress:"bg-amber-500"}:{borderLeft:"border-l-emerald-500",bgAvatar:"bg-emerald-50 text-emerald-600 border-emerald-100/50",badge:"text-emerald-600 bg-emerald-50",progress:"bg-emerald-500"},n=t.hasRegisteredAccount===!1&&t.source==="import",i=t.hasRegisteredAccount===!0;return e.jsxs("div",{onClick:()=>s(t),className:`p-[12px] bg-white rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] border-l-[4px] ${o.borderLeft} hover:scale-[1.02] transition-transform cursor-pointer group flex flex-col justify-between`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-[10px]",children:[e.jsxs("div",{className:"flex gap-[8px] items-center min-w-0 pr-2",children:[t.avatar?e.jsx("img",{src:t.avatar,alt:t.name,className:`w-8 h-8 rounded-full border ${o.bgAvatar.split(" ")[2]} object-cover shrink-0`}):e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-semibold text-[11px] shrink-0 border ${o.bgAvatar}`,children:t.name.substring(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] leading-tight truncate",children:t.name}),i&&e.jsx("span",{title:"Registered student account",className:"w-1.5 h-1.5 rounded-full bg-emerald-500 shrink-0"})]}),e.jsxs("p",{className:"text-[10px] text-[#64748b] flex items-center gap-[4px] mt-0.5 truncate",children:[e.jsx(Zs,{className:"w-[10px] h-[10px] shrink-0"})," ",t.lastActive||"recently"]})]})]}),e.jsxs("span",{className:`font-semibold text-[11px] px-[6px] py-[2px] rounded-[14px] shrink-0 ${o.badge}`,children:[t.avgScore,"%"]})]}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2 px-2 py-1 rounded-[10px] bg-amber-50 border border-amber-100/80",children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"No Account"}),a&&e.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),a(t)},className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-white text-amber-700 border border-amber-200 hover:bg-amber-100 text-[10px] font-semibold transition-colors","aria-label":`Create system account for ${t.name}`,children:[e.jsx("span",{"aria-hidden":!0,children:"+"}),"Create"]})]}),e.jsx("div",{className:"w-full bg-[#f1f5f9] h-1.5 rounded-full overflow-hidden mt-auto",children:e.jsx("div",{className:`h-full rounded-full ${o.progress}`,style:{width:`${t.avgScore}%`}})})]})}),vx=({students:t,allClasses:s,currentClass:a,onReassignSection:r,reassignBusyId:o})=>{const[n,i]=u.useState(!1),l=u.useMemo(()=>{const d=new Map;return s.forEach(m=>{const f=(m.classSectionId||m.id||"").trim();if(!f)return;const h=(m.classMetadata?.grade||"").trim(),b=(m.classMetadata?.section||"").trim();if(!h||!b)return;const y=m.name||`${h} - ${b}`;d.set(f,{classSectionId:f,grade:h,section:b,label:y})}),Array.from(d.values()).sort((m,f)=>m.label.localeCompare(f.label))},[s]),c=u.useMemo(()=>{const d=new Map,m=[];return t.forEach(f=>{const h=(f.classSectionId||"").trim();if(!h){m.push(f);return}const b=f.section||f.className||h,y=d.get(h)||{label:b,students:[]};y.students=[...y.students,f],d.set(h,y)}),{assigned:Array.from(d.entries()).map(([f,h])=>({sectionId:f,...h})).sort((f,h)=>f.label.localeCompare(h.label)),unassigned:m}},[t]);return e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white shadow-[0_1px_4px_rgba(0,0,0,0.04)] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(d=>!d),className:"w-full flex items-center justify-between px-6 py-4 text-left","aria-expanded":n,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Section Management"}),e.jsxs("p",{className:"text-[12px] text-[#64748b] mt-0.5",children:["Move students between sections. Showing ",t.length," students across ",c.assigned.length," section",c.assigned.length===1?"":"s",c.unassigned.length>0?` · ${c.unassigned.length} unassigned`:"","."]})]}),e.jsx(Tt,{className:`w-4 h-4 text-[#64748b] transition-transform ${n?"rotate-180":""}`})]}),n&&e.jsxs("div",{className:"border-t border-[#f1f5f9] divide-y divide-[#f1f5f9]",children:[c.assigned.length===0&&c.unassigned.length===0&&e.jsx("p",{className:"text-[12px] text-[#64748b] px-6 py-5",children:"No students yet. Add students to this teacher to manage section assignments."}),c.assigned.map(d=>e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-[#64748b] mb-2",children:[d.label," ",e.jsxs("span",{className:"text-[10px] font-normal text-[#94a3b8]",children:["(",d.students.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:d.students.map(m=>e.jsx(qo,{student:m,sectionTargets:l,currentSectionId:a.classSectionId,onReassign:r,isBusy:o===m.id},`section-row-${m.id}`))})]},d.sectionId)),c.unassigned.length>0&&e.jsxs("div",{className:"px-6 py-4 bg-amber-50/40",children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-amber-700 mb-2",children:["Unassigned ",e.jsxs("span",{className:"text-[10px] font-normal text-amber-600/80",children:["(",c.unassigned.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:c.unassigned.map(d=>e.jsx(qo,{student:d,sectionTargets:l,currentSectionId:a.classSectionId,onReassign:r,isBusy:o===d.id},`section-row-${d.id}`))})]})]})]})},qo=({student:t,sectionTargets:s,currentSectionId:a,onReassign:r,isBusy:o})=>{const[n,i]=u.useState(t.classSectionId||"");u.useEffect(()=>{i(t.classSectionId||"")},[t.classSectionId]);const l=()=>{const d=s.find(m=>m.classSectionId===n);d&&d.classSectionId!==t.classSectionId&&r(t,d)},c=n===(t.classSectionId||"");return e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-2 md:gap-3 px-3 py-2 rounded-[12px] bg-white border border-[#f1f5f9]",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] truncate",children:t.name}),e.jsxs("p",{className:"text-[11px] text-[#64748b] truncate",children:[t.lrn?`LRN ${t.lrn} · `:"",t.classMetadata?.className||t.className||"Unassigned section",a&&t.classSectionId===a?" · current":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:n,onChange:d=>i(d.target.value),disabled:o||s.length===0,className:"text-[12px] rounded-xl border border-[#dde3eb] bg-white px-3 py-1.5 text-[#0a1628] focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Select section…"}),s.map(d=>e.jsx("option",{value:d.classSectionId,children:d.label},d.classSectionId))]}),e.jsx("button",{type:"button",onClick:l,disabled:o||c||!n,className:"text-[12px] font-semibold rounded-xl px-3 py-1.5 bg-indigo-600 text-white hover:bg-indigo-700 transition-colors disabled:opacity-50 disabled:hover:bg-indigo-600",children:o?"Saving…":"Move"})]})]})},wx=({selectedClass:t,students:s,allClasses:a,riskDistribution:r,topicPerformance:o,onViewStudent:n,onCreateAccount:i,onReassignSection:l,reassignBusyId:c,onBack:d,teacherOptions:m,managerUpdating:f,onAssignManager:h,onOpenNotifications:b,onOpenProfile:y,classColor:j,insightDismissed:k,onOpenInsightModal:p,onAddStudents:N})=>{const{currentUser:I,userProfile:A}=ds(),[C,U]=u.useState(""),[v,S]=u.useState(""),[w,z]=u.useState("All"),O=[{name:"High Risk",value:s.filter(P=>P.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:s.filter(P=>P.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:s.filter(P=>P.riskLevel==="low").length,color:"#75D06A"}];u.useEffect(()=>{S(t.classMetadata?.managerId||t.managerId||"")},[t]);const T=u.useMemo(()=>{const P=C.trim().toLowerCase();let Y=s;return P&&(Y=Y.filter(M=>M.name.toLowerCase().includes(P)||(M.lrn||"").toLowerCase().includes(P)||(M.weakestTopic||"").toLowerCase().includes(P))),w==="Good"?Y=Y.filter(M=>M.avgScore>=85&&M.riskLevel!=="high"):w==="Risk"&&(Y=Y.filter(M=>M.riskLevel==="high"||M.avgScore<75)),Y},[C,s,w]),G=u.useMemo(()=>{if(s.length===0)return 0;const P=s.reduce((Y,M)=>Y+(M.assignmentCompletion||0),0);return Math.round(P/s.length)},[s]),q=u.useMemo(()=>{if(s.length===0)return 0;const P=s.reduce((M,K)=>M+(K.attendance||0),0)/s.length,Y=s.reduce((M,K)=>M+(K.engagementScore||0),0)/s.length;return Math.round(P*.6+Y*.4)},[s]),se=u.useMemo(()=>[...s].sort((P,Y)=>Y.avgScore-P.avgScore).slice(0,5),[s]),le=u.useMemo(()=>[...s].filter(P=>P.riskLevel==="high"||P.avgScore<70||P.assignmentCompletion<65),[s]),ae=u.useMemo(()=>m.find(P=>P.uid===v),[m,v]),fe=()=>{if(!ae){me.error("Select a teacher manager first.");return}h(ae)},pe=[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-3 sm:p-[24px] xl:p-[32px] space-y-3 sm:space-y-[24px] h-full overflow-y-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-3 sm:mb-6",children:e.jsxs("button",{onClick:d,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Ss,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("header",{style:{backgroundColor:j?.hex||"#6366f1"},className:"rounded-[24px] p-4 sm:p-[24px] lg:p-[32px] shadow-[0_8px_32px_rgba(0,0,0,0.08)] flex flex-col lg:flex-row lg:items-center justify-between gap-4 sm:gap-6 relative overflow-hidden group text-white",children:[e.jsx("div",{className:"absolute -right-10 -bottom-10 w-48 h-48 rounded-full bg-white/10 group-hover:scale-[1.3] transition-transform duration-700 ease-out pointer-events-none"}),e.jsx("div",{className:"absolute -left-10 -top-10 w-32 h-32 rounded-full bg-white/10 group-hover:scale-[1.2] transition-transform duration-700 delay-75 ease-out pointer-events-none"}),e.jsxs("div",{className:"shrink-0 relative z-10",children:[e.jsx("h1",{className:"text-xl sm:text-[28px] font-bold mb-2 sm:mb-3 tracking-tight",children:t.name}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:pe.map((P,Y)=>e.jsx("span",{className:"px-3 py-1 bg-white/20 backdrop-blur-md text-white text-[12px] font-semibold rounded-full shadow-sm border border-white/20",children:P},P))}),e.jsxs("p",{className:"text-[13px] text-white/80 font-medium",children:["Manager: ",t.classMetadata?.managerName||t.managerName||"Not assigned"]})]}),e.jsxs("div",{className:"bg-white/10 border border-white/20 rounded-[18px] p-[16px] backdrop-blur-md flex flex-col w-full md:w-auto shrink-0 relative z-10 shadow-inner",children:[e.jsx("label",{className:"text-[11px] font-bold text-white/90 uppercase tracking-wider mb-2 ml-1",children:"Section Manager"}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3",children:[e.jsxs("div",{className:"relative w-full md:w-[320px]",children:[e.jsxs("select",{value:v||"",onChange:P=>S(P.target.value),className:"appearance-none bg-white/20 border border-white/30 text-white text-[13px] font-bold rounded-xl pl-4 pr-10 py-2.5 outline-none focus:border-white/50 focus:ring-2 focus:ring-white/20 w-full shadow-sm cursor-pointer [&>option]:text-[#1e293b]",children:[e.jsx("option",{value:"",children:"Select teacher"}),m.map(P=>e.jsxs("option",{value:P.uid,children:[P.name," (",P.email,")"]},P.uid))]}),e.jsx(Tt,{className:"w-4 h-4 text-white/70 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsx("button",{onClick:fe,disabled:!v||f,className:"bg-white text-[#6366f1] hover:bg-white/90 text-[13px] font-bold rounded-full px-6 py-2.5 shadow-md transition-transform hover:scale-[1.02] whitespace-nowrap disabled:opacity-50 disabled:hover:scale-100",style:{color:j?.hex||"#6366f1"},children:f?"Updating...":"Assign"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-[18px] w-full",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#0ea5e9] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Class Average"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(ws,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#10b981] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Completion"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(qr,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[G,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#a855f7] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Participation"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(is,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[q,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Attention"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Xs,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[le.length," ",e.jsx("span",{className:"text-[12px] opacity-90 font-medium",children:"students"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-3 sm:gap-[24px] h-auto xl:h-[600px]",children:[e.jsxs("div",{className:"xl:col-span-1 bg-white/80 backdrop-blur-[12px] rounded-[18px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col overflow-hidden h-[500px] xl:h-full",children:[e.jsxs("div",{className:"p-5 border-b border-[#f1f5f9] shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:["Students ",e.jsxs("span",{className:"text-[#64748b] text-[13px]",children:["(",T.length,")"]})]}),e.jsx("button",{onClick:()=>N?.(),className:"text-[11px] font-semibold text-[#9956DE] hover:text-[#7c3aed] bg-[#9956DE]/10 hover:bg-[#9956DE]/20 px-3 py-1.5 rounded-lg transition-colors",children:"+ Add"})]}),e.jsxs("div",{className:"flex items-center bg-white px-4 py-2 rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] group",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search students...",value:C,onChange:P=>U(P.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#64748b]"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 overflow-x-auto no-scrollbar pb-1",children:[e.jsx("button",{onClick:()=>z("All"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="All"?"bg-[#4f46e5] text-white shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-[#f8fafc] text-[#64748b] hover:bg-[#f1f5f9]"}`,children:"All Students"}),e.jsx("button",{onClick:()=>z("Good"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="Good"?"bg-emerald-50 text-emerald-600 border border-emerald-100/50 shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-emerald-50/40 text-emerald-600 border border-emerald-50 hover:bg-emerald-50"}`,children:"Top Performers"}),e.jsx("button",{onClick:()=>z("Risk"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="Risk"?"bg-rose-50 text-rose-600 border border-rose-100/50 shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-rose-50/40 text-rose-600 border border-rose-50 hover:bg-rose-50"}`,children:"Needs Attention"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4 flex flex-col no-scrollbar",children:e.jsx(Yd,{style:{height:"100%"},data:T,className:"no-scrollbar",itemContent:(P,Y)=>e.jsx("div",{className:"py-[6px] px-[8px]",children:e.jsx(bx,{student:Y,onViewStudent:n,onCreateAccount:i})}),computeItemKey:(P,Y)=>Ur(Y)})})]}),e.jsxs("div",{className:"xl:col-span-2 flex flex-col gap-[24px] h-full overflow-y-auto no-scrollbar pb-10 xl:pb-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col group h-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"font-semibold text-[15px] text-[#1e293b]",children:"Risk Distribution"}),e.jsx(Lr,{className:"w-4 h-4 text-[#64748b] cursor-pointer group-hover:scale-110 transition-transform"})]}),e.jsx("div",{className:"relative w-full flex-1 min-h-[180px]",children:e.jsx(Dn,{width:"100%",height:"100%",children:e.jsxs($n,{data:O,children:[e.jsx(Fn,{strokeDasharray:"4 4",stroke:"#f1f5f9",vertical:!1}),e.jsx(On,{dataKey:"name",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#475569",fontSize:11,fontWeight:600},dy:10}),e.jsx(Bn,{axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600}}),e.jsx(Pn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Hn,{dataKey:"value",radius:[6,6,0,0],barSize:80,children:O.map((P,Y)=>{const M={"High Risk":"#f43f5e","Medium Risk":"#f59e0b","Low Risk":"#10b981"};return e.jsx(Qn,{fill:M[P.name]||P.color},`cell-${Y}`)})})]})})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col group h-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"font-semibold text-[15px] text-[#1e293b]",children:"Topic Performance"}),e.jsx(Lr,{className:"w-4 h-4 text-[#64748b] cursor-pointer group-hover:scale-110 transition-transform"})]}),e.jsx("div",{className:"relative w-full flex-1 min-h-[180px] -ml-8",children:e.jsx(Dn,{width:"100%",height:"100%",children:e.jsxs($n,{data:o,layout:"vertical",margin:{top:0,right:10,left:40,bottom:0},children:[e.jsx(Fn,{strokeDasharray:"4 4",stroke:"#f1f5f9",horizontal:!1}),e.jsx(On,{type:"number",domain:[0,100],axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600},tickFormatter:P=>`${P}%`}),e.jsx(Bn,{dataKey:"topic",type:"category",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#1e293b",fontSize:11,fontWeight:600},dx:-10}),e.jsx(Pn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Hn,{dataKey:"score",radius:[0,6,6,0],barSize:28,children:o.map((P,Y)=>{const M=["#6366f1","#a855f7","#10b981","#f59e0b","#ec4899"];return e.jsx(Qn,{fill:M[Y%M.length]},`cell-${Y}`)})})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("h3",{className:"font-semibold text-[15px] text-[#1e293b] flex items-center gap-2",children:[e.jsx(Ta,{className:"w-4 h-4 text-emerald-500"}),"Top Performers"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[se.map(P=>e.jsxs("div",{onClick:()=>n(P),className:"flex justify-between items-center p-3 bg-emerald-50/40 rounded-[14px] border border-emerald-50 group hover:scale-[1.02] transition-transform cursor-pointer",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:P.name}),e.jsxs("span",{className:"text-[13px] font-semibold text-emerald-600",children:[P.avgScore,"%"]})]},`top-${P.id}`)),se.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No students available yet."})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("h3",{className:"font-semibold text-[15px] text-[#1e293b] flex items-center gap-2",children:[e.jsx(Xs,{className:"w-4 h-4 text-rose-500"}),"Needs Attention"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[le.slice(0,4).map(P=>{const Y=P.riskLevel==="high",M=Y?"bg-rose-50/40 border-rose-50":"bg-amber-50/40 border-amber-50";return e.jsxs("div",{onClick:()=>n(P),className:`flex justify-between items-center p-3 rounded-[14px] border group hover:scale-[1.02] transition-transform cursor-pointer ${M}`,children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:P.name}),e.jsx("span",{className:`text-[11px] font-semibold bg-white px-2 py-0.5 rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] ${Y?"text-rose-600":"text-amber-600"}`,children:Y?"HIGH RISK":"MEDIUM RISK"})]},`attn-${P.id}`)}),le.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students."})]})]})]})]})]}),e.jsx(vx,{students:s,allClasses:a,currentClass:t,onReassignSection:l,reassignBusyId:c})]})},Nx=({student:t,teacherId:s,teacherName:a,onStudentUpdated:r,onBack:o,onNavigateToQuizMaker:n,initialCache:i,onCacheUpdate:l})=>{const c=(t.riskLevel||"low").toLowerCase(),d=c==="high"||c==="medium",m=u.useMemo(()=>nt.getImportGroundedRolloutFlags(),[]),[f,h]=u.useState(i?.learningPath||""),[b,y]=u.useState(!0),[j,k]=u.useState(i?.gradeDraft||t.grade||"Grade 11"),[p,N]=u.useState(i?.sectionDraft||t.section||"Section A"),[I,A]=u.useState(!1),[C,U]=u.useState(i?.lessonPlan??null),[v,S]=u.useState([]),[w,z]=u.useState(""),[O,T]=u.useState(!1),[G,q]=u.useState(""),[se,le]=u.useState("all"),[ae,fe]=u.useState("all"),[pe,P]=u.useState(!1),[Y,M]=u.useState(!1),[K,re]=u.useState(null),[$e,Me]=u.useState(!1),[Qe,H]=u.useState(!1),[ee,g]=u.useState(0),[E,R]=u.useState(!1),[X,J]=u.useState("choose"),[ne,ce]=u.useState([]),[$,oe]=u.useState(!1),[xe,we]=u.useState(!1),[te,he]=u.useState(!1),[et,Fe]=u.useState(!1);u.useEffect(()=>{k(t.grade||"Grade 11"),N(t.section||"Section A")},[t.grade,t.section]),u.useEffect(()=>{const B=Ae=>{if(Ae.key==="Escape"){if(et){Fe(!1);return}if(xe){te?Fe(!0):we(!1);return}E&&R(!1)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[xe,E,te,et]),u.useEffect(()=>{if(xe){const B=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=B}}},[xe]),u.useEffect(()=>{l?.(t.id,{lessonPlan:C,learningPath:f,gradeDraft:j,sectionDraft:p})},[C,f,j,p,t.id,l]),u.useEffect(()=>{(async()=>{y(!0);try{let Ae="";try{Ae=await Cl(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),z(Ae)}catch{z("")}const Ye=await nt.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),vt=Ae?`${Ye.learningPath} + +${Ae}`:Ye.learningPath;h(vt)}catch{h("Unable to generate learning path. Please try again later."),z("")}finally{y(!1)}})()},[t]);const Ke=u.useCallback(async()=>{T(!0),q("");try{const B=t.classSectionId||Lt(j||"Grade 11",p||"Section A"),Ae=t.struggles.length>0?t.struggles[0]:t.weakestTopic,Ye=await _m({gradeLevel:j||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[j,p].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${Ae}`,learningCompetency:Ae,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:B,className:[j,p].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:m.lessonEnabled,allowReviewSources:pe,allowUnverifiedLesson:Y},!0);U(Ye),S(Ye.curriculumSources||[]),re(null),nt.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:B,className:[j,p].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:Ye.usedImportedTopics,importedTopicCount:Ye.importedTopicCount,blockCount:Ye.blocks.length,publishReady:Ye.publishReady,sourceLegitimacyStatus:Ye.sourceLegitimacy.status,selfValidationPassed:Ye.selfValidation.passed,importGroundingEnabled:m.lessonEnabled}})}catch(B){let Ae=B instanceof Error?B.message:"Unable to generate lesson plan at this time.";if(B instanceof qa&&B.status===422)try{const vt=JSON.parse(B.responseBody)?.detail;vt?.message&&(Ae=vt.message);const xs=vt?.sourceLegitimacy?.issues||[],Ot=vt?.selfValidation?.issues||[],Wt=[...xs,...Ot].filter(Boolean).slice(0,3);Wt.length>0&&(Ae=`${Ae} ${Wt.join(" ")}`)}catch{}q(Ae),U(null),S([]),nt.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||Lt(j||"Grade 11",p||"Section A"),className:[j,p].filter(Boolean).join(" - ")||t.className,metadata:{error:Ae,allowReviewSources:pe,allowUnverifiedLesson:Y,importGroundingEnabled:m.lessonEnabled}})}finally{T(!1)}},[t,j,p,m.lessonEnabled,pe,Y]),rt=u.useCallback(async()=>{if(!C)return me.error("Generate a lesson plan first."),null;Me(!0);try{const B=await Em(C,s,{teacherName:a,studentId:t.id,studentName:t.name});return re(B),me.success("Lesson plan saved as draft."),B}catch(B){return console.error("Failed to save lesson draft:",B),me.error(B instanceof Error?B.message:"Failed to save lesson draft."),null}finally{Me(!1)}},[C,s,a,t.id,t.name]),Rt=u.useCallback(async()=>{if(!C){me.error("Generate a lesson plan first.");return}if(!C.publishReady){const B=[...C.sourceLegitimacy.issues,...C.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");me.error(B||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}H(!0);try{let B=K;if(B||(B=await rt()),!B)return;await Rm(B),me.success("Lesson plan published to class content."),nt.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:C.classSectionId||t.classSectionId,className:C.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:B,publishReady:C.publishReady,sourceLegitimacyStatus:C.sourceLegitimacy.status,selfValidationPassed:C.selfValidation.passed}})}catch(B){console.error("Failed to publish lesson plan:",B),me.error(B instanceof Error?B.message:"Failed to publish lesson plan."),nt.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:C.classSectionId||t.classSectionId,className:C.className||t.className,metadata:{action:"publish_lesson_plan",error:B instanceof Error?B.message:"Failed to publish lesson plan."}})}finally{H(!1)}},[C,K,rt,t.className,t.classSectionId]);u.useEffect(()=>{Ke()},[ee]),u.useEffect(()=>{g(B=>B+1)},[t.id]),u.useEffect(()=>{le("all"),fe("all")},[C]),u.useMemo(()=>C?Array.from(new Set(C.blocks.map(B=>B.provenance?.sourceFile?.trim()).filter(B=>!!B))).sort((B,Ae)=>B.localeCompare(Ae)):[],[C]),u.useMemo(()=>C?Array.from(new Set(C.blocks.map(B=>B.provenance?.materialId?.trim()).filter(B=>!!B))).sort((B,Ae)=>B.localeCompare(Ae)):[],[C]);const St=u.useMemo(()=>C?C.blocks.filter(B=>{const Ae=se==="all"||(B.provenance?.sourceFile||"").trim()===se,Ye=ae==="all"||(B.provenance?.materialId||"").trim()===ae;return Ae&&Ye}):[],[C,se,ae]),Ft=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:Gn},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:ii},{id:3,type:"assessment",title:"Final Check",questions:5,icon:qr}],as=async()=>{if(!s){me.error("Unable to update section: teacher context missing");return}A(!0);try{await mr(t.id,j,p,s,new Date().getFullYear().toString(),a),await Vi(t.id,j,p);const B={...t,grade:j,section:p,className:[j,p].filter(Boolean).join(" - "),classSectionId:Lt(j,p)};r(B),me.success("Student section assignment updated")}catch(B){console.error("Failed to update student section assignment:",B),me.error("Failed to update section assignment")}finally{A(!1)}};return e.jsxs(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"w-full h-full flex overflow-hidden relative",children:[e.jsx("div",{className:"flex-1 overflow-y-auto p-[24px] xl:p-[32px] no-scrollbar",children:e.jsxs("div",{className:"max-w-[1000px] mx-auto space-y-[24px]",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-[8px]",children:e.jsx("div",{children:e.jsxs("button",{onClick:o,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] mb-[16px] w-max shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Xa,{className:"w-4 h-4"}),"Back to Analytics"]})})}),e.jsxs("div",{className:"bg-gradient-to-br from-[#ecfdf5] via-[#f0fdf4] to-[#f7fdf9] backdrop-blur-[12px] rounded-[20px] p-[24px] border border-emerald-100 shadow-[0_4px_16px_rgba(16,185,129,0.08)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute right-[-20px] bottom-[-20px] opacity-[0.06] pointer-events-none",children:e.jsx(Cn,{className:"w-48 h-48 text-emerald-600"})}),e.jsxs("div",{className:"flex items-center gap-3 mb-5 relative z-10",children:[e.jsx("div",{className:"w-10 h-10 rounded-[12px] bg-gradient-to-br from-[#059669] to-[#10b981] flex items-center justify-center shrink-0 shadow-[0_4px_10px_rgba(5,150,105,0.3)]",children:e.jsx(Cn,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-[15px] font-bold text-[#1e293b]",children:"AI Analysis"}),e.jsxs("span",{className:"flex items-center gap-1 px-2.5 py-0.5 bg-emerald-500 text-white text-[10px] font-bold rounded-full uppercase tracking-wider shadow-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse"}),"Insights Active"]})]})]}),w&&e.jsx(No,{sources:v,className:"mb-4 relative z-10"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsxs("div",{className:"bg-white/70 backdrop-blur-sm rounded-[14px] p-4 border border-emerald-100/60 shadow-[0_1px_4px_rgba(0,0,0,0.04)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-400 rounded-l-[14px]"}),e.jsxs("h4",{className:"text-[11px] font-bold text-emerald-600 uppercase tracking-wider mb-2.5 flex items-center gap-1.5 pl-2",children:[e.jsx(Ta,{className:"w-3.5 h-3.5"})," Learning Strengths"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed pl-2",children:d?e.jsx(e.Fragment,{children:"Demonstrates engagement but faces challenges. Needs support with foundational topics."}):e.jsxs(e.Fragment,{children:["Excels in ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:t.weakestTopic}),". Demonstrates high engagement during interactive tests."]})})]}),e.jsxs("div",{className:"bg-white/70 backdrop-blur-sm rounded-[14px] p-4 border border-rose-100/60 shadow-[0_1px_4px_rgba(0,0,0,0.04)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-rose-400 rounded-l-[14px]"}),e.jsxs("h4",{className:"text-[11px] font-bold text-rose-500 uppercase tracking-wider mb-2.5 flex items-center gap-1.5 pl-2",children:[e.jsx(ws,{className:"w-3.5 h-3.5"})," Next Steps"]}),e.jsx("ul",{className:"text-[13px] text-[#475569] leading-relaxed list-none p-0 m-0 space-y-1 pl-2",children:t.struggles.length>0?t.struggles.map((B,Ae)=>e.jsxs("li",{children:["Must continue strengthening ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:B}),"."]},Ae)):e.jsxs("li",{children:["Focus on repetitive practice modules for ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:t.weakestTopic}),"."]})})]})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 border-b border-[#f1f5f9] pb-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Generated Learning Path"}),e.jsxs("button",{disabled:b,onClick:()=>g(B=>B+1),className:"bg-[#f8fafc] hover:bg-white text-[#4f46e5] border border-[#e0e7ff] text-[11px] font-semibold rounded-full px-4 py-1.5 transition-colors shadow-[0_1px_4px_rgba(0,0,0,0.02)] flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(zs,{className:"w-3 h-3"})," Regenerate"]})]}),e.jsxs(vo,{name:"teacher-intervention-learning-path",loading:!1,fixture:null,fallback:null,children:[e.jsxs("div",{className:"mb-8 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mr-2",children:"Methodology:"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Interactive"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Video"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Practice"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Quiz"})]}),e.jsx("div",{className:"relative border-l-2 border-[#e2e8f0] ml-[20px] space-y-[28px] pb-4",children:Ft.map((B,Ae)=>{let Ye=e.jsx(Gn,{className:"w-4 h-4"}),vt="bg-[#8b5cf6] shadow-[0_4px_10px_rgba(139,92,246,0.3)]",xs="text-purple-600",Ot="group-hover:border-purple-200",Wt="hover:bg-[#4f46e5]",qt=e.jsx(Pl,{className:"w-4 h-4 ml-0.5"});return B.type==="quiz"?(Ye=e.jsx(Hl,{className:"w-4 h-4"}),vt="bg-sky-500 shadow-[0_4px_10px_rgba(14,165,233,0.3)]",xs="text-sky-600",Ot="group-hover:border-sky-200",Wt="hover:bg-sky-500",qt=e.jsx(ys,{className:"w-4 h-4"})):B.type==="assessment"&&(Ye=e.jsx(Wr,{className:"w-4 h-4"}),vt="bg-emerald-500 shadow-[0_4px_10px_rgba(16,185,129,0.3)]",xs="text-emerald-600",Ot="group-hover:bg-emerald-50"),e.jsxs(Re.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:Ae*.1},className:"relative pl-[32px] group",children:[e.jsx("div",{className:`absolute -left-[17px] top-1 w-8 h-8 rounded-full ${vt} text-white flex items-center justify-center ring-4 ring-white group-hover:scale-110 transition-transform`,children:Ye}),e.jsxs("div",{className:`${B.type==="assessment"?"bg-emerald-50/50 border-emerald-100":"bg-white border-[#f1f5f9]"} rounded-[14px] p-[18px] border shadow-[0_1px_4px_rgba(0,0,0,0.04)] flex justify-between items-center transition-colors ${Ot}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wider mb-1 block ${xs}`,children:["Step ",Ae+1," • ",B.type==="video"?"Video Lesson":B.type==="quiz"?"Practice":"Assessment"]}),e.jsx("p",{className:"font-semibold text-[#1e293b] text-[13px] mb-0.5",children:B.title}),e.jsxs("p",{className:"text-[#64748b] text-[11px] flex items-center gap-1.5",children:[B.type==="video"&&e.jsxs(e.Fragment,{children:[e.jsx(Zs,{className:"w-3 h-3"})," ",B.duration]}),B.type==="quiz"&&e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"w-3 h-3"})," ",B.questions," questions"]}),B.type==="assessment"&&e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"w-3 h-3"})," ",B.questions," assessment questions"]})]})]}),B.type==="assessment"?e.jsx(Zo,{className:"w-6 h-6 text-emerald-400"}):e.jsx("button",{className:`w-8 h-8 rounded-full bg-[#f8fafc] flex items-center justify-center text-[#64748b] ${Wt} hover:text-white transition-colors border border-[#e2e8f0]`,children:qt})]})]},B.id)})})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Targeted Lesson Generation"}),e.jsx(pt,{onClick:()=>g(B=>B+1),disabled:O,className:"bg-[#4f46e5] hover:bg-[#3730a3] text-white h-8 text-[11px] rounded-full px-4",children:O?"Loading...":"Regenerate"})]}),e.jsx("p",{className:"text-[13px] text-[#64748b] mb-6",children:"Configure inputs and requirements for AI lesson generation."}),e.jsxs("div",{className:"bg-[#f8fafc]/80 rounded-[14px] p-[20px] border border-[#f1f5f9] mb-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ga,{className:"w-4 h-4 text-[#4f46e5] shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-[13px] text-[#475569] leading-relaxed",children:["Class records alone are not enough for import-grounded lesson plans. Ensure course materials are uploaded via ",e.jsx("span",{className:"text-[#4f46e5] font-semibold",children:"Data Import"}),"."]})]}),e.jsxs("div",{className:"space-y-4 border-t border-[#e2e8f0] pt-5 mt-5",children:[e.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[e.jsx("span",{className:"text-[13px] font-medium text-[#1e293b] group-hover:text-[#4f46e5] transition-colors",children:"Allow sources requiring manual review"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:pe,onChange:B=>P(B.target.checked)}),e.jsx("div",{className:"w-10 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]})]}),e.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[e.jsx("span",{className:"text-[13px] font-medium text-[#1e293b] group-hover:text-[#4f46e5] transition-colors",children:"Allow unverified lesson draft"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:Y,onChange:B=>M(B.target.checked)}),e.jsx("div",{className:"w-10 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]})]})]})]}),e.jsxs(vo,{name:"teacher-intervention-lesson-plan",loading:!1,fixture:null,fallback:null,children:[G&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A] mb-4",children:G}),C&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[#f8fafc] border border-[#f1f5f9] rounded-[14px] p-5 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("div",{className:"mb-3",children:e.jsx(No,{sources:v})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:C.lessonTitle}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2 mt-2",children:[e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Imported topics:"})," ",C.usedImportedTopics?"Yes":"No"," (",C.importedTopicCount,")"]}),e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Subject:"})," ",C.subject||"General Math"," (Q",C.quarter||1,")"]})]}),C.curriculumCompetency&&e.jsxs("p",{className:"text-[11px] text-[#4f46e5] font-semibold mt-2 bg-indigo-50/50 px-2 py-1 rounded inline-block",children:["Competency: ",C.curriculumCompetency]}),e.jsx("div",{className:"mt-3 flex items-center justify-between",children:e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:["Publish readiness: ",e.jsx("span",{className:`font-semibold ${C.publishReady?"text-emerald-600":"text-rose-500"}`,children:C.publishReady?"Ready":"Blocked"})]})}),C.warnings.length>0&&e.jsx("p",{className:"text-[11px] text-amber-600 mt-2 bg-amber-50 px-2 py-1.5 rounded",children:C.warnings.join(" ")})]}),C.lessonObjective&&e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[14px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5",children:"Lesson objective"}),e.jsx("p",{className:"text-[13px] text-[#1e293b]",children:C.lessonObjective})]}),C.realWorldHook&&e.jsxs("div",{className:"bg-indigo-50/50 border border-indigo-100 rounded-[14px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#4f46e5] uppercase tracking-wider mb-1.5",children:"Real-life application"}),e.jsx("p",{className:"text-[13px] text-[#1e293b]",children:C.realWorldHook})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:St.map(B=>e.jsxs("div",{className:"border border-[#e2e8f0] rounded-[14px] p-4 bg-white shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[#1e293b]",children:B.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] mt-1",children:[B.estimatedMinutes," mins "," • "," ",B.strategy]}),e.jsx("p",{className:"text-[12px] text-[#475569] mt-2 bg-[#f8fafc] p-2 rounded-lg",children:B.objective}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5",children:"Activities"}),B.activities.slice(0,2).map((Ae,Ye)=>e.jsxs("p",{className:"text-[11px] text-[#475569] mb-1 flex items-start gap-1",children:[e.jsx("span",{className:"text-[#94a3b8] mt-0.5",children:"•"})," ",e.jsx("span",{children:Ae})]},Ye))]})]},B.blockId))}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-4",children:[e.jsx(pt,{variant:"outline",onClick:()=>void rt(),disabled:$e||!C,className:"border-[#cbd5e1] text-[#475569] hover:bg-[#f8fafc] text-[12px] h-9 rounded-full px-5",children:$e?e.jsx(Ln,{className:"h-4 w-16"}):"Save Draft"}),e.jsx(pt,{onClick:()=>void Rt(),disabled:Qe||!C||!C.publishReady,className:"bg-[#10b981] hover:bg-[#059669] text-white text-[12px] h-9 rounded-full px-5",children:Qe?e.jsx(Ln,{className:"h-4 w-24 bg-white/35"}):"Publish Lesson Plan"})]})]})]})]})]})}),e.jsx("aside",{className:"w-[320px] 2xl:w-[340px] bg-white/70 backdrop-blur-[24px] border-l border-white shadow-[-4px_0_24px_rgba(0,0,0,0.02)] flex flex-col h-full shrink-0 overflow-y-auto z-10 no-scrollbar relative",children:e.jsxs("div",{className:"p-[24px] space-y-[24px] flex flex-col items-center",children:[e.jsxs("div",{className:"flex flex-col items-center text-center w-full",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-[96px] h-[96px] rounded-full object-cover shadow-[0_8px_16px_rgba(0,0,0,0.1)] mb-4 border-4 border-white z-10 relative"}),e.jsx("h2",{className:"text-[20px] font-semibold text-[#1e293b] mb-1",children:t.name}),e.jsxs("p",{className:"text-[11px] font-semibold text-[#64748b] mb-3 uppercase tracking-wider",children:["ID: ",t.id.substring(0,8)]}),e.jsx("span",{className:`text-[11px] font-semibold px-3 py-1 rounded-[14px] border ${t.riskLevel==="high"?"text-rose-600 bg-rose-50 border-rose-100":t.riskLevel==="medium"?"text-amber-600 bg-amber-50 border-amber-100":"text-emerald-600 bg-emerald-50 border-emerald-100"}`,children:t.riskLevel==="high"?"High Risk":t.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsxs("div",{className:"w-full grid grid-cols-2 gap-[12px]",children:[e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-[20px] font-bold text-[#4f46e5]",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Engagement"}),e.jsx("p",{className:"text-[20px] font-bold text-[#1e293b]",children:t.avgScore>80?"High":t.avgScore>50?"Medium":"Low"})]}),e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Last Active"}),e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] mt-1",children:t.lastActive})]}),e.jsxs("div",{className:"bg-rose-50/60 rounded-[14px] p-4 border border-rose-100 text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-rose-600 uppercase tracking-wider mb-1",children:"Weakest Topic"}),e.jsx("p",{className:"text-[12px] font-semibold text-[#1e293b] mt-1 leading-snug break-words",title:t.weakestTopic,children:t.weakestTopic})]})]}),e.jsx("div",{className:"w-full flex flex-col gap-[10px]",children:e.jsxs("button",{onClick:async()=>{J("choose"),R(!0)},className:"w-full flex items-center justify-center gap-2 bg-white hover:bg-[#f8fafc] text-[#475569] border border-[#cbd5e1] hover:border-[#94a3b8] text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-transform hover:scale-[1.02]",children:[e.jsx(Rc,{className:"w-4 h-4"})," Export Materials"]})}),E&&Ar.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",onClick:()=>R(!1),children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-[24px] shadow-[0_24px_64px_rgba(0,0,0,0.18)] w-full max-w-[460px] z-10 overflow-hidden",onClick:B=>B.stopPropagation(),children:[e.jsx("div",{className:"bg-gradient-to-r from-[#a855f7] to-[#9333ea] px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[X==="bank"&&e.jsx("button",{onClick:()=>J("choose"),className:"w-7 h-7 rounded-full bg-white/20 hover:bg-white/30 flex items-center justify-center text-white transition-colors mr-1",children:e.jsx(Ss,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-8 h-8 rounded-[8px] bg-white/20 flex items-center justify-center",children:e.jsx(Dr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[15px] font-bold text-white leading-tight",children:X==="choose"?"Export Materials":"Choose a Quiz"}),e.jsx("p",{className:"text-[11px] text-white/70 font-medium",children:X==="choose"?`For ${t.name}`:"Select a quiz from your bank"})]})]}),e.jsx("button",{onClick:()=>R(!1),className:"w-7 h-7 rounded-full bg-white/20 hover:bg-white/30 flex items-center justify-center text-white transition-colors",children:e.jsx(cs,{className:"w-4 h-4"})})]})}),e.jsx("div",{className:"p-6",children:X==="choose"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[13px] text-[#64748b] mb-5 font-medium",children:"How would you like to proceed?"}),e.jsxs("button",{onClick:async()=>{oe(!0),J("bank");try{const B=await ai(s);ce(B)}catch{ce([])}finally{oe(!1)}},className:"w-full flex items-start gap-4 p-4 rounded-[16px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_4px_12px_rgba(168,85,247,0.08)] hover:bg-purple-50/30 transition-all group mb-3 text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-[10px] bg-purple-50 border border-purple-100 flex items-center justify-center shrink-0 group-hover:bg-purple-100 transition-colors",children:e.jsx(Za,{className:"w-5 h-5 text-[#a855f7]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-0.5",children:"Choose from existing quizzes"}),e.jsx("p",{className:"text-[12px] text-[#64748b] font-medium",children:"Pick a quiz already in your Quiz Bank."})]})]}),e.jsxs("button",{onClick:()=>{R(!1),he(!1),we(!0)},className:"w-full flex items-start gap-4 p-4 rounded-[16px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_4px_12px_rgba(168,85,247,0.08)] hover:bg-purple-50/30 transition-all group text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-[10px] bg-purple-50 border border-purple-100 flex items-center justify-center shrink-0 group-hover:bg-purple-100 transition-colors",children:e.jsx($s,{className:"w-5 h-5 text-[#a855f7]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-0.5",children:"Create a new quiz"}),e.jsx("p",{className:"text-[12px] text-[#64748b] font-medium",children:"Use AI Quiz Maker. You can return here when done."})]})]})]}):e.jsx("div",{children:$?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-[#a855f7] border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-[13px] text-[#64748b] font-medium",children:"Loading quizzes..."})]}):ne.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-purple-50 flex items-center justify-center",children:e.jsx(Za,{className:"w-6 h-6 text-[#a855f7]"})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:"No quizzes yet"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Create your first quiz using the AI Quiz Maker."})]}):e.jsx("div",{className:"space-y-3 max-h-[320px] overflow-y-auto pr-1",children:ne.map(B=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 rounded-[14px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_2px_8px_rgba(168,85,247,0.08)] transition-all group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-bold text-[#1e293b] truncate",children:B.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] font-medium mt-0.5",children:[B.questions?.length??0," questions",B.gradeLevel?` · ${B.gradeLevel}`:"",B.metadata?.topicsCovered?.[0]?` · ${B.metadata.topicsCovered[0]}`:""]})]}),e.jsx("button",{onClick:()=>{R(!1),me.success(`"${B.title}" selected for ${t.name}`)},className:"shrink-0 px-3 py-1.5 rounded-full bg-[#a855f7] text-white text-[11px] font-bold hover:bg-[#9333ea] transition-colors shadow-sm",children:"Assign"})]},B.id))})})})]})]}),document.body),xe&&Ar.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/40 backdrop-blur-sm",onClick:()=>{te?Fe(!0):we(!1)}}),e.jsxs("div",{className:"fixed top-0 right-0 z-[9999] h-full w-full max-w-[88vw] xl:max-w-[1080px] bg-white shadow-[-8px_0_40px_rgba(0,0,0,0.15)] flex flex-col",style:{animation:"slideInFromRight 0.3s cubic-bezier(0.16,1,0.3,1)"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-slate-100 bg-white shrink-0",children:[e.jsxs("button",{onClick:()=>{te?Fe(!0):we(!1)},className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-indigo-50 hover:bg-indigo-100 px-4 py-2 rounded-full",children:[e.jsx(Xa,{className:"w-4 h-4"}),"Back to ",t.name]}),e.jsx("div",{className:"h-5 w-px bg-slate-200"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-[8px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center",children:e.jsx(Dr,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:"text-[14px] font-bold text-[#1e293b]",children:"AI Quiz Maker"})]}),te&&e.jsx("span",{className:"ml-auto text-[11px] font-semibold text-amber-600 bg-amber-50 border border-amber-200 px-2.5 py-0.5 rounded-full",children:"Quiz in progress"})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Yi,{onBack:()=>we(!1),drawerMode:!0,gradeLevel:t.grade,onQuizGenerating:()=>he(!0),onQuizSaved:B=>{he(!1),me.success("Quiz saved! Close this panel or create another.",{action:{label:"Close Panel",onClick:()=>we(!1)}})}})})]}),et&&e.jsxs("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>Fe(!1)}),e.jsxs("div",{className:"relative bg-white rounded-[20px] shadow-[0_24px_60px_rgba(0,0,0,0.2)] w-full max-w-[380px] p-7 z-10",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-amber-50 border border-amber-200 flex items-center justify-center mb-4",children:e.jsx(or,{className:"w-5 h-5 text-amber-500"})}),e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b] mb-2",children:"Discard quiz progress?"}),e.jsx("p",{className:"text-[13px] text-[#64748b] font-medium mb-6",children:"Your current quiz session will be lost if you close this panel. This cannot be undone."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>Fe(!1),className:"flex-1 py-2.5 rounded-full border border-slate-200 text-[13px] font-semibold text-[#475569] hover:bg-slate-50 transition-colors",children:"Keep editing"}),e.jsx("button",{onClick:()=>{Fe(!1),we(!1),he(!1)},className:"flex-1 py-2.5 rounded-full bg-rose-500 hover:bg-rose-600 text-white text-[13px] font-semibold transition-colors",children:"Discard & close"})]})]})]}),e.jsx("style",{children:` + @keyframes slideInFromRight { + from { transform: translateX(100%); opacity: 0.6; } + to { transform: translateX(0); opacity: 1; } + } + `})]}),document.body),e.jsxs("div",{className:"w-full bg-white/80 rounded-[18px] p-[20px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-auto",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[#1e293b] mb-4",children:"Section Assignment"}),e.jsxs("div",{className:"space-y-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5 block ml-1",children:"Grade Level"}),e.jsx("div",{className:"relative",children:e.jsx(Ns,{value:j,onChange:B=>k(B.target.value),placeholder:"Grade",className:"appearance-none w-full bg-[#f8fafc] border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[14px] px-4 py-2.5 outline-none focus:border-[#a855f7] focus:ring-1 focus:ring-[#a855f7] h-auto"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5 block ml-1",children:"Section"}),e.jsx("div",{className:"relative",children:e.jsx(Ns,{value:p,onChange:B=>N(B.target.value),placeholder:"Section",className:"appearance-none w-full bg-[#f8fafc] border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[14px] px-4 py-2.5 outline-none focus:border-[#a855f7] focus:ring-1 focus:ring-[#a855f7] h-auto"})})]}),e.jsx("button",{onClick:as,disabled:I||!j.trim()||!p.trim(),className:"w-full bg-white hover:bg-[#f8fafc] disabled:opacity-50 text-[#4f46e5] border border-[#e0e7ff] text-[13px] font-semibold rounded-[14px] px-4 py-2.5 transition-colors shadow-[0_1px_4px_rgba(0,0,0,0.02)] mt-2",children:I?"Updating...":"Update Assignment"})]})]})]})})]})},Yo=({onViewCalendar:t,onOpenProfile:s,userProfile:a,teacherName:r,liveActivity:o=[]})=>{const{currentUser:n}=ds(),[i,l]=u.useState(new Date),[c,d]=u.useState("pulse"),[m,f]=u.useState([]),[h,b]=u.useState(!1);u.useEffect(()=>{if(!n?.uid)return;const w=Ji(n.uid,{limitCount:100},z=>f(z),()=>{});return()=>w()},[n?.uid]);const y=w=>new Date(w.getFullYear(),w.getMonth()+1,0).getDate(),j=w=>new Date(w.getFullYear(),w.getMonth(),1).getDay(),k=()=>i.toLocaleDateString(void 0,{month:"long",year:"numeric"}),p=()=>l(new Date(i.getFullYear(),i.getMonth()-1)),N=()=>l(new Date(i.getFullYear(),i.getMonth()+1)),I=()=>{const w=y(i),z=j(i),O=[];for(let T=z-1;T>=0;T--)O.unshift(null);for(let T=1;T<=w;T++)O.push(T);return O},A=w=>{if(!w)return!1;const z=new Date;return w===z.getDate()&&i.getMonth()===z.getMonth()&&i.getFullYear()===z.getFullYear()},C=I(),U=["Mo","Tu","We","Th","Fr","Sa","Su"],v=w=>{if(!w)return!1;const z=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(w).padStart(2,"0")}`;return m.some(O=>{const T=new Date(O.startTime);return`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`===z})},S=w=>{if(!w)return;const z=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(w).padStart(2,"0")}`,O=m.filter(T=>{const G=new Date(T.startTime);return`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}`===z});if(O.length!==0)return O.map(T=>`• ${T.title}`).join(` +`)};return e.jsxs("aside",{className:"w-[280px] bg-white border-l border-[#e2e8f0] flex flex-col flex-shrink-0 overflow-hidden",children:[e.jsxs("div",{className:"p-[22px_16px_10px] border-b border-[#f1f5f9] flex flex-col items-center gap-[5px]",children:[e.jsx("div",{className:"w-[48px] h-[48px] rounded-full bg-[#e0e7ff] flex items-center justify-center text-[22px] text-[#4f46e5] shadow-[0_0_0_3px_#c7d2fe] flex-shrink-0",children:e.jsx(kl,{src:a?.photo,name:r,className:"w-full h-full rounded-full"})}),e.jsx("div",{className:"text-[13.5px] font-semibold text-[#1e293b] mt-1",children:r}),e.jsx("div",{className:"text-[11px] text-[#94a3b8]",children:"Teacher"}),e.jsx("button",{onClick:s,className:"mt-[4px] py-[6px] px-[22px] bg-[#818cf8] hover:bg-[#6366f1] text-white rounded-full text-[11.5px] font-medium transition-colors",children:"Profile"})]}),e.jsxs("div",{className:"border-b border-[#f1f5f9]",children:[e.jsxs("div",{className:"p-[10px_16px_8px] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:w=>{w.stopPropagation(),p()},className:"w-6 h-6 flex items-center justify-center bg-white border border-[#e2e8f0] rounded-[7px] text-[#64748b] hover:bg-[#f8fafc] cursor-pointer text-[14px] z-10",children:e.jsx(Ss,{size:14})}),e.jsx("span",{className:"text-[12px] font-semibold text-[#1e293b] hover:text-[#4f46e5] transition-colors cursor-pointer",onClick:t,children:k()}),e.jsx("button",{onClick:w=>{w.stopPropagation(),N()},className:"w-6 h-6 flex items-center justify-center bg-white border border-[#e2e8f0] rounded-[7px] text-[#64748b] hover:bg-[#f8fafc] cursor-pointer text-[14px] z-10",children:e.jsx(ys,{size:14})})]}),e.jsx("button",{onClick:()=>b(w=>!w),className:"w-6 h-6 flex items-center justify-center rounded-[7px] text-[#94a3b8] hover:bg-[#f1f5f9] hover:text-[#64748b] transition-colors",title:h?"Show calendar":"Hide calendar","aria-label":h?"Expand calendar":"Collapse calendar",children:e.jsx(Tt,{size:14,className:`transition-transform duration-200 ${h?"":"rotate-180"}`})})]}),e.jsx(Et,{initial:!1,children:!h&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22,ease:"easeInOut"},className:"overflow-hidden",children:e.jsx("div",{className:"px-[16px] pb-[10px] cursor-pointer hover:bg-slate-50 transition-colors group/cal",onClick:t,children:e.jsxs("div",{className:"grid grid-cols-7 gap-[2px] text-center mb-1",children:[U.map(w=>e.jsx("div",{className:"text-[10px] font-semibold text-[#94a3b8] p-[2px_0_4px]",children:w},w)),C.map((w,z)=>e.jsxs("div",{className:"relative flex flex-col items-center justify-center h-[28px]",title:S(w),children:[e.jsx("div",{className:`text-[11px] leading-[22px] w-[22px] h-[22px] flex items-center justify-center rounded-full transition-all ${w===null?"text-[#cbd5e1]":A(w)?"bg-[#818cf8] text-white font-semibold":"text-[#475569] group-hover/cal:bg-slate-100"}`,children:w}),w!==null&&v(w)&&e.jsx("div",{className:`absolute bottom-0 w-1 h-1 rounded-full ${A(w)?"bg-white":"bg-[#a855f7]"}`})]},`${i.getMonth()}-${z}`))]})})},"cal-grid")})]}),e.jsxs("div",{className:"flex gap-[18px] p-[12px_16px_0] border-b border-[#f1f5f9] flex-shrink-0",children:[e.jsx("button",{onClick:()=>d("pulse"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${c==="pulse"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Live pulse"}),e.jsx("button",{onClick:()=>d("reminders"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${c==="reminders"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Reminders"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-[14px_16px]",children:[c==="pulse"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[10px] font-bold text-[#64748b] uppercase tracking-wider",children:"Live Activity Stream"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[9px] font-bold text-emerald-600",children:"LIVE"})]})]}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center opacity-40",children:[e.jsx(si,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#1e293b]",children:"No recent activity"})]}):e.jsx("div",{className:"space-y-4",children:o.slice(0,5).map(w=>e.jsxs("div",{className:"relative pl-5 before:absolute before:left-1.5 before:top-2 before:bottom-[-16px] before:w-[1px] before:bg-slate-100 last:before:hidden",children:[e.jsx("div",{className:"absolute left-0 top-1.5 w-3 h-3 rounded-full border-2 border-white bg-indigo-500 shadow-sm z-10"}),e.jsxs("div",{className:"bg-white border border-[#f1f5f9] rounded-xl p-3 shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsx("span",{className:"text-[12px] font-bold text-[#1e293b] truncate",children:w.student}),e.jsx("span",{className:"text-[9px] font-medium text-[#94a3b8] shrink-0",children:w.time})]}),e.jsxs("p",{className:"text-[11px] text-[#64748b] leading-snug",children:[w.action," ",e.jsx("span",{className:"font-bold text-[#4f46e5]",children:w.topic})]})]})]},w.id))})]}),c==="reminders"&&e.jsxs("div",{className:"space-y-3",children:[m.filter(w=>{const z=new Date;return z.setHours(0,0,0,0),new Date(w.startTime).getTime()>=z.getTime()}).sort((w,z)=>new Date(w.startTime).getTime()-new Date(z.startTime).getTime()).slice(0,5).map(w=>{const z=new Date(w.startTime).toDateString()===new Date().toDateString();return e.jsxs("div",{onClick:t,className:"flex items-start gap-3 p-3 border border-[#f1f5f9] rounded-[14px] cursor-pointer hover:bg-slate-50 transition-colors group",children:[e.jsx("div",{className:`p-2 rounded-xl border border-[#f1f5f9] bg-white text-[14px] flex-shrink-0 shadow-sm transition-transform group-hover:scale-105 ${z?"text-rose-500":"text-[#4f46e5]"}`,children:e.jsx(Ya,{size:14})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-bold text-[#1e293b] mb-0.5 truncate",children:w.title}),e.jsxs("div",{className:`text-[10px] font-medium ${z?"text-rose-500 font-bold":"text-[#94a3b8]"}`,children:[z?"Today, ":"",new Date(w.startTime).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]},w.id)}),m.filter(w=>new Date(w.startTime).getTime()>=new Date().setHours(0,0,0,0)).length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center opacity-40",children:[e.jsx(Ja,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#1e293b]",children:"No upcoming tasks"})]})]})]})]})};export{bp as default}; diff --git a/assets/TeacherDashboard-MZLi5zPU.js b/assets/TeacherDashboard-MZLi5zPU.js deleted file mode 100644 index 9850471e71f4f341d7209c6842ce5db1e4c548ee..0000000000000000000000000000000000000000 --- a/assets/TeacherDashboard-MZLi5zPU.js +++ /dev/null @@ -1,109 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{e as ht,t as gl,f as jn,g as Ve,_ as _r,u as ds,h as Et,m as Re,i as Ko,j as me,k as bl,l as nt,n as Xo,a as Gt,G as Jo,B as Mr,Z as vl,o as qa,p as dt,A as Zo,U as os,q as vs,T as Ta,r as Ga,C as wl,v as yn,R as zs,w as Nl,x as Xs,y as Sn,z as kn,D as ei,E as jl,F as Ya,H as yl,M as Sl,I as Cn,J as kl,K as Cl}from"./index-dPnhhJ9w.js";import{d as de,j as e,r as m,c as Ar}from"./vendor-react-B4AQeu28.js";import{B as xt,c as Il}from"./button-WbM5w2Bp.js";import{I as ws}from"./input-BUQJctP7.js";import Tl from"./ConfirmModal-CtRcSVjb.js";import{collection as $t,query as kt,limit as Vr,where as jt,getDocs as Dt,doc as pt,getDoc as js,updateDoc as Zt,serverTimestamp as lt,setDoc as is,Timestamp as El,orderBy as Rl,onSnapshot as ti,deleteDoc as _l}from"./vendor-firebase-firestore-CNv3xXal.js";import{X as cs}from"./x-Ck4mo_h-.js";import{S as Os}from"./search-DqYX8akO.js";import{C as Mt}from"./check-CAUeuCaw.js";import{P as Js}from"./plus-BIEera7J.js";import{I as ga,F as gs,N as Ml,A as si}from"./NotificationDropdown-CMhB7x-Z.js";import{M as Al,L as zl,D as Ll,S as Dl,a as $l}from"./LogoutActionButton-USB3vnm6.js";import{s as In,f as ai,L as Ka,d as Fl,p as Ol,a as Bl,A as Xa,P as Pl,b as Hl}from"./quizService-DyO77cdL.js";import{S as Gl}from"./vendor-radix-BPuEd8FG.js";import{T as Ql,a as Ul,b as Vl}from"./tooltip-Dz2m8mUv.js";import{C as Wl}from"./circle-help-BkKMcGF2.js";import{E as ql,a as Yl}from"./eye-BmZ1sFKD.js";import{S as La}from"./send-C3s19g5N.js";import{T as ri}from"./trash-2-BCXZR1t7.js";import{C as or}from"./circle-alert-DCyh_PVA.js";import{C as Tt,a as wa}from"./chevron-up-D9yeZehY.js";import{M as Tn}from"./minus-BpJABcv4.js";import{C as Ds}from"./chart-column-DtQRo3DE.js";import{C as zr,H as En}from"./history-CL_DqqWk.js";import{D as Kl}from"./download-B80nBe--.js";import{C as Ss}from"./chevron-left-DfHtS3Om.js";import{C as ys}from"./chevron-right-DL17FiOB.js";import{S as ni}from"./save-DxX0wJjA.js";import{C as Wr}from"./circle-check-BjsGkfB1.js";import{S as $s}from"./sparkles-DPFO64ZX.js";import{U as Rn}from"./upload-Dezt40XU.js";import{u as Xl}from"./useQuery-C1X-hCq5.js";import{S as _n,g as Jl,G as Zl,s as Mn}from"./subjects-DzQfiusb.js";import{u as ec}from"./useCurriculum-BbSzWiM_.js";import{C as qr}from"./circle-check-big-DJBKLvuw.js";import tc from"./ChatMarkdown-3H5bHtZy.js";import{c as sc,a as oi,C as ac,f as rc}from"./formatDistanceToNow-JAG-bydR.js";import{C as Zs}from"./clock-Dy5eVj9o.js";import{B as Ja}from"./bell-cxZiilDJ.js";import{D as An,a as zn,b as nc,c as oc,d as ic,S as lc}from"./dialog-C4ok-Axi.js";import{S as Ln}from"./skeleton-BOUN1xTD.js";import{u as Vt,r as cc}from"./vendor-xlsx-uZelXSz_.js";import{C as ii}from"./clipboard-check-DfL2oC8x.js";import{R as Dn,B as $n,C as Fn,X as On,Y as Bn,T as Pn,a as Hn,b as Gn}from"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-markdown-yqZQ_iQm.js";import"./log-out-BUfoSJF2.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 dc=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],mc=ht("align-left",dc);/** - * @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 uc=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],br=ht("calendar-days",uc);/** - * @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 xc=[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]],pc=ht("chart-no-axes-column",xc);/** - * @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 hc=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],fc=ht("ellipsis-vertical",hc);/** - * @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 gc=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Lr=ht("ellipsis",gc);/** - * @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 bc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],vc=ht("external-link",bc);/** - * @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 wc=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],Nc=ht("file-spreadsheet",wc);/** - * @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 jc=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Za=ht("library",jc);/** - * @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 yc=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],li=ht("list-checks",yc);/** - * @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 Sc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],kc=ht("panel-right",Sc);/** - * @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 Cc=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Ic=ht("pen-line",Cc);/** - * @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 Tc=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ci=ht("pen",Tc);/** - * @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 Ec=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Rc=ht("printer",Ec);/** - * @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 _c=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],Mc=ht("scan-line",_c);/** - * @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 Ac=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],zc=ht("table",Ac);/** - * @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 Lc=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],di=ht("trending-down",Lc);/** - * @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 Dc=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Qn=ht("video",Dc);/** - * @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 $c=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Dr=ht("wand-sparkles",$c);function Fc(t,s){const a=gl(t);return isNaN(s)?sc(t,NaN):(a.setDate(a.getDate()+s),a)}function mi(t,s){const a=jn(t),r=jn(s);return+a==+r}function Un(t){return mi(t,oi(t))}function Oc(t,s){return Fc(t,-1)}function Vn(t){return mi(t,Oc(oi(t)))}const ir=0,Cs=1,ea=2,ui=4;function Wn(t){return()=>t}function Bc(t){t()}function xi(t,s){return a=>t(s(a))}function qn(t,s){return()=>t(s)}function Pc(t,s){return a=>t(s,a)}function Yr(t){return t!==void 0}function Hc(...t){return()=>{t.map(Bc)}}function ta(){}function lr(t,s){return s(t),t}function Gc(t,s){return s(t)}function Ze(...t){return t}function Ue(t,s){return t(Cs,s)}function Ie(t,s){t(ir,s)}function Kr(t){t(ea)}function tt(t){return t(ui)}function ue(t,s){return Ue(t,Pc(s,ir))}function es(t,s){const a=t(Cs,r=>{a(),s(r)});return a}function Yn(t){let s,a;return r=>o=>{s=o,a&&clearTimeout(a),a=setTimeout(()=>{r(s)},t)}}function pi(t,s){return t===s}function Je(t=pi){let s;return a=>r=>{t(s,r)||(s=r,a(r))}}function ve(t){return s=>a=>{t(a)&&s(a)}}function ie(t){return s=>xi(s,t)}function rs(t){return s=>()=>{s(t)}}function Q(t,...s){const a=Qc(...s);return((r,o)=>{switch(r){case ea:Kr(t);return;case Cs:return Ue(t,a(o))}})}function ns(t,s){return a=>r=>{a(s=t(s,r))}}function Fs(t){return s=>a=>{t>0?t--:s(a)}}function bs(t){let s=null,a;return r=>o=>{s=o,!a&&(a=setTimeout(()=>{a=void 0,r(s)},t))}}function Te(...t){const s=new Array(t.length);let a=0,r=null;const o=2**t.length-1;return t.forEach((n,i)=>{const l=2**i;Ue(n,c=>{const d=a;a|=l,s[i]=c,d!==o&&a===o&&r&&(r(),r=null)})}),n=>i=>{const l=()=>{n([i].concat(s))};a===o?l():r=l}}function Qc(...t){return s=>t.reduceRight(Gc,s)}function Uc(t){let s,a;const r=()=>s?.();return function(o,n){switch(o){case Cs:return n?a===n?void 0:(r(),a=n,s=Ue(t,n),s):(r(),ta);case ea:r(),a=null;return}}}function W(t){let s=t;const a=Le();return((r,o)=>{switch(r){case ir:s=o;break;case Cs:{o(s);break}case ui:return s}return a(r,o)})}function yt(t,s){return lr(W(s),a=>ue(t,a))}function Le(){const t=[];return((s,a)=>{switch(s){case ir:t.slice().forEach(r=>{r(a)});return;case ea:t.splice(0,t.length);return;case Cs:return t.push(a),()=>{const r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function zt(t){return lr(Le(),s=>ue(t,s))}function He(t,s=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:s,id:Vc(),singleton:a}}const Vc=()=>Symbol();function Wc(t){const s=new Map,a=({constructor:r,dependencies:o,id:n,singleton:i})=>{if(i&&s.has(n))return s.get(n);const l=r(o.map(c=>a(c)));return i&&s.set(n,l),l};return a(t)}function ct(...t){const s=Le(),a=new Array(t.length);let r=0;const o=2**t.length-1;return t.forEach((n,i)=>{const l=2**i;Ue(n,c=>{a[i]=c,r|=l,r===o&&Ie(s,a)})}),function(n,i){switch(n){case ea:{Kr(s);return}case Cs:return r===o&&i(a),Ue(s,i)}}}function be(t,s=pi){return Q(t,Je(s))}function $r(...t){return function(s,a){switch(s){case ea:return;case Cs:return Hc(...t.map(r=>Ue(r,a)))}}}const ut={DEBUG:0,INFO:1,WARN:2,ERROR:3},qc={[ut.DEBUG]:"debug",[ut.ERROR]:"error",[ut.INFO]:"log",[ut.WARN]:"warn"},Yc=()=>typeof globalThis>"u"?window:globalThis,Is=He(()=>{const t=W(ut.ERROR);return{log:W((s,a,r=ut.INFO)=>{const o=Yc().VIRTUOSO_LOG_LEVEL??tt(t);r>=o&&console[qc[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",s,a)}),logLevel:t}},[],{singleton:!0});function Bs(t,s,a){return Xr(t,s,a).callbackRef}function Xr(t,s,a){const r=de.useRef(null);let o=i=>{};const n=de.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const c=i[0].target;c.offsetParent!==null&&t(c)};a?l():requestAnimationFrame(l)}):null,[t,a]);return o=i=>{i&&s?(n?.observe(i),r.current=i):(r.current&&n?.unobserve(r.current),r.current=null)},{callbackRef:o,ref:r}}function Kc(t,s,a,r,o,n,i,l,c){const d=de.useCallback(u=>{const f=Xc(u.children,s,l?"offsetWidth":"offsetHeight",o);let h=u.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const b=h.lastElementChild.dataset.viewportType==="window";let k;b&&(k=h.ownerDocument.defaultView);const j=i?l?i.scrollLeft:i.scrollTop:b?l?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:l?h.scrollLeft:h.scrollTop,S=i?l?i.scrollWidth:i.scrollHeight:b?l?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:l?h.scrollWidth:h.scrollHeight,p=i?l?i.offsetWidth:i.offsetHeight:b?l?k.innerWidth:k.innerHeight:l?h.offsetWidth:h.offsetHeight;r({scrollHeight:S,scrollTop:Math.max(j,0),viewportHeight:p}),n?.(l?Kn("column-gap",getComputedStyle(u).columnGap,o):Kn("row-gap",getComputedStyle(u).rowGap,o)),f!==null&&t(f)},[t,s,o,n,i,r,l]);return Xr(d,a,c)}function Xc(t,s,a,r){const o=t.length;if(o===0)return null;const n=[];for(let i=0;i{if(!c?.offsetParent)return;const d=c.getBoundingClientRect(),u=d.width;let f,h;if(s){const b=s.getBoundingClientRect(),k=d.top-b.top;h=b.height-Math.max(0,k),f=k+s.scrollTop}else{const b=i.current.ownerDocument.defaultView;h=b.innerHeight-Math.max(0,d.top),f=d.top+b.scrollY}r.current={listHeight:d.height,offsetTop:f,visibleHeight:h,visibleWidth:u},t(r.current)},[t,s]),{callbackRef:n,ref:i}=Xr(o,!0,a),l=de.useCallback(()=>{o(i.current)},[o,i]);return de.useEffect(()=>{if(s){s.addEventListener("scroll",l);const d=new ResizeObserver(()=>{requestAnimationFrame(l)});return d.observe(s),()=>{s.removeEventListener("scroll",l),d.unobserve(s)}}const c=i.current?.ownerDocument.defaultView;return c?.addEventListener("scroll",l),c?.addEventListener("resize",l),()=>{c?.removeEventListener("scroll",l),c?.removeEventListener("resize",l)}},[l,s,i]),n}const Ct=He(()=>{const t=Le(),s=Le(),a=W(0),r=Le(),o=W(0),n=Le(),i=Le(),l=W(0),c=W(0),d=W(0),u=W(0),f=Le(),h=Le(),b=W(!1),k=W(!1),j=W(!1);return ue(Q(t,ie(({scrollTop:S})=>S)),s),ue(Q(t,ie(({scrollHeight:S})=>S)),i),ue(s,o),{deviation:a,fixedFooterHeight:d,fixedHeaderHeight:c,footerHeight:u,headerHeight:l,horizontalDirection:k,scrollBy:h,scrollContainerState:t,scrollHeight:i,scrollingInProgress:b,scrollTo:f,scrollTop:s,skipAnimationFrameInResizeObserver:j,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:n}},[],{singleton:!0}),Na={lvl:0};function fi(t,s){const a=t.length;if(a===0)return[];let{index:r,value:o}=s(t[0]);const n=[];for(let i=1;is&&(l=l.concat(Or(o,s,a))),r>=s&&r<=a&&l.push({k:r,v:i}),r<=a&&(l=l.concat(Or(n,s,a))),l}function Qa(t){const{l:s,lvl:a,r}=t;if(r.lvl>=a-1&&s.lvl>=a-1)return t;if(a>r.lvl+1){if(vr(s))return wi(mt(t,{lvl:a-1}));if(!qe(s)&&!qe(s.r))return mt(s.r,{l:mt(s,{r:s.r.l}),lvl:a,r:mt(t,{l:s.r.r,lvl:a-1})});throw new Error("Unexpected empty nodes")}if(vr(t))return Br(mt(t,{lvl:a-1}));if(!qe(r)&&!qe(r.l)){const o=r.l,n=vr(o)?r.lvl-1:r.lvl;return mt(o,{l:mt(t,{lvl:a-1,r:o.l}),lvl:o.lvl+1,r:Br(mt(r,{l:o.r,lvl:n}))})}throw new Error("Unexpected empty nodes")}function mt(t,s){return vi(s.k!==void 0?s.k:t.k,s.v!==void 0?s.v:t.v,s.lvl!==void 0?s.lvl:t.lvl,s.l!==void 0?s.l:t.l,s.r!==void 0?s.r:t.r)}function gi(t){return qe(t.r)?t.l:Qa(mt(t,{r:gi(t.r)}))}function vr(t){return qe(t)||t.lvl>t.r.lvl}function bi(t){return qe(t.r)?[t.k,t.v]:bi(t.r)}function vi(t,s,a,r=Na,o=Na){return{k:t,l:r,lvl:a,r:o,v:s}}function Xn(t){return Br(wi(t))}function wi(t){const{l:s}=t;return!qe(s)&&s.lvl===t.lvl?mt(s,{r:mt(t,{l:s.r})}):t}function Br(t){const{lvl:s,r:a}=t;return!qe(a)&&!qe(a.r)&&a.lvl===s&&a.r.lvl===s?mt(a,{l:mt(t,{r:a.l}),lvl:s+1}):t}function Jc(t){return fi(t,({k:s,v:a})=>({index:s,value:a}))}function Ni(t,s){return!!(t&&t.startIndex===s.startIndex&&t.endIndex===s.endIndex)}function ya(t,s){return!!(t&&t[0]===s[0]&&t[1]===s[1])}const Jr=He(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function ji(t,s,a){return t[er(t,s,a)]}function er(t,s,a,r=0){let o=t.length-1;for(;r<=o;){const n=Math.floor((r+o)/2),i=t[n],l=a(i,s);if(l===0)return n;if(l===-1){if(o-r<2)return n-1;o=n-1}else{if(o===r)return n;r=n+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${s}`)}function Zc(t,s,a,r){const o=er(t,s,r),n=er(t,a,r,o);return t.slice(o,n+1)}function ks(t,s){return Math.round(t.getBoundingClientRect()[s])}function cr(t){return!qe(t.groupOffsetTree)}function Zr({index:t},s){return s===t?0:s=f||n===h)&&(t=Fr(t,f)):(d=h!==n,c=!0),u>o&&o>=f&&h!==n&&(t=At(t,o+1,h));d&&(t=At(t,i,n))}return[t,a]}function sd(t){return typeof t.groupIndex<"u"}function ad({offset:t},s){return s===t?0:s0?l+a:l}function yi(t,s){if(!cr(s))return t;let a=0;for(;s.groupIndices[a]<=t+a;)a++;return t+a}function Si(t,s,a){if(sd(t))return s.groupIndices[t.groupIndex]+1;const r=t.index==="LAST"?a:t.index;let o=yi(r,s);return o=Math.max(0,o,Math.min(a,o)),o}function rd(t,s,a,r=0){return r>0&&(s=Math.max(s,ji(t,r,Zr).offset)),fi(Zc(t,s,a,ad),id)}function nd(t,[s,a,r,o]){s.length>0&&r("received item sizes",s,ut.DEBUG);const n=t.sizeTree;let i=n,l=0;if(a.length>0&&qe(n)&&s.length===2){const h=s[0].size,b=s[1].size;i=a.reduce((k,j)=>At(At(k,j,h),j+1,b),i)}else[i,l]=td(i,s);if(i===n)return t;const{lastIndex:c,lastOffset:d,lastSize:u,offsetTree:f}=Pr(t.offsetTree,l,i,o);return{groupIndices:a,groupOffsetTree:a.reduce((h,b)=>At(h,b,Sa(b,f,o)),Ys()),lastIndex:c,lastOffset:d,lastSize:u,offsetTree:f,sizeTree:i}}function od(t){return Ls(t).map(({k:s,v:a},r,o)=>{const n=o[r+1];return{endIndex:n!==void 0?n.k-1:1/0,size:a,startIndex:s}})}function Jn(t,s){let a=0,r=0;for(;ao.start===r&&(o.end===s||o.end===1/0)&&o.value===a}const cd={offsetHeight:"height",offsetWidth:"width"},ms=He(([{log:t},{recalcInProgress:s}])=>{const a=Le(),r=Le(),o=yt(r,0),n=Le(),i=Le(),l=W(0),c=W([]),d=W(void 0),u=W(void 0),f=W(void 0),h=W(void 0),b=W((v,y)=>ks(v,cd[y])),k=W(void 0),j=W(0),S=ed(),p=yt(Q(a,Te(c,t,j),ns(nd,S),Je()),S),N=yt(Q(c,Je(),ns((v,y)=>({current:y,prev:v.current}),{current:[],prev:[]}),ie(({prev:v})=>v)),[]);ue(Q(c,ve(v=>v.length>0),Te(p,j),ie(([v,y,w])=>{const A=v.reduce((B,E,F)=>At(B,E,Sa(E,y.offsetTree,w)||F),Ys());return{...y,groupIndices:v,groupOffsetTree:A}})),p),ue(Q(r,Te(p),ve(([v,{lastIndex:y}])=>v[{endIndex:y,size:w,startIndex:v}])),a),ue(d,u);const C=yt(Q(d,ie(v=>v===void 0)),!0);ue(Q(u,ve(v=>v!==void 0&&qe(tt(p).sizeTree)),ie(v=>{const y=tt(f),w=tt(c).length>0;return y!==void 0&&y!==0?w?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:v,startIndex:1}]:[]:[{endIndex:0,size:v,startIndex:0}]})),a),ue(Q(h,ve(v=>v!==void 0&&v.length>0&&qe(tt(p).sizeTree)),ie(v=>{const y=[];let w=v[0],A=0;for(let B=1;Bv!==void 0&&y!==void 0),ie(([v,y,w])=>{const A=[];for(let B=0;B({changed:w!==v,sizes:w}),{changed:!1,sizes:S}),ie(v=>v.changed)));Ue(Q(l,ns((v,y)=>({diff:v.prev-y,prev:y}),{diff:0,prev:0}),ie(v=>v.diff)),v=>{const{groupIndices:y}=tt(p);if(v>0)Ie(s,!0),Ie(n,v+Jn(v,y));else if(v<0){const w=tt(N);w.length>0&&(v-=Jn(-v,w)),Ie(i,v)}}),Ue(Q(l,Te(t)),([v,y])=>{v<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},ut.ERROR)});const I=zt(n);ue(Q(n,Te(p),ie(([v,y])=>{const w=y.groupIndices.length>0,A=[],B=y.lastSize;if(w){const E=ja(y.sizeTree,0);let F=0,X=0;for(;F{let he=ce.ranges;return ce.prevSize!==0&&(he=[...ce.ranges,{endIndex:ne+v-1,size:ce.prevSize,startIndex:ce.prevIndex}]),{prevIndex:ne+v,prevSize:xe,ranges:he}},{prevIndex:v,prevSize:0,ranges:A}).ranges}return Ls(y.sizeTree).reduce((E,{k:F,v:X})=>({prevIndex:F+v,prevSize:X,ranges:[...E.ranges,{endIndex:F+v-1,size:E.prevSize,startIndex:E.prevIndex}]}),{prevIndex:0,prevSize:B,ranges:[]}).ranges})),a);const U=zt(Q(i,Te(p,j),ie(([v,{offsetTree:y},w])=>{const A=-v;return Sa(A,y,w)})));return ue(Q(i,Te(p,j),ie(([v,y,w])=>{if(y.groupIndices.length>0){if(qe(y.sizeTree))return y;let B=Ys();const E=tt(N);let F=0,X=0,J=0;for(;F<-v;){J=E[X];const ce=E[X+1]-J-1;X++,F+=ce+1}if(B=Ls(y.sizeTree).reduce((ce,{k:ne,v:xe})=>At(ce,Math.max(0,ne+v),xe),B),F!==-v){const ce=ja(y.sizeTree,J);B=At(B,0,ce);const ne=ts(y.sizeTree,-v+1)[1];B=At(B,1,ne)}return{...y,sizeTree:B,...Pr(y.offsetTree,0,B,w)}}const A=Ls(y.sizeTree).reduce((B,{k:E,v:F})=>At(B,Math.max(0,E+v),F),Ys());return{...y,sizeTree:A,...Pr(y.offsetTree,0,A,w)}})),p),{beforeUnshiftWith:I,data:k,defaultItemSize:u,firstItemIndex:l,fixedItemSize:d,fixedGroupSize:f,gap:j,groupIndices:c,heightEstimates:h,itemSize:b,listRefresh:z,shiftWith:i,shiftWithOffset:U,sizeRanges:a,sizes:p,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:n}},Ze(Is,Jr),{singleton:!0});function dd(t){return t.reduce((s,a)=>(s.groupIndices.push(s.totalCount),s.totalCount+=a+1,s),{groupIndices:[],totalCount:0})}const ki=He(([{groupIndices:t,sizes:s,totalCount:a},{headerHeight:r,scrollTop:o}])=>{const n=Le(),i=Le(),l=zt(Q(n,ie(dd)));return ue(Q(l,ie(c=>c.totalCount)),a),ue(Q(l,ie(c=>c.groupIndices)),t),ue(Q(ct(o,s,r),ve(([c,d])=>cr(d)),ie(([c,d,u])=>ts(d.groupOffsetTree,Math.max(c-u,0),"v")[0]),Je(),ie(c=>[c])),i),{groupCounts:n,topItemsIndexes:i}},Ze(ms,Ct)),Ts=He(([{log:t}])=>{const s=W(!1),a=zt(Q(s,ve(r=>r),Je()));return Ue(s,r=>{r&&tt(t)("props updated",{},ut.DEBUG)}),{didMount:a,propsReady:s}},Ze(Is),{singleton:!0}),md=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ci(t){const s=typeof t=="number"?{index:t}:t;return s.align||(s.align="start"),(!s.behavior||!md)&&(s.behavior="auto"),s.offset===void 0&&(s.offset=0),s}const Ea=He(([{gap:t,listRefresh:s,sizes:a,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:n,footerHeight:i,headerHeight:l,scrollingInProgress:c,scrollTo:d,smoothScrollTargetReached:u,viewportHeight:f},{log:h}])=>{const b=Le(),k=Le(),j=W(0);let S=null,p=null,N=null;function C(){S!==null&&(S(),S=null),N!==null&&(N(),N=null),p&&(clearTimeout(p),p=null),Ie(c,!1)}return ue(Q(b,Te(a,f,r,j,l,i,h),Te(t,n,o),ie(([[z,I,U,v,y,w,A,B],E,F,X])=>{const J=Ci(z),{align:ce,behavior:ne,offset:xe}=J,he=v-1,H=Si(J,I,he);let q=Sa(H,I.offsetTree,E)+w;ce==="end"?(q+=F+ts(I.sizeTree,H)[1]-U+X,H===he&&(q+=A)):ce==="center"?q+=(F+ts(I.sizeTree,H)[1]-U+X)/2:q-=y,xe!==void 0&&xe!==0&&(q+=xe);const M=Y=>{C(),Y?(B("retrying to scroll to",{location:z},ut.DEBUG),Ie(b,z)):(Ie(k,!0),B("list did not change, scroll successful",{},ut.DEBUG))};if(C(),ne==="smooth"){let Y=!1;N=Ue(s,ae=>{Y=Y||ae}),S=es(u,()=>{M(Y)})}else S=es(Q(s,ud(150)),M);return p=setTimeout(()=>{C()},1200),Ie(c,!0),B("scrolling from index to",{behavior:ne,index:H,top:q},ut.DEBUG),{behavior:ne,top:q}})),d),{scrollTargetReached:k,scrollToIndex:b,topListHeight:j}},Ze(ms,Ct,Is),{singleton:!0});function ud(t){return s=>{const a=setTimeout(()=>{s(!1)},t);return r=>{r&&(s(!0),clearTimeout(a))}}}function en(t,s){t===0?s():requestAnimationFrame(()=>{en(t-1,s)})}function tn(t,s){const a=s-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}const Ra=He(([{defaultItemSize:t,listRefresh:s,sizes:a},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:n},{didMount:i}])=>{const l=W(!0),c=W(0),d=W(!0);return ue(Q(i,Te(c),ve(([u,f])=>f!==0),rs(!1)),l),ue(Q(i,Te(c),ve(([u,f])=>f!==0),rs(!1)),d),Ue(Q(ct(s,i),Te(l,a,t,d),ve(([[,u],f,{sizeTree:h},b,k])=>u&&(!qe(h)||Yr(b))&&!f&&!k),Te(c)),([,u])=>{es(o,()=>{Ie(d,!0)}),en(4,()=>{es(r,()=>{Ie(l,!0)}),Ie(n,u)})}),{initialItemFinalLocationReached:d,initialTopMostItemIndex:c,scrolledToInitialItem:l}},Ze(ms,Ct,Ea,Ts),{singleton:!0});function Ii(t,s){return Math.abs(t-s)<1.01}const ka="up",ba="down",xd="none",pd={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},hd=0,_a=He(([{footerHeight:t,headerHeight:s,scrollBy:a,scrollContainerState:r,scrollTop:o,viewportHeight:n}])=>{const i=W(!1),l=W(!0),c=Le(),d=Le(),u=W(4),f=W(hd),h=yt(Q($r(Q(be(o),Fs(1),rs(!0)),Q(be(o),Fs(1),rs(!1),Yn(100))),Je()),!1),b=yt(Q($r(Q(a,rs(!0)),Q(a,rs(!1),Yn(200))),Je()),!1);ue(Q(ct(be(o),be(f)),ie(([N,C])=>N<=C),Je()),l),ue(Q(l,bs(50)),d);const k=zt(Q(ct(r,be(n),be(s),be(t),be(u)),ns((N,[{scrollHeight:C,scrollTop:z},I,U,v,y])=>{const w=z+I-C>-y,A={scrollHeight:C,scrollTop:z,viewportHeight:I};if(w){let E,F;return z>N.state.scrollTop?(E="SCROLLED_DOWN",F=N.state.scrollTop-z):(E="SIZE_DECREASED",F=N.state.scrollTop-z||N.scrollTopDelta),{atBottom:!0,atBottomBecause:E,scrollTopDelta:F,state:A}}let B;return A.scrollHeight>N.state.scrollHeight?B="SIZE_INCREASED":IN!==void 0&&N.atBottom===C.atBottom))),j=yt(Q(r,ns((N,{scrollHeight:C,scrollTop:z,viewportHeight:I})=>{if(!Ii(N.scrollHeight,C)){const U=C-(z+I)<1;return N.scrollTop!==z&&U?{changed:!0,jump:N.scrollTop-z,scrollHeight:C,scrollTop:z}:{changed:!0,jump:0,scrollHeight:C,scrollTop:z}}return{changed:!1,jump:0,scrollHeight:C,scrollTop:z}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ve(N=>N.changed),ie(N=>N.jump)),0);ue(Q(k,ie(N=>N.atBottom)),i),ue(Q(i,bs(50)),c);const S=W(ba);ue(Q(r,ie(({scrollTop:N})=>N),Je(),ns((N,C)=>tt(b)?{direction:N.direction,prevScrollTop:C}:{direction:CN.direction)),S),ue(Q(r,bs(50),rs(xd)),S);const p=W(0);return ue(Q(h,ve(N=>!N),rs(0)),p),ue(Q(o,bs(100),Te(h),ve(([N,C])=>C),ns(([N,C],[z])=>[C,z],[0,0]),ie(([N,C])=>C-N)),p),{atBottomState:k,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:d,atTopThreshold:f,isAtBottom:i,isAtTop:l,isScrolling:h,lastJumpDueToItemResize:j,scrollDirection:S,scrollVelocity:p}},Ze(Ct)),Ca="top",Ia="bottom",Zn="none";function eo(t,s,a){return typeof t=="number"?a===ka&&s===Ca||a===ba&&s===Ia?t:0:a===ka?s===Ca?t.main:t.reverse:s===Ia?t.main:t.reverse}function to(t,s){return typeof t=="number"?t:t[s]??0}const sn=He(([{deviation:t,fixedHeaderHeight:s,headerHeight:a,scrollTop:r,viewportHeight:o}])=>{const n=Le(),i=W(0),l=W(0),c=W(0),d=yt(Q(ct(be(r),be(o),be(a),be(n,ya),be(c),be(i),be(s),be(t),be(l)),ie(([u,f,h,[b,k],j,S,p,N,C])=>{const z=u-N,I=S+p,U=Math.max(h-z,0);let v=Zn;const y=to(C,Ca),w=to(C,Ia);return b-=N,b+=h+p,k+=h+p,k-=N,b>u+I-y&&(v=ka),ku!==null),Je(ya)),[0,0]);return{increaseViewportBy:l,listBoundary:n,overscan:c,topListHeight:i,visibleRange:d}},Ze(Ct),{singleton:!0});function fd(t,s,a){if(cr(s)){const r=yi(t,s);return[{index:ts(s.groupOffsetTree,r)[0],offset:0,size:0},{data:a?.[0],index:r,offset:0,size:0}]}return[{data:a?.[0],index:t,offset:0,size:0}]}const wr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ua(t,s,a,r,o,n){const{lastIndex:i,lastOffset:l,lastSize:c}=o;let d=0,u=0;if(t.length>0){d=t[0].offset;const j=t[t.length-1];u=j.offset+j.size}const f=a-i,h=l+f*c+(f-1)*r,b=d,k=h-u;return{bottom:u,firstItemIndex:n,items:so(t,o,n),offsetBottom:k,offsetTop:d,top:b,topItems:so(s,o,n),topListHeight:s.reduce((j,S)=>S.size+j,0),totalCount:a}}function Ti(t,s,a,r,o,n){let i=0;if(a.groupIndices.length>0)for(const u of a.groupIndices){if(u-i>=t)break;i++}const l=t+i,c=tn(s,l),d=Array.from({length:l}).map((u,f)=>({data:n[f+c],index:f+c,offset:0,size:0}));return Ua(d,[],l,o,a,r)}function so(t,s,a){if(t.length===0)return[];if(!cr(s))return t.map(d=>({...d,index:d.index+a,originalIndex:d.index}));const r=t[0].index,o=t[t.length-1].index,n=[],i=Ks(s.groupOffsetTree,r,o);let l,c=0;for(const d of t){(!l||l.end{const j=W([]),S=W(0),p=Le(),N=W(0);ue(n.topItemsIndexes,j);const C=yt(Q(ct(b,k,be(c,ya),be(o),be(r),be(d),u,be(j),be(s),be(a),be(N),t),ve(([v,y,,w,,,,,,,,A])=>{const B=A!==void 0&&A.length!==w;return v&&!y&&!B}),ie(([,,[v,y],w,A,B,E,F,X,J,ce,ne])=>{const xe=A,{offsetTree:he,sizeTree:H}=xe,q=tt(S);if(w===0)return{...wr,totalCount:w};if(v===0&&y===0)return q===0?{...wr,totalCount:w}:Ti(q,B,A,X,J,ne||[]);if(qe(H))return q>0?null:Ua(fd(tn(B,w),xe,ne),[],w,J,xe,X);const M=[];if(F.length>0){const te=F[0],g=F[F.length-1];let T=0;for(const R of Ks(H,te,g)){const K=R.value,Z=Math.max(R.start,te),re=Math.min(R.end,g);for(let le=Z;le<=re;le++)M.push({data:ne?.[le],index:le,offset:T,size:K}),T+=K}}if(!E)return Ua([],M,w,J,xe,X);const Y=F.length>0?F[F.length-1]+1:0,ae=rd(he,v,y,Y);if(ae.length===0)return null;const $e=w-1,Me=lr([],te=>{for(const g of ae){const T=g.value;let R=T.offset,K=g.start;const Z=T.size;if(T.offset=y);le++)te.push({data:ne?.[le],index:le,offset:R,size:Z}),R+=Z+J}}),Ge=ao(ce,Ca),G=ao(ce,Ia);if(Me.length>0&&(Ge>0||G>0)){const te=Me[0],g=Me[Me.length-1];if(Ge>0&&te.index>Y){const T=Math.min(Ge,te.index-Y),R=[];let K=te.offset;for(let Z=te.index-1;Z>=te.index-T;Z--){const re=Ks(H,Z,Z)[0]?.value??te.size;K-=re+J,R.unshift({data:ne?.[Z],index:Z,offset:K,size:re})}Me.unshift(...R)}if(G>0&&g.index<$e){const T=Math.min(G,$e-g.index);let R=g.offset+g.size+J;for(let K=g.index+1;K<=g.index+T;K++){const Z=Ks(H,K,K)[0]?.value??g.size;Me.push({data:ne?.[K],index:K,offset:R,size:Z}),R+=Z+J}}}return Ua(Me,M,w,J,xe,X)}),ve(v=>v!==null),Je()),wr);ue(Q(t,ve(Yr),ie(v=>v?.length)),o),ue(Q(C,ie(v=>v.topListHeight)),f),ue(f,l),ue(Q(C,ie(v=>[v.top,v.bottom])),i),ue(Q(C,ie(v=>v.items)),p);const z=zt(Q(C,ve(({items:v})=>v.length>0),Te(o,t),ve(([{items:v},y])=>v[v.length-1].originalIndex===y-1),ie(([,v,y])=>[v-1,y]),Je(ya),ie(([v])=>v))),I=zt(Q(C,bs(200),ve(({items:v,topItems:y})=>v.length>0&&v[0].originalIndex===y.length),ie(({items:v})=>v[0].index),Je())),U=zt(Q(C,ve(({items:v})=>v.length>0),ie(({items:v})=>{let y=0,w=v.length-1;for(;v[y].type==="group"&&yy;)w--;return{endIndex:v[w].index,startIndex:v[y].index}}),Je(Ni)));return{endReached:z,initialItemCount:S,itemsRendered:p,listState:C,minOverscanItemCount:N,rangeChanged:U,startReached:I,topItemsIndexes:j,...h}},Ze(ms,ki,sn,Ra,Ea,_a,Ts,Jr),{singleton:!0}),Ei=He(([{fixedFooterHeight:t,fixedHeaderHeight:s,footerHeight:a,headerHeight:r},{listState:o}])=>{const n=Le(),i=yt(Q(ct(a,t,r,s,o),ie(([l,c,d,u,f])=>l+c+d+u+f.offsetBottom+f.bottom)),0);return ue(be(i),n),{totalListHeight:i,totalListHeightChanged:n}},Ze(Ct,Ps),{singleton:!0}),gd=He(([{viewportHeight:t},{totalListHeight:s}])=>{const a=W(!1),r=yt(Q(ct(a,t,s),ve(([o])=>o),ie(([,o,n])=>Math.max(0,o-n)),bs(0),Je()),0);return{alignToBottom:a,paddingTopAddition:r}},Ze(Ct,Ei),{singleton:!0}),Ri=He(()=>({context:W(null)})),bd=({itemBottom:t,itemTop:s,locationParams:{align:a,behavior:r,...o},viewportBottom:n,viewportTop:i})=>sn?{...o,align:a??"end",...r!==void 0?{behavior:r}:{}}:null,_i=He(([{gap:t,sizes:s,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:n,scrollingInProgress:i,scrollTop:l,viewportHeight:c},{scrollToIndex:d}])=>{const u=Le();return ue(Q(u,Te(s,c,a,n,o,r,l),Te(t),ie(([[f,h,b,k,j,S,p,N],C])=>{const{calculateViewLocation:z=bd,done:I,...U}=f,v=Si(f,h,k-1),y=Sa(v,h.offsetTree,C)+j+S,w=y+ts(h.sizeTree,v)[1],A=N+S,B=N+b-p,E=z({itemBottom:w,itemTop:y,locationParams:U,viewportBottom:B,viewportTop:A});return E!==null?I&&es(Q(i,ve(F=>!F),Fs(tt(i)?1:2)),I):I?.(),E}),ve(f=>f!==null)),d),{scrollIntoView:u}},Ze(ms,Ct,Ea,Ps,Is),{singleton:!0});function ro(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const vd=(t,s)=>typeof t=="function"?ro(t(s)):s&&ro(t),wd=He(([{listRefresh:t,totalCount:s,fixedItemSize:a,data:r},{atBottomState:o,isAtBottom:n},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:c,propsReady:d},{log:u},{scrollingInProgress:f},{context:h},{scrollIntoView:b}])=>{const k=W(!1),j=Le();let S=null;function p(I){Ie(i,{align:"end",behavior:I,index:"LAST"})}Ue(Q(ct(Q(be(s),Fs(1)),c),Te(be(k),n,l,f),ie(([[I,U],v,y,w,A])=>{let B=U&&w,E="auto";return B&&(E=vd(v,y||A),B=B&&E!==!1),{followOutputBehavior:E,shouldFollow:B,totalCount:I}}),ve(({shouldFollow:I})=>I)),({followOutputBehavior:I,totalCount:U})=>{S!==null&&(S(),S=null),tt(a)!==void 0?requestAnimationFrame(()=>{tt(u)("following output to ",{totalCount:U},ut.DEBUG),p(I)}):S=es(t,()=>{tt(u)("following output to ",{totalCount:U},ut.DEBUG),p(I),S=null})});function N(I){const U=es(o,v=>{I&&!v.atBottom&&v.notAtBottomBecause==="SIZE_INCREASED"&&S===null&&(tt(u)("scrolling to bottom due to increased size",{},ut.DEBUG),p("auto"))});setTimeout(U,100)}Ue(Q(ct(be(k),s,d),ve(([I,,U])=>I!==!1&&U),ns(({value:I},[,U])=>({refreshed:I===U,value:U}),{refreshed:!1,value:0}),ve(({refreshed:I})=>I),Te(k,s)),([,I])=>{tt(l)&&N(I!==!1)}),Ue(j,()=>{N(tt(k)!==!1)}),Ue(ct(be(k),o),([I,U])=>{I!==!1&&!U.atBottom&&U.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&p("auto")});const C=W(null),z=Le();return ue($r(Q(be(r),ie(I=>I?.length??0)),Q(be(s))),z),Ue(Q(ct(Q(z,Fs(1)),c),Te(be(C),l,f,h),ie(([[I,U],v,y,w,A])=>U&&y&&v?.({context:A,totalCount:I,scrollingInProgress:w})),ve(I=>!!I),bs(0)),I=>{S!==null&&(S(),S=null),tt(a)!==void 0?requestAnimationFrame(()=>{tt(u)("scrolling into view",{}),Ie(b,I)}):S=es(t,()=>{tt(u)("scrolling into view",{}),Ie(b,I),S=null})}),{autoscrollToBottom:j,followOutput:k,scrollIntoViewOnChange:C}},Ze(ms,_a,Ea,Ra,Ts,Is,Ct,Ri,_i)),Nd=He(([{data:t,firstItemIndex:s,gap:a,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:n,listState:i},{didMount:l}])=>(ue(Q(l,Te(n),ve(([,c])=>c!==0),Te(o,r,s,a,t),ie(([[,c],d,u,f,h,b=[]])=>Ti(c,d,u,f,h,b))),i),{}),Ze(ms,Ra,Ps,Ts),{singleton:!0}),jd=He(([{didMount:t},{scrollTo:s},{listState:a}])=>{const r=W(0);return Ue(Q(t,Te(r),ve(([,o])=>o!==0),ie(([,o])=>({top:o}))),o=>{es(Q(a,Fs(1),ve(n=>n.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(s,o)})})}),{initialScrollTop:r}},Ze(Ts,Ct,Ps),{singleton:!0}),Mi=He(([{scrollVelocity:t}])=>{const s=W(!1),a=Le(),r=W(!1);return ue(Q(t,Te(r,s,a),ve(([o,n])=>n!==!1&&n!==void 0),ie(([o,n,i,l])=>{const{enter:c,exit:d}=n;if(i){if(d(o,l))return!1}else if(c(o,l))return!0;return i}),Je()),s),Ue(Q(ct(s,t,a),Te(r)),([[o,n,i],l])=>{o&&l!==!1&&l!==void 0&&l.change&&l.change(n,i)}),{isSeeking:s,scrollSeekConfiguration:r,scrollSeekRangeChanged:a,scrollVelocity:t}},Ze(_a),{singleton:!0}),an=He(([{scrollContainerState:t,scrollTo:s}])=>{const a=Le(),r=Le(),o=Le(),n=W(!1),i=W(void 0);return ue(Q(ct(a,r),ie(([{scrollTop:l,viewportHeight:c},{offsetTop:d,listHeight:u}])=>({scrollHeight:u,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),ue(Q(s,Te(r),ie(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),o),{customScrollParent:i,useWindowScroll:n,windowScrollContainerState:a,windowScrollTo:o,windowViewportRect:r}},Ze(Ct)),yd=He(([{sizeRanges:t,sizes:s},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:o},{didMount:n},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:c}])=>{const d=Le(),u=W(void 0),f=W(null),h=W(null);return ue(l,f),ue(c,h),Ue(Q(d,Te(s,r,i,f,h,a)),([b,k,j,S,p,N,C])=>{const z=od(k.sizeTree);S&&p!==null&&N!==null&&(j=p.scrollTop-N.offsetTop),j-=C,b({ranges:z,scrollTop:j})}),ue(Q(u,ve(Yr),ie(Sd)),o),ue(Q(n,Te(u),ve(([,b])=>b!==void 0),Je(),ie(([,b])=>b.ranges)),t),{getState:d,restoreStateFrom:u}},Ze(ms,Ct,Ra,Ts,an));function Sd(t){return{align:"start",index:0,offset:t.scrollTop}}const kd=He(([{topItemsIndexes:t}])=>{const s=W(0);return ue(Q(s,ve(a=>a>=0),ie(a=>Array.from({length:a}).map((r,o)=>o))),t),{topItemCount:s}},Ze(Ps));function Ai(t){let s=!1,a;return(()=>(s||(s=!0,a=t()),a))}const Cd=Ai(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Id=He(([{deviation:t,scrollBy:s,scrollingInProgress:a,scrollTop:r},{isAtBottom:o,isScrolling:n,lastJumpDueToItemResize:i,scrollDirection:l},{listState:c},{beforeUnshiftWith:d,gap:u,shiftWithOffset:f,sizes:h},{log:b},{recalcInProgress:k}])=>{const j=zt(Q(c,Te(i),ns(([,p,N,C],[{bottom:z,items:I,offsetBottom:U,totalCount:v},y])=>{const w=z+U;let A=0;return N===v&&p.length>0&&I.length>0&&(I[0].originalIndex===0&&p[0].originalIndex===0||(A=w-C,A!==0&&(A+=y))),[A,I,v,w]},[0,[],0,0]),ve(([p])=>p!==0),Te(r,l,a,o,b,k),ve(([,p,N,C,,,z])=>!z&&!C&&p!==0&&N===ka),ie(([[p],,,,,N])=>(N("Upward scrolling compensation",{amount:p},ut.DEBUG),p))));function S(p){p>0?(Ie(s,{behavior:"auto",top:-p}),Ie(t,0)):(Ie(t,0),Ie(s,{behavior:"auto",top:-p}))}return Ue(Q(j,Te(t,n)),([p,N,C])=>{C&&Cd()?Ie(t,N-p):S(-p)}),Ue(Q(ct(yt(n,!1),t,k),ve(([p,N,C])=>!p&&!C&&N!==0),ie(([p,N])=>N),bs(1)),S),ue(Q(f,ie(p=>({top:-p}))),s),Ue(Q(d,Te(h,u),ie(([p,{groupIndices:N,lastSize:C,sizeTree:z},I])=>{function U(B){return B*(C+I)}if(N.length===0)return U(p);let v=0;const y=ja(z,0);let w=0,A=0;for(;wp&&(v-=y,B=p-w+1),w+=B,v+=U(B),A++}return v})),p=>{Ie(t,p),requestAnimationFrame(()=>{Ie(s,{top:p}),requestAnimationFrame(()=>{Ie(t,0),Ie(k,!1)})})}),{deviation:t}},Ze(Ct,_a,Ps,ms,Is,Jr)),Td=He(([t,s,a,r,o,n,i,l,c,d,u])=>({...t,...s,...a,...r,...o,...n,...i,...l,...c,...d,...u}),Ze(sn,Nd,Ts,Mi,Ei,jd,gd,an,_i,Is,Ri)),zi=He(([{data:t,defaultItemSize:s,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:o,gap:n,groupIndices:i,heightEstimates:l,itemSize:c,sizeRanges:d,sizes:u,statefulTotalCount:f,totalCount:h,trackItemSizes:b},{initialItemFinalLocationReached:k,initialTopMostItemIndex:j,scrolledToInitialItem:S},p,N,C,z,{scrollToIndex:I},U,{topItemCount:v},{groupCounts:y},w])=>{const{listState:A,minOverscanItemCount:B,topItemsIndexes:E,rangeChanged:F,...X}=z;return ue(F,w.scrollSeekRangeChanged),ue(Q(w.windowViewportRect,ie(J=>J.visibleHeight)),p.viewportHeight),{data:t,defaultItemHeight:s,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:o,gap:n,groupCounts:y,heightEstimates:l,initialItemFinalLocationReached:k,initialTopMostItemIndex:j,scrolledToInitialItem:S,sizeRanges:d,topItemCount:v,topItemsIndexes:E,totalCount:h,...C,groupIndices:i,itemSize:c,listState:A,minOverscanItemCount:B,scrollToIndex:I,statefulTotalCount:f,trackItemSizes:b,rangeChanged:F,...X,...w,...p,sizes:u,...N}},Ze(ms,Ra,Ct,yd,wd,Ps,Ea,Id,kd,ki,Td));function Ed(t,s){const a={},r={};let o=0;const n=t.length;for(;o(p[N]=C=>{const z=S[s.methods[N]];Ie(z,C)},p),{})}function u(S){return i.reduce((p,N)=>(p[N]=Uc(S[s.events[N]]),p),{})}const f=de.forwardRef(function(S,p){const{children:N,...C}=S,[z]=de.useState(()=>lr(Wc(t),v=>{c(v,C)})),[I]=de.useState(qn(u,z));Da(()=>{for(const v of i)v in C&&Ue(I[v],C[v]);return()=>{Object.values(I).map(Kr)}},[C,I,z]),Da(()=>{c(z,C)}),de.useImperativeHandle(p,Wn(d(z)));const U=a;return e.jsx(l.Provider,{value:z,children:a!==void 0?e.jsx(U,{...Ed([...r,...o,...i],C),children:N}):N})}),h=S=>{const p=de.useContext(l);return de.useCallback(N=>{Ie(p[S],N)},[p,S])},b=S=>{const p=de.useContext(l)[S],N=de.useCallback(C=>Ue(p,C),[p]);return de.useSyncExternalStore(N,()=>tt(p),()=>tt(p))},k=S=>{const p=de.useContext(l)[S],[N,C]=de.useState(qn(tt,p));return Da(()=>Ue(p,z=>{z!==N&&C(Wn(z))}),[p,N]),N},j=parseInt(de.version)>=18?b:k;return{Component:f,useEmitter:(S,p)=>{const N=de.useContext(l)[S];Da(()=>Ue(N,p),[p,N])},useEmitterValue:j,usePublisher:h}}const Di=de.createContext(void 0),$i=de.createContext(void 0),Nr="-webkit-sticky",no="sticky",rn=Ai(()=>{if(typeof document>"u")return no;const t=document.createElement("div");return t.style.position=Nr,t.style.position===Nr?Nr:no}),Fi=typeof document<"u"?de.useLayoutEffect:de.useEffect;function jr(t){return"self"in t}function Rd(t){return"body"in t}function Oi(t,s,a,r=ta,o,n){const i=de.useRef(null),l=de.useRef(null),c=de.useRef(null),d=de.useCallback(h=>{let b,k,j;const S=h.target;if(Rd(S)||jr(S)){const N=jr(S)?S:S.defaultView;j=n===!0?N.scrollX:N.scrollY,b=n===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,k=n===!0?N.innerWidth:N.innerHeight}else j=n===!0?S.scrollLeft:S.scrollTop,b=n===!0?S.scrollWidth:S.scrollHeight,k=n===!0?S.offsetWidth:S.offsetHeight;const p=()=>{t({scrollHeight:b,scrollTop:Math.max(j,0),viewportHeight:k})};h.suppressFlushSync===!0?p():Ar.flushSync(p),l.current!==null&&(j===l.current||j<=0||j===b-k)&&(l.current=null,s(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,s,n]);de.useEffect(()=>{const h=o||i.current;return r(o||i.current),d({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",d,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",d)}},[i,d,a,r,o]);function u(h){const b=i.current;if(!b||(n===!0?"offsetWidth"in b&&b.offsetWidth===0:"offsetHeight"in b&&b.offsetHeight===0))return;const k=h.behavior==="smooth";let j,S,p;jr(b)?(S=Math.max(ks(b.document.documentElement,n===!0?"width":"height"),n===!0?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight),j=n===!0?b.innerWidth:b.innerHeight,p=n===!0?window.scrollX:window.scrollY):(S=b[n===!0?"scrollWidth":"scrollHeight"],j=ks(b,n===!0?"width":"height"),p=b[n===!0?"scrollLeft":"scrollTop"]);const N=S-j;if(h.top=Math.ceil(Math.max(Math.min(N,h.top),0)),Ii(j,S)||h.top===p){t({scrollHeight:S,scrollTop:p,viewportHeight:j}),k&&s(!0);return}k?(l.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,s(!0)},1e3)):l.current=null,n===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:h.top}),b.scrollTo(h)}function f(h){n===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:h.top}:{}}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:u}}function nn(t){return t}const _d=He(()=>{const t=W(l=>`Item ${l}`),s=W(l=>`Group ${l}`),a=W({}),r=W(nn),o=W("div"),n=W(ta),i=(l,c=null)=>yt(Q(a,ie(d=>d[l]),Je()),c);return{components:a,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:s,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:t,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:n,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Md=He(([t,s])=>({...t,...s}),Ze(zi,_d)),Ad=({height:t})=>e.jsx("div",{style:{height:t}}),zd={overflowAnchor:"none",position:rn(),zIndex:1},Bi={overflowAnchor:"none"},Ld={...Bi,display:"inline-block",height:"100%"},oo=de.memo(function({showTopList:t=!1}){const s=ye("listState"),a=Qt("sizeRanges"),r=ye("useWindowScroll"),o=ye("customScrollParent"),n=Qt("windowScrollContainerState"),i=Qt("scrollContainerState"),l=o||r?n:i,c=ye("itemContent"),d=ye("context"),u=ye("groupContent"),f=ye("trackItemSizes"),h=ye("itemSize"),b=ye("log"),k=Qt("gap"),j=ye("horizontalDirection"),{callbackRef:S}=Kc(a,h,f,t?ta:l,b,k,o,j,ye("skipAnimationFrameInResizeObserver")),[p,N]=de.useState(0);ln("deviation",X=>{p!==X&&N(X)});const C=ye("EmptyPlaceholder"),z=ye("ScrollSeekPlaceholder")??Ad,I=ye("ListComponent"),U=ye("ItemComponent"),v=ye("GroupComponent"),y=ye("computeItemKey"),w=ye("isSeeking"),A=ye("groupIndices").length>0,B=ye("alignToBottom"),E=ye("initialItemFinalLocationReached"),F=t?{}:{boxSizing:"border-box",...j?{display:"inline-block",height:"100%",marginLeft:p!==0?p:B?"auto":0,paddingLeft:s.offsetTop,paddingRight:s.offsetBottom,whiteSpace:"nowrap"}:{marginTop:p!==0?p:B?"auto":0,paddingBottom:s.offsetBottom,paddingTop:s.offsetTop},...E?{}:{visibility:"hidden"}};return!t&&s.totalCount===0&&C!==null&&C!==void 0?e.jsx(C,{...Nt(C,d)}):e.jsx(I,{...Nt(I,d),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:S,style:F,children:(t?s.topItems:s.items).map(X=>{const J=X.originalIndex,ce=y(J+s.firstItemIndex,X.data,d);return w?m.createElement(z,{...Nt(z,d),height:X.size,index:X.index,key:ce,type:X.type||"item",...X.type==="group"?{}:{groupIndex:X.groupIndex}}):X.type==="group"?m.createElement(v,{...Nt(v,d),"data-index":J,"data-item-index":X.index,"data-known-size":X.size,key:ce,style:zd},u(X.index,d)):m.createElement(U,{...Nt(U,d),...Od(U,X.data),"data-index":J,"data-item-group-index":X.groupIndex,"data-item-index":X.index,"data-known-size":X.size,key:ce,style:j?Ld:Bi},A?c(X.index,X.groupIndex,X.data,d):c(X.index,X.data,d))})})}),Dd={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},$d={outline:"none",overflowX:"auto",position:"relative"},on=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Pi=(t,s,a=0)=>({...on(t),position:s?"relative":"absolute",top:s?-a:0}),Fd={position:rn(),top:0,width:"100%",zIndex:1};function Nt(t,s){if(typeof t!="string")return{context:s}}function Od(t,s){return{item:typeof t=="string"?void 0:s}}const Bd=de.memo(function(){const t=ye("HeaderComponent"),s=Qt("headerHeight"),a=ye("HeaderFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),Pd=de.memo(function(){const t=ye("FooterComponent"),s=Qt("footerHeight"),a=ye("HeaderFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null});function Hi({useEmitter:t,useEmitterValue:s,usePublisher:a}){return de.memo(function({children:r,style:o,context:n,...i}){const l=a("scrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),u=s("scrollerRef"),f=s("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:b,scrollToCallback:k}=Oi(l,d,c,u,void 0,f);return t("scrollTo",k),t("scrollBy",h),e.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:b,style:{...f?$d:Dd,...o},tabIndex:0,...i,...Nt(c,n),children:r})})}function Gi({useEmitter:t,useEmitterValue:s,usePublisher:a}){return de.memo(function({children:r,style:o,context:n,...i}){const l=a("windowScrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),u=s("totalListHeight"),f=s("deviation"),h=s("customScrollParent"),b=de.useRef(null),k=s("scrollerRef"),{scrollByCallback:j,scrollerRef:S,scrollToCallback:p}=Oi(l,d,c,k,h);return Fi(()=>(S.current=h||b.current?.ownerDocument.defaultView,()=>{S.current=null}),[S,h]),t("windowScrollTo",p),t("scrollBy",j),e.jsx(c,{ref:b,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...u!==0?{height:u+f}:void 0},...i,...Nt(c,n),children:r})})}const Hd=({children:t})=>{const s=de.useContext(Di),a=Qt("viewportHeight"),r=Qt("fixedItemHeight"),o=ye("alignToBottom"),n=ye("horizontalDirection"),i=de.useMemo(()=>xi(a,c=>ks(c,n?"width":"height")),[a,n]),l=Bs(i,!0,ye("skipAnimationFrameInResizeObserver"));return de.useEffect(()=>{s&&(a(s.viewportHeight),r(s.itemHeight))},[s,a,r]),e.jsx("div",{"data-viewport-type":"element",ref:l,style:on(o),children:t})},Gd=({children:t})=>{const s=de.useContext(Di),a=Qt("windowViewportRect"),r=Qt("fixedItemHeight"),o=ye("customScrollParent"),n=ye("useWindowScroll"),i=ye("topListHeight"),l=hi(a,o,ye("skipAnimationFrameInResizeObserver")),c=ye("alignToBottom");return de.useEffect(()=>{s&&(r(s.itemHeight),a({listHeight:0,offsetTop:0,visibleHeight:s.viewportHeight,visibleWidth:100}))},[s,a,r]),e.jsx("div",{"data-viewport-type":"window",ref:l,style:Pi(c,n,i),children:t})},Qd=({children:t})=>{const s=ye("TopItemListComponent")??"div",a=ye("headerHeight"),r={...Fd,marginTop:`${a}px`},o=ye("context");return e.jsx(s,{style:r,...Nt(s,o),children:t})},Ud=de.memo(function(t){const s=ye("useWindowScroll"),a=ye("topItemsIndexes").length>0,r=ye("customScrollParent"),o=ye("context");return e.jsxs(r||s?qd:Wd,{...t,context:o,children:[a&&e.jsx(Qd,{children:e.jsx(oo,{showTopList:!0})}),e.jsxs(r||s?Gd:Hd,{children:[e.jsx(Bd,{}),e.jsx(oo,{}),e.jsx(Pd,{})]})]})}),{Component:Vd,useEmitter:ln,useEmitterValue:ye,usePublisher:Qt}=Li(Md,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Ud),Wd=Hi({useEmitter:ln,useEmitterValue:ye,usePublisher:Qt}),qd=Gi({useEmitter:ln,useEmitterValue:ye,usePublisher:Qt}),Yd=Vd,Kd=He(()=>{const t=W(d=>e.jsxs("td",{children:["Item $",d]})),s=W(null),a=W(d=>e.jsxs("td",{colSpan:1e3,children:["Group ",d]})),r=W(null),o=W(null),n=W({}),i=W(nn),l=W(ta),c=(d,u=null)=>yt(Q(n,ie(f=>f[d]),Je()),u);return{components:n,computeItemKey:i,context:s,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:t,groupContent:a,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}});Ze(zi,Kd);rn();const io={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Xd={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:lo,floor:tr,max:va,min:yr,round:co}=Math;function mo(t,s,a){return Array.from({length:s-t+1}).map((r,o)=>({data:a===null?null:a[o+t],index:o+t}))}function Jd(t){return{...Xd,items:t}}function $a(t,s){return t!==void 0&&t.width===s.width&&t.height===s.height}function Zd(t,s){return t!==void 0&&t.column===s.column&&t.row===s.row}const em=He(([{increaseViewportBy:t,listBoundary:s,overscan:a,visibleRange:r},{footerHeight:o,headerHeight:n,scrollBy:i,scrollContainerState:l,scrollTo:c,scrollTop:d,smoothScrollTargetReached:u,viewportHeight:f},h,b,{didMount:k,propsReady:j},{customScrollParent:S,useWindowScroll:p,windowScrollContainerState:N,windowScrollTo:C,windowViewportRect:z},I])=>{const U=W(0),v=W(0),y=W(io),w=W({height:0,width:0}),A=W({height:0,width:0}),B=Le(),E=Le(),F=W(0),X=W(null),J=W({column:0,row:0}),ce=Le(),ne=Le(),xe=W(!1),he=W(0),H=W(!0),q=W(!1),M=W(!1);Ue(Q(k,Te(he),ve(([G,te])=>te!==0)),()=>{Ie(H,!1)}),Ue(Q(ct(k,H,A,w,he,q),ve(([G,te,g,T,,R])=>G&&!te&&g.height!==0&&T.height!==0&&!R)),([,,,,G])=>{Ie(q,!0),en(1,()=>{Ie(B,G)}),es(Q(d),()=>{Ie(s,[0,0]),Ie(H,!0)})}),ue(Q(ne,ve(G=>G!=null&&G.scrollTop>0),rs(0)),v),Ue(Q(k,Te(ne),ve(([,G])=>G!=null)),([,G])=>{G&&(Ie(w,G.viewport),Ie(A,G.item),Ie(J,G.gap),G.scrollTop>0&&(Ie(xe,!0),es(Q(d,Fs(1)),te=>{Ie(xe,!1)}),Ie(c,{top:G.scrollTop})))}),ue(Q(w,ie(({height:G})=>G)),f),ue(Q(ct(be(w,$a),be(A,$a),be(J,(G,te)=>G!==void 0&&G.column===te.column&&G.row===te.row),be(d)),ie(([G,te,g,T])=>({gap:g,item:te,scrollTop:T,viewport:G}))),ce),ue(Q(ct(be(U),r,be(J,Zd),be(A,$a),be(w,$a),be(X),be(v),be(xe),be(H),be(he)),ve(([,,,,,,,G])=>!G),ie(([G,[te,g],T,R,K,Z,re,,le,$])=>{const{column:oe,row:pe}=T,{height:we,width:se}=R,{width:fe}=K;if(re===0&&(G===0||fe===0))return io;if(se===0){const P=tn($,G),Ae=P+Math.max(re-1,0);return Jd(mo(P,Ae,Z))}const et=Qi(fe,se,oe);let Fe,Ke;le?te===0&&g===0&&re>0?(Fe=0,Ke=re-1):(Fe=et*tr((te+pe)/(we+pe)),Ke=et*lo((g+pe)/(we+pe))-1,Ke=yr(G-1,va(Ke,et-1)),Fe=yr(Ke,va(0,Fe))):(Fe=0,Ke=-1);const rt=mo(Fe,Ke,Z),{bottom:Rt,top:St}=uo(K,T,R,rt),Ft=lo(G/et),ss=Ft*we+(Ft-1)*pe-Rt;return{bottom:Rt,itemHeight:we,items:rt,itemWidth:se,offsetBottom:ss,offsetTop:St,top:St}})),y),ue(Q(X,ve(G=>G!==null),ie(G=>G.length)),U),ue(Q(ct(w,A,y,J),ve(([G,te,{items:g}])=>g.length>0&&te.height!==0&&G.height!==0),ie(([G,te,{items:g},T])=>{const{bottom:R,top:K}=uo(G,T,te,g);return[K,R]}),Je(ya)),s);const Y=W(!1);ue(Q(d,Te(Y),ie(([G,te])=>te||G!==0)),Y);const ae=zt(Q(ct(y,U),ve(([{items:G}])=>G.length>0),Te(Y),ve(([[G,te],g])=>{const T=G.items[G.items.length-1].index===te-1;return(g||G.bottom>0&&G.itemHeight>0&&G.offsetBottom===0&&G.items.length===te)&&T}),ie(([[,G]])=>G-1),Je())),$e=zt(Q(be(y),ve(({items:G})=>G.length>0&&G[0].index===0),rs(0),Je())),Me=zt(Q(be(y),Te(xe),ve(([{items:G},te])=>G.length>0&&!te),ie(([{items:G}])=>({endIndex:G[G.length-1].index,startIndex:G[0].index})),Je(Ni),bs(0)));ue(Me,b.scrollSeekRangeChanged),ue(Q(B,Te(w,A,U,J),ie(([G,te,g,T,R])=>{const K=Ci(G),{align:Z,behavior:re,offset:le}=K;let $=K.index;$==="LAST"&&($=T-1),$=va(0,$,yr(T-1,$));let oe=Hr(te,R,g,$);return Z==="end"?oe=co(oe-te.height+g.height):Z==="center"&&(oe=co(oe-te.height/2+g.height/2)),le!==void 0&&le!==0&&(oe+=le),{behavior:re,top:oe}})),c);const Ge=yt(Q(y,ie(G=>G.offsetBottom+G.bottom)),0);return ue(Q(z,ie(G=>({height:G.visibleHeight,width:G.visibleWidth}))),w),{customScrollParent:S,data:X,deviation:F,footerHeight:o,gap:J,headerHeight:n,increaseViewportBy:t,initialItemCount:v,itemDimensions:A,overscan:a,restoreStateFrom:ne,scrollBy:i,scrollContainerState:l,scrollHeight:E,scrollTo:c,scrollToIndex:B,scrollTop:d,smoothScrollTargetReached:u,totalCount:U,useWindowScroll:p,viewportDimensions:w,windowScrollContainerState:N,windowScrollTo:C,windowViewportRect:z,...b,gridState:y,horizontalDirection:M,initialTopMostItemIndex:he,totalListHeight:Ge,...h,endReached:ae,propsReady:j,rangeChanged:Me,startReached:$e,stateChanged:ce,stateRestoreInProgress:xe,...I}},Ze(sn,Ct,_a,Mi,Ts,an,Is));function Qi(t,s,a){return va(1,tr((t+a)/(tr(s)+a)))}function uo(t,s,a,r){const{height:o}=a;if(o===void 0||r.length===0)return{bottom:0,top:0};const n=Hr(t,s,a,r[0].index);return{bottom:Hr(t,s,a,r[r.length-1].index)+o,top:n}}function Hr(t,s,a,r){const o=Qi(t.width,a.width,s.column),n=tr(r/o),i=n*a.height+va(0,n-1)*s.row;return i>0?i+s.row:i}const tm=He(()=>{const t=W(f=>`Item ${f}`),s=W({}),a=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),n=W(nn),i=W("div"),l=W(ta),c=(f,h=null)=>yt(Q(s,ie(b=>b[f]),Je()),h),d=W(!1),u=W(!1);return ue(be(u),d),{components:s,computeItemKey:n,context:a,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:t,listClassName:o,ListComponent:c("List","div"),readyStateChanged:d,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),sm=He(([t,s])=>({...t,...s}),Ze(em,tm)),am=de.memo(function(){const t=Xe("gridState"),s=Xe("listClassName"),a=Xe("itemClassName"),r=Xe("itemContent"),o=Xe("computeItemKey"),n=Xe("isSeeking"),i=Ut("scrollHeight"),l=Xe("ItemComponent"),c=Xe("ListComponent"),d=Xe("ScrollSeekPlaceholder"),u=Xe("context"),f=Ut("itemDimensions"),h=Ut("gap"),b=Xe("log"),k=Xe("stateRestoreInProgress"),j=Ut("reportReadyState"),S=Bs(de.useMemo(()=>p=>{const N=p.parentElement.parentElement.scrollHeight;i(N);const C=p.firstChild;if(C!==null){const{height:z,width:I}=C.getBoundingClientRect();f({height:z,width:I})}h({column:xo("column-gap",getComputedStyle(p).columnGap,b),row:xo("row-gap",getComputedStyle(p).rowGap,b)})},[i,f,h,b]),!0,!1);return Fi(()=>{t.itemHeight>0&&t.itemWidth>0&&j(!0)},[t]),k?null:e.jsx(c,{className:s,ref:S,...Nt(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(p=>{const N=o(p.index,p.data,u);return n?e.jsx(d,{...Nt(d,u),height:t.itemHeight,index:p.index,width:t.itemWidth},N):m.createElement(l,{...Nt(l,u),className:a,"data-index":p.index,key:N},r(p.index,p.data,u))})})}),rm=de.memo(function(){const t=Xe("HeaderComponent"),s=Ut("headerHeight"),a=Xe("headerFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,!1),o=Xe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),nm=de.memo(function(){const t=Xe("FooterComponent"),s=Ut("footerHeight"),a=Xe("headerFooterTag"),r=Bs(de.useMemo(()=>n=>{s(ks(n,"height"))},[s]),!0,!1),o=Xe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...Nt(t,o)})}):null}),om=({children:t})=>{const s=de.useContext($i),a=Ut("itemDimensions"),r=Ut("viewportDimensions"),o=Bs(de.useMemo(()=>n=>{r(n.getBoundingClientRect())},[r]),!0,!1);return de.useEffect(()=>{s&&(r({height:s.viewportHeight,width:s.viewportWidth}),a({height:s.itemHeight,width:s.itemWidth}))},[s,r,a]),e.jsx("div",{ref:o,style:on(!1),children:t})},im=({children:t})=>{const s=de.useContext($i),a=Ut("windowViewportRect"),r=Ut("itemDimensions"),o=Xe("customScrollParent"),n=Xe("useWindowScroll"),i=hi(a,o,!1);return de.useEffect(()=>{s&&(r({height:s.itemHeight,width:s.itemWidth}),a({listHeight:0,offsetTop:0,visibleHeight:s.viewportHeight,visibleWidth:s.viewportWidth}))},[s,a,r]),e.jsx("div",{ref:i,style:Pi(!1,n),children:t})},lm=de.memo(function({...t}){const s=Xe("useWindowScroll"),a=Xe("customScrollParent"),r=a||s?dm:cm,o=a||s?im:om,n=Xe("context");return e.jsx(r,{...t,...Nt(r,n),children:e.jsxs(o,{children:[e.jsx(rm,{}),e.jsx(am,{}),e.jsx(nm,{})]})})}),{useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut}=Li(sm,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},lm),cm=Hi({useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut}),dm=Gi({useEmitter:Ui,useEmitterValue:Xe,usePublisher:Ut});function xo(t,s,a){return s!=="normal"&&s?.endsWith("px")!==!0&&a(`${t} was not resolved to pixel value correctly`,s,ut.WARN),s==="normal"?0:parseInt(s??"0",10)}function po(t){if(Array.isArray(t)){if(t.length<5||t.length>6)throw new Error(`Invalid bone format: expected [x,y,w,h,r,c?] but got ${t.length} elements`);const s=t;return{x:s[0],y:s[1],w:s[2],h:s[3],r:s[4],c:s[5]||void 0}}return t}const ho=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th"]);function mm(t,s="component",a){const r=t.getBoundingClientRect(),o=[],n=a?.leafTags?new Set([...ho,...a.leafTags]):ho,i=a?.captureRoundedBorders??!0,l=a?.excludeTags?new Set(a.excludeTags):null,c=a?.excludeSelectors??null;function d(u){const f=getComputedStyle(u);if(f.display==="none"||f.visibility==="hidden"||f.opacity==="0")return;const h=u.tagName.toLowerCase();if(l?.has(h)||c?.some(w=>u.matches(w)))return;const b=[...u.children].filter(w=>{const A=getComputedStyle(w);return A.display!=="none"&&A.visibility!=="hidden"&&A.opacity!=="0"}),k=h==="img"||h==="svg"||h==="video"||h==="canvas",j=h==="input"||h==="button"||h==="textarea"||h==="select",S=b.length===0||k||j||n.has(h),p=f.backgroundColor,N=p!=="rgba(0, 0, 0, 0)"&&p!=="transparent",C=f.backgroundImage!=="none",z=parseFloat(f.borderTopWidth)||0,I=i&&z>0&&f.borderTopColor!=="rgba(0, 0, 0, 0)"&&f.borderTopColor!=="transparent",U=(parseFloat(f.borderTopLeftRadius)||0)>0,v=N||C||I&&U,y=h==="tr"||h==="td"||h==="th"||h==="thead"||h==="tbody"||h==="table";if(S){const w=u.getBoundingClientRect();if(w.width<1||w.height<1)return;const A=k&&w.width>0&&w.height>0&&Math.abs(w.width-w.height)<4,B=y?0:A?"50%":fo(f,u)??8,E=r.width;o.push({x:E>0?+((w.left-r.left)/E*100).toFixed(4):0,y:Math.round(w.top-r.top),w:E>0?+(w.width/E*100).toFixed(4):0,h:Math.round(w.height),r:B});return}if(v){const w=u.getBoundingClientRect();if(w.width>=1&&w.height>=1){const A=y?0:fo(f,u)??8,B=r.width;o.push({x:B>0?+((w.left-r.left)/B*100).toFixed(4):0,y:Math.round(w.top-r.top),w:B>0?+(w.width/B*100).toFixed(4):0,h:Math.round(w.height),r:A,c:!0})}}for(const w of b)d(w)}for(const u of t.children)d(u);return{name:s,viewportWidth:Math.round(r.width),width:Math.round(r.width),height:Math.round(r.height),bones:o}}function fo(t,s){const a=parseFloat(t.borderTopLeftRadius)||0,r=parseFloat(t.borderTopRightRadius)||0,o=parseFloat(t.borderBottomRightRadius)||0,n=parseFloat(t.borderBottomLeftRadius)||0;if(a===0&&r===0&&o===0&&n===0)return;const i=s?(()=>{const d=s.getBoundingClientRect();return d.width>0&&d.height>0&&Math.abs(d.width-d.height)<4})():!1;return t.borderRadius==="50%"?"50%":Math.max(a,r,o,n)>9998?i?"50%":9999:a===r&&r===o&&o===n?a!==8?a:void 0:`${a}px ${r}px ${o}px ${n}px`}const um=new Map;function xm(t){return um.get(t)}function pm(){typeof window<"u"&&window.__BONEYARD_BUILD&&(window.__BONEYARD_SNAPSHOT=mm)}function hm(){return typeof window<"u"&&window.__BONEYARD_BUILD===!0}function fm(t,s){if(!("breakpoints"in t))return t;const a=Object.keys(t.breakpoints).map(Number).sort((o,n)=>o-n);if(a.length===0)return null;const r=[...a].reverse().find(o=>s>=o)??a[0];return t.breakpoints[r]??null}const Us={angle:110,start:30,end:70,speed:"2s",lightHighlight:"#f7f7f7",darkHighlight:"#2c2c2c"},ua={speed:"1.8s",lightAdjust:.3,darkAdjust:.02},go={web:{light:"#f0f0f0",dark:"#222222"}},gm=/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/;function bo(t,s){const a=t.match(gm);if(a){const[,r,o,n,i="1"]=a,l=Math.min(1,parseFloat(i)+s*.5);return`rgba(${r},${o},${n},${l.toFixed(3)})`}if(t.startsWith("#")&&t.length>=7){const r=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);if(!isNaN(r)&&!isNaN(o)&&!isNaN(n)){const i=Math.round(r+(255-r)*s),l=Math.round(o+(255-o)*s),c=Math.round(n+(255-n)*s);return`#${i.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}}return t}pm();let as={};function vo({loading:t,children:s,name:a,initialBones:r,color:o,darkColor:n,animate:i,stagger:l=!1,transition:c=!1,boneClass:d,className:u,fallback:f,fixture:h,snapshotConfig:b}){const k=m.useRef(null),j=m.useRef(Math.random().toString(36).slice(2,8)).current,[S,p]=m.useState(0),[N,C]=m.useState(0),[z,I]=m.useState(!1);m.useEffect(()=>{if(typeof window>"u")return;const g=()=>{const K=document.documentElement.classList.contains("dark")||!!k.current?.closest(".dark");I(K)};g();const T=new MutationObserver(g);T.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const R=window.matchMedia("(prefers-color-scheme: dark)");return R.addEventListener("change",g),()=>{T.disconnect(),R.removeEventListener("change",g)}},[]);const U=o??as.color??go.web.light,v=n??as.darkColor??go.web.dark,y=z?v:U,w=i??as.animate??"pulse",A=w===!0?"pulse":w===!1?"solid":w;m.useEffect(()=>{const g=k.current;if(!g)return;const T=new ResizeObserver(K=>{const Z=K[0]?.contentRect;p(Math.round(Z?.width??0)),Z&&Z.height>0&&C(Math.round(Z.height))});T.observe(g);const R=g.getBoundingClientRect();return p(Math.round(R.width)),R.height>0&&C(Math.round(R.height)),()=>T.disconnect()},[]);const B={};if(a&&(B["data-boneyard"]=a,b&&(B["data-boneyard-config"]=JSON.stringify(b))),hm())return e.jsx("div",{ref:k,className:u,style:{position:"relative"},...B,children:e.jsx("div",{children:h??s})});const[E,F]=m.useState(!1);m.useLayoutEffect(()=>{F(!0)},[]);const X=r??(a?xm(a):void 0),J=E&&typeof window<"u"?window.innerWidth:0,ce=S>0?S:J,ne=X&&ce>0?fm(X,ce):null,xe=d??as.boneClass,he=(()=>{const g=l??as.stagger;return g===!0?80:g===!1||!g?0:g})(),H=(()=>{const g=c??as.transition;return g===!0?300:g===!1||!g?0:g})(),[q,M]=m.useState(!1),Y=m.useRef(t),ae=m.useRef(null);m.useEffect(()=>(Y.current&&!t&&H>0&&ne&&(ae.current&&clearTimeout(ae.current),M(!0),ae.current=setTimeout(()=>{M(!1),ae.current=null},H)),Y.current=t,()=>{ae.current&&clearTimeout(ae.current)}),[t,H,ne]);const $e=(t||q)&&ne,Me=t&&!ne&&!q,Ge=N>0?N:ne?.height??0,G=ne?.height??0,te=Ge>0&&G>0?Ge/G:1;return e.jsxs("div",{ref:k,className:u,style:{position:"relative"},...B,children:[e.jsx("div",{"data-boneyard-content":"true",style:$e&&!q?{visibility:"hidden"}:void 0,children:Me?f:s}),$e&&e.jsx("div",{"data-boneyard-overlay":"true",style:{position:"absolute",inset:0,overflow:"hidden",opacity:q?0:1,transition:H>0?`opacity ${H}ms ease-out`:void 0},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ne.bones.filter(g=>!po(g).c).map((g,T)=>{const R=po(g),K=y;bo(y,z?ua.darkAdjust:ua.lightAdjust);const Z=R.w/100*(ne.width??0),re=R.r==="50%"&&Math.abs(Z-R.h)<4,le={position:"absolute",left:`${R.x}%`,top:R.y*te,width:re?R.h*te:`${R.w}%`,height:R.h*te,borderRadius:typeof R.r=="string"?R.r:`${R.r}px`,backgroundColor:K},$=as.speed;if(A==="pulse")le.animation=`bp-${j} ${$??ua.speed} ease-in-out infinite`;else if(A==="shimmer"){const oe=z?as.darkShimmerColor??Us.darkHighlight:as.shimmerColor??Us.lightHighlight,pe=as.shimmerAngle??Us.angle;delete le.backgroundColor,le.backgroundImage=`linear-gradient(${pe}deg, ${K} ${Us.start}%, ${oe} 50%, ${K} ${Us.end}%)`,le.backgroundSize="200% 100%",le.animation=`bs-${j} ${$??Us.speed} linear infinite`}return he>0&&(le.opacity=0,le.animation=`${le.animation?le.animation+",":""} by-${j} 0.3s ease-out ${T*he}ms forwards`),e.jsx("div",{"data-boneyard-bone":"true",className:xe,style:le},T)}),A==="pulse"&&e.jsx("style",{children:`@keyframes bp-${j}{0%,100%{background-color:${y}}50%{background-color:${bo(y,z?ua.darkAdjust:ua.lightAdjust)}}}`}),A==="shimmer"&&e.jsx("style",{children:`@keyframes bs-${j}{0%{background-position:200% 0}100%{background-position:-200% 0}}`}),he>0&&e.jsx("style",{children:`@keyframes by-${j}{from{opacity:0}to{opacity:1}}`})]})})]})}async function cn(t){const s=$t(Ve,"managedStudents");try{const n=kt(s,jt("teacherId","==",t)),i=await Dt(n);if(!i.empty)return i.docs.map(c=>({id:c.id,...c.data()})).sort((c,d)=>String(c.name||"").localeCompare(String(d.name||"")))}catch{}const r=(await Wi(t)).map(n=>n.id);if(r.length===0)return[];const o=new Map;for(let n=0;n{o.set(d.id,{id:d.id,...d.data()})})}return Array.from(o.values()).sort((n,i)=>String(n.name||"").localeCompare(String(i.name||"")))}async function bm(t,s=[]){if(!t)return[];const a=$t(Ve,"users"),r=new Map,o=(i,l)=>String(l.role||"").toLowerCase()!=="student"?null:{uid:i,name:String(l.name||l.displayName||"").trim()||"Student",email:String(l.email||"").trim(),lrn:l.lrn&&String(l.lrn).trim()||void 0,photo:l.photo?String(l.photo).trim()||void 0:l.photoURL&&String(l.photoURL).trim()||void 0,grade:l.grade&&String(l.grade).trim()||void 0,section:l.section&&String(l.section).trim()||void 0,classSectionId:l.classSectionId&&String(l.classSectionId).trim()||void 0,adviserTeacherId:l.adviserTeacherId&&String(l.adviserTeacherId).trim()||void 0,role:"student",createdAt:l.createdAt||void 0};try{const i=kt(a,jt("role","==","student"),jt("adviserTeacherId","==",t));(await Dt(i)).docs.forEach(c=>{const d=o(c.id,c.data());d&&r.set(c.id,d)})}catch(i){console.warn("[studentService] adviser-scoped student query failed:",i)}const n=Array.from(new Set((s||[]).map(i=>(i||"").trim()).filter(i=>!!i)));for(let i=0;i{if(r.has(u.id))return;const f=o(u.id,u.data());f&&r.set(u.id,f)})}catch(c){console.warn("[studentService] section-scoped student query failed:",c)}}return Array.from(r.values()).sort((i,l)=>i.name.localeCompare(l.name))}function vm(t){const s=`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||"Student")}&background=random`,a=El.now();return{id:t.uid,accountUid:t.uid,lrn:t.lrn,name:t.name,email:t.email,avatar:t.photo||s,teacherId:t.adviserTeacherId,grade:t.grade,gradeLevel:us(t.grade)||void 0,section:t.section,classSectionId:t.classSectionId,riskLevel:"Low",engagementScore:0,avgQuizScore:0,weakestTopic:"N/A",classroomId:t.classSectionId||"",attendance:0,assignmentCompletion:0,lastActive:null,struggles:[],createdAt:t.createdAt||a,updatedAt:a,hasRegisteredAccount:!0,source:"registered"}}function wo(t){return(t||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\s]+/g," ").trim().replace(/\s+/g," ")}async function wm(t){const s=(t.studentId||"").trim();if(!s)throw new Error("Cannot reassign section: studentId is required.");const a=(t.newClassSectionId||"").trim()||Lt(t.newGrade,t.newSection);if(!a)throw new Error("Cannot reassign section: a target class section is required.");const r=(t.teacherId||"").trim(),o=(t.teacherName||"").trim(),n=(t.schoolYear||"").trim(),i=(t.previousClassSectionId||"").trim();try{const l=pt(Ve,"managedStudents",s),c=await js(l);c.exists()&&await Zt(l,{grade:t.newGrade,section:t.newSection,classSectionId:a,gradeLevel:us(t.newGrade)||t.newGrade,teacherId:r||c.data()?.teacherId,updatedAt:lt()})}catch(l){console.warn("[studentService] reassignStudentSection: managedStudents update failed:",l)}if(t.isRegisteredAccount)try{await is(pt(Ve,"users",s),{grade:t.newGrade,section:t.newSection,classSectionId:a,adviserTeacherId:r||void 0,adviserTeacherName:o||void 0,updatedAt:lt()},{merge:!0})}catch(l){console.warn("[studentService] reassignStudentSection: users profile update failed:",l)}try{await dr({classSectionId:a,grade:t.newGrade,section:t.newSection,schoolYear:n,ownerTeacherId:r,ownerTeacherName:o,studentUids:[s]})}catch(l){console.warn("[studentService] reassignStudentSection: ownership upsert failed:",l)}if(i&&i!==a)try{const l=pt(Ve,"classSectionOwnership",i),c=await js(l);if(c.exists()){const u=(c.data().studentUids||[]).filter(f=>f!==s);await Zt(l,{studentUids:u,updatedAt:lt()})}}catch(l){console.warn("[studentService] reassignStudentSection: previous-section cleanup failed:",l)}}async function Nm(t){const{apiService:s}=await _r(async()=>{const{apiService:d}=await import("./index-dPnhhJ9w.js").then(u=>u.b6);return{apiService:d}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),a=(t.adviserTeacherId||"").trim();if(!a)throw new Error("createStudentAccountFromRoster requires adviserTeacherId.");const r=(t.email||"").trim().toLowerCase();if(!r)throw new Error("createStudentAccountFromRoster requires an email.");const o=(t.grade||"").trim(),n=(t.section||"").trim(),i=(t.classSectionId||"").trim()||(o&&n?Lt(o,n):""),c=((await s.createStudentAccount({name:(t.name||"").trim()||"Student",email:r,temporaryPassword:t.temporaryPassword,lrn:t.lrn?.trim()||void 0,grade:o||void 0,section:n||void 0,classSectionId:i||void 0,adviserTeacherId:a,adviserTeacherName:t.adviserTeacherName?.trim()||void 0,schoolYear:t.schoolYear?.trim()||void 0})).uid||"").trim();if(!c)throw new Error("Backend did not return a uid for the newly created student.");try{await is(pt(Ve,"managedStudents",c),sr({accountUid:c,name:(t.name||"").trim()||"Student",email:r,lrn:t.lrn?.trim()||null,teacherId:a,grade:o||null,gradeLevel:us(o)||null,section:n||null,classSectionId:i||null,classroomId:i||null,riskLevel:"Low",avgQuizScore:0,engagementScore:0,attendance:0,assignmentCompletion:0,weakestTopic:"",struggles:[],avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||"Student")}&background=random`,hasRegisteredAccount:!0,source:"both",createdAt:lt(),updatedAt:lt()}))}catch(d){console.warn("[studentService] createStudentAccountFromRoster: managed-student merge failed:",d)}if(i&&o&&n)try{await dr({classSectionId:i,grade:o,section:n,schoolYear:t.schoolYear||"",ownerTeacherId:a,ownerTeacherName:t.adviserTeacherName,studentUids:[c]})}catch(d){console.warn("[studentService] createStudentAccountFromRoster: ownership upsert failed:",d)}return{uid:c,email:r,temporaryPassword:t.temporaryPassword}}async function jm(t,s,a){const r=pt(Ve,"managedStudents",t);await Zt(r,{riskLevel:s,...a!==void 0?{riskConfidence:a}:{},updatedAt:lt()})}async function Vi(t,s,a){const r=Lt(s,a),o=pt(Ve,"managedStudents",t);await Zt(o,{grade:s,section:a,classSectionId:r,updatedAt:lt()})}function Lt(t,s){return[t,s].filter(Boolean).join("_").replace(/\s+/g,"_").toLowerCase()}function sr(t){const s=Object.entries(t).filter(([,a])=>a!==void 0);return Object.fromEntries(s)}function us(t){const s=(t||"").trim();if(!s)return null;const a=s.match(/(\d{1,2})/);return a?`Grade ${a[1]}`:/^grade\s+/i.test(s)?s.replace(/\s+/g," ").trim().replace(/^grade/i,"Grade"):s}function sa(t){const a=us(t)?.match(/(\d{1,2})/),r=a?Number.parseInt(a[1],10):Number.NaN;return Number.isFinite(r)?r>=11?"Senior High School":"Junior High School":null}function aa(t,s){const a=`${t||""} ${s||""}`.toUpperCase();if(!a.trim())return null;const r=["STEM","ABM","HUMSS","GAS","TVL","ICT"];for(const o of r)if(new RegExp(`\\b${o}\\b`).test(a))return o;return null}function ls(t){const s=(t||"").trim();if(!s)return{grade:"Grade 11",section:"Section A"};const[a="Grade 11",r="Section A"]=s.split(" - ").map(o=>o.trim());return{grade:a||"Grade 11",section:r||"Section A"}}function gt(t){const s=t.metadata||{},a=t.className||s.className,r=ls(a),o=(t.grade||s.grade||r.grade||"").trim()||null,n=(t.section||s.section||r.section||"").trim()||null,i=(t.classSectionId||s.classSectionId||"").trim()||(o&&n?Lt(o,n):"")||null,l=(a||"").trim()||(o&&n?`${o} - ${n}`:"")||null,c=us(t.gradeLevel||s.gradeLevel||o),d=(t.classification||s.classification||"").trim()||sa(c)||null,u=(t.strand||s.strand||"").trim()||aa(l,n)||null;return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:u,schoolYear:(t.schoolYear||s.schoolYear||"").trim()||null,ownerTeacherId:(t.ownerTeacherId||s.ownerTeacherId||"").trim()||null,ownerTeacherName:(t.ownerTeacherName||s.ownerTeacherName||"").trim()||null,adviserTeacherId:(t.adviserTeacherId||s.adviserTeacherId||"").trim()||null,adviserTeacherName:(t.adviserTeacherName||s.adviserTeacherName||"").trim()||null,managerId:(t.managerId||s.managerId||"").trim()||null,managerName:(t.managerName||s.managerName||"").trim()||null}}function ym(t){const s=(t.className||"").trim(),[a="",r=""]=s.split(" - "),o=(t.grade||a||"").trim()||null,n=(t.section||r||"").trim()||null,i=(t.classSectionId||"").trim()||(o&&n?Lt(o,n):"")||null,l=s||(o&&n?`${o} - ${n}`:null),c=us(t.gradeLevel||o),d=(t.classification||"").trim()||sa(c),u=(t.strand||"").trim()||aa(l,n);return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:u,schoolYear:(t.schoolYear||"").trim()||null,ownerTeacherId:(t.ownerTeacherId||"").trim()||null,ownerTeacherName:(t.ownerTeacherName||"").trim()||null,adviserTeacherId:(t.adviserTeacherId||"").trim()||null,adviserTeacherName:(t.adviserTeacherName||"").trim()||null,managerId:(t.managerId||"").trim()||null,managerName:(t.managerName||"").trim()||null}}async function Wi(t){const s=$t(Ve,"classrooms"),a=new Map,r=kt(s,jt("teacherId","==",t));(await Dt(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=kt(s,jt("managerId","==",t));return(await Dt(n)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})}),Array.from(a.values()).sort((l,c)=>String(l.name||"").localeCompare(String(c.name||"")))}async function dr(t){const s=t.classSectionId||Lt(t.grade,t.section),a=pt(Ve,"classSectionOwnership",s),r=await js(a),o=r.exists()?r.data().studentUids||[]:[],n=Array.from(new Set([...t.studentUids||[],...o])),i=sr(t);return r.exists()?await Zt(a,{...i,classSectionId:s,studentUids:n,updatedAt:lt()}):await is(a,{...i,classSectionId:s,studentUids:n,createdAt:lt(),updatedAt:lt()}),s}async function qi(t){const s=(t.classSectionId||"").trim()||Lt(t.grade,t.section),a=(t.className||"").trim()||`${t.grade} - ${t.section}`,r=ym({classSectionId:s,className:a,grade:t.grade,section:t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName,adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName,classification:t.classification,strand:t.strand,gradeLevel:t.gradeLevel});await dr({classSectionId:s,className:a,grade:r.grade||t.grade,gradeLevel:r.gradeLevel||t.gradeLevel||t.grade,classification:r.classification||t.classification,strand:r.strand||t.strand,section:r.section||t.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName,managerId:t.managerId,managerName:t.managerName,studentUids:[]});const o=$t(Ve,"classrooms"),n=kt(o,jt("classSectionId","==",s)),i=await Dt(n);if(i.empty){const l=sr({name:a,teacherId:t.ownerTeacherId,grade:r.grade,gradeLevel:r.gradeLevel,classification:r.classification,strand:r.strand,section:r.section,classSectionId:s,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName||"",adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName||"",managerId:t.managerId,managerName:t.managerName||"",classMetadata:r,schedule:"Mon-Fri",studentCount:0,avgScore:0,atRiskCount:0,createdAt:lt(),updatedAt:lt()});await is(pt(Ve,"classrooms",s),l,{merge:!0})}else for(const l of i.docs){const c=sr({name:a,grade:r.grade,gradeLevel:r.gradeLevel,classification:r.classification,strand:r.strand,section:r.section,schoolYear:t.schoolYear,ownerTeacherId:t.ownerTeacherId,ownerTeacherName:t.ownerTeacherName||"",adviserTeacherId:t.ownerTeacherId,adviserTeacherName:t.ownerTeacherName||"",managerId:t.managerId,managerName:t.managerName||"",classMetadata:r,updatedAt:lt()});await Zt(l.ref,c)}return s}async function mr(t,s,a,r,o,n){const i=Lt(s,a);await dr({classSectionId:i,grade:s,section:a,schoolYear:o,ownerTeacherId:r,ownerTeacherName:n,studentUids:[t]}),await is(pt(Ve,"users",t),{grade:s,section:a,classSectionId:i,adviserTeacherId:r,adviserTeacherName:n||"",updatedAt:lt()},{merge:!0})}async function Sm(t){const s=$t(Ve,"classSectionOwnership"),a=new Map,r=kt(s,jt("ownerTeacherId","==",t));(await Dt(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=kt(s,jt("managerId","==",t));return(await Dt(n)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})}),Array.from(a.values()).sort((l,c)=>String(l.classSectionId||"").localeCompare(String(c.classSectionId||"")))}async function km(t="",s=25){const a=$t(Ve,"users"),r=Math.max(1,Math.min(100,s)),o=kt(a,jt("role","==","teacher"),Vr(r*4)),n=await Dt(o),i=t.trim().toLowerCase();return n.docs.map(c=>{const d=c.data(),u=String(d.name||"").trim(),f=String(d.email||"").trim();return{uid:c.id,name:u||"Teacher",email:f,photo:String(d.photo||d.photoURL||"").trim()||void 0}}).filter(c=>i?c.name.toLowerCase().includes(i)||c.email.toLowerCase().includes(i):!0).sort((c,d)=>c.name.localeCompare(d.name)).slice(0,r)}function Cm(t,s,a=20){if(t.length===0)return s([]),()=>{};const r=$t(Ve,"activities"),o=kt(r,jt("classroomId","in",t),Rl("timestamp","desc"));return ti(o,n=>{const i=n.docs.slice(0,a).map(l=>({id:l.id,...l.data()}));s(i)})}const Im=({open:t,onClose:s,onCreated:a,teacherName:r})=>{const{currentUser:o}=ds(),[n,i]=m.useState("details"),[l,c]=m.useState(""),[d,u]=m.useState("Grade 11"),[f,h]=m.useState(""),[b,k]=m.useState(!1),[j,S]=m.useState(""),[p,N]=m.useState([]),[C,z]=m.useState(new Set),[I,U]=m.useState(""),[v,y]=m.useState(!1);m.useEffect(()=>{t||(i("details"),c(""),u("Grade 11"),h(""),S(""),z(new Set),U(""))},[t]),m.useEffect(()=>{t&&n==="students"&&w()},[t,n]);const w=async()=>{y(!0);try{const F=$t(Ve,"users"),X=kt(F,jt("role","==","student")),J=await Dt(X),ce=[];J.docs.forEach(ne=>{const xe=ne.data();ce.push({uid:ne.id,name:xe.name||xe.displayName||"Student",email:xe.email||"",grade:xe.grade,section:xe.section})}),N(ce.sort((ne,xe)=>ne.name.localeCompare(xe.name)))}catch(F){console.error("[CreateClassModal] Failed to load students:",F)}finally{y(!1)}},A=async()=>{if(o){if(!f.trim()){S("Section name is required");return}S(""),k(!0);try{const F=String(new Date().getFullYear());if(await qi({classSectionId:"",grade:d,section:f.trim(),schoolYear:F,ownerTeacherId:o.uid,ownerTeacherName:r||o.displayName||"",managerId:o.uid,managerName:r||o.displayName||"",className:l.trim()||`${d} - ${f.trim()}`}),C.size>0){const X=Array.from(C).map(J=>mr(J,d,f.trim(),o.uid,F,r||o.displayName||""));await Promise.allSettled(X)}a(),s()}catch(F){S(F instanceof Error?F.message:"Failed to create class")}finally{k(!1)}}},B=F=>{z(X=>{const J=new Set(X);return J.has(F)?J.delete(F):J.add(F),J})},E=p.filter(F=>F.name.toLowerCase().includes(I.toLowerCase())||F.email.toLowerCase().includes(I.toLowerCase()));return t?e.jsx(Et,{children:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white rounded-2xl shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#f1f5f9]",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#1e293b]",children:n==="details"?"Create New Class":"Add Students"}),e.jsx("button",{onClick:s,className:"p-1 rounded-lg hover:bg-[#f1f5f9] transition-colors",children:e.jsx(cs,{size:20,className:"text-[#64748b]"})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto flex-1",children:[n==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#475569] block mb-1.5",children:"Class Name"}),e.jsx(ws,{placeholder:"e.g. Grade 11 - Section A",value:l,onChange:F=>c(F.target.value)}),e.jsx("p",{className:"text-xs text-[#94a3b8] mt-1",children:"Optional. Auto-generated from grade + section if empty."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#475569] block mb-1.5",children:"Grade Level"}),e.jsxs("select",{value:d,onChange:F=>u(F.target.value),className:"w-full px-3 py-2 border border-[#e2e8f0] rounded-lg text-sm bg-white",children:[e.jsx("option",{value:"Grade 11",children:"Grade 11"}),e.jsx("option",{value:"Grade 12",children:"Grade 12"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#475569] block mb-1.5",children:"Section"}),e.jsx(ws,{placeholder:"e.g. Section A, STEM-1, Rizal",value:f,onChange:F=>h(F.target.value)})]}),j&&e.jsx("p",{className:"text-sm text-rose-500",children:j})]}),n==="students"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Os,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#94a3b8]"}),e.jsx(ws,{placeholder:"Search students...",value:I,onChange:F=>U(F.target.value),className:"pl-9"})]}),e.jsxs("p",{className:"text-xs text-[#64748b]",children:[C.size," student(s) selected"]}),v?e.jsx("p",{className:"text-sm text-[#64748b] text-center py-4",children:"Loading students..."}):E.length===0?e.jsx("p",{className:"text-sm text-[#64748b] text-center py-4",children:"No students found."}):e.jsx("div",{className:"space-y-1 max-h-[300px] overflow-y-auto",children:E.map(F=>e.jsxs("button",{onClick:()=>B(F.uid),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors ${C.has(F.uid)?"bg-purple-50 border border-purple-200":"hover:bg-[#f8fafc] border border-transparent"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-md border-2 flex items-center justify-center ${C.has(F.uid)?"bg-[#9956DE] border-[#9956DE]":"border-[#cbd5e1]"}`,children:C.has(F.uid)&&e.jsx(Mt,{size:12,className:"text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#1e293b] truncate",children:F.name}),e.jsx("p",{className:"text-xs text-[#64748b] truncate",children:F.email})]}),F.grade&&e.jsx("span",{className:"text-xs text-[#94a3b8]",children:F.grade})]},F.uid))}),j&&e.jsx("p",{className:"text-sm text-rose-500",children:j})]})]}),e.jsx("div",{className:"flex items-center justify-between p-6 border-t border-[#f1f5f9]",children:n==="details"?e.jsxs(e.Fragment,{children:[e.jsx(xt,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xt,{variant:"outline",onClick:()=>{if(!f.trim()){S("Section is required");return}S(""),i("students")},children:"Add Students"}),e.jsx(xt,{onClick:A,disabled:b||!f.trim(),className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:b?"Creating...":"Create Class"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xt,{variant:"outline",onClick:()=>i("details"),children:"Back"}),e.jsxs(xt,{onClick:A,disabled:b,className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Js,{size:16,className:"mr-1"}),b?"Creating...":`Create with ${C.size} Student${C.size!==1?"s":""}`]})]})})]})]})}):null},Tm=({open:t,onClose:s,onAdded:a,grade:r,section:o,teacherName:n,existingStudentUids:i=[]})=>{const{currentUser:l}=ds(),[c,d]=m.useState([]),[u,f]=m.useState(new Set),[h,b]=m.useState(""),[k,j]=m.useState(!1),[S,p]=m.useState(!1);m.useEffect(()=>{t&&(f(new Set),b(""),N())},[t]);const N=async()=>{j(!0);try{const I=kt($t(Ve,"users"),jt("role","==","student")),v=(await Dt(I)).docs.filter(y=>!i.includes(y.id)).map(y=>{const w=y.data();return{uid:y.id,name:w.name||w.displayName||"Student",email:w.email||""}}).sort((y,w)=>y.name.localeCompare(w.name));d(v)}catch{}j(!1)},C=async()=>{if(!(!l||u.size===0)){p(!0);try{const I=String(new Date().getFullYear()),U=Array.from(u).map(v=>mr(v,r,o,l.uid,I,n||l.displayName||""));await Promise.allSettled(U),me.success(`Added ${u.size} student(s) to class`),a(),s()}catch{me.error("Failed to add students")}p(!1)}},z=c.filter(I=>I.name.toLowerCase().includes(h.toLowerCase())||I.email.toLowerCase().includes(h.toLowerCase()));return t?e.jsx(Et,{children:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white rounded-2xl shadow-xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-[#f1f5f9]",children:[e.jsxs("h2",{className:"text-base font-semibold text-[#1e293b]",children:["Add Students to ",r," - ",o]}),e.jsx("button",{onClick:s,className:"p-1 rounded-lg hover:bg-[#f1f5f9]",children:e.jsx(cs,{size:18,className:"text-[#64748b]"})})]}),e.jsxs("div",{className:"p-4 space-y-3 flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Os,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#94a3b8]"}),e.jsx(ws,{placeholder:"Search students...",value:h,onChange:I=>b(I.target.value),className:"pl-8 h-9 text-sm"})]}),e.jsx("button",{onClick:()=>{u.size===z.length?f(new Set):f(new Set(z.map(I=>I.uid)))},className:"text-[11px] font-semibold text-[#9956DE] hover:text-[#7c3aed] bg-[#9956DE]/10 hover:bg-[#9956DE]/20 px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",children:u.size===z.length&&z.length>0?"Deselect All":"Select All"})]}),e.jsxs("p",{className:"text-xs text-[#64748b]",children:[u.size," of ",z.length," selected"]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-1 min-h-[300px]",children:k?e.jsx("p",{className:"text-sm text-center text-[#64748b] py-6",children:"Loading..."}):z.length===0?e.jsx("p",{className:"text-sm text-center text-[#64748b] py-6",children:"No students available"}):z.map(I=>e.jsxs("button",{onClick:()=>f(U=>{const v=new Set(U);return v.has(I.uid)?v.delete(I.uid):v.add(I.uid),v}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors ${u.has(I.uid)?"bg-purple-50 border border-purple-200":"hover:bg-[#f8fafc] border border-transparent"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-md border-2 flex items-center justify-center shrink-0 ${u.has(I.uid)?"bg-[#9956DE] border-[#9956DE]":"border-[#cbd5e1]"}`,children:u.has(I.uid)&&e.jsx(Mt,{size:12,className:"text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#1e293b] truncate",children:I.name}),e.jsx("p",{className:"text-[11px] text-[#64748b] truncate",children:I.email})]})]},I.uid))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-[#f1f5f9]",children:[e.jsx(xt,{variant:"outline",size:"sm",onClick:s,children:"Cancel"}),e.jsxs(xt,{size:"sm",onClick:C,disabled:S||u.size===0,className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Ko,{size:14,className:"mr-1.5"}),S?"Adding...":`Add ${u.size} Student${u.size!==1?"s":""}`]})]})]})]})}):null};async function Em(t,s,a){const r=pt($t(Ve,"generatedLessonPlans"));return await is(r,{...t,teacherId:s,teacherName:a?.teacherName||null,studentId:a?.studentId||null,studentName:a?.studentName||null,status:"draft",createdAt:lt(),updatedAt:lt()}),r.id}async function Rm(t){const s=pt(Ve,"generatedLessonPlans",t),a=await js(s);if(!a.exists())throw new Error("Lesson draft not found. Save draft before publishing.");if(!a.data().publishReady)throw new Error("Lesson is not publish-ready. Resolve source legitimacy and validation issues first.");await Zt(s,{status:"published",publishedAt:lt(),updatedAt:lt()})}async function _m(t,s=!0){const a=t.learningCompetency||t.lessonTitle||t.focusTopics&&t.focusTopics[0]||"general mathematics",r=t.subject||"general_math",o=t.quarter??1;let n="",i=[],l,c,d,u=!1;if(s)try{const b=await bl(a,r,o,{lessonTitle:t.lessonTitle,learningCompetency:t.learningCompetency,moduleUnit:t.moduleUnit,learnerLevel:t.learnerLevel});i=b.sources||[],n=b.explanation||"",l=b.retrievalConfidence,c=b.retrievalBand,d=b.retrievalQuery,u=b.needsReview??!1}catch{n="",i=[]}const f={...t,subject:r,quarter:o,curriculumContext:n?`[CURRICULUM CONTEXT] -${n}`:void 0,curriculumRetrievalConfidence:l,curriculumRetrievalBand:c,curriculumRetrievalQuery:d,needsReview:u};return{...await nt.generateLessonPlan(f),curriculumSources:i,curriculumContext:n}}const Mm=Il("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Am({className:t,variant:s,asChild:a=!1,...r}){const o=a?Gl:"span";return e.jsx(o,{"data-slot":"badge",className:Xo(Mm({variant:s}),t),...r})}function zm(t){return t.length<=42?t:`${t.slice(0,18)}...${t.slice(-20)}`}const No=({sources:t=[],className:s})=>t.length?e.jsxs(Ql,{children:[e.jsx(Ul,{asChild:!0,children:e.jsxs(Am,{className:["bg-[#75D06A]/15 text-[#2E7D32] border-[#75D06A]/40 font-body font-semibold text-[11px] px-2.5 py-1 rounded-full cursor-help",s||""].join(" "),variant:"outline",children:[e.jsx(Gt,{size:12}),"DepEd Aligned"]})}),e.jsxs(Vl,{side:"top",sideOffset:6,className:"max-w-sm bg-white border border-[#dde3eb] text-[#0a1628] shadow-lg p-3",children:[e.jsx("p",{className:"text-[11px] font-display font-bold uppercase tracking-wide text-[#5a6578] mb-2",children:"Curriculum Sources"}),e.jsx("div",{className:"space-y-2",children:t.slice(0,5).map((a,r)=>e.jsxs("div",{className:"text-xs leading-relaxed",children:[e.jsxs("p",{className:"font-semibold text-[#0a1628]",children:[a.subject," | Q",a.quarter]}),e.jsxs("p",{className:"text-[#5a6578]",children:[zm(a.sourceFile)," | p.",a.page]}),e.jsxs("p",{className:"text-[#5a6578]",children:["Similarity: ",(a.score*100).toFixed(1),"%"]})]},`${a.sourceFile}-${a.page}-${r}`))})]})]}):null,Lm=[{level:"Remember",icon:Mr,bgColor:"bg-sky-500/20",borderColor:"border-sky-500/40",textColor:"text-sky-400",description:"Recall facts, formulas, definitions, and basic procedures.",mathExample:"State the quadratic formula.",mapsTo:"Identification, Enumeration",defaultWeight:"Included by default"},{level:"Understand",icon:Gt,bgColor:"bg-sky-500/20",borderColor:"border-sky-500/40",textColor:"text-sky-400",description:"Explain concepts, interpret graphs, classify mathematical objects.",mathExample:"Explain why the discriminant determines the number of roots.",mapsTo:"Multiple Choice, Identification",defaultWeight:"Included by default"},{level:"Apply",icon:vl,bgColor:"bg-green-500/20",borderColor:"border-green-500/40",textColor:"text-green-400",description:"Use formulas and procedures to solve routine problems.",mathExample:"Solve: 2x² + 5x - 3 = 0 using the quadratic formula.",mapsTo:"Equation-Based, Word Problem",defaultWeight:"Included by default"},{level:"Analyze",icon:pc,bgColor:"bg-orange-500/20",borderColor:"border-orange-500/40",textColor:"text-orange-400",description:"Break down problems, compare solution methods, identify patterns.",mathExample:"Given f(x) = x³ - 3x, find and classify all critical points.",mapsTo:"Word Problem, Equation-Based",defaultWeight:"Included by default"}],Dm=({isOpen:t,onClose:s})=>t?e.jsx(Et,{children:t&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[70] flex items-center justify-center p-4",onClick:s,children:e.jsxs(Re.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white border border-slate-200 rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 px-6 py-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",children:e.jsx(Jo,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"Bloom's Taxonomy in MathPulse AI"}),e.jsx("p",{className:"text-cyan-200 text-xs",children:"Understanding cognitive levels in assessments"})]})]}),e.jsx("button",{onClick:s,className:"w-8 h-8 bg-white/20 hover:bg-white/30 rounded-lg flex items-center justify-center transition-colors",children:e.jsx(cs,{size:16,className:"text-white"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-2",children:"What is Bloom's Taxonomy?"}),e.jsx("p",{className:"text-sm text-slate-500 leading-relaxed",children:"Bloom's Taxonomy is an educational framework developed by Benjamin Bloom in 1956 and revised in 2001. It classifies learning objectives into six cognitive levels, from basic recall of facts up to complex evaluation and creation. MathPulse AI uses the first four levels most relevant to Senior High School mathematics."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-2",children:"Why MathPulse AI Uses It"}),e.jsx("p",{className:"text-sm text-slate-500 leading-relaxed",children:"Using Bloom's Taxonomy ensures that assessments do not only test memorization. A well-balanced math quiz should challenge students at multiple cognitive levels: remembering formulas, understanding concepts, applying procedures, and analyzing relationships. This mirrors the DepEd K-12 competency framework which requires higher-order thinking skills (HOTS) alongside foundational knowledge."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-rose-400 uppercase tracking-wide mb-3",children:"Level-by-Level Breakdown"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Lm.map(a=>{const r=a.icon;return e.jsxs("div",{className:`${a.bgColor} border ${a.borderColor} rounded-xl p-4 space-y-2`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{size:18,className:a.textColor}),e.jsx("span",{className:`font-bold text-sm ${a.textColor}`,children:a.level})]}),e.jsx("p",{className:"text-xs text-slate-500",children:a.description}),e.jsxs("div",{className:"bg-black/20 rounded-lg p-2",children:[e.jsx("p",{className:"text-[10px] font-semibold text-slate-500 uppercase tracking-wide mb-0.5",children:"Math Example"}),e.jsx("p",{className:"text-xs text-[#dde3eb] italic",children:a.mathExample})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsxs("span",{className:"text-slate-500",children:["Maps to: ",e.jsx("span",{className:"text-slate-500 font-medium",children:a.mapsTo})]}),e.jsx("span",{className:"text-green-400 font-medium",children:a.defaultWeight})]})]},a.level)})})]}),e.jsx("div",{className:"bg-slate-50 border border-slate-200 rounded-xl p-4",children:e.jsxs("p",{className:"text-xs text-slate-500 leading-relaxed",children:[e.jsx("span",{className:"font-semibold text-slate-600",children:"Note:"})," ","All four levels are selected by default to produce a balanced, HOTS-aligned assessment. Deselecting a level will remove questions of that cognitive depth from the generated quiz."]})})]}),e.jsxs("div",{className:"border-t border-slate-200 px-6 py-3 flex items-center justify-between flex-shrink-0 bg-slate-50",children:[e.jsxs("a",{href:"https://cft.vanderbilt.edu/guides-sub-pages/blooms-taxonomy/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-rose-400 hover:text-rose-300 font-medium transition-colors",children:[e.jsx(vc,{size:12}),"Learn More"]}),e.jsx("button",{onClick:s,className:"px-5 py-2 bg-sky-600 hover:bg-rose-500 text-white text-sm font-bold rounded-xl transition-colors",children:"Got it"})]})]})})}):null,$m={draft:"bg-[#edf1f7] text-[#5a6578]",published:"bg-green-100 text-green-700",assigned:"bg-sky-100 text-sky-700",completed:"bg-rose-100 text-rose-700"},Fa={identification:{label:"Identification",icon:e.jsx(gs,{size:16}),description:"Define or identify concepts"},enumeration:{label:"Enumeration",icon:e.jsx(Ka,{size:16}),description:"List steps or properties"},multiple_choice:{label:"Multiple Choice",icon:e.jsx(Mt,{size:16}),description:"Choose from 4 options"},word_problem:{label:"Word Problem",icon:e.jsx(Gt,{size:16}),description:"Real-world scenarios"},equation_based:{label:"Equation-Based",icon:e.jsx(wl,{size:16}),description:"Solve equations"}},jo={remember:{label:"Remember",color:"bg-sky-100 text-sky-700 border-sky-300",description:"Recall facts & formulas"},understand:{label:"Understand",color:"bg-emerald-100 text-emerald-700 border-emerald-300",description:"Explain concepts"},apply:{label:"Apply",color:"bg-rose-100 text-rose-700 border-rose-300",description:"Use in new contexts"},analyze:{label:"Analyze",color:"bg-rose-100 text-rose-700 border-rose-300",description:"Examine & compare"}},Fm=["Grade 11","Grade 12"],Sr=t=>{const s=(t||"").trim().toLowerCase();return s==="grade 12"||s==="12"||s.includes("12")?"Grade 12":"Grade 11"},Om={"Grade 11":{"General Mathematics - Patterns, Relations, and Functions":["Patterns and Real-Life Relationships","Functions as Mathematical Models","Function Notation and Evaluation","Domain and Range of Functions","Operations on Functions","Composite Functions","Inverse Functions","Graphs of Rational Functions","Graphs of Exponential Functions","Graphs of Logarithmic Functions"],"General Mathematics - Financial Mathematics":["Simple and Compound Interest","Simple and General Annuities","Present and Future Value","Loans, Amortization, and Sinking Funds","Stocks, Bonds, and Market Indices","Business Decision-Making with Mathematical Models"],"General Mathematics - Logic and Mathematical Reasoning":["Propositions and Logical Connectives","Truth Values and Truth Tables","Logical Equivalence and Implication","Quantifiers and Negation","Validity of Arguments"]},"Grade 12":{"Pre-Calculus - Analytic Geometry":["Conic Sections - Parabola","Conic Sections - Ellipse","Conic Sections - Hyperbola","Conic Sections - Circle","Systems of Nonlinear Equations"],"Pre-Calculus - Series and Induction":["Sequences and Series","Arithmetic Sequences","Geometric Sequences","Mathematical Induction","Binomial Theorem"],"Pre-Calculus - Trigonometry":["Angles and Unit Circle","Trigonometric Functions","Trigonometric Identities","Sum and Difference Formulas","Inverse Trigonometric Functions","Polar Coordinates"],"Basic Calculus - Limits":["Limits of Functions","Limit Theorems","One-Sided Limits","Infinite Limits and Limits at Infinity","Continuity of Functions"],"Basic Calculus - Derivatives":["Definition of the Derivative","Differentiation Rules","Chain Rule","Implicit Differentiation","Higher-Order Derivatives","Related Rates","Extrema and the First Derivative Test","Concavity and the Second Derivative Test","Optimization Problems"],"Basic Calculus - Integration":["Antiderivatives and Indefinite Integrals","Definite Integrals and the FTC","Integration by Substitution","Area Under a Curve"]}},Bm={"Grade 11":["General Mathematics - "],"Grade 12":["Pre-Calculus - ","Basic Calculus - "]},yo=(t,s)=>{const a=Bm[s];return Object.fromEntries(Object.entries(t).filter(([r])=>a.some(o=>r.startsWith(o))))},xa=30,pa=12,kr="mathpulse:quiz-maker:active-task",Pm={easy:"text-green-600",medium:"text-rose-600",hard:"text-red-600"},Yi=({onBack:t,gradeLevel:s,selectedClassId:a,selectedClassName:r,onOpenNotifications:o,onOpenProfile:n,onOpenInsightModal:i,userPhoto:l,teacherName:c,drawerMode:d=!1,onQuizSaved:u,onQuizGenerating:f})=>{const{currentUser:h,loading:b}=ds(),k=m.useMemo(()=>nt.getImportGroundedRolloutFlags(),[]),[j,S]=m.useState("create"),[p,N]=m.useState("setup"),[C,z]=m.useState(Sr(s)),[I,U]=m.useState(10),[v,y]=m.useState([]),[w,A]=m.useState([]),[B,E]=m.useState(["multiple_choice","word_problem","identification"]),[F,X]=m.useState(["remember","understand","apply","analyze"]),[J,ce]=m.useState(!1),[ne,xe]=m.useState({easy:30,medium:50,hard:20}),[he,H]=m.useState({}),[q,M]=m.useState(!1),[Y,ae]=m.useState([]),[$e,Me]=m.useState(!1),[Ge,G]=m.useState(""),[te,g]=m.useState(!1),[T,R]=m.useState(!1),[K,Z]=m.useState(null),[re,le]=m.useState(0),[$,oe]=m.useState("queued"),[pe,we]=m.useState("Waiting to start generation..."),[se,fe]=m.useState(null),[et,Fe]=m.useState(null),[Ke,rt]=m.useState(""),[Rt,St]=m.useState(!1),Ft=m.useRef(!1),[ss,P]=m.useState("topics"),[Ae,Ye]=m.useState(null),[vt,xs]=m.useState(!1),[Ot,Wt]=m.useState("all"),[qt,Rs]=m.useState("all"),[st,Aa]=m.useState(!1),[_t,_]=m.useState(null),[ee,ze]=m.useState(!1),[Ne,Qe]=m.useState(!1),[je,ft]=m.useState(!1),[ot,Ce]=m.useState([]),[ps,Yt]=m.useState(!1),[_s,za]=m.useState(""),[Kt,ra]=m.useState(null),[na,hs]=m.useState([]),[oa,ia]=m.useState(!1),[Hs,ur]=m.useState("all"),[xr,la]=m.useState(null),[ca,L]=m.useState(null),V=m.useCallback(async()=>{M(!0);const x=Sr(C);try{const D=await nt.getQuizTopics(x);D.topics&&H(yo(D.topics,x))}catch{H(yo(Om[x],x))}finally{M(!1)}},[C]),ke=m.useCallback(async()=>{if(!k.quizEnabled){ae([]),G("Import-grounded quiz generation is disabled by rollout flag; using curriculum defaults."),Me(!1);return}Me(!0),G("");try{const x=await nt.getCourseMaterialTopics({classSectionId:a,limit:20}),D=(x.topics||[]).filter(O=>O.title?.trim());ae(D),x.warnings&&x.warnings.length>0&&G(x.warnings.join(" "))}catch{ae([]),G("Imported topics are currently unavailable; quiz generation will use curriculum defaults.")}finally{Me(!1)}},[a,k.quizEnabled]);m.useEffect(()=>{V(),y([]),A([])},[V]),m.useEffect(()=>{ke()},[ke]);const _e=m.useMemo(()=>{const x=Array.from(new Set(Y.map(D=>D.title.trim()).filter(Boolean)));return x.length===0?he:{"Imported Course Materials":x,...he}},[he,Y]);m.useEffect(()=>{Wt("all"),Rs("all")},[se]);const Bt=m.useMemo(()=>{if(!se)return[];const x=se.questions.map(O=>O.provenance?.sourceFile?.trim()).filter(O=>!!O),D=(se.metadata.topicProvenance||[]).map(O=>O.sourceFile?.trim()).filter(O=>!!O);return Array.from(new Set([...x,...D])).sort((O,ge)=>O.localeCompare(ge))},[se]),Ee=m.useMemo(()=>{if(!se)return[];const x=se.questions.map(O=>O.provenance?.materialId?.trim()).filter(O=>!!O),D=(se.metadata.topicProvenance||[]).map(O=>O.materialId?.trim()).filter(O=>!!O);return Array.from(new Set([...x,...D])).sort((O,ge)=>O.localeCompare(ge))},[se]),Gs=m.useMemo(()=>se?se.questions.filter(x=>{const D=Ot==="all"||(x.provenance?.sourceFile||"").trim()===Ot,O=qt==="all"||(x.provenance?.materialId||"").trim()===qt;return D&&O}):[],[se,Ot,qt]),It=(x,D)=>{const O={...ne},ge=Math.max(0,Math.min(100,O[x]+D)),Oe=ge-O[x];O[x]=ge;const We=Object.keys(O).filter(it=>it!==x),Pt=We.reduce((it,Xt)=>it+O[Xt],0);if(Pt>0)for(const it of We)O[it]=Math.max(0,Math.round(O[it]-Oe*O[it]/Pt));const Qs=Object.values(O).reduce((it,Xt)=>it+Xt,0);if(Qs!==100){const it=We.reduce((Xt,Nn)=>O[Xt]>=O[Nn]?Xt:Nn);O[it]+=100-Qs}xe(O)},Pe=x=>{y(D=>D.includes(x)?D.filter(O=>O!==x):[...D,x]),A(D=>D.filter(O=>O!==x))},da=x=>{E(D=>D.includes(x)?D.length>1?D.filter(O=>O!==x):D:[...D,x])},ma=x=>{X(D=>D.includes(x)?D.length>1?D.filter(O=>O!==x):D:[...D,x])},ol=()=>{let x=v.length>0?v.filter(O=>!w.includes(O)):Object.values(_e).flat().filter(O=>!w.includes(O)).slice(0,3);x.length>pa&&(x=x.slice(0,pa));const D=Math.min(I,xa);return{topics:x,gradeLevel:C,numQuestions:D,questionTypes:B,includeGraphs:J,difficultyDistribution:ne,bloomLevels:F,excludeTopics:w,classSectionId:a,className:r,preferImportedTopics:k.quizEnabled}},il=m.useCallback((x,D)=>{const O={taskId:x,request:D,createdAt:new Date().toISOString(),ownerUid:h?.uid};try{sessionStorage.setItem(kr,JSON.stringify(O))}catch{}},[h]),fs=m.useCallback(()=>{try{sessionStorage.removeItem(kr)}catch{}},[]),pr=m.useCallback(x=>{const D=Math.max(0,Math.min(100,Math.round(typeof x.progressPercent=="number"?x.progressPercent:x.status==="queued"?10:x.status==="running"?65:x.status==="completed"?100:x.status==="cancelling"?95:100)));le(O=>{let ge=Math.max(O,D);if(x.status==="running"&&D<=O){const Oe=String(x.progressStage||"").toLowerCase(),We=Oe.includes("assembling")||Oe.includes("final")?97:Oe.includes("generating")?89:95;ge=Math.min(We,O+1)}return ge}),oe(x.progressStage||x.status),we(x.progressMessage||(x.status==="queued"?"Task queued for generation.":x.status==="running"?"Generating quiz in the background...":x.status==="completed"?"Generation complete.":x.status==="cancelling"?"Cancelling generation...":"Generation finished with an error."))},[]);m.useEffect(()=>{if(b||Ft.current)return;if(Ft.current=!0,!h){fs();return}let x=!1;const D=sessionStorage.getItem(kr);if(!D)return;let O=null;try{O=JSON.parse(D)}catch{fs();return}if(!O?.taskId){fs();return}if(O.ownerUid&&O.ownerUid!==h.uid){fs();return}return g(!0),Z(O.taskId),rt(""),nt.waitForTaskResult(O.taskId,{timeoutMs:24e4,pollIntervalMs:1500,onProgress:pr}).then(async ge=>{if(x)return;const Oe=ge.result;if(!Oe||typeof Oe!="object")throw new Error("Quiz generation completed without a valid result payload.");const We=Oe;fe(We),N("results"),le(100),oe("completed"),we("Generation complete."),Z(null),fs();try{await fn(We,O.request),me.success("Quiz auto-saved to your library as draft.")}catch(Pt){me.error(Pt instanceof Error?Pt.message:"Quiz generated but failed to save to library")}}).catch(ge=>{if(!x){if(ge instanceof qa&&(ge.status===401||ge.status===403)){Ft.current=!1,g(!1);return}rt(ge instanceof Error?ge.message:"Failed to resume quiz generation"),Z(null),fs()}}).finally(()=>{x||g(!1)}),()=>{x=!0}},[pr,b,fs,h]);const xn=()=>{if(te){window.confirm("Quiz generation is in progress. Are you sure you want to leave?")&&(N("setup"),fe(null),rt(""),t());return}N("setup"),fe(null),rt(""),t()},ll=async()=>{f?.(),rt(""),g(!0),L(null),le(8),oe("queued"),we("Submitting quiz generation task..."),fe(null);const x=ol();try{const D=await nt.generateQuiz(x,{onTaskCreated:O=>{Z(O),il(O,x),le(ge=>Math.max(ge,12)),oe("queued"),we("Task queued. Generation is running in the background.")},onProgress:O=>{pr(O),O.taskId&&O.taskId!==K&&Z(O.taskId)}});fe(D),N("results"),le(100),oe("completed"),we("Generation complete."),Z(null),fs();try{await fn(D,x),me.success("Quiz auto-saved to your library as draft.")}catch(O){me.error(O instanceof Error?O.message:"Quiz generated but failed to save to library")}nt.reportImportGroundedFeedback({flow:"quiz",status:"success",classSectionId:x.classSectionId,className:x.className,metadata:{totalQuestions:D.metadata.totalQuestions,usedImportedTopics:!!D.metadata.usedImportedTopics,importedTopicCount:D.metadata.importedTopicCount??0,importGroundingEnabled:k.quizEnabled}})}catch(D){rt(D instanceof Error?D.message:"Quiz generation failed"),le(100),oe("failed"),we("Generation failed."),Z(null),fs(),nt.reportImportGroundedFeedback({flow:"quiz",status:"failed",classSectionId:x.classSectionId,className:x.className,metadata:{error:D instanceof Error?D.message:"Quiz generation failed",importGroundingEnabled:k.quizEnabled}})}finally{g(!1)}},cl=()=>{if(!se)return;const x=se.questions.map((D,O)=>{let ge=`${O+1}. [${D.difficulty.toUpperCase()}] [${D.bloomLevel}] (${D.points} pts) -`;return ge+=` ${D.question} -`,D.options&&(ge+=D.options.map(Oe=>` ${Oe}`).join(` -`)+` -`),ge+=` Answer: ${D.correctAnswer} -`,ge+=` Explanation: ${D.explanation} -`,ge}).join(` -`);navigator.clipboard.writeText(x),St(!0),setTimeout(()=>St(!1),2e3)},dl=()=>{if(!se)return;const x=new Blob([JSON.stringify(se,null,2)],{type:"application/json"}),D=URL.createObjectURL(x),O=document.createElement("a");O.href=D,O.download=`quiz_${C.replace(/\s/g,"_")}_${Date.now()}.json`,O.click(),URL.revokeObjectURL(D)};v.length>0||Object.values(_e).flat().length>0;const pn=(x,D)=>{const O=D?.gradeLevel||C,ge=D?.topics||v,Oe=x.questions.map((We,Pt)=>({id:`q_${Date.now()}_${Pt}`,questionType:We.questionType||"identification",question:We.question,...We.options?{options:We.options}:{},correctAnswer:We.correctAnswer,bloomLevel:We.bloomLevel||"understand",difficulty:We.difficulty||"medium",topic:We.topic,subject:O,points:We.points,explanation:We.explanation}));return{title:`${O} Quiz – ${ge.length>0?ge.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:O,questions:Oe,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"}},hn=m.useCallback(x=>{hs(D=>[x,...D.filter(O=>O.id!==x.id)])},[]);async function fn(x,D){if(!h)return null;const O=pn(x,D),ge=await In(O,h.uid,_t?{documentId:_t}:void 0);return _(ge),hn({id:ge,...O,teacherId:h.uid}),ge}const ml=async()=>{if(!se){me.error("No quiz to save. Generate a quiz first.");return}if(!h){me.error("You must be signed in to save quizzes.");return}Aa(!0);try{const x=pn(se),D=await In(x,h.uid,_t?{documentId:_t}:void 0);_(D),hn({id:D,...x,teacherId:h.uid}),me.success("Quiz saved to your library!"),u?.(D)}catch(x){me.error(x instanceof Error?x.message:"Failed to save quiz")}finally{Aa(!1)}},ul=async()=>{if(_t){ze(!0);try{await Ol(_t),hs(x=>x.map(D=>D.id===_t?{...D,status:"published"}:D)),me.success("Quiz published to Quiz Bank!")}catch(x){me.error(x instanceof Error?x.message:"Failed to publish quiz")}finally{ze(!1)}}},hr=async x=>{const D=x??_t;if(!D){me.error("Save the quiz first before assigning.");return}if(la(D),Qe(!0),ra(null),za(""),ot.length===0&&h){Yt(!0);try{const O=await cn(h.uid);Ce(O)}catch{me.error("Failed to load students")}finally{Yt(!1)}}},xl=async()=>{const x=xr??_t;if(!(!Kt||!x||!h)){ft(!0);try{await Bl(x,Kt,h.uid),hs(D=>D.map(O=>O.id===x?{...O,status:"assigned",metadata:{...O.metadata,assignedTo:Kt}}:O)),me.success("Quiz assigned to student!"),Qe(!1),la(null),j==="bank"&&fr()}catch(D){me.error(D instanceof Error?D.message:"Failed to assign quiz")}finally{ft(!1)}}},fr=m.useCallback(async()=>{if(h){ia(!0);try{const x=await ai(h.uid);hs(x)}catch{me.error("Failed to load quiz bank")}finally{ia(!1)}}},[h]);m.useEffect(()=>{j==="bank"&&fr()},[j,fr]);const pl=async x=>{try{await Fl(x),hs(D=>D.filter(O=>O.id!==x)),me.success("Quiz deleted")}catch{me.error("Failed to delete quiz")}},gn=ot.filter(x=>x.name.toLowerCase().includes(_s.toLowerCase())||x.email.toLowerCase().includes(_s.toLowerCase())),bn=Hs==="all"?na:na.filter(x=>x.status===Hs),hl=x=>{const D=(x.metadata.topicsCovered||[]).reduce((O,ge)=>(O[ge]=(O[ge]||0)+1,O),{});return{questions:x.questions.map(O=>({questionType:O.questionType,question:O.question,correctAnswer:O.correctAnswer,options:O.options??null,bloomLevel:O.bloomLevel,difficulty:O.difficulty,topic:O.topic,points:O.points,explanation:O.explanation})),totalPoints:x.totalPoints,metadata:{topicsCovered:D,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||[]}}},gr=x=>{_(x.id),fe(hl(x)),Fe(null),L(x.id),Wt("all"),Rs("all"),Ye(null),N("results"),S("create")},vn={remember:{badge:"border-purple-200 text-purple-700 bg-purple-50",card:"from-[#a855f7] to-[#9333ea]",num:"text-purple-700 bg-purple-100 border-purple-200"},understand:{badge:"border-blue-200 text-blue-700 bg-blue-50",card:"from-[#3b82f6] to-[#2563eb]",num:"text-blue-700 bg-blue-100 border-blue-200"},apply:{badge:"border-amber-200 text-amber-700 bg-amber-50",card:"from-[#f59e0b] to-[#d97706]",num:"text-amber-700 bg-amber-100 border-amber-200"},analyze:{badge:"border-orange-200 text-orange-700 bg-orange-50",card:"from-[#f97316] to-[#ea580c]",num:"text-orange-700 bg-orange-100 border-orange-200"},evaluate:{badge:"border-rose-200 text-rose-700 bg-rose-50",card:"from-[#f43f5e] to-[#e11d48]",num:"text-rose-700 bg-rose-100 border-rose-200"},create:{badge:"border-emerald-200 text-emerald-700 bg-emerald-50",card:"from-[#10b981] to-[#059669]",num:"text-emerald-700 bg-emerald-100 border-emerald-200"}},fl=(x,D,O)=>{const ge=Ae===D,Oe=vn[x.bloomLevel?.toLowerCase()]||vn.remember,We=x.bloomLevel?.toLowerCase()==="remember"?"hover:border-purple-200":x.bloomLevel?.toLowerCase()==="understand"?"hover:border-blue-200":x.bloomLevel?.toLowerCase()==="apply"?"hover:border-amber-200":"hover:border-slate-200";return e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:D*.05},className:`border border-[#e2e8f0] rounded-[20px] overflow-hidden bg-white shadow-sm hover:shadow-md ${We} transition-all duration-300`,children:[e.jsxs("div",{className:"p-6 flex justify-between items-start cursor-pointer hover:bg-slate-50/50 transition-colors",onClick:()=>Ye(ge?null:D),children:[e.jsxs("div",{className:"space-y-3 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap mb-1",children:[e.jsxs("span",{className:`w-8 h-8 rounded-lg bg-gradient-to-br ${Oe.card} text-white flex items-center justify-center font-bold text-[13px] shadow-sm`,children:["Q",D+1]}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${Oe.badge}`,children:x.bloomLevel}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${x.difficulty==="easy"?"border-emerald-200 text-emerald-700 bg-emerald-50":x.difficulty==="hard"?"border-rose-200 text-rose-700 bg-rose-50":"border-amber-200 text-amber-700 bg-amber-50"}`,children:x.difficulty}),e.jsxs("span",{className:"text-[12px] font-bold text-[#64748b] bg-slate-100 px-2 py-1 rounded-md",children:[x.points," pts"]}),x.topic&&e.jsx("span",{className:"text-[12px] font-semibold text-[#64748b] px-2 py-1 hidden sm:inline-block border-l border-slate-200",children:x.topic})]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b] pr-4 leading-relaxed",children:x.question})]}),e.jsxs("div",{className:"flex flex-col items-end justify-between h-full gap-4 shrink-0 mt-1",children:[e.jsx("span",{className:`px-3 py-1.5 rounded-md text-[10px] font-bold uppercase tracking-widest hidden sm:block border shadow-sm ${Oe.badge}`,children:x.bloomLevel}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-50 flex items-center justify-center border border-slate-200 mt-2",children:ge?e.jsx(wa,{size:16,className:"text-[#64748b] transition-transform duration-300"}):e.jsx(Tt,{size:16,className:"text-[#64748b]"})})]})]}),e.jsx(Et,{children:ge&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsxs("div",{className:"p-6 pt-0 bg-white",children:[e.jsx("div",{className:"h-px w-full bg-gradient-to-r from-transparent via-[#e2e8f0] to-transparent mb-6"}),x.options&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[13px] font-bold text-[#64748b] mb-3 uppercase tracking-wider",children:"Options:"}),e.jsx("div",{className:"space-y-3",children:x.options.map((Pt,Qs)=>{const it=Pt.includes(x.correctAnswer);return e.jsxs("div",{className:`rounded-[12px] p-4 text-[14px] font-medium transition-all cursor-pointer relative overflow-hidden ${it?"bg-gradient-to-r from-emerald-50 to-emerald-100/30 border-2 border-emerald-400 text-emerald-800 font-bold shadow-sm":"bg-white border border-[#e2e8f0] text-[#475569] hover:border-[#a855f7] hover:shadow-[0_2px_8px_rgba(168,85,247,0.1)]"}`,children:[it&&e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-500"}),e.jsx("span",{className:it?"pl-2":"",children:Pt}),it&&e.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500 text-white flex items-center justify-center shadow-sm absolute right-4 top-1/2 -translate-y-1/2",children:e.jsx(Mt,{size:13})})]},Qs)})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-5",children:[e.jsxs("div",{className:"bg-emerald-50/80 border border-emerald-200/60 rounded-[16px] p-5 shadow-sm",children:[e.jsxs("p",{className:"text-[11px] font-bold text-emerald-700 uppercase tracking-wider mb-2 flex items-center gap-1.5",children:[e.jsx(Wr,{size:14})," Correct Answer"]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b]",children:x.correctAnswer})]}),e.jsxs("div",{className:"bg-purple-50/80 border border-purple-200/60 rounded-[16px] p-5 shadow-sm",children:[e.jsxs("p",{className:"text-[11px] font-bold text-purple-700 uppercase tracking-wider mb-2 flex items-center gap-1.5",children:[e.jsx($s,{size:14})," AI Explanation"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed font-medium",children:x.explanation})]})]}),e.jsxs("div",{className:"flex gap-6 text-[12px] font-medium text-[#64748b] mt-5 pt-4 border-t border-slate-100",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(gs,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Type:"})," ",Fa[x.questionType]?.label||x.questionType]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Mr,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Bloom:"})," ",x.bloomLevel]})]})]})})})]},D)},wn=e.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto bg-gradient-to-br from-[#eef2ff] via-[#f5f3ff] to-[#fff7ed]",children:[e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-[12px] pb-4",children:e.jsxs("div",{className:"flex items-center gap-1 bg-white/50 backdrop-blur-md p-1.5 rounded-full border border-white shadow-[0_2px_8px_rgba(0,0,0,0.04)] w-max",children:[e.jsxs("button",{onClick:()=>S("create"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${j==="create"?"bg-white text-[#a855f7] shadow-[0_2px_8px_rgba(168,85,247,0.15)] scale-100":"bg-transparent text-[#64748b] hover:text-[#1e293b] hover:bg-white/60 scale-95 hover:scale-100"}`,children:[e.jsx(Dr,{size:16})," Create Quiz"]}),e.jsxs("button",{onClick:()=>S("bank"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${j==="bank"?"bg-white text-[#a855f7] shadow-[0_2px_8px_rgba(168,85,247,0.15)] scale-100":"bg-transparent text-[#64748b] hover:text-[#1e293b] hover:bg-white/60 scale-95 hover:scale-100"}`,children:[e.jsx(Za,{size:16})," Quiz Bank"]})]})}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] flex-1",children:[j==="bank"&&e.jsxs("div",{className:"w-full space-y-[24px]",children:[e.jsx("div",{className:"flex items-center gap-3 overflow-x-auto pb-2 border-b border-[#e2e8f0] mb-6",style:{scrollbarWidth:"none"},children:["all","draft","published","assigned","completed"].map(x=>e.jsx("button",{onClick:()=>ur(x),className:`px-5 py-2 text-[13px] font-bold rounded-full whitespace-nowrap transition-all duration-300 mb-4 capitalize ${Hs===x?"bg-purple-50 text-[#9333ea] border border-purple-200 shadow-[0_2px_8px_rgba(168,85,247,0.15)] hover:scale-105":"bg-white/80 text-[#64748b] border border-white hover:border-[#e2e8f0] hover:bg-white shadow-sm hover:shadow-md hover:-translate-y-0.5"}`,children:x==="all"?"All":x.charAt(0).toUpperCase()+x.slice(1)},x))}),oa?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(dt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):bn.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(Za,{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:bn.map(x=>e.jsxs(Re.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>gr(x),role:"button",tabIndex:0,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),gr(x))},className:`relative bg-white/80 backdrop-blur-md rounded-[20px] p-6 shadow-sm border flex flex-col group hover:-translate-y-1 transition-all duration-300 cursor-pointer overflow-hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#a855f7] ${x.status==="assigned"||x.status==="published"?"border-white hover:border-purple-100 hover:shadow-[0_8px_24px_rgba(168,85,247,0.1)]":"border-white hover:border-slate-200 hover:shadow-[0_8px_24px_rgba(0,0,0,0.06)]"}`,children:[e.jsx("div",{className:`absolute top-0 left-0 w-[6px] h-full transition-colors duration-300 ${x.status==="assigned"||x.status==="published"?"bg-purple-300 group-hover:bg-[#a855f7]":"bg-slate-200 group-hover:bg-slate-400"}`}),e.jsxs("div",{className:"flex justify-between items-start mb-4 gap-4 pl-3",children:[e.jsx("h3",{className:`font-bold text-[15px] text-[#1e293b] leading-tight transition-colors ${x.status==="assigned"||x.status==="published"?"group-hover:text-[#9333ea]":"group-hover:text-slate-700"}`,children:x.title}),e.jsx("span",{className:`px-2.5 py-1 rounded-[6px] text-[10px] font-bold uppercase tracking-wider shrink-0 shadow-sm ${$m[x.status]}`,children:x.status})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-5 pl-3",children:x.metadata.topicsCovered.slice(0,3).map(D=>e.jsx("span",{className:"px-2.5 py-1 bg-[#f8fafc] text-slate-600 text-[11px] font-medium rounded-md border border-slate-200 group-hover:border-slate-300 transition-colors",children:D},D))}),e.jsxs("div",{className:"flex items-center gap-5 text-[13px] text-[#64748b] font-medium mb-6 pl-3",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Wl,{size:14})," ",x.questions.length," questions"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Zo,{size:14})," ",x.totalPoints," pts"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(os,{size:14})," ",x.gradeLevel]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-5 border-t border-[#f1f5f9] pl-3",children:[e.jsxs("button",{onClick:D=>{D.stopPropagation(),gr(x)},className:"flex items-center gap-1.5 text-[13px] font-semibold text-[#64748b] hover:text-[#1e293b] transition-colors bg-slate-50 hover:bg-slate-100 border border-slate-200 px-4 py-2 rounded-full shadow-sm",children:[e.jsx(ql,{size:14})," View"]}),e.jsxs("button",{onClick:D=>{D.stopPropagation(),hr(x.id)},className:"flex items-center gap-1.5 text-[13px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors",children:[e.jsx(La,{size:14})," Assign"]}),e.jsxs("button",{onClick:D=>{D.stopPropagation(),pl(x.id)},className:"flex items-center gap-1.5 text-[13px] font-semibold text-rose-500 hover:text-rose-700 transition-colors ml-auto opacity-60 group-hover:opacity-100",children:[e.jsx(ri,{size:14})," Delete"]})]})]},x.id))})]}),j==="create"&&e.jsxs(e.Fragment,{children:[Ke&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-4",children:e.jsxs(Re.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-red-50 border border-red-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(or,{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:Ke})]}),e.jsx("button",{onClick:()=>rt(""),className:"ml-auto",children:e.jsx(cs,{size:14,className:"text-red-400"})})]})}),te&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-[24px] xl:p-[32px]",children:[e.jsxs("div",{className:"bg-white p-8 rounded-[16px] shadow-sm border border-[#e2e8f0] w-full max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-[16px] font-bold text-[#1e293b] flex items-center gap-3",children:[e.jsx(dt,{size:20,className:"animate-spin text-[#a855f7]"}),"Generating Quiz in Background"]}),e.jsxs("span",{className:"text-[14px] font-extrabold text-[#9333ea]",children:[re,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 h-2.5 rounded-full overflow-hidden mb-6",children:e.jsx(Re.div,{animate:{width:`${re}%`},transition:{duration:.35,ease:"easeOut"},className:"bg-gradient-to-r from-sky-400 via-indigo-500 to-purple-500 h-full rounded-full"})}),e.jsxs("div",{className:"text-[13px] text-[#64748b]",children:[e.jsxs("p",{className:"font-medium text-[#475569] mb-1",children:["Stage: ",e.jsx("span",{className:"font-bold text-[#1e293b] capitalize",children:$.replace(/_/g," ")})]}),e.jsx("p",{children:pe}),K&&e.jsxs("p",{className:"text-[11px] mt-3 opacity-60 font-mono",children:["Task ID: ",K]})]})]}),e.jsxs("p",{className:"mt-8 text-[14px] font-medium text-[#64748b] flex items-center gap-2 animate-pulse",children:[e.jsx(dt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})]}),!te&&p!=="results"&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] mb-8",children:e.jsx("div",{className:"flex items-center justify-between bg-white/80 backdrop-blur-[12px] rounded-2xl border border-white shadow-[0_4px_16px_rgba(0,0,0,0.03)] p-1.5",children:[{id:"setup",label:"Setup"},{id:"topics",label:"Topics"},{id:"style",label:"Question Style"},{id:"preview",label:"Preview"}].map((x,D)=>{const ge=["setup","topics","style","preview"].indexOf(p),Oe=ge>D,We=ge===D;return e.jsxs("div",{className:`flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl transition-all duration-500 ${We?"bg-purple-50/80 shadow-[0_1px_3px_rgba(168,85,247,0.1)]":Oe?"bg-transparent":"bg-transparent opacity-60"}`,children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[12px] font-bold shrink-0 ${We?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":Oe?"bg-emerald-500 text-white shadow-sm":"bg-slate-100 text-[#64748b]"}`,children:Oe?e.jsx(Mt,{size:13,strokeWidth:3}):D+1}),e.jsx("span",{className:`text-[13px] font-bold whitespace-nowrap ${We?"text-[#9333ea]":Oe?"text-[#1e293b]":"text-[#64748b]"}`,children:x.label})]},x.id)})})}),p==="setup"&&!te&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-gradient-to-r from-purple-50/80 to-indigo-50/80 backdrop-blur-sm border border-purple-100/50 rounded-[16px] p-5 flex items-start gap-4 shadow-sm hover:shadow-md transition-shadow duration-300",children:[e.jsx("div",{className:"bg-white p-2 rounded-full shadow-sm shrink-0",children:e.jsx(ga,{size:18,className:"text-[#9333ea]"})}),e.jsxs("p",{className:"text-[13px] text-[#475569] leading-relaxed pt-0.5",children:["This quiz maker generates ",e.jsx("span",{className:"font-bold text-[#9333ea]",children:"supplemental assessments"})," to support classroom instruction. Questions follow Bloom's Taxonomy for comprehensive skill evaluation. Generation limit: up to ",xa," questions and ",pa," topics per quiz."]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-white shadow-[0_4px_16px_rgba(0,0,0,0.03)] overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.06)] transition-all duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Basic Settings"})}),e.jsxs("div",{className:"p-8 flex flex-col md:flex-row gap-8",children:[e.jsxs("div",{className:"flex-1 group",children:[e.jsx("label",{htmlFor:"quiz-grade-level",className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Grade level"}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{id:"quiz-grade-level",value:C,onChange:x=>z(Sr(x.target.value)),className:"appearance-none w-full bg-white border border-[#e2e8f0] hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl px-4 py-3.5 outline-none focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 cursor-pointer transition-all duration-200 shadow-sm",children:Fm.map(x=>e.jsx("option",{value:x,children:x},x))}),e.jsx(Tt,{size:18,className:"text-[#64748b] absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"flex-1 group",children:[e.jsx("label",{htmlFor:"quiz-num-questions",className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Number of questions"}),e.jsxs("div",{className:"flex items-center bg-white border border-[#e2e8f0] rounded-xl overflow-hidden focus-within:border-[#a855f7] focus-within:ring-4 focus-within:ring-[#a855f7]/10 transition-all duration-200 h-[50px] shadow-sm hover:border-[#cbd5e1]",children:[e.jsx("button",{onClick:()=>U(Math.max(1,I-1)),className:"w-14 h-full flex items-center justify-center text-[#64748b] bg-slate-50 hover:bg-slate-100 hover:text-[#1e293b] transition-colors border-r border-[#e2e8f0] active:bg-slate-200",children:e.jsx(Tn,{size:16})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:xa,value:I,onChange:x=>U(Math.min(xa,Math.max(1,parseInt(x.target.value)||1))),className:"flex-1 text-center font-bold text-[16px] text-[#1e293b] border-none outline-none focus:ring-0 w-full h-full p-0"}),e.jsx("button",{onClick:()=>U(Math.min(xa,I+1)),className:"w-14 h-full flex items-center justify-center text-[#64748b] bg-slate-50 hover:bg-slate-100 hover:text-[#1e293b] transition-colors border-l border-[#e2e8f0] active:bg-slate-200",children:e.jsx(Js,{size:16})})]})]})]})]})]}),p==="topics"&&!te&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"flex items-end justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b] mb-1",children:"Select topics"}),e.jsxs("p",{className:"text-[13px] text-[#64748b]",children:["Choose up to ",pa," topics across all strands"]})]}),e.jsxs("div",{className:"bg-purple-50 border border-purple-100 px-3 py-1.5 rounded-full flex items-center gap-2 shadow-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#a855f7] animate-pulse"}),e.jsxs("span",{className:"text-[12px] font-bold text-[#a855f7]",children:[v.filter(x=>!w.includes(x)).length," of ",pa," selected"]})]})]}),q?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(dt,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries(_e).map(([x,D])=>{const O=D.filter(Oe=>v.includes(Oe)&&!w.includes(Oe)).length,ge=ss===x;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>P(ge?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:[D.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:[O," selected"]}),ge?e.jsx(wa,{size:18,className:"text-slate-400"}):e.jsx(Tt,{size:18,className:"text-slate-400"})]})]}),e.jsx(Et,{children:ge&&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:D.map((Oe,We)=>{const Pt=v.includes(Oe),Qs=w.includes(Oe),it=Pt&&!Qs;let Xt="Core";return We%3===0&&(Xt="Foundation"),We%3===2&&(Xt="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 ${it?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:it&&e.jsx(Mt,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:it,onChange:()=>Pe(Oe)}),e.jsx("span",{className:`text-sm font-semibold ${it?"text-[#0a1628]":"text-[#5a6578]"}`,children:Oe})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${Xt==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:Xt})]},Oe)})})})})]},x)})})]}),p==="style"&&!te&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Question Types"})}),e.jsx("div",{className:"p-4 grid grid-cols-2 sm:grid-cols-5 gap-3",children:Object.entries(Fa).map(([x,D])=>{const O=B.includes(x);return e.jsxs("button",{onClick:()=>da(x),className:`border-2 rounded-[16px] p-4 flex flex-col items-center justify-center text-center cursor-pointer transition-all duration-300 relative overflow-hidden group hover:-translate-y-1 ${O?"border-[#a855f7] bg-gradient-to-b from-purple-50/80 to-white/80 shadow-[0_4px_12px_rgba(168,85,247,0.12)]":"border-slate-100 bg-slate-50/50 shadow-sm hover:shadow-md hover:border-purple-200"}`,children:[O&&e.jsx("div",{className:"absolute top-2 right-2 w-5 h-5 bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-full flex items-center justify-center shadow-md",children:e.jsx(Mt,{size:11,className:"text-white"})}),e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center mb-3 group-hover:scale-110 transition-transform duration-300 ${O?"bg-white border border-purple-200 shadow-md":"bg-white border border-slate-200 shadow-sm group-hover:shadow-md"}`,children:e.jsx("span",{className:O?"text-[#a855f7]":"text-slate-500",children:D.icon})}),e.jsx("span",{className:`font-bold text-[12px] leading-tight ${O?"text-[#9333ea]":"text-slate-700"}`,children:D.label})]},x)})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Bloom's Taxonomy Levels"})}),e.jsx("div",{className:"p-6 flex flex-wrap gap-4",children:Object.entries(jo).map(([x,D])=>{const O=F.includes(x);return e.jsx("button",{onClick:()=>ma(x),className:`px-6 py-2.5 rounded-full border-2 font-bold text-[13px] transition-all duration-200 hover:-translate-y-0.5 capitalize ${O?"border-[#a855f7] text-[#9333ea] bg-purple-50/80 shadow-[0_2px_8px_rgba(168,85,247,0.15)]":"border-slate-200 text-[#64748b] bg-white shadow-sm hover:border-slate-300 hover:bg-slate-50"}`,children:x},x)})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[20px] border border-[#e2e8f0] shadow-sm overflow-hidden hover:shadow-[0_8px_24px_rgba(0,0,0,0.04)] transition-shadow duration-300",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-white/50",children:e.jsx("h3",{className:"text-[11px] font-bold text-[#64748b] uppercase tracking-wider",children:"Difficulty Distribution"})}),e.jsx("div",{className:"p-8 space-y-8",children:Object.entries(ne).map(([x,D])=>{const O={easy:"bg-emerald-400",medium:"bg-amber-400",hard:"bg-rose-400"},ge={easy:"text-emerald-600",medium:"text-amber-500",hard:"text-rose-500"},Oe={easy:"group-hover:border-emerald-200",medium:"group-hover:border-amber-200",hard:"group-hover:border-rose-200"};return e.jsxs("div",{className:"flex items-center gap-6 group",children:[e.jsx("span",{className:`w-16 text-[13px] font-bold text-[#475569] capitalize group-hover:${ge[x]} transition-colors`,children:x}),e.jsx("div",{className:"flex-1 bg-slate-100 h-3 rounded-full overflow-hidden shadow-inner",children:e.jsx(Re.div,{animate:{width:`${D}%`},className:`h-full rounded-full transition-all duration-500 ease-out ${O[x]}`})}),e.jsxs("div",{className:`flex items-center bg-white border border-[#e2e8f0] rounded-xl shadow-sm overflow-hidden p-0.5 w-28 h-10 transition-colors ${Oe[x]}`,children:[e.jsx("button",{onClick:()=>It(x,-5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${ge[x]} rounded-lg transition-colors`,children:e.jsx(Tn,{className:"w-3.5 h-3.5"})}),e.jsx("input",{type:"text",value:`${D}%`,readOnly:!0,className:"flex-1 text-center font-bold text-[14px] text-[#1e293b] border-none outline-none focus:ring-0 w-full p-0 pointer-events-none"}),e.jsx("button",{onClick:()=>It(x,5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${ge[x]} rounded-lg transition-colors`,children:e.jsx(Js,{className:"w-3.5 h-3.5"})})]})]},x)})})]})]}),p==="preview"&&!te&&!se&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] flex-1 space-y-[24px] pb-8",children:e.jsxs("div",{className:"bg-white/80 backdrop-blur-md rounded-[20px] border border-[#e2e8f0] shadow-[0_8px_24px_rgba(0,0,0,0.04)] overflow-hidden p-8",children:[e.jsxs("h3",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-6 flex items-center gap-2",children:[e.jsx(Ds,{size:16,className:"text-[#a855f7]"})," Quiz Summary"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-6",children:[{label:"Questions",value:I},{label:"Topics",value:v.filter(x=>!w.includes(x)).length},{label:"Level",value:C.replace("Grade ","Gr. ")}].map(x=>e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-purple-50 to-indigo-50 rounded-[16px] p-6 text-center border border-purple-100/50 shadow-sm flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-16 h-16 bg-purple-200/30 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx("span",{className:"text-[36px] font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-[#a855f7] to-[#9333ea] leading-none mb-1 relative z-10",children:x.value}),e.jsx("span",{className:"text-[13px] font-bold text-[#64748b] relative z-10",children:x.label})]},x.label))}),e.jsxs("div",{className:"bg-slate-50/80 rounded-[14px] p-5 border border-slate-200/60 text-[#475569] text-[14px] leading-relaxed flex gap-4 items-start shadow-inner",children:[e.jsx(ga,{size:18,className:"text-[#94a3b8] shrink-0 mt-0.5"}),e.jsxs("p",{children:[B.map(x=>Fa[x]?.label).join(" and ")," questions across"," ",e.jsxs("span",{className:"font-bold text-[#1e293b]",children:[v.filter(x=>!w.includes(x)).length," topics"]})," ","— aligned to ",e.jsx("span",{className:"font-semibold",children:F.map(x=>jo[x]?.label).join(", ")})," levels of Bloom's Taxonomy."," ",e.jsxs("span",{className:"font-semibold text-emerald-600",children:["Easy ",ne.easy,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-amber-500",children:["Medium ",ne.medium,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-rose-500",children:["Hard ",ne.hard,"%"]}),"."]})]})]})}),p==="results"&&se&&e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] space-y-[24px] pb-8",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-md rounded-[20px] border border-[#e2e8f0] shadow-[0_8px_24px_rgba(0,0,0,0.04)] p-6",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:cl,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:[Rt?e.jsx(Mt,{size:14,className:"text-green-500"}):e.jsx(zr,{size:14}),Rt?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:dl,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(Kl,{size:14}),"Export JSON"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-[0_8px_16px_rgba(168,85,247,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(gs,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:se.questions.length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Questions"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f43f5e] to-[#e11d48] text-white shadow-[0_8px_16px_rgba(244,63,94,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(vs,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:se.totalPoints}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Total Points"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f59e0b] to-[#d97706] text-white shadow-[0_8px_16px_rgba(245,158,11,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(Gt,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:Object.keys(se.metadata.topicsCovered).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Topics"})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] text-white shadow-[0_8px_16px_rgba(16,185,129,0.25)] rounded-[20px] p-6 text-center flex flex-col items-center justify-center group hover:-translate-y-1 transition-transform",children:[e.jsx("div",{className:"absolute -right-4 -top-4 w-20 h-20 bg-white/10 rounded-full group-hover:scale-150 transition-transform duration-500"}),e.jsx(Ka,{size:22,className:"text-white/80 mb-2 relative z-10"}),e.jsx("span",{className:"text-[32px] font-extrabold leading-none mb-1 relative z-10 drop-shadow-sm",children:Object.keys(se.metadata.bloomTaxonomyDistribution).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Bloom Levels"})]})]}),(se.metadata.usedImportedTopics||(se.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: ",se.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",se.metadata.importedMaterialsCount??0," • ","Topics: ",se.metadata.importedTopicCount??0]}),(se.metadata.topicProvenance||[]).slice(0,5).map((x,D)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[x.title||"Untitled topic",x.sourceFile?` • ${x.sourceFile}`:""]},`${x.topicId||x.title||"topic"}_${D}`)),(Bt.length>0||Ee.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:Ot,onChange:x=>Wt(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"}),Bt.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:qt,onChange:x=>Rs(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"}),Ee.map(x=>e.jsx("option",{value:x,children:x},x))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",Gs.length," of ",se.questions.length," questions after provenance filters."]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mt-8 mb-10",children:[e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#10b981] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Ds,{size:14})," Difficulty"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(se.metadata.difficultyBreakdown).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:`font-bold capitalize ${Pm[x]||"text-[#475569]"}`,children:x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]}),e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#a855f7] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Mr,{size:14})," Bloom's Taxonomy"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(se.metadata.bloomTaxonomyDistribution).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:"text-[#1e293b] font-semibold capitalize",children:x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]}),e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[16px] p-6 shadow-sm border-t-[4px] border-t-[#0ea5e9] hover:shadow-md transition-shadow",children:[e.jsxs("h4",{className:"text-[12px] font-bold text-[#64748b] uppercase tracking-wider mb-5 flex items-center gap-2",children:[e.jsx(Ka,{size:14})," Question Types"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(se.metadata.questionTypeBreakdown).map(([x,D])=>e.jsxs("div",{className:"flex justify-between items-center bg-slate-50 px-3 py-2 rounded-lg",children:[e.jsx("span",{className:"text-[#1e293b] font-semibold",children:Fa[x]?.label||x}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:D})]},x))})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-purple-50 to-indigo-50/50 border border-purple-100 rounded-[16px] p-6 mb-10 flex items-start gap-4 shadow-sm relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full bg-[#a855f7]"}),e.jsx("div",{className:"bg-white p-2 rounded-full shadow-sm shrink-0",children:e.jsx(ga,{size:18,className:"text-[#9333ea]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#9333ea] mb-3",children:se.metadata.supplementalPurpose||"This quiz is designed to supplement classroom instruction, not replace teacher-led learning."}),se.metadata.recommendedTeacherActions&&se.metadata.recommendedTeacherActions.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[13px] font-bold text-[#1e293b] mb-2",children:"Recommended Actions:"}),e.jsx("ul",{className:"list-disc pl-5 text-[13px] font-medium text-[#475569] space-y-1.5",children:se.metadata.recommendedTeacherActions.map((x,D)=>e.jsx("li",{children:x},D))})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("h3",{className:"text-[18px] font-bold text-[#1e293b] flex items-center gap-2",children:[e.jsx(li,{size:20,className:"text-[#a855f7]"})," Review Questions"]}),e.jsx("div",{className:"space-y-4",children:Gs.length>0?Gs.map((x,D)=>fl(x,D)):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."})})]})]})]})]}),j==="create"&&e.jsx("div",{className:"sticky bottom-0 mt-auto w-full bg-white/90 backdrop-blur-[12px] border-t border-[#e2e8f0] z-30 shadow-[0_-4px_12px_rgba(0,0,0,0.03)]",children:e.jsxs("div",{className:"w-full px-6 xl:px-8 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[p==="topics"&&!te&&e.jsx("button",{onClick:()=>{y([]),A([])},className:"text-[13px] font-semibold text-[#a855f7] hover:underline",children:"Clear all"}),(p==="style"||p==="preview")&&!te&&e.jsxs("button",{onClick:()=>N(p==="preview"?"style":"topics"),className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Ss,{size:16})," Back"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[p==="setup"&&!te&&e.jsxs("button",{onClick:()=>N("topics"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Topics ",e.jsx(ys,{size:16})]}),p==="topics"&&!te&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>N("setup"),className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Ss,{size:16})," Back"]}),e.jsxs("button",{onClick:()=>N("style"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Question Style ",e.jsx(ys,{size:16})]})]}),p==="style"&&!te&&e.jsxs("button",{onClick:()=>N("preview"),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-semibold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:["Next: Preview ",e.jsx(ys,{size:16})]}),p==="preview"&&!te&&!se&&e.jsxs("button",{onClick:ll,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-all hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(Mt,{size:16})," Generate Quiz"]}),te&&e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(dt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]}),p==="results"&&(ca?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{S("bank"),L(null)},className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02]",children:"Back to Quiz Bank"}),e.jsxs("button",{onClick:()=>hr(ca),className:"bg-white border border-[#a855f7] text-[#9333ea] hover:bg-purple-50 text-[14px] font-bold rounded-full px-8 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(La,{size:16})," Assign"]}),e.jsx("button",{onClick:xn,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-10 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02]",children:"Done"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{N("setup"),fe(null),Fe(null),_(null),L(null)},className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[14px] font-semibold rounded-full px-6 py-2.5 shadow-sm transition-transform hover:scale-[1.02]",children:"Create Another"}),_t?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:ul,disabled:ee,className:"bg-white border border-[#a855f7] text-[#9333ea] hover:bg-purple-50 text-[14px] font-bold rounded-full px-8 py-2.5 shadow-sm transition-transform hover:scale-[1.02] flex items-center gap-2",children:[ee?e.jsx(dt,{size:16,className:"animate-spin"}):e.jsx(Ta,{size:16})," Publish"]}),e.jsxs("button",{onClick:()=>hr(),className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-8 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02] flex items-center gap-2",children:[e.jsx(La,{size:16})," Assign to Class"]})]}):e.jsxs("button",{onClick:ml,disabled:st,className:"bg-emerald-600 hover:bg-emerald-700 text-white px-8 py-2.5 rounded-full font-bold shadow-lg shadow-emerald-500/30 hover:-translate-y-1 transition-all flex items-center gap-2 text-[14px]",children:[st?e.jsx(dt,{size:16,className:"animate-spin"}):e.jsx(ni,{size:16})," Save to Library"]}),e.jsx("button",{onClick:xn,className:"bg-[#a855f7] hover:bg-[#9333ea] text-white text-[14px] font-bold rounded-full px-10 py-2.5 shadow-[0_4px_12px_rgba(168,85,247,0.3)] transition-transform hover:scale-[1.02]",children:"Done"})]}))]})]})}),e.jsx(Dm,{isOpen:vt,onClose:()=>xs(!1)}),e.jsx(Et,{children:Ne&&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:()=>Qe(!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(os,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>Qe(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(cs,{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(Os,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:_s,onChange:x=>za(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:ps?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(dt,{size:20,className:"animate-spin text-sky-500"})}):gn.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):gn.map(x=>e.jsxs("button",{onClick:()=>ra(x.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${Kt===x.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:x.avatar&&!x.avatar.includes("ui-avatars.com")?x.avatar:Ga(x.gender),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})]}),Kt===x.id&&e.jsx(Mt,{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:()=>Qe(!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:xl,disabled:!Kt||je,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${Kt&&!je?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[je?e.jsx(dt,{size:14,className:"animate-spin"}):e.jsx(La,{size:14}),"Assign"]})]})]})})})]});return d?e.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-white",children:wn}):wn},Hm=({onOpenNotifications:t,onOpenProfile:s,onOpenInsightModal:a,userPhoto:r,teacherName:o})=>{const[n,i]=m.useState([]),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(""),[b,k]=m.useState(11),[j,S]=m.useState("general_mathematics"),[p,N]=m.useState([]),[C,z]=m.useState(!1),[I,U]=m.useState(null),v=m.useCallback(async()=>{z(!0);try{const E=kt($t(Ve,"quizBattleQuestionBank"),Vr(50)),X=(await Dt(E)).docs.map(J=>{const ce=J.data();return{id:J.id,question:ce.question||"",choices:ce.choices||[],correct_answer:ce.correct_answer||"",explanation:ce.explanation||"",topic:ce.topic||"",difficulty:ce.difficulty||"medium",grade_level:ce.grade_level||11}});N(X)}catch(E){console.warn("[QuestionBankPanel] Failed to load questions:",E)}finally{z(!1)}},[]);m.useEffect(()=>{v()},[v]);const y=m.useCallback(async()=>{c(!0);try{const E=await yn("/api/quiz-battle/bank-status");i(E.pdfs)}catch(E){const F=E instanceof qa?E.message:"Failed to load bank status";me.error(F)}finally{c(!1)}},[]);m.useEffect(()=>{y()},[y]);const w=async()=>{if(!f.trim()){me.error("Please enter a storage path");return}u(!0);try{await yn("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:f.trim(),grade_level:b,topic:j.trim(),force_reingest:!1})}),me.success("PDF ingestion completed"),await y(),h("")}catch(E){const F=E instanceof qa?E.message:"Ingestion failed";me.error(F)}finally{u(!1)}},A=n.reduce((E,F)=>E+F.question_count,0),B=n.filter(E=>E.processed).length;return e.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto bg-gradient-to-br from-[#f8fafc] to-[#f1f5f9]",children:[e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-[12px] pb-2"}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] space-y-[32px]",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#3b82f6] to-[#2563eb] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(59,130,246,0.2)] hover:shadow-[0_8px_24px_rgba(59,130,246,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total PDFs"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(gs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:n.length})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] hover:shadow-[0_8px_24px_rgba(168,85,247,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Questions"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Gt,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:A})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] hover:shadow-[0_8px_24px_rgba(16,185,129,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Processed"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(zs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:B})]})]}),e.jsx("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden",children:e.jsxs("div",{className:"p-[24px] sm:p-[32px]",children:[e.jsxs("h2",{className:"text-[20px] font-bold text-[#1e293b] mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center shadow-md shadow-purple-500/20",children:e.jsx(Rn,{className:"w-4 h-4 text-white"})}),"Ingest New PDF"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 items-end",children:[e.jsxs("div",{className:"md:col-span-6 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Firebase Storage Path"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(gs,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"quiz_pdfs/grade_11/gen_math_q1.pdf",value:f,onChange:E=>h(E.target.value),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl pl-11 pr-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]})]}),e.jsxs("div",{className:"md:col-span-2 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Grade Level"}),e.jsx("input",{type:"number",placeholder:"11",min:7,max:12,value:b,onChange:E=>k(Number(E.target.value)),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl px-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]}),e.jsxs("div",{className:"md:col-span-4 group",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] mb-2 block group-hover:text-[#a855f7] transition-colors",children:"Topic Slug"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(Gt,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"general_mathematics",value:j,onChange:E=>S(E.target.value),className:"w-full bg-slate-50 border border-slate-200 hover:border-[#cbd5e1] text-[#475569] text-[14px] font-medium rounded-xl pl-11 pr-4 py-3.5 outline-none focus:bg-white focus:border-[#a855f7] focus:ring-4 focus:ring-[#a855f7]/10 transition-all shadow-inner"})]})]})]}),e.jsx("div",{className:"mt-6 flex justify-end pt-6 border-t border-slate-100",children:e.jsxs("button",{onClick:w,disabled:d,className:"bg-gradient-to-r from-[#a855f7] to-[#9333ea] hover:from-[#9333ea] hover:to-[#7e22ce] text-white text-[14px] font-bold rounded-full px-8 py-3 shadow-[0_4px_16px_rgba(168,85,247,0.3)] transition-all hover:scale-[1.02] flex items-center gap-2 hover:shadow-[0_8px_24px_rgba(168,85,247,0.4)] disabled:opacity-50 disabled:hover:scale-100",children:[d?e.jsx(dt,{className:"w-4 h-4 animate-spin"}):e.jsx(Rn,{className:"w-4 h-4"}),"Ingest PDF"]})})]})}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] p-[24px] sm:p-[32px]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b]",children:"Processing Status"}),e.jsx("button",{onClick:y,disabled:l,className:"w-9 h-9 rounded-full bg-white border border-slate-200 flex items-center justify-center text-[#64748b] hover:text-[#9333ea] hover:border-purple-200 shadow-sm transition-all hover:scale-105 active:scale-95 disabled:opacity-50",children:e.jsx(zs,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsx("div",{className:"bg-white rounded-[16px] border border-[#f1f5f9] overflow-hidden shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#9956DE] border-b border-[#8b5cf6] shadow-md relative z-10",children:[e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Filename"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Grade"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Topic"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap text-center",children:"Questions"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Status"}),e.jsx("th",{className:"h-12 px-6 text-[11px] font-bold text-white uppercase tracking-wider whitespace-nowrap",children:"Processed At"})]})}),e.jsxs("tbody",{className:"divide-y divide-[#f1f5f9] bg-white",children:[n.map(E=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors group",children:[e.jsx("td",{className:"py-4 px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${E.processed?"bg-indigo-50 text-indigo-500":"bg-amber-50 text-amber-500"}`,children:e.jsx(gs,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-[13px] font-bold text-[#1e293b] group-hover:text-purple-600 transition-colors line-clamp-1",children:E.filename})]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-semibold text-[#475569]",children:E.grade_level}),e.jsx("td",{className:"py-4 px-6",children:e.jsx("span",{className:"text-[12px] font-medium bg-slate-100 text-slate-600 px-2.5 py-1 rounded-md line-clamp-1",children:E.topic})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-bold text-[#1e293b] text-center",children:E.question_count||"-"}),e.jsx("td",{className:"py-4 px-6",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 text-[11px] font-bold rounded-full border shadow-sm ${E.processed?"bg-emerald-50 text-emerald-600 border-emerald-200/50":"bg-amber-50 text-amber-600 border-amber-200/50"}`,children:[E.processed?e.jsx(zs,{className:"w-3 h-3"}):e.jsx(dt,{className:"w-3 h-3 animate-spin"}),E.processed?"Completed":"Processing..."]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-medium text-[#64748b]",children:E.timestamp?new Date(E.timestamp).toLocaleDateString():"-"})]},E.filename)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-12 px-6 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-[#64748b]",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mb-4 border border-slate-100",children:e.jsx(gs,{className:"w-8 h-8 text-slate-300"})}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-1",children:"No PDFs processed yet"}),e.jsx("p",{className:"text-[13px]",children:"Upload a PDF using the form above to get started."})]})})})]})]})})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] p-[24px] sm:p-[32px]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("h2",{className:"text-[20px] font-bold text-[#1e293b] flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] bg-gradient-to-br from-[#3b82f6] to-[#2563eb] flex items-center justify-center shadow-md shadow-blue-500/20",children:e.jsx(Gt,{className:"w-4 h-4 text-white"})}),"Question Bank (",p.length,")"]}),e.jsx("button",{onClick:v,disabled:C,className:"w-9 h-9 rounded-full bg-white border border-slate-200 flex items-center justify-center text-[#64748b] hover:text-[#9333ea] hover:border-purple-200 shadow-sm transition-all hover:scale-105 active:scale-95 disabled:opacity-50",children:e.jsx(zs,{className:`w-4 h-4 ${C?"animate-spin":""}`})})]}),C?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(dt,{className:"w-6 h-6 animate-spin text-[#9956DE]"})}):p.length===0?e.jsxs("div",{className:"text-center py-12 text-[#64748b]",children:[e.jsx(Gt,{className:"w-10 h-10 mx-auto mb-3 text-slate-300"}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-1",children:"No questions in the bank yet"}),e.jsx("p",{className:"text-[13px]",children:"Ingest a PDF above to populate the question bank."})]}):e.jsx("div",{className:"space-y-2 max-h-[500px] overflow-y-auto",children:p.map(E=>e.jsxs("div",{className:"border border-[#f1f5f9] rounded-xl p-4 hover:border-purple-200 transition-colors bg-white",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 cursor-pointer",onClick:()=>U(I===E.id?null:E.id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-[#1e293b] line-clamp-2",children:E.question}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs("span",{className:"text-[11px] px-2 py-0.5 rounded-md bg-blue-50 text-blue-600 font-semibold",children:["Grade ",E.grade_level]}),e.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded-md bg-slate-100 text-slate-600 font-medium",children:E.topic}),e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-md font-semibold ${E.difficulty==="easy"?"bg-green-50 text-green-600":E.difficulty==="hard"?"bg-rose-50 text-rose-600":"bg-amber-50 text-amber-600"}`,children:E.difficulty})]})]}),I===E.id?e.jsx(wa,{size:16,className:"text-[#94a3b8] shrink-0"}):e.jsx(Tt,{size:16,className:"text-[#94a3b8] shrink-0"})]}),I===E.id&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-[#f1f5f9] space-y-2",children:[e.jsx("div",{className:"space-y-1",children:E.choices.map((F,X)=>e.jsxs("p",{className:`text-[12px] px-3 py-1.5 rounded-lg ${F===E.correct_answer?"bg-green-50 text-green-700 font-semibold border border-green-200":"bg-slate-50 text-[#475569]"}`,children:[String.fromCharCode(65+X),". ",F]},X))}),E.explanation&&e.jsxs("p",{className:"text-[12px] text-[#64748b] italic mt-2",children:["💡 ",E.explanation]})]})]},E.id))})]})]})]})},So={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},Gm={"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"}},ko={mastered:{label:"Mastered",color:"text-emerald-600 bg-emerald-50 border-emerald-100"},on_track:{label:"On Track",color:"text-amber-600 bg-amber-50 border-amber-100"},needs_attention:{label:"Needs Work",color:"text-rose-600 bg-rose-50 border-rose-100"},no_data:{label:"No Data",color:"text-slate-600 bg-slate-50 border-slate-200"}},Co={needs_attention:0,on_track:1,no_data:2,mastered:3},Qm=({classSectionId:t,onOpenNotifications:s,onOpenProfile:a})=>{const{currentUser:r,userProfile:o}=ds(),[n,i]=m.useState([]),[l,c]=m.useState(So),[d,u]=m.useState(!0),[f,h]=m.useState("all"),[b,k]=m.useState("all"),[j,S]=m.useState(""),[p,N]=m.useState("classAverage"),[C,z]=m.useState("asc"),I=_n.map(M=>M.id),U=_n.reduce((M,Y)=>(M[Y.id]=Y.name,M),{}),{isLoading:v,refetch:y}=ec();m.useEffect(()=>{v||(console.log("[TopicMasteryView] Curriculum ready"),y())},[v,y]);const[w,A]=m.useState(new Set),[B,E]=m.useState([]),F=Xl({queryKey:Nl.topicMastery(r?.uid||"anonymous",t),enabled:!!r,staleTime:120*1e3,gcTime:900*1e3,queryFn:async()=>{try{if(!r)return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}};const M=pt(Ve,"teachers",r.uid,"settings","quizSettings"),Y=await js(M),ae=Y.exists()?Y.data()?.excludedTopics||[]:[],$e="https://deign86-mathpulse-api-v3test.hf.space",Me=new URLSearchParams({teacherId:r.uid});t&&Me.set("classSectionId",t);const Ge=await r.getIdToken(),G=await fetch(`${$e}/api/analytics/topic-mastery?${Me.toString()}`,{headers:{Authorization:`Bearer ${Ge}`}});if(!G.ok)return{excluded:ae,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ae.length}};const te=await G.json(),g=(te.topics||[]).map(T=>({...T,isExcluded:ae.includes(T.topicName)}));return{excluded:ae,topics:g,summary:te.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ae.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});m.useEffect(()=>{if(u(F.isLoading||F.isFetching),!F.data){E([]),i([]),c(So),A(new Set);return}E(F.data.excluded),i(F.data.topics),c(F.data.summary)},[F.data,F.isFetching,F.isLoading]);const X=async M=>{if(!r)return;const Y=B.includes(M)?B.filter(ae=>ae!==M):[...B,M];E(Y),i(ae=>ae.map($e=>$e.topicName===M?{...$e,isExcluded:!$e.isExcluded}:$e)),c(ae=>({...ae,excludedCount:Y.length}));try{const ae=pt(Ve,"teachers",r.uid,"settings","quizSettings");(await js(ae)).exists()?await Zt(ae,{excludedTopics:Y}):await is(ae,{excludedTopics:Y})}catch{me.error("Failed to update excluded topics")}},J=async()=>{if(!r)return;const M=[...new Set([...B,...w])];E(M),i(Y=>Y.map(ae=>w.has(ae.topicName)?{...ae,isExcluded:!0}:ae)),c(Y=>({...Y,excludedCount:M.length})),A(new Set);try{const Y=pt(Ve,"teachers",r.uid,"settings","quizSettings");(await js(Y)).exists()?await Zt(Y,{excludedTopics:M}):await is(Y,{excludedTopics:M}),me.success(`${w.size} topics excluded from quizzes`)}catch{me.error("Failed to update")}},ce=async()=>{if(!r)return;const M=B.filter(Y=>!w.has(Y));E(M),i(Y=>Y.map(ae=>w.has(ae.topicName)?{...ae,isExcluded:!1}:ae)),c(Y=>({...Y,excludedCount:M.length})),A(new Set);try{const Y=pt(Ve,"teachers",r.uid,"settings","quizSettings");(await js(Y)).exists()?await Zt(Y,{excludedTopics:M}):await is(Y,{excludedTopics:M}),me.success(`${w.size} topics re-included in quizzes`)}catch{me.error("Failed to update")}},ne=M=>{p===M?z(Y=>Y==="asc"?"desc":"asc"):(N(M),z("asc"))},xe=b==="all"?I:Jl(b);m.useEffect(()=>{f!=="all"&&(xe.includes(f)||h("all"))},[xe,f]);const he=n.filter(M=>!(f!=="all"&&M.subjectId!==f||!xe.includes(M.subjectId)||j&&!M.topicName.toLowerCase().includes(j.toLowerCase()))).sort((M,Y)=>{const ae=C==="asc"?1:-1;switch(p){case"topicName":return ae*M.topicName.localeCompare(Y.topicName);case"classAverage":return ae*(M.classAverage-Y.classAverage);case"studentsAttempted":return ae*(M.studentsAttempted-Y.studentsAttempted);case"masteryStatus":return ae*((Co[M.masteryStatus]||0)-(Co[Y.masteryStatus]||0));default:return 0}}),H=()=>{w.size===he.length?A(new Set):A(new Set(he.map(M=>M.topicName)))},q=({field:M})=>p!==M?e.jsx(Tt,{size:14,className:"text-white/40"}):C==="asc"?e.jsx(wa,{size:14,className:"text-white font-bold"}):e.jsx(Tt,{size:14,className:"text-white font-bold"});return d?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(dt,{size:24,className:"animate-spin text-indigo-500"}),e.jsx("span",{className:"ml-2 text-[#64748b]",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:"w-full p-[24px] xl:p-[32px] space-y-[24px]",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Topics Tracked"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ds,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.totalTopicsTracked})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Mastered by Class"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(qr,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.masteredCount})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f43f5e] to-[#e11d48] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(244,63,94,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Needs Work"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Xs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.needsAttentionCount})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#64748b] to-[#475569] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(100,116,139,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Excluded Topics"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Yl,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:l.excludedCount})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center bg-white px-4 py-2.5 rounded-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-[#e2e8f0] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all w-full md:w-64",children:[e.jsx(Os,{size:16,className:"text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:j,onChange:M=>S(M.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]}),e.jsxs("div",{className:"relative w-full md:w-48",children:[e.jsxs("select",{value:f,onChange:M=>h(M.target.value),className:"appearance-none w-full bg-white border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[12px] pl-4 pr-10 py-2.5 outline-none focus:border-[#a855f7] focus:ring-2 focus:ring-[#a855f7]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer",children:[e.jsx("option",{value:"all",children:"All Subjects"}),xe.map(M=>e.jsx("option",{value:M,children:U[M]||M},M))]}),e.jsx(Tt,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsxs("div",{className:"relative w-full md:w-48",children:[e.jsxs("select",{value:b,onChange:M=>k(M.target.value),className:"appearance-none w-full bg-white border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[12px] pl-4 pr-10 py-2.5 outline-none focus:border-[#a855f7] focus:ring-2 focus:ring-[#a855f7]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer",children:[e.jsx("option",{value:"all",children:"All Grades"}),Zl.map(M=>e.jsx("option",{value:M,children:M},M))]}),e.jsx(Tt,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsx(Et,{children:w.size>0&&e.jsxs(Re.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-4 bg-indigo-50 border border-indigo-200 rounded-[12px] p-3 flex items-center gap-3 flex-wrap overflow-hidden",children:[e.jsxs("span",{className:"text-[13px] font-semibold text-indigo-700",children:[w.size," topics selected"]}),e.jsx("button",{onClick:J,className:"px-4 py-1.5 bg-[#475569] text-white text-[11px] font-bold rounded-full hover:bg-[#334155] transition-colors shadow-sm",children:"Exclude Selected"}),e.jsx("button",{onClick:ce,className:"px-4 py-1.5 bg-emerald-600 text-white text-[11px] font-bold rounded-full hover:bg-emerald-700 transition-colors shadow-sm",children:"Include Selected"}),e.jsx("button",{onClick:()=>A(new Set),className:"px-4 py-1.5 bg-white border border-[#e2e8f0] text-[#64748b] text-[11px] font-bold rounded-full hover:bg-[#f8fafc] transition-colors shadow-sm",children:"Clear Selection"})]})}),e.jsx("div",{className:"bg-white rounded-[16px] border border-[#f1f5f9] overflow-hidden shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"bg-[#9956DE] grid grid-cols-12 gap-4 p-4 border-b border-[#8b5cf6] items-center text-[11px] font-bold text-white tracking-wider uppercase shadow-md relative z-10 h-12",children:[e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx("input",{type:"checkbox",checked:w.size===he.length&&he.length>0,onChange:H,className:"rounded text-[#4f46e5] focus:ring-[#4f46e5] w-4 h-4 border-white/30 bg-white/10 cursor-pointer"})}),e.jsxs("div",{className:"col-span-3 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ne("topicName"),children:["TOPIC NAME ",e.jsx(q,{field:"topicName"})]}),e.jsx("div",{className:"col-span-2",children:"UNIT"}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ne("classAverage"),children:["CLASS AVG % ",e.jsx(q,{field:"classAverage"})]}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ne("studentsAttempted"),children:["STUDENTS ",e.jsx(q,{field:"studentsAttempted"})]}),e.jsxs("div",{className:"col-span-1 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ne("masteryStatus"),children:["STATUS ",e.jsx(q,{field:"masteryStatus"})]}),e.jsx("div",{className:"col-span-1 text-center",children:"EXCLUDE"})]}),e.jsx("div",{className:"flex flex-col",children:he.length===0?e.jsx("div",{className:"p-16 text-center border-b border-[#f1f5f9]",children:n.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ds,{size:32,className:"text-[#cbd5e1]"}),e.jsx("p",{className:"text-[13px] font-semibold text-[#64748b]",children:"No topic data available yet"}),e.jsx("p",{className:"text-[11px] text-[#94a3b8]",children:"Import student quiz data to see class topic mastery analytics."})]}):e.jsx("span",{className:"text-[13px] text-[#64748b]",children:"No topics match the current filters."})}):he.map(M=>{const Y=w.has(M.topicName),ae=ko[M.masteryStatus]||ko.no_data,$e=Gm[M.subjectId]||{label:M.subjectId.toUpperCase(),color:"bg-[#f8fafc] text-[#64748b]"},Me=M.classAverage<60?"bg-rose-500":M.classAverage<85?"bg-amber-500":"bg-emerald-500",Ge=M.isExcluded?"bg-slate-50/60 opacity-70":M.masteryStatus==="needs_attention"?"bg-rose-50/30":M.masteryStatus==="mastered"?"bg-emerald-50/20":"";return e.jsxs("div",{className:`grid grid-cols-12 gap-4 p-4 border-b border-[#f1f5f9] items-center hover:bg-slate-50/80 transition-colors group ${Ge} ${M.isExcluded?"line-through decoration-slate-400":""}`,children:[e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx("input",{type:"checkbox",checked:Y,onChange:()=>{const G=new Set(w);Y?G.delete(M.topicName):G.add(M.topicName),A(G)},className:"rounded text-[#4f46e5] focus:ring-[#4f46e5] w-4 h-4 border-gray-300 cursor-pointer"})}),e.jsxs("div",{className:"col-span-3 flex flex-col sm:flex-row sm:items-center gap-1.5 pr-2 min-w-0",children:[e.jsx("span",{className:"font-semibold text-[#1e293b] text-[13px] truncate",children:M.topicName}),e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded shrink-0 ${$e.color}`,children:$e.label})]}),e.jsx("div",{className:"col-span-2 text-[#475569] text-[13px] truncate pr-2",children:M.unit}),e.jsx("div",{className:"col-span-2",children:e.jsxs("span",{className:"font-bold text-[#1e293b] text-[14px]",children:[M.classAverage,"%"]})}),e.jsxs("div",{className:"col-span-2 pr-4",children:[e.jsx("div",{className:"flex justify-between items-center text-[11px] mb-1",children:e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[M.studentsAttempted," / ",M.totalStudents]})}),e.jsx("div",{className:"w-full bg-[#f1f5f9] h-1.5 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Me}`,style:{width:`${M.classAverage}%`}})})]}),e.jsx("div",{className:"col-span-1",children:e.jsx("span",{className:`text-[10px] font-bold px-2.5 py-1 rounded-full border whitespace-nowrap ${ae.color}`,children:ae.label})}),e.jsxs("div",{className:"col-span-1 flex justify-center relative",children:[e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer group/toggle",children:[e.jsx("input",{type:"checkbox",checked:M.isExcluded,onChange:()=>X(M.topicName),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]}),e.jsx("div",{className:"hidden group-hover/toggle:block absolute z-20 bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded whitespace-nowrap shadow-lg",children:M.isExcluded?"Include in generation":"Exclude from generation"})]})]},M.topicName)})})]})})})]})]})};function Ki(t){return(t||"").trim().toLowerCase()}function Io(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 o=Ki(t.classSectionId),n=(t.id||"").trim().toLowerCase();return o&&n?`${o}|id:${n}`:n?`id:${n}`:`${o}|anonymous`}function Um(t,s){const a=[],r=(t.lrn||"").trim().toLowerCase(),o=(t.email||"").trim().toLowerCase(),n=t.name.trim().toLowerCase(),i=(t.id||"").trim().toLowerCase();return r&&a.push(`${s}|lrn:${r}`),o&&a.push(`${s}|email:${o}`),n&&a.push(`${s}|name:${n}`),i&&a.push(`${s}|id:${i}`),a.length===0&&a.push(`${s}|anonymous`),a}function Vm(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 Xi(t,s){const a=new Map,r=new Map,o=s?Ki(s):"all";return t.forEach(n=>{const i=Um(n,o),l=i.map(u=>r.get(u)).find(Boolean)||i[0],c=a.get(l),d=c?Vm(c,n):n;a.set(l,d),i.forEach(u=>r.set(u,l))}),Array.from(a.values())}function To(t,s){return Xi([...t,...s])}function Vs(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function Wm(t){if(!t)return null;const s="gen-math",a=Mn.find(i=>i.id===s)?.modules||[];if(a.length===0)return null;const r={mastery:0,concept:0,application:0,engagement:0,consistency:0},o=t.lessons??{};a.forEach(i=>{const l=Mn.find(S=>S.modules.some(p=>p.id===i.id)),c=l?t?.subjects?.[l.id]?.modulesProgress?.[i.id]:null,d=Vs(c?.progress||0),u=i.lessons.length?i.lessons.reduce((S,p)=>{const N=o?.[p.id]?.score;if(typeof N=="number"&&Number.isFinite(N))return S+Vs(N);const C=!!c?.lessonsCompleted?.includes?.(p.id);return S+(C?100:0)},0)/i.lessons.length:0,f=i.quizzes.length?(c?.quizzesCompleted?.length||0)/i.quizzes.length*100:0,h=Vs(u),b=Vs(f),k=Vs(Math.min(100,(h+b*2)/1.5)),j=Vs(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=h,r.application+=b,r.engagement+=k,r.consistency+=j});const n=a.length;return{mastery:Math.round(r.mastery/n),concept:Math.round(r.concept/n),application:Math.round(r.application/n),engagement:Math.round(r.engagement/n),consistency:Math.round(r.consistency/n)}}const Eo={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"}},Cr=[{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:"Applications"},{key:"consistency",short:"S",label:"Consistency",header:"Consistency"}],qm=({classSectionId:t,className:s,fallbackStudents:a=[],onBack:r,onOpenNotifications:o,onOpenProfile:n,insightDismissed:i,onOpenInsightModal:l})=>{const{currentUser:c,userProfile:d}=ds(),u=m.useRef(0),[f,h]=m.useState([]),[b,k]=m.useState(!0),[j,S]=m.useState(""),[p,N]=m.useState("riskLevel"),[C,z]=m.useState("desc"),[I,U]=m.useState("all"),[v,y]=m.useState([]),[w,A]=m.useState(!1),[B,E]=m.useState(""),[F,X]=m.useState(""),J=m.useCallback(g=>({id:g.id,lrn:g.lrn||void 0,name:g.name,email:g.email||"",avatar:Ga(g.gender),classSectionId:g.classSectionId??null,riskLevel:g.riskLevel||"Low",engagementScore:g.engagementScore,avgQuizScore:g.avgQuizScore,weakestTopic:g.weakestTopic||"Foundational Skills"}),[]),ce=m.useCallback(g=>({id:g.id,lrn:g.lrn,name:g.name,email:g.email||"",avatar:g.avatar&&!g.avatar.includes("ui-avatars.com")?g.avatar:Ga(g.gender),classSectionId:g.classSectionId??null,riskLevel:String(g.riskLevel).charAt(0).toUpperCase()+String(g.riskLevel).slice(1).toLowerCase(),engagementScore:g.engagementScore,avgQuizScore:Number(g.avgQuizScore??g.avgScore??0),weakestTopic:g.weakestTopic||"Foundational Skills"}),[]),ne=m.useCallback(async(g,T)=>{const R=new Map;g.forEach(Z=>R.set(Z.id,null));const K=25;for(let Z=0;Z{try{const oe=await Sn($.id);return{studentId:$.id,summary:Wm(oe)}}catch{return{studentId:$.id,summary:null}}}))).forEach(($,oe)=>{const pe=re[oe]?.id;pe&&($.status==="fulfilled"?R.set(pe,$.value.summary):R.set(pe,null))})}u.current===T&&h(Z=>Z.map(re=>R.has(re.student.id)?{...re,competencyMatrix:R.get(re.student.id)??null,competencyMatrixLoading:!1}:re))},[]),xe=m.useCallback(async()=>{if(c?.uid){k(!0),X("");try{let T=(await cn(c.uid)).map(re=>({id:re.id,name:re.name,email:re.email||"",avatar:re.avatar&&!re.avatar.includes("ui-avatars.com")?re.avatar:Ga(re.gender),classSectionId:re.classSectionId??null,riskLevel:re.riskLevel,engagementScore:re.engagementScore,avgQuizScore:re.avgQuizScore,weakestTopic:re.weakestTopic||"Foundational Skills"}));a.length>0&&(T=To(T,a.map(ce))),t&&(T=T.filter(re=>re.classSectionId===t));const R=await nt.getImportedClassOverview({classSectionId:t,limit:3e3});R.warnings.length>0&&X(R.warnings.join(" ")),T=To(T,R.students.map(J));const K=Xi(T,t),Z=u.current+=1;h(K.map((re,le)=>({rowKey:`${Io(re)}|row:${le}`,student:re,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),ne(K,Z)}catch(g){if(console.error("Failed to load students:",g),a.length>0){const T=a.map(ce).filter(R=>!t||R.classSectionId===t).map((R,K)=>({rowKey:`${Io(R)}|row:${K}`,student:R,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));h(T),X("Showing recently imported students while backend roster sync catches up.")}else h([]),X("Student competency roster is unavailable right now.")}finally{k(!1)}}},[t,c?.uid,a,ne,ce,J]);m.useEffect(()=>{xe()},[xe]),m.useEffect(()=>{(async()=>{if(!t){y([]),E("");return}A(!0),E("");try{const T=await nt.getCourseMaterialTopics({classSectionId:t,limit:20}),R=(T.topics||[]).filter(K=>K.title?.trim());y(R),T.warnings.length>0&&E(T.warnings.join(" "))}catch{y([]),E("Imported topic context is unavailable right now.")}finally{A(!1)}})()},[t]);const he=async g=>{h(T=>T.map(R=>{if(R.rowKey!==g)return R;const K=!R.expanded,Z=R.student.id,re={weakestTopic:R.student.weakestTopic,avgQuizScore:R.student.avgQuizScore};return K&&!R.competency&&!R.loading?(H(g,Z,re),{...R,expanded:!0,loading:!0}):{...R,expanded:K}}))},H=async(g,T,R)=>{try{const Z=((await Sn(T))?.quizAttempts??[]).map(le=>({topic:le.quizId,score:le.score,total:100,timeTaken:le.timeSpent})),re=await nt.getStudentCompetency(T,Z.length>0?Z:void 0);h(le=>le.map($=>$.rowKey===g?{...$,competency:re,loading:!1}:$))}catch{const Z=R.avgQuizScore||50,re={studentId:T,competencies:[{topic:R.weakestTopic||"Unknown",efficiencyScore:Math.max(15,Z-20),competencyLevel:Z<50?"beginner":"developing",perspective:`Student needs focused practice in ${R.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,Z+10),competencyLevel:Z>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:Z,competencyLevel:Z>80?"advanced":Z>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[R.weakestTopic||"Review fundamentals"],excludeTopics:[]};h(le=>le.map($=>$.rowKey===g?{...$,competency:re,loading:!1}:$))}},q=g=>{p===g?z(T=>T==="asc"?"desc":"asc"):(N(g),z("asc"))},M={High:0,Medium:1,Low:2},Y=f.filter(g=>{if(I!=="all"&&g.student.riskLevel!==I)return!1;if(j){const T=j.toLowerCase();return g.student.name.toLowerCase().includes(T)||g.student.email.toLowerCase().includes(T)}return!0}).sort((g,T)=>{let R=0;switch(p){case"name":R=g.student.name.localeCompare(T.student.name);break;case"avgQuizScore":R=g.student.avgQuizScore-T.student.avgQuizScore;break;case"riskLevel":R=M[g.student.riskLevel]-M[T.student.riskLevel];break;case"engagementScore":R=g.student.engagementScore-T.student.engagementScore;break}return C==="asc"?R:-R}),ae=f.length,$e=f.filter(g=>g.student.riskLevel==="High").length,Me=ae>0?Math.round(f.reduce((g,T)=>g+T.student.avgQuizScore,0)/ae):0,Ge=ae>0?Math.round(f.reduce((g,T)=>g+T.student.engagementScore,0)/ae):0,G=Array.from(new Set(v.map(g=>g.title).filter(Boolean))).slice(0,10),te=({field:g})=>p!==g?e.jsx(Tt,{size:14,className:"text-white/40"}):C==="asc"?e.jsx(wa,{size:14,className:"text-white font-bold"}):e.jsx(Tt,{size:14,className:"text-white font-bold"});return b?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(dt,{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:[r&&e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("button",{onClick:r,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Ss,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-[16px] mb-6",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(168,85,247,0.2)] hover:shadow-[0_8px_24px_rgba(168,85,247,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Students"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(kn,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:ae}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Evaluated in this class"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(249,115,22,0.2)] hover:shadow-[0_8px_24px_rgba(249,115,22,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"At-Risk Students"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Xs,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:$e}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Need immediate intervention"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(14,165,233,0.2)] hover:shadow-[0_8px_24px_rgba(14,165,233,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Class Average"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ds,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Me,"%"]}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. expected benchmark"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[16px] p-5 shadow-[0_4px_12px_rgba(16,185,129,0.2)] hover:shadow-[0_8px_24px_rgba(16,185,129,0.3)] hover:-translate-y-1 transition-all duration-300 flex flex-col justify-between group text-white",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full transition-transform duration-500 group-hover:scale-[1.8] group-hover:-translate-y-4 group-hover:-translate-x-4"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Avg. Engagement"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(Ta,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Ge,"%"]}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Activity completion rate"})})]})]}),e.jsx("div",{className:"sticky top-0 z-30 py-4 -my-4 bg-[#f8fafc]/80 backdrop-blur-[16px] border-b border-slate-200/50 shadow-[0_4px_20px_rgba(0,0,0,0.02)] px-2 sm:-mx-6 sm:px-6 mb-6 rounded-b-[18px]",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 w-full md:w-auto items-center",children:[e.jsxs("div",{className:"flex items-center bg-white px-4 py-2.5 rounded-full shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#e2e8f0] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all w-full sm:w-64",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#9956DE] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search students...",value:j,onChange:g=>S(g.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]}),e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar w-full sm:w-auto p-2 -m-2",children:["all","High","Medium","Low"].map(g=>e.jsx("button",{onClick:()=>U(g),className:`px-4 py-1.5 text-[13px] font-semibold rounded-full whitespace-nowrap transition-colors shadow-md ${I===g?"bg-[#9956DE] text-white":"bg-white text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:g==="all"?"All":`${g} Risk`},g))})]}),e.jsxs("button",{onClick:xe,className:"flex items-center gap-2 text-[13px] font-semibold text-slate-500 hover:text-slate-700 transition-colors shrink-0 bg-white px-4 py-2 rounded-full shadow-md hover:bg-slate-50 self-end sm:self-auto",children:[e.jsx(zs,{className:"w-4 h-4"})," Refresh"]})]})}),e.jsxs("div",{className:"bg-[#f5f3ff]/60 border border-[#e0e7ff] rounded-[14px] px-5 py-3 mb-6 flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"mt-0.5 sm:mt-0 shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#9956DE]",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center flex-1",children:[e.jsxs("span",{className:"text-[#9956DE] font-semibold text-[13px] whitespace-nowrap mr-1",children:["Imported Topic Context",s?` for ${s}`:"",":"]}),w?e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:"Loading class-scoped imported topics..."}):G.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-1 sm:mt-0",children:G.map((g,T)=>e.jsxs(de.Fragment,{children:[e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:g}),Tq("name"),children:["Student ",e.jsx(te,{field:"name"})]}),e.jsxs("div",{className:"w-[120px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",onClick:()=>q("riskLevel"),children:["Risk Level ",e.jsx(te,{field:"riskLevel"})]}),e.jsxs("div",{className:"w-[200px] shrink-0 px-4 flex items-center gap-1 cursor-pointer hover:text-white/80 transition-colors",onClick:()=>q("avgQuizScore"),children:["Avg. Score ",e.jsx(te,{field:"avgQuizScore"})]}),e.jsxs("div",{className:"w-[180px] shrink-0 px-4 flex items-center gap-1 cursor-pointer hover:text-white/80 transition-colors",onClick:()=>q("engagementScore"),children:["Engagement ",e.jsx(te,{field:"engagementScore"})]}),e.jsx("div",{className:"w-[160px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",children:"Weakest Topic"}),Cr.map((g,T)=>e.jsx("div",{className:`w-[100px] shrink-0 px-2 flex justify-center ${T===Cr.length-1?"border-r border-transparent":""}`,children:g.header},g.key))]}),Y.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(kn,{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:Y.map(g=>(g.student.riskLevel==="High"||g.student.riskLevel,e.jsxs("div",{className:"flex flex-col border-b border-slate-100 group",children:[e.jsxs("div",{className:"flex items-center min-h-[64px] hover:bg-slate-50/60 transition-colors cursor-pointer relative",onClick:()=>void he(g.rowKey),children:[e.jsxs("div",{className:"w-[260px] shrink-0 sticky left-0 z-10 bg-white group-hover:bg-slate-50/90 transition-colors px-5 h-full min-h-[64px] flex items-center border-r border-slate-100 shadow-[2px_0_4px_rgba(0,0,0,0.01)]",children:[e.jsx("div",{className:`transition-transform duration-200 mr-3 shrink-0 ${g.expanded?"rotate-90":""}`,children:e.jsx(ys,{className:"w-4 h-4 text-slate-400"})}),e.jsx("img",{src:g.student.avatar,alt:g.student.name,className:"w-8 h-8 rounded-full bg-border object-cover shrink-0 mr-3"}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:g.student.name})]}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:`px-3 py-1 rounded-full border text-[11px] font-bold uppercase tracking-wider ${g.student.riskLevel==="High"?"bg-rose-50 text-rose-600 border-rose-200":g.student.riskLevel==="Medium"?"bg-amber-50 text-amber-600 border-amber-200":"bg-emerald-50 text-emerald-600 border-emerald-200"}`,children:g.student.riskLevel})}),e.jsxs("div",{className:"w-[200px] shrink-0 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-slate-100 h-2.5 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${g.student.avgQuizScore>=80?"bg-emerald-500":g.student.avgQuizScore>=60?"bg-amber-400":"bg-rose-500"}`,style:{width:`${g.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[g.student.avgQuizScore,"%"]})]}),e.jsxs("div",{className:"w-[180px] shrink-0 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-slate-100 h-2.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#9956DE]",style:{width:`${g.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[g.student.engagementScore,"%"]})]}),e.jsx("div",{className:"w-[160px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-600 text-[11px] font-medium rounded-full truncate max-w-full border border-slate-200",children:g.student.weakestTopic})}),Cr.map(T=>{const R=g.competencyMatrix?.[T.key]??0;return e.jsx("div",{className:"w-[100px] shrink-0 px-2 flex justify-center",children:g.competencyMatrixLoading?e.jsx(dt,{size:12,className:"animate-spin text-muted-foreground"}):g.competencyMatrix?e.jsxs("span",{className:`text-[12px] font-medium px-2 rounded-full border ${R>=80?"text-emerald-600 bg-emerald-50 border-emerald-100":R>=60?"text-amber-600 bg-amber-50 border-amber-100":"text-rose-500 bg-rose-50 border-rose-100"}`,children:[R,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},T.key)})]}),e.jsx(Et,{children:g.expanded&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden bg-slate-50/80 border-t border-slate-100 shadow-inner",children:e.jsxs("div",{className:"flex min-w-[1320px]",children:[e.jsx("div",{className:"w-[260px] shrink-0 sticky left-0 z-10 bg-slate-50/90 border-r border-slate-100 flex items-start justify-end pr-4 py-4",children:e.jsx("div",{className:"w-1.5 h-full rounded-full bg-[#9956DE]/30"})}),e.jsx("div",{className:"flex-1 py-4 pl-6 pr-6",children:g.loading?e.jsxs("div",{className:"flex items-center py-4",children:[e.jsx(dt,{size:16,className:"animate-spin text-indigo-500 mr-2"}),e.jsx("span",{className:"text-sm text-slate-500",children:"Analyzing competency data..."})]}):g.competency?e.jsxs("div",{className:"space-y-4 max-w-4xl",children:[g.competency.recommendedTopics.length>0&&e.jsxs("div",{className:"bg-[#f5f3ff] rounded-[12px] p-4 border border-[#e0e7ff] inline-block shadow-sm mb-4",children:[e.jsxs("h4",{className:"text-[#7274ED] font-semibold text-[13px] flex items-center gap-2 mb-1.5",children:[e.jsx(Gt,{className:"w-4 h-4"})," Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:g.competency.recommendedTopics.map((T,R)=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full border border-indigo-100 bg-white text-indigo-700 text-xs font-medium shadow-sm",children:T},R))})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:g.competency.competencies.map((T,R)=>e.jsx(Ym,{competency:T},R))})]}):e.jsx("div",{className:"text-sm text-slate-500 py-4",children:"Failed to load competency details."})})]})})})]},g.rowKey)))})]})})]})},Ym=({competency:t})=>{const s=Eo[t.competencyLevel]||Eo.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})]})},Km=()=>{const{notifications:t,unreadCount:s,isLoading:a,markAsRead:r,markAllAsRead:o}=ei(),[n,i]=m.useState("all"),l=["streak_reminder","daily_checkin","streak_milestone","achievement_unlocked","level_up","xp_earned","quiz_result"],c=t.filter(k=>!k.isRead&&!l.includes(k.type)).length,d=k=>{switch(k){case"achievement_unlocked":case"achievement":return jl;case"message":return Al;case"grade":case"quiz_result":return Jo;case"reminder":case"streak_reminder":case"daily_checkin":return Zs;case"risk_alert":return Xs;case"sparkles":case"lesson_plan_ready":return $s;case"users":case"student_import":return os;default:return Ja}},u=(k,j)=>{switch(k){case"risk_alert":return"bg-rose-50/30 text-rose-500 border-rose-100";case"sparkles":case"lesson_plan_ready":return"bg-purple-50/30 text-[#a855f7] border-purple-100";case"daily_checkin":return"bg-amber-50/20 text-amber-500 border-amber-100";case"users":case"student_import":return"bg-blue-50/30 text-blue-500 border-blue-100";default:return"bg-slate-50 text-slate-500 border-slate-100"}},f=k=>{switch(k){case"risk_alert":return"from-rose-400 to-rose-600 shadow-[0_4px_12px_rgba(244,63,94,0.3)]";case"sparkles":case"lesson_plan_ready":return"from-[#a855f7] to-[#9333ea] shadow-[0_4px_12px_rgba(168,85,247,0.3)]";case"daily_checkin":return"from-amber-300 to-amber-500 shadow-[0_4px_12px_rgba(245,158,11,0.3)]";case"users":case"student_import":return"from-blue-400 to-blue-600 shadow-[0_4px_12px_rgba(59,130,246,0.3)]";default:return"from-slate-400 to-slate-600 shadow-[0_4px_12px_rgba(100,116,139,0.3)]"}},h=m.useMemo(()=>{let k=t.filter(j=>!l.includes(j.type));return n==="unread"&&(k=k.filter(j=>!j.isRead)),n==="important"&&(k=k.filter(j=>j.type==="risk_alert")),k},[t,n]),b=m.useMemo(()=>{const k=[],j=h.filter(N=>Un(N.createdAt)),S=h.filter(N=>Vn(N.createdAt)),p=h.filter(N=>!Un(N.createdAt)&&!Vn(N.createdAt));return j.length>0&&k.push({title:"Today",icon:Zs,items:j}),S.length>0&&k.push({title:"Yesterday",icon:En,items:S}),p.length>0&&k.push({title:"Earlier",icon:En,items:p}),k},[h]);return e.jsx("div",{className:"w-full h-full flex flex-col bg-[#f8fafc]/50",children:e.jsxs("div",{className:"max-w-[900px] mx-auto w-full p-[24px] xl:p-[32px] space-y-[24px] flex-1 overflow-y-auto no-scrollbar pb-12",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>i("all"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border ${n==="all"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:"All"}),e.jsxs("button",{onClick:()=>i("unread"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border flex items-center gap-2 ${n==="unread"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:["Unread",e.jsx("span",{className:"w-5 h-5 rounded-full bg-slate-100 text-[10px] font-bold flex items-center justify-center text-slate-500",children:c})]}),e.jsxs("button",{onClick:()=>i("important"),className:`px-6 py-2.5 text-[13px] rounded-full whitespace-nowrap transition-all duration-300 border flex items-center gap-2 ${n==="important"?"bg-purple-50 text-[#9333ea] border-purple-200 shadow-md font-bold":"bg-white/80 text-[#64748b] border-white hover:border-[#e2e8f0] shadow-sm font-medium"}`,children:["Important",t.some(k=>k.type==="risk_alert"&&!k.isRead)&&e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-rose-500 shadow-[0_0_8px_rgba(244,63,94,0.6)]"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-3 shrink-0",children:[e.jsx("span",{className:"text-[13px] font-bold text-[#64748b]",children:c>0?`${c} unread`:"No unread"}),e.jsxs("button",{onClick:o,disabled:c===0,className:"bg-white hover:bg-slate-50 border border-slate-200 text-[#475569] text-[13px] font-bold rounded-full px-5 py-2 shadow-sm transition-all hover:shadow-md hover:-translate-y-0.5 flex items-center gap-2 group disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-sm",children:[e.jsx(ac,{className:"w-4 h-4 text-[#94a3b8] group-hover:text-emerald-500 transition-colors"}),"Mark all as read"]})]})]}),e.jsx("div",{className:"space-y-8",children:a?e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white p-12 flex flex-col items-center justify-center gap-4",children:[e.jsx(dt,{className:"w-8 h-8 text-[#a855f7] animate-spin"}),e.jsx("p",{className:"text-[14px] font-medium text-[#64748b]",children:"Syncing notifications..."})]}):b.length===0?e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white p-16 flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mb-6 border border-slate-100",children:e.jsx(Ja,{className:"w-10 h-10 text-slate-300"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:"All clear!"}),e.jsx("p",{className:"text-[14px] text-[#64748b] max-w-sm",children:"No notifications found for this filter. New alerts will appear here automatically."})]}):b.map(k=>e.jsxs("div",{children:[e.jsxs("h3",{className:"text-[12px] font-bold text-[#94a3b8] uppercase tracking-wider mb-3 ml-2 flex items-center gap-2",children:[e.jsx(k.icon,{className:"w-4 h-4"})," ",k.title]}),e.jsx("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_4px_24px_rgba(0,0,0,0.03)] overflow-hidden divide-y divide-[#f1f5f9]",children:k.items.map(j=>{const S=d(j.type),p=j.type==="risk_alert";return e.jsxs(Re.div,{layout:!0,onClick:()=>!j.isRead&&r(j.id),className:`relative p-5 flex gap-5 group cursor-pointer hover:bg-white transition-all duration-300 ${j.isRead?"opacity-80":u(j.type)}`,children:[e.jsx("div",{className:`absolute left-0 top-0 w-1.5 h-full transition-colors ${j.isRead?"bg-transparent":p?"bg-rose-500":"bg-[#a855f7]"}`}),e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-white shrink-0 group-hover:scale-110 transition-transform bg-gradient-to-br ${f(j.type)}`,children:e.jsx(S,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsxs("h4",{className:"text-[15px] font-bold text-[#1e293b] flex items-center gap-2 truncate pr-4",children:[j.title,!j.isRead&&e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${p?"bg-rose-500 shadow-[0_0_6px_rgba(244,63,94,0.8)]":"bg-[#a855f7] shadow-[0_0_6px_rgba(168,85,247,0.8)]"}`})]}),e.jsxs("span",{className:`text-[12px] font-bold whitespace-nowrap ${j.isRead?"text-[#94a3b8]":p?"text-rose-600":"text-[#a855f7]"}`,children:[rc(j.createdAt)," ago"]})]}),e.jsx("p",{className:"text-[14px] text-[#475569] font-medium leading-relaxed",children:j.message}),!j.isRead&&j.actionUrl&&e.jsx("div",{className:"mt-3 flex gap-2",children:e.jsx("button",{className:`px-5 py-2 bg-white border rounded-full text-[12px] font-bold shadow-sm transition-all hover:-translate-y-0.5 ${p?"border-rose-200 text-rose-600 hover:bg-rose-50":"border-purple-200 text-[#9333ea] hover:bg-purple-50"}`,children:"Review Plan"})})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 p-2 text-slate-400 hover:text-slate-600 transition-all rounded-full hover:bg-slate-100 shrink-0 self-start",children:e.jsx(fc,{size:18})})]},j.id)})})]},k.title))})]})})},Xm=t=>{const s=t.data(),a=s.startTime,r=s.endTime,o=s.createdAt,n=s.updatedAt,i=l=>{if(l){if(typeof l?.toDate=="function")return l.toDate();if(l instanceof Date)return l}};return{...s,id:t.id,startTime:i(a)||new Date,endTime:i(r),createdAt:i(o)||new Date,updatedAt:i(n)}},Jm=async(t,s)=>{const a=pt($t(Ve,"calendarEvents")),r={id:a.id,userId:t,title:s.title,description:s.description,startTime:s.startTime,endTime:s.endTime,color:s.color,createdAt:new Date};return await is(a,{...r,createdAt:lt(),updatedAt:lt()}),r},Zm=async(t,s)=>{const a=pt(Ve,"calendarEvents",t);await Zt(a,{...s,updatedAt:lt()})},eu=async t=>{await _l(pt(Ve,"calendarEvents",t))},Ji=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:o=500}=s,n=kt($t(Ve,"calendarEvents"),jt("userId","==",t),Vr(o));return ti(n,i=>{a(i.docs.map(l=>Xm(l)))},i=>{console.error("Error subscribing to calendar events:",i),r?.(i)})};function tu({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Xo("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 qs=t=>String(t).padStart(2,"0"),Ms=t=>`${t.getFullYear()}-${qs(t.getMonth()+1)}-${qs(t.getDate())}`,Gr=t=>new Date(t.getFullYear(),t.getMonth(),1),Ro=t=>new Date(t.getFullYear(),t.getMonth()+1,0),su=t=>{const s=Gr(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},au=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},_o=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),ru=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),nu=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),Oa=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),Mo=(t,s)=>{const[a,r,o]=t.split("-").map(l=>parseInt(l,10)),[n,i]=s.split(":").map(l=>parseInt(l,10));return new Date(a,(r||1)-1,o||1,n||0,i||0,0,0)},ou=["purple","blue","emerald","amber","rose"],Ir=t=>{switch(t){case"blue":return"#3b82f6";case"emerald":return"#10b981";case"amber":return"#f59e0b";case"rose":return"#f43f5e";case"purple":default:return"#a855f7"}},iu=(t,s=!1)=>{if(s)return"bg-blue-50 text-blue-700 border-blue-100 opacity-80";switch(t){case"blue":return"bg-blue-50 text-blue-700 border-blue-100 opacity-90 hover:bg-blue-100";case"emerald":return"bg-emerald-50 text-emerald-700 border-emerald-100 opacity-90 hover:bg-emerald-100";case"amber":return"bg-amber-50 text-amber-700 border-amber-100 opacity-90 hover:bg-amber-100";case"rose":return"bg-rose-50 text-rose-700 border-rose-100 opacity-90 hover:bg-rose-100";case"purple":default:return"bg-purple-50 text-purple-700 border-purple-100 opacity-90 hover:bg-purple-100"}},lu=(t,s=!1)=>{if(s)return{dot:"bg-[#3b82f6]",border:"border-l-blue-400",time:"text-blue-600 border-blue-50"};switch(t){case"blue":return{dot:"bg-blue-500",border:"border-l-blue-400",time:"text-blue-600 border-blue-50"};case"emerald":return{dot:"bg-emerald-500",border:"border-l-emerald-400",time:"text-emerald-600 border-emerald-50"};case"amber":return{dot:"bg-amber-500",border:"border-l-amber-400",time:"text-amber-600 border-amber-50"};case"rose":return{dot:"bg-rose-500",border:"border-l-rose-400",time:"text-rose-600 border-rose-50"};case"purple":default:return{dot:"bg-[#a855f7]",border:"border-l-[#a855f7]",time:"text-[#a855f7] border-purple-50"}}},Tr=[{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 cu(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 o=Tr.find(i=>i.names.includes(r[1]))?.day,n=Tr.find(i=>i.names.includes(r[2]))?.day;if(o!==void 0&&n!==void 0){let i=o;for(;a.add(i),i!==n;)i=(i+1)%7;return Array.from(a)}}return Tr.forEach(({names:o,day:n})=>{o.some(i=>s.includes(i))&&a.add(n)}),Array.from(a).sort((o,n)=>o-n)}const du=({classes:t,teacherId:s})=>{const{currentUser:a}=ds(),[r,o]=m.useState([]),[n,i]=m.useState(!0),[l,c]=m.useState(""),[d,u]=m.useState(!0),[f,h]=m.useState(()=>{const $=new Date;return $.setHours(0,0,0,0),$}),[b,k]=m.useState(()=>{const $=new Date;return $.setHours(0,0,0,0),$}),[j,S]=m.useState(new Set),[p,N]=m.useState(!1),[C,z]=m.useState(null),[I,U]=m.useState(!1),[v,y]=m.useState(""),[w,A]=m.useState(""),[B,E]=m.useState(()=>Ms(new Date)),[F,X]=m.useState("09:00"),[J,ce]=m.useState(""),[ne,xe]=m.useState("purple"),[he,H]=m.useState(!1),[q,M]=m.useState(null);m.useEffect(()=>{if(!a?.uid){o([]),i(!1);return}c(""),i(!0);const $=Ji(a.uid,{limitCount:500},oe=>{o(oe),i(!1)},()=>{c("Unable to load calendar events right now."),i(!1)});return()=>$()},[a?.uid]);const Y=m.useMemo(()=>{const $=Gr(f);return $.setHours(0,0,0,0),$},[f]),ae=m.useMemo(()=>{const $=Ro(f);return $.setHours(23,59,59,999),$},[f]),$e=m.useMemo(()=>{if(!t||t.length===0)return[];const $=[],oe=Gr(f),pe=Ro(f),we=new Date(oe);for(;we<=pe;){const se=we.getDay();t.forEach(fe=>{if(cu(fe.schedule).includes(se)){const Fe=`schedule-${fe.id}-${Ms(we)}`;j.has(Fe)||$.push({id:Fe,userId:s||"",title:fe.name,startTime:new Date(we),createdAt:new Date})}}),we.setDate(we.getDate()+1)}return $},[t,f,s,j]),Me=m.useMemo(()=>[...r,...$e],[r,$e]),Ge=m.useMemo(()=>Me.filter($=>$.startTime>=Y&&$.startTime<=ae).sort(($,oe)=>$.startTime.getTime()-oe.startTime.getTime()),[Me,Y,ae]),G=m.useMemo(()=>{const $=new Map;for(const oe of Ge){const pe=Ms(oe.startTime),we=$.get(pe)||[];we.push(oe),$.set(pe,we)}return $},[Ge]),te=m.useMemo(()=>Ms(b),[b]),g=m.useMemo(()=>[...G.get(te)||[]].sort((oe,pe)=>oe.startTime.getTime()-pe.startTime.getTime()),[G,te]),T=m.useMemo(()=>{const $=su(f);return Array.from({length:42}).map((oe,pe)=>au($,pe))},[f]),R=$=>{const oe=Ms($);z(null),y(""),A(""),E(oe),X("09:00"),ce(""),xe("purple"),N(!0)},K=$=>{$.id.startsWith("schedule-")?(S(oe=>new Set(oe).add($.id)),z(null)):z($.id),y($.title),A($.description||""),E(Ms($.startTime)),X(qs($.startTime.getHours())+":"+qs($.startTime.getMinutes())),ce($.endTime?qs($.endTime.getHours())+":"+qs($.endTime.getMinutes()):""),xe($.color||"purple"),H(!1),N(!0)},Z=($,oe)=>{$.stopPropagation(),M(oe),H(!0)},re=async()=>{const $=a?.uid||s||"local-user";if(!v.trim()){c("Event title is required.");return}U(!0),c("");const oe=Mo(B,F),pe=J?Mo(B,J):void 0,we={title:v.trim(),description:w.trim()?w.trim():void 0,startTime:oe,endTime:pe&&pe.getTime()>oe.getTime()?pe:void 0,color:ne};try{if(C)o(se=>se.map(fe=>fe.id===C?{...fe,...we}:fe)),await Zm(C,we);else{const se=`temp-${Date.now()}`;o(fe=>[...fe,{id:se,userId:$,createdAt:new Date,...we}]),await Jm($,we)}N(!1)}catch(se){console.error(se),N(!1)}finally{U(!1)}},le=async $=>{if($.startsWith("schedule-")){S(oe=>new Set(oe).add($)),q?.id===$&&H(!1);return}c(""),o(oe=>oe.filter(pe=>pe.id!==$)),q?.id===$&&H(!1);try{await eu($)}catch(oe){console.error(oe)}};return e.jsxs("div",{className:"w-full h-full flex flex-col px-[24px] xl:px-[32px] py-[24px] xl:py-[32px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 flex-1 min-h-0 w-full max-w-[1400px] mx-auto",children:[e.jsx("div",{className:`flex flex-col flex-1 min-w-0 transition-all duration-500 ${d?"lg:w-[65%] xl:w-[70%]":"lg:w-full"}`,children:e.jsxs("div",{className:"bg-white/90 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 border-b border-[#a855f7] bg-[#a855f7] shrink-0 flex justify-between items-center rounded-t-[24px] relative overflow-hidden group",children:[e.jsx("div",{className:"absolute -bottom-24 -right-12 w-64 h-64 bg-white/10 rounded-full"}),e.jsx("div",{className:"absolute -top-20 left-1/4 w-40 h-40 bg-white/5 rounded-full"}),e.jsxs("div",{className:"flex items-center gap-5 relative z-10",children:[e.jsx("button",{onClick:()=>h(new Date(f.getFullYear(),f.getMonth()-1,1)),"aria-label":"Previous month",className:"w-9 h-9 rounded-full flex items-center justify-center text-[#6d28d9] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(Ss,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-[22px] font-bold text-white w-44 text-center tracking-tight",children:nu(f)}),e.jsx("button",{onClick:()=>h(new Date(f.getFullYear(),f.getMonth()+1,1)),"aria-label":"Next month",className:"w-9 h-9 rounded-full flex items-center justify-center text-[#6d28d9] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(ys,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-3 relative z-10",children:[e.jsxs("span",{className:"text-[13px] font-bold text-[#6d28d9] bg-white px-4 py-1.5 rounded-full shadow-sm",children:[Ge.length," events"]}),e.jsx("button",{onClick:()=>u(!d),className:`w-9 h-9 rounded-full flex items-center justify-center transition-all shadow-sm hover:shadow-md border ${d?"text-[#6d28d9] bg-white border-white":"text-white bg-white/20 border-white/30 backdrop-blur-md"}`,title:d?"Hide Sidebar":"Show Sidebar","aria-label":d?"Hide Sidebar":"Show Sidebar",children:e.jsx(kc,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto custom-scrollbar",children:[e.jsx("div",{className:"grid grid-cols-7 text-center border-b border-slate-200/60 pb-5 shrink-0 sticky top-0 bg-white z-20 shadow-[0_10px_10px_-10px_rgba(0,0,0,0.05)] px-4 pt-6",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map($=>e.jsx("div",{className:"text-[12px] font-bold text-[#475569] uppercase tracking-widest",children:$},$))}),e.jsx("div",{className:"grid grid-cols-7 gap-2 pb-6 px-4",children:T.map($=>{const oe=Ms($),pe=G.get(oe)||[],we=_o($,b),se=_o($,new Date),fe=ru($,f);return e.jsxs("div",{onClick:()=>k(new Date($)),className:`group p-2 rounded-lg transition-all cursor-pointer border-2 flex flex-col relative min-h-[100px] xl:min-h-[120px] ${we?"bg-purple-50/50 border-[#a855f7] shadow-sm z-10":se?"bg-purple-50/20 border-purple-300 shadow-[inset_0_0_20px_rgba(168,85,247,0.05)] hover:bg-purple-50/40 hover:border-purple-400":"border-transparent hover:bg-slate-50 hover:border-slate-200"} ${fe?"":"opacity-30 grayscale"}`,children:[e.jsx("div",{className:"flex justify-between items-start",children:e.jsx("span",{className:`w-7 h-7 rounded-full flex items-center justify-center font-bold text-[14px] transition-all ${se?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":we?"text-[#9333ea]":"text-[#1e293b]"}`,children:$.getDate()})}),e.jsxs("div",{className:"mt-1 space-y-1",children:[pe.slice(0,3).map(et=>{const Fe=et.id.startsWith("schedule-");return e.jsx("div",{onClick:Ke=>Z(Ke,et),className:`w-full truncate text-[11px] font-bold px-2 py-1.5 rounded border shadow-sm transition-all hover:-translate-y-[1px] hover:shadow-md cursor-pointer ${iu(et.color,Fe)}`,children:et.title},et.id)}),pe.length>3&&e.jsxs("div",{className:"text-[10px] font-bold text-[#64748b] pl-1 pt-0.5",children:["+",pe.length-3," more"]})]})]},oe)})})]})]})}),e.jsx(Et,{children:d&&e.jsx(Re.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"lg:w-[35%] xl:w-[30%] h-full shrink-0",children:e.jsxs("div",{className:"bg-white/90 backdrop-blur-[12px] rounded-[24px] border border-white shadow-[0_8px_32px_rgba(0,0,0,0.04)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 border-b border-[#f1f5f9] bg-white shrink-0 flex justify-between items-center relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-[-30px] right-[-30px] w-24 h-24 bg-purple-50 rounded-full mix-blend-multiply filter blur-2xl opacity-50 transition-transform duration-700 group-hover:scale-150"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h2",{className:"text-[20px] font-bold text-[#1e293b]",children:b.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:b.toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})})]}),e.jsx("button",{onClick:()=>R(b),title:"Add Event",className:"w-10 h-10 flex items-center justify-center rounded-full bg-[#a855f7] text-white hover:bg-[#9333ea] shadow-md shadow-purple-200 transition-all hover:scale-105 active:scale-95 relative z-10",children:e.jsx(Js,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar pb-12",children:g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[e.jsx(br,{className:"w-12 h-12 text-slate-300 mb-4"}),e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b]",children:"No events today"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Schedule a meeting or add a class."})]}):g.map($=>{const oe=$.id.startsWith("schedule-"),pe=lu($.color,oe);return e.jsxs("div",{className:"relative pl-6 before:absolute before:left-2 before:top-2 before:bottom-[-24px] before:w-[2px] before:bg-slate-100 last:before:hidden",children:[e.jsx("div",{className:`absolute left-0 top-1.5 w-4 h-4 rounded-full border-[3px] border-white shadow-sm z-10 ${pe.dot}`}),e.jsxs("div",{onClick:we=>Z(we,$),className:`group relative bg-white border border-[#e2e8f0] rounded-[20px] p-5 shadow-sm hover:shadow-md hover:-translate-y-0.5 transition-all border-l-[6px] cursor-pointer ${pe.border}`,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsx("h4",{className:"text-[15px] font-bold text-[#1e293b] group-hover:text-[#9333ea] transition-colors break-words line-clamp-2 w-full pr-2",children:$.title})}),e.jsxs("div",{className:`flex items-center gap-2 text-[11px] font-bold bg-slate-50 w-max px-2.5 py-1 rounded-lg border mb-3 ${pe.time}`,children:[e.jsx(Zs,{className:"w-3.5 h-3.5"})," ",e.jsxs("span",{children:[Oa($.startTime),$.endTime?` - ${Oa($.endTime)}`:""]})]}),$.description&&e.jsx("p",{className:"text-[13px] font-medium text-[#64748b] bg-slate-50/50 px-3 py-2 rounded-xl border border-slate-100/30 break-words whitespace-normal w-full overflow-hidden",children:$.description})]})]},$.id)})})]})})})]}),e.jsx(An,{open:p,onOpenChange:N,children:e.jsx(zn,{className:"sm:max-w-[500px] p-0 overflow-hidden rounded-[28px] border-none shadow-2xl [&>button]:hidden",children:e.jsxs("div",{className:"p-8 bg-white",children:[e.jsxs(nc,{className:"mb-6",children:[e.jsx(oc,{className:"text-[24px] font-bold text-[#1e293b] tracking-tight",children:C?"Edit Event":"Add New Event"}),e.jsx(ic,{className:"text-[14px] text-[#64748b]",children:"Schedule a classroom activity or reminder."})]}),l&&e.jsx("p",{className:"text-rose-500 text-sm font-semibold mb-4",children:l}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Event Title"}),e.jsx(ws,{value:v,onChange:$=>y($.target.value),placeholder:"e.g., Mathematics Quiz - Grade 11",className:"bg-white border-slate-200 focus:border-[#a855f7] focus:ring-4 focus:ring-purple-50 rounded-xl h-12 px-4 transition-all text-[14px]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Date"}),e.jsx(ws,{type:"date",value:B,onChange:$=>E($.target.value),className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl h-12 px-4 text-[14px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Start Time"}),e.jsx(ws,{type:"time",value:F,onChange:$=>X($.target.value),className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl h-12 px-4 text-[14px]"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Notes (Optional)"}),e.jsx(tu,{value:w,onChange:$=>A($.target.value),placeholder:"Additional details about this event...",className:"bg-white border-slate-200 focus:border-[#a855f7] rounded-xl min-h-[100px] p-4 transition-all text-[14px] break-all"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("label",{className:"text-[13px] font-bold text-[#1e293b] ml-1",children:"Color Theme"}),e.jsx("div",{className:"flex gap-3 ml-1",children:ou.map($=>e.jsx("button",{onClick:()=>xe($),className:`w-8 h-8 rounded-full flex items-center justify-center transition-all ${ne===$?"ring-2 ring-offset-2 ring-slate-800 scale-110 shadow-sm":"hover:scale-110 opacity-80 hover:opacity-100"}`,style:{backgroundColor:Ir($)},title:$,children:ne===$&&e.jsx(Mt,{className:"w-4 h-4 text-white"})},$))})]})]}),e.jsxs("div",{className:"flex gap-3 mt-8",children:[e.jsx(xt,{variant:"outline",onClick:()=>N(!1),className:"flex-1 h-12 rounded-xl font-bold border-slate-200 hover:bg-slate-100 transition-all text-[14px]",children:"Cancel"}),e.jsx(xt,{onClick:re,disabled:I,className:"flex-[1.5] h-12 rounded-xl font-bold bg-[#a855f7] hover:bg-[#9333ea] text-white shadow-lg shadow-purple-200 transition-all hover:scale-[1.02] text-[14px]",children:I?e.jsx(dt,{className:"w-5 h-5 animate-spin"}):"Save Event"})]})]})})}),e.jsx(An,{open:he,onOpenChange:H,children:e.jsx(zn,{className:"sm:max-w-[400px] p-0 overflow-hidden rounded-[24px] border-none shadow-2xl [&>button]:hidden",children:q&&e.jsxs("div",{className:"p-8 bg-white relative",children:[e.jsx("button",{onClick:()=>H(!1),"aria-label":"Close event details",className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(cs,{size:18})}),e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center shrink-0",style:{backgroundColor:Ir(q.color||"purple")+"20",color:Ir(q.color||"purple")},children:q.id.startsWith("schedule-")?e.jsx(Ya,{size:24}):e.jsx(br,{size:24})}),e.jsxs("div",{className:"pr-6",children:[e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] leading-tight mb-2",children:q.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-[12px] font-semibold border border-slate-200",children:[e.jsx(br,{size:12}),q.startTime.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-[12px] font-semibold border border-slate-200",children:[e.jsx(Zs,{size:12}),Oa(q.startTime),q.endTime?` - ${Oa(q.endTime)}`:""]})]})]})]}),q.description&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(mc,{size:16,className:"text-slate-400"}),e.jsx("h4",{className:"text-[13px] font-bold text-slate-700",children:"Details"})]}),e.jsx("p",{className:"text-[14px] text-slate-600 leading-relaxed bg-slate-50/50 p-4 rounded-xl border border-slate-100/50 break-words",children:q.description})]}),e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-slate-100",children:[e.jsxs(xt,{variant:"outline",onClick:()=>le(q.id),className:"flex-1 h-11 rounded-xl font-bold border-rose-200 text-rose-600 hover:bg-rose-50 hover:text-rose-700 transition-all text-[13px]",children:[e.jsx(ri,{className:"w-4 h-4 mr-2"})," Delete"]}),e.jsxs(xt,{onClick:()=>K(q),className:"flex-1 h-11 rounded-xl font-bold bg-[#1e293b] hover:bg-slate-800 text-white shadow-lg shadow-slate-200 transition-all hover:scale-[1.02] text-[13px]",children:[e.jsx(ci,{className:"w-4 h-4 mr-2"})," Edit Event"]})]})]})})})]})},ar=[{hex:"#9956DE",bg:"bg-[#9956DE]/10",border:"border-[#9956DE]/20",borderLeft:"border-l-[#9956DE]",text:"text-[#9956DE]",groupHover:"group-hover:text-[#9956DE]"},{hex:"#7274ED",bg:"bg-[#7274ED]/10",border:"border-[#7274ED]/20",borderLeft:"border-l-[#7274ED]",text:"text-[#7274ED]",groupHover:"group-hover:text-[#7274ED]"},{hex:"#1FA7E1",bg:"bg-[#1FA7E1]/10",border:"border-[#1FA7E1]/20",borderLeft:"border-l-[#1FA7E1]",text:"text-[#1FA7E1]",groupHover:"group-hover:text-[#1FA7E1]"},{hex:"#6ED1CF",bg:"bg-[#6ED1CF]/10",border:"border-[#6ED1CF]/20",borderLeft:"border-l-[#6ED1CF]",text:"text-[#6ED1CF]",groupHover:"group-hover:text-[#6ED1CF]"},{hex:"#FFB356",bg:"bg-[#FFB356]/10",border:"border-[#FFB356]/20",borderLeft:"border-l-[#FFB356]",text:"text-[#FFB356]",groupHover:"group-hover:text-[#FFB356]"}],Ao=({classes:t,onSelectClass:s,onOpenNotifications:a,onOpenProfile:r,insightDismissed:o,onOpenInsightModal:n,viewType:i="analytics",onCreateClass:l})=>{const{currentUser:c,userProfile:d}=ds(),[u,f]=m.useState(""),h=i==="competency",b=t.reduce((p,N)=>p+(N.studentCount||0),0),k=t.reduce((p,N)=>p+(N.atRiskCount||0),0),j=t.length>0?(t.reduce((p,N)=>p+(N.avgScore||0),0)/t.length).toFixed(1):0,S=t.filter(p=>p.name.toLowerCase().includes(u.toLowerCase())||(p.gradeLevel||"").toLowerCase().includes(u.toLowerCase()));return e.jsx("div",{className:"h-full overflow-y-auto w-full block",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto p-3 sm:p-[24px] xl:p-[32px] space-y-3 sm:space-y-[24px]",children:[e.jsx("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:e.jsx("div",{className:"flex-1 max-w-xl",children:e.jsxs("div",{className:"flex items-center bg-white/80 px-4 py-2.5 rounded-[16px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white backdrop-blur-[12px] group focus-within:ring-2 focus-within:ring-indigo-500/20 transition-all",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Global search for a student across all classes...",value:u,onChange:p=>f(p.target.value),className:"bg-transparent border-none focus:outline-none ml-3 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]})})}),h?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Total Students Evaluated"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(os,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:b}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Active across all classes"})})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Global Avg Competency"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(vs,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[j,"%"]}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. expected benchmark"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:"+1.4%"})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-4",children:[e.jsx("span",{className:"text-[13px] font-medium text-white/90",children:"Universal Weakness"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(vs,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[20px] font-bold relative z-10 leading-tight mb-2 truncate",children:"Foundational Skills"}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3 mt-auto",children:e.jsxs("span",{className:"text-[12px] font-medium text-white/90",children:["Identified in ",t.length," classes"]})})]})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-2 sm:gap-[16px]",children:[e.jsxs("div",{className:"lg:col-span-8 grid grid-cols-3 sm:grid-cols-3 gap-2 sm:gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#10b981] to-[#059669] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(16,185,129,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"Attendance rate"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(os,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:"94%"}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Active participants"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:b>0?Math.round(b*.94):0})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"Class average"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(vs,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:[j,"%"]}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Vs. last month"}),e.jsx("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:"+2.1%"})]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[14px] sm:rounded-[16px] p-[14px] sm:p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col justify-between h-full group text-white",children:[e.jsx("div",{className:"absolute -right-12 -bottom-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-start justify-between relative z-10 mb-2 sm:mb-4",children:[e.jsx("span",{className:"text-[11px] sm:text-[13px] font-medium text-white/90",children:"At risk"}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center bg-white/10",children:e.jsx(or,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[24px] sm:text-[32px] font-bold relative z-10 leading-none mb-3 sm:mb-6",children:k}),e.jsxs("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:[e.jsx("span",{className:"text-[12px] font-medium text-white/90",children:"Requires attention"}),e.jsxs("span",{className:"text-[11px] font-bold bg-white/20 px-2 py-0.5 rounded-[4px] backdrop-blur-sm",children:[b>0?Math.round(k/b*100):0,"%"]})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col text-white",children:[e.jsx("div",{className:"absolute -right-12 -top-12 w-40 h-40 bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex justify-between items-center mb-4 relative z-10 border-b border-white/20 pb-3",children:[e.jsxs("h3",{className:"text-[14px] font-semibold text-white flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-white animate-pulse shadow-[0_0_8px_rgba(255,255,255,0.8)]"}),"AI Action Items"]}),e.jsx("span",{className:"text-[10px] font-bold text-[#9333ea] bg-white px-2 py-0.5 rounded-[4px]",children:"2 Pending"})]}),e.jsxs("div",{className:"space-y-[8px] flex-1 overflow-y-auto no-scrollbar relative z-10",children:[e.jsxs("div",{className:"bg-white/10 hover:bg-white/20 rounded-[8px] p-3 text-[12px] border border-white/10 transition-colors backdrop-blur-sm group cursor-pointer flex gap-3 items-start",children:[e.jsx("div",{className:"mt-0.5 shrink-0 text-white/80 group-hover:text-white transition-colors",children:e.jsx(di,{className:"w-4 h-4"})}),e.jsxs("div",{className:"leading-snug text-white/90",children:[e.jsx("span",{className:"font-bold text-white",children:"Grade 11 - Section B"})," average dropped by 4% after the last quiz."]})]}),e.jsxs("div",{className:"bg-white/10 hover:bg-white/20 rounded-[8px] p-3 text-[12px] border border-white/10 transition-colors backdrop-blur-sm group cursor-pointer flex gap-3 items-start",children:[e.jsx("div",{className:"mt-0.5 shrink-0 text-white/80 group-hover:text-white transition-colors",children:e.jsx(gs,{className:"w-4 h-4"})}),e.jsxs("div",{className:"leading-snug text-white/90",children:[e.jsx("span",{className:"font-bold text-white",children:"3 Lesson Plans"})," generated and awaiting your review."]})]})]})]})]}),e.jsxs("div",{className:"bg-white/60 backdrop-blur-[12px] rounded-[24px] p-3 sm:p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-3 sm:mt-[24px]",children:[e.jsxs("div",{className:"mb-6 border-b border-[#f1f5f9] pb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[18px] font-semibold text-[#1e293b]",children:h?"Select a Class":"My Classes"}),l&&!h&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-semibold text-[#9956DE] bg-[#9956DE]/10 rounded-lg hover:bg-[#9956DE]/20 transition-colors",children:[e.jsx(Js,{size:14}),"Create Class"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-[16px]",children:[S.map((p,N)=>{const C=ar[N%ar.length];let z=null;return p.riskLevel==="high"?z=e.jsx("span",{className:"inline-flex px-2 py-1 bg-rose-50 text-rose-600 text-[10px] font-bold rounded-md border border-rose-100/50 uppercase",children:"High Risk"}):p.riskLevel==="medium"?z=e.jsx("span",{className:"inline-flex px-2 py-1 bg-amber-50 text-amber-600 text-[10px] font-bold rounded-md border border-amber-100/50 uppercase",children:"Medium Risk"}):z=e.jsx("span",{className:"inline-flex px-2 py-1 bg-emerald-50 text-emerald-600 text-[10px] font-bold rounded-md border border-emerald-100/50 uppercase",children:"On Track"}),e.jsxs("div",{onClick:()=>s(p),className:`flex flex-col p-[16px] bg-white shadow-[0_1px_4px_rgba(0,0,0,0.04)] hover:shadow-md hover:-translate-y-0.5 rounded-[18px] transition-all cursor-pointer group border border-[#f1f5f9] border-l-[6px] ${C.borderLeft}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-[12px] ${C.bg} flex items-center justify-center border ${C.border}`,children:e.jsx(Gt,{className:`w-5 h-5 ${C.text}`})}),e.jsxs("div",{children:[e.jsx("h4",{className:`font-bold text-[14px] text-[#1e293b] mb-0.5 transition-colors ${C.groupHover}`,children:p.name}),e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider",children:p.gradeLevel||"Senior High"})]})]}),z]}),e.jsxs("div",{className:"flex items-center justify-between text-[13px] text-[#475569] bg-[#f8fafc] rounded-[12px] p-3 border border-[#f1f5f9]",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Students"}),e.jsx("span",{className:"font-semibold text-[#1e293b]",children:p.studentCount})]}),e.jsx("div",{className:"w-[1px] h-8 bg-[#e2e8f0]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:h?"Avg Competency":"Average"}),e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[p.avgScore,"%"]})]}),!h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-[1px] h-8 bg-[#e2e8f0]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Schedule"}),e.jsx("span",{className:"font-semibold text-[#1e293b]",children:p.schedule||"Mon-Fri"})]})]})]})]},p.id)}),S.length===0&&e.jsx("div",{className:"col-span-full py-8 text-center text-[#64748b] text-[13px] bg-[#f8fafc] rounded-[18px] border border-[#e2e8f0]",children:"No classes match your search."})]})]})]})})},Zi="PH_SHS_OFFICIAL_CLASS_RECORD",mu=.85,Qr=.85,uu="2026.04.24",el=4,Va=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],xu=[...Va,"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"],pu=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],Ma=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],hu=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],fu={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},Ws={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"]},Ht={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"]},De={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 gu(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function bt(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function zo(t){return bt(t).replace(/[^A-Z0-9]+/g,"")}function Se(t,s){const a=bt(t),r=bt(s);if(!a||!r)return!1;if(a.includes(r))return!0;const o=zo(t),n=zo(s);return!o||!n?!1:o.includes(n)}function Wa(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 Er(t){return bt(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function tl(t){const s={};return t.forEach(a=>{const r=Vt.encode_cell(a.s);for(let o=a.s.r;o<=a.e.r;o+=1)for(let n=a.s.c;n<=a.e.c;n+=1){const i=Vt.encode_cell({r:o,c:n});s[i]=r}}),s}function bu(t,s,a){const o=(a||tl(t.merges))[s]||s;return t.cells[o]||t.cells[s]}const sl="A1:A1",Lo=1200,Do=200,$o=2e5;function vu(t){const s=Math.max(0,t.s.r),a=Math.max(0,t.s.c);let r=Math.max(s,t.e.r),o=Math.max(a,t.e.c);r-s+1>Lo&&(r=s+Lo-1),o-a+1>Do&&(o=a+Do-1);const n=r-s+1,i=o-a+1;if(n*i>$o){const c=Math.max(1,Math.floor($o/i));r=s+Math.min(n,c)-1}return{s:{r:s,c:a},e:{r,c:o}}}function wu(t){try{return Vt.decode_range(t)}catch{return Vt.decode_range(sl)}}function Nu(t){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;return Object.keys(t.cells).forEach(n=>{try{const i=Vt.decode_cell(n);s=Math.min(s,i.r),a=Math.min(a,i.c),r=Math.max(r,i.r),o=Math.max(o,i.c)}catch{}}),t.merges.forEach(n=>{s=Math.min(s,n.s.r,n.e.r),a=Math.min(a,n.s.c,n.e.c),r=Math.max(r,n.s.r,n.e.r),o=Math.max(o,n.s.c,n.e.c)}),!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(o)?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(o))}}}function ju(t){const s=wu(t.ref||sl),a=Nu(t);return vu(a||s)}function yu(t,s){const a=ju(s),r=`${Vt.encode_cell(a.s)}:${Vt.encode_cell(a.e)}`,o=tl(s.merges),n=a.e.r-a.s.r+1,i=a.e.c-a.s.c+1,l=[];for(let c=0;ct.endRow||at.endCol?null:t.cells[s-t.startRow]?.[a-t.startCol]??null}function Es(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function ha(t){return Vt.encode_col(t)}function Ba(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return Vt.decode_col(s)}catch{return-1}}function Su(t){return`${Vt.encode_cell(t.s)}:${Vt.encode_cell(t.e)}`}function ku(t,s){const a=[];for(let r=s.s.r;r<=s.e.r;r+=1){const o=[];for(let n=s.s.c;n<=s.e.c;n+=1){const i=Be(t,r,n);o.push(i?.displayValue??null)}a.push(o)}return a}function Cu(t,s){const a=bt(t),r=bt(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function dn(t,s){const a=[];for(let r=0;r{Se(l.normalizedText,c)&&a.push({sheetName:t.sheetName,anchor:c,row:l.row,col:l.col,address:l.address,value:String(l.displayValue??""),confidence:Cu(l.displayValue,c)})})}const o=t.startRow+r,n=Es(t,o);n&&s.forEach(i=>{if(!Se(n,i))return;const l=t.cells[r].find(c=>c?.normalizedText);l&&a.push({sheetName:t.sheetName,anchor:i,row:o,col:l.col,address:l.address,value:n,confidence:.8})})}return a}function Iu(t,s){return Object.values(t).flatMap(a=>dn(a,s))}function wt(t,s){return dn(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function al(t,s,a,r=6){for(let o=1;o<=r;o+=1){const i=Be(t,s,a+o)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}for(let o=1;o<=r;o+=1){const i=Be(t,s+o,a)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}}function rl(t,s,a=5){let r=s,o=-1;for(let n=Math.max(t.startRow,s-a);n<=Math.min(t.endRow,s+a);n+=1){const i=Es(t,n),l=["LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK"].reduce((c,d)=>i.includes(d)?c+1:c,0);l>o&&(o=l,r=n)}return r}function Tu(t,s){const a=bt(t).toLowerCase(),r=o=>[...s].some(n=>Se(n,o));return Ws.inputData.some(o=>a.includes(o))||r("INPUT DATA")?"inputData":Ws.finalSemestral.some(o=>a.includes(o))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":Ws.firstQuarter.some(o=>a.includes(o))||r("FIRST QUARTER")?"firstQuarter":Ws.secondQuarter.some(o=>a.includes(o))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":Ws.helper.some(o=>a.includes(o))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":Ws.lookup.some(o=>a.includes(o))||r("LOOK UP")?"lookup":"other"}function Eu(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,o=.65*s+.2*a+.15*r;return Number(Math.max(0,Math.min(1,o)).toFixed(4))}function Ru(t){const s=Iu(t.matrices,xu),a=new Set,r=[];Va.forEach(b=>{s.some(j=>Se(j.anchor,b))&&(a.add(b),r.push(`Found critical anchor: ${b}`))});const o=Va.filter(b=>!a.has(b)),n=new Map;s.forEach(b=>{n.has(b.sheetName)||n.set(b.sheetName,new Set),n.get(b.sheetName)?.add(b.anchor)});const i=t.sheetNames.map(b=>{const k=n.get(b)||new Set,j=Tu(b,k),S=Math.min(1,.35+Math.min(.55,k.size*.08)),p=[`sheet:${b}`,`signals:${k.size}`,...[...k].slice(0,5)];return{sheetName:b,role:j,confidence:Number(S.toFixed(3)),evidence:p}}),l={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};i.forEach(b=>{switch(b.role){case"inputData":l.inputData?l.other.push(b.sheetName):l.inputData=b.sheetName;break;case"firstQuarter":l.firstQuarter.push(b.sheetName);break;case"secondQuarter":l.secondQuarter.push(b.sheetName);break;case"finalSemestral":l.finalSemestral.push(b.sheetName);break;case"helper":l.helper.push(b.sheetName);break;case"lookup":l.lookup.push(b.sheetName);break;case"other":default:l.other.push(b.sheetName);break}});const c=(l.inputData?1:0)+l.firstQuarter.length+l.secondQuarter.length+l.finalSemestral.length+l.helper.length+l.lookup.length,d=Eu({criticalFound:a.size,criticalTotal:Va.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(b=>Se(b.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),u=l.firstQuarter.length>0||l.secondQuarter.length>0,f=!!l.inputData&&u&&l.finalSemestral.length>0,h=d>=.55&&f;return l.inputData||r.push("Input Data sheet not confidently detected."),u||r.push("No quarter class record sheet detected."),l.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:Zi,isOfficialFormatLikely:h,confidence:d,evidence:r,missingCriticalAnchors:o,detectedSheets:l,anchorMatches:s}}function rr(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 mn(t){const s=bt(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function un(t){const s=bt(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":pu.some(a=>s.includes(a))?"signature":hu.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 _u(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{a.push({role:r,name:String(Be(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Mu(t){const s=[],a=wt(t,"LEARNERS NAMES")[0],r=a?rl(t,a.row,5):t.startRow,o=(S,p)=>wt(t,S).find(C=>Math.abs(C.row-r)<=2)?.col??p,n=o(De.learnerNo[0],t.startCol),i=o(De.learnerName[0],t.startCol+1),l=o(De.firstQuarter[0],i+1),c=o(De.secondQuarter[0],l+1),d=o(De.firstSemester[0],c+1),u=o(De.finalGrades[0],d+1),f=o(De.remark[0],u+1),h=o(De.additionalRemarks[0],f+1),b=[];let k="UNKNOWN",j=0;for(let S=r+1;S<=t.endRow;S+=1){const p=Es(t,S),N=un({rowText:p,hasLearnerNumber:/\b\d{1,2}\b/.test(p),hasLearnerName:/[A-Z]{2,}/.test(p)});if(N==="sex-header"){k=mn(p)||k;continue}if(N==="signature"||N==="helper")break;if(N==="blank"){if(j+=1,j>=el)break;continue}if(N!=="learner")continue;j=0;const C=rr(Be(t,S,n)?.displayValue),z=String(Be(t,S,i)?.displayValue||"").trim();if(!z&&C===void 0)continue;const I=Be(t,S,l)?.displayValue??null,U=Be(t,S,c)?.displayValue??null,v=Be(t,S,d)?.displayValue??null,y=Be(t,S,u)?.displayValue??null,w=Be(t,S,f)?.displayValue??null;let A=Be(t,S,h)?.displayValue??null;const B=Ma.filter(E=>Se(p,E));B.length>0&&(A=[A,B.join("; ")].filter(Boolean).join("; ")||null),!z&&C!==void 0&&s.push(`Row ${S+1} has learner number ${C} but empty learner name.`),b.push({learnerNo:C,fullName:z||`Unnamed Learner ${C||S+1}`,sex:k,firstQuarter:I,secondQuarter:U,firstSemester:v,finalGrades:y,remark:w,additionalRemarks:A,sourceRow:S+1})}return{sheetName:t.sheetName,learnerGrades:b,signatures:_u(t),warnings:s}}function Jt(t,s){for(const a of s){const r=wt(t,a);for(const o of r){const n=al(t,o.row,o.col,8);if(n&&n.trim())return n.trim()}}}function Au(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(n=>{const i=al(t,n.row,n.col,10);a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function zu(t){const s=wt(t,"LEARNERS NAMES")[0];if(!s)return[];const a=s.row+1,r=s.col,o=Math.max(t.startCol,r-1),n=Math.min(t.endCol,r+1),i=Math.min(t.endCol,r+2),l=[];let c="UNKNOWN",d=0;for(let u=a;u<=t.endRow;u+=1){const f=Es(t,u),h=un({rowText:f,hasLearnerNumber:!!rr(Be(t,u,o)?.displayValue),hasLearnerName:!!String(Be(t,u,r)?.displayValue||"").trim()});if(h==="sex-header"){c=mn(f)||c,d=0;continue}if(h==="signature"||h==="helper")break;if(h!=="learner"){if(h==="blank"&&(d+=1),d>=5)break;continue}d=0;const b=rr(Be(t,u,o)?.displayValue),k=String(Be(t,u,r)?.displayValue||"").trim(),j=String(Be(t,u,n)?.displayValue||"").trim()||void 0,S=String(Be(t,u,i)?.displayValue||"").trim()||void 0,p=Ma.filter(N=>Se(f,N));!k&&b===void 0||l.push({learnerNo:b,sex:c,fullName:k||`Unnamed Learner ${b||u}`,sourceSheet:t.sheetName,sourceRow:u+1,remarks:j,additionalRemarks:S,statuses:p.length>0?p:void 0})}return l}function Lu(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const o=Es(t,r);if(o){if(Ma.some(n=>Se(o,n))){s.push(o);continue}(Se(o,"IMPORTANT")||Se(o,"NOTE")||Se(o,"ATTACHMENT")||Se(o,"LOOK UP"))&&a.push(o)}}return{attachmentRules:Array.from(new Set(s)),helperNotes:Array.from(new Set(a))}}function Du(t){const s=[],a={region:Jt(t,Ht.region),division:Jt(t,Ht.division),schoolName:Jt(t,Ht.schoolName),schoolId:Jt(t,Ht.schoolId),schoolYear:Jt(t,Ht.schoolYear),gradeSection:Jt(t,Ht.gradeSection),semester:Jt(t,Ht.semester),track:Jt(t,Ht.track),subjectCode:Jt(t,Ht.subjectCode),subjectName:Jt(t,Ht.subjectName),teacherName:Jt(t,Ht.teacherName)},r=zu(t),o=Au(t),{attachmentRules:n,helperNotes:i}=Lu(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."),dn(t,Object.values(Ht).flat()).length<4&&s.push("Input Data sheet contains limited metadata anchors; layout may have drifted."),{sheetName:t.sheetName,schoolContext:a,learners:r,signatures:o,attachmentRules:n,helperNotes:i,warnings:s}}function $u(t){const s=bt(t.sheetName);return fu.SECOND.some(a=>Se(s,a))?"SECOND":"FIRST"}function Fu(t,s){const a=[],r=[],o=[];let n,i="NONE";for(let l=t.startCol;l<=t.endCol;l+=1){const c=Be(t,s,l),d=bt(c?.displayValue||""),u=Be(t,s+1,l),f=String(u?.displayValue||c?.displayValue||"").trim();if(!d&&!f)continue;if(Se(d,De.writtenWork[0])){i="WW";continue}if(Se(d,De.performanceTasks[0])){i="PT";continue}if(Se(d,De.quarterlyAssessment[0])){n={key:Er(f||"quarterly_assessment"),label:f||"Quarterly Assessment",column:ha(l)},i="DERIVED";continue}if(Se(d,De.initialGrade[0])||Se(d,De.quarterlyGrade[0])||Se(d,De.remark[0])||Se(d,De.additionalRemarks[0])||Se(d,De.firstQuarter[0])||Se(d,De.secondQuarter[0])||Se(d,De.firstSemester[0])||Se(d,De.finalGrades[0])||Se(d,De.ps[0])||Se(d,De.ws[0])||Se(d,De.total[0])){i="DERIVED",o.push({key:Er(f||d),label:f||d,column:ha(l)});continue}const h={key:Er(f||d||ha(l)),label:f||d||ha(l),maxScore:Wa(u?.displayValue),column:ha(l)};i==="WW"?a.push(h):i==="PT"?r.push(h):i==="DERIVED"&&o.push(h)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:n,derived:o}}function Ou(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{const n=Be(t,o.row,o.col+1),i=String(n?.displayValue||"").trim()||void 0;a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Fo(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const o=bt(Be(t,s,r)?.displayValue||""),n=bt(Be(t,s+1,r)?.displayValue||"");if(a.some(i=>Se(o,i)||Se(n,i)))return r}}function Bu(t,s,a,r){const o={learnerNo:rr(Be(t,s,r.numberCol)?.displayValue),fullName:String(Be(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},n={};a.writtenWorks.forEach(d=>{const u=d.column?Ba(d.column):-1;if(u<0)return;const f=Be(t,s,u)?.displayValue;n[d.key]=f??null}),Object.keys(n).length>0&&(o.writtenWorks=n);const i={};if(a.performanceTasks.forEach(d=>{const u=d.column?Ba(d.column):-1;if(u<0)return;const f=Be(t,s,u)?.displayValue;i[d.key]=f??null}),Object.keys(i).length>0&&(o.performanceTasks=i),a.quarterlyAssessment?.column){const d=Ba(a.quarterlyAssessment.column);o.quarterlyAssessment=Be(t,s,d)?.displayValue??null}const l=a.derived||[],c={};return l.forEach(d=>{if(!d.column)return;const u=Ba(d.column);if(u<0)return;const f=Be(t,s,u)?.displayValue??null;c[d.key]=f,Se(d.label,De.initialGrade[0])&&(o.initialGrade=f),Se(d.label,De.quarterlyGrade[0])&&(o.quarterlyGrade=f),Se(d.label,De.firstQuarter[0])&&(o.firstQuarter=f),Se(d.label,De.secondQuarter[0])&&(o.secondQuarter=f),Se(d.label,De.firstSemester[0])&&(o.firstSemester=f),Se(d.label,De.finalGrades[0])&&(o.finalGrades=f),Se(d.label,De.remark[0])&&(o.remark=f!==null?String(f):null),Se(d.label,De.additionalRemarks[0])&&(o.additionalRemarks=f!==null?String(f):null)}),Object.keys(c).length>0&&(o.totals=c),o}function Pu(t){const s=$u(t),a=[],r=wt(t,De.learnerName[0])[0]||wt(t,De.learnerName[1])[0],o=r?rl(t,r.row,4):t.startRow,n=Fu(t,o),i=Fo(t,o,De.learnerNo)??t.startCol,l=Fo(t,o,De.learnerName)??Math.min(t.endCol,i+1),c=[];let d="UNKNOWN",u=0;for(let k=o+1;k<=t.endRow;k+=1){const j=Es(t,k),S=un({rowText:j,hasLearnerNumber:/\b\d{1,2}\b/.test(j),hasLearnerName:/[A-Z]{2,}/.test(j)});if(S==="sex-header"){d=mn(j)||d;continue}if(S==="signature"||S==="helper")break;if(S==="blank"){if(u+=1,u>=el)break;continue}if(S!=="learner")continue;u=0;const p=Bu(t,k,n,{numberCol:i,nameCol:l});if(p.sex=d,!p.fullName&&p.learnerNo===void 0)continue;const N=Ma.filter(C=>Se(j,C));N.length>0&&!p.additionalRemarks&&(p.additionalRemarks=N.join("; ")),!p.fullName&&p.learnerNo!==void 0&&(a.push(`Row ${k+1} has learner number ${p.learnerNo} but empty name.`),p.fullName=`Unnamed Learner ${p.learnerNo}`),c.push(p)}n.writtenWorks.length===0&&n.performanceTasks.length===0&&a.push(`No detailed assessment columns detected in ${t.sheetName}.`);const f=Wa(wt(t,"WRITTEN WORK %")[0]?.value||wt(t,"WRITTEN WORK")[0]?.value),h=Wa(wt(t,"PERFORMANCE TASKS %")[0]?.value||wt(t,"PERFORMANCE TASKS")[0]?.value),b=Wa(wt(t,"QUARTERLY ASSESSMENT %")[0]?.value||wt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:f,performanceTasks:h,quarterlyAssessment:b},assessmentColumns:n,learnerGrades:c,signatures:Ou(t),warnings:a}}function Hu(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{wt(t,r).forEach(o=>{a.push({role:r,name:String(Be(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function Gu(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const o=Es(t,r);if(!o){if(a&&s.length>0)break;continue}if(Se(o,"WEIGHT OF COMPONENTS")){a=!0;continue}if(!a)continue;const n={sourceRow:r+1,raw:o};for(let i=t.startCol;i<=t.endCol;i+=1){const l=Be(t,r,i)?.displayValue;l==null||String(l).trim()===""||(n[`c${i}`]=l)}Object.keys(n).length>2&&s.push(n)}return s}function Qu(t){const s=[],a=[],r=[],o=[],n=[];return t.forEach(i=>{Hu(i).forEach(l=>a.push(l)),Gu(i).forEach(l=>r.push({...l,sourceSheet:i.sheetName}));for(let l=i.startRow;l<=i.endRow;l+=1){const c=Es(i,l);if(c){if(Ma.some(d=>Se(c,d))){o.push(`${i.sheetName}: ${c}`);continue}(Se(c,"HELPER")||Se(c,"LOOK UP")||Se(c,"IMPORTANT")||Se(c,"REFERENCE")||Se(c,"ATTACHMENT"))&&n.push(`${i.sheetName}: ${c}`)}}}),r.length===0&&s.push("No component weight rows were parsed from reference sheets."),{sheetName:t.map(i=>i.sheetName).join(", "),componentWeights:r,attachmentRules:Array.from(new Set(o)),helperNotes:Array.from(new Set(n)),signatures:a,warnings:s}}function Uu(t,s,a){const r=new Map,o=n=>{const i=`${bt(n.fullName)}|${n.learnerNo||""}|${n.sourceSheet}`,l=r.get(i);if(!l){r.set(i,n);return}const c=Array.from(new Set([...l.statuses||[],...n.statuses||[]]));r.set(i,{...l,...n,remarks:n.remarks||l.remarks,additionalRemarks:n.additionalRemarks||l.additionalRemarks,statuses:c.length>0?c:void 0})};return t.forEach(o),s.forEach(n=>{n.learnerGrades.forEach(i=>{o({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:n.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),a.forEach(n=>{n.learnerGrades.forEach(i=>{o({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:n.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),Array.from(r.values())}function Vu(t,s,a,r){const o=[...t.signatures,...s.flatMap(i=>i.signatures),...a.flatMap(i=>i.signatures),...r.signatures],n=new Map;return o.forEach(i=>{const l=`${bt(i.role)}|${bt(i.name||"")}|${i.sourceSheet}`;n.set(l,i)}),Array.from(n.values())}function Wu(t){const s=Uu(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:Zi,version:uu,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:Vu(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function qu(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 Yu(t){const s={ref:t["!ref"],merges:qu(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 Ku(t,s){const a=cc(s,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0,raw:!1}),r={},o={};return a.SheetNames.forEach(n=>{const i=a.Sheets[n];if(!i)return;const l=Yu(i);o[n]=l,r[n]=yu(n,l)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:o},matrices:r}}async function Xu(t){const s=await t.arrayBuffer();return Ku(t.name,s)}class Ju{state={};markRange(s,a,r){const o=s;this.state[o]||(this.state[o]={mappedAddresses:new Set,mappings:[]});for(let n=a.s.r;n<=a.e.r;n+=1)for(let i=a.s.c;i<=a.e.c;i+=1)this.state[o].mappedAddresses.add(`${n}:${i}`);this.state[o].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(o=>{const n=new Set,i=this.state[o.sheetName]?.mappedAddresses??new Set;for(let l=o.startRow;l<=o.endRow;l+=1)for(let c=o.startCol;c<=o.endCol;c+=1){const d=`${l}:${c}`;if(n.has(d)||i.has(d))continue;const u=Be(o,l,c);if(!(u&&u.displayValue!==null&&u.displayValue!==void 0&&String(u.displayValue).trim())){n.add(d);continue}const h=this.collectComponent(o,l,c,i,n);h&&r.push({sheetName:o.sheetName,range:Su(h),purposeGuess:a,raw2D:ku(o,h)})}}),r}collectComponent(s,a,r,o,n){const i=[{row:a,col:r}];let l=a,c=a,d=r,u=r,f=!1;for(;i.length>0;){const h=i.shift();if(!h)break;const b=`${h.row}:${h.col}`;if(n.has(b)||o.has(b))continue;n.add(b);const k=Be(s,h.row,h.col);k&&k.displayValue!==null&&k.displayValue!==void 0&&String(k.displayValue).trim()&&(f=!0,l=Math.min(l,h.row),c=Math.max(c,h.row),d=Math.min(d,h.col),u=Math.max(u,h.col),[{row:h.row-1,col:h.col},{row:h.row+1,col:h.col},{row:h.row,col:h.col-1},{row:h.row,col:h.col+1}].forEach(S=>{S.rows.endRow||S.cols.endCol||i.push(S)}))}return f?{s:{r:l,c:d},e:{r:c,c:u}}:null}}function Zu(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,o)=>r+o,0);return{totalSheets:t.totalSheets,recognizedSheets:a,unclassifiedSheets:s.other.length,mappedCellRegions:t.mappedCellRegions,unmappedCellRegions:t.unmappedCellRegions}}function ex(t){const s=new Map;t.forEach(r=>{const o=`${r.learnerNo||""}|${r.fullName.trim().toUpperCase()}`;s.has(o)||s.set(o,[]),s.get(o)?.push(r.sourceRow)});const a=[];return s.forEach((r,o)=>{r.length>1&&a.push(`Duplicate learner entry detected for ${o} at rows ${r.join(", ")}.`)}),a}function tx(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 o=r.writtenWorks&&Object.values(r.writtenWorks).some(i=>i!==null&&i!==""),n=r.performanceTasks&&Object.values(r.performanceTasks).some(i=>i!==null&&i!=="");!o&&!n&&r.quarterlyAssessment==null&&s.push(`${a.sheetName} row ${r.sourceRow}: all grade blocks are empty.`)})}),s}function sx(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 ax(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(", ")}.`),ex(t.inputData.learners).forEach(n=>s.push(n)),tx(t.quarterSheets).forEach(n=>s.push(n)),sx(t.finalSheets).forEach(n=>s.push(n)),s.push(...t.inputData.warnings),t.quarterSheets.forEach(n=>s.push(...n.warnings)),t.finalSheets.forEach(n=>s.push(...n.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,o=t.detection.isOfficialFormatLikely&&a.length===0;return r({fullName:i.fullName,learnerNo:i.learnerNo,sex:i.sex,remarks:i.remarks,additionalRemarks:i.additionalRemarks,statuses:i.statuses,sourceSheet:i.sourceSheet,sourceRow:i.sourceRow})),r=t.quarterlyRecords.flatMap(i=>i.learnerGrades.map(l=>({fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,quarter:i.quarter,firstQuarter:l.firstQuarter,secondQuarter:l.secondQuarter,firstSemester:l.firstSemester,finalGrades:l.finalGrades,quarterlyGrade:l.quarterlyGrade,initialGrade:l.initialGrade,remark:l.remark,additionalRemarks:l.additionalRemarks}))),o=t.finalSemestralRecords.flatMap(i=>i.learnerGrades.map(l=>({fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,firstQuarter:l.firstQuarter,secondQuarter:l.secondQuarter,firstSemester:l.firstSemester,finalGrades:l.finalGrades,remark:l.remark,additionalRemarks:l.additionalRemarks}))),n=[...t.learners,...t.quarterlyRecords.flatMap(i=>i.learnerGrades.map(l=>({learnerNo:l.learnerNo,sex:l.sex,fullName:l.fullName,sourceSheet:i.sheetName,sourceRow:l.sourceRow,remarks:l.remark||void 0,additionalRemarks:l.additionalRemarks||void 0})))].map(i=>({fullName:i.fullName,remark:i.remarks||null,additionalRemarks:i.additionalRemarks||null,statuses:"statuses"in i?i.statuses:void 0,sourceSheet:i.sourceSheet,sourceRow:i.sourceRow}));return{classEntity:s,studentEntities:a,gradeEntities:[...r,...o],remarksEntities:n}}const Oo=1500;function Bo(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function Po(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>=Oo){console.warn(`${s} slow=true threshold=${Oo}ms`);return}}function As(t,s){t?.onProgress?.(s)}function nx(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 fa(t,s,a,r){nx(a,s).forEach(o=>{t.markRange(s.sheetName,{s:{r:o,c:s.startCol},e:{r:o,c:s.endCol}},r)})}async function ox(t,s){const a=s?.confidenceThreshold??mu,r=Date.now();let o=null;try{if(As(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),o=await Xu(t),!o)throw new Error("Workbook read returned null");As(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const n=Ru(o);As(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const i=n.detectedSheets.inputData||o.sheetNames[0],l=o.matrices[i],c=l?Du(l):{sheetName:i,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},u=[...n.detectedSheets.firstQuarter||[],...n.detectedSheets.secondQuarter||[]].map(C=>o.matrices[C]).filter(C=>!!C).map(C=>Pu(C)),f=(n.detectedSheets.finalSemestral||[]).map(C=>o.matrices[C]).filter(C=>!!C).map(C=>Mu(C)),h=[...n.detectedSheets.helper||[],...n.detectedSheets.lookup||[]].map(C=>o.matrices[C]).filter(C=>!!C),b=Qu(h),k=new Ju;n.anchorMatches.forEach(C=>{const z=o.matrices[C.sheetName];z&&fa(k,z,[C.row],`Anchor match: ${C.anchor}`)}),[c.sheetName].forEach(C=>{const z=o.matrices[C];if(!z)return;const I=Array.from({length:Math.min(14,z.rowCount)},(y,w)=>z.startRow+w),U=c.learners.map(y=>y.sourceRow-1),v=c.signatures.map(y=>y.sourceRow).filter(y=>typeof y=="number").map(y=>y-1);fa(k,z,[...I,...U,...v],"Input Data parsed rows")}),u.forEach(C=>{const z=o.matrices[C.sheetName];if(!z)return;const I=C.learnerGrades.map(y=>y.sourceRow-1),U=C.signatures.map(y=>y.sourceRow).filter(y=>typeof y=="number").map(y=>y-1),v=I.length>0?Math.max(z.startRow,Math.min(...I)-2):z.startRow;fa(k,z,[v,v+1,...I,...U],"Quarter sheet parsed rows")}),f.forEach(C=>{const z=o.matrices[C.sheetName];if(!z)return;const I=C.learnerGrades.map(y=>y.sourceRow-1),U=C.signatures.map(y=>y.sourceRow).filter(y=>typeof y=="number").map(y=>y-1),v=I.length>0?Math.max(z.startRow,Math.min(...I)-2):z.startRow;fa(k,z,[v,v+1,...I,...U],"Final semestral parsed rows")}),h.forEach(C=>{const z=b.componentWeights.filter(v=>v.sourceSheet===C.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1),I=b.signatures?.filter(v=>v.sourceSheet===C.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1)||[],U=z.length===0&&I.length===0?[C.startRow,C.startRow+1,C.startRow+2]:[];fa(k,C,[...z,...I,...U],"Reference/helper parsed rows")});const j=k.getUnmappedBlocks(o.matrices);As(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const S=ax({detection:n,inputData:c,quarterSheets:u,finalSheets:f,mappedCellRegions:k.getMappedRegionCount(),unmappedCellRegions:j.length,totalSheets:o.sheetNames.length});As(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const p=Wu({workbook:o,detection:n,inputData:c,quarterSheets:u,finalSheets:f,references:b,validation:S,unclassifiedBlocks:j});p.validation.confidenceg.trim().toLowerCase().replace(/\s+/g," "),ne=g=>{if(typeof g=="number"&&Number.isFinite(g))return g;const T=Number(String(g??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(T)?T:null},xe=(g,T)=>{const R=Number.isFinite(g)?g:T;return Math.max(0,Math.min(100,R))},he=g=>{const T=String(g??"");return/[",\n]/.test(T)?`"${T.replace(/"/g,'""')}"`:T},H=(g,T)=>{const R=new Map,K=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];g.mapping.gradeEntities.forEach(se=>{const fe=ce(se.fullName||"");if(!fe)return;const et=K.map(Ke=>ne(se[Ke])).filter(Ke=>Ke!==null);if(et.length===0)return;const Fe=R.get(fe)||[];R.set(fe,Fe.concat(et))});const Z=g.mapping.studentEntities||[];if(Z.length===0)return null;const re=(g.imported.schoolContext.semester||g.imported.schoolContext.schoolYear||"First Semester").trim(),le=(g.imported.schoolContext.subjectName||"Class Record Import").trim(),$=(t||s||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",pe=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(Z.forEach((se,fe)=>{const et=ce(se.fullName||""),Fe=R.get(et)||[],Ke=Fe.length>0?Fe.reduce((Ye,vt)=>Ye+vt,0)/Fe.length:75,rt=xe(Ke,75),Rt=xe(rt+5,85),St=xe(rt*.7+Rt*.3,80),Ft=xe(Rt*.6+rt*.4,82),ss=se.learnerNo||fe+1,P=`IMP-${$}-${String(ss).padStart(4,"0")}`,Ae=se.fullName||`Learner ${fe+1}`;pe.push([he(Ae),he(P),he(""),he(Number(St.toFixed(1))),he(Number(rt.toFixed(1))),he(Number(Rt.toFixed(1))),he(Number(Ft.toFixed(1))),he(re),he(le)].join(","))}),pe.length<=1)return null;const we=T.replace(/\.(xlsx|xls)$/i,"");return new File([pe.join(` -`)],`${we}-normalized.csv`,{type:"text/csv"})},q=async g=>{v(!0),B(""),F(null);let T=g;if(/\.(xlsx|xls)$/i.test(g.name))try{const R=await ox(g,{confidenceThreshold:Qr});p(R);const K=H(R,g.name);K&&(T=K)}catch{p(null)}else p(null);try{const R=await nt.uploadClassRecords(T,{classSectionId:t,className:s,datasetIntent:"synthetic_student_records"}),K=R.students.length,re=((le,$,oe,pe)=>({classSectionId:le.classSectionId||$||"imported_class",className:le.className||oe||"Imported Class",classMetadata:le.classMetadata||pe}))(R,t,s,a);K>0&&i?.({students:R.students,classSectionId:re.classSectionId,className:re.className,classMetadata:re.classMetadata}),R.success?(me.success(`Successfully imported ${K} student records.`),F({datasetIntent:R.datasetIntent,summary:R.interpretationSummary,columns:R.columnInterpretations?.map(le=>({columnName:le.columnName,mappedField:le.mappedField,usagePolicy:le.usagePolicy,confidenceBand:le.confidenceBand,domainSignals:le.domainSignals}))||[]}),l?.()):me.error("Import completed but no usable student rows were detected. Check required columns and retry.")}catch(R){me.error(R instanceof Error?R.message:"Upload failed")}finally{v(!1)}},M=async g=>{w(!0);try{const T=await nt.uploadCourseMaterials(g,{classSectionId:t,className:s});if(T.success){const R=T.topics?.length??0;me.success(`Course material imported (${R} topics extracted).`),l?.()}}catch(T){me.error(T instanceof Error?T.message:"Course material upload failed")}finally{w(!1)}},[Y,ae]=m.useState(r),[$e,Me]=m.useState(!1);m.useEffect(()=>{ae(r),G(Object.fromEntries(r.map(g=>[Pa(g),{grade:g.grade||"Grade 11",section:g.section||"Section A"}])))},[r]);const[Ge,G]=m.useState({}),te=async()=>{Me(!0);try{for(const T of Y){const R=Ge[Pa(T)],K=R?.grade||T.grade,Z=R?.section||T.section;o&&(K!==T.grade||Z!==T.section)&&(await mr(T.id,K,Z,o,new Date().getFullYear().toString(),n),await Vi(T.id,K,Z));try{const re=await nt.predictRisk({engagementScore:T.engagementScore,avgQuizScore:T.avgScore,attendance:T.attendance,assignmentCompletion:T.assignmentCompletion});await jm(T.id,re.riskLevel,re.confidence)}catch(re){console.error("Failed to update risk:",re)}}const g=Y.map(T=>{const R=Ge[Pa(T)];if(!R)return T;const K=gt({metadata:T.classMetadata,classSectionId:T.classSectionId,className:[R.grade,R.section].filter(Boolean).join(" - "),grade:R.grade,section:R.section});return{...T,grade:R.grade,section:R.section,className:K.className||[R.grade,R.section].filter(Boolean).join(" - "),classSectionId:K.classSectionId||T.classSectionId,classMetadata:K}});ae(g),d?.(g),me.success("Records saved and risk levels updated"),j("main")}catch{me.error("Failed to save changes")}finally{Me(!1)}};return e.jsx("div",{className:"h-full overflow-y-auto w-full block",children:e.jsxs("div",{className:"w-full p-[24px] xl:p-[32px] space-y-[24px]",children:[k==="main"&&e.jsxs("div",{className:"block space-y-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[16px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-slate-200 flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-indigo-50 flex items-center justify-center border border-indigo-100/50",children:e.jsx(Ka,{className:"w-5 h-5 text-indigo-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[14px] font-bold text-[#1e293b]",children:"Upload Context"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Select where the imported data should be applied"})]})]}),e.jsxs("div",{className:"relative w-full md:w-[300px]",children:[e.jsxs("select",{className:"appearance-none bg-[#f8fafc] border border-[#e2e8f0] text-[#1e293b] font-bold text-[13px] rounded-lg pl-4 pr-10 py-2.5 outline-none focus:border-[#4f46e5] focus:ring-2 focus:ring-[#4f46e5]/20 shadow-[0_1px_4px_rgba(0,0,0,0.02)] cursor-pointer w-full transition-colors",value:s||t||"All Classes",onChange:()=>{},children:[e.jsx("option",{value:s||t||"All Classes",children:s||t?`${s} ${t?`(${t})`:""}`:"All Classes"}),e.jsx("option",{value:"Grade 11 - Section A",children:"Grade 11 - Section A"}),e.jsx("option",{value:"Grade 11 - Section B",children:"Grade 11 - Section B"})]}),e.jsx(Tt,{className:"w-4 h-4 text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{onDragOver:g=>{g.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:g=>{g.preventDefault(),C(!1);const T=g.dataTransfer.files[0];T&&q(T)},onClick:()=>X.current?.click(),className:`border-2 border-dashed transition-all rounded-[24px] p-8 flex flex-col items-center justify-center text-center cursor-pointer group shadow-[0_4px_20px_rgba(0,0,0,0.02)] relative overflow-hidden h-[280px] ${N?"border-[#1FA7E1] bg-[#1FA7E1]/10":"border-[#1FA7E1]/30 hover:border-[#1FA7E1] bg-white hover:bg-[#1FA7E1]/5"}`,children:[e.jsx("input",{ref:X,type:"file",accept:".csv,.xlsx,.xls",onChange:g=>{const T=g.target.files?.[0];T&&q(T)},className:"hidden"}),e.jsx("div",{className:"w-16 h-16 rounded-full bg-[#1FA7E1]/10 flex items-center justify-center mb-4 group-hover:scale-110 transition-transform duration-300 shadow-sm border border-[#1FA7E1]/20",children:U?e.jsx("span",{className:"animate-spin text-[#1FA7E1]",children:"..."}):e.jsx(zc,{className:"w-8 h-8 text-[#1FA7E1]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:U?"Uploading...":"Class Records"}),e.jsx("p",{className:"text-[13px] text-[#64748b] max-w-sm mb-6",children:"Upload student grades, attendance logs, and quiz scores to power predictive analytics."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".csv"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".xlsx"})]})]}),e.jsxs("div",{onDragOver:g=>{g.preventDefault(),I(!0)},onDragLeave:()=>I(!1),onDrop:g=>{g.preventDefault(),I(!1);const T=g.dataTransfer.files[0];T&&M(T)},onClick:()=>J.current?.click(),className:`border-2 border-dashed transition-all rounded-[24px] p-8 flex flex-col items-center justify-center text-center cursor-pointer group shadow-[0_4px_20px_rgba(0,0,0,0.02)] relative overflow-hidden h-[280px] ${z?"border-[#9956DE] bg-[#9956DE]/10":"border-[#9956DE]/30 hover:border-[#9956DE] bg-white hover:bg-[#9956DE]/5"}`,children:[e.jsx("input",{ref:J,type:"file",accept:".pdf,.docx,.txt",onChange:g=>{const T=g.target.files?.[0];T&&M(T)},className:"hidden"}),e.jsx("div",{className:"w-16 h-16 rounded-full bg-[#9956DE]/10 flex items-center justify-center mb-4 group-hover:scale-110 transition-transform duration-300 shadow-sm border border-[#9956DE]/20",children:y?e.jsx("span",{className:"animate-spin text-[#9956DE]",children:"..."}):e.jsx(gs,{className:"w-8 h-8 text-[#9956DE]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:y?"Uploading...":"Course Materials"}),e.jsx("p",{className:"text-[13px] text-[#64748b] max-w-sm mb-6",children:"Upload syllabus, lesson plans, and curriculum docs to ground AI lesson generation."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".pdf"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".docx"}),e.jsx("span",{className:"px-3 py-1 bg-slate-100 text-slate-500 text-[11px] font-semibold rounded-full border border-slate-200",children:".txt"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-[16px]",children:[e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#0ea5e9] to-[#0284c7] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(14,165,233,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-sky-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx(Mc,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Smart Parsing"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"AI automatically understands varied spreadsheet formats and maps column names securely."})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#f97316] to-[#ea580c] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(249,115,22,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-orange-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx(di,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Risk Prediction"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"Analyzes historical performance patterns across your data to predict at-risk students."})]}),e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-[#a855f7] to-[#9333ea] rounded-[16px] p-[20px] shadow-[0_4px_12px_rgba(168,85,247,0.2)] flex flex-col text-white group transition-all duration-300 hover:-translate-y-1 hover:shadow-lg hover:shadow-purple-500/30",children:[e.jsx("div",{className:"absolute -right-8 -bottom-8 w-24 h-24 bg-white/10 rounded-full"}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/10 border border-white/20 flex items-center justify-center shrink-0 mb-3 relative z-10 transition-transform group-hover:scale-110",children:e.jsx($s,{className:"w-5 h-5 text-white"})}),e.jsx("h4",{className:"font-bold text-[14px] mb-1.5 relative z-10",children:"Contextual AI"}),e.jsx("p",{className:"text-[12px] text-white/90 leading-relaxed relative z-10",children:"Maps curriculum topics to generate highly personalized remedial lesson paths."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white flex flex-col justify-between h-full",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[#1e293b] mb-4",children:"Data Health"}),e.jsxs("div",{className:"flex-1 bg-emerald-50/50 border border-emerald-100 rounded-[16px] p-6 flex flex-col items-center justify-center text-center transition-all duration-300 hover:bg-emerald-50 hover:shadow-md hover:border-emerald-200",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-100 flex items-center justify-center mb-3 text-emerald-600 transition-transform duration-300 hover:scale-110 hover:-translate-y-1",children:e.jsx(Wr,{className:"w-6 h-6"})}),e.jsx("h3",{className:"text-emerald-700 font-bold text-[15px] mb-1",children:"All Records Synced"}),e.jsx("p",{className:"text-emerald-600/80 text-[12px] max-w-[200px]",children:"AI parsing completed successfully with no anomalies detected."})]}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4",children:[e.jsxs("button",{onClick:()=>j("edit-records"),className:"w-full flex items-center justify-center gap-2 bg-[#1e293b] hover:bg-black text-white text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-transform hover:scale-[1.02]",children:[e.jsx(Ic,{className:"w-4 h-4"})," Edit Class Records"]}),e.jsx("button",{onClick:()=>j("mapping-logs"),className:"w-full flex items-center justify-center gap-2 bg-white text-[#475569] border border-slate-300 hover:bg-slate-50 text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-colors",children:"View Mapping Logs"})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[#1e293b]",children:"Recent Uploads"}),e.jsx("button",{onClick:()=>j("mapping-logs"),className:"text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors",children:"View All"})]}),e.jsxs("div",{className:"flex-1 space-y-[12px] overflow-y-auto no-scrollbar flex flex-col justify-center items-center h-[120px]",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-50 flex items-center justify-center mb-2 border border-slate-100",children:e.jsx(Nc,{className:"w-5 h-5 text-slate-300"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-500",children:"There are no recent uploads yet."})]})]})]})]}),k==="mapping-logs"&&e.jsxs("div",{className:"space-y-[16px]",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>j("main"),className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors w-max bg-white px-[18px] py-2 rounded-full shadow-sm border border-slate-200",children:[e.jsx(Xa,{className:"w-4 h-4"})," Back to Uploads"]})}),e.jsxs("div",{className:"bg-white rounded-[18px] border border-[#f1f5f9] overflow-hidden shadow-sm",children:[e.jsx("div",{className:"p-5 border-b border-[#f1f5f9] bg-slate-50 flex justify-between items-center",children:e.jsx("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Latest Import Mapping"})}),e.jsx("div",{className:"p-5",children:E?e.jsx("div",{className:"space-y-3",children:E.columns.map((g,T)=>e.jsxs("div",{className:"flex justify-between p-3 border rounded bg-slate-50",children:[e.jsx("span",{className:"font-semibold text-sm",children:g.columnName}),e.jsx("span",{className:"text-sm text-indigo-600",children:g.mappedField||"Unmapped"})]},T))}):e.jsx("p",{className:"text-slate-500 text-sm",children:"No recent mapping logs to display."})})]})]}),k==="edit-records"&&e.jsxs("div",{className:"space-y-[16px] h-full flex flex-col",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>j("main"),className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors w-max bg-white px-[18px] py-2 rounded-full shadow-sm border border-slate-200",children:[e.jsx(Xa,{className:"w-4 h-4"})," Back to Uploads"]})}),e.jsxs("div",{className:"bg-white rounded-[18px] border border-slate-200 shadow-sm overflow-hidden flex flex-col flex-1",children:[e.jsxs("div",{className:"p-5 border-b border-slate-200 flex justify-between items-center bg-white",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[18px] font-bold text-[#1e293b]",children:"Edit Class Records"}),e.jsx("p",{className:"text-[13px] text-[#64748b]",children:"Review and modify student data manually"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>j("main"),className:"px-5 py-2 rounded-full border border-slate-300 text-slate-700 font-semibold text-[13px] hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:te,disabled:$e,className:"px-5 py-2 rounded-full bg-emerald-500 text-white font-semibold text-[13px] hover:bg-emerald-600 flex items-center gap-2 disabled:opacity-50",children:$e?"Saving...":e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"w-4 h-4"})," Save Changes"]})})]})]}),e.jsxs("div",{className:"px-5 py-3 border-b border-slate-200 flex justify-between items-center bg-slate-50/50 shrink-0 text-slate-500 text-[13px]",children:[e.jsxs("span",{className:"flex items-center gap-2 font-medium",children:[e.jsx(ga,{className:"w-4 h-4"})," Click on any field to edit"]}),e.jsxs("span",{children:["Showing ",Y.length," records"]})]}),e.jsx("div",{className:"overflow-auto flex-1 table-scrollbar bg-white relative",children:e.jsxs("div",{className:"min-w-[1100px] w-full flex flex-col min-h-full",children:[e.jsxs("div",{className:"flex items-center w-full bg-slate-100/90 border-b border-slate-200 text-[12px] font-semibold text-slate-500 tracking-wide sticky top-0 z-20 shadow-[0_1px_2px_rgba(0,0,0,0.02)] h-12",children:[e.jsx("div",{className:"flex-[1.5] min-w-[240px] px-6 sticky left-0 z-30 bg-slate-100/90 backdrop-blur-sm border-r border-slate-200 h-full flex items-center shadow-[2px_0_4px_rgba(0,0,0,0.02)]",children:"Student Name"}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 h-full flex items-center justify-center",children:"LRN"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 h-full flex items-center justify-center",children:"Grade"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 h-full flex items-center justify-center",children:"Section"}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 h-full flex items-center justify-center",children:"Avg Score"}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 h-full flex items-center justify-center",children:"Risk Level"}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 h-full flex items-center justify-center",children:"Weakest Topic"}),e.jsx("div",{className:"w-[80px] shrink-0 px-4 h-full flex items-center justify-center border-r border-transparent",children:"Action"})]}),e.jsx("div",{className:"flex flex-col w-full pb-4",children:Y.map((g,T)=>{const R=Pa(g),K=g.name.split(" "),Z=K.length>1?`${K[0][0]}${K[K.length-1][0]}`.toUpperCase():g.name.substring(0,2).toUpperCase(),re=["bg-[#be185d]","bg-[#3b82f6]","bg-[#f43f5e]","bg-[#2563eb]","bg-[#059669]","bg-[#d946ef]"],le=re[T%re.length],$=(g.avgScore??0)>=75?"text-emerald-500":(g.avgScore??0)>=60?"text-orange-500":"text-rose-500";let oe="bg-slate-50 text-slate-600 border-slate-200";const pe=(g.riskLevel||"").toLowerCase();return pe==="low"?oe="bg-emerald-50 text-emerald-600 border-emerald-200":pe==="high"?oe="bg-rose-50 text-rose-600 border-rose-200":pe==="medium"&&(oe="bg-orange-50 text-orange-600 border-orange-200"),e.jsxs("div",{className:"flex items-center w-full border-b border-slate-100 hover:bg-slate-50 transition-colors group min-h-[64px]",children:[e.jsxs("div",{className:"flex-[1.5] min-w-[240px] px-6 sticky left-0 z-10 bg-white group-hover:bg-slate-50 border-r border-slate-100 h-full flex items-center gap-4 shadow-[2px_0_4px_rgba(0,0,0,0.01)]",children:[e.jsx("div",{className:`w-8 h-8 rounded-full ${le} text-white flex items-center justify-center font-bold text-[12px] shrink-0`,children:Z}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:g.name})]}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center text-[13px] text-slate-500",children:g.lrn||"—"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Ge[R]?.grade||g.grade||"",onChange:we=>G(se=>({...se,[R]:{...se[R],grade:we.target.value}})),className:"bg-slate-100 focus:bg-white outline-none px-4 py-1.5 rounded-full text-[13px] font-medium text-slate-600 w-full transition-all border border-transparent focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 text-center"})}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Ge[R]?.section||g.section||"",onChange:we=>G(se=>({...se,[R]:{...se[R],section:we.target.value}})),className:"bg-slate-100 focus:bg-white outline-none px-4 py-1.5 rounded-full text-[13px] font-medium text-slate-600 w-full transition-all border border-transparent focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 text-center"})}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center",children:e.jsxs("span",{className:`${$} font-bold text-[14px]`,children:[g.avgScore,"%"]})}),e.jsx("div",{className:"w-[120px] shrink-0 px-4 flex justify-center",children:e.jsx("span",{className:`px-3 py-1 text-[10px] font-bold rounded uppercase border ${oe}`,children:g.riskLevel||"Unknown"})}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 flex justify-center text-[13px] text-slate-600 truncate",children:g.weakestTopic||"Foundational Skills"}),e.jsx("div",{className:"w-[80px] shrink-0 px-4 flex justify-center border-r border-transparent",children:e.jsx("button",{className:"w-8 h-8 rounded-full hover:bg-slate-200 flex items-center justify-center transition-colors",children:e.jsx(ci,{className:"w-4 h-4 text-slate-400"})})})]},R)})})]})})]})]})]})})}const Ha="ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789",Go="school.mathpulse.local";function Qo(t=10){const s=typeof globalThis<"u"&&typeof globalThis.crypto<"u"?globalThis.crypto:void 0;if(s&&typeof s.getRandomValues=="function"){const r=new Uint32Array(t);s.getRandomValues(r);let o="";for(let n=0;n{const[l,c]=m.useState(""),[d,u]=m.useState(""),[f,h]=m.useState(!1),[b,k]=m.useState(null),[j,S]=m.useState(null),[p,N]=m.useState(!1);m.useEffect(()=>{t&&(k(null),N(!1),h(!1),S(null),c((a?.email||lx(a)).trim()),u(Qo()))},[t,a]);const C=m.useMemo(()=>a?[a.grade,a.section].filter(Boolean).join(" · ")||"Unassigned section":null,[a]),z=()=>{u(Qo()),N(!1)},I=async()=>{try{const y=j?.temporaryPassword||d;if(!y)return;typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(y),N(!0),me.success("Temporary password copied. Share it with the student now — it will not be shown again."),window.setTimeout(()=>N(!1),2500)}catch(y){console.warn("Clipboard write failed:",y),me.error("Unable to copy password. Please copy it manually.")}},U=async()=>{if(!a)return;const y=l.trim();if(!cx(y)){k("Enter a valid email address before creating the account.");return}if(!d||d.length<8){k("Temporary password must be at least 8 characters.");return}if(!r){k("Missing teacher context. Please refresh and try again.");return}h(!0),k(null);try{const w=await Nm({name:a.name,lrn:a.lrn,email:y,grade:a.grade,section:a.section,classSectionId:a.classSectionId,adviserTeacherId:r,adviserTeacherName:o,schoolYear:n,temporaryPassword:d});S(w),i?.({...w,rosterId:a.rosterId}),me.success(`Account created for ${a.name}.`)}catch(w){const A=w instanceof Error?w.message:"Failed to create account.";k(A)}finally{h(!1)}},v=j?.temporaryPassword||d;return e.jsx(Et,{children:t&&a&&e.jsx(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",onClick:()=>{f||s()},children:e.jsxs(Re.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{type:"spring",damping:28,stiffness:320},onClick:y=>y.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl w-full max-w-lg overflow-hidden border border-[#dde3eb]",role:"dialog","aria-modal":"true","aria-labelledby":"create-student-account-modal-title",children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-6",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0",children:e.jsx(Ko,{size:22})}),e.jsxs("div",{children:[e.jsx("h2",{id:"create-student-account-modal-title",className:"text-[16px] font-bold text-[#0a1628]",children:j?"Account Created":"Create Student Account"}),e.jsx("p",{className:"text-[12px] text-[#5a6578] mt-0.5",children:j?"Share these credentials with the student. The password will not be shown again.":`Provision a system account for ${a.name}.`})]})]}),e.jsx("button",{type:"button",onClick:()=>{f||s()},className:"p-1.5 rounded-lg hover:bg-[#dde3eb] transition-colors","aria-label":"Close",children:e.jsx(cs,{className:"w-4 h-4 text-[#5a6578]"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-2xl p-4",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-[#64748b]",children:"Roster Row"}),e.jsx("p",{className:"text-[14px] font-semibold text-[#0a1628] mt-1",children:a.name}),e.jsxs("p",{className:"text-[12px] text-[#475569] mt-0.5",children:[a.lrn?`LRN ${a.lrn} · `:"",C]})]}),!j&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#0a1628]",children:"Email address"}),e.jsx("input",{type:"email",value:l,onChange:y=>c(y.target.value),disabled:f,className:"mt-1 w-full rounded-xl border border-[#dde3eb] bg-white px-3 py-2 text-[13px] text-[#0a1628] focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"student@school.example",autoComplete:"off",spellCheck:!1}),e.jsx("span",{className:"text-[11px] text-[#64748b] mt-1 block",children:"Auto-generated from LRN if available. The student will sign in with this address."})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#0a1628] block",children:"Temporary password"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:d,readOnly:!0,className:"flex-1 rounded-xl border border-[#dde3eb] bg-white px-3 py-2 text-[13px] font-mono tracking-wide text-[#0a1628] focus:outline-none"}),e.jsx("button",{type:"button",onClick:z,disabled:f,className:"p-2 rounded-xl border border-[#dde3eb] bg-white hover:bg-[#f1f5f9] transition-colors disabled:opacity-60","aria-label":"Regenerate temporary password",children:e.jsx(zs,{className:"w-4 h-4 text-[#475569]"})}),e.jsx("button",{type:"button",onClick:I,className:"p-2 rounded-xl border border-[#dde3eb] bg-white hover:bg-[#f1f5f9] transition-colors","aria-label":"Copy temporary password",children:p?e.jsx(Mt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(zr,{className:"w-4 h-4 text-[#475569]"})})]}),e.jsx("span",{className:"text-[11px] text-[#64748b] mt-1 block",children:"The student should change this on first sign-in. Share it once — it will not be persisted."})]}),b&&e.jsxs("div",{className:"flex items-start gap-2 rounded-xl bg-rose-50 border border-rose-200 px-3 py-2 text-[12px] text-rose-700",children:[e.jsx(lc,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsx("span",{children:b})]})]}),j&&e.jsxs("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-4 space-y-2",children:[e.jsx("p",{className:"text-[12px] font-semibold text-emerald-800",children:"Credentials"}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-white border border-emerald-100 px-3 py-2",children:[e.jsx("span",{className:"text-[12px] text-[#475569]",children:"Email"}),e.jsx("span",{className:"text-[13px] font-semibold text-[#0a1628]",children:j.email})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-white border border-emerald-100 px-3 py-2",children:[e.jsx("span",{className:"text-[12px] text-[#475569]",children:"Temporary password"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold font-mono text-[#0a1628]",children:v}),e.jsx("button",{type:"button",onClick:I,className:"p-1.5 rounded-lg border border-emerald-200 bg-white hover:bg-emerald-100 transition-colors","aria-label":"Copy temporary password",children:p?e.jsx(Mt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(zr,{className:"w-4 h-4 text-emerald-700"})})]})]}),e.jsx("p",{className:"text-[11px] text-emerald-800",children:"This password is not stored anywhere. If you close this dialog without copying, you will need to reset it from the admin tools."})]})]}),e.jsx("div",{className:"flex items-center justify-end gap-2 px-6 pb-6",children:j?e.jsx(xt,{type:"button",onClick:s,className:"bg-indigo-600 hover:bg-indigo-700 text-white text-[13px] font-semibold rounded-xl px-5 py-2",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(xt,{type:"button",variant:"ghost",onClick:s,disabled:f,className:"text-[13px] font-semibold text-[#475569] rounded-xl px-4 py-2 hover:bg-[#dde3eb]",children:"Cancel"}),e.jsx(xt,{type:"button",onClick:U,disabled:f,className:"bg-indigo-600 hover:bg-indigo-700 text-white text-[13px] font-semibold rounded-xl px-5 py-2 disabled:opacity-60",children:f?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Creating…"]}):"Create account"})]})})]})})})};function mx(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=gt({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 Rr(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?nl(t.lastActive.toDate()):"Unknown",o=t.className||s||"Imported Class",n=ls(o),i=t.grade||n.grade,l=t.section||n.section,c=gt({metadata:t.classMetadata,classSectionId:t.classSectionId||t.classroomId,className:[i,l].filter(Boolean).join(" - ")||o,grade:i,gradeLevel:t.gradeLevel,classification:t.classification,strand:t.strand,section:l,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||o,className:c.className||[i,l].filter(Boolean).join(" - ")||o,grade:i,gradeLevel:c.gradeLevel||us(i)||void 0,classification:c.classification||sa(c.gradeLevel||i)||void 0,strand:c.strand||aa(c.className,l)||void 0,section:l,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,hasRegisteredAccount:t.hasRegisteredAccount,source:t.source,accountUid:t.accountUid,email:t.email}}function ux(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=gt({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 xx(t){const s=(t.riskLevel||"Low").toLowerCase(),a=gt({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||ls(r).grade,gradeLevel:a.gradeLevel||us(a.grade||ls(r).grade)||void 0,classification:a.classification||sa(a.gradeLevel||a.grade)||void 0,strand:a.strand||aa(r,a.section||t.section)||void 0,section:a.section||ls(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 px(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function hx(t,s,a,r){const o=gt({metadata:r,classSectionId:s,className:a}),n=o.className||"Imported Class",i=o.classSectionId||"imported_class",l=Number(t.avgQuizScore||0),c=Number(t.attendance||0),d=Number(t.engagementScore||0),u=Number(t.assignmentCompletion||0),f=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",h=px(l,c,d),b=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${i}-${b}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:l,riskLevel:h,weakestTopic:f,classroomId:i,className:n,grade:o.grade||ls(n).grade,gradeLevel:o.gradeLevel||us(o.grade||ls(n).grade)||void 0,classification:o.classification||sa(o.gradeLevel||o.grade)||void 0,strand:o.strand||aa(n,o.section)||void 0,section:o.section||ls(n).section,classSectionId:i,classMetadata:o,managerId:o.managerId||void 0,managerName:o.managerName||void 0,lastActive:"Recently imported",struggles:[f],engagementScore:d,attendance:c,assignmentCompletion:u}}function nl(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 o=Math.floor(r/24);return`${o} day${o>1?"s":""} ago`}function at(t){return(t||"").trim().toLowerCase()}function Uo(t){const s=at(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function Vo(t,s){const a=new Map;return t.forEach(r=>{a.set(Uo(r),r)}),s.forEach(r=>{const o=Uo(r),n=a.get(o);if(!n){a.set(o,r);return}const i=Math.max(n.atRiskCount||0,r.atRiskCount||0),l=Math.max(n.studentCount||0,r.studentCount||0),c=r.avgScore>0?r.avgScore:n.avgScore,d=i>=5?"high":i>=2?"medium":"low",u=gt({metadata:n.classMetadata,classSectionId:n.classSectionId||r.classSectionId,className:n.name||r.name,grade:n.classMetadata?.grade||r.classMetadata?.grade,gradeLevel:n.classMetadata?.gradeLevel||r.classMetadata?.gradeLevel,classification:n.classMetadata?.classification||r.classMetadata?.classification,strand:n.classMetadata?.strand||r.classMetadata?.strand,section:n.classMetadata?.section||r.classMetadata?.section,schoolYear:n.classMetadata?.schoolYear||r.classMetadata?.schoolYear,ownerTeacherId:n.classMetadata?.ownerTeacherId||r.classMetadata?.ownerTeacherId,ownerTeacherName:n.classMetadata?.ownerTeacherName||r.classMetadata?.ownerTeacherName,adviserTeacherId:n.classMetadata?.adviserTeacherId||r.classMetadata?.adviserTeacherId,adviserTeacherName:n.classMetadata?.adviserTeacherName||r.classMetadata?.adviserTeacherName,managerId:n.classMetadata?.managerId||r.classMetadata?.managerId,managerName:n.classMetadata?.managerName||r.classMetadata?.managerName});a.set(o,{...n,classSectionId:u.classSectionId||n.classSectionId||r.classSectionId,name:u.className||n.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:n.schedule||r.schedule,studentCount:l,atRiskCount:i,avgScore:c,riskLevel:d})}),Array.from(a.values())}function nr(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=at(t.classSectionId)||at(t.classroomId),o=(t.id||"").trim().toLowerCase();return r&&o?`${r}|id:${o}`:`${r}|anonymous`}function Ur(t){const s=at(t.classSectionId)||at(t.classroomId),a=(t.lrn||"").trim().toLowerCase(),r=(t.id||"").trim().toLowerCase(),o=t.name.trim().toLowerCase().replace(/\s+/g,"_");return s&&a?`${s}|lrn:${a}`:s&&r?`${s}|id:${r}`:a?`lrn:${a}`:r&&o?`id:${r}|name:${o}`:r?`id:${r}`:s&&o?`${s}|name:${o}`:`name:${o||"unknown"}`}function Wo(t,s){const a=new Map;return t.forEach(r=>{a.set(nr(r),r)}),s.forEach(r=>{const o=nr(r),n=a.get(o);if(!n){a.set(o,r);return}const i=[n.riskLevel,r.riskLevel].includes("high")?"high":[n.riskLevel,r.riskLevel].includes("medium")?"medium":"low",l=gt({metadata:n.classMetadata,classSectionId:n.classSectionId||r.classSectionId,className:n.className||r.className,grade:n.grade||r.grade,gradeLevel:n.gradeLevel||r.gradeLevel,classification:n.classification||r.classification,strand:n.strand||r.strand,section:n.section||r.section,managerId:n.managerId||r.managerId,managerName:n.managerName||r.managerName});a.set(o,{...n,lrn:n.lrn||r.lrn,classSectionId:l.classSectionId||n.classSectionId||r.classSectionId,classroomId:n.classroomId||r.classroomId,className:l.className||n.className||r.className,grade:l.grade||n.grade||r.grade,gradeLevel:l.gradeLevel||n.gradeLevel||r.gradeLevel,classification:l.classification||n.classification||r.classification,strand:l.strand||n.strand||r.strand,section:l.section||n.section||r.section,managerId:l.managerId||n.managerId||r.managerId,managerName:l.managerName||n.managerName||r.managerName,classMetadata:l,avgScore:r.avgScore>0?r.avgScore:n.avgScore,attendance:r.attendance>0?r.attendance:n.attendance,engagementScore:r.engagementScore>0?r.engagementScore:n.engagementScore,assignmentCompletion:r.assignmentCompletion>0?r.assignmentCompletion:n.assignmentCompletion,weakestTopic:n.weakestTopic&&n.weakestTopic!=="N/A"?n.weakestTopic:r.weakestTopic,riskLevel:i,struggles:n.struggles.length>0?n.struggles:r.struggles,hasRegisteredAccount:n.hasRegisteredAccount===!0||r.hasRegisteredAccount===!0?!0:n.hasRegisteredAccount??r.hasRegisteredAccount,source:n.source==="registered"&&r.source==="import"||n.source==="import"&&r.source==="registered"||n.source==="both"||r.source==="both"?"both":n.source||r.source,accountUid:n.accountUid||r.accountUid,email:n.email||r.email})}),Array.from(a.values())}const bp=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:o}=ds(),[n,i]=m.useState("dashboard"),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(!1),[b,k]=m.useState(!1),[j,S]=m.useState(!1),[p,N]=m.useState(!1),[C,z]=m.useState(!1),I=["streak_reminder","daily_checkin","streak_milestone","achievement_unlocked","level_up","xp_earned","quiz_result"],{notifications:U}=ei(),v=U.filter(_=>!_.isRead&&!I.includes(_.type)).length,[y,w]=m.useState(null),[A,B]=m.useState(null),[E,F]=m.useState(!1),[X,J]=m.useState(!1),[ce,ne]=m.useState(!1),[xe,he]=m.useState(!1),[H,q]=m.useState([]),[M,Y]=m.useState([]),[ae,$e]=m.useState([]),[Me,Ge]=m.useState(""),[G,te]=m.useState(!0),[g,T]=m.useState(!1),[R,K]=m.useState(0),[Z,re]=m.useState([]),[le,$]=m.useState(!1),[oe,pe]=m.useState(null),[we,se]=m.useState(null),fe=o?.name||"Teacher",et=m.useRef(new Map);m.useEffect(()=>{const _=()=>k(window.innerWidth<1024);return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),m.useEffect(()=>{if(!r)return;const _=r.uid;let ee=!0,ze;return(async()=>{te(!0);try{const Qe=await Wi(_);let je=Qe.map(mx);const ft=await Sm(_).catch(()=>[]),ot=new Map;ft.forEach(L=>{const V=at(L.classSectionId);V&&ot.set(V,L)}),je=je.map(L=>{const V=ot.get(at(L.classSectionId));if(!V)return L;const ke=gt({metadata:L.classMetadata,classSectionId:V.classSectionId||L.classSectionId,className:V.className||L.name,grade:V.grade||L.classMetadata?.grade,gradeLevel:V.gradeLevel||L.classMetadata?.gradeLevel,classification:V.classification||L.classMetadata?.classification,strand:V.strand||L.classMetadata?.strand,section:V.section||L.classMetadata?.section,schoolYear:V.schoolYear||L.classMetadata?.schoolYear,ownerTeacherId:V.ownerTeacherId||L.classMetadata?.ownerTeacherId,ownerTeacherName:V.ownerTeacherName||L.classMetadata?.ownerTeacherName,managerId:V.managerId||L.classMetadata?.managerId,managerName:V.managerName||L.classMetadata?.managerName});return{...L,name:ke.className||L.name,classSectionId:ke.classSectionId||L.classSectionId,classMetadata:ke,gradeLevel:ke.gradeLevel||L.gradeLevel,classification:ke.classification||L.classification,strand:ke.strand||L.strand,managerId:ke.managerId||L.managerId,managerName:ke.managerName||L.managerName}});const Ce=new Map,ps=new Map;Qe.forEach(L=>{const V=gt({metadata:L.classMetadata,classSectionId:L.classSectionId,className:L.name,grade:L.grade,gradeLevel:L.gradeLevel,classification:L.classification,strand:L.strand,section:L.section,schoolYear:L.schoolYear,ownerTeacherId:L.ownerTeacherId||L.teacherId,ownerTeacherName:L.ownerTeacherName,adviserTeacherId:L.adviserTeacherId||L.teacherId,adviserTeacherName:L.adviserTeacherName,managerId:L.managerId,managerName:L.managerName});Ce.set(L.id,V.className||L.name),ps.set(L.id,V);const ke=at(L.classSectionId);if(ke){const _e=ot.get(ke),Bt=gt({metadata:V,classSectionId:_e?.classSectionId||ke,className:_e?.className||V.className,grade:_e?.grade||V.grade,gradeLevel:_e?.gradeLevel||V.gradeLevel,classification:_e?.classification||V.classification,strand:_e?.strand||V.strand,section:_e?.section||V.section,schoolYear:_e?.schoolYear||V.schoolYear,ownerTeacherId:_e?.ownerTeacherId||V.ownerTeacherId,ownerTeacherName:_e?.ownerTeacherName||V.ownerTeacherName,managerId:_e?.managerId||V.managerId,managerName:_e?.managerName||V.managerName});Ce.set(ke,Bt.className||L.name),ps.set(ke,Bt)}});const Yt=L=>{const V=at(L.classSectionId||L.classroomId);if(!V)return L;const ke=ps.get(V);if(!ke)return L;const _e=gt({metadata:ke,classSectionId:L.classSectionId||ke.classSectionId,className:L.className||ke.className,grade:L.grade||ke.grade,gradeLevel:L.gradeLevel||ke.gradeLevel,classification:L.classification||ke.classification,strand:L.strand||ke.strand,section:L.section||ke.section,managerId:L.managerId||ke.managerId,managerName:L.managerName||ke.managerName});return{...L,className:_e.className||L.className,grade:_e.grade||L.grade,gradeLevel:_e.gradeLevel||L.gradeLevel,classification:_e.classification||L.classification,strand:_e.strand||L.strand,section:_e.section||L.section,classSectionId:_e.classSectionId||L.classSectionId,classMetadata:_e,managerId:_e.managerId||L.managerId,managerName:_e.managerName||L.managerName}},_s=(L,V,ke)=>Ce.get(L)||(V?Ce.get(V):void 0)||ke||"Unknown",za=Array.from(new Set([...ft.map(L=>L.classSectionId),...Qe.map(L=>L.classSectionId).filter(Boolean),...je.map(L=>L.classSectionId).filter(Boolean)].map(L=>(L||"").trim()).filter(L=>!!L))),[Kt,ra]=await Promise.all([cn(_).catch(L=>(console.warn("[TeacherDashboard] managed-student fetch failed:",L),[])),bm(_,za).catch(L=>(console.warn("[TeacherDashboard] registered-student fetch failed:",L),[]))]);let na=ra;if(ra.length===0&&Kt.length===0)try{const{collection:L,query:V,where:ke,getDocs:_e}=await _r(async()=>{const{collection:It,query:Pe,where:da,getDocs:ma}=await import("./vendor-firebase-firestore-CNv3xXal.js");return{collection:It,query:Pe,where:da,getDocs:ma}},__vite__mapDeps([2,3])),{db:Bt}=await _r(async()=>{const{db:It}=await import("./index-dPnhhJ9w.js").then(Pe=>Pe.b5);return{db:It}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),Ee=V(L(Bt,"users"),ke("role","==","student"));na=(await _e(Ee)).docs.map(It=>{const Pe=It.data();return{uid:It.id,name:String(Pe.name||Pe.displayName||"").trim()||"Student",email:String(Pe.email||"").trim(),lrn:Pe.lrn?String(Pe.lrn).trim():void 0,photo:Pe.photo?String(Pe.photo).trim():Pe.photoURL?String(Pe.photoURL).trim():void 0,grade:Pe.grade?String(Pe.grade).trim():void 0,section:Pe.section?String(Pe.section).trim():void 0,classSectionId:Pe.classSectionId?String(Pe.classSectionId).trim():void 0,adviserTeacherId:Pe.adviserTeacherId?String(Pe.adviserTeacherId).trim():void 0,role:"student",createdAt:Pe.createdAt||void 0}}).filter(It=>It.name!=="Student"||It.email)}catch(L){console.warn("[TeacherDashboard] fallback all-students fetch failed:",L)}const hs=new Map,oa=new Map,ia=new Map;Kt.forEach(L=>{hs.set(L.id,L),L.lrn&&oa.set(L.lrn.trim().toLowerCase(),L);const V=wo(L.name),ke=at(L.classSectionId||L.classroomId);V&&ia.set(`${V}|${ke}`,L)});const Hs=new Set,ur=na.map(L=>{const V=vm(L),ke=(L.lrn||"").trim().toLowerCase(),_e=wo(L.name),Bt=at(L.classSectionId);let Ee;if(hs.has(L.uid))Ee=hs.get(L.uid);else if(ke&&oa.has(ke))Ee=oa.get(ke);else if(_e){const Pe=`${_e}|${Bt}`;Ee=ia.get(Pe)}if(Ee){Hs.add(Ee.id);const Pe={...V,id:L.uid,accountUid:L.uid,email:V.email||Ee.email,lrn:V.lrn||Ee.lrn,name:V.name||Ee.name,avatar:V.avatar||Ee.avatar,riskLevel:Ee.riskLevel||V.riskLevel,avgQuizScore:Ee.avgQuizScore||V.avgQuizScore,engagementScore:Ee.engagementScore||V.engagementScore,attendance:Ee.attendance||V.attendance,assignmentCompletion:Ee.assignmentCompletion||V.assignmentCompletion,weakestTopic:Ee.weakestTopic||V.weakestTopic,struggles:Ee.struggles||V.struggles,lastActive:Ee.lastActive||V.lastActive,wri:Ee.wri??null,riskStatus:Ee.riskStatus??null,riskUpdatedAt:Ee.riskUpdatedAt??null,diagnosticScore:Ee.diagnosticScore??null,externalGradesAvg:Ee.externalGradesAvg??null,systemPerformanceAvg:Ee.systemPerformanceAvg??null,riskHistory:Ee.riskHistory,grade:V.grade||Ee.grade,gradeLevel:V.gradeLevel||Ee.gradeLevel,section:V.section||Ee.section,classSectionId:V.classSectionId||Ee.classSectionId,classroomId:V.classroomId||Ee.classroomId,classMetadata:Ee.classMetadata||V.classMetadata,hasRegisteredAccount:!0,source:"both"},da=at(Pe.classSectionId||Pe.classroomId),ma=_s(Pe.classroomId||"",da,Pe.className);return Yt(Rr(Pe,ma))}const Gs=at(V.classSectionId||V.classroomId),It=_s(V.classroomId||"",Gs,V.className);return Yt(Rr(V,It))}),xr=Kt.filter(L=>!Hs.has(L.id)).map(L=>{const V={...L,hasRegisteredAccount:!1,source:"import"},ke=at(V.classSectionId||V.classroomId),_e=_s(V.classroomId,ke,V.className);return Yt(Rr(V,_e))}),la=[...ur,...xr];if(!ee)return;q(L=>je.length===0&&L.length>0?L:je),Y(L=>la.length===0&&L.length>0?L:la),nt.getImportedClassOverview({limit:3e3,forceRefresh:R>0}).then(L=>{ee&&(L.warnings.length>0&&console.warn("Imported class overview warnings:",L.warnings.join(" ")),q(V=>Vo(V,L.classrooms.map(ux))),Y(V=>{if(V.length===0)return V;const ke=L.students.map(xx),_e=new Set;V.forEach(Ee=>_e.add(nr(Ee)));const Bt=ke.filter(Ee=>_e.has(nr(Ee)));return Bt.length===0?V:Wo(V,Bt)}))}).catch(L=>{console.warn("Imported class overview merge unavailable:",L)});const ca=Qe.map(L=>L.id);ca.length>0&&(ze=Cm(ca,L=>{ee&&$e(L.map(V=>({id:V.id,student:V.studentName,action:V.action,topic:V.topic,time:nl(V.timestamp.toDate()),type:V.type})))}))}catch(Qe){console.error("Failed to load teacher data:",Qe),me.error("Failed to load dashboard data")}finally{te(!1)}})(),()=>{ee=!1,ze&&ze()}},[r,R]),m.useEffect(()=>{if(!r)return;let _=!0;return km("",80).then(ee=>{_&&re(ee)}).catch(ee=>{console.warn("Failed to load teacher directory options:",ee)}),()=>{_=!1}},[r]),m.useEffect(()=>{if(M.length===0)return;(async()=>{if(M.length===0){Ge("");return}T(!0);try{const ee=M.map(Ne=>({name:Ne.name,engagementScore:Ne.engagementScore,avgQuizScore:Ne.avgScore,attendance:Ne.attendance,riskLevel:Ne.riskLevel})),ze=await nt.getDailyInsight({students:ee});Ge(ze.insight)}catch{Ge(`${M.filter(ee=>ee.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{T(!1)}})()},[M]);const Fe=H.reduce((_,ee)=>_+ee.studentCount,0),Ke=H.reduce((_,ee)=>_+ee.atRiskCount,0),rt=H.length>0?Math.round(H.reduce((_,ee)=>_+ee.avgScore,0)/H.length):0,Rt=[{name:"High Risk",value:M.filter(_=>_.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:M.filter(_=>_.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:M.filter(_=>_.riskLevel==="low").length,color:"#75D06A"}],St={};M.forEach(_=>{_.weakestTopic&&_.weakestTopic!=="N/A"&&(St[_.weakestTopic]||(St[_.weakestTopic]={total:0,sum:0}),St[_.weakestTopic].total+=1,St[_.weakestTopic].sum+=_.avgScore)});const Ft=Object.entries(St).map(([_,ee])=>({topic:_,score:Math.round(ee.sum/ee.total)})).sort((_,ee)=>_.score-ee.score).slice(0,6),ss=_=>{w(_),i("analytics")},P=_=>{B(_),i("intervention")},Ae=()=>{B(null),i("analytics")},Ye=()=>{w(null),B(null),i("dashboard")},vt=async(_,ee)=>{if(!r){me.error("Unable to assign manager: teacher context is missing.");return}const ze=ls(_.classMetadata?.className||_.name),Ne=gt({metadata:_.classMetadata,classSectionId:_.classSectionId,className:_.name,grade:_.classMetadata?.grade||ze.grade,gradeLevel:_.classMetadata?.gradeLevel,classification:_.classMetadata?.classification,strand:_.classMetadata?.strand,section:_.classMetadata?.section||ze.section,schoolYear:_.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:_.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:_.classMetadata?.ownerTeacherName||fe,adviserTeacherId:_.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:_.classMetadata?.adviserTeacherName||fe,managerId:ee.uid,managerName:ee.name}),Qe=Ne.classSectionId||Lt(Ne.grade||ze.grade,Ne.section||ze.section);if(!Qe){me.error("Unable to assign manager: missing class section ID.");return}$(!0);try{await qi({classSectionId:Qe,className:Ne.className||_.name,grade:Ne.grade||ze.grade,gradeLevel:Ne.gradeLevel||us(Ne.grade||ze.grade)||Ne.grade||ze.grade,classification:Ne.classification||sa(Ne.gradeLevel||Ne.grade)||void 0,strand:Ne.strand||aa(Ne.className,Ne.section)||void 0,section:Ne.section||ze.section,schoolYear:Ne.schoolYear||String(new Date().getFullYear()),ownerTeacherId:Ne.ownerTeacherId||r.uid,ownerTeacherName:Ne.ownerTeacherName||fe,managerId:ee.uid,managerName:ee.name});const je=gt({metadata:Ne,classSectionId:Qe,managerId:ee.uid,managerName:ee.name}),ft=at(Qe);q(ot=>ot.map(Ce=>at(Ce.classSectionId)!==ft?Ce:{...Ce,name:je.className||Ce.name,classSectionId:je.classSectionId||Ce.classSectionId,classMetadata:je,gradeLevel:je.gradeLevel||Ce.gradeLevel,classification:je.classification||Ce.classification,strand:je.strand||Ce.strand,managerId:ee.uid,managerName:ee.name})),Y(ot=>ot.map(Ce=>{if(at(Ce.classSectionId||Ce.classroomId)!==ft)return Ce;const Yt=gt({metadata:Ce.classMetadata,classSectionId:je.classSectionId||Ce.classSectionId,className:Ce.className||je.className,grade:Ce.grade||je.grade,gradeLevel:Ce.gradeLevel||je.gradeLevel,classification:Ce.classification||je.classification,strand:Ce.strand||je.strand,section:Ce.section||je.section,managerId:ee.uid,managerName:ee.name});return{...Ce,classMetadata:Yt,gradeLevel:Yt.gradeLevel||Ce.gradeLevel,classification:Yt.classification||Ce.classification,strand:Yt.strand||Ce.strand,managerId:ee.uid,managerName:ee.name}})),w(ot=>!ot||at(ot.classSectionId)!==ft?ot:{...ot,classMetadata:je,managerId:ee.uid,managerName:ee.name,gradeLevel:je.gradeLevel||ot.gradeLevel,classification:je.classification||ot.classification,strand:je.strand||ot.strand}),me.success(`Assigned ${ee.name} as section manager.`)}catch(je){console.error("Failed to assign class manager:",je),me.error(je instanceof Error?je.message:"Failed to assign class manager")}finally{$(!1)}},xs=m.useCallback(_=>{pe({rosterId:_.id,name:_.name,lrn:_.lrn,email:_.email,grade:_.grade,section:_.section,classSectionId:_.classSectionId})},[]),Ot=m.useCallback(_=>{Y(ee=>ee.map(ze=>ze.id===_.rosterId?{...ze,hasRegisteredAccount:!0,source:"both",accountUid:_.uid,email:_.email||ze.email}:ze)),K(ee=>ee+1)},[]),Wt=m.useCallback(async(_,ee)=>{if(!r){me.error("Cannot reassign section without an authenticated teacher.");return}const ze=r.uid,Ne=(ee.classSectionId||"").trim();if(!Ne){me.error("Pick a target section first.");return}se(_.id);try{await wm({studentId:_.accountUid||_.id,isRegisteredAccount:!!_.hasRegisteredAccount,newClassSectionId:Ne,newGrade:ee.grade,newSection:ee.section,previousClassSectionId:_.classSectionId,teacherId:ze,teacherName:fe,schoolYear:_.classMetadata?.schoolYear||String(new Date().getFullYear())}),Y(Qe=>Qe.map(je=>{if(je.id!==_.id)return je;const ft=gt({metadata:je.classMetadata,classSectionId:Ne,className:je.className,grade:ee.grade,section:ee.section});return{...je,grade:ee.grade,section:ee.section,classSectionId:Ne,classroomId:Ne,classMetadata:ft}})),me.success(`Moved ${_.name} to ${ee.grade} - ${ee.section}.`)}catch(Qe){console.error("Section reassignment failed:",Qe),me.error(Qe instanceof Error?Qe.message:"Failed to reassign section.")}finally{se(null)}},[r,fe]);m.useEffect(()=>{const _=()=>{const ee=window.innerWidth<1024;k(ee),ee?c(!1):h(!1)};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),m.useEffect(()=>{b&&h(!1)},[n,b]);const qt=_=>{i(_),w(null),B(null)},Rs=m.useMemo(()=>{if(!y)return;if(y.classMetadata?.classSectionId)return y.classMetadata.classSectionId||void 0;if(y.classSectionId)return y.classSectionId;const _=ls(y.classMetadata?.className||y.name);return Lt(_.grade,_.section)||void 0},[y]),st=m.useMemo(()=>y||null,[y]),Aa=m.useMemo(()=>{if(!st)return;const _=H.findIndex(ee=>ee.id===st.id);return ar[Math.max(0,_)%ar.length]},[st,H]),_t=m.useMemo(()=>{if(!st)return M;const _=(st.id||"").trim().toLowerCase(),ee=at(st.classSectionId),ze=(st.name||"").trim().toLowerCase();return M.filter(Ne=>{const Qe=at(Ne.classroomId),je=at(Ne.classSectionId),ft=(Ne.className||"").trim().toLowerCase();return ee&&(je===ee||Qe===ee)||_&&(Qe===_||je===_)||ze&&ft===ze})},[st,M]);return G?e.jsx(yl,{message:"Loading dashboard..."}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[b&&f&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>h(!1)}),e.jsxs(Re.aside,{initial:!1,animate:{width:b?280:l&&!d?80:280,x:b?f?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!b&&l&&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 ${l&&!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"})}),(!l||d)&&e.jsx("div",{children:e.jsx("h1",{className:"text-base font-semibold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),!b&&(!l||d)&&e.jsx(Re.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>c(!l),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":l?"Expand sidebar":"Collapse sidebar",children:l?e.jsx(ys,{size:20}):e.jsx(Ss,{size:20})}),b&&e.jsx("button",{onClick:()=>h(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(cs,{size:20})})]}),e.jsxs("nav",{className:"flex-1 space-y-5",children:[e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Overview"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ns,{icon:zl,label:"Dashboard",active:n==="dashboard",collapsed:l&&!d,onClick:Ye,forceExpanded:b}),e.jsx(Ns,{icon:Ds,label:"Class Analytics",active:n==="analytics"||n==="intervention",collapsed:l&&!d,onClick:()=>qt("analytics"),forceExpanded:b})]})]}),e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Students"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ns,{icon:vs,label:"Topic Mastery",active:n==="topic_mastery",collapsed:l&&!d,onClick:()=>qt("topic_mastery"),forceExpanded:b}),e.jsx(Ns,{icon:os,label:"Competency",active:n==="competency",collapsed:l&&!d,onClick:()=>qt("competency"),forceExpanded:b})]})]}),e.jsxs("div",{children:[l&&!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-semibold text-[#5a6578] uppercase tracking-widest",children:"Tools"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ns,{icon:Ll,label:"Data Import",active:n==="import",collapsed:l&&!d,onClick:()=>i("import"),forceExpanded:b}),e.jsx(Ns,{icon:ii,label:"AI Quiz Maker",active:n==="quiz_maker",collapsed:l&&!d,onClick:()=>i("quiz_maker"),forceExpanded:b}),e.jsx(Ns,{icon:Gt,label:"Question Bank",active:n==="question_bank",collapsed:l&&!d,onClick:()=>i("question_bank"),forceExpanded:b}),e.jsx(Ns,{icon:Ya,label:"Calendar",active:n==="calendar",collapsed:l&&!d,onClick:()=>i("calendar"),forceExpanded:b})]})]})]}),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-semibold border border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628] transition-all duration-200 whitespace-nowrap ${l&&!d?"justify-center":""}`,onClick:a,title:l&&!d?"Settings":"",children:[e.jsx(Dl,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!l||d)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]}),e.jsx("div",{className:"text-[#5a6578]",children:e.jsx($l,{onClick:()=>S(!0),collapsed:l&&!d})})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden bg-gradient-to-br from-[#eef2ff] via-[#f5f3ff] to-[#fff7ed]",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[["dashboard","analytics","intervention","competency","topic_mastery","calendar","notifications","question_bank","import","quiz_maker"].includes(n)&&e.jsx("header",{className:"bg-transparent border-b border-[#e2e8f0]/40 px-[24px] xl:px-[32px] pt-[24px] pb-[16px] flex-shrink-0 z-30",children:e.jsxs("div",{className:"flex flex-row items-center justify-between gap-2 mb-0",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[b&&e.jsx("button",{onClick:()=>h(!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(Sl,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg sm:text-[26px] font-bold text-[#1e293b] tracking-tight leading-tight truncate",children:[n==="dashboard"&&"Teacher Dashboard",n==="analytics"&&"Class Analytics",n==="intervention"&&"Intervention Center",n==="competency"&&"Student Competency",n==="topic_mastery"&&"Topic Mastery",n==="calendar"&&"Academic Calendar",n==="notifications"&&"Notifications",n==="question_bank"&&"Question Bank",n==="import"&&"Data Import",n==="quiz_maker"&&"AI Quiz Maker"]}),e.jsxs("p",{className:"text-[13px] text-[#64748b] mt-1",children:[n==="dashboard"&&`Welcome back, ${fe}`,n==="analytics"&&"Analyze performance and risk across your classes.",n==="intervention"&&"Identify and support students who need immediate help.",n==="competency"&&"Track individual student progress against learning goals.",n==="topic_mastery"&&"Overview of student mastery levels across different math topics.",n==="calendar"&&"Manage your schedules and academic events.",n==="notifications"&&"Stay updated with student activity and system alerts.",n==="question_bank"&&"Manage and create math questions for your quizzes.",n==="import"&&"Upload class records and materials to power AI analytics.",n==="quiz_maker"&&"Create AI-powered quizzes based on your curriculum."]})]}),n==="dashboard"&&e.jsxs("div",{className:"hidden xl:flex items-center gap-2 ml-4 mt-1",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(os,{size:13,className:"text-[#9956DE]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#9956DE]",children:[Fe," 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(Xs,{size:13,className:"text-[#F08386]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#C65E63]",children:[Ke," 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(Ta,{size:13,className:"text-[#75D06A]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#4D9F46]",children:[rt,"% avg"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:()=>{J(!0),F(!0)},className:"relative w-10 h-10 flex items-center justify-center bg-[#eef2ff]/80 hover:bg-[#e0e7ff] rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#a5b4fc]/60 text-[#4f46e5] hover:border-[#818cf8] transition-colors cursor-pointer hover:scale-[1.02]","aria-label":"View AI Insight",children:[e.jsx($s,{size:18}),!E&&Me&&e.jsx("div",{className:"absolute top-2.5 right-2.5 w-2 h-2 bg-rose-500 rounded-full border border-white animate-pulse"})]}),e.jsx("span",{className:"absolute -bottom-8 left-1/2 -translate-x-1/2 text-[10px] bg-[#1e293b] text-white px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-50 pointer-events-none",children:"AI Insight"})]}),b&&n==="dashboard"&&e.jsx("button",{onClick:()=>he(_=>!_),className:`relative w-10 h-10 flex items-center justify-center rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border transition-colors cursor-pointer hover:scale-[1.02] ${xe?"bg-[#818cf8] border-[#6366f1] text-white":"bg-white/60 hover:bg-white/80 border-white/50 text-[#64748b] hover:text-[#1e293b]"}`,"aria-label":xe?"Close calendar panel":"Open calendar panel",title:xe?"Close calendar":"View calendar",children:e.jsx(Ya,{size:18})}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ne(!ce),className:"relative w-10 h-10 flex items-center justify-center bg-white/60 hover:bg-white/80 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50 text-[#64748b] hover:text-[#1e293b] transition-colors cursor-pointer hover:scale-[1.02]","aria-label":"View notifications",title:"Notifications",children:[e.jsx(Ja,{size:18}),v>0&&e.jsx("span",{className:"absolute top-2.5 right-2.5 w-2 h-2 bg-rose-500 rounded-full border border-white"})]}),e.jsx(Ml,{isOpen:ce,onClose:()=>ne(!1),onViewAll:()=>i("notifications")})]}),n!=="dashboard"&&e.jsxs("div",{onClick:s,className:"flex items-center gap-2 bg-white/60 px-4 py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50 cursor-pointer hover:bg-white/80 transition-colors h-10 hover:scale-[1.02]",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-indigo-100 overflow-hidden shrink-0",children:e.jsx("img",{src:o?.photo||`https://ui-avatars.com/api/?name=${encodeURIComponent(fe)}&background=e0e7ff&color=4f46e5`,alt:"Profile",className:"w-full h-full object-cover"})}),e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:fe})]})]})]})}),e.jsx("main",{className:`flex-1 flex flex-col ${n==="intervention"||n==="analytics"?"overflow-hidden":"overflow-y-auto"}`,children:e.jsxs(Et,{mode:"wait",children:[n==="dashboard"&&e.jsx(gx,{classes:H,liveActivity:ae,onViewClass:ss,onViewAllClasses:()=>i("analytics"),onViewActivityStudent:_=>{const ee=M.find(ze=>ze.name===_);ee&&P(ee)},dailyInsight:Me,insightLoading:g,isInsightDismissed:E,onDismissInsight:()=>F(!0),onOpenInsightModal:()=>{J(!0),F(!0)},totalStudents:Fe,totalAtRisk:Ke,avgPerformance:rt,onCreateClass:()=>N(!0)}),n==="analytics"&&st&&e.jsx(wx,{selectedClass:st,students:_t,allClasses:H,riskDistribution:Rt,topicPerformance:Ft,onViewStudent:P,onCreateAccount:xs,onReassignSection:Wt,reassignBusyId:we,onBack:()=>w(null),teacherOptions:Z,managerUpdating:le,onAssignManager:_=>vt(st,_),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,classColor:Aa,insightDismissed:E,onOpenInsightModal:()=>J(!0),onAddStudents:()=>z(!0)}),n==="analytics"&&!st&&H.length>0&&e.jsx(Ao,{classes:H,onSelectClass:ss,onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:E,onOpenInsightModal:()=>J(!0),onCreateClass:()=>N(!0)}),n==="analytics"&&!st&&H.length===0&&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(Ds,{size:24})}),e.jsx("h2",{className:"text-2xl font-display font-semibold text-foreground mb-2",children:"Class Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed mb-4",children:"No classes available yet. Create a class or import class records to unlock analytics views."}),e.jsxs(xt,{onClick:()=>N(!0),className:"bg-[#9956DE] hover:bg-[#7c3aed] text-white",children:[e.jsx(Js,{size:16,className:"mr-1.5"}),"Create Class"]})]})}),n==="intervention"&&A&&e.jsx(Nx,{student:A,teacherId:r?.uid||"",teacherName:fe,initialCache:et.current.get(A.id),onCacheUpdate:(_,ee)=>et.current.set(_,ee),onStudentUpdated:_=>{const ee=A?Ur(A):null;B(_),Y(ze=>ze.map(Ne=>{const Qe=Ur(Ne),je=ee?Qe===ee:!1,ft=Ne.id===_.id&&at(Ne.classSectionId)===at(_.classSectionId);return je||ft?_:Ne}))},onBack:Ae,onNavigateToQuizMaker:_=>{i("quiz_maker"),_&&sessionStorage.setItem("quizMakerInitialTab",_)}}),n==="topic_mastery"&&e.jsx(Qm,{classSectionId:Rs,onOpenNotifications:()=>i("notifications"),onOpenProfile:s}),n==="competency"&&st&&e.jsx(qm,{classSectionId:Rs,className:y?.name,fallbackStudents:M,onBack:()=>w(null),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:E,onOpenInsightModal:()=>J(!0)}),n==="competency"&&!st&&H.length>0&&e.jsx(Ao,{classes:H,onSelectClass:_=>w(_),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:E,onOpenInsightModal:()=>J(!0),viewType:"competency"}),n==="competency"&&!st&&H.length===0&&e.jsx(fx,{icon:os,title:"Student Competency",description:"No classes available yet. Import class records to view competency breakdowns."}),n==="import"&&e.jsx(ix,{classSectionId:Rs,className:y?.name,classMetadata:y?.classMetadata,students:M,teacherId:r?.uid||"",teacherName:fe,onStudentsUpdated:_=>Y(_),onBackToClasses:()=>i("dashboard"),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{J(!0),F(!0)},userPhoto:o?.photo,onImportedClassRecords:_=>{const ee=_.students.map(Ce=>hx(Ce,_.classSectionId,_.className,_.classMetadata)),ze=gt({metadata:_.classMetadata,classSectionId:_.classSectionId,className:_.className}),Ne=ze.classSectionId||"imported_class",Qe=ze.className||"Imported Class",je=ee.filter(Ce=>Ce.riskLevel==="high").length,ft=ee.length>0?Math.round(ee.reduce((Ce,ps)=>Ce+ps.avgScore,0)/ee.length):0,ot={id:Ne,name:Qe,classSectionId:Ne,classMetadata:{...ze,classSectionId:Ne,className:Qe},schedule:"Mon-Fri",studentCount:ee.length,avgScore:ft,atRiskCount:je,riskLevel:je>=5?"high":je>=2?"medium":"low"};Y(Ce=>Wo(Ce,ee)),q(Ce=>Vo(Ce,[ot]))},onDataChanged:()=>K(_=>_+1)}),n==="notifications"&&e.jsx(Km,{liveActivity:ae,atRiskStudents:M.filter(_=>_.riskLevel==="high").map(_=>({name:_.name,riskLevel:_.riskLevel,weakestTopic:_.weakestTopic})),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{J(!0),F(!0)},userPhoto:o?.photo,teacherName:fe}),n==="calendar"&&e.jsx(du,{classes:H,teacherId:r?.uid}),n==="quiz_maker"&&e.jsx(Yi,{onBack:()=>{const _=sessionStorage.getItem("quizMakerReturnTo");sessionStorage.removeItem("quizMakerReturnTo"),sessionStorage.removeItem("quizMakerInitialTab"),i(_==="intervention"?"intervention":"dashboard")},onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{J(!0),F(!0)},userPhoto:o?.photo,teacherName:fe}),n==="question_bank"&&e.jsx(Hm,{onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{J(!0),F(!0)},userPhoto:o?.photo,teacherName:fe})]})})]}),n==="dashboard"&&!b&&e.jsx(Yo,{onViewCalendar:()=>i("calendar"),onOpenProfile:s,userProfile:o,teacherName:fe,liveActivity:ae})]}),e.jsx(Et,{children:b&&n==="dashboard"&&xe&&e.jsxs(e.Fragment,{children:[e.jsx(Re.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-40 bg-slate-900/40 backdrop-blur-[2px]","aria-label":"Close calendar panel",onClick:()=>he(!1)},"cal-backdrop"),e.jsx(Re.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:320,damping:32},className:"fixed top-0 right-0 bottom-0 z-50 w-[300px] max-w-[85vw] shadow-2xl",children:e.jsx(Yo,{onViewCalendar:()=>{i("calendar"),he(!1)},onOpenProfile:()=>{s?.(),he(!1)},userProfile:o,teacherName:fe,liveActivity:ae})},"cal-drawer")]})}),e.jsx(Et,{children:X&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs(Re.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden border border-slate-200",children:[e.jsxs("div",{className:"p-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600",children:e.jsx($s,{size:16})}),e.jsx("h3",{className:"font-semibold text-slate-800",children:"Detailed AI Insight"})]}),e.jsx("button",{onClick:()=>{J(!1)},className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(cs,{size:18})})]}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-sm text-slate-600 leading-relaxed",children:e.jsx(tc,{children:Me?.replace(/[*_]*\s*\(?Word\s*count\s*:\s*[*_]*\s*\d+\)?\s*[*_]*/gi,"").trim()||`**${Ke} students (${Fe>0?Math.round(Ke/Fe*100):0}%)** are currently at high risk of falling behind in recent topics. Review their progress in the analytics view to plan interventions.`})})}),e.jsx("div",{className:"p-4 border-t border-slate-100 bg-slate-50 flex justify-end gap-2",children:e.jsx("button",{onClick:()=>{J(!1)},className:"px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 hover:bg-slate-200 rounded-lg transition-colors",children:"Minimize to Menu"})})]})})}),e.jsx(Tl,{isOpen:j,onClose:()=>S(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"}),e.jsx(Im,{open:p,onClose:()=>N(!1),onCreated:()=>K(_=>_+1),teacherName:fe}),e.jsx(Tm,{open:C,onClose:()=>z(!1),onAdded:()=>K(_=>_+1),grade:st?.gradeLevel||st?.classMetadata?.grade||"Grade 11",section:st?.classMetadata?.section||st?.name?.split(" - ")[1]||"",teacherName:fe,existingStudentUids:_t.map(_=>_.id)}),e.jsx(dx,{isOpen:!!oe,onClose:()=>pe(null),seed:oe,adviserTeacherId:r?.uid||"",adviserTeacherName:fe,schoolYear:oe?M.find(_=>_.id===oe.rosterId)?.classMetadata?.schoolYear||String(new Date().getFullYear()):void 0,onCreated:Ot})]})},Ns=({icon:t,label:s,active:a,collapsed:r,forceExpanded:o=!1,onClick:n})=>e.jsxs(Re.button,{onClick:n,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&&!o?"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||o)&&e.jsx("span",{className:"font-body font-semibold 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}})]}),fx=({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-semibold text-foreground mb-2",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground font-body leading-relaxed",children:a})]})}),gx=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:o,dailyInsight:n,insightLoading:i,isInsightDismissed:l,onDismissInsight:c,onOpenInsightModal:d,totalStudents:u,totalAtRisk:f,avgPerformance:h,onCreateClass:b})=>{const k=u>0?Math.round(f/u*100):0,j=u>0?Math.round((u-f)/u*100):0;return e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-3 sm:p-6 space-y-4",children:[!l&&n&&e.jsxs("div",{onClick:d,className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[14px_16px] sm:p-[18px_20px] flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4 shadow-[0_1px_4px_rgba(0,0,0,0.04)] cursor-pointer hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"absolute -inset-[5px] rounded-full border-2 border-[#a5b4fc] opacity-50 animate-pulse"}),e.jsx("div",{className:"w-[46px] h-[46px] rounded-full bg-[#eef2ff] border-2 border-[#c7d2fe] flex items-center justify-center text-[#4f46e5] text-xl relative overflow-hidden group-hover:scale-[1.05] transition-transform",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Mascot",className:"w-[85%] h-[85%] object-contain"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"text-[13.5px] font-semibold text-[#1e1b4b] flex flex-wrap items-center gap-2 mb-1",children:[e.jsx($s,{size:14,className:"text-[#818cf8]"}),"MathPulse AI insight",e.jsx("span",{className:"bg-[#fee2e2] text-[#b91c1c] text-[10px] font-semibold px-2 py-0.5 rounded-full border border-[#fca5a5]",children:"Attention needed"})]}),e.jsx("div",{className:"text-[12.5px] text-[#475569] leading-[1.55]",children:"Some students may be at risk of falling behind. Click to view detailed analysis."})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0 self-end sm:self-auto",children:[e.jsx("button",{onClick:S=>{S.stopPropagation(),c()},className:"px-[15px] py-[7px] rounded-[10px] text-xs font-medium cursor-pointer border border-[#e2e8f0] bg-white text-[#475569] hover:bg-[#f8fafc] transition-colors",children:"Dismiss"}),e.jsx("button",{onClick:S=>{S.stopPropagation(),r()},className:"px-[15px] py-[7px] rounded-[10px] text-xs font-medium cursor-pointer border border-[#4f46e5] bg-[#4f46e5] text-white shadow-[0_2px_8px_rgba(79,70,229,0.13)] hover:bg-[#4338ca] transition-colors",children:"Review students"})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-1.5 sm:gap-3",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#10b981] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Total students"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(os,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:u}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Added this year"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:u>0?"+1":"0"})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#0ea5e9] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Class average"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(vs,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:[h,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Vs. last month"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:"+2.5%"})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#a855f7] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"Engage­ment"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(si,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:[j,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Active participants"}),e.jsx("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:Math.round(j/100*u)})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-sm sm:rounded-lg p-[10px] sm:p-[15px] text-white flex flex-col gap-[6px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[9px] sm:text-[11px] opacity-90 leading-tight",children:"At risk"}),e.jsx("div",{className:"hidden sm:flex bg-white/20 p-1.5 rounded-lg",children:e.jsx(or,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[18px] sm:text-[26px] font-semibold tracking-tight",children:f}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-1.5 sm:pt-2 flex justify-between items-center text-[9px] sm:text-[10px] opacity-90",children:[e.jsx("span",{className:"hidden sm:block",children:"Requires attention"}),e.jsxs("span",{className:"bg-black/15 px-[5px] sm:px-[7px] py-[2px] rounded font-semibold",children:[k,"%"]})]})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[18px_20px] shadow-[0_1px_4px_rgba(0,0,0,0.04)]",children:[e.jsxs("div",{className:"flex justify-between items-center mb-[14px]",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:"My classes"}),e.jsx("span",{onClick:r,className:"text-[12px] text-[#10b981] font-semibold cursor-pointer hover:underline",children:"View all"})]}),e.jsxs("div",{className:"space-y-[9px]",children:[t.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-slate-500 mb-3",children:"No classes imported yet."}),b&&e.jsx("button",{onClick:b,className:"text-sm text-[#9956DE] font-semibold hover:underline",children:"+ Create a class"})]}),t.map((S,p)=>{const N=[{bg:"bg-[#f3e8ff]",text:"text-[#a855f7]",borderHover:"hover:border-[#d8b4fe]",stripe:"bg-[#a855f7]"},{bg:"bg-[#eff6ff]",text:"text-[#3b82f6]",borderHover:"hover:border-[#bfdbfe]",stripe:"bg-[#3b82f6]"},{bg:"bg-[#f0fdf4]",text:"text-[#22c55e]",borderHover:"hover:border-[#bbf7d0]",stripe:"bg-[#22c55e]"},{bg:"bg-[#fff7ed]",text:"text-[#f97316]",borderHover:"hover:border-[#fed7aa]",stripe:"bg-[#f97316]"},{bg:"bg-[#fff1f2]",text:"text-[#f43f5e]",borderHover:"hover:border-[#fecdd3]",stripe:"bg-[#f43f5e]"}],C=N[p%N.length];return e.jsxs("div",{onClick:()=>a(S),className:`relative overflow-hidden flex items-center gap-3 p-[12px_13px] pl-[16px] border border-[#f1f5f9] rounded-[14px] cursor-pointer ${C.borderHover} hover:shadow-[0_2px_10px_rgba(0,0,0,0.04)] hover:bg-[#fafbff] transition-all group`,children:[e.jsx("div",{className:`absolute left-0 top-0 bottom-0 w-[5px] ${C.stripe}`}),e.jsx("div",{className:`w-[38px] h-[38px] rounded-[10px] flex items-center justify-center flex-shrink-0 text-[17px] ${C.bg} ${C.text} group-hover:scale-110 transition-transform duration-300`,children:e.jsx(Gt,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-[#1e293b]",children:S.name}),e.jsx("div",{className:"text-[11px] text-[#94a3b8] mt-[1px]",children:S.classification||"High School"})]}),e.jsx("div",{className:"hidden sm:block text-[12px] text-[#64748b] min-w-[65px]",children:S.schedule||"Mon-Fri"}),e.jsxs("div",{className:"hidden sm:block text-[12px] text-[#64748b] min-w-[85px]",children:[S.studentCount," students"]}),e.jsx("span",{className:`text-[10px] font-semibold px-[9px] py-[3px] rounded-[6px] ${S.riskLevel==="high"?"bg-[#fee2e2] text-[#b91c1c] border border-[#fca5a5]":S.riskLevel==="medium"?"bg-[#fffbeb] text-[#b45309] border border-[#fcd34d]":"bg-[#ecfdf5] text-[#065f46] border border-[#6ee7b7]"}`,children:S.riskLevel==="high"?"High risk":S.riskLevel==="medium"?"Medium risk":"On track"}),e.jsx(Lr,{size:16,className:"text-[#cbd5e1] ml-auto hover:text-[#64748b]"})]},S.id)})]})]})]})},bx=de.memo(({student:t,onViewStudent:s,onCreateAccount:a})=>{const o=t.riskLevel==="high"?{borderLeft:"border-l-rose-500",bgAvatar:"bg-rose-50 text-rose-600 border-rose-100/50",badge:"text-rose-600 bg-rose-50",progress:"bg-rose-500"}:t.riskLevel==="medium"?{borderLeft:"border-l-amber-500",bgAvatar:"bg-amber-50 text-amber-600 border-amber-100/50",badge:"text-amber-600 bg-amber-50",progress:"bg-amber-500"}:{borderLeft:"border-l-emerald-500",bgAvatar:"bg-emerald-50 text-emerald-600 border-emerald-100/50",badge:"text-emerald-600 bg-emerald-50",progress:"bg-emerald-500"},n=t.hasRegisteredAccount===!1&&t.source==="import",i=t.hasRegisteredAccount===!0;return e.jsxs("div",{onClick:()=>s(t),className:`p-[12px] bg-white rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] border-l-[4px] ${o.borderLeft} hover:scale-[1.02] transition-transform cursor-pointer group flex flex-col justify-between`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-[10px]",children:[e.jsxs("div",{className:"flex gap-[8px] items-center min-w-0 pr-2",children:[t.avatar?e.jsx("img",{src:t.avatar,alt:t.name,className:`w-8 h-8 rounded-full border ${o.bgAvatar.split(" ")[2]} object-cover shrink-0`}):e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-semibold text-[11px] shrink-0 border ${o.bgAvatar}`,children:t.name.substring(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] leading-tight truncate",children:t.name}),i&&e.jsx("span",{title:"Registered student account",className:"w-1.5 h-1.5 rounded-full bg-emerald-500 shrink-0"})]}),e.jsxs("p",{className:"text-[10px] text-[#64748b] flex items-center gap-[4px] mt-0.5 truncate",children:[e.jsx(Zs,{className:"w-[10px] h-[10px] shrink-0"})," ",t.lastActive||"recently"]})]})]}),e.jsxs("span",{className:`font-semibold text-[11px] px-[6px] py-[2px] rounded-[14px] shrink-0 ${o.badge}`,children:[t.avgScore,"%"]})]}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2 px-2 py-1 rounded-[10px] bg-amber-50 border border-amber-100/80",children:[e.jsx("span",{className:"text-[10px] font-semibold text-amber-700 uppercase tracking-wider",children:"No Account"}),a&&e.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),a(t)},className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-white text-amber-700 border border-amber-200 hover:bg-amber-100 text-[10px] font-semibold transition-colors","aria-label":`Create system account for ${t.name}`,children:[e.jsx("span",{"aria-hidden":!0,children:"+"}),"Create"]})]}),e.jsx("div",{className:"w-full bg-[#f1f5f9] h-1.5 rounded-full overflow-hidden mt-auto",children:e.jsx("div",{className:`h-full rounded-full ${o.progress}`,style:{width:`${t.avgScore}%`}})})]})}),vx=({students:t,allClasses:s,currentClass:a,onReassignSection:r,reassignBusyId:o})=>{const[n,i]=m.useState(!1),l=m.useMemo(()=>{const d=new Map;return s.forEach(u=>{const f=(u.classSectionId||u.id||"").trim();if(!f)return;const h=(u.classMetadata?.grade||"").trim(),b=(u.classMetadata?.section||"").trim();if(!h||!b)return;const k=u.name||`${h} - ${b}`;d.set(f,{classSectionId:f,grade:h,section:b,label:k})}),Array.from(d.values()).sort((u,f)=>u.label.localeCompare(f.label))},[s]),c=m.useMemo(()=>{const d=new Map,u=[];return t.forEach(f=>{const h=(f.classSectionId||"").trim();if(!h){u.push(f);return}const b=f.section||f.className||h,k=d.get(h)||{label:b,students:[]};k.students=[...k.students,f],d.set(h,k)}),{assigned:Array.from(d.entries()).map(([f,h])=>({sectionId:f,...h})).sort((f,h)=>f.label.localeCompare(h.label)),unassigned:u}},[t]);return e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white shadow-[0_1px_4px_rgba(0,0,0,0.04)] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(d=>!d),className:"w-full flex items-center justify-between px-6 py-4 text-left","aria-expanded":n,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Section Management"}),e.jsxs("p",{className:"text-[12px] text-[#64748b] mt-0.5",children:["Move students between sections. Showing ",t.length," students across ",c.assigned.length," section",c.assigned.length===1?"":"s",c.unassigned.length>0?` · ${c.unassigned.length} unassigned`:"","."]})]}),e.jsx(Tt,{className:`w-4 h-4 text-[#64748b] transition-transform ${n?"rotate-180":""}`})]}),n&&e.jsxs("div",{className:"border-t border-[#f1f5f9] divide-y divide-[#f1f5f9]",children:[c.assigned.length===0&&c.unassigned.length===0&&e.jsx("p",{className:"text-[12px] text-[#64748b] px-6 py-5",children:"No students yet. Add students to this teacher to manage section assignments."}),c.assigned.map(d=>e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-[#64748b] mb-2",children:[d.label," ",e.jsxs("span",{className:"text-[10px] font-normal text-[#94a3b8]",children:["(",d.students.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:d.students.map(u=>e.jsx(qo,{student:u,sectionTargets:l,currentSectionId:a.classSectionId,onReassign:r,isBusy:o===u.id},`section-row-${u.id}`))})]},d.sectionId)),c.unassigned.length>0&&e.jsxs("div",{className:"px-6 py-4 bg-amber-50/40",children:[e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-amber-700 mb-2",children:["Unassigned ",e.jsxs("span",{className:"text-[10px] font-normal text-amber-600/80",children:["(",c.unassigned.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:c.unassigned.map(d=>e.jsx(qo,{student:d,sectionTargets:l,currentSectionId:a.classSectionId,onReassign:r,isBusy:o===d.id},`section-row-${d.id}`))})]})]})]})},qo=({student:t,sectionTargets:s,currentSectionId:a,onReassign:r,isBusy:o})=>{const[n,i]=m.useState(t.classSectionId||"");m.useEffect(()=>{i(t.classSectionId||"")},[t.classSectionId]);const l=()=>{const d=s.find(u=>u.classSectionId===n);d&&d.classSectionId!==t.classSectionId&&r(t,d)},c=n===(t.classSectionId||"");return e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-2 md:gap-3 px-3 py-2 rounded-[12px] bg-white border border-[#f1f5f9]",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] truncate",children:t.name}),e.jsxs("p",{className:"text-[11px] text-[#64748b] truncate",children:[t.lrn?`LRN ${t.lrn} · `:"",t.classMetadata?.className||t.className||"Unassigned section",a&&t.classSectionId===a?" · current":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:n,onChange:d=>i(d.target.value),disabled:o||s.length===0,className:"text-[12px] rounded-xl border border-[#dde3eb] bg-white px-3 py-1.5 text-[#0a1628] focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Select section…"}),s.map(d=>e.jsx("option",{value:d.classSectionId,children:d.label},d.classSectionId))]}),e.jsx("button",{type:"button",onClick:l,disabled:o||c||!n,className:"text-[12px] font-semibold rounded-xl px-3 py-1.5 bg-indigo-600 text-white hover:bg-indigo-700 transition-colors disabled:opacity-50 disabled:hover:bg-indigo-600",children:o?"Saving…":"Move"})]})]})},wx=({selectedClass:t,students:s,allClasses:a,riskDistribution:r,topicPerformance:o,onViewStudent:n,onCreateAccount:i,onReassignSection:l,reassignBusyId:c,onBack:d,teacherOptions:u,managerUpdating:f,onAssignManager:h,onOpenNotifications:b,onOpenProfile:k,classColor:j,insightDismissed:S,onOpenInsightModal:p,onAddStudents:N})=>{const{currentUser:C,userProfile:z}=ds(),[I,U]=m.useState(""),[v,y]=m.useState(""),[w,A]=m.useState("All"),B=[{name:"High Risk",value:s.filter(H=>H.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:s.filter(H=>H.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:s.filter(H=>H.riskLevel==="low").length,color:"#75D06A"}];m.useEffect(()=>{y(t.classMetadata?.managerId||t.managerId||"")},[t]);const E=m.useMemo(()=>{const H=I.trim().toLowerCase();let q=s;return H&&(q=q.filter(M=>M.name.toLowerCase().includes(H)||(M.lrn||"").toLowerCase().includes(H)||(M.weakestTopic||"").toLowerCase().includes(H))),w==="Good"?q=q.filter(M=>M.avgScore>=85&&M.riskLevel!=="high"):w==="Risk"&&(q=q.filter(M=>M.riskLevel==="high"||M.avgScore<75)),q},[I,s,w]),F=m.useMemo(()=>{if(s.length===0)return 0;const H=s.reduce((q,M)=>q+(M.assignmentCompletion||0),0);return Math.round(H/s.length)},[s]),X=m.useMemo(()=>{if(s.length===0)return 0;const H=s.reduce((M,Y)=>M+(Y.attendance||0),0)/s.length,q=s.reduce((M,Y)=>M+(Y.engagementScore||0),0)/s.length;return Math.round(H*.6+q*.4)},[s]),J=m.useMemo(()=>[...s].sort((H,q)=>q.avgScore-H.avgScore).slice(0,5),[s]),ce=m.useMemo(()=>[...s].filter(H=>H.riskLevel==="high"||H.avgScore<70||H.assignmentCompletion<65),[s]),ne=m.useMemo(()=>u.find(H=>H.uid===v),[u,v]),xe=()=>{if(!ne){me.error("Select a teacher manager first.");return}h(ne)},he=[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-3 sm:p-[24px] xl:p-[32px] space-y-3 sm:space-y-[24px] h-full overflow-y-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-3 sm:mb-6",children:e.jsxs("button",{onClick:d,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Ss,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("header",{style:{backgroundColor:j?.hex||"#6366f1"},className:"rounded-[24px] p-4 sm:p-[24px] lg:p-[32px] shadow-[0_8px_32px_rgba(0,0,0,0.08)] flex flex-col lg:flex-row lg:items-center justify-between gap-4 sm:gap-6 relative overflow-hidden group text-white",children:[e.jsx("div",{className:"absolute -right-10 -bottom-10 w-48 h-48 rounded-full bg-white/10 group-hover:scale-[1.3] transition-transform duration-700 ease-out pointer-events-none"}),e.jsx("div",{className:"absolute -left-10 -top-10 w-32 h-32 rounded-full bg-white/10 group-hover:scale-[1.2] transition-transform duration-700 delay-75 ease-out pointer-events-none"}),e.jsxs("div",{className:"shrink-0 relative z-10",children:[e.jsx("h1",{className:"text-xl sm:text-[28px] font-bold mb-2 sm:mb-3 tracking-tight",children:t.name}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:he.map((H,q)=>e.jsx("span",{className:"px-3 py-1 bg-white/20 backdrop-blur-md text-white text-[12px] font-semibold rounded-full shadow-sm border border-white/20",children:H},H))}),e.jsxs("p",{className:"text-[13px] text-white/80 font-medium",children:["Manager: ",t.classMetadata?.managerName||t.managerName||"Not assigned"]})]}),e.jsxs("div",{className:"bg-white/10 border border-white/20 rounded-[18px] p-[16px] backdrop-blur-md flex flex-col w-full md:w-auto shrink-0 relative z-10 shadow-inner",children:[e.jsx("label",{className:"text-[11px] font-bold text-white/90 uppercase tracking-wider mb-2 ml-1",children:"Section Manager"}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3",children:[e.jsxs("div",{className:"relative w-full md:w-[320px]",children:[e.jsxs("select",{value:v||"",onChange:H=>y(H.target.value),className:"appearance-none bg-white/20 border border-white/30 text-white text-[13px] font-bold rounded-xl pl-4 pr-10 py-2.5 outline-none focus:border-white/50 focus:ring-2 focus:ring-white/20 w-full shadow-sm cursor-pointer [&>option]:text-[#1e293b]",children:[e.jsx("option",{value:"",children:"Select teacher"}),u.map(H=>e.jsxs("option",{value:H.uid,children:[H.name," (",H.email,")"]},H.uid))]}),e.jsx(Tt,{className:"w-4 h-4 text-white/70 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsx("button",{onClick:xe,disabled:!v||f,className:"bg-white text-[#6366f1] hover:bg-white/90 text-[13px] font-bold rounded-full px-6 py-2.5 shadow-md transition-transform hover:scale-[1.02] whitespace-nowrap disabled:opacity-50 disabled:hover:scale-100",style:{color:j?.hex||"#6366f1"},children:f?"Updating...":"Assign"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-[18px] w-full",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#0ea5e9] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Class Average"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(vs,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#10b981] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Completion"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(qr,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[F,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#a855f7] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Participation"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(os,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[X,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-lg sm:rounded-2xl p-[12px] sm:p-[15px] text-white flex flex-col gap-[8px] sm:gap-[10px]",children:[e.jsx("div",{className:"absolute -right-4 -bottom-4 w-24 h-24 rounded-full bg-white/10 group-hover:scale-[1.6] transition-transform duration-500 ease-out"}),e.jsx("div",{className:"absolute -left-4 -top-4 w-12 h-12 rounded-full bg-white/10 group-hover:scale-[1.4] transition-transform duration-500 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex justify-between items-start",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Attention"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Xs,{size:14})})]}),e.jsxs("div",{className:"relative z-10 text-[22px] sm:text-[26px] font-semibold tracking-tight",children:[ce.length," ",e.jsx("span",{className:"text-[12px] opacity-90 font-medium",children:"students"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-3 sm:gap-[24px] h-auto xl:h-[600px]",children:[e.jsxs("div",{className:"xl:col-span-1 bg-white/80 backdrop-blur-[12px] rounded-[18px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col overflow-hidden h-[500px] xl:h-full",children:[e.jsxs("div",{className:"p-5 border-b border-[#f1f5f9] shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-[15px] font-semibold text-[#1e293b]",children:["Students ",e.jsxs("span",{className:"text-[#64748b] text-[13px]",children:["(",E.length,")"]})]}),e.jsx("button",{onClick:()=>N?.(),className:"text-[11px] font-semibold text-[#9956DE] hover:text-[#7c3aed] bg-[#9956DE]/10 hover:bg-[#9956DE]/20 px-3 py-1.5 rounded-lg transition-colors",children:"+ Add"})]}),e.jsxs("div",{className:"flex items-center bg-white px-4 py-2 rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] group",children:[e.jsx(Os,{className:"w-4 h-4 text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search students...",value:I,onChange:H=>U(H.target.value),className:"bg-transparent border-none focus:outline-none ml-2 text-[13px] w-full text-[#475569] placeholder:text-[#64748b]"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 overflow-x-auto no-scrollbar pb-1",children:[e.jsx("button",{onClick:()=>A("All"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="All"?"bg-[#4f46e5] text-white shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-[#f8fafc] text-[#64748b] hover:bg-[#f1f5f9]"}`,children:"All Students"}),e.jsx("button",{onClick:()=>A("Good"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="Good"?"bg-emerald-50 text-emerald-600 border border-emerald-100/50 shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-emerald-50/40 text-emerald-600 border border-emerald-50 hover:bg-emerald-50"}`,children:"Top Performers"}),e.jsx("button",{onClick:()=>A("Risk"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${w==="Risk"?"bg-rose-50 text-rose-600 border border-rose-100/50 shadow-[0_1px_4px_rgba(0,0,0,0.04)]":"bg-rose-50/40 text-rose-600 border border-rose-50 hover:bg-rose-50"}`,children:"Needs Attention"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4 flex flex-col no-scrollbar",children:e.jsx(Yd,{style:{height:"100%"},data:E,className:"no-scrollbar",itemContent:(H,q)=>e.jsx("div",{className:"py-[6px] px-[8px]",children:e.jsx(bx,{student:q,onViewStudent:n,onCreateAccount:i})}),computeItemKey:(H,q)=>Ur(q)})})]}),e.jsxs("div",{className:"xl:col-span-2 flex flex-col gap-[24px] h-full overflow-y-auto no-scrollbar pb-10 xl:pb-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col group h-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"font-semibold text-[15px] text-[#1e293b]",children:"Risk Distribution"}),e.jsx(Lr,{className:"w-4 h-4 text-[#64748b] cursor-pointer group-hover:scale-110 transition-transform"})]}),e.jsx("div",{className:"relative w-full flex-1 min-h-[180px]",children:e.jsx(Dn,{width:"100%",height:"100%",children:e.jsxs($n,{data:B,children:[e.jsx(Fn,{strokeDasharray:"4 4",stroke:"#f1f5f9",vertical:!1}),e.jsx(On,{dataKey:"name",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#475569",fontSize:11,fontWeight:600},dy:10}),e.jsx(Bn,{axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600}}),e.jsx(Pn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Hn,{dataKey:"value",radius:[6,6,0,0],barSize:80,children:B.map((H,q)=>{const M={"High Risk":"#f43f5e","Medium Risk":"#f59e0b","Low Risk":"#10b981"};return e.jsx(Gn,{fill:M[H.name]||H.color},`cell-${q}`)})})]})})})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white flex flex-col group h-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"font-semibold text-[15px] text-[#1e293b]",children:"Topic Performance"}),e.jsx(Lr,{className:"w-4 h-4 text-[#64748b] cursor-pointer group-hover:scale-110 transition-transform"})]}),e.jsx("div",{className:"relative w-full flex-1 min-h-[180px] -ml-8",children:e.jsx(Dn,{width:"100%",height:"100%",children:e.jsxs($n,{data:o,layout:"vertical",margin:{top:0,right:10,left:40,bottom:0},children:[e.jsx(Fn,{strokeDasharray:"4 4",stroke:"#f1f5f9",horizontal:!1}),e.jsx(On,{type:"number",domain:[0,100],axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600},tickFormatter:H=>`${H}%`}),e.jsx(Bn,{dataKey:"topic",type:"category",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#1e293b",fontSize:11,fontWeight:600},dx:-10}),e.jsx(Pn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Hn,{dataKey:"score",radius:[0,6,6,0],barSize:28,children:o.map((H,q)=>{const M=["#6366f1","#a855f7","#10b981","#f59e0b","#ec4899"];return e.jsx(Gn,{fill:M[q%M.length]},`cell-${q}`)})})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-[24px]",children:[e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("h3",{className:"font-semibold text-[15px] text-[#1e293b] flex items-center gap-2",children:[e.jsx(Ta,{className:"w-4 h-4 text-emerald-500"}),"Top Performers"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[J.map(H=>e.jsxs("div",{onClick:()=>n(H),className:"flex justify-between items-center p-3 bg-emerald-50/40 rounded-[14px] border border-emerald-50 group hover:scale-[1.02] transition-transform cursor-pointer",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:H.name}),e.jsxs("span",{className:"text-[13px] font-semibold text-emerald-600",children:[H.avgScore,"%"]})]},`top-${H.id}`)),J.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No students available yet."})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-6 shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("h3",{className:"font-semibold text-[15px] text-[#1e293b] flex items-center gap-2",children:[e.jsx(Xs,{className:"w-4 h-4 text-rose-500"}),"Needs Attention"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[ce.slice(0,4).map(H=>{const q=H.riskLevel==="high",M=q?"bg-rose-50/40 border-rose-50":"bg-amber-50/40 border-amber-50";return e.jsxs("div",{onClick:()=>n(H),className:`flex justify-between items-center p-3 rounded-[14px] border group hover:scale-[1.02] transition-transform cursor-pointer ${M}`,children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:H.name}),e.jsx("span",{className:`text-[11px] font-semibold bg-white px-2 py-0.5 rounded-[14px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-[#f1f5f9] ${q?"text-rose-600":"text-amber-600"}`,children:q?"HIGH RISK":"MEDIUM RISK"})]},`attn-${H.id}`)}),ce.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students."})]})]})]})]})]}),e.jsx(vx,{students:s,allClasses:a,currentClass:t,onReassignSection:l,reassignBusyId:c})]})},Nx=({student:t,teacherId:s,teacherName:a,onStudentUpdated:r,onBack:o,onNavigateToQuizMaker:n,initialCache:i,onCacheUpdate:l})=>{const c=(t.riskLevel||"low").toLowerCase(),d=c==="high"||c==="medium",u=m.useMemo(()=>nt.getImportGroundedRolloutFlags(),[]),[f,h]=m.useState(i?.learningPath||""),[b,k]=m.useState(!0),[j,S]=m.useState(i?.gradeDraft||t.grade||"Grade 11"),[p,N]=m.useState(i?.sectionDraft||t.section||"Section A"),[C,z]=m.useState(!1),[I,U]=m.useState(i?.lessonPlan??null),[v,y]=m.useState([]),[w,A]=m.useState(""),[B,E]=m.useState(!1),[F,X]=m.useState(""),[J,ce]=m.useState("all"),[ne,xe]=m.useState("all"),[he,H]=m.useState(!1),[q,M]=m.useState(!1),[Y,ae]=m.useState(null),[$e,Me]=m.useState(!1),[Ge,G]=m.useState(!1),[te,g]=m.useState(0),[T,R]=m.useState(!1),[K,Z]=m.useState("choose"),[re,le]=m.useState([]),[$,oe]=m.useState(!1),[pe,we]=m.useState(!1),[se,fe]=m.useState(!1),[et,Fe]=m.useState(!1);m.useEffect(()=>{S(t.grade||"Grade 11"),N(t.section||"Section A")},[t.grade,t.section]),m.useEffect(()=>{const P=Ae=>{if(Ae.key==="Escape"){if(et){Fe(!1);return}if(pe){se?Fe(!0):we(!1);return}T&&R(!1)}};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[pe,T,se,et]),m.useEffect(()=>{if(pe){const P=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=P}}},[pe]),m.useEffect(()=>{l?.(t.id,{lessonPlan:I,learningPath:f,gradeDraft:j,sectionDraft:p})},[I,f,j,p,t.id,l]),m.useEffect(()=>{(async()=>{k(!0);try{let Ae="";try{Ae=await Cl(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),A(Ae)}catch{A("")}const Ye=await nt.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),vt=Ae?`${Ye.learningPath} - -${Ae}`:Ye.learningPath;h(vt)}catch{h("Unable to generate learning path. Please try again later."),A("")}finally{k(!1)}})()},[t]);const Ke=m.useCallback(async()=>{E(!0),X("");try{const P=t.classSectionId||Lt(j||"Grade 11",p||"Section A"),Ae=t.struggles.length>0?t.struggles[0]:t.weakestTopic,Ye=await _m({gradeLevel:j||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[j,p].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${Ae}`,learningCompetency:Ae,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:P,className:[j,p].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:u.lessonEnabled,allowReviewSources:he,allowUnverifiedLesson:q},!0);U(Ye),y(Ye.curriculumSources||[]),ae(null),nt.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:P,className:[j,p].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:Ye.usedImportedTopics,importedTopicCount:Ye.importedTopicCount,blockCount:Ye.blocks.length,publishReady:Ye.publishReady,sourceLegitimacyStatus:Ye.sourceLegitimacy.status,selfValidationPassed:Ye.selfValidation.passed,importGroundingEnabled:u.lessonEnabled}})}catch(P){let Ae=P instanceof Error?P.message:"Unable to generate lesson plan at this time.";if(P instanceof qa&&P.status===422)try{const vt=JSON.parse(P.responseBody)?.detail;vt?.message&&(Ae=vt.message);const xs=vt?.sourceLegitimacy?.issues||[],Ot=vt?.selfValidation?.issues||[],Wt=[...xs,...Ot].filter(Boolean).slice(0,3);Wt.length>0&&(Ae=`${Ae} ${Wt.join(" ")}`)}catch{}X(Ae),U(null),y([]),nt.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||Lt(j||"Grade 11",p||"Section A"),className:[j,p].filter(Boolean).join(" - ")||t.className,metadata:{error:Ae,allowReviewSources:he,allowUnverifiedLesson:q,importGroundingEnabled:u.lessonEnabled}})}finally{E(!1)}},[t,j,p,u.lessonEnabled,he,q]),rt=m.useCallback(async()=>{if(!I)return me.error("Generate a lesson plan first."),null;Me(!0);try{const P=await Em(I,s,{teacherName:a,studentId:t.id,studentName:t.name});return ae(P),me.success("Lesson plan saved as draft."),P}catch(P){return console.error("Failed to save lesson draft:",P),me.error(P instanceof Error?P.message:"Failed to save lesson draft."),null}finally{Me(!1)}},[I,s,a,t.id,t.name]),Rt=m.useCallback(async()=>{if(!I){me.error("Generate a lesson plan first.");return}if(!I.publishReady){const P=[...I.sourceLegitimacy.issues,...I.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");me.error(P||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}G(!0);try{let P=Y;if(P||(P=await rt()),!P)return;await Rm(P),me.success("Lesson plan published to class content."),nt.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:I.classSectionId||t.classSectionId,className:I.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:P,publishReady:I.publishReady,sourceLegitimacyStatus:I.sourceLegitimacy.status,selfValidationPassed:I.selfValidation.passed}})}catch(P){console.error("Failed to publish lesson plan:",P),me.error(P instanceof Error?P.message:"Failed to publish lesson plan."),nt.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:I.classSectionId||t.classSectionId,className:I.className||t.className,metadata:{action:"publish_lesson_plan",error:P instanceof Error?P.message:"Failed to publish lesson plan."}})}finally{G(!1)}},[I,Y,rt,t.className,t.classSectionId]);m.useEffect(()=>{Ke()},[te]),m.useEffect(()=>{g(P=>P+1)},[t.id]),m.useEffect(()=>{ce("all"),xe("all")},[I]),m.useMemo(()=>I?Array.from(new Set(I.blocks.map(P=>P.provenance?.sourceFile?.trim()).filter(P=>!!P))).sort((P,Ae)=>P.localeCompare(Ae)):[],[I]),m.useMemo(()=>I?Array.from(new Set(I.blocks.map(P=>P.provenance?.materialId?.trim()).filter(P=>!!P))).sort((P,Ae)=>P.localeCompare(Ae)):[],[I]);const St=m.useMemo(()=>I?I.blocks.filter(P=>{const Ae=J==="all"||(P.provenance?.sourceFile||"").trim()===J,Ye=ne==="all"||(P.provenance?.materialId||"").trim()===ne;return Ae&&Ye}):[],[I,J,ne]),Ft=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:Qn},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:ii},{id:3,type:"assessment",title:"Final Check",questions:5,icon:qr}],ss=async()=>{if(!s){me.error("Unable to update section: teacher context missing");return}z(!0);try{await mr(t.id,j,p,s,new Date().getFullYear().toString(),a),await Vi(t.id,j,p);const P={...t,grade:j,section:p,className:[j,p].filter(Boolean).join(" - "),classSectionId:Lt(j,p)};r(P),me.success("Student section assignment updated")}catch(P){console.error("Failed to update student section assignment:",P),me.error("Failed to update section assignment")}finally{z(!1)}};return e.jsxs(Re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"w-full h-full flex overflow-hidden relative",children:[e.jsx("div",{className:"flex-1 overflow-y-auto p-[24px] xl:p-[32px] no-scrollbar",children:e.jsxs("div",{className:"max-w-[1000px] mx-auto space-y-[24px]",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-[8px]",children:e.jsx("div",{children:e.jsxs("button",{onClick:o,className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-white/60 hover:bg-white/80 px-[18px] py-2 rounded-full backdrop-blur-[12px] mb-[16px] w-max shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(Xa,{className:"w-4 h-4"}),"Back to Analytics"]})})}),e.jsxs("div",{className:"bg-gradient-to-br from-[#ecfdf5] via-[#f0fdf4] to-[#f7fdf9] backdrop-blur-[12px] rounded-[20px] p-[24px] border border-emerald-100 shadow-[0_4px_16px_rgba(16,185,129,0.08)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute right-[-20px] bottom-[-20px] opacity-[0.06] pointer-events-none",children:e.jsx(Cn,{className:"w-48 h-48 text-emerald-600"})}),e.jsxs("div",{className:"flex items-center gap-3 mb-5 relative z-10",children:[e.jsx("div",{className:"w-10 h-10 rounded-[12px] bg-gradient-to-br from-[#059669] to-[#10b981] flex items-center justify-center shrink-0 shadow-[0_4px_10px_rgba(5,150,105,0.3)]",children:e.jsx(Cn,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-[15px] font-bold text-[#1e293b]",children:"AI Analysis"}),e.jsxs("span",{className:"flex items-center gap-1 px-2.5 py-0.5 bg-emerald-500 text-white text-[10px] font-bold rounded-full uppercase tracking-wider shadow-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse"}),"Insights Active"]})]})]}),w&&e.jsx(No,{sources:v,className:"mb-4 relative z-10"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsxs("div",{className:"bg-white/70 backdrop-blur-sm rounded-[14px] p-4 border border-emerald-100/60 shadow-[0_1px_4px_rgba(0,0,0,0.04)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-400 rounded-l-[14px]"}),e.jsxs("h4",{className:"text-[11px] font-bold text-emerald-600 uppercase tracking-wider mb-2.5 flex items-center gap-1.5 pl-2",children:[e.jsx(Ta,{className:"w-3.5 h-3.5"})," Learning Strengths"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed pl-2",children:d?e.jsx(e.Fragment,{children:"Demonstrates engagement but faces challenges. Needs support with foundational topics."}):e.jsxs(e.Fragment,{children:["Excels in ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:t.weakestTopic}),". Demonstrates high engagement during interactive tests."]})})]}),e.jsxs("div",{className:"bg-white/70 backdrop-blur-sm rounded-[14px] p-4 border border-rose-100/60 shadow-[0_1px_4px_rgba(0,0,0,0.04)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-rose-400 rounded-l-[14px]"}),e.jsxs("h4",{className:"text-[11px] font-bold text-rose-500 uppercase tracking-wider mb-2.5 flex items-center gap-1.5 pl-2",children:[e.jsx(vs,{className:"w-3.5 h-3.5"})," Next Steps"]}),e.jsx("ul",{className:"text-[13px] text-[#475569] leading-relaxed list-none p-0 m-0 space-y-1 pl-2",children:t.struggles.length>0?t.struggles.map((P,Ae)=>e.jsxs("li",{children:["Must continue strengthening ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:P}),"."]},Ae)):e.jsxs("li",{children:["Focus on repetitive practice modules for ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:t.weakestTopic}),"."]})})]})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 border-b border-[#f1f5f9] pb-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Generated Learning Path"}),e.jsxs("button",{disabled:b,onClick:()=>g(P=>P+1),className:"bg-[#f8fafc] hover:bg-white text-[#4f46e5] border border-[#e0e7ff] text-[11px] font-semibold rounded-full px-4 py-1.5 transition-colors shadow-[0_1px_4px_rgba(0,0,0,0.02)] flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(zs,{className:"w-3 h-3"})," Regenerate"]})]}),e.jsxs(vo,{name:"teacher-intervention-learning-path",loading:!1,fixture:null,fallback:null,children:[e.jsxs("div",{className:"mb-8 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mr-2",children:"Methodology:"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Interactive"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Video"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Practice"}),e.jsx("span",{className:"px-3 py-1 bg-[#f8fafc] text-[#475569] text-[11px] font-semibold rounded-full border border-[#e2e8f0]",children:"Quiz"})]}),e.jsx("div",{className:"relative border-l-2 border-[#e2e8f0] ml-[20px] space-y-[28px] pb-4",children:Ft.map((P,Ae)=>{let Ye=e.jsx(Qn,{className:"w-4 h-4"}),vt="bg-[#8b5cf6] shadow-[0_4px_10px_rgba(139,92,246,0.3)]",xs="text-purple-600",Ot="group-hover:border-purple-200",Wt="hover:bg-[#4f46e5]",qt=e.jsx(Pl,{className:"w-4 h-4 ml-0.5"});return P.type==="quiz"?(Ye=e.jsx(Hl,{className:"w-4 h-4"}),vt="bg-sky-500 shadow-[0_4px_10px_rgba(14,165,233,0.3)]",xs="text-sky-600",Ot="group-hover:border-sky-200",Wt="hover:bg-sky-500",qt=e.jsx(ys,{className:"w-4 h-4"})):P.type==="assessment"&&(Ye=e.jsx(Wr,{className:"w-4 h-4"}),vt="bg-emerald-500 shadow-[0_4px_10px_rgba(16,185,129,0.3)]",xs="text-emerald-600",Ot="group-hover:bg-emerald-50"),e.jsxs(Re.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:Ae*.1},className:"relative pl-[32px] group",children:[e.jsx("div",{className:`absolute -left-[17px] top-1 w-8 h-8 rounded-full ${vt} text-white flex items-center justify-center ring-4 ring-white group-hover:scale-110 transition-transform`,children:Ye}),e.jsxs("div",{className:`${P.type==="assessment"?"bg-emerald-50/50 border-emerald-100":"bg-white border-[#f1f5f9]"} rounded-[14px] p-[18px] border shadow-[0_1px_4px_rgba(0,0,0,0.04)] flex justify-between items-center transition-colors ${Ot}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wider mb-1 block ${xs}`,children:["Step ",Ae+1," • ",P.type==="video"?"Video Lesson":P.type==="quiz"?"Practice":"Assessment"]}),e.jsx("p",{className:"font-semibold text-[#1e293b] text-[13px] mb-0.5",children:P.title}),e.jsxs("p",{className:"text-[#64748b] text-[11px] flex items-center gap-1.5",children:[P.type==="video"&&e.jsxs(e.Fragment,{children:[e.jsx(Zs,{className:"w-3 h-3"})," ",P.duration]}),P.type==="quiz"&&e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"w-3 h-3"})," ",P.questions," questions"]}),P.type==="assessment"&&e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"w-3 h-3"})," ",P.questions," assessment questions"]})]})]}),P.type==="assessment"?e.jsx(Zo,{className:"w-6 h-6 text-emerald-400"}):e.jsx("button",{className:`w-8 h-8 rounded-full bg-[#f8fafc] flex items-center justify-center text-[#64748b] ${Wt} hover:text-white transition-colors border border-[#e2e8f0]`,children:qt})]})]},P.id)})})]})]}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-[#1e293b]",children:"Targeted Lesson Generation"}),e.jsx(xt,{onClick:()=>g(P=>P+1),disabled:B,className:"bg-[#4f46e5] hover:bg-[#3730a3] text-white h-8 text-[11px] rounded-full px-4",children:B?"Loading...":"Regenerate"})]}),e.jsx("p",{className:"text-[13px] text-[#64748b] mb-6",children:"Configure inputs and requirements for AI lesson generation."}),e.jsxs("div",{className:"bg-[#f8fafc]/80 rounded-[14px] p-[20px] border border-[#f1f5f9] mb-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ga,{className:"w-4 h-4 text-[#4f46e5] shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-[13px] text-[#475569] leading-relaxed",children:["Class records alone are not enough for import-grounded lesson plans. Ensure course materials are uploaded via ",e.jsx("span",{className:"text-[#4f46e5] font-semibold",children:"Data Import"}),"."]})]}),e.jsxs("div",{className:"space-y-4 border-t border-[#e2e8f0] pt-5 mt-5",children:[e.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[e.jsx("span",{className:"text-[13px] font-medium text-[#1e293b] group-hover:text-[#4f46e5] transition-colors",children:"Allow sources requiring manual review"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:he,onChange:P=>H(P.target.checked)}),e.jsx("div",{className:"w-10 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]})]}),e.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[e.jsx("span",{className:"text-[13px] font-medium text-[#1e293b] group-hover:text-[#4f46e5] transition-colors",children:"Allow unverified lesson draft"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:q,onChange:P=>M(P.target.checked)}),e.jsx("div",{className:"w-10 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#4f46e5]"})]})]})]})]}),e.jsxs(vo,{name:"teacher-intervention-lesson-plan",loading:!1,fixture:null,fallback:null,children:[F&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A] mb-4",children:F}),I&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[#f8fafc] border border-[#f1f5f9] rounded-[14px] p-5 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("div",{className:"mb-3",children:e.jsx(No,{sources:v})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:I.lessonTitle}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2 mt-2",children:[e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Imported topics:"})," ",I.usedImportedTopics?"Yes":"No"," (",I.importedTopicCount,")"]}),e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Subject:"})," ",I.subject||"General Math"," (Q",I.quarter||1,")"]})]}),I.curriculumCompetency&&e.jsxs("p",{className:"text-[11px] text-[#4f46e5] font-semibold mt-2 bg-indigo-50/50 px-2 py-1 rounded inline-block",children:["Competency: ",I.curriculumCompetency]}),e.jsx("div",{className:"mt-3 flex items-center justify-between",children:e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:["Publish readiness: ",e.jsx("span",{className:`font-semibold ${I.publishReady?"text-emerald-600":"text-rose-500"}`,children:I.publishReady?"Ready":"Blocked"})]})}),I.warnings.length>0&&e.jsx("p",{className:"text-[11px] text-amber-600 mt-2 bg-amber-50 px-2 py-1.5 rounded",children:I.warnings.join(" ")})]}),I.lessonObjective&&e.jsxs("div",{className:"bg-white border border-[#e2e8f0] rounded-[14px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5",children:"Lesson objective"}),e.jsx("p",{className:"text-[13px] text-[#1e293b]",children:I.lessonObjective})]}),I.realWorldHook&&e.jsxs("div",{className:"bg-indigo-50/50 border border-indigo-100 rounded-[14px] p-4 shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#4f46e5] uppercase tracking-wider mb-1.5",children:"Real-life application"}),e.jsx("p",{className:"text-[13px] text-[#1e293b]",children:I.realWorldHook})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:St.map(P=>e.jsxs("div",{className:"border border-[#e2e8f0] rounded-[14px] p-4 bg-white shadow-[0_1px_4px_rgba(0,0,0,0.02)]",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[#1e293b]",children:P.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] mt-1",children:[P.estimatedMinutes," mins "," • "," ",P.strategy]}),e.jsx("p",{className:"text-[12px] text-[#475569] mt-2 bg-[#f8fafc] p-2 rounded-lg",children:P.objective}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-[10px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5",children:"Activities"}),P.activities.slice(0,2).map((Ae,Ye)=>e.jsxs("p",{className:"text-[11px] text-[#475569] mb-1 flex items-start gap-1",children:[e.jsx("span",{className:"text-[#94a3b8] mt-0.5",children:"•"})," ",e.jsx("span",{children:Ae})]},Ye))]})]},P.blockId))}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-4",children:[e.jsx(xt,{variant:"outline",onClick:()=>void rt(),disabled:$e||!I,className:"border-[#cbd5e1] text-[#475569] hover:bg-[#f8fafc] text-[12px] h-9 rounded-full px-5",children:$e?e.jsx(Ln,{className:"h-4 w-16"}):"Save Draft"}),e.jsx(xt,{onClick:()=>void Rt(),disabled:Ge||!I||!I.publishReady,className:"bg-[#10b981] hover:bg-[#059669] text-white text-[12px] h-9 rounded-full px-5",children:Ge?e.jsx(Ln,{className:"h-4 w-24 bg-white/35"}):"Publish Lesson Plan"})]})]})]})]})]})}),e.jsx("aside",{className:"w-[320px] 2xl:w-[340px] bg-white/70 backdrop-blur-[24px] border-l border-white shadow-[-4px_0_24px_rgba(0,0,0,0.02)] flex flex-col h-full shrink-0 overflow-y-auto z-10 no-scrollbar relative",children:e.jsxs("div",{className:"p-[24px] space-y-[24px] flex flex-col items-center",children:[e.jsxs("div",{className:"flex flex-col items-center text-center w-full",children:[e.jsx("img",{src:t.avatar,alt:t.name,className:"w-[96px] h-[96px] rounded-full object-cover shadow-[0_8px_16px_rgba(0,0,0,0.1)] mb-4 border-4 border-white z-10 relative"}),e.jsx("h2",{className:"text-[20px] font-semibold text-[#1e293b] mb-1",children:t.name}),e.jsxs("p",{className:"text-[11px] font-semibold text-[#64748b] mb-3 uppercase tracking-wider",children:["ID: ",t.id.substring(0,8)]}),e.jsx("span",{className:`text-[11px] font-semibold px-3 py-1 rounded-[14px] border ${t.riskLevel==="high"?"text-rose-600 bg-rose-50 border-rose-100":t.riskLevel==="medium"?"text-amber-600 bg-amber-50 border-amber-100":"text-emerald-600 bg-emerald-50 border-emerald-100"}`,children:t.riskLevel==="high"?"High Risk":t.riskLevel==="medium"?"Medium Risk":"Low Risk"})]}),e.jsxs("div",{className:"w-full grid grid-cols-2 gap-[12px]",children:[e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Avg Score"}),e.jsxs("p",{className:"text-[20px] font-bold text-[#4f46e5]",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Engagement"}),e.jsx("p",{className:"text-[20px] font-bold text-[#1e293b]",children:t.avgScore>80?"High":t.avgScore>50?"Medium":"Low"})]}),e.jsxs("div",{className:"bg-white/80 rounded-[14px] p-4 border border-white shadow-[0_1px_4px_rgba(0,0,0,0.02)] text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1",children:"Last Active"}),e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] mt-1",children:t.lastActive})]}),e.jsxs("div",{className:"bg-rose-50/60 rounded-[14px] p-4 border border-rose-100 text-left flex flex-col justify-center",children:[e.jsx("p",{className:"text-[11px] font-semibold text-rose-600 uppercase tracking-wider mb-1",children:"Weakest Topic"}),e.jsx("p",{className:"text-[12px] font-semibold text-[#1e293b] mt-1 leading-snug break-words",title:t.weakestTopic,children:t.weakestTopic})]})]}),e.jsx("div",{className:"w-full flex flex-col gap-[10px]",children:e.jsxs("button",{onClick:async()=>{Z("choose"),R(!0)},className:"w-full flex items-center justify-center gap-2 bg-white hover:bg-[#f8fafc] text-[#475569] border border-[#cbd5e1] hover:border-[#94a3b8] text-[13px] font-semibold rounded-full px-4 py-3 shadow-[0_1px_4px_rgba(0,0,0,0.04)] transition-transform hover:scale-[1.02]",children:[e.jsx(Rc,{className:"w-4 h-4"})," Export Materials"]})}),T&&Ar.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",onClick:()=>R(!1),children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-[24px] shadow-[0_24px_64px_rgba(0,0,0,0.18)] w-full max-w-[460px] z-10 overflow-hidden",onClick:P=>P.stopPropagation(),children:[e.jsx("div",{className:"bg-gradient-to-r from-[#a855f7] to-[#9333ea] px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[K==="bank"&&e.jsx("button",{onClick:()=>Z("choose"),className:"w-7 h-7 rounded-full bg-white/20 hover:bg-white/30 flex items-center justify-center text-white transition-colors mr-1",children:e.jsx(Ss,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-8 h-8 rounded-[8px] bg-white/20 flex items-center justify-center",children:e.jsx(Dr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[15px] font-bold text-white leading-tight",children:K==="choose"?"Export Materials":"Choose a Quiz"}),e.jsx("p",{className:"text-[11px] text-white/70 font-medium",children:K==="choose"?`For ${t.name}`:"Select a quiz from your bank"})]})]}),e.jsx("button",{onClick:()=>R(!1),className:"w-7 h-7 rounded-full bg-white/20 hover:bg-white/30 flex items-center justify-center text-white transition-colors",children:e.jsx(cs,{className:"w-4 h-4"})})]})}),e.jsx("div",{className:"p-6",children:K==="choose"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[13px] text-[#64748b] mb-5 font-medium",children:"How would you like to proceed?"}),e.jsxs("button",{onClick:async()=>{oe(!0),Z("bank");try{const P=await ai(s);le(P)}catch{le([])}finally{oe(!1)}},className:"w-full flex items-start gap-4 p-4 rounded-[16px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_4px_12px_rgba(168,85,247,0.08)] hover:bg-purple-50/30 transition-all group mb-3 text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-[10px] bg-purple-50 border border-purple-100 flex items-center justify-center shrink-0 group-hover:bg-purple-100 transition-colors",children:e.jsx(Za,{className:"w-5 h-5 text-[#a855f7]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-0.5",children:"Choose from existing quizzes"}),e.jsx("p",{className:"text-[12px] text-[#64748b] font-medium",children:"Pick a quiz already in your Quiz Bank."})]})]}),e.jsxs("button",{onClick:()=>{R(!1),fe(!1),we(!0)},className:"w-full flex items-start gap-4 p-4 rounded-[16px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_4px_12px_rgba(168,85,247,0.08)] hover:bg-purple-50/30 transition-all group text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-[10px] bg-purple-50 border border-purple-100 flex items-center justify-center shrink-0 group-hover:bg-purple-100 transition-colors",children:e.jsx($s,{className:"w-5 h-5 text-[#a855f7]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#1e293b] mb-0.5",children:"Create a new quiz"}),e.jsx("p",{className:"text-[12px] text-[#64748b] font-medium",children:"Use AI Quiz Maker. You can return here when done."})]})]})]}):e.jsx("div",{children:$?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-[#a855f7] border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-[13px] text-[#64748b] font-medium",children:"Loading quizzes..."})]}):re.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-purple-50 flex items-center justify-center",children:e.jsx(Za,{className:"w-6 h-6 text-[#a855f7]"})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:"No quizzes yet"}),e.jsx("p",{className:"text-[12px] text-[#64748b]",children:"Create your first quiz using the AI Quiz Maker."})]}):e.jsx("div",{className:"space-y-3 max-h-[320px] overflow-y-auto pr-1",children:re.map(P=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 rounded-[14px] border border-slate-200 hover:border-[#a855f7] hover:shadow-[0_2px_8px_rgba(168,85,247,0.08)] transition-all group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-bold text-[#1e293b] truncate",children:P.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] font-medium mt-0.5",children:[P.questions?.length??0," questions",P.gradeLevel?` · ${P.gradeLevel}`:"",P.metadata?.topicsCovered?.[0]?` · ${P.metadata.topicsCovered[0]}`:""]})]}),e.jsx("button",{onClick:()=>{R(!1),me.success(`"${P.title}" selected for ${t.name}`)},className:"shrink-0 px-3 py-1.5 rounded-full bg-[#a855f7] text-white text-[11px] font-bold hover:bg-[#9333ea] transition-colors shadow-sm",children:"Assign"})]},P.id))})})})]})]}),document.body),pe&&Ar.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/40 backdrop-blur-sm",onClick:()=>{se?Fe(!0):we(!1)}}),e.jsxs("div",{className:"fixed top-0 right-0 z-[9999] h-full w-full max-w-[88vw] xl:max-w-[1080px] bg-white shadow-[-8px_0_40px_rgba(0,0,0,0.15)] flex flex-col",style:{animation:"slideInFromRight 0.3s cubic-bezier(0.16,1,0.3,1)"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-slate-100 bg-white shrink-0",children:[e.jsxs("button",{onClick:()=>{se?Fe(!0):we(!1)},className:"flex items-center gap-2 text-[13px] font-semibold text-[#4f46e5] hover:text-[#3730a3] transition-colors bg-indigo-50 hover:bg-indigo-100 px-4 py-2 rounded-full",children:[e.jsx(Xa,{className:"w-4 h-4"}),"Back to ",t.name]}),e.jsx("div",{className:"h-5 w-px bg-slate-200"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-[8px] bg-gradient-to-br from-[#a855f7] to-[#9333ea] flex items-center justify-center",children:e.jsx(Dr,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:"text-[14px] font-bold text-[#1e293b]",children:"AI Quiz Maker"})]}),se&&e.jsx("span",{className:"ml-auto text-[11px] font-semibold text-amber-600 bg-amber-50 border border-amber-200 px-2.5 py-0.5 rounded-full",children:"Quiz in progress"})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Yi,{onBack:()=>we(!1),drawerMode:!0,gradeLevel:t.grade,onQuizGenerating:()=>fe(!0),onQuizSaved:P=>{fe(!1),me.success("Quiz saved! Close this panel or create another.",{action:{label:"Close Panel",onClick:()=>we(!1)}})}})})]}),et&&e.jsxs("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>Fe(!1)}),e.jsxs("div",{className:"relative bg-white rounded-[20px] shadow-[0_24px_60px_rgba(0,0,0,0.2)] w-full max-w-[380px] p-7 z-10",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-amber-50 border border-amber-200 flex items-center justify-center mb-4",children:e.jsx(or,{className:"w-5 h-5 text-amber-500"})}),e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b] mb-2",children:"Discard quiz progress?"}),e.jsx("p",{className:"text-[13px] text-[#64748b] font-medium mb-6",children:"Your current quiz session will be lost if you close this panel. This cannot be undone."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>Fe(!1),className:"flex-1 py-2.5 rounded-full border border-slate-200 text-[13px] font-semibold text-[#475569] hover:bg-slate-50 transition-colors",children:"Keep editing"}),e.jsx("button",{onClick:()=>{Fe(!1),we(!1),fe(!1)},className:"flex-1 py-2.5 rounded-full bg-rose-500 hover:bg-rose-600 text-white text-[13px] font-semibold transition-colors",children:"Discard & close"})]})]})]}),e.jsx("style",{children:` - @keyframes slideInFromRight { - from { transform: translateX(100%); opacity: 0.6; } - to { transform: translateX(0); opacity: 1; } - } - `})]}),document.body),e.jsxs("div",{className:"w-full bg-white/80 rounded-[18px] p-[20px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-auto",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[#1e293b] mb-4",children:"Section Assignment"}),e.jsxs("div",{className:"space-y-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5 block ml-1",children:"Grade Level"}),e.jsx("div",{className:"relative",children:e.jsx(ws,{value:j,onChange:P=>S(P.target.value),placeholder:"Grade",className:"appearance-none w-full bg-[#f8fafc] border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[14px] px-4 py-2.5 outline-none focus:border-[#a855f7] focus:ring-1 focus:ring-[#a855f7] h-auto"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider mb-1.5 block ml-1",children:"Section"}),e.jsx("div",{className:"relative",children:e.jsx(ws,{value:p,onChange:P=>N(P.target.value),placeholder:"Section",className:"appearance-none w-full bg-[#f8fafc] border border-[#e2e8f0] text-[#475569] text-[13px] font-medium rounded-[14px] px-4 py-2.5 outline-none focus:border-[#a855f7] focus:ring-1 focus:ring-[#a855f7] h-auto"})})]}),e.jsx("button",{onClick:ss,disabled:C||!j.trim()||!p.trim(),className:"w-full bg-white hover:bg-[#f8fafc] disabled:opacity-50 text-[#4f46e5] border border-[#e0e7ff] text-[13px] font-semibold rounded-[14px] px-4 py-2.5 transition-colors shadow-[0_1px_4px_rgba(0,0,0,0.02)] mt-2",children:C?"Updating...":"Update Assignment"})]})]})]})})]})},Yo=({onViewCalendar:t,onOpenProfile:s,userProfile:a,teacherName:r,liveActivity:o=[]})=>{const{currentUser:n}=ds(),[i,l]=m.useState(new Date),[c,d]=m.useState("pulse"),[u,f]=m.useState([]),[h,b]=m.useState(!1);m.useEffect(()=>{if(!n?.uid)return;const w=Ji(n.uid,{limitCount:100},A=>f(A),()=>{});return()=>w()},[n?.uid]);const k=w=>new Date(w.getFullYear(),w.getMonth()+1,0).getDate(),j=w=>new Date(w.getFullYear(),w.getMonth(),1).getDay(),S=()=>i.toLocaleDateString(void 0,{month:"long",year:"numeric"}),p=()=>l(new Date(i.getFullYear(),i.getMonth()-1)),N=()=>l(new Date(i.getFullYear(),i.getMonth()+1)),C=()=>{const w=k(i),A=j(i),B=[];for(let E=A-1;E>=0;E--)B.unshift(null);for(let E=1;E<=w;E++)B.push(E);return B},z=w=>{if(!w)return!1;const A=new Date;return w===A.getDate()&&i.getMonth()===A.getMonth()&&i.getFullYear()===A.getFullYear()},I=C(),U=["Mo","Tu","We","Th","Fr","Sa","Su"],v=w=>{if(!w)return!1;const A=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(w).padStart(2,"0")}`;return u.some(B=>{const E=new Date(B.startTime);return`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`===A})},y=w=>{if(!w)return;const A=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(w).padStart(2,"0")}`,B=u.filter(E=>{const F=new Date(E.startTime);return`${F.getFullYear()}-${String(F.getMonth()+1).padStart(2,"0")}-${String(F.getDate()).padStart(2,"0")}`===A});if(B.length!==0)return B.map(E=>`• ${E.title}`).join(` -`)};return e.jsxs("aside",{className:"w-[280px] bg-white border-l border-[#e2e8f0] flex flex-col flex-shrink-0 overflow-hidden",children:[e.jsxs("div",{className:"p-[22px_16px_10px] border-b border-[#f1f5f9] flex flex-col items-center gap-[5px]",children:[e.jsx("div",{className:"w-[48px] h-[48px] rounded-full bg-[#e0e7ff] flex items-center justify-center text-[22px] text-[#4f46e5] shadow-[0_0_0_3px_#c7d2fe] flex-shrink-0",children:e.jsx(kl,{src:a?.photo,name:r,className:"w-full h-full rounded-full"})}),e.jsx("div",{className:"text-[13.5px] font-semibold text-[#1e293b] mt-1",children:r}),e.jsx("div",{className:"text-[11px] text-[#94a3b8]",children:"Teacher"}),e.jsx("button",{onClick:s,className:"mt-[4px] py-[6px] px-[22px] bg-[#818cf8] hover:bg-[#6366f1] text-white rounded-full text-[11.5px] font-medium transition-colors",children:"Profile"})]}),e.jsxs("div",{className:"border-b border-[#f1f5f9]",children:[e.jsxs("div",{className:"p-[10px_16px_8px] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:w=>{w.stopPropagation(),p()},className:"w-6 h-6 flex items-center justify-center bg-white border border-[#e2e8f0] rounded-[7px] text-[#64748b] hover:bg-[#f8fafc] cursor-pointer text-[14px] z-10",children:e.jsx(Ss,{size:14})}),e.jsx("span",{className:"text-[12px] font-semibold text-[#1e293b] hover:text-[#4f46e5] transition-colors cursor-pointer",onClick:t,children:S()}),e.jsx("button",{onClick:w=>{w.stopPropagation(),N()},className:"w-6 h-6 flex items-center justify-center bg-white border border-[#e2e8f0] rounded-[7px] text-[#64748b] hover:bg-[#f8fafc] cursor-pointer text-[14px] z-10",children:e.jsx(ys,{size:14})})]}),e.jsx("button",{onClick:()=>b(w=>!w),className:"w-6 h-6 flex items-center justify-center rounded-[7px] text-[#94a3b8] hover:bg-[#f1f5f9] hover:text-[#64748b] transition-colors",title:h?"Show calendar":"Hide calendar","aria-label":h?"Expand calendar":"Collapse calendar",children:e.jsx(Tt,{size:14,className:`transition-transform duration-200 ${h?"":"rotate-180"}`})})]}),e.jsx(Et,{initial:!1,children:!h&&e.jsx(Re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22,ease:"easeInOut"},className:"overflow-hidden",children:e.jsx("div",{className:"px-[16px] pb-[10px] cursor-pointer hover:bg-slate-50 transition-colors group/cal",onClick:t,children:e.jsxs("div",{className:"grid grid-cols-7 gap-[2px] text-center mb-1",children:[U.map(w=>e.jsx("div",{className:"text-[10px] font-semibold text-[#94a3b8] p-[2px_0_4px]",children:w},w)),I.map((w,A)=>e.jsxs("div",{className:"relative flex flex-col items-center justify-center h-[28px]",title:y(w),children:[e.jsx("div",{className:`text-[11px] leading-[22px] w-[22px] h-[22px] flex items-center justify-center rounded-full transition-all ${w===null?"text-[#cbd5e1]":z(w)?"bg-[#818cf8] text-white font-semibold":"text-[#475569] group-hover/cal:bg-slate-100"}`,children:w}),w!==null&&v(w)&&e.jsx("div",{className:`absolute bottom-0 w-1 h-1 rounded-full ${z(w)?"bg-white":"bg-[#a855f7]"}`})]},`${i.getMonth()}-${A}`))]})})},"cal-grid")})]}),e.jsxs("div",{className:"flex gap-[18px] p-[12px_16px_0] border-b border-[#f1f5f9] flex-shrink-0",children:[e.jsx("button",{onClick:()=>d("pulse"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${c==="pulse"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Live pulse"}),e.jsx("button",{onClick:()=>d("reminders"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${c==="reminders"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Reminders"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-[14px_16px]",children:[c==="pulse"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[10px] font-bold text-[#64748b] uppercase tracking-wider",children:"Live Activity Stream"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[9px] font-bold text-emerald-600",children:"LIVE"})]})]}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center opacity-40",children:[e.jsx(si,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#1e293b]",children:"No recent activity"})]}):e.jsx("div",{className:"space-y-4",children:o.slice(0,5).map(w=>e.jsxs("div",{className:"relative pl-5 before:absolute before:left-1.5 before:top-2 before:bottom-[-16px] before:w-[1px] before:bg-slate-100 last:before:hidden",children:[e.jsx("div",{className:"absolute left-0 top-1.5 w-3 h-3 rounded-full border-2 border-white bg-indigo-500 shadow-sm z-10"}),e.jsxs("div",{className:"bg-white border border-[#f1f5f9] rounded-xl p-3 shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsx("span",{className:"text-[12px] font-bold text-[#1e293b] truncate",children:w.student}),e.jsx("span",{className:"text-[9px] font-medium text-[#94a3b8] shrink-0",children:w.time})]}),e.jsxs("p",{className:"text-[11px] text-[#64748b] leading-snug",children:[w.action," ",e.jsx("span",{className:"font-bold text-[#4f46e5]",children:w.topic})]})]})]},w.id))})]}),c==="reminders"&&e.jsxs("div",{className:"space-y-3",children:[u.filter(w=>{const A=new Date;return A.setHours(0,0,0,0),new Date(w.startTime).getTime()>=A.getTime()}).sort((w,A)=>new Date(w.startTime).getTime()-new Date(A.startTime).getTime()).slice(0,5).map(w=>{const A=new Date(w.startTime).toDateString()===new Date().toDateString();return e.jsxs("div",{onClick:t,className:"flex items-start gap-3 p-3 border border-[#f1f5f9] rounded-[14px] cursor-pointer hover:bg-slate-50 transition-colors group",children:[e.jsx("div",{className:`p-2 rounded-xl border border-[#f1f5f9] bg-white text-[14px] flex-shrink-0 shadow-sm transition-transform group-hover:scale-105 ${A?"text-rose-500":"text-[#4f46e5]"}`,children:e.jsx(Ya,{size:14})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-bold text-[#1e293b] mb-0.5 truncate",children:w.title}),e.jsxs("div",{className:`text-[10px] font-medium ${A?"text-rose-500 font-bold":"text-[#94a3b8]"}`,children:[A?"Today, ":"",new Date(w.startTime).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]},w.id)}),u.filter(w=>new Date(w.startTime).getTime()>=new Date().setHours(0,0,0,0)).length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center opacity-40",children:[e.jsx(Ja,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#1e293b]",children:"No upcoming tasks"})]})]})]})]})};export{bp as default}; diff --git a/assets/XPNotification-Bj_GZruU.js b/assets/XPNotification-BlLePAZH.js similarity index 92% rename from assets/XPNotification-Bj_GZruU.js rename to assets/XPNotification-BlLePAZH.js index 128384e25b0b1e522f75cbec82e9d2b139127cc5..73370a3a031a9718ced55e2a060ec38c4cddee09 100644 --- a/assets/XPNotification-Bj_GZruU.js +++ b/assets/XPNotification-BlLePAZH.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{h as n,m as i,a5 as m}from"./index-dPnhhJ9w.js";import{S as c}from"./sparkles-DPFO64ZX.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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{h as n,m as i,a5 as m}from"./index-CGNBpSmO.js";import{S as c}from"./sparkles-C0ju-UTT.js";import"./vendor-firebase-firestore-CNv3xXal.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-aNpxrln-.js b/assets/automationService-BaY4ockN.js similarity index 98% rename from assets/automationService-aNpxrln-.js rename to assets/automationService-BaY4ockN.js index 487da77fa1dbf3451efd5cc2f30a0ef363d0397e..36536bca224cad3199a8fe44b03a277ccb652b23 100644 --- a/assets/automationService-aNpxrln-.js +++ b/assets/automationService-BaY4ockN.js @@ -1 +1 @@ -import{doc as g,collection as a,serverTimestamp as c,setDoc as l,addDoc as D,query as b,where as z,getDocs as A,updateDoc as C,writeBatch as Q}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as r,b3 as $}from"./index-dPnhhJ9w.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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=b(n,z("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=b(s,z("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 b,where as z,getDocs as A,updateDoc as C,writeBatch as Q}from"./vendor-firebase-firestore-CNv3xXal.js";import{g as r,b3 as $}from"./index-CGNBpSmO.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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=b(n,z("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=b(s,z("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-cxZiilDJ.js b/assets/bell-DbwiSyKd.js similarity index 91% rename from assets/bell-cxZiilDJ.js rename to assets/bell-DbwiSyKd.js index 13ee0abe07a0827d4a21131db4c88d1fb10484a4..4b881a53f57590fdcab971768e7fe0dcfb832dd0 100644 --- a/assets/bell-cxZiilDJ.js +++ b/assets/bell-DbwiSyKd.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/button-WbM5w2Bp.js b/assets/button-DVjn4LkC.js similarity index 97% rename from assets/button-WbM5w2Bp.js rename to assets/button-DVjn4LkC.js index 4453a7a4c821c96e189ef2cf2ec0e760277f20bf..a6695e3cf4b7f48312841948acb4b5f699b35c51 100644 --- a/assets/button-WbM5w2Bp.js +++ b/assets/button-DVjn4LkC.js @@ -1 +1 @@ -import{j as y}from"./vendor-react-B4AQeu28.js";import{S as k}from"./vendor-radix-BPuEd8FG.js";import{c as V}from"./vendor-charts-D7t7JfSr.js";import{n as p}from"./index-dPnhhJ9w.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-BPuEd8FG.js";import{c as V}from"./vendor-charts-D7t7JfSr.js";import{n as p}from"./index-CGNBpSmO.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/chart-column-DtQRo3DE.js b/assets/chart-column-g5DztEPT.js similarity index 89% rename from assets/chart-column-DtQRo3DE.js rename to assets/chart-column-g5DztEPT.js index d8b89f4ab7ba5d9327a6d3f61d2ef18335925b8b..7a9cd3447c05f6af2ab2672e90d16bd70e2fb54c 100644 --- a/assets/chart-column-DtQRo3DE.js +++ b/assets/chart-column-g5DztEPT.js @@ -1,4 +1,4 @@ -import{e as t}from"./index-dPnhhJ9w.js";/** +import{e as t}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chatService-BKpYR5sK.js b/assets/chatService-v4NqPDUe.js similarity index 97% rename from assets/chatService-BKpYR5sK.js rename to assets/chatService-v4NqPDUe.js index 665106ec80cf2f6c3addd3ea711b704d9c7484a0..027464c2533536543371c814fb52f9c7a510b84a 100644 --- a/assets/chatService-BKpYR5sK.js +++ b/assets/chatService-v4NqPDUe.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-CNv3xXal.js";import{g as a}from"./index-dPnhhJ9w.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-CNv3xXal.js";import{g as a}from"./index-CGNBpSmO.js";import"./vendor-firebase-core-D7GXCeNu.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-T_wvTOvf.js";import"./vendor-firebase-storage-Bi7H_66d.js";import"./vendor-firebase-analytics-rHarj5hR.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.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-CAUeuCaw.js b/assets/check-BfYhdun3.js similarity index 85% rename from assets/check-CAUeuCaw.js rename to assets/check-BfYhdun3.js index 5d6fa2c88536bb7fb588205d19831faecaeda82b..3049a0887e275bba31c4bedc88c3ba1159e97da1 100644 --- a/assets/check-CAUeuCaw.js +++ b/assets/check-BfYhdun3.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-dPnhhJ9w.js";/** +import{e as c}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-left-DfHtS3Om.js b/assets/chevron-left-BuATOj9f.js similarity index 86% rename from assets/chevron-left-DfHtS3Om.js rename to assets/chevron-left-BuATOj9f.js index ab4be89b3402f149e3243346caa7f7b3dd652940..2a7bbe3e97e67eca233718948186fe108b45a8dd 100644 --- a/assets/chevron-left-DfHtS3Om.js +++ b/assets/chevron-left-BuATOj9f.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-right-DL17FiOB.js b/assets/chevron-right-C39hNstc.js similarity index 85% rename from assets/chevron-right-DL17FiOB.js rename to assets/chevron-right-C39hNstc.js index 077850bfe74026ab25d1af6677cb2565ce7f8fbf..5bd6a4cdaa60c39742f18806da765ce7ee486510 100644 --- a/assets/chevron-right-DL17FiOB.js +++ b/assets/chevron-right-C39hNstc.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-dPnhhJ9w.js";/** +import{e as o}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chevron-up-D9yeZehY.js b/assets/chevron-up-B59xV3SY.js similarity index 92% rename from assets/chevron-up-D9yeZehY.js rename to assets/chevron-up-B59xV3SY.js index 85a2045975b38e543434bad818239657c2c9b1c8..d1e99ba3a288929c6a87225aa18091b7ee1c19f1 100644 --- a/assets/chevron-up-D9yeZehY.js +++ b/assets/chevron-up-B59xV3SY.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-dPnhhJ9w.js";/** +import{e as o}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-alert-DCyh_PVA.js b/assets/circle-alert-fZn6_hMx.js similarity index 90% rename from assets/circle-alert-DCyh_PVA.js rename to assets/circle-alert-fZn6_hMx.js index 6cc1ff0a97082e6869a9e52c48376cc6adc0c080..544bdbe81f25b4824708666524a04f32e60e869d 100644 --- a/assets/circle-alert-DCyh_PVA.js +++ b/assets/circle-alert-fZn6_hMx.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-BjsGkfB1.js b/assets/circle-check-BhLH88x1.js similarity index 87% rename from assets/circle-check-BjsGkfB1.js rename to assets/circle-check-BhLH88x1.js index dc5052277f295173cad0c35945f3f899aa041487..a4defd2be60dc40bcc8ae3630fa46bf02675d814 100644 --- a/assets/circle-check-BjsGkfB1.js +++ b/assets/circle-check-BhLH88x1.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-dPnhhJ9w.js";/** +import{e as c}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-big-DJBKLvuw.js b/assets/circle-check-big-yCNC9yfs.js similarity index 88% rename from assets/circle-check-big-DJBKLvuw.js rename to assets/circle-check-big-yCNC9yfs.js index 8f794ede2601c44a33148d90f9ebc0d5e10c01de..e867d4a4746be572bd7aa148aee3d3d337e32592 100644 --- a/assets/circle-check-big-DJBKLvuw.js +++ b/assets/circle-check-big-yCNC9yfs.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-dPnhhJ9w.js";/** +import{e as c}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-help-BkKMcGF2.js b/assets/circle-help-DMiD6EQw.js similarity index 89% rename from assets/circle-help-BkKMcGF2.js rename to assets/circle-help-DMiD6EQw.js index 3c72ebea05d8262b30b9cc55e1f2d126f4563214..277c1905e89229f1a0ee3d423246d1b214d6771a 100644 --- a/assets/circle-help-BkKMcGF2.js +++ b/assets/circle-help-DMiD6EQw.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-dPnhhJ9w.js";/** +import{e as c}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/clipboard-check-DfL2oC8x.js b/assets/clipboard-check-DSPNHJXj.js similarity index 91% rename from assets/clipboard-check-DfL2oC8x.js rename to assets/clipboard-check-DSPNHJXj.js index 7465fa7a4a7575894cbb75eb25f0e1049a39d1a9..5a8311d7162c316294abaf6c8932e4fd9a716162 100644 --- a/assets/clipboard-check-DfL2oC8x.js +++ b/assets/clipboard-check-DSPNHJXj.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/clock-Dy5eVj9o.js b/assets/clock-D2bky9WI.js similarity index 87% rename from assets/clock-Dy5eVj9o.js rename to assets/clock-D2bky9WI.js index 0cb4d63c570799c0ef4cdda48aad56d63c42390b..b93a9b916ec96cf435dd0c14f59a0f86cded3eca 100644 --- a/assets/clock-Dy5eVj9o.js +++ b/assets/clock-D2bky9WI.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-dPnhhJ9w.js";/** +import{e as c}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/diagnosticService-ukrfKIf7.js b/assets/diagnosticService-DLw8ENQS.js similarity index 93% rename from assets/diagnosticService-ukrfKIf7.js rename to assets/diagnosticService-DLw8ENQS.js index d144766d3cc565ba2722772bd4ed2a42c25f8bed..ff9940631e41c77d61b57996f357a80bcc5081ba 100644 --- a/assets/diagnosticService-ukrfKIf7.js +++ b/assets/diagnosticService-DLw8ENQS.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-dPnhhJ9w.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); -import{_ as w}from"./index-dPnhhJ9w.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-dPnhhJ9w.js").then(a=>a.b5);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-dPnhhJ9w.js").then(r=>r.b5);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}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGNBpSmO.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CEL3Ax6X.css"])))=>i.map(i=>d[i]); +import{_ as w}from"./index-CGNBpSmO.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-CGNBpSmO.js").then(a=>a.b5);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-CGNBpSmO.js").then(r=>r.b5);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-C4ok-Axi.js b/assets/dialog-DDOyFRnI.js similarity index 96% rename from assets/dialog-C4ok-Axi.js rename to assets/dialog-DDOyFRnI.js index 65438bba656c38530d6684bcce761c101f2844a5..0a03e94717f27979702fe35c5dd6dfdbf241030d 100644 --- a/assets/dialog-C4ok-Axi.js +++ b/assets/dialog-DDOyFRnI.js @@ -1,4 +1,4 @@ -import{e as g,n as s}from"./index-dPnhhJ9w.js";import{j as t,r as d}from"./vendor-react-B4AQeu28.js";import{b as m,c as l,d as p,T as n,D as i,P as u,O as r}from"./vendor-radix-BPuEd8FG.js";import{X as x}from"./x-Ck4mo_h-.js";/** +import{e as g,n as s}from"./index-CGNBpSmO.js";import{j as t,r as d}from"./vendor-react-B4AQeu28.js";import{b as m,c as l,d as p,T as n,D as i,P as u,O as r}from"./vendor-radix-BPuEd8FG.js";import{X as x}from"./x-Deb9zs8O.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/dollar-sign-CQIhGvzp.js b/assets/dollar-sign-CZpwYJk-.js similarity index 89% rename from assets/dollar-sign-CQIhGvzp.js rename to assets/dollar-sign-CZpwYJk-.js index 50c40ce6749717b8e52bfc093ed56be86c783269..b093e2f3b62d1c4069c0951348ddba774d5b14ac 100644 --- a/assets/dollar-sign-CQIhGvzp.js +++ b/assets/dollar-sign-CZpwYJk-.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/download-B80nBe--.js b/assets/download-Dg4u7Zq0.js similarity index 89% rename from assets/download-B80nBe--.js rename to assets/download-Dg4u7Zq0.js index b2ef52fa75c25e2f6c4cc1c813cd95c72df50871..e6e89a1392f3518367fcce0bfe1b146a70309433 100644 --- a/assets/download-B80nBe--.js +++ b/assets/download-Dg4u7Zq0.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-dPnhhJ9w.js";/** +import{e as o}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/eye-BmZ1sFKD.js b/assets/eye-_x45syMF.js similarity index 96% rename from assets/eye-BmZ1sFKD.js rename to assets/eye-_x45syMF.js index 7d1ae40146462eeb5ba1a46887e497cd8712ec20..525a01d211b0a3d1f09ee80de520ea793d6b1d98 100644 --- a/assets/eye-BmZ1sFKD.js +++ b/assets/eye-_x45syMF.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/formatDistanceToNow-JAG-bydR.js b/assets/formatDistanceToNow-Csp8CCDy.js similarity index 99% rename from assets/formatDistanceToNow-JAG-bydR.js rename to assets/formatDistanceToNow-Csp8CCDy.js index dcccc385221c90092fb5cbbb6648cb43b4686b29..92885cfc403d3e1ea9ea893c60c4d6fe5ffc2542 100644 --- a/assets/formatDistanceToNow-JAG-bydR.js +++ b/assets/formatDistanceToNow-Csp8CCDy.js @@ -1,4 +1,4 @@ -import{e as W,t as u,a8 as S}from"./index-dPnhhJ9w.js";/** +import{e as W,t as u,a8 as S}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/funnel-Bt7LE1rx.js b/assets/funnel-pOzgdLsf.js similarity index 90% rename from assets/funnel-Bt7LE1rx.js rename to assets/funnel-pOzgdLsf.js index 997b3c37545439fd01be7ffc9170e729acc471e9..95e7542a546914a07a37a3ed983f0c7c0093dcd5 100644 --- a/assets/funnel-Bt7LE1rx.js +++ b/assets/funnel-pOzgdLsf.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/history-CL_DqqWk.js b/assets/history-Dajczx-K.js similarity index 94% rename from assets/history-CL_DqqWk.js rename to assets/history-Dajczx-K.js index d57ae91d8909f9369c9addfdb8a246c6deb924f9..e71736ac16b20cd13b312f5117f61afbb7b5f479 100644 --- a/assets/history-CL_DqqWk.js +++ b/assets/history-Dajczx-K.js @@ -1,4 +1,4 @@ -import{e}from"./index-dPnhhJ9w.js";/** +import{e}from"./index-CGNBpSmO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/index-dPnhhJ9w.js b/assets/index-CGNBpSmO.js similarity index 55% rename from assets/index-dPnhhJ9w.js rename to assets/index-CGNBpSmO.js index 8d04795bc5682c1776e084291e2727ab36c6c774..01b7d4b09d7434db18ac0924aadaa39a886bdabf 100644 --- a/assets/index-dPnhhJ9w.js +++ b/assets/index-CGNBpSmO.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/automationService-aNpxrln-.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/chatService-BKpYR5sK.js","assets/trackingService-DGIx7EWv.js","assets/LoginPage-DktsN1Jx.js","assets/button-WbM5w2Bp.js","assets/input-BUQJctP7.js","assets/sparkles-DPFO64ZX.js","assets/mail-DiIt1YFo.js","assets/eye-BmZ1sFKD.js","assets/shield-check-CS0qf70Z.js","assets/TeacherDashboard-MZLi5zPU.js","assets/ConfirmModal-CtRcSVjb.js","assets/x-Ck4mo_h-.js","assets/trash-2-BCXZR1t7.js","assets/log-out-BUfoSJF2.js","assets/search-DqYX8akO.js","assets/check-CAUeuCaw.js","assets/plus-BIEera7J.js","assets/NotificationDropdown-CMhB7x-Z.js","assets/formatDistanceToNow-JAG-bydR.js","assets/bell-cxZiilDJ.js","assets/circle-check-BjsGkfB1.js","assets/circle-alert-DCyh_PVA.js","assets/LogoutActionButton-USB3vnm6.js","assets/quizService-DyO77cdL.js","assets/tooltip-Dz2m8mUv.js","assets/circle-help-BkKMcGF2.js","assets/send-C3s19g5N.js","assets/chevron-up-D9yeZehY.js","assets/minus-BpJABcv4.js","assets/chart-column-DtQRo3DE.js","assets/history-CL_DqqWk.js","assets/download-B80nBe--.js","assets/chevron-left-DfHtS3Om.js","assets/chevron-right-DL17FiOB.js","assets/save-DxX0wJjA.js","assets/upload-Dezt40XU.js","assets/useQuery-C1X-hCq5.js","assets/subjects-DzQfiusb.js","assets/useCurriculum-BbSzWiM_.js","assets/circle-check-big-DJBKLvuw.js","assets/ChatMarkdown-3H5bHtZy.js","assets/clock-Dy5eVj9o.js","assets/dialog-C4ok-Axi.js","assets/skeleton-BOUN1xTD.js","assets/vendor-xlsx-uZelXSz_.js","assets/clipboard-check-DfL2oC8x.js","assets/AdminDashboard-D4ep7elR.js","assets/Sidebar-DT74kKuo.js","assets/shirt-DP8IJVug.js","assets/select-Ca_HQeg8.js","assets/dollar-sign-CQIhGvzp.js","assets/switch-CuAphvDQ.js","assets/useSubjectAvailability-D0TkEgbI.js","assets/HeroBanner-BqAsDsi9.js","assets/RightSidebar-C3z9K6VT.js","assets/quiz_battle_avatar-BXHPSput.js","assets/XPNotification-Bj_GZruU.js","assets/index-DCKJn8K5.js","assets/megaphone-BbTJf9po.js","assets/SupplementalBanner-Cl_1p9XH.js","assets/SupplementalPillCarousel-BCZGCjNt.js","assets/LearningPath-3spRtYqf.js","assets/ModuleFolderCard-BDMyLDzi.js","assets/CompetencyRadarChart-c4f5tOE1.js","assets/ModulesPage-TA1UiY8-.js","assets/ScientificCalculator-Cc_fXNNW.js","assets/volume-x-ChU-f35o.js","assets/lightbulb-RToQsqFn.js","assets/confetti.module-C94ZD2ww.js","assets/funnel-Bt7LE1rx.js","assets/AIChatPage-DAxLSWfo.js","assets/GradesPage-eugSRvtq.js","assets/LeaderboardPage-BSAGck0o.js","assets/useFeatureAccess-Bk0jlnA0.js","assets/QuizBattlePage-BarEesP3.js","assets/CompositeAvatar-Col05lJc.js","assets/avatarData-BuQSOXo3.js","assets/AvatarShop-DVBimCS2.js","assets/FloatingAITutor-CSkan2Lo.js","assets/maximize-2-DZunkZ7R.js","assets/RewardsModal-Cur-YLkw.js","assets/ProfileModal-BDGytXZz.js","assets/ProfilePictureUploader-BaBXPmnP.js","assets/SettingsModal-fWJefMB6.js","assets/InitialAssessmentModal-BZbG1PlT.js","assets/diagnosticService-ukrfKIf7.js","assets/AssessmentPage-D95xz_DH.js","assets/DiagnosticBreakdown-Beq-2PZi.js","assets/testResetService-BuGylbcx.js"])))=>i.map(i=>d[i]); -import{r as h,j as b,d as I,c as Tp,f as Pp}from"./vendor-react-B4AQeu28.js";import{initializeFirestore as _p,memoryLocalCache as Ep,setDoc as $e,doc as W,serverTimestamp as ce,getDoc as ve,getDocFromServer as Ho,onSnapshot as Yt,query as Dt,limit as ks,orderBy as vn,collection as Xe,getDocs as zn,updateDoc as Tt,arrayUnion as Lu,increment as fs,where as Vt,deleteDoc as Zo,Timestamp as Dn,runTransaction as Cp}from"./vendor-firebase-firestore-CNv3xXal.js";import{U as Ap,V as Rp,Y as Mp,Z as Ip,$ as Dp,a0 as Op,a1 as Lp,a2 as zp,a3 as jp}from"./vendor-firebase-core-D7GXCeNu.js";import{browserLocalPersistence as Ha,initializeAuth as Za,browserSessionPersistence as Np,inMemoryPersistence as Ka,GoogleAuthProvider as $p,createUserWithEmailAndPassword as Fp,updateProfile as Vp,signInWithEmailAndPassword as Bp,signOut as Up,onAuthStateChanged as qp,updatePassword as Gp,updateEmail as Wp,deleteUser as Hp,EmailAuthProvider as Zp,reauthenticateWithCredential as Kp}from"./vendor-firebase-auth-T_wvTOvf.js";import{g as Qp}from"./vendor-firebase-storage-Bi7H_66d.js";import{g as Xp}from"./vendor-firebase-analytics-rHarj5hR.js";import{R as Yp,I as Jp,F as em}from"./vendor-radix-BPuEd8FG.js";import{c as tm}from"./vendor-charts-D7t7JfSr.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 o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var jr=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(){}},nm=class extends jr{#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"}},zu=new nm,sm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},rm=class{#e=sm;#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)}},Ko=new rm;function om(e){setTimeout(e,0)}var im=typeof window>"u"||"Deno"in globalThis;function xt(){}function am(e,t){return typeof e=="function"?e(t):e}function cm(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Qo(e,t){return typeof e=="function"?e(t):e}function um(e,t){return typeof e=="function"?e(t):e}function Qa(e,t){const{type:n="all",exact:s,fetchStatus:r,predicate:o,queryKey:i,stale:a}=e;if(i){if(s){if(t.queryHash!==Ni(i,t.options))return!1}else if(!ps(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||r&&r!==t.state.fetchStatus||o&&!o(t))}function Xa(e,t){const{exact:n,status:s,predicate:r,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(hs(t.options.mutationKey)!==hs(o))return!1}else if(!ps(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Ni(e,t){return(t?.queryKeyHashFn||hs)(e)}function hs(e){return JSON.stringify(e,(t,n)=>Xo(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}function ps(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ps(e[n],t[n])):!1}var dm=Object.prototype.hasOwnProperty;function ju(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=Ya(e)&&Ya(t);if(!s&&!(Xo(e)&&Xo(t)))return t;const o=(s?e:Object.keys(e)).length,i=s?t:Object.keys(t),a=i.length,c=s?new Array(a):{};let u=0;for(let d=0;d{Ko.setTimeout(t,e)})}function hm(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?ju(e,t):t}function pm(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function mm(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var $i=Symbol();function Nu(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===$i?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function SR(e,t){return typeof e=="function"?e(...t):!!e}function gm(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 $u=(()=>{let e=()=>im;return{isServer(){return e()},setIsServer(t){e=t}}})();function ym(){let e,t;const n=new Promise((r,o)=>{e=r,t=o});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 bm=om;function vm(){let e=[],t=0,n=a=>{a()},s=a=>{a()},r=bm;const o=a=>{t?e.push(a):r(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&r(()=>{s(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{o(()=>{a(...c)})},schedule:o,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{s=a},setScheduler:a=>{r=a}}}var Ze=vm(),wm=class extends jr{#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}},yr=new wm;function xm(e){return Math.min(1e3*2**e,3e4)}function Fu(e){return(e??"online")==="online"?yr.isOnline():!0}var Yo=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Vu(e){let t=!1,n=0,s;const r=ym(),o=()=>r.status!=="pending",i=g=>{if(!o()){const y=new Yo(g);f(y),e.onCancel?.(y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>zu.isFocused()&&(e.networkMode==="always"||yr.isOnline())&&e.canRun(),d=()=>Fu(e.networkMode)&&e.canRun(),l=g=>{o()||(s?.(),r.resolve(g))},f=g=>{o()||(s?.(),r.reject(g))},p=()=>new Promise(g=>{s=y=>{(o()||u())&&g(y)},e.onPause?.()}).then(()=>{s=void 0,o()||e.onContinue?.()}),m=()=>{if(o())return;let g;const y=n===0?e.initialPromise:void 0;try{g=y??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(l).catch(v=>{if(o())return;const k=e.retry??($u.isServer()?0:3),S=e.retryDelay??xm,x=typeof S=="function"?S(n,v):S,T=k===!0||typeof k=="number"&&nu()?void 0:p()).then(()=>{t?f(v):m()})})};return{promise:r,status:()=>r.status,cancel:i,continue:()=>(s?.(),r),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?m():p().then(m),r)}}var Bu=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),cm(this.gcTime)&&(this.#e=Ko.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($u.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Ko.clearTimeout(this.#e),this.#e=void 0)}};function Sm(e){return{onFetch:(t,n)=>{const s=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const l=m=>{gm(m,()=>t.signal,()=>d=!0)},f=Nu(t.options,t.fetchOptions),p=async(m,g,y)=>{if(d)return Promise.reject(t.signal.reason);if(g==null&&m.pages.length)return Promise.resolve(m);const k=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:g,direction:y?"backward":"forward",meta:t.options.meta};return l(P),P})(),S=await f(k),{maxPages:x}=t.options,T=y?mm:pm;return{pages:T(m.pages,S,x),pageParams:T(m.pageParams,g,x)}};if(r&&o.length){const m=r==="backward",g=m?km:ec,y={pages:o,pageParams:i},v=g(s,y);a=await p(y,v,m)}else{const m=e??o.length;do{const g=c===0?i[0]??s.initialPageParam:ec(s,a);if(c>0&&g==null)break;a=await p(a,g),c++}while(ct.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function ec(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 km(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Tm=class extends Bu{#e;#t;#n;#r;#o;#s;#c;#i;constructor(e){super(),this.#i=!1,this.#c=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#r=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=nc(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.#c,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=nc(this.options);t.data!==void 0&&(this.setState(tc(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=hm(this.state.data,e,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#a({type:"setState",state:e})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(xt).catch(xt):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=>um(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$i||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Qo(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:!lm(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.#i||this.#l()?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#l(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#a({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 c=this.observers.find(u=>u.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,s=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},r=()=>{const c=Nu(this.options,t),d=(()=>{const l={client:this.#o,queryKey:this.queryKey,meta:this.meta};return s(l),l})();return this.#i=!1,this.options.persister?this.options.persister(c,d,this):c(d)},i=(()=>{const c={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:r};return s(c),c})();(this.#e==="infinite"?Sm(this.options.pages):this.options.behavior)?.onFetch(i,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#a({type:"fetch",meta:i.fetchOptions?.meta}),this.#s=Vu({initialPromise:t?.initialPromise,fn:i.fetchFn,onCancel:c=>{c instanceof Yo&&c.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(c,u)=>{this.#a({type:"failed",failureCount:c,error:u})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0});try{const c=await this.#s.start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#r.config.onSuccess?.(c,this),this.#r.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Yo){if(c.silent)return this.#s.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#a({type:"error",error:c}),this.#r.config.onError?.(c,this),this.#r.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#a(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,...Pm(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,...tc(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 Pm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Fu(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function tc(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function nc(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 _m=class extends Bu{#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||Em(),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.#o({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Vu({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,i)=>{this.#o({type:"failed",failureCount:o,error:i})},onPause:()=>{this.#o({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.#o({type:"pending",variables:e,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const i=await this.options.onMutate?.(e,n);i!==this.state.context&&this.#o({type:"pending",context:i,variables:e,isPaused:r})}const o=await this.#r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#o({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(i){Promise.reject(i)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(i){Promise.reject(i)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(i){Promise.reject(i)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(i){Promise.reject(i)}throw this.#o({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#o(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 Em(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Cm=class extends jr{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 _m({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=Ns(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=Ns(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=Ns(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=Ns(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=>Xa(t,n))}findAll(e={}){return this.getAll().filter(t=>Xa(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(xt))))}};function Ns(e){return e.options.scope?.id}var Am=class extends jr{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const s=t.queryKey,r=t.queryHash??Ni(s,t);let o=this.get(r);return o||(o=new Tm({client:e,queryKey:s,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(o)),o}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=>Qa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Qa(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()})})}},Rm=class{#e;#t;#n;#r;#o;#s;#c;#i;constructor(e={}){this.#e=e.queryCache||new Am,this.#t=e.mutationCache||new Cm,this.#n=e.defaultOptions||{},this.#r=new Map,this.#o=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#c=zu.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=yr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#c?.(),this.#c=void 0,this.#i?.(),this.#i=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(Qo(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}),o=this.#e.get(s.queryHash)?.state.data,i=am(t,o);if(i!==void 0)return this.#e.build(this,s).setData(i,{...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(xt).catch(xt)}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 o=r.fetch(void 0,n);return n.throwOnError||(o=o.catch(xt)),r.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(s).then(xt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Qo(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(xt).catch(xt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(xt).catch(xt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return yr.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(hs(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(s=>{ps(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#o.set(hs(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(s=>{ps(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=Ni(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===$i&&(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()}},Uu=h.createContext(void 0),kR=e=>{const t=h.useContext(Uu);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Mm=({client:e,children:t})=>(h.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Uu.Provider,{value:e,children:t}));/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/automationService-BaY4ockN.js","assets/vendor-firebase-firestore-CNv3xXal.js","assets/vendor-firebase-core-D7GXCeNu.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-T_wvTOvf.js","assets/vendor-firebase-storage-Bi7H_66d.js","assets/vendor-firebase-analytics-rHarj5hR.js","assets/vendor-radix-BPuEd8FG.js","assets/vendor-charts-D7t7JfSr.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/chatService-v4NqPDUe.js","assets/trackingService-mnaKocvn.js","assets/LoginPage-BHI-A5a1.js","assets/button-DVjn4LkC.js","assets/input-CBi6xF4I.js","assets/sparkles-C0ju-UTT.js","assets/mail-C1tKDR_N.js","assets/eye-_x45syMF.js","assets/shield-check-h8afT4cG.js","assets/TeacherDashboard-6v6okHB7.js","assets/ConfirmModal-Bjb3K2ht.js","assets/x-Deb9zs8O.js","assets/trash-2-BhQyV3WQ.js","assets/log-out-G6mObnLf.js","assets/search-C_DiQDej.js","assets/check-BfYhdun3.js","assets/plus-ck_SGnHK.js","assets/NotificationDropdown-DGCnp7MU.js","assets/formatDistanceToNow-Csp8CCDy.js","assets/bell-DbwiSyKd.js","assets/circle-check-BhLH88x1.js","assets/circle-alert-fZn6_hMx.js","assets/LogoutActionButton-ynXvSPMf.js","assets/quizService-CuH9jeN9.js","assets/tooltip-A8-ihp1Q.js","assets/circle-help-DMiD6EQw.js","assets/send-DnRgK3MX.js","assets/chevron-up-B59xV3SY.js","assets/minus-DV5fnWn8.js","assets/chart-column-g5DztEPT.js","assets/history-Dajczx-K.js","assets/download-Dg4u7Zq0.js","assets/chevron-left-BuATOj9f.js","assets/chevron-right-C39hNstc.js","assets/save-CNayyZ15.js","assets/upload-Daz-vKaw.js","assets/useQuery-C7Nbsm2w.js","assets/subjects-DP2R71lN.js","assets/useCurriculum-cH2ZLq43.js","assets/circle-check-big-yCNC9yfs.js","assets/ChatMarkdown-BAxWaDZo.js","assets/clock-D2bky9WI.js","assets/dialog-DDOyFRnI.js","assets/skeleton-C6ieN9wR.js","assets/vendor-xlsx-uZelXSz_.js","assets/clipboard-check-DSPNHJXj.js","assets/AdminDashboard-DdSNmQm3.js","assets/Sidebar-DjsHKc7l.js","assets/shirt-T-KPAkDY.js","assets/select-3FfJraPy.js","assets/dollar-sign-CZpwYJk-.js","assets/switch-bpTyEA6p.js","assets/useSubjectAvailability-iyC7Wdl7.js","assets/HeroBanner-Db1VgQom.js","assets/RightSidebar-3FHMx0H9.js","assets/quiz_battle_avatar-BXHPSput.js","assets/XPNotification-BlLePAZH.js","assets/index-GfYJDIFA.js","assets/megaphone-DFHZ2_eA.js","assets/SupplementalBanner-DqWH4k4T.js","assets/SupplementalPillCarousel-CFX0nks9.js","assets/LearningPath-B5QBkJ31.js","assets/ModuleFolderCard-dHGX9Tik.js","assets/CompetencyRadarChart-CnxqIqQb.js","assets/ModulesPage--hVGaLzB.js","assets/ScientificCalculator-Bdrlg1Yp.js","assets/volume-x-BprCnnkN.js","assets/lightbulb-CrdekHc8.js","assets/confetti.module-C94ZD2ww.js","assets/funnel-pOzgdLsf.js","assets/AIChatPage-DUfoPWot.js","assets/GradesPage-eBdPESCo.js","assets/LeaderboardPage-Bttk2eAz.js","assets/useFeatureAccess-BUoKpUf3.js","assets/QuizBattlePage-mLpt23lk.js","assets/CompositeAvatar-Col05lJc.js","assets/avatarData-BuQSOXo3.js","assets/AvatarShop-CiTbxvY9.js","assets/FloatingAITutor-BkfkayUl.js","assets/maximize-2-CwlOKVNo.js","assets/RewardsModal-DnABWb4U.js","assets/ProfileModal-Jm1jfkzc.js","assets/ProfilePictureUploader-CCiptDXE.js","assets/SettingsModal-B-pY0VOy.js","assets/InitialAssessmentModal-J2vAV5pW.js","assets/diagnosticService-DLw8ENQS.js","assets/AssessmentPage-D5fw57-T.js","assets/DiagnosticBreakdown--QQ0WiYU.js","assets/testResetService-BSxjNIGe.js"])))=>i.map(i=>d[i]); +import{r as h,j as b,d as I,c as Tp,f as Pp}from"./vendor-react-B4AQeu28.js";import{initializeFirestore as _p,memoryLocalCache as Ep,setDoc as $e,doc as W,serverTimestamp as ce,getDoc as ve,getDocFromServer as Ho,onSnapshot as Yt,query as Ot,limit as kr,orderBy as vn,collection as Xe,getDocs as zn,updateDoc as Tt,arrayUnion as Lu,increment as fr,where as Mt,deleteDoc as Zo,Timestamp as Dn,runTransaction as Cp}from"./vendor-firebase-firestore-CNv3xXal.js";import{U as Ap,V as Rp,Y as Mp,Z as Ip,$ as Dp,a0 as Op,a1 as Lp,a2 as zp,a3 as jp}from"./vendor-firebase-core-D7GXCeNu.js";import{browserLocalPersistence as Ha,initializeAuth as Za,browserSessionPersistence as Np,inMemoryPersistence as Ka,GoogleAuthProvider as $p,createUserWithEmailAndPassword as Fp,updateProfile as Vp,signInWithEmailAndPassword as Bp,signOut as Up,onAuthStateChanged as qp,updatePassword as Gp,updateEmail as Wp,deleteUser as Hp,EmailAuthProvider as Zp,reauthenticateWithCredential as Kp}from"./vendor-firebase-auth-T_wvTOvf.js";import{g as Qp}from"./vendor-firebase-storage-Bi7H_66d.js";import{g as Xp}from"./vendor-firebase-analytics-rHarj5hR.js";import{R as Yp,I as Jp,F as em}from"./vendor-radix-BPuEd8FG.js";import{c as tm}from"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var js=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(){}},nm=class extends js{#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"}},zu=new nm,rm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},sm=class{#e=rm;#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)}},Ko=new sm;function om(e){setTimeout(e,0)}var im=typeof window>"u"||"Deno"in globalThis;function xt(){}function am(e,t){return typeof e=="function"?e(t):e}function cm(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Qo(e,t){return typeof e=="function"?e(t):e}function um(e,t){return typeof e=="function"?e(t):e}function Qa(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:o,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==Ni(i,t.options))return!1}else if(!pr(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||s&&s!==t.state.fetchStatus||o&&!o(t))}function Xa(e,t){const{exact:n,status:r,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(hr(t.options.mutationKey)!==hr(o))return!1}else if(!pr(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Ni(e,t){return(t?.queryKeyHashFn||hr)(e)}function hr(e){return JSON.stringify(e,(t,n)=>Xo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function pr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>pr(e[n],t[n])):!1}var dm=Object.prototype.hasOwnProperty;function ju(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Ya(e)&&Ya(t);if(!r&&!(Xo(e)&&Xo(t)))return t;const o=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),a=i.length,c=r?new Array(a):{};let u=0;for(let d=0;d{Ko.setTimeout(t,e)})}function hm(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?ju(e,t):t}function pm(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function mm(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $i=Symbol();function Nu(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===$i?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function SR(e,t){return typeof e=="function"?e(...t):!!e}function gm(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??=t(),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var $u=(()=>{let e=()=>im;return{isServer(){return e()},setIsServer(t){e=t}}})();function ym(){let e,t;const n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var bm=om;function vm(){let e=[],t=0,n=a=>{a()},r=a=>{a()},s=bm;const o=a=>{t?e.push(a):s(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&s(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{o(()=>{a(...c)})},schedule:o,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{s=a}}}var Ze=vm(),wm=class extends js{#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}},ys=new wm;function xm(e){return Math.min(1e3*2**e,3e4)}function Fu(e){return(e??"online")==="online"?ys.isOnline():!0}var Yo=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Vu(e){let t=!1,n=0,r;const s=ym(),o=()=>s.status!=="pending",i=g=>{if(!o()){const y=new Yo(g);f(y),e.onCancel?.(y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>zu.isFocused()&&(e.networkMode==="always"||ys.isOnline())&&e.canRun(),d=()=>Fu(e.networkMode)&&e.canRun(),l=g=>{o()||(r?.(),s.resolve(g))},f=g=>{o()||(r?.(),s.reject(g))},p=()=>new Promise(g=>{r=y=>{(o()||u())&&g(y)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),m=()=>{if(o())return;let g;const y=n===0?e.initialPromise:void 0;try{g=y??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(l).catch(v=>{if(o())return;const k=e.retry??($u.isServer()?0:3),S=e.retryDelay??xm,x=typeof S=="function"?S(n,v):S,T=k===!0||typeof k=="number"&&nu()?void 0:p()).then(()=>{t?f(v):m()})})};return{promise:s,status:()=>s.status,cancel:i,continue:()=>(r?.(),s),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?m():p().then(m),s)}}var Bu=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),cm(this.gcTime)&&(this.#e=Ko.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($u.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Ko.clearTimeout(this.#e),this.#e=void 0)}};function Sm(e){return{onFetch:(t,n)=>{const r=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const l=m=>{gm(m,()=>t.signal,()=>d=!0)},f=Nu(t.options,t.fetchOptions),p=async(m,g,y)=>{if(d)return Promise.reject(t.signal.reason);if(g==null&&m.pages.length)return Promise.resolve(m);const k=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:g,direction:y?"backward":"forward",meta:t.options.meta};return l(P),P})(),S=await f(k),{maxPages:x}=t.options,T=y?mm:pm;return{pages:T(m.pages,S,x),pageParams:T(m.pageParams,g,x)}};if(s&&o.length){const m=s==="backward",g=m?km:ec,y={pages:o,pageParams:i},v=g(r,y);a=await p(y,v,m)}else{const m=e??o.length;do{const g=c===0?i[0]??r.initialPageParam:ec(r,a);if(c>0&&g==null)break;a=await p(a,g),c++}while(ct.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function ec(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function km(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Tm=class extends Bu{#e;#t;#n;#s;#o;#r;#c;#i;constructor(e){super(),this.#i=!1,this.#c=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#s=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=nc(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.#r?.promise}setOptions(e){if(this.options={...this.#c,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=nc(this.options);t.data!==void 0&&(this.setState(tc(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const n=hm(this.state.data,e,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#a({type:"setState",state:e})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(xt).catch(xt):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=>um(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$i||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Qo(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:!lm(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.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.#r&&(this.#i||this.#l()?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#l(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(u=>u.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,r=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},s=()=>{const c=Nu(this.options,t),d=(()=>{const l={client:this.#o,queryKey:this.queryKey,meta:this.meta};return r(l),l})();return this.#i=!1,this.options.persister?this.options.persister(c,d,this):c(d)},i=(()=>{const c={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:s};return r(c),c})();(this.#e==="infinite"?Sm(this.options.pages):this.options.behavior)?.onFetch(i,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#a({type:"fetch",meta:i.fetchOptions?.meta}),this.#r=Vu({initialPromise:t?.initialPromise,fn:i.fetchFn,onCancel:c=>{c instanceof Yo&&c.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(c,u)=>{this.#a({type:"failed",failureCount:c,error:u})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0});try{const c=await this.#r.start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#s.config.onSuccess?.(c,this),this.#s.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Yo){if(c.silent)return this.#r.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#a({type:"error",error:c}),this.#s.config.onError?.(c,this),this.#s.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#a(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,...Pm(n.data,this.options),fetchMeta:e.meta??null};case"success":const r={...n,...tc(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?r:void 0,r;case"error":const s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,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.#s.notify({query:this,type:"updated",action:e})})}};function Pm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Fu(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function tc(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function nc(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var _m=class extends Bu{#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Em(),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.#s?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#o({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Vu({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,i)=>{this.#o({type:"failed",failureCount:o,error:i})},onPause:()=>{this.#o({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",s=!this.#s.canStart();try{if(r)t();else{this.#o({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const i=await this.options.onMutate?.(e,n);i!==this.state.context&&this.#o({type:"pending",context:i,variables:e,isPaused:s})}const o=await this.#s.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#o({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(i){Promise.reject(i)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(i){Promise.reject(i)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(i){Promise.reject(i)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(i){Promise.reject(i)}throw this.#o({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#o(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 Em(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Cm=class extends js{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 r=new _m({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);const t=Nr(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=Nr(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Nr(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(s=>s.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Nr(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.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=>Xa(t,n))}findAll(e={}){return this.getAll().filter(t=>Xa(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(xt))))}};function Nr(e){return e.options.scope?.id}var Am=class extends js{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const r=t.queryKey,s=t.queryHash??Ni(r,t);let o=this.get(s);return o||(o=new Tm({client:e,queryKey:r,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}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=>Qa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Qa(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()})})}},Rm=class{#e;#t;#n;#s;#o;#r;#c;#i;constructor(e={}){this.#e=e.queryCache||new Am,this.#t=e.mutationCache||new Cm,this.#n=e.defaultOptions||{},this.#s=new Map,this.#o=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#c=zu.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=ys.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#c?.(),this.#c=void 0,this.#i?.(),this.#i=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),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Qo(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(r.queryHash)?.state.data,i=am(t,o);if(i!==void 0)return this.#e.build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ze.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,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(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ze.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(xt).catch(xt)}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},r=Ze.batch(()=>this.#e.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(xt)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(xt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Qo(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(xt).catch(xt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(xt).catch(xt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return ys.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.#s.set(hr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{pr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#o.set(hr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(r=>{pr(e,r.mutationKey)&&Object.assign(n,r.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=Ni(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===$i&&(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()}},Uu=h.createContext(void 0),kR=e=>{const t=h.useContext(Uu);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Mm=({client:e,children:t})=>(h.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Uu.Provider,{value:e,children:t}));/** * react-router v7.14.2 * * Copyright (c) Remix Software Inc. @@ -8,9 +8,9 @@ import{r as h,j as b,d as I,c as Tp,f as Pp}from"./vendor-react-B4AQeu28.js";imp * LICENSE.md file in the root directory of this source tree. * * @license MIT - */var sc="popstate";function rc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Im(e={}){function t(s,r){let o=r.state?.masked,{pathname:i,search:a,hash:c}=o||s.location;return Jo("",{pathname:i,search:a,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default",o?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,r){return typeof r=="string"?r:ms(r)}return Om(t,n,null,e)}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ot(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Dm(){return Math.random().toString(36).substring(2,10)}function oc(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 Jo(e,t,n=null,s,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ts(t):t,state:n,key:t&&t.key||s||Dm(),unstable_mask:r}}function ms({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 Ts(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 Om(e,t,n,s={}){let{window:r=document.defaultView,v5Compat:o=!1}=s,i=r.history,a="POP",c=null,u=d();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function d(){return(i.state||{idx:null}).idx}function l(){a="POP";let y=d(),v=y==null?null:y-u;u=y,c&&c({action:a,location:g.location,delta:v})}function f(y,v){a="PUSH";let k=rc(y)?y:Jo(g.location,y,v);u=d()+1;let S=oc(k,u),x=g.createHref(k.unstable_mask||k);try{i.pushState(S,"",x)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;r.location.assign(x)}o&&c&&c({action:a,location:g.location,delta:1})}function p(y,v){a="REPLACE";let k=rc(y)?y:Jo(g.location,y,v);u=d();let S=oc(k,u),x=g.createHref(k.unstable_mask||k);i.replaceState(S,"",x),o&&c&&c({action:a,location:g.location,delta:0})}function m(y){return Lm(y)}let g={get action(){return a},get location(){return e(r,i)},listen(y){if(c)throw new Error("A history only accepts one active listener");return r.addEventListener(sc,l),c=y,()=>{r.removeEventListener(sc,l),c=null}},createHref(y){return t(r,y)},createURL:m,encodeLocation(y){let v=m(y);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:f,replace:p,go(y){return i.go(y)}};return g}function Lm(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ie(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:ms(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function qu(e,t,n="/"){return zm(e,t,n,!1)}function zm(e,t,n,s){let r=typeof t=="string"?Ts(t):t,o=Ut(r.pathname||"/",n);if(o==null)return null;let i=Gu(e);jm(i);let a=null;for(let c=0;a==null&&c{let d={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(s)&&c)return;Ie(d.relativePath.startsWith(s),`Absolute route path "${d.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(s.length)}let l=St([s,d.relativePath]),f=n.concat(d);i.children&&i.children.length>0&&(Ie(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Gu(i.children,t,f,l,c)),!(i.path==null&&!i.index)&&t.push({path:l,score:qm(l,i.index),routesMeta:f})};return e.forEach((i,a)=>{if(i.path===""||!i.path?.includes("?"))o(i,a);else for(let c of Wu(i.path))o(i,a,!0,c)}),t}function Wu(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,r=n.endsWith("?"),o=n.replace(/\?$/,"");if(s.length===0)return r?[o,""]:[o];let i=Wu(s.join("/")),a=[];return a.push(...i.map(c=>c===""?o:[o,c].join("/"))),r&&a.push(...i),a.map(c=>e.startsWith("/")&&c===""?"/":c)}function jm(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Gm(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var Nm=/^:[\w-]+$/,$m=3,Fm=2,Vm=1,Bm=10,Um=-2,ic=e=>e==="*";function qm(e,t){let n=e.split("/"),s=n.length;return n.some(ic)&&(s+=Um),t&&(s+=Fm),n.filter(r=>!ic(r)).reduce((r,o)=>r+(Nm.test(o)?$m:o===""?Vm:Bm),s)}function Gm(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 Wm(e,t,n=!1){let{routesMeta:s}=e,r={},o="/",i=[];for(let a=0;a{if(d==="*"){let m=a[f]||"";i=o.slice(0,o.length-m.length).replace(/(.)\/+$/,"$1")}const p=a[f];return l&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Hm(e,t=!1,n=!0){Ot(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,(i,a,c,u,d)=>{if(s.push({paramName:a,isOptional:c!=null}),c){let l=d.charAt(u+i.length);return l&&l!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Zm(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ot(!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 Ut(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 Km=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qm(e,t="/"){let{pathname:n,search:s="",hash:r=""}=typeof e=="string"?Ts(e):e,o;return n?(n=Zu(n),n.startsWith("/")?o=ac(n.substring(1),"/"):o=ac(n,t)):o=t,{pathname:o,search:Jm(s),hash:eg(r)}}function ac(e,t){let n=vr(t).split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function uo(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 Xm(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Hu(e){let t=Xm(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Fi(e,t,n,s=!1){let r;typeof e=="string"?r=Ts(e):(r={...e},Ie(!r.pathname||!r.pathname.includes("?"),uo("?","pathname","search",r)),Ie(!r.pathname||!r.pathname.includes("#"),uo("#","pathname","hash",r)),Ie(!r.search||!r.search.includes("#"),uo("#","search","hash",r)));let o=e===""||r.pathname==="",i=o?"/":r.pathname,a;if(i==null)a=n;else{let l=t.length-1;if(!s&&i.startsWith("..")){let f=i.split("/");for(;f[0]==="..";)f.shift(),l-=1;r.pathname=f.join("/")}a=l>=0?t[l]:"/"}let c=Qm(r,a),u=i&&i!=="/"&&i.endsWith("/"),d=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Zu=e=>e.replace(/\/\/+/g,"/"),St=e=>Zu(e.join("/")),vr=e=>e.replace(/\/+$/,""),Ym=e=>vr(e).replace(/^\/*/,"/"),Jm=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,eg=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,tg=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 ng(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function sg(e){let t=e.map(n=>n.route.path).filter(Boolean);return St(t)||"/"}var Ku=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qu(e,t){let n=e;if(typeof n!="string"||!Km.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,r=!1;if(Ku)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),a=Ut(i.pathname,t);i.origin===o.origin&&a!=null?n=a+i.search+i.hash:r=!0}catch{Ot(!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 Xu=["POST","PUT","PATCH","DELETE"];new Set(Xu);var rg=["GET",...Xu];new Set(rg);var Fn=h.createContext(null);Fn.displayName="DataRouter";var Nr=h.createContext(null);Nr.displayName="DataRouterState";var Yu=h.createContext(!1);function og(){return h.useContext(Yu)}var Ju=h.createContext({isTransitioning:!1});Ju.displayName="ViewTransition";var ig=h.createContext(new Map);ig.displayName="Fetchers";var ag=h.createContext(null);ag.displayName="Await";var dt=h.createContext(null);dt.displayName="Navigation";var $r=h.createContext(null);$r.displayName="Location";var Gt=h.createContext({outlet:null,matches:[],isDataRoute:!1});Gt.displayName="Route";var Vi=h.createContext(null);Vi.displayName="RouteError";var ed="REACT_ROUTER_ERROR",cg="REDIRECT",lg="ROUTE_ERROR_RESPONSE";function ug(e){if(e.startsWith(`${ed}:${cg}:{`))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 dg(e){if(e.startsWith(`${ed}:${lg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new tg(t.status,t.statusText,t.data)}catch{}}function fg(e,{relative:t}={}){Ie(Ps(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:s}=h.useContext(dt),{hash:r,pathname:o,search:i}=_s(e,{relative:t}),a=o;return n!=="/"&&(a=o==="/"?n:St([n,o])),s.createHref({pathname:a,search:i,hash:r})}function Ps(){return h.useContext($r)!=null}function zt(){return Ie(Ps(),"useLocation() may be used only in the context of a component."),h.useContext($r).location}var td="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function nd(e){h.useContext(dt).static||h.useLayoutEffect(e)}function Bi(){let{isDataRoute:e}=h.useContext(Gt);return e?Pg():hg()}function hg(){Ie(Ps(),"useNavigate() may be used only in the context of a component.");let e=h.useContext(Fn),{basename:t,navigator:n}=h.useContext(dt),{matches:s}=h.useContext(Gt),{pathname:r}=zt(),o=JSON.stringify(Hu(s)),i=h.useRef(!1);return nd(()=>{i.current=!0}),h.useCallback((c,u={})=>{if(Ot(i.current,td),!i.current)return;if(typeof c=="number"){n.go(c);return}let d=Fi(c,JSON.parse(o),r,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:St([t,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[t,n,o,r,e])}h.createContext(null);function _s(e,{relative:t}={}){let{matches:n}=h.useContext(Gt),{pathname:s}=zt(),r=JSON.stringify(Hu(n));return h.useMemo(()=>Fi(e,JSON.parse(r),s,t==="path"),[e,r,s,t])}function pg(e,t,n){Ie(Ps(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=h.useContext(dt),{matches:r}=h.useContext(Gt),o=r[r.length-1],i=o?o.params:{},a=o?o.pathname:"/",c=o?o.pathnameBase:"/",u=o&&o.route;{let y=u&&u.path||"";rd(a,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${a}" (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. + */var rc="popstate";function sc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Im(e={}){function t(r,s){let o=s.state?.masked,{pathname:i,search:a,hash:c}=o||r.location;return Jo("",{pathname:i,search:a,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",o?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:mr(s)}return Om(t,n,null,e)}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Lt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Dm(){return Math.random().toString(36).substring(2,10)}function oc(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 Jo(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Tr(t):t,state:n,key:t&&t.key||r||Dm(),unstable_mask:s}}function mr({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 Tr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Om(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:o=!1}=r,i=s.history,a="POP",c=null,u=d();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function d(){return(i.state||{idx:null}).idx}function l(){a="POP";let y=d(),v=y==null?null:y-u;u=y,c&&c({action:a,location:g.location,delta:v})}function f(y,v){a="PUSH";let k=sc(y)?y:Jo(g.location,y,v);u=d()+1;let S=oc(k,u),x=g.createHref(k.unstable_mask||k);try{i.pushState(S,"",x)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;s.location.assign(x)}o&&c&&c({action:a,location:g.location,delta:1})}function p(y,v){a="REPLACE";let k=sc(y)?y:Jo(g.location,y,v);u=d();let S=oc(k,u),x=g.createHref(k.unstable_mask||k);i.replaceState(S,"",x),o&&c&&c({action:a,location:g.location,delta:0})}function m(y){return Lm(y)}let g={get action(){return a},get location(){return e(s,i)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(rc,l),c=y,()=>{s.removeEventListener(rc,l),c=null}},createHref(y){return t(s,y)},createURL:m,encodeLocation(y){let v=m(y);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:f,replace:p,go(y){return i.go(y)}};return g}function Lm(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ie(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:mr(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function qu(e,t,n="/"){return zm(e,t,n,!1)}function zm(e,t,n,r){let s=typeof t=="string"?Tr(t):t,o=Ut(s.pathname||"/",n);if(o==null)return null;let i=Gu(e);jm(i);let a=null;for(let c=0;a==null&&c{let d={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Ie(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let l=St([r,d.relativePath]),f=n.concat(d);i.children&&i.children.length>0&&(Ie(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Gu(i.children,t,f,l,c)),!(i.path==null&&!i.index)&&t.push({path:l,score:qm(l,i.index),routesMeta:f})};return e.forEach((i,a)=>{if(i.path===""||!i.path?.includes("?"))o(i,a);else for(let c of Wu(i.path))o(i,a,!0,c)}),t}function Wu(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return s?[o,""]:[o];let i=Wu(r.join("/")),a=[];return a.push(...i.map(c=>c===""?o:[o,c].join("/"))),s&&a.push(...i),a.map(c=>e.startsWith("/")&&c===""?"/":c)}function jm(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Gm(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Nm=/^:[\w-]+$/,$m=3,Fm=2,Vm=1,Bm=10,Um=-2,ic=e=>e==="*";function qm(e,t){let n=e.split("/"),r=n.length;return n.some(ic)&&(r+=Um),t&&(r+=Fm),n.filter(s=>!ic(s)).reduce((s,o)=>s+(Nm.test(o)?$m:o===""?Vm:Bm),r)}function Gm(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Wm(e,t,n=!1){let{routesMeta:r}=e,s={},o="/",i=[];for(let a=0;a{if(d==="*"){let m=a[f]||"";i=o.slice(0,o.length-m.length).replace(/(.)\/+$/,"$1")}const p=a[f];return l&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Hm(e,t=!1,n=!0){Lt(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 r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,a,c,u,d)=>{if(r.push({paramName:a,isOptional:c!=null}),c){let l=d.charAt(u+i.length);return l&&l!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Zm(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Lt(!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 Ut(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Km=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qm(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Tr(e):e,o;return n?(n=Zu(n),n.startsWith("/")?o=ac(n.substring(1),"/"):o=ac(n,t)):o=t,{pathname:o,search:Jm(r),hash:eg(s)}}function ac(e,t){let n=vs(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function uo(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. 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 Xm(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Hu(e){let t=Xm(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Fi(e,t,n,r=!1){let s;typeof e=="string"?s=Tr(e):(s={...e},Ie(!s.pathname||!s.pathname.includes("?"),uo("?","pathname","search",s)),Ie(!s.pathname||!s.pathname.includes("#"),uo("#","pathname","hash",s)),Ie(!s.search||!s.search.includes("#"),uo("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,a;if(i==null)a=n;else{let l=t.length-1;if(!r&&i.startsWith("..")){let f=i.split("/");for(;f[0]==="..";)f.shift(),l-=1;s.pathname=f.join("/")}a=l>=0?t[l]:"/"}let c=Qm(s,a),u=i&&i!=="/"&&i.endsWith("/"),d=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Zu=e=>e.replace(/\/\/+/g,"/"),St=e=>Zu(e.join("/")),vs=e=>e.replace(/\/+$/,""),Ym=e=>vs(e).replace(/^\/*/,"/"),Jm=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,eg=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,tg=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ng(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function rg(e){let t=e.map(n=>n.route.path).filter(Boolean);return St(t)||"/"}var Ku=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qu(e,t){let n=e;if(typeof n!="string"||!Km.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Ku)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),a=Ut(i.pathname,t);i.origin===o.origin&&a!=null?n=a+i.search+i.hash:s=!0}catch{Lt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Xu=["POST","PUT","PATCH","DELETE"];new Set(Xu);var sg=["GET",...Xu];new Set(sg);var Fn=h.createContext(null);Fn.displayName="DataRouter";var Ns=h.createContext(null);Ns.displayName="DataRouterState";var Yu=h.createContext(!1);function og(){return h.useContext(Yu)}var Ju=h.createContext({isTransitioning:!1});Ju.displayName="ViewTransition";var ig=h.createContext(new Map);ig.displayName="Fetchers";var ag=h.createContext(null);ag.displayName="Await";var dt=h.createContext(null);dt.displayName="Navigation";var $s=h.createContext(null);$s.displayName="Location";var Gt=h.createContext({outlet:null,matches:[],isDataRoute:!1});Gt.displayName="Route";var Vi=h.createContext(null);Vi.displayName="RouteError";var ed="REACT_ROUTER_ERROR",cg="REDIRECT",lg="ROUTE_ERROR_RESPONSE";function ug(e){if(e.startsWith(`${ed}:${cg}:{`))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 dg(e){if(e.startsWith(`${ed}:${lg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new tg(t.status,t.statusText,t.data)}catch{}}function fg(e,{relative:t}={}){Ie(Pr(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=h.useContext(dt),{hash:s,pathname:o,search:i}=_r(e,{relative:t}),a=o;return n!=="/"&&(a=o==="/"?n:St([n,o])),r.createHref({pathname:a,search:i,hash:s})}function Pr(){return h.useContext($s)!=null}function jt(){return Ie(Pr(),"useLocation() may be used only in the context of a component."),h.useContext($s).location}var td="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function nd(e){h.useContext(dt).static||h.useLayoutEffect(e)}function Bi(){let{isDataRoute:e}=h.useContext(Gt);return e?Pg():hg()}function hg(){Ie(Pr(),"useNavigate() may be used only in the context of a component.");let e=h.useContext(Fn),{basename:t,navigator:n}=h.useContext(dt),{matches:r}=h.useContext(Gt),{pathname:s}=jt(),o=JSON.stringify(Hu(r)),i=h.useRef(!1);return nd(()=>{i.current=!0}),h.useCallback((c,u={})=>{if(Lt(i.current,td),!i.current)return;if(typeof c=="number"){n.go(c);return}let d=Fi(c,JSON.parse(o),s,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:St([t,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[t,n,o,s,e])}h.createContext(null);function _r(e,{relative:t}={}){let{matches:n}=h.useContext(Gt),{pathname:r}=jt(),s=JSON.stringify(Hu(n));return h.useMemo(()=>Fi(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function pg(e,t,n){Ie(Pr(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=h.useContext(dt),{matches:s}=h.useContext(Gt),o=s[s.length-1],i=o?o.params:{},a=o?o.pathname:"/",c=o?o.pathnameBase:"/",u=o&&o.route;{let y=u&&u.path||"";sd(a,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${a}" (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 d=zt(),l;l=d;let f=l.pathname||"/",p=f;if(c!=="/"){let y=c.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let m=qu(e,{pathname:p});return Ot(u||m!=null,`No routes matched location "${l.pathname}${l.search}${l.hash}" `),Ot(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${l.pathname}${l.search}${l.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.`),vg(m&&m.map(y=>Object.assign({},y,{params:Object.assign({},i,y.params),pathname:St([c,s.encodeLocation?s.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:St([c,s.encodeLocation?s.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),r,n)}function mg(){let e=Tg(),t=ng(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},o={padding:"2px 4px",backgroundColor:s},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:o},"ErrorBoundary")," or"," ",h.createElement("code",{style:o},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),n?h.createElement("pre",{style:r},n):null,i)}var gg=h.createElement(mg,null),sd=class extends h.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=dg(e.digest);n&&(e=n)}let t=e!==void 0?h.createElement(Gt.Provider,{value:this.props.routeContext},h.createElement(Vi.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(yg,{error:e},t):t}};sd.contextType=Yu;var fo=new WeakMap;function yg({children:e,error:t}){let{basename:n}=h.useContext(dt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=ug(t.digest);if(s){let r=fo.get(t);if(r)throw r;let o=Qu(s.location,n);if(Ku&&!fo.get(t))if(o.isExternal||s.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:s.replace}));throw fo.set(t,i),i}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function bg({routeContext:e,match:t,children:n}){let s=h.useContext(Fn);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),h.createElement(Gt.Provider,{value:e},n)}function vg(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,o=s?.errors;if(o!=null){let d=r.findIndex(l=>l.route.id&&o?.[l.route.id]!==void 0);Ie(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,d+1))}let i=!1,a=-1;if(n&&s){i=s.renderFallback;for(let d=0;d=0?r=r.slice(0,a+1):r=[r[0]];break}}}}let c=n?.onError,u=s&&c?(d,l)=>{c(d,{location:s.location,params:s.matches?.[0]?.params??{},unstable_pattern:sg(s.matches),errorInfo:l})}:void 0;return r.reduceRight((d,l,f)=>{let p,m=!1,g=null,y=null;s&&(p=o&&l.route.id?o[l.route.id]:void 0,g=l.route.errorElement||gg,i&&(a<0&&f===0?(rd("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,y=null):a===f&&(m=!0,y=l.route.hydrateFallbackElement||null)));let v=t.concat(r.slice(0,f+1)),k=()=>{let S;return p?S=g:m?S=y:l.route.Component?S=h.createElement(l.route.Component,null):l.route.element?S=l.route.element:S=d,h.createElement(bg,{match:l,routeContext:{outlet:d,matches:v,isDataRoute:s!=null},children:S})};return s&&(l.route.ErrorBoundary||l.route.errorElement||f===0)?h.createElement(sd,{location:s.location,revalidation:s.revalidation,component:g,error:p,children:k(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):k()},null)}function Ui(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wg(e){let t=h.useContext(Fn);return Ie(t,Ui(e)),t}function xg(e){let t=h.useContext(Nr);return Ie(t,Ui(e)),t}function Sg(e){let t=h.useContext(Gt);return Ie(t,Ui(e)),t}function qi(e){let t=Sg(e),n=t.matches[t.matches.length-1];return Ie(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function kg(){return qi("useRouteId")}function Tg(){let e=h.useContext(Vi),t=xg("useRouteError"),n=qi("useRouteError");return e!==void 0?e:t.errors?.[n]}function Pg(){let{router:e}=wg("useNavigate"),t=qi("useNavigate"),n=h.useRef(!1);return nd(()=>{n.current=!0}),h.useCallback(async(r,o={})=>{Ot(n.current,td),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...o}))},[e,t])}var cc={};function rd(e,t,n){!t&&!cc[e]&&(cc[e]=!0,Ot(!1,n))}h.memo(_g);function _g({routes:e,future:t,state:n,isStatic:s,onError:r}){return pg(e,void 0,{state:n,isStatic:s,onError:r})}function Eg({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:r,static:o=!1,unstable_useTransitions:i}){Ie(!Ps(),"You cannot render a inside another . You should never have more than one in your app.");let a=e.replace(/^\/*/,"/"),c=h.useMemo(()=>({basename:a,navigator:r,static:o,unstable_useTransitions:i,future:{}}),[a,r,o,i]);typeof n=="string"&&(n=Ts(n));let{pathname:u="/",search:d="",hash:l="",state:f=null,key:p="default",unstable_mask:m}=n,g=h.useMemo(()=>{let y=Ut(u,a);return y==null?null:{location:{pathname:y,search:d,hash:l,state:f,key:p,unstable_mask:m},navigationType:s}},[a,u,d,l,f,p,s,m]);return Ot(g!=null,` is not able to match the URL "${u}${d}${l}" because it does not start with the basename, so the won't render anything.`),g==null?null:h.createElement(dt.Provider,{value:c},h.createElement($r.Provider,{children:t,value:g}))}var sr="get",rr="application/x-www-form-urlencoded";function Fr(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Cg(e){return Fr(e)&&e.tagName.toLowerCase()==="button"}function Ag(e){return Fr(e)&&e.tagName.toLowerCase()==="form"}function Rg(e){return Fr(e)&&e.tagName.toLowerCase()==="input"}function Mg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ig(e,t){return e.button===0&&(!t||t==="_self")&&!Mg(e)}var $s=null;function Dg(){if($s===null)try{new FormData(document.createElement("form"),0),$s=!1}catch{$s=!0}return $s}var Og=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ho(e){return e!=null&&!Og.has(e)?(Ot(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${rr}"`),null):e}function Lg(e,t){let n,s,r,o,i;if(Ag(e)){let a=e.getAttribute("action");s=a?Ut(a,t):null,n=e.getAttribute("method")||sr,r=ho(e.getAttribute("enctype"))||rr,o=new FormData(e)}else if(Cg(e)||Rg(e)&&(e.type==="submit"||e.type==="image")){let a=e.form;if(a==null)throw new Error('Cannot submit a