import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./markdown-Biq8ujIZ.js";import{n}from"./AuthContext-Bov8HYX4.js";import{r}from"./date-B2PNJLB2.js";import{K as i,h as a,q as o}from"./index-Bh9Wgd1K.js";var s=e(t(),1),c=200,l=e=>r(new Date(e)),u=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function d(){let{data:e,loading:t}=i(`tasks`),{data:d,loading:f}=i(`pomodoroSessions`),{data:p,loading:m}=i(`notes`),{data:h}=i(`quizSessions`),{data:g}=i(`readingSessions`),{data:_}=o(`settings/study`),{user:v}=n(),y=v?.streak?.currentStreak??v?.currentStreak??0,b=a(v);return(0,s.useMemo)(()=>{let n=r(),i=d.filter(e=>e.mode===`focus`),a=i.filter(e=>l(e.completedAt)===n).reduce((e,t)=>e+t.minutes,0),o=i.filter(e=>l(e.completedAt)===n).length,s=i.reduce((e,t)=>e+t.minutes,0),v=g.filter(e=>e.date===n).reduce((e,t)=>e+t.minutes,0),x=g.reduce((e,t)=>e+t.minutes,0),S=e.filter(e=>!e.completed),C=S.filter(e=>e.dueDate===n),w=(C.length?C:S).slice().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)).slice(0,5),T=e.filter(e=>e.completed).length,E=e.filter(e=>e.completed&&e.completedAt&&l(e.completedAt)===n).length,D=h.filter(e=>e.completedAt&&l(e.completedAt)===n).reduce((e,t)=>e+(t.xp??0),0),O=o*10+E*5+D,k=b+i.length*10+T*5+h.reduce((e,t)=>e+(t.xp??0),0),A=Math.floor(k/c)+1,j=k%c,M=new Set([...i.map(e=>l(e.completedAt)),...h.filter(e=>e.completedAt).map(e=>l(e.completedAt))]),N=0,P=new Date;for(M.has(r(P))||P.setDate(P.getDate()-1);M.has(r(P));)N++,P.setDate(P.getDate()-1);N=Math.max(N,y);let F=Array.from({length:7},(e,t)=>{let n=new Date;n.setDate(n.getDate()-(6-t));let a=r(n),o=i.filter(e=>l(e.completedAt)===a).reduce((e,t)=>e+t.minutes,0),s=g.filter(e=>e.date===a).reduce((e,t)=>e+t.minutes,0);return{day:u[n.getDay()],hours:+((o+s)/60).toFixed(1)}}),I=Array.from({length:30},(e,t)=>{let n=new Date;n.setDate(n.getDate()-(29-t));let a=r(n);return{date:a,minutes:i.filter(e=>l(e.completedAt)===a).reduce((e,t)=>e+t.minutes,0)+g.filter(e=>e.date===a).reduce((e,t)=>e+t.minutes,0)}}),L=_?.dailyHours??4,R=+((a+v)/60).toFixed(1),z=L?Math.min(1,R/L):0,B=0;return i.length>=1&&B++,i.length>=10&&B++,i.length>=50&&B++,N>=3&&B++,N>=7&&B++,T>=10&&B++,{loading:t||f||m,tasksToday:C.length,todayTasks:w,studyMinutesToday:a,studyHoursToday:R,pomodorosToday:o,notesCount:p.filter(e=>!e.archived).length,tasksDone:T,tasksDoneToday:E,xpToday:O,streak:N,xp:k,level:A,xpInLevel:j,xpForLevel:c,badges:B,week:F,last30:I,dailyGoalHours:L,goalProgress:z,totalFocusMinutes:s,focusSessions:i.length,readingMinutesToday:v,totalReadingMinutes:x}},[e,d,p,h,g,_,t,f,m,y,b])}export{d as t};