diff --git a/assets/AIChatPage-C5Aol7Ef.js b/assets/AIChatPage-BEC3mijo.js similarity index 87% rename from assets/AIChatPage-C5Aol7Ef.js rename to assets/AIChatPage-BEC3mijo.js index b1edc94243bb9ddebf619767304b3a3681b129aa..87211521c959ee72c3ad5039fb5b9a4d73a9996e 100644 --- a/assets/AIChatPage-C5Aol7Ef.js +++ b/assets/AIChatPage-BEC3mijo.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-mbyiCUYG.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.js","assets/vendor-radix-xDOIcVzp.js","assets/vendor-charts-Ckgeb0nY.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CoeUXWgK.css"])))=>i.map(i=>d[i]); -import{az as F,l as $,_ as z,g as S,m as C,F as D}from"./index-mbyiCUYG.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-BqKfG4Jj.js";import{I}from"./input-DEPoMoHZ.js";import H from"./ChatMarkdown-vDoOnX8q.js";import{P as Y}from"./plus-CbpDHvDO.js";import{S as G}from"./search-F2fS74Xk.js";import{T as Q}from"./trash-2-8qZ3aehj.js";import{S as W}from"./send-iW1LmVFw.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";function q(r){return r?r instanceof Date?r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof r=="object"&&"toDate"in r?r.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(r):""}const xe=()=>{const{sessions:r,activeSessionId:o,isLoading:l,loadingSessionId:A,setActiveSessionId:d,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=F(),{userProfile:c}=$(),[x,P]=a.useState(""),[n,g]=a.useState(""),[y,j]=a.useState(!1),m=a.useRef(null),h=a.useRef(!0),u=a.useRef(!1),i=_(),f=i?.messages||[],M=f.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&o===A&&!M,w=(t="auto")=>{const s=m.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},E=()=>{const t=m.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},R=()=>{h.current=E()};a.useEffect(()=>{z(async()=>{const{warmupBackend:t}=await import("./index-mbyiCUYG.js").then(s=>s.b3);return{warmupBackend:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("AI chat warmup skipped:",t)})},[]),a.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[f,v]),a.useEffect(()=>{h.current=!0,w("auto")},[o]);const N=async()=>{if(!(!n.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=o;t||(t=b(),d(t));const s=n.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();d(t)},B=(t,s)=>{s.stopPropagation(),T(t)},p=r.filter(t=>t.title.toLowerCase().includes(x.toLowerCase())||t.preview.toLowerCase().includes(x.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex gap-4 px-4 sm:px-6 xl:px-10 py-6",children:[e.jsxs("div",{className:"w-80 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-2xl flex items-center justify-center",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-10 h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628]",children:"L.O.L.I."}),e.jsx("p",{className:"text-[10px] text-[#5a6578]",children:"Your AI Math Tutor"})]})]}),e.jsxs("button",{onClick:k,className:"w-full bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-4 py-3 rounded-xl text-sm font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(Y,{size:18}),"New Chat"]}),e.jsxs("div",{className:"relative mt-3",children:[e.jsx(G,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:14}),e.jsx(I,{type:"text",placeholder:"Search conversations...",value:x,onChange:t=>P(t.target.value),className:"w-full pl-9 pr-3 py-2 text-xs rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between mb-2 px-2",children:e.jsxs("span",{className:"text-xs font-bold text-[#5a6578]",children:[p.length," Conversations"]})}),e.jsx(S,{children:p.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>d(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${o===t.id?"bg-sky-50 border-sky-200 shadow-sm":"bg-[#edf1f7] border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("h3",{className:`text-xs font-bold mb-0.5 pr-6 line-clamp-1 ${o===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>B(t.id,s),className:"absolute top-2 right-2 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-100 text-slate-500 hover:text-red-600 transition-all",children:e.jsx(Q,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-2 line-clamp-2",children:t.preview}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-slate-500",children:t.date}),e.jsxs("span",{className:`px-2 py-0.5 rounded-full ${o===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),p.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-16 h-16 object-contain mx-auto mb-2 opacity-60 drop-shadow-sm grayscale contrast-50"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No conversations found"}),e.jsx("p",{className:"text-xs text-slate-500/60 mt-1",children:"Start a new chat!"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628]",children:i?.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:i?.date})]}),e.jsx("div",{className:"flex items-center gap-2",children:i?.topics.map((t,s)=>e.jsx("span",{className:"px-3 py-1 bg-sky-50 text-sky-600 text-xs font-bold rounded-lg",children:t},s))})]}),e.jsxs("div",{ref:m,onScroll:R,className:"flex-1 overflow-y-auto overscroll-contain p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex items-end gap-2 ${t.sender==="user"?"justify-end":"justify-start"}`,children:[t.sender!=="user"&&e.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-r from-sky-600 to-sky-500 flex items-center justify-center flex-shrink-0 mb-1",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI",className:"w-5 h-5 object-contain"})}),e.jsxs("div",{className:`max-w-[70%] rounded-2xl px-5 py-3 ${t.sender==="user"?"bg-gradient-to-r from-sky-600 to-sky-500 text-white":"bg-white text-[#0a1628] shadow-md border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:t.text}):e.jsx(H,{children:t.text}),e.jsx("p",{className:`text-[10px] mt-1.5 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:q(t.timestamp)})]}),t.sender==="user"&&e.jsx(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-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(I,{type:"text",value:n,onChange:t=>g(t.target.value),onKeyPress:t=>t.key==="Enter"&&N(),placeholder:"Ask me anything about math...",className:"flex-1 px-5 py-3 rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100 text-sm"}),e.jsx(O,{onClick:N,disabled:!n.trim()||l||y,className:"px-6 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",children:e.jsx(W,{size:18})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-24 h-24 bg-gradient-to-r from-sky-100 to-cyan-100 rounded-3xl flex items-center justify-center mb-6",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-20 h-20 object-contain drop-shadow-lg"})}),e.jsx("h2",{className:"text-2xl font-bold font-display text-[#0a1628] mb-1",children:"Welcome to L.O.L.I."}),e.jsx("p",{className:"text-sky-600 text-sm font-bold tracking-wide uppercase mb-4",children:"Logical Operations & Learning Intelligence"}),e.jsx("p",{className:"text-[#5a6578] mb-6 max-w-md",children:"Your personal AI math tutor is here to help! Start a new conversation or select one from the sidebar."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl font-bold shadow-lg hover:shadow-xl transition-all",children:"Start Your First Chat"}),e.jsx("div",{className:"mt-8 grid grid-cols-3 gap-4 max-w-2xl",children:["Algebra","Geometry","Calculus"].map(t=>e.jsxs("div",{className:"p-4 bg-[#edf1f7] rounded-xl border border-[#dde3eb]",children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628]",children:t}),e.jsxs("p",{className:"text-xs text-[#5a6578] mt-1",children:["Get help with ",t.toLowerCase()]})]},t))})]})})]})};export{xe as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B3ruOzo6.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.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-trN1hCQB.css"])))=>i.map(i=>d[i]); +import{aB as F,u as $,_ as D,k as S,m as C,F as z}from"./index-B3ruOzo6.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{B as O}from"./button-CaSK4KoS.js";import{I}from"./input-kh84w1XK.js";import H from"./ChatMarkdown-BWVWW9Zs.js";import{P as Y}from"./plus-Dx0gdu7_.js";import{S as G}from"./search-DeasjpAx.js";import{T as Q}from"./trash-2-CjkT7lLr.js";import{S as W}from"./send-CTO7uejQ.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";function q(r){return r?r instanceof Date?r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):typeof r=="object"&&"toDate"in r?r.toDate().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):String(r):""}const xe=()=>{const{sessions:r,activeSessionId:o,isLoading:l,loadingSessionId:A,setActiveSessionId:d,createNewSession:b,sendMessage:L,deleteSession:T,getActiveSession:_}=F(),{userProfile:c}=$(),[x,P]=a.useState(""),[n,g]=a.useState(""),[y,j]=a.useState(!1),m=a.useRef(null),h=a.useRef(!0),u=a.useRef(!1),i=_(),f=i?.messages||[],M=f.some(t=>t.sender==="ai"&&t.id.startsWith("stream-")),v=l&&o===A&&!M,w=(t="auto")=>{const s=m.current;s&&s.scrollTo({top:s.scrollHeight,behavior:t})},B=()=>{const t=m.current;return t?t.scrollHeight-t.scrollTop-t.clientHeight<=120:!0},E=()=>{h.current=B()};a.useEffect(()=>{D(async()=>{const{warmupBackend:t}=await import("./index-B3ruOzo6.js").then(s=>s.b3);return{warmupBackend:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({warmupBackend:t})=>{t()}).catch(t=>{console.warn("AI chat warmup skipped:",t)})},[]),a.useEffect(()=>{if(!h.current)return;const t=window.requestAnimationFrame(()=>w("auto"));return()=>window.cancelAnimationFrame(t)},[f,v]),a.useEffect(()=>{h.current=!0,w("auto")},[o]);const N=async()=>{if(!(!n.trim()||l||y||u.current)){u.current=!0,j(!0);try{let t=o;t||(t=b(),d(t));const s=n.trim();g(""),await L(t,s)}finally{u.current=!1,j(!1)}}},k=()=>{const t=b();d(t)},R=(t,s)=>{s.stopPropagation(),T(t)},p=r.filter(t=>t.title.toLowerCase().includes(x.toLowerCase())||t.preview.toLowerCase().includes(x.toLowerCase()));return e.jsxs("div",{className:"h-full min-h-0 overflow-hidden flex gap-4 px-4 sm:px-6 xl:px-10 py-6",children:[e.jsxs("div",{className:"w-80 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-sky-600 to-sky-500 rounded-2xl flex items-center justify-center",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-10 h-10 object-contain drop-shadow-md"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628]",children:"L.O.L.I."}),e.jsx("p",{className:"text-[10px] text-[#5a6578]",children:"Your AI Math Tutor"})]})]}),e.jsxs("button",{onClick:k,className:"w-full bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white px-4 py-3 rounded-xl text-sm font-bold transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(Y,{size:18}),"New Chat"]}),e.jsxs("div",{className:"relative mt-3",children:[e.jsx(G,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:14}),e.jsx(I,{type:"text",placeholder:"Search conversations...",value:x,onChange:t=>P(t.target.value),className:"w-full pl-9 pr-3 py-2 text-xs rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between mb-2 px-2",children:e.jsxs("span",{className:"text-xs font-bold text-[#5a6578]",children:[p.length," Conversations"]})}),e.jsx(S,{children:p.map(t=>e.jsxs(C.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},onClick:()=>d(t.id),className:`group p-3 rounded-2xl cursor-pointer transition-all duration-200 border relative ${o===t.id?"bg-sky-50 border-sky-200 shadow-sm":"bg-[#edf1f7] border-transparent hover:bg-[#dde3eb] hover:border-[#dde3eb]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("h3",{className:`text-xs font-bold mb-0.5 pr-6 line-clamp-1 ${o===t.id?"text-sky-700":"text-[#0a1628]"}`,children:t.title}),e.jsx("button",{onClick:s=>R(t.id,s),className:"absolute top-2 right-2 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-100 text-slate-500 hover:text-red-600 transition-all",children:e.jsx(Q,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-2 line-clamp-2",children:t.preview}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-slate-500",children:t.date}),e.jsxs("span",{className:`px-2 py-0.5 rounded-full ${o===t.id?"bg-sky-100 text-sky-600":"bg-[#dde3eb] text-[#5a6578]"}`,children:[t.messageCount," msgs"]})]})]},t.id))}),p.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-16 h-16 object-contain mx-auto mb-2 opacity-60 drop-shadow-sm grayscale contrast-50"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No conversations found"}),e.jsx("p",{className:"text-xs text-slate-500/60 mt-1",children:"Start a new chat!"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] overflow-hidden",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold font-display text-[#0a1628]",children:i?.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:i?.date})]}),e.jsx("div",{className:"flex items-center gap-2",children:i?.topics.map((t,s)=>e.jsx("span",{className:"px-3 py-1 bg-sky-50 text-sky-600 text-xs font-bold rounded-lg",children:t},s))})]}),e.jsxs("div",{ref:m,onScroll:E,className:"flex-1 overflow-y-auto overscroll-contain p-6 space-y-4 bg-[#edf1f7] min-h-0",children:[e.jsx(S,{children:f.map(t=>e.jsxs(C.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex items-end gap-2 ${t.sender==="user"?"justify-end":"justify-start"}`,children:[t.sender!=="user"&&e.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-r from-sky-600 to-sky-500 flex items-center justify-center flex-shrink-0 mb-1",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI",className:"w-5 h-5 object-contain"})}),e.jsxs("div",{className:`max-w-[70%] rounded-2xl px-5 py-3 ${t.sender==="user"?"bg-gradient-to-r from-sky-600 to-sky-500 text-white":"bg-white text-[#0a1628] shadow-md border border-[#dde3eb]"}`,children:[t.sender==="user"?e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:t.text}):e.jsx(H,{children:t.text}),e.jsx("p",{className:`text-[10px] mt-1.5 ${t.sender==="user"?"text-sky-200":"text-slate-500"}`,children:q(t.timestamp)})]}),t.sender==="user"&&e.jsx(z,{src:c?.photo,name:c?.name,gender:c?.gender,className:"w-7 h-7 flex-shrink-0 mb-1",fallbackClassName:"text-[10px]"})]},t.id))}),v&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white text-[#0a1628] shadow-md border border-[#dde3eb] rounded-2xl px-5 py-3 max-w-[70%]",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("div",{className:"w-2 h-2 bg-sky-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})})]}),e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-white flex-shrink-0",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(I,{type:"text",value:n,onChange:t=>g(t.target.value),onKeyPress:t=>t.key==="Enter"&&N(),placeholder:"Ask me anything about math...",className:"flex-1 px-5 py-3 rounded-xl border-[#dde3eb] focus:border-sky-600 focus:ring-2 focus:ring-sky-100 text-sm"}),e.jsx(O,{onClick:N,disabled:!n.trim()||l||y,className:"px-6 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",children:e.jsx(W,{size:18})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-24 h-24 bg-gradient-to-r from-sky-100 to-cyan-100 rounded-3xl flex items-center justify-center mb-6",children:e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"AI Tutor",className:"w-20 h-20 object-contain drop-shadow-lg"})}),e.jsx("h2",{className:"text-2xl font-bold font-display text-[#0a1628] mb-1",children:"Welcome to L.O.L.I."}),e.jsx("p",{className:"text-sky-600 text-sm font-bold tracking-wide uppercase mb-4",children:"Logical Operations & Learning Intelligence"}),e.jsx("p",{className:"text-[#5a6578] mb-6 max-w-md",children:"Your personal AI math tutor is here to help! Start a new conversation or select one from the sidebar."}),e.jsx("button",{onClick:k,className:"px-6 py-3 bg-gradient-to-r from-sky-600 to-sky-500 hover:from-sky-700 hover:to-sky-600 text-white rounded-xl font-bold shadow-lg hover:shadow-xl transition-all",children:"Start Your First Chat"}),e.jsx("div",{className:"mt-8 grid grid-cols-3 gap-4 max-w-2xl",children:["Algebra","Geometry","Calculus"].map(t=>e.jsxs("div",{className:"p-4 bg-[#edf1f7] rounded-xl border border-[#dde3eb]",children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628]",children:t}),e.jsxs("p",{className:"text-xs text-[#5a6578] mt-1",children:["Get help with ",t.toLowerCase()]})]},t))})]})})]})};export{xe as default}; diff --git a/assets/AdminDashboard-B7yRI4wL.js b/assets/AdminDashboard-B7yRI4wL.js deleted file mode 100644 index 1c37a0da654773230a400c544b35917b09f3c8c5..0000000000000000000000000000000000000000 --- a/assets/AdminDashboard-B7yRI4wL.js +++ /dev/null @@ -1,64 +0,0 @@ -import{r as l,d as Zt,j as e}from"./vendor-react-B4AQeu28.js";import Bs from"./Sidebar-CnFPEtsr.js";import Ns from"./ConfirmModal-BsY1WFdG.js";import{c as me,j as ye,n as z,p as H,R as Re,w as oe,h as X,I as Yt,J as ea,K as sa,o as ot,l as Ee,m as U,D as ys,L as mt,S as Je,Z as xt,k as ke,N as qs,O as Os,P as Gs,U as Ze,G as Cs,q as ut,A as Ye,Q as ht,B as ta,a as je,T as gt,v as aa,M as ra,F as la}from"./index-mbyiCUYG.js";import{B as M}from"./button-BqKfG4Jj.js";import{S as re,a as le,b as ie,c as ne,d as P}from"./select-B04HpeAZ.js";import{I as R}from"./input-DEPoMoHZ.js";import{S as Ke}from"./subjects-BGUwH4Kn.js";import{U as bs}from"./upload-CKMt4jtd.js";import{F as es,I as we,A as ws,D as Oe,T as ia}from"./trending-down-DaPJgM3L.js";import{C as _s,L as na}from"./lightbulb-D-SuIyuF.js";import{C as ss}from"./chart-column-B4tQNTpN.js";import{C as ts}from"./circle-check-big-BnoZ8KZB.js";import{D as pt,a as ft,b as bt,c as jt,d as vt,e as da}from"./dialog-fiLCzxmY.js";import{getDocs as de,collection as se,query as as,orderBy as Nt,limit as Ss,where as ks,addDoc as ca,serverTimestamp as yt,doc as As,getDoc as wt,setDoc as oa,onSnapshot as ma}from"./vendor-firebase-firestore-CP9q7ISf.js";import{C as Se}from"./circle-alert-CJ47UAgT.js";import{S as St}from"./search-F2fS74Xk.js";import{E as rs,a as Hs}from"./eye-DakyBxPE.js";import{S as be}from"./switch-CHYfNJFI.js";import{S as kt,M as xa}from"./LogoutActionButton-DQLJH-aF.js";import{B as ua}from"./bell-D_pyutJs.js";import{C as ha,a as ga}from"./vendor-radix-xDOIcVzp.js";import{C as pa}from"./check-BLN5Dl8e.js";import{P as fa}from"./plus-CbpDHvDO.js";import{C as ba}from"./check-check-wBIDWtv-.js";import{M as ja}from"./mail-DWQ9UHXG.js";import{D as Ct}from"./download-C2PVrIq3.js";import{T as Qs}from"./trash-2-8qZ3aehj.js";import{C as At}from"./clock-BLtPbCgT.js";import{F as va}from"./funnel-DxfPBPvT.js";import{S as Z}from"./skeleton-Br1snihA.js";import{u as Na,t as ya,a as wa}from"./useSubjectAvailability-CN1BUyIM.js";import{S as Sa}from"./save-DgO_wXsk.js";import{u as ka}from"./useQuery-L70l-ukL.js";import{C as Ca}from"./chevron-up-B_-cQcm8.js";import{M as Aa}from"./minus-BEbLkPkH.js";import"./tooltip-Cd2m83Wr.js";import"./x-oZO0Ye1Q.js";import"./chevron-right-bwYIKoxv.js";import"./chevron-left-BYtw_nqd.js";import"./shirt-nq7Lov7c.js";import"./log-out-Ddy014zi.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.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 za=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Vs=me("ban",za);/** - * @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 Pa=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Da=me("book-marked",Pa);/** - * @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 Ta=[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]],La=me("chart-pie",Ta);/** - * @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 Ma=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Ws=me("dollar-sign",Ma);/** - * @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 Ia=[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]],Ra=me("gamepad-2",Ia);/** - * @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 Ea=[["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"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ua=me("grid-3x3",Ea);/** - * @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 $a=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Fa=me("lock-open",$a);/** - * @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 Ba=[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]],qa=me("school",Ba);/** - * @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 Oa=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ga=me("square-pen",Oa);/** - * @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 _a=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]],Xs=me("user-check",_a),Ha=({onUploadSuccess:s})=>{const[t,i]=l.useState(!1),[r,h]=l.useState(null),[n,o]=l.useState(!1),[m,v]=l.useState(null),[p,S]=l.useState(""),[f,j]=l.useState(""),[w,A]=l.useState("1"),[k,d]=l.useState(0),[y,L]=l.useState(null),[C,B]=l.useState(!1),q=l.useRef(null),O=l.useCallback(async()=>{B(!0);try{const x=await ye.getRagHealth();L({subjects:x.subjects||{},chunkCount:x.chunkCount||0,lastIngested:x.lastIngested||""})}catch{z.error("Failed to load RAG health status")}finally{B(!1)}},[]);Zt.useEffect(()=>{O()},[O]);const G=x=>{if(x.type!=="application/pdf"){z.error("Only PDF files are allowed");return}if(x.size>50*1024*1024){z.error("File size must be under 50MB");return}if(v(x),p){const E=Ke.find(c=>c.id===p);E&&j(E.name)}},Y=l.useCallback(x=>{x.preventDefault(),o(!1);const E=x.dataTransfer.files[0];E&&G(E)},[p]),_=l.useCallback(x=>{x.preventDefault(),o(!0)},[]),ee=l.useCallback(()=>o(!1),[]),Q=x=>{S(x);const E=Ke.find(c=>c.id===x);E&&j(E.name)},ce=async()=>{if(!m||!p||!f.trim()){z.error("Please select a PDF file, subject, and enter a subject name");return}i(!0),d(0);try{const x=new FormData;x.append("file",m),x.append("subjectId",p),x.append("subjectName",f.trim()),x.append("quarter",w);const E=setInterval(()=>{d(u=>Math.min(u+15,85))},300),c=await ye.uploadModulePdf(x);clearInterval(E),d(100),c.success?(z.success(`${m.name} uploaded! ${c.chunkCount??0} chunks indexed.`),v(null),c.chunkCount!==void 0&&s?.(p,c.chunkCount),O()):z.error(c.error||"Upload failed")}catch(x){z.error(x instanceof Error?x.message:"Upload failed")}finally{i(!1),setTimeout(()=>d(0),500)}},b=async(x,E)=>{h(x);try{const c=await ye.reingestModulePdf(x,E);c.success?(z.success(`Re-ingestion complete for ${x}: ${c.chunkCount??0} chunks`),O()):z.error(c.error||"Re-ingestion failed")}catch(c){z.error(c instanceof Error?c.message:"Re-ingestion failed")}finally{h(null)}},V=y?Object.entries(y.subjects).map(([x,E])=>({name:x,chunks:E,storagePath:"",status:E>0?"active":"missing"})).filter(x=>x.chunks>0):[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-[#dde3eb] shadow-sm p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 bg-sky-100 rounded-xl flex items-center justify-center",children:e.jsx(bs,{size:20,className:"text-sky-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-[#0a1628]",children:"Upload Module PDF"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Upload a DepEd teaching module PDF and trigger RAG ingestion"})]})]}),e.jsxs("div",{onDrop:Y,onDragOver:_,onDragLeave:ee,onClick:()=>!t&&q.current?.click(),className:` - border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all mb-4 - ${n?"border-sky-500 bg-sky-50":"border-[#dde3eb] hover:border-sky-400 hover:bg-sky-50/50"} - ${t?"cursor-not-allowed opacity-60":""} - `,children:[e.jsx("input",{ref:q,type:"file",accept:".pdf",className:"hidden",onChange:x=>x.target.files?.[0]&&G(x.target.files[0])}),m?e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(es,{size:24,className:"text-sky-600"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-[#0a1628]",children:m.name}),e.jsxs("p",{className:"text-xs text-[#5a6578]",children:[(m.size/1024/1024).toFixed(2)," MB"]})]}),!t&&e.jsx("button",{onClick:x=>{x.stopPropagation(),v(null)},className:"ml-4 p-1.5 hover:bg-rose-50 rounded-lg text-rose-500","aria-label":"Remove file",children:e.jsx(_s,{size:18})})]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{size:28,className:"mx-auto mb-2 text-[#dde3eb]"}),e.jsx("p",{className:"font-semibold text-[#0a1628]",children:"Drop PDF here or click to browse"}),e.jsx("p",{className:"text-xs text-[#5a6578] mt-1",children:"PDF files only, max 50MB"})]})]}),k>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between text-xs text-[#5a6578] mb-1",children:[e.jsx("span",{children:t?"Uploading...":"Complete"}),e.jsxs("span",{children:[k,"%"]})]}),e.jsx("div",{className:"h-2 bg-[#edf1f7] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-sky-500 rounded-full transition-all duration-300",style:{width:`${k}%`}})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[#5a6578] mb-1.5 block",children:"Subject"}),e.jsxs(re,{value:p,onValueChange:Q,disabled:t,children:[e.jsx(le,{className:"w-full",children:e.jsx(ie,{placeholder:"Select subject"})}),e.jsx(ne,{children:Ke.map(x=>e.jsxs(P,{value:x.id,children:[x.name," (",x.gradeLevel," — ",x.semester,")"]},x.id))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[#5a6578] mb-1.5 block",children:"Subject Name (display)"}),e.jsx(R,{value:f,onChange:x=>j(x.target.value),placeholder:"e.g. General Mathematics",disabled:t})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[#5a6578] mb-1.5 block",children:"Semester"}),e.jsxs(re,{value:w,onValueChange:A,disabled:t,children:[e.jsx(le,{className:"w-full",children:e.jsx(ie,{})}),e.jsxs(ne,{children:[e.jsx(P,{value:"1",children:"Q1"}),e.jsx(P,{value:"2",children:"Q2"}),e.jsx(P,{value:"3",children:"Q3"}),e.jsx(P,{value:"4",children:"Q4"})]})]})]})]}),e.jsx(M,{onClick:ce,disabled:t||!m||!p||!f.trim(),className:"w-full gap-2 bg-sky-600 hover:bg-sky-700 text-white",children:t?e.jsxs(e.Fragment,{children:[e.jsx(H,{size:16,className:"animate-spin"})," Uploading & Indexing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{size:16})," Upload & Ingest"]})})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#dde3eb] shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"p-6 border-b border-[#dde3eb] 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-teal-100 rounded-xl flex items-center justify-center",children:e.jsx(ss,{size:20,className:"text-teal-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-[#0a1628]",children:"RAG Index Status"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:C?"Loading...":`${y?.chunkCount??0} total chunks across ${V.length} subjects`})]})]}),e.jsxs(M,{variant:"outline",size:"sm",className:"gap-2",onClick:O,disabled:C,children:[e.jsx(Re,{size:14,className:C?"animate-spin":""}),"Refresh"]})]}),C?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(H,{size:20,className:"animate-spin text-sky-500"})}):V.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-2",children:[e.jsx(oe,{size:24,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"No PDFs indexed yet"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#edf1f7] border-b border-[#dde3eb]",children:[e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Subject"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Chunks"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#dde3eb]",children:V.map(x=>e.jsxs("tr",{className:"hover:bg-[#f8fafc] transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(es,{size:16,className:"text-[#5a6578]"}),e.jsx("span",{className:"font-semibold text-sm text-[#0a1628]",children:x.name})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm font-bold text-[#0a1628]",children:x.chunks})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-bold border ${x.status==="active"?"bg-green-50 text-green-700 border-green-200":x.status==="locked"?"bg-amber-50 text-amber-700 border-amber-200":"bg-rose-50 text-rose-700 border-rose-200"}`,children:[x.status==="active"?e.jsx(ts,{size:12}):e.jsx(_s,{size:12}),x.status.charAt(0).toUpperCase()+x.status.slice(1)]})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs(M,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",onClick:()=>b(x.name.toLowerCase().replace(/\s+/g,"-").replace("&",""),x.storagePath),disabled:r===x.name.toLowerCase().replace(/\s+/g,"-").replace("&",""),children:[r===x.name.toLowerCase().replace(/\s+/g,"-").replace("&","")?e.jsx(H,{size:12,className:"animate-spin"}):e.jsx(Re,{size:12}),"Re-ingest"]})})]},x.name))})]})}),y?.lastIngested&&e.jsx("div",{className:"p-4 border-t border-[#dde3eb] bg-[#f8fafc]",children:e.jsxs("p",{className:"text-xs text-[#5a6578]",children:["Last ingestion: ",new Date(y.lastIngested).toLocaleString()]})})]})]})};function Qa(s){return s?s.charAt(0).toUpperCase()+s.slice(1):"Student"}function zt(s){if(!s||!s.toDate)return new Date().toISOString().replace("T"," ").slice(0,19);const t=s.toDate();return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function Va(){return zt({toDate:()=>new Date})}function Wa(s){if(!s)return"Never";const t=new Date(s);if(Number.isNaN(t.getTime()))return s;const r=Date.now()-t.getTime(),h=Math.floor(r/6e4);if(h<1)return"Just now";if(h<60)return`${h} minute${h!==1?"s":""} ago`;const n=Math.floor(h/60);if(n<24)return`${n} hour${n!==1?"s":""} ago`;const o=Math.floor(n/24);return o<7?`${o} day${o!==1?"s":""} ago`:t.toLocaleDateString()}function Xa(s){const t=(s.grade||"").trim(),i=(s.section||"").trim(),r=[t,i].filter(Boolean).join(" - ");return{id:s.uid,name:s.name||"Unknown",email:s.email||"",role:Qa(s.role||""),status:s.status||"Active",department:s.department||(s.role?.toLowerCase()==="student"?r||"Student":""),grade:t,section:i,classSectionId:s.classSectionId||void 0,classSection:r,lrn:(s.lrn||"").trim(),photo:(s.photo||"").trim(),lastLogin:Wa(s.lastLogin),createdAt:s.createdAt||void 0}}function is(s){if(s instanceof ot){try{const t=JSON.parse(s.responseBody);if(t?.detail&&typeof t.detail=="string")return t.detail}catch{}return`Request failed (${s.status}).`}return s instanceof Error?s.message:"Request failed."}async function Ka(s={}){try{const t=await ye.getAdminUsers({page:s.page??1,pageSize:s.pageSize??25,search:s.searchQuery,role:s.roleFilter,status:s.statusFilter,grade:s.gradeFilter,section:s.sectionFilter,classSectionId:s.classSectionId});if(!t.success)throw new Error("Failed to load admin users");return{users:(t.users||[]).map(Xa),page:t.page,pageSize:t.pageSize,total:t.total,totalPages:t.totalPages,hasNextPage:t.hasNextPage}}catch(t){throw console.error("[adminService] getAdminUsersPage error:",t),t instanceof ea?new Error("Loading users timed out. Please refresh and try again."):t instanceof sa?new Error("Unable to reach the server. Please check your connection and retry."):t instanceof ot&&t.status===504?new Error("Loading users took too long. Try narrowing your filters and retrying."):new Error(is(t))}}async function Ja(s,t){try{await ye.updateAdminUser(s,{...t.name!==void 0?{name:t.name}:{},...t.role!==void 0?{role:t.role}:{},...t.status!==void 0?{status:t.status}:{},...t.department!==void 0?{department:t.department}:{},...t.grade!==void 0?{grade:t.grade}:{},...t.section!==void 0?{section:t.section}:{},...t.lrn!==void 0?{lrn:t.lrn}:{}})}catch(i){throw new Error(is(i))}}async function Za(s){try{const t=await ye.createAdminUser({name:s.name.trim(),email:s.email.trim().toLowerCase(),password:s.password,confirmPassword:s.confirmPassword,role:s.role,status:s.status,grade:s.grade.trim(),section:s.section.trim(),...s.lrn?.trim()?{lrn:s.lrn.trim()}:{}});if(!t.success||!t.userCreated||!t.uid)throw new Error(t.message||"Failed to create user account.");return{uid:t.uid,userCreated:t.userCreated,emailSent:t.emailSent,resultCode:t.resultCode,message:t.message,warnings:t.warnings??[],emailError:t.emailError}}catch(t){throw new Error(is(t))}}async function Ya(s){try{const t=await ye.bulkAdminUsers({action:s.action,userIds:s.userIds??[],excludeUserIds:s.excludeUserIds??[],filters:s.filters,role:s.role,status:s.status,grade:s.grade,section:s.section,lrn:s.lrn,dryRun:s.dryRun,exportFormat:s.exportFormat??"csv"});return{success:t.success,action:t.action,summary:t.summary,results:t.results,warnings:t.warnings||[],exportRows:t.export?.rows||[]}}catch(t){throw new Error(is(t))}}async function Pt(){try{if(!Yt.currentUser)return[];const s=as(se(X,"accessAuditLogs"),Nt("timestamp","desc"),Ss(100));return(await de(s)).docs.map(i=>{const r=i.data(),n=r.success!==!1?"Info":"Error",o=r.action||"";let m="System";return r.module==="admin"||o.startsWith("admin_")?m="User":o.includes("login")||o.includes("auth")?m="Auth":(o.includes("upload")||o.includes("course"))&&(m="Content"),{id:i.id,severity:n,timestamp:typeof r.timestamp=="string"?r.timestamp:zt(r.timestamp),user:{name:r.actorName||r.teacherEmail||"System",role:r.actorRole||r.role||"Admin",avatar:null},action:o,category:m,details:r.description||(r.status?`Status: ${r.status}`:"")}})}catch(s){const t=s;return t?.code==="permission-denied"||t?.code==="firestore/permission-denied"?[]:(console.error("[adminService] getAuditLogs error:",s),[])}}async function js(s,t,i,r,h){await ca(se(X,"auditLogs"),{severity:i,timestamp:Va(),timestampRaw:yt(),user:h,action:s,category:t,details:r})}async function er(){try{const s=await de(se(X,"users"));let t=0,i=0,r=0;s.docs.forEach(m=>{const v=m.data();v.role==="student"&&(t++,v.overallRisk==="High"&&r++),v.role==="teacher"&&v.status!=="Inactive"&&i++});let h=0;try{h=(await de(se(X,"classrooms"))).size}catch{}let n=0;try{n=(await de(se(X,"xpActivities"))).size}catch{}let o=0;try{const m=await de(se(X,"progress")),v=[];m.docs.forEach(p=>{const S=p.data();typeof S.averageScore=="number"&&v.push(S.averageScore)}),o=v.length>0?Math.round(v.reduce((p,S)=>p+S,0)/v.length):0}catch{}return{totalStudents:t,activeTeachers:i,totalClasses:h,atRiskStudents:r,avgPerformance:o,aiPredictions:n}}catch(s){return console.error("[adminService] getDashboardStats error:",s),{totalStudents:0,activeTeachers:0,totalClasses:0,atRiskStudents:0,avgPerformance:0,aiPredictions:0}}}async function sr(s=3){const t=r=>{const h=r.data(),n=h.level||1,o=h.currentXP||0,m=Math.min(100,n*8+Math.round(o/100));return{id:r.id,name:h.name||"Student",avatar:h.photo||h.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(h.name||"S")}&background=0d9488&color=fff`,class:h.grade||"Math",performance:m,level:n}},i=r=>r.sort((h,n)=>n.level!==h.level?n.level-h.level:n.performance-h.performance).slice(0,s);try{const r=as(se(X,"users"),ks("role","==","student"),Nt("level","desc"),Ss(s)),h=await de(r);return i(h.docs.map(t))}catch(r){if(r?.code==="failed-precondition")try{const n=as(se(X,"users"),ks("role","==","student"),Ss(Math.max(50,s))),o=await de(n);return i(o.docs.map(t))}catch(n){return console.error("[adminService] getTopPerformers fallback error:",n),[]}return console.error("[adminService] getTopPerformers error:",r),[]}}async function tr(){try{const s=await de(se(X,"users"));let t=0,i=0,r=0,h=0,n=0;s.docs.forEach(v=>{const p=v.data();p.role==="student"&&(t++,p.overallRisk==="High"&&r++,p.streak>0&&n++,h+=p.totalXP||0),p.role==="teacher"&&i++});let o=0;try{o=(await de(se(X,"achievements"))).size}catch{}let m=0;try{m=(await de(se(X,"chatSessions"))).size}catch{}return{totalActiveUsers:t+i,totalStudents:t,totalTeachers:i,atRiskStudents:r,achievementsUnlocked:o,totalXPEarned:h,activeStreaks:n,aiTutorSessions:m}}catch(s){return console.error("[adminService] getAnalyticsSummary error:",s),{totalActiveUsers:0,totalStudents:0,totalTeachers:0,atRiskStudents:0,achievementsUnlocked:0,totalXPEarned:0,activeStreaks:0,aiTutorSessions:0}}}const ar=()=>{const{userProfile:s,loading:t}=Ee(),[i,r]=l.useState([]),[h,n]=l.useState(!0),[o,m]=l.useState(!1),[v,p]=l.useState(""),[S,f]=l.useState("All Categories"),[j,w]=l.useState("All Severity"),[A,k]=l.useState("All Roles"),[d,y]=l.useState(25),[L,C]=l.useState(null),B=l.useCallback(async()=>{if(t||!s)return;const b=String(s.role||"").toLowerCase();if(b!=="admin"&&b!=="teacher"){n(!1),m(!0);return}m(!1),n(!0);try{const V=await Pt();r(V)}catch{z.error("Failed to load audit logs")}finally{n(!1)}},[t,s]);l.useEffect(()=>{B()},[B]),l.useEffect(()=>{y(25)},[v,S,j,A,i.length]);const q=i.filter(b=>b.severity==="Info").length,O=i.filter(b=>b.severity==="Warning").length,G=i.filter(b=>b.severity==="Error"||b.severity==="Critical").length,Y=b=>{switch(b){case"Info":return e.jsx(we,{size:16,className:"text-sky-600"});case"Warning":return e.jsx(oe,{size:16,className:"text-rose-600"});case"Error":return e.jsx(Se,{size:16,className:"text-red-600"});case"Critical":return e.jsx(Se,{size:16,className:"text-red-600"});default:return e.jsx(we,{size:16,className:"text-[#5a6578]"})}},_=b=>{switch(b){case"Info":return"bg-sky-100 text-sky-700 border-sky-200";case"Warning":return"bg-rose-100 text-rose-700 border-rose-200";case"Error":return"bg-red-100 text-red-700 border-red-200";case"Critical":return"bg-red-100 text-red-700 border-red-200 ring-2 ring-red-500";default:return"bg-[#edf1f7] text-[#0a1628] border-[#dde3eb]"}},ee=b=>{switch(b){case"Auth":return"bg-sky-100 text-sky-700";case"Data":return"bg-rose-100 text-rose-700";case"User":return"bg-sky-100 text-sky-700";case"System":return"bg-[#edf1f7] text-[#0a1628]";case"Content":return"bg-green-100 text-green-700";default:return"bg-[#edf1f7] text-[#0a1628]"}},Q=i.filter(b=>{const V=b.action.toLowerCase().includes(v.toLowerCase())||b.details.toLowerCase().includes(v.toLowerCase())||b.user.name.toLowerCase().includes(v.toLowerCase()),x=S==="All Categories"||b.category===S,E=j==="All Severity"||b.severity===j,c=A==="All Roles"||b.user.role===A;return V&&x&&E&&c}),ce=Q.slice(0,d);return e.jsxs(U.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Audit Log"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"System activity monitoring and security events"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3",children:[e.jsxs("div",{className:"bg-white px-3 py-2 rounded-xl border border-[#dde3eb] flex items-center gap-2 text-[#5a6578] text-sm font-medium",children:[e.jsx(ys,{size:16}),e.jsx("span",{children:"Last 100 events"})]}),e.jsxs(M,{variant:"outline",className:"gap-2 border-[#dde3eb] hover:bg-[#edf1f7]",onClick:B,children:[e.jsx(Re,{size:16}),"Refresh"]}),e.jsx(M,{variant:"outline",disabled:!0,title:"Audit log export is not implemented yet",className:"gap-2 border-[#dde3eb] opacity-60 cursor-not-allowed",children:"Export (Unavailable)"})]}),h?e.jsx("div",{className:"flex items-center justify-center h-24",children:e.jsx(H,{size:24,className:"animate-spin text-sky-500"})}):o?e.jsxs("div",{className:"flex flex-col items-center justify-center h-24 text-center",children:[e.jsx(mt,{size:24,className:"text-[#a0aec0] mb-2"}),e.jsx("p",{className:"text-sm font-medium text-[#5a6578]",children:"Audit logs are available only to teachers and admins."})]}):null,!o&&!h&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-[#dde3eb] shadow-sm",children:[e.jsx("p",{className:"text-xs font-bold text-[#5a6578] mb-1",children:"Total Events"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:i.length})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-sky-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(we,{size:14,className:"text-sky-600"}),e.jsx("p",{className:"text-xs font-bold text-[#5a6578]",children:"Info"})]}),e.jsx("p",{className:"text-2xl font-bold text-sky-600",children:q})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-rose-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(oe,{size:14,className:"text-rose-600"}),e.jsx("p",{className:"text-xs font-bold text-[#5a6578]",children:"Warnings"})]}),e.jsx("p",{className:"text-2xl font-bold text-rose-600",children:O})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-red-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Se,{size:14,className:"text-red-600"}),e.jsx("p",{className:"text-xs font-bold text-[#5a6578]",children:"Errors"})]}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:G})]})]}),!o&&e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-[#dde3eb] shadow-sm space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:18}),e.jsx(R,{type:"text",placeholder:"Search by user, action, or details...",className:"pl-10 bg-[#edf1f7] border-[#dde3eb]",value:v,onChange:b=>p(b.target.value)})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3",children:[e.jsxs(re,{value:S,onValueChange:f,children:[e.jsx(le,{className:"w-full sm:w-[170px]",children:e.jsx(ie,{placeholder:"All Categories"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"All Categories",children:"All Categories"}),e.jsx(P,{value:"Auth",children:"Auth"}),e.jsx(P,{value:"Data",children:"Data"}),e.jsx(P,{value:"User",children:"User"}),e.jsx(P,{value:"System",children:"System"}),e.jsx(P,{value:"Content",children:"Content"})]})]}),e.jsxs(re,{value:j,onValueChange:w,children:[e.jsx(le,{className:"w-full sm:w-[170px]",children:e.jsx(ie,{placeholder:"All Severity"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"All Severity",children:"All Severity"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Warning",children:"Warning"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Critical",children:"Critical"})]})]}),e.jsxs(re,{value:A,onValueChange:k,children:[e.jsx(le,{className:"w-full sm:w-[170px]",children:e.jsx(ie,{placeholder:"All Roles"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"All Roles",children:"All Roles"}),e.jsx(P,{value:"Admin",children:"Admin"}),e.jsx(P,{value:"Teacher",children:"Teacher"}),e.jsx(P,{value:"Student",children:"Student"})]})]})]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] shadow-sm overflow-hidden",children:[e.jsx("div",{className:"md:hidden divide-y divide-[#dde3eb]",children:ce.map(b=>e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold border ${_(b.severity)}`,children:[Y(b.severity),b.severity]}),e.jsx("button",{type:"button",onClick:()=>C(b),className:"p-2 hover:bg-[#dde3eb] rounded-lg text-slate-500 hover:text-sky-600 transition-colors","aria-label":`View audit event ${b.action}`,children:e.jsx(rs,{size:16})})]}),e.jsx("p",{className:"text-sm font-semibold text-[#0a1628]",children:b.action}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:b.timestamp}),e.jsxs("p",{className:"text-xs text-[#5a6578]",children:[b.user.name," (",b.user.role,")"]}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:b.details})]},`mobile-${b.id}`))}),e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[980px] text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#edf1f7] border-b border-[#dde3eb]",children:[e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Severity"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Timestamp"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"User"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Action"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Category"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider",children:"Details"}),e.jsx("th",{className:"p-4 text-xs font-bold text-[#5a6578] uppercase tracking-wider text-right",children:"View"})]})}),e.jsx("tbody",{className:"divide-y divide-[#dde3eb]",children:ce.map(b=>e.jsxs("tr",{className:"hover:bg-[#edf1f7] transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold border ${_(b.severity)}`,children:[Y(b.severity),b.severity]})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-[#5a6578] text-sm",children:[e.jsx("div",{className:"p-1 bg-[#edf1f7] rounded",children:e.jsx(ys,{size:12})}),b.timestamp]})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[b.user.avatar?e.jsx("img",{src:b.user.avatar,alt:b.user.name,className:"w-8 h-8 rounded-full object-cover"}):e.jsx("div",{className:"w-8 h-8 bg-sky-100 rounded-full flex items-center justify-center",children:e.jsx(Je,{size:16,className:"text-sky-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-[#0a1628] text-sm",children:b.user.name}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:b.user.role})]})]})}),e.jsx("td",{className:"p-4",children:e.jsx("p",{className:"font-medium text-[#0a1628] text-sm",children:b.action})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:`px-2 py-1 rounded text-xs font-bold ${ee(b.category)}`,children:b.category})}),e.jsx("td",{className:"p-4 text-sm text-[#5a6578] max-w-xs truncate",title:b.details,children:b.details}),e.jsx("td",{className:"p-4 text-right",children:e.jsx("button",{type:"button",onClick:()=>C(b),className:"p-2 hover:bg-[#dde3eb] rounded-lg text-slate-500 hover:text-sky-600 transition-colors","aria-label":`View audit event ${b.action}`,children:e.jsx(rs,{size:16})})})]},b.id))})]})}),Q.length>d?e.jsx("div",{className:"border-t border-[#dde3eb] p-4 flex justify-center",children:e.jsx(M,{variant:"outline",className:"border-[#dde3eb]",onClick:()=>y(b=>b+25),children:"Load more events"})}):null,Q.length===0&&!h&&e.jsxs("div",{className:"p-12 text-center text-[#5a6578]",children:[e.jsx(Je,{size:48,className:"mx-auto mb-4 text-slate-500"}),e.jsx("p",{className:"font-medium",children:"No logs found"}),e.jsx("p",{className:"text-sm",children:i.length===0?"Audit events will appear here as actions are performed":"Try adjusting your search or filters"})]})]}),e.jsx(pt,{open:!!L,onOpenChange:b=>{b||C(null)},children:e.jsxs(ft,{children:[e.jsxs(bt,{children:[e.jsx(jt,{children:L?.action||"Audit Event Details"}),e.jsx(vt,{children:"Detailed audit information for operational review."})]}),L?e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:"Severity:"})," ",L.severity]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:"Category:"})," ",L.category]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:"Timestamp:"})," ",L.timestamp]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:"User:"})," ",L.user.name," (",L.user.role,")"]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:"Details:"})," ",L.details]})]}):null]})})]})},ls="—";function ve(s,t=ls){return s==null?t:String(s)}function rr(s){return s?s instanceof Date?s.toLocaleString():typeof s.toDate=="function"?s.toDate().toLocaleString():ls:ls}function Ce({label:s,value:t,accent:i}){return e.jsxs("div",{className:`rounded-xl border p-4 ${i?"bg-sky-50 border-sky-200":"bg-white border-[#dde3eb]"}`,children:[e.jsx("p",{className:"text-xs font-medium text-[#5a6578] uppercase tracking-wide mb-1",children:s}),e.jsx("p",{className:`text-base font-semibold ${t===ls?"text-slate-400":"text-[#0a1628]"}`,children:t})]})}function lr(){const[s,t]=l.useState(null),[i,r]=l.useState(!0),[h,n]=l.useState(null);return l.useEffect(()=>{(async()=>{r(!0),n(null);try{const m=As(X,"settings","modelConfig"),v=await wt(m);v.exists()?t(v.data()):t({})}catch(m){n(m.message??"Failed to load model configuration")}finally{r(!1)}})()},[]),i?e.jsx("div",{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Loading model configuration..."})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-blue-50 border border-blue-200 rounded-xl text-blue-800",children:[e.jsx(we,{size:16,className:"mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-xs leading-relaxed",children:"This configuration is managed by the system and cannot be edited here."})]}),h&&e.jsxs("p",{className:"text-sm text-red-600",children:["Error: ",h]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(Ce,{label:"Active Model Name",value:ve(s?.activeModelName)}),e.jsx(Ce,{label:"Provider / Endpoint",value:s?.endpoint?`${ve(s?.provider)} — ${s.endpoint}`:ve(s?.provider)}),e.jsx(Ce,{label:"Max Tokens",value:ve(s?.maxTokens)}),e.jsx(Ce,{label:"Temperature",value:ve(s?.temperature)}),e.jsx(Ce,{label:"Context Window",value:ve(s?.contextWindow)}),e.jsx(Ce,{label:"Fine-tune Status",value:ve(s?.fineTuneStatus),accent:!0})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb]",children:e.jsxs("p",{className:"text-xs text-[#5a6578]",children:["Last updated:"," ",e.jsx("span",{className:"font-medium text-[#0a1628]",children:rr(s?.lastUpdated)})]})})]})}const Dt="settings",Ks="general",Js="notifications",Zs="gamification",Ys="content",et={platformName:"MathPulse AI",institutionName:"",logoUrl:"",maintenanceMode:!1},st={emailAlertsOnRegistration:!1,alertOnQuizCompletionThreshold:!1,quizCompletionThresholdPercent:80,announcementBannerEnabled:!1,announcementBannerMessage:""},tt={xpPerCorrectAnswer:10,xpPerQuizCompletion:50,streakBonusMultiplier:1,leaderboardVisibility:!0},at={defaultQuizTimeLimitMinutes:30,maxQuestionsPerQuiz:20,allowStudentRetries:!0,difficultyAutoAdjustment:!1};async function Ge(s,t){try{const i=As(X,Dt,s),r=await wt(i);return r.exists()?{...t,...r.data()}:t}catch(i){return console.error(`[settings] Failed to load ${s}:`,i),t}}async function _e(s,t){await oa(As(X,Dt,s),{...t,updatedAt:yt()},{merge:!0})}const ir=[{id:"General",label:"General",icon:kt},{id:"Notifications",label:"Notifications",icon:ua},{id:"Gamification",label:"Gamification",icon:Ra},{id:"Content",label:"Content",icon:es},{id:"Model Config",label:"Model Configuration",icon:xt}],nr=({onDirtyChange:s})=>{const{userProfile:t}=Ee(),[i,r]=l.useState("General"),[h,n]=l.useState(et),[o,m]=l.useState(st),[v,p]=l.useState(tt),[S,f]=l.useState(at),[j,w]=l.useState(!1),[A,k]=l.useState(!1),[d,y]=l.useState(!1),[L,C]=l.useState(!1),[B,q]=l.useState(!1),[O,G]=l.useState(!1),[Y,_]=l.useState(!1),[ee,Q]=l.useState(!1);l.useEffect(()=>{t?.uid&&(w(!0),k(!0),y(!0),C(!0),Promise.all([Ge(Ks,et),Ge(Js,st),Ge(Zs,tt),Ge(Ys,at)]).then(([c,u,$,te])=>{n(c),m(u),p($),f(te)}).catch(c=>{console.error("[AdminSettings] Failed to load settings:",c),z.error("Failed to load admin settings")}).finally(()=>{w(!1),k(!1),y(!1),C(!1)}))},[t?.uid]);const ce=async()=>{q(!0);try{await _e(Ks,h),z.success("General settings saved")}catch(c){console.error("[AdminSettings] Failed to save general:",c),z.error("Failed to save general settings")}finally{q(!1)}},b=async()=>{G(!0);try{await _e(Js,o),z.success("Notification settings saved")}catch(c){console.error("[AdminSettings] Failed to save notifications:",c),z.error("Failed to save notification settings")}finally{G(!1)}},V=async()=>{_(!0);try{await _e(Zs,v),z.success("Gamification settings saved")}catch(c){console.error("[AdminSettings] Failed to save gamification:",c),z.error("Failed to save gamification settings")}finally{_(!1)}},x=async()=>{Q(!0);try{await _e(Ys,S),z.success("Content settings saved")}catch(c){console.error("[AdminSettings] Failed to save content:",c),z.error("Failed to save content settings")}finally{Q(!1)}},E=j||A||d||L;return e.jsx(U.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4 md:gap-6",children:[e.jsx("div",{className:"md:col-span-3",children:e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-[#dde3eb] overflow-hidden",children:e.jsx("nav",{className:"grid grid-cols-2 sm:grid-cols-3 md:flex md:flex-col py-2",children:ir.map(c=>{const u=c.icon,$=i===c.id;return e.jsxs("button",{onClick:()=>r(c.id),className:`flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all relative ${$?"text-sky-600 bg-sky-50/50":"text-[#5a6578] hover:bg-[#edf1f7] hover:text-[#0a1628]"}`,children:[$&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-sky-600 rounded-r-full"}),e.jsx(u,{size:18,className:$?"text-sky-600":"text-slate-500"}),c.label]},c.id)})})})}),e.jsx("div",{className:"md:col-span-9",children:e.jsx(U.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"space-y-6",children:e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-[#dde3eb] p-6",children:E?e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Loading settings..."}):e.jsxs(e.Fragment,{children:[i==="General"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Platform Name"}),e.jsx(R,{value:h.platformName,onChange:c=>n(u=>({...u,platformName:c.target.value})),className:"bg-white max-w-md"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"School / Institution Name"}),e.jsx(R,{value:h.institutionName,onChange:c=>n(u=>({...u,institutionName:c.target.value})),placeholder:"Enter institution name",className:"bg-white max-w-md"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Logo URL"}),e.jsx(R,{value:h.logoUrl,onChange:c=>n(u=>({...u,logoUrl:c.target.value})),placeholder:"https://example.com/logo.png",className:"bg-white max-w-md"})]}),e.jsxs("div",{className:"mt-6 p-4 bg-red-50 border border-red-100 rounded-xl flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-white rounded-lg text-red-600 shadow-sm border border-red-100",children:e.jsx(kt,{size:18})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-red-900",children:"Maintenance Mode"}),e.jsx("p",{className:"text-xs text-red-700 mt-0.5",children:"Temporarily disable access for non-admins"})]})]}),e.jsx(be,{checked:h.maintenanceMode,onCheckedChange:c=>n(u=>({...u,maintenanceMode:c})),className:"data-[state=checked]:bg-red-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb] flex justify-end",children:e.jsxs(M,{className:`bg-sky-600 hover:bg-sky-700 text-white gap-2 ${B?"opacity-70 cursor-not-allowed":""}`,onClick:ce,disabled:B,children:[B&&e.jsx(H,{size:16,className:"animate-spin"}),B?"Saving...":"Save Changes"]})})]}),i==="Notifications"&&e.jsxs("div",{className:"space-y-5",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]",children:"Email Alerts on New User Registrations"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Send email notification when a new user signs up"})]}),e.jsx(be,{checked:o.emailAlertsOnRegistration,onCheckedChange:c=>m(u=>({...u,emailAlertsOnRegistration:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),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]",children:"Alert on Quiz Completion Threshold"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Notify when a student's quiz score crosses a threshold"})]}),e.jsx(be,{checked:o.alertOnQuizCompletionThreshold,onCheckedChange:c=>m(u=>({...u,alertOnQuizCompletionThreshold:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),o.alertOnQuizCompletionThreshold&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Threshold Percentage (%)"}),e.jsx(R,{type:"number",min:0,max:100,value:o.quizCompletionThresholdPercent,onChange:c=>m(u=>({...u,quizCompletionThresholdPercent:Number(c.target.value||0)})),className:"max-w-xs bg-white"})]}),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]",children:"Announcement Banner"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Show a platform-wide banner message"})]}),e.jsx(be,{checked:o.announcementBannerEnabled,onCheckedChange:c=>m(u=>({...u,announcementBannerEnabled:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),o.announcementBannerEnabled&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Banner Message"}),e.jsx(R,{value:o.announcementBannerMessage,onChange:c=>m(u=>({...u,announcementBannerMessage:c.target.value})),placeholder:"Enter banner message text",className:"bg-white"})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb] flex justify-end",children:e.jsxs(M,{className:`bg-sky-600 hover:bg-sky-700 text-white gap-2 ${O?"opacity-70 cursor-not-allowed":""}`,onClick:b,disabled:O,children:[O&&e.jsx(H,{size:16,className:"animate-spin"}),O?"Saving...":"Save Changes"]})})]}),i==="Gamification"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"XP Earned per Correct Answer"}),e.jsx(R,{type:"number",min:0,value:v.xpPerCorrectAnswer,onChange:c=>p(u=>({...u,xpPerCorrectAnswer:Number(c.target.value||0)})),className:"max-w-xs bg-white"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"XP Earned per Quiz Completion"}),e.jsx(R,{type:"number",min:0,value:v.xpPerQuizCompletion,onChange:c=>p(u=>({...u,xpPerQuizCompletion:Number(c.target.value||0)})),className:"max-w-xs bg-white"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Streak Bonus Multiplier"}),e.jsx(R,{type:"number",min:0,step:.1,value:v.streakBonusMultiplier,onChange:c=>p(u=>({...u,streakBonusMultiplier:Number(c.target.value||0)})),className:"max-w-xs bg-white"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Applied as a multiplier to streak XP rewards."})]}),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]",children:"Leaderboard Visibility"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Show the leaderboard to students"})]}),e.jsx(be,{checked:v.leaderboardVisibility,onCheckedChange:c=>p(u=>({...u,leaderboardVisibility:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb] flex justify-end",children:e.jsxs(M,{className:`bg-sky-600 hover:bg-sky-700 text-white gap-2 ${Y?"opacity-70 cursor-not-allowed":""}`,onClick:V,disabled:Y,children:[Y&&e.jsx(H,{size:16,className:"animate-spin"}),Y?"Saving...":"Save Changes"]})})]}),i==="Content"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Default Quiz Time Limit (minutes)"}),e.jsx(R,{type:"number",min:1,value:S.defaultQuizTimeLimitMinutes,onChange:c=>f(u=>({...u,defaultQuizTimeLimitMinutes:Number(c.target.value||1)})),className:"max-w-xs bg-white"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-[#0a1628]",children:"Max Questions Per Quiz"}),e.jsx(R,{type:"number",min:1,value:S.maxQuestionsPerQuiz,onChange:c=>f(u=>({...u,maxQuestionsPerQuiz:Number(c.target.value||1)})),className:"max-w-xs bg-white"})]}),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]",children:"Allow Student Retries"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Let students retry quizzes"})]}),e.jsx(be,{checked:S.allowStudentRetries,onCheckedChange:c=>f(u=>({...u,allowStudentRetries:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),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]",children:"Difficulty Auto-Adjustment"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Automatically adjust quiz difficulty based on performance"})]}),e.jsx(be,{checked:S.difficultyAutoAdjustment,onCheckedChange:c=>f(u=>({...u,difficultyAutoAdjustment:c})),className:"data-[state=checked]:bg-sky-600 data-[state=unchecked]:bg-[#dde3eb]"})]}),e.jsx("div",{className:"pt-4 border-t border-[#dde3eb] flex justify-end",children:e.jsxs(M,{className:`bg-sky-600 hover:bg-sky-700 text-white gap-2 ${ee?"opacity-70 cursor-not-allowed":""}`,onClick:x,disabled:ee,children:[ee&&e.jsx(H,{size:16,className:"animate-spin"}),ee?"Saving...":"Save Changes"]})})]}),i==="Model Config"&&e.jsx(lr,{})]})})})})]})})};function He({className:s,...t}){return e.jsx(ha,{"data-slot":"checkbox",className:ke("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...t,children:e.jsx(ga,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx(pa,{className:"size-3.5"})})})}const dr=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cr=/[A-Z]/,or=/[a-z]/,mr=/\d/,xr=/[^A-Za-z0-9]/;function ur(s){const t={};s.name.trim()||(t.name="Name is required.");const i=s.email.trim().toLowerCase();i?dr.test(i)||(t.email="Enter a valid email address."):t.email="Email is required.";const r=s.password;return r.length<8?t.password="Password must be at least 8 characters.":cr.test(r)?or.test(r)?mr.test(r)?xr.test(r)||(t.password="Password must include at least one special character."):t.password="Password must include at least one number.":t.password="Password must include at least one lowercase letter.":t.password="Password must include at least one uppercase letter.",s.confirmPassword?s.confirmPassword!==r&&(t.confirmPassword="Passwords do not match."):t.confirmPassword="Confirm password is required.",s.role.trim()||(t.role="Role is required."),s.status.trim()||(t.status="Status is required."),s.grade.trim()||(t.grade="Grade is required."),s.section.trim()||(t.section="Section is required."),s.role.trim().toLowerCase()==="student"&&!s.lrn.trim()&&(t.lrn="LRN is required for student accounts."),t}function hr(s){return Object.values(s).find(i=>!!i)??null}const rt=(s="Student")=>({name:"",email:"",password:"",confirmPassword:"",role:s,status:"Active",department:s==="Teacher"?"Mathematics":s==="Admin"?"System":"",grade:"Grade 11",section:"Section A",lrn:""}),gr=["10","25","50","100"];function lt(s,t){const i=s.trim();if(!(!i||i===t))return i}function it(s){const t=String(s??"");return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}const pr=({createIntentRole:s=null,onCreateIntentConsumed:t})=>{const{userProfile:i}=Ee(),[r,h]=l.useState([]),[n,o]=l.useState(!0),[m,v]=l.useState(null),[p,S]=l.useState(!1),[f,j]=l.useState(!1),[w,A]=l.useState(null),[k,d]=l.useState(1),[y,L]=l.useState(25),[C,B]=l.useState(0),[q,O]=l.useState(1),[G,Y]=l.useState(!1),[_,ee]=l.useState(""),[Q,ce]=l.useState("All Roles"),[b,V]=l.useState("All Status"),[x,E]=l.useState(new Set),[c,u]=l.useState(!1),[$,te]=l.useState(new Set),[Ue,ns]=l.useState({}),[Ae,Tt]=l.useState("Student"),[ds,Lt]=l.useState("Active"),[cs,Mt]=l.useState("Grade 11"),[os,It]=l.useState("Section A"),[Rt,ze]=l.useState(!1),[Et,ms]=l.useState(!1),[$e,zs]=l.useState(!1),[xe,xs]=l.useState(null),[J,Ps]=l.useState(null),[D,ae]=l.useState({}),[us,Pe]=l.useState(!1),[hs,De]=l.useState(!1),[N,K]=l.useState(rt()),F=l.useMemo(()=>({search:_.trim()||void 0,role:lt(Q,"All Roles"),status:lt(b,"All Status")}),[_,Q,b]),ge=l.useCallback(()=>{E(new Set),u(!1),te(new Set)},[]),Fe=l.useCallback(a=>c?!$.has(a):x.has(a),[c,$,x]),W=l.useMemo(()=>c?Math.max(C-$.size,0):x.size,[c,$,x,C]),Ds=l.useMemo(()=>r.length===0?!1:r.every(a=>Fe(a.id)),[r,Fe]),ue=l.useMemo(()=>c?[]:Array.from(x).map(a=>Ue[a]).filter(a=>!!a),[c,x,Ue]),Ts=l.useMemo(()=>W===0?!1:c?!F.role||F.role.toLowerCase()==="student":ue.length!==x.size?!1:ue.every(a=>a.role==="Student"),[c,W,ue,x.size,F.role]),Ls=l.useMemo(()=>W===0?!1:c?F.status?.toLowerCase()!=="active":ue.length!==x.size?!1:ue.some(a=>a.status!=="Active"),[c,W,ue,x.size,F.status]),Ms=l.useMemo(()=>W===0?!1:c?F.status?.toLowerCase()!=="inactive":ue.length!==x.size?!1:ue.some(a=>a.status!=="Inactive"),[c,W,ue,x.size,F.status]),pe=l.useCallback(async a=>{o(!0),v(null);try{const g=await Ka({page:a,pageSize:y,searchQuery:F.search,roleFilter:F.role,statusFilter:F.status});h(g.users),d(g.total===0?1:g.page),B(g.total),O(g.totalPages||1),Y(g.hasNextPage),ns(I=>{const fe={...I};return g.users.forEach(T=>{fe[T.id]=T}),fe})}catch(g){const I=g instanceof Error?g.message:"Failed to load users";v(I),z.error(I)}finally{o(!1)}},[y,F.search,F.role,F.status]);l.useEffect(()=>{pe(k)},[pe,k]);const gs=l.useCallback((a="Student")=>{Ps(null),ae({}),Pe(!1),De(!1),K(rt(a)),ze(!0)},[]);l.useEffect(()=>{s&&(gs(s),t?.())},[s,gs,t]);const Is=l.useCallback(a=>{if(c){te(g=>{const I=new Set(g);return I.has(a)?I.delete(a):I.add(a),I});return}E(g=>{const I=new Set(g);return I.has(a)?I.delete(a):I.add(a),I})},[c]),Rs=l.useCallback(()=>{if(r.length===0)return;const a=r.map(g=>g.id);if(c){te(g=>{const I=new Set(g);return a.every(T=>!I.has(T))?a.forEach(T=>I.add(T)):a.forEach(T=>I.delete(T)),I});return}E(g=>{const I=new Set(g);return a.every(T=>I.has(T))?a.forEach(T=>I.delete(T)):a.forEach(T=>I.add(T)),I})},[r,c]),Ut=l.useCallback(()=>{u(!0),E(new Set),te(new Set)},[]),Es=l.useCallback(a=>{if(!a.length){z.info("No rows were returned for export.");return}const g=Array.from(a.reduce((qe,fs)=>(Object.keys(fs).forEach(Jt=>qe.add(Jt)),qe),new Set)),I=[g.map(it).join(","),...a.map(qe=>g.map(fs=>it(qe[fs])).join(","))].join(` -`),fe=new Blob([I],{type:"text/csv;charset=utf-8;"}),T=URL.createObjectURL(fe),ps=document.createElement("a");ps.href=T,ps.download=`admin-users-export-${Date.now()}.csv`,ps.click(),URL.revokeObjectURL(T)},[]),he=l.useCallback(async(a,g)=>{const I=g.userIds,fe={...F.search?{search:F.search}:{},...F.role?{role:F.role}:{},...F.status?{status:F.status}:{}};if(!I&&W===0){z.error("Select at least one user before applying a bulk action.");return}j(!0);try{const T=await Ya({action:a,...I?{userIds:I}:c?{userIds:[],excludeUserIds:Array.from($),filters:fe}:{userIds:Array.from(x)},...g.role?{role:g.role}:{},...g.status?{status:g.status}:{},...g.grade?{grade:g.grade}:{},...g.section?{section:g.section}:{},...g.exportFormat?{exportFormat:g.exportFormat}:{}});a==="export"&&Es(T.exportRows),T.summary.failed>0?z.warning(`Completed with partial failures. ${T.summary.succeeded} succeeded, ${T.summary.failed} failed, ${T.summary.skipped} skipped.`):z.success(`Action completed. ${T.summary.succeeded} user(s) updated.`),T.warnings.length>0&&z.info(T.warnings[0]),await js(g.auditAction,"User",a==="delete"||a==="deactivate"?"Warning":"Info",`${g.auditDetail}; targeted=${T.summary.targeted}, succeeded=${T.summary.succeeded}, failed=${T.summary.failed}, skipped=${T.summary.skipped}`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),g.skipSelectionReset||ge(),await pe(k)}catch(T){z.error(T instanceof Error?T.message:"Bulk action failed")}finally{j(!1)}},[F.search,F.role,F.status,c,$,x,W,i?.name,i?.photo,ge,pe,k,Es]),Be=l.useCallback(a=>{xs(a),ms(!0)},[]),$t=l.useCallback(async()=>{if(!(!xe||$e)){zs(!0);try{await he(xe.action,{...xe.params||{},auditAction:xe.auditAction,auditDetail:xe.auditDetail}),ms(!1),xs(null)}finally{zs(!1)}}},[xe,$e,he]),Us=a=>{Ps(a),ae({}),Pe(!1),De(!1),K({name:a.name,email:a.email,password:"",confirmPassword:"",role:a.role,status:a.status,department:a.department,grade:a.grade||"Grade 11",section:a.section||"Section A",lrn:a.lrn||""}),ze(!0)},Ft=async()=>{if(!N.name.trim()||!N.email.trim()){z.error("Name and email are required");return}if(!J){const a=ur({name:N.name,email:N.email,password:N.password,confirmPassword:N.confirmPassword,role:N.role,status:N.status,grade:N.grade,section:N.section,lrn:N.lrn}),g=hr(a);if(g){ae(a),z.error(g);return}}S(!0);try{if(J){const a={name:N.name,role:N.role,status:N.status,grade:N.grade,section:N.section,lrn:N.role==="Student"?N.lrn:void 0};N.role!=="Student"&&(a.department=N.department),await Ja(J.id,a),await js("User Updated","User","Info",`Updated user: ${N.name} (${J.email})`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),z.success("User updated successfully")}else{const a=await Za({email:N.email,name:N.name,password:N.password,confirmPassword:N.confirmPassword,role:N.role,status:N.status,grade:N.grade,section:N.section,lrn:N.role==="Student"?N.lrn:void 0});await js("Created New User","User","Info",`Created new ${N.role.toLowerCase()} account: ${N.name} (${N.email}), emailSent=${a.emailSent}`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),a.emailSent?z.success("User created and welcome email sent"):(z.warning("User created, but welcome email failed to send"),a.emailError?.message&&z.error(a.emailError.message))}J?await pe(k):(ge(),d(1),await pe(1)),ze(!1),Pe(!1),De(!1)}finally{S(!1)}},$s=(a,g)=>{Be({title:"Delete User?",message:`Delete user "${g}"? This cannot be undone.`,confirmText:"Delete",action:"delete",params:{userIds:[a]},auditAction:"User Deleted",auditDetail:`Deleted user account: ${g}`})},Fs=async a=>{if(w||f)return;if(a.status==="Active"){Be({title:"Deactivate User?",message:`Deactivate "${a.name}"? They will lose access until reactivated.`,confirmText:"Deactivate",action:"deactivate",params:{userIds:[a.id]},auditAction:"User Status Changed",auditDetail:`Deactivated user: ${a.email}`});return}A(a.id);try{await he("activate",{userIds:[a.id],auditAction:"User Status Changed",auditDetail:`Activated user: ${a.email}`,skipSelectionReset:!0})}finally{A(null)}},Bt=async()=>{await he("change_role",{role:Ae,auditAction:"Bulk Role Update",auditDetail:`Updated selected users to role ${Ae}`})},qt=async()=>{await he("change_status",{status:ds,auditAction:"Bulk Status Update",auditDetail:`Updated selected users to status ${ds}`})},Ot=async()=>{if(!Ts){z.error("Class/section assignment is only available for student selections.");return}await he("assign_class_section",{grade:cs,section:os,auditAction:"Bulk Class Assignment",auditDetail:`Assigned class section ${cs} - ${os}`})},Gt=async()=>{await he("reset_password_email",{auditAction:"Bulk Password Reset",auditDetail:"Sent password reset emails to selected users"})},_t=async()=>{await he("export",{exportFormat:"csv",auditAction:"Bulk Export Users",auditDetail:"Exported selected users"})},Ht=()=>{Ls&&he("activate",{auditAction:"Bulk User Activation",auditDetail:"Activated selected users"})},Qt=()=>{Ms&&Be({title:"Deactivate Selected Users?",message:`Deactivate ${W} selected user(s)? They will lose access until reactivated.`,confirmText:"Deactivate Users",action:"deactivate",auditAction:"Bulk User Deactivation",auditDetail:`Deactivated ${W} selected users`})},Vt=()=>{Be({title:"Delete Selected Users?",message:`Delete ${W} selected user(s)? This action cannot be undone.`,confirmText:"Delete Users",action:"delete",auditAction:"Bulk User Deletion",auditDetail:`Deleted ${W} selected users`})},Wt=[{label:"Total Users",value:C,color:"text-[#0a1628]"},{label:"Active (Page)",value:r.filter(a=>a.status==="Active").length,color:"text-green-600"},{label:"Admins (Page)",value:r.filter(a=>a.role==="Admin").length,color:"text-sky-600"},{label:"Teachers (Page)",value:r.filter(a=>a.role==="Teacher").length,color:"text-sky-600"},{label:"Students (Page)",value:r.filter(a=>a.role==="Student").length,color:"text-emerald-600"}],Xt=C===0?0:(k-1)*y+1,Kt=C===0?0:Math.min(k*y,C);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-4",children:n?Array.from({length:5}).map((a,g)=>e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-[#dde3eb] shadow-sm",children:[e.jsx("div",{className:"h-7 w-16 bg-[#edf1f7] rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-4 w-24 bg-[#edf1f7] rounded animate-pulse"})]},`stats-skeleton-${g}`)):Wt.map((a,g)=>e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-[#dde3eb] shadow-sm",children:[e.jsx("h3",{className:`text-2xl font-bold ${a.color}`,children:a.value}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:a.label})]},g))}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-[#dde3eb] shadow-sm space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(St,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500",size:18}),e.jsx(R,{placeholder:"Search users by name or email...",className:"pl-10 bg-[#edf1f7] border-[#dde3eb]",value:_,onChange:a=>{ee(a.target.value),d(1),ge()}})]}),e.jsxs("div",{className:"flex flex-col md:flex-row justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(re,{value:Q,onValueChange:a=>{ce(a),d(1),ge()},children:[e.jsx(le,{className:"w-full sm:w-[140px] bg-[#edf1f7] border-[#dde3eb]",children:e.jsx(ie,{placeholder:"All Roles"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"All Roles",children:"All Roles"}),e.jsx(P,{value:"Admin",children:"Admin"}),e.jsx(P,{value:"Teacher",children:"Teacher"}),e.jsx(P,{value:"Student",children:"Student"})]})]}),e.jsxs(re,{value:b,onValueChange:a=>{V(a),d(1),ge()},children:[e.jsx(le,{className:"w-full sm:w-[140px] bg-[#edf1f7] border-[#dde3eb]",children:e.jsx(ie,{placeholder:"All Status"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"All Status",children:"All Status"}),e.jsx(P,{value:"Active",children:"Active"}),e.jsx(P,{value:"Inactive",children:"Inactive"})]})]}),e.jsxs(re,{value:String(y),onValueChange:a=>{const g=Number(a);Number.isNaN(g)||(L(g),d(1),ge())},children:[e.jsx(le,{className:"w-full sm:w-[150px] bg-[#edf1f7] border-[#dde3eb]",children:e.jsx(ie,{placeholder:"Rows per page"})}),e.jsx(ne,{children:gr.map(a=>e.jsxs(P,{value:a,children:[a," / page"]},a))})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(M,{variant:"outline",className:"gap-2 border-[#dde3eb] text-[#5a6578]",onClick:()=>pe(k),disabled:n||f,children:[e.jsx(Re,{size:16}),"Refresh"]}),e.jsxs(M,{className:"gap-2 bg-sky-500 hover:bg-sky-600 text-white",onClick:()=>gs(),disabled:f,children:[e.jsx(fa,{size:16}),"Add User"]})]})]}),W>0?e.jsxs("div",{className:"border-t border-[#dde3eb] pt-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3",children:[e.jsxs("div",{className:"text-sm text-[#5a6578]",children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:W})," user(s) selected",c?" across filtered results":""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[!c&&W>0&&WTt(a),children:[e.jsx(le,{className:"bg-[#edf1f7] border-[#dde3eb] sm:w-[160px]",children:e.jsx(ie,{placeholder:"Role target"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"Student",children:"Student"}),e.jsx(P,{value:"Teacher",children:"Teacher"}),e.jsx(P,{value:"Admin",children:"Admin"})]})]}),e.jsx(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:()=>void Bt(),disabled:f,children:"Change Role"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(re,{value:ds,onValueChange:a=>Lt(a),children:[e.jsx(le,{className:"bg-[#edf1f7] border-[#dde3eb] sm:w-[160px]",children:e.jsx(ie,{placeholder:"Status target"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"Active",children:"Active"}),e.jsx(P,{value:"Inactive",children:"Inactive"})]})]}),e.jsx(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:()=>void qt(),disabled:f,children:"Change Status"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(R,{value:cs,onChange:a=>Mt(a.target.value),className:"bg-[#edf1f7] border-[#dde3eb] sm:w-[140px]",placeholder:"Grade"}),e.jsx(R,{value:os,onChange:a=>It(a.target.value),className:"bg-[#edf1f7] border-[#dde3eb] sm:w-[140px]",placeholder:"Section"}),e.jsx(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:()=>void Ot(),disabled:f||!Ts,children:"Assign Class"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:Ht,disabled:f||!Ls,children:[e.jsx(Xs,{size:14,className:"mr-2"}),"Activate"]}),e.jsxs(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:Qt,disabled:f||!Ms,children:[e.jsx(Vs,{size:14,className:"mr-2"}),"Deactivate"]}),e.jsxs(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:()=>void Gt(),disabled:f,children:[e.jsx(ja,{size:14,className:"mr-2"}),"Send Reset Email"]}),e.jsxs(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",onClick:()=>void _t(),disabled:f,children:[e.jsx(Ct,{size:14,className:"mr-2"}),"Export Selection"]}),e.jsxs(M,{variant:"destructive",size:"sm",onClick:Vt,disabled:f,children:[e.jsx(Qs,{size:14,className:"mr-2"}),"Delete"]})]})]}):null]}),m?e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx(Se,{size:18,className:"text-red-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-red-700",children:"Unable to load users"}),e.jsx("p",{className:"text-sm text-red-600 break-words",children:m})]})]}),e.jsx(M,{type:"button",variant:"outline",className:"border-red-200 text-red-700 hover:bg-red-100",onClick:()=>pe(k),disabled:n||f,children:"Retry"})]}):null,e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"md:hidden divide-y divide-[#dde3eb]",children:[e.jsxs("div",{className:"px-4 py-3 bg-[#edf1f7] border-b border-[#dde3eb] flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-[#5a6578]",children:[e.jsx(He,{checked:Ds,onCheckedChange:Rs}),"Select visible (",r.length,")"]}),e.jsxs("span",{className:"text-xs text-[#5a6578]",children:["Page ",k," / ",q]})]}),n&&r.length===0?e.jsx("div",{className:"px-6 py-10 text-center text-[#5a6578]",children:"Loading users..."}):r.length>0?r.map(a=>{const g=w===a.id;return e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(He,{checked:Fe(a.id),onCheckedChange:()=>Is(a.id)}),e.jsxs(qs,{children:[e.jsx(Os,{src:a.photo}),e.jsx(Gs,{children:a.name.charAt(0)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-[#0a1628] truncate",children:a.name}),e.jsx("p",{className:"text-xs text-[#5a6578] truncate",children:a.email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-lg bg-[#edf1f7] px-2 py-1.5 text-[#5a6578]",children:["Role: ",e.jsx("span",{className:"font-semibold text-[#0a1628]",children:a.role})]}),e.jsxs("div",{className:"rounded-lg bg-[#edf1f7] px-2 py-1.5 text-[#5a6578]",children:["Status: ",e.jsx("span",{className:"font-semibold text-[#0a1628]",children:a.status})]}),e.jsxs("div",{className:"rounded-lg bg-[#edf1f7] px-2 py-1.5 text-[#5a6578] col-span-2",children:["Last Login: ",e.jsx("span",{className:"font-semibold text-[#0a1628]",children:a.lastLogin||"Never"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Us(a),"aria-label":`Edit ${a.name}`,className:"px-3 py-2 rounded-lg border border-[#dde3eb] text-[#5a6578] hover:bg-[#edf1f7]",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>Fs(a),"aria-label":a.status==="Active"?`Deactivate ${a.name}`:`Activate ${a.name}`,disabled:g||f,className:"px-3 py-2 rounded-lg border border-[#dde3eb] text-[#5a6578] disabled:opacity-60 disabled:cursor-not-allowed",children:g?"Updating...":a.status==="Active"?"Deactivate":"Activate"}),e.jsx("button",{type:"button",onClick:()=>$s(a.id,a.name),"aria-label":`Delete ${a.name}`,disabled:f,className:"px-3 py-2 rounded-lg border border-red-200 text-red-600 disabled:opacity-60 disabled:cursor-not-allowed",children:"Delete"})]})]},`mobile-${a.id}`)}):m?e.jsx("div",{className:"px-6 py-12 text-center text-red-600",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(Se,{size:24,className:"text-red-500"}),e.jsx("p",{children:"Users could not be loaded."})]})}):e.jsx("div",{className:"px-6 py-12 text-center text-[#5a6578]",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-[#edf1f7] rounded-full",children:e.jsx(Ze,{size:24,className:"text-slate-500"})}),e.jsx("p",{children:"No users found matching your filters"})]})})]}),e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm text-left",children:[e.jsx("thead",{className:"text-xs text-[#5a6578] uppercase bg-[#edf1f7] border-b border-[#dde3eb]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-4 font-semibold w-[56px]",children:e.jsx(He,{checked:Ds,onCheckedChange:Rs})}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"User"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Role"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Status"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Class/Department"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Last Login"}),e.jsx("th",{className:"px-6 py-4 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#dde3eb]",children:n&&r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-[#5a6578]",children:"Loading users..."})}):r.length>0?r.map(a=>{const g=w===a.id;return e.jsxs("tr",{className:"hover:bg-[#edf1f7]/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-4",children:e.jsx(He,{checked:Fe(a.id),onCheckedChange:()=>Is(a.id)})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(qs,{children:[e.jsx(Os,{src:a.photo}),e.jsx(Gs,{children:a.name.charAt(0)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-[#0a1628]",children:a.name}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:a.email})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[a.role==="Admin"&&e.jsx(Je,{size:14,className:"text-sky-600"}),a.role==="Teacher"&&e.jsx(Cs,{size:14,className:"text-sky-600"}),a.role==="Student"&&e.jsx(qa,{size:14,className:"text-emerald-600"}),e.jsx("span",{className:` - font-medium text-xs px-2 py-0.5 rounded-full - ${a.role==="Admin"?"bg-sky-100 text-sky-700":""} - ${a.role==="Teacher"?"bg-sky-100 text-sky-700":""} - ${a.role==="Student"?"bg-emerald-100 text-emerald-700":""} - `,children:a.role})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:` - inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border - ${a.status==="Active"?"bg-green-50 text-green-700 border-green-200":"bg-[#edf1f7] text-[#5a6578] border-[#dde3eb]"} - `,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.status==="Active"?"bg-green-500":"bg-[#a8a5b3]"}`}),a.status]})}),e.jsx("td",{className:"px-6 py-4 text-[#5a6578]",children:a.role==="Student"&&a.classSection||a.department}),e.jsx("td",{className:"px-6 py-4 text-[#5a6578]",children:a.lastLogin||"Never"}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Us(a),"aria-label":`Edit ${a.name}`,className:"p-1.5 text-slate-500 hover:text-sky-600 hover:bg-sky-50 rounded-lg transition-colors",children:e.jsx(Ga,{size:16})}),e.jsx("button",{type:"button",onClick:()=>Fs(a),"aria-label":a.status==="Active"?`Deactivate ${a.name}`:`Activate ${a.name}`,disabled:g||f,className:`p-1.5 rounded-lg transition-colors ${g?"opacity-60 cursor-not-allowed":""} ${a.status==="Active"?"text-slate-500 hover:text-orange-600 hover:bg-orange-50":"text-orange-500 hover:text-green-600 hover:bg-green-50"}`,title:a.status==="Active"?"Deactivate User":"Activate User",children:g?e.jsx(H,{size:16,className:"animate-spin"}):a.status==="Active"?e.jsx(Vs,{size:16}):e.jsx(Xs,{size:16})}),e.jsx("button",{type:"button",onClick:()=>$s(a.id,a.name),"aria-label":`Delete ${a.name}`,disabled:f,className:"p-1.5 text-slate-500 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:e.jsx(Qs,{size:16})})]})})]},a.id)}):m?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-red-600",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(Se,{size:24,className:"text-red-500"}),e.jsx("p",{children:"Users could not be loaded."})]})})}):e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-[#5a6578]",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-[#edf1f7] rounded-full",children:e.jsx(Ze,{size:24,className:"text-slate-500"})}),e.jsx("p",{children:"No users found matching your filters"})]})})})})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 px-1",children:[e.jsxs("p",{className:"text-sm text-[#5a6578]",children:["Showing ",e.jsxs("span",{className:"font-semibold text-[#0a1628]",children:[Xt,"-",Kt]})," of"," ",e.jsx("span",{className:"font-semibold text-[#0a1628]",children:C})," users"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",disabled:k<=1||n||f,onClick:()=>d(a=>Math.max(a-1,1)),children:"Previous"}),e.jsxs("span",{className:"text-xs text-[#5a6578] min-w-[72px] text-center",children:["Page ",k," / ",Math.max(q,1)]}),e.jsx(M,{variant:"outline",size:"sm",className:"border-[#dde3eb]",disabled:!G||n||f||k>=q,onClick:()=>d(a=>Math.min(a+1,q||1)),children:"Next"})]})]}),e.jsx(pt,{open:Rt,onOpenChange:ze,children:e.jsxs(ft,{className:"sm:max-w-[425px]",children:[e.jsxs(bt,{children:[e.jsx(jt,{children:J?"Edit User Access":"Add New User"}),e.jsx(vt,{children:J?"Update user details and manage access permissions.":"Create a new account and send welcome credentials by email."})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"name",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Name"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(R,{id:"name",value:N.name,onChange:a=>{K({...N,name:a.target.value}),D.name&&ae(g=>({...g,name:void 0}))},className:D.name?"border-red-500 focus-visible:ring-red-500":""}),D.name?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.name}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"email",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Email"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(R,{id:"email",type:"email",value:N.email,onChange:a=>{J||(K({...N,email:a.target.value}),D.email&&ae(g=>({...g,email:void 0})))},readOnly:!!J,"aria-readonly":!!J,className:`${D.email?"border-red-500 focus-visible:ring-red-500":""} ${J?"bg-[#edf1f7] text-[#5a6578] cursor-not-allowed":""}`}),D.email?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.email}):null,J?e.jsx("p",{className:"mt-1 text-xs text-[#5a6578]",children:"Email changes are disabled because authentication email updates are not supported in this panel."}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"role",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Role"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsxs(re,{value:N.role,onValueChange:a=>{K({...N,role:a,lrn:a==="Student"?N.lrn:""}),ae(g=>({...g,role:void 0,lrn:void 0}))},children:[e.jsx(le,{className:D.role?"border-red-500 focus:ring-red-500":"",children:e.jsx(ie,{placeholder:"Select role"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"Student",children:"Student"}),e.jsx(P,{value:"Teacher",children:"Teacher"}),e.jsx(P,{value:"Admin",children:"Admin"})]})]}),D.role?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.role}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"status",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Status"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsxs(re,{value:N.status,onValueChange:a=>{K({...N,status:a}),D.status&&ae(g=>({...g,status:void 0}))},children:[e.jsx(le,{className:D.status?"border-red-500 focus:ring-red-500":"",children:e.jsx(ie,{placeholder:"Select status"})}),e.jsxs(ne,{children:[e.jsx(P,{value:"Active",children:"Active"}),e.jsx(P,{value:"Inactive",children:"Inactive"})]})]}),D.status?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.status}):null]})]}),J?N.role==="Student"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-center sm:gap-4",children:[e.jsx("label",{htmlFor:"lrn",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"LRN"}),e.jsx(R,{id:"lrn",value:N.lrn,onChange:a=>K({...N,lrn:a.target.value}),placeholder:"12-digit learner reference",className:"sm:col-span-3"})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-center sm:gap-4",children:[e.jsx("label",{htmlFor:"grade",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Grade"}),e.jsx(R,{id:"grade",value:N.grade,onChange:a=>K({...N,grade:a.target.value}),placeholder:"e.g. Grade 11",className:"sm:col-span-3"})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-center sm:gap-4",children:[e.jsx("label",{htmlFor:"section",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Section"}),e.jsx(R,{id:"section",value:N.section,onChange:a=>K({...N,section:a.target.value}),placeholder:"e.g. STEM A",className:"sm:col-span-3"})]})]}):e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-center sm:gap-4",children:[e.jsx("label",{htmlFor:"department",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Department"}),e.jsx(R,{id:"department",value:N.department,onChange:a=>K({...N,department:a.target.value}),placeholder:"e.g. Mathematics",className:"sm:col-span-3"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"grade",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Grade"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(R,{id:"grade",value:N.grade,onChange:a=>{K({...N,grade:a.target.value}),D.grade&&ae(g=>({...g,grade:void 0}))},placeholder:"e.g. Grade 11",className:D.grade?"border-red-500 focus-visible:ring-red-500":""}),D.grade?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.grade}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"section",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Section"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(R,{id:"section",value:N.section,onChange:a=>{K({...N,section:a.target.value}),D.section&&ae(g=>({...g,section:void 0}))},placeholder:"e.g. STEM A",className:D.section?"border-red-500 focus-visible:ring-red-500":""}),D.section?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.section}):null]})]}),N.role==="Student"?e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"lrn",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"LRN"}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(R,{id:"lrn",value:N.lrn,onChange:a=>{K({...N,lrn:a.target.value}),D.lrn&&ae(g=>({...g,lrn:void 0}))},placeholder:"Required for student accounts",className:D.lrn?"border-red-500 focus-visible:ring-red-500":""}),D.lrn?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.lrn}):null]})]}):null,e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"password",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Password"}),e.jsxs("div",{className:"sm:col-span-3 relative",children:[e.jsx(R,{id:"password",type:us?"text":"password",value:N.password,onChange:a=>{K({...N,password:a.target.value}),D.password&&ae(g=>({...g,password:void 0}))},placeholder:"Min 8 chars, upper/lowercase, number, and symbol",className:D.password?"border-red-500 focus-visible:ring-red-500 pr-10 ":"pr-10 "}),e.jsx("button",{type:"button",onClick:()=>Pe(!us),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",tabIndex:-1,children:us?e.jsx(rs,{size:16}):e.jsx(Hs,{size:16})}),D.password?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.password}):null]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4 sm:items-start sm:gap-4",children:[e.jsx("label",{htmlFor:"confirmPassword",className:"text-left sm:text-right text-sm font-medium text-[#0a1628]",children:"Confirm"}),e.jsxs("div",{className:"sm:col-span-3 relative",children:[e.jsx(R,{id:"confirmPassword",type:hs?"text":"password",value:N.confirmPassword,onChange:a=>{K({...N,confirmPassword:a.target.value}),D.confirmPassword&&ae(g=>({...g,confirmPassword:void 0}))},placeholder:"Retype password",className:D.confirmPassword?"border-red-500 focus-visible:ring-red-500 pr-10 ":"pr-10 "}),e.jsx("button",{type:"button",onClick:()=>De(!hs),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",tabIndex:-1,children:hs?e.jsx(rs,{size:16}):e.jsx(Hs,{size:16})}),D.confirmPassword?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:D.confirmPassword}):null]})]})]})]}),e.jsxs(da,{children:[e.jsx(M,{variant:"outline",onClick:()=>{ze(!1),Pe(!1),De(!1)},disabled:p,children:"Cancel"}),e.jsxs(M,{onClick:Ft,className:"bg-sky-600 hover:bg-sky-700 text-white",disabled:p,children:[p?e.jsx(H,{size:16,className:"animate-spin mr-2"}):null,J?"Save Changes":"Create User & Send Email"]})]})]})}),e.jsx(Ns,{isOpen:Et,onClose:()=>{$e||(ms(!1),xs(null))},onConfirm:$t,title:xe?.title||"Confirm Action",message:xe?.message||"Proceed with this action?",confirmText:$e?"Processing...":xe?.confirmText||"Confirm",cancelText:"Cancel",type:"danger",icon:"delete"})]})},Te=({icon:s,title:t,subtitle:i})=>e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-10 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#edf1f7] flex items-center justify-center",children:s}),e.jsx("p",{className:"text-sm font-semibold text-[#5a6578]",children:t}),i&&e.jsx("p",{className:"text-xs text-[#a0aec0] max-w-xs",children:i})]}),fr=()=>{const[s,t]=l.useState("30d"),[i,r]=l.useState(null),[h,n]=l.useState(!0);l.useEffect(()=>{tr().then(r).catch(console.error).finally(()=>n(!1))},[]);const o={"7d":"Last 7 Days","30d":"Last 30 Days","90d":"Last 90 Days","12m":"Last 12 Months"},m=[{label:"Total Active Users",value:h?null:(i?.totalActiveUsers??0).toLocaleString(),icon:Ze,color:"from-sky-500 to-blue-600"},{label:"Avg. Completion Rate",value:"N/A",icon:ut,color:"from-teal-500 to-emerald-600"},{label:"Avg. Session Duration",value:"N/A",icon:At,color:"from-violet-500 to-purple-600"},{label:"At-Risk Students",value:h?null:(i?.atRiskStudents??0).toString(),icon:ws,color:"from-rose-500 to-orange-600"}],v=[{label:"Achievements Unlocked",icon:Ye,color:"text-rose-600",bg:"bg-rose-50",value:h?null:(i?.achievementsUnlocked??0).toLocaleString()},{label:"XP Earned (Platform)",icon:xt,color:"text-violet-600",bg:"bg-violet-50",value:h?null:(i?.totalXPEarned??0)>=1e6?`${((i?.totalXPEarned??0)/1e6).toFixed(1)}M`:(i?.totalXPEarned??0)>=1e3?`${Math.round((i?.totalXPEarned??0)/1e3)}K`:(i?.totalXPEarned??0).toLocaleString()},{label:"Active Streaks",icon:ht,color:"text-orange-600",bg:"bg-orange-50",value:h?null:(i?.activeStreaks??0).toLocaleString()},{label:"AI Tutor Sessions",icon:ta,color:"text-sky-600",bg:"bg-sky-50",value:h?null:(i?.aiTutorSessions??0).toLocaleString()}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(U.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2 bg-white rounded-xl p-1 shadow-sm border border-[#dde3eb]",children:Object.entries(o).map(([p,S])=>e.jsx("button",{onClick:()=>t(p),disabled:!0,title:"Range selection is unavailable until backend range queries are supported.",className:`px-4 py-2 rounded-lg text-sm font-semibold transition-all ${s===p?"bg-sky-600 text-white shadow-sm":"text-[#5a6578] hover:bg-[#edf1f7]"} opacity-60 cursor-not-allowed`,children:S},p))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(M,{variant:"outline",disabled:!0,title:"Advanced analytics filters are not implemented yet",className:"px-4 py-2 gap-2 rounded-xl border-[#dde3eb] font-semibold text-sm opacity-50 cursor-not-allowed",children:[e.jsx(va,{size:16}),"Filters"]}),e.jsxs(M,{variant:"outline",disabled:!0,title:"Export is unavailable until backend report generation is implemented",className:"px-4 py-2 gap-2 rounded-xl border-[#dde3eb] font-semibold text-sm opacity-50 cursor-not-allowed",children:[e.jsx(Ct,{size:16}),"Export"]})]})]}),e.jsx("p",{className:"text-xs text-[#5a6578] -mt-3",children:"Time-range filtering is currently disabled because analytics range queries are not yet supported by the backend."}),!h&&!i?.totalActiveUsers&&e.jsxs(U.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.35},className:"flex items-center gap-3 bg-rose-50 border border-rose-200 rounded-2xl px-5 py-4",children:[e.jsx(Oe,{size:18,className:"text-rose-600 shrink-0"}),e.jsxs("p",{className:"text-sm text-rose-800",children:[e.jsx("span",{className:"font-semibold",children:"Limited analytics data."})," ","KPI cards will populate automatically as students, quizzes, and sessions accumulate in the platform. Chart visualisations require time-series data."]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4",children:m.map((p,S)=>{const f=p.icon;return e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.35,delay:S*.06},className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsx("div",{className:`w-11 h-11 rounded-xl bg-gradient-to-br ${p.color} flex items-center justify-center shadow-sm`,children:e.jsx(f,{size:20,className:"text-white"})})}),h?e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(H,{size:16,className:"animate-spin text-[#a0aec0]"}),e.jsx("div",{className:"w-14 h-6 bg-[#edf1f7] rounded-lg animate-pulse"})]}):e.jsx("p",{className:"text-2xl font-bold text-[#0a1628] mb-2",children:p.value}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-[#5a6578] font-medium",children:p.label}),e.jsx("span",{className:"text-xs text-[#a0aec0] font-medium",children:o[s]})]})]},p.label)})}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-6",children:[e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.15},className:"xl:col-span-8 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Performance Trends"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Average scores — students vs. teacher targets"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-sky-300"}),e.jsx("span",{className:"text-[#a0aec0] font-medium",children:"Students"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-violet-300"}),e.jsx("span",{className:"text-[#a0aec0] font-medium",children:"Teacher Targets"})]})]})]}),e.jsx(Te,{icon:e.jsx(ss,{size:24,className:"text-[#c2cad8]"}),title:"No performance data yet",subtitle:"Import student and class records to generate trend charts."})]}),e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},className:"xl:col-span-4 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-violet-100 rounded-xl flex items-center justify-center",children:e.jsx(La,{size:20,className:"text-violet-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Grade Distribution"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"All students, current term"})]})]}),e.jsx(Te,{icon:e.jsx(Oe,{size:24,className:"text-[#c2cad8]"}),title:"No grade data",subtitle:"Import quiz and assessment results to see grade breakdowns."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-6",children:[e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.25},className:"xl:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-sky-100 rounded-xl flex items-center justify-center",children:e.jsx(je,{size:20,className:"text-sky-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Subject Engagement"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Enrollment, completion, and average scores"})]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-[#dde3eb]",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#f7f9fc]",children:[e.jsx("th",{className:"text-left text-xs font-semibold text-[#5a6578] px-4 py-3",children:"Subject"}),e.jsx("th",{className:"text-right text-xs font-semibold text-[#5a6578] px-4 py-3",children:"Enrolled"}),e.jsx("th",{className:"text-right text-xs font-semibold text-[#5a6578] px-4 py-3",children:"Completion"}),e.jsx("th",{className:"text-right text-xs font-semibold text-[#5a6578] px-4 py-3",children:"Avg. Score"}),e.jsx("th",{className:"text-left text-xs font-semibold text-[#5a6578] px-4 py-3 w-36",children:"Progress"})]})}),e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-10",children:e.jsx(Te,{icon:e.jsx(Oe,{size:22,className:"text-[#c2cad8]"}),title:"No subject data available",subtitle:"Import class enrollment records to view subject engagement."})})})})]})})]}),e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.3},className:"xl:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-orange-100 rounded-xl flex items-center justify-center",children:e.jsx(ys,{size:20,className:"text-orange-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Weekly Activity"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Sessions per day of week"})]})]}),e.jsx(Te,{icon:e.jsx(ws,{size:24,className:"text-[#c2cad8]"}),title:"No session activity yet",subtitle:"Student logins and session data will appear here after data is imported."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-6",children:[e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.35},className:"xl:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-rose-100 rounded-xl flex items-center justify-center",children:e.jsx(Ye,{size:20,className:"text-rose-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Gamification Overview"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Engagement & motivation metrics"})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:v.map(p=>{const S=p.icon;return e.jsxs("div",{className:`${p.bg} border border-[#dde3eb] rounded-xl p-4`,children:[e.jsx(S,{size:20,className:p.color}),h?e.jsx("div",{className:"w-12 h-5 bg-white/60 rounded mt-2 mb-1 animate-pulse"}):e.jsx("p",{className:"text-lg font-bold text-[#0a1628] mt-2 mb-1",children:p.value}),e.jsx("p",{className:"text-xs text-[#5a6578] font-medium",children:p.label})]},p.label)})})]}),e.jsxs(U.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,delay:.4},className:"xl:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-teal-100 rounded-xl flex items-center justify-center",children:e.jsx(Cs,{size:20,className:"text-teal-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Top Performing Classes"}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"Ranked by average score this term"})]})]}),e.jsx(Te,{icon:e.jsx(Oe,{size:24,className:"text-[#c2cad8]"}),title:"No class data yet",subtitle:"Import class and student records to see top performers ranked here."})]})]})]})};function br(s){return!s||s.length===0?"Healthy":s.some(t=>t.status==="Down")?"Down":s.some(t=>t.status==="Degraded")?"Degraded":"Healthy"}function jr(s){return s.reduce((t,i)=>t+(i.estimatedCostUSD||0),0)}function vr(s){return!s||s.length===0?null:s.reduce((t,i)=>t.estimatedCostUSD>i.estimatedCostUSD?t:i)}function Nr(s){return!s||s.length===0?null:s.reduce((t,i)=>t.requestCount>i.requestCount?t:i)}function yr(s){const t=new Date().toISOString().slice(0,7),[i,r]=l.useState([]),[h,n]=l.useState(!0),[o,m]=l.useState(null),[v,p]=l.useState(0),S=l.useCallback(()=>{p(f=>f+1)},[]);return l.useEffect(()=>{let f=!0;n(!0),m(null);const j=as(se(X,"aiUsageLogs"),ks("month","==",t)),w=ma(j,A=>{if(!f)return;const k=[];A.forEach(d=>{const y=d.data();k.push(y)}),r(k),n(!1)},A=>{f&&(console.error("[useAIMonitoring] Firestore error:",A),m("Failed to load AI usage data. Please try again."),n(!1))});return()=>{f=!1,w()}},[t,v]),{stats:i,systemHealth:br(i),totalSpend:jr(i),highestCostFeature:vr(i),mostActiveFeature:Nr(i),isLoading:h,error:o,refresh:S}}const wr=[{id:"ai-chat",name:"AI Chat Tutor",description:"On-demand math help for students via DeepSeek with streaming responses"},{id:"quiz-generation",name:"Quiz Generation",description:"AI-powered quiz creation from imported topics and curriculum"},{id:"lesson-generation",name:"Lesson Generation",description:"AI-generated lesson plans grounded on imported topics and class signals"},{id:"learning-paths",name:"Learning Paths",description:"Personalized study plan generation based on student weaknesses"},{id:"risk-classification",name:"Risk Classification",description:"Student at-risk identification using AI structured output and ML scoring"},{id:"daily-insights",name:"Daily AI Insights",description:"Daily AI-powered analytics and recommendations for teachers"},{id:"solution-verification",name:"Solution Verification",description:"Multi-method math solution checking with self-consistency and code execution"},{id:"curriculum-search",name:"Curriculum Search",description:"Embedding-based search over lesson content and curriculum materials"},{id:"content-processing",name:"Content Processing",description:"AI column detection and topic extraction from uploaded files"},{id:"auto-feedback",name:"Auto Feedback",description:"Instant feedback and explanations for student quiz responses"}],Qe={"ai-chat":35,"quiz-generation":18,"lesson-generation":12,"learning-paths":8,"risk-classification":6,"daily-insights":5,"solution-verification":6,"curriculum-search":4,"content-processing":3,"auto-feedback":3};function Sr(s){if(!s)return"N/A";try{return new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"N/A"}}function Ne(s){return s>=1?`$${s.toFixed(2)}`:`$${s.toFixed(4)}`}function Ve(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function kr(s){const t=s.reduce((o,m)=>o+m.requestCount,0),i=s.reduce((o,m)=>o+m.estimatedCostUSD,0),r=new Date().toISOString(),h=wr.map(o=>{const m=s.find(j=>{const w=j.featureName.toLowerCase().replace(/[^a-z0-9]/g,""),A=o.name.toLowerCase().replace(/[^a-z0-9]/g,"");return w.includes(A)||A.includes(w)}),v=m?.requestCount??Math.round(t*(Qe[o.id]??1)/100),p=m?.estimatedCostUSD??i*(Qe[o.id]??1)/100,S=m?m.status==="Degraded"?"Warning":m.status==="Down"?"Offline":"Healthy":"Healthy",f=m?m.priority==="High"?"High":m.priority==="Medium"?"Medium":"Low":Qe[o.id]>=20?"High":Qe[o.id]>=8?"Medium":"Low";return{...o,status:S,requests:v,estimatedCost:p,avgCostPerRequest:v>0?p/v:0,usageLevel:f,lastActiveAt:m?.lastUpdated?.toDate().toISOString()??r,trend:"Stable"}}),n=h.reduce((o,m)=>o+m.estimatedCost,0);return h.map(o=>({...o,costPercent:n>0?o.estimatedCost/n*100:0}))}function Cr(s,t){const i=[],r=t.filter(m=>m.status==="Degraded");r.length>0&&i.push({id:"degraded",severity:"warning",message:`${r.length} AI feature(s) are in degraded state`});const h=t.filter(m=>m.status==="Down");h.length>0&&i.push({id:"offline",severity:"critical",message:`${h[0].featureName} is currently unavailable`});const n=s.find(m=>m.id==="ai-chat");n&&n.costPercent&&n.costPercent>40&&i.push({id:"chatcost",severity:"info",message:"AI Chat Tutor is driving most of the AI spend this period"});const o=s.find(m=>m.id==="quiz-generation");return o&&o.costPercent&&o.costPercent>25&&i.push({id:"quizcost",severity:"info",message:"Quiz Generation is using more AI resources than usual"}),i}function We({status:s,loading:t}){const r={Healthy:{label:"Healthy",className:"text-emerald-700 bg-emerald-50 border-emerald-200",icon:ts,iconClass:"text-emerald-500"},Warning:{label:"Needs Attention",className:"text-amber-700 bg-amber-50 border-amber-200",icon:oe,iconClass:"text-amber-500"},Offline:{label:"Offline",className:"text-rose-700 bg-rose-50 border-rose-200",icon:oe,iconClass:"text-rose-500"}}[s];return t?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold bg-slate-100 text-slate-400 border border-slate-200",children:[e.jsx(ws,{size:12,className:"animate-pulse"}),"Checking..."]}):e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border ${r.className}`,children:[e.jsx(r.icon,{size:12,className:r.iconClass}),r.label]})}function nt({level:s}){const t={Low:"bg-slate-100 text-slate-600 border-slate-200",Medium:"bg-sky-50 text-sky-700 border-sky-200",High:"bg-violet-50 text-violet-700 border-violet-200"};return e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-full text-xs font-semibold border ${t[s]}`,children:s})}function Ar({trend:s}){if(!s)return null;const i={Up:{label:"↑ Up",className:"text-emerald-600 bg-emerald-50"},Stable:{label:"→ Stable",className:"text-slate-600 bg-slate-50"},Down:{label:"↓ Down",className:"text-rose-600 bg-rose-50"}}[s];return e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold ${i.className}`,children:i.label})}function Le({title:s,subtitle:t,testId:i}){return e.jsxs("div",{className:"mb-4","data-testid":i,children:[e.jsx("h2",{className:"text-base font-semibold text-[#0a1628]",children:s}),t&&e.jsx("p",{className:"text-sm text-[#5a6578] mt-0.5",children:t})]})}const zr=()=>{const{stats:s,systemHealth:t,totalSpend:i,highestCostFeature:r,mostActiveFeature:h,isLoading:n,error:o,refresh:m}=yr(),v=new Date().toLocaleString("default",{month:"long",year:"numeric"}),p=l.useMemo(()=>kr(s),[s]),S=l.useMemo(()=>Cr(p,s),[p,s]),f=i,j=l.useMemo(()=>[...p].sort((d,y)=>y.estimatedCost-d.estimatedCost),[p]),w=l.useMemo(()=>[...p].sort((d,y)=>y.requests-d.requests),[p]),A=r?{name:r.featureName,estimatedCost:r.estimatedCostUSD,costPercent:f>0?r.estimatedCostUSD/f*100:0}:null,k=h?{name:h.featureName,requests:h.requestCount}:null;return e.jsxs("div",{className:"space-y-8","data-testid":"ai-usage-dashboard",children:[e.jsxs(U.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[#0a1628]",children:"AI Usage Dashboard"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Track where AI is being used, what it costs, and what needs attention"})]}),e.jsxs(M,{variant:"outline",size:"sm",className:"text-xs gap-1.5 shrink-0",onClick:m,disabled:n,"data-testid":"refresh-btn",children:[e.jsx(Re,{size:13,className:n?"animate-spin":""}),"Refresh"]})]}),o&&e.jsxs(U.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex items-center gap-3 bg-rose-50 border border-rose-200 rounded-2xl px-5 py-4",children:[e.jsx(oe,{size:18,className:"text-rose-600 shrink-0"}),e.jsx("p",{className:"text-sm text-rose-800",children:o})]}),!n&&!o&&s.length===0&&e.jsxs("div",{className:"mb-6 bg-sky-50 border border-sky-200 rounded-2xl px-5 py-4 flex items-center gap-3",children:[e.jsx(we,{size:18,className:"text-sky-600 shrink-0"}),e.jsxs("p",{className:"text-sm text-sky-800",children:["No AI usage data recorded yet for ",v,". Data will appear here once AI features are used."]})]}),e.jsxs(U.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.05},className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]","data-testid":"summary-ai-status",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center shadow-sm ${t==="Healthy"?"bg-gradient-to-br from-emerald-400 to-emerald-600":t==="Degraded"?"bg-gradient-to-br from-amber-400 to-amber-600":"bg-gradient-to-br from-rose-400 to-rose-600"}`,children:t==="Healthy"?e.jsx(ts,{size:18,className:"text-white"}):t==="Degraded"?e.jsx(oe,{size:18,className:"text-white"}):e.jsx(oe,{size:18,className:"text-white"})})}),n?e.jsx(Z,{className:"w-28 h-8 rounded-lg mb-2"}):e.jsx("p",{className:"text-2xl font-bold text-[#0a1628] mb-1",children:t==="Healthy"?"Healthy":t==="Degraded"?"Needs Attention":"Partial Outage"}),e.jsx("p",{className:"text-xs text-[#5a6578] font-medium",children:t==="Healthy"?"Most AI features are working normally":t==="Degraded"?"Some AI features need attention":"Several AI features are unavailable"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]","data-testid":"summary-ai-cost",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-violet-500 to-purple-700 flex items-center justify-center shadow-sm",children:e.jsx(Ws,{size:18,className:"text-white"})})}),n?e.jsx(Z,{className:"w-24 h-8 rounded-lg mb-2"}):e.jsx("p",{className:"text-2xl font-bold text-[#0a1628] mb-1",children:s.length===0?"No data":Ne(f)}),e.jsx("p",{className:"text-xs text-[#5a6578] font-medium",children:n?"...":"Total AI spend this month"}),!n&&i>0&&e.jsx("p",{className:"text-xs text-[#a0aec0] mt-1",children:"Cumulative AI cost for current period"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]","data-testid":"summary-most-expensive",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-amber-400 to-orange-600 flex items-center justify-center shadow-sm",children:e.jsx(gt,{size:18,className:"text-white"})})}),n?e.jsx(Z,{className:"w-32 h-8 rounded-lg mb-2"}):e.jsx("p",{className:"text-2xl font-bold text-[#0a1628] mb-1 truncate",children:A?.name??"N/A"}),e.jsx("p",{className:"text-xs text-[#5a6578] font-medium",children:n?"...":"Highest AI cost this month"}),!n&&A&&e.jsxs("p",{className:"text-xs text-[#a0aec0] mt-1",children:[Ne(A.estimatedCost)," ·"," ",A.costPercent?.toFixed(0),"% of total"]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]","data-testid":"summary-top-activity",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-sky-400 to-blue-600 flex items-center justify-center shadow-sm",children:e.jsx(ht,{size:18,className:"text-white"})})}),n?e.jsx(Z,{className:"w-32 h-8 rounded-lg mb-2"}):e.jsx("p",{className:"text-2xl font-bold text-[#0a1628] mb-1 truncate",children:k?.name??"N/A"}),e.jsx("p",{className:"text-xs text-[#5a6578] font-medium",children:n?"...":"Most active AI feature"}),!n&&k&&e.jsxs("p",{className:"text-xs text-[#a0aec0] mt-1",children:[Ve(k.requests)," requests"]})]})]}),e.jsxs("section",{"data-testid":"section-ai-usage-areas",children:[e.jsx(Le,{title:"Where AI is used",subtitle:"All AI-powered features in the platform",testId:"section-ai-usage-areas-header"}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:6}).map((d,y)=>e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb]",children:[e.jsx(Z,{className:"w-32 h-5 rounded mb-3"}),e.jsx(Z,{className:"w-full h-4 rounded mb-2"}),e.jsx(Z,{className:"w-24 h-4 rounded"})]},y))}):e.jsx(U.div,{initial:"hidden",animate:"show",variants:{hidden:{},show:{transition:{staggerChildren:.05}}},className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:p.map(d=>e.jsxs(U.div,{variants:{hidden:{opacity:0,y:8},show:{opacity:1,y:0}},className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb] hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-[#0a1628] leading-tight",children:d.name}),e.jsx(We,{status:d.status})]}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-3 leading-relaxed",children:d.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#5a6578]",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{size:12}),Ve(d.requests)," requests"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ws,{size:12}),Ne(d.estimatedCost)]}),e.jsx(nt,{level:d.usageLevel})]})]},d.id))})]}),e.jsxs("section",{"data-testid":"section-highest-cost",children:[e.jsx(Le,{title:"What costs the most",subtitle:"AI features ranked by estimated spend this month",testId:"section-highest-cost-header"}),n?e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((d,y)=>e.jsx("div",{className:"bg-white rounded-2xl p-4 shadow-sm border border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Z,{className:"w-6 h-6 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Z,{className:"w-40 h-4 rounded mb-2"}),e.jsx(Z,{className:"w-full h-2 rounded-full"})]})]})},y))}):e.jsx("div",{className:"space-y-3",children:j.slice(0,7).map((d,y)=>e.jsxs(U.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.25,delay:y*.04},className:"bg-white rounded-2xl p-4 shadow-sm border border-[#dde3eb] flex items-center gap-4",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 text-xs font-bold ${y===0?"bg-amber-100 text-amber-700":y===1?"bg-slate-100 text-slate-600":y===2?"bg-orange-100 text-orange-700":"bg-slate-50 text-slate-400"}`,children:y+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-[#0a1628]",children:d.name}),e.jsx(We,{status:d.status})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"font-semibold text-[#0a1628]",children:Ne(d.estimatedCost)}),e.jsxs("span",{className:"text-[#5a6578] min-w-[40px] text-right",children:[d.costPercent?.toFixed(1),"%"]})]})]}),e.jsx("div",{className:"h-2 bg-slate-100 rounded-full overflow-hidden",children:e.jsx(U.div,{initial:{width:0},animate:{width:`${d.costPercent??0}%`},transition:{duration:.6,delay:.1+y*.04},className:`h-full rounded-full ${y===0?"bg-amber-400":y===1?"bg-slate-400":y===2?"bg-orange-400":"bg-violet-400"}`})})]})]},d.id))})]}),e.jsxs("section",{"data-testid":"section-highest-usage",children:[e.jsx(Le,{title:"Most active AI features",subtitle:"Features with the highest request volume this month",testId:"section-highest-usage-header"}),n?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:6}).map((d,y)=>e.jsxs("div",{className:"bg-white rounded-2xl p-4 shadow-sm border border-[#dde3eb]",children:[e.jsx(Z,{className:"w-32 h-5 rounded mb-3"}),e.jsx(Z,{className:"w-24 h-8 rounded"})]},y))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:w.slice(0,6).map((d,y)=>e.jsxs(U.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25,delay:y*.04},className:"bg-white rounded-2xl p-4 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-[#0a1628] mb-0.5",children:d.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(We,{status:d.status}),e.jsx(Ar,{trend:d.trend})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold text-[#0a1628]",children:Ve(d.requests)}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:"requests"})]})]}),e.jsxs("div",{className:"pt-2 border-t border-slate-100 flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs text-[#5a6578]",children:["Avg cost: ",Ne(d.avgCostPerRequest),"/request"]}),e.jsx(nt,{level:d.usageLevel})]})]},d.id))})]}),e.jsxs("section",{"data-testid":"section-needs-attention",children:[e.jsx(Le,{title:"Needs attention",subtitle:"Actionable issues that may need review",testId:"section-needs-attention-header"}),n?e.jsx("div",{className:"bg-white rounded-2xl p-6 shadow-sm border border-[#dde3eb]",children:e.jsx("div",{className:"space-y-3",children:[1,2].map(d=>e.jsx(Z,{className:"w-full h-12 rounded-xl"},d))})}):S.length===0?e.jsxs(U.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:"bg-emerald-50 border border-emerald-200 rounded-2xl p-6 flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-100 flex items-center justify-center shrink-0",children:e.jsx(ts,{size:20,className:"text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-emerald-800",children:"Everything looks normal"}),e.jsx("p",{className:"text-xs text-emerald-600 mt-0.5",children:"No issues detected with AI features right now"})]})]}):e.jsx("div",{className:"space-y-3",children:S.map(d=>e.jsxs(U.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},className:`rounded-2xl p-4 flex items-start gap-3 border ${d.severity==="critical"?"bg-rose-50 border-rose-200":d.severity==="warning"?"bg-amber-50 border-amber-200":"bg-sky-50 border-sky-200"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-xl flex items-center justify-center shrink-0 ${d.severity==="critical"?"bg-rose-100":d.severity==="warning"?"bg-amber-100":"bg-sky-100"}`,children:d.severity==="critical"?e.jsx(oe,{size:16,className:"text-rose-600"}):d.severity==="warning"?e.jsx(na,{size:16,className:"text-amber-600"}):e.jsx(we,{size:16,className:"text-sky-600"})}),e.jsx("p",{className:`text-sm font-medium ${d.severity==="critical"?"text-rose-800":d.severity==="warning"?"text-amber-800":"text-sky-800"}`,children:d.message})]},d.id))})]}),e.jsxs("section",{"data-testid":"section-ai-breakdown-table",children:[e.jsx(Le,{title:"AI activity breakdown",subtitle:"Detailed view of all AI features and their usage",testId:"section-ai-breakdown-table-header"}),e.jsx("div",{className:"bg-white rounded-2xl shadow-sm border border-[#dde3eb] overflow-hidden",children:n?e.jsx("div",{className:"p-4 space-y-3",children:Array.from({length:5}).map((d,y)=>e.jsx(Z,{className:"w-full h-12 rounded-lg"},y))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#dde3eb] bg-slate-50",children:[e.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Feature"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Status"}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Requests"}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Est. Cost"}),e.jsx("th",{className:"text-right px-4 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Avg / Request"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[#5a6578] uppercase tracking-wide",children:"Last Active"})]})}),e.jsx("tbody",{className:"divide-y divide-[#dde3eb]",children:p.map(d=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[#0a1628]",children:d.name}),e.jsx("p",{className:"text-xs text-[#5a6578] hidden sm:block",children:d.description})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(We,{status:d.status})}),e.jsx("td",{className:"px-4 py-3 text-right font-medium text-[#0a1628]",children:Ve(d.requests)}),e.jsx("td",{className:"px-4 py-3 text-right font-medium text-[#0a1628]",children:Ne(d.estimatedCost)}),e.jsx("td",{className:"px-4 py-3 text-right text-[#5a6578]",children:Ne(d.avgCostPerRequest)}),e.jsx("td",{className:"px-4 py-3 text-[#5a6578]",children:Sr(d.lastActiveAt)})]},d.id))})]})})})]})]})};function Pr({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:ke("w-full caption-bottom text-sm",s),...t})})}function Dr({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:ke("[&_tr]:border-b",s),...t})}function Tr({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:ke("[&_tr:last-child]:border-0",s),...t})}function dt({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:ke("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...t})}function Me({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:ke("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function Ie({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:ke("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}const ct=Ke.map(s=>({id:s.id,name:s.name,code:s.code,gradeLevel:s.gradeLevel,semester:s.semester,color:s.color})),Lr=()=>{const{userProfile:s}=Ee(),{availability:t,loading:i,error:r}=Na(),[h,n]=l.useState(null),[o,m]=l.useState({}),v=l.useCallback(async(f,j)=>{if(!s?.uid){z.error("You must be logged in as admin to change availability");return}n(f);try{await ya(f,j,s.uid),z.success(`${ct.find(w=>w.id===f)?.name||f} is now ${j?"available":"locked"}`)}catch(w){z.error("Failed to update subject availability"),console.error(w)}finally{n(null)}},[s?.uid]),p=l.useCallback((f,j)=>{m(w=>({...w,[f]:j}))},[]),S=l.useCallback(async f=>{if(!s?.uid){z.error("You must be logged in as admin");return}const j=o[f]?.trim()||null;n(f);try{await wa(f,j,s.uid),z.success("PDF path updated")}catch(w){z.error("Failed to update PDF path"),console.error(w)}finally{n(null)}},[o,s?.uid]);return e.jsxs(U.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-display font-bold text-[#0a1628]",children:"Subject Availability"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Toggle subjects on or off to control student access. Changes take effect immediately across the platform."})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(H,{size:16,className:"animate-spin"}),"Syncing..."]})]}),r&&e.jsx("div",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:r}),e.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white shadow-sm overflow-hidden",children:e.jsxs(Pr,{children:[e.jsx(Dr,{children:e.jsxs(dt,{className:"bg-slate-50/80 hover:bg-slate-50/80",children:[e.jsx(Me,{className:"text-xs font-black uppercase tracking-wider text-slate-500",children:"Subject"}),e.jsx(Me,{className:"text-xs font-black uppercase tracking-wider text-slate-500",children:"Grade / Sem"}),e.jsx(Me,{className:"text-xs font-black uppercase tracking-wider text-slate-500",children:"Status"}),e.jsx(Me,{className:"text-xs font-black uppercase tracking-wider text-slate-500",children:"Available"}),e.jsx(Me,{className:"text-xs font-black uppercase tracking-wider text-slate-500 w-[320px]",children:"PDF Path"})]})}),e.jsx(Tr,{children:ct.map(f=>{const j=t[f.id],w=j?.available??!0,A=o[f.id]??j?.pdfPath??"",k=j?.lastUpdated,d=h===f.id;return e.jsxs(dt,{className:"group",children:[e.jsx(Ie,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg bg-gradient-to-br ${f.color} flex items-center justify-center text-white shadow-sm`,children:e.jsx(je,{size:14})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-sm text-[#0a1628]",children:f.name}),e.jsx("p",{className:"text-[11px] text-slate-400 font-semibold",children:f.code})]})]})}),e.jsxs(Ie,{children:[e.jsx("p",{className:"text-sm text-slate-600",children:f.gradeLevel}),e.jsx("p",{className:"text-[11px] text-slate-400",children:f.semester})]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"flex items-center gap-1.5",children:w?e.jsxs(e.Fragment,{children:[e.jsx(Fa,{size:14,className:"text-teal-500"}),e.jsx("span",{className:"text-xs font-bold text-teal-600",children:"Unlocked"})]}):e.jsxs(e.Fragment,{children:[e.jsx(mt,{size:14,className:"text-slate-400"}),e.jsx("span",{className:"text-xs font-bold text-slate-500",children:"Locked"})]})}),k&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-0.5 flex items-center gap-1",children:[e.jsx(At,{size:10}),k.toLocaleString()]})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(be,{checked:w,onCheckedChange:y=>v(f.id,y),disabled:d,"aria-label":`Toggle ${f.name} availability`}),d&&e.jsx(H,{size:14,className:"animate-spin text-slate-400"})]})}),e.jsx(Ie,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(es,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(R,{value:A,onChange:y=>p(f.id,y.target.value),placeholder:"Firebase Storage path (optional)",className:"pl-8 h-8 text-xs",disabled:d})]}),e.jsx(M,{variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>S(f.id),disabled:d,children:d?e.jsx(H,{size:14,className:"animate-spin"}):e.jsx(Sa,{size:14})})]})})]},f.id)})})]})}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 px-5 py-4",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-wide text-sky-700 mb-2",children:"How it works"}),e.jsxs("ul",{className:"text-sm text-sky-800 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Turning a subject ",e.jsx("strong",{children:"off"})," immediately locks its modules and removes it from Quiz Battle."]}),e.jsxs("li",{children:["Turning a subject ",e.jsx("strong",{children:"on"})," unlocks it everywhere — no redeployment required."]}),e.jsxs("li",{children:["The ",e.jsx("strong",{children:"PDF Path"})," field is optional and references the RAG source in Firebase Storage."]}),e.jsx("li",{children:"All changes are logged with timestamps and your admin user ID."})]})]})]})},Xe=[{id:"gen-math",name:"Gen Math",shortName:"GM",color:"#3B82F6"},{id:"stats-prob",name:"Stats & Prob",shortName:"SP",color:"#0ea5e9"},{id:"pre-calc",name:"Pre-Calc",shortName:"PC",color:"#F97316"},{id:"basic-calc",name:"Basic Calc",shortName:"BC",color:"#EF4444"}],vs={"gen-math":[{name:"Functions & Relations",unit:"Functions"},{name:"Rational Functions",unit:"Functions"},{name:"Exponential Functions",unit:"Functions"},{name:"Logarithmic Functions",unit:"Functions"},{name:"Simple Interest",unit:"Business Math"},{name:"Compound Interest",unit:"Business Math"},{name:"Annuities",unit:"Business Math"},{name:"Propositions",unit:"Logic"},{name:"Truth Tables",unit:"Logic"}],"stats-prob":[{name:"Random Variables",unit:"Random Variables"},{name:"Probability Distributions",unit:"Random Variables"},{name:"Normal Distribution",unit:"Normal Dist"},{name:"Z-scores",unit:"Normal Dist"},{name:"Sampling Distributions",unit:"Sampling"},{name:"Central Limit Theorem",unit:"Sampling"},{name:"Confidence Intervals",unit:"Estimation"},{name:"Hypothesis Testing",unit:"Testing"},{name:"Correlation",unit:"Regression"}],"pre-calc":[{name:"Parabola",unit:"Conics"},{name:"Ellipse",unit:"Conics"},{name:"Hyperbola",unit:"Conics"},{name:"Arithmetic Seq",unit:"Series"},{name:"Geometric Seq",unit:"Series"},{name:"Math Induction",unit:"Series"},{name:"Trig Functions",unit:"Trigonometry"},{name:"Trig Identities",unit:"Trigonometry"},{name:"Polar Coords",unit:"Trigonometry"}],"basic-calc":[{name:"Limits",unit:"Limits"},{name:"Continuity",unit:"Limits"},{name:"Definition of Deriv.",unit:"Derivatives"},{name:"Diff. Rules",unit:"Derivatives"},{name:"Chain Rule",unit:"Derivatives"},{name:"Related Rates",unit:"Derivatives"},{name:"Optimization",unit:"Derivatives"},{name:"Antiderivatives",unit:"Integration"},{name:"Definite Integrals",unit:"Integration"}]};function Mr(s){return s>=85?"bg-emerald-500":s>=70?"bg-emerald-300":s>=55?"bg-rose-300":s>=40?"bg-orange-400":s>=20?"bg-red-400":"bg-red-600"}function Ir(s){return s>=70||s>=40,"text-white"}const Rr=({title:s="Platform-Wide Subject Mastery"})=>{const[t,i]=l.useState(null),[r,h]=l.useState("all"),{data:n=[],isLoading:o}=ka({queryKey:aa.masteryHeatmap(),staleTime:180*1e3,gcTime:1200*1e3,queryFn:async()=>{try{const j=await de(se(X,"progress")),w={};j.forEach(k=>{const y=k.data().subjects||{};for(const[L,C]of Object.entries(y)){const B=vs[L]||[],q=C?.progress??0;for(const O of B){const G=`${L}::${O.name}`;w[G]||(w[G]={totalMastery:0,count:0}),w[G].totalMastery+=q,w[G].count+=1}}});const A=[];for(const k of Xe){const d=vs[k.id]||[];for(const y of d){const L=`${k.id}::${y.name}`,C=w[L];A.push({subject:k.id,topic:y.name,mastery:C&&C.count>0?Math.round(C.totalMastery/C.count):0,students:C?.count??0})}}return A}catch(j){return console.error("[MasteryHeatmap] Error fetching progress data:",j),[]}}}),m=r==="all"?Xe:Xe.filter(j=>j.id===r),v=n.filter(j=>j.students>0),p=v.length>0?Math.round(v.reduce((j,w)=>j+w.mastery,0)/v.length):0,S=v.length>0?v.reduce((j,w)=>w.mastery0?v.reduce((j,w)=>w.mastery>j.mastery?w:j,v[0]):null;return o?e.jsx("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb] flex items-center justify-center min-h-[200px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(H,{size:28,className:"text-sky-500 animate-spin"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Loading mastery data..."})]})}):e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",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-sky-500 rounded-xl flex items-center justify-center",children:e.jsx(Ua,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:s}),e.jsxs("p",{className:"text-xs text-[#5a6578]",children:["Aggregated mastery levels across all classes • ",n.filter(j=>j.students>0).length," tracked combinations"]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:r,onChange:j=>h(j.target.value),className:"appearance-none bg-[#edf1f7] border border-[#dde3eb] rounded-lg px-3 py-1.5 pr-8 text-xs font-semibold text-[#5a6578] focus:outline-none focus:ring-2 focus:ring-sky-500/20",children:[e.jsx("option",{value:"all",children:"All Subjects"}),Xe.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))]}),e.jsx(Ca,{size:12,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 pointer-events-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-5",children:[e.jsxs("div",{className:"bg-[#edf1f7] rounded-xl p-3 flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p>=70?"bg-emerald-100":"bg-rose-100"}`,children:e.jsx(Aa,{size:16,className:p>=70?"text-emerald-600":"text-rose-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg font-bold text-[#0a1628]",children:[p,"%"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] uppercase tracking-wider",children:"Platform Average"})]})]}),e.jsxs("div",{className:"bg-red-50 rounded-xl p-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center",children:e.jsx(ia,{size:16,className:"text-red-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628] truncate",children:S?.topic}),e.jsxs("p",{className:"text-[10px] text-red-600 font-semibold",children:[S?.mastery,"% — Lowest"]})]})]}),e.jsxs("div",{className:"bg-emerald-50 rounded-xl p-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-emerald-100 rounded-lg flex items-center justify-center",children:e.jsx(gt,{size:16,className:"text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628] truncate",children:f?.topic}),e.jsxs("p",{className:"text-[10px] text-emerald-600 font-semibold",children:[f?.mastery,"% — Highest"]})]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:m.map(j=>{const w=vs[j.id]||[],A=n.filter(d=>d.subject===j.id),k=A.length>0?Math.round(A.reduce((d,y)=>d+y.mastery,0)/A.length):0;return e.jsxs("div",{className:"mb-5 last:mb-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm e-bg",style:{"--bg":j.color}}),e.jsx("span",{className:"text-xs font-bold text-[#0a1628]",children:j.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-1",children:["Avg: ",k,"%"]})]}),e.jsxs("div",{className:"grid gap-1 e-grid-cols",style:{"--grid-cols":`repeat(${w.length}, minmax(0, 1fr))`},children:[w.map((d,y)=>e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-[9px] text-slate-500 truncate px-0.5 mb-1",title:d.name,children:d.name})},`label-${y}`)),w.map((d,y)=>{const L=A.find(q=>q.topic===d.name),C=L?.mastery||0,B=t?.topic===d.name&&t?.subject===j.id;return e.jsxs(U.div,{onMouseEnter:()=>L&&i(L),onMouseLeave:()=>i(null),whileHover:{scale:1.05},className:`relative h-10 rounded-lg flex items-center justify-center cursor-pointer transition-all ${Mr(C)} ${B?"ring-2 ring-white shadow-lg z-10":""}`,children:[e.jsxs("span",{className:`text-xs font-bold ${Ir(C)}`,children:[C,"%"]}),B&&L&&e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-slate-800 text-white rounded-lg px-3 py-2 text-xs whitespace-nowrap z-20 shadow-xl pointer-events-none",children:[e.jsx("p",{className:"font-bold mb-0.5",children:L.topic}),e.jsxs("p",{children:["Mastery: ",e.jsxs("strong",{children:[L.mastery,"%"]})]}),e.jsxs("p",{children:["Students: ",e.jsx("strong",{children:L.students})]}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-full w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px] border-t-slate-800"})]})]},`cell-${y}`)})]})]},j.id)})}),e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-5 pt-4 border-t border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#5a6578]",children:[e.jsx(we,{size:10}),e.jsx("span",{children:"Color scale:"})]}),[{label:"0-19%",color:"bg-red-600"},{label:"20-39%",color:"bg-red-400"},{label:"40-54%",color:"bg-orange-400"},{label:"55-69%",color:"bg-rose-300"},{label:"70-84%",color:"bg-emerald-300"},{label:"85-100%",color:"bg-emerald-500"}].map((j,w)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:`w-3 h-3 rounded-sm ${j.color}`}),e.jsx("span",{className:"text-[10px] text-[#5a6578]",children:j.label})]},w))]})]})},Er=[{id:"gen-math",title:"General Mathematics",icon:je,bg:"bg-[#9956DE]",tags:["Algebra","Fractions","Integers"],level:1,progress:25,isAtRisk:!0},{id:"pre-calc",title:"Pre-Calculus",icon:je,bg:"bg-[#1FA7E1]",tags:["Functions","Limits","Graphs"],level:2,progress:15,isAtRisk:!0},{id:"stats-prob",title:"Statistics & Probability",icon:je,bg:"bg-[#FFB356]",tags:["Probability","Mean/Median"],level:2,progress:40,isAtRisk:!1},{id:"basic-calc",title:"Basic Calculus",icon:je,bg:"bg-[#FB96BB]",tags:["Derivatives","Integrals"],level:3,progress:50,isAtRisk:!1},{id:"adv-math",title:"Advanced Algebra",icon:je,bg:"bg-[#7274ED]",tags:["Math","Logic"],level:4,progress:10,isAtRisk:!0}].slice(0,5),Ur=()=>{const s=l.useRef(null),[t,i]=l.useState(0),r=()=>{if(!s.current)return;const{scrollLeft:n,scrollWidth:o,clientWidth:m}=s.current,v=n/(o-m),p=3;let S=Math.round(v*(p-1));S<0&&(S=0),S>=p&&(S=p-1),i(S)},h=n=>{if(!s.current)return;const{scrollWidth:o,clientWidth:m}=s.current,p=(o-m)/2*n;s.current.scrollTo({left:p,behavior:"smooth"}),i(n)};return e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb] mb-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-5",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628] mb-1",children:"Priority Attention Modules"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Highly recommended to be reviewed (lowest performance)."})]})}),e.jsx("div",{className:"relative",children:e.jsx("div",{ref:s,onScroll:r,className:"flex overflow-x-auto snap-x snap-mandatory gap-5 pb-6 no-scrollbar",children:Er.map(n=>{const o=n.icon;return e.jsxs("div",{className:`snap-center shrink-0 w-[280px] sm:w-[300px] ${n.bg} rounded-[2rem] p-5 min-h-[290px] relative overflow-hidden transition-all duration-300 flex flex-col group shadow-sm`,children:[e.jsx("div",{className:"absolute -bottom-8 right-[-20%] w-32 h-32 bg-white opacity-10 rounded-full"}),e.jsx("div",{className:"absolute bottom-4 right-12 w-20 h-20 bg-white opacity-10 rounded-full"}),e.jsxs("div",{className:"flex justify-between items-start mb-4 relative z-10",children:[e.jsx("div",{className:"w-12 h-12 rounded-[1rem] bg-white/20 flex flex-shrink-0 items-center justify-center text-white backdrop-blur-sm",children:e.jsx(o,{size:24,className:"opacity-90"})}),e.jsxs("div",{className:"px-4 py-1.5 rounded-full bg-white/20 text-white/90 text-sm font-bold backdrop-blur-sm",children:["Lv ",n.level]})]}),e.jsxs("div",{className:"relative z-10 flex-1",children:[e.jsx("h3",{className:"text-2xl font-display font-black text-white leading-[1.1] mb-3 drop-shadow-sm pr-4 line-clamp-2",children:n.title}),e.jsx("div",{className:"flex flex-wrap gap-2 pb-4",children:n.tags.map(m=>e.jsx("span",{className:"px-3 py-1 rounded-full bg-white/20 text-white text-[13px] font-bold shadow-sm backdrop-blur-sm",children:m},m))})]}),e.jsxs("div",{className:"relative z-10 mt-auto pt-4 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex justify-between text-white/90 text-[13px] font-bold",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{children:"Avg Mastery"})}),e.jsxs("span",{children:[n.progress,"%"]})]}),e.jsx("div",{className:"w-full h-2 rounded-full bg-white/30 overflow-hidden shadow-inner mt-1",children:e.jsx("div",{className:"h-full bg-white rounded-full e-w",style:{"--w":`${n.progress}%`}})}),n.isAtRisk&&e.jsxs("div",{className:"absolute -top-12 right-0 bg-red-500 text-white px-3 py-1 rounded-full text-[11px] font-bold flex items-center gap-1 shadow-lg animate-pulse",children:[e.jsx(oe,{size:12})," At Risk"]})]})]},n.id)})})}),e.jsx("div",{className:"flex justify-center items-center gap-2 mt-2",children:[0,1,2].map(n=>e.jsx("button",{onClick:()=>h(n),className:`w-2.5 h-2.5 rounded-full transition-all duration-300 ${t===n?"bg-sky-600 w-6":"bg-sky-200 hover:bg-sky-300"}`,"aria-label":`Go to slide ${n+1}`},n))})]})},Ll=({onLogout:s,onOpenProfile:t})=>{const{userProfile:i}=Ee(),[r,h]=l.useState("Overview"),[n,o]=l.useState(!1),[m,v]=l.useState(!1),[p,S]=l.useState(null),[f,j]=l.useState(!1),[w,A]=l.useState(!1),[k,d]=l.useState(!1),[y,L]=l.useState(null),[C,B]=l.useState(null),[q,O]=l.useState([]),[G,Y]=l.useState([]),[_,ee]=l.useState(!0),Q=u=>r===u?!0:r==="Settings"&&u!=="Settings"&&k?(S(u),v(!0),!1):(h(u),!0),ce=()=>{p&&h(p),d(!1),S(null),v(!1),A(!1)},b=()=>{S(null),v(!1)},V=u=>{Q(u)&&A(!1)},x=u=>{L(u),Q("User Management")};l.useEffect(()=>{if(r!=="Overview"||!i)return;const u=String(i.role||"").toLowerCase(),$=u==="admin"||u==="teacher";let te=!1;return ee(!0),Promise.all([er(),$?Pt():Promise.resolve([]),sr(3)]).then(([Ue,ns,Ae])=>{te||(B(Ue),O(ns.slice(0,4)),Y(Ae))}).catch(console.error).finally(()=>{te||ee(!1)}),()=>{te=!0}},[r,i]);const E=[{label:"Total Students",value:(C?.totalStudents??0).toLocaleString(),icon:Ze,color:"bg-sky-100",iconColor:"text-sky-600"},{label:"Active Teachers",value:(C?.activeTeachers??0).toString(),icon:Cs,color:"bg-teal-100",iconColor:"text-teal-600"},{label:"Total Classes",value:(C?.totalClasses??0).toString(),icon:je,color:"bg-sky-100",iconColor:"text-sky-600"},{label:"At-Risk Students",value:(C?.atRiskStudents??0).toString(),icon:Se,color:"bg-red-100",iconColor:"text-red-600"},{label:"Avg Performance",value:`${C?.avgPerformance??0}%`,icon:ss,color:"bg-orange-100",iconColor:"text-orange-600"},{label:"AI Interactions",value:(C?.aiPredictions??0).toLocaleString(),icon:ut,color:"bg-sky-100",iconColor:"text-sky-600"}],c=u=>u==="Error"||u==="Critical"?{text:"text-red-600",bg:"bg-red-50"}:u==="Warning"?{text:"text-rose-600",bg:"bg-rose-50"}:{text:"text-sky-600",bg:"bg-sky-50"};return e.jsxs("div",{className:"flex h-screen w-full bg-[#edf1f7] overflow-hidden",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsx(Bs,{activeTab:r,setActiveTab:V,userRole:"admin",onOpenSettings:()=>V("Settings"),onLogout:()=>o(!0),sidebarCollapsed:f,setSidebarCollapsed:j})}),w&&e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-40 bg-slate-900/40 backdrop-blur-[1px] lg:hidden",onClick:()=>A(!1)}),e.jsx("div",{className:"fixed inset-y-0 left-0 z-50 p-3 lg:hidden",children:e.jsx(Bs,{mode:"mobile",onRequestClose:()=>A(!1),activeTab:r,setActiveTab:V,userRole:"admin",onOpenSettings:()=>V("Settings"),onLogout:()=>{o(!0),A(!1)},sidebarCollapsed:!1})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("header",{className:"bg-white/80 backdrop-blur-md border-b border-[#dde3eb] px-6 py-3 flex items-center justify-between sticky top-0 z-30",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{type:"button",onClick:()=>A(!0),className:"inline-flex lg:hidden items-center justify-center w-10 h-10 rounded-xl border border-[#dde3eb] bg-white text-[#5a6578] hover:bg-[#edf1f7]","aria-label":"Open navigation",children:e.jsx(ra,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-display font-bold text-[#0a1628] leading-tight",children:[r==="Overview"&&"Admin Dashboard",r==="Content"&&"Content & RAG",r==="Audit Log"&&"Audit Log",r==="User Management"&&"User Management",r==="Analytics"&&"Analytics",r==="AI Monitoring"&&"AI Monitoring",r==="Settings"&&"Settings",r==="Subjects"&&"Subjects"]}),e.jsxs("p",{className:"text-xs text-[#5a6578] font-body",children:[r==="Overview"&&"System Overview & Management",r==="Content"&&"Upload PDFs for AI-powered content",r==="Audit Log"&&"Monitor system activity",r==="User Management"&&"Manage all user accounts",r==="Analytics"&&"Detailed performance metrics",r==="AI Monitoring"&&"Platform AI usage and system health",r==="Settings"&&"Configure platform settings",r==="Subjects"&&"Manage subjects and module availability"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{onClick:t,className:"flex items-center gap-2.5 h-11 shrink-0 bg-[#edf1f7] p-1.5 pr-3 rounded-lg cursor-pointer hover:bg-[#dde3eb] transition-all group",children:[e.jsx(la,{src:i?.photo,name:i?.name||"Admin",gender:i?.gender,className:"w-8 h-8 rounded-lg"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:e.jsx("p",{className:"text-sm font-semibold text-[#0a1628] leading-none group-hover:text-sky-600 transition-colors truncate",children:i?.name||"Admin"})})]})})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto p-6",children:[r==="Overview"&&e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-6",children:[e.jsxs("div",{className:"xl:col-span-8 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:E.map((u,$)=>{const te=u.icon;return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-[#dde3eb] hover:shadow-md transition-all",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsx("div",{className:`w-12 h-12 ${u.color} rounded-xl flex items-center justify-center`,children:e.jsx(te,{size:24,className:u.iconColor})})}),e.jsx("h3",{className:"text-2xl font-bold text-[#0a1628] mb-1",children:_?e.jsx("div",{className:"h-8 w-20 bg-[#edf1f7] rounded animate-pulse"}):u.value}),e.jsx("p",{className:"text-sm text-[#5a6578] font-medium",children:u.label})]},$)})}),e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628] mb-1",children:"System Performance Overview"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"Trend visualization"})]})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(ss,{size:32,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm font-medium text-[#5a6578]",children:"Performance trend chart is currently unavailable"}),e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Live KPI totals are shown above. Time-series backend support is required for chart rendering."})]})]}),e.jsx(Ur,{}),e.jsx(Rr,{}),e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628] mb-5",children:"Recent System Activity"}),_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(H,{className:"animate-spin text-sky-500"})}):q.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(Da,{size:28,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"No audit events yet"})]}):e.jsx("div",{className:"space-y-3",children:q.map(u=>{const $=c(u.severity);return e.jsxs("div",{className:`${$.bg} border border-[#dde3eb] rounded-2xl p-4 flex items-start gap-4`,children:[e.jsx("div",{className:"w-10 h-10 bg-white rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(Je,{size:18,className:$.text})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-[#0a1628] mb-0.5",children:u.action}),e.jsx("p",{className:"text-xs text-[#5a6578] truncate",children:u.details}),e.jsxs("p",{className:"text-xs text-[#5a6578] mt-1",children:[u.timestamp," · ",u.user.name]})]})]},u.id)})})]})]}),e.jsxs("div",{className:"xl:col-span-4 space-y-6",children:[e.jsxs("div",{className:"bg-gradient-to-br from-indigo-600 to-sky-600 rounded-3xl p-6 text-white shadow-lg",children:[e.jsx("h2",{className:"text-lg font-bold mb-4",children:"Quick Actions"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>x("Teacher"),className:"w-full bg-white/20 hover:bg-white/30 backdrop-blur-sm border border-slate-300 rounded-xl p-3 text-left transition-all",children:[e.jsx("p",{className:"text-sm font-bold",children:"Add New Teacher"}),e.jsx("p",{className:"text-xs text-sky-100",children:"Create teacher account"})]}),e.jsxs("button",{type:"button",onClick:()=>x("Student"),className:"w-full bg-white/20 hover:bg-white/30 backdrop-blur-sm border border-slate-300 rounded-xl p-3 text-left transition-all",children:[e.jsx("p",{className:"text-sm font-bold",children:"Add New Student"}),e.jsx("p",{className:"text-xs text-sky-100",children:"Register new student"})]}),e.jsxs("button",{type:"button",onClick:()=>Q("Settings"),className:"w-full bg-white/20 hover:bg-white/30 backdrop-blur-sm border border-slate-300 rounded-xl p-3 text-left transition-all",children:[e.jsx("p",{className:"text-sm font-bold",children:"System Settings"}),e.jsx("p",{className:"text-xs text-sky-100",children:"Configure platform"})]}),e.jsxs("button",{type:"button",disabled:!0,"aria-disabled":"true",title:"Report export is not available yet",className:"w-full bg-white/10 border border-slate-300/70 rounded-xl p-3 text-left opacity-60 cursor-not-allowed",children:[e.jsx("p",{className:"text-sm font-bold",children:"Generate Report"}),e.jsx("p",{className:"text-xs text-sky-100",children:"Export support is not available yet"})]})]})]}),e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx("div",{className:"w-10 h-10 bg-rose-100 rounded-xl flex items-center justify-center",children:e.jsx(Ye,{size:20,className:"text-rose-600"})}),e.jsx("h2",{className:"text-lg font-bold text-[#0a1628]",children:"Top Performers"})]}),_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(H,{className:"animate-spin text-sky-500"})}):G.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(Ye,{size:28,className:"text-[#dde3eb]"}),e.jsx("p",{className:"text-sm text-[#5a6578]",children:"No student data yet"}),e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Students will appear here as they progress."})]}):e.jsx("div",{className:"space-y-3",children:G.map((u,$)=>e.jsxs("div",{className:"bg-gradient-to-r from-rose-50 to-orange-50 border border-rose-200 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:u.avatar,alt:u.name,className:"w-12 h-12 rounded-xl object-cover"}),e.jsx("span",{className:"absolute -top-1 -right-1 w-6 h-6 bg-rose-500 text-white text-xs font-bold rounded-full flex items-center justify-center",children:$+1})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628]",children:u.name}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:u.class})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-xl p-2",children:[e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-1",children:"Performance"}),e.jsxs("p",{className:"text-lg font-bold text-teal-600",children:[u.performance,"%"]})]}),e.jsxs("div",{className:"bg-white rounded-xl p-2",children:[e.jsx("p",{className:"text-[10px] text-[#5a6578] mb-1",children:"Level"}),e.jsx("p",{className:"text-lg font-bold text-sky-600",children:u.level})]})]})]},u.id))})]}),e.jsxs("div",{className:"bg-white rounded-3xl p-6 shadow-sm border border-[#dde3eb]",children:[e.jsx("h2",{className:"text-lg font-bold text-[#0a1628] mb-5",children:"AI Model Status"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[#5a6578]",children:"AI Interactions Logged"}),e.jsx("span",{className:"text-sm font-bold text-[#0a1628]",children:_?"...":(C?.aiPredictions??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[#5a6578]",children:"At-Risk Students Tracked"}),e.jsx("span",{className:"text-sm font-bold text-[#0a1628]",children:_?"...":(C?.atRiskStudents??0).toLocaleString()})]}),e.jsx("div",{className:"mt-4 p-3 bg-sky-50 border border-sky-200 rounded-xl",children:e.jsxs("p",{className:"text-xs text-sky-800",children:[e.jsx("strong",{children:"Status:"})," Model quality metrics (accuracy/drift) are unavailable in the current backend and are intentionally hidden."]})})]})]})]})]}),r==="Content"&&e.jsx(Ha,{}),r==="Audit Log"&&e.jsx(ar,{}),r==="User Management"&&e.jsx(pr,{createIntentRole:y,onCreateIntentConsumed:()=>L(null)}),r==="Analytics"&&e.jsx(fr,{}),r==="AI Monitoring"&&e.jsx(zr,{}),r==="Settings"&&e.jsx(nr,{onDirtyChange:d}),r==="Subjects"&&e.jsx(Lr,{})]})]}),e.jsx(Ns,{isOpen:n,onClose:()=>o(!1),onConfirm:s,title:"Logout Confirmation",message:"Are you sure you want to log out? This will end your current session.",confirmText:"Logout",cancelText:"Cancel"}),e.jsx(Ns,{isOpen:m,onClose:b,onConfirm:ce,title:"Discard Unsaved Changes?",message:"You have unsaved settings changes. If you continue, your edits will be discarded.",confirmText:"Discard Changes",cancelText:"Keep Editing",type:"warning",icon:"warning"})]})};export{Ll as default}; diff --git a/assets/AdminDashboard-C9BDGBhi.js b/assets/AdminDashboard-C9BDGBhi.js new file mode 100644 index 0000000000000000000000000000000000000000..e6d150a722e746475cfcdc61ee77e9d0443592ce --- /dev/null +++ b/assets/AdminDashboard-C9BDGBhi.js @@ -0,0 +1,93 @@ +import{j as e,r as l,d as Cs}from"./vendor-react-B4AQeu28.js";import{C as Gt,S as Rt}from"./Sidebar-1AFatJJg.js";import Vt from"./ConfirmModal-BjVnuYqC.js";import{e as O,j as je,i as be,l as D,k as Wt,m as _,o as Y,R as ke,a as Se,g as J,I as Es,J as Ds,K as zs,n as Xt,u as Qe,L as Kt,S as pt,v as ft,U as ye,G as ze,N as Ps,O as Tt,P as Mt,Q as Lt,p as Qt,A as Ut,Z as he,V as Rs,B as Ts,T as jt,D as Ms,b as Ls,W as Us,M as $s,F as Is}from"./index-B3ruOzo6.js";import{B as C}from"./button-CaSK4KoS.js";import{S as W,a as X,b as we,c as K,d as N}from"./select-C142YWNr.js";import{I as Z}from"./input-kh84w1XK.js";import{S as qe}from"./subjects-DEj_AlYz.js";import{U as $e}from"./upload-BBhypj4u.js";import{D as ge,F as We,A as Ae,I as Fs,N as _s}from"./NotificationDropdown-IzxN6ZqA.js";import{T as Ge}from"./trash-2-CjkT7lLr.js";import{S as ht}from"./sparkles-Bq0AaIRg.js";import{S as vt}from"./search-DeasjpAx.js";import{D as Zt,a as Yt,b as Jt,c as es,e as Os}from"./dialog-KaD0jw5O.js";import{getDocs as ie,collection as ee,query as Xe,orderBy as ts,limit as ut,where as gt,addDoc as Bs,serverTimestamp as Hs,onSnapshot as qs}from"./vendor-firebase-firestore-CP9q7ISf.js";import{D as wt}from"./download-BbFDZT3H.js";import{S as $t}from"./shield-alert-kYf2Mbtd.js";import{S as Ke}from"./shield-check-Cwi1kdxV.js";import{C as Ze}from"./clock-C73na4Cu.js";import{E as ss,a as Gs}from"./eye-WyNbhirJ.js";import{C as as}from"./chevron-left-Cr0wYLQi.js";import{C as Nt}from"./chevron-right-CbkkCalp.js";import{C as fe}from"./circle-alert-CTR2Lqp7.js";import{C as Vs,a as Ws}from"./vendor-radix-BPuEd8FG.js";import{C as Xs}from"./check-6eXlU5jr.js";import{M as Ks}from"./mail-BXNRz1ib.js";import{P as It}from"./plus-Dx0gdu7_.js";import{S as ls}from"./save-DXz2z5YH.js";import{C as rs}from"./chart-column-C9VTl-3A.js";import{L as Qs,P as Zs}from"./pen-tool-BelhGWFu.js";import{S as Ys}from"./switch-UwrfTEB3.js";import{u as Js,t as ea,a as ta}from"./useSubjectAvailability-D7FKRlYS.js";import{X as sa}from"./x-BNHnAXzL.js";import{C as aa}from"./circle-help-C5HGdkRZ.js";import{B as la}from"./bell-Bp_utT8v.js";import{R as dt,B as ra,C as ia,X as na,Y as oa,T as ca,a as Ft,A as da,d as xa,P as ma,e as pa,b as _t}from"./vendor-charts-D7t7JfSr.js";import{C as ha}from"./circle-check-DyFN6-07.js";import"./LogoutActionButton-D5BV__Zd.js";import"./log-out-CoRJnfoO.js";import"./tooltip-CLSYbTYK.js";import"./shirt-BBR3GIpi.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-CTb5_AvY.js";import"./formatDistanceToNow-DTsqWUq4.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 ua=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],ga=O("arrow-up-right",ua);/** + * @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 ba=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Ot=O("ban",ba);/** + * @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 fa=[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]],ja=O("chart-pie",fa);/** + * @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 va=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],wa=O("dollar-sign",va);/** + * @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 Na=[["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:"m9 15 2 2 4-4",key:"1grp1n"}]],ya=O("file-check",Na);/** + * @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 ka=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]],Sa=O("file-search",ka);/** + * @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 Aa=[["path",{d:"M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473",key:"ol2ft2"}],["path",{d:"m16.5 3.5 5 5",key:"15e6fa"}],["path",{d:"m21.5 3.5-5 5",key:"m0lwru"}]],is=O("funnel-x",Aa);/** + * @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 Ca=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Ea=O("list-filter",Ca);/** + * @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 Da=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],za=O("lock-open",Da);/** + * @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 Pa=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],Ra=O("message-circle",Pa);/** + * @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 Ta=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],Ma=O("mouse-pointer-2",Ta);/** + * @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 La=[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]],Ua=O("school",La);/** + * @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 $a=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ie=O("square-pen",$a);/** + * @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 Ia=[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]],Fa=O("sticker",Ia);/** + * @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 _a=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]],Ve=O("user-check",_a);function ns({className:s,...a}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:je("w-full caption-bottom text-sm",s),...a})})}function os({className:s,...a}){return e.jsx("thead",{"data-slot":"table-header",className:je("[&_tr]:border-b",s),...a})}function cs({className:s,...a}){return e.jsx("tbody",{"data-slot":"table-body",className:je("[&_tr:last-child]:border-0",s),...a})}function Ne({className:s,...a}){return e.jsx("tr",{"data-slot":"table-row",className:je("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...a})}function pe({className:s,...a}){return e.jsx("th",{"data-slot":"table-head",className:je("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}function re({className:s,...a}){return e.jsx("td",{"data-slot":"table-cell",className:je("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}const Oa=({onUploadSuccess:s})=>{const[a,i]=l.useState("upload"),[r,n]=l.useState(!1),[x,m]=l.useState(null),[p,j]=l.useState(!1),[w,f]=l.useState(null),[c,g]=l.useState(""),[v,y]=l.useState(""),[z,A]=l.useState("1"),[T,U]=l.useState(0),[M,$]=l.useState(null),[B,te]=l.useState(!1),ne=l.useRef(null),G=l.useCallback(async()=>{te(!0);try{const o=await be.getRagHealth();$({subjects:o.subjects||{},chunkCount:o.chunkCount||0,lastIngested:o.lastIngested||""})}catch{D.error("Failed to load RAG health status")}finally{te(!1)}},[]);Cs.useEffect(()=>{G()},[G]);const Q=o=>{if(o.type!=="application/pdf"){D.error("Only PDF files are allowed");return}if(o.size>50*1024*1024){D.error("File size must be under 50MB");return}if(f(o),c){const P=qe.find(d=>d.id===c);P&&y(P.name)}},se=l.useCallback(o=>{o.preventDefault(),j(!1);const P=o.dataTransfer.files[0];P&&Q(P)},[c]),I=l.useCallback(o=>{o.preventDefault(),j(!0)},[]),ae=l.useCallback(()=>j(!1),[]),V=o=>{g(o);const P=qe.find(d=>d.id===o);P&&y(P.name)},F=async()=>{if(!w||!c||!v.trim()){D.error("Please select a PDF file, subject, and enter a subject name");return}n(!0),U(0);try{const o=new FormData;o.append("file",w),o.append("subjectId",c),o.append("subjectName",v.trim()),o.append("quarter",z);const P=setInterval(()=>{U(H=>Math.min(H+15,85))},300),d=await be.uploadModulePdf(o);clearInterval(P),U(100),d.success?(D.success(`${w.name} uploaded! ${d.chunkCount??0} chunks indexed.`),f(null),d.chunkCount!==void 0&&s?.(c,d.chunkCount),G(),setTimeout(()=>i("inventory"),1e3)):D.error(d.error||"Upload failed")}catch(o){D.error(o instanceof Error?o.message:"Upload failed")}finally{n(!1),setTimeout(()=>U(0),500)}},h=async(o,P)=>{m(o);try{const d=await be.reingestModulePdf(o,P);d.success?(D.success(`Re-ingestion complete for ${o}: ${d.chunkCount??0} chunks`),G()):D.error(d.error||"Re-ingestion failed")}catch(d){D.error(d instanceof Error?d.message:"Re-ingestion failed")}finally{m(null)}},k=M?Object.entries(M.subjects).map(([o,P])=>({name:o,chunks:P,storagePath:"",status:P>0?"active":"missing"})).filter(o=>o.chunks>0):[];return e.jsxs("div",{className:"space-y-4 pt-2 xl:pt-4 pb-4 max-w-[1200px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-white p-1 rounded-2xl border border-slate-200 shadow-sm",children:[e.jsxs("button",{onClick:()=>i("upload"),className:`flex items-center gap-2 px-5 py-2 rounded-xl text-[12px] font-black transition-all duration-300 ${a==="upload"?"bg-[#9956DE] text-white shadow-lg shadow-purple-200":"text-slate-400 hover:text-purple-600 hover:bg-purple-50"}`,children:[e.jsx($e,{size:14}),"Import"]}),e.jsxs("button",{onClick:()=>i("inventory"),className:`flex items-center gap-2 px-5 py-2 rounded-xl text-[12px] font-black transition-all duration-300 ${a==="inventory"?"bg-[#9956DE] text-white shadow-lg shadow-purple-200":"text-slate-400 hover:text-purple-600 hover:bg-purple-50"}`,children:[e.jsx(ge,{size:14}),"Inventory"]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"hidden sm:flex items-center gap-3 bg-white/80 backdrop-blur-md px-3 py-1.5 rounded-xl border border-slate-100 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest leading-none",children:"Chunks"}),e.jsx("span",{className:"text-[12px] font-black text-purple-600 leading-none mt-1",children:B?"...":(M?.chunkCount??0).toLocaleString()})]}),e.jsx("div",{className:"w-px h-5 bg-slate-100"}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest leading-none",children:"Health"}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx("span",{className:"text-[12px] font-black text-purple-600 leading-none",children:k.length}),e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${k.length>0?"bg-emerald-500 animate-pulse":"bg-slate-300"}`})]})]})]})})]}),e.jsx(Wt,{mode:"wait",children:a==="upload"?e.jsxs(_.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-[24px] border border-slate-200 shadow-sm overflow-hidden group",children:[e.jsxs("div",{className:"p-6 border-b border-slate-50 bg-gradient-to-br from-white to-purple-50/20 relative",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-black text-[#1e293b] tracking-tight",children:"Learning Module Upload"}),e.jsx("p",{className:"text-[11px] text-slate-500 font-medium italic",children:"Provide curriculum context for AI tutoring logic."})]}),e.jsx("div",{className:"w-10 h-10 bg-[#9956DE] rounded-xl flex items-center justify-center text-white shadow-md transition-transform group-hover:scale-110",children:e.jsx($e,{size:20})})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{onDrop:se,onDragOver:I,onDragLeave:ae,onClick:()=>!r&&ne.current?.click(),className:` + relative border-2 border-dashed rounded-2xl p-6 text-center cursor-pointer transition-all duration-300 group/drop + ${p?"border-[#9956DE] bg-purple-50 scale-[0.99]":"border-slate-200 hover:border-[#9956DE] bg-white hover:bg-purple-50/30"} + ${r?"cursor-not-allowed opacity-60":""} + min-h-[160px] flex flex-col items-center justify-center + `,children:[e.jsx("input",{ref:ne,type:"file",accept:".pdf",className:"hidden",onChange:o=>o.target.files?.[0]&&Q(o.target.files[0])}),w?e.jsxs("div",{className:"flex items-center gap-4 text-left",children:[e.jsx("div",{className:"w-14 h-14 bg-purple-50 rounded-xl flex items-center justify-center text-purple-600 border border-purple-100 shadow-sm shrink-0",children:e.jsx(We,{size:28})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"font-black text-[14px] text-[#1e293b] truncate max-w-[300px]",children:w.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-purple-500 font-black uppercase",children:[(w.size/1024/1024).toFixed(2)," MB"]}),e.jsx("span",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest italic",children:"PDF Source"})]}),e.jsxs("button",{onClick:o=>{o.stopPropagation(),f(null)},className:"text-[10px] font-black text-rose-500 hover:text-rose-600 mt-1 flex items-center gap-1",children:[e.jsx(Ge,{size:10})," Replace"]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-50 rounded-xl flex items-center justify-center text-slate-300 mb-4 group-hover/drop:text-purple-500 group-hover/drop:bg-purple-50 transition-all",children:e.jsx($e,{size:24})}),e.jsx("h4",{className:"text-[14px] font-black text-[#1e293b]",children:"Drop PDF or click to browse"}),e.jsx("p",{className:"text-[10px] text-slate-400 mt-1 font-medium italic",children:"Max 50MB (SLM, Textbook, Guide)"})]}),T>0&&e.jsx("div",{className:"absolute inset-0 bg-white/95 backdrop-blur-[1px] rounded-2xl flex flex-col items-center justify-center p-8 z-20",children:e.jsxs("div",{className:"w-full max-w-xs space-y-3 text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-[#9956DE] rounded-xl flex items-center justify-center mx-auto mb-2 animate-bounce",children:e.jsx(ht,{size:24,className:"text-white"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h5",{className:"text-sm font-black text-[#1e293b]",children:r?"Analyzing Curriculum...":"Complete!"}),e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Platform Ingestion"})]}),e.jsx("div",{className:"h-2 bg-slate-100 rounded-full overflow-hidden p-0.5 border border-slate-200 mt-2",children:e.jsx(_.div,{className:"h-full bg-gradient-to-r from-purple-500 to-sky-500 rounded-full",initial:{width:0},animate:{width:`${T}%`},transition:{duration:.3}})})]})})]})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Curriculum Subject"}),e.jsxs(W,{value:c,onValueChange:V,disabled:r,children:[e.jsx(X,{className:"w-full h-10 bg-slate-50/50 border-slate-200 rounded-xl text-[12px] font-bold focus:ring-purple-500/20",children:e.jsx(we,{placeholder:"Select subject"})}),e.jsx(K,{className:"rounded-xl border-slate-200",children:qe.map(o=>e.jsx(N,{value:o.id,className:"rounded-lg py-2",children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-black text-[12px]",children:o.name}),e.jsxs("span",{className:"text-[9px] text-slate-400 font-bold uppercase",children:[o.gradeLevel," • ",o.semester]})]})},o.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Display Label"}),e.jsx(Z,{value:v,onChange:o=>y(o.target.value),placeholder:"e.g. General Mathematics",disabled:r,className:"h-10 bg-slate-50/50 border-slate-200 rounded-xl text-[12px] font-bold px-4 focus-visible:ring-purple-500/20"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Quarter"}),e.jsxs(W,{value:z,onValueChange:A,disabled:r,children:[e.jsx(X,{className:"w-full h-10 bg-slate-50/50 border-slate-200 rounded-xl text-[12px] font-bold focus:ring-purple-500/20",children:e.jsx(we,{})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"1",className:"rounded-lg text-[12px] font-bold",children:"First Quarter"}),e.jsx(N,{value:"2",className:"rounded-lg text-[12px] font-bold",children:"Second Quarter"}),e.jsx(N,{value:"3",className:"rounded-lg text-[12px] font-bold",children:"Third Quarter"}),e.jsx(N,{value:"4",className:"rounded-lg text-[12px] font-bold",children:"Fourth Quarter"})]})]})]})]}),e.jsx(C,{onClick:F,disabled:r||!w||!c||!v.trim(),className:"w-full h-12 gap-2 bg-[#9956DE] hover:bg-[#8b5cf6] text-white rounded-2xl shadow-lg shadow-purple-100 transition-all hover:scale-[1.01] active:scale-95 text-[14px] font-black",children:r?e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:16,className:"animate-spin"})," Ingesting..."]}):e.jsxs(e.Fragment,{children:[e.jsx($e,{size:16})," Deploy Knowledge Source"]})})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[{icon:ht,color:"bg-purple-50",iconColor:"text-purple-600",title:"Grounding",desc:"Curriculum-pinned logic."},{icon:ge,color:"bg-sky-50",iconColor:"text-sky-600",title:"Indexing",desc:"Millisecond RAG retrieval."},{icon:Gt,color:"bg-emerald-50",iconColor:"text-emerald-600",title:"Extraction",desc:"Neural chunk parsing."}].map((o,P)=>e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-slate-100 shadow-sm flex items-start gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg ${o.color} flex items-center justify-center shrink-0`,children:e.jsx(o.icon,{size:14,className:o.iconColor})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-black text-[#1e293b] uppercase tracking-wide leading-none",children:o.title}),e.jsx("p",{className:"text-[9px] text-slate-400 leading-tight mt-1 font-medium italic",children:o.desc})]})]},P))})]},"upload-tab"):e.jsx(_.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"space-y-4",children:e.jsx("div",{className:"bg-white rounded-[24px] border border-slate-200 shadow-sm overflow-hidden relative",children:e.jsxs(ns,{className:"w-full text-left border-collapse",children:[e.jsx(os,{children:e.jsxs(Ne,{className:"bg-[#9956DE] hover:bg-[#9956DE] border-b border-[#8b5cf6] sticky top-0 z-20 shadow-sm",children:[e.jsx(pe,{className:"px-6 py-4 text-[10px] font-black text-white uppercase tracking-widest h-auto",children:"Identity"}),e.jsx(pe,{className:"px-6 py-4 text-[10px] font-black text-white uppercase tracking-widest h-auto",children:"Density"}),e.jsx(pe,{className:"px-6 py-4 text-[10px] font-black text-white uppercase tracking-widest h-auto text-center",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-[10px] font-black text-white uppercase tracking-widest text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(vt,{className:"w-3 h-3 absolute left-3 top-1/2 -translate-y-1/2 text-white/60 group-focus-within:text-white transition-colors"}),e.jsx(Z,{placeholder:"Filter...",className:"pl-8 h-8 w-32 bg-white/10 border-white/20 rounded-lg text-[10px] font-black placeholder:text-white/40 text-white focus-visible:ring-white/20 transition-all"})]}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-8 px-2 bg-white/10 text-white hover:bg-white/20 rounded-lg",onClick:G,disabled:B,children:e.jsx(ke,{size:12,className:B?"animate-spin":""})})]})})]})}),e.jsx(cs,{className:"divide-y divide-slate-50",children:B?e.jsx(Ne,{children:e.jsxs(re,{colSpan:4,className:"h-48 text-center",children:[e.jsx(Y,{size:24,className:"animate-spin text-purple-500 mx-auto"}),e.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mt-2",children:"Syncing Knowledge Base..."})]})}):k.length===0?e.jsx(Ne,{children:e.jsxs(re,{colSpan:4,className:"h-48 text-center",children:[e.jsx(ge,{size:24,className:"text-slate-200 mx-auto"}),e.jsx("p",{className:"text-[12px] font-black text-slate-400 mt-2",children:"No data in index."})]})}):k.map(o=>e.jsxs(Ne,{className:"group hover:bg-purple-50/10 transition-all border-b border-slate-50",children:[e.jsx(re,{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-purple-50 to-white border border-purple-100 flex items-center justify-center text-purple-500 shadow-sm group-hover:scale-110 transition-transform",children:e.jsx(Se,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-black text-[#1e293b] text-[13px] block group-hover:text-purple-600 transition-colors",children:o.name}),e.jsx("span",{className:"text-[9px] font-black text-slate-400 uppercase tracking-tighter mt-1 block",children:"Curriculum Source"})]})]})}),e.jsx(re,{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("span",{className:"text-[14px] font-display font-black text-purple-600 leading-none",children:[o.chunks.toLocaleString()," ",e.jsx("span",{className:"text-[9px] text-slate-400",children:"units"})]}),e.jsx("div",{className:"w-20 h-1 bg-slate-100 rounded-full overflow-hidden border border-slate-200",children:e.jsx("div",{className:"h-full bg-purple-500 rounded-full",style:{width:"100%"}})})]})}),e.jsx(re,{className:"px-6 py-4 text-center",children:e.jsx("div",{className:"flex flex-col items-center gap-1",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-3 py-1 rounded-full text-[9px] font-black uppercase tracking-wider border ${o.status==="active"?"bg-emerald-50 text-emerald-600 border-emerald-100":"bg-rose-50 text-rose-600 border-rose-100"}`,children:[e.jsx("div",{className:`w-1 h-1 rounded-full ${o.status==="active"?"bg-emerald-500":"bg-rose-500"}`}),o.status]})})}),e.jsx(re,{className:"px-6 py-4 text-right",children:e.jsxs(C,{variant:"outline",size:"sm",className:"h-8 px-4 gap-1.5 text-[9px] font-black uppercase tracking-widest rounded-lg border-slate-200 hover:bg-purple-600 hover:text-white hover:border-purple-600 transition-all",onClick:()=>h(o.name.toLowerCase().replace(/\s+/g,"-").replace("&",""),o.storagePath),disabled:x===o.name.toLowerCase().replace(/\s+/g,"-").replace("&",""),children:[e.jsx(ke,{size:10,className:x===o.name.toLowerCase()?"animate-spin":""}),"Sync"]})})]},o.name))})]})})},"inventory-tab")})]})};function Ba(s){return s?s.charAt(0).toUpperCase()+s.slice(1):"Student"}function ds(s){if(!s||!s.toDate)return new Date().toISOString().replace("T"," ").slice(0,19);const a=s.toDate();return`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")} ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}:${String(a.getSeconds()).padStart(2,"0")}`}function Ha(){return ds({toDate:()=>new Date})}function qa(s){if(!s)return"Never";const a=new Date(s);if(Number.isNaN(a.getTime()))return s;const r=Date.now()-a.getTime(),n=Math.floor(r/6e4);if(n<1)return"Just now";if(n<60)return`${n} minute${n!==1?"s":""} ago`;const x=Math.floor(n/60);if(x<24)return`${x} hour${x!==1?"s":""} ago`;const m=Math.floor(x/24);return m<7?`${m} day${m!==1?"s":""} ago`:a.toLocaleDateString()}function Ga(s){const a=(s.grade||"").trim(),i=(s.section||"").trim(),r=[a,i].filter(Boolean).join(" - ");return{id:s.uid,name:s.name||"Unknown",email:s.email||"",role:Ba(s.role||""),status:s.status||"Active",department:s.department||(s.role?.toLowerCase()==="student"?r||"Student":""),grade:a,section:i,classSectionId:s.classSectionId||void 0,classSection:r,lrn:(s.lrn||"").trim(),photo:(s.photo||"").trim(),lastLogin:qa(s.lastLogin),createdAt:s.createdAt||void 0}}function Ye(s){if(s instanceof Xt){try{const a=JSON.parse(s.responseBody);if(a?.detail&&typeof a.detail=="string")return a.detail}catch{}return`Request failed (${s.status}).`}return s instanceof Error?s.message:"Request failed."}async function Va(s={}){try{const a=await be.getAdminUsers({page:s.page??1,pageSize:s.pageSize??25,search:s.searchQuery,role:s.roleFilter,status:s.statusFilter,grade:s.gradeFilter,section:s.sectionFilter,classSectionId:s.classSectionId});if(!a.success)throw new Error("Failed to load admin users");return{users:(a.users||[]).map(Ga),page:a.page,pageSize:a.pageSize,total:a.total,totalPages:a.totalPages,hasNextPage:a.hasNextPage}}catch(a){throw console.error("[adminService] getAdminUsersPage error:",a),a instanceof Ds?new Error("Loading users timed out. Please refresh and try again."):a instanceof zs?new Error("Unable to reach the server. Please check your connection and retry."):a instanceof Xt&&a.status===504?new Error("Loading users took too long. Try narrowing your filters and retrying."):new Error(Ye(a))}}async function Wa(s,a){try{await be.updateAdminUser(s,{...a.name!==void 0?{name:a.name}:{},...a.role!==void 0?{role:a.role}:{},...a.status!==void 0?{status:a.status}:{},...a.department!==void 0?{department:a.department}:{},...a.grade!==void 0?{grade:a.grade}:{},...a.section!==void 0?{section:a.section}:{},...a.lrn!==void 0?{lrn:a.lrn}:{}})}catch(i){throw new Error(Ye(i))}}async function Xa(s){try{const a=await be.createAdminUser({name:s.name.trim(),email:s.email.trim().toLowerCase(),password:s.password,confirmPassword:s.confirmPassword,role:s.role,status:s.status,grade:s.grade.trim(),section:s.section.trim(),...s.lrn?.trim()?{lrn:s.lrn.trim()}:{}});if(!a.success||!a.userCreated||!a.uid)throw new Error(a.message||"Failed to create user account.");return{uid:a.uid,userCreated:a.userCreated,emailSent:a.emailSent,resultCode:a.resultCode,message:a.message,warnings:a.warnings??[],emailError:a.emailError}}catch(a){throw new Error(Ye(a))}}async function Ka(s){try{const a=await be.bulkAdminUsers({action:s.action,userIds:s.userIds??[],excludeUserIds:s.excludeUserIds??[],filters:s.filters,role:s.role,status:s.status,grade:s.grade,section:s.section,lrn:s.lrn,dryRun:s.dryRun,exportFormat:s.exportFormat??"csv"});return{success:a.success,action:a.action,summary:a.summary,results:a.results,warnings:a.warnings||[],exportRows:a.export?.rows||[]}}catch(a){throw new Error(Ye(a))}}async function xs(){try{if(!Es.currentUser)return[];const s=Xe(ee(J,"accessAuditLogs"),ts("timestamp","desc"),ut(100));return(await ie(s)).docs.map(i=>{const r=i.data(),x=r.success!==!1?"Info":"Error",m=r.action||"";let p="System";return r.module==="admin"||m.startsWith("admin_")?p="User":m.includes("login")||m.includes("auth")?p="Auth":(m.includes("upload")||m.includes("course"))&&(p="Content"),{id:i.id,severity:x,timestamp:typeof r.timestamp=="string"?r.timestamp:ds(r.timestamp),user:{name:r.actorName||r.teacherEmail||"System",role:r.actorRole||r.role||"Admin",avatar:null},action:m,category:p,details:r.description||(r.status?`Status: ${r.status}`:"")}})}catch(s){const a=s;return a?.code==="permission-denied"||a?.code==="firestore/permission-denied"?[]:(console.error("[adminService] getAuditLogs error:",s),[])}}async function xt(s,a,i,r,n){await Bs(ee(J,"auditLogs"),{severity:i,timestamp:Ha(),timestampRaw:Hs(),user:n,action:s,category:a,details:r})}async function Qa(){try{const s=await ie(ee(J,"users"));let a=0,i=0,r=0;s.docs.forEach(p=>{const j=p.data();j.role==="student"&&(a++,j.overallRisk==="High"&&r++),j.role==="teacher"&&j.status!=="Inactive"&&i++});let n=0;try{n=(await ie(ee(J,"classrooms"))).size}catch{}let x=0;try{x=(await ie(ee(J,"xpActivities"))).size}catch{}let m=0;try{const p=await ie(ee(J,"progress")),j=[];p.docs.forEach(w=>{const f=w.data();typeof f.averageScore=="number"&&j.push(f.averageScore)}),m=j.length>0?Math.round(j.reduce((w,f)=>w+f,0)/j.length):0}catch{}return{totalStudents:a,activeTeachers:i,totalClasses:n,atRiskStudents:r,avgPerformance:m,aiPredictions:x}}catch(s){return console.error("[adminService] getDashboardStats error:",s),{totalStudents:0,activeTeachers:0,totalClasses:0,atRiskStudents:0,avgPerformance:0,aiPredictions:0}}}async function Za(s=3){const a=r=>{const n=r.data(),x=n.level||1,m=n.currentXP||0,p=Math.min(100,x*8+Math.round(m/100));return{id:r.id,name:n.name||"Student",avatar:n.photo||n.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(n.name||"S")}&background=0d9488&color=fff`,class:n.grade||"Math",performance:p,level:x}},i=r=>r.sort((n,x)=>x.level!==n.level?x.level-n.level:x.performance-n.performance).slice(0,s);try{const r=Xe(ee(J,"users"),gt("role","==","student"),ts("level","desc"),ut(s)),n=await ie(r);return i(n.docs.map(a))}catch(r){if(r?.code==="failed-precondition")try{const x=Xe(ee(J,"users"),gt("role","==","student"),ut(Math.max(50,s))),m=await ie(x);return i(m.docs.map(a))}catch(x){return console.error("[adminService] getTopPerformers fallback error:",x),[]}return console.error("[adminService] getTopPerformers error:",r),[]}}async function Ya(){try{const s=await ie(ee(J,"users"));let a=0,i=0,r=0,n=0,x=0;s.docs.forEach(j=>{const w=j.data();w.role==="student"&&(a++,w.overallRisk==="High"&&r++,w.streak>0&&x++,n+=w.totalXP||0),w.role==="teacher"&&i++});let m=0;try{m=(await ie(ee(J,"achievements"))).size}catch{}let p=0;try{p=(await ie(ee(J,"chatSessions"))).size}catch{}return{totalActiveUsers:a+i,totalStudents:a,totalTeachers:i,atRiskStudents:r,achievementsUnlocked:m,totalXPEarned:n,activeStreaks:x,aiTutorSessions:p}}catch(s){return console.error("[adminService] getAnalyticsSummary error:",s),{totalActiveUsers:0,totalStudents:0,totalTeachers:0,atRiskStudents:0,achievementsUnlocked:0,totalXPEarned:0,activeStreaks:0,aiTutorSessions:0}}}const Ja=[10,25,50,100],Fe=({title:s,value:a,subtitle:i,icon:r,variant:n})=>{const x={blue:"bg-[#5154E7] shadow-blue-200/50",purple:"bg-[#9956DE] shadow-purple-200/50",rose:"bg-[#F43F5E] shadow-rose-200/50",emerald:"bg-[#10B981] shadow-emerald-200/50"};return e.jsxs("div",{className:`relative overflow-hidden rounded-[24px] p-5 text-white shadow-lg transition-all hover:scale-[1.02] ${x[n]}`,children:[e.jsx("div",{className:"absolute -right-4 -top-4 opacity-10",children:e.jsx(r,{size:100})}),e.jsx("div",{className:"absolute right-4 top-4 w-8 h-8 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(r,{size:16})}),e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] opacity-80",children:s}),e.jsx("h3",{className:"text-2xl font-black mt-2 leading-none",children:a}),e.jsx("p",{className:"text-[10px] font-bold mt-4 opacity-70 uppercase tracking-widest",children:i}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-20 h-20 bg-white/10 rounded-full blur-2xl"})]})},el=()=>{const{userProfile:s,loading:a}=Qe(),[i,r]=l.useState([]),[n,x]=l.useState(!0),[m,p]=l.useState(!1),[j,w]=l.useState(""),[f,c]=l.useState("All Categories"),[g,v]=l.useState("All Severities"),[y,z]=l.useState("All Roles"),[A,T]=l.useState(null),[U,M]=l.useState(1),[$,B]=l.useState(25),te=l.useCallback(async()=>{if(a||!s)return;const d=String(s.role||"").toLowerCase();if(d!=="admin"&&d!=="teacher"){x(!1),p(!0);return}p(!1),x(!0);try{const H=await xs();r(H)}catch{D.error("Failed to load audit logs")}finally{x(!1)}},[a,s]);l.useEffect(()=>{te()},[te]);const ne=i.filter(d=>d.severity==="Info").length;i.filter(d=>d.severity==="Warning").length;const G=i.filter(d=>d.severity==="Error"||d.severity==="Critical").length,Q=d=>{switch(d){case"Info":return e.jsx(Fs,{size:14});case"Warning":return e.jsx(ft,{size:14});case"Error":return e.jsx($t,{size:14});case"Critical":return e.jsx(fe,{size:14});default:return e.jsx(Ae,{size:14})}},se=d=>{switch(d){case"Info":return"bg-sky-50 text-sky-600 border-sky-100";case"Warning":return"bg-amber-50 text-amber-600 border-amber-100";case"Error":return"bg-rose-50 text-rose-600 border-rose-100";case"Critical":return"bg-red-50 text-red-600 border-red-100 ring-1 ring-red-500";default:return"bg-slate-50 text-slate-600 border-slate-100"}},I={"All Categories":"All Categories",Auth:"Authentication",Data:"Data Operations",User:"User Management",System:"System Engine",Content:"Content Pipeline"},ae={"All Severities":"All Severities",Info:"Information",Warning:"Warning",Error:"Error",Critical:"Critical"},V={"All Roles":"All Roles",Admin:"Administrator",Teacher:"Educator",Student:"Student"},F=l.useMemo(()=>i.filter(d=>{const H=d.action.toLowerCase().includes(j.toLowerCase())||d.details.toLowerCase().includes(j.toLowerCase())||d.user.name.toLowerCase().includes(j.toLowerCase()),Pe=f==="All Categories"||d.category===f,Je=g==="All Severities"||d.severity===g,Ce=y==="All Roles"||d.user.role===y;return H&&Pe&&Je&&Ce}),[i,j,f,g,y]),h=Math.max(Math.ceil(F.length/$),1),k=l.useMemo(()=>{const d=(U-1)*$;return F.slice(d,d+$)},[F,U,$]);if(l.useEffect(()=>{M(1)},[j,f,g,y]),m)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center p-8 bg-white rounded-[32px] border border-slate-200 mt-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-rose-50 flex items-center justify-center mb-6",children:e.jsx(Kt,{size:40,className:"text-rose-500"})}),e.jsx("h3",{className:"text-2xl font-black text-[#1e293b]",children:"Access Denied"}),e.jsx("p",{className:"text-slate-400 font-medium max-w-md mx-auto mt-2 uppercase text-[11px] tracking-widest",children:"Security policy restricts audit log visibility to administrative personnel only."})]});const o=F.length===0?0:(U-1)*$+1,P=Math.min(U*$,F.length);return e.jsxs("div",{className:"flex flex-col min-h-full animate-in fade-in duration-500",children:[e.jsxs("div",{className:"flex-1 space-y-8 pt-6 xl:pt-8 pb-6 px-1 max-w-[1600px] mx-auto w-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-1.5 h-6 bg-[#9956DE] rounded-full"}),e.jsx("p",{className:"text-[11px] font-black text-slate-400 uppercase tracking-[0.2em]",children:"System Governance Pipeline"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:te,disabled:n,className:"p-2.5 rounded-xl bg-white border border-slate-200 text-slate-400 hover:text-purple-600 shadow-sm transition-all active:scale-95 group",title:"Synchronize logs",children:e.jsx(ke,{size:14,className:n?"animate-spin":"group-hover:rotate-180 transition-transform duration-500"})}),e.jsxs("button",{disabled:!0,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 text-slate-400 rounded-xl text-[10px] font-black uppercase tracking-widest opacity-60 cursor-not-allowed",children:[e.jsx(wt,{size:14})," Export Logs"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 shrink-0",children:[e.jsx(Fe,{title:"Total Events",value:n?"...":i.length,subtitle:"System-Wide Logs",icon:We,variant:"purple"}),e.jsx(Fe,{title:"Security Alerts",value:n?"...":G,subtitle:"Critical Incidents",icon:$t,variant:"rose"}),e.jsx(Fe,{title:"Operational Info",value:n?"...":ne,subtitle:"Routine Pipelines",icon:Ve,variant:"blue"}),e.jsx(Fe,{title:"System Health",value:G>0?"Compromised":"Healthy",subtitle:"Live Monitoring",icon:Ke,variant:G>0?"rose":"emerald"})]})]}),e.jsx("div",{className:"sticky top-0 z-40 -mx-[24px] xl:-mx-[32px] px-[24px] xl:px-[32px] pt-4 pb-4 bg-[#f8fafc] backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col xl:flex-row items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 w-full group",children:[e.jsx(vt,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 group-focus-within:text-[#9956DE] transition-colors",size:16}),e.jsx(Z,{type:"text",placeholder:"Trace user identity, action strings, or operation details...",className:"pl-11 h-12 bg-white border-slate-200/60 rounded-2xl focus-visible:ring-[#9956DE]/20 focus-visible:border-[#9956DE] transition-all text-sm font-medium shadow-md shadow-slate-200/40",value:j,onChange:d=>w(d.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full xl:w-auto",children:[e.jsxs(W,{value:f,onValueChange:c,children:[e.jsx(X,{className:"w-[200px] bg-white border border-slate-200 hover:border-[#9956DE] transition-all focus:ring-2 focus:ring-[#9956DE]/10 text-[10px] font-black uppercase tracking-widest text-slate-900 rounded-xl h-12 shadow-md shadow-slate-200/40 px-4",children:e.jsx("span",{className:"truncate",children:I[f]||f})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"All Categories",className:"font-bold",children:"All Categories"}),e.jsx(N,{value:"Auth",className:"font-bold",children:"Authentication"}),e.jsx(N,{value:"Data",className:"font-bold",children:"Data Operations"}),e.jsx(N,{value:"User",className:"font-bold",children:"User Management"}),e.jsx(N,{value:"System",className:"font-bold",children:"System Engine"}),e.jsx(N,{value:"Content",className:"font-bold",children:"Content Pipeline"})]})]}),e.jsxs(W,{value:g,onValueChange:v,children:[e.jsx(X,{className:"w-[200px] bg-white border border-slate-200 hover:border-[#9956DE] transition-all focus:ring-2 focus:ring-[#9956DE]/10 text-[10px] font-black uppercase tracking-widest text-slate-900 rounded-xl h-12 shadow-md shadow-slate-200/40 px-4",children:e.jsx("span",{className:"truncate",children:ae[g]||g})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"All Severities",className:"font-bold",children:"All Severities"}),e.jsx(N,{value:"Info",className:"font-bold",children:"Information"}),e.jsx(N,{value:"Warning",className:"font-bold",children:"Warning"}),e.jsx(N,{value:"Error",className:"font-bold",children:"Error"}),e.jsx(N,{value:"Critical",className:"font-bold",children:"Critical"})]})]}),e.jsxs(W,{value:y,onValueChange:z,children:[e.jsx(X,{className:"w-[200px] bg-white border border-slate-200 hover:border-[#9956DE] transition-all focus:ring-2 focus:ring-[#9956DE]/10 text-[10px] font-black uppercase tracking-widest text-slate-900 rounded-xl h-12 shadow-md shadow-slate-200/40 px-4",children:e.jsx("span",{className:"truncate",children:V[y]||y})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"All Roles",className:"font-bold",children:"All Roles"}),e.jsx(N,{value:"Admin",className:"font-bold",children:"Administrator"}),e.jsx(N,{value:"Teacher",className:"font-bold",children:"Educator"}),e.jsx(N,{value:"Student",className:"font-bold",children:"Student"})]})]}),e.jsx(C,{variant:"outline",size:"icon",onClick:()=>{w(""),c("All Categories"),v("All Severities"),z("All Roles")},disabled:!j&&f==="All Categories"&&g==="All Severities"&&y==="All Roles",className:"h-12 w-12 rounded-2xl border-slate-200/60 text-[#9956DE] hover:bg-purple-50 disabled:opacity-30 disabled:cursor-not-allowed transition-all shadow-sm",title:"Reset Filters",children:e.jsx(is,{size:18})})]})]})}),e.jsx("div",{className:"bg-white rounded-[32px] border border-slate-200/60 shadow-sm shadow-slate-200/40 relative",children:e.jsx("div",{className:"rounded-[32px]",children:e.jsxs("table",{className:"w-full text-left border-collapse min-w-[1000px]",children:[e.jsx("thead",{className:"sticky top-[80px] z-30 bg-[#f8fafc] backdrop-blur-sm shadow-[0_-12px_0_0_#f8fafc]",children:e.jsxs("tr",{className:"border-b border-[#8b5cf6]",children:[e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest whitespace-nowrap rounded-tl-[20px]",children:"Incident Level"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest whitespace-nowrap",children:"Timestamp"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"User Actor"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Action Performed"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Component"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest text-right whitespace-nowrap rounded-tr-[20px]",children:"Review"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:n?Array(10).fill(0).map((d,H)=>e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"h-20 p-8",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-slate-50 animate-pulse"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-32 h-3 bg-slate-50 animate-pulse rounded"}),e.jsx("div",{className:"w-48 h-2 bg-slate-50 animate-pulse rounded"})]})]})})},H)):k.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"h-64 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(pt,{size:48,className:"text-slate-100 mb-4"}),e.jsx("p",{className:"text-[16px] font-black text-[#1e293b]",children:"No audit trails captured"}),e.jsx("p",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-widest mt-1",children:"Try adjusting your tracking filters"})]})})}):k.map(d=>e.jsxs("tr",{className:"group hover:bg-purple-50/20 transition-colors",children:[e.jsx("td",{className:"px-8 py-5",children:e.jsxs("span",{className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[9px] font-black uppercase tracking-wider border ${se(d.severity)}`,children:[Q(d.severity),d.severity]})}),e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-slate-50 flex items-center justify-center text-slate-400",children:e.jsx(Ze,{size:14})}),e.jsx("span",{className:"text-[13px] font-bold text-[#1e293b]",children:d.timestamp})]})}),e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-slate-50 border border-slate-100 flex items-center justify-center overflow-hidden shrink-0",children:d.user.avatar?e.jsx("img",{src:d.user.avatar,alt:d.user.name,className:"w-full h-full object-cover"}):e.jsx(pt,{size:16,className:"text-slate-300"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-black text-[#1e293b] leading-none group-hover:text-[#9956DE] transition-colors truncate",children:d.user.name}),e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter mt-1",children:d.user.role})]})]})}),e.jsxs("td",{className:"px-8 py-5",children:[e.jsx("p",{className:"text-sm font-bold text-[#1e293b] truncate max-w-[250px]",title:d.details,children:d.action}),e.jsx("p",{className:"text-[10px] text-slate-400 font-medium truncate max-w-[250px] mt-0.5",children:d.details})]}),e.jsx("td",{className:"px-8 py-5",children:e.jsx("span",{className:"text-[10px] font-black px-2.5 py-1 rounded-lg bg-slate-50 text-slate-600 border border-slate-100 uppercase tracking-widest",children:d.category})}),e.jsx("td",{className:"px-8 py-5 text-right",children:e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>T(d),className:"w-9 h-9 rounded-xl border border-slate-200 flex items-center justify-center text-slate-400 hover:text-[#9956DE] hover:border-[#9956DE]/30 hover:bg-purple-50 transition-all ",children:e.jsx(ss,{size:16})})})})]},d.id))})]})})}),e.jsxs("div",{className:"sticky bottom-0 z-50 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 px-12 py-3 bg-white border-t-2 border-slate-100 shadow-[0_-8px_30px_rgba(0,0,0,0.08)] -mx-[24px] xl:-mx-[32px] w-[calc(100%+48px)] xl:w-[calc(100%+64px)]",children:[e.jsxs("p",{className:"text-[12px] font-black text-slate-500 uppercase tracking-widest flex items-center gap-4",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#9956DE] animate-pulse shadow-[0_0_12px_rgba(153,86,222,0.6)]"}),"Showing ",e.jsxs("span",{className:"text-slate-900 font-black border-b-2 border-[#9956DE]/40 pb-0.5",children:[o,"–",P]}),e.jsx("span",{className:"text-slate-300 font-bold mx-1",children:"/"}),e.jsx("span",{className:"text-slate-900 font-black border-b-2 border-[#9956DE]/40 pb-0.5",children:F.length}),e.jsx("span",{className:"text-slate-400 ml-1",children:"Total System Records"})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(W,{value:String($),onValueChange:d=>{B(Number(d)),M(1)},children:[e.jsx(X,{className:"h-10 w-[140px] bg-white border border-slate-300 text-[11px] font-black uppercase tracking-wider text-slate-900 rounded-xl hover:border-[#9956DE] transition-all px-4 shadow-sm",children:e.jsxs("span",{className:"truncate",children:[$," / Page"]})}),e.jsx(K,{className:"rounded-xl border-slate-200",children:Ja.map(d=>e.jsxs(N,{value:String(d),className:"font-bold",children:[d," / Page"]},d))})]}),e.jsxs("div",{className:"flex items-center gap-2 bg-slate-50 p-1.5 rounded-2xl border border-slate-200 shadow-inner",children:[e.jsx(C,{variant:"outline",size:"sm",className:"h-9 w-9 p-0 rounded-xl bg-[#9956DE] border-none text-white hover:bg-[#8b5cf6] hover:scale-105 active:scale-95 disabled:opacity-30 transition-all shadow-lg shadow-purple-200/60",disabled:U<=1||n,onClick:()=>M(d=>Math.max(d-1,1)),children:e.jsx(as,{size:18,strokeWidth:3})}),e.jsx("div",{className:"px-5 py-2 bg-white rounded-xl shadow-sm border border-slate-200 flex items-center justify-center min-w-[130px]",children:e.jsxs("span",{className:"text-[11px] font-black text-slate-900 uppercase tracking-widest",children:["Page ",e.jsx("span",{className:"text-[#9956DE] mx-1",children:U}),e.jsx("span",{className:"text-slate-300 mx-1",children:"OF"}),e.jsx("span",{className:"text-slate-500",children:Math.max(h,1)})]})}),e.jsx(C,{variant:"outline",size:"sm",className:"h-9 w-9 p-0 rounded-xl bg-[#9956DE] border-none text-white hover:bg-[#8b5cf6] hover:scale-105 active:scale-95 disabled:opacity-30 transition-all shadow-lg shadow-purple-200/60",disabled:U>=h||n,onClick:()=>M(d=>Math.min(d+1,h||1)),children:e.jsx(Nt,{size:18,strokeWidth:3})})]})]})]}),e.jsx(Zt,{open:!!A,onOpenChange:d=>{d||T(null)},children:e.jsxs(Yt,{className:"sm:max-w-[600px] rounded-[32px] border-none shadow-2xl p-0 overflow-hidden",children:[e.jsx("div",{className:`h-2 w-full ${A?se(A.severity).split(" ")[0].replace("bg-","bg-").replace("-50","-500"):"bg-purple-600"}`}),e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsx(Jt,{className:"text-left",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-slate-50 flex items-center justify-center text-[#9956DE] border border-slate-100",children:e.jsx(Ke,{size:24})}),e.jsxs("div",{children:[e.jsx(es,{className:"text-xl font-black text-[#1e293b] leading-tight",children:A?.action||"Audit Event Details"}),e.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] mt-1",children:"Platform Operational Integrity Trail"})]})]})}),A&&e.jsxs("div",{className:"grid grid-cols-2 gap-6 bg-slate-50/50 p-6 rounded-2xl border border-slate-100",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Incident Severity"}),e.jsx("p",{className:"text-sm font-black text-[#1e293b]",children:A.severity})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Timestamp"}),e.jsx("p",{className:"text-sm font-black text-[#1e293b]",children:A.timestamp})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Component"}),e.jsx("p",{className:"text-sm font-black text-[#1e293b]",children:A.category})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"User Actor"}),e.jsx("p",{className:"text-sm font-black text-[#1e293b]",children:A?.user.name})]}),e.jsxs("div",{className:"col-span-2 space-y-1 mt-2",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Full Operation Details"}),e.jsx("p",{className:"text-sm font-medium text-[#1e293b] leading-relaxed bg-white p-4 rounded-xl border border-slate-100",children:A.details})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx(C,{onClick:()=>T(null),className:"bg-[#9956DE] hover:bg-[#8b5cf6] text-white rounded-xl px-8 font-black uppercase text-[11px] tracking-widest shadow-lg shadow-purple-100 transition-all",children:"Dismiss Review"})})]})]})})]})};function _e({className:s,...a}){return e.jsx(Vs,{"data-slot":"checkbox",className:je("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(Ws,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx(Xs,{className:"size-3.5"})})})}const tl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,sl=/[A-Z]/,al=/[a-z]/,ll=/\d/,rl=/[^A-Za-z0-9]/;function il(s){const a={};s.name.trim()||(a.name="Name is required.");const i=s.email.trim().toLowerCase();i?tl.test(i)||(a.email="Enter a valid email address."):a.email="Email is required.";const r=s.password;return r.length<8?a.password="Password must be at least 8 characters.":sl.test(r)?al.test(r)?ll.test(r)?rl.test(r)||(a.password="Password must include at least one special character."):a.password="Password must include at least one number.":a.password="Password must include at least one lowercase letter.":a.password="Password must include at least one uppercase letter.",s.confirmPassword?s.confirmPassword!==r&&(a.confirmPassword="Passwords do not match."):a.confirmPassword="Confirm password is required.",s.role.trim()||(a.role="Role is required."),s.status.trim()||(a.status="Status is required."),s.grade.trim()||(a.grade="Grade is required."),s.section.trim()||(a.section="Section is required."),s.role.trim().toLowerCase()==="student"&&!s.lrn.trim()&&(a.lrn="LRN is required for student accounts."),a}function nl(s){return Object.values(s).find(i=>!!i)??null}const Bt=(s="Student")=>({name:"",email:"",password:"",confirmPassword:"",role:s,status:"Active",department:s==="Teacher"?"Mathematics":s==="Admin"?"System":"",grade:"Grade 11",section:"Section A",lrn:""}),ol=["10","25","50","100"];function Ht(s,a){const i=s.trim();if(!(!i||i===a))return i}function qt(s){const a=String(s??"");return/[",\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}const cl=({createIntentRole:s=null,onCreateIntentConsumed:a})=>{const{userProfile:i}=Qe(),[r,n]=l.useState([]),[x,m]=l.useState(!0),[p,j]=l.useState(null),[w,f]=l.useState(!1),[c,g]=l.useState(!1),[v,y]=l.useState(null),[z,A]=l.useState(1),[T,U]=l.useState(25),[M,$]=l.useState(0),[B,te]=l.useState(1),[ne,G]=l.useState(!1),[Q,se]=l.useState(""),[I,ae]=l.useState("All Roles"),[V,F]=l.useState("All Status"),[h,k]=l.useState(new Set),[o,P]=l.useState(!1),[d,H]=l.useState(new Set),[Pe,Je]=l.useState({}),[Ce,ms]=l.useState("Student"),[et,ps]=l.useState("Active"),[Nl,yl]=l.useState("Grade 11"),[kl,Sl]=l.useState("Section A"),[hs,Ee]=l.useState(!1),[us,tt]=l.useState(!1),[Re,yt]=l.useState(!1),[oe,st]=l.useState(null),[L,kt]=l.useState(null),[at,Te]=l.useState({}),[lt,Me]=l.useState(!1),[Al,rt]=l.useState(!1),[b,le]=l.useState(Bt()),R=l.useMemo(()=>({search:Q.trim()||void 0,role:Ht(I,"All Roles"),status:Ht(V,"All Status")}),[Q,I,V]),ce=l.useCallback(()=>{k(new Set),P(!1),H(new Set)},[]),Le=l.useCallback(t=>o?!d.has(t):h.has(t),[o,d,h]),q=l.useMemo(()=>o?Math.max(M-d.size,0):h.size,[o,d,h,M]),St=l.useMemo(()=>r.length===0?!1:r.every(t=>Le(t.id)),[r,Le]),de=l.useMemo(()=>o?[]:Array.from(h).map(t=>Pe[t]).filter(t=>!!t),[o,h,Pe]);l.useMemo(()=>q===0?!1:o?!R.role||R.role.toLowerCase()==="student":de.length!==h.size?!1:de.every(t=>t.role==="Student"),[o,q,de,h.size,R.role]),l.useMemo(()=>q===0?!1:o?R.status?.toLowerCase()!=="active":de.length!==h.size?!1:de.some(t=>t.status!=="Active"),[o,q,de,h.size,R.status]),l.useMemo(()=>q===0?!1:o?R.status?.toLowerCase()!=="inactive":de.length!==h.size?!1:de.some(t=>t.status!=="Inactive"),[o,q,de,h.size,R.status]);const xe=l.useCallback(async t=>{m(!0),j(null);try{const u=await Va({page:t,pageSize:T,searchQuery:R.search,roleFilter:R.role,statusFilter:R.status});n(u.users),A(u.total===0?1:u.page),$(u.total),te(u.totalPages||1),G(u.hasNextPage),Je(E=>{const me={...E};return u.users.forEach(S=>{me[S.id]=S}),me})}catch(u){const E=u instanceof Error?u.message:"Failed to load users";j(E),D.error(E)}finally{m(!1)}},[T,R.search,R.role,R.status]);l.useEffect(()=>{xe(z)},[xe,z]);const it=l.useCallback((t="Student")=>{kt(null),Te({}),Me(!1),rt(!1),le(Bt(t)),Ee(!0)},[]);l.useEffect(()=>{s&&(it(s),a?.())},[s,it,a]);const At=l.useCallback(t=>{if(o){H(u=>{const E=new Set(u);return E.has(t)?E.delete(t):E.add(t),E});return}k(u=>{const E=new Set(u);return E.has(t)?E.delete(t):E.add(t),E})},[o]),Ct=l.useCallback(()=>{if(r.length===0)return;const t=r.map(u=>u.id);if(o){H(u=>{const E=new Set(u);return t.every(S=>!E.has(S))?t.forEach(S=>E.add(S)):t.forEach(S=>E.delete(S)),E});return}k(u=>{const E=new Set(u);return t.every(S=>E.has(S))?t.forEach(S=>E.delete(S)):t.forEach(S=>E.add(S)),E})},[r,o]),gs=l.useCallback(()=>{P(!0),k(new Set),H(new Set)},[]),Et=l.useCallback(t=>{if(!t.length){D.info("No rows were returned for export.");return}const u=Array.from(t.reduce((Ue,ct)=>(Object.keys(ct).forEach(As=>Ue.add(As)),Ue),new Set)),E=[u.map(qt).join(","),...t.map(Ue=>u.map(ct=>qt(Ue[ct])).join(","))].join(` +`),me=new Blob([E],{type:"text/csv;charset=utf-8;"}),S=URL.createObjectURL(me),ot=document.createElement("a");ot.href=S,ot.download=`admin-users-export-${Date.now()}.csv`,ot.click(),URL.revokeObjectURL(S)},[]),ue=l.useCallback(async(t,u)=>{const E=u.userIds,me={...R.search?{search:R.search}:{},...R.role?{role:R.role}:{},...R.status?{status:R.status}:{}};if(!E&&q===0){D.error("Select at least one user before applying a bulk action.");return}g(!0);try{const S=await Ka({action:t,...E?{userIds:E}:o?{userIds:[],excludeUserIds:Array.from(d),filters:me}:{userIds:Array.from(h)},...u.role?{role:u.role}:{},...u.status?{status:u.status}:{},...u.grade?{grade:u.grade}:{},...u.section?{section:u.section}:{},...u.exportFormat?{exportFormat:u.exportFormat}:{}});t==="export"&&Et(S.exportRows),S.summary.failed>0?D.warning(`Completed with partial failures. ${S.summary.succeeded} succeeded, ${S.summary.failed} failed, ${S.summary.skipped} skipped.`):D.success(`Action completed. ${S.summary.succeeded} user(s) updated.`),S.warnings.length>0&&D.info(S.warnings[0]),await xt(u.auditAction,"User",t==="delete"||t==="deactivate"?"Warning":"Info",`${u.auditDetail}; targeted=${S.summary.targeted}, succeeded=${S.summary.succeeded}, failed=${S.summary.failed}, skipped=${S.summary.skipped}`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),u.skipSelectionReset||ce(),await xe(z)}catch(S){D.error(S instanceof Error?S.message:"Bulk action failed")}finally{g(!1)}},[R.search,R.role,R.status,o,d,h,q,i?.name,i?.photo,ce,xe,z,Et]),nt=l.useCallback(t=>{st(t),tt(!0)},[]),bs=l.useCallback(async()=>{if(!(!oe||Re)){yt(!0);try{await ue(oe.action,{...oe.params||{},auditAction:oe.auditAction,auditDetail:oe.auditDetail}),tt(!1),st(null)}finally{yt(!1)}}},[oe,Re,ue]),Dt=t=>{kt(t),Te({}),Me(!1),rt(!1),le({name:t.name,email:t.email,password:"",confirmPassword:"",role:t.role,status:t.status,department:t.department,grade:t.grade||"Grade 11",section:t.section||"Section A",lrn:t.lrn||""}),Ee(!0)},fs=async()=>{if(!b.name.trim()||!b.email.trim()){D.error("Name and email are required");return}if(!L){const t=il({name:b.name,email:b.email,password:b.password,confirmPassword:b.confirmPassword,role:b.role,status:b.status,grade:b.grade,section:b.section,lrn:b.lrn}),u=nl(t);if(u){Te(t),D.error(u);return}}f(!0);try{if(L){const t={name:b.name,role:b.role,status:b.status,grade:b.grade,section:b.section,lrn:b.role==="Student"?b.lrn:void 0};b.role!=="Student"&&(t.department=b.department),await Wa(L.id,t),await xt("User Updated","User","Info",`Updated user: ${b.name} (${L.email})`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),D.success("User updated successfully")}else{const t=await Xa({email:b.email,name:b.name,password:b.password,confirmPassword:b.confirmPassword,role:b.role,status:b.status,grade:b.grade,section:b.section,lrn:b.role==="Student"?b.lrn:void 0});await xt("Created New User","User","Info",`Created new ${b.role.toLowerCase()} account: ${b.name} (${b.email}), emailSent=${t.emailSent}`,{name:i?.name||"Admin",role:"Admin",avatar:i?.photo||null}),t.emailSent?D.success("User created and welcome email sent"):(D.warning("User created, but welcome email failed to send"),t.emailError?.message&&D.error(t.emailError.message))}L?await xe(z):(ce(),A(1),await xe(1)),Ee(!1),Me(!1),rt(!1)}finally{f(!1)}},zt=(t,u)=>{nt({title:"Delete User?",message:`Delete user "${u}"? This cannot be undone.`,confirmText:"Delete",action:"delete",params:{userIds:[t]},auditAction:"User Deleted",auditDetail:`Deleted user account: ${u}`})},Pt=async t=>{if(v||c)return;if(t.status==="Active"){nt({title:"Deactivate User?",message:`Deactivate "${t.name}"? They will lose access until reactivated.`,confirmText:"Deactivate",action:"deactivate",params:{userIds:[t.id]},auditAction:"User Status Changed",auditDetail:`Deactivated user: ${t.email}`});return}y(t.id);try{await ue("activate",{userIds:[t.id],auditAction:"User Status Changed",auditDetail:`Activated user: ${t.email}`,skipSelectionReset:!0})}finally{y(null)}},js=async()=>{await ue("change_role",{role:Ce,auditAction:"Bulk Role Update",auditDetail:`Updated selected users to role ${Ce}`})},vs=async()=>{await ue("change_status",{status:et,auditAction:"Bulk Status Update",auditDetail:`Updated selected users to status ${et}`})},ws=async()=>{await ue("reset_password_email",{auditAction:"Bulk Password Reset",auditDetail:"Sent password reset emails to selected users"})},Ns=async()=>{await ue("export",{exportFormat:"csv",auditAction:"Bulk Export Users",auditDetail:"Exported selected users"})},ys=()=>{nt({title:"Delete Selected Users?",message:`Delete ${q} selected user(s)? This action cannot be undone.`,confirmText:"Delete Users",action:"delete",auditAction:"Bulk User Deletion",auditDetail:`Deleted ${q} selected users`})};r.filter(t=>t.status==="Active").length,r.filter(t=>t.role==="Admin").length,r.filter(t=>t.role==="Teacher").length,r.filter(t=>t.role==="Student").length;const ks=M===0?0:(z-1)*T+1,Ss=M===0?0:Math.min(z*T,M);return e.jsxs("div",{className:"flex flex-col animate-in fade-in duration-500",children:[e.jsx("div",{className:"space-y-8 pt-6 xl:pt-8 pb-6 px-1",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-4",children:x&&r.length===0?Array.from({length:5}).map((t,u)=>e.jsxs("div",{className:"bg-white p-5 rounded-[28px] border border-slate-200/60 shadow-sm shadow-slate-200/50 animate-pulse",children:[e.jsx("div",{className:"h-4 w-20 bg-slate-100 rounded-full mb-3"}),e.jsx("div",{className:"h-8 w-12 bg-slate-100 rounded-lg"})]},`stats-skeleton-${u}`)):[{label:"Total Users",value:M,icon:ye,bg:"bg-[#4f46e5]",shadow:"shadow-indigo-500/20"},{label:"Active Today",value:r.filter(t=>t.status==="Active").length,icon:Ve,bg:"bg-[#10b981]",shadow:"shadow-emerald-500/20"},{label:"Admins",value:r.filter(t=>t.role==="Admin").length,icon:pt,bg:"bg-[#0ea5e9]",shadow:"shadow-sky-500/20"},{label:"Teachers",value:r.filter(t=>t.role==="Teacher").length,icon:ze,bg:"bg-[#8b5cf6]",shadow:"shadow-purple-500/20"},{label:"Students",value:r.filter(t=>t.role==="Student").length,icon:Ua,bg:"bg-[#3b82f6]",shadow:"shadow-blue-500/20"}].map((t,u)=>e.jsxs("div",{className:`relative overflow-hidden ${t.bg} ${t.shadow} p-5 rounded-[28px] text-white flex flex-col gap-3 group hover:scale-[1.02] transition-all duration-300 shadow-lg`,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-700 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-700 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] opacity-80",children:t.label}),e.jsx("div",{className:"bg-white/20 p-2 rounded-xl backdrop-blur-sm group-hover:bg-white/30 transition-colors",children:e.jsx(t.icon,{size:14})})]}),e.jsx("h3",{className:"relative z-10 text-3xl font-display font-black leading-none tracking-tight",children:t.value})]},u))})}),e.jsx("div",{className:"sticky top-0 z-40 -mx-[24px] xl:-mx-[32px] px-[24px] xl:px-[32px] pt-4 pb-4 bg-[#f8fafc] backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col xl:flex-row items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 w-full group",children:[e.jsx(vt,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 group-focus-within:text-indigo-500 transition-colors",size:16}),e.jsx(Z,{placeholder:"Search by name, email, or LRN...",className:"pl-11 h-12 bg-white border-slate-200/60 rounded-2xl focus-visible:ring-indigo-500/20 focus-visible:border-indigo-500 transition-all text-sm font-medium shadow-md shadow-slate-200/40",value:Q,onChange:t=>{se(t.target.value),A(1),ce()}})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full xl:w-auto",children:[e.jsxs(W,{value:I,onValueChange:t=>{ae(t),A(1),ce()},children:[e.jsx(X,{className:"w-[180px] h-12 rounded-xl bg-white border border-slate-200 hover:border-[#9956DE] transition-all focus:ring-2 focus:ring-[#9956DE]/10 text-[10px] font-black uppercase tracking-widest text-slate-900 shadow-md shadow-slate-200/40 px-4",children:e.jsx("span",{className:"truncate",children:I==="All Roles"?"All Roles":I==="Admin"?"Administrator":I==="Teacher"?"Educator":I})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"All Roles",className:"font-bold uppercase tracking-widest text-[10px]",children:"All Roles"}),e.jsx(N,{value:"Admin",className:"font-bold uppercase tracking-widest text-[10px]",children:"Administrator"}),e.jsx(N,{value:"Teacher",className:"font-bold uppercase tracking-widest text-[10px]",children:"Educator"}),e.jsx(N,{value:"Student",className:"font-bold uppercase tracking-widest text-[10px]",children:"Student"})]})]}),e.jsxs(W,{value:V,onValueChange:t=>{F(t),A(1),ce()},children:[e.jsx(X,{className:"w-[180px] h-12 rounded-xl bg-white border border-slate-200 hover:border-[#9956DE] transition-all focus:ring-2 focus:ring-[#9956DE]/10 text-[10px] font-black uppercase tracking-widest text-slate-900 shadow-md shadow-slate-200/40 px-4",children:e.jsx("span",{className:"truncate",children:V==="All Status"?"All Statuses":V})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"All Status",className:"font-bold uppercase tracking-widest text-[10px]",children:"All Statuses"}),e.jsx(N,{value:"Active",className:"font-bold uppercase tracking-widest text-[10px]",children:"Active"}),e.jsx(N,{value:"Inactive",className:"font-bold uppercase tracking-widest text-[10px]",children:"Inactive"})]})]})]}),e.jsx(C,{variant:"outline",size:"icon",onClick:()=>{se(""),ae("All Roles"),F("All Status"),A(1),ce()},disabled:!Q&&I==="All Roles"&&V==="All Status",className:"h-12 w-12 rounded-xl border-slate-200 text-[#9956DE] hover:bg-purple-50 disabled:opacity-30 disabled:cursor-not-allowed transition-all shadow-md shadow-slate-200/40",title:"Reset Filters",children:e.jsx(is,{size:18})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-12 w-12 rounded-xl border-slate-200 text-slate-500 hover:bg-slate-50 transition-all shadow-md shadow-slate-200/40",onClick:()=>xe(z),disabled:x||c,children:e.jsx(ke,{size:18,className:x?"animate-spin":""})}),e.jsxs(C,{className:"h-12 gap-2 bg-[#9956DE] hover:bg-[#8b5cf6] text-white rounded-xl shadow-lg shadow-purple-200/50 transition-all px-6 font-black uppercase text-[11px] tracking-widest",onClick:()=>it(),disabled:c,children:[e.jsx(Ps,{size:18}),"Add User"]})]})}),q>0&&e.jsxs("div",{className:"mt-3 bg-indigo-900 rounded-2xl p-3 flex flex-col xl:flex-row items-center gap-4 animate-in slide-in-from-top-2 duration-300",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 border-r border-white/10 pr-6",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-indigo-500/30 flex items-center justify-center text-white font-black text-xs",children:q}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black text-indigo-300 uppercase tracking-widest leading-none",children:"Selected"}),e.jsx("p",{className:"text-[9px] text-white/60 font-medium mt-1",children:o?"All matching users":`${q} users chosen`})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-white/5 p-1 rounded-xl",children:[e.jsxs(W,{value:Ce,onValueChange:t=>ms(t),children:[e.jsx(X,{className:"h-8 bg-transparent border-none text-white text-[10px] font-bold min-w-[90px] focus:ring-0",children:e.jsx(we,{})}),e.jsxs(K,{className:"rounded-xl",children:[e.jsx(N,{value:"Student",children:"Student"}),e.jsx(N,{value:"Teacher",children:"Teacher"}),e.jsx(N,{value:"Admin",children:"Admin"})]})]}),e.jsx(C,{size:"sm",className:"h-8 bg-indigo-600 hover:bg-indigo-500 text-[10px] font-black rounded-lg",onClick:()=>void js(),children:"Apply Role"})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-white/5 p-1 rounded-xl",children:[e.jsxs(W,{value:et,onValueChange:t=>ps(t),children:[e.jsx(X,{className:"h-8 bg-transparent border-none text-white text-[10px] font-bold min-w-[90px] focus:ring-0",children:e.jsx(we,{})}),e.jsxs(K,{className:"rounded-xl",children:[e.jsx(N,{value:"Active",children:"Active"}),e.jsx(N,{value:"Inactive",children:"Inactive"})]})]}),e.jsx(C,{size:"sm",className:"h-8 bg-indigo-600 hover:bg-indigo-500 text-[10px] font-black rounded-lg",onClick:()=>void vs(),children:"Set Status"})]}),e.jsx("div",{className:"h-6 w-[1px] bg-white/10 mx-1"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{size:"sm",variant:"ghost",className:"h-9 text-white hover:bg-white/10 text-[10px] font-black uppercase tracking-widest gap-2",onClick:()=>void ws(),children:[e.jsx(Ks,{size:14})," Reset Pass"]}),e.jsxs(C,{size:"sm",variant:"ghost",className:"h-9 text-white hover:bg-white/10 text-[10px] font-black uppercase tracking-widest gap-2",onClick:()=>void Ns(),children:[e.jsx(wt,{size:14})," Export"]}),e.jsxs(C,{size:"sm",variant:"ghost",className:"h-9 text-rose-400 hover:bg-rose-500/10 hover:text-rose-300 text-[10px] font-black uppercase tracking-widest gap-2",onClick:ys,children:[e.jsx(Ge,{size:14})," Delete"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 border-l border-white/10",children:[!o&&qxe(z),disabled:x||c,children:"Retry"})]}):null,e.jsxs("div",{className:"bg-white rounded-[32px] border border-slate-200/60 shadow-sm shadow-slate-200/50 relative",children:[x&&r.length>0&&e.jsx("div",{className:"absolute inset-0 bg-white/40 backdrop-blur-[1px] z-20 flex items-center justify-center",children:e.jsx(Y,{className:"animate-spin text-indigo-500",size:32})}),e.jsxs("div",{className:"md:hidden divide-y divide-slate-100",children:[e.jsxs("div",{className:"px-6 py-4 bg-slate-50/50 border-b border-slate-100 flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center gap-3 text-[10px] font-black text-slate-400 uppercase tracking-widest cursor-pointer",children:[e.jsx(_e,{checked:St,onCheckedChange:Ct,className:"rounded-md border-slate-300"}),"Select Page"]}),e.jsxs("span",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:["Page ",z," of ",B]})]}),x&&r.length===0?e.jsx("div",{className:"px-6 py-12 text-center text-slate-400 font-medium",children:"Loading users..."}):r.length>0?r.map(t=>(t.id,e.jsxs("div",{className:"p-5 space-y-4 group hover:bg-slate-50/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_e,{checked:Le(t.id),onCheckedChange:()=>At(t.id),className:"rounded-md border-slate-300"}),e.jsxs("div",{className:"relative",children:[e.jsxs(Tt,{className:"h-12 w-12 rounded-2xl border-2 border-white shadow-sm",children:[e.jsx(Mt,{src:t.photo,className:"object-cover"}),e.jsx(Lt,{className:"bg-indigo-50 text-indigo-600 font-bold",children:t.name.charAt(0)})]}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-4 h-4 rounded-full border-2 border-white shadow-sm ${t.status==="Active"?"bg-emerald-500":"bg-slate-300"}`})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-black text-[#1e293b] truncate text-sm",children:t.name}),e.jsx("p",{className:"text-[11px] font-medium text-slate-400 truncate mt-0.5",children:t.email})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:`text-[9px] font-black uppercase tracking-widest px-2 py-1 rounded-lg ${t.role==="Admin"?"bg-sky-50 text-sky-600":t.role==="Teacher"?"bg-purple-50 text-purple-600":"bg-blue-50 text-blue-600"}`,children:t.role}),e.jsxs("span",{className:"text-[9px] font-black uppercase tracking-widest px-2 py-1 rounded-lg bg-slate-50 text-slate-500",children:[t.grade," • ",t.section||t.department]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 h-9 rounded-xl border-slate-200 text-slate-600 font-bold text-xs gap-2",onClick:()=>Dt(t),children:[e.jsx(Ie,{size:14})," Edit"]}),e.jsxs(C,{variant:"outline",size:"sm",className:`flex-1 h-9 rounded-xl border-slate-200 font-bold text-xs gap-2 ${t.status==="Active"?"text-slate-600":"text-emerald-600"}`,onClick:()=>Pt(t),disabled:v===t.id||c,children:[v===t.id?e.jsx(Y,{size:14,className:"animate-spin"}):t.status==="Active"?e.jsx(Ot,{size:14}):e.jsx(Ve,{size:14}),t.status==="Active"?"Ban":"Active"]}),e.jsx(C,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl border-slate-200 text-rose-500 hover:bg-rose-50 hover:border-rose-100",onClick:()=>zt(t.id,t.name),disabled:c,children:e.jsx(Ge,{size:14})})]})]},`mobile-${t.id}`))):e.jsxs("div",{className:"px-6 py-20 text-center space-y-4",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mx-auto",children:e.jsx(ye,{size:32,className:"text-slate-300"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-black text-slate-600 uppercase tracking-widest text-sm",children:"No Users Found"}),e.jsx("p",{className:"text-xs text-slate-400 font-medium max-w-[200px] mx-auto leading-relaxed",children:"We couldn't find any users matching your current filters. Try adjusting your search."})]}),e.jsx(C,{variant:"outline",size:"sm",className:"rounded-xl border-slate-200 text-indigo-600 font-bold",onClick:()=>{se(""),ae("All Roles"),F("All Status")},children:"Clear Filters"})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"sticky top-[80px] z-30 bg-[#f8fafc] backdrop-blur-sm shadow-[0_-12px_0_0_#f8fafc]",children:e.jsxs("tr",{className:"border-b border-[#8b5cf6]",children:[e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 w-[60px] rounded-tl-[20px]",children:e.jsx(_e,{checked:St,onCheckedChange:Ct,className:"rounded-md border-white/50 data-[state=checked]:bg-white data-[state=checked]:text-[#9956DE]"})}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-[11px] font-black text-white uppercase tracking-widest",children:"User Profile"}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-[11px] font-black text-white uppercase tracking-widest",children:"Role & Access"}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-[11px] font-black text-white uppercase tracking-widest",children:"Status"}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-[11px] font-black text-white uppercase tracking-widest",children:"Placement"}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-[11px] font-black text-white uppercase tracking-widest",children:"Activity"}),e.jsx("th",{className:"bg-[#9956DE] px-6 py-4 text-right text-[11px] font-black text-white uppercase tracking-widest rounded-tr-[20px]",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:x&&r.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-6 py-20 text-center",children:[e.jsx(Y,{className:"animate-spin text-indigo-200 mx-auto",size:40}),e.jsx("p",{className:"mt-4 text-[10px] font-black text-slate-300 uppercase tracking-widest",children:"Loading Records..."})]})}):r.length>0?r.map(t=>{const u=v===t.id;return e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-all group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx(_e,{checked:Le(t.id),onCheckedChange:()=>At(t.id),className:"rounded-md border-slate-300 group-hover:border-indigo-400 transition-colors"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"relative shrink-0",children:e.jsxs(Tt,{className:"h-11 w-11 rounded-2xl border-2 border-white shadow-sm ring-1 ring-slate-100",children:[e.jsx(Mt,{src:t.photo,className:"object-cover"}),e.jsx(Lt,{className:"bg-indigo-50 text-indigo-600 font-bold text-sm",children:t.name.charAt(0)})]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-black text-[#1e293b] truncate text-sm leading-tight group-hover:text-indigo-600 transition-colors",children:t.name}),e.jsx("p",{className:"text-[11px] font-medium text-slate-400 truncate mt-0.5",children:t.email})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:` + text-[9px] font-black px-2 py-0.5 rounded-lg uppercase tracking-wider + ${t.role==="Admin"?"bg-sky-50 text-sky-600":""} + ${t.role==="Teacher"?"bg-purple-50 text-purple-600":""} + ${t.role==="Student"?"bg-blue-50 text-blue-600":""} + `,children:t.role})}),t.lrn&&e.jsxs("p",{className:"text-[9px] font-black text-slate-300 uppercase tracking-tighter ml-0.5",children:["LRN: ",t.lrn]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:` + inline-flex items-center gap-1.5 px-3 py-1.5 rounded-2xl text-[10px] font-black uppercase tracking-wider border + ${t.status==="Active"?"bg-emerald-50 text-emerald-600 border-emerald-100":"bg-slate-50 text-slate-400 border-slate-100"} + `,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t.status==="Active"?"bg-emerald-500 animate-pulse":"bg-slate-300"}`}),t.status]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-xs font-black text-slate-600",children:t.grade||"N/A"}),e.jsx("p",{className:"text-[10px] font-medium text-slate-400",children:t.role==="Student"?t.classSection||t.section||"Unassigned":t.department})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-black text-slate-600 uppercase tracking-tighter",children:t.lastLogin?"Recent Activity":"Inactive Account"}),e.jsx("p",{className:"text-[10px] font-medium text-slate-400",children:t.lastLogin||"No login history"})]})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>Dt(t),className:"h-9 w-9 rounded-xl text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-all",title:"Edit User",children:e.jsx(Ie,{size:16})}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>Pt(t),disabled:u||c,className:`h-9 w-9 rounded-xl transition-all ${t.status==="Active"?"text-slate-400 hover:text-amber-600 hover:bg-amber-50":"text-slate-400 hover:text-emerald-600 hover:bg-emerald-50"}`,title:t.status==="Active"?"Deactivate":"Activate",children:u?e.jsx(Y,{size:16,className:"animate-spin"}):t.status==="Active"?e.jsx(Ot,{size:16}):e.jsx(Ve,{size:16})}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>zt(t.id,t.name),disabled:c,className:"h-9 w-9 rounded-xl text-slate-400 hover:text-rose-600 hover:bg-rose-50 transition-all",title:"Delete User",children:e.jsx(Ge,{size:16})})]})})]},t.id)}):e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-32 text-center",children:e.jsxs("div",{className:"max-w-xs mx-auto space-y-6",children:[e.jsx("div",{className:"w-24 h-24 bg-slate-50 rounded-[32px] flex items-center justify-center mx-auto shadow-sm shadow-slate-100 group-hover:scale-110 transition-transform duration-500",children:e.jsx(ye,{size:40,className:"text-slate-200"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-black text-slate-600 uppercase tracking-widest",children:"No matching users"}),e.jsx("p",{className:"text-xs text-slate-400 font-medium leading-relaxed",children:"We couldn't find any results for your current query. Try broadening your search or clearing filters."})]}),e.jsx(C,{variant:"outline",size:"sm",className:"rounded-xl border-slate-200 text-indigo-600 font-bold px-6 h-10 hover:bg-indigo-50",onClick:()=>{se(""),ae("All Roles"),F("All Status")},children:"Reset Filters"})]})})})})]})})]}),e.jsxs("div",{className:"sticky bottom-0 z-50 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 px-12 py-3 bg-white border-t-2 border-slate-100 shadow-[0_-8px_30px_rgba(0,0,0,0.08)] -mx-[24px] xl:-mx-[32px] w-[calc(100%+48px)] xl:w-[calc(100%+64px)]",children:[e.jsxs("p",{className:"text-[12px] font-black text-slate-500 uppercase tracking-widest flex items-center gap-4",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-[#9956DE] animate-pulse shadow-[0_0_12px_rgba(153,86,222,0.6)]"}),"Showing ",e.jsxs("span",{className:"text-slate-900 font-black border-b-2 border-[#9956DE]/40 pb-0.5",children:[ks,"–",Ss]}),e.jsx("span",{className:"text-slate-300 font-bold mx-1",children:"/"}),e.jsx("span",{className:"text-slate-900 font-black border-b-2 border-[#9956DE]/40 pb-0.5",children:M}),e.jsx("span",{className:"text-slate-400 ml-1",children:"Total System Records"})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(W,{value:String(T),onValueChange:t=>{const u=Number(t);Number.isNaN(u)||(U(u),A(1),ce())},children:[e.jsx(X,{className:"h-10 w-[140px] bg-white border border-slate-300 text-[11px] font-black uppercase tracking-wider text-slate-900 rounded-xl hover:border-[#9956DE] transition-all px-4 shadow-sm",children:e.jsxs("span",{className:"truncate",children:[T," / Page"]})}),e.jsx(K,{className:"rounded-xl border-slate-200",children:ol.map(t=>e.jsxs(N,{value:t,className:"font-bold",children:[t," / Page"]},t))})]}),e.jsxs("div",{className:"flex items-center gap-2 bg-slate-50 p-1.5 rounded-2xl border border-slate-200 shadow-inner",children:[e.jsx(C,{variant:"outline",size:"sm",className:"h-9 w-9 p-0 rounded-xl bg-[#9956DE] border-none text-white hover:bg-[#8b5cf6] hover:scale-105 active:scale-95 disabled:opacity-30 transition-all shadow-lg shadow-purple-200/60",disabled:z<=1||x||c,onClick:()=>A(t=>Math.max(t-1,1)),children:e.jsx(as,{size:18,strokeWidth:3})}),e.jsx("div",{className:"px-5 py-2 bg-white rounded-xl shadow-sm border border-slate-200 flex items-center justify-center min-w-[130px]",children:e.jsxs("span",{className:"text-[11px] font-black text-slate-900 uppercase tracking-widest",children:["Page ",e.jsx("span",{className:"text-[#9956DE] mx-1",children:z}),e.jsx("span",{className:"text-slate-300 mx-1",children:"OF"}),e.jsx("span",{className:"text-slate-500",children:Math.max(B,1)})]})}),e.jsx(C,{variant:"outline",size:"sm",className:"h-9 w-9 p-0 rounded-xl bg-[#9956DE] border-none text-white hover:bg-[#8b5cf6] hover:scale-105 active:scale-95 disabled:opacity-30 transition-all shadow-lg shadow-purple-200/60",disabled:!ne||x||c||z>=B,onClick:()=>A(t=>Math.min(t+1,B||1)),children:e.jsx(Nt,{size:18,strokeWidth:3})})]})]})]}),e.jsx(Zt,{open:hs,onOpenChange:t=>!w&&Ee(t),children:e.jsxs(Yt,{className:"sm:max-w-[850px] rounded-[32px] border-none shadow-2xl p-0 overflow-hidden [&>button:last-child]:hidden",children:[e.jsx("div",{className:`h-2 w-full bg-gradient-to-r ${L?"from-indigo-600 to-purple-600":"from-emerald-600 to-indigo-600"}`}),e.jsxs("div",{className:"p-8 space-y-8",children:[e.jsx(Jt,{className:"text-left",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:`w-14 h-14 rounded-2xl flex items-center justify-center shadow-lg transition-transform duration-500 hover:rotate-3 ${L?"bg-indigo-100 text-indigo-700 shadow-indigo-200/50":"bg-emerald-100 text-emerald-700 shadow-emerald-200/50"}`,children:L?e.jsx(Ie,{size:28,className:"drop-shadow-sm"}):e.jsx(It,{size:28,className:"drop-shadow-sm"})}),e.jsxs("div",{children:[e.jsx(es,{className:"text-2xl font-display font-black text-[#1e293b] leading-tight",children:L?"Edit User Access":"Onboard New User"}),e.jsxs("p",{className:"text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-500 animate-pulse"}),L?"User Identity Management":"System Enrollment Pipeline"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-10 gap-y-6",children:[e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-[11px] font-black text-indigo-600 uppercase tracking-[0.15em] pb-1 border-b border-indigo-50",children:"Identity Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Full Name"}),e.jsxs("div",{className:"relative group",children:[e.jsx(Z,{value:b.name,onChange:t=>{le({...b,name:t.target.value}),at.name&&Te(u=>({...u,name:void 0}))},placeholder:"Enter full name",className:`h-12 rounded-xl bg-slate-50 border-slate-200 focus-visible:ring-indigo-500/20 focus-visible:border-indigo-500 transition-all font-bold text-[#1e293b] ${at.name?"border-rose-300 bg-rose-50/20":""}`}),at.name&&e.jsx(fe,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-rose-500"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Email Address"}),e.jsx(Z,{type:"email",value:b.email,onChange:t=>{L||le({...b,email:t.target.value})},readOnly:!!L,placeholder:"name@example.com",className:`h-12 rounded-xl bg-slate-50 border-slate-200 focus-visible:ring-indigo-500/20 focus-visible:border-indigo-500 transition-all font-bold text-[#1e293b] ${L?"opacity-60 grayscale bg-slate-100":""}`})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Access Role"}),e.jsxs(W,{value:b.role,onValueChange:t=>{le({...b,role:t,lrn:t==="Student"?b.lrn:""})},children:[e.jsx(X,{className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-black text-[#1e293b]",children:e.jsx(we,{placeholder:"Role"})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"Student",className:"font-bold",children:"Student"}),e.jsx(N,{value:"Teacher",className:"font-bold",children:"Teacher"}),e.jsx(N,{value:"Admin",className:"font-bold",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Status"}),e.jsxs(W,{value:b.status,onValueChange:t=>le({...b,status:t}),children:[e.jsx(X,{className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-black text-[#1e293b]",children:e.jsx(we,{placeholder:"Status"})}),e.jsxs(K,{className:"rounded-xl border-slate-200",children:[e.jsx(N,{value:"Active",className:"font-bold",children:"Active"}),e.jsx(N,{value:"Inactive",className:"font-bold",children:"Inactive"})]})]})]})]})]})}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-[11px] font-black text-indigo-600 uppercase tracking-[0.15em] pb-1 border-b border-indigo-50",children:"Contextual Assignment"}),b.role==="Student"?e.jsxs("div",{className:"space-y-4 animate-in fade-in slide-in-from-right-4 duration-500",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Grade Level"}),e.jsx(Z,{value:b.grade,onChange:t=>le({...b,grade:t.target.value}),placeholder:"Grade 11",className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-bold"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Section"}),e.jsx(Z,{value:b.section,onChange:t=>le({...b,section:t.target.value}),placeholder:"STEM A",className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-bold"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"LRN (Learner Reference Number)"}),e.jsx(Z,{value:b.lrn,onChange:t=>le({...b,lrn:t.target.value}),placeholder:"12-digit number",className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-black tracking-widest"})]})]}):e.jsxs("div",{className:"space-y-1.5 animate-in fade-in slide-in-from-right-4 duration-500",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Department / Office"}),e.jsx(Z,{value:b.department,onChange:t=>le({...b,department:t.target.value}),placeholder:"e.g. Mathematics Department",className:"h-12 rounded-xl bg-slate-50 border-slate-200 font-bold"})]}),!L&&e.jsxs("div",{className:"space-y-1.5 pt-2",children:[e.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1",children:"Initial Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Z,{type:lt?"text":"password",value:b.password,onChange:t=>le({...b,password:t.target.value}),className:"h-12 rounded-xl bg-slate-50 border-slate-200 pr-10 font-black tracking-widest"}),e.jsx("button",{type:"button",onClick:()=>Me(!lt),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",children:lt?e.jsx(ss,{size:16}):e.jsx(Gs,{size:16})})]})]})]})})]}),e.jsxs(Os,{className:"grid grid-cols-2 gap-3 pt-6 border-t border-slate-100",children:[e.jsx(C,{variant:"outline",className:`h-12 rounded-xl font-black uppercase tracking-widest text-[10px] transition-all border-2 ${L?"border-indigo-600/50 text-indigo-600 hover:bg-indigo-50":"border-emerald-600/50 text-emerald-600 hover:bg-emerald-50"}`,onClick:()=>Ee(!1),disabled:w,children:"Cancel"}),e.jsx(C,{onClick:fs,className:`h-12 rounded-xl font-black uppercase tracking-widest gap-3 text-[10px] shadow-lg transition-all active:scale-95 ${L?"bg-indigo-600 hover:bg-indigo-700 shadow-indigo-500/25":"bg-emerald-600 hover:bg-emerald-700 shadow-emerald-500/25"}`,disabled:w,children:w?e.jsx(Y,{size:16,className:"animate-spin"}):L?e.jsxs(e.Fragment,{children:[e.jsx(ls,{size:16})," Save Changes"]}):e.jsxs(e.Fragment,{children:[e.jsx(It,{size:16})," Onboard User"]})})]})]})]})}),e.jsx(Vt,{isOpen:us,onClose:()=>{Re||(tt(!1),st(null))},onConfirm:bs,title:oe?.title||"Confirm Action",message:oe?.message||"Proceed with this action?",confirmText:Re?"Processing...":oe?.confirmText||"Confirm",cancelText:"Cancel",type:"danger",icon:"delete"})]})},De=({icon:s,title:a,subtitle:i})=>e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-slate-50 border border-slate-100 flex items-center justify-center",children:s}),e.jsx("p",{className:"text-[11px] font-black text-slate-500 uppercase tracking-widest",children:a}),i&&e.jsx("p",{className:"text-[10px] text-slate-400 font-medium max-w-xs leading-relaxed",children:i})]}),dl=()=>{const[s,a]=l.useState("30d"),[i,r]=l.useState(null),[n,x]=l.useState(!0),m=()=>{x(!0),Ya().then(r).catch(console.error).finally(()=>x(!1))};l.useEffect(()=>{m()},[]);const p={"7d":"7 Days","30d":"30 Days","90d":"90 Days","12m":"12 Months"},j=[{label:"Total Active Users",value:n?null:(i?.totalActiveUsers??0).toLocaleString(),icon:ye,bg:"bg-[#4f46e5]",shadow:"shadow-indigo-500/20"},{label:"Completion Rate",value:"N/A",icon:Qt,bg:"bg-[#10b981]",shadow:"shadow-emerald-500/20"},{label:"Session Duration",value:"N/A",icon:Ze,bg:"bg-[#8b5cf6]",shadow:"shadow-purple-500/20"},{label:"At-Risk Students",value:n?null:(i?.atRiskStudents??0).toString(),icon:Ae,bg:"bg-[#f43f5e]",shadow:"shadow-rose-500/20"}],w=[{label:"Achievements Unlocked",icon:Ut,color:"text-rose-600",bg:"bg-rose-50",border:"border-rose-100",value:n?null:(i?.achievementsUnlocked??0).toLocaleString()},{label:"XP Earned (Platform)",icon:he,color:"text-violet-600",bg:"bg-violet-50",border:"border-violet-100",value:n?null:(i?.totalXPEarned??0)>=1e6?`${((i?.totalXPEarned??0)/1e6).toFixed(1)}M`:(i?.totalXPEarned??0)>=1e3?`${Math.round((i?.totalXPEarned??0)/1e3)}K`:(i?.totalXPEarned??0).toLocaleString()},{label:"Active Streaks",icon:Rs,color:"text-orange-600",bg:"bg-orange-50",border:"border-orange-100",value:n?null:(i?.activeStreaks??0).toLocaleString()},{label:"AI Tutor Sessions",icon:Ts,color:"text-sky-600",bg:"bg-sky-50",border:"border-sky-100",value:n?null:(i?.aiTutorSessions??0).toLocaleString()}];return e.jsxs("div",{className:"space-y-6 pt-6 xl:pt-8 pb-10 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-1.5 h-6 bg-[#9956DE] rounded-full"}),e.jsx("p",{className:"text-[11px] font-black text-slate-400 uppercase tracking-[0.2em]",children:"Platform Analytics"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center bg-white rounded-xl p-1 shadow-sm border border-slate-200/60",children:Object.entries(p).map(([f,c])=>e.jsx("button",{onClick:()=>a(f),disabled:!0,title:"Range selection unavailable",className:`px-3 py-1.5 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${s===f?"bg-[#9956DE] text-white shadow-sm":"text-slate-500 hover:bg-slate-50"} opacity-50 cursor-not-allowed`,children:c},f))}),e.jsx("button",{onClick:m,disabled:n,title:"Refresh data",className:"p-2.5 rounded-xl bg-white border border-slate-200 text-slate-400 hover:text-[#9956DE] shadow-sm transition-all active:scale-95",children:e.jsx(ke,{size:14,className:n?"animate-spin":""})}),e.jsxs(C,{variant:"outline",disabled:!0,title:"Export unavailable",className:"h-9 px-4 gap-2 rounded-xl border-slate-200 text-[10px] font-black uppercase tracking-widest text-slate-400 opacity-50 cursor-not-allowed shadow-sm",children:[e.jsx(wt,{size:14}),"Export"]})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:j.map((f,c)=>{const g=f.icon;return e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3,delay:c*.05},className:`relative overflow-hidden ${f.bg} ${f.shadow} p-5 rounded-[28px] text-white flex flex-col gap-3 group hover:scale-[1.02] transition-all duration-300 shadow-lg`,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-700 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-700 delay-75 ease-out"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] opacity-80",children:f.label}),e.jsx("div",{className:"bg-white/20 p-2 rounded-xl backdrop-blur-sm group-hover:bg-white/30 transition-colors",children:e.jsx(g,{size:14})})]}),n?e.jsx("div",{className:"relative z-10 flex items-center gap-2",children:e.jsx(Y,{size:18,className:"animate-spin opacity-60"})}):e.jsx("h3",{className:"relative z-10 text-3xl font-display font-black leading-none tracking-tight",children:f.value})]},f.label)})}),!n&&!i?.totalActiveUsers&&e.jsxs(_.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"flex items-center gap-3 bg-amber-50 border border-amber-100 rounded-2xl px-5 py-3",children:[e.jsx(ge,{size:16,className:"text-amber-600 shrink-0"}),e.jsx("p",{className:"text-[10px] font-black text-amber-700 uppercase tracking-widest",children:"Limited data — KPIs populate as platform usage grows. Charts require time-series data."})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-5",children:[e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.1},className:"xl:col-span-8 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-50 text-indigo-600 flex items-center justify-center border border-indigo-100",children:e.jsx(jt,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Performance Trends"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Students vs. Teacher Targets"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-indigo-400"}),e.jsx("span",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Students"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-purple-400"}),e.jsx("span",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Targets"})]})]})]}),e.jsx(De,{icon:e.jsx(rs,{size:22,className:"text-slate-300"}),title:"No performance data yet",subtitle:"Trend charts will generate as students complete quizzes and assessments."})]}),e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.15},className:"xl:col-span-4 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-purple-50 text-purple-600 flex items-center justify-center border border-purple-100",children:e.jsx(ja,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Grade Distribution"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Current Term"})]})]}),e.jsx(De,{icon:e.jsx(ge,{size:22,className:"text-slate-300"}),title:"No grade data",subtitle:"Import quiz results to see grade breakdowns."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-5",children:[e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.2},className:"xl:col-span-7 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-sky-50 text-sky-600 flex items-center justify-center border border-sky-100",children:e.jsx(Se,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Subject Engagement"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Enrollment & Completion"})]})]}),e.jsx("div",{className:"rounded-2xl border border-slate-200/60 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/80",children:[e.jsx("th",{className:"text-left text-[10px] font-black text-slate-400 uppercase tracking-widest px-5 py-3",children:"Subject"}),e.jsx("th",{className:"text-right text-[10px] font-black text-slate-400 uppercase tracking-widest px-5 py-3",children:"Enrolled"}),e.jsx("th",{className:"text-right text-[10px] font-black text-slate-400 uppercase tracking-widest px-5 py-3",children:"Completion"}),e.jsx("th",{className:"text-right text-[10px] font-black text-slate-400 uppercase tracking-widest px-5 py-3",children:"Avg. Score"}),e.jsx("th",{className:"text-left text-[10px] font-black text-slate-400 uppercase tracking-widest px-5 py-3 w-32",children:"Progress"})]})}),e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8",children:e.jsx(De,{icon:e.jsx(ge,{size:20,className:"text-slate-300"}),title:"No subject data available",subtitle:"Import class enrollment records to view engagement."})})})})]})})]}),e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.25},className:"xl:col-span-5 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-orange-50 text-orange-600 flex items-center justify-center border border-orange-100",children:e.jsx(Ms,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Weekly Activity"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Sessions Per Day"})]})]}),e.jsx(De,{icon:e.jsx(Ae,{size:22,className:"text-slate-300"}),title:"No session activity yet",subtitle:"Student logins and session data will appear here."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-5",children:[e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.3},className:"xl:col-span-5 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-rose-50 text-rose-600 flex items-center justify-center border border-rose-100",children:e.jsx(Ut,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Gamification Overview"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Engagement Metrics"})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:w.map(f=>{const c=f.icon;return e.jsxs("div",{className:`${f.bg} border ${f.border} rounded-2xl p-4 group hover:scale-[1.02] transition-all duration-200`,children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx(c,{size:18,className:f.color})}),n?e.jsx("div",{className:"w-12 h-5 bg-white/60 rounded-lg mt-1 mb-1 animate-pulse"}):e.jsx("p",{className:"text-xl font-black text-[#1e293b] leading-none",children:f.value}),e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest mt-2",children:f.label})]},f.label)})})]}),e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.35},className:"xl:col-span-7 bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/40",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center border border-emerald-100",children:e.jsx(ze,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-black text-[#1e293b] tracking-tight",children:"Top Performing Classes"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:"Ranked by Average Score"})]})]}),e.jsx(De,{icon:e.jsx(ge,{size:22,className:"text-slate-300"}),title:"No class data yet",subtitle:"Import class and student records to see top performers."})]})]})]})};function xl(s){return!s||s.length===0?"Healthy":s.some(a=>a.status==="Down")?"Down":s.some(a=>a.status==="Degraded")?"Degraded":"Healthy"}function ml(s){return s.reduce((a,i)=>a+(i.estimatedCostUSD||0),0)}function pl(s){return!s||s.length===0?null:s.reduce((a,i)=>a.estimatedCostUSD>i.estimatedCostUSD?a:i)}function hl(s){return!s||s.length===0?null:s.reduce((a,i)=>a.requestCount>i.requestCount?a:i)}function ul(s){const a=new Date().toISOString().slice(0,7),[i,r]=l.useState([]),[n,x]=l.useState(!0),[m,p]=l.useState(null),[j,w]=l.useState(0),f=l.useCallback(()=>{w(c=>c+1)},[]);return l.useEffect(()=>{let c=!0;x(!0),p(null);const g=Xe(ee(J,"aiUsageLogs"),gt("month","==",a)),v=qs(g,y=>{if(!c)return;const z=[];y.forEach(A=>{const T=A.data();z.push(T)}),r(z),x(!1)},y=>{c&&(console.error("[useAIMonitoring] Firestore error:",y),p("Failed to load AI usage data. Please try again."),x(!1))});return()=>{c=!1,v()}},[a,j]),{stats:i,systemHealth:xl(i),totalSpend:ml(i),highestCostFeature:pl(i),mostActiveFeature:hl(i),isLoading:n,error:m,refresh:f}}const bt={"ai-chat":{icon:Ra,color:"text-sky-500 bg-sky-50"},"quiz-generation":{icon:Zs,color:"text-purple-500 bg-purple-50"},"lesson-generation":{icon:ze,color:"text-indigo-500 bg-indigo-50"},"learning-paths":{icon:Qt,color:"text-rose-500 bg-rose-50"},"risk-classification":{icon:ft,color:"text-amber-500 bg-amber-50"},"daily-insights":{icon:ht,color:"text-emerald-500 bg-emerald-50"},"solution-verification":{icon:ya,color:"text-blue-500 bg-blue-50"},"curriculum-search":{icon:Sa,color:"text-slate-500 bg-slate-50"},"content-processing":{icon:Qs,color:"text-violet-500 bg-violet-50"},"auto-feedback":{icon:Fa,color:"text-pink-500 bg-pink-50"}},gl=[{id:"ai-chat",name:"AI Chat Tutor",description:"On-demand math help via DeepSeek"},{id:"quiz-generation",name:"Quiz Generation",description:"AI quiz creation from curriculum"},{id:"lesson-generation",name:"Lesson Generation",description:"AI-generated lesson plans"},{id:"learning-paths",name:"Learning Paths",description:"Personalized study plans"},{id:"risk-classification",name:"Risk Classification",description:"Student at-risk identification"},{id:"daily-insights",name:"Daily AI Insights",description:"Analytics for teachers"},{id:"solution-verification",name:"Solution Verification",description:"Math solution checking"},{id:"curriculum-search",name:"Curriculum Search",description:"Embedding-based search"},{id:"content-processing",name:"Content Processing",description:"Topic extraction"},{id:"auto-feedback",name:"Auto Feedback",description:"Instant feedback for students"}],Oe={"ai-chat":35,"quiz-generation":18,"lesson-generation":12,"learning-paths":8,"risk-classification":6,"daily-insights":5,"solution-verification":6,"curriculum-search":4,"content-processing":3,"auto-feedback":3};function bl(s){if(!s)return"N/A";try{return new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"N/A"}}function Be(s){return s>=1?`$${s.toFixed(2)}`:`$${s.toFixed(4)}`}function mt(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function fl(s){const a=s.reduce((m,p)=>m+p.requestCount,0),i=s.reduce((m,p)=>m+p.estimatedCostUSD,0),r=new Date().toISOString(),n=gl.map(m=>{const p=s.find(g=>{const v=g.featureName.toLowerCase().replace(/[^a-z0-9]/g,""),y=m.name.toLowerCase().replace(/[^a-z0-9]/g,"");return v.includes(y)||y.includes(v)}),j=p?.requestCount??Math.round(a*(Oe[m.id]??1)/100),w=p?.estimatedCostUSD??i*(Oe[m.id]??1)/100,f=p?p.status==="Degraded"?"Warning":p.status==="Down"?"Offline":"Healthy":"Healthy",c=p?p.priority==="High"?"High":p.priority==="Medium"?"Medium":"Low":Oe[m.id]>=20?"High":Oe[m.id]>=8?"Medium":"Low";return{...m,status:f,requests:j,estimatedCost:w,avgCostPerRequest:j>0?w/j:0,usageLevel:c,lastActiveAt:p?.lastUpdated?.toDate().toISOString()??r,trend:"Stable",icon:bt[m.id]?.icon||he}}),x=n.reduce((m,p)=>m+p.estimatedCost,0);return n.map(m=>({...m,costPercent:x>0?m.estimatedCost/x*100:0}))}const He=({title:s,value:a,subtitle:i,icon:r,variant:n})=>{const x={blue:"bg-[#5154E7] shadow-blue-200",sky:"bg-[#0EA5E9] shadow-sky-100",green:"bg-[#10B981] shadow-emerald-200",red:"bg-[#EF4444] shadow-rose-200",purple:"bg-[#9956DE] shadow-purple-200"};return e.jsxs("div",{className:`relative overflow-hidden rounded-[24px] p-5 text-white shadow-lg transition-transform ${x[n]}`,children:[e.jsx("div",{className:"absolute -right-4 -top-4 opacity-10",children:e.jsx(r,{size:100})}),e.jsx("div",{className:"absolute right-4 top-4 w-8 h-8 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(r,{size:16})}),e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] opacity-80",children:s}),e.jsx("h3",{className:"text-2xl font-black mt-2 leading-none",children:a}),e.jsx("p",{className:"text-[10px] font-bold mt-4 opacity-70 uppercase tracking-widest",children:i}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-20 h-20 bg-white/10 rounded-full blur-2xl"})]})},jl=()=>{const[s,a]=l.useState(!1),{stats:i,systemHealth:r,totalSpend:n,highestCostFeature:x,mostActiveFeature:m,isLoading:p,refresh:j}=ul(),w=l.useMemo(()=>fl(i),[i]),f=l.useMemo(()=>[...w].sort((g,v)=>v.estimatedCost-g.estimatedCost),[w]),c=r==="Healthy"?"green":"red";return e.jsxs("div",{className:"space-y-6 pt-6 xl:pt-8 pb-10 w-full max-w-[1600px] mx-auto px-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-1.5 h-6 bg-[#9956DE] rounded-full"}),e.jsx("p",{className:"text-[11px] font-black text-slate-400 uppercase tracking-[0.2em]",children:"Platform AI Systems"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wt,{children:r!=="Healthy"&&e.jsxs(_.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},className:"flex items-center gap-2 bg-amber-50 px-3 py-1.5 rounded-full border border-amber-100",children:[e.jsx(ft,{size:12,className:"text-amber-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-black text-amber-700 uppercase tracking-widest",children:"System Performance Issues"})]})}),e.jsx("button",{onClick:j,disabled:p,title:"Refresh live data",className:"p-2 rounded-xl bg-white border border-slate-200 text-slate-400 hover:text-purple-600 shadow-sm transition-all active:scale-95",children:e.jsx(ke,{size:14,className:p?"animate-spin":""})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(He,{title:"System Status",value:r==="Healthy"?"All Clear":"Issues Found",subtitle:r==="Healthy"?"Infrastructure Stable":"Action Recommended",icon:Ke,variant:c}),e.jsx(He,{title:"Monthly Cost",value:p?"...":Be(n),subtitle:"Current Billable Cycle",icon:wa,variant:"purple"}),e.jsx(He,{title:"Total Usage",value:p?"...":mt(i.reduce((g,v)=>g+v.requestCount,0)),subtitle:"Inference Requests",icon:Ae,variant:"blue"}),e.jsx(He,{title:"Active Engine",value:"DeepSeek-R1",subtitle:"High-Performance LLM",icon:Gt,variant:"sky"})]})]}),s?e.jsxs(_.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},className:"space-y-4",children:[e.jsx("div",{className:"sticky top-0 z-40 -mx-[24px] xl:-mx-[32px] px-[24px] xl:px-[32px] pt-4 pb-4 bg-[#f8fafc] backdrop-blur-sm",children:e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-[24px] border border-slate-200/60 shadow-sm p-3",children:[e.jsxs("button",{onClick:()=>a(!1),className:"flex items-center gap-2 h-12 px-6 text-[11px] font-black text-[#9956DE] hover:bg-purple-50 rounded-xl uppercase tracking-widest transition-all",children:[e.jsx(Nt,{className:"rotate-180",size:16})," Back to System Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-2 px-4",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:"Real-time Engine Logs"})]})]})}),e.jsx("div",{className:"bg-white rounded-[32px] border border-slate-200/60 shadow-sm shadow-slate-200/40 relative",children:e.jsx("div",{className:"rounded-[32px]",children:e.jsxs("table",{className:"w-full text-left border-collapse min-w-[1000px]",children:[e.jsx("thead",{className:"sticky top-[106px] z-30 shadow-md bg-[#f8fafc]",children:e.jsxs("tr",{className:"border-b border-[#8b5cf6]",children:[e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest whitespace-nowrap rounded-tl-[32px]",children:"AI Module Identity"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Engine Status"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest text-right",children:"Inference Reqs"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest text-right",children:"Monthly Cost"}),e.jsx("th",{className:"bg-[#9956DE] px-8 py-5 text-[11px] font-black text-white uppercase tracking-widest rounded-tr-[32px]",children:"Last Activity"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:w.map(g=>{const v=bt[g.id]||{icon:he,color:"text-slate-500 bg-slate-50"};return e.jsxs("tr",{className:"group hover:bg-purple-50/10 border-b border-slate-50",children:[e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl border flex items-center justify-center ${v.color} border-slate-100`,children:e.jsx(v.icon,{size:18})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-black text-[#1e293b] text-sm block leading-none tracking-tight group-hover:text-[#9956DE] transition-colors",children:g.name}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter mt-1 opacity-70",children:g.description})]})]})}),e.jsx("td",{className:"px-8 py-5",children:e.jsxs("span",{className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[9px] font-black uppercase tracking-wider border ${g.status==="Healthy"?"bg-emerald-50 text-emerald-600 border-emerald-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:[e.jsx("div",{className:`w-1 h-1 rounded-full ${g.status==="Healthy"?"bg-emerald-500":"bg-amber-500"}`}),g.status]})}),e.jsx("td",{className:"px-8 py-5 text-right font-black text-[#1e293b]",children:mt(g.requests)}),e.jsx("td",{className:"px-8 py-5 text-right font-black text-[#9956DE]",children:Be(g.estimatedCost)}),e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:[e.jsx(Ze,{size:12})," ",bl(g.lastActiveAt)]})})]},g.id)})})]})})})]}):e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},className:"grid grid-cols-1 lg:grid-cols-12 gap-5",children:[e.jsxs("div",{className:"lg:col-span-4 bg-white rounded-[28px] border border-slate-200 p-6 shadow-sm flex flex-col justify-between group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-slate-50 text-[#9956DE] flex items-center justify-center border border-slate-100 group-hover:scale-110 transition-transform",children:e.jsx(jt,{size:20})}),e.jsx("span",{className:"text-[9px] font-black text-[#9956DE] bg-purple-50 px-2.5 py-1 rounded-full border border-purple-100 uppercase tracking-widest",children:"Top Spending"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Highest Monthly Cost"}),e.jsx("h4",{className:"text-xl font-black text-[#1e293b] mt-1 truncate",children:p?"...":x?.featureName||"N/A"}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[11px] font-black text-slate-500 uppercase tracking-tighter",children:"Cost Share"}),e.jsx("span",{className:"text-[13px] font-black text-[#9956DE]",children:Be(x?.estimatedCostUSD||0)})]}),e.jsx("div",{className:"h-1.5 bg-slate-50 rounded-full overflow-hidden border border-slate-100",children:e.jsx(_.div,{initial:{width:0},animate:{width:`${(x?.estimatedCostUSD||0)/(n||1)*100}%`},className:"h-full bg-gradient-to-r from-[#9956DE] to-[#8b5cf6] rounded-full"})})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 bg-white rounded-[28px] border border-slate-200 p-6 shadow-sm flex flex-col justify-between group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-slate-50 text-[#0EA5E9] flex items-center justify-center border border-slate-100 group-hover:scale-110 transition-transform",children:e.jsx(Ma,{size:20})}),e.jsx("span",{className:"text-[9px] font-black text-[#0EA5E9] bg-sky-50 px-2.5 py-1 rounded-full border border-sky-100 uppercase tracking-widest",children:"Most Active"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:"Most Popular Feature"}),e.jsx("h4",{className:"text-xl font-black text-[#1e293b] mt-1 truncate",children:p?"...":m?.featureName||"N/A"}),e.jsxs("p",{className:"text-2xl font-black text-[#1e293b] mt-3 tracking-tighter leading-none",children:[p?"...":mt(m?.requestCount||0),e.jsx("span",{className:"text-[10px] text-slate-400 font-bold ml-2 uppercase tracking-widest",children:"REQS"})]})]})]}),e.jsxs("div",{onClick:()=>a(!0),className:"lg:col-span-4 bg-white rounded-[28px] border border-slate-200 p-6 flex flex-col justify-center items-center text-center group cursor-pointer transition-all hover:border-[#9956DE]/50",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#9956DE]/10 text-[#9956DE] flex items-center justify-center mb-3 group-hover:scale-110 transition-all",children:e.jsx(Ea,{size:24})}),e.jsx("h3",{className:"text-[16px] font-black text-[#1e293b] tracking-tight",children:"System Directory"}),e.jsxs("button",{className:"mt-4 flex items-center gap-2 px-5 py-2 bg-[#9956DE] text-white rounded-full text-[9px] font-black uppercase tracking-[0.2em] shadow-lg shadow-purple-100 transition-all hover:bg-[#8b5cf6] hover:scale-105",children:["SEE FULL LIST ",e.jsx(Ls,{size:12})]})]}),e.jsxs("div",{className:"lg:col-span-12 bg-white rounded-[28px] border border-slate-200 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4 px-2",children:[e.jsx(rs,{size:16,className:"text-[#9956DE]"}),e.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:"Resource Ranking Breakdown"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 px-2",children:f.slice(0,4).map((g,v)=>{const y=bt[g.id]||{icon:he};return e.jsxs("div",{className:"flex items-center gap-4 group",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-slate-50 border border-slate-100 flex items-center justify-center text-slate-400 group-hover:text-[#9956DE] transition-all",children:e.jsx(y.icon,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[12px] font-black text-[#1e293b] truncate leading-none",children:g.name}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"text-[10px] font-black text-[#9956DE]",children:Be(g.estimatedCost)}),e.jsxs("span",{className:"text-[8px] font-black text-slate-400 uppercase",children:[Math.round(g.costPercent||0),"% Share"]})]})]})]},g.id)})})]})]})]})},ve=qe.map(s=>({id:s.id,name:s.name,code:s.code,gradeLevel:s.gradeLevel,semester:s.semester,color:s.color})),vl=()=>{const{userProfile:s}=Qe(),{availability:a,loading:i,error:r}=Js(),[n,x]=l.useState(null),[m,p]=l.useState({}),j=l.useCallback(async(c,g)=>{if(!s?.uid){D.error("You must be logged in as admin to change availability");return}x(c);try{await ea(c,g,s.uid),D.success(`${ve.find(v=>v.id===c)?.name||c} is now ${g?"available":"locked"}`)}catch(v){D.error("Failed to update subject availability"),console.error(v)}finally{x(null)}},[s?.uid]),w=l.useCallback((c,g)=>{p(v=>({...v,[c]:g}))},[]),f=l.useCallback(async c=>{if(!s?.uid){D.error("You must be logged in as admin");return}const g=m[c]?.trim()||null;x(c);try{await ta(c,g,s.uid),D.success("PDF path updated")}catch(v){D.error("Failed to update PDF path"),console.error(v)}finally{x(null)}},[m,s?.uid]);return e.jsxs("div",{className:"flex flex-col min-h-full space-y-8 pt-6 xl:pt-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-6",children:[i&&e.jsx("div",{className:"flex items-center justify-end px-2",children:e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-indigo-50 text-indigo-600 rounded-2xl border border-indigo-100 animate-pulse",children:[e.jsx(Y,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Syncing Subject Cloud Data..."})]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Subjects",value:ve.length,icon:Se,bg:"bg-[#4f46e5]",shadow:"shadow-indigo-500/20"},{label:"Available",value:ve.filter(c=>a[c.id]?.available!==!1).length,icon:za,bg:"bg-[#10b981]",shadow:"shadow-emerald-500/20"},{label:"Locked",value:ve.filter(c=>a[c.id]?.available===!1).length,icon:Kt,bg:"bg-[#ef4444]",shadow:"shadow-rose-500/20"},{label:"RAG Sources",value:ve.filter(c=>a[c.id]?.pdfPath).length,icon:We,bg:"bg-[#8b5cf6]",shadow:"shadow-purple-500/20"}].map((c,g)=>e.jsxs("div",{className:`relative overflow-hidden ${c.bg} ${c.shadow} p-5 rounded-[28px] text-white flex flex-col gap-3 group hover:scale-[1.02] transition-all duration-300 shadow-lg`,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-700 ease-out"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] opacity-80",children:c.label}),e.jsx("div",{className:"bg-white/20 p-2 rounded-xl backdrop-blur-sm",children:e.jsx(c.icon,{size:14})})]}),e.jsx("h3",{className:"relative z-10 text-3xl font-display font-black leading-none tracking-tight",children:c.value})]},g))}),r&&e.jsxs("div",{className:"rounded-2xl border border-rose-200 bg-rose-50 px-6 py-4 flex items-center gap-3 animate-in shake duration-500",children:[e.jsx(fe,{className:"text-rose-600",size:20}),e.jsx("p",{className:"text-sm font-bold text-rose-700",children:r})]}),e.jsx("div",{className:"bg-white rounded-[32px] border border-slate-200/60 shadow-sm shadow-slate-200/50 overflow-hidden relative",children:e.jsxs(ns,{className:"w-full text-left border-collapse",children:[e.jsx(os,{children:e.jsxs(Ne,{className:"bg-[#9956DE] hover:bg-[#9956DE] border-b border-[#8b5cf6] sticky top-0 z-20 shadow-md",children:[e.jsx(pe,{className:"px-6 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Subject Identity"}),e.jsx(pe,{className:"px-6 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Grade / Semester"}),e.jsx(pe,{className:"px-6 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Access Status"}),e.jsx(pe,{className:"px-6 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"Toggle Access"}),e.jsx(pe,{className:"px-6 py-5 text-[11px] font-black text-white uppercase tracking-widest",children:"RAG Resource Mapping"})]})}),e.jsx(cs,{className:"divide-y divide-slate-50",children:ve.map(c=>{const g=a[c.id],v=g?.available??!0,y=m[c.id]??g?.pdfPath??"",z=g?.lastUpdated,A=n===c.id;return e.jsxs(Ne,{className:"group hover:bg-slate-50/50 transition-all",children:[e.jsx(re,{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl bg-gradient-to-br ${c.color} flex items-center justify-center text-white shadow-lg shadow-indigo-100 group-hover:scale-110 transition-transform duration-500`,children:e.jsx(Se,{size:20,className:"drop-shadow-sm"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-black text-[#1e293b] truncate text-sm leading-tight group-hover:text-indigo-600 transition-colors",children:c.name}),e.jsx("p",{className:"text-[11px] font-black text-slate-400 uppercase tracking-tighter mt-1",children:c.code})]})]})}),e.jsx(re,{className:"px-6 py-5",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-black text-slate-700 uppercase tracking-wide",children:c.gradeLevel}),e.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-tight",children:c.semester})]})}),e.jsx(re,{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("span",{className:` + inline-flex items-center gap-1.5 px-3 py-1.5 rounded-2xl text-[10px] font-black uppercase tracking-wider border + ${v?"bg-emerald-50 text-emerald-600 border-emerald-100":"bg-slate-50 text-slate-400 border-slate-100"} + `,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v?"bg-emerald-500 animate-pulse":"bg-slate-300"}`}),v?"Available":"Locked"]}),z&&e.jsxs("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-tighter ml-1 flex items-center gap-1",children:[e.jsx(Ze,{size:10}),"Updated: ",z.toLocaleString()]})]})}),e.jsx(re,{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ys,{checked:v,onCheckedChange:T=>j(c.id,T),disabled:A,className:"data-[state=checked]:bg-emerald-500 data-[state=unchecked]:bg-slate-200","aria-label":`Toggle ${c.name} availability`}),A&&e.jsx(Y,{size:16,className:"animate-spin text-indigo-500"})]})}),e.jsx(re,{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 group/input",children:[e.jsx(We,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 group-focus-within/input:text-indigo-500 transition-colors"}),e.jsx(Z,{value:y,onChange:T=>w(c.id,T.target.value),placeholder:"Firebase path (e.g., rag/calculus.pdf)",className:"pl-10 h-10 text-xs font-bold rounded-xl bg-slate-50/50 border-slate-200 focus-visible:ring-indigo-500/20 focus-visible:border-indigo-500 transition-all",disabled:A})]}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-xl text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-all",onClick:()=>f(c.id),disabled:A,title:"Save PDF Path",children:A?e.jsx(Y,{size:18,className:"animate-spin text-indigo-500"}):e.jsx(ls,{size:18})})]})})]},c.id)})})]})})]})},wl=({isOpen:s,onClose:a})=>s?e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 sm:p-6",children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/40 backdrop-blur-sm animate-in fade-in duration-300",onClick:a}),e.jsxs("div",{className:"relative bg-white w-full max-w-4xl rounded-[40px] shadow-2xl border border-slate-200 overflow-hidden animate-in zoom-in slide-in-from-bottom-8 duration-500",children:[e.jsxs("div",{className:"px-10 pt-10 pb-6 flex items-center justify-between border-b border-slate-50 bg-slate-50/50",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-black text-[#1e293b] uppercase tracking-wider",children:"How It Works: Subject Governance"}),e.jsx("p",{className:"text-[11px] font-black text-indigo-500 uppercase tracking-[0.2em] mt-1",children:"Platform Curriculum Protocol & RAG Workflow"})]}),e.jsx("button",{onClick:a,className:"w-12 h-12 rounded-2xl flex items-center justify-center bg-white text-slate-400 hover:text-rose-500 hover:bg-rose-50 transition-all border border-slate-200 shadow-sm group",children:e.jsx(sa,{size:20,className:"group-hover:rotate-90 transition-transform duration-300"})})]}),e.jsx("div",{className:"p-12",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-12 relative",children:[e.jsx("div",{className:"absolute top-12 left-0 right-0 h-0.5 border-t-2 border-dashed border-indigo-100 hidden md:block z-0",style:{left:"10%",right:"10%"}}),[{step:"1",title:"Define Identity",desc:"Assign subject codes and grade levels in the core registry.",icon:Se,color:"text-indigo-600",bg:"bg-indigo-50"},{step:"2",title:"Map RAG Source",desc:"Link Firebase PDF paths to the AI Knowledge Base.",icon:he,color:"text-amber-600",bg:"bg-amber-50"},{step:"3",title:"Global Toggle",desc:"Enable or lock subject access across all dashboards instantly.",icon:Us,color:"text-emerald-600",bg:"bg-emerald-50"},{step:"4",title:"Audit Sync",desc:"Every modification is logged and synced to the cloud registry.",icon:Ke,color:"text-purple-600",bg:"bg-purple-50"}].map((i,r)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center text-center group relative z-10",children:[e.jsxs("div",{className:`relative mb-6 w-24 h-24 ${i.bg} rounded-[32px] flex items-center justify-center transition-all duration-500 group-hover:scale-110 group-hover:rotate-3 shadow-lg shadow-indigo-100/20`,children:[e.jsx(i.icon,{size:36,className:`${i.color} drop-shadow-sm`}),e.jsx("div",{className:"absolute -top-3 -left-3 bg-[#9956DE] text-white text-[12px] font-black w-10 h-10 rounded-2xl flex items-center justify-center shadow-lg border-2 border-white",children:i.step})]}),e.jsx("h4",{className:"text-sm font-black text-[#1e293b] uppercase tracking-wide mb-2",children:i.title}),e.jsx("p",{className:"text-xs text-slate-400 font-bold leading-relaxed max-w-[180px]",children:i.desc})]},r))]})}),e.jsxs("div",{className:"px-12 py-6 bg-slate-50/50 border-t border-slate-100 flex items-center justify-center gap-4",children:[e.jsx("div",{className:"flex -space-x-2",children:[1,2,3].map(i=>e.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-white bg-indigo-100 flex items-center justify-center",children:e.jsx("div",{className:"w-4 h-4 rounded-full bg-indigo-500 animate-pulse"})},i))}),e.jsx("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:"Platform Governance Active & Monitored"})]})]})]}):null,wr=({onLogout:s,onOpenProfile:a,onOpenSettings:i})=>{const{userProfile:r}=Qe(),[n,x]=l.useState("Overview"),[m,p]=l.useState(!1),[j,w]=l.useState(!1),[f,c]=l.useState(!1),[g,v]=l.useState(null),[y,z]=l.useState(null),[A,T]=l.useState([]),[U,M]=l.useState([]),[$,B]=l.useState(!0),[te,ne]=l.useState(!1),[G,Q]=l.useState(!1),[se,I]=l.useState(!1),ae=h=>(n===h||(x(h),h==="Subjects"&&(I(!0),setTimeout(()=>I(!1),2e3))),!0),V=h=>{ae(h)&&c(!1)};l.useEffect(()=>{if(n!=="Overview"||!r)return;const h=String(r.role||"").toLowerCase(),k=h==="admin"||h==="teacher";let o=!1;return B(!0),Promise.all([Qa(),k?xs():Promise.resolve([]),Za(3)]).then(([P,d,H])=>{o||(z(P),T(d.slice(0,4)),M(H))}).catch(console.error).finally(()=>{o||B(!1)}),()=>{o=!0}},[n,r]);const F=[{label:"Active Teachers",value:(y?.activeTeachers??0).toString(),icon:ze,color:"bg-teal-100",iconColor:"text-teal-600"},{label:"Total Classes",value:(y?.totalClasses??0).toString(),icon:Se,color:"bg-indigo-100",iconColor:"text-indigo-600"},{label:"AI Inferences",value:(y?.aiPredictions??0).toLocaleString(),icon:he,color:"bg-amber-100",iconColor:"text-amber-600"},{label:"At-Risk Alerts",value:(y?.atRiskStudents??0).toString(),icon:fe,color:"bg-rose-100",iconColor:"text-rose-600"}];return e.jsxs("div",{className:"flex h-screen w-full bg-[#f8fafc] overflow-hidden font-body",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsx(Rt,{activeTab:n,setActiveTab:V,userRole:"admin",onOpenSettings:()=>i?.(),onLogout:()=>p(!0),sidebarCollapsed:j,setSidebarCollapsed:w})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-40 bg-slate-900/40 backdrop-blur-[1px] lg:hidden",onClick:()=>c(!1)}),e.jsx("div",{className:"fixed inset-y-0 left-0 z-50 p-3 lg:hidden",children:e.jsx(Rt,{mode:"mobile",onRequestClose:()=>c(!1),activeTab:n,setActiveTab:V,userRole:"admin",onOpenSettings:()=>i?.(),onLogout:()=>{p(!0),c(!1)},sidebarCollapsed:!1})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[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-col sm:flex-row sm:items-start justify-between gap-4 mb-0",children:[e.jsxs("div",{className:"flex-1 flex items-start gap-3",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"lg:hidden mt-1 p-2 rounded-lg border border-[#dde3eb] bg-white text-[#5a6578] hover:bg-[#edf1f7] transition-colors","aria-label":"Open navigation",children:e.jsx($s,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[26px] font-bold text-[#1e293b] tracking-tight leading-tight",children:[n==="Overview"&&"Admin Dashboard",n==="Content"&&"Content & RAG",n==="Audit Log"&&"Audit Log",n==="User Management"&&"User Management",n==="Analytics"&&"Analytics",n==="AI Monitoring"&&"AI Monitoring",n==="Subjects"&&"Curriculum Control"]}),e.jsxs("p",{className:"text-[13px] text-[#64748b] mt-1",children:[n==="Overview"&&"System Overview & Management",n==="Content"&&"Upload PDFs for AI-powered content.",n==="Audit Log"&&"Monitor system activity and security.",n==="User Management"&&"Manage all user accounts and roles.",n==="Analytics"&&"Detailed system performance metrics.",n==="AI Monitoring"&&"Platform AI usage and system health.",n==="Subjects"&&"Manage academic subjects, availability, and RAG knowledge sources."]})]}),n==="Overview"&&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-[#4f46e5]/10 border border-[#4f46e5]/20 rounded-lg",children:[e.jsx(ye,{size:13,className:"text-[#4f46e5]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#4f46e5]",children:[(y?.totalStudents??0).toLocaleString()," students"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-[#0ea5e9]/10 border border-[#0ea5e9]/20 rounded-lg",children:[e.jsx(ze,{size:13,className:"text-[#0ea5e9]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#0ea5e9]",children:[y?.activeTeachers??0," teachers"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[e.jsx(he,{size:13,className:"text-amber-600"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-amber-600",children:[(y?.aiPredictions??0).toLocaleString()," inferences"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 self-end sm:self-auto",children:[n==="Subjects"&&e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>Q(!0),className:"relative w-10 h-10 flex items-center justify-center bg-indigo-600 hover:bg-indigo-700 rounded-full shadow-lg shadow-indigo-200 text-white transition-all cursor-pointer hover:scale-110 active:scale-95 animate-in zoom-in duration-300","aria-label":"How it works",children:e.jsx(aa,{size:20})}),se&&e.jsxs("div",{className:"absolute top-12 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-[#1e293b] text-white text-[10px] font-black uppercase tracking-widest rounded-lg shadow-xl whitespace-nowrap animate-in fade-in slide-in-from-top-2 duration-300 z-50",children:["How It Works?",e.jsx("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-[#1e293b] rotate-45"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ne(!te),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",children:[e.jsx(la,{size:18}),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(_s,{isOpen:te,onClose:()=>ne(!1),onViewAll:()=>ae("Audit Log")})]}),e.jsxs("div",{onClick:a,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(Is,{src:r?.photo,name:r?.name||"Admin",gender:r?.gender,className:"w-full h-full object-cover"})}),e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:r?.name||"Admin"})]})]})]})}),e.jsxs("main",{className:`flex-1 overflow-y-auto px-[24px] xl:px-[32px] scrollbar-hide ${["User Management","Audit Log"].includes(n)?"pb-0":"pb-[32px]"}`,children:[n==="Overview"&&e.jsxs("div",{className:"max-w-[1600px] mx-auto space-y-8 pt-6 xl:pt-8",children:[e.jsxs("div",{className:"grid grid-cols-12 gap-6 h-[170px]",children:[e.jsxs("div",{className:"col-span-12 xl:col-span-4 h-full bg-gradient-to-br from-[#4f46e5] to-[#7c3aed] rounded-[28px] p-6 relative overflow-hidden shadow-sm shadow-indigo-500/10 group",children:[e.jsx("div",{className:"absolute -top-24 -right-24 w-64 h-64 bg-white/10 rounded-full blur-3xl group-hover:bg-white/20 transition-all duration-1000"}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between h-full",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white/70 text-[10px] font-black uppercase tracking-[0.2em] mb-1.5",children:"Platform Overview"}),e.jsx("p",{className:"text-white text-4xl font-display font-black tracking-tighter leading-none",children:$?"...":(y?.totalStudents??0).toLocaleString()}),e.jsx("p",{className:"text-white/80 text-xs font-medium mt-1",children:"Total Active Students"})]}),e.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 bg-white/10 backdrop-blur-md rounded-full w-fit border border-white/10",children:[e.jsx(jt,{size:12,className:"text-emerald-400"}),e.jsx("span",{className:"text-white text-[10px] font-bold tracking-wide",children:"+12.5% increase"})]})]}),e.jsx("div",{className:"absolute -bottom-6 -right-6 opacity-10 group-hover:scale-110 group-hover:rotate-6 transition-all duration-700 pointer-events-none",children:e.jsx(ye,{size:140,className:"text-white"})})]}),e.jsx("div",{className:"col-span-12 xl:col-span-8 h-full bg-white border border-slate-200/60 rounded-[28px] px-2 py-5 flex items-center shadow-sm shadow-slate-200/50",children:e.jsx("div",{className:"grid grid-cols-4 w-full h-full",children:F.map((h,k)=>e.jsxs("div",{className:`flex flex-col justify-center px-8 ${k!==3?"border-r border-slate-100":""}`,children:[e.jsx("div",{className:`w-10 h-10 ${h.color} rounded-xl flex items-center justify-center mb-3 shadow-sm`,children:e.jsx(h.icon,{size:20,className:h.iconColor})}),e.jsx("p",{className:"text-[24px] font-display font-black text-[#1e293b] leading-tight tracking-tight",children:$?"...":h.value}),e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-[0.15em] mt-0.5",children:h.label})]},k))})})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-6 min-h-[330px]",children:[e.jsxs("div",{className:"col-span-12 xl:col-span-5 bg-white rounded-[28px] border border-slate-200/60 p-6 flex flex-col shadow-sm shadow-slate-200/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b]",children:"System Performance"}),e.jsx("p",{className:"text-[11px] text-slate-400 font-medium",children:"AI vs Manual Activity"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 bg-slate-50 rounded-lg",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#6366f1]"}),e.jsx("span",{className:"text-[9px] font-black text-slate-500 uppercase tracking-wider",children:"AI"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 bg-slate-50 rounded-lg",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-slate-200"}),e.jsx("span",{className:"text-[9px] font-black text-slate-500 uppercase tracking-wider",children:"Manual"})]})]})]}),e.jsx("div",{className:"flex-1 w-full min-h-[200px]",children:e.jsx(dt,{width:"100%",height:"100%",children:e.jsxs(ra,{data:[{name:"M",ai:400,man:240},{name:"T",ai:300,man:139},{name:"W",ai:520,man:280},{name:"T",ai:480,man:390},{name:"F",ai:600,man:480},{name:"S",ai:200,man:100},{name:"S",ai:150,man:90}],margin:{top:0,right:0,left:-20,bottom:0},children:[e.jsx(ia,{strokeDasharray:"4 4",vertical:!1,stroke:"#f1f5f9"}),e.jsx(na,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:800,fill:"#cbd5e1"},dy:10}),e.jsx(oa,{axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:800,fill:"#cbd5e1"}}),e.jsx(ca,{contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 15px 20px -5px rgb(0 0 0 / 0.1)",padding:"10px"},cursor:{fill:"#f8fafc"}}),e.jsx(Ft,{dataKey:"ai",fill:"#6366f1",radius:[4,4,0,0],barSize:12}),e.jsx(Ft,{dataKey:"man",fill:"#e2e8f0",radius:[4,4,0,0],barSize:12})]})})})]}),e.jsxs("div",{className:"col-span-12 xl:col-span-4 bg-white rounded-[28px] border border-slate-200/60 p-6 flex flex-col shadow-sm shadow-slate-200/50 group",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b]",children:"AI Model Status"}),e.jsx("p",{className:"text-[11px] text-slate-400 font-medium",children:"Inference Tracking"})]}),e.jsx("div",{className:"w-9 h-9 bg-indigo-50 rounded-xl flex items-center justify-center",children:e.jsx(Ae,{size:16,className:"text-indigo-600"})})]}),e.jsxs("div",{className:"flex items-baseline gap-2 mb-4",children:[e.jsx("span",{className:"text-[38px] font-display font-black text-indigo-600 tracking-tighter leading-none",children:"160"}),e.jsx("span",{className:"text-[10px] font-black text-emerald-500 bg-emerald-50 px-2 py-0.5 rounded-full uppercase tracking-wider",children:"Optimal"})]}),e.jsx("div",{className:"flex-1 min-h-[120px]",children:e.jsx(dt,{width:"100%",height:"100%",children:e.jsxs(da,{data:[{v:10},{v:15},{v:12},{v:25},{v:18},{v:35},{v:28},{v:45}],children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorStatus",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.15}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]})}),e.jsx(xa,{type:"monotone",dataKey:"v",stroke:"#6366f1",strokeWidth:3,fillOpacity:1,fill:"url(#colorStatus)"})]})})}),e.jsxs("button",{className:"w-full mt-4 py-3 bg-slate-50 text-[#1e293b] text-[11px] font-black uppercase tracking-[0.15em] rounded-xl hover:bg-indigo-600 hover:text-white transition-all flex items-center justify-center gap-2.5 group/btn",children:["Health Check ",e.jsx(ga,{size:14,className:"group-hover/btn:translate-x-0.5 group-hover/btn:-translate-y-0.5 transition-transform"})]})]}),e.jsxs("div",{className:"col-span-12 xl:col-span-3 flex flex-col gap-4",children:[e.jsx("h3",{className:"text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] pl-2",children:"Top Performers"}),e.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[$?e.jsx("div",{className:"flex-1 flex items-center justify-center bg-white rounded-[28px] border border-slate-100",children:e.jsx(Y,{size:24,className:"animate-spin text-slate-200"})}):U.slice(0,2).map((h,k)=>e.jsxs("div",{className:`relative rounded-[28px] border p-4 shadow-sm shadow-slate-200/50 transition-all cursor-pointer group overflow-hidden ${k===0?"bg-gradient-to-br from-emerald-50 to-white border-emerald-200/50":"bg-gradient-to-br from-indigo-50 to-white border-indigo-200/50"}`,children:[e.jsx("div",{className:`absolute -top-12 -right-12 w-32 h-32 rounded-full blur-2xl opacity-20 transition-all duration-700 group-hover:scale-125 ${k===0?"bg-emerald-400":"bg-indigo-400"}`}),e.jsxs("div",{className:"flex items-center gap-3 relative z-10",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:`p-[3px] rounded-[20px] shadow-sm ${k===0?"bg-gradient-to-tr from-emerald-500 to-emerald-200":"bg-gradient-to-tr from-indigo-500 to-indigo-200"}`,children:e.jsx("img",{src:h.avatar,alt:"",className:"w-11 h-11 rounded-[17px] object-cover bg-white"})}),e.jsx("div",{className:`absolute -top-2 -right-2 w-6 h-6 text-[10px] font-black rounded-full flex items-center justify-center border-2 border-white shadow-md ${k===0?"bg-emerald-500 text-white":"bg-indigo-500 text-white"}`,children:k===0?"🥇":"🥈"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:`text-[13px] font-black truncate transition-colors ${k===0?"text-emerald-900 group-hover:text-emerald-600":"text-indigo-900 group-hover:text-indigo-600"}`,children:h.name}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:e.jsx("span",{className:`text-[8px] font-black uppercase tracking-widest px-1.5 py-0.5 rounded-md ${k===0?"bg-emerald-500/10 text-emerald-600":"bg-indigo-500/10 text-indigo-600"}`,children:h.class})})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:`text-xl font-display font-black leading-none ${k===0?"text-emerald-600":"text-indigo-600"}`,children:[h.performance,"%"]}),e.jsx("p",{className:"text-[7px] font-black text-slate-400 uppercase tracking-tighter mt-1",children:"Mastery"})]})]})]},h.id)),e.jsx("button",{onClick:()=>x("Analytics"),className:"mt-auto py-2.5 text-[10px] font-black text-indigo-600 uppercase tracking-[0.2em] text-center bg-white border border-slate-200/60 rounded-xl hover:bg-slate-50 transition-all shadow-sm shadow-slate-200/50",children:"All Rankings"})]})]})]}),e.jsxs("div",{className:"flex flex-col xl:flex-row gap-6 pb-8 items-stretch",children:[e.jsxs("div",{className:"w-full xl:w-1/3 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-[#1e293b] rounded-[28px] p-6 text-white shadow-sm shadow-slate-900/10 relative overflow-hidden group min-h-[190px] flex flex-col justify-between shrink-0",children:[e.jsx("div",{className:"absolute -bottom-10 -right-10 opacity-5 group-hover:scale-110 group-hover:-rotate-12 transition-all duration-700 pointer-events-none",children:e.jsx(fe,{size:200})}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("div",{className:"w-10 h-10 bg-rose-500 rounded-xl flex items-center justify-center mb-4 shadow-lg shadow-rose-500/20",children:e.jsx(fe,{size:18,className:"text-white"})}),e.jsxs("div",{className:"px-2.5 py-1 bg-white/10 backdrop-blur-md rounded-full border border-white/10 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-rose-500 animate-pulse"}),e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest",children:"Urgent"})]})]}),e.jsx("h4",{className:"text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] mb-0.5",children:"Priority Attention"}),e.jsx("h3",{className:"text-xl font-display font-black tracking-tight leading-tight",children:"General Mathematics"})]}),e.jsxs("div",{className:"relative z-10 pt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:"12 At-Risk Students"}),e.jsx("button",{className:"text-[10px] font-black uppercase tracking-widest text-indigo-400 hover:text-indigo-300 transition-colors",children:"Review"})]})]}),e.jsxs("div",{className:"bg-white rounded-[28px] border border-slate-200/60 p-7 flex flex-col items-center justify-center shadow-sm shadow-slate-200/50 relative overflow-hidden flex-1",children:[e.jsxs("div",{className:"absolute top-7 left-8",children:[e.jsx("h3",{className:"text-[14px] font-bold text-[#1e293b]",children:"Global Mastery"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-medium",children:"Average performance"})]}),e.jsxs("div",{className:"relative w-40 h-40 mt-6",children:[e.jsx(dt,{width:"100%",height:"100%",children:e.jsx(ma,{children:e.jsxs(pa,{data:[{name:"Mastery",value:76},{name:"Remaining",value:24}],cx:"50%",cy:"50%",innerRadius:55,outerRadius:75,paddingAngle:8,dataKey:"value",startAngle:90,endAngle:450,stroke:"none",children:[e.jsx(_t,{fill:"#6366f1"}),e.jsx(_t,{fill:"#f1f5f9"})]})})}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[36px] font-display font-black text-[#1e293b] leading-none",children:"76%"}),e.jsx("span",{className:"text-[9px] font-black text-slate-400 uppercase tracking-[0.1em] mt-1",children:"Overall"})]})]}),e.jsxs("div",{className:"mt-8 flex items-center gap-12",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xl font-display font-black text-indigo-600 leading-none",children:"1,762"}),e.jsx("p",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest mt-1",children:"Passed"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xl font-display font-black text-slate-300 leading-none",children:"762"}),e.jsx("p",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest mt-1",children:"Pending"})]})]}),e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1 bg-gradient-to-r from-indigo-500/20 to-purple-500/20"})]})]}),e.jsxs("div",{className:"w-full xl:w-2/3 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[28px] border border-slate-200/60 shadow-sm shadow-slate-200/50 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-slate-50 flex items-center justify-between bg-slate-50/30",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[15px] font-bold text-[#1e293b]",children:"Subject Breakdown"}),e.jsx("p",{className:"text-[11px] text-slate-400 font-medium",children:"Core vs STEM performance"})]}),e.jsx("button",{className:"px-3 py-1.5 bg-white border border-slate-200 text-[10px] font-black text-[#1e293b] uppercase tracking-widest rounded-lg hover:bg-slate-50 transition-all",children:"Export"})]}),e.jsx("div",{className:"flex-1 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/20",children:[e.jsx("th",{className:"px-6 py-3 text-[9px] font-black text-slate-300 uppercase tracking-[0.2em]",children:"Subject"}),e.jsx("th",{className:"px-6 py-3 text-[9px] font-black text-slate-300 uppercase tracking-[0.2em]",children:"Category"}),e.jsx("th",{className:"px-6 py-3 text-[9px] font-black text-slate-300 uppercase tracking-[0.2em] text-center",children:"Enrolled"}),e.jsx("th",{className:"px-6 py-3 text-[9px] font-black text-slate-300 uppercase tracking-[0.2em]",children:"Progress"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50/60",children:[{name:"General Mathematics",type:"Core",count:"4.2k",progress:85},{name:"Pre-Calculus (STEM)",type:"STEM",count:"1.8k",progress:62},{name:"Stats & Probability",type:"Core",count:"3.1k",progress:78},{name:"Basic Calculus",type:"STEM",count:"1.2k",progress:45}].map((h,k)=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[13px] font-bold text-[#1e293b] group-hover:text-indigo-600 transition-colors",children:h.name}),e.jsx("span",{className:"text-[9px] font-medium text-slate-400",children:"Semester 1"})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`text-[8px] font-black px-2 py-0.5 rounded-md uppercase tracking-wider ${h.type==="STEM"?"bg-indigo-50 text-indigo-600 border border-indigo-100":"bg-slate-100 text-slate-500 border border-slate-200"}`,children:h.type})}),e.jsx("td",{className:"px-6 py-4 text-center",children:e.jsx("span",{className:"text-[12px] font-bold text-slate-600",children:h.count})}),e.jsx("td",{className:"px-6 py-4 min-w-[180px]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-1.5 bg-slate-100 rounded-full overflow-hidden p-[1px]",children:e.jsx("div",{className:`h-full rounded-full ${h.progress>80?"bg-indigo-500":h.progress>60?"bg-indigo-400":"bg-rose-400"} transition-all duration-1000`,style:{width:`${h.progress}%`}})}),e.jsxs("span",{className:"text-[11px] font-black text-[#1e293b] w-8",children:[h.progress,"%"]})]})})]},k))})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-[15px] font-bold text-[#1e293b]",children:"Activity"}),e.jsx("div",{className:"w-7 h-7 bg-slate-50 rounded-lg flex items-center justify-center",children:e.jsx(Ae,{size:14,className:"text-slate-400"})})]}),e.jsx("div",{className:"space-y-5",children:A.slice(0,3).map((h,k)=>e.jsxs("div",{className:"flex gap-3 group",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-indigo-50 flex items-center justify-center shrink-0 group-hover:scale-110 transition-transform",children:e.jsx(ha,{size:14,className:"text-indigo-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[12px] font-bold text-[#1e293b] truncate leading-tight group-hover:text-indigo-600 transition-colors",children:h.action}),e.jsx("p",{className:"text-[10px] font-medium text-slate-400 truncate mt-0.5",children:h.details})]})]},k))})]}),e.jsxs("div",{className:"bg-white rounded-[28px] border border-slate-200/60 p-6 shadow-sm shadow-slate-200/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-[15px] font-bold text-[#1e293b]",children:"Load"}),e.jsx("div",{className:"w-7 h-7 bg-slate-50 rounded-lg flex items-center justify-center",children:e.jsx(he,{size:14,className:"text-slate-400"})})]}),e.jsx("div",{className:"space-y-5",children:[{label:"Foundational",color:"bg-emerald-400",val:45},{label:"Intermediate",color:"bg-indigo-400",val:35},{label:"Advanced",color:"bg-rose-400",val:20}].map((h,k)=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[e.jsx("span",{className:"text-[9px] font-black text-slate-400 uppercase tracking-[0.15em]",children:h.label}),e.jsxs("span",{className:"text-[11px] font-black text-[#1e293b]",children:[h.val,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-slate-50 rounded-full overflow-hidden p-[1px]",children:e.jsx("div",{className:`h-full rounded-full ${h.color}`,style:{width:`${h.val}%`}})})]},k))})]})]})]})]})]}),n==="Content"&&e.jsx(Oa,{}),n==="Audit Log"&&e.jsx(el,{}),n==="User Management"&&e.jsx(cl,{createIntentRole:g,onCreateIntentConsumed:()=>v(null)}),n==="Analytics"&&e.jsx(dl,{}),n==="AI Monitoring"&&e.jsx(jl,{}),n==="Subjects"&&e.jsx(vl,{})]})]}),e.jsx(wl,{isOpen:G,onClose:()=>Q(!1)}),e.jsx(Vt,{isOpen:m,onClose:()=>p(!1),onConfirm:s,title:"Logout Confirmation",message:"Are you sure you want to log out? This will end your current session.",confirmText:"Logout",cancelText:"Cancel"})]})};export{wr as default}; diff --git a/assets/AssessmentPage-D98zS7Za.js b/assets/AssessmentPage-DI0qCtR6.js similarity index 93% rename from assets/AssessmentPage-D98zS7Za.js rename to assets/AssessmentPage-DI0qCtR6.js index 911dfd5779cd7bb66cc212a582513003e4e0a992..25dde70766a566963a5837b846975ef06eedbc6a 100644 --- a/assets/AssessmentPage-D98zS7Za.js +++ b/assets/AssessmentPage-DI0qCtR6.js @@ -1,6 +1,6 @@ -import{r as n,j as e}from"./vendor-react-B4AQeu28.js";import{B as P}from"./button-BqKfG4Jj.js";import{s as Q}from"./diagnosticService-D1BQOFa3.js";import{c as Y,m as a,Z as J,g as O,T as U,z as Z,q as G}from"./index-mbyiCUYG.js";import{M as H}from"./maximize-2-BqKWV1Bn.js";import{X as W}from"./x-oZO0Ye1Q.js";import{C as X}from"./clock-BLtPbCgT.js";import{C as K}from"./circle-check-big-BnoZ8KZB.js";import{C as V}from"./chevron-right-bwYIKoxv.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as n,j as e}from"./vendor-react-B4AQeu28.js";import{B as P}from"./button-CaSK4KoS.js";import{s as Q}from"./diagnosticService-CLsUcd9M.js";import{e as Y,m as a,Z as J,k as O,T as U,z as Z,p as G}from"./index-B3ruOzo6.js";import{M as H}from"./maximize-2-Cr4HMoWg.js";import{X as W}from"./x-BNHnAXzL.js";import{C as X}from"./clock-C73na4Cu.js";import{C as K}from"./circle-check-big-CWdn1Nqf.js";import{C as V}from"./chevron-right-CbkkCalp.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.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 ee=[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],se=Y("minimize-2",ee),we=({testId:S,questions:u,userName:k,onComplete:_,onCancel:z})=>{const[h,b]=n.useState("testing"),[l,E]=n.useState(0),[i,g]=n.useState(null),[d,C]=n.useState(()=>{try{const s=sessionStorage.getItem("mathpulse_diagnostic_responses");return s?JSON.parse(s):[]}catch{return[]}}),[w,D]=n.useState([]),[F,A]=n.useState(0),[j,v]=n.useState(null),[y,p]=n.useState(!1),o=n.useRef(null),f=n.useRef(Date.now()),c=u.length,m=u[l],M=Math.round((l+(i?1:0))/c*100),[I]=n.useState(Array.from({length:10},(s,t)=>({id:t,size:Math.random()*80+30,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*20+15,delay:Math.random()*-20,color:["bg-purple-500/10","bg-blue-500/10","bg-cyan-500/10","bg-emerald-500/10"][Math.floor(Math.random()*4)]}))),N=n.useCallback(()=>{f.current=Date.now(),o.current&&clearInterval(o.current),o.current=setInterval(()=>{A(Math.floor((Date.now()-f.current)/1e3))},200)},[]);n.useEffect(()=>(N(),()=>{o.current&&clearInterval(o.current)}),[l,N]);const R=n.useCallback(()=>{const s=document.getElementById("assessment-container");s&&(document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen().then(()=>{p(!1)}).catch(t=>{console.error("Exit fullscreen error:",t)}):s.requestFullscreen().then(()=>{p(!0)}).catch(t=>{console.error("Fullscreen error:",t)}))},[]);n.useEffect(()=>{const s=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",s),()=>document.removeEventListener("fullscreenchange",s)},[]);const B=s=>{g(s)},T=()=>{if(!i)return;o.current&&clearInterval(o.current);const s=Math.floor((Date.now()-f.current)/1e3),t=[...w,!0],r=[...d,{question_id:m.question_id,student_answer:i,time_spent_seconds:s}];D(t),C(r),g(null),lx+1):$(r)},$=async s=>{b("submitting"),v(null);try{sessionStorage.setItem("mathpulse_diagnostic_responses",JSON.stringify(s))}catch{}try{const t=await Q(S,s);sessionStorage.removeItem("mathpulse_diagnostic"),sessionStorage.removeItem("mathpulse_diagnostic_responses"),b("results"),setTimeout(()=>{_({overallRisk:t.overall_risk,overallScorePercent:t.overall_score_percent,intervention:t.recommended_intervention,xpEarned:t.xp_earned,badgeUnlocked:t.badge_unlocked})},3e3)}catch(t){const r=t instanceof Error?t.message:"Submission failed. Your answers are saved locally.";v(r)}},q=s=>{const t=Math.floor(s/60),r=s%60;return`${t}:${r.toString().padStart(2,"0")}`},L=["A","B","C","D"];return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-md flex items-center justify-center p-4 sm:p-6 overflow-hidden",children:e.jsxs("div",{id:"assessment-container",className:"bg-white/95 backdrop-blur-xl border border-white/20 rounded-3xl shadow-[0_0_50px_rgba(0,0,0,0.3)] w-full max-w-4xl h-[95vh] sm:h-[90vh] md:h-[85vh] flex flex-col relative z-10 overflow-hidden transition-all duration-300",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:I.map(s=>e.jsx(a.div,{className:`absolute rounded-full blur-3xl ${s.color.replace("/10","/30")}`,style:{width:s.size*1.5,height:s.size*1.5,left:`${s.x}%`,top:`${s.y}%`},animate:{x:[0,Math.random()*100-50,0],y:[0,Math.random()*100-50,0],scale:[1,1.3,1]},transition:{duration:s.duration,repeat:1/0,ease:"linear",delay:s.delay}},s.id))}),e.jsxs(a.div,{className:"shrink-0 text-white border-b border-white/10 shadow-md relative z-10",style:{backgroundColor:"#9956DE"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 md:p-6",children:[e.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl font-bold truncate",children:"Diagnostic Assessment"}),e.jsxs("p",{className:"text-white/80 text-xs sm:text-sm font-medium truncate",children:[m.domain," • ",m.difficulty]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:R,className:"w-9 h-9 sm:w-10 sm:h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",title:y?"Exit Fullscreen":"Enter Fullscreen",children:y?e.jsx(se,{size:18}):e.jsx(H,{size:18})}),e.jsx("button",{onClick:z,className:"w-9 h-9 sm:w-10 sm:h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",children:e.jsx(W,{size:20})})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 md:px-6 pb-3 sm:pb-4 md:pb-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"bg-white/20 px-3 py-1 rounded-full flex items-center gap-1",children:[e.jsx(J,{size:16}),e.jsxs("span",{className:"font-bold text-sm",children:[d.length," / ",c]})]})}),e.jsxs("div",{className:"flex items-center gap-1 bg-white/20 px-3 py-1 rounded-full",children:[e.jsx(X,{size:16}),e.jsx("span",{className:"font-bold text-sm",children:q(F)})]})]}),e.jsxs("div",{className:"px-4 sm:px-5 md:px-6 pb-3 sm:pb-4 md:pb-5",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Question ",l+1," of ",c]}),e.jsxs("span",{className:"text-sm font-bold",children:[M,"%"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:u.map((s,t)=>{let r="bg-white/30";return t{const t=m.options[s];if(!t)return null;const r=i===s;let x="bg-[#edf1f7] hover:bg-[#dde3eb] border-[#dde3eb]";return r&&(x="bg-purple-50 border-[#9956DE]"),e.jsx(a.button,{whileHover:{scale:1.01},whileTap:{scale:.99},onClick:()=>B(s),className:`w-full text-left p-2.5 sm:p-3 md:p-4 rounded-xl border-2 transition-all ${x} cursor-pointer shadow-sm hover:shadow-md flex items-center min-h-[3rem] sm:min-h-[4rem] md:min-h-[5rem]`,children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 w-full min-w-0",children:[e.jsx("div",{className:`w-8 h-8 sm:w-10 sm:h-10 rounded-xl shrink-0 flex items-center justify-center font-bold text-sm sm:text-base ${r?"bg-[#9956DE] text-white shadow-inner":"bg-white text-[#0a1628] shadow-sm"}`,children:s}),e.jsx("span",{className:"font-semibold text-[#0a1628] text-xs sm:text-sm md:text-base break-words",children:t}),r&&e.jsx(K,{size:18,className:"ml-auto text-[#9956DE] flex-shrink-0"})]})},s)})})]},l)})}),e.jsx("div",{className:"p-4 sm:p-5 md:p-6 bg-[#edf1f7] border-t border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-[#5a6578]",children:i?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(U,{size:16}),"Ready for the next one!"]}):e.jsx("span",{children:"Select an answer to continue"})}),e.jsxs(P,{onClick:T,disabled:!i,className:`font-bold px-6 py-2.5 sm:py-3 rounded-xl flex items-center gap-2 transition-all shadow-md hover:shadow-lg text-sm ${i?"bg-[#9956DE] hover:bg-[#8850CE] text-white shadow-[#9956DE]/20":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[l=c*.7?"bg-gradient-to-br from-[#75D06A] to-[#6ED1CF]":"bg-gradient-to-br from-[#FFB356] to-[#FF8B8B]"}`,children:d.length>=c*.7?e.jsx(Z,{size:48,className:"text-white"}):e.jsx(G,{size:48,className:"text-white"})}),e.jsx("h2",{className:"text-3xl font-bold font-display text-[#0a1628] mb-2",children:"Assessment Complete!"}),e.jsxs("p",{className:"text-[#5a6578] mb-6",children:["Great job, ",k,"! Your personalized learning path is ready."]}),e.jsxs("div",{className:"bg-gradient-to-br from-[#1FA7E1]/10 to-[#6ED1CF]/10 rounded-2xl p-5 mb-5",children:[e.jsxs("div",{className:"text-sm text-[#5a6578] mb-2",children:["You answered ",d.length," questions"]}),e.jsx("div",{className:"text-xs text-[#5a6578]",children:"Results will be available shortly..."})]}),e.jsx("p",{className:"text-xs text-slate-400 mb-4",children:"Redirecting to dashboard..."})]})})]})})};export{we as default}; + */const ee=[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],se=Y("minimize-2",ee),we=({testId:k,questions:u,userName:S,onComplete:_,onCancel:z})=>{const[h,b]=n.useState("testing"),[l,E]=n.useState(0),[i,g]=n.useState(null),[d,C]=n.useState(()=>{try{const s=sessionStorage.getItem("mathpulse_diagnostic_responses");return s?JSON.parse(s):[]}catch{return[]}}),[w,D]=n.useState([]),[F,A]=n.useState(0),[j,v]=n.useState(null),[y,p]=n.useState(!1),o=n.useRef(null),f=n.useRef(Date.now()),c=u.length,m=u[l],M=Math.round((l+(i?1:0))/c*100),[I]=n.useState(Array.from({length:10},(s,t)=>({id:t,size:Math.random()*80+30,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*20+15,delay:Math.random()*-20,color:["bg-purple-500/10","bg-blue-500/10","bg-cyan-500/10","bg-emerald-500/10"][Math.floor(Math.random()*4)]}))),N=n.useCallback(()=>{f.current=Date.now(),o.current&&clearInterval(o.current),o.current=setInterval(()=>{A(Math.floor((Date.now()-f.current)/1e3))},200)},[]);n.useEffect(()=>(N(),()=>{o.current&&clearInterval(o.current)}),[l,N]);const R=n.useCallback(()=>{const s=document.getElementById("assessment-container");s&&(document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen().then(()=>{p(!1)}).catch(t=>{console.error("Exit fullscreen error:",t)}):s.requestFullscreen().then(()=>{p(!0)}).catch(t=>{console.error("Fullscreen error:",t)}))},[]);n.useEffect(()=>{const s=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",s),()=>document.removeEventListener("fullscreenchange",s)},[]);const B=s=>{g(s)},T=()=>{if(!i)return;o.current&&clearInterval(o.current);const s=Math.floor((Date.now()-f.current)/1e3),t=[...w,!0],r=[...d,{question_id:m.question_id,student_answer:i,time_spent_seconds:s}];D(t),C(r),g(null),lx+1):$(r)},$=async s=>{b("submitting"),v(null);try{sessionStorage.setItem("mathpulse_diagnostic_responses",JSON.stringify(s))}catch{}try{const t=await Q(k,s);sessionStorage.removeItem("mathpulse_diagnostic"),sessionStorage.removeItem("mathpulse_diagnostic_responses"),b("results"),setTimeout(()=>{_({overallRisk:t.overall_risk,overallScorePercent:t.overall_score_percent,intervention:t.recommended_intervention,xpEarned:t.xp_earned,badgeUnlocked:t.badge_unlocked})},3e3)}catch(t){const r=t instanceof Error?t.message:"Submission failed. Your answers are saved locally.";v(r)}},q=s=>{const t=Math.floor(s/60),r=s%60;return`${t}:${r.toString().padStart(2,"0")}`},L=["A","B","C","D"];return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-md flex items-center justify-center p-4 sm:p-6 overflow-hidden",children:e.jsxs("div",{id:"assessment-container",className:"bg-white/95 backdrop-blur-xl border border-white/20 rounded-3xl shadow-[0_0_50px_rgba(0,0,0,0.3)] w-full max-w-4xl h-[95vh] sm:h-[90vh] md:h-[85vh] flex flex-col relative z-10 overflow-hidden transition-all duration-300",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:I.map(s=>e.jsx(a.div,{className:`absolute rounded-full blur-3xl ${s.color.replace("/10","/30")}`,style:{width:s.size*1.5,height:s.size*1.5,left:`${s.x}%`,top:`${s.y}%`},animate:{x:[0,Math.random()*100-50,0],y:[0,Math.random()*100-50,0],scale:[1,1.3,1]},transition:{duration:s.duration,repeat:1/0,ease:"linear",delay:s.delay}},s.id))}),e.jsxs(a.div,{className:"shrink-0 text-white border-b border-white/10 shadow-md relative z-10",style:{backgroundColor:"#9956DE"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 md:p-6",children:[e.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl font-bold truncate",children:"Diagnostic Assessment"}),e.jsxs("p",{className:"text-white/80 text-xs sm:text-sm font-medium truncate",children:[m.domain," • ",m.difficulty]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:R,className:"w-9 h-9 sm:w-10 sm:h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",title:y?"Exit Fullscreen":"Enter Fullscreen",children:y?e.jsx(se,{size:18}):e.jsx(H,{size:18})}),e.jsx("button",{onClick:z,className:"w-9 h-9 sm:w-10 sm:h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",children:e.jsx(W,{size:20})})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 md:px-6 pb-3 sm:pb-4 md:pb-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"bg-white/20 px-3 py-1 rounded-full flex items-center gap-1",children:[e.jsx(J,{size:16}),e.jsxs("span",{className:"font-bold text-sm",children:[d.length," / ",c]})]})}),e.jsxs("div",{className:"flex items-center gap-1 bg-white/20 px-3 py-1 rounded-full",children:[e.jsx(X,{size:16}),e.jsx("span",{className:"font-bold text-sm",children:q(F)})]})]}),e.jsxs("div",{className:"px-4 sm:px-5 md:px-6 pb-3 sm:pb-4 md:pb-5",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Question ",l+1," of ",c]}),e.jsxs("span",{className:"text-sm font-bold",children:[M,"%"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:u.map((s,t)=>{let r="bg-white/30";return t{const t=m.options[s];if(!t)return null;const r=i===s;let x="bg-[#edf1f7] hover:bg-[#dde3eb] border-[#dde3eb]";return r&&(x="bg-purple-50 border-[#9956DE]"),e.jsx(a.button,{whileHover:{scale:1.01},whileTap:{scale:.99},onClick:()=>B(s),className:`w-full text-left p-2.5 sm:p-3 md:p-4 rounded-xl border-2 transition-all ${x} cursor-pointer shadow-sm hover:shadow-md flex items-center min-h-[3rem] sm:min-h-[4rem] md:min-h-[5rem]`,children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 w-full min-w-0",children:[e.jsx("div",{className:`w-8 h-8 sm:w-10 sm:h-10 rounded-xl shrink-0 flex items-center justify-center font-bold text-sm sm:text-base ${r?"bg-[#9956DE] text-white shadow-inner":"bg-white text-[#0a1628] shadow-sm"}`,children:s}),e.jsx("span",{className:"font-semibold text-[#0a1628] text-xs sm:text-sm md:text-base break-words",children:t}),r&&e.jsx(K,{size:18,className:"ml-auto text-[#9956DE] flex-shrink-0"})]})},s)})})]},l)})}),e.jsx("div",{className:"p-4 sm:p-5 md:p-6 bg-[#edf1f7] border-t border-[#dde3eb]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-[#5a6578]",children:i?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(U,{size:16}),"Ready for the next one!"]}):e.jsx("span",{children:"Select an answer to continue"})}),e.jsxs(P,{onClick:T,disabled:!i,className:`font-bold px-6 py-2.5 sm:py-3 rounded-xl flex items-center gap-2 transition-all shadow-md hover:shadow-lg text-sm ${i?"bg-[#9956DE] hover:bg-[#8850CE] text-white shadow-[#9956DE]/20":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[l=c*.7?"bg-gradient-to-br from-[#75D06A] to-[#6ED1CF]":"bg-gradient-to-br from-[#FFB356] to-[#FF8B8B]"}`,children:d.length>=c*.7?e.jsx(Z,{size:48,className:"text-white"}):e.jsx(G,{size:48,className:"text-white"})}),e.jsx("h2",{className:"text-3xl font-bold font-display text-[#0a1628] mb-2",children:"Assessment Complete!"}),e.jsxs("p",{className:"text-[#5a6578] mb-6",children:["Great job, ",S,"! Your personalized learning path is ready."]}),e.jsxs("div",{className:"bg-gradient-to-br from-[#1FA7E1]/10 to-[#6ED1CF]/10 rounded-2xl p-5 mb-5",children:[e.jsxs("div",{className:"text-sm text-[#5a6578] mb-2",children:["You answered ",d.length," questions"]}),e.jsx("div",{className:"text-xs text-[#5a6578]",children:"Results will be available shortly..."})]}),e.jsx("p",{className:"text-xs text-slate-400 mb-4",children:"Redirecting to dashboard..."})]})})]})})};export{we as default}; diff --git a/assets/AvatarShop-AFWgueuK.js b/assets/AvatarShop-CAPwOQHq.js similarity index 89% rename from assets/AvatarShop-AFWgueuK.js rename to assets/AvatarShop-CAPwOQHq.js index 957d421c1e85eaa2b12e26b1485c2598223403f8..400358346aacbee6640154c2499abdd89e52dd3f 100644 --- a/assets/AvatarShop-AFWgueuK.js +++ b/assets/AvatarShop-CAPwOQHq.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-xDOIcVzp.js";import{c as S,l as le,L as w,Y as R,m as y,g as ie,n as c,aH as ne,aI as ce}from"./index-mbyiCUYG.js";import{u as de}from"./useFeatureAccess-CbliO-_q.js";import{T as me,a as ue,b as xe}from"./tooltip-Cd2m83Wr.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-DgO_wXsk.js";import{S as V}from"./sparkles-THbTTiEe.js";import{S as fe}from"./shirt-nq7Lov7c.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-charts-Ckgeb0nY.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,a0 as R,m as y,k as ie,l as c,aJ as ne,aK as ce}from"./index-B3ruOzo6.js";import{u as de}from"./useFeatureAccess-CSvNejlY.js";import{T as me,a as ue,b as xe}from"./tooltip-CLSYbTYK.js";import{C as pe}from"./CompositeAvatar-Col05lJc.js";import{M as j}from"./avatarData-BuQSOXo3.js";import{S as O}from"./save-DXz2z5YH.js";import{S as V}from"./sparkles-Bq0AaIRg.js";import{S as fe}from"./shirt-BBR3GIpi.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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. @@ -28,4 +28,4 @@ import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{e as se,L as ae,g a .animate-spin-slow { animation: spin-slow 1s linear infinite; } -`,X=["Wow!","Cute!","I love it!","Perfect!","So cool!","Awesome!"],q=["Gain more XP to buy me more clothes!","Help me get stylish!","Let's earn some XP to unlock more!","I'd love to try on more outfits!","Keep learning to unlock new looks!"],Y="top_blue",F="mathpulse:avatar-inventory:v2",je=600*1e3,Ne=2e4,Ye=({onSaveProfile:k,onNavigateToModules:U})=>{const{userProfile:l,refreshProfile:$,currentUser:D}=le(),{cosmeticShop:H,loading:B}=de(D?.uid||null),G=!1,[m,A]=i.useState({top:l?.avatarLayers?.top??Y,bottom:l?.avatarLayers?.bottom||"",shoes:l?.avatarLayers?.shoes||"",accessory:l?.avatarLayers?.accessory||""}),[x,p]=i.useState(!1),[f,E]=i.useState([]),[K,T]=i.useState(0),[I,_]=i.useState(null),[d,h]=i.useState(null),[P,z]=i.useState(j),[Z,J]=i.useState("top"),C=i.useRef(l);C.current=l;const b=i.useRef(!1),v=i.useRef(null);i.useEffect(()=>{if(typeof window>"u")return;const t=Date.now();try{const o=sessionStorage.getItem(F);if(o){const s=JSON.parse(o);if(Array.isArray(s.items)&&typeof s.expiresAt=="number"&&s.expiresAt>t){z(s.items);return}}}catch{}z(j);try{sessionStorage.setItem(F,JSON.stringify({expiresAt:t+je,items:j}))}catch{}},[]),i.useEffect(()=>{if(l&&l.role==="student"){const t=l;E(t.ownedAvatarItems||[]),T(t.currentXP||0)}},[l]),i.useEffect(()=>{A({top:l?.avatarLayers?.top??Y,bottom:l?.avatarLayers?.bottom||"",shoes:l?.avatarLayers?.shoes||"",accessory:l?.avatarLayers?.accessory||""})},[]),i.useEffect(()=>{if(!d){const t=setInterval(()=>{Math.random()>.6&&h(q[Math.floor(Math.random()*q.length)])},4e3);return()=>clearInterval(t)}},[d]),i.useEffect(()=>{if(d){const t=setTimeout(()=>{h(null)},3500);return()=>clearTimeout(t)}},[d]);const W=(t,o)=>{const s=P.find(n=>n.id===o);if(s&&(s.price&&s.price>0||s.isReward)&&!f.includes(o)){c.error("This item is locked. Earn or purchase it first!");return}const a={...m,[t]:m[t]===o?"":o};A(a),h(X[Math.floor(Math.random()*X.length)]),g(a,{showSuccessToast:!1,showSavingState:!1})},Q=async(t,o,s)=>{if(t.stopPropagation(),!l?.uid){c.error("You must be logged in to purchase items");return}if(f.includes(o)){c.info("You already own this item");return}_(o);try{const a=await ne(l.uid,o,s);a.success?(c.success(a.message||"Item purchased!"),E(n=>[...n,o]),a.currentXP!==void 0&&T(a.currentXP),await $()):c.error(a.message||"Failed to purchase item")}catch(a){console.error("Purchase error:",a),c.error("Error purchasing item")}finally{_(null)}},L=t=>({top:typeof t.top=="string"?t.top:"",bottom:typeof t.bottom=="string"?t.bottom:"",shoes:typeof t.shoes=="string"?t.shoes:"",accessory:typeof t.accessory=="string"?t.accessory:""}),ee=(t,o,s)=>{let a;const n=new Promise((r,u)=>{a=setTimeout(()=>{u(new Error(`${s} timed out after ${Math.round(o/1e3)}s`))},o)});return Promise.race([t,n]).finally(()=>{a!==void 0&&clearTimeout(a)})},g=async(t,o={})=>{const s=C.current;if(!s?.uid)return;const{showSuccessToast:a=!0,showSavingState:n=!0}=o;if(b.current){v.current={layers:L(t),options:{showSuccessToast:a,showSavingState:n}},n&&p(!0);return}b.current=!0,n&&p(!0);try{const r=L(t);await ee(ce(s.uid,{avatarLayers:r}),Ne,"Avatar save"),k&&k(r),a&&c.success("Avatar saved successfully")}catch(r){if(console.error(r),a){const u=r instanceof Error&&r.message.includes("timed out");c.error(u?"Avatar save timed out. Please try again.":"Failed to save avatar")}}finally{const r=v.current;if(v.current=null,b.current=!1,r){g(r.layers,r.options);return}(n||x)&&p(!1)}},te=async()=>{await g(m,{showSuccessToast:!0,showSavingState:!0})},M=[{id:"top",label:"Tops",icon:e.jsx(fe,{size:16})},{id:"bottom",label:"Bottoms",icon:e.jsx(ge,{size:16,className:"rotate-90"})},{id:"shoes",label:"Shoes",icon:e.jsx(be,{size:16})},{id:"accessory",label:"Accessories",icon:e.jsx(R,{size:16})}];return B?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx("div",{className:"animate-spin",children:e.jsx(O,{size:24,className:"opacity-50"})}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading..."})]}):H?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ye}),e.jsx("div",{className:"h-full w-full flex items-start xl:items-center justify-center p-4 sm:p-6 lg:p-8 overflow-y-auto xl:overflow-hidden",children:e.jsxs("div",{className:"relative w-full max-w-[1000px] min-h-[500px] xl:h-[80vh] xl:max-h-[700px] rounded-[2rem] p-6 lg:p-8 bg-gradient-to-br from-white via-sky-50/30 to-white border border-slate-200/80 shadow-[0_8px_30px_rgb(0,0,0,0.04)] flex flex-col xl:flex-row gap-8 xl:gap-12 overflow-visible xl:overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden 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/30 to-transparent"}),e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 bg-blue-100/40 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 bg-purple-100/30 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"flex flex-col xl:h-full min-h-0 relative z-10 w-full xl:w-[50%] mx-auto xl:mx-0 flex-1",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-2 shrink-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between xl:justify-start gap-4",children:[e.jsxs("h1",{className:"text-3xl md:text-4xl font-display font-black text-[#0a1628] tracking-tight flex items-center gap-2.5",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Avatar Studio"})," ",e.jsx(V,{className:"text-blue-500 fill-blue-500",size:28})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[G,e.jsxs("div",{className:"bg-gradient-to-br from-amber-400 to-orange-500 rounded-xl px-3 py-1.5 shadow-md flex items-center gap-2 h-fit",children:[e.jsx(N,{className:"text-white shrink-0",size:16}),e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{onClick:U,className:"cursor-pointer hover:opacity-90 transition-opacity active:scale-95 text-left",children:[e.jsx("p",{className:"text-white text-[9px] font-bold uppercase tracking-wider leading-none mb-0.5",children:"XP Balance"}),e.jsx("p",{className:"text-white text-base font-black leading-none",children:K})]})}),e.jsx(xe,{side:"bottom",className:"bg-slate-900 text-white border border-slate-700",children:"Review more lessons to earn more XP!"})]})]})]})]}),e.jsx("p",{className:"text-slate-500 font-medium text-sm md:text-base",children:"Design your perfect learning companion."})]}),e.jsxs(se,{value:Z,onValueChange:t=>J(t),className:"flex flex-col flex-1 min-h-0",children:[e.jsx(ae,{className:"flex flex-nowrap shrink-0 justify-start space-x-1 sm:space-x-2 mb-4 bg-white shadow-sm p-1 rounded-full border border-slate-100 w-fit overflow-x-auto max-w-full scrollbar-hide",children:M.map(t=>e.jsxs(re,{value:t.id,className:"flex items-center gap-1.5 px-4 py-2 rounded-full font-bold text-[13px] text-slate-500 hover:bg-slate-50 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-600 data-[state=active]:to-sky-500 data-[state=active]:text-white transition-all shadow-sm outline-none whitespace-nowrap",children:[t.icon,t.label]},t.id))}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden min-h-0 pb-6 scrollbar-hide px-2 -mx-2",children:M.map(t=>{const o=P.filter(s=>s.category===t.id);return e.jsx(oe,{value:t.id,className:"outline-none pt-2 h-full",children:o.length===0?e.jsxs("div",{className:"w-full h-full min-h-[250px] flex flex-col items-center justify-center border-2 border-dashed border-slate-200 rounded-[2rem] bg-slate-50/50 p-8 text-center",children:[e.jsx(R,{size:48,className:"text-slate-300 mb-4 opacity-50"}),e.jsx("h3",{className:"font-bold text-xl text-slate-500 mb-2",children:"Accessories coming soon"}),e.jsx("p",{className:"text-slate-400 text-sm max-w-xs",children:"We're crafting some awesome gear for your avatar! Check back later."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 lg:gap-6",children:o.map(s=>{const a=m[t.id]===s.id,n=f.includes(s.id),r=!!((s.price&&s.price>0||s.isReward)&&!n);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{onClick:()=>!r&&W(t.id,s.id),disabled:r,className:`relative w-full aspect-square rounded-2xl border-2 transition-all flex flex-col items-center justify-center group ${a&&!r?"bg-white border-blue-500 shadow-md scale-[1.02] z-10":r?"bg-slate-50 border-slate-200 opacity-50 cursor-not-allowed":"bg-white border-slate-100 hover:border-sky-300 hover:shadow-lg hover:scale-[1.02] hover:z-10"}`,children:[a&&!r&&e.jsxs("div",{className:"absolute top-1.5 left-1/2 -translate-x-1/2 px-1.5 py-0.5 bg-gradient-to-r from-blue-500 to-sky-400 text-white text-[9px] font-black rounded-full flex items-center gap-1 z-10 whitespace-nowrap",children:["Equipped ",e.jsx(V,{size:9,className:"fill-white"})]}),r&&e.jsx("div",{className:"absolute inset-0 bg-black/20 z-20 flex items-center justify-center rounded-[1rem]",children:e.jsx(w,{className:"text-white",size:24})}),e.jsx("img",{src:s.thumbnail,alt:s.name,className:`w-3/4 h-3/4 object-contain transition-transform e-filter ${!r&&"group-hover:scale-110"}`,style:{"--filter":r?"grayscale(70%)":"none"}})]}),e.jsx("p",{className:"text-xs font-bold text-slate-700 text-center line-clamp-2",children:s.name}),r&&(s.isReward?e.jsxs("div",{className:"w-full py-1 bg-slate-200 text-slate-500 text-[9px] font-bold flex items-center justify-center gap-1 rounded shadow-sm border border-slate-300",children:[e.jsx(w,{size:11})," Exclusive Reward"]}):e.jsx(y.button,{initial:{opacity:0},animate:{opacity:1},onClick:u=>Q(u,s.id,s.price||0),disabled:I===s.id,className:"w-full py-1 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white text-[9px] font-bold flex items-center justify-center gap-1 rounded shadow-sm transition-all disabled:opacity-70",children:I===s.id?e.jsx(y.div,{animate:{rotate:360},transition:{repeat:1/0,duration:1},children:e.jsx(N,{size:11})}):e.jsxs(e.Fragment,{children:[e.jsx(N,{size:11}),s.price," XP"]})}))]},s.id)})})},t.id)})})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 relative z-10 w-full xl:w-[350px] max-w-[420px] xl:max-w-none shrink-0 xl:self-center mx-auto xl:mx-0",children:[e.jsxs("div",{className:"bg-[#0f1422] rounded-[2rem] overflow-hidden relative shadow-[0_20px_50px_rgba(15,20,34,0.2)] h-[400px] w-full flex items-center justify-center mx-auto border-4 border-slate-800",children:[e.jsx("div",{className:"absolute top-[-10%] left-0 right-0 h-[110%] pointer-events-none mix-blend-screen opacity-70 avatar-gloss"}),e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 w-[220px] h-[25px] bg-sky-500/20 blur-xl rounded-full"}),e.jsxs("div",{className:"relative w-full h-[80%] z-10 flex justify-center items-center animate-avatar-float",children:[e.jsx(pe,{layers:m,className:"w-full h-full absolute inset-0 z-20"}),e.jsx(ie,{children:d&&e.jsxs(y.div,{initial:{opacity:0,y:-10,scale:.8},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.8},transition:{duration:.3},className:"absolute -top-24 left-1/2 -translate-x-1/2 z-30 bg-white text-slate-800 px-4 py-2 rounded-full shadow-lg border-2 border-sky-300 whitespace-nowrap font-bold text-sm max-w-xs text-center",children:[d,e.jsx("div",{className:"absolute -bottom-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-white"})]})})]})]}),e.jsxs("button",{onClick:te,disabled:x,className:"w-full max-w-[450px] mx-auto h-[54px] bg-blue-600 hover:bg-blue-500 text-white rounded-xl font-bold text-base flex items-center justify-center gap-2 transition-colors shadow-md disabled:opacity-70 disabled:cursor-not-allowed active:scale-[0.98]",children:[x?e.jsx("div",{className:"animate-spin-slow",children:e.jsx(O,{size:24,className:"opacity-50"})}):null,x?"Saving...":"Save Profile Avatar"]})]})]})})]}):e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(w,{className:"w-7 h-7 text-slate-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Avatar Shop Locked"}),e.jsx("p",{className:"text-xs text-slate-400",children:"This feature is temporarily unavailable while you focus on your learning."})]})]})};export{Ye as default}; +`,X=["Wow!","Cute!","I love it!","Perfect!","So cool!","Awesome!"],q=["Gain more XP to buy me more clothes!","Help me get stylish!","Let's earn some XP to unlock more!","I'd love to try on more outfits!","Keep learning to unlock new looks!"],Y="top_blue",F="mathpulse:avatar-inventory:v2",je=600*1e3,Ne=2e4,Ye=({onSaveProfile:k,onNavigateToModules:U})=>{const{userProfile:l,refreshProfile:$,currentUser:D}=le(),{cosmeticShop:B,loading:H}=de(D?.uid||null),K=!1,[m,A]=i.useState({top:l?.avatarLayers?.top??Y,bottom:l?.avatarLayers?.bottom||"",shoes:l?.avatarLayers?.shoes||"",accessory:l?.avatarLayers?.accessory||""}),[x,p]=i.useState(!1),[f,E]=i.useState([]),[G,T]=i.useState(0),[_,I]=i.useState(null),[d,h]=i.useState(null),[P,z]=i.useState(j),[J,Z]=i.useState("top"),C=i.useRef(l);C.current=l;const b=i.useRef(!1),v=i.useRef(null);i.useEffect(()=>{if(typeof window>"u")return;const t=Date.now();try{const o=sessionStorage.getItem(F);if(o){const s=JSON.parse(o);if(Array.isArray(s.items)&&typeof s.expiresAt=="number"&&s.expiresAt>t){z(s.items);return}}}catch{}z(j);try{sessionStorage.setItem(F,JSON.stringify({expiresAt:t+je,items:j}))}catch{}},[]),i.useEffect(()=>{if(l&&l.role==="student"){const t=l;E(t.ownedAvatarItems||[]),T(t.currentXP||0)}},[l]),i.useEffect(()=>{A({top:l?.avatarLayers?.top??Y,bottom:l?.avatarLayers?.bottom||"",shoes:l?.avatarLayers?.shoes||"",accessory:l?.avatarLayers?.accessory||""})},[]),i.useEffect(()=>{if(!d){const t=setInterval(()=>{Math.random()>.6&&h(q[Math.floor(Math.random()*q.length)])},4e3);return()=>clearInterval(t)}},[d]),i.useEffect(()=>{if(d){const t=setTimeout(()=>{h(null)},3500);return()=>clearTimeout(t)}},[d]);const W=(t,o)=>{const s=P.find(n=>n.id===o);if(s&&(s.price&&s.price>0||s.isReward)&&!f.includes(o)){c.error("This item is locked. Earn or purchase it first!");return}const a={...m,[t]:m[t]===o?"":o};A(a),h(X[Math.floor(Math.random()*X.length)]),g(a,{showSuccessToast:!1,showSavingState:!1})},Q=async(t,o,s)=>{if(t.stopPropagation(),!l?.uid){c.error("You must be logged in to purchase items");return}if(f.includes(o)){c.info("You already own this item");return}I(o);try{const a=await ne(l.uid,o,s);a.success?(c.success(a.message||"Item purchased!"),E(n=>[...n,o]),a.currentXP!==void 0&&T(a.currentXP),await $()):c.error(a.message||"Failed to purchase item")}catch(a){console.error("Purchase error:",a),c.error("Error purchasing item")}finally{I(null)}},L=t=>({top:typeof t.top=="string"?t.top:"",bottom:typeof t.bottom=="string"?t.bottom:"",shoes:typeof t.shoes=="string"?t.shoes:"",accessory:typeof t.accessory=="string"?t.accessory:""}),ee=(t,o,s)=>{let a;const n=new Promise((r,u)=>{a=setTimeout(()=>{u(new Error(`${s} timed out after ${Math.round(o/1e3)}s`))},o)});return Promise.race([t,n]).finally(()=>{a!==void 0&&clearTimeout(a)})},g=async(t,o={})=>{const s=C.current;if(!s?.uid)return;const{showSuccessToast:a=!0,showSavingState:n=!0}=o;if(b.current){v.current={layers:L(t),options:{showSuccessToast:a,showSavingState:n}},n&&p(!0);return}b.current=!0,n&&p(!0);try{const r=L(t);await ee(ce(s.uid,{avatarLayers:r}),Ne,"Avatar save"),k&&k(r),a&&c.success("Avatar saved successfully")}catch(r){if(console.error(r),a){const u=r instanceof Error&&r.message.includes("timed out");c.error(u?"Avatar save timed out. Please try again.":"Failed to save avatar")}}finally{const r=v.current;if(v.current=null,b.current=!1,r){g(r.layers,r.options);return}(n||x)&&p(!1)}},te=async()=>{await g(m,{showSuccessToast:!0,showSavingState:!0})},M=[{id:"top",label:"Tops",icon:e.jsx(fe,{size:16})},{id:"bottom",label:"Bottoms",icon:e.jsx(ge,{size:16,className:"rotate-90"})},{id:"shoes",label:"Shoes",icon:e.jsx(be,{size:16})},{id:"accessory",label:"Accessories",icon:e.jsx(R,{size:16})}];return H?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx("div",{className:"animate-spin",children:e.jsx(O,{size:24,className:"opacity-50"})}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading..."})]}):B?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ye}),e.jsx("div",{className:"h-full w-full flex items-start xl:items-center justify-center p-4 sm:p-6 lg:p-8 overflow-y-auto xl:overflow-hidden",children:e.jsxs("div",{className:"relative w-full max-w-[1000px] min-h-[500px] xl:h-[80vh] xl:max-h-[700px] rounded-[2rem] p-6 lg:p-8 bg-gradient-to-br from-white via-sky-50/30 to-white border border-slate-200/80 shadow-[0_8px_30px_rgb(0,0,0,0.04)] flex flex-col xl:flex-row gap-8 xl:gap-12 overflow-visible xl:overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden 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/30 to-transparent"}),e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 bg-blue-100/40 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 bg-purple-100/30 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"flex flex-col xl:h-full min-h-0 relative z-10 w-full xl:w-[50%] mx-auto xl:mx-0 flex-1",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-2 shrink-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between xl:justify-start gap-4",children:[e.jsxs("h1",{className:"text-3xl md:text-4xl font-display font-black text-[#0a1628] tracking-tight flex items-center gap-2.5",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Avatar Studio"})," ",e.jsx(V,{className:"text-blue-500 fill-blue-500",size:28})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[K,e.jsxs("div",{className:"bg-gradient-to-br from-amber-400 to-orange-500 rounded-xl px-3 py-1.5 shadow-md flex items-center gap-2 h-fit",children:[e.jsx(N,{className:"text-white shrink-0",size:16}),e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{onClick:U,className:"cursor-pointer hover:opacity-90 transition-opacity active:scale-95 text-left",children:[e.jsx("p",{className:"text-white text-[9px] font-bold uppercase tracking-wider leading-none mb-0.5",children:"XP Balance"}),e.jsx("p",{className:"text-white text-base font-black leading-none",children:G})]})}),e.jsx(xe,{side:"bottom",className:"bg-slate-900 text-white border border-slate-700",children:"Review more lessons to earn more XP!"})]})]})]})]}),e.jsx("p",{className:"text-slate-500 font-medium text-sm md:text-base",children:"Design your perfect learning companion."})]}),e.jsxs(se,{value:J,onValueChange:t=>Z(t),className:"flex flex-col flex-1 min-h-0",children:[e.jsx(ae,{className:"flex flex-nowrap shrink-0 justify-start space-x-1 sm:space-x-2 mb-4 bg-white shadow-sm p-1 rounded-full border border-slate-100 w-fit overflow-x-auto max-w-full scrollbar-hide",children:M.map(t=>e.jsxs(re,{value:t.id,className:"flex items-center gap-1.5 px-4 py-2 rounded-full font-bold text-[13px] text-slate-500 hover:bg-slate-50 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-600 data-[state=active]:to-sky-500 data-[state=active]:text-white transition-all shadow-sm outline-none whitespace-nowrap",children:[t.icon,t.label]},t.id))}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden min-h-0 pb-6 scrollbar-hide px-2 -mx-2",children:M.map(t=>{const o=P.filter(s=>s.category===t.id);return e.jsx(oe,{value:t.id,className:"outline-none pt-2 h-full",children:o.length===0?e.jsxs("div",{className:"w-full h-full min-h-[250px] flex flex-col items-center justify-center border-2 border-dashed border-slate-200 rounded-[2rem] bg-slate-50/50 p-8 text-center",children:[e.jsx(R,{size:48,className:"text-slate-300 mb-4 opacity-50"}),e.jsx("h3",{className:"font-bold text-xl text-slate-500 mb-2",children:"Accessories coming soon"}),e.jsx("p",{className:"text-slate-400 text-sm max-w-xs",children:"We're crafting some awesome gear for your avatar! Check back later."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 lg:gap-6",children:o.map(s=>{const a=m[t.id]===s.id,n=f.includes(s.id),r=!!((s.price&&s.price>0||s.isReward)&&!n);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{onClick:()=>!r&&W(t.id,s.id),disabled:r,className:`relative w-full aspect-square rounded-2xl border-2 transition-all flex flex-col items-center justify-center group ${a&&!r?"bg-white border-blue-500 shadow-md scale-[1.02] z-10":r?"bg-slate-50 border-slate-200 opacity-50 cursor-not-allowed":"bg-white border-slate-100 hover:border-sky-300 hover:shadow-lg hover:scale-[1.02] hover:z-10"}`,children:[a&&!r&&e.jsxs("div",{className:"absolute top-1.5 left-1/2 -translate-x-1/2 px-1.5 py-0.5 bg-gradient-to-r from-blue-500 to-sky-400 text-white text-[9px] font-black rounded-full flex items-center gap-1 z-10 whitespace-nowrap",children:["Equipped ",e.jsx(V,{size:9,className:"fill-white"})]}),r&&e.jsx("div",{className:"absolute inset-0 bg-black/20 z-20 flex items-center justify-center rounded-[1rem]",children:e.jsx(w,{className:"text-white",size:24})}),e.jsx("img",{src:s.thumbnail,alt:s.name,className:`w-3/4 h-3/4 object-contain transition-transform e-filter ${!r&&"group-hover:scale-110"}`,style:{"--filter":r?"grayscale(70%)":"none"}})]}),e.jsx("p",{className:"text-xs font-bold text-slate-700 text-center line-clamp-2",children:s.name}),r&&(s.isReward?e.jsxs("div",{className:"w-full py-1 bg-slate-200 text-slate-500 text-[9px] font-bold flex items-center justify-center gap-1 rounded shadow-sm border border-slate-300",children:[e.jsx(w,{size:11})," Exclusive Reward"]}):e.jsx(y.button,{initial:{opacity:0},animate:{opacity:1},onClick:u=>Q(u,s.id,s.price||0),disabled:_===s.id,className:"w-full py-1 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white text-[9px] font-bold flex items-center justify-center gap-1 rounded shadow-sm transition-all disabled:opacity-70",children:_===s.id?e.jsx(y.div,{animate:{rotate:360},transition:{repeat:1/0,duration:1},children:e.jsx(N,{size:11})}):e.jsxs(e.Fragment,{children:[e.jsx(N,{size:11}),s.price," XP"]})}))]},s.id)})})},t.id)})})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 relative z-10 w-full xl:w-[350px] max-w-[420px] xl:max-w-none shrink-0 xl:self-center mx-auto xl:mx-0",children:[e.jsxs("div",{className:"bg-[#0f1422] rounded-[2rem] overflow-hidden relative shadow-[0_20px_50px_rgba(15,20,34,0.2)] h-[400px] w-full flex items-center justify-center mx-auto border-4 border-slate-800",children:[e.jsx("div",{className:"absolute top-[-10%] left-0 right-0 h-[110%] pointer-events-none mix-blend-screen opacity-70 avatar-gloss"}),e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 w-[220px] h-[25px] bg-sky-500/20 blur-xl rounded-full"}),e.jsxs("div",{className:"relative w-full h-[80%] z-10 flex justify-center items-center animate-avatar-float",children:[e.jsx(pe,{layers:m,className:"w-full h-full absolute inset-0 z-20"}),e.jsx(ie,{children:d&&e.jsxs(y.div,{initial:{opacity:0,y:-10,scale:.8},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.8},transition:{duration:.3},className:"absolute -top-24 left-1/2 -translate-x-1/2 z-30 bg-white text-slate-800 px-4 py-2 rounded-full shadow-lg border-2 border-sky-300 whitespace-nowrap font-bold text-sm max-w-xs text-center",children:[d,e.jsx("div",{className:"absolute -bottom-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-white"})]})})]})]}),e.jsxs("button",{onClick:te,disabled:x,className:"w-full max-w-[450px] mx-auto h-[54px] bg-blue-600 hover:bg-blue-500 text-white rounded-xl font-bold text-base flex items-center justify-center gap-2 transition-colors shadow-md disabled:opacity-70 disabled:cursor-not-allowed active:scale-[0.98]",children:[x?e.jsx("div",{className:"animate-spin-slow",children:e.jsx(O,{size:24,className:"opacity-50"})}):null,x?"Saving...":"Save Profile Avatar"]})]})]})})]}):e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(w,{className:"w-7 h-7 text-slate-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Avatar Shop Locked"}),e.jsx("p",{className:"text-xs text-slate-400",children:"This feature is temporarily unavailable while you focus on your learning."})]})]})};export{Ye as default}; diff --git a/assets/ChatMarkdown-vDoOnX8q.js b/assets/ChatMarkdown-BWVWW9Zs.js similarity index 92% rename from assets/ChatMarkdown-vDoOnX8q.js rename to assets/ChatMarkdown-BWVWW9Zs.js index 14d9db8971490549fc9686d2c82057a363f3b3d8..5829efb5317dc0ff179d38ca787b6954b49b4409 100644 --- a/assets/ChatMarkdown-vDoOnX8q.js +++ b/assets/ChatMarkdown-BWVWW9Zs.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{b1 as d,_ as c}from"./index-mbyiCUYG.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-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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{b1 as d,_ as c}from"./index-B3ruOzo6.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-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-CB4_VQS8.js b/assets/CompetencyRadarChart-C3fx_ulE.js similarity index 89% rename from assets/CompetencyRadarChart-CB4_VQS8.js rename to assets/CompetencyRadarChart-C3fx_ulE.js index a0e648a313722146109f2931e5df71e272a8450f..175756b88fc37562d43883c99d124bf87a7b2255 100644 --- a/assets/CompetencyRadarChart-CB4_VQS8.js +++ b/assets/CompetencyRadarChart-C3fx_ulE.js @@ -1 +1 @@ -import{r as g,j as t}from"./vendor-react-B4AQeu28.js";import{h as A,a5 as P,l as B,m as L,B as O,R as W,a as H}from"./index-mbyiCUYG.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-CP9q7ISf.js";import{g as X,s as Y}from"./subjects-BGUwH4Kn.js";import{S as Z}from"./sparkles-THbTTiEe.js";import{R as ee,e as te,P as se,f as ne,g as ae,h as oe,T as re}from"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B4tQNTpN.js";const I=["#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,C=y?.quizzes?.length||1,z=Math.min(100,f/x*100),k=Math.min(100,N/C*100),v=Math.min(100,(z+k+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",k=Y.find(j=>j.id===z)?.modules||[],v=k.map((j,S)=>({id:j.id,name:j.title.length>15?j.title.substring(0,15).trim()+"...":j.title,color:I[S%I.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,k,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(C=>{const z=P(a,k=>{z(),C(k)})});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=P(a,x=>{const C=++f.current;N(x,C)});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,a7 as I,u as B,m as L,B as O,R as W,a as H}from"./index-B3ruOzo6.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-CP9q7ISf.js";import{g as X,s as Y}from"./subjects-DEj_AlYz.js";import{S as Z}from"./sparkles-Bq0AaIRg.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-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-C9VTl-3A.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-BsY1WFdG.js b/assets/ConfirmModal-BjVnuYqC.js similarity index 89% rename from assets/ConfirmModal-BsY1WFdG.js rename to assets/ConfirmModal-BjVnuYqC.js index 367d99890c7ea8c471eeffb1cb6fdf69b33bb683..5a48ec5d57bed5c2c4bd264c248373a10b83510c 100644 --- a/assets/ConfirmModal-BsY1WFdG.js +++ b/assets/ConfirmModal-BjVnuYqC.js @@ -1 +1 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{B as i}from"./button-BqKfG4Jj.js";import{g as f,m as r,w as h}from"./index-mbyiCUYG.js";import{X as y}from"./x-oZO0Ye1Q.js";import{T as j}from"./trash-2-8qZ3aehj.js";import{L as w}from"./log-out-Ddy014zi.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";const O=({isOpen:s,onClose:t,onConfirm:n,title:a,message:l,confirmText:c="Confirm",cancelText:d="Cancel",type:m="warning",icon:x="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(x){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(j,{size:32});case"warning":default:return e.jsx(h,{size:32})}},o=(()=>{switch(m){case"danger":return{iconBg:"bg-red-100",iconColor:"text-red-600",buttonBg:"bg-red-600 hover:bg-red-700",buttonText:"text-white"};case"warning":return{iconBg:"bg-rose-100",iconColor:"text-rose-600",buttonBg:"bg-rose-600 hover:bg-rose-700",buttonText:"text-white"};case"info":default:return{iconBg:"bg-sky-100",iconColor:"text-sky-600",buttonBg:"bg-sky-600 hover:bg-sky-700",buttonText:"text-white"}}})(),p=async()=>{try{await n(),t()}catch{}};return e.jsx(f,{children:s&&e.jsx(e.Fragment,{children:e.jsx(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:`fixed inset-0 bg-black/50 backdrop-blur-sm ${g} flex items-center justify-center p-4`,children:e.jsxs(r.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{type:"spring",damping:25,stiffness:300},onClick:u=>u.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl max-w-md w-full overflow-hidden border border-[#dde3eb]",children:[e.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-500 hover:text-[#0a1628] hover:bg-[#dde3eb] rounded-xl transition-colors z-10",children:e.jsx(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-CaSK4KoS.js";import{k as f,m as r,v as h}from"./index-B3ruOzo6.js";import{X as y}from"./x-BNHnAXzL.js";import{T as j}from"./trash-2-CjkT7lLr.js";import{L as w}from"./log-out-CoRJnfoO.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";const O=({isOpen:s,onClose:t,onConfirm:n,title:a,message:l,confirmText:c="Confirm",cancelText:d="Cancel",type:m="warning",icon:x="warning",zIndexClass:g="z-50"})=>{const b=()=>{switch(x){case"logout":return e.jsx(w,{size:32});case"delete":return e.jsx(j,{size:32});case"warning":default:return e.jsx(h,{size:32})}},o=(()=>{switch(m){case"danger":return{iconBg:"bg-red-100",iconColor:"text-red-600",buttonBg:"bg-red-600 hover:bg-red-700",buttonText:"text-white"};case"warning":return{iconBg:"bg-rose-100",iconColor:"text-rose-600",buttonBg:"bg-rose-600 hover:bg-rose-700",buttonText:"text-white"};case"info":default:return{iconBg:"bg-sky-100",iconColor:"text-sky-600",buttonBg:"bg-sky-600 hover:bg-sky-700",buttonText:"text-white"}}})(),p=async()=>{try{await n(),t()}catch{}};return e.jsx(f,{children:s&&e.jsx(e.Fragment,{children:e.jsx(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:`fixed inset-0 bg-black/50 backdrop-blur-sm ${g} flex items-center justify-center p-4`,children:e.jsxs(r.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{type:"spring",damping:25,stiffness:300},onClick:u=>u.stopPropagation(),className:"bg-[#f7f9fc] rounded-3xl shadow-2xl max-w-md w-full overflow-hidden border border-[#dde3eb]",children:[e.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-500 hover:text-[#0a1628] hover:bg-[#dde3eb] rounded-xl transition-colors z-10",children:e.jsx(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/FloatingAITutor-CSSEfiYF.js b/assets/FloatingAITutor-BkNIiXkv.js similarity index 92% rename from assets/FloatingAITutor-CSSEfiYF.js rename to assets/FloatingAITutor-BkNIiXkv.js index f101373b0b20cb392687fbe5bca3910d21b9e9a8..57f78a9248f62403c1ac8664ba5007cd7c97a7f0 100644 --- a/assets/FloatingAITutor-CSSEfiYF.js +++ b/assets/FloatingAITutor-BkNIiXkv.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatMarkdown-vDoOnX8q.js","assets/index-mbyiCUYG.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.js","assets/vendor-radix-xDOIcVzp.js","assets/vendor-charts-Ckgeb0nY.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CoeUXWgK.css"])))=>i.map(i=>d[i]); -import{az as C,_ as y,m as b,E as A}from"./index-mbyiCUYG.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-BqKWV1Bn.js";import{M as w}from"./minus-BEbLkPkH.js";import{X as g}from"./x-oZO0Ye1Q.js";import{S as L}from"./send-iW1LmVFw.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-vDoOnX8q.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-mbyiCUYG.js").then(d=>d.b3);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-BWVWW9Zs.js","assets/index-B3ruOzo6.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.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-trN1hCQB.css"])))=>i.map(i=>d[i]); +import{aB as C,_ as y,m as b,E as A}from"./index-B3ruOzo6.js";import{r as i,j as e}from"./vendor-react-B4AQeu28.js";import{M}from"./maximize-2-Cr4HMoWg.js";import{M as w}from"./minus-B69_eMXI.js";import{X as g}from"./x-BNHnAXzL.js";import{S as L}from"./send-CTO7uejQ.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const E=i.lazy(()=>y(()=>import("./ChatMarkdown-BWVWW9Zs.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-B3ruOzo6.js").then(d=>d.b3);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-wWFYB1uJ.js b/assets/GradesPage-CU5DI0dR.js similarity index 93% rename from assets/GradesPage-wWFYB1uJ.js rename to assets/GradesPage-CU5DI0dR.js index 3d313ac9f581ae01e0a0d83d0aac284ec4adefb0..774a2747a4b3665ced548d71c59f21c36a50f88d 100644 --- a/assets/GradesPage-wWFYB1uJ.js +++ b/assets/GradesPage-CU5DI0dR.js @@ -1,2 +1,2 @@ -import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as v}from"./button-BqKfG4Jj.js";import{l as J,aA as K,aB as W,D as X,A as Z,q as R,T as D}from"./index-mbyiCUYG.js";import{g as q,S as E}from"./subjects-BGUwH4Kn.js";import{u as ee}from"./useCurriculum-uUEvXpH4.js";import{D as te}from"./download-C2PVrIq3.js";import{F as P}from"./funnel-DxfPBPvT.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B4tQNTpN.js";const ge=()=>{const{currentUser:i,userProfile:w}=J(),[n,N]=o.useState("all"),[x,z]=o.useState("all"),[M,u]=o.useState(!0),[h,L]=o.useState(null),[F,G]=o.useState([]),y=w?.grade,S=q(y),_=new Set(S),{isLoading:Q}=ee(y);o.useEffect(()=>{},[Q]);const B=t=>{if(t==null)return"N/A";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"N/A":s.toISOString().split("T")[0]};o.useEffect(()=>{if(!i)return;u(!0);const t=K(i.uid,a=>{L(a),u(!1)}),s=W(i.uid,a=>{G(a),u(!1)});return()=>{t(),s()}},[i]);const b=h?.averageScore?Math.round(h.averageScore):0,O=h?.quizzesCompleted??0,U=b>0?(b/100*4).toFixed(2):"0.00",I={"gen-math":"indigo","stats-prob":"violet"},k={indigo:{dot:"bg-indigo-500",bar:"bg-indigo-500"},violet:{dot:"bg-violet-500",bar:"bg-violet-500"},fuchsia:{dot:"bg-fuchsia-500",bar:"bg-fuchsia-500"},purple:{dot:"bg-purple-500",bar:"bg-purple-500"},slate:{dot:"bg-slate-500",bar:"bg-slate-500"}},A=E.reduce((t,s)=>(t[s.id]={label:s.name,color:I[s.id]||"slate"},t),{}),c=E.filter(t=>_.has(t.id)).map(t=>t.name),T=Object.entries({}).filter(([t])=>_.has(t)).map(([t,s])=>{const a=A[t]||{label:t,color:"slate"},r=[],f=r.length>0?Math.round(r.reduce((g,p)=>g+p.score,0)/r.length):Math.round(s?.progress??0);return{subject:a.label,average:f,quizzes:r.length||s?.completedModules,color:a.color}}),H=S.map(t=>{const s=A[t]||{label:t,color:"slate"};return{subject:s.label,average:0,quizzes:0,color:s.color}}),C=T.length>0?T:H,$=F.slice().sort((t,s)=>{const a=t.completedAt?.toDate?.()?.getTime()??0;return(s.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((t,s)=>({id:s+1,title:t.title||`Assessment ${s+1}`,subject:t.subject||"General",score:t.score,date:t.completedAt?B(t.completedAt.toDate()):"N/A",type:t.type==="practice"?"practice":(t.type==="diagnostic","module"),status:t.score>=80?"Excellent":t.score>=60?"Passing":"Needs Review"})).filter(t=>c.includes(t.subject)),m=$.filter(t=>{if(!c.includes(t.subject))return!1;const s=n==="all"||t.subject===n,a=x==="all"||t.type===x;return s&&a});o.useEffect(()=>{n!=="all"&&(c.includes(n)||N("all"))},[c,n]);const V=()=>{const t=l=>{const j=String(l??"");return/[",\n]/.test(j)?`"${j.replace(/"/g,'""')}"`:j},s=[],a=w?.name||i?.displayName||i?.email||"Student",r=new Date().toISOString().split("T")[0];s.push("Grade Report"),s.push(`Student,${t(a)}`),s.push(`Export Date,${t(r)}`),s.push(`Subject Filter,${t(n)}`),s.push(`Type Filter,${t(x)}`),s.push(""),s.push("Subject Performance"),s.push("Subject,Average Score"),C.forEach(l=>{s.push([t(l.subject),t(l.average)].join(","))}),s.push(""),s.push("Recent Quizzes"),s.push("Title,Subject,Score,Date,Type,Status"),m.length===0?s.push("No quiz data available for the selected filters"):m.forEach(l=>{s.push([t(l.title),t(l.subject),t(l.score),t(l.date),t(l.type),t(l.status)].join(","))});const f=s.join(` -`),g=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=window.URL.createObjectURL(g),d=document.createElement("a"),Y=a.replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()||"student";d.href=p,d.setAttribute("download",`grade-report-${Y}-${r}.csv`),document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(p)};return M?e.jsx("div",{className:"p-8 flex justify-center items-center h-full",children:e.jsx("div",{className:"w-10 h-10 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 space-y-8 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 bg-white p-6 rounded-[2rem] shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] border border-slate-50",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black text-slate-800 tracking-tight",children:"Assessment"}),e.jsx("p",{className:"text-slate-400 font-bold mt-1 text-[13px]",children:"Review your performance across subjects"})]}),e.jsxs("div",{className:"flex gap-3 w-full sm:w-auto",children:[e.jsxs(v,{variant:"outline",className:"flex-1 sm:flex-none border-slate-200 text-slate-500 font-bold rounded-xl h-11 px-5 hover:bg-slate-50 hover:text-slate-700",children:[e.jsx(X,{className:"w-4 h-4 mr-2 text-slate-400"}),"This Semester"]}),e.jsxs(v,{className:"flex-1 sm:flex-none bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl h-11 px-5 shadow-[0_8px_20px_-8px_rgba(79,70,229,0.5)] hover:-translate-y-0.5 transition-all",onClick:V,children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Report"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-indigo-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-indigo-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(Z,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Overall GPA"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:U})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-emerald-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-emerald-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-emerald-100 text-emerald-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(R,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Average Score"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsxs("h3",{className:"text-4xl font-display font-black text-slate-800",children:[b,"%"]})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-violet-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-violet-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-violet-100 text-violet-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(D,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Quizzes Completed"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:O})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 sm:p-8 border-b border-slate-50 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-black text-xl text-slate-800",children:"Recent Assessments"}),e.jsx("p",{className:"text-slate-400 font-bold text-[13px] mt-1",children:"Your latest quiz and practice results"})]}),e.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:n,onChange:t=>N(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[140px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Subjects"}),c.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:x,onChange:t=>z(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[120px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"module",children:"Module Quiz"}),e.jsx("option",{value:"practice",children:"Practice"})]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]})]}),e.jsx("div",{className:"overflow-x-auto flex-1 p-2",children:e.jsxs("table",{className:"w-full text-left border-separate border-spacing-y-2 px-4 sm:px-6 mb-4",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Assessment"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent min-w-[120px]",children:"Subject"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Type"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right border-b border-transparent",children:"Score"})]})}),e.jsx("tbody",{children:m.length>0?m.map(t=>e.jsxs("tr",{className:"group hover:bg-slate-50/70 transition-colors",children:[e.jsxs("td",{className:"px-4 py-4 rounded-l-2xl",children:[e.jsx("p",{className:"text-[14px] font-bold text-slate-800",children:t.title}),e.jsx("p",{className:"text-[11px] font-bold text-slate-400 mt-1",children:t.date})]}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:"inline-flex flex-col gap-1 items-start",children:e.jsx("span",{className:"text-[13px] font-bold text-slate-600 truncate max-w-[140px] block",children:t.subject})})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`inline-flex items-center px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wide ${t.type==="practice"?"bg-emerald-100/50 text-emerald-600":"bg-indigo-100/50 text-indigo-600"}`,children:t.type==="practice"?"Practice":"Quiz"})}),e.jsx("td",{className:"px-4 py-4 text-right rounded-r-2xl",children:e.jsxs("span",{className:`inline-flex items-center px-3 py-1.5 rounded-xl text-[13px] font-black ${t.score>=80?"bg-emerald-100 text-emerald-700":t.score>=60?"bg-amber-100 text-amber-700":"bg-rose-100 text-rose-700"}`,children:[t.score,"%"]})})]},t.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mb-4",children:e.jsx(R,{className:"w-8 h-8 text-slate-300"})}),e.jsx("p",{className:"text-slate-500 font-bold text-sm",children:"No recent assessments match the selected filters."})]})})})})]})})]})}),e.jsxs("div",{className:"space-y-6 lg:space-y-8 flex flex-col",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)]",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsx("h3",{className:"font-display font-black text-lg text-slate-800",children:"Subject Performance"})}),e.jsx("div",{className:"space-y-7",children:C.map((t,s)=>{const a=k[t.color]||k.slate;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex justify-between items-end mb-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[14px] font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.dot} group-hover:scale-125 transition-transform`}),t.subject]}),e.jsxs("p",{className:"text-[11px] text-slate-400 font-bold ml-4 mt-0.5",children:[t.quizzes," activities"]})]}),e.jsxs("span",{className:"text-[15px] font-black text-slate-800",children:[t.average,"%"]})]}),e.jsx("div",{className:"h-2.5 w-full bg-slate-100 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full e-w ${a.bar} shadow-sm relative overflow-hidden transition-all duration-1000`,style:{"--w":`${Math.max(t.average,5)}%`},children:e.jsx("div",{className:"absolute inset-0 bg-white/20 w-1/2 -skew-x-12 translate-x-[-100%] group-hover:animate-[shimmer_1.5s_ease-out]"})})})]},s)})})]}),e.jsxs("div",{className:"relative bg-gradient-to-br from-indigo-600 to-violet-700 rounded-[2rem] p-6 sm:p-8 shadow-[0_12px_30px_-10px_rgba(79,70,229,0.5)] text-white overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-white/10 rounded-full blur-3xl -mt-10 -mr-10 group-hover:bg-white/20 transition-all duration-700 ease-in-out"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-32 h-32 bg-indigo-400/30 rounded-full blur-2xl -mb-10 -ml-10"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-12 h-12 bg-white/10 rounded-2xl flex items-center justify-center mb-5 backdrop-blur-sm border border-white/20 shadow-sm group-hover:scale-110 transition-transform",children:e.jsx(D,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-2xl font-display font-black tracking-tight mb-2 leading-tight",children:"Keep up the momentum!"}),e.jsxs("p",{className:"text-white/80 text-[13px] font-medium leading-relaxed mb-8 max-w-[90%]",children:["You've completed ",e.jsx("span",{className:"font-black text-white",children:$.length})," activities recently. Try a practice session to boost your lowest scores."]}),e.jsx(v,{className:"w-full bg-white text-indigo-600 hover:bg-slate-50 border-0 font-black h-12 rounded-xl shadow-[0_8px_16px_rgba(0,0,0,0.15)] hover:shadow-[0_8px_24px_rgba(0,0,0,0.2)] hover:-translate-y-0.5 transition-all",children:"Start Practice Session"})]})]})]})]})]})};export{ge as default}; +import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{B as v}from"./button-CaSK4KoS.js";import{u as J,aC as K,aD as W,D as X,A as Z,p as D,T as R}from"./index-B3ruOzo6.js";import{g as q,S as E}from"./subjects-DEj_AlYz.js";import{u as ee}from"./useCurriculum-CQZ78SzC.js";import{D as te}from"./download-BbFDZT3H.js";import{F as P}from"./funnel-8X5OzLOw.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-C9VTl-3A.js";const ge=()=>{const{currentUser:i,userProfile:w}=J(),[n,N]=o.useState("all"),[x,z]=o.useState("all"),[M,u]=o.useState(!0),[h,L]=o.useState(null),[F,G]=o.useState([]),y=w?.grade,S=q(y),_=new Set(S),{isLoading:Q}=ee(y);o.useEffect(()=>{},[Q]);const O=t=>{if(t==null)return"N/A";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"N/A":s.toISOString().split("T")[0]};o.useEffect(()=>{if(!i)return;u(!0);const t=K(i.uid,a=>{L(a),u(!1)}),s=W(i.uid,a=>{G(a),u(!1)});return()=>{t(),s()}},[i]);const b=h?.averageScore?Math.round(h.averageScore):0,U=h?.quizzesCompleted??0,B=b>0?(b/100*4).toFixed(2):"0.00",I={"gen-math":"indigo","stats-prob":"violet"},k={indigo:{dot:"bg-indigo-500",bar:"bg-indigo-500"},violet:{dot:"bg-violet-500",bar:"bg-violet-500"},fuchsia:{dot:"bg-fuchsia-500",bar:"bg-fuchsia-500"},purple:{dot:"bg-purple-500",bar:"bg-purple-500"},slate:{dot:"bg-slate-500",bar:"bg-slate-500"}},A=E.reduce((t,s)=>(t[s.id]={label:s.name,color:I[s.id]||"slate"},t),{}),c=E.filter(t=>_.has(t.id)).map(t=>t.name),T=Object.entries({}).filter(([t])=>_.has(t)).map(([t,s])=>{const a=A[t]||{label:t,color:"slate"},r=[],f=r.length>0?Math.round(r.reduce((g,p)=>g+p.score,0)/r.length):Math.round(s?.progress??0);return{subject:a.label,average:f,quizzes:r.length||s?.completedModules,color:a.color}}),H=S.map(t=>{const s=A[t]||{label:t,color:"slate"};return{subject:s.label,average:0,quizzes:0,color:s.color}}),C=T.length>0?T:H,$=F.slice().sort((t,s)=>{const a=t.completedAt?.toDate?.()?.getTime()??0;return(s.completedAt?.toDate?.()?.getTime()??0)-a}).slice(0,10).map((t,s)=>({id:s+1,title:t.title||`Assessment ${s+1}`,subject:t.subject||"General",score:t.score,date:t.completedAt?O(t.completedAt.toDate()):"N/A",type:t.type==="practice"?"practice":(t.type==="diagnostic","module"),status:t.score>=80?"Excellent":t.score>=60?"Passing":"Needs Review"})).filter(t=>c.includes(t.subject)),m=$.filter(t=>{if(!c.includes(t.subject))return!1;const s=n==="all"||t.subject===n,a=x==="all"||t.type===x;return s&&a});o.useEffect(()=>{n!=="all"&&(c.includes(n)||N("all"))},[c,n]);const V=()=>{const t=l=>{const j=String(l??"");return/[",\n]/.test(j)?`"${j.replace(/"/g,'""')}"`:j},s=[],a=w?.name||i?.displayName||i?.email||"Student",r=new Date().toISOString().split("T")[0];s.push("Grade Report"),s.push(`Student,${t(a)}`),s.push(`Export Date,${t(r)}`),s.push(`Subject Filter,${t(n)}`),s.push(`Type Filter,${t(x)}`),s.push(""),s.push("Subject Performance"),s.push("Subject,Average Score"),C.forEach(l=>{s.push([t(l.subject),t(l.average)].join(","))}),s.push(""),s.push("Recent Quizzes"),s.push("Title,Subject,Score,Date,Type,Status"),m.length===0?s.push("No quiz data available for the selected filters"):m.forEach(l=>{s.push([t(l.title),t(l.subject),t(l.score),t(l.date),t(l.type),t(l.status)].join(","))});const f=s.join(` +`),g=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=window.URL.createObjectURL(g),d=document.createElement("a"),Y=a.replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()||"student";d.href=p,d.setAttribute("download",`grade-report-${Y}-${r}.csv`),document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(p)};return M?e.jsx("div",{className:"p-8 flex justify-center items-center h-full",children:e.jsx("div",{className:"w-10 h-10 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 space-y-8 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 bg-white p-6 rounded-[2rem] shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] border border-slate-50",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black text-slate-800 tracking-tight",children:"Assessment"}),e.jsx("p",{className:"text-slate-400 font-bold mt-1 text-[13px]",children:"Review your performance across subjects"})]}),e.jsxs("div",{className:"flex gap-3 w-full sm:w-auto",children:[e.jsxs(v,{variant:"outline",className:"flex-1 sm:flex-none border-slate-200 text-slate-500 font-bold rounded-xl h-11 px-5 hover:bg-slate-50 hover:text-slate-700",children:[e.jsx(X,{className:"w-4 h-4 mr-2 text-slate-400"}),"This Semester"]}),e.jsxs(v,{className:"flex-1 sm:flex-none bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl h-11 px-5 shadow-[0_8px_20px_-8px_rgba(79,70,229,0.5)] hover:-translate-y-0.5 transition-all",onClick:V,children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Report"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-indigo-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-indigo-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(Z,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Overall GPA"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:B})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-emerald-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-emerald-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-emerald-100 text-emerald-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(D,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Average Score"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsxs("h3",{className:"text-4xl font-display font-black text-slate-800",children:[b,"%"]})})]})]}),e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_24px_-10px_rgba(0,0,0,0.05)] relative overflow-hidden group hover:border-violet-100 transition-colors",children:[e.jsx("div",{className:"absolute -right-8 -top-8 w-32 h-32 bg-violet-50 rounded-full group-hover:scale-110 transition-transform duration-500"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 bg-violet-100 text-violet-600 rounded-2xl flex items-center justify-center mb-6 shadow-sm",children:e.jsx(R,{className:"w-7 h-7"})}),e.jsx("p",{className:"text-slate-400 font-bold text-sm tracking-wide uppercase",children:"Quizzes Completed"}),e.jsx("div",{className:"flex items-end gap-2 mt-2",children:e.jsx("h3",{className:"text-4xl font-display font-black text-slate-800",children:U})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)] overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-6 sm:p-8 border-b border-slate-50 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-black text-xl text-slate-800",children:"Recent Assessments"}),e.jsx("p",{className:"text-slate-400 font-bold text-[13px] mt-1",children:"Your latest quiz and practice results"})]}),e.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:n,onChange:t=>N(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[140px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Subjects"}),c.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsxs("select",{value:x,onChange:t=>z(t.target.value),className:"appearance-none w-full pl-4 pr-10 py-2.5 border-none bg-slate-50 rounded-xl text-sm font-bold text-slate-600 focus:ring-2 focus:ring-indigo-500/30 transition-all cursor-pointer min-w-[120px] shadow-sm",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"module",children:"Module Quiz"}),e.jsx("option",{value:"practice",children:"Practice"})]}),e.jsx(P,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]})]}),e.jsx("div",{className:"overflow-x-auto flex-1 p-2",children:e.jsxs("table",{className:"w-full text-left border-separate border-spacing-y-2 px-4 sm:px-6 mb-4",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Assessment"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent min-w-[120px]",children:"Subject"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider border-b border-transparent",children:"Type"}),e.jsx("th",{className:"px-4 py-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right border-b border-transparent",children:"Score"})]})}),e.jsx("tbody",{children:m.length>0?m.map(t=>e.jsxs("tr",{className:"group hover:bg-slate-50/70 transition-colors",children:[e.jsxs("td",{className:"px-4 py-4 rounded-l-2xl",children:[e.jsx("p",{className:"text-[14px] font-bold text-slate-800",children:t.title}),e.jsx("p",{className:"text-[11px] font-bold text-slate-400 mt-1",children:t.date})]}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:"inline-flex flex-col gap-1 items-start",children:e.jsx("span",{className:"text-[13px] font-bold text-slate-600 truncate max-w-[140px] block",children:t.subject})})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`inline-flex items-center px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wide ${t.type==="practice"?"bg-emerald-100/50 text-emerald-600":"bg-indigo-100/50 text-indigo-600"}`,children:t.type==="practice"?"Practice":"Quiz"})}),e.jsx("td",{className:"px-4 py-4 text-right rounded-r-2xl",children:e.jsxs("span",{className:`inline-flex items-center px-3 py-1.5 rounded-xl text-[13px] font-black ${t.score>=80?"bg-emerald-100 text-emerald-700":t.score>=60?"bg-amber-100 text-amber-700":"bg-rose-100 text-rose-700"}`,children:[t.score,"%"]})})]},t.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mb-4",children:e.jsx(D,{className:"w-8 h-8 text-slate-300"})}),e.jsx("p",{className:"text-slate-500 font-bold text-sm",children:"No recent assessments match the selected filters."})]})})})})]})})]})}),e.jsxs("div",{className:"space-y-6 lg:space-y-8 flex flex-col",children:[e.jsxs("div",{className:"bg-white rounded-[2rem] border border-slate-100 p-6 sm:p-8 shadow-[0_8px_30px_-12px_rgba(0,0,0,0.06)]",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsx("h3",{className:"font-display font-black text-lg text-slate-800",children:"Subject Performance"})}),e.jsx("div",{className:"space-y-7",children:C.map((t,s)=>{const a=k[t.color]||k.slate;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex justify-between items-end mb-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[14px] font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.dot} group-hover:scale-125 transition-transform`}),t.subject]}),e.jsxs("p",{className:"text-[11px] text-slate-400 font-bold ml-4 mt-0.5",children:[t.quizzes," activities"]})]}),e.jsxs("span",{className:"text-[15px] font-black text-slate-800",children:[t.average,"%"]})]}),e.jsx("div",{className:"h-2.5 w-full bg-slate-100 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full e-w ${a.bar} shadow-sm relative overflow-hidden transition-all duration-1000`,style:{"--w":`${Math.max(t.average,5)}%`},children:e.jsx("div",{className:"absolute inset-0 bg-white/20 w-1/2 -skew-x-12 translate-x-[-100%] group-hover:animate-[shimmer_1.5s_ease-out]"})})})]},s)})})]}),e.jsxs("div",{className:"relative bg-gradient-to-br from-indigo-600 to-violet-700 rounded-[2rem] p-6 sm:p-8 shadow-[0_12px_30px_-10px_rgba(79,70,229,0.5)] text-white overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-white/10 rounded-full blur-3xl -mt-10 -mr-10 group-hover:bg-white/20 transition-all duration-700 ease-in-out"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-32 h-32 bg-indigo-400/30 rounded-full blur-2xl -mb-10 -ml-10"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-12 h-12 bg-white/10 rounded-2xl flex items-center justify-center mb-5 backdrop-blur-sm border border-white/20 shadow-sm group-hover:scale-110 transition-transform",children:e.jsx(R,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-2xl font-display font-black tracking-tight mb-2 leading-tight",children:"Keep up the momentum!"}),e.jsxs("p",{className:"text-white/80 text-[13px] font-medium leading-relaxed mb-8 max-w-[90%]",children:["You've completed ",e.jsx("span",{className:"font-black text-white",children:$.length})," activities recently. Try a practice session to boost your lowest scores."]}),e.jsx(v,{className:"w-full bg-white text-indigo-600 hover:bg-slate-50 border-0 font-black h-12 rounded-xl shadow-[0_8px_16px_rgba(0,0,0,0.15)] hover:shadow-[0_8px_24px_rgba(0,0,0,0.2)] hover:-translate-y-0.5 transition-all",children:"Start Practice Session"})]})]})]})]})]})};export{ge as default}; diff --git a/assets/HeroBanner-Co1DN6x_.js b/assets/HeroBanner-Co1DN6x_.js deleted file mode 100644 index 0275017f3188e5539cd9ac6a493d10d48ba03d3a..0000000000000000000000000000000000000000 --- a/assets/HeroBanner-Co1DN6x_.js +++ /dev/null @@ -1,13 +0,0 @@ -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{c as y,T as v,h as w,W as k,g as M,m as p,A as P,B as u,q as A,Z as T,b as _,_ as E}from"./index-mbyiCUYG.js";import{j as e,r as o}from"./vendor-react-B4AQeu28.js";import{D as V,a as $}from"./dialog-fiLCzxmY.js";import{R as Q,L as q,C as G,X as W,Y,T as X,d as F}from"./vendor-charts-Ckgeb0nY.js";import{collection as S,query as C,limit as L,orderBy as R,getDocs as D}from"./vendor-firebase-firestore-CP9q7ISf.js";import{X as K}from"./x-oZO0Ye1Q.js";import{C as z}from"./circle-alert-CJ47UAgT.js";import{C as U}from"./circle-check-BENuYz-J.js";import{S as Z}from"./sparkles-THbTTiEe.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-markdown-yqZQ_iQm.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 O=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],J=y("hand",O);/** - * @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 I=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],ee=y("shield-alert",I),se=({history:s})=>{if(s.length===0)return e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(v,{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 t=s.map(a=>({date:new Date(a.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),score:a.percentage,level:a.proficiencyLevel}));return e.jsx("div",{className:"w-full",children:e.jsx(Q,{width:"100%",height:250,children:e.jsxs(q,{data:t,margin:{top:10,right:20,left:0,bottom:5},children:[e.jsx(G,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(W,{dataKey:"date",tick:{fontSize:12,fill:"#64748b"}}),e.jsx(Y,{domain:[0,100],tick:{fontSize:12,fill:"#64748b"}}),e.jsx(X,{contentStyle:{borderRadius:"12px",border:"1px solid #e2e8f0",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"}}),e.jsx(F,{type:"monotone",dataKey:"score",stroke:"#0ea5e9",strokeWidth:3,dot:{fill:"#0ea5e9",strokeWidth:2,r:5},activeDot:{r:7,fill:"#0284c7"}})]})})})};async function te(s){const t=S(w,"assessmentResults",s,"attempts"),a=C(t,R("completedAt","desc"),L(10));return(await D(a)).docs.map(n=>{const r=n.data();return{attemptId:r.attemptId,score:r.score,totalQuestions:r.totalQuestions,percentage:r.percentage,completedAt:r.completedAt?.toDate?.()?.toISOString()||r.completedAt,proficiencyLevel:r.proficiencyLevel}})}async function ae(s){const t=S(w,"assessmentResults",s,"attempts"),a=C(t,R("completedAt","desc"),L(1)),i=await D(a);if(i.empty)return null;const r=i.docs[0].data();return{...r,completedAt:r.completedAt?.toDate?.()?.toISOString()||r.completedAt}}const re={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"},le=({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 ${re[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(u,{className:"w-4 h-4 text-sky-500"}),"Competency Breakdown"]}),e.jsx("div",{className:"space-y-2",children:s.competencyBreakdown.map((t,a)=>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:t.topic}),e.jsxs("p",{className:"text-xs text-slate-500",children:[t.correctAnswers,"/",t.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 ${t.accuracyPercent>=70?"bg-emerald-500":"bg-red-400"}`,style:{width:`${t.accuracyPercent}%`}})}),e.jsxs("span",{className:"text-sm font-semibold text-slate-600 w-10 text-right",children:[t.accuracyPercent,"%"]})]},a))})]}),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(Z,{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(A,{className:"w-4 h-4 text-sky-500"}),"Question Breakdown"]}),e.jsx("div",{className:"space-y-3",children:s.answers.map((t,a)=>e.jsxs("div",{className:`p-4 rounded-xl border-2 ${t.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",a+1,". ",t.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:t.isCorrect?"text-emerald-600 font-medium":"text-red-500 font-medium",children:t.userAnswer||"—"})]}),!t.isCorrect&&e.jsxs("span",{className:"text-slate-500",children:["Correct: ",e.jsx("span",{className:"text-emerald-600 font-medium",children:t.correctAnswer})]})]}),t.explanation&&e.jsx("p",{className:"text-xs text-slate-500 mt-2 leading-relaxed",children:t.explanation})]},a))})]})]}),oe=({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(ee,{className:"w-4 h-4"}):s.latestRiskLevel==="Needs Attention"?e.jsx(z,{className:"w-4 h-4"}):e.jsx(U,{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(v,{className:"w-4 h-4"}),"Strengths"]}),e.jsx("ul",{className:"space-y-2",children:s.strengths.map((t,a)=>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:t})]},a))})]}),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(A,{className:"w-4 h-4"}),"Focus Areas"]}),e.jsx("ul",{className:"space-y-2",children:s.weaknesses.map((t,a)=>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:t})]},a))})]})]}),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(u,{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})]})]}),ie=({heroBannerSummary:s,latestResult:t,loading:a})=>a?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&&!t?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(u,{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(oe,{summary:s}):t?e.jsx(le,{result:t}):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(z,{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."})]}),ne=({isOpen:s,onClose:t,studentId:a,latestResult:i,heroBannerSummary:n})=>{const[r,d]=o.useState("latest"),[f,c]=o.useState(i||null),[m,j]=o.useState([]),[b,g]=o.useState(!1),[x,N]=o.useState(null);o.useEffect(()=>{if(s&&a&&!n){const l=k(a,h=>{N(h)});return()=>l()}},[s,a,n]);const H=n||x;o.useEffect(()=>{s&&a&&(g(!0),Promise.all([i?Promise.resolve(i):ae(a),te(a)]).then(([l,h])=>{c(l),j(h)}).catch(console.error).finally(()=>g(!1)))},[s,a,i]);const B=[{key:"latest",label:"Last Results",icon:e.jsx(P,{className:"w-4 h-4"})},{key:"history",label:"History & Trends",icon:e.jsx(v,{className:"w-4 h-4"})}];return e.jsx(V,{open:s,onOpenChange:l=>!l&&t(),children:e.jsxs($,{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:t,className:"p-1.5 rounded-lg hover:bg-slate-100 transition-colors",children:e.jsx(K,{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(l=>e.jsxs("button",{onClick:()=>d(l.key),className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all ${r===l.key?"bg-white text-sky-600 shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:[l.icon,l.label]},l.key))})]}),e.jsx("div",{className:"px-6 py-5",children:e.jsxs(M,{mode:"wait",children:[r==="latest"&&e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:e.jsx(ie,{heroBannerSummary:H,latestResult:f,loading:b})},"latest"),r==="history"&&e.jsxs(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:[e.jsx(se,{history:m}),m.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"}),m.map((l,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 ",m.length-h]}),e.jsx("p",{className:"text-xs text-slate-500",children:new Date(l.completedAt).toLocaleDateString()})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-semibold text-sky-600",children:[l.percentage,"%"]}),e.jsx("p",{className:"text-xs text-slate-500",children:l.proficiencyLevel})]})]},h))]})]},"history")]})})]})})},de=o.lazy(()=>E(()=>import("./DashboardAvatar-CbAKGmA6.js"),__vite__mapDeps([0,1,2]))),Ae=({userName:s="Student",userLevel:t=1,avatarLayers:a,onContinueLearning:i,showAssessmentTooltip:n,onOpenAssessment:r,studentId:d,assessmentCompleted:f=!1})=>{const[c,m]=o.useState(!1),[j,b]=o.useState(null);o.useEffect(()=>{if(!c||!d)return;const x=k(d,N=>{b(N)});return()=>x()},[c,d]),o.useEffect(()=>{c||b(null)},[c]);const g=()=>{const x=new Date().getHours();return x<12?"Good Morning":x<18?"Good Afternoon":"Good Evening"};return e.jsxs(p.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-[2rem] 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-[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 min-h-[140px] lg:min-h-[160px] items-center justify-between gap-6 pb-0",children:e.jsxs("div",{className:"flex-1 min-w-0 pr-40 lg:pr-[280px] py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 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 ",t]})}),e.jsxs("div",{className:"px-3 md:px-4 py-1.5 rounded-full bg-rose-50 border border-rose-200",children:[e.jsx(T,{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-xl md:text-2xl lg:text-3xl font-display font-black text-[#0a1628] mb-1.5 tracking-tight leading-[1.1]",children:[g(),", ",s,"! ",e.jsx(J,{size:20,className:"inline -mt-1 ml-1"})]}),e.jsx("p",{className:"text-slate-500 mb-1 text-xs md:text-sm font-body font-bold",children:"Today is a great day to move one step forward in math mastery."}),e.jsx("p",{className:"text-[11px] md:text-xs text-slate-400 font-body mb-4",children:"Focus on your next recommended lesson and keep your momentum."}),e.jsxs(p.button,{onClick:i,whileHover:{scale:1.03},whileTap:{scale:.97},className:"mt-2 bg-gradient-to-r from-purple-600 to-[#9956DE] text-white px-5 py-2 rounded-xl font-body font-bold text-sm shadow-lg shadow-purple-500/20 hover:shadow-purple-500/30 transition-all flex items-center gap-2 group",children:["Continue Learning",e.jsx(_,{size:14,className:"group-hover:translate-x-1 transition-transform"})]})]})}),n&&e.jsx(p.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:r,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(u,{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"})]})}),f&&!n&&e.jsx(p.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:()=>d&&m(!0),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"})]})}),c&&d&&e.jsx(ne,{isOpen:c,onClose:()=>m(!1),studentId:d,heroBannerSummary:j}),e.jsx("div",{className:"hidden md:block absolute right-0 lg:right-10 bottom-0 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-[21%] lg:translate-y-[19%] drop-shadow-2xl",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"w-full h-full scale-[1.25] lg:scale-[1.3] origin-bottom"}),children:e.jsx(de,{layers:a,className:"w-full h-full scale-[1.25] lg:scale-[1.3] origin-bottom"})})})})]})};export{Ae as default}; diff --git a/assets/HeroBanner-DPijLb9x.js b/assets/HeroBanner-DPijLb9x.js new file mode 100644 index 0000000000000000000000000000000000000000..8f712bca5c42517dd2eb5080d7be6a5fe228391d --- /dev/null +++ b/assets/HeroBanner-DPijLb9x.js @@ -0,0 +1,8 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardAvatar-CbAKGmA6.js","assets/vendor-react-B4AQeu28.js","assets/avatarData-BuQSOXo3.js"])))=>i.map(i=>d[i]); +import{e as B,T as v,g as y,Y as w,k as P,m as p,A as T,B as u,p as k,Z as E,b as M,_}from"./index-B3ruOzo6.js";import{j as e,r as o}from"./vendor-react-B4AQeu28.js";import{D as V,a as Q}from"./dialog-KaD0jw5O.js";import{R as $,L as G,C as Y,X as q,Y as W,T as X,f as F}from"./vendor-charts-D7t7JfSr.js";import{collection as A,query as S,limit as C,orderBy as L,getDocs as R}from"./vendor-firebase-firestore-CP9q7ISf.js";import{X as K}from"./x-BNHnAXzL.js";import{C as D}from"./circle-alert-CTR2Lqp7.js";import{S as U}from"./shield-alert-kYf2Mbtd.js";import{C as Z}from"./circle-check-DyFN6-07.js";import{S as O}from"./sparkles-Bq0AaIRg.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-markdown-yqZQ_iQm.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 J=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],I=B("hand",J),ee=({history:s})=>{if(s.length===0)return e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(v,{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 t=s.map(a=>({date:new Date(a.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),score:a.percentage,level:a.proficiencyLevel}));return e.jsx("div",{className:"w-full",children:e.jsx($,{width:"100%",height:250,children:e.jsxs(G,{data:t,margin:{top:10,right:20,left:0,bottom:5},children:[e.jsx(Y,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(q,{dataKey:"date",tick:{fontSize:12,fill:"#64748b"}}),e.jsx(W,{domain:[0,100],tick:{fontSize:12,fill:"#64748b"}}),e.jsx(X,{contentStyle:{borderRadius:"12px",border:"1px solid #e2e8f0",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"}}),e.jsx(F,{type:"monotone",dataKey:"score",stroke:"#0ea5e9",strokeWidth:3,dot:{fill:"#0ea5e9",strokeWidth:2,r:5},activeDot:{r:7,fill:"#0284c7"}})]})})})};async function se(s){const t=A(y,"assessmentResults",s,"attempts"),a=S(t,L("completedAt","desc"),C(10));return(await R(a)).docs.map(n=>{const r=n.data();return{attemptId:r.attemptId,score:r.score,totalQuestions:r.totalQuestions,percentage:r.percentage,completedAt:r.completedAt?.toDate?.()?.toISOString()||r.completedAt,proficiencyLevel:r.proficiencyLevel}})}async function te(s){const t=A(y,"assessmentResults",s,"attempts"),a=S(t,L("completedAt","desc"),C(1)),i=await R(a);if(i.empty)return null;const r=i.docs[0].data();return{...r,completedAt:r.completedAt?.toDate?.()?.toISOString()||r.completedAt}}const ae={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"},re=({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 ${ae[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(u,{className:"w-4 h-4 text-sky-500"}),"Competency Breakdown"]}),e.jsx("div",{className:"space-y-2",children:s.competencyBreakdown.map((t,a)=>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:t.topic}),e.jsxs("p",{className:"text-xs text-slate-500",children:[t.correctAnswers,"/",t.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 ${t.accuracyPercent>=70?"bg-emerald-500":"bg-red-400"}`,style:{width:`${t.accuracyPercent}%`}})}),e.jsxs("span",{className:"text-sm font-semibold text-slate-600 w-10 text-right",children:[t.accuracyPercent,"%"]})]},a))})]}),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(O,{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(k,{className:"w-4 h-4 text-sky-500"}),"Question Breakdown"]}),e.jsx("div",{className:"space-y-3",children:s.answers.map((t,a)=>e.jsxs("div",{className:`p-4 rounded-xl border-2 ${t.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",a+1,". ",t.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:t.isCorrect?"text-emerald-600 font-medium":"text-red-500 font-medium",children:t.userAnswer||"—"})]}),!t.isCorrect&&e.jsxs("span",{className:"text-slate-500",children:["Correct: ",e.jsx("span",{className:"text-emerald-600 font-medium",children:t.correctAnswer})]})]}),t.explanation&&e.jsx("p",{className:"text-xs text-slate-500 mt-2 leading-relaxed",children:t.explanation})]},a))})]})]}),le=({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(U,{className:"w-4 h-4"}):s.latestRiskLevel==="Needs Attention"?e.jsx(D,{className:"w-4 h-4"}):e.jsx(Z,{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(v,{className:"w-4 h-4"}),"Strengths"]}),e.jsx("ul",{className:"space-y-2",children:s.strengths.map((t,a)=>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:t})]},a))})]}),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(k,{className:"w-4 h-4"}),"Focus Areas"]}),e.jsx("ul",{className:"space-y-2",children:s.weaknesses.map((t,a)=>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:t})]},a))})]})]}),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(u,{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})]})]}),oe=({heroBannerSummary:s,latestResult:t,loading:a})=>a?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&&!t?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(u,{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(le,{summary:s}):t?e.jsx(re,{result:t}):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(D,{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."})]}),ie=({isOpen:s,onClose:t,studentId:a,latestResult:i,heroBannerSummary:n})=>{const[r,d]=o.useState("latest"),[f,c]=o.useState(i||null),[m,j]=o.useState([]),[b,g]=o.useState(!1),[x,N]=o.useState(null);o.useEffect(()=>{if(s&&a&&!n){const l=w(a,h=>{N(h)});return()=>l()}},[s,a,n]);const z=n||x;o.useEffect(()=>{s&&a&&(g(!0),Promise.all([i?Promise.resolve(i):te(a),se(a)]).then(([l,h])=>{c(l),j(h)}).catch(console.error).finally(()=>g(!1)))},[s,a,i]);const H=[{key:"latest",label:"Last Results",icon:e.jsx(T,{className:"w-4 h-4"})},{key:"history",label:"History & Trends",icon:e.jsx(v,{className:"w-4 h-4"})}];return e.jsx(V,{open:s,onOpenChange:l=>!l&&t(),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:t,className:"p-1.5 rounded-lg hover:bg-slate-100 transition-colors",children:e.jsx(K,{className:"w-5 h-5 text-slate-400"})})]}),e.jsx("div",{className:"flex gap-1 bg-slate-100 p-1 rounded-lg",children:H.map(l=>e.jsxs("button",{onClick:()=>d(l.key),className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all ${r===l.key?"bg-white text-sky-600 shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:[l.icon,l.label]},l.key))})]}),e.jsx("div",{className:"px-6 py-5",children:e.jsxs(P,{mode:"wait",children:[r==="latest"&&e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:e.jsx(oe,{heroBannerSummary:z,latestResult:f,loading:b})},"latest"),r==="history"&&e.jsxs(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:[e.jsx(ee,{history:m}),m.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"}),m.map((l,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 ",m.length-h]}),e.jsx("p",{className:"text-xs text-slate-500",children:new Date(l.completedAt).toLocaleDateString()})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-semibold text-sky-600",children:[l.percentage,"%"]}),e.jsx("p",{className:"text-xs text-slate-500",children:l.proficiencyLevel})]})]},h))]})]},"history")]})})]})})},ne=o.lazy(()=>_(()=>import("./DashboardAvatar-CbAKGmA6.js"),__vite__mapDeps([0,1,2]))),Ae=({userName:s="Student",userLevel:t=1,avatarLayers:a,onContinueLearning:i,showAssessmentTooltip:n,onOpenAssessment:r,studentId:d,assessmentCompleted:f=!1})=>{const[c,m]=o.useState(!1),[j,b]=o.useState(null);o.useEffect(()=>{if(!c||!d)return;const x=w(d,N=>{b(N)});return()=>x()},[c,d]),o.useEffect(()=>{c||b(null)},[c]);const g=()=>{const x=new Date().getHours();return x<12?"Good Morning":x<18?"Good Afternoon":"Good Evening"};return e.jsxs(p.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-[2rem] 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-[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 min-h-[140px] lg:min-h-[160px] items-center justify-between gap-6 pb-0",children:e.jsxs("div",{className:"flex-1 min-w-0 pr-40 lg:pr-[280px] py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 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 ",t]})}),e.jsxs("div",{className:"px-3 md:px-4 py-1.5 rounded-full bg-rose-50 border border-rose-200",children:[e.jsx(E,{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-xl md:text-2xl lg:text-3xl font-display font-black text-[#0a1628] mb-1.5 tracking-tight leading-[1.1]",children:[g(),", ",s,"! ",e.jsx(I,{size:20,className:"inline -mt-1 ml-1"})]}),e.jsx("p",{className:"text-slate-500 mb-1 text-xs md:text-sm font-body font-bold",children:"Today is a great day to move one step forward in math mastery."}),e.jsx("p",{className:"text-[11px] md:text-xs text-slate-400 font-body mb-4",children:"Focus on your next recommended lesson and keep your momentum."}),e.jsxs(p.button,{onClick:i,whileHover:{scale:1.03},whileTap:{scale:.97},className:"mt-2 bg-gradient-to-r from-purple-600 to-[#9956DE] text-white px-5 py-2 rounded-xl font-body font-bold text-sm shadow-lg shadow-purple-500/20 hover:shadow-purple-500/30 transition-all flex items-center gap-2 group",children:["Continue Learning",e.jsx(M,{size:14,className:"group-hover:translate-x-1 transition-transform"})]})]})}),n&&e.jsx(p.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:r,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(u,{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"})]})}),f&&!n&&e.jsx(p.div,{initial:{opacity:0,scale:.9,x:10},animate:{opacity:1,scale:1,x:0},transition:{delay:.5,type:"spring"},onClick:()=>d&&m(!0),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"})]})}),c&&d&&e.jsx(ie,{isOpen:c,onClose:()=>m(!1),studentId:d,heroBannerSummary:j}),e.jsx("div",{className:"hidden md:block absolute right-0 lg:right-10 bottom-0 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-[21%] lg:translate-y-[19%] drop-shadow-2xl",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"w-full h-full scale-[1.25] lg:scale-[1.3] origin-bottom"}),children:e.jsx(ne,{layers:a,className:"w-full h-full scale-[1.25] lg:scale-[1.3] origin-bottom"})})})})]})};export{Ae as default}; diff --git a/assets/InitialAssessmentModal-BbFsU9kR.js b/assets/InitialAssessmentModal-C4M589Rr.js similarity index 93% rename from assets/InitialAssessmentModal-BbFsU9kR.js rename to assets/InitialAssessmentModal-C4M589Rr.js index a46da6836c63ace64b73752a8cf196edeb97b028..f72d6a0fc4fc12b15c46590977606d5bd57e0001 100644 --- a/assets/InitialAssessmentModal-BbFsU9kR.js +++ b/assets/InitialAssessmentModal-C4M589Rr.js @@ -1 +1 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{B as j}from"./button-BqKfG4Jj.js";import{g as y}from"./diagnosticService-D1BQOFa3.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CP9q7ISf.js";import{m as o,B as k,w as C,p as L,h as z}from"./index-mbyiCUYG.js";import{X as S}from"./x-oZO0Ye1Q.js";import{C as A}from"./circle-check-big-BnoZ8KZB.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";const H=({isOpen:n,onClose:d,onDismiss:m,userId:c,strand:x,gradeLevel:p,onAssessmentStart:u,onAssessmentComplete:I})=>{const[t,a]=l.useState(!1),[r,i]=l.useState(null),h=async()=>{a(!0),i(null);try{const s=await y(x,p);sessionStorage.setItem("mathpulse_diagnostic",JSON.stringify({testId:s.test_id,questions:s.questions,totalItems:s.total_items,estimatedMinutes:s.estimated_minutes})),u(s.test_id,s.questions)}catch(s){const b=s instanceof Error?s.message:"Failed to load assessment";i(b),a(!1)}},f=()=>{sessionStorage.setItem("mathpulse_iar_session_dismissed","true"),d()},g=async()=>{try{await N(v(z,"users",c),{assessmentDismissed:!0,assessmentDismissedAt:w()})}catch(s){console.error("[diagnostic] Failed to save dismiss state:",s)}m()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.stopPropagation(),children:e.jsxs(o.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"bg-white rounded-2xl shadow-2xl max-w-[36rem] w-full flex flex-col overflow-hidden pointer-events-auto",onClick:s=>s.stopPropagation(),style:{willChange:"transform, opacity"},children:[e.jsxs("div",{className:"px-5 py-3 border-b border-[#dde3eb] flex items-center justify-between bg-[#edf1f7] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center text-purple-600",children:e.jsx(k,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-[#0a1628] leading-tight",children:"Initial Assessment"}),e.jsx("p",{className:"text-[11px] text-[#5a6578]",children:"Analyze your strengths & weaknesses"})]})]}),e.jsx("button",{onClick:f,"aria-label":"Close assessment modal",className:"ml-auto w-8 h-8 rounded-lg flex items-center justify-center text-[#5a6578] hover:bg-[#dde3eb] hover:text-[#0a1628] transition-colors",children:e.jsx(S,{size:18})})]}),e.jsx("div",{className:"p-5 text-center space-y-3",children:e.jsxs(o.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3,ease:"easeOut"},children:[e.jsx("div",{className:"w-20 h-20 bg-purple-50 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx("svg",{className:"w-9 h-9 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})})}),e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Welcome to MathPulse AI!"}),e.jsx("p",{className:"text-[13px] text-[#5a6578] max-w-[19rem] mx-auto leading-relaxed",children:"To personalize your learning path, complete a DepEd competency-based SHS diagnostic (15 items, around 11.6 minutes)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 max-w-[22rem] mx-auto text-left mt-4",children:[e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(A,{size:14,className:"text-teal-500"}),"Personalized Path"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Get recommendations based on your level."})]}),e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(C,{size:14,className:"text-rose-500"}),"Identify Risks"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Spot areas that need more attention early."})]})]}),r&&e.jsx("div",{className:"mt-3 p-2.5 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-xs text-red-700",children:r})}),e.jsxs("div",{className:"pt-3 space-y-2.5",children:[e.jsx(j,{onClick:h,disabled:t,className:"bg-gradient-to-r from-purple-600 to-purple-500 hover:from-purple-700 hover:to-purple-600 text-white px-5 py-3 rounded-xl text-sm font-bold shadow-lg shadow-purple-200 w-full max-w-[320px] mx-auto",children:t?e.jsxs(e.Fragment,{children:[e.jsx(L,{size:16,className:"animate-spin mr-2"}),"Crafting your assessment..."]}):"Start Assessment"}),t&&e.jsx("p",{className:"text-[10px] text-slate-400 max-w-[18rem] mx-auto text-center leading-relaxed",children:"This may take up to 90 seconds while AI generates your personalized test."}),!t&&e.jsx("button",{onClick:g,disabled:t,className:"block mx-auto text-xs text-slate-500 hover:text-[#5a6578] transition-colors font-medium disabled:opacity-40",children:"Skip for now"})]})]})})]})}):null};export{H as default}; +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{B as j}from"./button-CaSK4KoS.js";import{g as y}from"./diagnosticService-CLsUcd9M.js";import{updateDoc as N,doc as v,serverTimestamp as w}from"./vendor-firebase-firestore-CP9q7ISf.js";import{m as o,B as k,v as C,o as L,g as z}from"./index-B3ruOzo6.js";import{X as S}from"./x-BNHnAXzL.js";import{C as A}from"./circle-check-big-CWdn1Nqf.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";const H=({isOpen:n,onClose:d,onDismiss:m,userId:c,strand:x,gradeLevel:p,onAssessmentStart:u,onAssessmentComplete:I})=>{const[t,a]=l.useState(!1),[r,i]=l.useState(null),h=async()=>{a(!0),i(null);try{const s=await y(x,p);sessionStorage.setItem("mathpulse_diagnostic",JSON.stringify({testId:s.test_id,questions:s.questions,totalItems:s.total_items,estimatedMinutes:s.estimated_minutes})),u(s.test_id,s.questions)}catch(s){const b=s instanceof Error?s.message:"Failed to load assessment";i(b),a(!1)}},f=()=>{sessionStorage.setItem("mathpulse_iar_session_dismissed","true"),d()},g=async()=>{try{await N(v(z,"users",c),{assessmentDismissed:!0,assessmentDismissedAt:w()})}catch(s){console.error("[diagnostic] Failed to save dismiss state:",s)}m()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.stopPropagation(),children:e.jsxs(o.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{type:"spring",damping:25,stiffness:200},className:"bg-white rounded-2xl shadow-2xl max-w-[36rem] w-full flex flex-col overflow-hidden pointer-events-auto",onClick:s=>s.stopPropagation(),style:{willChange:"transform, opacity"},children:[e.jsxs("div",{className:"px-5 py-3 border-b border-[#dde3eb] flex items-center justify-between bg-[#edf1f7] flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center text-purple-600",children:e.jsx(k,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-[#0a1628] leading-tight",children:"Initial Assessment"}),e.jsx("p",{className:"text-[11px] text-[#5a6578]",children:"Analyze your strengths & weaknesses"})]})]}),e.jsx("button",{onClick:f,"aria-label":"Close assessment modal",className:"ml-auto w-8 h-8 rounded-lg flex items-center justify-center text-[#5a6578] hover:bg-[#dde3eb] hover:text-[#0a1628] transition-colors",children:e.jsx(S,{size:18})})]}),e.jsx("div",{className:"p-5 text-center space-y-3",children:e.jsxs(o.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3,ease:"easeOut"},children:[e.jsx("div",{className:"w-20 h-20 bg-purple-50 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx("svg",{className:"w-9 h-9 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"})})}),e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:"Welcome to MathPulse AI!"}),e.jsx("p",{className:"text-[13px] text-[#5a6578] max-w-[19rem] mx-auto leading-relaxed",children:"To personalize your learning path, complete a DepEd competency-based SHS diagnostic (15 items, around 11.6 minutes)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 max-w-[22rem] mx-auto text-left mt-4",children:[e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(A,{size:14,className:"text-teal-500"}),"Personalized Path"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Get recommendations based on your level."})]}),e.jsxs("div",{className:"bg-[#edf1f7] p-2.5 rounded-lg border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-[13px] text-[#0a1628] mb-1",children:[e.jsx(C,{size:14,className:"text-rose-500"}),"Identify Risks"]}),e.jsx("p",{className:"text-[10px] text-[#5a6578] pl-[18px]",children:"Spot areas that need more attention early."})]})]}),r&&e.jsx("div",{className:"mt-3 p-2.5 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-xs text-red-700",children:r})}),e.jsxs("div",{className:"pt-3 space-y-2.5",children:[e.jsx(j,{onClick:h,disabled:t,className:"bg-gradient-to-r from-purple-600 to-purple-500 hover:from-purple-700 hover:to-purple-600 text-white px-5 py-3 rounded-xl text-sm font-bold shadow-lg shadow-purple-200 w-full max-w-[320px] mx-auto",children:t?e.jsxs(e.Fragment,{children:[e.jsx(L,{size:16,className:"animate-spin mr-2"}),"Crafting your assessment..."]}):"Start Assessment"}),t&&e.jsx("p",{className:"text-[10px] text-slate-400 max-w-[18rem] mx-auto text-center leading-relaxed",children:"This may take up to 90 seconds while AI generates your personalized test."}),!t&&e.jsx("button",{onClick:g,disabled:t,className:"block mx-auto text-xs text-slate-500 hover:text-[#5a6578] transition-colors font-medium disabled:opacity-40",children:"Skip for now"})]})]})})]})}):null};export{H as default}; diff --git a/assets/LeaderboardPage-CoNMThBG.js b/assets/LeaderboardPage-BGY9czx-.js similarity index 93% rename from assets/LeaderboardPage-CoNMThBG.js rename to assets/LeaderboardPage-BGY9czx-.js index bb807b8990383334e72f3255aae8a0b265c3c700..3e7d079ca4003c8bd705394a0f5807eb391d4374 100644 --- a/assets/LeaderboardPage-CoNMThBG.js +++ b/assets/LeaderboardPage-BGY9czx-.js @@ -1,8 +1,8 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{c as O,aD as W,g as q,m as n,a as y,q as P,A as k,z as m,T as E,p as _,Y as T,$ as H,Q as U,l as $,aE as Q,R as G,L as K,y as X}from"./index-mbyiCUYG.js";import{X as V}from"./x-oZO0Ye1Q.js";import{C as Z}from"./clock-BLtPbCgT.js";import{u as J}from"./useFeatureAccess-CbliO-_q.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{e as O,aF as W,k as H,m as n,a as y,p as P,A as k,z as m,T as E,o as _,a0 as T,a1 as U,V as q,u as G,aG as V,R as $,L as K,x as X}from"./index-B3ruOzo6.js";import{X as Q}from"./x-BNHnAXzL.js";import{C as Z}from"./clock-C73na4Cu.js";import{u as J}from"./useFeatureAccess-CSvNejlY.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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. * See the LICENSE file in the root directory of this source tree. - */const ee=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],te=O("badge-check",ee),se=({student:s,onClose:f})=>{const[i,u]=l.useState([]),[p,h]=l.useState(!1);if(l.useEffect(()=>{s?.uid&&(h(!0),W(s.uid).then(u).catch(d=>console.error("Failed to load achievements:",d)).finally(()=>h(!1)))},[s?.uid]),!s)return null;const j={trophy:e.jsx(m,{size:24,className:"text-rose-500"}),flame:e.jsx(U,{size:24,className:"text-orange-500"}),star:e.jsx(H,{size:24,className:"text-rose-400"}),"book-open":e.jsx(y,{size:24,className:"text-sky-600"}),"badge-check":e.jsx(te,{size:24,className:"text-emerald-600"}),crown:e.jsx(T,{size:24,className:"text-rose-500"}),target:e.jsx(P,{size:24,className:"text-rose-500"})};return e.jsx(q,{children:e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(n.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:f,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(n.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-8 text-white relative overflow-hidden",children:[e.jsx("div",{className:"accent-line absolute top-0 left-0 right-0"}),e.jsx("button",{onClick:f,className:"absolute top-4 right-4 p-2 hover:bg-slate-100 rounded-xl transition-colors z-10",children:e.jsx(V,{size:20})}),e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 bg-white/10 backdrop-blur-sm rounded-2xl flex items-center justify-center text-6xl border border-slate-300",children:s.avatar}),s.isOnline&&e.jsx("div",{className:"absolute -bottom-2 -right-2 w-6 h-6 bg-green-500 rounded-full border-4 border-white"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-3xl font-display font-bold mb-2",children:s.name}),e.jsx("p",{className:"text-slate-500 mb-4",children:s.section}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"bg-slate-100 backdrop-blur-sm rounded-xl px-4 py-2 border border-slate-200",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Level"}),e.jsx("p",{className:"text-xl font-bold",children:s.level})]}),e.jsxs("div",{className:"bg-slate-100 backdrop-blur-sm rounded-xl px-4 py-2 border border-slate-200",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Total XP"}),e.jsx("p",{className:"text-xl font-bold",children:s.totalXP})]})]})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-sky-500/5 rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-rose-500/5 rounded-full translate-y-1/2 -translate-x-1/2"})]}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-320px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Performance Stats"}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(y,{size:24,className:"text-sky-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.quizzesCompleted}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Quizzes"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(P,{size:24,className:"text-emerald-600 mx-auto mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-[#0a1628]",children:[s.stats.averageScore,"%"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Avg Score"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(k,{size:24,className:"text-rose-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.modulesCompleted}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Modules"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(Z,{size:24,className:"text-rose-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.studyHours}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Hours"})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Rankings"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-rose-600 mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-rose-900",children:["#",s.rank.global]}),e.jsx("p",{className:"text-xs text-rose-700 mt-1 font-body",children:"School"})]}),e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-sky-600 mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-sky-900",children:["#",s.rank.section]}),e.jsx("p",{className:"text-xs text-sky-700 mt-1 font-body",children:"Section"})]}),e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-rose-600 mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-rose-900",children:s.rank.change>0?e.jsxs("span",{className:"flex items-center gap-1 text-emerald-600",children:[e.jsx(E,{size:20}),"+",s.rank.change]}):s.rank.change<0?e.jsxs("span",{className:"flex items-center gap-1 text-red-600",children:[e.jsx(E,{size:20,className:"rotate-180"}),s.rank.change]}):"0"}),e.jsx("p",{className:"text-xs text-rose-700 mt-1 font-body",children:"This Week"})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Achievements"}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_,{size:24,className:"text-sky-500 animate-spin"})}):i.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-3",children:i.map(d=>e.jsxs("div",{className:"rounded-xl p-4 text-center transition-all bg-white border-2 border-sky-200",children:[e.jsx("div",{className:"text-3xl mb-2",children:j[d.icon]||e.jsx(k,{size:24,className:"text-slate-500 mx-auto"})}),e.jsx("p",{className:"font-bold text-xs text-[#0a1628] mb-1 font-body",children:d.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:d.description})]},d.id))}):e.jsxs("div",{className:"flex flex-col items-center py-8 gap-2",children:[e.jsx(k,{size:32,className:"text-[#d1cec6]"}),e.jsx("p",{className:"text-sm text-[#5a6578] font-body",children:"No achievements unlocked yet"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Recent Activity"}),e.jsxs("div",{className:"flex flex-col items-center py-8 gap-2",children:[e.jsx(y,{size:32,className:"text-[#d1cec6]"}),e.jsx("p",{className:"text-sm text-[#5a6578] font-body",children:"Activity history coming soon"})]})]})]})]})]})})},ue=({currentUserPhoto:s,onBack:f})=>{const{currentUser:i,userProfile:u}=$(),p=u,{leaderboard:h,loading:j}=J(i?.uid||null),[d]=l.useState("section"),[g,I]=l.useState("weekly"),[M,z]=l.useState(null),[Y,v]=l.useState(!0),[F,S]=l.useState(null),[D,C]=l.useState([]),w=[p?.grade,p?.section].filter(Boolean).join(" - "),N=l.useCallback(async()=>{if(!i){v(!1);return}v(!0),S(null);try{const t=g==="all"?"all":"week",r=await Q(i.uid,!1,t,20);if(!r||r.length===0){C([]);return}const c=r.map(a=>({id:a.userId,uid:a.userId,name:a.name,avatar:a.userId===i.uid?s||a.photo||"":a.photo||"",level:a.level,totalXP:a.xp,section:w||"Grade 11 - STEM A",rank:{global:a.rank,section:a.rank,change:0},stats:{quizzesCompleted:0,averageScore:0,modulesCompleted:0,studyHours:0},isOnline:!1,isYou:a.userId===i.uid}));C(c)}catch(t){console.error("Error loading leaderboard:",t),S(t instanceof Error?t.message:"Failed to load leaderboard")}finally{v(!1)}},[i,w,g,s]);l.useEffect(()=>{N()},[N]);const x=(()=>{let t=D;if(d==="section"){const c=w||"";c&&(t=t.filter(a=>a.section===c))}return t.sort((c,a)=>{const B=d==="section"?"section":"global";return(c.rank[B]||999)-(a.rank[B]||999)})})(),A=x.find(t=>t.isYou)?.rank.section||x.length+1,R=x.length>1?Math.max(10,Math.min(99,100-A/Math.max(1,x.length)*100)):90,o=x.slice(0,3),L=x.slice(3),b=(t,r)=>t?t.startsWith("http")||t.startsWith("data:")?e.jsx("img",{src:t,alt:"Avatar",className:"w-full h-full object-cover rounded-full"}):e.jsx(X,{size:r,className:"text-slate-400 opacity-70"}):e.jsx(X,{size:r,className:"text-slate-400 opacity-70"});return Y?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx(_,{className:"w-8 h-8 animate-spin text-purple-600"}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading leaderboard..."})]}):F?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(m,{className:"w-7 h-7 text-red-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Couldn't load leaderboard"}),e.jsx("p",{className:"text-xs text-slate-400",children:F})]}),e.jsxs("button",{onClick:N,className:"flex items-center gap-2 px-4 py-2 bg-purple-600 text-white text-sm font-medium rounded-xl hover:bg-purple-700 transition-colors",children:[e.jsx(G,{size:14}),"Try Again"]})]}):j?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx(_,{className:"w-8 h-8 animate-spin text-purple-600"}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading..."})]}):h?e.jsxs("div",{className:"w-full min-h-screen relative flex flex-col items-center font-body text-white",children:[e.jsxs("div",{className:"absolute inset-x-[-20px] top-0 h-[100vh] min-h-[800px] z-[-1] pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_50%_100%,#9333ea_0%,#c084fc_40%,transparent_80%)]"}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-[250vw] md:w-[200vw] h-[150vh] opacity-75 pointer-events-none",style:{WebkitMaskImage:"radial-gradient(circle at 50% 100%, black 10%, transparent 60%)"},children:e.jsx(n.div,{className:"absolute bottom-0 left-1/2 w-[600vw] h-[600vw] md:w-[400vw] md:h-[400vw]",style:{x:"-50%",y:"50%",originX:.5,originY:.5,background:`repeating-conic-gradient(from 0deg at 50% 50%, + */const ee=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],te=O("badge-check",ee),se=({student:s,onClose:f})=>{const[i,u]=l.useState([]),[p,h]=l.useState(!1);if(l.useEffect(()=>{s?.uid&&(h(!0),W(s.uid).then(u).catch(d=>console.error("Failed to load achievements:",d)).finally(()=>h(!1)))},[s?.uid]),!s)return null;const j={trophy:e.jsx(m,{size:24,className:"text-rose-500"}),flame:e.jsx(q,{size:24,className:"text-orange-500"}),star:e.jsx(U,{size:24,className:"text-rose-400"}),"book-open":e.jsx(y,{size:24,className:"text-sky-600"}),"badge-check":e.jsx(te,{size:24,className:"text-emerald-600"}),crown:e.jsx(T,{size:24,className:"text-rose-500"}),target:e.jsx(P,{size:24,className:"text-rose-500"})};return e.jsx(H,{children:e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(n.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:f,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(n.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-8 text-white relative overflow-hidden",children:[e.jsx("div",{className:"accent-line absolute top-0 left-0 right-0"}),e.jsx("button",{onClick:f,className:"absolute top-4 right-4 p-2 hover:bg-slate-100 rounded-xl transition-colors z-10",children:e.jsx(Q,{size:20})}),e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 bg-white/10 backdrop-blur-sm rounded-2xl flex items-center justify-center text-6xl border border-slate-300",children:s.avatar}),s.isOnline&&e.jsx("div",{className:"absolute -bottom-2 -right-2 w-6 h-6 bg-green-500 rounded-full border-4 border-white"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-3xl font-display font-bold mb-2",children:s.name}),e.jsx("p",{className:"text-slate-500 mb-4",children:s.section}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"bg-slate-100 backdrop-blur-sm rounded-xl px-4 py-2 border border-slate-200",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Level"}),e.jsx("p",{className:"text-xl font-bold",children:s.level})]}),e.jsxs("div",{className:"bg-slate-100 backdrop-blur-sm rounded-xl px-4 py-2 border border-slate-200",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Total XP"}),e.jsx("p",{className:"text-xl font-bold",children:s.totalXP})]})]})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-sky-500/5 rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-rose-500/5 rounded-full translate-y-1/2 -translate-x-1/2"})]}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-320px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Performance Stats"}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(y,{size:24,className:"text-sky-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.quizzesCompleted}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Quizzes"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(P,{size:24,className:"text-emerald-600 mx-auto mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-[#0a1628]",children:[s.stats.averageScore,"%"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Avg Score"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(k,{size:24,className:"text-rose-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.modulesCompleted}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Modules"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-[#dde3eb] p-4 text-center",children:[e.jsx(Z,{size:24,className:"text-rose-600 mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-[#0a1628]",children:s.stats.studyHours}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Hours"})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Rankings"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-rose-600 mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-rose-900",children:["#",s.rank.global]}),e.jsx("p",{className:"text-xs text-rose-700 mt-1 font-body",children:"School"})]}),e.jsxs("div",{className:"bg-sky-50 border border-sky-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-sky-600 mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-sky-900",children:["#",s.rank.section]}),e.jsx("p",{className:"text-xs text-sky-700 mt-1 font-body",children:"Section"})]}),e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded-xl p-4",children:[e.jsx(m,{size:20,className:"text-rose-600 mb-2"}),e.jsx("p",{className:"text-2xl font-bold text-rose-900",children:s.rank.change>0?e.jsxs("span",{className:"flex items-center gap-1 text-emerald-600",children:[e.jsx(E,{size:20}),"+",s.rank.change]}):s.rank.change<0?e.jsxs("span",{className:"flex items-center gap-1 text-red-600",children:[e.jsx(E,{size:20,className:"rotate-180"}),s.rank.change]}):"0"}),e.jsx("p",{className:"text-xs text-rose-700 mt-1 font-body",children:"This Week"})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Achievements"}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_,{size:24,className:"text-sky-500 animate-spin"})}):i.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-3",children:i.map(d=>e.jsxs("div",{className:"rounded-xl p-4 text-center transition-all bg-white border-2 border-sky-200",children:[e.jsx("div",{className:"text-3xl mb-2",children:j[d.icon]||e.jsx(k,{size:24,className:"text-slate-500 mx-auto"})}),e.jsx("p",{className:"font-bold text-xs text-[#0a1628] mb-1 font-body",children:d.title}),e.jsx("p",{className:"text-xs text-[#5a6578]",children:d.description})]},d.id))}):e.jsxs("div",{className:"flex flex-col items-center py-8 gap-2",children:[e.jsx(k,{size:32,className:"text-[#d1cec6]"}),e.jsx("p",{className:"text-sm text-[#5a6578] font-body",children:"No achievements unlocked yet"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-lg text-[#0a1628] mb-4",children:"Recent Activity"}),e.jsxs("div",{className:"flex flex-col items-center py-8 gap-2",children:[e.jsx(y,{size:32,className:"text-[#d1cec6]"}),e.jsx("p",{className:"text-sm text-[#5a6578] font-body",children:"Activity history coming soon"})]})]})]})]})]})})},ue=({currentUserPhoto:s,onBack:f})=>{const{currentUser:i,userProfile:u}=G(),p=u,{leaderboard:h,loading:j}=J(i?.uid||null),[d]=l.useState("section"),[g,I]=l.useState("weekly"),[M,z]=l.useState(null),[R,v]=l.useState(!0),[F,S]=l.useState(null),[Y,C]=l.useState([]),w=[p?.grade,p?.section].filter(Boolean).join(" - "),N=l.useCallback(async()=>{if(!i){v(!1);return}v(!0),S(null);try{const t=g==="all"?"all":"week",r=await V(i.uid,!1,t,20);if(!r||r.length===0){C([]);return}const c=r.map(a=>({id:a.userId,uid:a.userId,name:a.name,avatar:a.userId===i.uid?s||a.photo||"":a.photo||"",level:a.level,totalXP:a.xp,section:w||"Grade 11 - STEM A",rank:{global:a.rank,section:a.rank,change:0},stats:{quizzesCompleted:0,averageScore:0,modulesCompleted:0,studyHours:0},isOnline:!1,isYou:a.userId===i.uid}));C(c)}catch(t){console.error("Error loading leaderboard:",t),S(t instanceof Error?t.message:"Failed to load leaderboard")}finally{v(!1)}},[i,w,g,s]);l.useEffect(()=>{N()},[N]);const x=(()=>{let t=Y;if(d==="section"){const c=w||"";c&&(t=t.filter(a=>a.section===c))}return t.sort((c,a)=>{const B=d==="section"?"section":"global";return(c.rank[B]||999)-(a.rank[B]||999)})})(),A=x.find(t=>t.isYou)?.rank.section||x.length+1,D=x.length>1?Math.max(10,Math.min(99,100-A/Math.max(1,x.length)*100)):90,o=x.slice(0,3),L=x.slice(3),b=(t,r)=>t?t.startsWith("http")||t.startsWith("data:")?e.jsx("img",{src:t,alt:"Avatar",className:"w-full h-full object-cover rounded-full"}):e.jsx(X,{size:r,className:"text-slate-400 opacity-70"}):e.jsx(X,{size:r,className:"text-slate-400 opacity-70"});return R?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx(_,{className:"w-8 h-8 animate-spin text-purple-600"}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading leaderboard..."})]}):F?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(m,{className:"w-7 h-7 text-red-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Couldn't load leaderboard"}),e.jsx("p",{className:"text-xs text-slate-400",children:F})]}),e.jsxs("button",{onClick:N,className:"flex items-center gap-2 px-4 py-2 bg-purple-600 text-white text-sm font-medium rounded-xl hover:bg-purple-700 transition-colors",children:[e.jsx($,{size:14}),"Try Again"]})]}):j?e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-3",children:[e.jsx(_,{className:"w-8 h-8 animate-spin text-purple-600"}),e.jsx("p",{className:"text-sm text-slate-400 font-medium",children:"Loading..."})]}):h?e.jsxs("div",{className:"w-full min-h-screen relative flex flex-col items-center font-body text-white",children:[e.jsxs("div",{className:"absolute inset-x-[-20px] top-0 h-[100vh] min-h-[800px] z-[-1] pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_50%_100%,#9333ea_0%,#c084fc_40%,transparent_80%)]"}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-[250vw] md:w-[200vw] h-[150vh] opacity-75 pointer-events-none",style:{WebkitMaskImage:"radial-gradient(circle at 50% 100%, black 10%, transparent 60%)"},children:e.jsx(n.div,{className:"absolute bottom-0 left-1/2 w-[600vw] h-[600vw] md:w-[400vw] md:h-[400vw]",style:{x:"-50%",y:"50%",originX:.5,originY:.5,background:`repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0.7) 0deg, rgba(255,255,255,0.7) 6deg, - transparent 6deg, transparent 12deg)`},animate:{rotate:360},transition:{duration:160,repeat:1/0,ease:"linear"}})}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-[150vw] h-[100vh] bg-[radial-gradient(ellipse_at_50%_100%,#7e22ce_10%,transparent_60%)] mix-blend-overlay"})]}),e.jsx("div",{className:"absolute inset-0 bg-math-pattern opacity-[0.03] mix-blend-overlay pointer-events-none z-[-1]",style:{WebkitMaskImage:"linear-gradient(to bottom, transparent, black 15%)"}}),e.jsxs("div",{className:"relative z-10 w-full px-4 sm:px-8 py-4 md:py-6 flex flex-col items-center",children:[e.jsx("div",{className:"w-full flex justify-center items-center mb-4 mt-2",children:e.jsx("h1",{className:"text-3xl md:text-4xl font-display font-bold tracking-wide text-slate-800 drop-shadow-sm",children:"Leaderboard"})}),e.jsx("div",{className:"bg-slate-800/5 backdrop-blur-md rounded-full p-1 flex gap-1 mb-3 shadow-[inset_0_2px_4px_rgba(0,0,0,0.05)] border border-slate-800/10 w-full max-w-[340px]",children:["daily","weekly","all"].map(t=>e.jsx("button",{onClick:()=>I(t),className:`flex-1 py-1.5 rounded-full text-[13px] md:text-sm font-semibold transition-all capitalize inline-flex justify-center items-center ${g===t?"bg-white text-purple-700 shadow-md border border-white/50 backdrop-blur-lg":"text-slate-600 hover:text-purple-700 hover:bg-white/50"}`,children:t==="all"?"All Time":t},t))}),e.jsxs(n.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"w-full max-w-[420px] mb-4 bg-[#FFB356] p-2.5 md:p-3 rounded-full shadow-lg flex items-center gap-3 relative overflow-hidden ring-1 ring-white/20",children:[e.jsx("div",{className:"absolute inset-0 bg-noise opacity-[0.15] mix-blend-overlay pointer-events-none"}),e.jsx("div",{className:"bg-white/25 backdrop-blur-md px-4 py-2 min-w-[60px] rounded-full flex flex-col items-center justify-center shadow-sm z-10 border border-white/20",children:e.jsxs("span",{className:"text-xl md:text-2xl font-display font-bold text-white leading-none",children:["#",A]})}),e.jsx("div",{className:"z-10 flex-1 pr-2 md:pr-4",children:e.jsxs("p",{className:"font-medium text-white/90 text-sm md:text-[15px] leading-snug text-center",children:["You are doing better than ",e.jsxs("span",{className:"font-black text-white drop-shadow-sm",children:[Math.round(R),"%"]})," of other players!"]})})]}),e.jsxs("div",{className:"w-full max-w-[1000px] flex items-end justify-center gap-3 md:gap-6 h-[280px] md:h-[310px] relative z-20 mt-8 md:mt-12 mx-auto px-2 sm:px-4 group perspective-1000",children:[e.jsxs(n.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{delay:.15,type:"spring",stiffness:90},className:"flex flex-col items-center relative z-10 w-[30%] sm:w-[32%] max-w-[280px] mx-1 md:mr-2",children:[e.jsxs("div",{className:"flex flex-col items-center mb-2 md:mb-4 relative z-40 w-full",children:[e.jsx("div",{className:"w-14 h-14 md:w-[72px] md:h-[72px] rounded-full border-[3px] border-[#FF8B8B] bg-[#111827] flex items-center justify-center shadow-[0_0_18px_rgba(255,139,139,0.6)] overflow-hidden",children:b(o[1]?.avatar,26)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-xs md:text-sm drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[1]?.name||"---"})]}),e.jsxs("div",{className:"w-[90%] relative mt-2",children:[e.jsx("div",{className:"w-full h-10 md:h-14 absolute -bottom-5 md:-bottom-7 bg-[#D96C6A] rounded-[50%] shadow-[0_15px_25px_rgba(0,0,0,0.4)] z-0"}),e.jsx("div",{className:"w-full h-[100px] md:h-[130px] bg-[#D96C6A] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-3 flex items-center justify-center text-[60px] md:text-[80px] font-black text-white/10 drop-shadow",children:"2"})}),e.jsx("div",{className:"w-full h-10 md:h-14 absolute -top-5 md:-top-7 bg-[#FF8B8B] rounded-[50%] z-20 shadow-[0_4px_8px_rgba(0,0,0,0.3)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[18px] md:text-[26px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[1]?.totalXP||0," XP"]})})]})]}),e.jsxs(n.div,{initial:{opacity:0,y:60},animate:{opacity:1,y:0},transition:{delay:.05,type:"spring",stiffness:100},className:"flex flex-col items-center relative z-30 w-[38%] sm:w-[40%] max-w-[330px]",children:[e.jsxs("div",{className:"flex flex-col items-center mb-3 md:mb-5 relative z-40 w-full",children:[e.jsx(n.div,{animate:{y:[0,-6,0]},transition:{repeat:1/0,duration:2.2,ease:"easeInOut"},className:"mb-[-10px] z-30",children:e.jsx(T,{size:30,className:"text-yellow-300 fill-yellow-300 drop-shadow-[0_0_12px_rgba(250,204,21,0.9)] md:w-9 md:h-9"})}),e.jsx("div",{className:"w-16 h-16 md:w-[86px] md:h-[86px] rounded-full border-[4px] border-[#fde68a] bg-[#111827] flex items-center justify-center shadow-[0_0_24px_rgba(250,204,21,0.6)] overflow-hidden",children:b(o[0]?.avatar,34)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-sm md:text-base drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[0]?.name||"---"})]}),e.jsxs("div",{className:"w-[95%] relative mt-2",children:[e.jsx("div",{className:"w-full h-12 md:h-16 absolute -bottom-6 md:-bottom-8 bg-[#6F2BAF] rounded-[50%] shadow-[0_20px_30px_rgba(0,0,0,0.5)] z-0"}),e.jsx("div",{className:"w-full h-[140px] md:h-[180px] bg-[#6F2BAF] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-4 flex items-center justify-center text-[80px] md:text-[110px] font-black text-white/10 drop-shadow",children:"1"})}),e.jsx("div",{className:"w-full h-12 md:h-16 absolute -top-6 md:-top-8 bg-[#9956DE] rounded-[50%] z-20 shadow-[0_5px_12px_rgba(0,0,0,0.4)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[22px] md:text-[32px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[0]?.totalXP||0," XP"]})})]})]}),e.jsxs(n.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{delay:.25,type:"spring",stiffness:90},className:"flex flex-col items-center relative z-10 w-[30%] sm:w-[32%] max-w-[280px] mx-1 md:ml-2",children:[e.jsxs("div",{className:"flex flex-col items-center mb-2 md:mb-4 relative z-40 w-full",children:[e.jsx("div",{className:"w-14 h-14 md:w-[72px] md:h-[72px] rounded-full border-[3px] border-[#FFB356] bg-[#111827] flex items-center justify-center shadow-[0_0_18px_rgba(255,179,86,0.6)] overflow-hidden",children:b(o[2]?.avatar,26)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-xs md:text-sm drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[2]?.name||"---"})]}),e.jsxs("div",{className:"w-[90%] relative mt-2",children:[e.jsx("div",{className:"w-full h-10 md:h-14 absolute -bottom-5 md:-bottom-7 bg-[#DE7949] rounded-[50%] shadow-[0_15px_25px_rgba(0,0,0,0.4)] z-0"}),e.jsx("div",{className:"w-full h-[75px] md:h-[100px] bg-[#DE7949] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-1 flex items-center justify-center text-[50px] md:text-[70px] font-black text-white/10 drop-shadow",children:"3"})}),e.jsx("div",{className:"w-full h-10 md:h-14 absolute -top-5 md:-top-7 bg-[#FFB356] rounded-[50%] z-20 shadow-[0_4px_8px_rgba(0,0,0,0.3)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[16px] md:text-[22px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[2]?.totalXP||0," XP"]})})]})]})]})]}),e.jsxs("div",{className:"w-full flex-grow relative z-20 pt-6 pb-32 px-4 sm:px-10 flex flex-col items-center mt-[-20px] md:mt-[-40px] transition-all duration-300 hover:-translate-y-2 min-h-[50vh] group",children:[e.jsxs("div",{className:"absolute top-0 left-0 right-0 bottom-[-500px] z-[-2] overflow-hidden rounded-t-[2.5rem] pointer-events-none",children:[e.jsx("div",{className:"absolute top-[-5%] left-[-10%] w-[70%] h-[400px] bg-purple-400/30 rounded-full blur-[100px]"}),e.jsx("div",{className:"absolute top-[15%] right-[-5%] w-[60%] h-[350px] bg-amber-300/20 rounded-full blur-[120px]"}),e.jsx("div",{className:"absolute top-[45%] left-[15%] w-[80%] h-[400px] bg-fuchsia-300/20 rounded-full blur-[120px]"})]}),e.jsx("div",{className:"absolute top-0 left-0 right-0 bottom-[-500px] z-[-1] rounded-t-[2.5rem] bg-gradient-to-b from-white/60 to-white/20 backdrop-blur-2xl transition-all duration-300 shadow-[0_-15px_40px_rgba(0,0,0,0.1),inset_0_2px_15px_rgba(255,255,255,0.7),inset_0_1px_1px_rgba(255,255,255,1)] group-hover:shadow-[0_-20px_50px_rgba(0,0,0,0.15),inset_0_2px_15px_rgba(255,255,255,0.8),inset_0_1px_1px_rgba(255,255,255,1)] border-t border-white/80"}),e.jsx("div",{className:"w-12 h-1.5 bg-slate-300/60 rounded-full mb-6 mt-[-10px] shadow-[inset_0_1px_2px_rgba(0,0,0,0.1)] backdrop-blur-md"}),e.jsxs("div",{className:"w-full max-w-4xl space-y-3.5",children:[L.map((t,r)=>{const c=t.rank.global||r+4;return e.jsxs(n.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:r*.05+.3},onClick:()=>z(t),className:`flex items-center gap-4 p-3.5 md:p-4 rounded-3xl cursor-pointer bg-white border transition-all duration-300 ${t.isYou?"border-[#8B5CF6]/40 shadow-xl shadow-[#8B5CF6]/20 ring-2 ring-[#8B5CF6]/10":"border-slate-100 shadow-[0_12px_25px_rgba(0,0,0,0.08)] hover:shadow-[0_16px_30px_rgba(0,0,0,0.12)]"}`,children:[e.jsx("div",{className:"w-9 h-9 md:w-11 md:h-11 rounded-full border-2 border-slate-100 bg-white flex items-center justify-center font-display font-bold text-slate-500 shadow-sm text-sm",children:c}),e.jsx("div",{className:"w-11 h-11 md:w-14 md:h-14 bg-slate-100 rounded-full flex items-center justify-center text-xl overflow-hidden shadow-sm relative border-[3px] border-[#F1F5F9]",children:b(t.avatar,24)}),e.jsxs("div",{className:"flex-1 flex justify-between items-center pr-2",children:[e.jsx("div",{children:e.jsxs("h4",{className:"font-display font-bold text-[#1E293B] text-[15px] md:text-lg flex items-center gap-2 tracking-wide",children:[t.name,t.isYou&&e.jsx("span",{className:"text-[9px] uppercase tracking-wider bg-[#8B5CF6] text-white px-1.5 py-0.5 rounded font-bold",children:"You"})]})}),e.jsx("div",{children:e.jsxs("p",{className:"text-[13px] md:text-[15px] font-bold text-slate-500 text-right",children:[t.totalXP," ",e.jsx("span",{className:"text-[10px] text-slate-400 font-normal uppercase",children:"XP"})]})})]})]},t.id)}),L.length===0&&e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-slate-400 font-medium",children:"No other participants found in this view."})})]})]}),e.jsx(se,{student:M,onClose:()=>z(null)})]}):e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(K,{className:"w-7 h-7 text-slate-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Leaderboard Locked"}),e.jsx("p",{className:"text-xs text-slate-400",children:"This feature is temporarily unavailable while you focus on your learning."})]})]})};export{ue as default}; + transparent 6deg, transparent 12deg)`},animate:{rotate:360},transition:{duration:160,repeat:1/0,ease:"linear"}})}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-[150vw] h-[100vh] bg-[radial-gradient(ellipse_at_50%_100%,#7e22ce_10%,transparent_60%)] mix-blend-overlay"})]}),e.jsx("div",{className:"absolute inset-0 bg-math-pattern opacity-[0.03] mix-blend-overlay pointer-events-none z-[-1]",style:{WebkitMaskImage:"linear-gradient(to bottom, transparent, black 15%)"}}),e.jsxs("div",{className:"relative z-10 w-full px-4 sm:px-8 py-4 md:py-6 flex flex-col items-center",children:[e.jsx("div",{className:"w-full flex justify-center items-center mb-4 mt-2",children:e.jsx("h1",{className:"text-3xl md:text-4xl font-display font-bold tracking-wide text-slate-800 drop-shadow-sm",children:"Leaderboard"})}),e.jsx("div",{className:"bg-slate-800/5 backdrop-blur-md rounded-full p-1 flex gap-1 mb-3 shadow-[inset_0_2px_4px_rgba(0,0,0,0.05)] border border-slate-800/10 w-full max-w-[340px]",children:["daily","weekly","all"].map(t=>e.jsx("button",{onClick:()=>I(t),className:`flex-1 py-1.5 rounded-full text-[13px] md:text-sm font-semibold transition-all capitalize inline-flex justify-center items-center ${g===t?"bg-white text-purple-700 shadow-md border border-white/50 backdrop-blur-lg":"text-slate-600 hover:text-purple-700 hover:bg-white/50"}`,children:t==="all"?"All Time":t},t))}),e.jsxs(n.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"w-full max-w-[420px] mb-4 bg-[#FFB356] p-2.5 md:p-3 rounded-full shadow-lg flex items-center gap-3 relative overflow-hidden ring-1 ring-white/20",children:[e.jsx("div",{className:"absolute inset-0 bg-noise opacity-[0.15] mix-blend-overlay pointer-events-none"}),e.jsx("div",{className:"bg-white/25 backdrop-blur-md px-4 py-2 min-w-[60px] rounded-full flex flex-col items-center justify-center shadow-sm z-10 border border-white/20",children:e.jsxs("span",{className:"text-xl md:text-2xl font-display font-bold text-white leading-none",children:["#",A]})}),e.jsx("div",{className:"z-10 flex-1 pr-2 md:pr-4",children:e.jsxs("p",{className:"font-medium text-white/90 text-sm md:text-[15px] leading-snug text-center",children:["You are doing better than ",e.jsxs("span",{className:"font-black text-white drop-shadow-sm",children:[Math.round(D),"%"]})," of other players!"]})})]}),e.jsxs("div",{className:"w-full max-w-[1000px] flex items-end justify-center gap-3 md:gap-6 h-[280px] md:h-[310px] relative z-20 mt-8 md:mt-12 mx-auto px-2 sm:px-4 group perspective-1000",children:[e.jsxs(n.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{delay:.15,type:"spring",stiffness:90},className:"flex flex-col items-center relative z-10 w-[30%] sm:w-[32%] max-w-[280px] mx-1 md:mr-2",children:[e.jsxs("div",{className:"flex flex-col items-center mb-2 md:mb-4 relative z-40 w-full",children:[e.jsx("div",{className:"w-14 h-14 md:w-[72px] md:h-[72px] rounded-full border-[3px] border-[#FF8B8B] bg-[#111827] flex items-center justify-center shadow-[0_0_18px_rgba(255,139,139,0.6)] overflow-hidden",children:b(o[1]?.avatar,26)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-xs md:text-sm drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[1]?.name||"---"})]}),e.jsxs("div",{className:"w-[90%] relative mt-2",children:[e.jsx("div",{className:"w-full h-10 md:h-14 absolute -bottom-5 md:-bottom-7 bg-[#D96C6A] rounded-[50%] shadow-[0_15px_25px_rgba(0,0,0,0.4)] z-0"}),e.jsx("div",{className:"w-full h-[100px] md:h-[130px] bg-[#D96C6A] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-3 flex items-center justify-center text-[60px] md:text-[80px] font-black text-white/10 drop-shadow",children:"2"})}),e.jsx("div",{className:"w-full h-10 md:h-14 absolute -top-5 md:-top-7 bg-[#FF8B8B] rounded-[50%] z-20 shadow-[0_4px_8px_rgba(0,0,0,0.3)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[18px] md:text-[26px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[1]?.totalXP||0," XP"]})})]})]}),e.jsxs(n.div,{initial:{opacity:0,y:60},animate:{opacity:1,y:0},transition:{delay:.05,type:"spring",stiffness:100},className:"flex flex-col items-center relative z-30 w-[38%] sm:w-[40%] max-w-[330px]",children:[e.jsxs("div",{className:"flex flex-col items-center mb-3 md:mb-5 relative z-40 w-full",children:[e.jsx(n.div,{animate:{y:[0,-6,0]},transition:{repeat:1/0,duration:2.2,ease:"easeInOut"},className:"mb-[-10px] z-30",children:e.jsx(T,{size:30,className:"text-yellow-300 fill-yellow-300 drop-shadow-[0_0_12px_rgba(250,204,21,0.9)] md:w-9 md:h-9"})}),e.jsx("div",{className:"w-16 h-16 md:w-[86px] md:h-[86px] rounded-full border-[4px] border-[#fde68a] bg-[#111827] flex items-center justify-center shadow-[0_0_24px_rgba(250,204,21,0.6)] overflow-hidden",children:b(o[0]?.avatar,34)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-sm md:text-base drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[0]?.name||"---"})]}),e.jsxs("div",{className:"w-[95%] relative mt-2",children:[e.jsx("div",{className:"w-full h-12 md:h-16 absolute -bottom-6 md:-bottom-8 bg-[#6F2BAF] rounded-[50%] shadow-[0_20px_30px_rgba(0,0,0,0.5)] z-0"}),e.jsx("div",{className:"w-full h-[140px] md:h-[180px] bg-[#6F2BAF] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-4 flex items-center justify-center text-[80px] md:text-[110px] font-black text-white/10 drop-shadow",children:"1"})}),e.jsx("div",{className:"w-full h-12 md:h-16 absolute -top-6 md:-top-8 bg-[#9956DE] rounded-[50%] z-20 shadow-[0_5px_12px_rgba(0,0,0,0.4)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[22px] md:text-[32px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[0]?.totalXP||0," XP"]})})]})]}),e.jsxs(n.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{delay:.25,type:"spring",stiffness:90},className:"flex flex-col items-center relative z-10 w-[30%] sm:w-[32%] max-w-[280px] mx-1 md:ml-2",children:[e.jsxs("div",{className:"flex flex-col items-center mb-2 md:mb-4 relative z-40 w-full",children:[e.jsx("div",{className:"w-14 h-14 md:w-[72px] md:h-[72px] rounded-full border-[3px] border-[#FFB356] bg-[#111827] flex items-center justify-center shadow-[0_0_18px_rgba(255,179,86,0.6)] overflow-hidden",children:b(o[2]?.avatar,26)}),e.jsx("h3",{className:"font-semibold text-white mt-1.5 md:mt-2 text-xs md:text-sm drop-shadow-md w-full text-center pb-1 px-1 whitespace-normal break-words leading-tight relative z-50",children:o[2]?.name||"---"})]}),e.jsxs("div",{className:"w-[90%] relative mt-2",children:[e.jsx("div",{className:"w-full h-10 md:h-14 absolute -bottom-5 md:-bottom-7 bg-[#DE7949] rounded-[50%] shadow-[0_15px_25px_rgba(0,0,0,0.4)] z-0"}),e.jsx("div",{className:"w-full h-[75px] md:h-[100px] bg-[#DE7949] relative z-10 flex flex-col items-center justify-start overflow-hidden",children:e.jsx("span",{className:"absolute inset-x-0 top-1 flex items-center justify-center text-[50px] md:text-[70px] font-black text-white/10 drop-shadow",children:"3"})}),e.jsx("div",{className:"w-full h-10 md:h-14 absolute -top-5 md:-top-7 bg-[#FFB356] rounded-[50%] z-20 shadow-[0_4px_8px_rgba(0,0,0,0.3)] flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-black/25 font-black text-[16px] md:text-[22px] transform scale-y-75 uppercase tracking-widest pointer-events-none z-30",children:[o[2]?.totalXP||0," XP"]})})]})]})]})]}),e.jsxs("div",{className:"w-full flex-grow relative z-20 pt-6 pb-32 px-4 sm:px-10 flex flex-col items-center mt-[-20px] md:mt-[-40px] transition-all duration-300 hover:-translate-y-2 min-h-[50vh] group",children:[e.jsxs("div",{className:"absolute top-0 left-0 right-0 bottom-[-500px] z-[-2] overflow-hidden rounded-t-[2.5rem] pointer-events-none",children:[e.jsx("div",{className:"absolute top-[-5%] left-[-10%] w-[70%] h-[400px] bg-purple-400/30 rounded-full blur-[100px]"}),e.jsx("div",{className:"absolute top-[15%] right-[-5%] w-[60%] h-[350px] bg-amber-300/20 rounded-full blur-[120px]"}),e.jsx("div",{className:"absolute top-[45%] left-[15%] w-[80%] h-[400px] bg-fuchsia-300/20 rounded-full blur-[120px]"})]}),e.jsx("div",{className:"absolute top-0 left-0 right-0 bottom-[-500px] z-[-1] rounded-t-[2.5rem] bg-gradient-to-b from-white/60 to-white/20 backdrop-blur-2xl transition-all duration-300 shadow-[0_-15px_40px_rgba(0,0,0,0.1),inset_0_2px_15px_rgba(255,255,255,0.7),inset_0_1px_1px_rgba(255,255,255,1)] group-hover:shadow-[0_-20px_50px_rgba(0,0,0,0.15),inset_0_2px_15px_rgba(255,255,255,0.8),inset_0_1px_1px_rgba(255,255,255,1)] border-t border-white/80"}),e.jsx("div",{className:"w-12 h-1.5 bg-slate-300/60 rounded-full mb-6 mt-[-10px] shadow-[inset_0_1px_2px_rgba(0,0,0,0.1)] backdrop-blur-md"}),e.jsxs("div",{className:"w-full max-w-4xl space-y-3.5",children:[L.map((t,r)=>{const c=t.rank.global||r+4;return e.jsxs(n.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:r*.05+.3},onClick:()=>z(t),className:`flex items-center gap-4 p-3.5 md:p-4 rounded-3xl cursor-pointer bg-white border transition-all duration-300 ${t.isYou?"border-[#8B5CF6]/40 shadow-xl shadow-[#8B5CF6]/20 ring-2 ring-[#8B5CF6]/10":"border-slate-100 shadow-[0_12px_25px_rgba(0,0,0,0.08)] hover:shadow-[0_16px_30px_rgba(0,0,0,0.12)]"}`,children:[e.jsx("div",{className:"w-9 h-9 md:w-11 md:h-11 rounded-full border-2 border-slate-100 bg-white flex items-center justify-center font-display font-bold text-slate-500 shadow-sm text-sm",children:c}),e.jsx("div",{className:"w-11 h-11 md:w-14 md:h-14 bg-slate-100 rounded-full flex items-center justify-center text-xl overflow-hidden shadow-sm relative border-[3px] border-[#F1F5F9]",children:b(t.avatar,24)}),e.jsxs("div",{className:"flex-1 flex justify-between items-center pr-2",children:[e.jsx("div",{children:e.jsxs("h4",{className:"font-display font-bold text-[#1E293B] text-[15px] md:text-lg flex items-center gap-2 tracking-wide",children:[t.name,t.isYou&&e.jsx("span",{className:"text-[9px] uppercase tracking-wider bg-[#8B5CF6] text-white px-1.5 py-0.5 rounded font-bold",children:"You"})]})}),e.jsx("div",{children:e.jsxs("p",{className:"text-[13px] md:text-[15px] font-bold text-slate-500 text-right",children:[t.totalXP," ",e.jsx("span",{className:"text-[10px] text-slate-400 font-normal uppercase",children:"XP"})]})})]})]},t.id)}),L.length===0&&e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-slate-400 font-medium",children:"No other participants found in this view."})})]})]}),e.jsx(se,{student:M,onClose:()=>z(null)})]}):e.jsxs("div",{className:"flex flex-col justify-center items-center h-[500px] gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(K,{className:"w-7 h-7 text-slate-400"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Leaderboard Locked"}),e.jsx("p",{className:"text-xs text-slate-400",children:"This feature is temporarily unavailable while you focus on your learning."})]})]})};export{ue as default}; diff --git a/assets/LearningPath-B69Oihj_.js b/assets/LearningPath-BIfd3u7Y.js similarity index 79% rename from assets/LearningPath-B69Oihj_.js rename to assets/LearningPath-BIfd3u7Y.js index da5c9c343d89da96c64c935af8b595c4aa74c7e4..c2d7ee1ab03b409dda9efbec85e2fcd9b0dce39c 100644 --- a/assets/LearningPath-B69Oihj_.js +++ b/assets/LearningPath-BIfd3u7Y.js @@ -1 +1 @@ -import{r as m,d as p,j as r}from"./vendor-react-B4AQeu28.js";import{l as j,a3 as P,a4 as I,x as N,a as k,b as L}from"./index-mbyiCUYG.js";import{M as S}from"./ModuleFolderCard-BQjDrVls.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-CN1BUyIM.js";import"./clock-BLtPbCgT.js";const V=({onNavigateToModules:c,atRiskSubjects:d=[],priorityTopics:o=[],modules:a})=>{const{userProfile:l}=j(),[u,h]=m.useState(null),i=p.useMemo(()=>{const e=o.length>0?o:d.map(s=>P(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,d]),x=p.useMemo(()=>{if(i.length===0)return a.slice(0,3);const e=new Map(i.map((t,s)=>[I[t],s]));return[...a].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,b=e.get(s.id)??Number.POSITIVE_INFINITY;return n-b}).slice(0,3)},[a,i]);m.useEffect(()=>{l?.uid&&N(l.uid).then(h).catch(console.error)},[l?.uid]);const g=x.slice(0,3).map(e=>{const t=u?.subjects?.[e.subject]?.modulesProgress?.[e.id],s=e.lessons.length,n=t?.progress??(s>0?Math.round((t?.lessonsCompleted?.length||0)/s*100):0);return{...e,progress:n,status:n===100?"Completed":n>0?"In Progress":"Not Started"}}),f=g.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(k,{size:20,strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:f})]}),r.jsxs("button",{onClick:()=>c?.(),className:"text-primary font-bold text-sm flex items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-4 py-2 rounded-xl hover:bg-primary/20",children:["View All ",r.jsx(L,{size:16})]})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:g.map((e,t)=>r.jsx(S,{module:e,index:t,onClick:()=>c?.(e.id),isAtRisk:i.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0},e.id))})]})};export{V as default}; +import{r as m,d as p,j as r}from"./vendor-react-B4AQeu28.js";import{u as j,a5 as P,a6 as I,w as N,a as k,b as w}from"./index-B3ruOzo6.js";import{M as L}from"./ModuleFolderCard-DKst1S7k.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-D7FKRlYS.js";import"./clock-C73na4Cu.js";const V=({onNavigateToModules:c,atRiskSubjects:d=[],priorityTopics:o=[],modules:a})=>{const{userProfile:l}=j(),[u,h]=m.useState(null),i=p.useMemo(()=>{const e=o.length>0?o:d.map(s=>P(s)).filter(s=>s!==null),t=new Set;return e.filter(s=>t.has(s)?!1:(t.add(s),!0))},[o,d]),x=p.useMemo(()=>{if(i.length===0)return a.slice(0,3);const e=new Map(i.map((t,s)=>[I[t],s]));return[...a].sort((t,s)=>{const n=e.get(t.id)??Number.POSITIVE_INFINITY,b=e.get(s.id)??Number.POSITIVE_INFINITY;return n-b}).slice(0,3)},[a,i]);m.useEffect(()=>{l?.uid&&N(l.uid).then(h).catch(console.error)},[l?.uid]);const g=x.slice(0,3).map(e=>{const t=u?.subjects?.[e.subject]?.modulesProgress?.[e.id],s=e.lessons.length,n=t?.progress??(s>0?Math.round((t?.lessonsCompleted?.length||0)/s*100):0);return{...e,progress:n,status:n===100?"Completed":n>0?"In Progress":"Not Started"}}),f=g.some(e=>e.progress>0)?"Continue Learning":"Start Learning";return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-6 px-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500 shadow-inner",children:r.jsx(k,{size:20,strokeWidth:2.5})}),r.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:f})]}),r.jsxs("button",{onClick:()=>c?.(),className:"text-primary font-bold text-sm flex items-center gap-1 hover:gap-2 transition-all bg-primary/10 px-4 py-2 rounded-xl hover:bg-primary/20",children:["View All ",r.jsx(w,{size:16})]})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:g.map((e,t)=>r.jsx(L,{module:e,index:t,onClick:()=>c?.(e.id),isAtRisk:i.length>0,badgeLabel:e.status!=="Not Started"?e.status:void 0},e.id))})]})};export{V as default}; diff --git a/assets/LoginPage-CptqcE8b.js b/assets/LoginPage-CptqcE8b.js new file mode 100644 index 0000000000000000000000000000000000000000..f137f4bfbda2cca470f9afdf4e4753cebc976f00 --- /dev/null +++ b/assets/LoginPage-CptqcE8b.js @@ -0,0 +1 @@ +import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as Me}from"./button-CaSK4KoS.js";import{I as D}from"./input-kh84w1XK.js";import{m as r,B as Ee,T as Te,A as Re,U as te,G as se,a as ae,L as re,b as ie,s as oe,c as Ce,d as le}from"./index-B3ruOzo6.js";import{S as Ie}from"./sparkles-Bq0AaIRg.js";import{M as Le}from"./mail-BXNRz1ib.js";import{E as De,a as ze}from"./eye-WyNbhirJ.js";import{S as qe}from"./shield-check-Cwi1kdxV.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";const ne="/assets/shader-bg-DA7bEbBA.mp4",Be=[{id:"length",label:"At least 8 characters",test:i=>i.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:i=>/[A-Z]/.test(i)&&/[a-z]/.test(i)},{id:"number",label:"Contains at least one number",test:i=>/\d/.test(i)},{id:"special",label:"Contains at least one special character",test:i=>/[^A-Za-z0-9]/.test(i)}],z="Use at least 8 characters with uppercase, lowercase, number, and special character.",Oe=i=>{const c=typeof i=="object"&&i!==null?i:null,o=i instanceof Error?i.message:"";if(c?.code&&typeof c.code=="string")return{code:c.code.toLowerCase(),message:o};const d=o.match(/auth\/[a-z-]+/i);return{code:d?d[0].toLowerCase():"",message:o}},_e=i=>i.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),ce=(i,c)=>{const{code:o,message:d}=Oe(i),h=_e(d);return o==="auth/invalid-credential"||o==="auth/wrong-password"||o==="auth/user-not-found"?"Invalid email or password. Please check your credentials and try again.":o==="auth/email-already-in-use"?"This email is already registered. Please sign in instead.":o==="auth/weak-password"||o==="auth/password-does-not-meet-requirements"?h?`Password does not meet signup requirements. ${h}`:`Password does not meet signup requirements. ${z}`:o==="auth/too-many-requests"?"Access to this account has been temporarily disabled due to many failed login attempts. You can immediately restore it by resetting your password or you can try again later.":o==="auth/network-request-failed"?"Network error. Please check your internet connection and try again.":o.startsWith("auth/")?h||c:d.includes("Firebase:")||d.includes("auth/")?c:d||c},rt=()=>{const i=["Grade 11"],c={"Grade 11":["STEM A","STEM B","ABM A","HUMSS A"]},o={teacher:["Mathematics","Science","English","Technology","Humanities"]},[d,h]=s.useState(""),[f,q]=s.useState(""),[A,de]=s.useState(!1),[l,B]=s.useState(!1),[M,ue]=s.useState(""),[n,O]=s.useState("student"),[b,me]=s.useState("Grade 11"),[w,_]=s.useState(c["Grade 11"][0]),[g,V]=s.useState("Mathematics"),[G,x]=s.useState(!1),[v,m]=s.useState(null),[pe,xe]=s.useState(!1),[ye,he]=s.useState(!1),[E,be]=s.useState(16),[F,U]=s.useState("primary"),[$,T]=s.useState(0),R=s.useRef(null),C=s.useRef(null),N=pe&&ye,j=s.useRef("primary"),k=s.useRef(0),S=s.useRef(!1),W=1.1,H=.34,Y=t=>{const a=Math.max(0,Math.min(1,t));Math.abs(k.current-a)<.02||(k.current=a,T(a))},Z=t=>{!Number.isFinite(t)||t<=0||Math.abs(E-t)>.05&&be(t)},I=s.useMemo(()=>Be.map(t=>({...t,met:t.test(f)})),[f]),fe=s.useMemo(()=>I.every(t=>t.met),[I]),J=s.useMemo(()=>{if(!l||!v)return!1;const t=v.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[v,l]),ge=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)},ve=()=>{const t=C.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)};s.useEffect(()=>{if(!N)return;const t=R.current,a=C.current;if(!t||!a)return;let u=!1,p=0;j.current="primary",U("primary"),S.current=!1,k.current=0,T(0),t.loop=!1,a.loop=!1,t.currentTime=0,a.currentTime=0,a.pause(),t.play().catch(()=>{});const P=()=>{if(u)return;const y=j.current==="primary"?t:a,K=j.current==="primary"?a:t,Pe=Number.isFinite(y.duration)&&y.duration>0?y.duration:E,L=Math.max(Pe-y.currentTime,0);if(L<=W){S.current||(S.current=!0,K.currentTime=0,K.play().catch(()=>{}));const Ae=1-L/W;if(Y(Ae),L<=.03||y.ended){y.pause(),y.currentTime=0;const ee=j.current==="primary"?"secondary":"primary";j.current=ee,U(ee),S.current=!1,k.current=0,T(0)}}else Y(0);p=window.requestAnimationFrame(P)};return p=window.requestAnimationFrame(P),()=>{u=!0,p&&window.cancelAnimationFrame(p)}},[E,N]);const Q=N?H*(1-$):0,X=N?H*$:0,je=F==="primary"?Q:X,we=F==="secondary"?Q:X;s.useEffect(()=>{n==="teacher"&&!o.teacher.includes(g)&&V(o.teacher[0])},[g,n]),s.useEffect(()=>{const t=c[b]||[];t.length>0&&!t.includes(w)&&_(t[0])},[b,w]);const Ne=[{label:"Student",role:"student",email:"teststudent@school.edu",password:"TestPass123!",icon:se,color:"sky"},{label:"Teacher",role:"teacher",email:"testteacher@school.edu",password:"TestPass123!",icon:ae,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:qe,color:"rose"}],ke=async(t,a,u)=>{m(null),x(!0),h(t),q(a),O(u),B(!1);try{oe(u),await le(t,a)}catch(p){m(ce(p,"Demo sign-in failed. Please try again.")),x(!1)}},Se=async t=>{t.preventDefault(),m(null),x(!0);try{if(l){if(!M.trim()){m("Please enter your name"),x(!1);return}if(n==="student"&&!b){m("Please select a grade level"),x(!1);return}if(n!=="student"&&!g){m("Please select a department"),x(!1);return}if(n==="admin"){m("Admin account creation is restricted. Please contact an existing administrator."),x(!1);return}if(!fe){m(`Password does not meet signup requirements. ${z}`),x(!1);return}oe(n),await Ce(d,f,M,n,n==="student"?{grade:b,section:w}:{department:g})}else await le(d,f)}catch(a){const u=l?`Sign-up failed. ${z}`:"Sign-in failed. Please check your credentials and try again.";m(ce(a,u)),x(!1)}};return e.jsxs("div",{className:"h-screen w-full flex items-center justify-center px-6 overflow-hidden relative login-bg",children:[e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>xe(!0),onLoadedMetadata:ge,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":je},src:ne}),e.jsx("video",{ref:C,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>he(!0),onLoadedMetadata:ve,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":we},src:ne}),e.jsx("div",{className:"absolute inset-0 pointer-events-none login-frost-overlay"}),e.jsx("div",{className:"absolute top-[10%] left-[-10%] w-[60%] h-[60%] rounded-full blur-[140px] pointer-events-none mix-blend-multiply login-orb-purple"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[70%] h-[70%] rounded-full blur-[160px] pointer-events-none mix-blend-multiply login-orb-pink"}),e.jsx("div",{className:"absolute top-[40%] left-[40%] w-[40%] h-[40%] rounded-full blur-[120px] pointer-events-none mix-blend-screen login-orb-blue"}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 items-center",children:[e.jsxs(r.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col justify-center space-y-8",children:[e.jsxs(r.div,{className:"flex items-center gap-2.5",children:[e.jsx(r.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI Logo",className:"w-16 h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black tracking-tight text-slate-900 bg-clip-text text-transparent bg-gradient-to-r from-purple-600 via-pink-600 to-sky-500",children:"MathPulse"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(Ie,{size:12,className:"text-rose-500"}),e.jsx("span",{className:"text-xs text-slate-500 font-body font-medium tracking-wide",children:"Powered by Machine Learning"})]})]})]}),e.jsxs(r.div,{className:"space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-4xl lg:text-5xl xl:text-[3.4rem] font-display font-extrabold leading-[1.1] tracking-tight text-slate-900",children:["Transform Your",e.jsx("br",{}),e.jsx("span",{className:"bg-gradient-to-r from-sky-600 via-cyan-500 to-sky-500 bg-clip-text text-transparent",children:"Math Journey"})]}),e.jsx("p",{className:"text-base text-slate-500 leading-relaxed max-w-md font-body",children:"AI-powered predictive system designed to identify at-risk students and provide personalized learning recommendations."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{icon:Ee,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Te,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:Re,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,a)=>{const u=t.icon,p={sky:"border-sky-200/60 hover:border-sky-300",rose:"border-rose-200/60 hover:border-rose-300",emerald:"border-emerald-200/60 hover:border-emerald-300"},P={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},y={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(r.div,{className:`bg-white/80 backdrop-blur-xl border ${p[t.color]} rounded-xl p-4 transition-all cursor-pointer group shadow-md shadow-slate-900/[0.04]`,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5+a*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${y[t.color]} flex items-center justify-center mb-3`,children:e.jsx(u,{size:18,className:P[t.color]})}),e.jsx("h3",{className:"text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-xs text-slate-400 font-body",children:t.desc})]},a)})})]}),e.jsx(r.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.15,ease:[.22,1,.36,1]},className:"relative flex justify-center lg:justify-end",children:e.jsxs("div",{className:"bg-white/85 backdrop-blur-2xl border border-slate-200/60 rounded-3xl p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[3px] bg-gradient-to-r from-purple-500 via-pink-500 to-sky-500"}),e.jsx("div",{className:"absolute -top-40 left-1/2 -translate-x-1/2 w-80 h-80 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full blur-[60px] pointer-events-none"}),e.jsxs("div",{className:"text-center mb-6 relative",children:[e.jsx(r.h3,{className:"text-2xl font-display font-bold text-slate-900 mb-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},children:l?"Create Account":"Welcome Back"}),e.jsx(r.p,{className:"text-sm text-slate-500 font-body",initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:l?"Begin your learning journey":"Sign in to continue learning"})]}),e.jsxs("form",{onSubmit:Se,className:"space-y-4 mb-5 relative",children:[v&&!J&&e.jsx(r.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-rose-50 border border-rose-200 text-rose-600 px-4 py-3 rounded-lg text-sm font-body",children:v}),l&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"text",placeholder:"Your Name",value:M,onChange:t=>ue(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),l&&e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.45},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Account Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{role:"student",label:"Student"},{role:"teacher",label:"Teacher"}].map(t=>{const a=n===t.role;return e.jsx("button",{type:"button",onClick:()=>O(t.role),className:`rounded-lg border px-3 py-2 text-xs font-body font-semibold transition-all ${a?"border-sky-400 bg-sky-50 text-sky-700":"border-slate-200 bg-slate-50 text-slate-500 hover:border-slate-300"}`,children:t.label},t.role)})})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(se,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:b,onChange:t=>me(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:i.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:w,onChange:t=>_(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:(c[b]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n!=="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Department"}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:g,onChange:t=>V(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:o.teacher.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.5},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"email",placeholder:"your.email@school.edu",value:d,onChange:t=>h(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.6},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:A?"text":"password",placeholder:"••••••••",value:f,onChange:t=>q(t.target.value),className:"w-full pl-11 pr-11 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0,minLength:l?8:6}),e.jsx(r.button,{type:"button",onClick:()=>de(!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:A?e.jsx(De,{size:16}):e.jsx(ze,{size:16})})]}),l&&e.jsxs("div",{className:"mt-2 rounded-lg border border-sky-100/80 bg-sky-50/70 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-body font-semibold uppercase tracking-wider text-slate-600",children:"Password requirements"}),e.jsx("ul",{className:"mt-2 space-y-1",children:I.map(t=>e.jsxs("li",{className:`flex items-center gap-2 text-[11px] font-body ${t.met?"text-emerald-700":"text-slate-500"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t.met?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{children:t.label})]},t.id))}),J&&e.jsx("p",{className:"mt-2 text-[11px] font-body font-semibold text-rose-600",children:"Password does not meet signup requirements."})]})]}),e.jsx(r.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(Me,{type:"submit",disabled:G,className:"w-full bg-gradient-to-r from-purple-600 to-pink-500 hover:from-purple-500 hover:to-pink-400 text-white font-body font-semibold py-3 rounded-xl shadow-lg shadow-purple-600/25 hover:shadow-pink-500/35 hover:scale-[1.02] transition-all text-sm group relative overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(r.span,{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/15 to-white/0",animate:{x:["-100%","100%"]},transition:{duration:3,repeat:1/0,repeatDelay:2}}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[G?"Please wait...":l?"Create Account":"Sign In",e.jsx(ie,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{B(!l),m(null)},className:"text-sm text-slate-400 hover:text-sky-500 font-body font-medium transition-colors",children:l?"Already have an account? Sign in":"Don't have an account? Create one"})})]}),!l&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.85},className:"mb-4 relative",children:[e.jsxs("div",{className:"relative flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-[10px] font-body font-semibold text-slate-400 uppercase tracking-widest",children:"Quick Demo Access"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Ne.map(t=>{const a=t.icon,u={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},p={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(r.button,{type:"button",onClick:()=>ke(t.email,t.password,t.role),className:"group flex items-center gap-3 w-full px-4 py-2.5 rounded-lg bg-slate-50/80 border border-slate-200/70 hover:border-sky-300 hover:bg-sky-50/80 hover:shadow-sm transition-all text-left",whileHover:{scale:1.01},whileTap:{scale:.99},children:[e.jsx("div",{className:`w-8 h-8 rounded-md flex items-center justify-center shrink-0 ${u[t.color]}`,children:e.jsx(a,{size:15,className:p[t.color]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-body font-semibold text-slate-700 group-hover:text-sky-600 transition-colors",children:[t.label," Account"]}),e.jsx("p",{className:"text-[10px] text-slate-400 font-body truncate",children:t.email})]}),e.jsx(ie,{size:14,className:"text-slate-300 group-hover:text-sky-500 group-hover:translate-x-0.5 transition-all shrink-0"})]},t.label)})})]}),e.jsxs(r.p,{className:"text-xs text-slate-400 text-center mt-4 font-body relative",initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx(re,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{rt as default}; diff --git a/assets/LoginPage-CqIFZBqL.js b/assets/LoginPage-CqIFZBqL.js deleted file mode 100644 index faa32c48535bc04a0c6f23cc85d584bf82e1f065..0000000000000000000000000000000000000000 --- a/assets/LoginPage-CqIFZBqL.js +++ /dev/null @@ -1,6 +0,0 @@ -import{r as s,j as e}from"./vendor-react-B4AQeu28.js";import{B as Me}from"./button-BqKfG4Jj.js";import{I as D}from"./input-DEPoMoHZ.js";import{c as Ee,m as r,B as Te,T as Ce,A as Re,U as te,G as se,a as ae,L as re,b as ie,s as oe,d as Ie,e as le}from"./index-mbyiCUYG.js";import{S as Le}from"./sparkles-THbTTiEe.js";import{M as De}from"./mail-DWQ9UHXG.js";import{E as ze,a as _e}from"./eye-DakyBxPE.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Be=Ee("shield-check",qe),ne="/assets/shader-bg-DA7bEbBA.mp4",Oe=[{id:"length",label:"At least 8 characters",test:i=>i.length>=8},{id:"upper-lower",label:"Contains uppercase and lowercase letters",test:i=>/[A-Z]/.test(i)&&/[a-z]/.test(i)},{id:"number",label:"Contains at least one number",test:i=>/\d/.test(i)},{id:"special",label:"Contains at least one special character",test:i=>/[^A-Za-z0-9]/.test(i)}],z="Use at least 8 characters with uppercase, lowercase, number, and special character.",Ve=i=>{const c=typeof i=="object"&&i!==null?i:null,o=i instanceof Error?i.message:"";if(c?.code&&typeof c.code=="string")return{code:c.code.toLowerCase(),message:o};const d=o.match(/auth\/[a-z-]+/i);return{code:d?d[0].toLowerCase():"",message:o}},Ge=i=>i.replace(/^Firebase:\s*/i,"").replace(/\s*\(auth\/[a-z-]+\)\.?/i,"").trim(),ce=(i,c)=>{const{code:o,message:d}=Ve(i),h=Ge(d);return o==="auth/invalid-credential"||o==="auth/wrong-password"||o==="auth/user-not-found"?"Invalid email or password. Please check your credentials and try again.":o==="auth/email-already-in-use"?"This email is already registered. Please sign in instead.":o==="auth/weak-password"||o==="auth/password-does-not-meet-requirements"?h?`Password does not meet signup requirements. ${h}`:`Password does not meet signup requirements. ${z}`:o==="auth/too-many-requests"?"Access to this account has been temporarily disabled due to many failed login attempts. You can immediately restore it by resetting your password or you can try again later.":o==="auth/network-request-failed"?"Network error. Please check your internet connection and try again.":o.startsWith("auth/")?h||c:d.includes("Firebase:")||d.includes("auth/")?c:d||c},it=()=>{const i=["Grade 11"],c={"Grade 11":["STEM A","STEM B","ABM A","HUMSS A"]},o={teacher:["Mathematics","Science","English","Technology","Humanities"]},[d,h]=s.useState(""),[f,_]=s.useState(""),[A,de]=s.useState(!1),[l,q]=s.useState(!1),[M,ue]=s.useState(""),[n,B]=s.useState("student"),[b,me]=s.useState("Grade 11"),[w,O]=s.useState(c["Grade 11"][0]),[g,V]=s.useState("Mathematics"),[G,x]=s.useState(!1),[v,m]=s.useState(null),[pe,xe]=s.useState(!1),[ye,he]=s.useState(!1),[E,be]=s.useState(16),[F,U]=s.useState("primary"),[$,T]=s.useState(0),C=s.useRef(null),R=s.useRef(null),N=pe&&ye,j=s.useRef("primary"),k=s.useRef(0),S=s.useRef(!1),W=1.1,H=.34,Y=t=>{const a=Math.max(0,Math.min(1,t));Math.abs(k.current-a)<.02||(k.current=a,T(a))},Z=t=>{!Number.isFinite(t)||t<=0||Math.abs(E-t)>.05&&be(t)},I=s.useMemo(()=>Oe.map(t=>({...t,met:t.test(f)})),[f]),fe=s.useMemo(()=>I.every(t=>t.met),[I]),J=s.useMemo(()=>{if(!l||!v)return!1;const t=v.toLowerCase();return t.includes("password requirements not met")||t.includes("password does not meet")},[v,l]),ge=()=>{const t=C.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)},ve=()=>{const t=R.current?.duration;t&&Number.isFinite(t)&&t>0&&Z(t)};s.useEffect(()=>{if(!N)return;const t=C.current,a=R.current;if(!t||!a)return;let u=!1,p=0;j.current="primary",U("primary"),S.current=!1,k.current=0,T(0),t.loop=!1,a.loop=!1,t.currentTime=0,a.currentTime=0,a.pause(),t.play().catch(()=>{});const P=()=>{if(u)return;const y=j.current==="primary"?t:a,K=j.current==="primary"?a:t,Pe=Number.isFinite(y.duration)&&y.duration>0?y.duration:E,L=Math.max(Pe-y.currentTime,0);if(L<=W){S.current||(S.current=!0,K.currentTime=0,K.play().catch(()=>{}));const Ae=1-L/W;if(Y(Ae),L<=.03||y.ended){y.pause(),y.currentTime=0;const ee=j.current==="primary"?"secondary":"primary";j.current=ee,U(ee),S.current=!1,k.current=0,T(0)}}else Y(0);p=window.requestAnimationFrame(P)};return p=window.requestAnimationFrame(P),()=>{u=!0,p&&window.cancelAnimationFrame(p)}},[E,N]);const Q=N?H*(1-$):0,X=N?H*$:0,je=F==="primary"?Q:X,we=F==="secondary"?Q:X;s.useEffect(()=>{n==="teacher"&&!o.teacher.includes(g)&&V(o.teacher[0])},[g,n]),s.useEffect(()=>{const t=c[b]||[];t.length>0&&!t.includes(w)&&O(t[0])},[b,w]);const Ne=[{label:"Student",role:"student",email:"teststudent@school.edu",password:"TestPass123!",icon:se,color:"sky"},{label:"Teacher",role:"teacher",email:"testteacher@school.edu",password:"TestPass123!",icon:ae,color:"emerald"},{label:"Admin",role:"admin",email:"testadmin@school.edu",password:"TestPass123!",icon:Be,color:"rose"}],ke=async(t,a,u)=>{m(null),x(!0),h(t),_(a),B(u),q(!1);try{oe(u),await le(t,a)}catch(p){m(ce(p,"Demo sign-in failed. Please try again.")),x(!1)}},Se=async t=>{t.preventDefault(),m(null),x(!0);try{if(l){if(!M.trim()){m("Please enter your name"),x(!1);return}if(n==="student"&&!b){m("Please select a grade level"),x(!1);return}if(n!=="student"&&!g){m("Please select a department"),x(!1);return}if(n==="admin"){m("Admin account creation is restricted. Please contact an existing administrator."),x(!1);return}if(!fe){m(`Password does not meet signup requirements. ${z}`),x(!1);return}oe(n),await Ie(d,f,M,n,n==="student"?{grade:b,section:w}:{department:g})}else await le(d,f)}catch(a){const u=l?`Sign-up failed. ${z}`:"Sign-in failed. Please check your credentials and try again.";m(ce(a,u)),x(!1)}};return e.jsxs("div",{className:"h-screen w-full flex items-center justify-center px-6 overflow-hidden relative login-bg",children:[e.jsx("video",{ref:C,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>xe(!0),onLoadedMetadata:ge,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":je},src:ne}),e.jsx("video",{ref:R,autoPlay:!0,muted:!0,playsInline:!0,preload:"auto",onCanPlay:()=>he(!0),onLoadedMetadata:ve,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-150 e-opacity",style:{"--o":we},src:ne}),e.jsx("div",{className:"absolute inset-0 pointer-events-none login-frost-overlay"}),e.jsx("div",{className:"absolute top-[10%] left-[-10%] w-[60%] h-[60%] rounded-full blur-[140px] pointer-events-none mix-blend-multiply login-orb-purple"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[70%] h-[70%] rounded-full blur-[160px] pointer-events-none mix-blend-multiply login-orb-pink"}),e.jsx("div",{className:"absolute top-[40%] left-[40%] w-[40%] h-[40%] rounded-full blur-[120px] pointer-events-none mix-blend-screen login-orb-blue"}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 items-center",children:[e.jsxs(r.div,{initial:{opacity:0,x:-40},animate:{opacity:1,x:0},transition:{duration:.8,ease:[.22,1,.36,1]},className:"flex flex-col justify-center space-y-8",children:[e.jsxs(r.div,{className:"flex items-center gap-2.5",children:[e.jsx(r.div,{className:"relative flex items-center justify-center drop-shadow-md",children:e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI Logo",className:"w-16 h-16 object-contain flex-shrink-0"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-black tracking-tight text-slate-900 bg-clip-text text-transparent bg-gradient-to-r from-purple-600 via-pink-600 to-sky-500",children:"MathPulse"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(Le,{size:12,className:"text-rose-500"}),e.jsx("span",{className:"text-xs text-slate-500 font-body font-medium tracking-wide",children:"Powered by Machine Learning"})]})]})]}),e.jsxs(r.div,{className:"space-y-5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2,duration:.8},children:[e.jsxs("h2",{className:"text-4xl lg:text-5xl xl:text-[3.4rem] font-display font-extrabold leading-[1.1] tracking-tight text-slate-900",children:["Transform Your",e.jsx("br",{}),e.jsx("span",{className:"bg-gradient-to-r from-sky-600 via-cyan-500 to-sky-500 bg-clip-text text-transparent",children:"Math Journey"})]}),e.jsx("p",{className:"text-base text-slate-500 leading-relaxed max-w-md font-body",children:"AI-powered predictive system designed to identify at-risk students and provide personalized learning recommendations."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{icon:Te,label:"AI Predictions",desc:"Smart detection",color:"sky"},{icon:Ce,label:"Analytics",desc:"Real-time data",color:"rose"},{icon:Re,label:"Gamified",desc:"Learn & earn",color:"emerald"}].map((t,a)=>{const u=t.icon,p={sky:"border-sky-200/60 hover:border-sky-300",rose:"border-rose-200/60 hover:border-rose-300",emerald:"border-emerald-200/60 hover:border-emerald-300"},P={sky:"text-sky-600",rose:"text-rose-500",emerald:"text-emerald-600"},y={sky:"bg-sky-100",rose:"bg-rose-100",emerald:"bg-emerald-100"};return e.jsxs(r.div,{className:`bg-white/80 backdrop-blur-xl border ${p[t.color]} rounded-xl p-4 transition-all cursor-pointer group shadow-md shadow-slate-900/[0.04]`,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5+a*.1},whileHover:{scale:1.03,y:-4},children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${y[t.color]} flex items-center justify-center mb-3`,children:e.jsx(u,{size:18,className:P[t.color]})}),e.jsx("h3",{className:"text-sm font-display font-semibold text-slate-800 mb-0.5",children:t.label}),e.jsx("p",{className:"text-xs text-slate-400 font-body",children:t.desc})]},a)})})]}),e.jsx(r.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.15,ease:[.22,1,.36,1]},className:"relative flex justify-center lg:justify-end",children:e.jsxs("div",{className:"bg-white/85 backdrop-blur-2xl border border-slate-200/60 rounded-3xl p-7 w-full max-w-md relative overflow-hidden shadow-[0_20px_60px_-15px_rgba(168,85,247,0.15)]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[3px] bg-gradient-to-r from-purple-500 via-pink-500 to-sky-500"}),e.jsx("div",{className:"absolute -top-40 left-1/2 -translate-x-1/2 w-80 h-80 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full blur-[60px] pointer-events-none"}),e.jsxs("div",{className:"text-center mb-6 relative",children:[e.jsx(r.h3,{className:"text-2xl font-display font-bold text-slate-900 mb-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.4},children:l?"Create Account":"Welcome Back"}),e.jsx(r.p,{className:"text-sm text-slate-500 font-body",initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:l?"Begin your learning journey":"Sign in to continue learning"})]}),e.jsxs("form",{onSubmit:Se,className:"space-y-4 mb-5 relative",children:[v&&!J&&e.jsx(r.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-rose-50 border border-rose-200 text-rose-600 px-4 py-3 rounded-lg text-sm font-body",children:v}),l&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"text",placeholder:"Your Name",value:M,onChange:t=>ue(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),l&&e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.45},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Account Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{role:"student",label:"Student"},{role:"teacher",label:"Teacher"}].map(t=>{const a=n===t.role;return e.jsx("button",{type:"button",onClick:()=>B(t.role),className:`rounded-lg border px-3 py-2 text-xs font-body font-semibold transition-all ${a?"border-sky-400 bg-sky-50 text-sky-700":"border-slate-200 bg-slate-50 text-slate-500 hover:border-slate-300"}`,children:t.label},t.role)})})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(se,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:b,onChange:t=>me(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:i.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n==="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:w,onChange:t=>O(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:(c[b]||[]).map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),l&&n!=="student"&&e.jsxs(r.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Department"}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("select",{value:g,onChange:t=>V(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border border-slate-200/80 text-slate-900 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all appearance-none",required:!0,children:o.teacher.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.5},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:"email",placeholder:"your.email@school.edu",value:d,onChange:t=>h(t.target.value),className:"w-full pl-11 pr-4 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0})]})]}),e.jsxs(r.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.6},children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-slate-500 mb-2 uppercase tracking-wider",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(re,{size:16,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx(D,{type:A?"text":"password",placeholder:"••••••••",value:f,onChange:t=>_(t.target.value),className:"w-full pl-11 pr-11 py-3 rounded-lg bg-slate-100/70 border-slate-200/80 text-slate-900 placeholder:text-slate-400 focus:border-sky-400 focus:ring-2 focus:ring-sky-400/20 focus:bg-white text-sm font-body transition-all",required:!0,minLength:l?8:6}),e.jsx(r.button,{type:"button",onClick:()=>de(!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",whileTap:{scale:.9},children:A?e.jsx(ze,{size:16}):e.jsx(_e,{size:16})})]}),l&&e.jsxs("div",{className:"mt-2 rounded-lg border border-sky-100/80 bg-sky-50/70 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-body font-semibold uppercase tracking-wider text-slate-600",children:"Password requirements"}),e.jsx("ul",{className:"mt-2 space-y-1",children:I.map(t=>e.jsxs("li",{className:`flex items-center gap-2 text-[11px] font-body ${t.met?"text-emerald-700":"text-slate-500"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t.met?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{children:t.label})]},t.id))}),J&&e.jsx("p",{className:"mt-2 text-[11px] font-body font-semibold text-rose-600",children:"Password does not meet signup requirements."})]})]}),e.jsx(r.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},children:e.jsxs(Me,{type:"submit",disabled:G,className:"w-full bg-gradient-to-r from-purple-600 to-pink-500 hover:from-purple-500 hover:to-pink-400 text-white font-body font-semibold py-3 rounded-xl shadow-lg shadow-purple-600/25 hover:shadow-pink-500/35 hover:scale-[1.02] transition-all text-sm group relative overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(r.span,{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/15 to-white/0",animate:{x:["-100%","100%"]},transition:{duration:3,repeat:1/0,repeatDelay:2}}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[G?"Please wait...":l?"Create Account":"Sign In",e.jsx(ie,{size:16,className:"group-hover:translate-x-1 transition-transform"})]})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>{q(!l),m(null)},className:"text-sm text-slate-400 hover:text-sky-500 font-body font-medium transition-colors",children:l?"Already have an account? Sign in":"Don't have an account? Create one"})})]}),!l&&e.jsxs(r.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.85},className:"mb-4 relative",children:[e.jsxs("div",{className:"relative flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-[10px] font-body font-semibold text-slate-400 uppercase tracking-widest",children:"Quick Demo Access"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Ne.map(t=>{const a=t.icon,u={sky:"bg-sky-100",emerald:"bg-emerald-100",rose:"bg-rose-100"},p={sky:"text-sky-600",emerald:"text-emerald-600",rose:"text-rose-500"};return e.jsxs(r.button,{type:"button",onClick:()=>ke(t.email,t.password,t.role),className:"group flex items-center gap-3 w-full px-4 py-2.5 rounded-lg bg-slate-50/80 border border-slate-200/70 hover:border-sky-300 hover:bg-sky-50/80 hover:shadow-sm transition-all text-left",whileHover:{scale:1.01},whileTap:{scale:.99},children:[e.jsx("div",{className:`w-8 h-8 rounded-md flex items-center justify-center shrink-0 ${u[t.color]}`,children:e.jsx(a,{size:15,className:p[t.color]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-body font-semibold text-slate-700 group-hover:text-sky-600 transition-colors",children:[t.label," Account"]}),e.jsx("p",{className:"text-[10px] text-slate-400 font-body truncate",children:t.email})]}),e.jsx(ie,{size:14,className:"text-slate-300 group-hover:text-sky-500 group-hover:translate-x-0.5 transition-all shrink-0"})]},t.label)})})]}),e.jsxs(r.p,{className:"text-xs text-slate-400 text-center mt-4 font-body relative",initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx(re,{size:10,className:"inline mr-1 -mt-0.5"})," Your data is encrypted and secure"]})]})})]})})]})};export{it as default}; diff --git a/assets/LogoutActionButton-DQLJH-aF.js b/assets/LogoutActionButton-D5BV__Zd.js similarity index 96% rename from assets/LogoutActionButton-DQLJH-aF.js rename to assets/LogoutActionButton-D5BV__Zd.js index 3696fff4f988d4820e2af2173c67b3aa7c5ece41..cec6bcf608eee151f99347f1bd45e8f95404f699 100644 --- a/assets/LogoutActionButton-DQLJH-aF.js +++ b/assets/LogoutActionButton-D5BV__Zd.js @@ -1,4 +1,4 @@ -import{c as a,m as s,k as i}from"./index-mbyiCUYG.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as l}from"./log-out-Ddy014zi.js";/** +import{e as a,m as s,j as i}from"./index-B3ruOzo6.js";import{j as t}from"./vendor-react-B4AQeu28.js";import{L as l}from"./log-out-CoRJnfoO.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ModuleFolderCard-BQjDrVls.js b/assets/ModuleFolderCard-DKst1S7k.js similarity index 97% rename from assets/ModuleFolderCard-BQjDrVls.js rename to assets/ModuleFolderCard-DKst1S7k.js index 2b20c4762a214cfb894119935f149854f506ebdd..3796606feac7363aa342483cbc46d56ae03e0ff8 100644 --- a/assets/ModuleFolderCard-BQjDrVls.js +++ b/assets/ModuleFolderCard-DKst1S7k.js @@ -1,4 +1,4 @@ -import{j as e}from"./vendor-react-B4AQeu28.js";import{u as g}from"./useSubjectAvailability-CN1BUyIM.js";import{c as w,m as f,a as j,w as v,L as k}from"./index-mbyiCUYG.js";import{C as y}from"./clock-BLtPbCgT.js";/** +import{j as e}from"./vendor-react-B4AQeu28.js";import{u as g}from"./useSubjectAvailability-D7FKRlYS.js";import{e as w,m as f,a as j,v,L as k}from"./index-B3ruOzo6.js";import{C as y}from"./clock-C73na4Cu.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/ModulesPage-CyxYQpv4.js b/assets/ModulesPage-D_ceNMZi.js similarity index 89% rename from assets/ModulesPage-CyxYQpv4.js rename to assets/ModulesPage-D_ceNMZi.js index f63a9c83a21602501b793f3d83c29f4141f42f85..6453e255c74ae887ba04f5e3ebce7b3d1b555b2e 100644 --- a/assets/ModulesPage-CyxYQpv4.js +++ b/assets/ModulesPage-D_ceNMZi.js @@ -1,95 +1,105 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-core-DCQrgkxC.js"])))=>i.map(i=>d[i]); -import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u as Gs}from"./useQuery-L70l-ukL.js";import{getDoc as Ot,doc as bt,onSnapshot as Gt,runTransaction as Vs,serverTimestamp as Ys,query as Ks,where as Zs,collection as Js}from"./vendor-firebase-firestore-CP9q7ISf.js";import{c as me,m as v,Z as Re,C as mt,g as $e,Q as As,M as ea,b as pt,T as Pt,q as Oe,$ as Es,R as Ps,z as Ct,_ as Lt,B as ns,I as ta,l as It,A as Ft,a as Je,k as At,w as Ts,r as sa,a5 as is,a6 as aa,a7 as os,a8 as ra,a9 as la,L as Vt,h as We,x as na,aa as ia,ab as oa,ac as Ls,ad as ca,ae as da,af as xa,a3 as ma,v as ua,ag as cs,ah as pa,ai as ds,G as ha,a1 as fa,n as Bt,a4 as ba}from"./index-mbyiCUYG.js";import{M as Wt}from"./ModuleFolderCard-BQjDrVls.js";import{B as ze}from"./button-BqKfG4Jj.js";import Is from"./ScientificCalculator-C3ad9xEg.js";import{C as lt}from"./check-BLN5Dl8e.js";import{X as De}from"./x-oZO0Ye1Q.js";import{V as Fs,a as Ds,M as Rs,b as $s}from"./volume-x-R52lt03l.js";import{C as Yt}from"./chevron-left-BYtw_nqd.js";import{C as ht}from"./chevron-right-bwYIKoxv.js";import{C as ga}from"./circle-help-BP0kOuya.js";import{P as Bs,A as Ut,b as Xt,c as wa,L as ya}from"./quizService-CjK9zjBp.js";import{L as Kt,C as Ht}from"./lightbulb-D-SuIyuF.js";import{logLessonView as ja}from"./trackingService-DJ_reXHi.js";import{C as ft}from"./clock-BLtPbCgT.js";import{C as Hs}from"./clipboard-check-BB6UVEW1.js";import{C as zt}from"./circle-check-big-BnoZ8KZB.js";import{s as Tt}from"./subjects-BGUwH4Kn.js";import{C as va}from"./circle-check-BENuYz-J.js";import{triggerQuizSubmitted as Na}from"./automationService-pLIzsro_.js";import xs from"./confetti.module-C94ZD2ww.js";import{u as ka}from"./useCurriculum-uUEvXpH4.js";import{S as Sa}from"./search-F2fS74Xk.js";import{F as Ca}from"./funnel-DxfPBPvT.js";import{S as za}from"./sparkles-THbTTiEe.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-CN1BUyIM.js";import"./chevron-up-B_-cQcm8.js";import"./chart-column-B4tQNTpN.js";/** +import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{P as As,A as Ot,b as Gs,u as Vs}from"./quizService-Bqc478Xh.js";import{getDoc as Wt,doc as bt,onSnapshot as Gt,runTransaction as Ys,serverTimestamp as Ks,query as Zs,where as Js,collection as ea}from"./vendor-firebase-firestore-CP9q7ISf.js";import{e as ie,m as v,Z as Re,C as mt,k as $e,V as Es,M as ta,b as pt,T as Pt,p as Oe,a1 as Ps,R as Ts,z as Ct,_ as Lt,B as ns,I as sa,u as It,A as Ft,a as Je,j as At,v as Ls,q as aa,a7 as is,a8 as ra,a9 as os,aa as la,ab as na,L as Vt,g as We,w as ia,ac as oa,ad as ca,ae as Is,af as da,ag as xa,ah as ma,a5 as ua,r as pa,ai as cs,aj as ha,ak as ds,G as fa,a3 as ba,l as Bt,a6 as ga}from"./index-B3ruOzo6.js";import{M as Ut}from"./ModuleFolderCard-DKst1S7k.js";import{B as ze}from"./button-CaSK4KoS.js";import Fs from"./ScientificCalculator-C0Zl3TP5.js";import{C as lt}from"./check-6eXlU5jr.js";import{X as De}from"./x-BNHnAXzL.js";import{V as Ds,a as Rs,M as $s,b as Bs}from"./volume-x-z-Eai_Ym.js";import{C as Yt}from"./chevron-left-Cr0wYLQi.js";import{C as ht}from"./chevron-right-CbkkCalp.js";import{C as wa}from"./circle-help-C5HGdkRZ.js";import{logLessonView as ya}from"./trackingService-D4gZcipe.js";import{C as ft}from"./clock-C73na4Cu.js";import{C as Hs}from"./clipboard-check-Bv_xk-Mp.js";import{C as zt}from"./circle-check-big-CWdn1Nqf.js";import{s as Tt}from"./subjects-DEj_AlYz.js";import{C as ja}from"./circle-check-DyFN6-07.js";import{P as Xt,L as va}from"./pen-tool-BelhGWFu.js";import{triggerQuizSubmitted as Na}from"./automationService-JEEI7dc9.js";import xs from"./confetti.module-C94ZD2ww.js";import{u as ka}from"./useCurriculum-CQZ78SzC.js";import{S as Sa}from"./search-DeasjpAx.js";import{F as Ca}from"./funnel-8X5OzLOw.js";import{S as za}from"./sparkles-Bq0AaIRg.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./useSubjectAvailability-D7FKRlYS.js";import"./chevron-up-CTb5_AvY.js";import"./chart-column-C9VTl-3A.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 _a=[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]],Ma=me("binary",_a);/** + */const _a=[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]],Ma=ie("binary",_a);/** * @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 Aa=[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]],ms=me("book-user",Aa);/** + */const Aa=[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]],ms=ie("book-user",Aa);/** * @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 Ea=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],us=me("bookmark",Ea);/** + */const Ea=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],us=ie("bookmark",Ea);/** * @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 Pa=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ps=me("box",Pa);/** + */const Pa=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ps=ie("box",Pa);/** * @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 Ta=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],hs=me("braces",Ta);/** + */const Ta=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],hs=ie("braces",Ta);/** * @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 La=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fs=me("circle",La);/** + */const La=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Ht=ie("circle-x",La);/** * @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 Ia=[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]],Qt=me("divide",Ia);/** + */const Ia=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fs=ie("circle",Ia);/** * @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 Fa=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],bs=me("hash",Fa);/** + */const Fa=[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]],Qt=ie("divide",Fa);/** * @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 Da=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Ra=me("key",Da);/** + */const Da=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],bs=ie("hash",Da);/** * @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 $a=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Ba=me("notebook-pen",$a);/** + */const Ra=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],$a=ie("key",Ra);/** * @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 Ha=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],gs=me("percent",Ha);/** + */const Ba=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Kt=ie("lightbulb",Ba);/** * @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 Qa=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],qa=me("ruler",Qa);/** + */const Ha=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Qa=ie("notebook-pen",Ha);/** * @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 Oa=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]],Wa=me("scaling",Oa);/** + */const qa=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],gs=ie("percent",qa);/** * @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 Ua=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],ws=me("sigma",Ua);/** + */const Oa=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],Wa=ie("ruler",Oa);/** * @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 Xa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]],qt=me("square-function",Xa);/** + */const Ua=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]],Xa=ie("scaling",Ua);/** * @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 Ga=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ys=me("square",Ga);/** + */const Ga=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],ws=ie("sigma",Ga);/** * @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 Va=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ya=me("timer",Va);/** + */const Va=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]],qt=ie("square-function",Va);/** * @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 Ka=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],js=me("triangle",Ka);function Za(t){let a=t>>>0;return()=>{a+=1831565813;let l=Math.imul(a^a>>>15,a|1);return l^=l+Math.imul(l^l>>>7,l|61),((l^l>>>14)>>>0)/4294967296}}function Ja(t,a){const l=[...t],o=Za(a);for(let n=l.length-1;n>0;n--){const r=Math.floor(o()*(n+1));[l[n],l[r]]=[l[r],l[n]]}return l}function Zt(t){const a=t??new Date;return new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Manila",year:"numeric",month:"2-digit",day:"2-digit"}).format(a)}function Jt(t){const a=new Date,l=new Intl.DateTimeFormat("en-US",{timeZone:"Asia/Manila",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(a),o=n=>parseInt(l.find(r=>r.type===n)?.value??"0",10);return new Date(o("year"),o("month")-1,o("day"),o("hour"),o("minute"),o("second"))}function es(t){const a=Jt(),l=a.getFullYear(),o=(a.getDay()+6)%7,n=new Date(a);n.setDate(a.getDate()-o+3);const r=new Date(n.getFullYear(),0,1),i=Math.floor((n.getTime()-r.getTime())/(1440*60*1e3)),x=Math.floor(i/7)+1;return l*100+x}function ts(t){return(Jt().getDay()+6)%7}function er(t){const a=new Date,l=480*60*1e3,o=a.getTime()+l,r=(new Date(o).getUTCDay()+6)%7,i=r===0?7:7-r,p=o-o%(1440*60*1e3)+i*24*60*60*1e3;return new Date(p-l)}const tr=[{id:"xp_50",label:"+50 XP Boost",description:"Bonus XP on your next quiz",icon:"⚡",type:"xp",value:50,rarity:"common",color:"#4ade80"},{id:"xp_100",label:"+100 XP Boost",description:"Double bonus XP reward",icon:"🌟",type:"xp",value:100,rarity:"rare",color:"#facc15"},{id:"xp_200",label:"+200 XP Epic Boost",description:"Massive XP surge",icon:"💥",type:"xp",value:200,rarity:"epic",color:"#f97316"},{id:"streak_shield",label:"Streak Shield",description:"Protects streak if you miss a day",icon:"🛡️",type:"streak_shield",value:1,rarity:"rare",color:"#60a5fa"},{id:"hint_x3",label:"3 Hint Tokens",description:"Use in-quiz hints",icon:"💡",type:"hint_token",value:3,rarity:"common",color:"#a78bfa"},{id:"hint_x5",label:"5 Hint Tokens",description:"More hints to use",icon:"🔦",type:"hint_token",value:5,rarity:"rare",color:"#8b5cf6"},{id:"xp_mult_1h",label:"1-Hour XP ×1.5",description:"1.5× XP for all quizzes for 1 hour",icon:"⏰",type:"xp_multiplier",value:60,rarity:"epic",color:"#ec4899"},{id:"xp_mult_30m",label:"30-Min XP ×2",description:"2× XP for 30 minutes",icon:"🚀",type:"xp_multiplier",value:30,rarity:"epic",color:"#e11d48"},{id:"xp_75",label:"+75 XP Boost",description:"Solid XP reward",icon:"✨",type:"xp",value:75,rarity:"common",color:"#34d399"},{id:"hint_x2",label:"2 Hint Tokens",description:"Quick hint pack",icon:"🕯️",type:"hint_token",value:2,rarity:"common",color:"#7c3aed"},{id:"xp_streak_150",label:"+150 XP + Streak Save",description:"XP boost + streak protection combo",icon:"🔥",type:"xp",value:150,rarity:"epic",color:"#dc2626"},{id:"xp_25",label:"+25 XP Starter",description:"Small but reliable XP",icon:"🌱",type:"xp",value:25,rarity:"common",color:"#86efac"},{id:"hint_x1",label:"1 Hint Token",description:"A single lifeline",icon:"🔍",type:"hint_token",value:1,rarity:"common",color:"#c4b5fd"},{id:"streak_shield2",label:"2 Streak Shields",description:"Double streak protection",icon:"🏰",type:"streak_shield",value:2,rarity:"epic",color:"#3b82f6"},{id:"xp_120",label:"+120 XP Power Surge",description:"Strong XP reward for the day",icon:"⚡",type:"xp",value:120,rarity:"rare",color:"#16a34a"},{id:"hint_x4",label:"4 Hint Tokens",description:"Generous hint pack",icon:"📚",type:"hint_token",value:4,rarity:"rare",color:"#9333ea"}];function sr(t){return Ja(tr,t).slice(0,7).map((o,n)=>({...o,day:n}))}function ss(){return sr(es())}function ar(){const t=ss(),a=ts();return t[a]}const vs=({value:t,label:a,delay:l=0,icon:o})=>{const[n,r]=Ae.useState(0);return Ae.useEffect(()=>{if(t<=0)return;const i=1e3,x=30,p=Math.abs(Math.floor(i/x));let b=0;const g=setTimeout(()=>{const M=setInterval(()=>{b+=Math.max(1,Math.floor(t/x)),b>=t?(r(t),clearInterval(M)):r(b)},p);return()=>clearInterval(M)},l);return()=>clearTimeout(g)},[t,l]),t<0?null:e.jsxs(v.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:l/1e3,duration:.5},className:"flex items-center justify-between bg-slate-50 border border-slate-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-bold uppercase tracking-wider text-[10px]",children:[o,a]}),e.jsxs("div",{className:"text-xl font-black text-purple-600 tabular-nums",children:["+",n]})]})},rr=({viewportHeight:t})=>{const a=Ae.useMemo(()=>[...Array(40)].map((l,o)=>({id:o,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[t]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex justify-between",children:a.map(l=>e.jsx(v.div,{className:"absolute w-0.5 h-16 bg-blue-400/40 rounded-full",style:{left:l.left,top:"-10%"},animate:{y:[0,t*1.2]},transition:{duration:l.duration,ease:"linear",delay:l.delay}},l.id))})},lr=({viewportHeight:t,viewportWidth:a})=>{const l=Ae.useMemo(()=>[...Array(30)].map((o,n)=>({id:n,xShift:(Math.random()-.5)*a*.8,yShift:(Math.random()-.5)*t*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[t,a]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex items-center justify-center",children:l.map(o=>e.jsx(v.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.6)]",style:{left:"50%",top:"50%"},animate:{y:[0,o.yShift],x:[0,o.xShift],scale:[0,o.scale,0],opacity:[0,1,0]},transition:{duration:o.duration,ease:"easeOut",delay:o.delay}},o.id))})},nr=()=>{const t=Ae.useMemo(()=>[...Array(60)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,backgroundColor:["#75D06A","#6ED1CF","#9956DE","#FB96BB","#FFB356"][l%5],duration:2+Math.random()*2,delay:Math.random()*.5,size:6+Math.random()*8,borderRadius:Math.random()>.5?"50%":"2px"})),[]);return e.jsxs("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden",children:[e.jsx("style",{children:` + */const Ya=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ys=ie("square",Ya);/** + * @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 Ka=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Za=ie("timer",Ka);/** + * @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 Ja=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],js=ie("triangle",Ja);function er(t){let a=t>>>0;return()=>{a+=1831565813;let l=Math.imul(a^a>>>15,a|1);return l^=l+Math.imul(l^l>>>7,l|61),((l^l>>>14)>>>0)/4294967296}}function tr(t,a){const l=[...t],o=er(a);for(let n=l.length-1;n>0;n--){const r=Math.floor(o()*(n+1));[l[n],l[r]]=[l[r],l[n]]}return l}function Zt(t){const a=t??new Date;return new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Manila",year:"numeric",month:"2-digit",day:"2-digit"}).format(a)}function Jt(t){const a=new Date,l=new Intl.DateTimeFormat("en-US",{timeZone:"Asia/Manila",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(a),o=n=>parseInt(l.find(r=>r.type===n)?.value??"0",10);return new Date(o("year"),o("month")-1,o("day"),o("hour"),o("minute"),o("second"))}function es(t){const a=Jt(),l=a.getFullYear(),o=(a.getDay()+6)%7,n=new Date(a);n.setDate(a.getDate()-o+3);const r=new Date(n.getFullYear(),0,1),i=Math.floor((n.getTime()-r.getTime())/(1440*60*1e3)),x=Math.floor(i/7)+1;return l*100+x}function ts(t){return(Jt().getDay()+6)%7}function sr(t){const a=new Date,l=480*60*1e3,o=a.getTime()+l,r=(new Date(o).getUTCDay()+6)%7,i=r===0?7:7-r,p=o-o%(1440*60*1e3)+i*24*60*60*1e3;return new Date(p-l)}const ar=[{id:"xp_50",label:"+50 XP Boost",description:"Bonus XP on your next quiz",icon:"⚡",type:"xp",value:50,rarity:"common",color:"#4ade80"},{id:"xp_100",label:"+100 XP Boost",description:"Double bonus XP reward",icon:"🌟",type:"xp",value:100,rarity:"rare",color:"#facc15"},{id:"xp_200",label:"+200 XP Epic Boost",description:"Massive XP surge",icon:"💥",type:"xp",value:200,rarity:"epic",color:"#f97316"},{id:"streak_shield",label:"Streak Shield",description:"Protects streak if you miss a day",icon:"🛡️",type:"streak_shield",value:1,rarity:"rare",color:"#60a5fa"},{id:"hint_x3",label:"3 Hint Tokens",description:"Use in-quiz hints",icon:"💡",type:"hint_token",value:3,rarity:"common",color:"#a78bfa"},{id:"hint_x5",label:"5 Hint Tokens",description:"More hints to use",icon:"🔦",type:"hint_token",value:5,rarity:"rare",color:"#8b5cf6"},{id:"xp_mult_1h",label:"1-Hour XP ×1.5",description:"1.5× XP for all quizzes for 1 hour",icon:"⏰",type:"xp_multiplier",value:60,rarity:"epic",color:"#ec4899"},{id:"xp_mult_30m",label:"30-Min XP ×2",description:"2× XP for 30 minutes",icon:"🚀",type:"xp_multiplier",value:30,rarity:"epic",color:"#e11d48"},{id:"xp_75",label:"+75 XP Boost",description:"Solid XP reward",icon:"✨",type:"xp",value:75,rarity:"common",color:"#34d399"},{id:"hint_x2",label:"2 Hint Tokens",description:"Quick hint pack",icon:"🕯️",type:"hint_token",value:2,rarity:"common",color:"#7c3aed"},{id:"xp_streak_150",label:"+150 XP + Streak Save",description:"XP boost + streak protection combo",icon:"🔥",type:"xp",value:150,rarity:"epic",color:"#dc2626"},{id:"xp_25",label:"+25 XP Starter",description:"Small but reliable XP",icon:"🌱",type:"xp",value:25,rarity:"common",color:"#86efac"},{id:"hint_x1",label:"1 Hint Token",description:"A single lifeline",icon:"🔍",type:"hint_token",value:1,rarity:"common",color:"#c4b5fd"},{id:"streak_shield2",label:"2 Streak Shields",description:"Double streak protection",icon:"🏰",type:"streak_shield",value:2,rarity:"epic",color:"#3b82f6"},{id:"xp_120",label:"+120 XP Power Surge",description:"Strong XP reward for the day",icon:"⚡",type:"xp",value:120,rarity:"rare",color:"#16a34a"},{id:"hint_x4",label:"4 Hint Tokens",description:"Generous hint pack",icon:"📚",type:"hint_token",value:4,rarity:"rare",color:"#9333ea"}];function rr(t){return tr(ar,t).slice(0,7).map((o,n)=>({...o,day:n}))}function ss(){return rr(es())}function lr(){const t=ss(),a=ts();return t[a]}const vs=({value:t,label:a,delay:l=0,icon:o})=>{const[n,r]=Ae.useState(0);return Ae.useEffect(()=>{if(t<=0)return;const i=1e3,x=30,p=Math.abs(Math.floor(i/x));let b=0;const g=setTimeout(()=>{const M=setInterval(()=>{b+=Math.max(1,Math.floor(t/x)),b>=t?(r(t),clearInterval(M)):r(b)},p);return()=>clearInterval(M)},l);return()=>clearTimeout(g)},[t,l]),t<0?null:e.jsxs(v.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:l/1e3,duration:.5},className:"flex items-center justify-between bg-slate-50 border border-slate-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-bold uppercase tracking-wider text-[10px]",children:[o,a]}),e.jsxs("div",{className:"text-xl font-black text-purple-600 tabular-nums",children:["+",n]})]})},nr=({viewportHeight:t})=>{const a=Ae.useMemo(()=>[...Array(40)].map((l,o)=>({id:o,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[t]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex justify-between",children:a.map(l=>e.jsx(v.div,{className:"absolute w-0.5 h-16 bg-blue-400/40 rounded-full",style:{left:l.left,top:"-10%"},animate:{y:[0,t*1.2]},transition:{duration:l.duration,ease:"linear",delay:l.delay}},l.id))})},ir=({viewportHeight:t,viewportWidth:a})=>{const l=Ae.useMemo(()=>[...Array(30)].map((o,n)=>({id:n,xShift:(Math.random()-.5)*a*.8,yShift:(Math.random()-.5)*t*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[t,a]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex items-center justify-center",children:l.map(o=>e.jsx(v.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.6)]",style:{left:"50%",top:"50%"},animate:{y:[0,o.yShift],x:[0,o.xShift],scale:[0,o.scale,0],opacity:[0,1,0]},transition:{duration:o.duration,ease:"easeOut",delay:o.delay}},o.id))})},or=()=>{const t=Ae.useMemo(()=>[...Array(60)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,backgroundColor:["#75D06A","#6ED1CF","#9956DE","#FB96BB","#FFB356"][l%5],duration:2+Math.random()*2,delay:Math.random()*.5,size:6+Math.random()*8,borderRadius:Math.random()>.5?"50%":"2px"})),[]);return e.jsxs("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden",children:[e.jsx("style",{children:` @keyframes confetti-fall { 0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; } 100% { transform: translateY(110vh) rotate(720deg); opacity: 0; } @@ -99,7 +109,7 @@ import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u a animation-timing-function: linear; animation-fill-mode: forwards; } - `}),t.map(a=>e.jsx("div",{className:"confetti-piece absolute",style:{left:a.left,top:"-10%",backgroundColor:a.backgroundColor,width:a.size,height:a.size,borderRadius:a.borderRadius,animationDuration:`${a.duration}s`,animationDelay:`${a.delay}s`}},a.id))]})},ir=({lesson:t,questions:a,onComplete:l,onBack:o})=>{const[n,r]=s.useState(0),[i,x]=s.useState(0),[p,b]=s.useState(null),[g,M]=s.useState(""),[z,d]=s.useState(!1),[A,N]=s.useState(!1),[_,R]=s.useState(0),[m,y]=s.useState(0),[j,E]=s.useState(0),[k,U]=s.useState(!1),[O,Y]=s.useState([]),[$,te]=s.useState(!1),[de,_e]=s.useState(!1),[re,W]=s.useState(null),[Z,ge]=s.useState(null),[K,we]=s.useState(!1),[Me,I]=s.useState(!1),[u,P]=s.useState(!1),[f,T]=s.useState(!1),[F,ee]=s.useState(!1),[ne,Be]=s.useState(typeof window<"u"?window.innerHeight:800),[gt,Ue]=s.useState(typeof window<"u"?window.innerWidth:1200),[et,je]=s.useState([]),[nt]=s.useState(Date.now()),[_t,Xe]=s.useState(0),[wt,Ge]=s.useState(!1),[tt,it]=s.useState(!0),[He,Ve]=s.useState(!1),[ye,ve]=s.useState(!1),[Ne,st]=s.useState(!1),[Qe,ot]=s.useState(!1),[Ye,Ke]=s.useState(0),[c,D]=s.useState({}),[X,le]=s.useState(5),[L,ke]=s.useState(15),[Se,Le]=s.useState(null),[ie,ue]=s.useState(!1),[at,Ie]=s.useState(900*1e3),[fe,yt]=s.useState({}),[pe,Mt]=s.useState({}),[jt,ct]=s.useState(!1),[vt,oe]=s.useState(!1),[se,dt]=s.useState(null),[S]=s.useState(Array.from({length:15},(w,C)=>({id:C,size:Math.random()*120+60,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*25+15,delay:Math.random()*-20,color:["bg-white/5","bg-indigo-300/10","bg-sky-300/10","bg-purple-300/10"][Math.floor(Math.random()*4)]}))),h=a[i],H=i{if(tt)try{const C=window.AudioContext||window.webkitAudioContext;if(!C)return;const q=new C,V=q.currentTime,ce=(J,G,ae,Pe=.1,xt="sine")=>{const Ze=q.createOscillator(),rt=q.createGain();Ze.type=xt,Ze.frequency.value=J,rt.gain.setValueAtTime(0,G),rt.gain.linearRampToValueAtTime(Pe,G+.05),rt.gain.exponentialRampToValueAtTime(.001,G+ae),Ze.connect(rt),rt.connect(q.destination),Ze.start(G),Ze.stop(G+ae)};w==="correct"?(ce(880,V,.1,.1,"sine"),ce(1108.73,V+.1,.2,.1,"sine")):w==="incorrect"?(ce(300,V,.2,.05,"sawtooth"),ce(250,V+.15,.3,.05,"sawtooth")):w==="streak"?(ce(440,V,.1,.05,"square"),ce(554.37,V+.1,.1,.05,"square"),ce(659.25,V+.2,.1,.05,"square"),ce(880,V+.3,.4,.05,"square")):w==="complete"&&(ce(523.25,V,.1,.1),ce(659.25,V+.15,.1,.1),ce(783.99,V+.3,.1,.1),ce(1046.5,V+.45,.5,.1))}catch{}};s.useEffect(()=>{const w=()=>{Be(window.innerHeight),Ue(window.innerWidth)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]),s.useEffect(()=>{if(h?.type==="multiple-choice"&&h.options){const w=h.options.map((C,q)=>({id:`${h.id}-${q}`,text:C}));for(let C=w.length-1;C>0;C--){const q=Math.floor(Math.random()*(C+1));[w[C],w[q]]=[w[q],w[C]]}Y(w)}else Y([])},[n,h]),s.useEffect(()=>{ve(!1),st(!1)},[n]);const Ee=()=>{document.fullscreenElement?(document.exitFullscreen().catch(()=>{}),Ve(!1)):(document.documentElement.requestFullscreen().catch(()=>{}),Ve(!0))},he=()=>st(w=>!w);s.useEffect(()=>{const w=C=>{C.key==="Enter"&&(!z&&Fe()?qe():z&&Nt())};return window.addEventListener("keypress",w),()=>window.removeEventListener("keypress",w)},[z,p,g]),s.useEffect(()=>{L===0&&!Se&&(Le(Date.now()),ue(!0))},[L,Se]),s.useEffect(()=>{if(!ie||!Se)return;const w=setInterval(()=>{const C=Date.now()-Se,q=Math.max(0,900*1e3-C);Ie(q)},1e3);return()=>clearInterval(w)},[ie,Se]);const Fe=()=>h.type==="fill-in-blank"?g.trim().length>0:p!==null,be=()=>{if(X<=0||z||fe[n]||Ne)return;const w=c[n]||[],C=O.filter(V=>V.text!==h.correctAnswer).filter(V=>!w.includes(V.text));if(C.length===0)return;const q=C[Math.floor(Math.random()*C.length)];D(V=>({...V,[n]:[...w,q.text]})),le(V=>Math.max(0,V-1)),Ke(V=>Math.max(0,V-5)),Ce("correct")},xe=()=>{fe[n]||z||Ne||(yt(w=>({...w,[n]:!0})),ve(!0))},qe=w=>{if($||iae.id===p);q=G?G.text:""}else{te(!1);return}C=q===h.correctAnswer}if(!C){ct(!0),Ce("incorrect"),setTimeout(()=>ct(!1),500),ke(ae=>Math.max(0,ae-1)),y(0);const G=[...pe[n]||[],q];if(Mt(ae=>({...ae,[n]:G})),h.type==="multiple-choice"||h.type==="true-false"){const ae=h.options?h.options.length-1:1;G.length>=ae&&(N(!1),d(!0),je(Pe=>{const xt=[...Pe];return xt[i]=!1,xt}))}else G.length>=3&&(N(!1),d(!0),je(ae=>{const Pe=[...ae];return Pe[i]=!1,Pe}));te(!1);return}N(!0),d(!0),je(G=>{const ae=[...G];return ae[i]=!0,ae});const ce=(c[n]||[]).length>0?5:10;Ke(G=>G+ce),R(G=>G+1);const J=m+1;if(y(J),E(Math.max(j,J)),J===2?dt("streak"):J===3&&ls<2?dt("multiplier2"):J===5&&ls<3&&dt("multiplier3"),J>0&&J%3===0){const G=J*5;Xe(ae=>ae+G),Ce("streak")}else Ce("correct");ot(!0),setTimeout(()=>{ot(!1),dt(null),setTimeout(()=>Nt(),500)},1200),Lt(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(G=>{G.default({particleCount:30,spread:40,colors:["#75D06A","#6ED1CF"],origin:{y:.6}})}).finally(()=>te(!1))},Nt=()=>{nw+1),x(w=>w+1),d(!1),b(null),M(""),N(!1)):Us()},Us=()=>{const w=Math.round(_/a.length*100);U(!0),w>=80||(w>=50?(T(!0),setTimeout(()=>T(!1),5e3)):(P(!0),setTimeout(()=>P(!1),5e3))),Ce("complete")},rs=Q==="quiz"?{gradient:"bg-gradient-to-br from-[#7274ED] via-[#9956DE] to-[#7274ED]"}:{gradient:"bg-gradient-to-br from-[#75D06A] via-[#6ED1CF] to-[#75D06A]"},Rt=(()=>{const w=B.toLowerCase();return w.includes("geometry")||w.includes("shape")?[js,fs,ys,ps,qa,Wa]:w.includes("algebra")||w.includes("equation")?[De,Qt,hs,qt,mt,gs]:w.includes("calculus")||w.includes("derivative")||w.includes("integral")?[ws,qt,Pt,mt,Qt,hs]:w.includes("statistics")||w.includes("probability")?[Oe,Pt,ps,fs,js,ys]:[mt,ws,Qt,gs,qt,Ma]})();Rt[0];const ls=Math.min(2,1+m*.1);if(k){const w=Math.round(_/a.length*100),C=w>=80,q=w>=50&&w<80,V=Q==="quiz"?100:50,ce=Math.round(_/a.length*100),J=V+ce+_t,G=document.getElementById("modal-root"),ae=e.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/40",children:[f&&e.jsx(lr,{viewportHeight:ne,viewportWidth:gt}),u&&e.jsx(rr,{viewportHeight:ne}),C&&e.jsx(nr,{}),e.jsxs(v.div,{initial:{opacity:0,scale:.8,y:40},animate:{opacity:1,scale:1,y:0},transition:{type:"spring",damping:18,stiffness:200},className:"w-full max-w-xs sm:max-w-sm bg-white border-2 border-slate-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)] rounded-[2rem] p-4 sm:p-5 text-center relative z-10",children:[e.jsx(v.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",damping:12,stiffness:150,delay:.2},className:"mb-3",children:e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-16 h-16 sm:w-20 sm:h-20 mx-auto drop-shadow-xl"})}),e.jsx(v.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:`text-xl sm:text-2xl font-black uppercase tracking-tight mb-1 drop-shadow-sm ${C?"text-emerald-500":q?"text-amber-500":"text-rose-500"}`,children:C?"EXCELLENT!":q?"GOOD JOB!":"KEEP TRYING!"}),e.jsxs("p",{className:"text-slate-400 font-bold text-[10px] mb-3 uppercase tracking-widest",children:["Quiz Complete • Score: ",_,"/",a.length]}),e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"bg-slate-50/50 rounded-xl p-3 mb-4 border border-slate-100 flex flex-col gap-2",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest text-left mb-1.5 ml-1",children:"Performance Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(vs,{value:_,label:"Correct Answers",delay:500,icon:e.jsx(lt,{size:14,className:"h-3 w-3 text-emerald-500"})}),e.jsx(vs,{value:Ye,label:"Total XP Earned",delay:800,icon:e.jsx(Re,{size:14,className:"h-3 w-3 text-amber-500"})}),e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.4},className:"flex items-center justify-between pt-1.5 mt-1 border-t border-slate-100",children:[e.jsx("span",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest",children:"Final Accuracy"}),e.jsxs("span",{className:"text-lg font-black text-slate-800 tabular-nums",children:[w,"%"]})]})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{size:"lg",onClick:()=>{r(0),x(0),b(null),M(""),R(0),y(0),E(0),Ke(0),je([]),d(!1),N(!1),U(!1),D({}),yt({}),Mt({}),ee(!1)},className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-white hover:bg-slate-50 text-purple-600 border-2 border-purple-100",children:"RETAKE QUIZ"}),e.jsx(ze,{size:"lg",onClick:()=>l(w,J),className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-purple-600 hover:bg-purple-700 text-white shadow-lg shadow-purple-200",children:"BACK TO MODULE"})]})]})]});return ut.createPortal(ae,G)}return e.jsxs(e.Fragment,{children:[vt&&ut.createPortal(e.jsx(v.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"fixed right-6 top-1/2 -translate-y-1/2 z-[9999] w-64",children:e.jsxs("div",{className:"bg-white rounded-2xl p-3 border border-slate-200 shadow-[0_10px_40px_rgba(0,0,0,0.2)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsxs("h4",{className:"text-xs font-bold text-[#0a1628] flex items-center gap-2",children:[e.jsx(mt,{size:14,className:"text-purple-600"})," Calculator"]}),e.jsx("button",{onClick:()=>oe(!1),className:"w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-slate-500 hover:text-slate-800 hover:bg-slate-200 transition-colors",children:e.jsx(De,{size:12})})]}),e.jsx(Is,{isOpen:!0,onClose:()=>oe(!1),inline:!0})]})}),document.getElementById("modal-root")),ie&&ut.createPortal(e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-6 max-w-xs w-full text-center border-2 border-rose-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)]",children:[e.jsx(v.div,{animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},className:"text-6xl mb-4",children:"💔"}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-3",children:"Out of Lives!"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"Your hearts have run out. You can wait for them to refill or head back and review your lessons in the meantime."}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2 text-rose-500 font-bold",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5"}),e.jsx("span",{children:"0 / 15 hearts"})]}),e.jsxs("p",{className:"text-slate-400 text-xs mb-4",children:["Next heart in: ",e.jsxs("span",{className:"font-bold text-slate-600",children:[Math.floor(at/6e4),":",Math.floor(at%6e4/1e3).toString().padStart(2,"0")]})," (15 minutes per heart)"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{onClick:o,className:"w-full py-3 bg-rose-500 hover:bg-rose-600 text-white font-bold rounded-full",children:"Exit Quiz"}),e.jsx(ze,{onClick:()=>{ue(!1)},className:"w-full py-3 bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold rounded-full",children:"Review Lessons"})]})]})}),document.getElementById("modal-root")),e.jsxs($e,{children:[K&&Z&&e.jsx(v.div,{initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:-20,opacity:0},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-24 left-1/2 -translate-x-1/2 z-[75] pointer-events-none",style:{willChange:"transform, opacity"},children:e.jsx("div",{className:"bg-white/90 px-4 py-2 rounded-2xl shadow-xl font-bold text-sm",children:Z})},"popup"),Qe&&e.jsx(v.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[100] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-white/95 backdrop-blur-xl border border-slate-200 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.15)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-[0_10px_20px_rgba(0,0,0,0.15)]"}),e.jsx("h2",{className:`text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest ${A?"text-emerald-500":"text-rose-500"}`,children:A?"Correct!":"Incorrect"}),A?e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-full font-bold border border-emerald-500/30",children:e.jsxs("span",{children:["+ ",(c[n]||[]).length>0?5:10," XP"]})}),se==="streak"&&e.jsxs("div",{className:"flex items-center gap-2 bg-orange-500/20 text-orange-400 px-4 py-1.5 rounded-full text-sm font-bold border border-orange-500/30",children:[e.jsx(As,{size:14})," Streak Started!"]}),se==="multiplier2"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×2!"]}),se==="multiplier3"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×3!"]})]}):e.jsxs("div",{className:"bg-rose-500/20 border border-rose-500/30 text-rose-400 font-bold px-5 py-2 rounded-xl text-center",children:["Correct: ",h.correctAnswer]})]})},"round-result")]}),e.jsxs("div",{className:"fixed inset-0 z-50 h-screen w-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsxs("header",{className:`relative shrink-0 flex flex-col items-center justify-start px-4 pt-4 sm:pt-6 pb-6 z-[60] shadow-md overflow-hidden ${rs.gradient} rounded-b-[32px] sm:rounded-b-[40px] min-h-[110px] sm:min-h-[130px]`,children:[e.jsxs("div",{className:"absolute inset-0 z-0 pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-0 w-64 h-64 bg-white opacity-10 rounded-full -translate-x-1/2 -translate-y-1/2 blur-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-80 h-80 bg-white opacity-10 rounded-full translate-x-1/3 translate-y-1/3 blur-3xl"}),Rt.map((w,C)=>e.jsx("div",{className:"absolute text-white/10",style:{top:`${10+C*15}%`,left:`${10+C*25%80}%`,transform:`rotate(${C*45}deg) scale(${1+C%3*.2})`},children:e.jsx(w,{size:48+C%2*32})},C))]}),e.jsxs("div",{className:"w-full max-w-7xl flex items-start justify-between relative z-10 mb-4 sm:mb-6",children:[e.jsx("div",{className:"flex-1 pointer-events-none"}),e.jsxs("div",{className:"relative flex items-center justify-center bg-purple-900/40 backdrop-blur-md px-6 sm:px-8 py-3 rounded-full border border-white/10 gap-3 sm:gap-4 shadow-inner",children:[e.jsx("div",{className:"w-3 h-3 sm:w-4 sm:h-4 rounded-full bg-yellow-400 shrink-0 shadow-[0_0_10px_rgba(250,204,21,0.6)]"}),e.jsxs("div",{className:"flex flex-col items-start justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] font-black text-purple-200 uppercase tracking-widest leading-none mb-1",children:"Try It Yourself!"}),e.jsxs("span",{className:"font-bold text-white tracking-wide text-base sm:text-lg leading-none truncate max-w-[200px] sm:max-w-[300px]",children:["LESSON ",t.id||"1"]})]})]}),e.jsxs("div",{className:"flex-1 flex justify-end gap-2 sm:gap-3 relative pointer-events-auto",children:[e.jsx("button",{onClick:()=>it(!tt),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:tt?e.jsx(Fs,{size:20}):e.jsx(Ds,{size:20})}),e.jsx("button",{onClick:Ee,className:"hidden sm:flex w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:He?e.jsx(Rs,{size:20}):e.jsx($s,{size:20})}),e.jsx("button",{onClick:()=>Ge(!0),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:e.jsx(ea,{size:20})})]})]}),e.jsx("div",{className:"w-full max-w-[50rem] flex items-center justify-center px-4 z-10",children:e.jsx("div",{className:"w-full flex items-center gap-2 sm:gap-3",children:a.map((w,C)=>e.jsx("div",{className:`h-1.5 sm:h-2 rounded-full flex-1 transition-all ${C<=n?"bg-white shadow-[0_0_8px_rgba(255,255,255,0.8)]":"bg-white/20"}`},C))})})]}),e.jsx($e,{children:wt&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>Ge(!1),children:e.jsxs(v.div,{onClick:w=>w.stopPropagation(),initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"bg-white rounded-[32px] p-6 sm:p-8 max-w-sm w-full shadow-2xl border border-slate-200 flex flex-col gap-4 text-center",children:[e.jsx("h2",{className:"text-2xl font-black text-[#0a1628]",children:"Pause Menu"}),e.jsx(ze,{onClick:()=>Ge(!1),className:"w-full py-6 rounded-2xl bg-slate-100 text-slate-700 font-bold",children:"Continue Quiz"}),e.jsx(ze,{onClick:o,className:"w-full py-6 rounded-2xl bg-red-500 text-white font-bold",children:"Exit Quiz"})]})})}),e.jsxs("div",{className:"w-full max-w-[54rem] mx-auto shrink-0 flex items-center justify-between px-4 sm:px-6 py-2 sm:py-3 z-[50] relative mt-4",children:[e.jsx("button",{onClick:()=>x(w=>Math.max(0,w-1)),disabled:i===0,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${i===0?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(Yt,{size:24})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 sm:gap-5 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-rose-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5 object-contain"}),L]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-yellow-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Keys",className:"w-5 h-5 object-contain"}),X]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 px-3 py-1.5 pl-5 sm:pl-6 rounded-full bg-white shadow-md border border-slate-200/60",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_streak.png",alt:"Streak",className:"w-5 h-5 object-contain"})," ",m]}),e.jsxs("div",{className:"bg-emerald-100 text-emerald-800 px-4 py-1.5 rounded-full font-bold text-sm sm:text-base shadow-inner border border-emerald-200/50",children:["+ ",Ye," pts"]})]})]}),e.jsx("button",{onClick:()=>x(w=>Math.min(n,w+1)),disabled:i>=n,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${i>=n?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(ht,{size:24})})]}),e.jsx("main",{className:"flex-1 overflow-y-auto w-full px-4 sm:px-6 pt-0 pb-6 flex flex-col items-center relative z-10",children:e.jsxs(v.div,{initial:{opacity:0,x:20},animate:jt?{x:[-10,10,-10,10,0],scale:[1,1.01,1],opacity:1}:{opacity:1,x:0},className:"w-full max-w-3xl flex flex-col mt-2",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-lg border-t-[6px] border-purple-500 p-6 sm:p-8 text-center flex flex-col items-center mb-6 w-full relative overflow-hidden",children:[(()=>{const C=[{label:"New",color:"bg-blue-100 text-blue-700",icon:e.jsx(Es,{size:14,className:"mr-1.5"})},{label:"Learning",color:"bg-amber-100 text-amber-700",icon:e.jsx(Pt,{size:14,className:"mr-1.5"})},{label:"Retry",color:"bg-rose-100 text-rose-700",icon:e.jsx(Ps,{size:14,className:"mr-1.5"})},{label:"Mastered",color:"bg-emerald-100 text-emerald-700",icon:e.jsx(Ct,{size:14,className:"mr-1.5"})}][i%4];return e.jsxs("div",{className:`${C.color} px-4 py-1.5 rounded-full text-[11px] sm:text-xs font-black uppercase tracking-widest mb-6 flex items-center shadow-sm`,children:[C.icon," ",C.label]})})(),e.jsx("h2",{className:"text-xl sm:text-2xl font-extrabold text-[#0a1628] leading-tight w-full",children:h.question.includes("___")?e.jsx("span",{children:h.question.split("___").map((w,C,q)=>e.jsxs(Ae.Fragment,{children:[w,C0,value:g,onChange:V=>M(V.target.value),className:`inline-block w-24 mx-2 border-b-4 outline-none text-center bg-transparent font-bold ${H?et[i]?"border-[#75D06A] text-[#75D06A]":"border-rose-500 text-rose-500":"border-[#7C3AED] text-[#7C3AED] focus:border-[#75D06A]"}`})]},C))}):h.question})]}),e.jsxs("div",{className:"w-full flex flex-col items-center",children:[(h.type==="multiple-choice"||h.type==="true-false")&&e.jsx("div",{className:"w-full grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-5",children:(h.type==="true-false"?["True","False"]:O).map((w,C)=>{const q=typeof w=="string"?w:w.text,V=typeof w=="string"?`${h.id}-${C}`:w.id,J=(pe[i]||[]).includes(q),G=fe[i]||Ne,ae=c[n]||[],Pe=ae.includes(q),xt=ae.length,Ze=O.filter(Xs=>Xs.text!==h.correctAnswer).length,rt=i===n&&Ze>0&&xt>=Ze;let Te="bg-white hover:bg-slate-50 border-transparent text-slate-700 hover:border-slate-200",$t=!1;return rt?($t=!0,q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-80":Te="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through"):Pe?Te="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through cursor-not-allowed":G?q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800 shadow-[0_0_15px_rgba(16,185,129,0.2)] scale-[1.02] z-10":Te="bg-slate-50 border-slate-200 text-slate-400 opacity-60":H?q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800 shadow-[0_0_15px_rgba(16,185,129,0.2)] scale-[1.02] z-10":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-60":Te="bg-slate-50 border-slate-200 text-slate-400 opacity-60":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-60":p===V&&(Te="bg-purple-50 border-[#9956DE] text-[#9956DE]"),e.jsxs("button",{disabled:$t||H||J||G||Pe,onClick:()=>{$t||H||$||J||G||Pe||(b(V),qe(q))},className:`p-4 sm:p-5 rounded-2xl shadow-sm border-[3px] font-extrabold text-base sm:text-lg text-left transition-all flex items-center justify-between ${Te} ${H||G||Pe?"cursor-default":"hover:shadow-md hover:-translate-y-0.5 active:translate-y-0"}`,children:[e.jsx("span",{className:"truncate pr-4",children:q}),Pe&&e.jsx(De,{size:20,className:"text-slate-400 shrink-0"}),G&&q===h.correctAnswer&&e.jsx(lt,{size:24,className:"text-emerald-500 shrink-0"}),H&&q===h.correctAnswer&&!G&&e.jsx(lt,{size:24,className:"text-emerald-500 shrink-0"}),(H||J)&&J&&e.jsx(De,{size:24,className:"text-rose-500 shrink-0"})]},V)})}),Ne&&e.jsx(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"w-full mt-6 space-y-4 max-w-3xl",children:e.jsxs("div",{className:"border-2 rounded-2xl p-5 flex items-start gap-4 bg-sky-50 border-sky-200",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",className:"w-10 h-10 shrink-0",alt:"AI Explain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-extrabold text-lg mb-1 text-sky-700",children:"Explanation"}),e.jsx("p",{className:"text-base leading-relaxed text-sky-800",children:h.explanation||`The correct answer is: ${h.correctAnswer}`})]})]})})]})]},i)}),e.jsxs("footer",{className:`shrink-0 relative z-[60] flex flex-col items-center justify-center p-4 sm:p-6 ${rs.gradient} rounded-t-[32px] sm:rounded-t-[40px] shadow-[0_-10px_40px_rgba(0,0,0,0.15)]`,children:[e.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none opacity-20",children:Rt.slice(0,3).map((w,C)=>e.jsx("div",{className:"absolute text-white",style:{top:`${20+C*20}%`,left:`${20+C*30}%`,transform:`rotate(${C*30}deg) scale(1.5)`},children:e.jsx(w,{size:32})},C))}),e.jsx("div",{className:"relative z-10 flex flex-col gap-3",children:ix(n),className:"bg-white text-slate-700 font-extrabold text-lg px-6 sm:px-8 py-3 sm:py-4 rounded-full flex items-center gap-2 sm:gap-3 shadow-lg hover:bg-slate-50 transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(ht,{size:20,className:"sm:w-6 sm:h-6"}),"Back to Current Question"]})]}):e.jsx(e.Fragment,{children:(()=>{const w=(c[n]||[]).length,C=O.filter(J=>J.text!==h.correctAnswer).length,q=C>0&&w>=C,V=z&&!A||fe[n]||Ne||q;if(Ne)return e.jsxs("button",{onClick:Nt,className:"bg-orange-500 hover:bg-orange-600 text-white font-extrabold text-lg px-8 py-4 rounded-full flex items-center justify-center gap-3 shadow-xl hover:scale-[1.02] active:scale-[0.98] transition-all w-full",children:[n0&&!z&&!fe[n]&&!Ne&&!q;return e.jsxs("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4",children:[e.jsxs("button",{onClick:be,disabled:!ce,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Hint",className:"w-5 h-5 object-contain"}),"Hint"]}),e.jsxs("button",{onClick:xe,disabled:fe[n]||z||Ne,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(ga,{size:18,className:"text-purple-500"}),"Reveal"]}),e.jsxs("button",{onClick:he,className:"bg-white hover:bg-slate-50 text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",className:"w-5 h-5 drop-shadow-sm",alt:"AI Explain"}),"Explain"]}),e.jsx("button",{onClick:()=>oe(J=>!J),className:`w-11 h-11 sm:w-12 sm:h-12 rounded-full flex items-center justify-center shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200 ${vt?"bg-purple-100 text-purple-600 border-purple-300":"bg-white hover:bg-slate-50 text-slate-700"}`,children:e.jsx(mt,{size:20})})]})})()})})]})]})]})};function or(){return e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-slate-900 shadow-lg",children:[e.jsx("div",{className:"relative w-full aspect-video bg-slate-800 animate-pulse"}),e.jsxs("div",{className:"px-4 py-3 bg-slate-800 space-y-2",children:[e.jsx("div",{className:"h-4 bg-slate-700 rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-3 bg-slate-700 rounded w-1/2 animate-pulse"})]})]})}const cr=({videos:t,topic:a})=>{const[l,o]=s.useState(0);if(!t||t.length===0)return e.jsx(or,{});const n=t[l],r=t.filter((i,x)=>x!==l);return e.jsxs("div",{className:"space-y-4",children:[e.jsx($e,{mode:"wait",children:e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"rounded-2xl overflow-hidden bg-slate-900 shadow-lg",children:[e.jsx("div",{className:"relative w-full aspect-video",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${n.videoId}?rel=0&modestbranding=1`,title:n.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"absolute inset-0 w-full h-full border-0"})}),e.jsxs("div",{className:"px-4 py-3 bg-slate-800",children:[e.jsx("p",{className:"text-slate-200 text-sm font-medium truncate",children:n.title}),e.jsx("p",{className:"text-slate-400 text-xs mt-0.5",children:n.channelTitle})]})]},n.videoId)}),r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium uppercase tracking-wide",children:"More videos"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:r.slice(0,2).map(i=>{const x=t.findIndex(p=>p.videoId===i.videoId);return e.jsxs("button",{onClick:()=>o(x),className:"group text-left rounded-xl overflow-hidden border border-slate-200 hover:border-rose-300 hover:shadow-md transition-all duration-200 bg-white",children:[e.jsxs("div",{className:"relative aspect-video",children:[e.jsx("img",{src:i.thumbnailUrl,alt:i.title,loading:"lazy",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:e.jsx(Bs,{size:14,className:"text-rose-500 ml-0.5"})})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"text-slate-700 text-xs font-medium line-clamp-2 leading-snug",children:i.title}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-0.5 truncate",children:i.channelTitle})]})]},i.videoId)})})]})]})},dr=({lessonId:t,lessonTitle:a,topic:l,subjectId:o,competencyCode:n,onComplete:r,onQuizComplete:i,onClose:x,onContinueLearning:p})=>{const[b,g]=s.useState([]),[M,z]=s.useState(!0),[d,A]=s.useState(null),[N,_]=s.useState(0),[R,m]=s.useState(null),[y,j]=s.useState(!1),[E,k]=s.useState(!1),[U,O]=s.useState([]),[Y,$]=s.useState(!1),[te,de]=s.useState(!1),_e=U.reduce((I,u)=>I+(u?.correct?1:0),0),re=s.useCallback(async()=>{z(!0),A(null);try{const{generateLessonQuiz:I}=await Lt(async()=>{const{generateLessonQuiz:P}=await Promise.resolve().then(()=>kr);return{generateLessonQuiz:P}},void 0),u=await I({lessonId:t,lessonTitle:a,topic:l,subjectId:o,competencyCode:n,questionCount:10});if(u.length===0){A("No questions available for this topic.");return}g(u)}catch(I){console.error("[TryItYourselfQuiz] Generation failed:",I),A("Failed to generate quiz. Please try again.")}finally{z(!1)}},[t,a,l,o,n]);s.useEffect(()=>{if(b.length>0&&U.length>0)try{const I=U.every(u=>u!==void 0);sessionStorage.setItem(`quiz_${t}`,JSON.stringify({answers:U,currentIndex:N,questions:b,isCompleted:I}))}catch{}},[U,N,t,b]),s.useEffect(()=>{if(!te){try{const I=sessionStorage.getItem(`quiz_${t}`);if(I){const{answers:u,currentIndex:P,questions:f,isCompleted:T}=JSON.parse(I);if(u?.length&&f?.length){O(u),_(P),g(f),z(!1);const F=u[P];F&&(m(F.userAnswer),j(!0),k(F.correct)),T&&$(!0),de(!0);return}}}catch{}re()}},[t]);const W=s.useCallback(I=>{if(y)return;const u=b[N],P=I.toLowerCase().trim(),f=u.correctAnswer?.toLowerCase().trim()||"";let T=P===f;if(!T&&u.options&&u.options.length>0){const F=u.options.map(ne=>ne.toLowerCase().trim()),ee=F.includes(P);(ee&&F.includes(f)||ee&&F.length===2)&&(T=!0)}m(I),j(!0),k(T),O(F=>{const ee=[...F];return ee[N]={correct:T,userAnswer:I},ee})},[N,y,b]),Z=()=>{if(Nu+1);const I=U[N+1];I?(m(I.userAnswer),j(!0),k(I.correct)):(m(null),j(!1),k(!1))}else{const I=U.reduce((P,f)=>P+(f?.correct?1:0),0),u=Math.round(I/b.length*100);r?.(I,b.length),i?.(u),$(!0)}},ge=()=>{if(N>0){_(u=>u-1);const I=U[N-1];I?(m(I.userAnswer),j(!0),k(I.correct)):(m(null),j(!1),k(!1))}},K=b[N],we=(N+1)/b.length*100;if(M)return e.jsx("div",{className:"bg-white rounded-2xl p-6 border border-slate-200 shadow-sm",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-rose-400 border-t-transparent animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"Generating your practice quiz..."}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Creating 10 unique questions with variance"})]})});if(d)return e.jsx("div",{className:"bg-white rounded-2xl p-6 border border-slate-200 shadow-sm",children:e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-rose-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(De,{className:"text-rose-500",size:24})}),e.jsx("p",{className:"text-slate-700 font-medium mb-2",children:d}),e.jsx("button",{onClick:re,className:"px-4 py-2 bg-rose-500 text-white rounded-lg font-semibold text-sm hover:bg-rose-600 transition-colors",children:"Try Again"})]})});if(!K)return null;const Me=N===b.length-1;return e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-rose-500 to-orange-400 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(ns,{size:20}),e.jsx("span",{className:"font-bold",children:"Practice Quiz"})]}),e.jsxs("div",{className:"text-white/90 text-sm font-semibold",children:[_e,"/",b.length," correct"]})]}),e.jsx("div",{className:"h-2 bg-white/30 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-white rounded-full",initial:{width:0},animate:{width:`${we}%`},transition:{duration:.3}})}),e.jsxs("div",{className:"flex justify-between text-white/80 text-xs mt-1",children:[e.jsxs("span",{children:["Question ",N+1," of ",b.length]}),e.jsxs("span",{children:[Math.round(we),"% complete"]})]})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[N<2&&e.jsxs("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Kt,{size:12})," Recall"]}),N>=2&&N<6&&e.jsxs("span",{className:"px-2 py-0.5 bg-emerald-100 text-emerald-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Oe,{size:12})," Application"]}),N>=6&&N<9&&e.jsxs("span",{className:"px-2 py-0.5 bg-purple-100 text-purple-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Re,{size:12})," Mixed"]}),N===9&&e.jsxs("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(ns,{size:12})," Metacognitive"]}),K.type==="true-false"&&e.jsx("span",{className:"px-2 py-0.5 bg-slate-100 text-slate-700 text-xs font-semibold rounded-full uppercase tracking-wide border border-slate-200",children:"True or False"})]}),e.jsx("p",{className:"text-slate-800 text-base font-medium leading-relaxed mb-5",children:K.question}),e.jsx("div",{className:"space-y-2",children:K.type==="true-false"?e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>W("True"),disabled:y,className:`flex-1 py-4 rounded-xl font-bold text-lg transition-all ${y?R==="True"?K.correctAnswer==="True"?"bg-emerald-500 text-white":"bg-rose-500 text-white":"bg-slate-200 text-slate-400":"bg-purple-100 text-purple-700 hover:bg-purple-200"}`,children:"True"}),e.jsx("button",{onClick:()=>W("False"),disabled:y,className:`flex-1 py-4 rounded-xl font-bold text-lg transition-all ${y?R==="False"?K.correctAnswer==="False"?"bg-emerald-500 text-white":"bg-rose-500 text-white":"bg-slate-200 text-slate-400":"bg-purple-100 text-purple-700 hover:bg-purple-200"}`,children:"False"})]}):K.options?K.options.map((I,u)=>e.jsx(v.button,{whileHover:{scale:y?1:1.01},whileTap:{scale:y?1:.99},onClick:()=>W(I),disabled:y,className:` + `}),t.map(a=>e.jsx("div",{className:"confetti-piece absolute",style:{left:a.left,top:"-10%",backgroundColor:a.backgroundColor,width:a.size,height:a.size,borderRadius:a.borderRadius,animationDuration:`${a.duration}s`,animationDelay:`${a.delay}s`}},a.id))]})},cr=({lesson:t,questions:a,onComplete:l,onBack:o})=>{const[n,r]=s.useState(0),[i,x]=s.useState(0),[p,b]=s.useState(null),[g,M]=s.useState(""),[z,d]=s.useState(!1),[A,N]=s.useState(!1),[_,R]=s.useState(0),[m,y]=s.useState(0),[j,E]=s.useState(0),[k,U]=s.useState(!1),[O,Y]=s.useState([]),[$,te]=s.useState(!1),[xe,_e]=s.useState(!1),[re,W]=s.useState(null),[Z,ge]=s.useState(null),[K,we]=s.useState(!1),[Me,I]=s.useState(!1),[u,P]=s.useState(!1),[f,T]=s.useState(!1),[F,ee]=s.useState(!1),[ne,Be]=s.useState(typeof window<"u"?window.innerHeight:800),[gt,Ue]=s.useState(typeof window<"u"?window.innerWidth:1200),[et,je]=s.useState([]),[nt]=s.useState(Date.now()),[_t,Xe]=s.useState(0),[wt,Ge]=s.useState(!1),[tt,it]=s.useState(!0),[He,Ve]=s.useState(!1),[ye,ve]=s.useState(!1),[Ne,st]=s.useState(!1),[Qe,ot]=s.useState(!1),[Ye,Ke]=s.useState(0),[c,D]=s.useState({}),[X,le]=s.useState(5),[L,ke]=s.useState(15),[Se,Le]=s.useState(null),[oe,ue]=s.useState(!1),[at,Ie]=s.useState(900*1e3),[fe,yt]=s.useState({}),[pe,Mt]=s.useState({}),[jt,ct]=s.useState(!1),[vt,ce]=s.useState(!1),[se,dt]=s.useState(null),[S]=s.useState(Array.from({length:15},(w,C)=>({id:C,size:Math.random()*120+60,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*25+15,delay:Math.random()*-20,color:["bg-white/5","bg-indigo-300/10","bg-sky-300/10","bg-purple-300/10"][Math.floor(Math.random()*4)]}))),h=a[i],H=i{if(tt)try{const C=window.AudioContext||window.webkitAudioContext;if(!C)return;const q=new C,V=q.currentTime,de=(J,G,ae,Pe=.1,xt="sine")=>{const Ze=q.createOscillator(),rt=q.createGain();Ze.type=xt,Ze.frequency.value=J,rt.gain.setValueAtTime(0,G),rt.gain.linearRampToValueAtTime(Pe,G+.05),rt.gain.exponentialRampToValueAtTime(.001,G+ae),Ze.connect(rt),rt.connect(q.destination),Ze.start(G),Ze.stop(G+ae)};w==="correct"?(de(880,V,.1,.1,"sine"),de(1108.73,V+.1,.2,.1,"sine")):w==="incorrect"?(de(300,V,.2,.05,"sawtooth"),de(250,V+.15,.3,.05,"sawtooth")):w==="streak"?(de(440,V,.1,.05,"square"),de(554.37,V+.1,.1,.05,"square"),de(659.25,V+.2,.1,.05,"square"),de(880,V+.3,.4,.05,"square")):w==="complete"&&(de(523.25,V,.1,.1),de(659.25,V+.15,.1,.1),de(783.99,V+.3,.1,.1),de(1046.5,V+.45,.5,.1))}catch{}};s.useEffect(()=>{const w=()=>{Be(window.innerHeight),Ue(window.innerWidth)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]),s.useEffect(()=>{if(h?.type==="multiple-choice"&&h.options){const w=h.options.map((C,q)=>({id:`${h.id}-${q}`,text:C}));for(let C=w.length-1;C>0;C--){const q=Math.floor(Math.random()*(C+1));[w[C],w[q]]=[w[q],w[C]]}Y(w)}else Y([])},[n,h]),s.useEffect(()=>{ve(!1),st(!1)},[n]);const Ee=()=>{document.fullscreenElement?(document.exitFullscreen().catch(()=>{}),Ve(!1)):(document.documentElement.requestFullscreen().catch(()=>{}),Ve(!0))},he=()=>st(w=>!w);s.useEffect(()=>{const w=C=>{C.key==="Enter"&&(!z&&Fe()?qe():z&&Nt())};return window.addEventListener("keypress",w),()=>window.removeEventListener("keypress",w)},[z,p,g]),s.useEffect(()=>{L===0&&!Se&&(Le(Date.now()),ue(!0))},[L,Se]),s.useEffect(()=>{if(!oe||!Se)return;const w=setInterval(()=>{const C=Date.now()-Se,q=Math.max(0,900*1e3-C);Ie(q)},1e3);return()=>clearInterval(w)},[oe,Se]);const Fe=()=>h.type==="fill-in-blank"?g.trim().length>0:p!==null,be=()=>{if(X<=0||z||fe[n]||Ne)return;const w=c[n]||[],C=O.filter(V=>V.text!==h.correctAnswer).filter(V=>!w.includes(V.text));if(C.length===0)return;const q=C[Math.floor(Math.random()*C.length)];D(V=>({...V,[n]:[...w,q.text]})),le(V=>Math.max(0,V-1)),Ke(V=>Math.max(0,V-5)),Ce("correct")},me=()=>{fe[n]||z||Ne||(yt(w=>({...w,[n]:!0})),ve(!0))},qe=w=>{if($||iae.id===p);q=G?G.text:""}else{te(!1);return}C=q===h.correctAnswer}if(!C){ct(!0),Ce("incorrect"),setTimeout(()=>ct(!1),500),ke(ae=>Math.max(0,ae-1)),y(0);const G=[...pe[n]||[],q];if(Mt(ae=>({...ae,[n]:G})),h.type==="multiple-choice"||h.type==="true-false"){const ae=h.options?h.options.length-1:1;G.length>=ae&&(N(!1),d(!0),je(Pe=>{const xt=[...Pe];return xt[i]=!1,xt}))}else G.length>=3&&(N(!1),d(!0),je(ae=>{const Pe=[...ae];return Pe[i]=!1,Pe}));te(!1);return}N(!0),d(!0),je(G=>{const ae=[...G];return ae[i]=!0,ae});const de=(c[n]||[]).length>0?5:10;Ke(G=>G+de),R(G=>G+1);const J=m+1;if(y(J),E(Math.max(j,J)),J===2?dt("streak"):J===3&&ls<2?dt("multiplier2"):J===5&&ls<3&&dt("multiplier3"),J>0&&J%3===0){const G=J*5;Xe(ae=>ae+G),Ce("streak")}else Ce("correct");ot(!0),setTimeout(()=>{ot(!1),dt(null),setTimeout(()=>Nt(),500)},1200),Lt(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(G=>{G.default({particleCount:30,spread:40,colors:["#75D06A","#6ED1CF"],origin:{y:.6}})}).finally(()=>te(!1))},Nt=()=>{nw+1),x(w=>w+1),d(!1),b(null),M(""),N(!1)):Us()},Us=()=>{const w=Math.round(_/a.length*100);U(!0),w>=80||(w>=50?(T(!0),setTimeout(()=>T(!1),5e3)):(P(!0),setTimeout(()=>P(!1),5e3))),Ce("complete")},rs=Q==="quiz"?{gradient:"bg-gradient-to-br from-[#7274ED] via-[#9956DE] to-[#7274ED]"}:{gradient:"bg-gradient-to-br from-[#75D06A] via-[#6ED1CF] to-[#75D06A]"},Rt=(()=>{const w=B.toLowerCase();return w.includes("geometry")||w.includes("shape")?[js,fs,ys,ps,Wa,Xa]:w.includes("algebra")||w.includes("equation")?[De,Qt,hs,qt,mt,gs]:w.includes("calculus")||w.includes("derivative")||w.includes("integral")?[ws,qt,Pt,mt,Qt,hs]:w.includes("statistics")||w.includes("probability")?[Oe,Pt,ps,fs,js,ys]:[mt,ws,Qt,gs,qt,Ma]})();Rt[0];const ls=Math.min(2,1+m*.1);if(k){const w=Math.round(_/a.length*100),C=w>=80,q=w>=50&&w<80,V=Q==="quiz"?100:50,de=Math.round(_/a.length*100),J=V+de+_t,G=document.getElementById("modal-root"),ae=e.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/40",children:[f&&e.jsx(ir,{viewportHeight:ne,viewportWidth:gt}),u&&e.jsx(nr,{viewportHeight:ne}),C&&e.jsx(or,{}),e.jsxs(v.div,{initial:{opacity:0,scale:.8,y:40},animate:{opacity:1,scale:1,y:0},transition:{type:"spring",damping:18,stiffness:200},className:"w-full max-w-xs sm:max-w-sm bg-white border-2 border-slate-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)] rounded-[2rem] p-4 sm:p-5 text-center relative z-10",children:[e.jsx(v.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",damping:12,stiffness:150,delay:.2},className:"mb-3",children:e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-16 h-16 sm:w-20 sm:h-20 mx-auto drop-shadow-xl"})}),e.jsx(v.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:`text-xl sm:text-2xl font-black uppercase tracking-tight mb-1 drop-shadow-sm ${C?"text-emerald-500":q?"text-amber-500":"text-rose-500"}`,children:C?"EXCELLENT!":q?"GOOD JOB!":"KEEP TRYING!"}),e.jsxs("p",{className:"text-slate-400 font-bold text-[10px] mb-3 uppercase tracking-widest",children:["Quiz Complete • Score: ",_,"/",a.length]}),e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"bg-slate-50/50 rounded-xl p-3 mb-4 border border-slate-100 flex flex-col gap-2",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest text-left mb-1.5 ml-1",children:"Performance Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(vs,{value:_,label:"Correct Answers",delay:500,icon:e.jsx(lt,{size:14,className:"h-3 w-3 text-emerald-500"})}),e.jsx(vs,{value:Ye,label:"Total XP Earned",delay:800,icon:e.jsx(Re,{size:14,className:"h-3 w-3 text-amber-500"})}),e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.4},className:"flex items-center justify-between pt-1.5 mt-1 border-t border-slate-100",children:[e.jsx("span",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest",children:"Final Accuracy"}),e.jsxs("span",{className:"text-lg font-black text-slate-800 tabular-nums",children:[w,"%"]})]})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{size:"lg",onClick:()=>{r(0),x(0),b(null),M(""),R(0),y(0),E(0),Ke(0),je([]),d(!1),N(!1),U(!1),D({}),yt({}),Mt({}),ee(!1)},className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-white hover:bg-slate-50 text-purple-600 border-2 border-purple-100",children:"RETAKE QUIZ"}),e.jsx(ze,{size:"lg",onClick:()=>l(w,J),className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-purple-600 hover:bg-purple-700 text-white shadow-lg shadow-purple-200",children:"BACK TO MODULE"})]})]})]});return ut.createPortal(ae,G)}return e.jsxs(e.Fragment,{children:[vt&&ut.createPortal(e.jsx(v.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"fixed right-6 top-1/2 -translate-y-1/2 z-[9999] w-64",children:e.jsxs("div",{className:"bg-white rounded-2xl p-3 border border-slate-200 shadow-[0_10px_40px_rgba(0,0,0,0.2)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsxs("h4",{className:"text-xs font-bold text-[#0a1628] flex items-center gap-2",children:[e.jsx(mt,{size:14,className:"text-purple-600"})," Calculator"]}),e.jsx("button",{onClick:()=>ce(!1),className:"w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-slate-500 hover:text-slate-800 hover:bg-slate-200 transition-colors",children:e.jsx(De,{size:12})})]}),e.jsx(Fs,{isOpen:!0,onClose:()=>ce(!1),inline:!0})]})}),document.getElementById("modal-root")),oe&&ut.createPortal(e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-6 max-w-xs w-full text-center border-2 border-rose-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)]",children:[e.jsx(v.div,{animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},className:"text-6xl mb-4",children:"💔"}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-3",children:"Out of Lives!"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"Your hearts have run out. You can wait for them to refill or head back and review your lessons in the meantime."}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2 text-rose-500 font-bold",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5"}),e.jsx("span",{children:"0 / 15 hearts"})]}),e.jsxs("p",{className:"text-slate-400 text-xs mb-4",children:["Next heart in: ",e.jsxs("span",{className:"font-bold text-slate-600",children:[Math.floor(at/6e4),":",Math.floor(at%6e4/1e3).toString().padStart(2,"0")]})," (15 minutes per heart)"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{onClick:o,className:"w-full py-3 bg-rose-500 hover:bg-rose-600 text-white font-bold rounded-full",children:"Exit Quiz"}),e.jsx(ze,{onClick:()=>{ue(!1)},className:"w-full py-3 bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold rounded-full",children:"Review Lessons"})]})]})}),document.getElementById("modal-root")),e.jsxs($e,{children:[K&&Z&&e.jsx(v.div,{initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:-20,opacity:0},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-24 left-1/2 -translate-x-1/2 z-[75] pointer-events-none",style:{willChange:"transform, opacity"},children:e.jsx("div",{className:"bg-white/90 px-4 py-2 rounded-2xl shadow-xl font-bold text-sm",children:Z})},"popup"),Qe&&e.jsx(v.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[100] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-white/95 backdrop-blur-xl border border-slate-200 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.15)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-[0_10px_20px_rgba(0,0,0,0.15)]"}),e.jsx("h2",{className:`text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest ${A?"text-emerald-500":"text-rose-500"}`,children:A?"Correct!":"Incorrect"}),A?e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-full font-bold border border-emerald-500/30",children:e.jsxs("span",{children:["+ ",(c[n]||[]).length>0?5:10," XP"]})}),se==="streak"&&e.jsxs("div",{className:"flex items-center gap-2 bg-orange-500/20 text-orange-400 px-4 py-1.5 rounded-full text-sm font-bold border border-orange-500/30",children:[e.jsx(Es,{size:14})," Streak Started!"]}),se==="multiplier2"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×2!"]}),se==="multiplier3"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×3!"]})]}):e.jsxs("div",{className:"bg-rose-500/20 border border-rose-500/30 text-rose-400 font-bold px-5 py-2 rounded-xl text-center",children:["Correct: ",h.correctAnswer]})]})},"round-result")]}),e.jsxs("div",{className:"fixed inset-0 z-50 h-screen w-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsxs("header",{className:`relative shrink-0 flex flex-col items-center justify-start px-4 pt-4 sm:pt-6 pb-6 z-[60] shadow-md overflow-hidden ${rs.gradient} rounded-b-[32px] sm:rounded-b-[40px] min-h-[110px] sm:min-h-[130px]`,children:[e.jsxs("div",{className:"absolute inset-0 z-0 pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-0 w-64 h-64 bg-white opacity-10 rounded-full -translate-x-1/2 -translate-y-1/2 blur-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-80 h-80 bg-white opacity-10 rounded-full translate-x-1/3 translate-y-1/3 blur-3xl"}),Rt.map((w,C)=>e.jsx("div",{className:"absolute text-white/10",style:{top:`${10+C*15}%`,left:`${10+C*25%80}%`,transform:`rotate(${C*45}deg) scale(${1+C%3*.2})`},children:e.jsx(w,{size:48+C%2*32})},C))]}),e.jsxs("div",{className:"w-full max-w-7xl flex items-start justify-between relative z-10 mb-4 sm:mb-6",children:[e.jsx("div",{className:"flex-1 pointer-events-none"}),e.jsxs("div",{className:"relative flex items-center justify-center bg-purple-900/40 backdrop-blur-md px-6 sm:px-8 py-3 rounded-full border border-white/10 gap-3 sm:gap-4 shadow-inner",children:[e.jsx("div",{className:"w-3 h-3 sm:w-4 sm:h-4 rounded-full bg-yellow-400 shrink-0 shadow-[0_0_10px_rgba(250,204,21,0.6)]"}),e.jsxs("div",{className:"flex flex-col items-start justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] font-black text-purple-200 uppercase tracking-widest leading-none mb-1",children:"Try It Yourself!"}),e.jsxs("span",{className:"font-bold text-white tracking-wide text-base sm:text-lg leading-none truncate max-w-[200px] sm:max-w-[300px]",children:["LESSON ",t.id||"1"]})]})]}),e.jsxs("div",{className:"flex-1 flex justify-end gap-2 sm:gap-3 relative pointer-events-auto",children:[e.jsx("button",{onClick:()=>it(!tt),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:tt?e.jsx(Ds,{size:20}):e.jsx(Rs,{size:20})}),e.jsx("button",{onClick:Ee,className:"hidden sm:flex w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:He?e.jsx($s,{size:20}):e.jsx(Bs,{size:20})}),e.jsx("button",{onClick:()=>Ge(!0),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:e.jsx(ta,{size:20})})]})]}),e.jsx("div",{className:"w-full max-w-[50rem] flex items-center justify-center px-4 z-10",children:e.jsx("div",{className:"w-full flex items-center gap-2 sm:gap-3",children:a.map((w,C)=>e.jsx("div",{className:`h-1.5 sm:h-2 rounded-full flex-1 transition-all ${C<=n?"bg-white shadow-[0_0_8px_rgba(255,255,255,0.8)]":"bg-white/20"}`},C))})})]}),e.jsx($e,{children:wt&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>Ge(!1),children:e.jsxs(v.div,{onClick:w=>w.stopPropagation(),initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"bg-white rounded-[32px] p-6 sm:p-8 max-w-sm w-full shadow-2xl border border-slate-200 flex flex-col gap-4 text-center",children:[e.jsx("h2",{className:"text-2xl font-black text-[#0a1628]",children:"Pause Menu"}),e.jsx(ze,{onClick:()=>Ge(!1),className:"w-full py-6 rounded-2xl bg-slate-100 text-slate-700 font-bold",children:"Continue Quiz"}),e.jsx(ze,{onClick:o,className:"w-full py-6 rounded-2xl bg-red-500 text-white font-bold",children:"Exit Quiz"})]})})}),e.jsxs("div",{className:"w-full max-w-[54rem] mx-auto shrink-0 flex items-center justify-between px-4 sm:px-6 py-2 sm:py-3 z-[50] relative mt-4",children:[e.jsx("button",{onClick:()=>x(w=>Math.max(0,w-1)),disabled:i===0,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${i===0?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(Yt,{size:24})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 sm:gap-5 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-rose-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5 object-contain"}),L]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-yellow-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Keys",className:"w-5 h-5 object-contain"}),X]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 px-3 py-1.5 pl-5 sm:pl-6 rounded-full bg-white shadow-md border border-slate-200/60",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_streak.png",alt:"Streak",className:"w-5 h-5 object-contain"})," ",m]}),e.jsxs("div",{className:"bg-emerald-100 text-emerald-800 px-4 py-1.5 rounded-full font-bold text-sm sm:text-base shadow-inner border border-emerald-200/50",children:["+ ",Ye," pts"]})]})]}),e.jsx("button",{onClick:()=>x(w=>Math.min(n,w+1)),disabled:i>=n,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${i>=n?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(ht,{size:24})})]}),e.jsx("main",{className:"flex-1 overflow-y-auto w-full px-4 sm:px-6 pt-0 pb-6 flex flex-col items-center relative z-10",children:e.jsxs(v.div,{initial:{opacity:0,x:20},animate:jt?{x:[-10,10,-10,10,0],scale:[1,1.01,1],opacity:1}:{opacity:1,x:0},className:"w-full max-w-3xl flex flex-col mt-2",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-lg border-t-[6px] border-purple-500 p-6 sm:p-8 text-center flex flex-col items-center mb-6 w-full relative overflow-hidden",children:[(()=>{const C=[{label:"New",color:"bg-blue-100 text-blue-700",icon:e.jsx(Ps,{size:14,className:"mr-1.5"})},{label:"Learning",color:"bg-amber-100 text-amber-700",icon:e.jsx(Pt,{size:14,className:"mr-1.5"})},{label:"Retry",color:"bg-rose-100 text-rose-700",icon:e.jsx(Ts,{size:14,className:"mr-1.5"})},{label:"Mastered",color:"bg-emerald-100 text-emerald-700",icon:e.jsx(Ct,{size:14,className:"mr-1.5"})}][i%4];return e.jsxs("div",{className:`${C.color} px-4 py-1.5 rounded-full text-[11px] sm:text-xs font-black uppercase tracking-widest mb-6 flex items-center shadow-sm`,children:[C.icon," ",C.label]})})(),e.jsx("h2",{className:"text-xl sm:text-2xl font-extrabold text-[#0a1628] leading-tight w-full",children:h.question.includes("___")?e.jsx("span",{children:h.question.split("___").map((w,C,q)=>e.jsxs(Ae.Fragment,{children:[w,C0,value:g,onChange:V=>M(V.target.value),className:`inline-block w-24 mx-2 border-b-4 outline-none text-center bg-transparent font-bold ${H?et[i]?"border-[#75D06A] text-[#75D06A]":"border-rose-500 text-rose-500":"border-[#7C3AED] text-[#7C3AED] focus:border-[#75D06A]"}`})]},C))}):h.question})]}),e.jsxs("div",{className:"w-full flex flex-col items-center",children:[(h.type==="multiple-choice"||h.type==="true-false")&&e.jsx("div",{className:"w-full grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-5",children:(h.type==="true-false"?["True","False"]:O).map((w,C)=>{const q=typeof w=="string"?w:w.text,V=typeof w=="string"?`${h.id}-${C}`:w.id,J=(pe[i]||[]).includes(q),G=fe[i]||Ne,ae=c[n]||[],Pe=ae.includes(q),xt=ae.length,Ze=O.filter(Xs=>Xs.text!==h.correctAnswer).length,rt=i===n&&Ze>0&&xt>=Ze;let Te="bg-white hover:bg-slate-50 border-transparent text-slate-700 hover:border-slate-200",$t=!1;return rt?($t=!0,q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-80":Te="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through"):Pe?Te="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through cursor-not-allowed":G?q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800 shadow-[0_0_15px_rgba(16,185,129,0.2)] scale-[1.02] z-10":Te="bg-slate-50 border-slate-200 text-slate-400 opacity-60":H?q===h.correctAnswer?Te="bg-emerald-50 border-emerald-400 text-emerald-800 shadow-[0_0_15px_rgba(16,185,129,0.2)] scale-[1.02] z-10":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-60":Te="bg-slate-50 border-slate-200 text-slate-400 opacity-60":J?Te="bg-rose-50 border-rose-400 text-rose-800 opacity-60":p===V&&(Te="bg-purple-50 border-[#9956DE] text-[#9956DE]"),e.jsxs("button",{disabled:$t||H||J||G||Pe,onClick:()=>{$t||H||$||J||G||Pe||(b(V),qe(q))},className:`p-4 sm:p-5 rounded-2xl shadow-sm border-[3px] font-extrabold text-base sm:text-lg text-left transition-all flex items-center justify-between ${Te} ${H||G||Pe?"cursor-default":"hover:shadow-md hover:-translate-y-0.5 active:translate-y-0"}`,children:[e.jsx("span",{className:"truncate pr-4",children:q}),Pe&&e.jsx(De,{size:20,className:"text-slate-400 shrink-0"}),G&&q===h.correctAnswer&&e.jsx(lt,{size:24,className:"text-emerald-500 shrink-0"}),H&&q===h.correctAnswer&&!G&&e.jsx(lt,{size:24,className:"text-emerald-500 shrink-0"}),(H||J)&&J&&e.jsx(De,{size:24,className:"text-rose-500 shrink-0"})]},V)})}),Ne&&e.jsx(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"w-full mt-6 space-y-4 max-w-3xl",children:e.jsxs("div",{className:"border-2 rounded-2xl p-5 flex items-start gap-4 bg-sky-50 border-sky-200",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",className:"w-10 h-10 shrink-0",alt:"AI Explain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-extrabold text-lg mb-1 text-sky-700",children:"Explanation"}),e.jsx("p",{className:"text-base leading-relaxed text-sky-800",children:h.explanation||`The correct answer is: ${h.correctAnswer}`})]})]})})]})]},i)}),e.jsxs("footer",{className:`shrink-0 relative z-[60] flex flex-col items-center justify-center p-4 sm:p-6 ${rs.gradient} rounded-t-[32px] sm:rounded-t-[40px] shadow-[0_-10px_40px_rgba(0,0,0,0.15)]`,children:[e.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none opacity-20",children:Rt.slice(0,3).map((w,C)=>e.jsx("div",{className:"absolute text-white",style:{top:`${20+C*20}%`,left:`${20+C*30}%`,transform:`rotate(${C*30}deg) scale(1.5)`},children:e.jsx(w,{size:32})},C))}),e.jsx("div",{className:"relative z-10 flex flex-col gap-3",children:ix(n),className:"bg-white text-slate-700 font-extrabold text-lg px-6 sm:px-8 py-3 sm:py-4 rounded-full flex items-center gap-2 sm:gap-3 shadow-lg hover:bg-slate-50 transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(ht,{size:20,className:"sm:w-6 sm:h-6"}),"Back to Current Question"]})]}):e.jsx(e.Fragment,{children:(()=>{const w=(c[n]||[]).length,C=O.filter(J=>J.text!==h.correctAnswer).length,q=C>0&&w>=C,V=z&&!A||fe[n]||Ne||q;if(Ne)return e.jsxs("button",{onClick:Nt,className:"bg-orange-500 hover:bg-orange-600 text-white font-extrabold text-lg px-8 py-4 rounded-full flex items-center justify-center gap-3 shadow-xl hover:scale-[1.02] active:scale-[0.98] transition-all w-full",children:[n0&&!z&&!fe[n]&&!Ne&&!q;return e.jsxs("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4",children:[e.jsxs("button",{onClick:be,disabled:!de,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Hint",className:"w-5 h-5 object-contain"}),"Hint"]}),e.jsxs("button",{onClick:me,disabled:fe[n]||z||Ne,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(wa,{size:18,className:"text-purple-500"}),"Reveal"]}),e.jsxs("button",{onClick:he,className:"bg-white hover:bg-slate-50 text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",className:"w-5 h-5 drop-shadow-sm",alt:"AI Explain"}),"Explain"]}),e.jsx("button",{onClick:()=>ce(J=>!J),className:`w-11 h-11 sm:w-12 sm:h-12 rounded-full flex items-center justify-center shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200 ${vt?"bg-purple-100 text-purple-600 border-purple-300":"bg-white hover:bg-slate-50 text-slate-700"}`,children:e.jsx(mt,{size:20})})]})})()})})]})]})]})};function dr(){return e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-slate-900 shadow-lg",children:[e.jsx("div",{className:"relative w-full aspect-video bg-slate-800 animate-pulse"}),e.jsxs("div",{className:"px-4 py-3 bg-slate-800 space-y-2",children:[e.jsx("div",{className:"h-4 bg-slate-700 rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-3 bg-slate-700 rounded w-1/2 animate-pulse"})]})]})}const xr=({videos:t,topic:a})=>{const[l,o]=s.useState(0);if(!t||t.length===0)return e.jsx(dr,{});const n=t[l],r=t.filter((i,x)=>x!==l);return e.jsxs("div",{className:"space-y-4",children:[e.jsx($e,{mode:"wait",children:e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"rounded-2xl overflow-hidden bg-slate-900 shadow-lg",children:[e.jsx("div",{className:"relative w-full aspect-video",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${n.videoId}?rel=0&modestbranding=1`,title:n.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"absolute inset-0 w-full h-full border-0"})}),e.jsxs("div",{className:"px-4 py-3 bg-slate-800",children:[e.jsx("p",{className:"text-slate-200 text-sm font-medium truncate",children:n.title}),e.jsx("p",{className:"text-slate-400 text-xs mt-0.5",children:n.channelTitle})]})]},n.videoId)}),r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium uppercase tracking-wide",children:"More videos"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:r.slice(0,2).map(i=>{const x=t.findIndex(p=>p.videoId===i.videoId);return e.jsxs("button",{onClick:()=>o(x),className:"group text-left rounded-xl overflow-hidden border border-slate-200 hover:border-rose-300 hover:shadow-md transition-all duration-200 bg-white",children:[e.jsxs("div",{className:"relative aspect-video",children:[e.jsx("img",{src:i.thumbnailUrl,alt:i.title,loading:"lazy",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:e.jsx(As,{size:14,className:"text-rose-500 ml-0.5"})})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"text-slate-700 text-xs font-medium line-clamp-2 leading-snug",children:i.title}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-0.5 truncate",children:i.channelTitle})]})]},i.videoId)})})]})]})},mr=({lessonId:t,lessonTitle:a,topic:l,subjectId:o,competencyCode:n,onComplete:r,onQuizComplete:i,onClose:x,onContinueLearning:p})=>{const[b,g]=s.useState([]),[M,z]=s.useState(!0),[d,A]=s.useState(null),[N,_]=s.useState(0),[R,m]=s.useState(null),[y,j]=s.useState(!1),[E,k]=s.useState(!1),[U,O]=s.useState([]),[Y,$]=s.useState(!1),[te,xe]=s.useState(!1),_e=U.reduce((I,u)=>I+(u?.correct?1:0),0),re=s.useCallback(async()=>{z(!0),A(null);try{const{generateLessonQuiz:I}=await Lt(async()=>{const{generateLessonQuiz:P}=await Promise.resolve().then(()=>Cr);return{generateLessonQuiz:P}},void 0),u=await I({lessonId:t,lessonTitle:a,topic:l,subjectId:o,competencyCode:n,questionCount:10});if(u.length===0){A("No questions available for this topic.");return}g(u)}catch(I){console.error("[TryItYourselfQuiz] Generation failed:",I),A("Failed to generate quiz. Please try again.")}finally{z(!1)}},[t,a,l,o,n]);s.useEffect(()=>{if(b.length>0&&U.length>0)try{const I=U.every(u=>u!==void 0);sessionStorage.setItem(`quiz_${t}`,JSON.stringify({answers:U,currentIndex:N,questions:b,isCompleted:I}))}catch{}},[U,N,t,b]),s.useEffect(()=>{if(!te){try{const I=sessionStorage.getItem(`quiz_${t}`);if(I){const{answers:u,currentIndex:P,questions:f,isCompleted:T}=JSON.parse(I);if(u?.length&&f?.length){O(u),_(P),g(f),z(!1);const F=u[P];F&&(m(F.userAnswer),j(!0),k(F.correct)),T&&$(!0),xe(!0);return}}}catch{}re()}},[t]);const W=s.useCallback(I=>{if(y)return;const u=b[N],P=I.toLowerCase().trim(),f=u.correctAnswer?.toLowerCase().trim()||"";let T=P===f;if(!T&&u.options&&u.options.length>0){const F=u.options.map(ne=>ne.toLowerCase().trim()),ee=F.includes(P);(ee&&F.includes(f)||ee&&F.length===2)&&(T=!0)}m(I),j(!0),k(T),O(F=>{const ee=[...F];return ee[N]={correct:T,userAnswer:I},ee})},[N,y,b]),Z=()=>{if(Nu+1);const I=U[N+1];I?(m(I.userAnswer),j(!0),k(I.correct)):(m(null),j(!1),k(!1))}else{const I=U.reduce((P,f)=>P+(f?.correct?1:0),0),u=Math.round(I/b.length*100);r?.(I,b.length),i?.(u),$(!0)}},ge=()=>{if(N>0){_(u=>u-1);const I=U[N-1];I?(m(I.userAnswer),j(!0),k(I.correct)):(m(null),j(!1),k(!1))}},K=b[N],we=(N+1)/b.length*100;if(M)return e.jsx("div",{className:"bg-white rounded-2xl p-6 border border-slate-200 shadow-sm",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-rose-400 border-t-transparent animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"Generating your practice quiz..."}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Creating 10 unique questions with variance"})]})});if(d)return e.jsx("div",{className:"bg-white rounded-2xl p-6 border border-slate-200 shadow-sm",children:e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-rose-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(De,{className:"text-rose-500",size:24})}),e.jsx("p",{className:"text-slate-700 font-medium mb-2",children:d}),e.jsx("button",{onClick:re,className:"px-4 py-2 bg-rose-500 text-white rounded-lg font-semibold text-sm hover:bg-rose-600 transition-colors",children:"Try Again"})]})});if(!K)return null;const Me=N===b.length-1;return e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-rose-500 to-orange-400 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(ns,{size:20}),e.jsx("span",{className:"font-bold",children:"Practice Quiz"})]}),e.jsxs("div",{className:"text-white/90 text-sm font-semibold",children:[_e,"/",b.length," correct"]})]}),e.jsx("div",{className:"h-2 bg-white/30 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-white rounded-full",initial:{width:0},animate:{width:`${we}%`},transition:{duration:.3}})}),e.jsxs("div",{className:"flex justify-between text-white/80 text-xs mt-1",children:[e.jsxs("span",{children:["Question ",N+1," of ",b.length]}),e.jsxs("span",{children:[Math.round(we),"% complete"]})]})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[N<2&&e.jsxs("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Kt,{size:12})," Recall"]}),N>=2&&N<6&&e.jsxs("span",{className:"px-2 py-0.5 bg-emerald-100 text-emerald-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Oe,{size:12})," Application"]}),N>=6&&N<9&&e.jsxs("span",{className:"px-2 py-0.5 bg-purple-100 text-purple-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(Re,{size:12})," Mixed"]}),N===9&&e.jsxs("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-semibold rounded-full flex items-center gap-1",children:[e.jsx(ns,{size:12})," Metacognitive"]}),K.type==="true-false"&&e.jsx("span",{className:"px-2 py-0.5 bg-slate-100 text-slate-700 text-xs font-semibold rounded-full uppercase tracking-wide border border-slate-200",children:"True or False"})]}),e.jsx("p",{className:"text-slate-800 text-base font-medium leading-relaxed mb-5",children:K.question}),e.jsx("div",{className:"space-y-2",children:K.type==="true-false"?e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>W("True"),disabled:y,className:`flex-1 py-4 rounded-xl font-bold text-lg transition-all ${y?R==="True"?K.correctAnswer==="True"?"bg-emerald-500 text-white":"bg-rose-500 text-white":"bg-slate-200 text-slate-400":"bg-purple-100 text-purple-700 hover:bg-purple-200"}`,children:"True"}),e.jsx("button",{onClick:()=>W("False"),disabled:y,className:`flex-1 py-4 rounded-xl font-bold text-lg transition-all ${y?R==="False"?K.correctAnswer==="False"?"bg-emerald-500 text-white":"bg-rose-500 text-white":"bg-slate-200 text-slate-400":"bg-purple-100 text-purple-700 hover:bg-purple-200"}`,children:"False"})]}):K.options?K.options.map((I,u)=>e.jsx(v.button,{whileHover:{scale:y?1:1.01},whileTap:{scale:y?1:.99},onClick:()=>W(I),disabled:y,className:` w-full p-4 rounded-xl text-left font-medium transition-all border-2 ${y?I===K.correctAnswer?"bg-emerald-50 border-emerald-500 text-emerald-700":I===R?"bg-rose-50 border-rose-500 text-rose-700":"bg-slate-50 border-slate-200 text-slate-500 opacity-50":"bg-slate-50 border-slate-200 text-slate-700 hover:border-rose-300 hover:bg-rose-50"} `,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:` @@ -111,7 +121,7 @@ import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u a `}),y?e.jsx("button",{onClick:Z,className:"w-full py-3 bg-rose-500 text-white rounded-xl font-bold hover:bg-rose-600 transition-colors",children:Me?"Finish Quiz":"Next Question"}):e.jsxs("button",{onClick:()=>{R?.trim()&&W(R.trim())},disabled:!R?.trim(),className:"w-full py-3 bg-rose-500 text-white rounded-xl font-bold hover:bg-rose-600 transition-colors disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[e.jsx(lt,{size:16}),"Submit Answer"]})]})}),e.jsx($e,{children:y&&e.jsx(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`mt-4 p-4 rounded-xl ${E?"bg-emerald-50 border border-emerald-200":"bg-rose-50 border border-rose-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[E?e.jsx(lt,{className:"text-emerald-500 mt-0.5 shrink-0",size:20}):e.jsx(De,{className:"text-rose-500 mt-0.5 shrink-0",size:20}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:`font-bold text-sm ${E?"text-emerald-700":"text-rose-700"}`,children:E?"Correct!":"Not quite right"}),K.explanation&&e.jsx("p",{className:"text-slate-600 text-sm mt-1 leading-relaxed",children:K.explanation}),!E&&e.jsxs("p",{className:"text-rose-600 text-sm mt-1 font-medium",children:["Correct answer: ",K.correctAnswer]})]})]})})}),y&&e.jsxs("div",{className:"flex items-center justify-between mt-5 pt-4 border-t border-slate-100",children:[e.jsxs("button",{onClick:ge,disabled:N===0,className:` flex items-center gap-1 px-4 py-2 rounded-lg font-semibold text-sm transition-colors ${N===0?"text-slate-300 cursor-not-allowed":"text-slate-600 hover:bg-slate-100"} - `,children:[e.jsx(Yt,{size:18}),"Previous"]}),e.jsxs("button",{onClick:Z,className:"flex items-center gap-1 px-6 py-2.5 bg-rose-500 text-white rounded-xl font-bold text-sm hover:bg-rose-600 transition-colors shadow-md",children:[Me?"Finish":"Next",e.jsx(ht,{size:18})]})]})]}),Y&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-3xl p-8 max-w-sm w-full text-center shadow-2xl",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-rose-400 to-orange-400 flex items-center justify-center mx-auto mb-5",children:e.jsx(Ct,{className:"text-white",size:40})}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-2",children:"Quiz Complete!"}),e.jsxs("p",{className:"text-slate-500 text-sm mb-6",children:["You got ",e.jsx("span",{className:"font-bold text-rose-500",children:_e})," out of ",e.jsx("span",{className:"font-bold",children:b.length})," correct"]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"w-full h-4 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-rose-400 to-orange-400 rounded-full transition-all duration-1000",style:{width:`${_e/b.length*100}%`}})})}),e.jsx("button",{onClick:()=>{$(!1),x?.(),p?.()},className:"w-full py-3 bg-rose-500 text-white rounded-xl font-bold hover:bg-rose-600 transition-colors",children:"Continue Learning"})]})})]})},xr="https://deign86-mathpulse-api-v3test.hf.space";async function Qs(t,a,l=!1){const o={"Content-Type":"application/json",...a?.headers||{}},n=ta.currentUser;if(n)try{const i=await n.getIdToken(l);i&&(o.Authorization=`Bearer ${i}`)}catch(i){throw console.error("[lessonService] Failed to get Firebase ID token:",i),new Error("Authentication failed. Please sign in again.")}const r=await fetch(`${xr}${t}`,{...a,headers:o});if(r.status===401&&n&&!l)return Qs(t,a,!0);if(!r.ok){let i;try{i=await r.json()}catch{i=await r.text()}const x=new Error(typeof i=="object"?JSON.stringify(i):i);throw x.status=r.status,x.body=i,x}return r.json()}async function mr(t){return Qs("/api/rag/lesson",{method:"POST",body:JSON.stringify(t)})}const ur="rag_lesson_";function as(t){return`${ur}${t}`}function pr(t){try{const a=sessionStorage.getItem(as(t));if(a)return JSON.parse(a)}catch{}return null}function hr(t,a){try{sessionStorage.setItem(as(t),JSON.stringify(a))}catch{}}function fr(t,a,l=!0){const[o,n]=s.useState([]),[r,i]=s.useState(!0),[x,p]=s.useState(null),[b,g]=s.useState([]),[M,z]=s.useState("low"),[d,A]=s.useState(0),[N,_]=s.useState(!1),[R,m]=s.useState(void 0),[y,j]=s.useState(!1),E=s.useCallback(async()=>{if(!l||!t)return;const U=pr(t);if(U){n(U.sections),g(U.sources),z(U.retrievalBand),A(U.retrievalConfidence),_(U.needsReview),m(U.activeModel),i(!1),p(null),j(!1);return}i(!0),p(null),j(!1);try{const Y=(await Lt(()=>import("./vendor-firebase-auth-Bcpr4O6E.js"),__vite__mapDeps([0,1])).then(te=>te.getAuth().currentUser))?.uid,$=await mr({...a,lessonId:t,userId:Y});n($.sections),g($.sources||[]),z($.retrievalBand),A($.retrievalConfidence),_($.needsReview),m($.activeModel),hr(t,$),p(null),j(!1)}catch(O){const Y=O.status||O.response?.status,$=O.body||O.response;let te="Failed to load lesson content.",de=!1;Y===404&&$?.error==="no_curriculum_context"?(te=$.message||"Lesson source PDF not found or not yet ingested.",de=!0):Y===401?te="Please sign in again to access lessons.":navigator.onLine||(te="No internet connection. Please try again when online.",de=!0),p(te),j(de),n([])}finally{i(!1)}},[t,l,JSON.stringify(a)]);s.useEffect(()=>{E()},[E]);const k=s.useCallback(()=>{t&&sessionStorage.removeItem(as(t)),i(!0),p(null),E()},[E,t]);return{sections:o,isLoading:r,error:x,retry:k,sources:b,retrievalBand:M,retrievalConfidence:d,needsReview:N,activeModel:R,isOffline:y}}function br(){return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-slate-50 gap-5",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-rose-400 border-t-transparent animate-spin"}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("p",{className:"text-slate-700 font-semibold text-base",children:"Loading lesson from DepEd curriculum..."}),e.jsx("p",{className:"text-slate-400 text-xs max-w-xs",children:"This may take a moment while the AI retrieves curriculum content."})]}),e.jsx("div",{className:"w-64 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-rose-300 rounded-full",animate:{x:["-100%","100%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"},style:{width:"50%"}})})]})}function gr({message:t,onRetry:a,isOffline:l}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-50 p-6",children:e.jsxs(v.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white rounded-3xl p-8 max-w-md w-full shadow-xl border border-slate-200 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-50 rounded-2xl flex items-center justify-center mx-auto mb-5",children:e.jsx(Ts,{className:"text-red-500",size:32})}),e.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:l?"Lesson Source Unavailable":"Failed to Load Lesson"}),e.jsx("p",{className:"text-slate-500 text-sm leading-relaxed mb-6",children:t}),e.jsxs(ze,{onClick:a,className:"w-full py-3 rounded-xl font-bold bg-rose-500 hover:bg-rose-600 text-white flex items-center justify-center gap-2",children:[e.jsx(Ps,{size:16}),"Try Again"]}),e.jsx("button",{onClick:a,className:"mt-3 text-slate-400 text-xs hover:text-slate-600 underline",children:"Retry"})]})})}function wr({section:t,sectionIndex:a,onShowSolution:l,expandedIndex:o,lesson:n,practiceQuiz:r,practiceQuizCompleted:i,practiceQuizScore:x,onStartPractice:p,lessonSpecificTopic:b,onTryItQuizComplete:g,onContinueLearning:M}){switch(t.type){case"introduction":return e.jsx("div",{className:"space-y-4",children:t.content?.trim()?e.jsx("p",{className:"text-slate-700 leading-relaxed text-base whitespace-pre-line",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Introduction content is being prepared. Please proceed to the next section or try refreshing the lesson."})});case"key_concepts":return e.jsxs("div",{className:"space-y-4",children:[t.content?.trim()?e.jsx("p",{className:"text-slate-700 leading-relaxed text-base whitespace-pre-line mb-4",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic mb-4",children:"Key concepts are being compiled. Review the curriculum sources below for reference material."}),t.callouts&&t.callouts.length>0&&e.jsx("div",{className:"space-y-2",children:t.callouts.map((z,d)=>e.jsxs("div",{className:`rounded-xl p-4 border-l-4 flex items-start gap-3 ${z.type==="important"?"bg-rose-50 border-rose-400":z.type==="tip"?"bg-emerald-50 border-emerald-400":"bg-amber-50 border-amber-400"}`,children:[e.jsx(Kt,{size:18,className:z.type==="important"?"text-rose-500 mt-0.5":z.type==="tip"?"text-emerald-500 mt-0.5":"text-amber-500 mt-0.5"}),e.jsx("p",{className:"text-sm text-slate-700",children:z.text})]},d))})]});case"video":return e.jsxs("div",{className:"space-y-4",children:[t.content?.trim()?e.jsx("p",{className:"text-slate-600 text-sm",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Video explanation loading..."}),e.jsx(cr,{videos:t.videos||[],topic:n.title})]});case"worked_examples":return e.jsx("div",{className:"space-y-4",children:t.examples&&t.examples.length>0?t.examples.map((z,d)=>e.jsxs("div",{className:"bg-gradient-to-br from-rose-50 to-orange-50 rounded-2xl p-5 border border-rose-100",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-8 h-8 bg-rose-500 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(mt,{size:16,className:"text-white"})}),e.jsx("p",{className:"font-semibold text-slate-800 text-sm pt-1",children:z.problem})]}),e.jsxs("div",{className:"space-y-1.5 ml-11",children:[z.steps.map((A,N)=>e.jsxs("p",{className:"text-slate-600 text-sm",children:[N+1,". ",A]},N)),z.answer&&e.jsxs("p",{className:"text-slate-800 text-sm font-semibold mt-2 pt-2 border-t border-rose-100",children:["Answer: ",z.answer]})]})]},d)):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"No worked examples available for this lesson."})});case"important_notes":return e.jsx("div",{className:"space-y-2",children:t.bulletPoints&&t.bulletPoints.length>0?t.bulletPoints.map((z,d)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-slate-50 border border-slate-100",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-rose-400 mt-2 flex-shrink-0"}),e.jsx("p",{className:"text-slate-700 text-sm leading-relaxed",children:z})]},d)):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"No notes available for this lesson."})});case"try_it_yourself":return e.jsxs("div",{className:"space-y-4",children:[r&&e.jsx("div",{className:"bg-white rounded-2xl p-5 border border-slate-200 shadow-sm",children:i?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-100 rounded-xl flex items-center justify-center",children:e.jsx(zt,{size:20,className:"text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-emerald-700",children:["Quiz Complete",typeof x=="number"&&e.jsxs("span",{className:"ml-2 text-emerald-600",children:[x,"%"]})]}),e.jsx("p",{className:"text-xs text-emerald-600/80",children:"Great job! You can now complete this lesson."})]})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm: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 bg-gradient-to-br from-rose-400 to-orange-400 rounded-xl flex items-center justify-center",children:e.jsx(Re,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:"Practice Quiz"}),e.jsxs("p",{className:"text-xs text-slate-500",children:[r.questions," questions · ",r.duration]})]})]}),e.jsxs("button",{onClick:p,className:"w-full sm:w-auto px-5 py-2.5 rounded-xl bg-gradient-to-r from-rose-500 to-orange-400 text-white text-sm font-bold hover:opacity-90 transition-opacity shadow-md flex items-center justify-center gap-2",children:[e.jsx(Hs,{size:16}),"Start Practice Quiz"]})]})}),e.jsx(dr,{lessonId:n.id?.toString()||"unknown",lessonTitle:n.title,topic:b||t.title||n.title,subjectId:n.subjectId,competencyCode:n.competencyCode,onComplete:(z,d)=>{},onQuizComplete:g,onClose:M,onContinueLearning:M})]});case"summary":return e.jsx("div",{className:"space-y-3",children:t.content?.trim()?e.jsx("p",{className:"text-slate-700 text-base leading-relaxed whitespace-pre-line",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Summary is being prepared. Review the lesson sections above to reinforce your understanding."})});default:return e.jsx("p",{className:"text-slate-500 text-sm italic",children:"Section content not available."})}}const kt=[{type:"introduction",label:"Intro",helper:"Welcome note",icon:ft,accent:"from-[#1a85a4] to-[#126b84]",tint:"bg-[#1a85a4] text-white border-transparent",tabBg:"bg-[#1a85a4]"},{type:"key_concepts",label:"Concepts",helper:"Core ideas",icon:Ra,accent:"from-[#fbab41] to-[#e0983a]",tint:"bg-[#fbab41] text-white border-transparent",tabBg:"bg-[#fbab41]"},{type:"video",label:"Video",helper:"Watch and learn",icon:Kt,accent:"from-[#e66a5e] to-[#ce5e53]",tint:"bg-[#e66a5e] text-white border-transparent",tabBg:"bg-[#e66a5e]"},{type:"worked_examples",label:"Examples",helper:"Guided solving",icon:Hs,accent:"from-[#7ec16d] to-[#71ad62]",tint:"bg-[#7ec16d] text-white border-transparent",tabBg:"bg-[#7ec16d]"},{type:"important_notes",label:"Notes",helper:"Key reminders",icon:Ba,accent:"from-[#9a67d0] to-[#8a5cc0]",tint:"bg-[#9a67d0] text-white border-transparent",tabBg:"bg-[#9a67d0]"},{type:"try_it_yourself",label:"Practice",helper:"Try it yourself",icon:Oe,accent:"from-[#eb74a6] to-[#d46895]",tint:"bg-[#eb74a6] text-white border-transparent",tabBg:"bg-[#eb74a6]"},{type:"summary",label:"Summary",helper:"Wrap-up",icon:Ft,accent:"from-[#48bca6] to-[#40a794]",tint:"bg-[#48bca6] text-white border-transparent",tabBg:"bg-[#48bca6]"}],yr=({lesson:t,lessonCompletionXP:a=10,practiceQuiz:l,practiceQuizCompleted:o=!1,practiceQuizScore:n,initialSection:r=0,onStartPractice:i,onBack:x,onComplete:p,onProgressUpdate:b,onTryItQuizComplete:g,onContinueLearning:M})=>{const{userProfile:z}=It(),[d,A]=s.useState(0),[N,_]=s.useState(1),[R,m]=s.useState(!1),[y,j]=s.useState(null),E={topic:t.title,subject:t.subject||"General Mathematics",quarter:t.quarter||1,lessonTitle:t.title,moduleId:t.subjectId,lessonId:t.id,competencyCode:t.competencyCode,learnerLevel:"Grade 11-12",storagePath:t.storagePath},{sections:k,isLoading:U,error:O,retry:Y,sources:$,retrievalBand:te,activeModel:de,isOffline:_e}=fr(t.id,E,!0),[re,W]=s.useState(null);s.useEffect(()=>{if(k.length>0){const f=k.find(T=>T.type==="introduction");if(f?.title){const F=f.title.replace(/^Introduction\s+(to|-|:|—)\s+/i,"").replace(/\s*[-:—]\s*Introduction$/i,"").replace(/\s+Introduction$/i,"").trim();F&&F.toLowerCase()!=="introduction"&&W(F)}}},[k]),s.useEffect(()=>{k.length>0&&z?.uid&&t.id&&ja(z.uid,t.id,re||t.title).catch(()=>{})},[k.length,z?.uid,t.id,re,t.title]);const Z=k.length||kt.length;if(s.useEffect(()=>{r>=0&&r{const f=k.findIndex(T=>T.type==="try_it_yourself");r===-1&&f>=0&&A(f)},[k,r]),s.useEffect(()=>{const f=Z>0?(d+1)/Z*100:0;b?.(f)},[d,Z,b]),U)return e.jsx(br,{});if(O&&k.length===0)return e.jsx(gr,{message:O,onRetry:Y,isOffline:_e});const ge=k[d]||{type:"introduction",title:"Loading...",content:"Lesson content is loading. Please wait a moment."},K=()=>{df+1)):(!l||o)&&m(!0)},we=()=>{d>0&&(_(-1),A(f=>f-1))},Me=f=>{p(void 0,void 0,f)},I=!!(l&&!o),u=kt[d]||kt[0],P=u.icon;return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-slate-50 overflow-hidden font-sans",children:[e.jsx("header",{className:"flex-none bg-transparent px-4 sm:px-8 py-6 relative z-40",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("button",{onClick:x,className:"w-10 h-10 rounded-full bg-white border border-slate-200 hover:bg-slate-50 flex items-center justify-center text-slate-600 transition-colors flex-shrink-0 shadow-sm","aria-label":"Go back",children:e.jsx(Ut,{size:18})}),e.jsxs("div",{className:"min-w-0 flex flex-col justify-center",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-slate-500 uppercase tracking-widest mb-0.5",children:[e.jsx(Je,{size:12}),e.jsx("span",{children:"NOTEBOOK LESSON"}),de&&e.jsx("span",{className:"text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded font-mono",children:de.split("/").pop()}),te==="high"&&e.jsx("span",{className:"text-emerald-600 bg-emerald-50 px-1.5 py-0.5 rounded text-[10px] font-semibold border border-emerald-200",children:"DepEd Source"})]}),e.jsx("h1",{className:"font-bold text-slate-800 text-sm truncate",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Progress"}),e.jsxs("p",{className:"text-sm font-bold text-slate-800",children:[Math.round((d+1)/Z*100),"%"]})]}),e.jsx("div",{className:"w-24 sm:w-32 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-[#7ec16d] rounded-full",animate:{width:`${(d+1)/Z*100}%`},transition:{duration:.25}})})]})]})}),e.jsx("main",{className:"flex-1 overflow-hidden px-4 sm:px-8 pb-8 relative flex justify-center",children:e.jsxs("div",{className:"w-full max-w-5xl h-full relative flex md:pl-16",children:[e.jsx("div",{className:"hidden md:flex absolute left-0 top-8 bottom-8 w-20 flex-col justify-between z-0 py-2",children:kt.map((f,T)=>{const F=T===d,ee=f.icon;return e.jsxs("button",{onClick:()=>{_(T>d?1:-1),A(T)},className:At("group relative flex items-center justify-start pl-4 rounded-l-[1.5rem] transition-all duration-300 shadow-sm border-r-0 flex-shrink-0",f.tabBg,F?"w-24 h-20 -translate-x-4 shadow-xl z-20 brightness-105":"w-16 h-16 hover:w-24 hover:h-20 hover:-translate-x-4 hover:brightness-110 opacity-90 hover:opacity-100 z-10"),"aria-label":`Go to ${f.label} section`,children:[e.jsx("div",{className:At("transition-all duration-300 rounded-xl",F?"bg-white/30 p-2.5":"bg-white/20 p-2 group-hover:bg-white/30 group-hover:p-2.5"),children:e.jsx(ee,{size:F?24:20,className:"text-white transition-transform duration-300 group-hover:scale-110"})}),e.jsxs("div",{className:"absolute right-full mr-3 px-3 py-1.5 bg-slate-800 text-white text-xs font-bold rounded-lg opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[100] shadow-xl border border-slate-700/50",children:[e.jsx("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 w-2 h-2 bg-slate-800 rotate-45 border-r border-t border-slate-700/50"}),f.label]})]},f.type)})}),e.jsxs("div",{className:At("flex-1 rounded-[2rem] shadow-2xl flex flex-col overflow-hidden relative z-10 transition-colors duration-500",u.tabBg),children:[e.jsxs("div",{className:"px-6 sm:px-8 py-5 flex items-center gap-4 text-white",children:[e.jsx("div",{className:"bg-white/20 p-2.5 rounded-xl shrink-0",children:e.jsx(P,{size:28,className:"text-white"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold truncate",title:ge.title,children:ge.title}),e.jsx("p",{className:"text-white/90 text-sm font-medium truncate mt-0.5",title:t.title,children:t.title})]})]}),e.jsxs("div",{className:"flex-1 bg-[#fdfdfd] rounded-[1.5rem] m-2 mt-0 relative overflow-hidden shadow-inner flex flex-col",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-30",style:{backgroundImage:"linear-gradient(transparent 95%, #cbd5e1 95%)",backgroundSize:"100% 40px",backgroundPosition:"0 0"}}),e.jsx("div",{className:"absolute top-0 bottom-0 left-12 md:left-16 w-[2px] bg-rose-300/60 pointer-events-none z-0"}),e.jsxs("div",{className:"relative z-10 flex-1 overflow-y-auto px-6 md:pl-24 md:pr-12 py-8",children:[e.jsx("div",{className:"md:hidden flex gap-2 overflow-x-auto pb-4 mb-4 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:kt.map((f,T)=>{const F=T===d,ee=f.icon;return e.jsx("button",{onClick:()=>{_(T>d?1:-1),A(T)},className:At("min-w-[100px] rounded-2xl px-3 py-2 text-left transition-all duration-200",F?`${f.tabBg} text-white shadow-md`:"bg-slate-100 text-slate-600 border border-slate-200"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:14}),e.jsx("span",{className:"text-xs font-bold",children:f.label})]})},f.type)})}),e.jsx($e,{mode:"wait",children:e.jsxs(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"space-y-6",children:[e.jsx("div",{className:"bg-white/90 backdrop-blur-sm rounded-[1.5rem] p-6 sm:p-8 shadow-sm border border-slate-100/50",children:e.jsx(wr,{section:ge,sectionIndex:d,onShowSolution:f=>j(y===f?null:f),expandedIndex:y,lesson:t,lessonSpecificTopic:re,onTryItQuizComplete:g,onContinueLearning:M})}),$.length>0&&(z?.role==="admin"||z?.role==="teacher")&&e.jsxs("details",{className:"rounded-xl border border-slate-200 bg-white/90 backdrop-blur-sm px-4 py-3 text-xs text-slate-500 shadow-sm",children:[e.jsxs("summary",{className:"cursor-pointer font-semibold text-slate-600 hover:text-slate-800",children:[$.length," source",$.length>1?"s":""," used"]}),e.jsx("div",{className:"mt-2 space-y-1 pl-2",children:$.slice(0,3).map((f,T)=>e.jsxs("p",{className:"font-mono truncate",children:[f.source_file," p.",f.page," (",Math.round((f.score||0)*100),"%)"]},T))})]})]},d)})]},d)]})]})]})}),e.jsx("footer",{className:"bg-transparent px-4 sm:px-8 flex-shrink-0 relative z-40 w-full flex justify-center items-center h-20",children:e.jsxs("div",{className:"w-full max-w-5xl flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-8 w-full md:ml-16",children:[e.jsxs(ze,{onClick:we,disabled:d===0,variant:"outline",className:"px-6 py-3 rounded-full font-bold text-sm bg-white border-slate-200 text-slate-600 shadow-sm disabled:opacity-40 hover:bg-slate-50 transition-colors flex items-center gap-2",children:[e.jsx(Ut,{size:16}),"Previous"]}),e.jsxs("p",{className:"text-sm text-slate-500 font-bold tabular-nums",children:[d+1," / ",Z]}),e.jsx(ze,{onClick:K,disabled:d===Z-1&&I,className:"px-8 py-3 rounded-full font-bold text-sm bg-[#7ec16d] text-white hover:bg-[#6ab359] shadow-md transition-colors disabled:opacity-40 flex items-center gap-2",children:d===Z-1?e.jsxs(e.Fragment,{children:["Complete",e.jsx(zt,{size:16})]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(pt,{size:16})]})})]}),d===Z-1&&I&&e.jsx("p",{className:"text-center text-xs font-semibold text-amber-600 mt-3 md:ml-16",children:"Complete the practice quiz first to unlock lesson completion."})]})}),e.jsx($e,{children:R&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-sm p-4",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-8 max-w-sm w-full text-center shadow-2xl",children:[e.jsx("div",{className:"w-20 h-20 bg-[#7ec16d] rounded-full flex items-center justify-center mx-auto mb-5 shadow-lg",children:e.jsx(zt,{size:40,className:"text-white"})}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-2",children:"Lesson Complete!"}),e.jsxs("p",{className:"text-slate-500 text-sm mb-6 leading-relaxed",children:["Great job finishing ",e.jsx("strong",{className:"text-slate-700",children:t.title}),"."]}),e.jsxs("div",{className:"bg-emerald-50 rounded-2xl p-4 mb-6 border border-emerald-100",children:[e.jsx("div",{className:"flex items-center justify-center mb-1",children:e.jsx(Ft,{className:"text-[#7ec16d]",size:22})}),e.jsx("p",{className:"text-xs text-[#7ec16d] font-bold uppercase tracking-wider mb-0.5",children:"XP Earned"}),e.jsxs("p",{className:"text-3xl font-black text-[#7ec16d]",children:["+",a]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("button",{onClick:()=>Me(!0),disabled:I,className:"w-full py-3 rounded-xl font-bold text-sm bg-[#1a85a4] text-white hover:bg-[#126b84] transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Continue to Next Lesson"}),e.jsx("button",{onClick:()=>Me(!1),className:"w-full py-3 rounded-xl font-bold text-sm bg-slate-100 text-slate-600 hover:bg-slate-200 transition-colors",children:"Back to Modules"})]})]})})})]})},jr=[{id:1,type:"multiple-choice",question:"What is the value of π (pi) to two decimal places?",options:["3.12","3.14","3.16","3.18"],correctAnswer:"3.14",explanation:"π ≈ 3.14159..., so to two decimal places it is 3.14."},{id:2,type:"true-false",question:"The sum of angles in a triangle is 180 degrees.",correctAnswer:"True",explanation:"The interior angles of any Euclidean triangle sum to 180°."},{id:3,type:"fill-in-blank",question:"If 2x + 5 = 13, then x = ___.",correctAnswer:"4",explanation:"2x = 13 - 5 = 8 → x = 4."},{id:4,type:"multiple-choice",question:"Which of the following is a prime number?",options:["9","15","17","21"],correctAnswer:"17",explanation:"17 is only divisible by 1 and itself. 9=3×3, 15=3×5, 21=3×7."},{id:5,type:"true-false",question:"The slope of a horizontal line is zero.",correctAnswer:"True",explanation:"A horizontal line has no rise, so rise/run = 0."},{id:6,type:"fill-in-blank",question:"The square root of 144 is ___.",correctAnswer:"12",explanation:"12 × 12 = 144, so √144 = 12."}];async function vr(t){const{lessonTitle:a,topic:l,subjectId:o,competencyCode:n,questionCount:r=6}=t,i=Nr(o)||"General Mathematics",x=t.lessonId?Math.abs(t.lessonId.split("").reduce((p,b)=>Math.imul(31,p)+b.charCodeAt(0)|0,0))%1e6:Math.floor(Math.random()*1e6);try{const p=await sa("/api/quiz/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:l||a,subject:i,lessonTitle:a,questionCount:r,questionTypes:["multiple-choice","true-false","fill-in-blank"],difficulty:"medium",competencyCode:n,varianceSeed:x})});return!p.questions||p.questions.length===0?(console.warn("[lessonQuizService] API returned empty questions, using fallback"),Ns(r)):p.questions.map(b=>({id:b.id,type:b.type,question:b.question,options:b.options||void 0,correctAnswer:b.correctAnswer,explanation:b.explanation}))}catch(p){return console.error("[lessonQuizService] Failed to generate quiz via API:",p),console.warn("[lessonQuizService] Using fallback questions"),Ns(r)}}function qs(t){return t==="quiz"?8:6}function Nr(t){if(!t)return null;const a=t.toLowerCase();return a.includes("gen-math")||a.includes("gen_math")?"General Mathematics":a.includes("stats")||a.includes("prob")?"Statistics and Probability":a.includes("pre-calc")||a.includes("pre_calc")?"Pre-Calculus":a.includes("basic-calc")||a.includes("basic_calc")||a.includes("calculus")?"Basic Calculus":null}function Ns(t){const a=[...jr].sort(()=>Math.random()-.5);return a.slice(0,Math.min(t,a.length)).map((l,o)=>({...l,id:o+1}))}const kr=Object.freeze(Object.defineProperty({__proto__:null,generateLessonQuiz:vr,getQuestionCountForQuiz:qs},Symbol.toStringTag,{value:"Module"})),Et={},Sr=(t,a)=>{if(Et[t]&&Et[t].length)return Et[t];const o=Array.from({length:8}).map((n,r)=>{const i=r+2,x=r+3,p=(i+x).toString();return{id:r+1,type:"multiple-choice",question:`Compute: ${i} + ${x}`,options:[p,(i*x).toString(),Math.abs(i-x).toString(),(i+x+1).toString()],correctAnswer:p,explanation:`Add ${i} and ${x} to get ${p}.`}});return Et[t]=o,o},Cr=({module:t,onBack:a,onEarnXP:l,isInQuizMode:o=!1,setIsInQuizMode:n})=>{const[i,x]=s.useState(null),{userProfile:p}=It(),[b,g]=s.useState(null),[M,z]=s.useState(!1);s.useEffect(()=>{if(!p?.uid)return;(async()=>{try{const[P,f]=await Promise.all([Ot(bt(We,"diagnosticResults",p.uid)),Ot(bt(We,"competencyProfiles",p.uid))]),T=P.exists()&&P.data()?.status==="completed",F=f.exists()&&(f.data()?.overallScore??0)>0;z(T||F)}catch{z(!1)}})()},[p?.uid]);const d=s.useRef(l);s.useEffect(()=>{d.current=l},[l]);const A=s.useRef(i);s.useEffect(()=>{A.current=i},[i]),s.useEffect(()=>{try{const u=sessionStorage.getItem(`mathpulse_module_${t.id}_selectedLesson`);if(u){const{lessonId:P}=JSON.parse(u),f=t.lessons.find(T=>T.id===P);f&&x({lesson:f,type:"lesson"})}}catch{}},[]),s.useEffect(()=>{if(i?.type==="lesson"&&i.lesson)try{sessionStorage.setItem(`mathpulse_module_${t.id}_selectedLesson`,JSON.stringify({lessonId:i.lesson.id}))}catch{}else if(i===null)try{sessionStorage.removeItem(`mathpulse_module_${t.id}_selectedLesson`)}catch{}},[i,t.id]);const N=s.useMemo(()=>{const u=Number(t.id.split("-").pop());return Number.isFinite(u)&&u>0?u:1},[t.id]),_=s.useMemo(()=>{const u=t.subjectId;return u||(Tt.find(f=>f.modules.some(T=>T.id===t.id))?.id??null)},[t.id]),R=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];s.useMemo(()=>{const u=t.subjectAccentColor;if(u)return u;const f=(_?Tt.find(F=>F.id===_):null)?.modules?.findIndex(F=>F.id===t.id)??0,T=f>=0?f:0;return R[T%R.length]},[t,t.id,_]),s.useEffect(()=>{if(p?.uid)return is(p.uid,g)},[p?.uid]);const m=s.useMemo(()=>_?b?.subjects?.[_]?.modulesProgress?.[t.id]??null:null,[t.id,_,b?.subjects]),[y,j]=s.useState(null),E=s.useMemo(()=>{const u=m?.lessonsCompleted??[];return new Set(u)},[m?.lessonsCompleted]),k=s.useMemo(()=>{const u=m?.quizzesCompleted??[];return new Set(u)},[m?.quizzesCompleted]),U=m?.lessonsCompleted?.length??t.lessons.filter(u=>u.completed).length,O=m?.quizzesCompleted?.length??t.quizzes.filter(u=>u.completed).length,Y=m?.progress??t.progress,$=t.lessons.length+t.quizzes.length,te=U+O;t.lessons.length&&U/t.lessons.length*100,t.quizzes.length&&O/t.quizzes.length*100;const de=(u,P)=>{const f=b?.lessons?.[u]?.score;return typeof f=="number"&&Number.isFinite(f)?Math.max(0,Math.min(100,f)):P?100:0},_e=s.useMemo(()=>{if(!$)return 0;const u=t.lessons.reduce((f,T)=>{const F=E.has(T.id)||T.completed;return f+de(T.id,F)},0),P=O*100;return Math.round((u+P)/$)},[E,O,t.lessons,t.quizzes.length,$,b?.lessons]),re=Y>0?Y:_e,W=s.useMemo(()=>{const u=t.quizzes.find(f=>f.type==="final"||/module\s+quiz|general\s+quiz/i.test(f.title));if(u)return u;const P=t.quizzes.find(f=>f.isStandalone===!0);return P||(t.quizzes.length?t.quizzes[0]:null)},[t.quizzes]),Z=s.useMemo(()=>{const u=new Map;t.lessons.forEach(f=>{u.set(f.id,[])});const P=t.lessons.length;return P===0||t.quizzes.forEach((f,T)=>{if(W?.id===f.id)return;const F=Math.min(T,P-1),ee=t.lessons[F];if(!ee)return;const ne=u.get(ee.id)??[];ne.push(f),u.set(ee.id,ne)}),u},[t.lessons,t.quizzes,W?.id]),ge=s.useMemo(()=>Math.max(1,Math.ceil(t.lessons.length/2)),[t.lessons.length]),K=s.useCallback(()=>{x(null),j(null)},[]),we=s.useCallback(()=>{const u=A.current?.type==="lesson"?A.current.lesson:null;if(!u)return;const P={id:`${u.id}-practice`,title:`Practice Quiz: ${u.title}`,questions:qs("practice"),duration:u.duration,completed:!1,locked:!1,type:"practice"};j(u),x({type:"quiz",quiz:P})},[]),Me=s.useCallback((u,P,f)=>{const T=A.current;if(T?.type!=="lesson"||!T.lesson)return;const F=T.lesson,ee=10;if(d.current?.(ee,`Completed "${F.title}"`),p?.uid&&_&&(async()=>{try{await aa(p.uid,_,t.id,F.id,0,ee),await os(p.uid,_,t.id,t.lessons.length,t.quizzes.length)}catch(ne){console.error("[LessonComplete] Failed to persist progress:",ne)}})(),f){const ne=t.lessons.findIndex(Be=>Be.id===F.id);ne!==-1&&ne0?x({type:"quiz",quiz:t.quizzes[0]}):x(null)}else x(null)},[_,t.id,t.lessons.length,t.quizzes.length]),I=s.useCallback(u=>{if(!p?.uid||!A.current||A.current.type!=="lesson")return;const P=A.current.lesson.id;(async()=>{try{await ra(p.uid,P,u)}catch(f){console.warn("[ModuleDetailView] Failed to persist lesson progress:",f)}})()},[p?.uid,t.id]);if(i)if(i.type==="lesson"){const u=Z.get(i.lesson.id)?.[0]??null,P=u?k.has(u.id)||u.completed:!1;return e.jsx(yr,{lesson:i.lesson,lessonCompletionXP:10,practiceQuiz:u,practiceQuizCompleted:P,initialSection:i.returnFromQuiz?-1:0,onBack:K,onStartPractice:we,onProgressUpdate:I,onComplete:Me})}else{const u=Sr(i.quiz.id);return e.jsx(ir,{lesson:{id:parseInt(i.quiz.id.split("-").pop()||"1"),title:i.quiz.title,duration:i.quiz.duration,type:"quiz",completed:i.quiz.completed,locked:i.quiz.locked},questions:u,onBack:()=>{y?(x({type:"lesson",lesson:y,returnFromQuiz:!0}),j(null)):x(null),n&&n(!1)},onComplete:(P,f)=>{p?.uid&&_&&(async()=>{try{await la(p.uid,_,t.id,i.quiz.id,P,[],0,f),await os(p.uid,_,t.id,t.lessons.length,t.quizzes.length),await is(p.uid,g)}catch(T){console.warn("[Quiz] Progress persist failed:",T)}l&&l(f??0,`Quiz Complete! +${f??0} XP`)})(),y?(x({type:"lesson",lesson:y,returnFromQuiz:!0}),j(null)):x(null),n&&n(!1)}})}return e.jsxs("div",{className:"h-full overflow-y-auto scrollbar-hide px-4 sm:px-6 xl:px-10 py-6 sm:py-8 relative",children:[e.jsx("div",{className:"relative mb-6 xl:mb-8 w-full sm:w-max",children:e.jsxs("button",{onClick:a,className:"flex items-center gap-2 px-4 py-2.5 rounded-full bg-white/80 backdrop-blur-xl border border-slate-200/60 text-slate-600 hover:text-indigo-600 font-bold text-sm tracking-wide transition-all hover:-translate-x-1 shadow-sm hover:shadow-md",children:[e.jsx(Ut,{size:18}),"Back"]})}),e.jsxs(v.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:`relative mb-6 lg:mb-8 rounded-[2rem] ${t.accentColor} shadow-[0_20px_40px_-15px_rgba(0,0,0,0.3)] shrink-0 overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-none z-0"}),e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none module-detail-grid-pattern"}),e.jsx("div",{className:"absolute top-0 right-0 w-[400px] h-[400px] bg-sky-500/20 blur-[100px] rounded-full pointer-events-none"}),e.jsxs("div",{className:"relative p-5 sm:p-7 md:p-10 flex flex-col md:flex-row md:items-center justify-between gap-6 md:gap-8",children:[e.jsxs("div",{className:"flex-1 text-white",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4 md:mb-5",children:[e.jsxs("div",{className:"px-3 py-1 bg-white/10 backdrop-blur-md rounded-full text-[11px] font-black uppercase tracking-widest text-[#f8fafc] border border-white/20 shadow-sm flex items-center gap-1.5",children:[e.jsx(us,{size:14})," Chapter ",t.id.split("-").pop()||"1"]}),e.jsxs("div",{className:"px-3 py-1 bg-white/10 backdrop-blur-md rounded-full text-[11px] font-black uppercase tracking-widest text-emerald-400 border border-emerald-400/30",children:["Lv ",N]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-display font-black text-white mb-3 md:mb-4 tracking-[-0.02em] leading-tight",children:t.title}),e.jsx("p",{className:"text-slate-300 text-sm md:text-[15px] max-w-2xl font-medium leading-relaxed mb-6 md:mb-8",children:t.description}),e.jsxs("div",{className:"bg-black/20 backdrop-blur-md rounded-2xl p-4 md:p-5 border border-white/10 max-w-xl",children:[e.jsxs("div",{className:"flex justify-between items-end mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ft,{size:20,className:"text-emerald-400"}),e.jsx("span",{className:"text-[12px] md:text-[13px] font-black text-white uppercase tracking-wider",children:"Module Mastery"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-[12px] md:text-[13px] font-bold text-slate-400 mb-0.5",children:[te,"/",$," steps"]}),e.jsxs("span",{className:"text-xl md:text-2xl font-black text-white shrink-0 leading-none",children:[Math.round(re),"%"]})]})]}),e.jsx("div",{className:"h-3 bg-black/40 rounded-full overflow-hidden shadow-inner ring-1 ring-white/10 p-0.5",children:e.jsx(v.div,{initial:{width:0},animate:{width:`${re}%`},transition:{duration:1.5,ease:"easeOut",delay:.2},className:`h-full rounded-full relative ${re===100?"bg-gradient-to-r from-emerald-400 to-teal-300":t.accentColor}`,children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4IiBoZWlnaHQ9IjgiPgo8cmVjdCB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMSI+PC9yZWN0Pgo8L3N2Zz4=')] opacity-30 mix-blend-overlay"})})})]})]}),e.jsxs("div",{className:"hidden lg:flex w-48 h-48 bg-white/5 rounded-[2rem] border border-white/10 backdrop-blur-md items-center justify-center transform rotate-[-3deg] shadow-2xl relative group hover:rotate-0 transition-all duration-500 shrink-0",children:[e.jsx("div",{className:`absolute inset-0 opacity-40 rounded-[2rem] ${t.progress===100?"bg-gradient-to-br from-emerald-400 to-teal-600":t.accentColor}`}),re===100?e.jsx(Ct,{size:80,className:"text-white drop-shadow-xl z-10 scale-100 group-hover:scale-110 transition-transform duration-500",strokeWidth:1}):e.jsx(Je,{size:80,className:"text-white drop-shadow-xl z-10 scale-100 group-hover:scale-110 transition-transform duration-500",strokeWidth:1}),e.jsx(v.div,{animate:{y:[-5,5,-5],rotate:[-10,10,-10]},transition:{duration:4,repeat:1/0},className:"absolute top-6 left-6 text-emerald-300 z-20",children:e.jsx(Es,{size:20,fill:"currentColor"})}),e.jsx(v.div,{animate:{y:[5,-5,5],rotate:[10,-10,10]},transition:{duration:3.5,repeat:1/0},className:"absolute bottom-8 right-6 text-sky-300 z-20",children:e.jsx(bs,{size:24})})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2 pb-8 scrollbar-hide",children:e.jsxs("div",{className:"relative rounded-[2rem] border border-slate-200 bg-white/90 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(153,86,222,0.08),transparent_45%),radial-gradient(circle_at_bottom_left,rgba(31,167,225,0.08),transparent_45%)]"}),e.jsxs("div",{className:"relative z-10 px-4 sm:px-6 md:px-8 py-5 md:py-6 border-b border-slate-200/70 bg-white/70 backdrop-blur-sm flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("h2",{className:"font-display font-black text-xl md:text-2xl text-slate-800 flex items-center gap-3",children:[e.jsx(Je,{size:24,className:"text-sky-500"}),"Study Journey"]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("div",{className:"text-xs md:text-sm font-bold bg-sky-100 text-sky-700 px-3 py-1 rounded-full shadow-sm border border-sky-200/50",children:["Lessons ",U,"/",t.lessons.length]}),e.jsxs("div",{className:"text-xs md:text-sm font-bold bg-rose-100 text-rose-700 px-3 py-1 rounded-full shadow-sm border border-rose-200/50",children:["Quizzes ",O,"/",t.quizzes.length]})]})]}),e.jsxs("div",{className:"relative z-10 px-4 sm:px-6 md:px-8 py-5 md:py-6 space-y-5",children:[t.lessons.map((u,P)=>{const f=E.has(u.id)||u.completed,T=de(u.id,f),F=R[P%R.length];return e.jsxs(Ae.Fragment,{children:[e.jsxs(v.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{delay:P*.05},className:`relative rounded-[1.5rem] border overflow-hidden group transition-all duration-500 mb-6 ${u.locked?"border-slate-200 opacity-65 saturate-50":"border-slate-200/80 hover:border-slate-300 hover:shadow-[0_16px_40px_-15px_rgba(0,0,0,0.12)] hover:-translate-y-0.5"}`,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[6px] z-20 bg-slate-100 overflow-hidden",children:e.jsx(v.div,{initial:{width:0},animate:{width:`${Math.max(2,T)}%`},transition:{duration:1.2,ease:"easeOut",delay:.1+P*.05},className:"h-full relative",style:{backgroundColor:F},children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4IiBoZWlnaHQ9IjgiPgo8cmVjdCB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMSI+PC9yZWN0Pgo8L3N2Zz4=')] opacity-30 mix-blend-overlay"})})}),e.jsx("div",{className:"absolute inset-0 bg-white transition-opacity duration-500 group-hover:opacity-90",style:{backgroundImage:`linear-gradient(to right, ${F}44 0%, ${F}11 50%, white 100%)`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.2] pointer-events-none",style:{backgroundImage:`radial-gradient(circle at 2px 2px, ${F} 1.5px, transparent 0)`,backgroundSize:"24px 24px"}}),e.jsx("div",{className:"absolute -top-12 -left-10 h-40 w-40 rounded-full blur-[32px] pointer-events-none transition-transform duration-700 group-hover:scale-[1.3] group-hover:translate-x-4",style:{backgroundColor:`${F}22`}}),e.jsx("div",{className:"absolute -bottom-8 right-8 h-32 w-32 rounded-full blur-2xl pointer-events-none transition-transform duration-700 group-hover:scale-125 group-hover:-translate-y-4",style:{backgroundColor:`${F}11`}}),e.jsx("div",{className:"absolute right-4 top-4 opacity-10 pointer-events-none transition-all duration-500 group-hover:rotate-12 group-hover:scale-110 drop-shadow-sm",style:{color:F},children:e.jsx(bs,{size:56,strokeWidth:1})}),e.jsx("div",{className:"absolute right-16 bottom-5 opacity-10 pointer-events-none transition-all duration-500 group-hover:-rotate-6 group-hover:-translate-y-2 drop-shadow-sm",style:{color:F},children:e.jsx(Je,{size:40,strokeWidth:1})}),e.jsxs("div",{className:"relative z-10 p-4 md:p-5 pt-6 space-y-4",children:[e.jsxs("button",{type:"button",onClick:()=>!u.locked&&x({lesson:u,type:"lesson"}),className:`w-full text-left flex flex-wrap items-center justify-between gap-3 rounded-2xl px-5 py-4 transition shadow-sm ${u.locked?"cursor-not-allowed border border-slate-200 bg-white/70":"cursor-pointer bg-white hover:bg-slate-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center shrink-0 transition-colors shadow-sm ${u.locked?"bg-slate-100 text-slate-400":"text-white"}`,style:u.locked?{}:f?{backgroundColor:"#0ea5e9"}:{backgroundColor:F},children:u.locked?e.jsx(Vt,{size:18}):f?e.jsx(va,{size:24}):e.jsx(Bs,{size:20,className:"ml-0.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] md:text-[12px] font-black uppercase tracking-wider text-slate-500 mb-0.5",children:["Lesson ",P+1]}),e.jsx("h3",{className:"font-bold text-[16px] md:text-[18px] text-[#0a1628] truncate",children:u.title})]})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-slate-500 text-xs md:text-sm font-semibold bg-slate-100/80 px-3 py-1.5 rounded-xl",children:[e.jsx(ft,{size:14}),u.duration]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 px-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-full bg-white px-4 py-1.5 text-[12px] font-bold shadow-sm transition hover:-translate-y-0.5",style:{color:F},children:[e.jsx(Je,{size:14})," Study Materials"]}),e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-full bg-white px-4 py-1.5 text-[12px] font-bold shadow-sm transition hover:-translate-y-0.5",style:{color:F},children:[e.jsx(us,{size:14})," Quiz"]})]})]})]}),W&&P===ge-1&&e.jsxs(v.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15+P*.03},className:"mt-8 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-xs font-bold text-indigo-400 uppercase tracking-widest text-center",children:"mid-module checkpoint"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsxs("div",{className:"relative rounded-[1.5rem] bg-[#533ab6] p-5 shadow-lg overflow-hidden group transition-all hover:shadow-xl hover:-translate-y-1",children:[e.jsx("div",{className:"absolute right-4 md:right-10 top-1/2 -translate-y-1/2 text-white/5 text-[140px] font-black font-display pointer-events-none group-hover:scale-110 transition-transform duration-500",children:"?"}),e.jsxs("div",{className:"relative z-10 flex flex-wrap items-center gap-4 md:gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-[14px] bg-white/10 backdrop-blur-md border border-white/10 shrink-0 flex items-center justify-center shadow-inner",children:e.jsx(Oe,{size:28,className:"text-rose-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] md:text-[11px] font-black uppercase tracking-widest text-[#a3b1ee] mb-1 drop-shadow-sm",children:"COMPETENCY CHECK · General Quiz"}),e.jsx("h3",{className:"font-display font-medium text-[20px] md:text-[22px] text-white leading-tight mb-2 tracking-tight",children:W.title}),e.jsxs("p",{className:"text-xs font-semibold text-white/80 flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{size:12})," ",W.questions," Qs"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",W.duration]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-300 drop-shadow-md",children:[e.jsx(Re,{size:12,className:"fill-amber-300"})," +50 XP"]})]})]}),e.jsx("button",{type:"button",onClick:()=>!W.locked&&(x({quiz:W,type:"quiz"}),n&&n(!0)),className:`px-6 py-2.5 rounded-xl text-xs md:text-sm font-bold tracking-wider transition-all backdrop-blur-sm self-center shrink-0 ${W.locked?"bg-white/5 text-white/30 border border-white/10 cursor-not-allowed":M&&(k.has(W.id)||W.completed)?"bg-white/20 text-white border border-white/40 hover:bg-white/30 shadow-sm":"bg-transparent text-white border border-white/40 hover:bg-white/10 shadow-sm"}`,children:M&&(k.has(W.id)||W.completed)?"REVIEW":"START"})]})]})]})]},u.id)}),t.lessons.length===0&&W&&e.jsxs("div",{className:"relative rounded-[1.5rem] bg-[#533ab6] p-5 shadow-lg overflow-hidden group",children:[e.jsx("div",{className:"absolute right-4 md:right-10 top-1/2 -translate-y-1/2 text-white/5 text-[140px] font-black font-display pointer-events-none group-hover:scale-110 transition-transform duration-500",children:"?"}),e.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-between gap-4 md:gap-5",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e.jsx("div",{className:"w-14 h-14 rounded-[14px] bg-white/10 backdrop-blur-md border border-white/10 shrink-0 flex items-center justify-center shadow-inner",children:e.jsx(Oe,{size:28,className:"text-rose-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] md:text-[11px] font-black uppercase tracking-widest text-[#a3b1ee] mb-1 drop-shadow-sm",children:"COMPETENCY CHECK · General Quiz"}),e.jsx("h3",{className:"font-display font-medium text-[20px] md:text-[22px] text-white leading-tight mb-2 tracking-tight",children:W.title}),e.jsxs("p",{className:"text-xs font-semibold text-white/80 flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{size:12})," ",W.questions," Qs"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",W.duration]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-300 drop-shadow-md",children:[e.jsx(Re,{size:12,className:"fill-amber-300"})," +50 XP"]})]})]})]}),e.jsx("button",{type:"button",onClick:()=>!W.locked&&(x({quiz:W,type:"quiz"}),n&&n(!0)),className:`px-6 py-2.5 rounded-xl text-xs md:text-sm font-bold tracking-wider transition-all backdrop-blur-sm self-center shrink-0 ${W.locked?"bg-white/5 text-white/30 border border-white/10 cursor-not-allowed":M&&(k.has(W.id)||W.completed)?"bg-white/20 text-white border border-white/40 hover:bg-white/30 shadow-sm":"bg-transparent text-white border border-white/40 hover:bg-white/10 shadow-sm"}`,children:M&&(k.has(W.id)||W.completed)?"REVIEW":"START"})]})]})]})]})})]})},zr=({onStartQuiz:t,searchQuery:a="",allowedSubjectIds:l})=>{const{userProfile:o}=It(),[n,r]=s.useState("all"),[i,x]=s.useState("all"),[p,b]=s.useState(null),g=s.useMemo(()=>!l||l.length===0?Tt:Tt.filter(m=>l.includes(m.id)),[l]);s.useEffect(()=>{o?.uid&&na(o.uid).then(b).catch(console.error)},[o?.uid]),s.useEffect(()=>{if(i==="all")return;g.some(y=>y.title===i)||x("all")},[g,i]);const M=p?.totalQuizzesCompleted||0,z=o?.totalXP||0,d=p?.averageScore?Math.round(p.averageScore):0,A=new Set(p?.quizAttempts?.map(m=>m.quizId)||[]),N={};if(p?.quizAttempts)for(const m of p.quizAttempts)(!N[m.quizId]||m.score>N[m.quizId])&&(N[m.quizId]=m.score);const R=g.flatMap(m=>m.modules.flatMap(y=>y.quizzes.map(j=>({id:j.id,title:j.title,subject:m.title,difficulty:j.type==="module"?"Medium":"Easy",questions:j.questions,duration:j.duration,xpReward:j.questions*5,type:j.type==="module"?"challenge":"practice",completed:A.has(j.id),bestScore:N[j.id],locked:j.locked})))).filter(m=>{const y=n==="all"||m.type===n,j=i==="all"||m.subject===i,E=!a||m.title.toLowerCase().includes(a.toLowerCase())||m.subject.toLowerCase().includes(a.toLowerCase());return y&&j&&E});return e.jsxs("div",{className:"px-4 sm:px-6 xl:px-10 py-4 sm:py-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-sky-700 to-sky-500 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Ft,{size:24})}),e.jsx("span",{className:"text-3xl font-bold",children:M})]}),e.jsx("p",{className:"text-sm font-medium text-sky-100",children:"Quizzes Completed"})]}),e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-rose-500 to-rose-600 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Re,{size:24})}),e.jsx("span",{className:"text-3xl font-bold",children:z.toLocaleString()})]}),e.jsx("p",{className:"text-sm font-medium text-cyan-100",children:"Total XP Earned"})]}),e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-indigo-600 to-indigo-700 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Oe,{size:24})}),e.jsxs("span",{className:"text-3xl font-bold",children:[d,"%"]})]}),e.jsx("p",{className:"text-sm font-medium text-sky-100",children:"Average Score"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white rounded-xl p-1 shadow-sm",children:[e.jsx("button",{onClick:()=>r("all"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="all"?"bg-sky-600 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"All"}),e.jsx("button",{onClick:()=>r("practice"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="practice"?"bg-sky-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Practice"}),e.jsx("button",{onClick:()=>r("challenge"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="challenge"?"bg-orange-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Challenge"}),e.jsx("button",{onClick:()=>r("mastery"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="mastery"?"bg-sky-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Mastery"})]}),e.jsxs("select",{value:i,onChange:m=>x(m.target.value),className:"px-4 py-2.5 bg-white border-2 border-[#dde3eb] rounded-xl text-sm font-bold text-[#0a1628] focus:border-indigo-600 focus:outline-none",children:[e.jsx("option",{value:"all",children:"All Subjects"}),g.map(m=>e.jsx("option",{value:m.title,children:m.title},m.id))]})]}),e.jsxs("div",{className:"pr-2 pb-4 rounded-[2rem] border border-slate-200 shadow-inner relative",style:{backgroundImage:"radial-gradient(#CBD5E1 1px, transparent 1px)",backgroundSize:"24px 24px",backgroundPosition:"-12px -12px",backgroundColor:"#FAFAFA"},children:[e.jsx("div",{className:"absolute left-12 top-0 bottom-0 w-0.5 bg-rose-200/60 pointer-events-none z-0"}),e.jsx("div",{className:"absolute left-[54px] top-0 bottom-0 w-px bg-rose-100/40 pointer-events-none z-0"}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-5 p-4 md:p-6 relative z-10",children:R.map((m,y)=>{const j=m.locked,E=m.difficulty==="Hard",k=m.type==="challenge";return e.jsx(v.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:y*.05},onClick:()=>!j&&t?.(m),className:`bg-white/90 backdrop-blur-sm rounded-2xl p-4 md:p-5 border-2 relative select-none transition-all duration-300 ${j?"border-slate-200 opacity-60 saturate-50 cursor-not-allowed":m.completed?"border-teal-200 shadow-sm hover:border-teal-300 hover:shadow-md cursor-pointer":E?"border-indigo-200 shadow-sm hover:border-indigo-300 hover:shadow-md cursor-pointer":"border-orange-200 shadow-sm hover:border-orange-300 hover:shadow-md cursor-pointer"} group`,children:e.jsxs("div",{className:"flex items-center justify-between gap-3 md:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 md:gap-4 flex-1",children:[e.jsx("div",{className:`w-10 h-10 md:w-12 md:h-12 rounded-xl flex items-center justify-center shrink-0 shadow-sm transform group-hover:rotate-3 transition-transform ${j?"bg-slate-100 text-slate-400":m.completed?"bg-teal-500 text-white":E?"bg-indigo-500 text-white":"bg-orange-500 text-white"}`,children:j?e.jsx(Vt,{size:18}):m.completed?e.jsx(Ct,{size:18}):e.jsx(Xt,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded-[6px] text-[9px] md:text-[10px] font-black uppercase tracking-wider ${E?"bg-indigo-100 text-indigo-700":k?"bg-orange-100 text-orange-700":"bg-sky-100 text-sky-700"}`,children:[m.type," ΓÇó ",m.difficulty]}),!j&&!m.completed&&e.jsx("span",{className:"w-1.5 h-1.5 md:w-2 md:h-2 rounded-full bg-rose-500 animate-pulse"})]}),e.jsx("h3",{className:`font-bold text-[14px] md:text-[16px] leading-tight mb-1 md:mb-1.5 transition-colors ${j?"text-slate-600":"text-[#0a1628]"}`,children:m.title}),e.jsx("p",{className:"text-[11px] md:text-[12px] text-slate-500 mb-1.5 line-clamp-1",children:m.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:gap-3 text-[11px] md:text-[12px] font-bold text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Je,{size:12})," ",m.questions," Qs"]}),e.jsx("span",{className:"hidden sm:inline",children:"ΓÇó"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",m.duration]}),e.jsx("span",{className:"hidden sm:inline",children:"ΓÇó"}),e.jsxs("span",{className:"flex items-center gap-1 text-rose-500",children:[e.jsx(Ct,{size:12})," +",m.xpReward," XP"]})]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2 shrink-0",children:[m.bestScore!==void 0&&e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:`text-xl md:text-2xl font-black leading-none ${m.bestScore>=80?"text-teal-600":"text-orange-500"}`,children:[m.bestScore,"%"]}),e.jsx("div",{className:"text-[9px] uppercase tracking-wide text-slate-400 font-bold mt-1",children:"Best Score"})]}),!j&&e.jsx("div",{className:`px-3 py-1.5 md:px-4 md:py-2 rounded-xl text-[11px] md:text-[12px] font-black uppercase tracking-wider shadow-sm transition-all ${m.completed?"bg-white border border-slate-200 text-slate-600 group-hover:bg-slate-50":"bg-slate-900 text-white group-hover:bg-slate-600"}`,children:m.completed?"Review":"Start"})]})]})},m.id)})}),R.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-slate-500 relative z-10",children:[e.jsx(Oe,{size:48,className:"mb-3"}),e.jsx("p",{className:"font-medium",children:"No quizzes found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters or search query"})]})]})]})},_r=` + `,children:[e.jsx(Yt,{size:18}),"Previous"]}),e.jsxs("button",{onClick:Z,className:"flex items-center gap-1 px-6 py-2.5 bg-rose-500 text-white rounded-xl font-bold text-sm hover:bg-rose-600 transition-colors shadow-md",children:[Me?"Finish":"Next",e.jsx(ht,{size:18})]})]})]}),Y&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-3xl p-8 max-w-sm w-full text-center shadow-2xl",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-rose-400 to-orange-400 flex items-center justify-center mx-auto mb-5",children:e.jsx(Ct,{className:"text-white",size:40})}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-2",children:"Quiz Complete!"}),e.jsxs("p",{className:"text-slate-500 text-sm mb-6",children:["You got ",e.jsx("span",{className:"font-bold text-rose-500",children:_e})," out of ",e.jsx("span",{className:"font-bold",children:b.length})," correct"]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"w-full h-4 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-rose-400 to-orange-400 rounded-full transition-all duration-1000",style:{width:`${_e/b.length*100}%`}})})}),e.jsx("button",{onClick:()=>{$(!1),x?.(),p?.()},className:"w-full py-3 bg-rose-500 text-white rounded-xl font-bold hover:bg-rose-600 transition-colors",children:"Continue Learning"})]})})]})},ur="https://deign86-mathpulse-api-v3test.hf.space";async function Qs(t,a,l=!1){const o={"Content-Type":"application/json",...a?.headers||{}},n=sa.currentUser;if(n)try{const i=await n.getIdToken(l);i&&(o.Authorization=`Bearer ${i}`)}catch(i){throw console.error("[lessonService] Failed to get Firebase ID token:",i),new Error("Authentication failed. Please sign in again.")}const r=await fetch(`${ur}${t}`,{...a,headers:o});if(r.status===401&&n&&!l)return Qs(t,a,!0);if(!r.ok){let i;try{i=await r.json()}catch{i=await r.text()}const x=new Error(typeof i=="object"?JSON.stringify(i):i);throw x.status=r.status,x.body=i,x}return r.json()}async function pr(t){return Qs("/api/rag/lesson",{method:"POST",body:JSON.stringify(t)})}const hr="rag_lesson_";function as(t){return`${hr}${t}`}function fr(t){try{const a=sessionStorage.getItem(as(t));if(a)return JSON.parse(a)}catch{}return null}function br(t,a){try{sessionStorage.setItem(as(t),JSON.stringify(a))}catch{}}function gr(t,a,l=!0){const[o,n]=s.useState([]),[r,i]=s.useState(!0),[x,p]=s.useState(null),[b,g]=s.useState([]),[M,z]=s.useState("low"),[d,A]=s.useState(0),[N,_]=s.useState(!1),[R,m]=s.useState(void 0),[y,j]=s.useState(!1),E=s.useCallback(async()=>{if(!l||!t)return;const U=fr(t);if(U){n(U.sections),g(U.sources),z(U.retrievalBand),A(U.retrievalConfidence),_(U.needsReview),m(U.activeModel),i(!1),p(null),j(!1);return}i(!0),p(null),j(!1);try{const Y=(await Lt(()=>import("./vendor-firebase-auth-Bcpr4O6E.js"),__vite__mapDeps([0,1])).then(te=>te.getAuth().currentUser))?.uid,$=await pr({...a,lessonId:t,userId:Y});n($.sections),g($.sources||[]),z($.retrievalBand),A($.retrievalConfidence),_($.needsReview),m($.activeModel),br(t,$),p(null),j(!1)}catch(O){const Y=O.status||O.response?.status,$=O.body||O.response;let te="Failed to load lesson content.",xe=!1;Y===404&&$?.error==="no_curriculum_context"?(te=$.message||"Lesson source PDF not found or not yet ingested.",xe=!0):Y===401?te="Please sign in again to access lessons.":navigator.onLine||(te="No internet connection. Please try again when online.",xe=!0),p(te),j(xe),n([])}finally{i(!1)}},[t,l,JSON.stringify(a)]);s.useEffect(()=>{E()},[E]);const k=s.useCallback(()=>{t&&sessionStorage.removeItem(as(t)),i(!0),p(null),E()},[E,t]);return{sections:o,isLoading:r,error:x,retry:k,sources:b,retrievalBand:M,retrievalConfidence:d,needsReview:N,activeModel:R,isOffline:y}}function wr(){return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-slate-50 gap-5",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border-4 border-rose-400 border-t-transparent animate-spin"}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("p",{className:"text-slate-700 font-semibold text-base",children:"Loading lesson from DepEd curriculum..."}),e.jsx("p",{className:"text-slate-400 text-xs max-w-xs",children:"This may take a moment while the AI retrieves curriculum content."})]}),e.jsx("div",{className:"w-64 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-rose-300 rounded-full",animate:{x:["-100%","100%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"},style:{width:"50%"}})})]})}function yr({message:t,onRetry:a,isOffline:l}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-50 p-6",children:e.jsxs(v.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white rounded-3xl p-8 max-w-md w-full shadow-xl border border-slate-200 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-50 rounded-2xl flex items-center justify-center mx-auto mb-5",children:e.jsx(Ls,{className:"text-red-500",size:32})}),e.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:l?"Lesson Source Unavailable":"Failed to Load Lesson"}),e.jsx("p",{className:"text-slate-500 text-sm leading-relaxed mb-6",children:t}),e.jsxs(ze,{onClick:a,className:"w-full py-3 rounded-xl font-bold bg-rose-500 hover:bg-rose-600 text-white flex items-center justify-center gap-2",children:[e.jsx(Ts,{size:16}),"Try Again"]}),e.jsx("button",{onClick:a,className:"mt-3 text-slate-400 text-xs hover:text-slate-600 underline",children:"Retry"})]})})}function jr({section:t,sectionIndex:a,onShowSolution:l,expandedIndex:o,lesson:n,practiceQuiz:r,practiceQuizCompleted:i,practiceQuizScore:x,onStartPractice:p,lessonSpecificTopic:b,onTryItQuizComplete:g,onContinueLearning:M}){switch(t.type){case"introduction":return e.jsx("div",{className:"space-y-4",children:t.content?.trim()?e.jsx("p",{className:"text-slate-700 leading-relaxed text-base whitespace-pre-line",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Introduction content is being prepared. Please proceed to the next section or try refreshing the lesson."})});case"key_concepts":return e.jsxs("div",{className:"space-y-4",children:[t.content?.trim()?e.jsx("p",{className:"text-slate-700 leading-relaxed text-base whitespace-pre-line mb-4",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic mb-4",children:"Key concepts are being compiled. Review the curriculum sources below for reference material."}),t.callouts&&t.callouts.length>0&&e.jsx("div",{className:"space-y-2",children:t.callouts.map((z,d)=>e.jsxs("div",{className:`rounded-xl p-4 border-l-4 flex items-start gap-3 ${z.type==="important"?"bg-rose-50 border-rose-400":z.type==="tip"?"bg-emerald-50 border-emerald-400":"bg-amber-50 border-amber-400"}`,children:[e.jsx(Kt,{size:18,className:z.type==="important"?"text-rose-500 mt-0.5":z.type==="tip"?"text-emerald-500 mt-0.5":"text-amber-500 mt-0.5"}),e.jsx("p",{className:"text-sm text-slate-700",children:z.text})]},d))})]});case"video":return e.jsxs("div",{className:"space-y-4",children:[t.content?.trim()?e.jsx("p",{className:"text-slate-600 text-sm",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Video explanation loading..."}),e.jsx(xr,{videos:t.videos||[],topic:n.title})]});case"worked_examples":return e.jsx("div",{className:"space-y-4",children:t.examples&&t.examples.length>0?t.examples.map((z,d)=>e.jsxs("div",{className:"bg-gradient-to-br from-rose-50 to-orange-50 rounded-2xl p-5 border border-rose-100",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-8 h-8 bg-rose-500 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(mt,{size:16,className:"text-white"})}),e.jsx("p",{className:"font-semibold text-slate-800 text-sm pt-1",children:z.problem})]}),e.jsxs("div",{className:"space-y-1.5 ml-11",children:[z.steps.map((A,N)=>e.jsxs("p",{className:"text-slate-600 text-sm",children:[N+1,". ",A]},N)),z.answer&&e.jsxs("p",{className:"text-slate-800 text-sm font-semibold mt-2 pt-2 border-t border-rose-100",children:["Answer: ",z.answer]})]})]},d)):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"No worked examples available for this lesson."})});case"important_notes":return e.jsx("div",{className:"space-y-2",children:t.bulletPoints&&t.bulletPoints.length>0?t.bulletPoints.map((z,d)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-slate-50 border border-slate-100",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-rose-400 mt-2 flex-shrink-0"}),e.jsx("p",{className:"text-slate-700 text-sm leading-relaxed",children:z})]},d)):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"No notes available for this lesson."})});case"try_it_yourself":return e.jsxs("div",{className:"space-y-4",children:[r&&e.jsx("div",{className:"bg-white rounded-2xl p-5 border border-slate-200 shadow-sm",children:i?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-100 rounded-xl flex items-center justify-center",children:e.jsx(zt,{size:20,className:"text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-emerald-700",children:["Quiz Complete",typeof x=="number"&&e.jsxs("span",{className:"ml-2 text-emerald-600",children:[x,"%"]})]}),e.jsx("p",{className:"text-xs text-emerald-600/80",children:"Great job! You can now complete this lesson."})]})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm: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 bg-gradient-to-br from-rose-400 to-orange-400 rounded-xl flex items-center justify-center",children:e.jsx(Re,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:"Practice Quiz"}),e.jsxs("p",{className:"text-xs text-slate-500",children:[r.questions," questions · ",r.duration]})]})]}),e.jsxs("button",{onClick:p,className:"w-full sm:w-auto px-5 py-2.5 rounded-xl bg-gradient-to-r from-rose-500 to-orange-400 text-white text-sm font-bold hover:opacity-90 transition-opacity shadow-md flex items-center justify-center gap-2",children:[e.jsx(Hs,{size:16}),"Start Practice Quiz"]})]})}),e.jsx(mr,{lessonId:n.id?.toString()||"unknown",lessonTitle:n.title,topic:b||t.title||n.title,subjectId:n.subjectId,competencyCode:n.competencyCode,onComplete:(z,d)=>{},onQuizComplete:g,onClose:M,onContinueLearning:M})]});case"summary":return e.jsx("div",{className:"space-y-3",children:t.content?.trim()?e.jsx("p",{className:"text-slate-700 text-base leading-relaxed whitespace-pre-line",children:t.content}):e.jsx("p",{className:"text-slate-400 text-sm italic",children:"Summary is being prepared. Review the lesson sections above to reinforce your understanding."})});default:return e.jsx("p",{className:"text-slate-500 text-sm italic",children:"Section content not available."})}}const kt=[{type:"introduction",label:"Intro",helper:"Welcome note",icon:ft,accent:"from-[#1a85a4] to-[#126b84]",tint:"bg-[#1a85a4] text-white border-transparent",tabBg:"bg-[#1a85a4]"},{type:"key_concepts",label:"Concepts",helper:"Core ideas",icon:$a,accent:"from-[#fbab41] to-[#e0983a]",tint:"bg-[#fbab41] text-white border-transparent",tabBg:"bg-[#fbab41]"},{type:"video",label:"Video",helper:"Watch and learn",icon:Kt,accent:"from-[#e66a5e] to-[#ce5e53]",tint:"bg-[#e66a5e] text-white border-transparent",tabBg:"bg-[#e66a5e]"},{type:"worked_examples",label:"Examples",helper:"Guided solving",icon:Hs,accent:"from-[#7ec16d] to-[#71ad62]",tint:"bg-[#7ec16d] text-white border-transparent",tabBg:"bg-[#7ec16d]"},{type:"important_notes",label:"Notes",helper:"Key reminders",icon:Qa,accent:"from-[#9a67d0] to-[#8a5cc0]",tint:"bg-[#9a67d0] text-white border-transparent",tabBg:"bg-[#9a67d0]"},{type:"try_it_yourself",label:"Practice",helper:"Try it yourself",icon:Oe,accent:"from-[#eb74a6] to-[#d46895]",tint:"bg-[#eb74a6] text-white border-transparent",tabBg:"bg-[#eb74a6]"},{type:"summary",label:"Summary",helper:"Wrap-up",icon:Ft,accent:"from-[#48bca6] to-[#40a794]",tint:"bg-[#48bca6] text-white border-transparent",tabBg:"bg-[#48bca6]"}],vr=({lesson:t,lessonCompletionXP:a=10,practiceQuiz:l,practiceQuizCompleted:o=!1,practiceQuizScore:n,initialSection:r=0,onStartPractice:i,onBack:x,onComplete:p,onProgressUpdate:b,onTryItQuizComplete:g,onContinueLearning:M})=>{const{userProfile:z}=It(),[d,A]=s.useState(0),[N,_]=s.useState(1),[R,m]=s.useState(!1),[y,j]=s.useState(null),E={topic:t.title,subject:t.subject||"General Mathematics",quarter:t.quarter||1,lessonTitle:t.title,moduleId:t.subjectId,lessonId:t.id,competencyCode:t.competencyCode,learnerLevel:"Grade 11-12",storagePath:t.storagePath},{sections:k,isLoading:U,error:O,retry:Y,sources:$,retrievalBand:te,activeModel:xe,isOffline:_e}=gr(t.id,E,!0),[re,W]=s.useState(null);s.useEffect(()=>{if(k.length>0){const f=k.find(T=>T.type==="introduction");if(f?.title){const F=f.title.replace(/^Introduction\s+(to|-|:|—)\s+/i,"").replace(/\s*[-:—]\s*Introduction$/i,"").replace(/\s+Introduction$/i,"").trim();F&&F.toLowerCase()!=="introduction"&&W(F)}}},[k]),s.useEffect(()=>{k.length>0&&z?.uid&&t.id&&ya(z.uid,t.id,re||t.title).catch(()=>{})},[k.length,z?.uid,t.id,re,t.title]);const Z=k.length||kt.length;if(s.useEffect(()=>{r>=0&&r{const f=k.findIndex(T=>T.type==="try_it_yourself");r===-1&&f>=0&&A(f)},[k,r]),s.useEffect(()=>{const f=Z>0?(d+1)/Z*100:0;b?.(f)},[d,Z,b]),U)return e.jsx(wr,{});if(O&&k.length===0)return e.jsx(yr,{message:O,onRetry:Y,isOffline:_e});const ge=k[d]||{type:"introduction",title:"Loading...",content:"Lesson content is loading. Please wait a moment."},K=()=>{df+1)):(!l||o)&&m(!0)},we=()=>{d>0&&(_(-1),A(f=>f-1))},Me=f=>{p(void 0,void 0,f)},I=!!(l&&!o),u=kt[d]||kt[0],P=u.icon;return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-slate-50 overflow-hidden font-sans",children:[e.jsx("header",{className:"flex-none bg-transparent px-4 sm:px-8 py-6 relative z-40",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("button",{onClick:x,className:"w-10 h-10 rounded-full bg-white border border-slate-200 hover:bg-slate-50 flex items-center justify-center text-slate-600 transition-colors flex-shrink-0 shadow-sm","aria-label":"Go back",children:e.jsx(Ot,{size:18})}),e.jsxs("div",{className:"min-w-0 flex flex-col justify-center",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-slate-500 uppercase tracking-widest mb-0.5",children:[e.jsx(Je,{size:12}),e.jsx("span",{children:"NOTEBOOK LESSON"}),xe&&e.jsx("span",{className:"text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded font-mono",children:xe.split("/").pop()}),te==="high"&&e.jsx("span",{className:"text-emerald-600 bg-emerald-50 px-1.5 py-0.5 rounded text-[10px] font-semibold border border-emerald-200",children:"DepEd Source"})]}),e.jsx("h1",{className:"font-bold text-slate-800 text-sm truncate",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Progress"}),e.jsxs("p",{className:"text-sm font-bold text-slate-800",children:[Math.round((d+1)/Z*100),"%"]})]}),e.jsx("div",{className:"w-24 sm:w-32 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx(v.div,{className:"h-full bg-[#7ec16d] rounded-full",animate:{width:`${(d+1)/Z*100}%`},transition:{duration:.25}})})]})]})}),e.jsx("main",{className:"flex-1 overflow-hidden px-4 sm:px-8 pb-8 relative flex justify-center",children:e.jsxs("div",{className:"w-full max-w-5xl h-full relative flex md:pl-16",children:[e.jsx("div",{className:"hidden md:flex absolute left-0 top-8 bottom-8 w-20 flex-col justify-between z-0 py-2",children:kt.map((f,T)=>{const F=T===d,ee=f.icon;return e.jsxs("button",{onClick:()=>{_(T>d?1:-1),A(T)},className:At("group relative flex items-center justify-start pl-4 rounded-l-[1.5rem] transition-all duration-300 shadow-sm border-r-0 flex-shrink-0",f.tabBg,F?"w-24 h-20 -translate-x-4 shadow-xl z-20 brightness-105":"w-16 h-16 hover:w-24 hover:h-20 hover:-translate-x-4 hover:brightness-110 opacity-90 hover:opacity-100 z-10"),"aria-label":`Go to ${f.label} section`,children:[e.jsx("div",{className:At("transition-all duration-300 rounded-xl",F?"bg-white/30 p-2.5":"bg-white/20 p-2 group-hover:bg-white/30 group-hover:p-2.5"),children:e.jsx(ee,{size:F?24:20,className:"text-white transition-transform duration-300 group-hover:scale-110"})}),e.jsxs("div",{className:"absolute right-full mr-3 px-3 py-1.5 bg-slate-800 text-white text-xs font-bold rounded-lg opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[100] shadow-xl border border-slate-700/50",children:[e.jsx("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 w-2 h-2 bg-slate-800 rotate-45 border-r border-t border-slate-700/50"}),f.label]})]},f.type)})}),e.jsxs("div",{className:At("flex-1 rounded-[2rem] shadow-2xl flex flex-col overflow-hidden relative z-10 transition-colors duration-500",u.tabBg),children:[e.jsxs("div",{className:"px-6 sm:px-8 py-5 flex items-center gap-4 text-white",children:[e.jsx("div",{className:"bg-white/20 p-2.5 rounded-xl shrink-0",children:e.jsx(P,{size:28,className:"text-white"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold truncate",title:ge.title,children:ge.title}),e.jsx("p",{className:"text-white/90 text-sm font-medium truncate mt-0.5",title:t.title,children:t.title})]})]}),e.jsxs("div",{className:"flex-1 bg-[#fdfdfd] rounded-[1.5rem] m-2 mt-0 relative overflow-hidden shadow-inner flex flex-col",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-30",style:{backgroundImage:"linear-gradient(transparent 95%, #cbd5e1 95%)",backgroundSize:"100% 40px",backgroundPosition:"0 0"}}),e.jsx("div",{className:"absolute top-0 bottom-0 left-12 md:left-16 w-[2px] bg-rose-300/60 pointer-events-none z-0"}),e.jsxs("div",{className:"relative z-10 flex-1 overflow-y-auto px-6 md:pl-24 md:pr-12 py-8",children:[e.jsx("div",{className:"md:hidden flex gap-2 overflow-x-auto pb-4 mb-4 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:kt.map((f,T)=>{const F=T===d,ee=f.icon;return e.jsx("button",{onClick:()=>{_(T>d?1:-1),A(T)},className:At("min-w-[100px] rounded-2xl px-3 py-2 text-left transition-all duration-200",F?`${f.tabBg} text-white shadow-md`:"bg-slate-100 text-slate-600 border border-slate-200"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:14}),e.jsx("span",{className:"text-xs font-bold",children:f.label})]})},f.type)})}),e.jsx($e,{mode:"wait",children:e.jsxs(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"space-y-6",children:[e.jsx("div",{className:"bg-white/90 backdrop-blur-sm rounded-[1.5rem] p-6 sm:p-8 shadow-sm border border-slate-100/50",children:e.jsx(jr,{section:ge,sectionIndex:d,onShowSolution:f=>j(y===f?null:f),expandedIndex:y,lesson:t,lessonSpecificTopic:re,onTryItQuizComplete:g,onContinueLearning:M})}),$.length>0&&(z?.role==="admin"||z?.role==="teacher")&&e.jsxs("details",{className:"rounded-xl border border-slate-200 bg-white/90 backdrop-blur-sm px-4 py-3 text-xs text-slate-500 shadow-sm",children:[e.jsxs("summary",{className:"cursor-pointer font-semibold text-slate-600 hover:text-slate-800",children:[$.length," source",$.length>1?"s":""," used"]}),e.jsx("div",{className:"mt-2 space-y-1 pl-2",children:$.slice(0,3).map((f,T)=>e.jsxs("p",{className:"font-mono truncate",children:[f.source_file," p.",f.page," (",Math.round((f.score||0)*100),"%)"]},T))})]})]},d)})]},d)]})]})]})}),e.jsx("footer",{className:"bg-transparent px-4 sm:px-8 flex-shrink-0 relative z-40 w-full flex justify-center items-center h-20",children:e.jsxs("div",{className:"w-full max-w-5xl flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-8 w-full md:ml-16",children:[e.jsxs(ze,{onClick:we,disabled:d===0,variant:"outline",className:"px-6 py-3 rounded-full font-bold text-sm bg-white border-slate-200 text-slate-600 shadow-sm disabled:opacity-40 hover:bg-slate-50 transition-colors flex items-center gap-2",children:[e.jsx(Ot,{size:16}),"Previous"]}),e.jsxs("p",{className:"text-sm text-slate-500 font-bold tabular-nums",children:[d+1," / ",Z]}),e.jsx(ze,{onClick:K,disabled:d===Z-1&&I,className:"px-8 py-3 rounded-full font-bold text-sm bg-[#7ec16d] text-white hover:bg-[#6ab359] shadow-md transition-colors disabled:opacity-40 flex items-center gap-2",children:d===Z-1?e.jsxs(e.Fragment,{children:["Complete",e.jsx(zt,{size:16})]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(pt,{size:16})]})})]}),d===Z-1&&I&&e.jsx("p",{className:"text-center text-xs font-semibold text-amber-600 mt-3 md:ml-16",children:"Complete the practice quiz first to unlock lesson completion."})]})}),e.jsx($e,{children:R&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-sm p-4",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-8 max-w-sm w-full text-center shadow-2xl",children:[e.jsx("div",{className:"w-20 h-20 bg-[#7ec16d] rounded-full flex items-center justify-center mx-auto mb-5 shadow-lg",children:e.jsx(zt,{size:40,className:"text-white"})}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-2",children:"Lesson Complete!"}),e.jsxs("p",{className:"text-slate-500 text-sm mb-6 leading-relaxed",children:["Great job finishing ",e.jsx("strong",{className:"text-slate-700",children:t.title}),"."]}),e.jsxs("div",{className:"bg-emerald-50 rounded-2xl p-4 mb-6 border border-emerald-100",children:[e.jsx("div",{className:"flex items-center justify-center mb-1",children:e.jsx(Ft,{className:"text-[#7ec16d]",size:22})}),e.jsx("p",{className:"text-xs text-[#7ec16d] font-bold uppercase tracking-wider mb-0.5",children:"XP Earned"}),e.jsxs("p",{className:"text-3xl font-black text-[#7ec16d]",children:["+",a]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("button",{onClick:()=>Me(!0),disabled:I,className:"w-full py-3 rounded-xl font-bold text-sm bg-[#1a85a4] text-white hover:bg-[#126b84] transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Continue to Next Lesson"}),e.jsx("button",{onClick:()=>Me(!1),className:"w-full py-3 rounded-xl font-bold text-sm bg-slate-100 text-slate-600 hover:bg-slate-200 transition-colors",children:"Back to Modules"})]})]})})})]})},Nr=[{id:1,type:"multiple-choice",question:"What is the value of π (pi) to two decimal places?",options:["3.12","3.14","3.16","3.18"],correctAnswer:"3.14",explanation:"π ≈ 3.14159..., so to two decimal places it is 3.14."},{id:2,type:"true-false",question:"The sum of angles in a triangle is 180 degrees.",correctAnswer:"True",explanation:"The interior angles of any Euclidean triangle sum to 180°."},{id:3,type:"fill-in-blank",question:"If 2x + 5 = 13, then x = ___.",correctAnswer:"4",explanation:"2x = 13 - 5 = 8 → x = 4."},{id:4,type:"multiple-choice",question:"Which of the following is a prime number?",options:["9","15","17","21"],correctAnswer:"17",explanation:"17 is only divisible by 1 and itself. 9=3×3, 15=3×5, 21=3×7."},{id:5,type:"true-false",question:"The slope of a horizontal line is zero.",correctAnswer:"True",explanation:"A horizontal line has no rise, so rise/run = 0."},{id:6,type:"fill-in-blank",question:"The square root of 144 is ___.",correctAnswer:"12",explanation:"12 × 12 = 144, so √144 = 12."}];async function kr(t){const{lessonTitle:a,topic:l,subjectId:o,competencyCode:n,questionCount:r=6}=t,i=Sr(o)||"General Mathematics",x=t.lessonId?Math.abs(t.lessonId.split("").reduce((p,b)=>Math.imul(31,p)+b.charCodeAt(0)|0,0))%1e6:Math.floor(Math.random()*1e6);try{const p=await aa("/api/quiz/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:l||a,subject:i,lessonTitle:a,questionCount:r,questionTypes:["multiple-choice","true-false","fill-in-blank"],difficulty:"medium",competencyCode:n,varianceSeed:x})});return!p.questions||p.questions.length===0?(console.warn("[lessonQuizService] API returned empty questions, using fallback"),Ns(r)):p.questions.map(b=>({id:b.id,type:b.type,question:b.question,options:b.options||void 0,correctAnswer:b.correctAnswer,explanation:b.explanation}))}catch(p){return console.error("[lessonQuizService] Failed to generate quiz via API:",p),console.warn("[lessonQuizService] Using fallback questions"),Ns(r)}}function qs(t){return t==="quiz"?8:6}function Sr(t){if(!t)return null;const a=t.toLowerCase();return a.includes("gen-math")||a.includes("gen_math")?"General Mathematics":a.includes("stats")||a.includes("prob")?"Statistics and Probability":a.includes("pre-calc")||a.includes("pre_calc")?"Pre-Calculus":a.includes("basic-calc")||a.includes("basic_calc")||a.includes("calculus")?"Basic Calculus":null}function Ns(t){const a=[...Nr].sort(()=>Math.random()-.5);return a.slice(0,Math.min(t,a.length)).map((l,o)=>({...l,id:o+1}))}const Cr=Object.freeze(Object.defineProperty({__proto__:null,generateLessonQuiz:kr,getQuestionCountForQuiz:qs},Symbol.toStringTag,{value:"Module"})),Et={},zr=(t,a)=>{if(Et[t]&&Et[t].length)return Et[t];const o=Array.from({length:8}).map((n,r)=>{const i=r+2,x=r+3,p=(i+x).toString();return{id:r+1,type:"multiple-choice",question:`Compute: ${i} + ${x}`,options:[p,(i*x).toString(),Math.abs(i-x).toString(),(i+x+1).toString()],correctAnswer:p,explanation:`Add ${i} and ${x} to get ${p}.`}});return Et[t]=o,o},_r=({module:t,onBack:a,onEarnXP:l,isInQuizMode:o=!1,setIsInQuizMode:n})=>{const[i,x]=s.useState(null),{userProfile:p}=It(),[b,g]=s.useState(null),[M,z]=s.useState(!1);s.useEffect(()=>{if(!p?.uid)return;(async()=>{try{const[P,f]=await Promise.all([Wt(bt(We,"diagnosticResults",p.uid)),Wt(bt(We,"competencyProfiles",p.uid))]),T=P.exists()&&P.data()?.status==="completed",F=f.exists()&&(f.data()?.overallScore??0)>0;z(T||F)}catch{z(!1)}})()},[p?.uid]);const d=s.useRef(l);s.useEffect(()=>{d.current=l},[l]);const A=s.useRef(i);s.useEffect(()=>{A.current=i},[i]),s.useEffect(()=>{try{const u=sessionStorage.getItem(`mathpulse_module_${t.id}_selectedLesson`);if(u){const{lessonId:P}=JSON.parse(u),f=t.lessons.find(T=>T.id===P);f&&x({lesson:f,type:"lesson"})}}catch{}},[]),s.useEffect(()=>{if(i?.type==="lesson"&&i.lesson)try{sessionStorage.setItem(`mathpulse_module_${t.id}_selectedLesson`,JSON.stringify({lessonId:i.lesson.id}))}catch{}else if(i===null)try{sessionStorage.removeItem(`mathpulse_module_${t.id}_selectedLesson`)}catch{}},[i,t.id]);const N=s.useMemo(()=>{const u=Number(t.id.split("-").pop());return Number.isFinite(u)&&u>0?u:1},[t.id]),_=s.useMemo(()=>{const u=t.subjectId;return u||(Tt.find(f=>f.modules.some(T=>T.id===t.id))?.id??null)},[t.id]),R=["#1FA7E1","#9956DE","#75D06A","#FFB356","#7274ED","#FF8B8B","#6ED1CF","#FB96BB"];s.useMemo(()=>{const u=t.subjectAccentColor;if(u)return u;const f=(_?Tt.find(F=>F.id===_):null)?.modules?.findIndex(F=>F.id===t.id)??0,T=f>=0?f:0;return R[T%R.length]},[t,t.id,_]),s.useEffect(()=>{if(p?.uid)return is(p.uid,g)},[p?.uid]);const m=s.useMemo(()=>_?b?.subjects?.[_]?.modulesProgress?.[t.id]??null:null,[t.id,_,b?.subjects]),[y,j]=s.useState(null),E=s.useMemo(()=>{const u=m?.lessonsCompleted??[];return new Set(u)},[m?.lessonsCompleted]),k=s.useMemo(()=>{const u=m?.quizzesCompleted??[];return new Set(u)},[m?.quizzesCompleted]),U=m?.lessonsCompleted?.length??t.lessons.filter(u=>u.completed).length,O=m?.quizzesCompleted?.length??t.quizzes.filter(u=>u.completed).length,Y=m?.progress??t.progress,$=t.lessons.length+t.quizzes.length,te=U+O;t.lessons.length&&U/t.lessons.length*100,t.quizzes.length&&O/t.quizzes.length*100;const xe=(u,P)=>{const f=b?.lessons?.[u]?.score;return typeof f=="number"&&Number.isFinite(f)?Math.max(0,Math.min(100,f)):P?100:0},_e=s.useMemo(()=>{if(!$)return 0;const u=t.lessons.reduce((f,T)=>{const F=E.has(T.id)||T.completed;return f+xe(T.id,F)},0),P=O*100;return Math.round((u+P)/$)},[E,O,t.lessons,t.quizzes.length,$,b?.lessons]),re=Y>0?Y:_e,W=s.useMemo(()=>{const u=t.quizzes.find(f=>f.type==="final"||/module\s+quiz|general\s+quiz/i.test(f.title));if(u)return u;const P=t.quizzes.find(f=>f.isStandalone===!0);return P||(t.quizzes.length?t.quizzes[0]:null)},[t.quizzes]),Z=s.useMemo(()=>{const u=new Map;t.lessons.forEach(f=>{u.set(f.id,[])});const P=t.lessons.length;return P===0||t.quizzes.forEach((f,T)=>{if(W?.id===f.id)return;const F=Math.min(T,P-1),ee=t.lessons[F];if(!ee)return;const ne=u.get(ee.id)??[];ne.push(f),u.set(ee.id,ne)}),u},[t.lessons,t.quizzes,W?.id]),ge=s.useMemo(()=>Math.max(1,Math.ceil(t.lessons.length/2)),[t.lessons.length]),K=s.useCallback(()=>{x(null),j(null)},[]),we=s.useCallback(()=>{const u=A.current?.type==="lesson"?A.current.lesson:null;if(!u)return;const P={id:`${u.id}-practice`,title:`Practice Quiz: ${u.title}`,questions:qs("practice"),duration:u.duration,completed:!1,locked:!1,type:"practice"};j(u),x({type:"quiz",quiz:P})},[]),Me=s.useCallback((u,P,f)=>{const T=A.current;if(T?.type!=="lesson"||!T.lesson)return;const F=T.lesson,ee=10;if(d.current?.(ee,`Completed "${F.title}"`),p?.uid&&_&&(async()=>{try{await ra(p.uid,_,t.id,F.id,0,ee),await os(p.uid,_,t.id,t.lessons.length,t.quizzes.length)}catch(ne){console.error("[LessonComplete] Failed to persist progress:",ne)}})(),f){const ne=t.lessons.findIndex(Be=>Be.id===F.id);ne!==-1&&ne0?x({type:"quiz",quiz:t.quizzes[0]}):x(null)}else x(null)},[_,t.id,t.lessons.length,t.quizzes.length]),I=s.useCallback(u=>{if(!p?.uid||!A.current||A.current.type!=="lesson")return;const P=A.current.lesson.id;(async()=>{try{await la(p.uid,P,u)}catch(f){console.warn("[ModuleDetailView] Failed to persist lesson progress:",f)}})()},[p?.uid,t.id]);if(i)if(i.type==="lesson"){const u=Z.get(i.lesson.id)?.[0]??null,P=u?k.has(u.id)||u.completed:!1;return e.jsx(vr,{lesson:i.lesson,lessonCompletionXP:10,practiceQuiz:u,practiceQuizCompleted:P,initialSection:i.returnFromQuiz?-1:0,onBack:K,onStartPractice:we,onProgressUpdate:I,onComplete:Me})}else{const u=zr(i.quiz.id);return e.jsx(cr,{lesson:{id:parseInt(i.quiz.id.split("-").pop()||"1"),title:i.quiz.title,duration:i.quiz.duration,type:"quiz",completed:i.quiz.completed,locked:i.quiz.locked},questions:u,onBack:()=>{y?(x({type:"lesson",lesson:y,returnFromQuiz:!0}),j(null)):x(null),n&&n(!1)},onComplete:(P,f)=>{p?.uid&&_&&(async()=>{try{await na(p.uid,_,t.id,i.quiz.id,P,[],0,f),await os(p.uid,_,t.id,t.lessons.length,t.quizzes.length),await is(p.uid,g)}catch(T){console.warn("[Quiz] Progress persist failed:",T)}l&&l(f??0,`Quiz Complete! +${f??0} XP`)})(),y?(x({type:"lesson",lesson:y,returnFromQuiz:!0}),j(null)):x(null),n&&n(!1)}})}return e.jsxs("div",{className:"h-full overflow-y-auto scrollbar-hide px-4 sm:px-6 xl:px-10 py-6 sm:py-8 relative",children:[e.jsx("div",{className:"relative mb-6 xl:mb-8 w-full sm:w-max",children:e.jsxs("button",{onClick:a,className:"flex items-center gap-2 px-4 py-2.5 rounded-full bg-white/80 backdrop-blur-xl border border-slate-200/60 text-slate-600 hover:text-indigo-600 font-bold text-sm tracking-wide transition-all hover:-translate-x-1 shadow-sm hover:shadow-md",children:[e.jsx(Ot,{size:18}),"Back"]})}),e.jsxs(v.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:`relative mb-6 lg:mb-8 rounded-[2rem] ${t.accentColor} shadow-[0_20px_40px_-15px_rgba(0,0,0,0.3)] shrink-0 overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-none z-0"}),e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none module-detail-grid-pattern"}),e.jsx("div",{className:"absolute top-0 right-0 w-[400px] h-[400px] bg-sky-500/20 blur-[100px] rounded-full pointer-events-none"}),e.jsxs("div",{className:"relative p-5 sm:p-7 md:p-10 flex flex-col md:flex-row md:items-center justify-between gap-6 md:gap-8",children:[e.jsxs("div",{className:"flex-1 text-white",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4 md:mb-5",children:[e.jsxs("div",{className:"px-3 py-1 bg-white/10 backdrop-blur-md rounded-full text-[11px] font-black uppercase tracking-widest text-[#f8fafc] border border-white/20 shadow-sm flex items-center gap-1.5",children:[e.jsx(us,{size:14})," Chapter ",t.id.split("-").pop()||"1"]}),e.jsxs("div",{className:"px-3 py-1 bg-white/10 backdrop-blur-md rounded-full text-[11px] font-black uppercase tracking-widest text-emerald-400 border border-emerald-400/30",children:["Lv ",N]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-display font-black text-white mb-3 md:mb-4 tracking-[-0.02em] leading-tight",children:t.title}),e.jsx("p",{className:"text-slate-300 text-sm md:text-[15px] max-w-2xl font-medium leading-relaxed mb-6 md:mb-8",children:t.description}),e.jsxs("div",{className:"bg-black/20 backdrop-blur-md rounded-2xl p-4 md:p-5 border border-white/10 max-w-xl",children:[e.jsxs("div",{className:"flex justify-between items-end mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ft,{size:20,className:"text-emerald-400"}),e.jsx("span",{className:"text-[12px] md:text-[13px] font-black text-white uppercase tracking-wider",children:"Module Mastery"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-[12px] md:text-[13px] font-bold text-slate-400 mb-0.5",children:[te,"/",$," steps"]}),e.jsxs("span",{className:"text-xl md:text-2xl font-black text-white shrink-0 leading-none",children:[Math.round(re),"%"]})]})]}),e.jsx("div",{className:"h-3 bg-black/40 rounded-full overflow-hidden shadow-inner ring-1 ring-white/10 p-0.5",children:e.jsx(v.div,{initial:{width:0},animate:{width:`${re}%`},transition:{duration:1.5,ease:"easeOut",delay:.2},className:`h-full rounded-full relative ${re===100?"bg-gradient-to-r from-emerald-400 to-teal-300":t.accentColor}`,children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4IiBoZWlnaHQ9IjgiPgo8cmVjdCB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMSI+PC9yZWN0Pgo8L3N2Zz4=')] opacity-30 mix-blend-overlay"})})})]})]}),e.jsxs("div",{className:"hidden lg:flex w-48 h-48 bg-white/5 rounded-[2rem] border border-white/10 backdrop-blur-md items-center justify-center transform rotate-[-3deg] shadow-2xl relative group hover:rotate-0 transition-all duration-500 shrink-0",children:[e.jsx("div",{className:`absolute inset-0 opacity-40 rounded-[2rem] ${t.progress===100?"bg-gradient-to-br from-emerald-400 to-teal-600":t.accentColor}`}),re===100?e.jsx(Ct,{size:80,className:"text-white drop-shadow-xl z-10 scale-100 group-hover:scale-110 transition-transform duration-500",strokeWidth:1}):e.jsx(Je,{size:80,className:"text-white drop-shadow-xl z-10 scale-100 group-hover:scale-110 transition-transform duration-500",strokeWidth:1}),e.jsx(v.div,{animate:{y:[-5,5,-5],rotate:[-10,10,-10]},transition:{duration:4,repeat:1/0},className:"absolute top-6 left-6 text-emerald-300 z-20",children:e.jsx(Ps,{size:20,fill:"currentColor"})}),e.jsx(v.div,{animate:{y:[5,-5,5],rotate:[10,-10,10]},transition:{duration:3.5,repeat:1/0},className:"absolute bottom-8 right-6 text-sky-300 z-20",children:e.jsx(bs,{size:24})})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2 pb-8 scrollbar-hide",children:e.jsxs("div",{className:"relative rounded-[2rem] border border-slate-200 bg-white/90 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(153,86,222,0.08),transparent_45%),radial-gradient(circle_at_bottom_left,rgba(31,167,225,0.08),transparent_45%)]"}),e.jsxs("div",{className:"relative z-10 px-4 sm:px-6 md:px-8 py-5 md:py-6 border-b border-slate-200/70 bg-white/70 backdrop-blur-sm flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("h2",{className:"font-display font-black text-xl md:text-2xl text-slate-800 flex items-center gap-3",children:[e.jsx(Je,{size:24,className:"text-sky-500"}),"Study Journey"]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("div",{className:"text-xs md:text-sm font-bold bg-sky-100 text-sky-700 px-3 py-1 rounded-full shadow-sm border border-sky-200/50",children:["Lessons ",U,"/",t.lessons.length]}),e.jsxs("div",{className:"text-xs md:text-sm font-bold bg-rose-100 text-rose-700 px-3 py-1 rounded-full shadow-sm border border-rose-200/50",children:["Quizzes ",O,"/",t.quizzes.length]})]})]}),e.jsxs("div",{className:"relative z-10 px-4 sm:px-6 md:px-8 py-5 md:py-6 space-y-5",children:[t.lessons.map((u,P)=>{const f=E.has(u.id)||u.completed,T=xe(u.id,f),F=R[P%R.length];return e.jsxs(Ae.Fragment,{children:[e.jsxs(v.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{delay:P*.05},className:`relative rounded-[1.5rem] border overflow-hidden group transition-all duration-500 mb-6 ${u.locked?"border-slate-200 opacity-65 saturate-50":"border-slate-200/80 hover:border-slate-300 hover:shadow-[0_16px_40px_-15px_rgba(0,0,0,0.12)] hover:-translate-y-0.5"}`,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[6px] z-20 bg-slate-100 overflow-hidden",children:e.jsx(v.div,{initial:{width:0},animate:{width:`${Math.max(2,T)}%`},transition:{duration:1.2,ease:"easeOut",delay:.1+P*.05},className:"h-full relative",style:{backgroundColor:F},children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4IiBoZWlnaHQ9IjgiPgo8cmVjdCB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMSI+PC9yZWN0Pgo8L3N2Zz4=')] opacity-30 mix-blend-overlay"})})}),e.jsx("div",{className:"absolute inset-0 bg-white transition-opacity duration-500 group-hover:opacity-90",style:{backgroundImage:`linear-gradient(to right, ${F}44 0%, ${F}11 50%, white 100%)`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.2] pointer-events-none",style:{backgroundImage:`radial-gradient(circle at 2px 2px, ${F} 1.5px, transparent 0)`,backgroundSize:"24px 24px"}}),e.jsx("div",{className:"absolute -top-12 -left-10 h-40 w-40 rounded-full blur-[32px] pointer-events-none transition-transform duration-700 group-hover:scale-[1.3] group-hover:translate-x-4",style:{backgroundColor:`${F}22`}}),e.jsx("div",{className:"absolute -bottom-8 right-8 h-32 w-32 rounded-full blur-2xl pointer-events-none transition-transform duration-700 group-hover:scale-125 group-hover:-translate-y-4",style:{backgroundColor:`${F}11`}}),e.jsx("div",{className:"absolute right-4 top-4 opacity-10 pointer-events-none transition-all duration-500 group-hover:rotate-12 group-hover:scale-110 drop-shadow-sm",style:{color:F},children:e.jsx(bs,{size:56,strokeWidth:1})}),e.jsx("div",{className:"absolute right-16 bottom-5 opacity-10 pointer-events-none transition-all duration-500 group-hover:-rotate-6 group-hover:-translate-y-2 drop-shadow-sm",style:{color:F},children:e.jsx(Je,{size:40,strokeWidth:1})}),e.jsxs("div",{className:"relative z-10 p-4 md:p-5 pt-6 space-y-4",children:[e.jsxs("button",{type:"button",onClick:()=>!u.locked&&x({lesson:u,type:"lesson"}),className:`w-full text-left flex flex-wrap items-center justify-between gap-3 rounded-2xl px-5 py-4 transition shadow-sm ${u.locked?"cursor-not-allowed border border-slate-200 bg-white/70":"cursor-pointer bg-white hover:bg-slate-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center shrink-0 transition-colors shadow-sm ${u.locked?"bg-slate-100 text-slate-400":"text-white"}`,style:u.locked?{}:f?{backgroundColor:"#0ea5e9"}:{backgroundColor:F},children:u.locked?e.jsx(Vt,{size:18}):f?e.jsx(ja,{size:24}):e.jsx(As,{size:20,className:"ml-0.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] md:text-[12px] font-black uppercase tracking-wider text-slate-500 mb-0.5",children:["Lesson ",P+1]}),e.jsx("h3",{className:"font-bold text-[16px] md:text-[18px] text-[#0a1628] truncate",children:u.title})]})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-slate-500 text-xs md:text-sm font-semibold bg-slate-100/80 px-3 py-1.5 rounded-xl",children:[e.jsx(ft,{size:14}),u.duration]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 px-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-full bg-white px-4 py-1.5 text-[12px] font-bold shadow-sm transition hover:-translate-y-0.5",style:{color:F},children:[e.jsx(Je,{size:14})," Study Materials"]}),e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-full bg-white px-4 py-1.5 text-[12px] font-bold shadow-sm transition hover:-translate-y-0.5",style:{color:F},children:[e.jsx(us,{size:14})," Quiz"]})]})]})]}),W&&P===ge-1&&e.jsxs(v.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15+P*.03},className:"mt-8 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("div",{className:"flex-1 h-px bg-slate-200"}),e.jsx("span",{className:"text-xs font-bold text-indigo-400 uppercase tracking-widest text-center",children:"mid-module checkpoint"}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),e.jsxs("div",{className:"relative rounded-[1.5rem] bg-[#533ab6] p-5 shadow-lg overflow-hidden group transition-all hover:shadow-xl hover:-translate-y-1",children:[e.jsx("div",{className:"absolute right-4 md:right-10 top-1/2 -translate-y-1/2 text-white/5 text-[140px] font-black font-display pointer-events-none group-hover:scale-110 transition-transform duration-500",children:"?"}),e.jsxs("div",{className:"relative z-10 flex flex-wrap items-center gap-4 md:gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-[14px] bg-white/10 backdrop-blur-md border border-white/10 shrink-0 flex items-center justify-center shadow-inner",children:e.jsx(Oe,{size:28,className:"text-rose-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] md:text-[11px] font-black uppercase tracking-widest text-[#a3b1ee] mb-1 drop-shadow-sm",children:"COMPETENCY CHECK · General Quiz"}),e.jsx("h3",{className:"font-display font-medium text-[20px] md:text-[22px] text-white leading-tight mb-2 tracking-tight",children:W.title}),e.jsxs("p",{className:"text-xs font-semibold text-white/80 flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{size:12})," ",W.questions," Qs"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",W.duration]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-300 drop-shadow-md",children:[e.jsx(Re,{size:12,className:"fill-amber-300"})," +50 XP"]})]})]}),e.jsx("button",{type:"button",onClick:()=>!W.locked&&(x({quiz:W,type:"quiz"}),n&&n(!0)),className:`px-6 py-2.5 rounded-xl text-xs md:text-sm font-bold tracking-wider transition-all backdrop-blur-sm self-center shrink-0 ${W.locked?"bg-white/5 text-white/30 border border-white/10 cursor-not-allowed":M&&(k.has(W.id)||W.completed)?"bg-white/20 text-white border border-white/40 hover:bg-white/30 shadow-sm":"bg-transparent text-white border border-white/40 hover:bg-white/10 shadow-sm"}`,children:M&&(k.has(W.id)||W.completed)?"REVIEW":"START"})]})]})]})]},u.id)}),t.lessons.length===0&&W&&e.jsxs("div",{className:"relative rounded-[1.5rem] bg-[#533ab6] p-5 shadow-lg overflow-hidden group",children:[e.jsx("div",{className:"absolute right-4 md:right-10 top-1/2 -translate-y-1/2 text-white/5 text-[140px] font-black font-display pointer-events-none group-hover:scale-110 transition-transform duration-500",children:"?"}),e.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-between gap-4 md:gap-5",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e.jsx("div",{className:"w-14 h-14 rounded-[14px] bg-white/10 backdrop-blur-md border border-white/10 shrink-0 flex items-center justify-center shadow-inner",children:e.jsx(Oe,{size:28,className:"text-rose-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] md:text-[11px] font-black uppercase tracking-widest text-[#a3b1ee] mb-1 drop-shadow-sm",children:"COMPETENCY CHECK · General Quiz"}),e.jsx("h3",{className:"font-display font-medium text-[20px] md:text-[22px] text-white leading-tight mb-2 tracking-tight",children:W.title}),e.jsxs("p",{className:"text-xs font-semibold text-white/80 flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{size:12})," ",W.questions," Qs"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",W.duration]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-300 drop-shadow-md",children:[e.jsx(Re,{size:12,className:"fill-amber-300"})," +50 XP"]})]})]})]}),e.jsx("button",{type:"button",onClick:()=>!W.locked&&(x({quiz:W,type:"quiz"}),n&&n(!0)),className:`px-6 py-2.5 rounded-xl text-xs md:text-sm font-bold tracking-wider transition-all backdrop-blur-sm self-center shrink-0 ${W.locked?"bg-white/5 text-white/30 border border-white/10 cursor-not-allowed":M&&(k.has(W.id)||W.completed)?"bg-white/20 text-white border border-white/40 hover:bg-white/30 shadow-sm":"bg-transparent text-white border border-white/40 hover:bg-white/10 shadow-sm"}`,children:M&&(k.has(W.id)||W.completed)?"REVIEW":"START"})]})]})]})]})})]})},Mr=({onStartQuiz:t,searchQuery:a="",allowedSubjectIds:l})=>{const{userProfile:o}=It(),[n,r]=s.useState("all"),[i,x]=s.useState("all"),[p,b]=s.useState(null),g=s.useMemo(()=>!l||l.length===0?Tt:Tt.filter(m=>l.includes(m.id)),[l]);s.useEffect(()=>{o?.uid&&ia(o.uid).then(b).catch(console.error)},[o?.uid]),s.useEffect(()=>{if(i==="all")return;g.some(y=>y.title===i)||x("all")},[g,i]);const M=p?.totalQuizzesCompleted||0,z=o?.totalXP||0,d=p?.averageScore?Math.round(p.averageScore):0,A=new Set(p?.quizAttempts?.map(m=>m.quizId)||[]),N={};if(p?.quizAttempts)for(const m of p.quizAttempts)(!N[m.quizId]||m.score>N[m.quizId])&&(N[m.quizId]=m.score);const R=g.flatMap(m=>m.modules.flatMap(y=>y.quizzes.map(j=>({id:j.id,title:j.title,subject:m.title,difficulty:j.type==="module"?"Medium":"Easy",questions:j.questions,duration:j.duration,xpReward:j.questions*5,type:j.type==="module"?"challenge":"practice",completed:A.has(j.id),bestScore:N[j.id],locked:j.locked})))).filter(m=>{const y=n==="all"||m.type===n,j=i==="all"||m.subject===i,E=!a||m.title.toLowerCase().includes(a.toLowerCase())||m.subject.toLowerCase().includes(a.toLowerCase());return y&&j&&E});return e.jsxs("div",{className:"px-4 sm:px-6 xl:px-10 py-4 sm:py-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-sky-700 to-sky-500 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Ft,{size:24})}),e.jsx("span",{className:"text-3xl font-bold",children:M})]}),e.jsx("p",{className:"text-sm font-medium text-sky-100",children:"Quizzes Completed"})]}),e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-rose-500 to-rose-600 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Re,{size:24})}),e.jsx("span",{className:"text-3xl font-bold",children:z.toLocaleString()})]}),e.jsx("p",{className:"text-sm font-medium text-cyan-100",children:"Total XP Earned"})]}),e.jsxs(v.div,{whileHover:{scale:1.02},className:"bg-gradient-to-br from-indigo-600 to-indigo-700 rounded-2xl p-5 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Oe,{size:24})}),e.jsxs("span",{className:"text-3xl font-bold",children:[d,"%"]})]}),e.jsx("p",{className:"text-sm font-medium text-sky-100",children:"Average Score"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white rounded-xl p-1 shadow-sm",children:[e.jsx("button",{onClick:()=>r("all"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="all"?"bg-sky-600 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"All"}),e.jsx("button",{onClick:()=>r("practice"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="practice"?"bg-sky-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Practice"}),e.jsx("button",{onClick:()=>r("challenge"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="challenge"?"bg-orange-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Challenge"}),e.jsx("button",{onClick:()=>r("mastery"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${n==="mastery"?"bg-sky-500 text-white shadow-md":"text-[#5a6578] hover:bg-[#edf1f7]"}`,children:"Mastery"})]}),e.jsxs("select",{value:i,onChange:m=>x(m.target.value),className:"px-4 py-2.5 bg-white border-2 border-[#dde3eb] rounded-xl text-sm font-bold text-[#0a1628] focus:border-indigo-600 focus:outline-none",children:[e.jsx("option",{value:"all",children:"All Subjects"}),g.map(m=>e.jsx("option",{value:m.title,children:m.title},m.id))]})]}),e.jsxs("div",{className:"pr-2 pb-4 rounded-[2rem] border border-slate-200 shadow-inner relative",style:{backgroundImage:"radial-gradient(#CBD5E1 1px, transparent 1px)",backgroundSize:"24px 24px",backgroundPosition:"-12px -12px",backgroundColor:"#FAFAFA"},children:[e.jsx("div",{className:"absolute left-12 top-0 bottom-0 w-0.5 bg-rose-200/60 pointer-events-none z-0"}),e.jsx("div",{className:"absolute left-[54px] top-0 bottom-0 w-px bg-rose-100/40 pointer-events-none z-0"}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-5 p-4 md:p-6 relative z-10",children:R.map((m,y)=>{const j=m.locked,E=m.difficulty==="Hard",k=m.type==="challenge";return e.jsx(v.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:y*.05},onClick:()=>!j&&t?.(m),className:`bg-white/90 backdrop-blur-sm rounded-2xl p-4 md:p-5 border-2 relative select-none transition-all duration-300 ${j?"border-slate-200 opacity-60 saturate-50 cursor-not-allowed":m.completed?"border-teal-200 shadow-sm hover:border-teal-300 hover:shadow-md cursor-pointer":E?"border-indigo-200 shadow-sm hover:border-indigo-300 hover:shadow-md cursor-pointer":"border-orange-200 shadow-sm hover:border-orange-300 hover:shadow-md cursor-pointer"} group`,children:e.jsxs("div",{className:"flex items-center justify-between gap-3 md:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 md:gap-4 flex-1",children:[e.jsx("div",{className:`w-10 h-10 md:w-12 md:h-12 rounded-xl flex items-center justify-center shrink-0 shadow-sm transform group-hover:rotate-3 transition-transform ${j?"bg-slate-100 text-slate-400":m.completed?"bg-teal-500 text-white":E?"bg-indigo-500 text-white":"bg-orange-500 text-white"}`,children:j?e.jsx(Vt,{size:18}):m.completed?e.jsx(Ct,{size:18}):e.jsx(Xt,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded-[6px] text-[9px] md:text-[10px] font-black uppercase tracking-wider ${E?"bg-indigo-100 text-indigo-700":k?"bg-orange-100 text-orange-700":"bg-sky-100 text-sky-700"}`,children:[m.type," ΓÇó ",m.difficulty]}),!j&&!m.completed&&e.jsx("span",{className:"w-1.5 h-1.5 md:w-2 md:h-2 rounded-full bg-rose-500 animate-pulse"})]}),e.jsx("h3",{className:`font-bold text-[14px] md:text-[16px] leading-tight mb-1 md:mb-1.5 transition-colors ${j?"text-slate-600":"text-[#0a1628]"}`,children:m.title}),e.jsx("p",{className:"text-[11px] md:text-[12px] text-slate-500 mb-1.5 line-clamp-1",children:m.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:gap-3 text-[11px] md:text-[12px] font-bold text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Je,{size:12})," ",m.questions," Qs"]}),e.jsx("span",{className:"hidden sm:inline",children:"ΓÇó"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ft,{size:12})," ",m.duration]}),e.jsx("span",{className:"hidden sm:inline",children:"ΓÇó"}),e.jsxs("span",{className:"flex items-center gap-1 text-rose-500",children:[e.jsx(Ct,{size:12})," +",m.xpReward," XP"]})]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2 shrink-0",children:[m.bestScore!==void 0&&e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:`text-xl md:text-2xl font-black leading-none ${m.bestScore>=80?"text-teal-600":"text-orange-500"}`,children:[m.bestScore,"%"]}),e.jsx("div",{className:"text-[9px] uppercase tracking-wide text-slate-400 font-bold mt-1",children:"Best Score"})]}),!j&&e.jsx("div",{className:`px-3 py-1.5 md:px-4 md:py-2 rounded-xl text-[11px] md:text-[12px] font-black uppercase tracking-wider shadow-sm transition-all ${m.completed?"bg-white border border-slate-200 text-slate-600 group-hover:bg-slate-50":"bg-slate-900 text-white group-hover:bg-slate-600"}`,children:m.completed?"Review":"Start"})]})]})},m.id)})}),R.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-slate-500 relative z-10",children:[e.jsx(Oe,{size:48,className:"mb-3"}),e.jsx("p",{className:"font-medium",children:"No quizzes found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters or search query"})]})]})]})},Ar=` @keyframes head-sway { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-2px); } @@ -154,7 +164,7 @@ import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u a transform-origin: 50% 55%; animation: mouth-talk 3s ease-in-out infinite; } -`,Mr=({assessmentDismissed:t,initialAssessmentCompleted:a})=>{const l="absolute inset-0 w-full h-full object-contain",[o,n]=s.useState(!1);s.useEffect(()=>{t&&!a&&!sessionStorage.getItem("mathpulse_assessment_reminder_shown")?n(!0):n(!1)},[t,a]);const r=()=>{sessionStorage.setItem("mathpulse_assessment_reminder_shown","true"),n(!1),window.dispatchEvent(new CustomEvent("mathpulse:open-assessment"))};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_r}),e.jsxs("div",{className:"relative w-full h-[250px] flex items-end justify-center drop-shadow-sm select-none pointer-events-none",children:[o&&e.jsxs(v.div,{initial:{opacity:0,scale:.8,x:10},animate:{opacity:1,scale:1,x:0},className:"absolute top-0 right-0 z-50 max-w-[180px] bg-white rounded-2xl shadow-lg border border-[#dde3eb] p-3 cursor-pointer pointer-events-auto",onClick:r,children:[e.jsx("p",{className:"text-[11px] font-bold text-[#0a1628] leading-snug",children:"Psst! Complete your assessment for a personalized path! ✨"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[10px] text-[#5a6578] font-medium",children:"Tap to start"})]}),e.jsx("div",{className:"absolute -bottom-2 left-4 w-3 h-3 bg-white border-r border-b border-[#dde3eb] rotate-45"})]}),e.jsx("img",{src:"/mascot/modules_avatar_body.png",alt:"Desk setup",className:`${l} z-10`}),e.jsxs("div",{className:`${l} z-20 animate-head-sway`,children:[e.jsx("img",{src:"/mascot/modules_left_horn.png",alt:"Left Horn",className:`${l} z-0 animate-horn-left`}),e.jsx("img",{src:"/mascot/modules_right_horn.png",alt:"Right Horn",className:`${l} z-0 animate-horn-right`}),e.jsx("img",{src:"/mascot/modules_head.png",alt:"Mascot Head",className:`${l} z-[1]`}),e.jsx("img",{src:"/mascot/modules_eyes.png",alt:"Eyes",className:`${l} z-[2] animate-blink`}),e.jsx("img",{src:"/mascot/modules_mouth.png",alt:"Mouth",className:`${l} z-[3] animate-mouth`})]})]})]})};function Ar(t){const[a,l]=s.useState({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!0});return s.useEffect(()=>{if(!t){l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1});return}const o=bt(We,"users",t);return Gt(o,r=>{if(!r.exists()){l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1});return}const i=r.data(),x=i?.extraHintsEnabled===!0,p=i?.hintTokens||0,b=x?p+3:p;l({extraHintsEnabled:x,hintTokens:p,totalHintsAvailable:b,loading:!1})},r=>{console.error("[useExtraHints] snapshot error:",r),l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1})})},[t]),a}const ks=` +`,Er=({assessmentDismissed:t,initialAssessmentCompleted:a})=>{const l="absolute inset-0 w-full h-full object-contain",[o,n]=s.useState(!1);s.useEffect(()=>{t&&!a&&!sessionStorage.getItem("mathpulse_assessment_reminder_shown")?n(!0):n(!1)},[t,a]);const r=()=>{sessionStorage.setItem("mathpulse_assessment_reminder_shown","true"),n(!1),window.dispatchEvent(new CustomEvent("mathpulse:open-assessment"))};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ar}),e.jsxs("div",{className:"relative w-full h-[250px] flex items-end justify-center drop-shadow-sm select-none pointer-events-none",children:[o&&e.jsxs(v.div,{initial:{opacity:0,scale:.8,x:10},animate:{opacity:1,scale:1,x:0},className:"absolute top-0 right-0 z-50 max-w-[180px] bg-white rounded-2xl shadow-lg border border-[#dde3eb] p-3 cursor-pointer pointer-events-auto",onClick:r,children:[e.jsx("p",{className:"text-[11px] font-bold text-[#0a1628] leading-snug",children:"Psst! Complete your assessment for a personalized path! ✨"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[10px] text-[#5a6578] font-medium",children:"Tap to start"})]}),e.jsx("div",{className:"absolute -bottom-2 left-4 w-3 h-3 bg-white border-r border-b border-[#dde3eb] rotate-45"})]}),e.jsx("img",{src:"/mascot/modules_avatar_body.png",alt:"Desk setup",className:`${l} z-10`}),e.jsxs("div",{className:`${l} z-20 animate-head-sway`,children:[e.jsx("img",{src:"/mascot/modules_left_horn.png",alt:"Left Horn",className:`${l} z-0 animate-horn-left`}),e.jsx("img",{src:"/mascot/modules_right_horn.png",alt:"Right Horn",className:`${l} z-0 animate-horn-right`}),e.jsx("img",{src:"/mascot/modules_head.png",alt:"Mascot Head",className:`${l} z-[1]`}),e.jsx("img",{src:"/mascot/modules_eyes.png",alt:"Eyes",className:`${l} z-[2] animate-blink`}),e.jsx("img",{src:"/mascot/modules_mouth.png",alt:"Mouth",className:`${l} z-[3] animate-mouth`})]})]})]})};function Pr(t){const[a,l]=s.useState({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!0});return s.useEffect(()=>{if(!t){l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1});return}const o=bt(We,"users",t);return Gt(o,r=>{if(!r.exists()){l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1});return}const i=r.data(),x=i?.extraHintsEnabled===!0,p=i?.hintTokens||0,b=x?p+3:p;l({extraHintsEnabled:x,hintTokens:p,totalHintsAvailable:b,loading:!1})},r=>{console.error("[useExtraHints] snapshot error:",r),l({extraHintsEnabled:!1,hintTokens:0,totalHintsAvailable:0,loading:!1})})},[t]),a}const ks=` @keyframes score-pop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } @@ -176,4 +186,4 @@ import{r as s,j as e,b as ut,d as Ae}from"./vendor-react-B4AQeu28.js";import{u a height: 10px; animation: confetti-fall linear forwards; } -`,Er=({viewportHeight:t})=>e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex justify-between bg-slate-900/5",children:Ae.useMemo(()=>[...Array(40)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[t]).map(a=>e.jsx(v.div,{className:"absolute w-0.5 h-16 bg-blue-400/30 rounded-full",style:{left:a.left,top:"-10%"},animate:{y:[0,t*1.2]},transition:{duration:a.duration,ease:"linear",delay:a.delay}},a.id))}),Pr=()=>{const t=Ae.useMemo(()=>[...Array(60)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,backgroundColor:["#75D06A","#6ED1CF","#9956DE","#FB96BB","#FFB356"][l%5],duration:2+Math.random()*2,delay:Math.random()*.5,size:6+Math.random()*8,borderRadius:Math.random()>.5?"50%":"2px"})),[]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden",children:t.map(a=>e.jsx("div",{className:"confetti-piece",style:{left:a.left,top:"-10%",backgroundColor:a.backgroundColor,width:a.size,height:a.size,borderRadius:a.borderRadius,animationDuration:`${a.duration}s`,animationDelay:`${a.delay}s`}},a.id))})},Tr=({viewportHeight:t,viewportWidth:a})=>{const l=Ae.useMemo(()=>[...Array(30)].map((o,n)=>({id:n,xShift:(Math.random()-.5)*a*.8,yShift:(Math.random()-.5)*t*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[t,a]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex items-center justify-center",children:l.map(o=>e.jsx(v.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.5)]",style:{left:"50%",top:"50%"},animate:{y:[0,o.yShift],x:[0,o.xShift],scale:[0,o.scale,0],opacity:[0,1,0]},transition:{duration:o.duration,ease:"easeOut",delay:o.delay}},o.id))})},Ss=({value:t,label:a,delay:l=0,icon:o})=>{const[n,r]=Ae.useState(0);return Ae.useEffect(()=>{if(t<=0)return;const i=1e3,x=30,p=Math.abs(Math.floor(i/x));let b=0;const g=setTimeout(()=>{const M=setInterval(()=>{b+=Math.max(1,Math.floor(t/x)),b>=t?(r(t),clearInterval(M)):r(b)},p);return()=>clearInterval(M)},l);return()=>clearTimeout(g)},[t,l]),t<0?null:e.jsxs(v.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:l/1e3,duration:.5},className:"flex items-center justify-between bg-slate-50 border border-slate-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-bold uppercase tracking-wider text-[10px]",children:[o,a]}),e.jsxs("div",{className:"text-xl font-black text-purple-600 tabular-nums",children:["+",n]})]})};function Lr(t){if(t.questionType==="multiple_choice"&&t.options&&t.options.length>0){const a=t.options.findIndex(l=>l.trim().toLowerCase()===t.correctAnswer.trim().toLowerCase());return{id:t.id,question:t.question,options:t.options,correctAnswer:a>=0?a:0,correctAnswerText:t.correctAnswer,explanation:t.explanation,questionType:t.questionType,points:t.points,difficulty:t.difficulty,topic:t.topic,bloomLevel:t.bloomLevel}}return{id:t.id,question:t.question,options:[],correctAnswer:-1,correctAnswerText:t.correctAnswer,explanation:t.explanation,questionType:t.questionType,points:t.points,difficulty:t.difficulty,topic:t.topic,bloomLevel:t.bloomLevel}}function Cs(t){return t.replace(/²/g,"^2").replace(/³/g,"^3").replace(/⁻¹/g,"^-1").replace(/⁰/g,"^0").replace(/¹/g,"^1").replace(/⁴/g,"^4").replace(/⁵/g,"^5").replace(/⁶/g,"^6").replace(/⁷/g,"^7").replace(/⁸/g,"^8").replace(/⁹/g,"^9").replace(/π/g,"pi").replace(/√/g,"sqrt").replace(/×/g,"*").replace(/÷/g,"/").replace(/\s+/g,"").toLowerCase().trim()}function Ir(t,a,l){const o=n=>n.trim().toLowerCase().replace(/\s+/g," ");switch(l){case"identification":return o(t)===o(a);case"enumeration":{const n=t.split(",").map(i=>o(i)).filter(Boolean).sort(),r=a.split(",").map(i=>o(i)).filter(Boolean).sort();return JSON.stringify(n)===JSON.stringify(r)}case"word_problem":case"equation_based":{const n=Cs(t),r=Cs(a);if(n===r)return!0;const i=parseFloat(t.replace(/[^\d.\-]/g,"")),x=parseFloat(a.replace(/[^\d.\-]/g,""));return!isNaN(i)&&!isNaN(x)?Math.abs(i-x)<=.01:o(t)===o(a)}default:return o(t)===o(a)}}const Fr=({quiz:t,onClose:a,onComplete:l,studentId:o,atRiskSubjects:n=[]})=>{const[r,i]=s.useState(0),[x,p]=s.useState(null),[b,g]=s.useState(""),[M,z]=s.useState(!1),[d,A]=s.useState(!1),[N,_]=s.useState(!1),[R,m]=s.useState(0),[y,j]=s.useState(0),[E,k]=s.useState(1),[U,O]=s.useState([]),[Y,$]=s.useState([]),[te,de]=s.useState(Date.now()),[_e,re]=s.useState(!1),[W,Z]=s.useState(!1),[ge,K]=s.useState(null),[we,Me]=s.useState(0),[I,u]=s.useState(0),[P,f]=s.useState(!1),[T,F]=s.useState(!0),[ee,ne]=s.useState(!1),[Be,gt]=s.useState({width:1280,height:720});s.useEffect(()=>{const S=()=>gt({width:window.innerWidth,height:window.innerHeight});return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const[Ue,et]=s.useState(0),[je,nt]=s.useState({}),[_t,Xe]=s.useState(!1),[wt,Ge]=s.useState(!1),[tt,it]=s.useState(!1),{totalHintsAvailable:He}=Ar(o||null),[Ve,ye]=s.useState(5),[ve,Ne]=s.useState(15),st=Ve+He,[Qe,ot]=s.useState(null),[Ye,Ke]=s.useState(!1),[c,D]=s.useState(900*1e3),[X,le]=s.useState([]),[L,ke]=s.useState(0),[Se,Le]=s.useState(null),[ie]=s.useState(()=>t.loadedQuestions&&t.loadedQuestions.length>0?t.loadedQuestions.map(Lr):Array.from({length:t.questions},(S,h)=>({id:`q${h+1}`,question:Dr(t.subject,h),options:Rr(t.subject,h),correctAnswer:$r(t.subject,h),explanation:Br(t.subject,h,t.difficulty)})));s.useEffect(()=>{nt({}),le([]),ye(5),Ne(15),et(0),m(0),j(0),k(1)},[t.id]);const ue=ie[r];s.useEffect(()=>{const S=parseInt(t.duration)||10;Me(S*60);const h=setInterval(()=>{Me(H=>H<=1?(clearInterval(h),yt(),0):H-1)},1e3);return()=>clearInterval(h)},[]),s.useEffect(()=>{ve===0&&!Qe&&(ot(Date.now()),Ke(!0))},[ve,Qe]),s.useEffect(()=>{if(!Ye||!Qe)return;const S=setInterval(()=>{const h=Date.now()-Qe,H=Math.max(0,900*1e3-h);D(H)},1e3);return()=>clearInterval(S)},[Ye,Qe]);const[at,Ie]=s.useState(Array.from({length:15},(S,h)=>({id:h,size:Math.random()*120+40,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*20+15,delay:Math.random()*-20,color:["bg-purple-500/10","bg-blue-500/10","bg-cyan-500/10","bg-emerald-500/10"][Math.floor(Math.random()*4)]}))),fe=S=>{if(T)try{const h=window.AudioContext||window.webkitAudioContext;if(!h)return;const H=new h,B=H.currentTime,Q=(Ce,Ee,he,Fe=.1,be="sine")=>{const xe=H.createOscillator(),qe=H.createGain();xe.type=be,xe.frequency.value=Ce,qe.gain.setValueAtTime(0,Ee),qe.gain.linearRampToValueAtTime(Fe,Ee+.05),qe.gain.exponentialRampToValueAtTime(.001,Ee+he),xe.connect(qe),qe.connect(H.destination),xe.start(Ee),xe.stop(Ee+he)};S==="correct"?(Q(880,B,.1,.1,"sine"),Q(1108.73,B+.1,.2,.1,"sine")):S==="incorrect"?(Q(300,B,.2,.05,"sawtooth"),Q(250,B+.15,.3,.05,"sawtooth")):S==="combo"?(Q(440,B,.1,.05,"square"),Q(554.37,B+.1,.1,.05,"square"),Q(659.25,B+.2,.1,.05,"square"),Q(880,B+.3,.4,.05,"square")):S==="complete"&&(Q(523.25,B,.1,.1),Q(659.25,B+.15,.1,.1),Q(783.99,B+.3,.1,.1),Q(1046.5,B+.45,.5,.1))}catch{}},yt=()=>{re(!0),vt()},pe=()=>{if(Ve<=0||d)return;const S=je[r]||[],h=ue.options.filter(B=>B!==ue.correctAnswerText).filter(B=>!S.includes(B));if(h.length===0)return;const H=h[Math.floor(Math.random()*h.length)];nt(B=>({...B,[r]:[...S,H]})),ye(B=>Math.max(0,B-1)),fe("correct")},Mt=S=>{d||oe||(p(S),setTimeout(()=>{jt(S)},150))},jt=S=>{const h=ue.questionType!=null&&ue.questionType!=="multiple_choice",H=S!==void 0?S:x;if(h){if(!b.trim())return}else if(H===null)return;const B=h?Ir(b,ue.correctAnswerText||"",ue.questionType||""):H===ue.correctAnswer,Q=h?b:String(H),Ce=Math.round((Date.now()-te)/1e3);$(xe=>[...xe,{questionId:ue.id,answer:Q,correct:B,timeSpent:Ce}]);const Ee=[...U];if(Ee[r]=B?1:0,O(Ee),z(B),A(!0),!B){Ge(!0),fe("incorrect"),setTimeout(()=>Ge(!1),500),Ne(xe=>Math.max(0,xe-1)),j(0),k(1),setTimeout(()=>{ct()},1500);return}fe("correct");const Fe=(je[r]||[]).length>0?5:10;et(xe=>xe+Fe),m(R+1);const be=y+1;j(be),be===2?Le("streak"):be===3&&E<2?Le("multiplier2"):be===5&&E<3&&Le("multiplier3"),be>0&&be%3===0&&fe("combo"),be>=5?k(3):be>=3?k(2):k(1),Lt(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(xe=>{xe.default({particleCount:30,spread:40,colors:["#75D06A","#6ED1CF"],origin:{y:.6}})}),it(!0),setTimeout(()=>{it(!1),Le(null),setTimeout(()=>ct(),300)},1500)},ct=()=>{if(r{const S=Math.round(R/ie.length*100);let h=t.xpReward;S>=90?h=Math.round(h*1.5):S>=80&&(h=Math.round(h*1.25));const H=parseInt(t.duration)*60;we>H*.5&&(h=Math.round(h*1.2)),u(h);const B=H-we;o&&Na({lrn:o,quizId:t.id,subject:t.subject,score:S,totalQuestions:ie.length,correctAnswers:R,timeSpentSeconds:B}).catch(Q=>console.error("[WARN] Automation: quiz pipeline failed:",Q)),t.source==="ai_generated"&&o?wa(o,t.id,t.generatedQuizId,t.subject,t.source,S,h,B,Y,ie.map(Q=>({topic:Q.topic||t.subject,difficulty:Q.difficulty||"medium",bloomLevel:Q.bloomLevel||"understand"}))).catch(Q=>console.error("[WARN] Quiz result save failed:",Q)):o&&ia(o,t.id,t.subject,S,Y.map(Q=>({questionId:Q.questionId,selectedAnswer:Q.answer,isCorrect:Q.correct})),B).catch(Q=>console.error("[WARN] Practice quiz persist failed:",Q)),fe("complete")},oe=L{document.fullscreenElement?(document.exitFullscreen().catch(()=>{}),ne(!1)):(document.documentElement.requestFullscreen().catch(()=>{}),ne(!0))};if(_e){const S=Math.round(R/ie.length*100),h=S>=80,H=S>=50&&S<80,B=S<50,Q=document.getElementById("modal-root"),Ce=e.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50 backdrop-blur-sm",children:[e.jsx("style",{children:ks}),h&&e.jsx(Pr,{}),H&&e.jsx(Tr,{viewportHeight:Be.height,viewportWidth:Be.width}),B&&e.jsx(Er,{viewportHeight:Be.height}),e.jsxs(v.div,{initial:{opacity:0,scale:.8,y:40},animate:{opacity:1,scale:1,y:0},transition:{type:"spring",damping:18,stiffness:200},className:"w-full max-w-xs sm:max-w-sm bg-white border-2 border-slate-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)] rounded-[2rem] p-4 sm:p-5 text-center relative z-10",children:[e.jsx(v.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",damping:12,stiffness:150,delay:.2},className:"mb-3",children:e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-16 h-16 sm:w-20 sm:h-20 mx-auto drop-shadow-xl animate-mascot-float"})}),e.jsx(v.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:`text-xl sm:text-2xl font-black uppercase tracking-tight mb-1 drop-shadow-sm ${h?"text-emerald-500":H?"text-amber-500":"text-rose-500"}`,children:h?"EXCELLENT!":H?"GOOD JOB!":"KEEP TRYING!"}),e.jsxs("p",{className:"text-slate-400 font-bold text-[10px] mb-3 uppercase tracking-widest",children:["Quiz Complete • Score: ",R,"/",ie.length]}),e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"bg-slate-50/50 rounded-xl p-3 mb-4 border border-slate-100 flex flex-col gap-2",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest text-left mb-1.5 ml-1",children:"Performance Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Ss,{value:R,label:"Correct Answers",delay:500,icon:e.jsx(lt,{className:"h-3 w-3 text-emerald-500"})}),e.jsx(Ss,{value:Ue,label:"Total XP Earned",delay:800,icon:e.jsx(Re,{className:"h-3 w-3 text-amber-500"})}),e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.4},className:"flex items-center justify-between pt-1.5 mt-1 border-t border-slate-100",children:[e.jsx("span",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest",children:"Final Accuracy"}),e.jsxs("span",{className:"text-lg font-black text-slate-800 tabular-nums",children:[S,"%"]})]})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{size:"lg",onClick:()=>{i(0),ke(0),p(null),g(""),m(0),j(0),k(1),O([]),$([]),et(0),re(!1),A(!1),_(!1),de(Date.now()),nt({}),le([]),Xe(!1),ye(5),Z(!1)},className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-white hover:bg-slate-50 text-purple-600 border-2 border-purple-100",children:"RETAKE QUIZ"}),e.jsx(ze,{size:"lg",onClick:a,className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-purple-600 hover:bg-purple-700 text-white shadow-lg shadow-purple-200",children:"BACK TO PRACTICE CENTER"})]})]})]});return ut.createPortal(Ce,Q)}return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ks}),P&&ut.createPortal(e.jsx(v.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"fixed right-6 top-1/2 -translate-y-1/2 z-[9999] w-64",children:e.jsxs("div",{className:"bg-white rounded-2xl p-3 border border-slate-200 shadow-[0_10px_40px_rgba(0,0,0,0.3)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsxs("h4",{className:"text-xs font-bold text-[#0a1628] flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-purple-600",children:[e.jsx("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"6",y2:"6"})]}),"Calculator"]}),e.jsx("button",{onClick:()=>f(!1),className:"w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-slate-500 hover:text-slate-800 hover:bg-slate-200 transition-colors",children:e.jsx(De,{size:12})})]}),e.jsx(Is,{isOpen:!0,onClose:()=>f(!1),inline:!0})]})}),document.getElementById("modal-root")),Ye&&ut.createPortal(e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-6 max-w-xs w-full text-center border-2 border-rose-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)]",children:[e.jsx(v.div,{animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},className:"text-6xl mb-4",children:"💔"}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-3",children:"Out of Lives!"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"Your hearts have run out. You can wait for them to refill or head back and review your lessons in the meantime."}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2 text-rose-500 font-bold",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5"}),e.jsx("span",{children:"0 / 15 hearts"})]}),e.jsxs("p",{className:"text-slate-400 text-xs mb-4",children:["Next heart in: ",e.jsxs("span",{className:"font-bold text-slate-600",children:[Math.floor(c/6e4),":",Math.floor(c%6e4/1e3).toString().padStart(2,"0")]})," (15 minutes per heart)"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{onClick:a,className:"w-full py-3 bg-rose-500 hover:bg-rose-600 text-white font-bold rounded-full",children:"Exit Quiz"}),e.jsx(ze,{onClick:()=>{Ke(!1)},className:"w-full py-3 bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold rounded-full",children:"Review Lessons"})]})]})}),document.getElementById("modal-root")),e.jsx($e,{children:tt&&M&&e.jsx(v.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[200] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-white/95 backdrop-blur-xl border border-slate-200 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.15)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-[0_10px_20px_rgba(0,0,0,0.15)]"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest text-emerald-500",children:"Correct!"}),e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-full font-bold border border-emerald-500/30",children:e.jsxs("span",{children:["+ ",(je[r]||[]).length>0?5:10," XP"]})}),Se==="streak"&&e.jsxs("div",{className:"flex items-center gap-2 bg-orange-500/20 text-orange-400 px-4 py-1.5 rounded-full text-sm font-bold border border-orange-500/30",children:[e.jsx(As,{size:14})," Streak Started!"]}),Se==="multiplier2"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×2!"]}),Se==="multiplier3"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×3!"]})]})]})},"round-result")}),e.jsxs("div",{className:"fixed inset-0 z-[100] h-screen w-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsxs("header",{className:"relative shrink-0 flex flex-col items-center justify-start px-4 pt-4 sm:pt-6 pb-6 z-[60] shadow-md overflow-hidden bg-gradient-to-r from-purple-600 to-indigo-400 rounded-b-[32px] sm:rounded-b-[40px] min-h-[110px] sm:min-h-[130px]",children:[e.jsxs("div",{className:"absolute inset-0 z-0 pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-0 w-64 h-64 bg-white opacity-10 rounded-full -translate-x-1/2 -translate-y-1/2 blur-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-80 h-80 bg-white opacity-10 rounded-full translate-x-1/3 translate-y-1/3 blur-3xl"})]}),e.jsxs("div",{className:"w-full max-w-7xl flex items-start justify-between relative z-10 mb-4 sm:mb-6",children:[e.jsx("div",{className:"flex-1 flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-1 bg-white/20 px-3 py-1.5 rounded-full text-white text-sm font-bold",children:[e.jsx(ft,{size:16})," ",Hr(we)]})}),e.jsxs("div",{className:"relative flex items-center justify-center bg-purple-900/40 backdrop-blur-md px-6 sm:px-8 py-3 rounded-full border border-white/10 gap-3 sm:gap-4 shadow-inner",children:[e.jsx("div",{className:"w-3 h-3 sm:w-4 sm:h-4 rounded-full bg-yellow-400 shrink-0 shadow-[0_0_10px_rgba(250,204,21,0.6)]"}),e.jsxs("div",{className:"flex flex-col items-start justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] font-black text-purple-200 uppercase tracking-widest leading-none mb-1",children:"Try It Yourself!"}),e.jsx("span",{className:"font-bold text-white tracking-wide text-base sm:text-lg leading-none truncate max-w-[200px] sm:max-w-[300px]",children:t.title||t.subject})]})]}),e.jsxs("div",{className:"flex-1 flex justify-end gap-2 sm:gap-3 relative pointer-events-auto",children:[e.jsx("button",{onClick:()=>F(!T),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:T?e.jsx(Fs,{size:20}):e.jsx(Ds,{size:20})}),e.jsx("button",{onClick:dt,className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:ee?e.jsx(Rs,{size:20}):e.jsx($s,{size:20})}),e.jsx("button",{onClick:a,className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:e.jsx(De,{size:20})})]})]}),e.jsx("div",{className:"w-full max-w-[50rem] flex items-center justify-center px-4 z-10",children:e.jsx("div",{className:"w-full flex items-center gap-2 sm:gap-3",children:ie.map((S,h)=>{let H=h<=r?"bg-white shadow-[0_0_8px_rgba(255,255,255,0.8)]":"bg-white/20";return e.jsx("div",{className:`h-1.5 sm:h-2 rounded-full flex-1 transition-all ${H}`},h)})})})]}),e.jsxs("div",{className:"w-full max-w-[54rem] mx-auto shrink-0 flex items-center justify-between px-4 sm:px-6 py-2 sm:py-3 z-[50] relative mt-8",children:[e.jsx("button",{onClick:()=>ke(S=>Math.max(0,S-1)),disabled:L===0,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${L===0?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(Yt,{size:24})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 sm:gap-5 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-rose-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5 object-contain"})," ",ve]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-yellow-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Keys",className:"w-5 h-5 object-contain"})," ",Ve]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 px-3 py-1.5 pl-5 sm:pl-6 rounded-full bg-white shadow-md border border-slate-200/60",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_streak.png",alt:"Streak",className:"w-5 h-5 object-contain"})," ",y]}),e.jsxs("div",{className:"bg-emerald-100 text-emerald-800 px-4 py-1.5 rounded-full font-bold text-sm sm:text-base shadow-inner border border-emerald-200/50",children:["+ ",Ue," pts"]})]})]}),e.jsx("button",{onClick:()=>ke(S=>Math.min(r,S+1)),disabled:L>=r,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${L>=r?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(ht,{size:24})})]}),e.jsx("main",{className:"flex-1 overflow-y-auto w-full px-4 sm:px-6 pt-0 pb-6 flex flex-col items-center relative z-10",children:e.jsxs(v.div,{initial:{opacity:0,x:20},animate:wt?{x:[-10,10,-10,10,0],scale:[1,1.01,1],opacity:1}:{opacity:1,x:0},className:"w-full max-w-3xl flex flex-col mt-2",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-lg border-t-[6px] border-purple-500 p-6 sm:p-8 text-center flex flex-col items-center mb-6 w-full relative overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-100 text-slate-600 px-4 py-1.5 rounded-full text-[11px] sm:text-xs font-black uppercase tracking-widest mb-4 flex items-center shadow-sm",children:["Q",L+1," of ",ie.length]}),e.jsx("h2",{className:"text-xl sm:text-2xl font-extrabold text-[#0a1628] leading-tight w-full",children:se.question.includes("___")?e.jsx("span",{children:se.question.split("___").map((S,h,H)=>e.jsxs(Ae.Fragment,{children:[S,hg(B.target.value),onKeyDown:B=>{B.key==="Enter"&&!d&&jt()},className:`inline-block w-24 mx-2 border-b-4 outline-none text-center bg-transparent font-bold ${oe?"border-slate-300 text-slate-500":"border-[#7C3AED] text-[#7C3AED] focus:border-[#75D06A]"}`})]},h))}):se.question})]}),e.jsxs("div",{className:"w-full flex flex-col items-center",children:[se.questionType==="multiple_choice"||!se.questionType?e.jsx("div",{className:"w-full grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-5",children:(se.options||[]).map((S,h)=>{const H=je[r]||[],B=H.includes(S),Q=H.length,Ce=(se.options||[]).length-1,Ee=Ce>0&&Q>=Ce;let he="bg-white hover:bg-slate-50 border-transparent text-slate-700 hover:border-slate-200",Fe=!1;if(Ee){Fe=!0;const be=se.options?.[se.correctAnswer];S===be?he="bg-emerald-50 border-emerald-400 text-emerald-800":Y[L]?.answer===String(h)?he="bg-rose-50 border-rose-400 text-rose-800 opacity-80":he="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through"}else if(B)he="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through cursor-not-allowed";else if(oe){const be=h===se.correctAnswer,xe=L===r&&(x===h||ge===h)||L{Fe||oe||B||Mt(h)},className:`p-4 sm:p-5 rounded-2xl shadow-sm border-[3px] font-extrabold text-base sm:text-lg text-left transition-all flex items-center justify-between ${he} ${Fe||oe||B?"cursor-default":"hover:shadow-md hover:-translate-y-0.5 active:translate-y-0"}`,children:[e.jsx("span",{className:"truncate pr-4",children:S}),B&&e.jsx(Ht,{size:20,className:"text-slate-400 shrink-0"}),oe&&h===se.correctAnswer&&e.jsx(zt,{size:22,className:"text-emerald-500 shrink-0"}),oe&&x===h&&h!==se.correctAnswer&&e.jsx(Ht,{size:22,className:"text-rose-500 shrink-0"})]},h)})}):e.jsx("div",{className:"w-full max-w-2xl mx-auto flex flex-col gap-4",children:!se.question.includes("___")&&e.jsx("input",{type:"text",disabled:oe,value:L===r?b:"",onChange:S=>g(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!d&&jt()},placeholder:"Type your answer here...",className:`w-full p-4 sm:p-5 rounded-2xl border-[3px] font-extrabold text-lg text-center outline-none transition-colors ${oe?M?"border-emerald-400 text-emerald-700 bg-emerald-50":"border-rose-400 text-rose-700 bg-rose-50":"border-slate-200 focus:border-[#7C3AED] bg-white text-slate-800"}`})}),oe&&N&&e.jsxs("div",{className:"w-full max-w-3xl mt-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:se.topic||t?.subject||"General Math"}),e.jsxs("p",{className:"text-sm text-slate-500",children:["Question ",L+1," Explanation"]})]}),e.jsx("img",{src:"/icons/default-module-avatar.png",alt:"Module Avatar",className:"w-12 h-12 rounded-full object-cover border-2 border-slate-200"})]}),oe&&N&&e.jsx(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"w-full mt-4 space-y-4 max-w-3xl",children:e.jsxs("div",{className:`border-2 rounded-2xl p-5 flex items-start gap-4 ${(L===r?M:Y[L]?.correct)?"bg-emerald-50 border-emerald-200":"bg-rose-50 border-rose-200"}`,children:[(L===r?M:Y[L]?.correct)?e.jsx(zt,{size:28,className:"text-emerald-500 shrink-0 mt-0.5"}):e.jsx(Ht,{size:28,className:"text-rose-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`font-extrabold text-lg mb-1 ${(L===r?M:Y[L]?.correct)?"text-emerald-700":"text-rose-700"}`,children:(L===r?M:Y[L]?.correct)?"Correct!":"Incorrect"}),e.jsx("p",{className:`text-base leading-relaxed ${(L===r?M:Y[L]?.correct)?"text-emerald-800":"text-rose-800"}`,children:se.explanation||`Correct Answer: ${se.correctAnswerText||se.options?.[se.correctAnswer]}`})]})]})})]})]},L)}),e.jsx("footer",{className:"shrink-0 relative z-[60] flex flex-col items-center justify-center p-4 sm:p-6 bg-gradient-to-r from-purple-600 to-indigo-400 rounded-t-[32px] sm:rounded-t-[40px] shadow-[0_-10px_40px_rgba(0,0,0,0.15)]",children:(()=>{const S=(je[r]||[]).length,h=(ue.options||[]).length-1,H=h>0&&S>=h;return H||oe&&!M?e.jsxs("button",{onClick:ct,className:"bg-orange-500 hover:bg-orange-600 text-white font-extrabold text-lg px-8 py-4 rounded-full flex items-center justify-center gap-3 shadow-xl hover:scale-[1.02] active:scale-[0.98] transition-all w-full max-w-md mx-auto",children:[r{const Q=st>0&&!d&&!H;return e.jsxs("button",{onClick:pe,disabled:!Q,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Key",className:"w-5 h-5 object-contain"})," Hint"]})})(),oe&&e.jsxs("button",{onClick:()=>_(!0),className:"bg-white hover:bg-slate-50 text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(Je,{size:20})," Explain"]}),e.jsx("button",{onClick:()=>f(Q=>!Q),className:`w-11 h-11 sm:w-12 sm:h-12 rounded-full flex items-center justify-center shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200 ${P?"bg-purple-100 text-purple-600 border-purple-300":"bg-white hover:bg-slate-50 text-slate-700"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"6",y2:"6"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M8 14h.01"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M8 18h.01"}),e.jsx("line",{x1:"16",x2:"16",y1:"14",y2:"18"})]})})]}):Lke(r),className:"bg-white text-slate-700 font-extrabold text-lg px-6 sm:px-8 py-3 sm:py-4 rounded-full inline-flex items-center gap-2 sm:gap-3 shadow-lg hover:bg-slate-50 transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(ht,{size:20}),"Back to Current Question"]}):null})()})]})]})};function Dr(t,a){const l={"Pre-Calculus":["What is the domain of the function f(x) = √(x - 2)?","Solve for x: 2^x = 16","What is the period of the function y = sin(2x)?","Find the inverse of f(x) = 3x + 5","What is the value of log₂(32)?","Simplify: (x² - 9) / (x - 3)","What is the range of f(x) = |x| - 3?","If f(x) = 2x + 1 and g(x) = x², find f(g(2)).","What is the amplitude of y = 3cos(x)?","Solve: log₃(x) = 4"],"General Mathematics":["Simplify: (2x + 3)(x - 4)","What is 15% of 240?","Solve: 3x + 7 = 22","What is the value of 5! (5 factorial)?","Convert 0.75 to a fraction","What is 25% of 360?","Simplify: 12/18","What is the GCD of 24 and 36?","Convert 3/8 to a decimal","If a shirt costs $40 and is 20% off, what is the sale price?","What is 2/3 + 1/4?","Calculate: 15% tip on a $80 bill","Simplify: 45/60","What fraction is equivalent to 0.125?","If 30% of a number is 45, what is the number?"],"Statistics and Probability":["What is the probability of rolling a 6 on a fair die?","Calculate the mean of: 4, 7, 9, 12, 15","What is the median of: 2, 5, 8, 11, 14?","In a bag with 5 red and 3 blue balls, what is P(red)?","What is the range of: 10, 15, 20, 25, 30?","What is the mode of: 3, 5, 5, 7, 8, 5, 9?","What is the standard deviation concept?","P(A) = 0.3, P(B) = 0.5, events independent. P(A and B) = ?","What is the median of: 4, 7, 10, 13?","How many ways can you arrange 3 books?"],"Basic Calculus":["Find the derivative of f(x) = 3x²","What is the limit of (x² - 4)/(x - 2) as x → 2?","Integrate: ∫ 2x dx","Find f'(x) if f(x) = 5x³ - 2x","What is the derivative of sin(x)?","Find the derivative of f(x) = eˣ + 3x","What is ∫ cos(x) dx?","Find the derivative of f(x) = ln(x)","What is the limit of 1/x as x → ∞?","Find f'(x) if f(x) = x⁴ - 2x² + 1"]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function Dt(t){const a=t.toLowerCase();return a.includes("pre-calc")||a.includes("pre calc")||a.includes("precalc")?"Pre-Calculus":a.includes("statistic")||a.includes("probability")?"Statistics and Probability":a.includes("calculus")&&!a.includes("pre")?"Basic Calculus":a.includes("general")||a.includes("math")||a.includes("algebra")||a.includes("fraction")||a.includes("percent")||a.includes("ratio")||a.includes("geometry")?"General Mathematics":a.includes("derivative")||a.includes("integral")||a.includes("limit")?"Basic Calculus":a.includes("trig")||a.includes("function")||a.includes("log")?"Pre-Calculus":a.includes("mean")||a.includes("median")||a.includes("data")?"Statistics and Probability":"General Mathematics"}function Rr(t,a){const l={"Pre-Calculus":[["x ≥ 2","x ≤ 2","x ≥ 0","All real numbers"],["x = 2","x = 4","x = 8","x = 16"],["π","2π","π/2","4π"],["f⁻¹(x) = (x - 5)/3","f⁻¹(x) = 3x - 5","f⁻¹(x) = x/3 - 5","f⁻¹(x) = (x + 5)/3"],["4","5","6","7"],["x + 3","x - 3","x² + 3","(x + 3)(x - 3)"],["y ≥ -3","y ≥ 0","All real numbers","y > -3"],["9","5","7","3"],["1","2","3","1/3"],["12","27","64","81"]],"General Mathematics":[["2x² - 5x - 12","2x² + 5x - 12","2x² - 8x + 12","2x² - 5x + 12"],["36","32","28","24"],["x = 5","x = 4","x = 6","x = 7"],["120","24","60","720"],["3/4","1/2","2/3","4/5"],["90","80","100","72"],["2/3","3/4","4/6","6/9"],["12","6","8","4"],["0.375","0.38","0.35","0.325"],["$32","$28","$30","$36"],["11/12","3/7","5/6","2/3"],["$12","$10","$15","$8"],["3/4","2/3","4/5","9/12"],["1/8","1/4","1/5","1/6"],["150","135","120","160"]],"Statistics and Probability":[["1/6","1/3","1/2","2/3"],["9.4","8.5","10.2","7.8"],["8","9","7","10"],["5/8","3/8","1/2","2/5"],["20","15","25","30"],["5","3","7","8"],["Spread of data from the mean","The highest value","The average","The middle value"],["0.15","0.8","0.35","0.2"],["8.5","7","10","9"],["6","3","9","12"]],"Basic Calculus":[["6x","3x","9x²","6x²"],["4","2","0","undefined"],["x² + C","2x² + C","x²/2 + C","2x + C"],["15x² - 2","15x² - 2x","5x² - 2","15x - 2"],["cos(x)","-cos(x)","tan(x)","-sin(x)"],["eˣ + 3","eˣ + 3x","xeˣ + 3","eˣ"],["sin(x) + C","-sin(x) + C","tan(x) + C","-cos(x) + C"],["1/x","x","ln(x)","-1/x²"],["0","1","∞","undefined"],["4x³ - 4x","4x³ - 2x","x³ - 4x","4x⁴ - 4x²"]]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function $r(t,a){const l={"Pre-Calculus":[0,1,0,0,1,0,0,0,2,3],"General Mathematics":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Statistics and Probability":[0,0,0,0,0,0,0,0,0,0],"Basic Calculus":[0,0,0,0,0,0,0,0,0,0]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function Br(t,a,l){const o={"Pre-Calculus":["The expression under the square root must be non-negative: x - 2 ≥ 0, so x ≥ 2.","Since 2⁴ = 16, we get x = 4.","The period of sin(kx) is 2π/k. Here k = 2, so period = 2π/2 = π.","To find the inverse: y = 3x + 5 → x = 3y + 5 → y = (x - 5)/3.","Since 2⁵ = 32, log₂(32) = 5.","(x² - 9)/(x - 3) = (x+3)(x-3)/(x-3) = x + 3 (for x ≠ 3).","The absolute value |x| ≥ 0 for all x, so |x| - 3 ≥ -3. The range is y ≥ -3.","g(2) = 4, then f(4) = 2(4) + 1 = 9.","The amplitude of y = Acos(x) is |A|. Here A = 3, so amplitude = 3.","log₃(x) = 4 means 3⁴ = x, so x = 81."],"General Mathematics":["(2x + 3)(x - 4) = 2x² - 8x + 3x - 12 = 2x² - 5x - 12","15% of 240 = 0.15 × 240 = 36","3x + 7 = 22 → 3x = 15 → x = 5","5! = 5 × 4 × 3 × 2 × 1 = 120","0.75 = 75/100 = 3/4 after simplifying by dividing both by 25","25% of 360 = 0.25 × 360 = 90","12/18 = (12÷6)/(18÷6) = 2/3","Factors of 24: {1,2,3,4,6,8,12,24}. Factors of 36: {1,2,3,4,6,9,12,18,36}. GCD = 12","3 ÷ 8 = 0.375","20% off $40 = $40 × 0.80 = $32","2/3 + 1/4 = 8/12 + 3/12 = 11/12","15% of $80 = 0.15 × 80 = $12","45/60 = (45÷15)/(60÷15) = 3/4","0.125 = 125/1000 = 1/8","30% × N = 45 → N = 45/0.30 = 150"],"Statistics and Probability":["A fair die has 6 outcomes, each equally likely. P(6) = 1/6.","Mean = (4 + 7 + 9 + 12 + 15) / 5 = 47/5 = 9.4","Sorted: 2, 5, 8, 11, 14. The middle value is 8.","P(red) = 5/(5+3) = 5/8","Range = max - min = 30 - 10 = 20","The value 5 appears 3 times, more than any other value. Mode = 5.","Standard deviation measures how spread out data points are from the mean.","For independent events: P(A and B) = P(A) × P(B) = 0.3 × 0.5 = 0.15","For even-count dataset {4,7,10,13}: median = (7+10)/2 = 8.5","3 books can be arranged in 3! = 3 × 2 × 1 = 6 ways."],"Basic Calculus":["Using the power rule: d/dx[3x²] = 3 × 2x = 6x","Factor: (x²-4)/(x-2) = (x+2)(x-2)/(x-2) = x+2. As x→2: 2+2 = 4","∫ 2x dx = 2 × x²/2 + C = x² + C","f'(x) = 5 × 3x² - 2 = 15x² - 2","The derivative of sin(x) is cos(x). This is a fundamental trigonometric derivative.","d/dx[eˣ + 3x] = eˣ + 3. The derivative of eˣ is eˣ and of 3x is 3.","∫ cos(x) dx = sin(x) + C. Integration is the reverse of differentiation.","The derivative of ln(x) is 1/x. This is a fundamental logarithmic derivative.","As x → ∞, 1/x approaches 0. The function gets infinitely close to zero.","f'(x) = 4x³ - 4x using the power rule on each term."]},n=Dt(t),r=o[n]||o["General Mathematics"];return r[a%r.length]}function Hr(t){const a=Math.floor(t/60),l=t%60;return`${a}:${l.toString().padStart(2,"0")}`}const zs={common:"bg-slate-100 text-slate-500",rare:"bg-blue-50 text-blue-500",epic:"bg-amber-50 text-amber-500"},_s=["bg-[#1FA7E1]/80 text-white","bg-[#9956DE]/80 text-white","bg-[#FFB356]/90 text-white","bg-[#7274ED]/80 text-white","bg-[#1FA7E1]/80 text-white","bg-[#9956DE]/80 text-white","bg-gradient-to-r from-[#FFB356] to-[#FF8C00] text-white"],Qr=({isOpen:t,onClose:a,onClaim:l,weekRewards:o,todayReward:n,canClaim:r,isClaiming:i,claimedDays:x,currentDayIndex:p,timeUntilReset:b})=>{const[g,M]=s.useState(!1);if(!t)return null;const z=()=>{if(!r||g)return;M(!0),n?.rarity==="epic"?xs({particleCount:150,spread:80,origin:{y:.6},colors:["#FFD700","#FFA500","#FF8C00","#FF6B6B","#4ade80"]}):xs({particleCount:100,spread:70,origin:{y:.6},colors:["#FFD700","#FFA500","#FF8C00"]}),setTimeout(()=>{M(!1),l()},1200)},d=y=>y+1,A=y=>y===p,N=y=>x.includes(y),_=y=>y>p,R=o.slice(0,6),m=o[6];return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-8",children:[e.jsx($e,{children:t&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-slate-900/60 backdrop-blur-sm",onClick:a})}),e.jsxs(v.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"relative w-full max-w-[420px] bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] shadow-2xl flex flex-col items-center p-5 overflow-visible",children:[e.jsxs("div",{className:"absolute -top-6 w-[85%] h-12 bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] rounded-xl shadow-lg flex items-center justify-center z-20",children:[e.jsx("div",{className:"absolute -left-2.5 -z-10 w-5 h-8 bg-[#633299] rounded-l-full rotate-12 top-1.5"}),e.jsx("div",{className:"absolute -right-2.5 -z-10 w-5 h-8 bg-[#10709b] rounded-r-full -rotate-12 top-1.5"}),e.jsx("h2",{className:"text-white font-black text-lg tracking-wide uppercase drop-shadow-sm font-display",children:"Daily Rewards"})]}),e.jsx("button",{onClick:a,className:"absolute -right-3 -top-3 w-8 h-8 bg-white hover:bg-slate-100 border border-slate-200 text-slate-500 hover:text-slate-800 rounded-full flex items-center justify-center z-30 shadow-md transition-transform hover:scale-105 active:scale-95",children:e.jsx(De,{size:16,strokeWidth:3})}),e.jsxs("div",{className:"mt-6 mb-2 text-center w-full",children:[e.jsx("h3",{className:"text-xl font-bold text-slate-800 font-display mt-2",children:"Welcome Back!"}),e.jsx("p",{className:"text-slate-500 font-medium text-xs mt-0.5",children:"Claim your daily reward for today."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 w-full mb-5 relative z-10",children:[R.map((y,j)=>{const E=d(j),k=N(j),U=A(j),O=_(j);return e.jsxs("div",{className:`relative rounded-xl flex flex-col overflow-hidden border-[1.5px] transition-all ${U&&!k?"border-amber-400 shadow-[0_0_15px_rgba(251,191,36,0.25)] scale-105 z-10 bg-amber-50":k?"border-[#dde3eb] bg-slate-200/50":"border-[#dde3eb] bg-white"}`,children:[e.jsxs("div",{className:`py-0.5 text-center font-black text-[10px] uppercase tracking-wider ${U&&!k?"bg-amber-400 text-amber-900":_s[j]}`,children:["Day ",E]}),e.jsx("div",{className:"absolute top-5 right-1 z-10",children:e.jsx("span",{className:`text-[8px] font-bold uppercase px-1 rounded ${zs[y.rarity]}`,children:y.rarity})}),e.jsxs("div",{className:"flex-1 p-2 flex flex-col items-center justify-center relative min-h-[75px]",children:[k&&e.jsxs(v.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",bounce:.5},className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-rose-200/50"})}),e.jsxs("div",{className:"relative w-14 h-14 rounded-full border-[3px] border-rose-500 bg-rose-100 flex items-center justify-center transform -rotate-12 shadow-lg",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"Claimed",className:"w-10 h-10 object-contain drop-shadow-md"}),e.jsx("div",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 bg-rose-500 rounded-md px-2 py-0.5 border-2 border-rose-300 shadow-md",children:e.jsx("span",{className:"text-[9px] font-black text-white uppercase tracking-wider leading-none whitespace-nowrap",children:"Claimed"})})]})]}),O&&e.jsx("div",{className:"absolute top-1 right-1 bg-slate-200 rounded-full p-0.5 z-10",children:e.jsx(Vt,{size:8,className:"text-slate-400"})}),e.jsxs("div",{className:`flex flex-col items-center transition-all w-full ${k?"opacity-30 grayscale":""}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center border-2 mb-1",style:{backgroundColor:y.color+"20",borderColor:y.color+"40"},children:e.jsx("span",{className:"text-lg",children:y.icon})}),e.jsx("div",{className:`font-black text-xs leading-none mt-0.5 text-center ${U?"text-amber-600":k?"text-slate-500":"text-slate-600"}`,children:y.label})]})]})]},y.id)}),m&&e.jsxs("div",{className:`col-span-3 relative rounded-xl flex flex-col overflow-hidden border-[1.5px] transition-all mt-1 ${A(6)&&!N(6)?"border-amber-400 shadow-[0_0_20px_rgba(251,191,36,0.3)] scale-[1.02] z-10 bg-amber-50":N(6)?"border-[#dde3eb] bg-slate-200/50":"border-[#dde3eb] bg-white"}`,children:[e.jsx("div",{className:`py-1 text-center font-black text-[10px] uppercase tracking-widest ${A(6)&&!N(6)?"bg-amber-400 text-amber-900":_s[6]}`,children:"Day 7 • Epic Reward"}),e.jsx("div",{className:"absolute top-6 right-2 z-10",children:e.jsx("span",{className:`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded ${zs[m.rarity]}`,children:m.rarity})}),e.jsxs("div",{className:"flex items-center justify-center gap-5 p-3 relative",children:[N(6)&&e.jsxs(v.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",bounce:.5},className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-rose-200/50"})}),e.jsxs("div",{className:"relative w-20 h-20 rounded-full border-[4px] border-rose-500 bg-rose-100 flex items-center justify-center transform rotate-12 shadow-lg",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"Claimed",className:"w-14 h-14 object-contain drop-shadow-md"}),e.jsx("div",{className:"absolute -bottom-3 left-1/2 -translate-x-1/2 bg-rose-500 rounded-md px-2.5 py-1 border-2 border-rose-300 shadow-md",children:e.jsx("span",{className:"text-[10px] font-black text-white uppercase tracking-wider leading-none whitespace-nowrap",children:"Claimed"})})]})]}),e.jsxs("div",{className:`flex items-center justify-center gap-5 w-full transition-all ${N(6)?"opacity-30 grayscale":""}`,children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center border-2 shadow-sm mb-0.5",style:{backgroundColor:m.color+"20",borderColor:m.color+"40"},children:e.jsx("span",{className:"text-2xl",children:m.icon})}),e.jsx("span",{className:`font-black text-sm ${A(6)?"text-amber-600":"text-slate-600"}`,children:m.label})]}),m.rarity==="epic"&&e.jsxs("div",{className:"relative mt-1",children:[e.jsx("div",{className:"w-14 h-14 bg-purple-50 rounded-xl flex items-center justify-center border-2 border-purple-200 shadow-sm",children:e.jsx("span",{className:"text-3xl drop-shadow-md",children:"🎁"})}),e.jsx("div",{className:"absolute -right-5 -bottom-4 w-14 h-14 bg-white rounded-xl p-1 border-2 border-amber-300 shadow-lg transform rotate-[-5deg]",children:e.jsx("img",{src:"/avatar/crown_thumbnail.png",alt:"Crown",className:"w-full h-full object-contain drop-shadow-md"})})]})]})]})]})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-xs text-slate-400",children:[e.jsx(Ya,{size:14}),e.jsx("span",{className:"font-mono font-medium",children:b}),e.jsx("span",{children:"until next reset"})]}),e.jsx(v.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:z,disabled:!r||i||g,className:`w-[85%] py-3 rounded-full font-black text-base tracking-wide uppercase shadow-lg transition-all mt-2 ${!r||i||g?"bg-slate-200 text-slate-400 cursor-not-allowed border border-slate-300":"bg-gradient-to-r from-[#FFB356] to-[#FF8C00] text-white hover:from-[#FFA500] hover:to-[#FF7F00] border-b-4 border-[#e67e00]"}`,children:i||g?"Claiming...":r?"Claim!":"Claimed"})]})]})};function qr(t){const[a,l]=s.useState({difficulty:"normal",loading:!0});return s.useEffect(()=>{if(!t){l({difficulty:"normal",loading:!1});return}const o=bt(We,"users",t);return Gt(o,r=>{if(!r.exists()){l({difficulty:"normal",loading:!1});return}const x=r.data()?.moduleDifficulty||"normal";l({difficulty:["normal","easier","remedial"].includes(x)?x:"normal",loading:!1})},r=>{console.error("[useModuleDifficulty] snapshot error:",r),l({difficulty:"normal",loading:!1})})},[t]),a}function Or(t,a){return a==="normal"?t:a==="easier"?t.filter(l=>{const o=l.tags||[],n=l.difficulty||"";return o.some(r=>["foundation","basic","introductory"].includes(r.toLowerCase()))||["foundation","basic","introductory"].includes(n.toLowerCase())||!o.includes("advanced")&&!n.toLowerCase().includes("advanced")}):a==="remedial"?t.filter(l=>{const o=l.tags||[],n=l.difficulty||"";return o.some(r=>["remedial","review","catch-up"].includes(r.toLowerCase()))||["remedial","review","catch-up"].includes(n.toLowerCase())}):t}const Wr=new Set([7,14,30,60,100]),St={lastClaimedDate:"",lastClaimedWeekSeed:0,claimedDays:[],currentStreak:0,longestStreak:0,totalClaimed:0,hintTokens:0,streakShields:0,activeMultiplier:null};function Ur(t){if(t<=0)return"00:00:00";const a=Math.floor(t/1e3),l=Math.floor(a/3600),o=Math.floor(a%3600/60),n=a%60;return`${String(l).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function Xr(){const t=Jt();return t.setDate(t.getDate()-1),Zt(t)}function Os(t){return t?new Date(t.expiresAt).getTime()>Date.now():!1}function Ws(t){return bt(We,"users",t,"dailyRewards",t)}function Gr(t){return bt(We,"users",t)}async function Ms(t){try{const a=Ws(t),l=await Ot(a);if(!l.exists())return{...St};const o=l.data(),n=es();return o.lastClaimedWeekSeed&&o.lastClaimedWeekSeed!==n?{...o,claimedDays:[],lastClaimedWeekSeed:n}:{...St,...o,activeMultiplier:o.activeMultiplier&&Os(o.activeMultiplier)?o.activeMultiplier:null}}catch(a){return console.error("[dailyRewardService] Error getting state:",a),{...St}}}function Vr(t){const a=Zt();return t.lastClaimedDate!==a}async function Yr(t){const a=Zt(),l=es(),o=ts(),r=ss()[o];if(!r)throw new Error(`No reward found for day index ${o}`);try{const i=await Vs(We,async p=>{const b=Ws(t),g=Gr(t),M=await p.get(b),z=await p.get(g);let d;if(M.exists()?d={...St,...M.data()}:(d={...St,lastClaimedWeekSeed:l},p.set(b,d)),d.lastClaimedWeekSeed!==l&&(d.claimedDays=[],d.lastClaimedWeekSeed=l),d.lastClaimedDate===a)return{code:"ALREADY_CLAIMED",state:d};let A=d.currentStreak,N=!1;if(!d.lastClaimedDate||d.currentStreak===0)A=1;else{const j=Xr();d.lastClaimedDate===j?A=d.currentStreak+1:d.streakShields>0?(d.streakShields-=1,A=d.currentStreak+1,N=!0):A=1}const _=Math.max(d.longestStreak,A);let R=0,m=1;switch(r.type){case"xp":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;m=Os(d.activeMultiplier)?d.activeMultiplier?.multiplier??1:1,R=Math.floor(j*m);break}case"hint_token":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;d.hintTokens+=j;break}case"streak_shield":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;d.streakShields+=j;break}case"xp_multiplier":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||60,E=r.id.includes("2")?2:1.5,k=new Date;k.setMinutes(k.getMinutes()+j),d.activeMultiplier={multiplier:E,expiresAt:k.toISOString()};break}case"badge_unlock":break}const y=[...d.claimedDays,o];return d.lastClaimedDate=a,d.currentStreak=A,d.longestStreak=_,d.totalClaimed+=1,p.set(b,d,{merge:!0}),z.exists()&&p.update(g,{hintTokens:d.hintTokens,streakShields:d.streakShields,activeMultiplier:d.activeMultiplier,lastClaimedDate:d.lastClaimedDate,updatedAt:Ys()}),{code:"SUCCESS",state:d,newClaimedDays:y,newStreak:A,newLongestStreak:_,xpAwarded:R,multiplierApplied:m,streakPreserved:N}});if(i.code==="ALREADY_CLAIMED")return{success:!1,reward:r,dayIndex:o,streakAfter:i.state.currentStreak,longestStreakAfter:i.state.longestStreak,hintTokensAfter:i.state.hintTokens,streakShieldsAfter:i.state.streakShields,streakPreserved:!1,xpAwarded:0,multiplierApplied:1,isMilestone:!1,error:"Already claimed today"};if(i.xpAwarded>0)try{await oa(t,i.xpAwarded,"daily_reward",`Daily Reward Day ${o+1}! +${i.xpAwarded} XP`)}catch(p){console.error("[dailyRewardService] Error awarding XP:",p)}if(r.type==="badge_unlock"&&typeof r.value=="string")try{await Ls(t,r.value)}catch(p){console.error("[dailyRewardService] Error unlocking avatar item:",p)}const x=Wr.has(i.newStreak);return{success:!0,reward:r,dayIndex:o,streakAfter:i.newStreak,longestStreakAfter:i.newLongestStreak,hintTokensAfter:i.state.hintTokens,streakShieldsAfter:i.state.streakShields,streakPreserved:i.streakPreserved,xpAwarded:i.xpAwarded,multiplierApplied:i.multiplierApplied,isMilestone:x}}catch(i){throw console.error("[dailyRewardService] Error claiming daily reward:",i),i}}function Kr(t){const[a,l]=s.useState(null),[o,n]=s.useState(!1),[r,i]=s.useState(!1),[x,p]=s.useState(null),[b,g]=s.useState(null),[M,z]=s.useState("00:00:00"),d=s.useRef(null),A=s.useMemo(()=>ss(),[]),N=s.useMemo(()=>ar(),[]),_=s.useCallback(async()=>{if(!t){l(null);return}try{g(null);const E=await Ms(t);l(E)}catch(E){const k=E instanceof Error?E.message:"Failed to load rewards";g(k),console.error("[useDailyReward] refresh error:",E)}},[t]);s.useEffect(()=>{_()},[_]),s.useEffect(()=>{const E=()=>{const U=er().getTime()-Date.now();z(Ur(U))};return E(),d.current=setInterval(E,1e3),()=>{d.current&&(clearInterval(d.current),d.current=null)}},[]);const R=s.useMemo(()=>!a||o?!1:Vr(a),[a,o]),m=s.useMemo(()=>!a?.activeMultiplier||new Date(a.activeMultiplier.expiresAt).getTime()<=Date.now()?null:a.activeMultiplier,[a?.activeMultiplier]),y=s.useCallback(async()=>{if(!(!t||!R)){n(!0),g(null);try{const E=await Yr(t);if(p(E),E.success){i(!0);const k=await Ms(t);l(k)}else g(E.error||"Claim failed")}catch(E){const k=E instanceof Error?E.message:"Claim failed";g(k),console.error("[useDailyReward] claim error:",E)}finally{n(!1)}}},[t,R]),j=s.useCallback(()=>{i(!1)},[]);return{weekRewards:A,todayReward:N,canClaim:R,isClaiming:o,claimedDays:a?.claimedDays??[],currentStreak:a?.currentStreak??0,longestStreak:a?.longestStreak??0,totalClaimed:a?.totalClaimed??0,hintTokens:a?.hintTokens??0,streakShields:a?.streakShields??0,activeMultiplier:m,timeUntilReset:M,showModal:r,lastClaimResult:x,error:b,claim:y,dismissModal:j,refresh:_}}const Zr=["all","Q1","Q2","Q3","Q4"],$l=({onEarnXP:t,atRiskSubjects:a=[],priorityTopics:l=[],initialModuleId:o=null,isInQuizMode:n=!1,setIsInQuizMode:r,hasCompletedDiagnostic:i=!1})=>{const{userProfile:x,currentUser:p}=It(),[b,g]=s.useState("modules"),M=x,z=M?.grade,d=ca(z);ka(d);const[A,N]=s.useState(""),[_,R]=s.useState("all"),[m,y]=s.useState("all"),[j,E]=s.useState("all"),[k,U]=s.useState(!1),[O,Y]=s.useState(null),[$,te]=s.useState(null),de=s.useMemo(()=>{const c=M?.learnerCurriculumAssignments?.subjects??M?.assignedSubjects??M?.curriculumAssignedSubjects??[];return Array.isArray(c)?c:[]},[M]),{difficulty:_e}=qr(p?.uid||null),re=s.useMemo(()=>{const c=da(d,de);return Or(c,_e)},[d,de,_e]),W=o&&re.find(c=>c.id===o)||null,[Z,ge]=s.useState(W),[K,we]=s.useState(null),[Me,I]=s.useState(null),[u,P]=s.useState(!1),[f,T]=s.useState(null),[F,ee]=s.useState(!1),[ne,Be]=s.useState([]),[gt,Ue]=s.useState(!1);s.useEffect(()=>{if(b!=="teacher_uploaded"||!We)return;Ue(!0);const c=Gt(Ks(Js(We,"modules"),Zs("moduleType","==","teacher_uploaded")),D=>{const X=D.docs.map(le=>({...le.data(),moduleId:le.id}));Be(X),Ue(!1)},D=>{console.error("Error fetching teacher modules:",D),Ue(!1)});return()=>c()},[b]);const[et,je]=s.useState(!1),{weekRewards:nt,todayReward:_t,canClaim:Xe,isClaiming:wt,claimedDays:Ge,timeUntilReset:tt,claim:it,lastClaimResult:He}=Kr(x?.uid??null);s.useEffect(()=>{if(!x?.uid)return;let c=!1;const D=async L=>{c||(Xe||L)&&je(!0)},X=L=>{L.detail?.tab==="Modules"&&D(!0)},le=setTimeout(()=>D(),500);return window.addEventListener("mathpulse:navigate",X),()=>{c=!0,clearTimeout(le),window.removeEventListener("mathpulse:navigate",X)}},[x?.uid,Xe]);const Ve=async()=>{if(x?.uid)try{await it(),He?.success&&(fa({userId:x.uid,type:"daily_checkin",title:"Daily Reward Claimed!",message:`You earned ${He.reward.label} and kept your streak alive!`,metadata:{rewardId:He.reward.id,streakDay:He.dayIndex+1}}).catch(console.error),He.reward.rarity==="epic"&&Ls(x.uid,"acc_crown").then(()=>Bt.success("👑 Epic reward unlocked!")).catch(console.error)),setTimeout(()=>je(!1),1e3)}catch(c){const D=c instanceof Error?c.message:"";console.error("Failed to claim daily reward:",c),D.includes("Already claimed")?Bt.info("You already claimed your reward today!"):Bt.error("Failed to claim daily reward. Please try again.")}};s.useEffect(()=>{if(o){const c=re.find(D=>D.id===o);c&&ge(c)}},[o,re]),s.useEffect(()=>{x?.uid&&(ee(!0),xa(x.uid).then(c=>{T(c)}).catch(c=>{console.error("Failed to load competency profile:",c)}).finally(()=>{ee(!1)}))},[x?.uid]);const ye=s.useMemo(()=>{const c=l.length>0?l:a.map(X=>ma(X)).filter(X=>X!==null),D=new Set;return c.filter(X=>D.has(X)?!1:(D.add(X),!0))},[l,a]),{data:ve=[]}=Gs({queryKey:ua.modules(d,ye),enabled:!0,staleTime:600*1e3,gcTime:1800*1e3,queryFn:async()=>{const c=re;if(ye.length===0)return c;const D=new Map(ye.map((X,le)=>[ba[X],le]));return[...c].sort((X,le)=>{const L=D.get(X.id)??Number.POSITIVE_INFINITY,ke=D.get(le.id)??Number.POSITIVE_INFINITY;return L-ke})}}),Ne=s.useMemo(()=>{const c=new Set;return ve.forEach(D=>c.add(D.competency_group)),Array.from(c)},[ve]),st=s.useMemo(()=>{const c=A.trim().toLowerCase(),D=ve.filter(X=>{const le=!c||X.title.toLowerCase().includes(c),L=!c||X.description.toLowerCase().includes(c),ke=!c||X.lessons.some(Ie=>Ie.title.toLowerCase().includes(c)),Se=!c||X.quizzes.some(Ie=>Ie.title.toLowerCase().includes(c)),Le=c?X.competencies.some(Ie=>Ie.outcome.toLowerCase().includes(c)||Ie.code.toLowerCase().includes(c)):!0,ie=_==="all"||X.subjectId===_,ue=m==="all"||X.quarter===m,at=j==="all"||X.competency_group===j;return(le||L||ke||Se||Le)&&ie&&ue&&at});if(f?.competencies){const X=new Set(Object.entries(f.competencies).filter(([,L])=>L.score<50).map(([L])=>L)),le=new Set(Object.entries(f.competencies).filter(([,L])=>L.score>=80).map(([L])=>L));return D.sort((L,ke)=>{const Se=L.competencies.map(pe=>pe.code),Le=ke.competencies.map(pe=>pe.code),ie=Se.some(pe=>X.has(pe))?1:0,ue=Le.some(pe=>X.has(pe))?1:0,at=Se.some(pe=>le.has(pe))?1:0,Ie=Le.some(pe=>le.has(pe))?1:0,fe=ie*2+at;return ue*2+Ie-fe})}return D},[ve,A,_,m,j,f]),Qe=s.useMemo(()=>{const c=m==="all"?"All Quarters":m,D=_==="all"?"All Subjects":cs[_]?.label??"Subject";return`${d} · ${D} · ${c}`},[d,_,m]),ot=s.useMemo(()=>{const c=new Set(ve.map(D=>D.subjectId));return Array.from(c)},[ve]),Ye=()=>{R("all"),y("all"),E("all"),N("")};s.useEffect(()=>{b!=="recommended"||ye.length===0||(P(!0),pa({weakTopics:ye.map(c=>ds[c]),subject:_!=="all"?_:"General Mathematics",userId:x?.uid}).then(c=>{I(c.curriculumContext),P(!1)}).catch(()=>P(!1)))},[b,ye]);const Ke=(c,D)=>{t&&t(D,`Quiz Completed! +${D} XP`),we(null),r&&r(!1)};return K?(r&&r(!0),e.jsx(Fr,{quiz:K,onClose:()=>we(null),onComplete:Ke,studentId:x?.uid})):Z?e.jsx(Cr,{module:Z,onBack:()=>ge(null),onEarnXP:t,isInQuizMode:n,setIsInQuizMode:r}):$?e.jsxs("div",{className:"h-full overflow-y-auto px-4 sm:px-6 xl:px-10 pb-8 scrollbar-hide scroll-smooth relative",children:[e.jsxs("button",{onClick:()=>te(null),className:"mb-4 inline-flex items-center gap-2 text-sm font-bold text-slate-600 hover:text-slate-900 transition-colors",children:[e.jsx(pt,{className:"rotate-180",size:16}),"Back to Modules"]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#F08386]/30 p-6 md:p-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F08386]/12 border border-[#F08386]/30 text-[#F08386] text-xs font-bold",children:"Teacher Upload"}),$.quarter&&e.jsx("span",{className:"px-2 py-1 rounded-md bg-slate-100 text-slate-600 text-xs",children:$.quarter})]}),e.jsx("h1",{className:"text-2xl md:text-3xl font-display font-black text-slate-900 mb-2",children:$.title}),e.jsxs("p",{className:"text-sm text-slate-600 mb-6",children:[$.subject," · ",$.gradeLevel]}),$.summary&&e.jsx("p",{className:"text-slate-700 text-base leading-relaxed mb-6",children:$.summary}),$.learningObjectives?.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-2",children:"Learning Objectives"}),e.jsx("ul",{className:"list-disc list-inside space-y-1 text-slate-700",children:$.learningObjectives.map((c,D)=>e.jsx("li",{children:c},D))})]}),$.sections?.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-3",children:"Sections"}),e.jsx("div",{className:"space-y-3",children:$.sections.map((c,D)=>e.jsxs("div",{className:"border border-slate-200 rounded-xl p-4",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-800 mb-1",children:c.title}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:c.content})]},D))})]}),$.practice?.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-3",children:"Practice Questions"}),e.jsx("div",{className:"space-y-3",children:$.practice.map((c,D)=>e.jsxs("div",{className:"border border-slate-200 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 mb-2",children:c.question}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-2",children:c.options.map((X,le)=>e.jsxs("div",{className:"text-xs text-slate-600 bg-slate-50 rounded-lg px-3 py-2",children:[X.label,". ",X.text]},le))}),e.jsxs("p",{className:"text-xs text-emerald-700 font-semibold",children:["Answer: ",c.answer]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:c.explanation})]},D))})]})]})]}):e.jsxs("div",{className:"h-full overflow-y-auto px-4 sm:px-6 xl:px-10 pb-8 scrollbar-hide scroll-smooth relative",onScroll:c=>U(c.currentTarget.scrollTop>100),children:[e.jsx(Qr,{isOpen:et,onClose:()=>je(!1),onClaim:Ve,weekRewards:nt,todayReward:_t,canClaim:Xe,isClaiming:wt,claimedDays:Ge,currentDayIndex:ts(),timeUntilReset:tt}),e.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-start lg:items-center py-6 gap-6",children:[e.jsxs("div",{className:"flex-1 max-w-3xl",children:[e.jsx("h1",{className:"text-[36px] md:text-[44px] font-display font-black text-[#202124] tracking-tight leading-[1.1] mb-4",children:"Curriculum Modules"}),e.jsx("p",{className:"text-[#3c4043] text-[16px] md:text-[17px] leading-[1.7] md:pr-10",children:"MathPulse AI loads modules directly from DepEd Strengthened SHS curriculum guides with AI-powered RAG lesson generation. Currently available: General Mathematics, Business Mathematics, and Statistics & Probability. Pre-Calculus and Basic Calculus modules are coming soon once teaching module PDFs are sourced."}),e.jsx("div",{className:"mt-4 flex items-center gap-3",children:e.jsx("div",{className:"inline-flex items-center rounded-full border border-sky-200 bg-sky-50 px-4 py-2 text-sm font-bold text-sky-900",children:Qe})})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center justify-center lg:justify-end w-full lg:w-[350px] mt-4 lg:mt-0",children:e.jsx(Mr,{assessmentDismissed:x?.assessmentDismissed,initialAssessmentCompleted:x?.initialAssessmentCompleted})})]}),e.jsxs("div",{className:`sticky top-0 z-30 -mx-4 px-4 sm:-mx-6 sm:px-6 xl:-mx-10 xl:px-10 pt-3 pb-3 space-y-3 transition-colors duration-300 ${k?"bg-[#f8faff] border-b border-[#dde3eb] shadow-sm":"bg-transparent"}`,children:[e.jsxs("div",{className:"flex flex-col lg:flex-row items-center gap-3 w-full",children:[e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-[#5f6368]",children:e.jsx(Sa,{size:16,strokeWidth:2.5})}),e.jsx("input",{id:"modules-search",name:"modules-search","aria-label":"Search modules",type:"text",value:A,onChange:c=>N(c.target.value),placeholder:"Search modules, lessons, or assessments...",className:"w-full pl-10 pr-10 py-2 rounded-xl border border-[#dadce0] bg-white text-[#202124] text-[13px] font-medium focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all shadow-sm"}),!1]}),e.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-2 w-full lg:w-auto shrink-0",children:[e.jsxs("select",{value:_,onChange:c=>R(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Subject",children:[e.jsx("option",{value:"all",children:"All Subjects"}),ot.map(c=>e.jsx("option",{value:c,children:cs[c].label},c))]}),e.jsx("select",{value:m,onChange:c=>y(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Quarter",children:Zr.map(c=>e.jsx("option",{value:c,children:c==="all"?"All Quarters":c},c))}),e.jsxs("select",{value:j,onChange:c=>E(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Competency Group",children:[e.jsx("option",{value:"all",children:"All Competencies"}),Ne.map(c=>e.jsx("option",{value:c,children:c},c))]}),e.jsxs("button",{type:"button",onClick:Ye,className:"inline-flex w-full md:w-auto items-center justify-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-bold text-slate-700 transition-colors hover:bg-slate-50 shadow-sm shrink-0",children:[e.jsx(Ca,{size:14}),"Reset"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center bg-slate-100/80 p-1 rounded-full border border-slate-200/60 shadow-inner gap-1 overflow-x-auto no-scrollbar",children:[{id:"modules",label:"Modules",icon:Je,color:"text-[#1FA7E1]"},{id:"recommended",label:"Recommended",icon:Pt,color:"text-[#75D06A]"},{id:"practice",label:"Practice",icon:Oe,color:"text-[#FFB356]"},{id:"teacher_uploaded",label:"Teacher Uploaded",icon:ha,color:"text-[#F08386]"}].map(c=>{const D=b===c.id;return e.jsxs("button",{onClick:()=>g(c.id),className:`relative flex items-center gap-1.5 px-4 py-1.5 rounded-full text-[13px] font-bold transition-all duration-300 flex-shrink-0 ${D?"shadow-sm":"text-slate-500 hover:text-slate-700 hover:bg-slate-200/50"}`,children:[D&&e.jsx(v.div,{layoutId:"modulesTabBackground",className:"absolute inset-0 bg-white rounded-full shadow-[0_2px_15px_-3px_rgba(0,0,0,0.1)] border border-slate-100",transition:{type:"spring",bounce:.2,duration:.6}}),e.jsxs("span",{className:`relative z-10 flex items-center gap-1.5 ${D?c.color:""}`,children:[e.jsx(c.icon,{size:15,strokeWidth:D?2.5:2}),c.label]})]},c.id)})}),e.jsxs("div",{className:"flex items-center gap-2 ml-1",children:[b==="modules"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500",children:e.jsx(ya,{size:15,strokeWidth:2.5})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"DepEd Strengthened SHS Modules"})]}),b==="recommended"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#75D06A]/10 flex items-center justify-center",children:e.jsx(za,{size:15,className:"text-[#75D06A]"})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Suggested Next"})]}),b==="practice"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#FFB356]/10 flex items-center justify-center",children:e.jsx(Oe,{size:15,className:"text-[#FFB356]"})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Practice Center"})]}),b==="teacher_uploaded"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#F08386]/15 border border-[#F08386]/30 flex items-center justify-center text-[#F08386]",children:e.jsx(ms,{size:15,strokeWidth:2.5})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Teacher Uploaded Modules"})]})]})]})]}),e.jsxs("div",{className:"pt-4",children:[ye.length>0&&e.jsxs("div",{className:"mb-4 rounded-2xl border border-amber-300 bg-amber-50 px-5 py-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-sm font-black text-amber-900",children:[e.jsx(Ts,{size:15}),"Assessment Focus Areas"]}),e.jsx("p",{className:"mt-1 text-sm text-amber-900/80",children:"Modules are currently prioritized by your latest diagnostic needs."})]}),e.jsxs("button",{type:"button",onClick:()=>g("recommended"),className:"inline-flex items-center gap-1.5 rounded-xl bg-amber-600 px-3 py-2 text-xs font-bold text-white transition-colors hover:bg-amber-700",children:["View Recommended",e.jsx(pt,{size:14})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:ye.map((c,D)=>e.jsxs("span",{className:"rounded-full bg-white px-3 py-1 text-xs font-semibold text-amber-900 shadow-sm",children:[D+1,". ",ds[c]]},c))})]}),e.jsx($e,{mode:"wait",children:e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"pb-8 mt-4",children:b==="practice"?e.jsx(zr,{onStartQuiz:we,searchQuery:A}):b==="teacher_uploaded"?gt?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6",children:[1,2,3].map(c=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-slate-200 rounded w-3/4 mb-4"}),e.jsx("div",{className:"h-3 bg-slate-100 rounded w-1/2 mb-3"}),e.jsx("div",{className:"h-3 bg-slate-100 rounded w-5/6"})]},c))}):ne.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 bg-[#F08386]/10 rounded-2xl flex items-center justify-center mx-auto mb-4",children:e.jsx(ms,{size:32,className:"text-[#F08386]"})}),e.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-2",children:"No Teacher-Uploaded Modules Yet"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Your teachers haven't uploaded any custom modules yet."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6",children:ne.map(c=>e.jsxs("div",{className:"bg-white rounded-2xl border border-[#F08386]/30 p-6 hover:border-[#F08386]/60 hover:shadow-md transition-all cursor-pointer",onClick:()=>te(c),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F08386]/12 border border-[#F08386]/30 text-[#F08386] text-xs font-bold",children:"Teacher Upload"}),c.quarter&&e.jsx("span",{className:"px-2 py-1 rounded-md bg-slate-100 text-slate-600 text-xs",children:c.quarter})]}),e.jsx("h3",{className:"text-lg font-bold text-slate-900 mb-2 line-clamp-2",children:c.title}),e.jsxs("p",{className:"text-sm text-slate-600 mb-3",children:[c.subject," · ",c.gradeLevel]}),c.summary&&e.jsx("p",{className:"text-xs text-slate-500 line-clamp-3",children:c.summary})]},c.moduleId))}):b==="modules"?e.jsx(Jr,{modules:st,onSelectModule:ge,onPreviewSources:Y,isAtRisk:ye.length>0&&i,weakTopics:M?.assessmentResults?.weakTopics||[]}):e.jsx(el,{modules:st,fullPool:ve,onSelectModule:ge,onPreviewSources:Y,isAtRisk:ye.length>0&&i,learningPathContext:Me,learningPathLoading:u,weakTopics:M?.assessmentResults?.weakTopics||[]})},b)})]}),e.jsx($e,{children:O&&e.jsxs(v.aside,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{duration:.25},className:"fixed inset-y-0 right-0 z-[80] w-full max-w-xl border-l border-slate-200 bg-white p-6 shadow-2xl",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-wide text-sky-700",children:"Curriculum Preview"}),e.jsx("h3",{className:"mt-1 text-xl font-black text-slate-900",children:O.title}),e.jsxs("p",{className:"mt-1 text-sm text-slate-600",children:[O.active_grade_level," · ",O.subject," · ",O.quarter]})]}),e.jsx("button",{type:"button",onClick:()=>Y(null),className:"rounded-lg border border-slate-200 p-2 text-slate-500 hover:bg-slate-50",children:e.jsx(De,{size:16})})]}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-slate-50 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Competency Group"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-800",children:O.competency_group})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Performance Standard"}),e.jsx("p",{className:"mt-1 text-sm text-slate-700",children:O.performance_standard})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Competencies"}),e.jsx("div",{className:"mt-2 space-y-2",children:O.competencies.map(c=>e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-slate-50 p-3",children:[e.jsx("p",{className:"text-xs font-black text-slate-600",children:c.code}),e.jsx("p",{className:"mt-1 text-sm text-slate-700",children:c.outcome})]},c.code))})]})]})]})})]})},Jr=({modules:t,onSelectModule:a,onPreviewSources:l,isAtRisk:o=!1,weakTopics:n=[]})=>e.jsx("div",{className:"pr-2 space-y-8",children:e.jsx("div",{children:t.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-[#dde3eb] p-8 text-center",children:[e.jsx("p",{className:"text-slate-700 font-semibold",children:"No matching modules found."}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"If modules are not yet available for your selected view, this area will unlock after assessment sync and content rollout."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:t.map((r,i)=>{const x=n.some(p=>r.content_domain&&r.content_domain.toLowerCase().includes(p.toLowerCase())||r.title&&r.title.toLowerCase().includes(p.toLowerCase())||r.competency_group&&r.competency_group.toLowerCase().includes(p.toLowerCase())||r.subject&&r.subject.toLowerCase().includes(p.toLowerCase()));return e.jsx(Wt,{module:r,index:i,onClick:()=>a(r),onPreviewSources:()=>l(r),isAtRisk:o,isRecommended:x},r.id)})})})}),el=({modules:t,fullPool:a,onSelectModule:l,onPreviewSources:o,isAtRisk:n=!1,learningPathContext:r=null,learningPathLoading:i=!1,weakTopics:x=[]})=>{const p=t.filter(g=>g.progress>0&&g.progress<100),b=(t.length>0?t:a).filter(g=>g.progress===0).slice(0,6);return e.jsxs("div",{className:"pr-2 space-y-10",children:[i&&e.jsxs("div",{className:"mb-6 rounded-2xl border border-sky-200 bg-sky-50 px-5 py-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded-full border-2 border-sky-400 border-t-transparent animate-spin flex-shrink-0"}),e.jsx("p",{className:"text-sm font-semibold text-sky-800",children:"Building your personalized learning path from DepEd curriculum..."})]}),r&&!i&&e.jsxs("div",{className:"mb-6 rounded-2xl border border-indigo-200 bg-gradient-to-br from-indigo-50 to-purple-50 px-5 py-4 shadow-sm",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-wide text-indigo-700 mb-2",children:"📚 Your Personalized Learning Path"}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-indigo-900 font-medium leading-relaxed font-sans",children:r})]}),p.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-[#FF8B8B]/10 flex items-center justify-center text-[20px] shadow-inner",children:"🔥"}),e.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:"Continue This Module"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:p.slice(0,4).map((g,M)=>{const z=x.some(d=>g.content_domain&&g.content_domain.toLowerCase().includes(d.toLowerCase())||g.title&&g.title.toLowerCase().includes(d.toLowerCase())||g.competency_group&&g.competency_group.toLowerCase().includes(d.toLowerCase())||g.subject&&g.subject.toLowerCase().includes(d.toLowerCase()));return e.jsx(Wt,{module:g,index:M,onClick:()=>l(g),onPreviewSources:()=>o(g),isAtRisk:n,badgeLabel:"In Progress",isRecommended:z},g.id)})})]}),e.jsx("div",{children:b.length===0?e.jsx("div",{className:"bg-white rounded-2xl border border-[#dde3eb] p-8 text-center text-slate-500 font-medium",children:"You are all caught up. Practice more quizzes to unlock additional recommendations."}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:b.map((g,M)=>{const z=x.some(d=>g.content_domain&&g.content_domain.toLowerCase().includes(d.toLowerCase())||g.title&&g.title.toLowerCase().includes(d.toLowerCase())||g.competency_group&&g.competency_group.toLowerCase().includes(d.toLowerCase())||g.subject&&g.subject.toLowerCase().includes(d.toLowerCase()));return e.jsx(Wt,{module:g,index:M,onClick:()=>l(g),onPreviewSources:()=>o(g),isAtRisk:n,badgeLabel:"Start",isRecommended:z},g.id)})})})]})};export{$l as default}; +`,Tr=({viewportHeight:t})=>e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex justify-between bg-slate-900/5",children:Ae.useMemo(()=>[...Array(40)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[t]).map(a=>e.jsx(v.div,{className:"absolute w-0.5 h-16 bg-blue-400/30 rounded-full",style:{left:a.left,top:"-10%"},animate:{y:[0,t*1.2]},transition:{duration:a.duration,ease:"linear",delay:a.delay}},a.id))}),Lr=()=>{const t=Ae.useMemo(()=>[...Array(60)].map((a,l)=>({id:l,left:`${Math.random()*100}%`,backgroundColor:["#75D06A","#6ED1CF","#9956DE","#FB96BB","#FFB356"][l%5],duration:2+Math.random()*2,delay:Math.random()*.5,size:6+Math.random()*8,borderRadius:Math.random()>.5?"50%":"2px"})),[]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden",children:t.map(a=>e.jsx("div",{className:"confetti-piece",style:{left:a.left,top:"-10%",backgroundColor:a.backgroundColor,width:a.size,height:a.size,borderRadius:a.borderRadius,animationDuration:`${a.duration}s`,animationDelay:`${a.delay}s`}},a.id))})},Ir=({viewportHeight:t,viewportWidth:a})=>{const l=Ae.useMemo(()=>[...Array(30)].map((o,n)=>({id:n,xShift:(Math.random()-.5)*a*.8,yShift:(Math.random()-.5)*t*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[t,a]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[250] overflow-hidden flex items-center justify-center",children:l.map(o=>e.jsx(v.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.5)]",style:{left:"50%",top:"50%"},animate:{y:[0,o.yShift],x:[0,o.xShift],scale:[0,o.scale,0],opacity:[0,1,0]},transition:{duration:o.duration,ease:"easeOut",delay:o.delay}},o.id))})},Ss=({value:t,label:a,delay:l=0,icon:o})=>{const[n,r]=Ae.useState(0);return Ae.useEffect(()=>{if(t<=0)return;const i=1e3,x=30,p=Math.abs(Math.floor(i/x));let b=0;const g=setTimeout(()=>{const M=setInterval(()=>{b+=Math.max(1,Math.floor(t/x)),b>=t?(r(t),clearInterval(M)):r(b)},p);return()=>clearInterval(M)},l);return()=>clearTimeout(g)},[t,l]),t<0?null:e.jsxs(v.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:l/1e3,duration:.5},className:"flex items-center justify-between bg-slate-50 border border-slate-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-bold uppercase tracking-wider text-[10px]",children:[o,a]}),e.jsxs("div",{className:"text-xl font-black text-purple-600 tabular-nums",children:["+",n]})]})};function Fr(t){if(t.questionType==="multiple_choice"&&t.options&&t.options.length>0){const a=t.options.findIndex(l=>l.trim().toLowerCase()===t.correctAnswer.trim().toLowerCase());return{id:t.id,question:t.question,options:t.options,correctAnswer:a>=0?a:0,correctAnswerText:t.correctAnswer,explanation:t.explanation,questionType:t.questionType,points:t.points,difficulty:t.difficulty,topic:t.topic,bloomLevel:t.bloomLevel}}return{id:t.id,question:t.question,options:[],correctAnswer:-1,correctAnswerText:t.correctAnswer,explanation:t.explanation,questionType:t.questionType,points:t.points,difficulty:t.difficulty,topic:t.topic,bloomLevel:t.bloomLevel}}function Cs(t){return t.replace(/²/g,"^2").replace(/³/g,"^3").replace(/⁻¹/g,"^-1").replace(/⁰/g,"^0").replace(/¹/g,"^1").replace(/⁴/g,"^4").replace(/⁵/g,"^5").replace(/⁶/g,"^6").replace(/⁷/g,"^7").replace(/⁸/g,"^8").replace(/⁹/g,"^9").replace(/π/g,"pi").replace(/√/g,"sqrt").replace(/×/g,"*").replace(/÷/g,"/").replace(/\s+/g,"").toLowerCase().trim()}function Dr(t,a,l){const o=n=>n.trim().toLowerCase().replace(/\s+/g," ");switch(l){case"identification":return o(t)===o(a);case"enumeration":{const n=t.split(",").map(i=>o(i)).filter(Boolean).sort(),r=a.split(",").map(i=>o(i)).filter(Boolean).sort();return JSON.stringify(n)===JSON.stringify(r)}case"word_problem":case"equation_based":{const n=Cs(t),r=Cs(a);if(n===r)return!0;const i=parseFloat(t.replace(/[^\d.\-]/g,"")),x=parseFloat(a.replace(/[^\d.\-]/g,""));return!isNaN(i)&&!isNaN(x)?Math.abs(i-x)<=.01:o(t)===o(a)}default:return o(t)===o(a)}}const Rr=({quiz:t,onClose:a,onComplete:l,studentId:o,atRiskSubjects:n=[]})=>{const[r,i]=s.useState(0),[x,p]=s.useState(null),[b,g]=s.useState(""),[M,z]=s.useState(!1),[d,A]=s.useState(!1),[N,_]=s.useState(!1),[R,m]=s.useState(0),[y,j]=s.useState(0),[E,k]=s.useState(1),[U,O]=s.useState([]),[Y,$]=s.useState([]),[te,xe]=s.useState(Date.now()),[_e,re]=s.useState(!1),[W,Z]=s.useState(!1),[ge,K]=s.useState(null),[we,Me]=s.useState(0),[I,u]=s.useState(0),[P,f]=s.useState(!1),[T,F]=s.useState(!0),[ee,ne]=s.useState(!1),[Be,gt]=s.useState({width:1280,height:720});s.useEffect(()=>{const S=()=>gt({width:window.innerWidth,height:window.innerHeight});return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const[Ue,et]=s.useState(0),[je,nt]=s.useState({}),[_t,Xe]=s.useState(!1),[wt,Ge]=s.useState(!1),[tt,it]=s.useState(!1),{totalHintsAvailable:He}=Pr(o||null),[Ve,ye]=s.useState(5),[ve,Ne]=s.useState(15),st=Ve+He,[Qe,ot]=s.useState(null),[Ye,Ke]=s.useState(!1),[c,D]=s.useState(900*1e3),[X,le]=s.useState([]),[L,ke]=s.useState(0),[Se,Le]=s.useState(null),[oe]=s.useState(()=>t.loadedQuestions&&t.loadedQuestions.length>0?t.loadedQuestions.map(Fr):Array.from({length:t.questions},(S,h)=>({id:`q${h+1}`,question:$r(t.subject,h),options:Br(t.subject,h),correctAnswer:Hr(t.subject,h),explanation:Qr(t.subject,h,t.difficulty)})));s.useEffect(()=>{nt({}),le([]),ye(5),Ne(15),et(0),m(0),j(0),k(1)},[t.id]);const ue=oe[r];s.useEffect(()=>{const S=parseInt(t.duration)||10;Me(S*60);const h=setInterval(()=>{Me(H=>H<=1?(clearInterval(h),yt(),0):H-1)},1e3);return()=>clearInterval(h)},[]),s.useEffect(()=>{ve===0&&!Qe&&(ot(Date.now()),Ke(!0))},[ve,Qe]),s.useEffect(()=>{if(!Ye||!Qe)return;const S=setInterval(()=>{const h=Date.now()-Qe,H=Math.max(0,900*1e3-h);D(H)},1e3);return()=>clearInterval(S)},[Ye,Qe]);const[at,Ie]=s.useState(Array.from({length:15},(S,h)=>({id:h,size:Math.random()*120+40,x:Math.random()*100,y:Math.random()*100,duration:Math.random()*20+15,delay:Math.random()*-20,color:["bg-purple-500/10","bg-blue-500/10","bg-cyan-500/10","bg-emerald-500/10"][Math.floor(Math.random()*4)]}))),fe=S=>{if(T)try{const h=window.AudioContext||window.webkitAudioContext;if(!h)return;const H=new h,B=H.currentTime,Q=(Ce,Ee,he,Fe=.1,be="sine")=>{const me=H.createOscillator(),qe=H.createGain();me.type=be,me.frequency.value=Ce,qe.gain.setValueAtTime(0,Ee),qe.gain.linearRampToValueAtTime(Fe,Ee+.05),qe.gain.exponentialRampToValueAtTime(.001,Ee+he),me.connect(qe),qe.connect(H.destination),me.start(Ee),me.stop(Ee+he)};S==="correct"?(Q(880,B,.1,.1,"sine"),Q(1108.73,B+.1,.2,.1,"sine")):S==="incorrect"?(Q(300,B,.2,.05,"sawtooth"),Q(250,B+.15,.3,.05,"sawtooth")):S==="combo"?(Q(440,B,.1,.05,"square"),Q(554.37,B+.1,.1,.05,"square"),Q(659.25,B+.2,.1,.05,"square"),Q(880,B+.3,.4,.05,"square")):S==="complete"&&(Q(523.25,B,.1,.1),Q(659.25,B+.15,.1,.1),Q(783.99,B+.3,.1,.1),Q(1046.5,B+.45,.5,.1))}catch{}},yt=()=>{re(!0),vt()},pe=()=>{if(Ve<=0||d)return;const S=je[r]||[],h=ue.options.filter(B=>B!==ue.correctAnswerText).filter(B=>!S.includes(B));if(h.length===0)return;const H=h[Math.floor(Math.random()*h.length)];nt(B=>({...B,[r]:[...S,H]})),ye(B=>Math.max(0,B-1)),fe("correct")},Mt=S=>{d||ce||(p(S),setTimeout(()=>{jt(S)},150))},jt=S=>{const h=ue.questionType!=null&&ue.questionType!=="multiple_choice",H=S!==void 0?S:x;if(h){if(!b.trim())return}else if(H===null)return;const B=h?Dr(b,ue.correctAnswerText||"",ue.questionType||""):H===ue.correctAnswer,Q=h?b:String(H),Ce=Math.round((Date.now()-te)/1e3);$(me=>[...me,{questionId:ue.id,answer:Q,correct:B,timeSpent:Ce}]);const Ee=[...U];if(Ee[r]=B?1:0,O(Ee),z(B),A(!0),!B){Ge(!0),fe("incorrect"),setTimeout(()=>Ge(!1),500),Ne(me=>Math.max(0,me-1)),j(0),k(1),setTimeout(()=>{ct()},1500);return}fe("correct");const Fe=(je[r]||[]).length>0?5:10;et(me=>me+Fe),m(R+1);const be=y+1;j(be),be===2?Le("streak"):be===3&&E<2?Le("multiplier2"):be===5&&E<3&&Le("multiplier3"),be>0&&be%3===0&&fe("combo"),be>=5?k(3):be>=3?k(2):k(1),Lt(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(me=>{me.default({particleCount:30,spread:40,colors:["#75D06A","#6ED1CF"],origin:{y:.6}})}),it(!0),setTimeout(()=>{it(!1),Le(null),setTimeout(()=>ct(),300)},1500)},ct=()=>{if(r{const S=Math.round(R/oe.length*100);let h=t.xpReward;S>=90?h=Math.round(h*1.5):S>=80&&(h=Math.round(h*1.25));const H=parseInt(t.duration)*60;we>H*.5&&(h=Math.round(h*1.2)),u(h);const B=H-we;o&&Na({lrn:o,quizId:t.id,subject:t.subject,score:S,totalQuestions:oe.length,correctAnswers:R,timeSpentSeconds:B}).catch(Q=>console.error("[WARN] Automation: quiz pipeline failed:",Q)),t.source==="ai_generated"&&o?Gs(o,t.id,t.generatedQuizId,t.subject,t.source,S,h,B,Y,oe.map(Q=>({topic:Q.topic||t.subject,difficulty:Q.difficulty||"medium",bloomLevel:Q.bloomLevel||"understand"}))).catch(Q=>console.error("[WARN] Quiz result save failed:",Q)):o&&oa(o,t.id,t.subject,S,Y.map(Q=>({questionId:Q.questionId,selectedAnswer:Q.answer,isCorrect:Q.correct})),B).catch(Q=>console.error("[WARN] Practice quiz persist failed:",Q)),fe("complete")},ce=L{document.fullscreenElement?(document.exitFullscreen().catch(()=>{}),ne(!1)):(document.documentElement.requestFullscreen().catch(()=>{}),ne(!0))};if(_e){const S=Math.round(R/oe.length*100),h=S>=80,H=S>=50&&S<80,B=S<50,Q=document.getElementById("modal-root"),Ce=e.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50 backdrop-blur-sm",children:[e.jsx("style",{children:ks}),h&&e.jsx(Lr,{}),H&&e.jsx(Ir,{viewportHeight:Be.height,viewportWidth:Be.width}),B&&e.jsx(Tr,{viewportHeight:Be.height}),e.jsxs(v.div,{initial:{opacity:0,scale:.8,y:40},animate:{opacity:1,scale:1,y:0},transition:{type:"spring",damping:18,stiffness:200},className:"w-full max-w-xs sm:max-w-sm bg-white border-2 border-slate-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)] rounded-[2rem] p-4 sm:p-5 text-center relative z-10",children:[e.jsx(v.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",damping:12,stiffness:150,delay:.2},className:"mb-3",children:e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-16 h-16 sm:w-20 sm:h-20 mx-auto drop-shadow-xl animate-mascot-float"})}),e.jsx(v.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:`text-xl sm:text-2xl font-black uppercase tracking-tight mb-1 drop-shadow-sm ${h?"text-emerald-500":H?"text-amber-500":"text-rose-500"}`,children:h?"EXCELLENT!":H?"GOOD JOB!":"KEEP TRYING!"}),e.jsxs("p",{className:"text-slate-400 font-bold text-[10px] mb-3 uppercase tracking-widest",children:["Quiz Complete • Score: ",R,"/",oe.length]}),e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"bg-slate-50/50 rounded-xl p-3 mb-4 border border-slate-100 flex flex-col gap-2",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest text-left mb-1.5 ml-1",children:"Performance Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Ss,{value:R,label:"Correct Answers",delay:500,icon:e.jsx(lt,{className:"h-3 w-3 text-emerald-500"})}),e.jsx(Ss,{value:Ue,label:"Total XP Earned",delay:800,icon:e.jsx(Re,{className:"h-3 w-3 text-amber-500"})}),e.jsxs(v.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.4},className:"flex items-center justify-between pt-1.5 mt-1 border-t border-slate-100",children:[e.jsx("span",{className:"text-slate-400 text-[9px] font-black uppercase tracking-widest",children:"Final Accuracy"}),e.jsxs("span",{className:"text-lg font-black text-slate-800 tabular-nums",children:[S,"%"]})]})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{size:"lg",onClick:()=>{i(0),ke(0),p(null),g(""),m(0),j(0),k(1),O([]),$([]),et(0),re(!1),A(!1),_(!1),xe(Date.now()),nt({}),le([]),Xe(!1),ye(5),Z(!1)},className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-white hover:bg-slate-50 text-purple-600 border-2 border-purple-100",children:"RETAKE QUIZ"}),e.jsx(ze,{size:"lg",onClick:a,className:"w-full h-10 sm:h-11 rounded-2xl text-xs font-black bg-purple-600 hover:bg-purple-700 text-white shadow-lg shadow-purple-200",children:"BACK TO PRACTICE CENTER"})]})]})]});return ut.createPortal(Ce,Q)}return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ks}),P&&ut.createPortal(e.jsx(v.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},className:"fixed right-6 top-1/2 -translate-y-1/2 z-[9999] w-64",children:e.jsxs("div",{className:"bg-white rounded-2xl p-3 border border-slate-200 shadow-[0_10px_40px_rgba(0,0,0,0.3)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsxs("h4",{className:"text-xs font-bold text-[#0a1628] flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-purple-600",children:[e.jsx("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"6",y2:"6"})]}),"Calculator"]}),e.jsx("button",{onClick:()=>f(!1),className:"w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-slate-500 hover:text-slate-800 hover:bg-slate-200 transition-colors",children:e.jsx(De,{size:12})})]}),e.jsx(Fs,{isOpen:!0,onClose:()=>f(!1),inline:!0})]})}),document.getElementById("modal-root")),Ye&&ut.createPortal(e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-slate-900/50",children:e.jsxs(v.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-white rounded-[2rem] p-6 max-w-xs w-full text-center border-2 border-rose-200 shadow-[0_25px_60px_rgba(0,0,0,0.15)]",children:[e.jsx(v.div,{animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},className:"text-6xl mb-4",children:"💔"}),e.jsx("h2",{className:"text-2xl font-black text-slate-800 mb-3",children:"Out of Lives!"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"Your hearts have run out. You can wait for them to refill or head back and review your lessons in the meantime."}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2 text-rose-500 font-bold",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5"}),e.jsx("span",{children:"0 / 15 hearts"})]}),e.jsxs("p",{className:"text-slate-400 text-xs mb-4",children:["Next heart in: ",e.jsxs("span",{className:"font-bold text-slate-600",children:[Math.floor(c/6e4),":",Math.floor(c%6e4/1e3).toString().padStart(2,"0")]})," (15 minutes per heart)"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ze,{onClick:a,className:"w-full py-3 bg-rose-500 hover:bg-rose-600 text-white font-bold rounded-full",children:"Exit Quiz"}),e.jsx(ze,{onClick:()=>{Ke(!1)},className:"w-full py-3 bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold rounded-full",children:"Review Lessons"})]})]})}),document.getElementById("modal-root")),e.jsx($e,{children:tt&&M&&e.jsx(v.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[200] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-white/95 backdrop-blur-xl border border-slate-200 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.15)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:"/mascot/modules_avatar.png",alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-[0_10px_20px_rgba(0,0,0,0.15)]"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest text-emerald-500",children:"Correct!"}),e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-full font-bold border border-emerald-500/30",children:e.jsxs("span",{children:["+ ",(je[r]||[]).length>0?5:10," XP"]})}),Se==="streak"&&e.jsxs("div",{className:"flex items-center gap-2 bg-orange-500/20 text-orange-400 px-4 py-1.5 rounded-full text-sm font-bold border border-orange-500/30",children:[e.jsx(Es,{size:14})," Streak Started!"]}),Se==="multiplier2"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×2!"]}),Se==="multiplier3"&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-1.5 rounded-full text-sm font-bold border border-amber-500/30",children:[e.jsx(Re,{size:14})," Multiplier ×3!"]})]})]})},"round-result")}),e.jsxs("div",{className:"fixed inset-0 z-[100] h-screen w-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsxs("header",{className:"relative shrink-0 flex flex-col items-center justify-start px-4 pt-4 sm:pt-6 pb-6 z-[60] shadow-md overflow-hidden bg-gradient-to-r from-purple-600 to-indigo-400 rounded-b-[32px] sm:rounded-b-[40px] min-h-[110px] sm:min-h-[130px]",children:[e.jsxs("div",{className:"absolute inset-0 z-0 pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-0 w-64 h-64 bg-white opacity-10 rounded-full -translate-x-1/2 -translate-y-1/2 blur-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-80 h-80 bg-white opacity-10 rounded-full translate-x-1/3 translate-y-1/3 blur-3xl"})]}),e.jsxs("div",{className:"w-full max-w-7xl flex items-start justify-between relative z-10 mb-4 sm:mb-6",children:[e.jsx("div",{className:"flex-1 flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-1 bg-white/20 px-3 py-1.5 rounded-full text-white text-sm font-bold",children:[e.jsx(ft,{size:16})," ",qr(we)]})}),e.jsxs("div",{className:"relative flex items-center justify-center bg-purple-900/40 backdrop-blur-md px-6 sm:px-8 py-3 rounded-full border border-white/10 gap-3 sm:gap-4 shadow-inner",children:[e.jsx("div",{className:"w-3 h-3 sm:w-4 sm:h-4 rounded-full bg-yellow-400 shrink-0 shadow-[0_0_10px_rgba(250,204,21,0.6)]"}),e.jsxs("div",{className:"flex flex-col items-start justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-[11px] font-black text-purple-200 uppercase tracking-widest leading-none mb-1",children:"Try It Yourself!"}),e.jsx("span",{className:"font-bold text-white tracking-wide text-base sm:text-lg leading-none truncate max-w-[200px] sm:max-w-[300px]",children:t.title||t.subject})]})]}),e.jsxs("div",{className:"flex-1 flex justify-end gap-2 sm:gap-3 relative pointer-events-auto",children:[e.jsx("button",{onClick:()=>F(!T),className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:T?e.jsx(Ds,{size:20}):e.jsx(Rs,{size:20})}),e.jsx("button",{onClick:dt,className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:ee?e.jsx($s,{size:20}):e.jsx(Bs,{size:20})}),e.jsx("button",{onClick:a,className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-purple-900/20 text-white flex items-center justify-center hover:bg-purple-900/40 transition-colors shadow-sm border border-white/10",children:e.jsx(De,{size:20})})]})]}),e.jsx("div",{className:"w-full max-w-[50rem] flex items-center justify-center px-4 z-10",children:e.jsx("div",{className:"w-full flex items-center gap-2 sm:gap-3",children:oe.map((S,h)=>{let H=h<=r?"bg-white shadow-[0_0_8px_rgba(255,255,255,0.8)]":"bg-white/20";return e.jsx("div",{className:`h-1.5 sm:h-2 rounded-full flex-1 transition-all ${H}`},h)})})})]}),e.jsxs("div",{className:"w-full max-w-[54rem] mx-auto shrink-0 flex items-center justify-between px-4 sm:px-6 py-2 sm:py-3 z-[50] relative mt-8",children:[e.jsx("button",{onClick:()=>ke(S=>Math.max(0,S-1)),disabled:L===0,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${L===0?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(Yt,{size:24})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 sm:gap-5 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-rose-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_heart.png",alt:"Hearts",className:"w-5 h-5 object-contain"})," ",ve]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-8 sm:px-10 py-2 rounded-full bg-white shadow-md border border-slate-200/60 text-yellow-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Keys",className:"w-5 h-5 object-contain"})," ",Ve]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 px-3 py-1.5 pl-5 sm:pl-6 rounded-full bg-white shadow-md border border-slate-200/60",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-500 font-extrabold text-sm sm:text-base",children:[e.jsx("img",{src:"/icons/quiz_streak.png",alt:"Streak",className:"w-5 h-5 object-contain"})," ",y]}),e.jsxs("div",{className:"bg-emerald-100 text-emerald-800 px-4 py-1.5 rounded-full font-bold text-sm sm:text-base shadow-inner border border-emerald-200/50",children:["+ ",Ue," pts"]})]})]}),e.jsx("button",{onClick:()=>ke(S=>Math.min(r,S+1)),disabled:L>=r,className:`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-full flex items-center justify-center shadow-md border-2 transition-all ${L>=r?"bg-slate-100 text-slate-400 border-slate-200 cursor-not-allowed":"bg-white text-purple-600 border-purple-100 hover:bg-purple-50 hover:border-purple-200 hover:scale-105 active:scale-95"}`,children:e.jsx(ht,{size:24})})]}),e.jsx("main",{className:"flex-1 overflow-y-auto w-full px-4 sm:px-6 pt-0 pb-6 flex flex-col items-center relative z-10",children:e.jsxs(v.div,{initial:{opacity:0,x:20},animate:wt?{x:[-10,10,-10,10,0],scale:[1,1.01,1],opacity:1}:{opacity:1,x:0},className:"w-full max-w-3xl flex flex-col mt-2",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-lg border-t-[6px] border-purple-500 p-6 sm:p-8 text-center flex flex-col items-center mb-6 w-full relative overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-100 text-slate-600 px-4 py-1.5 rounded-full text-[11px] sm:text-xs font-black uppercase tracking-widest mb-4 flex items-center shadow-sm",children:["Q",L+1," of ",oe.length]}),e.jsx("h2",{className:"text-xl sm:text-2xl font-extrabold text-[#0a1628] leading-tight w-full",children:se.question.includes("___")?e.jsx("span",{children:se.question.split("___").map((S,h,H)=>e.jsxs(Ae.Fragment,{children:[S,hg(B.target.value),onKeyDown:B=>{B.key==="Enter"&&!d&&jt()},className:`inline-block w-24 mx-2 border-b-4 outline-none text-center bg-transparent font-bold ${ce?"border-slate-300 text-slate-500":"border-[#7C3AED] text-[#7C3AED] focus:border-[#75D06A]"}`})]},h))}):se.question})]}),e.jsxs("div",{className:"w-full flex flex-col items-center",children:[se.questionType==="multiple_choice"||!se.questionType?e.jsx("div",{className:"w-full grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-5",children:(se.options||[]).map((S,h)=>{const H=je[r]||[],B=H.includes(S),Q=H.length,Ce=(se.options||[]).length-1,Ee=Ce>0&&Q>=Ce;let he="bg-white hover:bg-slate-50 border-transparent text-slate-700 hover:border-slate-200",Fe=!1;if(Ee){Fe=!0;const be=se.options?.[se.correctAnswer];S===be?he="bg-emerald-50 border-emerald-400 text-emerald-800":Y[L]?.answer===String(h)?he="bg-rose-50 border-rose-400 text-rose-800 opacity-80":he="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through"}else if(B)he="bg-slate-100 border-slate-200 text-slate-400 opacity-40 line-through cursor-not-allowed";else if(ce){const be=h===se.correctAnswer,me=L===r&&(x===h||ge===h)||L{Fe||ce||B||Mt(h)},className:`p-4 sm:p-5 rounded-2xl shadow-sm border-[3px] font-extrabold text-base sm:text-lg text-left transition-all flex items-center justify-between ${he} ${Fe||ce||B?"cursor-default":"hover:shadow-md hover:-translate-y-0.5 active:translate-y-0"}`,children:[e.jsx("span",{className:"truncate pr-4",children:S}),B&&e.jsx(Ht,{size:20,className:"text-slate-400 shrink-0"}),ce&&h===se.correctAnswer&&e.jsx(zt,{size:22,className:"text-emerald-500 shrink-0"}),ce&&x===h&&h!==se.correctAnswer&&e.jsx(Ht,{size:22,className:"text-rose-500 shrink-0"})]},h)})}):e.jsx("div",{className:"w-full max-w-2xl mx-auto flex flex-col gap-4",children:!se.question.includes("___")&&e.jsx("input",{type:"text",disabled:ce,value:L===r?b:"",onChange:S=>g(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!d&&jt()},placeholder:"Type your answer here...",className:`w-full p-4 sm:p-5 rounded-2xl border-[3px] font-extrabold text-lg text-center outline-none transition-colors ${ce?M?"border-emerald-400 text-emerald-700 bg-emerald-50":"border-rose-400 text-rose-700 bg-rose-50":"border-slate-200 focus:border-[#7C3AED] bg-white text-slate-800"}`})}),ce&&N&&e.jsxs("div",{className:"w-full max-w-3xl mt-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#0a1628]",children:se.topic||t?.subject||"General Math"}),e.jsxs("p",{className:"text-sm text-slate-500",children:["Question ",L+1," Explanation"]})]}),e.jsx("img",{src:"/icons/default-module-avatar.png",alt:"Module Avatar",className:"w-12 h-12 rounded-full object-cover border-2 border-slate-200"})]}),ce&&N&&e.jsx(v.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"w-full mt-4 space-y-4 max-w-3xl",children:e.jsxs("div",{className:`border-2 rounded-2xl p-5 flex items-start gap-4 ${(L===r?M:Y[L]?.correct)?"bg-emerald-50 border-emerald-200":"bg-rose-50 border-rose-200"}`,children:[(L===r?M:Y[L]?.correct)?e.jsx(zt,{size:28,className:"text-emerald-500 shrink-0 mt-0.5"}):e.jsx(Ht,{size:28,className:"text-rose-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`font-extrabold text-lg mb-1 ${(L===r?M:Y[L]?.correct)?"text-emerald-700":"text-rose-700"}`,children:(L===r?M:Y[L]?.correct)?"Correct!":"Incorrect"}),e.jsx("p",{className:`text-base leading-relaxed ${(L===r?M:Y[L]?.correct)?"text-emerald-800":"text-rose-800"}`,children:se.explanation||`Correct Answer: ${se.correctAnswerText||se.options?.[se.correctAnswer]}`})]})]})})]})]},L)}),e.jsx("footer",{className:"shrink-0 relative z-[60] flex flex-col items-center justify-center p-4 sm:p-6 bg-gradient-to-r from-purple-600 to-indigo-400 rounded-t-[32px] sm:rounded-t-[40px] shadow-[0_-10px_40px_rgba(0,0,0,0.15)]",children:(()=>{const S=(je[r]||[]).length,h=(ue.options||[]).length-1,H=h>0&&S>=h;return H||ce&&!M?e.jsxs("button",{onClick:ct,className:"bg-orange-500 hover:bg-orange-600 text-white font-extrabold text-lg px-8 py-4 rounded-full flex items-center justify-center gap-3 shadow-xl hover:scale-[1.02] active:scale-[0.98] transition-all w-full max-w-md mx-auto",children:[r{const Q=st>0&&!d&&!H;return e.jsxs("button",{onClick:pe,disabled:!Q,className:"bg-white hover:bg-slate-50 disabled:opacity-70 disabled:cursor-not-allowed text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx("img",{src:"/icons/quiz_key.png",alt:"Key",className:"w-5 h-5 object-contain"})," Hint"]})})(),ce&&e.jsxs("button",{onClick:()=>_(!0),className:"bg-white hover:bg-slate-50 text-slate-700 font-bold px-6 sm:px-8 py-3 sm:py-3.5 rounded-full flex items-center gap-2 shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(Je,{size:20})," Explain"]}),e.jsx("button",{onClick:()=>f(Q=>!Q),className:`w-11 h-11 sm:w-12 sm:h-12 rounded-full flex items-center justify-center shadow-lg transition-transform hover:scale-105 active:scale-95 border border-slate-200 ${P?"bg-purple-100 text-purple-600 border-purple-300":"bg-white hover:bg-slate-50 text-slate-700"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"6",y2:"6"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M8 14h.01"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M8 18h.01"}),e.jsx("line",{x1:"16",x2:"16",y1:"14",y2:"18"})]})})]}):Lke(r),className:"bg-white text-slate-700 font-extrabold text-lg px-6 sm:px-8 py-3 sm:py-4 rounded-full inline-flex items-center gap-2 sm:gap-3 shadow-lg hover:bg-slate-50 transition-transform hover:scale-105 active:scale-95 border border-slate-200",children:[e.jsx(ht,{size:20}),"Back to Current Question"]}):null})()})]})]})};function $r(t,a){const l={"Pre-Calculus":["What is the domain of the function f(x) = √(x - 2)?","Solve for x: 2^x = 16","What is the period of the function y = sin(2x)?","Find the inverse of f(x) = 3x + 5","What is the value of log₂(32)?","Simplify: (x² - 9) / (x - 3)","What is the range of f(x) = |x| - 3?","If f(x) = 2x + 1 and g(x) = x², find f(g(2)).","What is the amplitude of y = 3cos(x)?","Solve: log₃(x) = 4"],"General Mathematics":["Simplify: (2x + 3)(x - 4)","What is 15% of 240?","Solve: 3x + 7 = 22","What is the value of 5! (5 factorial)?","Convert 0.75 to a fraction","What is 25% of 360?","Simplify: 12/18","What is the GCD of 24 and 36?","Convert 3/8 to a decimal","If a shirt costs $40 and is 20% off, what is the sale price?","What is 2/3 + 1/4?","Calculate: 15% tip on a $80 bill","Simplify: 45/60","What fraction is equivalent to 0.125?","If 30% of a number is 45, what is the number?"],"Statistics and Probability":["What is the probability of rolling a 6 on a fair die?","Calculate the mean of: 4, 7, 9, 12, 15","What is the median of: 2, 5, 8, 11, 14?","In a bag with 5 red and 3 blue balls, what is P(red)?","What is the range of: 10, 15, 20, 25, 30?","What is the mode of: 3, 5, 5, 7, 8, 5, 9?","What is the standard deviation concept?","P(A) = 0.3, P(B) = 0.5, events independent. P(A and B) = ?","What is the median of: 4, 7, 10, 13?","How many ways can you arrange 3 books?"],"Basic Calculus":["Find the derivative of f(x) = 3x²","What is the limit of (x² - 4)/(x - 2) as x → 2?","Integrate: ∫ 2x dx","Find f'(x) if f(x) = 5x³ - 2x","What is the derivative of sin(x)?","Find the derivative of f(x) = eˣ + 3x","What is ∫ cos(x) dx?","Find the derivative of f(x) = ln(x)","What is the limit of 1/x as x → ∞?","Find f'(x) if f(x) = x⁴ - 2x² + 1"]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function Dt(t){const a=t.toLowerCase();return a.includes("pre-calc")||a.includes("pre calc")||a.includes("precalc")?"Pre-Calculus":a.includes("statistic")||a.includes("probability")?"Statistics and Probability":a.includes("calculus")&&!a.includes("pre")?"Basic Calculus":a.includes("general")||a.includes("math")||a.includes("algebra")||a.includes("fraction")||a.includes("percent")||a.includes("ratio")||a.includes("geometry")?"General Mathematics":a.includes("derivative")||a.includes("integral")||a.includes("limit")?"Basic Calculus":a.includes("trig")||a.includes("function")||a.includes("log")?"Pre-Calculus":a.includes("mean")||a.includes("median")||a.includes("data")?"Statistics and Probability":"General Mathematics"}function Br(t,a){const l={"Pre-Calculus":[["x ≥ 2","x ≤ 2","x ≥ 0","All real numbers"],["x = 2","x = 4","x = 8","x = 16"],["π","2π","π/2","4π"],["f⁻¹(x) = (x - 5)/3","f⁻¹(x) = 3x - 5","f⁻¹(x) = x/3 - 5","f⁻¹(x) = (x + 5)/3"],["4","5","6","7"],["x + 3","x - 3","x² + 3","(x + 3)(x - 3)"],["y ≥ -3","y ≥ 0","All real numbers","y > -3"],["9","5","7","3"],["1","2","3","1/3"],["12","27","64","81"]],"General Mathematics":[["2x² - 5x - 12","2x² + 5x - 12","2x² - 8x + 12","2x² - 5x + 12"],["36","32","28","24"],["x = 5","x = 4","x = 6","x = 7"],["120","24","60","720"],["3/4","1/2","2/3","4/5"],["90","80","100","72"],["2/3","3/4","4/6","6/9"],["12","6","8","4"],["0.375","0.38","0.35","0.325"],["$32","$28","$30","$36"],["11/12","3/7","5/6","2/3"],["$12","$10","$15","$8"],["3/4","2/3","4/5","9/12"],["1/8","1/4","1/5","1/6"],["150","135","120","160"]],"Statistics and Probability":[["1/6","1/3","1/2","2/3"],["9.4","8.5","10.2","7.8"],["8","9","7","10"],["5/8","3/8","1/2","2/5"],["20","15","25","30"],["5","3","7","8"],["Spread of data from the mean","The highest value","The average","The middle value"],["0.15","0.8","0.35","0.2"],["8.5","7","10","9"],["6","3","9","12"]],"Basic Calculus":[["6x","3x","9x²","6x²"],["4","2","0","undefined"],["x² + C","2x² + C","x²/2 + C","2x + C"],["15x² - 2","15x² - 2x","5x² - 2","15x - 2"],["cos(x)","-cos(x)","tan(x)","-sin(x)"],["eˣ + 3","eˣ + 3x","xeˣ + 3","eˣ"],["sin(x) + C","-sin(x) + C","tan(x) + C","-cos(x) + C"],["1/x","x","ln(x)","-1/x²"],["0","1","∞","undefined"],["4x³ - 4x","4x³ - 2x","x³ - 4x","4x⁴ - 4x²"]]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function Hr(t,a){const l={"Pre-Calculus":[0,1,0,0,1,0,0,0,2,3],"General Mathematics":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Statistics and Probability":[0,0,0,0,0,0,0,0,0,0],"Basic Calculus":[0,0,0,0,0,0,0,0,0,0]},o=Dt(t),n=l[o]||l["General Mathematics"];return n[a%n.length]}function Qr(t,a,l){const o={"Pre-Calculus":["The expression under the square root must be non-negative: x - 2 ≥ 0, so x ≥ 2.","Since 2⁴ = 16, we get x = 4.","The period of sin(kx) is 2π/k. Here k = 2, so period = 2π/2 = π.","To find the inverse: y = 3x + 5 → x = 3y + 5 → y = (x - 5)/3.","Since 2⁵ = 32, log₂(32) = 5.","(x² - 9)/(x - 3) = (x+3)(x-3)/(x-3) = x + 3 (for x ≠ 3).","The absolute value |x| ≥ 0 for all x, so |x| - 3 ≥ -3. The range is y ≥ -3.","g(2) = 4, then f(4) = 2(4) + 1 = 9.","The amplitude of y = Acos(x) is |A|. Here A = 3, so amplitude = 3.","log₃(x) = 4 means 3⁴ = x, so x = 81."],"General Mathematics":["(2x + 3)(x - 4) = 2x² - 8x + 3x - 12 = 2x² - 5x - 12","15% of 240 = 0.15 × 240 = 36","3x + 7 = 22 → 3x = 15 → x = 5","5! = 5 × 4 × 3 × 2 × 1 = 120","0.75 = 75/100 = 3/4 after simplifying by dividing both by 25","25% of 360 = 0.25 × 360 = 90","12/18 = (12÷6)/(18÷6) = 2/3","Factors of 24: {1,2,3,4,6,8,12,24}. Factors of 36: {1,2,3,4,6,9,12,18,36}. GCD = 12","3 ÷ 8 = 0.375","20% off $40 = $40 × 0.80 = $32","2/3 + 1/4 = 8/12 + 3/12 = 11/12","15% of $80 = 0.15 × 80 = $12","45/60 = (45÷15)/(60÷15) = 3/4","0.125 = 125/1000 = 1/8","30% × N = 45 → N = 45/0.30 = 150"],"Statistics and Probability":["A fair die has 6 outcomes, each equally likely. P(6) = 1/6.","Mean = (4 + 7 + 9 + 12 + 15) / 5 = 47/5 = 9.4","Sorted: 2, 5, 8, 11, 14. The middle value is 8.","P(red) = 5/(5+3) = 5/8","Range = max - min = 30 - 10 = 20","The value 5 appears 3 times, more than any other value. Mode = 5.","Standard deviation measures how spread out data points are from the mean.","For independent events: P(A and B) = P(A) × P(B) = 0.3 × 0.5 = 0.15","For even-count dataset {4,7,10,13}: median = (7+10)/2 = 8.5","3 books can be arranged in 3! = 3 × 2 × 1 = 6 ways."],"Basic Calculus":["Using the power rule: d/dx[3x²] = 3 × 2x = 6x","Factor: (x²-4)/(x-2) = (x+2)(x-2)/(x-2) = x+2. As x→2: 2+2 = 4","∫ 2x dx = 2 × x²/2 + C = x² + C","f'(x) = 5 × 3x² - 2 = 15x² - 2","The derivative of sin(x) is cos(x). This is a fundamental trigonometric derivative.","d/dx[eˣ + 3x] = eˣ + 3. The derivative of eˣ is eˣ and of 3x is 3.","∫ cos(x) dx = sin(x) + C. Integration is the reverse of differentiation.","The derivative of ln(x) is 1/x. This is a fundamental logarithmic derivative.","As x → ∞, 1/x approaches 0. The function gets infinitely close to zero.","f'(x) = 4x³ - 4x using the power rule on each term."]},n=Dt(t),r=o[n]||o["General Mathematics"];return r[a%r.length]}function qr(t){const a=Math.floor(t/60),l=t%60;return`${a}:${l.toString().padStart(2,"0")}`}const zs={common:"bg-slate-100 text-slate-500",rare:"bg-blue-50 text-blue-500",epic:"bg-amber-50 text-amber-500"},_s=["bg-[#1FA7E1]/80 text-white","bg-[#9956DE]/80 text-white","bg-[#FFB356]/90 text-white","bg-[#7274ED]/80 text-white","bg-[#1FA7E1]/80 text-white","bg-[#9956DE]/80 text-white","bg-gradient-to-r from-[#FFB356] to-[#FF8C00] text-white"],Or=({isOpen:t,onClose:a,onClaim:l,weekRewards:o,todayReward:n,canClaim:r,isClaiming:i,claimedDays:x,currentDayIndex:p,timeUntilReset:b})=>{const[g,M]=s.useState(!1);if(!t)return null;const z=()=>{if(!r||g)return;M(!0),n?.rarity==="epic"?xs({particleCount:150,spread:80,origin:{y:.6},colors:["#FFD700","#FFA500","#FF8C00","#FF6B6B","#4ade80"]}):xs({particleCount:100,spread:70,origin:{y:.6},colors:["#FFD700","#FFA500","#FF8C00"]}),setTimeout(()=>{M(!1),l()},1200)},d=y=>y+1,A=y=>y===p,N=y=>x.includes(y),_=y=>y>p,R=o.slice(0,6),m=o[6];return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-8",children:[e.jsx($e,{children:t&&e.jsx(v.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-slate-900/60 backdrop-blur-sm",onClick:a})}),e.jsxs(v.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"relative w-full max-w-[420px] bg-[#f7f9fc] rounded-3xl border border-[#dde3eb] shadow-2xl flex flex-col items-center p-5 overflow-visible",children:[e.jsxs("div",{className:"absolute -top-6 w-[85%] h-12 bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] rounded-xl shadow-lg flex items-center justify-center z-20",children:[e.jsx("div",{className:"absolute -left-2.5 -z-10 w-5 h-8 bg-[#633299] rounded-l-full rotate-12 top-1.5"}),e.jsx("div",{className:"absolute -right-2.5 -z-10 w-5 h-8 bg-[#10709b] rounded-r-full -rotate-12 top-1.5"}),e.jsx("h2",{className:"text-white font-black text-lg tracking-wide uppercase drop-shadow-sm font-display",children:"Daily Rewards"})]}),e.jsx("button",{onClick:a,className:"absolute -right-3 -top-3 w-8 h-8 bg-white hover:bg-slate-100 border border-slate-200 text-slate-500 hover:text-slate-800 rounded-full flex items-center justify-center z-30 shadow-md transition-transform hover:scale-105 active:scale-95",children:e.jsx(De,{size:16,strokeWidth:3})}),e.jsxs("div",{className:"mt-6 mb-2 text-center w-full",children:[e.jsx("h3",{className:"text-xl font-bold text-slate-800 font-display mt-2",children:"Welcome Back!"}),e.jsx("p",{className:"text-slate-500 font-medium text-xs mt-0.5",children:"Claim your daily reward for today."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 w-full mb-5 relative z-10",children:[R.map((y,j)=>{const E=d(j),k=N(j),U=A(j),O=_(j);return e.jsxs("div",{className:`relative rounded-xl flex flex-col overflow-hidden border-[1.5px] transition-all ${U&&!k?"border-amber-400 shadow-[0_0_15px_rgba(251,191,36,0.25)] scale-105 z-10 bg-amber-50":k?"border-[#dde3eb] bg-slate-200/50":"border-[#dde3eb] bg-white"}`,children:[e.jsxs("div",{className:`py-0.5 text-center font-black text-[10px] uppercase tracking-wider ${U&&!k?"bg-amber-400 text-amber-900":_s[j]}`,children:["Day ",E]}),e.jsx("div",{className:"absolute top-5 right-1 z-10",children:e.jsx("span",{className:`text-[8px] font-bold uppercase px-1 rounded ${zs[y.rarity]}`,children:y.rarity})}),e.jsxs("div",{className:"flex-1 p-2 flex flex-col items-center justify-center relative min-h-[75px]",children:[k&&e.jsxs(v.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",bounce:.5},className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-rose-200/50"})}),e.jsxs("div",{className:"relative w-14 h-14 rounded-full border-[3px] border-rose-500 bg-rose-100 flex items-center justify-center transform -rotate-12 shadow-lg",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"Claimed",className:"w-10 h-10 object-contain drop-shadow-md"}),e.jsx("div",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 bg-rose-500 rounded-md px-2 py-0.5 border-2 border-rose-300 shadow-md",children:e.jsx("span",{className:"text-[9px] font-black text-white uppercase tracking-wider leading-none whitespace-nowrap",children:"Claimed"})})]})]}),O&&e.jsx("div",{className:"absolute top-1 right-1 bg-slate-200 rounded-full p-0.5 z-10",children:e.jsx(Vt,{size:8,className:"text-slate-400"})}),e.jsxs("div",{className:`flex flex-col items-center transition-all w-full ${k?"opacity-30 grayscale":""}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center border-2 mb-1",style:{backgroundColor:y.color+"20",borderColor:y.color+"40"},children:e.jsx("span",{className:"text-lg",children:y.icon})}),e.jsx("div",{className:`font-black text-xs leading-none mt-0.5 text-center ${U?"text-amber-600":k?"text-slate-500":"text-slate-600"}`,children:y.label})]})]})]},y.id)}),m&&e.jsxs("div",{className:`col-span-3 relative rounded-xl flex flex-col overflow-hidden border-[1.5px] transition-all mt-1 ${A(6)&&!N(6)?"border-amber-400 shadow-[0_0_20px_rgba(251,191,36,0.3)] scale-[1.02] z-10 bg-amber-50":N(6)?"border-[#dde3eb] bg-slate-200/50":"border-[#dde3eb] bg-white"}`,children:[e.jsx("div",{className:`py-1 text-center font-black text-[10px] uppercase tracking-widest ${A(6)&&!N(6)?"bg-amber-400 text-amber-900":_s[6]}`,children:"Day 7 • Epic Reward"}),e.jsx("div",{className:"absolute top-6 right-2 z-10",children:e.jsx("span",{className:`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded ${zs[m.rarity]}`,children:m.rarity})}),e.jsxs("div",{className:"flex items-center justify-center gap-5 p-3 relative",children:[N(6)&&e.jsxs(v.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",bounce:.5},className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-rose-200/50"})}),e.jsxs("div",{className:"relative w-20 h-20 rounded-full border-[4px] border-rose-500 bg-rose-100 flex items-center justify-center transform rotate-12 shadow-lg",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"Claimed",className:"w-14 h-14 object-contain drop-shadow-md"}),e.jsx("div",{className:"absolute -bottom-3 left-1/2 -translate-x-1/2 bg-rose-500 rounded-md px-2.5 py-1 border-2 border-rose-300 shadow-md",children:e.jsx("span",{className:"text-[10px] font-black text-white uppercase tracking-wider leading-none whitespace-nowrap",children:"Claimed"})})]})]}),e.jsxs("div",{className:`flex items-center justify-center gap-5 w-full transition-all ${N(6)?"opacity-30 grayscale":""}`,children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center border-2 shadow-sm mb-0.5",style:{backgroundColor:m.color+"20",borderColor:m.color+"40"},children:e.jsx("span",{className:"text-2xl",children:m.icon})}),e.jsx("span",{className:`font-black text-sm ${A(6)?"text-amber-600":"text-slate-600"}`,children:m.label})]}),m.rarity==="epic"&&e.jsxs("div",{className:"relative mt-1",children:[e.jsx("div",{className:"w-14 h-14 bg-purple-50 rounded-xl flex items-center justify-center border-2 border-purple-200 shadow-sm",children:e.jsx("span",{className:"text-3xl drop-shadow-md",children:"🎁"})}),e.jsx("div",{className:"absolute -right-5 -bottom-4 w-14 h-14 bg-white rounded-xl p-1 border-2 border-amber-300 shadow-lg transform rotate-[-5deg]",children:e.jsx("img",{src:"/avatar/crown_thumbnail.png",alt:"Crown",className:"w-full h-full object-contain drop-shadow-md"})})]})]})]})]})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-xs text-slate-400",children:[e.jsx(Za,{size:14}),e.jsx("span",{className:"font-mono font-medium",children:b}),e.jsx("span",{children:"until next reset"})]}),e.jsx(v.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:z,disabled:!r||i||g,className:`w-[85%] py-3 rounded-full font-black text-base tracking-wide uppercase shadow-lg transition-all mt-2 ${!r||i||g?"bg-slate-200 text-slate-400 cursor-not-allowed border border-slate-300":"bg-gradient-to-r from-[#FFB356] to-[#FF8C00] text-white hover:from-[#FFA500] hover:to-[#FF7F00] border-b-4 border-[#e67e00]"}`,children:i||g?"Claiming...":r?"Claim!":"Claimed"})]})]})};function Wr(t){const[a,l]=s.useState({difficulty:"normal",loading:!0});return s.useEffect(()=>{if(!t){l({difficulty:"normal",loading:!1});return}const o=bt(We,"users",t);return Gt(o,r=>{if(!r.exists()){l({difficulty:"normal",loading:!1});return}const x=r.data()?.moduleDifficulty||"normal";l({difficulty:["normal","easier","remedial"].includes(x)?x:"normal",loading:!1})},r=>{console.error("[useModuleDifficulty] snapshot error:",r),l({difficulty:"normal",loading:!1})})},[t]),a}function Ur(t,a){return a==="normal"?t:a==="easier"?t.filter(l=>{const o=l.tags||[],n=l.difficulty||"";return o.some(r=>["foundation","basic","introductory"].includes(r.toLowerCase()))||["foundation","basic","introductory"].includes(n.toLowerCase())||!o.includes("advanced")&&!n.toLowerCase().includes("advanced")}):a==="remedial"?t.filter(l=>{const o=l.tags||[],n=l.difficulty||"";return o.some(r=>["remedial","review","catch-up"].includes(r.toLowerCase()))||["remedial","review","catch-up"].includes(n.toLowerCase())}):t}const Xr=new Set([7,14,30,60,100]),St={lastClaimedDate:"",lastClaimedWeekSeed:0,claimedDays:[],currentStreak:0,longestStreak:0,totalClaimed:0,hintTokens:0,streakShields:0,activeMultiplier:null};function Gr(t){if(t<=0)return"00:00:00";const a=Math.floor(t/1e3),l=Math.floor(a/3600),o=Math.floor(a%3600/60),n=a%60;return`${String(l).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function Vr(){const t=Jt();return t.setDate(t.getDate()-1),Zt(t)}function Os(t){return t?new Date(t.expiresAt).getTime()>Date.now():!1}function Ws(t){return bt(We,"users",t,"dailyRewards",t)}function Yr(t){return bt(We,"users",t)}async function Ms(t){try{const a=Ws(t),l=await Wt(a);if(!l.exists())return{...St};const o=l.data(),n=es();return o.lastClaimedWeekSeed&&o.lastClaimedWeekSeed!==n?{...o,claimedDays:[],lastClaimedWeekSeed:n}:{...St,...o,activeMultiplier:o.activeMultiplier&&Os(o.activeMultiplier)?o.activeMultiplier:null}}catch(a){return console.error("[dailyRewardService] Error getting state:",a),{...St}}}function Kr(t){const a=Zt();return t.lastClaimedDate!==a}async function Zr(t){const a=Zt(),l=es(),o=ts(),r=ss()[o];if(!r)throw new Error(`No reward found for day index ${o}`);try{const i=await Ys(We,async p=>{const b=Ws(t),g=Yr(t),M=await p.get(b),z=await p.get(g);let d;if(M.exists()?d={...St,...M.data()}:(d={...St,lastClaimedWeekSeed:l},p.set(b,d)),d.lastClaimedWeekSeed!==l&&(d.claimedDays=[],d.lastClaimedWeekSeed=l),d.lastClaimedDate===a)return{code:"ALREADY_CLAIMED",state:d};let A=d.currentStreak,N=!1;if(!d.lastClaimedDate||d.currentStreak===0)A=1;else{const j=Vr();d.lastClaimedDate===j?A=d.currentStreak+1:d.streakShields>0?(d.streakShields-=1,A=d.currentStreak+1,N=!0):A=1}const _=Math.max(d.longestStreak,A);let R=0,m=1;switch(r.type){case"xp":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;m=Os(d.activeMultiplier)?d.activeMultiplier?.multiplier??1:1,R=Math.floor(j*m);break}case"hint_token":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;d.hintTokens+=j;break}case"streak_shield":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||0;d.streakShields+=j;break}case"xp_multiplier":{const j=typeof r.value=="number"?r.value:parseInt(r.value,10)||60,E=r.id.includes("2")?2:1.5,k=new Date;k.setMinutes(k.getMinutes()+j),d.activeMultiplier={multiplier:E,expiresAt:k.toISOString()};break}case"badge_unlock":break}const y=[...d.claimedDays,o];return d.lastClaimedDate=a,d.currentStreak=A,d.longestStreak=_,d.totalClaimed+=1,p.set(b,d,{merge:!0}),z.exists()&&p.update(g,{hintTokens:d.hintTokens,streakShields:d.streakShields,activeMultiplier:d.activeMultiplier,lastClaimedDate:d.lastClaimedDate,updatedAt:Ks()}),{code:"SUCCESS",state:d,newClaimedDays:y,newStreak:A,newLongestStreak:_,xpAwarded:R,multiplierApplied:m,streakPreserved:N}});if(i.code==="ALREADY_CLAIMED")return{success:!1,reward:r,dayIndex:o,streakAfter:i.state.currentStreak,longestStreakAfter:i.state.longestStreak,hintTokensAfter:i.state.hintTokens,streakShieldsAfter:i.state.streakShields,streakPreserved:!1,xpAwarded:0,multiplierApplied:1,isMilestone:!1,error:"Already claimed today"};if(i.xpAwarded>0)try{await ca(t,i.xpAwarded,"daily_reward",`Daily Reward Day ${o+1}! +${i.xpAwarded} XP`)}catch(p){console.error("[dailyRewardService] Error awarding XP:",p)}if(r.type==="badge_unlock"&&typeof r.value=="string")try{await Is(t,r.value)}catch(p){console.error("[dailyRewardService] Error unlocking avatar item:",p)}const x=Xr.has(i.newStreak);return{success:!0,reward:r,dayIndex:o,streakAfter:i.newStreak,longestStreakAfter:i.newLongestStreak,hintTokensAfter:i.state.hintTokens,streakShieldsAfter:i.state.streakShields,streakPreserved:i.streakPreserved,xpAwarded:i.xpAwarded,multiplierApplied:i.multiplierApplied,isMilestone:x}}catch(i){throw console.error("[dailyRewardService] Error claiming daily reward:",i),i}}function Jr(t){const[a,l]=s.useState(null),[o,n]=s.useState(!1),[r,i]=s.useState(!1),[x,p]=s.useState(null),[b,g]=s.useState(null),[M,z]=s.useState("00:00:00"),d=s.useRef(null),A=s.useMemo(()=>ss(),[]),N=s.useMemo(()=>lr(),[]),_=s.useCallback(async()=>{if(!t){l(null);return}try{g(null);const E=await Ms(t);l(E)}catch(E){const k=E instanceof Error?E.message:"Failed to load rewards";g(k),console.error("[useDailyReward] refresh error:",E)}},[t]);s.useEffect(()=>{_()},[_]),s.useEffect(()=>{const E=()=>{const U=sr().getTime()-Date.now();z(Gr(U))};return E(),d.current=setInterval(E,1e3),()=>{d.current&&(clearInterval(d.current),d.current=null)}},[]);const R=s.useMemo(()=>!a||o?!1:Kr(a),[a,o]),m=s.useMemo(()=>!a?.activeMultiplier||new Date(a.activeMultiplier.expiresAt).getTime()<=Date.now()?null:a.activeMultiplier,[a?.activeMultiplier]),y=s.useCallback(async()=>{if(!(!t||!R)){n(!0),g(null);try{const E=await Zr(t);if(p(E),E.success){i(!0);const k=await Ms(t);l(k)}else g(E.error||"Claim failed")}catch(E){const k=E instanceof Error?E.message:"Claim failed";g(k),console.error("[useDailyReward] claim error:",E)}finally{n(!1)}}},[t,R]),j=s.useCallback(()=>{i(!1)},[]);return{weekRewards:A,todayReward:N,canClaim:R,isClaiming:o,claimedDays:a?.claimedDays??[],currentStreak:a?.currentStreak??0,longestStreak:a?.longestStreak??0,totalClaimed:a?.totalClaimed??0,hintTokens:a?.hintTokens??0,streakShields:a?.streakShields??0,activeMultiplier:m,timeUntilReset:M,showModal:r,lastClaimResult:x,error:b,claim:y,dismissModal:j,refresh:_}}const el=["all","Q1","Q2","Q3","Q4"],Bl=({onEarnXP:t,atRiskSubjects:a=[],priorityTopics:l=[],initialModuleId:o=null,isInQuizMode:n=!1,setIsInQuizMode:r,hasCompletedDiagnostic:i=!1})=>{const{userProfile:x,currentUser:p}=It(),[b,g]=s.useState("modules"),M=x,z=M?.grade,d=da(z);ka(d);const[A,N]=s.useState(""),[_,R]=s.useState("all"),[m,y]=s.useState("all"),[j,E]=s.useState("all"),[k,U]=s.useState(!1),[O,Y]=s.useState(null),[$,te]=s.useState(null),xe=s.useMemo(()=>{const c=M?.learnerCurriculumAssignments?.subjects??M?.assignedSubjects??M?.curriculumAssignedSubjects??[];return Array.isArray(c)?c:[]},[M]),{difficulty:_e}=Wr(p?.uid||null),re=s.useMemo(()=>{const c=xa(d,xe);return Ur(c,_e)},[d,xe,_e]),W=o&&re.find(c=>c.id===o)||null,[Z,ge]=s.useState(W),[K,we]=s.useState(null),[Me,I]=s.useState(null),[u,P]=s.useState(!1),[f,T]=s.useState(null),[F,ee]=s.useState(!1),[ne,Be]=s.useState([]),[gt,Ue]=s.useState(!1);s.useEffect(()=>{if(b!=="teacher_uploaded"||!We)return;Ue(!0);const c=Gt(Zs(ea(We,"modules"),Js("moduleType","==","teacher_uploaded")),D=>{const X=D.docs.map(le=>({...le.data(),moduleId:le.id}));Be(X),Ue(!1)},D=>{console.error("Error fetching teacher modules:",D),Ue(!1)});return()=>c()},[b]);const[et,je]=s.useState(!1),{weekRewards:nt,todayReward:_t,canClaim:Xe,isClaiming:wt,claimedDays:Ge,timeUntilReset:tt,claim:it,lastClaimResult:He}=Jr(x?.uid??null);s.useEffect(()=>{if(!x?.uid)return;let c=!1;const D=async L=>{c||(Xe||L)&&je(!0)},X=L=>{L.detail?.tab==="Modules"&&D(!0)},le=setTimeout(()=>D(),500);return window.addEventListener("mathpulse:navigate",X),()=>{c=!0,clearTimeout(le),window.removeEventListener("mathpulse:navigate",X)}},[x?.uid,Xe]);const Ve=async()=>{if(x?.uid)try{await it(),He?.success&&(ba({userId:x.uid,type:"daily_checkin",title:"Daily Reward Claimed!",message:`You earned ${He.reward.label} and kept your streak alive!`,metadata:{rewardId:He.reward.id,streakDay:He.dayIndex+1}}).catch(console.error),He.reward.rarity==="epic"&&Is(x.uid,"acc_crown").then(()=>Bt.success("👑 Epic reward unlocked!")).catch(console.error)),setTimeout(()=>je(!1),1e3)}catch(c){const D=c instanceof Error?c.message:"";console.error("Failed to claim daily reward:",c),D.includes("Already claimed")?Bt.info("You already claimed your reward today!"):Bt.error("Failed to claim daily reward. Please try again.")}};s.useEffect(()=>{if(o){const c=re.find(D=>D.id===o);c&&ge(c)}},[o,re]),s.useEffect(()=>{x?.uid&&(ee(!0),ma(x.uid).then(c=>{T(c)}).catch(c=>{console.error("Failed to load competency profile:",c)}).finally(()=>{ee(!1)}))},[x?.uid]);const ye=s.useMemo(()=>{const c=l.length>0?l:a.map(X=>ua(X)).filter(X=>X!==null),D=new Set;return c.filter(X=>D.has(X)?!1:(D.add(X),!0))},[l,a]),{data:ve=[]}=Vs({queryKey:pa.modules(d,ye),enabled:!0,staleTime:600*1e3,gcTime:1800*1e3,queryFn:async()=>{const c=re;if(ye.length===0)return c;const D=new Map(ye.map((X,le)=>[ga[X],le]));return[...c].sort((X,le)=>{const L=D.get(X.id)??Number.POSITIVE_INFINITY,ke=D.get(le.id)??Number.POSITIVE_INFINITY;return L-ke})}}),Ne=s.useMemo(()=>{const c=new Set;return ve.forEach(D=>c.add(D.competency_group)),Array.from(c)},[ve]),st=s.useMemo(()=>{const c=A.trim().toLowerCase(),D=ve.filter(X=>{const le=!c||X.title.toLowerCase().includes(c),L=!c||X.description.toLowerCase().includes(c),ke=!c||X.lessons.some(Ie=>Ie.title.toLowerCase().includes(c)),Se=!c||X.quizzes.some(Ie=>Ie.title.toLowerCase().includes(c)),Le=c?X.competencies.some(Ie=>Ie.outcome.toLowerCase().includes(c)||Ie.code.toLowerCase().includes(c)):!0,oe=_==="all"||X.subjectId===_,ue=m==="all"||X.quarter===m,at=j==="all"||X.competency_group===j;return(le||L||ke||Se||Le)&&oe&&ue&&at});if(f?.competencies){const X=new Set(Object.entries(f.competencies).filter(([,L])=>L.score<50).map(([L])=>L)),le=new Set(Object.entries(f.competencies).filter(([,L])=>L.score>=80).map(([L])=>L));return D.sort((L,ke)=>{const Se=L.competencies.map(pe=>pe.code),Le=ke.competencies.map(pe=>pe.code),oe=Se.some(pe=>X.has(pe))?1:0,ue=Le.some(pe=>X.has(pe))?1:0,at=Se.some(pe=>le.has(pe))?1:0,Ie=Le.some(pe=>le.has(pe))?1:0,fe=oe*2+at;return ue*2+Ie-fe})}return D},[ve,A,_,m,j,f]),Qe=s.useMemo(()=>{const c=m==="all"?"All Quarters":m,D=_==="all"?"All Subjects":cs[_]?.label??"Subject";return`${d} · ${D} · ${c}`},[d,_,m]),ot=s.useMemo(()=>{const c=new Set(ve.map(D=>D.subjectId));return Array.from(c)},[ve]),Ye=()=>{R("all"),y("all"),E("all"),N("")};s.useEffect(()=>{b!=="recommended"||ye.length===0||(P(!0),ha({weakTopics:ye.map(c=>ds[c]),subject:_!=="all"?_:"General Mathematics",userId:x?.uid}).then(c=>{I(c.curriculumContext),P(!1)}).catch(()=>P(!1)))},[b,ye]);const Ke=(c,D)=>{t&&t(D,`Quiz Completed! +${D} XP`),we(null),r&&r(!1)};return K?(r&&r(!0),e.jsx(Rr,{quiz:K,onClose:()=>we(null),onComplete:Ke,studentId:x?.uid})):Z?e.jsx(_r,{module:Z,onBack:()=>ge(null),onEarnXP:t,isInQuizMode:n,setIsInQuizMode:r}):$?e.jsxs("div",{className:"h-full overflow-y-auto px-4 sm:px-6 xl:px-10 pb-8 scrollbar-hide scroll-smooth relative",children:[e.jsxs("button",{onClick:()=>te(null),className:"mb-4 inline-flex items-center gap-2 text-sm font-bold text-slate-600 hover:text-slate-900 transition-colors",children:[e.jsx(pt,{className:"rotate-180",size:16}),"Back to Modules"]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#F08386]/30 p-6 md:p-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F08386]/12 border border-[#F08386]/30 text-[#F08386] text-xs font-bold",children:"Teacher Upload"}),$.quarter&&e.jsx("span",{className:"px-2 py-1 rounded-md bg-slate-100 text-slate-600 text-xs",children:$.quarter})]}),e.jsx("h1",{className:"text-2xl md:text-3xl font-display font-black text-slate-900 mb-2",children:$.title}),e.jsxs("p",{className:"text-sm text-slate-600 mb-6",children:[$.subject," · ",$.gradeLevel]}),$.summary&&e.jsx("p",{className:"text-slate-700 text-base leading-relaxed mb-6",children:$.summary}),$.learningObjectives?.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-2",children:"Learning Objectives"}),e.jsx("ul",{className:"list-disc list-inside space-y-1 text-slate-700",children:$.learningObjectives.map((c,D)=>e.jsx("li",{children:c},D))})]}),$.sections?.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-3",children:"Sections"}),e.jsx("div",{className:"space-y-3",children:$.sections.map((c,D)=>e.jsxs("div",{className:"border border-slate-200 rounded-xl p-4",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-800 mb-1",children:c.title}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:c.content})]},D))})]}),$.practice?.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900 mb-3",children:"Practice Questions"}),e.jsx("div",{className:"space-y-3",children:$.practice.map((c,D)=>e.jsxs("div",{className:"border border-slate-200 rounded-xl p-4",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 mb-2",children:c.question}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-2",children:c.options.map((X,le)=>e.jsxs("div",{className:"text-xs text-slate-600 bg-slate-50 rounded-lg px-3 py-2",children:[X.label,". ",X.text]},le))}),e.jsxs("p",{className:"text-xs text-emerald-700 font-semibold",children:["Answer: ",c.answer]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:c.explanation})]},D))})]})]})]}):e.jsxs("div",{className:"h-full overflow-y-auto px-4 sm:px-6 xl:px-10 pb-8 scrollbar-hide scroll-smooth relative",onScroll:c=>U(c.currentTarget.scrollTop>100),children:[e.jsx(Or,{isOpen:et,onClose:()=>je(!1),onClaim:Ve,weekRewards:nt,todayReward:_t,canClaim:Xe,isClaiming:wt,claimedDays:Ge,currentDayIndex:ts(),timeUntilReset:tt}),e.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-start lg:items-center py-6 gap-6",children:[e.jsxs("div",{className:"flex-1 max-w-3xl",children:[e.jsx("h1",{className:"text-[36px] md:text-[44px] font-display font-black text-[#202124] tracking-tight leading-[1.1] mb-4",children:"Curriculum Modules"}),e.jsx("p",{className:"text-[#3c4043] text-[16px] md:text-[17px] leading-[1.7] md:pr-10",children:"MathPulse AI loads modules directly from DepEd Strengthened SHS curriculum guides with AI-powered RAG lesson generation. Currently available: General Mathematics, Business Mathematics, and Statistics & Probability. Pre-Calculus and Basic Calculus modules are coming soon once teaching module PDFs are sourced."}),e.jsx("div",{className:"mt-4 flex items-center gap-3",children:e.jsx("div",{className:"inline-flex items-center rounded-full border border-sky-200 bg-sky-50 px-4 py-2 text-sm font-bold text-sky-900",children:Qe})})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center justify-center lg:justify-end w-full lg:w-[350px] mt-4 lg:mt-0",children:e.jsx(Er,{assessmentDismissed:x?.assessmentDismissed,initialAssessmentCompleted:x?.initialAssessmentCompleted})})]}),e.jsxs("div",{className:`sticky top-0 z-30 -mx-4 px-4 sm:-mx-6 sm:px-6 xl:-mx-10 xl:px-10 pt-3 pb-3 space-y-3 transition-colors duration-300 ${k?"bg-[#f8faff] border-b border-[#dde3eb] shadow-sm":"bg-transparent"}`,children:[e.jsxs("div",{className:"flex flex-col lg:flex-row items-center gap-3 w-full",children:[e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-[#5f6368]",children:e.jsx(Sa,{size:16,strokeWidth:2.5})}),e.jsx("input",{id:"modules-search",name:"modules-search","aria-label":"Search modules",type:"text",value:A,onChange:c=>N(c.target.value),placeholder:"Search modules, lessons, or assessments...",className:"w-full pl-10 pr-10 py-2 rounded-xl border border-[#dadce0] bg-white text-[#202124] text-[13px] font-medium focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-all shadow-sm"}),!1]}),e.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-2 w-full lg:w-auto shrink-0",children:[e.jsxs("select",{value:_,onChange:c=>R(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Subject",children:[e.jsx("option",{value:"all",children:"All Subjects"}),ot.map(c=>e.jsx("option",{value:c,children:cs[c].label},c))]}),e.jsx("select",{value:m,onChange:c=>y(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Quarter",children:el.map(c=>e.jsx("option",{value:c,children:c==="all"?"All Quarters":c},c))}),e.jsxs("select",{value:j,onChange:c=>E(c.target.value),className:"w-full md:w-auto rounded-xl border border-slate-200 bg-white pl-3 pr-8 py-2 text-xs font-semibold text-slate-700 focus:border-sky-400 focus:outline-none shadow-sm","aria-label":"Competency Group",children:[e.jsx("option",{value:"all",children:"All Competencies"}),Ne.map(c=>e.jsx("option",{value:c,children:c},c))]}),e.jsxs("button",{type:"button",onClick:Ye,className:"inline-flex w-full md:w-auto items-center justify-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-bold text-slate-700 transition-colors hover:bg-slate-50 shadow-sm shrink-0",children:[e.jsx(Ca,{size:14}),"Reset"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center bg-slate-100/80 p-1 rounded-full border border-slate-200/60 shadow-inner gap-1 overflow-x-auto no-scrollbar",children:[{id:"modules",label:"Modules",icon:Je,color:"text-[#1FA7E1]"},{id:"recommended",label:"Recommended",icon:Pt,color:"text-[#75D06A]"},{id:"practice",label:"Practice",icon:Oe,color:"text-[#FFB356]"},{id:"teacher_uploaded",label:"Teacher Uploaded",icon:fa,color:"text-[#F08386]"}].map(c=>{const D=b===c.id;return e.jsxs("button",{onClick:()=>g(c.id),className:`relative flex items-center gap-1.5 px-4 py-1.5 rounded-full text-[13px] font-bold transition-all duration-300 flex-shrink-0 ${D?"shadow-sm":"text-slate-500 hover:text-slate-700 hover:bg-slate-200/50"}`,children:[D&&e.jsx(v.div,{layoutId:"modulesTabBackground",className:"absolute inset-0 bg-white rounded-full shadow-[0_2px_15px_-3px_rgba(0,0,0,0.1)] border border-slate-100",transition:{type:"spring",bounce:.2,duration:.6}}),e.jsxs("span",{className:`relative z-10 flex items-center gap-1.5 ${D?c.color:""}`,children:[e.jsx(c.icon,{size:15,strokeWidth:D?2.5:2}),c.label]})]},c.id)})}),e.jsxs("div",{className:"flex items-center gap-2 ml-1",children:[b==="modules"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-indigo-50 border border-indigo-100 flex items-center justify-center text-indigo-500",children:e.jsx(va,{size:15,strokeWidth:2.5})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"DepEd Strengthened SHS Modules"})]}),b==="recommended"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#75D06A]/10 flex items-center justify-center",children:e.jsx(za,{size:15,className:"text-[#75D06A]"})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Suggested Next"})]}),b==="practice"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#FFB356]/10 flex items-center justify-center",children:e.jsx(Oe,{size:15,className:"text-[#FFB356]"})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Practice Center"})]}),b==="teacher_uploaded"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#F08386]/15 border border-[#F08386]/30 flex items-center justify-center text-[#F08386]",children:e.jsx(ms,{size:15,strokeWidth:2.5})}),e.jsx("span",{className:"font-display font-black text-[15px] text-slate-700 tracking-tight whitespace-nowrap",children:"Teacher Uploaded Modules"})]})]})]})]}),e.jsxs("div",{className:"pt-4",children:[ye.length>0&&e.jsxs("div",{className:"mb-4 rounded-2xl border border-amber-300 bg-amber-50 px-5 py-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-sm font-black text-amber-900",children:[e.jsx(Ls,{size:15}),"Assessment Focus Areas"]}),e.jsx("p",{className:"mt-1 text-sm text-amber-900/80",children:"Modules are currently prioritized by your latest diagnostic needs."})]}),e.jsxs("button",{type:"button",onClick:()=>g("recommended"),className:"inline-flex items-center gap-1.5 rounded-xl bg-amber-600 px-3 py-2 text-xs font-bold text-white transition-colors hover:bg-amber-700",children:["View Recommended",e.jsx(pt,{size:14})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:ye.map((c,D)=>e.jsxs("span",{className:"rounded-full bg-white px-3 py-1 text-xs font-semibold text-amber-900 shadow-sm",children:[D+1,". ",ds[c]]},c))})]}),e.jsx($e,{mode:"wait",children:e.jsx(v.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"pb-8 mt-4",children:b==="practice"?e.jsx(Mr,{onStartQuiz:we,searchQuery:A}):b==="teacher_uploaded"?gt?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6",children:[1,2,3].map(c=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-slate-200 rounded w-3/4 mb-4"}),e.jsx("div",{className:"h-3 bg-slate-100 rounded w-1/2 mb-3"}),e.jsx("div",{className:"h-3 bg-slate-100 rounded w-5/6"})]},c))}):ne.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 bg-[#F08386]/10 rounded-2xl flex items-center justify-center mx-auto mb-4",children:e.jsx(ms,{size:32,className:"text-[#F08386]"})}),e.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-2",children:"No Teacher-Uploaded Modules Yet"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Your teachers haven't uploaded any custom modules yet."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6",children:ne.map(c=>e.jsxs("div",{className:"bg-white rounded-2xl border border-[#F08386]/30 p-6 hover:border-[#F08386]/60 hover:shadow-md transition-all cursor-pointer",onClick:()=>te(c),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F08386]/12 border border-[#F08386]/30 text-[#F08386] text-xs font-bold",children:"Teacher Upload"}),c.quarter&&e.jsx("span",{className:"px-2 py-1 rounded-md bg-slate-100 text-slate-600 text-xs",children:c.quarter})]}),e.jsx("h3",{className:"text-lg font-bold text-slate-900 mb-2 line-clamp-2",children:c.title}),e.jsxs("p",{className:"text-sm text-slate-600 mb-3",children:[c.subject," · ",c.gradeLevel]}),c.summary&&e.jsx("p",{className:"text-xs text-slate-500 line-clamp-3",children:c.summary})]},c.moduleId))}):b==="modules"?e.jsx(tl,{modules:st,onSelectModule:ge,onPreviewSources:Y,isAtRisk:ye.length>0&&i,weakTopics:M?.assessmentResults?.weakTopics||[]}):e.jsx(sl,{modules:st,fullPool:ve,onSelectModule:ge,onPreviewSources:Y,isAtRisk:ye.length>0&&i,learningPathContext:Me,learningPathLoading:u,weakTopics:M?.assessmentResults?.weakTopics||[]})},b)})]}),e.jsx($e,{children:O&&e.jsxs(v.aside,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{duration:.25},className:"fixed inset-y-0 right-0 z-[80] w-full max-w-xl border-l border-slate-200 bg-white p-6 shadow-2xl",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-wide text-sky-700",children:"Curriculum Preview"}),e.jsx("h3",{className:"mt-1 text-xl font-black text-slate-900",children:O.title}),e.jsxs("p",{className:"mt-1 text-sm text-slate-600",children:[O.active_grade_level," · ",O.subject," · ",O.quarter]})]}),e.jsx("button",{type:"button",onClick:()=>Y(null),className:"rounded-lg border border-slate-200 p-2 text-slate-500 hover:bg-slate-50",children:e.jsx(De,{size:16})})]}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-slate-50 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Competency Group"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-800",children:O.competency_group})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Performance Standard"}),e.jsx("p",{className:"mt-1 text-sm text-slate-700",children:O.performance_standard})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-slate-500",children:"Competencies"}),e.jsx("div",{className:"mt-2 space-y-2",children:O.competencies.map(c=>e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-slate-50 p-3",children:[e.jsx("p",{className:"text-xs font-black text-slate-600",children:c.code}),e.jsx("p",{className:"mt-1 text-sm text-slate-700",children:c.outcome})]},c.code))})]})]})]})})]})},tl=({modules:t,onSelectModule:a,onPreviewSources:l,isAtRisk:o=!1,weakTopics:n=[]})=>e.jsx("div",{className:"pr-2 space-y-8",children:e.jsx("div",{children:t.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-[#dde3eb] p-8 text-center",children:[e.jsx("p",{className:"text-slate-700 font-semibold",children:"No matching modules found."}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"If modules are not yet available for your selected view, this area will unlock after assessment sync and content rollout."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:t.map((r,i)=>{const x=n.some(p=>r.content_domain&&r.content_domain.toLowerCase().includes(p.toLowerCase())||r.title&&r.title.toLowerCase().includes(p.toLowerCase())||r.competency_group&&r.competency_group.toLowerCase().includes(p.toLowerCase())||r.subject&&r.subject.toLowerCase().includes(p.toLowerCase()));return e.jsx(Ut,{module:r,index:i,onClick:()=>a(r),onPreviewSources:()=>l(r),isAtRisk:o,isRecommended:x},r.id)})})})}),sl=({modules:t,fullPool:a,onSelectModule:l,onPreviewSources:o,isAtRisk:n=!1,learningPathContext:r=null,learningPathLoading:i=!1,weakTopics:x=[]})=>{const p=t.filter(g=>g.progress>0&&g.progress<100),b=(t.length>0?t:a).filter(g=>g.progress===0).slice(0,6);return e.jsxs("div",{className:"pr-2 space-y-10",children:[i&&e.jsxs("div",{className:"mb-6 rounded-2xl border border-sky-200 bg-sky-50 px-5 py-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded-full border-2 border-sky-400 border-t-transparent animate-spin flex-shrink-0"}),e.jsx("p",{className:"text-sm font-semibold text-sky-800",children:"Building your personalized learning path from DepEd curriculum..."})]}),r&&!i&&e.jsxs("div",{className:"mb-6 rounded-2xl border border-indigo-200 bg-gradient-to-br from-indigo-50 to-purple-50 px-5 py-4 shadow-sm",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-wide text-indigo-700 mb-2",children:"📚 Your Personalized Learning Path"}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-indigo-900 font-medium leading-relaxed font-sans",children:r})]}),p.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-[14px] bg-[#FF8B8B]/10 flex items-center justify-center text-[20px] shadow-inner",children:"🔥"}),e.jsx("h2",{className:"font-display font-black text-[24px] text-slate-800 tracking-tight",children:"Continue This Module"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:p.slice(0,4).map((g,M)=>{const z=x.some(d=>g.content_domain&&g.content_domain.toLowerCase().includes(d.toLowerCase())||g.title&&g.title.toLowerCase().includes(d.toLowerCase())||g.competency_group&&g.competency_group.toLowerCase().includes(d.toLowerCase())||g.subject&&g.subject.toLowerCase().includes(d.toLowerCase()));return e.jsx(Ut,{module:g,index:M,onClick:()=>l(g),onPreviewSources:()=>o(g),isAtRisk:n,badgeLabel:"In Progress",isRecommended:z},g.id)})})]}),e.jsx("div",{children:b.length===0?e.jsx("div",{className:"bg-white rounded-2xl border border-[#dde3eb] p-8 text-center text-slate-500 font-medium",children:"You are all caught up. Practice more quizzes to unlock additional recommendations."}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6",children:b.map((g,M)=>{const z=x.some(d=>g.content_domain&&g.content_domain.toLowerCase().includes(d.toLowerCase())||g.title&&g.title.toLowerCase().includes(d.toLowerCase())||g.competency_group&&g.competency_group.toLowerCase().includes(d.toLowerCase())||g.subject&&g.subject.toLowerCase().includes(d.toLowerCase()));return e.jsx(Ut,{module:g,index:M,onClick:()=>l(g),onPreviewSources:()=>o(g),isAtRisk:n,badgeLabel:"Start",isRecommended:z},g.id)})})})]})};export{Bl as default}; diff --git a/assets/NotificationDropdown-IzxN6ZqA.js b/assets/NotificationDropdown-IzxN6ZqA.js new file mode 100644 index 0000000000000000000000000000000000000000..8f336ec3c5999c85e3308dfc08f9b127f75cc5a3 --- /dev/null +++ b/assets/NotificationDropdown-IzxN6ZqA.js @@ -0,0 +1,21 @@ +import{e as t,y as h,k as b,m as f,b as u,U as y}from"./index-B3ruOzo6.js";import{j as e}from"./vendor-react-B4AQeu28.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import{C as N,f as w}from"./formatDistanceToNow-DTsqWUq4.js";import{B as c}from"./bell-Bp_utT8v.js";import{C as k}from"./circle-check-DyFN6-07.js";import{C as j}from"./circle-alert-CTR2Lqp7.js";import{S as g}from"./sparkles-Bq0AaIRg.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 v=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],V=t("activity",v);/** + * @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 _=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],F=t("database",_);/** + * @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 A=[["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:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],B=t("file-text",A);/** + * @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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],L=t("info",C),S=({isOpen:i,onClose:a,onViewAll:o})=>{const{notifications:n,markAsRead:d,markAllAsRead:x,unreadCount:m}=h(),r=n.slice(0,5),p=s=>{switch(s){case"sparkles":case"achievement_unlocked":case"level_up":return e.jsx(g,{className:"w-4 h-4"});case"alert-circle":case"risk_alert":case"system_alert":return e.jsx(j,{className:"w-4 h-4"});case"check-circle-2":case"quiz_result":return e.jsx(k,{className:"w-4 h-4"});case"users":case"new_assignment":return e.jsx(y,{className:"w-4 h-4"});default:return e.jsx(c,{className:"w-4 h-4"})}},l=s=>{switch(s){case"sparkles":case"achievement_unlocked":case"level_up":return"from-[#a855f7] to-[#9333ea] text-white bg-purple-50/30";case"alert-circle":case"risk_alert":case"system_alert":return"from-[#f43f5e] to-[#e11d48] text-white bg-rose-50/30";case"check-circle-2":case"quiz_result":return"bg-emerald-50 text-emerald-500 border border-emerald-100";case"users":case"new_assignment":return"bg-blue-50 text-blue-500 border border-blue-100";default:return"bg-slate-50 text-slate-500 border border-slate-100"}};return e.jsx(b,{children:i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[90]",onClick:a}),e.jsxs(f.div,{initial:{opacity:0,scale:.95,y:-10,x:10},animate:{opacity:1,scale:1,y:0,x:0},exit:{opacity:0,scale:.95,y:-10,x:10},className:"fixed top-[80px] right-[24px] xl:right-[32px] w-[380px] bg-white/95 backdrop-blur-xl rounded-[20px] shadow-[0_8px_32px_rgba(0,0,0,0.12)] border border-white z-[100] flex flex-col overflow-hidden origin-top-right",children:[e.jsxs("div",{className:"p-4 border-b border-[#f1f5f9] flex justify-between items-center bg-white/50",children:[e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b]",children:"Notifications"}),e.jsxs("button",{onClick:()=>x(),disabled:m===0,className:"text-[12px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors flex items-center gap-1.5 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-[#a855f7]",children:[e.jsx(N,{className:"w-3.5 h-3.5"})," Mark all as read"]})]}),e.jsx("div",{className:"max-h-[360px] overflow-y-auto no-scrollbar flex flex-col divide-y divide-[#f1f5f9]",children:r.length>0?r.map(s=>e.jsxs("div",{onClick:()=>{d(s.id)},className:`p-4 hover:bg-slate-50 transition-colors cursor-pointer flex gap-3 ${s.isRead?"opacity-70":l(s.type).split(" ")[2]}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 shadow-sm ${l(s.type).split(" ").slice(0,2).join(" ")}`,children:p(s.type)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between items-start mb-0.5",children:[e.jsx("h4",{className:"text-[13px] font-bold text-[#1e293b]",children:s.title}),!s.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#a855f7] shadow-[0_0_4px_rgba(168,85,247,0.6)] mt-1"})]}),e.jsx("p",{className:"text-[12px] text-[#475569] line-clamp-2 leading-relaxed",children:s.message}),e.jsxs("span",{className:`text-[10px] font-bold mt-1 block ${s.isRead?"text-[#94a3b8]":"text-[#a855f7]"}`,children:[w(s.createdAt)," ago"]})]})]},s.id)):e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(c,{className:"w-8 h-8 text-[#94a3b8] mx-auto mb-2 opacity-20"}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:"No new notifications"})]})}),e.jsx("div",{className:"p-3 border-t border-[#f1f5f9] bg-white",children:e.jsxs("button",{onClick:()=>{o(),a()},className:"w-full py-2 bg-purple-50 text-[#9333ea] hover:bg-purple-100 transition-colors rounded-xl text-[13px] font-bold flex items-center justify-center gap-2",children:["View All Notifications ",e.jsx(u,{className:"w-4 h-4"})]})})]})]})})};export{V as A,F as D,B as F,L as I,S as N}; diff --git a/assets/ProfileModal-BLj_o7UC.js b/assets/ProfileModal-BLj_o7UC.js deleted file mode 100644 index 2eae130d1f644d470cc472526dbb40741b4a5c55..0000000000000000000000000000000000000000 --- a/assets/ProfileModal-BLj_o7UC.js +++ /dev/null @@ -1,11 +0,0 @@ -import{r,j as e}from"./vendor-react-B4AQeu28.js";import{B as c}from"./button-BqKfG4Jj.js";import{I as d}from"./input-DEPoMoHZ.js";import{S as _,a as R,c as U,d as h}from"./select-B04HpeAZ.js";import{c as S,g as D,m as k,U as u,A as x,a as w,D as B,aN as T,aE as q,aP as G}from"./index-mbyiCUYG.js";import{P as V,M as z,V as C}from"./ProfilePictureUploader-Byg9gnjl.js";import{X}from"./x-oZO0Ye1Q.js";import{M as Y}from"./mail-DWQ9UHXG.js";import{C as L}from"./circle-help-BP0kOuya.js";import{S as $}from"./save-DgO_wXsk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./chevron-up-B_-cQcm8.js";import"./check-BLN5Dl8e.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.js";import"./minus-BEbLkPkH.js";import"./plus-CbpDHvDO.js";import"./upload-CKMt4jtd.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 H=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],K=S("building",H);/** - * @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 O=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Q=S("phone",O),ye=({isOpen:i,onClose:o,profileData:p,onSave:E})=>{const[s,t]=r.useState(p),[l,b]=r.useState(!1),[M,g]=r.useState(!1),[m,j]=r.useState([]),[y,v]=r.useState(0);r.useEffect(()=>{if(!i)return;const a=n=>{n.key==="Escape"&&o()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i,o]),r.useEffect(()=>{if(!i||s.role!=="student"||!s.uid)return;const a=s.uid;(async()=>{g(!0);try{const[f,F]=await Promise.all([q(void 0,!1,"all",5),G(a)]);j(f),v(F)}catch(f){console.error("Failed to load leaderboard for profile modal:",f),j([]),v(0)}finally{g(!1)}})()},[i,s.role,s.uid]);const I=()=>{E(s),b(!1)},P=()=>{t(p),b(!1)},A=a=>{switch(a){case"student":return"bg-sky-100 text-sky-700 border-sky-200";case"teacher":return"bg-rose-100 text-rose-700 border-rose-200";case"admin":return"bg-rose-100 text-rose-700 border-rose-200";default:return"bg-zinc-100 text-zinc-700 border-zinc-200"}},N=m.find(a=>a.userId===s.uid);return e.jsx(D,{children:i&&e.jsxs(e.Fragment,{children:[e.jsx(k.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:o,className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50"}),e.jsx(k.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},className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"bg-[#f7f9fc] rounded-2xl shadow-2xl w-full max-w-3xl max-h-[90vh] overflow-hidden border border-[#dde3eb]",children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/30 to-transparent"}),e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-white/10 rounded-full -mr-24 -mt-24"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-36 h-36 bg-white/5 rounded-full -ml-18 -mb-18"}),e.jsxs("div",{className:"relative z-10 flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-white mb-1",children:"Profile Settings"}),e.jsx("p",{className:"text-white/90 text-sm font-body",children:"Manage your account information"})]}),e.jsx("button",{onClick:o,className:"text-white/80 hover:text-white hover:bg-white/10 p-2 rounded-lg transition-all",children:e.jsx(X,{size:20})})]})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[calc(90vh-200px)] p-6 scrollbar-thin scrollbar-thumb-[#d1cec6] scrollbar-track-[#edf1f7]",children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsx(V,{uid:s.uid,photoURL:s.photo,displayName:s.name,onUploaded:a=>t(n=>({...n,photo:a}))}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:s.name}),e.jsx("span",{className:`inline-block mt-2 px-3 py-1 rounded-full text-xs font-body font-semibold border ${A(s.role)}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-sky-600 rounded-full"}),"Basic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.name,onChange:a=>t({...s,name:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Y,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{type:"email",value:s.email,onChange:a=>t({...s,email:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Phone Number"}),e.jsxs("div",{className:"relative",children:[e.jsx(Q,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.phone,onChange:a=>t({...s,phone:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Gender"}),e.jsxs(_,{value:s.gender||"",onValueChange:a=>{t({...s,gender:a||void 0})},disabled:!l,children:[e.jsx(R,{className:"w-full bg-white border-[#dde3eb] rounded-lg [&>span]:flex [&>span]:items-center [&>span]:gap-2",children:e.jsxs("span",{className:"flex items-center gap-2",children:[s.gender==="male"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]}),s.gender==="female"&&e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]}),s.gender==="prefer_not_to_say"&&e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]}),!s.gender&&e.jsx("span",{className:"text-muted-foreground",children:"Select gender (optional)"})]})}),e.jsxs(U,{children:[e.jsx(h,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(h,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(h,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:s.role==="student"?"School":s.role==="teacher"?"Department":"Office Location"}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.school||s.department||s.office||"",onChange:a=>{s.role==="student"?t({...s,school:a.target.value}):s.role==="teacher"?t({...s,department:a.target.value}):t({...s,office:a.target.value})},disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),s.role==="student"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-teal-600 rounded-full"}),"Academic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Learner's Reference Number (LRN)"}),e.jsxs("div",{className:"relative",children:[e.jsx(x,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.lrn||"",onChange:a=>t({...s,lrn:a.target.value}),disabled:!l,className:"pl-10 bg-[#edf1f7] border-[#dde3eb] rounded-xl disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.grade||"",onChange:a=>t({...s,grade:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.section||"",onChange:a=>t({...s,section:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-600 rounded-full"}),"Leaderboard Overview"]}),M?e.jsx("div",{className:"rounded-lg border border-[#dde3eb] bg-white p-4 text-sm font-body text-[#5a6578]",children:"Loading leaderboard data..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-rose-200 bg-rose-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-rose-700 uppercase tracking-wider",children:"Your Rank"}),e.jsx("p",{className:"text-2xl font-display font-bold text-rose-800 mt-1",children:y>0?`#${y}`:"Unranked"})]}),e.jsxs("div",{className:"rounded-lg border border-sky-200 bg-sky-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-sky-700 uppercase tracking-wider",children:"Total XP"}),e.jsx("p",{className:"text-2xl font-display font-bold text-sky-800 mt-1",children:N?.xp??0})]}),e.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-emerald-700 uppercase tracking-wider",children:"Level"}),e.jsx("p",{className:"text-2xl font-display font-bold text-emerald-800 mt-1",children:N?.level??"-"})]})]}),e.jsxs("div",{className:"rounded-lg border border-[#dde3eb] bg-white overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2 border-b border-[#dde3eb] bg-[#f7f9fc]",children:e.jsx("p",{className:"text-xs font-body font-semibold text-[#5a6578] uppercase tracking-wider",children:"Top Students"})}),e.jsx("div",{className:"divide-y divide-[#edf1f7]",children:m.length>0?m.map(a=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-[#edf1f7] text-[#0a1628] text-xs font-display font-bold flex items-center justify-center",children:a.rank}),e.jsxs("p",{className:"text-sm font-body font-semibold text-[#0a1628] truncate",children:[a.name,a.userId===s.uid?" (You)":""]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-body font-semibold text-[#0a1628]",children:[a.xp," XP"]}),e.jsxs("p",{className:"text-xs font-body text-[#5a6578]",children:["Lv ",a.level]})]})]},a.userId)):e.jsx("div",{className:"px-4 py-6 text-center text-sm font-body text-[#5a6578]",children:"No leaderboard data available yet."})})]})]})]})]}),s.role==="teacher"&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-500 rounded-full"}),"Teaching Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Teacher ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(x,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.teacherId||"",onChange:a=>t({...s,teacherId:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Subject/Specialization"}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.subject||"",onChange:a=>t({...s,subject:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Years of Experience"}),e.jsxs("div",{className:"relative",children:[e.jsx(B,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.yearsOfExperience||"",onChange:a=>t({...s,yearsOfExperience:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Qualification"}),e.jsxs("div",{className:"relative",children:[e.jsx(x,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.qualification||"",onChange:a=>t({...s,qualification:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),s.role==="admin"&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-600 rounded-full"}),"Administrative Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Admin ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(x,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.adminId||"",onChange:a=>t({...s,adminId:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Position/Title"}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.position||"",onChange:a=>t({...s,position:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Access Level/Permissions"}),e.jsxs("div",{className:"relative",children:[e.jsx(T,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.permissions||"",onChange:a=>t({...s,permissions:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]})]})]}),e.jsx("div",{className:"border-t border-[#dde3eb] p-5 bg-[#edf1f7]",children:e.jsx("div",{className:"flex gap-3 justify-end",children:l?e.jsxs(e.Fragment,{children:[e.jsx(c,{onClick:P,variant:"outline",className:"px-5 py-2 rounded-lg border-[#d1cec6] hover:bg-white font-body font-medium text-[#5a6578]",children:"Cancel"}),e.jsxs(c,{onClick:I,className:"px-5 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white font-body font-semibold flex items-center gap-2",children:[e.jsx($,{size:16}),"Save Changes"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(c,{onClick:o,variant:"outline",className:"px-5 py-2 rounded-lg border-[#d1cec6] hover:bg-white font-body font-medium text-[#5a6578]",children:"Close"}),e.jsx(c,{onClick:()=>b(!0),className:"px-5 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white font-body font-semibold",children:"Edit Profile"})]})})})]})})]})})};export{ye as default}; diff --git a/assets/ProfileModal-xyqhi5Hx.js b/assets/ProfileModal-xyqhi5Hx.js new file mode 100644 index 0000000000000000000000000000000000000000..b3f2a6fc16606c9d7fe00982ea8cd76a23e1cb16 --- /dev/null +++ b/assets/ProfileModal-xyqhi5Hx.js @@ -0,0 +1,11 @@ +import{r,j as e}from"./vendor-react-B4AQeu28.js";import{e as S,k as _,m as k,U as h,A as c,a as w,D,W as R,aG as U,aP as B,l as T}from"./index-B3ruOzo6.js";import{B as x}from"./button-CaSK4KoS.js";import{I as d}from"./input-kh84w1XK.js";import{S as G,a as $,c as q,d as p}from"./select-C142YWNr.js";import{P as V,M as z,V as C,v as X}from"./ProfilePictureUploader-B3ToJmez.js";import{X as Y}from"./x-BNHnAXzL.js";import{M as H}from"./mail-BXNRz1ib.js";import{C as L}from"./circle-help-C5HGdkRZ.js";import{S as K}from"./save-DXz2z5YH.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-CTb5_AvY.js";import"./check-6eXlU5jr.js";import"./minus-B69_eMXI.js";import"./plus-Dx0gdu7_.js";import"./upload-BBhypj4u.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 O=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Q=S("building",O);/** + * @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 W=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],J=S("phone",W),Ne=({isOpen:i,onClose:o,profileData:u,onSave:E})=>{const[s,t]=r.useState(u),[l,b]=r.useState(!1),[M,g]=r.useState(!1),[m,j]=r.useState([]),[y,v]=r.useState(0);r.useEffect(()=>{if(!i)return;const a=n=>{n.key==="Escape"&&o()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i,o]),r.useEffect(()=>{if(!i||s.role!=="student"||!s.uid)return;const a=s.uid;(async()=>{g(!0);try{const[f,F]=await Promise.all([U(void 0,!1,"all",5),B(a)]);j(f),v(F)}catch(f){console.error("Failed to load leaderboard for profile modal:",f),j([]),v(0)}finally{g(!1)}})()},[i,s.role,s.uid]);const P=()=>{const a=X({name:s.name,phone:s.phone});if(a){T.error(a);return}E(s),b(!1)},I=()=>{t(u),b(!1)},A=a=>{switch(a){case"student":return"bg-sky-100 text-sky-700 border-sky-200";case"teacher":return"bg-rose-100 text-rose-700 border-rose-200";case"admin":return"bg-rose-100 text-rose-700 border-rose-200";default:return"bg-zinc-100 text-zinc-700 border-zinc-200"}},N=m.find(a=>a.userId===s.uid);return e.jsx(_,{children:i&&e.jsxs(e.Fragment,{children:[e.jsx(k.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:o,className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50"}),e.jsx(k.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},className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"bg-[#f7f9fc] rounded-2xl shadow-2xl w-full max-w-3xl max-h-[90vh] overflow-hidden border border-[#dde3eb]",children:[e.jsxs("div",{className:"bg-gradient-to-r from-sky-600 to-sky-500 p-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/30 to-transparent"}),e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 bg-white/10 rounded-full -mr-24 -mt-24"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-36 h-36 bg-white/5 rounded-full -ml-18 -mb-18"}),e.jsxs("div",{className:"relative z-10 flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-white mb-1",children:"Profile Settings"}),e.jsx("p",{className:"text-white/90 text-sm font-body",children:"Manage your account information"})]}),e.jsx("button",{onClick:o,className:"text-white/80 hover:text-white hover:bg-white/10 p-2 rounded-lg transition-all",children:e.jsx(Y,{size:20})})]})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[calc(90vh-200px)] p-6 scrollbar-thin scrollbar-thumb-[#d1cec6] scrollbar-track-[#edf1f7]",children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsx(V,{uid:s.uid,photoURL:s.photo,displayName:s.name,onUploaded:a=>t(n=>({...n,photo:a}))}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:s.name}),e.jsx("span",{className:`inline-block mt-2 px-3 py-1 rounded-full text-xs font-body font-semibold border ${A(s.role)}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-sky-600 rounded-full"}),"Basic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Full Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.name,onChange:a=>t({...s,name:a.target.value}),disabled:!l,maxLength:100,autoComplete:"name",className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(H,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{type:"email",value:s.email,onChange:a=>t({...s,email:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Phone Number"}),e.jsxs("div",{className:"relative",children:[e.jsx(J,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.phone,onChange:a=>t({...s,phone:a.target.value}),disabled:!l,type:"tel",inputMode:"tel",maxLength:20,autoComplete:"tel",pattern:"^\\+?[0-9 ()\\-.]{7,20}$",placeholder:"+63 912 345 6789",className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Gender"}),e.jsxs(G,{value:s.gender||"",onValueChange:a=>{t({...s,gender:a||void 0})},disabled:!l,children:[e.jsx($,{className:"w-full bg-white border-[#dde3eb] rounded-lg [&>span]:flex [&>span]:items-center [&>span]:gap-2",children:e.jsxs("span",{className:"flex items-center gap-2",children:[s.gender==="male"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]}),s.gender==="female"&&e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]}),s.gender==="prefer_not_to_say"&&e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]}),!s.gender&&e.jsx("span",{className:"text-muted-foreground",children:"Select gender (optional)"})]})}),e.jsxs(q,{children:[e.jsx(p,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(p,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(p,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:s.role==="student"?"School":s.role==="teacher"?"Department":"Office Location"}),e.jsxs("div",{className:"relative",children:[e.jsx(Q,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.school||s.department||s.office||"",onChange:a=>{s.role==="student"?t({...s,school:a.target.value}):s.role==="teacher"?t({...s,department:a.target.value}):t({...s,office:a.target.value})},disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),s.role==="student"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-teal-600 rounded-full"}),"Academic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Learner's Reference Number (LRN)"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.lrn||"",onChange:a=>t({...s,lrn:a.target.value}),disabled:!l,className:"pl-10 bg-[#edf1f7] border-[#dde3eb] rounded-xl disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Grade Level"}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.grade||"",onChange:a=>t({...s,grade:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Section"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.section||"",onChange:a=>t({...s,section:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-600 rounded-full"}),"Leaderboard Overview"]}),M?e.jsx("div",{className:"rounded-lg border border-[#dde3eb] bg-white p-4 text-sm font-body text-[#5a6578]",children:"Loading leaderboard data..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-rose-200 bg-rose-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-rose-700 uppercase tracking-wider",children:"Your Rank"}),e.jsx("p",{className:"text-2xl font-display font-bold text-rose-800 mt-1",children:y>0?`#${y}`:"Unranked"})]}),e.jsxs("div",{className:"rounded-lg border border-sky-200 bg-sky-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-sky-700 uppercase tracking-wider",children:"Total XP"}),e.jsx("p",{className:"text-2xl font-display font-bold text-sky-800 mt-1",children:N?.xp??0})]}),e.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 p-3",children:[e.jsx("p",{className:"text-xs font-body font-semibold text-emerald-700 uppercase tracking-wider",children:"Level"}),e.jsx("p",{className:"text-2xl font-display font-bold text-emerald-800 mt-1",children:N?.level??"-"})]})]}),e.jsxs("div",{className:"rounded-lg border border-[#dde3eb] bg-white overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2 border-b border-[#dde3eb] bg-[#f7f9fc]",children:e.jsx("p",{className:"text-xs font-body font-semibold text-[#5a6578] uppercase tracking-wider",children:"Top Students"})}),e.jsx("div",{className:"divide-y divide-[#edf1f7]",children:m.length>0?m.map(a=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-[#edf1f7] text-[#0a1628] text-xs font-display font-bold flex items-center justify-center",children:a.rank}),e.jsxs("p",{className:"text-sm font-body font-semibold text-[#0a1628] truncate",children:[a.name,a.userId===s.uid?" (You)":""]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-body font-semibold text-[#0a1628]",children:[a.xp," XP"]}),e.jsxs("p",{className:"text-xs font-body text-[#5a6578]",children:["Lv ",a.level]})]})]},a.userId)):e.jsx("div",{className:"px-4 py-6 text-center text-sm font-body text-[#5a6578]",children:"No leaderboard data available yet."})})]})]})]})]}),s.role==="teacher"&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-500 rounded-full"}),"Teaching Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Teacher ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.teacherId||"",onChange:a=>t({...s,teacherId:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Subject/Specialization"}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.subject||"",onChange:a=>t({...s,subject:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Years of Experience"}),e.jsxs("div",{className:"relative",children:[e.jsx(D,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.yearsOfExperience||"",onChange:a=>t({...s,yearsOfExperience:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Qualification"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.qualification||"",onChange:a=>t({...s,qualification:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]}),s.role==="admin"&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-display font-bold text-[#0a1628] mb-4 flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-4 bg-rose-600 rounded-full"}),"Administrative Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Admin ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.adminId||"",onChange:a=>t({...s,adminId:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Position/Title"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.position||"",onChange:a=>t({...s,position:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-body font-semibold text-[#5a6578] mb-2 uppercase tracking-wider",children:"Access Level/Permissions"}),e.jsxs("div",{className:"relative",children:[e.jsx(R,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx(d,{value:s.permissions||"",onChange:a=>t({...s,permissions:a.target.value}),disabled:!l,className:"pl-10 bg-white border-[#dde3eb] rounded-lg font-body text-[#0a1628] focus:border-sky-400 focus:ring-sky-400/20 disabled:opacity-100 disabled:cursor-default"})]})]})]})]})]})]}),e.jsx("div",{className:"border-t border-[#dde3eb] p-5 bg-[#edf1f7]",children:e.jsx("div",{className:"flex gap-3 justify-end",children:l?e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:I,variant:"outline",className:"px-5 py-2 rounded-lg border-[#d1cec6] hover:bg-white font-body font-medium text-[#5a6578]",children:"Cancel"}),e.jsxs(x,{onClick:P,className:"px-5 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white font-body font-semibold flex items-center gap-2",children:[e.jsx(K,{size:16}),"Save Changes"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:o,variant:"outline",className:"px-5 py-2 rounded-lg border-[#d1cec6] hover:bg-white font-body font-medium text-[#5a6578]",children:"Close"}),e.jsx(x,{onClick:()=>b(!0),className:"px-5 py-2 rounded-lg bg-sky-600 hover:bg-sky-700 text-white font-body font-semibold",children:"Edit Profile"})]})})})]})})]})})};export{Ne as default}; diff --git a/assets/ProfilePictureUploader-B3ToJmez.js b/assets/ProfilePictureUploader-B3ToJmez.js new file mode 100644 index 0000000000000000000000000000000000000000..1b784e0d2d34860fdaebf39989460b91759d5fe6 --- /dev/null +++ b/assets/ProfilePictureUploader-B3ToJmez.js @@ -0,0 +1,147 @@ +import{e as Re,j as be,I as Ue,a_ as Gt,a$ as Kt,u as Xt,O as Yt,P as Qt,Q as er,k as tr,m as Me,l as Fe}from"./index-B3ruOzo6.js";import{g as rr,r as x,j as g}from"./vendor-react-B4AQeu28.js";import{_ as nr,o as R,p as or,q as ir,r as sr,s as ar}from"./vendor-radix-BPuEd8FG.js";import{B as Le}from"./button-CaSK4KoS.js";import{updateProfile as cr}from"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-core-DCQrgkxC.js";import{r as ur,u as lr,a as dr}from"./vendor-firebase-storage-dc5X5yTv.js";import{X as pr}from"./x-BNHnAXzL.js";import{M as fr}from"./minus-B69_eMXI.js";import{P as hr}from"./plus-Dx0gdu7_.js";import{U as mr}from"./upload-BBhypj4u.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 gr=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],vr=Re("camera",gr);/** + * @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 _r=[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m21 3-6.75 6.75",key:"pv0uzu"}],["circle",{cx:"10",cy:"14",r:"6",key:"1qwbdc"}]],Da=Re("mars",_r);/** + * @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 wr=[["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M9 19h6",key:"456am0"}],["circle",{cx:"12",cy:"9",r:"6",key:"1nw4tq"}]],ja=Re("venus",wr);function d(e,r,t){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),r(a,c);const u=i.prototype,l=Object.keys(u);for(let f=0;ft?.Parent&&a instanceof t.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class H extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class _t extends Error{constructor(r){super(`Encountered unidirectional transform during encode: ${r}`),this.name="ZodEncodeError"}}const wt={};function J(e){return wt}function yt(e){const r=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>r.indexOf(+n)===-1).map(([n,o])=>o)}function Ce(e,r){return typeof r=="bigint"?r.toString():r}function Oe(e){return{get value(){{const r=e();return Object.defineProperty(this,"value",{value:r}),r}}}}function Te(e){return e==null}function De(e){const r=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(r,t)}const We=Symbol("evaluating");function z(e,r,t){let n;Object.defineProperty(e,r,{get(){if(n!==We)return n===void 0&&(n=We,n=t()),n},set(o){Object.defineProperty(e,r,{value:o})},configurable:!0})}function V(e,r,t){Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}function M(...e){const r={};for(const t of e){const n=Object.getOwnPropertyDescriptors(t);Object.assign(r,n)}return Object.defineProperties({},r)}function Je(e){return JSON.stringify(e)}function yr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const zt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zr=Oe(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function re(e){if(de(e)===!1)return!1;const r=e.constructor;if(r===void 0||typeof r!="function")return!0;const t=r.prototype;return!(de(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function bt(e){return re(e)?{...e}:Array.isArray(e)?[...e]:e}const br=new Set(["string","number","symbol"]);function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(e,r,t){const n=new e._zod.constr(r??e._zod.def);return(!r||t?.parent)&&(n._zod.parent=e),n}function m(e){const r=e;if(!r)return{};if(typeof r=="string")return{error:()=>r};if(r?.message!==void 0){if(r?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");r.error=r.message}return delete r.message,typeof r.error=="string"?{...r,error:()=>r.error}:r}function Sr(e){return Object.keys(e).filter(r=>e[r]._zod.optin==="optional"&&e[r]._zod.optout==="optional")}function kr(e,r){const t=e._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=M(e._zod.def,{get shape(){const i={};for(const a in r){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=t.shape[a])}return V(this,"shape",i),i},checks:[]});return F(e,s)}function Pr(e,r){const t=e._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=M(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in r){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);r[a]&&delete i[a]}return V(this,"shape",i),i},checks:[]});return F(e,s)}function Er(e,r){if(!re(r))throw new Error("Invalid input to extend: expected a plain object");const t=e._zod.def.checks;if(t&&t.length>0){const s=e._zod.def.shape;for(const i in r)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=M(e._zod.def,{get shape(){const s={...e._zod.def.shape,...r};return V(this,"shape",s),s}});return F(e,o)}function xr(e,r){if(!re(r))throw new Error("Invalid input to safeExtend: expected a plain object");const t=M(e._zod.def,{get shape(){const n={...e._zod.def.shape,...r};return V(this,"shape",n),n}});return F(e,t)}function Cr(e,r){const t=M(e._zod.def,{get shape(){const n={...e._zod.def.shape,...r._zod.def.shape};return V(this,"shape",n),n},get catchall(){return r._zod.def.catchall},checks:[]});return F(e,t)}function $r(e,r,t){const o=r._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=M(r._zod.def,{get shape(){const a=r._zod.def.shape,c={...a};if(t)for(const u in t){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return V(this,"shape",c),c},checks:[]});return F(r,i)}function Zr(e,r,t){const n=M(r._zod.def,{get shape(){const o=r._zod.def.shape,s={...o};if(t)for(const i in t){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return V(this,"shape",s),s}});return F(r,n)}function q(e,r=0){if(e.aborted===!0)return!0;for(let t=r;t{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ae(e){return typeof e=="string"?e:e?.message}function B(e,r,t){const n={...e,path:e.path??[]};if(!e.message){const o=ae(e.inst?._zod.def?.error?.(e))??ae(r?.error?.(e))??ae(t.customError?.(e))??ae(t.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,r?.reportInput||delete n.input,n}function je(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ne(...e){const[r,t,n]=e;return typeof r=="string"?{message:r,code:"custom",input:t,inst:n}:{...r}}const kt=(e,r)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:r,enumerable:!1}),e.message=JSON.stringify(r,Ce,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pt=d("$ZodError",kt),Et=d("$ZodError",kt,{Parent:Error});function Rr(e,r=t=>t.message){const t={},n=[];for(const o of e.issues)o.path.length>0?(t[o.path[0]]=t[o.path[0]]||[],t[o.path[0]].push(r(o))):n.push(r(o));return{formErrors:n,fieldErrors:t}}function Or(e,r=t=>t.message){const t={_errors:[]},n=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>n({issues:i}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)t._errors.push(r(s));else{let i=t,a=0;for(;a(r,t,n,o)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},i=r._zod.run({value:t,issues:[]},s);if(i instanceof Promise)throw new H;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>B(c,s,J())));throw zt(a,o?.callee),a}return i.value},Ie=e=>async(r,t,n,o)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=r._zod.run({value:t,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>B(c,s,J())));throw zt(a,o?.callee),a}return i.value},ge=e=>(r,t,n)=>{const o=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:t,issues:[]},o);if(s instanceof Promise)throw new H;return s.issues.length?{success:!1,error:new(e??Pt)(s.issues.map(i=>B(i,o,J())))}:{success:!0,data:s.value}},Tr=ge(Et),ve=e=>async(r,t,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let s=r._zod.run({value:t,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>B(i,o,J())))}:{success:!0,data:s.value}},Dr=ve(Et),jr=e=>(r,t,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ae(e)(r,t,o)},Ar=e=>(r,t,n)=>Ae(e)(r,t,n),Ir=e=>async(r,t,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ie(e)(r,t,o)},Nr=e=>async(r,t,n)=>Ie(e)(r,t,n),Ur=e=>(r,t,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ge(e)(r,t,o)},Mr=e=>(r,t,n)=>ge(e)(r,t,n),Fr=e=>async(r,t,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ve(e)(r,t,o)},Lr=e=>async(r,t,n)=>ve(e)(r,t,n),Wr=/^[cC][^\s-]{8,}$/,Jr=/^[0-9a-z]+$/,Br=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vr=/^[0-9a-vA-V]{20}$/,qr=/^[A-Za-z0-9]{27}$/,Hr=/^[a-zA-Z0-9_-]{21}$/,Gr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Kr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Be=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Xr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Yr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Qr(){return new RegExp(Yr,"u")}const en=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,rn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,nn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,on=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xt=/^[A-Za-z0-9_-]*$/,sn=/^\+[1-9]\d{6,14}$/,Ct="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",an=new RegExp(`^${Ct}$`);function $t(e){const r="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${r}`:e.precision===0?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${e.precision}}`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}function cn(e){return new RegExp(`^${$t(e)}$`)}function un(e){const r=$t({precision:e.precision}),t=["Z"];e.local&&t.push(""),e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${r}(?:${t.join("|")})`;return new RegExp(`^${Ct}T(?:${n})$`)}const ln=e=>{const r=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${r}$`)},dn=/^[^A-Z]*$/,pn=/^[^a-z]*$/,N=d("$ZodCheck",(e,r)=>{var t;e._zod??(e._zod={}),e._zod.def=r,(t=e._zod).onattach??(t.onattach=[])}),fn=d("$ZodCheckMaxLength",(e,r)=>{var t;N.init(e,r),(t=e._zod.def).when??(t.when=n=>{const o=n.value;return!Te(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;r.maximum{const o=n.value;if(o.length<=r.maximum)return;const i=je(o);n.issues.push({origin:i,code:"too_big",maximum:r.maximum,inclusive:!0,input:o,inst:e,continue:!r.abort})}}),hn=d("$ZodCheckMinLength",(e,r)=>{var t;N.init(e,r),(t=e._zod.def).when??(t.when=n=>{const o=n.value;return!Te(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;r.minimum>o&&(n._zod.bag.minimum=r.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=r.minimum)return;const i=je(o);n.issues.push({origin:i,code:"too_small",minimum:r.minimum,inclusive:!0,input:o,inst:e,continue:!r.abort})}}),mn=d("$ZodCheckLengthEquals",(e,r)=>{var t;N.init(e,r),(t=e._zod.def).when??(t.when=n=>{const o=n.value;return!Te(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=r.length,o.maximum=r.length,o.length=r.length}),e._zod.check=n=>{const o=n.value,s=o.length;if(s===r.length)return;const i=je(o),a=s>r.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!r.abort})}}),_e=d("$ZodCheckStringFormat",(e,r)=>{var t,n;N.init(e,r),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=r.format,r.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(r.pattern))}),r.pattern?(t=e._zod).check??(t.check=o=>{r.pattern.lastIndex=0,!r.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:r.format,input:o.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:e,continue:!r.abort})}):(n=e._zod).check??(n.check=()=>{})}),gn=d("$ZodCheckRegex",(e,r)=>{_e.init(e,r),e._zod.check=t=>{r.pattern.lastIndex=0,!r.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:r.pattern.toString(),inst:e,continue:!r.abort})}}),vn=d("$ZodCheckLowerCase",(e,r)=>{r.pattern??(r.pattern=dn),_e.init(e,r)}),_n=d("$ZodCheckUpperCase",(e,r)=>{r.pattern??(r.pattern=pn),_e.init(e,r)}),wn=d("$ZodCheckIncludes",(e,r)=>{N.init(e,r);const t=me(r.includes),n=new RegExp(typeof r.position=="number"?`^.{${r.position}}${t}`:t);r.pattern=n,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(r.includes,r.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:o.value,inst:e,continue:!r.abort})}}),yn=d("$ZodCheckStartsWith",(e,r)=>{N.init(e,r);const t=new RegExp(`^${me(r.prefix)}.*`);r.pattern??(r.pattern=t),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(t)}),e._zod.check=n=>{n.value.startsWith(r.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:n.value,inst:e,continue:!r.abort})}}),zn=d("$ZodCheckEndsWith",(e,r)=>{N.init(e,r);const t=new RegExp(`.*${me(r.suffix)}$`);r.pattern??(r.pattern=t),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(t)}),e._zod.check=n=>{n.value.endsWith(r.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:n.value,inst:e,continue:!r.abort})}}),bn=d("$ZodCheckOverwrite",(e,r)=>{N.init(e,r),e._zod.check=t=>{t.value=r.tx(t.value)}});class Sn{constructor(r=[]){this.content=[],this.indent=0,this&&(this.args=r)}indented(r){this.indent+=1,r(this),this.indent-=1}write(r){if(typeof r=="function"){r(this,{execution:"sync"}),r(this,{execution:"async"});return}const n=r.split(` +`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const r=Function,t=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new r(...t,o.join(` +`))}}const kn={major:4,minor:3,patch:6},C=d("$ZodType",(e,r)=>{var t;e??(e={}),e._zod.def=r,e._zod.bag=e._zod.bag||{},e._zod.version=kn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const s of o._zod.onattach)s(e);if(n.length===0)(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,a,c)=>{let u=q(i),l;for(const f of a){if(f._zod.def.when){if(!f._zod.def.when(i))continue}else if(u)continue;const p=i.issues.length,h=f._zod.check(i);if(h instanceof Promise&&c?.async===!1)throw new H;if(l||h instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await h,i.issues.length!==p&&(u||(u=q(i,p)))});else{if(i.issues.length===p)continue;u||(u=q(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(q(i))return i.aborted=!0,i;const u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new H;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new H;return c.then(u=>o(u,n,a))}return o(c,n,a)}}z(e,"~standard",()=>({validate:o=>{try{const s=Tr(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Dr(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Ne=d("$ZodString",(e,r)=>{C.init(e,r),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ln(e._zod.bag),e._zod.parse=(t,n)=>{if(r.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}}),S=d("$ZodStringFormat",(e,r)=>{_e.init(e,r),Ne.init(e,r)}),Pn=d("$ZodGUID",(e,r)=>{r.pattern??(r.pattern=Kr),S.init(e,r)}),En=d("$ZodUUID",(e,r)=>{if(r.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(n===void 0)throw new Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=Be(n))}else r.pattern??(r.pattern=Be());S.init(e,r)}),xn=d("$ZodEmail",(e,r)=>{r.pattern??(r.pattern=Xr),S.init(e,r)}),Cn=d("$ZodURL",(e,r)=>{S.init(e,r),e._zod.check=t=>{try{const n=t.value.trim(),o=new URL(n);r.hostname&&(r.hostname.lastIndex=0,r.hostname.test(o.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:t.value,inst:e,continue:!r.abort})),r.protocol&&(r.protocol.lastIndex=0,r.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:t.value,inst:e,continue:!r.abort})),r.normalize?t.value=o.href:t.value=n;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!r.abort})}}}),$n=d("$ZodEmoji",(e,r)=>{r.pattern??(r.pattern=Qr()),S.init(e,r)}),Zn=d("$ZodNanoID",(e,r)=>{r.pattern??(r.pattern=Hr),S.init(e,r)}),Rn=d("$ZodCUID",(e,r)=>{r.pattern??(r.pattern=Wr),S.init(e,r)}),On=d("$ZodCUID2",(e,r)=>{r.pattern??(r.pattern=Jr),S.init(e,r)}),Tn=d("$ZodULID",(e,r)=>{r.pattern??(r.pattern=Br),S.init(e,r)}),Dn=d("$ZodXID",(e,r)=>{r.pattern??(r.pattern=Vr),S.init(e,r)}),jn=d("$ZodKSUID",(e,r)=>{r.pattern??(r.pattern=qr),S.init(e,r)}),An=d("$ZodISODateTime",(e,r)=>{r.pattern??(r.pattern=un(r)),S.init(e,r)}),In=d("$ZodISODate",(e,r)=>{r.pattern??(r.pattern=an),S.init(e,r)}),Nn=d("$ZodISOTime",(e,r)=>{r.pattern??(r.pattern=cn(r)),S.init(e,r)}),Un=d("$ZodISODuration",(e,r)=>{r.pattern??(r.pattern=Gr),S.init(e,r)}),Mn=d("$ZodIPv4",(e,r)=>{r.pattern??(r.pattern=en),S.init(e,r),e._zod.bag.format="ipv4"}),Fn=d("$ZodIPv6",(e,r)=>{r.pattern??(r.pattern=tn),S.init(e,r),e._zod.bag.format="ipv6",e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!r.abort})}}}),Ln=d("$ZodCIDRv4",(e,r)=>{r.pattern??(r.pattern=rn),S.init(e,r)}),Wn=d("$ZodCIDRv6",(e,r)=>{r.pattern??(r.pattern=nn),S.init(e,r),e._zod.check=t=>{const n=t.value.split("/");try{if(n.length!==2)throw new Error;const[o,s]=n;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!r.abort})}}});function Zt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Jn=d("$ZodBase64",(e,r)=>{r.pattern??(r.pattern=on),S.init(e,r),e._zod.bag.contentEncoding="base64",e._zod.check=t=>{Zt(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!r.abort})}});function Bn(e){if(!xt.test(e))return!1;const r=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),t=r.padEnd(Math.ceil(r.length/4)*4,"=");return Zt(t)}const Vn=d("$ZodBase64URL",(e,r)=>{r.pattern??(r.pattern=xt),S.init(e,r),e._zod.bag.contentEncoding="base64url",e._zod.check=t=>{Bn(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!r.abort})}}),qn=d("$ZodE164",(e,r)=>{r.pattern??(r.pattern=sn),S.init(e,r)});function Hn(e,r=null){try{const t=e.split(".");if(t.length!==3)return!1;const[n]=t;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||r&&(!("alg"in o)||o.alg!==r))}catch{return!1}}const Gn=d("$ZodJWT",(e,r)=>{S.init(e,r),e._zod.check=t=>{Hn(t.value,r.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!r.abort})}}),Kn=d("$ZodUnknown",(e,r)=>{C.init(e,r),e._zod.parse=t=>t}),Xn=d("$ZodNever",(e,r)=>{C.init(e,r),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Ve(e,r,t){e.issues.length&&r.issues.push(...St(t,e.issues)),r.value[t]=e.value}const Yn=d("$ZodArray",(e,r)=>{C.init(e,r),e._zod.parse=(t,n)=>{const o=t.value;if(!Array.isArray(o))return t.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),t;t.value=Array(o.length);const s=[];for(let i=0;iVe(u,t,i))):Ve(c,t,i)}return s.length?Promise.all(s).then(()=>t):t}});function pe(e,r,t,n,o){if(e.issues.length){if(o&&!(t in n))return;r.issues.push(...St(t,e.issues))}e.value===void 0?t in n&&(r.value[t]=void 0):r.value[t]=e.value}function Rt(e){const r=Object.keys(e.shape);for(const n of r)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const t=Sr(e.shape);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(t)}}function Ot(e,r,t,n,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout==="optional";for(const f in r){if(a.has(f))continue;if(u==="never"){i.push(f);continue}const p=c.run({value:r[f],issues:[]},n);p instanceof Promise?e.push(p.then(h=>pe(h,t,f,r,l))):pe(p,t,f,r,l)}return i.length&&t.issues.push({code:"unrecognized_keys",keys:i,input:r,inst:s}),e.length?Promise.all(e).then(()=>t):t}const Qn=d("$ZodObject",(e,r)=>{if(C.init(e,r),!Object.getOwnPropertyDescriptor(r,"shape")?.get){const a=r.shape;Object.defineProperty(r,"shape",{get:()=>{const c={...a};return Object.defineProperty(r,"shape",{value:c}),c}})}const n=Oe(()=>Rt(r));z(e._zod,"propValues",()=>{const a=r.shape,c={};for(const u in a){const l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(const f of l.values)c[u].add(f)}}return c});const o=de,s=r.catchall;let i;e._zod.parse=(a,c)=>{i??(i=n.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const l=[],f=i.shape;for(const p of i.keys){const h=f[p],w=h._zod.optout==="optional",v=h._zod.run({value:u[p],issues:[]},c);v instanceof Promise?l.push(v.then(y=>pe(y,a,p,u,w))):pe(v,a,p,u,w)}return s?Ot(l,u,a,c,n.value,e):l.length?Promise.all(l).then(()=>a):a}}),eo=d("$ZodObjectJIT",(e,r)=>{Qn.init(e,r);const t=e._zod.parse,n=Oe(()=>Rt(r)),o=p=>{const h=new Sn(["shape","payload","ctx"]),w=n.value,v=_=>{const b=Je(_);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};h.write("const input = payload.value;");const y=Object.create(null);let D=0;for(const _ of w.keys)y[_]=`key_${D++}`;h.write("const newResult = {};");for(const _ of w.keys){const b=y[_],E=Je(_),X=p[_]?._zod?.optout==="optional";h.write(`const ${b} = ${v(_)};`),X?h.write(` + if (${b}.issues.length) { + if (${E} in input) { + payload.issues = payload.issues.concat(${b}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${E}, ...iss.path] : [${E}] + }))); + } + } + + if (${b}.value === undefined) { + if (${E} in input) { + newResult[${E}] = undefined; + } + } else { + newResult[${E}] = ${b}.value; + } + + `):h.write(` + if (${b}.issues.length) { + payload.issues = payload.issues.concat(${b}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${E}, ...iss.path] : [${E}] + }))); + } + + if (${b}.value === undefined) { + if (${E} in input) { + newResult[${E}] = undefined; + } + } else { + newResult[${E}] = ${b}.value; + } + + `)}h.write("payload.value = newResult;"),h.write("return payload;");const P=h.compile();return(_,b)=>P(p,_,b)};let s;const i=de,a=!wt.jitless,u=a&&zr.value,l=r.catchall;let f;e._zod.parse=(p,h)=>{f??(f=n.value);const w=p.value;return i(w)?a&&u&&h?.async===!1&&h.jitless!==!0?(s||(s=o(r.shape)),p=s(p,h),l?Ot([],w,p,h,f,e):p):t(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),p)}});function qe(e,r,t,n){for(const s of e)if(s.issues.length===0)return r.value=s.value,r;const o=e.filter(s=>!q(s));return o.length===1?(r.value=o[0].value,o[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:t,errors:e.map(s=>s.issues.map(i=>B(i,n,J())))}),r)}const to=d("$ZodUnion",(e,r)=>{C.init(e,r),z(e._zod,"optin",()=>r.options.some(o=>o._zod.optin==="optional")?"optional":void 0),z(e._zod,"optout",()=>r.options.some(o=>o._zod.optout==="optional")?"optional":void 0),z(e._zod,"values",()=>{if(r.options.every(o=>o._zod.values))return new Set(r.options.flatMap(o=>Array.from(o._zod.values)))}),z(e._zod,"pattern",()=>{if(r.options.every(o=>o._zod.pattern)){const o=r.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>De(s.source)).join("|")})$`)}});const t=r.options.length===1,n=r.options[0]._zod.run;e._zod.parse=(o,s)=>{if(t)return n(o,s);let i=!1;const a=[];for(const c of r.options){const u=c._zod.run({value:o.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>qe(c,o,e,s)):qe(a,o,e,s)}}),ro=d("$ZodIntersection",(e,r)=>{C.init(e,r),e._zod.parse=(t,n)=>{const o=t.value,s=r.left._zod.run({value:o,issues:[]},n),i=r.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>He(t,c,u)):He(t,s,i)}});function $e(e,r){if(e===r)return{valid:!0,data:e};if(e instanceof Date&&r instanceof Date&&+e==+r)return{valid:!0,data:e};if(re(e)&&re(r)){const t=Object.keys(r),n=Object.keys(e).filter(s=>t.indexOf(s)!==-1),o={...e,...r};for(const s of n){const i=$e(e[s],r[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let n=0;na.l&&a.r).map(([a])=>a);if(s.length&&o&&e.issues.push({...o,keys:s}),q(e))return e;const i=$e(r.value,t.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const no=d("$ZodEnum",(e,r)=>{C.init(e,r);const t=yt(r.entries),n=new Set(t);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.filter(o=>br.has(typeof o)).map(o=>typeof o=="string"?me(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t,input:i,inst:e}),o}}),oo=d("$ZodTransform",(e,r)=>{C.init(e,r),e._zod.parse=(t,n)=>{if(n.direction==="backward")throw new _t(e.constructor.name);const o=r.transform(t.value,t);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(t.value=i,t));if(o instanceof Promise)throw new H;return t.value=o,t}});function Ge(e,r){return e.issues.length&&r===void 0?{issues:[],value:void 0}:e}const Tt=d("$ZodOptional",(e,r)=>{C.init(e,r),e._zod.optin="optional",e._zod.optout="optional",z(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),z(e._zod,"pattern",()=>{const t=r.innerType._zod.pattern;return t?new RegExp(`^(${De(t.source)})?$`):void 0}),e._zod.parse=(t,n)=>{if(r.innerType._zod.optin==="optional"){const o=r.innerType._zod.run(t,n);return o instanceof Promise?o.then(s=>Ge(s,t.value)):Ge(o,t.value)}return t.value===void 0?t:r.innerType._zod.run(t,n)}}),io=d("$ZodExactOptional",(e,r)=>{Tt.init(e,r),z(e._zod,"values",()=>r.innerType._zod.values),z(e._zod,"pattern",()=>r.innerType._zod.pattern),e._zod.parse=(t,n)=>r.innerType._zod.run(t,n)}),so=d("$ZodNullable",(e,r)=>{C.init(e,r),z(e._zod,"optin",()=>r.innerType._zod.optin),z(e._zod,"optout",()=>r.innerType._zod.optout),z(e._zod,"pattern",()=>{const t=r.innerType._zod.pattern;return t?new RegExp(`^(${De(t.source)}|null)$`):void 0}),z(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),e._zod.parse=(t,n)=>t.value===null?t:r.innerType._zod.run(t,n)}),ao=d("$ZodDefault",(e,r)=>{C.init(e,r),e._zod.optin="optional",z(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(t,n)=>{if(n.direction==="backward")return r.innerType._zod.run(t,n);if(t.value===void 0)return t.value=r.defaultValue,t;const o=r.innerType._zod.run(t,n);return o instanceof Promise?o.then(s=>Ke(s,r)):Ke(o,r)}});function Ke(e,r){return e.value===void 0&&(e.value=r.defaultValue),e}const co=d("$ZodPrefault",(e,r)=>{C.init(e,r),e._zod.optin="optional",z(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(t,n)=>(n.direction==="backward"||t.value===void 0&&(t.value=r.defaultValue),r.innerType._zod.run(t,n))}),uo=d("$ZodNonOptional",(e,r)=>{C.init(e,r),z(e._zod,"values",()=>{const t=r.innerType._zod.values;return t?new Set([...t].filter(n=>n!==void 0)):void 0}),e._zod.parse=(t,n)=>{const o=r.innerType._zod.run(t,n);return o instanceof Promise?o.then(s=>Xe(s,e)):Xe(o,e)}});function Xe(e,r){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:r}),e}const lo=d("$ZodCatch",(e,r)=>{C.init(e,r),z(e._zod,"optin",()=>r.innerType._zod.optin),z(e._zod,"optout",()=>r.innerType._zod.optout),z(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(t,n)=>{if(n.direction==="backward")return r.innerType._zod.run(t,n);const o=r.innerType._zod.run(t,n);return o instanceof Promise?o.then(s=>(t.value=s.value,s.issues.length&&(t.value=r.catchValue({...t,error:{issues:s.issues.map(i=>B(i,n,J()))},input:t.value}),t.issues=[]),t)):(t.value=o.value,o.issues.length&&(t.value=r.catchValue({...t,error:{issues:o.issues.map(s=>B(s,n,J()))},input:t.value}),t.issues=[]),t)}}),po=d("$ZodPipe",(e,r)=>{C.init(e,r),z(e._zod,"values",()=>r.in._zod.values),z(e._zod,"optin",()=>r.in._zod.optin),z(e._zod,"optout",()=>r.out._zod.optout),z(e._zod,"propValues",()=>r.in._zod.propValues),e._zod.parse=(t,n)=>{if(n.direction==="backward"){const s=r.out._zod.run(t,n);return s instanceof Promise?s.then(i=>ce(i,r.in,n)):ce(s,r.in,n)}const o=r.in._zod.run(t,n);return o instanceof Promise?o.then(s=>ce(s,r.out,n)):ce(o,r.out,n)}});function ce(e,r,t){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:e.value,issues:e.issues},t)}const fo=d("$ZodReadonly",(e,r)=>{C.init(e,r),z(e._zod,"propValues",()=>r.innerType._zod.propValues),z(e._zod,"values",()=>r.innerType._zod.values),z(e._zod,"optin",()=>r.innerType?._zod?.optin),z(e._zod,"optout",()=>r.innerType?._zod?.optout),e._zod.parse=(t,n)=>{if(n.direction==="backward")return r.innerType._zod.run(t,n);const o=r.innerType._zod.run(t,n);return o instanceof Promise?o.then(Ye):Ye(o)}});function Ye(e){return e.value=Object.freeze(e.value),e}const ho=d("$ZodCustom",(e,r)=>{N.init(e,r),C.init(e,r),e._zod.parse=(t,n)=>t,e._zod.check=t=>{const n=t.value,o=r.fn(n);if(o instanceof Promise)return o.then(s=>Qe(s,t,n,e));Qe(o,t,n,e)}});function Qe(e,r,t,n){if(!e){const o={code:"custom",input:t,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),r.issues.push(ne(o))}}var et;class mo{constructor(){this._map=new WeakMap,this._idmap=new Map}add(r,...t){const n=t[0];return this._map.set(r,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,r),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(r){const t=this._map.get(r);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(r),this}get(r){const t=r._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const o={...n,...this._map.get(r)};return Object.keys(o).length?o:void 0}return this._map.get(r)}has(r){return this._map.has(r)}}function go(){return new mo}(et=globalThis).__zod_globalRegistry??(et.__zod_globalRegistry=go());const te=globalThis.__zod_globalRegistry;function vo(e,r){return new e({type:"string",...m(r)})}function _o(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...m(r)})}function tt(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...m(r)})}function wo(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...m(r)})}function yo(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...m(r)})}function zo(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...m(r)})}function bo(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...m(r)})}function So(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...m(r)})}function ko(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...m(r)})}function Po(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...m(r)})}function Eo(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...m(r)})}function xo(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...m(r)})}function Co(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...m(r)})}function $o(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...m(r)})}function Zo(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...m(r)})}function Ro(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...m(r)})}function Oo(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...m(r)})}function To(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...m(r)})}function Do(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...m(r)})}function jo(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...m(r)})}function Ao(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...m(r)})}function Io(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...m(r)})}function No(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...m(r)})}function Uo(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...m(r)})}function Mo(e,r){return new e({type:"string",format:"date",check:"string_format",...m(r)})}function Fo(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...m(r)})}function Lo(e,r){return new e({type:"string",format:"duration",check:"string_format",...m(r)})}function Wo(e){return new e({type:"unknown"})}function Jo(e,r){return new e({type:"never",...m(r)})}function Dt(e,r){return new fn({check:"max_length",...m(r),maximum:e})}function fe(e,r){return new hn({check:"min_length",...m(r),minimum:e})}function jt(e,r){return new mn({check:"length_equals",...m(r),length:e})}function Bo(e,r){return new gn({check:"string_format",format:"regex",...m(r),pattern:e})}function Vo(e){return new vn({check:"string_format",format:"lowercase",...m(e)})}function qo(e){return new _n({check:"string_format",format:"uppercase",...m(e)})}function Ho(e,r){return new wn({check:"string_format",format:"includes",...m(r),includes:e})}function Go(e,r){return new yn({check:"string_format",format:"starts_with",...m(r),prefix:e})}function Ko(e,r){return new zn({check:"string_format",format:"ends_with",...m(r),suffix:e})}function K(e){return new bn({check:"overwrite",tx:e})}function Xo(e){return K(r=>r.normalize(e))}function Yo(){return K(e=>e.trim())}function Qo(){return K(e=>e.toLowerCase())}function ei(){return K(e=>e.toUpperCase())}function ti(){return K(e=>yr(e))}function ri(e,r,t){return new e({type:"array",element:r,...m(t)})}function ni(e,r,t){return new e({type:"custom",check:"custom",fn:r,...m(t)})}function oi(e){const r=ii(t=>(t.addIssue=n=>{if(typeof n=="string")t.issues.push(ne(n,t.value,r._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),t.issues.push(ne(o))}},e(t.value,t)));return r}function ii(e,r){const t=new N({check:"custom",...m(r)});return t._zod.check=e,t}function At(e){let r=e?.target??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??te,target:r,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Z(e,r,t={path:[],schemaPath:[]}){var n;const o=e._zod.def,s=r.seen.get(e);if(s)return s.count++,t.schemaPath.includes(e)&&(s.cycle=t.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:t.path};r.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const l={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,i.schema,l);else{const p=i.schema,h=r.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,r,p,l)}const f=e._zod.parent;f&&(i.ref||(i.ref=f),Z(f,r,l),r.seen.get(f).isParent=!0)}const c=r.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),r.io==="input"&&T(e)&&(delete i.schema.examples,delete i.schema.default),r.io==="input"&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,r.seen.get(e).schema}function It(e,r){const t=e.seen.get(r);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(i[0])?.id,p=e.external.uri??(w=>w);if(f)return{ref:p(f)};const h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${p("__shared")}#/${a}/${h}`}}if(i[1]===t)return{ref:"#"};const u=`#/${a}/`,l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/ + +Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(r===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(r!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function Nt(e,r){const t=e.seen.get(r);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},l=a.ref;if(a.ref=null,l){n(l);const p=e.seen.get(l),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,u),i._zod.parent===l)for(const v in c)v==="$ref"||v==="allOf"||v in u||delete c[v];if(h.$ref&&p.def)for(const v in c)v==="$ref"||v==="allOf"||v in p.def&&JSON.stringify(c[v])===JSON.stringify(p.def[v])&&delete c[v]}const f=i._zod.parent;if(f&&f!==l){n(f);const p=e.seen.get(f);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())n(i[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(r)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,t.def??t.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...r["~standard"],jsonSchema:{input:he(r,"input",e.processors),output:he(r,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function T(e,r){const t=r??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return T(n.element,t);if(n.type==="set")return T(n.valueType,t);if(n.type==="lazy")return T(n.getter(),t);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return T(n.innerType,t);if(n.type==="intersection")return T(n.left,t)||T(n.right,t);if(n.type==="record"||n.type==="map")return T(n.keyType,t)||T(n.valueType,t);if(n.type==="pipe")return T(n.in,t)||T(n.out,t);if(n.type==="object"){for(const o in n.shape)if(T(n.shape[o],t))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(T(o,t))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(T(o,t))return!0;return!!(n.rest&&T(n.rest,t))}return!1}const si=(e,r={})=>t=>{const n=At({...t,processors:r});return Z(e,n),It(n,e),Nt(n,e)},he=(e,r,t={})=>n=>{const{libraryOptions:o,target:s}=n??{},i=At({...o??{},target:s,io:r,processors:t});return Z(e,i),It(i,e),Nt(i,e)},ai={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ci=(e,r,t,n)=>{const o=t;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ai[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(f=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},ui=(e,r,t,n)=>{t.not={}},li=(e,r,t,n)=>{},di=(e,r,t,n)=>{const o=e._zod.def,s=yt(o.entries);s.every(i=>typeof i=="number")&&(t.type="number"),s.every(i=>typeof i=="string")&&(t.type="string"),t.enum=s},pi=(e,r,t,n)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fi=(e,r,t,n)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},hi=(e,r,t,n)=>{const o=t,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=Z(s.element,r,{...n,path:[...n.path,"items"]})},mi=(e,r,t,n)=>{const o=t,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=Z(i[u],r,{...n,path:[...n.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const l=s.shape[u]._zod;return r.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Z(s.catchall,r,{...n,path:[...n.path,"additionalProperties"]})):r.io==="output"&&(o.additionalProperties=!1)},gi=(e,r,t,n)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>Z(a,r,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?t.oneOf=i:t.anyOf=i},vi=(e,r,t,n)=>{const o=e._zod.def,s=Z(o.left,r,{...n,path:[...n.path,"allOf",0]}),i=Z(o.right,r,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];t.allOf=c},_i=(e,r,t,n)=>{const o=e._zod.def,s=Z(o.innerType,r,n),i=r.seen.get(e);r.target==="openapi-3.0"?(i.ref=o.innerType,t.nullable=!0):t.anyOf=[s,{type:"null"}]},wi=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType},yi=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType,t.default=JSON.parse(JSON.stringify(o.defaultValue))},zi=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType,r.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},bi=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=i},Si=(e,r,t,n)=>{const o=e._zod.def,s=r.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Z(s,r,n);const i=r.seen.get(e);i.ref=s},ki=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType,t.readOnly=!0},Ut=(e,r,t,n)=>{const o=e._zod.def;Z(o.innerType,r,n);const s=r.seen.get(e);s.ref=o.innerType},Pi=d("ZodISODateTime",(e,r)=>{An.init(e,r),k.init(e,r)});function Ei(e){return Uo(Pi,e)}const xi=d("ZodISODate",(e,r)=>{In.init(e,r),k.init(e,r)});function Ci(e){return Mo(xi,e)}const $i=d("ZodISOTime",(e,r)=>{Nn.init(e,r),k.init(e,r)});function Zi(e){return Fo($i,e)}const Ri=d("ZodISODuration",(e,r)=>{Un.init(e,r),k.init(e,r)});function Oi(e){return Lo(Ri,e)}const Ti=(e,r)=>{Pt.init(e,r),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>Or(e,t)},flatten:{value:t=>Rr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ce,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ce,2)}},isEmpty:{get(){return e.issues.length===0}}})},A=d("ZodError",Ti,{Parent:Error}),Di=Ae(A),ji=Ie(A),Ai=ge(A),Ii=ve(A),Ni=jr(A),Ui=Ar(A),Mi=Ir(A),Fi=Nr(A),Li=Ur(A),Wi=Mr(A),Ji=Fr(A),Bi=Lr(A),$=d("ZodType",(e,r)=>(C.init(e,r),Object.assign(e["~standard"],{jsonSchema:{input:he(e,"input"),output:he(e,"output")}}),e.toJSONSchema=si(e,{}),e.def=r,e.type=r.type,Object.defineProperty(e,"_def",{value:r}),e.check=(...t)=>e.clone(M(r,{checks:[...r.checks??[],...t.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>F(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Di(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ai(e,t,n),e.parseAsync=async(t,n)=>ji(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ii(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ni(e,t,n),e.decode=(t,n)=>Ui(e,t,n),e.encodeAsync=async(t,n)=>Mi(e,t,n),e.decodeAsync=async(t,n)=>Fi(e,t,n),e.safeEncode=(t,n)=>Li(e,t,n),e.safeDecode=(t,n)=>Wi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ji(e,t,n),e.safeDecodeAsync=async(t,n)=>Bi(e,t,n),e.refine=(t,n)=>e.check(Ns(t,n)),e.superRefine=t=>e.check(Us(t)),e.overwrite=t=>e.check(K(t)),e.optional=()=>ot(e),e.exactOptional=()=>Ps(e),e.nullable=()=>it(e),e.nullish=()=>ot(it(e)),e.nonoptional=t=>Rs(e,t),e.array=()=>hs(e),e.or=t=>_s([e,t]),e.and=t=>ys(e,t),e.transform=t=>st(e,Ss(t)),e.default=t=>Cs(e,t),e.prefault=t=>Zs(e,t),e.catch=t=>Ts(e,t),e.pipe=t=>st(e,t),e.readonly=()=>As(e),e.describe=t=>{const n=e.clone();return te.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return te.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return te.get(e);const n=e.clone();return te.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Mt=d("_ZodString",(e,r)=>{Ne.init(e,r),$.init(e,r),e._zod.processJSONSchema=(n,o,s)=>ci(e,n,o);const t=e._zod.bag;e.format=t.format??null,e.minLength=t.minimum??null,e.maxLength=t.maximum??null,e.regex=(...n)=>e.check(Bo(...n)),e.includes=(...n)=>e.check(Ho(...n)),e.startsWith=(...n)=>e.check(Go(...n)),e.endsWith=(...n)=>e.check(Ko(...n)),e.min=(...n)=>e.check(fe(...n)),e.max=(...n)=>e.check(Dt(...n)),e.length=(...n)=>e.check(jt(...n)),e.nonempty=(...n)=>e.check(fe(1,...n)),e.lowercase=n=>e.check(Vo(n)),e.uppercase=n=>e.check(qo(n)),e.trim=()=>e.check(Yo()),e.normalize=(...n)=>e.check(Xo(...n)),e.toLowerCase=()=>e.check(Qo()),e.toUpperCase=()=>e.check(ei()),e.slugify=()=>e.check(ti())}),Vi=d("ZodString",(e,r)=>{Ne.init(e,r),Mt.init(e,r),e.email=t=>e.check(_o(qi,t)),e.url=t=>e.check(So(Hi,t)),e.jwt=t=>e.check(No(us,t)),e.emoji=t=>e.check(ko(Gi,t)),e.guid=t=>e.check(tt(rt,t)),e.uuid=t=>e.check(wo(ue,t)),e.uuidv4=t=>e.check(yo(ue,t)),e.uuidv6=t=>e.check(zo(ue,t)),e.uuidv7=t=>e.check(bo(ue,t)),e.nanoid=t=>e.check(Po(Ki,t)),e.guid=t=>e.check(tt(rt,t)),e.cuid=t=>e.check(Eo(Xi,t)),e.cuid2=t=>e.check(xo(Yi,t)),e.ulid=t=>e.check(Co(Qi,t)),e.base64=t=>e.check(jo(ss,t)),e.base64url=t=>e.check(Ao(as,t)),e.xid=t=>e.check($o(es,t)),e.ksuid=t=>e.check(Zo(ts,t)),e.ipv4=t=>e.check(Ro(rs,t)),e.ipv6=t=>e.check(Oo(ns,t)),e.cidrv4=t=>e.check(To(os,t)),e.cidrv6=t=>e.check(Do(is,t)),e.e164=t=>e.check(Io(cs,t)),e.datetime=t=>e.check(Ei(t)),e.date=t=>e.check(Ci(t)),e.time=t=>e.check(Zi(t)),e.duration=t=>e.check(Oi(t))});function Ft(e){return vo(Vi,e)}const k=d("ZodStringFormat",(e,r)=>{S.init(e,r),Mt.init(e,r)}),qi=d("ZodEmail",(e,r)=>{xn.init(e,r),k.init(e,r)}),rt=d("ZodGUID",(e,r)=>{Pn.init(e,r),k.init(e,r)}),ue=d("ZodUUID",(e,r)=>{En.init(e,r),k.init(e,r)}),Hi=d("ZodURL",(e,r)=>{Cn.init(e,r),k.init(e,r)}),Gi=d("ZodEmoji",(e,r)=>{$n.init(e,r),k.init(e,r)}),Ki=d("ZodNanoID",(e,r)=>{Zn.init(e,r),k.init(e,r)}),Xi=d("ZodCUID",(e,r)=>{Rn.init(e,r),k.init(e,r)}),Yi=d("ZodCUID2",(e,r)=>{On.init(e,r),k.init(e,r)}),Qi=d("ZodULID",(e,r)=>{Tn.init(e,r),k.init(e,r)}),es=d("ZodXID",(e,r)=>{Dn.init(e,r),k.init(e,r)}),ts=d("ZodKSUID",(e,r)=>{jn.init(e,r),k.init(e,r)}),rs=d("ZodIPv4",(e,r)=>{Mn.init(e,r),k.init(e,r)}),ns=d("ZodIPv6",(e,r)=>{Fn.init(e,r),k.init(e,r)}),os=d("ZodCIDRv4",(e,r)=>{Ln.init(e,r),k.init(e,r)}),is=d("ZodCIDRv6",(e,r)=>{Wn.init(e,r),k.init(e,r)}),ss=d("ZodBase64",(e,r)=>{Jn.init(e,r),k.init(e,r)}),as=d("ZodBase64URL",(e,r)=>{Vn.init(e,r),k.init(e,r)}),cs=d("ZodE164",(e,r)=>{qn.init(e,r),k.init(e,r)}),us=d("ZodJWT",(e,r)=>{Gn.init(e,r),k.init(e,r)}),ls=d("ZodUnknown",(e,r)=>{Kn.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>li()});function nt(){return Wo(ls)}const ds=d("ZodNever",(e,r)=>{Xn.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>ui(e,t,n)});function ps(e){return Jo(ds,e)}const fs=d("ZodArray",(e,r)=>{Yn.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>hi(e,t,n,o),e.element=r.element,e.min=(t,n)=>e.check(fe(t,n)),e.nonempty=t=>e.check(fe(1,t)),e.max=(t,n)=>e.check(Dt(t,n)),e.length=(t,n)=>e.check(jt(t,n)),e.unwrap=()=>e.element});function hs(e,r){return ri(fs,e,r)}const ms=d("ZodObject",(e,r)=>{eo.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>mi(e,t,n,o),z(e,"shape",()=>r.shape),e.keyof=()=>zs(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:nt()}),e.loose=()=>e.clone({...e._zod.def,catchall:nt()}),e.strict=()=>e.clone({...e._zod.def,catchall:ps()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Er(e,t),e.safeExtend=t=>xr(e,t),e.merge=t=>Cr(e,t),e.pick=t=>kr(e,t),e.omit=t=>Pr(e,t),e.partial=(...t)=>$r(Lt,e,t[0]),e.required=(...t)=>Zr(Wt,e,t[0])});function gs(e,r){const t={type:"object",shape:e??{},...m(r)};return new ms(t)}const vs=d("ZodUnion",(e,r)=>{to.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>gi(e,t,n,o),e.options=r.options});function _s(e,r){return new vs({type:"union",options:e,...m(r)})}const ws=d("ZodIntersection",(e,r)=>{ro.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>vi(e,t,n,o)});function ys(e,r){return new ws({type:"intersection",left:e,right:r})}const Ze=d("ZodEnum",(e,r)=>{no.init(e,r),$.init(e,r),e._zod.processJSONSchema=(n,o,s)=>di(e,n,o),e.enum=r.entries,e.options=Object.values(r.entries);const t=new Set(Object.keys(r.entries));e.extract=(n,o)=>{const s={};for(const i of n)if(t.has(i))s[i]=r.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ze({...r,checks:[],...m(o),entries:s})},e.exclude=(n,o)=>{const s={...r.entries};for(const i of n)if(t.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ze({...r,checks:[],...m(o),entries:s})}});function zs(e,r){const t=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ze({type:"enum",entries:t,...m(r)})}const bs=d("ZodTransform",(e,r)=>{oo.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>fi(e,t),e._zod.parse=(t,n)=>{if(n.direction==="backward")throw new _t(e.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(ne(s,t.value,r));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),t.issues.push(ne(i))}};const o=r.transform(t.value,t);return o instanceof Promise?o.then(s=>(t.value=s,t)):(t.value=o,t)}});function Ss(e){return new bs({type:"transform",transform:e})}const Lt=d("ZodOptional",(e,r)=>{Tt.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>Ut(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function ot(e){return new Lt({type:"optional",innerType:e})}const ks=d("ZodExactOptional",(e,r)=>{io.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>Ut(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function Ps(e){return new ks({type:"optional",innerType:e})}const Es=d("ZodNullable",(e,r)=>{so.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>_i(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function it(e){return new Es({type:"nullable",innerType:e})}const xs=d("ZodDefault",(e,r)=>{ao.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>yi(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Cs(e,r){return new xs({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():bt(r)}})}const $s=d("ZodPrefault",(e,r)=>{co.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>zi(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function Zs(e,r){return new $s({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():bt(r)}})}const Wt=d("ZodNonOptional",(e,r)=>{uo.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>wi(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function Rs(e,r){return new Wt({type:"nonoptional",innerType:e,...m(r)})}const Os=d("ZodCatch",(e,r)=>{lo.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>bi(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ts(e,r){return new Os({type:"catch",innerType:e,catchValue:typeof r=="function"?r:()=>r})}const Ds=d("ZodPipe",(e,r)=>{po.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>Si(e,t,n,o),e.in=r.in,e.out=r.out});function st(e,r){return new Ds({type:"pipe",in:e,out:r})}const js=d("ZodReadonly",(e,r)=>{fo.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>ki(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function As(e){return new js({type:"readonly",innerType:e})}const Is=d("ZodCustom",(e,r)=>{ho.init(e,r),$.init(e,r),e._zod.processJSONSchema=(t,n,o)=>pi(e,t)});function Ns(e,r={}){return ni(Is,e,r)}function Us(e){return oi(e)}const Ms=/[<>]/,Fs=/^\+?[0-9 ()\-.]{7,20}$/,Ls=Ft().trim().min(1,"Full name is required").max(100,"Full name must be 100 characters or fewer").refine(e=>!Ms.test(e),{message:"Full name cannot contain < or > characters"}),Ws=Ft().trim().max(20,"Phone number must be 20 characters or fewer").refine(e=>e.length===0||Fs.test(e),{message:"Phone number must contain only digits and + ( ) - . spaces"}),Js=gs({name:Ls,phone:Ws.optional()});function Aa(e){const r=Js.safeParse({name:e.name??"",phone:e.phone??""});return r.success?null:r.error.issues[0]?.message??"Invalid profile data"}var Se,at;function Bs(){if(at)return Se;at=1;var e=!1,r,t,n,o,s,i,a,c,u,l,f,p,h,w,v;function y(){if(!e){e=!0;var P=navigator.userAgent,_=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(P),b=/(Mac OS X)|(Windows)|(Linux)/.exec(P);if(p=/\b(iPhone|iP[ao]d)/.exec(P),h=/\b(iP[ao]d)/.exec(P),l=/Android/i.exec(P),w=/FBAN\/\w+;/i.exec(P),v=/Mobile/i.exec(P),f=!!/Win64/.exec(P),_){r=_[1]?parseFloat(_[1]):_[5]?parseFloat(_[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var E=/(?:Trident\/(\d+.\d+))/.exec(P);i=E?parseFloat(E[1])+4:r,t=_[2]?parseFloat(_[2]):NaN,n=_[3]?parseFloat(_[3]):NaN,o=_[4]?parseFloat(_[4]):NaN,o?(_=/(?:Chrome\/(\d+\.\d+))/.exec(P),s=_&&_[1]?parseFloat(_[1]):NaN):s=NaN}else r=t=n=s=o=NaN;if(b){if(b[1]){var j=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(P);a=j?parseFloat(j[1].replace("_",".")):!0}else a=!1;c=!!b[2],u=!!b[3]}else a=c=u=!1}}var D={ie:function(){return y()||r},ieCompatibilityMode:function(){return y()||i>r},ie64:function(){return D.ie()&&f},firefox:function(){return y()||t},opera:function(){return y()||n},webkit:function(){return y()||o},safari:function(){return D.webkit()},chrome:function(){return y()||s},windows:function(){return y()||c},osx:function(){return y()||a},linux:function(){return y()||u},iphone:function(){return y()||p},mobile:function(){return y()||p||h||l||v},nativeApp:function(){return y()||w},android:function(){return y()||l},ipad:function(){return y()||h}};return Se=D,Se}var ke,ct;function Vs(){if(ct)return ke;ct=1;var e=!!(typeof window<"u"&&window.document&&window.document.createElement),r={canUseDOM:e,canUseWorkers:typeof Worker<"u",canUseEventListeners:e&&!!(window.addEventListener||window.attachEvent),canUseViewport:e&&!!window.screen,isInWorker:!e};return ke=r,ke}var Pe,ut;function qs(){if(ut)return Pe;ut=1;var e=Vs(),r;e.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);/** + * Checks if an event is supported in the current execution environment. + * + * NOTE: This will not work correctly for non-generic events such as `change`, + * `reset`, `load`, `error`, and `select`. + * + * Borrows from Modernizr. + * + * @param {string} eventNameSuffix Event name, e.g. "click". + * @param {?boolean} capture Check if the capture phase is supported. + * @return {boolean} True if the event is supported. + * @internal + * @license Modernizr 3.0.0pre (Custom Build) | MIT + */function t(n,o){if(!e.canUseDOM||o&&!("addEventListener"in document))return!1;var s="on"+n,i=s in document;if(!i){var a=document.createElement("div");a.setAttribute(s,"return;"),i=typeof a[s]=="function"}return!i&&r&&n==="wheel"&&(i=document.implementation.hasFeature("Events.wheel","3.0")),i}return Pe=t,Pe}var Ee,lt;function Hs(){if(lt)return Ee;lt=1;var e=Bs(),r=qs(),t=10,n=40,o=800;function s(i){var a=0,c=0,u=0,l=0;return"detail"in i&&(c=i.detail),"wheelDelta"in i&&(c=-i.wheelDelta/120),"wheelDeltaY"in i&&(c=-i.wheelDeltaY/120),"wheelDeltaX"in i&&(a=-i.wheelDeltaX/120),"axis"in i&&i.axis===i.HORIZONTAL_AXIS&&(a=c,c=0),u=a*t,l=c*t,"deltaY"in i&&(l=i.deltaY),"deltaX"in i&&(u=i.deltaX),(u||l)&&i.deltaMode&&(i.deltaMode==1?(u*=n,l*=n):(u*=o,l*=o)),u&&!a&&(a=u<1?-1:1),l&&!c&&(c=l<1?-1:1),{spinX:a,spinY:c,pixelX:u,pixelY:l}}return s.getEventType=function(){return e.firefox()?"DOMMouseScroll":r("wheel")?"wheel":"mousewheel"},Ee=s,Ee}var xe,dt;function Gs(){return dt||(dt=1,xe=Hs()),xe}var Ks=Gs();const Xs=rr(Ks);function Ys(e,r,t,n,o,s){s===void 0&&(s=0);var i=G(e,r,s),a=i.width,c=i.height,u=Math.min(a,t),l=Math.min(c,n);return u>l*o?{width:l*o,height:l}:{width:u,height:u/o}}function Qs(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}function Q(e,r,t,n,o){o===void 0&&(o=0);var s=G(r.width,r.height,o),i=s.width,a=s.height;return{x:pt(e.x,i,t.width,n),y:pt(e.y,a,t.height,n)}}function pt(e,r,t,n){var o=Math.abs(r*n/2-t/2);return we(e,-o,o)}function ft(e,r){return Math.sqrt(Math.pow(e.y-r.y,2)+Math.pow(e.x-r.x,2))}function ht(e,r){return Math.atan2(r.y-e.y,r.x-e.x)*180/Math.PI}function ea(e,r,t,n,o,s,i){s===void 0&&(s=0),i===void 0&&(i=!0);var a=i?ta:ra,c=G(r.width,r.height,s),u=G(r.naturalWidth,r.naturalHeight,s),l={x:a(100,((c.width-t.width/o)/2-e.x/o)/c.width*100),y:a(100,((c.height-t.height/o)/2-e.y/o)/c.height*100),width:a(100,t.width/c.width*100/o),height:a(100,t.height/c.height*100/o)},f=Math.round(a(u.width,l.width*u.width/100)),p=Math.round(a(u.height,l.height*u.height/100)),h=u.width>=u.height*n,w=h?{width:Math.round(p*n),height:p}:{width:f,height:Math.round(f/n)},v=R(R({},w),{x:Math.round(a(u.width-w.width,l.x*u.width/100)),y:Math.round(a(u.height-w.height,l.y*u.height/100))});return{croppedAreaPercentages:l,croppedAreaPixels:v}}function ta(e,r){return Math.min(e,Math.max(0,r))}function ra(e,r){return r}function na(e,r,t,n,o,s){var i=G(r.width,r.height,t),a=we(n.width/i.width*(100/e.width),o,s),c={x:a*i.width/2-n.width/2-i.width*a*(e.x/100),y:a*i.height/2-n.height/2-i.height*a*(e.y/100)};return{crop:c,zoom:a}}function oa(e,r,t){var n=Qs(r);return t.height>t.width?t.height/(e.height*n):t.width/(e.width*n)}function ia(e,r,t,n,o,s){t===void 0&&(t=0);var i=G(r.naturalWidth,r.naturalHeight,t),a=we(oa(e,r,n),o,s),c=n.height>n.width?n.height/e.height:n.width/e.width,u={x:((i.width-e.width)/2-e.x)*c,y:((i.height-e.height)/2-e.y)*c};return{crop:u,zoom:a}}function mt(e,r){return{x:(r.x+e.x)/2,y:(r.y+e.y)/2}}function sa(e){return e*Math.PI/180}function G(e,r,t){var n=sa(t);return{width:Math.abs(Math.cos(n)*e)+Math.abs(Math.sin(n)*r),height:Math.abs(Math.sin(n)*e)+Math.abs(Math.cos(n)*r)}}function we(e,r,t){return Math.min(Math.max(e,r),t)}function le(){for(var e=[],r=0;r0}).join(" ").trim()}var aa=`.reactEasyCrop_Container { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + user-select: none; + touch-action: none; + cursor: move; + display: flex; + justify-content: center; + align-items: center; +} + +.reactEasyCrop_Image, +.reactEasyCrop_Video { + will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */ +} + +.reactEasyCrop_Contain { + max-width: 100%; + max-height: 100%; + margin: auto; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; +} +.reactEasyCrop_Cover_Horizontal { + width: 100%; + height: auto; +} +.reactEasyCrop_Cover_Vertical { + width: auto; + height: 100%; +} + +.reactEasyCrop_CropArea { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + border: 1px solid rgba(255, 255, 255, 0.5); + box-sizing: border-box; + box-shadow: 0 0 0 9999em; + color: rgba(0, 0, 0, 0.5); + overflow: hidden; +} + +.reactEasyCrop_CropAreaRound { + border-radius: 50%; +} + +.reactEasyCrop_CropAreaGrid::before { + content: ' '; + box-sizing: border-box; + position: absolute; + border: 1px solid rgba(255, 255, 255, 0.5); + top: 0; + bottom: 0; + left: 33.33%; + right: 33.33%; + border-top: 0; + border-bottom: 0; +} + +.reactEasyCrop_CropAreaGrid::after { + content: ' '; + box-sizing: border-box; + position: absolute; + border: 1px solid rgba(255, 255, 255, 0.5); + top: 33.33%; + bottom: 33.33%; + left: 0; + right: 0; + border-left: 0; + border-right: 0; +} +`,ca=1,ua=3,la=1,da=(function(e){nr(r,e);function r(){var t=e!==null&&e.apply(this,arguments)||this;return t.cropperRef=x.createRef(),t.imageRef=x.createRef(),t.videoRef=x.createRef(),t.containerPosition={x:0,y:0},t.containerRef=null,t.styleRef=null,t.containerRect=null,t.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},t.dragStartPosition={x:0,y:0},t.dragStartCrop={x:0,y:0},t.gestureZoomStart=0,t.gestureRotationStart=0,t.isTouching=!1,t.lastPinchDistance=0,t.lastPinchRotation=0,t.rafDragTimeout=null,t.rafPinchTimeout=null,t.wheelTimer=null,t.currentDoc=typeof document<"u"?document:null,t.currentWindow=typeof window<"u"?window:null,t.resizeObserver=null,t.previousCropSize=null,t.isInitialized=!1,t.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},t.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!t.containerRef)){var n=!0;t.resizeObserver=new window.ResizeObserver(function(o){if(n){n=!1;return}t.computeSizes()}),t.resizeObserver.observe(t.containerRef)}},t.preventZoomSafari=function(n){return n.preventDefault()},t.cleanEvents=function(){t.currentDoc&&(t.currentDoc.removeEventListener("mousemove",t.onMouseMove),t.currentDoc.removeEventListener("mouseup",t.onDragStopped),t.currentDoc.removeEventListener("touchmove",t.onTouchMove),t.currentDoc.removeEventListener("touchend",t.onDragStopped),t.currentDoc.removeEventListener("gesturechange",t.onGestureChange),t.currentDoc.removeEventListener("gestureend",t.onGestureEnd),t.currentDoc.removeEventListener("scroll",t.onScroll))},t.clearScrollEvent=function(){t.containerRef&&t.containerRef.removeEventListener("wheel",t.onWheel),t.wheelTimer&&clearTimeout(t.wheelTimer)},t.onMediaLoad=function(){var n=t.computeSizes();n&&(t.previousCropSize=n,t.emitCropData(),t.setInitialCrop(n),t.isInitialized=!0),t.props.onMediaLoaded&&t.props.onMediaLoaded(t.mediaSize)},t.setInitialCrop=function(n){if(t.props.initialCroppedAreaPercentages){var o=na(t.props.initialCroppedAreaPercentages,t.mediaSize,t.props.rotation,n,t.props.minZoom,t.props.maxZoom),s=o.crop,i=o.zoom;t.props.onCropChange(s),t.props.onZoomChange&&t.props.onZoomChange(i)}else if(t.props.initialCroppedAreaPixels){var a=ia(t.props.initialCroppedAreaPixels,t.mediaSize,t.props.rotation,n,t.props.minZoom,t.props.maxZoom),s=a.crop,i=a.zoom;t.props.onCropChange(s),t.props.onZoomChange&&t.props.onZoomChange(i)}},t.computeSizes=function(){var n,o,s,i,a,c,u=t.imageRef.current||t.videoRef.current;if(u&&t.containerRef){t.containerRect=t.containerRef.getBoundingClientRect(),t.saveContainerPosition();var l=t.containerRect.width/t.containerRect.height,f=((n=t.imageRef.current)===null||n===void 0?void 0:n.naturalWidth)||((o=t.videoRef.current)===null||o===void 0?void 0:o.videoWidth)||0,p=((s=t.imageRef.current)===null||s===void 0?void 0:s.naturalHeight)||((i=t.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,h=u.offsetWidthw?{width:t.containerRect.height*w,height:t.containerRect.height}:{width:t.containerRect.width,height:t.containerRect.width/w};break;case"horizontal-cover":v={width:t.containerRect.width,height:t.containerRect.width/w};break;case"vertical-cover":v={width:t.containerRect.height*w,height:t.containerRect.height};break}else v={width:u.offsetWidth,height:u.offsetHeight};t.mediaSize=R(R({},v),{naturalWidth:f,naturalHeight:p}),t.props.setMediaSize&&t.props.setMediaSize(t.mediaSize);var y=t.props.cropSize?t.props.cropSize:Ys(t.mediaSize.width,t.mediaSize.height,t.containerRect.width,t.containerRect.height,t.props.aspect,t.props.rotation);return(((a=t.state.cropSize)===null||a===void 0?void 0:a.height)!==y.height||((c=t.state.cropSize)===null||c===void 0?void 0:c.width)!==y.width)&&t.props.onCropSizeChange&&t.props.onCropSizeChange(y),t.setState({cropSize:y},t.recomputeCropPosition),t.props.setCropSize&&t.props.setCropSize(y),y}},t.saveContainerPosition=function(){if(t.containerRef){var n=t.containerRef.getBoundingClientRect();t.containerPosition={x:n.left,y:n.top}}},t.onMouseDown=function(n){t.currentDoc&&(n.preventDefault(),t.currentDoc.addEventListener("mousemove",t.onMouseMove),t.currentDoc.addEventListener("mouseup",t.onDragStopped),t.saveContainerPosition(),t.onDragStart(r.getMousePoint(n)))},t.onMouseMove=function(n){return t.onDrag(r.getMousePoint(n))},t.onScroll=function(n){t.currentDoc&&(n.preventDefault(),t.saveContainerPosition())},t.onTouchStart=function(n){t.currentDoc&&(t.isTouching=!0,!(t.props.onTouchRequest&&!t.props.onTouchRequest(n))&&(t.currentDoc.addEventListener("touchmove",t.onTouchMove,{passive:!1}),t.currentDoc.addEventListener("touchend",t.onDragStopped),t.saveContainerPosition(),n.touches.length===2?t.onPinchStart(n):n.touches.length===1&&t.onDragStart(r.getTouchPoint(n.touches[0]))))},t.onTouchMove=function(n){n.preventDefault(),n.touches.length===2?t.onPinchMove(n):n.touches.length===1&&t.onDrag(r.getTouchPoint(n.touches[0]))},t.onGestureStart=function(n){t.currentDoc&&(n.preventDefault(),t.currentDoc.addEventListener("gesturechange",t.onGestureChange),t.currentDoc.addEventListener("gestureend",t.onGestureEnd),t.gestureZoomStart=t.props.zoom,t.gestureRotationStart=t.props.rotation)},t.onGestureChange=function(n){if(n.preventDefault(),!t.isTouching){var o=r.getMousePoint(n),s=t.gestureZoomStart-1+n.scale;if(t.setNewZoom(s,o,{shouldUpdatePosition:!0}),t.props.onRotationChange){var i=t.gestureRotationStart+n.rotation;t.props.onRotationChange(i)}}},t.onGestureEnd=function(n){t.cleanEvents()},t.onDragStart=function(n){var o,s,i=n.x,a=n.y;t.dragStartPosition={x:i,y:a},t.dragStartCrop=R({},t.props.crop),(s=(o=t.props).onInteractionStart)===null||s===void 0||s.call(o)},t.onDrag=function(n){var o=n.x,s=n.y;t.currentWindow&&(t.rafDragTimeout&&t.currentWindow.cancelAnimationFrame(t.rafDragTimeout),t.rafDragTimeout=t.currentWindow.requestAnimationFrame(function(){if(t.state.cropSize&&!(o===void 0||s===void 0)){var i=o-t.dragStartPosition.x,a=s-t.dragStartPosition.y,c={x:t.dragStartCrop.x+i,y:t.dragStartCrop.y+a},u=t.props.restrictPosition?Q(c,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):c;t.props.onCropChange(u)}}))},t.onDragStopped=function(){var n,o;t.isTouching=!1,t.cleanEvents(),t.emitCropData(),(o=(n=t.props).onInteractionEnd)===null||o===void 0||o.call(n)},t.onWheel=function(n){if(t.currentWindow&&!(t.props.onWheelRequest&&!t.props.onWheelRequest(n))){n.preventDefault();var o=r.getMousePoint(n),s=Xs(n).pixelY,i=t.props.zoom-s*t.props.zoomSpeed/200;t.setNewZoom(i,o,{shouldUpdatePosition:!0}),t.state.hasWheelJustStarted||t.setState({hasWheelJustStarted:!0},function(){var a,c;return(c=(a=t.props).onInteractionStart)===null||c===void 0?void 0:c.call(a)}),t.wheelTimer&&clearTimeout(t.wheelTimer),t.wheelTimer=t.currentWindow.setTimeout(function(){return t.setState({hasWheelJustStarted:!1},function(){var a,c;return(c=(a=t.props).onInteractionEnd)===null||c===void 0?void 0:c.call(a)})},250)}},t.getPointOnContainer=function(n,o){var s=n.x,i=n.y;if(!t.containerRect)throw new Error("The Cropper is not mounted");return{x:t.containerRect.width/2-(s-o.x),y:t.containerRect.height/2-(i-o.y)}},t.getPointOnMedia=function(n){var o=n.x,s=n.y,i=t.props,a=i.crop,c=i.zoom;return{x:(o+a.x)/c,y:(s+a.y)/c}},t.setNewZoom=function(n,o,s){var i=s===void 0?{}:s,a=i.shouldUpdatePosition,c=a===void 0?!0:a;if(!(!t.state.cropSize||!t.props.onZoomChange)){var u=we(n,t.props.minZoom,t.props.maxZoom);if(c){var l=t.getPointOnContainer(o,t.containerPosition),f=t.getPointOnMedia(l),p={x:f.x*u-l.x,y:f.y*u-l.y},h=t.props.restrictPosition?Q(p,t.mediaSize,t.state.cropSize,u,t.props.rotation):p;t.props.onCropChange(h)}t.props.onZoomChange(u)}},t.getCropData=function(){if(!t.state.cropSize)return null;var n=t.props.restrictPosition?Q(t.props.crop,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):t.props.crop;return ea(n,t.mediaSize,t.state.cropSize,t.getAspect(),t.props.zoom,t.props.rotation,t.props.restrictPosition)},t.emitCropData=function(){var n=t.getCropData();if(n){var o=n.croppedAreaPercentages,s=n.croppedAreaPixels;t.props.onCropComplete&&t.props.onCropComplete(o,s),t.props.onCropAreaChange&&t.props.onCropAreaChange(o,s)}},t.emitCropAreaChange=function(){var n=t.getCropData();if(n){var o=n.croppedAreaPercentages,s=n.croppedAreaPixels;t.props.onCropAreaChange&&t.props.onCropAreaChange(o,s)}},t.recomputeCropPosition=function(){var n,o;if(t.state.cropSize){var s=t.props.crop;if(t.isInitialized&&(!((n=t.previousCropSize)===null||n===void 0)&&n.width)&&(!((o=t.previousCropSize)===null||o===void 0)&&o.height)){var i=Math.abs(t.previousCropSize.width-t.state.cropSize.width)>1e-6||Math.abs(t.previousCropSize.height-t.state.cropSize.height)>1e-6;if(i){var a=t.state.cropSize.width/t.previousCropSize.width,c=t.state.cropSize.height/t.previousCropSize.height;s={x:t.props.crop.x*a,y:t.props.crop.y*c}}}var u=t.props.restrictPosition?Q(s,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):s;t.previousCropSize=t.state.cropSize,t.props.onCropChange(u),t.emitCropData()}},t.onKeyDown=function(n){var o,s,i=t.props,a=i.crop,c=i.onCropChange,u=i.keyboardStep,l=i.zoom,f=i.rotation,p=u;if(t.state.cropSize){n.shiftKey&&(p*=.2);var h=R({},a);switch(n.key){case"ArrowUp":h.y-=p,n.preventDefault();break;case"ArrowDown":h.y+=p,n.preventDefault();break;case"ArrowLeft":h.x-=p,n.preventDefault();break;case"ArrowRight":h.x+=p,n.preventDefault();break;default:return}t.props.restrictPosition&&(h=Q(h,t.mediaSize,t.state.cropSize,l,f)),n.repeat||(s=(o=t.props).onInteractionStart)===null||s===void 0||s.call(o),c(h)}},t.onKeyUp=function(n){var o,s;switch(n.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":n.preventDefault();break;default:return}t.emitCropData(),(s=(o=t.props).onInteractionEnd)===null||s===void 0||s.call(o)},t}return r.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=aa,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))},r.prototype.componentWillUnmount=function(){var t,n;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((n=this.styleRef.parentNode)===null||n===void 0||n.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},r.prototype.componentDidUpdate=function(t){var n,o,s,i,a,c,u,l,f;t.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):t.aspect!==this.props.aspect?this.computeSizes():t.objectFit!==this.props.objectFit?this.computeSizes():t.zoom!==this.props.zoom?this.recomputeCropPosition():((n=t.cropSize)===null||n===void 0?void 0:n.height)!==((o=this.props.cropSize)===null||o===void 0?void 0:o.height)||((s=t.cropSize)===null||s===void 0?void 0:s.width)!==((i=this.props.cropSize)===null||i===void 0?void 0:i.width)?this.computeSizes():(((a=t.crop)===null||a===void 0?void 0:a.x)!==((c=this.props.crop)===null||c===void 0?void 0:c.x)||((u=t.crop)===null||u===void 0?void 0:u.y)!==((l=this.props.crop)===null||l===void 0?void 0:l.y))&&this.emitCropAreaChange(),t.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),t.video!==this.props.video&&((f=this.videoRef.current)===null||f===void 0||f.load());var p=this.getObjectFit();p!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:p},this.computeSizes)},r.prototype.getAspect=function(){var t=this.props,n=t.cropSize,o=t.aspect;return n?n.width/n.height:o},r.prototype.getObjectFit=function(){var t,n,o,s;if(this.props.objectFit==="cover"){var i=this.imageRef.current||this.videoRef.current;if(i&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var a=this.containerRect.width/this.containerRect.height,c=((t=this.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((n=this.videoRef.current)===null||n===void 0?void 0:n.videoWidth)||0,u=((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalHeight)||((s=this.videoRef.current)===null||s===void 0?void 0:s.videoHeight)||0,l=c/u;return lArray.isArray(t)?t:Array.isArray(r)?r:[n,o],[t,r,n,o]);return g.jsxs(or,{"data-slot":"slider",defaultValue:r,value:t,min:n,max:o,className:be("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",e),...s,children:[g.jsx(ir,{"data-slot":"slider-track",className:be("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:g.jsx(sr,{"data-slot":"slider-range",className:be("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,c)=>g.jsx(ar,{"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 Jt=["image/png","image/jpeg","image/webp"],Bt=2*1024*1024,Vt=256,fa=e=>{const r=e.normalize("NFKD").toLowerCase(),t=r.lastIndexOf("."),n=t>0?r.slice(0,t):r,o=t>0?r.slice(t).replace(/[^.a-z0-9]/g,""):"";return`${n.replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"profile-picture"}${o}`},ha=(e,r,t=Date.now())=>`profile-pictures/${e}/${t}-${fa(r)}`,qt=e=>Jt.includes(e.type)?e.size>Bt?"Profile pictures must be 2MB or smaller.":e.name.trim()?null:"Please choose a valid image file.":"Only PNG, JPEG, and WebP images are allowed.",ma=e=>new Promise((r,t)=>{const n=URL.createObjectURL(e),o=new Image,s=setTimeout(()=>{URL.revokeObjectURL(n),t(new Error("Image loading timed out. Please try a different file."))},15e3);o.onload=()=>{clearTimeout(s),URL.revokeObjectURL(n),r(o)},o.onerror=()=>{clearTimeout(s),URL.revokeObjectURL(n),t(new Error("Unable to read the selected image. Please try another file."))},o.crossOrigin="anonymous",o.src=n}),gt=(e,r,t)=>new Promise((n,o)=>{e.toBlob(s=>{if(!s){o(new Error("Failed to prepare the image for upload."));return}n(s)},r,t)}),ga=async(e,r=Vt)=>{const t=await ma(e),n=document.createElement("canvas");n.width=r,n.height=r;const o=n.getContext("2d");if(!o)throw new Error("Your browser cannot process image uploads right now.");const s=t.naturalWidth||t.width,i=t.naturalHeight||t.height,a=Math.min(s,i),c=Math.max(0,(s-a)/2),u=Math.max(0,(i-a)/2);o.clearRect(0,0,r,r),o.drawImage(t,c,u,a,a,0,0,r,r);try{return await gt(n,"image/webp",.9)}catch{return await gt(n,"image/jpeg",.9)}},ee=(e,r,t)=>{let n;const o=new Promise((s,i)=>{n=setTimeout(()=>i(new Error(`${t} timed out after ${Math.round(r/1e3)}s`)),r)});return Promise.race([e,o]).finally(()=>clearTimeout(n))},va=async(e,r,t)=>{const n=Kt.options.projectId;if(!n)throw new Error("Firebase project ID is not configured.");const o=await e.getIdToken(),s=`https://firestore.googleapis.com/v1/projects/${n}/databases/(default)/documents/users/${r}?updateMask.fieldPaths=photo&updateMask.fieldPaths=updatedAt`,i=await fetch(s,{method:"PATCH",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({fields:{photo:{stringValue:t},updatedAt:{timestampValue:new Date().toISOString()}}})});if(!i.ok){const a=await i.text().catch(()=>"");throw new Error(`Firestore REST update failed (${i.status}): ${a}`)}},_a=async({file:e,uid:r,currentUser:t=Ue.currentUser,syncFirestore:n=!0})=>{const o=qt(e);if(o)throw new Error(o);const s=t??Ue.currentUser;if(!s)throw new Error("You need to be signed in to change your profile picture.");const i=r||s.uid;if(!i)throw new Error("Unable to determine which profile should be updated.");if(s.uid!==i)throw new Error("The signed-in user does not match the profile being edited.");const a=await ee(ga(e,Vt),2e4,"Image processing"),c=ha(i,e.name),u=ur(Gt,c),l=await ee(lr(u,a,{contentType:a.type||"image/webp",cacheControl:"public, max-age=31536000, immutable"}),3e4,"Storage upload"),f=await ee(dr(l.ref),1e4,"Download URL retrieval");try{await ee(cr(s,{photoURL:f}),1e4,"Auth profile update")}catch(p){console.warn("[PROFILE UPLOAD] Auth profile update failed (non-fatal):",p)}if(n)try{await ee(va(s,i,f),1e4,"Firestore profile sync")}catch(p){console.error("[PROFILE UPLOAD] Firestore REST sync failed:",p),console.warn("[PROFILE UPLOAD] Photo was uploaded but the database record may be stale. It will refresh on next login.")}return f},wa=e=>`${(e/(1024*1024)).toFixed(1)} MB`,ya=e=>{const r=(e||"").trim();return r?r.split(/\s+/).slice(0,2).map(t=>t[0]?.toUpperCase()).join(""):"U"},za=e=>new Promise((r,t)=>{const n=new Image;n.onload=()=>r(n),n.onerror=()=>t(new Error("Unable to load the image for cropping.")),n.src=e}),vt=(e,r,t)=>new Promise((n,o)=>{e.toBlob(s=>{if(!s){o(new Error("Failed to prepare the cropped image."));return}n(s)},r,t)}),ba=async(e,r,t)=>{const n=await za(e),o=document.createElement("canvas"),s=640;o.width=s,o.height=s;const i=o.getContext("2d");if(!i)throw new Error("Your browser cannot process the selected image right now.");i.clearRect(0,0,s,s),i.drawImage(n,r.x,r.y,r.width,r.height,0,0,s,s);let a;try{a=await vt(o,"image/webp",.92)}catch{a=await vt(o,"image/jpeg",.92)}if(!a)throw new Error("Could not create an image from the cropped area.");const c=a.type==="image/webp"?"webp":"jpg",l=`${t.name.replace(/\.[^/.]+$/,"")||"profile-picture"}-cropped.${c}`;return new File([a],l,{type:a.type,lastModified:Date.now()})},Ia=({uid:e,photoURL:r,displayName:t,className:n="",onUploaded:o,syncFirestore:s=!0})=>{const{currentUser:i,refreshProfile:a}=Xt(),[c,u]=x.useState(null),[l,f]=x.useState(null),[p,h]=x.useState({x:0,y:0}),[w,v]=x.useState(1),[y,D]=x.useState(null),[P,_]=x.useState(""),[b,E]=x.useState(!1),j=x.useRef(null);x.useEffect(()=>{if(!c){f(null);return}const O=URL.createObjectURL(c);return f(O),()=>URL.revokeObjectURL(O)},[c]);const X=l||r||"",ye=x.useMemo(()=>`${Jt.map(I=>I.replace("image/","").toUpperCase()).join(", ")} up to ${wa(Bt)}. The image will be cropped to a circular avatar.`,[]),L=()=>{u(null),h({x:0,y:0}),v(1),D(null),_(""),j.current&&(j.current.value="")},U=O=>{const I=O.target.files?.[0]||null;if(!I)return;const W=qt(I);if(W){_(W),u(null),O.target.value="";return}_(""),u(I),h({x:0,y:0}),v(1),D(null)},Y=async()=>{if(!c){_("Choose an image before saving.");return}E(!0),_("");const O=6e4;let I;try{const W=(async()=>{const se=l&&y?await ba(l,y,c):c,ze=e||i?.uid;return _a({file:se,uid:ze,currentUser:i,syncFirestore:s})})(),ie=new Promise((se,ze)=>{I=setTimeout(()=>ze(new Error("Upload timed out. Please check your connection and try again.")),O)}),Ht=await Promise.race([W,ie]);o?.(Ht),a().catch(se=>console.warn("[ProfilePictureUploader] refreshProfile failed:",se)),Fe.success("Profile picture updated."),L()}catch(W){const ie=W instanceof Error?W.message:"Failed to update your profile picture.";_(ie),Fe.error(ie)}finally{clearTimeout(I),E(!1)}},oe=()=>{j.current?.click()};return g.jsxs(g.Fragment,{children:[g.jsxs("section",{className:`flex items-center gap-4 rounded-xl border border-slate-200 bg-white p-4 shadow-sm ${n}`,children:[g.jsxs("div",{className:"relative cursor-pointer group",onClick:oe,role:"button",tabIndex:0,onKeyDown:O=>O.key==="Enter"&&oe(),"aria-label":"Change profile picture",children:[g.jsxs(Yt,{className:"size-16 sm:size-20 ring-4 ring-sky-50 shadow-sm transition-transform duration-200 group-hover:scale-105",children:[g.jsx(Qt,{src:X,alt:`${t||"User"} profile picture`}),g.jsx(er,{className:"bg-gradient-to-br from-sky-600 to-cyan-500 text-lg font-semibold text-white",children:ya(t)})]}),g.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:g.jsx(vr,{size:14})})]}),g.jsxs("div",{className:"space-y-1 flex-1",children:[g.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Profile picture"}),g.jsx("p",{className:"text-xs text-slate-500",children:"Click your avatar to upload a new photo."}),P&&g.jsx("p",{className:"text-xs font-medium text-rose-600 mt-1",children:P})]}),g.jsx("input",{ref:j,type:"file",accept:"image/*",onChange:U,className:"sr-only","aria-label":"Choose profile picture"})]}),g.jsx(tr,{children:l&&g.jsxs(g.Fragment,{children:[g.jsx(Me.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[60]",onClick:L}),g.jsx(Me.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:O=>O.stopPropagation(),children:g.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-100",children:[g.jsx("h3",{className:"text-lg font-bold text-slate-900",children:"Update profile picture"}),g.jsx("button",{onClick:L,className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors","aria-label":"Close modal",children:g.jsx(pr,{size:20})})]}),g.jsxs("div",{className:"p-4 sm:p-6 bg-slate-50 flex flex-col items-center",children:[g.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:g.jsx(da,{image:l,crop:p,zoom:w,aspect:1,cropShape:"round",showGrid:!1,objectFit:"cover",restrictPosition:!0,onCropChange:h,onZoomChange:v,onCropComplete:(O,I)=>D(I),style:{containerStyle:{backgroundColor:"#f8fafc"}}})}),g.jsxs("div",{className:"mt-6 w-full max-w-xs flex items-center gap-4",children:[g.jsx(fr,{size:18,className:"text-slate-500"}),g.jsx(pa,{value:[w],min:1,max:3,step:.05,onValueChange:O=>v(O[0]||1),"aria-label":"Profile picture zoom",className:"flex-1 cursor-pointer"}),g.jsx(hr,{size:18,className:"text-slate-500"})]}),g.jsx("p",{className:"mt-4 text-xs text-slate-500 text-center",children:ye})]}),g.jsxs("div",{className:"p-4 border-t border-slate-100 flex items-center justify-end gap-3 bg-white",children:[g.jsx(Le,{type:"button",variant:"ghost",onClick:L,disabled:b,className:"font-medium text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-5",children:"Cancel"}),g.jsx(Le,{type:"button",onClick:Y,disabled:b||!c,className:"bg-sky-600 hover:bg-sky-700 text-white min-w-[120px] gap-2 shadow-sm",children:b?g.jsxs(g.Fragment,{children:[g.jsx(mr,{size:16,className:"animate-pulse"}),"Saving..."]}):"Save picture"})]})]})})]})})]})};export{Da as M,Ia as P,ja as V,Aa as v}; diff --git a/assets/ProfilePictureUploader-Byg9gnjl.js b/assets/ProfilePictureUploader-Byg9gnjl.js deleted file mode 100644 index a520ebe0706ef7f3cb44d91759fb8393ec875b86..0000000000000000000000000000000000000000 --- a/assets/ProfilePictureUploader-Byg9gnjl.js +++ /dev/null @@ -1,109 +0,0 @@ -import{c as X,k as B,I as V,a_ as ve,a$ as ge,l as we,N as xe,O as ye,P as be,g as Ce,m as K,n as J}from"./index-mbyiCUYG.js";import{g as Pe,r as g,j as u}from"./vendor-react-B4AQeu28.js";import{_ as Re,o as b,p as Ee,q as Se,r as _e,s as ze}from"./vendor-radix-xDOIcVzp.js";import{B as Q}from"./button-BqKfG4Jj.js";import{updateProfile as De}from"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-core-DCQrgkxC.js";import{r as Me,u as Ae,a as Ne}from"./vendor-firebase-storage-dc5X5yTv.js";import{X as Te}from"./x-oZO0Ye1Q.js";import{M as je}from"./minus-BEbLkPkH.js";import{P as Ue}from"./plus-CbpDHvDO.js";import{U as Fe}from"./upload-CKMt4jtd.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 Ie=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Le=X("camera",Ie);/** - * @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 Oe=[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m21 3-6.75 6.75",key:"pv0uzu"}],["circle",{cx:"10",cy:"14",r:"6",key:"1qwbdc"}]],Mt=X("mars",Oe);/** - * @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 ke=[["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M9 19h6",key:"456am0"}],["circle",{cx:"12",cy:"9",r:"6",key:"1nw4tq"}]],At=X("venus",ke);var $,ee;function We(){if(ee)return $;ee=1;var a=!1,o,e,t,r,i,n,s,c,l,p,d,h,m,w,y;function f(){if(!a){a=!0;var x=navigator.userAgent,v=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(x),E=/(Mac OS X)|(Windows)|(Linux)/.exec(x);if(h=/\b(iPhone|iP[ao]d)/.exec(x),m=/\b(iP[ao]d)/.exec(x),p=/Android/i.exec(x),w=/FBAN\/\w+;/i.exec(x),y=/Mobile/i.exec(x),d=!!/Win64/.exec(x),v){o=v[1]?parseFloat(v[1]):v[5]?parseFloat(v[5]):NaN,o&&document&&document.documentMode&&(o=document.documentMode);var _=/(?:Trident\/(\d+.\d+))/.exec(x);n=_?parseFloat(_[1])+4:o,e=v[2]?parseFloat(v[2]):NaN,t=v[3]?parseFloat(v[3]):NaN,r=v[4]?parseFloat(v[4]):NaN,r?(v=/(?:Chrome\/(\d+\.\d+))/.exec(x),i=v&&v[1]?parseFloat(v[1]):NaN):i=NaN}else o=e=t=i=r=NaN;if(E){if(E[1]){var P=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(x);s=P?parseFloat(P[1].replace("_",".")):!0}else s=!1;c=!!E[2],l=!!E[3]}else s=c=l=!1}}var R={ie:function(){return f()||o},ieCompatibilityMode:function(){return f()||n>o},ie64:function(){return R.ie()&&d},firefox:function(){return f()||e},opera:function(){return f()||t},webkit:function(){return f()||r},safari:function(){return R.webkit()},chrome:function(){return f()||i},windows:function(){return f()||c},osx:function(){return f()||s},linux:function(){return f()||l},iphone:function(){return f()||h},mobile:function(){return f()||h||m||p||y},nativeApp:function(){return f()||w},android:function(){return f()||p},ipad:function(){return f()||m}};return $=R,$}var H,te;function Ze(){if(te)return H;te=1;var a=!!(typeof window<"u"&&window.document&&window.document.createElement),o={canUseDOM:a,canUseWorkers:typeof Worker<"u",canUseEventListeners:a&&!!(window.addEventListener||window.attachEvent),canUseViewport:a&&!!window.screen,isInWorker:!a};return H=o,H}var q,re;function Be(){if(re)return q;re=1;var a=Ze(),o;a.canUseDOM&&(o=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);/** - * Checks if an event is supported in the current execution environment. - * - * NOTE: This will not work correctly for non-generic events such as `change`, - * `reset`, `load`, `error`, and `select`. - * - * Borrows from Modernizr. - * - * @param {string} eventNameSuffix Event name, e.g. "click". - * @param {?boolean} capture Check if the capture phase is supported. - * @return {boolean} True if the event is supported. - * @internal - * @license Modernizr 3.0.0pre (Custom Build) | MIT - */function e(t,r){if(!a.canUseDOM||r&&!("addEventListener"in document))return!1;var i="on"+t,n=i in document;if(!n){var s=document.createElement("div");s.setAttribute(i,"return;"),n=typeof s[i]=="function"}return!n&&o&&t==="wheel"&&(n=document.implementation.hasFeature("Events.wheel","3.0")),n}return q=e,q}var G,oe;function $e(){if(oe)return G;oe=1;var a=We(),o=Be(),e=10,t=40,r=800;function i(n){var s=0,c=0,l=0,p=0;return"detail"in n&&(c=n.detail),"wheelDelta"in n&&(c=-n.wheelDelta/120),"wheelDeltaY"in n&&(c=-n.wheelDeltaY/120),"wheelDeltaX"in n&&(s=-n.wheelDeltaX/120),"axis"in n&&n.axis===n.HORIZONTAL_AXIS&&(s=c,c=0),l=s*e,p=c*e,"deltaY"in n&&(p=n.deltaY),"deltaX"in n&&(l=n.deltaX),(l||p)&&n.deltaMode&&(n.deltaMode==1?(l*=t,p*=t):(l*=r,p*=r)),l&&!s&&(s=l<1?-1:1),p&&!c&&(c=p<1?-1:1),{spinX:s,spinY:c,pixelX:l,pixelY:p}}return i.getEventType=function(){return a.firefox()?"DOMMouseScroll":o("wheel")?"wheel":"mousewheel"},G=i,G}var Y,ie;function He(){return ie||(ie=1,Y=$e()),Y}var qe=He();const Ge=Pe(qe);function Ye(a,o,e,t,r,i){i===void 0&&(i=0);var n=A(a,o,i),s=n.width,c=n.height,l=Math.min(s,e),p=Math.min(c,t);return l>p*r?{width:p*r,height:p}:{width:l,height:l/r}}function Xe(a){return a.width>a.height?a.width/a.naturalWidth:a.height/a.naturalHeight}function T(a,o,e,t,r){r===void 0&&(r=0);var i=A(o.width,o.height,r),n=i.width,s=i.height;return{x:ne(a.x,n,e.width,t),y:ne(a.y,s,e.height,t)}}function ne(a,o,e,t){var r=Math.abs(o*t/2-e/2);return O(a,-r,r)}function ae(a,o){return Math.sqrt(Math.pow(a.y-o.y,2)+Math.pow(a.x-o.x,2))}function se(a,o){return Math.atan2(o.y-a.y,o.x-a.x)*180/Math.PI}function Ve(a,o,e,t,r,i,n){i===void 0&&(i=0),n===void 0&&(n=!0);var s=n?Ke:Je,c=A(o.width,o.height,i),l=A(o.naturalWidth,o.naturalHeight,i),p={x:s(100,((c.width-e.width/r)/2-a.x/r)/c.width*100),y:s(100,((c.height-e.height/r)/2-a.y/r)/c.height*100),width:s(100,e.width/c.width*100/r),height:s(100,e.height/c.height*100/r)},d=Math.round(s(l.width,p.width*l.width/100)),h=Math.round(s(l.height,p.height*l.height/100)),m=l.width>=l.height*t,w=m?{width:Math.round(h*t),height:h}:{width:d,height:Math.round(d/t)},y=b(b({},w),{x:Math.round(s(l.width-w.width,p.x*l.width/100)),y:Math.round(s(l.height-w.height,p.y*l.height/100))});return{croppedAreaPercentages:p,croppedAreaPixels:y}}function Ke(a,o){return Math.min(a,Math.max(0,o))}function Je(a,o){return o}function Qe(a,o,e,t,r,i){var n=A(o.width,o.height,e),s=O(t.width/n.width*(100/a.width),r,i),c={x:s*n.width/2-t.width/2-n.width*s*(a.x/100),y:s*n.height/2-t.height/2-n.height*s*(a.y/100)};return{crop:c,zoom:s}}function et(a,o,e){var t=Xe(o);return e.height>e.width?e.height/(a.height*t):e.width/(a.width*t)}function tt(a,o,e,t,r,i){e===void 0&&(e=0);var n=A(o.naturalWidth,o.naturalHeight,e),s=O(et(a,o,t),r,i),c=t.height>t.width?t.height/a.height:t.width/a.width,l={x:((n.width-a.width)/2-a.x)*c,y:((n.height-a.height)/2-a.y)*c};return{crop:l,zoom:s}}function ce(a,o){return{x:(o.x+a.x)/2,y:(o.y+a.y)/2}}function rt(a){return a*Math.PI/180}function A(a,o,e){var t=rt(e);return{width:Math.abs(Math.cos(t)*a)+Math.abs(Math.sin(t)*o),height:Math.abs(Math.sin(t)*a)+Math.abs(Math.cos(t)*o)}}function O(a,o,e){return Math.min(Math.max(a,o),e)}function L(){for(var a=[],o=0;o0}).join(" ").trim()}var ot=`.reactEasyCrop_Container { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - overflow: hidden; - user-select: none; - touch-action: none; - cursor: move; - display: flex; - justify-content: center; - align-items: center; -} - -.reactEasyCrop_Image, -.reactEasyCrop_Video { - will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */ -} - -.reactEasyCrop_Contain { - max-width: 100%; - max-height: 100%; - margin: auto; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; -} -.reactEasyCrop_Cover_Horizontal { - width: 100%; - height: auto; -} -.reactEasyCrop_Cover_Vertical { - width: auto; - height: 100%; -} - -.reactEasyCrop_CropArea { - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - border: 1px solid rgba(255, 255, 255, 0.5); - box-sizing: border-box; - box-shadow: 0 0 0 9999em; - color: rgba(0, 0, 0, 0.5); - overflow: hidden; -} - -.reactEasyCrop_CropAreaRound { - border-radius: 50%; -} - -.reactEasyCrop_CropAreaGrid::before { - content: ' '; - box-sizing: border-box; - position: absolute; - border: 1px solid rgba(255, 255, 255, 0.5); - top: 0; - bottom: 0; - left: 33.33%; - right: 33.33%; - border-top: 0; - border-bottom: 0; -} - -.reactEasyCrop_CropAreaGrid::after { - content: ' '; - box-sizing: border-box; - position: absolute; - border: 1px solid rgba(255, 255, 255, 0.5); - top: 33.33%; - bottom: 33.33%; - left: 0; - right: 0; - border-left: 0; - border-right: 0; -} -`,it=1,nt=3,at=1,st=(function(a){Re(o,a);function o(){var e=a!==null&&a.apply(this,arguments)||this;return e.cropperRef=g.createRef(),e.imageRef=g.createRef(),e.videoRef=g.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=Qe(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=tt(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 p=e.containerRect.width/e.containerRect.height,d=((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,h=((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":y={width:e.containerRect.width,height:e.containerRect.width/w};break;case"vertical-cover":y={width:e.containerRect.height*w,height:e.containerRect.height};break}else y={width:l.offsetWidth,height:l.offsetHeight};e.mediaSize=b(b({},y),{naturalWidth:d,naturalHeight:h}),e.props.setMediaSize&&e.props.setMediaSize(e.mediaSize);var f=e.props.cropSize?e.props.cropSize:Ye(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?T(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=Ge(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 p=e.getPointOnContainer(r,e.containerPosition),d=e.getPointOnMedia(p),h={x:d.x*l-p.x,y:d.y*l-p.y},m=e.props.restrictPosition?T(h,e.mediaSize,e.state.cropSize,l,e.props.rotation):h;e.props.onCropChange(m)}e.props.onZoomChange(l)}},e.getCropData=function(){if(!e.state.cropSize)return null;var t=e.props.restrictPosition?T(e.props.crop,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):e.props.crop;return Ve(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?T(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,p=n.zoom,d=n.rotation,h=l;if(e.state.cropSize){t.shiftKey&&(h*=.2);var m=b({},s);switch(t.key){case"ArrowUp":m.y-=h,t.preventDefault();break;case"ArrowDown":m.y+=h,t.preventDefault();break;case"ArrowLeft":m.x-=h,t.preventDefault();break;case"ArrowRight":m.x+=h,t.preventDefault();break;default:return}e.props.restrictPosition&&(m=T(m,e.mediaSize,e.state.cropSize,p,d)),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=ot,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,p,d;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)!==((p=this.props.crop)===null||p===void 0?void 0:p.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&&((d=this.videoRef.current)===null||d===void 0||d.load());var h=this.getObjectFit();h!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:h},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,p=c/l;return pArray.isArray(e)?e:Array.isArray(o)?o:[t,r],[e,o,t,r]);return u.jsxs(Ee,{"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:[u.jsx(Se,{"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:u.jsx(_e,{"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)=>u.jsx(ze,{"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 ue=["image/png","image/jpeg","image/webp"],he=2*1024*1024,de=256,lt=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}-${lt(o)}`,fe=a=>ue.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.",ut=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}),le=(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=de)=>{const e=await ut(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 le(t,"image/webp",.9)}catch{return await le(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))},dt=async(a,o,e)=>{const t=ge.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}`)}},ft=async({file:a,uid:o,currentUser:e=V.currentUser,syncFirestore:t=!0})=>{const r=fe(a);if(r)throw new Error(r);const i=e??V.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,de),2e4,"Image processing"),c=pt(n,a.name),l=Me(ve,c),p=await j(Ae(l,s,{contentType:s.type||"image/webp",cacheControl:"public, max-age=31536000, immutable"}),3e4,"Storage upload"),d=await j(Ne(p.ref),1e4,"Download URL retrieval");try{await j(De(i,{photoURL:d}),1e4,"Auth profile update")}catch(h){console.warn("[PROFILE UPLOAD] Auth profile update failed (non-fatal):",h)}if(t)try{await j(dt(i,n,d),1e4,"Firestore profile sync")}catch(h){console.error("[PROFILE UPLOAD] Firestore REST sync failed:",h),console.warn("[PROFILE UPLOAD] Photo was uploaded but the database record may be stale. It will refresh on next login.")}return d},mt=a=>`${(a/(1024*1024)).toFixed(1)} MB`,vt=a=>{const o=(a||"").trim();return o?o.split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()).join(""):"U"},gt=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)}),wt=async(a,o,e)=>{const t=await gt(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",p=`${e.name.replace(/\.[^/.]+$/,"")||"profile-picture"}-cropped.${c}`;return new File([s],p,{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}=we(),[c,l]=g.useState(null),[p,d]=g.useState(null),[h,m]=g.useState({x:0,y:0}),[w,y]=g.useState(1),[f,R]=g.useState(null),[x,v]=g.useState(""),[E,_]=g.useState(!1),P=g.useRef(null);g.useEffect(()=>{if(!c){d(null);return}const C=URL.createObjectURL(c);return d(C),()=>URL.revokeObjectURL(C)},[c]);const k=p||o||"",W=g.useMemo(()=>`${ue.map(S=>S.replace("image/","").toUpperCase()).join(", ")} up to ${mt(he)}. The image will be cropped to a circular avatar.`,[]),D=()=>{l(null),m({x:0,y:0}),y(1),R(null),v(""),P.current&&(P.current.value="")},z=C=>{const S=C.target.files?.[0]||null;if(!S)return;const M=fe(S);if(M){v(M),l(null),C.target.value="";return}v(""),l(S),m({x:0,y:0}),y(1),R(null)},N=async()=>{if(!c){v("Choose an image before saving.");return}_(!0),v("");const C=6e4;let S;try{const M=(async()=>{const I=p&&f?await wt(p,f,c):c,Z=a||n?.uid;return ft({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)}),me=await Promise.race([M,F]);r?.(me),s().catch(I=>console.warn("[ProfilePictureUploader] refreshProfile failed:",I)),J.success("Profile picture updated."),D()}catch(M){const F=M instanceof Error?M.message:"Failed to update your profile picture.";v(F),J.error(F)}finally{clearTimeout(S),_(!1)}},U=()=>{P.current?.click()};return u.jsxs(u.Fragment,{children:[u.jsxs("section",{className:`flex items-center gap-4 rounded-xl border border-slate-200 bg-white p-4 shadow-sm ${t}`,children:[u.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:[u.jsxs(xe,{className:"size-16 sm:size-20 ring-4 ring-sky-50 shadow-sm transition-transform duration-200 group-hover:scale-105",children:[u.jsx(ye,{src:k,alt:`${e||"User"} profile picture`}),u.jsx(be,{className:"bg-gradient-to-br from-sky-600 to-cyan-500 text-lg font-semibold text-white",children:vt(e)})]}),u.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:u.jsx(Le,{size:14})})]}),u.jsxs("div",{className:"space-y-1 flex-1",children:[u.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Profile picture"}),u.jsx("p",{className:"text-xs text-slate-500",children:"Click your avatar to upload a new photo."}),x&&u.jsx("p",{className:"text-xs font-medium text-rose-600 mt-1",children:x})]}),u.jsx("input",{ref:P,type:"file",accept:"image/*",onChange:z,className:"sr-only","aria-label":"Choose profile picture"})]}),u.jsx(Ce,{children:p&&u.jsxs(u.Fragment,{children:[u.jsx(K.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[60]",onClick:D}),u.jsx(K.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:u.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-100",children:[u.jsx("h3",{className:"text-lg font-bold text-slate-900",children:"Update profile picture"}),u.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:u.jsx(Te,{size:20})})]}),u.jsxs("div",{className:"p-4 sm:p-6 bg-slate-50 flex flex-col items-center",children:[u.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:u.jsx(st,{image:p,crop:h,zoom:w,aspect:1,cropShape:"round",showGrid:!1,objectFit:"cover",restrictPosition:!0,onCropChange:m,onZoomChange:y,onCropComplete:(C,S)=>R(S),style:{containerStyle:{backgroundColor:"#f8fafc"}}})}),u.jsxs("div",{className:"mt-6 w-full max-w-xs flex items-center gap-4",children:[u.jsx(je,{size:18,className:"text-slate-500"}),u.jsx(ct,{value:[w],min:1,max:3,step:.05,onValueChange:C=>y(C[0]||1),"aria-label":"Profile picture zoom",className:"flex-1 cursor-pointer"}),u.jsx(Ue,{size:18,className:"text-slate-500"})]}),u.jsx("p",{className:"mt-4 text-xs text-slate-500 text-center",children:W})]}),u.jsxs("div",{className:"p-4 border-t border-slate-100 flex items-center justify-end gap-3 bg-white",children:[u.jsx(Q,{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"}),u.jsx(Q,{type:"button",onClick:N,disabled:E||!c,className:"bg-sky-600 hover:bg-sky-700 text-white min-w-[120px] gap-2 shadow-sm",children:E?u.jsxs(u.Fragment,{children:[u.jsx(Fe,{size:16,className:"animate-pulse"}),"Saving..."]}):"Save picture"})]})]})})]})})]})};export{Mt as M,Nt as P,At as V}; diff --git a/assets/QuizBattlePage-B6iQUgiR.js b/assets/QuizBattlePage-CgKinHpO.js similarity index 96% rename from assets/QuizBattlePage-B6iQUgiR.js rename to assets/QuizBattlePage-CgKinHpO.js index e61da77777505e81daf230633e94d7bf70f978b9..07ca286f40191822fb66720ae9051109ebcc63e7 100644 --- a/assets/QuizBattlePage-B6iQUgiR.js +++ b/assets/QuizBattlePage-CgKinHpO.js @@ -1,4 +1,4 @@ -import{c as xa,k as u,m as y,h as tt,aF as De,I as rt,aG as Q,Q as Va,q as At,M as Ua,E as Te,U as ge,g as Ke,p as Je,l as Wa,_ as Ya,V as wt,$ as vt,z as Kt,Y as Jt}from"./index-mbyiCUYG.js";import{r as i,j as e,d as Ft}from"./vendor-react-B4AQeu28.js";import{q as jt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Xa,s as ea}from"./subjects-BGUwH4Kn.js";import{doc as Ga,getDoc as Za,where as ta,orderBy as pa,limit as Ct,getDocs as zt,query as It,collection as Bt}from"./vendor-firebase-firestore-CP9q7ISf.js";import{a4 as q,a5 as ha,a6 as ba,a7 as ze,a8 as Ka}from"./vendor-firebase-core-DCQrgkxC.js";import{B as A}from"./button-BqKfG4Jj.js";import{e as Ja,f as es}from"./vendor-radix-xDOIcVzp.js";import{S as Ne,a as ke,b as _e,c as Se,d as K}from"./select-B04HpeAZ.js";import{I as ts}from"./input-DEPoMoHZ.js";import{S as aa}from"./switch-CHYfNJFI.js";import{S as xe}from"./skeleton-Br1snihA.js";import{V as fa,a as ga,M as as,b as ss}from"./volume-x-R52lt03l.js";import{C as rs}from"./CompositeAvatar-Col05lJc.js";import{S as et}from"./sparkles-THbTTiEe.js";import{C as yt}from"./check-BLN5Dl8e.js";import{H as ns,C as sa}from"./history-CUgB1MuD.js";import{C as We}from"./chevron-right-bwYIKoxv.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-B4tQNTpN.js";import"./chevron-up-B_-cQcm8.js";import"./avatarData-BuQSOXo3.js";/** +import{e as xa,j as u,m as y,g as tt,aH as De,I as rt,aI as Q,V as Va,p as At,M as Ua,E as Te,U as ge,k as Ke,o as Je,u as Wa,_ as Ya,X as wt,a1 as vt,z as Kt,a0 as Jt}from"./index-B3ruOzo6.js";import{r as i,j as e,d as Ft}from"./vendor-react-B4AQeu28.js";import{q as jt}from"./quiz_battle_avatar-BXHPSput.js";import{g as Xa,s as ea}from"./subjects-DEj_AlYz.js";import{doc as Ga,getDoc as Za,where as ta,orderBy as pa,limit as Ct,getDocs as zt,query as It,collection as Bt}from"./vendor-firebase-firestore-CP9q7ISf.js";import{a4 as q,a5 as ha,a6 as ba,a7 as ze,a8 as Ka}from"./vendor-firebase-core-DCQrgkxC.js";import{B as A}from"./button-CaSK4KoS.js";import{e as Ja,f as es}from"./vendor-radix-BPuEd8FG.js";import{S as Ne,a as ke,b as _e,c as Se,d as K}from"./select-C142YWNr.js";import{I as ts}from"./input-kh84w1XK.js";import{S as aa}from"./switch-UwrfTEB3.js";import{H as as,S as xe,C as sa}from"./skeleton-B6L2gPDz.js";import{V as fa,a as ga,M as ss,b as rs}from"./volume-x-z-Eai_Ym.js";import{C as ns}from"./CompositeAvatar-Col05lJc.js";import{S as et}from"./sparkles-Bq0AaIRg.js";import{C as yt}from"./check-6eXlU5jr.js";import{C as We}from"./chevron-right-CbkkCalp.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chart-column-C9VTl-3A.js";import"./chevron-up-CTb5_AvY.js";import"./avatarData-BuQSOXo3.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. @@ -8,7 +8,7 @@ import{c as xa,k as u,m as y,h as tt,aF as De,I as rt,aG as Q,Q as Va,q as At,M * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ls=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],is=xa("pause",ls),Ye=({width:a,x:s,delay:n,duration:c})=>{const d=["#9956DE","#7274ED","#1FA7E1","#6ED1CF","#75D06A","#FFB356","#FF8B8B","#FB96BB"],l=d[Math.floor(Math.random()*d.length)],w=Math.floor(Math.random()*10)+1;return e.jsx(y.div,{style:{"--x":`${s}`,"--width":`${a}`,"--aspect-ratio":`${w}`,"--background":`linear-gradient(${l}cc, transparent)`},className:"absolute left-[var(--x)] top-0 [aspect-ratio:1/var(--aspect-ratio)] [background:var(--background)] [width:var(--width)]",initial:{y:"100cqmax",x:"-50%"},animate:{y:"-100%",x:"-50%"},transition:{duration:c,delay:n,repeat:Number.POSITIVE_INFINITY,ease:"linear"}})},na=({children:a,perspective:s=100,className:n,bgVideo:c,beamsPerSide:d=6,beamSize:l=4,beamDelayMax:w=1.5,beamDelayMin:z=0,beamDuration:g=4,gridColor:N="rgba(100, 116, 139, 0.08)",...b})=>{const j=i.useCallback(()=>{const S=[],W=Math.floor(100/l)/d;for(let ee=0;eej(),[j]),m=i.useMemo(()=>j(),[j]),v=i.useMemo(()=>j(),[j]),U=i.useMemo(()=>j(),[j]);return e.jsxs("div",{className:u("relative w-full h-full",n),...b,children:[c?e.jsx("video",{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"pointer-events-none absolute inset-0 w-full h-full object-cover -z-10",src:c}):e.jsxs("div",{style:{"--perspective":`${s}px`,"--grid-color":N,"--beam-size":`${l}%`},className:"pointer-events-none absolute inset-0 overflow-hidden [clip-path:inset(0)] [container-type:size] [perspective:var(--perspective)] [transform-style:preserve-3d] -z-10 bg-[#42389d]",children:[e.jsx("div",{className:"absolute [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]",children:h.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`top-${E}`))}),e.jsx("div",{className:"absolute top-full [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]",children:v.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`bottom-${E}`))}),e.jsx("div",{className:"absolute left-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:0%_0%] [transform:rotate(90deg)_rotateX(-90deg)] [width:100cqh]",children:U.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`left-${E}`))}),e.jsx("div",{className:"absolute right-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [width:100cqh] [transform-origin:100%_0%] [transform:rotate(-90deg)_rotateX(-90deg)]",children:m.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`right-${E}`))})]}),e.jsx("div",{className:"relative z-10 w-full h-full",children:a})]})},ds=15e3,cs="mathpulse.quizBattle.local",oa="".toLowerCase()==="true",nt=typeof window<"u",at=()=>nt&&!1,Et=()=>{const a=rt.currentUser?.uid;return a||"local-student"},wa=a=>`${cs}.${a}`,Pe=a=>{const s={stats:Ie(a),history:[],queueStatus:"idle"};if(!nt)return s;try{const n=window.localStorage.getItem(wa(a));if(!n)return s;const c=JSON.parse(n),d=Array.isArray(c.history)?c.history.map(w=>Mt(w.matchId||"local-match",w)):[];return{stats:c.stats?{...Ie(a),...c.stats,userId:a,updatedAt:st(c.stats.updatedAt)}:Ie(a),history:d,queueStatus:c.queueStatus==="queued"||c.queueStatus==="matched"?c.queueStatus:"idle"}}catch(n){return console.error("Error reading local Quiz Battle fallback store:",n),s}},va=(a,s)=>{if(nt)try{window.localStorage.setItem(wa(a),JSON.stringify(s))}catch(n){console.error("Error writing local Quiz Battle fallback store:",n)}},ja=a=>{const s=a||{},n=typeof s.code=="string"?s.code:"";return n?n.startsWith("functions/")?n.replace("functions/",""):n:""},oe=a=>{if(!at())return!1;const s=ja(a);if(["internal","not-found","unavailable","deadline-exceeded"].includes(s))return!0;const n=a||{},c=(typeof n.message=="string"?n.message:a instanceof Error?a.message:"").toLowerCase();return c?c.includes("cors policy")||c.includes("no access-control-allow-origin")||c.includes("failed to fetch")||c.includes("network error")||c.includes("err_failed"):!1},Xe=(a,s)=>Math.floor(Math.random()*(s-a+1))+a,us=(a,s)=>{const n=Math.max(3,a),c=s==="easy"?0:s==="medium"?1:s==="hard"?2:1,d=Xe(Math.max(0,n-3-c),n),l=Xe(Math.max(0,n-4+c),n),w=Math.min(n,Math.max(0,d)),z=Math.min(n,Math.max(0,l)),g=Math.max(0,Math.min(100,w/n*100+Xe(-8,6))),N=Xe(1800,6200);return{scoreFor:w,scoreAgainst:z,accuracy:g,averageResponseMs:N}},ms=a=>{const s=Et(),n=Pe(s),c=`local-bot-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,d=us(a.rounds,a.botDifficulty),l=d.scoreFor>d.scoreAgainst?"win":d.scoreFor0?m/h*100:0,averageAccuracy:h>0?(n.stats.averageAccuracy*n.stats.matchesPlayed+d.accuracy)/h:d.accuracy,averageResponseMs:h>0?Math.round((n.stats.averageResponseMs*n.stats.matchesPlayed+d.averageResponseMs)/h):d.averageResponseMs,currentStreak:S,bestStreak:E,favoriteTopicId:a.topicId,leaderboardScore:n.stats.leaderboardScore+j.xpEarned,updatedAt:w};return va(s,{stats:W,history:[j,...n.history].slice(0,50),queueStatus:"idle"}),{success:!0,matchId:c,status:"ready",botDifficulty:a.botDifficulty}},ya=a=>{const s=Et(),n=Pe(s);va(s,{...n,queueStatus:a})},xs=()=>Math.random().toString(36).slice(2,8).toUpperCase(),Rt=a=>{const s=Et();return{roomId:`local-room-${Date.now()}`,roomCode:a||xs(),ownerStudentId:s,participantIds:[s],participantCount:1,status:"waiting",subjectId:"gen-math",topicId:"functions",difficulty:"medium",rounds:5,timePerQuestionSec:30,isOwner:!0}},Na=()=>nt&&!!rt.currentUser?.uid&&!!De,ka=(a,s,n)=>`quizBattlePresence/${a}/${s}/${n}`,ps=async(a,s)=>{if(!Na()||!s.trim()||!De)return;const n=rt.currentUser?.uid;if(!n)return;const c=ha(De,ka(a,s,n));try{await ba(c,{studentId:n,scope:a,resourceId:s,online:!0,heartbeatAt:ze(),updatedAt:ze()}),await Ka(c).update({online:!1,updatedAt:ze(),disconnectedAt:ze()})}catch(d){console.warn("Realtime presence connect failed:",d)}},hs=async(a,s)=>{if(!Na()||!s.trim()||!De)return;const n=rt.currentUser?.uid;if(!n)return;const c=ha(De,ka(a,s,n));try{await ba(c,{studentId:n,scope:a,resourceId:s,online:!1,updatedAt:ze(),disconnectedAt:ze()})}catch(d){console.warn("Realtime presence disconnect failed:",d)}},O=(a,s)=>{const n=`Unable to continue while ${a}. Please try again.`;if(s instanceof Error&&s.message.startsWith("Timed out while"))return s.message;const c=s||{},d=ja(s),l=typeof c.message=="string"?c.message.trim():"";return d==="unauthenticated"?"Your session has expired. Sign in again before starting a battle.":d==="permission-denied"?"Only student accounts can access Quiz Battle matchmaking.":d==="invalid-argument"?l||"Battle setup is invalid. Review the selected options and try again.":d==="already-exists"?l||"This room is already full. Try another room code.":d==="failed-precondition"?l||"Battle state changed. Please refresh and continue.":d==="unavailable"||d==="internal"||d==="not-found"||d==="deadline-exceeded"?/question generation temporarily unavailable/i.test(l)?l:"Quiz Battle service is temporarily unavailable. Please retry in a moment.":n},L=async(a,s,n=ds)=>{let c;try{return await Promise.race([s,new Promise((d,l)=>{c=setTimeout(()=>{l(new Error(`Timed out while ${a}. Please try again.`))},n)})])}finally{c&&clearTimeout(c)}},st=a=>{if(!a)return new Date;if(a instanceof Date)return a;if(typeof a=="string"){const s=Date.parse(a);return Number.isNaN(s)?new Date:new Date(s)}if(typeof a=="number")return new Date(a);if(typeof a=="object"){const s=a;if(typeof s.toDate=="function")return s.toDate();if(typeof s.seconds=="number")return new Date(s.seconds*1e3)}return new Date},bs=()=>({mode:"online",subjectId:"gen-math",topicId:"",difficulty:"medium",rounds:5,timePerQuestionSec:30,queueType:"public_matchmaking",botDifficulty:"medium",adaptiveBot:!1}),fs=a=>{const s=[];return a.subjectId.trim()||s.push({field:"subjectId",message:"Choose a category before starting."}),a.topicId.trim()||s.push({field:"topicId",message:"Choose a strand or topic before starting."}),(a.rounds<3||a.rounds>20)&&s.push({field:"rounds",message:"Questions must be between 3 and 20."}),(a.timePerQuestionSec<10||a.timePerQuestionSec>180)&&s.push({field:"timePerQuestionSec",message:"Timer must be between 10s and 180s."}),a.mode==="bot"&&a.queueType!=="public_matchmaking"&&s.push({field:"queueType",message:"Bot battles use instant start and do not support private room mode."}),s},Ie=a=>({userId:a,matchesPlayed:0,wins:0,losses:0,draws:0,winRate:0,averageAccuracy:0,averageResponseMs:0,bestStreak:0,currentStreak:0,favoriteTopicId:void 0,leaderboardScore:0,updatedAt:new Date}),gs=async a=>{try{const s=Ga(tt,"studentBattleStats",a),n=await Za(s),c=at()?Pe(a).stats:null;if(!n.exists())return c&&c.matchesPlayed>0?c:Ie(a);const d=n.data(),l={...Ie(a),...d,userId:a,updatedAt:st(d.updatedAt)};return c&&c.matchesPlayed>l.matchesPlayed?c:l}catch(s){if(console.error("Error loading battle stats:",s),at()){const n=Pe(a).stats;if(n.matchesPlayed>0)return n}return Ie(a)}},Mt=(a,s)=>({matchId:s.matchId||a,mode:s.mode||"online",status:s.status||"completed",subjectId:s.subjectId||"gen-math",topicId:s.topicId||"unknown-topic",difficulty:s.difficulty||"medium",rounds:s.rounds||0,timePerQuestionSec:s.timePerQuestionSec||0,scoreFor:s.scoreFor||0,scoreAgainst:s.scoreAgainst||0,outcome:s.outcome||"draw",accuracy:s.accuracy||0,averageResponseMs:s.averageResponseMs||0,bestStreak:s.bestStreak||0,xpEarned:s.xpEarned||0,opponentName:s.opponentName||"Unknown opponent",opponentType:s.opponentType||"student",createdAt:st(s.createdAt),endedAt:st(s.endedAt)}),ws=async(a,s={})=>{const n=s.limitCount||25,c=at()?Pe(a).history:[],d=w=>w.filter(g=>!(s.mode&&s.mode!=="all"&&g.mode!==s.mode||s.subjectId&&g.subjectId!==s.subjectId||s.startDate&&g.endedAts.endDate)).sort((g,N)=>N.endedAt.getTime()-g.endedAt.getTime()).slice(0,n),l=w=>{if(c.length===0)return d(w);const z=new Map;return[...c,...w].forEach(g=>{z.set(g.matchId,g)}),d(Array.from(z.values()))};try{const w=[ta("studentId","==",a),pa("endedAt","desc"),Ct(n)],g=(await zt(It(Bt(tt,"quizBattleHistory"),...w))).docs.map(N=>Mt(N.id,N.data()));return l(g)}catch(w){try{const g=(await zt(It(Bt(tt,"quizBattleHistory"),ta("studentId","==",a),Ct(n)))).docs.map(N=>Mt(N.id,N.data())).sort((N,b)=>b.endedAt.getTime()-N.endedAt.getTime());return l(g)}catch(z){return console.error("Error loading battle history:",w,z),d(c)}}},vs=async a=>{const s=q(Q,"quizBattleJoinQueue");try{return(await L("joining Quiz Battle matchmaking queue",s({setup:a}))).data}catch(n){if(oe(n))return ya("queued"),{success:!0,status:"queued",queueEntryId:`local-queue-${Date.now()}`};throw new Error(O("joining Quiz Battle matchmaking queue",n))}},la=async()=>{const a=q(Q,"quizBattleLeaveQueue");try{return(await L("leaving Quiz Battle matchmaking queue",a({}))).data}catch(s){if(oe(s))return ya("idle"),{success:!0,status:"idle"};throw new Error(O("leaving Quiz Battle matchmaking queue",s))}},js=async a=>{const s=q(Q,"quizBattleCreatePrivateRoom");try{return(await L("creating Quiz Battle private room",s({setup:a}))).data}catch(n){if(oe(n))return{success:!0,room:Rt()};throw new Error(O("creating Quiz Battle private room",n))}},ys=async a=>{const s=q(Q,"quizBattleJoinPrivateRoom");try{return(await L("joining Quiz Battle private room",s({roomCode:a}),2e4)).data}catch(n){if(oe(n))return{success:!0,room:Rt(a.trim().toUpperCase()||void 0)};throw new Error(O("joining Quiz Battle private room",n))}},Ns=async a=>{const s=q(Q,"quizBattleGetPrivateRoomState");try{return(await L("loading Quiz Battle private room state",s(a),2e4)).data}catch(n){if(oe(n))return{success:!0,room:Rt(a.roomCode?.trim().toUpperCase()||void 0)};throw new Error(O("loading Quiz Battle private room state",n))}},ks=async(a={})=>{const s=q(Q,"quizBattleLeavePrivateRoom");try{return(await L("leaving Quiz Battle private room",s(a),2e4)).data}catch(n){if(oe(n))return{success:!0,status:"idle"};throw new Error(O("leaving Quiz Battle private room",n))}},ia=async()=>{const a=q(Q,"quizBattleResumeSession");try{return(await L("resuming Quiz Battle session",a({}),2e4)).data}catch(s){if(oe(s))return{success:!0,sessionType:"idle"};throw new Error(O("resuming Quiz Battle session",s))}},_s=async(a,s)=>{if(!s.trim())return;const n=q(Q,"quizBattleHeartbeat");await ps(a,s);try{await L("sending Quiz Battle heartbeat",n({scope:a,resourceId:s}),12e3)}catch(c){if(!oe(c))throw new Error(O("sending Quiz Battle heartbeat",c))}},Ss=async a=>{const s=q(Q,"quizBattleCreateBotMatch");try{return(await L("starting Quiz Battle bot match",s({setup:a}))).data}catch(n){if(oe(n))return ms(a);throw new Error(O("starting Quiz Battle bot match",n))}},As=async a=>{const s=q(Q,"quizBattleGetGenerationAudit");return(await L("verifying Quiz Battle generation metadata",s({matchId:a}),2e4)).data},ne=async a=>{const s=q(Q,"quizBattleStartMatch");try{const c=(await L("starting Quiz Battle match",s({matchId:a}),2e4)).data.match;if(c.mode==="online")try{const d=await As(a);if(oa&&!d.isAiSource)throw new Error(`Quiz Battle generation audit failed: expected AI source, got "${d.questionSetSource||"unknown"}".`)}catch(d){if(d instanceof Error&&d.message.startsWith("Quiz Battle generation audit failed"))throw d;if(console.warn("Quiz Battle generation audit unavailable:",d),oa)throw new Error("Unable to verify Quiz Battle generation metadata. Please retry in a moment.")}return c}catch(n){throw new Error(O("starting Quiz Battle match",n))}},Nt=async a=>{const s=q(Q,"quizBattleGetMatchState");try{return(await L("loading Quiz Battle match state",s({matchId:a}),2e4)).data.match}catch(n){throw new Error(O("loading Quiz Battle match state",n))}},Cs=async a=>{const s=q(Q,"quizBattleSubmitAnswer");try{return(await L("submitting Quiz Battle answer",s({...a,idempotencyKey:a.idempotencyKey||`client-${Date.now()}-${Math.random().toString(16).slice(2,8)}`}),2e4)).data}catch(n){throw new Error(O("submitting Quiz Battle answer",n))}},zs=async a=>{const s=q(Q,"quizBattleRequestRematch");try{return(await L("creating Quiz Battle rematch",s({matchId:a}),2e4)).data}catch(n){throw new Error(O("creating Quiz Battle rematch",n))}},Is=async(a=20)=>{try{const s=It(Bt(tt,"studentBattleLeaderboard"),pa("leaderboardScore","desc"),Ct(a));return(await zt(s)).docs.map((c,d)=>{const l=c.data();return{userId:l.userId||c.id,displayName:l.displayName||"Student",photo:l.photo,rank:l.rank||d+1,leaderboardScore:l.leaderboardScore||0,winRate:l.winRate||0,bestStreak:l.bestStreak||0}})}catch(s){return console.error("Error loading Quiz Battle leaderboard:",s),[]}};function pe({className:a,...s}){return e.jsx("div",{"data-slot":"card",className:u("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",a),...s})}function he({className:a,...s}){return e.jsx("div",{"data-slot":"card-header",className:u("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function be({className:a,...s}){return e.jsx("h4",{"data-slot":"card-title",className:u("leading-none",a),...s})}function Ae({className:a,...s}){return e.jsx("p",{"data-slot":"card-description",className:u("text-muted-foreground",a),...s})}function Ge({className:a,...s}){return e.jsx("div",{"data-slot":"card-content",className:u("px-6 [&:last-child]:pb-6",a),...s})}function Bs({className:a,...s}){return e.jsx(Ja,{"data-slot":"tabs",className:u("flex flex-col gap-2",a),...s})}function Ce({className:a,...s}){return e.jsx(es,{"data-slot":"tabs-content",className:u("flex-1 outline-none",a),...s})}const _a=Ft.memo(({playerRoundStreak:a,playerVisualMultiplier:s,liveXpEarned:n,activeMatch:c,subjects:d,battleSoundEnabled:l,onToggleSound:w,isFullscreen:z,onToggleFullscreen:g,isDesignPauseAvailable:N,onTogglePause:b})=>e.jsxs("header",{className:"flex items-center justify-between shrink-0 h-16 relative gap-4",children:[e.jsx("div",{className:"flex items-center min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3 md:gap-4 px-4 py-2 md:px-5 md:py-2.5 rounded-full bg-white/5 border border-white/10 backdrop-blur-md min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400 font-bold text-sm shrink-0",children:[e.jsx(Va,{className:"w-4 h-4"})," ",a]}),e.jsx("div",{className:"w-px h-4 bg-white/10 shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-violet-300 font-bold text-sm shrink-0",children:[e.jsx(At,{className:"w-4 h-4"})," ",s.toFixed(2),"x"]}),e.jsx("div",{className:"w-px h-4 bg-white/10 shrink-0"}),e.jsxs(y.div,{animate:n>0?{scale:[1,1.25,1]}:{},transition:{duration:.35},className:"flex flex-col items-center text-emerald-400 bg-emerald-500/10 px-3 py-0.5 rounded-full border border-emerald-500/20 font-bold shadow-[0_0_10px_rgba(16,185,129,0.15)] shrink-0",children:[e.jsxs("span",{className:"text-sm leading-none tabular-nums",children:[n," pts"]}),e.jsx("span",{className:"text-[8px] leading-none text-emerald-500/70 uppercase tracking-widest font-black whitespace-nowrap",children:"Battle Score"})]},n)]})}),e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 hidden md:flex items-center gap-3 bg-black/20 px-5 py-2 rounded-full border border-white/5 min-w-0 max-w-[48%]",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-sm bg-orange-400 shadow-[0_0_10px_rgba(251,146,60,0.5)] shrink-0"}),e.jsx("div",{className:"flex flex-col items-start justify-center -space-y-0.5 min-w-0",children:(()=>{if(!c?.topicId)return e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none truncate",children:"Practice Match"});for(const j of d){const h=j.modules?.find(m=>m.id===c.topicId);if(h)return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[9px] font-black text-white/40 uppercase tracking-widest leading-none",children:j.title}),e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none pt-1 truncate",children:h.title})]})}return e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none truncate",children:c.topicId.split("-").map(j=>j.charAt(0).toUpperCase()+j.slice(1)).join(" ")})})()})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"outline",size:"icon",className:"h-12 w-12 rounded-full border-white/20 bg-black/20 hover:bg-white/10 text-white",onClick:w,children:l?e.jsx(fa,{className:"h-5 w-5"}):e.jsx(ga,{className:"h-5 w-5"})}),e.jsx(A,{variant:"outline",size:"icon",className:"h-12 w-12 rounded-full border-white/20 bg-black/20 hover:bg-white/10 text-white",onClick:g,children:z?e.jsx(as,{className:"h-5 w-5"}):e.jsx(ss,{className:"h-5 w-5"})}),e.jsx(A,{variant:"outline",size:"icon",className:u("h-12 w-12 rounded-full border-white/20 text-white",N?"bg-black/20 hover:bg-white/10":"bg-black/10 opacity-50 cursor-not-allowed"),onClick:b,disabled:!N,children:e.jsx(Ua,{className:"h-5 w-5"})})]})]}));_a.displayName="BattleHeader";const Sa=Ft.memo(({studentProfile:a,activeMatch:s,scorePulseTarget:n,quizBattleAvatar:c})=>e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 w-full xl:max-w-[1400px] mx-auto px-4 md:px-8 shrink-0 h-32 md:h-48 flex justify-between items-end pb-0 pointer-events-none z-30",children:[e.jsxs("div",{className:"flex items-end gap-3 sm:gap-6 relative pointer-events-auto",children:[e.jsx("div",{className:"relative w-28 h-28 md:w-40 md:h-40 rounded-t-[40px] flex items-end",children:e.jsx(rs,{layers:a?.avatarLayers||{},className:"w-full h-full object-contain origin-bottom scale-[1.15]"})}),e.jsxs("div",{className:"bg-black/40 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 md:px-5 shadow-[0_8px_30px_rgba(0,0,0,0.5)] flex items-center gap-3 md:gap-4 mb-4 max-w-[220px] md:max-w-[280px]",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-white font-black text-base md:text-lg truncate tracking-wide",children:a?.name||"Player"}),e.jsxs("span",{className:"text-xs md:text-sm text-white/50 font-bold uppercase tracking-wider",children:["Level ",a?.level||1]})]}),e.jsx("div",{className:"h-10 w-px bg-white/20"}),e.jsxs("div",{className:"flex flex-col items-center justify-center shrink-0 w-10 md:w-12",children:[e.jsx(y.span,{animate:n==="player"?{scale:[1,1.4,1],color:["#fff","#34d399","#fff"]}:{},transition:{duration:.5},className:"text-2xl md:text-3xl font-black text-white leading-none",children:s.scoreFor}),e.jsx("span",{className:"text-[9px] md:text-[10px] text-emerald-400 font-bold uppercase tracking-widest mt-1 leading-none",children:"Score"})]})]})]}),e.jsxs("div",{className:"flex items-end gap-3 sm:gap-6 relative flex-row-reverse pointer-events-auto",children:[e.jsx("div",{className:"relative w-28 h-28 md:w-40 md:h-40 bg-[#1a2030] rounded-t-[40px] flex items-end justify-center border-t-4 border-slate-700/50 shadow-inner",children:s.mode==="bot"?e.jsx(Te,{className:"h-16 w-16 md:h-20 md:w-20 text-rose-400 mb-6 drop-shadow-xl",strokeWidth:1.5}):e.jsx(ge,{className:"h-16 w-16 md:h-20 md:w-20 text-slate-500 mb-6 drop-shadow-xl",strokeWidth:1.5})}),e.jsxs("div",{className:"bg-black/40 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 md:px-5 shadow-[0_8px_30px_rgba(0,0,0,0.5)] flex items-center gap-3 md:gap-4 mb-4 flex-row-reverse text-right max-w-[220px] md:max-w-[280px]",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-white font-black text-base md:text-lg truncate tracking-wide",children:s.opponentName||"Anonymous"}),e.jsx("span",{className:"text-xs md:text-sm text-rose-400 font-bold uppercase tracking-wider",children:s.mode==="bot"?"System Bot":"Challenger"})]}),e.jsx("div",{className:"h-10 w-px bg-white/20"}),e.jsxs("div",{className:"flex flex-col items-center justify-center shrink-0 w-10 md:w-12",children:[e.jsx(y.span,{animate:n==="opponent"?{scale:[1,1.4,1],color:["#fff","#fb7185","#fff"]}:{},transition:{duration:.5},className:"text-2xl md:text-3xl font-black text-white leading-none",children:s.scoreAgainst}),e.jsx("span",{className:"text-[9px] md:text-[10px] text-rose-400 font-bold uppercase tracking-widest mt-1 leading-none",children:"Score"})]})]})]})]}));Sa.displayName="BattleFooter";const Aa=Ft.memo(({activeMatch:a,roundSecondsLeft:s,lastRoundResult:n,selectedOptionIndex:c,roundLocked:d,answerSubmitting:l,designPauseActive:w,onOptionSelect:z,floatingMomentum:g,lastRoundMomentumDelta:N,studentProfile:b,quizBattleAvatar:j})=>e.jsxs("div",{className:"flex-1 flex flex-col justify-center items-center gap-4 md:gap-6 w-full min-h-0 overflow-y-auto pt-4 pb-28 z-20 no-scrollbar",children:[e.jsxs("div",{className:u("relative bg-[#1e2536] border shadow-[0_20px_60px_rgba(0,0,0,0.4)] rounded-[1.5rem] p-5 md:p-6 w-full max-w-4xl text-center flex flex-col items-center",s<=3?"border-rose-400/50":"border-white/10"),children:[e.jsxs("div",{className:"absolute -top-3.5 bg-[#2f3547] border border-white/10 text-white/80 px-4 py-1 rounded-full text-xs font-black shadow-lg uppercase tracking-wider",children:[a.currentRound," / ",a.totalRounds]}),e.jsx(Ke,{children:g&&g.tone==="positive"&&e.jsx(y.div,{initial:{opacity:0,y:14,scale:.92},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.9},className:u("absolute -top-12 rounded-full border px-3 py-1 text-[10px] font-black uppercase tracking-[0.15em] backdrop-blur-lg",g.tone==="positive"?"border-emerald-300/70 bg-emerald-500/20 text-emerald-100":g.tone==="negative"?"border-rose-300/70 bg-rose-500/20 text-rose-100":"border-slate-300/50 bg-slate-500/20 text-slate-100"),children:g.label},g.id)}),e.jsx("p",{className:"text-base sm:text-lg md:text-xl text-white font-extrabold leading-tight tracking-tight mt-1 min-h-[40px] flex items-center justify-center",children:a.currentQuestion?.prompt}),typeof window<"u"&&window.location.search.includes("debug=true")&&a.currentQuestion?.varianceApplied&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2 justify-center",children:a.currentQuestion.varianceApplied.map(h=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-blue-500/20 text-blue-200 border border-blue-400/30",children:h.replace(/_/g," ")},h))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 md:gap-4 w-full max-w-4xl px-4",children:a.currentQuestion?.choices.map((h,m)=>{const v=c===m,U=l||d,S=!!n&&n.roundNumber===a.currentRound,E=S&&n.correctOptionIndex===m;let W=-1;if(S)if(a.mode==="bot")if(n.botCorrect)W=n.correctOptionIndex;else{const H=[0,1,2,3].filter(C=>C!==n.correctOptionIndex);W=H[n.roundNumber%H.length]}else W=typeof n.botSelectedIndex=="number"?n.botSelectedIndex:-1;const ee=W===m;let T="bg-[#1e2433] hover:bg-[#283042] border-[#2f384e] text-white shadow-[0_6px_0_rgba(15,20,30,0.5)]";return S?E?T="bg-emerald-500 text-emerald-950 border-emerald-400 shadow-[0_6px_0_rgba(5,150,105,1)]":v?T="bg-rose-500 text-white border-rose-400 shadow-[0_6px_0_rgba(225,29,72,1)]":T="bg-[#1e2433] opacity-40 border-[#2f384e] shadow-[0_6px_0_rgba(15,20,30,0.5)] text-white":v&&(T="bg-indigo-500 text-white border-indigo-400 shadow-[0_6px_0_rgba(79,70,229,1)]"),e.jsxs(y.button,{whileTap:{y:8,scale:.98},whileHover:!S&&!U?{scale:1.02}:{},disabled:U||d||w,onClick:()=>z(m),className:u("relative h-16 md:h-20 rounded-2xl md:rounded-3xl font-black text-base md:text-lg pl-6 pr-20 border-[2px] border-b-[4px] flex items-center justify-start text-left transition-all disabled:cursor-not-allowed",T,v&&!S?"ring-[4px] ring-white/20 ring-offset-[4px] ring-offset-[#0B0F19]":"",s<=3&&!U&&!S?"shadow-[0_0_0_2px_rgba(251,113,133,0.45),0_6px_0_rgba(127,29,29,1)]":""),children:[e.jsx("span",{className:"mr-3 md:mr-4 text-xs md:text-sm opacity-60 bg-black/20 px-3 py-1 rounded-full",children:String.fromCharCode(65+m)}),e.jsx("span",{className:"line-clamp-2",children:h}),e.jsxs("div",{className:"absolute right-3 md:right-4 flex items-center gap-1.5 md:gap-2",children:[ee&&e.jsx(y.div,{initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},className:"w-8 h-8 md:w-10 md:h-10 rounded-full border-[3px] border-[#0B0F19] overflow-hidden bg-rose-500 shadow-lg flex items-center justify-center z-10",children:a.mode==="bot"?e.jsx(Te,{className:"w-4 h-4 md:w-5 md:h-5 text-white"}):e.jsx(ge,{className:"w-4 h-4 md:w-5 md:h-5 text-white"})}),v&&e.jsx(y.div,{initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},className:"w-8 h-8 md:w-10 md:h-10 rounded-full border-[3px] border-[#0B0F19] overflow-hidden bg-indigo-200 shadow-lg z-20",children:e.jsx("img",{src:b?.photo||j,alt:"You",className:"w-full h-full object-cover"})})]})]},m)})}),e.jsx(Ke,{children:d&&!n&&a.mode==="online"&&e.jsxs(y.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/70 font-semibold bg-black/30 px-6 py-2 rounded-full border border-white/10",children:[e.jsx(Je,{className:"w-4 h-4 animate-spin text-amber-400"}),"Waiting for opponent..."]}),e.jsx("p",{className:"text-white/30 text-[11px] mt-1",children:"Choices locked until round resolves"})]})}),e.jsx(Ke,{children:n?.studentCorrect&&e.jsx(y.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[100] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-[#1e2433]/95 backdrop-blur-xl border border-white/10 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.6)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:j,alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-xl"}),e.jsx("h2",{className:u("text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest",n.studentCorrect?"text-emerald-400":"text-rose-400"),children:n.studentCorrect?"Correct!":"Incorrect"}),n.studentCorrect?e.jsxs("div",{className:"flex items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-2xl font-bold border border-emerald-500/30",children:e.jsx("span",{children:"+ 10 XP"})}),N!==null&&N>0&&e.jsx("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-2 rounded-2xl font-bold border border-amber-500/30",children:e.jsxs("span",{children:["+ ",N," ",e.jsx(et,{className:"w-4 h-4 inline"})]})})]}):e.jsxs("div",{className:"bg-rose-500/20 border border-rose-500/30 text-rose-400 font-bold px-5 py-2 rounded-xl text-center",children:["Correct: ",String.fromCharCode(65+n.correctOptionIndex)]})]})})})]}));Aa.displayName="BattleActiveContent";const kt={width:1280,height:720},_t=` + */const ls=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],is=xa("pause",ls),Ye=({width:a,x:s,delay:n,duration:c})=>{const d=["#9956DE","#7274ED","#1FA7E1","#6ED1CF","#75D06A","#FFB356","#FF8B8B","#FB96BB"],l=d[Math.floor(Math.random()*d.length)],w=Math.floor(Math.random()*10)+1;return e.jsx(y.div,{style:{"--x":`${s}`,"--width":`${a}`,"--aspect-ratio":`${w}`,"--background":`linear-gradient(${l}cc, transparent)`},className:"absolute left-[var(--x)] top-0 [aspect-ratio:1/var(--aspect-ratio)] [background:var(--background)] [width:var(--width)]",initial:{y:"100cqmax",x:"-50%"},animate:{y:"-100%",x:"-50%"},transition:{duration:c,delay:n,repeat:Number.POSITIVE_INFINITY,ease:"linear"}})},na=({children:a,perspective:s=100,className:n,bgVideo:c,beamsPerSide:d=6,beamSize:l=4,beamDelayMax:w=1.5,beamDelayMin:z=0,beamDuration:g=4,gridColor:N="rgba(100, 116, 139, 0.08)",...b})=>{const j=i.useCallback(()=>{const S=[],W=Math.floor(100/l)/d;for(let ee=0;eej(),[j]),m=i.useMemo(()=>j(),[j]),v=i.useMemo(()=>j(),[j]),U=i.useMemo(()=>j(),[j]);return e.jsxs("div",{className:u("relative w-full h-full",n),...b,children:[c?e.jsx("video",{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"pointer-events-none absolute inset-0 w-full h-full object-cover -z-10",src:c}):e.jsxs("div",{style:{"--perspective":`${s}px`,"--grid-color":N,"--beam-size":`${l}%`},className:"pointer-events-none absolute inset-0 overflow-hidden [clip-path:inset(0)] [container-type:size] [perspective:var(--perspective)] [transform-style:preserve-3d] -z-10 bg-[#42389d]",children:[e.jsx("div",{className:"absolute [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]",children:h.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`top-${E}`))}),e.jsx("div",{className:"absolute top-full [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]",children:v.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`bottom-${E}`))}),e.jsx("div",{className:"absolute left-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:0%_0%] [transform:rotate(90deg)_rotateX(-90deg)] [width:100cqh]",children:U.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`left-${E}`))}),e.jsx("div",{className:"absolute right-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [width:100cqh] [transform-origin:100%_0%] [transform:rotate(-90deg)_rotateX(-90deg)]",children:m.map((S,E)=>e.jsx(Ye,{width:`${l}%`,x:`${S.x*l}%`,delay:S.delay,duration:g},`right-${E}`))})]}),e.jsx("div",{className:"relative z-10 w-full h-full",children:a})]})},ds=15e3,cs="mathpulse.quizBattle.local",oa="".toLowerCase()==="true",nt=typeof window<"u",at=()=>nt&&!1,Et=()=>{const a=rt.currentUser?.uid;return a||"local-student"},wa=a=>`${cs}.${a}`,Pe=a=>{const s={stats:Ie(a),history:[],queueStatus:"idle"};if(!nt)return s;try{const n=window.localStorage.getItem(wa(a));if(!n)return s;const c=JSON.parse(n),d=Array.isArray(c.history)?c.history.map(w=>Mt(w.matchId||"local-match",w)):[];return{stats:c.stats?{...Ie(a),...c.stats,userId:a,updatedAt:st(c.stats.updatedAt)}:Ie(a),history:d,queueStatus:c.queueStatus==="queued"||c.queueStatus==="matched"?c.queueStatus:"idle"}}catch(n){return console.error("Error reading local Quiz Battle fallback store:",n),s}},va=(a,s)=>{if(nt)try{window.localStorage.setItem(wa(a),JSON.stringify(s))}catch(n){console.error("Error writing local Quiz Battle fallback store:",n)}},ja=a=>{const s=a||{},n=typeof s.code=="string"?s.code:"";return n?n.startsWith("functions/")?n.replace("functions/",""):n:""},oe=a=>{if(!at())return!1;const s=ja(a);if(["internal","not-found","unavailable","deadline-exceeded"].includes(s))return!0;const n=a||{},c=(typeof n.message=="string"?n.message:a instanceof Error?a.message:"").toLowerCase();return c?c.includes("cors policy")||c.includes("no access-control-allow-origin")||c.includes("failed to fetch")||c.includes("network error")||c.includes("err_failed"):!1},Xe=(a,s)=>Math.floor(Math.random()*(s-a+1))+a,us=(a,s)=>{const n=Math.max(3,a),c=s==="easy"?0:s==="medium"?1:s==="hard"?2:1,d=Xe(Math.max(0,n-3-c),n),l=Xe(Math.max(0,n-4+c),n),w=Math.min(n,Math.max(0,d)),z=Math.min(n,Math.max(0,l)),g=Math.max(0,Math.min(100,w/n*100+Xe(-8,6))),N=Xe(1800,6200);return{scoreFor:w,scoreAgainst:z,accuracy:g,averageResponseMs:N}},ms=a=>{const s=Et(),n=Pe(s),c=`local-bot-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,d=us(a.rounds,a.botDifficulty),l=d.scoreFor>d.scoreAgainst?"win":d.scoreFor0?m/h*100:0,averageAccuracy:h>0?(n.stats.averageAccuracy*n.stats.matchesPlayed+d.accuracy)/h:d.accuracy,averageResponseMs:h>0?Math.round((n.stats.averageResponseMs*n.stats.matchesPlayed+d.averageResponseMs)/h):d.averageResponseMs,currentStreak:S,bestStreak:E,favoriteTopicId:a.topicId,leaderboardScore:n.stats.leaderboardScore+j.xpEarned,updatedAt:w};return va(s,{stats:W,history:[j,...n.history].slice(0,50),queueStatus:"idle"}),{success:!0,matchId:c,status:"ready",botDifficulty:a.botDifficulty}},ya=a=>{const s=Et(),n=Pe(s);va(s,{...n,queueStatus:a})},xs=()=>Math.random().toString(36).slice(2,8).toUpperCase(),Rt=a=>{const s=Et();return{roomId:`local-room-${Date.now()}`,roomCode:a||xs(),ownerStudentId:s,participantIds:[s],participantCount:1,status:"waiting",subjectId:"gen-math",topicId:"functions",difficulty:"medium",rounds:5,timePerQuestionSec:30,isOwner:!0}},Na=()=>nt&&!!rt.currentUser?.uid&&!!De,ka=(a,s,n)=>`quizBattlePresence/${a}/${s}/${n}`,ps=async(a,s)=>{if(!Na()||!s.trim()||!De)return;const n=rt.currentUser?.uid;if(!n)return;const c=ha(De,ka(a,s,n));try{await ba(c,{studentId:n,scope:a,resourceId:s,online:!0,heartbeatAt:ze(),updatedAt:ze()}),await Ka(c).update({online:!1,updatedAt:ze(),disconnectedAt:ze()})}catch(d){console.warn("Realtime presence connect failed:",d)}},hs=async(a,s)=>{if(!Na()||!s.trim()||!De)return;const n=rt.currentUser?.uid;if(!n)return;const c=ha(De,ka(a,s,n));try{await ba(c,{studentId:n,scope:a,resourceId:s,online:!1,updatedAt:ze(),disconnectedAt:ze()})}catch(d){console.warn("Realtime presence disconnect failed:",d)}},H=(a,s)=>{const n=`Unable to continue while ${a}. Please try again.`;if(s instanceof Error&&s.message.startsWith("Timed out while"))return s.message;const c=s||{},d=ja(s),l=typeof c.message=="string"?c.message.trim():"";return d==="unauthenticated"?"Your session has expired. Sign in again before starting a battle.":d==="permission-denied"?"Only student accounts can access Quiz Battle matchmaking.":d==="invalid-argument"?l||"Battle setup is invalid. Review the selected options and try again.":d==="already-exists"?l||"This room is already full. Try another room code.":d==="failed-precondition"?l||"Battle state changed. Please refresh and continue.":d==="unavailable"||d==="internal"||d==="not-found"||d==="deadline-exceeded"?/question generation temporarily unavailable/i.test(l)?l:"Quiz Battle service is temporarily unavailable. Please retry in a moment.":n},L=async(a,s,n=ds)=>{let c;try{return await Promise.race([s,new Promise((d,l)=>{c=setTimeout(()=>{l(new Error(`Timed out while ${a}. Please try again.`))},n)})])}finally{c&&clearTimeout(c)}},st=a=>{if(!a)return new Date;if(a instanceof Date)return a;if(typeof a=="string"){const s=Date.parse(a);return Number.isNaN(s)?new Date:new Date(s)}if(typeof a=="number")return new Date(a);if(typeof a=="object"){const s=a;if(typeof s.toDate=="function")return s.toDate();if(typeof s.seconds=="number")return new Date(s.seconds*1e3)}return new Date},bs=()=>({mode:"online",subjectId:"gen-math",topicId:"",difficulty:"medium",rounds:5,timePerQuestionSec:30,queueType:"public_matchmaking",botDifficulty:"medium",adaptiveBot:!1}),fs=a=>{const s=[];return a.subjectId.trim()||s.push({field:"subjectId",message:"Choose a category before starting."}),a.topicId.trim()||s.push({field:"topicId",message:"Choose a strand or topic before starting."}),(a.rounds<3||a.rounds>20)&&s.push({field:"rounds",message:"Questions must be between 3 and 20."}),(a.timePerQuestionSec<10||a.timePerQuestionSec>180)&&s.push({field:"timePerQuestionSec",message:"Timer must be between 10s and 180s."}),a.mode==="bot"&&a.queueType!=="public_matchmaking"&&s.push({field:"queueType",message:"Bot battles use instant start and do not support private room mode."}),s},Ie=a=>({userId:a,matchesPlayed:0,wins:0,losses:0,draws:0,winRate:0,averageAccuracy:0,averageResponseMs:0,bestStreak:0,currentStreak:0,favoriteTopicId:void 0,leaderboardScore:0,updatedAt:new Date}),gs=async a=>{try{const s=Ga(tt,"studentBattleStats",a),n=await Za(s),c=at()?Pe(a).stats:null;if(!n.exists())return c&&c.matchesPlayed>0?c:Ie(a);const d=n.data(),l={...Ie(a),...d,userId:a,updatedAt:st(d.updatedAt)};return c&&c.matchesPlayed>l.matchesPlayed?c:l}catch(s){if(console.error("Error loading battle stats:",s),at()){const n=Pe(a).stats;if(n.matchesPlayed>0)return n}return Ie(a)}},Mt=(a,s)=>({matchId:s.matchId||a,mode:s.mode||"online",status:s.status||"completed",subjectId:s.subjectId||"gen-math",topicId:s.topicId||"unknown-topic",difficulty:s.difficulty||"medium",rounds:s.rounds||0,timePerQuestionSec:s.timePerQuestionSec||0,scoreFor:s.scoreFor||0,scoreAgainst:s.scoreAgainst||0,outcome:s.outcome||"draw",accuracy:s.accuracy||0,averageResponseMs:s.averageResponseMs||0,bestStreak:s.bestStreak||0,xpEarned:s.xpEarned||0,opponentName:s.opponentName||"Unknown opponent",opponentType:s.opponentType||"student",createdAt:st(s.createdAt),endedAt:st(s.endedAt)}),ws=async(a,s={})=>{const n=s.limitCount||25,c=at()?Pe(a).history:[],d=w=>w.filter(g=>!(s.mode&&s.mode!=="all"&&g.mode!==s.mode||s.subjectId&&g.subjectId!==s.subjectId||s.startDate&&g.endedAts.endDate)).sort((g,N)=>N.endedAt.getTime()-g.endedAt.getTime()).slice(0,n),l=w=>{if(c.length===0)return d(w);const z=new Map;return[...c,...w].forEach(g=>{z.set(g.matchId,g)}),d(Array.from(z.values()))};try{const w=[ta("studentId","==",a),pa("endedAt","desc"),Ct(n)],g=(await zt(It(Bt(tt,"quizBattleHistory"),...w))).docs.map(N=>Mt(N.id,N.data()));return l(g)}catch(w){try{const g=(await zt(It(Bt(tt,"quizBattleHistory"),ta("studentId","==",a),Ct(n)))).docs.map(N=>Mt(N.id,N.data())).sort((N,b)=>b.endedAt.getTime()-N.endedAt.getTime());return l(g)}catch(z){return console.error("Error loading battle history:",w,z),d(c)}}},vs=async a=>{const s=q(Q,"quizBattleJoinQueue");try{return(await L("joining Quiz Battle matchmaking queue",s({setup:a}))).data}catch(n){if(oe(n))return ya("queued"),{success:!0,status:"queued",queueEntryId:`local-queue-${Date.now()}`};throw new Error(H("joining Quiz Battle matchmaking queue",n))}},la=async()=>{const a=q(Q,"quizBattleLeaveQueue");try{return(await L("leaving Quiz Battle matchmaking queue",a({}))).data}catch(s){if(oe(s))return ya("idle"),{success:!0,status:"idle"};throw new Error(H("leaving Quiz Battle matchmaking queue",s))}},js=async a=>{const s=q(Q,"quizBattleCreatePrivateRoom");try{return(await L("creating Quiz Battle private room",s({setup:a}))).data}catch(n){if(oe(n))return{success:!0,room:Rt()};throw new Error(H("creating Quiz Battle private room",n))}},ys=async a=>{const s=q(Q,"quizBattleJoinPrivateRoom");try{return(await L("joining Quiz Battle private room",s({roomCode:a}),2e4)).data}catch(n){if(oe(n))return{success:!0,room:Rt(a.trim().toUpperCase()||void 0)};throw new Error(H("joining Quiz Battle private room",n))}},Ns=async a=>{const s=q(Q,"quizBattleGetPrivateRoomState");try{return(await L("loading Quiz Battle private room state",s(a),2e4)).data}catch(n){if(oe(n))return{success:!0,room:Rt(a.roomCode?.trim().toUpperCase()||void 0)};throw new Error(H("loading Quiz Battle private room state",n))}},ks=async(a={})=>{const s=q(Q,"quizBattleLeavePrivateRoom");try{return(await L("leaving Quiz Battle private room",s(a),2e4)).data}catch(n){if(oe(n))return{success:!0,status:"idle"};throw new Error(H("leaving Quiz Battle private room",n))}},ia=async()=>{const a=q(Q,"quizBattleResumeSession");try{return(await L("resuming Quiz Battle session",a({}),2e4)).data}catch(s){if(oe(s))return{success:!0,sessionType:"idle"};throw new Error(H("resuming Quiz Battle session",s))}},_s=async(a,s)=>{if(!s.trim())return;const n=q(Q,"quizBattleHeartbeat");await ps(a,s);try{await L("sending Quiz Battle heartbeat",n({scope:a,resourceId:s}),12e3)}catch(c){if(!oe(c))throw new Error(H("sending Quiz Battle heartbeat",c))}},Ss=async a=>{const s=q(Q,"quizBattleCreateBotMatch");try{return(await L("starting Quiz Battle bot match",s({setup:a}))).data}catch(n){if(oe(n))return ms(a);throw new Error(H("starting Quiz Battle bot match",n))}},As=async a=>{const s=q(Q,"quizBattleGetGenerationAudit");return(await L("verifying Quiz Battle generation metadata",s({matchId:a}),2e4)).data},ne=async a=>{const s=q(Q,"quizBattleStartMatch");try{const c=(await L("starting Quiz Battle match",s({matchId:a}),2e4)).data.match;if(c.mode==="online")try{const d=await As(a);if(oa&&!d.isAiSource)throw new Error(`Quiz Battle generation audit failed: expected AI source, got "${d.questionSetSource||"unknown"}".`)}catch(d){if(d instanceof Error&&d.message.startsWith("Quiz Battle generation audit failed"))throw d;if(console.warn("Quiz Battle generation audit unavailable:",d),oa)throw new Error("Unable to verify Quiz Battle generation metadata. Please retry in a moment.")}return c}catch(n){throw new Error(H("starting Quiz Battle match",n))}},Nt=async a=>{const s=q(Q,"quizBattleGetMatchState");try{return(await L("loading Quiz Battle match state",s({matchId:a}),2e4)).data.match}catch(n){throw new Error(H("loading Quiz Battle match state",n))}},Cs=async a=>{const s=q(Q,"quizBattleSubmitAnswer");try{return(await L("submitting Quiz Battle answer",s({...a,idempotencyKey:a.idempotencyKey||`client-${Date.now()}-${Math.random().toString(16).slice(2,8)}`}),2e4)).data}catch(n){throw new Error(H("submitting Quiz Battle answer",n))}},zs=async a=>{const s=q(Q,"quizBattleRequestRematch");try{return(await L("creating Quiz Battle rematch",s({matchId:a}),2e4)).data}catch(n){throw new Error(H("creating Quiz Battle rematch",n))}},Is=async(a=20)=>{try{const s=It(Bt(tt,"studentBattleLeaderboard"),pa("leaderboardScore","desc"),Ct(a));return(await zt(s)).docs.map((c,d)=>{const l=c.data();return{userId:l.userId||c.id,displayName:l.displayName||"Student",photo:l.photo,rank:l.rank||d+1,leaderboardScore:l.leaderboardScore||0,winRate:l.winRate||0,bestStreak:l.bestStreak||0}})}catch(s){return console.error("Error loading Quiz Battle leaderboard:",s),[]}};function pe({className:a,...s}){return e.jsx("div",{"data-slot":"card",className:u("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",a),...s})}function he({className:a,...s}){return e.jsx("div",{"data-slot":"card-header",className:u("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function be({className:a,...s}){return e.jsx("h4",{"data-slot":"card-title",className:u("leading-none",a),...s})}function Ae({className:a,...s}){return e.jsx("p",{"data-slot":"card-description",className:u("text-muted-foreground",a),...s})}function Ge({className:a,...s}){return e.jsx("div",{"data-slot":"card-content",className:u("px-6 [&:last-child]:pb-6",a),...s})}function Bs({className:a,...s}){return e.jsx(Ja,{"data-slot":"tabs",className:u("flex flex-col gap-2",a),...s})}function Ce({className:a,...s}){return e.jsx(es,{"data-slot":"tabs-content",className:u("flex-1 outline-none",a),...s})}const _a=Ft.memo(({playerRoundStreak:a,playerVisualMultiplier:s,liveXpEarned:n,activeMatch:c,subjects:d,battleSoundEnabled:l,onToggleSound:w,isFullscreen:z,onToggleFullscreen:g,isDesignPauseAvailable:N,onTogglePause:b})=>e.jsxs("header",{className:"flex items-center justify-between shrink-0 h-16 relative gap-4",children:[e.jsx("div",{className:"flex items-center min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3 md:gap-4 px-4 py-2 md:px-5 md:py-2.5 rounded-full bg-white/5 border border-white/10 backdrop-blur-md min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400 font-bold text-sm shrink-0",children:[e.jsx(Va,{className:"w-4 h-4"})," ",a]}),e.jsx("div",{className:"w-px h-4 bg-white/10 shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-violet-300 font-bold text-sm shrink-0",children:[e.jsx(At,{className:"w-4 h-4"})," ",s.toFixed(2),"x"]}),e.jsx("div",{className:"w-px h-4 bg-white/10 shrink-0"}),e.jsxs(y.div,{animate:n>0?{scale:[1,1.25,1]}:{},transition:{duration:.35},className:"flex flex-col items-center text-emerald-400 bg-emerald-500/10 px-3 py-0.5 rounded-full border border-emerald-500/20 font-bold shadow-[0_0_10px_rgba(16,185,129,0.15)] shrink-0",children:[e.jsxs("span",{className:"text-sm leading-none tabular-nums",children:[n," pts"]}),e.jsx("span",{className:"text-[8px] leading-none text-emerald-500/70 uppercase tracking-widest font-black whitespace-nowrap",children:"Battle Score"})]},n)]})}),e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 hidden md:flex items-center gap-3 bg-black/20 px-5 py-2 rounded-full border border-white/5 min-w-0 max-w-[48%]",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-sm bg-orange-400 shadow-[0_0_10px_rgba(251,146,60,0.5)] shrink-0"}),e.jsx("div",{className:"flex flex-col items-start justify-center -space-y-0.5 min-w-0",children:(()=>{if(!c?.topicId)return e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none truncate",children:"Practice Match"});for(const j of d){const h=j.modules?.find(m=>m.id===c.topicId);if(h)return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[9px] font-black text-white/40 uppercase tracking-widest leading-none",children:j.title}),e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none pt-1 truncate",children:h.title})]})}return e.jsx("span",{className:"font-bold text-white/90 tracking-wide text-sm leading-none truncate",children:c.topicId.split("-").map(j=>j.charAt(0).toUpperCase()+j.slice(1)).join(" ")})})()})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"outline",size:"icon",className:"h-12 w-12 rounded-full border-white/20 bg-black/20 hover:bg-white/10 text-white",onClick:w,children:l?e.jsx(fa,{className:"h-5 w-5"}):e.jsx(ga,{className:"h-5 w-5"})}),e.jsx(A,{variant:"outline",size:"icon",className:"h-12 w-12 rounded-full border-white/20 bg-black/20 hover:bg-white/10 text-white",onClick:g,children:z?e.jsx(ss,{className:"h-5 w-5"}):e.jsx(rs,{className:"h-5 w-5"})}),e.jsx(A,{variant:"outline",size:"icon",className:u("h-12 w-12 rounded-full border-white/20 text-white",N?"bg-black/20 hover:bg-white/10":"bg-black/10 opacity-50 cursor-not-allowed"),onClick:b,disabled:!N,children:e.jsx(Ua,{className:"h-5 w-5"})})]})]}));_a.displayName="BattleHeader";const Sa=Ft.memo(({studentProfile:a,activeMatch:s,scorePulseTarget:n,quizBattleAvatar:c})=>e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 w-full xl:max-w-[1400px] mx-auto px-4 md:px-8 shrink-0 h-32 md:h-48 flex justify-between items-end pb-0 pointer-events-none z-30",children:[e.jsxs("div",{className:"flex items-end gap-3 sm:gap-6 relative pointer-events-auto",children:[e.jsx("div",{className:"relative w-28 h-28 md:w-40 md:h-40 rounded-t-[40px] flex items-end",children:e.jsx(ns,{layers:a?.avatarLayers||{},className:"w-full h-full object-contain origin-bottom scale-[1.15]"})}),e.jsxs("div",{className:"bg-black/40 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 md:px-5 shadow-[0_8px_30px_rgba(0,0,0,0.5)] flex items-center gap-3 md:gap-4 mb-4 max-w-[220px] md:max-w-[280px]",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-white font-black text-base md:text-lg truncate tracking-wide",children:a?.name||"Player"}),e.jsxs("span",{className:"text-xs md:text-sm text-white/50 font-bold uppercase tracking-wider",children:["Level ",a?.level||1]})]}),e.jsx("div",{className:"h-10 w-px bg-white/20"}),e.jsxs("div",{className:"flex flex-col items-center justify-center shrink-0 w-10 md:w-12",children:[e.jsx(y.span,{animate:n==="player"?{scale:[1,1.4,1],color:["#fff","#34d399","#fff"]}:{},transition:{duration:.5},className:"text-2xl md:text-3xl font-black text-white leading-none",children:s.scoreFor}),e.jsx("span",{className:"text-[9px] md:text-[10px] text-emerald-400 font-bold uppercase tracking-widest mt-1 leading-none",children:"Score"})]})]})]}),e.jsxs("div",{className:"flex items-end gap-3 sm:gap-6 relative flex-row-reverse pointer-events-auto",children:[e.jsx("div",{className:"relative w-28 h-28 md:w-40 md:h-40 bg-[#1a2030] rounded-t-[40px] flex items-end justify-center border-t-4 border-slate-700/50 shadow-inner",children:s.mode==="bot"?e.jsx(Te,{className:"h-16 w-16 md:h-20 md:w-20 text-rose-400 mb-6 drop-shadow-xl",strokeWidth:1.5}):e.jsx(ge,{className:"h-16 w-16 md:h-20 md:w-20 text-slate-500 mb-6 drop-shadow-xl",strokeWidth:1.5})}),e.jsxs("div",{className:"bg-black/40 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 md:px-5 shadow-[0_8px_30px_rgba(0,0,0,0.5)] flex items-center gap-3 md:gap-4 mb-4 flex-row-reverse text-right max-w-[220px] md:max-w-[280px]",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-white font-black text-base md:text-lg truncate tracking-wide",children:s.opponentName||"Anonymous"}),e.jsx("span",{className:"text-xs md:text-sm text-rose-400 font-bold uppercase tracking-wider",children:s.mode==="bot"?"System Bot":"Challenger"})]}),e.jsx("div",{className:"h-10 w-px bg-white/20"}),e.jsxs("div",{className:"flex flex-col items-center justify-center shrink-0 w-10 md:w-12",children:[e.jsx(y.span,{animate:n==="opponent"?{scale:[1,1.4,1],color:["#fff","#fb7185","#fff"]}:{},transition:{duration:.5},className:"text-2xl md:text-3xl font-black text-white leading-none",children:s.scoreAgainst}),e.jsx("span",{className:"text-[9px] md:text-[10px] text-rose-400 font-bold uppercase tracking-widest mt-1 leading-none",children:"Score"})]})]})]})]}));Sa.displayName="BattleFooter";const Aa=Ft.memo(({activeMatch:a,roundSecondsLeft:s,lastRoundResult:n,selectedOptionIndex:c,roundLocked:d,answerSubmitting:l,designPauseActive:w,onOptionSelect:z,floatingMomentum:g,lastRoundMomentumDelta:N,studentProfile:b,quizBattleAvatar:j})=>e.jsxs("div",{className:"flex-1 flex flex-col justify-center items-center gap-4 md:gap-6 w-full min-h-0 overflow-y-auto pt-4 pb-28 z-20 no-scrollbar",children:[e.jsxs("div",{className:u("relative bg-[#1e2536] border shadow-[0_20px_60px_rgba(0,0,0,0.4)] rounded-[1.5rem] p-5 md:p-6 w-full max-w-4xl text-center flex flex-col items-center",s<=3?"border-rose-400/50":"border-white/10"),children:[e.jsxs("div",{className:"absolute -top-3.5 bg-[#2f3547] border border-white/10 text-white/80 px-4 py-1 rounded-full text-xs font-black shadow-lg uppercase tracking-wider",children:[a.currentRound," / ",a.totalRounds]}),e.jsx(Ke,{children:g&&g.tone==="positive"&&e.jsx(y.div,{initial:{opacity:0,y:14,scale:.92},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.9},className:u("absolute -top-12 rounded-full border px-3 py-1 text-[10px] font-black uppercase tracking-[0.15em] backdrop-blur-lg",g.tone==="positive"?"border-emerald-300/70 bg-emerald-500/20 text-emerald-100":g.tone==="negative"?"border-rose-300/70 bg-rose-500/20 text-rose-100":"border-slate-300/50 bg-slate-500/20 text-slate-100"),children:g.label},g.id)}),e.jsx("p",{className:"text-base sm:text-lg md:text-xl text-white font-extrabold leading-tight tracking-tight mt-1 min-h-[40px] flex items-center justify-center",children:a.currentQuestion?.prompt}),typeof window<"u"&&window.location.search.includes("debug=true")&&a.currentQuestion?.varianceApplied&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2 justify-center",children:a.currentQuestion.varianceApplied.map(h=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-blue-500/20 text-blue-200 border border-blue-400/30",children:h.replace(/_/g," ")},h))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 md:gap-4 w-full max-w-4xl px-4",children:a.currentQuestion?.choices.map((h,m)=>{const v=c===m,U=l||d,S=!!n&&n.roundNumber===a.currentRound,E=S&&n.correctOptionIndex===m;let W=-1;if(S)if(a.mode==="bot")if(n.botCorrect)W=n.correctOptionIndex;else{const O=[0,1,2,3].filter(C=>C!==n.correctOptionIndex);W=O[n.roundNumber%O.length]}else W=typeof n.botSelectedIndex=="number"?n.botSelectedIndex:-1;const ee=W===m;let T="bg-[#1e2433] hover:bg-[#283042] border-[#2f384e] text-white shadow-[0_6px_0_rgba(15,20,30,0.5)]";return S?E?T="bg-emerald-500 text-emerald-950 border-emerald-400 shadow-[0_6px_0_rgba(5,150,105,1)]":v?T="bg-rose-500 text-white border-rose-400 shadow-[0_6px_0_rgba(225,29,72,1)]":T="bg-[#1e2433] opacity-40 border-[#2f384e] shadow-[0_6px_0_rgba(15,20,30,0.5)] text-white":v&&(T="bg-indigo-500 text-white border-indigo-400 shadow-[0_6px_0_rgba(79,70,229,1)]"),e.jsxs(y.button,{whileTap:{y:8,scale:.98},whileHover:!S&&!U?{scale:1.02}:{},disabled:U||d||w,onClick:()=>z(m),className:u("relative h-16 md:h-20 rounded-2xl md:rounded-3xl font-black text-base md:text-lg pl-6 pr-20 border-[2px] border-b-[4px] flex items-center justify-start text-left transition-all disabled:cursor-not-allowed",T,v&&!S?"ring-[4px] ring-white/20 ring-offset-[4px] ring-offset-[#0B0F19]":"",s<=3&&!U&&!S?"shadow-[0_0_0_2px_rgba(251,113,133,0.45),0_6px_0_rgba(127,29,29,1)]":""),children:[e.jsx("span",{className:"mr-3 md:mr-4 text-xs md:text-sm opacity-60 bg-black/20 px-3 py-1 rounded-full",children:String.fromCharCode(65+m)}),e.jsx("span",{className:"line-clamp-2",children:h}),e.jsxs("div",{className:"absolute right-3 md:right-4 flex items-center gap-1.5 md:gap-2",children:[ee&&e.jsx(y.div,{initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},className:"w-8 h-8 md:w-10 md:h-10 rounded-full border-[3px] border-[#0B0F19] overflow-hidden bg-rose-500 shadow-lg flex items-center justify-center z-10",children:a.mode==="bot"?e.jsx(Te,{className:"w-4 h-4 md:w-5 md:h-5 text-white"}):e.jsx(ge,{className:"w-4 h-4 md:w-5 md:h-5 text-white"})}),v&&e.jsx(y.div,{initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},className:"w-8 h-8 md:w-10 md:h-10 rounded-full border-[3px] border-[#0B0F19] overflow-hidden bg-indigo-200 shadow-lg z-20",children:e.jsx("img",{src:b?.photo||j,alt:"You",className:"w-full h-full object-cover"})})]})]},m)})}),e.jsx(Ke,{children:d&&!n&&a.mode==="online"&&e.jsxs(y.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/70 font-semibold bg-black/30 px-6 py-2 rounded-full border border-white/10",children:[e.jsx(Je,{className:"w-4 h-4 animate-spin text-amber-400"}),"Waiting for opponent..."]}),e.jsx("p",{className:"text-white/30 text-[11px] mt-1",children:"Choices locked until round resolves"})]})}),e.jsx(Ke,{children:n?.studentCorrect&&e.jsx(y.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,filter:"blur(10px)"},transition:{type:"spring",damping:20,stiffness:300},className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[100] pointer-events-none flex flex-col items-center justify-center",children:e.jsxs("div",{className:"bg-[#1e2433]/95 backdrop-blur-xl border border-white/10 rounded-[2rem] p-6 md:p-8 shadow-[0_30px_80px_rgba(0,0,0,0.6)] flex flex-col items-center min-w-[280px] md:min-w-[320px]",children:[e.jsx("img",{src:j,alt:"Mascot",className:"w-24 h-24 md:w-32 md:h-32 mb-4 drop-shadow-xl"}),e.jsx("h2",{className:u("text-3xl md:text-4xl font-black mb-4 uppercase tracking-widest",n.studentCorrect?"text-emerald-400":"text-rose-400"),children:n.studentCorrect?"Correct!":"Incorrect"}),n.studentCorrect?e.jsxs("div",{className:"flex items-center gap-3 w-full justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 bg-emerald-500/20 text-emerald-400 px-4 py-2 rounded-2xl font-bold border border-emerald-500/30",children:e.jsx("span",{children:"+ 10 XP"})}),N!==null&&N>0&&e.jsx("div",{className:"flex items-center gap-2 bg-amber-500/20 text-amber-400 px-4 py-2 rounded-2xl font-bold border border-amber-500/30",children:e.jsxs("span",{children:["+ ",N," ",e.jsx(et,{className:"w-4 h-4 inline"})]})})]}):e.jsxs("div",{className:"bg-rose-500/20 border border-rose-500/30 text-rose-400 font-bold px-5 py-2 rounded-xl text-center",children:["Correct: ",String.fromCharCode(65+n.correctOptionIndex)]})]})})})]}));Aa.displayName="BattleActiveContent";const kt={width:1280,height:720},_t=` @keyframes mascot-float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-24px) rotate(3deg); } @@ -102,4 +102,4 @@ import{c as xa,k as u,m as y,h as tt,aF as De,I as rt,aG as Q,Q as Va,q as At,M .animate-reward-pop { animation: reward-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards; } .animate-score-pop { animation: score-pop 0.5s ease-out forwards; } .animate-overlay-slide-up { animation: overlay-slide-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards; } -`,Ms=300*1e3,Fs=({viewportHeight:a})=>e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[50] overflow-hidden flex justify-between bg-slate-900/10",children:i.useMemo(()=>[...Array(40)].map((s,n)=>({id:n,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[a]).map(s=>e.jsx(y.div,{className:"absolute w-0.5 h-16 bg-blue-300/40 rounded-full e-left-top",style:{"--left":s.left,"--top":"-10%"},animate:{y:[0,a*1.2]},transition:{duration:s.duration,ease:"linear",delay:s.delay}},s.id))}),Es=({viewportHeight:a,viewportWidth:s})=>{const n=i.useMemo(()=>[...Array(30)].map((c,d)=>({id:d,xShift:(Math.random()-.5)*s*.8,yShift:(Math.random()-.5)*a*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[a,s]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[50] overflow-hidden flex items-center justify-center",children:n.map(c=>e.jsx(y.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.8)] e-left-top",style:{"--left":"50%","--top":"50%"},animate:{y:[0,c.yShift],x:[0,c.xShift],scale:[0,c.scale,0],opacity:[0,1,0]},transition:{duration:c.duration,ease:"easeOut",delay:c.delay}},c.id))})},da=({value:a,label:s,delay:n=0,icon:c})=>{const[d,l]=i.useState(0);return i.useEffect(()=>{if(a<=0)return;const w=1e3,z=30,g=Math.abs(Math.floor(w/z));let N=0;const b=setTimeout(()=>{const j=setInterval(()=>{N+=Math.max(1,Math.floor(a/z)),N>=a?(l(a),clearInterval(j)):l(N)},g);return()=>clearInterval(j)},n);return()=>clearTimeout(b)},[a,n]),a<=0?null:e.jsxs(y.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:n/1e3,duration:.5},className:"flex items-center justify-between bg-white/5 border border-white/10 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-white/80 font-bold uppercase tracking-wider text-sm",children:[c,s]}),e.jsxs("div",{className:"text-2xl font-black text-amber-400 tabular-nums",children:["+",d]})]})},fe="border border-border bg-card text-card-foreground shadow-sm dark:border-[#2b3140] dark:bg-[#181d27] dark:text-[#f5f7fb] dark:shadow-[0_12px_24px_rgba(0,0,0,0.22)]",Rs=a=>a<=0?"--":`${(a/1e3).toFixed(2)}s`,Ts=a=>a==="win"?"Win":a==="loss"?"Loss":"Draw",Ze=(a,s,n)=>Math.max(s,Math.min(n,a)),ca=a=>{const s=Math.floor(a/60),n=a%60;return`${s}:${String(n).padStart(2,"0")}`},Ds=a=>{const s=a.trim().split(/\s+/).filter(Boolean).slice(0,2);return s.length===0?"ST":s.map(n=>n[0]?.toUpperCase()||"").join("")},ua=(a,s)=>a?a.eventType==="round_started"?`Round ${a.roundNumber} started.`:a.eventType==="answer_locked"?a.lockedByStudentId&&s&&a.lockedByStudentId===s?`Round ${a.roundNumber}: your answer is locked.`:`Round ${a.roundNumber}: opponent answer locked.`:a.eventType==="round_result"?`Round ${a.roundNumber} resolved.`:"Match completed.":null;let St=null;const ma=()=>{if(typeof window>"u")return null;if(!St){const a=window.AudioContext||window.webkitAudioContext;a&&(St=new a)}return St},cr=()=>{const{userProfile:a,userRole:s}=Wa(),n=a,[c,d]=i.useState("hub"),[l,w]=i.useState(bs),[z,g]=i.useState([]),[N,b]=i.useState({status:"idle"}),[j,h]=i.useState(!1),[m,v]=i.useState(null),[U,S]=i.useState(""),[E,W]=i.useState(null),[ee,T]=i.useState(0),[H,C]=i.useState(null),[J,Tt]=i.useState(()=>typeof window>"u"?!0:window.localStorage.getItem("quiz_battle_sound_enabled")!=="0"),[ce,Ca]=i.useState(()=>{if(typeof window>"u")return .7;const t=Number(window.localStorage.getItem("quiz_battle_sound_volume")||"0.7");return Number.isFinite(t)?Ze(t,0,1):.7}),[Dt,I]=i.useState("connected"),[we,za]=i.useState("all"),[Pt,ot]=i.useState(!0),[te,lt]=i.useState(null),[it,dt]=i.useState([]),[Ia,Qt]=i.useState(!1),[qt,Ba]=i.useState([]),[Qe,Ma]=i.useState("alias"),[ct,Fa]=i.useState(!1),[r,_]=i.useState(null),[ve,Y]=i.useState(null),[X,Be]=i.useState(!1),[D,Me]=i.useState(0),[G,Z]=i.useState(!1),[M,ut]=i.useState(!1),[Ea,Ra]=i.useState(!1),[mt,Ta]=i.useState(kt),[B,ae]=i.useState(null),[Da,xt]=i.useState(!1),[qe,pt]=i.useState(null),[Pa,ht]=i.useState(null),[Qa,Le]=i.useState(null),Lt=i.useRef(""),bt=i.useRef(null),je=i.useRef(null),le=i.useRef(0),$t=i.useRef(""),Fe=i.useRef(0),ft=i.useRef(0),$e=i.useRef(null),Ee=i.useRef(null),Oe=i.useRef(-1),gt=!1,ie=i.useMemo(()=>{const t=Xa(n?.grade);return ea.filter(o=>t.includes(o.id))},[n?.grade]),qa=i.useMemo(()=>(ie.find(o=>o.id===l.subjectId)?.modules||[]).map(o=>({value:o.id,label:o.title})),[ie,l.subjectId]),$=i.useMemo(()=>{const t=r?.roundResults||[];let o=0;return t.forEach(p=>{o=p.studentCorrect?o+1:0}),o},[r?.roundResults]),La=i.useMemo(()=>{const t=Math.max(0,$-1)*.12;return Number((1+Math.min(.72,t)).toFixed(2))},[$]),$a=i.useMemo(()=>{if(!r)return 0;if(r.status==="completed")return r.xpEarned||0;const t=r.roundResults||[];let o=0,p=0;for(const x of t)if(x.studentCorrect){o++;const k=o>=2?Math.min(25,(o-1)*5):0;p+=10+k}else o=0;return p},[r?.status,r?.xpEarned,r?.roundResults]),Ot=i.useMemo(()=>{const t=r?.roundResults||[];let o=0;return t.forEach(p=>{o=p.botCorrect?o+1:0}),o},[r?.roundResults]);i.useMemo(()=>{const t=Math.max(0,Ot-1)*.1;return Number((1+Math.min(.5,t)).toFixed(2))},[Ot]),i.useMemo(()=>$>=5?{label:"Inferno",badgeClass:"text-amber-300 border-amber-300/50 bg-amber-500/20 shadow-[0_0_18px_rgba(251,191,36,0.35)]"}:$>=3?{label:"Heating Up",badgeClass:"text-orange-300 border-orange-300/50 bg-orange-500/15 shadow-[0_0_16px_rgba(249,115,22,0.3)]"}:B?.studentCorrect?{label:"Steady",badgeClass:"text-emerald-300 border-emerald-300/40 bg-emerald-500/15 shadow-[0_0_14px_rgba(16,185,129,0.25)]"}:{label:"Rebuild",badgeClass:"text-slate-300 border-slate-300/30 bg-slate-500/15 shadow-[0_0_14px_rgba(148,163,184,0.2)]"},[B?.studentCorrect,$]);const de=i.useMemo(()=>{if(!B)return null;const t=B.studentCorrect?12:-8,o=B.studentCorrect&&!B.botCorrect?6:0,p=B.studentCorrect?Math.max(0,($-1)*2):0;return t+o+p},[B,$]),P=i.useCallback(t=>{if(!(!J||ce<=0||typeof window>"u"))try{const o=ma();if(!o)return;o.state==="suspended"&&o.resume().catch(()=>{});const x={tick:{notes:[740],duration:.06,type:"triangle",volume:.03},lock:{notes:[520],duration:.08,type:"square",volume:.04},result:{notes:[660,720],duration:.08,type:"sine",volume:.04},win:{notes:[920,1040,1180],duration:.12,type:"triangle",volume:.05},loss:{notes:[260,220],duration:.14,type:"sawtooth",volume:.045},streak:{notes:[780,920],duration:.09,type:"triangle",volume:.045},multiplier:{notes:[660,880,1120],duration:.08,type:"triangle",volume:.05}}[t],k=o.currentTime,R=.07,f=Ze(x.volume*ce,.004,.08);x.notes.forEach((F,re)=>{const me=o.createOscillator(),Re=o.createGain(),ye=k+re*R;me.type=x.type,me.frequency.setValueAtTime(F,ye),Re.gain.setValueAtTime(1e-4,ye),Re.gain.exponentialRampToValueAtTime(f,ye+.012),Re.gain.exponentialRampToValueAtTime(1e-4,ye+x.duration),me.connect(Re),Re.connect(o.destination),me.start(ye),me.stop(ye+x.duration+.02)})}catch(o){console.warn("Battle tone playback skipped or blocked:",o)}},[J,ce]),Ht=i.useCallback(async t=>{if(!(!t||typeof window>"u"))try{await window.navigator.clipboard.writeText(t),W(t),window.setTimeout(()=>{W(o=>o===t?null:o)},1600)}catch{b({status:"error",message:"Unable to copy room code automatically. Please copy it manually."})}},[]),Vt=i.useCallback(()=>{},[gt]),Ut=i.useCallback(t=>{h(!1),v(null),_(null),T(0),C(null),b({status:"error",message:t}),d("setup")},[]),se=i.useCallback(async()=>{if(!n?.uid)return null;const[t,o]=await Promise.all([gs(n.uid),ws(n.uid,{mode:we,limitCount:8})]);return{stats:t,history:o}},[we,n?.uid]);i.useEffect(()=>{if(ie.length===0)return;const o=ie.some(k=>k.id===l.subjectId)?l.subjectId:ie[0].id,p=ie.find(k=>k.id===o),x=p?.modules?.[0]?.id||"";w(k=>{const R=p?.modules?.some(f=>f.id===k.topicId)?k.topicId:x;return k.subjectId===o&&k.topicId===R?k:{...k,subjectId:o,topicId:R}})},[ie,l.subjectId]),i.useEffect(()=>{if(!n?.uid){lt(null),dt([]),ot(!1);return}let t=!0;return ot(!0),(async()=>{const p=await se();t&&(p&&(lt(p.stats),dt(p.history)),ot(!1))})(),()=>{t=!1}},[se,n?.uid]);const He=i.useMemo(()=>we==="all"?it:it.filter(t=>t.mode===we),[it,we]),Wt=i.useMemo(()=>qt.map((t,o)=>{const p=t.rank||o+1,x=t.userId===n?.uid,k=`Student-${t.userId.slice(-4).toUpperCase()}`,R=Qe==="full"?t.displayName:Qe==="initials"?Ds(t.displayName):k,f=Math.floor(t.leaderboardScore/25)*25,F=ct||x?`${t.leaderboardScore} pts`:`${f}-${f+24} pts`;return{...t,rank:p,isSelf:x,displayName:R,scoreLabel:F}}),[qt,Qe,ct,n?.uid]);i.useEffect(()=>{if(c!=="leaderboard"&&c!=="hub")return;let t=!0;return Qt(!0),(async()=>{const p=await Is(20);t&&(Ba(p),Qt(!1))})(),()=>{t=!1}},[c]);const Ve=i.useCallback(async()=>{if(n?.uid)try{const t=await ia();if(t.sessionType==="match"&&t.match){let o=t.match;if(t.match.mode==="bot"&&t.match.status==="ready")try{o=await ne(t.match.matchId),Fe.current=0}catch(p){const x=p;h(!1),v(null),_(null),d("setup"),I(typeof window<"u"&&window.navigator.onLine?"connected":"disconnected"),b({status:"error",message:x?.message||"Unable to resume bot battle. Please start a new match."});return}h(!1),v(t.room||null),_(o),C(t.queue?.expiresAtMs||o.expiresAtMs||null),d("battle"),I("connected");return}if(t.sessionType==="room"&&t.room){h(!1),v(t.room),_(o=>o?.mode==="bot"?o:null),C(null),I("connected");return}if(t.sessionType==="queue"){h(!0),v(null),_(o=>o?.mode==="bot"?o:null),C(t.queue?.expiresAtMs||null),I("connected");return}h(!1),v(null),_(o=>o?.mode==="bot"?o:null),C(null),I("connected")}catch(t){console.warn("Quiz Battle session resume failed:",t),I("reconnecting")}},[n?.uid]);i.useEffect(()=>{n?.uid&&Ve()},[n?.uid,Ve]),i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("quiz_battle_sound_enabled",J?"1":"0")},[J]),i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("quiz_battle_sound_volume",ce.toFixed(2))},[ce]),i.useEffect(()=>{if(typeof window>"u")return;const t=()=>{const o=window.innerWidth,p=window.innerHeight;Ta({width:Number.isFinite(o)&&o>0?o:kt.width,height:Number.isFinite(p)&&p>0?p:kt.height})};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),i.useEffect(()=>{if(typeof document>"u")return;const t=()=>{Ra(!!document.fullscreenElement)};return t(),document.addEventListener("fullscreenchange",t),()=>{document.removeEventListener("fullscreenchange",t)}},[]),i.useEffect(()=>{const t=H!==null;if(!(j||m&&(m.status==="waiting"||m.status==="ready")||t)){T(0);return}const o=()=>{if(!H){T(x=>x+1);return}T(Math.max(0,Math.ceil((H-Date.now())/1e3)))};o();const p=window.setInterval(o,1e3);return()=>{window.clearInterval(p)}},[j,m?.status,m?.roomId,H]),i.useEffect(()=>{if(!H)return;const t=window.setInterval(()=>{H-Date.now()<=0&&(window.clearInterval(t),(async()=>{try{(j||!m)&&await la()}catch{}finally{Ut("Public matchmaking timed out after 5 minutes. Please start again.")}})())},1e3);return()=>{window.clearInterval(t)}},[m,Ut,j,H]),i.useEffect(()=>{if(typeof window>"u")return;I(window.navigator.onLine?"connected":"disconnected");const t=()=>{I("reconnecting"),Ve()},o=()=>{I("disconnected")};return window.addEventListener("online",t),window.addEventListener("offline",o),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",o)}},[Ve]),i.useEffect(()=>{const t=r?.mode==="online"&&(r.status==="ready"||r.status==="in_progress"),o=r?.mode==="bot"&&r.status==="ready",p=!!(m&&(m.status==="waiting"||m.status==="ready"));if(o||(Fe.current=0),!j&&!p&&!t&&!o||M)return;let x=!1;const k=async()=>{try{if(r?.mode==="bot"&&r.status==="ready"){const f=await ne(r.matchId);if(x)return;_(f),I("connected"),C(f.expiresAtMs||null),Fe.current=0,f.status==="in_progress"&&b({status:"queued",message:"Practice bot match started."});return}if(r?.mode==="online"){if(r.status==="ready"){const re=await ne(r.matchId);if(x)return;_(re),I("connected"),C(re.expiresAtMs||null),re.status==="in_progress"&&b({status:"queued",message:"Match started. Round timer is live."});return}const f=await Nt(r.matchId);if(x)return;const F=f.roundResults.filter(re=>re.roundNumber>Oe.current).sort((re,me)=>re.roundNumber-me.roundNumber)[0];F?(Oe.current=F.roundNumber,ae(F),pt(f)):(_(f),f.status==="completed"&&(h(!1),v(null),C(null)),f.status==="cancelled"&&r.status==="in_progress"&&(xt(!0),Z(!1))),I("connected");return}if(m?.roomId){const f=await Ns({roomId:m.roomId});if(x)return;if(v(f.room),f.match){const F=await ne(f.match.matchId);if(x)return;_(F),v(f.room),h(!1),C(F.expiresAtMs||null),d("battle"),I("connected"),b({status:"queued",message:F.status==="ready"?"Opponent connected. Waiting for synchronized start...":"Private room match started."})}return}if(j){const f=await ia();if(x)return;if(f.sessionType==="match"&&f.match){const F=await ne(f.match.matchId);if(x)return;_(F),v(f.room||null),h(!1),C(F.expiresAtMs||null),d("battle"),I("connected"),b({status:"queued",message:"Opponent found. Preparing synchronized start..."});return}if(f.sessionType==="room"&&f.room){h(!1),v(f.room),C(null),I("connected");return}I("connected")}}catch(f){if(!x){if(console.warn("Quiz Battle sync poll failed:",f),r?.mode==="bot"&&r.status==="ready"&&(Fe.current+=1,Fe.current>=3)){const F=f;h(!1),v(null),_(null),d("setup"),b({status:"error",message:F?.message||"Unable to start bot battle. Please try again."}),I("disconnected");return}I("reconnecting")}}};k();const R=window.setInterval(()=>{k()},3e3);return()=>{x=!0,window.clearInterval(R)}},[r?.matchId,r?.mode,r?.status,m?.roomId,m?.status,M,j]);const ue=i.useMemo(()=>r?.mode==="online"&&(r.status==="ready"||r.status==="in_progress")?{scope:"match",resourceId:r.matchId}:m&&(m.status==="waiting"||m.status==="ready")?{scope:"room",resourceId:m.roomId}:j&&n?.uid?{scope:"queue",resourceId:n.uid}:null,[r,m,j,n?.uid]);i.useEffect(()=>{if(!ue)return;let t=!1;const o=async()=>{try{await _s(ue.scope,ue.resourceId),t||I("connected")}catch(x){t||(console.warn("Quiz Battle heartbeat failed:",x),I("reconnecting"))}};o();const p=window.setInterval(()=>{o()},8e3);return()=>{t=!0,window.clearInterval(p),hs(ue.scope,ue.resourceId)}},[ue?.scope,ue?.resourceId]),i.useEffect(()=>{if(!r||r.status!=="in_progress"){Z(!1),je.current=null,le.current=0;return}je.current=null,le.current=0;const t=r.roundDeadlineAtMs?Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3)):r.timePerQuestionSec;Me(t),Y(null),Z(!1)},[r?.matchId,r?.status,r?.currentRound,r?.timePerQuestionSec]),i.useEffect(()=>{M&&(!r||r.status!=="in_progress")&&ut(!1)},[r?.matchId,r?.status,M]),i.useEffect(()=>{const t=r?.lifecycle;if(!t?.eventType)return;const o=`${t.eventType}:${t.sequence}`;Lt.current!==o&&(Lt.current=o,t.eventType==="answer_locked"?P("lock"):t.eventType==="round_result"&&P("result"))},[r?.lifecycle?.eventType,r?.lifecycle?.sequence,P]),i.useEffect(()=>{!r||r.status!=="completed"||$t.current!==r.matchId&&($t.current=r.matchId,P(r.outcome==="loss"?"loss":"win"),r.outcome==="win"&&Ya(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(t=>{t.default({particleCount:110,spread:78,origin:{y:.62},ticks:160})}).catch(()=>{}))},[r?.matchId,r?.status,r?.outcome,P]),i.useEffect(()=>{if(!r||r.status!=="in_progress"||G||X||M){bt.current=null;return}D<=3&&D>0&&bt.current!==D&&(bt.current=D,P("tick"))},[r?.status,D,G,X,M,P]),i.useEffect(()=>{if(!r||r.status!=="in_progress"){ft.current=0;return}$>ft.current&&$>=2&&P($>=4?"multiplier":"streak"),ft.current=$},[r?.matchId,r?.status,$,P]),i.useEffect(()=>{if(!r){$e.current=null,Le(null);return}const t=$e.current;if(!t||t.matchId!==r.matchId){$e.current={matchId:r.matchId,scoreFor:r.scoreFor,scoreAgainst:r.scoreAgainst},Le(null);return}if(r.scoreFor!==t.scoreFor||r.scoreAgainst!==t.scoreAgainst){const o=r.scoreFor>t.scoreFor?"player":"opponent";Le(o),Ee.current&&window.clearTimeout(Ee.current),Ee.current=window.setTimeout(()=>{Le(null)},850)}$e.current={matchId:r.matchId,scoreFor:r.scoreFor,scoreAgainst:r.scoreAgainst}},[r?.matchId,r?.scoreAgainst,r?.scoreFor]),i.useEffect(()=>()=>{Ee.current&&window.clearTimeout(Ee.current)},[]),i.useEffect(()=>{if(!B?.studentCorrect||de===null||de<=0){ht(null);return}const t=de>0?"positive":de<0?"negative":"neutral";ht({id:Date.now(),label:`${de>=0?"+":""}${de} Momentum`,tone:t});const o=window.setTimeout(()=>{ht(null)},1400);return()=>{window.clearTimeout(o)}},[de,B]),i.useEffect(()=>{if(B&&qe){B.studentCorrect?P("win"):P("loss");const t=window.setTimeout(()=>{_(qe),ae(null),Y(null),Z(!1),pt(null),qe.status==="completed"&&(h(!1),v(null),se(),Oe.current=-1)},1500);return()=>window.clearTimeout(t)}},[B,qe,P,se]);const Ue=i.useCallback(async t=>{if(!r||r.status!=="in_progress"||G||M)return;Be(!0);const o=window.setTimeout(()=>{Be(!1),b({status:"error",message:"Submission took too long. Syncing latest match state now..."}),Nt(r.matchId).then(p=>{_(p),p.status==="completed"&&(h(!1),v(null),C(null))}).catch(()=>{})},12e3);try{const p=r.roundDeadlineAtMs?Ze(r.timePerQuestionSec*1e3-Math.max(0,r.roundDeadlineAtMs-Date.now()),0,r.timePerQuestionSec*1e3):Math.max(0,(r.timePerQuestionSec-D)*1e3),x=await Cs({matchId:r.matchId,roundNumber:r.currentRound,selectedOptionIndex:t,responseMs:p});je.current=null,le.current=0,x.roundResult?(Oe.current=x.roundResult.roundNumber,ae(x.roundResult),pt(x.match)):(_(x.match),ae(null),x.match.mode==="online"&&x.match.status==="in_progress"?(Z(!0),b({status:"queued",message:"Answer locked. Waiting for opponent to finish the round..."})):Y(null)),x.match.status==="completed"&&(h(!1),v(null),C(null),se(),b({status:"queued",message:x.completion?`Match finished (${x.completion.outcome.toUpperCase()}) +${x.completion.xpEarned} XP`:"Match finished. Results saved."}))}catch(p){const k=p?.message||"Unable to submit answer right now. Please try again.";if(t===null||k.includes("Round timer elapsed")||k.includes("Expected round")||k.includes("Match is not currently active"))try{const f=await Nt(r.matchId),F=f.currentRound!==r.currentRound;if(_(f),Y(null),Z(!1),F||f.status==="completed"?(je.current=null,le.current=0):t===null&&(le.current=Date.now()+3e3),f.status==="completed"){h(!1),v(null),C(null),se(),b({status:"queued",message:"Match finished. Results synchronized."});return}b({status:"queued",message:"Round timed out. Synced to the latest battle state."});return}catch{}t===null&&(le.current=Date.now()+3e3),b({status:"error",message:k})}finally{window.clearTimeout(o),Be(!1)}},[r,M,se,G,D]);i.useEffect(()=>{if(!r||r.status!=="in_progress"||M||X||G)return;const t=r.roundDeadlineAtMs?Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3)):D;if(r.roundDeadlineAtMs&&t!==D&&Me(t),ve===null?t<=1:t<=0){if(je.current===r.currentRound&&Date.now(){r.roundDeadlineAtMs?Me(Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3))):Me(x=>Math.max(0,x-1))},1e3);return()=>{window.clearTimeout(p)}},[r,X,M,G,D,ve,Ue]);const Yt=i.useCallback(async()=>{if(!(!r||r.mode!=="bot")){Be(!0),b({status:"validating"});try{const t=await zs(r.matchId),o=await ne(t.matchId);_(o),v(null),h(!1),C(null),ae(null),Y(null),Z(!1),d("battle"),b({status:"queued",message:`Rematch ready (${t.botDifficulty}). Good luck!`})}catch(t){b({status:"error",message:t?.message||"Unable to start rematch right now."})}finally{Be(!1)}}},[r]);if(s!=="student")return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsx("div",{className:"px-4 sm:px-6 xl:px-10 py-6 sm:py-8",children:e.jsx(pe,{className:u(fe,"max-w-2xl"),children:e.jsxs(he,{children:[e.jsx(be,{children:"Quiz Battle is student-only"}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#aab3c7]",children:"Your account role does not have access to this module."})]})})})]});const Xt=t=>{g([]),b({status:"idle"}),ut(!1),h(!1),v(null),S(""),_(null),ae(null),Y(null),Z(!1),C(null),w(o=>({...o,mode:t,queueType:t==="online"?o.queueType:"public_matchmaking"})),T(0),d("setup")},Gt=async()=>{b({status:"validating"});try{m?.roomId?await ks({roomId:m.roomId}):await la(),h(!1),v(null),_(t=>!t||t.mode!=="online"?t:t.status==="ready"||t.status==="cancelled"?null:t),S(""),T(0),C(null),b({status:"queued",message:m?.roomId?"Private room cancelled.":"Left matchmaking queue."})}catch(t){b({status:"error",message:t?.message||"Unable to cancel this online session right now. Please try again."})}},Oa=async()=>{b({status:"validating"});const t=fs(l);if(t.length>0){g(t),b({status:"error",message:"Fix the highlighted setup fields before starting."});return}g([]);try{if(l.mode==="online"){if(l.queueType==="private_room"){const k=U.trim().toUpperCase(),R=k?await ys(k):await js(l);if(h(!1),v(R.room),S(""),C(R.match?.expiresAtMs||null),R.match){const f=await ne(R.match.matchId);_(f),ae(null),Y(null),Z(!1),d("battle"),C(f.expiresAtMs||null),b({status:"queued",message:f.status==="ready"?`Room ${R.room.roomCode} linked. Waiting for synchronized start...`:"Private room match started."});return}_(null),C(null),b({status:"queued",message:k?"Joined private room. Waiting for opponent...":"Private room created. Share code:"});return}const x=await vs(l);if(x.status==="matched"&&x.matchId){const k=await ne(x.matchId);h(!1),v(null),_(k),ae(null),Y(null),Z(!1),d("battle"),C(k.expiresAtMs||null),b({status:"queued",message:"Opponent found. Preparing synchronized start..."});return}h(!0),v(null),_(null),C(x.expiresAtMs||Date.now()+Ms),T(0),b({status:"queued",message:"Joined matchmaking queue. Waiting for an opponent..."});return}const o=await Ss(l),p=await ne(o.matchId);h(!1),v(null),_(p),ae(null),Y(null),Z(!1),Me(p.timePerQuestionSec),C(null),d("battle"),b({status:"queued",message:`Bot match ${o.matchId.slice(0,8)} live (${o.botDifficulty}).`}),se().then(x=>{x&&(lt(x.stats),dt(x.history))})}catch(o){h(!1),b({status:"error",message:o?.message||"Unable to start battle. Please try again."})}},V=t=>z.find(o=>o.field===t)?.message;te?.winRate;const Zt=!!(l.mode==="online"&&m&&(m.status==="waiting"||m.status==="ready")&&(!r||r.status!=="completed")),Ha=!!(j||m&&(m.status==="waiting"||m.status==="ready")&&(!r||r.status==="ready"||r.status==="cancelled"));return r&&(r.status==="in_progress"||r.status==="completed")?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsxs("div",{className:"fixed inset-0 z-[100] bg-[#0B0F19] text-white flex flex-col overflow-hidden",children:[r.status==="completed"&&r.outcome==="loss"&&e.jsx(Fs,{viewportHeight:mt.height}),r.status==="completed"&&r.outcome==="draw"&&e.jsx(Es,{viewportHeight:mt.height,viewportWidth:mt.width}),e.jsx("div",{className:"absolute inset-0 z-0 opacity-40",children:e.jsx(na,{children:e.jsx("div",{className:"h-full w-full"})})}),e.jsx(Ke,{children:Da&&e.jsx(y.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-[120] bg-black/70 backdrop-blur-md flex flex-col items-center justify-center px-6",children:e.jsxs(y.div,{initial:{opacity:0,transform:"translateY(40px) scale(0.85)"},animate:{opacity:1,transform:"translateY(0) scale(1)"},transition:{type:"spring",damping:18,stiffness:250,delay:.1},className:"bg-[#1e2433] border border-white/10 rounded-[2rem] p-8 flex flex-col items-center gap-5 max-w-sm w-full shadow-[0_30px_80px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[#1a2030] border-4 border-rose-500/50 overflow-hidden flex items-end justify-center shadow-xl",children:r.mode==="bot"?e.jsx(Te,{className:"h-16 w-16 text-rose-400 mb-2",strokeWidth:1.5}):e.jsx(ge,{className:"h-14 w-14 text-slate-500 mb-2",strokeWidth:1.5})}),e.jsx(y.div,{initial:{opacity:0,transform:"scale(0.5) translateX(-10px)"},animate:{opacity:1,transform:"scale(1) translateX(0)"},transition:{delay:.4,type:"spring",stiffness:300},className:"absolute -top-2 left-full ml-2 bg-white text-slate-900 text-xs font-black px-3 py-1.5 rounded-2xl rounded-bl-none whitespace-nowrap shadow-lg",children:"I give up! 🏳️"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-black text-white mb-1",children:"Opponent Surrendered"}),e.jsxs("p",{className:"text-white/50 text-sm",children:[e.jsx("span",{className:"font-bold text-white/70",children:r.opponentName||"Your opponent"})," left the match. You win! 🏆"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsx(A,{size:"lg",className:"w-full h-12 bg-emerald-500 hover:bg-emerald-400 text-white font-black rounded-xl",onClick:()=>{xt(!1),_(null),v(null),h(!1),b({status:"idle"}),d("hub"),se()},children:"🏆 Claim Victory"}),e.jsx(A,{size:"lg",variant:"outline",className:"w-full h-12 border-white/20 text-white/70 hover:bg-white/10 rounded-xl",onClick:()=>{xt(!1),_(null),v(null),h(!1),b({status:"idle"}),d("hub")},children:"Back to Arena"})]})]})})}),M&&e.jsx("div",{className:"absolute inset-0 z-[110] bg-black/60 backdrop-blur-md flex items-center justify-center",children:e.jsxs(pe,{className:"w-full max-w-sm border-border/50 bg-[#181d27] shadow-[0_20px_50px_rgba(0,0,0,0.5)]",children:[e.jsxs(he,{className:"text-center",children:[e.jsx(be,{className:"text-3xl font-black text-white",children:"PAUSED"}),e.jsx(Ae,{className:"text-base text-muted-foreground mt-2",children:r.mode==="online"?"Online match - timer continues in the background! Hurry!":"Bot match - round timer frozen."})]}),e.jsxs(Ge,{className:"flex flex-col gap-3",children:[e.jsx(A,{variant:"default",size:"lg",className:"w-full text-lg h-12",onClick:Vt,children:"Resume Match"}),e.jsx(A,{variant:"outline",size:"lg",className:"w-full text-lg h-12 border-rose-500/20 text-rose-500 hover:bg-rose-500/10",onClick:()=>{ut(!1),_(null),v(null),h(!1),b({status:"idle"}),d("setup")},children:"Leave Match"})]})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col h-full w-full max-w-[1400px] mx-auto px-4 md:px-8 py-4",children:[e.jsx(_a,{playerRoundStreak:$,playerVisualMultiplier:La,liveXpEarned:$a,activeMatch:r,subjects:ea,battleSoundEnabled:J,onToggleSound:()=>Tt(t=>!t),isFullscreen:Ea,onToggleFullscreen:()=>{typeof document>"u"||(document.fullscreenElement?document.exitFullscreen().catch(t=>{console.warn("Fullscreen mode unavailable or blocked by browser (exit):",t)}):document.documentElement.requestFullscreen().catch(t=>{console.warn("Fullscreen mode unavailable or blocked by browser (enter):",t)}))},isDesignPauseAvailable:gt,onTogglePause:Vt}),r.status==="in_progress"?e.jsx("div",{className:"shrink-0 w-full max-w-4xl mx-auto h-2 bg-white/10 rounded-full overflow-hidden mt-6 mb-4",children:e.jsx(y.div,{className:"h-full",animate:{width:`${Math.max(0,D/r.timePerQuestionSec*100)}%`,backgroundColor:D>Math.floor(r.timePerQuestionSec/2)?"#10b981":D>3?"#f59e0b":"#ef4444"},transition:{duration:1,ease:"linear"}})}):e.jsx("div",{className:"shrink-0 h-6 md:h-10 w-full"}),e.jsx("div",{className:"flex-1 flex flex-col justify-center items-center w-full min-h-0 relative",children:r.status==="completed"?e.jsx("div",{className:"fixed inset-0 z-[200] flex flex-col items-center justify-center bg-slate-900/50 backdrop-blur-md px-4",children:e.jsxs(y.div,{initial:{opacity:0,scale:.9,y:10},animate:{opacity:1,scale:1,y:0},className:"w-full max-w-sm sm:max-w-md bg-[#161a25]/90 border border-white/20 shadow-[0_30px_80px_rgba(0,0,0,0.8)] rounded-[1.5rem] p-6 text-center",children:[e.jsx("h2",{className:u("text-3xl font-black uppercase tracking-widest drop-shadow-md mb-2",r.outcome==="win"?"text-emerald-400":r.outcome==="loss"?"text-rose-400":"text-amber-400"),children:r.outcome==="win"?"VICTORY!":r.outcome==="loss"?"DEFEAT":"DRAW MATCH"}),e.jsxs("p",{className:"text-white/80 font-bold text-sm mb-4 uppercase tracking-widest",children:["Final Score: ",r.scoreFor," - ",r.scoreAgainst]}),e.jsxs("div",{className:"bg-black/50 rounded-xl p-4 mb-5 border border-white/5 flex flex-col gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white/40 text-[10px] font-black uppercase tracking-widest text-left mb-2",children:"Battle Score"}),(()=>{const t=r.roundResults||[];let o=0,p=0,x=0;for(const k of t)if(k.studentCorrect){o++;const R=o>=2?Math.min(15,(o-1)*5):0;p+=10,x+=R}else o=0;return e.jsxs(e.Fragment,{children:[e.jsx(da,{value:p,label:"Correct Answers",delay:300,icon:e.jsx(yt,{className:"h-3 w-3 text-emerald-400"})}),e.jsx(da,{value:x,label:"Streak Bonus",delay:900,icon:e.jsx(et,{className:"h-3 w-3 text-amber-400"})}),e.jsxs(y.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.5,duration:.4},className:"flex items-center justify-between pt-1 mt-1 border-t border-white/5",children:[e.jsx("span",{className:"text-white/50 text-xs font-bold uppercase tracking-widest",children:"Total"}),e.jsxs("span",{className:"text-base font-black text-white/80",children:[p+x," pts"]})]})]})})()]}),e.jsx("div",{className:"w-full h-px bg-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white/40 text-[10px] font-black uppercase tracking-widest text-left mb-2",children:"Match Reward"}),e.jsxs(y.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:2,duration:.5,type:"spring"},className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white/70 text-sm font-bold",children:r.outcome==="win"?"🏆 Victory Reward":r.outcome==="draw"?"🤝 Draw Reward":"📘 Participation Reward"}),e.jsxs("span",{className:"text-2xl font-black text-amber-400 drop-shadow-md",children:["+",r.xpEarned||(r.outcome==="win"?80:r.outcome==="draw"?55:35)," XP"]})]}),e.jsx("p",{className:"text-white/25 text-[9px] mt-1 text-right uppercase tracking-widest",children:"Credited to your profile"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 justify-center",children:[e.jsx(A,{size:"lg",onClick:()=>{_(null),v(null),h(!1),d("hub")},className:"w-full h-12 rounded-xl text-sm font-black bg-white/10 hover:bg-white/20 text-white border border-white/20",children:"BACK TO ARENA"}),r.mode==="bot"&&e.jsx(A,{size:"lg",onClick:()=>void Yt(),disabled:X,className:"w-full h-12 rounded-xl text-sm font-black bg-violet-600 hover:bg-violet-500 text-white border-b-2 border-violet-800 active:border-b-0 active:translate-y-[2px]",children:"REMATCH"})]})]})}):e.jsx(Aa,{activeMatch:r,roundSecondsLeft:D,lastRoundResult:B,selectedOptionIndex:ve,roundLocked:G,answerSubmitting:X,designPauseActive:M,onOptionSelect:t=>{B&&B.roundNumber===r.currentRound||X||G||(ma()?.resume().catch(()=>{}),P("lock"),Y(t),Ue(t))},floatingMomentum:Pa,lastRoundMomentumDelta:de,studentProfile:n,quizBattleAvatar:jt})}),e.jsx(Sa,{studentProfile:n,activeMatch:r,scorePulseTarget:Qa,quizBattleAvatar:jt})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsx(na,{bgVideo:"/videos/warp_bg.mp4",className:"-mx-3 lg:-mx-4 -mt-3 lg:-mt-4 -mb-8 px-4 sm:px-6 xl:px-10 py-6 sm:py-8 min-h-[calc(100vh-3.5rem)] !w-auto overflow-hidden relative",children:e.jsx("div",{className:"h-full flex flex-col max-w-[1400px] mx-auto w-full",children:e.jsx(y.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.24,ease:[.22,1,.36,1]},className:"space-y-3 lg:space-y-4",children:e.jsxs(Bs,{value:c,onValueChange:t=>d(t),children:[e.jsx(Ce,{value:"hub",className:"mt-0 outline-none",children:e.jsx(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-5",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] xl:grid-cols-[1fr_320px] gap-6 sm:gap-8 lg:gap-10",children:[e.jsxs("div",{className:"space-y-3 lg:space-y-4",children:[e.jsxs("div",{className:"relative select-none isolate bg-indigo-600 rounded-[2rem] shadow-[0_20px_45px_-15px_rgba(0,0,0,0.3)] shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-none z-0 rounded-[2rem]"}),e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none rounded-[2rem] overflow-hidden repeating-stripe-bg"}),e.jsx("div",{className:"absolute top-0 right-0 w-[400px] h-[400px] bg-sky-500/20 blur-[100px] rounded-full pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex flex-col md:flex-row items-center justify-between p-6 lg:p-8 h-full min-h-[140px] lg:min-h-[160px]",children:[e.jsx("div",{className:"flex-1 space-y-3 w-full pr-0 md:pr-[240px] lg:pr-[280px]",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"flex items-center gap-3 text-3xl sm:text-4xl lg:text-[46px] font-black tracking-tight text-white mb-2 sm:mb-4",children:[e.jsx(wt,{className:"h-8 w-8 sm:h-10 sm:w-10 lg:h-12 lg:w-12 text-[#d1abff]",strokeWidth:2.5}),"Quiz Battle"]}),e.jsx("p",{className:"text-base sm:text-lg lg:text-xl text-white mt-1.5 sm:mt-2 max-w-2xl leading-relaxed",children:"Timed student duels with synchronized rounds, instant feedback, and progression rewards."}),e.jsxs("p",{className:"text-xs lg:text-sm font-semibold uppercase tracking-[0.15em] text-[#8a7fbc] mt-3",children:["Connection: ",e.jsx("span",{className:Dt==="connected"?"text-emerald-400":"text-amber-400",children:Dt})]})]})}),e.jsx("div",{className:"hidden md:block absolute right-[-5px] lg:right-[-15px] top-0 lg:top-[5px] w-[200px] lg:w-[260px] shrink-0 pointer-events-none z-20",children:e.jsx("img",{src:jt,alt:"Mascot",className:"w-full h-full object-contain animate-mascot-float"})})]})]}),e.jsxs("div",{className:"pt-4 lg:pt-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 pb-4 text-xl lg:text-2xl font-black tracking-wide uppercase text-white drop-shadow-[0_0_12px_rgba(255,255,255,0.4)]",children:[e.jsx(wt,{className:"h-6 w-6 lg:h-8 lg:w-8 text-amber-400 drop-shadow-[0_0_8px_rgba(251,191,36,0.9)]"})," BATTLE MODES"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 lg:gap-6 relative z-10 w-full mb-2",children:[e.jsxs(y.button,{type:"button",onClick:()=>Xt("online"),whileHover:{scale:1.025},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:15},className:"w-full h-[205px] sm:h-[245px] lg:h-[265px] bg-[#8A3FD3] rounded-[22px] border-none relative text-left shadow-[0_8px_30px_rgba(138,63,211,0.2)] hover:shadow-[0_12px_45px_rgba(138,63,211,0.4)] block flex-col group",children:[e.jsx("div",{className:"absolute inset-0 rounded-[22px] shadow-[inset_0_6px_15px_rgba(255,255,255,0.4)] pointer-events-none z-40"}),e.jsxs("div",{className:"absolute top-4 -left-4 z-20 w-[100px] h-[40px] opacity-100",children:[e.jsx("svg",{viewBox:"0 0 100 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-full h-full block drop-shadow-md",children:e.jsx("path",{d:"M0 0 H94 Q100 0 100 6 V34 Q100 40 94 40 H0 L14 20 Z",fill:"#b91c1c"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-end pr-3 font-black text-[13px] text-white tracking-[0.3px] opacity-100 font-nunito",children:"VS Player"})]}),e.jsxs("div",{className:"rounded-[22px] overflow-hidden relative isolate h-full flex flex-col justify-end",children:[e.jsx("div",{className:"absolute top-0 -left-[150%] w-[100%] h-full bg-gradient-to-r from-transparent via-white/40 to-transparent -skew-x-12 z-50 pointer-events-none transition-all duration-0 group-hover:duration-[800ms] ease-in-out group-hover:left-[150%]"}),e.jsxs("div",{className:"flex-1 w-full flex items-end justify-center relative pt-2 pointer-events-none",children:[e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[70px] sm:h-[95px] bg-[#662AA8] rounded-[50%_50%_0_0/100%_100%_0_0] scale-[1.05] z-0"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-center mb-[2px] h-[120px] sm:h-[140px] w-full",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"h-[120%] sm:h-[125%] object-contain relative z-20 origin-bottom right-[-15px] drop-shadow-[0_12px_15px_rgba(0,0,0,0.3)] animate-avatar-left"}),e.jsx("div",{className:"relative z-30 flex flex-col items-center mx-[-20px] scale-[1.1] animate-vs-pulse",children:e.jsxs("span",{className:"font-black italic text-[40px] text-gray-200 tracking-tighter leading-none drop-shadow-[-2px_3px_0px_rgba(0,0,0,0.8)] webkit-text-stroke",children:[e.jsx("span",{className:"text-gray-300",children:"V"}),e.jsx("span",{className:"text-gray-400",children:"S"})]})}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"h-[120%] sm:h-[125%] object-contain relative z-10 scale-x-[-1] origin-bottom left-[-20px] drop-shadow-[0_12px_15px_rgba(0,0,0,0.3)] animate-avatar-right"})]})]}),e.jsx("div",{className:"relative z-10 w-full px-5 py-3 sm:py-4 text-center bg-[#662AA8]",children:e.jsx("p",{className:"text-[13px] font-bold text-white leading-[1.45] font-nunito",children:"Queue or room-code match with another student."})})]})]}),e.jsxs(y.button,{type:"button",onClick:()=>Xt("bot"),whileHover:{scale:1.025},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:15},className:"w-full h-[205px] sm:h-[245px] lg:h-[265px] bg-[#1FA7E1] rounded-[22px] border-none relative text-left shadow-[0_8px_30px_rgba(31,167,225,0.2)] hover:shadow-[0_12px_45px_rgba(31,167,225,0.4)] block flex-col group",children:[e.jsx("div",{className:"absolute inset-0 rounded-[22px] shadow-[inset_0_6px_15px_rgba(255,255,255,0.4)] pointer-events-none z-40"}),e.jsxs("div",{className:"absolute top-4 -left-4 z-20 w-[100px] h-[40px] opacity-100",children:[e.jsx("svg",{viewBox:"0 0 100 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-full h-full block drop-shadow-md",children:e.jsx("path",{d:"M0 0 H94 Q100 0 100 6 V34 Q100 40 94 40 H0 L14 20 Z",fill:"#b91c1c"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-end pr-3 font-black text-[13px] text-white tracking-[0.3px] opacity-100 font-nunito",children:"VS Bot"})]}),e.jsxs("div",{className:"rounded-[22px] overflow-hidden relative isolate h-full flex flex-col justify-end",children:[e.jsx("div",{className:"absolute top-0 -left-[150%] w-[100%] h-full bg-gradient-to-r from-transparent via-white/40 to-transparent -skew-x-12 z-50 pointer-events-none transition-all duration-0 group-hover:duration-[800ms] ease-in-out group-hover:left-[150%]"}),e.jsxs("div",{className:"flex-1 w-full flex items-end justify-center relative pt-2 pointer-events-none",children:[e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[70px] sm:h-[95px] bg-[#127DA6] rounded-[50%_50%_0_0/100%_100%_0_0] scale-[1.05] z-0"}),e.jsxs("div",{className:"relative z-10 flex items-end justify-center mb-[2px] h-[125px] sm:h-[145px] w-full",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"absolute opacity-40 blur-[1px] h-full object-contain origin-bottom -translate-x-[45px] sm:-translate-x-[60px] scale-[0.80] sm:scale-[0.85] animate-ghost-left"}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"absolute opacity-40 blur-[1px] h-full object-contain origin-bottom translate-x-[45px] sm:translate-x-[60px] scale-[0.80] sm:scale-[0.85] animate-ghost-right"}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"VS Bot",className:"relative opacity-100 scale-100 h-[105%] sm:h-[115%] object-contain drop-shadow-[0_15px_15px_rgba(0,0,0,0.3)] z-20 origin-bottom animate-main-avatar"})]})]}),e.jsx("div",{className:"relative z-10 w-full px-5 py-3 sm:py-4 text-center bg-[#127DA6]",children:e.jsx("p",{className:"text-[13px] font-bold text-white leading-[1.45] font-nunito",children:"Instant solo duel with selectable bot difficulty."})})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3 lg:space-y-4 flex flex-col h-full justify-between",children:[e.jsx("div",{onClick:()=>d("leaderboard"),className:"relative w-full bg-[#3b3a82] dark:bg-[#2b2b5f] rounded-[24px] overflow-hidden flex flex-col shadow-[0_8px_30px_rgba(59,58,130,0.3)] cursor-pointer group mb-4",children:e.jsxs("div",{className:"relative w-full h-[190px] flex flex-col items-center justify-end pt-8",children:[e.jsxs("div",{className:"absolute top-[25px] w-full flex justify-center items-end px-2 z-10 gap-3",children:[e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[32px] h-[32px] text-[#fcd34d] -rotate-[15deg] mb-2 drop-shadow-[0_0_15px_rgba(252,211,77,0.8)]"}),e.jsx("div",{className:"z-10 animate-star-float",children:e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[48px] h-[48px] text-[#fcd34d] drop-shadow-[0_0_25px_rgba(252,211,77,0.9)]"})}),e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[32px] h-[32px] text-[#fcd34d] rotate-[15deg] mb-2 drop-shadow-[0_0_15px_rgba(252,211,77,0.8)]"})]}),e.jsx("div",{className:"absolute bottom-[50px] left-1/2 -translate-x-1/2 w-[220px] h-[160px] bg-gradient-to-t from-white/20 to-transparent blur-[2px] z-0 pointer-events-none",style:{clipPath:"polygon(25% 0, 75% 0, 100% 100%, 0% 100%)"}}),e.jsxs("div",{className:"flex items-end justify-center z-10 relative px-4 bottom-[35px]",children:[e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx("div",{className:"w-[75px] h-[14px] bg-[#D44747] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[65px] h-[45px] bg-[#FE6464] flex flex-col items-center justify-center gap-2 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full"})]})]}),e.jsxs("div",{className:"flex flex-col items-center relative z-20 -mx-1",children:[e.jsx("div",{className:"w-[90px] h-[16px] bg-[#F39029] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[80px] h-[65px] bg-[#FFA23A] flex flex-col items-center justify-center gap-2.5 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-10 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-10 h-1.5 bg-white/90 rounded-full"})]})]}),e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx("div",{className:"w-[75px] h-[14px] bg-[#D44747] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[65px] h-[45px] bg-[#FE6464] flex flex-col items-center justify-center gap-2 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full"})]})]})]}),e.jsxs("div",{className:"absolute bottom-[2px] w-full flex justify-center z-30",children:[e.jsx("div",{className:"absolute top-[10px] w-full h-[35px] bg-[#8E1010] z-0"}),e.jsxs("div",{className:"relative w-[85%] h-[50px] bg-[#C62828] z-10 flex flex-col items-center justify-center rounded-[3px] shadow-[0_4px_10px_rgba(0,0,0,0.2)]",children:[e.jsx("h3",{className:"text-[18px] font-black text-white tracking-wide leading-none font-nunito mt-0.5",children:"Hall of Fame"}),e.jsx("span",{className:"text-[10px] font-bold text-white/90 tracking-wide mt-1",children:"View Page >"})]})]})]})}),e.jsxs("div",{className:"relative w-full bg-[#3b3a82] dark:bg-[#2b2b5f] rounded-[24px] overflow-hidden flex flex-col shadow-[0_8px_30px_rgba(59,58,130,0.3)]",children:[e.jsxs("div",{className:"flex flex-row items-center justify-between px-5 pt-5 pb-3 relative z-10",children:[e.jsx("h3",{className:"text-[20px] font-black text-white tracking-wide leading-none drop-shadow-md font-nunito",children:"My Stats"}),e.jsx(A,{className:"bg-[#7C51A8] hover:bg-[#6b4494] text-white font-bold text-[10px] tracking-widest uppercase rounded-full px-4 h-[28px] border border-white/10 shadow-md transition-transform active:scale-95",onClick:()=>d("stats"),children:"View Stats >"})]}),e.jsxs("div",{className:"relative z-10 w-full overflow-hidden pb-6",children:[e.jsx("div",{className:"absolute left-0 top-0 bottom-6 w-8 bg-gradient-to-r from-[#3b3a82] dark:from-[#2b2b5f] to-transparent z-20 pointer-events-none"}),e.jsx("div",{className:"absolute right-0 top-0 bottom-6 w-8 bg-gradient-to-l from-[#3b3a82] dark:from-[#2b2b5f] to-transparent z-20 pointer-events-none"}),e.jsx(y.div,{className:"flex w-max",animate:{x:["0%","-33.333333%"]},transition:{ease:"linear",duration:15,repeat:1/0},children:[1,2,3].map(t=>e.jsx("div",{className:"flex gap-3 pr-3",children:[{key:"totalXP",bg:"from-[#FF7B88] to-[#FF5C70]",shadow:"shadow-[0_4px_15px_rgba(255,92,112,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:et,value:n?.currentXP||0,label:"Total XP"},{key:"winRate",bg:"from-[#B467FF] to-[#9D44FF]",shadow:"shadow-[0_4px_15px_rgba(157,68,255,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:Kt,value:`${Math.round(te?.winRate||0)} %`,label:"Win Rate"},{key:"matches",bg:"from-[#4DB9E9] to-[#2DA1D8]",shadow:"shadow-[0_4px_15px_rgba(45,161,216,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:At,value:te?.matchesPlayed||0,label:"Matches"},{key:"response",bg:"from-[#48DA94] to-[#2BBF7B]",shadow:"shadow-[0_4px_15px_rgba(43,191,123,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:ra,value:te?.averageResponseMs?`${(te.averageResponseMs/1e3).toFixed(0)}s`:"0s",label:"Response"}].map(o=>e.jsxs("div",{className:u("w-[90px] sm:w-[100px] shrink-0 aspect-square rounded-[16px] bg-gradient-to-br p-3 flex flex-col justify-between relative overflow-hidden group",o.bg,o.shadow),children:[e.jsx("div",{className:"absolute -bottom-6 -right-6 text-white/10 transition-transform duration-500 group-hover:scale-110",children:e.jsx(o.icon,{className:"w-20 h-20"})}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center relative z-10 shadow-[inset_0_1px_3px_rgba(255,255,255,0.5)]",children:e.jsx(o.icon,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"relative z-10 flex flex-col",children:[e.jsx("h4",{className:"text-[14px] sm:text-[16px] lg:text-[18px] font-black text-white leading-none tracking-tight drop-shadow-sm",children:o.value}),e.jsx("p",{className:"text-[8px] sm:text-[9px] font-extrabold text-white/80 uppercase tracking-widest mt-1 truncate",children:o.label})]})]},o.key))},t))})]})]}),e.jsxs(pe,{className:u(fe,"rounded-[18px] flex flex-col min-h-[200px]"),children:[e.jsxs(he,{className:"pb-0 pt-3 px-4 flex flex-row items-center justify-between",children:[e.jsxs(be,{className:"text-[14px] font-black flex items-center gap-2 text-[#2e2b5e] dark:text-[#f5f7fb]",children:[e.jsx(ns,{className:"h-[16px] w-[16px] text-[#2e2b5e] dark:text-[#9e8fff]"})," Match History"]}),e.jsx(A,{variant:"link",size:"sm",className:"h-auto p-0 text-[12px] font-semibold text-muted-foreground dark:text-[#95a0bb] hover:text-primary transition-colors",onClick:()=>d("history"),children:"View All"})]}),e.jsxs(Ge,{className:"space-y-1.5 px-4 pt-1 pb-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[11px] text-muted-foreground dark:text-[#8b95ad] mb-1.5 leading-relaxed",children:"Your recent student battles only."}),Pt?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"h-10 w-full rounded-xl bg-muted dark:bg-[#2a3143]"}),e.jsx(xe,{className:"h-10 w-full rounded-xl bg-muted dark:bg-[#2a3143]"})]}):He.length===0?e.jsx("p",{className:"text-xs text-center text-muted-foreground dark:text-[#a8b2c9] py-2",children:"No battle history yet."}):He.slice(0,3).map(t=>{const o=t.outcome==="win",p=t.outcome==="loss",x=t.opponentName.split(" ").map(k=>k[0]).join("").substring(0,2).toUpperCase()||"OP";return e.jsxs("div",{className:"group relative overflow-hidden rounded-[14px] border border-muted-foreground/15 bg-white dark:bg-[#11151d] dark:border-[#2f3547] p-2 shadow-sm transition-all hover:scale-[1.01] hover:shadow-md",children:[e.jsx("div",{className:u("absolute inset-y-0 right-0 w-[55%] pointer-events-none opacity-[0.2] dark:opacity-[0.25] mix-blend-multiply dark:mix-blend-screen transition-all",o?"bg-gradient-to-l from-emerald-500 via-emerald-500/40 to-transparent":p?"bg-gradient-to-l from-rose-500 via-rose-500/40 to-transparent":"bg-gradient-to-l from-amber-400 via-amber-400/40 to-transparent")}),e.jsxs("div",{className:"flex items-center gap-2.5 relative z-10 w-full",children:[e.jsx("div",{className:u("w-9 h-9 rounded-full flex items-center justify-center font-black text-[12px] tracking-wide text-white flex-shrink-0 shadow-inner",o?"bg-[#34d399] dark:bg-[#15803d]":p?"bg-[#fb7185] dark:bg-[#be123c]":"bg-[#fbbf24] dark:bg-[#b45309]"),children:x}),e.jsxs("div",{className:"flex-grow min-w-0 flex flex-col justify-center",children:[e.jsxs("p",{className:"text-[13px] font-extrabold text-[#36326e] dark:text-[#e4e7f1] truncate leading-tight",children:["vs ",t.opponentName]}),e.jsxs("p",{className:"text-[10px] font-bold text-muted-foreground/60 dark:text-[#7f88a3] truncate flex items-center gap-1 mt-0.5",children:[t.subjectId," ",e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground/30"})," ",t.difficulty||"Medium"," ",e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground/30"})," ",t.rounds||"5"," rnds"]})]}),e.jsxs("div",{className:"text-right flex flex-col items-end justify-center pl-2 flex-shrink-0",children:[e.jsxs("p",{className:"tabular-nums text-[16px] leading-[1.1] font-black text-[#2e2b5e] dark:text-[#f5f7fb] tracking-tighter",children:[t.scoreFor,e.jsx("span",{className:"text-muted-foreground/40 mx-[1px]",children:"-"}),t.scoreAgainst]}),e.jsx("p",{className:u("text-[9px] font-black uppercase tracking-[0.1em]",o?"text-emerald-500 dark:text-emerald-400":p?"text-rose-500 dark:text-rose-400":"text-amber-500 dark:text-amber-400"),children:t.outcome})]})]})]},t.matchId)})]})]})]})]})},"hub")}),e.jsx(Ce,{value:"setup",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"w-full space-y-6",children:[e.jsxs(y.div,{className:u(fe,"relative overflow-hidden rounded-[24px] mb-6 shadow-lg",l.mode==="online"?"border-purple-500/20 shadow-[0_0_40px_-10px_rgba(138,63,211,0.2)]":"border-sky-500/20 shadow-[0_0_40px_-10px_rgba(31,167,225,0.2)]"),whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:u("pointer-events-none absolute inset-0 bg-gradient-to-r",l.mode==="online"?"from-purple-500/20 via-fuchsia-500/10 to-purple-600/5 dark:from-purple-500/20 dark:via-fuchsia-500/10 dark:to-purple-900/10":"from-sky-500/20 via-cyan-500/10 to-sky-600/5 dark:from-sky-500/20 dark:via-cyan-500/10 dark:to-sky-900/10")}),e.jsx("div",{className:u("pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full blur-3xl animate-orb-pulse",l.mode==="online"?"bg-purple-400/20":"bg-sky-400/20")}),e.jsx("div",{className:u("pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full blur-2xl animate-orb-pulse-delayed",l.mode==="online"?"bg-fuchsia-400/30":"bg-cyan-400/30")}),e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAiLz4KPHBhdGggZD0iTTAgMEgxdjFIMHoiIGZpbGw9IiM2MzY2ZjEiIGZpbGwtb3BhY2l0eT0iMC4wNSIvPgo8L3N2Zz4=')] opacity-30 dark:opacity-10 mix-blend-overlay"}),e.jsxs("div",{className:"relative p-6 sm:p-8 md:px-10 flex items-center gap-5 sm:gap-8 z-10",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:u("h-12 w-12 sm:h-14 sm:w-14 p-0 rounded-full hover:scale-105 transition-all backdrop-blur-md shadow-lg shrink-0 flex items-center justify-center group",l.mode==="online"?"bg-white/50 dark:bg-black/40 hover:bg-white/80 dark:hover:bg-black/60 border border-purple-500/30":"bg-white/50 dark:bg-black/40 hover:bg-white/80 dark:hover:bg-black/60 border border-sky-500/30"),children:e.jsx(We,{className:u("h-6 w-6 sm:h-8 sm:w-8 rotate-180 transition-transform group-hover:-translate-x-0.5",l.mode==="online"?"text-purple-800 dark:text-purple-300":"text-sky-800 dark:text-sky-300")})}),e.jsxs("div",{children:[e.jsxs("h2",{className:u("flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-transparent bg-clip-text bg-gradient-to-br drop-shadow-sm",l.mode==="online"?"from-purple-600 to-fuchsia-500 dark:from-purple-300 dark:to-fuchsia-200":"from-sky-600 to-cyan-500 dark:from-sky-300 dark:to-cyan-200"),children:[e.jsx("div",{className:u("p-2 rounded-2xl shadow-inner border animate-icon-bob",l.mode==="online"?"bg-purple-100 dark:bg-purple-900/50 border-purple-200 dark:border-purple-700/50":"bg-sky-100 dark:bg-sky-900/50 border-sky-200 dark:border-sky-700/50"),children:l.mode==="online"?e.jsx(ge,{className:"h-8 w-8 text-purple-600 dark:text-purple-400 drop-shadow-[0_0_8px_rgba(138,63,211,0.5)]"}):e.jsx(Te,{className:"h-8 w-8 text-sky-600 dark:text-sky-400 drop-shadow-[0_0_8px_rgba(31,167,225,0.5)]"})}),l.mode==="online"?"1v1 Online":"1v1 vs Bot"]}),e.jsx("p",{className:u("text-[10px] sm:text-[12px] font-black uppercase tracking-[0.2em] mt-1.5 drop-shadow-sm",l.mode==="online"?"text-purple-600/80 dark:text-purple-400/80":"text-sky-600/80 dark:text-sky-400/80"),children:l.mode==="online"?"CHALLENGE YOUR SCHOOLMATES AND PROVE YOUR SKILLS.":"CHALLENGE THE AI AND SHARPEN YOUR SKILLS."})]})]})]}),e.jsx("div",{className:"rounded-[24px] border border-white/40 bg-white/85 dark:border-white/10 dark:bg-black/80 backdrop-blur-xl p-5 sm:p-7 shadow-xl",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-10",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Category"}),e.jsxs(Ne,{value:l.subjectId,onValueChange:t=>w(o=>({...o,subjectId:t})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("subjectId")&&"border-rose-400"),children:e.jsx(_e,{placeholder:"Select category"})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:ie.map(t=>e.jsx(K,{value:t.id,className:"rounded-lg",children:t.title},t.id))})]}),V("subjectId")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("subjectId")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Strand / Topic Group"}),e.jsxs(Ne,{value:l.topicId,onValueChange:t=>w(o=>({...o,topicId:t})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("topicId")&&"border-rose-400"),children:e.jsx(_e,{placeholder:"Select topic group"})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:qa.map(t=>e.jsx(K,{value:t.value,className:"rounded-lg",children:t.label},t.value))})]}),V("topicId")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("topicId")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:l.mode==="online"?"Difficulty":"Bot Difficulty"}),e.jsxs(Ne,{value:l.mode==="bot"?l.adaptiveBot?"adaptive":l.botDifficulty:l.difficulty,onValueChange:t=>w(o=>o.mode==="bot"?{...o,botDifficulty:t,adaptiveBot:t==="adaptive"}:{...o,difficulty:t}),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50"),children:e.jsx(_e,{})}),e.jsxs(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[e.jsx(K,{value:"easy",className:"rounded-lg",children:"Easy"}),e.jsx(K,{value:"medium",className:"rounded-lg",children:"Medium"}),e.jsx(K,{value:"hard",className:"rounded-lg",children:"Hard"}),l.mode==="bot"&&e.jsx(K,{value:"adaptive",className:"rounded-lg",children:"Adaptive"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[10px] sm:text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Questions"}),e.jsxs(Ne,{value:String(l.rounds),onValueChange:t=>w(o=>({...o,rounds:Number(t)})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("rounds")&&"border-rose-400"),children:e.jsx(_e,{})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[3,5,7,10,12,15].map(t=>e.jsx(K,{value:String(t),className:"rounded-lg",children:t},t))})]}),V("rounds")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("rounds")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[10px] sm:text-[11px] font-black uppercase tracking-[0.12em] ml-1 line-clamp-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Time / Q"}),e.jsxs(Ne,{value:String(l.timePerQuestionSec),onValueChange:t=>w(o=>({...o,timePerQuestionSec:Number(t)})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("timePerQuestionSec")&&"border-rose-400"),children:e.jsx(_e,{})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[15,20,30,45,60,90].map(t=>e.jsxs(K,{value:String(t),className:"rounded-lg",children:[t," sec"]},t))})]}),V("timePerQuestionSec")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("timePerQuestionSec")})]})]})]}),e.jsxs("div",{className:"flex flex-col justify-between space-y-6",children:[e.jsxs("div",{className:"space-y-5",children:[l.mode==="online"&&e.jsxs("div",{className:"space-y-3 rounded-2xl border border-[#8A3FD3]/20 bg-[#8A3FD3]/5 dark:border-[#8A3FD3]/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[11px] font-black uppercase tracking-[0.12em] text-[#8A3FD3] dark:text-[#a35ceb] ml-1",children:"Online Match Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"public_matchmaking",label:"Public Queue"},{value:"private_room",label:"Private Room"}].map(t=>e.jsx(A,{type:"button",variant:l.queueType===t.value?"default":"outline",className:u("rounded-xl h-11 transition-all border-none font-bold text-xs",l.queueType===t.value?"bg-[#8A3FD3] hover:bg-[#7b35c0] text-white shadow-md shadow-[#8A3FD3]/30":"bg-white/50 hover:bg-white/80 dark:bg-black/30 dark:hover:bg-black/50 text-[#8A3FD3] dark:text-[#d3a8ff]"),onClick:()=>w(o=>({...o,queueType:t.value})),children:t.label},t.value))})]}),l.queueType==="private_room"&&e.jsxs(y.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"pt-2 space-y-2",children:[e.jsx("label",{className:"text-[11px] font-black uppercase tracking-[0.12em] text-[#8A3FD3] dark:text-[#a35ceb] ml-1",children:"Room Code (optional)"}),e.jsx(ts,{value:U,onChange:t=>S(t.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6)),placeholder:"Leave blank to create a room",className:"rounded-xl h-12 text-center text-lg uppercase font-bold tracking-[0.25em] border-[#8A3FD3]/30 bg-white/80 dark:bg-black/50 dark:border-[#8A3FD3]/20 focus-visible:ring-[#8A3FD3]/50 shadow-inner",maxLength:6}),e.jsx("div",{className:"rounded-xl border border-[#8A3FD3]/30 bg-[#8A3FD3]/10 px-3 py-3 text-[12px] font-semibold text-[#6620a2] leading-snug dark:border-[#8A3FD3]/30 dark:bg-[#8A3FD3]/10 dark:text-[#d3a8ff]",children:"Enter a room code to join an existing battle, or leave it blank to create a new room and share your code."})]})]}),e.jsxs("label",{className:u("flex flex-col sm:flex-row sm:items-center justify-between rounded-[16px] border bg-white/50 p-4 transition-colors cursor-pointer shadow-sm dark:bg-black/50 group",l.mode==="online"?"border-[#8A3FD3]/20 hover:bg-[#8A3FD3]/5 dark:border-[#8A3FD3]/20 dark:hover:bg-[#8A3FD3]/10":"border-[#1FA7E1]/20 hover:bg-[#1FA7E1]/5 dark:border-[#1FA7E1]/20 dark:hover:bg-[#1FA7E1]/10"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:u("h-11 w-11 rounded-full flex items-center justify-center group-hover:scale-110 transition-transform",l.mode==="online"?"bg-[#8A3FD3]/10 text-[#8A3FD3] dark:text-[#c48bfc]":"bg-[#1FA7E1]/10 text-[#1FA7E1] dark:text-[#7ad8ff]"),children:J?e.jsx(fa,{className:"h-5 w-5"}):e.jsx(ga,{className:"h-5 w-5 opacity-60"})}),e.jsxs("div",{className:"mb-3 sm:mb-0",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 dark:text-slate-200",children:"Battle Sounds"}),e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Cues for countdowns and results."})]})]}),e.jsx(aa,{checked:J,onCheckedChange:Tt})]}),e.jsxs(y.div,{initial:!1,animate:{opacity:J?1:.45,y:J?0:-2},className:u("rounded-[16px] border bg-white/40 p-4 shadow-sm dark:bg-black/40",l.mode==="online"?"border-[#8A3FD3]/20 dark:border-[#8A3FD3]/20":"border-[#1FA7E1]/20 dark:border-[#1FA7E1]/20"),children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.14em] text-slate-700 dark:text-slate-200",children:"SFX Volume"}),e.jsxs("p",{className:"text-xs font-bold text-slate-500 dark:text-slate-400",children:[Math.round(ce*100),"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,step:1,value:Math.round(ce*100),disabled:!J,onChange:t=>{const o=Ze(Number(t.target.value)/100,0,1);Ca(o)},onMouseUp:()=>P("tick"),onTouchEnd:()=>P("tick"),className:"h-2 w-full cursor-pointer accent-violet-500 disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Battle sound effects volume"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{"aria-live":"polite",className:"min-h-[24px] text-sm font-medium",children:[N.status==="queued"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:u("inline-flex items-center gap-1 text-[13px] font-bold px-3 py-1.5 rounded-lg",l.mode==="online"?"text-[#8A3FD3] bg-[#8A3FD3]/10":"text-[#1FA7E1] bg-[#1FA7E1]/10"),children:N.message}),l.mode==="online"&&l.queueType==="private_room"&&m?.roomCode&&e.jsxs(A,{type:"button",variant:"outline",className:u("h-8 rounded-full border-emerald-500/50 bg-emerald-50 px-4 text-xs font-black uppercase tracking-[0.16em] text-emerald-900 shadow-sm hover:bg-emerald-100 hover:scale-105 transition-all dark:border-emerald-500/40 dark:bg-emerald-500/10 dark:text-emerald-300 dark:hover:bg-emerald-500/20",E===m.roomCode&&"scale-105 bg-emerald-200 dark:bg-emerald-500/30"),onClick:()=>void Ht(m.roomCode),"aria-label":`Copy room code ${m.roomCode}`,children:[E===m.roomCode?e.jsx(yt,{className:"h-4 w-4"}):e.jsx(sa,{className:"h-4 w-4"}),m.roomCode]}),(j||Zt)&&ee>0&&e.jsxs("span",{className:u("inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-bold animate-pulse",l.mode==="online"?"bg-[#8A3FD3]/10 text-[#8A3FD3]":"bg-[#1FA7E1]/10 text-[#1FA7E1]"),children:["Waiting ",ca(ee)]})]}),N.status==="error"&&e.jsx("span",{className:"inline-flex items-center gap-1.5 text-[13px] font-bold text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-500/10 px-3 py-1.5 rounded-lg border border-rose-200 dark:border-rose-500/20",children:N.message}),N.status==="validating"&&e.jsxs("span",{className:u("inline-flex items-center gap-2 font-bold px-3 py-1.5 rounded-lg",l.mode==="online"?"text-[#8A3FD3] bg-[#8A3FD3]/10":"text-[#1FA7E1] bg-[#1FA7E1]/10"),children:[e.jsx(Je,{className:"h-4 w-4 animate-spin"})," Validating..."]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[Ha&&e.jsx(A,{type:"button",variant:"outline",onClick:Gt,disabled:N.status==="validating",className:"rounded-xl h-14 flex-1 sm:flex-none border-slate-300 hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800 font-bold px-6",children:m?"Cancel room":"Leave queue"}),e.jsx(A,{type:"button",onClick:Oa,disabled:N.status==="validating"||j||Zt,className:u("rounded-xl h-14 flex-1 px-8 font-black uppercase tracking-wide text-sm shadow-xl hover:scale-[1.02] active:scale-95 transition-all text-white border-0",l.mode==="online"?"bg-[#8A3FD3] hover:bg-[#7b35c0] shadow-[#8A3FD3]/40":"bg-[#1FA7E1] hover:bg-[#1a95c9] shadow-[#1FA7E1]/40"),children:N.status==="validating"?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(Je,{className:"h-5 w-5 animate-spin"})," Starting..."]}):l.mode==="online"&&l.queueType==="private_room"?U.trim()?"Join Room":"Create Room":"Start Battle"})]})]})]})]})})]},"setup")}),e.jsx(Ce,{value:"battle",className:"mt-0 outline-none",children:e.jsx(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:r?e.jsxs(pe,{className:u(fe,"rounded-[18px]"),children:[e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.mode==="bot"?e.jsx(Te,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}):e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"vs ",r.opponentName]}),e.jsxs("div",{className:"inline-flex items-center gap-2",children:[gt,e.jsxs("span",{className:"text-sm font-bold tabular-nums",children:[r.scoreFor," - ",r.scoreAgainst]})]})]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:r.status==="completed"?`Completed in ${r.totalRounds} rounds.`:r.status==="ready"?r.mode==="online"?"Waiting for both players to confirm and start together.":"Finalizing practice bot session start.":`Round ${r.currentRound} of ${r.totalRounds}${M?" (paused for design)":""}`}),ua(r.lifecycle,n?.uid)&&e.jsx("p",{className:"text-xs font-medium text-muted-foreground dark:text-[#9aa4be]",children:ua(r.lifecycle,n?.uid)})]}),e.jsxs(Ge,{className:"space-y-4",children:[r.status==="ready"&&e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-4 dark:border-[#2f3547] dark:bg-[#11151d] flex flex-col gap-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:r.mode==="online"?"Waiting for both players to lock in start...":"Starting practice bot round..."}),r.mode==="online"&&r.expiresAtMs&&e.jsxs("p",{className:"text-xs font-medium text-muted-foreground dark:text-[#9aa4be]",children:["Public match expires in ",e.jsx("span",{className:"font-semibold tabular-nums",children:ca(ee)})," if the synchronized start does not happen."]}),e.jsx(A,{variant:"outline",size:"sm",className:"w-full text-rose-500 border-rose-200 hover:bg-rose-50 dark:border-rose-900 dark:hover:bg-rose-900/30",onClick:()=>{_(null),v(null),h(!1),b({status:"idle"}),d("setup")},children:"Force Cancel"})]}),r.status==="in_progress"&&r.currentQuestion&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-border bg-muted/40 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Time left: ",e.jsxs("span",{className:"font-semibold tabular-nums",children:[D,"s"]}),M?" (paused)":""]}),M&&e.jsx("p",{className:"mt-1 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:"Design pause keeps this battle screen static while you edit UI."})]}),e.jsx("p",{className:"text-lg font-bold text-foreground dark:text-[#f5f7fb]",children:r.currentQuestion.prompt}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.currentQuestion.choices.map((t,o)=>e.jsxs(A,{type:"button",variant:ve===o?"default":"outline",onClick:()=>Y(o),disabled:X||G||M,className:u("h-auto min-h-[48px] justify-start text-left font-medium px-4 py-3 rounded-xl whitespace-normal",ve===o?"ring-2 ring-primary ring-offset-2 dark:ring-offset-[#0B0F19]":""),children:[e.jsxs("span",{className:"mr-2 font-semibold",children:[String.fromCharCode(65+o),"."]}),t]},o))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(A,{type:"button",onClick:()=>void Ue(ve),disabled:X||G||M,className:"rounded-xl",children:M?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(is,{className:"h-4 w-4"})," Paused for design"]}):X?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4 animate-spin"})," Submitting..."]}):G?"Waiting for opponent...":"Lock Answer"})})]}),B&&e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:["Last round: ",B.studentCorrect?"Correct":"Incorrect"," · ",r.mode==="bot"?"Bot":"Opponent"," ",B.botCorrect?"Correct":"Incorrect"]}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Correct option: ",String.fromCharCode(65+B.correctOptionIndex)]})]}),r.status==="completed"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:u("rounded-2xl border p-4",r.outcome==="win"?"border-emerald-300 bg-emerald-50 dark:border-emerald-400/40 dark:bg-emerald-900/20":r.outcome==="loss"?"border-rose-300 bg-rose-50 dark:border-rose-400/40 dark:bg-rose-900/20":"border-amber-300 bg-amber-50 dark:border-amber-400/40 dark:bg-amber-900/20"),children:[e.jsx("p",{className:"text-lg font-black tracking-wide text-foreground dark:text-[#ecf0fb]",children:r.outcome==="win"?"Victory!":r.outcome==="loss"?"Match Complete":"Draw Match"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:["Final Score: ",r.scoreFor," - ",r.scoreAgainst]}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["XP Earned: +",r.xpBreakdown?.totalXPAwarded??r.xpEarned??0,r.xpBreakdown&&e.jsxs("span",{className:"block",children:["Base: +",r.xpBreakdown.baseMatchXP," + Performance: +",r.xpBreakdown.performanceXP]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(A,{type:"button",variant:"outline",onClick:()=>{_(null),v(null),h(!1),d("setup")},className:"rounded-xl",children:"Start New Match"}),r.mode==="bot"&&e.jsx(A,{type:"button",onClick:()=>void Yt(),disabled:X,className:"rounded-xl",children:"Rematch"})]})]})]})]}):m?e.jsxs(pe,{className:u(fe,"rounded-[18px]"),children:[e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"Private Room Lobby"]}),e.jsxs(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:["Room ",m.roomCode," · ",m.participantCount,"/2 students connected."]})]}),e.jsx(Ge,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:m.status==="ready"?"Opponent connected. Syncing start...":"Waiting for another student to join this room."}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Share room code ",m.roomCode," with your classmate."]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[(m.status==="waiting"||m.status==="ready")&&e.jsx(A,{type:"button",variant:"outline",className:"h-8 rounded-lg",onClick:Gt,disabled:N.status==="validating",children:"Cancel room"}),e.jsxs(A,{type:"button",variant:"outline",className:"h-8 rounded-lg",onClick:()=>void Ht(m.roomCode),children:[E===m.roomCode?e.jsx(yt,{className:"h-4 w-4"}):e.jsx(sa,{className:"h-4 w-4"}),E===m.roomCode?"Copied":"Copy code"]})]})]})})]}):j?e.jsx(pe,{className:u(fe,"rounded-[18px]"),children:e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"Public Matchmaking"]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:"Searching for a student with the same setup..."})]})}):e.jsx(pe,{className:u(fe,"rounded-[18px]"),children:e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(wt,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"No active battle"]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:"Start from Setup to create a bot match, private room, or public queue session."})]})})},"battle")}),e.jsx(Ce,{value:"history",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-emerald-500/10 via-teal-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-emerald-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-teal-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(16,185,129,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-emerald-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx("div",{className:"bg-emerald-500/20 p-2 rounded-2xl shadow-inner border border-emerald-500/30",children:e.jsxs("div",{className:"relative w-8 h-8 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-5 h-6 bg-emerald-500/30 border border-emerald-400/50 rounded-sm -rotate-12 translate-x-1 shadow-sm"}),e.jsx("div",{className:"absolute w-5 h-6 bg-teal-400/50 border border-teal-300/60 rounded-sm rotate-6 -translate-x-1 shadow-md backdrop-blur-sm"}),e.jsxs("div",{className:"absolute w-5 h-6 bg-gradient-to-br from-emerald-400 to-teal-500 rounded-sm shadow-[0_0_15px_rgba(52,211,153,0.8)] z-10 flex flex-col items-center justify-center gap-[3px]",children:[e.jsx("div",{className:"w-2.5 h-[2px] bg-white/90 rounded-full"}),e.jsx("div",{className:"w-3 h-[2px] bg-white/90 rounded-full"}),e.jsx("div",{className:"w-2 h-[2px] bg-white/90 rounded-full"})]})]})}),"Matches History"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"Review your past duels and track your progress."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[-10%] right-[-5%] w-[400px] h-[400px] bg-blue-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[-10%] left-[-5%] w-[350px] h-[350px] bg-teal-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsxs("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-xl font-black text-white tracking-wide leading-none drop-shadow-md",children:"Match History"}),e.jsx("p",{className:"text-sm font-semibold text-white/60 mt-2",children:"Your recent student battles only."})]}),e.jsx("div",{className:"flex gap-2 mb-6",children:[{value:"all",label:"All"},{value:"online",label:"Online"},{value:"bot",label:"Bot"}].map(t=>e.jsx(A,{type:"button",variant:"outline",onClick:()=>za(t.value),className:u("rounded-full h-9 px-5 border transition-all font-bold tracking-wide",we===t.value?"bg-emerald-500/20 border-emerald-500/50 text-emerald-300 shadow-[0_0_15px_rgba(16,185,129,0.2)]":"bg-white/5 border-white/10 text-white/70 hover:bg-white/10 hover:text-white"),children:t.label},t.value))}),e.jsx("div",{className:"space-y-4",children:Pt?e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{className:"h-[76px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[76px] w-full rounded-2xl bg-white/5 border border-white/10"})]}):He.length===0?e.jsx("p",{className:"text-sm text-white/50 py-4",children:"No matches in this filter yet."}):He.map(t=>{const o=t.outcome==="win",p=t.outcome==="loss";return e.jsxs("div",{className:"relative overflow-hidden rounded-[20px] bg-white/5 border border-white/10 p-5 flex items-center justify-between shadow-lg transition-all hover:bg-white/10 hover:shadow-xl",children:[e.jsx("div",{className:u("absolute inset-y-0 left-0 w-3/4 pointer-events-none z-0",o?"bg-gradient-to-r from-emerald-500/50 via-emerald-500/10 to-transparent":p?"bg-gradient-to-r from-rose-500/50 via-rose-500/10 to-transparent":"bg-gradient-to-r from-amber-500/50 via-amber-500/10 to-transparent")}),e.jsxs("div",{className:"relative z-10 pl-2",children:[e.jsxs("p",{className:"text-base sm:text-lg font-black text-white drop-shadow-md",children:["vs ",t.opponentName]}),e.jsxs("p",{className:"text-[13px] font-bold text-white/60 tabular-nums mt-0.5",children:[t.scoreFor,"-",t.scoreAgainst," ",e.jsx("span",{className:"mx-1",children:"•"})," ",t.accuracy.toFixed(0),"% ",e.jsx("span",{className:"mx-1",children:"•"})," +",t.xpEarned," XP"]})]}),e.jsx("div",{className:"relative z-10",children:e.jsx("span",{className:u("text-sm font-black uppercase tracking-[0.1em] rounded-full px-4 py-1.5 border shadow-sm",o?"text-emerald-300 border-emerald-500/30 bg-emerald-500/10 shadow-[0_0_15px_rgba(16,185,129,0.15)]":p?"text-rose-300 border-rose-500/30 bg-rose-500/10 shadow-[0_0_15px_rgba(244,63,94,0.15)]":"text-amber-300 border-amber-500/30 bg-amber-500/10 shadow-[0_0_15px_rgba(245,158,11,0.15)]"),children:Ts(t.outcome)})})]},t.matchId)})})]})]})]},"history")}),e.jsx(Ce,{value:"stats",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-indigo-500/10 via-purple-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-indigo-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-purple-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(99,102,241,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-indigo-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx("div",{className:"bg-indigo-500/20 p-2 rounded-2xl shadow-inner border border-indigo-500/30 animate-icon-bob",children:e.jsxs("div",{className:"relative w-8 h-8 flex items-end justify-center gap-1 pb-1",children:[e.jsx("div",{className:"w-1.5 h-3 bg-indigo-300 rounded-t-[2px] shadow-[0_0_8px_rgba(165,180,252,0.8)]"}),e.jsx("div",{className:"w-1.5 h-6 bg-purple-400 rounded-t-[2px] shadow-[0_0_12px_rgba(192,132,252,0.9)]"}),e.jsx("div",{className:"w-1.5 h-4 bg-indigo-400 rounded-t-[2px] shadow-[0_0_8px_rgba(129,140,248,0.8)]"})]})}),"My Statistics"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"Analyzing your battlefield performance."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[0%] left-[10%] w-[350px] h-[350px] bg-indigo-500/30 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[0%] right-[10%] w-[300px] h-[300px] bg-purple-500/30 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 sm:gap-6",children:[{label:"WINS",value:te?.wins??0,icon:Kt,textColor:"text-rose-400",gradient:"radial-gradient(circle at 10% 90%, rgba(244,63,94,0.35) 0%, transparent 70%)"},{label:"CURRENT STREAK",value:te?.currentStreak??0,icon:et,textColor:"text-purple-400",gradient:"radial-gradient(circle at 10% 90%, rgba(168,85,247,0.35) 0%, transparent 70%)"},{label:"AVG ACCURACY",value:`${(te?.averageAccuracy||0).toFixed(1)}%`,icon:At,textColor:"text-blue-400",gradient:"radial-gradient(circle at 10% 90%, rgba(59,130,246,0.35) 0%, transparent 70%)"},{label:"AVG RESPONSE",value:Rs(te?.averageResponseMs||0),icon:ra,textColor:"text-teal-400",gradient:"radial-gradient(circle at 10% 90%, rgba(20,184,166,0.35) 0%, transparent 70%)"}].map(t=>e.jsxs("div",{className:"relative overflow-hidden rounded-[20px] bg-white/5 border border-white/10 shadow-lg min-h-[160px] flex flex-col justify-between p-6 transition-transform hover:scale-105",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none z-0 mix-blend-screen",style:{background:t.gradient}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("p",{className:u("text-[11px] font-black uppercase tracking-[0.15em] mb-3",t.textColor),children:t.label}),e.jsx("p",{className:"text-4xl sm:text-5xl font-black text-white tabular-nums tracking-tighter drop-shadow-md",children:t.value})]}),e.jsx("div",{className:"relative z-10 mt-6 flex justify-start",children:e.jsx(t.icon,{className:u("h-5 w-5 drop-shadow-md",t.textColor)})})]},t.label))})})]})]},"stats")}),e.jsx(Ce,{value:"leaderboard",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-amber-500/10 via-orange-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-amber-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-orange-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(245,158,11,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-amber-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx(y.div,{animate:{scale:[1,1.1,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"bg-amber-500/20 p-2 rounded-2xl shadow-inner border border-amber-500/30",children:e.jsx(Jt,{className:"h-8 w-8 text-amber-400 drop-shadow-[0_0_12px_rgba(245,158,11,0.8)]"})}),"Hall of Fame"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"The top-ranked minds across the globe."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[20%] left-[20%] w-[400px] h-[400px] bg-orange-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[350px] h-[350px] bg-pink-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsxs("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:[e.jsxs("div",{className:"mb-8 flex items-start gap-3",children:[e.jsx(Jt,{className:"h-8 w-8 text-amber-400 drop-shadow-[0_0_12px_rgba(245,158,11,0.6)] shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-black text-white tracking-wide leading-none drop-shadow-md",children:"Hall of Fame"}),e.jsx("p",{className:"text-sm font-semibold text-white/60 mt-2",children:"Student-only ranking using trusted backend aggregates."})]})]}),Ia?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"})]}):Wt.length===0?e.jsx("p",{className:"text-sm text-white/50",children:"No leaderboard entries yet. Finish a battle to place on the board."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-4 transition-colors hover:bg-white/10",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-white/50 mb-3",children:"Name display"}),e.jsxs(Ne,{value:Qe,onValueChange:t=>Ma(t),children:[e.jsx(ke,{className:"h-10 rounded-xl bg-black/20 border-white/10 text-white font-bold hover:bg-black/30",children:e.jsx(_e,{})}),e.jsxs(Se,{className:"rounded-xl border border-white/10 bg-[#161a25]/95 backdrop-blur-xl",children:[e.jsx(K,{value:"alias",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Alias"}),e.jsx(K,{value:"initials",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Initials"}),e.jsx(K,{value:"full",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Full name"})]})]})]}),e.jsxs("label",{className:"rounded-2xl border border-white/10 bg-white/5 p-4 flex items-center justify-between gap-4 transition-colors hover:bg-white/10 cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-white/50 mb-1",children:"Score detail"}),e.jsx("p",{className:"text-sm font-bold text-white/90",children:"Show exact score values"})]}),e.jsx(aa,{checked:ct,onCheckedChange:Fa})]})]}),e.jsx("p",{className:"text-[13px] font-semibold text-white/40 leading-relaxed px-1",children:"Privacy mode keeps classmate identities and scores obfuscated by default while preserving your own exact rank and score."}),e.jsx("div",{className:"space-y-3",children:Wt.map(t=>e.jsxs("div",{className:u("relative overflow-hidden rounded-[20px] p-5 flex items-center justify-between shadow-lg transition-all hover:scale-[1.01] group",t.isSelf?"bg-amber-500/10 border border-amber-500/40 shadow-[0_0_20px_rgba(245,158,11,0.15)]":"bg-white/5 border border-white/10 hover:bg-white/10"),children:[t.isSelf&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-amber-500/20 to-transparent pointer-events-none -z-10"}),e.jsxs("div",{className:"relative z-10 flex flex-col gap-1.5",children:[e.jsxs("h4",{className:u("text-lg sm:text-xl font-black drop-shadow-md",t.isSelf?"text-amber-400":"text-white"),children:["#",t.rank," ",t.displayName,t.isSelf?" (You)":""]}),e.jsxs("p",{className:"text-[13px] font-bold text-white/60",children:["Win rate ",t.winRate.toFixed(1),"% ",e.jsx("span",{className:"mx-1",children:"•"})," Best streak ",t.bestStreak]})]}),e.jsx("div",{className:"relative z-10 text-xl sm:text-2xl font-black text-white tabular-nums drop-shadow-md",children:t.scoreLabel})]},t.userId))})]})]})]})]},"leaderboard")})]})})})})]})};export{cr as default}; +`,Ms=300*1e3,Fs=({viewportHeight:a})=>e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[50] overflow-hidden flex justify-between bg-slate-900/10",children:i.useMemo(()=>[...Array(40)].map((s,n)=>({id:n,left:`${Math.random()*100}%`,duration:.6+Math.random()*.4,delay:Math.random()*.4})),[a]).map(s=>e.jsx(y.div,{className:"absolute w-0.5 h-16 bg-blue-300/40 rounded-full e-left-top",style:{"--left":s.left,"--top":"-10%"},animate:{y:[0,a*1.2]},transition:{duration:s.duration,ease:"linear",delay:s.delay}},s.id))}),Es=({viewportHeight:a,viewportWidth:s})=>{const n=i.useMemo(()=>[...Array(30)].map((c,d)=>({id:d,xShift:(Math.random()-.5)*s*.8,yShift:(Math.random()-.5)*a*.8,scale:Math.random()*1.5+.5,duration:2+Math.random()*1.5,delay:Math.random()*.35})),[a,s]);return e.jsx("div",{className:"absolute inset-0 pointer-events-none z-[50] overflow-hidden flex items-center justify-center",children:n.map(c=>e.jsx(y.div,{className:"absolute w-2 h-2 bg-amber-400 rounded-full shadow-[0_0_10px_rgba(251,191,36,0.8)] e-left-top",style:{"--left":"50%","--top":"50%"},animate:{y:[0,c.yShift],x:[0,c.xShift],scale:[0,c.scale,0],opacity:[0,1,0]},transition:{duration:c.duration,ease:"easeOut",delay:c.delay}},c.id))})},da=({value:a,label:s,delay:n=0,icon:c})=>{const[d,l]=i.useState(0);return i.useEffect(()=>{if(a<=0)return;const w=1e3,z=30,g=Math.abs(Math.floor(w/z));let N=0;const b=setTimeout(()=>{const j=setInterval(()=>{N+=Math.max(1,Math.floor(a/z)),N>=a?(l(a),clearInterval(j)):l(N)},g);return()=>clearInterval(j)},n);return()=>clearTimeout(b)},[a,n]),a<=0?null:e.jsxs(y.div,{initial:{opacity:0,transform:"translateX(-20px)"},animate:{opacity:1,transform:"translateX(0)"},transition:{delay:n/1e3,duration:.5},className:"flex items-center justify-between bg-white/5 border border-white/10 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-white/80 font-bold uppercase tracking-wider text-sm",children:[c,s]}),e.jsxs("div",{className:"text-2xl font-black text-amber-400 tabular-nums",children:["+",d]})]})},fe="border border-border bg-card text-card-foreground shadow-sm dark:border-[#2b3140] dark:bg-[#181d27] dark:text-[#f5f7fb] dark:shadow-[0_12px_24px_rgba(0,0,0,0.22)]",Rs=a=>a<=0?"--":`${(a/1e3).toFixed(2)}s`,Ts=a=>a==="win"?"Win":a==="loss"?"Loss":"Draw",Ze=(a,s,n)=>Math.max(s,Math.min(n,a)),ca=a=>{const s=Math.floor(a/60),n=a%60;return`${s}:${String(n).padStart(2,"0")}`},Ds=a=>{const s=a.trim().split(/\s+/).filter(Boolean).slice(0,2);return s.length===0?"ST":s.map(n=>n[0]?.toUpperCase()||"").join("")},ua=(a,s)=>a?a.eventType==="round_started"?`Round ${a.roundNumber} started.`:a.eventType==="answer_locked"?a.lockedByStudentId&&s&&a.lockedByStudentId===s?`Round ${a.roundNumber}: your answer is locked.`:`Round ${a.roundNumber}: opponent answer locked.`:a.eventType==="round_result"?`Round ${a.roundNumber} resolved.`:"Match completed.":null;let St=null;const ma=()=>{if(typeof window>"u")return null;if(!St){const a=window.AudioContext||window.webkitAudioContext;a&&(St=new a)}return St},dr=()=>{const{userProfile:a,userRole:s}=Wa(),n=a,[c,d]=i.useState("hub"),[l,w]=i.useState(bs),[z,g]=i.useState([]),[N,b]=i.useState({status:"idle"}),[j,h]=i.useState(!1),[m,v]=i.useState(null),[U,S]=i.useState(""),[E,W]=i.useState(null),[ee,T]=i.useState(0),[O,C]=i.useState(null),[J,Tt]=i.useState(()=>typeof window>"u"?!0:window.localStorage.getItem("quiz_battle_sound_enabled")!=="0"),[ce,Ca]=i.useState(()=>{if(typeof window>"u")return .7;const t=Number(window.localStorage.getItem("quiz_battle_sound_volume")||"0.7");return Number.isFinite(t)?Ze(t,0,1):.7}),[Dt,I]=i.useState("connected"),[we,za]=i.useState("all"),[Pt,ot]=i.useState(!0),[te,lt]=i.useState(null),[it,dt]=i.useState([]),[Ia,Qt]=i.useState(!1),[qt,Ba]=i.useState([]),[Qe,Ma]=i.useState("alias"),[ct,Fa]=i.useState(!1),[r,_]=i.useState(null),[ve,Y]=i.useState(null),[X,Be]=i.useState(!1),[D,Me]=i.useState(0),[G,Z]=i.useState(!1),[M,ut]=i.useState(!1),[Ea,Ra]=i.useState(!1),[mt,Ta]=i.useState(kt),[B,ae]=i.useState(null),[Da,xt]=i.useState(!1),[qe,pt]=i.useState(null),[Pa,ht]=i.useState(null),[Qa,Le]=i.useState(null),Lt=i.useRef(""),bt=i.useRef(null),je=i.useRef(null),le=i.useRef(0),$t=i.useRef(""),Fe=i.useRef(0),ft=i.useRef(0),$e=i.useRef(null),Ee=i.useRef(null),He=i.useRef(-1),gt=!1,ie=i.useMemo(()=>{const t=Xa(n?.grade);return ea.filter(o=>t.includes(o.id))},[n?.grade]),qa=i.useMemo(()=>(ie.find(o=>o.id===l.subjectId)?.modules||[]).map(o=>({value:o.id,label:o.title})),[ie,l.subjectId]),$=i.useMemo(()=>{const t=r?.roundResults||[];let o=0;return t.forEach(p=>{o=p.studentCorrect?o+1:0}),o},[r?.roundResults]),La=i.useMemo(()=>{const t=Math.max(0,$-1)*.12;return Number((1+Math.min(.72,t)).toFixed(2))},[$]),$a=i.useMemo(()=>{if(!r)return 0;if(r.status==="completed")return r.xpEarned||0;const t=r.roundResults||[];let o=0,p=0;for(const x of t)if(x.studentCorrect){o++;const k=o>=2?Math.min(25,(o-1)*5):0;p+=10+k}else o=0;return p},[r?.status,r?.xpEarned,r?.roundResults]),Ht=i.useMemo(()=>{const t=r?.roundResults||[];let o=0;return t.forEach(p=>{o=p.botCorrect?o+1:0}),o},[r?.roundResults]);i.useMemo(()=>{const t=Math.max(0,Ht-1)*.1;return Number((1+Math.min(.5,t)).toFixed(2))},[Ht]),i.useMemo(()=>$>=5?{label:"Inferno",badgeClass:"text-amber-300 border-amber-300/50 bg-amber-500/20 shadow-[0_0_18px_rgba(251,191,36,0.35)]"}:$>=3?{label:"Heating Up",badgeClass:"text-orange-300 border-orange-300/50 bg-orange-500/15 shadow-[0_0_16px_rgba(249,115,22,0.3)]"}:B?.studentCorrect?{label:"Steady",badgeClass:"text-emerald-300 border-emerald-300/40 bg-emerald-500/15 shadow-[0_0_14px_rgba(16,185,129,0.25)]"}:{label:"Rebuild",badgeClass:"text-slate-300 border-slate-300/30 bg-slate-500/15 shadow-[0_0_14px_rgba(148,163,184,0.2)]"},[B?.studentCorrect,$]);const de=i.useMemo(()=>{if(!B)return null;const t=B.studentCorrect?12:-8,o=B.studentCorrect&&!B.botCorrect?6:0,p=B.studentCorrect?Math.max(0,($-1)*2):0;return t+o+p},[B,$]),P=i.useCallback(t=>{if(!(!J||ce<=0||typeof window>"u"))try{const o=ma();if(!o)return;o.state==="suspended"&&o.resume().catch(()=>{});const x={tick:{notes:[740],duration:.06,type:"triangle",volume:.03},lock:{notes:[520],duration:.08,type:"square",volume:.04},result:{notes:[660,720],duration:.08,type:"sine",volume:.04},win:{notes:[920,1040,1180],duration:.12,type:"triangle",volume:.05},loss:{notes:[260,220],duration:.14,type:"sawtooth",volume:.045},streak:{notes:[780,920],duration:.09,type:"triangle",volume:.045},multiplier:{notes:[660,880,1120],duration:.08,type:"triangle",volume:.05}}[t],k=o.currentTime,R=.07,f=Ze(x.volume*ce,.004,.08);x.notes.forEach((F,re)=>{const me=o.createOscillator(),Re=o.createGain(),ye=k+re*R;me.type=x.type,me.frequency.setValueAtTime(F,ye),Re.gain.setValueAtTime(1e-4,ye),Re.gain.exponentialRampToValueAtTime(f,ye+.012),Re.gain.exponentialRampToValueAtTime(1e-4,ye+x.duration),me.connect(Re),Re.connect(o.destination),me.start(ye),me.stop(ye+x.duration+.02)})}catch(o){console.warn("Battle tone playback skipped or blocked:",o)}},[J,ce]),Ot=i.useCallback(async t=>{if(!(!t||typeof window>"u"))try{await window.navigator.clipboard.writeText(t),W(t),window.setTimeout(()=>{W(o=>o===t?null:o)},1600)}catch{b({status:"error",message:"Unable to copy room code automatically. Please copy it manually."})}},[]),Vt=i.useCallback(()=>{},[gt]),Ut=i.useCallback(t=>{h(!1),v(null),_(null),T(0),C(null),b({status:"error",message:t}),d("setup")},[]),se=i.useCallback(async()=>{if(!n?.uid)return null;const[t,o]=await Promise.all([gs(n.uid),ws(n.uid,{mode:we,limitCount:8})]);return{stats:t,history:o}},[we,n?.uid]);i.useEffect(()=>{if(ie.length===0)return;const o=ie.some(k=>k.id===l.subjectId)?l.subjectId:ie[0].id,p=ie.find(k=>k.id===o),x=p?.modules?.[0]?.id||"";w(k=>{const R=p?.modules?.some(f=>f.id===k.topicId)?k.topicId:x;return k.subjectId===o&&k.topicId===R?k:{...k,subjectId:o,topicId:R}})},[ie,l.subjectId]),i.useEffect(()=>{if(!n?.uid){lt(null),dt([]),ot(!1);return}let t=!0;return ot(!0),(async()=>{const p=await se();t&&(p&&(lt(p.stats),dt(p.history)),ot(!1))})(),()=>{t=!1}},[se,n?.uid]);const Oe=i.useMemo(()=>we==="all"?it:it.filter(t=>t.mode===we),[it,we]),Wt=i.useMemo(()=>qt.map((t,o)=>{const p=t.rank||o+1,x=t.userId===n?.uid,k=`Student-${t.userId.slice(-4).toUpperCase()}`,R=Qe==="full"?t.displayName:Qe==="initials"?Ds(t.displayName):k,f=Math.floor(t.leaderboardScore/25)*25,F=ct||x?`${t.leaderboardScore} pts`:`${f}-${f+24} pts`;return{...t,rank:p,isSelf:x,displayName:R,scoreLabel:F}}),[qt,Qe,ct,n?.uid]);i.useEffect(()=>{if(c!=="leaderboard"&&c!=="hub")return;let t=!0;return Qt(!0),(async()=>{const p=await Is(20);t&&(Ba(p),Qt(!1))})(),()=>{t=!1}},[c]);const Ve=i.useCallback(async()=>{if(n?.uid)try{const t=await ia();if(t.sessionType==="match"&&t.match){let o=t.match;if(t.match.mode==="bot"&&t.match.status==="ready")try{o=await ne(t.match.matchId),Fe.current=0}catch(p){const x=p;h(!1),v(null),_(null),d("setup"),I(typeof window<"u"&&window.navigator.onLine?"connected":"disconnected"),b({status:"error",message:x?.message||"Unable to resume bot battle. Please start a new match."});return}h(!1),v(t.room||null),_(o),C(t.queue?.expiresAtMs||o.expiresAtMs||null),d("battle"),I("connected");return}if(t.sessionType==="room"&&t.room){h(!1),v(t.room),_(o=>o?.mode==="bot"?o:null),C(null),I("connected");return}if(t.sessionType==="queue"){h(!0),v(null),_(o=>o?.mode==="bot"?o:null),C(t.queue?.expiresAtMs||null),I("connected");return}h(!1),v(null),_(o=>o?.mode==="bot"?o:null),C(null),I("connected")}catch(t){console.warn("Quiz Battle session resume failed:",t),I("reconnecting")}},[n?.uid]);i.useEffect(()=>{n?.uid&&Ve()},[n?.uid,Ve]),i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("quiz_battle_sound_enabled",J?"1":"0")},[J]),i.useEffect(()=>{typeof window>"u"||window.localStorage.setItem("quiz_battle_sound_volume",ce.toFixed(2))},[ce]),i.useEffect(()=>{if(typeof window>"u")return;const t=()=>{const o=window.innerWidth,p=window.innerHeight;Ta({width:Number.isFinite(o)&&o>0?o:kt.width,height:Number.isFinite(p)&&p>0?p:kt.height})};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),i.useEffect(()=>{if(typeof document>"u")return;const t=()=>{Ra(!!document.fullscreenElement)};return t(),document.addEventListener("fullscreenchange",t),()=>{document.removeEventListener("fullscreenchange",t)}},[]),i.useEffect(()=>{const t=O!==null;if(!(j||m&&(m.status==="waiting"||m.status==="ready")||t)){T(0);return}const o=()=>{if(!O){T(x=>x+1);return}T(Math.max(0,Math.ceil((O-Date.now())/1e3)))};o();const p=window.setInterval(o,1e3);return()=>{window.clearInterval(p)}},[j,m?.status,m?.roomId,O]),i.useEffect(()=>{if(!O)return;const t=window.setInterval(()=>{O-Date.now()<=0&&(window.clearInterval(t),(async()=>{try{(j||!m)&&await la()}catch{}finally{Ut("Public matchmaking timed out after 5 minutes. Please start again.")}})())},1e3);return()=>{window.clearInterval(t)}},[m,Ut,j,O]),i.useEffect(()=>{if(typeof window>"u")return;I(window.navigator.onLine?"connected":"disconnected");const t=()=>{I("reconnecting"),Ve()},o=()=>{I("disconnected")};return window.addEventListener("online",t),window.addEventListener("offline",o),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",o)}},[Ve]),i.useEffect(()=>{const t=r?.mode==="online"&&(r.status==="ready"||r.status==="in_progress"),o=r?.mode==="bot"&&r.status==="ready",p=!!(m&&(m.status==="waiting"||m.status==="ready"));if(o||(Fe.current=0),!j&&!p&&!t&&!o||M)return;let x=!1;const k=async()=>{try{if(r?.mode==="bot"&&r.status==="ready"){const f=await ne(r.matchId);if(x)return;_(f),I("connected"),C(f.expiresAtMs||null),Fe.current=0,f.status==="in_progress"&&b({status:"queued",message:"Practice bot match started."});return}if(r?.mode==="online"){if(r.status==="ready"){const re=await ne(r.matchId);if(x)return;_(re),I("connected"),C(re.expiresAtMs||null),re.status==="in_progress"&&b({status:"queued",message:"Match started. Round timer is live."});return}const f=await Nt(r.matchId);if(x)return;const F=f.roundResults.filter(re=>re.roundNumber>He.current).sort((re,me)=>re.roundNumber-me.roundNumber)[0];F?(He.current=F.roundNumber,ae(F),pt(f)):(_(f),f.status==="completed"&&(h(!1),v(null),C(null)),f.status==="cancelled"&&r.status==="in_progress"&&(xt(!0),Z(!1))),I("connected");return}if(m?.roomId){const f=await Ns({roomId:m.roomId});if(x)return;if(v(f.room),f.match){const F=await ne(f.match.matchId);if(x)return;_(F),v(f.room),h(!1),C(F.expiresAtMs||null),d("battle"),I("connected"),b({status:"queued",message:F.status==="ready"?"Opponent connected. Waiting for synchronized start...":"Private room match started."})}return}if(j){const f=await ia();if(x)return;if(f.sessionType==="match"&&f.match){const F=await ne(f.match.matchId);if(x)return;_(F),v(f.room||null),h(!1),C(F.expiresAtMs||null),d("battle"),I("connected"),b({status:"queued",message:"Opponent found. Preparing synchronized start..."});return}if(f.sessionType==="room"&&f.room){h(!1),v(f.room),C(null),I("connected");return}I("connected")}}catch(f){if(!x){if(console.warn("Quiz Battle sync poll failed:",f),r?.mode==="bot"&&r.status==="ready"&&(Fe.current+=1,Fe.current>=3)){const F=f;h(!1),v(null),_(null),d("setup"),b({status:"error",message:F?.message||"Unable to start bot battle. Please try again."}),I("disconnected");return}I("reconnecting")}}};k();const R=window.setInterval(()=>{k()},3e3);return()=>{x=!0,window.clearInterval(R)}},[r?.matchId,r?.mode,r?.status,m?.roomId,m?.status,M,j]);const ue=i.useMemo(()=>r?.mode==="online"&&(r.status==="ready"||r.status==="in_progress")?{scope:"match",resourceId:r.matchId}:m&&(m.status==="waiting"||m.status==="ready")?{scope:"room",resourceId:m.roomId}:j&&n?.uid?{scope:"queue",resourceId:n.uid}:null,[r,m,j,n?.uid]);i.useEffect(()=>{if(!ue)return;let t=!1;const o=async()=>{try{await _s(ue.scope,ue.resourceId),t||I("connected")}catch(x){t||(console.warn("Quiz Battle heartbeat failed:",x),I("reconnecting"))}};o();const p=window.setInterval(()=>{o()},8e3);return()=>{t=!0,window.clearInterval(p),hs(ue.scope,ue.resourceId)}},[ue?.scope,ue?.resourceId]),i.useEffect(()=>{if(!r||r.status!=="in_progress"){Z(!1),je.current=null,le.current=0;return}je.current=null,le.current=0;const t=r.roundDeadlineAtMs?Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3)):r.timePerQuestionSec;Me(t),Y(null),Z(!1)},[r?.matchId,r?.status,r?.currentRound,r?.timePerQuestionSec]),i.useEffect(()=>{M&&(!r||r.status!=="in_progress")&&ut(!1)},[r?.matchId,r?.status,M]),i.useEffect(()=>{const t=r?.lifecycle;if(!t?.eventType)return;const o=`${t.eventType}:${t.sequence}`;Lt.current!==o&&(Lt.current=o,t.eventType==="answer_locked"?P("lock"):t.eventType==="round_result"&&P("result"))},[r?.lifecycle?.eventType,r?.lifecycle?.sequence,P]),i.useEffect(()=>{!r||r.status!=="completed"||$t.current!==r.matchId&&($t.current=r.matchId,P(r.outcome==="loss"?"loss":"win"),r.outcome==="win"&&Ya(()=>import("./confetti.module-C94ZD2ww.js"),[]).then(t=>{t.default({particleCount:110,spread:78,origin:{y:.62},ticks:160})}).catch(()=>{}))},[r?.matchId,r?.status,r?.outcome,P]),i.useEffect(()=>{if(!r||r.status!=="in_progress"||G||X||M){bt.current=null;return}D<=3&&D>0&&bt.current!==D&&(bt.current=D,P("tick"))},[r?.status,D,G,X,M,P]),i.useEffect(()=>{if(!r||r.status!=="in_progress"){ft.current=0;return}$>ft.current&&$>=2&&P($>=4?"multiplier":"streak"),ft.current=$},[r?.matchId,r?.status,$,P]),i.useEffect(()=>{if(!r){$e.current=null,Le(null);return}const t=$e.current;if(!t||t.matchId!==r.matchId){$e.current={matchId:r.matchId,scoreFor:r.scoreFor,scoreAgainst:r.scoreAgainst},Le(null);return}if(r.scoreFor!==t.scoreFor||r.scoreAgainst!==t.scoreAgainst){const o=r.scoreFor>t.scoreFor?"player":"opponent";Le(o),Ee.current&&window.clearTimeout(Ee.current),Ee.current=window.setTimeout(()=>{Le(null)},850)}$e.current={matchId:r.matchId,scoreFor:r.scoreFor,scoreAgainst:r.scoreAgainst}},[r?.matchId,r?.scoreAgainst,r?.scoreFor]),i.useEffect(()=>()=>{Ee.current&&window.clearTimeout(Ee.current)},[]),i.useEffect(()=>{if(!B?.studentCorrect||de===null||de<=0){ht(null);return}const t=de>0?"positive":de<0?"negative":"neutral";ht({id:Date.now(),label:`${de>=0?"+":""}${de} Momentum`,tone:t});const o=window.setTimeout(()=>{ht(null)},1400);return()=>{window.clearTimeout(o)}},[de,B]),i.useEffect(()=>{if(B&&qe){B.studentCorrect?P("win"):P("loss");const t=window.setTimeout(()=>{_(qe),ae(null),Y(null),Z(!1),pt(null),qe.status==="completed"&&(h(!1),v(null),se(),He.current=-1)},1500);return()=>window.clearTimeout(t)}},[B,qe,P,se]);const Ue=i.useCallback(async t=>{if(!r||r.status!=="in_progress"||G||M)return;Be(!0);const o=window.setTimeout(()=>{Be(!1),b({status:"error",message:"Submission took too long. Syncing latest match state now..."}),Nt(r.matchId).then(p=>{_(p),p.status==="completed"&&(h(!1),v(null),C(null))}).catch(()=>{})},12e3);try{const p=r.roundDeadlineAtMs?Ze(r.timePerQuestionSec*1e3-Math.max(0,r.roundDeadlineAtMs-Date.now()),0,r.timePerQuestionSec*1e3):Math.max(0,(r.timePerQuestionSec-D)*1e3),x=await Cs({matchId:r.matchId,roundNumber:r.currentRound,selectedOptionIndex:t,responseMs:p});je.current=null,le.current=0,x.roundResult?(He.current=x.roundResult.roundNumber,ae(x.roundResult),pt(x.match)):(_(x.match),ae(null),x.match.mode==="online"&&x.match.status==="in_progress"?(Z(!0),b({status:"queued",message:"Answer locked. Waiting for opponent to finish the round..."})):Y(null)),x.match.status==="completed"&&(h(!1),v(null),C(null),se(),b({status:"queued",message:x.completion?`Match finished (${x.completion.outcome.toUpperCase()}) +${x.completion.xpEarned} XP`:"Match finished. Results saved."}))}catch(p){const k=p?.message||"Unable to submit answer right now. Please try again.";if(t===null||k.includes("Round timer elapsed")||k.includes("Expected round")||k.includes("Match is not currently active"))try{const f=await Nt(r.matchId),F=f.currentRound!==r.currentRound;if(_(f),Y(null),Z(!1),F||f.status==="completed"?(je.current=null,le.current=0):t===null&&(le.current=Date.now()+3e3),f.status==="completed"){h(!1),v(null),C(null),se(),b({status:"queued",message:"Match finished. Results synchronized."});return}b({status:"queued",message:"Round timed out. Synced to the latest battle state."});return}catch{}t===null&&(le.current=Date.now()+3e3),b({status:"error",message:k})}finally{window.clearTimeout(o),Be(!1)}},[r,M,se,G,D]);i.useEffect(()=>{if(!r||r.status!=="in_progress"||M||X||G)return;const t=r.roundDeadlineAtMs?Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3)):D;if(r.roundDeadlineAtMs&&t!==D&&Me(t),ve===null?t<=1:t<=0){if(je.current===r.currentRound&&Date.now(){r.roundDeadlineAtMs?Me(Math.max(0,Math.ceil((r.roundDeadlineAtMs-Date.now())/1e3))):Me(x=>Math.max(0,x-1))},1e3);return()=>{window.clearTimeout(p)}},[r,X,M,G,D,ve,Ue]);const Yt=i.useCallback(async()=>{if(!(!r||r.mode!=="bot")){Be(!0),b({status:"validating"});try{const t=await zs(r.matchId),o=await ne(t.matchId);_(o),v(null),h(!1),C(null),ae(null),Y(null),Z(!1),d("battle"),b({status:"queued",message:`Rematch ready (${t.botDifficulty}). Good luck!`})}catch(t){b({status:"error",message:t?.message||"Unable to start rematch right now."})}finally{Be(!1)}}},[r]);if(s!=="student")return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsx("div",{className:"px-4 sm:px-6 xl:px-10 py-6 sm:py-8",children:e.jsx(pe,{className:u(fe,"max-w-2xl"),children:e.jsxs(he,{children:[e.jsx(be,{children:"Quiz Battle is student-only"}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#aab3c7]",children:"Your account role does not have access to this module."})]})})})]});const Xt=t=>{g([]),b({status:"idle"}),ut(!1),h(!1),v(null),S(""),_(null),ae(null),Y(null),Z(!1),C(null),w(o=>({...o,mode:t,queueType:t==="online"?o.queueType:"public_matchmaking"})),T(0),d("setup")},Gt=async()=>{b({status:"validating"});try{m?.roomId?await ks({roomId:m.roomId}):await la(),h(!1),v(null),_(t=>!t||t.mode!=="online"?t:t.status==="ready"||t.status==="cancelled"?null:t),S(""),T(0),C(null),b({status:"queued",message:m?.roomId?"Private room cancelled.":"Left matchmaking queue."})}catch(t){b({status:"error",message:t?.message||"Unable to cancel this online session right now. Please try again."})}},Ha=async()=>{b({status:"validating"});const t=fs(l);if(t.length>0){g(t),b({status:"error",message:"Fix the highlighted setup fields before starting."});return}g([]);try{if(l.mode==="online"){if(l.queueType==="private_room"){const k=U.trim().toUpperCase(),R=k?await ys(k):await js(l);if(h(!1),v(R.room),S(""),C(R.match?.expiresAtMs||null),R.match){const f=await ne(R.match.matchId);_(f),ae(null),Y(null),Z(!1),d("battle"),C(f.expiresAtMs||null),b({status:"queued",message:f.status==="ready"?`Room ${R.room.roomCode} linked. Waiting for synchronized start...`:"Private room match started."});return}_(null),C(null),b({status:"queued",message:k?"Joined private room. Waiting for opponent...":"Private room created. Share code:"});return}const x=await vs(l);if(x.status==="matched"&&x.matchId){const k=await ne(x.matchId);h(!1),v(null),_(k),ae(null),Y(null),Z(!1),d("battle"),C(k.expiresAtMs||null),b({status:"queued",message:"Opponent found. Preparing synchronized start..."});return}h(!0),v(null),_(null),C(x.expiresAtMs||Date.now()+Ms),T(0),b({status:"queued",message:"Joined matchmaking queue. Waiting for an opponent..."});return}const o=await Ss(l),p=await ne(o.matchId);h(!1),v(null),_(p),ae(null),Y(null),Z(!1),Me(p.timePerQuestionSec),C(null),d("battle"),b({status:"queued",message:`Bot match ${o.matchId.slice(0,8)} live (${o.botDifficulty}).`}),se().then(x=>{x&&(lt(x.stats),dt(x.history))})}catch(o){h(!1),b({status:"error",message:o?.message||"Unable to start battle. Please try again."})}},V=t=>z.find(o=>o.field===t)?.message;te?.winRate;const Zt=!!(l.mode==="online"&&m&&(m.status==="waiting"||m.status==="ready")&&(!r||r.status!=="completed")),Oa=!!(j||m&&(m.status==="waiting"||m.status==="ready")&&(!r||r.status==="ready"||r.status==="cancelled"));return r&&(r.status==="in_progress"||r.status==="completed")?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsxs("div",{className:"fixed inset-0 z-[100] bg-[#0B0F19] text-white flex flex-col overflow-hidden",children:[r.status==="completed"&&r.outcome==="loss"&&e.jsx(Fs,{viewportHeight:mt.height}),r.status==="completed"&&r.outcome==="draw"&&e.jsx(Es,{viewportHeight:mt.height,viewportWidth:mt.width}),e.jsx("div",{className:"absolute inset-0 z-0 opacity-40",children:e.jsx(na,{children:e.jsx("div",{className:"h-full w-full"})})}),e.jsx(Ke,{children:Da&&e.jsx(y.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-[120] bg-black/70 backdrop-blur-md flex flex-col items-center justify-center px-6",children:e.jsxs(y.div,{initial:{opacity:0,transform:"translateY(40px) scale(0.85)"},animate:{opacity:1,transform:"translateY(0) scale(1)"},transition:{type:"spring",damping:18,stiffness:250,delay:.1},className:"bg-[#1e2433] border border-white/10 rounded-[2rem] p-8 flex flex-col items-center gap-5 max-w-sm w-full shadow-[0_30px_80px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[#1a2030] border-4 border-rose-500/50 overflow-hidden flex items-end justify-center shadow-xl",children:r.mode==="bot"?e.jsx(Te,{className:"h-16 w-16 text-rose-400 mb-2",strokeWidth:1.5}):e.jsx(ge,{className:"h-14 w-14 text-slate-500 mb-2",strokeWidth:1.5})}),e.jsx(y.div,{initial:{opacity:0,transform:"scale(0.5) translateX(-10px)"},animate:{opacity:1,transform:"scale(1) translateX(0)"},transition:{delay:.4,type:"spring",stiffness:300},className:"absolute -top-2 left-full ml-2 bg-white text-slate-900 text-xs font-black px-3 py-1.5 rounded-2xl rounded-bl-none whitespace-nowrap shadow-lg",children:"I give up! 🏳️"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-black text-white mb-1",children:"Opponent Surrendered"}),e.jsxs("p",{className:"text-white/50 text-sm",children:[e.jsx("span",{className:"font-bold text-white/70",children:r.opponentName||"Your opponent"})," left the match. You win! 🏆"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsx(A,{size:"lg",className:"w-full h-12 bg-emerald-500 hover:bg-emerald-400 text-white font-black rounded-xl",onClick:()=>{xt(!1),_(null),v(null),h(!1),b({status:"idle"}),d("hub"),se()},children:"🏆 Claim Victory"}),e.jsx(A,{size:"lg",variant:"outline",className:"w-full h-12 border-white/20 text-white/70 hover:bg-white/10 rounded-xl",onClick:()=>{xt(!1),_(null),v(null),h(!1),b({status:"idle"}),d("hub")},children:"Back to Arena"})]})]})})}),M&&e.jsx("div",{className:"absolute inset-0 z-[110] bg-black/60 backdrop-blur-md flex items-center justify-center",children:e.jsxs(pe,{className:"w-full max-w-sm border-border/50 bg-[#181d27] shadow-[0_20px_50px_rgba(0,0,0,0.5)]",children:[e.jsxs(he,{className:"text-center",children:[e.jsx(be,{className:"text-3xl font-black text-white",children:"PAUSED"}),e.jsx(Ae,{className:"text-base text-muted-foreground mt-2",children:r.mode==="online"?"Online match - timer continues in the background! Hurry!":"Bot match - round timer frozen."})]}),e.jsxs(Ge,{className:"flex flex-col gap-3",children:[e.jsx(A,{variant:"default",size:"lg",className:"w-full text-lg h-12",onClick:Vt,children:"Resume Match"}),e.jsx(A,{variant:"outline",size:"lg",className:"w-full text-lg h-12 border-rose-500/20 text-rose-500 hover:bg-rose-500/10",onClick:()=>{ut(!1),_(null),v(null),h(!1),b({status:"idle"}),d("setup")},children:"Leave Match"})]})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col h-full w-full max-w-[1400px] mx-auto px-4 md:px-8 py-4",children:[e.jsx(_a,{playerRoundStreak:$,playerVisualMultiplier:La,liveXpEarned:$a,activeMatch:r,subjects:ea,battleSoundEnabled:J,onToggleSound:()=>Tt(t=>!t),isFullscreen:Ea,onToggleFullscreen:()=>{typeof document>"u"||(document.fullscreenElement?document.exitFullscreen().catch(t=>{console.warn("Fullscreen mode unavailable or blocked by browser (exit):",t)}):document.documentElement.requestFullscreen().catch(t=>{console.warn("Fullscreen mode unavailable or blocked by browser (enter):",t)}))},isDesignPauseAvailable:gt,onTogglePause:Vt}),r.status==="in_progress"?e.jsx("div",{className:"shrink-0 w-full max-w-4xl mx-auto h-2 bg-white/10 rounded-full overflow-hidden mt-6 mb-4",children:e.jsx(y.div,{className:"h-full",animate:{width:`${Math.max(0,D/r.timePerQuestionSec*100)}%`,backgroundColor:D>Math.floor(r.timePerQuestionSec/2)?"#10b981":D>3?"#f59e0b":"#ef4444"},transition:{duration:1,ease:"linear"}})}):e.jsx("div",{className:"shrink-0 h-6 md:h-10 w-full"}),e.jsx("div",{className:"flex-1 flex flex-col justify-center items-center w-full min-h-0 relative",children:r.status==="completed"?e.jsx("div",{className:"fixed inset-0 z-[200] flex flex-col items-center justify-center bg-slate-900/50 backdrop-blur-md px-4",children:e.jsxs(y.div,{initial:{opacity:0,scale:.9,y:10},animate:{opacity:1,scale:1,y:0},className:"w-full max-w-sm sm:max-w-md bg-[#161a25]/90 border border-white/20 shadow-[0_30px_80px_rgba(0,0,0,0.8)] rounded-[1.5rem] p-6 text-center",children:[e.jsx("h2",{className:u("text-3xl font-black uppercase tracking-widest drop-shadow-md mb-2",r.outcome==="win"?"text-emerald-400":r.outcome==="loss"?"text-rose-400":"text-amber-400"),children:r.outcome==="win"?"VICTORY!":r.outcome==="loss"?"DEFEAT":"DRAW MATCH"}),e.jsxs("p",{className:"text-white/80 font-bold text-sm mb-4 uppercase tracking-widest",children:["Final Score: ",r.scoreFor," - ",r.scoreAgainst]}),e.jsxs("div",{className:"bg-black/50 rounded-xl p-4 mb-5 border border-white/5 flex flex-col gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white/40 text-[10px] font-black uppercase tracking-widest text-left mb-2",children:"Battle Score"}),(()=>{const t=r.roundResults||[];let o=0,p=0,x=0;for(const k of t)if(k.studentCorrect){o++;const R=o>=2?Math.min(15,(o-1)*5):0;p+=10,x+=R}else o=0;return e.jsxs(e.Fragment,{children:[e.jsx(da,{value:p,label:"Correct Answers",delay:300,icon:e.jsx(yt,{className:"h-3 w-3 text-emerald-400"})}),e.jsx(da,{value:x,label:"Streak Bonus",delay:900,icon:e.jsx(et,{className:"h-3 w-3 text-amber-400"})}),e.jsxs(y.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.5,duration:.4},className:"flex items-center justify-between pt-1 mt-1 border-t border-white/5",children:[e.jsx("span",{className:"text-white/50 text-xs font-bold uppercase tracking-widest",children:"Total"}),e.jsxs("span",{className:"text-base font-black text-white/80",children:[p+x," pts"]})]})]})})()]}),e.jsx("div",{className:"w-full h-px bg-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white/40 text-[10px] font-black uppercase tracking-widest text-left mb-2",children:"Match Reward"}),e.jsxs(y.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:2,duration:.5,type:"spring"},className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white/70 text-sm font-bold",children:r.outcome==="win"?"🏆 Victory Reward":r.outcome==="draw"?"🤝 Draw Reward":"📘 Participation Reward"}),e.jsxs("span",{className:"text-2xl font-black text-amber-400 drop-shadow-md",children:["+",r.xpEarned||(r.outcome==="win"?80:r.outcome==="draw"?55:35)," XP"]})]}),e.jsx("p",{className:"text-white/25 text-[9px] mt-1 text-right uppercase tracking-widest",children:"Credited to your profile"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 justify-center",children:[e.jsx(A,{size:"lg",onClick:()=>{_(null),v(null),h(!1),d("hub")},className:"w-full h-12 rounded-xl text-sm font-black bg-white/10 hover:bg-white/20 text-white border border-white/20",children:"BACK TO ARENA"}),r.mode==="bot"&&e.jsx(A,{size:"lg",onClick:()=>void Yt(),disabled:X,className:"w-full h-12 rounded-xl text-sm font-black bg-violet-600 hover:bg-violet-500 text-white border-b-2 border-violet-800 active:border-b-0 active:translate-y-[2px]",children:"REMATCH"})]})]})}):e.jsx(Aa,{activeMatch:r,roundSecondsLeft:D,lastRoundResult:B,selectedOptionIndex:ve,roundLocked:G,answerSubmitting:X,designPauseActive:M,onOptionSelect:t=>{B&&B.roundNumber===r.currentRound||X||G||(ma()?.resume().catch(()=>{}),P("lock"),Y(t),Ue(t))},floatingMomentum:Pa,lastRoundMomentumDelta:de,studentProfile:n,quizBattleAvatar:jt})}),e.jsx(Sa,{studentProfile:n,activeMatch:r,scorePulseTarget:Qa,quizBattleAvatar:jt})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:_t}),e.jsx(na,{bgVideo:"/videos/warp_bg.mp4",className:"-mx-3 lg:-mx-4 -mt-3 lg:-mt-4 -mb-8 px-4 sm:px-6 xl:px-10 py-6 sm:py-8 min-h-[calc(100vh-3.5rem)] !w-auto overflow-hidden relative",children:e.jsx("div",{className:"h-full flex flex-col max-w-[1400px] mx-auto w-full",children:e.jsx(y.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.24,ease:[.22,1,.36,1]},className:"space-y-3 lg:space-y-4",children:e.jsxs(Bs,{value:c,onValueChange:t=>d(t),children:[e.jsx(Ce,{value:"hub",className:"mt-0 outline-none",children:e.jsx(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-5",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] xl:grid-cols-[1fr_320px] gap-6 sm:gap-8 lg:gap-10",children:[e.jsxs("div",{className:"space-y-3 lg:space-y-4",children:[e.jsxs("div",{className:"relative select-none isolate bg-indigo-600 rounded-[2rem] shadow-[0_20px_45px_-15px_rgba(0,0,0,0.3)] shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-none z-0 rounded-[2rem]"}),e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none rounded-[2rem] overflow-hidden repeating-stripe-bg"}),e.jsx("div",{className:"absolute top-0 right-0 w-[400px] h-[400px] bg-sky-500/20 blur-[100px] rounded-full pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex flex-col md:flex-row items-center justify-between p-6 lg:p-8 h-full min-h-[140px] lg:min-h-[160px]",children:[e.jsx("div",{className:"flex-1 space-y-3 w-full pr-0 md:pr-[240px] lg:pr-[280px]",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"flex items-center gap-3 text-3xl sm:text-4xl lg:text-[46px] font-black tracking-tight text-white mb-2 sm:mb-4",children:[e.jsx(wt,{className:"h-8 w-8 sm:h-10 sm:w-10 lg:h-12 lg:w-12 text-[#d1abff]",strokeWidth:2.5}),"Quiz Battle"]}),e.jsx("p",{className:"text-base sm:text-lg lg:text-xl text-white mt-1.5 sm:mt-2 max-w-2xl leading-relaxed",children:"Timed student duels with synchronized rounds, instant feedback, and progression rewards."}),e.jsxs("p",{className:"text-xs lg:text-sm font-semibold uppercase tracking-[0.15em] text-[#8a7fbc] mt-3",children:["Connection: ",e.jsx("span",{className:Dt==="connected"?"text-emerald-400":"text-amber-400",children:Dt})]})]})}),e.jsx("div",{className:"hidden md:block absolute right-[-5px] lg:right-[-15px] top-0 lg:top-[5px] w-[200px] lg:w-[260px] shrink-0 pointer-events-none z-20",children:e.jsx("img",{src:jt,alt:"Mascot",className:"w-full h-full object-contain animate-mascot-float"})})]})]}),e.jsxs("div",{className:"pt-4 lg:pt-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 pb-4 text-xl lg:text-2xl font-black tracking-wide uppercase text-white drop-shadow-[0_0_12px_rgba(255,255,255,0.4)]",children:[e.jsx(wt,{className:"h-6 w-6 lg:h-8 lg:w-8 text-amber-400 drop-shadow-[0_0_8px_rgba(251,191,36,0.9)]"})," BATTLE MODES"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 lg:gap-6 relative z-10 w-full mb-2",children:[e.jsxs(y.button,{type:"button",onClick:()=>Xt("online"),whileHover:{scale:1.025},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:15},className:"w-full h-[205px] sm:h-[245px] lg:h-[265px] bg-[#8A3FD3] rounded-[22px] border-none relative text-left shadow-[0_8px_30px_rgba(138,63,211,0.2)] hover:shadow-[0_12px_45px_rgba(138,63,211,0.4)] block flex-col group",children:[e.jsx("div",{className:"absolute inset-0 rounded-[22px] shadow-[inset_0_6px_15px_rgba(255,255,255,0.4)] pointer-events-none z-40"}),e.jsxs("div",{className:"absolute top-4 -left-4 z-20 w-[100px] h-[40px] opacity-100",children:[e.jsx("svg",{viewBox:"0 0 100 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-full h-full block drop-shadow-md",children:e.jsx("path",{d:"M0 0 H94 Q100 0 100 6 V34 Q100 40 94 40 H0 L14 20 Z",fill:"#b91c1c"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-end pr-3 font-black text-[13px] text-white tracking-[0.3px] opacity-100 font-nunito",children:"VS Player"})]}),e.jsxs("div",{className:"rounded-[22px] overflow-hidden relative isolate h-full flex flex-col justify-end",children:[e.jsx("div",{className:"absolute top-0 -left-[150%] w-[100%] h-full bg-gradient-to-r from-transparent via-white/40 to-transparent -skew-x-12 z-50 pointer-events-none transition-all duration-0 group-hover:duration-[800ms] ease-in-out group-hover:left-[150%]"}),e.jsxs("div",{className:"flex-1 w-full flex items-end justify-center relative pt-2 pointer-events-none",children:[e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[70px] sm:h-[95px] bg-[#662AA8] rounded-[50%_50%_0_0/100%_100%_0_0] scale-[1.05] z-0"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-center mb-[2px] h-[120px] sm:h-[140px] w-full",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"h-[120%] sm:h-[125%] object-contain relative z-20 origin-bottom right-[-15px] drop-shadow-[0_12px_15px_rgba(0,0,0,0.3)] animate-avatar-left"}),e.jsx("div",{className:"relative z-30 flex flex-col items-center mx-[-20px] scale-[1.1] animate-vs-pulse",children:e.jsxs("span",{className:"font-black italic text-[40px] text-gray-200 tracking-tighter leading-none drop-shadow-[-2px_3px_0px_rgba(0,0,0,0.8)] webkit-text-stroke",children:[e.jsx("span",{className:"text-gray-300",children:"V"}),e.jsx("span",{className:"text-gray-400",children:"S"})]})}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"h-[120%] sm:h-[125%] object-contain relative z-10 scale-x-[-1] origin-bottom left-[-20px] drop-shadow-[0_12px_15px_rgba(0,0,0,0.3)] animate-avatar-right"})]})]}),e.jsx("div",{className:"relative z-10 w-full px-5 py-3 sm:py-4 text-center bg-[#662AA8]",children:e.jsx("p",{className:"text-[13px] font-bold text-white leading-[1.45] font-nunito",children:"Queue or room-code match with another student."})})]})]}),e.jsxs(y.button,{type:"button",onClick:()=>Xt("bot"),whileHover:{scale:1.025},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:15},className:"w-full h-[205px] sm:h-[245px] lg:h-[265px] bg-[#1FA7E1] rounded-[22px] border-none relative text-left shadow-[0_8px_30px_rgba(31,167,225,0.2)] hover:shadow-[0_12px_45px_rgba(31,167,225,0.4)] block flex-col group",children:[e.jsx("div",{className:"absolute inset-0 rounded-[22px] shadow-[inset_0_6px_15px_rgba(255,255,255,0.4)] pointer-events-none z-40"}),e.jsxs("div",{className:"absolute top-4 -left-4 z-20 w-[100px] h-[40px] opacity-100",children:[e.jsx("svg",{viewBox:"0 0 100 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-full h-full block drop-shadow-md",children:e.jsx("path",{d:"M0 0 H94 Q100 0 100 6 V34 Q100 40 94 40 H0 L14 20 Z",fill:"#b91c1c"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-end pr-3 font-black text-[13px] text-white tracking-[0.3px] opacity-100 font-nunito",children:"VS Bot"})]}),e.jsxs("div",{className:"rounded-[22px] overflow-hidden relative isolate h-full flex flex-col justify-end",children:[e.jsx("div",{className:"absolute top-0 -left-[150%] w-[100%] h-full bg-gradient-to-r from-transparent via-white/40 to-transparent -skew-x-12 z-50 pointer-events-none transition-all duration-0 group-hover:duration-[800ms] ease-in-out group-hover:left-[150%]"}),e.jsxs("div",{className:"flex-1 w-full flex items-end justify-center relative pt-2 pointer-events-none",children:[e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[70px] sm:h-[95px] bg-[#127DA6] rounded-[50%_50%_0_0/100%_100%_0_0] scale-[1.05] z-0"}),e.jsxs("div",{className:"relative z-10 flex items-end justify-center mb-[2px] h-[125px] sm:h-[145px] w-full",children:[e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"absolute opacity-40 blur-[1px] h-full object-contain origin-bottom -translate-x-[45px] sm:-translate-x-[60px] scale-[0.80] sm:scale-[0.85] animate-ghost-left"}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"",className:"absolute opacity-40 blur-[1px] h-full object-contain origin-bottom translate-x-[45px] sm:translate-x-[60px] scale-[0.80] sm:scale-[0.85] animate-ghost-right"}),e.jsx("img",{src:"/avatar/avatar_icon.png",alt:"VS Bot",className:"relative opacity-100 scale-100 h-[105%] sm:h-[115%] object-contain drop-shadow-[0_15px_15px_rgba(0,0,0,0.3)] z-20 origin-bottom animate-main-avatar"})]})]}),e.jsx("div",{className:"relative z-10 w-full px-5 py-3 sm:py-4 text-center bg-[#127DA6]",children:e.jsx("p",{className:"text-[13px] font-bold text-white leading-[1.45] font-nunito",children:"Instant solo duel with selectable bot difficulty."})})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3 lg:space-y-4 flex flex-col h-full justify-between",children:[e.jsx("div",{onClick:()=>d("leaderboard"),className:"relative w-full bg-[#3b3a82] dark:bg-[#2b2b5f] rounded-[24px] overflow-hidden flex flex-col shadow-[0_8px_30px_rgba(59,58,130,0.3)] cursor-pointer group mb-4",children:e.jsxs("div",{className:"relative w-full h-[190px] flex flex-col items-center justify-end pt-8",children:[e.jsxs("div",{className:"absolute top-[25px] w-full flex justify-center items-end px-2 z-10 gap-3",children:[e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[32px] h-[32px] text-[#fcd34d] -rotate-[15deg] mb-2 drop-shadow-[0_0_15px_rgba(252,211,77,0.8)]"}),e.jsx("div",{className:"z-10 animate-star-float",children:e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[48px] h-[48px] text-[#fcd34d] drop-shadow-[0_0_25px_rgba(252,211,77,0.9)]"})}),e.jsx(vt,{strokeWidth:0,fill:"currentColor",className:"w-[32px] h-[32px] text-[#fcd34d] rotate-[15deg] mb-2 drop-shadow-[0_0_15px_rgba(252,211,77,0.8)]"})]}),e.jsx("div",{className:"absolute bottom-[50px] left-1/2 -translate-x-1/2 w-[220px] h-[160px] bg-gradient-to-t from-white/20 to-transparent blur-[2px] z-0 pointer-events-none",style:{clipPath:"polygon(25% 0, 75% 0, 100% 100%, 0% 100%)"}}),e.jsxs("div",{className:"flex items-end justify-center z-10 relative px-4 bottom-[35px]",children:[e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx("div",{className:"w-[75px] h-[14px] bg-[#D44747] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[65px] h-[45px] bg-[#FE6464] flex flex-col items-center justify-center gap-2 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full"})]})]}),e.jsxs("div",{className:"flex flex-col items-center relative z-20 -mx-1",children:[e.jsx("div",{className:"w-[90px] h-[16px] bg-[#F39029] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[80px] h-[65px] bg-[#FFA23A] flex flex-col items-center justify-center gap-2.5 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-10 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-10 h-1.5 bg-white/90 rounded-full"})]})]}),e.jsxs("div",{className:"flex flex-col items-center relative z-10",children:[e.jsx("div",{className:"w-[75px] h-[14px] bg-[#D44747] rounded-t-[3px] border-x-[1.5px] border-white/90"}),e.jsxs("div",{className:"w-[65px] h-[45px] bg-[#FE6464] flex flex-col items-center justify-center gap-2 border-x-[1.5px] border-white/90",children:[e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full mt-1"}),e.jsx("div",{className:"w-8 h-1.5 bg-white/90 rounded-full"})]})]})]}),e.jsxs("div",{className:"absolute bottom-[2px] w-full flex justify-center z-30",children:[e.jsx("div",{className:"absolute top-[10px] w-full h-[35px] bg-[#8E1010] z-0"}),e.jsxs("div",{className:"relative w-[85%] h-[50px] bg-[#C62828] z-10 flex flex-col items-center justify-center rounded-[3px] shadow-[0_4px_10px_rgba(0,0,0,0.2)]",children:[e.jsx("h3",{className:"text-[18px] font-black text-white tracking-wide leading-none font-nunito mt-0.5",children:"Hall of Fame"}),e.jsx("span",{className:"text-[10px] font-bold text-white/90 tracking-wide mt-1",children:"View Page >"})]})]})]})}),e.jsxs("div",{className:"relative w-full bg-[#3b3a82] dark:bg-[#2b2b5f] rounded-[24px] overflow-hidden flex flex-col shadow-[0_8px_30px_rgba(59,58,130,0.3)]",children:[e.jsxs("div",{className:"flex flex-row items-center justify-between px-5 pt-5 pb-3 relative z-10",children:[e.jsx("h3",{className:"text-[20px] font-black text-white tracking-wide leading-none drop-shadow-md font-nunito",children:"My Stats"}),e.jsx(A,{className:"bg-[#7C51A8] hover:bg-[#6b4494] text-white font-bold text-[10px] tracking-widest uppercase rounded-full px-4 h-[28px] border border-white/10 shadow-md transition-transform active:scale-95",onClick:()=>d("stats"),children:"View Stats >"})]}),e.jsxs("div",{className:"relative z-10 w-full overflow-hidden pb-6",children:[e.jsx("div",{className:"absolute left-0 top-0 bottom-6 w-8 bg-gradient-to-r from-[#3b3a82] dark:from-[#2b2b5f] to-transparent z-20 pointer-events-none"}),e.jsx("div",{className:"absolute right-0 top-0 bottom-6 w-8 bg-gradient-to-l from-[#3b3a82] dark:from-[#2b2b5f] to-transparent z-20 pointer-events-none"}),e.jsx(y.div,{className:"flex w-max",animate:{x:["0%","-33.333333%"]},transition:{ease:"linear",duration:15,repeat:1/0},children:[1,2,3].map(t=>e.jsx("div",{className:"flex gap-3 pr-3",children:[{key:"totalXP",bg:"from-[#FF7B88] to-[#FF5C70]",shadow:"shadow-[0_4px_15px_rgba(255,92,112,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:et,value:n?.currentXP||0,label:"Total XP"},{key:"winRate",bg:"from-[#B467FF] to-[#9D44FF]",shadow:"shadow-[0_4px_15px_rgba(157,68,255,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:Kt,value:`${Math.round(te?.winRate||0)} %`,label:"Win Rate"},{key:"matches",bg:"from-[#4DB9E9] to-[#2DA1D8]",shadow:"shadow-[0_4px_15px_rgba(45,161,216,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:At,value:te?.matchesPlayed||0,label:"Matches"},{key:"response",bg:"from-[#48DA94] to-[#2BBF7B]",shadow:"shadow-[0_4px_15px_rgba(43,191,123,0.4),inset_0_1px_1px_rgba(255,255,255,0.4)]",icon:ra,value:te?.averageResponseMs?`${(te.averageResponseMs/1e3).toFixed(0)}s`:"0s",label:"Response"}].map(o=>e.jsxs("div",{className:u("w-[90px] sm:w-[100px] shrink-0 aspect-square rounded-[16px] bg-gradient-to-br p-3 flex flex-col justify-between relative overflow-hidden group",o.bg,o.shadow),children:[e.jsx("div",{className:"absolute -bottom-6 -right-6 text-white/10 transition-transform duration-500 group-hover:scale-110",children:e.jsx(o.icon,{className:"w-20 h-20"})}),e.jsx("div",{className:"w-8 h-8 rounded-full border border-white/30 flex items-center justify-center relative z-10 shadow-[inset_0_1px_3px_rgba(255,255,255,0.5)]",children:e.jsx(o.icon,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"relative z-10 flex flex-col",children:[e.jsx("h4",{className:"text-[14px] sm:text-[16px] lg:text-[18px] font-black text-white leading-none tracking-tight drop-shadow-sm",children:o.value}),e.jsx("p",{className:"text-[8px] sm:text-[9px] font-extrabold text-white/80 uppercase tracking-widest mt-1 truncate",children:o.label})]})]},o.key))},t))})]})]}),e.jsxs(pe,{className:u(fe,"rounded-[18px] flex flex-col min-h-[200px]"),children:[e.jsxs(he,{className:"pb-0 pt-3 px-4 flex flex-row items-center justify-between",children:[e.jsxs(be,{className:"text-[14px] font-black flex items-center gap-2 text-[#2e2b5e] dark:text-[#f5f7fb]",children:[e.jsx(as,{className:"h-[16px] w-[16px] text-[#2e2b5e] dark:text-[#9e8fff]"})," Match History"]}),e.jsx(A,{variant:"link",size:"sm",className:"h-auto p-0 text-[12px] font-semibold text-muted-foreground dark:text-[#95a0bb] hover:text-primary transition-colors",onClick:()=>d("history"),children:"View All"})]}),e.jsxs(Ge,{className:"space-y-1.5 px-4 pt-1 pb-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[11px] text-muted-foreground dark:text-[#8b95ad] mb-1.5 leading-relaxed",children:"Your recent student battles only."}),Pt?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"h-10 w-full rounded-xl bg-muted dark:bg-[#2a3143]"}),e.jsx(xe,{className:"h-10 w-full rounded-xl bg-muted dark:bg-[#2a3143]"})]}):Oe.length===0?e.jsx("p",{className:"text-xs text-center text-muted-foreground dark:text-[#a8b2c9] py-2",children:"No battle history yet."}):Oe.slice(0,3).map(t=>{const o=t.outcome==="win",p=t.outcome==="loss",x=t.opponentName.split(" ").map(k=>k[0]).join("").substring(0,2).toUpperCase()||"OP";return e.jsxs("div",{className:"group relative overflow-hidden rounded-[14px] border border-muted-foreground/15 bg-white dark:bg-[#11151d] dark:border-[#2f3547] p-2 shadow-sm transition-all hover:scale-[1.01] hover:shadow-md",children:[e.jsx("div",{className:u("absolute inset-y-0 right-0 w-[55%] pointer-events-none opacity-[0.2] dark:opacity-[0.25] mix-blend-multiply dark:mix-blend-screen transition-all",o?"bg-gradient-to-l from-emerald-500 via-emerald-500/40 to-transparent":p?"bg-gradient-to-l from-rose-500 via-rose-500/40 to-transparent":"bg-gradient-to-l from-amber-400 via-amber-400/40 to-transparent")}),e.jsxs("div",{className:"flex items-center gap-2.5 relative z-10 w-full",children:[e.jsx("div",{className:u("w-9 h-9 rounded-full flex items-center justify-center font-black text-[12px] tracking-wide text-white flex-shrink-0 shadow-inner",o?"bg-[#34d399] dark:bg-[#15803d]":p?"bg-[#fb7185] dark:bg-[#be123c]":"bg-[#fbbf24] dark:bg-[#b45309]"),children:x}),e.jsxs("div",{className:"flex-grow min-w-0 flex flex-col justify-center",children:[e.jsxs("p",{className:"text-[13px] font-extrabold text-[#36326e] dark:text-[#e4e7f1] truncate leading-tight",children:["vs ",t.opponentName]}),e.jsxs("p",{className:"text-[10px] font-bold text-muted-foreground/60 dark:text-[#7f88a3] truncate flex items-center gap-1 mt-0.5",children:[t.subjectId," ",e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground/30"})," ",t.difficulty||"Medium"," ",e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground/30"})," ",t.rounds||"5"," rnds"]})]}),e.jsxs("div",{className:"text-right flex flex-col items-end justify-center pl-2 flex-shrink-0",children:[e.jsxs("p",{className:"tabular-nums text-[16px] leading-[1.1] font-black text-[#2e2b5e] dark:text-[#f5f7fb] tracking-tighter",children:[t.scoreFor,e.jsx("span",{className:"text-muted-foreground/40 mx-[1px]",children:"-"}),t.scoreAgainst]}),e.jsx("p",{className:u("text-[9px] font-black uppercase tracking-[0.1em]",o?"text-emerald-500 dark:text-emerald-400":p?"text-rose-500 dark:text-rose-400":"text-amber-500 dark:text-amber-400"),children:t.outcome})]})]})]},t.matchId)})]})]})]})]})},"hub")}),e.jsx(Ce,{value:"setup",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"w-full space-y-6",children:[e.jsxs(y.div,{className:u(fe,"relative overflow-hidden rounded-[24px] mb-6 shadow-lg",l.mode==="online"?"border-purple-500/20 shadow-[0_0_40px_-10px_rgba(138,63,211,0.2)]":"border-sky-500/20 shadow-[0_0_40px_-10px_rgba(31,167,225,0.2)]"),whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:u("pointer-events-none absolute inset-0 bg-gradient-to-r",l.mode==="online"?"from-purple-500/20 via-fuchsia-500/10 to-purple-600/5 dark:from-purple-500/20 dark:via-fuchsia-500/10 dark:to-purple-900/10":"from-sky-500/20 via-cyan-500/10 to-sky-600/5 dark:from-sky-500/20 dark:via-cyan-500/10 dark:to-sky-900/10")}),e.jsx("div",{className:u("pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full blur-3xl animate-orb-pulse",l.mode==="online"?"bg-purple-400/20":"bg-sky-400/20")}),e.jsx("div",{className:u("pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full blur-2xl animate-orb-pulse-delayed",l.mode==="online"?"bg-fuchsia-400/30":"bg-cyan-400/30")}),e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAiLz4KPHBhdGggZD0iTTAgMEgxdjFIMHoiIGZpbGw9IiM2MzY2ZjEiIGZpbGwtb3BhY2l0eT0iMC4wNSIvPgo8L3N2Zz4=')] opacity-30 dark:opacity-10 mix-blend-overlay"}),e.jsxs("div",{className:"relative p-6 sm:p-8 md:px-10 flex items-center gap-5 sm:gap-8 z-10",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:u("h-12 w-12 sm:h-14 sm:w-14 p-0 rounded-full hover:scale-105 transition-all backdrop-blur-md shadow-lg shrink-0 flex items-center justify-center group",l.mode==="online"?"bg-white/50 dark:bg-black/40 hover:bg-white/80 dark:hover:bg-black/60 border border-purple-500/30":"bg-white/50 dark:bg-black/40 hover:bg-white/80 dark:hover:bg-black/60 border border-sky-500/30"),children:e.jsx(We,{className:u("h-6 w-6 sm:h-8 sm:w-8 rotate-180 transition-transform group-hover:-translate-x-0.5",l.mode==="online"?"text-purple-800 dark:text-purple-300":"text-sky-800 dark:text-sky-300")})}),e.jsxs("div",{children:[e.jsxs("h2",{className:u("flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-transparent bg-clip-text bg-gradient-to-br drop-shadow-sm",l.mode==="online"?"from-purple-600 to-fuchsia-500 dark:from-purple-300 dark:to-fuchsia-200":"from-sky-600 to-cyan-500 dark:from-sky-300 dark:to-cyan-200"),children:[e.jsx("div",{className:u("p-2 rounded-2xl shadow-inner border animate-icon-bob",l.mode==="online"?"bg-purple-100 dark:bg-purple-900/50 border-purple-200 dark:border-purple-700/50":"bg-sky-100 dark:bg-sky-900/50 border-sky-200 dark:border-sky-700/50"),children:l.mode==="online"?e.jsx(ge,{className:"h-8 w-8 text-purple-600 dark:text-purple-400 drop-shadow-[0_0_8px_rgba(138,63,211,0.5)]"}):e.jsx(Te,{className:"h-8 w-8 text-sky-600 dark:text-sky-400 drop-shadow-[0_0_8px_rgba(31,167,225,0.5)]"})}),l.mode==="online"?"1v1 Online":"1v1 vs Bot"]}),e.jsx("p",{className:u("text-[10px] sm:text-[12px] font-black uppercase tracking-[0.2em] mt-1.5 drop-shadow-sm",l.mode==="online"?"text-purple-600/80 dark:text-purple-400/80":"text-sky-600/80 dark:text-sky-400/80"),children:l.mode==="online"?"CHALLENGE YOUR SCHOOLMATES AND PROVE YOUR SKILLS.":"CHALLENGE THE AI AND SHARPEN YOUR SKILLS."})]})]})]}),e.jsx("div",{className:"rounded-[24px] border border-white/40 bg-white/85 dark:border-white/10 dark:bg-black/80 backdrop-blur-xl p-5 sm:p-7 shadow-xl",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-10",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Category"}),e.jsxs(Ne,{value:l.subjectId,onValueChange:t=>w(o=>({...o,subjectId:t})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("subjectId")&&"border-rose-400"),children:e.jsx(_e,{placeholder:"Select category"})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:ie.map(t=>e.jsx(K,{value:t.id,className:"rounded-lg",children:t.title},t.id))})]}),V("subjectId")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("subjectId")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Strand / Topic Group"}),e.jsxs(Ne,{value:l.topicId,onValueChange:t=>w(o=>({...o,topicId:t})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("topicId")&&"border-rose-400"),children:e.jsx(_e,{placeholder:"Select topic group"})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:qa.map(t=>e.jsx(K,{value:t.value,className:"rounded-lg",children:t.label},t.value))})]}),V("topicId")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("topicId")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:l.mode==="online"?"Difficulty":"Bot Difficulty"}),e.jsxs(Ne,{value:l.mode==="bot"?l.adaptiveBot?"adaptive":l.botDifficulty:l.difficulty,onValueChange:t=>w(o=>o.mode==="bot"?{...o,botDifficulty:t,adaptiveBot:t==="adaptive"}:{...o,difficulty:t}),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50"),children:e.jsx(_e,{})}),e.jsxs(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[e.jsx(K,{value:"easy",className:"rounded-lg",children:"Easy"}),e.jsx(K,{value:"medium",className:"rounded-lg",children:"Medium"}),e.jsx(K,{value:"hard",className:"rounded-lg",children:"Hard"}),l.mode==="bot"&&e.jsx(K,{value:"adaptive",className:"rounded-lg",children:"Adaptive"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[10px] sm:text-[11px] font-black uppercase tracking-[0.12em] ml-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Questions"}),e.jsxs(Ne,{value:String(l.rounds),onValueChange:t=>w(o=>({...o,rounds:Number(t)})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("rounds")&&"border-rose-400"),children:e.jsx(_e,{})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[3,5,7,10,12,15].map(t=>e.jsx(K,{value:String(t),className:"rounded-lg",children:t},t))})]}),V("rounds")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("rounds")})]}),e.jsxs("div",{className:"space-y-1.5 group",children:[e.jsx("label",{className:u("text-[10px] sm:text-[11px] font-black uppercase tracking-[0.12em] ml-1 line-clamp-1",l.mode==="online"?"text-[#8A3FD3] dark:text-[#a35ceb]":"text-[#1FA7E1] dark:text-[#4bc1f2]"),children:"Time / Q"}),e.jsxs(Ne,{value:String(l.timePerQuestionSec),onValueChange:t=>w(o=>({...o,timePerQuestionSec:Number(t)})),children:[e.jsx(ke,{className:u("rounded-xl h-11 border-white/20 bg-white/60 dark:bg-black/50 dark:border-white/10 transition-colors shadow-inner",l.mode==="online"?"hover:border-[#8A3FD3]/50":"hover:border-[#1FA7E1]/50",V("timePerQuestionSec")&&"border-rose-400"),children:e.jsx(_e,{})}),e.jsx(Se,{className:"rounded-xl backdrop-blur-xl bg-white/90 dark:bg-[#1a1f2e]/90",children:[15,20,30,45,60,90].map(t=>e.jsxs(K,{value:String(t),className:"rounded-lg",children:[t," sec"]},t))})]}),V("timePerQuestionSec")&&e.jsx("p",{className:"text-xs text-destructive dark:text-rose-300 ml-1",children:V("timePerQuestionSec")})]})]})]}),e.jsxs("div",{className:"flex flex-col justify-between space-y-6",children:[e.jsxs("div",{className:"space-y-5",children:[l.mode==="online"&&e.jsxs("div",{className:"space-y-3 rounded-2xl border border-[#8A3FD3]/20 bg-[#8A3FD3]/5 dark:border-[#8A3FD3]/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[11px] font-black uppercase tracking-[0.12em] text-[#8A3FD3] dark:text-[#a35ceb] ml-1",children:"Online Match Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"public_matchmaking",label:"Public Queue"},{value:"private_room",label:"Private Room"}].map(t=>e.jsx(A,{type:"button",variant:l.queueType===t.value?"default":"outline",className:u("rounded-xl h-11 transition-all border-none font-bold text-xs",l.queueType===t.value?"bg-[#8A3FD3] hover:bg-[#7b35c0] text-white shadow-md shadow-[#8A3FD3]/30":"bg-white/50 hover:bg-white/80 dark:bg-black/30 dark:hover:bg-black/50 text-[#8A3FD3] dark:text-[#d3a8ff]"),onClick:()=>w(o=>({...o,queueType:t.value})),children:t.label},t.value))})]}),l.queueType==="private_room"&&e.jsxs(y.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"pt-2 space-y-2",children:[e.jsx("label",{className:"text-[11px] font-black uppercase tracking-[0.12em] text-[#8A3FD3] dark:text-[#a35ceb] ml-1",children:"Room Code (optional)"}),e.jsx(ts,{value:U,onChange:t=>S(t.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6)),placeholder:"Leave blank to create a room",className:"rounded-xl h-12 text-center text-lg uppercase font-bold tracking-[0.25em] border-[#8A3FD3]/30 bg-white/80 dark:bg-black/50 dark:border-[#8A3FD3]/20 focus-visible:ring-[#8A3FD3]/50 shadow-inner",maxLength:6}),e.jsx("div",{className:"rounded-xl border border-[#8A3FD3]/30 bg-[#8A3FD3]/10 px-3 py-3 text-[12px] font-semibold text-[#6620a2] leading-snug dark:border-[#8A3FD3]/30 dark:bg-[#8A3FD3]/10 dark:text-[#d3a8ff]",children:"Enter a room code to join an existing battle, or leave it blank to create a new room and share your code."})]})]}),e.jsxs("label",{className:u("flex flex-col sm:flex-row sm:items-center justify-between rounded-[16px] border bg-white/50 p-4 transition-colors cursor-pointer shadow-sm dark:bg-black/50 group",l.mode==="online"?"border-[#8A3FD3]/20 hover:bg-[#8A3FD3]/5 dark:border-[#8A3FD3]/20 dark:hover:bg-[#8A3FD3]/10":"border-[#1FA7E1]/20 hover:bg-[#1FA7E1]/5 dark:border-[#1FA7E1]/20 dark:hover:bg-[#1FA7E1]/10"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:u("h-11 w-11 rounded-full flex items-center justify-center group-hover:scale-110 transition-transform",l.mode==="online"?"bg-[#8A3FD3]/10 text-[#8A3FD3] dark:text-[#c48bfc]":"bg-[#1FA7E1]/10 text-[#1FA7E1] dark:text-[#7ad8ff]"),children:J?e.jsx(fa,{className:"h-5 w-5"}):e.jsx(ga,{className:"h-5 w-5 opacity-60"})}),e.jsxs("div",{className:"mb-3 sm:mb-0",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 dark:text-slate-200",children:"Battle Sounds"}),e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Cues for countdowns and results."})]})]}),e.jsx(aa,{checked:J,onCheckedChange:Tt})]}),e.jsxs(y.div,{initial:!1,animate:{opacity:J?1:.45,y:J?0:-2},className:u("rounded-[16px] border bg-white/40 p-4 shadow-sm dark:bg-black/40",l.mode==="online"?"border-[#8A3FD3]/20 dark:border-[#8A3FD3]/20":"border-[#1FA7E1]/20 dark:border-[#1FA7E1]/20"),children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.14em] text-slate-700 dark:text-slate-200",children:"SFX Volume"}),e.jsxs("p",{className:"text-xs font-bold text-slate-500 dark:text-slate-400",children:[Math.round(ce*100),"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,step:1,value:Math.round(ce*100),disabled:!J,onChange:t=>{const o=Ze(Number(t.target.value)/100,0,1);Ca(o)},onMouseUp:()=>P("tick"),onTouchEnd:()=>P("tick"),className:"h-2 w-full cursor-pointer accent-violet-500 disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Battle sound effects volume"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{"aria-live":"polite",className:"min-h-[24px] text-sm font-medium",children:[N.status==="queued"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:u("inline-flex items-center gap-1 text-[13px] font-bold px-3 py-1.5 rounded-lg",l.mode==="online"?"text-[#8A3FD3] bg-[#8A3FD3]/10":"text-[#1FA7E1] bg-[#1FA7E1]/10"),children:N.message}),l.mode==="online"&&l.queueType==="private_room"&&m?.roomCode&&e.jsxs(A,{type:"button",variant:"outline",className:u("h-8 rounded-full border-emerald-500/50 bg-emerald-50 px-4 text-xs font-black uppercase tracking-[0.16em] text-emerald-900 shadow-sm hover:bg-emerald-100 hover:scale-105 transition-all dark:border-emerald-500/40 dark:bg-emerald-500/10 dark:text-emerald-300 dark:hover:bg-emerald-500/20",E===m.roomCode&&"scale-105 bg-emerald-200 dark:bg-emerald-500/30"),onClick:()=>void Ot(m.roomCode),"aria-label":`Copy room code ${m.roomCode}`,children:[E===m.roomCode?e.jsx(yt,{className:"h-4 w-4"}):e.jsx(sa,{className:"h-4 w-4"}),m.roomCode]}),(j||Zt)&&ee>0&&e.jsxs("span",{className:u("inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-bold animate-pulse",l.mode==="online"?"bg-[#8A3FD3]/10 text-[#8A3FD3]":"bg-[#1FA7E1]/10 text-[#1FA7E1]"),children:["Waiting ",ca(ee)]})]}),N.status==="error"&&e.jsx("span",{className:"inline-flex items-center gap-1.5 text-[13px] font-bold text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-500/10 px-3 py-1.5 rounded-lg border border-rose-200 dark:border-rose-500/20",children:N.message}),N.status==="validating"&&e.jsxs("span",{className:u("inline-flex items-center gap-2 font-bold px-3 py-1.5 rounded-lg",l.mode==="online"?"text-[#8A3FD3] bg-[#8A3FD3]/10":"text-[#1FA7E1] bg-[#1FA7E1]/10"),children:[e.jsx(Je,{className:"h-4 w-4 animate-spin"})," Validating..."]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[Oa&&e.jsx(A,{type:"button",variant:"outline",onClick:Gt,disabled:N.status==="validating",className:"rounded-xl h-14 flex-1 sm:flex-none border-slate-300 hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800 font-bold px-6",children:m?"Cancel room":"Leave queue"}),e.jsx(A,{type:"button",onClick:Ha,disabled:N.status==="validating"||j||Zt,className:u("rounded-xl h-14 flex-1 px-8 font-black uppercase tracking-wide text-sm shadow-xl hover:scale-[1.02] active:scale-95 transition-all text-white border-0",l.mode==="online"?"bg-[#8A3FD3] hover:bg-[#7b35c0] shadow-[#8A3FD3]/40":"bg-[#1FA7E1] hover:bg-[#1a95c9] shadow-[#1FA7E1]/40"),children:N.status==="validating"?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(Je,{className:"h-5 w-5 animate-spin"})," Starting..."]}):l.mode==="online"&&l.queueType==="private_room"?U.trim()?"Join Room":"Create Room":"Start Battle"})]})]})]})]})})]},"setup")}),e.jsx(Ce,{value:"battle",className:"mt-0 outline-none",children:e.jsx(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:r?e.jsxs(pe,{className:u(fe,"rounded-[18px]"),children:[e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.mode==="bot"?e.jsx(Te,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}):e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"vs ",r.opponentName]}),e.jsxs("div",{className:"inline-flex items-center gap-2",children:[gt,e.jsxs("span",{className:"text-sm font-bold tabular-nums",children:[r.scoreFor," - ",r.scoreAgainst]})]})]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:r.status==="completed"?`Completed in ${r.totalRounds} rounds.`:r.status==="ready"?r.mode==="online"?"Waiting for both players to confirm and start together.":"Finalizing practice bot session start.":`Round ${r.currentRound} of ${r.totalRounds}${M?" (paused for design)":""}`}),ua(r.lifecycle,n?.uid)&&e.jsx("p",{className:"text-xs font-medium text-muted-foreground dark:text-[#9aa4be]",children:ua(r.lifecycle,n?.uid)})]}),e.jsxs(Ge,{className:"space-y-4",children:[r.status==="ready"&&e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-4 dark:border-[#2f3547] dark:bg-[#11151d] flex flex-col gap-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:r.mode==="online"?"Waiting for both players to lock in start...":"Starting practice bot round..."}),r.mode==="online"&&r.expiresAtMs&&e.jsxs("p",{className:"text-xs font-medium text-muted-foreground dark:text-[#9aa4be]",children:["Public match expires in ",e.jsx("span",{className:"font-semibold tabular-nums",children:ca(ee)})," if the synchronized start does not happen."]}),e.jsx(A,{variant:"outline",size:"sm",className:"w-full text-rose-500 border-rose-200 hover:bg-rose-50 dark:border-rose-900 dark:hover:bg-rose-900/30",onClick:()=>{_(null),v(null),h(!1),b({status:"idle"}),d("setup")},children:"Force Cancel"})]}),r.status==="in_progress"&&r.currentQuestion&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-border bg-muted/40 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Time left: ",e.jsxs("span",{className:"font-semibold tabular-nums",children:[D,"s"]}),M?" (paused)":""]}),M&&e.jsx("p",{className:"mt-1 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:"Design pause keeps this battle screen static while you edit UI."})]}),e.jsx("p",{className:"text-lg font-bold text-foreground dark:text-[#f5f7fb]",children:r.currentQuestion.prompt}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.currentQuestion.choices.map((t,o)=>e.jsxs(A,{type:"button",variant:ve===o?"default":"outline",onClick:()=>Y(o),disabled:X||G||M,className:u("h-auto min-h-[48px] justify-start text-left font-medium px-4 py-3 rounded-xl whitespace-normal",ve===o?"ring-2 ring-primary ring-offset-2 dark:ring-offset-[#0B0F19]":""),children:[e.jsxs("span",{className:"mr-2 font-semibold",children:[String.fromCharCode(65+o),"."]}),t]},o))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(A,{type:"button",onClick:()=>void Ue(ve),disabled:X||G||M,className:"rounded-xl",children:M?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(is,{className:"h-4 w-4"})," Paused for design"]}):X?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4 animate-spin"})," Submitting..."]}):G?"Waiting for opponent...":"Lock Answer"})})]}),B&&e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:["Last round: ",B.studentCorrect?"Correct":"Incorrect"," · ",r.mode==="bot"?"Bot":"Opponent"," ",B.botCorrect?"Correct":"Incorrect"]}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Correct option: ",String.fromCharCode(65+B.correctOptionIndex)]})]}),r.status==="completed"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:u("rounded-2xl border p-4",r.outcome==="win"?"border-emerald-300 bg-emerald-50 dark:border-emerald-400/40 dark:bg-emerald-900/20":r.outcome==="loss"?"border-rose-300 bg-rose-50 dark:border-rose-400/40 dark:bg-rose-900/20":"border-amber-300 bg-amber-50 dark:border-amber-400/40 dark:bg-amber-900/20"),children:[e.jsx("p",{className:"text-lg font-black tracking-wide text-foreground dark:text-[#ecf0fb]",children:r.outcome==="win"?"Victory!":r.outcome==="loss"?"Match Complete":"Draw Match"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:["Final Score: ",r.scoreFor," - ",r.scoreAgainst]}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["XP Earned: +",r.xpBreakdown?.totalXPAwarded??r.xpEarned??0,r.xpBreakdown&&e.jsxs("span",{className:"block",children:["Base: +",r.xpBreakdown.baseMatchXP," + Performance: +",r.xpBreakdown.performanceXP]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(A,{type:"button",variant:"outline",onClick:()=>{_(null),v(null),h(!1),d("setup")},className:"rounded-xl",children:"Start New Match"}),r.mode==="bot"&&e.jsx(A,{type:"button",onClick:()=>void Yt(),disabled:X,className:"rounded-xl",children:"Rematch"})]})]})]})]}):m?e.jsxs(pe,{className:u(fe,"rounded-[18px]"),children:[e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"Private Room Lobby"]}),e.jsxs(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:["Room ",m.roomCode," · ",m.participantCount,"/2 students connected."]})]}),e.jsx(Ge,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-xl border border-border bg-muted/30 p-3 dark:border-[#2f3547] dark:bg-[#11151d]",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground dark:text-[#ecf0fb]",children:m.status==="ready"?"Opponent connected. Syncing start...":"Waiting for another student to join this room."}),e.jsxs("p",{className:"text-xs text-muted-foreground dark:text-[#9aa4be]",children:["Share room code ",m.roomCode," with your classmate."]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[(m.status==="waiting"||m.status==="ready")&&e.jsx(A,{type:"button",variant:"outline",className:"h-8 rounded-lg",onClick:Gt,disabled:N.status==="validating",children:"Cancel room"}),e.jsxs(A,{type:"button",variant:"outline",className:"h-8 rounded-lg",onClick:()=>void Ot(m.roomCode),children:[E===m.roomCode?e.jsx(yt,{className:"h-4 w-4"}):e.jsx(sa,{className:"h-4 w-4"}),E===m.roomCode?"Copied":"Copy code"]})]})]})})]}):j?e.jsx(pe,{className:u(fe,"rounded-[18px]"),children:e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"Public Matchmaking"]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:"Searching for a student with the same setup..."})]})}):e.jsx(pe,{className:u(fe,"rounded-[18px]"),children:e.jsxs(he,{children:[e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(wt,{className:"h-4 w-4 text-primary dark:text-[#9e8fff]"}),"No active battle"]}),e.jsx(Ae,{className:"text-muted-foreground dark:text-[#b2bad0]",children:"Start from Setup to create a bot match, private room, or public queue session."})]})})},"battle")}),e.jsx(Ce,{value:"history",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-emerald-500/10 via-teal-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-emerald-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-teal-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(16,185,129,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-emerald-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx("div",{className:"bg-emerald-500/20 p-2 rounded-2xl shadow-inner border border-emerald-500/30",children:e.jsxs("div",{className:"relative w-8 h-8 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-5 h-6 bg-emerald-500/30 border border-emerald-400/50 rounded-sm -rotate-12 translate-x-1 shadow-sm"}),e.jsx("div",{className:"absolute w-5 h-6 bg-teal-400/50 border border-teal-300/60 rounded-sm rotate-6 -translate-x-1 shadow-md backdrop-blur-sm"}),e.jsxs("div",{className:"absolute w-5 h-6 bg-gradient-to-br from-emerald-400 to-teal-500 rounded-sm shadow-[0_0_15px_rgba(52,211,153,0.8)] z-10 flex flex-col items-center justify-center gap-[3px]",children:[e.jsx("div",{className:"w-2.5 h-[2px] bg-white/90 rounded-full"}),e.jsx("div",{className:"w-3 h-[2px] bg-white/90 rounded-full"}),e.jsx("div",{className:"w-2 h-[2px] bg-white/90 rounded-full"})]})]})}),"Matches History"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"Review your past duels and track your progress."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[-10%] right-[-5%] w-[400px] h-[400px] bg-blue-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[-10%] left-[-5%] w-[350px] h-[350px] bg-teal-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsxs("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-xl font-black text-white tracking-wide leading-none drop-shadow-md",children:"Match History"}),e.jsx("p",{className:"text-sm font-semibold text-white/60 mt-2",children:"Your recent student battles only."})]}),e.jsx("div",{className:"flex gap-2 mb-6",children:[{value:"all",label:"All"},{value:"online",label:"Online"},{value:"bot",label:"Bot"}].map(t=>e.jsx(A,{type:"button",variant:"outline",onClick:()=>za(t.value),className:u("rounded-full h-9 px-5 border transition-all font-bold tracking-wide",we===t.value?"bg-emerald-500/20 border-emerald-500/50 text-emerald-300 shadow-[0_0_15px_rgba(16,185,129,0.2)]":"bg-white/5 border-white/10 text-white/70 hover:bg-white/10 hover:text-white"),children:t.label},t.value))}),e.jsx("div",{className:"space-y-4",children:Pt?e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{className:"h-[76px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[76px] w-full rounded-2xl bg-white/5 border border-white/10"})]}):Oe.length===0?e.jsx("p",{className:"text-sm text-white/50 py-4",children:"No matches in this filter yet."}):Oe.map(t=>{const o=t.outcome==="win",p=t.outcome==="loss";return e.jsxs("div",{className:"relative overflow-hidden rounded-[20px] bg-white/5 border border-white/10 p-5 flex items-center justify-between shadow-lg transition-all hover:bg-white/10 hover:shadow-xl",children:[e.jsx("div",{className:u("absolute inset-y-0 left-0 w-3/4 pointer-events-none z-0",o?"bg-gradient-to-r from-emerald-500/50 via-emerald-500/10 to-transparent":p?"bg-gradient-to-r from-rose-500/50 via-rose-500/10 to-transparent":"bg-gradient-to-r from-amber-500/50 via-amber-500/10 to-transparent")}),e.jsxs("div",{className:"relative z-10 pl-2",children:[e.jsxs("p",{className:"text-base sm:text-lg font-black text-white drop-shadow-md",children:["vs ",t.opponentName]}),e.jsxs("p",{className:"text-[13px] font-bold text-white/60 tabular-nums mt-0.5",children:[t.scoreFor,"-",t.scoreAgainst," ",e.jsx("span",{className:"mx-1",children:"•"})," ",t.accuracy.toFixed(0),"% ",e.jsx("span",{className:"mx-1",children:"•"})," +",t.xpEarned," XP"]})]}),e.jsx("div",{className:"relative z-10",children:e.jsx("span",{className:u("text-sm font-black uppercase tracking-[0.1em] rounded-full px-4 py-1.5 border shadow-sm",o?"text-emerald-300 border-emerald-500/30 bg-emerald-500/10 shadow-[0_0_15px_rgba(16,185,129,0.15)]":p?"text-rose-300 border-rose-500/30 bg-rose-500/10 shadow-[0_0_15px_rgba(244,63,94,0.15)]":"text-amber-300 border-amber-500/30 bg-amber-500/10 shadow-[0_0_15px_rgba(245,158,11,0.15)]"),children:Ts(t.outcome)})})]},t.matchId)})})]})]})]},"history")}),e.jsx(Ce,{value:"stats",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-indigo-500/10 via-purple-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-indigo-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-purple-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(99,102,241,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-indigo-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx("div",{className:"bg-indigo-500/20 p-2 rounded-2xl shadow-inner border border-indigo-500/30 animate-icon-bob",children:e.jsxs("div",{className:"relative w-8 h-8 flex items-end justify-center gap-1 pb-1",children:[e.jsx("div",{className:"w-1.5 h-3 bg-indigo-300 rounded-t-[2px] shadow-[0_0_8px_rgba(165,180,252,0.8)]"}),e.jsx("div",{className:"w-1.5 h-6 bg-purple-400 rounded-t-[2px] shadow-[0_0_12px_rgba(192,132,252,0.9)]"}),e.jsx("div",{className:"w-1.5 h-4 bg-indigo-400 rounded-t-[2px] shadow-[0_0_8px_rgba(129,140,248,0.8)]"})]})}),"My Statistics"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"Analyzing your battlefield performance."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[0%] left-[10%] w-[350px] h-[350px] bg-indigo-500/30 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[0%] right-[10%] w-[300px] h-[300px] bg-purple-500/30 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 sm:gap-6",children:[{label:"WINS",value:te?.wins??0,icon:Kt,textColor:"text-rose-400",gradient:"radial-gradient(circle at 10% 90%, rgba(244,63,94,0.35) 0%, transparent 70%)"},{label:"CURRENT STREAK",value:te?.currentStreak??0,icon:et,textColor:"text-purple-400",gradient:"radial-gradient(circle at 10% 90%, rgba(168,85,247,0.35) 0%, transparent 70%)"},{label:"AVG ACCURACY",value:`${(te?.averageAccuracy||0).toFixed(1)}%`,icon:At,textColor:"text-blue-400",gradient:"radial-gradient(circle at 10% 90%, rgba(59,130,246,0.35) 0%, transparent 70%)"},{label:"AVG RESPONSE",value:Rs(te?.averageResponseMs||0),icon:ra,textColor:"text-teal-400",gradient:"radial-gradient(circle at 10% 90%, rgba(20,184,166,0.35) 0%, transparent 70%)"}].map(t=>e.jsxs("div",{className:"relative overflow-hidden rounded-[20px] bg-white/5 border border-white/10 shadow-lg min-h-[160px] flex flex-col justify-between p-6 transition-transform hover:scale-105",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none z-0 mix-blend-screen",style:{background:t.gradient}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("p",{className:u("text-[11px] font-black uppercase tracking-[0.15em] mb-3",t.textColor),children:t.label}),e.jsx("p",{className:"text-4xl sm:text-5xl font-black text-white tabular-nums tracking-tighter drop-shadow-md",children:t.value})]}),e.jsx("div",{className:"relative z-10 mt-6 flex justify-start",children:e.jsx(t.icon,{className:u("h-5 w-5 drop-shadow-md",t.textColor)})})]},t.label))})})]})]},"stats")}),e.jsx(Ce,{value:"leaderboard",className:"mt-0 outline-none",children:e.jsxs(y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},className:"space-y-4",children:[e.jsxs(y.div,{className:"relative overflow-hidden rounded-[24px] mb-6 bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl",whileHover:{scale:1.01},transition:{type:"spring",stiffness:300,damping:20},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-r from-amber-500/10 via-orange-500/5 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute -top-24 -right-24 h-64 w-64 rounded-full bg-amber-500/20 blur-3xl animate-orb-pulse"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -left-12 h-40 w-40 rounded-full bg-orange-500/20 blur-2xl animate-orb-pulse-delayed"}),e.jsx("div",{className:"relative z-10 p-6 sm:p-8 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx(A,{variant:"ghost",onClick:()=>d("hub"),className:"h-12 w-12 p-0 rounded-full bg-white/10 hover:bg-white/20 hover:scale-105 transition-all backdrop-blur-md border border-white/10 shadow-[0_0_15px_rgba(245,158,11,0.15)] shrink-0",children:e.jsx(We,{className:"h-6 w-6 rotate-180 text-amber-300"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-3 text-3xl sm:text-4xl font-black tracking-tight text-white drop-shadow-md",children:[e.jsx(y.div,{animate:{scale:[1,1.1,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"bg-amber-500/20 p-2 rounded-2xl shadow-inner border border-amber-500/30",children:e.jsx(Jt,{className:"h-8 w-8 text-amber-400 drop-shadow-[0_0_12px_rgba(245,158,11,0.8)]"})}),"Hall of Fame"]}),e.jsx("p",{className:"text-[12px] font-black text-white/60 mt-2 tracking-[0.1em] uppercase",children:"The top-ranked minds across the globe."})]})]})})]}),e.jsxs("div",{className:"relative isolate w-full",children:[e.jsx("div",{className:"absolute top-[20%] left-[20%] w-[400px] h-[400px] bg-orange-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[350px] h-[350px] bg-pink-500/20 rounded-full blur-[120px] pointer-events-none -z-10"}),e.jsxs("div",{className:"rounded-[24px] bg-white/5 border border-white/10 shadow-2xl backdrop-blur-3xl p-6 sm:p-8",children:[e.jsxs("div",{className:"mb-8 flex items-start gap-3",children:[e.jsx(Jt,{className:"h-8 w-8 text-amber-400 drop-shadow-[0_0_12px_rgba(245,158,11,0.6)] shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-black text-white tracking-wide leading-none drop-shadow-md",children:"Hall of Fame"}),e.jsx("p",{className:"text-sm font-semibold text-white/60 mt-2",children:"Student-only ranking using trusted backend aggregates."})]})]}),Ia?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"}),e.jsx(xe,{className:"h-[80px] w-full rounded-2xl bg-white/5 border border-white/10"})]}):Wt.length===0?e.jsx("p",{className:"text-sm text-white/50",children:"No leaderboard entries yet. Finish a battle to place on the board."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-4 transition-colors hover:bg-white/10",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-white/50 mb-3",children:"Name display"}),e.jsxs(Ne,{value:Qe,onValueChange:t=>Ma(t),children:[e.jsx(ke,{className:"h-10 rounded-xl bg-black/20 border-white/10 text-white font-bold hover:bg-black/30",children:e.jsx(_e,{})}),e.jsxs(Se,{className:"rounded-xl border border-white/10 bg-[#161a25]/95 backdrop-blur-xl",children:[e.jsx(K,{value:"alias",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Alias"}),e.jsx(K,{value:"initials",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Initials"}),e.jsx(K,{value:"full",className:"text-white hover:bg-white/10 rounded-lg focus:bg-white/10 focus:text-white",children:"Full name"})]})]})]}),e.jsxs("label",{className:"rounded-2xl border border-white/10 bg-white/5 p-4 flex items-center justify-between gap-4 transition-colors hover:bg-white/10 cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-white/50 mb-1",children:"Score detail"}),e.jsx("p",{className:"text-sm font-bold text-white/90",children:"Show exact score values"})]}),e.jsx(aa,{checked:ct,onCheckedChange:Fa})]})]}),e.jsx("p",{className:"text-[13px] font-semibold text-white/40 leading-relaxed px-1",children:"Privacy mode keeps classmate identities and scores obfuscated by default while preserving your own exact rank and score."}),e.jsx("div",{className:"space-y-3",children:Wt.map(t=>e.jsxs("div",{className:u("relative overflow-hidden rounded-[20px] p-5 flex items-center justify-between shadow-lg transition-all hover:scale-[1.01] group",t.isSelf?"bg-amber-500/10 border border-amber-500/40 shadow-[0_0_20px_rgba(245,158,11,0.15)]":"bg-white/5 border border-white/10 hover:bg-white/10"),children:[t.isSelf&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-amber-500/20 to-transparent pointer-events-none -z-10"}),e.jsxs("div",{className:"relative z-10 flex flex-col gap-1.5",children:[e.jsxs("h4",{className:u("text-lg sm:text-xl font-black drop-shadow-md",t.isSelf?"text-amber-400":"text-white"),children:["#",t.rank," ",t.displayName,t.isSelf?" (You)":""]}),e.jsxs("p",{className:"text-[13px] font-bold text-white/60",children:["Win rate ",t.winRate.toFixed(1),"% ",e.jsx("span",{className:"mx-1",children:"•"})," Best streak ",t.bestStreak]})]}),e.jsx("div",{className:"relative z-10 text-xl sm:text-2xl font-black text-white tabular-nums drop-shadow-md",children:t.scoreLabel})]},t.userId))})]})]})]})]},"leaderboard")})]})})})})]})};export{dr as default}; diff --git a/assets/RewardsModal-DfvIngtK.js b/assets/RewardsModal-DfvIngtK.js new file mode 100644 index 0000000000000000000000000000000000000000..709cd28ef7c5f35af909c62ea031b07177fde504 --- /dev/null +++ b/assets/RewardsModal-DfvIngtK.js @@ -0,0 +1 @@ +import{r as d,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CP9q7ISf.js";import{aL as u,A as j,aM as U,aN as P,U as B,D as $,N as I,x as R,W as L,T as g,aO as M,a0 as N,R as T,S as q,X,V as w,a1 as v,B as G,Z as H,p as V,z as W,G as Z,a as O,aF as Q,g as J}from"./index-B3ruOzo6.js";import{X as K}from"./x-BNHnAXzL.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:O,GraduationCap:Z,Trophy:W,Target:V,Zap:H,Brain:G,Star:v,Flame:w,Swords:X,Shield:q,RefreshCw:T,Crown:N,Sun:M,TrendingUp:g,Globe:L,User:R,UserPlus:I,Calendar:$,Users:B,Compass:P,Heart:U,Award:j},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:i})=>{const[y,b]=d.useState(!0),[k,_]=d.useState(new Set),[E,C]=d.useState({});d.useEffect(()=>{if(!o||!i)return;(async()=>{b(!0);try{const t=await Q(i);_(new Set(t.map(a=>a.id)));const r=await F(S(J,"progress",i));r.exists()&&C(r.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,i]);const D=s=>{const{condition:t,threshold:r}=s,a=E;let l=0,f=r??1;switch(t){case"lesson_complete":l=a.totalLessonsCompleted||0;break;case"quiz_complete":l=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":l=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":l=a.consecutiveDaysActive||0;break;case"mastery_xp":l=p;break;case"explore_friend_added":case"social_friend":case"explore_social":l=a.friendsAdded||0;break;case"perfect_score":{l=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(l,f),total:f}},h=u.map(s=>{const t=Y[s.icon.name]??j,r=k.has(s.id),a=D(s);return{id:s.id,icon:t,title:s.title,description:s.description,progress:a?.progress,total:a?.total,unlocked:r,color:r?s.iconColor:"text-slate-500",bgColor:r?s.iconColor.replace("text-","bg-").replace("-500","/10").replace("-400","/10").replace("-600","/10"):"bg-slate-100"}}),z=h.filter(s=>s.unlocked).length;return o?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-8",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:c}),e.jsxs("div",{className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-6 text-white relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_14%_12%,rgba(251,150,187,0.35),transparent_42%),radial-gradient(circle_at_80%_80%,rgba(117,208,106,0.25),transparent_38%)]"}),e.jsxs("div",{className:"flex items-center justify-between mb-4 relative z-10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",u.length," Achievements Unlocked"]})]}),e.jsx("button",{onClick:c,className:"text-white/90 hover:text-white hover:bg-white/20 p-2 rounded-xl transition-colors",children:e.jsx(K,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(N,{size:18,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(v,{size:18,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(w,{size:18,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-2xl font-bold",children:"Check-in"})]})]}),e.jsxs("div",{className:"mt-4 relative z-10",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n]}),e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n+1]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsxs("span",{className:"text-xs text-white/90",children:[x," / ",m," XP"]})}),e.jsx("div",{className:"h-3 bg-white/20 rounded-full overflow-hidden border border-white/20",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full transition-all duration-500 e-w",style:{"--w":`${x/m*100}%`}})})]})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:y?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-[#9956DE] border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628] mb-4",children:"Achievements"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:h.map(s=>{const t=s.icon;return e.jsx("div",{className:`${s.unlocked?"bg-white border-[#9956DE]/25":"bg-[#edf1f7] border-[#dde3eb]"} border-2 rounded-xl p-4 transition-all ${s.unlocked?"shadow-md":"opacity-60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-12 h-12 ${s.bgColor} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(t,{size:24,className:s.color})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:`text-sm font-bold ${s.unlocked?"text-[#0a1628]":"text-slate-500"} font-body`,children:s.title}),s.unlocked&&e.jsx("span",{className:"px-2 py-0.5 bg-[#75D06A] text-white text-[9px] font-bold rounded-full",children:"Unlocked"})]}),e.jsx("p",{className:`text-xs ${s.unlocked?"text-[#5a6578]":"text-slate-500"} mb-2`,children:s.description}),s.progress!==void 0&&s.total!==void 0&&!s.unlocked&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Progress"}),e.jsxs("span",{className:"text-[10px] font-bold text-[#5a6578]",children:[s.progress," / ",s.total]})]}),e.jsx("div",{className:"h-1.5 bg-[#dde3eb] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#7274ED] to-[#1FA7E1] rounded-full transition-all e-w",style:{"--w":`${s.progress/s.total*100}%`}})})]})]})]})},s.id)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-[#7274ED] to-[#1FA7E1] rounded-lg flex items-center justify-center",children:e.jsx(g,{size:16,className:"text-white"})}),e.jsx("h3",{className:"text-base font-display font-bold text-[#0a1628]",children:"How to Earn XP"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{activity:"Complete a video lesson",xp:50},{activity:"Complete exercises",xp:100},{activity:"Perfect quiz score",xp:150},{activity:"Finish a quiz",xp:75},{activity:"Daily check-in",xp:"20-100"}].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-[#1FA7E1] rounded-full"}),e.jsxs("span",{className:"text-xs text-[#5a6578] font-body",children:[s.activity,":"]}),e.jsxs("span",{className:"text-xs font-bold text-[#7274ED]",children:["+",s.xp," XP"]})]},t))})]})]})})]})]}):null};export{me as default}; diff --git a/assets/RewardsModal-gGwAMPUb.js b/assets/RewardsModal-gGwAMPUb.js deleted file mode 100644 index 3f499b088a3bf35d5443609f72596407ee052760..0000000000000000000000000000000000000000 --- a/assets/RewardsModal-gGwAMPUb.js +++ /dev/null @@ -1 +0,0 @@ -import{r as d,j as e}from"./vendor-react-B4AQeu28.js";import{getDoc as F,doc as S}from"./vendor-firebase-firestore-CP9q7ISf.js";import{aJ as u,A as j,aK as U,aL as P,U as $,D as B,aM as I,y as R,aN as q,T as g,aO as L,Y as N,R as M,S as T,V as G,Q as w,$ as v,B as H,Z as X,q as Q,z as V,G as Z,a as J,aD as K,h as O}from"./index-mbyiCUYG.js";import{X as W}from"./x-oZO0Ye1Q.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";const Y={BookOpen:J,GraduationCap:Z,Trophy:V,Target:Q,Zap:X,Brain:H,Star:v,Flame:w,Swords:G,Shield:T,RefreshCw:M,Crown:N,Sun:L,TrendingUp:g,Globe:q,User:R,UserPlus:I,Calendar:B,Users:$,Compass:P,Heart:U,Award:j},me=({isOpen:o,onClose:c,userLevel:n,currentXP:x,xpToNextLevel:m,totalXP:p,userId:i})=>{const[y,b]=d.useState(!0),[k,_]=d.useState(new Set),[E,C]=d.useState({});d.useEffect(()=>{if(!o||!i)return;(async()=>{b(!0);try{const t=await K(i);_(new Set(t.map(a=>a.id)));const r=await F(S(O,"progress",i));r.exists()&&C(r.data())}catch(t){console.error("Error loading achievements:",t)}finally{b(!1)}})()},[o,i]);const D=s=>{const{condition:t,threshold:r}=s,a=E;let l=0,f=r??1;switch(t){case"lesson_complete":l=a.totalLessonsCompleted||0;break;case"quiz_complete":l=a.totalQuizzesCompleted||0;break;case"battle_win":case"battle_undefeated":l=a.battleWins||0;break;case"mastery_10":case"social_streak_30":case"social_daily_return":l=a.consecutiveDaysActive||0;break;case"mastery_xp":l=p;break;case"explore_friend_added":case"social_friend":case"explore_social":l=a.friendsAdded||0;break;case"perfect_score":{l=(a.quizAttempts||[]).filter(A=>A.score===100).length;break}default:return}return{progress:Math.min(l,f),total:f}},h=u.map(s=>{const t=Y[s.icon.name]??j,r=k.has(s.id),a=D(s);return{id:s.id,icon:t,title:s.title,description:s.description,progress:a?.progress,total:a?.total,unlocked:r,color:r?s.iconColor:"text-slate-500",bgColor:r?s.iconColor.replace("text-","bg-").replace("-500","/10").replace("-400","/10").replace("-600","/10"):"bg-slate-100"}}),z=h.filter(s=>s.unlocked).length;return o?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-8",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:c}),e.jsxs("div",{className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-2xl max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#9956DE] via-[#7274ED] to-[#1FA7E1] p-6 text-white relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_14%_12%,rgba(251,150,187,0.35),transparent_42%),radial-gradient(circle_at_80%_80%,rgba(117,208,106,0.25),transparent_38%)]"}),e.jsxs("div",{className:"flex items-center justify-between mb-4 relative z-10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold",children:"Rewards & Achievements"}),e.jsxs("p",{className:"text-white/90 text-sm font-body",children:[z," / ",u.length," Achievements Unlocked"]})]}),e.jsx("button",{onClick:c,className:"text-white/90 hover:text-white hover:bg-white/20 p-2 rounded-xl transition-colors",children:e.jsx(W,{size:24})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(N,{size:18,className:"text-[#FFB356]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Level"})]}),e.jsx("p",{className:"text-2xl font-bold",children:n})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(v,{size:18,className:"text-[#6ED1CF]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Total XP"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.toLocaleString()})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-xl p-4 border border-white/25",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(w,{size:18,className:"text-[#FF8B8B]"}),e.jsx("span",{className:"text-xs font-medium text-white/90 font-body",children:"Daily Rewards"})]}),e.jsx("p",{className:"text-2xl font-bold",children:"Check-in"})]})]}),e.jsxs("div",{className:"mt-4 relative z-10",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n]}),e.jsxs("span",{className:"text-sm font-bold text-white font-body",children:["Level ",n+1]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsxs("span",{className:"text-xs text-white/90",children:[x," / ",m," XP"]})}),e.jsx("div",{className:"h-3 bg-white/20 rounded-full overflow-hidden border border-white/20",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#6ED1CF] via-[#75D06A] to-[#FFB356] rounded-full transition-all duration-500 e-w",style:{"--w":`${x/m*100}%`}})})]})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:y?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-[#9956DE] border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628] mb-4",children:"Achievements"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:h.map(s=>{const t=s.icon;return e.jsx("div",{className:`${s.unlocked?"bg-white border-[#9956DE]/25":"bg-[#edf1f7] border-[#dde3eb]"} border-2 rounded-xl p-4 transition-all ${s.unlocked?"shadow-md":"opacity-60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-12 h-12 ${s.bgColor} rounded-xl flex items-center justify-center flex-shrink-0`,children:e.jsx(t,{size:24,className:s.color})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:`text-sm font-bold ${s.unlocked?"text-[#0a1628]":"text-slate-500"} font-body`,children:s.title}),s.unlocked&&e.jsx("span",{className:"px-2 py-0.5 bg-[#75D06A] text-white text-[9px] font-bold rounded-full",children:"Unlocked"})]}),e.jsx("p",{className:`text-xs ${s.unlocked?"text-[#5a6578]":"text-slate-500"} mb-2`,children:s.description}),s.progress!==void 0&&s.total!==void 0&&!s.unlocked&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Progress"}),e.jsxs("span",{className:"text-[10px] font-bold text-[#5a6578]",children:[s.progress," / ",s.total]})]}),e.jsx("div",{className:"h-1.5 bg-[#dde3eb] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-[#7274ED] to-[#1FA7E1] rounded-full transition-all e-w",style:{"--w":`${s.progress/s.total*100}%`}})})]})]})]})},s.id)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-[#dde3eb]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-[#7274ED] to-[#1FA7E1] rounded-lg flex items-center justify-center",children:e.jsx(g,{size:16,className:"text-white"})}),e.jsx("h3",{className:"text-base font-display font-bold text-[#0a1628]",children:"How to Earn XP"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{activity:"Complete a video lesson",xp:50},{activity:"Complete exercises",xp:100},{activity:"Perfect quiz score",xp:150},{activity:"Finish a quiz",xp:75},{activity:"Daily check-in",xp:"20-100"}].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-[#1FA7E1] rounded-full"}),e.jsxs("span",{className:"text-xs text-[#5a6578] font-body",children:[s.activity,":"]}),e.jsxs("span",{className:"text-xs font-bold text-[#7274ED]",children:["+",s.xp," XP"]})]},t))})]})]})})]})]}):null};export{me as default}; diff --git a/assets/RightSidebar-C9HBuSrc.js b/assets/RightSidebar-C9HBuSrc.js deleted file mode 100644 index eda6788489c801bec468cbca7718d45d0e891cc5..0000000000000000000000000000000000000000 --- a/assets/RightSidebar-C9HBuSrc.js +++ /dev/null @@ -1 +0,0 @@ -import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{g as B,m as c,Z as _,V as q,X as P,z as W,Y as v,$ as X,p as Y,y as k}from"./index-mbyiCUYG.js";import{C as M}from"./circle-check-big-BnoZ8KZB.js";import{T as O,a as Z,b as H}from"./tooltip-Cd2m83Wr.js";import{C as T}from"./chevron-right-bwYIKoxv.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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}`},V=({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(V,{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/RightSidebar-GlSyU02g.js b/assets/RightSidebar-GlSyU02g.js new file mode 100644 index 0000000000000000000000000000000000000000..88aa547882cbd6a09e02795cf97b2d1519cd0466 --- /dev/null +++ b/assets/RightSidebar-GlSyU02g.js @@ -0,0 +1 @@ +import{r as o,j as e}from"./vendor-react-B4AQeu28.js";import{q as S}from"./quiz_battle_avatar-BXHPSput.js";import{k as B,m as c,Z as E,X as q,$ as P,z as W,a0 as v,a1 as X,o as Y,x as _}from"./index-B3ruOzo6.js";import{C as M}from"./circle-check-big-CWdn1Nqf.js";import{T as O,a as Z,b as H}from"./tooltip-CLSYbTYK.js";import{C as T}from"./chevron-right-CbkkCalp.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";const k=[{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(E,{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)%k.length)},5e3);return()=>clearInterval(r)},[]);const t=k[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(E,{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(_,{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(_,{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-C3ad9xEg.js b/assets/ScientificCalculator-C0Zl3TP5.js similarity index 98% rename from assets/ScientificCalculator-C3ad9xEg.js rename to assets/ScientificCalculator-C0Zl3TP5.js index 486f735ccbc2b9b4ebb947beb13b3338dd33df73..560cd47ea0a5a675a63907d1b03a86c92fed45a2 100644 --- a/assets/ScientificCalculator-C3ad9xEg.js +++ b/assets/ScientificCalculator-C0Zl3TP5.js @@ -1,4 +1,4 @@ -import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{c as Z,j as de,g as U,m as ue}from"./index-mbyiCUYG.js";import{a as fe,C as pe}from"./chevron-up-B_-cQcm8.js";import{X as be}from"./x-oZO0Ye1Q.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";/** +import{r as c,j as e}from"./vendor-react-B4AQeu28.js";import{e as Z,i as de,k as U,m as ue}from"./index-B3ruOzo6.js";import{a as fe,C as pe}from"./chevron-up-CTb5_AvY.js";import{X as be}from"./x-BNHnAXzL.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-CQfmcUsu.js b/assets/SettingsModal-CQfmcUsu.js deleted file mode 100644 index 912991424d0238c82ebd67f7a3e03c7337052e72..0000000000000000000000000000000000000000 --- a/assets/SettingsModal-CQfmcUsu.js +++ /dev/null @@ -1,17 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-mbyiCUYG.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.js","assets/vendor-radix-xDOIcVzp.js","assets/vendor-charts-Ckgeb0nY.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CoeUXWgK.css"])))=>i.map(i=>d[i]); -import{c as se,l as Te,aQ as Le,aR as Me,aS as _e,aT as De,aU as qe,aV as Ie,y as Fe,S as Ve,aN as Oe,a as Ge,g as He,m as V,L as Ue,_ as fe,n as x,aW as Qe,aX as Xe,aY as Be,aZ as We}from"./index-mbyiCUYG.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{S as Ye,a as $e,b as Je,c as Ke,d as Z}from"./select-B04HpeAZ.js";import{B as f}from"./button-BqKfG4Jj.js";import{I as n}from"./input-DEPoMoHZ.js";import{S as d}from"./switch-CHYfNJFI.js";import pe from"./ConfirmModal-BsY1WFdG.js";import{P as Ze,M as es,V as ss}from"./ProfilePictureUploader-Byg9gnjl.js";import{B as ye}from"./bell-D_pyutJs.js";import{D as je}from"./download-C2PVrIq3.js";import{X as ge}from"./x-oZO0Ye1Q.js";import{C as ts}from"./circle-help-BP0kOuya.js";import{C as as}from"./clock-BLtPbCgT.js";import{T as ns}from"./trash-2-8qZ3aehj.js";import{E as is,a as ls}from"./eye-DakyBxPE.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-B_-cQcm8.js";import"./check-BLN5Dl8e.js";import"./log-out-Ddy014zi.js";import"./minus-BEbLkPkH.js";import"./plus-CbpDHvDO.js";import"./upload-CKMt4jtd.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 rs=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],cs=se("palette",rs);/** - * @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 os=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ds=se("server",os);/** - * @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 xs=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],ms=se("smartphone",xs),hs=()=>{const{userProfile:m,userRole:y}=Te(),[l,E]=a.useState(Le),[z,R]=a.useState(Me),[C,T]=a.useState(!1),[_,S]=a.useState(null);a.useEffect(()=>{if(!m?.uid)return;(async()=>{T(!0),S(null);try{if(y==="teacher"){const u=await qe(m.uid);E(u)}if(y==="admin"){const u=await Ie();R(u)}}catch(u){S(u instanceof Error?u.message:"Failed to load settings")}finally{T(!1)}})()},[m?.uid,y]);const c=a.useCallback(async k=>{if(!m?.uid)return;const u=await _e(m.uid,k);E(u)},[m?.uid]),L=a.useCallback(async k=>{const u=await De(k);R(u)},[]);return{teacherPrefs:l,adminConfig:z,loading:C,error:_,saveTeacherPrefs:c,saveAdminConfig:L}},ee=()=>JSON.parse(JSON.stringify(Qe)),Us=({isOpen:m,onClose:y,profileData:l,onSave:E,settingsData:z,onSaveSettings:R,onApplySettingsPreview:C,onExportData:T,onClearCache:_,onResetData:S})=>{const c=l?.role||"student",{teacherPrefs:L,adminConfig:k,saveTeacherPrefs:u,saveAdminConfig:ve}=hs(),[p,Ne]=a.useState("account"),[o,h]=a.useState({}),[i,te]=a.useState(ee()),[j,g]=a.useState(L),[v,N]=a.useState(k),[O,ae]=a.useState(!1),[D,ne]=a.useState(!1),[G,ie]=a.useState(!1),[H,le]=a.useState(!1),[re,us]=a.useState(!1),[ke,q]=a.useState(!1),[we,I]=a.useState(!1),[Ce,P]=a.useState(!1),[M,ce]=a.useState(""),[b,Se]=a.useState(null),[w,oe]=a.useState(!1),[U,de]=a.useState(!1),[Q,xe]=a.useState(""),[F,me]=a.useState(""),X=a.useRef(!1),B=a.useRef(ee());a.useEffect(()=>{if(!m){X.current=!1;return}if(X.current)return;X.current=!0;const s=z?JSON.parse(JSON.stringify(z)):ee();B.current=s,h({uid:l?.uid,name:l?.name||"",email:l?.email||"",phone:l?.phone||"",photo:l?.photo||"",avatarLayers:l?.avatarLayers,role:l?.role,gender:l?.gender,lrn:l?.lrn||"",grade:l?.grade||"",section:l?.section||"",school:l?.school||"",department:l?.department||"",subject:l?.subject||"",yearsOfExperience:l?.yearsOfExperience||"",qualification:l?.qualification||"",position:l?.position||""}),te(s),g(L),N(k)},[m,l,z,L,k]),a.useEffect(()=>{m&&C?.(i)},[m,i,C]),a.useEffect(()=>{if(!m)return;const s=t=>{t.key==="Escape"&&(C?.(B.current),y())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[m,y,C]);const he=a.useMemo(()=>{const s=[{id:"account",label:"Account",icon:Fe},{id:"notifications",label:"Notifications",icon:ye},{id:"appearance",label:"Appearance",icon:cs},{id:"privacy",label:"Privacy & Security",icon:Ve}];return c==="student"&&s.push({id:"learning",label:"Learning",icon:Oe}),c==="teacher"&&s.push({id:"teaching",label:"Teaching",icon:Ge}),c==="admin"&&s.push({id:"system",label:"System",icon:ds}),s.push({id:"data",label:"Data & Storage",icon:je}),s},[c]),r=s=>{te(t=>s(t))},W=s=>{Se(s),ce(""),de(!1),s==="password"&&xe(""),s==="email"&&me(o.email||""),P(!0)},ue=async()=>{if(!M.trim()){x.error("Current password is required");return}oe(!0);try{if(b==="password"){if(Q.length<8){x.error("New password must be at least 8 characters");return}await Xe(M,Q),x.success("Password updated")}else if(b==="email"){if(!F.includes("@")){x.error("Enter a valid email");return}await Be(M,F),h(s=>({...s,email:F})),x.success("Email updated")}else if(b==="delete"){await We(M,o.uid||""),x.success("Account deleted"),y();return}P(!1)}catch(s){x.error(s instanceof Error?s.message:"Authentication failed")}finally{oe(!1)}},Pe=async()=>{ae(!0);try{E&&await E(o),R&&await R(i),c==="teacher"&&await u(j),c==="admin"&&await ve(v),y()}catch(s){x.error(s instanceof Error?s.message:"Failed to save settings")}finally{ae(!1)}},Y=()=>{P(!1),q(!1),I(!1),C?.(B.current),y()},Ae=async()=>{if(!(!T||G)){ie(!0);try{await T()}catch(s){x.error(s instanceof Error?s.message:"Failed to export data")}finally{ie(!1)}}},Ee=async()=>{if(!(!_||H)){le(!0);try{await _()}catch(s){x.error(s instanceof Error?s.message:"Failed to clear cache")}finally{le(!1)}}},ze=async()=>{if(!(!S||D)){q(!1),ne(!0);try{await S(),x.success("Testing data reset completed")}catch(s){x.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{ne(!1)}}},Re=()=>{I(!1),W("delete")};return m?e.jsx(He,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Y,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-4xl max-h-[85vh] overflow-hidden flex",children:[e.jsxs("div",{className:"w-64 bg-slate-50 border-r border-slate-200 p-6 overflow-y-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-[#0a1628]",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Manage your preferences"})]}),e.jsx("nav",{className:"space-y-1",children:he.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 ${p===s.id?"bg-sky-50 text-sky-700 shadow-sm":"text-slate-500 hover:bg-slate-100 hover:text-sky-700"}`,children:[e.jsx(t,{size:18}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]},s.id)})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:he.find(s=>s.id===p)?.label}),e.jsx("button",{onClick:Y,className:"p-2 hover:bg-[#edf1f7] rounded-xl transition-colors",children:e.jsx(ge,{size:20,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[p==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ze,{uid:o.uid,photoURL:o.photo,displayName:o.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:o.name||"",onChange:s=>h(t=>({...t,name:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Email Address"}),e.jsxs("div",{className:"flex items-center gap-2 max-w-md",children:[e.jsx(n,{type:"email",value:o.email||"",disabled:!0,className:"flex-1 bg-slate-100"}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>W("email"),children:"Change"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Phone Number"}),e.jsx(n,{type:"tel",value:o.phone||"",onChange:s=>h(t=>({...t,phone:s.target.value})),className:"max-w-md"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Gender"}),e.jsxs(Ye,{value:o.gender||"",onValueChange:s=>h(t=>({...t,gender:s})),children:[e.jsx($e,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg",children:e.jsx(Je,{placeholder:"Select gender (optional)"})}),e.jsxs(Ke,{children:[e.jsx(Z,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(Z,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(Z,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ts,{className:"size-4 text-gray-500"}),e.jsx("span",{children:"Prefer not to say"})]})})]})]})]}),c==="student"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"LRN"}),e.jsx(n,{value:o.lrn||"",onChange:s=>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:o.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:o.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:o.school||"",onChange:s=>h(t=>({...t,school:s.target.value})),className:"max-w-md"})]})]}),c==="teacher"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Department"}),e.jsx(n,{value:o.department||"",onChange:s=>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:o.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:o.yearsOfExperience||"",onChange:s=>h(t=>({...t,yearsOfExperience:s.target.value})),className:"max-w-md"})]})]}),c==="admin"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-bold text-[#5a6578] mb-2 block font-body uppercase tracking-wider text-xs",children:"Position"}),e.jsx(n,{value:o.position||"",onChange:s=>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(f,{variant:"outline",className:"rounded-xl",onClick:()=>W("password"),children:[e.jsx(Ue,{size:16,className:"mr-2"}),"Update Password"]})]})]}),p==="notifications"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Email Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Receive updates via email"})]}),e.jsx(d,{checked:i.notifications.emailNotifications,onCheckedChange:s=>r(t=>({...t,notifications:{...t.notifications,emailNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(d,{checked:i.notifications.pushNotifications,onCheckedChange:s=>r(t=>({...t,notifications:{...t.notifications,pushNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Sound Effects"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Play sounds for notifications"})]}),e.jsx(d,{checked:i.notifications.soundEnabled,onCheckedChange:s=>r(t=>({...t,notifications:{...t.notifications,soundEnabled:s}}))})]}),c==="teacher"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Submissions"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Notify when students submit work"})]}),e.jsx(d,{checked:j.notifyOnSubmission,onCheckedChange:s=>g(t=>({...t,notifyOnSubmission:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Activity Alerts"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Notify on at-risk student activity"})]}),e.jsx(d,{checked:j.notifyOnStudentActivity,onCheckedChange:s=>g(t=>({...t,notifyOnStudentActivity:s}))})]})]}),e.jsxs("div",{className:"pt-4",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-3 font-body",children:"Notification Types"}),e.jsx("div",{className:"space-y-3",children:[{key:"quizReminders",label:"Quiz Reminders"},{key:"newContent",label:"New Content"},{key:"achievements",label:"Achievements"},{key:"streakAlerts",label:"Streak Alerts"},{key:"weeklySummary",label:"Weekly Summary"}].map(s=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:i.notifications.notificationTypes[s.key],onChange:t=>r(A=>({...A,notifications:{...A.notifications,notificationTypes:{...A.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(d,{checked:i.pushPreferences.pushEnabled,onCheckedChange:s=>r(t=>({...t,pushPreferences:{...t.pushPreferences,pushEnabled:s}}))})]}),e.jsx("div",{className:"space-y-2",children:[{key:"achievement",label:"🏆 Achievements unlocked"},{key:"quiz_battle",label:"⚔️ Quiz battle invites & results"},{key:"daily_reward",label:"🎁 Daily reward reminders"},{key:"assignment",label:"📚 New assignments / deadlines"},{key:"grade_posted",label:"📝 Grades posted"},{key:"streak_reminder",label:"🔥 Streak reminders"},{key:"leaderboard",label:"📊 Leaderboard updates"},{key:"system",label:"🔔 System announcements"}].map(s=>{const t=s.key;return e.jsxs("label",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-sm text-[#0a1628] font-body",children:s.label}),e.jsx(d,{checked:!!i.pushPreferences[t],onCheckedChange:A=>r($=>({...$,pushPreferences:{...$.pushPreferences,[s.key]:A}})),disabled:!i.pushPreferences.pushEnabled&&t!=="pushEnabled"})]},s.key)})}),e.jsx("div",{className:"mt-4",children:e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:async()=>{try{const{httpsCallable:s}=await fe(async()=>{const{httpsCallable:J}=await import("./vendor-firebase-core-DCQrgkxC.js").then(K=>K.a9);return{httpsCallable:J}},[]),{cloudFunctions:t}=await fe(async()=>{const{cloudFunctions:J}=await import("./index-mbyiCUYG.js").then(K=>K.b2);return{cloudFunctions:J}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),be=(await s(t,"sendTestPush")({}))?.data?.sent??0;be>0?x.success(`Sent test push to ${be} device(s).`):x.message("No active devices found. Enable browser notifications first.")}catch(s){x.error(s instanceof Error?s.message:"Failed to send test push")}},children:[e.jsx(ye,{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(as,{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=>r(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=>r(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,end:s.target.value}}})),className:"w-32"})]})]})]}),p==="appearance"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Dark Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Toggle dark theme"})]}),e.jsx(d,{checked:i.appearance.darkMode,onCheckedChange:s=>r(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=>r(t=>({...t,appearance:{...t.appearance,fontSize:Number(s.target.value)}})),className:"flex-1"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Large"}),e.jsxs("span",{className:"text-xs font-mono text-slate-600 w-8",children:[i.appearance.fontSize,"px"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Compact View"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show more content on screen"})]}),e.jsx(d,{checked:i.appearance.compactView,onCheckedChange:s=>r(t=>({...t,appearance:{...t.appearance,compactView:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Reduce Animations"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Minimize motion effects"})]}),e.jsx(d,{checked:i.appearance.reduceAnimations,onCheckedChange:s=>r(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),p==="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=>r(t=>({...t,privacy:{...t.privacy,profileVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"everyone",children:"Everyone"}),e.jsx("option",{value:"students_and_staff",children:"Students and Staff"}),e.jsx("option",{value:"private",children:"Private"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Activity Status"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let others see when you're online"})]}),e.jsx(d,{checked:i.privacy.showActivityStatus,onCheckedChange:s=>r(t=>({...t,privacy:{...t.privacy,showActivityStatus:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Data Sharing"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Share anonymous usage data"})]}),e.jsx(d,{checked:i.privacy.dataSharing,onCheckedChange:s=>r(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),p==="learning"&&c==="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=>r(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=>r(t=>({...t,learning:{...t.learning,preferredStudyTime:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"morning",children:"Morning (6AM - 12PM)"}),e.jsx("option",{value:"afternoon",children:"Afternoon (12PM - 6PM)"}),e.jsx("option",{value:"evening",children:"Evening (6PM - 12PM)"}),e.jsx("option",{value:"night",children:"Night (12AM - 6AM)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-play Next Lesson"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically start the next lesson"})]}),e.jsx(d,{checked:i.learning.autoPlayLessons,onCheckedChange:s=>r(t=>({...t,learning:{...t.learning,autoPlayLessons:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Hints During Quizzes"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Display helpful hints for questions"})]}),e.jsx(d,{checked:i.learning.showHints,onCheckedChange:s=>r(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=>r(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(ms,{size:16,className:"inline mr-2"}),"Study Reminders"]}),e.jsx(n,{type:"time",value:i.learning.studyReminderTime,onChange:s=>r(t=>({...t,learning:{...t.learning,studyReminderTime:s.target.value}})),className:"w-32"})]})]}),p==="teaching"&&c==="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:j.quizDefaults.timeLimitMinutes,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,timeLimitMinutes:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Passing Score (%)"}),e.jsx(n,{type:"number",value:j.quizDefaults.passingScore,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,passingScore:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Attempts"}),e.jsx(n,{type:"number",value:j.quizDefaults.maxAttempts,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,maxAttempts:Number(s.target.value)}}))})]})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"Class Preferences"}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-Enroll Students"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically enroll new students"})]}),e.jsx(d,{checked:j.classPreferences.autoEnroll,onCheckedChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,autoEnroll:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Class Visibility"}),e.jsxs("select",{value:j.classPreferences.classVisibility,onChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,classVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"public",children:"Public"}),e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"invite_only",children:"Invite Only"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Analytics Visibility"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let students see their leaderboard rank"})]}),e.jsx(d,{checked:j.studentAnalyticsVisibility,onCheckedChange:s=>g(t=>({...t,studentAnalyticsVisibility:s}))})]})]}),p==="system"&&c==="admin"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Maintenance Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Disable platform access for non-admins"})]}),e.jsx(d,{checked:v.maintenanceMode,onCheckedChange:s=>N(t=>({...t,maintenanceMode:s}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Grade Level"}),e.jsx(n,{value:v.defaultGradeLevel,onChange:s=>N(t=>({...t,defaultGradeLevel:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Curriculum"}),e.jsx(n,{value:v.defaultCurriculum,onChange:s=>N(t=>({...t,defaultCurriculum:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Class Size"}),e.jsx(n,{type:"number",value:v.maxClassSize,onChange:s=>N(t=>({...t,maxClassSize:Number(s.target.value)}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Audit Log Visible"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show audit logs in admin dashboard"})]}),e.jsx(d,{checked:v.auditLogVisible,onCheckedChange:s=>N(t=>({...t,auditLogVisible:s}))})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"AI Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Model Name"}),e.jsx(n,{value:v.aiConfig.modelName,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,modelName:s.target.value}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Temperature"}),e.jsx(n,{type:"number",step:"0.1",min:"0",max:"2",value:v.aiConfig.temperature,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,temperature:Number(s.target.value)}}))})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"API Endpoint"}),e.jsx(n,{value:v.aiConfig.endpoint,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,endpoint:s.target.value}}))})]})]})]}),p==="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(f,{variant:"outline",size:"sm",className:"rounded-xl",onClick:Ae,disabled:G,children:[e.jsx(je,{size:16,className:"mr-2"}),G?"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(f,{variant:"outline",size:"sm",className:"rounded-xl",onClick:Ee,disabled:H,children:H?"Clearing...":"Clear Cache"})]}),e.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-rose-900 mb-1",children:"Reset Progress"}),e.jsxs("p",{className:"text-xs text-rose-700 mb-3",children:[c==="student"&&"Reset quizzes, diagnostic state, XP, and learning progress for retesting.",c==="teacher"&&"Reset imported records, managed classrooms, and teacher-generated quiz artifacts.",c==="admin"&&"Reset admin testing artifacts like personal audit/content update records."]}),e.jsx(f,{variant:"outline",size:"sm",className:"rounded-xl text-rose-700 border-rose-300",disabled:!S||D,onClick:()=>q(!0),children:D?"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(f,{variant:"outline",size:"sm",className:"rounded-xl text-red-700 border-red-300",onClick:()=>I(!0),disabled:re,children:[e.jsx(ns,{size:16,className:"mr-2"}),re?"Deleting...":"Delete Account"]})]})]})]}),e.jsxs("div",{className:"p-6 border-t border-[#dde3eb] bg-[#edf1f7] flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",onClick:Y,className:"rounded-lg border-[#dde3eb]",disabled:O,children:"Cancel"}),e.jsx(f,{onClick:Pe,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white",disabled:O,children:O?"Saving...":"Save Changes"})]})]})]})]})]}),Ce&&e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[130] bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>{w||P(!1)},children:e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-md rounded-2xl border border-[#dde3eb] bg-[#f7f9fc] shadow-2xl",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[#dde3eb] px-6 py-4",children:[e.jsxs("h4",{className:"text-lg font-display font-bold text-[#0a1628]",children:[b==="password"&&"Change Password",b==="email"&&"Change Email",b==="delete"&&"Delete Account"]}),e.jsx("button",{onClick:()=>{w||P(!1)},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close",children:e.jsx(ge,{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:U?"text":"password",value:M,onChange:s=>ce(s.target.value),placeholder:"Current password",autoFocus:!0,className:"pr-10",disabled:w,onKeyDown:s=>{s.key==="Enter"&&ue()}}),e.jsx("button",{type:"button",onClick:()=>de(!U),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",tabIndex:-1,children:U?e.jsx(is,{size:16}):e.jsx(ls,{size:16})})]}),b==="password"&&e.jsx("div",{className:"relative",children:e.jsx(n,{type:"password",value:Q,onChange:s=>xe(s.target.value),placeholder:"New password (min 8 chars)",disabled:w})}),b==="email"&&e.jsx(n,{type:"email",value:F,onChange:s=>me(s.target.value),placeholder:"New email address",disabled:w}),b==="delete"&&e.jsx("p",{className:"text-sm text-red-600 font-medium",children:"This action is permanent and cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(f,{variant:"outline",onClick:()=>P(!1),disabled:w,children:"Cancel"}),e.jsx(f,{onClick:()=>void ue(),className:b==="delete"?"bg-red-600 hover:bg-red-700 text-white":"bg-sky-600 hover:bg-sky-700 text-white",disabled:w,children:w?"Processing...":b==="delete"?"Delete Forever":"Confirm"})]})]})]})}),e.jsx(pe,{isOpen:ke,onClose:()=>q(!1),onConfirm:ze,title:"Reset Testing Data?",message:`Reset ${c} testing data? This will clear quizzes, diagnostic assessments, assessment history, XP, and learning progress. This action cannot be undone.`,confirmText:D?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(pe,{isOpen:we,onClose:()=>I(!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{Us as default}; diff --git a/assets/SettingsModal-DILgCJsp.js b/assets/SettingsModal-DILgCJsp.js new file mode 100644 index 0000000000000000000000000000000000000000..746a4bcc03df8a397a84caf2ec821f553ebc15ca --- /dev/null +++ b/assets/SettingsModal-DILgCJsp.js @@ -0,0 +1,17 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B3ruOzo6.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.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-trN1hCQB.css"])))=>i.map(i=>d[i]); +import{e as se,u as Te,aQ as Le,aR as Me,aS as _e,aT as De,aU as qe,aV as Ie,x as Fe,S as Ve,W as Oe,a as Ge,k as He,m as V,L as Ue,_ as fe,l as x,aW as Qe,aX as We,aY as Xe,aZ as Be}from"./index-B3ruOzo6.js";import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{S as $e,a as Ye,b as Je,c as Ke,d as Z}from"./select-C142YWNr.js";import{B as f}from"./button-CaSK4KoS.js";import{I as n}from"./input-kh84w1XK.js";import{S as d}from"./switch-UwrfTEB3.js";import pe from"./ConfirmModal-BjVnuYqC.js";import{P as Ze,M as es,V as ss,v as ts}from"./ProfilePictureUploader-B3ToJmez.js";import{B as ye}from"./bell-Bp_utT8v.js";import{D as je}from"./download-BbFDZT3H.js";import{X as ge}from"./x-BNHnAXzL.js";import{C as as}from"./circle-help-C5HGdkRZ.js";import{C as ns}from"./clock-C73na4Cu.js";import{T as is}from"./trash-2-CjkT7lLr.js";import{E as ls,a as rs}from"./eye-WyNbhirJ.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-BPuEd8FG.js";import"./vendor-charts-D7t7JfSr.js";import"./vendor-markdown-yqZQ_iQm.js";import"./chevron-up-CTb5_AvY.js";import"./check-6eXlU5jr.js";import"./log-out-CoRJnfoO.js";import"./minus-B69_eMXI.js";import"./plus-Dx0gdu7_.js";import"./upload-BBhypj4u.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 cs=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],os=se("palette",cs);/** + * @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 ds=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],xs=se("server",ds);/** + * @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 ms=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],hs=se("smartphone",ms),us=()=>{const{userProfile:m,userRole:y}=Te(),[l,E]=a.useState(Le),[z,R]=a.useState(Me),[C,T]=a.useState(!1),[_,S]=a.useState(null);a.useEffect(()=>{if(!m?.uid)return;(async()=>{T(!0),S(null);try{if(y==="teacher"){const u=await qe(m.uid);E(u)}if(y==="admin"){const u=await Ie();R(u)}}catch(u){S(u instanceof Error?u.message:"Failed to load settings")}finally{T(!1)}})()},[m?.uid,y]);const o=a.useCallback(async k=>{if(!m?.uid)return;const u=await _e(m.uid,k);E(u)},[m?.uid]),L=a.useCallback(async k=>{const u=await De(k);R(u)},[]);return{teacherPrefs:l,adminConfig:z,loading:C,error:_,saveTeacherPrefs:o,saveAdminConfig:L}},ee=()=>JSON.parse(JSON.stringify(Qe)),Qs=({isOpen:m,onClose:y,profileData:l,onSave:E,settingsData:z,onSaveSettings:R,onApplySettingsPreview:C,onExportData:T,onClearCache:_,onResetData:S})=>{const o=l?.role||"student",{teacherPrefs:L,adminConfig:k,saveTeacherPrefs:u,saveAdminConfig:ve}=us(),[p,Ne]=a.useState("account"),[c,h]=a.useState({}),[i,te]=a.useState(ee()),[j,g]=a.useState(L),[v,N]=a.useState(k),[O,ae]=a.useState(!1),[D,ne]=a.useState(!1),[G,ie]=a.useState(!1),[H,le]=a.useState(!1),[re,bs]=a.useState(!1),[ke,q]=a.useState(!1),[we,I]=a.useState(!1),[Ce,P]=a.useState(!1),[M,ce]=a.useState(""),[b,Se]=a.useState(null),[w,oe]=a.useState(!1),[U,de]=a.useState(!1),[Q,xe]=a.useState(""),[F,me]=a.useState(""),W=a.useRef(!1),X=a.useRef(ee());a.useEffect(()=>{if(!m){W.current=!1;return}if(W.current)return;W.current=!0;const s=z?JSON.parse(JSON.stringify(z)):ee();X.current=s,h({uid:l?.uid,name:l?.name||"",email:l?.email||"",phone:l?.phone||"",photo:l?.photo||"",avatarLayers:l?.avatarLayers,role:l?.role,gender:l?.gender,lrn:l?.lrn||"",grade:l?.grade||"",section:l?.section||"",school:l?.school||"",department:l?.department||"",subject:l?.subject||"",yearsOfExperience:l?.yearsOfExperience||"",qualification:l?.qualification||"",position:l?.position||""}),te(s),g(L),N(k)},[m,l,z,L,k]),a.useEffect(()=>{m&&C?.(i)},[m,i,C]),a.useEffect(()=>{if(!m)return;const s=t=>{t.key==="Escape"&&(C?.(X.current),y())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[m,y,C]);const he=a.useMemo(()=>{const s=[{id:"account",label:"Account",icon:Fe},{id:"notifications",label:"Notifications",icon:ye},{id:"appearance",label:"Appearance",icon:os},{id:"privacy",label:"Privacy & Security",icon:Ve}];return o==="student"&&s.push({id:"learning",label:"Learning",icon:Oe}),o==="teacher"&&s.push({id:"teaching",label:"Teaching",icon:Ge}),o==="admin"&&s.push({id:"system",label:"System",icon:xs}),s.push({id:"data",label:"Data & Storage",icon:je}),s},[o]),r=s=>{te(t=>s(t))},B=s=>{Se(s),ce(""),de(!1),s==="password"&&xe(""),s==="email"&&me(c.email||""),P(!0)},ue=async()=>{if(!M.trim()){x.error("Current password is required");return}oe(!0);try{if(b==="password"){if(Q.length<8){x.error("New password must be at least 8 characters");return}await We(M,Q),x.success("Password updated")}else if(b==="email"){if(!F.includes("@")){x.error("Enter a valid email");return}await Xe(M,F),h(s=>({...s,email:F})),x.success("Email updated")}else if(b==="delete"){await Be(M,c.uid||""),x.success("Account deleted"),y();return}P(!1)}catch(s){x.error(s instanceof Error?s.message:"Authentication failed")}finally{oe(!1)}},Pe=async()=>{const s=ts({name:c.name,phone:c.phone});if(s){x.error(s);return}ae(!0);try{E&&await E(c),R&&await R(i),o==="teacher"&&await u(j),o==="admin"&&await ve(v),y()}catch(t){x.error(t instanceof Error?t.message:"Failed to save settings")}finally{ae(!1)}},$=()=>{P(!1),q(!1),I(!1),C?.(X.current),y()},Ae=async()=>{if(!(!T||G)){ie(!0);try{await T()}catch(s){x.error(s instanceof Error?s.message:"Failed to export data")}finally{ie(!1)}}},Ee=async()=>{if(!(!_||H)){le(!0);try{await _()}catch(s){x.error(s instanceof Error?s.message:"Failed to clear cache")}finally{le(!1)}}},ze=async()=>{if(!(!S||D)){q(!1),ne(!0);try{await S(),x.success("Testing data reset completed")}catch(s){x.error(s instanceof Error?s.message:"Failed to reset testing data")}finally{ne(!1)}}},Re=()=>{I(!1),B("delete")};return m?e.jsx(He,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:$,className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2},className:"relative bg-[#f7f9fc] rounded-2xl shadow-2xl border border-[#dde3eb] w-full max-w-4xl max-h-[85vh] overflow-hidden flex",children:[e.jsxs("div",{className:"w-64 bg-slate-50 border-r border-slate-200 p-6 overflow-y-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-display font-bold text-[#0a1628]",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 font-body",children:"Manage your preferences"})]}),e.jsx("nav",{className:"space-y-1",children:he.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 ${p===s.id?"bg-sky-50 text-sky-700 shadow-sm":"text-slate-500 hover:bg-slate-100 hover:text-sky-700"}`,children:[e.jsx(t,{size:18}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]},s.id)})})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-[#dde3eb]",children:[e.jsx("h3",{className:"text-lg font-display font-bold text-[#0a1628]",children:he.find(s=>s.id===p)?.label}),e.jsx("button",{onClick:$,className:"p-2 hover:bg-[#edf1f7] rounded-xl transition-colors",children:e.jsx(ge,{size:20,className:"text-[#5a6578]"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[p==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ze,{uid:c.uid,photoURL:c.photo,displayName:c.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:c.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:c.email||"",disabled:!0,className:"flex-1 bg-slate-100"}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>B("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:c.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($e,{value:c.gender||"",onValueChange:s=>h(t=>({...t,gender:s})),children:[e.jsx(Ye,{className:"max-w-md bg-white border-[#dde3eb] rounded-lg",children:e.jsx(Je,{placeholder:"Select gender (optional)"})}),e.jsxs(Ke,{children:[e.jsx(Z,{value:"male",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{className:"size-4 text-blue-500"}),e.jsx("span",{children:"Male"})]})}),e.jsx(Z,{value:"female",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{className:"size-4 text-pink-500"}),e.jsx("span",{children:"Female"})]})}),e.jsx(Z,{value:"prefer_not_to_say",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(as,{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:c.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:c.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:c.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:c.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:c.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:c.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:c.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:c.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(f,{variant:"outline",className:"rounded-xl",onClick:()=>B("password"),children:[e.jsx(Ue,{size:16,className:"mr-2"}),"Update Password"]})]})]}),p==="notifications"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Email Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Receive updates via email"})]}),e.jsx(d,{checked:i.notifications.emailNotifications,onCheckedChange:s=>r(t=>({...t,notifications:{...t.notifications,emailNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Push Notifications"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get notified on your device"})]}),e.jsx(d,{checked:i.notifications.pushNotifications,onCheckedChange:s=>r(t=>({...t,notifications:{...t.notifications,pushNotifications:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Sound Effects"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Play sounds for notifications"})]}),e.jsx(d,{checked:i.notifications.soundEnabled,onCheckedChange:s=>r(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(d,{checked:j.notifyOnSubmission,onCheckedChange:s=>g(t=>({...t,notifyOnSubmission:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Activity Alerts"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Notify on at-risk student activity"})]}),e.jsx(d,{checked:j.notifyOnStudentActivity,onCheckedChange:s=>g(t=>({...t,notifyOnStudentActivity:s}))})]})]}),e.jsxs("div",{className:"pt-4",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] mb-3 font-body",children:"Notification Types"}),e.jsx("div",{className:"space-y-3",children:[{key:"quizReminders",label:"Quiz Reminders"},{key:"newContent",label:"New Content"},{key:"achievements",label:"Achievements"},{key:"streakAlerts",label:"Streak Alerts"},{key:"weeklySummary",label:"Weekly Summary"}].map(s=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:i.notifications.notificationTypes[s.key],onChange:t=>r(A=>({...A,notifications:{...A.notifications,notificationTypes:{...A.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(d,{checked:i.pushPreferences.pushEnabled,onCheckedChange:s=>r(t=>({...t,pushPreferences:{...t.pushPreferences,pushEnabled:s}}))})]}),e.jsx("div",{className:"space-y-2",children:[{key:"achievement",label:"🏆 Achievements unlocked"},{key:"quiz_battle",label:"⚔️ Quiz battle invites & results"},{key:"daily_reward",label:"🎁 Daily reward reminders"},{key:"assignment",label:"📚 New assignments / deadlines"},{key:"grade_posted",label:"📝 Grades posted"},{key:"streak_reminder",label:"🔥 Streak reminders"},{key:"leaderboard",label:"📊 Leaderboard updates"},{key:"system",label:"🔔 System announcements"}].map(s=>{const t=s.key;return e.jsxs("label",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-sm text-[#0a1628] font-body",children:s.label}),e.jsx(d,{checked:!!i.pushPreferences[t],onCheckedChange:A=>r(Y=>({...Y,pushPreferences:{...Y.pushPreferences,[s.key]:A}})),disabled:!i.pushPreferences.pushEnabled&&t!=="pushEnabled"})]},s.key)})}),e.jsx("div",{className:"mt-4",children:e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:async()=>{try{const{httpsCallable:s}=await fe(async()=>{const{httpsCallable:J}=await import("./vendor-firebase-core-DCQrgkxC.js").then(K=>K.a9);return{httpsCallable:J}},[]),{cloudFunctions:t}=await fe(async()=>{const{cloudFunctions:J}=await import("./index-B3ruOzo6.js").then(K=>K.b2);return{cloudFunctions:J}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),be=(await s(t,"sendTestPush")({}))?.data?.sent??0;be>0?x.success(`Sent test push to ${be} device(s).`):x.message("No active devices found. Enable browser notifications first.")}catch(s){x.error(s instanceof Error?s.message:"Failed to send test push")}},children:[e.jsx(ye,{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(ns,{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=>r(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=>r(t=>({...t,notifications:{...t.notifications,quietHours:{...t.notifications.quietHours,end:s.target.value}}})),className:"w-32"})]})]})]}),p==="appearance"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Dark Mode"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Toggle dark theme"})]}),e.jsx(d,{checked:i.appearance.darkMode,onCheckedChange:s=>r(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=>r(t=>({...t,appearance:{...t.appearance,fontSize:Number(s.target.value)}})),className:"flex-1"}),e.jsx("span",{className:"text-xs text-slate-500",children:"Large"}),e.jsxs("span",{className:"text-xs font-mono text-slate-600 w-8",children:[i.appearance.fontSize,"px"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Compact View"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show more content on screen"})]}),e.jsx(d,{checked:i.appearance.compactView,onCheckedChange:s=>r(t=>({...t,appearance:{...t.appearance,compactView:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Reduce Animations"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Minimize motion effects"})]}),e.jsx(d,{checked:i.appearance.reduceAnimations,onCheckedChange:s=>r(t=>({...t,appearance:{...t.appearance,reduceAnimations:s}}))})]})]}),p==="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=>r(t=>({...t,privacy:{...t.privacy,profileVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"everyone",children:"Everyone"}),e.jsx("option",{value:"students_and_staff",children:"Students and Staff"}),e.jsx("option",{value:"private",children:"Private"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Activity Status"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let others see when you're online"})]}),e.jsx(d,{checked:i.privacy.showActivityStatus,onCheckedChange:s=>r(t=>({...t,privacy:{...t.privacy,showActivityStatus:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Data Sharing"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Share anonymous usage data"})]}),e.jsx(d,{checked:i.privacy.dataSharing,onCheckedChange:s=>r(t=>({...t,privacy:{...t.privacy,dataSharing:s}}))})]})]}),p==="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=>r(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=>r(t=>({...t,learning:{...t.learning,preferredStudyTime:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm w-full max-w-xs bg-white text-[#0a1628]",children:[e.jsx("option",{value:"morning",children:"Morning (6AM - 12PM)"}),e.jsx("option",{value:"afternoon",children:"Afternoon (12PM - 6PM)"}),e.jsx("option",{value:"evening",children:"Evening (6PM - 12PM)"}),e.jsx("option",{value:"night",children:"Night (12AM - 6AM)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-play Next Lesson"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically start the next lesson"})]}),e.jsx(d,{checked:i.learning.autoPlayLessons,onCheckedChange:s=>r(t=>({...t,learning:{...t.learning,autoPlayLessons:s}}))})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Show Hints During Quizzes"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Display helpful hints for questions"})]}),e.jsx(d,{checked:i.learning.showHints,onCheckedChange:s=>r(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=>r(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(hs,{size:16,className:"inline mr-2"}),"Study Reminders"]}),e.jsx(n,{type:"time",value:i.learning.studyReminderTime,onChange:s=>r(t=>({...t,learning:{...t.learning,studyReminderTime:s.target.value}})),className:"w-32"})]})]}),p==="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:j.quizDefaults.timeLimitMinutes,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,timeLimitMinutes:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Passing Score (%)"}),e.jsx(n,{type:"number",value:j.quizDefaults.passingScore,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,passingScore:Number(s.target.value)}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Attempts"}),e.jsx(n,{type:"number",value:j.quizDefaults.maxAttempts,onChange:s=>g(t=>({...t,quizDefaults:{...t.quizDefaults,maxAttempts:Number(s.target.value)}}))})]})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"Class Preferences"}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Auto-Enroll Students"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Automatically enroll new students"})]}),e.jsx(d,{checked:j.classPreferences.autoEnroll,onCheckedChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,autoEnroll:s}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Class Visibility"}),e.jsxs("select",{value:j.classPreferences.classVisibility,onChange:s=>g(t=>({...t,classPreferences:{...t.classPreferences,classVisibility:s.target.value}})),className:"px-3 py-2 border border-[#dde3eb] rounded-lg text-sm bg-white text-[#0a1628]",children:[e.jsx("option",{value:"public",children:"Public"}),e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"invite_only",children:"Invite Only"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Student Analytics Visibility"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Let students see their leaderboard rank"})]}),e.jsx(d,{checked:j.studentAnalyticsVisibility,onCheckedChange:s=>g(t=>({...t,studentAnalyticsVisibility:s}))})]})]}),p==="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(d,{checked:v.maintenanceMode,onCheckedChange:s=>N(t=>({...t,maintenanceMode:s}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Grade Level"}),e.jsx(n,{value:v.defaultGradeLevel,onChange:s=>N(t=>({...t,defaultGradeLevel:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Default Curriculum"}),e.jsx(n,{value:v.defaultCurriculum,onChange:s=>N(t=>({...t,defaultCurriculum:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Max Class Size"}),e.jsx(n,{type:"number",value:v.maxClassSize,onChange:s=>N(t=>({...t,maxClassSize:Number(s.target.value)}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#dde3eb]",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body",children:"Audit Log Visible"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Show audit logs in admin dashboard"})]}),e.jsx(d,{checked:v.auditLogVisible,onCheckedChange:s=>N(t=>({...t,auditLogVisible:s}))})]}),e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] font-body pt-4",children:"AI Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Model Name"}),e.jsx(n,{value:v.aiConfig.modelName,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,modelName:s.target.value}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"Temperature"}),e.jsx(n,{type:"number",step:"0.1",min:"0",max:"2",value:v.aiConfig.temperature,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,temperature:Number(s.target.value)}}))})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-[#5a6578] block mb-1",children:"API Endpoint"}),e.jsx(n,{value:v.aiConfig.endpoint,onChange:s=>N(t=>({...t,aiConfig:{...t.aiConfig,endpoint:s.target.value}}))})]})]})]}),p==="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(f,{variant:"outline",size:"sm",className:"rounded-xl",onClick:Ae,disabled:G,children:[e.jsx(je,{size:16,className:"mr-2"}),G?"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(f,{variant:"outline",size:"sm",className:"rounded-xl",onClick:Ee,disabled:H,children:H?"Clearing...":"Clear Cache"})]}),e.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-xl",children:[e.jsx("h4",{className:"text-sm font-bold text-rose-900 mb-1",children:"Reset Progress"}),e.jsxs("p",{className:"text-xs text-rose-700 mb-3",children:[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(f,{variant:"outline",size:"sm",className:"rounded-xl text-rose-700 border-rose-300",disabled:!S||D,onClick:()=>q(!0),children:D?"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(f,{variant:"outline",size:"sm",className:"rounded-xl text-red-700 border-red-300",onClick:()=>I(!0),disabled:re,children:[e.jsx(is,{size:16,className:"mr-2"}),re?"Deleting...":"Delete Account"]})]})]})]}),e.jsxs("div",{className:"p-6 border-t border-[#dde3eb] bg-[#edf1f7] flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500 font-body",children:"MathPulse AI v2.1.0"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",onClick:$,className:"rounded-lg border-[#dde3eb]",disabled:O,children:"Cancel"}),e.jsx(f,{onClick:Pe,className:"rounded-lg bg-sky-600 hover:bg-sky-700 text-white",disabled:O,children:O?"Saving...":"Save Changes"})]})]})]})]})]}),Ce&&e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[130] bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",onClick:()=>{w||P(!1)},children:e.jsxs(V.div,{initial:{opacity:0,scale:.95,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{duration:.2},className:"w-full max-w-md rounded-2xl border border-[#dde3eb] bg-[#f7f9fc] shadow-2xl",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[#dde3eb] px-6 py-4",children:[e.jsxs("h4",{className:"text-lg font-display font-bold text-[#0a1628]",children:[b==="password"&&"Change Password",b==="email"&&"Change Email",b==="delete"&&"Delete Account"]}),e.jsx("button",{onClick:()=>{w||P(!1)},className:"p-2 rounded-xl hover:bg-[#edf1f7] transition-colors","aria-label":"Close",children:e.jsx(ge,{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:U?"text":"password",value:M,onChange:s=>ce(s.target.value),placeholder:"Current password",autoFocus:!0,className:"pr-10",disabled:w,onKeyDown:s=>{s.key==="Enter"&&ue()}}),e.jsx("button",{type:"button",onClick:()=>de(!U),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",tabIndex:-1,children:U?e.jsx(ls,{size:16}):e.jsx(rs,{size:16})})]}),b==="password"&&e.jsx("div",{className:"relative",children:e.jsx(n,{type:"password",value:Q,onChange:s=>xe(s.target.value),placeholder:"New password (min 8 chars)",disabled:w})}),b==="email"&&e.jsx(n,{type:"email",value:F,onChange:s=>me(s.target.value),placeholder:"New email address",disabled:w}),b==="delete"&&e.jsx("p",{className:"text-sm text-red-600 font-medium",children:"This action is permanent and cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(f,{variant:"outline",onClick:()=>P(!1),disabled:w,children:"Cancel"}),e.jsx(f,{onClick:()=>void ue(),className:b==="delete"?"bg-red-600 hover:bg-red-700 text-white":"bg-sky-600 hover:bg-sky-700 text-white",disabled:w,children:w?"Processing...":b==="delete"?"Delete Forever":"Confirm"})]})]})]})}),e.jsx(pe,{isOpen:ke,onClose:()=>q(!1),onConfirm:ze,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:D?"Resetting...":"Reset Data",cancelText:"Cancel",type:"warning",icon:"warning",zIndexClass:"z-[130]"}),e.jsx(pe,{isOpen:we,onClose:()=>I(!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{Qs as default}; diff --git a/assets/Sidebar-1AFatJJg.js b/assets/Sidebar-1AFatJJg.js new file mode 100644 index 0000000000000000000000000000000000000000..e1d37c5cdd9885cc7e027144a076a3d6c8e34952 --- /dev/null +++ b/assets/Sidebar-1AFatJJg.js @@ -0,0 +1,6 @@ +import{r as x,j as e}from"./vendor-react-B4AQeu28.js";import{S as _,a as $,L as u,M as B}from"./LogoutActionButton-D5BV__Zd.js";import{e as P,m as c,j as D,U as S,G as N,a as m,S as G,X as U,z as q}from"./index-B3ruOzo6.js";import{T as M,a as L,b as C}from"./tooltip-CLSYbTYK.js";import{X as F}from"./x-BNHnAXzL.js";import{C as Q}from"./chevron-right-CbkkCalp.js";import{C as W}from"./chevron-left-Cr0wYLQi.js";import{C as z}from"./chart-column-C9VTl-3A.js";import{S as X}from"./shirt-BBR3GIpi.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 J=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],K=P("cpu",J),R=({activeTab:b,setActiveTab:A,userRole:f="student",onOpenSettings:g,onLogout:y,sidebarCollapsed:o=!1,setSidebarCollapsed:j,mode:T="desktop",onRequestClose:v,forceCollapsed:n=!1})=>{const[E,p]=x.useState(!1),[k,t]=x.useState(null),i=T==="mobile",r=!n&&E,h=typeof g=="function",a=!i&&(n||o&&!r),l=a,I=!i&&!n;x.useEffect(()=>{n&&(p(!1),t(null))},[n]),x.useEffect(()=>{l||t(null)},[l]);const O=f==="admin"?[{label:"Management",items:[{icon:u,label:"Overview"},{icon:S,label:"User Management"},{icon:N,label:"Subjects"},{icon:m,label:"Content"}]},{label:"Insights",items:[{icon:z,label:"Analytics"},{icon:K,label:"AI Monitoring"},{icon:G,label:"Audit Log"}]}]:f==="teacher"?[{label:"Teaching",items:[{icon:u,label:"Dashboard"},{icon:S,label:"My Students"},{icon:m,label:"Classes"}]},{label:"Insights",items:[{icon:z,label:"Analytics"}]}]:[{label:"Learn",items:[{icon:u,label:"Dashboard"},{icon:m,label:"Modules"},{icon:B,label:"AI Chat"}]},{label:"Progress",items:[{icon:N,label:"Grades",displayLabel:"Assessment"},{icon:U,label:"Quiz Battle",displayLabel:"Quiz Battle"},{icon:q,label:"Leaderboard",displayLabel:"Leadership Board"}]},{label:"Customization",items:[{icon:X,label:"Avatar Studio",displayLabel:"Avatar Studio"}]}];return e.jsxs(c.aside,{initial:!1,animate:i?{width:280}:{width:a?80:280},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>I&&o&&p(!0),onMouseLeave:()=>{p(!1),t(null)},className:D("h-full bg-[#f7f9fc] border border-[#dde3eb] shadow-sm flex flex-col",i?"rounded-2xl p-4":"rounded-3xl p-5"),children:[e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:`mb-8 flex items-center ${a?"justify-center":"justify-between"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI",className:"w-12 h-12 object-contain drop-shadow-md flex-shrink-0"}),(!a||r)&&e.jsx("div",{children:e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),i&&v&&e.jsx("button",{onClick:v,className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(F,{size:20})}),!i&&!n&&j&&(!o||r)&&e.jsx(c.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>j(!o),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":o?"Expand sidebar":"Collapse sidebar",title:o?"Expand sidebar":"Collapse sidebar",children:o?e.jsx(Q,{size:20}):e.jsx(W,{size:20})})]}),e.jsx("nav",{className:"flex-1 min-h-0 overflow-y-auto space-y-5 pr-1",children:O.map((d,H)=>e.jsxs("div",{children:[a?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):d.label&&e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:d.label}),e.jsx("div",{className:"space-y-1",children:d.items.map(s=>e.jsxs(M,{open:l&&k===s.label,children:[e.jsx(L,{asChild:!0,children:e.jsxs(c.button,{whileHover:{x:2},whileTap:{scale:.98},onMouseEnter:()=>{l&&t(s.label)},onMouseLeave:()=>{t(w=>w===s.label?null:w)},onFocus:()=>t(null),onClick:()=>A(s.label),className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl cursor-pointer transition-all duration-200 border whitespace-nowrap ${a?"justify-center":""} ${b===s.label?"bg-sky-50 border-sky-200 shadow-sm text-sky-700":"bg-transparent border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]"}`,children:[e.jsx(s.icon,{size:18,strokeWidth:b===s.label?2.5:2,className:"flex-shrink-0"}),(!a||r)&&e.jsx("span",{className:"font-body font-bold text-xs",children:s.displayLabel||s.label}),b===s.label&&(!a||r)&&e.jsx(c.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-sky-500",transition:{type:"spring",duration:.4}})]})}),l&&e.jsx(C,{side:"right",sideOffset:16,className:"font-bold text-xs",children:s.displayLabel||s.label})]},s.label))})]},H))})]}),e.jsxs("div",{className:"mt-4 space-y-2 border-t border-[#dde3eb] pt-4",children:[e.jsxs(M,{open:l&&k==="Settings",children:[e.jsx(L,{asChild:!0,children:e.jsxs(c.button,{whileHover:{x:2},whileTap:{scale:.98},onMouseEnter:()=>{l&&t("Settings")},onMouseLeave:()=>{t(d=>d==="Settings"?null:d)},onFocus:()=>t(null),className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl font-bold border transition-all duration-200 whitespace-nowrap ${a?"justify-center":""} ${b==="Settings"?"bg-sky-50 border-sky-200 text-sky-700 shadow-sm":h?"border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]":"border-transparent text-[#a0aec0] cursor-not-allowed opacity-60"}`,onClick:h?g:void 0,disabled:!h,"aria-disabled":!h,"aria-label":"Open settings",children:[e.jsx(_,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!a||r)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]})}),l&&e.jsx(C,{side:"right",sideOffset:16,className:"font-bold text-xs",children:"Settings"})]}),y&&e.jsx("div",{className:"text-[#5a6578]",children:e.jsx($,{onClick:y,collapsed:a})})]})]})},ie=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"}));export{K as C,R as S,ie as a}; diff --git a/assets/Sidebar-CnFPEtsr.js b/assets/Sidebar-CnFPEtsr.js deleted file mode 100644 index a0998e6c1f270e367aeed485558864b0f918f5b7..0000000000000000000000000000000000000000 --- a/assets/Sidebar-CnFPEtsr.js +++ /dev/null @@ -1,6 +0,0 @@ -import{r as p,j as e}from"./vendor-react-B4AQeu28.js";import{S as N,a as $,L as u,M as D}from"./LogoutActionButton-DQLJH-aF.js";import{c as G,m as c,k as P,U as S,G as M,a as f,S as U,V as _,z as q}from"./index-mbyiCUYG.js";import{T as L,a as C,b as z}from"./tooltip-Cd2m83Wr.js";import{X as F}from"./x-oZO0Ye1Q.js";import{C as Q}from"./chevron-right-bwYIKoxv.js";import{C as W}from"./chevron-left-BYtw_nqd.js";import{C as A}from"./chart-column-B4tQNTpN.js";import{S as V}from"./shirt-nq7Lov7c.js";import"./log-out-Ddy014zi.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.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 X=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],J=G("cpu",X),me=({activeTab:b,setActiveTab:E,userRole:x="student",onOpenSettings:g,onLogout:y,sidebarCollapsed:o=!1,setSidebarCollapsed:j,mode:T="desktop",onRequestClose:v,forceCollapsed:i=!1})=>{const[I,m]=p.useState(!1),[k,t]=p.useState(null),n=T==="mobile",r=!i&&I,h=typeof g=="function",a=!n&&(i||o&&!r),l=a,H=!n&&!i;p.useEffect(()=>{i&&(m(!1),t(null))},[i]),p.useEffect(()=>{l||t(null)},[l]);const O=x==="admin"?[{label:"Management",items:[{icon:u,label:"Overview"},{icon:S,label:"User Management"},{icon:M,label:"Subjects"},{icon:f,label:"Content"}]},{label:"Insights",items:[{icon:A,label:"Analytics"},{icon:J,label:"AI Monitoring"},{icon:U,label:"Audit Log"},{icon:N,label:"Settings"}]}]:x==="teacher"?[{label:"Teaching",items:[{icon:u,label:"Dashboard"},{icon:S,label:"My Students"},{icon:f,label:"Classes"}]},{label:"Insights",items:[{icon:A,label:"Analytics"}]}]:[{label:"Learn",items:[{icon:u,label:"Dashboard"},{icon:f,label:"Modules"},{icon:D,label:"AI Chat"}]},{label:"Progress",items:[{icon:M,label:"Grades",displayLabel:"Assessment"},{icon:_,label:"Quiz Battle",displayLabel:"Quiz Battle"},{icon:q,label:"Leaderboard",displayLabel:"Leadership Board"}]},{label:"Customization",items:[{icon:V,label:"Avatar Studio",displayLabel:"Avatar Studio"}]}];return e.jsxs(c.aside,{initial:!1,animate:n?{width:280}:{width:a?80:280},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>H&&o&&m(!0),onMouseLeave:()=>{m(!1),t(null)},className:P("h-full bg-[#f7f9fc] border border-[#dde3eb] shadow-sm flex flex-col",n?"rounded-2xl p-4":"rounded-3xl p-5"),children:[e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:`mb-8 flex items-center ${a?"justify-center":"justify-between"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/mathpulse_logo.png",alt:"MathPulse AI",className:"w-12 h-12 object-contain drop-shadow-md flex-shrink-0"}),(!a||r)&&e.jsx("div",{children:e.jsx("h2",{className:"text-base font-bold font-display text-[#0a1628] whitespace-nowrap",children:"MathPulse AI"})})]}),n&&v&&e.jsx("button",{onClick:v,className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(F,{size:20})}),!n&&!i&&j&&(!o||r)&&e.jsx(c.button,{whileHover:{scale:1.1},whileTap:{scale:.95},onClick:()=>j(!o),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":o?"Expand sidebar":"Collapse sidebar",title:o?"Expand sidebar":"Collapse sidebar",children:o?e.jsx(Q,{size:20}):e.jsx(W,{size:20})})]}),e.jsx("nav",{className:"flex-1 min-h-0 overflow-y-auto space-y-5 pr-1",children:O.map((d,B)=>e.jsxs("div",{children:[a?e.jsx("div",{className:"px-4 mb-2 flex items-center gap-2",children:e.jsx("div",{className:"flex-1 h-[1px] bg-[#dde3eb]"})}):d.label&&e.jsx("p",{className:"px-4 mb-2 text-[10px] font-bold text-[#5a6578] uppercase tracking-widest",children:d.label}),e.jsx("div",{className:"space-y-1",children:d.items.map(s=>e.jsxs(L,{open:l&&k===s.label,children:[e.jsx(C,{asChild:!0,children:e.jsxs(c.button,{whileHover:{x:2},whileTap:{scale:.98},onMouseEnter:()=>{l&&t(s.label)},onMouseLeave:()=>{t(w=>w===s.label?null:w)},onFocus:()=>t(null),onClick:()=>E(s.label),className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl cursor-pointer transition-all duration-200 border whitespace-nowrap ${a?"justify-center":""} ${b===s.label?"bg-sky-50 border-sky-200 shadow-sm text-sky-700":"bg-transparent border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]"}`,children:[e.jsx(s.icon,{size:18,strokeWidth:b===s.label?2.5:2,className:"flex-shrink-0"}),(!a||r)&&e.jsx("span",{className:"font-body font-bold text-xs",children:s.displayLabel||s.label}),b===s.label&&(!a||r)&&e.jsx(c.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-sky-500",transition:{type:"spring",duration:.4}})]})}),l&&e.jsx(z,{side:"right",sideOffset:16,className:"font-bold text-xs",children:s.displayLabel||s.label})]},s.label))})]},B))})]}),e.jsxs("div",{className:"mt-4 space-y-2 border-t border-[#dde3eb] pt-4",children:[x!=="admin"?e.jsxs(L,{open:l&&k==="Settings",children:[e.jsx(C,{asChild:!0,children:e.jsxs(c.button,{whileHover:{x:2},whileTap:{scale:.98},onMouseEnter:()=>{l&&t("Settings")},onMouseLeave:()=>{t(d=>d==="Settings"?null:d)},onFocus:()=>t(null),className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl font-bold border transition-all duration-200 whitespace-nowrap ${a?"justify-center":""} ${b==="Settings"?"bg-sky-50 border-sky-200 text-sky-700 shadow-sm":h?"border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]":"border-transparent text-[#a0aec0] cursor-not-allowed opacity-60"}`,onClick:h?g:void 0,disabled:!h,"aria-disabled":!h,"aria-label":"Open settings",children:[e.jsx(N,{size:18,strokeWidth:2,className:"flex-shrink-0"}),(!a||r)&&e.jsx("span",{className:"font-body text-xs",children:"Settings"})]})}),l&&e.jsx(z,{side:"right",sideOffset:16,className:"font-bold text-xs",children:"Settings"})]}):null,y&&e.jsx("div",{className:"text-[#5a6578]",children:e.jsx($,{onClick:y,collapsed:a})})]})]})};export{me as default}; diff --git a/assets/SupplementalBanner-DX4KIC1c.js b/assets/SupplementalBanner-BaFvS7H9.js similarity index 94% rename from assets/SupplementalBanner-DX4KIC1c.js rename to assets/SupplementalBanner-BaFvS7H9.js index dcf137b0622a92971310407a881cd5a30bc633ed..1f09a4dc35c04a8c7ff5f807bf74ff4ea5bb3ff9 100644 --- a/assets/SupplementalBanner-DX4KIC1c.js +++ b/assets/SupplementalBanner-BaFvS7H9.js @@ -1 +1 @@ -import{j as e,r as y}from"./vendor-react-B4AQeu28.js";import{g as j,m as p,w as h,a as f,T as m,B as x}from"./index-mbyiCUYG.js";import{X as v}from"./x-oZO0Ye1Q.js";import{S as w}from"./sparkles-THbTTiEe.js";import{C as g}from"./chevron-right-bwYIKoxv.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";const b={"General Mathematics":[{label:"Functions Deep Dive",description:"Interactive review of function types and graphs",icon:e.jsx(m,{size:14})},{label:"Business Math Basics",description:"Simple & compound interest practice",icon:e.jsx(f,{size:14})}],"Statistics and Probability":[{label:"Distribution Visualizer",description:"Explore normal distribution curves",icon:e.jsx(m,{size:14})},{label:"Hypothesis Practice",description:"Step-by-step hypothesis testing",icon:e.jsx(x,{size:14})}],"Pre-Calculus":[{label:"Conic Sections Explorer",description:"Visual parabola, ellipse, hyperbola tool",icon:e.jsx(m,{size:14})},{label:"Trig Identity Practice",description:"Identity verification drill set",icon:e.jsx(x,{size:14})}],"Basic Calculus":[{label:"Limits Visualizer",description:"Graphical approach to limits",icon:e.jsx(m,{size:14})},{label:"Derivative Rules Drill",description:"Practice chain rule & implicit diff",icon:e.jsx(x,{size:14})}]};function u(i){const s=i.toLowerCase();return s==="functions"||s.includes("function")||s==="businessmath"||s.includes("business")||s==="logic"||s.includes("reason")||s.includes("general")||s.includes("gen-math")||s.includes("gen math")?"General Mathematics":s.includes("stat")||s.includes("prob")?"Statistics and Probability":s.includes("pre-calc")||s.includes("pre calc")||s.includes("precalc")?"Pre-Calculus":s.includes("basic")||s.includes("calc")?"Basic Calculus":null}function N(i){const s=i.trim().toLowerCase();return s==="functions"?"Functions and Graphs":s==="businessmath"?"Business and Financial Mathematics":s==="logic"?"Logic and Reasoning":i}const k=({atRiskSubjects:i=[],onAction:s,onDismiss:n})=>{const[l,a]=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?u(i):null;if(!s.some(r=>{const t=u(r);return t&&t===n})||!n)return null;const a=b[n]||[];return e.jsx(p.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"mb-4 overflow-hidden",children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-50 to-orange-50 border border-rose-200 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(h,{size:14,className:"text-rose-600"}),e.jsxs("span",{className:"text-xs font-bold text-rose-800",children:["Supplemental Focus Area — ",n]})]}),e.jsx("p",{className:"text-xs text-rose-700 mb-2",children:"This topic was flagged in your diagnostic. Take your time and review the explanations carefully."}),a.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.slice(0,2).map((r,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-rose-100 text-rose-700 px-2 py-0.5 rounded-md text-xs font-medium",children:[r.icon,r.label]},t))})]})})},C=({quizSubject:i,quizScore:s=0,atRiskSubjects:n=[],onAction:l})=>{const a=i?u(i):null,r=n.some(c=>{const d=u(c);return d&&d===a});if(s>=70&&!r)return null;const t=a?b[a]||[]:[],o=s<70;return e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-4",children:e.jsx("div",{className:`rounded-2xl p-4 border-2 ${o?"bg-orange-50 border-orange-200":"bg-sky-50 border-sky-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${o?"bg-orange-500":"bg-sky-500"}`,children:e.jsx(f,{size:20,className:"text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-display font-bold text-[#0a1628] text-sm mb-1",children:o?"Review Recommended":"Supplemental Materials"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2",children:o?`You scored ${s}% on this quiz. We recommend reviewing the following resources to strengthen your understanding.`:"This topic was identified as an area for growth. Check out these additional resources."}),t.length>0&&e.jsx("div",{className:"space-y-1.5 mb-3",children:t.map((c,d)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center ${o?"bg-orange-100 text-orange-600":"bg-sky-100 text-sky-600"}`,children:c.icon}),e.jsx("span",{className:"font-medium text-[#0a1628]",children:c.label}),e.jsxs("span",{className:"text-slate-500",children:["— ",c.description]})]},d))}),l&&e.jsxs("button",{onClick:l,className:`inline-flex items-center gap-1.5 text-xs font-bold px-3 py-1.5 rounded-lg transition-colors ${o?"bg-orange-500 hover:bg-orange-600 text-white":"bg-sky-500 hover:bg-sky-600 text-white"}`,children:["Review Topics",e.jsx(g,{size:12})]})]})]})})})},I=i=>{switch(i.variant){case"compact":return e.jsx(z,{...i});case"results":return e.jsx(C,{...i});case"full":default:return e.jsx(k,{...i})}};export{I as default}; +import{j as e,r as y}from"./vendor-react-B4AQeu28.js";import{k as j,m as p,v as h,a as f,T as m,B as x}from"./index-B3ruOzo6.js";import{X as v}from"./x-BNHnAXzL.js";import{S as w}from"./sparkles-Bq0AaIRg.js";import{C as g}from"./chevron-right-CbkkCalp.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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(x,{size:14})}],"Pre-Calculus":[{label:"Conic Sections Explorer",description:"Visual parabola, ellipse, hyperbola tool",icon:e.jsx(m,{size:14})},{label:"Trig Identity Practice",description:"Identity verification drill set",icon:e.jsx(x,{size:14})}],"Basic Calculus":[{label:"Limits Visualizer",description:"Graphical approach to limits",icon:e.jsx(m,{size:14})},{label:"Derivative Rules Drill",description:"Practice chain rule & implicit diff",icon:e.jsx(x,{size:14})}]};function u(i){const s=i.toLowerCase();return s==="functions"||s.includes("function")||s==="businessmath"||s.includes("business")||s==="logic"||s.includes("reason")||s.includes("general")||s.includes("gen-math")||s.includes("gen math")?"General Mathematics":s.includes("stat")||s.includes("prob")?"Statistics and Probability":s.includes("pre-calc")||s.includes("pre calc")||s.includes("precalc")?"Pre-Calculus":s.includes("basic")||s.includes("calc")?"Basic Calculus":null}function N(i){const s=i.trim().toLowerCase();return s==="functions"?"Functions and Graphs":s==="businessmath"?"Business and Financial Mathematics":s==="logic"?"Logic and Reasoning":i}const k=({atRiskSubjects:i=[],onAction:s,onDismiss:n})=>{const[l,a]=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?u(i):null;if(!s.some(r=>{const t=u(r);return t&&t===n})||!n)return null;const a=b[n]||[];return e.jsx(p.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"mb-4 overflow-hidden",children:e.jsxs("div",{className:"bg-gradient-to-r from-rose-50 to-orange-50 border border-rose-200 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(h,{size:14,className:"text-rose-600"}),e.jsxs("span",{className:"text-xs font-bold text-rose-800",children:["Supplemental Focus Area — ",n]})]}),e.jsx("p",{className:"text-xs text-rose-700 mb-2",children:"This topic was flagged in your diagnostic. Take your time and review the explanations carefully."}),a.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.slice(0,2).map((r,t)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-rose-100 text-rose-700 px-2 py-0.5 rounded-md text-xs font-medium",children:[r.icon,r.label]},t))})]})})},C=({quizSubject:i,quizScore:s=0,atRiskSubjects:n=[],onAction:l})=>{const a=i?u(i):null,r=n.some(c=>{const d=u(c);return d&&d===a});if(s>=70&&!r)return null;const t=a?b[a]||[]:[],o=s<70;return e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-4",children:e.jsx("div",{className:`rounded-2xl p-4 border-2 ${o?"bg-orange-50 border-orange-200":"bg-sky-50 border-sky-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${o?"bg-orange-500":"bg-sky-500"}`,children:e.jsx(f,{size:20,className:"text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-display font-bold text-[#0a1628] text-sm mb-1",children:o?"Review Recommended":"Supplemental Materials"}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2",children:o?`You scored ${s}% on this quiz. We recommend reviewing the following resources to strengthen your understanding.`:"This topic was identified as an area for growth. Check out these additional resources."}),t.length>0&&e.jsx("div",{className:"space-y-1.5 mb-3",children:t.map((c,d)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center ${o?"bg-orange-100 text-orange-600":"bg-sky-100 text-sky-600"}`,children:c.icon}),e.jsx("span",{className:"font-medium text-[#0a1628]",children:c.label}),e.jsxs("span",{className:"text-slate-500",children:["— ",c.description]})]},d))}),l&&e.jsxs("button",{onClick:l,className:`inline-flex items-center gap-1.5 text-xs font-bold px-3 py-1.5 rounded-lg transition-colors ${o?"bg-orange-500 hover:bg-orange-600 text-white":"bg-sky-500 hover:bg-sky-600 text-white"}`,children:["Review Topics",e.jsx(g,{size:12})]})]})]})})})},I=i=>{switch(i.variant){case"compact":return e.jsx(z,{...i});case"results":return e.jsx(C,{...i});case"full":default:return e.jsx(k,{...i})}};export{I as default}; diff --git a/assets/SupplementalPillCarousel-BcOOOGo2.js b/assets/SupplementalPillCarousel-Dxq4aiMj.js similarity index 92% rename from assets/SupplementalPillCarousel-BcOOOGo2.js rename to assets/SupplementalPillCarousel-Dxq4aiMj.js index 9c7c28870517884fde7c9cdef25392a78e0d620a..998282d50d449d7984c057b4a9cc295bfcdb22af 100644 --- a/assets/SupplementalPillCarousel-BcOOOGo2.js +++ b/assets/SupplementalPillCarousel-Dxq4aiMj.js @@ -1,4 +1,4 @@ -import{r as a,j as e}from"./vendor-react-B4AQeu28.js";import{m as f,w as x}from"./index-mbyiCUYG.js";import{C as n}from"./chevron-right-bwYIKoxv.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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,v as x}from"./index-B3ruOzo6.js";import{C as n}from"./chevron-right-CbkkCalp.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-DH_EClon.js b/assets/TeacherDashboard-DH_EClon.js deleted file mode 100644 index 16c1e5930e2ed60003cec193c80f243f1bcccdc0..0000000000000000000000000000000000000000 --- a/assets/TeacherDashboard-DH_EClon.js +++ /dev/null @@ -1,102 +0,0 @@ -import{d as le,j as e,r as h,c as sr}from"./vendor-react-B4AQeu28.js";import{c as ol,B as ms}from"./button-BqKfG4Jj.js";import{I as Qs}from"./input-DEPoMoHZ.js";import il from"./ConfirmModal-BsY1WFdG.js";import{c as ut,t as ll,f as rn,u as Io,g as Bt,m as Pe,b as cl,U as Rt,h as st,i as dl,j as Ze,k as Eo,a as Lt,G as _o,B as ar,Z as ul,l as gs,n as me,o as ja,p as ct,A as Ro,q as Yt,T as sa,C as ml,r as nn,R as Vs,v as xl,w as _s,x as on,y as ln,z as pl,D as Mo,M as hl,E as cn,F as fl,H as gl}from"./index-mbyiCUYG.js";import{collection as Xt,query as Ht,limit as zo,where as Gt,getDocs as ts,orderBy as bl,onSnapshot as Lo,setDoc as Zt,doc as vt,updateDoc as Kt,getDoc as Cs,serverTimestamp as ft,deleteDoc as vl}from"./vendor-firebase-firestore-CP9q7ISf.js";import{C as Ao}from"./check-check-wBIDWtv-.js";import{c as wl,a as Do,f as Fo}from"./formatDistanceToNow-B_Ixh2wt.js";import{B as Rs}from"./bell-D_pyutJs.js";import{C as Ra}from"./circle-check-BENuYz-J.js";import{C as aa}from"./circle-alert-CJ47UAgT.js";import{S as ss}from"./sparkles-THbTTiEe.js";import{M as Nl,L as jl,S as yl,a as Sl}from"./LogoutActionButton-DQLJH-aF.js";import{s as dn,f as $o,L as ya,d as kl,p as Cl,a as Tl,A as Sa,P as Il,b as El}from"./quizService-CjK9zjBp.js";import{S as _l}from"./vendor-radix-xDOIcVzp.js";import{T as Rl,a as Ml,b as zl}from"./tooltip-Cd2m83Wr.js";import{X as ps}from"./x-oZO0Ye1Q.js";import{C as Ll}from"./circle-help-BP0kOuya.js";import{E as Al,a as Dl}from"./eye-DakyBxPE.js";import{S as da}from"./send-iW1LmVFw.js";import{T as Oo}from"./trash-2-8qZ3aehj.js";import{C as Ut}from"./check-BLN5Dl8e.js";import{I as Us,F as Wt,T as Bo,D as Fl,A as $l}from"./trending-down-DaPJgM3L.js";import{C as _t,a as ka}from"./chevron-up-B_-cQcm8.js";import{M as un}from"./minus-BEbLkPkH.js";import{P as rr}from"./plus-CbpDHvDO.js";import{C as hs}from"./chart-column-B4tQNTpN.js";import{C as Ol,H as mn}from"./history-CUgB1MuD.js";import{D as Bl}from"./download-C2PVrIq3.js";import{C as as}from"./chevron-left-BYtw_nqd.js";import{C as es}from"./chevron-right-bwYIKoxv.js";import{S as Po}from"./save-DgO_wXsk.js";import{S as ra}from"./search-F2fS74Xk.js";import{U as xn}from"./upload-CKMt4jtd.js";import{u as Pl}from"./useQuery-L70l-ukL.js";import{S as pn,g as Hl,G as Gl,s as hn}from"./subjects-BGUwH4Kn.js";import{u as Ql}from"./useCurriculum-uUEvXpH4.js";import{C as gr}from"./circle-check-big-BnoZ8KZB.js";import Vl from"./ChatMarkdown-vDoOnX8q.js";import{C as Ms}from"./clock-BLtPbCgT.js";import{D as fn,a as gn,b as Ul,c as Wl,d as ql}from"./dialog-fiLCzxmY.js";import{S as Me}from"./skeleton-Br1snihA.js";import{u as Tt,r as Yl}from"./vendor-xlsx-uZelXSz_.js";import{C as Ho}from"./clipboard-check-BB6UVEW1.js";import{R as bn,B as vn,C as wn,X as Nn,Y as jn,T as yn,a as Sn,b as kn}from"./vendor-charts-Ckgeb0nY.js";import"./log-out-Ddy014zi.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.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 Kl=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Xl=ut("align-left",Kl);/** - * @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 Jl=[["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"}]],Qa=ut("calendar-days",Jl);/** - * @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 Zl=[["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"}]],ec=ut("chart-no-axes-column",Zl);/** - * @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=[["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"}]],sc=ut("ellipsis-vertical",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 ac=[["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"}]],nr=ut("ellipsis",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 rc=[["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"}]],nc=ut("external-link",rc);/** - * @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 oc=[["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"}]],ic=ut("file-spreadsheet",oc);/** - * @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=[["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"}]],Ca=ut("library",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 cc=[["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"}]],Go=ut("list-checks",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 dc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],uc=ut("panel-right",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 mc=[["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"}]],xc=ut("pen-line",mc);/** - * @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 pc=[["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"}]],Qo=ut("pen",pc);/** - * @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=[["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"}]],fc=ut("printer",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=[["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"}]],bc=ut("scan-line",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 vc=[["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"}]],wc=ut("table",vc);/** - * @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 Nc=[["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"}]],Cn=ut("video",Nc);/** - * @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:"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"}]],or=ut("wand-sparkles",jc);function yc(t,s){const a=ll(t);return isNaN(s)?wl(t,NaN):(a.setDate(a.getDate()+s),a)}function Vo(t,s){const a=rn(t),r=rn(s);return+a==+r}function Tn(t){return Vo(t,Do(t))}function Sc(t,s){return yc(t,-1)}function In(t){return Vo(t,Sc(Do(t)))}const Ma=0,ns=1,zs=2,Uo=4;function En(t){return()=>t}function kc(t){t()}function Wo(t,s){return a=>t(s(a))}function _n(t,s){return()=>t(s)}function Cc(t,s){return a=>t(s,a)}function br(t){return t!==void 0}function Tc(...t){return()=>{t.map(kc)}}function Ls(){}function za(t,s){return s(t),t}function Ic(t,s){return s(t)}function Ke(...t){return t}function He(t,s){return t(ns,s)}function Te(t,s){t(Ma,s)}function vr(t){t(zs)}function Xe(t){return t(Uo)}function ce(t,s){return He(t,Cc(s,Ma))}function Mt(t,s){const a=t(ns,r=>{a(),s(r)});return a}function Rn(t){let s,a;return r=>n=>{s=n,a&&clearTimeout(a),a=setTimeout(()=>{r(s)},t)}}function qo(t,s){return t===s}function Ye(t=qo){let s;return a=>r=>{t(s,r)||(s=r,a(r))}}function fe(t){return s=>a=>{t(a)&&s(a)}}function re(t){return s=>Wo(s,t)}function $t(t){return s=>()=>{s(t)}}function P(t,...s){const a=Ec(...s);return((r,n)=>{switch(r){case zs:vr(t);return;case ns:return He(t,a(n))}})}function Ot(t,s){return a=>r=>{a(s=t(s,r))}}function fs(t){return s=>a=>{t>0?t--:s(a)}}function qt(t){let s=null,a;return r=>n=>{s=n,!a&&(a=setTimeout(()=>{a=void 0,r(s)},t))}}function Ie(...t){const s=new Array(t.length);let a=0,r=null;const n=2**t.length-1;return t.forEach((o,i)=>{const l=2**i;He(o,c=>{const d=a;a|=l,s[i]=c,d!==n&&a===n&&r&&(r(),r=null)})}),o=>i=>{const l=()=>{o([i].concat(s))};a===n?l():r=l}}function Ec(...t){return s=>t.reduceRight(Ic,s)}function _c(t){let s,a;const r=()=>s?.();return function(n,o){switch(n){case ns:return o?a===o?void 0:(r(),a=o,s=He(t,o),s):(r(),Ls);case zs:r(),a=null;return}}}function G(t){let s=t;const a=ze();return((r,n)=>{switch(r){case Ma:s=n;break;case ns:{n(s);break}case Uo:return s}return a(r,n)})}function ht(t,s){return za(G(s),a=>ce(t,a))}function ze(){const t=[];return((s,a)=>{switch(s){case Ma:t.slice().forEach(r=>{r(a)});return;case zs:t.splice(0,t.length);return;case ns:return t.push(a),()=>{const r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function jt(t){return za(ze(),s=>ce(t,s))}function Be(t,s=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:s,id:Rc(),singleton:a}}const Rc=()=>Symbol();function Mc(t){const s=new Map,a=({constructor:r,dependencies:n,id:o,singleton:i})=>{if(i&&s.has(o))return s.get(o);const l=r(n.map(c=>a(c)));return i&&s.set(o,l),l};return a(t)}function at(...t){const s=ze(),a=new Array(t.length);let r=0;const n=2**t.length-1;return t.forEach((o,i)=>{const l=2**i;He(o,c=>{a[i]=c,r|=l,r===n&&Te(s,a)})}),function(o,i){switch(o){case zs:{vr(s);return}case ns:return r===n&&i(a),He(s,i)}}}function he(t,s=qo){return P(t,Ye(s))}function ir(...t){return function(s,a){switch(s){case zs:return;case ns:return Tc(...t.map(r=>He(r,a)))}}}const nt={DEBUG:0,INFO:1,WARN:2,ERROR:3},zc={[nt.DEBUG]:"debug",[nt.ERROR]:"error",[nt.INFO]:"log",[nt.WARN]:"warn"},Lc=()=>typeof globalThis>"u"?window:globalThis,os=Be(()=>{const t=G(nt.ERROR);return{log:G((s,a,r=nt.INFO)=>{const n=Lc().VIRTUOSO_LOG_LEVEL??Xe(t);r>=n&&console[zc[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 wr(t,s,a).callbackRef}function wr(t,s,a){const r=le.useRef(null);let n=i=>{};const o=le.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 n=i=>{i&&s?(o?.observe(i),r.current=i):(r.current&&o?.unobserve(r.current),r.current=null)},{callbackRef:n,ref:r}}function Ac(t,s,a,r,n,o,i,l,c){const d=le.useCallback(x=>{const b=Dc(x.children,s,l?"offsetWidth":"offsetHeight",n);let p=x.parentElement;for(;p.dataset.virtuosoScroller===void 0;)p=p.parentElement;const g=p.lastElementChild.dataset.viewportType==="window";let C;g&&(C=p.ownerDocument.defaultView);const S=i?l?i.scrollLeft:i.scrollTop:g?l?C.scrollX||C.document.documentElement.scrollLeft:C.scrollY||C.document.documentElement.scrollTop:l?p.scrollLeft:p.scrollTop,N=i?l?i.scrollWidth:i.scrollHeight:g?l?C.document.documentElement.scrollWidth:C.document.documentElement.scrollHeight:l?p.scrollWidth:p.scrollHeight,m=i?l?i.offsetWidth:i.offsetHeight:g?l?C.innerWidth:C.innerHeight:l?p.offsetWidth:p.offsetHeight;r({scrollHeight:N,scrollTop:Math.max(S,0),viewportHeight:m}),o?.(l?Mn("column-gap",getComputedStyle(x).columnGap,n):Mn("row-gap",getComputedStyle(x).rowGap,n)),b!==null&&t(b)},[t,s,n,o,i,r,l]);return wr(d,a,c)}function Dc(t,s,a,r){const n=t.length;if(n===0)return null;const o=[];for(let i=0;i{if(!c?.offsetParent)return;const d=c.getBoundingClientRect(),x=d.width;let b,p;if(s){const g=s.getBoundingClientRect(),C=d.top-g.top;p=g.height-Math.max(0,C),b=C+s.scrollTop}else{const g=i.current.ownerDocument.defaultView;p=g.innerHeight-Math.max(0,d.top),b=d.top+g.scrollY}r.current={listHeight:d.height,offsetTop:b,visibleHeight:p,visibleWidth:x},t(r.current)},[t,s]),{callbackRef:o,ref:i}=wr(n,!0,a),l=le.useCallback(()=>{n(i.current)},[n,i]);return le.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]),o}const bt=Be(()=>{const t=ze(),s=ze(),a=G(0),r=ze(),n=G(0),o=ze(),i=ze(),l=G(0),c=G(0),d=G(0),x=G(0),b=ze(),p=ze(),g=G(!1),C=G(!1),S=G(!1);return ce(P(t,re(({scrollTop:N})=>N)),s),ce(P(t,re(({scrollHeight:N})=>N)),i),ce(s,n),{deviation:a,fixedFooterHeight:d,fixedHeaderHeight:c,footerHeight:x,headerHeight:l,horizontalDirection:C,scrollBy:p,scrollContainerState:t,scrollHeight:i,scrollingInProgress:g,scrollTo:b,scrollTop:s,skipAnimationFrameInResizeObserver:S,smoothScrollTargetReached:r,statefulScrollTop:n,viewportHeight:o}},[],{singleton:!0}),Ys={lvl:0};function Ko(t,s){const a=t.length;if(a===0)return[];let{index:r,value:n}=s(t[0]);const o=[];for(let i=1;is&&(l=l.concat(cr(n,s,a))),r>=s&&r<=a&&l.push({k:r,v:i}),r<=a&&(l=l.concat(cr(o,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(Va(s))return ei(rt(t,{lvl:a-1}));if(!Ve(s)&&!Ve(s.r))return rt(s.r,{l:rt(s,{r:s.r.l}),lvl:a,r:rt(t,{l:s.r.r,lvl:a-1})});throw new Error("Unexpected empty nodes")}if(Va(t))return dr(rt(t,{lvl:a-1}));if(!Ve(r)&&!Ve(r.l)){const n=r.l,o=Va(n)?r.lvl-1:r.lvl;return rt(n,{l:rt(t,{lvl:a-1,r:n.l}),lvl:n.lvl+1,r:dr(rt(r,{l:n.r,lvl:o}))})}throw new Error("Unexpected empty nodes")}function rt(t,s){return Zo(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 Xo(t){return Ve(t.r)?t.l:ga(rt(t,{r:Xo(t.r)}))}function Va(t){return Ve(t)||t.lvl>t.r.lvl}function Jo(t){return Ve(t.r)?[t.k,t.v]:Jo(t.r)}function Zo(t,s,a,r=Ys,n=Ys){return{k:t,l:r,lvl:a,r:n,v:s}}function zn(t){return dr(ei(t))}function ei(t){const{l:s}=t;return!Ve(s)&&s.lvl===t.lvl?rt(s,{r:rt(t,{l:s.r})}):t}function dr(t){const{lvl:s,r:a}=t;return!Ve(a)&&!Ve(a.r)&&a.lvl===s&&a.r.lvl===s?rt(a,{l:rt(t,{r:a.l}),lvl:s+1}):t}function Fc(t){return Ko(t,({k:s,v:a})=>({index:s,value:a}))}function ti(t,s){return!!(t&&t.startIndex===s.startIndex&&t.endIndex===s.endIndex)}function Xs(t,s){return!!(t&&t[0]===s[0]&&t[1]===s[1])}const Nr=Be(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function si(t,s,a){return t[Ta(t,s,a)]}function Ta(t,s,a,r=0){let n=t.length-1;for(;r<=n;){const o=Math.floor((r+n)/2),i=t[o],l=a(i,s);if(l===0)return o;if(l===-1){if(n-r<2)return o-1;n=o-1}else{if(n===r)return o;r=o+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${s}`)}function $c(t,s,a,r){const n=Ta(t,s,r),o=Ta(t,a,r,n);return t.slice(n,o+1)}function rs(t,s){return Math.round(t.getBoundingClientRect()[s])}function La(t){return!Ve(t.groupOffsetTree)}function jr({index:t},s){return s===t?0:s=b||o===p)&&(t=lr(t,b)):(d=p!==o,c=!0),x>n&&n>=b&&p!==o&&(t=Nt(t,n+1,p));d&&(t=Nt(t,i,o))}return[t,a]}function Pc(t){return typeof t.groupIndex<"u"}function Hc({offset:t},s){return s===t?0:s0?l+a:l}function ai(t,s){if(!La(s))return t;let a=0;for(;s.groupIndices[a]<=t+a;)a++;return t+a}function ri(t,s,a){if(Pc(t))return s.groupIndices[t.groupIndex]+1;const r=t.index==="LAST"?a:t.index;let n=ai(r,s);return n=Math.max(0,n,Math.min(a,n)),n}function Gc(t,s,a,r=0){return r>0&&(s=Math.max(s,si(t,r,jr).offset)),Ko($c(t,s,a,Hc),Uc)}function Qc(t,[s,a,r,n]){s.length>0&&r("received item sizes",s,nt.DEBUG);const o=t.sizeTree;let i=o,l=0;if(a.length>0&&Ve(o)&&s.length===2){const p=s[0].size,g=s[1].size;i=a.reduce((C,S)=>Nt(Nt(C,S,p),S+1,g),i)}else[i,l]=Bc(i,s);if(i===o)return t;const{lastIndex:c,lastOffset:d,lastSize:x,offsetTree:b}=ur(t.offsetTree,l,i,n);return{groupIndices:a,groupOffsetTree:a.reduce((p,g)=>Nt(p,g,Js(g,b,n)),Is()),lastIndex:c,lastOffset:d,lastSize:x,offsetTree:b,sizeTree:i}}function Vc(t){return xs(t).map(({k:s,v:a},r,n)=>{const o=n[r+1];return{endIndex:o!==void 0?o.k-1:1/0,size:a,startIndex:s}})}function Ln(t,s){let a=0,r=0;for(;an.start===r&&(n.end===s||n.end===1/0)&&n.value===a}const qc={offsetHeight:"height",offsetWidth:"width"},Qt=Be(([{log:t},{recalcInProgress:s}])=>{const a=ze(),r=ze(),n=ht(r,0),o=ze(),i=ze(),l=G(0),c=G([]),d=G(void 0),x=G(void 0),b=G(void 0),p=G(void 0),g=G((v,k)=>rs(v,qc[k])),C=G(void 0),S=G(0),N=Oc(),m=ht(P(a,Ie(c,t,S),Ot(Qc,N),Ye()),N),w=ht(P(c,Ye(),Ot((v,k)=>({current:k,prev:v.current}),{current:[],prev:[]}),re(({prev:v})=>v)),[]);ce(P(c,fe(v=>v.length>0),Ie(m,S),re(([v,k,I])=>{const $=v.reduce((D,q,Q)=>Nt(D,q,Js(q,k.offsetTree,I)||Q),Is());return{...k,groupIndices:v,groupOffsetTree:$}})),m),ce(P(r,Ie(m),fe(([v,{lastIndex:k}])=>v[{endIndex:k,size:I,startIndex:v}])),a),ce(d,x);const y=ht(P(d,re(v=>v===void 0)),!0);ce(P(x,fe(v=>v!==void 0&&Ve(Xe(m).sizeTree)),re(v=>{const k=Xe(b),I=Xe(c).length>0;return k!==void 0&&k!==0?I?[{endIndex:0,size:k,startIndex:0},{endIndex:1,size:v,startIndex:1}]:[]:[{endIndex:0,size:v,startIndex:0}]})),a),ce(P(p,fe(v=>v!==void 0&&v.length>0&&Ve(Xe(m).sizeTree)),re(v=>{const k=[];let I=v[0],$=0;for(let D=1;Dv!==void 0&&k!==void 0),re(([v,k,I])=>{const $=[];for(let D=0;D({changed:I!==v,sizes:I}),{changed:!1,sizes:N}),re(v=>v.changed)));He(P(l,Ot((v,k)=>({diff:v.prev-k,prev:k}),{diff:0,prev:0}),re(v=>v.diff)),v=>{const{groupIndices:k}=Xe(m);if(v>0)Te(s,!0),Te(o,v+Ln(v,k));else if(v<0){const I=Xe(w);I.length>0&&(v-=Ln(-v,I)),Te(i,v)}}),He(P(l,Ie(t)),([v,k])=>{v<0&&k("`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},nt.ERROR)});const j=jt(o);ce(P(o,Ie(m),re(([v,k])=>{const I=k.groupIndices.length>0,$=[],D=k.lastSize;if(I){const q=Ks(k.sizeTree,0);let Q=0,A=0;for(;Q{let ge=ee.ranges;return ee.prevSize!==0&&(ge=[...ee.ranges,{endIndex:ie+v-1,size:ee.prevSize,startIndex:ee.prevIndex}]),{prevIndex:ie+v,prevSize:je,ranges:ge}},{prevIndex:v,prevSize:0,ranges:$}).ranges}return xs(k.sizeTree).reduce((q,{k:Q,v:A})=>({prevIndex:Q+v,prevSize:A,ranges:[...q.ranges,{endIndex:Q+v-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),a);const H=jt(P(i,Ie(m,S),re(([v,{offsetTree:k},I])=>{const $=-v;return Js($,k,I)})));return ce(P(i,Ie(m,S),re(([v,k,I])=>{if(k.groupIndices.length>0){if(Ve(k.sizeTree))return k;let D=Is();const q=Xe(w);let Q=0,A=0,U=0;for(;Q<-v;){U=q[A];const ee=q[A+1]-U-1;A++,Q+=ee+1}if(D=xs(k.sizeTree).reduce((ee,{k:ie,v:je})=>Nt(ee,Math.max(0,ie+v),je),D),Q!==-v){const ee=Ks(k.sizeTree,U);D=Nt(D,0,ee);const ie=At(k.sizeTree,-v+1)[1];D=Nt(D,1,ie)}return{...k,sizeTree:D,...ur(k.offsetTree,0,D,I)}}const $=xs(k.sizeTree).reduce((D,{k:q,v:Q})=>Nt(D,Math.max(0,q+v),Q),Is());return{...k,sizeTree:$,...ur(k.offsetTree,0,$,I)}})),m),{beforeUnshiftWith:j,data:C,defaultItemSize:x,firstItemIndex:l,fixedItemSize:d,fixedGroupSize:b,gap:S,groupIndices:c,heightEstimates:p,itemSize:g,listRefresh:R,shiftWith:i,shiftWithOffset:H,sizeRanges:a,sizes:m,statefulTotalCount:n,totalCount:r,trackItemSizes:y,unshiftWith:o}},Ke(os,Nr),{singleton:!0});function Yc(t){return t.reduce((s,a)=>(s.groupIndices.push(s.totalCount),s.totalCount+=a+1,s),{groupIndices:[],totalCount:0})}const ni=Be(([{groupIndices:t,sizes:s,totalCount:a},{headerHeight:r,scrollTop:n}])=>{const o=ze(),i=ze(),l=jt(P(o,re(Yc)));return ce(P(l,re(c=>c.totalCount)),a),ce(P(l,re(c=>c.groupIndices)),t),ce(P(at(n,s,r),fe(([c,d])=>La(d)),re(([c,d,x])=>At(d.groupOffsetTree,Math.max(c-x,0),"v")[0]),Ye(),re(c=>[c])),i),{groupCounts:o,topItemsIndexes:i}},Ke(Qt,bt)),is=Be(([{log:t}])=>{const s=G(!1),a=jt(P(s,fe(r=>r),Ye()));return He(s,r=>{r&&Xe(t)("props updated",{},nt.DEBUG)}),{didMount:a,propsReady:s}},Ke(os),{singleton:!0}),Kc=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function oi(t){const s=typeof t=="number"?{index:t}:t;return s.align||(s.align="start"),(!s.behavior||!Kc)&&(s.behavior="auto"),s.offset===void 0&&(s.offset=0),s}const na=Be(([{gap:t,listRefresh:s,sizes:a,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:o,footerHeight:i,headerHeight:l,scrollingInProgress:c,scrollTo:d,smoothScrollTargetReached:x,viewportHeight:b},{log:p}])=>{const g=ze(),C=ze(),S=G(0);let N=null,m=null,w=null;function y(){N!==null&&(N(),N=null),w!==null&&(w(),w=null),m&&(clearTimeout(m),m=null),Te(c,!1)}return ce(P(g,Ie(a,b,r,S,l,i,p),Ie(t,o,n),re(([[R,j,H,v,k,I,$,D],q,Q,A])=>{const U=oi(R),{align:ee,behavior:ie,offset:je}=U,ge=v-1,Ce=ri(U,j,ge);let de=Js(Ce,j.offsetTree,q)+I;ee==="end"?(de+=Q+At(j.sizeTree,Ce)[1]-H+A,Ce===ge&&(de+=$)):ee==="center"?de+=(Q+At(j.sizeTree,Ce)[1]-H+A)/2:de-=k,je!==void 0&&je!==0&&(de+=je);const B=Y=>{y(),Y?(D("retrying to scroll to",{location:R},nt.DEBUG),Te(g,R)):(Te(C,!0),D("list did not change, scroll successful",{},nt.DEBUG))};if(y(),ie==="smooth"){let Y=!1;w=He(s,ne=>{Y=Y||ne}),N=Mt(x,()=>{B(Y)})}else N=Mt(P(s,Xc(150)),B);return m=setTimeout(()=>{y()},1200),Te(c,!0),D("scrolling from index to",{behavior:ie,index:Ce,top:de},nt.DEBUG),{behavior:ie,top:de}})),d),{scrollTargetReached:C,scrollToIndex:g,topListHeight:S}},Ke(Qt,bt,os),{singleton:!0});function Xc(t){return s=>{const a=setTimeout(()=>{s(!1)},t);return r=>{r&&(s(!0),clearTimeout(a))}}}function yr(t,s){t===0?s():requestAnimationFrame(()=>{yr(t-1,s)})}function Sr(t,s){const a=s-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}const oa=Be(([{defaultItemSize:t,listRefresh:s,sizes:a},{scrollTop:r},{scrollTargetReached:n,scrollToIndex:o},{didMount:i}])=>{const l=G(!0),c=G(0),d=G(!0);return ce(P(i,Ie(c),fe(([x,b])=>b!==0),$t(!1)),l),ce(P(i,Ie(c),fe(([x,b])=>b!==0),$t(!1)),d),He(P(at(s,i),Ie(l,a,t,d),fe(([[,x],b,{sizeTree:p},g,C])=>x&&(!Ve(p)||br(g))&&!b&&!C),Ie(c)),([,x])=>{Mt(n,()=>{Te(d,!0)}),yr(4,()=>{Mt(r,()=>{Te(l,!0)}),Te(o,x)})}),{initialItemFinalLocationReached:d,initialTopMostItemIndex:c,scrolledToInitialItem:l}},Ke(Qt,bt,na,is),{singleton:!0});function ii(t,s){return Math.abs(t-s)<1.01}const Zs="up",Ws="down",Jc="none",Zc={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ed=0,ia=Be(([{footerHeight:t,headerHeight:s,scrollBy:a,scrollContainerState:r,scrollTop:n,viewportHeight:o}])=>{const i=G(!1),l=G(!0),c=ze(),d=ze(),x=G(4),b=G(ed),p=ht(P(ir(P(he(n),fs(1),$t(!0)),P(he(n),fs(1),$t(!1),Rn(100))),Ye()),!1),g=ht(P(ir(P(a,$t(!0)),P(a,$t(!1),Rn(200))),Ye()),!1);ce(P(at(he(n),he(b)),re(([w,y])=>w<=y),Ye()),l),ce(P(l,qt(50)),d);const C=jt(P(at(r,he(o),he(s),he(t),he(x)),Ot((w,[{scrollHeight:y,scrollTop:R},j,H,v,k])=>{const I=R+j-y>-k,$={scrollHeight:y,scrollTop:R,viewportHeight:j};if(I){let q,Q;return R>w.state.scrollTop?(q="SCROLLED_DOWN",Q=w.state.scrollTop-R):(q="SIZE_DECREASED",Q=w.state.scrollTop-R||w.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:Q,state:$}}let D;return $.scrollHeight>w.state.scrollHeight?D="SIZE_INCREASED":jw!==void 0&&w.atBottom===y.atBottom))),S=ht(P(r,Ot((w,{scrollHeight:y,scrollTop:R,viewportHeight:j})=>{if(!ii(w.scrollHeight,y)){const H=y-(R+j)<1;return w.scrollTop!==R&&H?{changed:!0,jump:w.scrollTop-R,scrollHeight:y,scrollTop:R}:{changed:!0,jump:0,scrollHeight:y,scrollTop:R}}return{changed:!1,jump:0,scrollHeight:y,scrollTop:R}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),re(w=>w.jump)),0);ce(P(C,re(w=>w.atBottom)),i),ce(P(i,qt(50)),c);const N=G(Ws);ce(P(r,re(({scrollTop:w})=>w),Ye(),Ot((w,y)=>Xe(g)?{direction:w.direction,prevScrollTop:y}:{direction:yw.direction)),N),ce(P(r,qt(50),$t(Jc)),N);const m=G(0);return ce(P(p,fe(w=>!w),$t(0)),m),ce(P(n,qt(100),Ie(p),fe(([w,y])=>y),Ot(([w,y],[R])=>[y,R],[0,0]),re(([w,y])=>y-w)),m),{atBottomState:C,atBottomStateChange:c,atBottomThreshold:x,atTopStateChange:d,atTopThreshold:b,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:S,scrollDirection:N,scrollVelocity:m}},Ke(bt)),ea="top",ta="bottom",An="none";function Dn(t,s,a){return typeof t=="number"?a===Zs&&s===ea||a===Ws&&s===ta?t:0:a===Zs?s===ea?t.main:t.reverse:s===ta?t.main:t.reverse}function Fn(t,s){return typeof t=="number"?t:t[s]??0}const kr=Be(([{deviation:t,fixedHeaderHeight:s,headerHeight:a,scrollTop:r,viewportHeight:n}])=>{const o=ze(),i=G(0),l=G(0),c=G(0),d=ht(P(at(he(r),he(n),he(a),he(o,Xs),he(c),he(i),he(s),he(t),he(l)),re(([x,b,p,[g,C],S,N,m,w,y])=>{const R=x-w,j=N+m,H=Math.max(p-R,0);let v=An;const k=Fn(y,ea),I=Fn(y,ta);return g-=w,g+=p+m,C+=p+m,C-=w,g>x+j-k&&(v=Zs),Cx!==null),Ye(Xs)),[0,0]);return{increaseViewportBy:l,listBoundary:o,overscan:c,topListHeight:i,visibleRange:d}},Ke(bt),{singleton:!0});function td(t,s,a){if(La(s)){const r=ai(t,s);return[{index:At(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 Ua={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ba(t,s,a,r,n,o){const{lastIndex:i,lastOffset:l,lastSize:c}=n;let d=0,x=0;if(t.length>0){d=t[0].offset;const S=t[t.length-1];x=S.offset+S.size}const b=a-i,p=l+b*c+(b-1)*r,g=d,C=p-x;return{bottom:x,firstItemIndex:o,items:$n(t,n,o),offsetBottom:C,offsetTop:d,top:g,topItems:$n(s,n,o),topListHeight:s.reduce((S,N)=>N.size+S,0),totalCount:a}}function li(t,s,a,r,n,o){let i=0;if(a.groupIndices.length>0)for(const x of a.groupIndices){if(x-i>=t)break;i++}const l=t+i,c=Sr(s,l),d=Array.from({length:l}).map((x,b)=>({data:o[b+c],index:b+c,offset:0,size:0}));return ba(d,[],l,n,a,r)}function $n(t,s,a){if(t.length===0)return[];if(!La(s))return t.map(d=>({...d,index:d.index+a,originalIndex:d.index}));const r=t[0].index,n=t[t.length-1].index,o=[],i=Es(s.groupOffsetTree,r,n);let l,c=0;for(const d of t){(!l||l.end{const S=G([]),N=G(0),m=ze(),w=G(0);ce(o.topItemsIndexes,S);const y=ht(P(at(g,C,he(c,Xs),he(n),he(r),he(d),x,he(S),he(s),he(a),he(w),t),fe(([v,k,,I,,,,,,,,$])=>{const D=$!==void 0&&$.length!==I;return v&&!k&&!D}),re(([,,[v,k],I,$,D,q,Q,A,U,ee,ie])=>{const je=$,{offsetTree:ge,sizeTree:Ce}=je,de=Xe(N);if(I===0)return{...Ua,totalCount:I};if(v===0&&k===0)return de===0?{...Ua,totalCount:I}:li(de,D,$,A,U,ie||[]);if(Ve(Ce))return de>0?null:ba(td(Sr(D,I),je,ie),[],I,U,je,A);const B=[];if(Q.length>0){const X=Q[0],f=Q[Q.length-1];let T=0;for(const E of Es(Ce,X,f)){const W=E.value,V=Math.max(E.start,X),se=Math.min(E.end,f);for(let ae=V;ae<=se;ae++)B.push({data:ie?.[ae],index:ae,offset:T,size:W}),T+=W}}if(!q)return ba([],B,I,U,je,A);const Y=Q.length>0?Q[Q.length-1]+1:0,ne=Gc(ge,v,k,Y);if(ne.length===0)return null;const De=I-1,Le=za([],X=>{for(const f of ne){const T=f.value;let E=T.offset,W=f.start;const V=T.size;if(T.offset=k);ae++)X.push({data:ie?.[ae],index:ae,offset:E,size:V}),E+=V+U}}),Ge=On(ee,ea),O=On(ee,ta);if(Le.length>0&&(Ge>0||O>0)){const X=Le[0],f=Le[Le.length-1];if(Ge>0&&X.index>Y){const T=Math.min(Ge,X.index-Y),E=[];let W=X.offset;for(let V=X.index-1;V>=X.index-T;V--){const se=Es(Ce,V,V)[0]?.value??X.size;W-=se+U,E.unshift({data:ie?.[V],index:V,offset:W,size:se})}Le.unshift(...E)}if(O>0&&f.indexv!==null),Ye()),Ua);ce(P(t,fe(br),re(v=>v?.length)),n),ce(P(y,re(v=>v.topListHeight)),b),ce(b,l),ce(P(y,re(v=>[v.top,v.bottom])),i),ce(P(y,re(v=>v.items)),m);const R=jt(P(y,fe(({items:v})=>v.length>0),Ie(n,t),fe(([{items:v},k])=>v[v.length-1].originalIndex===k-1),re(([,v,k])=>[v-1,k]),Ye(Xs),re(([v])=>v))),j=jt(P(y,qt(200),fe(({items:v,topItems:k})=>v.length>0&&v[0].originalIndex===k.length),re(({items:v})=>v[0].index),Ye())),H=jt(P(y,fe(({items:v})=>v.length>0),re(({items:v})=>{let k=0,I=v.length-1;for(;v[k].type==="group"&&kk;)I--;return{endIndex:v[I].index,startIndex:v[k].index}}),Ye(ti)));return{endReached:R,initialItemCount:N,itemsRendered:m,listState:y,minOverscanItemCount:w,rangeChanged:H,startReached:j,topItemsIndexes:S,...p}},Ke(Qt,ni,kr,oa,na,ia,is,Nr),{singleton:!0}),ci=Be(([{fixedFooterHeight:t,fixedHeaderHeight:s,footerHeight:a,headerHeight:r},{listState:n}])=>{const o=ze(),i=ht(P(at(a,t,r,s,n),re(([l,c,d,x,b])=>l+c+d+x+b.offsetBottom+b.bottom)),0);return ce(he(i),o),{totalListHeight:i,totalListHeightChanged:o}},Ke(bt,vs),{singleton:!0}),sd=Be(([{viewportHeight:t},{totalListHeight:s}])=>{const a=G(!1),r=ht(P(at(a,t,s),fe(([n])=>n),re(([,n,o])=>Math.max(0,n-o)),qt(0),Ye()),0);return{alignToBottom:a,paddingTopAddition:r}},Ke(bt,ci),{singleton:!0}),di=Be(()=>({context:G(null)})),ad=({itemBottom:t,itemTop:s,locationParams:{align:a,behavior:r,...n},viewportBottom:o,viewportTop:i})=>so?{...n,align:a??"end",...r!==void 0?{behavior:r}:{}}:null,ui=Be(([{gap:t,sizes:s,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:n,headerHeight:o,scrollingInProgress:i,scrollTop:l,viewportHeight:c},{scrollToIndex:d}])=>{const x=ze();return ce(P(x,Ie(s,c,a,o,n,r,l),Ie(t),re(([[b,p,g,C,S,N,m,w],y])=>{const{calculateViewLocation:R=ad,done:j,...H}=b,v=ri(b,p,C-1),k=Js(v,p.offsetTree,y)+S+N,I=k+At(p.sizeTree,v)[1],$=w+N,D=w+g-m,q=R({itemBottom:I,itemTop:k,locationParams:H,viewportBottom:D,viewportTop:$});return q!==null?j&&Mt(P(i,fe(Q=>!Q),fs(Xe(i)?1:2)),j):j?.(),q}),fe(b=>b!==null)),d),{scrollIntoView:x}},Ke(Qt,bt,na,vs,os),{singleton:!0});function Bn(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const rd=(t,s)=>typeof t=="function"?Bn(t(s)):s&&Bn(t),nd=Be(([{listRefresh:t,totalCount:s,fixedItemSize:a,data:r},{atBottomState:n,isAtBottom:o},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:c,propsReady:d},{log:x},{scrollingInProgress:b},{context:p},{scrollIntoView:g}])=>{const C=G(!1),S=ze();let N=null;function m(j){Te(i,{align:"end",behavior:j,index:"LAST"})}He(P(at(P(he(s),fs(1)),c),Ie(he(C),o,l,b),re(([[j,H],v,k,I,$])=>{let D=H&&I,q="auto";return D&&(q=rd(v,k||$),D=D&&q!==!1),{followOutputBehavior:q,shouldFollow:D,totalCount:j}}),fe(({shouldFollow:j})=>j)),({followOutputBehavior:j,totalCount:H})=>{N!==null&&(N(),N=null),Xe(a)!==void 0?requestAnimationFrame(()=>{Xe(x)("following output to ",{totalCount:H},nt.DEBUG),m(j)}):N=Mt(t,()=>{Xe(x)("following output to ",{totalCount:H},nt.DEBUG),m(j),N=null})});function w(j){const H=Mt(n,v=>{j&&!v.atBottom&&v.notAtBottomBecause==="SIZE_INCREASED"&&N===null&&(Xe(x)("scrolling to bottom due to increased size",{},nt.DEBUG),m("auto"))});setTimeout(H,100)}He(P(at(he(C),s,d),fe(([j,,H])=>j!==!1&&H),Ot(({value:j},[,H])=>({refreshed:j===H,value:H}),{refreshed:!1,value:0}),fe(({refreshed:j})=>j),Ie(C,s)),([,j])=>{Xe(l)&&w(j!==!1)}),He(S,()=>{w(Xe(C)!==!1)}),He(at(he(C),n),([j,H])=>{j!==!1&&!H.atBottom&&H.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&m("auto")});const y=G(null),R=ze();return ce(ir(P(he(r),re(j=>j?.length??0)),P(he(s))),R),He(P(at(P(R,fs(1)),c),Ie(he(y),l,b,p),re(([[j,H],v,k,I,$])=>H&&k&&v?.({context:$,totalCount:j,scrollingInProgress:I})),fe(j=>!!j),qt(0)),j=>{N!==null&&(N(),N=null),Xe(a)!==void 0?requestAnimationFrame(()=>{Xe(x)("scrolling into view",{}),Te(g,j)}):N=Mt(t,()=>{Xe(x)("scrolling into view",{}),Te(g,j),N=null})}),{autoscrollToBottom:S,followOutput:C,scrollIntoViewOnChange:y}},Ke(Qt,ia,na,oa,is,os,bt,di,ui)),od=Be(([{data:t,firstItemIndex:s,gap:a,sizes:r},{initialTopMostItemIndex:n},{initialItemCount:o,listState:i},{didMount:l}])=>(ce(P(l,Ie(o),fe(([,c])=>c!==0),Ie(n,r,s,a,t),re(([[,c],d,x,b,p,g=[]])=>li(c,d,x,b,p,g))),i),{}),Ke(Qt,oa,vs,is),{singleton:!0}),id=Be(([{didMount:t},{scrollTo:s},{listState:a}])=>{const r=G(0);return He(P(t,Ie(r),fe(([,n])=>n!==0),re(([,n])=>({top:n}))),n=>{Mt(P(a,fs(1),fe(o=>o.items.length>1)),()=>{requestAnimationFrame(()=>{Te(s,n)})})}),{initialScrollTop:r}},Ke(is,bt,vs),{singleton:!0}),mi=Be(([{scrollVelocity:t}])=>{const s=G(!1),a=ze(),r=G(!1);return ce(P(t,Ie(r,s,a),fe(([n,o])=>o!==!1&&o!==void 0),re(([n,o,i,l])=>{const{enter:c,exit:d}=o;if(i){if(d(n,l))return!1}else if(c(n,l))return!0;return i}),Ye()),s),He(P(at(s,t,a),Ie(r)),([[n,o,i],l])=>{n&&l!==!1&&l!==void 0&&l.change&&l.change(o,i)}),{isSeeking:s,scrollSeekConfiguration:r,scrollSeekRangeChanged:a,scrollVelocity:t}},Ke(ia),{singleton:!0}),Cr=Be(([{scrollContainerState:t,scrollTo:s}])=>{const a=ze(),r=ze(),n=ze(),o=G(!1),i=G(void 0);return ce(P(at(a,r),re(([{scrollTop:l,viewportHeight:c},{offsetTop:d,listHeight:x}])=>({scrollHeight:x,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),ce(P(s,Ie(r),re(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),n),{customScrollParent:i,useWindowScroll:o,windowScrollContainerState:a,windowScrollTo:n,windowViewportRect:r}},Ke(bt)),ld=Be(([{sizeRanges:t,sizes:s},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:n},{didMount:o},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:c}])=>{const d=ze(),x=G(void 0),b=G(null),p=G(null);return ce(l,b),ce(c,p),He(P(d,Ie(s,r,i,b,p,a)),([g,C,S,N,m,w,y])=>{const R=Vc(C.sizeTree);N&&m!==null&&w!==null&&(S=m.scrollTop-w.offsetTop),S-=y,g({ranges:R,scrollTop:S})}),ce(P(x,fe(br),re(cd)),n),ce(P(o,Ie(x),fe(([,g])=>g!==void 0),Ye(),re(([,g])=>g.ranges)),t),{getState:d,restoreStateFrom:x}},Ke(Qt,bt,oa,is,Cr));function cd(t){return{align:"start",index:0,offset:t.scrollTop}}const dd=Be(([{topItemsIndexes:t}])=>{const s=G(0);return ce(P(s,fe(a=>a>=0),re(a=>Array.from({length:a}).map((r,n)=>n))),t),{topItemCount:s}},Ke(vs));function xi(t){let s=!1,a;return(()=>(s||(s=!0,a=t()),a))}const ud=xi(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),md=Be(([{deviation:t,scrollBy:s,scrollingInProgress:a,scrollTop:r},{isAtBottom:n,isScrolling:o,lastJumpDueToItemResize:i,scrollDirection:l},{listState:c},{beforeUnshiftWith:d,gap:x,shiftWithOffset:b,sizes:p},{log:g},{recalcInProgress:C}])=>{const S=jt(P(c,Ie(i),Ot(([,m,w,y],[{bottom:R,items:j,offsetBottom:H,totalCount:v},k])=>{const I=R+H;let $=0;return w===v&&m.length>0&&j.length>0&&(j[0].originalIndex===0&&m[0].originalIndex===0||($=I-y,$!==0&&($+=k))),[$,j,v,I]},[0,[],0,0]),fe(([m])=>m!==0),Ie(r,l,a,n,g,C),fe(([,m,w,y,,,R])=>!R&&!y&&m!==0&&w===Zs),re(([[m],,,,,w])=>(w("Upward scrolling compensation",{amount:m},nt.DEBUG),m))));function N(m){m>0?(Te(s,{behavior:"auto",top:-m}),Te(t,0)):(Te(t,0),Te(s,{behavior:"auto",top:-m}))}return He(P(S,Ie(t,o)),([m,w,y])=>{y&&ud()?Te(t,w-m):N(-m)}),He(P(at(ht(o,!1),t,C),fe(([m,w,y])=>!m&&!y&&w!==0),re(([m,w])=>w),qt(1)),N),ce(P(b,re(m=>({top:-m}))),s),He(P(d,Ie(p,x),re(([m,{groupIndices:w,lastSize:y,sizeTree:R},j])=>{function H(D){return D*(y+j)}if(w.length===0)return H(m);let v=0;const k=Ks(R,0);let I=0,$=0;for(;Im&&(v-=k,D=m-I+1),I+=D,v+=H(D),$++}return v})),m=>{Te(t,m),requestAnimationFrame(()=>{Te(s,{top:m}),requestAnimationFrame(()=>{Te(t,0),Te(C,!1)})})}),{deviation:t}},Ke(bt,ia,vs,Qt,os,Nr)),xd=Be(([t,s,a,r,n,o,i,l,c,d,x])=>({...t,...s,...a,...r,...n,...o,...i,...l,...c,...d,...x}),Ke(kr,od,is,mi,ci,id,sd,Cr,ui,os,di)),pi=Be(([{data:t,defaultItemSize:s,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:n,gap:o,groupIndices:i,heightEstimates:l,itemSize:c,sizeRanges:d,sizes:x,statefulTotalCount:b,totalCount:p,trackItemSizes:g},{initialItemFinalLocationReached:C,initialTopMostItemIndex:S,scrolledToInitialItem:N},m,w,y,R,{scrollToIndex:j},H,{topItemCount:v},{groupCounts:k},I])=>{const{listState:$,minOverscanItemCount:D,topItemsIndexes:q,rangeChanged:Q,...A}=R;return ce(Q,I.scrollSeekRangeChanged),ce(P(I.windowViewportRect,re(U=>U.visibleHeight)),m.viewportHeight),{data:t,defaultItemHeight:s,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:n,gap:o,groupCounts:k,heightEstimates:l,initialItemFinalLocationReached:C,initialTopMostItemIndex:S,scrolledToInitialItem:N,sizeRanges:d,topItemCount:v,topItemsIndexes:q,totalCount:p,...y,groupIndices:i,itemSize:c,listState:$,minOverscanItemCount:D,scrollToIndex:j,statefulTotalCount:b,trackItemSizes:g,rangeChanged:Q,...A,...I,...m,sizes:x,...w}},Ke(Qt,oa,bt,ld,nd,vs,na,md,dd,ni,xd));function pd(t,s){const a={},r={};let n=0;const o=t.length;for(;n(m[w]=y=>{const R=N[s.methods[w]];Te(R,y)},m),{})}function x(N){return i.reduce((m,w)=>(m[w]=_c(N[s.events[w]]),m),{})}const b=le.forwardRef(function(N,m){const{children:w,...y}=N,[R]=le.useState(()=>za(Mc(t),v=>{c(v,y)})),[j]=le.useState(_n(x,R));ua(()=>{for(const v of i)v in y&&He(j[v],y[v]);return()=>{Object.values(j).map(vr)}},[y,j,R]),ua(()=>{c(R,y)}),le.useImperativeHandle(m,En(d(R)));const H=a;return e.jsx(l.Provider,{value:R,children:a!==void 0?e.jsx(H,{...pd([...r,...n,...i],y),children:w}):w})}),p=N=>{const m=le.useContext(l);return le.useCallback(w=>{Te(m[N],w)},[m,N])},g=N=>{const m=le.useContext(l)[N],w=le.useCallback(y=>He(m,y),[m]);return le.useSyncExternalStore(w,()=>Xe(m),()=>Xe(m))},C=N=>{const m=le.useContext(l)[N],[w,y]=le.useState(_n(Xe,m));return ua(()=>He(m,R=>{R!==w&&y(En(R))}),[m,w]),w},S=parseInt(le.version)>=18?g:C;return{Component:b,useEmitter:(N,m)=>{const w=le.useContext(l)[N];ua(()=>He(w,m),[m,w])},useEmitterValue:S,usePublisher:p}}const fi=le.createContext(void 0),gi=le.createContext(void 0),Wa="-webkit-sticky",Pn="sticky",Tr=xi(()=>{if(typeof document>"u")return Pn;const t=document.createElement("div");return t.style.position=Wa,t.style.position===Wa?Wa:Pn}),bi=typeof document<"u"?le.useLayoutEffect:le.useEffect;function qa(t){return"self"in t}function hd(t){return"body"in t}function vi(t,s,a,r=Ls,n,o){const i=le.useRef(null),l=le.useRef(null),c=le.useRef(null),d=le.useCallback(p=>{let g,C,S;const N=p.target;if(hd(N)||qa(N)){const w=qa(N)?N:N.defaultView;S=o===!0?w.scrollX:w.scrollY,g=o===!0?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,C=o===!0?w.innerWidth:w.innerHeight}else S=o===!0?N.scrollLeft:N.scrollTop,g=o===!0?N.scrollWidth:N.scrollHeight,C=o===!0?N.offsetWidth:N.offsetHeight;const m=()=>{t({scrollHeight:g,scrollTop:Math.max(S,0),viewportHeight:C})};p.suppressFlushSync===!0?m():sr.flushSync(m),l.current!==null&&(S===l.current||S<=0||S===g-C)&&(l.current=null,s(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,s,o]);le.useEffect(()=>{const p=n||i.current;return r(n||i.current),d({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",d,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",d)}},[i,d,a,r,n]);function x(p){const g=i.current;if(!g||(o===!0?"offsetWidth"in g&&g.offsetWidth===0:"offsetHeight"in g&&g.offsetHeight===0))return;const C=p.behavior==="smooth";let S,N,m;qa(g)?(N=Math.max(rs(g.document.documentElement,o===!0?"width":"height"),o===!0?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight),S=o===!0?g.innerWidth:g.innerHeight,m=o===!0?window.scrollX:window.scrollY):(N=g[o===!0?"scrollWidth":"scrollHeight"],S=rs(g,o===!0?"width":"height"),m=g[o===!0?"scrollLeft":"scrollTop"]);const w=N-S;if(p.top=Math.ceil(Math.max(Math.min(w,p.top),0)),ii(S,N)||p.top===m){t({scrollHeight:N,scrollTop:m,viewportHeight:S}),C&&s(!0);return}C?(l.current=p.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,s(!0)},1e3)):l.current=null,o===!0&&(p={...p.behavior!==void 0?{behavior:p.behavior}:{},left:p.top}),g.scrollTo(p)}function b(p){o===!0&&(p={...p.behavior!==void 0?{behavior:p.behavior}:{},...p.top!==void 0?{left:p.top}:{}}),i.current.scrollBy(p)}return{scrollByCallback:b,scrollerRef:i,scrollToCallback:x}}function Ir(t){return t}const fd=Be(()=>{const t=G(l=>`Item ${l}`),s=G(l=>`Group ${l}`),a=G({}),r=G(Ir),n=G("div"),o=G(Ls),i=(l,c=null)=>ht(P(a,re(d=>d[l]),Ye()),c);return{components:a,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:s,HeaderComponent:i("Header"),HeaderFooterTag:n,ItemComponent:i("Item","div"),itemContent:t,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:o,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),gd=Be(([t,s])=>({...t,...s}),Ke(pi,fd)),bd=({height:t})=>e.jsx("div",{style:{height:t}}),vd={overflowAnchor:"none",position:Tr(),zIndex:1},wi={overflowAnchor:"none"},wd={...wi,display:"inline-block",height:"100%"},Hn=le.memo(function({showTopList:t=!1}){const s=ye("listState"),a=kt("sizeRanges"),r=ye("useWindowScroll"),n=ye("customScrollParent"),o=kt("windowScrollContainerState"),i=kt("scrollContainerState"),l=n||r?o:i,c=ye("itemContent"),d=ye("context"),x=ye("groupContent"),b=ye("trackItemSizes"),p=ye("itemSize"),g=ye("log"),C=kt("gap"),S=ye("horizontalDirection"),{callbackRef:N}=Ac(a,p,b,t?Ls:l,g,C,n,S,ye("skipAnimationFrameInResizeObserver")),[m,w]=le.useState(0);_r("deviation",A=>{m!==A&&w(A)});const y=ye("EmptyPlaceholder"),R=ye("ScrollSeekPlaceholder")??bd,j=ye("ListComponent"),H=ye("ItemComponent"),v=ye("GroupComponent"),k=ye("computeItemKey"),I=ye("isSeeking"),$=ye("groupIndices").length>0,D=ye("alignToBottom"),q=ye("initialItemFinalLocationReached"),Q=t?{}:{boxSizing:"border-box",...S?{display:"inline-block",height:"100%",marginLeft:m!==0?m:D?"auto":0,paddingLeft:s.offsetTop,paddingRight:s.offsetBottom,whiteSpace:"nowrap"}:{marginTop:m!==0?m:D?"auto":0,paddingBottom:s.offsetBottom,paddingTop:s.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&s.totalCount===0&&y!==null&&y!==void 0?e.jsx(y,{...pt(y,d)}):e.jsx(j,{...pt(j,d),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:N,style:Q,children:(t?s.topItems:s.items).map(A=>{const U=A.originalIndex,ee=k(U+s.firstItemIndex,A.data,d);return I?h.createElement(R,{...pt(R,d),height:A.size,index:A.index,key:ee,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?h.createElement(v,{...pt(v,d),"data-index":U,"data-item-index":A.index,"data-known-size":A.size,key:ee,style:vd},x(A.index,d)):h.createElement(H,{...pt(H,d),...Sd(H,A.data),"data-index":U,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:ee,style:S?wd:wi},$?c(A.index,A.groupIndex,A.data,d):c(A.index,A.data,d))})})}),Nd={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},jd={outline:"none",overflowX:"auto",position:"relative"},Er=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Ni=(t,s,a=0)=>({...Er(t),position:s?"relative":"absolute",top:s?-a:0}),yd={position:Tr(),top:0,width:"100%",zIndex:1};function pt(t,s){if(typeof t!="string")return{context:s}}function Sd(t,s){return{item:typeof t=="string"?void 0:s}}const kd=le.memo(function(){const t=ye("HeaderComponent"),s=kt("headerHeight"),a=ye("HeaderFooterTag"),r=bs(le.useMemo(()=>o=>{s(rs(o,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),n=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,n)})}):null}),Cd=le.memo(function(){const t=ye("FooterComponent"),s=kt("footerHeight"),a=ye("HeaderFooterTag"),r=bs(le.useMemo(()=>o=>{s(rs(o,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),n=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,n)})}):null});function ji({useEmitter:t,useEmitterValue:s,usePublisher:a}){return le.memo(function({children:r,style:n,context:o,...i}){const l=a("scrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),x=s("scrollerRef"),b=s("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:g,scrollToCallback:C}=vi(l,d,c,x,void 0,b);return t("scrollTo",C),t("scrollBy",p),e.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:g,style:{...b?jd:Nd,...n},tabIndex:0,...i,...pt(c,o),children:r})})}function yi({useEmitter:t,useEmitterValue:s,usePublisher:a}){return le.memo(function({children:r,style:n,context:o,...i}){const l=a("windowScrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),x=s("totalListHeight"),b=s("deviation"),p=s("customScrollParent"),g=le.useRef(null),C=s("scrollerRef"),{scrollByCallback:S,scrollerRef:N,scrollToCallback:m}=vi(l,d,c,C,p);return bi(()=>(N.current=p||g.current?.ownerDocument.defaultView,()=>{N.current=null}),[N,p]),t("windowScrollTo",m),t("scrollBy",S),e.jsx(c,{ref:g,"data-virtuoso-scroller":!0,style:{position:"relative",...n,...x!==0?{height:x+b}:void 0},...i,...pt(c,o),children:r})})}const Td=({children:t})=>{const s=le.useContext(fi),a=kt("viewportHeight"),r=kt("fixedItemHeight"),n=ye("alignToBottom"),o=ye("horizontalDirection"),i=le.useMemo(()=>Wo(a,c=>rs(c,o?"width":"height")),[a,o]),l=bs(i,!0,ye("skipAnimationFrameInResizeObserver"));return le.useEffect(()=>{s&&(a(s.viewportHeight),r(s.itemHeight))},[s,a,r]),e.jsx("div",{"data-viewport-type":"element",ref:l,style:Er(n),children:t})},Id=({children:t})=>{const s=le.useContext(fi),a=kt("windowViewportRect"),r=kt("fixedItemHeight"),n=ye("customScrollParent"),o=ye("useWindowScroll"),i=ye("topListHeight"),l=Yo(a,n,ye("skipAnimationFrameInResizeObserver")),c=ye("alignToBottom");return le.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:Ni(c,o,i),children:t})},Ed=({children:t})=>{const s=ye("TopItemListComponent")??"div",a=ye("headerHeight"),r={...yd,marginTop:`${a}px`},n=ye("context");return e.jsx(s,{style:r,...pt(s,n),children:t})},_d=le.memo(function(t){const s=ye("useWindowScroll"),a=ye("topItemsIndexes").length>0,r=ye("customScrollParent"),n=ye("context");return e.jsxs(r||s?zd:Md,{...t,context:n,children:[a&&e.jsx(Ed,{children:e.jsx(Hn,{showTopList:!0})}),e.jsxs(r||s?Id:Td,{children:[e.jsx(kd,{}),e.jsx(Hn,{}),e.jsx(Cd,{})]})]})}),{Component:Rd,useEmitter:_r,useEmitterValue:ye,usePublisher:kt}=hi(gd,{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"}},_d),Md=ji({useEmitter:_r,useEmitterValue:ye,usePublisher:kt}),zd=yi({useEmitter:_r,useEmitterValue:ye,usePublisher:kt}),Ld=Rd,Ad=Be(()=>{const t=G(d=>e.jsxs("td",{children:["Item $",d]})),s=G(null),a=G(d=>e.jsxs("td",{colSpan:1e3,children:["Group ",d]})),r=G(null),n=G(null),o=G({}),i=G(Ir),l=G(Ls),c=(d,x=null)=>ht(P(o,re(b=>b[d]),Ye()),x);return{components:o,computeItemKey:i,context:s,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:n,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")}});Ke(pi,Ad);Tr();const Gn={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dd={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Qn,floor:Ia,max:qs,min:Ya,round:Vn}=Math;function Un(t,s,a){return Array.from({length:s-t+1}).map((r,n)=>({data:a===null?null:a[n+t],index:n+t}))}function Fd(t){return{...Dd,items:t}}function ma(t,s){return t!==void 0&&t.width===s.width&&t.height===s.height}function $d(t,s){return t!==void 0&&t.column===s.column&&t.row===s.row}const Od=Be(([{increaseViewportBy:t,listBoundary:s,overscan:a,visibleRange:r},{footerHeight:n,headerHeight:o,scrollBy:i,scrollContainerState:l,scrollTo:c,scrollTop:d,smoothScrollTargetReached:x,viewportHeight:b},p,g,{didMount:C,propsReady:S},{customScrollParent:N,useWindowScroll:m,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:R},j])=>{const H=G(0),v=G(0),k=G(Gn),I=G({height:0,width:0}),$=G({height:0,width:0}),D=ze(),q=ze(),Q=G(0),A=G(null),U=G({column:0,row:0}),ee=ze(),ie=ze(),je=G(!1),ge=G(0),Ce=G(!0),de=G(!1),B=G(!1);He(P(C,Ie(ge),fe(([O,X])=>X!==0)),()=>{Te(Ce,!1)}),He(P(at(C,Ce,$,I,ge,de),fe(([O,X,f,T,,E])=>O&&!X&&f.height!==0&&T.height!==0&&!E)),([,,,,O])=>{Te(de,!0),yr(1,()=>{Te(D,O)}),Mt(P(d),()=>{Te(s,[0,0]),Te(Ce,!0)})}),ce(P(ie,fe(O=>O!=null&&O.scrollTop>0),$t(0)),v),He(P(C,Ie(ie),fe(([,O])=>O!=null)),([,O])=>{O&&(Te(I,O.viewport),Te($,O.item),Te(U,O.gap),O.scrollTop>0&&(Te(je,!0),Mt(P(d,fs(1)),X=>{Te(je,!1)}),Te(c,{top:O.scrollTop})))}),ce(P(I,re(({height:O})=>O)),b),ce(P(at(he(I,ma),he($,ma),he(U,(O,X)=>O!==void 0&&O.column===X.column&&O.row===X.row),he(d)),re(([O,X,f,T])=>({gap:f,item:X,scrollTop:T,viewport:O}))),ee),ce(P(at(he(H),r,he(U,$d),he($,ma),he(I,ma),he(A),he(v),he(je),he(Ce),he(ge)),fe(([,,,,,,,O])=>!O),re(([O,[X,f],T,E,W,V,se,,ae,z])=>{const{column:oe,row:ue}=T,{height:ve,width:K}=E,{width:we}=W;if(se===0&&(O===0||we===0))return Gn;if(K===0){const M=Sr(z,O),te=M+Math.max(se-1,0);return Fd(Un(M,te,V))}const We=Si(we,K,oe);let Se,Je;ae?X===0&&f===0&&se>0?(Se=0,Je=se-1):(Se=We*Ia((X+ue)/(ve+ue)),Je=We*Qn((f+ue)/(ve+ue))-1,Je=Ya(O-1,qs(Je,We-1)),Se=Ya(Je,qs(0,Se))):(Se=0,Je=-1);const et=Un(Se,Je,V),{bottom:F,top:Z}=Wn(W,T,E,et),Re=Qn(O/We),Ne=Re*ve+(Re-1)*ue-F;return{bottom:F,itemHeight:ve,items:et,itemWidth:K,offsetBottom:Ne,offsetTop:Z,top:Z}})),k),ce(P(A,fe(O=>O!==null),re(O=>O.length)),H),ce(P(at(I,$,k,U),fe(([O,X,{items:f}])=>f.length>0&&X.height!==0&&O.height!==0),re(([O,X,{items:f},T])=>{const{bottom:E,top:W}=Wn(O,T,X,f);return[W,E]}),Ye(Xs)),s);const Y=G(!1);ce(P(d,Ie(Y),re(([O,X])=>X||O!==0)),Y);const ne=jt(P(at(k,H),fe(([{items:O}])=>O.length>0),Ie(Y),fe(([[O,X],f])=>{const T=O.items[O.items.length-1].index===X-1;return(f||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===X)&&T}),re(([[,O]])=>O-1),Ye())),De=jt(P(he(k),fe(({items:O})=>O.length>0&&O[0].index===0),$t(0),Ye())),Le=jt(P(he(k),Ie(je),fe(([{items:O},X])=>O.length>0&&!X),re(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),Ye(ti),qt(0)));ce(Le,g.scrollSeekRangeChanged),ce(P(D,Ie(I,$,H,U),re(([O,X,f,T,E])=>{const W=oi(O),{align:V,behavior:se,offset:ae}=W;let z=W.index;z==="LAST"&&(z=T-1),z=qs(0,z,Ya(T-1,z));let oe=mr(X,E,f,z);return V==="end"?oe=Vn(oe-X.height+f.height):V==="center"&&(oe=Vn(oe-X.height/2+f.height/2)),ae!==void 0&&ae!==0&&(oe+=ae),{behavior:se,top:oe}})),c);const Ge=ht(P(k,re(O=>O.offsetBottom+O.bottom)),0);return ce(P(R,re(O=>({height:O.visibleHeight,width:O.visibleWidth}))),I),{customScrollParent:N,data:A,deviation:Q,footerHeight:n,gap:U,headerHeight:o,increaseViewportBy:t,initialItemCount:v,itemDimensions:$,overscan:a,restoreStateFrom:ie,scrollBy:i,scrollContainerState:l,scrollHeight:q,scrollTo:c,scrollToIndex:D,scrollTop:d,smoothScrollTargetReached:x,totalCount:H,useWindowScroll:m,viewportDimensions:I,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:R,...g,gridState:k,horizontalDirection:B,initialTopMostItemIndex:ge,totalListHeight:Ge,...p,endReached:ne,propsReady:S,rangeChanged:Le,startReached:De,stateChanged:ee,stateRestoreInProgress:je,...j}},Ke(kr,bt,ia,mi,is,Cr,os));function Si(t,s,a){return qs(1,Ia((t+a)/(Ia(s)+a)))}function Wn(t,s,a,r){const{height:n}=a;if(n===void 0||r.length===0)return{bottom:0,top:0};const o=mr(t,s,a,r[0].index);return{bottom:mr(t,s,a,r[r.length-1].index)+n,top:o}}function mr(t,s,a,r){const n=Si(t.width,a.width,s.column),o=Ia(r/n),i=o*a.height+qs(0,o-1)*s.row;return i>0?i+s.row:i}const Bd=Be(()=>{const t=G(b=>`Item ${b}`),s=G({}),a=G(null),r=G("virtuoso-grid-item"),n=G("virtuoso-grid-list"),o=G(Ir),i=G("div"),l=G(Ls),c=(b,p=null)=>ht(P(s,re(g=>g[b]),Ye()),p),d=G(!1),x=G(!1);return ce(he(x),d),{components:s,computeItemKey:o,context:a,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:t,listClassName:n,ListComponent:c("List","div"),readyStateChanged:d,reportReadyState:x,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Pd=Be(([t,s])=>({...t,...s}),Ke(Od,Bd)),Hd=le.memo(function(){const t=qe("gridState"),s=qe("listClassName"),a=qe("itemClassName"),r=qe("itemContent"),n=qe("computeItemKey"),o=qe("isSeeking"),i=Ct("scrollHeight"),l=qe("ItemComponent"),c=qe("ListComponent"),d=qe("ScrollSeekPlaceholder"),x=qe("context"),b=Ct("itemDimensions"),p=Ct("gap"),g=qe("log"),C=qe("stateRestoreInProgress"),S=Ct("reportReadyState"),N=bs(le.useMemo(()=>m=>{const w=m.parentElement.parentElement.scrollHeight;i(w);const y=m.firstChild;if(y!==null){const{height:R,width:j}=y.getBoundingClientRect();b({height:R,width:j})}p({column:qn("column-gap",getComputedStyle(m).columnGap,g),row:qn("row-gap",getComputedStyle(m).rowGap,g)})},[i,b,p,g]),!0,!1);return bi(()=>{t.itemHeight>0&&t.itemWidth>0&&S(!0)},[t]),C?null:e.jsx(c,{className:s,ref:N,...pt(c,x),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(m=>{const w=n(m.index,m.data,x);return o?e.jsx(d,{...pt(d,x),height:t.itemHeight,index:m.index,width:t.itemWidth},w):h.createElement(l,{...pt(l,x),className:a,"data-index":m.index,key:w},r(m.index,m.data,x))})})}),Gd=le.memo(function(){const t=qe("HeaderComponent"),s=Ct("headerHeight"),a=qe("headerFooterTag"),r=bs(le.useMemo(()=>o=>{s(rs(o,"height"))},[s]),!0,!1),n=qe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,n)})}):null}),Qd=le.memo(function(){const t=qe("FooterComponent"),s=Ct("footerHeight"),a=qe("headerFooterTag"),r=bs(le.useMemo(()=>o=>{s(rs(o,"height"))},[s]),!0,!1),n=qe("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,n)})}):null}),Vd=({children:t})=>{const s=le.useContext(gi),a=Ct("itemDimensions"),r=Ct("viewportDimensions"),n=bs(le.useMemo(()=>o=>{r(o.getBoundingClientRect())},[r]),!0,!1);return le.useEffect(()=>{s&&(r({height:s.viewportHeight,width:s.viewportWidth}),a({height:s.itemHeight,width:s.itemWidth}))},[s,r,a]),e.jsx("div",{ref:n,style:Er(!1),children:t})},Ud=({children:t})=>{const s=le.useContext(gi),a=Ct("windowViewportRect"),r=Ct("itemDimensions"),n=qe("customScrollParent"),o=qe("useWindowScroll"),i=Yo(a,n,!1);return le.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:Ni(!1,o),children:t})},Wd=le.memo(function({...t}){const s=qe("useWindowScroll"),a=qe("customScrollParent"),r=a||s?Yd:qd,n=a||s?Ud:Vd,o=qe("context");return e.jsx(r,{...t,...pt(r,o),children:e.jsxs(n,{children:[e.jsx(Gd,{}),e.jsx(Hd,{}),e.jsx(Qd,{})]})})}),{useEmitter:ki,useEmitterValue:qe,usePublisher:Ct}=hi(Pd,{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"}},Wd),qd=ji({useEmitter:ki,useEmitterValue:qe,usePublisher:Ct}),Yd=yi({useEmitter:ki,useEmitterValue:qe,usePublisher:Ct});function qn(t,s,a){return s!=="normal"&&s?.endsWith("px")!==!0&&a(`${t} was not resolved to pixel value correctly`,s,nt.WARN),s==="normal"?0:parseInt(s??"0",10)}function Yn(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 Kn=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th"]);function Kd(t,s="component",a){const r=t.getBoundingClientRect(),n=[],o=a?.leafTags?new Set([...Kn,...a.leafTags]):Kn,i=a?.captureRoundedBorders??!0,l=a?.excludeTags?new Set(a.excludeTags):null,c=a?.excludeSelectors??null;function d(x){const b=getComputedStyle(x);if(b.display==="none"||b.visibility==="hidden"||b.opacity==="0")return;const p=x.tagName.toLowerCase();if(l?.has(p)||c?.some(I=>x.matches(I)))return;const g=[...x.children].filter(I=>{const $=getComputedStyle(I);return $.display!=="none"&&$.visibility!=="hidden"&&$.opacity!=="0"}),C=p==="img"||p==="svg"||p==="video"||p==="canvas",S=p==="input"||p==="button"||p==="textarea"||p==="select",N=g.length===0||C||S||o.has(p),m=b.backgroundColor,w=m!=="rgba(0, 0, 0, 0)"&&m!=="transparent",y=b.backgroundImage!=="none",R=parseFloat(b.borderTopWidth)||0,j=i&&R>0&&b.borderTopColor!=="rgba(0, 0, 0, 0)"&&b.borderTopColor!=="transparent",H=(parseFloat(b.borderTopLeftRadius)||0)>0,v=w||y||j&&H,k=p==="tr"||p==="td"||p==="th"||p==="thead"||p==="tbody"||p==="table";if(N){const I=x.getBoundingClientRect();if(I.width<1||I.height<1)return;const $=C&&I.width>0&&I.height>0&&Math.abs(I.width-I.height)<4,D=k?0:$?"50%":Xn(b,x)??8,q=r.width;n.push({x:q>0?+((I.left-r.left)/q*100).toFixed(4):0,y:Math.round(I.top-r.top),w:q>0?+(I.width/q*100).toFixed(4):0,h:Math.round(I.height),r:D});return}if(v){const I=x.getBoundingClientRect();if(I.width>=1&&I.height>=1){const $=k?0:Xn(b,x)??8,D=r.width;n.push({x:D>0?+((I.left-r.left)/D*100).toFixed(4):0,y:Math.round(I.top-r.top),w:D>0?+(I.width/D*100).toFixed(4):0,h:Math.round(I.height),r:$,c:!0})}}for(const I of g)d(I)}for(const x of t.children)d(x);return{name:s,viewportWidth:Math.round(r.width),width:Math.round(r.width),height:Math.round(r.height),bones:n}}function Xn(t,s){const a=parseFloat(t.borderTopLeftRadius)||0,r=parseFloat(t.borderTopRightRadius)||0,n=parseFloat(t.borderBottomRightRadius)||0,o=parseFloat(t.borderBottomLeftRadius)||0;if(a===0&&r===0&&n===0&&o===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,n,o)>9998?i?"50%":9999:a===r&&r===n&&n===o?a!==8?a:void 0:`${a}px ${r}px ${n}px ${o}px`}const Xd=new Map;function Jd(t){return Xd.get(t)}function Zd(){typeof window<"u"&&window.__BONEYARD_BUILD&&(window.__BONEYARD_SNAPSHOT=Kd)}function eu(){return typeof window<"u"&&window.__BONEYARD_BUILD===!0}function tu(t,s){if(!("breakpoints"in t))return t;const a=Object.keys(t.breakpoints).map(Number).sort((n,o)=>n-o);if(a.length===0)return null;const r=[...a].reverse().find(n=>s>=n)??a[0];return t.breakpoints[r]??null}const ys={angle:110,start:30,end:70,speed:"2s",lightHighlight:"#f7f7f7",darkHighlight:"#2c2c2c"},Os={speed:"1.8s",lightAdjust:.3,darkAdjust:.02},Jn={web:{light:"#f0f0f0",dark:"#222222"}},su=/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/;function Zn(t,s){const a=t.match(su);if(a){const[,r,n,o,i="1"]=a,l=Math.min(1,parseFloat(i)+s*.5);return`rgba(${r},${n},${o},${l.toFixed(3)})`}if(t.startsWith("#")&&t.length>=7){const r=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);if(!isNaN(r)&&!isNaN(n)&&!isNaN(o)){const i=Math.round(r+(255-r)*s),l=Math.round(n+(255-n)*s),c=Math.round(o+(255-o)*s);return`#${i.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}}return t}Zd();let Ft={};function va({loading:t,children:s,name:a,initialBones:r,color:n,darkColor:o,animate:i,stagger:l=!1,transition:c=!1,boneClass:d,className:x,fallback:b,fixture:p,snapshotConfig:g}){const C=h.useRef(null),S=h.useRef(Math.random().toString(36).slice(2,8)).current,[N,m]=h.useState(0),[w,y]=h.useState(0),[R,j]=h.useState(!1);h.useEffect(()=>{if(typeof window>"u")return;const f=()=>{const W=document.documentElement.classList.contains("dark")||!!C.current?.closest(".dark");j(W)};f();const T=new MutationObserver(f);T.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const E=window.matchMedia("(prefers-color-scheme: dark)");return E.addEventListener("change",f),()=>{T.disconnect(),E.removeEventListener("change",f)}},[]);const H=n??Ft.color??Jn.web.light,v=o??Ft.darkColor??Jn.web.dark,k=R?v:H,I=i??Ft.animate??"pulse",$=I===!0?"pulse":I===!1?"solid":I;h.useEffect(()=>{const f=C.current;if(!f)return;const T=new ResizeObserver(W=>{const V=W[0]?.contentRect;m(Math.round(V?.width??0)),V&&V.height>0&&y(Math.round(V.height))});T.observe(f);const E=f.getBoundingClientRect();return m(Math.round(E.width)),E.height>0&&y(Math.round(E.height)),()=>T.disconnect()},[]);const D={};if(a&&(D["data-boneyard"]=a,g&&(D["data-boneyard-config"]=JSON.stringify(g))),eu())return e.jsx("div",{ref:C,className:x,style:{position:"relative"},...D,children:e.jsx("div",{children:p??s})});const[q,Q]=h.useState(!1);h.useLayoutEffect(()=>{Q(!0)},[]);const A=r??(a?Jd(a):void 0),U=q&&typeof window<"u"?window.innerWidth:0,ee=N>0?N:U,ie=A&&ee>0?tu(A,ee):null,je=d??Ft.boneClass,ge=(()=>{const f=l??Ft.stagger;return f===!0?80:f===!1||!f?0:f})(),Ce=(()=>{const f=c??Ft.transition;return f===!0?300:f===!1||!f?0:f})(),[de,B]=h.useState(!1),Y=h.useRef(t),ne=h.useRef(null);h.useEffect(()=>(Y.current&&!t&&Ce>0&&ie&&(ne.current&&clearTimeout(ne.current),B(!0),ne.current=setTimeout(()=>{B(!1),ne.current=null},Ce)),Y.current=t,()=>{ne.current&&clearTimeout(ne.current)}),[t,Ce,ie]);const De=(t||de)&&ie,Le=t&&!ie&&!de,Ge=w>0?w:ie?.height??0,O=ie?.height??0,X=Ge>0&&O>0?Ge/O:1;return e.jsxs("div",{ref:C,className:x,style:{position:"relative"},...D,children:[e.jsx("div",{"data-boneyard-content":"true",style:De&&!de?{visibility:"hidden"}:void 0,children:Le?b:s}),De&&e.jsx("div",{"data-boneyard-overlay":"true",style:{position:"absolute",inset:0,overflow:"hidden",opacity:de?0:1,transition:Ce>0?`opacity ${Ce}ms ease-out`:void 0},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ie.bones.filter(f=>!Yn(f).c).map((f,T)=>{const E=Yn(f),W=k;Zn(k,R?Os.darkAdjust:Os.lightAdjust);const V=E.w/100*(ie.width??0),se=E.r==="50%"&&Math.abs(V-E.h)<4,ae={position:"absolute",left:`${E.x}%`,top:E.y*X,width:se?E.h*X:`${E.w}%`,height:E.h*X,borderRadius:typeof E.r=="string"?E.r:`${E.r}px`,backgroundColor:W},z=Ft.speed;if($==="pulse")ae.animation=`bp-${S} ${z??Os.speed} ease-in-out infinite`;else if($==="shimmer"){const oe=R?Ft.darkShimmerColor??ys.darkHighlight:Ft.shimmerColor??ys.lightHighlight,ue=Ft.shimmerAngle??ys.angle;delete ae.backgroundColor,ae.backgroundImage=`linear-gradient(${ue}deg, ${W} ${ys.start}%, ${oe} 50%, ${W} ${ys.end}%)`,ae.backgroundSize="200% 100%",ae.animation=`bs-${S} ${z??ys.speed} linear infinite`}return ge>0&&(ae.opacity=0,ae.animation=`${ae.animation?ae.animation+",":""} by-${S} 0.3s ease-out ${T*ge}ms forwards`),e.jsx("div",{"data-boneyard-bone":"true",className:je,style:ae},T)}),$==="pulse"&&e.jsx("style",{children:`@keyframes bp-${S}{0%,100%{background-color:${k}}50%{background-color:${Zn(k,R?Os.darkAdjust:Os.lightAdjust)}}}`}),$==="shimmer"&&e.jsx("style",{children:`@keyframes bs-${S}{0%{background-position:200% 0}100%{background-position:-200% 0}}`}),ge>0&&e.jsx("style",{children:`@keyframes by-${S}{from{opacity:0}to{opacity:1}}`})]})})]})}const au=({isOpen:t,onClose:s,onViewAll:a})=>{const{notifications:r,markAsRead:n,markAllAsRead:o,unreadCount:i}=Io(),l=r.slice(0,5),c=x=>{switch(x){case"sparkles":case"achievement_unlocked":case"level_up":return e.jsx(ss,{className:"w-4 h-4"});case"alert-circle":case"risk_alert":case"system_alert":return e.jsx(aa,{className:"w-4 h-4"});case"check-circle-2":case"quiz_result":return e.jsx(Ra,{className:"w-4 h-4"});case"users":case"new_assignment":return e.jsx(Rt,{className:"w-4 h-4"});default:return e.jsx(Rs,{className:"w-4 h-4"})}},d=x=>{switch(x){case"sparkles":case"achievement_unlocked":case"level_up":return"from-[#a855f7] to-[#9333ea] text-white bg-purple-50/30";case"alert-circle":case"risk_alert":case"system_alert":return"from-[#f43f5e] to-[#e11d48] text-white bg-rose-50/30";case"check-circle-2":case"quiz_result":return"bg-emerald-50 text-emerald-500 border border-emerald-100";case"users":case"new_assignment":return"bg-blue-50 text-blue-500 border border-blue-100";default:return"bg-slate-50 text-slate-500 border border-slate-100"}};return e.jsx(Bt,{children:t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[90]",onClick:s}),e.jsxs(Pe.div,{initial:{opacity:0,scale:.95,y:-10,x:10},animate:{opacity:1,scale:1,y:0,x:0},exit:{opacity:0,scale:.95,y:-10,x:10},className:"fixed top-[80px] right-[24px] xl:right-[32px] w-[380px] bg-white/95 backdrop-blur-xl rounded-[20px] shadow-[0_8px_32px_rgba(0,0,0,0.12)] border border-white z-[100] flex flex-col overflow-hidden origin-top-right",children:[e.jsxs("div",{className:"p-4 border-b border-[#f1f5f9] flex justify-between items-center bg-white/50",children:[e.jsx("h3",{className:"text-[16px] font-bold text-[#1e293b]",children:"Notifications"}),e.jsxs("button",{onClick:()=>o(),disabled:i===0,className:"text-[12px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors flex items-center gap-1.5 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-[#a855f7]",children:[e.jsx(Ao,{className:"w-3.5 h-3.5"})," Mark all as read"]})]}),e.jsx("div",{className:"max-h-[360px] overflow-y-auto no-scrollbar flex flex-col divide-y divide-[#f1f5f9]",children:l.length>0?l.map(x=>e.jsxs("div",{onClick:()=>{n(x.id)},className:`p-4 hover:bg-slate-50 transition-colors cursor-pointer flex gap-3 ${x.isRead?"opacity-70":d(x.type).split(" ")[2]}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 shadow-sm ${d(x.type).split(" ").slice(0,2).join(" ")}`,children:c(x.type)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between items-start mb-0.5",children:[e.jsx("h4",{className:"text-[13px] font-bold text-[#1e293b]",children:x.title}),!x.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#a855f7] shadow-[0_0_4px_rgba(168,85,247,0.6)] mt-1"})]}),e.jsx("p",{className:"text-[12px] text-[#475569] line-clamp-2 leading-relaxed",children:x.message}),e.jsxs("span",{className:`text-[10px] font-bold mt-1 block ${x.isRead?"text-[#94a3b8]":"text-[#a855f7]"}`,children:[Fo(x.createdAt)," ago"]})]})]},x.id)):e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Rs,{className:"w-8 h-8 text-[#94a3b8] mx-auto mb-2 opacity-20"}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:"No new notifications"})]})}),e.jsx("div",{className:"p-3 border-t border-[#f1f5f9] bg-white",children:e.jsxs("button",{onClick:()=>{a(),s()},className:"w-full py-2 bg-purple-50 text-[#9333ea] hover:bg-purple-100 transition-colors rounded-xl text-[13px] font-bold flex items-center justify-center gap-2",children:["View All Notifications ",e.jsx(cl,{className:"w-4 h-4"})]})})]})]})})};async function Rr(t){const s=Xt(st,"managedStudents");try{const o=Ht(s,Gt("teacherId","==",t)),i=await ts(o);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 Ti(t)).map(o=>o.id);if(r.length===0)return[];const n=new Map;for(let o=0;o{n.set(d.id,{id:d.id,...d.data()})})}return Array.from(n.values()).sort((o,i)=>String(o.name||"").localeCompare(String(i.name||"")))}async function ru(t,s,a){const r=vt(st,"managedStudents",t);await Kt(r,{riskLevel:s,...a!==void 0?{riskConfidence:a}:{},updatedAt:ft()})}async function Ci(t,s,a){const r=zt(s,a),n=vt(st,"managedStudents",t);await Kt(n,{grade:s,section:a,classSectionId:r,updatedAt:ft()})}function zt(t,s){return[t,s].filter(Boolean).join("_").replace(/\s+/g,"_").toLowerCase()}function xr(t){const s=Object.entries(t).filter(([,a])=>a!==void 0);return Object.fromEntries(s)}function ws(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 As(t){const a=ws(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 Ds(t,s){const a=`${t||""} ${s||""}`.toUpperCase();if(!a.trim())return null;const r=["STEM","ABM","HUMSS","GAS","TVL","ICT"];for(const n of r)if(new RegExp(`\\b${n}\\b`).test(a))return n;return null}function Pt(t){const s=(t||"").trim();if(!s)return{grade:"Grade 11",section:"Section A"};const[a="Grade 11",r="Section A"]=s.split(" - ").map(n=>n.trim());return{grade:a||"Grade 11",section:r||"Section A"}}function mt(t){const s=t.metadata||{},a=t.className||s.className,r=Pt(a),n=(t.grade||s.grade||r.grade||"").trim()||null,o=(t.section||s.section||r.section||"").trim()||null,i=(t.classSectionId||s.classSectionId||"").trim()||(n&&o?zt(n,o):"")||null,l=(a||"").trim()||(n&&o?`${n} - ${o}`:"")||null,c=ws(t.gradeLevel||s.gradeLevel||n),d=(t.classification||s.classification||"").trim()||As(c)||null,x=(t.strand||s.strand||"").trim()||Ds(l,o)||null;return{classSectionId:i,className:l,grade:n,section:o,gradeLevel:c,classification:d,strand:x,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 nu(t){const s=(t.className||"").trim(),[a="",r=""]=s.split(" - "),n=(t.grade||a||"").trim()||null,o=(t.section||r||"").trim()||null,i=(t.classSectionId||"").trim()||(n&&o?zt(n,o):"")||null,l=s||(n&&o?`${n} - ${o}`:null),c=ws(t.gradeLevel||n),d=(t.classification||"").trim()||As(c),x=(t.strand||"").trim()||Ds(l,o);return{classSectionId:i,className:l,grade:n,section:o,gradeLevel:c,classification:d,strand:x,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 Ti(t){const s=Xt(st,"classrooms"),a=new Map,r=Ht(s,Gt("teacherId","==",t));(await ts(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const o=Ht(s,Gt("managerId","==",t));return(await ts(o)).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 Ii(t){const s=t.classSectionId||zt(t.grade,t.section),a=vt(st,"classSectionOwnership",s),r=await Cs(a),n=r.exists()?r.data().studentUids||[]:[],o=Array.from(new Set([...t.studentUids||[],...n])),i=xr(t);return r.exists()?await Kt(a,{...i,classSectionId:s,studentUids:o,updatedAt:ft()}):await Zt(a,{...i,classSectionId:s,studentUids:o,createdAt:ft(),updatedAt:ft()}),s}async function ou(t){const s=(t.classSectionId||"").trim()||zt(t.grade,t.section),a=(t.className||"").trim()||`${t.grade} - ${t.section}`,r=nu({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 Ii({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 n=Xt(st,"classrooms"),o=Ht(n,Gt("classSectionId","==",s)),i=await ts(o);if(i.empty){const l=xr({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:ft(),updatedAt:ft()});await Zt(vt(st,"classrooms",s),l,{merge:!0})}else for(const l of i.docs){const c=xr({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:ft()});await Kt(l.ref,c)}return s}async function Ei(t,s,a,r,n,o){const i=zt(s,a);await Ii({classSectionId:i,grade:s,section:a,schoolYear:n,ownerTeacherId:r,ownerTeacherName:o,studentUids:[t]}),await Zt(vt(st,"users",t),{grade:s,section:a,classSectionId:i,adviserTeacherId:r,adviserTeacherName:o||"",updatedAt:ft()},{merge:!0})}async function iu(t){const s=Xt(st,"classSectionOwnership"),a=new Map,r=Ht(s,Gt("ownerTeacherId","==",t));(await ts(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const o=Ht(s,Gt("managerId","==",t));return(await ts(o)).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 lu(t="",s=25){const a=Xt(st,"users"),r=Math.max(1,Math.min(100,s)),n=Ht(a,Gt("role","==","teacher"),zo(r*4)),o=await ts(n),i=t.trim().toLowerCase();return o.docs.map(c=>{const d=c.data(),x=String(d.name||"").trim(),b=String(d.email||"").trim();return{uid:c.id,name:x||"Teacher",email:b,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 cu(t,s,a=20){if(t.length===0)return s([]),()=>{};const r=Xt(st,"activities"),n=Ht(r,Gt("classroomId","in",t),bl("timestamp","desc"));return Lo(n,o=>{const i=o.docs.slice(0,a).map(l=>({id:l.id,...l.data()}));s(i)})}async function du(t,s,a){const r=vt(Xt(st,"generatedLessonPlans"));return await Zt(r,{...t,teacherId:s,teacherName:a?.teacherName||null,studentId:a?.studentId||null,studentName:a?.studentName||null,status:"draft",createdAt:ft(),updatedAt:ft()}),r.id}async function uu(t){const s=vt(st,"generatedLessonPlans",t),a=await Cs(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 Kt(s,{status:"published",publishedAt:ft(),updatedAt:ft()})}async function mu(t,s=!0){const a=t.learningCompetency||t.lessonTitle||t.focusTopics&&t.focusTopics[0]||"general mathematics",r=t.subject||"general_math",n=t.quarter??1;let o="",i=[],l,c,d,x=!1;if(s)try{const g=await dl(a,r,n,{lessonTitle:t.lessonTitle,learningCompetency:t.learningCompetency,moduleUnit:t.moduleUnit,learnerLevel:t.learnerLevel});i=g.sources||[],o=g.explanation||"",l=g.retrievalConfidence,c=g.retrievalBand,d=g.retrievalQuery,x=g.needsReview??!1}catch{o="",i=[]}const b={...t,subject:r,quarter:n,curriculumContext:o?`[CURRICULUM CONTEXT] -${o}`:void 0,curriculumRetrievalConfidence:l,curriculumRetrievalBand:c,curriculumRetrievalQuery:d,needsReview:x};return{...await Ze.generateLessonPlan(b),curriculumSources:i,curriculumContext:o}}const xu=ol("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 pu({className:t,variant:s,asChild:a=!1,...r}){const n=a?_l:"span";return e.jsx(n,{"data-slot":"badge",className:Eo(xu({variant:s}),t),...r})}function hu(t){return t.length<=42?t:`${t.slice(0,18)}...${t.slice(-20)}`}const eo=({sources:t=[],className:s})=>t.length?e.jsxs(Rl,{children:[e.jsx(Ml,{asChild:!0,children:e.jsxs(pu,{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(Lt,{size:12}),"DepEd Aligned"]})}),e.jsxs(zl,{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:[hu(a.sourceFile)," | p.",a.page]}),e.jsxs("p",{className:"text-[#5a6578]",children:["Similarity: ",(a.score*100).toFixed(1),"%"]})]},`${a.sourceFile}-${a.page}-${r}`))})]})]}):null,fu=[{level:"Remember",icon:ar,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:Lt,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:ul,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:ec,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"}],gu=({isOpen:t,onClose:s})=>t?e.jsx(Bt,{children:t&&e.jsx(Pe.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(Pe.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(_o,{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(ps,{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:fu.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(nc,{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,bu={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"},xa={identification:{label:"Identification",icon:e.jsx(Wt,{size:16}),description:"Define or identify concepts"},enumeration:{label:"Enumeration",icon:e.jsx(ya,{size:16}),description:"List steps or properties"},multiple_choice:{label:"Multiple Choice",icon:e.jsx(Ut,{size:16}),description:"Choose from 4 options"},word_problem:{label:"Word Problem",icon:e.jsx(Lt,{size:16}),description:"Real-world scenarios"},equation_based:{label:"Equation-Based",icon:e.jsx(ml,{size:16}),description:"Solve equations"}},to={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"}},vu=["Grade 11","Grade 12"],Ka=t=>{const s=(t||"").trim().toLowerCase();return s==="grade 12"||s==="12"||s.includes("12")?"Grade 12":"Grade 11"},wu={"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"]}},Nu={"Grade 11":["General Mathematics - "],"Grade 12":["Pre-Calculus - ","Basic Calculus - "]},so=(t,s)=>{const a=Nu[s];return Object.fromEntries(Object.entries(t).filter(([r])=>a.some(n=>r.startsWith(n))))},Bs=30,Ps=12,Xa="mathpulse:quiz-maker:active-task",ju={easy:"text-green-600",medium:"text-rose-600",hard:"text-red-600"},_i=({onBack:t,gradeLevel:s,selectedClassId:a,selectedClassName:r,onOpenNotifications:n,onOpenProfile:o,onOpenInsightModal:i,userPhoto:l,teacherName:c,drawerMode:d=!1,onQuizSaved:x,onQuizGenerating:b})=>{const{currentUser:p,loading:g}=gs(),C=h.useMemo(()=>Ze.getImportGroundedRolloutFlags(),[]),[S,N]=h.useState("create"),[m,w]=h.useState("setup"),[y,R]=h.useState(Ka(s)),[j,H]=h.useState(10),[v,k]=h.useState([]),[I,$]=h.useState([]),[D,q]=h.useState(["multiple_choice","word_problem","identification"]),[Q,A]=h.useState(["remember","understand","apply","analyze"]),[U,ee]=h.useState(!1),[ie,je]=h.useState({easy:30,medium:50,hard:20}),[ge,Ce]=h.useState({}),[de,B]=h.useState(!1),[Y,ne]=h.useState([]),[De,Le]=h.useState(!1),[Ge,O]=h.useState(""),[X,f]=h.useState(!1),[T,E]=h.useState(!1),[W,V]=h.useState(null),[se,ae]=h.useState(0),[z,oe]=h.useState("queued"),[ue,ve]=h.useState("Waiting to start generation..."),[K,we]=h.useState(null),[We,Se]=h.useState(null),[Je,et]=h.useState(""),[F,Z]=h.useState(!1),Re=h.useRef(!1),[Ne,M]=h.useState("topics"),[te,_e]=h.useState(null),[Fe,be]=h.useState(!1),[ot,gt]=h.useState("all"),[Dt,Ns]=h.useState("all"),[J,xe]=h.useState(!1),[Ue,Ee]=h.useState(null),[lt,wt]=h.useState(!1),[Bi,Fs]=h.useState(!1),[Aa,Ar]=h.useState(!1),[Dr,Pi]=h.useState([]),[Hi,Fr]=h.useState(!1),[Da,$r]=h.useState(""),[cs,Or]=h.useState(null),[Br,$s]=h.useState([]),[Gi,Pr]=h.useState(!1),[Fa,Qi]=h.useState("all"),[Vi,Hr]=h.useState(null),[Gr,ca]=h.useState(null),Qr=h.useCallback(async()=>{B(!0);const u=Ka(y);try{const _=await Ze.getQuizTopics(u);_.topics&&Ce(so(_.topics,u))}catch{Ce(so(wu[u],u))}finally{B(!1)}},[y]),Vr=h.useCallback(async()=>{if(!C.quizEnabled){ne([]),O("Import-grounded quiz generation is disabled by rollout flag; using curriculum defaults."),Le(!1);return}Le(!0),O("");try{const u=await Ze.getCourseMaterialTopics({classSectionId:a,limit:20}),_=(u.topics||[]).filter(L=>L.title?.trim());ne(_),u.warnings&&u.warnings.length>0&&O(u.warnings.join(" "))}catch{ne([]),O("Imported topics are currently unavailable; quiz generation will use curriculum defaults.")}finally{Le(!1)}},[a,C.quizEnabled]);h.useEffect(()=>{Qr(),k([]),$([])},[Qr]),h.useEffect(()=>{Vr()},[Vr]);const $a=h.useMemo(()=>{const u=Array.from(new Set(Y.map(_=>_.title.trim()).filter(Boolean)));return u.length===0?ge:{"Imported Course Materials":u,...ge}},[ge,Y]);h.useEffect(()=>{gt("all"),Ns("all")},[K]);const Ur=h.useMemo(()=>{if(!K)return[];const u=K.questions.map(L=>L.provenance?.sourceFile?.trim()).filter(L=>!!L),_=(K.metadata.topicProvenance||[]).map(L=>L.sourceFile?.trim()).filter(L=>!!L);return Array.from(new Set([...u,..._])).sort((L,pe)=>L.localeCompare(pe))},[K]),Wr=h.useMemo(()=>{if(!K)return[];const u=K.questions.map(L=>L.provenance?.materialId?.trim()).filter(L=>!!L),_=(K.metadata.topicProvenance||[]).map(L=>L.materialId?.trim()).filter(L=>!!L);return Array.from(new Set([...u,..._])).sort((L,pe)=>L.localeCompare(pe))},[K]),Oa=h.useMemo(()=>K?K.questions.filter(u=>{const _=ot==="all"||(u.provenance?.sourceFile||"").trim()===ot,L=Dt==="all"||(u.provenance?.materialId||"").trim()===Dt;return _&&L}):[],[K,ot,Dt]),qr=(u,_)=>{const L={...ie},pe=Math.max(0,Math.min(100,L[u]+_)),$e=pe-L[u];L[u]=pe;const Qe=Object.keys(L).filter(tt=>tt!==u),yt=Qe.reduce((tt,It)=>tt+L[It],0);if(yt>0)for(const tt of Qe)L[tt]=Math.max(0,Math.round(L[tt]-$e*L[tt]/yt));const js=Object.values(L).reduce((tt,It)=>tt+It,0);if(js!==100){const tt=Qe.reduce((It,an)=>L[It]>=L[an]?It:an);L[tt]+=100-js}je(L)},Ui=u=>{k(_=>_.includes(u)?_.filter(L=>L!==u):[..._,u]),$(_=>_.filter(L=>L!==u))},Wi=u=>{q(_=>_.includes(u)?_.length>1?_.filter(L=>L!==u):_:[..._,u])},qi=u=>{A(_=>_.includes(u)?_.length>1?_.filter(L=>L!==u):_:[..._,u])},Yi=()=>{let u=v.length>0?v.filter(L=>!I.includes(L)):Object.values($a).flat().filter(L=>!I.includes(L)).slice(0,3);u.length>Ps&&(u=u.slice(0,Ps));const _=Math.min(j,Bs);return{topics:u,gradeLevel:y,numQuestions:_,questionTypes:D,includeGraphs:U,difficultyDistribution:ie,bloomLevels:Q,excludeTopics:I,classSectionId:a,className:r,preferImportedTopics:C.quizEnabled}},Ki=h.useCallback((u,_)=>{const L={taskId:u,request:_,createdAt:new Date().toISOString(),ownerUid:p?.uid};try{sessionStorage.setItem(Xa,JSON.stringify(L))}catch{}},[p]),Vt=h.useCallback(()=>{try{sessionStorage.removeItem(Xa)}catch{}},[]),Ba=h.useCallback(u=>{const _=Math.max(0,Math.min(100,Math.round(typeof u.progressPercent=="number"?u.progressPercent:u.status==="queued"?10:u.status==="running"?65:u.status==="completed"?100:u.status==="cancelling"?95:100)));ae(L=>{let pe=Math.max(L,_);if(u.status==="running"&&_<=L){const $e=String(u.progressStage||"").toLowerCase(),Qe=$e.includes("assembling")||$e.includes("final")?97:$e.includes("generating")?89:95;pe=Math.min(Qe,L+1)}return pe}),oe(u.progressStage||u.status),ve(u.progressMessage||(u.status==="queued"?"Task queued for generation.":u.status==="running"?"Generating quiz in the background...":u.status==="completed"?"Generation complete.":u.status==="cancelling"?"Cancelling generation...":"Generation finished with an error."))},[]);h.useEffect(()=>{if(g||Re.current)return;if(Re.current=!0,!p){Vt();return}let u=!1;const _=sessionStorage.getItem(Xa);if(!_)return;let L=null;try{L=JSON.parse(_)}catch{Vt();return}if(!L?.taskId){Vt();return}if(L.ownerUid&&L.ownerUid!==p.uid){Vt();return}return f(!0),V(L.taskId),et(""),Ze.waitForTaskResult(L.taskId,{timeoutMs:24e4,pollIntervalMs:1500,onProgress:Ba}).then(async pe=>{if(u)return;const $e=pe.result;if(!$e||typeof $e!="object")throw new Error("Quiz generation completed without a valid result payload.");const Qe=$e;we(Qe),w("results"),ae(100),oe("completed"),ve("Generation complete."),V(null),Vt();try{await Jr(Qe,L.request),me.success("Quiz auto-saved to your library as draft.")}catch(yt){me.error(yt instanceof Error?yt.message:"Quiz generated but failed to save to library")}}).catch(pe=>{if(!u){if(pe instanceof ja&&(pe.status===401||pe.status===403)){Re.current=!1,f(!1);return}et(pe instanceof Error?pe.message:"Failed to resume quiz generation"),V(null),Vt()}}).finally(()=>{u||f(!1)}),()=>{u=!0}},[Ba,g,Vt,p]);const Yr=()=>{if(X){window.confirm("Quiz generation is in progress. Are you sure you want to leave?")&&(w("setup"),we(null),et(""),t());return}w("setup"),we(null),et(""),t()},Xi=async()=>{b?.(),et(""),f(!0),ca(null),ae(8),oe("queued"),ve("Submitting quiz generation task..."),we(null);const u=Yi();try{const _=await Ze.generateQuiz(u,{onTaskCreated:L=>{V(L),Ki(L,u),ae(pe=>Math.max(pe,12)),oe("queued"),ve("Task queued. Generation is running in the background.")},onProgress:L=>{Ba(L),L.taskId&&L.taskId!==W&&V(L.taskId)}});we(_),w("results"),ae(100),oe("completed"),ve("Generation complete."),V(null),Vt();try{await Jr(_,u),me.success("Quiz auto-saved to your library as draft.")}catch(L){me.error(L instanceof Error?L.message:"Quiz generated but failed to save to library")}Ze.reportImportGroundedFeedback({flow:"quiz",status:"success",classSectionId:u.classSectionId,className:u.className,metadata:{totalQuestions:_.metadata.totalQuestions,usedImportedTopics:!!_.metadata.usedImportedTopics,importedTopicCount:_.metadata.importedTopicCount??0,importGroundingEnabled:C.quizEnabled}})}catch(_){et(_ instanceof Error?_.message:"Quiz generation failed"),ae(100),oe("failed"),ve("Generation failed."),V(null),Vt(),Ze.reportImportGroundedFeedback({flow:"quiz",status:"failed",classSectionId:u.classSectionId,className:u.className,metadata:{error:_ instanceof Error?_.message:"Quiz generation failed",importGroundingEnabled:C.quizEnabled}})}finally{f(!1)}},Ji=()=>{if(!K)return;const u=K.questions.map((_,L)=>{let pe=`${L+1}. [${_.difficulty.toUpperCase()}] [${_.bloomLevel}] (${_.points} pts) -`;return pe+=` ${_.question} -`,_.options&&(pe+=_.options.map($e=>` ${$e}`).join(` -`)+` -`),pe+=` Answer: ${_.correctAnswer} -`,pe+=` Explanation: ${_.explanation} -`,pe}).join(` -`);navigator.clipboard.writeText(u),Z(!0),setTimeout(()=>Z(!1),2e3)},Zi=()=>{if(!K)return;const u=new Blob([JSON.stringify(K,null,2)],{type:"application/json"}),_=URL.createObjectURL(u),L=document.createElement("a");L.href=_,L.download=`quiz_${y.replace(/\s/g,"_")}_${Date.now()}.json`,L.click(),URL.revokeObjectURL(_)};v.length>0||Object.values($a).flat().length>0;const Kr=(u,_)=>{const L=_?.gradeLevel||y,pe=_?.topics||v,$e=u.questions.map((Qe,yt)=>({id:`q_${Date.now()}_${yt}`,questionType:Qe.questionType||"identification",question:Qe.question,...Qe.options?{options:Qe.options}:{},correctAnswer:Qe.correctAnswer,bloomLevel:Qe.bloomLevel||"understand",difficulty:Qe.difficulty||"medium",topic:Qe.topic,subject:L,points:Qe.points,explanation:Qe.explanation}));return{title:`${L} Quiz – ${pe.length>0?pe.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:L,questions:$e,totalPoints:u.totalPoints,metadata:{topicsCovered:Object.keys(u.metadata.topicsCovered),difficultyBreakdown:{easy:u.metadata.difficultyBreakdown.easy??0,medium:u.metadata.difficultyBreakdown.medium??0,hard:u.metadata.difficultyBreakdown.hard??0},bloomDistribution:u.metadata.bloomTaxonomyDistribution,questionTypeBreakdown:u.metadata.questionTypeBreakdown,supplementalPurpose:u.metadata.supplementalPurpose,recommendedTeacherActions:u.metadata.recommendedTeacherActions??[],generatedAt:new Date().toISOString(),generatedBy:"teacher_generated"},status:"draft",source:"teacher_generated"}},Xr=h.useCallback(u=>{$s(_=>[u,..._.filter(L=>L.id!==u.id)])},[]);async function Jr(u,_){if(!p)return null;const L=Kr(u,_),pe=await dn(L,p.uid,Ue?{documentId:Ue}:void 0);return Ee(pe),Xr({id:pe,...L,teacherId:p.uid}),pe}const el=async()=>{if(!K){me.error("No quiz to save. Generate a quiz first.");return}if(!p){me.error("You must be signed in to save quizzes.");return}xe(!0);try{const u=Kr(K),_=await dn(u,p.uid,Ue?{documentId:Ue}:void 0);Ee(_),Xr({id:_,...u,teacherId:p.uid}),me.success("Quiz saved to your library!"),x?.(_)}catch(u){me.error(u instanceof Error?u.message:"Failed to save quiz")}finally{xe(!1)}},tl=async()=>{if(Ue){wt(!0);try{await Cl(Ue),$s(u=>u.map(_=>_.id===Ue?{..._,status:"published"}:_)),me.success("Quiz published to Quiz Bank!")}catch(u){me.error(u instanceof Error?u.message:"Failed to publish quiz")}finally{wt(!1)}}},Pa=async u=>{const _=u??Ue;if(!_){me.error("Save the quiz first before assigning.");return}if(Hr(_),Fs(!0),Or(null),$r(""),Dr.length===0&&p){Fr(!0);try{const L=await Rr(p.uid);Pi(L)}catch{me.error("Failed to load students")}finally{Fr(!1)}}},sl=async()=>{const u=Vi??Ue;if(!(!cs||!u||!p)){Ar(!0);try{await Tl(u,cs,p.uid),$s(_=>_.map(L=>L.id===u?{...L,status:"assigned",metadata:{...L.metadata,assignedTo:cs}}:L)),me.success("Quiz assigned to student!"),Fs(!1),Hr(null),S==="bank"&&Ha()}catch(_){me.error(_ instanceof Error?_.message:"Failed to assign quiz")}finally{Ar(!1)}}},Ha=h.useCallback(async()=>{if(p){Pr(!0);try{const u=await $o(p.uid);$s(u)}catch{me.error("Failed to load quiz bank")}finally{Pr(!1)}}},[p]);h.useEffect(()=>{S==="bank"&&Ha()},[S,Ha]);const al=async u=>{try{await kl(u),$s(_=>_.filter(L=>L.id!==u)),me.success("Quiz deleted")}catch{me.error("Failed to delete quiz")}},Zr=Dr.filter(u=>u.name.toLowerCase().includes(Da.toLowerCase())||u.email.toLowerCase().includes(Da.toLowerCase())),en=Fa==="all"?Br:Br.filter(u=>u.status===Fa),rl=u=>{const _=(u.metadata.topicsCovered||[]).reduce((L,pe)=>(L[pe]=(L[pe]||0)+1,L),{});return{questions:u.questions.map(L=>({questionType:L.questionType,question:L.question,correctAnswer:L.correctAnswer,options:L.options??null,bloomLevel:L.bloomLevel,difficulty:L.difficulty,topic:L.topic,points:L.points,explanation:L.explanation})),totalPoints:u.totalPoints,metadata:{topicsCovered:_,difficultyBreakdown:u.metadata.difficultyBreakdown,bloomTaxonomyDistribution:u.metadata.bloomDistribution,questionTypeBreakdown:u.metadata.questionTypeBreakdown,gradeLevel:u.gradeLevel,totalQuestions:u.questions.length,includesGraphQuestions:!1,supplementalPurpose:u.metadata.supplementalPurpose,bloomTaxonomyRationale:"Loaded from saved quiz bank entry.",recommendedTeacherActions:u.metadata.recommendedTeacherActions||[]}}},Ga=u=>{Ee(u.id),we(rl(u)),Se(null),ca(u.id),gt("all"),Ns("all"),_e(null),w("results"),N("create")},tn={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"}},nl=(u,_,L)=>{const pe=te===_,$e=tn[u.bloomLevel?.toLowerCase()]||tn.remember,Qe=u.bloomLevel?.toLowerCase()==="remember"?"hover:border-purple-200":u.bloomLevel?.toLowerCase()==="understand"?"hover:border-blue-200":u.bloomLevel?.toLowerCase()==="apply"?"hover:border-amber-200":"hover:border-slate-200";return e.jsxs(Pe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:_*.05},className:`border border-[#e2e8f0] rounded-[20px] overflow-hidden bg-white shadow-sm hover:shadow-md ${Qe} 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:()=>_e(pe?null:_),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 ${$e.card} text-white flex items-center justify-center font-bold text-[13px] shadow-sm`,children:["Q",_+1]}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${$e.badge}`,children:u.bloomLevel}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${u.difficulty==="easy"?"border-emerald-200 text-emerald-700 bg-emerald-50":u.difficulty==="hard"?"border-rose-200 text-rose-700 bg-rose-50":"border-amber-200 text-amber-700 bg-amber-50"}`,children:u.difficulty}),e.jsxs("span",{className:"text-[12px] font-bold text-[#64748b] bg-slate-100 px-2 py-1 rounded-md",children:[u.points," pts"]}),u.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:u.topic})]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b] pr-4 leading-relaxed",children:u.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 ${$e.badge}`,children:u.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:pe?e.jsx(ka,{size:16,className:"text-[#64748b] transition-transform duration-300"}):e.jsx(_t,{size:16,className:"text-[#64748b]"})})]})]}),e.jsx(Bt,{children:pe&&e.jsx(Pe.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"}),u.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:u.options.map((yt,js)=>{const tt=yt.includes(u.correctAnswer);return e.jsxs("div",{className:`rounded-[12px] p-4 text-[14px] font-medium transition-all cursor-pointer relative overflow-hidden ${tt?"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:[tt&&e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-500"}),e.jsx("span",{className:tt?"pl-2":"",children:yt}),tt&&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(Ut,{size:13})})]},js)})})]}),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(Ra,{size:14})," Correct Answer"]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b]",children:u.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(ss,{size:14})," AI Explanation"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed font-medium",children:u.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(Wt,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Type:"})," ",xa[u.questionType]?.label||u.questionType]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ar,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Bloom:"})," ",u.bloomLevel]})]})]})})})]},_)},sn=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:()=>N("create"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${S==="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(or,{size:16})," Create Quiz"]}),e.jsxs("button",{onClick:()=>N("bank"),className:`px-6 py-2 rounded-full text-[13px] font-bold flex items-center gap-2 transition-all duration-300 ease-out ${S==="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(Ca,{size:16})," Quiz Bank"]})]})}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] flex-1",children:[S==="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(u=>e.jsx("button",{onClick:()=>Qi(u),className:`px-5 py-2 text-[13px] font-bold rounded-full whitespace-nowrap transition-all duration-300 mb-4 capitalize ${Fa===u?"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:u==="all"?"All":u.charAt(0).toUpperCase()+u.slice(1)},u))}),Gi?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(ct,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):en.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(Ca,{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:en.map(u=>e.jsxs(Pe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>Ga(u),role:"button",tabIndex:0,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),Ga(u))},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] ${u.status==="assigned"||u.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 ${u.status==="assigned"||u.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 ${u.status==="assigned"||u.status==="published"?"group-hover:text-[#9333ea]":"group-hover:text-slate-700"}`,children:u.title}),e.jsx("span",{className:`px-2.5 py-1 rounded-[6px] text-[10px] font-bold uppercase tracking-wider shrink-0 shadow-sm ${bu[u.status]}`,children:u.status})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-5 pl-3",children:u.metadata.topicsCovered.slice(0,3).map(_=>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:_},_))}),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(Ll,{size:14})," ",u.questions.length," questions"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ro,{size:14})," ",u.totalPoints," pts"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Rt,{size:14})," ",u.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:_=>{_.stopPropagation(),Ga(u)},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(Al,{size:14})," View"]}),e.jsxs("button",{onClick:_=>{_.stopPropagation(),Pa(u.id)},className:"flex items-center gap-1.5 text-[13px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors",children:[e.jsx(da,{size:14})," Assign"]}),e.jsxs("button",{onClick:_=>{_.stopPropagation(),al(u.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(Oo,{size:14})," Delete"]})]})]},u.id))})]}),S==="create"&&e.jsxs(e.Fragment,{children:[Je&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-4",children:e.jsxs(Pe.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(aa,{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:Je})]}),e.jsx("button",{onClick:()=>et(""),className:"ml-auto",children:e.jsx(ps,{size:14,className:"text-red-400"})})]})}),X&&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(ct,{size:20,className:"animate-spin text-[#a855f7]"}),"Generating Quiz in Background"]}),e.jsxs("span",{className:"text-[14px] font-extrabold text-[#9333ea]",children:[se,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 h-2.5 rounded-full overflow-hidden mb-6",children:e.jsx(Pe.div,{animate:{width:`${se}%`},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:z.replace(/_/g," ")})]}),e.jsx("p",{children:ue}),W&&e.jsxs("p",{className:"text-[11px] mt-3 opacity-60 font-mono",children:["Task ID: ",W]})]})]}),e.jsxs("p",{className:"mt-8 text-[14px] font-medium text-[#64748b] flex items-center gap-2 animate-pulse",children:[e.jsx(ct,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})]}),!X&&m!=="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((u,_)=>{const pe=["setup","topics","style","preview"].indexOf(m),$e=pe>_,Qe=pe===_;return e.jsxs("div",{className:`flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl transition-all duration-500 ${Qe?"bg-purple-50/80 shadow-[0_1px_3px_rgba(168,85,247,0.1)]":$e?"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 ${Qe?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":$e?"bg-emerald-500 text-white shadow-sm":"bg-slate-100 text-[#64748b]"}`,children:$e?e.jsx(Ut,{size:13,strokeWidth:3}):_+1}),e.jsx("span",{className:`text-[13px] font-bold whitespace-nowrap ${Qe?"text-[#9333ea]":$e?"text-[#1e293b]":"text-[#64748b]"}`,children:u.label})]},u.id)})})}),m==="setup"&&!X&&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(Us,{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 ",Bs," questions and ",Ps," 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:y,onChange:u=>R(Ka(u.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:vu.map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx(_t,{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:()=>H(Math.max(1,j-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(un,{size:16})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:Bs,value:j,onChange:u=>H(Math.min(Bs,Math.max(1,parseInt(u.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:()=>H(Math.min(Bs,j+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(rr,{size:16})})]})]})]})]})]}),m==="topics"&&!X&&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 ",Ps," 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(u=>!I.includes(u)).length," of ",Ps," selected"]})]})]}),de?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(ct,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries($a).map(([u,_])=>{const L=_.filter($e=>v.includes($e)&&!I.includes($e)).length,pe=Ne===u;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>M(pe?null:u),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:u}),e.jsxs("p",{className:"text-xs text-slate-500",children:[_.length," topics"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"bg-purple-100 text-[#9b51e0] px-2.5 py-0.5 rounded-full text-xs font-semibold",children:[L," selected"]}),pe?e.jsx(ka,{size:18,className:"text-slate-400"}):e.jsx(_t,{size:18,className:"text-slate-400"})]})]}),e.jsx(Bt,{children:pe&&e.jsx(Pe.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:_.map(($e,Qe)=>{const yt=v.includes($e),js=I.includes($e),tt=yt&&!js;let It="Core";return Qe%3===0&&(It="Foundation"),Qe%3===2&&(It="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 ${tt?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:tt&&e.jsx(Ut,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:tt,onChange:()=>Ui($e)}),e.jsx("span",{className:`text-sm font-semibold ${tt?"text-[#0a1628]":"text-[#5a6578]"}`,children:$e})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${It==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:It})]},$e)})})})})]},u)})})]}),m==="style"&&!X&&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(xa).map(([u,_])=>{const L=D.includes(u);return e.jsxs("button",{onClick:()=>Wi(u),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 ${L?"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:[L&&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(Ut,{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 ${L?"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:L?"text-[#a855f7]":"text-slate-500",children:_.icon})}),e.jsx("span",{className:`font-bold text-[12px] leading-tight ${L?"text-[#9333ea]":"text-slate-700"}`,children:_.label})]},u)})})]}),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(to).map(([u,_])=>{const L=Q.includes(u);return e.jsx("button",{onClick:()=>qi(u),className:`px-6 py-2.5 rounded-full border-2 font-bold text-[13px] transition-all duration-200 hover:-translate-y-0.5 capitalize ${L?"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:u},u)})})]}),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(ie).map(([u,_])=>{const L={easy:"bg-emerald-400",medium:"bg-amber-400",hard:"bg-rose-400"},pe={easy:"text-emerald-600",medium:"text-amber-500",hard:"text-rose-500"},$e={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:${pe[u]} transition-colors`,children:u}),e.jsx("div",{className:"flex-1 bg-slate-100 h-3 rounded-full overflow-hidden shadow-inner",children:e.jsx(Pe.div,{animate:{width:`${_}%`},className:`h-full rounded-full transition-all duration-500 ease-out ${L[u]}`})}),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 ${$e[u]}`,children:[e.jsx("button",{onClick:()=>qr(u,-5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${pe[u]} rounded-lg transition-colors`,children:e.jsx(un,{className:"w-3.5 h-3.5"})}),e.jsx("input",{type:"text",value:`${_}%`,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:()=>qr(u,5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${pe[u]} rounded-lg transition-colors`,children:e.jsx(rr,{className:"w-3.5 h-3.5"})})]})]},u)})})]})]}),m==="preview"&&!X&&!K&&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(hs,{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:j},{label:"Topics",value:v.filter(u=>!I.includes(u)).length},{label:"Level",value:y.replace("Grade ","Gr. ")}].map(u=>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:u.value}),e.jsx("span",{className:"text-[13px] font-bold text-[#64748b] relative z-10",children:u.label})]},u.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(Us,{size:18,className:"text-[#94a3b8] shrink-0 mt-0.5"}),e.jsxs("p",{children:[D.map(u=>xa[u]?.label).join(" and ")," questions across"," ",e.jsxs("span",{className:"font-bold text-[#1e293b]",children:[v.filter(u=>!I.includes(u)).length," topics"]})," ","— aligned to ",e.jsx("span",{className:"font-semibold",children:Q.map(u=>to[u]?.label).join(", ")})," levels of Bloom's Taxonomy."," ",e.jsxs("span",{className:"font-semibold text-emerald-600",children:["Easy ",ie.easy,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-amber-500",children:["Medium ",ie.medium,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-rose-500",children:["Hard ",ie.hard,"%"]}),"."]})]})]})}),m==="results"&&K&&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:Ji,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:[F?e.jsx(Ut,{size:14,className:"text-green-500"}):e.jsx(Ol,{size:14}),F?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:Zi,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(Bl,{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(Wt,{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:K.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(Yt,{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:K.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(Lt,{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(K.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(ya,{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(K.metadata.bloomTaxonomyDistribution).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Bloom Levels"})]})]}),(K.metadata.usedImportedTopics||(K.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: ",K.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",K.metadata.importedMaterialsCount??0," • ","Topics: ",K.metadata.importedTopicCount??0]}),(K.metadata.topicProvenance||[]).slice(0,5).map((u,_)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[u.title||"Untitled topic",u.sourceFile?` • ${u.sourceFile}`:""]},`${u.topicId||u.title||"topic"}_${_}`)),(Ur.length>0||Wr.length>0)&&e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("label",{className:"text-xs text-[#5a6578] flex flex-col gap-1",children:[e.jsx("span",{className:"font-semibold",children:"Filter by Source File"}),e.jsxs("select",{value:ot,onChange:u=>gt(u.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All sources"}),Ur.map(u=>e.jsx("option",{value:u,children:u},u))]})]}),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:Dt,onChange:u=>Ns(u.target.value),className:"bg-white border border-[#dde3eb] rounded-md px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"all",children:"All materials"}),Wr.map(u=>e.jsx("option",{value:u,children:u},u))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",Oa.length," of ",K.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(hs,{size:14})," Difficulty"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(K.metadata.difficultyBreakdown).map(([u,_])=>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 ${ju[u]||"text-[#475569]"}`,children:u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:_})]},u))})]}),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(ar,{size:14})," Bloom's Taxonomy"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(K.metadata.bloomTaxonomyDistribution).map(([u,_])=>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:u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:_})]},u))})]}),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(ya,{size:14})," Question Types"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(K.metadata.questionTypeBreakdown).map(([u,_])=>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:xa[u]?.label||u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:_})]},u))})]})]}),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(Us,{size:18,className:"text-[#9333ea]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#9333ea] mb-3",children:K.metadata.supplementalPurpose||"This quiz is designed to supplement classroom instruction, not replace teacher-led learning."}),K.metadata.recommendedTeacherActions&&K.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:K.metadata.recommendedTeacherActions.map((u,_)=>e.jsx("li",{children:u},_))})]})]})]})]}),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(Go,{size:20,className:"text-[#a855f7]"})," Review Questions"]}),e.jsx("div",{className:"space-y-4",children:Oa.length>0?Oa.map((u,_)=>nl(u,_)):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."})})]})]})]})]}),S==="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:[m==="topics"&&!X&&e.jsx("button",{onClick:()=>{k([]),$([])},className:"text-[13px] font-semibold text-[#a855f7] hover:underline",children:"Clear all"}),(m==="style"||m==="preview")&&!X&&e.jsxs("button",{onClick:()=>w(m==="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(as,{size:16})," Back"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[m==="setup"&&!X&&e.jsxs("button",{onClick:()=>w("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(es,{size:16})]}),m==="topics"&&!X&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>w("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(as,{size:16})," Back"]}),e.jsxs("button",{onClick:()=>w("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(es,{size:16})]})]}),m==="style"&&!X&&e.jsxs("button",{onClick:()=>w("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(es,{size:16})]}),m==="preview"&&!X&&!K&&e.jsxs("button",{onClick:Xi,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(Ut,{size:16})," Generate Quiz"]}),X&&e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(ct,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]}),m==="results"&&(Gr?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{N("bank"),ca(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:()=>Pa(Gr),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(da,{size:16})," Assign"]}),e.jsx("button",{onClick:Yr,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:()=>{w("setup"),we(null),Se(null),Ee(null),ca(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"}),Ue?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:tl,disabled:lt,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:[lt?e.jsx(ct,{size:16,className:"animate-spin"}):e.jsx(sa,{size:16})," Publish"]}),e.jsxs("button",{onClick:()=>Pa(),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(da,{size:16})," Assign to Class"]})]}):e.jsxs("button",{onClick:el,disabled:J,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:[J?e.jsx(ct,{size:16,className:"animate-spin"}):e.jsx(Po,{size:16})," Save to Library"]}),e.jsx("button",{onClick:Yr,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(gu,{isOpen:Fe,onClose:()=>be(!1)}),e.jsx(Bt,{children:Bi&&e.jsx(Pe.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:()=>Fs(!1),children:e.jsxs(Pe.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:u=>u.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(Rt,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>Fs(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(ps,{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(ra,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:Da,onChange:u=>$r(u.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:Hi?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(ct,{size:20,className:"animate-spin text-sky-500"})}):Zr.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):Zr.map(u=>e.jsxs("button",{onClick:()=>Or(u.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${cs===u.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:u.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(u.name)}&background=random&size=32`,alt:u.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:u.name}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:u.email})]}),cs===u.id&&e.jsx(Ut,{size:16,className:"text-sky-600 flex-shrink-0"})]},u.id))}),e.jsxs("div",{className:"px-5 py-3 border-t border-[#dde3eb] flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>Fs(!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:sl,disabled:!cs||Aa,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${cs&&!Aa?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[Aa?e.jsx(ct,{size:14,className:"animate-spin"}):e.jsx(da,{size:14}),"Assign"]})]})]})})})]});return d?e.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-white",children:sn}):sn},yu=({onOpenNotifications:t,onOpenProfile:s,onOpenInsightModal:a,userPhoto:r,teacherName:n})=>{const[o,i]=h.useState([]),[l,c]=h.useState(!1),[d,x]=h.useState(!1),[b,p]=h.useState(""),[g,C]=h.useState(11),[S,N]=h.useState("general_mathematics"),m=h.useCallback(async()=>{c(!0);try{const j=await nn("/api/quiz-battle/bank-status");i(j.pdfs)}catch(j){const H=j instanceof ja?j.message:"Failed to load bank status";me.error(H)}finally{c(!1)}},[]);h.useEffect(()=>{m()},[m]);const w=async()=>{if(!b.trim()){me.error("Please enter a storage path");return}x(!0);try{await nn("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:b.trim(),grade_level:g,topic:S.trim(),force_reingest:!1})}),me.success("PDF ingestion completed"),await m(),p("")}catch(j){const H=j instanceof ja?j.message:"Ingestion failed";me.error(H)}finally{x(!1)}},y=o.reduce((j,H)=>j+H.question_count,0),R=o.filter(j=>j.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(Wt,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:o.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(Lt,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:y})]}),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(Vs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:R})]})]}),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(xn,{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(Wt,{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:b,onChange:j=>p(j.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:g,onChange:j=>C(Number(j.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(Lt,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"general_mathematics",value:S,onChange:j=>N(j.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(ct,{className:"w-4 h-4 animate-spin"}):e.jsx(xn,{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:m,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(Vs,{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:[o.map(j=>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 ${j.processed?"bg-indigo-50 text-indigo-500":"bg-amber-50 text-amber-500"}`,children:e.jsx(Wt,{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:j.filename})]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-semibold text-[#475569]",children:j.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:j.topic})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-bold text-[#1e293b] text-center",children:j.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 ${j.processed?"bg-emerald-50 text-emerald-600 border-emerald-200/50":"bg-amber-50 text-amber-600 border-amber-200/50"}`,children:[j.processed?e.jsx(Vs,{className:"w-3 h-3"}):e.jsx(ct,{className:"w-3 h-3 animate-spin"}),j.processed?"Completed":"Processing..."]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-medium text-[#64748b]",children:j.timestamp?new Date(j.timestamp).toLocaleDateString():"-"})]},j.filename)),o.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(Wt,{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."})]})})})]})]})})})]})]})]})},ao={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},Su={"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"}},ro={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"}},no={needs_attention:0,on_track:1,no_data:2,mastered:3},ku=({classSectionId:t,onOpenNotifications:s,onOpenProfile:a})=>{const{currentUser:r,userProfile:n}=gs(),[o,i]=h.useState([]),[l,c]=h.useState(ao),[d,x]=h.useState(!0),[b,p]=h.useState("all"),[g,C]=h.useState("all"),[S,N]=h.useState(""),[m,w]=h.useState("classAverage"),[y,R]=h.useState("asc"),j=pn.map(B=>B.id),H=pn.reduce((B,Y)=>(B[Y.id]=Y.name,B),{}),{isLoading:v,refetch:k}=Ql();h.useEffect(()=>{v||(console.log("[TopicMasteryView] Curriculum ready"),k())},[v,k]);const[I,$]=h.useState(new Set),[D,q]=h.useState([]),Q=Pl({queryKey:xl.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 B=vt(st,"teachers",r.uid,"settings","quizSettings"),Y=await Cs(B),ne=Y.exists()?Y.data()?.excludedTopics||[]:[],De="https://deign86-mathpulse-api-v3test.hf.space",Le=new URLSearchParams({teacherId:r.uid});t&&Le.set("classSectionId",t);const Ge=await r.getIdToken(),O=await fetch(`${De}/api/analytics/topic-mastery?${Le.toString()}`,{headers:{Authorization:`Bearer ${Ge}`}});if(!O.ok)return{excluded:ne,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ne.length}};const X=await O.json(),f=(X.topics||[]).map(T=>({...T,isExcluded:ne.includes(T.topicName)}));return{excluded:ne,topics:f,summary:X.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ne.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});h.useEffect(()=>{if(x(Q.isLoading||Q.isFetching),!Q.data){q([]),i([]),c(ao),$(new Set);return}q(Q.data.excluded),i(Q.data.topics),c(Q.data.summary)},[Q.data,Q.isFetching,Q.isLoading]);const A=async B=>{if(!r)return;const Y=D.includes(B)?D.filter(ne=>ne!==B):[...D,B];q(Y),i(ne=>ne.map(De=>De.topicName===B?{...De,isExcluded:!De.isExcluded}:De)),c(ne=>({...ne,excludedCount:Y.length}));try{const ne=vt(st,"teachers",r.uid,"settings","quizSettings");(await Cs(ne)).exists()?await Kt(ne,{excludedTopics:Y}):await Zt(ne,{excludedTopics:Y})}catch{me.error("Failed to update excluded topics")}},U=async()=>{if(!r)return;const B=[...new Set([...D,...I])];q(B),i(Y=>Y.map(ne=>I.has(ne.topicName)?{...ne,isExcluded:!0}:ne)),c(Y=>({...Y,excludedCount:B.length})),$(new Set);try{const Y=vt(st,"teachers",r.uid,"settings","quizSettings");(await Cs(Y)).exists()?await Kt(Y,{excludedTopics:B}):await Zt(Y,{excludedTopics:B}),me.success(`${I.size} topics excluded from quizzes`)}catch{me.error("Failed to update")}},ee=async()=>{if(!r)return;const B=D.filter(Y=>!I.has(Y));q(B),i(Y=>Y.map(ne=>I.has(ne.topicName)?{...ne,isExcluded:!1}:ne)),c(Y=>({...Y,excludedCount:B.length})),$(new Set);try{const Y=vt(st,"teachers",r.uid,"settings","quizSettings");(await Cs(Y)).exists()?await Kt(Y,{excludedTopics:B}):await Zt(Y,{excludedTopics:B}),me.success(`${I.size} topics re-included in quizzes`)}catch{me.error("Failed to update")}},ie=B=>{m===B?R(Y=>Y==="asc"?"desc":"asc"):(w(B),R("asc"))},je=g==="all"?j:Hl(g);h.useEffect(()=>{b!=="all"&&(je.includes(b)||p("all"))},[je,b]);const ge=o.filter(B=>!(b!=="all"&&B.subjectId!==b||!je.includes(B.subjectId)||S&&!B.topicName.toLowerCase().includes(S.toLowerCase()))).sort((B,Y)=>{const ne=y==="asc"?1:-1;switch(m){case"topicName":return ne*B.topicName.localeCompare(Y.topicName);case"classAverage":return ne*(B.classAverage-Y.classAverage);case"studentsAttempted":return ne*(B.studentsAttempted-Y.studentsAttempted);case"masteryStatus":return ne*((no[B.masteryStatus]||0)-(no[Y.masteryStatus]||0));default:return 0}}),Ce=()=>{I.size===ge.length?$(new Set):$(new Set(ge.map(B=>B.topicName)))},de=({field:B})=>m!==B?e.jsx(_t,{size:14,className:"text-white/40"}):y==="asc"?e.jsx(ka,{size:14,className:"text-white font-bold"}):e.jsx(_t,{size:14,className:"text-white font-bold"});return d?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(ct,{size:24,className:"animate-spin text-indigo-500"}),e.jsx("span",{className:"ml-2 text-[#64748b]",children:"Loading topic mastery data..."})]}):e.jsxs(Pe.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(hs,{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(gr,{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(_s,{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(Dl,{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(ra,{size:16,className:"text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:S,onChange:B=>N(B.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:b,onChange:B=>p(B.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"}),je.map(B=>e.jsx("option",{value:B,children:H[B]||B},B))]}),e.jsx(_t,{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:g,onChange:B=>C(B.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"}),Gl.map(B=>e.jsx("option",{value:B,children:B},B))]}),e.jsx(_t,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsx(Bt,{children:I.size>0&&e.jsxs(Pe.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:[I.size," topics selected"]}),e.jsx("button",{onClick:U,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:ee,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:()=>$(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:I.size===ge.length&&ge.length>0,onChange:Ce,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:()=>ie("topicName"),children:["TOPIC NAME ",e.jsx(de,{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:()=>ie("classAverage"),children:["CLASS AVG % ",e.jsx(de,{field:"classAverage"})]}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ie("studentsAttempted"),children:["STUDENTS ",e.jsx(de,{field:"studentsAttempted"})]}),e.jsxs("div",{className:"col-span-1 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ie("masteryStatus"),children:["STATUS ",e.jsx(de,{field:"masteryStatus"})]}),e.jsx("div",{className:"col-span-1 text-center",children:"EXCLUDE"})]}),e.jsx("div",{className:"flex flex-col",children:ge.length===0?e.jsx("div",{className:"p-16 text-center border-b border-[#f1f5f9]",children:o.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(hs,{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."})}):ge.map(B=>{const Y=I.has(B.topicName),ne=ro[B.masteryStatus]||ro.no_data,De=Su[B.subjectId]||{label:B.subjectId.toUpperCase(),color:"bg-[#f8fafc] text-[#64748b]"},Le=B.classAverage<60?"bg-rose-500":B.classAverage<85?"bg-amber-500":"bg-emerald-500",Ge=B.isExcluded?"bg-slate-50/60 opacity-70":B.masteryStatus==="needs_attention"?"bg-rose-50/30":B.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} ${B.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 O=new Set(I);Y?O.delete(B.topicName):O.add(B.topicName),$(O)},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:B.topicName}),e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded shrink-0 ${De.color}`,children:De.label})]}),e.jsx("div",{className:"col-span-2 text-[#475569] text-[13px] truncate pr-2",children:B.unit}),e.jsx("div",{className:"col-span-2",children:e.jsxs("span",{className:"font-bold text-[#1e293b] text-[14px]",children:[B.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:[B.studentsAttempted," / ",B.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 ${Le}`,style:{width:`${B.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 ${ne.color}`,children:ne.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:B.isExcluded,onChange:()=>A(B.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:B.isExcluded?"Include in generation":"Exclude from generation"})]})]},B.topicName)})})]})})})]})]})};function Ri(t){return(t||"").trim().toLowerCase()}function oo(t){const s=(t.lrn||"").trim().toLowerCase();if(s)return`lrn:${s}`;const a=(t.email||"").trim().toLowerCase();if(a)return`email:${a}`;const r=t.name.trim().toLowerCase();if(r)return`name:${r}`;const n=Ri(t.classSectionId),o=(t.id||"").trim().toLowerCase();return n&&o?`${n}|id:${o}`:o?`id:${o}`:`${n}|anonymous`}function Cu(t,s){const a=[],r=(t.lrn||"").trim().toLowerCase(),n=(t.email||"").trim().toLowerCase(),o=t.name.trim().toLowerCase(),i=(t.id||"").trim().toLowerCase();return r&&a.push(`${s}|lrn:${r}`),n&&a.push(`${s}|email:${n}`),o&&a.push(`${s}|name:${o}`),i&&a.push(`${s}|id:${i}`),a.length===0&&a.push(`${s}|anonymous`),a}function Tu(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 Mi(t,s){const a=new Map,r=new Map,n=s?Ri(s):"all";return t.forEach(o=>{const i=Cu(o,n),l=i.map(x=>r.get(x)).find(Boolean)||i[0],c=a.get(l),d=c?Tu(c,o):o;a.set(l,d),i.forEach(x=>r.set(x,l))}),Array.from(a.values())}function io(t,s){return Mi([...t,...s])}function Ss(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function Iu(t){if(!t)return null;const s="gen-math",a=hn.find(i=>i.id===s)?.modules||[];if(a.length===0)return null;const r={mastery:0,concept:0,application:0,engagement:0,consistency:0},n=t.lessons??{};a.forEach(i=>{const l=hn.find(N=>N.modules.some(m=>m.id===i.id)),c=l?t?.subjects?.[l.id]?.modulesProgress?.[i.id]:null,d=Ss(c?.progress||0),x=i.lessons.length?i.lessons.reduce((N,m)=>{const w=n?.[m.id]?.score;if(typeof w=="number"&&Number.isFinite(w))return N+Ss(w);const y=!!c?.lessonsCompleted?.includes?.(m.id);return N+(y?100:0)},0)/i.lessons.length:0,b=i.quizzes.length?(c?.quizzesCompleted?.length||0)/i.quizzes.length*100:0,p=Ss(x),g=Ss(b),C=Ss(Math.min(100,(p+g*2)/1.5)),S=Ss(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=p,r.application+=g,r.engagement+=C,r.consistency+=S});const o=a.length;return{mastery:Math.round(r.mastery/o),concept:Math.round(r.concept/o),application:Math.round(r.application/o),engagement:Math.round(r.engagement/o),consistency:Math.round(r.consistency/o)}}const lo={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"}},Ja=[{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"}],Eu=({classSectionId:t,className:s,fallbackStudents:a=[],onBack:r,onOpenNotifications:n,onOpenProfile:o,insightDismissed:i,onOpenInsightModal:l})=>{const{currentUser:c,userProfile:d}=gs(),x=h.useRef(0),[b,p]=h.useState([]),[g,C]=h.useState(!0),[S,N]=h.useState(""),[m,w]=h.useState("riskLevel"),[y,R]=h.useState("desc"),[j,H]=h.useState("all"),[v,k]=h.useState([]),[I,$]=h.useState(!1),[D,q]=h.useState(""),[Q,A]=h.useState(""),U=h.useCallback(f=>({id:f.id,lrn:f.lrn||void 0,name:f.name,email:f.email||"",avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(f.name)}&background=random`,classSectionId:f.classSectionId??null,riskLevel:f.riskLevel||"Low",engagementScore:f.engagementScore,avgQuizScore:f.avgQuizScore,weakestTopic:f.weakestTopic||"Foundational Skills"}),[]),ee=h.useCallback(f=>({id:f.id,lrn:f.lrn,name:f.name,email:f.email||"",avatar:f.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(f.name)}&background=random`,classSectionId:f.classSectionId??null,riskLevel:String(f.riskLevel).charAt(0).toUpperCase()+String(f.riskLevel).slice(1).toLowerCase(),engagementScore:f.engagementScore,avgQuizScore:Number(f.avgQuizScore??f.avgScore??0),weakestTopic:f.weakestTopic||"Foundational Skills"}),[]),ie=h.useCallback(async(f,T)=>{const E=new Map;f.forEach(V=>E.set(V.id,null));const W=25;for(let V=0;V{try{const oe=await on(z.id);return{studentId:z.id,summary:Iu(oe)}}catch{return{studentId:z.id,summary:null}}}))).forEach((z,oe)=>{const ue=se[oe]?.id;ue&&(z.status==="fulfilled"?E.set(ue,z.value.summary):E.set(ue,null))})}x.current===T&&p(V=>V.map(se=>E.has(se.student.id)?{...se,competencyMatrix:E.get(se.student.id)??null,competencyMatrixLoading:!1}:se))},[]),je=h.useCallback(async()=>{if(c?.uid){C(!0),A("");try{let T=(await Rr(c.uid)).map(se=>({id:se.id,name:se.name,email:se.email||"",avatar:se.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(se.name)}&background=random`,classSectionId:se.classSectionId??null,riskLevel:se.riskLevel,engagementScore:se.engagementScore,avgQuizScore:se.avgQuizScore,weakestTopic:se.weakestTopic||"Foundational Skills"}));a.length>0&&(T=io(T,a.map(ee))),t&&(T=T.filter(se=>se.classSectionId===t));const E=await Ze.getImportedClassOverview({classSectionId:t,limit:3e3});E.warnings.length>0&&A(E.warnings.join(" ")),T=io(T,E.students.map(U));const W=Mi(T,t),V=x.current+=1;p(W.map((se,ae)=>({rowKey:`${oo(se)}|row:${ae}`,student:se,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),ie(W,V)}catch(f){if(console.error("Failed to load students:",f),a.length>0){const T=a.map(ee).filter(E=>!t||E.classSectionId===t).map((E,W)=>({rowKey:`${oo(E)}|row:${W}`,student:E,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));p(T),A("Showing recently imported students while backend roster sync catches up.")}else p([]),A("Student competency roster is unavailable right now.")}finally{C(!1)}}},[t,c?.uid,a,ie,ee,U]);h.useEffect(()=>{je()},[je]),h.useEffect(()=>{(async()=>{if(!t){k([]),q("");return}$(!0),q("");try{const T=await Ze.getCourseMaterialTopics({classSectionId:t,limit:20}),E=(T.topics||[]).filter(W=>W.title?.trim());k(E),T.warnings.length>0&&q(T.warnings.join(" "))}catch{k([]),q("Imported topic context is unavailable right now.")}finally{$(!1)}})()},[t]);const ge=async f=>{p(T=>T.map(E=>{if(E.rowKey!==f)return E;const W=!E.expanded,V=E.student.id,se={weakestTopic:E.student.weakestTopic,avgQuizScore:E.student.avgQuizScore};return W&&!E.competency&&!E.loading?(Ce(f,V,se),{...E,expanded:!0,loading:!0}):{...E,expanded:W}}))},Ce=async(f,T,E)=>{try{const V=((await on(T))?.quizAttempts??[]).map(ae=>({topic:ae.quizId,score:ae.score,total:100,timeTaken:ae.timeSpent})),se=await Ze.getStudentCompetency(T,V.length>0?V:void 0);p(ae=>ae.map(z=>z.rowKey===f?{...z,competency:se,loading:!1}:z))}catch{const V=E.avgQuizScore||50,se={studentId:T,competencies:[{topic:E.weakestTopic||"Unknown",efficiencyScore:Math.max(15,V-20),competencyLevel:V<50?"beginner":"developing",perspective:`Student needs focused practice in ${E.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,V+10),competencyLevel:V>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:V,competencyLevel:V>80?"advanced":V>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[E.weakestTopic||"Review fundamentals"],excludeTopics:[]};p(ae=>ae.map(z=>z.rowKey===f?{...z,competency:se,loading:!1}:z))}},de=f=>{m===f?R(T=>T==="asc"?"desc":"asc"):(w(f),R("asc"))},B={High:0,Medium:1,Low:2},Y=b.filter(f=>{if(j!=="all"&&f.student.riskLevel!==j)return!1;if(S){const T=S.toLowerCase();return f.student.name.toLowerCase().includes(T)||f.student.email.toLowerCase().includes(T)}return!0}).sort((f,T)=>{let E=0;switch(m){case"name":E=f.student.name.localeCompare(T.student.name);break;case"avgQuizScore":E=f.student.avgQuizScore-T.student.avgQuizScore;break;case"riskLevel":E=B[f.student.riskLevel]-B[T.student.riskLevel];break;case"engagementScore":E=f.student.engagementScore-T.student.engagementScore;break}return y==="asc"?E:-E}),ne=b.length,De=b.filter(f=>f.student.riskLevel==="High").length,Le=ne>0?Math.round(b.reduce((f,T)=>f+T.student.avgQuizScore,0)/ne):0,Ge=ne>0?Math.round(b.reduce((f,T)=>f+T.student.engagementScore,0)/ne):0,O=Array.from(new Set(v.map(f=>f.title).filter(Boolean))).slice(0,10),X=({field:f})=>m!==f?e.jsx(_t,{size:14,className:"text-white/40"}):y==="asc"?e.jsx(ka,{size:14,className:"text-white font-bold"}):e.jsx(_t,{size:14,className:"text-white font-bold"});return g?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(ct,{size:32,className:"animate-spin text-[var(--primary)]"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading student data..."})]}):e.jsxs(Pe.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(as,{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(ln,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:ne}),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(_s,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:De}),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(hs,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Le,"%"]}),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(sa,{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(ra,{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:S,onChange:f=>N(f.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(f=>e.jsx("button",{onClick:()=>H(f),className:`px-4 py-1.5 text-[13px] font-semibold rounded-full whitespace-nowrap transition-colors shadow-md ${j===f?"bg-[#9956DE] text-white":"bg-white text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:f==="all"?"All":`${f} Risk`},f))})]}),e.jsxs("button",{onClick:je,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(Vs,{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}`:"",":"]}),I?e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:"Loading class-scoped imported topics..."}):O.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-1 sm:mt-0",children:O.map((f,T)=>e.jsxs(le.Fragment,{children:[e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:f}),Tde("name"),children:["Student ",e.jsx(X,{field:"name"})]}),e.jsxs("div",{className:"w-[120px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",onClick:()=>de("riskLevel"),children:["Risk Level ",e.jsx(X,{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:()=>de("avgQuizScore"),children:["Avg. Score ",e.jsx(X,{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:()=>de("engagementScore"),children:["Engagement ",e.jsx(X,{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"}),Ja.map((f,T)=>e.jsx("div",{className:`w-[100px] shrink-0 px-2 flex justify-center ${T===Ja.length-1?"border-r border-transparent":""}`,children:f.header},f.key))]}),Y.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(ln,{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(f=>(f.student.riskLevel==="High"||f.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 ge(f.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 ${f.expanded?"rotate-90":""}`,children:e.jsx(es,{className:"w-4 h-4 text-slate-400"})}),e.jsx("img",{src:f.student.avatar,alt:f.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:f.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 ${f.student.riskLevel==="High"?"bg-rose-50 text-rose-600 border-rose-200":f.student.riskLevel==="Medium"?"bg-amber-50 text-amber-600 border-amber-200":"bg-emerald-50 text-emerald-600 border-emerald-200"}`,children:f.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 ${f.student.avgQuizScore>=80?"bg-emerald-500":f.student.avgQuizScore>=60?"bg-amber-400":"bg-rose-500"}`,style:{width:`${f.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[f.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:`${f.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[f.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:f.student.weakestTopic})}),Ja.map(T=>{const E=f.competencyMatrix?.[T.key]??0;return e.jsx("div",{className:"w-[100px] shrink-0 px-2 flex justify-center",children:f.competencyMatrixLoading?e.jsx(ct,{size:12,className:"animate-spin text-muted-foreground"}):f.competencyMatrix?e.jsxs("span",{className:`text-[12px] font-medium px-2 rounded-full border ${E>=80?"text-emerald-600 bg-emerald-50 border-emerald-100":E>=60?"text-amber-600 bg-amber-50 border-amber-100":"text-rose-500 bg-rose-50 border-rose-100"}`,children:[E,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},T.key)})]}),e.jsx(Bt,{children:f.expanded&&e.jsx(Pe.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:f.loading?e.jsxs("div",{className:"flex items-center py-4",children:[e.jsx(ct,{size:16,className:"animate-spin text-indigo-500 mr-2"}),e.jsx("span",{className:"text-sm text-slate-500",children:"Analyzing competency data..."})]}):f.competency?e.jsxs("div",{className:"space-y-4 max-w-4xl",children:[f.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(Lt,{className:"w-4 h-4"})," Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:f.competency.recommendedTopics.map((T,E)=>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},E))})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:f.competency.competencies.map((T,E)=>e.jsx(_u,{competency:T},E))})]}):e.jsx("div",{className:"text-sm text-slate-500 py-4",children:"Failed to load competency details."})})]})})})]},f.rowKey)))})]})})]})},_u=({competency:t})=>{const s=lo[t.competencyLevel]||lo.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(Pe.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})]})},Ru=()=>{const{notifications:t,unreadCount:s,isLoading:a,markAsRead:r,markAllAsRead:n}=Io(),[o,i]=h.useState("all"),l=p=>{switch(p){case"achievement_unlocked":case"achievement":return pl;case"message":return Nl;case"grade":case"quiz_result":return _o;case"reminder":case"streak_reminder":case"daily_checkin":return Ms;case"risk_alert":return _s;case"sparkles":case"lesson_plan_ready":return ss;case"users":case"student_import":return Rt;default:return Rs}},c=(p,g)=>{switch(p){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"}},d=p=>{switch(p){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)]"}},x=h.useMemo(()=>{let p=t;return o==="unread"&&(p=p.filter(g=>!g.isRead)),o==="important"&&(p=p.filter(g=>g.type==="risk_alert")),p},[t,o]),b=h.useMemo(()=>{const p=[],g=x.filter(N=>Tn(N.createdAt)),C=x.filter(N=>In(N.createdAt)),S=x.filter(N=>!Tn(N.createdAt)&&!In(N.createdAt));return g.length>0&&p.push({title:"Today",icon:Ms,items:g}),C.length>0&&p.push({title:"Yesterday",icon:mn,items:C}),S.length>0&&p.push({title:"Earlier",icon:mn,items:S}),p},[x]);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 ${o==="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 ${o==="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:s})]}),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 ${o==="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",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:s>0?`${s} unread`:"No unread"}),e.jsxs("button",{onClick:n,disabled:s===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(Ao,{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(ct,{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(Rs,{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(p=>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(p.icon,{className:"w-4 h-4"})," ",p.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:p.items.map(g=>{const C=l(g.type),S=g.type==="risk_alert";return e.jsxs(Pe.div,{layout:!0,onClick:()=>!g.isRead&&r(g.id),className:`relative p-5 flex gap-5 group cursor-pointer hover:bg-white transition-all duration-300 ${g.isRead?"opacity-80":c(g.type)}`,children:[e.jsx("div",{className:`absolute left-0 top-0 w-1.5 h-full transition-colors ${g.isRead?"bg-transparent":S?"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 ${d(g.type)}`,children:e.jsx(C,{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:[g.title,!g.isRead&&e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${S?"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 ${g.isRead?"text-[#94a3b8]":S?"text-rose-600":"text-[#a855f7]"}`,children:[Fo(g.createdAt)," ago"]})]}),e.jsx("p",{className:"text-[14px] text-[#475569] font-medium leading-relaxed",children:g.message}),!g.isRead&&g.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 ${S?"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(sc,{size:18})})]},g.id)})})]},p.title))})]})})},Mu=t=>{const s=t.data(),a=s.startTime,r=s.endTime,n=s.createdAt,o=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(n)||new Date,updatedAt:i(o)}},zu=async(t,s)=>{const a=vt(Xt(st,"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 Zt(a,{...r,createdAt:ft(),updatedAt:ft()}),r},Lu=async(t,s)=>{const a=vt(st,"calendarEvents",t);await Kt(a,{...s,updatedAt:ft()})},Au=async t=>{await vl(vt(st,"calendarEvents",t))},Du=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:n=500}=s,o=Ht(Xt(st,"calendarEvents"),Gt("userId","==",t),zo(n));return Lo(o,i=>{a(i.docs.map(l=>Mu(l)))},i=>{console.error("Error subscribing to calendar events:",i),r?.(i)})};function Fu({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Eo("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 Ts=t=>String(t).padStart(2,"0"),ds=t=>`${t.getFullYear()}-${Ts(t.getMonth()+1)}-${Ts(t.getDate())}`,pr=t=>new Date(t.getFullYear(),t.getMonth(),1),co=t=>new Date(t.getFullYear(),t.getMonth()+1,0),$u=t=>{const s=pr(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},Ou=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},uo=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),Bu=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),Pu=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),pa=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),mo=(t,s)=>{const[a,r,n]=t.split("-").map(l=>parseInt(l,10)),[o,i]=s.split(":").map(l=>parseInt(l,10));return new Date(a,(r||1)-1,n||1,o||0,i||0,0,0)},Hu=["purple","blue","emerald","amber","rose"],Za=t=>{switch(t){case"blue":return"#3b82f6";case"emerald":return"#10b981";case"amber":return"#f59e0b";case"rose":return"#f43f5e";case"purple":default:return"#a855f7"}},Gu=(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"}},Qu=(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"}}},er=[{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 Vu(t){const s=t.toLowerCase(),a=new Set;if(s.includes("daily")||s.includes("everyday"))return[0,1,2,3,4,5,6];if(s.includes("weekends"))return[0,6];if(s.includes("weekdays"))return[1,2,3,4,5];const r=s.match(/(mon|tue|wed|thu|fri|sat|sun)[\s/-]*(mon|tue|wed|thu|fri|sat|sun)/);if(r){const n=er.find(i=>i.names.includes(r[1]))?.day,o=er.find(i=>i.names.includes(r[2]))?.day;if(n!==void 0&&o!==void 0){let i=n;for(;a.add(i),i!==o;)i=(i+1)%7;return Array.from(a)}}return er.forEach(({names:n,day:o})=>{n.some(i=>s.includes(i))&&a.add(o)}),Array.from(a).sort((n,o)=>n-o)}const Uu=({classes:t,teacherId:s})=>{const{currentUser:a}=gs(),[r,n]=h.useState([]),[o,i]=h.useState(!0),[l,c]=h.useState(""),[d,x]=h.useState(!0),[b,p]=h.useState(()=>{const z=new Date;return z.setHours(0,0,0,0),z}),[g,C]=h.useState(()=>{const z=new Date;return z.setHours(0,0,0,0),z}),[S,N]=h.useState(new Set),[m,w]=h.useState(!1),[y,R]=h.useState(null),[j,H]=h.useState(!1),[v,k]=h.useState(""),[I,$]=h.useState(""),[D,q]=h.useState(()=>ds(new Date)),[Q,A]=h.useState("09:00"),[U,ee]=h.useState(""),[ie,je]=h.useState("purple"),[ge,Ce]=h.useState(!1),[de,B]=h.useState(null);h.useEffect(()=>{if(!a?.uid){n([]),i(!1);return}c(""),i(!0);const z=Du(a.uid,{limitCount:500},oe=>{n(oe),i(!1)},()=>{c("Unable to load calendar events right now."),i(!1)});return()=>z()},[a?.uid]);const Y=h.useMemo(()=>{const z=pr(b);return z.setHours(0,0,0,0),z},[b]),ne=h.useMemo(()=>{const z=co(b);return z.setHours(23,59,59,999),z},[b]),De=h.useMemo(()=>{if(!t||t.length===0)return[];const z=[],oe=pr(b),ue=co(b),ve=new Date(oe);for(;ve<=ue;){const K=ve.getDay();t.forEach(we=>{if(Vu(we.schedule).includes(K)){const Se=`schedule-${we.id}-${ds(ve)}`;S.has(Se)||z.push({id:Se,userId:s||"",title:we.name,startTime:new Date(ve),createdAt:new Date})}}),ve.setDate(ve.getDate()+1)}return z},[t,b,s,S]),Le=h.useMemo(()=>[...r,...De],[r,De]),Ge=h.useMemo(()=>Le.filter(z=>z.startTime>=Y&&z.startTime<=ne).sort((z,oe)=>z.startTime.getTime()-oe.startTime.getTime()),[Le,Y,ne]),O=h.useMemo(()=>{const z=new Map;for(const oe of Ge){const ue=ds(oe.startTime),ve=z.get(ue)||[];ve.push(oe),z.set(ue,ve)}return z},[Ge]),X=h.useMemo(()=>ds(g),[g]),f=h.useMemo(()=>[...O.get(X)||[]].sort((oe,ue)=>oe.startTime.getTime()-ue.startTime.getTime()),[O,X]),T=h.useMemo(()=>{const z=$u(b);return Array.from({length:42}).map((oe,ue)=>Ou(z,ue))},[b]),E=z=>{const oe=ds(z);R(null),k(""),$(""),q(oe),A("09:00"),ee(""),je("purple"),w(!0)},W=z=>{z.id.startsWith("schedule-")?(N(oe=>new Set(oe).add(z.id)),R(null)):R(z.id),k(z.title),$(z.description||""),q(ds(z.startTime)),A(Ts(z.startTime.getHours())+":"+Ts(z.startTime.getMinutes())),ee(z.endTime?Ts(z.endTime.getHours())+":"+Ts(z.endTime.getMinutes()):""),je(z.color||"purple"),Ce(!1),w(!0)},V=(z,oe)=>{z.stopPropagation(),B(oe),Ce(!0)},se=async()=>{const z=a?.uid||s||"local-user";if(!v.trim()){c("Event title is required.");return}H(!0),c("");const oe=mo(D,Q),ue=U?mo(D,U):void 0,ve={title:v.trim(),description:I.trim()?I.trim():void 0,startTime:oe,endTime:ue&&ue.getTime()>oe.getTime()?ue:void 0,color:ie};try{if(y)n(K=>K.map(we=>we.id===y?{...we,...ve}:we)),await Lu(y,ve);else{const K=`temp-${Date.now()}`;n(we=>[...we,{id:K,userId:z,createdAt:new Date,...ve}]),await zu(z,ve)}w(!1)}catch(K){console.error(K),w(!1)}finally{H(!1)}},ae=async z=>{if(z.startsWith("schedule-")){N(oe=>new Set(oe).add(z)),de?.id===z&&Ce(!1);return}c(""),n(oe=>oe.filter(ue=>ue.id!==z)),de?.id===z&&Ce(!1);try{await Au(z)}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:()=>p(new Date(b.getFullYear(),b.getMonth()-1,1)),className:"w-9 h-9 rounded-full flex items-center justify-center text-[#a855f7] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(as,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-[22px] font-bold text-white w-44 text-center tracking-tight",children:Pu(b)}),e.jsx("button",{onClick:()=>p(new Date(b.getFullYear(),b.getMonth()+1,1)),className:"w-9 h-9 rounded-full flex items-center justify-center text-[#a855f7] bg-white hover:bg-slate-50 transition-colors shadow-sm hover:shadow-md active:scale-90",children:e.jsx(es,{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-[#a855f7] bg-white px-4 py-1.5 rounded-full shadow-sm",children:[Ge.length," events"]}),e.jsx("button",{onClick:()=>x(!d),className:`w-9 h-9 rounded-full flex items-center justify-center transition-all shadow-sm hover:shadow-md border ${d?"text-[#a855f7] bg-white border-white":"text-white bg-white/20 border-white/30 backdrop-blur-md"}`,title:d?"Hide Sidebar":"Show Sidebar",children:e.jsx(uc,{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(z=>e.jsx("div",{className:"text-[12px] font-bold text-[#94a3b8] uppercase tracking-widest",children:z},z))}),e.jsx("div",{className:"grid grid-cols-7 gap-2 pb-6 px-4",children:T.map(z=>{const oe=ds(z),ue=O.get(oe)||[],ve=uo(z,g),K=uo(z,new Date),we=Bu(z,b);return e.jsxs("div",{onClick:()=>C(new Date(z)),className:`group p-2 rounded-lg transition-all cursor-pointer border-2 flex flex-col relative min-h-[100px] xl:min-h-[120px] ${ve?"bg-purple-50/50 border-[#a855f7] shadow-sm z-10":K?"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"} ${we?"":"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 ${K?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":ve?"text-[#9333ea]":"text-[#1e293b]"}`,children:z.getDate()})}),e.jsxs("div",{className:"mt-1 space-y-1",children:[ue.slice(0,3).map(We=>{const Se=We.id.startsWith("schedule-");return e.jsx("div",{onClick:Je=>V(Je,We),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 ${Gu(We.color,Se)}`,children:We.title},We.id)}),ue.length>3&&e.jsxs("div",{className:"text-[10px] font-bold text-[#64748b] pl-1 pt-0.5",children:["+",ue.length-3," more"]})]})]},oe)})})]})]})}),e.jsx(Bt,{children:d&&e.jsx(Pe.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:g.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:g.toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})})]}),e.jsx("button",{onClick:()=>E(g),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(rr,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar pb-12",children:f.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[e.jsx(Qa,{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."})]}):f.map(z=>{const oe=z.id.startsWith("schedule-"),ue=Qu(z.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 ${ue.dot}`}),e.jsxs("div",{onClick:ve=>V(ve,z),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 ${ue.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:z.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 ${ue.time}`,children:[e.jsx(Ms,{className:"w-3.5 h-3.5"})," ",e.jsxs("span",{children:[pa(z.startTime),z.endTime?` - ${pa(z.endTime)}`:""]})]}),z.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:z.description})]})]},z.id)})})]})})})]}),e.jsx(fn,{open:m,onOpenChange:w,children:e.jsx(gn,{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(Ul,{className:"mb-6",children:[e.jsx(Wl,{className:"text-[24px] font-bold text-[#1e293b] tracking-tight",children:y?"Edit Event":"Add New Event"}),e.jsx(ql,{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(Qs,{value:v,onChange:z=>k(z.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(Qs,{type:"date",value:D,onChange:z=>q(z.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(Qs,{type:"time",value:Q,onChange:z=>A(z.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(Fu,{value:I,onChange:z=>$(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:Hu.map(z=>e.jsx("button",{onClick:()=>je(z),className:`w-8 h-8 rounded-full flex items-center justify-center transition-all ${ie===z?"ring-2 ring-offset-2 ring-slate-800 scale-110 shadow-sm":"hover:scale-110 opacity-80 hover:opacity-100"}`,style:{backgroundColor:Za(z)},title:z,children:ie===z&&e.jsx(Ut,{className:"w-4 h-4 text-white"})},z))})]})]}),e.jsxs("div",{className:"flex gap-3 mt-8",children:[e.jsx(ms,{variant:"outline",onClick:()=>w(!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(ms,{onClick:se,disabled:j,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:j?e.jsx(ct,{className:"w-5 h-5 animate-spin"}):"Save Event"})]})]})})}),e.jsx(fn,{open:ge,onOpenChange:Ce,children:e.jsx(gn,{className:"sm:max-w-[400px] p-0 overflow-hidden rounded-[24px] border-none shadow-2xl [&>button]:hidden",children:de&&e.jsxs("div",{className:"p-8 bg-white relative",children:[e.jsx("button",{onClick:()=>Ce(!1),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(ps,{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:Za(de.color||"purple")+"20",color:Za(de.color||"purple")},children:de.id.startsWith("schedule-")?e.jsx(Mo,{size:24}):e.jsx(Qa,{size:24})}),e.jsxs("div",{className:"pr-6",children:[e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] leading-tight mb-2",children:de.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(Qa,{size:12}),de.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(Ms,{size:12}),pa(de.startTime),de.endTime?` - ${pa(de.endTime)}`:""]})]})]})]}),de.description&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Xl,{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:de.description})]}),e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-slate-100",children:[e.jsxs(ms,{variant:"outline",onClick:()=>ae(de.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(Oo,{className:"w-4 h-4 mr-2"})," Delete"]}),e.jsxs(ms,{onClick:()=>W(de),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(Qo,{className:"w-4 h-4 mr-2"})," Edit Event"]})]})]})})})]})},Ea=[{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]"}],xo=({classes:t,onSelectClass:s,onOpenNotifications:a,onOpenProfile:r,insightDismissed:n,onOpenInsightModal:o,viewType:i="analytics"})=>{const{currentUser:l,userProfile:c}=gs(),[d,x]=h.useState(""),b=i==="competency",p=t.reduce((N,m)=>N+(m.studentCount||0),0),g=t.reduce((N,m)=>N+(m.atRiskCount||0),0),C=t.length>0?(t.reduce((N,m)=>N+(m.avgScore||0),0)/t.length).toFixed(1):0,S=t.filter(N=>N.name.toLowerCase().includes(d.toLowerCase())||(N.gradeLevel||"").toLowerCase().includes(d.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-[24px] xl:p-[32px] 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(ra,{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:d,onChange:N=>x(N.target.value),className:"bg-transparent border-none focus:outline-none ml-3 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]})})}),b?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(Rt,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:p}),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(Yt,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[C,"%"]}),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(Yt,{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-[16px]",children:[e.jsxs("div",{className:"lg:col-span-8 grid grid-cols-1 sm:grid-cols-3 gap-[16px]",children:[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:"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(Rt,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none 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:p>0?Math.round(p*.94):0})]})]}),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:"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(Yt,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[C,"%"]}),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-[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:"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(aa,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:g}),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:[p>0?Math.round(g/p*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(Bo,{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(Wt,{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-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-[24px]",children:[e.jsx("div",{className:"mb-6 border-b border-[#f1f5f9] pb-4",children:e.jsx("h2",{className:"text-[18px] font-semibold text-[#1e293b]",children:b?"Select a Class":"My Classes"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-[16px]",children:[S.map((N,m)=>{const w=Ea[m%Ea.length];let y=null;return N.riskLevel==="high"?y=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"}):N.riskLevel==="medium"?y=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"}):y=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(N),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] ${w.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] ${w.bg} flex items-center justify-center border ${w.border}`,children:e.jsx(Lt,{className:`w-5 h-5 ${w.text}`})}),e.jsxs("div",{children:[e.jsx("h4",{className:`font-bold text-[14px] text-[#1e293b] mb-0.5 transition-colors ${w.groupHover}`,children:N.name}),e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider",children:N.gradeLevel||"Senior High"})]})]}),y]}),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:N.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:b?"Avg Competency":"Average"}),e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[N.avgScore,"%"]})]}),!b&&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:N.schedule||"Mon-Fri"})]})]})]})]},N.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",Wu=.85,hr=.85,qu="2026.04.24",Li=4,wa=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],Yu=[...wa,"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"],Ku=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],la=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],Xu=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],Ju={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},ks={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"]},St={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"]},Ae={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 Zu(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function dt(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function po(t){return dt(t).replace(/[^A-Z0-9]+/g,"")}function ke(t,s){const a=dt(t),r=dt(s);if(!a||!r)return!1;if(a.includes(r))return!0;const n=po(t),o=po(s);return!n||!o?!1:n.includes(o)}function Na(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 tr(t){return dt(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function Ai(t){const s={};return t.forEach(a=>{const r=Tt.encode_cell(a.s);for(let n=a.s.r;n<=a.e.r;n+=1)for(let o=a.s.c;o<=a.e.c;o+=1){const i=Tt.encode_cell({r:n,c:o});s[i]=r}}),s}function em(t,s,a){const n=(a||Ai(t.merges))[s]||s;return t.cells[n]||t.cells[s]}const Di="A1:A1",ho=1200,fo=200,go=2e5;function tm(t){const s=Math.max(0,t.s.r),a=Math.max(0,t.s.c);let r=Math.max(s,t.e.r),n=Math.max(a,t.e.c);r-s+1>ho&&(r=s+ho-1),n-a+1>fo&&(n=a+fo-1);const o=r-s+1,i=n-a+1;if(o*i>go){const c=Math.max(1,Math.floor(go/i));r=s+Math.min(o,c)-1}return{s:{r:s,c:a},e:{r,c:n}}}function sm(t){try{return Tt.decode_range(t)}catch{return Tt.decode_range(Di)}}function am(t){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return Object.keys(t.cells).forEach(o=>{try{const i=Tt.decode_cell(o);s=Math.min(s,i.r),a=Math.min(a,i.c),r=Math.max(r,i.r),n=Math.max(n,i.c)}catch{}}),t.merges.forEach(o=>{s=Math.min(s,o.s.r,o.e.r),a=Math.min(a,o.s.c,o.e.c),r=Math.max(r,o.s.r,o.e.r),n=Math.max(n,o.s.c,o.e.c)}),!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)?null:{s:{r:Math.max(0,Math.trunc(s)),c:Math.max(0,Math.trunc(a))},e:{r:Math.max(0,Math.trunc(r)),c:Math.max(0,Math.trunc(n))}}}function rm(t){const s=sm(t.ref||Di),a=am(t);return tm(a||s)}function nm(t,s){const a=rm(s),r=`${Tt.encode_cell(a.s)}:${Tt.encode_cell(a.e)}`,n=Ai(s.merges),o=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 ls(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function Hs(t){return Tt.encode_col(t)}function ha(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return Tt.decode_col(s)}catch{return-1}}function om(t){return`${Tt.encode_cell(t.s)}:${Tt.encode_cell(t.e)}`}function im(t,s){const a=[];for(let r=s.s.r;r<=s.e.r;r+=1){const n=[];for(let o=s.s.c;o<=s.e.c;o+=1){const i=Oe(t,r,o);n.push(i?.displayValue??null)}a.push(n)}return a}function lm(t,s){const a=dt(t),r=dt(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function Mr(t,s){const a=[];for(let r=0;r{ke(l.normalizedText,c)&&a.push({sheetName:t.sheetName,anchor:c,row:l.row,col:l.col,address:l.address,value:String(l.displayValue??""),confidence:lm(l.displayValue,c)})})}const n=t.startRow+r,o=ls(t,n);o&&s.forEach(i=>{if(!ke(o,i))return;const l=t.cells[r].find(c=>c?.normalizedText);l&&a.push({sheetName:t.sheetName,anchor:i,row:n,col:l.col,address:l.address,value:o,confidence:.8})})}return a}function cm(t,s){return Object.values(t).flatMap(a=>Mr(a,s))}function xt(t,s){return Mr(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function Fi(t,s,a,r=6){for(let n=1;n<=r;n+=1){const i=Oe(t,s,a+n)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}for(let n=1;n<=r;n+=1){const i=Oe(t,s+n,a)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}}function $i(t,s,a=5){let r=s,n=-1;for(let o=Math.max(t.startRow,s-a);o<=Math.min(t.endRow,s+a);o+=1){const i=ls(t,o),l=["LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK"].reduce((c,d)=>i.includes(d)?c+1:c,0);l>n&&(n=l,r=o)}return r}function dm(t,s){const a=dt(t).toLowerCase(),r=n=>[...s].some(o=>ke(o,n));return ks.inputData.some(n=>a.includes(n))||r("INPUT DATA")?"inputData":ks.finalSemestral.some(n=>a.includes(n))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":ks.firstQuarter.some(n=>a.includes(n))||r("FIRST QUARTER")?"firstQuarter":ks.secondQuarter.some(n=>a.includes(n))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":ks.helper.some(n=>a.includes(n))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":ks.lookup.some(n=>a.includes(n))||r("LOOK UP")?"lookup":"other"}function um(t){const s=t.criticalTotal>0?t.criticalFound/t.criticalTotal:0,a=t.totalSheets>0?t.recognizedSheets/t.totalSheets:0,r=t.hasDepedAnchor?1:0,n=.65*s+.2*a+.15*r;return Number(Math.max(0,Math.min(1,n)).toFixed(4))}function mm(t){const s=cm(t.matrices,Yu),a=new Set,r=[];wa.forEach(g=>{s.some(S=>ke(S.anchor,g))&&(a.add(g),r.push(`Found critical anchor: ${g}`))});const n=wa.filter(g=>!a.has(g)),o=new Map;s.forEach(g=>{o.has(g.sheetName)||o.set(g.sheetName,new Set),o.get(g.sheetName)?.add(g.anchor)});const i=t.sheetNames.map(g=>{const C=o.get(g)||new Set,S=dm(g,C),N=Math.min(1,.35+Math.min(.55,C.size*.08)),m=[`sheet:${g}`,`signals:${C.size}`,...[...C].slice(0,5)];return{sheetName:g,role:S,confidence:Number(N.toFixed(3)),evidence:m}}),l={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};i.forEach(g=>{switch(g.role){case"inputData":l.inputData?l.other.push(g.sheetName):l.inputData=g.sheetName;break;case"firstQuarter":l.firstQuarter.push(g.sheetName);break;case"secondQuarter":l.secondQuarter.push(g.sheetName);break;case"finalSemestral":l.finalSemestral.push(g.sheetName);break;case"helper":l.helper.push(g.sheetName);break;case"lookup":l.lookup.push(g.sheetName);break;case"other":default:l.other.push(g.sheetName);break}});const c=(l.inputData?1:0)+l.firstQuarter.length+l.secondQuarter.length+l.finalSemestral.length+l.helper.length+l.lookup.length,d=um({criticalFound:a.size,criticalTotal:wa.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(g=>ke(g.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),x=l.firstQuarter.length>0||l.secondQuarter.length>0,b=!!l.inputData&&x&&l.finalSemestral.length>0,p=d>=.55&&b;return l.inputData||r.push("Input Data sheet not confidently detected."),x||r.push("No quarter class record sheet detected."),l.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:zi,isOfficialFormatLikely:p,confidence:d,evidence:r,missingCriticalAnchors:n,detectedSheets:l,anchorMatches:s}}function _a(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 zr(t){const s=dt(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function Lr(t){const s=dt(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":Ku.some(a=>s.includes(a))?"signature":Xu.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 xm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(n=>{a.push({role:r,name:String(Oe(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function pm(t){const s=[],a=xt(t,"LEARNERS NAMES")[0],r=a?$i(t,a.row,5):t.startRow,n=(N,m)=>xt(t,N).find(y=>Math.abs(y.row-r)<=2)?.col??m,o=n(Ae.learnerNo[0],t.startCol),i=n(Ae.learnerName[0],t.startCol+1),l=n(Ae.firstQuarter[0],i+1),c=n(Ae.secondQuarter[0],l+1),d=n(Ae.firstSemester[0],c+1),x=n(Ae.finalGrades[0],d+1),b=n(Ae.remark[0],x+1),p=n(Ae.additionalRemarks[0],b+1),g=[];let C="UNKNOWN",S=0;for(let N=r+1;N<=t.endRow;N+=1){const m=ls(t,N),w=Lr({rowText:m,hasLearnerNumber:/\b\d{1,2}\b/.test(m),hasLearnerName:/[A-Z]{2,}/.test(m)});if(w==="sex-header"){C=zr(m)||C;continue}if(w==="signature"||w==="helper")break;if(w==="blank"){if(S+=1,S>=Li)break;continue}if(w!=="learner")continue;S=0;const y=_a(Oe(t,N,o)?.displayValue),R=String(Oe(t,N,i)?.displayValue||"").trim();if(!R&&y===void 0)continue;const j=Oe(t,N,l)?.displayValue??null,H=Oe(t,N,c)?.displayValue??null,v=Oe(t,N,d)?.displayValue??null,k=Oe(t,N,x)?.displayValue??null,I=Oe(t,N,b)?.displayValue??null;let $=Oe(t,N,p)?.displayValue??null;const D=la.filter(q=>ke(m,q));D.length>0&&($=[$,D.join("; ")].filter(Boolean).join("; ")||null),!R&&y!==void 0&&s.push(`Row ${N+1} has learner number ${y} but empty learner name.`),g.push({learnerNo:y,fullName:R||`Unnamed Learner ${y||N+1}`,sex:C,firstQuarter:j,secondQuarter:H,firstSemester:v,finalGrades:k,remark:I,additionalRemarks:$,sourceRow:N+1})}return{sheetName:t.sheetName,learnerGrades:g,signatures:xm(t),warnings:s}}function Et(t,s){for(const a of s){const r=xt(t,a);for(const n of r){const o=Fi(t,n.row,n.col,8);if(o&&o.trim())return o.trim()}}}function hm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(o=>{const i=Fi(t,o.row,o.col,10);a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function fm(t){const s=xt(t,"LEARNERS NAMES")[0];if(!s)return[];const a=s.row+1,r=s.col,n=Math.max(t.startCol,r-1),o=Math.min(t.endCol,r+1),i=Math.min(t.endCol,r+2),l=[];let c="UNKNOWN",d=0;for(let x=a;x<=t.endRow;x+=1){const b=ls(t,x),p=Lr({rowText:b,hasLearnerNumber:!!_a(Oe(t,x,n)?.displayValue),hasLearnerName:!!String(Oe(t,x,r)?.displayValue||"").trim()});if(p==="sex-header"){c=zr(b)||c,d=0;continue}if(p==="signature"||p==="helper")break;if(p!=="learner"){if(p==="blank"&&(d+=1),d>=5)break;continue}d=0;const g=_a(Oe(t,x,n)?.displayValue),C=String(Oe(t,x,r)?.displayValue||"").trim(),S=String(Oe(t,x,o)?.displayValue||"").trim()||void 0,N=String(Oe(t,x,i)?.displayValue||"").trim()||void 0,m=la.filter(w=>ke(b,w));!C&&g===void 0||l.push({learnerNo:g,sex:c,fullName:C||`Unnamed Learner ${g||x}`,sourceSheet:t.sheetName,sourceRow:x+1,remarks:S,additionalRemarks:N,statuses:m.length>0?m:void 0})}return l}function gm(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const n=ls(t,r);if(n){if(la.some(o=>ke(n,o))){s.push(n);continue}(ke(n,"IMPORTANT")||ke(n,"NOTE")||ke(n,"ATTACHMENT")||ke(n,"LOOK UP"))&&a.push(n)}}return{attachmentRules:Array.from(new Set(s)),helperNotes:Array.from(new Set(a))}}function bm(t){const s=[],a={region:Et(t,St.region),division:Et(t,St.division),schoolName:Et(t,St.schoolName),schoolId:Et(t,St.schoolId),schoolYear:Et(t,St.schoolYear),gradeSection:Et(t,St.gradeSection),semester:Et(t,St.semester),track:Et(t,St.track),subjectCode:Et(t,St.subjectCode),subjectName:Et(t,St.subjectName),teacherName:Et(t,St.teacherName)},r=fm(t),n=hm(t),{attachmentRules:o,helperNotes:i}=gm(t);return a.schoolName||s.push("Input Data metadata is missing School Name."),a.schoolYear||s.push("Input Data metadata is missing School Year."),r.length===0&&s.push("No learners detected in Input Data sheet."),Mr(t,Object.values(St).flat()).length<4&&s.push("Input Data sheet contains limited metadata anchors; layout may have drifted."),{sheetName:t.sheetName,schoolContext:a,learners:r,signatures:n,attachmentRules:o,helperNotes:i,warnings:s}}function vm(t){const s=dt(t.sheetName);return Ju.SECOND.some(a=>ke(s,a))?"SECOND":"FIRST"}function wm(t,s){const a=[],r=[],n=[];let o,i="NONE";for(let l=t.startCol;l<=t.endCol;l+=1){const c=Oe(t,s,l),d=dt(c?.displayValue||""),x=Oe(t,s+1,l),b=String(x?.displayValue||c?.displayValue||"").trim();if(!d&&!b)continue;if(ke(d,Ae.writtenWork[0])){i="WW";continue}if(ke(d,Ae.performanceTasks[0])){i="PT";continue}if(ke(d,Ae.quarterlyAssessment[0])){o={key:tr(b||"quarterly_assessment"),label:b||"Quarterly Assessment",column:Hs(l)},i="DERIVED";continue}if(ke(d,Ae.initialGrade[0])||ke(d,Ae.quarterlyGrade[0])||ke(d,Ae.remark[0])||ke(d,Ae.additionalRemarks[0])||ke(d,Ae.firstQuarter[0])||ke(d,Ae.secondQuarter[0])||ke(d,Ae.firstSemester[0])||ke(d,Ae.finalGrades[0])||ke(d,Ae.ps[0])||ke(d,Ae.ws[0])||ke(d,Ae.total[0])){i="DERIVED",n.push({key:tr(b||d),label:b||d,column:Hs(l)});continue}const p={key:tr(b||d||Hs(l)),label:b||d||Hs(l),maxScore:Na(x?.displayValue),column:Hs(l)};i==="WW"?a.push(p):i==="PT"?r.push(p):i==="DERIVED"&&n.push(p)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:o,derived:n}}function Nm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(n=>{const o=Oe(t,n.row,n.col+1),i=String(o?.displayValue||"").trim()||void 0;a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function bo(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const n=dt(Oe(t,s,r)?.displayValue||""),o=dt(Oe(t,s+1,r)?.displayValue||"");if(a.some(i=>ke(n,i)||ke(o,i)))return r}}function jm(t,s,a,r){const n={learnerNo:_a(Oe(t,s,r.numberCol)?.displayValue),fullName:String(Oe(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},o={};a.writtenWorks.forEach(d=>{const x=d.column?ha(d.column):-1;if(x<0)return;const b=Oe(t,s,x)?.displayValue;o[d.key]=b??null}),Object.keys(o).length>0&&(n.writtenWorks=o);const i={};if(a.performanceTasks.forEach(d=>{const x=d.column?ha(d.column):-1;if(x<0)return;const b=Oe(t,s,x)?.displayValue;i[d.key]=b??null}),Object.keys(i).length>0&&(n.performanceTasks=i),a.quarterlyAssessment?.column){const d=ha(a.quarterlyAssessment.column);n.quarterlyAssessment=Oe(t,s,d)?.displayValue??null}const l=a.derived||[],c={};return l.forEach(d=>{if(!d.column)return;const x=ha(d.column);if(x<0)return;const b=Oe(t,s,x)?.displayValue??null;c[d.key]=b,ke(d.label,Ae.initialGrade[0])&&(n.initialGrade=b),ke(d.label,Ae.quarterlyGrade[0])&&(n.quarterlyGrade=b),ke(d.label,Ae.firstQuarter[0])&&(n.firstQuarter=b),ke(d.label,Ae.secondQuarter[0])&&(n.secondQuarter=b),ke(d.label,Ae.firstSemester[0])&&(n.firstSemester=b),ke(d.label,Ae.finalGrades[0])&&(n.finalGrades=b),ke(d.label,Ae.remark[0])&&(n.remark=b!==null?String(b):null),ke(d.label,Ae.additionalRemarks[0])&&(n.additionalRemarks=b!==null?String(b):null)}),Object.keys(c).length>0&&(n.totals=c),n}function ym(t){const s=vm(t),a=[],r=xt(t,Ae.learnerName[0])[0]||xt(t,Ae.learnerName[1])[0],n=r?$i(t,r.row,4):t.startRow,o=wm(t,n),i=bo(t,n,Ae.learnerNo)??t.startCol,l=bo(t,n,Ae.learnerName)??Math.min(t.endCol,i+1),c=[];let d="UNKNOWN",x=0;for(let C=n+1;C<=t.endRow;C+=1){const S=ls(t,C),N=Lr({rowText:S,hasLearnerNumber:/\b\d{1,2}\b/.test(S),hasLearnerName:/[A-Z]{2,}/.test(S)});if(N==="sex-header"){d=zr(S)||d;continue}if(N==="signature"||N==="helper")break;if(N==="blank"){if(x+=1,x>=Li)break;continue}if(N!=="learner")continue;x=0;const m=jm(t,C,o,{numberCol:i,nameCol:l});if(m.sex=d,!m.fullName&&m.learnerNo===void 0)continue;const w=la.filter(y=>ke(S,y));w.length>0&&!m.additionalRemarks&&(m.additionalRemarks=w.join("; ")),!m.fullName&&m.learnerNo!==void 0&&(a.push(`Row ${C+1} has learner number ${m.learnerNo} but empty name.`),m.fullName=`Unnamed Learner ${m.learnerNo}`),c.push(m)}o.writtenWorks.length===0&&o.performanceTasks.length===0&&a.push(`No detailed assessment columns detected in ${t.sheetName}.`);const b=Na(xt(t,"WRITTEN WORK %")[0]?.value||xt(t,"WRITTEN WORK")[0]?.value),p=Na(xt(t,"PERFORMANCE TASKS %")[0]?.value||xt(t,"PERFORMANCE TASKS")[0]?.value),g=Na(xt(t,"QUARTERLY ASSESSMENT %")[0]?.value||xt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:b,performanceTasks:p,quarterlyAssessment:g},assessmentColumns:o,learnerGrades:c,signatures:Nm(t),warnings:a}}function Sm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(n=>{a.push({role:r,name:String(Oe(t,n.row,n.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function km(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const n=ls(t,r);if(!n){if(a&&s.length>0)break;continue}if(ke(n,"WEIGHT OF COMPONENTS")){a=!0;continue}if(!a)continue;const o={sourceRow:r+1,raw:n};for(let i=t.startCol;i<=t.endCol;i+=1){const l=Oe(t,r,i)?.displayValue;l==null||String(l).trim()===""||(o[`c${i}`]=l)}Object.keys(o).length>2&&s.push(o)}return s}function Cm(t){const s=[],a=[],r=[],n=[],o=[];return t.forEach(i=>{Sm(i).forEach(l=>a.push(l)),km(i).forEach(l=>r.push({...l,sourceSheet:i.sheetName}));for(let l=i.startRow;l<=i.endRow;l+=1){const c=ls(i,l);if(c){if(la.some(d=>ke(c,d))){n.push(`${i.sheetName}: ${c}`);continue}(ke(c,"HELPER")||ke(c,"LOOK UP")||ke(c,"IMPORTANT")||ke(c,"REFERENCE")||ke(c,"ATTACHMENT"))&&o.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(n)),helperNotes:Array.from(new Set(o)),signatures:a,warnings:s}}function Tm(t,s,a){const r=new Map,n=o=>{const i=`${dt(o.fullName)}|${o.learnerNo||""}|${o.sourceSheet}`,l=r.get(i);if(!l){r.set(i,o);return}const c=Array.from(new Set([...l.statuses||[],...o.statuses||[]]));r.set(i,{...l,...o,remarks:o.remarks||l.remarks,additionalRemarks:o.additionalRemarks||l.additionalRemarks,statuses:c.length>0?c:void 0})};return t.forEach(n),s.forEach(o=>{o.learnerGrades.forEach(i=>{n({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:o.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),a.forEach(o=>{o.learnerGrades.forEach(i=>{n({learnerNo:i.learnerNo,sex:i.sex,fullName:i.fullName,sourceSheet:o.sheetName,sourceRow:i.sourceRow,remarks:i.remark||void 0,additionalRemarks:i.additionalRemarks||void 0})})}),Array.from(r.values())}function Im(t,s,a,r){const n=[...t.signatures,...s.flatMap(i=>i.signatures),...a.flatMap(i=>i.signatures),...r.signatures],o=new Map;return n.forEach(i=>{const l=`${dt(i.role)}|${dt(i.name||"")}|${i.sourceSheet}`;o.set(l,i)}),Array.from(o.values())}function Em(t){const s=Tm(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:zi,version:qu,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:Im(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function _m(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 Rm(t){const s={ref:t["!ref"],merges:_m(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 Mm(t,s){const a=Yl(s,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0,raw:!1}),r={},n={};return a.SheetNames.forEach(o=>{const i=a.Sheets[o];if(!i)return;const l=Rm(i);n[o]=l,r[o]=nm(o,l)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:n},matrices:r}}async function zm(t){const s=await t.arrayBuffer();return Mm(t.name,s)}class Lm{state={};markRange(s,a,r){const n=s;this.state[n]||(this.state[n]={mappedAddresses:new Set,mappings:[]});for(let o=a.s.r;o<=a.e.r;o+=1)for(let i=a.s.c;i<=a.e.c;i+=1)this.state[n].mappedAddresses.add(`${o}:${i}`);this.state[n].mappings.push({sheetName:s,range:a,reason:r})}getMappings(){return Object.values(this.state).flatMap(s=>s.mappings)}getMappedRegionCount(){return this.getMappings().length}getUnmappedBlocks(s,a="unclassified"){const r=[];return Object.values(s).forEach(n=>{const o=new Set,i=this.state[n.sheetName]?.mappedAddresses??new Set;for(let l=n.startRow;l<=n.endRow;l+=1)for(let c=n.startCol;c<=n.endCol;c+=1){const d=`${l}:${c}`;if(o.has(d)||i.has(d))continue;const x=Oe(n,l,c);if(!(x&&x.displayValue!==null&&x.displayValue!==void 0&&String(x.displayValue).trim())){o.add(d);continue}const p=this.collectComponent(n,l,c,i,o);p&&r.push({sheetName:n.sheetName,range:om(p),purposeGuess:a,raw2D:im(n,p)})}}),r}collectComponent(s,a,r,n,o){const i=[{row:a,col:r}];let l=a,c=a,d=r,x=r,b=!1;for(;i.length>0;){const p=i.shift();if(!p)break;const g=`${p.row}:${p.col}`;if(o.has(g)||n.has(g))continue;o.add(g);const C=Oe(s,p.row,p.col);C&&C.displayValue!==null&&C.displayValue!==void 0&&String(C.displayValue).trim()&&(b=!0,l=Math.min(l,p.row),c=Math.max(c,p.row),d=Math.min(d,p.col),x=Math.max(x,p.col),[{row:p.row-1,col:p.col},{row:p.row+1,col:p.col},{row:p.row,col:p.col-1},{row:p.row,col:p.col+1}].forEach(N=>{N.rows.endRow||N.cols.endCol||i.push(N)}))}return b?{s:{r:l,c:d},e:{r:c,c:x}}:null}}function Am(t){const s=t.detection.detectedSheets,a=[s.inputData?1:0,s.firstQuarter.length,s.secondQuarter.length,s.finalSemestral.length,s.helper.length,s.lookup.length].reduce((r,n)=>r+n,0);return{totalSheets:t.totalSheets,recognizedSheets:a,unclassifiedSheets:s.other.length,mappedCellRegions:t.mappedCellRegions,unmappedCellRegions:t.unmappedCellRegions}}function Dm(t){const s=new Map;t.forEach(r=>{const n=`${r.learnerNo||""}|${r.fullName.trim().toUpperCase()}`;s.has(n)||s.set(n,[]),s.get(n)?.push(r.sourceRow)});const a=[];return s.forEach((r,n)=>{r.length>1&&a.push(`Duplicate learner entry detected for ${n} at rows ${r.join(", ")}.`)}),a}function Fm(t){const s=[];return t.forEach(a=>{a.learnerGrades.forEach(r=>{r.fullName.trim()||s.push(`${a.sheetName} row ${r.sourceRow}: learner name is blank.`);const n=r.writtenWorks&&Object.values(r.writtenWorks).some(i=>i!==null&&i!==""),o=r.performanceTasks&&Object.values(r.performanceTasks).some(i=>i!==null&&i!=="");!n&&!o&&r.quarterlyAssessment==null&&s.push(`${a.sheetName} row ${r.sourceRow}: all grade blocks are empty.`)})}),s}function $m(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 Om(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(", ")}.`),Dm(t.inputData.learners).forEach(o=>s.push(o)),Fm(t.quarterSheets).forEach(o=>s.push(o)),$m(t.finalSheets).forEach(o=>s.push(o)),s.push(...t.inputData.warnings),t.quarterSheets.forEach(o=>s.push(...o.warnings)),t.finalSheets.forEach(o=>s.push(...o.warnings)),t.unmappedCellRegions>t.mappedCellRegions&&s.push("A significant portion of workbook regions are unclassified; review diagnostics before confirming import.");const r=t.detection.confidence,n=t.detection.isOfficialFormatLikely&&a.length===0;return r({fullName: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}))),n=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}))),o=[...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,...n],remarksEntities:o}}const vo=1500;function wo(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function No(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>=vo){console.warn(`${s} slow=true threshold=${vo}ms`);return}}function us(t,s){t?.onProgress?.(s)}function Pm(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 Gs(t,s,a,r){Pm(a,s).forEach(n=>{t.markRange(s.sheetName,{s:{r:n,c:s.startCol},e:{r:n,c:s.endCol}},r)})}async function Hm(t,s){const a=s?.confidenceThreshold??Wu,r=Date.now();let n=null;try{if(us(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),n=await zm(t),!n)throw new Error("Workbook read returned null");us(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const o=mm(n);us(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const i=o.detectedSheets.inputData||n.sheetNames[0],l=n.matrices[i],c=l?bm(l):{sheetName:i,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},x=[...o.detectedSheets.firstQuarter||[],...o.detectedSheets.secondQuarter||[]].map(y=>n.matrices[y]).filter(y=>!!y).map(y=>ym(y)),b=(o.detectedSheets.finalSemestral||[]).map(y=>n.matrices[y]).filter(y=>!!y).map(y=>pm(y)),p=[...o.detectedSheets.helper||[],...o.detectedSheets.lookup||[]].map(y=>n.matrices[y]).filter(y=>!!y),g=Cm(p),C=new Lm;o.anchorMatches.forEach(y=>{const R=n.matrices[y.sheetName];R&&Gs(C,R,[y.row],`Anchor match: ${y.anchor}`)}),[c.sheetName].forEach(y=>{const R=n.matrices[y];if(!R)return;const j=Array.from({length:Math.min(14,R.rowCount)},(k,I)=>R.startRow+I),H=c.learners.map(k=>k.sourceRow-1),v=c.signatures.map(k=>k.sourceRow).filter(k=>typeof k=="number").map(k=>k-1);Gs(C,R,[...j,...H,...v],"Input Data parsed rows")}),x.forEach(y=>{const R=n.matrices[y.sheetName];if(!R)return;const j=y.learnerGrades.map(k=>k.sourceRow-1),H=y.signatures.map(k=>k.sourceRow).filter(k=>typeof k=="number").map(k=>k-1),v=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Gs(C,R,[v,v+1,...j,...H],"Quarter sheet parsed rows")}),b.forEach(y=>{const R=n.matrices[y.sheetName];if(!R)return;const j=y.learnerGrades.map(k=>k.sourceRow-1),H=y.signatures.map(k=>k.sourceRow).filter(k=>typeof k=="number").map(k=>k-1),v=j.length>0?Math.max(R.startRow,Math.min(...j)-2):R.startRow;Gs(C,R,[v,v+1,...j,...H],"Final semestral parsed rows")}),p.forEach(y=>{const R=g.componentWeights.filter(v=>v.sourceSheet===y.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1),j=g.signatures?.filter(v=>v.sourceSheet===y.sheetName).map(v=>v.sourceRow).filter(v=>typeof v=="number").map(v=>v-1)||[],H=R.length===0&&j.length===0?[y.startRow,y.startRow+1,y.startRow+2]:[];Gs(C,y,[...R,...j,...H],"Reference/helper parsed rows")});const S=C.getUnmappedBlocks(n.matrices);us(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const N=Om({detection:o,inputData:c,quarterSheets:x,finalSheets:b,mappedCellRegions:C.getMappedRegionCount(),unmappedCellRegions:S.length,totalSheets:n.sheetNames.length});us(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const m=Em({workbook:n,detection:o,inputData:c,quarterSheets:x,finalSheets:b,references:g,validation:N,unclassifiedBlocks:S});m.validation.confidencef.trim().toLowerCase().replace(/\s+/g," "),ie=f=>{if(typeof f=="number"&&Number.isFinite(f))return f;const T=Number(String(f??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(T)?T:null},je=(f,T)=>{const E=Number.isFinite(f)?f:T;return Math.max(0,Math.min(100,E))},ge=f=>{const T=String(f??"");return/[",\n]/.test(T)?`"${T.replace(/"/g,'""')}"`:T},Ce=(f,T)=>{const E=new Map,W=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];f.mapping.gradeEntities.forEach(K=>{const we=ee(K.fullName||"");if(!we)return;const We=W.map(Je=>ie(K[Je])).filter(Je=>Je!==null);if(We.length===0)return;const Se=E.get(we)||[];E.set(we,Se.concat(We))});const V=f.mapping.studentEntities||[];if(V.length===0)return null;const se=(f.imported.schoolContext.semester||f.imported.schoolContext.schoolYear||"First Semester").trim(),ae=(f.imported.schoolContext.subjectName||"Class Record Import").trim(),z=(t||s||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",ue=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(V.forEach((K,we)=>{const We=ee(K.fullName||""),Se=E.get(We)||[],Je=Se.length>0?Se.reduce((_e,Fe)=>_e+Fe,0)/Se.length:75,et=je(Je,75),F=je(et+5,85),Z=je(et*.7+F*.3,80),Re=je(F*.6+et*.4,82),Ne=K.learnerNo||we+1,M=`IMP-${z}-${String(Ne).padStart(4,"0")}`,te=K.fullName||`Learner ${we+1}`;ue.push([ge(te),ge(M),ge(""),ge(Number(Z.toFixed(1))),ge(Number(et.toFixed(1))),ge(Number(F.toFixed(1))),ge(Number(Re.toFixed(1))),ge(se),ge(ae)].join(","))}),ue.length<=1)return null;const ve=T.replace(/\.(xlsx|xls)$/i,"");return new File([ue.join(` -`)],`${ve}-normalized.csv`,{type:"text/csv"})},de=async f=>{v(!0),D(""),Q(null);let T=f;if(/\.(xlsx|xls)$/i.test(f.name))try{const E=await Hm(f,{confidenceThreshold:hr});m(E);const W=Ce(E,f.name);W&&(T=W)}catch{m(null)}else m(null);try{const E=await Ze.uploadClassRecords(T,{classSectionId:t,className:s,datasetIntent:"synthetic_student_records"}),W=E.students.length,se=((ae,z,oe,ue)=>({classSectionId:ae.classSectionId||z||"imported_class",className:ae.className||oe||"Imported Class",classMetadata:ae.classMetadata||ue}))(E,t,s,a);W>0&&i?.({students:E.students,classSectionId:se.classSectionId,className:se.className,classMetadata:se.classMetadata}),E.success?(me.success(`Successfully imported ${W} student records.`),Q({datasetIntent:E.datasetIntent,summary:E.interpretationSummary,columns:E.columnInterpretations?.map(ae=>({columnName:ae.columnName,mappedField:ae.mappedField,usagePolicy:ae.usagePolicy,confidenceBand:ae.confidenceBand,domainSignals:ae.domainSignals}))||[]}),l?.()):me.error("Import completed but no usable student rows were detected. Check required columns and retry.")}catch(E){me.error(E instanceof Error?E.message:"Upload failed")}finally{v(!1)}},B=async f=>{I(!0);try{const T=await Ze.uploadCourseMaterials(f,{classSectionId:t,className:s});if(T.success){const E=T.topics?.length??0;me.success(`Course material imported (${E} topics extracted).`),l?.()}}catch(T){me.error(T instanceof Error?T.message:"Course material upload failed")}finally{I(!1)}},[Y,ne]=h.useState(r),[De,Le]=h.useState(!1);h.useEffect(()=>{ne(r),O(Object.fromEntries(r.map(f=>[fa(f),{grade:f.grade||"Grade 11",section:f.section||"Section A"}])))},[r]);const[Ge,O]=h.useState({}),X=async()=>{Le(!0);try{for(const T of Y){const E=Ge[fa(T)],W=E?.grade||T.grade,V=E?.section||T.section;n&&(W!==T.grade||V!==T.section)&&(await Ei(T.id,W,V,n,new Date().getFullYear().toString(),o),await Ci(T.id,W,V));try{const se=await Ze.predictRisk({engagementScore:T.engagementScore,avgQuizScore:T.avgScore,attendance:T.attendance,assignmentCompletion:T.assignmentCompletion});await ru(T.id,se.riskLevel,se.confidence)}catch(se){console.error("Failed to update risk:",se)}}const f=Y.map(T=>{const E=Ge[fa(T)];if(!E)return T;const W=mt({metadata:T.classMetadata,classSectionId:T.classSectionId,className:[E.grade,E.section].filter(Boolean).join(" - "),grade:E.grade,section:E.section});return{...T,grade:E.grade,section:E.section,className:W.className||[E.grade,E.section].filter(Boolean).join(" - "),classSectionId:W.classSectionId||T.classSectionId,classMetadata:W}});ne(f),d?.(f),me.success("Records saved and risk levels updated"),S("main")}catch{me.error("Failed to save changes")}finally{Le(!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:[C==="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(ya,{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(_t,{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:f=>{f.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:f=>{f.preventDefault(),y(!1);const T=f.dataTransfer.files[0];T&&de(T)},onClick:()=>A.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] ${w?"border-[#1FA7E1] bg-[#1FA7E1]/10":"border-[#1FA7E1]/30 hover:border-[#1FA7E1] bg-white hover:bg-[#1FA7E1]/5"}`,children:[e.jsx("input",{ref:A,type:"file",accept:".csv,.xlsx,.xls",onChange:f=>{const T=f.target.files?.[0];T&&de(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:H?e.jsx("span",{className:"animate-spin text-[#1FA7E1]",children:"..."}):e.jsx(wc,{className:"w-8 h-8 text-[#1FA7E1]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:H?"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:f=>{f.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:f=>{f.preventDefault(),j(!1);const T=f.dataTransfer.files[0];T&&B(T)},onClick:()=>U.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] ${R?"border-[#9956DE] bg-[#9956DE]/10":"border-[#9956DE]/30 hover:border-[#9956DE] bg-white hover:bg-[#9956DE]/5"}`,children:[e.jsx("input",{ref:U,type:"file",accept:".pdf,.docx,.txt",onChange:f=>{const T=f.target.files?.[0];T&&B(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:k?e.jsx("span",{className:"animate-spin text-[#9956DE]",children:"..."}):e.jsx(Wt,{className:"w-8 h-8 text-[#9956DE]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:k?"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(bc,{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(Bo,{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(ss,{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(Ra,{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:()=>S("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(xc,{className:"w-4 h-4"})," Edit Class Records"]}),e.jsx("button",{onClick:()=>S("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:()=>S("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(ic,{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."})]})]})]})]}),C==="mapping-logs"&&e.jsxs("div",{className:"space-y-[16px]",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>S("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(Sa,{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:q?e.jsx("div",{className:"space-y-3",children:q.columns.map((f,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:f.columnName}),e.jsx("span",{className:"text-sm text-indigo-600",children:f.mappedField||"Unmapped"})]},T))}):e.jsx("p",{className:"text-slate-500 text-sm",children:"No recent mapping logs to display."})})]})]}),C==="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:()=>S("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(Sa,{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:()=>S("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:X,disabled:De,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:De?"Saving...":e.jsxs(e.Fragment,{children:[e.jsx(Po,{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(Us,{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((f,T)=>{const E=fa(f),W=f.name.split(" "),V=W.length>1?`${W[0][0]}${W[W.length-1][0]}`.toUpperCase():f.name.substring(0,2).toUpperCase(),se=["bg-[#be185d]","bg-[#3b82f6]","bg-[#f43f5e]","bg-[#2563eb]","bg-[#059669]","bg-[#d946ef]"],ae=se[T%se.length],z=(f.avgScore??0)>=75?"text-emerald-500":(f.avgScore??0)>=60?"text-orange-500":"text-rose-500";let oe="bg-slate-50 text-slate-600 border-slate-200";const ue=(f.riskLevel||"").toLowerCase();return ue==="low"?oe="bg-emerald-50 text-emerald-600 border-emerald-200":ue==="high"?oe="bg-rose-50 text-rose-600 border-rose-200":ue==="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 ${ae} text-white flex items-center justify-center font-bold text-[12px] shrink-0`,children:V}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:f.name})]}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center text-[13px] text-slate-500",children:f.lrn||"—"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Ge[E]?.grade||f.grade||"",onChange:ve=>O(K=>({...K,[E]:{...K[E],grade:ve.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[E]?.section||f.section||"",onChange:ve=>O(K=>({...K,[E]:{...K[E],section:ve.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:`${z} font-bold text-[14px]`,children:[f.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:f.riskLevel||"Unknown"})}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 flex justify-center text-[13px] text-slate-600 truncate",children:f.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(Qo,{className:"w-4 h-4 text-slate-400"})})})]},E)})})]})})]})]})]})})}function Qm(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=mt({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 Vm(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?Oi(t.lastActive.toDate()):"Unknown",n=t.className||s||"Imported Class",o=Pt(n),i=t.grade||o.grade,l=t.section||o.section,c=mt({metadata:t.classMetadata,classSectionId:t.classSectionId||t.classroomId,className:[i,l].filter(Boolean).join(" - ")||n,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||n,className:c.className||[i,l].filter(Boolean).join(" - ")||n,grade:i,gradeLevel:c.gradeLevel||ws(i)||void 0,classification:c.classification||As(c.gradeLevel||i)||void 0,strand:c.strand||Ds(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}}function Um(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=mt({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 Wm(t){const s=(t.riskLevel||"Low").toLowerCase(),a=mt({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||Pt(r).grade,gradeLevel:a.gradeLevel||ws(a.grade||Pt(r).grade)||void 0,classification:a.classification||As(a.gradeLevel||a.grade)||void 0,strand:a.strand||Ds(r,a.section||t.section)||void 0,section:a.section||Pt(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 qm(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function Ym(t,s,a,r){const n=mt({metadata:r,classSectionId:s,className:a}),o=n.className||"Imported Class",i=n.classSectionId||"imported_class",l=Number(t.avgQuizScore||0),c=Number(t.attendance||0),d=Number(t.engagementScore||0),x=Number(t.assignmentCompletion||0),b=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",p=qm(l,c,d),g=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${i}-${g}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:l,riskLevel:p,weakestTopic:b,classroomId:i,className:o,grade:n.grade||Pt(o).grade,gradeLevel:n.gradeLevel||ws(n.grade||Pt(o).grade)||void 0,classification:n.classification||As(n.gradeLevel||n.grade)||void 0,strand:n.strand||Ds(o,n.section)||void 0,section:n.section||Pt(o).section,classSectionId:i,classMetadata:n,managerId:n.managerId||void 0,managerName:n.managerName||void 0,lastActive:"Recently imported",struggles:[b],engagementScore:d,attendance:c,assignmentCompletion:x}}function Oi(t){const s=Date.now()-t.getTime(),a=Math.floor(s/6e4);if(a<1)return"Just now";if(a<60)return`${a} min${a>1?"s":""} ago`;const r=Math.floor(a/60);if(r<24)return`${r} hour${r>1?"s":""} ago`;const n=Math.floor(r/24);return`${n} day${n>1?"s":""} ago`}function it(t){return(t||"").trim().toLowerCase()}function yo(t){const s=it(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function So(t,s){const a=new Map;return t.forEach(r=>{a.set(yo(r),r)}),s.forEach(r=>{const n=yo(r),o=a.get(n);if(!o){a.set(n,r);return}const i=Math.max(o.atRiskCount||0,r.atRiskCount||0),l=Math.max(o.studentCount||0,r.studentCount||0),c=r.avgScore>0?r.avgScore:o.avgScore,d=i>=5?"high":i>=2?"medium":"low",x=mt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.name||r.name,grade:o.classMetadata?.grade||r.classMetadata?.grade,gradeLevel:o.classMetadata?.gradeLevel||r.classMetadata?.gradeLevel,classification:o.classMetadata?.classification||r.classMetadata?.classification,strand:o.classMetadata?.strand||r.classMetadata?.strand,section:o.classMetadata?.section||r.classMetadata?.section,schoolYear:o.classMetadata?.schoolYear||r.classMetadata?.schoolYear,ownerTeacherId:o.classMetadata?.ownerTeacherId||r.classMetadata?.ownerTeacherId,ownerTeacherName:o.classMetadata?.ownerTeacherName||r.classMetadata?.ownerTeacherName,adviserTeacherId:o.classMetadata?.adviserTeacherId||r.classMetadata?.adviserTeacherId,adviserTeacherName:o.classMetadata?.adviserTeacherName||r.classMetadata?.adviserTeacherName,managerId:o.classMetadata?.managerId||r.classMetadata?.managerId,managerName:o.classMetadata?.managerName||r.classMetadata?.managerName});a.set(n,{...o,classSectionId:x.classSectionId||o.classSectionId||r.classSectionId,name:x.className||o.name||r.name,classMetadata:x,gradeLevel:x.gradeLevel||void 0,classification:x.classification||void 0,strand:x.strand||void 0,managerId:x.managerId||void 0,managerName:x.managerName||void 0,schedule:o.schedule||r.schedule,studentCount:l,atRiskCount:i,avgScore:c,riskLevel:d})}),Array.from(a.values())}function ko(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=it(t.classSectionId)||it(t.classroomId),n=(t.id||"").trim().toLowerCase();return r&&n?`${r}|id:${n}`:`${r}|anonymous`}function fr(t){const s=it(t.classSectionId)||it(t.classroomId),a=(t.lrn||"").trim().toLowerCase(),r=(t.id||"").trim().toLowerCase(),n=t.name.trim().toLowerCase().replace(/\s+/g,"_");return s&&a?`${s}|lrn:${a}`:s&&r?`${s}|id:${r}`:a?`lrn:${a}`:r&&n?`id:${r}|name:${n}`:r?`id:${r}`:s&&n?`${s}|name:${n}`:`name:${n||"unknown"}`}function Co(t,s){const a=new Map;return t.forEach(r=>{a.set(ko(r),r)}),s.forEach(r=>{const n=ko(r),o=a.get(n);if(!o){a.set(n,r);return}const i=[o.riskLevel,r.riskLevel].includes("high")?"high":[o.riskLevel,r.riskLevel].includes("medium")?"medium":"low",l=mt({metadata:o.classMetadata,classSectionId:o.classSectionId||r.classSectionId,className:o.className||r.className,grade:o.grade||r.grade,gradeLevel:o.gradeLevel||r.gradeLevel,classification:o.classification||r.classification,strand:o.strand||r.strand,section:o.section||r.section,managerId:o.managerId||r.managerId,managerName:o.managerName||r.managerName});a.set(n,{...o,lrn:o.lrn||r.lrn,classSectionId:l.classSectionId||o.classSectionId||r.classSectionId,classroomId:o.classroomId||r.classroomId,className:l.className||o.className||r.className,grade:l.grade||o.grade||r.grade,gradeLevel:l.gradeLevel||o.gradeLevel||r.gradeLevel,classification:l.classification||o.classification||r.classification,strand:l.strand||o.strand||r.strand,section:l.section||o.section||r.section,managerId:l.managerId||o.managerId||r.managerId,managerName:l.managerName||o.managerName||r.managerName,classMetadata:l,avgScore:r.avgScore>0?r.avgScore:o.avgScore,attendance:r.attendance>0?r.attendance:o.attendance,engagementScore:r.engagementScore>0?r.engagementScore:o.engagementScore,assignmentCompletion:r.assignmentCompletion>0?r.assignmentCompletion:o.assignmentCompletion,weakestTopic:o.weakestTopic&&o.weakestTopic!=="N/A"?o.weakestTopic:r.weakestTopic,riskLevel:i,struggles:o.struggles.length>0?o.struggles:r.struggles})}),Array.from(a.values())}const Jx=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:n}=gs(),[o,i]=h.useState("dashboard"),[l,c]=h.useState(!1),[d,x]=h.useState(!1),[b,p]=h.useState(!1),[g,C]=h.useState(!1),[S,N]=h.useState(!1),[m,w]=h.useState(null),[y,R]=h.useState(null),[j,H]=h.useState(!1),[v,k]=h.useState(!1),[I,$]=h.useState(!1),[D,q]=h.useState([]),[Q,A]=h.useState([]),[U,ee]=h.useState([]),[ie,je]=h.useState(""),[ge,Ce]=h.useState(!0),[de,B]=h.useState(!1),[Y,ne]=h.useState(0),[De,Le]=h.useState([]),[Ge,O]=h.useState(!1),X=h.useRef(new Map);h.useEffect(()=>{if(!r)return;const F=r.uid;let Z=!0,Re;return(async()=>{Ce(!0);try{const M=await Ti(F);let te=M.map(Qm);const _e=await iu(F).catch(()=>[]),Fe=new Map;_e.forEach(J=>{const xe=it(J.classSectionId);xe&&Fe.set(xe,J)}),te=te.map(J=>{const xe=Fe.get(it(J.classSectionId));if(!xe)return J;const Ue=mt({metadata:J.classMetadata,classSectionId:xe.classSectionId||J.classSectionId,className:xe.className||J.name,grade:xe.grade||J.classMetadata?.grade,gradeLevel:xe.gradeLevel||J.classMetadata?.gradeLevel,classification:xe.classification||J.classMetadata?.classification,strand:xe.strand||J.classMetadata?.strand,section:xe.section||J.classMetadata?.section,schoolYear:xe.schoolYear||J.classMetadata?.schoolYear,ownerTeacherId:xe.ownerTeacherId||J.classMetadata?.ownerTeacherId,ownerTeacherName:xe.ownerTeacherName||J.classMetadata?.ownerTeacherName,managerId:xe.managerId||J.classMetadata?.managerId,managerName:xe.managerName||J.classMetadata?.managerName});return{...J,name:Ue.className||J.name,classSectionId:Ue.classSectionId||J.classSectionId,classMetadata:Ue,gradeLevel:Ue.gradeLevel||J.gradeLevel,classification:Ue.classification||J.classification,strand:Ue.strand||J.strand,managerId:Ue.managerId||J.managerId,managerName:Ue.managerName||J.managerName}});const be=new Map,ot=new Map;M.forEach(J=>{const xe=mt({metadata:J.classMetadata,classSectionId:J.classSectionId,className:J.name,grade:J.grade,gradeLevel:J.gradeLevel,classification:J.classification,strand:J.strand,section:J.section,schoolYear:J.schoolYear,ownerTeacherId:J.ownerTeacherId||J.teacherId,ownerTeacherName:J.ownerTeacherName,adviserTeacherId:J.adviserTeacherId||J.teacherId,adviserTeacherName:J.adviserTeacherName,managerId:J.managerId,managerName:J.managerName});be.set(J.id,xe.className||J.name),ot.set(J.id,xe);const Ue=it(J.classSectionId);if(Ue){const Ee=Fe.get(Ue),lt=mt({metadata:xe,classSectionId:Ee?.classSectionId||Ue,className:Ee?.className||xe.className,grade:Ee?.grade||xe.grade,gradeLevel:Ee?.gradeLevel||xe.gradeLevel,classification:Ee?.classification||xe.classification,strand:Ee?.strand||xe.strand,section:Ee?.section||xe.section,schoolYear:Ee?.schoolYear||xe.schoolYear,ownerTeacherId:Ee?.ownerTeacherId||xe.ownerTeacherId,ownerTeacherName:Ee?.ownerTeacherName||xe.ownerTeacherName,managerId:Ee?.managerId||xe.managerId,managerName:Ee?.managerName||xe.managerName});be.set(Ue,lt.className||J.name),ot.set(Ue,lt)}});const Dt=(await Rr(F)).map(J=>{const xe=it(J.classSectionId||J.classroomId),Ue=be.get(J.classroomId)||(xe?be.get(xe):void 0)||J.className||"Unknown",Ee=Vm(J,Ue);if(!xe)return Ee;const lt=ot.get(xe);if(!lt)return Ee;const wt=mt({metadata:lt,classSectionId:Ee.classSectionId||lt.classSectionId,className:Ee.className||lt.className,grade:Ee.grade||lt.grade,gradeLevel:Ee.gradeLevel||lt.gradeLevel,classification:Ee.classification||lt.classification,strand:Ee.strand||lt.strand,section:Ee.section||lt.section,managerId:Ee.managerId||lt.managerId,managerName:Ee.managerName||lt.managerName});return{...Ee,className:wt.className||Ee.className,grade:wt.grade||Ee.grade,gradeLevel:wt.gradeLevel||Ee.gradeLevel,classification:wt.classification||Ee.classification,strand:wt.strand||Ee.strand,section:wt.section||Ee.section,classSectionId:wt.classSectionId||Ee.classSectionId,classMetadata:wt,managerId:wt.managerId||Ee.managerId,managerName:wt.managerName||Ee.managerName}});if(!Z)return;q(J=>te.length===0&&J.length>0?J:te),A(J=>Dt.length===0&&J.length>0?J:Dt),Ze.getImportedClassOverview({limit:3e3,forceRefresh:Y>0}).then(J=>{Z&&(J.warnings.length>0&&console.warn("Imported class overview warnings:",J.warnings.join(" ")),q(xe=>So(xe,J.classrooms.map(Um))),A(xe=>Co(xe,J.students.map(Wm))))}).catch(J=>{console.warn("Imported class overview merge unavailable:",J)});const Ns=M.map(J=>J.id);Ns.length>0&&(Re=cu(Ns,J=>{Z&&ee(J.map(xe=>({id:xe.id,student:xe.studentName,action:xe.action,topic:xe.topic,time:Oi(xe.timestamp.toDate()),type:xe.type})))}))}catch(M){console.error("Failed to load teacher data:",M),me.error("Failed to load dashboard data")}finally{Ce(!1)}})(),()=>{Z=!1,Re&&Re()}},[r,Y]),h.useEffect(()=>{if(!r)return;let F=!0;return lu("",80).then(Z=>{F&&Le(Z)}).catch(Z=>{console.warn("Failed to load teacher directory options:",Z)}),()=>{F=!1}},[r]),h.useEffect(()=>{if(Q.length===0)return;(async()=>{B(!0);try{const Z=Q.map(Ne=>({name:Ne.name,engagementScore:Ne.engagementScore,avgQuizScore:Ne.avgScore,attendance:Ne.attendance,riskLevel:Ne.riskLevel})),Re=await Ze.getDailyInsight({students:Z});je(Re.insight)}catch{je(`${Q.filter(Z=>Z.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{B(!1)}})()},[Q]);const f=D.reduce((F,Z)=>F+Z.studentCount,0),T=D.reduce((F,Z)=>F+Z.atRiskCount,0),E=D.length>0?Math.round(D.reduce((F,Z)=>F+Z.avgScore,0)/D.length):0,W=[{name:"High Risk",value:Q.filter(F=>F.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:Q.filter(F=>F.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:Q.filter(F=>F.riskLevel==="low").length,color:"#75D06A"}],V={};Q.forEach(F=>{F.weakestTopic&&F.weakestTopic!=="N/A"&&(V[F.weakestTopic]||(V[F.weakestTopic]={total:0,sum:0}),V[F.weakestTopic].total+=1,V[F.weakestTopic].sum+=F.avgScore)});const se=Object.entries(V).map(([F,Z])=>({topic:F,score:Math.round(Z.sum/Z.total)})).sort((F,Z)=>F.score-Z.score).slice(0,6),ae=F=>{w(F),i("analytics")},z=F=>{R(F),i("intervention")},oe=()=>{R(null),i("analytics")},ue=()=>{w(null),R(null),i("dashboard")},ve=async(F,Z)=>{if(!r){me.error("Unable to assign manager: teacher context is missing.");return}const Re=Pt(F.classMetadata?.className||F.name),Ne=mt({metadata:F.classMetadata,classSectionId:F.classSectionId,className:F.name,grade:F.classMetadata?.grade||Re.grade,gradeLevel:F.classMetadata?.gradeLevel,classification:F.classMetadata?.classification,strand:F.classMetadata?.strand,section:F.classMetadata?.section||Re.section,schoolYear:F.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:F.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:F.classMetadata?.ownerTeacherName||we,adviserTeacherId:F.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:F.classMetadata?.adviserTeacherName||we,managerId:Z.uid,managerName:Z.name}),M=Ne.classSectionId||zt(Ne.grade||Re.grade,Ne.section||Re.section);if(!M){me.error("Unable to assign manager: missing class section ID.");return}O(!0);try{await ou({classSectionId:M,className:Ne.className||F.name,grade:Ne.grade||Re.grade,gradeLevel:Ne.gradeLevel||ws(Ne.grade||Re.grade)||Ne.grade||Re.grade,classification:Ne.classification||As(Ne.gradeLevel||Ne.grade)||void 0,strand:Ne.strand||Ds(Ne.className,Ne.section)||void 0,section:Ne.section||Re.section,schoolYear:Ne.schoolYear||String(new Date().getFullYear()),ownerTeacherId:Ne.ownerTeacherId||r.uid,ownerTeacherName:Ne.ownerTeacherName||we,managerId:Z.uid,managerName:Z.name});const te=mt({metadata:Ne,classSectionId:M,managerId:Z.uid,managerName:Z.name}),_e=it(M);q(Fe=>Fe.map(be=>it(be.classSectionId)!==_e?be:{...be,name:te.className||be.name,classSectionId:te.classSectionId||be.classSectionId,classMetadata:te,gradeLevel:te.gradeLevel||be.gradeLevel,classification:te.classification||be.classification,strand:te.strand||be.strand,managerId:Z.uid,managerName:Z.name})),A(Fe=>Fe.map(be=>{if(it(be.classSectionId||be.classroomId)!==_e)return be;const gt=mt({metadata:be.classMetadata,classSectionId:te.classSectionId||be.classSectionId,className:be.className||te.className,grade:be.grade||te.grade,gradeLevel:be.gradeLevel||te.gradeLevel,classification:be.classification||te.classification,strand:be.strand||te.strand,section:be.section||te.section,managerId:Z.uid,managerName:Z.name});return{...be,classMetadata:gt,gradeLevel:gt.gradeLevel||be.gradeLevel,classification:gt.classification||be.classification,strand:gt.strand||be.strand,managerId:Z.uid,managerName:Z.name}})),w(Fe=>!Fe||it(Fe.classSectionId)!==_e?Fe:{...Fe,classMetadata:te,managerId:Z.uid,managerName:Z.name,gradeLevel:te.gradeLevel||Fe.gradeLevel,classification:te.classification||Fe.classification,strand:te.strand||Fe.strand}),me.success(`Assigned ${Z.name} as section manager.`)}catch(te){console.error("Failed to assign class manager:",te),me.error(te instanceof Error?te.message:"Failed to assign class manager")}finally{O(!1)}};h.useEffect(()=>{const F=()=>{const Z=window.innerWidth<1024;C(Z),Z?c(!1):p(!1)};return F(),window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),h.useEffect(()=>{g&&p(!1)},[o,g]);const K=F=>{i(F),w(null),R(null)},we=n?.name||"Teacher",We=h.useMemo(()=>{if(!m)return;if(m.classMetadata?.classSectionId)return m.classMetadata.classSectionId||void 0;if(m.classSectionId)return m.classSectionId;const F=Pt(m.classMetadata?.className||m.name);return zt(F.grade,F.section)||void 0},[m]),Se=h.useMemo(()=>m||null,[m]),Je=h.useMemo(()=>{if(!Se)return;const F=D.findIndex(Z=>Z.id===Se.id);return Ea[Math.max(0,F)%Ea.length]},[Se,D]),et=h.useMemo(()=>{if(!Se)return Q;const F=(Se.id||"").trim().toLowerCase(),Z=it(Se.classSectionId),Re=(Se.name||"").trim().toLowerCase();return Q.filter(Ne=>{const M=it(Ne.classroomId),te=it(Ne.classSectionId),_e=(Ne.className||"").trim().toLowerCase();return Z&&(te===Z||M===Z)||F&&(M===F||te===F)||Re&&_e===Re})},[Se,Q]);return ge?e.jsxs("div",{className:"flex h-screen w-full bg-background p-6",children:[e.jsx("div",{className:"hidden lg:flex w-[280px] shrink-0 rounded-3xl border border-border bg-card p-5",children:e.jsxs("div",{className:"w-full space-y-4",children:[e.jsx(Me,{className:"h-12 w-40"}),e.jsx(Me,{className:"h-10 w-full"}),e.jsx(Me,{className:"h-10 w-full"}),e.jsx(Me,{className:"h-10 w-full"}),e.jsx(Me,{className:"h-10 w-full"})]})}),e.jsxs("div",{className:"flex-1 space-y-4 lg:pl-6",children:[e.jsx(Me,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Me,{className:"h-28 w-full rounded-2xl"}),e.jsx(Me,{className:"h-28 w-full rounded-2xl"}),e.jsx(Me,{className:"h-28 w-full rounded-2xl"})]}),e.jsx(Me,{className:"h-[420px] w-full rounded-2xl"})]})]}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[g&&b&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>p(!1)}),e.jsxs(Pe.aside,{initial:!1,animate:{width:g?280:l&&!d?80:280,x:g?b?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!g&&l&&x(!0),onMouseLeave:()=>x(!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"})})]}),!g&&(!l||d)&&e.jsx(Pe.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(es,{size:20}):e.jsx(as,{size:20})}),g&&e.jsx("button",{onClick:()=>p(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(ps,{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(Jt,{icon:jl,label:"Dashboard",active:o==="dashboard",collapsed:l&&!d,onClick:ue,forceExpanded:g}),e.jsx(Jt,{icon:hs,label:"Class Analytics",active:o==="analytics",collapsed:l&&!d,onClick:()=>K("analytics"),forceExpanded:g})]})]}),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(Jt,{icon:Yt,label:"Topic Mastery",active:o==="topic_mastery",collapsed:l&&!d,onClick:()=>K("topic_mastery"),forceExpanded:g}),e.jsx(Jt,{icon:Rt,label:"Competency",active:o==="competency",collapsed:l&&!d,onClick:()=>K("competency"),forceExpanded:g})]})]}),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(Jt,{icon:Fl,label:"Data Import",active:o==="import",collapsed:l&&!d,onClick:()=>i("import"),forceExpanded:g}),e.jsx(Jt,{icon:Ho,label:"AI Quiz Maker",active:o==="quiz_maker",collapsed:l&&!d,onClick:()=>i("quiz_maker"),forceExpanded:g}),e.jsx(Jt,{icon:Lt,label:"Question Bank",active:o==="question_bank",collapsed:l&&!d,onClick:()=>i("question_bank"),forceExpanded:g}),e.jsx(Jt,{icon:Mo,label:"Calendar",active:o==="calendar",collapsed:l&&!d,onClick:()=>i("calendar"),forceExpanded:g})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t border-[#dde3eb] pt-4",children:[e.jsxs(Pe.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(yl,{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(Sl,{onClick:()=>N(!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(o)&&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-col sm:flex-row sm:items-start justify-between gap-4 mb-0",children:[e.jsxs("div",{className:"flex-1 flex items-start gap-3",children:[g&&e.jsx("button",{onClick:()=>p(!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(hl,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[26px] font-bold text-[#1e293b] tracking-tight leading-tight",children:[o==="dashboard"&&"Teacher Dashboard",o==="analytics"&&"Class Analytics",o==="intervention"&&"Intervention Center",o==="competency"&&"Student Competency",o==="topic_mastery"&&"Topic Mastery",o==="calendar"&&"Academic Calendar",o==="notifications"&&"Notifications",o==="question_bank"&&"Question Bank",o==="import"&&"Data Import",o==="quiz_maker"&&"AI Quiz Maker"]}),e.jsxs("p",{className:"text-[13px] text-[#64748b] mt-1",children:[o==="dashboard"&&`Welcome back, ${we}`,o==="analytics"&&"Analyze performance and risk across your classes.",o==="intervention"&&"Identify and support students who need immediate help.",o==="competency"&&"Track individual student progress against learning goals.",o==="topic_mastery"&&"Overview of student mastery levels across different math topics.",o==="calendar"&&"Manage your schedules and academic events.",o==="notifications"&&"Stay updated with student activity and system alerts.",o==="question_bank"&&"Manage and create math questions for your quizzes.",o==="import"&&"Upload class records and materials to power AI analytics.",o==="quiz_maker"&&"Create AI-powered quizzes based on your curriculum."]})]}),o==="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(Rt,{size:13,className:"text-[#9956DE]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#9956DE]",children:[f," 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(_s,{size:13,className:"text-[#F08386]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#C65E63]",children:[T," 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(sa,{size:13,className:"text-[#75D06A]"}),e.jsxs("span",{className:"text-xs font-display font-semibold text-[#4D9F46]",children:[E,"% avg"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 self-end sm:self-auto",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:()=>{k(!0),H(!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(ss,{size:18}),!j&&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"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>$(!I),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(Rs,{size:18}),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(au,{isOpen:I,onClose:()=>$(!1),onViewAll:()=>i("notifications")})]}),o!=="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:n?.photo||`https://ui-avatars.com/api/?name=${encodeURIComponent(we)}&background=e0e7ff&color=4f46e5`,alt:"Profile",className:"w-full h-full object-cover"})}),e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:we})]})]})]})}),e.jsx("main",{className:`flex-1 flex flex-col ${o==="intervention"||o==="analytics"?"overflow-hidden":"overflow-y-auto"}`,children:e.jsxs(Bt,{mode:"wait",children:[o==="dashboard"&&e.jsx(Km,{classes:D,liveActivity:U,onViewClass:ae,onViewAllClasses:()=>i("analytics"),onViewActivityStudent:F=>{const Z=Q.find(Re=>Re.name===F);Z&&z(Z)},dailyInsight:ie,insightLoading:de,isInsightDismissed:j,onDismissInsight:()=>H(!0),onOpenInsightModal:()=>{k(!0),H(!0)},totalStudents:f,totalAtRisk:T,avgPerformance:E}),o==="analytics"&&Se&&e.jsx(Jm,{selectedClass:Se,students:et,riskDistribution:W,topicPerformance:se,onViewStudent:z,onBack:()=>w(null),teacherOptions:De,managerUpdating:Ge,onAssignManager:F=>ve(Se,F),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,classColor:Je,insightDismissed:j,onOpenInsightModal:()=>k(!0)}),o==="analytics"&&!Se&&D.length>0&&e.jsx(xo,{classes:D,onSelectClass:ae,onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:j,onOpenInsightModal:()=>k(!0)}),o==="analytics"&&!Se&&D.length===0&&e.jsx(To,{icon:hs,title:"Class Analytics",description:"No classes available yet. Import class records to unlock analytics views."}),o==="intervention"&&y&&e.jsx(Zm,{student:y,teacherId:r?.uid||"",teacherName:we,initialCache:X.current.get(y.id),onCacheUpdate:(F,Z)=>X.current.set(F,Z),onStudentUpdated:F=>{const Z=y?fr(y):null;R(F),A(Re=>Re.map(Ne=>{const M=fr(Ne),te=Z?M===Z:!1,_e=Ne.id===F.id&&it(Ne.classSectionId)===it(F.classSectionId);return te||_e?F:Ne}))},onBack:oe,onNavigateToQuizMaker:F=>{i("quiz_maker"),F&&sessionStorage.setItem("quizMakerInitialTab",F)}}),o==="topic_mastery"&&e.jsx(ku,{classSectionId:We,onOpenNotifications:()=>i("notifications"),onOpenProfile:s}),o==="competency"&&Se&&e.jsx(Eu,{classSectionId:We,className:m?.name,fallbackStudents:Q,onBack:()=>w(null),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:j,onOpenInsightModal:()=>k(!0)}),o==="competency"&&!Se&&D.length>0&&e.jsx(xo,{classes:D,onSelectClass:F=>w(F),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:j,onOpenInsightModal:()=>k(!0),viewType:"competency"}),o==="competency"&&!Se&&D.length===0&&e.jsx(To,{icon:Rt,title:"Student Competency",description:"No classes available yet. Import class records to view competency breakdowns."}),o==="import"&&e.jsx(Gm,{classSectionId:We,className:m?.name,classMetadata:m?.classMetadata,students:Q,teacherId:r?.uid||"",teacherName:we,onStudentsUpdated:F=>A(F),onBackToClasses:()=>i("dashboard"),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{k(!0),H(!0)},userPhoto:n?.photo,onImportedClassRecords:F=>{const Z=F.students.map(be=>Ym(be,F.classSectionId,F.className,F.classMetadata)),Re=mt({metadata:F.classMetadata,classSectionId:F.classSectionId,className:F.className}),Ne=Re.classSectionId||"imported_class",M=Re.className||"Imported Class",te=Z.filter(be=>be.riskLevel==="high").length,_e=Z.length>0?Math.round(Z.reduce((be,ot)=>be+ot.avgScore,0)/Z.length):0,Fe={id:Ne,name:M,classSectionId:Ne,classMetadata:{...Re,classSectionId:Ne,className:M},schedule:"Mon-Fri",studentCount:Z.length,avgScore:_e,atRiskCount:te,riskLevel:te>=5?"high":te>=2?"medium":"low"};A(be=>Co(be,Z)),q(be=>So(be,[Fe]))},onDataChanged:()=>ne(F=>F+1)}),o==="notifications"&&e.jsx(Ru,{liveActivity:U,atRiskStudents:Q.filter(F=>F.riskLevel==="high").map(F=>({name:F.name,riskLevel:F.riskLevel,weakestTopic:F.weakestTopic})),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{k(!0),H(!0)},userPhoto:n?.photo,teacherName:we}),o==="calendar"&&e.jsx(Uu,{classes:D,teacherId:r?.uid}),o==="quiz_maker"&&e.jsx(_i,{onBack:()=>{const F=sessionStorage.getItem("quizMakerReturnTo");sessionStorage.removeItem("quizMakerReturnTo"),sessionStorage.removeItem("quizMakerInitialTab"),i(F==="intervention"?"intervention":"dashboard")},onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{k(!0),H(!0)},userPhoto:n?.photo,teacherName:we}),o==="question_bank"&&e.jsx(yu,{onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{k(!0),H(!0)},userPhoto:n?.photo,teacherName:we})]})})]}),o==="dashboard"&&e.jsx(ex,{onViewCalendar:()=>i("calendar"),onOpenProfile:s,userProfile:n,teacherName:we})]}),e.jsx(Bt,{children:v&&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(Pe.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(ss,{size:16})}),e.jsx("h3",{className:"font-semibold text-slate-800",children:"Detailed AI Insight"})]}),e.jsx("button",{onClick:()=>{k(!1)},className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(ps,{size:18})})]}),e.jsx("div",{className:"p-6",children:e.jsx(va,{name:"teacher-dashboard-ai-insight-modal",loading:de,fixture:e.jsx(Me,{className:"h-32 w-full bg-slate-200"}),fallback:e.jsx(Me,{className:"h-32 w-full bg-slate-200"}),children:e.jsx("div",{className:"text-sm text-slate-600 leading-relaxed",children:e.jsx(Vl,{children:ie?.replace(/[*_]*\s*\(?Word\s*count\s*:\s*[*_]*\s*\d+\)?\s*[*_]*/gi,"").trim()||`I've noticed **${T} students (${f>0?Math.round(T/f*100):0}%)** are currently showing a high risk of falling behind in recent topics. Shall I draft an intervention plan?`})})})}),e.jsx("div",{className:"p-4 border-t border-slate-100 bg-slate-50 flex justify-end gap-2",children:e.jsx("button",{onClick:()=>{k(!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(il,{isOpen:S,onClose:()=>N(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"})]})},Jt=({icon:t,label:s,active:a,collapsed:r,forceExpanded:n=!1,onClick:o})=>e.jsxs(Pe.button,{onClick:o,whileHover:{x:2},whileTap:{scale:.98},className:`w-full flex items-center gap-3 px-4 py-3 rounded-2xl cursor-pointer transition-all duration-200 border whitespace-nowrap ${r&&!n?"justify-center":""} ${a?"bg-[#9956DE]/12 border-[#9956DE]/30 shadow-sm text-[#9956DE]":"bg-transparent border-transparent text-[#5a6578] hover:bg-[#dde3eb] hover:border-[#dde3eb] hover:text-[#0a1628]"}`,children:[e.jsx(t,{size:18,strokeWidth:a?2.5:2,className:"flex-shrink-0"}),(!r||n)&&e.jsx("span",{className:"font-body font-semibold text-xs",children:s}),a&&!r&&e.jsx(Pe.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-[#9956DE]",transition:{type:"spring",duration:.4}})]}),To=({icon:t,title:s,description:a})=>e.jsx(Pe.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})]})}),Km=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:n,dailyInsight:o,insightLoading:i,isInsightDismissed:l,onDismissInsight:c,onOpenInsightModal:d,totalStudents:x,totalAtRisk:b,avgPerformance:p})=>{const g=x>0?Math.round(b/x*100):0,C=x>0?Math.round((x-b)/x*100):0;return e.jsxs(Pe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-4",children:[!l&&e.jsxs("div",{onClick:d,className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[18px_20px] flex items-center 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 items-center gap-2 mb-1",children:[e.jsx(ss,{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:"I've noticed some students are currently showing a high risk of falling behind. Click to view detailed analysis..."})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",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-3",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#10b981] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90",children:"Total students"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Rt,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:x}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px] opacity-90",children:[e.jsx("span",{children:"Added this year"}),e.jsx("span",{className:"bg-black/15 px-[7px] py-[2px] rounded font-semibold",children:x>0?"+1":"0"})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#0ea5e9] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90",children:"Class average"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Yt,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[p,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px] opacity-90",children:[e.jsx("span",{children:"Vs. last month"}),e.jsx("span",{className:"bg-black/15 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-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90",children:"Engagement rate"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx($l,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[C,"%"]}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px] opacity-90",children:[e.jsx("span",{children:"Active participants"}),e.jsx("span",{className:"bg-black/15 px-[7px] py-[2px] rounded font-semibold",children:Math.round(C/100*x)})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90",children:"At risk"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(aa,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:b}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px] opacity-90",children:[e.jsx("span",{children:"Requires attention"}),e.jsxs("span",{className:"bg-black/15 px-[7px] py-[2px] rounded font-semibold",children:[g,"%"]})]})]})]}),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.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"No classes imported yet."}),t.map((S,N)=>{const m=[{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]"}],w=m[N%m.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 ${w.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] ${w.stripe}`}),e.jsx("div",{className:`w-[38px] h-[38px] rounded-[10px] flex items-center justify-center flex-shrink-0 text-[17px] ${w.bg} ${w.text} group-hover:scale-110 transition-transform duration-300`,children:e.jsx(Lt,{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:"text-[12px] text-[#64748b] min-w-[65px]",children:S.schedule||"Mon-Fri"}),e.jsxs("div",{className:"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(nr,{size:16,className:"text-[#cbd5e1] ml-auto hover:text-[#64748b]"})]},S.id)})]})]})]})},Xm=le.memo(({student:t,onViewStudent:s})=>{const r=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"};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] ${r.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 ${r.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 ${r.bgAvatar}`,children:t.name.substring(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] leading-tight truncate",children:t.name}),e.jsxs("p",{className:"text-[10px] text-[#64748b] flex items-center gap-[4px] mt-0.5 truncate",children:[e.jsx(Ms,{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 ${r.badge}`,children:[t.avgScore,"%"]})]}),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 ${r.progress}`,style:{width:`${t.avgScore}%`}})})]})}),Jm=({selectedClass:t,students:s,riskDistribution:a,topicPerformance:r,onViewStudent:n,onBack:o,teacherOptions:i,managerUpdating:l,onAssignManager:c,onOpenNotifications:d,onOpenProfile:x,classColor:b,insightDismissed:p,onOpenInsightModal:g})=>{const{currentUser:C,userProfile:S}=gs(),[N,m]=h.useState(""),[w,y]=h.useState(""),[R,j]=h.useState("All");h.useEffect(()=>{y(t.classMetadata?.managerId||t.managerId||"")},[t]);const H=h.useMemo(()=>{const A=N.trim().toLowerCase();let U=s;return A&&(U=U.filter(ee=>ee.name.toLowerCase().includes(A)||(ee.lrn||"").toLowerCase().includes(A)||(ee.weakestTopic||"").toLowerCase().includes(A))),R==="Good"?U=U.filter(ee=>ee.avgScore>=85&&ee.riskLevel!=="high"):R==="Risk"&&(U=U.filter(ee=>ee.riskLevel==="high"||ee.avgScore<75)),U},[N,s,R]),v=h.useMemo(()=>{if(s.length===0)return 0;const A=s.reduce((U,ee)=>U+(ee.assignmentCompletion||0),0);return Math.round(A/s.length)},[s]),k=h.useMemo(()=>{if(s.length===0)return 0;const A=s.reduce((ee,ie)=>ee+(ie.attendance||0),0)/s.length,U=s.reduce((ee,ie)=>ee+(ie.engagementScore||0),0)/s.length;return Math.round(A*.6+U*.4)},[s]),I=h.useMemo(()=>[...s].sort((A,U)=>U.avgScore-A.avgScore).slice(0,5),[s]),$=h.useMemo(()=>[...s].filter(A=>A.riskLevel==="high"||A.avgScore<70||A.assignmentCompletion<65),[s]),D=h.useMemo(()=>i.find(A=>A.uid===w),[i,w]),q=()=>{if(!D){me.error("Select a teacher manager first.");return}c(D)},Q=[t.classMetadata?.gradeLevel||t.gradeLevel,t.classMetadata?.classification||t.classification,t.classMetadata?.strand||t.strand].filter(Boolean);return e.jsxs(Pe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-[24px] xl:p-[32px] space-y-[24px] h-full overflow-y-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",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] shadow-[0_1px_4px_rgba(0,0,0,0.04)] border border-white/50",children:[e.jsx(as,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("header",{style:{backgroundColor:b?.hex||"#6366f1"},className:"rounded-[24px] 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-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-[28px] font-bold mb-3 tracking-tight",children:t.name}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:Q.map((A,U)=>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:A},A))}),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 items-center gap-3",children:[e.jsxs("div",{className:"relative w-full md:w-[320px]",children:[e.jsxs("select",{value:w||"",onChange:A=>y(A.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"}),i.map(A=>e.jsxs("option",{value:A.uid,children:[A.name," (",A.email,")"]},A.uid))]}),e.jsx(_t,{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:q,disabled:!w||l,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:b?.hex||"#6366f1"},children:l?"Updating...":"Assign"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 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-2xl p-[15px] text-white flex flex-col 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-[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(Yt,{size:15})})]}),e.jsxs("div",{className:"relative z-10 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-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Completion Rate"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(gr,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[v,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#a855f7] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[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(Rt,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[k,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#f97316] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Needs Attention"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(_s,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[$.length," ",e.jsx("span",{className:"text-[13px] opacity-90 font-medium",children:"students"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 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.jsx("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:["(",H.length,")"]})]})}),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(ra,{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:N,onChange:A=>m(A.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:()=>j("All"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${R==="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:()=>j("Good"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${R==="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:()=>j("Risk"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${R==="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(Ld,{style:{height:"100%"},data:H,className:"no-scrollbar",itemContent:(A,U)=>e.jsx("div",{className:"py-[6px] px-[8px]",children:e.jsx(Xm,{student:U,onViewStudent:n})}),computeItemKey:(A,U)=>fr(U)})})]}),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(nr,{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(bn,{width:"100%",height:"100%",children:e.jsxs(vn,{data:a,children:[e.jsx(wn,{strokeDasharray:"4 4",stroke:"#f1f5f9",vertical:!1}),e.jsx(Nn,{dataKey:"name",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#475569",fontSize:11,fontWeight:600},dy:10}),e.jsx(jn,{axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600}}),e.jsx(yn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Sn,{dataKey:"value",radius:[6,6,0,0],barSize:80,children:a.map((A,U)=>{const ee={"High Risk":"#f43f5e","Medium Risk":"#f59e0b","Low Risk":"#10b981"};return e.jsx(kn,{fill:ee[A.name]||A.color},`cell-${U}`)})})]})})})]}),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(nr,{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(bn,{width:"100%",height:"100%",children:e.jsxs(vn,{data:r,layout:"vertical",margin:{top:0,right:10,left:40,bottom:0},children:[e.jsx(wn,{strokeDasharray:"4 4",stroke:"#f1f5f9",horizontal:!1}),e.jsx(Nn,{type:"number",domain:[0,100],axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600},tickFormatter:A=>`${A}%`}),e.jsx(jn,{dataKey:"topic",type:"category",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#1e293b",fontSize:11,fontWeight:600},dx:-10}),e.jsx(yn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Sn,{dataKey:"score",radius:[0,6,6,0],barSize:28,children:r.map((A,U)=>{const ee=["#6366f1","#a855f7","#10b981","#f59e0b","#ec4899"];return e.jsx(kn,{fill:ee[U%ee.length]},`cell-${U}`)})})]})})})]})]}),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(sa,{className:"w-4 h-4 text-emerald-500"}),"Top Performers"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[I.map(A=>e.jsxs("div",{onClick:()=>n(A),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:A.name}),e.jsxs("span",{className:"text-[13px] font-semibold text-emerald-600",children:[A.avgScore,"%"]})]},`top-${A.id}`)),I.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(_s,{className:"w-4 h-4 text-rose-500"}),"Needs Attention"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[$.slice(0,4).map(A=>{const U=A.riskLevel==="high",ee=U?"bg-rose-50/40 border-rose-50":"bg-amber-50/40 border-amber-50";return e.jsxs("div",{onClick:()=>n(A),className:`flex justify-between items-center p-3 rounded-[14px] border group hover:scale-[1.02] transition-transform cursor-pointer ${ee}`,children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:A.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] ${U?"text-rose-600":"text-amber-600"}`,children:U?"HIGH RISK":"MEDIUM RISK"})]},`attn-${A.id}`)}),$.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students."})]})]})]})]})]})]})},Zm=({student:t,teacherId:s,teacherName:a,onStudentUpdated:r,onBack:n,onNavigateToQuizMaker:o,initialCache:i,onCacheUpdate:l})=>{const c=(t.riskLevel||"low").toLowerCase(),d=c==="high"||c==="medium",x=h.useMemo(()=>Ze.getImportGroundedRolloutFlags(),[]),[b,p]=h.useState(i?.learningPath||""),[g,C]=h.useState(!0),[S,N]=h.useState(i?.gradeDraft||t.grade||"Grade 11"),[m,w]=h.useState(i?.sectionDraft||t.section||"Section A"),[y,R]=h.useState(!1),[j,H]=h.useState(i?.lessonPlan??null),[v,k]=h.useState([]),[I,$]=h.useState(""),[D,q]=h.useState(!1),[Q,A]=h.useState(""),[U,ee]=h.useState("all"),[ie,je]=h.useState("all"),[ge,Ce]=h.useState(!1),[de,B]=h.useState(!1),[Y,ne]=h.useState(null),[De,Le]=h.useState(!1),[Ge,O]=h.useState(!1),[X,f]=h.useState(0),[T,E]=h.useState(!1),[W,V]=h.useState("choose"),[se,ae]=h.useState([]),[z,oe]=h.useState(!1),[ue,ve]=h.useState(!1),[K,we]=h.useState(!1),[We,Se]=h.useState(!1);h.useEffect(()=>{N(t.grade||"Grade 11"),w(t.section||"Section A")},[t.grade,t.section]),h.useEffect(()=>{const M=te=>{if(te.key==="Escape"){if(We){Se(!1);return}if(ue){K?Se(!0):ve(!1);return}T&&E(!1)}};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[ue,T,K,We]),h.useEffect(()=>{if(ue){const M=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=M}}},[ue]),h.useEffect(()=>{l?.(t.id,{lessonPlan:j,learningPath:b,gradeDraft:S,sectionDraft:m})},[j,b,S,m,t.id,l]),h.useEffect(()=>{(async()=>{C(!0);try{let te="";try{te=await gl(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),$(te)}catch{$("")}const _e=await Ze.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),Fe=te?`${_e.learningPath} - -${te}`:_e.learningPath;p(Fe)}catch{p("Unable to generate learning path. Please try again later."),$("")}finally{C(!1)}})()},[t]);const Je=h.useCallback(async()=>{q(!0),A("");try{const M=t.classSectionId||zt(S||"Grade 11",m||"Section A"),te=t.struggles.length>0?t.struggles[0]:t.weakestTopic,_e=await mu({gradeLevel:S||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[S,m].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${te}`,learningCompetency:te,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:M,className:[S,m].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:x.lessonEnabled,allowReviewSources:ge,allowUnverifiedLesson:de},!0);H(_e),k(_e.curriculumSources||[]),ne(null),Ze.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:M,className:[S,m].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:_e.usedImportedTopics,importedTopicCount:_e.importedTopicCount,blockCount:_e.blocks.length,publishReady:_e.publishReady,sourceLegitimacyStatus:_e.sourceLegitimacy.status,selfValidationPassed:_e.selfValidation.passed,importGroundingEnabled:x.lessonEnabled}})}catch(M){let te=M instanceof Error?M.message:"Unable to generate lesson plan at this time.";if(M instanceof ja&&M.status===422)try{const Fe=JSON.parse(M.responseBody)?.detail;Fe?.message&&(te=Fe.message);const be=Fe?.sourceLegitimacy?.issues||[],ot=Fe?.selfValidation?.issues||[],gt=[...be,...ot].filter(Boolean).slice(0,3);gt.length>0&&(te=`${te} ${gt.join(" ")}`)}catch{}A(te),H(null),k([]),Ze.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||zt(S||"Grade 11",m||"Section A"),className:[S,m].filter(Boolean).join(" - ")||t.className,metadata:{error:te,allowReviewSources:ge,allowUnverifiedLesson:de,importGroundingEnabled:x.lessonEnabled}})}finally{q(!1)}},[t,S,m,x.lessonEnabled,ge,de]),et=h.useCallback(async()=>{if(!j)return me.error("Generate a lesson plan first."),null;Le(!0);try{const M=await du(j,s,{teacherName:a,studentId:t.id,studentName:t.name});return ne(M),me.success("Lesson plan saved as draft."),M}catch(M){return console.error("Failed to save lesson draft:",M),me.error(M instanceof Error?M.message:"Failed to save lesson draft."),null}finally{Le(!1)}},[j,s,a,t.id,t.name]),F=h.useCallback(async()=>{if(!j){me.error("Generate a lesson plan first.");return}if(!j.publishReady){const M=[...j.sourceLegitimacy.issues,...j.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");me.error(M||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}O(!0);try{let M=Y;if(M||(M=await et()),!M)return;await uu(M),me.success("Lesson plan published to class content."),Ze.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:M,publishReady:j.publishReady,sourceLegitimacyStatus:j.sourceLegitimacy.status,selfValidationPassed:j.selfValidation.passed}})}catch(M){console.error("Failed to publish lesson plan:",M),me.error(M instanceof Error?M.message:"Failed to publish lesson plan."),Ze.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:j.classSectionId||t.classSectionId,className:j.className||t.className,metadata:{action:"publish_lesson_plan",error:M instanceof Error?M.message:"Failed to publish lesson plan."}})}finally{O(!1)}},[j,Y,et,t.className,t.classSectionId]);h.useEffect(()=>{Je()},[X]),h.useEffect(()=>{f(M=>M+1)},[t.id]),h.useEffect(()=>{ee("all"),je("all")},[j]),h.useMemo(()=>j?Array.from(new Set(j.blocks.map(M=>M.provenance?.sourceFile?.trim()).filter(M=>!!M))).sort((M,te)=>M.localeCompare(te)):[],[j]),h.useMemo(()=>j?Array.from(new Set(j.blocks.map(M=>M.provenance?.materialId?.trim()).filter(M=>!!M))).sort((M,te)=>M.localeCompare(te)):[],[j]);const Z=h.useMemo(()=>j?j.blocks.filter(M=>{const te=U==="all"||(M.provenance?.sourceFile||"").trim()===U,_e=ie==="all"||(M.provenance?.materialId||"").trim()===ie;return te&&_e}):[],[j,U,ie]),Re=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:Cn},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:Ho},{id:3,type:"assessment",title:"Final Check",questions:5,icon:gr}],Ne=async()=>{if(!s){me.error("Unable to update section: teacher context missing");return}R(!0);try{await Ei(t.id,S,m,s,new Date().getFullYear().toString(),a),await Ci(t.id,S,m);const M={...t,grade:S,section:m,className:[S,m].filter(Boolean).join(" - "),classSectionId:zt(S,m)};r(M),me.success("Student section assignment updated")}catch(M){console.error("Failed to update student section assignment:",M),me.error("Failed to update section assignment")}finally{R(!1)}};return e.jsxs(Pe.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:n,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(Sa,{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"]})]})]}),I&&e.jsx(eo,{sources:v,className:"mb-4 relative z-10"}),e.jsx(va,{name:"teacher-intervention-analysis",loading:g,fixture:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsx(Me,{className:"h-24 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-24 w-full rounded-[14px]"})]}),fallback:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsx(Me,{className:"h-24 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-24 w-full rounded-[14px]"})]}),children: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(sa,{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(Yt,{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((M,te)=>e.jsxs("li",{children:["Must continue strengthening ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:M}),"."]},te)):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:g,onClick:()=>f(M=>M+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(Vs,{className:"w-3 h-3"})," Regenerate"]})]}),e.jsxs(va,{name:"teacher-intervention-learning-path",loading:g,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Me,{className:"h-24 w-full rounded-xl"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Me,{className:"h-24 w-full rounded-xl"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Me,{className:"h-20 w-full rounded-[14px]"})]}),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:Re.map((M,te)=>{let _e=e.jsx(Cn,{className:"w-4 h-4"}),Fe="bg-[#8b5cf6] shadow-[0_4px_10px_rgba(139,92,246,0.3)]",be="text-purple-600",ot="group-hover:border-purple-200",gt="hover:bg-[#4f46e5]",Dt=e.jsx(Il,{className:"w-4 h-4 ml-0.5"});return M.type==="quiz"?(_e=e.jsx(El,{className:"w-4 h-4"}),Fe="bg-sky-500 shadow-[0_4px_10px_rgba(14,165,233,0.3)]",be="text-sky-600",ot="group-hover:border-sky-200",gt="hover:bg-sky-500",Dt=e.jsx(es,{className:"w-4 h-4"})):M.type==="assessment"&&(_e=e.jsx(Ra,{className:"w-4 h-4"}),Fe="bg-emerald-500 shadow-[0_4px_10px_rgba(16,185,129,0.3)]",be="text-emerald-600",ot="group-hover:bg-emerald-50"),e.jsxs(Pe.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:te*.1},className:"relative pl-[32px] group",children:[e.jsx("div",{className:`absolute -left-[17px] top-1 w-8 h-8 rounded-full ${Fe} text-white flex items-center justify-center ring-4 ring-white group-hover:scale-110 transition-transform`,children:_e}),e.jsxs("div",{className:`${M.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 ${be}`,children:["Step ",te+1," • ",M.type==="video"?"Video Lesson":M.type==="quiz"?"Practice":"Assessment"]}),e.jsx("p",{className:"font-semibold text-[#1e293b] text-[13px] mb-0.5",children:M.title}),e.jsxs("p",{className:"text-[#64748b] text-[11px] flex items-center gap-1.5",children:[M.type==="video"&&e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"w-3 h-3"})," ",M.duration]}),M.type==="quiz"&&e.jsxs(e.Fragment,{children:[e.jsx(Go,{className:"w-3 h-3"})," ",M.questions," questions"]}),M.type==="assessment"&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"w-3 h-3"})," ",M.questions," assessment questions"]})]})]}),M.type==="assessment"?e.jsx(Ro,{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] ${gt} hover:text-white transition-colors border border-[#e2e8f0]`,children:Dt})]})]},M.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(ms,{onClick:()=>f(M=>M+1),disabled:D,className:"bg-[#4f46e5] hover:bg-[#3730a3] text-white h-8 text-[11px] rounded-full px-4",children:D?e.jsx(Me,{className:"h-3 w-16 bg-white/35"}):"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(Us,{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:ge,onChange:M=>Ce(M.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:de,onChange:M=>B(M.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(va,{name:"teacher-intervention-lesson-plan",loading:D,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Me,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(Me,{className:"h-24 w-full rounded-xl"}),e.jsx(Me,{className:"h-24 w-full rounded-xl"})]}),e.jsx(Me,{className:"h-28 w-full rounded-xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Me,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(Me,{className:"h-24 w-full rounded-xl"}),e.jsx(Me,{className:"h-24 w-full rounded-xl"})]}),e.jsx(Me,{className:"h-28 w-full rounded-xl"})]}),children:[Q&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A] mb-4",children:Q}),j&&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(eo,{sources:v})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:j.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:"})," ",j.usedImportedTopics?"Yes":"No"," (",j.importedTopicCount,")"]}),e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Subject:"})," ",j.subject||"General Math"," (Q",j.quarter||1,")"]})]}),j.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: ",j.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 ${j.publishReady?"text-emerald-600":"text-rose-500"}`,children:j.publishReady?"Ready":"Blocked"})]})}),j.warnings.length>0&&e.jsx("p",{className:"text-[11px] text-amber-600 mt-2 bg-amber-50 px-2 py-1.5 rounded",children:j.warnings.join(" ")})]}),j.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:j.lessonObjective})]}),j.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:j.realWorldHook})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:Z.map(M=>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:M.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] mt-1",children:[M.estimatedMinutes," mins "," • "," ",M.strategy]}),e.jsx("p",{className:"text-[12px] text-[#475569] mt-2 bg-[#f8fafc] p-2 rounded-lg",children:M.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"}),M.activities.slice(0,2).map((te,_e)=>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:te})]},_e))]})]},M.blockId))}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-4",children:[e.jsx(ms,{variant:"outline",onClick:()=>void et(),disabled:De||!j,className:"border-[#cbd5e1] text-[#475569] hover:bg-[#f8fafc] text-[12px] h-9 rounded-full px-5",children:De?e.jsx(Me,{className:"h-4 w-16"}):"Save Draft"}),e.jsx(ms,{onClick:()=>void F(),disabled:Ge||!j||!j.publishReady,className:"bg-[#10b981] hover:bg-[#059669] text-white text-[12px] h-9 rounded-full px-5",children:Ge?e.jsx(Me,{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()=>{V("choose"),E(!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(fc,{className:"w-4 h-4"})," Export Materials"]})}),T&&sr.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",onClick:()=>E(!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:M=>M.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:[W==="bank"&&e.jsx("button",{onClick:()=>V("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(as,{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(or,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[15px] font-bold text-white leading-tight",children:W==="choose"?"Export Materials":"Choose a Quiz"}),e.jsx("p",{className:"text-[11px] text-white/70 font-medium",children:W==="choose"?`For ${t.name}`:"Select a quiz from your bank"})]})]}),e.jsx("button",{onClick:()=>E(!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(ps,{className:"w-4 h-4"})})]})}),e.jsx("div",{className:"p-6",children:W==="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),V("bank");try{const M=await $o(s);ae(M)}catch{ae([])}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(Ca,{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:()=>{E(!1),we(!1),ve(!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(ss,{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:z?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..."})]}):se.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(Ca,{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:se.map(M=>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:M.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] font-medium mt-0.5",children:[M.questions?.length??0," questions",M.gradeLevel?` · ${M.gradeLevel}`:"",M.metadata?.topicsCovered?.[0]?` · ${M.metadata.topicsCovered[0]}`:""]})]}),e.jsx("button",{onClick:()=>{E(!1),me.success(`"${M.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"})]},M.id))})})})]})]}),document.body),ue&&sr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/40 backdrop-blur-sm",onClick:()=>{K?Se(!0):ve(!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:()=>{K?Se(!0):ve(!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(Sa,{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(or,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:"text-[14px] font-bold text-[#1e293b]",children:"AI Quiz Maker"})]}),K&&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(_i,{onBack:()=>ve(!1),drawerMode:!0,gradeLevel:t.grade,onQuizGenerating:()=>we(!0),onQuizSaved:M=>{we(!1),me.success("Quiz saved! Close this panel or create another.",{action:{label:"Close Panel",onClick:()=>ve(!1)}})}})})]}),We&&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:()=>Se(!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(aa,{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:()=>Se(!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:()=>{Se(!1),ve(!1),we(!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(Qs,{value:S,onChange:M=>N(M.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(Qs,{value:m,onChange:M=>w(M.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:Ne,disabled:y||!S.trim()||!m.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:y?"Updating...":"Update Assignment"})]})]})]})})]})},ex=({onViewCalendar:t,onOpenProfile:s,userProfile:a,teacherName:r})=>{const[n,o]=h.useState(new Date),[i,l]=h.useState("pulse"),c=m=>new Date(m.getFullYear(),m.getMonth()+1,0).getDate(),d=m=>new Date(m.getFullYear(),m.getMonth(),1).getDay(),x=()=>n.toLocaleDateString(void 0,{month:"long",year:"numeric"}),b=()=>o(new Date(n.getFullYear(),n.getMonth()-1)),p=()=>o(new Date(n.getFullYear(),n.getMonth()+1)),g=()=>{const m=c(n),w=d(n),y=[];for(let R=w-1;R>=0;R--)y.unshift(null);for(let R=1;R<=m;R++)y.push(R);return y},C=m=>{if(!m)return!1;const w=new Date;return m===w.getDate()&&n.getMonth()===w.getMonth()&&n.getFullYear()===w.getFullYear()},S=g(),N=["Mo","Tu","We","Th","Fr","Sa","Su"];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(fl,{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:"p-[10px_16px] border-b border-[#f1f5f9]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("button",{onClick:b,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]",children:e.jsx(as,{size:14})}),e.jsx("span",{className:"text-[12px] font-semibold text-[#1e293b]",children:x()}),e.jsx("button",{onClick: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]",children:e.jsx(es,{size:14})})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-[2px] text-center mb-1",children:[N.map(m=>e.jsx("div",{className:"text-[10px] font-semibold text-[#94a3b8] p-[2px_0_4px]",children:m},m)),S.map((m,w)=>e.jsx("div",{className:`text-[11px] leading-[22px] w-[22px] h-[22px] m-auto flex items-center justify-center rounded-full ${m===null?"text-[#cbd5e1]":C(m)?"bg-[#818cf8] text-white font-semibold":"text-[#475569]"}`,children:m},`${n.getMonth()}-${w}`))]})]}),e.jsxs("div",{className:"flex gap-[18px] p-[12px_16px_0] border-b border-[#f1f5f9] flex-shrink-0",children:[e.jsx("button",{onClick:()=>l("pulse"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${i==="pulse"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Live pulse"}),e.jsx("button",{onClick:()=>l("reminders"),className:`text-[11.5px] font-semibold pb-[9px] border-b-[2.5px] transition-colors ${i==="reminders"?"text-[#10b981] border-[#10b981]":"text-[#94a3b8] border-transparent"}`,children:"Reminders"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-[14px_16px]",children:[i==="pulse"&&e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsxs("svg",{className:"w-[96px] h-[96px]",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"#e2e8f0",strokeWidth:"4"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"#10b981",strokeWidth:"4",strokeDasharray:"78 100",strokeDashoffset:"25",strokeLinecap:"round"}),e.jsx("text",{x:"18",y:"16.5",textAnchor:"middle",fontFamily:"DM Sans,sans-serif",fontSize:"7",fontWeight:"600",fill:"#1e293b",children:"78%"}),e.jsx("text",{x:"18",y:"23",textAnchor:"middle",fontFamily:"DM Sans,sans-serif",fontSize:"3.8",fill:"#94a3b8",letterSpacing:"0.3",children:"ENGAGED"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-[7px] w-full",children:[e.jsxs("div",{className:"flex items-center gap-[6px] text-[11px] text-[#64748b]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#10b981] flex-shrink-0"}),"Engaged",e.jsx("span",{className:"ml-auto font-semibold text-[#1e293b]",children:"78%"})]}),e.jsxs("div",{className:"flex items-center gap-[6px] text-[11px] text-[#64748b]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#e2e8f0] flex-shrink-0"}),"Inactive",e.jsx("span",{className:"ml-auto font-semibold text-[#1e293b]",children:"22%"})]})]}),e.jsxs("div",{className:"bg-[#f8fafc] rounded-[11px] p-[11px_12px] text-center w-full mt-1",children:[e.jsx("div",{className:"text-[9px] font-semibold text-[#94a3b8] uppercase tracking-[0.07em] mb-[3px]",children:"Current activity"}),e.jsx("div",{className:"text-[12px] font-medium text-[#1e293b] mb-[2px]",children:"Quadratic equations quiz"}),e.jsx("div",{className:"text-[11.5px] text-[#4f46e5] font-medium",children:"10 / 12 students active"})]})]}),i==="reminders"&&e.jsxs("div",{className:"space-y-[8px]",children:[e.jsxs("div",{className:"flex items-start gap-[10px] p-[10px_11px] border border-[#f1f5f9] rounded-[12px] cursor-pointer hover:bg-[#f8fafc] transition-colors",children:[e.jsx("div",{className:"p-[7px] rounded-[8px] border border-[#f1f5f9] bg-white text-[14px] text-[#4f46e5] flex-shrink-0",children:e.jsx(Rs,{size:14})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-[#1e293b] mb-[2px]",children:"Eng – Vocabulary test"}),e.jsx("div",{className:"text-[10.5px] text-[#94a3b8]",children:"12 May 2026, Friday"})]})]}),e.jsxs("div",{className:"flex items-start gap-[10px] p-[10px_11px] border border-[#f1f5f9] rounded-[12px] cursor-pointer hover:bg-[#f8fafc] transition-colors",children:[e.jsx("div",{className:"p-[7px] rounded-[8px] border border-[#f1f5f9] bg-white text-[14px] text-[#10b981] flex-shrink-0",children:e.jsx(Lt,{size:14})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-[#1e293b] mb-[2px]",children:"Eng – Essay review"}),e.jsx("div",{className:"text-[10.5px] text-[#94a3b8]",children:"12 May 2026, Friday"})]})]})]})]})]})};export{Jx as default}; diff --git a/assets/TeacherDashboard-DyMHG-dm.js b/assets/TeacherDashboard-DyMHG-dm.js new file mode 100644 index 0000000000000000000000000000000000000000..3b6141dd04fb1567230e14dd030de8ba820a9dc9 --- /dev/null +++ b/assets/TeacherDashboard-DyMHG-dm.js @@ -0,0 +1,108 @@ +import{d as ce,j as e,r as h,c as sr}from"./vendor-react-B4AQeu28.js";import{c as nl,B as ps}from"./button-CaSK4KoS.js";import{I as Qs}from"./input-kh84w1XK.js";import ol from"./ConfirmModal-BjVnuYqC.js";import{I as Us,F as Zt,D as il,N as ll,A as Ro}from"./NotificationDropdown-IzxN6ZqA.js";import{M as cl,L as dl,S as ul,a as ml}from"./LogoutActionButton-D5BV__Zd.js";import{e as it,t as xl,f as on,g as et,h as pl,i as Je,j as _o,a as Bt,k as qt,m as Ge,G as Mo,B as ar,Z as hl,u as os,l as pe,n as ja,o as lt,A as zo,U as Ft,p as Yt,T as aa,C as fl,q as ln,R as Vs,r as gl,v as Rs,w as cn,x as dn,y as bl,z as vl,D as gr,M as wl,E as un,F as Nl,H as jl}from"./index-B3ruOzo6.js";import{collection as Xt,query as Pt,limit as Lo,where as Ht,getDocs as ss,orderBy as yl,onSnapshot as Ao,setDoc as es,doc as vt,updateDoc as Kt,getDoc as Cs,serverTimestamp as ft,deleteDoc as Sl}from"./vendor-firebase-firestore-CP9q7ISf.js";import{s as mn,f as Do,d as kl,p as Cl,a as Tl,u as Il,A as ya,P as El}from"./quizService-Bqc478Xh.js";import{S as Rl}from"./vendor-radix-BPuEd8FG.js";import{T as _l,a as Ml,b as zl}from"./tooltip-CLSYbTYK.js";import{X as fs}from"./x-BNHnAXzL.js";import{C as Ll}from"./circle-help-C5HGdkRZ.js";import{E as Al,a as Dl}from"./eye-WyNbhirJ.js";import{S as da}from"./send-CTO7uejQ.js";import{T as $o}from"./trash-2-CjkT7lLr.js";import{C as Ys}from"./circle-alert-CTR2Lqp7.js";import{C as Vt}from"./check-6eXlU5jr.js";import{C as _t,a as Sa}from"./chevron-up-CTb5_AvY.js";import{M as xn}from"./minus-B69_eMXI.js";import{P as rr}from"./plus-Dx0gdu7_.js";import{C as gs}from"./chart-column-C9VTl-3A.js";import{C as $l,H as pn,S as Ce}from"./skeleton-B6L2gPDz.js";import{D as Fl}from"./download-BbFDZT3H.js";import{L as ka,P as Ol}from"./pen-tool-BelhGWFu.js";import{C as as}from"./chevron-left-Cr0wYLQi.js";import{C as ts}from"./chevron-right-CbkkCalp.js";import{S as Fo}from"./save-DXz2z5YH.js";import{S as ra}from"./search-DeasjpAx.js";import{C as br}from"./circle-check-DyFN6-07.js";import{S as rs}from"./sparkles-Bq0AaIRg.js";import{U as hn}from"./upload-BBhypj4u.js";import{S as fn,g as Bl,G as Pl,s as gn}from"./subjects-DEj_AlYz.js";import{u as Hl}from"./useCurriculum-CQZ78SzC.js";import{C as vr}from"./circle-check-big-CWdn1Nqf.js";import Gl from"./ChatMarkdown-BWVWW9Zs.js";import{c as Ql,a as Oo,C as Ul,f as Vl}from"./formatDistanceToNow-DTsqWUq4.js";import{C as _s}from"./clock-C73na4Cu.js";import{B as Ca}from"./bell-Bp_utT8v.js";import{D as bn,a as vn,b as Wl,c as ql,d as Yl}from"./dialog-KaD0jw5O.js";import{u as Tt,r as Kl}from"./vendor-xlsx-uZelXSz_.js";import{C as Bo}from"./clipboard-check-Bv_xk-Mp.js";import{R as wn,B as Nn,C as jn,X as yn,Y as Sn,T as kn,a as Cn,b as Tn}from"./vendor-charts-D7t7JfSr.js";import"./log-out-CoRJnfoO.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-markdown-yqZQ_iQm.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 Xl=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Jl=it("align-left",Xl);/** + * @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 Zl=[["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"}]],Qa=it("calendar-days",Zl);/** + * @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=[["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"}]],tc=it("chart-no-axes-column",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 sc=[["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"}]],ac=it("ellipsis-vertical",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 rc=[["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"}]],nr=it("ellipsis",rc);/** + * @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 nc=[["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"}]],oc=it("external-link",nc);/** + * @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 ic=[["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"}]],lc=it("file-spreadsheet",ic);/** + * @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:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ta=it("library",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 dc=[["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"}]],Po=it("list-checks",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=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],mc=it("panel-right",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=[["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"}]],pc=it("pen-line",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=[["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"}]],Ho=it("pen",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 fc=[["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"}]],gc=it("printer",fc);/** + * @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:"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"}]],vc=it("scan-line",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:"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"}]],Nc=it("table",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=[["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"}]],Go=it("trending-down",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:"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"}]],In=it("video",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=[["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"}]],or=it("wand-sparkles",Sc);function kc(t,s){const a=xl(t);return isNaN(s)?Ql(t,NaN):(a.setDate(a.getDate()+s),a)}function Qo(t,s){const a=on(t),r=on(s);return+a==+r}function En(t){return Qo(t,Oo(t))}function Cc(t,s){return kc(t,-1)}function Rn(t){return Qo(t,Cc(Oo(t)))}const Ma=0,is=1,Ms=2,Uo=4;function _n(t){return()=>t}function Tc(t){t()}function Vo(t,s){return a=>t(s(a))}function Mn(t,s){return()=>t(s)}function Ic(t,s){return a=>t(s,a)}function wr(t){return t!==void 0}function Ec(...t){return()=>{t.map(Tc)}}function zs(){}function za(t,s){return s(t),t}function Rc(t,s){return s(t)}function Ye(...t){return t}function Be(t,s){return t(is,s)}function Ie(t,s){t(Ma,s)}function Nr(t){t(Ms)}function Xe(t){return t(Uo)}function de(t,s){return Be(t,Ic(s,Ma))}function Mt(t,s){const a=t(is,r=>{a(),s(r)});return a}function zn(t){let s,a;return r=>o=>{s=o,a&&clearTimeout(a),a=setTimeout(()=>{r(s)},t)}}function Wo(t,s){return t===s}function qe(t=Wo){let s;return a=>r=>{t(s,r)||(s=r,a(r))}}function be(t){return s=>a=>{t(a)&&s(a)}}function ne(t){return s=>Vo(s,t)}function Dt(t){return s=>()=>{s(t)}}function H(t,...s){const a=_c(...s);return((r,o)=>{switch(r){case Ms:Nr(t);return;case is:return Be(t,a(o))}})}function $t(t,s){return a=>r=>{a(s=t(s,r))}}function bs(t){return s=>a=>{t>0?t--:s(a)}}function Wt(t){let s=null,a;return r=>o=>{s=o,!a&&(a=setTimeout(()=>{a=void 0,r(s)},t))}}function Ee(...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;Be(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 _c(...t){return s=>t.reduceRight(Rc,s)}function Mc(t){let s,a;const r=()=>s?.();return function(o,n){switch(o){case is:return n?a===n?void 0:(r(),a=n,s=Be(t,n),s):(r(),zs);case Ms:r(),a=null;return}}}function G(t){let s=t;const a=ze();return((r,o)=>{switch(r){case Ma:s=o;break;case is:{o(s);break}case Uo:return s}return a(r,o)})}function ht(t,s){return za(G(s),a=>de(t,a))}function ze(){const t=[];return((s,a)=>{switch(s){case Ma:t.slice().forEach(r=>{r(a)});return;case Ms:t.splice(0,t.length);return;case is:return t.push(a),()=>{const r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function jt(t){return za(ze(),s=>de(t,s))}function Oe(t,s=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:s,id:zc(),singleton:a}}const zc=()=>Symbol();function Lc(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 tt(...t){const s=ze(),a=new Array(t.length);let r=0;const o=2**t.length-1;return t.forEach((n,i)=>{const l=2**i;Be(n,c=>{a[i]=c,r|=l,r===o&&Ie(s,a)})}),function(n,i){switch(n){case Ms:{Nr(s);return}case is:return r===o&&i(a),Be(s,i)}}}function ge(t,s=Wo){return H(t,qe(s))}function ir(...t){return function(s,a){switch(s){case Ms:return;case is:return Ec(...t.map(r=>Be(r,a)))}}}const nt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Ac={[nt.DEBUG]:"debug",[nt.ERROR]:"error",[nt.INFO]:"log",[nt.WARN]:"warn"},Dc=()=>typeof globalThis>"u"?window:globalThis,ls=Oe(()=>{const t=G(nt.ERROR);return{log:G((s,a,r=nt.INFO)=>{const o=Dc().VIRTUOSO_LOG_LEVEL??Xe(t);r>=o&&console[Ac[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",s,a)}),logLevel:t}},[],{singleton:!0});function vs(t,s,a){return jr(t,s,a).callbackRef}function jr(t,s,a){const r=ce.useRef(null);let o=i=>{};const n=ce.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 $c(t,s,a,r,o,n,i,l,c){const d=ce.useCallback(f=>{const v=Fc(f.children,s,l?"offsetWidth":"offsetHeight",o);let x=f.parentElement;for(;x.dataset.virtuosoScroller===void 0;)x=x.parentElement;const g=x.lastElementChild.dataset.viewportType==="window";let T;g&&(T=x.ownerDocument.defaultView);const C=i?l?i.scrollLeft:i.scrollTop:g?l?T.scrollX||T.document.documentElement.scrollLeft:T.scrollY||T.document.documentElement.scrollTop:l?x.scrollLeft:x.scrollTop,S=i?l?i.scrollWidth:i.scrollHeight:g?l?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight:l?x.scrollWidth:x.scrollHeight,p=i?l?i.offsetWidth:i.offsetHeight:g?l?T.innerWidth:T.innerHeight:l?x.offsetWidth:x.offsetHeight;r({scrollHeight:S,scrollTop:Math.max(C,0),viewportHeight:p}),n?.(l?Ln("column-gap",getComputedStyle(f).columnGap,o):Ln("row-gap",getComputedStyle(f).rowGap,o)),v!==null&&t(v)},[t,s,o,n,i,r,l]);return jr(d,a,c)}function Fc(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(),f=d.width;let v,x;if(s){const g=s.getBoundingClientRect(),T=d.top-g.top;x=g.height-Math.max(0,T),v=T+s.scrollTop}else{const g=i.current.ownerDocument.defaultView;x=g.innerHeight-Math.max(0,d.top),v=d.top+g.scrollY}r.current={listHeight:d.height,offsetTop:v,visibleHeight:x,visibleWidth:f},t(r.current)},[t,s]),{callbackRef:n,ref:i}=jr(o,!0,a),l=ce.useCallback(()=>{o(i.current)},[o,i]);return ce.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 bt=Oe(()=>{const t=ze(),s=ze(),a=G(0),r=ze(),o=G(0),n=ze(),i=ze(),l=G(0),c=G(0),d=G(0),f=G(0),v=ze(),x=ze(),g=G(!1),T=G(!1),C=G(!1);return de(H(t,ne(({scrollTop:S})=>S)),s),de(H(t,ne(({scrollHeight:S})=>S)),i),de(s,o),{deviation:a,fixedFooterHeight:d,fixedHeaderHeight:c,footerHeight:f,headerHeight:l,horizontalDirection:T,scrollBy:x,scrollContainerState:t,scrollHeight:i,scrollingInProgress:g,scrollTo:v,scrollTop:s,skipAnimationFrameInResizeObserver:C,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:n}},[],{singleton:!0}),Ks={lvl:0};function Yo(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(cr(o,s,a))),r>=s&&r<=a&&l.push({k:r,v:i}),r<=a&&(l=l.concat(cr(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(Ua(s))return Zo(rt(t,{lvl:a-1}));if(!Ue(s)&&!Ue(s.r))return rt(s.r,{l:rt(s,{r:s.r.l}),lvl:a,r:rt(t,{l:s.r.r,lvl:a-1})});throw new Error("Unexpected empty nodes")}if(Ua(t))return dr(rt(t,{lvl:a-1}));if(!Ue(r)&&!Ue(r.l)){const o=r.l,n=Ua(o)?r.lvl-1:r.lvl;return rt(o,{l:rt(t,{lvl:a-1,r:o.l}),lvl:o.lvl+1,r:dr(rt(r,{l:o.r,lvl:n}))})}throw new Error("Unexpected empty nodes")}function rt(t,s){return Jo(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 Ko(t){return Ue(t.r)?t.l:ga(rt(t,{r:Ko(t.r)}))}function Ua(t){return Ue(t)||t.lvl>t.r.lvl}function Xo(t){return Ue(t.r)?[t.k,t.v]:Xo(t.r)}function Jo(t,s,a,r=Ks,o=Ks){return{k:t,l:r,lvl:a,r:o,v:s}}function An(t){return dr(Zo(t))}function Zo(t){const{l:s}=t;return!Ue(s)&&s.lvl===t.lvl?rt(s,{r:rt(t,{l:s.r})}):t}function dr(t){const{lvl:s,r:a}=t;return!Ue(a)&&!Ue(a.r)&&a.lvl===s&&a.r.lvl===s?rt(a,{l:rt(t,{r:a.l}),lvl:s+1}):t}function Oc(t){return Yo(t,({k:s,v:a})=>({index:s,value:a}))}function ei(t,s){return!!(t&&t.startIndex===s.startIndex&&t.endIndex===s.endIndex)}function Js(t,s){return!!(t&&t[0]===s[0]&&t[1]===s[1])}const yr=Oe(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function ti(t,s,a){return t[Ia(t,s,a)]}function Ia(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 Bc(t,s,a,r){const o=Ia(t,s,r),n=Ia(t,a,r,o);return t.slice(o,n+1)}function ns(t,s){return Math.round(t.getBoundingClientRect()[s])}function La(t){return!Ue(t.groupOffsetTree)}function Sr({index:t},s){return s===t?0:s=v||n===x)&&(t=lr(t,v)):(d=x!==n,c=!0),f>o&&o>=v&&x!==n&&(t=Nt(t,o+1,x));d&&(t=Nt(t,i,n))}return[t,a]}function Gc(t){return typeof t.groupIndex<"u"}function Qc({offset:t},s){return s===t?0:s0?l+a:l}function si(t,s){if(!La(s))return t;let a=0;for(;s.groupIndices[a]<=t+a;)a++;return t+a}function ai(t,s,a){if(Gc(t))return s.groupIndices[t.groupIndex]+1;const r=t.index==="LAST"?a:t.index;let o=si(r,s);return o=Math.max(0,o,Math.min(a,o)),o}function Uc(t,s,a,r=0){return r>0&&(s=Math.max(s,ti(t,r,Sr).offset)),Yo(Bc(t,s,a,Qc),qc)}function Vc(t,[s,a,r,o]){s.length>0&&r("received item sizes",s,nt.DEBUG);const n=t.sizeTree;let i=n,l=0;if(a.length>0&&Ue(n)&&s.length===2){const x=s[0].size,g=s[1].size;i=a.reduce((T,C)=>Nt(Nt(T,C,x),C+1,g),i)}else[i,l]=Hc(i,s);if(i===n)return t;const{lastIndex:c,lastOffset:d,lastSize:f,offsetTree:v}=ur(t.offsetTree,l,i,o);return{groupIndices:a,groupOffsetTree:a.reduce((x,g)=>Nt(x,g,Zs(g,v,o)),Is()),lastIndex:c,lastOffset:d,lastSize:f,offsetTree:v,sizeTree:i}}function Wc(t){return hs(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 Dn(t,s){let a=0,r=0;for(;ao.start===r&&(o.end===s||o.end===1/0)&&o.value===a}const Kc={offsetHeight:"height",offsetWidth:"width"},Gt=Oe(([{log:t},{recalcInProgress:s}])=>{const a=ze(),r=ze(),o=ht(r,0),n=ze(),i=ze(),l=G(0),c=G([]),d=G(void 0),f=G(void 0),v=G(void 0),x=G(void 0),g=G((m,j)=>ns(m,Kc[j])),T=G(void 0),C=G(0),S=Pc(),p=ht(H(a,Ee(c,t,C),$t(Vc,S),qe()),S),y=ht(H(c,qe(),$t((m,j)=>({current:j,prev:m.current}),{current:[],prev:[]}),ne(({prev:m})=>m)),[]);de(H(c,be(m=>m.length>0),Ee(p,C),ne(([m,j,w])=>{const R=m.reduce((z,V,Q)=>Nt(z,V,Zs(V,j.offsetTree,w)||Q),Is());return{...j,groupIndices:m,groupOffsetTree:R}})),p),de(H(r,Ee(p),be(([m,{lastIndex:j}])=>m[{endIndex:j,size:w,startIndex:m}])),a),de(d,f);const k=ht(H(d,ne(m=>m===void 0)),!0);de(H(f,be(m=>m!==void 0&&Ue(Xe(p).sizeTree)),ne(m=>{const j=Xe(v),w=Xe(c).length>0;return j!==void 0&&j!==0?w?[{endIndex:0,size:j,startIndex:0},{endIndex:1,size:m,startIndex:1}]:[]:[{endIndex:0,size:m,startIndex:0}]})),a),de(H(x,be(m=>m!==void 0&&m.length>0&&Ue(Xe(p).sizeTree)),ne(m=>{const j=[];let w=m[0],R=0;for(let z=1;zm!==void 0&&j!==void 0),ne(([m,j,w])=>{const R=[];for(let z=0;z({changed:w!==m,sizes:w}),{changed:!1,sizes:S}),ne(m=>m.changed)));Be(H(l,$t((m,j)=>({diff:m.prev-j,prev:j}),{diff:0,prev:0}),ne(m=>m.diff)),m=>{const{groupIndices:j}=Xe(p);if(m>0)Ie(s,!0),Ie(n,m+Dn(m,j));else if(m<0){const w=Xe(y);w.length>0&&(m-=Dn(-m,w)),Ie(i,m)}}),Be(H(l,Ee(t)),([m,j])=>{m<0&&j("`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},nt.ERROR)});const N=jt(n);de(H(n,Ee(p),ne(([m,j])=>{const w=j.groupIndices.length>0,R=[],z=j.lastSize;if(w){const V=Xs(j.sizeTree,0);let Q=0,F=0;for(;Q{let ve=ee.ranges;return ee.prevSize!==0&&(ve=[...ee.ranges,{endIndex:ie+m-1,size:ee.prevSize,startIndex:ee.prevIndex}]),{prevIndex:ie+m,prevSize:je,ranges:ve}},{prevIndex:m,prevSize:0,ranges:R}).ranges}return hs(j.sizeTree).reduce((V,{k:Q,v:F})=>({prevIndex:Q+m,prevSize:F,ranges:[...V.ranges,{endIndex:Q+m-1,size:V.prevSize,startIndex:V.prevIndex}]}),{prevIndex:0,prevSize:z,ranges:[]}).ranges})),a);const B=jt(H(i,Ee(p,C),ne(([m,{offsetTree:j},w])=>{const R=-m;return Zs(R,j,w)})));return de(H(i,Ee(p,C),ne(([m,j,w])=>{if(j.groupIndices.length>0){if(Ue(j.sizeTree))return j;let z=Is();const V=Xe(y);let Q=0,F=0,W=0;for(;Q<-m;){W=V[F];const ee=V[F+1]-W-1;F++,Q+=ee+1}if(z=hs(j.sizeTree).reduce((ee,{k:ie,v:je})=>Nt(ee,Math.max(0,ie+m),je),z),Q!==-m){const ee=Xs(j.sizeTree,W);z=Nt(z,0,ee);const ie=Lt(j.sizeTree,-m+1)[1];z=Nt(z,1,ie)}return{...j,sizeTree:z,...ur(j.offsetTree,0,z,w)}}const R=hs(j.sizeTree).reduce((z,{k:V,v:Q})=>Nt(z,Math.max(0,V+m),Q),Is());return{...j,sizeTree:R,...ur(j.offsetTree,0,R,w)}})),p),{beforeUnshiftWith:N,data:T,defaultItemSize:f,firstItemIndex:l,fixedItemSize:d,fixedGroupSize:v,gap:C,groupIndices:c,heightEstimates:x,itemSize:g,listRefresh:L,shiftWith:i,shiftWithOffset:B,sizeRanges:a,sizes:p,statefulTotalCount:o,totalCount:r,trackItemSizes:k,unshiftWith:n}},Ye(ls,yr),{singleton:!0});function Xc(t){return t.reduce((s,a)=>(s.groupIndices.push(s.totalCount),s.totalCount+=a+1,s),{groupIndices:[],totalCount:0})}const ri=Oe(([{groupIndices:t,sizes:s,totalCount:a},{headerHeight:r,scrollTop:o}])=>{const n=ze(),i=ze(),l=jt(H(n,ne(Xc)));return de(H(l,ne(c=>c.totalCount)),a),de(H(l,ne(c=>c.groupIndices)),t),de(H(tt(o,s,r),be(([c,d])=>La(d)),ne(([c,d,f])=>Lt(d.groupOffsetTree,Math.max(c-f,0),"v")[0]),qe(),ne(c=>[c])),i),{groupCounts:n,topItemsIndexes:i}},Ye(Gt,bt)),cs=Oe(([{log:t}])=>{const s=G(!1),a=jt(H(s,be(r=>r),qe()));return Be(s,r=>{r&&Xe(t)("props updated",{},nt.DEBUG)}),{didMount:a,propsReady:s}},Ye(ls),{singleton:!0}),Jc=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ni(t){const s=typeof t=="number"?{index:t}:t;return s.align||(s.align="start"),(!s.behavior||!Jc)&&(s.behavior="auto"),s.offset===void 0&&(s.offset=0),s}const na=Oe(([{gap:t,listRefresh:s,sizes:a,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:n,footerHeight:i,headerHeight:l,scrollingInProgress:c,scrollTo:d,smoothScrollTargetReached:f,viewportHeight:v},{log:x}])=>{const g=ze(),T=ze(),C=G(0);let S=null,p=null,y=null;function k(){S!==null&&(S(),S=null),y!==null&&(y(),y=null),p&&(clearTimeout(p),p=null),Ie(c,!1)}return de(H(g,Ee(a,v,r,C,l,i,x),Ee(t,n,o),ne(([[L,N,B,m,j,w,R,z],V,Q,F])=>{const W=ni(L),{align:ee,behavior:ie,offset:je}=W,ve=m-1,ke=ai(W,N,ve);let le=Zs(ke,N.offsetTree,V)+w;ee==="end"?(le+=Q+Lt(N.sizeTree,ke)[1]-B+F,ke===ve&&(le+=R)):ee==="center"?le+=(Q+Lt(N.sizeTree,ke)[1]-B+F)/2:le-=j,je!==void 0&&je!==0&&(le+=je);const P=K=>{k(),K?(z("retrying to scroll to",{location:L},nt.DEBUG),Ie(g,L)):(Ie(T,!0),z("list did not change, scroll successful",{},nt.DEBUG))};if(k(),ie==="smooth"){let K=!1;y=Be(s,ae=>{K=K||ae}),S=Mt(f,()=>{P(K)})}else S=Mt(H(s,Zc(150)),P);return p=setTimeout(()=>{k()},1200),Ie(c,!0),z("scrolling from index to",{behavior:ie,index:ke,top:le},nt.DEBUG),{behavior:ie,top:le}})),d),{scrollTargetReached:T,scrollToIndex:g,topListHeight:C}},Ye(Gt,bt,ls),{singleton:!0});function Zc(t){return s=>{const a=setTimeout(()=>{s(!1)},t);return r=>{r&&(s(!0),clearTimeout(a))}}}function kr(t,s){t===0?s():requestAnimationFrame(()=>{kr(t-1,s)})}function Cr(t,s){const a=s-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}const oa=Oe(([{defaultItemSize:t,listRefresh:s,sizes:a},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:n},{didMount:i}])=>{const l=G(!0),c=G(0),d=G(!0);return de(H(i,Ee(c),be(([f,v])=>v!==0),Dt(!1)),l),de(H(i,Ee(c),be(([f,v])=>v!==0),Dt(!1)),d),Be(H(tt(s,i),Ee(l,a,t,d),be(([[,f],v,{sizeTree:x},g,T])=>f&&(!Ue(x)||wr(g))&&!v&&!T),Ee(c)),([,f])=>{Mt(o,()=>{Ie(d,!0)}),kr(4,()=>{Mt(r,()=>{Ie(l,!0)}),Ie(n,f)})}),{initialItemFinalLocationReached:d,initialTopMostItemIndex:c,scrolledToInitialItem:l}},Ye(Gt,bt,na,cs),{singleton:!0});function oi(t,s){return Math.abs(t-s)<1.01}const ea="up",Ws="down",ed="none",td={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},sd=0,ia=Oe(([{footerHeight:t,headerHeight:s,scrollBy:a,scrollContainerState:r,scrollTop:o,viewportHeight:n}])=>{const i=G(!1),l=G(!0),c=ze(),d=ze(),f=G(4),v=G(sd),x=ht(H(ir(H(ge(o),bs(1),Dt(!0)),H(ge(o),bs(1),Dt(!1),zn(100))),qe()),!1),g=ht(H(ir(H(a,Dt(!0)),H(a,Dt(!1),zn(200))),qe()),!1);de(H(tt(ge(o),ge(v)),ne(([y,k])=>y<=k),qe()),l),de(H(l,Wt(50)),d);const T=jt(H(tt(r,ge(n),ge(s),ge(t),ge(f)),$t((y,[{scrollHeight:k,scrollTop:L},N,B,m,j])=>{const w=L+N-k>-j,R={scrollHeight:k,scrollTop:L,viewportHeight:N};if(w){let V,Q;return L>y.state.scrollTop?(V="SCROLLED_DOWN",Q=y.state.scrollTop-L):(V="SIZE_DECREASED",Q=y.state.scrollTop-L||y.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:Q,state:R}}let z;return R.scrollHeight>y.state.scrollHeight?z="SIZE_INCREASED":Ny!==void 0&&y.atBottom===k.atBottom))),C=ht(H(r,$t((y,{scrollHeight:k,scrollTop:L,viewportHeight:N})=>{if(!oi(y.scrollHeight,k)){const B=k-(L+N)<1;return y.scrollTop!==L&&B?{changed:!0,jump:y.scrollTop-L,scrollHeight:k,scrollTop:L}:{changed:!0,jump:0,scrollHeight:k,scrollTop:L}}return{changed:!1,jump:0,scrollHeight:k,scrollTop:L}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(y=>y.changed),ne(y=>y.jump)),0);de(H(T,ne(y=>y.atBottom)),i),de(H(i,Wt(50)),c);const S=G(Ws);de(H(r,ne(({scrollTop:y})=>y),qe(),$t((y,k)=>Xe(g)?{direction:y.direction,prevScrollTop:k}:{direction:ky.direction)),S),de(H(r,Wt(50),Dt(ed)),S);const p=G(0);return de(H(x,be(y=>!y),Dt(0)),p),de(H(o,Wt(100),Ee(x),be(([y,k])=>k),$t(([y,k],[L])=>[k,L],[0,0]),ne(([y,k])=>k-y)),p),{atBottomState:T,atBottomStateChange:c,atBottomThreshold:f,atTopStateChange:d,atTopThreshold:v,isAtBottom:i,isAtTop:l,isScrolling:x,lastJumpDueToItemResize:C,scrollDirection:S,scrollVelocity:p}},Ye(bt)),ta="top",sa="bottom",$n="none";function Fn(t,s,a){return typeof t=="number"?a===ea&&s===ta||a===Ws&&s===sa?t:0:a===ea?s===ta?t.main:t.reverse:s===sa?t.main:t.reverse}function On(t,s){return typeof t=="number"?t:t[s]??0}const Tr=Oe(([{deviation:t,fixedHeaderHeight:s,headerHeight:a,scrollTop:r,viewportHeight:o}])=>{const n=ze(),i=G(0),l=G(0),c=G(0),d=ht(H(tt(ge(r),ge(o),ge(a),ge(n,Js),ge(c),ge(i),ge(s),ge(t),ge(l)),ne(([f,v,x,[g,T],C,S,p,y,k])=>{const L=f-y,N=S+p,B=Math.max(x-L,0);let m=$n;const j=On(k,ta),w=On(k,sa);return g-=y,g+=x+p,T+=x+p,T-=y,g>f+N-j&&(m=ea),Tf!==null),qe(Js)),[0,0]);return{increaseViewportBy:l,listBoundary:n,overscan:c,topListHeight:i,visibleRange:d}},Ye(bt),{singleton:!0});function ad(t,s,a){if(La(s)){const r=si(t,s);return[{index:Lt(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 Va={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ba(t,s,a,r,o,n){const{lastIndex:i,lastOffset:l,lastSize:c}=o;let d=0,f=0;if(t.length>0){d=t[0].offset;const C=t[t.length-1];f=C.offset+C.size}const v=a-i,x=l+v*c+(v-1)*r,g=d,T=x-f;return{bottom:f,firstItemIndex:n,items:Bn(t,o,n),offsetBottom:T,offsetTop:d,top:g,topItems:Bn(s,o,n),topListHeight:s.reduce((C,S)=>S.size+C,0),totalCount:a}}function ii(t,s,a,r,o,n){let i=0;if(a.groupIndices.length>0)for(const f of a.groupIndices){if(f-i>=t)break;i++}const l=t+i,c=Cr(s,l),d=Array.from({length:l}).map((f,v)=>({data:n[v+c],index:v+c,offset:0,size:0}));return ba(d,[],l,o,a,r)}function Bn(t,s,a){if(t.length===0)return[];if(!La(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=Es(s.groupOffsetTree,r,o);let l,c=0;for(const d of t){(!l||l.end{const C=G([]),S=G(0),p=ze(),y=G(0);de(n.topItemsIndexes,C);const k=ht(H(tt(g,T,ge(c,Js),ge(o),ge(r),ge(d),f,ge(C),ge(s),ge(a),ge(y),t),be(([m,j,,w,,,,,,,,R])=>{const z=R!==void 0&&R.length!==w;return m&&!j&&!z}),ne(([,,[m,j],w,R,z,V,Q,F,W,ee,ie])=>{const je=R,{offsetTree:ve,sizeTree:ke}=je,le=Xe(S);if(w===0)return{...Va,totalCount:w};if(m===0&&j===0)return le===0?{...Va,totalCount:w}:ii(le,z,R,F,W,ie||[]);if(Ue(ke))return le>0?null:ba(ad(Cr(z,w),je,ie),[],w,W,je,F);const P=[];if(Q.length>0){const X=Q[0],b=Q[Q.length-1];let I=0;for(const E of Es(ke,X,b)){const U=E.value,Y=Math.max(E.start,X),re=Math.min(E.end,b);for(let te=Y;te<=re;te++)P.push({data:ie?.[te],index:te,offset:I,size:U}),I+=U}}if(!V)return ba([],P,w,W,je,F);const K=Q.length>0?Q[Q.length-1]+1:0,ae=Uc(ve,m,j,K);if(ae.length===0)return null;const Le=w-1,Ae=za([],X=>{for(const b of ae){const I=b.value;let E=I.offset,U=b.start;const Y=I.size;if(I.offset=j);te++)X.push({data:ie?.[te],index:te,offset:E,size:Y}),E+=Y+W}}),Pe=Pn(ee,ta),O=Pn(ee,sa);if(Ae.length>0&&(Pe>0||O>0)){const X=Ae[0],b=Ae[Ae.length-1];if(Pe>0&&X.index>K){const I=Math.min(Pe,X.index-K),E=[];let U=X.offset;for(let Y=X.index-1;Y>=X.index-I;Y--){const re=Es(ke,Y,Y)[0]?.value??X.size;U-=re+W,E.unshift({data:ie?.[Y],index:Y,offset:U,size:re})}Ae.unshift(...E)}if(O>0&&b.indexm!==null),qe()),Va);de(H(t,be(wr),ne(m=>m?.length)),o),de(H(k,ne(m=>m.topListHeight)),v),de(v,l),de(H(k,ne(m=>[m.top,m.bottom])),i),de(H(k,ne(m=>m.items)),p);const L=jt(H(k,be(({items:m})=>m.length>0),Ee(o,t),be(([{items:m},j])=>m[m.length-1].originalIndex===j-1),ne(([,m,j])=>[m-1,j]),qe(Js),ne(([m])=>m))),N=jt(H(k,Wt(200),be(({items:m,topItems:j})=>m.length>0&&m[0].originalIndex===j.length),ne(({items:m})=>m[0].index),qe())),B=jt(H(k,be(({items:m})=>m.length>0),ne(({items:m})=>{let j=0,w=m.length-1;for(;m[j].type==="group"&&jj;)w--;return{endIndex:m[w].index,startIndex:m[j].index}}),qe(ei)));return{endReached:L,initialItemCount:S,itemsRendered:p,listState:k,minOverscanItemCount:y,rangeChanged:B,startReached:N,topItemsIndexes:C,...x}},Ye(Gt,ri,Tr,oa,na,ia,cs,yr),{singleton:!0}),li=Oe(([{fixedFooterHeight:t,fixedHeaderHeight:s,footerHeight:a,headerHeight:r},{listState:o}])=>{const n=ze(),i=ht(H(tt(a,t,r,s,o),ne(([l,c,d,f,v])=>l+c+d+f+v.offsetBottom+v.bottom)),0);return de(ge(i),n),{totalListHeight:i,totalListHeightChanged:n}},Ye(bt,ws),{singleton:!0}),rd=Oe(([{viewportHeight:t},{totalListHeight:s}])=>{const a=G(!1),r=ht(H(tt(a,t,s),be(([o])=>o),ne(([,o,n])=>Math.max(0,o-n)),Wt(0),qe()),0);return{alignToBottom:a,paddingTopAddition:r}},Ye(bt,li),{singleton:!0}),ci=Oe(()=>({context:G(null)})),nd=({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,di=Oe(([{gap:t,sizes:s,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:n,scrollingInProgress:i,scrollTop:l,viewportHeight:c},{scrollToIndex:d}])=>{const f=ze();return de(H(f,Ee(s,c,a,n,o,r,l),Ee(t),ne(([[v,x,g,T,C,S,p,y],k])=>{const{calculateViewLocation:L=nd,done:N,...B}=v,m=ai(v,x,T-1),j=Zs(m,x.offsetTree,k)+C+S,w=j+Lt(x.sizeTree,m)[1],R=y+S,z=y+g-p,V=L({itemBottom:w,itemTop:j,locationParams:B,viewportBottom:z,viewportTop:R});return V!==null?N&&Mt(H(i,be(Q=>!Q),bs(Xe(i)?1:2)),N):N?.(),V}),be(v=>v!==null)),d),{scrollIntoView:f}},Ye(Gt,bt,na,ws,ls),{singleton:!0});function Hn(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const od=(t,s)=>typeof t=="function"?Hn(t(s)):s&&Hn(t),id=Oe(([{listRefresh:t,totalCount:s,fixedItemSize:a,data:r},{atBottomState:o,isAtBottom:n},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:c,propsReady:d},{log:f},{scrollingInProgress:v},{context:x},{scrollIntoView:g}])=>{const T=G(!1),C=ze();let S=null;function p(N){Ie(i,{align:"end",behavior:N,index:"LAST"})}Be(H(tt(H(ge(s),bs(1)),c),Ee(ge(T),n,l,v),ne(([[N,B],m,j,w,R])=>{let z=B&&w,V="auto";return z&&(V=od(m,j||R),z=z&&V!==!1),{followOutputBehavior:V,shouldFollow:z,totalCount:N}}),be(({shouldFollow:N})=>N)),({followOutputBehavior:N,totalCount:B})=>{S!==null&&(S(),S=null),Xe(a)!==void 0?requestAnimationFrame(()=>{Xe(f)("following output to ",{totalCount:B},nt.DEBUG),p(N)}):S=Mt(t,()=>{Xe(f)("following output to ",{totalCount:B},nt.DEBUG),p(N),S=null})});function y(N){const B=Mt(o,m=>{N&&!m.atBottom&&m.notAtBottomBecause==="SIZE_INCREASED"&&S===null&&(Xe(f)("scrolling to bottom due to increased size",{},nt.DEBUG),p("auto"))});setTimeout(B,100)}Be(H(tt(ge(T),s,d),be(([N,,B])=>N!==!1&&B),$t(({value:N},[,B])=>({refreshed:N===B,value:B}),{refreshed:!1,value:0}),be(({refreshed:N})=>N),Ee(T,s)),([,N])=>{Xe(l)&&y(N!==!1)}),Be(C,()=>{y(Xe(T)!==!1)}),Be(tt(ge(T),o),([N,B])=>{N!==!1&&!B.atBottom&&B.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&p("auto")});const k=G(null),L=ze();return de(ir(H(ge(r),ne(N=>N?.length??0)),H(ge(s))),L),Be(H(tt(H(L,bs(1)),c),Ee(ge(k),l,v,x),ne(([[N,B],m,j,w,R])=>B&&j&&m?.({context:R,totalCount:N,scrollingInProgress:w})),be(N=>!!N),Wt(0)),N=>{S!==null&&(S(),S=null),Xe(a)!==void 0?requestAnimationFrame(()=>{Xe(f)("scrolling into view",{}),Ie(g,N)}):S=Mt(t,()=>{Xe(f)("scrolling into view",{}),Ie(g,N),S=null})}),{autoscrollToBottom:C,followOutput:T,scrollIntoViewOnChange:k}},Ye(Gt,ia,na,oa,cs,ls,bt,ci,di)),ld=Oe(([{data:t,firstItemIndex:s,gap:a,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:n,listState:i},{didMount:l}])=>(de(H(l,Ee(n),be(([,c])=>c!==0),Ee(o,r,s,a,t),ne(([[,c],d,f,v,x,g=[]])=>ii(c,d,f,v,x,g))),i),{}),Ye(Gt,oa,ws,cs),{singleton:!0}),cd=Oe(([{didMount:t},{scrollTo:s},{listState:a}])=>{const r=G(0);return Be(H(t,Ee(r),be(([,o])=>o!==0),ne(([,o])=>({top:o}))),o=>{Mt(H(a,bs(1),be(n=>n.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(s,o)})})}),{initialScrollTop:r}},Ye(cs,bt,ws),{singleton:!0}),ui=Oe(([{scrollVelocity:t}])=>{const s=G(!1),a=ze(),r=G(!1);return de(H(t,Ee(r,s,a),be(([o,n])=>n!==!1&&n!==void 0),ne(([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}),qe()),s),Be(H(tt(s,t,a),Ee(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}},Ye(ia),{singleton:!0}),Ir=Oe(([{scrollContainerState:t,scrollTo:s}])=>{const a=ze(),r=ze(),o=ze(),n=G(!1),i=G(void 0);return de(H(tt(a,r),ne(([{scrollTop:l,viewportHeight:c},{offsetTop:d,listHeight:f}])=>({scrollHeight:f,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),de(H(s,Ee(r),ne(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),o),{customScrollParent:i,useWindowScroll:n,windowScrollContainerState:a,windowScrollTo:o,windowViewportRect:r}},Ye(bt)),dd=Oe(([{sizeRanges:t,sizes:s},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:o},{didMount:n},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:c}])=>{const d=ze(),f=G(void 0),v=G(null),x=G(null);return de(l,v),de(c,x),Be(H(d,Ee(s,r,i,v,x,a)),([g,T,C,S,p,y,k])=>{const L=Wc(T.sizeTree);S&&p!==null&&y!==null&&(C=p.scrollTop-y.offsetTop),C-=k,g({ranges:L,scrollTop:C})}),de(H(f,be(wr),ne(ud)),o),de(H(n,Ee(f),be(([,g])=>g!==void 0),qe(),ne(([,g])=>g.ranges)),t),{getState:d,restoreStateFrom:f}},Ye(Gt,bt,oa,cs,Ir));function ud(t){return{align:"start",index:0,offset:t.scrollTop}}const md=Oe(([{topItemsIndexes:t}])=>{const s=G(0);return de(H(s,be(a=>a>=0),ne(a=>Array.from({length:a}).map((r,o)=>o))),t),{topItemCount:s}},Ye(ws));function mi(t){let s=!1,a;return(()=>(s||(s=!0,a=t()),a))}const xd=mi(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),pd=Oe(([{deviation:t,scrollBy:s,scrollingInProgress:a,scrollTop:r},{isAtBottom:o,isScrolling:n,lastJumpDueToItemResize:i,scrollDirection:l},{listState:c},{beforeUnshiftWith:d,gap:f,shiftWithOffset:v,sizes:x},{log:g},{recalcInProgress:T}])=>{const C=jt(H(c,Ee(i),$t(([,p,y,k],[{bottom:L,items:N,offsetBottom:B,totalCount:m},j])=>{const w=L+B;let R=0;return y===m&&p.length>0&&N.length>0&&(N[0].originalIndex===0&&p[0].originalIndex===0||(R=w-k,R!==0&&(R+=j))),[R,N,m,w]},[0,[],0,0]),be(([p])=>p!==0),Ee(r,l,a,o,g,T),be(([,p,y,k,,,L])=>!L&&!k&&p!==0&&y===ea),ne(([[p],,,,,y])=>(y("Upward scrolling compensation",{amount:p},nt.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 Be(H(C,Ee(t,n)),([p,y,k])=>{k&&xd()?Ie(t,y-p):S(-p)}),Be(H(tt(ht(n,!1),t,T),be(([p,y,k])=>!p&&!k&&y!==0),ne(([p,y])=>y),Wt(1)),S),de(H(v,ne(p=>({top:-p}))),s),Be(H(d,Ee(x,f),ne(([p,{groupIndices:y,lastSize:k,sizeTree:L},N])=>{function B(z){return z*(k+N)}if(y.length===0)return B(p);let m=0;const j=Xs(L,0);let w=0,R=0;for(;wp&&(m-=j,z=p-w+1),w+=z,m+=B(z),R++}return m})),p=>{Ie(t,p),requestAnimationFrame(()=>{Ie(s,{top:p}),requestAnimationFrame(()=>{Ie(t,0),Ie(T,!1)})})}),{deviation:t}},Ye(bt,ia,ws,Gt,ls,yr)),hd=Oe(([t,s,a,r,o,n,i,l,c,d,f])=>({...t,...s,...a,...r,...o,...n,...i,...l,...c,...d,...f}),Ye(Tr,ld,cs,ui,li,cd,rd,Ir,di,ls,ci)),xi=Oe(([{data:t,defaultItemSize:s,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:o,gap:n,groupIndices:i,heightEstimates:l,itemSize:c,sizeRanges:d,sizes:f,statefulTotalCount:v,totalCount:x,trackItemSizes:g},{initialItemFinalLocationReached:T,initialTopMostItemIndex:C,scrolledToInitialItem:S},p,y,k,L,{scrollToIndex:N},B,{topItemCount:m},{groupCounts:j},w])=>{const{listState:R,minOverscanItemCount:z,topItemsIndexes:V,rangeChanged:Q,...F}=L;return de(Q,w.scrollSeekRangeChanged),de(H(w.windowViewportRect,ne(W=>W.visibleHeight)),p.viewportHeight),{data:t,defaultItemHeight:s,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:o,gap:n,groupCounts:j,heightEstimates:l,initialItemFinalLocationReached:T,initialTopMostItemIndex:C,scrolledToInitialItem:S,sizeRanges:d,topItemCount:m,topItemsIndexes:V,totalCount:x,...k,groupIndices:i,itemSize:c,listState:R,minOverscanItemCount:z,scrollToIndex:N,statefulTotalCount:v,trackItemSizes:g,rangeChanged:Q,...F,...w,...p,sizes:f,...y}},Ye(Gt,oa,bt,dd,id,ws,na,pd,md,ri,hd));function fd(t,s){const a={},r={};let o=0;const n=t.length;for(;o(p[y]=k=>{const L=S[s.methods[y]];Ie(L,k)},p),{})}function f(S){return i.reduce((p,y)=>(p[y]=Mc(S[s.events[y]]),p),{})}const v=ce.forwardRef(function(S,p){const{children:y,...k}=S,[L]=ce.useState(()=>za(Lc(t),m=>{c(m,k)})),[N]=ce.useState(Mn(f,L));ua(()=>{for(const m of i)m in k&&Be(N[m],k[m]);return()=>{Object.values(N).map(Nr)}},[k,N,L]),ua(()=>{c(L,k)}),ce.useImperativeHandle(p,_n(d(L)));const B=a;return e.jsx(l.Provider,{value:L,children:a!==void 0?e.jsx(B,{...fd([...r,...o,...i],k),children:y}):y})}),x=S=>{const p=ce.useContext(l);return ce.useCallback(y=>{Ie(p[S],y)},[p,S])},g=S=>{const p=ce.useContext(l)[S],y=ce.useCallback(k=>Be(p,k),[p]);return ce.useSyncExternalStore(y,()=>Xe(p),()=>Xe(p))},T=S=>{const p=ce.useContext(l)[S],[y,k]=ce.useState(Mn(Xe,p));return ua(()=>Be(p,L=>{L!==y&&k(_n(L))}),[p,y]),y},C=parseInt(ce.version)>=18?g:T;return{Component:v,useEmitter:(S,p)=>{const y=ce.useContext(l)[S];ua(()=>Be(y,p),[p,y])},useEmitterValue:C,usePublisher:x}}const hi=ce.createContext(void 0),fi=ce.createContext(void 0),Wa="-webkit-sticky",Gn="sticky",Er=mi(()=>{if(typeof document>"u")return Gn;const t=document.createElement("div");return t.style.position=Wa,t.style.position===Wa?Wa:Gn}),gi=typeof document<"u"?ce.useLayoutEffect:ce.useEffect;function qa(t){return"self"in t}function gd(t){return"body"in t}function bi(t,s,a,r=zs,o,n){const i=ce.useRef(null),l=ce.useRef(null),c=ce.useRef(null),d=ce.useCallback(x=>{let g,T,C;const S=x.target;if(gd(S)||qa(S)){const y=qa(S)?S:S.defaultView;C=n===!0?y.scrollX:y.scrollY,g=n===!0?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight,T=n===!0?y.innerWidth:y.innerHeight}else C=n===!0?S.scrollLeft:S.scrollTop,g=n===!0?S.scrollWidth:S.scrollHeight,T=n===!0?S.offsetWidth:S.offsetHeight;const p=()=>{t({scrollHeight:g,scrollTop:Math.max(C,0),viewportHeight:T})};x.suppressFlushSync===!0?p():sr.flushSync(p),l.current!==null&&(C===l.current||C<=0||C===g-T)&&(l.current=null,s(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,s,n]);ce.useEffect(()=>{const x=o||i.current;return r(o||i.current),d({suppressFlushSync:!0,target:x}),x.addEventListener("scroll",d,{passive:!0}),()=>{r(null),x.removeEventListener("scroll",d)}},[i,d,a,r,o]);function f(x){const g=i.current;if(!g||(n===!0?"offsetWidth"in g&&g.offsetWidth===0:"offsetHeight"in g&&g.offsetHeight===0))return;const T=x.behavior==="smooth";let C,S,p;qa(g)?(S=Math.max(ns(g.document.documentElement,n===!0?"width":"height"),n===!0?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight),C=n===!0?g.innerWidth:g.innerHeight,p=n===!0?window.scrollX:window.scrollY):(S=g[n===!0?"scrollWidth":"scrollHeight"],C=ns(g,n===!0?"width":"height"),p=g[n===!0?"scrollLeft":"scrollTop"]);const y=S-C;if(x.top=Math.ceil(Math.max(Math.min(y,x.top),0)),oi(C,S)||x.top===p){t({scrollHeight:S,scrollTop:p,viewportHeight:C}),T&&s(!0);return}T?(l.current=x.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,s(!0)},1e3)):l.current=null,n===!0&&(x={...x.behavior!==void 0?{behavior:x.behavior}:{},left:x.top}),g.scrollTo(x)}function v(x){n===!0&&(x={...x.behavior!==void 0?{behavior:x.behavior}:{},...x.top!==void 0?{left:x.top}:{}}),i.current.scrollBy(x)}return{scrollByCallback:v,scrollerRef:i,scrollToCallback:f}}function Rr(t){return t}const bd=Oe(()=>{const t=G(l=>`Item ${l}`),s=G(l=>`Group ${l}`),a=G({}),r=G(Rr),o=G("div"),n=G(zs),i=(l,c=null)=>ht(H(a,ne(d=>d[l]),qe()),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")}}),vd=Oe(([t,s])=>({...t,...s}),Ye(xi,bd)),wd=({height:t})=>e.jsx("div",{style:{height:t}}),Nd={overflowAnchor:"none",position:Er(),zIndex:1},vi={overflowAnchor:"none"},jd={...vi,display:"inline-block",height:"100%"},Qn=ce.memo(function({showTopList:t=!1}){const s=ye("listState"),a=kt("sizeRanges"),r=ye("useWindowScroll"),o=ye("customScrollParent"),n=kt("windowScrollContainerState"),i=kt("scrollContainerState"),l=o||r?n:i,c=ye("itemContent"),d=ye("context"),f=ye("groupContent"),v=ye("trackItemSizes"),x=ye("itemSize"),g=ye("log"),T=kt("gap"),C=ye("horizontalDirection"),{callbackRef:S}=$c(a,x,v,t?zs:l,g,T,o,C,ye("skipAnimationFrameInResizeObserver")),[p,y]=ce.useState(0);Mr("deviation",F=>{p!==F&&y(F)});const k=ye("EmptyPlaceholder"),L=ye("ScrollSeekPlaceholder")??wd,N=ye("ListComponent"),B=ye("ItemComponent"),m=ye("GroupComponent"),j=ye("computeItemKey"),w=ye("isSeeking"),R=ye("groupIndices").length>0,z=ye("alignToBottom"),V=ye("initialItemFinalLocationReached"),Q=t?{}:{boxSizing:"border-box",...C?{display:"inline-block",height:"100%",marginLeft:p!==0?p:z?"auto":0,paddingLeft:s.offsetTop,paddingRight:s.offsetBottom,whiteSpace:"nowrap"}:{marginTop:p!==0?p:z?"auto":0,paddingBottom:s.offsetBottom,paddingTop:s.offsetTop},...V?{}:{visibility:"hidden"}};return!t&&s.totalCount===0&&k!==null&&k!==void 0?e.jsx(k,{...pt(k,d)}):e.jsx(N,{...pt(N,d),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:S,style:Q,children:(t?s.topItems:s.items).map(F=>{const W=F.originalIndex,ee=j(W+s.firstItemIndex,F.data,d);return w?h.createElement(L,{...pt(L,d),height:F.size,index:F.index,key:ee,type:F.type||"item",...F.type==="group"?{}:{groupIndex:F.groupIndex}}):F.type==="group"?h.createElement(m,{...pt(m,d),"data-index":W,"data-item-index":F.index,"data-known-size":F.size,key:ee,style:Nd},f(F.index,d)):h.createElement(B,{...pt(B,d),...Cd(B,F.data),"data-index":W,"data-item-group-index":F.groupIndex,"data-item-index":F.index,"data-known-size":F.size,key:ee,style:C?jd:vi},R?c(F.index,F.groupIndex,F.data,d):c(F.index,F.data,d))})})}),yd={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Sd={outline:"none",overflowX:"auto",position:"relative"},_r=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),wi=(t,s,a=0)=>({..._r(t),position:s?"relative":"absolute",top:s?-a:0}),kd={position:Er(),top:0,width:"100%",zIndex:1};function pt(t,s){if(typeof t!="string")return{context:s}}function Cd(t,s){return{item:typeof t=="string"?void 0:s}}const Td=ce.memo(function(){const t=ye("HeaderComponent"),s=kt("headerHeight"),a=ye("HeaderFooterTag"),r=vs(ce.useMemo(()=>n=>{s(ns(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,o)})}):null}),Id=ce.memo(function(){const t=ye("FooterComponent"),s=kt("footerHeight"),a=ye("HeaderFooterTag"),r=vs(ce.useMemo(()=>n=>{s(ns(n,"height"))},[s]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,o)})}):null});function Ni({useEmitter:t,useEmitterValue:s,usePublisher:a}){return ce.memo(function({children:r,style:o,context:n,...i}){const l=a("scrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),f=s("scrollerRef"),v=s("horizontalDirection")||!1,{scrollByCallback:x,scrollerRef:g,scrollToCallback:T}=bi(l,d,c,f,void 0,v);return t("scrollTo",T),t("scrollBy",x),e.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:g,style:{...v?Sd:yd,...o},tabIndex:0,...i,...pt(c,n),children:r})})}function ji({useEmitter:t,useEmitterValue:s,usePublisher:a}){return ce.memo(function({children:r,style:o,context:n,...i}){const l=a("windowScrollContainerState"),c=s("ScrollerComponent"),d=a("smoothScrollTargetReached"),f=s("totalListHeight"),v=s("deviation"),x=s("customScrollParent"),g=ce.useRef(null),T=s("scrollerRef"),{scrollByCallback:C,scrollerRef:S,scrollToCallback:p}=bi(l,d,c,T,x);return gi(()=>(S.current=x||g.current?.ownerDocument.defaultView,()=>{S.current=null}),[S,x]),t("windowScrollTo",p),t("scrollBy",C),e.jsx(c,{ref:g,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...f!==0?{height:f+v}:void 0},...i,...pt(c,n),children:r})})}const Ed=({children:t})=>{const s=ce.useContext(hi),a=kt("viewportHeight"),r=kt("fixedItemHeight"),o=ye("alignToBottom"),n=ye("horizontalDirection"),i=ce.useMemo(()=>Vo(a,c=>ns(c,n?"width":"height")),[a,n]),l=vs(i,!0,ye("skipAnimationFrameInResizeObserver"));return ce.useEffect(()=>{s&&(a(s.viewportHeight),r(s.itemHeight))},[s,a,r]),e.jsx("div",{"data-viewport-type":"element",ref:l,style:_r(o),children:t})},Rd=({children:t})=>{const s=ce.useContext(hi),a=kt("windowViewportRect"),r=kt("fixedItemHeight"),o=ye("customScrollParent"),n=ye("useWindowScroll"),i=ye("topListHeight"),l=qo(a,o,ye("skipAnimationFrameInResizeObserver")),c=ye("alignToBottom");return ce.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:wi(c,n,i),children:t})},_d=({children:t})=>{const s=ye("TopItemListComponent")??"div",a=ye("headerHeight"),r={...kd,marginTop:`${a}px`},o=ye("context");return e.jsx(s,{style:r,...pt(s,o),children:t})},Md=ce.memo(function(t){const s=ye("useWindowScroll"),a=ye("topItemsIndexes").length>0,r=ye("customScrollParent"),o=ye("context");return e.jsxs(r||s?Ad:Ld,{...t,context:o,children:[a&&e.jsx(_d,{children:e.jsx(Qn,{showTopList:!0})}),e.jsxs(r||s?Rd:Ed,{children:[e.jsx(Td,{}),e.jsx(Qn,{}),e.jsx(Id,{})]})]})}),{Component:zd,useEmitter:Mr,useEmitterValue:ye,usePublisher:kt}=pi(vd,{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"}},Md),Ld=Ni({useEmitter:Mr,useEmitterValue:ye,usePublisher:kt}),Ad=ji({useEmitter:Mr,useEmitterValue:ye,usePublisher:kt}),Dd=zd,$d=Oe(()=>{const t=G(d=>e.jsxs("td",{children:["Item $",d]})),s=G(null),a=G(d=>e.jsxs("td",{colSpan:1e3,children:["Group ",d]})),r=G(null),o=G(null),n=G({}),i=G(Rr),l=G(zs),c=(d,f=null)=>ht(H(n,ne(v=>v[d]),qe()),f);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")}});Ye(xi,$d);Er();const Un={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Fd={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Vn,floor:Ea,max:qs,min:Ya,round:Wn}=Math;function qn(t,s,a){return Array.from({length:s-t+1}).map((r,o)=>({data:a===null?null:a[o+t],index:o+t}))}function Od(t){return{...Fd,items:t}}function ma(t,s){return t!==void 0&&t.width===s.width&&t.height===s.height}function Bd(t,s){return t!==void 0&&t.column===s.column&&t.row===s.row}const Pd=Oe(([{increaseViewportBy:t,listBoundary:s,overscan:a,visibleRange:r},{footerHeight:o,headerHeight:n,scrollBy:i,scrollContainerState:l,scrollTo:c,scrollTop:d,smoothScrollTargetReached:f,viewportHeight:v},x,g,{didMount:T,propsReady:C},{customScrollParent:S,useWindowScroll:p,windowScrollContainerState:y,windowScrollTo:k,windowViewportRect:L},N])=>{const B=G(0),m=G(0),j=G(Un),w=G({height:0,width:0}),R=G({height:0,width:0}),z=ze(),V=ze(),Q=G(0),F=G(null),W=G({column:0,row:0}),ee=ze(),ie=ze(),je=G(!1),ve=G(0),ke=G(!0),le=G(!1),P=G(!1);Be(H(T,Ee(ve),be(([O,X])=>X!==0)),()=>{Ie(ke,!1)}),Be(H(tt(T,ke,R,w,ve,le),be(([O,X,b,I,,E])=>O&&!X&&b.height!==0&&I.height!==0&&!E)),([,,,,O])=>{Ie(le,!0),kr(1,()=>{Ie(z,O)}),Mt(H(d),()=>{Ie(s,[0,0]),Ie(ke,!0)})}),de(H(ie,be(O=>O!=null&&O.scrollTop>0),Dt(0)),m),Be(H(T,Ee(ie),be(([,O])=>O!=null)),([,O])=>{O&&(Ie(w,O.viewport),Ie(R,O.item),Ie(W,O.gap),O.scrollTop>0&&(Ie(je,!0),Mt(H(d,bs(1)),X=>{Ie(je,!1)}),Ie(c,{top:O.scrollTop})))}),de(H(w,ne(({height:O})=>O)),v),de(H(tt(ge(w,ma),ge(R,ma),ge(W,(O,X)=>O!==void 0&&O.column===X.column&&O.row===X.row),ge(d)),ne(([O,X,b,I])=>({gap:b,item:X,scrollTop:I,viewport:O}))),ee),de(H(tt(ge(B),r,ge(W,Bd),ge(R,ma),ge(w,ma),ge(F),ge(m),ge(je),ge(ke),ge(ve)),be(([,,,,,,,O])=>!O),ne(([O,[X,b],I,E,U,Y,re,,te,A])=>{const{column:oe,row:me}=I,{height:Ne,width:J}=E,{width:_e}=U;if(re===0&&(O===0||_e===0))return Un;if(J===0){const _=Cr(A,O),se=_+Math.max(re-1,0);return Od(qn(_,se,Y))}const Ve=yi(_e,J,oe);let Te,Ke;te?X===0&&b===0&&re>0?(Te=0,Ke=re-1):(Te=Ve*Ea((X+me)/(Ne+me)),Ke=Ve*Vn((b+me)/(Ne+me))-1,Ke=Ya(O-1,qs(Ke,Ve-1)),Te=Ya(Ke,qs(0,Te))):(Te=0,Ke=-1);const Me=qn(Te,Ke,Y),{bottom:wt,top:It}=Yn(U,I,E,Me),$=Vn(O/Ve),Z=$*Ne+($-1)*me-wt;return{bottom:wt,itemHeight:Ne,items:Me,itemWidth:J,offsetBottom:Z,offsetTop:It,top:It}})),j),de(H(F,be(O=>O!==null),ne(O=>O.length)),B),de(H(tt(w,R,j,W),be(([O,X,{items:b}])=>b.length>0&&X.height!==0&&O.height!==0),ne(([O,X,{items:b},I])=>{const{bottom:E,top:U}=Yn(O,I,X,b);return[U,E]}),qe(Js)),s);const K=G(!1);de(H(d,Ee(K),ne(([O,X])=>X||O!==0)),K);const ae=jt(H(tt(j,B),be(([{items:O}])=>O.length>0),Ee(K),be(([[O,X],b])=>{const I=O.items[O.items.length-1].index===X-1;return(b||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===X)&&I}),ne(([[,O]])=>O-1),qe())),Le=jt(H(ge(j),be(({items:O})=>O.length>0&&O[0].index===0),Dt(0),qe())),Ae=jt(H(ge(j),Ee(je),be(([{items:O},X])=>O.length>0&&!X),ne(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),qe(ei),Wt(0)));de(Ae,g.scrollSeekRangeChanged),de(H(z,Ee(w,R,B,W),ne(([O,X,b,I,E])=>{const U=ni(O),{align:Y,behavior:re,offset:te}=U;let A=U.index;A==="LAST"&&(A=I-1),A=qs(0,A,Ya(I-1,A));let oe=mr(X,E,b,A);return Y==="end"?oe=Wn(oe-X.height+b.height):Y==="center"&&(oe=Wn(oe-X.height/2+b.height/2)),te!==void 0&&te!==0&&(oe+=te),{behavior:re,top:oe}})),c);const Pe=ht(H(j,ne(O=>O.offsetBottom+O.bottom)),0);return de(H(L,ne(O=>({height:O.visibleHeight,width:O.visibleWidth}))),w),{customScrollParent:S,data:F,deviation:Q,footerHeight:o,gap:W,headerHeight:n,increaseViewportBy:t,initialItemCount:m,itemDimensions:R,overscan:a,restoreStateFrom:ie,scrollBy:i,scrollContainerState:l,scrollHeight:V,scrollTo:c,scrollToIndex:z,scrollTop:d,smoothScrollTargetReached:f,totalCount:B,useWindowScroll:p,viewportDimensions:w,windowScrollContainerState:y,windowScrollTo:k,windowViewportRect:L,...g,gridState:j,horizontalDirection:P,initialTopMostItemIndex:ve,totalListHeight:Pe,...x,endReached:ae,propsReady:C,rangeChanged:Ae,startReached:Le,stateChanged:ee,stateRestoreInProgress:je,...N}},Ye(Tr,bt,ia,ui,cs,Ir,ls));function yi(t,s,a){return qs(1,Ea((t+a)/(Ea(s)+a)))}function Yn(t,s,a,r){const{height:o}=a;if(o===void 0||r.length===0)return{bottom:0,top:0};const n=mr(t,s,a,r[0].index);return{bottom:mr(t,s,a,r[r.length-1].index)+o,top:n}}function mr(t,s,a,r){const o=yi(t.width,a.width,s.column),n=Ea(r/o),i=n*a.height+qs(0,n-1)*s.row;return i>0?i+s.row:i}const Hd=Oe(()=>{const t=G(v=>`Item ${v}`),s=G({}),a=G(null),r=G("virtuoso-grid-item"),o=G("virtuoso-grid-list"),n=G(Rr),i=G("div"),l=G(zs),c=(v,x=null)=>ht(H(s,ne(g=>g[v]),qe()),x),d=G(!1),f=G(!1);return de(ge(f),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:f,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Gd=Oe(([t,s])=>({...t,...s}),Ye(Pd,Hd)),Qd=ce.memo(function(){const t=We("gridState"),s=We("listClassName"),a=We("itemClassName"),r=We("itemContent"),o=We("computeItemKey"),n=We("isSeeking"),i=Ct("scrollHeight"),l=We("ItemComponent"),c=We("ListComponent"),d=We("ScrollSeekPlaceholder"),f=We("context"),v=Ct("itemDimensions"),x=Ct("gap"),g=We("log"),T=We("stateRestoreInProgress"),C=Ct("reportReadyState"),S=vs(ce.useMemo(()=>p=>{const y=p.parentElement.parentElement.scrollHeight;i(y);const k=p.firstChild;if(k!==null){const{height:L,width:N}=k.getBoundingClientRect();v({height:L,width:N})}x({column:Kn("column-gap",getComputedStyle(p).columnGap,g),row:Kn("row-gap",getComputedStyle(p).rowGap,g)})},[i,v,x,g]),!0,!1);return gi(()=>{t.itemHeight>0&&t.itemWidth>0&&C(!0)},[t]),T?null:e.jsx(c,{className:s,ref:S,...pt(c,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(p=>{const y=o(p.index,p.data,f);return n?e.jsx(d,{...pt(d,f),height:t.itemHeight,index:p.index,width:t.itemWidth},y):h.createElement(l,{...pt(l,f),className:a,"data-index":p.index,key:y},r(p.index,p.data,f))})})}),Ud=ce.memo(function(){const t=We("HeaderComponent"),s=Ct("headerHeight"),a=We("headerFooterTag"),r=vs(ce.useMemo(()=>n=>{s(ns(n,"height"))},[s]),!0,!1),o=We("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,o)})}):null}),Vd=ce.memo(function(){const t=We("FooterComponent"),s=Ct("footerHeight"),a=We("headerFooterTag"),r=vs(ce.useMemo(()=>n=>{s(ns(n,"height"))},[s]),!0,!1),o=We("context");return t!=null?e.jsx(a,{ref:r,children:e.jsx(t,{...pt(t,o)})}):null}),Wd=({children:t})=>{const s=ce.useContext(fi),a=Ct("itemDimensions"),r=Ct("viewportDimensions"),o=vs(ce.useMemo(()=>n=>{r(n.getBoundingClientRect())},[r]),!0,!1);return ce.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:_r(!1),children:t})},qd=({children:t})=>{const s=ce.useContext(fi),a=Ct("windowViewportRect"),r=Ct("itemDimensions"),o=We("customScrollParent"),n=We("useWindowScroll"),i=qo(a,o,!1);return ce.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:wi(!1,n),children:t})},Yd=ce.memo(function({...t}){const s=We("useWindowScroll"),a=We("customScrollParent"),r=a||s?Xd:Kd,o=a||s?qd:Wd,n=We("context");return e.jsx(r,{...t,...pt(r,n),children:e.jsxs(o,{children:[e.jsx(Ud,{}),e.jsx(Qd,{}),e.jsx(Vd,{})]})})}),{useEmitter:Si,useEmitterValue:We,usePublisher:Ct}=pi(Gd,{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"}},Yd),Kd=Ni({useEmitter:Si,useEmitterValue:We,usePublisher:Ct}),Xd=ji({useEmitter:Si,useEmitterValue:We,usePublisher:Ct});function Kn(t,s,a){return s!=="normal"&&s?.endsWith("px")!==!0&&a(`${t} was not resolved to pixel value correctly`,s,nt.WARN),s==="normal"?0:parseInt(s??"0",10)}function Xn(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 Jn=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th"]);function Jd(t,s="component",a){const r=t.getBoundingClientRect(),o=[],n=a?.leafTags?new Set([...Jn,...a.leafTags]):Jn,i=a?.captureRoundedBorders??!0,l=a?.excludeTags?new Set(a.excludeTags):null,c=a?.excludeSelectors??null;function d(f){const v=getComputedStyle(f);if(v.display==="none"||v.visibility==="hidden"||v.opacity==="0")return;const x=f.tagName.toLowerCase();if(l?.has(x)||c?.some(w=>f.matches(w)))return;const g=[...f.children].filter(w=>{const R=getComputedStyle(w);return R.display!=="none"&&R.visibility!=="hidden"&&R.opacity!=="0"}),T=x==="img"||x==="svg"||x==="video"||x==="canvas",C=x==="input"||x==="button"||x==="textarea"||x==="select",S=g.length===0||T||C||n.has(x),p=v.backgroundColor,y=p!=="rgba(0, 0, 0, 0)"&&p!=="transparent",k=v.backgroundImage!=="none",L=parseFloat(v.borderTopWidth)||0,N=i&&L>0&&v.borderTopColor!=="rgba(0, 0, 0, 0)"&&v.borderTopColor!=="transparent",B=(parseFloat(v.borderTopLeftRadius)||0)>0,m=y||k||N&&B,j=x==="tr"||x==="td"||x==="th"||x==="thead"||x==="tbody"||x==="table";if(S){const w=f.getBoundingClientRect();if(w.width<1||w.height<1)return;const R=T&&w.width>0&&w.height>0&&Math.abs(w.width-w.height)<4,z=j?0:R?"50%":Zn(v,f)??8,V=r.width;o.push({x:V>0?+((w.left-r.left)/V*100).toFixed(4):0,y:Math.round(w.top-r.top),w:V>0?+(w.width/V*100).toFixed(4):0,h:Math.round(w.height),r:z});return}if(m){const w=f.getBoundingClientRect();if(w.width>=1&&w.height>=1){const R=j?0:Zn(v,f)??8,z=r.width;o.push({x:z>0?+((w.left-r.left)/z*100).toFixed(4):0,y:Math.round(w.top-r.top),w:z>0?+(w.width/z*100).toFixed(4):0,h:Math.round(w.height),r:R,c:!0})}}for(const w of g)d(w)}for(const f of t.children)d(f);return{name:s,viewportWidth:Math.round(r.width),width:Math.round(r.width),height:Math.round(r.height),bones:o}}function Zn(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 Zd=new Map;function eu(t){return Zd.get(t)}function tu(){typeof window<"u"&&window.__BONEYARD_BUILD&&(window.__BONEYARD_SNAPSHOT=Jd)}function su(){return typeof window<"u"&&window.__BONEYARD_BUILD===!0}function au(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 ys={angle:110,start:30,end:70,speed:"2s",lightHighlight:"#f7f7f7",darkHighlight:"#2c2c2c"},Os={speed:"1.8s",lightAdjust:.3,darkAdjust:.02},eo={web:{light:"#f0f0f0",dark:"#222222"}},ru=/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/;function to(t,s){const a=t.match(ru);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}tu();let At={};function va({loading:t,children:s,name:a,initialBones:r,color:o,darkColor:n,animate:i,stagger:l=!1,transition:c=!1,boneClass:d,className:f,fallback:v,fixture:x,snapshotConfig:g}){const T=h.useRef(null),C=h.useRef(Math.random().toString(36).slice(2,8)).current,[S,p]=h.useState(0),[y,k]=h.useState(0),[L,N]=h.useState(!1);h.useEffect(()=>{if(typeof window>"u")return;const b=()=>{const U=document.documentElement.classList.contains("dark")||!!T.current?.closest(".dark");N(U)};b();const I=new MutationObserver(b);I.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const E=window.matchMedia("(prefers-color-scheme: dark)");return E.addEventListener("change",b),()=>{I.disconnect(),E.removeEventListener("change",b)}},[]);const B=o??At.color??eo.web.light,m=n??At.darkColor??eo.web.dark,j=L?m:B,w=i??At.animate??"pulse",R=w===!0?"pulse":w===!1?"solid":w;h.useEffect(()=>{const b=T.current;if(!b)return;const I=new ResizeObserver(U=>{const Y=U[0]?.contentRect;p(Math.round(Y?.width??0)),Y&&Y.height>0&&k(Math.round(Y.height))});I.observe(b);const E=b.getBoundingClientRect();return p(Math.round(E.width)),E.height>0&&k(Math.round(E.height)),()=>I.disconnect()},[]);const z={};if(a&&(z["data-boneyard"]=a,g&&(z["data-boneyard-config"]=JSON.stringify(g))),su())return e.jsx("div",{ref:T,className:f,style:{position:"relative"},...z,children:e.jsx("div",{children:x??s})});const[V,Q]=h.useState(!1);h.useLayoutEffect(()=>{Q(!0)},[]);const F=r??(a?eu(a):void 0),W=V&&typeof window<"u"?window.innerWidth:0,ee=S>0?S:W,ie=F&&ee>0?au(F,ee):null,je=d??At.boneClass,ve=(()=>{const b=l??At.stagger;return b===!0?80:b===!1||!b?0:b})(),ke=(()=>{const b=c??At.transition;return b===!0?300:b===!1||!b?0:b})(),[le,P]=h.useState(!1),K=h.useRef(t),ae=h.useRef(null);h.useEffect(()=>(K.current&&!t&&ke>0&&ie&&(ae.current&&clearTimeout(ae.current),P(!0),ae.current=setTimeout(()=>{P(!1),ae.current=null},ke)),K.current=t,()=>{ae.current&&clearTimeout(ae.current)}),[t,ke,ie]);const Le=(t||le)&&ie,Ae=t&&!ie&&!le,Pe=y>0?y:ie?.height??0,O=ie?.height??0,X=Pe>0&&O>0?Pe/O:1;return e.jsxs("div",{ref:T,className:f,style:{position:"relative"},...z,children:[e.jsx("div",{"data-boneyard-content":"true",style:Le&&!le?{visibility:"hidden"}:void 0,children:Ae?v:s}),Le&&e.jsx("div",{"data-boneyard-overlay":"true",style:{position:"absolute",inset:0,overflow:"hidden",opacity:le?0:1,transition:ke>0?`opacity ${ke}ms ease-out`:void 0},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ie.bones.filter(b=>!Xn(b).c).map((b,I)=>{const E=Xn(b),U=j;to(j,L?Os.darkAdjust:Os.lightAdjust);const Y=E.w/100*(ie.width??0),re=E.r==="50%"&&Math.abs(Y-E.h)<4,te={position:"absolute",left:`${E.x}%`,top:E.y*X,width:re?E.h*X:`${E.w}%`,height:E.h*X,borderRadius:typeof E.r=="string"?E.r:`${E.r}px`,backgroundColor:U},A=At.speed;if(R==="pulse")te.animation=`bp-${C} ${A??Os.speed} ease-in-out infinite`;else if(R==="shimmer"){const oe=L?At.darkShimmerColor??ys.darkHighlight:At.shimmerColor??ys.lightHighlight,me=At.shimmerAngle??ys.angle;delete te.backgroundColor,te.backgroundImage=`linear-gradient(${me}deg, ${U} ${ys.start}%, ${oe} 50%, ${U} ${ys.end}%)`,te.backgroundSize="200% 100%",te.animation=`bs-${C} ${A??ys.speed} linear infinite`}return ve>0&&(te.opacity=0,te.animation=`${te.animation?te.animation+",":""} by-${C} 0.3s ease-out ${I*ve}ms forwards`),e.jsx("div",{"data-boneyard-bone":"true",className:je,style:te},I)}),R==="pulse"&&e.jsx("style",{children:`@keyframes bp-${C}{0%,100%{background-color:${j}}50%{background-color:${to(j,L?Os.darkAdjust:Os.lightAdjust)}}}`}),R==="shimmer"&&e.jsx("style",{children:`@keyframes bs-${C}{0%{background-position:200% 0}100%{background-position:-200% 0}}`}),ve>0&&e.jsx("style",{children:`@keyframes by-${C}{from{opacity:0}to{opacity:1}}`})]})})]})}async function zr(t){const s=Xt(et,"managedStudents");try{const n=Pt(s,Ht("teacherId","==",t)),i=await ss(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 Ci(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 nu(t,s,a){const r=vt(et,"managedStudents",t);await Kt(r,{riskLevel:s,...a!==void 0?{riskConfidence:a}:{},updatedAt:ft()})}async function ki(t,s,a){const r=zt(s,a),o=vt(et,"managedStudents",t);await Kt(o,{grade:s,section:a,classSectionId:r,updatedAt:ft()})}function zt(t,s){return[t,s].filter(Boolean).join("_").replace(/\s+/g,"_").toLowerCase()}function xr(t){const s=Object.entries(t).filter(([,a])=>a!==void 0);return Object.fromEntries(s)}function Ns(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 Ls(t){const a=Ns(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 As(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 Ot(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 mt(t){const s=t.metadata||{},a=t.className||s.className,r=Ot(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?zt(o,n):"")||null,l=(a||"").trim()||(o&&n?`${o} - ${n}`:"")||null,c=Ns(t.gradeLevel||s.gradeLevel||o),d=(t.classification||s.classification||"").trim()||Ls(c)||null,f=(t.strand||s.strand||"").trim()||As(l,n)||null;return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:f,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 ou(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?zt(o,n):"")||null,l=s||(o&&n?`${o} - ${n}`:null),c=Ns(t.gradeLevel||o),d=(t.classification||"").trim()||Ls(c),f=(t.strand||"").trim()||As(l,n);return{classSectionId:i,className:l,grade:o,section:n,gradeLevel:c,classification:d,strand:f,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 Ci(t){const s=Xt(et,"classrooms"),a=new Map,r=Pt(s,Ht("teacherId","==",t));(await ss(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=Pt(s,Ht("managerId","==",t));return(await ss(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 Ti(t){const s=t.classSectionId||zt(t.grade,t.section),a=vt(et,"classSectionOwnership",s),r=await Cs(a),o=r.exists()?r.data().studentUids||[]:[],n=Array.from(new Set([...t.studentUids||[],...o])),i=xr(t);return r.exists()?await Kt(a,{...i,classSectionId:s,studentUids:n,updatedAt:ft()}):await es(a,{...i,classSectionId:s,studentUids:n,createdAt:ft(),updatedAt:ft()}),s}async function iu(t){const s=(t.classSectionId||"").trim()||zt(t.grade,t.section),a=(t.className||"").trim()||`${t.grade} - ${t.section}`,r=ou({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 Ti({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=Xt(et,"classrooms"),n=Pt(o,Ht("classSectionId","==",s)),i=await ss(n);if(i.empty){const l=xr({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:ft(),updatedAt:ft()});await es(vt(et,"classrooms",s),l,{merge:!0})}else for(const l of i.docs){const c=xr({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:ft()});await Kt(l.ref,c)}return s}async function Ii(t,s,a,r,o,n){const i=zt(s,a);await Ti({classSectionId:i,grade:s,section:a,schoolYear:o,ownerTeacherId:r,ownerTeacherName:n,studentUids:[t]}),await es(vt(et,"users",t),{grade:s,section:a,classSectionId:i,adviserTeacherId:r,adviserTeacherName:n||"",updatedAt:ft()},{merge:!0})}async function lu(t){const s=Xt(et,"classSectionOwnership"),a=new Map,r=Pt(s,Ht("ownerTeacherId","==",t));(await ss(r)).docs.forEach(l=>{a.set(l.id,{id:l.id,...l.data()})});const n=Pt(s,Ht("managerId","==",t));return(await ss(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 cu(t="",s=25){const a=Xt(et,"users"),r=Math.max(1,Math.min(100,s)),o=Pt(a,Ht("role","==","teacher"),Lo(r*4)),n=await ss(o),i=t.trim().toLowerCase();return n.docs.map(c=>{const d=c.data(),f=String(d.name||"").trim(),v=String(d.email||"").trim();return{uid:c.id,name:f||"Teacher",email:v,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 du(t,s,a=20){if(t.length===0)return s([]),()=>{};const r=Xt(et,"activities"),o=Pt(r,Ht("classroomId","in",t),yl("timestamp","desc"));return Ao(o,n=>{const i=n.docs.slice(0,a).map(l=>({id:l.id,...l.data()}));s(i)})}async function uu(t,s,a){const r=vt(Xt(et,"generatedLessonPlans"));return await es(r,{...t,teacherId:s,teacherName:a?.teacherName||null,studentId:a?.studentId||null,studentName:a?.studentName||null,status:"draft",createdAt:ft(),updatedAt:ft()}),r.id}async function mu(t){const s=vt(et,"generatedLessonPlans",t),a=await Cs(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 Kt(s,{status:"published",publishedAt:ft(),updatedAt:ft()})}async function xu(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,f=!1;if(s)try{const g=await pl(a,r,o,{lessonTitle:t.lessonTitle,learningCompetency:t.learningCompetency,moduleUnit:t.moduleUnit,learnerLevel:t.learnerLevel});i=g.sources||[],n=g.explanation||"",l=g.retrievalConfidence,c=g.retrievalBand,d=g.retrievalQuery,f=g.needsReview??!1}catch{n="",i=[]}const v={...t,subject:r,quarter:o,curriculumContext:n?`[CURRICULUM CONTEXT] +${n}`:void 0,curriculumRetrievalConfidence:l,curriculumRetrievalBand:c,curriculumRetrievalQuery:d,needsReview:f};return{...await Je.generateLessonPlan(v),curriculumSources:i,curriculumContext:n}}const pu=nl("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 hu({className:t,variant:s,asChild:a=!1,...r}){const o=a?Rl:"span";return e.jsx(o,{"data-slot":"badge",className:_o(pu({variant:s}),t),...r})}function fu(t){return t.length<=42?t:`${t.slice(0,18)}...${t.slice(-20)}`}const so=({sources:t=[],className:s})=>t.length?e.jsxs(_l,{children:[e.jsx(Ml,{asChild:!0,children:e.jsxs(hu,{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(Bt,{size:12}),"DepEd Aligned"]})}),e.jsxs(zl,{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:[fu(a.sourceFile)," | p.",a.page]}),e.jsxs("p",{className:"text-[#5a6578]",children:["Similarity: ",(a.score*100).toFixed(1),"%"]})]},`${a.sourceFile}-${a.page}-${r}`))})]})]}):null,gu=[{level:"Remember",icon:ar,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:Bt,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:hl,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:tc,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"}],bu=({isOpen:t,onClose:s})=>t?e.jsx(qt,{children:t&&e.jsx(Ge.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(Ge.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(Mo,{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(fs,{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:gu.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(oc,{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,vu={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"},xa={identification:{label:"Identification",icon:e.jsx(Zt,{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(Vt,{size:16}),description:"Choose from 4 options"},word_problem:{label:"Word Problem",icon:e.jsx(Bt,{size:16}),description:"Real-world scenarios"},equation_based:{label:"Equation-Based",icon:e.jsx(fl,{size:16}),description:"Solve equations"}},ao={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"}},wu=["Grade 11","Grade 12"],Ka=t=>{const s=(t||"").trim().toLowerCase();return s==="grade 12"||s==="12"||s.includes("12")?"Grade 12":"Grade 11"},Nu={"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"]}},ju={"Grade 11":["General Mathematics - "],"Grade 12":["Pre-Calculus - ","Basic Calculus - "]},ro=(t,s)=>{const a=ju[s];return Object.fromEntries(Object.entries(t).filter(([r])=>a.some(o=>r.startsWith(o))))},Bs=30,Ps=12,Xa="mathpulse:quiz-maker:active-task",yu={easy:"text-green-600",medium:"text-rose-600",hard:"text-red-600"},Ei=({onBack:t,gradeLevel:s,selectedClassId:a,selectedClassName:r,onOpenNotifications:o,onOpenProfile:n,onOpenInsightModal:i,userPhoto:l,teacherName:c,drawerMode:d=!1,onQuizSaved:f,onQuizGenerating:v})=>{const{currentUser:x,loading:g}=os(),T=h.useMemo(()=>Je.getImportGroundedRolloutFlags(),[]),[C,S]=h.useState("create"),[p,y]=h.useState("setup"),[k,L]=h.useState(Ka(s)),[N,B]=h.useState(10),[m,j]=h.useState([]),[w,R]=h.useState([]),[z,V]=h.useState(["multiple_choice","word_problem","identification"]),[Q,F]=h.useState(["remember","understand","apply","analyze"]),[W,ee]=h.useState(!1),[ie,je]=h.useState({easy:30,medium:50,hard:20}),[ve,ke]=h.useState({}),[le,P]=h.useState(!1),[K,ae]=h.useState([]),[Le,Ae]=h.useState(!1),[Pe,O]=h.useState(""),[X,b]=h.useState(!1),[I,E]=h.useState(!1),[U,Y]=h.useState(null),[re,te]=h.useState(0),[A,oe]=h.useState("queued"),[me,Ne]=h.useState("Waiting to start generation..."),[J,_e]=h.useState(null),[Ve,Te]=h.useState(null),[Ke,Me]=h.useState(""),[wt,It]=h.useState(!1),$=h.useRef(!1),[Z,_]=h.useState("topics"),[se,we]=h.useState(null),[ue,st]=h.useState(!1),[He,he]=h.useState("all"),[gt,Qt]=h.useState("all"),[Ds,$s]=h.useState(!1),[q,xe]=h.useState(null),[at,Re]=h.useState(!1),[dt,ut]=h.useState(!1),[Aa,$r]=h.useState(!1),[Fr,Bi]=h.useState([]),[Pi,Or]=h.useState(!1),[Da,Br]=h.useState(""),[us,Pr]=h.useState(null),[Hr,Fs]=h.useState([]),[Hi,Gr]=h.useState(!1),[$a,Gi]=h.useState("all"),[Qi,Qr]=h.useState(null),[Ur,ca]=h.useState(null),Vr=h.useCallback(async()=>{P(!0);const u=Ka(k);try{const M=await Je.getQuizTopics(u);M.topics&&ke(ro(M.topics,u))}catch{ke(ro(Nu[u],u))}finally{P(!1)}},[k]),Wr=h.useCallback(async()=>{if(!T.quizEnabled){ae([]),O("Import-grounded quiz generation is disabled by rollout flag; using curriculum defaults."),Ae(!1);return}Ae(!0),O("");try{const u=await Je.getCourseMaterialTopics({classSectionId:a,limit:20}),M=(u.topics||[]).filter(D=>D.title?.trim());ae(M),u.warnings&&u.warnings.length>0&&O(u.warnings.join(" "))}catch{ae([]),O("Imported topics are currently unavailable; quiz generation will use curriculum defaults.")}finally{Ae(!1)}},[a,T.quizEnabled]);h.useEffect(()=>{Vr(),j([]),R([])},[Vr]),h.useEffect(()=>{Wr()},[Wr]);const Fa=h.useMemo(()=>{const u=Array.from(new Set(K.map(M=>M.title.trim()).filter(Boolean)));return u.length===0?ve:{"Imported Course Materials":u,...ve}},[ve,K]);h.useEffect(()=>{he("all"),Qt("all")},[J]);const qr=h.useMemo(()=>{if(!J)return[];const u=J.questions.map(D=>D.provenance?.sourceFile?.trim()).filter(D=>!!D),M=(J.metadata.topicProvenance||[]).map(D=>D.sourceFile?.trim()).filter(D=>!!D);return Array.from(new Set([...u,...M])).sort((D,fe)=>D.localeCompare(fe))},[J]),Yr=h.useMemo(()=>{if(!J)return[];const u=J.questions.map(D=>D.provenance?.materialId?.trim()).filter(D=>!!D),M=(J.metadata.topicProvenance||[]).map(D=>D.materialId?.trim()).filter(D=>!!D);return Array.from(new Set([...u,...M])).sort((D,fe)=>D.localeCompare(fe))},[J]),Oa=h.useMemo(()=>J?J.questions.filter(u=>{const M=He==="all"||(u.provenance?.sourceFile||"").trim()===He,D=gt==="all"||(u.provenance?.materialId||"").trim()===gt;return M&&D}):[],[J,He,gt]),Kr=(u,M)=>{const D={...ie},fe=Math.max(0,Math.min(100,D[u]+M)),$e=fe-D[u];D[u]=fe;const Qe=Object.keys(D).filter(Ze=>Ze!==u),yt=Qe.reduce((Ze,Et)=>Ze+D[Et],0);if(yt>0)for(const Ze of Qe)D[Ze]=Math.max(0,Math.round(D[Ze]-$e*D[Ze]/yt));const js=Object.values(D).reduce((Ze,Et)=>Ze+Et,0);if(js!==100){const Ze=Qe.reduce((Et,nn)=>D[Et]>=D[nn]?Et:nn);D[Ze]+=100-js}je(D)},Ui=u=>{j(M=>M.includes(u)?M.filter(D=>D!==u):[...M,u]),R(M=>M.filter(D=>D!==u))},Vi=u=>{V(M=>M.includes(u)?M.length>1?M.filter(D=>D!==u):M:[...M,u])},Wi=u=>{F(M=>M.includes(u)?M.length>1?M.filter(D=>D!==u):M:[...M,u])},qi=()=>{let u=m.length>0?m.filter(D=>!w.includes(D)):Object.values(Fa).flat().filter(D=>!w.includes(D)).slice(0,3);u.length>Ps&&(u=u.slice(0,Ps));const M=Math.min(N,Bs);return{topics:u,gradeLevel:k,numQuestions:M,questionTypes:z,includeGraphs:W,difficultyDistribution:ie,bloomLevels:Q,excludeTopics:w,classSectionId:a,className:r,preferImportedTopics:T.quizEnabled}},Yi=h.useCallback((u,M)=>{const D={taskId:u,request:M,createdAt:new Date().toISOString(),ownerUid:x?.uid};try{sessionStorage.setItem(Xa,JSON.stringify(D))}catch{}},[x]),Ut=h.useCallback(()=>{try{sessionStorage.removeItem(Xa)}catch{}},[]),Ba=h.useCallback(u=>{const M=Math.max(0,Math.min(100,Math.round(typeof u.progressPercent=="number"?u.progressPercent:u.status==="queued"?10:u.status==="running"?65:u.status==="completed"?100:u.status==="cancelling"?95:100)));te(D=>{let fe=Math.max(D,M);if(u.status==="running"&&M<=D){const $e=String(u.progressStage||"").toLowerCase(),Qe=$e.includes("assembling")||$e.includes("final")?97:$e.includes("generating")?89:95;fe=Math.min(Qe,D+1)}return fe}),oe(u.progressStage||u.status),Ne(u.progressMessage||(u.status==="queued"?"Task queued for generation.":u.status==="running"?"Generating quiz in the background...":u.status==="completed"?"Generation complete.":u.status==="cancelling"?"Cancelling generation...":"Generation finished with an error."))},[]);h.useEffect(()=>{if(g||$.current)return;if($.current=!0,!x){Ut();return}let u=!1;const M=sessionStorage.getItem(Xa);if(!M)return;let D=null;try{D=JSON.parse(M)}catch{Ut();return}if(!D?.taskId){Ut();return}if(D.ownerUid&&D.ownerUid!==x.uid){Ut();return}return b(!0),Y(D.taskId),Me(""),Je.waitForTaskResult(D.taskId,{timeoutMs:24e4,pollIntervalMs:1500,onProgress:Ba}).then(async fe=>{if(u)return;const $e=fe.result;if(!$e||typeof $e!="object")throw new Error("Quiz generation completed without a valid result payload.");const Qe=$e;_e(Qe),y("results"),te(100),oe("completed"),Ne("Generation complete."),Y(null),Ut();try{await en(Qe,D.request),pe.success("Quiz auto-saved to your library as draft.")}catch(yt){pe.error(yt instanceof Error?yt.message:"Quiz generated but failed to save to library")}}).catch(fe=>{if(!u){if(fe instanceof ja&&(fe.status===401||fe.status===403)){$.current=!1,b(!1);return}Me(fe instanceof Error?fe.message:"Failed to resume quiz generation"),Y(null),Ut()}}).finally(()=>{u||b(!1)}),()=>{u=!0}},[Ba,g,Ut,x]);const Xr=()=>{if(X){window.confirm("Quiz generation is in progress. Are you sure you want to leave?")&&(y("setup"),_e(null),Me(""),t());return}y("setup"),_e(null),Me(""),t()},Ki=async()=>{v?.(),Me(""),b(!0),ca(null),te(8),oe("queued"),Ne("Submitting quiz generation task..."),_e(null);const u=qi();try{const M=await Je.generateQuiz(u,{onTaskCreated:D=>{Y(D),Yi(D,u),te(fe=>Math.max(fe,12)),oe("queued"),Ne("Task queued. Generation is running in the background.")},onProgress:D=>{Ba(D),D.taskId&&D.taskId!==U&&Y(D.taskId)}});_e(M),y("results"),te(100),oe("completed"),Ne("Generation complete."),Y(null),Ut();try{await en(M,u),pe.success("Quiz auto-saved to your library as draft.")}catch(D){pe.error(D instanceof Error?D.message:"Quiz generated but failed to save to library")}Je.reportImportGroundedFeedback({flow:"quiz",status:"success",classSectionId:u.classSectionId,className:u.className,metadata:{totalQuestions:M.metadata.totalQuestions,usedImportedTopics:!!M.metadata.usedImportedTopics,importedTopicCount:M.metadata.importedTopicCount??0,importGroundingEnabled:T.quizEnabled}})}catch(M){Me(M instanceof Error?M.message:"Quiz generation failed"),te(100),oe("failed"),Ne("Generation failed."),Y(null),Ut(),Je.reportImportGroundedFeedback({flow:"quiz",status:"failed",classSectionId:u.classSectionId,className:u.className,metadata:{error:M instanceof Error?M.message:"Quiz generation failed",importGroundingEnabled:T.quizEnabled}})}finally{b(!1)}},Xi=()=>{if(!J)return;const u=J.questions.map((M,D)=>{let fe=`${D+1}. [${M.difficulty.toUpperCase()}] [${M.bloomLevel}] (${M.points} pts) +`;return fe+=` ${M.question} +`,M.options&&(fe+=M.options.map($e=>` ${$e}`).join(` +`)+` +`),fe+=` Answer: ${M.correctAnswer} +`,fe+=` Explanation: ${M.explanation} +`,fe}).join(` +`);navigator.clipboard.writeText(u),It(!0),setTimeout(()=>It(!1),2e3)},Ji=()=>{if(!J)return;const u=new Blob([JSON.stringify(J,null,2)],{type:"application/json"}),M=URL.createObjectURL(u),D=document.createElement("a");D.href=M,D.download=`quiz_${k.replace(/\s/g,"_")}_${Date.now()}.json`,D.click(),URL.revokeObjectURL(M)};m.length>0||Object.values(Fa).flat().length>0;const Jr=(u,M)=>{const D=M?.gradeLevel||k,fe=M?.topics||m,$e=u.questions.map((Qe,yt)=>({id:`q_${Date.now()}_${yt}`,questionType:Qe.questionType||"identification",question:Qe.question,...Qe.options?{options:Qe.options}:{},correctAnswer:Qe.correctAnswer,bloomLevel:Qe.bloomLevel||"understand",difficulty:Qe.difficulty||"medium",topic:Qe.topic,subject:D,points:Qe.points,explanation:Qe.explanation}));return{title:`${D} Quiz – ${fe.length>0?fe.slice(0,2).join(", "):"Mixed Topics"}`,gradeLevel:D,questions:$e,totalPoints:u.totalPoints,metadata:{topicsCovered:Object.keys(u.metadata.topicsCovered),difficultyBreakdown:{easy:u.metadata.difficultyBreakdown.easy??0,medium:u.metadata.difficultyBreakdown.medium??0,hard:u.metadata.difficultyBreakdown.hard??0},bloomDistribution:u.metadata.bloomTaxonomyDistribution,questionTypeBreakdown:u.metadata.questionTypeBreakdown,supplementalPurpose:u.metadata.supplementalPurpose,recommendedTeacherActions:u.metadata.recommendedTeacherActions??[],generatedAt:new Date().toISOString(),generatedBy:"teacher_generated"},status:"draft",source:"teacher_generated"}},Zr=h.useCallback(u=>{Fs(M=>[u,...M.filter(D=>D.id!==u.id)])},[]);async function en(u,M){if(!x)return null;const D=Jr(u,M),fe=await mn(D,x.uid,q?{documentId:q}:void 0);return xe(fe),Zr({id:fe,...D,teacherId:x.uid}),fe}const Zi=async()=>{if(!J){pe.error("No quiz to save. Generate a quiz first.");return}if(!x){pe.error("You must be signed in to save quizzes.");return}$s(!0);try{const u=Jr(J),M=await mn(u,x.uid,q?{documentId:q}:void 0);xe(M),Zr({id:M,...u,teacherId:x.uid}),pe.success("Quiz saved to your library!"),f?.(M)}catch(u){pe.error(u instanceof Error?u.message:"Failed to save quiz")}finally{$s(!1)}},el=async()=>{if(q){Re(!0);try{await Cl(q),Fs(u=>u.map(M=>M.id===q?{...M,status:"published"}:M)),pe.success("Quiz published to Quiz Bank!")}catch(u){pe.error(u instanceof Error?u.message:"Failed to publish quiz")}finally{Re(!1)}}},Pa=async u=>{const M=u??q;if(!M){pe.error("Save the quiz first before assigning.");return}if(Qr(M),ut(!0),Pr(null),Br(""),Fr.length===0&&x){Or(!0);try{const D=await zr(x.uid);Bi(D)}catch{pe.error("Failed to load students")}finally{Or(!1)}}},tl=async()=>{const u=Qi??q;if(!(!us||!u||!x)){$r(!0);try{await Tl(u,us,x.uid),Fs(M=>M.map(D=>D.id===u?{...D,status:"assigned",metadata:{...D.metadata,assignedTo:us}}:D)),pe.success("Quiz assigned to student!"),ut(!1),Qr(null),C==="bank"&&Ha()}catch(M){pe.error(M instanceof Error?M.message:"Failed to assign quiz")}finally{$r(!1)}}},Ha=h.useCallback(async()=>{if(x){Gr(!0);try{const u=await Do(x.uid);Fs(u)}catch{pe.error("Failed to load quiz bank")}finally{Gr(!1)}}},[x]);h.useEffect(()=>{C==="bank"&&Ha()},[C,Ha]);const sl=async u=>{try{await kl(u),Fs(M=>M.filter(D=>D.id!==u)),pe.success("Quiz deleted")}catch{pe.error("Failed to delete quiz")}},tn=Fr.filter(u=>u.name.toLowerCase().includes(Da.toLowerCase())||u.email.toLowerCase().includes(Da.toLowerCase())),sn=$a==="all"?Hr:Hr.filter(u=>u.status===$a),al=u=>{const M=(u.metadata.topicsCovered||[]).reduce((D,fe)=>(D[fe]=(D[fe]||0)+1,D),{});return{questions:u.questions.map(D=>({questionType:D.questionType,question:D.question,correctAnswer:D.correctAnswer,options:D.options??null,bloomLevel:D.bloomLevel,difficulty:D.difficulty,topic:D.topic,points:D.points,explanation:D.explanation})),totalPoints:u.totalPoints,metadata:{topicsCovered:M,difficultyBreakdown:u.metadata.difficultyBreakdown,bloomTaxonomyDistribution:u.metadata.bloomDistribution,questionTypeBreakdown:u.metadata.questionTypeBreakdown,gradeLevel:u.gradeLevel,totalQuestions:u.questions.length,includesGraphQuestions:!1,supplementalPurpose:u.metadata.supplementalPurpose,bloomTaxonomyRationale:"Loaded from saved quiz bank entry.",recommendedTeacherActions:u.metadata.recommendedTeacherActions||[]}}},Ga=u=>{xe(u.id),_e(al(u)),Te(null),ca(u.id),he("all"),Qt("all"),we(null),y("results"),S("create")},an={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"}},rl=(u,M,D)=>{const fe=se===M,$e=an[u.bloomLevel?.toLowerCase()]||an.remember,Qe=u.bloomLevel?.toLowerCase()==="remember"?"hover:border-purple-200":u.bloomLevel?.toLowerCase()==="understand"?"hover:border-blue-200":u.bloomLevel?.toLowerCase()==="apply"?"hover:border-amber-200":"hover:border-slate-200";return e.jsxs(Ge.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:M*.05},className:`border border-[#e2e8f0] rounded-[20px] overflow-hidden bg-white shadow-sm hover:shadow-md ${Qe} 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:()=>we(fe?null:M),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 ${$e.card} text-white flex items-center justify-center font-bold text-[13px] shadow-sm`,children:["Q",M+1]}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${$e.badge}`,children:u.bloomLevel}),e.jsx("span",{className:`px-2.5 py-1 rounded-md border text-[10px] font-bold uppercase tracking-wider shadow-sm ${u.difficulty==="easy"?"border-emerald-200 text-emerald-700 bg-emerald-50":u.difficulty==="hard"?"border-rose-200 text-rose-700 bg-rose-50":"border-amber-200 text-amber-700 bg-amber-50"}`,children:u.difficulty}),e.jsxs("span",{className:"text-[12px] font-bold text-[#64748b] bg-slate-100 px-2 py-1 rounded-md",children:[u.points," pts"]}),u.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:u.topic})]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b] pr-4 leading-relaxed",children:u.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 ${$e.badge}`,children:u.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:fe?e.jsx(Sa,{size:16,className:"text-[#64748b] transition-transform duration-300"}):e.jsx(_t,{size:16,className:"text-[#64748b]"})})]})]}),e.jsx(qt,{children:fe&&e.jsx(Ge.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"}),u.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:u.options.map((yt,js)=>{const Ze=yt.includes(u.correctAnswer);return e.jsxs("div",{className:`rounded-[12px] p-4 text-[14px] font-medium transition-all cursor-pointer relative overflow-hidden ${Ze?"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:[Ze&&e.jsx("div",{className:"absolute left-0 top-0 w-1 h-full bg-emerald-500"}),e.jsx("span",{className:Ze?"pl-2":"",children:yt}),Ze&&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(Vt,{size:13})})]},js)})})]}),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(br,{size:14})," Correct Answer"]}),e.jsx("p",{className:"text-[16px] font-bold text-[#1e293b]",children:u.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(rs,{size:14})," AI Explanation"]}),e.jsx("p",{className:"text-[13px] text-[#475569] leading-relaxed font-medium",children:u.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(Zt,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Type:"})," ",xa[u.questionType]?.label||u.questionType]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ar,{size:14})," ",e.jsx("strong",{className:"text-[#1e293b]",children:"Bloom:"})," ",u.bloomLevel]})]})]})})})]},M)},rn=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 ${C==="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(or,{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 ${C==="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(Ta,{size:16})," Quiz Bank"]})]})}),e.jsxs("div",{className:"w-full px-[24px] xl:px-[32px] pb-[32px] flex-1",children:[C==="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(u=>e.jsx("button",{onClick:()=>Gi(u),className:`px-5 py-2 text-[13px] font-bold rounded-full whitespace-nowrap transition-all duration-300 mb-4 capitalize ${$a===u?"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:u==="all"?"All":u.charAt(0).toUpperCase()+u.slice(1)},u))}),Hi?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(lt,{size:24,className:"animate-spin text-sky-500"}),e.jsx("span",{className:"ml-2 text-sm text-[#5a6578]",children:"Loading quiz bank…"})]}):sn.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(Ta,{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:sn.map(u=>e.jsxs(Ge.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},onClick:()=>Ga(u),role:"button",tabIndex:0,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),Ga(u))},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] ${u.status==="assigned"||u.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 ${u.status==="assigned"||u.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 ${u.status==="assigned"||u.status==="published"?"group-hover:text-[#9333ea]":"group-hover:text-slate-700"}`,children:u.title}),e.jsx("span",{className:`px-2.5 py-1 rounded-[6px] text-[10px] font-bold uppercase tracking-wider shrink-0 shadow-sm ${vu[u.status]}`,children:u.status})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-5 pl-3",children:u.metadata.topicsCovered.slice(0,3).map(M=>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:M},M))}),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(Ll,{size:14})," ",u.questions.length," questions"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(zo,{size:14})," ",u.totalPoints," pts"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ft,{size:14})," ",u.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:M=>{M.stopPropagation(),Ga(u)},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(Al,{size:14})," View"]}),e.jsxs("button",{onClick:M=>{M.stopPropagation(),Pa(u.id)},className:"flex items-center gap-1.5 text-[13px] font-bold text-[#a855f7] hover:text-[#9333ea] transition-colors",children:[e.jsx(da,{size:14})," Assign"]}),e.jsxs("button",{onClick:M=>{M.stopPropagation(),sl(u.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($o,{size:14})," Delete"]})]})]},u.id))})]}),C==="create"&&e.jsxs(e.Fragment,{children:[Ke&&e.jsx("div",{className:"w-full px-[24px] xl:px-[32px] pt-4",children:e.jsxs(Ge.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(Ys,{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:()=>Me(""),className:"ml-auto",children:e.jsx(fs,{size:14,className:"text-red-400"})})]})}),X&&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(lt,{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(Ge.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:A.replace(/_/g," ")})]}),e.jsx("p",{children:me}),U&&e.jsxs("p",{className:"text-[11px] mt-3 opacity-60 font-mono",children:["Task ID: ",U]})]})]}),e.jsxs("p",{className:"mt-8 text-[14px] font-medium text-[#64748b] flex items-center gap-2 animate-pulse",children:[e.jsx(lt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]})]}),!X&&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((u,M)=>{const fe=["setup","topics","style","preview"].indexOf(p),$e=fe>M,Qe=fe===M;return e.jsxs("div",{className:`flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl transition-all duration-500 ${Qe?"bg-purple-50/80 shadow-[0_1px_3px_rgba(168,85,247,0.1)]":$e?"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 ${Qe?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":$e?"bg-emerald-500 text-white shadow-sm":"bg-slate-100 text-[#64748b]"}`,children:$e?e.jsx(Vt,{size:13,strokeWidth:3}):M+1}),e.jsx("span",{className:`text-[13px] font-bold whitespace-nowrap ${Qe?"text-[#9333ea]":$e?"text-[#1e293b]":"text-[#64748b]"}`,children:u.label})]},u.id)})})}),p==="setup"&&!X&&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(Us,{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 ",Bs," questions and ",Ps," 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:k,onChange:u=>L(Ka(u.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:wu.map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx(_t,{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:()=>B(Math.max(1,N-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(xn,{size:16})}),e.jsx("input",{id:"quiz-num-questions",type:"number",min:1,max:Bs,value:N,onChange:u=>B(Math.min(Bs,Math.max(1,parseInt(u.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:()=>B(Math.min(Bs,N+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(rr,{size:16})})]})]})]})]})]}),p==="topics"&&!X&&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 ",Ps," 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:[m.filter(u=>!w.includes(u)).length," of ",Ps," selected"]})]})]}),le?e.jsxs("div",{className:"flex items-center justify-center py-10 text-sm text-[#5a6578]",children:[e.jsx(lt,{size:24,className:"animate-spin text-[#9b51e0] mr-2"})," Loading topics..."]}):e.jsx("div",{className:"space-y-3",children:Object.entries(Fa).map(([u,M])=>{const D=M.filter($e=>m.includes($e)&&!w.includes($e)).length,fe=Z===u;return e.jsxs("div",{className:"border border-[#dde3eb] rounded-xl bg-white overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>_(fe?null:u),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:u}),e.jsxs("p",{className:"text-xs text-slate-500",children:[M.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:[D," selected"]}),fe?e.jsx(Sa,{size:18,className:"text-slate-400"}):e.jsx(_t,{size:18,className:"text-slate-400"})]})]}),e.jsx(qt,{children:fe&&e.jsx(Ge.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:M.map(($e,Qe)=>{const yt=m.includes($e),js=w.includes($e),Ze=yt&&!js;let Et="Core";return Qe%3===0&&(Et="Foundation"),Qe%3===2&&(Et="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 ${Ze?"bg-[#9b51e0] border-[#9b51e0]":"border-2 border-[#dde3eb] bg-white"}`,children:Ze&&e.jsx(Vt,{size:14,className:"text-white"})}),e.jsx("input",{type:"checkbox",className:"hidden",checked:Ze,onChange:()=>Ui($e)}),e.jsx("span",{className:`text-sm font-semibold ${Ze?"text-[#0a1628]":"text-[#5a6578]"}`,children:$e})]}),e.jsx("span",{className:`border px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${Et==="Advanced"?"bg-white text-slate-400 border-[#dde3eb]":"bg-purple-50 text-[#9b51e0] border-purple-100"}`,children:Et})]},$e)})})})})]},u)})})]}),p==="style"&&!X&&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(xa).map(([u,M])=>{const D=z.includes(u);return e.jsxs("button",{onClick:()=>Vi(u),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 ${D?"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:[D&&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(Vt,{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 ${D?"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:D?"text-[#a855f7]":"text-slate-500",children:M.icon})}),e.jsx("span",{className:`font-bold text-[12px] leading-tight ${D?"text-[#9333ea]":"text-slate-700"}`,children:M.label})]},u)})})]}),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(ao).map(([u,M])=>{const D=Q.includes(u);return e.jsx("button",{onClick:()=>Wi(u),className:`px-6 py-2.5 rounded-full border-2 font-bold text-[13px] transition-all duration-200 hover:-translate-y-0.5 capitalize ${D?"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:u},u)})})]}),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(ie).map(([u,M])=>{const D={easy:"bg-emerald-400",medium:"bg-amber-400",hard:"bg-rose-400"},fe={easy:"text-emerald-600",medium:"text-amber-500",hard:"text-rose-500"},$e={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:${fe[u]} transition-colors`,children:u}),e.jsx("div",{className:"flex-1 bg-slate-100 h-3 rounded-full overflow-hidden shadow-inner",children:e.jsx(Ge.div,{animate:{width:`${M}%`},className:`h-full rounded-full transition-all duration-500 ease-out ${D[u]}`})}),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 ${$e[u]}`,children:[e.jsx("button",{onClick:()=>Kr(u,-5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${fe[u]} rounded-lg transition-colors`,children:e.jsx(xn,{className:"w-3.5 h-3.5"})}),e.jsx("input",{type:"text",value:`${M}%`,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:()=>Kr(u,5),className:`w-8 h-full flex items-center justify-center text-[#64748b] hover:bg-slate-50 hover:${fe[u]} rounded-lg transition-colors`,children:e.jsx(rr,{className:"w-3.5 h-3.5"})})]})]},u)})})]})]}),p==="preview"&&!X&&!J&&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(gs,{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:N},{label:"Topics",value:m.filter(u=>!w.includes(u)).length},{label:"Level",value:k.replace("Grade ","Gr. ")}].map(u=>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:u.value}),e.jsx("span",{className:"text-[13px] font-bold text-[#64748b] relative z-10",children:u.label})]},u.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(Us,{size:18,className:"text-[#94a3b8] shrink-0 mt-0.5"}),e.jsxs("p",{children:[z.map(u=>xa[u]?.label).join(" and ")," questions across"," ",e.jsxs("span",{className:"font-bold text-[#1e293b]",children:[m.filter(u=>!w.includes(u)).length," topics"]})," ","— aligned to ",e.jsx("span",{className:"font-semibold",children:Q.map(u=>ao[u]?.label).join(", ")})," levels of Bloom's Taxonomy."," ",e.jsxs("span",{className:"font-semibold text-emerald-600",children:["Easy ",ie.easy,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-amber-500",children:["Medium ",ie.medium,"%"]})," • ",e.jsxs("span",{className:"font-semibold text-rose-500",children:["Hard ",ie.hard,"%"]}),"."]})]})]})}),p==="results"&&J&&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:Xi,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:[wt?e.jsx(Vt,{size:14,className:"text-green-500"}):e.jsx($l,{size:14}),wt?"Copied!":"Copy All"]}),e.jsxs("button",{onClick:Ji,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(Fl,{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(Zt,{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:J.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(Yt,{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:J.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(Bt,{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(J.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(J.metadata.bloomTaxonomyDistribution).length}),e.jsx("span",{className:"text-[12px] font-bold text-white/90 uppercase tracking-widest relative z-10",children:"Bloom Levels"})]})]}),(J.metadata.usedImportedTopics||(J.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: ",J.metadata.usedImportedTopics?"Yes":"No"," • ","Materials: ",J.metadata.importedMaterialsCount??0," • ","Topics: ",J.metadata.importedTopicCount??0]}),(J.metadata.topicProvenance||[]).slice(0,5).map((u,M)=>e.jsxs("div",{className:"text-xs text-[#5a6578]",children:[u.title||"Untitled topic",u.sourceFile?` • ${u.sourceFile}`:""]},`${u.topicId||u.title||"topic"}_${M}`)),(qr.length>0||Yr.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:He,onChange:u=>he(u.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"}),qr.map(u=>e.jsx("option",{value:u,children:u},u))]})]}),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:gt,onChange:u=>Qt(u.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"}),Yr.map(u=>e.jsx("option",{value:u,children:u},u))]})]})]}),e.jsxs("p",{className:"text-[11px] text-[#5a6578] mt-2",children:["Showing ",Oa.length," of ",J.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(gs,{size:14})," Difficulty"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(J.metadata.difficultyBreakdown).map(([u,M])=>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 ${yu[u]||"text-[#475569]"}`,children:u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:M})]},u))})]}),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(ar,{size:14})," Bloom's Taxonomy"]}),e.jsx("div",{className:"space-y-3 text-[14px] font-medium text-[#475569]",children:Object.entries(J.metadata.bloomTaxonomyDistribution).map(([u,M])=>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:u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:M})]},u))})]}),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(J.metadata.questionTypeBreakdown).map(([u,M])=>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:xa[u]?.label||u}),e.jsx("span",{className:"font-bold text-[#1e293b] bg-white px-2 py-0.5 rounded shadow-sm border border-slate-100",children:M})]},u))})]})]}),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(Us,{size:18,className:"text-[#9333ea]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold text-[#9333ea] mb-3",children:J.metadata.supplementalPurpose||"This quiz is designed to supplement classroom instruction, not replace teacher-led learning."}),J.metadata.recommendedTeacherActions&&J.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:J.metadata.recommendedTeacherActions.map((u,M)=>e.jsx("li",{children:u},M))})]})]})]})]}),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(Po,{size:20,className:"text-[#a855f7]"})," Review Questions"]}),e.jsx("div",{className:"space-y-4",children:Oa.length>0?Oa.map((u,M)=>rl(u,M)):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."})})]})]})]})]}),C==="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"&&!X&&e.jsx("button",{onClick:()=>{j([]),R([])},className:"text-[13px] font-semibold text-[#a855f7] hover:underline",children:"Clear all"}),(p==="style"||p==="preview")&&!X&&e.jsxs("button",{onClick:()=>y(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(as,{size:16})," Back"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[p==="setup"&&!X&&e.jsxs("button",{onClick:()=>y("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(ts,{size:16})]}),p==="topics"&&!X&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>y("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(as,{size:16})," Back"]}),e.jsxs("button",{onClick:()=>y("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(ts,{size:16})]})]}),p==="style"&&!X&&e.jsxs("button",{onClick:()=>y("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(ts,{size:16})]}),p==="preview"&&!X&&!J&&e.jsxs("button",{onClick:Ki,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(Vt,{size:16})," Generate Quiz"]}),X&&e.jsxs("div",{className:"flex items-center gap-3 text-slate-500 font-medium text-sm",children:[e.jsx(lt,{size:16,className:"animate-spin"})," Generating quiz... Please wait."]}),p==="results"&&(Ur?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{S("bank"),ca(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:()=>Pa(Ur),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(da,{size:16})," Assign"]}),e.jsx("button",{onClick:Xr,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:()=>{y("setup"),_e(null),Te(null),xe(null),ca(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"}),q?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:el,disabled:at,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:[at?e.jsx(lt,{size:16,className:"animate-spin"}):e.jsx(aa,{size:16})," Publish"]}),e.jsxs("button",{onClick:()=>Pa(),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(da,{size:16})," Assign to Class"]})]}):e.jsxs("button",{onClick:Zi,disabled:Ds,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:[Ds?e.jsx(lt,{size:16,className:"animate-spin"}):e.jsx(Fo,{size:16})," Save to Library"]}),e.jsx("button",{onClick:Xr,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(bu,{isOpen:ue,onClose:()=>st(!1)}),e.jsx(qt,{children:dt&&e.jsx(Ge.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:()=>ut(!1),children:e.jsxs(Ge.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:u=>u.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(Ft,{size:18,className:"text-sky-600"}),"Assign to Student"]}),e.jsx("button",{onClick:()=>ut(!1),className:"p-1 hover:bg-[#edf1f7] rounded-lg transition-colors",children:e.jsx(fs,{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(ra,{size:14,className:"text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search students…",value:Da,onChange:u=>Br(u.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:Pi?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(lt,{size:20,className:"animate-spin text-sky-500"})}):tn.length===0?e.jsx("p",{className:"text-center text-sm text-slate-500 py-10",children:"No students found"}):tn.map(u=>e.jsxs("button",{onClick:()=>Pr(u.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left transition-colors ${us===u.id?"bg-sky-50 border border-sky-300":"hover:bg-[#edf1f7] border border-transparent"}`,children:[e.jsx("img",{src:u.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(u.name)}&background=random&size=32`,alt:u.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:u.name}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:u.email})]}),us===u.id&&e.jsx(Vt,{size:16,className:"text-sky-600 flex-shrink-0"})]},u.id))}),e.jsxs("div",{className:"px-5 py-3 border-t border-[#dde3eb] flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>ut(!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:tl,disabled:!us||Aa,className:`flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold transition-all ${us&&!Aa?"bg-gradient-to-r from-sky-600 to-sky-500 text-white shadow-sm":"bg-[#dde3eb] text-slate-500 cursor-not-allowed"}`,children:[Aa?e.jsx(lt,{size:14,className:"animate-spin"}):e.jsx(da,{size:14}),"Assign"]})]})]})})})]});return d?e.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-white",children:rn}):rn},Su=({onOpenNotifications:t,onOpenProfile:s,onOpenInsightModal:a,userPhoto:r,teacherName:o})=>{const[n,i]=h.useState([]),[l,c]=h.useState(!1),[d,f]=h.useState(!1),[v,x]=h.useState(""),[g,T]=h.useState(11),[C,S]=h.useState("general_mathematics"),p=h.useCallback(async()=>{c(!0);try{const N=await ln("/api/quiz-battle/bank-status");i(N.pdfs)}catch(N){const B=N instanceof ja?N.message:"Failed to load bank status";pe.error(B)}finally{c(!1)}},[]);h.useEffect(()=>{p()},[p]);const y=async()=>{if(!v.trim()){pe.error("Please enter a storage path");return}f(!0);try{await ln("/api/quiz-battle/ingest-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storage_path:v.trim(),grade_level:g,topic:C.trim(),force_reingest:!1})}),pe.success("PDF ingestion completed"),await p(),x("")}catch(N){const B=N instanceof ja?N.message:"Ingestion failed";pe.error(B)}finally{f(!1)}},k=n.reduce((N,B)=>N+B.question_count,0),L=n.filter(N=>N.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(Zt,{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(Bt,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:k})]}),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(Vs,{size:16,className:"text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none",children:L})]})]}),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(hn,{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(Zt,{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:v,onChange:N=>x(N.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:g,onChange:N=>T(Number(N.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(Bt,{className:"h-4 w-4 text-[#94a3b8] group-hover:text-[#a855f7] transition-colors"})}),e.jsx("input",{type:"text",placeholder:"general_mathematics",value:C,onChange:N=>S(N.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:y,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(lt,{className:"w-4 h-4 animate-spin"}):e.jsx(hn,{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:p,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(Vs,{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(N=>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 ${N.processed?"bg-indigo-50 text-indigo-500":"bg-amber-50 text-amber-500"}`,children:e.jsx(Zt,{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:N.filename})]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-semibold text-[#475569]",children:N.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:N.topic})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-bold text-[#1e293b] text-center",children:N.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 ${N.processed?"bg-emerald-50 text-emerald-600 border-emerald-200/50":"bg-amber-50 text-amber-600 border-amber-200/50"}`,children:[N.processed?e.jsx(Vs,{className:"w-3 h-3"}):e.jsx(lt,{className:"w-3 h-3 animate-spin"}),N.processed?"Completed":"Processing..."]})}),e.jsx("td",{className:"py-4 px-6 text-[13px] font-medium text-[#64748b]",children:N.timestamp?new Date(N.timestamp).toLocaleDateString():"-"})]},N.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(Zt,{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."})]})})})]})]})})})]})]})]})},no={totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0},ku={"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"}},oo={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"}},io={needs_attention:0,on_track:1,no_data:2,mastered:3},Cu=({classSectionId:t,onOpenNotifications:s,onOpenProfile:a})=>{const{currentUser:r,userProfile:o}=os(),[n,i]=h.useState([]),[l,c]=h.useState(no),[d,f]=h.useState(!0),[v,x]=h.useState("all"),[g,T]=h.useState("all"),[C,S]=h.useState(""),[p,y]=h.useState("classAverage"),[k,L]=h.useState("asc"),N=fn.map(P=>P.id),B=fn.reduce((P,K)=>(P[K.id]=K.name,P),{}),{isLoading:m,refetch:j}=Hl();h.useEffect(()=>{m||(console.log("[TopicMasteryView] Curriculum ready"),j())},[m,j]);const[w,R]=h.useState(new Set),[z,V]=h.useState([]),Q=Il({queryKey:gl.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 P=vt(et,"teachers",r.uid,"settings","quizSettings"),K=await Cs(P),ae=K.exists()?K.data()?.excludedTopics||[]:[],Le="https://deign86-mathpulse-api-v3test.hf.space",Ae=new URLSearchParams({teacherId:r.uid});t&&Ae.set("classSectionId",t);const Pe=await r.getIdToken(),O=await fetch(`${Le}/api/analytics/topic-mastery?${Ae.toString()}`,{headers:{Authorization:`Bearer ${Pe}`}});if(!O.ok)return{excluded:ae,topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ae.length}};const X=await O.json(),b=(X.topics||[]).map(I=>({...I,isExcluded:ae.includes(I.topicName)}));return{excluded:ae,topics:b,summary:X.summary||{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:ae.length}}}catch{return{excluded:[],topics:[],summary:{totalTopicsTracked:0,masteredCount:0,needsAttentionCount:0,excludedCount:0}}}}});h.useEffect(()=>{if(f(Q.isLoading||Q.isFetching),!Q.data){V([]),i([]),c(no),R(new Set);return}V(Q.data.excluded),i(Q.data.topics),c(Q.data.summary)},[Q.data,Q.isFetching,Q.isLoading]);const F=async P=>{if(!r)return;const K=z.includes(P)?z.filter(ae=>ae!==P):[...z,P];V(K),i(ae=>ae.map(Le=>Le.topicName===P?{...Le,isExcluded:!Le.isExcluded}:Le)),c(ae=>({...ae,excludedCount:K.length}));try{const ae=vt(et,"teachers",r.uid,"settings","quizSettings");(await Cs(ae)).exists()?await Kt(ae,{excludedTopics:K}):await es(ae,{excludedTopics:K})}catch{pe.error("Failed to update excluded topics")}},W=async()=>{if(!r)return;const P=[...new Set([...z,...w])];V(P),i(K=>K.map(ae=>w.has(ae.topicName)?{...ae,isExcluded:!0}:ae)),c(K=>({...K,excludedCount:P.length})),R(new Set);try{const K=vt(et,"teachers",r.uid,"settings","quizSettings");(await Cs(K)).exists()?await Kt(K,{excludedTopics:P}):await es(K,{excludedTopics:P}),pe.success(`${w.size} topics excluded from quizzes`)}catch{pe.error("Failed to update")}},ee=async()=>{if(!r)return;const P=z.filter(K=>!w.has(K));V(P),i(K=>K.map(ae=>w.has(ae.topicName)?{...ae,isExcluded:!1}:ae)),c(K=>({...K,excludedCount:P.length})),R(new Set);try{const K=vt(et,"teachers",r.uid,"settings","quizSettings");(await Cs(K)).exists()?await Kt(K,{excludedTopics:P}):await es(K,{excludedTopics:P}),pe.success(`${w.size} topics re-included in quizzes`)}catch{pe.error("Failed to update")}},ie=P=>{p===P?L(K=>K==="asc"?"desc":"asc"):(y(P),L("asc"))},je=g==="all"?N:Bl(g);h.useEffect(()=>{v!=="all"&&(je.includes(v)||x("all"))},[je,v]);const ve=n.filter(P=>!(v!=="all"&&P.subjectId!==v||!je.includes(P.subjectId)||C&&!P.topicName.toLowerCase().includes(C.toLowerCase()))).sort((P,K)=>{const ae=k==="asc"?1:-1;switch(p){case"topicName":return ae*P.topicName.localeCompare(K.topicName);case"classAverage":return ae*(P.classAverage-K.classAverage);case"studentsAttempted":return ae*(P.studentsAttempted-K.studentsAttempted);case"masteryStatus":return ae*((io[P.masteryStatus]||0)-(io[K.masteryStatus]||0));default:return 0}}),ke=()=>{w.size===ve.length?R(new Set):R(new Set(ve.map(P=>P.topicName)))},le=({field:P})=>p!==P?e.jsx(_t,{size:14,className:"text-white/40"}):k==="asc"?e.jsx(Sa,{size:14,className:"text-white font-bold"}):e.jsx(_t,{size:14,className:"text-white font-bold"});return d?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(lt,{size:24,className:"animate-spin text-indigo-500"}),e.jsx("span",{className:"ml-2 text-[#64748b]",children:"Loading topic mastery data..."})]}):e.jsxs(Ge.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(gs,{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(vr,{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(Rs,{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(Dl,{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(ra,{size:16,className:"text-[#64748b] shrink-0 group-focus-within:text-[#4f46e5] transition-colors"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:C,onChange:P=>S(P.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:v,onChange:P=>x(P.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"}),je.map(P=>e.jsx("option",{value:P,children:B[P]||P},P))]}),e.jsx(_t,{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:g,onChange:P=>T(P.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"}),Pl.map(P=>e.jsx("option",{value:P,children:P},P))]}),e.jsx(_t,{size:16,className:"text-[#64748b] absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsx(qt,{children:w.size>0&&e.jsxs(Ge.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:W,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:ee,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:()=>R(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===ve.length&&ve.length>0,onChange:ke,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:()=>ie("topicName"),children:["TOPIC NAME ",e.jsx(le,{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:()=>ie("classAverage"),children:["CLASS AVG % ",e.jsx(le,{field:"classAverage"})]}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ie("studentsAttempted"),children:["STUDENTS ",e.jsx(le,{field:"studentsAttempted"})]}),e.jsxs("div",{className:"col-span-1 flex items-center gap-1 cursor-pointer hover:text-white/80 select-none",onClick:()=>ie("masteryStatus"),children:["STATUS ",e.jsx(le,{field:"masteryStatus"})]}),e.jsx("div",{className:"col-span-1 text-center",children:"EXCLUDE"})]}),e.jsx("div",{className:"flex flex-col",children:ve.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(gs,{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."})}):ve.map(P=>{const K=w.has(P.topicName),ae=oo[P.masteryStatus]||oo.no_data,Le=ku[P.subjectId]||{label:P.subjectId.toUpperCase(),color:"bg-[#f8fafc] text-[#64748b]"},Ae=P.classAverage<60?"bg-rose-500":P.classAverage<85?"bg-amber-500":"bg-emerald-500",Pe=P.isExcluded?"bg-slate-50/60 opacity-70":P.masteryStatus==="needs_attention"?"bg-rose-50/30":P.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 ${Pe} ${P.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 O=new Set(w);K?O.delete(P.topicName):O.add(P.topicName),R(O)},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:P.topicName}),e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded shrink-0 ${Le.color}`,children:Le.label})]}),e.jsx("div",{className:"col-span-2 text-[#475569] text-[13px] truncate pr-2",children:P.unit}),e.jsx("div",{className:"col-span-2",children:e.jsxs("span",{className:"font-bold text-[#1e293b] text-[14px]",children:[P.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:[P.studentsAttempted," / ",P.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 ${Ae}`,style:{width:`${P.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:P.isExcluded,onChange:()=>F(P.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:P.isExcluded?"Include in generation":"Exclude from generation"})]})]},P.topicName)})})]})})})]})]})};function Ri(t){return(t||"").trim().toLowerCase()}function lo(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=Ri(t.classSectionId),n=(t.id||"").trim().toLowerCase();return o&&n?`${o}|id:${n}`:n?`id:${n}`:`${o}|anonymous`}function Tu(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 Iu(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 _i(t,s){const a=new Map,r=new Map,o=s?Ri(s):"all";return t.forEach(n=>{const i=Tu(n,o),l=i.map(f=>r.get(f)).find(Boolean)||i[0],c=a.get(l),d=c?Iu(c,n):n;a.set(l,d),i.forEach(f=>r.set(f,l))}),Array.from(a.values())}function co(t,s){return _i([...t,...s])}function Ss(t){return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0}function Eu(t){if(!t)return null;const s="gen-math",a=gn.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=gn.find(S=>S.modules.some(p=>p.id===i.id)),c=l?t?.subjects?.[l.id]?.modulesProgress?.[i.id]:null,d=Ss(c?.progress||0),f=i.lessons.length?i.lessons.reduce((S,p)=>{const y=o?.[p.id]?.score;if(typeof y=="number"&&Number.isFinite(y))return S+Ss(y);const k=!!c?.lessonsCompleted?.includes?.(p.id);return S+(k?100:0)},0)/i.lessons.length:0,v=i.quizzes.length?(c?.quizzesCompleted?.length||0)/i.quizzes.length*100:0,x=Ss(f),g=Ss(v),T=Ss(Math.min(100,(x+g*2)/1.5)),C=Ss(Math.min(100,40+d*.6));r.mastery+=d,r.concept+=x,r.application+=g,r.engagement+=T,r.consistency+=C});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 uo={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"}},Ja=[{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"}],Ru=({classSectionId:t,className:s,fallbackStudents:a=[],onBack:r,onOpenNotifications:o,onOpenProfile:n,insightDismissed:i,onOpenInsightModal:l})=>{const{currentUser:c,userProfile:d}=os(),f=h.useRef(0),[v,x]=h.useState([]),[g,T]=h.useState(!0),[C,S]=h.useState(""),[p,y]=h.useState("riskLevel"),[k,L]=h.useState("desc"),[N,B]=h.useState("all"),[m,j]=h.useState([]),[w,R]=h.useState(!1),[z,V]=h.useState(""),[Q,F]=h.useState(""),W=h.useCallback(b=>({id:b.id,lrn:b.lrn||void 0,name:b.name,email:b.email||"",avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(b.name)}&background=random`,classSectionId:b.classSectionId??null,riskLevel:b.riskLevel||"Low",engagementScore:b.engagementScore,avgQuizScore:b.avgQuizScore,weakestTopic:b.weakestTopic||"Foundational Skills"}),[]),ee=h.useCallback(b=>({id:b.id,lrn:b.lrn,name:b.name,email:b.email||"",avatar:b.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(b.name)}&background=random`,classSectionId:b.classSectionId??null,riskLevel:String(b.riskLevel).charAt(0).toUpperCase()+String(b.riskLevel).slice(1).toLowerCase(),engagementScore:b.engagementScore,avgQuizScore:Number(b.avgQuizScore??b.avgScore??0),weakestTopic:b.weakestTopic||"Foundational Skills"}),[]),ie=h.useCallback(async(b,I)=>{const E=new Map;b.forEach(Y=>E.set(Y.id,null));const U=25;for(let Y=0;Y{try{const oe=await cn(A.id);return{studentId:A.id,summary:Eu(oe)}}catch{return{studentId:A.id,summary:null}}}))).forEach((A,oe)=>{const me=re[oe]?.id;me&&(A.status==="fulfilled"?E.set(me,A.value.summary):E.set(me,null))})}f.current===I&&x(Y=>Y.map(re=>E.has(re.student.id)?{...re,competencyMatrix:E.get(re.student.id)??null,competencyMatrixLoading:!1}:re))},[]),je=h.useCallback(async()=>{if(c?.uid){T(!0),F("");try{let I=(await zr(c.uid)).map(re=>({id:re.id,name:re.name,email:re.email||"",avatar:re.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(re.name)}&background=random`,classSectionId:re.classSectionId??null,riskLevel:re.riskLevel,engagementScore:re.engagementScore,avgQuizScore:re.avgQuizScore,weakestTopic:re.weakestTopic||"Foundational Skills"}));a.length>0&&(I=co(I,a.map(ee))),t&&(I=I.filter(re=>re.classSectionId===t));const E=await Je.getImportedClassOverview({classSectionId:t,limit:3e3});E.warnings.length>0&&F(E.warnings.join(" ")),I=co(I,E.students.map(W));const U=_i(I,t),Y=f.current+=1;x(U.map((re,te)=>({rowKey:`${lo(re)}|row:${te}`,student:re,competency:null,competencyMatrix:null,competencyMatrixLoading:!0,loading:!1,expanded:!1}))),ie(U,Y)}catch(b){if(console.error("Failed to load students:",b),a.length>0){const I=a.map(ee).filter(E=>!t||E.classSectionId===t).map((E,U)=>({rowKey:`${lo(E)}|row:${U}`,student:E,competency:null,competencyMatrix:null,competencyMatrixLoading:!1,loading:!1,expanded:!1}));x(I),F("Showing recently imported students while backend roster sync catches up.")}else x([]),F("Student competency roster is unavailable right now.")}finally{T(!1)}}},[t,c?.uid,a,ie,ee,W]);h.useEffect(()=>{je()},[je]),h.useEffect(()=>{(async()=>{if(!t){j([]),V("");return}R(!0),V("");try{const I=await Je.getCourseMaterialTopics({classSectionId:t,limit:20}),E=(I.topics||[]).filter(U=>U.title?.trim());j(E),I.warnings.length>0&&V(I.warnings.join(" "))}catch{j([]),V("Imported topic context is unavailable right now.")}finally{R(!1)}})()},[t]);const ve=async b=>{x(I=>I.map(E=>{if(E.rowKey!==b)return E;const U=!E.expanded,Y=E.student.id,re={weakestTopic:E.student.weakestTopic,avgQuizScore:E.student.avgQuizScore};return U&&!E.competency&&!E.loading?(ke(b,Y,re),{...E,expanded:!0,loading:!0}):{...E,expanded:U}}))},ke=async(b,I,E)=>{try{const Y=((await cn(I))?.quizAttempts??[]).map(te=>({topic:te.quizId,score:te.score,total:100,timeTaken:te.timeSpent})),re=await Je.getStudentCompetency(I,Y.length>0?Y:void 0);x(te=>te.map(A=>A.rowKey===b?{...A,competency:re,loading:!1}:A))}catch{const Y=E.avgQuizScore||50,re={studentId:I,competencies:[{topic:E.weakestTopic||"Unknown",efficiencyScore:Math.max(15,Y-20),competencyLevel:Y<50?"beginner":"developing",perspective:`Student needs focused practice in ${E.weakestTopic}.`},{topic:"Functions and Relations",efficiencyScore:Math.min(95,Y+10),competencyLevel:Y>70?"proficient":"developing",perspective:"Shows solid understanding of function concepts."},{topic:"Problem Solving",efficiencyScore:Y,competencyLevel:Y>80?"advanced":Y>60?"proficient":"developing",perspective:"Applies mathematical reasoning consistently."}],recommendedTopics:[E.weakestTopic||"Review fundamentals"],excludeTopics:[]};x(te=>te.map(A=>A.rowKey===b?{...A,competency:re,loading:!1}:A))}},le=b=>{p===b?L(I=>I==="asc"?"desc":"asc"):(y(b),L("asc"))},P={High:0,Medium:1,Low:2},K=v.filter(b=>{if(N!=="all"&&b.student.riskLevel!==N)return!1;if(C){const I=C.toLowerCase();return b.student.name.toLowerCase().includes(I)||b.student.email.toLowerCase().includes(I)}return!0}).sort((b,I)=>{let E=0;switch(p){case"name":E=b.student.name.localeCompare(I.student.name);break;case"avgQuizScore":E=b.student.avgQuizScore-I.student.avgQuizScore;break;case"riskLevel":E=P[b.student.riskLevel]-P[I.student.riskLevel];break;case"engagementScore":E=b.student.engagementScore-I.student.engagementScore;break}return k==="asc"?E:-E}),ae=v.length,Le=v.filter(b=>b.student.riskLevel==="High").length,Ae=ae>0?Math.round(v.reduce((b,I)=>b+I.student.avgQuizScore,0)/ae):0,Pe=ae>0?Math.round(v.reduce((b,I)=>b+I.student.engagementScore,0)/ae):0,O=Array.from(new Set(m.map(b=>b.title).filter(Boolean))).slice(0,10),X=({field:b})=>p!==b?e.jsx(_t,{size:14,className:"text-white/40"}):k==="asc"?e.jsx(Sa,{size:14,className:"text-white font-bold"}):e.jsx(_t,{size:14,className:"text-white font-bold"});return g?e.jsxs("div",{className:"flex items-center justify-center py-20 p-6",children:[e.jsx(lt,{size:32,className:"animate-spin text-[var(--primary)]"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading student data..."})]}):e.jsxs(Ge.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(as,{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(dn,{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(Rs,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:Le}),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(gs,{className:"w-4 h-4 text-white"})})]}),e.jsxs("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:"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(aa,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[28px] font-bold relative z-10 leading-none mb-4",children:[Pe,"%"]}),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(ra,{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:C,onChange:b=>S(b.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(b=>e.jsx("button",{onClick:()=>B(b),className:`px-4 py-1.5 text-[13px] font-semibold rounded-full whitespace-nowrap transition-colors shadow-md ${N===b?"bg-[#9956DE] text-white":"bg-white text-slate-500 hover:text-slate-700 hover:bg-slate-50"}`,children:b==="all"?"All":`${b} Risk`},b))})]}),e.jsxs("button",{onClick:je,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(Vs,{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..."}):O.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-1 sm:mt-0",children:O.map((b,I)=>e.jsxs(ce.Fragment,{children:[e.jsx("span",{className:"text-[#8b5cf6] text-[13px]",children:b}),Ile("name"),children:["Student ",e.jsx(X,{field:"name"})]}),e.jsxs("div",{className:"w-[120px] shrink-0 px-4 flex justify-center cursor-pointer hover:text-white/80 transition-colors",onClick:()=>le("riskLevel"),children:["Risk Level ",e.jsx(X,{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:()=>le("avgQuizScore"),children:["Avg. Score ",e.jsx(X,{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:()=>le("engagementScore"),children:["Engagement ",e.jsx(X,{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"}),Ja.map((b,I)=>e.jsx("div",{className:`w-[100px] shrink-0 px-2 flex justify-center ${I===Ja.length-1?"border-r border-transparent":""}`,children:b.header},b.key))]}),K.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(dn,{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(b=>(b.student.riskLevel==="High"||b.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 ve(b.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 ${b.expanded?"rotate-90":""}`,children:e.jsx(ts,{className:"w-4 h-4 text-slate-400"})}),e.jsx("img",{src:b.student.avatar,alt:b.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:b.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 ${b.student.riskLevel==="High"?"bg-rose-50 text-rose-600 border-rose-200":b.student.riskLevel==="Medium"?"bg-amber-50 text-amber-600 border-amber-200":"bg-emerald-50 text-emerald-600 border-emerald-200"}`,children:b.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 ${b.student.avgQuizScore>=80?"bg-emerald-500":b.student.avgQuizScore>=60?"bg-amber-400":"bg-rose-500"}`,style:{width:`${b.student.avgQuizScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[b.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:`${b.student.engagementScore}%`}})}),e.jsxs("span",{className:"text-[13px] font-bold text-slate-800 w-8",children:[b.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:b.student.weakestTopic})}),Ja.map(I=>{const E=b.competencyMatrix?.[I.key]??0;return e.jsx("div",{className:"w-[100px] shrink-0 px-2 flex justify-center",children:b.competencyMatrixLoading?e.jsx(lt,{size:12,className:"animate-spin text-muted-foreground"}):b.competencyMatrix?e.jsxs("span",{className:`text-[12px] font-medium px-2 rounded-full border ${E>=80?"text-emerald-600 bg-emerald-50 border-emerald-100":E>=60?"text-amber-600 bg-amber-50 border-amber-100":"text-rose-500 bg-rose-50 border-rose-100"}`,children:[E,"%"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},I.key)})]}),e.jsx(qt,{children:b.expanded&&e.jsx(Ge.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:b.loading?e.jsxs("div",{className:"flex items-center py-4",children:[e.jsx(lt,{size:16,className:"animate-spin text-indigo-500 mr-2"}),e.jsx("span",{className:"text-sm text-slate-500",children:"Analyzing competency data..."})]}):b.competency?e.jsxs("div",{className:"space-y-4 max-w-4xl",children:[b.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(Bt,{className:"w-4 h-4"})," Recommended Focus Areas"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:b.competency.recommendedTopics.map((I,E)=>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:I},E))})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:b.competency.competencies.map((I,E)=>e.jsx(_u,{competency:I},E))})]}):e.jsx("div",{className:"text-sm text-slate-500 py-4",children:"Failed to load competency details."})})]})})})]},b.rowKey)))})]})})]})},_u=({competency:t})=>{const s=uo[t.competencyLevel]||uo.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(Ge.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})]})},Mu=()=>{const{notifications:t,unreadCount:s,isLoading:a,markAsRead:r,markAllAsRead:o}=bl(),[n,i]=h.useState("all"),l=x=>{switch(x){case"achievement_unlocked":case"achievement":return vl;case"message":return cl;case"grade":case"quiz_result":return Mo;case"reminder":case"streak_reminder":case"daily_checkin":return _s;case"risk_alert":return Rs;case"sparkles":case"lesson_plan_ready":return rs;case"users":case"student_import":return Ft;default:return Ca}},c=(x,g)=>{switch(x){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"}},d=x=>{switch(x){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)]"}},f=h.useMemo(()=>{let x=t;return n==="unread"&&(x=x.filter(g=>!g.isRead)),n==="important"&&(x=x.filter(g=>g.type==="risk_alert")),x},[t,n]),v=h.useMemo(()=>{const x=[],g=f.filter(S=>En(S.createdAt)),T=f.filter(S=>Rn(S.createdAt)),C=f.filter(S=>!En(S.createdAt)&&!Rn(S.createdAt));return g.length>0&&x.push({title:"Today",icon:_s,items:g}),T.length>0&&x.push({title:"Yesterday",icon:pn,items:T}),C.length>0&&x.push({title:"Earlier",icon:pn,items:C}),x},[f]);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:s})]}),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",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:s>0?`${s} unread`:"No unread"}),e.jsxs("button",{onClick:o,disabled:s===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(Ul,{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(lt,{className:"w-8 h-8 text-[#a855f7] animate-spin"}),e.jsx("p",{className:"text-[14px] font-medium text-[#64748b]",children:"Syncing notifications..."})]}):v.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(Ca,{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."})]}):v.map(x=>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(x.icon,{className:"w-4 h-4"})," ",x.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:x.items.map(g=>{const T=l(g.type),C=g.type==="risk_alert";return e.jsxs(Ge.div,{layout:!0,onClick:()=>!g.isRead&&r(g.id),className:`relative p-5 flex gap-5 group cursor-pointer hover:bg-white transition-all duration-300 ${g.isRead?"opacity-80":c(g.type)}`,children:[e.jsx("div",{className:`absolute left-0 top-0 w-1.5 h-full transition-colors ${g.isRead?"bg-transparent":C?"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 ${d(g.type)}`,children:e.jsx(T,{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:[g.title,!g.isRead&&e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${C?"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 ${g.isRead?"text-[#94a3b8]":C?"text-rose-600":"text-[#a855f7]"}`,children:[Vl(g.createdAt)," ago"]})]}),e.jsx("p",{className:"text-[14px] text-[#475569] font-medium leading-relaxed",children:g.message}),!g.isRead&&g.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 ${C?"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(ac,{size:18})})]},g.id)})})]},x.title))})]})})},zu=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)}},Lu=async(t,s)=>{const a=vt(Xt(et,"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:ft(),updatedAt:ft()}),r},Au=async(t,s)=>{const a=vt(et,"calendarEvents",t);await Kt(a,{...s,updatedAt:ft()})},Du=async t=>{await Sl(vt(et,"calendarEvents",t))},Mi=(t,s={},a,r)=>{if(!t)return a([]),()=>{};const{limitCount:o=500}=s,n=Pt(Xt(et,"calendarEvents"),Ht("userId","==",t),Lo(o));return Ao(n,i=>{a(i.docs.map(l=>zu(l)))},i=>{console.error("Error subscribing to calendar events:",i),r?.(i)})};function $u({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:_o("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 Ts=t=>String(t).padStart(2,"0"),ms=t=>`${t.getFullYear()}-${Ts(t.getMonth()+1)}-${Ts(t.getDate())}`,pr=t=>new Date(t.getFullYear(),t.getMonth(),1),mo=t=>new Date(t.getFullYear(),t.getMonth()+1,0),Fu=t=>{const s=pr(t),a=s.getDay(),r=new Date(s);return r.setDate(s.getDate()-a),r.setHours(0,0,0,0),r},Ou=(t,s)=>{const a=new Date(t);return a.setDate(a.getDate()+s),a},xo=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate(),Bu=(t,s)=>t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth(),Pu=t=>t.toLocaleDateString(void 0,{month:"long",year:"numeric"}),pa=t=>t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),po=(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)},Hu=["purple","blue","emerald","amber","rose"],Za=t=>{switch(t){case"blue":return"#3b82f6";case"emerald":return"#10b981";case"amber":return"#f59e0b";case"rose":return"#f43f5e";case"purple":default:return"#a855f7"}},Gu=(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"}},Qu=(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"}}},er=[{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 Uu(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=er.find(i=>i.names.includes(r[1]))?.day,n=er.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 er.forEach(({names:o,day:n})=>{o.some(i=>s.includes(i))&&a.add(n)}),Array.from(a).sort((o,n)=>o-n)}const Vu=({classes:t,teacherId:s})=>{const{currentUser:a}=os(),[r,o]=h.useState([]),[n,i]=h.useState(!0),[l,c]=h.useState(""),[d,f]=h.useState(!0),[v,x]=h.useState(()=>{const A=new Date;return A.setHours(0,0,0,0),A}),[g,T]=h.useState(()=>{const A=new Date;return A.setHours(0,0,0,0),A}),[C,S]=h.useState(new Set),[p,y]=h.useState(!1),[k,L]=h.useState(null),[N,B]=h.useState(!1),[m,j]=h.useState(""),[w,R]=h.useState(""),[z,V]=h.useState(()=>ms(new Date)),[Q,F]=h.useState("09:00"),[W,ee]=h.useState(""),[ie,je]=h.useState("purple"),[ve,ke]=h.useState(!1),[le,P]=h.useState(null);h.useEffect(()=>{if(!a?.uid){o([]),i(!1);return}c(""),i(!0);const A=Mi(a.uid,{limitCount:500},oe=>{o(oe),i(!1)},()=>{c("Unable to load calendar events right now."),i(!1)});return()=>A()},[a?.uid]);const K=h.useMemo(()=>{const A=pr(v);return A.setHours(0,0,0,0),A},[v]),ae=h.useMemo(()=>{const A=mo(v);return A.setHours(23,59,59,999),A},[v]),Le=h.useMemo(()=>{if(!t||t.length===0)return[];const A=[],oe=pr(v),me=mo(v),Ne=new Date(oe);for(;Ne<=me;){const J=Ne.getDay();t.forEach(_e=>{if(Uu(_e.schedule).includes(J)){const Te=`schedule-${_e.id}-${ms(Ne)}`;C.has(Te)||A.push({id:Te,userId:s||"",title:_e.name,startTime:new Date(Ne),createdAt:new Date})}}),Ne.setDate(Ne.getDate()+1)}return A},[t,v,s,C]),Ae=h.useMemo(()=>[...r,...Le],[r,Le]),Pe=h.useMemo(()=>Ae.filter(A=>A.startTime>=K&&A.startTime<=ae).sort((A,oe)=>A.startTime.getTime()-oe.startTime.getTime()),[Ae,K,ae]),O=h.useMemo(()=>{const A=new Map;for(const oe of Pe){const me=ms(oe.startTime),Ne=A.get(me)||[];Ne.push(oe),A.set(me,Ne)}return A},[Pe]),X=h.useMemo(()=>ms(g),[g]),b=h.useMemo(()=>[...O.get(X)||[]].sort((oe,me)=>oe.startTime.getTime()-me.startTime.getTime()),[O,X]),I=h.useMemo(()=>{const A=Fu(v);return Array.from({length:42}).map((oe,me)=>Ou(A,me))},[v]),E=A=>{const oe=ms(A);L(null),j(""),R(""),V(oe),F("09:00"),ee(""),je("purple"),y(!0)},U=A=>{A.id.startsWith("schedule-")?(S(oe=>new Set(oe).add(A.id)),L(null)):L(A.id),j(A.title),R(A.description||""),V(ms(A.startTime)),F(Ts(A.startTime.getHours())+":"+Ts(A.startTime.getMinutes())),ee(A.endTime?Ts(A.endTime.getHours())+":"+Ts(A.endTime.getMinutes()):""),je(A.color||"purple"),ke(!1),y(!0)},Y=(A,oe)=>{A.stopPropagation(),P(oe),ke(!0)},re=async()=>{const A=a?.uid||s||"local-user";if(!m.trim()){c("Event title is required.");return}B(!0),c("");const oe=po(z,Q),me=W?po(z,W):void 0,Ne={title:m.trim(),description:w.trim()?w.trim():void 0,startTime:oe,endTime:me&&me.getTime()>oe.getTime()?me:void 0,color:ie};try{if(k)o(J=>J.map(_e=>_e.id===k?{..._e,...Ne}:_e)),await Au(k,Ne);else{const J=`temp-${Date.now()}`;o(_e=>[..._e,{id:J,userId:A,createdAt:new Date,...Ne}]),await Lu(A,Ne)}y(!1)}catch(J){console.error(J),y(!1)}finally{B(!1)}},te=async A=>{if(A.startsWith("schedule-")){S(oe=>new Set(oe).add(A)),le?.id===A&&ke(!1);return}c(""),o(oe=>oe.filter(me=>me.id!==A)),le?.id===A&&ke(!1);try{await Du(A)}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:()=>x(new Date(v.getFullYear(),v.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(as,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-[22px] font-bold text-white w-44 text-center tracking-tight",children:Pu(v)}),e.jsx("button",{onClick:()=>x(new Date(v.getFullYear(),v.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(ts,{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:[Pe.length," events"]}),e.jsx("button",{onClick:()=>f(!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(mc,{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(A=>e.jsx("div",{className:"text-[12px] font-bold text-[#475569] uppercase tracking-widest",children:A},A))}),e.jsx("div",{className:"grid grid-cols-7 gap-2 pb-6 px-4",children:I.map(A=>{const oe=ms(A),me=O.get(oe)||[],Ne=xo(A,g),J=xo(A,new Date),_e=Bu(A,v);return e.jsxs("div",{onClick:()=>T(new Date(A)),className:`group p-2 rounded-lg transition-all cursor-pointer border-2 flex flex-col relative min-h-[100px] xl:min-h-[120px] ${Ne?"bg-purple-50/50 border-[#a855f7] shadow-sm z-10":J?"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"} ${_e?"":"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 ${J?"bg-gradient-to-br from-[#a855f7] to-[#9333ea] text-white shadow-md":Ne?"text-[#9333ea]":"text-[#1e293b]"}`,children:A.getDate()})}),e.jsxs("div",{className:"mt-1 space-y-1",children:[me.slice(0,3).map(Ve=>{const Te=Ve.id.startsWith("schedule-");return e.jsx("div",{onClick:Ke=>Y(Ke,Ve),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 ${Gu(Ve.color,Te)}`,children:Ve.title},Ve.id)}),me.length>3&&e.jsxs("div",{className:"text-[10px] font-bold text-[#64748b] pl-1 pt-0.5",children:["+",me.length-3," more"]})]})]},oe)})})]})]})}),e.jsx(qt,{children:d&&e.jsx(Ge.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:g.toLocaleDateString(void 0,{weekday:"long"})}),e.jsx("p",{className:"text-[13px] font-medium text-[#64748b]",children:g.toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})})]}),e.jsx("button",{onClick:()=>E(g),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(rr,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar pb-12",children:b.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[e.jsx(Qa,{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."})]}):b.map(A=>{const oe=A.id.startsWith("schedule-"),me=Qu(A.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 ${me.dot}`}),e.jsxs("div",{onClick:Ne=>Y(Ne,A),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 ${me.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:A.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 ${me.time}`,children:[e.jsx(_s,{className:"w-3.5 h-3.5"})," ",e.jsxs("span",{children:[pa(A.startTime),A.endTime?` - ${pa(A.endTime)}`:""]})]}),A.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:A.description})]})]},A.id)})})]})})})]}),e.jsx(bn,{open:p,onOpenChange:y,children:e.jsx(vn,{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(Wl,{className:"mb-6",children:[e.jsx(ql,{className:"text-[24px] font-bold text-[#1e293b] tracking-tight",children:k?"Edit Event":"Add New Event"}),e.jsx(Yl,{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(Qs,{value:m,onChange:A=>j(A.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(Qs,{type:"date",value:z,onChange:A=>V(A.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(Qs,{type:"time",value:Q,onChange:A=>F(A.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($u,{value:w,onChange:A=>R(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:Hu.map(A=>e.jsx("button",{onClick:()=>je(A),className:`w-8 h-8 rounded-full flex items-center justify-center transition-all ${ie===A?"ring-2 ring-offset-2 ring-slate-800 scale-110 shadow-sm":"hover:scale-110 opacity-80 hover:opacity-100"}`,style:{backgroundColor:Za(A)},title:A,children:ie===A&&e.jsx(Vt,{className:"w-4 h-4 text-white"})},A))})]})]}),e.jsxs("div",{className:"flex gap-3 mt-8",children:[e.jsx(ps,{variant:"outline",onClick:()=>y(!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(ps,{onClick:re,disabled:N,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:N?e.jsx(lt,{className:"w-5 h-5 animate-spin"}):"Save Event"})]})]})})}),e.jsx(bn,{open:ve,onOpenChange:ke,children:e.jsx(vn,{className:"sm:max-w-[400px] p-0 overflow-hidden rounded-[24px] border-none shadow-2xl [&>button]:hidden",children:le&&e.jsxs("div",{className:"p-8 bg-white relative",children:[e.jsx("button",{onClick:()=>ke(!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(fs,{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:Za(le.color||"purple")+"20",color:Za(le.color||"purple")},children:le.id.startsWith("schedule-")?e.jsx(gr,{size:24}):e.jsx(Qa,{size:24})}),e.jsxs("div",{className:"pr-6",children:[e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] leading-tight mb-2",children:le.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(Qa,{size:12}),le.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(_s,{size:12}),pa(le.startTime),le.endTime?` - ${pa(le.endTime)}`:""]})]})]})]}),le.description&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Jl,{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:le.description})]}),e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-slate-100",children:[e.jsxs(ps,{variant:"outline",onClick:()=>te(le.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($o,{className:"w-4 h-4 mr-2"})," Delete"]}),e.jsxs(ps,{onClick:()=>U(le),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(Ho,{className:"w-4 h-4 mr-2"})," Edit Event"]})]})]})})})]})},Ra=[{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]"}],ho=({classes:t,students:s=[],onSelectClass:a,onOpenNotifications:r,onOpenProfile:o,insightDismissed:n,onOpenInsightModal:i,viewType:l="analytics"})=>{const{currentUser:c,userProfile:d}=os(),[f,v]=h.useState(""),x=l==="competency",g=t.reduce((w,R)=>w+(R.studentCount||0),0),T=t.reduce((w,R)=>w+(R.atRiskCount||0),0),C=t.length>0?(t.reduce((w,R)=>w+(R.avgScore||0),0)/t.length).toFixed(1):0,S=s.filter(w=>typeof w.attendance=="number"&&Number.isFinite(w.attendance)),p=S.length>0?Math.round(S.reduce((w,R)=>w+(R.attendance??0),0)/S.length):null,y=p!==null?Math.round(g*(p/100)):null,k=s.reduce((w,R)=>{const z=(R.weakestTopic||"").trim();return z&&(w[z]=(w[z]??0)+1),w},{}),L=Object.entries(k).sort((w,R)=>R[1]-w[1])[0]?.[0]??null,N=t.filter(w=>w.riskLevel==="high").sort((w,R)=>(R.atRiskCount||0)-(w.atRiskCount||0))[0],B=t.filter(w=>w.riskLevel==="medium").sort((w,R)=>(R.atRiskCount||0)-(w.atRiskCount||0))[0],m=[];N&&m.push({kind:"risk",className:N.name,atRisk:N.atRiskCount}),B&&B.id!==N?.id&&m.push({kind:"medium",className:B.name,atRisk:B.atRiskCount});const j=t.filter(w=>w.name.toLowerCase().includes(f.toLowerCase())||(w.gradeLevel||"").toLowerCase().includes(f.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-[24px] xl:p-[32px] 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(ra,{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:f,onChange:w=>v(w.target.value),className:"bg-transparent border-none focus:outline-none ml-3 text-[13px] w-full text-[#475569] placeholder:text-[#94a3b8]"})]})})}),x?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",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(Ft,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:g}),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",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",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(Yt,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[C,"%"]}),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",children:"Across all classes"})})]}),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",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(Yt,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[20px] font-bold relative z-10 leading-tight mb-2 truncate",children:L??"—"}),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",children:L?`Identified across ${t.length} ${t.length===1?"class":"classes"}`:"Awaiting student topic data"})})]})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-[16px]",children:[e.jsxs("div",{className:"lg:col-span-8 grid grid-cols-1 sm:grid-cols-3 gap-[16px]",children:[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",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(Ft,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:p!==null?`${p}%`:"—"}),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",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:y!==null?y:"—"})]})]}),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",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(Yt,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:[C,"%"]}),e.jsx("div",{className:"flex items-center justify-between relative z-10 border-t border-white/20 pt-3",children:e.jsxs("span",{className:"text-[12px] font-medium text-white",children:["Across ",t.length," ",t.length===1?"class":"classes"]})})]}),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",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(Ys,{className:"w-4 h-4 text-white"})})]}),e.jsx("div",{className:"text-[32px] font-bold relative z-10 leading-none mb-6",children:T}),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",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:[g>0?Math.round(T/g*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:m.length===0?"All clear":`${m.length} Pending`})]}),e.jsxs("div",{className:"space-y-[8px] flex-1 overflow-y-auto no-scrollbar relative z-10",children:[m.length===0&&e.jsxs("div",{className:"bg-white/10 rounded-[8px] p-3 text-[12px] border border-white/10 backdrop-blur-sm flex gap-3 items-start",children:[e.jsx("div",{className:"mt-0.5 shrink-0 text-white",children:e.jsx(rs,{className:"w-4 h-4"})}),e.jsx("div",{className:"leading-snug text-white",children:"No high-risk classes detected. Review individual student progress in the Competency tab."})]}),m.map((w,R)=>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",children:w.kind==="risk"?e.jsx(Ys,{className:"w-4 h-4"}):e.jsx(Go,{className:"w-4 h-4"})}),e.jsxs("div",{className:"leading-snug text-white",children:[e.jsx("span",{className:"font-bold text-white",children:w.className})," ","has ",w.atRisk," ",w.atRisk===1?"student":"students"," flagged"," ",w.kind==="risk"?"as high-risk":"as needing attention","."]})]},`${w.kind}-${R}-${w.className}`))]})]})]}),e.jsxs("div",{className:"bg-white/60 backdrop-blur-[12px] rounded-[24px] p-[24px] shadow-[0_1px_4px_rgba(0,0,0,0.02)] border border-white mt-[24px]",children:[e.jsx("div",{className:"mb-6 border-b border-[#f1f5f9] pb-4",children:e.jsx("h2",{className:"text-[18px] font-semibold text-[#1e293b]",children:x?"Select a Class":"My Classes"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-[16px]",children:[j.map((w,R)=>{const z=Ra[R%Ra.length];let V=null;return w.riskLevel==="high"?V=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"}):w.riskLevel==="medium"?V=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"}):V=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:()=>a(w),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] ${z.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] ${z.bg} flex items-center justify-center border ${z.border}`,children:e.jsx(Bt,{className:`w-5 h-5 ${z.text}`})}),e.jsxs("div",{children:[e.jsx("h4",{className:`font-bold text-[14px] text-[#1e293b] mb-0.5 transition-colors ${z.groupHover}`,children:w.name}),e.jsx("p",{className:"text-[11px] font-semibold text-[#64748b] uppercase tracking-wider",children:w.gradeLevel||"Senior High"})]})]}),V]}),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:w.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:x?"Avg Competency":"Average"}),e.jsxs("span",{className:"font-semibold text-[#1e293b]",children:[w.avgScore,"%"]})]}),!x&&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:w.schedule||"Mon-Fri"})]})]})]})]},w.id)}),j.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",Wu=.85,hr=.85,qu="2026.04.24",Li=4,wa=["INPUT DATA","SENIOR HIGH SCHOOL CLASS RECORD","LEARNERS NAMES","WRITTEN WORK","PERFORMANCE TASKS","QUARTERLY ASSESSMENT","REMARK","FINAL SEMESTRAL GRADES"],Yu=[...wa,"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"],Ku=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],la=["WITH ATTACHMENTS","OFFICIALLY DROPPED","WITHDRAWN","UNOFFICIALLY DROPPED","TRANSFEREE","SHIFTER"],Xu=["TOTAL","SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY","WEIGHT OF COMPONENTS"],Ju={SECOND:["SECOND QUARTER","2ND QUARTER","Q2"]},ks={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"]},St={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 Zu(t){return t==null?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:String(t)}function ct(t){return String(t??"").replace(/[\u00a0\t\r\n]+/g," ").replace(/[|]+/g," ").replace(/\s+/g," ").trim().toUpperCase()}function fo(t){return ct(t).replace(/[^A-Z0-9]+/g,"")}function Se(t,s){const a=ct(t),r=ct(s);if(!a||!r)return!1;if(a.includes(r))return!0;const o=fo(t),n=fo(s);return!o||!n?!1:o.includes(n)}function Na(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 tr(t){return ct(t).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80)}function Ai(t){const s={};return t.forEach(a=>{const r=Tt.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=Tt.encode_cell({r:o,c:n});s[i]=r}}),s}function em(t,s,a){const o=(a||Ai(t.merges))[s]||s;return t.cells[o]||t.cells[s]}const Di="A1:A1",go=1200,bo=200,vo=2e5;function tm(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>go&&(r=s+go-1),o-a+1>bo&&(o=a+bo-1);const n=r-s+1,i=o-a+1;if(n*i>vo){const c=Math.max(1,Math.floor(vo/i));r=s+Math.min(n,c)-1}return{s:{r:s,c:a},e:{r,c:o}}}function sm(t){try{return Tt.decode_range(t)}catch{return Tt.decode_range(Di)}}function am(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=Tt.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 rm(t){const s=sm(t.ref||Di),a=am(t);return tm(a||s)}function nm(t,s){const a=rm(s),r=`${Tt.encode_cell(a.s)}:${Tt.encode_cell(a.e)}`,o=Ai(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 ds(t,s){return st.endRow?"":(t.cells[s-t.startRow]||[]).map(r=>r?.normalizedText||"").filter(Boolean).join(" ").trim()}function Hs(t){return Tt.encode_col(t)}function ha(t){const s=String(t||"").trim().toUpperCase();if(!s||!/^[A-Z]+$/.test(s))return-1;try{return Tt.decode_col(s)}catch{return-1}}function om(t){return`${Tt.encode_cell(t.s)}:${Tt.encode_cell(t.e)}`}function im(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=Fe(t,r,n);o.push(i?.displayValue??null)}a.push(o)}return a}function lm(t,s){const a=ct(t),r=ct(s);return!a||!r?0:a===r?1:a.includes(r)?.9:.75}function Lr(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:lm(l.displayValue,c)})})}const o=t.startRow+r,n=ds(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 cm(t,s){return Object.values(t).flatMap(a=>Lr(a,s))}function xt(t,s){return Lr(t,[s]).sort((a,r)=>a.row-r.row||a.col-r.col)}function $i(t,s,a,r=6){for(let o=1;o<=r;o+=1){const i=Fe(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=Fe(t,s+o,a)?.displayValue;if(i!=null&&String(i).trim())return String(i).trim()}}function Fi(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=ds(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 dm(t,s){const a=ct(t).toLowerCase(),r=o=>[...s].some(n=>Se(n,o));return ks.inputData.some(o=>a.includes(o))||r("INPUT DATA")?"inputData":ks.finalSemestral.some(o=>a.includes(o))||r("FINAL SEMESTRAL GRADES")||r("FINAL GRADES")?"finalSemestral":ks.firstQuarter.some(o=>a.includes(o))||r("FIRST QUARTER")?"firstQuarter":ks.secondQuarter.some(o=>a.includes(o))||r("SECOND QUARTER")?"secondQuarter":r("SENIOR HIGH SCHOOL CLASS RECORD")||r("WRITTEN WORK")&&r("PERFORMANCE TASKS")?"firstQuarter":ks.helper.some(o=>a.includes(o))||r("WEIGHT OF COMPONENTS")||r("ATTACHMENTS")||r("HELPER")?"helper":ks.lookup.some(o=>a.includes(o))||r("LOOK UP")?"lookup":"other"}function um(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 mm(t){const s=cm(t.matrices,Yu),a=new Set,r=[];wa.forEach(g=>{s.some(C=>Se(C.anchor,g))&&(a.add(g),r.push(`Found critical anchor: ${g}`))});const o=wa.filter(g=>!a.has(g)),n=new Map;s.forEach(g=>{n.has(g.sheetName)||n.set(g.sheetName,new Set),n.get(g.sheetName)?.add(g.anchor)});const i=t.sheetNames.map(g=>{const T=n.get(g)||new Set,C=dm(g,T),S=Math.min(1,.35+Math.min(.55,T.size*.08)),p=[`sheet:${g}`,`signals:${T.size}`,...[...T].slice(0,5)];return{sheetName:g,role:C,confidence:Number(S.toFixed(3)),evidence:p}}),l={firstQuarter:[],secondQuarter:[],finalSemestral:[],helper:[],lookup:[],other:[]};i.forEach(g=>{switch(g.role){case"inputData":l.inputData?l.other.push(g.sheetName):l.inputData=g.sheetName;break;case"firstQuarter":l.firstQuarter.push(g.sheetName);break;case"secondQuarter":l.secondQuarter.push(g.sheetName);break;case"finalSemestral":l.finalSemestral.push(g.sheetName);break;case"helper":l.helper.push(g.sheetName);break;case"lookup":l.lookup.push(g.sheetName);break;case"other":default:l.other.push(g.sheetName);break}});const c=(l.inputData?1:0)+l.firstQuarter.length+l.secondQuarter.length+l.finalSemestral.length+l.helper.length+l.lookup.length,d=um({criticalFound:a.size,criticalTotal:wa.length,recognizedSheets:c,totalSheets:t.sheetNames.length,hasDepedAnchor:s.some(g=>Se(g.anchor,"Pursuant to DepEd Order 8 series of 2015"))}),f=l.firstQuarter.length>0||l.secondQuarter.length>0,v=!!l.inputData&&f&&l.finalSemestral.length>0,x=d>=.55&&v;return l.inputData||r.push("Input Data sheet not confidently detected."),f||r.push("No quarter class record sheet detected."),l.finalSemestral.length===0&&r.push("No Final Semestral Grades sheet detected."),{format:zi,isOfficialFormatLikely:x,confidence:d,evidence:r,missingCriticalAnchors:o,detectedSheets:l,anchorMatches:s}}function _a(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 Ar(t){const s=ct(t);if(s.includes("FEMALE"))return"FEMALE";if(s.includes("MALE"))return"MALE"}function Dr(t){const s=ct(t.rowText);return s?s==="MALE"||s==="FEMALE"?"sex-header":Ku.some(a=>s.includes(a))?"signature":Xu.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 xm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(o=>{a.push({role:r,name:String(Fe(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function pm(t){const s=[],a=xt(t,"LEARNERS NAMES")[0],r=a?Fi(t,a.row,5):t.startRow,o=(S,p)=>xt(t,S).find(k=>Math.abs(k.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),f=o(De.finalGrades[0],d+1),v=o(De.remark[0],f+1),x=o(De.additionalRemarks[0],v+1),g=[];let T="UNKNOWN",C=0;for(let S=r+1;S<=t.endRow;S+=1){const p=ds(t,S),y=Dr({rowText:p,hasLearnerNumber:/\b\d{1,2}\b/.test(p),hasLearnerName:/[A-Z]{2,}/.test(p)});if(y==="sex-header"){T=Ar(p)||T;continue}if(y==="signature"||y==="helper")break;if(y==="blank"){if(C+=1,C>=Li)break;continue}if(y!=="learner")continue;C=0;const k=_a(Fe(t,S,n)?.displayValue),L=String(Fe(t,S,i)?.displayValue||"").trim();if(!L&&k===void 0)continue;const N=Fe(t,S,l)?.displayValue??null,B=Fe(t,S,c)?.displayValue??null,m=Fe(t,S,d)?.displayValue??null,j=Fe(t,S,f)?.displayValue??null,w=Fe(t,S,v)?.displayValue??null;let R=Fe(t,S,x)?.displayValue??null;const z=la.filter(V=>Se(p,V));z.length>0&&(R=[R,z.join("; ")].filter(Boolean).join("; ")||null),!L&&k!==void 0&&s.push(`Row ${S+1} has learner number ${k} but empty learner name.`),g.push({learnerNo:k,fullName:L||`Unnamed Learner ${k||S+1}`,sex:T,firstQuarter:N,secondQuarter:B,firstSemester:m,finalGrades:j,remark:w,additionalRemarks:R,sourceRow:S+1})}return{sheetName:t.sheetName,learnerGrades:g,signatures:xm(t),warnings:s}}function Rt(t,s){for(const a of s){const r=xt(t,a);for(const o of r){const n=$i(t,o.row,o.col,8);if(n&&n.trim())return n.trim()}}}function hm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(n=>{const i=$i(t,n.row,n.col,10);a.push({role:r,name:i,sourceSheet:t.sheetName,sourceRow:n.row+1})})}),a}function fm(t){const s=xt(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 f=a;f<=t.endRow;f+=1){const v=ds(t,f),x=Dr({rowText:v,hasLearnerNumber:!!_a(Fe(t,f,o)?.displayValue),hasLearnerName:!!String(Fe(t,f,r)?.displayValue||"").trim()});if(x==="sex-header"){c=Ar(v)||c,d=0;continue}if(x==="signature"||x==="helper")break;if(x!=="learner"){if(x==="blank"&&(d+=1),d>=5)break;continue}d=0;const g=_a(Fe(t,f,o)?.displayValue),T=String(Fe(t,f,r)?.displayValue||"").trim(),C=String(Fe(t,f,n)?.displayValue||"").trim()||void 0,S=String(Fe(t,f,i)?.displayValue||"").trim()||void 0,p=la.filter(y=>Se(v,y));!T&&g===void 0||l.push({learnerNo:g,sex:c,fullName:T||`Unnamed Learner ${g||f}`,sourceSheet:t.sheetName,sourceRow:f+1,remarks:C,additionalRemarks:S,statuses:p.length>0?p:void 0})}return l}function gm(t){const s=[],a=[];for(let r=t.startRow;r<=t.endRow;r+=1){const o=ds(t,r);if(o){if(la.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 bm(t){const s=[],a={region:Rt(t,St.region),division:Rt(t,St.division),schoolName:Rt(t,St.schoolName),schoolId:Rt(t,St.schoolId),schoolYear:Rt(t,St.schoolYear),gradeSection:Rt(t,St.gradeSection),semester:Rt(t,St.semester),track:Rt(t,St.track),subjectCode:Rt(t,St.subjectCode),subjectName:Rt(t,St.subjectName),teacherName:Rt(t,St.teacherName)},r=fm(t),o=hm(t),{attachmentRules:n,helperNotes:i}=gm(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."),Lr(t,Object.values(St).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 vm(t){const s=ct(t.sheetName);return Ju.SECOND.some(a=>Se(s,a))?"SECOND":"FIRST"}function wm(t,s){const a=[],r=[],o=[];let n,i="NONE";for(let l=t.startCol;l<=t.endCol;l+=1){const c=Fe(t,s,l),d=ct(c?.displayValue||""),f=Fe(t,s+1,l),v=String(f?.displayValue||c?.displayValue||"").trim();if(!d&&!v)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:tr(v||"quarterly_assessment"),label:v||"Quarterly Assessment",column:Hs(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:tr(v||d),label:v||d,column:Hs(l)});continue}const x={key:tr(v||d||Hs(l)),label:v||d||Hs(l),maxScore:Na(f?.displayValue),column:Hs(l)};i==="WW"?a.push(x):i==="PT"?r.push(x):i==="DERIVED"&&o.push(x)}return{writtenWorks:a,performanceTasks:r,quarterlyAssessment:n,derived:o}}function Nm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(o=>{const n=Fe(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 wo(t,s,a){for(let r=t.startCol;r<=t.endCol;r+=1){const o=ct(Fe(t,s,r)?.displayValue||""),n=ct(Fe(t,s+1,r)?.displayValue||"");if(a.some(i=>Se(o,i)||Se(n,i)))return r}}function jm(t,s,a,r){const o={learnerNo:_a(Fe(t,s,r.numberCol)?.displayValue),fullName:String(Fe(t,s,r.nameCol)?.displayValue||"").trim(),sourceRow:s+1},n={};a.writtenWorks.forEach(d=>{const f=d.column?ha(d.column):-1;if(f<0)return;const v=Fe(t,s,f)?.displayValue;n[d.key]=v??null}),Object.keys(n).length>0&&(o.writtenWorks=n);const i={};if(a.performanceTasks.forEach(d=>{const f=d.column?ha(d.column):-1;if(f<0)return;const v=Fe(t,s,f)?.displayValue;i[d.key]=v??null}),Object.keys(i).length>0&&(o.performanceTasks=i),a.quarterlyAssessment?.column){const d=ha(a.quarterlyAssessment.column);o.quarterlyAssessment=Fe(t,s,d)?.displayValue??null}const l=a.derived||[],c={};return l.forEach(d=>{if(!d.column)return;const f=ha(d.column);if(f<0)return;const v=Fe(t,s,f)?.displayValue??null;c[d.key]=v,Se(d.label,De.initialGrade[0])&&(o.initialGrade=v),Se(d.label,De.quarterlyGrade[0])&&(o.quarterlyGrade=v),Se(d.label,De.firstQuarter[0])&&(o.firstQuarter=v),Se(d.label,De.secondQuarter[0])&&(o.secondQuarter=v),Se(d.label,De.firstSemester[0])&&(o.firstSemester=v),Se(d.label,De.finalGrades[0])&&(o.finalGrades=v),Se(d.label,De.remark[0])&&(o.remark=v!==null?String(v):null),Se(d.label,De.additionalRemarks[0])&&(o.additionalRemarks=v!==null?String(v):null)}),Object.keys(c).length>0&&(o.totals=c),o}function ym(t){const s=vm(t),a=[],r=xt(t,De.learnerName[0])[0]||xt(t,De.learnerName[1])[0],o=r?Fi(t,r.row,4):t.startRow,n=wm(t,o),i=wo(t,o,De.learnerNo)??t.startCol,l=wo(t,o,De.learnerName)??Math.min(t.endCol,i+1),c=[];let d="UNKNOWN",f=0;for(let T=o+1;T<=t.endRow;T+=1){const C=ds(t,T),S=Dr({rowText:C,hasLearnerNumber:/\b\d{1,2}\b/.test(C),hasLearnerName:/[A-Z]{2,}/.test(C)});if(S==="sex-header"){d=Ar(C)||d;continue}if(S==="signature"||S==="helper")break;if(S==="blank"){if(f+=1,f>=Li)break;continue}if(S!=="learner")continue;f=0;const p=jm(t,T,n,{numberCol:i,nameCol:l});if(p.sex=d,!p.fullName&&p.learnerNo===void 0)continue;const y=la.filter(k=>Se(C,k));y.length>0&&!p.additionalRemarks&&(p.additionalRemarks=y.join("; ")),!p.fullName&&p.learnerNo!==void 0&&(a.push(`Row ${T+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 v=Na(xt(t,"WRITTEN WORK %")[0]?.value||xt(t,"WRITTEN WORK")[0]?.value),x=Na(xt(t,"PERFORMANCE TASKS %")[0]?.value||xt(t,"PERFORMANCE TASKS")[0]?.value),g=Na(xt(t,"QUARTERLY ASSESSMENT %")[0]?.value||xt(t,"QUARTERLY ASSESSMENT")[0]?.value);return{sheetName:t.sheetName,quarter:s,gradingWeights:{writtenWork:v,performanceTasks:x,quarterlyAssessment:g},assessmentColumns:n,learnerGrades:c,signatures:Nm(t),warnings:a}}function Sm(t){const s=["SUBMITTED BY","CHECKED BY","VERIFIED BY","RECOMMENDED BY","APPROVED BY"],a=[];return s.forEach(r=>{xt(t,r).forEach(o=>{a.push({role:r,name:String(Fe(t,o.row,o.col+1)?.displayValue||"").trim()||void 0,sourceSheet:t.sheetName,sourceRow:o.row+1})})}),a}function km(t){const s=[];let a=!1;for(let r=t.startRow;r<=t.endRow;r+=1){const o=ds(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=Fe(t,r,i)?.displayValue;l==null||String(l).trim()===""||(n[`c${i}`]=l)}Object.keys(n).length>2&&s.push(n)}return s}function Cm(t){const s=[],a=[],r=[],o=[],n=[];return t.forEach(i=>{Sm(i).forEach(l=>a.push(l)),km(i).forEach(l=>r.push({...l,sourceSheet:i.sheetName}));for(let l=i.startRow;l<=i.endRow;l+=1){const c=ds(i,l);if(c){if(la.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 Tm(t,s,a){const r=new Map,o=n=>{const i=`${ct(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 Im(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=`${ct(i.role)}|${ct(i.name||"")}|${i.sourceSheet}`;n.set(l,i)}),Array.from(n.values())}function Em(t){const s=Tm(t.inputData.learners,t.quarterSheets,t.finalSheets);return{format:zi,version:qu,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:Im(t.inputData,t.quarterSheets,t.finalSheets,t.references),unclassifiedBlocks:t.unclassifiedBlocks},validation:t.validation,raw:t.workbook.raw}}function Rm(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 _m(t){const s={ref:t["!ref"],merges:Rm(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 Mm(t,s){const a=Kl(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=_m(i);o[n]=l,r[n]=nm(n,l)}),{fileName:t,sheetNames:a.SheetNames,raw:{sheets:o},matrices:r}}async function zm(t){const s=await t.arrayBuffer();return Mm(t.name,s)}class Lm{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 f=Fe(o,l,c);if(!(f&&f.displayValue!==null&&f.displayValue!==void 0&&String(f.displayValue).trim())){n.add(d);continue}const x=this.collectComponent(o,l,c,i,n);x&&r.push({sheetName:o.sheetName,range:om(x),purposeGuess:a,raw2D:im(o,x)})}}),r}collectComponent(s,a,r,o,n){const i=[{row:a,col:r}];let l=a,c=a,d=r,f=r,v=!1;for(;i.length>0;){const x=i.shift();if(!x)break;const g=`${x.row}:${x.col}`;if(n.has(g)||o.has(g))continue;n.add(g);const T=Fe(s,x.row,x.col);T&&T.displayValue!==null&&T.displayValue!==void 0&&String(T.displayValue).trim()&&(v=!0,l=Math.min(l,x.row),c=Math.max(c,x.row),d=Math.min(d,x.col),f=Math.max(f,x.col),[{row:x.row-1,col:x.col},{row:x.row+1,col:x.col},{row:x.row,col:x.col-1},{row:x.row,col:x.col+1}].forEach(S=>{S.rows.endRow||S.cols.endCol||i.push(S)}))}return v?{s:{r:l,c:d},e:{r:c,c:f}}:null}}function Am(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 Dm(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 $m(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 Fm(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 Om(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(", ")}.`),Dm(t.inputData.learners).forEach(n=>s.push(n)),$m(t.quarterSheets).forEach(n=>s.push(n)),Fm(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 No=1500;function jo(t){return t?Object.values(t.matrices).reduce((s,a)=>s+a.rowCount*a.colCount,0):0}function yo(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>=No){console.warn(`${s} slow=true threshold=${No}ms`);return}}function xs(t,s){t?.onProgress?.(s)}function Pm(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 Gs(t,s,a,r){Pm(a,s).forEach(o=>{t.markRange(s.sheetName,{s:{r:o,c:s.startCol},e:{r:o,c:s.endCol}},r)})}async function Hm(t,s){const a=s?.confidenceThreshold??Wu,r=Date.now();let o=null;try{if(xs(s,{stage:"reading",message:"Reading workbook structure and raw sheets..."}),o=await zm(t),!o)throw new Error("Workbook read returned null");xs(s,{stage:"detecting-format",message:"Detecting DepEd SHS workbook format..."});const n=mm(o);xs(s,{stage:"extracting",message:"Extracting metadata, learners, grades, and references..."});const i=n.detectedSheets.inputData||o.sheetNames[0],l=o.matrices[i],c=l?bm(l):{sheetName:i,schoolContext:{},learners:[],signatures:[],attachmentRules:[],helperNotes:[],warnings:["Input data sheet was not available in matrix map."]},f=[...n.detectedSheets.firstQuarter||[],...n.detectedSheets.secondQuarter||[]].map(k=>o.matrices[k]).filter(k=>!!k).map(k=>ym(k)),v=(n.detectedSheets.finalSemestral||[]).map(k=>o.matrices[k]).filter(k=>!!k).map(k=>pm(k)),x=[...n.detectedSheets.helper||[],...n.detectedSheets.lookup||[]].map(k=>o.matrices[k]).filter(k=>!!k),g=Cm(x),T=new Lm;n.anchorMatches.forEach(k=>{const L=o.matrices[k.sheetName];L&&Gs(T,L,[k.row],`Anchor match: ${k.anchor}`)}),[c.sheetName].forEach(k=>{const L=o.matrices[k];if(!L)return;const N=Array.from({length:Math.min(14,L.rowCount)},(j,w)=>L.startRow+w),B=c.learners.map(j=>j.sourceRow-1),m=c.signatures.map(j=>j.sourceRow).filter(j=>typeof j=="number").map(j=>j-1);Gs(T,L,[...N,...B,...m],"Input Data parsed rows")}),f.forEach(k=>{const L=o.matrices[k.sheetName];if(!L)return;const N=k.learnerGrades.map(j=>j.sourceRow-1),B=k.signatures.map(j=>j.sourceRow).filter(j=>typeof j=="number").map(j=>j-1),m=N.length>0?Math.max(L.startRow,Math.min(...N)-2):L.startRow;Gs(T,L,[m,m+1,...N,...B],"Quarter sheet parsed rows")}),v.forEach(k=>{const L=o.matrices[k.sheetName];if(!L)return;const N=k.learnerGrades.map(j=>j.sourceRow-1),B=k.signatures.map(j=>j.sourceRow).filter(j=>typeof j=="number").map(j=>j-1),m=N.length>0?Math.max(L.startRow,Math.min(...N)-2):L.startRow;Gs(T,L,[m,m+1,...N,...B],"Final semestral parsed rows")}),x.forEach(k=>{const L=g.componentWeights.filter(m=>m.sourceSheet===k.sheetName).map(m=>m.sourceRow).filter(m=>typeof m=="number").map(m=>m-1),N=g.signatures?.filter(m=>m.sourceSheet===k.sheetName).map(m=>m.sourceRow).filter(m=>typeof m=="number").map(m=>m-1)||[],B=L.length===0&&N.length===0?[k.startRow,k.startRow+1,k.startRow+2]:[];Gs(T,k,[...L,...N,...B],"Reference/helper parsed rows")});const C=T.getUnmappedBlocks(o.matrices);xs(s,{stage:"validating",message:"Validating completeness and structural integrity..."});const S=Om({detection:n,inputData:c,quarterSheets:f,finalSheets:v,mappedCellRegions:T.getMappedRegionCount(),unmappedCellRegions:C.length,totalSheets:o.sheetNames.length});xs(s,{stage:"normalizing",message:"Normalizing parsed workbook and creating entity mapping..."});const p=Em({workbook:o,detection:n,inputData:c,quarterSheets:f,finalSheets:v,references:g,validation:S,unclassifiedBlocks:C});p.validation.confidenceb.trim().toLowerCase().replace(/\s+/g," "),ie=b=>{if(typeof b=="number"&&Number.isFinite(b))return b;const I=Number(String(b??"").replace(/[^0-9.-]+/g,""));return Number.isFinite(I)?I:null},je=(b,I)=>{const E=Number.isFinite(b)?b:I;return Math.max(0,Math.min(100,E))},ve=b=>{const I=String(b??"");return/[",\n]/.test(I)?`"${I.replace(/"/g,'""')}"`:I},ke=(b,I)=>{const E=new Map,U=["quarterlyGrade","finalGrades","firstSemester","firstQuarter","secondQuarter","initialGrade"];b.mapping.gradeEntities.forEach(J=>{const _e=ee(J.fullName||"");if(!_e)return;const Ve=U.map(Ke=>ie(J[Ke])).filter(Ke=>Ke!==null);if(Ve.length===0)return;const Te=E.get(_e)||[];E.set(_e,Te.concat(Ve))});const Y=b.mapping.studentEntities||[];if(Y.length===0)return null;const re=(b.imported.schoolContext.semester||b.imported.schoolContext.schoolYear||"First Semester").trim(),te=(b.imported.schoolContext.subjectName||"Class Record Import").trim(),A=(t||s||"import").replace(/[^a-zA-Z0-9]+/g,"").toUpperCase().slice(0,12)||"IMPORT",me=[["name","lrn","email","engagementScore","avgQuizScore","attendance","assignmentCompletion","term","assessmentName"].join(",")];if(Y.forEach((J,_e)=>{const Ve=ee(J.fullName||""),Te=E.get(Ve)||[],Ke=Te.length>0?Te.reduce((we,ue)=>we+ue,0)/Te.length:75,Me=je(Ke,75),wt=je(Me+5,85),It=je(Me*.7+wt*.3,80),$=je(wt*.6+Me*.4,82),Z=J.learnerNo||_e+1,_=`IMP-${A}-${String(Z).padStart(4,"0")}`,se=J.fullName||`Learner ${_e+1}`;me.push([ve(se),ve(_),ve(""),ve(Number(It.toFixed(1))),ve(Number(Me.toFixed(1))),ve(Number(wt.toFixed(1))),ve(Number($.toFixed(1))),ve(re),ve(te)].join(","))}),me.length<=1)return null;const Ne=I.replace(/\.(xlsx|xls)$/i,"");return new File([me.join(` +`)],`${Ne}-normalized.csv`,{type:"text/csv"})},le=async b=>{m(!0),z(""),Q(null);let I=b;if(/\.(xlsx|xls)$/i.test(b.name))try{const E=await Hm(b,{confidenceThreshold:hr});p(E);const U=ke(E,b.name);U&&(I=U)}catch{p(null)}else p(null);try{const E=await Je.uploadClassRecords(I,{classSectionId:t,className:s,datasetIntent:"synthetic_student_records"}),U=E.students.length,re=((te,A,oe,me)=>({classSectionId:te.classSectionId||A||"imported_class",className:te.className||oe||"Imported Class",classMetadata:te.classMetadata||me}))(E,t,s,a);U>0&&i?.({students:E.students,classSectionId:re.classSectionId,className:re.className,classMetadata:re.classMetadata}),E.success?(pe.success(`Successfully imported ${U} student records.`),Q({datasetIntent:E.datasetIntent,summary:E.interpretationSummary,columns:E.columnInterpretations?.map(te=>({columnName:te.columnName,mappedField:te.mappedField,usagePolicy:te.usagePolicy,confidenceBand:te.confidenceBand,domainSignals:te.domainSignals}))||[]}),l?.()):pe.error("Import completed but no usable student rows were detected. Check required columns and retry.")}catch(E){pe.error(E instanceof Error?E.message:"Upload failed")}finally{m(!1)}},P=async b=>{w(!0);try{const I=await Je.uploadCourseMaterials(b,{classSectionId:t,className:s});if(I.success){const E=I.topics?.length??0;pe.success(`Course material imported (${E} topics extracted).`),l?.()}}catch(I){pe.error(I instanceof Error?I.message:"Course material upload failed")}finally{w(!1)}},[K,ae]=h.useState(r),[Le,Ae]=h.useState(!1);h.useEffect(()=>{ae(r),O(Object.fromEntries(r.map(b=>[fa(b),{grade:b.grade||"Grade 11",section:b.section||"Section A"}])))},[r]);const[Pe,O]=h.useState({}),X=async()=>{Ae(!0);try{for(const I of K){const E=Pe[fa(I)],U=E?.grade||I.grade,Y=E?.section||I.section;o&&(U!==I.grade||Y!==I.section)&&(await Ii(I.id,U,Y,o,new Date().getFullYear().toString(),n),await ki(I.id,U,Y));try{const re=await Je.predictRisk({engagementScore:I.engagementScore,avgQuizScore:I.avgScore,attendance:I.attendance,assignmentCompletion:I.assignmentCompletion});await nu(I.id,re.riskLevel,re.confidence)}catch(re){console.error("Failed to update risk:",re)}}const b=K.map(I=>{const E=Pe[fa(I)];if(!E)return I;const U=mt({metadata:I.classMetadata,classSectionId:I.classSectionId,className:[E.grade,E.section].filter(Boolean).join(" - "),grade:E.grade,section:E.section});return{...I,grade:E.grade,section:E.section,className:U.className||[E.grade,E.section].filter(Boolean).join(" - "),classSectionId:U.classSectionId||I.classSectionId,classMetadata:U}});ae(b),d?.(b),pe.success("Records saved and risk levels updated"),C("main")}catch{pe.error("Failed to save changes")}finally{Ae(!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:[T==="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(_t,{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:b=>{b.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:b=>{b.preventDefault(),k(!1);const I=b.dataTransfer.files[0];I&&le(I)},onClick:()=>F.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] ${y?"border-[#1FA7E1] bg-[#1FA7E1]/10":"border-[#1FA7E1]/30 hover:border-[#1FA7E1] bg-white hover:bg-[#1FA7E1]/5"}`,children:[e.jsx("input",{ref:F,type:"file",accept:".csv,.xlsx,.xls",onChange:b=>{const I=b.target.files?.[0];I&&le(I)},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:B?e.jsx("span",{className:"animate-spin text-[#1FA7E1]",children:"..."}):e.jsx(Nc,{className:"w-8 h-8 text-[#1FA7E1]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:B?"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:b=>{b.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:b=>{b.preventDefault(),N(!1);const I=b.dataTransfer.files[0];I&&P(I)},onClick:()=>W.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] ${L?"border-[#9956DE] bg-[#9956DE]/10":"border-[#9956DE]/30 hover:border-[#9956DE] bg-white hover:bg-[#9956DE]/5"}`,children:[e.jsx("input",{ref:W,type:"file",accept:".pdf,.docx,.txt",onChange:b=>{const I=b.target.files?.[0];I&&P(I)},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:j?e.jsx("span",{className:"animate-spin text-[#9956DE]",children:"..."}):e.jsx(Zt,{className:"w-8 h-8 text-[#9956DE]"})}),e.jsx("h3",{className:"text-[18px] font-bold text-[#1e293b] mb-2",children:j?"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(vc,{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(Go,{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(rs,{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(br,{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:()=>C("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(pc,{className:"w-4 h-4"})," Edit Class Records"]}),e.jsx("button",{onClick:()=>C("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:()=>C("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(lc,{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."})]})]})]})]}),T==="mapping-logs"&&e.jsxs("div",{className:"space-y-[16px]",children:[e.jsx("div",{className:"shrink-0 mb-2",children:e.jsxs("button",{onClick:()=>C("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(ya,{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:V?e.jsx("div",{className:"space-y-3",children:V.columns.map((b,I)=>e.jsxs("div",{className:"flex justify-between p-3 border rounded bg-slate-50",children:[e.jsx("span",{className:"font-semibold text-sm",children:b.columnName}),e.jsx("span",{className:"text-sm text-indigo-600",children:b.mappedField||"Unmapped"})]},I))}):e.jsx("p",{className:"text-slate-500 text-sm",children:"No recent mapping logs to display."})})]})]}),T==="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:()=>C("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(ya,{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:()=>C("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:X,disabled:Le,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:Le?"Saving...":e.jsxs(e.Fragment,{children:[e.jsx(Fo,{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(Us,{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((b,I)=>{const E=fa(b),U=b.name.split(" "),Y=U.length>1?`${U[0][0]}${U[U.length-1][0]}`.toUpperCase():b.name.substring(0,2).toUpperCase(),re=["bg-[#be185d]","bg-[#3b82f6]","bg-[#f43f5e]","bg-[#2563eb]","bg-[#059669]","bg-[#d946ef]"],te=re[I%re.length],A=(b.avgScore??0)>=75?"text-emerald-500":(b.avgScore??0)>=60?"text-orange-500":"text-rose-500";let oe="bg-slate-50 text-slate-600 border-slate-200";const me=(b.riskLevel||"").toLowerCase();return me==="low"?oe="bg-emerald-50 text-emerald-600 border-emerald-200":me==="high"?oe="bg-rose-50 text-rose-600 border-rose-200":me==="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 ${te} text-white flex items-center justify-center font-bold text-[12px] shrink-0`,children:Y}),e.jsx("span",{className:"font-semibold text-slate-800 text-[14px] truncate",children:b.name})]}),e.jsx("div",{className:"w-[100px] shrink-0 px-4 flex justify-center text-[13px] text-slate-500",children:b.lrn||"—"}),e.jsx("div",{className:"w-[140px] shrink-0 px-4 flex justify-center",children:e.jsx("input",{type:"text",value:Pe[E]?.grade||b.grade||"",onChange:Ne=>O(J=>({...J,[E]:{...J[E],grade:Ne.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:Pe[E]?.section||b.section||"",onChange:Ne=>O(J=>({...J,[E]:{...J[E],section:Ne.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:`${A} font-bold text-[14px]`,children:[b.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:b.riskLevel||"Unknown"})}),e.jsx("div",{className:"flex-1 min-w-[180px] px-4 flex justify-center text-[13px] text-slate-600 truncate",children:b.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(Ho,{className:"w-4 h-4 text-slate-400"})})})]},E)})})]})})]})]})]})})}function Qm(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=mt({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 Um(t,s){const a=t.riskLevel.toLowerCase(),r=t.lastActive?Oi(t.lastActive.toDate()):"Unknown",o=t.className||s||"Imported Class",n=Ot(o),i=t.grade||n.grade,l=t.section||n.section,c=mt({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||Ns(i)||void 0,classification:c.classification||Ls(c.gradeLevel||i)||void 0,strand:c.strand||As(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}}function Vm(t){const s=t.atRiskCount>=5?"high":t.atRiskCount>=2?"medium":"low",a=mt({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 Wm(t){const s=(t.riskLevel||"Low").toLowerCase(),a=mt({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||Ot(r).grade,gradeLevel:a.gradeLevel||Ns(a.grade||Ot(r).grade)||void 0,classification:a.classification||Ls(a.gradeLevel||a.grade)||void 0,strand:a.strand||As(r,a.section||t.section)||void 0,section:a.section||Ot(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 qm(t,s,a){return t<60||s<75||a<55?"high":t<75||s<85||a<70?"medium":"low"}function Ym(t,s,a,r){const o=mt({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),f=Number(t.assignmentCompletion||0),v=t.unknownFields?.weakestTopic||t.unknownFields?.topic||"Foundational Skills",x=qm(l,c,d),g=t.studentId||t.lrn||t.email||t.name||Math.random().toString(36).slice(2);return{id:`upload-${i}-${g}`,lrn:t.lrn,name:t.name,avatar:`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name)}&background=random`,avgScore:l,riskLevel:x,weakestTopic:v,classroomId:i,className:n,grade:o.grade||Ot(n).grade,gradeLevel:o.gradeLevel||Ns(o.grade||Ot(n).grade)||void 0,classification:o.classification||Ls(o.gradeLevel||o.grade)||void 0,strand:o.strand||As(n,o.section)||void 0,section:o.section||Ot(n).section,classSectionId:i,classMetadata:o,managerId:o.managerId||void 0,managerName:o.managerName||void 0,lastActive:"Recently imported",struggles:[v],engagementScore:d,attendance:c,assignmentCompletion:f}}function Oi(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 ot(t){return(t||"").trim().toLowerCase()}function ko(t){const s=ot(t.classSectionId);if(s)return`section:${s}`;const a=(t.id||"").trim().toLowerCase();return a?`id:${a}`:`name:${(t.name||"").trim().toLowerCase()}`}function Co(t,s){const a=new Map;return t.forEach(r=>{a.set(ko(r),r)}),s.forEach(r=>{const o=ko(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",f=mt({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:f.classSectionId||n.classSectionId||r.classSectionId,name:f.className||n.name||r.name,classMetadata:f,gradeLevel:f.gradeLevel||void 0,classification:f.classification||void 0,strand:f.strand||void 0,managerId:f.managerId||void 0,managerName:f.managerName||void 0,schedule:n.schedule||r.schedule,studentCount:l,atRiskCount:i,avgScore:c,riskLevel:d})}),Array.from(a.values())}function To(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=ot(t.classSectionId)||ot(t.classroomId),o=(t.id||"").trim().toLowerCase();return r&&o?`${r}|id:${o}`:`${r}|anonymous`}function fr(t){const s=ot(t.classSectionId)||ot(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 Io(t,s){const a=new Map;return t.forEach(r=>{a.set(To(r),r)}),s.forEach(r=>{const o=To(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=mt({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})}),Array.from(a.values())}const Kx=({onLogout:t,onOpenProfile:s,onOpenSettings:a})=>{const{currentUser:r,userProfile:o}=os(),[n,i]=h.useState("dashboard"),[l,c]=h.useState(!1),[d,f]=h.useState(!1),[v,x]=h.useState(!1),[g,T]=h.useState(!1),[C,S]=h.useState(!1),[p,y]=h.useState(null),[k,L]=h.useState(null),[N,B]=h.useState(!1),[m,j]=h.useState(!1),[w,R]=h.useState(!1),[z,V]=h.useState([]),[Q,F]=h.useState([]),[W,ee]=h.useState([]),[ie,je]=h.useState(""),[ve,ke]=h.useState(!0),[le,P]=h.useState(!0),[K,ae]=h.useState(!1),[Le,Ae]=h.useState(0),[Pe,O]=h.useState([]),[X,b]=h.useState(!1),I=h.useRef(new Map);h.useEffect(()=>{if(!r)return;const $=r.uid;let Z=!0,_;return(async()=>{ke(!0),P(!0);try{const we=await Ci($);let ue=we.map(Qm);const st=await lu($).catch(()=>[]),He=new Map;st.forEach(q=>{const xe=ot(q.classSectionId);xe&&He.set(xe,q)}),ue=ue.map(q=>{const xe=He.get(ot(q.classSectionId));if(!xe)return q;const at=mt({metadata:q.classMetadata,classSectionId:xe.classSectionId||q.classSectionId,className:xe.className||q.name,grade:xe.grade||q.classMetadata?.grade,gradeLevel:xe.gradeLevel||q.classMetadata?.gradeLevel,classification:xe.classification||q.classMetadata?.classification,strand:xe.strand||q.classMetadata?.strand,section:xe.section||q.classMetadata?.section,schoolYear:xe.schoolYear||q.classMetadata?.schoolYear,ownerTeacherId:xe.ownerTeacherId||q.classMetadata?.ownerTeacherId,ownerTeacherName:xe.ownerTeacherName||q.classMetadata?.ownerTeacherName,managerId:xe.managerId||q.classMetadata?.managerId,managerName:xe.managerName||q.classMetadata?.managerName});return{...q,name:at.className||q.name,classSectionId:at.classSectionId||q.classSectionId,classMetadata:at,gradeLevel:at.gradeLevel||q.gradeLevel,classification:at.classification||q.classification,strand:at.strand||q.strand,managerId:at.managerId||q.managerId,managerName:at.managerName||q.managerName}});const he=new Map,gt=new Map;we.forEach(q=>{const xe=mt({metadata:q.classMetadata,classSectionId:q.classSectionId,className:q.name,grade:q.grade,gradeLevel:q.gradeLevel,classification:q.classification,strand:q.strand,section:q.section,schoolYear:q.schoolYear,ownerTeacherId:q.ownerTeacherId||q.teacherId,ownerTeacherName:q.ownerTeacherName,adviserTeacherId:q.adviserTeacherId||q.teacherId,adviserTeacherName:q.adviserTeacherName,managerId:q.managerId,managerName:q.managerName});he.set(q.id,xe.className||q.name),gt.set(q.id,xe);const at=ot(q.classSectionId);if(at){const Re=He.get(at),dt=mt({metadata:xe,classSectionId:Re?.classSectionId||at,className:Re?.className||xe.className,grade:Re?.grade||xe.grade,gradeLevel:Re?.gradeLevel||xe.gradeLevel,classification:Re?.classification||xe.classification,strand:Re?.strand||xe.strand,section:Re?.section||xe.section,schoolYear:Re?.schoolYear||xe.schoolYear,ownerTeacherId:Re?.ownerTeacherId||xe.ownerTeacherId,ownerTeacherName:Re?.ownerTeacherName||xe.ownerTeacherName,managerId:Re?.managerId||xe.managerId,managerName:Re?.managerName||xe.managerName});he.set(at,dt.className||q.name),gt.set(at,dt)}});const Ds=(await zr($)).map(q=>{const xe=ot(q.classSectionId||q.classroomId),at=he.get(q.classroomId)||(xe?he.get(xe):void 0)||q.className||"Unknown",Re=Um(q,at);if(!xe)return Re;const dt=gt.get(xe);if(!dt)return Re;const ut=mt({metadata:dt,classSectionId:Re.classSectionId||dt.classSectionId,className:Re.className||dt.className,grade:Re.grade||dt.grade,gradeLevel:Re.gradeLevel||dt.gradeLevel,classification:Re.classification||dt.classification,strand:Re.strand||dt.strand,section:Re.section||dt.section,managerId:Re.managerId||dt.managerId,managerName:Re.managerName||dt.managerName});return{...Re,className:ut.className||Re.className,grade:ut.grade||Re.grade,gradeLevel:ut.gradeLevel||Re.gradeLevel,classification:ut.classification||Re.classification,strand:ut.strand||Re.strand,section:ut.section||Re.section,classSectionId:ut.classSectionId||Re.classSectionId,classMetadata:ut,managerId:ut.managerId||Re.managerId,managerName:ut.managerName||Re.managerName}});if(!Z)return;V(q=>ue.length===0&&q.length>0?q:ue),F(q=>Ds.length===0&&q.length>0?q:Ds),Je.getImportedClassOverview({limit:3e3,forceRefresh:Le>0}).then(q=>{Z&&(q.warnings.length>0&&console.warn("Imported class overview warnings:",q.warnings.join(" ")),V(xe=>Co(xe,q.classrooms.map(Vm))),F(xe=>Io(xe,q.students.map(Wm))))}).catch(q=>{console.warn("Imported class overview merge unavailable:",q)}).finally(()=>{Z&&P(!1)});const $s=we.map(q=>q.id);$s.length>0&&(_=du($s,q=>{Z&&ee(q.map(xe=>({id:xe.id,student:xe.studentName,action:xe.action,topic:xe.topic,time:Oi(xe.timestamp.toDate()),type:xe.type})))}))}catch(we){console.error("Failed to load teacher data:",we),pe.error("Failed to load dashboard data")}finally{ke(!1)}})(),()=>{Z=!1,_&&_()}},[r,Le]),h.useEffect(()=>{if(!r)return;let $=!0;return cu("",80).then(Z=>{$&&O(Z)}).catch(Z=>{console.warn("Failed to load teacher directory options:",Z)}),()=>{$=!1}},[r]),h.useEffect(()=>{if(le||Q.length===0)return;const $=new AbortController;let Z=!1;return(async()=>{ae(!0);try{const se=Q.map(ue=>({name:ue.name,engagementScore:ue.engagementScore,avgQuizScore:ue.avgScore,attendance:ue.attendance,riskLevel:ue.riskLevel})),we=await Je.getDailyInsight({students:se},{signal:$.signal});Z||je(we.insight)}catch{if($.signal.aborted)return;Z||je(`${Q.filter(we=>we.riskLevel==="high").length} students are at high risk of falling behind. Review their progress in the analytics view.`)}finally{Z||ae(!1)}})(),()=>{Z=!0,$.abort()}},[Q,le]);const E=z.reduce(($,Z)=>$+Z.studentCount,0),U=z.reduce(($,Z)=>$+Z.atRiskCount,0),Y=z.length>0?Math.round(z.reduce(($,Z)=>$+Z.avgScore,0)/z.length):0,re=[{name:"High Risk",value:Q.filter($=>$.riskLevel==="high").length,color:"#FF8B8B"},{name:"Medium Risk",value:Q.filter($=>$.riskLevel==="medium").length,color:"#F08386"},{name:"Low Risk",value:Q.filter($=>$.riskLevel==="low").length,color:"#75D06A"}],te={};Q.forEach($=>{$.weakestTopic&&$.weakestTopic!=="N/A"&&(te[$.weakestTopic]||(te[$.weakestTopic]={total:0,sum:0}),te[$.weakestTopic].total+=1,te[$.weakestTopic].sum+=$.avgScore)});const A=Object.entries(te).map(([$,Z])=>({topic:$,score:Math.round(Z.sum/Z.total)})).sort(($,Z)=>$.score-Z.score).slice(0,6),oe=$=>{y($),i("analytics")},me=$=>{L($),i("intervention")},Ne=()=>{L(null),i("analytics")},J=()=>{y(null),L(null),i("dashboard")},_e=async($,Z)=>{if(!r){pe.error("Unable to assign manager: teacher context is missing.");return}const _=Ot($.classMetadata?.className||$.name),se=mt({metadata:$.classMetadata,classSectionId:$.classSectionId,className:$.name,grade:$.classMetadata?.grade||_.grade,gradeLevel:$.classMetadata?.gradeLevel,classification:$.classMetadata?.classification,strand:$.classMetadata?.strand,section:$.classMetadata?.section||_.section,schoolYear:$.classMetadata?.schoolYear||String(new Date().getFullYear()),ownerTeacherId:$.classMetadata?.ownerTeacherId||r.uid,ownerTeacherName:$.classMetadata?.ownerTeacherName||Te,adviserTeacherId:$.classMetadata?.adviserTeacherId||r.uid,adviserTeacherName:$.classMetadata?.adviserTeacherName||Te,managerId:Z.uid,managerName:Z.name}),we=se.classSectionId||zt(se.grade||_.grade,se.section||_.section);if(!we){pe.error("Unable to assign manager: missing class section ID.");return}b(!0);try{await iu({classSectionId:we,className:se.className||$.name,grade:se.grade||_.grade,gradeLevel:se.gradeLevel||Ns(se.grade||_.grade)||se.grade||_.grade,classification:se.classification||Ls(se.gradeLevel||se.grade)||void 0,strand:se.strand||As(se.className,se.section)||void 0,section:se.section||_.section,schoolYear:se.schoolYear||String(new Date().getFullYear()),ownerTeacherId:se.ownerTeacherId||r.uid,ownerTeacherName:se.ownerTeacherName||Te,managerId:Z.uid,managerName:Z.name});const ue=mt({metadata:se,classSectionId:we,managerId:Z.uid,managerName:Z.name}),st=ot(we);V(He=>He.map(he=>ot(he.classSectionId)!==st?he:{...he,name:ue.className||he.name,classSectionId:ue.classSectionId||he.classSectionId,classMetadata:ue,gradeLevel:ue.gradeLevel||he.gradeLevel,classification:ue.classification||he.classification,strand:ue.strand||he.strand,managerId:Z.uid,managerName:Z.name})),F(He=>He.map(he=>{if(ot(he.classSectionId||he.classroomId)!==st)return he;const Qt=mt({metadata:he.classMetadata,classSectionId:ue.classSectionId||he.classSectionId,className:he.className||ue.className,grade:he.grade||ue.grade,gradeLevel:he.gradeLevel||ue.gradeLevel,classification:he.classification||ue.classification,strand:he.strand||ue.strand,section:he.section||ue.section,managerId:Z.uid,managerName:Z.name});return{...he,classMetadata:Qt,gradeLevel:Qt.gradeLevel||he.gradeLevel,classification:Qt.classification||he.classification,strand:Qt.strand||he.strand,managerId:Z.uid,managerName:Z.name}})),y(He=>!He||ot(He.classSectionId)!==st?He:{...He,classMetadata:ue,managerId:Z.uid,managerName:Z.name,gradeLevel:ue.gradeLevel||He.gradeLevel,classification:ue.classification||He.classification,strand:ue.strand||He.strand}),pe.success(`Assigned ${Z.name} as section manager.`)}catch(ue){console.error("Failed to assign class manager:",ue),pe.error(ue instanceof Error?ue.message:"Failed to assign class manager")}finally{b(!1)}};h.useEffect(()=>{const $=()=>{const Z=window.innerWidth<1024;T(Z),Z?c(!1):x(!1)};return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},[]),h.useEffect(()=>{g&&x(!1)},[n,g]);const Ve=$=>{i($),y(null),L(null)},Te=o?.name||"Teacher",Ke=h.useMemo(()=>{if(!p)return;if(p.classMetadata?.classSectionId)return p.classMetadata.classSectionId||void 0;if(p.classSectionId)return p.classSectionId;const $=Ot(p.classMetadata?.className||p.name);return zt($.grade,$.section)||void 0},[p]),Me=h.useMemo(()=>p||null,[p]),wt=h.useMemo(()=>{if(!Me)return;const $=z.findIndex(Z=>Z.id===Me.id);return Ra[Math.max(0,$)%Ra.length]},[Me,z]),It=h.useMemo(()=>{if(!Me)return Q;const $=(Me.id||"").trim().toLowerCase(),Z=ot(Me.classSectionId),_=(Me.name||"").trim().toLowerCase();return Q.filter(se=>{const we=ot(se.classroomId),ue=ot(se.classSectionId),st=(se.className||"").trim().toLowerCase();return Z&&(ue===Z||we===Z)||$&&(we===$||ue===$)||_&&st===_})},[Me,Q]);return ve?e.jsxs("div",{className:"flex h-screen w-full bg-background p-6",children:[e.jsx("div",{className:"hidden lg:flex w-[280px] shrink-0 rounded-3xl border border-border bg-card p-5",children:e.jsxs("div",{className:"w-full space-y-4",children:[e.jsx(Ce,{className:"h-12 w-40"}),e.jsx(Ce,{className:"h-10 w-full"}),e.jsx(Ce,{className:"h-10 w-full"}),e.jsx(Ce,{className:"h-10 w-full"}),e.jsx(Ce,{className:"h-10 w-full"})]})}),e.jsxs("div",{className:"flex-1 space-y-4 lg:pl-6",children:[e.jsx(Ce,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ce,{className:"h-28 w-full rounded-2xl"}),e.jsx(Ce,{className:"h-28 w-full rounded-2xl"}),e.jsx(Ce,{className:"h-28 w-full rounded-2xl"})]}),e.jsx(Ce,{className:"h-[420px] w-full rounded-2xl"})]})]}):e.jsxs("div",{className:"relative flex h-screen w-full bg-background overflow-hidden",children:[g&&v&&e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-30 bg-slate-900/40 backdrop-blur-[1px]",onClick:()=>x(!1)}),e.jsxs(Ge.aside,{initial:!1,animate:{width:g?280:l&&!d?80:280,x:g?v?0:-300:0},transition:{type:"spring",stiffness:360,damping:34},onMouseEnter:()=>!g&&l&&f(!0),onMouseLeave:()=>f(!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"})})]}),!g&&(!l||d)&&e.jsx(Ge.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(ts,{size:20}):e.jsx(as,{size:20})}),g&&e.jsx("button",{onClick:()=>x(!1),className:"p-2 hover:bg-[#dde3eb] rounded-lg transition-colors text-[#5a6578]","aria-label":"Close navigation",children:e.jsx(fs,{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(Jt,{icon:dl,label:"Dashboard",active:n==="dashboard",collapsed:l&&!d,onClick:J,forceExpanded:g}),e.jsx(Jt,{icon:gs,label:"Class Analytics",active:n==="analytics"||n==="intervention",collapsed:l&&!d,onClick:()=>Ve("analytics"),forceExpanded:g})]})]}),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(Jt,{icon:Yt,label:"Topic Mastery",active:n==="topic_mastery",collapsed:l&&!d,onClick:()=>Ve("topic_mastery"),forceExpanded:g}),e.jsx(Jt,{icon:Ft,label:"Competency",active:n==="competency",collapsed:l&&!d,onClick:()=>Ve("competency"),forceExpanded:g})]})]}),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(Jt,{icon:il,label:"Data Import",active:n==="import",collapsed:l&&!d,onClick:()=>i("import"),forceExpanded:g}),e.jsx(Jt,{icon:Bo,label:"AI Quiz Maker",active:n==="quiz_maker",collapsed:l&&!d,onClick:()=>i("quiz_maker"),forceExpanded:g}),e.jsx(Jt,{icon:Bt,label:"Question Bank",active:n==="question_bank",collapsed:l&&!d,onClick:()=>i("question_bank"),forceExpanded:g}),e.jsx(Jt,{icon:gr,label:"Calendar",active:n==="calendar",collapsed:l&&!d,onClick:()=>i("calendar"),forceExpanded:g})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t border-[#dde3eb] pt-4",children:[e.jsxs(Ge.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(ul,{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(ml,{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-col sm:flex-row sm:items-start justify-between gap-4 mb-0",children:[e.jsxs("div",{className:"flex-1 flex items-start gap-3",children:[g&&e.jsx("button",{onClick:()=>x(!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(wl,{size:18})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[26px] font-bold text-[#1e293b] tracking-tight leading-tight",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, ${Te}`,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","aria-live":"polite",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(Ft,{size:13,className:"text-[#9956DE]"}),e.jsx("span",{className:"text-xs font-display font-semibold text-[#9956DE]",children:le?e.jsx(Ce,{className:"h-3 w-14 inline-block align-middle bg-[#9956DE]/30"}):`${E} 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(Rs,{size:13,className:"text-[#F08386]"}),e.jsx("span",{className:"text-xs font-display font-semibold text-[#C65E63]",children:le?e.jsx(Ce,{className:"h-3 w-14 inline-block align-middle bg-[#F08386]/30"}):`${U} 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(aa,{size:13,className:"text-[#75D06A]"}),e.jsx("span",{className:"text-xs font-display font-semibold text-[#4D9F46]",children:le?e.jsx(Ce,{className:"h-3 w-14 inline-block align-middle bg-[#75D06A]/30"}):`${Y}% avg`})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 self-end sm:self-auto",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:()=>{j(!0),B(!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(rs,{size:18}),!N&&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"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>R(!w),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(Ca,{size:18}),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(ll,{isOpen:w,onClose:()=>R(!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(Te)}&background=e0e7ff&color=4f46e5`,alt:"Profile",className:"w-full h-full object-cover"})}),e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:Te})]})]})]})}),e.jsx("main",{className:`flex-1 flex flex-col ${n==="intervention"||n==="analytics"?"overflow-hidden":"overflow-y-auto"}`,children:e.jsxs(qt,{mode:"wait",children:[n==="dashboard"&&e.jsx(Km,{classes:z,liveActivity:W,onViewClass:oe,onViewAllClasses:()=>i("analytics"),onViewActivityStudent:$=>{const Z=Q.find(_=>_.name===$);Z&&me(Z)},dailyInsight:ie,insightLoading:K,isInsightDismissed:N,onDismissInsight:()=>B(!0),onOpenInsightModal:()=>{j(!0),B(!0)},totalStudents:E,totalAtRisk:U,avgPerformance:Y,statsLoading:le}),n==="analytics"&&Me&&e.jsx(Jm,{selectedClass:Me,students:It,riskDistribution:re,topicPerformance:A,onViewStudent:me,onBack:()=>y(null),teacherOptions:Pe,managerUpdating:X,onAssignManager:$=>_e(Me,$),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,classColor:wt,insightDismissed:N,onOpenInsightModal:()=>j(!0)}),n==="analytics"&&!Me&&z.length>0&&e.jsx(ho,{classes:z,students:Q.map($=>({classroomId:$.classroomId,attendance:$.attendance,weakestTopic:$.weakestTopic})),onSelectClass:oe,onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:N,onOpenInsightModal:()=>j(!0)}),n==="analytics"&&!Me&&z.length===0&&e.jsx(Eo,{icon:gs,title:"Class Analytics",description:"No classes available yet. Import class records to unlock analytics views."}),n==="intervention"&&k&&e.jsx(Zm,{student:k,teacherId:r?.uid||"",teacherName:Te,initialCache:I.current.get(k.id),onCacheUpdate:($,Z)=>I.current.set($,Z),onStudentUpdated:$=>{const Z=k?fr(k):null;L($),F(_=>_.map(se=>{const we=fr(se),ue=Z?we===Z:!1,st=se.id===$.id&&ot(se.classSectionId)===ot($.classSectionId);return ue||st?$:se}))},onBack:Ne,onNavigateToQuizMaker:$=>{i("quiz_maker"),$&&sessionStorage.setItem("quizMakerInitialTab",$)}}),n==="topic_mastery"&&e.jsx(Cu,{classSectionId:Ke,onOpenNotifications:()=>i("notifications"),onOpenProfile:s}),n==="competency"&&Me&&e.jsx(Ru,{classSectionId:Ke,className:p?.name,fallbackStudents:Q,onBack:()=>y(null),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:N,onOpenInsightModal:()=>j(!0)}),n==="competency"&&!Me&&z.length>0&&e.jsx(ho,{classes:z,students:Q.map($=>({classroomId:$.classroomId,attendance:$.attendance,weakestTopic:$.weakestTopic})),onSelectClass:$=>y($),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,insightDismissed:N,onOpenInsightModal:()=>j(!0),viewType:"competency"}),n==="competency"&&!Me&&z.length===0&&e.jsx(Eo,{icon:Ft,title:"Student Competency",description:"No classes available yet. Import class records to view competency breakdowns."}),n==="import"&&e.jsx(Gm,{classSectionId:Ke,className:p?.name,classMetadata:p?.classMetadata,students:Q,teacherId:r?.uid||"",teacherName:Te,onStudentsUpdated:$=>F($),onBackToClasses:()=>i("dashboard"),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{j(!0),B(!0)},userPhoto:o?.photo,onImportedClassRecords:$=>{const Z=$.students.map(he=>Ym(he,$.classSectionId,$.className,$.classMetadata)),_=mt({metadata:$.classMetadata,classSectionId:$.classSectionId,className:$.className}),se=_.classSectionId||"imported_class",we=_.className||"Imported Class",ue=Z.filter(he=>he.riskLevel==="high").length,st=Z.length>0?Math.round(Z.reduce((he,gt)=>he+gt.avgScore,0)/Z.length):0,He={id:se,name:we,classSectionId:se,classMetadata:{..._,classSectionId:se,className:we},schedule:"Mon-Fri",studentCount:Z.length,avgScore:st,atRiskCount:ue,riskLevel:ue>=5?"high":ue>=2?"medium":"low"};F(he=>Io(he,Z)),V(he=>Co(he,[He]))},onDataChanged:()=>Ae($=>$+1)}),n==="notifications"&&e.jsx(Mu,{liveActivity:W,atRiskStudents:Q.filter($=>$.riskLevel==="high").map($=>({name:$.name,riskLevel:$.riskLevel,weakestTopic:$.weakestTopic})),onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{j(!0),B(!0)},userPhoto:o?.photo,teacherName:Te}),n==="calendar"&&e.jsx(Vu,{classes:z,teacherId:r?.uid}),n==="quiz_maker"&&e.jsx(Ei,{onBack:()=>{const $=sessionStorage.getItem("quizMakerReturnTo");sessionStorage.removeItem("quizMakerReturnTo"),sessionStorage.removeItem("quizMakerInitialTab"),i($==="intervention"?"intervention":"dashboard")},onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{j(!0),B(!0)},userPhoto:o?.photo,teacherName:Te}),n==="question_bank"&&e.jsx(Su,{onOpenNotifications:()=>i("notifications"),onOpenProfile:s,onOpenInsightModal:()=>{j(!0),B(!0)},userPhoto:o?.photo,teacherName:Te})]})})]}),n==="dashboard"&&e.jsx(ex,{onViewCalendar:()=>i("calendar"),onOpenProfile:s,userProfile:o,teacherName:Te,liveActivity:W})]}),e.jsx(qt,{children:m&&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(Ge.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(rs,{size:16})}),e.jsx("h3",{className:"font-semibold text-slate-800",children:"Detailed AI Insight"})]}),e.jsx("button",{onClick:()=>{j(!1)},"aria-label":"Close AI insight",className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:e.jsx(fs,{size:18})})]}),e.jsx("div",{className:"p-6",children:e.jsx(va,{name:"teacher-dashboard-ai-insight-modal",loading:K,fixture:e.jsx(Ce,{className:"h-32 w-full bg-slate-200"}),fallback:e.jsx(Ce,{className:"h-32 w-full bg-slate-200"}),children:e.jsx("div",{className:"text-sm text-slate-600 leading-relaxed",children:e.jsx(Gl,{children:ie?.replace(/[*_]*\s*\(?Word\s*count\s*:\s*[*_]*\s*\d+\)?\s*[*_]*/gi,"").trim()||`I've noticed **${U} students (${E>0?Math.round(U/E*100):0}%)** are currently showing a high risk of falling behind in recent topics. Shall I draft an intervention plan?`})})})}),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(ol,{isOpen:C,onClose:()=>S(!1),onConfirm:t,title:"Logout",message:"Are you sure you want to logout?",confirmText:"Logout",cancelText:"Cancel"})]})},Jt=({icon:t,label:s,active:a,collapsed:r,forceExpanded:o=!1,onClick:n})=>e.jsxs(Ge.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-[#6d28d9]":"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(Ge.div,{layoutId:"sidebar-active-indicator",className:"ml-auto w-2 h-2 rounded-full bg-[#9956DE]",transition:{type:"spring",duration:.4}})]}),Eo=({icon:t,title:s,description:a})=>e.jsx(Ge.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})]})}),Km=({classes:t,liveActivity:s,onViewClass:a,onViewAllClasses:r,onViewActivityStudent:o,dailyInsight:n,insightLoading:i,isInsightDismissed:l,onDismissInsight:c,onOpenInsightModal:d,totalStudents:f,totalAtRisk:v,avgPerformance:x,statsLoading:g=!1})=>{const T=f>0?Math.round(v/f*100):0,C=f>0?Math.round((f-v)/f*100):0;return e.jsxs(Ge.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-6 space-y-4",children:[!l&&e.jsxs("div",{onClick:d,className:"bg-white/80 backdrop-blur-[12px] rounded-[18px] border border-white p-[18px_20px] flex items-center 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 items-center gap-2 mb-1",children:[e.jsx(rs,{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:"I've noticed some students are currently showing a high risk of falling behind. Click to view detailed analysis..."})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",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-3",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#047857] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px]",children:"Total students"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Ft,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight","aria-live":"polite",children:g?e.jsx(Ce,{className:"h-7 w-12 bg-white/30"}):f}),e.jsx("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px]",children:e.jsxs("span",{children:[t.length," ",t.length===1?"class":"classes"]})})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#0369a1] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px]",children:"Class average"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Yt,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight","aria-live":"polite",children:g?e.jsx(Ce,{className:"h-7 w-16 bg-white/30"}):`${x}%`}),e.jsx("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px]",children:e.jsxs("span",{children:["Across ",f," ",f===1?"student":"students"]})})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#7e22ce] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px]",children:"Engagement rate"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Ro,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight","aria-live":"polite",children:g?e.jsx(Ce,{className:"h-7 w-16 bg-white/30"}):`${C}%`}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px]",children:[e.jsx("span",{children:"Active participants"}),e.jsx("span",{className:"bg-black/15 px-[7px] py-[2px] rounded font-semibold",children:Math.round(C/100*f)})]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#c2410c] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px]",children:"At risk"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Ys,{size:15})})]}),e.jsx("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight","aria-live":"polite",children:g?e.jsx(Ce,{className:"h-7 w-12 bg-white/30"}):v}),e.jsxs("div",{className:"relative z-10 border-t border-white/30 pt-2 flex justify-between items-center text-[10px]",children:[e.jsx("span",{children:"Requires attention"}),e.jsxs("span",{className:"bg-black/15 px-[7px] py-[2px] rounded font-semibold",children:[T,"%"]})]})]})]}),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.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"No classes imported yet."}),t.map((S,p)=>{const y=[{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]"}],k=y[p%y.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 ${k.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] ${k.stripe}`}),e.jsx("div",{className:`w-[38px] h-[38px] rounded-[10px] flex items-center justify-center flex-shrink-0 text-[17px] ${k.bg} ${k.text} group-hover:scale-110 transition-transform duration-300`,children:e.jsx(Bt,{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-[#475569] mt-[1px]",children:S.classification||"High School"})]}),e.jsx("div",{className:"text-[12px] text-[#64748b] min-w-[65px]",children:S.schedule||"Mon-Fri"}),e.jsxs("div",{className:"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(nr,{size:16,className:"text-[#cbd5e1] ml-auto hover:text-[#64748b]"})]},S.id)})]})]})]})},Xm=ce.memo(({student:t,onViewStudent:s})=>{const r=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"};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] ${r.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 ${r.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 ${r.bgAvatar}`,children:t.name.substring(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold text-[#1e293b] leading-tight truncate",children:t.name}),e.jsxs("p",{className:"text-[10px] text-[#64748b] flex items-center gap-[4px] mt-0.5 truncate",children:[e.jsx(_s,{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 ${r.badge}`,children:[t.avgScore,"%"]})]}),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 ${r.progress}`,style:{width:`${t.avgScore}%`}})})]})}),Jm=({selectedClass:t,students:s,riskDistribution:a,topicPerformance:r,onViewStudent:o,onBack:n,teacherOptions:i,managerUpdating:l,onAssignManager:c,onOpenNotifications:d,onOpenProfile:f,classColor:v,insightDismissed:x,onOpenInsightModal:g})=>{const{currentUser:T,userProfile:C}=os(),[S,p]=h.useState(""),[y,k]=h.useState(""),[L,N]=h.useState("All");h.useEffect(()=>{k(t.classMetadata?.managerId||t.managerId||"")},[t]);const B=h.useMemo(()=>{const F=S.trim().toLowerCase();let W=s;return F&&(W=W.filter(ee=>ee.name.toLowerCase().includes(F)||(ee.lrn||"").toLowerCase().includes(F)||(ee.weakestTopic||"").toLowerCase().includes(F))),L==="Good"?W=W.filter(ee=>ee.avgScore>=85&&ee.riskLevel!=="high"):L==="Risk"&&(W=W.filter(ee=>ee.riskLevel==="high"||ee.avgScore<75)),W},[S,s,L]),m=h.useMemo(()=>{if(s.length===0)return 0;const F=s.reduce((W,ee)=>W+(ee.assignmentCompletion||0),0);return Math.round(F/s.length)},[s]),j=h.useMemo(()=>{if(s.length===0)return 0;const F=s.reduce((ee,ie)=>ee+(ie.attendance||0),0)/s.length,W=s.reduce((ee,ie)=>ee+(ie.engagementScore||0),0)/s.length;return Math.round(F*.6+W*.4)},[s]),w=h.useMemo(()=>[...s].sort((F,W)=>W.avgScore-F.avgScore).slice(0,5),[s]),R=h.useMemo(()=>[...s].filter(F=>F.riskLevel==="high"||F.avgScore<70||F.assignmentCompletion<65),[s]),z=h.useMemo(()=>i.find(F=>F.uid===y),[i,y]),V=()=>{if(!z){pe.error("Select a teacher manager first.");return}c(z)},Q=[t.classMetadata?.gradeLevel||t.gradeLevel,t.classMetadata?.classification||t.classification,t.classMetadata?.strand||t.strand].filter(Boolean);return e.jsxs(Ge.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"p-[24px] xl:p-[32px] space-y-[24px] h-full overflow-y-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("button",{onClick:n,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(as,{className:"w-4 h-4"}),"Back to Classes"]})}),e.jsxs("header",{style:{backgroundColor:v?.hex||"#6366f1"},className:"rounded-[24px] 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-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-[28px] font-bold mb-3 tracking-tight",children:t.name}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:Q.map((F,W)=>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:F},F))}),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 items-center gap-3",children:[e.jsxs("div",{className:"relative w-full md:w-[320px]",children:[e.jsxs("select",{value:y||"",onChange:F=>k(F.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"}),i.map(F=>e.jsxs("option",{value:F.uid,children:[F.name," (",F.email,")"]},F.uid))]}),e.jsx(_t,{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:V,disabled:!y||l,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:v?.hex||"#6366f1"},children:l?"Updating...":"Assign"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-[18px] w-full",children:[e.jsxs("div",{className:"group relative overflow-hidden bg-[#0369a1] shadow-[0_4px_16px_rgba(14,165,233,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[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(Yt,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[t.avgScore,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#047857] shadow-[0_4px_16px_rgba(16,185,129,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Completion Rate"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(vr,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[m,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#7e22ce] shadow-[0_4px_16px_rgba(168,85,247,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[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(Ft,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[j,"%"]})]}),e.jsxs("div",{className:"group relative overflow-hidden bg-[#c2410c] shadow-[0_4px_16px_rgba(249,115,22,0.13)] rounded-2xl p-[15px] text-white flex flex-col 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-[11px] opacity-90 uppercase tracking-wider font-semibold",children:"Needs Attention"}),e.jsx("div",{className:"bg-white/20 p-1.5 rounded-lg flex",children:e.jsx(Rs,{size:15})})]}),e.jsxs("div",{className:"relative z-10 text-[26px] font-semibold tracking-tight",children:[R.length," ",e.jsx("span",{className:"text-[13px] opacity-90 font-medium",children:"students"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 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.jsx("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:["(",B.length,")"]})]})}),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(ra,{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:S,onChange:F=>p(F.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:()=>N("All"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${L==="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:()=>N("Good"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${L==="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:()=>N("Risk"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-[14px] whitespace-nowrap transition-all hover:scale-[1.02] ${L==="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(Dd,{style:{height:"100%"},data:B,className:"no-scrollbar",itemContent:(F,W)=>e.jsx("div",{className:"py-[6px] px-[8px]",children:e.jsx(Xm,{student:W,onViewStudent:o})}),computeItemKey:(F,W)=>fr(W)})})]}),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(nr,{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(wn,{width:"100%",height:"100%",children:e.jsxs(Nn,{data:a,children:[e.jsx(jn,{strokeDasharray:"4 4",stroke:"#f1f5f9",vertical:!1}),e.jsx(yn,{dataKey:"name",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#475569",fontSize:11,fontWeight:600},dy:10}),e.jsx(Sn,{axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600}}),e.jsx(kn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Cn,{dataKey:"value",radius:[6,6,0,0],barSize:80,children:a.map((F,W)=>{const ee={"High Risk":"#f43f5e","Medium Risk":"#f59e0b","Low Risk":"#10b981"};return e.jsx(Tn,{fill:ee[F.name]||F.color},`cell-${W}`)})})]})})})]}),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(nr,{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(wn,{width:"100%",height:"100%",children:e.jsxs(Nn,{data:r,layout:"vertical",margin:{top:0,right:10,left:40,bottom:0},children:[e.jsx(jn,{strokeDasharray:"4 4",stroke:"#f1f5f9",horizontal:!1}),e.jsx(yn,{type:"number",domain:[0,100],axisLine:!1,tickLine:!1,tick:{fill:"#64748b",fontSize:10,fontWeight:600},tickFormatter:F=>`${F}%`}),e.jsx(Sn,{dataKey:"topic",type:"category",axisLine:{stroke:"#cbd5e1",strokeWidth:2},tickLine:!1,tick:{fill:"#1e293b",fontSize:11,fontWeight:600},dx:-10}),e.jsx(kn,{cursor:{fill:"#f8fafc"},contentStyle:{borderRadius:"12px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),e.jsx(Cn,{dataKey:"score",radius:[0,6,6,0],barSize:28,children:r.map((F,W)=>{const ee=["#6366f1","#a855f7","#10b981","#f59e0b","#ec4899"];return e.jsx(Tn,{fill:ee[W%ee.length]},`cell-${W}`)})})]})})})]})]}),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(aa,{className:"w-4 h-4 text-emerald-500"}),"Top Performers"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[w.map(F=>e.jsxs("div",{onClick:()=>o(F),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:F.name}),e.jsxs("span",{className:"text-[13px] font-semibold text-emerald-600",children:[F.avgScore,"%"]})]},`top-${F.id}`)),w.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(Rs,{className:"w-4 h-4 text-rose-500"}),"Needs Attention"]})}),e.jsxs("div",{className:"space-y-[8px]",children:[R.slice(0,4).map(F=>{const W=F.riskLevel==="high",ee=W?"bg-rose-50/40 border-rose-50":"bg-amber-50/40 border-amber-50";return e.jsxs("div",{onClick:()=>o(F),className:`flex justify-between items-center p-3 rounded-[14px] border group hover:scale-[1.02] transition-transform cursor-pointer ${ee}`,children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#1e293b]",children:F.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] ${W?"text-rose-600":"text-amber-600"}`,children:W?"HIGH RISK":"MEDIUM RISK"})]},`attn-${F.id}`)}),R.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No urgent students."})]})]})]})]})]})]})},Zm=({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",f=h.useMemo(()=>Je.getImportGroundedRolloutFlags(),[]),[v,x]=h.useState(i?.learningPath||""),[g,T]=h.useState(!0),[C,S]=h.useState(i?.gradeDraft||t.grade||"Grade 11"),[p,y]=h.useState(i?.sectionDraft||t.section||"Section A"),[k,L]=h.useState(!1),[N,B]=h.useState(i?.lessonPlan??null),[m,j]=h.useState([]),[w,R]=h.useState(""),[z,V]=h.useState(!1),[Q,F]=h.useState(""),[W,ee]=h.useState("all"),[ie,je]=h.useState("all"),[ve,ke]=h.useState(!1),[le,P]=h.useState(!1),[K,ae]=h.useState(null),[Le,Ae]=h.useState(!1),[Pe,O]=h.useState(!1),[X,b]=h.useState(0),[I,E]=h.useState(!1),[U,Y]=h.useState("choose"),[re,te]=h.useState([]),[A,oe]=h.useState(!1),[me,Ne]=h.useState(!1),[J,_e]=h.useState(!1),[Ve,Te]=h.useState(!1);h.useEffect(()=>{S(t.grade||"Grade 11"),y(t.section||"Section A")},[t.grade,t.section]),h.useEffect(()=>{const _=se=>{if(se.key==="Escape"){if(Ve){Te(!1);return}if(me){J?Te(!0):Ne(!1);return}I&&E(!1)}};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[me,I,J,Ve]),h.useEffect(()=>{if(me){const _=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_}}},[me]),h.useEffect(()=>{l?.(t.id,{lessonPlan:N,learningPath:v,gradeDraft:C,sectionDraft:p})},[N,v,C,p,t.id,l]),h.useEffect(()=>{(async()=>{T(!0);try{let se="";try{se=await jl(t.struggles.length>0?t.struggles:[t.weakestTopic],"general_math"),R(se)}catch{R("")}const we=await Je.getLearningPath({weaknesses:t.struggles.length>0?t.struggles:[t.weakestTopic],gradeLevel:"High School",subject:"general_math"}),ue=se?`${we.learningPath} + +${se}`:we.learningPath;x(ue)}catch{x("Unable to generate learning path. Please try again later."),R("")}finally{T(!1)}})()},[t]);const Ke=h.useCallback(async()=>{V(!0),F("");try{const _=t.classSectionId||zt(C||"Grade 11",p||"Section A"),se=t.struggles.length>0?t.struggles[0]:t.weakestTopic,we=await xu({gradeLevel:C||t.grade||"Grade 11",subject:"general_math",quarter:1,moduleUnit:[C,p].filter(Boolean).join(" - ")||t.className,lessonTitle:`Grounded Lesson: ${se}`,learningCompetency:se,learnerLevel:t.avgScore<60?"support":t.avgScore<80?"developing":"advanced",classSectionId:_,className:[C,p].filter(Boolean).join(" - ")||t.className,focusTopics:t.struggles.length>0?t.struggles:[t.weakestTopic],topicCount:5,preferImportedTopics:f.lessonEnabled,allowReviewSources:ve,allowUnverifiedLesson:le},!0);B(we),j(we.curriculumSources||[]),ae(null),Je.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:_,className:[C,p].filter(Boolean).join(" - ")||t.className,metadata:{usedImportedTopics:we.usedImportedTopics,importedTopicCount:we.importedTopicCount,blockCount:we.blocks.length,publishReady:we.publishReady,sourceLegitimacyStatus:we.sourceLegitimacy.status,selfValidationPassed:we.selfValidation.passed,importGroundingEnabled:f.lessonEnabled}})}catch(_){let se=_ instanceof Error?_.message:"Unable to generate lesson plan at this time.";if(_ instanceof ja&&_.status===422)try{const ue=JSON.parse(_.responseBody)?.detail;ue?.message&&(se=ue.message);const st=ue?.sourceLegitimacy?.issues||[],He=ue?.selfValidation?.issues||[],he=[...st,...He].filter(Boolean).slice(0,3);he.length>0&&(se=`${se} ${he.join(" ")}`)}catch{}F(se),B(null),j([]),Je.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:t.classSectionId||zt(C||"Grade 11",p||"Section A"),className:[C,p].filter(Boolean).join(" - ")||t.className,metadata:{error:se,allowReviewSources:ve,allowUnverifiedLesson:le,importGroundingEnabled:f.lessonEnabled}})}finally{V(!1)}},[t,C,p,f.lessonEnabled,ve,le]),Me=h.useCallback(async()=>{if(!N)return pe.error("Generate a lesson plan first."),null;Ae(!0);try{const _=await uu(N,s,{teacherName:a,studentId:t.id,studentName:t.name});return ae(_),pe.success("Lesson plan saved as draft."),_}catch(_){return console.error("Failed to save lesson draft:",_),pe.error(_ instanceof Error?_.message:"Failed to save lesson draft."),null}finally{Ae(!1)}},[N,s,a,t.id,t.name]),wt=h.useCallback(async()=>{if(!N){pe.error("Generate a lesson plan first.");return}if(!N.publishReady){const _=[...N.sourceLegitimacy.issues,...N.selfValidation.issues].filter(Boolean).slice(0,2).join(" ");pe.error(_||"Lesson is not publish-ready. Resolve legitimacy and validation checks first.");return}O(!0);try{let _=K;if(_||(_=await Me()),!_)return;await mu(_),pe.success("Lesson plan published to class content."),Je.reportImportGroundedFeedback({flow:"lesson",status:"success",classSectionId:N.classSectionId||t.classSectionId,className:N.className||t.className,metadata:{action:"publish_lesson_plan",lessonPlanId:_,publishReady:N.publishReady,sourceLegitimacyStatus:N.sourceLegitimacy.status,selfValidationPassed:N.selfValidation.passed}})}catch(_){console.error("Failed to publish lesson plan:",_),pe.error(_ instanceof Error?_.message:"Failed to publish lesson plan."),Je.reportImportGroundedFeedback({flow:"lesson",status:"failed",classSectionId:N.classSectionId||t.classSectionId,className:N.className||t.className,metadata:{action:"publish_lesson_plan",error:_ instanceof Error?_.message:"Failed to publish lesson plan."}})}finally{O(!1)}},[N,K,Me,t.className,t.classSectionId]);h.useEffect(()=>{Ke()},[X]),h.useEffect(()=>{b(_=>_+1)},[t.id]),h.useEffect(()=>{ee("all"),je("all")},[N]),h.useMemo(()=>N?Array.from(new Set(N.blocks.map(_=>_.provenance?.sourceFile?.trim()).filter(_=>!!_))).sort((_,se)=>_.localeCompare(se)):[],[N]),h.useMemo(()=>N?Array.from(new Set(N.blocks.map(_=>_.provenance?.materialId?.trim()).filter(_=>!!_))).sort((_,se)=>_.localeCompare(se)):[],[N]);const It=h.useMemo(()=>N?N.blocks.filter(_=>{const se=W==="all"||(_.provenance?.sourceFile||"").trim()===W,we=ie==="all"||(_.provenance?.materialId||"").trim()===ie;return se&&we}):[],[N,W,ie]),$=[{id:1,type:"video",title:`${t.weakestTopic} Fundamentals`,duration:"8 mins",icon:In},{id:2,type:"quiz",title:`${t.weakestTopic} Practice`,questions:10,icon:Bo},{id:3,type:"assessment",title:"Final Check",questions:5,icon:vr}],Z=async()=>{if(!s){pe.error("Unable to update section: teacher context missing");return}L(!0);try{await Ii(t.id,C,p,s,new Date().getFullYear().toString(),a),await ki(t.id,C,p);const _={...t,grade:C,section:p,className:[C,p].filter(Boolean).join(" - "),classSectionId:zt(C,p)};r(_),pe.success("Student section assignment updated")}catch(_){console.error("Failed to update student section assignment:",_),pe.error("Failed to update section assignment")}finally{L(!1)}};return e.jsxs(Ge.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(ya,{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(un,{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(un,{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(so,{sources:m,className:"mb-4 relative z-10"}),e.jsx(va,{name:"teacher-intervention-analysis",loading:g,fixture:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsx(Ce,{className:"h-24 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-24 w-full rounded-[14px]"})]}),fallback:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full relative z-10",children:[e.jsx(Ce,{className:"h-24 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-24 w-full rounded-[14px]"})]}),children: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(aa,{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(Yt,{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((_,se)=>e.jsxs("li",{children:["Must continue strengthening ",e.jsx("span",{className:"font-semibold text-[#1e293b]",children:_}),"."]},se)):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:g,onClick:()=>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(Vs,{className:"w-3 h-3"})," Regenerate"]})]}),e.jsxs(va,{name:"teacher-intervention-learning-path",loading:g,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ce,{className:"h-24 w-full rounded-xl"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ce,{className:"h-24 w-full rounded-xl"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"}),e.jsx(Ce,{className:"h-20 w-full rounded-[14px]"})]}),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:$.map((_,se)=>{let we=e.jsx(In,{className:"w-4 h-4"}),ue="bg-[#8b5cf6] shadow-[0_4px_10px_rgba(139,92,246,0.3)]",st="text-purple-600",He="group-hover:border-purple-200",he="hover:bg-[#4f46e5]",gt=e.jsx(El,{className:"w-4 h-4 ml-0.5"});return _.type==="quiz"?(we=e.jsx(Ol,{className:"w-4 h-4"}),ue="bg-sky-500 shadow-[0_4px_10px_rgba(14,165,233,0.3)]",st="text-sky-600",He="group-hover:border-sky-200",he="hover:bg-sky-500",gt=e.jsx(ts,{className:"w-4 h-4"})):_.type==="assessment"&&(we=e.jsx(br,{className:"w-4 h-4"}),ue="bg-emerald-500 shadow-[0_4px_10px_rgba(16,185,129,0.3)]",st="text-emerald-600",He="group-hover:bg-emerald-50"),e.jsxs(Ge.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:se*.1},className:"relative pl-[32px] group",children:[e.jsx("div",{className:`absolute -left-[17px] top-1 w-8 h-8 rounded-full ${ue} text-white flex items-center justify-center ring-4 ring-white group-hover:scale-110 transition-transform`,children:we}),e.jsxs("div",{className:`${_.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 ${He}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wider mb-1 block ${st}`,children:["Step ",se+1," • ",_.type==="video"?"Video Lesson":_.type==="quiz"?"Practice":"Assessment"]}),e.jsx("p",{className:"font-semibold text-[#1e293b] text-[13px] mb-0.5",children:_.title}),e.jsxs("p",{className:"text-[#64748b] text-[11px] flex items-center gap-1.5",children:[_.type==="video"&&e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"w-3 h-3"})," ",_.duration]}),_.type==="quiz"&&e.jsxs(e.Fragment,{children:[e.jsx(Po,{className:"w-3 h-3"})," ",_.questions," questions"]}),_.type==="assessment"&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"w-3 h-3"})," ",_.questions," assessment questions"]})]})]}),_.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] ${he} hover:text-white transition-colors border border-[#e2e8f0]`,children:gt})]})]},_.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(ps,{onClick:()=>b(_=>_+1),disabled:z,className:"bg-[#4f46e5] hover:bg-[#3730a3] text-white h-8 text-[11px] rounded-full px-4",children:z?e.jsx(Ce,{className:"h-3 w-16 bg-white/35"}):"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(Us,{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:ve,onChange:_=>ke(_.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:le,onChange:_=>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(va,{name:"teacher-intervention-lesson-plan",loading:z,fixture:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ce,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(Ce,{className:"h-24 w-full rounded-xl"}),e.jsx(Ce,{className:"h-24 w-full rounded-xl"})]}),e.jsx(Ce,{className:"h-28 w-full rounded-xl"})]}),fallback:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ce,{className:"h-20 w-full rounded-xl"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(Ce,{className:"h-24 w-full rounded-xl"}),e.jsx(Ce,{className:"h-24 w-full rounded-xl"})]}),e.jsx(Ce,{className:"h-28 w-full rounded-xl"})]}),children:[Q&&e.jsx("div",{className:"bg-[#FF8B8B]/14 border border-[#FF8B8B]/35 rounded-xl p-3 text-sm text-[#D66A6A] mb-4",children:Q}),N&&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(so,{sources:m})}),e.jsx("p",{className:"text-[14px] font-semibold text-[#1e293b]",children:N.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:"})," ",N.usedImportedTopics?"Yes":"No"," (",N.importedTopicCount,")"]}),e.jsxs("p",{className:"text-[11px] text-[#64748b]",children:[e.jsx("span",{className:"font-semibold text-[#475569]",children:"Subject:"})," ",N.subject||"General Math"," (Q",N.quarter||1,")"]})]}),N.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: ",N.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 ${N.publishReady?"text-emerald-600":"text-rose-500"}`,children:N.publishReady?"Ready":"Blocked"})]})}),N.warnings.length>0&&e.jsx("p",{className:"text-[11px] text-amber-600 mt-2 bg-amber-50 px-2 py-1.5 rounded",children:N.warnings.join(" ")})]}),N.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:N.lessonObjective})]}),N.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:N.realWorldHook})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:It.map(_=>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:_.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] mt-1",children:[_.estimatedMinutes," mins "," • "," ",_.strategy]}),e.jsx("p",{className:"text-[12px] text-[#475569] mt-2 bg-[#f8fafc] p-2 rounded-lg",children:_.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"}),_.activities.slice(0,2).map((se,we)=>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:se})]},we))]})]},_.blockId))}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-4",children:[e.jsx(ps,{variant:"outline",onClick:()=>void Me(),disabled:Le||!N,className:"border-[#cbd5e1] text-[#475569] hover:bg-[#f8fafc] text-[12px] h-9 rounded-full px-5",children:Le?e.jsx(Ce,{className:"h-4 w-16"}):"Save Draft"}),e.jsx(ps,{onClick:()=>void wt(),disabled:Pe||!N||!N.publishReady,className:"bg-[#10b981] hover:bg-[#059669] text-white text-[12px] h-9 rounded-full px-5",children:Pe?e.jsx(Ce,{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()=>{Y("choose"),E(!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(gc,{className:"w-4 h-4"})," Export Materials"]})}),I&&sr.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",onClick:()=>E(!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:_=>_.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:[U==="bank"&&e.jsx("button",{onClick:()=>Y("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(as,{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(or,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[15px] font-bold text-white leading-tight",children:U==="choose"?"Export Materials":"Choose a Quiz"}),e.jsx("p",{className:"text-[11px] text-white/70 font-medium",children:U==="choose"?`For ${t.name}`:"Select a quiz from your bank"})]})]}),e.jsx("button",{onClick:()=>E(!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(fs,{className:"w-4 h-4"})})]})}),e.jsx("div",{className:"p-6",children:U==="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),Y("bank");try{const _=await Do(s);te(_)}catch{te([])}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(Ta,{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:()=>{E(!1),_e(!1),Ne(!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(rs,{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:A?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(Ta,{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(_=>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:_.title}),e.jsxs("p",{className:"text-[11px] text-[#64748b] font-medium mt-0.5",children:[_.questions?.length??0," questions",_.gradeLevel?` · ${_.gradeLevel}`:"",_.metadata?.topicsCovered?.[0]?` · ${_.metadata.topicsCovered[0]}`:""]})]}),e.jsx("button",{onClick:()=>{E(!1),pe.success(`"${_.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"})]},_.id))})})})]})]}),document.body),me&&sr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/40 backdrop-blur-sm",onClick:()=>{J?Te(!0):Ne(!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:()=>{J?Te(!0):Ne(!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(ya,{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(or,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:"text-[14px] font-bold text-[#1e293b]",children:"AI Quiz Maker"})]}),J&&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(Ei,{onBack:()=>Ne(!1),drawerMode:!0,gradeLevel:t.grade,onQuizGenerating:()=>_e(!0),onQuizSaved:_=>{_e(!1),pe.success("Quiz saved! Close this panel or create another.",{action:{label:"Close Panel",onClick:()=>Ne(!1)}})}})})]}),Ve&&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:()=>Te(!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(Ys,{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:()=>Te(!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:()=>{Te(!1),Ne(!1),_e(!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(Qs,{value:C,onChange:_=>S(_.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(Qs,{value:p,onChange:_=>y(_.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:Z,disabled:k||!C.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:k?"Updating...":"Update Assignment"})]})]})]})})]})},ex=({onViewCalendar:t,onOpenProfile:s,userProfile:a,teacherName:r,liveActivity:o=[]})=>{const{currentUser:n}=os(),[i,l]=h.useState(new Date),[c,d]=h.useState("pulse"),[f,v]=h.useState([]);h.useEffect(()=>{if(!n?.uid)return;const m=Mi(n.uid,{limitCount:100},j=>v(j),()=>{});return()=>m()},[n?.uid]);const x=m=>new Date(m.getFullYear(),m.getMonth()+1,0).getDate(),g=m=>new Date(m.getFullYear(),m.getMonth(),1).getDay(),T=()=>i.toLocaleDateString(void 0,{month:"long",year:"numeric"}),C=()=>l(new Date(i.getFullYear(),i.getMonth()-1)),S=()=>l(new Date(i.getFullYear(),i.getMonth()+1)),p=()=>{const m=x(i),j=g(i),w=[];for(let R=j-1;R>=0;R--)w.unshift(null);for(let R=1;R<=m;R++)w.push(R);return w},y=m=>{if(!m)return!1;const j=new Date;return m===j.getDate()&&i.getMonth()===j.getMonth()&&i.getFullYear()===j.getFullYear()},k=p(),L=["Mo","Tu","We","Th","Fr","Sa","Su"],N=m=>{if(!m)return!1;const j=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(m).padStart(2,"0")}`;return f.some(w=>{const R=new Date(w.startTime);return`${R.getFullYear()}-${String(R.getMonth()+1).padStart(2,"0")}-${String(R.getDate()).padStart(2,"0")}`===j})},B=m=>{if(!m)return;const j=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(m).padStart(2,"0")}`,w=f.filter(R=>{const z=new Date(R.startTime);return`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`===j});if(w.length!==0)return w.map(R=>`• ${R.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(Nl,{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-[#475569]",children:"Teacher"}),e.jsx("button",{onClick:s,className:"mt-[4px] py-[6px] px-[22px] bg-[#4f46e5] hover:bg-[#4338ca] text-white rounded-full text-[11.5px] font-medium transition-colors",children:"Profile"})]}),e.jsxs("div",{className:"p-[10px_16px] border-b border-[#f1f5f9] cursor-pointer hover:bg-slate-50 transition-colors group/cal",onClick:t,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("button",{onClick:m=>{m.stopPropagation(),C()},"aria-label":"Previous month",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(as,{size:14})}),e.jsx("span",{className:"text-[12px] font-semibold text-[#1e293b] group-hover/cal:text-[#4f46e5] transition-colors",children:T()}),e.jsx("button",{onClick:m=>{m.stopPropagation(),S()},"aria-label":"Next month",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(ts,{size:14})})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-[2px] text-center mb-1",children:[L.map(m=>e.jsx("div",{className:"text-[10px] font-semibold text-[#475569] p-[2px_0_4px]",children:m},m)),k.map((m,j)=>e.jsxs("div",{className:"relative flex flex-col items-center justify-center h-[28px]",title:B(m),children:[e.jsx("div",{className:`text-[11px] leading-[22px] w-[22px] h-[22px] flex items-center justify-center rounded-full transition-all ${m===null?"text-[#cbd5e1]":y(m)?"bg-[#4f46e5] text-white font-semibold":"text-[#475569] group-hover/cal:bg-slate-100"}`,children:m}),m!==null&&N(m)&&e.jsx("div",{className:`absolute bottom-0 w-1 h-1 rounded-full ${y(m)?"bg-white":"bg-[#a855f7]"}`})]},`${i.getMonth()}-${j}`))]})]}),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-[#047857] border-[#047857]":"text-[#475569] 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-[#047857] border-[#047857]":"text-[#475569] 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-700",children:"LIVE"})]})]}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[e.jsx(Ro,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#475569]",children:"No recent activity"})]}):e.jsx("div",{className:"space-y-4",children:o.slice(0,5).map(m=>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:m.student}),e.jsx("span",{className:"text-[9px] font-medium text-[#94a3b8] shrink-0",children:m.time})]}),e.jsxs("p",{className:"text-[11px] text-[#64748b] leading-snug",children:[m.action," ",e.jsx("span",{className:"font-bold text-[#4f46e5]",children:m.topic})]})]})]},m.id))})]}),c==="reminders"&&e.jsxs("div",{className:"space-y-3",children:[f.filter(m=>{const j=new Date;return j.setHours(0,0,0,0),new Date(m.startTime).getTime()>=j.getTime()}).sort((m,j)=>new Date(m.startTime).getTime()-new Date(j.startTime).getTime()).slice(0,5).map(m=>{const j=new Date(m.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 ${j?"text-rose-500":"text-[#4f46e5]"}`,children:e.jsx(gr,{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:m.title}),e.jsxs("div",{className:`text-[10px] font-medium ${j?"text-rose-500 font-bold":"text-[#94a3b8]"}`,children:[j?"Today, ":"",new Date(m.startTime).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]},m.id)}),f.filter(m=>new Date(m.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(Ca,{size:32,className:"text-slate-300 mb-2"}),e.jsx("p",{className:"text-[11px] font-bold text-[#1e293b]",children:"No upcoming tasks"})]})]})]})]})};export{Kx as default}; diff --git a/assets/XPNotification-B5D6Y4_2.js b/assets/XPNotification-B5D6Y4_2.js deleted file mode 100644 index edff7cd6867764234fe2fc65948bf714acd8c358..0000000000000000000000000000000000000000 --- a/assets/XPNotification-B5D6Y4_2.js +++ /dev/null @@ -1 +0,0 @@ -import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{g as n,m as i,$ as m}from"./index-mbyiCUYG.js";import{S as c}from"./sparkles-THbTTiEe.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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/XPNotification-Doid3miV.js b/assets/XPNotification-Doid3miV.js new file mode 100644 index 0000000000000000000000000000000000000000..c2bc1ea88a260bddcbe7cdb0e60c29c38b918be8 --- /dev/null +++ b/assets/XPNotification-Doid3miV.js @@ -0,0 +1 @@ +import{r as l,j as e}from"./vendor-react-B4AQeu28.js";import{k as n,m as i,a1 as m}from"./index-B3ruOzo6.js";import{S as c}from"./sparkles-Bq0AaIRg.js";import"./vendor-firebase-firestore-CP9q7ISf.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-pLIzsro_.js b/assets/automationService-JEEI7dc9.js similarity index 95% rename from assets/automationService-pLIzsro_.js rename to assets/automationService-JEEI7dc9.js index a1b0bda435aa2db6790862754cb700c00ccfd2d6..bc357cbc2d8192e973fb67340c0d20ed701db6a2 100644 --- a/assets/automationService-pLIzsro_.js +++ b/assets/automationService-JEEI7dc9.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-CP9q7ISf.js";import{h as r,b0 as $}from"./index-mbyiCUYG.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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-CP9q7ISf.js";import{g as r,b0 as $}from"./index-B3ruOzo6.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-D_pyutJs.js b/assets/bell-Bp_utT8v.js similarity index 63% rename from assets/bell-D_pyutJs.js rename to assets/bell-Bp_utT8v.js index 074d84c4b2707d691de7257bfbc03820e0712e79..685a54c13b1e17e8b744aac0fc511b03cd267fad 100644 --- a/assets/bell-D_pyutJs.js +++ b/assets/bell-Bp_utT8v.js @@ -1,6 +1,6 @@ -import{c as e}from"./index-mbyiCUYG.js";/** +import{e}from"./index-B3ruOzo6.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 c=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],t=e("bell",c);export{t as B}; + */const o=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],a=e("bell",o);export{a as B}; diff --git a/assets/button-BqKfG4Jj.js b/assets/button-BqKfG4Jj.js deleted file mode 100644 index e1812f40e7a7a189282d0726ad8519eba13e5e7b..0000000000000000000000000000000000000000 --- a/assets/button-BqKfG4Jj.js +++ /dev/null @@ -1 +0,0 @@ -import{j as y}from"./vendor-react-B4AQeu28.js";import{S as k}from"./vendor-radix-xDOIcVzp.js";import{c as V}from"./vendor-charts-Ckgeb0nY.js";import{k as p}from"./index-mbyiCUYG.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/button-CaSK4KoS.js b/assets/button-CaSK4KoS.js new file mode 100644 index 0000000000000000000000000000000000000000..00aebc6e87c1f5266d552bd5013776afc0c90247 --- /dev/null +++ b/assets/button-CaSK4KoS.js @@ -0,0 +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{j}from"./index-B3ruOzo6.js";const g=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,m=V,p=(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=p("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:j(N({variant:r,size:e,className:n})),...u})}export{w as B,p as c}; diff --git a/assets/chart-column-B4tQNTpN.js b/assets/chart-column-C9VTl-3A.js similarity index 89% rename from assets/chart-column-B4tQNTpN.js rename to assets/chart-column-C9VTl-3A.js index 14b4ed34c561479c91662ee61fb4b14de860f1b8..d03c5fbe31d4757b767e9ffcec149a9cac42420f 100644 --- a/assets/chart-column-B4tQNTpN.js +++ b/assets/chart-column-C9VTl-3A.js @@ -1,4 +1,4 @@ -import{c as t}from"./index-mbyiCUYG.js";/** +import{e as t}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/chatService-BuuZ3z6i.js b/assets/chatService-oZskyXOh.js similarity index 87% rename from assets/chatService-BuuZ3z6i.js rename to assets/chatService-oZskyXOh.js index 631a3b4c2a6e62f0f8256f0f2f053eb19328396f..93b43d24162649457a2616fc5734b5a5b637f7ae 100644 --- a/assets/chatService-BuuZ3z6i.js +++ b/assets/chatService-oZskyXOh.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-CP9q7ISf.js";import{h as a}from"./index-mbyiCUYG.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.js";import"./vendor-radix-xDOIcVzp.js";import"./vendor-charts-Ckgeb0nY.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}:{}},h=await g(c(a,"chatSessions",s));h.exists()&&(o.userId=h.data().userId);const m={id:o.id,userId:o.userId,role:o.role,content:o.content,sessionId:s,timestamp:i()};return o.context&&(m.context=o.context),await w(r,m),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-CP9q7ISf.js";import{g as a}from"./index-B3ruOzo6.js";import"./vendor-firebase-core-DCQrgkxC.js";import"./vendor-react-B4AQeu28.js";import"./vendor-firebase-auth-Bcpr4O6E.js";import"./vendor-firebase-storage-dc5X5yTv.js";import"./vendor-firebase-analytics-CHPyhRzk.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-BLN5Dl8e.js b/assets/check-6eXlU5jr.js similarity index 85% rename from assets/check-BLN5Dl8e.js rename to assets/check-6eXlU5jr.js index d6f39804aec7afcdd7e5c8f95c48028c66cd3d01..761bd84125af7c7bfcf9725dc03a476466b561a9 100644 --- a/assets/check-BLN5Dl8e.js +++ b/assets/check-6eXlU5jr.js @@ -1,4 +1,4 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e as c}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/check-check-wBIDWtv-.js b/assets/check-check-wBIDWtv-.js deleted file mode 100644 index bf090b39dbbf70493030143254f4c801b9f4a10e..0000000000000000000000000000000000000000 --- a/assets/check-check-wBIDWtv-.js +++ /dev/null @@ -1,6 +0,0 @@ -import{c}from"./index-mbyiCUYG.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 e=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],k=c("check-check",e);export{k as C}; diff --git a/assets/chevron-left-BYtw_nqd.js b/assets/chevron-left-Cr0wYLQi.js similarity index 54% rename from assets/chevron-left-BYtw_nqd.js rename to assets/chevron-left-Cr0wYLQi.js index d66d2f36b26c9ebbcb926b6d9fa196bde505906d..44439da0de1297ebfb6b0db647654ea613f7d980 100644 --- a/assets/chevron-left-BYtw_nqd.js +++ b/assets/chevron-left-Cr0wYLQi.js @@ -1,6 +1,6 @@ -import{c as e}from"./index-mbyiCUYG.js";/** +import{e}from"./index-B3ruOzo6.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 o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t=e("chevron-left",o);export{t as C}; + */const o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],c=e("chevron-left",o);export{c as C}; diff --git a/assets/chevron-right-bwYIKoxv.js b/assets/chevron-right-CbkkCalp.js similarity index 54% rename from assets/chevron-right-bwYIKoxv.js rename to assets/chevron-right-CbkkCalp.js index a1a7edee783029e8710784ba060c45df0f3581ce..acd569261834f5eb33857147c6af730444021fed 100644 --- a/assets/chevron-right-bwYIKoxv.js +++ b/assets/chevron-right-CbkkCalp.js @@ -1,6 +1,6 @@ -import{c as o}from"./index-mbyiCUYG.js";/** +import{e as o}from"./index-B3ruOzo6.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 t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=o("chevron-right",t);export{e as C}; + */const e=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],c=o("chevron-right",e);export{c as C}; diff --git a/assets/chevron-up-B_-cQcm8.js b/assets/chevron-up-CTb5_AvY.js similarity index 74% rename from assets/chevron-up-B_-cQcm8.js rename to assets/chevron-up-CTb5_AvY.js index df07567299b88c06d91f78fa2f6f9abb21a80930..8a394e8d77aa9b4b94c2ecce8446b27fe026a460 100644 --- a/assets/chevron-up-B_-cQcm8.js +++ b/assets/chevron-up-CTb5_AvY.js @@ -1,4 +1,4 @@ -import{c as o}from"./index-mbyiCUYG.js";/** +import{e as o}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. @@ -8,4 +8,4 @@ import{c as o}from"./index-mbyiCUYG.js";/** * * 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:"m18 15-6-6-6 6",key:"153udz"}]],t=o("chevron-up",c);export{r as C,t as a}; + */const e=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],t=o("chevron-up",e);export{r as C,t as a}; diff --git a/assets/circle-alert-CJ47UAgT.js b/assets/circle-alert-CTR2Lqp7.js similarity index 89% rename from assets/circle-alert-CJ47UAgT.js rename to assets/circle-alert-CTR2Lqp7.js index 24be98936ffaa87aa70055c98596a92824e1c61d..d18568b80922cb877c72d72114e5241b4b1a67ec 100644 --- a/assets/circle-alert-CJ47UAgT.js +++ b/assets/circle-alert-CTR2Lqp7.js @@ -1,4 +1,4 @@ -import{c as e}from"./index-mbyiCUYG.js";/** +import{e}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-BENuYz-J.js b/assets/circle-check-DyFN6-07.js similarity index 87% rename from assets/circle-check-BENuYz-J.js rename to assets/circle-check-DyFN6-07.js index e376c840dbc8f1daef99450a8dd65fc13d258f00..6ebc0e0802cc732cf8c32f496b9a7b216526ef24 100644 --- a/assets/circle-check-BENuYz-J.js +++ b/assets/circle-check-DyFN6-07.js @@ -1,4 +1,4 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e as c}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-check-big-BnoZ8KZB.js b/assets/circle-check-big-CWdn1Nqf.js similarity index 88% rename from assets/circle-check-big-BnoZ8KZB.js rename to assets/circle-check-big-CWdn1Nqf.js index 824a21dcca01d1d5a5cc507ddeb3a5a8c3586945..e8b96a67c5d32d5df73e6fa6443f36815d83a780 100644 --- a/assets/circle-check-big-BnoZ8KZB.js +++ b/assets/circle-check-big-CWdn1Nqf.js @@ -1,4 +1,4 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e as c}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/circle-help-BP0kOuya.js b/assets/circle-help-C5HGdkRZ.js similarity index 89% rename from assets/circle-help-BP0kOuya.js rename to assets/circle-help-C5HGdkRZ.js index 1a23f91eda15ad91d964fc9ef8dffdd525cd5a44..694db2381d51f121c14c3f15ccdd904aa4eccbdc 100644 --- a/assets/circle-help-BP0kOuya.js +++ b/assets/circle-help-C5HGdkRZ.js @@ -1,4 +1,4 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e as c}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/clipboard-check-BB6UVEW1.js b/assets/clipboard-check-Bv_xk-Mp.js similarity index 64% rename from assets/clipboard-check-BB6UVEW1.js rename to assets/clipboard-check-Bv_xk-Mp.js index 1f27343d1935095dddeaefb0434a08ec5bcef7c9..8266e5155ef406df6b2bfc1134da15edf6494d4a 100644 --- a/assets/clipboard-check-BB6UVEW1.js +++ b/assets/clipboard-check-Bv_xk-Mp.js @@ -1,6 +1,6 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e}from"./index-B3ruOzo6.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 e=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],t=c("clipboard-check",e);export{t as C}; + */const a=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],t=e("clipboard-check",a);export{t as C}; diff --git a/assets/clock-BLtPbCgT.js b/assets/clock-C73na4Cu.js similarity index 87% rename from assets/clock-BLtPbCgT.js rename to assets/clock-C73na4Cu.js index 9ffb85e307f65ef41cec33c1ea3360222cb00e83..ecbe1976d40d7c5c63dfcc7610248c721a62616d 100644 --- a/assets/clock-BLtPbCgT.js +++ b/assets/clock-C73na4Cu.js @@ -1,4 +1,4 @@ -import{c}from"./index-mbyiCUYG.js";/** +import{e as c}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/diagnosticService-D1BQOFa3.js b/assets/diagnosticService-CLsUcd9M.js similarity index 88% rename from assets/diagnosticService-D1BQOFa3.js rename to assets/diagnosticService-CLsUcd9M.js index 7f3165f755f1a8d0daacd127daaf9db454b5cc10..c0ded888c261d36478a80b9b9583b6e7ef338523 100644 --- a/assets/diagnosticService-D1BQOFa3.js +++ b/assets/diagnosticService-CLsUcd9M.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-mbyiCUYG.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.js","assets/vendor-radix-xDOIcVzp.js","assets/vendor-charts-Ckgeb0nY.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/index-CoeUXWgK.css"])))=>i.map(i=>d[i]); -import{_ as w}from"./index-mbyiCUYG.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-mbyiCUYG.js").then(a=>a.b2);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-mbyiCUYG.js").then(r=>r.b2);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-B3ruOzo6.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.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-trN1hCQB.css"])))=>i.map(i=>d[i]); +import{_ as w}from"./index-B3ruOzo6.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-B3ruOzo6.js").then(a=>a.b2);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-B3ruOzo6.js").then(r=>r.b2);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-fiLCzxmY.js b/assets/dialog-KaD0jw5O.js similarity index 79% rename from assets/dialog-fiLCzxmY.js rename to assets/dialog-KaD0jw5O.js index 5cabe3bcecbf0c41a93690ab40c99047c2134a66..44efd28743704f7c465c0deb15227de8c98e0824 100644 --- a/assets/dialog-fiLCzxmY.js +++ b/assets/dialog-KaD0jw5O.js @@ -1 +1 @@ -import{j as t,r as l}from"./vendor-react-B4AQeu28.js";import{b as g,c as n,d as m,T as r,D as d,P as p,O as i}from"./vendor-radix-xDOIcVzp.js";import{k as o}from"./index-mbyiCUYG.js";import{X as u}from"./x-oZO0Ye1Q.js";function w({...a}){return t.jsx(g,{"data-slot":"dialog",...a})}function x({...a}){return t.jsx(p,{"data-slot":"dialog-portal",...a})}const c=l.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,"data-slot":"dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e}));c.displayName=i.displayName;const y=l.forwardRef(({className:a,children:e,...s},f)=>t.jsxs(x,{"data-slot":"dialog-portal",children:[t.jsx(c,{}),t.jsxs(n,{ref:f,"data-slot":"dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...s,children:[e,t.jsxs(m,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));y.displayName=n.displayName;function z({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...e})}function R({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}const j=l.forwardRef(({className:a,...e},s)=>t.jsx(r,{ref:s,"data-slot":"dialog-title",className:o("text-lg leading-none font-semibold",a),...e}));j.displayName=r.displayName;const N=l.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,"data-slot":"dialog-description",className:o("text-muted-foreground text-sm",a),...e}));N.displayName=d.displayName;export{w as D,y as a,z as b,j as c,N as d,R as e}; +import{j as t,r as l}from"./vendor-react-B4AQeu28.js";import{b as g,c as n,d as m,T as r,D as d,P as p,O as i}from"./vendor-radix-BPuEd8FG.js";import{j as o}from"./index-B3ruOzo6.js";import{X as u}from"./x-BNHnAXzL.js";function w({...a}){return t.jsx(g,{"data-slot":"dialog",...a})}function x({...a}){return t.jsx(p,{"data-slot":"dialog-portal",...a})}const c=l.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,"data-slot":"dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e}));c.displayName=i.displayName;const j=l.forwardRef(({className:a,children:e,...s},f)=>t.jsxs(x,{"data-slot":"dialog-portal",children:[t.jsx(c,{}),t.jsxs(n,{ref:f,"data-slot":"dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...s,children:[e,t.jsxs(m,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));j.displayName=n.displayName;function z({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...e})}function R({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}const y=l.forwardRef(({className:a,...e},s)=>t.jsx(r,{ref:s,"data-slot":"dialog-title",className:o("text-lg leading-none font-semibold",a),...e}));y.displayName=r.displayName;const N=l.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,"data-slot":"dialog-description",className:o("text-muted-foreground text-sm",a),...e}));N.displayName=d.displayName;export{w as D,j as a,z as b,y as c,N as d,R as e}; diff --git a/assets/download-C2PVrIq3.js b/assets/download-BbFDZT3H.js similarity index 89% rename from assets/download-C2PVrIq3.js rename to assets/download-BbFDZT3H.js index da0bdaef8ef112ccd3755b8ae04927f40b98ff4b..d604df37a8efee3b4e5cf86af0208b96712779d0 100644 --- a/assets/download-C2PVrIq3.js +++ b/assets/download-BbFDZT3H.js @@ -1,4 +1,4 @@ -import{c as o}from"./index-mbyiCUYG.js";/** +import{e as o}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/eye-DakyBxPE.js b/assets/eye-WyNbhirJ.js similarity index 95% rename from assets/eye-DakyBxPE.js rename to assets/eye-WyNbhirJ.js index cf2db75ec56effffb47c684f4ead548bbddb82e1..0e691354f6f48673925e68b57cf1d0151b07a9f4 100644 --- a/assets/eye-DakyBxPE.js +++ b/assets/eye-WyNbhirJ.js @@ -1,4 +1,4 @@ -import{c as e}from"./index-mbyiCUYG.js";/** +import{e}from"./index-B3ruOzo6.js";/** * @license lucide-react v0.487.0 - ISC * * This source code is licensed under the ISC license. diff --git a/assets/formatDistanceToNow-B_Ixh2wt.js b/assets/formatDistanceToNow-B_Ixh2wt.js deleted file mode 100644 index dc9e48b0b9c4b4f7dbeb4e58a2bff4597672e539..0000000000000000000000000000000000000000 --- a/assets/formatDistanceToNow-B_Ixh2wt.js +++ /dev/null @@ -1 +0,0 @@ -import{t as u,a2 as W}from"./index-mbyiCUYG.js";function S(t,n){return t instanceof Date?new t.constructor(n):new Date(n)}const b=43200,p=1440;let k={};function F(){return k}function P(t){const n=u(t),e=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return e.setUTCFullYear(n.getFullYear()),+t-+e}function w(t,n){const e=u(t),r=u(n),a=e.getTime()-r.getTime();return a<0?-1:a>0?1:a}function T(t){return S(t,Date.now())}function x(t,n){const e=u(t),r=u(n),a=e.getFullYear()-r.getFullYear(),s=e.getMonth()-r.getMonth();return a*12+s}function C(t){return n=>{const r=(t?Math[t]:Math.trunc)(n);return r===0?0:r}}function X(t,n){return+u(t)-+u(n)}function A(t){const n=u(t),e=n.getMonth();return n.setFullYear(n.getFullYear(),e+1,0),n.setHours(23,59,59,999),n}function O(t){const n=u(t);return+W(n)==+A(n)}function Y(t,n){const e=u(t),r=u(n),a=w(e,r),s=Math.abs(x(e,r));let i;if(s<1)i=0;else{e.getMonth()===1&&e.getDate()>27&&e.setDate(30),e.setMonth(e.getMonth()-a*s);let o=w(e,r)===-a;O(u(t))&&s===1&&w(t,r)===1&&(o=!1),i=a*(s-Number(o))}return i===0?0:i}function N(t,n,e){const r=X(t,n)/1e3;return C(e?.roundingMethod)(r)}const j={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},_=(t,n,e)=>{let r;const a=j[t];return typeof a=="string"?r=a:n===1?r=a.one:r=a.other.replace("{{count}}",n.toString()),e?.addSuffix?e.comparison&&e.comparison>0?"in "+r:r+" ago":r};function D(t){return(n={})=>{const e=n.width?String(n.width):t.defaultWidth;return t.formats[e]||t.formats[t.defaultWidth]}}const I={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},R={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},V={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},z={date:D({formats:I,defaultWidth:"full"}),time:D({formats:R,defaultWidth:"full"}),dateTime:D({formats:V,defaultWidth:"full"})},L={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},q=(t,n,e,r)=>L[t];function y(t){return(n,e)=>{const r=e?.context?String(e.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,o=e?.width?String(e.width):i;a=t.formattingValues[o]||t.formattingValues[i]}else{const i=t.defaultWidth,o=e?.width?String(e.width):t.defaultWidth;a=t.values[o]||t.values[i]}const s=t.argumentCallback?t.argumentCallback(n):n;return a[s]}}const J={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},E={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},H={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Q={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},U={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},B={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},K=(t,n)=>{const e=Number(t),r=e%100;if(r>20||r<10)switch(r%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},$={ordinalNumber:K,era:y({values:J,defaultWidth:"wide"}),quarter:y({values:E,defaultWidth:"wide",argumentCallback:t=>t-1}),month:y({values:H,defaultWidth:"wide"}),day:y({values:Q,defaultWidth:"wide"}),dayPeriod:y({values:U,defaultWidth:"wide",formattingValues:B,defaultFormattingWidth:"wide"})};function M(t){return(n,e={})=>{const r=e.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=n.match(a);if(!s)return null;const i=s[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(o)?Z(o,g=>g.test(i)):G(o,g=>g.test(i));let d;d=t.valueCallback?t.valueCallback(l):l,d=e.valueCallback?e.valueCallback(d):d;const h=n.slice(i.length);return{value:d,rest:h}}}function G(t,n){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&n(t[e]))return e}function Z(t,n){for(let e=0;e{const r=n.match(t.matchPattern);if(!r)return null;const a=r[0],s=n.match(t.parsePattern);if(!s)return null;let i=t.valueCallback?t.valueCallback(s[0]):s[0];i=e.valueCallback?e.valueCallback(i):i;const o=n.slice(a.length);return{value:i,rest:o}}}const et=/^(\d+)(th|st|nd|rd)?/i,nt=/\d+/i,at={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rt={any:[/^b/i,/^(a|c)/i]},ot={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},it={any:[/1/i,/2/i,/3/i,/4/i]},st={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ut={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ct={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},dt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},lt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ht={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},mt={ordinalNumber:tt({matchPattern:et,parsePattern:nt,valueCallback:t=>parseInt(t,10)}),era:M({matchPatterns:at,defaultMatchWidth:"wide",parsePatterns:rt,defaultParseWidth:"any"}),quarter:M({matchPatterns:ot,defaultMatchWidth:"wide",parsePatterns:it,defaultParseWidth:"any",valueCallback:t=>t+1}),month:M({matchPatterns:st,defaultMatchWidth:"wide",parsePatterns:ut,defaultParseWidth:"any"}),day:M({matchPatterns:ct,defaultMatchWidth:"wide",parsePatterns:dt,defaultParseWidth:"any"}),dayPeriod:M({matchPatterns:lt,defaultMatchWidth:"any",parsePatterns:ht,defaultParseWidth:"any"})},ft={code:"en-US",formatDistance:_,formatLong:z,formatRelative:q,localize:$,match:mt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function gt(t,n,e){const r=F(),a=e?.locale??r.locale??ft,s=2520,i=w(t,n);if(isNaN(i))throw new RangeError("Invalid time value");const o=Object.assign({},e,{addSuffix:e?.addSuffix,comparison:i});let l,d;i>0?(l=u(n),d=u(t)):(l=u(t),d=u(n));const h=N(d,l),g=(P(d)-P(l))/1e3,c=Math.round((h-g)/60);let f;if(c<2)return e?.includeSeconds?h<5?a.formatDistance("lessThanXSeconds",5,o):h<10?a.formatDistance("lessThanXSeconds",10,o):h<20?a.formatDistance("lessThanXSeconds",20,o):h<40?a.formatDistance("halfAMinute",0,o):h<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):c===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",c,o);if(c<45)return a.formatDistance("xMinutes",c,o);if(c<90)return a.formatDistance("aboutXHours",1,o);if(c0?1:a}function C(t){return F(t,Date.now())}function X(t,n){const e=u(t),r=u(n),a=e.getFullYear()-r.getFullYear(),s=e.getMonth()-r.getMonth();return a*12+s}function A(t){return n=>{const r=(t?Math[t]:Math.trunc)(n);return r===0?0:r}}function O(t,n){return+u(t)-+u(n)}function N(t){const n=u(t),e=n.getMonth();return n.setFullYear(n.getFullYear(),e+1,0),n.setHours(23,59,59,999),n}function Y(t){const n=u(t);return+S(n)==+N(n)}function _(t,n){const e=u(t),r=u(n),a=w(e,r),s=Math.abs(X(e,r));let i;if(s<1)i=0;else{e.getMonth()===1&&e.getDate()>27&&e.setDate(30),e.setMonth(e.getMonth()-a*s);let o=w(e,r)===-a;Y(u(t))&&s===1&&w(t,r)===1&&(o=!1),i=a*(s-Number(o))}return i===0?0:i}function j(t,n,e){const r=O(t,n)/1e3;return A(e?.roundingMethod)(r)}const I={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},L=(t,n,e)=>{let r;const a=I[t];return typeof a=="string"?r=a:n===1?r=a.one:r=a.other.replace("{{count}}",n.toString()),e?.addSuffix?e.comparison&&e.comparison>0?"in "+r:r+" ago":r};function p(t){return(n={})=>{const e=n.width?String(n.width):t.defaultWidth;return t.formats[e]||t.formats[t.defaultWidth]}}const R={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},q={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},V={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},z={date:p({formats:R,defaultWidth:"full"}),time:p({formats:q,defaultWidth:"full"}),dateTime:p({formats:V,defaultWidth:"full"})},J={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},E=(t,n,e,r)=>J[t];function y(t){return(n,e)=>{const r=e?.context?String(e.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,o=e?.width?String(e.width):i;a=t.formattingValues[o]||t.formattingValues[i]}else{const i=t.defaultWidth,o=e?.width?String(e.width):t.defaultWidth;a=t.values[o]||t.values[i]}const s=t.argumentCallback?t.argumentCallback(n):n;return a[s]}}const H={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Q={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},U={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},B={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},K={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},$={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},G=(t,n)=>{const e=Number(t),r=e%100;if(r>20||r<10)switch(r%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},Z={ordinalNumber:G,era:y({values:H,defaultWidth:"wide"}),quarter:y({values:Q,defaultWidth:"wide",argumentCallback:t=>t-1}),month:y({values:U,defaultWidth:"wide"}),day:y({values:B,defaultWidth:"wide"}),dayPeriod:y({values:K,defaultWidth:"wide",formattingValues:$,defaultFormattingWidth:"wide"})};function M(t){return(n,e={})=>{const r=e.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=n.match(a);if(!s)return null;const i=s[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(o)?et(o,g=>g.test(i)):tt(o,g=>g.test(i));let d;d=t.valueCallback?t.valueCallback(l):l,d=e.valueCallback?e.valueCallback(d):d;const h=n.slice(i.length);return{value:d,rest:h}}}function tt(t,n){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&n(t[e]))return e}function et(t,n){for(let e=0;e{const r=n.match(t.matchPattern);if(!r)return null;const a=r[0],s=n.match(t.parsePattern);if(!s)return null;let i=t.valueCallback?t.valueCallback(s[0]):s[0];i=e.valueCallback?e.valueCallback(i):i;const o=n.slice(a.length);return{value:i,rest:o}}}const at=/^(\d+)(th|st|nd|rd)?/i,rt=/\d+/i,ot={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},it={any:[/^b/i,/^(a|c)/i]},st={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ut={any:[/1/i,/2/i,/3/i,/4/i]},ct={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},dt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},lt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ht={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},mt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ft={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gt={ordinalNumber:nt({matchPattern:at,parsePattern:rt,valueCallback:t=>parseInt(t,10)}),era:M({matchPatterns:ot,defaultMatchWidth:"wide",parsePatterns:it,defaultParseWidth:"any"}),quarter:M({matchPatterns:st,defaultMatchWidth:"wide",parsePatterns:ut,defaultParseWidth:"any",valueCallback:t=>t+1}),month:M({matchPatterns:ct,defaultMatchWidth:"wide",parsePatterns:dt,defaultParseWidth:"any"}),day:M({matchPatterns:lt,defaultMatchWidth:"wide",parsePatterns:ht,defaultParseWidth:"any"}),dayPeriod:M({matchPatterns:mt,defaultMatchWidth:"any",parsePatterns:ft,defaultParseWidth:"any"})},yt={code:"en-US",formatDistance:L,formatLong:z,formatRelative:E,localize:Z,match:gt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Mt(t,n,e){const r=T(),a=e?.locale??r.locale??yt,s=2520,i=w(t,n);if(isNaN(i))throw new RangeError("Invalid time value");const o=Object.assign({},e,{addSuffix:e?.addSuffix,comparison:i});let l,d;i>0?(l=u(n),d=u(t)):(l=u(t),d=u(n));const h=j(d,l),g=(P(d)-P(l))/1e3,c=Math.round((h-g)/60);let f;if(c<2)return e?.includeSeconds?h<5?a.formatDistance("lessThanXSeconds",5,o):h<10?a.formatDistance("lessThanXSeconds",10,o):h<20?a.formatDistance("lessThanXSeconds",20,o):h<40?a.formatDistance("halfAMinute",0,o):h<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):c===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",c,o);if(c<45)return a.formatDistance("xMinutes",c,o);if(c<90)return a.formatDistance("aboutXHours",1,o);if(c{switch(t){case"achievement_unlocked":case"achievement":return"bg-rose-500/10 text-rose-600";case"xp_earned":return"bg-amber-500/10 text-amber-600";case"daily_checkin":case"checkin":return"bg-emerald-500/10 text-emerald-600";case"streak_milestone":case"streak_reminder":return"bg-orange-500/10 text-orange-600";case"teacher_announcement":return"bg-violet-500/10 text-violet-600";case"new_assignment":case"quiz_result":return"bg-sky-500/10 text-sky-600";case"level_up":return"bg-indigo-500/10 text-indigo-600";case"system_alert":return"bg-red-500/10 text-red-600";default:return"bg-[#edf1f7] text-[#5a6578]"}},T=({notification:t})=>{const{markAsRead:r,deleteNotification:a}=m(),o=R[t.type]||d,i=L(t.type),n=()=>{if(t.isRead||r(t.id),t.type==="streak_reminder"||t.type==="daily_checkin"){window.dispatchEvent(new CustomEvent("mathpulse:navigate",{detail:{tab:"Modules"}}));return}t.actionUrl&&(window.location.href=t.actionUrl)},l=N(t.createdAt,{addSuffix:!0});return e.jsx("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),n())},className:`group text-left p-4 border-b border-[#dde3eb] cursor-pointer transition-colors hover:bg-[#edf1f7]/50 ${t.isRead?"":"bg-sky-50/40"}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${i}`,children:e.jsx(o,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] line-clamp-1 font-body",children:t.title}),!t.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sky-600 flex-shrink-0 mt-1.5"})]}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2 line-clamp-2 font-body",children:t.message}),e.jsx("p",{className:"text-xs text-slate-500",children:l})]}),e.jsx("button",{onClick:s=>{s.stopPropagation(),a(t.id)},className:"opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500","aria-label":"Delete notification",children:e.jsx(w,{size:14})})]})})},A=({onClose:t})=>{const{notifications:r,unreadCount:a,isLoading:o,markAllAsRead:i}=m(),n=c.useRef(null);c.useEffect(()=>{const s=x=>{n.current&&!n.current.contains(x.target)&&t()};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const l=e.jsxs("div",{ref:n,className:"fixed right-4 top-20 w-80 bg-[#f7f9fc] rounded-xl shadow-2xl border border-[#dde3eb] max-h-96 overflow-y-auto z-[9999] overflow-hidden",style:{right:"1rem",top:"5rem"},children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between bg-gradient-to-r from-sky-600 to-sky-500",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-white text-sm",children:"Notifications"}),e.jsx("p",{className:"text-xs text-sky-100 mt-0.5",children:a>0?`${a} unread`:"No new alerts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsxs("button",{onClick:i,className:"text-xs text-sky-200 hover:text-white font-bold transition-colors flex items-center gap-1",children:[e.jsx(_,{size:14}),"Mark all read"]}),e.jsx("button",{onClick:t,className:"text-sky-200 hover:text-white transition-colors",title:"Close",children:e.jsx(C,{size:16})})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto",children:o?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(s=>e.jsx("div",{className:"animate-pulse bg-[#dde3eb] rounded h-12"},s))}):r.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(d,{size:48,className:"text-[#d1cec6] mx-auto mb-3"}),e.jsx("p",{className:"text-[#5a6578] text-sm font-body",children:"You're all caught up!"})]}):r.map(s=>e.jsx(T,{notification:s},s.id))})]});return v.createPortal(l,document.body)},J=()=>{const{unreadCount:t}=m(),[r,a]=c.useState(!1),o=c.useRef(null);c.useEffect(()=>{const n=l=>{o.current&&!o.current.contains(l.target)&&a(!1)};return r&&document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[r]);const i=t>99?"99+":t.toString();return e.jsxs("div",{ref:o,className:"relative",children:[e.jsxs("button",{onClick:()=>a(!r),className:"relative p-3 bg-[#edf1f7] rounded-xl text-[#5a6578] hover:bg-[#dde3eb] transition-colors","aria-label":"Notifications","aria-expanded":r,"aria-haspopup":"true",children:[e.jsx(d,{size:20}),t>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1",children:i})]}),r&&e.jsx(A,{onClose:()=>a(!1)})]})};export{J as NotificationBell,ee as NotificationProvider,te as notify,m as useNotifications}; + */const E=[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]],z=u("megaphone",E),R={achievement_unlocked:g,level_up:b,quiz_result:j,daily_checkin:k,streak_milestone:f,streak_reminder:d,teacher_announcement:z,new_assignment:h,xp_earned:p,system_alert:y},L=t=>{switch(t){case"achievement_unlocked":case"achievement":return"bg-rose-500/10 text-rose-600";case"xp_earned":return"bg-amber-500/10 text-amber-600";case"daily_checkin":case"checkin":return"bg-emerald-500/10 text-emerald-600";case"streak_milestone":case"streak_reminder":return"bg-orange-500/10 text-orange-600";case"teacher_announcement":return"bg-violet-500/10 text-violet-600";case"new_assignment":case"quiz_result":return"bg-sky-500/10 text-sky-600";case"level_up":return"bg-indigo-500/10 text-indigo-600";case"system_alert":return"bg-red-500/10 text-red-600";default:return"bg-[#edf1f7] text-[#5a6578]"}},T=({notification:t})=>{const{markAsRead:r,deleteNotification:a}=m(),o=R[t.type]||d,i=L(t.type),n=()=>{if(t.isRead||r(t.id),t.type==="streak_reminder"||t.type==="daily_checkin"){window.dispatchEvent(new CustomEvent("mathpulse:navigate",{detail:{tab:"Modules"}}));return}t.actionUrl&&(window.location.href=t.actionUrl)},l=N(t.createdAt,{addSuffix:!0});return e.jsx("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),n())},className:`group text-left p-4 border-b border-[#dde3eb] cursor-pointer transition-colors hover:bg-[#edf1f7]/50 ${t.isRead?"":"bg-sky-50/40"}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${i}`,children:e.jsx(o,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-bold text-[#0a1628] line-clamp-1 font-body",children:t.title}),!t.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sky-600 flex-shrink-0 mt-1.5"})]}),e.jsx("p",{className:"text-xs text-[#5a6578] mb-2 line-clamp-2 font-body",children:t.message}),e.jsx("p",{className:"text-xs text-slate-500",children:l})]}),e.jsx("button",{onClick:s=>{s.stopPropagation(),a(t.id)},className:"opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500","aria-label":"Delete notification",children:e.jsx(_,{size:14})})]})})},A=({onClose:t})=>{const{notifications:r,unreadCount:a,isLoading:o,markAllAsRead:i}=m(),n=c.useRef(null);c.useEffect(()=>{const s=x=>{n.current&&!n.current.contains(x.target)&&t()};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const l=e.jsxs("div",{ref:n,className:"fixed right-4 top-20 w-80 bg-[#f7f9fc] rounded-xl shadow-2xl border border-[#dde3eb] max-h-96 overflow-y-auto z-[9999] overflow-hidden",style:{right:"1rem",top:"5rem"},children:[e.jsxs("div",{className:"p-4 border-b border-[#dde3eb] flex items-center justify-between bg-gradient-to-r from-sky-600 to-sky-500",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-bold text-white text-sm",children:"Notifications"}),e.jsx("p",{className:"text-xs text-sky-100 mt-0.5",children:a>0?`${a} unread`:"No new alerts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsxs("button",{onClick:i,className:"text-xs text-sky-200 hover:text-white font-bold transition-colors flex items-center gap-1",children:[e.jsx(w,{size:14}),"Mark all read"]}),e.jsx("button",{onClick:t,className:"text-sky-200 hover:text-white transition-colors",title:"Close",children:e.jsx(C,{size:16})})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto",children:o?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(s=>e.jsx("div",{className:"animate-pulse bg-[#dde3eb] rounded h-12"},s))}):r.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(d,{size:48,className:"text-[#d1cec6] mx-auto mb-3"}),e.jsx("p",{className:"text-[#5a6578] text-sm font-body",children:"You're all caught up!"})]}):r.map(s=>e.jsx(T,{notification:s},s.id))})]});return v.createPortal(l,document.body)},H=()=>{const{unreadCount:t}=m(),[r,a]=c.useState(!1),o=c.useRef(null);c.useEffect(()=>{const n=l=>{o.current&&!o.current.contains(l.target)&&a(!1)};return r&&document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[r]);const i=t>99?"99+":t.toString();return e.jsxs("div",{ref:o,className:"relative",children:[e.jsxs("button",{onClick:()=>a(!r),className:"relative p-3 bg-[#edf1f7] rounded-xl text-[#5a6578] hover:bg-[#dde3eb] transition-colors","aria-label":"Notifications","aria-expanded":r,"aria-haspopup":"true",children:[e.jsx(d,{size:20}),t>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1",children:i})]}),r&&e.jsx(A,{onClose:()=>a(!1)})]})};export{H as NotificationBell,W as NotificationProvider,ee as notify,m as useNotifications}; diff --git a/assets/index-mbyiCUYG.js b/assets/index-B3ruOzo6.js similarity index 69% rename from assets/index-mbyiCUYG.js rename to assets/index-B3ruOzo6.js index 0c86914f17f2f49677169e41b4ae819e2fe40e00..9627c75ab3ff2bd582f55ba1c0a3ef05956d0741 100644 --- a/assets/index-mbyiCUYG.js +++ b/assets/index-B3ruOzo6.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/automationService-pLIzsro_.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.js","assets/vendor-radix-xDOIcVzp.js","assets/vendor-charts-Ckgeb0nY.js","assets/vendor-markdown-yqZQ_iQm.js","assets/vendor-markdown-CfVKi3_s.css","assets/chatService-BuuZ3z6i.js","assets/trackingService-DJ_reXHi.js","assets/LoginPage-CqIFZBqL.js","assets/button-BqKfG4Jj.js","assets/input-DEPoMoHZ.js","assets/sparkles-THbTTiEe.js","assets/mail-DWQ9UHXG.js","assets/eye-DakyBxPE.js","assets/TeacherDashboard-DH_EClon.js","assets/ConfirmModal-BsY1WFdG.js","assets/x-oZO0Ye1Q.js","assets/trash-2-8qZ3aehj.js","assets/log-out-Ddy014zi.js","assets/check-check-wBIDWtv-.js","assets/formatDistanceToNow-B_Ixh2wt.js","assets/bell-D_pyutJs.js","assets/circle-check-BENuYz-J.js","assets/circle-alert-CJ47UAgT.js","assets/LogoutActionButton-DQLJH-aF.js","assets/quizService-CjK9zjBp.js","assets/tooltip-Cd2m83Wr.js","assets/circle-help-BP0kOuya.js","assets/send-iW1LmVFw.js","assets/check-BLN5Dl8e.js","assets/trending-down-DaPJgM3L.js","assets/chevron-up-B_-cQcm8.js","assets/minus-BEbLkPkH.js","assets/plus-CbpDHvDO.js","assets/chart-column-B4tQNTpN.js","assets/history-CUgB1MuD.js","assets/download-C2PVrIq3.js","assets/chevron-left-BYtw_nqd.js","assets/chevron-right-bwYIKoxv.js","assets/save-DgO_wXsk.js","assets/search-F2fS74Xk.js","assets/upload-CKMt4jtd.js","assets/useQuery-L70l-ukL.js","assets/subjects-BGUwH4Kn.js","assets/useCurriculum-uUEvXpH4.js","assets/circle-check-big-BnoZ8KZB.js","assets/ChatMarkdown-vDoOnX8q.js","assets/clock-BLtPbCgT.js","assets/dialog-fiLCzxmY.js","assets/skeleton-Br1snihA.js","assets/vendor-xlsx-uZelXSz_.js","assets/clipboard-check-BB6UVEW1.js","assets/AdminDashboard-B7yRI4wL.js","assets/Sidebar-CnFPEtsr.js","assets/shirt-nq7Lov7c.js","assets/select-B04HpeAZ.js","assets/lightbulb-D-SuIyuF.js","assets/switch-CHYfNJFI.js","assets/funnel-DxfPBPvT.js","assets/useSubjectAvailability-CN1BUyIM.js","assets/HeroBanner-Co1DN6x_.js","assets/RightSidebar-C9HBuSrc.js","assets/quiz_battle_avatar-BXHPSput.js","assets/XPNotification-B5D6Y4_2.js","assets/index-sdjpVDKv.js","assets/SupplementalBanner-DX4KIC1c.js","assets/SupplementalPillCarousel-BcOOOGo2.js","assets/LearningPath-B69Oihj_.js","assets/ModuleFolderCard-BQjDrVls.js","assets/CompetencyRadarChart-CB4_VQS8.js","assets/ModulesPage-CyxYQpv4.js","assets/ScientificCalculator-C3ad9xEg.js","assets/volume-x-R52lt03l.js","assets/confetti.module-C94ZD2ww.js","assets/AIChatPage-C5Aol7Ef.js","assets/GradesPage-wWFYB1uJ.js","assets/LeaderboardPage-CoNMThBG.js","assets/useFeatureAccess-CbliO-_q.js","assets/QuizBattlePage-B6iQUgiR.js","assets/CompositeAvatar-Col05lJc.js","assets/avatarData-BuQSOXo3.js","assets/AvatarShop-AFWgueuK.js","assets/FloatingAITutor-CSSEfiYF.js","assets/maximize-2-BqKWV1Bn.js","assets/RewardsModal-gGwAMPUb.js","assets/ProfileModal-BLj_o7UC.js","assets/ProfilePictureUploader-Byg9gnjl.js","assets/SettingsModal-CQfmcUsu.js","assets/InitialAssessmentModal-BbFsU9kR.js","assets/diagnosticService-D1BQOFa3.js","assets/AssessmentPage-D98zS7Za.js","assets/testResetService-D3s6D6jU.js"])))=>i.map(i=>d[i]); -import{r as h,j as b,d as _,c as Lf,f as Of}from"./vendor-react-B4AQeu28.js";import{persistentLocalCache as Za,initializeFirestore as eo,setDoc as Ie,doc as G,serverTimestamp as ae,getDoc as ge,getDocFromServer as ui,onSnapshot as rn,query as Dt,limit as Yn,orderBy as Sn,collection as We,getDocs as Tn,updateDoc as Tt,arrayUnion as Cc,where as Mt,increment as zn,deleteDoc as di,Timestamp as jn,runTransaction as Nf}from"./vendor-firebase-firestore-CP9q7ISf.js";import{U as jf,V as Ff,Y as Vf,Z as Bf,$ as $f,a0 as zf,a1 as Uf,a2 as qf,a3 as Gf}from"./vendor-firebase-core-DCQrgkxC.js";import{browserLocalPersistence as to,initializeAuth as no,browserSessionPersistence as Hf,inMemoryPersistence as so,GoogleAuthProvider as Wf,createUserWithEmailAndPassword as Kf,updateProfile as Qf,signInWithEmailAndPassword as Xf,signOut as Yf,onAuthStateChanged as Jf,updatePassword as Zf,updateEmail as eh,deleteUser as th,EmailAuthProvider as nh,reauthenticateWithCredential as sh}from"./vendor-firebase-auth-Bcpr4O6E.js";import{g as rh}from"./vendor-firebase-storage-dc5X5yTv.js";import{g as ih}from"./vendor-firebase-analytics-CHPyhRzk.js";import{R as ah,I as oh,F as lh}from"./vendor-radix-xDOIcVzp.js";import{c as ch}from"./vendor-charts-Ckgeb0nY.js";import"./vendor-markdown-yqZQ_iQm.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var sr=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(){}},uh=class extends sr{#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"}},Pc=new uh,dh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},fh=class{#e=dh;#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)}},fi=new fh;function hh(e){setTimeout(e,0)}var mh=typeof window>"u"||"Deno"in globalThis;function lt(){}function ph(e,t){return typeof e=="function"?e(t):e}function gh(e){return typeof e=="number"&&e>=0&&e!==1/0}function yh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hi(e,t){return typeof e=="function"?e(t):e}function bh(e,t){return typeof e=="function"?e(t):e}function ro(e,t){const{type:n="all",exact:s,fetchStatus:r,predicate:i,queryKey:a,stale:o}=e;if(a){if(s){if(t.queryHash!==Yi(a,t.options))return!1}else if(!qn(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||r&&r!==t.state.fetchStatus||i&&!i(t))}function io(e,t){const{exact:n,status:s,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Un(t.options.mutationKey)!==Un(i))return!1}else if(!qn(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Yi(e,t){return(t?.queryKeyHashFn||Un)(e)}function Un(e){return JSON.stringify(e,(t,n)=>mi(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}function qn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qn(e[n],t[n])):!1}var vh=Object.prototype.hasOwnProperty;function Ec(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=ao(e)&&ao(t);if(!s&&!(mi(e)&&mi(t)))return t;const i=(s?e:Object.keys(e)).length,a=s?t:Object.keys(t),o=a.length,l=s?new Array(o):{};let d=0;for(let u=0;u{fi.setTimeout(t,e)})}function xh(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Ec(e,t):t}function Sh(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Th(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var Ji=Symbol();function kc(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ji?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cC(e,t){return typeof e=="function"?e(...t):!!e}function Ch(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 Ac=(()=>{let e=()=>mh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ph(){let e,t;const n=new Promise((r,i)=>{e=r,t=i});n.status="pending",n.catch(()=>{});function s(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},n.reject=r=>{s({status:"rejected",reason:r}),t(r)},n}var Eh=hh;function kh(){let e=[],t=0,n=o=>{o()},s=o=>{o()},r=Eh;const i=o=>{t?e.push(o):r(()=>{n(o)})},a=()=>{const o=e;e=[],o.length&&r(()=>{s(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;t++;try{l=o()}finally{t--,t||a()}return l},batchCalls:o=>(...l)=>{i(()=>{o(...l)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{s=o},setScheduler:o=>{r=o}}}var ze=kh(),Ah=class extends sr{#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}},zs=new Ah;function Rh(e){return Math.min(1e3*2**e,3e4)}function Rc(e){return(e??"online")==="online"?zs.isOnline():!0}var pi=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Mc(e){let t=!1,n=0,s;const r=Ph(),i=()=>r.status!=="pending",a=y=>{if(!i()){const g=new pi(y);f(g),e.onCancel?.(g)}},o=()=>{t=!0},l=()=>{t=!1},d=()=>Pc.isFocused()&&(e.networkMode==="always"||zs.isOnline())&&e.canRun(),u=()=>Rc(e.networkMode)&&e.canRun(),c=y=>{i()||(s?.(),r.resolve(y))},f=y=>{i()||(s?.(),r.reject(y))},m=()=>new Promise(y=>{s=g=>{(i()||d())&&y(g)},e.onPause?.()}).then(()=>{s=void 0,i()||e.onContinue?.()}),p=()=>{if(i())return;let y;const g=n===0?e.initialPromise:void 0;try{y=g??e.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(c).catch(v=>{if(i())return;const T=e.retry??(Ac.isServer()?0:3),x=e.retryDelay??Rh,S=typeof x=="function"?x(n,v):x,C=T===!0||typeof T=="number"&&nd()?void 0:m()).then(()=>{t?f(v):p()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(s?.(),r),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?p():m().then(p),r)}}var _c=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),gh(this.gcTime)&&(this.#e=fi.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ac.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(fi.clearTimeout(this.#e),this.#e=void 0)}};function Mh(e){return{onFetch:(t,n)=>{const s=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const c=p=>{Ch(p,()=>t.signal,()=>u=!0)},f=kc(t.options,t.fetchOptions),m=async(p,y,g)=>{if(u)return Promise.reject(t.signal.reason);if(y==null&&p.pages.length)return Promise.resolve(p);const T=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:y,direction:g?"backward":"forward",meta:t.options.meta};return c(P),P})(),x=await f(T),{maxPages:S}=t.options,C=g?Th:Sh;return{pages:C(p.pages,x,S),pageParams:C(p.pageParams,y,S)}};if(r&&i.length){const p=r==="backward",y=p?_h:lo,g={pages:i,pageParams:a},v=y(s,g);o=await m(g,v,p)}else{const p=e??i.length;do{const y=l===0?a[0]??s.initialPageParam:lo(s,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(lt.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function lo(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 _h(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ih=class extends _c{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e){super(),this.#a=!1,this.#l=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=uo(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#s?.promise}setOptions(e){if(this.options={...this.#l,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=uo(this.options);t.data!==void 0&&(this.setState(co(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=xh(this.state.data,e,this.options);return this.#o({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#o({type:"setState",state:e})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(lt).catch(lt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>bh(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ji||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>hi(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:!yh(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#a||this.#c()?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#s?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(d=>d.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,s=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},r=()=>{const l=kc(this.options,t),u=(()=>{const c={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(c),c})();return this.#a=!1,this.options.persister?this.options.persister(l,u,this):l(u)},a=(()=>{const l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:r};return s(l),l})();(this.#e==="infinite"?Mh(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#o({type:"fetch",meta:a.fetchOptions?.meta}),this.#s=Mc({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:l=>{l instanceof pi&&l.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(l,d)=>{this.#o({type:"failed",failureCount:l,error:d})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const l=await this.#s.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#r.config.onSuccess?.(l,this),this.#r.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof pi){if(l.silent)return this.#s.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#o({type:"error",error:l}),this.#r.config.onError?.(l,this),this.#r.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#o(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Dh(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,...co(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 Dh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Rc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function co(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function uo(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 Lh=class extends _c{#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||Oh(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#i({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Mc({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const s=this.state.status==="pending",r=!this.#r.canStart();try{if(s)t();else{this.#i({type:"pending",variables:e,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:r})}const i=await this.#r.start();return await this.#n.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#n.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#i({type:"success",data:i}),i}catch(i){try{await this.#n.config.onError?.(i,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#n.runNext(this)}}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function Oh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nh=class extends sr{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 Lh({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(s),s}add(e){this.#e.add(e);const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=hs(e);if(typeof t=="string"){const s=this.#t.get(t)?.find(r=>r.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=hs(e);return typeof t=="string"?this.#t.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>io(t,n))}findAll(e={}){return this.getAll().filter(t=>io(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(lt))))}};function hs(e){return e.options.scope?.id}var jh=class extends sr{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const s=t.queryKey,r=t.queryHash??Yi(s,t);let i=this.get(r);return i||(i=new Ih({client:e,queryKey:s,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>ro(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>ro(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()})})}},Fh=class{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e={}){this.#e=e.queryCache||new jh,this.#t=e.mutationCache||new Nh,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#l=Pc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=zs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#l?.(),this.#l=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(hi(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(s.queryHash)?.state.data,a=ph(t,i);if(a!==void 0)return this.#e.build(this,s).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=ze.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(s).then(lt).catch(lt)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=ze.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(lt)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(lt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(hi(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(lt).catch(lt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(lt).catch(lt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return zs.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Un(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(s=>{qn(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Un(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(s=>{qn(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Yi(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===Ji&&(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()}},Ic=h.createContext(void 0),uC=e=>{const t=h.useContext(Ic);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Vh=({client:e,children:t})=>(h.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Ic.Provider,{value:e,children:t}));/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/automationService-JEEI7dc9.js","assets/vendor-firebase-firestore-CP9q7ISf.js","assets/vendor-firebase-core-DCQrgkxC.js","assets/vendor-react-B4AQeu28.js","assets/vendor-firebase-auth-Bcpr4O6E.js","assets/vendor-firebase-storage-dc5X5yTv.js","assets/vendor-firebase-analytics-CHPyhRzk.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-oZskyXOh.js","assets/trackingService-D4gZcipe.js","assets/LoginPage-CptqcE8b.js","assets/button-CaSK4KoS.js","assets/input-kh84w1XK.js","assets/sparkles-Bq0AaIRg.js","assets/mail-BXNRz1ib.js","assets/eye-WyNbhirJ.js","assets/shield-check-Cwi1kdxV.js","assets/TeacherDashboard-DyMHG-dm.js","assets/ConfirmModal-BjVnuYqC.js","assets/x-BNHnAXzL.js","assets/trash-2-CjkT7lLr.js","assets/log-out-CoRJnfoO.js","assets/NotificationDropdown-IzxN6ZqA.js","assets/formatDistanceToNow-DTsqWUq4.js","assets/bell-Bp_utT8v.js","assets/circle-check-DyFN6-07.js","assets/circle-alert-CTR2Lqp7.js","assets/LogoutActionButton-D5BV__Zd.js","assets/quizService-Bqc478Xh.js","assets/tooltip-CLSYbTYK.js","assets/circle-help-C5HGdkRZ.js","assets/send-CTO7uejQ.js","assets/check-6eXlU5jr.js","assets/chevron-up-CTb5_AvY.js","assets/minus-B69_eMXI.js","assets/plus-Dx0gdu7_.js","assets/chart-column-C9VTl-3A.js","assets/skeleton-B6L2gPDz.js","assets/download-BbFDZT3H.js","assets/pen-tool-BelhGWFu.js","assets/chevron-left-Cr0wYLQi.js","assets/chevron-right-CbkkCalp.js","assets/save-DXz2z5YH.js","assets/search-DeasjpAx.js","assets/upload-BBhypj4u.js","assets/subjects-DEj_AlYz.js","assets/useCurriculum-CQZ78SzC.js","assets/circle-check-big-CWdn1Nqf.js","assets/ChatMarkdown-BWVWW9Zs.js","assets/clock-C73na4Cu.js","assets/dialog-KaD0jw5O.js","assets/vendor-xlsx-uZelXSz_.js","assets/clipboard-check-Bv_xk-Mp.js","assets/AdminDashboard-C9BDGBhi.js","assets/Sidebar-1AFatJJg.js","assets/shirt-BBR3GIpi.js","assets/select-C142YWNr.js","assets/shield-alert-kYf2Mbtd.js","assets/switch-UwrfTEB3.js","assets/useSubjectAvailability-D7FKRlYS.js","assets/HeroBanner-DPijLb9x.js","assets/RightSidebar-GlSyU02g.js","assets/quiz_battle_avatar-BXHPSput.js","assets/XPNotification-Doid3miV.js","assets/index-B0ICny8Z.js","assets/SupplementalBanner-BaFvS7H9.js","assets/SupplementalPillCarousel-Dxq4aiMj.js","assets/LearningPath-BIfd3u7Y.js","assets/ModuleFolderCard-DKst1S7k.js","assets/CompetencyRadarChart-C3fx_ulE.js","assets/ModulesPage-D_ceNMZi.js","assets/ScientificCalculator-C0Zl3TP5.js","assets/volume-x-z-Eai_Ym.js","assets/confetti.module-C94ZD2ww.js","assets/funnel-8X5OzLOw.js","assets/AIChatPage-BEC3mijo.js","assets/GradesPage-CU5DI0dR.js","assets/LeaderboardPage-BGY9czx-.js","assets/useFeatureAccess-CSvNejlY.js","assets/QuizBattlePage-CgKinHpO.js","assets/CompositeAvatar-Col05lJc.js","assets/avatarData-BuQSOXo3.js","assets/AvatarShop-CAPwOQHq.js","assets/FloatingAITutor-BkNIiXkv.js","assets/maximize-2-Cr4HMoWg.js","assets/RewardsModal-DfvIngtK.js","assets/ProfileModal-xyqhi5Hx.js","assets/ProfilePictureUploader-B3ToJmez.js","assets/SettingsModal-DILgCJsp.js","assets/InitialAssessmentModal-C4M589Rr.js","assets/diagnosticService-CLsUcd9M.js","assets/AssessmentPage-DI0qCtR6.js","assets/testResetService-Wp_VTbZ9.js"])))=>i.map(i=>d[i]); +import{r as h,j as b,d as _,c as Lf,f as Of}from"./vendor-react-B4AQeu28.js";import{persistentLocalCache as Za,initializeFirestore as eo,setDoc as Ie,doc as G,serverTimestamp as ae,getDoc as ge,getDocFromServer as ui,onSnapshot as rn,query as Dt,limit as Yn,orderBy as Sn,collection as We,getDocs as Tn,updateDoc as Tt,arrayUnion as Cc,where as Mt,increment as zn,deleteDoc as di,Timestamp as jn,runTransaction as Nf}from"./vendor-firebase-firestore-CP9q7ISf.js";import{U as jf,V as Ff,Y as Vf,Z as $f,$ as Bf,a0 as zf,a1 as Uf,a2 as qf,a3 as Gf}from"./vendor-firebase-core-DCQrgkxC.js";import{browserLocalPersistence as to,initializeAuth as no,browserSessionPersistence as Hf,inMemoryPersistence as so,GoogleAuthProvider as Wf,createUserWithEmailAndPassword as Kf,updateProfile as Qf,signInWithEmailAndPassword as Xf,signOut as Yf,onAuthStateChanged as Jf,updatePassword as Zf,updateEmail as eh,deleteUser as th,EmailAuthProvider as nh,reauthenticateWithCredential as sh}from"./vendor-firebase-auth-Bcpr4O6E.js";import{g as rh}from"./vendor-firebase-storage-dc5X5yTv.js";import{g as ih}from"./vendor-firebase-analytics-CHPyhRzk.js";import{R as ah,I as oh,F as lh}from"./vendor-radix-BPuEd8FG.js";import{c as ch}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 i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var sr=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(){}},uh=class extends sr{#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"}},Pc=new uh,dh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},fh=class{#e=dh;#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)}},fi=new fh;function hh(e){setTimeout(e,0)}var mh=typeof window>"u"||"Deno"in globalThis;function lt(){}function ph(e,t){return typeof e=="function"?e(t):e}function gh(e){return typeof e=="number"&&e>=0&&e!==1/0}function yh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hi(e,t){return typeof e=="function"?e(t):e}function bh(e,t){return typeof e=="function"?e(t):e}function ro(e,t){const{type:n="all",exact:s,fetchStatus:r,predicate:i,queryKey:a,stale:o}=e;if(a){if(s){if(t.queryHash!==Yi(a,t.options))return!1}else if(!qn(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||r&&r!==t.state.fetchStatus||i&&!i(t))}function io(e,t){const{exact:n,status:s,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Un(t.options.mutationKey)!==Un(i))return!1}else if(!qn(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Yi(e,t){return(t?.queryKeyHashFn||Un)(e)}function Un(e){return JSON.stringify(e,(t,n)=>mi(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}function qn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qn(e[n],t[n])):!1}var vh=Object.prototype.hasOwnProperty;function Ec(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=ao(e)&&ao(t);if(!s&&!(mi(e)&&mi(t)))return t;const i=(s?e:Object.keys(e)).length,a=s?t:Object.keys(t),o=a.length,l=s?new Array(o):{};let d=0;for(let u=0;u{fi.setTimeout(t,e)})}function xh(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Ec(e,t):t}function Sh(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Th(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var Ji=Symbol();function kc(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ji?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cC(e,t){return typeof e=="function"?e(...t):!!e}function Ch(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 Ac=(()=>{let e=()=>mh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ph(){let e,t;const n=new Promise((r,i)=>{e=r,t=i});n.status="pending",n.catch(()=>{});function s(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},n.reject=r=>{s({status:"rejected",reason:r}),t(r)},n}var Eh=hh;function kh(){let e=[],t=0,n=o=>{o()},s=o=>{o()},r=Eh;const i=o=>{t?e.push(o):r(()=>{n(o)})},a=()=>{const o=e;e=[],o.length&&r(()=>{s(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;t++;try{l=o()}finally{t--,t||a()}return l},batchCalls:o=>(...l)=>{i(()=>{o(...l)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{s=o},setScheduler:o=>{r=o}}}var ze=kh(),Ah=class extends sr{#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}},zs=new Ah;function Rh(e){return Math.min(1e3*2**e,3e4)}function Rc(e){return(e??"online")==="online"?zs.isOnline():!0}var pi=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Mc(e){let t=!1,n=0,s;const r=Ph(),i=()=>r.status!=="pending",a=y=>{if(!i()){const g=new pi(y);f(g),e.onCancel?.(g)}},o=()=>{t=!0},l=()=>{t=!1},d=()=>Pc.isFocused()&&(e.networkMode==="always"||zs.isOnline())&&e.canRun(),u=()=>Rc(e.networkMode)&&e.canRun(),c=y=>{i()||(s?.(),r.resolve(y))},f=y=>{i()||(s?.(),r.reject(y))},m=()=>new Promise(y=>{s=g=>{(i()||d())&&y(g)},e.onPause?.()}).then(()=>{s=void 0,i()||e.onContinue?.()}),p=()=>{if(i())return;let y;const g=n===0?e.initialPromise:void 0;try{y=g??e.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(c).catch(v=>{if(i())return;const T=e.retry??(Ac.isServer()?0:3),x=e.retryDelay??Rh,S=typeof x=="function"?x(n,v):x,C=T===!0||typeof T=="number"&&nd()?void 0:m()).then(()=>{t?f(v):p()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(s?.(),r),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?p():m().then(p),r)}}var _c=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),gh(this.gcTime)&&(this.#e=fi.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ac.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(fi.clearTimeout(this.#e),this.#e=void 0)}};function Mh(e){return{onFetch:(t,n)=>{const s=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const c=p=>{Ch(p,()=>t.signal,()=>u=!0)},f=kc(t.options,t.fetchOptions),m=async(p,y,g)=>{if(u)return Promise.reject(t.signal.reason);if(y==null&&p.pages.length)return Promise.resolve(p);const T=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:y,direction:g?"backward":"forward",meta:t.options.meta};return c(P),P})(),x=await f(T),{maxPages:S}=t.options,C=g?Th:Sh;return{pages:C(p.pages,x,S),pageParams:C(p.pageParams,y,S)}};if(r&&i.length){const p=r==="backward",y=p?_h:lo,g={pages:i,pageParams:a},v=y(s,g);o=await m(g,v,p)}else{const p=e??i.length;do{const y=l===0?a[0]??s.initialPageParam:lo(s,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(lt.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function lo(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 _h(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ih=class extends _c{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e){super(),this.#a=!1,this.#l=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=uo(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#s?.promise}setOptions(e){if(this.options={...this.#l,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=uo(this.options);t.data!==void 0&&(this.setState(co(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=xh(this.state.data,e,this.options);return this.#o({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#o({type:"setState",state:e})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(lt).catch(lt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>bh(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ji||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>hi(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:!yh(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#a||this.#c()?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#s?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(d=>d.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,s=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},r=()=>{const l=kc(this.options,t),u=(()=>{const c={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(c),c})();return this.#a=!1,this.options.persister?this.options.persister(l,u,this):l(u)},a=(()=>{const l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:r};return s(l),l})();(this.#e==="infinite"?Mh(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#o({type:"fetch",meta:a.fetchOptions?.meta}),this.#s=Mc({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:l=>{l instanceof pi&&l.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(l,d)=>{this.#o({type:"failed",failureCount:l,error:d})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const l=await this.#s.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#r.config.onSuccess?.(l,this),this.#r.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof pi){if(l.silent)return this.#s.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#o({type:"error",error:l}),this.#r.config.onError?.(l,this),this.#r.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#o(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Dh(n.data,this.options),fetchMeta:e.meta??null};case"success":const s={...n,...co(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 Dh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Rc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function co(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function uo(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 Lh=class extends _c{#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||Oh(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#i({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Mc({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const s=this.state.status==="pending",r=!this.#r.canStart();try{if(s)t();else{this.#i({type:"pending",variables:e,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:r})}const i=await this.#r.start();return await this.#n.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#n.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#i({type:"success",data:i}),i}catch(i){try{await this.#n.config.onError?.(i,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#n.runNext(this)}}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function Oh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nh=class extends sr{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 Lh({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(s),s}add(e){this.#e.add(e);const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=hs(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=hs(e);if(typeof t=="string"){const s=this.#t.get(t)?.find(r=>r.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=hs(e);return typeof t=="string"?this.#t.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>io(t,n))}findAll(e={}){return this.getAll().filter(t=>io(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(lt))))}};function hs(e){return e.options.scope?.id}var jh=class extends sr{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const s=t.queryKey,r=t.queryHash??Yi(s,t);let i=this.get(r);return i||(i=new Ih({client:e,queryKey:s,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>ro(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>ro(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()})})}},Fh=class{#e;#t;#n;#r;#i;#s;#l;#a;constructor(e={}){this.#e=e.queryCache||new jh,this.#t=e.mutationCache||new Nh,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#l=Pc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=zs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#l?.(),this.#l=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(hi(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(s.queryHash)?.state.data,a=ph(t,i);if(a!==void 0)return this.#e.build(this,s).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=ze.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(s).then(lt).catch(lt)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=ze.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(lt)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(lt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(hi(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(lt).catch(lt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(lt).catch(lt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return zs.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Un(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(s=>{qn(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Un(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(s=>{qn(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Yi(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===Ji&&(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()}},Ic=h.createContext(void 0),uC=e=>{const t=h.useContext(Ic);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Vh=({client:e,children:t})=>(h.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Ic.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 _,c as Lf,f as Of}from"./vendor-react-B4AQeu28.js";imp * LICENSE.md file in the root directory of this source tree. * * @license MIT - */var fo="popstate";function ho(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Bh(e={}){function t(s,r){let i=r.state?.masked,{pathname:a,search:o,hash:l}=i||s.location;return gi("",{pathname:a,search:o,hash:l},r.state&&r.state.usr||null,r.state&&r.state.key||"default",i?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,r){return typeof r=="string"?r:Gn(r)}return zh(t,n,null,e)}function Ae(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function wt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function $h(){return Math.random().toString(36).substring(2,10)}function mo(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 gi(e,t,n=null,s,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jn(t):t,state:n,key:t&&t.key||s||$h(),unstable_mask:r}}function Gn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function zh(e,t,n,s={}){let{window:r=document.defaultView,v5Compat:i=!1}=s,a=r.history,o="POP",l=null,d=u();d==null&&(d=0,a.replaceState({...a.state,idx:d},""));function u(){return(a.state||{idx:null}).idx}function c(){o="POP";let g=u(),v=g==null?null:g-d;d=g,l&&l({action:o,location:y.location,delta:v})}function f(g,v){o="PUSH";let T=ho(g)?g:gi(y.location,g,v);d=u()+1;let x=mo(T,d),S=y.createHref(T.unstable_mask||T);try{a.pushState(x,"",S)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;r.location.assign(S)}i&&l&&l({action:o,location:y.location,delta:1})}function m(g,v){o="REPLACE";let T=ho(g)?g:gi(y.location,g,v);d=u();let x=mo(T,d),S=y.createHref(T.unstable_mask||T);a.replaceState(x,"",S),i&&l&&l({action:o,location:y.location,delta:0})}function p(g){return Uh(g)}let y={get action(){return o},get location(){return e(r,a)},listen(g){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(fo,c),l=g,()=>{r.removeEventListener(fo,c),l=null}},createHref(g){return t(r,g)},createURL:p,encodeLocation(g){let v=p(g);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:f,replace:m,go(g){return a.go(g)}};return y}function Uh(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ae(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:Gn(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function Dc(e,t,n="/"){return qh(e,t,n,!1)}function qh(e,t,n,s){let r=typeof t=="string"?Jn(t):t,i=It(r.pathname||"/",n);if(i==null)return null;let a=Lc(e);Gh(a);let o=null;for(let l=0;o==null&&l{let u={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(s)&&l)return;Ae(u.relativePath.startsWith(s),`Absolute route path "${u.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(s.length)}let c=ct([s,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(Ae(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Lc(a.children,t,f,c,l)),!(a.path==null&&!a.index)&&t.push({path:c,score:Jh(c,a.index),routesMeta:f})};return e.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))i(a,o);else for(let l of Oc(a.path))i(a,o,!0,l)}),t}function Oc(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return r?[i,""]:[i];let a=Oc(s.join("/")),o=[];return o.push(...a.map(l=>l===""?i:[i,l].join("/"))),r&&o.push(...a),o.map(l=>e.startsWith("/")&&l===""?"/":l)}function Gh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Zh(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var Hh=/^:[\w-]+$/,Wh=3,Kh=2,Qh=1,Xh=10,Yh=-2,po=e=>e==="*";function Jh(e,t){let n=e.split("/"),s=n.length;return n.some(po)&&(s+=Yh),t&&(s+=Kh),n.filter(r=>!po(r)).reduce((r,i)=>r+(Hh.test(i)?Wh:i===""?Qh:Xh),s)}function Zh(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 em(e,t,n=!1){let{routesMeta:s}=e,r={},i="/",a=[];for(let o=0;o{if(u==="*"){let p=o[f]||"";a=i.slice(0,i.length-p.length).replace(/(.)\/+$/,"$1")}const m=o[f];return c&&!m?d[u]=void 0:d[u]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:a,pattern:e}}function tm(e,t=!1,n=!0){wt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let s=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l,d,u)=>{if(s.push({paramName:o,isOptional:l!=null}),l){let c=u.charAt(d+a.length);return c&&c!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),s]}function nm(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function It(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 sm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function rm(e,t="/"){let{pathname:n,search:s="",hash:r=""}=typeof e=="string"?Jn(e):e,i;return n?(n=jc(n),n.startsWith("/")?i=go(n.substring(1),"/"):i=go(n,t)):i=t,{pathname:i,search:om(s),hash:lm(r)}}function go(e,t){let n=qs(t).split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Ar(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function im(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nc(e){let t=im(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Zi(e,t,n,s=!1){let r;typeof e=="string"?r=Jn(e):(r={...e},Ae(!r.pathname||!r.pathname.includes("?"),Ar("?","pathname","search",r)),Ae(!r.pathname||!r.pathname.includes("#"),Ar("#","pathname","hash",r)),Ae(!r.search||!r.search.includes("#"),Ar("#","search","hash",r)));let i=e===""||r.pathname==="",a=i?"/":r.pathname,o;if(a==null)o=n;else{let c=t.length-1;if(!s&&a.startsWith("..")){let f=a.split("/");for(;f[0]==="..";)f.shift(),c-=1;r.pathname=f.join("/")}o=c>=0?t[c]:"/"}let l=rm(r,o),d=a&&a!=="/"&&a.endsWith("/"),u=(i||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(d||u)&&(l.pathname+="/"),l}var jc=e=>e.replace(/\/\/+/g,"/"),ct=e=>jc(e.join("/")),qs=e=>e.replace(/\/+$/,""),am=e=>qs(e).replace(/^\/*/,"/"),om=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,lm=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cm=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 um(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function dm(e){let t=e.map(n=>n.route.path).filter(Boolean);return ct(t)||"/"}var Fc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vc(e,t){let n=e;if(typeof n!="string"||!sm.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,r=!1;if(Fc)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),o=It(a.pathname,t);a.origin===i.origin&&o!=null?n=o+a.search+a.hash:r=!0}catch{wt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Bc=["POST","PUT","PATCH","DELETE"];new Set(Bc);var fm=["GET",...Bc];new Set(fm);var Cn=h.createContext(null);Cn.displayName="DataRouter";var rr=h.createContext(null);rr.displayName="DataRouterState";var $c=h.createContext(!1);function hm(){return h.useContext($c)}var zc=h.createContext({isTransitioning:!1});zc.displayName="ViewTransition";var mm=h.createContext(new Map);mm.displayName="Fetchers";var pm=h.createContext(null);pm.displayName="Await";var tt=h.createContext(null);tt.displayName="Navigation";var ir=h.createContext(null);ir.displayName="Location";var Lt=h.createContext({outlet:null,matches:[],isDataRoute:!1});Lt.displayName="Route";var ea=h.createContext(null);ea.displayName="RouteError";var Uc="REACT_ROUTER_ERROR",gm="REDIRECT",ym="ROUTE_ERROR_RESPONSE";function bm(e){if(e.startsWith(`${Uc}:${gm}:{`))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 vm(e){if(e.startsWith(`${Uc}:${ym}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new cm(t.status,t.statusText,t.data)}catch{}}function wm(e,{relative:t}={}){Ae(Zn(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:s}=h.useContext(tt),{hash:r,pathname:i,search:a}=es(e,{relative:t}),o=i;return n!=="/"&&(o=i==="/"?n:ct([n,i])),s.createHref({pathname:o,search:a,hash:r})}function Zn(){return h.useContext(ir)!=null}function Ct(){return Ae(Zn(),"useLocation() may be used only in the context of a component."),h.useContext(ir).location}var qc="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gc(e){h.useContext(tt).static||h.useLayoutEffect(e)}function ta(){let{isDataRoute:e}=h.useContext(Lt);return e?Dm():xm()}function xm(){Ae(Zn(),"useNavigate() may be used only in the context of a component.");let e=h.useContext(Cn),{basename:t,navigator:n}=h.useContext(tt),{matches:s}=h.useContext(Lt),{pathname:r}=Ct(),i=JSON.stringify(Nc(s)),a=h.useRef(!1);return Gc(()=>{a.current=!0}),h.useCallback((l,d={})=>{if(wt(a.current,qc),!a.current)return;if(typeof l=="number"){n.go(l);return}let u=Zi(l,JSON.parse(i),r,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:ct([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,r,e])}h.createContext(null);function es(e,{relative:t}={}){let{matches:n}=h.useContext(Lt),{pathname:s}=Ct(),r=JSON.stringify(Nc(n));return h.useMemo(()=>Zi(e,JSON.parse(r),s,t==="path"),[e,r,s,t])}function Sm(e,t,n){Ae(Zn(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=h.useContext(tt),{matches:r}=h.useContext(Lt),i=r[r.length-1],a=i?i.params:{},o=i?i.pathname:"/",l=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";Wc(o,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${o}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + */var fo="popstate";function ho(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function $h(e={}){function t(s,r){let i=r.state?.masked,{pathname:a,search:o,hash:l}=i||s.location;return gi("",{pathname:a,search:o,hash:l},r.state&&r.state.usr||null,r.state&&r.state.key||"default",i?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,r){return typeof r=="string"?r:Gn(r)}return zh(t,n,null,e)}function Ae(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function wt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Bh(){return Math.random().toString(36).substring(2,10)}function mo(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 gi(e,t,n=null,s,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jn(t):t,state:n,key:t&&t.key||s||Bh(),unstable_mask:r}}function Gn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function zh(e,t,n,s={}){let{window:r=document.defaultView,v5Compat:i=!1}=s,a=r.history,o="POP",l=null,d=u();d==null&&(d=0,a.replaceState({...a.state,idx:d},""));function u(){return(a.state||{idx:null}).idx}function c(){o="POP";let g=u(),v=g==null?null:g-d;d=g,l&&l({action:o,location:y.location,delta:v})}function f(g,v){o="PUSH";let T=ho(g)?g:gi(y.location,g,v);d=u()+1;let x=mo(T,d),S=y.createHref(T.unstable_mask||T);try{a.pushState(x,"",S)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;r.location.assign(S)}i&&l&&l({action:o,location:y.location,delta:1})}function m(g,v){o="REPLACE";let T=ho(g)?g:gi(y.location,g,v);d=u();let x=mo(T,d),S=y.createHref(T.unstable_mask||T);a.replaceState(x,"",S),i&&l&&l({action:o,location:y.location,delta:0})}function p(g){return Uh(g)}let y={get action(){return o},get location(){return e(r,a)},listen(g){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(fo,c),l=g,()=>{r.removeEventListener(fo,c),l=null}},createHref(g){return t(r,g)},createURL:p,encodeLocation(g){let v=p(g);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:f,replace:m,go(g){return a.go(g)}};return y}function Uh(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ae(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:Gn(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function Dc(e,t,n="/"){return qh(e,t,n,!1)}function qh(e,t,n,s){let r=typeof t=="string"?Jn(t):t,i=It(r.pathname||"/",n);if(i==null)return null;let a=Lc(e);Gh(a);let o=null;for(let l=0;o==null&&l{let u={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(s)&&l)return;Ae(u.relativePath.startsWith(s),`Absolute route path "${u.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(s.length)}let c=ct([s,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(Ae(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Lc(a.children,t,f,c,l)),!(a.path==null&&!a.index)&&t.push({path:c,score:Jh(c,a.index),routesMeta:f})};return e.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))i(a,o);else for(let l of Oc(a.path))i(a,o,!0,l)}),t}function Oc(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return r?[i,""]:[i];let a=Oc(s.join("/")),o=[];return o.push(...a.map(l=>l===""?i:[i,l].join("/"))),r&&o.push(...a),o.map(l=>e.startsWith("/")&&l===""?"/":l)}function Gh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Zh(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var Hh=/^:[\w-]+$/,Wh=3,Kh=2,Qh=1,Xh=10,Yh=-2,po=e=>e==="*";function Jh(e,t){let n=e.split("/"),s=n.length;return n.some(po)&&(s+=Yh),t&&(s+=Kh),n.filter(r=>!po(r)).reduce((r,i)=>r+(Hh.test(i)?Wh:i===""?Qh:Xh),s)}function Zh(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 em(e,t,n=!1){let{routesMeta:s}=e,r={},i="/",a=[];for(let o=0;o{if(u==="*"){let p=o[f]||"";a=i.slice(0,i.length-p.length).replace(/(.)\/+$/,"$1")}const m=o[f];return c&&!m?d[u]=void 0:d[u]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:a,pattern:e}}function tm(e,t=!1,n=!0){wt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let s=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l,d,u)=>{if(s.push({paramName:o,isOptional:l!=null}),l){let c=u.charAt(d+a.length);return c&&c!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),s]}function nm(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function It(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 sm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function rm(e,t="/"){let{pathname:n,search:s="",hash:r=""}=typeof e=="string"?Jn(e):e,i;return n?(n=jc(n),n.startsWith("/")?i=go(n.substring(1),"/"):i=go(n,t)):i=t,{pathname:i,search:om(s),hash:lm(r)}}function go(e,t){let n=qs(t).split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Ar(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function im(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nc(e){let t=im(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Zi(e,t,n,s=!1){let r;typeof e=="string"?r=Jn(e):(r={...e},Ae(!r.pathname||!r.pathname.includes("?"),Ar("?","pathname","search",r)),Ae(!r.pathname||!r.pathname.includes("#"),Ar("#","pathname","hash",r)),Ae(!r.search||!r.search.includes("#"),Ar("#","search","hash",r)));let i=e===""||r.pathname==="",a=i?"/":r.pathname,o;if(a==null)o=n;else{let c=t.length-1;if(!s&&a.startsWith("..")){let f=a.split("/");for(;f[0]==="..";)f.shift(),c-=1;r.pathname=f.join("/")}o=c>=0?t[c]:"/"}let l=rm(r,o),d=a&&a!=="/"&&a.endsWith("/"),u=(i||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(d||u)&&(l.pathname+="/"),l}var jc=e=>e.replace(/\/\/+/g,"/"),ct=e=>jc(e.join("/")),qs=e=>e.replace(/\/+$/,""),am=e=>qs(e).replace(/^\/*/,"/"),om=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,lm=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cm=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 um(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function dm(e){let t=e.map(n=>n.route.path).filter(Boolean);return ct(t)||"/"}var Fc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vc(e,t){let n=e;if(typeof n!="string"||!sm.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,r=!1;if(Fc)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),o=It(a.pathname,t);a.origin===i.origin&&o!=null?n=o+a.search+a.hash:r=!0}catch{wt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var $c=["POST","PUT","PATCH","DELETE"];new Set($c);var fm=["GET",...$c];new Set(fm);var Cn=h.createContext(null);Cn.displayName="DataRouter";var rr=h.createContext(null);rr.displayName="DataRouterState";var Bc=h.createContext(!1);function hm(){return h.useContext(Bc)}var zc=h.createContext({isTransitioning:!1});zc.displayName="ViewTransition";var mm=h.createContext(new Map);mm.displayName="Fetchers";var pm=h.createContext(null);pm.displayName="Await";var tt=h.createContext(null);tt.displayName="Navigation";var ir=h.createContext(null);ir.displayName="Location";var Lt=h.createContext({outlet:null,matches:[],isDataRoute:!1});Lt.displayName="Route";var ea=h.createContext(null);ea.displayName="RouteError";var Uc="REACT_ROUTER_ERROR",gm="REDIRECT",ym="ROUTE_ERROR_RESPONSE";function bm(e){if(e.startsWith(`${Uc}:${gm}:{`))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 vm(e){if(e.startsWith(`${Uc}:${ym}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new cm(t.status,t.statusText,t.data)}catch{}}function wm(e,{relative:t}={}){Ae(Zn(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:s}=h.useContext(tt),{hash:r,pathname:i,search:a}=es(e,{relative:t}),o=i;return n!=="/"&&(o=i==="/"?n:ct([n,i])),s.createHref({pathname:o,search:a,hash:r})}function Zn(){return h.useContext(ir)!=null}function Ct(){return Ae(Zn(),"useLocation() may be used only in the context of a component."),h.useContext(ir).location}var qc="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gc(e){h.useContext(tt).static||h.useLayoutEffect(e)}function ta(){let{isDataRoute:e}=h.useContext(Lt);return e?Dm():xm()}function xm(){Ae(Zn(),"useNavigate() may be used only in the context of a component.");let e=h.useContext(Cn),{basename:t,navigator:n}=h.useContext(tt),{matches:s}=h.useContext(Lt),{pathname:r}=Ct(),i=JSON.stringify(Nc(s)),a=h.useRef(!1);return Gc(()=>{a.current=!0}),h.useCallback((l,d={})=>{if(wt(a.current,qc),!a.current)return;if(typeof l=="number"){n.go(l);return}let u=Zi(l,JSON.parse(i),r,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:ct([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,r,e])}h.createContext(null);function es(e,{relative:t}={}){let{matches:n}=h.useContext(Lt),{pathname:s}=Ct(),r=JSON.stringify(Nc(n));return h.useMemo(()=>Zi(e,JSON.parse(r),s,t==="path"),[e,r,s,t])}function Sm(e,t,n){Ae(Zn(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=h.useContext(tt),{matches:r}=h.useContext(Lt),i=r[r.length-1],a=i?i.params:{},o=i?i.pathname:"/",l=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";Wc(o,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${o}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. -Please change the parent to .`)}let u=Ct(),c;c=u;let f=c.pathname||"/",m=f;if(l!=="/"){let g=l.replace(/^\//,"").split("/");m="/"+f.replace(/^\//,"").split("/").slice(g.length).join("/")}let p=Dc(e,{pathname:m});return wt(d||p!=null,`No routes matched location "${c.pathname}${c.search}${c.hash}" `),wt(p==null||p[p.length-1].route.element!==void 0||p[p.length-1].route.Component!==void 0||p[p.length-1].route.lazy!==void 0,`Matched leaf route at location "${c.pathname}${c.search}${c.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`),km(p&&p.map(g=>Object.assign({},g,{params:Object.assign({},a,g.params),pathname:ct([l,s.encodeLocation?s.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?l:ct([l,s.encodeLocation?s.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),r,n)}function Tm(){let e=Im(),t=um(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:s},i={padding:"2px 4px",backgroundColor:s},a=null;return console.error("Error handled by React Router default ErrorBoundary:",e),a=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:i},"ErrorBoundary")," or"," ",h.createElement("code",{style:i},"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,a)}var Cm=h.createElement(Tm,null),Hc=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=vm(e.digest);n&&(e=n)}let t=e!==void 0?h.createElement(Lt.Provider,{value:this.props.routeContext},h.createElement(ea.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(Pm,{error:e},t):t}};Hc.contextType=$c;var Rr=new WeakMap;function Pm({children:e,error:t}){let{basename:n}=h.useContext(tt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=bm(t.digest);if(s){let r=Rr.get(t);if(r)throw r;let i=Vc(s.location,n);if(Fc&&!Rr.get(t))if(i.isExternal||s.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:s.replace}));throw Rr.set(t,a),a}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Em({routeContext:e,match:t,children:n}){let s=h.useContext(Cn);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),h.createElement(Lt.Provider,{value:e},n)}function km(e,t=[],n){let s=n?.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let r=e,i=s?.errors;if(i!=null){let u=r.findIndex(c=>c.route.id&&i?.[c.route.id]!==void 0);Ae(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),r=r.slice(0,Math.min(r.length,u+1))}let a=!1,o=-1;if(n&&s){a=s.renderFallback;for(let u=0;u=0?r=r.slice(0,o+1):r=[r[0]];break}}}}let l=n?.onError,d=s&&l?(u,c)=>{l(u,{location:s.location,params:s.matches?.[0]?.params??{},unstable_pattern:dm(s.matches),errorInfo:c})}:void 0;return r.reduceRight((u,c,f)=>{let m,p=!1,y=null,g=null;s&&(m=i&&c.route.id?i[c.route.id]:void 0,y=c.route.errorElement||Cm,a&&(o<0&&f===0?(Wc("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):o===f&&(p=!0,g=c.route.hydrateFallbackElement||null)));let v=t.concat(r.slice(0,f+1)),T=()=>{let x;return m?x=y:p?x=g:c.route.Component?x=h.createElement(c.route.Component,null):c.route.element?x=c.route.element:x=u,h.createElement(Em,{match:c,routeContext:{outlet:u,matches:v,isDataRoute:s!=null},children:x})};return s&&(c.route.ErrorBoundary||c.route.errorElement||f===0)?h.createElement(Hc,{location:s.location,revalidation:s.revalidation,component:y,error:m,children:T(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:d}):T()},null)}function na(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Am(e){let t=h.useContext(Cn);return Ae(t,na(e)),t}function Rm(e){let t=h.useContext(rr);return Ae(t,na(e)),t}function Mm(e){let t=h.useContext(Lt);return Ae(t,na(e)),t}function sa(e){let t=Mm(e),n=t.matches[t.matches.length-1];return Ae(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function _m(){return sa("useRouteId")}function Im(){let e=h.useContext(ea),t=Rm("useRouteError"),n=sa("useRouteError");return e!==void 0?e:t.errors?.[n]}function Dm(){let{router:e}=Am("useNavigate"),t=sa("useNavigate"),n=h.useRef(!1);return Gc(()=>{n.current=!0}),h.useCallback(async(r,i={})=>{wt(n.current,qc),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var yo={};function Wc(e,t,n){!t&&!yo[e]&&(yo[e]=!0,wt(!1,n))}h.memo(Lm);function Lm({routes:e,future:t,state:n,isStatic:s,onError:r}){return Sm(e,void 0,{state:n,isStatic:s,onError:r})}function Om({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:r,static:i=!1,unstable_useTransitions:a}){Ae(!Zn(),"You cannot render a inside another . You should never have more than one in your app.");let o=e.replace(/^\/*/,"/"),l=h.useMemo(()=>({basename:o,navigator:r,static:i,unstable_useTransitions:a,future:{}}),[o,r,i,a]);typeof n=="string"&&(n=Jn(n));let{pathname:d="/",search:u="",hash:c="",state:f=null,key:m="default",unstable_mask:p}=n,y=h.useMemo(()=>{let g=It(d,o);return g==null?null:{location:{pathname:g,search:u,hash:c,state:f,key:m,unstable_mask:p},navigationType:s}},[o,d,u,c,f,m,s,p]);return wt(y!=null,` is not able to match the URL "${d}${u}${c}" because it does not start with the basename, so the won't render anything.`),y==null?null:h.createElement(tt.Provider,{value:l},h.createElement(ir.Provider,{children:t,value:y}))}var As="get",Rs="application/x-www-form-urlencoded";function ar(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Nm(e){return ar(e)&&e.tagName.toLowerCase()==="button"}function jm(e){return ar(e)&&e.tagName.toLowerCase()==="form"}function Fm(e){return ar(e)&&e.tagName.toLowerCase()==="input"}function Vm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Bm(e,t){return e.button===0&&(!t||t==="_self")&&!Vm(e)}var ms=null;function $m(){if(ms===null)try{new FormData(document.createElement("form"),0),ms=!1}catch{ms=!0}return ms}var zm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Mr(e){return e!=null&&!zm.has(e)?(wt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Rs}"`),null):e}function Um(e,t){let n,s,r,i,a;if(jm(e)){let o=e.getAttribute("action");s=o?It(o,t):null,n=e.getAttribute("method")||As,r=Mr(e.getAttribute("enctype"))||Rs,i=new FormData(e)}else if(Nm(e)||Fm(e)&&(e.type==="submit"||e.type==="image")){let o=e.form;if(o==null)throw new Error('Cannot submit a